| 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 testMOPredicate_MO(unsigned PredicateID, const MachineOperand &MO, const MatcherState &State) const override; |
| 149 | bool testSimplePredicate(unsigned PredicateID) const override; |
| 150 | bool runCustomAction(unsigned FnID, const MatcherState &State, NewMIVector &OutMIs) const override; |
| 151 | #endif // ifdef GET_GICOMBINER_CLASS_MEMBERS |
| 152 | |
| 153 | #ifdef GET_GICOMBINER_IMPL |
| 154 | // LLT Objects. |
| 155 | enum { |
| 156 | GILLT_s1, |
| 157 | }; |
| 158 | const static size_t NumTypeObjects = 1; |
| 159 | const static LLT TypeObjects[] = { |
| 160 | LLT::scalar(1), |
| 161 | }; |
| 162 | |
| 163 | // Bits for subtarget features that participate in instruction matching. |
| 164 | enum SubtargetFeatureBits : uint8_t { |
| 165 | }; |
| 166 | |
| 167 | PredicateBitset MipsPostLegalizerCombinerImpl:: |
| 168 | computeAvailableModuleFeatures(const MipsSubtarget *Subtarget) const { |
| 169 | PredicateBitset Features{}; |
| 170 | return Features; |
| 171 | } |
| 172 | |
| 173 | void MipsPostLegalizerCombinerImpl::setupGeneratedPerFunctionState(MachineFunction &MF) { |
| 174 | AvailableFunctionFeatures = computeAvailableFunctionFeatures((const MipsSubtarget *)&MF.getSubtarget(), &MF); |
| 175 | } |
| 176 | PredicateBitset MipsPostLegalizerCombinerImpl:: |
| 177 | computeAvailableFunctionFeatures(const MipsSubtarget *Subtarget, const MachineFunction *MF) const { |
| 178 | PredicateBitset Features{}; |
| 179 | return Features; |
| 180 | } |
| 181 | |
| 182 | // Feature bitsets. |
| 183 | enum { |
| 184 | GIFBS_Invalid, |
| 185 | }; |
| 186 | constexpr static PredicateBitset FeatureBitsets[] { |
| 187 | {}, // GIFBS_Invalid |
| 188 | }; |
| 189 | |
| 190 | // ComplexPattern predicates. |
| 191 | enum { |
| 192 | GICP_Invalid, |
| 193 | }; |
| 194 | // See constructor for table contents |
| 195 | |
| 196 | MipsPostLegalizerCombinerImpl::ComplexMatcherMemFn |
| 197 | MipsPostLegalizerCombinerImpl::ComplexPredicateFns[] = { |
| 198 | nullptr, // GICP_Invalid |
| 199 | }; |
| 200 | |
| 201 | bool MipsPostLegalizerCombinerImpl::testMIPredicate_MI(unsigned PredicateID, const MachineInstr & MI, const MatcherState &State) const { |
| 202 | llvm_unreachable("Unknown predicate" ); |
| 203 | return false; |
| 204 | } |
| 205 | bool MipsPostLegalizerCombinerImpl::testMOPredicate_MO(unsigned PredicateID, const MachineOperand & MO, const MatcherState &State) const { |
| 206 | llvm_unreachable("Unknown predicate" ); |
| 207 | return false; |
| 208 | } |
| 209 | bool MipsPostLegalizerCombinerImpl::testImmPredicate_I64(unsigned PredicateID, int64_t Imm) const { |
| 210 | llvm_unreachable("Unknown predicate" ); |
| 211 | return false; |
| 212 | } |
| 213 | bool MipsPostLegalizerCombinerImpl::testImmPredicate_APFloat(unsigned PredicateID, const APFloat & Imm) const { |
| 214 | llvm_unreachable("Unknown predicate" ); |
| 215 | return false; |
| 216 | } |
| 217 | bool MipsPostLegalizerCombinerImpl::testImmPredicate_APInt(unsigned PredicateID, const APInt & Imm) const { |
| 218 | llvm_unreachable("Unknown predicate" ); |
| 219 | return false; |
| 220 | } |
| 221 | bool MipsPostLegalizerCombinerImpl::testSimplePredicate(unsigned Predicate) const { |
| 222 | return RuleConfig.isRuleEnabled(Predicate - GICXXPred_Invalid - 1); |
| 223 | } |
| 224 | // Custom renderers. |
| 225 | enum { |
| 226 | GICR_Invalid, |
| 227 | }; |
| 228 | MipsPostLegalizerCombinerImpl::CustomRendererFn |
| 229 | MipsPostLegalizerCombinerImpl::CustomRenderers[] = { |
| 230 | nullptr, // GICR_Invalid |
| 231 | }; |
| 232 | |
| 233 | bool MipsPostLegalizerCombinerImpl::tryCombineAll(MachineInstr &I) const { |
| 234 | const TargetSubtargetInfo &ST = MF.getSubtarget(); |
| 235 | const PredicateBitset AvailableFeatures = getAvailableFeatures(); |
| 236 | B.setInstrAndDebugLoc(I); |
| 237 | State.MIs.clear(); |
| 238 | State.MIs.push_back(&I); |
| 239 | if (executeMatchTable(*this, State, ExecInfo, B, getMatchTable(), *ST.getInstrInfo(), MRI, *MRI.getTargetRegisterInfo(), *ST.getRegBankInfo(), AvailableFeatures, /*CoverageInfo*/ nullptr)) { |
| 240 | return true; |
| 241 | } |
| 242 | |
| 243 | return false; |
| 244 | } |
| 245 | |
| 246 | bool MipsPostLegalizerCombinerImpl::runCustomAction(unsigned ApplyID, const MatcherState &State, NewMIVector &OutMIs) const { |
| 247 | Helper.getBuilder().setInstrAndDebugLoc(*State.MIs[0]); |
| 248 | llvm_unreachable("Unknown Apply Action" ); |
| 249 | } |
| 250 | #if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ |
| 251 | #define GIMT_Encode2(Val) uint8_t(Val), uint8_t((uint16_t)Val >> 8) |
| 252 | #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) |
| 253 | #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) |
| 254 | #else |
| 255 | #define GIMT_Encode2(Val) uint8_t((uint16_t)Val >> 8), uint8_t(Val) |
| 256 | #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) |
| 257 | #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) |
| 258 | #endif |
| 259 | const uint8_t *MipsPostLegalizerCombinerImpl::getMatchTable() const { |
| 260 | constexpr static uint8_t MatchTable0[] = { |
| 261 | /* 0 */ GIM_Reject, |
| 262 | /* 1 */ }; // Size: 1 bytes |
| 263 | return MatchTable0; |
| 264 | } |
| 265 | #undef GIMT_Encode2 |
| 266 | #undef GIMT_Encode4 |
| 267 | #undef GIMT_Encode8 |
| 268 | |
| 269 | #endif // ifdef GET_GICOMBINER_IMPL |
| 270 | |
| 271 | #ifdef GET_GICOMBINER_CONSTRUCTOR_INITS |
| 272 | AvailableModuleFeatures(computeAvailableModuleFeatures(&STI)), |
| 273 | AvailableFunctionFeatures() |
| 274 | #endif // ifdef GET_GICOMBINER_CONSTRUCTOR_INITS |
| 275 | #ifdef GET_GICOMBINER_CONSTRUCTOR_INITS |
| 276 | , State(0), |
| 277 | ExecInfo(TypeObjects, NumTypeObjects, FeatureBitsets, ComplexPredicateFns, CustomRenderers) |
| 278 | #endif // ifdef GET_GICOMBINER_CONSTRUCTOR_INITS |
| 279 | |
| 280 | |