Skip to content

Fix - AArch64 Big Endian Intrinsics #1708

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 13 commits into from
Feb 24, 2025
Prev Previous commit
Next Next commit
fix test runner for armv7
  • Loading branch information
Jamesbarford committed Feb 20, 2025
commit 3b49a07f70e39da1e2da497e67fd2b87ac2b2bf0
4 changes: 2 additions & 2 deletions crates/intrinsic-test/src/argument.rs
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ impl ArgumentList {
ty = arg.to_c_type(),
name = arg.name,
load = if arg.is_simd() {
arg.ty.get_load_function(target)
arg.ty.get_load_function(armv7_p64)
} else {
"*".to_string()
},
Expand Down Expand Up @@ -258,7 +258,7 @@ impl ArgumentList {
name = arg.name,
vals_name = arg.rust_vals_array_name(),
load = if arg.is_simd() {
arg.ty.get_load_function("__")
arg.ty.get_load_function(false)
} else {
"*".to_string()
},
Expand Down
59 changes: 39 additions & 20 deletions crates/intrinsic-test/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -201,10 +201,10 @@ fn main() {{
{passes}
}}
"#,
target_arch = if target.starts_with("aarch64") {
"aarch64"
} else {
target_arch = if target.contains("v7") {
"arm"
} else {
"aarch64"
},
arglists = intrinsic
.arguments
Expand All @@ -226,10 +226,10 @@ fn compile_c(
cxx_toolchain_dir: Option<&str>,
) -> bool {
let flags = std::env::var("CPPFLAGS").unwrap_or("".into());
let arch_flags = if target.starts_with("aarch64") {
"-march=armv8.6-a+crypto+sha3+crc+dotprod"
} else {
let arch_flags = if target.contains("v7") {
"-march=armv8.6-a+crypto+crc+dotprod"
} else {
"-march=armv8.6-a+crypto+sha3+crc+dotprod"
};

let intrinsic_name = &intrinsic.name;
Expand Down Expand Up @@ -394,7 +394,6 @@ path = "{intrinsic}/main.rs""#,

/* If there has been a linker explicitly set from the command line then
* we want to set it via setting it in the RUSTFLAGS*/
let mut rust_flags = "-Cdebuginfo=0".to_string();

let cargo_command = format!(
"cargo {toolchain} build --target {target} --release",
Expand All @@ -403,12 +402,12 @@ path = "{intrinsic}/main.rs""#,
);

let mut command = Command::new("sh");

command
.current_dir("rust_programs")
.arg("-c")
.arg(cargo_command);

let mut rust_flags = "-Cdebuginfo=0".to_string();
if let Some(linker) = linker {
rust_flags.push_str(" -C linker=");
rust_flags.push_str(linker);
Expand All @@ -418,6 +417,7 @@ path = "{intrinsic}/main.rs""#,
}

command.env("RUSTFLAGS", rust_flags);
println!("{:?}", command);
let output = command.output();

if let Ok(output) = output {
Expand Down Expand Up @@ -552,8 +552,8 @@ fn main() {
std::process::exit(3);
}

if let Some(ref _toolchain) = toolchain {
if !compare_outputs(&intrinsics, &c_runner, target) {
if let Some(ref toolchain) = toolchain {
if !compare_outputs(&intrinsics, toolchain, &c_runner, target) {
std::process::exit(1)
}
}
Expand All @@ -565,7 +565,12 @@ enum FailureReason {
Difference(String, String, String),
}

fn compare_outputs(intrinsics: &Vec<Intrinsic>, runner: &str, target: &str) -> bool {
fn compare_outputs(
intrinsics: &Vec<Intrinsic>,
toolchain: &str,
runner: &str,
target: &str,
) -> bool {
let intrinsics = intrinsics
.par_iter()
.filter_map(|intrinsic| {
Expand All @@ -578,15 +583,29 @@ fn compare_outputs(intrinsics: &Vec<Intrinsic>, runner: &str, target: &str) -> b
))
.output();

let rust = Command::new("sh")
.arg("-c")
.arg(format!(
"{runner} ./rust_programs/target/{target}/release/{intrinsic}",
runner = runner,
target = target,
intrinsic = intrinsic.name,
))
.output();
let rust = if target != "aarch64_be-none-linux-gnu" {
Command::new("sh")
.current_dir("rust_programs")
.arg("-c")
.arg(format!(
"cargo {toolchain} run --target {target} --bin {intrinsic} --release",
intrinsic = intrinsic.name,
toolchain = toolchain,
target = target
))
.env("RUSTFLAGS", "-Cdebuginfo=0")
.output()
} else {
Command::new("sh")
.arg("-c")
.arg(format!(
"{runner} ./rust_programs/target/{target}/release/{intrinsic}",
runner = runner,
target = target,
intrinsic = intrinsic.name,
))
.output()
};

let (c, rust) = match (c, rust) {
(Ok(c), Ok(rust)) => (c, rust),
Expand Down
6 changes: 3 additions & 3 deletions crates/intrinsic-test/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -375,9 +375,9 @@ impl IntrinsicType {
}

/// Determines the load function for this type.
pub fn get_load_function(&self, target: &str) -> String {
pub fn get_load_function(&self, armv7_p64_workaround: bool) -> String {
match self {
IntrinsicType::Ptr { child, .. } => child.get_load_function(target),
IntrinsicType::Ptr { child, .. } => child.get_load_function(armv7_p64_workaround),
IntrinsicType::Type {
kind: k,
bit_len: Some(bl),
Expand All @@ -397,7 +397,7 @@ impl IntrinsicType {
TypeKind::Int => "s",
TypeKind::Float => "f",
// The ACLE doesn't support 64-bit polynomial loads on Armv7
TypeKind::Poly => if target.starts_with("armv7") && *bl == 64 {"s"} else {"p"},
TypeKind::Poly => if armv7_p64_workaround && *bl == 64 {"s"} else {"p"},
x => todo!("get_load_function TypeKind: {:#?}", x),
},
size = bl,
Expand Down