| 1 | /*===- TableGen'erated file -------------------------------------*- C++ -*-===*\ |
| 2 | |* *| |
| 3 | |* WebAssemblyPostLegalizerCombinerImpl 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" |
| 12 | namespace llvm { |
| 13 | |
| 14 | extern cl::OptionCategory GICombinerOptionCategory; |
| 15 | |
| 16 | } // namespace llvm |
| 17 | |
| 18 | #endif // GET_GICOMBINER_DEPS |
| 19 | |
| 20 | #ifdef GET_GICOMBINER_TYPES |
| 21 | |
| 22 | struct WebAssemblyPostLegalizerCombinerImplRuleConfig { |
| 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 | |
| 31 | static 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 | } |
| 43 | static 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 | |
| 63 | bool WebAssemblyPostLegalizerCombinerImplRuleConfig::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 | |
| 72 | bool WebAssemblyPostLegalizerCombinerImplRuleConfig::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 | |
| 81 | static std::vector<std::string> WebAssemblyPostLegalizerCombinerOption; |
| 82 | static cl::list<std::string> WebAssemblyPostLegalizerCombinerDisableOption( |
| 83 | "webassemblypostlegalizercombiner-disable-rule" , |
| 84 | cl::desc("Disable one or more combiner rules temporarily in the WebAssemblyPostLegalizerCombiner pass" ), |
| 85 | cl::CommaSeparated, |
| 86 | cl::Hidden, |
| 87 | cl::cat(GICombinerOptionCategory), |
| 88 | cl::callback([](const std::string &Str) { |
| 89 | WebAssemblyPostLegalizerCombinerOption.push_back(Str); |
| 90 | })); |
| 91 | static cl::list<std::string> WebAssemblyPostLegalizerCombinerOnlyEnableOption( |
| 92 | "webassemblypostlegalizercombiner-only-enable-rule" , |
| 93 | cl::desc("Disable all rules in the WebAssemblyPostLegalizerCombiner 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 | WebAssemblyPostLegalizerCombinerOption.push_back("*" ); |
| 99 | do { |
| 100 | auto X = Str.split("," ); |
| 101 | WebAssemblyPostLegalizerCombinerOption.push_back(("!" + X.first).str()); |
| 102 | Str = X.second; |
| 103 | } while (!Str.empty()); |
| 104 | })); |
| 105 | |
| 106 | |
| 107 | bool WebAssemblyPostLegalizerCombinerImplRuleConfig::isRuleEnabled(unsigned RuleID) const { |
| 108 | return !DisabledRules.test(RuleID); |
| 109 | } |
| 110 | bool WebAssemblyPostLegalizerCombinerImplRuleConfig::parseCommandLineOption() { |
| 111 | for (StringRef Identifier : WebAssemblyPostLegalizerCombinerOption) { |
| 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 | |
| 126 | const unsigned MAX_SUBTARGET_PREDICATES = 0; |
| 127 | using PredicateBitset = llvm::Bitset<MAX_SUBTARGET_PREDICATES>; |
| 128 | |
| 129 | #endif // GET_GICOMBINER_TYPES |
| 130 | |
| 131 | #ifdef GET_GICOMBINER_CLASS_MEMBERS |
| 132 | |
| 133 | PredicateBitset AvailableModuleFeatures; |
| 134 | mutable PredicateBitset AvailableFunctionFeatures; |
| 135 | PredicateBitset getAvailableFeatures() const { |
| 136 | return AvailableModuleFeatures | AvailableFunctionFeatures; |
| 137 | } |
| 138 | PredicateBitset |
| 139 | computeAvailableModuleFeatures(const WebAssemblySubtarget *Subtarget) const; |
| 140 | PredicateBitset |
| 141 | computeAvailableFunctionFeatures(const WebAssemblySubtarget *Subtarget, |
| 142 | const MachineFunction *MF) const; |
| 143 | void setupGeneratedPerFunctionState(MachineFunction &MF) override; |
| 144 | |
| 145 | #endif // GET_GICOMBINER_CLASS_MEMBERS |
| 146 | |
| 147 | #ifdef GET_GICOMBINER_CLASS_MEMBERS |
| 148 | |
| 149 | mutable MatcherState State; |
| 150 | typedef ComplexRendererFns(WebAssemblyPostLegalizerCombinerImpl::*ComplexMatcherMemFn)(MachineOperand &) const; |
| 151 | typedef void(WebAssemblyPostLegalizerCombinerImpl::*CustomRendererFn)(MachineInstrBuilder &, const MachineInstr &, int) const; |
| 152 | const ExecInfoTy<PredicateBitset, ComplexMatcherMemFn, CustomRendererFn> ExecInfo; |
| 153 | static WebAssemblyPostLegalizerCombinerImpl::ComplexMatcherMemFn ComplexPredicateFns[]; |
| 154 | static WebAssemblyPostLegalizerCombinerImpl::CustomRendererFn CustomRenderers[]; |
| 155 | bool testImmPredicate_I64(unsigned PredicateID, int64_t Imm) const override; |
| 156 | bool testImmPredicate_APInt(unsigned PredicateID, const APInt &Imm) const override; |
| 157 | bool testImmPredicate_APFloat(unsigned PredicateID, const APFloat &Imm) const override; |
| 158 | const uint8_t *getMatchTable() const override; |
| 159 | bool testMIPredicate_MI(unsigned PredicateID, const MachineInstr &MI, const MatcherState &State) const override; |
| 160 | bool testMOPredicate_MO(unsigned PredicateID, const MachineOperand &MO, const MatcherState &State) const override; |
| 161 | bool testSimplePredicate(unsigned PredicateID) const override; |
| 162 | bool runCustomAction(unsigned FnID, const MatcherState &State, NewMIVector &OutMIs) const override; |
| 163 | |
| 164 | #endif // GET_GICOMBINER_CLASS_MEMBERS |
| 165 | |
| 166 | #ifdef GET_GICOMBINER_IMPL |
| 167 | |
| 168 | // LLT Objects. |
| 169 | enum { |
| 170 | GILLT_s1, |
| 171 | }; |
| 172 | const static size_t NumTypeObjects = 1; |
| 173 | const static LLT TypeObjects[] = { |
| 174 | LLT::scalar(1), |
| 175 | }; |
| 176 | |
| 177 | // Bits for subtarget features that participate in instruction matching. |
| 178 | enum SubtargetFeatureBits : uint8_t { |
| 179 | }; |
| 180 | |
| 181 | PredicateBitset WebAssemblyPostLegalizerCombinerImpl:: |
| 182 | computeAvailableModuleFeatures(const WebAssemblySubtarget *Subtarget) const { |
| 183 | PredicateBitset Features{}; |
| 184 | return Features; |
| 185 | } |
| 186 | |
| 187 | void WebAssemblyPostLegalizerCombinerImpl::setupGeneratedPerFunctionState(MachineFunction &MF) { |
| 188 | AvailableFunctionFeatures = computeAvailableFunctionFeatures((const WebAssemblySubtarget *)&MF.getSubtarget(), &MF); |
| 189 | } |
| 190 | PredicateBitset WebAssemblyPostLegalizerCombinerImpl:: |
| 191 | computeAvailableFunctionFeatures(const WebAssemblySubtarget *Subtarget, const MachineFunction *MF) const { |
| 192 | PredicateBitset Features{}; |
| 193 | return Features; |
| 194 | } |
| 195 | |
| 196 | // Feature bitsets. |
| 197 | enum { |
| 198 | GIFBS_Invalid, |
| 199 | }; |
| 200 | constexpr static PredicateBitset FeatureBitsets[] { |
| 201 | {}, // GIFBS_Invalid |
| 202 | }; |
| 203 | |
| 204 | // ComplexPattern predicates. |
| 205 | enum { |
| 206 | GICP_Invalid, |
| 207 | }; |
| 208 | // See constructor for table contents |
| 209 | |
| 210 | WebAssemblyPostLegalizerCombinerImpl::ComplexMatcherMemFn |
| 211 | WebAssemblyPostLegalizerCombinerImpl::ComplexPredicateFns[] = { |
| 212 | nullptr, // GICP_Invalid |
| 213 | }; |
| 214 | |
| 215 | bool WebAssemblyPostLegalizerCombinerImpl::testMIPredicate_MI(unsigned PredicateID, const MachineInstr & MI, const MatcherState &State) const { |
| 216 | llvm_unreachable("Unknown predicate" ); |
| 217 | return false; |
| 218 | } |
| 219 | bool WebAssemblyPostLegalizerCombinerImpl::testMOPredicate_MO(unsigned PredicateID, const MachineOperand & MO, const MatcherState &State) const { |
| 220 | llvm_unreachable("Unknown predicate" ); |
| 221 | return false; |
| 222 | } |
| 223 | bool WebAssemblyPostLegalizerCombinerImpl::testImmPredicate_I64(unsigned PredicateID, int64_t Imm) const { |
| 224 | llvm_unreachable("Unknown predicate" ); |
| 225 | return false; |
| 226 | } |
| 227 | bool WebAssemblyPostLegalizerCombinerImpl::testImmPredicate_APFloat(unsigned PredicateID, const APFloat & Imm) const { |
| 228 | llvm_unreachable("Unknown predicate" ); |
| 229 | return false; |
| 230 | } |
| 231 | bool WebAssemblyPostLegalizerCombinerImpl::testImmPredicate_APInt(unsigned PredicateID, const APInt & Imm) const { |
| 232 | llvm_unreachable("Unknown predicate" ); |
| 233 | return false; |
| 234 | } |
| 235 | bool WebAssemblyPostLegalizerCombinerImpl::testSimplePredicate(unsigned Predicate) const { |
| 236 | return RuleConfig.isRuleEnabled(Predicate - GICXXPred_Invalid - 1); |
| 237 | } |
| 238 | // Custom renderers. |
| 239 | enum { |
| 240 | GICR_Invalid, |
| 241 | }; |
| 242 | WebAssemblyPostLegalizerCombinerImpl::CustomRendererFn |
| 243 | WebAssemblyPostLegalizerCombinerImpl::CustomRenderers[] = { |
| 244 | nullptr, // GICR_Invalid |
| 245 | }; |
| 246 | |
| 247 | bool WebAssemblyPostLegalizerCombinerImpl::tryCombineAll(MachineInstr &I) const { |
| 248 | const TargetSubtargetInfo &ST = MF.getSubtarget(); |
| 249 | const PredicateBitset AvailableFeatures = getAvailableFeatures(); |
| 250 | B.setInstrAndDebugLoc(I); |
| 251 | State.MIs.clear(); |
| 252 | State.MIs.push_back(&I); |
| 253 | if (executeMatchTable(*this, State, ExecInfo, B, getMatchTable(), *ST.getInstrInfo(), MRI, *MRI.getTargetRegisterInfo(), *ST.getRegBankInfo(), AvailableFeatures, /*CoverageInfo*/ nullptr)) { |
| 254 | return true; |
| 255 | } |
| 256 | |
| 257 | return false; |
| 258 | } |
| 259 | |
| 260 | bool WebAssemblyPostLegalizerCombinerImpl::runCustomAction(unsigned ApplyID, const MatcherState &State, NewMIVector &OutMIs) const { |
| 261 | Helper.getBuilder().setInstrAndDebugLoc(*State.MIs[0]); |
| 262 | llvm_unreachable("Unknown Apply Action" ); |
| 263 | } |
| 264 | #if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ |
| 265 | #define GIMT_Encode2(Val) uint8_t(Val), uint8_t((Val) >> 8) |
| 266 | #define GIMT_Encode4(Val) uint8_t(Val), uint8_t((Val) >> 8), uint8_t((Val) >> 16), uint8_t((Val) >> 24) |
| 267 | #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) |
| 268 | #else |
| 269 | #define GIMT_Encode2(Val) uint8_t((Val) >> 8), uint8_t(Val) |
| 270 | #define GIMT_Encode4(Val) uint8_t((Val) >> 24), uint8_t((Val) >> 16), uint8_t((Val) >> 8), uint8_t(Val) |
| 271 | #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) |
| 272 | #endif |
| 273 | const uint8_t *WebAssemblyPostLegalizerCombinerImpl::getMatchTable() const { |
| 274 | constexpr static uint8_t MatchTable0[] = { |
| 275 | /* 0 */ GIM_Reject, |
| 276 | /* 1 */ }; // Size: 1 bytes |
| 277 | return MatchTable0; |
| 278 | } |
| 279 | #undef GIMT_Encode2 |
| 280 | #undef GIMT_Encode4 |
| 281 | #undef GIMT_Encode8 |
| 282 | |
| 283 | |
| 284 | #endif // GET_GICOMBINER_IMPL |
| 285 | |
| 286 | #ifdef GET_GICOMBINER_CONSTRUCTOR_INITS |
| 287 | |
| 288 | AvailableModuleFeatures(computeAvailableModuleFeatures(&STI)), |
| 289 | AvailableFunctionFeatures() |
| 290 | |
| 291 | #endif // GET_GICOMBINER_CONSTRUCTOR_INITS |
| 292 | |
| 293 | #ifdef GET_GICOMBINER_CONSTRUCTOR_INITS |
| 294 | |
| 295 | , State(0), |
| 296 | ExecInfo(TypeObjects, NumTypeObjects, FeatureBitsets, ComplexPredicateFns, CustomRenderers) |
| 297 | |
| 298 | #endif // GET_GICOMBINER_CONSTRUCTOR_INITS |
| 299 | |
| 300 | |