summaryrefslogtreecommitdiffstats
path: root/llvm/utils/TableGen/GlobalISelEmitter.cpp
diff options
context:
space:
mode:
authorRoman Tereshin <rtereshin@apple.com>2018-05-22 16:53:42 +0000
committerRoman Tereshin <rtereshin@apple.com>2018-05-22 16:53:42 +0000
commitdad5d6f3474061e99f3f78085f1f55e4ca7f701e (patch)
tree4e9964813f8420a17a5ce93f2ab825336e5ddf2c /llvm/utils/TableGen/GlobalISelEmitter.cpp
parenta7b5d45f9b5a055ecb4747054dde3bbf29992ca2 (diff)
downloadbcm5719-llvm-dad5d6f3474061e99f3f78085f1f55e4ca7f701e.tar.gz
bcm5719-llvm-dad5d6f3474061e99f3f78085f1f55e4ca7f701e.zip
Reverting 332999 to get it a proper commit message
llvm-svn: 333000
Diffstat (limited to 'llvm/utils/TableGen/GlobalISelEmitter.cpp')
-rw-r--r--llvm/utils/TableGen/GlobalISelEmitter.cpp30
1 files changed, 11 insertions, 19 deletions
diff --git a/llvm/utils/TableGen/GlobalISelEmitter.cpp b/llvm/utils/TableGen/GlobalISelEmitter.cpp
index be08165a200..cdc9df7bf6b 100644
--- a/llvm/utils/TableGen/GlobalISelEmitter.cpp
+++ b/llvm/utils/TableGen/GlobalISelEmitter.cpp
@@ -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();
OpenPOWER on IntegriCloud