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