diff options
| author | Falco Hirschenberger <falco.hirschenberger@gmail.com> | 2017-04-21 09:00:34 +0200 |
|---|---|---|
| committer | Falco Hirschenberger <falco.hirschenberger@gmail.com> | 2017-06-01 08:34:16 +0200 |
| commit | f83901bb89e4043268ec3bf033b435d56e1ed303 (patch) | |
| tree | 09737778c8b856c79e244fbf8f82562ed7adb0aa /src/librustc_trans | |
| parent | e1fe1a8933c5d13da9fcde618c074c0d4e099b96 (diff) | |
| download | rust-f83901bb89e4043268ec3bf033b435d56e1ed303.tar.gz rust-f83901bb89e4043268ec3bf033b435d56e1ed303.zip | |
Adding support for the llvm `prefetch` intrinsic
Related to #37251
Diffstat (limited to 'src/librustc_trans')
| -rw-r--r-- | src/librustc_trans/context.rs | 1 | ||||
| -rw-r--r-- | src/librustc_trans/intrinsic.rs | 13 |
2 files changed, 13 insertions, 1 deletions
diff --git a/src/librustc_trans/context.rs b/src/librustc_trans/context.rs index c3b16c2d07d..0413b0ea5c8 100644 --- a/src/librustc_trans/context.rs +++ b/src/librustc_trans/context.rs @@ -942,6 +942,7 @@ fn declare_intrinsic(ccx: &CrateContext, key: &str) -> Option<ValueRef> { ifn!("llvm.x86.seh.recoverfp", fn(i8p, i8p) -> i8p); ifn!("llvm.assume", fn(i1) -> void); + ifn!("llvm.prefetch", fn(i8p, t_i32, t_i32, t_i32) -> void); if ccx.sess().opts.debuginfo != NoDebugInfo { ifn!("llvm.dbg.declare", fn(Type::metadata(ccx), Type::metadata(ccx)) -> void); diff --git a/src/librustc_trans/intrinsic.rs b/src/librustc_trans/intrinsic.rs index 54e20f590c6..f2e6aa3ef00 100644 --- a/src/librustc_trans/intrinsic.rs +++ b/src/librustc_trans/intrinsic.rs @@ -255,7 +255,18 @@ pub fn trans_intrinsic_call<'a, 'tcx>(bcx: &Builder<'a, 'tcx>, } C_nil(ccx) }, - + "prefetch_read_data" | "prefetch_write_data" | + "prefetch_read_instruction" | "prefetch_write_instruction" => { + let expect = ccx.get_intrinsic(&("llvm.prefetch")); + let (rw, cache_type) = match name { + "prefetch_read_data" => (0, 1), + "prefetch_write_data" => (1, 1), + "prefetch_read_instruction" => (0, 0), + "prefetch_write_instruction" => (1, 0), + _ => bug!() + }; + bcx.call(expect, &[llargs[0], C_i32(ccx, rw), llargs[1], C_i32(ccx, cache_type)], None) + }, "ctlz" | "cttz" | "ctpop" | "bswap" | "add_with_overflow" | "sub_with_overflow" | "mul_with_overflow" | "overflowing_add" | "overflowing_sub" | "overflowing_mul" | |
