[PATCH] D151999: [llvm-tblgen] Fix parser error when using generic used as index

Guillaume Gomez via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jun 2 07:04:10 PDT 2023


GuillaumeGomez created this revision.
Herald added subscribers: arphaman, hiraditya.
Herald added a project: All.
GuillaumeGomez requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Using a generic variable as list index was throwing an error


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D151999

Files:
  llvm/lib/TableGen/TGParser.cpp
  llvm/test/TableGen/var-index.td


Index: llvm/test/TableGen/var-index.td
===================================================================
--- /dev/null
+++ llvm/test/TableGen/var-index.td
@@ -0,0 +1,10 @@
+// RUN: llvm-tblgen %s
+
+class ResolveArgCode<
+    list<int> Mapping,
+    int ax> {
+  int al = !and(ax, 0x00FF);
+  int num = Mapping[al];
+}
+
+def foo : ResolveArgCode<[0, 1], 0>;
Index: llvm/lib/TableGen/TGParser.cpp
===================================================================
--- llvm/lib/TableGen/TGParser.cpp
+++ llvm/lib/TableGen/TGParser.cpp
@@ -169,7 +169,6 @@
   // arguments, loop iterator, etc.
   switch (Kind) {
   case SK_Local:
-    break; /* do nothing. */
   case SK_Record: {
     if (CurRec) {
       // The variable is a record field?


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D151999.527853.patch
Type: text/x-patch
Size: 743 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230602/b45a8fb5/attachment.bin>


More information about the llvm-commits mailing list