From 549e190236f638c087fca664d8823a268efdf5c8 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Mon, 22 Mar 2021 15:02:04 -0700 Subject: [PATCH] [PatternRewriter] Rename OwningRewritePatternList -> RewritePatternSet and insert -> add This maintains the old name to have minimal source impact on downstream codes, and does not do the huge mechanical patch. I expect the huge mechanical patch to land sometime this week, but we can keep around the old names for a couple weeks to reduce impact on downstream projects. Differential Revision: https://reviews.llvm.org/D99119 --- .../Conversion/AffineToStandard/AffineToStandard.h | 4 +- .../mlir/Conversion/ArmSVEToLLVM/ArmSVEToLLVM.h | 3 +- .../mlir/Conversion/AsyncToLLVM/AsyncToLLVM.h | 3 +- .../mlir/Conversion/GPUCommon/GPUCommonPass.h | 3 +- .../mlir/Conversion/GPUToNVVM/GPUToNVVMPass.h | 6 +- .../mlir/Conversion/GPUToROCDL/GPUToROCDLPass.h | 3 +- .../mlir/Conversion/LinalgToSPIRV/LinalgToSPIRV.h | 3 +- .../Conversion/OpenMPToLLVM/ConvertOpenMPToLLVM.h | 5 +- mlir/include/mlir/Conversion/SCFToGPU/SCFToGPU.h | 3 +- .../mlir/Conversion/SCFToSPIRV/SCFToSPIRV.h | 3 +- .../mlir/Conversion/SCFToStandard/SCFToStandard.h | 5 +- .../Conversion/ShapeToStandard/ShapeToStandard.h | 3 +- .../StandardToLLVM/ConvertStandardToLLVMPass.h | 3 +- .../mlir/Conversion/VectorToROCDL/VectorToROCDL.h | 3 +- .../mlir/Conversion/VectorToSCF/VectorToSCF.h | 3 +- mlir/include/mlir/Dialect/AMX/Transforms.h | 3 +- mlir/include/mlir/Dialect/AVX512/Transforms.h | 3 +- mlir/include/mlir/Dialect/Math/Transforms/Passes.h | 7 +- mlir/include/mlir/Dialect/SCF/Transforms.h | 3 +- .../StandardOps/Transforms/FuncConversions.h | 3 +- .../mlir/Dialect/StandardOps/Transforms/Passes.h | 3 +- .../mlir/Dialect/Tensor/Transforms/Passes.h | 3 +- mlir/include/mlir/Dialect/Vector/VectorOps.h | 3 +- .../include/mlir/Dialect/Vector/VectorTransforms.h | 3 +- mlir/include/mlir/IR/OperationSupport.h | 24 +++-- mlir/include/mlir/IR/PatternMatch.h | 101 +++++++++++++++++---- mlir/lib/Dialect/Math/Transforms/ExpandTanh.cpp | 4 +- 27 files changed, 154 insertions(+), 59 deletions(-) diff --git a/mlir/include/mlir/Conversion/AffineToStandard/AffineToStandard.h b/mlir/include/mlir/Conversion/AffineToStandard/AffineToStandard.h index 8d3301c..8058f5d 100644 --- a/mlir/include/mlir/Conversion/AffineToStandard/AffineToStandard.h +++ b/mlir/include/mlir/Conversion/AffineToStandard/AffineToStandard.h @@ -24,8 +24,8 @@ class RewritePattern; class Value; class ValueRange; -// Owning list of rewriting patterns. -class OwningRewritePatternList; +class RewritePatternSet; +using OwningRewritePatternList = RewritePatternSet; /// Emit code that computes the given affine expression using standard /// arithmetic operations applied to the provided dimension and symbol values. diff --git a/mlir/include/mlir/Conversion/ArmSVEToLLVM/ArmSVEToLLVM.h b/mlir/include/mlir/Conversion/ArmSVEToLLVM/ArmSVEToLLVM.h index 8cba4e9..70170f8 100644 --- a/mlir/include/mlir/Conversion/ArmSVEToLLVM/ArmSVEToLLVM.h +++ b/mlir/include/mlir/Conversion/ArmSVEToLLVM/ArmSVEToLLVM.h @@ -12,7 +12,8 @@ namespace mlir { class LLVMTypeConverter; -class OwningRewritePatternList; +class RewritePatternSet; +using OwningRewritePatternList = RewritePatternSet; /// Collect a set of patterns to convert from the ArmSVE dialect to LLVM. void populateArmSVEToLLVMConversionPatterns(LLVMTypeConverter &converter, diff --git a/mlir/include/mlir/Conversion/AsyncToLLVM/AsyncToLLVM.h b/mlir/include/mlir/Conversion/AsyncToLLVM/AsyncToLLVM.h index 670942a..cf3763f 100644 --- a/mlir/include/mlir/Conversion/AsyncToLLVM/AsyncToLLVM.h +++ b/mlir/include/mlir/Conversion/AsyncToLLVM/AsyncToLLVM.h @@ -18,8 +18,9 @@ class ModuleOp; template class OperationPass; class MLIRContext; -class OwningRewritePatternList; class TypeConverter; +class RewritePatternSet; +using OwningRewritePatternList = RewritePatternSet; /// Create a pass to convert Async operations to the LLVM dialect. std::unique_ptr> createConvertAsyncToLLVMPass(); diff --git a/mlir/include/mlir/Conversion/GPUCommon/GPUCommonPass.h b/mlir/include/mlir/Conversion/GPUCommon/GPUCommonPass.h index 878861e..708a3fe 100644 --- a/mlir/include/mlir/Conversion/GPUCommon/GPUCommonPass.h +++ b/mlir/include/mlir/Conversion/GPUCommon/GPUCommonPass.h @@ -24,7 +24,8 @@ class Location; struct LogicalResult; class ModuleOp; class Operation; -class OwningRewritePatternList; +class RewritePatternSet; +using OwningRewritePatternList = RewritePatternSet; template class OperationPass; diff --git a/mlir/include/mlir/Conversion/GPUToNVVM/GPUToNVVMPass.h b/mlir/include/mlir/Conversion/GPUToNVVM/GPUToNVVMPass.h index 233b947..cdfe5fa 100644 --- a/mlir/include/mlir/Conversion/GPUToNVVM/GPUToNVVMPass.h +++ b/mlir/include/mlir/Conversion/GPUToNVVM/GPUToNVVMPass.h @@ -13,10 +13,12 @@ namespace mlir { class LLVMTypeConverter; -class OwningRewritePatternList; class ConversionTarget; +class RewritePatternSet; +using OwningRewritePatternList = RewritePatternSet; -template class OperationPass; +template +class OperationPass; namespace gpu { class GPUModuleOp; diff --git a/mlir/include/mlir/Conversion/GPUToROCDL/GPUToROCDLPass.h b/mlir/include/mlir/Conversion/GPUToROCDL/GPUToROCDLPass.h index 5fa798b..e298d2d 100644 --- a/mlir/include/mlir/Conversion/GPUToROCDL/GPUToROCDLPass.h +++ b/mlir/include/mlir/Conversion/GPUToROCDL/GPUToROCDLPass.h @@ -13,8 +13,9 @@ namespace mlir { class LLVMTypeConverter; -class OwningRewritePatternList; class ConversionTarget; +class RewritePatternSet; +using OwningRewritePatternList = RewritePatternSet; template class OperationPass; diff --git a/mlir/include/mlir/Conversion/LinalgToSPIRV/LinalgToSPIRV.h b/mlir/include/mlir/Conversion/LinalgToSPIRV/LinalgToSPIRV.h index 8f94597..f05e9d5 100644 --- a/mlir/include/mlir/Conversion/LinalgToSPIRV/LinalgToSPIRV.h +++ b/mlir/include/mlir/Conversion/LinalgToSPIRV/LinalgToSPIRV.h @@ -15,8 +15,9 @@ namespace mlir { class MLIRContext; -class OwningRewritePatternList; class SPIRVTypeConverter; +class RewritePatternSet; +using OwningRewritePatternList = RewritePatternSet; /// Appends to a pattern list additional patterns for translating Linalg ops to /// SPIR-V ops. diff --git a/mlir/include/mlir/Conversion/OpenMPToLLVM/ConvertOpenMPToLLVM.h b/mlir/include/mlir/Conversion/OpenMPToLLVM/ConvertOpenMPToLLVM.h index 4eae84c..5092322 100644 --- a/mlir/include/mlir/Conversion/OpenMPToLLVM/ConvertOpenMPToLLVM.h +++ b/mlir/include/mlir/Conversion/OpenMPToLLVM/ConvertOpenMPToLLVM.h @@ -8,7 +8,7 @@ #ifndef MLIR_CONVERSION_OPENMPTOLLVM_OPENMPTOLLVM_H_ #define MLIR_CONVERSION_OPENMPTOLLVM_OPENMPTOLLVM_H_ -#include +#include namespace mlir { class LLVMTypeConverter; @@ -16,7 +16,8 @@ class MLIRContext; class ModuleOp; template class OperationPass; -class OwningRewritePatternList; +class RewritePatternSet; +using OwningRewritePatternList = RewritePatternSet; /// Populate the given list with patterns that convert from OpenMP to LLVM. void populateOpenMPToLLVMConversionPatterns(LLVMTypeConverter &converter, diff --git a/mlir/include/mlir/Conversion/SCFToGPU/SCFToGPU.h b/mlir/include/mlir/Conversion/SCFToGPU/SCFToGPU.h index 14c1608..a27c408 100644 --- a/mlir/include/mlir/Conversion/SCFToGPU/SCFToGPU.h +++ b/mlir/include/mlir/Conversion/SCFToGPU/SCFToGPU.h @@ -15,8 +15,9 @@ class AffineForOp; class ConversionTarget; struct LogicalResult; class MLIRContext; -class OwningRewritePatternList; class Value; +class RewritePatternSet; +using OwningRewritePatternList = RewritePatternSet; namespace scf { class ForOp; diff --git a/mlir/include/mlir/Conversion/SCFToSPIRV/SCFToSPIRV.h b/mlir/include/mlir/Conversion/SCFToSPIRV/SCFToSPIRV.h index 5a14c9b..14679f4 100644 --- a/mlir/include/mlir/Conversion/SCFToSPIRV/SCFToSPIRV.h +++ b/mlir/include/mlir/Conversion/SCFToSPIRV/SCFToSPIRV.h @@ -18,9 +18,10 @@ namespace mlir { class Pass; // Owning list of rewriting patterns. -class OwningRewritePatternList; class SPIRVTypeConverter; struct ScfToSPIRVContextImpl; +class RewritePatternSet; +using OwningRewritePatternList = RewritePatternSet; struct ScfToSPIRVContext { ScfToSPIRVContext(); diff --git a/mlir/include/mlir/Conversion/SCFToStandard/SCFToStandard.h b/mlir/include/mlir/Conversion/SCFToStandard/SCFToStandard.h index 95667d8..fc12079 100644 --- a/mlir/include/mlir/Conversion/SCFToStandard/SCFToStandard.h +++ b/mlir/include/mlir/Conversion/SCFToStandard/SCFToStandard.h @@ -15,10 +15,9 @@ namespace mlir { struct LogicalResult; class Pass; -class RewritePattern; -// Owning list of rewriting patterns. -class OwningRewritePatternList; +class RewritePatternSet; +using OwningRewritePatternList = RewritePatternSet; /// Collect a set of patterns to lower from scf.for, scf.if, and /// loop.terminator to CFG operations within the Standard dialect, in particular diff --git a/mlir/include/mlir/Conversion/ShapeToStandard/ShapeToStandard.h b/mlir/include/mlir/Conversion/ShapeToStandard/ShapeToStandard.h index 7c94470..3ab3ee7 100644 --- a/mlir/include/mlir/Conversion/ShapeToStandard/ShapeToStandard.h +++ b/mlir/include/mlir/Conversion/ShapeToStandard/ShapeToStandard.h @@ -17,7 +17,8 @@ class FuncOp; class ModuleOp; template class OperationPass; -class OwningRewritePatternList; +class RewritePatternSet; +using OwningRewritePatternList = RewritePatternSet; void populateShapeToStandardConversionPatterns( OwningRewritePatternList &patterns); diff --git a/mlir/include/mlir/Conversion/StandardToLLVM/ConvertStandardToLLVMPass.h b/mlir/include/mlir/Conversion/StandardToLLVM/ConvertStandardToLLVMPass.h index ca623a3..e9ee9e9 100644 --- a/mlir/include/mlir/Conversion/StandardToLLVM/ConvertStandardToLLVMPass.h +++ b/mlir/include/mlir/Conversion/StandardToLLVM/ConvertStandardToLLVMPass.h @@ -18,7 +18,8 @@ class LLVMTypeConverter; class ModuleOp; template class OperationPass; -class OwningRewritePatternList; +class RewritePatternSet; +using OwningRewritePatternList = RewritePatternSet; /// Value to pass as bitwidth for the index type when the converter is expected /// to derive the bitwidth from the LLVM data layout. diff --git a/mlir/include/mlir/Conversion/VectorToROCDL/VectorToROCDL.h b/mlir/include/mlir/Conversion/VectorToROCDL/VectorToROCDL.h index 660de02..7f0859c 100644 --- a/mlir/include/mlir/Conversion/VectorToROCDL/VectorToROCDL.h +++ b/mlir/include/mlir/Conversion/VectorToROCDL/VectorToROCDL.h @@ -12,10 +12,11 @@ namespace mlir { class LLVMTypeConverter; -class OwningRewritePatternList; class ModuleOp; template class OperationPass; +class RewritePatternSet; +using OwningRewritePatternList = RewritePatternSet; /// Collect a set of patterns to convert from the GPU dialect to ROCDL. void populateVectorToROCDLConversionPatterns( diff --git a/mlir/include/mlir/Conversion/VectorToSCF/VectorToSCF.h b/mlir/include/mlir/Conversion/VectorToSCF/VectorToSCF.h index e7478cf..561a3e9 100644 --- a/mlir/include/mlir/Conversion/VectorToSCF/VectorToSCF.h +++ b/mlir/include/mlir/Conversion/VectorToSCF/VectorToSCF.h @@ -13,8 +13,9 @@ namespace mlir { class MLIRContext; -class OwningRewritePatternList; class Pass; +class RewritePatternSet; +using OwningRewritePatternList = RewritePatternSet; /// Control whether unrolling is used when lowering vector transfer ops to SCF. /// diff --git a/mlir/include/mlir/Dialect/AMX/Transforms.h b/mlir/include/mlir/Dialect/AMX/Transforms.h index 11b3004..1fccbb5 100644 --- a/mlir/include/mlir/Dialect/AMX/Transforms.h +++ b/mlir/include/mlir/Dialect/AMX/Transforms.h @@ -13,7 +13,8 @@ namespace mlir { class LLVMConversionTarget; class LLVMTypeConverter; -class OwningRewritePatternList; +class RewritePatternSet; +using OwningRewritePatternList = RewritePatternSet; /// Collect a set of patterns to lower 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 index 3506f50d..5418336 100644 --- a/mlir/include/mlir/Dialect/AVX512/Transforms.h +++ b/mlir/include/mlir/Dialect/AVX512/Transforms.h @@ -13,7 +13,8 @@ namespace mlir { class LLVMConversionTarget; class LLVMTypeConverter; -class OwningRewritePatternList; +class RewritePatternSet; +using OwningRewritePatternList = RewritePatternSet; /// Collect a set of patterns to lower AVX512 ops to ops that map to LLVM /// intrinsics. diff --git a/mlir/include/mlir/Dialect/Math/Transforms/Passes.h b/mlir/include/mlir/Dialect/Math/Transforms/Passes.h index 3ce88a13..1063566 100644 --- a/mlir/include/mlir/Dialect/Math/Transforms/Passes.h +++ b/mlir/include/mlir/Dialect/Math/Transforms/Passes.h @@ -11,12 +11,11 @@ namespace mlir { -class OwningRewritePatternList; +class RewritePatternSet; -void populateExpandTanhPattern(OwningRewritePatternList &patterns); +void populateExpandTanhPattern(RewritePatternSet &patterns); -void populateMathPolynomialApproximationPatterns( - OwningRewritePatternList &patterns); +void populateMathPolynomialApproximationPatterns(RewritePatternSet &patterns); } // namespace mlir diff --git a/mlir/include/mlir/Dialect/SCF/Transforms.h b/mlir/include/mlir/Dialect/SCF/Transforms.h index 914a1a0..94473af 100644 --- a/mlir/include/mlir/Dialect/SCF/Transforms.h +++ b/mlir/include/mlir/Dialect/SCF/Transforms.h @@ -19,9 +19,10 @@ namespace mlir { class ConversionTarget; class MLIRContext; -class OwningRewritePatternList; class Region; class TypeConverter; +class RewritePatternSet; +using OwningRewritePatternList = RewritePatternSet; namespace scf { diff --git a/mlir/include/mlir/Dialect/StandardOps/Transforms/FuncConversions.h b/mlir/include/mlir/Dialect/StandardOps/Transforms/FuncConversions.h index a7eb59a..6e0abfc 100644 --- a/mlir/include/mlir/Dialect/StandardOps/Transforms/FuncConversions.h +++ b/mlir/include/mlir/Dialect/StandardOps/Transforms/FuncConversions.h @@ -19,8 +19,9 @@ namespace mlir { class ConversionTarget; class MLIRContext; class Operation; -class OwningRewritePatternList; class TypeConverter; +class RewritePatternSet; +using OwningRewritePatternList = RewritePatternSet; /// Add a pattern to the given pattern list to convert the operand and result /// types of a CallOp with the given type converter. diff --git a/mlir/include/mlir/Dialect/StandardOps/Transforms/Passes.h b/mlir/include/mlir/Dialect/StandardOps/Transforms/Passes.h index 1e04b22..6e95dae 100644 --- a/mlir/include/mlir/Dialect/StandardOps/Transforms/Passes.h +++ b/mlir/include/mlir/Dialect/StandardOps/Transforms/Passes.h @@ -19,7 +19,8 @@ namespace mlir { -class OwningRewritePatternList; +class RewritePatternSet; +using OwningRewritePatternList = RewritePatternSet; void populateStdBufferizePatterns(BufferizeTypeConverter &typeConverter, OwningRewritePatternList &patterns); diff --git a/mlir/include/mlir/Dialect/Tensor/Transforms/Passes.h b/mlir/include/mlir/Dialect/Tensor/Transforms/Passes.h index 72539c8..dc1fd7e9 100644 --- a/mlir/include/mlir/Dialect/Tensor/Transforms/Passes.h +++ b/mlir/include/mlir/Dialect/Tensor/Transforms/Passes.h @@ -14,7 +14,8 @@ namespace mlir { -class OwningRewritePatternList; +class RewritePatternSet; +using OwningRewritePatternList = RewritePatternSet; void populateTensorBufferizePatterns(BufferizeTypeConverter &typeConverter, OwningRewritePatternList &patterns); diff --git a/mlir/include/mlir/Dialect/Vector/VectorOps.h b/mlir/include/mlir/Dialect/Vector/VectorOps.h index 7d20e64..456cc88 100644 --- a/mlir/include/mlir/Dialect/Vector/VectorOps.h +++ b/mlir/include/mlir/Dialect/Vector/VectorOps.h @@ -28,7 +28,8 @@ namespace mlir { class MLIRContext; -class OwningRewritePatternList; +class RewritePatternSet; +using OwningRewritePatternList = RewritePatternSet; namespace vector { class VectorDialect; diff --git a/mlir/include/mlir/Dialect/Vector/VectorTransforms.h b/mlir/include/mlir/Dialect/Vector/VectorTransforms.h index ff3dbfd..9a0d553 100644 --- a/mlir/include/mlir/Dialect/Vector/VectorTransforms.h +++ b/mlir/include/mlir/Dialect/Vector/VectorTransforms.h @@ -16,8 +16,9 @@ namespace mlir { class MLIRContext; -class OwningRewritePatternList; class VectorTransferOpInterface; +class RewritePatternSet; +using OwningRewritePatternList = RewritePatternSet; namespace scf { class IfOp; diff --git a/mlir/include/mlir/IR/OperationSupport.h b/mlir/include/mlir/IR/OperationSupport.h index 60af4b0..19173d1 100644 --- a/mlir/include/mlir/IR/OperationSupport.h +++ b/mlir/include/mlir/IR/OperationSupport.h @@ -51,9 +51,11 @@ class RewritePattern; class Type; class Value; class ValueRange; -template class ValueTypeRange; +template +class ValueTypeRange; -class OwningRewritePatternList; +class RewritePatternSet; +using OwningRewritePatternList = RewritePatternSet; //===----------------------------------------------------------------------===// // AbstractOperation @@ -132,12 +134,14 @@ public: /// Returns an instance of the concept object for the given interface if it /// was registered to this operation, null otherwise. This should not be used /// directly. - template typename T::Concept *getInterface() const { + template + typename T::Concept *getInterface() const { return interfaceMap.lookup(); } /// Returns true if the operation has a particular trait. - template