Skip to content

Commit 7b1b684

Browse files
test commit to check if load_Values_c can be dissociated from target logic
1 parent 66d21bd commit 7b1b684

File tree

3 files changed

+32
-24
lines changed

3 files changed

+32
-24
lines changed

crates/intrinsic-test/src/arm/argument.rs

+8-19
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ pub enum Constraint {
2323
Range(Range<i64>),
2424
}
2525

26+
/// ARM-specific
2627
impl TryFrom<ArgPrep> for Constraint {
2728
type Error = ();
2829

@@ -77,6 +78,7 @@ impl Argument {
7778
(arg[..split_index + 1].trim_end(), &arg[split_index + 1..])
7879
}
7980

81+
// ARM-specific
8082
pub fn from_c(pos: usize, arg: &str, arg_prep: Option<ArgPrep>) -> Argument {
8183
let (ty, var_name) = Self::type_and_name_from_c(arg);
8284

@@ -208,36 +210,23 @@ impl ArgumentList {
208210
/// Creates a line for each argument that initializes the argument from an array `[arg]_vals` at
209211
/// an offset `i` using a load intrinsic, in C.
210212
/// e.g `uint8x8_t a = vld1_u8(&a_vals[i]);`
211-
pub fn load_values_c(&self, indentation: Indentation, target: &str) -> String {
213+
///
214+
/// ARM-specific
215+
pub fn load_values_c(&self, indentation: Indentation) -> String {
212216
self.iter()
213217
.filter_map(|arg| {
214218
// The ACLE doesn't support 64-bit polynomial loads on Armv7
215219
// This and the cast are a workaround for this
216-
let armv7_p64 = if let TypeKind::Poly = arg.ty.kind() {
217-
target.contains("v7")
218-
} else {
219-
false
220-
};
221220

222221
(!arg.has_constraint()).then(|| {
223222
format!(
224-
"{indentation}{ty} {name} = {open_cast}{load}(&{name}_vals[i]){close_cast};\n",
223+
"{indentation}{ty} {name} = cast<{ty}>({load}(&{name}_vals[i]));\n",
225224
ty = arg.to_c_type(),
226225
name = arg.name,
227226
load = if arg.is_simd() {
228-
arg.ty.get_load_function(armv7_p64)
227+
arg.ty.get_load_function_c()
229228
} else {
230229
"*".to_string()
231-
},
232-
open_cast = if armv7_p64 {
233-
format!("cast<{}>(", arg.to_c_type())
234-
} else {
235-
"".to_string()
236-
},
237-
close_cast = if armv7_p64 {
238-
")".to_string()
239-
} else {
240-
"".to_string()
241230
}
242231
)
243232
})
@@ -257,7 +246,7 @@ impl ArgumentList {
257246
name = arg.name,
258247
vals_name = arg.rust_vals_array_name(),
259248
load = if arg.is_simd() {
260-
arg.ty.get_load_function(false)
249+
arg.ty.get_load_function_rust()
261250
} else {
262251
"*".to_string()
263252
},

crates/intrinsic-test/src/arm/intrinsic.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ impl Intrinsic {
8989
indentation: Indentation,
9090
additional: &str,
9191
passes: u32,
92-
target: &str,
92+
_target: &str,
9393
) -> String {
9494
let body_indentation = indentation.nested();
9595
format!(
@@ -98,7 +98,7 @@ impl Intrinsic {
9898
{body_indentation}auto __return_value = {intrinsic_call}({args});\n\
9999
{print_result}\n\
100100
{indentation}}}",
101-
loaded_args = self.arguments.load_values_c(body_indentation, target),
101+
loaded_args = self.arguments.load_values_c(body_indentation),
102102
intrinsic_call = self.name,
103103
args = self.arguments.as_call_param_c(),
104104
print_result = self.print_result_c(body_indentation, additional)

crates/intrinsic-test/src/arm/types.rs

+22-3
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,7 @@ impl IntrinsicType {
163163
}
164164
}
165165

166+
/// Move to Argument
166167
pub fn c_scalar_type(&self) -> String {
167168
format!(
168169
"{prefix}{bits}_t",
@@ -171,6 +172,7 @@ impl IntrinsicType {
171172
)
172173
}
173174

175+
/// Move to Argument
174176
pub fn rust_scalar_type(&self) -> String {
175177
format!(
176178
"{prefix}{bits}",
@@ -180,6 +182,8 @@ impl IntrinsicType {
180182
}
181183

182184
/// Gets a string containing the typename for this type in C format.
185+
///
186+
/// ARM-specific
183187
pub fn c_type(&self) -> String {
184188
match self {
185189
IntrinsicType::Ptr { child, .. } => child.c_type(),
@@ -214,6 +218,7 @@ impl IntrinsicType {
214218
}
215219
}
216220

221+
/// ARM-specific
217222
pub fn c_single_vector_type(&self) -> String {
218223
match self {
219224
IntrinsicType::Ptr { child, .. } => child.c_single_vector_type(),
@@ -228,6 +233,7 @@ impl IntrinsicType {
228233
}
229234
}
230235

236+
/// ARM-specific
231237
pub fn rust_type(&self) -> String {
232238
match self {
233239
IntrinsicType::Ptr { child, .. } => child.c_type(),
@@ -377,9 +383,11 @@ impl IntrinsicType {
377383
}
378384

379385
/// Determines the load function for this type.
380-
pub fn get_load_function(&self, armv7_p64_workaround: bool) -> String {
386+
///
387+
/// ARM-specific
388+
fn get_load_function(&self, language: Language) -> String {
381389
match self {
382-
IntrinsicType::Ptr { child, .. } => child.get_load_function(armv7_p64_workaround),
390+
IntrinsicType::Ptr { child, .. } => child.get_load_function(language),
383391
IntrinsicType::Type {
384392
kind: k,
385393
bit_len: Some(bl),
@@ -399,7 +407,7 @@ impl IntrinsicType {
399407
TypeKind::Int => "s",
400408
TypeKind::Float => "f",
401409
// The ACLE doesn't support 64-bit polynomial loads on Armv7
402-
TypeKind::Poly => if armv7_p64_workaround && *bl == 64 {"s"} else {"p"},
410+
TypeKind::Poly => if language == Language::C && *bl == 64 {"s"} else {"p"},
403411
x => todo!("get_load_function TypeKind: {:#?}", x),
404412
},
405413
size = bl,
@@ -411,7 +419,17 @@ impl IntrinsicType {
411419
}
412420
}
413421

422+
pub fn get_load_function_c(&self) -> String {
423+
self.get_load_function(Language::C)
424+
}
425+
426+
pub fn get_load_function_rust(&self) -> String {
427+
self.get_load_function(Language::Rust)
428+
}
429+
414430
/// Determines the get lane function for this type.
431+
///
432+
/// ARM-specific
415433
pub fn get_lane_function(&self) -> String {
416434
match self {
417435
IntrinsicType::Ptr { child, .. } => child.get_lane_function(),
@@ -443,6 +461,7 @@ impl IntrinsicType {
443461
}
444462
}
445463

464+
/// ARM-specific
446465
pub fn from_c(s: &str) -> Result<IntrinsicType, String> {
447466
const CONST_STR: &str = "const";
448467
if let Some(s) = s.strip_suffix('*') {

0 commit comments

Comments
 (0)