diff --git a/mlir/docs/Bufferization.md b/mlir/docs/Bufferization.md --- a/mlir/docs/Bufferization.md +++ b/mlir/docs/Bufferization.md @@ -156,19 +156,19 @@ ``` void mlir::populateTensorBufferizePatterns( - MLIRContext *context, BufferizeTypeConverter &typeConverter, - OwningRewritePatternList &patterns) { - patterns.insert(typeConverter, context); + BufferizeTypeConverter &typeConverter, RewritePatternSet &patterns) { + patterns.add(typeConverter, + patterns.getContext()); } struct TensorBufferizePass : public TensorBufferizeBase { void runOnFunction() override { auto *context = &getContext(); BufferizeTypeConverter typeConverter; - OwningRewritePatternList patterns; + RewritePatternSet patterns(context); ConversionTarget target(*context); - populateTensorBufferizePatterns(context, typeConverter, patterns); + populateTensorBufferizePatterns(typeConverter, patterns); target.addIllegalOp(); target.addLegalDialect(); @@ -180,7 +180,7 @@ ``` The pass has all the hallmarks of a dialect conversion pass that does type -conversions: a `TypeConverter`, a `OwningRewritePatternList`, and a +conversions: a `TypeConverter`, a `RewritePatternSet`, and a `ConversionTarget`, and a call to `applyPartialConversion`. Note that a function `populateTensorBufferizePatterns` is separated, so that power users can use the patterns independently, if necessary (such as to combine multiple sets of diff --git a/mlir/docs/Canonicalization.md b/mlir/docs/Canonicalization.md --- a/mlir/docs/Canonicalization.md +++ b/mlir/docs/Canonicalization.md @@ -79,9 +79,9 @@ Canonicalization patterns can then be provided in the source file: ```c++ -void MyOp::getCanonicalizationPatterns(OwningRewritePatternList &patterns, +void MyOp::getCanonicalizationPatterns(RewritePatternSet &patterns, MLIRContext *context) { - patterns.insert<...>(...); + patterns.add<...>(...); } ``` diff --git a/mlir/docs/PatternRewriter.md b/mlir/docs/PatternRewriter.md --- a/mlir/docs/PatternRewriter.md +++ b/mlir/docs/PatternRewriter.md @@ -154,10 +154,10 @@ After a set of patterns have been defined, they are collected and provided to a specific driver for application. A driver consists of several high levels parts: -* Input `OwningRewritePatternList` +* Input `RewritePatternSet` The input patterns to a driver are provided in the form of an -`OwningRewritePatternList`. This class provides a simplified API for building a +`RewritePatternSet`. This class provides a simplified API for building a list of patterns. * Driver-specific `PatternRewriter` @@ -173,7 +173,7 @@ Each driver is responsible for defining its own operation visitation order as well as pattern cost model, but the final application is performed via a `PatternApplicator` class. This class takes as input the -`OwningRewritePatternList` and transforms the patterns based upon a provided +`RewritePatternSet` and transforms the patterns based upon a provided cost model. This cost model computes a final benefit for a given pattern, using whatever driver specific information necessary. After a cost model has been computed, the driver may begin to match patterns against operations using @@ -189,8 +189,8 @@ }; /// Populate the pattern list. -void collectMyPatterns(OwningRewritePatternList &patterns, MLIRContext *ctx) { - patterns.insert(/*benefit=*/1, ctx); +void collectMyPatterns(RewritePatternSet &patterns, MLIRContext *ctx) { + patterns.add(/*benefit=*/1, ctx); } /// Define a custom PatternRewriter for use by the driver. @@ -203,7 +203,7 @@ /// Apply the custom driver to `op`. void applyMyPatternDriver(Operation *op, - const OwningRewritePatternList &patterns) { + const RewritePatternSet &patterns) { // Initialize the custom PatternRewriter. MyPatternRewriter rewriter(op->getContext()); diff --git a/mlir/docs/Tutorials/QuickstartRewrites.md b/mlir/docs/Tutorials/QuickstartRewrites.md --- a/mlir/docs/Tutorials/QuickstartRewrites.md +++ b/mlir/docs/Tutorials/QuickstartRewrites.md @@ -155,7 +155,7 @@ Then you can `#include` the generated file in any C++ implementation file you like. (You will also need to make sure the library depends on the CMake target defined in the above.) The generated file will have a `populateWithGenerated( -OwningRewritePatternList &patterns)` function that you can +RewritePatternSet &patterns)` function that you can use to collect all the generated patterns inside `patterns` and then use `patterns` in any pass you would like. diff --git a/mlir/docs/Tutorials/Toy/Ch-3.md b/mlir/docs/Tutorials/Toy/Ch-3.md --- a/mlir/docs/Tutorials/Toy/Ch-3.md +++ b/mlir/docs/Tutorials/Toy/Ch-3.md @@ -114,8 +114,8 @@ ```c++ // Register our patterns for rewrite by the Canonicalization framework. void TransposeOp::getCanonicalizationPatterns( - OwningRewritePatternList &results, MLIRContext *context) { - results.insert(context); + RewritePatternSet &results, MLIRContext *context) { + results.add(context); } ``` diff --git a/mlir/docs/Tutorials/Toy/Ch-5.md b/mlir/docs/Tutorials/Toy/Ch-5.md --- a/mlir/docs/Tutorials/Toy/Ch-5.md +++ b/mlir/docs/Tutorials/Toy/Ch-5.md @@ -147,8 +147,8 @@ // Now that the conversion target has been defined, we just need to provide // the set of patterns that will lower the Toy operations. - mlir::OwningRewritePatternList patterns; - patterns.insert<..., TransposeOpLowering>(&getContext()); + mlir::RewritePatternSet patterns; + patterns.add<..., TransposeOpLowering>(&getContext()); ... ``` diff --git a/mlir/docs/Tutorials/Toy/Ch-6.md b/mlir/docs/Tutorials/Toy/Ch-6.md --- a/mlir/docs/Tutorials/Toy/Ch-6.md +++ b/mlir/docs/Tutorials/Toy/Ch-6.md @@ -90,14 +90,14 @@ by relying on [transitive lowering](../../../getting_started/Glossary.md#transitive-lowering). ```c++ - mlir::OwningRewritePatternList patterns; + mlir::RewritePatternSet patterns; mlir::populateAffineToStdConversionPatterns(patterns, &getContext()); mlir::populateLoopToStdConversionPatterns(patterns, &getContext()); mlir::populateStdToLLVMConversionPatterns(typeConverter, patterns); // The only remaining operation, to lower from the `toy` dialect, is the // PrintOp. - patterns.insert(&getContext()); + patterns.add(&getContext()); ``` ### Full Lowering diff --git a/mlir/examples/toy/Ch3/mlir/ToyCombine.cpp b/mlir/examples/toy/Ch3/mlir/ToyCombine.cpp --- a/mlir/examples/toy/Ch3/mlir/ToyCombine.cpp +++ b/mlir/examples/toy/Ch3/mlir/ToyCombine.cpp @@ -54,15 +54,15 @@ /// Register our patterns as "canonicalization" patterns on the TransposeOp so /// that they can be picked up by the Canonicalization framework. -void TransposeOp::getCanonicalizationPatterns(OwningRewritePatternList &results, +void TransposeOp::getCanonicalizationPatterns(RewritePatternSet &results, MLIRContext *context) { - results.insert(context); + results.add(context); } /// Register our patterns as "canonicalization" patterns on the ReshapeOp so /// that they can be picked up by the Canonicalization framework. -void ReshapeOp::getCanonicalizationPatterns(OwningRewritePatternList &results, +void ReshapeOp::getCanonicalizationPatterns(RewritePatternSet &results, MLIRContext *context) { - results.insert(context); + results.add(context); } diff --git a/mlir/examples/toy/Ch4/mlir/ToyCombine.cpp b/mlir/examples/toy/Ch4/mlir/ToyCombine.cpp --- a/mlir/examples/toy/Ch4/mlir/ToyCombine.cpp +++ b/mlir/examples/toy/Ch4/mlir/ToyCombine.cpp @@ -54,15 +54,15 @@ /// Register our patterns as "canonicalization" patterns on the TransposeOp so /// that they can be picked up by the Canonicalization framework. -void TransposeOp::getCanonicalizationPatterns(OwningRewritePatternList &results, +void TransposeOp::getCanonicalizationPatterns(RewritePatternSet &results, MLIRContext *context) { - results.insert(context); + results.add(context); } /// Register our patterns as "canonicalization" patterns on the ReshapeOp so /// that they can be picked up by the Canonicalization framework. -void ReshapeOp::getCanonicalizationPatterns(OwningRewritePatternList &results, +void ReshapeOp::getCanonicalizationPatterns(RewritePatternSet &results, MLIRContext *context) { - results.insert(context); + results.add(context); } diff --git a/mlir/examples/toy/Ch5/mlir/LowerToAffineLoops.cpp b/mlir/examples/toy/Ch5/mlir/LowerToAffineLoops.cpp --- a/mlir/examples/toy/Ch5/mlir/LowerToAffineLoops.cpp +++ b/mlir/examples/toy/Ch5/mlir/LowerToAffineLoops.cpp @@ -297,9 +297,9 @@ // Now that the conversion target has been defined, we just need to provide // the set of patterns that will lower the Toy operations. - OwningRewritePatternList patterns(&getContext()); - patterns.insert(&getContext()); + RewritePatternSet patterns(&getContext()); + patterns.add(&getContext()); // With the target and rewrite patterns defined, we can now attempt the // conversion. The conversion will signal failure if any of our `illegal` diff --git a/mlir/examples/toy/Ch5/mlir/ToyCombine.cpp b/mlir/examples/toy/Ch5/mlir/ToyCombine.cpp --- a/mlir/examples/toy/Ch5/mlir/ToyCombine.cpp +++ b/mlir/examples/toy/Ch5/mlir/ToyCombine.cpp @@ -54,15 +54,15 @@ /// Register our patterns as "canonicalization" patterns on the TransposeOp so /// that they can be picked up by the Canonicalization framework. -void TransposeOp::getCanonicalizationPatterns(OwningRewritePatternList &results, +void TransposeOp::getCanonicalizationPatterns(RewritePatternSet &results, MLIRContext *context) { - results.insert(context); + results.add(context); } /// Register our patterns as "canonicalization" patterns on the ReshapeOp so /// that they can be picked up by the Canonicalization framework. -void ReshapeOp::getCanonicalizationPatterns(OwningRewritePatternList &results, +void ReshapeOp::getCanonicalizationPatterns(RewritePatternSet &results, MLIRContext *context) { - results.insert(context); + results.add(context); } diff --git a/mlir/examples/toy/Ch6/mlir/LowerToAffineLoops.cpp b/mlir/examples/toy/Ch6/mlir/LowerToAffineLoops.cpp --- a/mlir/examples/toy/Ch6/mlir/LowerToAffineLoops.cpp +++ b/mlir/examples/toy/Ch6/mlir/LowerToAffineLoops.cpp @@ -296,9 +296,9 @@ // Now that the conversion target has been defined, we just need to provide // the set of patterns that will lower the Toy operations. - OwningRewritePatternList patterns(&getContext()); - patterns.insert(&getContext()); + RewritePatternSet patterns(&getContext()); + patterns.add(&getContext()); // With the target and rewrite patterns defined, we can now attempt the // conversion. The conversion will signal failure if any of our `illegal` diff --git a/mlir/examples/toy/Ch6/mlir/LowerToLLVM.cpp b/mlir/examples/toy/Ch6/mlir/LowerToLLVM.cpp --- a/mlir/examples/toy/Ch6/mlir/LowerToLLVM.cpp +++ b/mlir/examples/toy/Ch6/mlir/LowerToLLVM.cpp @@ -191,14 +191,14 @@ // lowerings. Transitive lowering, or A->B->C lowering, is when multiple // patterns must be applied to fully transform an illegal operation into a // set of legal ones. - OwningRewritePatternList patterns(&getContext()); + RewritePatternSet patterns(&getContext()); populateAffineToStdConversionPatterns(patterns); populateLoopToStdConversionPatterns(patterns); populateStdToLLVMConversionPatterns(typeConverter, patterns); // The only remaining operation to lower from the `toy` dialect, is the // PrintOp. - patterns.insert(&getContext()); + patterns.add(&getContext()); // We want to completely lower to LLVM, so we use a `FullConversion`. This // ensures that only legal operations will remain after the conversion. diff --git a/mlir/examples/toy/Ch6/mlir/ToyCombine.cpp b/mlir/examples/toy/Ch6/mlir/ToyCombine.cpp --- a/mlir/examples/toy/Ch6/mlir/ToyCombine.cpp +++ b/mlir/examples/toy/Ch6/mlir/ToyCombine.cpp @@ -54,15 +54,15 @@ /// Register our patterns as "canonicalization" patterns on the TransposeOp so /// that they can be picked up by the Canonicalization framework. -void TransposeOp::getCanonicalizationPatterns(OwningRewritePatternList &results, +void TransposeOp::getCanonicalizationPatterns(RewritePatternSet &results, MLIRContext *context) { - results.insert(context); + results.add(context); } /// Register our patterns as "canonicalization" patterns on the ReshapeOp so /// that they can be picked up by the Canonicalization framework. -void ReshapeOp::getCanonicalizationPatterns(OwningRewritePatternList &results, +void ReshapeOp::getCanonicalizationPatterns(RewritePatternSet &results, MLIRContext *context) { - results.insert(context); + results.add(context); } diff --git a/mlir/examples/toy/Ch7/mlir/LowerToAffineLoops.cpp b/mlir/examples/toy/Ch7/mlir/LowerToAffineLoops.cpp --- a/mlir/examples/toy/Ch7/mlir/LowerToAffineLoops.cpp +++ b/mlir/examples/toy/Ch7/mlir/LowerToAffineLoops.cpp @@ -297,9 +297,9 @@ // Now that the conversion target has been defined, we just need to provide // the set of patterns that will lower the Toy operations. - OwningRewritePatternList patterns(&getContext()); - patterns.insert(&getContext()); + RewritePatternSet patterns(&getContext()); + patterns.add(&getContext()); // With the target and rewrite patterns defined, we can now attempt the // conversion. The conversion will signal failure if any of our `illegal` diff --git a/mlir/examples/toy/Ch7/mlir/LowerToLLVM.cpp b/mlir/examples/toy/Ch7/mlir/LowerToLLVM.cpp --- a/mlir/examples/toy/Ch7/mlir/LowerToLLVM.cpp +++ b/mlir/examples/toy/Ch7/mlir/LowerToLLVM.cpp @@ -191,14 +191,14 @@ // lowerings. Transitive lowering, or A->B->C lowering, is when multiple // patterns must be applied to fully transform an illegal operation into a // set of legal ones. - OwningRewritePatternList patterns(&getContext()); + RewritePatternSet patterns(&getContext()); populateAffineToStdConversionPatterns(patterns); populateLoopToStdConversionPatterns(patterns); populateStdToLLVMConversionPatterns(typeConverter, patterns); // The only remaining operation to lower from the `toy` dialect, is the // PrintOp. - patterns.insert(&getContext()); + patterns.add(&getContext()); // We want to completely lower to LLVM, so we use a `FullConversion`. This // ensures that only legal operations will remain after the conversion. diff --git a/mlir/examples/toy/Ch7/mlir/ToyCombine.cpp b/mlir/examples/toy/Ch7/mlir/ToyCombine.cpp --- a/mlir/examples/toy/Ch7/mlir/ToyCombine.cpp +++ b/mlir/examples/toy/Ch7/mlir/ToyCombine.cpp @@ -72,15 +72,15 @@ /// Register our patterns as "canonicalization" patterns on the TransposeOp so /// that they can be picked up by the Canonicalization framework. -void TransposeOp::getCanonicalizationPatterns(OwningRewritePatternList &results, +void TransposeOp::getCanonicalizationPatterns(RewritePatternSet &results, MLIRContext *context) { - results.insert(context); + results.add(context); } /// Register our patterns as "canonicalization" patterns on the ReshapeOp so /// that they can be picked up by the Canonicalization framework. -void ReshapeOp::getCanonicalizationPatterns(OwningRewritePatternList &results, +void ReshapeOp::getCanonicalizationPatterns(RewritePatternSet &results, MLIRContext *context) { - results.insert(context); + results.add(context); } diff --git a/mlir/include/mlir/Conversion/AffineToStandard/AffineToStandard.h b/mlir/include/mlir/Conversion/AffineToStandard/AffineToStandard.h --- a/mlir/include/mlir/Conversion/AffineToStandard/AffineToStandard.h +++ b/mlir/include/mlir/Conversion/AffineToStandard/AffineToStandard.h @@ -42,12 +42,11 @@ /// Collect a set of patterns to convert from the Affine dialect to the Standard /// dialect, in particular convert structured affine control flow into CFG /// branch-based control flow. -void populateAffineToStdConversionPatterns(OwningRewritePatternList &patterns); +void populateAffineToStdConversionPatterns(RewritePatternSet &patterns); /// Collect a set of patterns to convert vector-related Affine ops to the Vector /// dialect. -void populateAffineToVectorConversionPatterns( - OwningRewritePatternList &patterns); +void populateAffineToVectorConversionPatterns(RewritePatternSet &patterns); /// Emit code that computes the lower bound of the given affine loop using /// standard arithmetic operations. diff --git a/mlir/include/mlir/Conversion/ArmSVEToLLVM/ArmSVEToLLVM.h b/mlir/include/mlir/Conversion/ArmSVEToLLVM/ArmSVEToLLVM.h --- a/mlir/include/mlir/Conversion/ArmSVEToLLVM/ArmSVEToLLVM.h +++ b/mlir/include/mlir/Conversion/ArmSVEToLLVM/ArmSVEToLLVM.h @@ -17,7 +17,7 @@ /// Collect a set of patterns to convert from the ArmSVE dialect to LLVM. void populateArmSVEToLLVMConversionPatterns(LLVMTypeConverter &converter, - OwningRewritePatternList &patterns); + RewritePatternSet &patterns); } // namespace mlir diff --git a/mlir/include/mlir/Conversion/AsyncToLLVM/AsyncToLLVM.h b/mlir/include/mlir/Conversion/AsyncToLLVM/AsyncToLLVM.h --- a/mlir/include/mlir/Conversion/AsyncToLLVM/AsyncToLLVM.h +++ b/mlir/include/mlir/Conversion/AsyncToLLVM/AsyncToLLVM.h @@ -34,7 +34,7 @@ /// the TypeConverter, but otherwise don't care what type conversions are /// happening. void populateAsyncStructuralTypeConversionsAndLegality( - TypeConverter &typeConverter, OwningRewritePatternList &patterns, + TypeConverter &typeConverter, RewritePatternSet &patterns, ConversionTarget &target); } // namespace mlir diff --git a/mlir/include/mlir/Conversion/ComplexToLLVM/ComplexToLLVM.h b/mlir/include/mlir/Conversion/ComplexToLLVM/ComplexToLLVM.h --- a/mlir/include/mlir/Conversion/ComplexToLLVM/ComplexToLLVM.h +++ b/mlir/include/mlir/Conversion/ComplexToLLVM/ComplexToLLVM.h @@ -18,8 +18,8 @@ class OperationPass; /// Populate the given list with patterns that convert from Complex to LLVM. -void populateComplexToLLVMConversionPatterns( - LLVMTypeConverter &converter, OwningRewritePatternList &patterns); +void populateComplexToLLVMConversionPatterns(LLVMTypeConverter &converter, + RewritePatternSet &patterns); /// Create a pass to convert Complex operations to the LLVMIR dialect. std::unique_ptr> createConvertComplexToLLVMPass(); diff --git a/mlir/include/mlir/Conversion/GPUToNVVM/GPUToNVVMPass.h b/mlir/include/mlir/Conversion/GPUToNVVM/GPUToNVVMPass.h --- a/mlir/include/mlir/Conversion/GPUToNVVM/GPUToNVVMPass.h +++ b/mlir/include/mlir/Conversion/GPUToNVVM/GPUToNVVMPass.h @@ -29,7 +29,7 @@ /// Collect a set of patterns to convert from the GPU dialect to NVVM. void populateGpuToNVVMConversionPatterns(LLVMTypeConverter &converter, - OwningRewritePatternList &patterns); + RewritePatternSet &patterns); /// Creates a pass that lowers GPU dialect operations to NVVM counterparts. The /// index bitwidth used for the lowering of the device side index computations diff --git a/mlir/include/mlir/Conversion/GPUToROCDL/GPUToROCDLPass.h b/mlir/include/mlir/Conversion/GPUToROCDL/GPUToROCDLPass.h --- a/mlir/include/mlir/Conversion/GPUToROCDL/GPUToROCDLPass.h +++ b/mlir/include/mlir/Conversion/GPUToROCDL/GPUToROCDLPass.h @@ -26,7 +26,7 @@ /// Collect a set of patterns to convert from the GPU dialect to ROCDL. void populateGpuToROCDLConversionPatterns(LLVMTypeConverter &converter, - OwningRewritePatternList &patterns); + RewritePatternSet &patterns); /// Configure target to convert from the GPU dialect to ROCDL. void configureGpuToROCDLConversionLegality(ConversionTarget &target); diff --git a/mlir/include/mlir/Conversion/GPUToSPIRV/GPUToSPIRV.h b/mlir/include/mlir/Conversion/GPUToSPIRV/GPUToSPIRV.h --- a/mlir/include/mlir/Conversion/GPUToSPIRV/GPUToSPIRV.h +++ b/mlir/include/mlir/Conversion/GPUToSPIRV/GPUToSPIRV.h @@ -22,7 +22,7 @@ /// SPIR-V ops. For a gpu.func to be converted, it should have a /// spv.entry_point_abi attribute. void populateGPUToSPIRVPatterns(SPIRVTypeConverter &typeConverter, - OwningRewritePatternList &patterns); + RewritePatternSet &patterns); } // namespace mlir #endif // MLIR_CONVERSION_GPUTOSPIRV_GPUTOSPIRV_H diff --git a/mlir/include/mlir/Conversion/LinalgToLLVM/LinalgToLLVM.h b/mlir/include/mlir/Conversion/LinalgToLLVM/LinalgToLLVM.h --- a/mlir/include/mlir/Conversion/LinalgToLLVM/LinalgToLLVM.h +++ b/mlir/include/mlir/Conversion/LinalgToLLVM/LinalgToLLVM.h @@ -14,11 +14,12 @@ namespace mlir { class MLIRContext; class ModuleOp; -template class OperationPass; +template +class OperationPass; /// Populate the given list with patterns that convert from Linalg to LLVM. void populateLinalgToLLVMConversionPatterns(LLVMTypeConverter &converter, - OwningRewritePatternList &patterns); + RewritePatternSet &patterns); /// Create a pass to convert Linalg operations to the LLVMIR dialect. std::unique_ptr> createConvertLinalgToLLVMPass(); diff --git a/mlir/include/mlir/Conversion/LinalgToSPIRV/LinalgToSPIRV.h b/mlir/include/mlir/Conversion/LinalgToSPIRV/LinalgToSPIRV.h --- a/mlir/include/mlir/Conversion/LinalgToSPIRV/LinalgToSPIRV.h +++ b/mlir/include/mlir/Conversion/LinalgToSPIRV/LinalgToSPIRV.h @@ -22,7 +22,7 @@ /// Appends to a pattern list additional patterns for translating Linalg ops to /// SPIR-V ops. void populateLinalgToSPIRVPatterns(SPIRVTypeConverter &typeConverter, - OwningRewritePatternList &patterns); + RewritePatternSet &patterns); } // namespace mlir diff --git a/mlir/include/mlir/Conversion/LinalgToStandard/LinalgToStandard.h b/mlir/include/mlir/Conversion/LinalgToStandard/LinalgToStandard.h --- a/mlir/include/mlir/Conversion/LinalgToStandard/LinalgToStandard.h +++ b/mlir/include/mlir/Conversion/LinalgToStandard/LinalgToStandard.h @@ -69,8 +69,7 @@ }; /// Populate the given list with patterns that convert from Linalg to Standard. -void populateLinalgToStandardConversionPatterns( - OwningRewritePatternList &patterns); +void populateLinalgToStandardConversionPatterns(RewritePatternSet &patterns); } // namespace linalg diff --git a/mlir/include/mlir/Conversion/OpenMPToLLVM/ConvertOpenMPToLLVM.h b/mlir/include/mlir/Conversion/OpenMPToLLVM/ConvertOpenMPToLLVM.h --- a/mlir/include/mlir/Conversion/OpenMPToLLVM/ConvertOpenMPToLLVM.h +++ b/mlir/include/mlir/Conversion/OpenMPToLLVM/ConvertOpenMPToLLVM.h @@ -21,7 +21,7 @@ /// Populate the given list with patterns that convert from OpenMP to LLVM. void populateOpenMPToLLVMConversionPatterns(LLVMTypeConverter &converter, - OwningRewritePatternList &patterns); + RewritePatternSet &patterns); /// Create a pass to convert OpenMP operations to the LLVMIR dialect. std::unique_ptr> createConvertOpenMPToLLVMPass(); diff --git a/mlir/include/mlir/Conversion/SCFToGPU/SCFToGPU.h b/mlir/include/mlir/Conversion/SCFToGPU/SCFToGPU.h --- a/mlir/include/mlir/Conversion/SCFToGPU/SCFToGPU.h +++ b/mlir/include/mlir/Conversion/SCFToGPU/SCFToGPU.h @@ -43,7 +43,7 @@ /// Adds the conversion pattern from `scf.parallel` to `gpu.launch` to the /// provided pattern list. -void populateParallelLoopToGPUPatterns(OwningRewritePatternList &patterns); +void populateParallelLoopToGPUPatterns(RewritePatternSet &patterns); /// Configures the rewrite target such that only `scf.parallel` operations that /// are not rewritten by the provided patterns are legal. diff --git a/mlir/include/mlir/Conversion/SCFToSPIRV/SCFToSPIRV.h b/mlir/include/mlir/Conversion/SCFToSPIRV/SCFToSPIRV.h --- a/mlir/include/mlir/Conversion/SCFToSPIRV/SCFToSPIRV.h +++ b/mlir/include/mlir/Conversion/SCFToSPIRV/SCFToSPIRV.h @@ -37,7 +37,7 @@ /// loop.terminator to CFG operations within the SPIR-V dialect. void populateSCFToSPIRVPatterns(SPIRVTypeConverter &typeConverter, ScfToSPIRVContext &scfToSPIRVContext, - OwningRewritePatternList &patterns); + RewritePatternSet &patterns); } // namespace mlir #endif // MLIR_CONVERSION_SCFTOSPIRV_SCFTOSPIRV_H_ diff --git a/mlir/include/mlir/Conversion/SCFToStandard/SCFToStandard.h b/mlir/include/mlir/Conversion/SCFToStandard/SCFToStandard.h --- a/mlir/include/mlir/Conversion/SCFToStandard/SCFToStandard.h +++ b/mlir/include/mlir/Conversion/SCFToStandard/SCFToStandard.h @@ -22,7 +22,7 @@ /// Collect a set of patterns to lower from scf.for, scf.if, and /// loop.terminator to CFG operations within the Standard dialect, in particular /// convert structured control flow into CFG branch-based control flow. -void populateLoopToStdConversionPatterns(OwningRewritePatternList &patterns); +void populateLoopToStdConversionPatterns(RewritePatternSet &patterns); /// Creates a pass to convert scf.for, scf.if and loop.terminator ops to CFG. std::unique_ptr createLowerToCFGPass(); diff --git a/mlir/include/mlir/Conversion/SPIRVToLLVM/SPIRVToLLVM.h b/mlir/include/mlir/Conversion/SPIRVToLLVM/SPIRVToLLVM.h --- a/mlir/include/mlir/Conversion/SPIRVToLLVM/SPIRVToLLVM.h +++ b/mlir/include/mlir/Conversion/SPIRVToLLVM/SPIRVToLLVM.h @@ -41,16 +41,16 @@ /// Populates the given list with patterns that convert from SPIR-V to LLVM. void populateSPIRVToLLVMConversionPatterns(LLVMTypeConverter &typeConverter, - OwningRewritePatternList &patterns); + RewritePatternSet &patterns); /// Populates the given list with patterns for function conversion from SPIR-V /// to LLVM. void populateSPIRVToLLVMFunctionConversionPatterns( - LLVMTypeConverter &typeConverter, OwningRewritePatternList &patterns); + LLVMTypeConverter &typeConverter, RewritePatternSet &patterns); /// Populates the given patterns for module conversion from SPIR-V to LLVM. void populateSPIRVToLLVMModuleConversionPatterns( - LLVMTypeConverter &typeConverter, OwningRewritePatternList &patterns); + LLVMTypeConverter &typeConverter, RewritePatternSet &patterns); } // namespace mlir diff --git a/mlir/include/mlir/Conversion/ShapeToStandard/ShapeToStandard.h b/mlir/include/mlir/Conversion/ShapeToStandard/ShapeToStandard.h --- a/mlir/include/mlir/Conversion/ShapeToStandard/ShapeToStandard.h +++ b/mlir/include/mlir/Conversion/ShapeToStandard/ShapeToStandard.h @@ -20,13 +20,12 @@ class RewritePatternSet; using OwningRewritePatternList = RewritePatternSet; -void populateShapeToStandardConversionPatterns( - OwningRewritePatternList &patterns); +void populateShapeToStandardConversionPatterns(RewritePatternSet &patterns); std::unique_ptr> createConvertShapeToStandardPass(); void populateConvertShapeConstraintsConversionPatterns( - OwningRewritePatternList &patterns); + RewritePatternSet &patterns); std::unique_ptr> createConvertShapeConstraintsPass(); diff --git a/mlir/include/mlir/Conversion/StandardToLLVM/ConvertStandardToLLVMPass.h b/mlir/include/mlir/Conversion/StandardToLLVM/ConvertStandardToLLVMPass.h --- a/mlir/include/mlir/Conversion/StandardToLLVM/ConvertStandardToLLVMPass.h +++ b/mlir/include/mlir/Conversion/StandardToLLVM/ConvertStandardToLLVMPass.h @@ -49,27 +49,27 @@ /// Collect a set of patterns to convert memory-related operations from the /// Standard dialect to the LLVM dialect, excluding non-memory-related /// operations and FuncOp. -void populateStdToLLVMMemoryConversionPatterns( - LLVMTypeConverter &converter, OwningRewritePatternList &patterns); +void populateStdToLLVMMemoryConversionPatterns(LLVMTypeConverter &converter, + RewritePatternSet &patterns); /// Collect a set of patterns to convert from the Standard dialect to the LLVM /// dialect, excluding the memory-related operations. -void populateStdToLLVMNonMemoryConversionPatterns( - LLVMTypeConverter &converter, OwningRewritePatternList &patterns); +void populateStdToLLVMNonMemoryConversionPatterns(LLVMTypeConverter &converter, + RewritePatternSet &patterns); /// Collect the default pattern to convert a FuncOp to the LLVM dialect. If /// `emitCWrappers` is set, the pattern will also produce functions /// that pass memref descriptors by pointer-to-structure in addition to the /// default unpacked form. -void populateStdToLLVMFuncOpConversionPattern( - LLVMTypeConverter &converter, OwningRewritePatternList &patterns); +void populateStdToLLVMFuncOpConversionPattern(LLVMTypeConverter &converter, + RewritePatternSet &patterns); /// Collect the patterns to convert from the Standard dialect to LLVM. The /// conversion patterns capture the LLVMTypeConverter and the LowerToLLVMOptions /// by reference meaning the references have to remain alive during the entire /// pattern lifetime. void populateStdToLLVMConversionPatterns(LLVMTypeConverter &converter, - OwningRewritePatternList &patterns); + RewritePatternSet &patterns); /// Creates a pass to convert the Standard dialect into the LLVMIR dialect. /// stdlib malloc/free is used by default for allocating memrefs allocated with diff --git a/mlir/include/mlir/Conversion/StandardToSPIRV/StandardToSPIRV.h b/mlir/include/mlir/Conversion/StandardToSPIRV/StandardToSPIRV.h --- a/mlir/include/mlir/Conversion/StandardToSPIRV/StandardToSPIRV.h +++ b/mlir/include/mlir/Conversion/StandardToSPIRV/StandardToSPIRV.h @@ -22,7 +22,7 @@ /// to SPIR-V ops. Also adds the patterns to legalize ops not directly /// translated to SPIR-V dialect. void populateStandardToSPIRVPatterns(SPIRVTypeConverter &typeConverter, - OwningRewritePatternList &patterns); + RewritePatternSet &patterns); /// Appends to a pattern list additional patterns for translating tensor ops /// to SPIR-V ops. @@ -38,12 +38,12 @@ /// threshold is used to control when the patterns should kick in. void populateTensorToSPIRVPatterns(SPIRVTypeConverter &typeConverter, int64_t byteCountThreshold, - OwningRewritePatternList &patterns); + RewritePatternSet &patterns); /// Appends to a pattern list patterns to legalize ops that are not directly /// lowered to SPIR-V. void populateStdLegalizationPatternsForSPIRVLowering( - OwningRewritePatternList &patterns); + RewritePatternSet &patterns); } // namespace mlir diff --git a/mlir/include/mlir/Conversion/TosaToLinalg/TosaToLinalg.h b/mlir/include/mlir/Conversion/TosaToLinalg/TosaToLinalg.h --- a/mlir/include/mlir/Conversion/TosaToLinalg/TosaToLinalg.h +++ b/mlir/include/mlir/Conversion/TosaToLinalg/TosaToLinalg.h @@ -28,7 +28,7 @@ /// Populates conversion passes from TOSA dialect to Linalg dialect. void populateTosaToLinalgOnTensorsConversionPatterns( - OwningRewritePatternList *patterns); + RewritePatternSet *patterns); } // namespace tosa } // namespace mlir diff --git a/mlir/include/mlir/Conversion/TosaToSCF/TosaToSCF.h b/mlir/include/mlir/Conversion/TosaToSCF/TosaToSCF.h --- a/mlir/include/mlir/Conversion/TosaToSCF/TosaToSCF.h +++ b/mlir/include/mlir/Conversion/TosaToSCF/TosaToSCF.h @@ -20,7 +20,7 @@ std::unique_ptr createTosaToSCF(); -void populateTosaToSCFConversionPatterns(OwningRewritePatternList *patterns); +void populateTosaToSCFConversionPatterns(RewritePatternSet *patterns); /// Populates passes to convert from TOSA to SCF. void addTosaToSCFPasses(OpPassManager &pm); diff --git a/mlir/include/mlir/Conversion/TosaToStandard/TosaToStandard.h b/mlir/include/mlir/Conversion/TosaToStandard/TosaToStandard.h --- a/mlir/include/mlir/Conversion/TosaToStandard/TosaToStandard.h +++ b/mlir/include/mlir/Conversion/TosaToStandard/TosaToStandard.h @@ -20,11 +20,10 @@ std::unique_ptr createTosaToStandard(); -void populateTosaToStandardConversionPatterns( - OwningRewritePatternList *patterns); +void populateTosaToStandardConversionPatterns(RewritePatternSet *patterns); void populateTosaRescaleToStandardConversionPatterns( - OwningRewritePatternList *patterns); + RewritePatternSet *patterns); /// Populates passes to convert from TOSA to Standard. void addTosaToStandardPasses(OpPassManager &pm); diff --git a/mlir/include/mlir/Conversion/VectorToLLVM/ConvertVectorToLLVM.h b/mlir/include/mlir/Conversion/VectorToLLVM/ConvertVectorToLLVM.h --- a/mlir/include/mlir/Conversion/VectorToLLVM/ConvertVectorToLLVM.h +++ b/mlir/include/mlir/Conversion/VectorToLLVM/ConvertVectorToLLVM.h @@ -62,12 +62,12 @@ /// Collect a set of patterns to convert from Vector contractions to LLVM Matrix /// Intrinsics. To lower to assembly, the LLVM flag -lower-matrix-intrinsics /// will be needed when invoking LLVM. -void populateVectorToLLVMMatrixConversionPatterns( - LLVMTypeConverter &converter, OwningRewritePatternList &patterns); +void populateVectorToLLVMMatrixConversionPatterns(LLVMTypeConverter &converter, + RewritePatternSet &patterns); /// Collect a set of patterns to convert from the Vector dialect to LLVM. void populateVectorToLLVMConversionPatterns( - LLVMTypeConverter &converter, OwningRewritePatternList &patterns, + LLVMTypeConverter &converter, RewritePatternSet &patterns, bool reassociateFPReductions = false, bool enableIndexOptimizations = true); /// Create a pass to convert vector operations to the LLVMIR dialect. diff --git a/mlir/include/mlir/Conversion/VectorToROCDL/VectorToROCDL.h b/mlir/include/mlir/Conversion/VectorToROCDL/VectorToROCDL.h --- a/mlir/include/mlir/Conversion/VectorToROCDL/VectorToROCDL.h +++ b/mlir/include/mlir/Conversion/VectorToROCDL/VectorToROCDL.h @@ -19,8 +19,8 @@ using OwningRewritePatternList = RewritePatternSet; /// Collect a set of patterns to convert from the GPU dialect to ROCDL. -void populateVectorToROCDLConversionPatterns( - LLVMTypeConverter &converter, OwningRewritePatternList &patterns); +void populateVectorToROCDLConversionPatterns(LLVMTypeConverter &converter, + RewritePatternSet &patterns); /// Create a pass to convert vector operations to the ROCDL dialect. std::unique_ptr> createConvertVectorToROCDLPass(); diff --git a/mlir/include/mlir/Conversion/VectorToSCF/VectorToSCF.h b/mlir/include/mlir/Conversion/VectorToSCF/VectorToSCF.h --- a/mlir/include/mlir/Conversion/VectorToSCF/VectorToSCF.h +++ b/mlir/include/mlir/Conversion/VectorToSCF/VectorToSCF.h @@ -163,7 +163,7 @@ /// Collect a set of patterns to convert from the Vector dialect to SCF + std. void populateVectorToSCFConversionPatterns( - OwningRewritePatternList &patterns, + RewritePatternSet &patterns, const VectorTransferToSCFOptions &options = VectorTransferToSCFOptions()); /// Create a pass to convert a subset of vector ops to SCF. diff --git a/mlir/include/mlir/Conversion/VectorToSPIRV/VectorToSPIRV.h b/mlir/include/mlir/Conversion/VectorToSPIRV/VectorToSPIRV.h --- a/mlir/include/mlir/Conversion/VectorToSPIRV/VectorToSPIRV.h +++ b/mlir/include/mlir/Conversion/VectorToSPIRV/VectorToSPIRV.h @@ -21,7 +21,7 @@ /// Appends to a pattern list additional patterns for translating Vector Ops to /// SPIR-V ops. void populateVectorToSPIRVPatterns(SPIRVTypeConverter &typeConverter, - OwningRewritePatternList &patterns); + RewritePatternSet &patterns); } // namespace mlir diff --git a/mlir/include/mlir/Dialect/AMX/Transforms.h b/mlir/include/mlir/Dialect/AMX/Transforms.h --- a/mlir/include/mlir/Dialect/AMX/Transforms.h +++ b/mlir/include/mlir/Dialect/AMX/Transforms.h @@ -18,8 +18,8 @@ /// Collect a set of patterns to lower AMX ops to ops that map to LLVM /// intrinsics. -void populateAMXLegalizeForLLVMExportPatterns( - LLVMTypeConverter &converter, OwningRewritePatternList &patterns); +void populateAMXLegalizeForLLVMExportPatterns(LLVMTypeConverter &converter, + RewritePatternSet &patterns); /// Configure the target to support lowering AMX ops to ops that map to LLVM /// intrinsics. diff --git a/mlir/include/mlir/Dialect/AVX512/Transforms.h b/mlir/include/mlir/Dialect/AVX512/Transforms.h --- a/mlir/include/mlir/Dialect/AVX512/Transforms.h +++ b/mlir/include/mlir/Dialect/AVX512/Transforms.h @@ -18,8 +18,8 @@ /// Collect a set of patterns to lower AVX512 ops to ops that map to LLVM /// intrinsics. -void populateAVX512LegalizeForLLVMExportPatterns( - LLVMTypeConverter &converter, OwningRewritePatternList &patterns); +void populateAVX512LegalizeForLLVMExportPatterns(LLVMTypeConverter &converter, + RewritePatternSet &patterns); /// Configure the target to support lowering AVX512 ops to ops that map to LLVM /// intrinsics. diff --git a/mlir/include/mlir/Dialect/GPU/Passes.h b/mlir/include/mlir/Dialect/GPU/Passes.h --- a/mlir/include/mlir/Dialect/GPU/Passes.h +++ b/mlir/include/mlir/Dialect/GPU/Passes.h @@ -31,10 +31,10 @@ std::unique_ptr> createGpuAsyncRegionPass(); /// Collect a set of patterns to rewrite all-reduce ops within the GPU dialect. -void populateGpuAllReducePatterns(OwningRewritePatternList &patterns); +void populateGpuAllReducePatterns(RewritePatternSet &patterns); /// Collect all patterns to rewrite ops within the GPU dialect. -inline void populateGpuRewritePatterns(OwningRewritePatternList &patterns) { +inline void populateGpuRewritePatterns(RewritePatternSet &patterns) { populateGpuAllReducePatterns(patterns); } diff --git a/mlir/include/mlir/Dialect/Linalg/Passes.h b/mlir/include/mlir/Dialect/Linalg/Passes.h --- a/mlir/include/mlir/Dialect/Linalg/Passes.h +++ b/mlir/include/mlir/Dialect/Linalg/Passes.h @@ -52,8 +52,7 @@ /// Populate patterns that convert `ElementwiseMappable` ops to linalg /// parallel loops. -void populateElementwiseToLinalgConversionPatterns( - OwningRewritePatternList &patterns); +void populateElementwiseToLinalgConversionPatterns(RewritePatternSet &patterns); /// Create a pass to conver named Linalg operations to Linalg generic /// operations. @@ -66,15 +65,13 @@ /// Patterns to fold an expanding (collapsing) tensor_reshape operation with its /// producer (consumer) generic operation by expanding the dimensionality of the /// loop in the generic op. -void populateFoldReshapeOpsByExpansionPatterns( - OwningRewritePatternList &patterns); +void populateFoldReshapeOpsByExpansionPatterns(RewritePatternSet &patterns); /// Patterns to fold a collapsing (expanding) tensor_reshape operation with its /// producer (consumer) generic/indexed_generic operation by linearizing the /// indexing map used to access the source (target) of the reshape operation in /// the generic/indexed_generic operation. -void populateFoldReshapeOpsByLinearizationPatterns( - OwningRewritePatternList &patterns); +void populateFoldReshapeOpsByLinearizationPatterns(RewritePatternSet &patterns); /// Patterns to fold a collapsing (expanding) tensor_reshape operation with its /// producer (consumer) generic/indexed_generic operation by linearizing the @@ -83,15 +80,14 @@ /// the tensor reshape involved is collapsing (introducing) unit-extent /// dimensions. void populateFoldUnitDimsReshapeOpsByLinearizationPatterns( - OwningRewritePatternList &patterns); + RewritePatternSet &patterns); /// Patterns for fusing linalg operation on tensors. -void populateLinalgTensorOpsFusionPatterns(OwningRewritePatternList &patterns); +void populateLinalgTensorOpsFusionPatterns(RewritePatternSet &patterns); /// Patterns to fold unit-extent dimensions in operands/results of linalg ops on /// tensors. -void populateLinalgFoldUnitExtentDimsPatterns( - OwningRewritePatternList &patterns); +void populateLinalgFoldUnitExtentDimsPatterns(RewritePatternSet &patterns); //===----------------------------------------------------------------------===// // Registration diff --git a/mlir/include/mlir/Dialect/Linalg/Transforms/CodegenStrategy.h b/mlir/include/mlir/Dialect/Linalg/Transforms/CodegenStrategy.h --- a/mlir/include/mlir/Dialect/Linalg/Transforms/CodegenStrategy.h +++ b/mlir/include/mlir/Dialect/Linalg/Transforms/CodegenStrategy.h @@ -24,7 +24,7 @@ explicit Transformation(linalg::LinalgTransformationFilter::FilterFunction f) : filter(f) {} virtual ~Transformation() = default; - virtual OwningRewritePatternList + virtual RewritePatternSet buildRewritePatterns(MLIRContext *context, linalg::LinalgTransformationFilter m) = 0; linalg::LinalgTransformationFilter::FilterFunction filter = nullptr; @@ -35,33 +35,32 @@ typename OptionsType, typename = std::enable_if_t::value>> -void sfinae_enqueue(OwningRewritePatternList &patternList, OptionsType options, +void sfinae_enqueue(RewritePatternSet &patternList, OptionsType options, StringRef opName, linalg::LinalgTransformationFilter m) { assert(opName == ConcreteOpType::getOperationName() && "explicit name must match ConcreteOpType::getOperationName"); - patternList.insert>(patternList.getContext(), - options, m); + patternList.add>(patternList.getContext(), + options, m); } /// SFINAE: Enqueue helper for OpType that do not have a `getOperationName` /// (e.g. LinalgOp, other interfaces, Operation*). template