Skip to content

Commit 0b8357b

Browse files
japaricgnzlbg
authored andcommitted
add the trap instrinsic
1 parent f474174 commit 0b8357b

File tree

7 files changed

+68
-0
lines changed

7 files changed

+68
-0
lines changed

coresimd/aarch64/mod.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,13 @@ pub use self::neon::*;
1414

1515
mod crypto;
1616
pub use self::crypto::*;
17+
18+
#[cfg(test)]
19+
use stdsimd_test::assert_instr;
20+
21+
/// Generates the trap instruction `BRK 1`
22+
#[cfg_attr(test, assert_instr(brk))]
23+
#[inline]
24+
pub unsafe fn brk() -> ! {
25+
::_core::intrinsics::abort()
26+
}

coresimd/arm/mod.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,3 +42,14 @@ mod neon;
4242
dox
4343
))]
4444
pub use self::neon::*;
45+
46+
#[cfg(test)]
47+
use stdsimd_test::assert_instr;
48+
49+
/// Generates the trap instruction `UDF`
50+
#[cfg(target_arch = "arm")]
51+
#[cfg_attr(test, assert_instr(udf))]
52+
#[inline]
53+
pub unsafe fn udf() -> ! {
54+
::_core::intrinsics::abort()
55+
}

coresimd/mips/mod.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,13 @@
22
33
mod msa;
44
pub use self::msa::*;
5+
6+
#[cfg(test)]
7+
use stdsimd_test::assert_instr;
8+
9+
/// Generates the trap instruction `BREAK`
10+
#[cfg_attr(test, assert_instr(break))]
11+
#[inline]
12+
pub unsafe fn break_() -> ! {
13+
::_core::intrinsics::abort()
14+
}

coresimd/nvptx/mod.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@
1111
//! [llvm_docs]:
1212
//! https://llvm.org/docs/NVPTXUsage.html
1313
14+
#[cfg(test)]
15+
use stdsimd_test::assert_instr;
16+
1417
#[allow(improper_ctypes)]
1518
extern "C" {
1619
#[link_name = "llvm.nvvm.barrier0"]
@@ -118,3 +121,10 @@ pub unsafe fn _thread_idx_y() -> i32 {
118121
pub unsafe fn _thread_idx_z() -> i32 {
119122
thread_idx_z()
120123
}
124+
125+
/// Generates the trap instruction `TRAP`
126+
#[cfg_attr(test, assert_instr(trap))]
127+
#[inline]
128+
pub unsafe fn trap() -> ! {
129+
::_core::intrinsics::abort()
130+
}

coresimd/powerpc/mod.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,13 @@ pub use self::altivec::*;
77

88
mod vsx;
99
pub use self::vsx::*;
10+
11+
#[cfg(test)]
12+
use stdsimd_test::assert_instr;
13+
14+
/// Generates the trap instruction `TRAP`
15+
#[cfg_attr(test, assert_instr(trap))]
16+
#[inline]
17+
pub unsafe fn trap() -> ! {
18+
::_core::intrinsics::abort()
19+
}

coresimd/wasm32/mod.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,10 @@ pub unsafe fn grow_memory(delta: i32) -> i32 {
3838

3939
pub mod atomic;
4040
pub mod memory;
41+
42+
/// Generates the trap instruction `UNREACHABLE`
43+
#[cfg_attr(test, assert_instr(unreachable))]
44+
#[inline]
45+
pub unsafe fn unreachable() -> ! {
46+
::_core::intrinsics::abort()
47+
}

coresimd/x86/mod.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -512,3 +512,13 @@ pub use self::rdrand::*;
512512

513513
mod sha;
514514
pub use self::sha::*;
515+
516+
#[cfg(test)]
517+
use stdsimd_test::assert_instr;
518+
519+
/// Generates the trap instruction `UD2`
520+
#[cfg_attr(test, assert_instr(ud2))]
521+
#[inline]
522+
pub unsafe fn ud2() -> ! {
523+
::_core::intrinsics::abort()
524+
}

0 commit comments

Comments
 (0)