Skip to content

Commit 4375d3b

Browse files
committed
tests: Add tests for LoongArch64
1 parent f229949 commit 4375d3b

18 files changed

+364
-23
lines changed

tests/codegen/abi-main-signature-16bit-c-int.rs

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
// ignore-wasm32
1818
// ignore-x86
1919
// ignore-x86_64
20+
// ignore-loongarch64
2021

2122
fn main() {
2223
}

tests/codegen/call-llvm-intrinsics.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// compile-flags: -C no-prepopulate-passes -Copt-level=0
22

33
// ignore-riscv64
4+
// ignore-loongarch64
45

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

tests/codegen/catch-unwind.rs

+2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
// ignore-riscv64 FIXME
1111
// On s390x the closure is also in another function
1212
// ignore-s390x FIXME
13+
// On loongarch64 the closure is also in another function
14+
// ignore-loongarch64 FIXME
1315

1416
#![crate_type = "lib"]
1517
#![feature(c_unwind)]

tests/codegen/global_asm.rs

+1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
// ignore-wasm32
1919
// ignore-wasm64
2020
// ignore-emscripten
21+
// ignore-loongarch64
2122
// compile-flags: -C no-prepopulate-passes
2223

2324
#![crate_type = "lib"]

tests/codegen/global_asm_include.rs

+1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
// ignore-wasm32
1919
// ignore-wasm64
2020
// ignore-emscripten
21+
// ignore-loongarch64
2122
// compile-flags: -C no-prepopulate-passes
2223

2324
#![crate_type = "lib"]

tests/codegen/global_asm_x2.rs

+1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
// ignore-wasm32
1919
// ignore-wasm64
2020
// ignore-emscripten
21+
// ignore-loongarch64
2122
// compile-flags: -C no-prepopulate-passes
2223

