1 // REQUIRES: xcore-registered-target 2 // RUN: %clang_cc1 -triple xcore-unknown-unknown -fno-signed-char -fno-common -emit-llvm -o - %s | FileCheck %s 3 4 // CHECK: target triple = "xcore-unknown-unknown" 5 6 // In the tests below, some types are not supported by the ABI (_Complex, 7 // variable length arrays) and will thus emit no meta data. 8 // The 38 tests that do emit typestrings are gathered into '!xcore.typestrings' 9 // Please see 'Tools Development Guide' section 2.16.2 for format details: 10 // <https://www.xmos.com/download/public/Tools-Development-Guide%28X9114A%29.pdf> 11 12 // CHECK: !xcore.typestrings = !{ 13 // CHECK: !{{[0-9]+}}, !{{[0-9]+}}, !{{[0-9]+}}, !{{[0-9]+}}, !{{[0-9]+}}, 14 // CHECK: !{{[0-9]+}}, !{{[0-9]+}}, !{{[0-9]+}}, !{{[0-9]+}}, !{{[0-9]+}}, 15 // CHECK: !{{[0-9]+}}, !{{[0-9]+}}, !{{[0-9]+}}, !{{[0-9]+}}, !{{[0-9]+}}, 16 // CHECK: !{{[0-9]+}}, !{{[0-9]+}}, !{{[0-9]+}}, !{{[0-9]+}}, !{{[0-9]+}}, 17 // CHECK: !{{[0-9]+}}, !{{[0-9]+}}, !{{[0-9]+}}, !{{[0-9]+}}, !{{[0-9]+}}, 18 // CHECK: !{{[0-9]+}}, !{{[0-9]+}}, !{{[0-9]+}}, !{{[0-9]+}}, !{{[0-9]+}}, 19 // CHECK: !{{[0-9]+}}, !{{[0-9]+}}, !{{[0-9]+}}, !{{[0-9]+}}, !{{[0-9]+}}, 20 // CHECK: !{{[0-9]+}}, !{{[0-9]+}}, !{{[0-9]+}} 21 // CHECK-NOT: , !{{[0-9]+}} 22 // CHECK: } 23 24 25 // test BuiltinType 26 // CHECK: !{{[0-9]+}} = !{void (i1, i8, i8, i8, i16, i16, i16, i32, i32, i32, 27 // CHECK: i32, i32, i32, i64, i64, i64, float, double, double)* 28 // CHECK: @builtinType, !"f{0}(b,uc,uc,sc,ss,us,ss,si,ui,si,sl, 29 // CHECK: ul,sl,sll,ull,sll,ft,d,ld)"} 30 void builtinType(_Bool B, char C, unsigned char UC, signed char SC, short S, 31 unsigned short US, signed short SS, int I, unsigned int UI, 32 signed int SI, long L, unsigned long UL, signed long SL, 33 long long LL, unsigned long long ULL, signed long long SLL, 34 float F, double D, long double LD) {} 35 double _Complex Complex; // not supported 36 37 38 // test FunctionType & Qualifiers 39 // CHECK: !{{[0-9]+}} = !{void ()* @gI, !"f{0}()"} 40 // CHECK: !{{[0-9]+}} = !{void (...)* @eI, !"f{0}()"} 41 // CHECK: !{{[0-9]+}} = !{void ()* @gV, !"f{0}(0)"} 42 // CHECK: !{{[0-9]+}} = !{void ()* @eV, !"f{0}(0)"} 43 // CHECK: !{{[0-9]+}} = !{void (i32, ...)* @gVA, !"f{0}(si,va)"} 44 // CHECK: !{{[0-9]+}} = !{void (i32, ...)* @eVA, !"f{0}(si,va)"} 45 // CHECK: !{{[0-9]+}} = !{i32* (i32*)* @gQ, !"f{crv:p(cv:si)}(p(cv:si))"} 46 // CHECK: !{{[0-9]+}} = !{i32* (i32*)* @eQ, !"f{crv:p(cv:si)}(p(cv:si))"} 47 extern void eI(); 48 void gI() {eI();}; 49 extern void eV(void); 50 void gV(void) {eV();} 51 extern void eVA(int, ...); 52 void gVA(int i, ...) {eVA(i);} 53 extern const volatile int* volatile restrict const 54 eQ(const volatile int * volatile restrict const); 55 const volatile int* volatile restrict const 56 gQ(const volatile int * volatile restrict const i) {return eQ(i);} 57 58 59 // test PointerType 60 // CHECK: !{{[0-9]+}} = !{i32* (i32*, i32* (i32*)*)* 61 // CHECK: @pointerType, !"f{p(si)}(p(si),p(f{p(si)}(p(si))))"} 62 // CHECK: !{{[0-9]+}} = !{i32** @EP, !"p(si)"} 63 // CHECK: !{{[0-9]+}} = !{i32** @GP, !"p(si)"} 64 extern int* EP; 65 int* GP; 66 int* pointerType(int *I, int * (*FP)(int *)) { 67 return I? EP : GP; 68 } 69 70 // test ArrayType 71 // CHECK: !{{[0-9]+}} = !{[2 x i32]* (i32*, i32*, [2 x i32]*, [2 x i32]*, i32*)* 72 // CHECK: @arrayType, !"f{p(a(2:si))}(p(si),p(cv:si),p(a(2:si)), 73 // CHECK: p(a(2:si)),p(si))"} 74 // CHECK: !{{[0-9]+}} = !{[0 x i32]* @EA1, !"a(*:cv:si)"} 75 // CHECK: !{{[0-9]+}} = !{[2 x i32]* @EA2, !"a(2:si)"} 76 // CHECK: !{{[0-9]+}} = !{[0 x [2 x i32]]* @EA3, !"a(*:a(2:si))"} 77 // CHECK: !{{[0-9]+}} = !{[3 x [2 x i32]]* @EA4, !"a(3:a(2:si))"} 78 // CHECK: !{{[0-9]+}} = !{[2 x i32]* @GA1, !"a(2:cv:si)"} 79 // CHECK: !{{[0-9]+}} = !{void ([2 x i32]*)* @arrayTypeVariable1, 80 // CHECK: !"f{0}(p(a(2:si)))"} 81 // CHECK: !{{[0-9]+}} = !{void (void ([2 x i32]*)*)* @arrayTypeVariable2, 82 // CHECK: !"f{0}(p(f{0}(p(a(2:si)))))"} 83 // CHECK: !{{[0-9]+}} = !{[3 x [2 x i32]]* @GA2, !"a(3:a(2:si))"} 84 extern int GA2[3][2]; 85 extern const volatile int EA1[]; 86 extern int EA2[2]; 87 extern int EA3[][2]; 88 extern int EA4[3][2]; 89 const volatile int GA1[2]; 90 extern void arrayTypeVariable1(int[*][2]); 91 extern void arrayTypeVariable2( void(*fp)(int[*][2]) ); 92 extern void arrayTypeVariable3(int[3][*]); // not supported 93 extern void arrayTypeVariable4( void(*fp)(int[3][*]) ); // not supported 94 typedef int RetType[2]; 95 RetType* arrayType(int A1[], int const volatile A2[2], int A3[][2], 96 int A4[3][2], int A5[const volatile restrict static 2]) { 97 if (A1) EA2[0] = EA1[0]; 98 if (A2) return &EA2; 99 if (A3) return EA3; 100 if (A4) return EA4; 101 if (A5) EA2[0] = GA1[0]; 102 arrayTypeVariable1(EA4); 103 arrayTypeVariable2(arrayTypeVariable1); 104 arrayTypeVariable3(EA4); 105 arrayTypeVariable4(arrayTypeVariable3); 106 return GA2; 107 } 108 109 110 // test StructureType 111 // CHECK: !{{[0-9]+}} = !{void (%struct.S1*)* @structureType1, 112 // CHECK: !"f{0}(s(S1){m(ps2){p(s(S2){m(ps3){p(s(S3){m(s1){s(S1){}}})}})}})"} 113 // CHECK: !{{[0-9]+}} = !{void (%struct.S2*)* @structureType2, 114 // CHECK: !"f{0}(s(S2){m(ps3){p(s(S3){m(s1){s(S1){m(ps2){p(s(S2){})}}}})}})"} 115 // CHECK: !{{[0-9]+}} = !{void (%struct.S3*)* @structureType3, 116 // CHECK: !"f{0}(s(S3){m(s1){s(S1){m(ps2){p(s(S2){m(ps3){p(s(S3){})}})}}}})"} 117 // CHECK: !{{[0-9]+}} = !{void (%struct.S4*)* @structureType4, 118 // CHECK: !"f{0}(s(S4){m(s1){s(S1){m(ps2){p(s(S2){m(ps3){p(s(S3){m(s1){s(S1){}}})}})}}}})"} 119 // CHECK: !{{[0-9]+}} = !{%struct.anon* @StructAnon, !"s(){m(A){si}}"} 120 // CHECK: !{{[0-9]+}} = !{i32 (%struct.SB*)* @structureTypeB, 121 // CHECK: !"f{si}(s(SB){m(){b(4:si)},m(){b(2:si)},m(N4){b(4:si)}, 122 // CHECK: m(N2){b(2:si)},m(){b(4:ui)},m(){b(4:si)},m(){b(4:c:si)}, 123 // CHECK: m(){b(4:c:si)},m(){b(4:cv:si)}})"} 124 struct S2; 125 struct S1{struct S2 *ps2;}; 126 struct S3; 127 struct S2{struct S3 *ps3;}; 128 struct S3{struct S1 s1;}; 129 struct S4{struct S1 s1;}; 130 void structureType1(struct S1 s1){} 131 void structureType2(struct S2 s2){} 132 void structureType3(struct S3 s3){} 133 void structureType4(struct S4 s4){} 134 struct {int A;} StructAnon = {1}; 135 struct SB{int:4; int:2; int N4:4; int N2:2; unsigned int:4; signed int:4; 136 const int:4; int const :4; volatile const int:4;}; 137 int structureTypeB(struct SB sb){return StructAnon.A;} 138 139 140 // test UnionType 141 // CHECK: !{{[0-9]+}} = !{void (%union.U1*)* @unionType1, 142 // CHECK: !"f{0}(u(U1){m(pu2){p(u(U2){m(pu3){p(u(U3){m(u1){u(U1){}}})}})}})"} 143 // CHECK: !{{[0-9]+}} = !{void (%union.U2*)* @unionType2, 144 // CHECK: !"f{0}(u(U2){m(pu3){p(u(U3){m(u1){u(U1){m(pu2){p(u(U2){})}}}})}})"} 145 // CHECK: !{{[0-9]+}} = !{void (%union.U3*)* @unionType3, 146 // CHECK: !"f{0}(u(U3){m(u1){u(U1){m(pu2){p(u(U2){m(pu3){p(u(U3){})}})}}}})"} 147 // CHECK: !{{[0-9]+}} = !{void (%union.U4*)* @unionType4, 148 // CHECK: !"f{0}(u(U4){m(u1){u(U1){m(pu2){p(u(U2){m(pu3){p(u(U3){m(u1){u(U1){}}})}})}}}})"} 149 // CHECK: !{{[0-9]+}} = !{%union.anon* @UnionAnon, !"u(){m(A){si}}"} 150 // CHECK: !{{[0-9]+}} = !{i32 (%union.UB*)* @unionTypeB, 151 // CHECK: !"f{si}(u(UB){m(N2){b(2:si)},m(N4){b(4:si)},m(){b(2:si)}, 152 // CHECK: m(){b(4:c:si)},m(){b(4:c:si)},m(){b(4:cv:si)},m(){b(4:si)}, 153 // CHECK: m(){b(4:si)},m(){b(4:ui)}})"} 154 union U2; 155 union U1{union U2 *pu2;}; 156 union U3; 157 union U2{union U3 *pu3;}; 158 union U3{union U1 u1;}; 159 union U4{union U1 u1;}; 160 void unionType1(union U1 u1) {} 161 void unionType2(union U2 u2) {} 162 void unionType3(union U3 u3) {} 163 void unionType4(union U4 u4) {} 164 union UB{int:4; int:2; int N4:4; int N2:2; unsigned int:4; signed int:4; 165 const int:4; int const :4; volatile const int:4;}; 166 union {int A;} UnionAnon = {1}; 167 int unionTypeB(union UB ub) {return UnionAnon.A;} 168 169 170 // test EnumType 171 // CHECK: !{{[0-9]+}} = !{i32* @EnumAnon, !"e(){m(EA){3}}"} 172 // CHECK: !{{[0-9]+}} = !{i32 (i32)* @enumType, 173 // CHECK: !"f{si}(e(E){m(A){7},m(B){6},m(C){5},m(D){0}})"} 174 enum E {D, C=5, B, A}; 175 enum {EA=3} EnumAnon = EA; 176 int enumType(enum E e) {return EnumAnon;} 177 178 179 // CHECK: !{{[0-9]+}} = !{i32 ()* @testReDecl, !"f{si}()"} 180 // CHECK: !{{[0-9]+}} = !{[10 x i32]* @After, !"a(10:si)"} 181 // CHECK: !{{[0-9]+}} = !{[10 x i32]* @Before, !"a(10:si)"} 182 extern int After[]; 183 extern int Before[10]; 184 int testReDecl() {return After[0] + Before[0];} 185 int After[10]; 186 int Before[]; 187 188