diff options
| author | beetrees <b@beetr.ee> | 2024-10-17 01:13:17 +0100 |
|---|---|---|
| committer | beetrees <b@beetr.ee> | 2024-10-17 02:07:02 +0100 |
| commit | 3ea91c05db131ec7c4bd6d507b569a58cd19dd93 (patch) | |
| tree | 245af27bd4396fc1625dc60c59752a477bd8ce4b /tests | |
| parent | 7342830c05ec0996e9e4b7df550b1043dca7829c (diff) | |
| download | rust-3ea91c05db131ec7c4bd6d507b569a58cd19dd93.tar.gz rust-3ea91c05db131ec7c4bd6d507b569a58cd19dd93.zip | |
Always specify `llvm_abiname` for RISC-V targets
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/assembly/riscv-soft-abi-with-float-features.rs | 46 | ||||
| -rw-r--r-- | tests/codegen/riscv-target-abi.rs | 2 |
2 files changed, 47 insertions, 1 deletions
diff --git a/tests/assembly/riscv-soft-abi-with-float-features.rs b/tests/assembly/riscv-soft-abi-with-float-features.rs new file mode 100644 index 00000000000..733137f5700 --- /dev/null +++ b/tests/assembly/riscv-soft-abi-with-float-features.rs @@ -0,0 +1,46 @@ +//@ assembly-output: emit-asm +//@ compile-flags: --target riscv64imac-unknown-none-elf -Ctarget-feature=+f,+d +//@ needs-llvm-components: riscv + +#![feature(no_core, lang_items, f16)] +#![crate_type = "lib"] +#![no_core] + +#[lang = "sized"] +trait Sized {} + +#[lang = "copy"] +trait Copy {} + +impl Copy for f16 {} +impl Copy for f32 {} +impl Copy for f64 {} + +// This test checks that the floats are all returned in `a0` as required by the `lp64` ABI. + +// CHECK-LABEL: read_f16 +#[no_mangle] +pub extern "C" fn read_f16(x: &f16) -> f16 { + // CHECK: lh a0, 0(a0) + // CHECK-NEXT: lui a1, 1048560 + // CHECK-NEXT: or a0, a0, a1 + // CHECK-NEXT: ret + *x +} + +// CHECK-LABEL: read_f32 +#[no_mangle] +pub extern "C" fn read_f32(x: &f32) -> f32 { + // CHECK: flw fa5, 0(a0) + // CHECK-NEXT: fmv.x.w a0, fa5 + // CHECK-NEXT: ret + *x +} + +// CHECK-LABEL: read_f64 +#[no_mangle] +pub extern "C" fn read_f64(x: &f64) -> f64 { + // CHECK: ld a0, 0(a0) + // CHECK-NEXT: ret + *x +} diff --git a/tests/codegen/riscv-target-abi.rs b/tests/codegen/riscv-target-abi.rs index 5d545af9c76..88da4ece7ba 100644 --- a/tests/codegen/riscv-target-abi.rs +++ b/tests/codegen/riscv-target-abi.rs @@ -10,7 +10,7 @@ //@[riscv32imac] compile-flags: --target=riscv32imac-unknown-none-elf //@[riscv32imac] needs-llvm-components: riscv -// riscv32imac-NOT: !"target-abi" +// riscv32imac: !{i32 1, !"target-abi", !"ilp32"} #![feature(no_core, lang_items)] #![crate_type = "lib"] |
