Skip to content

Commit

Permalink
test: codegen: Add riscv abi llvm intrinsics test
Browse files Browse the repository at this point in the history
  • Loading branch information
tblah committed Jun 4, 2020
1 parent c872dcf commit 37e8e05
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/test/codegen/call-llvm-intrinsics.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
// compile-flags: -C no-prepopulate-passes

// ignore-riscv64

#![feature(link_llvm_intrinsics)]
#![crate_type = "lib"]

Expand Down
30 changes: 30 additions & 0 deletions src/test/codegen/riscv-abi/call-llvm-intrinsics.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// compile-flags: -C no-prepopulate-passes

// only-riscv64

#![feature(link_llvm_intrinsics)]
#![crate_type = "lib"]

struct A;

impl Drop for A {
fn drop(&mut self) {
println!("A");
}
}

extern {
#[link_name = "llvm.sqrt.f32"]
fn sqrt(x: f32) -> f32;
}

pub fn do_call() {
let _a = A;

unsafe {
// Ensure that we `call` LLVM intrinsics instead of trying to `invoke` them
// CHECK: store float 4.000000e+00, float* %{{.}}, align 4
// CHECK: call float @llvm.sqrt.f32(float %{{.}}
sqrt(4.0);
}
}

0 comments on commit 37e8e05

Please sign in to comment.