test commit to check if load_Values_c can be dissociated from target logic
This commit is contained in:
parent
bb1dfa0276
commit
9927915e58
3 changed files with 32 additions and 24 deletions
|
|
@ -23,6 +23,7 @@ pub enum Constraint {
|
|||
Range(Range<i64>),
|
||||
}
|
||||
|
||||
/// ARM-specific
|
||||
impl TryFrom<ArgPrep> for Constraint {
|
||||
type Error = ();
|
||||
|
||||
|
|
@ -77,6 +78,7 @@ impl Argument {
|
|||
(arg[..split_index + 1].trim_end(), &arg[split_index + 1..])
|
||||
}
|
||||
|
||||
// ARM-specific
|
||||
pub fn from_c(pos: usize, arg: &str, arg_prep: Option<ArgPrep>) -> Argument {
|
||||
let (ty, var_name) = Self::type_and_name_from_c(arg);
|
||||
|
||||
|
|
@ -208,36 +210,23 @@ impl ArgumentList {
|
|||
/// Creates a line for each argument that initializes the argument from an array `[arg]_vals` at
|
||||
/// an offset `i` using a load intrinsic, in C.
|
||||
/// e.g `uint8x8_t a = vld1_u8(&a_vals[i]);`
|
||||
pub fn load_values_c(&self, indentation: Indentation, target: &str) -> String {
|
||||
///
|
||||
/// ARM-specific
|
||||
pub fn load_values_c(&self, indentation: Indentation) -> String {
|
||||
self.iter()
|
||||
.filter_map(|arg| {
|
||||
// The ACLE doesn't support 64-bit polynomial loads on Armv7
|
||||
// This and the cast are a workaround for this
|
||||
let armv7_p64 = if let TypeKind::Poly = arg.ty.kind() {
|
||||
target.contains("v7")
|
||||
} else {
|
||||
false
|
||||
};
|
||||
|
||||
(!arg.has_constraint()).then(|| {
|
||||
format!(
|
||||
"{indentation}{ty} {name} = {open_cast}{load}(&{name}_vals[i]){close_cast};\n",
|
||||
"{indentation}{ty} {name} = cast<{ty}>({load}(&{name}_vals[i]));\n",
|
||||
ty = arg.to_c_type(),
|
||||
name = arg.name,
|
||||
load = if arg.is_simd() {
|
||||
arg.ty.get_load_function(armv7_p64)
|
||||
arg.ty.get_load_function_c()
|
||||
} else {
|
||||
"*".to_string()
|
||||
},
|
||||
open_cast = if armv7_p64 {
|
||||
format!("cast<{}>(", arg.to_c_type())
|
||||
} else {
|
||||
"".to_string()
|
||||
},
|
||||
close_cast = if armv7_p64 {
|
||||
")".to_string()
|
||||
} else {
|
||||
"".to_string()
|
||||
}
|
||||
)
|
||||
})
|
||||
|
|
@ -257,7 +246,7 @@ impl ArgumentList {
|
|||
name = arg.name,
|
||||
vals_name = arg.rust_vals_array_name(),
|
||||
load = if arg.is_simd() {
|
||||
arg.ty.get_load_function(false)
|
||||
arg.ty.get_load_function_rust()
|
||||
} else {
|
||||
"*".to_string()
|
||||
},
|
||||
|
|
|
|||
|
|
@ -89,7 +89,7 @@ impl Intrinsic {
|
|||
indentation: Indentation,
|
||||
additional: &str,
|
||||
passes: u32,
|
||||
target: &str,
|
||||
_target: &str,
|
||||
) -> String {
|
||||
let body_indentation = indentation.nested();
|
||||
format!(
|
||||
|
|
@ -98,7 +98,7 @@ impl Intrinsic {
|
|||
{body_indentation}auto __return_value = {intrinsic_call}({args});\n\
|
||||
{print_result}\n\
|
||||
{indentation}}}",
|
||||
loaded_args = self.arguments.load_values_c(body_indentation, target),
|
||||
loaded_args = self.arguments.load_values_c(body_indentation),
|
||||
intrinsic_call = self.name,
|
||||
args = self.arguments.as_call_param_c(),
|
||||
print_result = self.print_result_c(body_indentation, additional)
|
||||
|
|
|
|||
|
|
@ -163,6 +163,7 @@ impl IntrinsicType {
|
|||
}
|
||||
}
|
||||
|
||||
/// Move to Argument
|
||||
pub fn c_scalar_type(&self) -> String {
|
||||
format!(
|
||||
"{prefix}{bits}_t",
|
||||
|
|
@ -171,6 +172,7 @@ impl IntrinsicType {
|
|||
)
|
||||
}
|
||||
|
||||
/// Move to Argument
|
||||
pub fn rust_scalar_type(&self) -> String {
|
||||
format!(
|
||||
"{prefix}{bits}",
|
||||
|
|
@ -180,6 +182,8 @@ impl IntrinsicType {
|
|||
}
|
||||
|
||||
/// Gets a string containing the typename for this type in C format.
|
||||
///
|
||||
/// ARM-specific
|
||||
pub fn c_type(&self) -> String {
|
||||
match self {
|
||||
IntrinsicType::Ptr { child, .. } => child.c_type(),
|
||||
|
|
@ -214,6 +218,7 @@ impl IntrinsicType {
|
|||
}
|
||||
}
|
||||
|
||||
/// ARM-specific
|
||||
pub fn c_single_vector_type(&self) -> String {
|
||||
match self {
|
||||
IntrinsicType::Ptr { child, .. } => child.c_single_vector_type(),
|
||||
|
|
@ -228,6 +233,7 @@ impl IntrinsicType {
|
|||
}
|
||||
}
|
||||
|
||||
/// ARM-specific
|
||||
pub fn rust_type(&self) -> String {
|
||||
match self {
|
||||
IntrinsicType::Ptr { child, .. } => child.c_type(),
|
||||
|
|
@ -377,9 +383,11 @@ impl IntrinsicType {
|
|||
}
|
||||
|
||||
/// Determines the load function for this type.
|
||||
pub fn get_load_function(&self, armv7_p64_workaround: bool) -> String {
|
||||
///
|
||||
/// ARM-specific
|
||||
fn get_load_function(&self, language: Language) -> String {
|
||||
match self {
|
||||
IntrinsicType::Ptr { child, .. } => child.get_load_function(armv7_p64_workaround),
|
||||
IntrinsicType::Ptr { child, .. } => child.get_load_function(language),
|
||||
IntrinsicType::Type {
|
||||
kind: k,
|
||||
bit_len: Some(bl),
|
||||
|
|
@ -399,7 +407,7 @@ impl IntrinsicType {
|
|||
TypeKind::Int => "s",
|
||||
TypeKind::Float => "f",
|
||||
// The ACLE doesn't support 64-bit polynomial loads on Armv7
|
||||
TypeKind::Poly => if armv7_p64_workaround && *bl == 64 {"s"} else {"p"},
|
||||
TypeKind::Poly => if language == Language::C && *bl == 64 {"s"} else {"p"},
|
||||
x => todo!("get_load_function TypeKind: {:#?}", x),
|
||||
},
|
||||
size = bl,
|
||||
|
|
@ -411,7 +419,17 @@ impl IntrinsicType {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn get_load_function_c(&self) -> String {
|
||||
self.get_load_function(Language::C)
|
||||
}
|
||||
|
||||
pub fn get_load_function_rust(&self) -> String {
|
||||
self.get_load_function(Language::Rust)
|
||||
}
|
||||
|
||||
/// Determines the get lane function for this type.
|
||||
///
|
||||
/// ARM-specific
|
||||
pub fn get_lane_function(&self) -> String {
|
||||
match self {
|
||||
IntrinsicType::Ptr { child, .. } => child.get_lane_function(),
|
||||
|
|
@ -443,6 +461,7 @@ impl IntrinsicType {
|
|||
}
|
||||
}
|
||||
|
||||
/// ARM-specific
|
||||
pub fn from_c(s: &str) -> Result<IntrinsicType, String> {
|
||||
const CONST_STR: &str = "const";
|
||||
if let Some(s) = s.strip_suffix('*') {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue