2
2
//!
3
3
//! # References
4
4
//!
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
6
8
7
9
#[ cfg( test) ]
8
10
use stdsimd_test:: assert_instr;
9
11
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.
11
20
///
12
- /// It enables you to include a breakpoint instruction in your Rust code
21
+ /// # Safety
13
22
///
14
- /// `val` is a compile-time constant integer whose range is:
23
+ /// If `val` is out-of-range the behavior is **undefined**.
15
24
///
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
18
26
///
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`:
20
29
///
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
23
37
#[ cfg_attr( all( test, target_arch = "arm" ) , assert_instr( bkpt, val = 0 ) ) ]
24
38
#[ cfg_attr( all( test, target_arch = "aarch64" ) , assert_instr( brk, val = 0 ) ) ]
25
39
#[ inline( always) ]
@@ -39,8 +53,7 @@ pub unsafe fn __breakpoint(val: i32) {
39
53
}
40
54
}
41
55
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`:
45
58
constify_imm8 ! ( val, call) ;
46
59
}
0 commit comments