From f83901bb89e4043268ec3bf033b435d56e1ed303 Mon Sep 17 00:00:00 2001 From: Falco Hirschenberger Date: Fri, 21 Apr 2017 09:00:34 +0200 Subject: Adding support for the llvm `prefetch` intrinsic Related to #37251 --- src/libcore/intrinsics.rs | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) (limited to 'src/libcore') diff --git a/src/libcore/intrinsics.rs b/src/libcore/intrinsics.rs index 9f1870e56d3..3566bbdebc2 100644 --- a/src/libcore/intrinsics.rs +++ b/src/libcore/intrinsics.rs @@ -564,8 +564,55 @@ extern "rust-intrinsic" { pub fn atomic_umax_rel(dst: *mut T, src: T) -> T; pub fn atomic_umax_acqrel(dst: *mut T, src: T) -> T; pub fn atomic_umax_relaxed(dst: *mut T, src: T) -> T; + + /// The `prefetch` intrinsic is a hint to the code generator to insert a prefetch instruction + /// if supported; otherwise, it is a noop. + /// Prefetches have no effect on the behavior of the program but can change its performance + /// characteristics. + /// + /// The `locality` argument must be a constant integer and is a temporal locality specifier + /// ranging from (0) - no locality, to (3) - extremely local keep in cache + #[cfg(not(stage0))] + pub fn prefetch_read_data(data: *const T, locality: i32); + /// The `prefetch` intrinsic is a hint to the code generator to insert a prefetch instruction + /// if supported; otherwise, it is a noop. + /// Prefetches have no effect on the behavior of the program but can change its performance + /// characteristics. + /// + /// The `locality` argument must be a constant integer and is a temporal locality specifier + /// ranging from (0) - no locality, to (3) - extremely local keep in cache + #[cfg(not(stage0))] + pub fn prefetch_write_data(data: *const T, locality: i32); + /// The `prefetch` intrinsic is a hint to the code generator to insert a prefetch instruction + /// if supported; otherwise, it is a noop. + /// Prefetches have no effect on the behavior of the program but can change its performance + /// characteristics. + /// + /// The `locality` argument must be a constant integer and is a temporal locality specifier + /// ranging from (0) - no locality, to (3) - extremely local keep in cache + #[cfg(not(stage0))] + pub fn prefetch_read_instruction(data: *const T, locality: i32); + /// The `prefetch` intrinsic is a hint to the code generator to insert a prefetch instruction + /// if supported; otherwise, it is a noop. + /// Prefetches have no effect on the behavior of the program but can change its performance + /// characteristics. + /// + /// The `locality` argument must be a constant integer and is a temporal locality specifier + /// ranging from (0) - no locality, to (3) - extremely local keep in cache + #[cfg(not(stage0))] + pub fn prefetch_write_instruction(data: *const T, locality: i32); } +// Empty bootstrap implementations for stage0 compilation +#[cfg(stage0)] +pub fn prefetch_read_data(_data: *const T, _locality: i32) { /* EMPTY */ } +#[cfg(stage0)] +pub fn prefetch_write_data(_data: *const T, _locality: i32) { /* EMPTY */ } +#[cfg(stage0)] +pub fn prefetch_read_instruction(_data: *const T, _locality: i32) { /* EMPTY */ } +#[cfg(stage0)] +pub fn prefetch_write_instruction(_data: *const T, _locality: i32) { /* EMPTY */ } + extern "rust-intrinsic" { pub fn atomic_fence(); -- cgit 1.4.1-3-g733a5