Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 0 additions & 25 deletions crates/intrinsic-test/src/arm/config.rs

This file was deleted.

38 changes: 31 additions & 7 deletions crates/intrinsic-test/src/arm/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
mod config;
mod intrinsic;
mod json_parser;
mod types;
Expand All @@ -20,14 +19,20 @@ impl SupportedArchitecture for Arm {
&self.0
}

const NOTICE: &str = config::NOTICE;
const NOTICE: &str = r#"
// This is a transient test file, not intended for distribution. Some aspects of the
// test are derived from a JSON specification, published under the same license as the
// `intrinsic-test` crate.
"#;

const PLATFORM_C_HEADERS: &[&str] = &["arm_neon.h", "arm_acle.h", "arm_fp16.h"];
const C_PRELUDE: &str = r#"
#include <arm_acle.h>
#include <arm_fp16.h>
#include <arm_neon.h>
"#;
const RUST_PRELUDE: &str = RUST_PRELUDE;

const PLATFORM_RUST_DEFINITIONS: &str = config::PLATFORM_RUST_DEFINITIONS;
const PLATFORM_RUST_CFGS: &str = config::PLATFORM_RUST_CFGS;

fn arch_flags(&self, cli_options: &ProcessedCli) -> Vec<&str> {
fn c_compiler_flags(&self, cli_options: &ProcessedCli) -> Vec<&str> {
// GCC uses an extra `-` in the arch name
match cli_options.cc_arg_style {
CcArgStyle::Clang => vec!["-march=armv8.6a+crypto+crc+dotprod+fp16"],
Expand Down Expand Up @@ -125,3 +130,22 @@ impl SupportedArchitecture for Arm {
Self(intrinsics)
}
}

const RUST_PRELUDE: &str = r#"
#![cfg_attr(target_arch = "arm", feature(stdarch_arm_neon_intrinsics))]
#![cfg_attr(target_arch = "arm", feature(stdarch_aarch32_crc32))]
#![cfg_attr(any(target_arch = "aarch64", target_arch = "arm64ec"), feature(stdarch_neon_fcma))]
#![cfg_attr(any(target_arch = "aarch64", target_arch = "arm64ec"), feature(stdarch_neon_i8mm))]
#![cfg_attr(any(target_arch = "aarch64", target_arch = "arm64ec"), feature(stdarch_neon_sm4))]
#![cfg_attr(any(target_arch = "aarch64", target_arch = "arm64ec"), feature(stdarch_neon_ftts))]
#![cfg_attr(any(target_arch = "aarch64", target_arch = "arm64ec"), feature(stdarch_neon_feat_lut))]
#![cfg_attr(any(target_arch = "aarch64", target_arch = "arm64ec"), feature(stdarch_neon_fp8))]
#![cfg_attr(any(target_arch = "aarch64", target_arch = "arm64ec"), feature(faminmax))]
#![feature(stdarch_neon_f16)]

#[cfg(any(target_arch = "aarch64", target_arch = "arm64ec"))]
use core_arch::arch::aarch64::*;

#[cfg(target_arch = "arm")]
use core_arch::arch::arm::*;
"#;
9 changes: 2 additions & 7 deletions crates/intrinsic-test/src/common/gen_c.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,13 @@ use super::intrinsic_helpers::TypeDefinition;
/// ```
pub fn write_wrapper_c<A: SupportedArchitecture>(
w: &mut impl std::io::Write,
notice: &str,
platform_headers: &[&str],
intrinsics: &[Intrinsic<A>],
) -> std::io::Result<()> {
write!(w, "{notice}")?;
write!(w, "{}", A::NOTICE)?;

writeln!(w, "#include <stdint.h>")?;
writeln!(w, "#include <stddef.h>")?;

for header in platform_headers {
writeln!(w, "#include <{header}>")?;
}
writeln!(w, "{}", A::C_PRELUDE)?;

for intrinsic in intrinsics {
intrinsic.iter_specializations(|imm_values| {
Expand Down
7 changes: 2 additions & 5 deletions crates/intrinsic-test/src/common/gen_rust.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,14 +116,11 @@ pub fn write_lib_rs<A: SupportedArchitecture>(
#![allow(non_camel_case_types)]
#![allow(non_snake_case)]

{cfg}
{prelude}
{COMMON_RUST_DEFINITIONS}

{definitions}
"#,
notice = A::NOTICE,
cfg = A::PLATFORM_RUST_CFGS,
definitions = A::PLATFORM_RUST_DEFINITIONS,
prelude = A::RUST_PRELUDE,
)?;

let mut seen = std::collections::HashSet::new();
Expand Down
12 changes: 5 additions & 7 deletions crates/intrinsic-test/src/common/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,10 @@ pub trait SupportedArchitecture: Sized {

const NOTICE: &str;

const PLATFORM_C_HEADERS: &[&str];
const C_PRELUDE: &str;
const RUST_PRELUDE: &str;

const PLATFORM_RUST_CFGS: &str;
const PLATFORM_RUST_DEFINITIONS: &str;

fn arch_flags(&self, cli_options: &ProcessedCli) -> Vec<&str>;
fn c_compiler_flags(&self, cli_options: &ProcessedCli) -> Vec<&str>;

fn generate_c_file(&self) {
let (max_chunk_size, _chunk_count) = manual_chunk(self.intrinsics().len());
Expand All @@ -55,14 +53,14 @@ pub trait SupportedArchitecture: Sized {
.map(|(i, chunk)| {
let c_filename = format!("c_programs/wrapper_{i}.c");
let mut file = File::create(&c_filename).unwrap();
write_wrapper_c(&mut file, Self::NOTICE, Self::PLATFORM_C_HEADERS, chunk)
write_wrapper_c(&mut file, chunk)
})
.collect::<io::Result<()>>()
.unwrap();
}

fn generate_rust_file(&self, cli_options: &ProcessedCli) {
let arch_flags = self.arch_flags(cli_options);
let arch_flags = self.c_compiler_flags(cli_options);

std::fs::create_dir_all("rust_programs").unwrap();

Expand Down
138 changes: 0 additions & 138 deletions crates/intrinsic-test/src/x86/config.rs

This file was deleted.

Loading