[llvm] r295661 - [globalisel] Separate the SelectionDAG importer from the emitter. NFC
Daniel Sanders via llvm-commits
llvm-commits at lists.llvm.org
Mon Feb 20 06:31:27 PST 2017
Author: dsanders
Date: Mon Feb 20 08:31:27 2017
New Revision: 295661
URL: http://llvm.org/viewvc/llvm-project?rev=295661&view=rev
Log:
[globalisel] Separate the SelectionDAG importer from the emitter. NFC
Summary:
In the near future the rules will be sorted between these two steps to
ensure that more important rules are not prevented by less important ones.
Reviewers: t.p.northover, ab, rovka, qcolombet, aditya_nandakumar
Reviewed By: ab
Subscribers: dberris, kristof.beyls, llvm-commits
Differential Revision: https://reviews.llvm.org/D29709
Modified:
llvm/trunk/utils/TableGen/GlobalISelEmitter.cpp
Modified: llvm/trunk/utils/TableGen/GlobalISelEmitter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/GlobalISelEmitter.cpp?rev=295661&r1=295660&r2=295661&view=diff
==============================================================================
--- llvm/trunk/utils/TableGen/GlobalISelEmitter.cpp (original)
+++ llvm/trunk/utils/TableGen/GlobalISelEmitter.cpp Mon Feb 20 08:31:27 2017
@@ -45,7 +45,8 @@ using namespace llvm;
#define DEBUG_TYPE "gisel-emitter"
STATISTIC(NumPatternTotal, "Total number of patterns");
-STATISTIC(NumPatternSkipped, "Number of patterns skipped");
+STATISTIC(NumPatternImported, "Number of patterns imported from SelectionDAG");
+STATISTIC(NumPatternImportsSkipped, "Number of SelectionDAG imports skipped");
STATISTIC(NumPatternEmitted, "Number of patterns emitted");
static cl::opt<bool> WarnOnSkippedPatterns(
@@ -55,7 +56,6 @@ static cl::opt<bool> WarnOnSkippedPatter
cl::init(false));
namespace {
-class RuleMatcher;
//===- Helper functions ---------------------------------------------------===//
@@ -322,7 +322,7 @@ public:
return *static_cast<Kind *>(Actions.back().get());
}
- void emit(raw_ostream &OS) {
+ void emit(raw_ostream &OS) const {
if (Matchers.empty())
llvm_unreachable("Unexpected empty matcher!");
@@ -516,6 +516,7 @@ Expected<RuleMatcher> GlobalISelEmitter:
}
// We're done with this pattern! It's eligible for GISel emission; return it.
+ ++NumPatternImported;
return std::move(M);
}
@@ -530,6 +531,7 @@ void GlobalISelEmitter::run(raw_ostream
"(MachineInstr &I) const {\n const MachineRegisterInfo &MRI = "
"I.getParent()->getParent()->getRegInfo();\n\n";
+ std::vector<RuleMatcher> Rules;
// Look through the SelectionDAG patterns we found, possibly emitting some.
for (const PatternToMatch &Pat : CGP.ptms()) {
++NumPatternTotal;
@@ -544,11 +546,15 @@ void GlobalISelEmitter::run(raw_ostream
} else {
consumeError(std::move(Err));
}
- ++NumPatternSkipped;
+ ++NumPatternImportsSkipped;
continue;
}
- MatcherOrErr->emit(OS);
+ Rules.push_back(std::move(MatcherOrErr.get()));
+ }
+
+ for (const auto &Rule : Rules) {
+ Rule.emit(OS);
++NumPatternEmitted;
}
More information about the llvm-commits
mailing list