]>
git.proxmox.com Git - rustc.git/blob - src/stdarch/crates/core_arch/src/arm/armclang.rs
1 //! ARM compiler specific intrinsics
5 //! - [ARM Compiler v 6.10 - armclang Reference Guide][arm_comp_ref]
7 //! [arm_comp_ref]: https://developer.arm.com/docs/100067/0610
10 use stdarch_test
::assert_instr
;
12 /// Inserts a breakpoint instruction.
14 /// `val` is a compile-time constant integer in range `[0, 255]`.
16 /// The breakpoint instruction inserted is:
18 /// * `BKPT` when compiling as T32,
19 /// * `BRK` when compiling as A32 or A64.
23 /// If `val` is out-of-range the behavior is **undefined**.
27 /// [ARM's documentation][arm_docs] defines that `__breakpoint` accepts the
28 /// following values for `val`:
30 /// - `0...65535` when compiling as A32 or A64,
31 /// - `0...255` when compiling as T32.
33 /// The current implementation only accepts values in range `[0, 255]` - if the
34 /// value is out-of-range the behavior is **undefined**.
36 /// [arm_docs]: https://developer.arm.com/docs/100067/latest/compiler-specific-intrinsics/__breakpoint-intrinsic
37 #[cfg_attr(all(test, target_arch = "arm"), assert_instr(bkpt, val = 0))]
38 #[cfg_attr(all(test, target_arch = "aarch64"), assert_instr(brk, val = 0))]
40 #[rustc_args_required_const(0)]
41 pub unsafe fn __breakpoint(val
: i32) {
42 // Ensure that this compiles correctly on non-arm architectures, so libstd
43 // doc builds work. The proper macro will shadow this definition below.
44 #[allow(unused_macros)]
51 #[cfg(target_arch = "arm")]
54 llvm_asm
!(concat
!("BKPT ", stringify
!($imm8
)) : : : : "volatile")
58 #[cfg(target_arch = "aarch64")]
61 llvm_asm
!(concat
!("BRK ", stringify
!($imm8
)) : : : : "volatile")
65 // We can't `panic!` inside this intrinsic, so we can't really validate the
66 // arguments here. If `val` is out-of-range this macro uses `val == 255`:
67 constify_imm8
!(val
, call
);