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
7typedef struct int_single {
8    int a;
9} int_single;
10
11typedef struct int_pair {
12    long a;
13    long b;
14} int_pair;
15
16typedef 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
27kernel void test_single(int_single input, global int* output) {
28// CHECK: spir_kernel
29// AMDGCN: define amdgpu_kernel void @test_single
30// CHECK: struct.int_single* nocapture {{.*}} byval(%struct.int_single)
31// CHECK: i32* nocapture %output
32 output[0] = input.a;
33}
34
35kernel void test_pair(int_pair input, global int* output) {
36// CHECK: spir_kernel
37// AMDGCN: define amdgpu_kernel void @test_pair
38// CHECK: struct.int_pair* nocapture {{.*}} byval(%struct.int_pair)
39// CHECK: i32* nocapture %output
40 output[0] = (int)input.a;
41 output[1] = (int)input.b;
42}
43
44kernel void test_kernel(test_struct input, global int* output) {
45// CHECK: spir_kernel
46// AMDGCN: define amdgpu_kernel void @test_kernel
47// CHECK: struct.test_struct* nocapture {{.*}} byval(%struct.test_struct)
48// CHECK: i32* nocapture %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
59void 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, i32* nocapture %output
63 output[0] = (int)input.a;
64 output[1] = (int)input.b;
65}
66