From 9927915e58e8e079bb22ce622685a3d70b41603a Mon Sep 17 00:00:00 2001 From: Madhav Madhusoodanan Date: Mon, 14 Apr 2025 00:13:05 +0530 Subject: [PATCH] test commit to check if `load_Values_c` can be dissociated from target logic --- .../crates/intrinsic-test/src/arm/argument.rs | 27 ++++++------------- .../intrinsic-test/src/arm/intrinsic.rs | 4 +-- .../crates/intrinsic-test/src/arm/types.rs | 25 ++++++++++++++--- 3 files changed, 32 insertions(+), 24 deletions(-) diff --git a/library/stdarch/crates/intrinsic-test/src/arm/argument.rs b/library/stdarch/crates/intrinsic-test/src/arm/argument.rs index e354ba765a76..5edfca0b3688 100644 --- a/library/stdarch/crates/intrinsic-test/src/arm/argument.rs +++ b/library/stdarch/crates/intrinsic-test/src/arm/argument.rs @@ -23,6 +23,7 @@ pub enum Constraint { Range(Range), } +/// ARM-specific impl TryFrom 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) -> 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() }, diff --git a/library/stdarch/crates/intrinsic-test/src/arm/intrinsic.rs b/library/stdarch/crates/intrinsic-test/src/arm/intrinsic.rs index e9275072a98d..b2d242ab7360 100644 --- a/library/stdarch/crates/intrinsic-test/src/arm/intrinsic.rs +++ b/library/stdarch/crates/intrinsic-test/src/arm/intrinsic.rs @@ -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) diff --git a/library/stdarch/crates/intrinsic-test/src/arm/types.rs b/library/stdarch/crates/intrinsic-test/src/arm/types.rs index 98fcac4e00fc..a27651a3c055 100644 --- a/library/stdarch/crates/intrinsic-test/src/arm/types.rs +++ b/library/stdarch/crates/intrinsic-test/src/arm/types.rs @@ -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 { const CONST_STR: &str = "const"; if let Some(s) = s.strip_suffix('*') {