| 1 |
// RUN: %clang_cc1 %s -cl-std=CL1.2 -emit-llvm -triple x86_64-unknown-unknown -o - | FileCheck %s |
| 2 |
// RUN: %clang_cc1 %s -cl-std=CL1.2 -emit-llvm -triple amdgcn-unknown-unknown -o - | FileCheck -check-prefixes=AMDGCN %s |
| 3 |
// Test that the kernels always use the SPIR calling convention |
| 4 |
// to have unambiguous mapping of arguments to feasibly implement |
| 5 |
// clSetKernelArg(). |
| 6 |
|
| 7 |
typedef struct int_single { |
| 8 |
int a; |
| 9 |
} int_single; |
| 10 |
|
| 11 |
typedef struct int_pair { |
| 12 |
long a; |
| 13 |
long b; |
| 14 |
} int_pair; |
| 15 |
|
| 16 |
typedef struct test_struct { |
| 17 |
int elementA; |
| 18 |
int elementB; |
| 19 |
long elementC; |
| 20 |
char elementD; |
| 21 |
long elementE; |
| 22 |
float elementF; |
| 23 |
short elementG; |
| 24 |
double elementH; |
| 25 |
} test_struct; |
| 26 |
|
| 27 |
kernel void test_single(int_single input, global int* output) { |
| 28 |
// CHECK: spir_kernel |
| 29 |
// AMDGCN: define{{.*}} amdgpu_kernel void @test_single |
| 30 |
// CHECK: ptr {{.*}} byval(%struct.int_single) align 4 captures(none) |
| 31 |
// CHECK: ptr noundef writeonly align 4 captures(none) initializes((0, 4)) %output |
| 32 |
output[0] = input.a; |
| 33 |
} |
| 34 |
|
| 35 |
kernel void test_pair(int_pair input, global int* output) { |
| 36 |
// CHECK: spir_kernel |
| 37 |
// AMDGCN: define{{.*}} amdgpu_kernel void @test_pair |
| 38 |
// CHECK: ptr {{.*}} byval(%struct.int_pair) align 8 captures(none) |
| 39 |
// CHECK: ptr noundef writeonly align 4 captures(none) initializes((0, 8)) %output |
| 40 |
output[0] = (int)input.a; |
| 41 |
output[1] = (int)input.b; |
| 42 |
} |
| 43 |
|
| 44 |
kernel void test_kernel(test_struct input, global int* output) { |
| 45 |
// CHECK: spir_kernel |
| 46 |
// AMDGCN: define{{.*}} amdgpu_kernel void @test_kernel |
| 47 |
// CHECK: ptr {{.*}} byval(%struct.test_struct) align 8 captures(none) |
| 48 |
// CHECK: ptr noundef writeonly align 4 captures(none) initializes((0, 32)) %output |
| 49 |
output[0] = input.elementA; |
| 50 |
output[1] = input.elementB; |
| 51 |
output[2] = (int)input.elementC; |
| 52 |
output[3] = (int)input.elementD; |
| 53 |
output[4] = (int)input.elementE; |
| 54 |
output[5] = (int)input.elementF; |
| 55 |
output[6] = (int)input.elementG; |
| 56 |
output[7] = (int)input.elementH; |
| 57 |
}; |
| 58 |
|
| 59 |
void test_function(int_pair input, global int* output) { |
| 60 |
// CHECK-NOT: spir_kernel |
| 61 |
// AMDGCN-NOT: define{{.*}} amdgpu_kernel void @test_function |
| 62 |
// CHECK: i64 %input.coerce0, i64 %input.coerce1, ptr noundef writeonly captures(none) initializes((0, 8)) %output |
| 63 |
output[0] = (int)input.a; |
| 64 |
output[1] = (int)input.b; |
| 65 |
} |