Skip to content

Commit 0cf01e1

Browse files
committed
inline assert_instr tests
1 parent 44f4069 commit 0cf01e1

2 files changed

Lines changed: 12 additions & 68 deletions

File tree

crates/core_arch/src/aarch64/mte.rs

Lines changed: 8 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
//!
33
//! [ACLE documentation](https://arm-software.github.io/acle/main/acle.html#markdown-toc-mte-intrinsics)
44
5+
use stdarch_test::assert_instr;
6+
57
unsafe extern "unadjusted" {
68
#[link_name = "llvm.aarch64.irg"]
79
fn irg_(ptr: *const (), exclude: i64) -> *const ();
@@ -33,6 +35,7 @@ unsafe extern "unadjusted" {
3335
/// and Undefined Behavior to dereference it.
3436
#[inline]
3537
#[target_feature(enable = "mte")]
38+
#[cfg_attr(test, assert_instr(irg))]
3639
#[unstable(feature = "stdarch_aarch64_mte", issue = "129010")]
3740
pub unsafe fn __arm_mte_create_random_tag<T>(src: *const T, mask: u64) -> *const T {
3841
irg_(src as *const (), mask as i64) as *const T
@@ -49,6 +52,7 @@ pub unsafe fn __arm_mte_create_random_tag<T>(src: *const T, mask: u64) -> *const
4952
/// SAFETY: See `__arm_mte_create_random_tag`.
5053
#[inline]
5154
#[target_feature(enable = "mte")]
55+
#[cfg_attr(test, assert_instr(addg))]
5256
#[unstable(feature = "stdarch_aarch64_mte", issue = "129010")]
5357
pub unsafe fn __arm_mte_increment_tag<const OFFSET: i64, T>(src: *const T) -> *const T {
5458
addg_(src as *const (), OFFSET) as *const T
@@ -64,6 +68,7 @@ pub unsafe fn __arm_mte_increment_tag<const OFFSET: i64, T>(src: *const T) -> *c
6468
/// the result.
6569
#[inline]
6670
#[target_feature(enable = "mte")]
71+
#[cfg_attr(test, assert_instr(gmi))]
6772
#[unstable(feature = "stdarch_aarch64_mte", issue = "129010")]
6873
pub unsafe fn __arm_mte_exclude_tag<T>(src: *const T, excluded: u64) -> u64 {
6974
gmi_(src as *const (), excluded as i64) as u64
@@ -78,6 +83,7 @@ pub unsafe fn __arm_mte_exclude_tag<T>(src: *const T, excluded: u64) -> u64 {
7883
/// entire 16-byte memory granule.
7984
#[inline]
8085
#[target_feature(enable = "mte")]
86+
#[cfg_attr(test, assert_instr(stg))]
8187
#[unstable(feature = "stdarch_aarch64_mte", issue = "129010")]
8288
pub unsafe fn __arm_mte_set_tag<T>(tag_address: *const T) {
8389
stg_(tag_address as *const (), tag_address as *const ());
@@ -90,6 +96,7 @@ pub unsafe fn __arm_mte_set_tag<T>(tag_address: *const T) {
9096
/// is read. This does not need to be 16-byte aligned.
9197
#[inline]
9298
#[target_feature(enable = "mte")]
99+
#[cfg_attr(test, assert_instr(ldg))]
93100
#[unstable(feature = "stdarch_aarch64_mte", issue = "129010")]
94101
pub unsafe fn __arm_mte_get_tag<T>(address: *const T) -> *const T {
95102
ldg_(address as *const (), address as *const ()) as *const T
@@ -99,55 +106,8 @@ pub unsafe fn __arm_mte_get_tag<T>(address: *const T) -> *const T {
99106
/// the tags, and sign-extending the result.
100107
#[inline]
101108
#[target_feature(enable = "mte")]
109+
#[cfg_attr(test, assert_instr(subp))]
102110
#[unstable(feature = "stdarch_aarch64_mte", issue = "129010")]
103111
pub unsafe fn __arm_mte_ptrdiff<T, U>(a: *const T, b: *const U) -> i64 {
104112
subp_(a as *const (), b as *const ())
105113
}
106-
107-
#[cfg(test)]
108-
mod test {
109-
use super::*;
110-
use stdarch_test::assert_instr;
111-
112-
#[cfg_attr(all(test, not(target_env = "msvc")), assert_instr(irg))] // FIXME: MSVC `dumpbin` doesn't support MTE
113-
#[allow(dead_code)]
114-
#[target_feature(enable = "mte")]
115-
unsafe fn test_arm_mte_create_random_tag(src: *const (), mask: u64) -> *const () {
116-
__arm_mte_create_random_tag(src, mask)
117-
}
118-
119-
#[cfg_attr(all(test, not(target_env = "msvc")), assert_instr(addg))]
120-
#[allow(dead_code)]
121-
#[target_feature(enable = "mte")]
122-
unsafe fn test_arm_mte_increment_tag(src: *const ()) -> *const () {
123-
__arm_mte_increment_tag::<1, _>(src)
124-
}
125-
126-
#[cfg_attr(all(test, not(target_env = "msvc")), assert_instr(gmi))]
127-
#[allow(dead_code)]
128-
#[target_feature(enable = "mte")]
129-
unsafe fn test_arm_mte_exclude_tag(src: *const (), excluded: u64) -> u64 {
130-
__arm_mte_exclude_tag(src, excluded)
131-
}
132-
133-
#[cfg_attr(all(test, not(target_env = "msvc")), assert_instr(stg))]
134-
#[allow(dead_code)]
135-
#[target_feature(enable = "mte")]
136-
unsafe fn test_arm_mte_set_tag(src: *const ()) {
137-
__arm_mte_set_tag(src)
138-
}
139-
140-
#[cfg_attr(all(test, not(target_env = "msvc")), assert_instr(ldg))]
141-
#[allow(dead_code)]
142-
#[target_feature(enable = "mte")]
143-
unsafe fn test_arm_mte_get_tag(src: *const ()) -> *const () {
144-
__arm_mte_get_tag(src)
145-
}
146-
147-
#[cfg_attr(all(test, not(target_env = "msvc")), assert_instr(subp))]
148-
#[allow(dead_code)]
149-
#[target_feature(enable = "mte")]
150-
unsafe fn test_arm_mte_ptrdiff(a: *const (), b: *const ()) -> i64 {
151-
__arm_mte_ptrdiff(a, b)
152-
}
153-
}

crates/core_arch/src/aarch64/rand.rs

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
//!
33
//! [ACLE documentation](https://arm-software.github.io/acle/main/acle.html#random-number-generation-intrinsics)
44
5+
use stdarch_test::assert_instr;
6+
57
unsafe extern "unadjusted" {
68
#[link_name = "llvm.aarch64.rndr"]
79
fn rndr_() -> Tuple;
@@ -22,6 +24,7 @@ struct Tuple {
2224
/// is returned.
2325
#[inline]
2426
#[target_feature(enable = "rand")]
27+
#[cfg_attr(test, assert_instr(mrs))]
2528
#[unstable(feature = "stdarch_aarch64_rand", issue = "153514")]
2629
pub unsafe fn __rndr(value: *mut u64) -> i32 {
2730
let Tuple { bits, status } = rndr_();
@@ -35,29 +38,10 @@ pub unsafe fn __rndr(value: *mut u64) -> i32 {
3538
/// to by the input is set to zero and a non-zero value is returned.
3639
#[inline]
3740
#[target_feature(enable = "rand")]
41+
#[cfg_attr(test, assert_instr(mrs))]
3842
#[unstable(feature = "stdarch_aarch64_rand", issue = "153514")]
3943
pub unsafe fn __rndrrs(value: *mut u64) -> i32 {
4044
let Tuple { bits, status } = rndrrs_();
4145
unsafe { *value = bits };
4246
status as i32
4347
}
44-
45-
#[cfg(test)]
46-
mod test {
47-
use super::*;
48-
use stdarch_test::assert_instr;
49-
50-
#[cfg_attr(test, assert_instr(mrs))]
51-
#[allow(dead_code)]
52-
#[target_feature(enable = "rand")]
53-
unsafe fn test_rndr(value: &mut u64) -> i32 {
54-
__rndr(value)
55-
}
56-
57-
#[cfg_attr(test, assert_instr(mrs))]
58-
#[allow(dead_code)]
59-
#[target_feature(enable = "rand")]
60-
unsafe fn test_rndrrs(value: &mut u64) -> i32 {
61-
__rndrrs(value)
62-
}
63-
}

0 commit comments

Comments
 (0)