Skip to content

Commit

Permalink
Fix test verification and allow for generic types in intrinsics
Browse files Browse the repository at this point in the history
  • Loading branch information
dheaton-arm authored and Amanieu committed Aug 27, 2024
1 parent a1231ff commit 5dfe757
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 9 deletions.
12 changes: 6 additions & 6 deletions crates/core_arch/src/aarch64/mte.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,42 +130,42 @@ mod test {
#[cfg_attr(test, assert_instr(irg))]
#[allow(dead_code)]
#[target_feature(enable = "mte")]
pub unsafe fn __test_create_random_tag(src: *const (), mask: u64) -> *const () {
unsafe fn test_arm_mte_create_random_tag(src: *const (), mask: u64) -> *const () {
__arm_mte_create_random_tag(src, mask)
}

#[cfg_attr(test, assert_instr(addg))]
#[allow(dead_code)]
#[target_feature(enable = "mte")]
pub unsafe fn __test_increment_tag(src: *const ()) -> *const () {
unsafe fn test_arm_mte_increment_tag(src: *const ()) -> *const () {
__arm_mte_increment_tag::<1, _>(src)
}

#[cfg_attr(test, assert_instr(gmi))]
#[allow(dead_code)]
#[target_feature(enable = "mte")]
pub unsafe fn __test_exclude_tag(src: *const (), excluded: u64) -> u64 {
unsafe fn test_arm_mte_exclude_tag(src: *const (), excluded: u64) -> u64 {
__arm_mte_exclude_tag(src, excluded)
}

#[cfg_attr(test, assert_instr(stg))]
#[allow(dead_code)]
#[target_feature(enable = "mte")]
pub unsafe fn __test_set_tag(src: *const ()) {
unsafe fn test_arm_mte_set_tag(src: *const ()) {
__arm_mte_set_tag(src)
}

#[cfg_attr(test, assert_instr(ldg))]
#[allow(dead_code)]
#[target_feature(enable = "mte")]
pub unsafe fn __test_get_tag(src: *const ()) -> *const () {
unsafe fn test_arm_mte_get_tag(src: *const ()) -> *const () {
__arm_mte_get_tag(src)
}

#[cfg_attr(test, assert_instr(subp))]
#[allow(dead_code)]
#[target_feature(enable = "mte")]
pub unsafe fn __test_ptrdiff(a: *const (), b: *const ()) -> i64 {
unsafe fn test_arm_mte_ptrdiff(a: *const (), b: *const ()) -> i64 {
__arm_mte_ptrdiff(a, b)
}
}
10 changes: 7 additions & 3 deletions crates/stdarch-verify/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,11 @@ fn functions(input: TokenStream, dirs: &[&str]) -> TokenStream {
arguments.push(to_type(ty));
}
for generic in f.sig.generics.params.iter() {
let ty = match *generic {
syn::GenericParam::Const(ref c) => &c.ty,
match *generic {
syn::GenericParam::Const(ref c) => const_arguments.push(to_type(&c.ty)),
syn::GenericParam::Type(ref _t) => (),
_ => panic!("invalid generic argument on {name}"),
};
const_arguments.push(to_type(ty));
}
let ret = match f.sig.output {
syn::ReturnType::Default => quote! { None },
Expand Down Expand Up @@ -345,6 +345,10 @@ fn to_type(t: &syn::Type) -> proc_macro2::TokenStream {
"v4f32" => quote! { &v4f32 },
"v2f64" => quote! { &v2f64 },

// Generic types
"T" => quote! { &GENERICT },
"U" => quote! { &GENERICU },

s => panic!("unsupported type: \"{s}\""),
},
syn::Type::Ptr(syn::TypePtr {
Expand Down
4 changes: 4 additions & 0 deletions crates/stdarch-verify/tests/arm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ static U32: Type = Type::PrimUnsigned(32);
static U64: Type = Type::PrimUnsigned(64);
static U8: Type = Type::PrimUnsigned(8);
static NEVER: Type = Type::Never;
static GENERICT: Type = Type::GenericParam("T");
static GENERICU: Type = Type::GenericParam("U");

static F16X4: Type = Type::F(16, 4, 1);
static F16X4X2: Type = Type::F(16, 4, 2);
Expand Down Expand Up @@ -157,6 +159,7 @@ enum Type {
PrimPoly(u8),
MutPtr(&'static Type),
ConstPtr(&'static Type),
GenericParam(&'static str),
I(u8, u8, u8),
U(u8, u8, u8),
P(u8, u8, u8),
Expand Down Expand Up @@ -456,6 +459,7 @@ fn verify_all_signatures() {
&& !rust.file.ends_with("v7.rs\"")
&& !rust.file.ends_with("v8.rs\"")
&& !rust.file.ends_with("tme.rs\"")
&& !rust.file.ends_with("mte.rs\"")
&& !rust.file.ends_with("ex.rs\"")
&& !skip_intrinsic_verify.contains(&rust.name)
{
Expand Down

0 comments on commit 5dfe757

Please sign in to comment.