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+
57unsafe 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" ) ]
3740pub 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" ) ]
5357pub 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" ) ]
6873pub 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" ) ]
8288pub 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" ) ]
94101pub 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" ) ]
103111pub 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- }
0 commit comments