2324
#![crate_type = "lib"]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// compile-flags: -C no-prepopulate-passes
2+
3+
// only-loongarch64
4+
5+
#![feature(link_llvm_intrinsics)]
6+
#![crate_type = "lib"]
7+
8+
struct A;
9+
10+
impl Drop for A {
11+
fn drop(&mut self) {
12+
println!("A");
13+
}
14+
}
15+
16+
extern "C" {
17+
#[link_name = "llvm.sqrt.f32"]
18+
fn sqrt(x: f32) -> f32;
19+
}
20+
21+
pub fn do_call() {
22+
let _a = A;
23+
24+
unsafe {
25+
// Ensure that we `call` LLVM intrinsics instead of trying to `invoke` them
26+
// CHECK: store float 4.000000e+00, ptr %{{.}}, align 4
27+
// CHECK: load float, ptr %{{.}}, align 4
28+
// CHECK: call float @llvm.sqrt.f32(float %{{.}}
29+
sqrt(4.0);
30+
}
31+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,293 @@
1+
// compile-flags: -C no-prepopulate-passes
2+
// only-loongarch64
3+
// only-linux
4+
5+
#![crate_type = "lib"]
6+
7+
// CHECK: define void @f_fpr_tracking(double %0, double %1, double %2, double %3, double %4, double %5, double %6, double %7, i8 noundef zeroext %i)
8+
#[no_mangle]
9+
pub extern "C" fn f_fpr_tracking(
10+
a: f64,
11+
b: f64,
12+
c: f64,
13+
d: f64,
14+
e: f64,
15+
f: f64,
16+
g: f64,
17+
h: f64,
18+
i: u8,
19+
) {
20+
}
21+
22+
#[repr(C)]
23+
pub struct Double {
24+
f: f64,
25+
}
26+
27+
#[repr(C)]
28+
pub struct DoubleDouble {
29+
f: f64,
30+
g: f64,
31+
}
32+
33+
#[repr(C)]
34+
pub struct DoubleFloat {
35+
f: f64,
36+
g: f32,
37+
}
38+
39+
// CHECK: define void @f_double_s_arg(double %0)
40+
#[no_mangle]
41+
pub extern "C" fn f_double_s_arg(a: Double) {}
42+
43+
// CHECK: define double @f_ret_double_s()
44+
#[no_mangle]
45+
pub extern "C" fn f_ret_double_s() -> Double {
46+
Double { f: 1. }
47+
}
48+
49+
// CHECK: define void @f_double_double_s_arg({ double, double } %0)
50+
#[no_mangle]
51+
pub extern "C" fn f_double_double_s_arg(a: DoubleDouble) {}
52+
53+
// CHECK: define { double, double } @f_ret_double_double_s()
54+
#[no_mangle]
55+
pub extern "C" fn f_ret_double_double_s() -> DoubleDouble {
56+
DoubleDouble { f: 1., g: 2. }
57+
}
58+
59+
// CHECK: define void @f_double_float_s_arg({ double, float } %0)
60+
#[no_mangle]
61+
pub extern "C" fn f_double_float_s_arg(a: DoubleFloat) {}
62+
63+
// CHECK: define { double, float } @f_ret_double_float_s()
64+
#[no_mangle]
65+
pub extern "C" fn f_ret_double_float_s() -> DoubleFloat {
66+
DoubleFloat { f: 1., g: 2. }
67+
}
68+
69+
// CHECK: define void @f_double_double_s_arg_insufficient_fprs(double %0, double %1, double %2, double %3, double %4, double %5, double %6, [2 x i64] %7)
70+
#[no_mangle]
71+
pub extern "C" fn f_double_double_s_arg_insufficient_fprs(
72+
a: f64,
73+
b: f64,
74+
c: f64,
75+
d: f64,
76+
e: f64,
77+
f: f64,
78+
g: f64,
79+
h: DoubleDouble,
80+
) {
81+
}
82+
83+
#[repr(C)]
84+
pub struct DoubleInt8 {
85+
f: f64,
86+
i: i8,
87+
}
88+
89+
#[repr(C)]
90+
pub struct DoubleUInt8 {
91+
f: f64,
92+
i: u8,
93+
}
94+
95+
#[repr(C)]
96+
pub struct DoubleInt32 {
97+
f: f64,
98+
i: i32,
99+
}
100+
101+
#[repr(C)]
102+
pub struct DoubleInt64 {
103+
f: f64,
104+
i: i64,
105+
}
106+
107+
// CHECK: define void @f_double_int8_s_arg({ double, i8 } %0)
108+
#[no_mangle]
109+
pub extern "C" fn f_double_int8_s_arg(a: DoubleInt8) {}
110+
111+
// CHECK: define { double, i8 } @f_ret_double_int8_s()
112+
#[no_mangle]
113+
pub extern "C" fn f_ret_double_int8_s() -> DoubleInt8 {
114+
DoubleInt8 { f: 1., i: 2 }
115+
}
116+
117+
// CHECK: define void @f_double_int32_s_arg({ double, i32 } %0)
118+
#[no_mangle]
119+
pub extern "C" fn f_double_int32_s_arg(a: DoubleInt32) {}
120+
121+
// CHECK: define { double, i32 } @f_ret_double_int32_s()
122+
#[no_mangle]
123+
pub extern "C" fn f_ret_double_int32_s() -> DoubleInt32 {
124+
DoubleInt32 { f: 1., i: 2 }
125+
}
126+
127+
// CHECK: define void @f_double_uint8_s_arg({ double, i8 } %0)
128+
#[no_mangle]
129+
pub extern "C" fn f_double_uint8_s_arg(a: DoubleUInt8) {}
130+
131+
// CHECK: define { double, i8 } @f_ret_double_uint8_s()
132+
#[no_mangle]
133+
pub extern "C" fn f_ret_double_uint8_s() -> DoubleUInt8 {
134+
DoubleUInt8 { f: 1., i: 2 }
135+
}
136+
137+
// CHECK: define void @f_double_int64_s_arg({ double, i64 } %0)
138+
#[no_mangle]
139+
pub extern "C" fn f_double_int64_s_arg(a: DoubleInt64) {}
140+
141+
// CHECK: define { double, i64 } @f_ret_double_int64_s()
142+
#[no_mangle]
143+
pub extern "C" fn f_ret_double_int64_s() -> DoubleInt64 {
144+
DoubleInt64 { f: 1., i: 2 }
145+
}
146+
147+
// CHECK: define void @f_double_int8_s_arg_insufficient_gprs(i32 noundef signext %a, i32 noundef signext %b, i32 noundef signext %c, i32 noundef signext %d, i32 noundef signext %e, i32 noundef signext %f, i32 noundef signext %g, i32 noundef signext %h, [2 x i64] %0)
148+
#[no_mangle]
149+
pub extern "C" fn f_double_int8_s_arg_insufficient_gprs(
150+
a: i32,
151+
b: i32,
152+
c: i32,
153+
d: i32,
154+
e: i32,
155+
f: i32,
156+
g: i32,
157+
h: i32,
158+
i: DoubleInt8,
159+
) {
160+
}
161+
162+
// CHECK: define void @f_struct_double_int8_insufficient_fprs(float %0, double %1, double %2, double %3, double %4, double %5, double %6, double %7, [2 x i64] %8)
163+
#[no_mangle]
164+
pub extern "C" fn f_struct_double_int8_insufficient_fprs(
165+
a: f32,
166+
b: f64,
167+
c: f64,
168+
d: f64,
169+
e: f64,
170+
f: f64,
171+
g: f64,
172+
h: f64,
173+
i: DoubleInt8,
174+
) {
175+
}
176+
177+
#[repr(C)]
178+
pub struct DoubleArr1 {
179+
a: [f64; 1],
180+
}
181+
182+
// CHECK: define void @f_doublearr1_s_arg(double %0)
183+
#[no_mangle]
184+
pub extern "C" fn f_doublearr1_s_arg(a: DoubleArr1) {}
185+
186+
// CHECK: define double @f_ret_doublearr1_s()
187+
#[no_mangle]
188+
pub extern "C" fn f_ret_doublearr1_s() -> DoubleArr1 {
189+
DoubleArr1 { a: [1.] }
190+
}
191+
192+
#[repr(C)]
193+
pub struct DoubleArr2 {
194+
a: [f64; 2],
195+
}
196+
197+
// CHECK: define void @f_doublearr2_s_arg({ double, double } %0)
198+
#[no_mangle]
199+
pub extern "C" fn f_doublearr2_s_arg(a: DoubleArr2) {}
200+
201+
// CHECK: define { double, double } @f_ret_doublearr2_s()
202+
#[no_mangle]
203+
pub extern "C" fn f_ret_doublearr2_s() -> DoubleArr2 {
204+
DoubleArr2 { a: [1., 2.] }
205+
}
206+
207+
#[repr(C)]
208+
pub struct Tricky1 {
209+
f: [f64; 1],
210+
}
211+
212+
#[repr(C)]
213+
pub struct DoubleArr2Tricky1 {
214+
g: [Tricky1; 2],
215+
}
216+
217+
// CHECK: define void @f_doublearr2_tricky1_s_arg({ double, double } %0)
218+
#[no_mangle]
219+
pub extern "C" fn f_doublearr2_tricky1_s_arg(a: DoubleArr2Tricky1) {}
220+
221+
// CHECK: define { double, double } @f_ret_doublearr2_tricky1_s()
222+
#[no_mangle]
223+
pub extern "C" fn f_ret_doublearr2_tricky1_s() -> DoubleArr2Tricky1 {
224+
DoubleArr2Tricky1 { g: [Tricky1 { f: [1.] }, Tricky1 { f: [2.] }] }
225+
}
226+
227+
#[repr(C)]
228+
pub struct EmptyStruct {}
229+
230+
#[repr(C)]
231+
pub struct DoubleArr2Tricky2 {
232+
s: EmptyStruct,
233+
g: [Tricky1; 2],
234+
}
235+
236+
// CHECK: define void @f_doublearr2_tricky2_s_arg({ double, double } %0)
237+
#[no_mangle]
238+
pub extern "C" fn f_doublearr2_tricky2_s_arg(a: DoubleArr2Tricky2) {}
239+
240+
// CHECK: define { double, double } @f_ret_doublearr2_tricky2_s()
241+
#[no_mangle]
242+
pub extern "C" fn f_ret_doublearr2_tricky2_s() -> DoubleArr2Tricky2 {
243+
DoubleArr2Tricky2 { s: EmptyStruct {}, g: [Tricky1 { f: [1.] }, Tricky1 { f: [2.] }] }
244+
}
245+
246+
#[repr(C)]
247+
pub struct IntDoubleInt {
248+
a: i32,
249+
b: f64,
250+
c: i32,
251+
}
252+
253+
// CHECK: define void @f_int_double_int_s_arg(ptr noalias nocapture noundef dereferenceable(24) %a)
254+
#[no_mangle]
255+
pub extern "C" fn f_int_double_int_s_arg(a: IntDoubleInt) {}
256+
257+
// CHECK: define void @f_ret_int_double_int_s(ptr noalias nocapture noundef sret(%IntDoubleInt) dereferenceable(24) %0)
258+
#[no_mangle]
259+
pub extern "C" fn f_ret_int_double_int_s() -> IntDoubleInt {
260+
IntDoubleInt { a: 1, b: 2., c: 3 }
261+
}
262+
263+
#[repr(C)]
264+
pub struct CharCharDouble {
265+
a: u8,
266+
b: u8,
267+
c: f64,
268+
}
269+
270+
// CHECK: define void @f_char_char_double_s_arg([2 x i64] %0)
271+
#[no_mangle]
272+
pub extern "C" fn f_char_char_double_s_arg(a: CharCharDouble) {}
273+
274+
// CHECK: define [2 x i64] @f_ret_char_char_double_s()
275+
#[no_mangle]
276+
pub extern "C" fn f_ret_char_char_double_s() -> CharCharDouble {
277+
CharCharDouble { a: 1, b: 2, c: 3. }
278+
}
279+
280+
#[repr(C)]
281+
pub union DoubleU {
282+
a: f64,
283+
}
284+
285+
// CHECK: define void @f_double_u_arg(i64 %0)
286+
#[no_mangle]
287+
pub extern "C" fn f_double_u_arg(a: DoubleU) {}
288+
289+
// CHECK: define i64 @f_ret_double_u()
290+
#[no_mangle]
291+
pub extern "C" fn f_ret_double_u() -> DoubleU {
292+
unsafe { DoubleU { a: 1. } }
293+
}

tests/codegen/repr-transparent-aggregates-1.rs

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
// ignore-riscv64 see codegen/riscv-abi
1111
// ignore-s390x
1212
// ignore-windows
13+
// ignore-loongarch64
1314
// See repr-transparent.rs
1415

1516
#![feature(transparent_unions)]

tests/codegen/repr-transparent-aggregates-2.rs

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
// ignore-sparc64
1313
// ignore-x86
1414
// ignore-x86_64
15+
// ignore-loongarch64
1516
// See repr-transparent.rs
1617

1718
#![feature(transparent_unions)]

tests/codegen/repr-transparent.rs

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
// ignore-riscv64 riscv64 has an i128 type used with test_Vector
44
// see codegen/riscv-abi for riscv functiona call tests
55
// ignore-s390x s390x with default march passes vector types per reference
6+
// ignore-loongarch64 see codegen/loongarch-abi for loongarch function call tests
67

78
#![crate_type="lib"]
89
#![feature(repr_simd, transparent_unions)]

0 commit comments

Comments
 (0)