1 // Copyright 2017 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
11 // compile-flags: -C no-prepopulate-passes
13 #![crate_type = "lib"]
14 #![feature(core_intrinsics)]
16 use std::intrinsics::{prefetch_read_data, prefetch_write_data,
17 prefetch_read_instruction, prefetch_write_instruction};
20 pub fn check_prefetch_read_data(data: &[i8]) {
22 // CHECK: call void @llvm.prefetch(i8* %{{.*}}, i32 0, i32 0, i32 1)
23 prefetch_read_data(data.as_ptr(), 0);
24 // CHECK: call void @llvm.prefetch(i8* %{{.*}}, i32 0, i32 1, i32 1)
25 prefetch_read_data(data.as_ptr(), 1);
26 // CHECK: call void @llvm.prefetch(i8* %{{.*}}, i32 0, i32 2, i32 1)
27 prefetch_read_data(data.as_ptr(), 2);
28 // CHECK: call void @llvm.prefetch(i8* %{{.*}}, i32 0, i32 3, i32 1)
29 prefetch_read_data(data.as_ptr(), 3);
34 pub fn check_prefetch_write_data(data: &[i8]) {
36 // CHECK: call void @llvm.prefetch(i8* %{{.*}}, i32 1, i32 0, i32 1)
37 prefetch_write_data(data.as_ptr(), 0);
38 // CHECK: call void @llvm.prefetch(i8* %{{.*}}, i32 1, i32 1, i32 1)
39 prefetch_write_data(data.as_ptr(), 1);
40 // CHECK: call void @llvm.prefetch(i8* %{{.*}}, i32 1, i32 2, i32 1)
41 prefetch_write_data(data.as_ptr(), 2);
42 // CHECK: call void @llvm.prefetch(i8* %{{.*}}, i32 1, i32 3, i32 1)
43 prefetch_write_data(data.as_ptr(), 3);
48 pub fn check_prefetch_read_instruction(data: &[i8]) {
50 // CHECK: call void @llvm.prefetch(i8* %{{.*}}, i32 0, i32 0, i32 0)
51 prefetch_read_instruction(data.as_ptr(), 0);
52 // CHECK: call void @llvm.prefetch(i8* %{{.*}}, i32 0, i32 1, i32 0)
53 prefetch_read_instruction(data.as_ptr(), 1);
54 // CHECK: call void @llvm.prefetch(i8* %{{.*}}, i32 0, i32 2, i32 0)
55 prefetch_read_instruction(data.as_ptr(), 2);
56 // CHECK: call void @llvm.prefetch(i8* %{{.*}}, i32 0, i32 3, i32 0)
57 prefetch_read_instruction(data.as_ptr(), 3);
62 pub fn check_prefetch_write_instruction(data: &[i8]) {
64 // CHECK: call void @llvm.prefetch(i8* %{{.*}}, i32 1, i32 0, i32 0)
65 prefetch_write_instruction(data.as_ptr(), 0);
66 // CHECK: call void @llvm.prefetch(i8* %{{.*}}, i32 1, i32 1, i32 0)
67 prefetch_write_instruction(data.as_ptr(), 1);
68 // CHECK: call void @llvm.prefetch(i8* %{{.*}}, i32 1, i32 2, i32 0)
69 prefetch_write_instruction(data.as_ptr(), 2);
70 // CHECK: call void @llvm.prefetch(i8* %{{.*}}, i32 1, i32 3, i32 0)
71 prefetch_write_instruction(data.as_ptr(), 3);