Skip to content

Commit e72b4c1

Browse files
moved more code generation functionality to common
1 parent 5ac0c71 commit e72b4c1

File tree

7 files changed

+301
-286
lines changed

7 files changed

+301
-286
lines changed
+64
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
use crate::common::compile_c::CompilationCommandBuilder;
2+
use crate::common::gen_c::compile_c;
3+
4+
pub fn compile_c_arm(
5+
intrinsics_name_list: &Vec<String>,
6+
compiler: &str,
7+
target: &str,
8+
cxx_toolchain_dir: Option<&str>,
9+
) -> bool {
10+
// -ffp-contract=off emulates Rust's approach of not fusing separate mul-add operations
11+
let mut command = CompilationCommandBuilder::new()
12+
.add_arch_flags(vec!["armv8.6-a", "crypto", "crc", "dotprod", "fp16"])
13+
.set_compiler(compiler)
14+
.set_target(target)
15+
.set_opt_level("2")
16+
.set_cxx_toolchain_dir(cxx_toolchain_dir)
17+
.set_project_root("c_programs")
18+
.add_extra_flags(vec!["-ffp-contract=off", "-Wno-narrowing"]);
19+
20+
if !target.contains("v7") {
21+
command = command.add_arch_flags(vec!["faminmax", "lut", "sha3"]);
22+
}
23+
24+
/*
25+
* clang++ cannot link an aarch64_be object file, so we invoke
26+
* aarch64_be-unknown-linux-gnu's C++ linker. This ensures that we
27+
* are testing the intrinsics against LLVM.
28+
*
29+
* Note: setting `--sysroot=<...>` which is the obvious thing to do
30+
* does not work as it gets caught up with `#include_next <stdlib.h>`
31+
* not existing...
32+
*/
33+
if target.contains("aarch64_be") {
34+
command = command
35+
.set_linker(
36+
cxx_toolchain_dir.unwrap_or("").to_string() + "/bin/aarch64_be-none-linux-gnu-g++",
37+
)
38+
.set_include_paths(vec![
39+
"/include",
40+
"/aarch64_be-none-linux-gnu/include",
41+
"/aarch64_be-none-linux-gnu/include/c++/14.2.1",
42+
"/aarch64_be-none-linux-gnu/include/c++/14.2.1/aarch64_be-none-linux-gnu",
43+
"/aarch64_be-none-linux-gnu/include/c++/14.2.1/backward",
44+
"/aarch64_be-none-linux-gnu/libc/usr/include",
45+
]);
46+
}
47+
48+
if !compiler.contains("clang") {
49+
command = command.add_extra_flag("-flax-vector-conversions");
50+
}
51+
52+
let compiler_commands = intrinsics_name_list
53+
.iter()
54+
.map(|intrinsic_name| {
55+
command
56+
.clone()
57+
.set_input_name(intrinsic_name)
58+
.set_output_name(intrinsic_name)
59+
.to_string()
60+
})
61+
.collect::<Vec<_>>();
62+
63+
compile_c(&compiler_commands)
64+
}

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

-270
This file was deleted.

0 commit comments

Comments
 (0)