Skip to content

Commit e195070

Browse files
committed
Remove code for compiling and comparing C and Rust files, made the C files wrappers
1 parent 8a370d2 commit e195070

17 files changed

Lines changed: 90 additions & 1523 deletions

File tree

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

Lines changed: 0 additions & 51 deletions
This file was deleted.

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

Lines changed: 0 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -3,51 +3,6 @@ pub const NOTICE: &str = "\
33
// test are derived from a JSON specification, published under the same license as the
44
// `intrinsic-test` crate.\n";
55

6-
pub const PLATFORM_C_FORWARD_DECLARATIONS: &str = r#"
7-
#ifdef __aarch64__
8-
std::ostream& operator<<(std::ostream& os, poly128_t value);
9-
#endif
10-
11-
std::ostream& operator<<(std::ostream& os, float16_t value);
12-
std::ostream& operator<<(std::ostream& os, uint8_t value);
13-
14-
// T1 is the `To` type, T2 is the `From` type
15-
template<typename T1, typename T2> T1 cast(T2 x) {
16-
static_assert(sizeof(T1) == sizeof(T2), "sizeof T1 and T2 must be the same");
17-
T1 ret{};
18-
memcpy(&ret, &x, sizeof(T1));
19-
return ret;
20-
}
21-
"#;
22-
23-
pub const PLATFORM_C_DEFINITIONS: &str = r#"
24-
#ifdef __aarch64__
25-
std::ostream& operator<<(std::ostream& os, poly128_t value) {
26-
std::stringstream temp;
27-
do {
28-
int n = value % 10;
29-
value /= 10;
30-
temp << n;
31-
} while (value != 0);
32-
std::string tempstr(temp.str());
33-
std::string res(tempstr.rbegin(), tempstr.rend());
34-
os << res;
35-
return os;
36-
}
37-
38-
#endif
39-
40-
std::ostream& operator<<(std::ostream& os, float16_t value) {
41-
os << static_cast<float>(value);
42-
return os;
43-
}
44-
45-
std::ostream& operator<<(std::ostream& os, uint8_t value) {
46-
os << (unsigned int) value;
47-
return os;
48-
}
49-
"#;
50-
516
pub const PLATFORM_RUST_DEFINITIONS: &str = "";
527

538
pub const PLATFORM_RUST_CFGS: &str = r#"

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

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
mod argument;
2-
mod compile;
32
mod config;
43
mod intrinsic;
54
mod json_parser;
65
mod types;
76

