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.
This commit is contained in:
Madhav Madhusoodanan 2025-03-25 21:17:56 +04:00 committed by Amanieu d'Antras
parent d7edb3ea7c
commit 1d39fd0964
4 changed files with 60 additions and 44 deletions

View file

@ -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<String>,
/// 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<String>,
/// Filename for a list of intrinsics to skip (one per line)
#[arg(long)]
skip: Option<PathBuf>,
/// 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<String>,
/// Set the sysroot for the C++ compiler
#[arg(long)]
cxx_toolchain_dir: Option<String>,
}
pub fn test() {
let args: Cli = clap::Parser::parse();

View file

@ -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<String>,
/// 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<String>,
/// Filename for a list of intrinsics to skip (one per line)
#[arg(long)]
pub skip: Option<PathBuf>,
/// 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<String>,
/// Set the sysroot for the C++ compiler
#[arg(long)]
pub cxx_toolchain_dir: Option<String>,
}

View file

@ -1,2 +1,4 @@
pub mod types;
pub mod supporting_test;
pub mod values;
pub mod cli;

View file

@ -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);
}