ab_riscv_interpreter/rv32/b/zbb/
rv32_zbb_helpers.rs1use const_fn_specialization::const_fn_specialization;
4
5#[const_fn_specialization]
6#[inline(always)]
7#[doc(hidden)]
8#[cfg_attr(feature = "no-panic", no_panic_const::no_panic)]
9pub fn orc_b(src: u32) -> u32 {
10 cfg_select! {
12 all(not(miri), target_arch = "riscv32", target_feature = "zbb") => {
13 unsafe { core::arch::riscv32::orc_b(src as usize) as u32 }
15 }
16 _ => orc_b_generic(src),
17 }
18}
19
20#[const_fn_specialization]
21#[inline(always)]
22#[doc(hidden)]
23#[cfg_attr(feature = "no-panic", no_panic_const::no_panic)]
24pub const fn orc_b(src: u32) -> u32 {
25 orc_b_generic(src)
26}
27
28#[inline(always)]
29#[cfg_attr(feature = "no-panic", no_panic_const::no_panic)]
30const fn orc_b_generic(src: u32) -> u32 {
31 let bytes = src.to_le_bytes();
32
33 u32::from_le_bytes([
34 if bytes[0] != 0 { 0xFF } else { 0 },
35 if bytes[1] != 0 { 0xFF } else { 0 },
36 if bytes[2] != 0 { 0xFF } else { 0 },
37 if bytes[3] != 0 { 0xFF } else { 0 },
38 ])
39}