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
7 // RUN: not llvm-tblgen -DERROR6 %s 2>&1 | FileCheck --check-prefix=ERROR6 %s
8 // RUN: not llvm-tblgen -DERROR7 %s 2>&1 | FileCheck --check-prefix=ERROR7 %s
9 // RUN: not llvm-tblgen -DERROR8 %s 2>&1 | FileCheck --check-prefix=ERROR8 %s
11 class TestClass<int a, int b = 2, int c = 3> {
12 int value = !add(a, b, c);
14 // CHECK: def testClass1 {
15 // CHECK-NEXT: int value = 6;
17 // CHECK: def testClass2 {
18 // CHECK-NEXT: int value = 6;
20 // CHECK: def testClass3 {
21 // CHECK-NEXT: int value = 6;
23 // CHECK: def testClass4 {
24 // CHECK-NEXT: int value = 6;
26 // CHECK: def testClass5 {
27 // CHECK-NEXT: int value = 6;
29 // CHECK: def testClass6 {
30 // CHECK-NEXT: int value = 6;
32 // CHECK: def testClass7 {
33 // CHECK-NEXT: int value = 6;
35 // CHECK: def testClass8 {
36 // CHECK-NEXT: int value = 6;
38 def testClass1: TestClass<1>;
39 def testClass2: TestClass<1, 2>;
40 def testClass3: TestClass<1, 2, 3>;
41 def testClass4: TestClass<1, b=2>;
42 def testClass5: TestClass<1, c=3>;
43 def testClass6: TestClass<1, b=2, c=3>;
44 def testClass7: TestClass<1, c=3, b=2>;
45 def testClass8: TestClass<a=1, c=3, b=2>;
47 multiclass TestMultiClass<int a, int b = 2, int c = 3> {
48 def "": TestClass<a, b=b, c=c>;
51 // CHECK: def testMultiClass1 {
52 // CHECK-NEXT: int value = 6;
54 // CHECK: def testMultiClass2 {
55 // CHECK-NEXT: int value = 6;
57 // CHECK: def testMultiClass3 {
58 // CHECK-NEXT: int value = 6;
60 // CHECK: def testMultiClass4 {
61 // CHECK-NEXT: int value = 6;
63 // CHECK: def testMultiClass5 {
64 // CHECK-NEXT: int value = 6;
66 // CHECK: def testMultiClass6 {
67 // CHECK-NEXT: int value = 6;
69 // CHECK: def testMultiClass7 {
70 // CHECK-NEXT: int value = 6;
72 // CHECK: def testMultiClass8 {
73 // CHECK-NEXT: int value = 6;
75 defm testMultiClass1: TestMultiClass<1>;
76 defm testMultiClass2: TestMultiClass<1, 2>;
77 defm testMultiClass3: TestMultiClass<1, 2, 3>;
78 defm testMultiClass4: TestMultiClass<1, b=2>;
79 defm testMultiClass5: TestMultiClass<1, c=3>;
80 defm testMultiClass6: TestMultiClass<1, b=2, c=3>;
81 defm testMultiClass7: TestMultiClass<1, c=3, b=2>;
82 defm testMultiClass8: TestMultiClass<a=1, b=2, c=3>;
84 class TestSubroutine<int a, int b=a>{
88 // CHECK: def testSubroutine {
89 // CHECK-NEXT: int value1 = 2;
90 // CHECK-NEXT: int value2 = 2;
91 // CHECK-NEXT: int value3 = 2;
94 int value1=TestSubroutine<1>.value;
95 int value2=TestSubroutine<1, b=1>.value;
96 int value3=TestSubroutine<b=1, a=1>.value;
100 // ERROR1: Argument "d" doesn't exist
101 def testError1: TestClass<1, d=3>;
105 // ERROR2: The name of named argument should be a valid identifier
106 def testError2: TestClass<1, 3=0>;
110 // ERROR3: Positional argument should be put before named argument
111 def testError3: TestClass<1, b=1, 2>;
115 // ERROR4: The value of named argument should be initialized, but we got '?'
116 def testError4: TestClass<1, b=?>;
120 // ERROR5: We can only specify the template argument 'TestClass:a' once
121 def testError5: TestClass<1, a=1>;
125 // ERROR6: We can only specify the template argument 'TestMultiClass::a' once
126 defm testError6: TestMultiClass<1, a=1>;
130 // ERROR7: We can only specify the template argument 'TestSubroutine:a' once
132 int value=TestSubroutine<1, a=1>.value;
137 // ERROR8: We can only specify the template argument 'TestClass:b' once
138 def testError8: TestClass<a=1, b=1, b=1>;