#![cfg_attr(feature = "cargo-clippy", allow(inline_always))]
extern {
#[inline(always)]
#[link_name = "llvm.prefetch"]
fn llvm_prefetch(address: *const u8, rw: i32, locality: i32, cache_type: i32);
}
const ICACHE : i32 = 0;
const DCACHE : i32 = 1;
const LOWEST : i32 = 0;
const LOW : i32 = 1;
const HIGH : i32 = 2;
const HIGHEST : i32 = 3;
const RW : i32 = 1;
const RD : i32 = 0;
#[inline(always)]
pub fn prefetch_lowest<T>(addr: *const T) {
unsafe { llvm_prefetch(addr as *const u8, RD, LOWEST, DCACHE); }
}
#[inline(always)]
pub fn prefetch_low<T>(addr: *const T) {
unsafe { llvm_prefetch(addr as *const u8, RD, LOW, DCACHE); }
}
#[inline(always)]
pub fn prefetch_high<T>(addr: *const T) {
unsafe { llvm_prefetch(addr as *const u8, RD, HIGH, DCACHE); }
}
#[inline(always)]
pub fn prefetch_highest<T>(addr: *const T) {
unsafe { llvm_prefetch(addr as *const u8, RD, HIGHEST, DCACHE); }
}
#[inline(always)]
pub fn prefetch_insn_lowest<T>(addr: *const T) {
unsafe { llvm_prefetch(addr as *const u8, RD, LOWEST, ICACHE); }
}
#[inline(always)]
pub fn prefetch_insn_low<T>(addr: *const T) {
unsafe { llvm_prefetch(addr as *const u8, RD, LOW, ICACHE); }
}
#[inline(always)]
pub fn prefetch_insn_high<T>(addr: *const T) {
unsafe { llvm_prefetch(addr as *const u8, RD, HIGH, ICACHE); }
}
#[inline(always)]
pub fn prefetch_insn_highest<T>(addr: *const T) {
unsafe { llvm_prefetch(addr as *const u8, RD, HIGHEST, ICACHE); }
}
#[inline(always)]
pub fn prefetch_lowest_mut<T>(addr: *mut T) {
unsafe { llvm_prefetch(addr as *const u8, RW, LOWEST, DCACHE); }
}
#[inline(always)]
pub fn prefetch_low_mut<T>(addr: *mut T) {
unsafe { llvm_prefetch(addr as *const u8, RW, LOW, DCACHE); }
}
#[inline(always)]
pub fn prefetch_high_mut<T>(addr: *mut T) {
unsafe { llvm_prefetch(addr as *const u8, RW, HIGH, DCACHE); }
}
#[inline(always)]
pub fn prefetch_highest_mut<T>(addr: *mut T) {
unsafe { llvm_prefetch(addr as *const u8, RW, HIGHEST, DCACHE); }
}
#[inline(always)]
pub fn prefetch_insn_lowest_mut<T>(addr: *mut T) {
unsafe { llvm_prefetch(addr as *const u8, RW, LOWEST, ICACHE); }
}
#[inline(always)]
pub fn prefetch_insn_low_mut<T>(addr: *mut T) {
unsafe { llvm_prefetch(addr as *const u8, RW, LOW, ICACHE); }
}
#[inline(always)]
pub fn prefetch_insn_high_mut<T>(addr: *mut T) {
unsafe { llvm_prefetch(addr as *const u8, RW, HIGH, ICACHE); }
}
#[inline(always)]
pub fn prefetch_insn_highest_mut<T>(addr: *mut T) {
unsafe { llvm_prefetch(addr as *const u8, RW, HIGHEST, ICACHE); }
}
#[cfg(test)]
mod test {
#[test]
fn does_it_compile() {
super::prefetch_high(0xdead as *const i32);
}
}