aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEvan Cheng <evan.cheng@apple.com>2006-02-18 02:33:09 +0000
committerEvan Cheng <evan.cheng@apple.com>2006-02-18 02:33:09 +0000
commitfbad70808cc17b56703777598d276723608d717d (patch)
treef6f91a0450053374ebeda1cc5347840cd1b454b2
parent6428302f3d5c70b3fa4bdedfc14cdd9104e271cf (diff)
Bump up pattern cost if the resulting instruction is marked
usesCustomDAGSchedInserter. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@26282 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--utils/TableGen/DAGISelEmitter.cpp21
1 files changed, 14 insertions, 7 deletions
diff --git a/utils/TableGen/DAGISelEmitter.cpp b/utils/TableGen/DAGISelEmitter.cpp
index 0c0cab9f01..cd3045d730 100644
--- a/utils/TableGen/DAGISelEmitter.cpp
+++ b/utils/TableGen/DAGISelEmitter.cpp
@@ -1749,12 +1749,19 @@ static unsigned getPatternSize(TreePatternNode *P, DAGISelEmitter &ISE) {
/// 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 @@ struct PatternSortingPredicate {
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 @@ void DAGISelEmitter::EmitPatterns(std::vector<std::pair<PatternToMatch*,
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 @@ void DAGISelEmitter::EmitPatterns(std::vector<std::pair<PatternToMatch*,
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;