Skip to content

Commit b8c747f

Browse files
committed
Pre-commit amdgpu gpu-kernel ABI test
1 parent 039b8bc commit b8c747f

1 file changed

Lines changed: 133 additions & 0 deletions

File tree

Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
//@ add-minicore
2+
//@ compile-flags: --crate-type=rlib --target=amdgcn-amd-amdhsa -Ctarget-cpu=gfx900 -Copt-level=3
3+
//@ needs-llvm-components: amdgpu
4+
#![feature(no_core, abi_gpu_kernel)]
5+
#![no_core]
6+
#![allow(improper_gpu_kernel_arg)]
7+
8+
extern crate minicore;
9+
use minicore::num::Complex;
10+
11+
// Tests from llvm-project/clang/test/CodeGenOpenCL/amdgpu-abi-struct-coerce.cl
12+
13+
#[repr(C)]
14+
pub struct SingleElementStructArg {
15+
i: i32,
16+
}
17+
18+
#[repr(C)]
19+
pub struct NestedSingleElementStructArg {
20+
i: SingleElementStructArg,
21+
}
22+
23+
#[repr(C)]
24+
pub struct StructArg {
25+
i1: i32,
26+
f: f32,
27+
i2: i32,
28+
}
29+
30+
#[repr(C)]
31+
pub struct StructPaddingArg {
32+
i1: i8,
33+
f: i64,
34+
}
35+
36+
#[repr(C)]
37+
pub struct StructOfArraysArg {
38+
i1: [i32; 2],
39+
f1: f32,
40+
i2: [i32; 4],
41+
f2: [f32; 3],
42+
i3: i32,
43+
}
44+
45+
#[repr(C)]
46+
pub struct StructOfStructsArg {
47+
i1: i32,
48+
f1: f32,
49+
s1: StructArg,
50+
i2: i32,
51+
}
52+
53+
#[repr(C)]
54+
pub union U {
55+
b1: i32,
56+
b2: f32,
57+
}
58+
59+
#[repr(C)]
60+
pub struct SingleArrayElementStructArg {
61+
i: [i32; 4],
62+
}
63+
64+
#[repr(C)]
65+
pub struct SingleStructElementStructArgInner {
66+
i: i32,
67+
b: i64,
68+
}
69+
70+
#[repr(C)]
71+
pub struct SingleStructElementStructArg {
72+
s: SingleStructElementStructArgInner,
73+
}
74+
75+
#[repr(C)]
76+
pub struct DifferentSizeTypePair {
77+
l: i64,
78+
i: i32,
79+
}
80+
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) {{%.+}})
82+
#[no_mangle]
83+
pub extern "gpu-kernel" fn kernel_single_element_struct_arg(_: SingleElementStructArg) {}
84+
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) {{%.+}})
86+
#[no_mangle]
87+
pub extern "gpu-kernel" fn kernel_nested_single_element_struct_arg(
88+
_: NestedSingleElementStructArg,
89+
) {
90+
}
91+
92+
// CHECK: define amdgpu_kernel void @kernel_struct_arg(ptr noalias nofree noundef readnone align 4 captures(none) dead_on_return dereferenceable(12) {{%.+}})
93+
#[no_mangle]
94+
pub extern "gpu-kernel" fn kernel_struct_arg(_: StructArg) {}
95+
96+
// CHECK: define amdgpu_kernel void @kernel_struct_padding_arg(i8 noundef {{%.+}}, i64 noundef {{%.+}})
97+
#[no_mangle]
98+
pub extern "gpu-kernel" fn kernel_struct_padding_arg(_: StructPaddingArg) {}
99+
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) {{%.+}})
101+
#[no_mangle]
102+
pub extern "gpu-kernel" fn kernel_struct_of_arrays_arg(_: StructOfArraysArg) {}
103+
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) {{%.+}})
105+
#[no_mangle]
106+
pub extern "gpu-kernel" fn kernel_struct_of_structs_arg(_: StructOfStructsArg) {}
107+
108+
// CHECK: define amdgpu_kernel void @test_kernel_union_arg(ptr noalias nofree noundef readnone align 4 captures(none) dead_on_return dereferenceable(4) {{%.+}})
109+
#[no_mangle]
110+
pub extern "gpu-kernel" fn test_kernel_union_arg(_: U) {}
111+
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) {{%.+}})
113+
#[no_mangle]
114+
pub extern "gpu-kernel" fn kernel_single_array_element_struct_arg(_: SingleArrayElementStructArg) {}
115+
116+
// CHECK: define amdgpu_kernel void @kernel_single_struct_element_struct_arg(i32 noundef {{%.+}}, i64 noundef {{%.+}})
117+
#[no_mangle]
118+
pub extern "gpu-kernel" fn kernel_single_struct_element_struct_arg(
119+
_: SingleStructElementStructArg,
120+
) {
121+
}
122+
123+
// CHECK: define amdgpu_kernel void @kernel_different_size_type_pair_arg(i64 noundef {{%.+}}, i32 noundef {{%.+}})
124+
#[no_mangle]
125+
pub extern "gpu-kernel" fn kernel_different_size_type_pair_arg(_: DifferentSizeTypePair) {}
126+
127+
// CHECK: define amdgpu_kernel void @kernel_complex(float noundef {{%.+}}, float noundef {{%.+}})
128+
#[no_mangle]
129+
pub extern "gpu-kernel" fn kernel_complex(_: Complex<f32>) {}
130+
131+
// CHECK: define amdgpu_kernel void @kernel_slice(ptr noalias nofree noundef nonnull readonly align 4 captures(none) {{%.+}}, i64 noundef range(i64 0, 2305843009213693952) {{%.+}})
132+
#[no_mangle]
133+
pub extern "gpu-kernel" fn kernel_slice(_: &[u32]) {}

0 commit comments

Comments
 (0)