diff --git a/library/stdarch/crates/intrinsic-test/src/arm/mod.rs b/library/stdarch/crates/intrinsic-test/src/arm/mod.rs index 2d1846e14ebf..1131858c0d29 100644 --- a/library/stdarch/crates/intrinsic-test/src/arm/mod.rs +++ b/library/stdarch/crates/intrinsic-test/src/arm/mod.rs @@ -6,7 +6,6 @@ pub(crate) mod types; use std::fs::File; use std::io::Write; -use std::path::PathBuf; use std::process::Command; use intrinsic::Intrinsic; @@ -17,6 +16,7 @@ use types::TypeKind; use argument::Argument; use format::Indentation; use json_parser::get_neon_intrinsics; +use crate::common::cli::Cli; // The number of times each intrinsic will be called. const PASSES: u32 = 20; @@ -443,49 +443,6 @@ path = "{intrinsic}/main.rs""#, } } -/// Intrinsic test tool -#[derive(clap::Parser)] -#[command( - name = "Intrinsic test tool", - about = "Generates Rust and C programs for intrinsics and compares the output" -)] -struct Cli { - /// The input file containing the intrinsics - input: PathBuf, - - /// The rust toolchain to use for building the rust code - #[arg(long)] - toolchain: Option, - - /// The C++ compiler to use for compiling the c++ code - #[arg(long, default_value_t = String::from("clang++"))] - cppcompiler: String, - - /// Run the C programs under emulation with this command - #[arg(long)] - runner: Option, - - /// Filename for a list of intrinsics to skip (one per line) - #[arg(long)] - skip: Option, - - /// Regenerate test programs, but don't build or run them - #[arg(long)] - generate_only: bool, - - /// Pass a target the test suite - #[arg(long, default_value_t = String::from("aarch64-unknown-linux-gnu"))] - target: String, - - /// Set the linker - #[arg(long)] - linker: Option, - - /// Set the sysroot for the C++ compiler - #[arg(long)] - cxx_toolchain_dir: Option, -} - pub fn test() { let args: Cli = clap::Parser::parse(); diff --git a/library/stdarch/crates/intrinsic-test/src/common/cli.rs b/library/stdarch/crates/intrinsic-test/src/common/cli.rs new file mode 100644 index 000000000000..92f0e86e81e7 --- /dev/null +++ b/library/stdarch/crates/intrinsic-test/src/common/cli.rs @@ -0,0 +1,44 @@ +use std::path::PathBuf; + +/// Intrinsic test tool +#[derive(clap::Parser)] +#[command( + name = "Intrinsic test tool", + about = "Generates Rust and C programs for intrinsics and compares the output" +)] +pub struct Cli { + /// The input file containing the intrinsics + pub input: PathBuf, + + /// The rust toolchain to use for building the rust code + #[arg(long)] + pub toolchain: Option, + + /// The C++ compiler to use for compiling the c++ code + #[arg(long, default_value_t = String::from("clang++"))] + pub cppcompiler: String, + + /// Run the C programs under emulation with this command + #[arg(long)] + pub runner: Option, + + /// Filename for a list of intrinsics to skip (one per line) + #[arg(long)] + pub skip: Option, + + /// Regenerate test programs, but don't build or run them + #[arg(long)] + pub generate_only: bool, + + /// Pass a target the test suite + #[arg(long, default_value_t = String::from("aarch64-unknown-linux-gnu"))] + pub target: String, + + /// Set the linker + #[arg(long)] + pub linker: Option, + + /// Set the sysroot for the C++ compiler + #[arg(long)] + pub cxx_toolchain_dir: Option, +} diff --git a/library/stdarch/crates/intrinsic-test/src/common/mod.rs b/library/stdarch/crates/intrinsic-test/src/common/mod.rs index f5710ca82b84..4e378c9c6dfd 100644 --- a/library/stdarch/crates/intrinsic-test/src/common/mod.rs +++ b/library/stdarch/crates/intrinsic-test/src/common/mod.rs @@ -1,2 +1,4 @@ pub mod types; +pub mod supporting_test; pub mod values; +pub mod cli; diff --git a/library/stdarch/crates/intrinsic-test/src/common/supporting_test.rs b/library/stdarch/crates/intrinsic-test/src/common/supporting_test.rs new file mode 100644 index 000000000000..37a63c7a557d --- /dev/null +++ b/library/stdarch/crates/intrinsic-test/src/common/supporting_test.rs @@ -0,0 +1,13 @@ +/// Architectures must support this trait +/// to be successfully tested. +pub trait SupportedArchitectureTest { + fn write_c_file(filename: &str); + + fn write_rust_file(filename: &str); + + fn build_c_file(filename: &str); + + fn build_rust_file(filename: &str); + + fn read_intrinsic_source_file(filename: &str); +}