ab_riscv_interpreter/rv64/b/zbb/rv64_zbb_helpers.rs
1//! Opaque helpers for Zbb extension
2
3#[inline(always)]
4#[doc(hidden)]
5pub fn orc_b(src: u64) -> u64 {
6 // TODO: Miri is excluded because corresponding intrinsic is not implemented there
7 cfg_select! {
8 all(not(miri), target_arch = "riscv64", target_feature = "zbb") => {
9 // SAFETY: Compile-time checked for supported feature
10 unsafe { core::arch::riscv64::orc_b(src as usize) as u64 }
11 }
12 _ => {{
13 let mut bytes = src.to_le_bytes();
14 // Explicit loop to ensure inlining
15 for byte in &mut bytes {
16 *byte = if *byte != 0 { 0xFF } else { 0 };
17 }
18 u64::from_le_bytes(bytes)
19 }}
20 }
21}