summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2005-09-26 21:59:35 +0000
committerChris Lattner <sabre@nondot.org>2005-09-26 21:59:35 +0000
commitc9153266c61f8b4dc2eec2b66be3bcc30c966796 (patch)
tree7f3d6089c75699e81865bed02201056582840a3f
parent5f2443c8a3aa4f434778956d3a5607f4c47e4271 (diff)
downloadbcm5719-llvm-c9153266c61f8b4dc2eec2b66be3bcc30c966796.tar.gz
bcm5719-llvm-c9153266c61f8b4dc2eec2b66be3bcc30c966796.zip
Emit the switch stmt cases in alphabetical order instead of pointer order,
which is not stable. llvm-svn: 23456
-rw-r--r--llvm/utils/TableGen/DAGISelEmitter.cpp23
1 files changed, 19 insertions, 4 deletions
diff --git a/llvm/utils/TableGen/DAGISelEmitter.cpp b/llvm/utils/TableGen/DAGISelEmitter.cpp
index 77067806f2d..bd439093c17 100644
--- a/llvm/utils/TableGen/DAGISelEmitter.cpp
+++ b/llvm/utils/TableGen/DAGISelEmitter.cpp
@@ -1200,6 +1200,20 @@ struct PatternSortingPredicate {
}
};
+
+namespace {
+ /// CompareByRecordName - An ordering predicate that implements less-than by
+ /// comparing the names records.
+ struct CompareByRecordName {
+ bool operator()(const Record *LHS, const Record *RHS) const {
+ // Sort by name first.
+ if (LHS->getName() < RHS->getName()) return true;
+ // If both names are equal, sort by pointer.
+ return LHS->getName() == RHS->getName() && LHS < RHS;
+ }
+ };
+}
+
void DAGISelEmitter::EmitInstructionSelector(std::ostream &OS) {
// Emit boilerplate.
OS << "// The main instruction selector code.\n"
@@ -1220,15 +1234,16 @@ void DAGISelEmitter::EmitInstructionSelector(std::ostream &OS) {
<< " return Select(N.getOperand(0));\n";
// Group the patterns by their top-level opcodes.
- std::map<Record*, std::vector<PatternToMatch*> > PatternsByOpcode;
+ std::map<Record*, std::vector<PatternToMatch*>,
+ CompareByRecordName> PatternsByOpcode;
for (unsigned i = 0, e = PatternsToMatch.size(); i != e; ++i)
PatternsByOpcode[PatternsToMatch[i].first->getOperator()]
.push_back(&PatternsToMatch[i]);
// Loop over all of the case statements.
- for (std::map<Record*, std::vector<PatternToMatch*> >::iterator
- PBOI = PatternsByOpcode.begin(), E = PatternsByOpcode.end(); PBOI != E;
- ++PBOI) {
+ for (std::map<Record*, std::vector<PatternToMatch*>,
+ CompareByRecordName>::iterator PBOI = PatternsByOpcode.begin(),
+ E = PatternsByOpcode.end(); PBOI != E; ++PBOI) {
const SDNodeInfo &OpcodeInfo = getSDNodeInfo(PBOI->first);
std::vector<PatternToMatch*> &Patterns = PBOI->second;
OpenPOWER on IntegriCloud