Skip to content

Commit 5dfe757

Browse files
dheaton-armAmanieu
authored andcommitted
Fix test verification and allow for generic types in intrinsics
1 parent a1231ff commit 5dfe757

File tree

3 files changed

+17
-9
lines changed

3 files changed

+17
-9
lines changed

crates/core_arch/src/aarch64/mte.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -130,42 +130,42 @@ mod test {
130130
#[cfg_attr(test, assert_instr(irg))]
131131
#[allow(dead_code)]
132132
#[target_feature(enable = "mte")]
133-
pub unsafe fn __test_create_random_tag(src: *const (), mask: u64) -> *const () {
133+
unsafe fn test_arm_mte_create_random_tag(src: *const (), mask: u64) -> *const () {
134134
__arm_mte_create_random_tag(src, mask)
135135
}
136136

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

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

151151
#[cfg_attr(test, assert_instr(stg))]
152152
#[allow(dead_code)]
153153
#[target_feature(enable = "mte")]
154-
pub unsafe fn __test_set_tag(src: *const ()) {
154+
unsafe fn test_arm_mte_set_tag(src: *const ()) {
155155
__arm_mte_set_tag(src)
156156
}
157157

158158
#[cfg_attr(test, assert_instr(ldg))]
159159
#[allow(dead_code)]
160160
#[target_feature(enable = "mte")]
161-
pub unsafe fn __test_get_tag(src: *const ()) -> *const () {
161+
unsafe fn test_arm_mte_get_tag(src: *const ()) -> *const () {
162162
__arm_mte_get_tag(src)
163163
}
164164

165165
#[cfg_attr(test, assert_instr(subp))]
166166
#[allow(dead_code)]
167167
#[target_feature(enable = "mte")]
168-
pub unsafe fn __test_ptrdiff(a: *const (), b: *const ()) -> i64 {
168+
unsafe fn test_arm_mte_ptrdiff(a: *const (), b: *const ()) -> i64 {
169169
__arm_mte_ptrdiff(a, b)
170170
}
171171
}

crates/stdarch-verify/src/lib.rs

+7-3
Original file line numberDiff line numberDiff line change
@@ -97,11 +97,11 @@ fn functions(input: TokenStream, dirs: &[&str]) -> TokenStream {
9797
arguments.push(to_type(ty));
9898
}
9999
for generic in f.sig.generics.params.iter() {
100-
let ty = match *generic {
101-
syn::GenericParam::Const(ref c) => &c.ty,
100+
match *generic {
101+
syn::GenericParam::Const(ref c) => const_arguments.push(to_type(&c.ty)),
102+
syn::GenericParam::Type(ref _t) => (),
102103
_ => panic!("invalid generic argument on {name}"),
103104
};
104-
const_arguments.push(to_type(ty));
105105
}
106106
let ret = match f.sig.output {
107107
syn::ReturnType::Default => quote! { None },
@@ -345,6 +345,10 @@ fn to_type(t: &syn::Type) -> proc_macro2::TokenStream {
345345
"v4f32" => quote! { &v4f32 },
346346
"v2f64" => quote! { &v2f64 },
347347

348+
// Generic types
349+
"T" => quote! { &GENERICT },
350+
"U" => quote! { &GENERICU },
351+
348352
s => panic!("unsupported type: \"{s}\""),
349353
},
350354
syn::Type::Ptr(syn::TypePtr {

crates/stdarch-verify/tests/arm.rs

+4
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ static U32: Type = Type::PrimUnsigned(32);
2828
static U64: Type = Type::PrimUnsigned(64);
2929
static U8: Type = Type::PrimUnsigned(8);
3030
static NEVER: Type = Type::Never;
31+
static GENERICT: Type = Type::GenericParam("T");
32+
static GENERICU: Type = Type::GenericParam("U");
3133

3234
static F16X4: Type = Type::F(16, 4, 1);
3335
static F16X4X2: Type = Type::F(16, 4, 2);
@@ -157,6 +159,7 @@ enum Type {
157159
PrimPoly(u8),
158160
MutPtr(&'static Type),
159161
ConstPtr(&'static Type),
162+
GenericParam(&'static str),
160163
I(u8, u8, u8),
161164
U(u8, u8, u8),
162165
P(u8, u8, u8),
@@ -456,6 +459,7 @@ fn verify_all_signatures() {
456459
&& !rust.file.ends_with("v7.rs\"")
457460
&& !rust.file.ends_with("v8.rs\"")
458461
&& !rust.file.ends_with("tme.rs\"")
462+
&& !rust.file.ends_with("mte.rs\"")
459463
&& !rust.file.ends_with("ex.rs\"")
460464
&& !skip_intrinsic_verify.contains(&rust.name)
461465
{

0 commit comments

Comments
 (0)