22//!
33//! # References
44//!
5- //! - [ARM Compiler v 6.10 - armclang Reference Guide](https://developer.arm.com/docs/100067/0610)
5+ //! - [ARM Compiler v 6.10 - armclang Reference Guide][arm_comp_ref]
6+ //!
7+ //! [arm_comp_ref]: https://developer.arm.com/docs/100067/0610
68
79#[ cfg( test) ]
810use stdsimd_test:: assert_instr;
911
10- /// This intrinsic inserts a BKPT instruction into the instruction stream generated by the compiler
12+ /// Inserts a breakpoint instruction.
13+ ///
14+ /// `val` is a compile-time constant integer in range `[0, 255]`.
15+ ///
16+ /// The breakpoint instruction inserted is:
17+ ///
18+ /// * `BKPT` when compiling as T32,
19+ /// * `BRK` when compiling as A32 or A64.
1120///
12- /// It enables you to include a breakpoint instruction in your Rust code
21+ /// # Safety
1322///
14- /// `val` is a compile-time constant integer whose range is:
23+ /// If `val` is out-of-range the behavior is **undefined**.
1524///
16- /// - `0...65535` if you are compiling source as A32 or A64 code.
17- /// - `0...255` if you are compiling source as T32 code.
25+ /// # Note
1826///
19- /// [ARM's documentation](https://developer.arm.com/docs/100067/latest/compiler-specific-intrinsics/__breakpoint-intrinsic)
27+ /// [ARM's documentation][arm_docs] defines that `__breakpoint` accepts the
28+ /// following values for `val`:
2029///
21- /// **NOTE**: Due to compiler limitations this function only supports the range `0...255` in A32 and
22- /// A64 mode.
30+ /// - `0...65535` when compiling as A32 or A64,
31+ /// - `0...255` when compiling as T32.
32+ ///
33+ /// The current implementation only accepts values in range `[0, 255]` - if the
34+ /// value is out-of-range the behavior is **undefined**.
35+ ///
36+ /// [arm_docs]: https://developer.arm.com/docs/100067/latest/compiler-specific-intrinsics/__breakpoint-intrinsic
2337#[ cfg_attr( all( test, target_arch = "arm" ) , assert_instr( bkpt, val = 0 ) ) ]
2438#[ cfg_attr( all( test, target_arch = "aarch64" ) , assert_instr( brk, val = 0 ) ) ]
2539#[ inline( always) ]
@@ -39,8 +53,7 @@ pub unsafe fn __breakpoint(val: i32) {
3953 }
4054 }
4155
42- // validate range
43- assert ! ( val >= 0 && val <= 255 ) ;
44-
56+ // We can't `panic!` inside this intrinsic, so we can't really validate the
57+ // arguments here. If `val` is out-of-range this macro uses `val == 255`:
4558 constify_imm8 ! ( val, call) ;
4659}
0 commit comments