diff --git a/library/stdarch/crates/intrinsic-test/README.md b/library/stdarch/crates/intrinsic-test/README.md
index 2e53230ddd40..260d59fca80f 100644
--- a/library/stdarch/crates/intrinsic-test/README.md
+++ b/library/stdarch/crates/intrinsic-test/README.md
@@ -7,9 +7,10 @@ USAGE:
intrinsic-test [FLAGS] [OPTIONS]
FLAGS:
- --a32 Run tests for A32 instrinsics instead of A64
- -h, --help Prints help information
- -V, --version Prints version information
+ --a32 Run tests for A32 instrinsics instead of A64
+ --generate-only Regenerate test programs, but don't build or run them
+ -h, --help Prints help information
+ -V, --version Prints version information
OPTIONS:
--cppcompiler The C++ compiler to use for compiling the c++ code [default: clang++]
diff --git a/library/stdarch/crates/intrinsic-test/src/main.rs b/library/stdarch/crates/intrinsic-test/src/main.rs
index 297f76951a8e..4890bf5aab3c 100644
--- a/library/stdarch/crates/intrinsic-test/src/main.rs
+++ b/library/stdarch/crates/intrinsic-test/src/main.rs
@@ -232,7 +232,7 @@ fn build_notices(line_prefix: &str) -> String {
)
}
-fn build_c(notices: &str, intrinsics: &Vec, compiler: &str, a32: bool) -> bool {
+fn build_c(notices: &str, intrinsics: &Vec, compiler: Option<&str>, a32: bool) -> bool {
let _ = std::fs::create_dir("c_programs");
intrinsics
.par_iter()
@@ -242,13 +242,16 @@ fn build_c(notices: &str, intrinsics: &Vec, compiler: &str, a32: bool
let c_code = generate_c_program(notices, &["arm_neon.h", "arm_acle.h"], &i, a32);
file.write_all(c_code.into_bytes().as_slice()).unwrap();
- compile_c(&c_filename, &i, compiler, a32)
+ match compiler {
+ None => true,
+ Some(compiler) => compile_c(&c_filename, &i, compiler, a32),
+ }
})
.find_any(|x| !x)
.is_none()
}
-fn build_rust(notices: &str, intrinsics: &[Intrinsic], toolchain: &str, a32: bool) -> bool {
+fn build_rust(notices: &str, intrinsics: &[Intrinsic], toolchain: Option<&str>, a32: bool) -> bool {
intrinsics.iter().for_each(|i| {
let rust_dir = format!(r#"rust_programs/{}"#, i.name);
let _ = std::fs::create_dir_all(&rust_dir);
@@ -296,6 +299,11 @@ path = "{intrinsic}/main.rs""#,
)
.unwrap();
+ let toolchain = match toolchain {
+ None => return true,
+ Some(t) => t,
+ };
+
let output = Command::new("sh")
.current_dir("rust_programs")
.arg("-c")
@@ -356,6 +364,10 @@ struct Cli {
/// Run tests for A32 instrinsics instead of A64
#[arg(long)]
a32: bool,
+
+ /// Regenerate test programs, but don't build or run them
+ #[arg(long)]
+ generate_only: bool,
}
fn main() {
@@ -364,8 +376,6 @@ fn main() {
let args: Cli = clap::Parser::parse();
let filename = args.input;
- let toolchain = args.toolchain.map_or_else(String::new, |t| format!("+{t}"));
- let cpp_compiler = args.cppcompiler;
let c_runner = args.runner.unwrap_or_else(String::new);
let skip = if let Some(filename) = args.skip {
let data = std::fs::read_to_string(&filename).expect("Failed to open file");
@@ -403,18 +413,29 @@ fn main() {
.collect::>();
intrinsics.dedup();
+ let (toolchain, cpp_compiler) = if args.generate_only {
+ (None, None)
+ } else {
+ (
+ Some(args.toolchain.map_or_else(String::new, |t| format!("+{t}"))),
+ Some(args.cppcompiler),
+ )
+ };
+
let notices = build_notices("// ");
- if !build_c(¬ices, &intrinsics, &cpp_compiler, a32) {
+ if !build_c(¬ices, &intrinsics, cpp_compiler.as_deref(), a32) {
std::process::exit(2);
}
- if !build_rust(¬ices, &intrinsics, &toolchain, a32) {
+ if !build_rust(¬ices, &intrinsics, toolchain.as_deref(), a32) {
std::process::exit(3);
}
- if !compare_outputs(&intrinsics, &toolchain, &c_runner, a32) {
- std::process::exit(1)
+ if let Some(ref toolchain) = toolchain {
+ if !compare_outputs(&intrinsics, toolchain, &c_runner, a32) {
+ std::process::exit(1)
+ }
}
}