unsigned CurrentSize = 0;
/// A unique identifier for a MatchTable label.
unsigned CurrentLabelID = 0;
+ /// Determines if the table should be instrumented for rule coverage tracking.
+ bool IsWithCoverage;
public:
static MatchTableRecord LineBreak;
MatchTableRecord::MTRF_CommaFollows);
}
- static MatchTable buildTable(ArrayRef<Matcher *> Rules);
+ static MatchTable buildTable(ArrayRef<Matcher *> Rules, bool WithCoverage);
- MatchTable(unsigned ID = 0) : ID(ID) {}
+ MatchTable(bool WithCoverage, unsigned ID = 0)
+ : ID(ID), IsWithCoverage(WithCoverage) {}
+
+ bool isWithCoverage() const { return IsWithCoverage; }
void push_back(const MatchTableRecord &Value) {
if (Value.Flags & MatchTableRecord::MTRF_Label)
virtual std::unique_ptr<PredicateMatcher> forgetFirstCondition() = 0;
};
-MatchTable MatchTable::buildTable(ArrayRef<Matcher *> Rules) {
- MatchTable Table;
+MatchTable MatchTable::buildTable(ArrayRef<Matcher *> Rules,
+ bool WithCoverage) {
+ MatchTable Table(WithCoverage);
for (Matcher *Rule : Rules)
Rule->emit(Table);
for (const auto &MA : Actions)
MA->emitActionOpcodes(Table, *this);
- if (GenerateCoverage)
+ if (Table.isWithCoverage())
Table << MatchTable::Opcode("GIR_Coverage") << MatchTable::IntValue(RuleID)
<< MatchTable::LineBreak;
ArrayRef<Matcher *> Rules,
std::vector<std::unique_ptr<GroupMatcher>> &StorageGroupMatcher);
- MatchTable buildMatchTable(MutableArrayRef<RuleMatcher> Rules, bool Optimize);
+ MatchTable buildMatchTable(MutableArrayRef<RuleMatcher> Rules, bool Optimize,
+ bool WithCoverage);
};
void GlobalISelEmitter::gatherNodeEquivs() {
MatchTable
GlobalISelEmitter::buildMatchTable(MutableArrayRef<RuleMatcher> Rules,
- bool Optimize) {
+ bool Optimize, bool WithCoverage) {
std::vector<Matcher *> InputRules;
for (Matcher &Rule : Rules)
InputRules.push_back(&Rule);
if (!Optimize)
- return MatchTable::buildTable(InputRules);
+ return MatchTable::buildTable(InputRules, WithCoverage);
std::vector<std::unique_ptr<GroupMatcher>> StorageGroupMatcher;
std::vector<Matcher *> OptRules =
optimizeRules(InputRules, StorageGroupMatcher);
- return MatchTable::buildTable(OptRules);
+ return MatchTable::buildTable(OptRules, WithCoverage);
}
void GlobalISelEmitter::run(raw_ostream &OS) {
<< " return false;\n"
<< "}\n\n";
- const MatchTable Table = buildMatchTable(Rules, OptimizeMatchTable);
+ const MatchTable Table =
+ buildMatchTable(Rules, OptimizeMatchTable, GenerateCoverage);
OS << "const int64_t *" << Target.getName()
<< "InstructionSelector::getMatchTable() const {\n";
Table.emitDeclaration(OS);