[llvm-commits] CVS: llvm/utils/TableGen/DAGISelEmitter.cpp
Evan Cheng
evan.cheng at apple.com
Tue Jul 18 17:24:55 PDT 2006
Changes in directory llvm/utils/TableGen:
DAGISelEmitter.cpp updated: 1.222 -> 1.223
---
Log message:
Add code size to target instruction use it as the 3rd isel sorting tie-breaker.
---
Diffs of the changes: (+25 -3)
DAGISelEmitter.cpp | 28 +++++++++++++++++++++++++---
1 files changed, 25 insertions(+), 3 deletions(-)
Index: llvm/utils/TableGen/DAGISelEmitter.cpp
diff -u llvm/utils/TableGen/DAGISelEmitter.cpp:1.222 llvm/utils/TableGen/DAGISelEmitter.cpp:1.223
--- llvm/utils/TableGen/DAGISelEmitter.cpp:1.222 Sun Jul 16 01:14:37 2006
+++ llvm/utils/TableGen/DAGISelEmitter.cpp Tue Jul 18 19:24:41 2006
@@ -1986,6 +1986,21 @@
return Cost;
}
+/// getResultPatternCodeSize - Compute the code size of instructions for this
+/// pattern.
+static unsigned getResultPatternSize(TreePatternNode *P, DAGISelEmitter &ISE) {
+ if (P->isLeaf()) return 0;
+
+ unsigned Cost = 0;
+ Record *Op = P->getOperator();
+ if (Op->isSubClassOf("Instruction")) {
+ Cost += Op->getValueAsInt("CodeSize");
+ }
+ for (unsigned i = 0, e = P->getNumChildren(); i != e; ++i)
+ Cost += getResultPatternSize(P->getChild(i), ISE);
+ return Cost;
+}
+
// PatternSortingPredicate - return true if we prefer to match LHS before RHS.
// In particular, we want to match maximal patterns first and lowest cost within
// a particular complexity first.
@@ -2003,8 +2018,13 @@
if (LHSSize < RHSSize) return false;
// If the patterns have equal complexity, compare generated instruction cost
- return getResultPatternCost(LHS->getDstPattern(), ISE) <
- getResultPatternCost(RHS->getDstPattern(), ISE);
+ unsigned LHSCost = getResultPatternCost(LHS->getDstPattern(), ISE);
+ unsigned RHSCost = getResultPatternCost(RHS->getDstPattern(), ISE);
+ if (LHSCost < RHSCost) return true;
+ if (LHSCost > RHSCost) return false;
+
+ return getResultPatternSize(LHS->getDstPattern(), ISE) <
+ getResultPatternSize(RHS->getDstPattern(), ISE);
}
};
@@ -3105,7 +3125,9 @@
OS << std::string(Indent, ' ') << "// Pattern complexity = "
<< getPatternSize(Pattern.getSrcPattern(), *this) + AddedComplexity
<< " cost = "
- << getResultPatternCost(Pattern.getDstPattern(), *this) << "\n";
+ << getResultPatternCost(Pattern.getDstPattern(), *this)
+ << " size = "
+ << getResultPatternSize(Pattern.getDstPattern(), *this) << "\n";
}
if (!FirstCodeLine.first) {
OS << std::string(Indent, ' ') << "{\n";
More information about the llvm-commits
mailing list