Skip to content

Commit 7ff8497

Browse files
Chore: Added SupportedArchitectureTest trait which must be implemented for different architectures.
Next steps: Move the existing ARM-specific implementation into one that fits well with this trait.
1 parent bd0a675 commit 7ff8497

File tree

4 files changed

+60
-44
lines changed

4 files changed

+60
-44
lines changed

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

+1-44
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ pub(crate) mod types;
66

77
use std::fs::File;
88
use std::io::Write;
9-
use std::path::PathBuf;
109
use std::process::Command;
1110

1211
use intrinsic::Intrinsic;
@@ -17,6 +16,7 @@ use types::TypeKind;
1716
use argument::Argument;
1817
use format::Indentation;
1918
use json_parser::get_neon_intrinsics;
19+
use crate::common::cli::Cli;
2020

2121
// The number of times each intrinsic will be called.
2222
const PASSES: u32 = 20;
@@ -443,49 +443,6 @@ path = "{intrinsic}/main.rs""#,
443443
}
444444
}
445445

446-
/// Intrinsic test tool
447-
#[derive(clap::Parser)]
448-
#[command(
449-
name = "Intrinsic test tool",
450-
about = "Generates Rust and C programs for intrinsics and compares the output"
451-
)]
452-
struct Cli {
453-
/// The input file containing the intrinsics
454-
input: PathBuf,
455-
456-
/// The rust toolchain to use for building the rust code
457-
#[arg(long)]
458-
toolchain: Option<String>,
459-
460-
/// The C++ compiler to use for compiling the c++ code
461-
#[arg(long, default_value_t = String::from("clang++"))]
462-
cppcompiler: String,
463-
464-
/// Run the C programs under emulation with this command
465-
#[arg(long)]
466-
runner: Option<String>,
467-
468-
/// Filename for a list of intrinsics to skip (one per line)
469-
#[arg(long)]
470-
skip: Option<PathBuf>,
471-
472-
/// Regenerate test programs, but don't build or run them
473-
#[arg(long)]
474-
generate_only: bool,
475-
476-
/// Pass a target the test suite
477-
#[arg(long, default_value_t = String::from("aarch64-unknown-linux-gnu"))]
478-
target: String,
479-
480-
/// Set the linker
481-
#[arg(long)]
482-
linker: Option<String>,
483-
484-
/// Set the sysroot for the C++ compiler
485-
#[arg(long)]
486-
cxx_toolchain_dir: Option<String>,
487-
}
488-
489446
pub fn test() {
490447
let args: Cli = clap::Parser::parse();
491448

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
use std::path::PathBuf;
2+
3+
/// Intrinsic test tool
4+
#[derive(clap::Parser)]
5+
#[command(
6+
name = "Intrinsic test tool",
7+
about = "Generates Rust and C programs for intrinsics and compares the output"
8+
)]
9+
pub struct Cli {
10+
/// The input file containing the intrinsics
11+
pub input: PathBuf,
12+
13+
/// The rust toolchain to use for building the rust code
14+
#[arg(long)]
15+
pub toolchain: Option<String>,
16+
17+
/// The C++ compiler to use for compiling the c++ code
18+
#[arg(long, default_value_t = String::from("clang++"))]
19+
pub cppcompiler: String,
20+
21+
/// Run the C programs under emulation with this command
22+
#[arg(long)]
23+
pub runner: Option<String>,
24+
25+
/// Filename for a list of intrinsics to skip (one per line)
26+
#[arg(long)]
27+
pub skip: Option<PathBuf>,
28+
29+
/// Regenerate test programs, but don't build or run them
30+
#[arg(long)]
31+
pub generate_only: bool,
32+
33+
/// Pass a target the test suite
34+
#[arg(long, default_value_t = String::from("aarch64-unknown-linux-gnu"))]
35+
pub target: String,
36+
37+
/// Set the linker
38+
#[arg(long)]
39+
pub linker: Option<String>,
40+
41+
/// Set the sysroot for the C++ compiler
42+
#[arg(long)]
43+
pub cxx_toolchain_dir: Option<String>,
44+
}
+2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
pub mod types;
2+
pub mod supporting_test;
23
pub mod values;
4+
pub mod cli;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/// Architectures must support this trait
2+
/// to be successfully tested.
3+
pub trait SupportedArchitectureTest {
4+
fn write_c_file(filename: &str);
5+
6+
fn write_rust_file(filename: &str);
7+
8+
fn build_c_file(filename: &str);
9+
10+
fn build_rust_file(filename: &str);
11+
12+
fn read_intrinsic_source_file(filename: &str);
13+
}

0 commit comments

Comments
 (0)