11//@ add-minicore
22//@ compile-flags: --crate-type=rlib --target=amdgcn-amd-amdhsa -Ctarget-cpu=gfx900 -Copt-level=3
33//@ needs-llvm-components: amdgpu
4- #![ feature( no_core, abi_gpu_kernel) ]
4+ #![ feature( no_core, abi_gpu_kernel, repr_simd ) ]
55#![ no_core]
66#![ allow( improper_gpu_kernel_arg) ]
77
@@ -10,14 +10,32 @@ use minicore::num::Complex;
1010
1111// Tests from llvm-project/clang/test/CodeGenOpenCL/amdgpu-abi-struct-coerce.cl
1212
13+ #[ repr( simd) ]
14+ pub struct I8X2 ( [ i8 ; 2 ] ) ;
15+
16+ #[ repr( simd) ]
17+ pub struct I16X2 ( [ i16 ; 2 ] ) ;
18+
19+ #[ repr( simd) ]
20+ pub struct I16X3 ( [ i16 ; 3 ] ) ;
21+
22+ #[ repr( simd) ]
23+ pub struct I16X4 ( [ i16 ; 4 ] ) ;
24+
25+ #[ repr( simd) ]
26+ pub struct I32X3 ( [ i32 ; 3 ] ) ;
27+
28+ #[ repr( simd) ]
29+ pub struct I32X4 ( [ i32 ; 4 ] ) ;
30+
1331#[ repr( C ) ]
14- pub struct SingleElementStructArg {
15- i : i32 ,
32+ pub struct SingleElementStructArg < T > {
33+ i : T ,
1634}
1735
1836#[ repr( C ) ]
1937pub struct NestedSingleElementStructArg {
20- i : SingleElementStructArg ,
38+ i : SingleElementStructArg < i32 > ,
2139}
2240
2341#[ repr( C ) ]
@@ -78,56 +96,92 @@ pub struct DifferentSizeTypePair {
7896 i : i32 ,
7997}
8098
81- // CHECK: define amdgpu_kernel void @kernel_single_element_struct_arg(ptr noalias nofree noundef readnone align 4 captures(none) dead_on_return dereferenceable(4) {{%.+}} )
99+ // CHECK: define amdgpu_kernel void @kernel_single_element_struct_arg(i32 %0 )
82100#[ no_mangle]
83- pub extern "gpu-kernel" fn kernel_single_element_struct_arg ( _: SingleElementStructArg ) { }
101+ pub extern "gpu-kernel" fn kernel_single_element_struct_arg ( _: SingleElementStructArg < i32 > ) { }
84102
85- // CHECK: define amdgpu_kernel void @kernel_nested_single_element_struct_arg(ptr noalias nofree noundef readnone align 4 captures(none) dead_on_return dereferenceable(4) {{%.+}} )
103+ // CHECK: define amdgpu_kernel void @kernel_nested_single_element_struct_arg(i32 %0 )
86104#[ no_mangle]
87105pub extern "gpu-kernel" fn kernel_nested_single_element_struct_arg (
88106 _: NestedSingleElementStructArg ,
89107) {
90108}
91109
92- // CHECK: define amdgpu_kernel void @kernel_struct_arg(ptr noalias nofree noundef readnone align 4 captures(none) dead_on_return dereferenceable(12) {{%.+}})
110+ // CHECK: define amdgpu_kernel void @kernel_struct_arg(ptr addrspace(4) noalias nofree noundef readnone byref([12 x i8]) align 4 captures(none) dereferenceable(12) {{%.+}})
93111#[ no_mangle]
94112pub extern "gpu-kernel" fn kernel_struct_arg ( _: StructArg ) { }
95113
96- // CHECK: define amdgpu_kernel void @kernel_struct_padding_arg(i8 noundef {{%.+}}, i64 noundef {{%.+}})
114+ // CHECK: define amdgpu_kernel void @kernel_struct_padding_arg(ptr addrspace(4) noalias nofree noundef readnone byref([16 x i8]) align 8 captures(none) dereferenceable(16) {{%.+}})
97115#[ no_mangle]
98116pub extern "gpu-kernel" fn kernel_struct_padding_arg ( _: StructPaddingArg ) { }
99117
100- // CHECK: define amdgpu_kernel void @kernel_struct_of_arrays_arg(ptr noalias nofree noundef readnone align 4 captures(none) dead_on_return dereferenceable(44) {{%.+}})
118+ // CHECK: define amdgpu_kernel void @kernel_struct_of_arrays_arg(ptr addrspace(4) noalias nofree noundef readnone byref([44 x i8]) align 4 captures(none) dereferenceable(44) {{%.+}})
101119#[ no_mangle]
102120pub extern "gpu-kernel" fn kernel_struct_of_arrays_arg ( _: StructOfArraysArg ) { }
103121
104- // CHECK: define amdgpu_kernel void @kernel_struct_of_structs_arg(ptr noalias nofree noundef readnone align 4 captures(none) dead_on_return dereferenceable(24) {{%.+}})
122+ // CHECK: define amdgpu_kernel void @kernel_struct_of_structs_arg(ptr addrspace(4) noalias nofree noundef readnone byref([24 x i8]) align 4 captures(none) dereferenceable(24) {{%.+}})
105123#[ no_mangle]
106124pub extern "gpu-kernel" fn kernel_struct_of_structs_arg ( _: StructOfStructsArg ) { }
107125
108- // CHECK: define amdgpu_kernel void @test_kernel_union_arg(ptr noalias nofree noundef readnone align 4 captures(none) dead_on_return dereferenceable(4) {{%.+}})
126+ // CHECK: define amdgpu_kernel void @test_kernel_union_arg(ptr addrspace(4) noalias nofree noundef readnone byref([4 x i8]) align 4 captures(none) dereferenceable(4) {{%.+}})
109127#[ no_mangle]
110128pub extern "gpu-kernel" fn test_kernel_union_arg ( _: U ) { }
111129
112- // CHECK: define amdgpu_kernel void @kernel_single_array_element_struct_arg(ptr noalias nofree noundef readnone align 4 captures(none) dead_on_return dereferenceable(16) {{%.+}})
130+ // CHECK: define amdgpu_kernel void @kernel_single_array_element_struct_arg(ptr addrspace(4) noalias nofree noundef readnone byref([16 x i8]) align 4 captures(none) dereferenceable(16) {{%.+}})
113131#[ no_mangle]
114132pub extern "gpu-kernel" fn kernel_single_array_element_struct_arg ( _: SingleArrayElementStructArg ) { }
115133
116- // CHECK: define amdgpu_kernel void @kernel_single_struct_element_struct_arg(i32 noundef {{%.+}}, i64 noundef {{%.+}})
134+ // CHECK: define amdgpu_kernel void @kernel_single_struct_element_struct_arg(ptr addrspace(4) noalias nofree noundef readnone byref([16 x i8]) align 8 captures(none) dereferenceable(16) {{%.+}})
117135#[ no_mangle]
118136pub extern "gpu-kernel" fn kernel_single_struct_element_struct_arg (
119137 _: SingleStructElementStructArg ,
120138) {
121139}
122140
123- // CHECK: define amdgpu_kernel void @kernel_different_size_type_pair_arg(i64 noundef {{%.+}}, i32 noundef {{%.+}})
141+ // CHECK: define amdgpu_kernel void @kernel_different_size_type_pair_arg(ptr addrspace(4) noalias nofree noundef readnone byref([16 x i8]) align 8 captures(none) dereferenceable(16) {{%.+}})
124142#[ no_mangle]
125143pub extern "gpu-kernel" fn kernel_different_size_type_pair_arg ( _: DifferentSizeTypePair ) { }
126144
127- // CHECK: define amdgpu_kernel void @kernel_complex(float noundef {{%.+}}, float noundef {{%.+}})
145+ // CHECK: define amdgpu_kernel void @kernel_complex(ptr addrspace(4) noalias nofree noundef readnone byref([8 x i8]) align 4 captures(none) dereferenceable(8) {{%.+}})
128146#[ no_mangle]
129147pub extern "gpu-kernel" fn kernel_complex ( _: Complex < f32 > ) { }
130148
131- // CHECK: define amdgpu_kernel void @kernel_slice(ptr noalias nofree noundef nonnull readonly align 4 captures(none) {{%.+}}, i64 noundef range(i64 0, 2305843009213693952 ) {{%.+}})
149+ // CHECK: define amdgpu_kernel void @kernel_slice(ptr addrspace(4) noalias nofree noundef readnone byref([16 x i8]) align 8 captures(none) dereferenceable(16 ) {{%.+}})
132150#[ no_mangle]
133151pub extern "gpu-kernel" fn kernel_slice ( _: & [ u32 ] ) { }
152+
153+ // CHECK: define amdgpu_kernel void @kernel_i64(i64 noundef {{%.+}})
154+ #[ no_mangle]
155+ pub extern "gpu-kernel" fn kernel_i64 ( _: i64 ) { }
156+
157+ // CHECK: define amdgpu_kernel void @kernel_i64_struct(i64 {{%.+}})
158+ #[ no_mangle]
159+ pub extern "gpu-kernel" fn kernel_i64_struct ( _: SingleElementStructArg < i64 > ) { }
160+
161+ // CHECK: define amdgpu_kernel void @kernel_i128_struct(i128 {{%.+}})
162+ #[ no_mangle]
163+ pub extern "gpu-kernel" fn kernel_i128_struct ( _: SingleElementStructArg < i128 > ) { }
164+
165+ // CHECK: define amdgpu_kernel void @kernel_i8x2_struct(<2 x i8> {{%.+}})
166+ #[ no_mangle]
167+ pub extern "gpu-kernel" fn kernel_i8x2_struct ( _: SingleElementStructArg < I8X2 > ) { }
168+
169+ // CHECK: define amdgpu_kernel void @kernel_i16x2_struct(<2 x i16> {{%.+}})
170+ #[ no_mangle]
171+ pub extern "gpu-kernel" fn kernel_i16x2_struct ( _: SingleElementStructArg < I16X2 > ) { }
172+
173+ // CHECK: define amdgpu_kernel void @kernel_i16x3_struct(<4 x i16> {{%.+}})
174+ #[ no_mangle]
175+ pub extern "gpu-kernel" fn kernel_i16x3_struct ( _: SingleElementStructArg < I16X3 > ) { }
176+
177+ // CHECK: define amdgpu_kernel void @kernel_i16x4_struct(<4 x i16> {{%.+}})
178+ #[ no_mangle]
179+ pub extern "gpu-kernel" fn kernel_i16x4_struct ( _: SingleElementStructArg < I16X4 > ) { }
180+
181+ // CHECK: define amdgpu_kernel void @kernel_i32x3_struct(<4 x i32> {{%.+}})
182+ #[ no_mangle]
183+ pub extern "gpu-kernel" fn kernel_i32x3_struct ( _: SingleElementStructArg < I32X3 > ) { }
184+
185+ // CHECK: define amdgpu_kernel void @kernel_i32x4_struct(<4 x i32> {{%.+}})
186+ #[ no_mangle]
187+ pub extern "gpu-kernel" fn kernel_i32x4_struct ( _: SingleElementStructArg < I32X4 > ) { }
0 commit comments