Skip to content

Commit 5b89089

Browse files
feat: added initial functionality for building Rust files
1 parent e57c4bf commit 5b89089

File tree

2 files changed

+57
-2
lines changed

2 files changed

+57
-2
lines changed

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

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,35 @@ pub fn build_notices(line_prefix: &str) -> String {
77
"
88
)
99
}
10+
11+
// Format f16 values (and vectors containing them) in a way that is consistent with C.
12+
pub const F16_FORMATTING_DEF: &str = r#"
13+
#[repr(transparent)]
14+
struct Hex<T>(T);
15+
"#;
16+
17+
pub const X86_CONFIGURATIONS: &str = r#"
18+
#![cfg_attr(target_arch = "x86", feature(stdarch_x86_avx512))]
19+
#![cfg_attr(target_arch = "x86", feature(stdarch_x86_avx2))]
20+
#![cfg_attr(target_arch = "x86", feature(stdarch_x86_avx))]
21+
#![cfg_attr(target_arch = "x86", feature(stdarch_x86_sse42))]
22+
#![cfg_attr(target_arch = "x86", feature(stdarch_x86_sse41))]
23+
#![cfg_attr(target_arch = "x86", feature(stdarch_x86_ssse3))]
24+
#![cfg_attr(target_arch = "x86", feature(stdarch_x86_sse3))]
25+
#![cfg_attr(target_arch = "x86", feature(stdarch_x86_sse2))]
26+
#![cfg_attr(target_arch = "x86", feature(stdarch_x86_sse))]
27+
#![cfg_attr(target_arch = "x86_64", feature(stdarch_x86_avx512))]
28+
#![cfg_attr(target_arch = "x86_64", feature(stdarch_x86_avx2))]
29+
#![cfg_attr(target_arch = "x86_64", feature(stdarch_x86_avx))]
30+
#![cfg_attr(target_arch = "x86_64", feature(stdarch_x86_fma))]
31+
#![cfg_attr(target_arch = "x86_64", feature(stdarch_x86_aes))]
32+
#![cfg_attr(target_arch = "x86_64", feature(stdarch_x86_sha))]
33+
#![cfg_attr(target_arch = "x86_64", feature(stdarch_x86_bmi1))]
34+
#![cfg_attr(target_arch = "x86_64", feature(stdarch_x86_bmi2))]
35+
#![cfg_attr(target_arch = "x86_64", feature(stdarch_x86_lzcnt))]
36+
#![cfg_attr(target_arch = "x86_64", feature(stdarch_x86_popcnt))]
37+
#![cfg_attr(target_arch = "x86_64", feature(stdarch_x86_rdrand))]
38+
#![cfg_attr(target_arch = "x86_64", feature(stdarch_x86_rdseed))]
39+
#![cfg_attr(any(target_arch = "x86", target_arch = "x86_64"), feature(stdarch_x86_mmx))]
40+
#![feature(fmt_helpers_for_derive)]
41+
"#;

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

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,11 @@ mod xml_parser;
55

66
use crate::common::SupportedArchitectureTest;
77
use crate::common::cli::ProcessedCli;
8+
use crate::common::gen_rust::compile_rust_programs;
89
use crate::common::intrinsic::{Intrinsic, IntrinsicDefinition};
910
use crate::common::intrinsic_helpers::TypeKind;
10-
use crate::common::write_file::write_c_testfiles;
11+
use crate::common::write_file::{write_c_testfiles, write_rust_testfiles};
12+
use crate::x86::config::{F16_FORMATTING_DEF, X86_CONFIGURATIONS};
1113
use config::build_notices;
1214
use intrinsic::X86IntrinsicType;
1315
use xml_parser::get_xml_intrinsics;
@@ -67,7 +69,28 @@ impl SupportedArchitectureTest for X86ArchitectureTest {
6769
}
6870

6971
fn build_rust_file(&self) -> bool {
70-
todo!("build_rust_file in X86ArchitectureTest is not implemented")
72+
// this is the module that handles the specific intrinsic
73+
// within the core_arch crate in std::arch
74+
let rust_target = if self.cli_options.target.contains("v7") {
75+
"x86"
76+
} else {
77+
"x86_64"
78+
};
79+
let target = &self.cli_options.target;
80+
let toolchain = self.cli_options.toolchain.as_deref();
81+
let linker = self.cli_options.linker.as_deref();
82+
let intrinsics_name_list = write_rust_testfiles(
83+
self.intrinsics
84+
.iter()
85+
.map(|i| i as &dyn IntrinsicDefinition<_>)
86+
.collect::<Vec<_>>(),
87+
rust_target,
88+
&build_notices("// "),
89+
F16_FORMATTING_DEF,
90+
X86_CONFIGURATIONS,
91+
);
92+
93+
compile_rust_programs(intrinsics_name_list, toolchain, target, linker)
7194
}
7295

7396
fn compare_outputs(&self) -> bool {

0 commit comments

Comments
 (0)