1 // RUN: %clang_cc1 -triple x86_64-gnu-linux -O3 -disable-llvm-passes -emit-llvm -o - %s | FileCheck %s --check-prefixes=CHECK,CHECK64 2 // RUN: %clang_cc1 -triple x86_64-windows-pc -O3 -disable-llvm-passes -emit-llvm -o - %s | FileCheck %s --check-prefixes=CHECK,CHECK64 3 // RUN: %clang_cc1 -triple i386-gnu-linux -O3 -disable-llvm-passes -emit-llvm -o - %s | FileCheck %s --check-prefixes=CHECK,LIN32 4 // RUN: %clang_cc1 -triple i386-windows-pc -O3 -disable-llvm-passes -emit-llvm -o - %s | FileCheck %s --check-prefixes=CHECK,WIN32 5 6 void GenericTest(_BitInt(3) a, unsigned _BitInt(3) b, _BitInt(4) c) { 7 // CHECK: define {{.*}}void @GenericTest 8 int which = _Generic(a, _BitInt(3): 1, unsigned _BitInt(3) : 2, _BitInt(4) : 3); 9 // CHECK: store i32 1 10 int which2 = _Generic(b, _BitInt(3): 1, unsigned _BitInt(3) : 2, _BitInt(4) : 3); 11 // CHECK: store i32 2 12 int which3 = _Generic(c, _BitInt(3): 1, unsigned _BitInt(3) : 2, _BitInt(4) : 3); 13 // CHECK: store i32 3 14 } 15 16 void VLATest(_BitInt(3) A, _BitInt(99) B, _BitInt(123) C) { 17 // CHECK: define {{.*}}void @VLATest 18 int AR1[A]; 19 // CHECK: %[[A:.+]] = zext i3 %{{.+}} to i[[INDXSIZE:[0-9]+]] 20 // CHECK: %[[VLA1:.+]] = alloca i32, i[[INDXSIZE]] %[[A]] 21 int AR2[B]; 22 // CHECK: %[[B:.+]] = trunc i99 %{{.+}} to i[[INDXSIZE]] 23 // CHECK: %[[VLA2:.+]] = alloca i32, i[[INDXSIZE]] %[[B]] 24 int AR3[C]; 25 // CHECK: %[[C:.+]] = trunc i123 %{{.+}} to i[[INDXSIZE]] 26 // CHECK: %[[VLA3:.+]] = alloca i32, i[[INDXSIZE]] %[[C]] 27 } 28 29 struct S { 30 _BitInt(17) A; 31 _BitInt(128) B; 32 _BitInt(17) C; 33 }; 34 35 void OffsetOfTest() { 36 // CHECK: define {{.*}}void @OffsetOfTest 37 int A = __builtin_offsetof(struct S,A); 38 // CHECK: store i32 0, i32* %{{.+}} 39 int B = __builtin_offsetof(struct S,B); 40 // CHECK64: store i32 8, i32* %{{.+}} 41 // LIN32: store i32 4, i32* %{{.+}} 42 // WINCHECK32: store i32 8, i32* %{{.+}} 43 int C = __builtin_offsetof(struct S,C); 44 // CHECK64: store i32 24, i32* %{{.+}} 45 // LIN32: store i32 20, i32* %{{.+}} 46 // WIN32: store i32 24, i32* %{{.+}} 47 } 48 49 void Size1ExtIntParam(unsigned _BitInt(1) A) { 50 // CHECK: define {{.*}}void @Size1ExtIntParam(i1{{.*}} %[[PARAM:.+]]) 51 // CHECK: %[[PARAM_ADDR:.+]] = alloca i1 52 // CHECK: %[[B:.+]] = alloca [5 x i1] 53 // CHECK: store i1 %[[PARAM]], i1* %[[PARAM_ADDR]] 54 unsigned _BitInt(1) B[5]; 55 56 // CHECK: %[[PARAM_LOAD:.+]] = load i1, i1* %[[PARAM_ADDR]] 57 // CHECK: %[[IDX:.+]] = getelementptr inbounds [5 x i1], [5 x i1]* %[[B]] 58 // CHECK: store i1 %[[PARAM_LOAD]], i1* %[[IDX]] 59 B[2] = A; 60 } 61