Allow types to be omitted in output patterns.
authorJakob Stoklund Olesen <stoklund@2pi.dk>
Sun, 24 Mar 2013 19:37:00 +0000 (19:37 +0000)
committerJakob Stoklund Olesen <stoklund@2pi.dk>
Sun, 24 Mar 2013 19:37:00 +0000 (19:37 +0000)
This syntax is now preferred:

  def : Pat<(subc i32:$b, i32:$c), (SUBCCrr $b, $c)>;

There is no reason to repeat the types in the output pattern.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@177844 91177308-0d34-0410-b5e6-96231b3b80d8

utils/TableGen/CodeGenDAGPatterns.cpp
utils/TableGen/DAGISelMatcherGen.cpp

index 7f9f88ed40a10965bbe234845a6843b32aeb4ef4..8e5bb7760f6590183c95c8ed905fa539df590d5c 100644 (file)
@@ -1866,6 +1866,16 @@ TreePatternNode *TreePattern::ParseTreePattern(Init *TheInit, StringRef OpName){
     return Res;
   }
 
+  // ?:$name or just $name.
+  if (TheInit == UnsetInit::get()) {
+    if (OpName.empty())
+      error("'?' argument requires a name to match with operand list");
+    TreePatternNode *Res = new TreePatternNode(TheInit, 1);
+    Args.push_back(OpName);
+    Res->setName(OpName);
+    return Res;
+  }
+
   if (IntInit *II = dyn_cast<IntInit>(TheInit)) {
     if (!OpName.empty())
       error("Constant int argument should not have a name!");
index e91fd1e7ddee0a703b3452d99f612e4a0351b0b9..ed41631456b05d51b4cfac89159b1626eca63192 100644 (file)
@@ -211,6 +211,12 @@ void MatcherGen::EmitLeafMatchCode(const TreePatternNode *N) {
     return AddMatcher(new CheckIntegerMatcher(II->getValue()));
   }
 
+  // An UnsetInit represents a named node without any constraints.
+  if (N->getLeafValue() == UnsetInit::get()) {
+    assert(N->hasName() && "Unnamed ? leaf");
+    return;
+  }
+
   DefInit *DI = dyn_cast<DefInit>(N->getLeafValue());
   if (DI == 0) {
     errs() << "Unknown leaf kind: " << *N << "\n";