1/*===- TableGen'erated file -------------------------------------*- C++ -*-===*\
2|* *|
3|* WebAssemblyPreLegalizerCombinerImpl 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 WebAssemblyPreLegalizerCombinerImplRuleConfig {
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 WebAssemblyPreLegalizerCombinerImplRuleConfig::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 WebAssemblyPreLegalizerCombinerImplRuleConfig::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> WebAssemblyPreLegalizerCombinerOption;
82static cl::list<std::string> WebAssemblyPreLegalizerCombinerDisableOption(
83 "webassemblyprelegalizercombiner-disable-rule",
84 cl::desc("Disable one or more combiner rules temporarily in the WebAssemblyPreLegalizerCombiner pass"),
85 cl::CommaSeparated,
86 cl::Hidden,
87 cl::cat(GICombinerOptionCategory),
88 cl::callback([](const std::string &Str) {
89 WebAssemblyPreLegalizerCombinerOption.push_back(Str);
90 }));
91static cl::list<std::string> WebAssemblyPreLegalizerCombinerOnlyEnableOption(
92 "webassemblyprelegalizercombiner-only-enable-rule",
93 cl::desc("Disable all rules in the WebAssemblyPreLegalizerCombiner 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 WebAssemblyPreLegalizerCombinerOption.push_back("*");
99 do {
100 auto X = Str.split(",");
101 WebAssemblyPreLegalizerCombinerOption.push_back(("!" + X.first).str());
102 Str = X.second;
103 } while (!Str.empty());
104 }));
105
106
107bool WebAssemblyPreLegalizerCombinerImplRuleConfig::isRuleEnabled(unsigned RuleID) const {
108 return !DisabledRules.test(RuleID);
109}
110bool WebAssemblyPreLegalizerCombinerImplRuleConfig::parseCommandLineOption() {
111 for (StringRef Identifier : WebAssemblyPreLegalizerCombinerOption) {
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 WebAssemblySubtarget *Subtarget) const;
147PredicateBitset
148computeAvailableFunctionFeatures(const WebAssemblySubtarget *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(WebAssemblyPreLegalizerCombinerImpl::*ComplexMatcherMemFn)(MachineOperand &) const;
158 typedef void(WebAssemblyPreLegalizerCombinerImpl::*CustomRendererFn)(MachineInstrBuilder &, const MachineInstr &, int) const;
159 const ExecInfoTy<PredicateBitset, ComplexMatcherMemFn, CustomRendererFn> ExecInfo;
160 static WebAssemblyPreLegalizerCombinerImpl::ComplexMatcherMemFn ComplexPredicateFns[];
161 static WebAssemblyPreLegalizerCombinerImpl::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 LLT getLLTForHwMode(unsigned Index) const override;
167 bool testMIPredicate_MI(unsigned PredicateID, const MachineInstr &MI, const MatcherState &State) const override;
168 bool testMOPredicate_MO(unsigned PredicateID, const MachineOperand &MO, const MatcherState &State) const override;
169 bool testSimplePredicate(unsigned PredicateID) const override;
170 bool runCustomAction(unsigned FnID, const MatcherState &State, NewMIVector &OutMIs) const override;
171
172#endif // GET_GICOMBINER_CLASS_MEMBERS
173
174#ifdef GET_GICOMBINER_IMPL
175
176// LLT Objects.
177enum {
178 GILLT_s1,
179};
180const static size_t NumTypeObjects = 1;
181const static LLT TypeObjects[] = {
182 LLT::scalar(1),
183};
184
185// Bits for subtarget features that participate in instruction matching.
186enum SubtargetFeatureBits : uint8_t {
187};
188
189PredicateBitset WebAssemblyPreLegalizerCombinerImpl::
190computeAvailableModuleFeatures(const WebAssemblySubtarget *Subtarget) const {
191 PredicateBitset Features{};
192 return Features;
193}
194
195void WebAssemblyPreLegalizerCombinerImpl::setupGeneratedPerFunctionState(MachineFunction &MF) {
196 AvailableFunctionFeatures = computeAvailableFunctionFeatures((const WebAssemblySubtarget *)&MF.getSubtarget(), &MF);
197}
198PredicateBitset WebAssemblyPreLegalizerCombinerImpl::
199computeAvailableFunctionFeatures(const WebAssemblySubtarget *Subtarget, const MachineFunction *MF) const {
200 PredicateBitset Features{};
201 return Features;
202}
203
204// Feature bitsets.
205enum {
206 GIFBS_Invalid,
207};
208constexpr static PredicateBitset FeatureBitsets[] {
209 {}, // GIFBS_Invalid
210};
211
212// ComplexPattern predicates.
213enum {
214 GICP_Invalid,
215};
216// See constructor for table contents
217
218WebAssemblyPreLegalizerCombinerImpl::ComplexMatcherMemFn
219WebAssemblyPreLegalizerCombinerImpl::ComplexPredicateFns[] = {
220 nullptr, // GICP_Invalid
221};
222
223bool WebAssemblyPreLegalizerCombinerImpl::testMIPredicate_MI(unsigned PredicateID, const MachineInstr & MI, const MatcherState &State) const {
224 llvm_unreachable("Unknown predicate");
225 return false;
226}
227bool WebAssemblyPreLegalizerCombinerImpl::testMOPredicate_MO(unsigned PredicateID, const MachineOperand & MO, const MatcherState &State) const {
228 llvm_unreachable("Unknown predicate");
229 return false;
230}
231bool WebAssemblyPreLegalizerCombinerImpl::testImmPredicate_I64(unsigned PredicateID, int64_t Imm) const {
232 llvm_unreachable("Unknown predicate");
233 return false;
234}
235bool WebAssemblyPreLegalizerCombinerImpl::testImmPredicate_APFloat(unsigned PredicateID, const APFloat & Imm) const {
236 llvm_unreachable("Unknown predicate");
237 return false;
238}
239bool WebAssemblyPreLegalizerCombinerImpl::testImmPredicate_APInt(unsigned PredicateID, const APInt & Imm) const {
240 llvm_unreachable("Unknown predicate");
241 return false;
242}
243bool WebAssemblyPreLegalizerCombinerImpl::testSimplePredicate(unsigned Predicate) const {
244 return RuleConfig.isRuleEnabled(Predicate - GICXXPred_Invalid - 1);
245}
246// Custom renderers.
247enum {
248 GICR_Invalid,
249};
250WebAssemblyPreLegalizerCombinerImpl::CustomRendererFn
251WebAssemblyPreLegalizerCombinerImpl::CustomRenderers[] = {
252 nullptr, // GICR_Invalid
253};
254
255bool WebAssemblyPreLegalizerCombinerImpl::canMatchOpcode(unsigned Opc) const {
256 (void)Opc;
257 return false;
258}
259
260uint32_t WebAssemblyPreLegalizerCombinerImpl::getRootFlagsToDrop() const {
261 return MachineInstr::getPoisonGeneratingFlags();
262}
263
264bool WebAssemblyPreLegalizerCombinerImpl::tryCombineAll(MachineInstr &I) const {
265 const PredicateBitset AvailableFeatures = getAvailableFeatures();
266 State.MIs.clear();
267 State.MIs.push_back(&I);
268 if (executeMatchTable(*this, State, ExecInfo, B, getMatchTable(), Helper.getTII(), MRI, Helper.getTRI(), Helper.getRBI(), AvailableFeatures, /*CoverageInfo*/ nullptr)) {
269 return true;
270 }
271
272 return false;
273}
274
275bool WebAssemblyPreLegalizerCombinerImpl::runCustomAction(unsigned ApplyID, const MatcherState &State, NewMIVector &OutMIs) const {
276 Helper.getBuilder().setInstrAndDebugLoc(*State.MIs[0]);
277 llvm_unreachable("Unknown Apply Action");
278}
279#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
280#define GIMT_Encode2(Val) uint8_t(Val), uint8_t((Val) >> 8)
281#define GIMT_Encode4(Val) uint8_t(Val), uint8_t((Val) >> 8), uint8_t((Val) >> 16), uint8_t((Val) >> 24)
282#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)
283#else
284#define GIMT_Encode2(Val) uint8_t((Val) >> 8), uint8_t(Val)
285#define GIMT_Encode4(Val) uint8_t((Val) >> 24), uint8_t((Val) >> 16), uint8_t((Val) >> 8), uint8_t(Val)
286#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)
287#endif
288const uint8_t *WebAssemblyPreLegalizerCombinerImpl::getMatchTable() const {
289 constexpr static uint8_t MatchTable0[] = {
290 /* 0 */ GIM_Reject,
291 /* 1 */ }; // Size: 1 bytes
292 return MatchTable0;
293}
294#undef GIMT_Encode2
295#undef GIMT_Encode4
296#undef GIMT_Encode8
297
298LLT WebAssemblyPreLegalizerCombinerImpl::getLLTForHwMode(unsigned Index) const {
299 llvm_unreachable("Unexpected index");
300}
301
302
303#endif // GET_GICOMBINER_IMPL
304
305#ifdef GET_GICOMBINER_CONSTRUCTOR_INITS
306
307AvailableModuleFeatures(computeAvailableModuleFeatures(&STI)),
308AvailableFunctionFeatures()
309
310#endif // GET_GICOMBINER_CONSTRUCTOR_INITS
311
312#ifdef GET_GICOMBINER_CONSTRUCTOR_INITS
313
314, State(0),
315ExecInfo(TypeObjects, NumTypeObjects, FeatureBitsets, ComplexPredicateFns, CustomRenderers)
316
317#endif // GET_GICOMBINER_CONSTRUCTOR_INITS
318
319