1 // RUN: llvm-tblgen %s | FileCheck %s
2 // RUN: not llvm-tblgen -DERROR1 %s 2>&1 | FileCheck --check-prefix=ERROR1 %s
3 // RUN: not llvm-tblgen -DERROR2 %s 2>&1 | FileCheck --check-prefix=ERROR2 %s
4 // RUN: not llvm-tblgen -DERROR3 %s 2>&1 | FileCheck --check-prefix=ERROR3 %s
5 // RUN: not llvm-tblgen -DERROR4 %s 2>&1 | FileCheck --check-prefix=ERROR4 %s
6 // RUN: not llvm-tblgen -DERROR5 %s 2>&1 | FileCheck --check-prefix=ERROR5 %s
12 deftype StringAlias = string;
13 deftype CodeAlias = code;
14 deftype DagAlias = dag;
15 deftype Boolean = bit;
16 deftype Byte = bits<8>;
17 deftype Integer = int;
18 deftype IntList = list<int>;
19 deftype ByteList = list<Byte>;
20 deftype ClassList = list<Class>;
21 // The type can be another type alias.
22 deftype ClassListAlias = ClassList;
25 // CHECK-NEXT: string str = "string";
26 // CHECK-NEXT: string codeStr = "code";
27 // CHECK-NEXT: dag dagExpr = ("string" "code");
28 // CHECK-NEXT: bit bool = 0;
29 // CHECK-NEXT: bits<8> byte = { 0, 1, 1, 1, 1, 0, 1, 1 };
30 // CHECK-NEXT: int integer = 123;
31 // CHECK-NEXT: list<int> ints = [1, 2, 3];
32 // CHECK-NEXT: list<bits<8>> bytes = [{ 0, 0, 0, 0, 0, 0, 0, 1 }, { 0, 0, 0, 0, 0, 0, 1, 0 }, { 0, 0, 0, 0, 0, 0, 1, 1 }];
33 // CHECK-NEXT: list<Class> defs = [anonymous_0, anonymous_1, anonymous_2];
36 StringAlias str = "string";
37 CodeAlias codeStr = "code";
38 DagAlias dagExpr = (str codeStr);
41 Integer integer = 123;
42 IntList ints = [1, 2, 3];
43 ByteList bytes = [1, 2, 3];
44 ClassListAlias defs = [Class<1>, Class<2>, Class<3>];
48 // ERROR1: [[@LINE+1]]:9: error: type of this name 'Byte' already exists
49 deftype Byte = bits<8>;
53 // ERROR2: [[@LINE+1]]:9: error: type of this name 'Class' already exists
58 // ERROR3: [[@LINE+1]]:22: error: cannot define type alias for class type 'Class'
59 deftype ClassAlias = Class;
63 // ERROR4: [[@LINE+1]]:7: error: there is already a defined type alias 'Byte'
64 class Byte; // incomplete class definition.
68 // ERROR5: [[@LINE+1]]:7: error: there is already a defined type alias 'Byte'