[llvm-commits] CVS: llvm/utils/TableGen/DAGISelEmitter.cpp

Evan Cheng evan.cheng at apple.com
Mon Jul 31 12:02:14 PDT 2006



Changes in directory llvm/utils/TableGen:

DAGISelEmitter.cpp updated: 1.232 -> 1.233
---
Log message:

Remove an unneeded match condition: the type check for root node has been
moved to outside the actual select routine.


---
Diffs of the changes:  (+22 -7)

 DAGISelEmitter.cpp |   29 ++++++++++++++++++++++-------
 1 files changed, 22 insertions(+), 7 deletions(-)


Index: llvm/utils/TableGen/DAGISelEmitter.cpp
diff -u llvm/utils/TableGen/DAGISelEmitter.cpp:1.232 llvm/utils/TableGen/DAGISelEmitter.cpp:1.233
--- llvm/utils/TableGen/DAGISelEmitter.cpp:1.232	Fri Jul 28 17:51:01 2006
+++ llvm/utils/TableGen/DAGISelEmitter.cpp	Mon Jul 31 14:01:58 2006
@@ -1829,9 +1829,22 @@
   // If this node is commutative, consider the commuted order.
   if (NodeInfo.hasProperty(SDNodeInfo::SDNPCommutative)) {
     assert(N->getNumChildren()==2 &&"Commutative but doesn't have 2 children!");
+    // Don't count childrean which are actually
+    unsigned NC = 0;
+    for (unsigned i = 0, e = N->getNumChildren(); i != e; ++i) {
+      TreePatternNode *Child = N->getChild(i);
+      if (Child->isLeaf())
+        if (DefInit *DI = dynamic_cast<DefInit*>(Child->getLeafValue())) {
+          Record *RR = DI->getDef();
+          if (RR->isSubClassOf("Register"))
+            continue;
+        }
+      NC++;
+    }
     // Consider the commuted order.
-    CombineChildVariants(N, ChildVariants[1], ChildVariants[0],
-                         OutVariants, ISE);
+    if (NC == 2)
+      CombineChildVariants(N, ChildVariants[1], ChildVariants[0],
+                           OutVariants, ISE);
   }
 }
 
@@ -2845,13 +2858,15 @@
   /// 'Pat' may be missing types.  If we find an unresolved type to add a check
   /// for, this returns true otherwise false if Pat has all types.
   bool InsertOneTypeCheck(TreePatternNode *Pat, TreePatternNode *Other,
-                          const std::string &Prefix) {
+                          const std::string &Prefix, bool isRoot = false) {
     // Did we find one?
     if (Pat->getExtTypes() != Other->getExtTypes()) {
       // Move a type over from 'other' to 'pat'.
       Pat->setTypes(Other->getExtTypes());
-      emitCheck(Prefix + ".Val->getValueType(0) == " +
-                getName(Pat->getTypeNum(0)));
+      // The top level node type is checked outside of the select function.
+      if (!isRoot)
+        emitCheck(Prefix + ".Val->getValueType(0) == " +
+                  getName(Pat->getTypeNum(0)));
       return true;
     }
   
@@ -3005,7 +3020,7 @@
     // Insert a check for an unresolved type and add it to the tree.  If we find
     // an unresolved type to add a check for, this returns true and we iterate,
     // otherwise we are done.
-  } while (Emitter.InsertOneTypeCheck(Pat, Pattern.getSrcPattern(), "N"));
+  } while (Emitter.InsertOneTypeCheck(Pat, Pattern.getSrcPattern(), "N", true));
 
   Emitter.EmitResultCode(Pattern.getDstPattern(), false, true /*the root*/);
   delete Pat;
@@ -3282,7 +3297,7 @@
         // patterns after it CANNOT ever match.  Error out.
         if (mightNotMatch == false && i != CodeForPatterns.size()-1) {
           std::cerr << "Pattern '";
-          CodeForPatterns[i+1].first->getSrcPattern()->print(OS);
+          CodeForPatterns[i+1].first->getSrcPattern()->print(std::cerr);
           std::cerr << "' is impossible to select!\n";
           exit(1);
         }






More information about the llvm-commits mailing list