87
use crate::common::SupportedArchitectureTest;
98
use crate::common::cli::ProcessedCli;
10-
use crate::common::compile_c::CppCompilation;
119
use crate::common::intrinsic::Intrinsic;
1210
use crate::common::intrinsic_helpers::TypeKind;
1311
use intrinsic::ArmIntrinsicType;
@@ -32,18 +30,12 @@ impl SupportedArchitectureTest for ArmArchitectureTest {
3230
const NOTICE: &str = config::NOTICE;
3331

3432
const PLATFORM_C_HEADERS: &[&str] = &["arm_neon.h", "arm_acle.h", "arm_fp16.h"];
35-
const PLATFORM_C_DEFINITIONS: &str = config::PLATFORM_C_DEFINITIONS;
36-
const PLATFORM_C_FORWARD_DECLARATIONS: &str = config::PLATFORM_C_FORWARD_DECLARATIONS;
3733

3834
const PLATFORM_RUST_DEFINITIONS: &str = config::PLATFORM_RUST_DEFINITIONS;
3935
const PLATFORM_RUST_CFGS: &str = config::PLATFORM_RUST_CFGS;
4036

41-
fn cpp_compilation(&self) -> Option<CppCompilation> {
42-
compile::build_cpp_compilation(&self.cli_options)
43-
}
44-
4537
fn create(cli_options: ProcessedCli) -> Self {
46-
let a32 = cli_options.target.contains("v7");
38+
let a32 = cli_options.target.starts_with("armv7");
4739
let mut intrinsics = get_neon_intrinsics(&cli_options.filename, &cli_options.target)
4840
.expect("Error parsing input file");
4941

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

Lines changed: 2 additions & 109 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
use super::intrinsic::ArmIntrinsicType;
2-
use crate::common::cli::Language;
3-
use crate::common::indentation::Indentation;
42
use crate::common::intrinsic_helpers::{IntrinsicType, IntrinsicTypeDefinition, Sign, TypeKind};
53

64
impl IntrinsicTypeDefinition for ArmIntrinsicType {
@@ -20,19 +18,8 @@ impl IntrinsicTypeDefinition for ArmIntrinsicType {
2018
}
2119
}
2220

23-
fn c_single_vector_type(&self) -> String {
24-
if let (Some(bit_len), Some(simd_len)) = (self.bit_len, self.simd_len) {
25-
format!(
26-
"{prefix}{bit_len}x{simd_len}_t",
27-
prefix = self.kind.c_prefix()
28-
)
29-
} else {
30-
unreachable!("Shouldn't be called on this type")
31-
}
32-
}
33-
3421
/// Determines the load function for this type.
35-
fn get_load_function(&self, language: Language) -> String {
22+
fn get_load_function(&self) -> String {
3623
if let IntrinsicType {
3724
kind: k,
3825
bit_len: Some(bl),
@@ -47,16 +34,13 @@ impl IntrinsicTypeDefinition for ArmIntrinsicType {
4734
""
4835
};
4936

50-
let choose_workaround = language == Language::C && self.target.contains("v7");
5137
format!(
5238
"vld{len}{quad}_{type}{size}",
5339
type = match k {
5440
TypeKind::Int(Sign::Unsigned) => "u",
5541
TypeKind::Int(Sign::Signed) => "s",
5642
TypeKind::Float => "f",
57-
// The ACLE doesn't support 64-bit polynomial loads on Armv7
58-
// if armv7 and bl == 64, use "s", else "p"
59-
TypeKind::Poly => if choose_workaround && *bl == 64 {"s"} else {"p"},
43+
TypeKind::Poly => "p",
6044
x => todo!("get_load_function TypeKind: {x:#?}"),
6145
},
6246
size = bl,
@@ -67,97 +51,6 @@ impl IntrinsicTypeDefinition for ArmIntrinsicType {
6751
todo!("get_load_function IntrinsicType: {self:#?}")
6852
}
6953
}
70-
71-
/// Determines the get lane function for this type.
72-
fn get_lane_function(&self) -> String {
73-
if let IntrinsicType {
74-
kind: k,
75-
bit_len: Some(bl),
76-
simd_len,
77-
..
78-
} = &self.data
79-
{
80-
let quad = if (simd_len.unwrap_or(1) * bl) > 64 {
81-
"q"
82-
} else {
83-
""
84-
};
85-
format!(
86-
"vget{quad}_lane_{type}{size}",
87-
type = match k {
88-
TypeKind::Int(Sign::Unsigned) => "u",
89-
TypeKind::Int(Sign::Signed) => "s",
90-
TypeKind::Float => "f",
91-
TypeKind::Poly => "p",
92-
x => todo!("get_load_function TypeKind: {x:#?}"),
93-
},
94-
size = bl,
95-
quad = quad,
96-
)
97-
} else {
98-
todo!("get_lane_function IntrinsicType: {self:#?}")
99-
}
100-
}
101-
102-
/// Generates a std::cout for the intrinsics results that will match the
103-
/// rust debug output format for the return type. The generated line assumes
104-
/// there is an int i in scope which is the current pass number.
105-
fn print_result_c(&self, indentation: Indentation, additional: &str) -> String {
106-
let lanes = if self.num_vectors() > 1 {
107-
(0..self.num_vectors())
108-
.map(|vector| {
109-
format!(
110-
r#""{ty}(" << {lanes} << ")""#,
111-
ty = self.c_single_vector_type(),
112-
lanes = (0..self.num_lanes())
113-
.map(move |idx| -> std::string::String {
114-
let lane_fn = self.get_lane_function();
115-
let final_cast = self.generate_final_type_cast();
116-
format!(
117-
"{final_cast}{lane_fn}(__return_value.val[{vector}], {idx})"
118-
)
119-
})
120-
.collect::<Vec<_>>()
121-
.join(r#" << ", " << "#)
122-
)
123-
})
124-
.collect::<Vec<_>>()
125-
.join(r#" << ", " << "#)
126-
} else if self.num_lanes() > 1 {
127-
(0..self.num_lanes())
128-
.map(|idx| -> std::string::String {
129-
let lane_fn = self.get_lane_function();
130-
let final_cast = self.generate_final_type_cast();
131-
format!("{final_cast}{lane_fn}(__return_value, {idx})")
132-
})
133-
.collect::<Vec<_>>()
134-
.join(r#" << ", " << "#)
135-
} else {
136-
format!(
137-
"{promote}cast<{cast}>(__return_value)",
138-
cast = match self.kind() {
139-
TypeKind::Float if self.inner_size() == 16 => "float16_t".to_string(),
140-
TypeKind::Float if self.inner_size() == 32 => "float".to_string(),
141-
TypeKind::Float if self.inner_size() == 64 => "double".to_string(),
142-
TypeKind::Int(Sign::Signed) => format!("int{}_t", self.inner_size()),
143-
TypeKind::Int(Sign::Unsigned) => format!("uint{}_t", self.inner_size()),
144-
TypeKind::Poly => format!("poly{}_t", self.inner_size()),
145-
ty => todo!("print_result_c - Unknown type: {ty:#?}"),
146-
},
147-
promote = self.generate_final_type_cast(),
148-
)
149-
};
150-
151-
format!(
152-
r#"{indentation}std::cout << "Result {additional}-" << i+1 << ": {ty}" << std::fixed << std::setprecision(150) << {lanes} << "{close}" << std::endl;"#,
153-
ty = if self.is_simd() {
154-
format!("{}(", self.c_type())
155-
} else {
156-
String::from("")
157-
},
158-
close = if self.is_simd() { ")" } else { "" },
159-
)
160-
}
16154
}
16255

16356
impl ArmIntrinsicType {

0 commit comments

Comments
 (0)