[PATCH] D95308: [TableGen] Fix instantiating multiclass in foreach
Jyun-Yan You via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Jan 25 07:15:17 PST 2021
jyyou.tw updated this revision to Diff 319001.
jyyou.tw added a comment.
Refine test case
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D95308/new/
https://reviews.llvm.org/D95308
Files:
llvm/lib/TableGen/TGParser.cpp
llvm/test/TableGen/foreach-multiclass.td
Index: llvm/test/TableGen/foreach-multiclass.td
===================================================================
--- llvm/test/TableGen/foreach-multiclass.td
+++ llvm/test/TableGen/foreach-multiclass.td
@@ -57,6 +57,9 @@
// CHECK: def F2_2_1
// CHECK-NOT: def F2_2_2
+// CHECK: def G0
+// CHECK: def H0_G0_0
+
multiclass A<int x> {
foreach i = [0, 1] in {
def NAME#i {
@@ -116,3 +119,20 @@
defm F0 : F<[]>;
defm F1 : F<[0]>;
defm F2 : F<[0, 1, 2]>;
+
+// If multiclass argument comes from loop variable,
+// and field of argument is placed at foreach statement,
+// the record field must be resolved correctly.
+class G {
+ list<int> val = [0];
+}
+
+multiclass H<G g> {
+ foreach n = g.val in
+ def _#g#_#n;
+}
+
+def G0 : G;
+
+foreach g = [G0] in
+ defm H0 : H<g>;
Index: llvm/lib/TableGen/TGParser.cpp
===================================================================
--- llvm/lib/TableGen/TGParser.cpp
+++ llvm/lib/TableGen/TGParser.cpp
@@ -3524,8 +3524,8 @@
Substs.emplace_back(QualifiedNameOfImplicitName(MC), DefmName);
- if (resolve(MC->Entries, Substs, CurMultiClass == nullptr, &NewEntries,
- &SubClassLoc))
+ if (resolve(MC->Entries, Substs, CurMultiClass == nullptr && Loops.empty(),
+ &NewEntries, &SubClassLoc))
return true;
if (!consume(tgtok::comma))
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D95308.319001.patch
Type: text/x-patch
Size: 1358 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210125/02b86afb/attachment.bin>
More information about the llvm-commits
mailing list