2017-04-21 02:00:34 -05:00
|
|
|
//@ compile-flags: -C no-prepopulate-passes
|
|
|
|
|
|
|
|
#![crate_type = "lib"]
|
|
|
|
#![feature(core_intrinsics)]
|
|
|
|
|
2024-05-28 23:11:20 -05:00
|
|
|
use std::intrinsics::{
|
|
|
|
prefetch_read_data, prefetch_read_instruction, prefetch_write_data, prefetch_write_instruction,
|
|
|
|
};
|
2017-04-21 02:00:34 -05:00
|
|
|
|
|
|
|
#[no_mangle]
|
|
|
|
pub fn check_prefetch_read_data(data: &[i8]) {
|
|
|
|
unsafe {
|
2022-02-21 04:21:23 -06:00
|
|
|
// CHECK: call void @llvm.prefetch{{.*}}({{.*}}, i32 0, i32 0, i32 1)
|
2017-04-21 02:00:34 -05:00
|
|
|
prefetch_read_data(data.as_ptr(), 0);
|
2022-02-21 04:21:23 -06:00
|
|
|
// CHECK: call void @llvm.prefetch{{.*}}({{.*}}, i32 0, i32 1, i32 1)
|
2017-04-21 02:00:34 -05:00
|
|
|
prefetch_read_data(data.as_ptr(), 1);
|
2022-02-21 04:21:23 -06:00
|
|
|
// CHECK: call void @llvm.prefetch{{.*}}({{.*}}, i32 0, i32 2, i32 1)
|
2017-04-21 02:00:34 -05:00
|
|
|
prefetch_read_data(data.as_ptr(), 2);
|
2022-02-21 04:21:23 -06:00
|
|
|
// CHECK: call void @llvm.prefetch{{.*}}({{.*}}, i32 0, i32 3, i32 1)
|
2017-04-21 02:00:34 -05:00
|
|
|
prefetch_read_data(data.as_ptr(), 3);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#[no_mangle]
|
|
|
|
pub fn check_prefetch_write_data(data: &[i8]) {
|
|
|
|
unsafe {
|
2022-02-21 04:21:23 -06:00
|
|
|
// CHECK: call void @llvm.prefetch{{.*}}({{.*}}, i32 1, i32 0, i32 1)
|
2017-04-21 02:00:34 -05:00
|
|
|
prefetch_write_data(data.as_ptr(), 0);
|
2022-02-21 04:21:23 -06:00
|
|
|
// CHECK: call void @llvm.prefetch{{.*}}({{.*}}, i32 1, i32 1, i32 1)
|
2017-04-21 02:00:34 -05:00
|
|
|
prefetch_write_data(data.as_ptr(), 1);
|
2022-02-21 04:21:23 -06:00
|
|
|
// CHECK: call void @llvm.prefetch{{.*}}({{.*}}, i32 1, i32 2, i32 1)
|
2017-04-21 02:00:34 -05:00
|
|
|
prefetch_write_data(data.as_ptr(), 2);
|
2022-02-21 04:21:23 -06:00
|
|
|
// CHECK: call void @llvm.prefetch{{.*}}({{.*}}, i32 1, i32 3, i32 1)
|
2017-04-21 02:00:34 -05:00
|
|
|
prefetch_write_data(data.as_ptr(), 3);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#[no_mangle]
|
|
|
|
pub fn check_prefetch_read_instruction(data: &[i8]) {
|
|
|
|
unsafe {
|
2022-02-21 04:21:23 -06:00
|
|
|
// CHECK: call void @llvm.prefetch{{.*}}({{.*}}, i32 0, i32 0, i32 0)
|
2017-04-21 02:00:34 -05:00
|
|
|
prefetch_read_instruction(data.as_ptr(), 0);
|
2022-02-21 04:21:23 -06:00
|
|
|
// CHECK: call void @llvm.prefetch{{.*}}({{.*}}, i32 0, i32 1, i32 0)
|
2017-04-21 02:00:34 -05:00
|
|
|
prefetch_read_instruction(data.as_ptr(), 1);
|
2022-02-21 04:21:23 -06:00
|
|
|
// CHECK: call void @llvm.prefetch{{.*}}({{.*}}, i32 0, i32 2, i32 0)
|
2017-04-21 02:00:34 -05:00
|
|
|
prefetch_read_instruction(data.as_ptr(), 2);
|
2022-02-21 04:21:23 -06:00
|
|
|
// CHECK: call void @llvm.prefetch{{.*}}({{.*}}, i32 0, i32 3, i32 0)
|
2017-04-21 02:00:34 -05:00
|
|
|
prefetch_read_instruction(data.as_ptr(), 3);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#[no_mangle]
|
|
|
|
pub fn check_prefetch_write_instruction(data: &[i8]) {
|
|
|
|
unsafe {
|
2022-02-21 04:21:23 -06:00
|
|
|
// CHECK: call void @llvm.prefetch{{.*}}({{.*}}, i32 1, i32 0, i32 0)
|
2017-04-21 02:00:34 -05:00
|
|
|
prefetch_write_instruction(data.as_ptr(), 0);
|
2022-02-21 04:21:23 -06:00
|
|
|
// CHECK: call void @llvm.prefetch{{.*}}({{.*}}, i32 1, i32 1, i32 0)
|
2017-04-21 02:00:34 -05:00
|
|
|
prefetch_write_instruction(data.as_ptr(), 1);
|
2022-02-21 04:21:23 -06:00
|
|
|
// CHECK: call void @llvm.prefetch{{.*}}({{.*}}, i32 1, i32 2, i32 0)
|
2017-04-21 02:00:34 -05:00
|
|
|
prefetch_write_instruction(data.as_ptr(), 2);
|
2022-02-21 04:21:23 -06:00
|
|
|
// CHECK: call void @llvm.prefetch{{.*}}({{.*}}, i32 1, i32 3, i32 0)
|
2017-04-21 02:00:34 -05:00
|
|
|
prefetch_write_instruction(data.as_ptr(), 3);
|
|
|
|
}
|
|
|
|
}
|