Skip to content

Commit 2777ceb

Browse files
chore: code consolidation
1 parent 3e46d80 commit 2777ceb

14 files changed

+137
-159
lines changed

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

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
use std::ops::Range;
2-
31
use super::format::Indentation;
42
use super::json_parser::ArgPrep;
53
use super::types::{IntrinsicType, TypeKind};
64
use crate::common::types::Language;
5+
use std::ops::Range;
76

87
/// An argument for the intrinsic.
98
#[derive(Debug, PartialEq, Clone)]

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

+1-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@ pub fn build_notices(line_prefix: &str) -> String {
88
)
99
}
1010

11-
pub const POLY128_OSTREAM_DEF: &str =
12-
r#"std::ostream& operator<<(std::ostream& os, poly128_t value) {
11+
pub const POLY128_OSTREAM_DEF: &str = r#"std::ostream& operator<<(std::ostream& os, poly128_t value) {
1312
std::stringstream temp;
1413
do {
1514
int n = value % 10;

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

+4-5
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
1-
use itertools::Itertools;
2-
use rayon::prelude::*;
3-
use std::io::Write;
4-
51
use super::argument::Argument;
62
use super::config::{AARCH_CONFIGURATIONS, POLY128_OSTREAM_DEF, build_notices};
73
use super::format::Indentation;
84
use super::intrinsic::Intrinsic;
95
use crate::common::gen_c::{compile_c, create_c_files, generate_c_program};
106
use crate::common::gen_rust::{compile_rust, create_rust_files, generate_rust_program};
7+
use itertools::Itertools;
8+
use rayon::prelude::*;
9+
use std::io::Write;
1110

1211
// The number of times each intrinsic will be called.
1312
const PASSES: u32 = 20;
@@ -156,7 +155,7 @@ fn compile_c_arm(
156155
cxx_toolchain_dir: Option<&str>,
157156
) -> bool {
158157
let compiler_commands = intrinsics_name_list.iter().map(|intrinsic_name|{
159-
let c_filename = format!(r#"c_programs/{}.cpp"#, intrinsic_name);
158+
let c_filename = format!(r#"c_programs/{intrinsic_name}.cpp"#);
160159
let flags = std::env::var("CPPFLAGS").unwrap_or("".into());
161160
let arch_flags = if target.contains("v7") {
162161
"-march=armv8.6-a+crypto+crc+dotprod+fp16"

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

+1-5
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1+
use super::argument::ArgumentList;
12
use super::format::Indentation;
23
use super::types::{IntrinsicType, TypeKind};
34

4-
use super::argument::ArgumentList;
5-
65
/// An intrinsic
76
#[derive(Debug, PartialEq, Clone)]
87
pub struct Intrinsic {
@@ -82,8 +81,6 @@ impl Intrinsic {
8281
String::from("")
8382
},
8483
close = if self.results.is_simd() { ")" } else { "" },
85-
lanes = lanes,
86-
additional = additional,
8784
)
8885
}
8986

@@ -135,7 +132,6 @@ impl Intrinsic {
135132
intrinsic_call = self.name,
136133
const = constraints,
137134
args = self.arguments.as_call_param_rust(),
138-
additional = additional,
139135
)
140136
}
141137
}

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

+3-5
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
1-
use std::collections::HashMap;
2-
use std::path::Path;
3-
4-
use serde::Deserialize;
5-
61
use super::argument::{Argument, ArgumentList};
72
use super::intrinsic::Intrinsic;
83
use super::types::IntrinsicType;
4+
use serde::Deserialize;
5+
use std::collections::HashMap;
6+
use std::path::Path;
97

108
#[derive(Deserialize, Debug)]
119
#[serde(deny_unknown_fields)]

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ mod intrinsic;
66
mod json_parser;
77
mod types;
88

9-
use crate::common::cli::ProcessedCli;
9+
use crate::common::SupportedArchitectureTest;
1010
use crate::common::compare::compare_outputs;
11-
use crate::common::supporting_test::SupportedArchitectureTest;
11+
use crate::common::types::ProcessedCli;
1212
use functions::{build_c, build_rust};
1313
use intrinsic::Intrinsic;
1414
use json_parser::get_neon_intrinsics;

crates/intrinsic-test/src/common/cli.rs

-101
This file was deleted.

crates/intrinsic-test/src/common/compare.rs

+2-17
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,7 @@
1+
use super::types::FailureReason;
12
use rayon::prelude::*;
23
use std::process::Command;
34

4-
enum FailureReason {
5-
RunC(String),
6-
RunRust(String),
7-
Difference(String, String, String),
8-
}
9-
105
pub fn compare_outputs(
116
intrinsic_name_list: &Vec<String>,
127
toolchain: &str,
@@ -18,11 +13,7 @@ pub fn compare_outputs(
1813
.filter_map(|intrinsic_name| {
1914
let c = Command::new("sh")
2015
.arg("-c")
21-
.arg(format!(
22-
"{runner} ./c_programs/{intrinsic_name}",
23-
runner = runner,
24-
intrinsic_name = intrinsic_name,
25-
))
16+
.arg(format!("{runner} ./c_programs/{intrinsic_name}"))
2617
.output();
2718

2819
let rust = if target != "aarch64_be-unknown-linux-gnu" {
@@ -31,9 +22,6 @@ pub fn compare_outputs(
3122
.arg("-c")
3223
.arg(format!(
3324
"cargo {toolchain} run --target {target} --bin {intrinsic_name} --release",
34-
intrinsic_name = intrinsic_name,
35-
toolchain = toolchain,
36-
target = target
3725
))
3826
.env("RUSTFLAGS", "-Cdebuginfo=0")
3927
.output()
@@ -42,9 +30,6 @@ pub fn compare_outputs(
4230
.arg("-c")
4331
.arg(format!(
4432
"{runner} ./rust_programs/target/{target}/release/{intrinsic_name}",
45-
runner = runner,
46-
target = target,
47-
intrinsic_name = intrinsic_name,
4833
))
4934
.output()
5035
};

crates/intrinsic-test/src/common/gen_c.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ pub fn create_c_files(identifiers: &Vec<String>) -> BTreeMap<&String, File> {
8383
identifiers
8484
.par_iter()
8585
.map(|identifier| {
86-
let c_filename = format!(r#"c_programs/{}.cpp"#, identifier);
86+
let c_filename = format!(r#"c_programs/{identifier}.cpp"#);
8787
let file = File::create(&c_filename).unwrap();
8888

8989
(identifier, file)

crates/intrinsic-test/src/common/gen_rust.rs

+1-5
Original file line numberDiff line numberDiff line change
@@ -78,11 +78,7 @@ path = "{binary}/main.rs""#,
7878
/* If there has been a linker explicitly set from the command line then
7979
* we want to set it via setting it in the RUSTFLAGS*/
8080

81-
let cargo_command = format!(
82-
"cargo {toolchain} build --target {target} --release",
83-
toolchain = toolchain,
84-
target = target
85-
);
81+
let cargo_command = format!("cargo {toolchain} build --target {target} --release");
8682

8783
let mut command = Command::new("sh");
8884
command
+11-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,16 @@
1-
pub mod cli;
1+
use crate::common::types::ProcessedCli;
2+
23
pub mod compare;
34
pub mod gen_c;
45
pub mod gen_rust;
5-
pub mod supporting_test;
66
pub mod types;
77
pub mod values;
8+
9+
/// Architectures must support this trait
10+
/// to be successfully tested.
11+
pub trait SupportedArchitectureTest {
12+
fn create(cli_options: ProcessedCli) -> Self;
13+
fn build_c_file(&self) -> bool;
14+
fn build_rust_file(&self) -> bool;
15+
fn compare_outputs(&self) -> bool;
16+
}

crates/intrinsic-test/src/common/supporting_test.rs

-10
This file was deleted.

0 commit comments

Comments
 (0)