]>
Commit | Line | Data |
---|---|---|
e74abb32 | 1 | // ignore-emscripten vectors passed directly |
a1dfa0c6 XL |
2 | // compile-flags: -C no-prepopulate-passes |
3 | ||
4 | // This test that using union forward the abi of the inner type, as | |
5 | // discussed in #54668 | |
6 | ||
7 | #![crate_type="lib"] | |
8 | #![feature(repr_simd)] | |
9 | ||
10 | #[derive(Copy, Clone)] | |
11 | pub enum Unhab {} | |
12 | ||
13 | #[repr(simd)] | |
14 | #[derive(Copy, Clone)] | |
15 | pub struct i64x4(i64, i64, i64, i64); | |
16 | ||
17 | #[derive(Copy, Clone)] | |
18 | pub union UnionI64x4{ a:(), b: i64x4 } | |
19 | ||
e1599b0c | 20 | // CHECK: define void @test_UnionI64x4(<4 x i64>* {{.*}} %_1) |
a1dfa0c6 XL |
21 | #[no_mangle] |
22 | pub fn test_UnionI64x4(_: UnionI64x4) { loop {} } | |
23 | ||
24 | pub union UnionI64x4_{ a: i64x4, b: (), c:i64x4, d: Unhab, e: ((),()), f: UnionI64x4 } | |
25 | ||
e1599b0c | 26 | // CHECK: define void @test_UnionI64x4_(<4 x i64>* {{.*}} %_1) |
a1dfa0c6 XL |
27 | #[no_mangle] |
28 | pub fn test_UnionI64x4_(_: UnionI64x4_) { loop {} } | |
29 | ||
30 | pub union UnionI64x4I64{ a: i64x4, b: i64 } | |
31 | ||
e1599b0c | 32 | // CHECK: define void @test_UnionI64x4I64(%UnionI64x4I64* {{.*}} %_1) |
a1dfa0c6 XL |
33 | #[no_mangle] |
34 | pub fn test_UnionI64x4I64(_: UnionI64x4I64) { loop {} } | |
35 | ||
36 | pub union UnionI64x4Tuple{ a: i64x4, b: (i64, i64, i64, i64) } | |
37 | ||
e1599b0c | 38 | // CHECK: define void @test_UnionI64x4Tuple(%UnionI64x4Tuple* {{.*}} %_1) |
a1dfa0c6 XL |
39 | #[no_mangle] |
40 | pub fn test_UnionI64x4Tuple(_: UnionI64x4Tuple) { loop {} } | |
41 | ||
42 | ||
43 | pub union UnionF32{a:f32} | |
44 | ||
e1599b0c | 45 | // CHECK: define float @test_UnionF32(float %_1) |
a1dfa0c6 XL |
46 | #[no_mangle] |
47 | pub fn test_UnionF32(_: UnionF32) -> UnionF32 { loop {} } | |
48 | ||
49 | pub union UnionF32F32{a:f32, b:f32} | |
50 | ||
e1599b0c | 51 | // CHECK: define float @test_UnionF32F32(float %_1) |
a1dfa0c6 XL |
52 | #[no_mangle] |
53 | pub fn test_UnionF32F32(_: UnionF32F32) -> UnionF32F32 { loop {} } | |
54 | ||
55 | pub union UnionF32U32{a:f32, b:u32} | |
56 | ||
57 | // CHECK: define i32 @test_UnionF32U32(i32) | |
58 | #[no_mangle] | |
59 | pub fn test_UnionF32U32(_: UnionF32U32) -> UnionF32U32 { loop {} } | |
60 | ||
61 | pub union UnionU128{a:u128} | |
e1599b0c | 62 | // CHECK: define i128 @test_UnionU128(i128 %_1) |
a1dfa0c6 XL |
63 | #[no_mangle] |
64 | pub fn test_UnionU128(_: UnionU128) -> UnionU128 { loop {} } | |
65 | ||
66 | #[repr(C)] | |
67 | pub union CUnionU128{a:u128} | |
e1599b0c | 68 | // CHECK: define void @test_CUnionU128(%CUnionU128* {{.*}} %_1) |
a1dfa0c6 XL |
69 | #[no_mangle] |
70 | pub fn test_CUnionU128(_: CUnionU128) { loop {} } | |
71 | ||
72 | pub union UnionBool { b:bool } | |
73 | // CHECK: define zeroext i1 @test_UnionBool(i8 %b) | |
74 | #[no_mangle] | |
75 | pub fn test_UnionBool(b: UnionBool) -> bool { unsafe { b.b } } | |
76 | // CHECK: %0 = trunc i8 %b to i1 |