| 1 | /* Autogenerated by mlir-tblgen; don't manually edit */ |
| 2 | |
| 3 | #ifdef GEN_PASS_DECL |
| 4 | // Generate declarations for all passes. |
| 5 | #define GEN_PASS_DECL_ARITHEMULATEUNSUPPORTEDFLOATS |
| 6 | #define GEN_PASS_DECL_ARITHEMULATEWIDEINT |
| 7 | #define GEN_PASS_DECL_ARITHEXPANDOPSPASS |
| 8 | #define GEN_PASS_DECL_ARITHINTRANGENARROWING |
| 9 | #define GEN_PASS_DECL_ARITHINTRANGEOPTS |
| 10 | #define GEN_PASS_DECL_ARITHUNSIGNEDWHENEQUIVALENTPASS |
| 11 | #undef GEN_PASS_DECL |
| 12 | #endif // GEN_PASS_DECL |
| 13 | |
| 14 | //===----------------------------------------------------------------------===// |
| 15 | // ArithEmulateUnsupportedFloats |
| 16 | //===----------------------------------------------------------------------===// |
| 17 | #ifdef GEN_PASS_DECL_ARITHEMULATEUNSUPPORTEDFLOATS |
| 18 | struct ArithEmulateUnsupportedFloatsOptions { |
| 19 | ::llvm::SmallVector<std::string> sourceTypeStrs; |
| 20 | std::string targetTypeStr = "f32" ; |
| 21 | }; |
| 22 | std::unique_ptr<::mlir::Pass> createArithEmulateUnsupportedFloats(); |
| 23 | std::unique_ptr<::mlir::Pass> createArithEmulateUnsupportedFloats(ArithEmulateUnsupportedFloatsOptions options); |
| 24 | #undef GEN_PASS_DECL_ARITHEMULATEUNSUPPORTEDFLOATS |
| 25 | #endif // GEN_PASS_DECL_ARITHEMULATEUNSUPPORTEDFLOATS |
| 26 | #ifdef GEN_PASS_DEF_ARITHEMULATEUNSUPPORTEDFLOATS |
| 27 | |
| 28 | namespace impl { |
| 29 | std::unique_ptr<::mlir::Pass> createArithEmulateUnsupportedFloats(); |
| 30 | } // namespace impl |
| 31 | |
| 32 | namespace impl { |
| 33 | std::unique_ptr<::mlir::Pass> createArithEmulateUnsupportedFloats(ArithEmulateUnsupportedFloatsOptions options); |
| 34 | } // namespace impl |
| 35 | namespace impl { |
| 36 | |
| 37 | template <typename DerivedT> |
| 38 | class ArithEmulateUnsupportedFloatsBase : public ::mlir::OperationPass<> { |
| 39 | public: |
| 40 | using Base = ArithEmulateUnsupportedFloatsBase; |
| 41 | |
| 42 | ArithEmulateUnsupportedFloatsBase() : ::mlir::OperationPass<>(::mlir::TypeID::get<DerivedT>()) {} |
| 43 | ArithEmulateUnsupportedFloatsBase(const ArithEmulateUnsupportedFloatsBase &other) : ::mlir::OperationPass<>(other) {} |
| 44 | ArithEmulateUnsupportedFloatsBase& operator=(const ArithEmulateUnsupportedFloatsBase &) = delete; |
| 45 | ArithEmulateUnsupportedFloatsBase(ArithEmulateUnsupportedFloatsBase &&) = delete; |
| 46 | ArithEmulateUnsupportedFloatsBase& operator=(ArithEmulateUnsupportedFloatsBase &&) = delete; |
| 47 | ~ArithEmulateUnsupportedFloatsBase() = default; |
| 48 | |
| 49 | /// Returns the command-line argument attached to this pass. |
| 50 | static constexpr ::llvm::StringLiteral getArgumentName() { |
| 51 | return ::llvm::StringLiteral("arith-emulate-unsupported-floats" ); |
| 52 | } |
| 53 | ::llvm::StringRef getArgument() const override { return "arith-emulate-unsupported-floats" ; } |
| 54 | |
| 55 | ::llvm::StringRef getDescription() const override { return R"PD(Emulate operations on unsupported floats with extf/truncf)PD" ; } |
| 56 | |
| 57 | /// Returns the derived pass name. |
| 58 | static constexpr ::llvm::StringLiteral getPassName() { |
| 59 | return ::llvm::StringLiteral("ArithEmulateUnsupportedFloats" ); |
| 60 | } |
| 61 | ::llvm::StringRef getName() const override { return "ArithEmulateUnsupportedFloats" ; } |
| 62 | |
| 63 | /// Support isa/dyn_cast functionality for the derived pass class. |
| 64 | static bool classof(const ::mlir::Pass *pass) { |
| 65 | return pass->getTypeID() == ::mlir::TypeID::get<DerivedT>(); |
| 66 | } |
| 67 | |
| 68 | /// A clone method to create a copy of this pass. |
| 69 | std::unique_ptr<::mlir::Pass> clonePass() const override { |
| 70 | return std::make_unique<DerivedT>(*static_cast<const DerivedT *>(this)); |
| 71 | } |
| 72 | |
| 73 | /// Return the dialect that must be loaded in the context before this pass. |
| 74 | void getDependentDialects(::mlir::DialectRegistry ®istry) const override { |
| 75 | registry.insert<vector::VectorDialect>(); |
| 76 | } |
| 77 | |
| 78 | /// Explicitly declare the TypeID for this class. We declare an explicit private |
| 79 | /// instantiation because Pass classes should only be visible by the current |
| 80 | /// library. |
| 81 | MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(ArithEmulateUnsupportedFloatsBase<DerivedT>) |
| 82 | |
| 83 | ArithEmulateUnsupportedFloatsBase(ArithEmulateUnsupportedFloatsOptions options) : ArithEmulateUnsupportedFloatsBase() { |
| 84 | sourceTypeStrs = std::move(options.sourceTypeStrs); |
| 85 | targetTypeStr = std::move(options.targetTypeStr); |
| 86 | } |
| 87 | protected: |
| 88 | ::mlir::Pass::ListOption<std::string> sourceTypeStrs{*this, "source-types" , ::llvm::cl::desc(R"PO(MLIR types without arithmetic support on a given target)PO" )}; |
| 89 | ::mlir::Pass::Option<std::string> targetTypeStr{*this, "target-type" , ::llvm::cl::desc(R"PO(MLIR type to convert the unsupported source types to)PO" ), ::llvm::cl::init("f32" )}; |
| 90 | private: |
| 91 | |
| 92 | friend std::unique_ptr<::mlir::Pass> createArithEmulateUnsupportedFloats() { |
| 93 | return std::make_unique<DerivedT>(); |
| 94 | } |
| 95 | |
| 96 | friend std::unique_ptr<::mlir::Pass> createArithEmulateUnsupportedFloats(ArithEmulateUnsupportedFloatsOptions options) { |
| 97 | return std::make_unique<DerivedT>(std::move(options)); |
| 98 | } |
| 99 | }; |
| 100 | } // namespace impl |
| 101 | |
| 102 | std::unique_ptr<::mlir::Pass> createArithEmulateUnsupportedFloats() { |
| 103 | return impl::createArithEmulateUnsupportedFloats(); |
| 104 | } |
| 105 | |
| 106 | std::unique_ptr<::mlir::Pass> createArithEmulateUnsupportedFloats(ArithEmulateUnsupportedFloatsOptions options) { |
| 107 | return impl::createArithEmulateUnsupportedFloats(std::move(options)); |
| 108 | } |
| 109 | #undef GEN_PASS_DEF_ARITHEMULATEUNSUPPORTEDFLOATS |
| 110 | #endif // GEN_PASS_DEF_ARITHEMULATEUNSUPPORTEDFLOATS |
| 111 | |
| 112 | //===----------------------------------------------------------------------===// |
| 113 | // ArithEmulateWideInt |
| 114 | //===----------------------------------------------------------------------===// |
| 115 | #ifdef GEN_PASS_DECL_ARITHEMULATEWIDEINT |
| 116 | struct ArithEmulateWideIntOptions { |
| 117 | unsigned widestIntSupported = 32; |
| 118 | }; |
| 119 | std::unique_ptr<::mlir::Pass> createArithEmulateWideInt(); |
| 120 | std::unique_ptr<::mlir::Pass> createArithEmulateWideInt(ArithEmulateWideIntOptions options); |
| 121 | #undef GEN_PASS_DECL_ARITHEMULATEWIDEINT |
| 122 | #endif // GEN_PASS_DECL_ARITHEMULATEWIDEINT |
| 123 | #ifdef GEN_PASS_DEF_ARITHEMULATEWIDEINT |
| 124 | |
| 125 | namespace impl { |
| 126 | std::unique_ptr<::mlir::Pass> createArithEmulateWideInt(); |
| 127 | } // namespace impl |
| 128 | |
| 129 | namespace impl { |
| 130 | std::unique_ptr<::mlir::Pass> createArithEmulateWideInt(ArithEmulateWideIntOptions options); |
| 131 | } // namespace impl |
| 132 | namespace impl { |
| 133 | |
| 134 | template <typename DerivedT> |
| 135 | class ArithEmulateWideIntBase : public ::mlir::OperationPass<> { |
| 136 | public: |
| 137 | using Base = ArithEmulateWideIntBase; |
| 138 | |
| 139 | ArithEmulateWideIntBase() : ::mlir::OperationPass<>(::mlir::TypeID::get<DerivedT>()) {} |
| 140 | ArithEmulateWideIntBase(const ArithEmulateWideIntBase &other) : ::mlir::OperationPass<>(other) {} |
| 141 | ArithEmulateWideIntBase& operator=(const ArithEmulateWideIntBase &) = delete; |
| 142 | ArithEmulateWideIntBase(ArithEmulateWideIntBase &&) = delete; |
| 143 | ArithEmulateWideIntBase& operator=(ArithEmulateWideIntBase &&) = delete; |
| 144 | ~ArithEmulateWideIntBase() = default; |
| 145 | |
| 146 | /// Returns the command-line argument attached to this pass. |
| 147 | static constexpr ::llvm::StringLiteral getArgumentName() { |
| 148 | return ::llvm::StringLiteral("arith-emulate-wide-int" ); |
| 149 | } |
| 150 | ::llvm::StringRef getArgument() const override { return "arith-emulate-wide-int" ; } |
| 151 | |
| 152 | ::llvm::StringRef getDescription() const override { return R"PD(Emulate 2*N-bit integer operations using N-bit operations)PD" ; } |
| 153 | |
| 154 | /// Returns the derived pass name. |
| 155 | static constexpr ::llvm::StringLiteral getPassName() { |
| 156 | return ::llvm::StringLiteral("ArithEmulateWideInt" ); |
| 157 | } |
| 158 | ::llvm::StringRef getName() const override { return "ArithEmulateWideInt" ; } |
| 159 | |
| 160 | /// Support isa/dyn_cast functionality for the derived pass class. |
| 161 | static bool classof(const ::mlir::Pass *pass) { |
| 162 | return pass->getTypeID() == ::mlir::TypeID::get<DerivedT>(); |
| 163 | } |
| 164 | |
| 165 | /// A clone method to create a copy of this pass. |
| 166 | std::unique_ptr<::mlir::Pass> clonePass() const override { |
| 167 | return std::make_unique<DerivedT>(*static_cast<const DerivedT *>(this)); |
| 168 | } |
| 169 | |
| 170 | /// Return the dialect that must be loaded in the context before this pass. |
| 171 | void getDependentDialects(::mlir::DialectRegistry ®istry) const override { |
| 172 | registry.insert<vector::VectorDialect>(); |
| 173 | } |
| 174 | |
| 175 | /// Explicitly declare the TypeID for this class. We declare an explicit private |
| 176 | /// instantiation because Pass classes should only be visible by the current |
| 177 | /// library. |
| 178 | MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(ArithEmulateWideIntBase<DerivedT>) |
| 179 | |
| 180 | ArithEmulateWideIntBase(ArithEmulateWideIntOptions options) : ArithEmulateWideIntBase() { |
| 181 | widestIntSupported = std::move(options.widestIntSupported); |
| 182 | } |
| 183 | protected: |
| 184 | ::mlir::Pass::Option<unsigned> widestIntSupported{*this, "widest-int-supported" , ::llvm::cl::desc(R"PO(Widest integer type supported by the target)PO" ), ::llvm::cl::init(32)}; |
| 185 | private: |
| 186 | |
| 187 | friend std::unique_ptr<::mlir::Pass> createArithEmulateWideInt() { |
| 188 | return std::make_unique<DerivedT>(); |
| 189 | } |
| 190 | |
| 191 | friend std::unique_ptr<::mlir::Pass> createArithEmulateWideInt(ArithEmulateWideIntOptions options) { |
| 192 | return std::make_unique<DerivedT>(std::move(options)); |
| 193 | } |
| 194 | }; |
| 195 | } // namespace impl |
| 196 | |
| 197 | std::unique_ptr<::mlir::Pass> createArithEmulateWideInt() { |
| 198 | return impl::createArithEmulateWideInt(); |
| 199 | } |
| 200 | |
| 201 | std::unique_ptr<::mlir::Pass> createArithEmulateWideInt(ArithEmulateWideIntOptions options) { |
| 202 | return impl::createArithEmulateWideInt(std::move(options)); |
| 203 | } |
| 204 | #undef GEN_PASS_DEF_ARITHEMULATEWIDEINT |
| 205 | #endif // GEN_PASS_DEF_ARITHEMULATEWIDEINT |
| 206 | |
| 207 | //===----------------------------------------------------------------------===// |
| 208 | // ArithExpandOpsPass |
| 209 | //===----------------------------------------------------------------------===// |
| 210 | #ifdef GEN_PASS_DECL_ARITHEXPANDOPSPASS |
| 211 | struct ArithExpandOpsPassOptions { |
| 212 | bool includeBf16 = false; |
| 213 | bool includeF8E8M0 = false; |
| 214 | bool includeF4E2M1 = false; |
| 215 | bool includeF8E5M2 = false; |
| 216 | bool includeF8E4M3FN = false; |
| 217 | bool includeFlushDenormals = false; |
| 218 | bool includeMinMaxF = false; |
| 219 | bool includeMinMaxI = false; |
| 220 | }; |
| 221 | std::unique_ptr<::mlir::Pass> createArithExpandOpsPass(); |
| 222 | std::unique_ptr<::mlir::Pass> createArithExpandOpsPass(ArithExpandOpsPassOptions options); |
| 223 | #undef GEN_PASS_DECL_ARITHEXPANDOPSPASS |
| 224 | #endif // GEN_PASS_DECL_ARITHEXPANDOPSPASS |
| 225 | #ifdef GEN_PASS_DEF_ARITHEXPANDOPSPASS |
| 226 | |
| 227 | namespace impl { |
| 228 | std::unique_ptr<::mlir::Pass> createArithExpandOpsPass(); |
| 229 | } // namespace impl |
| 230 | |
| 231 | namespace impl { |
| 232 | std::unique_ptr<::mlir::Pass> createArithExpandOpsPass(ArithExpandOpsPassOptions options); |
| 233 | } // namespace impl |
| 234 | namespace impl { |
| 235 | |
| 236 | template <typename DerivedT> |
| 237 | class ArithExpandOpsPassBase : public ::mlir::OperationPass<> { |
| 238 | public: |
| 239 | using Base = ArithExpandOpsPassBase; |
| 240 | |
| 241 | ArithExpandOpsPassBase() : ::mlir::OperationPass<>(::mlir::TypeID::get<DerivedT>()) {} |
| 242 | ArithExpandOpsPassBase(const ArithExpandOpsPassBase &other) : ::mlir::OperationPass<>(other) {} |
| 243 | ArithExpandOpsPassBase& operator=(const ArithExpandOpsPassBase &) = delete; |
| 244 | ArithExpandOpsPassBase(ArithExpandOpsPassBase &&) = delete; |
| 245 | ArithExpandOpsPassBase& operator=(ArithExpandOpsPassBase &&) = delete; |
| 246 | ~ArithExpandOpsPassBase() = default; |
| 247 | |
| 248 | /// Returns the command-line argument attached to this pass. |
| 249 | static constexpr ::llvm::StringLiteral getArgumentName() { |
| 250 | return ::llvm::StringLiteral("arith-expand" ); |
| 251 | } |
| 252 | ::llvm::StringRef getArgument() const override { return "arith-expand" ; } |
| 253 | |
| 254 | ::llvm::StringRef getDescription() const override { return R"PD(Legalize Arith ops to be convertible to LLVM.)PD" ; } |
| 255 | |
| 256 | /// Returns the derived pass name. |
| 257 | static constexpr ::llvm::StringLiteral getPassName() { |
| 258 | return ::llvm::StringLiteral("ArithExpandOpsPass" ); |
| 259 | } |
| 260 | ::llvm::StringRef getName() const override { return "ArithExpandOpsPass" ; } |
| 261 | |
| 262 | /// Support isa/dyn_cast functionality for the derived pass class. |
| 263 | static bool classof(const ::mlir::Pass *pass) { |
| 264 | return pass->getTypeID() == ::mlir::TypeID::get<DerivedT>(); |
| 265 | } |
| 266 | |
| 267 | /// A clone method to create a copy of this pass. |
| 268 | std::unique_ptr<::mlir::Pass> clonePass() const override { |
| 269 | return std::make_unique<DerivedT>(*static_cast<const DerivedT *>(this)); |
| 270 | } |
| 271 | |
| 272 | /// Return the dialect that must be loaded in the context before this pass. |
| 273 | void getDependentDialects(::mlir::DialectRegistry ®istry) const override { |
| 274 | registry.insert<vector::VectorDialect>(); |
| 275 | } |
| 276 | |
| 277 | /// Explicitly declare the TypeID for this class. We declare an explicit private |
| 278 | /// instantiation because Pass classes should only be visible by the current |
| 279 | /// library. |
| 280 | MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(ArithExpandOpsPassBase<DerivedT>) |
| 281 | |
| 282 | ArithExpandOpsPassBase(ArithExpandOpsPassOptions options) : ArithExpandOpsPassBase() { |
| 283 | includeBf16 = std::move(options.includeBf16); |
| 284 | includeF8E8M0 = std::move(options.includeF8E8M0); |
| 285 | includeF4E2M1 = std::move(options.includeF4E2M1); |
| 286 | includeF8E5M2 = std::move(options.includeF8E5M2); |
| 287 | includeF8E4M3FN = std::move(options.includeF8E4M3FN); |
| 288 | includeFlushDenormals = std::move(options.includeFlushDenormals); |
| 289 | includeMinMaxF = std::move(options.includeMinMaxF); |
| 290 | includeMinMaxI = std::move(options.includeMinMaxI); |
| 291 | } |
| 292 | protected: |
| 293 | ::mlir::Pass::Option<bool> includeBf16{*this, "include-bf16" , ::llvm::cl::desc(R"PO(Enable the BF16 expansion patterns)PO" ), ::llvm::cl::init(false)}; |
| 294 | ::mlir::Pass::Option<bool> includeF8E8M0{*this, "include-f8e8m0" , ::llvm::cl::desc(R"PO(Enable the F8E8M0 expansion patterns)PO" ), ::llvm::cl::init(false)}; |
| 295 | ::mlir::Pass::Option<bool> includeF4E2M1{*this, "include-f4e2m1" , ::llvm::cl::desc(R"PO(Enable the F4E2M1 expansion patterns)PO" ), ::llvm::cl::init(false)}; |
| 296 | ::mlir::Pass::Option<bool> includeF8E5M2{*this, "include-f8e5m2" , ::llvm::cl::desc(R"PO(Enable the F8E5M2 expansion patterns)PO" ), ::llvm::cl::init(false)}; |
| 297 | ::mlir::Pass::Option<bool> includeF8E4M3FN{*this, "include-f8e4m3fn" , ::llvm::cl::desc(R"PO(Enable the F8E4M3FN expansion patterns)PO" ), ::llvm::cl::init(false)}; |
| 298 | ::mlir::Pass::Option<bool> includeFlushDenormals{*this, "include-flush-denormals" , ::llvm::cl::desc(R"PO(Enable expansion of `arith.flush_denormals` on IEEE-like floating-point types)PO" ), ::llvm::cl::init(false)}; |
| 299 | ::mlir::Pass::Option<bool> includeMinMaxF{*this, "include-min-max-f" , ::llvm::cl::desc(R"PO(Enable expansion of the floating-point min/max ops (maximumf/minimumf/maxnumf/minnumf). These ops also have a direct arith-to-llvm lowering to the `llvm.intr.maximum/minimum/maxnum/minnum` intrinsics; disable this so pipelines that run arith-to-llvm can use those single-instruction lowerings instead of the cmpf/select expansion)PO" ), ::llvm::cl::init(false)}; |
| 300 | ::mlir::Pass::Option<bool> includeMinMaxI{*this, "include-min-max-i" , ::llvm::cl::desc(R"PO(Enable expansion of the signed/unsigned integer min/max ops (maxsi/maxui/minsi/minui). These ops also have a direct arith-to-llvm lowering to the `llvm.intr.smax/umax/smin/umin` intrinsics; disable this so pipelines that run arith-to-llvm can use those single-instruction lowerings instead of the cmpi/select expansion)PO" ), ::llvm::cl::init(false)}; |
| 301 | private: |
| 302 | |
| 303 | friend std::unique_ptr<::mlir::Pass> createArithExpandOpsPass() { |
| 304 | return std::make_unique<DerivedT>(); |
| 305 | } |
| 306 | |
| 307 | friend std::unique_ptr<::mlir::Pass> createArithExpandOpsPass(ArithExpandOpsPassOptions options) { |
| 308 | return std::make_unique<DerivedT>(std::move(options)); |
| 309 | } |
| 310 | }; |
| 311 | } // namespace impl |
| 312 | |
| 313 | std::unique_ptr<::mlir::Pass> createArithExpandOpsPass() { |
| 314 | return impl::createArithExpandOpsPass(); |
| 315 | } |
| 316 | |
| 317 | std::unique_ptr<::mlir::Pass> createArithExpandOpsPass(ArithExpandOpsPassOptions options) { |
| 318 | return impl::createArithExpandOpsPass(std::move(options)); |
| 319 | } |
| 320 | #undef GEN_PASS_DEF_ARITHEXPANDOPSPASS |
| 321 | #endif // GEN_PASS_DEF_ARITHEXPANDOPSPASS |
| 322 | |
| 323 | //===----------------------------------------------------------------------===// |
| 324 | // ArithIntRangeNarrowing |
| 325 | //===----------------------------------------------------------------------===// |
| 326 | #ifdef GEN_PASS_DECL_ARITHINTRANGENARROWING |
| 327 | struct ArithIntRangeNarrowingOptions { |
| 328 | ::llvm::SmallVector<unsigned> bitwidthsSupported; |
| 329 | }; |
| 330 | std::unique_ptr<::mlir::Pass> createArithIntRangeNarrowing(); |
| 331 | std::unique_ptr<::mlir::Pass> createArithIntRangeNarrowing(ArithIntRangeNarrowingOptions options); |
| 332 | #undef GEN_PASS_DECL_ARITHINTRANGENARROWING |
| 333 | #endif // GEN_PASS_DECL_ARITHINTRANGENARROWING |
| 334 | #ifdef GEN_PASS_DEF_ARITHINTRANGENARROWING |
| 335 | |
| 336 | namespace impl { |
| 337 | std::unique_ptr<::mlir::Pass> createArithIntRangeNarrowing(); |
| 338 | } // namespace impl |
| 339 | |
| 340 | namespace impl { |
| 341 | std::unique_ptr<::mlir::Pass> createArithIntRangeNarrowing(ArithIntRangeNarrowingOptions options); |
| 342 | } // namespace impl |
| 343 | namespace impl { |
| 344 | |
| 345 | template <typename DerivedT> |
| 346 | class ArithIntRangeNarrowingBase : public ::mlir::OperationPass<> { |
| 347 | public: |
| 348 | using Base = ArithIntRangeNarrowingBase; |
| 349 | |
| 350 | ArithIntRangeNarrowingBase() : ::mlir::OperationPass<>(::mlir::TypeID::get<DerivedT>()) {} |
| 351 | ArithIntRangeNarrowingBase(const ArithIntRangeNarrowingBase &other) : ::mlir::OperationPass<>(other) {} |
| 352 | ArithIntRangeNarrowingBase& operator=(const ArithIntRangeNarrowingBase &) = delete; |
| 353 | ArithIntRangeNarrowingBase(ArithIntRangeNarrowingBase &&) = delete; |
| 354 | ArithIntRangeNarrowingBase& operator=(ArithIntRangeNarrowingBase &&) = delete; |
| 355 | ~ArithIntRangeNarrowingBase() = default; |
| 356 | |
| 357 | /// Returns the command-line argument attached to this pass. |
| 358 | static constexpr ::llvm::StringLiteral getArgumentName() { |
| 359 | return ::llvm::StringLiteral("arith-int-range-narrowing" ); |
| 360 | } |
| 361 | ::llvm::StringRef getArgument() const override { return "arith-int-range-narrowing" ; } |
| 362 | |
| 363 | ::llvm::StringRef getDescription() const override { return R"PD(Reduce integer operations bitwidth based on integer range analysis)PD" ; } |
| 364 | |
| 365 | /// Returns the derived pass name. |
| 366 | static constexpr ::llvm::StringLiteral getPassName() { |
| 367 | return ::llvm::StringLiteral("ArithIntRangeNarrowing" ); |
| 368 | } |
| 369 | ::llvm::StringRef getName() const override { return "ArithIntRangeNarrowing" ; } |
| 370 | |
| 371 | /// Support isa/dyn_cast functionality for the derived pass class. |
| 372 | static bool classof(const ::mlir::Pass *pass) { |
| 373 | return pass->getTypeID() == ::mlir::TypeID::get<DerivedT>(); |
| 374 | } |
| 375 | |
| 376 | /// A clone method to create a copy of this pass. |
| 377 | std::unique_ptr<::mlir::Pass> clonePass() const override { |
| 378 | return std::make_unique<DerivedT>(*static_cast<const DerivedT *>(this)); |
| 379 | } |
| 380 | |
| 381 | /// Return the dialect that must be loaded in the context before this pass. |
| 382 | void getDependentDialects(::mlir::DialectRegistry ®istry) const override { |
| 383 | registry.insert<::mlir::arith::ArithDialect>(); |
| 384 | } |
| 385 | |
| 386 | /// Explicitly declare the TypeID for this class. We declare an explicit private |
| 387 | /// instantiation because Pass classes should only be visible by the current |
| 388 | /// library. |
| 389 | MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(ArithIntRangeNarrowingBase<DerivedT>) |
| 390 | |
| 391 | ArithIntRangeNarrowingBase(ArithIntRangeNarrowingOptions options) : ArithIntRangeNarrowingBase() { |
| 392 | bitwidthsSupported = std::move(options.bitwidthsSupported); |
| 393 | } |
| 394 | protected: |
| 395 | ::mlir::Pass::ListOption<unsigned> bitwidthsSupported{*this, "int-bitwidths-supported" , ::llvm::cl::desc(R"PO(Integer bitwidths supported)PO" )}; |
| 396 | private: |
| 397 | |
| 398 | friend std::unique_ptr<::mlir::Pass> createArithIntRangeNarrowing() { |
| 399 | return std::make_unique<DerivedT>(); |
| 400 | } |
| 401 | |
| 402 | friend std::unique_ptr<::mlir::Pass> createArithIntRangeNarrowing(ArithIntRangeNarrowingOptions options) { |
| 403 | return std::make_unique<DerivedT>(std::move(options)); |
| 404 | } |
| 405 | }; |
| 406 | } // namespace impl |
| 407 | |
| 408 | std::unique_ptr<::mlir::Pass> createArithIntRangeNarrowing() { |
| 409 | return impl::createArithIntRangeNarrowing(); |
| 410 | } |
| 411 | |
| 412 | std::unique_ptr<::mlir::Pass> createArithIntRangeNarrowing(ArithIntRangeNarrowingOptions options) { |
| 413 | return impl::createArithIntRangeNarrowing(std::move(options)); |
| 414 | } |
| 415 | #undef GEN_PASS_DEF_ARITHINTRANGENARROWING |
| 416 | #endif // GEN_PASS_DEF_ARITHINTRANGENARROWING |
| 417 | |
| 418 | //===----------------------------------------------------------------------===// |
| 419 | // ArithIntRangeOpts |
| 420 | //===----------------------------------------------------------------------===// |
| 421 | #ifdef GEN_PASS_DECL_ARITHINTRANGEOPTS |
| 422 | std::unique_ptr<::mlir::Pass> createArithIntRangeOpts(); |
| 423 | #undef GEN_PASS_DECL_ARITHINTRANGEOPTS |
| 424 | #endif // GEN_PASS_DECL_ARITHINTRANGEOPTS |
| 425 | #ifdef GEN_PASS_DEF_ARITHINTRANGEOPTS |
| 426 | |
| 427 | namespace impl { |
| 428 | std::unique_ptr<::mlir::Pass> createArithIntRangeOpts(); |
| 429 | } // namespace impl |
| 430 | namespace impl { |
| 431 | |
| 432 | template <typename DerivedT> |
| 433 | class ArithIntRangeOptsBase : public ::mlir::OperationPass<> { |
| 434 | public: |
| 435 | using Base = ArithIntRangeOptsBase; |
| 436 | |
| 437 | ArithIntRangeOptsBase() : ::mlir::OperationPass<>(::mlir::TypeID::get<DerivedT>()) {} |
| 438 | ArithIntRangeOptsBase(const ArithIntRangeOptsBase &other) : ::mlir::OperationPass<>(other) {} |
| 439 | ArithIntRangeOptsBase& operator=(const ArithIntRangeOptsBase &) = delete; |
| 440 | ArithIntRangeOptsBase(ArithIntRangeOptsBase &&) = delete; |
| 441 | ArithIntRangeOptsBase& operator=(ArithIntRangeOptsBase &&) = delete; |
| 442 | ~ArithIntRangeOptsBase() = default; |
| 443 | |
| 444 | /// Returns the command-line argument attached to this pass. |
| 445 | static constexpr ::llvm::StringLiteral getArgumentName() { |
| 446 | return ::llvm::StringLiteral("int-range-optimizations" ); |
| 447 | } |
| 448 | ::llvm::StringRef getArgument() const override { return "int-range-optimizations" ; } |
| 449 | |
| 450 | ::llvm::StringRef getDescription() const override { return R"PD(Do optimizations based on integer range analysis)PD" ; } |
| 451 | |
| 452 | /// Returns the derived pass name. |
| 453 | static constexpr ::llvm::StringLiteral getPassName() { |
| 454 | return ::llvm::StringLiteral("ArithIntRangeOpts" ); |
| 455 | } |
| 456 | ::llvm::StringRef getName() const override { return "ArithIntRangeOpts" ; } |
| 457 | |
| 458 | /// Support isa/dyn_cast functionality for the derived pass class. |
| 459 | static bool classof(const ::mlir::Pass *pass) { |
| 460 | return pass->getTypeID() == ::mlir::TypeID::get<DerivedT>(); |
| 461 | } |
| 462 | |
| 463 | /// A clone method to create a copy of this pass. |
| 464 | std::unique_ptr<::mlir::Pass> clonePass() const override { |
| 465 | return std::make_unique<DerivedT>(*static_cast<const DerivedT *>(this)); |
| 466 | } |
| 467 | |
| 468 | /// Return the dialect that must be loaded in the context before this pass. |
| 469 | void getDependentDialects(::mlir::DialectRegistry ®istry) const override { |
| 470 | registry.insert<::mlir::arith::ArithDialect>(); |
| 471 | } |
| 472 | |
| 473 | /// Explicitly declare the TypeID for this class. We declare an explicit private |
| 474 | /// instantiation because Pass classes should only be visible by the current |
| 475 | /// library. |
| 476 | MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(ArithIntRangeOptsBase<DerivedT>) |
| 477 | |
| 478 | protected: |
| 479 | private: |
| 480 | |
| 481 | friend std::unique_ptr<::mlir::Pass> createArithIntRangeOpts() { |
| 482 | return std::make_unique<DerivedT>(); |
| 483 | } |
| 484 | }; |
| 485 | } // namespace impl |
| 486 | |
| 487 | std::unique_ptr<::mlir::Pass> createArithIntRangeOpts() { |
| 488 | return impl::createArithIntRangeOpts(); |
| 489 | } |
| 490 | #undef GEN_PASS_DEF_ARITHINTRANGEOPTS |
| 491 | #endif // GEN_PASS_DEF_ARITHINTRANGEOPTS |
| 492 | |
| 493 | //===----------------------------------------------------------------------===// |
| 494 | // ArithUnsignedWhenEquivalentPass |
| 495 | //===----------------------------------------------------------------------===// |
| 496 | #ifdef GEN_PASS_DECL_ARITHUNSIGNEDWHENEQUIVALENTPASS |
| 497 | std::unique_ptr<::mlir::Pass> createArithUnsignedWhenEquivalentPass(); |
| 498 | #undef GEN_PASS_DECL_ARITHUNSIGNEDWHENEQUIVALENTPASS |
| 499 | #endif // GEN_PASS_DECL_ARITHUNSIGNEDWHENEQUIVALENTPASS |
| 500 | #ifdef GEN_PASS_DEF_ARITHUNSIGNEDWHENEQUIVALENTPASS |
| 501 | |
| 502 | namespace impl { |
| 503 | std::unique_ptr<::mlir::Pass> createArithUnsignedWhenEquivalentPass(); |
| 504 | } // namespace impl |
| 505 | namespace impl { |
| 506 | |
| 507 | template <typename DerivedT> |
| 508 | class ArithUnsignedWhenEquivalentPassBase : public ::mlir::OperationPass<> { |
| 509 | public: |
| 510 | using Base = ArithUnsignedWhenEquivalentPassBase; |
| 511 | |
| 512 | ArithUnsignedWhenEquivalentPassBase() : ::mlir::OperationPass<>(::mlir::TypeID::get<DerivedT>()) {} |
| 513 | ArithUnsignedWhenEquivalentPassBase(const ArithUnsignedWhenEquivalentPassBase &other) : ::mlir::OperationPass<>(other) {} |
| 514 | ArithUnsignedWhenEquivalentPassBase& operator=(const ArithUnsignedWhenEquivalentPassBase &) = delete; |
| 515 | ArithUnsignedWhenEquivalentPassBase(ArithUnsignedWhenEquivalentPassBase &&) = delete; |
| 516 | ArithUnsignedWhenEquivalentPassBase& operator=(ArithUnsignedWhenEquivalentPassBase &&) = delete; |
| 517 | ~ArithUnsignedWhenEquivalentPassBase() = default; |
| 518 | |
| 519 | /// Returns the command-line argument attached to this pass. |
| 520 | static constexpr ::llvm::StringLiteral getArgumentName() { |
| 521 | return ::llvm::StringLiteral("arith-unsigned-when-equivalent" ); |
| 522 | } |
| 523 | ::llvm::StringRef getArgument() const override { return "arith-unsigned-when-equivalent" ; } |
| 524 | |
| 525 | ::llvm::StringRef getDescription() const override { return R"PD(Replace signed ops with unsigned ones where they are proven equivalent)PD" ; } |
| 526 | |
| 527 | /// Returns the derived pass name. |
| 528 | static constexpr ::llvm::StringLiteral getPassName() { |
| 529 | return ::llvm::StringLiteral("ArithUnsignedWhenEquivalentPass" ); |
| 530 | } |
| 531 | ::llvm::StringRef getName() const override { return "ArithUnsignedWhenEquivalentPass" ; } |
| 532 | |
| 533 | /// Support isa/dyn_cast functionality for the derived pass class. |
| 534 | static bool classof(const ::mlir::Pass *pass) { |
| 535 | return pass->getTypeID() == ::mlir::TypeID::get<DerivedT>(); |
| 536 | } |
| 537 | |
| 538 | /// A clone method to create a copy of this pass. |
| 539 | std::unique_ptr<::mlir::Pass> clonePass() const override { |
| 540 | return std::make_unique<DerivedT>(*static_cast<const DerivedT *>(this)); |
| 541 | } |
| 542 | |
| 543 | /// Return the dialect that must be loaded in the context before this pass. |
| 544 | void getDependentDialects(::mlir::DialectRegistry ®istry) const override { |
| 545 | |
| 546 | } |
| 547 | |
| 548 | /// Explicitly declare the TypeID for this class. We declare an explicit private |
| 549 | /// instantiation because Pass classes should only be visible by the current |
| 550 | /// library. |
| 551 | MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(ArithUnsignedWhenEquivalentPassBase<DerivedT>) |
| 552 | |
| 553 | protected: |
| 554 | private: |
| 555 | |
| 556 | friend std::unique_ptr<::mlir::Pass> createArithUnsignedWhenEquivalentPass() { |
| 557 | return std::make_unique<DerivedT>(); |
| 558 | } |
| 559 | }; |
| 560 | } // namespace impl |
| 561 | |
| 562 | std::unique_ptr<::mlir::Pass> createArithUnsignedWhenEquivalentPass() { |
| 563 | return impl::createArithUnsignedWhenEquivalentPass(); |
| 564 | } |
| 565 | #undef GEN_PASS_DEF_ARITHUNSIGNEDWHENEQUIVALENTPASS |
| 566 | #endif // GEN_PASS_DEF_ARITHUNSIGNEDWHENEQUIVALENTPASS |
| 567 | #ifdef GEN_PASS_REGISTRATION |
| 568 | // Generate registrations for all passes. |
| 569 | #define GEN_PASS_REGISTRATION_ARITHEMULATEUNSUPPORTEDFLOATS |
| 570 | #define GEN_PASS_REGISTRATION_ARITHEMULATEWIDEINT |
| 571 | #define GEN_PASS_REGISTRATION_ARITHEXPANDOPSPASS |
| 572 | #define GEN_PASS_REGISTRATION_ARITHINTRANGENARROWING |
| 573 | #define GEN_PASS_REGISTRATION_ARITHINTRANGEOPTS |
| 574 | #define GEN_PASS_REGISTRATION_ARITHUNSIGNEDWHENEQUIVALENTPASS |
| 575 | #endif // GEN_PASS_REGISTRATION |
| 576 | |
| 577 | //===----------------------------------------------------------------------===// |
| 578 | // ArithEmulateUnsupportedFloats Registration |
| 579 | //===----------------------------------------------------------------------===// |
| 580 | #ifdef GEN_PASS_REGISTRATION_ARITHEMULATEUNSUPPORTEDFLOATS |
| 581 | |
| 582 | inline void registerArithEmulateUnsupportedFloats() { |
| 583 | ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> { |
| 584 | return createArithEmulateUnsupportedFloats(); |
| 585 | }); |
| 586 | } |
| 587 | |
| 588 | // Old registration code, kept for temporary backwards compatibility. |
| 589 | inline void registerArithEmulateUnsupportedFloatsPass() { |
| 590 | ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> { |
| 591 | return createArithEmulateUnsupportedFloats(); |
| 592 | }); |
| 593 | } |
| 594 | |
| 595 | #undef GEN_PASS_REGISTRATION_ARITHEMULATEUNSUPPORTEDFLOATS |
| 596 | #endif // GEN_PASS_REGISTRATION_ARITHEMULATEUNSUPPORTEDFLOATS |
| 597 | |
| 598 | //===----------------------------------------------------------------------===// |
| 599 | // ArithEmulateWideInt Registration |
| 600 | //===----------------------------------------------------------------------===// |
| 601 | #ifdef GEN_PASS_REGISTRATION_ARITHEMULATEWIDEINT |
| 602 | |
| 603 | inline void registerArithEmulateWideInt() { |
| 604 | ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> { |
| 605 | return createArithEmulateWideInt(); |
| 606 | }); |
| 607 | } |
| 608 | |
| 609 | // Old registration code, kept for temporary backwards compatibility. |
| 610 | inline void registerArithEmulateWideIntPass() { |
| 611 | ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> { |
| 612 | return createArithEmulateWideInt(); |
| 613 | }); |
| 614 | } |
| 615 | |
| 616 | #undef GEN_PASS_REGISTRATION_ARITHEMULATEWIDEINT |
| 617 | #endif // GEN_PASS_REGISTRATION_ARITHEMULATEWIDEINT |
| 618 | |
| 619 | //===----------------------------------------------------------------------===// |
| 620 | // ArithExpandOpsPass Registration |
| 621 | //===----------------------------------------------------------------------===// |
| 622 | #ifdef GEN_PASS_REGISTRATION_ARITHEXPANDOPSPASS |
| 623 | |
| 624 | inline void registerArithExpandOpsPass() { |
| 625 | ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> { |
| 626 | return createArithExpandOpsPass(); |
| 627 | }); |
| 628 | } |
| 629 | |
| 630 | // Old registration code, kept for temporary backwards compatibility. |
| 631 | inline void registerArithExpandOpsPassPass() { |
| 632 | ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> { |
| 633 | return createArithExpandOpsPass(); |
| 634 | }); |
| 635 | } |
| 636 | |
| 637 | #undef GEN_PASS_REGISTRATION_ARITHEXPANDOPSPASS |
| 638 | #endif // GEN_PASS_REGISTRATION_ARITHEXPANDOPSPASS |
| 639 | |
| 640 | //===----------------------------------------------------------------------===// |
| 641 | // ArithIntRangeNarrowing Registration |
| 642 | //===----------------------------------------------------------------------===// |
| 643 | #ifdef GEN_PASS_REGISTRATION_ARITHINTRANGENARROWING |
| 644 | |
| 645 | inline void registerArithIntRangeNarrowing() { |
| 646 | ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> { |
| 647 | return createArithIntRangeNarrowing(); |
| 648 | }); |
| 649 | } |
| 650 | |
| 651 | // Old registration code, kept for temporary backwards compatibility. |
| 652 | inline void registerArithIntRangeNarrowingPass() { |
| 653 | ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> { |
| 654 | return createArithIntRangeNarrowing(); |
| 655 | }); |
| 656 | } |
| 657 | |
| 658 | #undef GEN_PASS_REGISTRATION_ARITHINTRANGENARROWING |
| 659 | #endif // GEN_PASS_REGISTRATION_ARITHINTRANGENARROWING |
| 660 | |
| 661 | //===----------------------------------------------------------------------===// |
| 662 | // ArithIntRangeOpts Registration |
| 663 | //===----------------------------------------------------------------------===// |
| 664 | #ifdef GEN_PASS_REGISTRATION_ARITHINTRANGEOPTS |
| 665 | |
| 666 | inline void registerArithIntRangeOpts() { |
| 667 | ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> { |
| 668 | return createArithIntRangeOpts(); |
| 669 | }); |
| 670 | } |
| 671 | |
| 672 | // Old registration code, kept for temporary backwards compatibility. |
| 673 | inline void registerArithIntRangeOptsPass() { |
| 674 | ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> { |
| 675 | return createArithIntRangeOpts(); |
| 676 | }); |
| 677 | } |
| 678 | |
| 679 | #undef GEN_PASS_REGISTRATION_ARITHINTRANGEOPTS |
| 680 | #endif // GEN_PASS_REGISTRATION_ARITHINTRANGEOPTS |
| 681 | |
| 682 | //===----------------------------------------------------------------------===// |
| 683 | // ArithUnsignedWhenEquivalentPass Registration |
| 684 | //===----------------------------------------------------------------------===// |
| 685 | #ifdef GEN_PASS_REGISTRATION_ARITHUNSIGNEDWHENEQUIVALENTPASS |
| 686 | |
| 687 | inline void registerArithUnsignedWhenEquivalentPass() { |
| 688 | ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> { |
| 689 | return createArithUnsignedWhenEquivalentPass(); |
| 690 | }); |
| 691 | } |
| 692 | |
| 693 | // Old registration code, kept for temporary backwards compatibility. |
| 694 | inline void registerArithUnsignedWhenEquivalentPassPass() { |
| 695 | ::mlir::registerPass([]() -> std::unique_ptr<::mlir::Pass> { |
| 696 | return createArithUnsignedWhenEquivalentPass(); |
| 697 | }); |
| 698 | } |
| 699 | |
| 700 | #undef GEN_PASS_REGISTRATION_ARITHUNSIGNEDWHENEQUIVALENTPASS |
| 701 | #endif // GEN_PASS_REGISTRATION_ARITHUNSIGNEDWHENEQUIVALENTPASS |
| 702 | #ifdef GEN_PASS_REGISTRATION |
| 703 | |
| 704 | //===----------------------------------------------------------------------===// |
| 705 | // Arith Registration |
| 706 | //===----------------------------------------------------------------------===// |
| 707 | |
| 708 | inline void registerArithPasses() { |
| 709 | registerArithEmulateUnsupportedFloats(); |
| 710 | registerArithEmulateWideInt(); |
| 711 | registerArithExpandOpsPass(); |
| 712 | registerArithIntRangeNarrowing(); |
| 713 | registerArithIntRangeOpts(); |
| 714 | registerArithUnsignedWhenEquivalentPass(); |
| 715 | } |
| 716 | #undef GEN_PASS_REGISTRATION |
| 717 | #endif // GEN_PASS_REGISTRATION |
| 718 | #ifdef GEN_PASS_CLASSES |
| 719 | #error "GEN_PASS_CLASSES is deprecated; use per-pass macros" |
| 720 | #undef GEN_PASS_CLASSES |
| 721 | #endif // GEN_PASS_CLASSES |
| 722 | |