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

Evan Cheng evan.cheng at apple.com
Fri Feb 17 18:33:21 PST 2006



Changes in directory llvm/utils/TableGen:

DAGISelEmitter.cpp updated: 1.172 -> 1.173
---
Log message:

Bump up pattern cost if the resulting instruction is marked
usesCustomDAGSchedInserter.


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

 DAGISelEmitter.cpp |   21 ++++++++++++++-------
 1 files changed, 14 insertions(+), 7 deletions(-)


Index: llvm/utils/TableGen/DAGISelEmitter.cpp
diff -u llvm/utils/TableGen/DAGISelEmitter.cpp:1.172 llvm/utils/TableGen/DAGISelEmitter.cpp:1.173
--- llvm/utils/TableGen/DAGISelEmitter.cpp:1.172	Thu Feb  9 16:12:27 2006
+++ llvm/utils/TableGen/DAGISelEmitter.cpp	Fri Feb 17 20:33:09 2006
@@ -1749,12 +1749,19 @@
 /// getResultPatternCost - Compute the number of instructions for this pattern.
 /// This is a temporary hack.  We should really include the instruction
 /// latencies in this calculation.
-static unsigned getResultPatternCost(TreePatternNode *P) {
+static unsigned getResultPatternCost(TreePatternNode *P, DAGISelEmitter &ISE) {
   if (P->isLeaf()) return 0;
   
-  unsigned Cost = P->getOperator()->isSubClassOf("Instruction");
+  unsigned Cost = 0;
+  Record *Op = P->getOperator();
+  if (Op->isSubClassOf("Instruction")) {
+    Cost++;
+    CodeGenInstruction &II = ISE.getTargetInfo().getInstruction(Op->getName());
+    if (II.usesCustomDAGSchedInserter)
+      Cost += 10;
+  }
   for (unsigned i = 0, e = P->getNumChildren(); i != e; ++i)
-    Cost += getResultPatternCost(P->getChild(i));
+    Cost += getResultPatternCost(P->getChild(i), ISE);
   return Cost;
 }
 
@@ -1773,8 +1780,8 @@
     if (LHSSize < RHSSize) return false;
     
     // If the patterns have equal complexity, compare generated instruction cost
-    return getResultPatternCost(LHS->getDstPattern()) <
-      getResultPatternCost(RHS->getDstPattern());
+    return getResultPatternCost(LHS->getDstPattern(), ISE) <
+      getResultPatternCost(RHS->getDstPattern(), ISE);
   }
 };
 
@@ -2748,7 +2755,7 @@
       OS << "\n";
       OS << std::string(Indent, ' ') << "// Pattern complexity = "
          << getPatternSize(Pattern.getSrcPattern(), *this) << "  cost = "
-         << getResultPatternCost(Pattern.getDstPattern()) << "\n";
+         << getResultPatternCost(Pattern.getDstPattern(), *this) << "\n";
     }
     if (!FirstCodeLine.first) {
       OS << std::string(Indent, ' ') << "{\n";
@@ -2769,7 +2776,7 @@
       OS << "\n";
       OS << std::string(Indent, ' ') << "// Pattern complexity = "
          << getPatternSize(Pattern.getSrcPattern(), *this) << "  cost = "
-         << getResultPatternCost(Pattern.getDstPattern()) << "\n";
+         << getResultPatternCost(Pattern.getDstPattern(), *this) << "\n";
     }
     EmitPatterns(Other, Indent, OS);
     return;






More information about the llvm-commits mailing list