[PATCH] D44111: TableGen: Allow ? in lists

Nicolai Hähnle via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Mar 5 12:20:39 PST 2018


nhaehnle created this revision.
nhaehnle added reviewers: arsenm, craig.topper, tra, MartinO.
Herald added a subscriber: wdng.
nhaehnle added a dependency: D44110: TableGen: Add !dag function for construction.
nhaehnle added a dependent revision: D44112: TableGen: Type-check BinOps.

This makes using !dag more convenient in some cases.

Change-Id: I0a8c35e15ccd1ecec778fd1c8d64eee38d74517c


Repository:
  rL LLVM

https://reviews.llvm.org/D44111

Files:
  lib/TableGen/TGParser.cpp
  test/TableGen/dag-functional.td


Index: test/TableGen/dag-functional.td
===================================================================
--- test/TableGen/dag-functional.td
+++ test/TableGen/dag-functional.td
@@ -8,7 +8,7 @@
 // }
 
 // CHECK: def A1 {
-//   dag ret = (ops 1:$a, 2:$b);
+//   dag ret = (ops ?:$a, 1:$b, 2);
 // }
 
 // CHECK: def B0 {
@@ -40,7 +40,7 @@
 }
 
 def A0 : A<[], []>;
-def A1 : A<[1, 2], ["a", "b"]>;
+def A1 : A<[?, 1, 2], ["a", "b", ?]>;
 
 def B0 : B<[]>;
 def B1 : B<[Node<1, "a">, Node<2, "b">]>;
Index: lib/TableGen/TGParser.cpp
===================================================================
--- lib/TableGen/TGParser.cpp
+++ lib/TableGen/TGParser.cpp
@@ -1673,18 +1673,16 @@
     RecTy *EltTy = nullptr;
     for (Init *V : Vals) {
       TypedInit *TArg = dyn_cast<TypedInit>(V);
-      if (!TArg) {
-        TokError("Untyped list element");
-        return nullptr;
-      }
-      if (EltTy) {
-        EltTy = resolveTypes(EltTy, TArg->getType());
-        if (!EltTy) {
-          TokError("Incompatible types in list elements");
-          return nullptr;
+      if (TArg) {
+        if (EltTy) {
+          EltTy = resolveTypes(EltTy, TArg->getType());
+          if (!EltTy) {
+            TokError("Incompatible types in list elements");
+            return nullptr;
+          }
+        } else {
+          EltTy = TArg->getType();
         }
-      } else {
-        EltTy = TArg->getType();
       }
     }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D44111.137059.patch
Type: text/x-patch
Size: 1433 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180305/257e34a0/attachment.bin>


More information about the llvm-commits mailing list