diff options
Diffstat (limited to 'tests/codegen')
| -rw-r--r-- | tests/codegen/float/f128.rs | 6 | ||||
| -rw-r--r-- | tests/codegen/float/f16.rs | 49 | ||||
| -rw-r--r-- | tests/codegen/regparm-inreg.rs | 125 | ||||
| -rw-r--r-- | tests/codegen/riscv-target-abi.rs | 2 |
4 files changed, 157 insertions, 25 deletions
diff --git a/tests/codegen/float/f128.rs b/tests/codegen/float/f128.rs index 4af264101de..514d35433e1 100644 --- a/tests/codegen/float/f128.rs +++ b/tests/codegen/float/f128.rs @@ -1,4 +1,4 @@ -// 32-bit x86 returns `f32` and `f64` differently to avoid the x87 stack. +// 32-bit x86 returns float types differently to avoid the x87 stack. // 32-bit systems will return 128bit values using a return area pointer. //@ revisions: x86 bit32 bit64 //@[x86] only-x86 @@ -152,7 +152,9 @@ pub fn f128_rem_assign(a: &mut f128, b: f128) { /* float to float conversions */ -// CHECK-LABEL: half @f128_as_f16( +// x86-LABEL: i16 @f128_as_f16( +// bits32-LABEL: half @f128_as_f16( +// bits64-LABEL: half @f128_as_f16( #[no_mangle] pub fn f128_as_f16(a: f128) -> f16 { // CHECK: fptrunc fp128 %{{.+}} to half diff --git a/tests/codegen/float/f16.rs b/tests/codegen/float/f16.rs index 80931051f18..5c3a5893b9d 100644 --- a/tests/codegen/float/f16.rs +++ b/tests/codegen/float/f16.rs @@ -1,4 +1,4 @@ -// 32-bit x86 returns `f32` and `f64` differently to avoid the x87 stack. +// 32-bit x86 returns float types differently to avoid the x87 stack. // 32-bit systems will return 128bit values using a return area pointer. //@ revisions: x86 bit32 bit64 //@[x86] only-x86 @@ -58,42 +58,44 @@ pub fn f16_le(a: f16, b: f16) -> bool { a <= b } -// CHECK-LABEL: half @f16_neg( +// This is where we check the argument and return ABI for f16. +// other-LABEL: half @f16_neg(half +// x86-LABEL: i16 @f16_neg(half #[no_mangle] pub fn f16_neg(a: f16) -> f16 { // CHECK: fneg half %{{.+}} -a } -// CHECK-LABEL: half @f16_add( +// CHECK-LABEL: @f16_add #[no_mangle] pub fn f16_add(a: f16, b: f16) -> f16 { // CHECK: fadd half %{{.+}}, %{{.+}} a + b } -// CHECK-LABEL: half @f16_sub( +// CHECK-LABEL: @f16_sub #[no_mangle] pub fn f16_sub(a: f16, b: f16) -> f16 { // CHECK: fsub half %{{.+}}, %{{.+}} a - b } -// CHECK-LABEL: half @f16_mul( +// CHECK-LABEL: @f16_mul #[no_mangle] pub fn f16_mul(a: f16, b: f16) -> f16 { // CHECK: fmul half %{{.+}}, %{{.+}} a * b } -// CHECK-LABEL: half @f16_div( +// CHECK-LABEL: @f16_div #[no_mangle] pub fn f16_div(a: f16, b: f16) -> f16 { // CHECK: fdiv half %{{.+}}, %{{.+}} a / b } -// CHECK-LABEL: half @f16_rem( +// CHECK-LABEL: @f16_rem #[no_mangle] pub fn f16_rem(a: f16, b: f16) -> f16 { // CHECK: frem half %{{.+}}, %{{.+}} @@ -142,10 +144,13 @@ pub fn f16_rem_assign(a: &mut f16, b: f16) { /* float to float conversions */ -// CHECK-LABEL: half @f16_as_self( +// other-LABEL: half @f16_as_self( +// x86-LABEL: i16 @f16_as_self( #[no_mangle] pub fn f16_as_self(a: f16) -> f16 { - // CHECK: ret half %{{.+}} + // other-CHECK: ret half %{{.+}} + // x86-CHECK: bitcast half + // x86-CHECK: ret i16 a as f16 } @@ -176,21 +181,21 @@ pub fn f16_as_f128(a: f16) -> f128 { a as f128 } -// CHECK-LABEL: half @f32_as_f16( +// CHECK-LABEL: @f32_as_f16 #[no_mangle] pub fn f32_as_f16(a: f32) -> f16 { // CHECK: fptrunc float %{{.+}} to half a as f16 } -// CHECK-LABEL: half @f64_as_f16( +// CHECK-LABEL: @f64_as_f16 #[no_mangle] pub fn f64_as_f16(a: f64) -> f16 { // CHECK: fptrunc double %{{.+}} to half a as f16 } -// CHECK-LABEL: half @f128_as_f16( +// CHECK-LABEL: @f128_as_f16 #[no_mangle] pub fn f128_as_f16(a: f128) -> f16 { // CHECK: fptrunc fp128 %{{.+}} to half @@ -273,70 +278,70 @@ pub fn f16_as_i128(a: f16) -> i128 { /* int to float conversions */ -// CHECK-LABEL: half @u8_as_f16( +// CHECK-LABEL: @u8_as_f16 #[no_mangle] pub fn u8_as_f16(a: u8) -> f16 { // CHECK: uitofp i8 %{{.+}} to half a as f16 } -// CHECK-LABEL: half @u16_as_f16( +// CHECK-LABEL: @u16_as_f16 #[no_mangle] pub fn u16_as_f16(a: u16) -> f16 { // CHECK: uitofp i16 %{{.+}} to half a as f16 } -// CHECK-LABEL: half @u32_as_f16( +// CHECK-LABEL: @u32_as_f16 #[no_mangle] pub fn u32_as_f16(a: u32) -> f16 { // CHECK: uitofp i32 %{{.+}} to half a as f16 } -// CHECK-LABEL: half @u64_as_f16( +// CHECK-LABEL: @u64_as_f16 #[no_mangle] pub fn u64_as_f16(a: u64) -> f16 { // CHECK: uitofp i64 %{{.+}} to half a as f16 } -// CHECK-LABEL: half @u128_as_f16( +// CHECK-LABEL: @u128_as_f16 #[no_mangle] pub fn u128_as_f16(a: u128) -> f16 { // CHECK: uitofp i128 %{{.+}} to half a as f16 } -// CHECK-LABEL: half @i8_as_f16( +// CHECK-LABEL: @i8_as_f16 #[no_mangle] pub fn i8_as_f16(a: i8) -> f16 { // CHECK: sitofp i8 %{{.+}} to half a as f16 } -// CHECK-LABEL: half @i16_as_f16( +// CHECK-LABEL: @i16_as_f16 #[no_mangle] pub fn i16_as_f16(a: i16) -> f16 { // CHECK: sitofp i16 %{{.+}} to half a as f16 } -// CHECK-LABEL: half @i32_as_f16( +// CHECK-LABEL: @i32_as_f16 #[no_mangle] pub fn i32_as_f16(a: i32) -> f16 { // CHECK: sitofp i32 %{{.+}} to half a as f16 } -// CHECK-LABEL: half @i64_as_f16( +// CHECK-LABEL: @i64_as_f16 #[no_mangle] pub fn i64_as_f16(a: i64) -> f16 { // CHECK: sitofp i64 %{{.+}} to half a as f16 } -// CHECK-LABEL: half @i128_as_f16( +// CHECK-LABEL: @i128_as_f16 #[no_mangle] pub fn i128_as_f16(a: i128) -> f16 { // CHECK: sitofp i128 %{{.+}} to half diff --git a/tests/codegen/regparm-inreg.rs b/tests/codegen/regparm-inreg.rs new file mode 100644 index 00000000000..c8c647bcc87 --- /dev/null +++ b/tests/codegen/regparm-inreg.rs @@ -0,0 +1,125 @@ +// Checks how `regparm` flag works with different calling conventions: +// marks function arguments as "inreg" like the C/C++ compilers for the platforms. +// x86 only. + +//@ compile-flags: --target i686-unknown-linux-gnu -O -C no-prepopulate-passes +//@ needs-llvm-components: x86 + +//@ revisions:regparm0 regparm1 regparm2 regparm3 +//@[regparm0] compile-flags: -Zregparm=0 +//@[regparm1] compile-flags: -Zregparm=1 +//@[regparm2] compile-flags: -Zregparm=2 +//@[regparm3] compile-flags: -Zregparm=3 + +#![crate_type = "lib"] +#![no_core] +#![feature(no_core, lang_items, repr_simd)] +#[lang = "sized"] +trait Sized {} +#[lang = "copy"] +trait Copy {} + +pub mod tests { + // regparm doesn't work for "fastcall" calling conv (only 2 inregs) + // CHECK: @f1(i32 inreg noundef %_1, i32 inreg noundef %_2, i32 noundef %_3) + #[no_mangle] + pub extern "fastcall" fn f1(_: i32, _: i32, _: i32) {} + + // regparm0: @f3(i32 noundef %_1, i32 noundef %_2, i32 noundef %_3) + // regparm1: @f3(i32 inreg noundef %_1, i32 noundef %_2, i32 noundef %_3) + // regparm2: @f3(i32 inreg noundef %_1, i32 inreg noundef %_2, i32 noundef %_3) + // regparm3: @f3(i32 inreg noundef %_1, i32 inreg noundef %_2, i32 inreg noundef %_3) + #[no_mangle] + pub extern "C" fn f3(_: i32, _: i32, _: i32) {} + + // regparm0: @f4(i32 noundef %_1, i32 noundef %_2, i32 noundef %_3) + // regparm1: @f4(i32 inreg noundef %_1, i32 noundef %_2, i32 noundef %_3) + // regparm2: @f4(i32 inreg noundef %_1, i32 inreg noundef %_2, i32 noundef %_3) + // regparm3: @f4(i32 inreg noundef %_1, i32 inreg noundef %_2, i32 inreg noundef %_3) + #[no_mangle] + pub extern "cdecl" fn f4(_: i32, _: i32, _: i32) {} + + // regparm0: @f5(i32 noundef %_1, i32 noundef %_2, i32 noundef %_3) + // regparm1: @f5(i32 inreg noundef %_1, i32 noundef %_2, i32 noundef %_3) + // regparm2: @f5(i32 inreg noundef %_1, i32 inreg noundef %_2, i32 noundef %_3) + // regparm3: @f5(i32 inreg noundef %_1, i32 inreg noundef %_2, i32 inreg noundef %_3) + #[no_mangle] + pub extern "stdcall" fn f5(_: i32, _: i32, _: i32) {} + + // regparm doesn't work for thiscall + // CHECK: @f6(i32 noundef %_1, i32 noundef %_2, i32 noundef %_3) + #[no_mangle] + pub extern "thiscall" fn f6(_: i32, _: i32, _: i32) {} + + struct S1 { + x1: i32, + } + // regparm0: @f7(i32 noundef %_1, i32 noundef %_2, i32 noundef %_3, i32 noundef %_4) + // regparm1: @f7(i32 inreg noundef %_1, i32 noundef %_2, i32 noundef %_3, i32 noundef %_4) + // regparm2: @f7(i32 inreg noundef %_1, i32 inreg noundef %_2, i32 noundef %_3, i32 noundef %_4) + // regparm3: @f7(i32 inreg noundef %_1, i32 inreg noundef %_2, i32 inreg noundef %_3, + // regparm3-SAME: i32 noundef %_4) + #[no_mangle] + pub extern "C" fn f7(_: i32, _: i32, _: S1, _: i32) {} + + #[repr(C)] + struct S2 { + x1: i32, + x2: i32, + } + // regparm0: @f8(i32 noundef %_1, i32 noundef %_2, ptr {{.*}} %_3, i32 noundef %_4) + // regparm1: @f8(i32 inreg noundef %_1, i32 noundef %_2, ptr {{.*}} %_3, i32 noundef %_4) + // regparm2: @f8(i32 inreg noundef %_1, i32 inreg noundef %_2, ptr {{.*}} %_3, i32 noundef %_4) + // regparm3: @f8(i32 inreg noundef %_1, i32 inreg noundef %_2, ptr {{.*}} %_3, + // regparm3-SAME: i32 inreg noundef %_4) + #[no_mangle] + pub extern "C" fn f8(_: i32, _: i32, _: S2, _: i32) {} + + // regparm0: @f9(i1 noundef zeroext %_1, i16 noundef signext %_2, i64 noundef %_3, + // regparm0-SAME: i128 noundef %_4) + // regparm1: @f9(i1 inreg noundef zeroext %_1, i16 noundef signext %_2, i64 noundef %_3, + // regparm1-SAME: i128 noundef %_4) + // regparm2: @f9(i1 inreg noundef zeroext %_1, i16 inreg noundef signext %_2, i64 noundef %_3, + // regparm2-SAME: i128 noundef %_4) + // regparm3: @f9(i1 inreg noundef zeroext %_1, i16 inreg noundef signext %_2, i64 noundef %_3, + // regparm3-SAME: i128 noundef %_4) + #[no_mangle] + pub extern "C" fn f9(_: bool, _: i16, _: i64, _: u128) {} + + // regparm0: @f10(float noundef %_1, double noundef %_2, i1 noundef zeroext %_3, + // regparm0-SAME: i16 noundef signext %_4) + // regparm1: @f10(float noundef %_1, double noundef %_2, i1 inreg noundef zeroext %_3, + // regparm1-SAME: i16 noundef signext %_4) + // regparm2: @f10(float noundef %_1, double noundef %_2, i1 inreg noundef zeroext %_3, + // regparm2-SAME: i16 inreg noundef signext %_4) + // regparm3: @f10(float noundef %_1, double noundef %_2, i1 inreg noundef zeroext %_3, + // regparm3-SAME: i16 inreg noundef signext %_4) + #[no_mangle] + pub extern "C" fn f10(_: f32, _: f64, _: bool, _: i16) {} + + #[allow(non_camel_case_types)] + #[repr(simd)] + pub struct __m128([f32; 4]); + + // regparm0: @f11(i32 noundef %_1, <4 x float> %_2, i32 noundef %_3, i32 noundef %_4) + // regparm1: @f11(i32 inreg noundef %_1, <4 x float> %_2, i32 noundef %_3, i32 noundef %_4) + // regparm2: @f11(i32 inreg noundef %_1, <4 x float> %_2, i32 inreg noundef %_3, + // regparm2-SAME: i32 noundef %_4) + // regparm3: @f11(i32 inreg noundef %_1, <4 x float> %_2, i32 inreg noundef %_3, + // regparm3-SAME: i32 inreg noundef %_4) + #[no_mangle] + pub extern "C" fn f11(_: i32, _: __m128, _: i32, _: i32) {} + + #[allow(non_camel_case_types)] + #[repr(simd)] + pub struct __m256([f32; 8]); + + // regparm0: @f12(i32 noundef %_1, <8 x float> %_2, i32 noundef %_3, i32 noundef %_4) + // regparm1: @f12(i32 inreg noundef %_1, <8 x float> %_2, i32 noundef %_3, i32 noundef %_4) + // regparm2: @f12(i32 inreg noundef %_1, <8 x float> %_2, i32 inreg noundef %_3, + // regparm2-SAME: i32 noundef %_4) + // regparm3: @f12(i32 inreg noundef %_1, <8 x float> %_2, i32 inreg noundef %_3, + // regparm3-SAME: i32 inreg noundef %_4) + #[no_mangle] + pub extern "C" fn f12(_: i32, _: __m256, _: i32, _: i32) {} +} 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"] |
