[llvm] [SelectionDAG] Add space-optimized forms of OPC_CheckPredicate (PR #73488)
Wang Pengcheng via llvm-commits
llvm-commits at lists.llvm.org
Mon Jan 8 00:04:01 PST 2024
https://github.com/wangpc-pp updated https://github.com/llvm/llvm-project/pull/73488
>From 352fd1fb9d90ca0551c2083f9ee8cb31ae8756cf Mon Sep 17 00:00:00 2001
From: wangpc <wangpengcheng.pp at bytedance.com>
Date: Fri, 24 Nov 2023 13:24:12 +0800
Subject: [PATCH 1/2] [SelectionDAG] Add space-optimized forms of
OPC_CheckComplexPat
We record the usage of each `ComplexPat` and sort the `ComplexPat`s
by usage.
For the top 8 `ComplexPat`s, we will emit a `OPC_CheckComplexPatN`
to save one byte.
Overall this reduces the llc binary size with all in-tree targets by
about 89K.
---
llvm/include/llvm/CodeGen/SelectionDAGISel.h | 8 +++
.../CodeGen/SelectionDAG/SelectionDAGISel.cpp | 14 ++++-
llvm/test/TableGen/dag-isel-complexpattern.td | 2 +-
llvm/utils/TableGen/DAGISelMatcherEmitter.cpp | 55 ++++++++++++++-----
4 files changed, 63 insertions(+), 16 deletions(-)
diff --git a/llvm/include/llvm/CodeGen/SelectionDAGISel.h b/llvm/include/llvm/CodeGen/SelectionDAGISel.h
index 40046e0a8dec9a..99ce658e7eb711 100644
--- a/llvm/include/llvm/CodeGen/SelectionDAGISel.h
+++ b/llvm/include/llvm/CodeGen/SelectionDAGISel.h
@@ -207,6 +207,14 @@ class SelectionDAGISel : public MachineFunctionPass {
OPC_CheckChild2CondCode,
OPC_CheckValueType,
OPC_CheckComplexPat,
+ OPC_CheckComplexPat0,
+ OPC_CheckComplexPat1,
+ OPC_CheckComplexPat2,
+ OPC_CheckComplexPat3,
+ OPC_CheckComplexPat4,
+ OPC_CheckComplexPat5,
+ OPC_CheckComplexPat6,
+ OPC_CheckComplexPat7,
OPC_CheckAndImm,
OPC_CheckOrImm,
OPC_CheckImmAllOnesV,
diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
index 99bb3d875d4fa5..0c708b3da58898 100644
--- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
@@ -3361,8 +3361,18 @@ void SelectionDAGISel::SelectCodeCommon(SDNode *NodeToMatch,
break;
continue;
}
- case OPC_CheckComplexPat: {
- unsigned CPNum = MatcherTable[MatcherIndex++];
+ case OPC_CheckComplexPat:
+ case OPC_CheckComplexPat0:
+ case OPC_CheckComplexPat1:
+ case OPC_CheckComplexPat2:
+ case OPC_CheckComplexPat3:
+ case OPC_CheckComplexPat4:
+ case OPC_CheckComplexPat5:
+ case OPC_CheckComplexPat6:
+ case OPC_CheckComplexPat7: {
+ unsigned CPNum = Opcode == OPC_CheckComplexPat
+ ? MatcherTable[MatcherIndex++]
+ : Opcode - OPC_CheckComplexPat0;
unsigned RecNo = MatcherTable[MatcherIndex++];
assert(RecNo < RecordedNodes.size() && "Invalid CheckComplexPat");
diff --git a/llvm/test/TableGen/dag-isel-complexpattern.td b/llvm/test/TableGen/dag-isel-complexpattern.td
index 3d74e4e46dc41c..b8f517a1fc2890 100644
--- a/llvm/test/TableGen/dag-isel-complexpattern.td
+++ b/llvm/test/TableGen/dag-isel-complexpattern.td
@@ -22,7 +22,7 @@ def CP32 : ComplexPattern<i32, 0, "SelectCP32">;
def INSTR : Instruction {
// CHECK-LABEL: OPC_CheckOpcode, TARGET_VAL(ISD::STORE)
// CHECK: OPC_CheckTypeI32
-// CHECK: OPC_CheckComplexPat, /*CP*/0, /*#*/1, // SelectCP32:$
+// CHECK: OPC_CheckComplexPat0, /*#*/1, // SelectCP32:$
// CHECK: Src: (st (add:{ *:[i32] } (CP32:{ *:[i32] }), (CP32:{ *:[i32] })), i64:{ *:[i64] }:$addr)
let OutOperandList = (outs);
let InOperandList = (ins GPR64:$addr);
diff --git a/llvm/utils/TableGen/DAGISelMatcherEmitter.cpp b/llvm/utils/TableGen/DAGISelMatcherEmitter.cpp
index 6fd5698e7372e4..e460a2804c6649 100644
--- a/llvm/utils/TableGen/DAGISelMatcherEmitter.cpp
+++ b/llvm/utils/TableGen/DAGISelMatcherEmitter.cpp
@@ -63,7 +63,6 @@ class MatcherTableEmitter {
StringMap<unsigned> PatternPredicateMap;
std::vector<std::string> PatternPredicates;
- DenseMap<const ComplexPattern*, unsigned> ComplexPatternMap;
std::vector<const ComplexPattern*> ComplexPatterns;
@@ -84,8 +83,38 @@ class MatcherTableEmitter {
}
public:
- MatcherTableEmitter(const CodeGenDAGPatterns &cgp)
- : CGP(cgp), OpcodeCounts(Matcher::HighestKind + 1, 0) {}
+ MatcherTableEmitter(const Matcher *TheMatcher, const CodeGenDAGPatterns &cgp)
+ : CGP(cgp), OpcodeCounts(Matcher::HighestKind + 1, 0) {
+ // Record the usage of ComplexPattern.
+ DenseMap<const ComplexPattern *, unsigned> ComplexPatternUsage;
+
+ // Iterate the whole MatcherTable once and do some statistics.
+ std::function<void(const Matcher *)> Statistic = [&](const Matcher *N) {
+ while (N) {
+ if (auto *SM = dyn_cast<ScopeMatcher>(N))
+ for (unsigned I = 0; I < SM->getNumChildren(); I++)
+ Statistic(SM->getChild(I));
+ else if (auto *SOM = dyn_cast<SwitchOpcodeMatcher>(N))
+ for (unsigned I = 0; I < SOM->getNumCases(); I++)
+ Statistic(SOM->getCaseMatcher(I));
+ else if (auto *STM = dyn_cast<SwitchTypeMatcher>(N))
+ for (unsigned I = 0; I < STM->getNumCases(); I++)
+ Statistic(STM->getCaseMatcher(I));
+ else if (auto *CPM = dyn_cast<CheckComplexPatMatcher>(N))
+ ++ComplexPatternUsage[&CPM->getPattern()];
+ N = N->getNext();
+ }
+ };
+ Statistic(TheMatcher);
+
+ // Sort ComplexPatterns by usage.
+ std::vector<std::pair<const ComplexPattern *, unsigned>> ComplexPatternList(
+ ComplexPatternUsage.begin(), ComplexPatternUsage.end());
+ sort(ComplexPatternList,
+ [](const auto &A, const auto &B) { return A.second > B.second; });
+ for (const auto &ComplexPattern : ComplexPatternList)
+ ComplexPatterns.push_back(ComplexPattern.first);
+ }
unsigned EmitMatcherList(const Matcher *N, const unsigned Indent,
unsigned StartIdx, raw_ostream &OS);
@@ -146,12 +175,7 @@ class MatcherTableEmitter {
return Entry-1;
}
unsigned getComplexPat(const ComplexPattern &P) {
- unsigned &Entry = ComplexPatternMap[&P];
- if (Entry == 0) {
- ComplexPatterns.push_back(&P);
- Entry = ComplexPatterns.size();
- }
- return Entry-1;
+ return llvm::find(ComplexPatterns, &P) - ComplexPatterns.begin();
}
unsigned getNodeXFormID(Record *Rec) {
@@ -652,8 +676,13 @@ EmitMatcher(const Matcher *N, const unsigned Indent, unsigned CurrentIdx,
case Matcher::CheckComplexPat: {
const CheckComplexPatMatcher *CCPM = cast<CheckComplexPatMatcher>(N);
const ComplexPattern &Pattern = CCPM->getPattern();
- OS << "OPC_CheckComplexPat, /*CP*/" << getComplexPat(Pattern) << ", /*#*/"
- << CCPM->getMatchNumber() << ',';
+ unsigned PatternNo = getComplexPat(Pattern);
+ if (PatternNo < 8)
+ OS << "OPC_CheckComplexPat" << PatternNo << ", /*#*/"
+ << CCPM->getMatchNumber() << ',';
+ else
+ OS << "OPC_CheckComplexPat, /*CP*/" << PatternNo << ", /*#*/"
+ << CCPM->getMatchNumber() << ',';
if (!OmitComments) {
OS << " // " << Pattern.getSelectFunc();
@@ -665,7 +694,7 @@ EmitMatcher(const Matcher *N, const unsigned Indent, unsigned CurrentIdx,
OS << " + chain result";
}
OS << '\n';
- return 3;
+ return PatternNo < 8 ? 2 : 3;
}
case Matcher::CheckAndImm: {
@@ -1267,7 +1296,7 @@ void llvm::EmitMatcherTable(Matcher *TheMatcher,
OS << "#endif\n\n";
BeginEmitFunction(OS, "void", "SelectCode(SDNode *N)", false/*AddOverride*/);
- MatcherTableEmitter MatcherEmitter(CGP);
+ MatcherTableEmitter MatcherEmitter(TheMatcher, CGP);
// First we size all the children of the three kinds of matchers that have
// them. This is done by sharing the code in EmitMatcher(). but we don't
>From 1f4f5ed90d9be2fff0e2a602bfb318e95eff173d Mon Sep 17 00:00:00 2001
From: wangpc <wangpengcheng.pp at bytedance.com>
Date: Mon, 27 Nov 2023 16:28:36 +0800
Subject: [PATCH 2/2] [SelectionDAG] Add space-optimized forms of
OPC_CheckPredicate
We record the usage of each `Predicate` and sort them by usage.
For the top 8 `Predicate`s, we will emit a `PC_CheckPredicateN` to
save one byte.
Overall this reduces the llc binary size with all in-tree targets by
about 61K.
This PR is stacked on #73310.
---
llvm/include/llvm/CodeGen/SelectionDAGISel.h | 8 ++
.../CodeGen/SelectionDAG/SelectionDAGISel.cpp | 30 +++++-
llvm/test/TableGen/address-space-patfrags.td | 4 +-
llvm/test/TableGen/predicate-patfags.td | 4 +-
llvm/utils/TableGen/DAGISelMatcherEmitter.cpp | 93 ++++++++++++-------
5 files changed, 94 insertions(+), 45 deletions(-)
diff --git a/llvm/include/llvm/CodeGen/SelectionDAGISel.h b/llvm/include/llvm/CodeGen/SelectionDAGISel.h
index 99ce658e7eb711..572d54291e7780 100644
--- a/llvm/include/llvm/CodeGen/SelectionDAGISel.h
+++ b/llvm/include/llvm/CodeGen/SelectionDAGISel.h
@@ -161,6 +161,14 @@ class SelectionDAGISel : public MachineFunctionPass {
OPC_CheckPatternPredicate,
OPC_CheckPatternPredicate2,
OPC_CheckPredicate,
+ OPC_CheckPredicate0,
+ OPC_CheckPredicate1,
+ OPC_CheckPredicate2,
+ OPC_CheckPredicate3,
+ OPC_CheckPredicate4,
+ OPC_CheckPredicate5,
+ OPC_CheckPredicate6,
+ OPC_CheckPredicate7,
OPC_CheckPredicateWithOperands,
OPC_CheckOpcode,
OPC_SwitchOpcode,
diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
index 0c708b3da58898..3ff6d058fb37ee 100644
--- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
@@ -2710,9 +2710,13 @@ CheckPatternPredicate(const unsigned char *MatcherTable, unsigned &MatcherIndex,
/// CheckNodePredicate - Implements OP_CheckNodePredicate.
LLVM_ATTRIBUTE_ALWAYS_INLINE static bool
-CheckNodePredicate(const unsigned char *MatcherTable, unsigned &MatcherIndex,
- const SelectionDAGISel &SDISel, SDNode *N) {
- return SDISel.CheckNodePredicate(N, MatcherTable[MatcherIndex++]);
+CheckNodePredicate(unsigned Opcode, const unsigned char *MatcherTable,
+ unsigned &MatcherIndex, const SelectionDAGISel &SDISel,
+ SDNode *N) {
+ unsigned PredNo = Opcode == SelectionDAGISel::OPC_CheckPredicate
+ ? MatcherTable[MatcherIndex++]
+ : Opcode - SelectionDAGISel::OPC_CheckPredicate0;
+ return SDISel.CheckNodePredicate(N, PredNo);
}
LLVM_ATTRIBUTE_ALWAYS_INLINE static bool
@@ -2860,7 +2864,15 @@ static unsigned IsPredicateKnownToFail(const unsigned char *Table,
Table[Index - 1] == SelectionDAGISel::OPC_CheckPatternPredicate2);
return Index;
case SelectionDAGISel::OPC_CheckPredicate:
- Result = !::CheckNodePredicate(Table, Index, SDISel, N.getNode());
+ case SelectionDAGISel::OPC_CheckPredicate0:
+ case SelectionDAGISel::OPC_CheckPredicate1:
+ case SelectionDAGISel::OPC_CheckPredicate2:
+ case SelectionDAGISel::OPC_CheckPredicate3:
+ case SelectionDAGISel::OPC_CheckPredicate4:
+ case SelectionDAGISel::OPC_CheckPredicate5:
+ case SelectionDAGISel::OPC_CheckPredicate6:
+ case SelectionDAGISel::OPC_CheckPredicate7:
+ Result = !::CheckNodePredicate(Opcode, Table, Index, SDISel, N.getNode());
return Index;
case SelectionDAGISel::OPC_CheckOpcode:
Result = !::CheckOpcode(Table, Index, N.getNode());
@@ -3344,8 +3356,16 @@ void SelectionDAGISel::SelectCodeCommon(SDNode *NodeToMatch,
Opcode == OPC_CheckPatternPredicate2))
break;
continue;
+ case SelectionDAGISel::OPC_CheckPredicate0:
+ case SelectionDAGISel::OPC_CheckPredicate1:
+ case SelectionDAGISel::OPC_CheckPredicate2:
+ case SelectionDAGISel::OPC_CheckPredicate3:
+ case SelectionDAGISel::OPC_CheckPredicate4:
+ case SelectionDAGISel::OPC_CheckPredicate5:
+ case SelectionDAGISel::OPC_CheckPredicate6:
+ case SelectionDAGISel::OPC_CheckPredicate7:
case OPC_CheckPredicate:
- if (!::CheckNodePredicate(MatcherTable, MatcherIndex, *this,
+ if (!::CheckNodePredicate(Opcode, MatcherTable, MatcherIndex, *this,
N.getNode()))
break;
continue;
diff --git a/llvm/test/TableGen/address-space-patfrags.td b/llvm/test/TableGen/address-space-patfrags.td
index 27b174b4633cd8..4aec6ea7e0eae8 100644
--- a/llvm/test/TableGen/address-space-patfrags.td
+++ b/llvm/test/TableGen/address-space-patfrags.td
@@ -46,7 +46,7 @@ def inst_d : Instruction {
let InOperandList = (ins GPR32:$src0, GPR32:$src1);
}
-// SDAG: case 2: {
+// SDAG: case 1: {
// SDAG-NEXT: // Predicate_pat_frag_b
// SDAG-NEXT: // Predicate_truncstorei16_addrspace
// SDAG-NEXT: SDNode *N = Node;
@@ -69,7 +69,7 @@ def : Pat <
>;
-// SDAG: case 3: {
+// SDAG: case 6: {
// SDAG: // Predicate_pat_frag_a
// SDAG-NEXT: SDNode *N = Node;
// SDAG-NEXT: (void)N;
diff --git a/llvm/test/TableGen/predicate-patfags.td b/llvm/test/TableGen/predicate-patfags.td
index 0912b05127ef81..2cf29769dc13a7 100644
--- a/llvm/test/TableGen/predicate-patfags.td
+++ b/llvm/test/TableGen/predicate-patfags.td
@@ -39,10 +39,10 @@ def TGTmul24_oneuse : PatFrag<
}
// SDAG: OPC_CheckOpcode, TARGET_VAL(ISD::INTRINSIC_W_CHAIN),
-// SDAG: OPC_CheckPredicate, 0, // Predicate_TGTmul24_oneuse
+// SDAG: OPC_CheckPredicate0, // Predicate_TGTmul24_oneuse
// SDAG: OPC_CheckOpcode, TARGET_VAL(TargetISD::MUL24),
-// SDAG: OPC_CheckPredicate, 0, // Predicate_TGTmul24_oneuse
+// SDAG: OPC_CheckPredicate0, // Predicate_TGTmul24_oneuse
// GISEL: GIM_CheckOpcode, /*MI*/1, GIMT_Encode2(TargetOpcode::G_INTRINSIC_W_SIDE_EFFECTS),
// GISEL: GIM_CheckIntrinsicID, /*MI*/1, /*Op*/1, GIMT_Encode2(Intrinsic::tgt_mul24),
diff --git a/llvm/utils/TableGen/DAGISelMatcherEmitter.cpp b/llvm/utils/TableGen/DAGISelMatcherEmitter.cpp
index e460a2804c6649..fc1f452743ca32 100644
--- a/llvm/utils/TableGen/DAGISelMatcherEmitter.cpp
+++ b/llvm/utils/TableGen/DAGISelMatcherEmitter.cpp
@@ -52,9 +52,8 @@ class MatcherTableEmitter {
SmallVector<unsigned, Matcher::HighestKind+1> OpcodeCounts;
- DenseMap<TreePattern *, unsigned> NodePredicateMap;
- std::vector<TreePredicateFn> NodePredicates;
- std::vector<TreePredicateFn> NodePredicatesWithOperands;
+ std::vector<TreePattern *> NodePredicates;
+ std::vector<TreePattern *> NodePredicatesWithOperands;
// We de-duplicate the predicates by code string, and use this map to track
// all the patterns with "identical" predicates.
@@ -87,6 +86,8 @@ class MatcherTableEmitter {
: CGP(cgp), OpcodeCounts(Matcher::HighestKind + 1, 0) {
// Record the usage of ComplexPattern.
DenseMap<const ComplexPattern *, unsigned> ComplexPatternUsage;
+ // Record the usage of Predicate.
+ DenseMap<TreePattern *, unsigned> PredicateUsage;
// Iterate the whole MatcherTable once and do some statistics.
std::function<void(const Matcher *)> Statistic = [&](const Matcher *N) {
@@ -102,6 +103,8 @@ class MatcherTableEmitter {
Statistic(STM->getCaseMatcher(I));
else if (auto *CPM = dyn_cast<CheckComplexPatMatcher>(N))
++ComplexPatternUsage[&CPM->getPattern()];
+ else if (auto *PM = dyn_cast<CheckPredicateMatcher>(N))
+ ++PredicateUsage[PM->getPredicate().getOrigPatFragRecord()];
N = N->getNext();
}
};
@@ -114,6 +117,39 @@ class MatcherTableEmitter {
[](const auto &A, const auto &B) { return A.second > B.second; });
for (const auto &ComplexPattern : ComplexPatternList)
ComplexPatterns.push_back(ComplexPattern.first);
+
+ // Sort Predicates by usage.
+ // Merge predicates with same code.
+ for (const auto &Usage : PredicateUsage) {
+ TreePattern *TP = Usage.first;
+ TreePredicateFn Pred(TP);
+ NodePredicatesByCodeToRun[Pred.getCodeToRunOnSDNode()].push_back(TP);
+ }
+
+ std::vector<std::pair<TreePattern *, unsigned>> PredicateList;
+ // Sum the usage.
+ for (auto &Predicate : NodePredicatesByCodeToRun) {
+ TinyPtrVector<TreePattern *> &TPs = Predicate.second;
+ sort(TPs, [](const auto *A, const auto *B) {
+ return A->getRecord()->getName() < B->getRecord()->getName();
+ });
+ unsigned Uses = 0;
+ for (TreePattern *TP : TPs)
+ Uses += PredicateUsage.at(TP);
+
+ // We only add the first predicate here since they are with the same code.
+ PredicateList.push_back({TPs[0], Uses});
+ }
+
+ sort(PredicateList,
+ [](const auto &A, const auto &B) { return A.second > B.second; });
+ for (const auto &Predicate : PredicateList) {
+ TreePattern *TP = Predicate.first;
+ if (TreePredicateFn(TP).usesOperands())
+ NodePredicatesWithOperands.push_back(TP);
+ else
+ NodePredicates.push_back(TP);
+ }
}
unsigned EmitMatcherList(const Matcher *N, const unsigned Indent,
@@ -128,7 +164,7 @@ class MatcherTableEmitter {
void EmitPatternMatchTable(raw_ostream &OS);
private:
- void EmitNodePredicatesFunction(const std::vector<TreePredicateFn> &Preds,
+ void EmitNodePredicatesFunction(const std::vector<TreePattern *> &Preds,
StringRef Decl, raw_ostream &OS);
unsigned SizeMatcher(Matcher *N, raw_ostream &OS);
@@ -137,33 +173,13 @@ class MatcherTableEmitter {
raw_ostream &OS);
unsigned getNodePredicate(TreePredicateFn Pred) {
- TreePattern *TP = Pred.getOrigPatFragRecord();
- unsigned &Entry = NodePredicateMap[TP];
- if (Entry == 0) {
- TinyPtrVector<TreePattern *> &SameCodePreds =
- NodePredicatesByCodeToRun[Pred.getCodeToRunOnSDNode()];
- if (SameCodePreds.empty()) {
- // We've never seen a predicate with the same code: allocate an entry.
- if (Pred.usesOperands()) {
- NodePredicatesWithOperands.push_back(Pred);
- Entry = NodePredicatesWithOperands.size();
- } else {
- NodePredicates.push_back(Pred);
- Entry = NodePredicates.size();
- }
- } else {
- // We did see an identical predicate: re-use it.
- Entry = NodePredicateMap[SameCodePreds.front()];
- assert(Entry != 0);
- assert(TreePredicateFn(SameCodePreds.front()).usesOperands() ==
- Pred.usesOperands() &&
- "PatFrags with some code must have same usesOperands setting");
- }
- // In both cases, we've never seen this particular predicate before, so
- // mark it in the list of predicates sharing the same code.
- SameCodePreds.push_back(TP);
- }
- return Entry-1;
+ // We use the first predicate.
+ TreePattern *PredPat =
+ NodePredicatesByCodeToRun[Pred.getCodeToRunOnSDNode()][0];
+ return Pred.usesOperands()
+ ? llvm::find(NodePredicatesWithOperands, PredPat) -
+ NodePredicatesWithOperands.begin()
+ : llvm::find(NodePredicates, PredPat) - NodePredicates.begin();
}
unsigned getPatternPredicate(StringRef PredName) {
@@ -521,6 +537,7 @@ EmitMatcher(const Matcher *N, const unsigned Indent, unsigned CurrentIdx,
case Matcher::CheckPredicate: {
TreePredicateFn Pred = cast<CheckPredicateMatcher>(N)->getPredicate();
unsigned OperandBytes = 0;
+ unsigned PredNo = getNodePredicate(Pred);
if (Pred.usesOperands()) {
unsigned NumOps = cast<CheckPredicateMatcher>(N)->getNumOperands();
@@ -529,10 +546,15 @@ EmitMatcher(const Matcher *N, const unsigned Indent, unsigned CurrentIdx,
OS << cast<CheckPredicateMatcher>(N)->getOperandNo(i) << ", ";
OperandBytes = 1 + NumOps;
} else {
- OS << "OPC_CheckPredicate, ";
+ if (PredNo < 8) {
+ OperandBytes = -1;
+ OS << "OPC_CheckPredicate" << PredNo << ", ";
+ } else
+ OS << "OPC_CheckPredicate, ";
}
- OS << getNodePredicate(Pred) << ',';
+ if (PredNo >= 8 || Pred.usesOperands())
+ OS << PredNo << ',';
if (!OmitComments)
OS << " // " << Pred.getFnName();
OS << '\n';
@@ -1021,8 +1043,7 @@ EmitMatcherList(const Matcher *N, const unsigned Indent, unsigned CurrentIdx,
}
void MatcherTableEmitter::EmitNodePredicatesFunction(
- const std::vector<TreePredicateFn> &Preds, StringRef Decl,
- raw_ostream &OS) {
+ const std::vector<TreePattern *> &Preds, StringRef Decl, raw_ostream &OS) {
if (Preds.empty())
return;
@@ -1032,7 +1053,7 @@ void MatcherTableEmitter::EmitNodePredicatesFunction(
OS << " default: llvm_unreachable(\"Invalid predicate in table?\");\n";
for (unsigned i = 0, e = Preds.size(); i != e; ++i) {
// Emit the predicate code corresponding to this pattern.
- const TreePredicateFn PredFn = Preds[i];
+ TreePredicateFn PredFn(Preds[i]);
assert(!PredFn.isAlwaysTrue() && "No code in this predicate");
std::string PredFnCodeStr = PredFn.getCodeToRunOnSDNode();
More information about the llvm-commits
mailing list