Add --generate-only to intrinsic-test.
This is useful for debugging.
This commit is contained in:
parent
ef6263d968
commit
d2736197f7
2 changed files with 34 additions and 12 deletions
|
|
@ -7,9 +7,10 @@ USAGE:
|
|||
intrinsic-test [FLAGS] [OPTIONS] <INPUT>
|
||||
|
||||
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 <CPPCOMPILER> The C++ compiler to use for compiling the c++ code [default: clang++]
|
||||
|
|
|
|||
|
|
@ -232,7 +232,7 @@ fn build_notices(line_prefix: &str) -> String {
|
|||
)
|
||||
}
|
||||
|
||||
fn build_c(notices: &str, intrinsics: &Vec<Intrinsic>, compiler: &str, a32: bool) -> bool {
|
||||
fn build_c(notices: &str, intrinsics: &Vec<Intrinsic>, 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<Intrinsic>, 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::<Vec<_>>();
|
||||
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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue