1// RUN: %clang_cc1 -triple r600 -cl-std=CL1.2 %s -emit-llvm -o - | FileCheck %s
2// RUN: %clang_cc1 -triple amdgcn-mesa-mesa3d -cl-std=CL1.2 %s -emit-llvm -o - | FileCheck %s
3// RUN: %clang_cc1 -triple amdgcn---opencl -cl-std=CL1.2 %s -emit-llvm -o - | FileCheck %s
4// RUN: %clang_cc1 -triple amdgcn---opencl -cl-std=CL2.0 %s -emit-llvm -o - | FileCheck %s
5// RUN: %clang_cc1 -triple amdgcn---amdgizcl -cl-std=CL1.2 %s -emit-llvm -o - | FileCheck %s
6// RUN: %clang_cc1 -triple amdgcn---amdgizcl -cl-std=CL2.0 %s -emit-llvm -o - | FileCheck %s
7
8#ifdef __AMDGCN__
9#define PTSIZE 8
10#else
11#define PTSIZE 4
12#endif
13
14#ifdef cl_khr_fp64
15#pragma OPENCL EXTENSION cl_khr_fp64 : enable
16#endif
17#ifdef cl_khr_fp16
18#pragma OPENCL EXTENSION cl_khr_fp16 : enable
19#endif
20
21typedef __SIZE_TYPE__ size_t;
22typedef __PTRDIFF_TYPE__ ptrdiff_t;
23typedef __INTPTR_TYPE__ intptr_t;
24typedef __UINTPTR_TYPE__ uintptr_t;
25typedef global void *global_ptr_t;
26typedef constant void *constant_ptr_t;
27typedef local void *local_ptr_t;
28typedef private void *private_ptr_t;
29
30void check(bool);
31
32void test() {
33  // CHECK-NOT: call void @check(i1 zeroext false)
34  check(sizeof(size_t) == PTSIZE);
35  check(__alignof__(size_t) == PTSIZE);
36  check(sizeof(intptr_t) == PTSIZE);
37  check(__alignof__(intptr_t) == PTSIZE);
38  check(sizeof(uintptr_t) == PTSIZE);
39  check(__alignof__(uintptr_t) == PTSIZE);
40  check(sizeof(ptrdiff_t) == PTSIZE);
41  check(__alignof__(ptrdiff_t) == PTSIZE);
42
43  check(sizeof(char) == 1);
44  check(__alignof__(char) == 1);
45  check(sizeof(short) == 2);
46  check(__alignof__(short) == 2);
47  check(sizeof(int) == 4);
48  check(__alignof__(int) == 4);
49  check(sizeof(long) == 8);
50  check(__alignof__(long) == 8);
51#ifdef cl_khr_fp16
52  check(sizeof(half) == 2);
53  check(__alignof__(half) == 2);
54#endif
55  check(sizeof(float) == 4);
56  check(__alignof__(float) == 4);
57#ifdef cl_khr_fp64
58  check(sizeof(double) == 8);
59  check(__alignof__(double) == 8);
60#endif
61
62  check(sizeof(void*) == (__OPENCL_C_VERSION__ >= 200 ? 8 : 4));
63  check(__alignof__(void*) == (__OPENCL_C_VERSION__ >= 200 ? 8 : 4));
64  check(sizeof(global_ptr_t) == PTSIZE);
65  check(__alignof__(global_ptr_t) == PTSIZE);
66  check(sizeof(constant_ptr_t) == PTSIZE);
67  check(__alignof__(constant_ptr_t) == PTSIZE);
68  check(sizeof(local_ptr_t) == 4);
69  check(__alignof__(private_ptr_t) == 4);
70}
71