forked from OSchip/llvm-project
Reverting 332999 to get it a proper commit message
llvm-svn: 333000
This commit is contained in:
parent
a7b5d45f9b
commit
dad5d6f347
|
@ -851,6 +851,7 @@ public:
|
|||
|
||||
std::unique_ptr<PredicateMatcher> popFirstCondition() override;
|
||||
const PredicateMatcher &getFirstCondition() const override;
|
||||
LLTCodeGen getFirstConditionAsRootType();
|
||||
bool hasFirstCondition() const override;
|
||||
unsigned getNumOperands() const;
|
||||
StringRef getOpcode() const;
|
||||
|
@ -1921,6 +1922,16 @@ unsigned RuleMatcher::getNumOperands() const {
|
|||
return Matchers.front()->getNumOperands();
|
||||
}
|
||||
|
||||
LLTCodeGen RuleMatcher::getFirstConditionAsRootType() {
|
||||
InstructionMatcher &InsnMatcher = *Matchers.front();
|
||||
if (!InsnMatcher.predicates_empty())
|
||||
if (const auto *TM =
|
||||
dyn_cast<LLTOperandMatcher>(&**InsnMatcher.predicates_begin()))
|
||||
if (TM->getInsnVarID() == 0 && TM->getOpIdx() == 0)
|
||||
return TM->getTy();
|
||||
return {};
|
||||
}
|
||||
|
||||
/// Generates code to check that the operand is a register defined by an
|
||||
/// instruction that matches the given instruction matcher.
|
||||
///
|
||||
|
@ -4016,25 +4027,6 @@ GlobalISelEmitter::buildMatchTable(MutableArrayRef<RuleMatcher> Rules,
|
|||
if (!Optimize)
|
||||
return MatchTable::buildTable(InputRules, WithCoverage);
|
||||
|
||||
unsigned CurrentOrdering = 0;
|
||||
StringMap<unsigned> OpcodeOrder;
|
||||
for (RuleMatcher &Rule : Rules) {
|
||||
const StringRef Opcode = Rule.getOpcode();
|
||||
assert(!Opcode.empty() && "Didn't expect an undefined opcode");
|
||||
if (OpcodeOrder.count(Opcode) == 0)
|
||||
OpcodeOrder[Opcode] = CurrentOrdering++;
|
||||
}
|
||||
|
||||
std::stable_sort(InputRules.begin(), InputRules.end(),
|
||||
[&OpcodeOrder](const Matcher *A, const Matcher *B) {
|
||||
auto *L = static_cast<const RuleMatcher *>(A);
|
||||
auto *R = static_cast<const RuleMatcher *>(B);
|
||||
return std::make_tuple(OpcodeOrder[L->getOpcode()],
|
||||
L->getNumOperands()) <
|
||||
std::make_tuple(OpcodeOrder[R->getOpcode()],
|
||||
R->getNumOperands());
|
||||
});
|
||||
|
||||
for (Matcher *Rule : InputRules)
|
||||
Rule->optimize();
|
||||
|
||||
|
|
Loading…
Reference in New Issue