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