• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // RUN: %clang -target lanai-unknown-unknown -### %s -emit-llvm-only -c 2>&1 \
2 // RUN:   | FileCheck %s -check-prefix=ECHO
3 // RUN: %clang -target lanai-unknown-unknown %s -emit-llvm -S -o - \
4 // RUN:   | FileCheck %s
5 
6 // ECHO: {{.*}} "-cc1" {{.*}}lanai-unknown-unknown.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_vl = dso_local global i32 4
33 int align_vl = __alignof(va_list);
34 
35 // Check types
36 
37 // CHECK: signext i8 @check_char()
check_char()38 char check_char() { return 0; }
39 
40 // CHECK: signext i16 @check_short()
check_short()41 short check_short() { return 0; }
42 
43 // CHECK: i32 @check_int()
check_int()44 int check_int() { return 0; }
45 
46 // CHECK: i32 @check_long()
check_long()47 long check_long() { return 0; }
48 
49 // CHECK: i64 @check_longlong()
check_longlong()50 long long check_longlong() { return 0; }
51 
52 // CHECK: zeroext i8 @check_uchar()
check_uchar()53 unsigned char check_uchar() { return 0; }
54 
55 // CHECK: zeroext i16 @check_ushort()
check_ushort()56 unsigned short check_ushort() { return 0; }
57 
58 // CHECK: i32 @check_uint()
check_uint()59 unsigned int check_uint() { return 0; }
60 
61 // CHECK: i32 @check_ulong()
check_ulong()62 unsigned long check_ulong() { return 0; }
63 
64 // CHECK: i64 @check_ulonglong()
check_ulonglong()65 unsigned long long check_ulonglong() { return 0; }
66 
67 // CHECK: i32 @check_size_t()
check_size_t()68 size_t check_size_t() { return 0; }
69 
70 }
71 
72 template<int> void Switch();
73 template<> void Switch<4>();
74 template<> void Switch<8>();
75 template<> void Switch<16>();
76 
check_pointer_size()77 void check_pointer_size() {
78   // CHECK: SwitchILi4
79   Switch<sizeof(void*)>();
80 
81   // CHECK: SwitchILi8
82   Switch<sizeof(long long)>();
83 
84   // CHECK: SwitchILi4
85   Switch<sizeof(va_list)>();
86 }
87