Mercurial > hg > CbC > CbC_llvm
comparison llvm/test/TableGen/defvar.td @ 252:1f2b6ac9f198 llvm-original
LLVM16-1
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Fri, 18 Aug 2023 09:04:13 +0900 |
parents | 1d019706d866 |
children |
comparison
equal
deleted
inserted
replaced
237:c80f45b162ad | 252:1f2b6ac9f198 |
---|---|
1 // RUN: llvm-tblgen %s | FileCheck %s | 1 // RUN: llvm-tblgen %s | FileCheck %s |
2 // RUN: not llvm-tblgen -DERROR1 %s 2>&1 | FileCheck --check-prefix=ERROR1 %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 | 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 | 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 | |
5 | 7 |
6 #ifdef ERROR1 | 8 #ifdef ERROR1 |
7 // Refer to a variable we haven't defined *yet*, expecting an error. | 9 // Refer to a variable we haven't defined *yet*, expecting an error. |
8 // ERROR1: [[@LINE+1]]:22: error: Variable not defined: 'myvar' | 10 // ERROR1: [[@LINE+1]]:22: error: Variable not defined: 'myvar' |
9 def bad { dag x = (? myvar); } | 11 def bad { dag x = (? myvar); } |
132 | 134 |
133 // Now the outer variable is back in scope again. | 135 // Now the outer variable is back in scope again. |
134 def shadowOuterBelowIf # first { int var = shadowedVariable; } | 136 def shadowOuterBelowIf # first { int var = shadowedVariable; } |
135 } | 137 } |
136 | 138 |
139 class RedefinitionTest<int a, int b> { | |
140 #ifdef ERROR4 | |
141 defvar value = !add(a, b); | |
142 #endif | |
143 // ERROR4: [[@LINE+1]]:7: error: local variable of this name already exists | |
144 int value = !add(a, b); | |
145 #ifdef ERROR5 | |
146 // ERROR5: [[@LINE+1]]:10: error: field of this name already exists | |
147 defvar value = !add(a, b); | |
148 #endif | |
149 } | |
150 | |
151 // These variables should be shadowed by class/multiclass template arguments. | |
152 defvar a = 2333; | |
153 defvar b = 2333; | |
154 defvar c = 2333; | |
155 class ShadowGlobalsTest<int a, int b, int c> { | |
156 // Template arguments have higher priorities than global variables. | |
157 int value = !add(a, b, c); | |
158 } | |
159 | |
160 class ShadowClassArgumentTest<int a, int b, int c> { | |
161 // Local variable 'c' has higher priority than class template argument 'c'. | |
162 defvar c = !add(c, c); | |
163 int value = !add(a, b, c); | |
164 } | |
165 | |
166 multiclass ShadowMulticlassArgumentTest<int a, int b, int c> { | |
167 // Local variable 'c' has higher priority than multiclass template argument 'c'. | |
168 defvar c = !add(c, c); | |
169 def "" { | |
170 int value = !add(a, b, c); | |
171 } | |
172 } | |
173 | |
174 // CHECK: def shadowTestOfClassArgument { | |
175 // CHECK-NEXT: int value = 11; | |
176 // CHECK: def shadowTestOfGlobals { | |
177 // CHECK-NEXT: int value = 8; | |
178 // CHECK: def shadowTestOfLoopIterator0 { | |
179 // CHECK-NEXT: int value = 10; | |
180 // CHECK: def shadowTestOfLoopIterator1 { | |
181 // CHECK-NEXT: int value = 11; | |
182 // CHECK: def shadowTestOfMulticlassArgument { | |
183 // CHECK-NEXT: int value = 11; | |
184 def shadowTestOfClassArgument: ShadowClassArgumentTest<2, 3, 3>; | |
185 def shadowTestOfGlobals: ShadowGlobalsTest<2, 3, 3>; | |
186 foreach i = 0...1 in { | |
187 // Local variable 'i' has higher priority than loop iterator 'i'. | |
188 def shadowTestOfLoopIterator # i { | |
189 defvar i = !add(10, i); | |
190 int value = i; | |
191 } | |
192 } | |
193 defm shadowTestOfMulticlassArgument: ShadowMulticlassArgumentTest<2, 3, 3>; | |
194 | |
137 // Test that a top-level let statement also makes a variable scope (on the | 195 // Test that a top-level let statement also makes a variable scope (on the |
138 // general principle of consistency, because it defines a braced sub-block). | 196 // general principle of consistency, because it defines a braced sub-block). |
139 | 197 |
140 let someVariable = "some value" in { | 198 let someVariable = "some value" in { |
141 defvar myvar = "override the definition from above and expect no error"; | 199 defvar myvar = "override the definition from above and expect no error"; |