1*0a6a1f1dSLionel Sambuc // RUN: %clang -target le64-unknown-unknown -### %s -emit-llvm-only -c 2>&1 | FileCheck %s -check-prefix=ECHO 2*0a6a1f1dSLionel Sambuc // RUN: %clang -target le64-unknown-unknown %s -emit-llvm -S -c -o - | FileCheck %s 3*0a6a1f1dSLionel Sambuc 4*0a6a1f1dSLionel Sambuc // ECHO: {{.*}} "-cc1" {{.*}}le64-unknown-unknown.c 5*0a6a1f1dSLionel Sambuc 6*0a6a1f1dSLionel Sambuc typedef __builtin_va_list va_list; 7*0a6a1f1dSLionel Sambuc typedef __SIZE_TYPE__ size_t; 8*0a6a1f1dSLionel Sambuc typedef __PTRDIFF_TYPE__ ptrdiff_t; 9*0a6a1f1dSLionel Sambuc 10*0a6a1f1dSLionel Sambuc extern "C" { 11*0a6a1f1dSLionel Sambuc 12*0a6a1f1dSLionel Sambuc // CHECK: @align_c = global i32 1 13*0a6a1f1dSLionel Sambuc int align_c = __alignof(char); 14*0a6a1f1dSLionel Sambuc 15*0a6a1f1dSLionel Sambuc // CHECK: @align_s = global i32 2 16*0a6a1f1dSLionel Sambuc int align_s = __alignof(short); 17*0a6a1f1dSLionel Sambuc 18*0a6a1f1dSLionel Sambuc // CHECK: @align_i = global i32 4 19*0a6a1f1dSLionel Sambuc int align_i = __alignof(int); 20*0a6a1f1dSLionel Sambuc 21*0a6a1f1dSLionel Sambuc // CHECK: @align_l = global i32 8 22*0a6a1f1dSLionel Sambuc int align_l = __alignof(long); 23*0a6a1f1dSLionel Sambuc 24*0a6a1f1dSLionel Sambuc // CHECK: @align_ll = global i32 8 25*0a6a1f1dSLionel Sambuc int align_ll = __alignof(long long); 26*0a6a1f1dSLionel Sambuc 27*0a6a1f1dSLionel Sambuc // CHECK: @align_p = global i32 8 28*0a6a1f1dSLionel Sambuc int align_p = __alignof(void*); 29*0a6a1f1dSLionel Sambuc 30*0a6a1f1dSLionel Sambuc // CHECK: @align_f = global i32 4 31*0a6a1f1dSLionel Sambuc int align_f = __alignof(float); 32*0a6a1f1dSLionel Sambuc 33*0a6a1f1dSLionel Sambuc // CHECK: @align_d = global i32 8 34*0a6a1f1dSLionel Sambuc int align_d = __alignof(double); 35*0a6a1f1dSLionel Sambuc 36*0a6a1f1dSLionel Sambuc // CHECK: @align_ld = global i32 8 37*0a6a1f1dSLionel Sambuc int align_ld = __alignof(long double); 38*0a6a1f1dSLionel Sambuc 39*0a6a1f1dSLionel Sambuc // CHECK: @align_vl = global i32 4 40*0a6a1f1dSLionel Sambuc int align_vl = __alignof(va_list); 41*0a6a1f1dSLionel Sambuc 42*0a6a1f1dSLionel Sambuc // CHECK: __LITTLE_ENDIAN__defined 43*0a6a1f1dSLionel Sambuc #ifdef __LITTLE_ENDIAN__ __LITTLE_ENDIAN__defined()44*0a6a1f1dSLionel Sambucvoid __LITTLE_ENDIAN__defined() {} 45*0a6a1f1dSLionel Sambuc #endif 46*0a6a1f1dSLionel Sambuc 47*0a6a1f1dSLionel Sambuc // CHECK: __le64defined 48*0a6a1f1dSLionel Sambuc #ifdef __le64 __le64defined()49*0a6a1f1dSLionel Sambucvoid __le64defined() {} 50*0a6a1f1dSLionel Sambuc #endif 51*0a6a1f1dSLionel Sambuc 52*0a6a1f1dSLionel Sambuc // CHECK: __le64__defined 53*0a6a1f1dSLionel Sambuc #ifdef __le64__ __le64__defined()54*0a6a1f1dSLionel Sambucvoid __le64__defined() {} 55*0a6a1f1dSLionel Sambuc #endif 56*0a6a1f1dSLionel Sambuc 57*0a6a1f1dSLionel Sambuc // CHECK: unixdefined 58*0a6a1f1dSLionel Sambuc #ifdef unix unixdefined()59*0a6a1f1dSLionel Sambucvoid unixdefined() {} 60*0a6a1f1dSLionel Sambuc #endif 61*0a6a1f1dSLionel Sambuc 62*0a6a1f1dSLionel Sambuc // CHECK: __unixdefined 63*0a6a1f1dSLionel Sambuc #ifdef __unix __unixdefined()64*0a6a1f1dSLionel Sambucvoid __unixdefined() {} 65*0a6a1f1dSLionel Sambuc #endif 66*0a6a1f1dSLionel Sambuc 67*0a6a1f1dSLionel Sambuc // CHECK: __unix__defined 68*0a6a1f1dSLionel Sambuc #ifdef __unix__ __unix__defined()69*0a6a1f1dSLionel Sambucvoid __unix__defined() {} 70*0a6a1f1dSLionel Sambuc #endif 71*0a6a1f1dSLionel Sambuc 72*0a6a1f1dSLionel Sambuc // CHECK: __ELF__defined 73*0a6a1f1dSLionel Sambuc #ifdef __ELF__ __ELF__defined()74*0a6a1f1dSLionel Sambucvoid __ELF__defined() {} 75*0a6a1f1dSLionel Sambuc #endif 76*0a6a1f1dSLionel Sambuc 77*0a6a1f1dSLionel Sambuc // Check types 78*0a6a1f1dSLionel Sambuc 79*0a6a1f1dSLionel Sambuc // CHECK: signext i8 @check_char() check_char()80*0a6a1f1dSLionel Sambucchar check_char() { return 0; } 81*0a6a1f1dSLionel Sambuc 82*0a6a1f1dSLionel Sambuc // CHECK: signext i16 @check_short() check_short()83*0a6a1f1dSLionel Sambucshort check_short() { return 0; } 84*0a6a1f1dSLionel Sambuc 85*0a6a1f1dSLionel Sambuc // CHECK: i32 @check_int() check_int()86*0a6a1f1dSLionel Sambucint check_int() { return 0; } 87*0a6a1f1dSLionel Sambuc 88*0a6a1f1dSLionel Sambuc // CHECK: i64 @check_long() check_long()89*0a6a1f1dSLionel Sambuclong check_long() { return 0; } 90*0a6a1f1dSLionel Sambuc 91*0a6a1f1dSLionel Sambuc // CHECK: i64 @check_longlong() check_longlong()92*0a6a1f1dSLionel Sambuclong long check_longlong() { return 0; } 93*0a6a1f1dSLionel Sambuc 94*0a6a1f1dSLionel Sambuc // CHECK: zeroext i8 @check_uchar() check_uchar()95*0a6a1f1dSLionel Sambucunsigned char check_uchar() { return 0; } 96*0a6a1f1dSLionel Sambuc 97*0a6a1f1dSLionel Sambuc // CHECK: zeroext i16 @check_ushort() check_ushort()98*0a6a1f1dSLionel Sambucunsigned short check_ushort() { return 0; } 99*0a6a1f1dSLionel Sambuc 100*0a6a1f1dSLionel Sambuc // CHECK: i32 @check_uint() check_uint()101*0a6a1f1dSLionel Sambucunsigned int check_uint() { return 0; } 102*0a6a1f1dSLionel Sambuc 103*0a6a1f1dSLionel Sambuc // CHECK: i64 @check_ulong() check_ulong()104*0a6a1f1dSLionel Sambucunsigned long check_ulong() { return 0; } 105*0a6a1f1dSLionel Sambuc 106*0a6a1f1dSLionel Sambuc // CHECK: i64 @check_ulonglong() check_ulonglong()107*0a6a1f1dSLionel Sambucunsigned long long check_ulonglong() { return 0; } 108*0a6a1f1dSLionel Sambuc 109*0a6a1f1dSLionel Sambuc // CHECK: i64 @check_size_t() check_size_t()110*0a6a1f1dSLionel Sambucsize_t check_size_t() { return 0; } 111*0a6a1f1dSLionel Sambuc 112*0a6a1f1dSLionel Sambuc // CHECK: i64 @check_ptrdiff_t() check_ptrdiff_t()113*0a6a1f1dSLionel Sambucptrdiff_t check_ptrdiff_t() { return 0; } 114*0a6a1f1dSLionel Sambuc 115*0a6a1f1dSLionel Sambuc // CHECK: float @check_float() check_float()116*0a6a1f1dSLionel Sambucfloat check_float() { return 0; } 117*0a6a1f1dSLionel Sambuc 118*0a6a1f1dSLionel Sambuc // CHECK: double @check_double() check_double()119*0a6a1f1dSLionel Sambucdouble check_double() { return 0; } 120*0a6a1f1dSLionel Sambuc 121*0a6a1f1dSLionel Sambuc // CHECK: double @check_longdouble() check_longdouble()122*0a6a1f1dSLionel Sambuclong double check_longdouble() { return 0; } 123*0a6a1f1dSLionel Sambuc 124*0a6a1f1dSLionel Sambuc } 125*0a6a1f1dSLionel Sambuc 126*0a6a1f1dSLionel Sambuc template<int> void Switch(); 127*0a6a1f1dSLionel Sambuc template<> void Switch<4>(); 128*0a6a1f1dSLionel Sambuc template<> void Switch<8>(); 129*0a6a1f1dSLionel Sambuc template<> void Switch<16>(); 130*0a6a1f1dSLionel Sambuc check_pointer_size()131*0a6a1f1dSLionel Sambucvoid check_pointer_size() { 132*0a6a1f1dSLionel Sambuc // CHECK: SwitchILi8 133*0a6a1f1dSLionel Sambuc Switch<sizeof(void*)>(); 134*0a6a1f1dSLionel Sambuc 135*0a6a1f1dSLionel Sambuc // CHECK: SwitchILi16 136*0a6a1f1dSLionel Sambuc Switch<sizeof(va_list)>(); 137*0a6a1f1dSLionel Sambuc } 138