[PATCH] D47432: TableGen/DAGPatterns: Allow bit constants in addition to int constants

Nicolai Hähnle via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun May 27 13:49:22 PDT 2018


nhaehnle created this revision.
nhaehnle added reviewers: tra, simon_tatham, craig.topper, MartinO, arsenm.
Herald added a subscriber: wdng.

Implicit casting is a simple quality of life improvement.

Change-Id: I3d2b31b8b8f12cbb1e84f691e359fa713a9c4b42


Repository:
  rL LLVM

https://reviews.llvm.org/D47432

Files:
  utils/TableGen/CodeGenDAGPatterns.cpp


Index: utils/TableGen/CodeGenDAGPatterns.cpp
===================================================================
--- utils/TableGen/CodeGenDAGPatterns.cpp
+++ utils/TableGen/CodeGenDAGPatterns.cpp
@@ -2572,10 +2572,12 @@
     return Res;
   }
 
-  if (IntInit *II = dyn_cast<IntInit>(TheInit)) {
+  if (isa<IntInit>(TheInit) || isa<BitInit>(TheInit)) {
     if (!OpName.empty())
-      error("Constant int argument should not have a name!");
-    return new TreePatternNode(II, 1);
+      error("Constant int or bit argument should not have a name!");
+    if (isa<BitInit>(TheInit))
+      TheInit = TheInit->convertInitializerTo(IntRecTy::get());
+    return new TreePatternNode(TheInit, 1);
   }
 
   if (BitsInit *BI = dyn_cast<BitsInit>(TheInit)) {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D47432.148768.patch
Type: text/x-patch
Size: 754 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180527/7c873a73/attachment.bin>


More information about the llvm-commits mailing list