Allow result node to be a simple leaf node. This enable bitconvert patterns
authorEvan Cheng <evan.cheng@apple.com>
Thu, 23 Mar 2006 02:35:32 +0000 (02:35 +0000)
committerEvan Cheng <evan.cheng@apple.com>
Thu, 23 Mar 2006 02:35:32 +0000 (02:35 +0000)
like this:
def : Pat<(v4i32 (bitconvert (v4f32 VR128:$src))), (v4i32 VR128:$src)>;

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

utils/TableGen/DAGISelEmitter.cpp

index ae2fcc75400e4fbc2aae3409806d89961a9f98a8..4aa6f7fc7e34fb980ac9f8fa4a37bfc05e994fd9 100644 (file)
@@ -1459,8 +1459,10 @@ void DAGISelEmitter::ParsePatterns() {
       }
       ResultNodeOperands.push_back(OpNode);
     }
-    DstPattern = new TreePatternNode(Result->getOnlyTree()->getOperator(),
-                                     ResultNodeOperands);
+    DstPattern = Result->getOnlyTree();
+    if (!DstPattern->isLeaf())
+      DstPattern = new TreePatternNode(DstPattern->getOperator(),
+                                       ResultNodeOperands);
     DstPattern->setTypes(Result->getOnlyTree()->getExtTypes());
     TreePattern Temp(Result->getRecord(), DstPattern, false, *this);
     Temp.InferAllTypes();
@@ -2191,7 +2193,6 @@ public:
   EmitResultCode(TreePatternNode *N, bool LikeLeaf = false, bool isRoot = false) {
     // This is something selected from the pattern we matched.
     if (!N->getName().empty()) {
-      assert(!isRoot && "Root of pattern cannot be a leaf!");
       std::string &Val = VariableMap[N->getName()];
       assert(!Val.empty() &&
              "Variable referenced but not defined and not caught earlier!");
@@ -2276,13 +2277,17 @@ public:
           emitCode("Tmp" + utostr(ResNo) + " = " + Val + ";");
         else
           emitCode("Select(Tmp" + utostr(ResNo) + ", " + Val + ");");
+
+        if (isRoot && N->isLeaf()) {
+          emitCode("Result = Tmp" + utostr(ResNo) + ";");
+          emitCode("return;");
+        }
       }
       // Add Tmp<ResNo> to VariableMap, so that we don't multiply select this
       // value if used multiple times by this pattern result.
       Val = "Tmp"+utostr(ResNo);
       return std::make_pair(NumRes, ResNo);
     }
-  
     if (N->isLeaf()) {
       // If this is an explicit register reference, handle it.
       if (DefInit *DI = dynamic_cast<DefInit*>(N->getLeafValue())) {