• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // RUN: %clang -target le32-unknown-nacl -### %s -emit-llvm-only -c 2>&1 | FileCheck %s -check-prefix=ECHO
2 // RUN: %clang -target le32-unknown-nacl %s -emit-llvm -S -c -o - | FileCheck %s
3 // RUN: %clang -target le32-unknown-nacl -fexperimental-new-pass-manager %s -emit-llvm -S -c -o - | FileCheck %s
4 // RUN: %clang -target le32-unknown-nacl %s -emit-llvm -S -c -pthread -o - | FileCheck %s -check-prefix=THREADS
5 
6 // ECHO: {{.*}} "-cc1" {{.*}}le32-unknown-nacl.c
7 
8 typedef __builtin_va_list va_list;
9 typedef __SIZE_TYPE__ size_t;
10 typedef __PTRDIFF_TYPE__ ptrdiff_t;
11 
12 extern "C" {
13 
14 // CHECK: @align_c = dso_local global i32 1
15 int align_c = __alignof(char);
16 
17 // CHECK: @align_s = dso_local global i32 2
18 int align_s = __alignof(short);
19 
20 // CHECK: @align_i = dso_local global i32 4
21 int align_i = __alignof(int);
22 
23 // CHECK: @align_l = dso_local global i32 4
24 int align_l = __alignof(long);
25 
26 // CHECK: @align_ll = dso_local global i32 8
27 int align_ll = __alignof(long long);
28 
29 // CHECK: @align_p = dso_local global i32 4
30 int align_p = __alignof(void*);
31 
32 // CHECK: @align_f = dso_local global i32 4
33 int align_f = __alignof(float);
34 
35 // CHECK: @align_d = dso_local global i32 8
36 int align_d = __alignof(double);
37 
38 // CHECK: @align_ld = dso_local global i32 8
39 int align_ld = __alignof(long double);
40 
41 // CHECK: @align_vl = dso_local global i32 4
42 int align_vl = __alignof(va_list);
43 
44 // CHECK: __LITTLE_ENDIAN__defined
45 #ifdef __LITTLE_ENDIAN__
__LITTLE_ENDIAN__defined()46 void __LITTLE_ENDIAN__defined() {}
47 #endif
48 
49 // CHECK: __native_client__defined
50 #ifdef __native_client__
__native_client__defined()51 void __native_client__defined() {}
52 #endif
53 
54 // CHECK: __le32__defined
55 #ifdef __le32__
__le32__defined()56 void __le32__defined() {}
57 #endif
58 
59 // CHECK: __pnacl__defined
60 #ifdef __pnacl__
__pnacl__defined()61 void __pnacl__defined() {}
62 #endif
63 
64 // CHECK: unixdefined
65 #ifdef unix
unixdefined()66 void unixdefined() {}
67 #endif
68 
69 // CHECK: __ELF__defined
70 #ifdef __ELF__
__ELF__defined()71 void __ELF__defined() {}
72 #endif
73 
74 // CHECK: _GNU_SOURCEdefined
75 #ifdef _GNU_SOURCE
_GNU_SOURCEdefined()76 void _GNU_SOURCEdefined() {}
77 #endif
78 
79 // THREADS: _REENTRANTdefined
80 // CHECK: _REENTRANTundefined
81 #ifdef _REENTRANT
_REENTRANTdefined()82 void _REENTRANTdefined() {}
83 #else
_REENTRANTundefined()84 void _REENTRANTundefined() {}
85 #endif
86 
87 // Check types
88 
89 // CHECK: signext i8 @check_char()
check_char()90 char check_char() { return 0; }
91 
92 // CHECK: signext i16 @check_short()
check_short()93 short check_short() { return 0; }
94 
95 // CHECK: i32 @check_int()
check_int()96 int check_int() { return 0; }
97 
98 // CHECK: i32 @check_long()
check_long()99 long check_long() { return 0; }
100 
101 // CHECK: i64 @check_longlong()
check_longlong()102 long long check_longlong() { return 0; }
103 
104 // CHECK: zeroext i8 @check_uchar()
check_uchar()105 unsigned char check_uchar() { return 0; }
106 
107 // CHECK: zeroext i16 @check_ushort()
check_ushort()108 unsigned short check_ushort() { return 0; }
109 
110 // CHECK: i32 @check_uint()
check_uint()111 unsigned int check_uint() { return 0; }
112 
113 // CHECK: i32 @check_ulong()
check_ulong()114 unsigned long check_ulong() { return 0; }
115 
116 // CHECK: i64 @check_ulonglong()
check_ulonglong()117 unsigned long long check_ulonglong() { return 0; }
118 
119 // CHECK: i32 @check_size_t()
check_size_t()120 size_t check_size_t() { return 0; }
121 
122 // CHECK: float @check_float()
check_float()123 float check_float() { return 0; }
124 
125 // CHECK: double @check_double()
check_double()126 double check_double() { return 0; }
127 
128 // CHECK: double @check_longdouble()
check_longdouble()129 long double check_longdouble() { return 0; }
130 
131 }
132 
133 template<int> void Switch();
134 template<> void Switch<4>();
135 template<> void Switch<8>();
136 template<> void Switch<16>();
137 
check_pointer_size()138 void check_pointer_size() {
139   // CHECK: SwitchILi4
140   Switch<sizeof(void*)>();
141 
142   // CHECK: SwitchILi8
143   Switch<sizeof(long long)>();
144 
145   // CHECK: SwitchILi16
146   Switch<sizeof(va_list)>();
147 }
148