diff options
-rw-r--r-- | test/CodeGen/Alpha/add.ll | 3 | ||||
-rw-r--r-- | utils/TableGen/CodeGenDAGPatterns.cpp | 9 | ||||
-rw-r--r-- | utils/TableGen/CodeGenDAGPatterns.h | 7 | ||||
-rw-r--r-- | utils/TableGen/DAGISelEmitter.cpp | 10 | ||||
-rw-r--r-- | utils/TableGen/Record.h | 4 |
5 files changed, 23 insertions, 10 deletions
diff --git a/test/CodeGen/Alpha/add.ll b/test/CodeGen/Alpha/add.ll index 24a74188f8..cd883f64a6 100644 --- a/test/CodeGen/Alpha/add.ll +++ b/test/CodeGen/Alpha/add.ll @@ -4,9 +4,8 @@ ; RUN: grep { addl} %t.s | count 2 ; RUN: grep { addq} %t.s | count 2 ; RUN: grep { subl} %t.s | count 2 -; RUN: grep { subq} %t.s | count 1 +; RUN: grep { subq} %t.s | count 2 ; -; RUN: grep {lda \$0,-100(\$16)} %t.s | count 1 ; RUN: grep {s4addl} %t.s | count 2 ; RUN: grep {s8addl} %t.s | count 2 ; RUN: grep {s4addq} %t.s | count 2 diff --git a/utils/TableGen/CodeGenDAGPatterns.cpp b/utils/TableGen/CodeGenDAGPatterns.cpp index 8f4788f872..db90031709 100644 --- a/utils/TableGen/CodeGenDAGPatterns.cpp +++ b/utils/TableGen/CodeGenDAGPatterns.cpp @@ -2110,7 +2110,8 @@ void CodeGenDAGPatterns::ParseInstructions() { SrcPattern, TheInst.getResultPattern(), TheInst.getImpResults(), - Instr->getValueAsInt("AddedComplexity"))); + Instr->getValueAsInt("AddedComplexity"), + Instr->getID())); } } @@ -2320,7 +2321,8 @@ void CodeGenDAGPatterns::ParsePatterns() { PatternToMatch(Patterns[i]->getValueAsListInit("Predicates"), Pattern->getTree(0), Temp.getOnlyTree(), InstImpResults, - Patterns[i]->getValueAsInt("AddedComplexity"))); + Patterns[i]->getValueAsInt("AddedComplexity"), + Patterns[i]->getID())); } } @@ -2614,7 +2616,8 @@ void CodeGenDAGPatterns::GenerateVariants() { push_back(PatternToMatch(PatternsToMatch[i].getPredicates(), Variant, PatternsToMatch[i].getDstPattern(), PatternsToMatch[i].getDstRegs(), - PatternsToMatch[i].getAddedComplexity())); + PatternsToMatch[i].getAddedComplexity(), + Record::getNewUID())); } DEBUG(errs() << "\n"); diff --git a/utils/TableGen/CodeGenDAGPatterns.h b/utils/TableGen/CodeGenDAGPatterns.h index 60898bc04c..37d633ecc2 100644 --- a/utils/TableGen/CodeGenDAGPatterns.h +++ b/utils/TableGen/CodeGenDAGPatterns.h @@ -476,15 +476,16 @@ public: PatternToMatch(ListInit *preds, TreePatternNode *src, TreePatternNode *dst, const std::vector<Record*> &dstregs, - unsigned complexity): - Predicates(preds), SrcPattern(src), DstPattern(dst), Dstregs(dstregs), - AddedComplexity(complexity) {} + unsigned complexity, unsigned uid) + : Predicates(preds), SrcPattern(src), DstPattern(dst), + Dstregs(dstregs), AddedComplexity(complexity), ID(uid) {} ListInit *Predicates; // Top level predicate conditions to match. TreePatternNode *SrcPattern; // Source pattern to match. TreePatternNode *DstPattern; // Resulting pattern. std::vector<Record*> Dstregs; // Physical register defs being matched. unsigned AddedComplexity; // Add to matching pattern complexity. + unsigned ID; // Unique ID for the record. ListInit *getPredicates() const { return Predicates; } TreePatternNode *getSrcPattern() const { return SrcPattern; } diff --git a/utils/TableGen/DAGISelEmitter.cpp b/utils/TableGen/DAGISelEmitter.cpp index 8816c9c0e7..03a12cd13d 100644 --- a/utils/TableGen/DAGISelEmitter.cpp +++ b/utils/TableGen/DAGISelEmitter.cpp @@ -174,8 +174,14 @@ struct PatternSortingPredicate { if (LHSCost < RHSCost) return true; if (LHSCost > RHSCost) return false; - return getResultPatternSize(LHS->getDstPattern(), CGP) < - getResultPatternSize(RHS->getDstPattern(), CGP); + unsigned LHSPatSize = getResultPatternSize(LHS->getDstPattern(), CGP); + unsigned RHSPatSize = getResultPatternSize(RHS->getDstPattern(), CGP); + if (LHSPatSize < RHSPatSize) return true; + if (LHSPatSize > RHSPatSize) return false; + + // Sort based on the UID of the pattern, giving us a deterministic ordering. + assert(LHS->ID != RHS->ID); + return LHS->ID < RHS->ID; } }; } diff --git a/utils/TableGen/Record.h b/utils/TableGen/Record.h index 45f3072ff0..90096e98e2 100644 --- a/utils/TableGen/Record.h +++ b/utils/TableGen/Record.h @@ -1225,6 +1225,10 @@ public: ID(LastID++), Name(N), Loc(loc) {} ~Record() {} + + static unsigned getNewUID() { return LastID++; } + + unsigned getID() const { return ID; } const std::string &getName() const { return Name; } |