rust/tests/codegen/intrinsics/prefetch.rs
Nicholas Nethercote 72800d3b89 Run rustfmt on tests/codegen/.
Except for `simd-intrinsic/`, which has a lot of files containing
multiple types like `u8x64` which really are better when hand-formatted.

There is a surprising amount of two-space indenting in this directory.

Non-trivial changes:
- `rustfmt::skip` needed in `debug-column.rs` to preserve meaning of the
  test.
- `rustfmt::skip` used in a few places where hand-formatting read more
  nicely: `enum/enum-match.rs`
- Line number adjustments needed for the expected output of
  `debug-column.rs` and `coroutine-debug.rs`.
2024-05-31 15:56:43 +10:00

65 lines
2.6 KiB
Rust

//@ compile-flags: -C no-prepopulate-passes
#![crate_type = "lib"]
#![feature(core_intrinsics)]
use std::intrinsics::{
prefetch_read_data, prefetch_read_instruction, prefetch_write_data, prefetch_write_instruction,
};
#[no_mangle]
pub fn check_prefetch_read_data(data: &[i8]) {
unsafe {
// CHECK: call void @llvm.prefetch{{.*}}({{.*}}, i32 0, i32 0, i32 1)
prefetch_read_data(data.as_ptr(), 0);
// CHECK: call void @llvm.prefetch{{.*}}({{.*}}, i32 0, i32 1, i32 1)
prefetch_read_data(data.as_ptr(), 1);
// CHECK: call void @llvm.prefetch{{.*}}({{.*}}, i32 0, i32 2, i32 1)
prefetch_read_data(data.as_ptr(), 2);
// CHECK: call void @llvm.prefetch{{.*}}({{.*}}, i32 0, i32 3, i32 1)
prefetch_read_data(data.as_ptr(), 3);
}
}
#[no_mangle]
pub fn check_prefetch_write_data(data: &[i8]) {
unsafe {
// CHECK: call void @llvm.prefetch{{.*}}({{.*}}, i32 1, i32 0, i32 1)
prefetch_write_data(data.as_ptr(), 0);
// CHECK: call void @llvm.prefetch{{.*}}({{.*}}, i32 1, i32 1, i32 1)
prefetch_write_data(data.as_ptr(), 1);
// CHECK: call void @llvm.prefetch{{.*}}({{.*}}, i32 1, i32 2, i32 1)
prefetch_write_data(data.as_ptr(), 2);
// CHECK: call void @llvm.prefetch{{.*}}({{.*}}, i32 1, i32 3, i32 1)
prefetch_write_data(data.as_ptr(), 3);
}
}
#[no_mangle]
pub fn check_prefetch_read_instruction(data: &[i8]) {
unsafe {
// CHECK: call void @llvm.prefetch{{.*}}({{.*}}, i32 0, i32 0, i32 0)
prefetch_read_instruction(data.as_ptr(), 0);
// CHECK: call void @llvm.prefetch{{.*}}({{.*}}, i32 0, i32 1, i32 0)
prefetch_read_instruction(data.as_ptr(), 1);
// CHECK: call void @llvm.prefetch{{.*}}({{.*}}, i32 0, i32 2, i32 0)
prefetch_read_instruction(data.as_ptr(), 2);
// CHECK: call void @llvm.prefetch{{.*}}({{.*}}, i32 0, i32 3, i32 0)
prefetch_read_instruction(data.as_ptr(), 3);
}
}
#[no_mangle]
pub fn check_prefetch_write_instruction(data: &[i8]) {
unsafe {
// CHECK: call void @llvm.prefetch{{.*}}({{.*}}, i32 1, i32 0, i32 0)
prefetch_write_instruction(data.as_ptr(), 0);
// CHECK: call void @llvm.prefetch{{.*}}({{.*}}, i32 1, i32 1, i32 0)
prefetch_write_instruction(data.as_ptr(), 1);
// CHECK: call void @llvm.prefetch{{.*}}({{.*}}, i32 1, i32 2, i32 0)
prefetch_write_instruction(data.as_ptr(), 2);
// CHECK: call void @llvm.prefetch{{.*}}({{.*}}, i32 1, i32 3, i32 0)
prefetch_write_instruction(data.as_ptr(), 3);
}
}