1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
#![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);
}
}