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