1/*===- TableGen'erated file -------------------------------------*- C++ -*-===*\
2|* *|
3|* MipsPostLegalizerCombinerImpl Combiner Match Table *|
4|* *|
5|* Automatically generated file, do not edit! *|
6|* *|
7\*===----------------------------------------------------------------------===*/
8
9#ifdef GET_GICOMBINER_DEPS
10
11#include "llvm/ADT/SparseBitVector.h"
12namespace llvm {
13
14extern cl::OptionCategory GICombinerOptionCategory;
15
16} // namespace llvm
17
18#endif // GET_GICOMBINER_DEPS
19
20#ifdef GET_GICOMBINER_TYPES
21
22struct MipsPostLegalizerCombinerImplRuleConfig {
23 SparseBitVector<> DisabledRules;
24
25 bool isRuleEnabled(unsigned RuleID) const;
26 bool parseCommandLineOption();
27 bool setRuleEnabled(StringRef RuleIdentifier);
28 bool setRuleDisabled(StringRef RuleIdentifier);
29};
30
31static std::optional<uint64_t> getRuleIdxForIdentifier(StringRef RuleIdentifier) {
32 uint64_t I;
33 // getAtInteger(...) returns false on success
34 bool Parsed = !RuleIdentifier.getAsInteger(0, I);
35 if (Parsed)
36 return I;
37
38#ifndef NDEBUG
39#endif // ifndef NDEBUG
40
41 return std::nullopt;
42}
43static std::optional<std::pair<uint64_t, uint64_t>> getRuleRangeForIdentifier(StringRef RuleIdentifier) {
44 std::pair<StringRef, StringRef> RangePair = RuleIdentifier.split('-');
45 if (!RangePair.second.empty()) {
46 const auto First = getRuleIdxForIdentifier(RangePair.first);
47 const auto Last = getRuleIdxForIdentifier(RangePair.second);
48 if (!First || !Last)
49 return std::nullopt;
50 if (First >= Last)
51 report_fatal_error("Beginning of range should be before end of range");
52 return {{*First, *Last + 1}};
53 }
54 if (RangePair.first == "*") {
55 return {{0, 0}};
56 }
57 const auto I = getRuleIdxForIdentifier(RangePair.first);
58 if (!I)
59 return std::nullopt;
60 return {{*I, *I + 1}};
61}
62
63bool MipsPostLegalizerCombinerImplRuleConfig::setRuleEnabled(StringRef RuleIdentifier) {
64 auto MaybeRange = getRuleRangeForIdentifier(RuleIdentifier);
65 if (!MaybeRange)
66 return false;
67 for (auto I = MaybeRange->first; I < MaybeRange->second; ++I)
68 DisabledRules.reset(I);
69 return true;
70}
71
72bool MipsPostLegalizerCombinerImplRuleConfig::setRuleDisabled(StringRef RuleIdentifier) {
73 auto MaybeRange = getRuleRangeForIdentifier(RuleIdentifier);
74 if (!MaybeRange)
75 return false;
76 for (auto I = MaybeRange->first; I < MaybeRange->second; ++I)
77 DisabledRules.set(I);
78 return true;
79}
80
81static std::vector<std::string> MipsPostLegalizerCombinerOption;
82static cl::list<std::string> MipsPostLegalizerCombinerDisableOption(
83 "mipspostlegalizercombiner-disable-rule",
84 cl::desc("Disable one or more combiner rules temporarily in the MipsPostLegalizerCombiner pass"),
85 cl::CommaSeparated,
86 cl::Hidden,
87 cl::cat(GICombinerOptionCategory),
88 cl::callback([](const std::string &Str) {
89 MipsPostLegalizerCombinerOption.push_back(Str);
90 }));
91static cl::list<std::string> MipsPostLegalizerCombinerOnlyEnableOption(
92 "mipspostlegalizercombiner-only-enable-rule",
93 cl::desc("Disable all rules in the MipsPostLegalizerCombiner pass then re-enable the specified ones"),
94 cl::Hidden,
95 cl::cat(GICombinerOptionCategory),
96 cl::callback([](const std::string &CommaSeparatedArg) {
97 StringRef Str = CommaSeparatedArg;
98 MipsPostLegalizerCombinerOption.push_back("*");
99 do {
100 auto X = Str.split(",");
101 MipsPostLegalizerCombinerOption.push_back(("!" + X.first).str());
102 Str = X.second;
103 } while (!Str.empty());
104 }));
105
106
107bool MipsPostLegalizerCombinerImplRuleConfig::isRuleEnabled(unsigned RuleID) const {
108 return !DisabledRules.test(RuleID);
109}
110bool MipsPostLegalizerCombinerImplRuleConfig::parseCommandLineOption() {
111 for (StringRef Identifier : MipsPostLegalizerCombinerOption) {
112 bool Enabled = Identifier.consume_front("!");
113 if (Enabled && !setRuleEnabled(Identifier))
114 return false;
115 if (!Enabled && !setRuleDisabled(Identifier))
116 return false;
117 }
118 return true;
119}
120
121
122#endif // GET_GICOMBINER_TYPES
123
124#ifdef GET_GICOMBINER_TYPES
125
126const unsigned MAX_SUBTARGET_PREDICATES = 0;
127using PredicateBitset = llvm::Bitset<MAX_SUBTARGET_PREDICATES>;
128
129#endif // GET_GICOMBINER_TYPES
130
131#ifdef GET_GICOMBINER_CLASS_MEMBERS
132
133 bool canMatchOpcode(unsigned Opc) const override;
134 uint32_t getRootFlagsToDrop() const override;
135
136#endif // GET_GICOMBINER_CLASS_MEMBERS
137
138#ifdef GET_GICOMBINER_CLASS_MEMBERS
139
140PredicateBitset AvailableModuleFeatures;
141mutable PredicateBitset AvailableFunctionFeatures;
142PredicateBitset getAvailableFeatures() const {
143 return AvailableModuleFeatures | AvailableFunctionFeatures;
144}
145PredicateBitset
146computeAvailableModuleFeatures(const MipsSubtarget *Subtarget) const;
147PredicateBitset
148computeAvailableFunctionFeatures(const MipsSubtarget *Subtarget,
149 const MachineFunction *MF) const;
150void setupGeneratedPerFunctionState(MachineFunction &MF) override;
151
152#endif // GET_GICOMBINER_CLASS_MEMBERS
153
154#ifdef GET_GICOMBINER_CLASS_MEMBERS
155
156 mutable MatcherState State;
157 typedef ComplexRendererFns(MipsPostLegalizerCombinerImpl::*ComplexMatcherMemFn)(MachineOperand &) const;
158 typedef void(MipsPostLegalizerCombinerImpl::*CustomRendererFn)(MachineInstrBuilder &, const MachineInstr &, int) const;
159 const ExecInfoTy<PredicateBitset, ComplexMatcherMemFn, CustomRendererFn> ExecInfo;
160 static MipsPostLegalizerCombinerImpl::ComplexMatcherMemFn ComplexPredicateFns[];
161 static MipsPostLegalizerCombinerImpl::CustomRendererFn CustomRenderers[];
162 bool testImmPredicate_I64(unsigned PredicateID, int64_t Imm) const override;
163 bool testImmPredicate_APInt(unsigned PredicateID, const APInt &Imm) const override;
164 bool testImmPredicate_APFloat(unsigned PredicateID, const APFloat &Imm) const override;
165 const uint8_t *getMatchTable() const override;
166 bool testMIPredicate_MI(unsigned PredicateID, const MachineInstr &MI, const MatcherState &State) const override;
167 bool testMOPredicate_MO(unsigned PredicateID, const MachineOperand &MO, const MatcherState &State) const override;
168 bool testSimplePredicate(unsigned PredicateID) const override;
169 bool runCustomAction(unsigned FnID, const MatcherState &State, NewMIVector &OutMIs) const override;
170
171#endif // GET_GICOMBINER_CLASS_MEMBERS
172
173#ifdef GET_GICOMBINER_IMPL
174
175// LLT Objects.
176enum {
177 GILLT_s1,
178};
179const static size_t NumTypeObjects = 1;
180const static LLT TypeObjects[] = {
181 LLT::scalar(1),
182};
183
184// Bits for subtarget features that participate in instruction matching.
185enum SubtargetFeatureBits : uint8_t {
186};
187
188PredicateBitset MipsPostLegalizerCombinerImpl::
189computeAvailableModuleFeatures(const MipsSubtarget *Subtarget) const {
190 PredicateBitset Features{};
191 return Features;
192}
193
194void MipsPostLegalizerCombinerImpl::setupGeneratedPerFunctionState(MachineFunction &MF) {
195 AvailableFunctionFeatures = computeAvailableFunctionFeatures((const MipsSubtarget *)&MF.getSubtarget(), &MF);
196}
197PredicateBitset MipsPostLegalizerCombinerImpl::
198computeAvailableFunctionFeatures(const MipsSubtarget *Subtarget, const MachineFunction *MF) const {
199 PredicateBitset Features{};
200 return Features;
201}
202
203// Feature bitsets.
204enum {
205 GIFBS_Invalid,
206};
207constexpr static PredicateBitset FeatureBitsets[] {
208 {}, // GIFBS_Invalid
209};
210
211// ComplexPattern predicates.
212enum {
213 GICP_Invalid,
214};
215// See constructor for table contents
216
217MipsPostLegalizerCombinerImpl::ComplexMatcherMemFn
218MipsPostLegalizerCombinerImpl::ComplexPredicateFns[] = {
219 nullptr, // GICP_Invalid
220};
221
222bool MipsPostLegalizerCombinerImpl::testMIPredicate_MI(unsigned PredicateID, const MachineInstr & MI, const MatcherState &State) const {
223 llvm_unreachable("Unknown predicate");
224 return false;
225}
226bool MipsPostLegalizerCombinerImpl::testMOPredicate_MO(unsigned PredicateID, const MachineOperand & MO, const MatcherState &State) const {
227 llvm_unreachable("Unknown predicate");
228 return false;
229}
230bool MipsPostLegalizerCombinerImpl::testImmPredicate_I64(unsigned PredicateID, int64_t Imm) const {
231 llvm_unreachable("Unknown predicate");
232 return false;
233}
234bool MipsPostLegalizerCombinerImpl::testImmPredicate_APFloat(unsigned PredicateID, const APFloat & Imm) const {
235 llvm_unreachable("Unknown predicate");
236 return false;
237}
238bool MipsPostLegalizerCombinerImpl::testImmPredicate_APInt(unsigned PredicateID, const APInt & Imm) const {
239 llvm_unreachable("Unknown predicate");
240 return false;
241}
242bool MipsPostLegalizerCombinerImpl::testSimplePredicate(unsigned Predicate) const {
243 return RuleConfig.isRuleEnabled(Predicate - GICXXPred_Invalid - 1);
244}
245// Custom renderers.
246enum {
247 GICR_Invalid,
248};
249MipsPostLegalizerCombinerImpl::CustomRendererFn
250MipsPostLegalizerCombinerImpl::CustomRenderers[] = {
251 nullptr, // GICR_Invalid
252};
253
254bool MipsPostLegalizerCombinerImpl::canMatchOpcode(unsigned Opc) const {
255 (void)Opc;
256 return false;
257}
258
259uint32_t MipsPostLegalizerCombinerImpl::getRootFlagsToDrop() const {
260 return MachineInstr::getPoisonGeneratingFlags();
261}
262
263bool MipsPostLegalizerCombinerImpl::tryCombineAll(MachineInstr &I) const {
264 const PredicateBitset AvailableFeatures = getAvailableFeatures();
265 State.MIs.clear();
266 State.MIs.push_back(&I);
267 if (executeMatchTable(*this, State, ExecInfo, B, getMatchTable(), Helper.getTII(), MRI, Helper.getTRI(), Helper.getRBI(), AvailableFeatures, /*CoverageInfo*/ nullptr)) {
268 return true;
269 }
270
271 return false;
272}
273
274bool MipsPostLegalizerCombinerImpl::runCustomAction(unsigned ApplyID, const MatcherState &State, NewMIVector &OutMIs) const {
275 Helper.getBuilder().setInstrAndDebugLoc(*State.MIs[0]);
276 llvm_unreachable("Unknown Apply Action");
277}
278#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
279#define GIMT_Encode2(Val) uint8_t(Val), uint8_t((Val) >> 8)
280#define GIMT_Encode4(Val) uint8_t(Val), uint8_t((Val) >> 8), uint8_t((Val) >> 16), uint8_t((Val) >> 24)
281#define GIMT_Encode8(Val) uint8_t(Val), uint8_t((Val) >> 8), uint8_t((Val) >> 16), uint8_t((Val) >> 24), uint8_t(uint64_t(Val) >> 32), uint8_t(uint64_t(Val) >> 40), uint8_t(uint64_t(Val) >> 48), uint8_t(uint64_t(Val) >> 56)
282#else
283#define GIMT_Encode2(Val) uint8_t((Val) >> 8), uint8_t(Val)
284#define GIMT_Encode4(Val) uint8_t((Val) >> 24), uint8_t((Val) >> 16), uint8_t((Val) >> 8), uint8_t(Val)
285#define GIMT_Encode8(Val) uint8_t(uint64_t(Val) >> 56), uint8_t(uint64_t(Val) >> 48), uint8_t(uint64_t(Val) >> 40), uint8_t(uint64_t(Val) >> 32), uint8_t((Val) >> 24), uint8_t((Val) >> 16), uint8_t((Val) >> 8), uint8_t(Val)
286#endif
287const uint8_t *MipsPostLegalizerCombinerImpl::getMatchTable() const {
288 constexpr static uint8_t MatchTable0[] = {
289 /* 0 */ GIM_Reject,
290 /* 1 */ }; // Size: 1 bytes
291 return MatchTable0;
292}
293#undef GIMT_Encode2
294#undef GIMT_Encode4
295#undef GIMT_Encode8
296
297
298#endif // GET_GICOMBINER_IMPL
299
300#ifdef GET_GICOMBINER_CONSTRUCTOR_INITS
301
302AvailableModuleFeatures(computeAvailableModuleFeatures(&STI)),
303AvailableFunctionFeatures()
304
305#endif // GET_GICOMBINER_CONSTRUCTOR_INITS
306
307#ifdef GET_GICOMBINER_CONSTRUCTOR_INITS
308
309, State(0),
310ExecInfo(TypeObjects, NumTypeObjects, FeatureBitsets, ComplexPredicateFns, CustomRenderers)
311
312#endif // GET_GICOMBINER_CONSTRUCTOR_INITS
313
314