[flang-commits] [flang] [mlir] [mlir][NFC] Mark type converter in `populate...` functions as `const` (PR #111250)

via flang-commits flang-commits at lists.llvm.org
Sat Oct 5 05:03:59 PDT 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-mlir-bufferization
@llvm/pr-subscribers-mlir-spirv

@llvm/pr-subscribers-backend-amdgpu

Author: Matthias Springer (matthias-springer)

<details>
<summary>Changes</summary>

This commit marks the type converter in `populate...` functions as `const`. This is useful for debugging.

Patterns already take a `const` type converter. However, some `populate...` functions do not only add new patterns, but also add additional type conversion rules. That makes it difficult to find the place where a type conversion was added in the code base. With this change, all `populate...` functions that only populate pattern now have a `const` type converter. Programmers can then conclude from the function signature that these functions do not register any new type conversion rules.

Also some minor cleanups around the 1:N dialect conversion infrastructure, which did not always pass the type converter as a `const` object internally.


---

Patch is 140.85 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/111250.diff


115 Files Affected:

- (modified) flang/include/flang/Optimizer/CodeGen/CodeGen.h (+3-3) 
- (modified) flang/include/flang/Optimizer/CodeGen/CodeGenOpenMP.h (+1-1) 
- (modified) flang/include/flang/Optimizer/Transforms/CufOpConversion.h (+1-1) 
- (modified) flang/lib/Optimizer/CodeGen/CodeGen.cpp (+1-1) 
- (modified) flang/lib/Optimizer/CodeGen/CodeGenOpenMP.cpp (+1-1) 
- (modified) flang/lib/Optimizer/Transforms/CufOpConversion.cpp (+1-1) 
- (modified) mlir/docs/Bufferization.md (+1-1) 
- (modified) mlir/include/mlir/Conversion/AMDGPUToROCDL/AMDGPUToROCDL.h (+1-1) 
- (modified) mlir/include/mlir/Conversion/ArithToLLVM/ArithToLLVM.h (+1-1) 
- (modified) mlir/include/mlir/Conversion/ArithToSPIRV/ArithToSPIRV.h (+1-1) 
- (modified) mlir/include/mlir/Conversion/ComplexToLLVM/ComplexToLLVM.h (+1-1) 
- (modified) mlir/include/mlir/Conversion/ComplexToSPIRV/ComplexToSPIRV.h (+1-1) 
- (modified) mlir/include/mlir/Conversion/ControlFlowToLLVM/ControlFlowToLLVM.h (+3-3) 
- (modified) mlir/include/mlir/Conversion/ControlFlowToSPIRV/ControlFlowToSPIRV.h (+1-1) 
- (modified) mlir/include/mlir/Conversion/FuncToLLVM/ConvertFuncToLLVM.h (+3-3) 
- (modified) mlir/include/mlir/Conversion/FuncToSPIRV/FuncToSPIRV.h (+1-1) 
- (modified) mlir/include/mlir/Conversion/GPUToLLVMSPV/GPUToLLVMSPVPass.h (+1-1) 
- (modified) mlir/include/mlir/Conversion/GPUToNVVM/GPUToNVVMPass.h (+4-4) 
- (modified) mlir/include/mlir/Conversion/GPUToROCDL/GPUToROCDLPass.h (+1-1) 
- (modified) mlir/include/mlir/Conversion/GPUToSPIRV/GPUToSPIRV.h (+2-2) 
- (modified) mlir/include/mlir/Conversion/IndexToLLVM/IndexToLLVM.h (+1-1) 
- (modified) mlir/include/mlir/Conversion/IndexToSPIRV/IndexToSPIRV.h (+1-1) 
- (modified) mlir/include/mlir/Conversion/MathToLLVM/MathToLLVM.h (+1-1) 
- (modified) mlir/include/mlir/Conversion/MathToROCDL/MathToROCDL.h (+1-1) 
- (modified) mlir/include/mlir/Conversion/MathToSPIRV/MathToSPIRV.h (+1-1) 
- (modified) mlir/include/mlir/Conversion/MemRefToEmitC/MemRefToEmitC.h (+1-1) 
- (modified) mlir/include/mlir/Conversion/MemRefToLLVM/MemRefToLLVM.h (+1-1) 
- (modified) mlir/include/mlir/Conversion/MemRefToSPIRV/MemRefToSPIRV.h (+1-1) 
- (modified) mlir/include/mlir/Conversion/NVGPUToNVVM/NVGPUToNVVM.h (+1-1) 
- (modified) mlir/include/mlir/Conversion/OpenMPToLLVM/ConvertOpenMPToLLVM.h (+2-2) 
- (modified) mlir/include/mlir/Conversion/SCFToSPIRV/SCFToSPIRV.h (+1-1) 
- (modified) mlir/include/mlir/Conversion/SPIRVToLLVM/SPIRVToLLVM.h (+10-7) 
- (modified) mlir/include/mlir/Conversion/TensorToSPIRV/TensorToSPIRV.h (+1-1) 
- (modified) mlir/include/mlir/Conversion/TosaToLinalg/TosaToLinalg.h (+1-1) 
- (modified) mlir/include/mlir/Conversion/TosaToTensor/TosaToTensor.h (+1-1) 
- (modified) mlir/include/mlir/Conversion/UBToLLVM/UBToLLVM.h (+1-1) 
- (modified) mlir/include/mlir/Conversion/UBToSPIRV/UBToSPIRV.h (+1-1) 
- (modified) mlir/include/mlir/Conversion/VectorToLLVM/ConvertVectorToLLVM.h (+3-3) 
- (modified) mlir/include/mlir/Conversion/VectorToSPIRV/VectorToSPIRV.h (+1-1) 
- (modified) mlir/include/mlir/Dialect/AMX/Transforms.h (+2-2) 
- (modified) mlir/include/mlir/Dialect/Arith/Transforms/Passes.h (+6-4) 
- (modified) mlir/include/mlir/Dialect/ArmSVE/Transforms/Transforms.h (+2-2) 
- (modified) mlir/include/mlir/Dialect/Bufferization/Transforms/Bufferize.h (+1-1) 
- (modified) mlir/include/mlir/Dialect/Func/Transforms/DecomposeCallGraphTypes.h (+1-1) 
- (modified) mlir/include/mlir/Dialect/Func/Transforms/FuncConversions.h (+6-6) 
- (modified) mlir/include/mlir/Dialect/Func/Transforms/OneToNFuncConversions.h (+1-1) 
- (modified) mlir/include/mlir/Dialect/Math/Transforms/Passes.h (+1-1) 
- (modified) mlir/include/mlir/Dialect/MemRef/Transforms/Transforms.h (+2-2) 
- (modified) mlir/include/mlir/Dialect/SCF/Transforms/Patterns.h (+4-4) 
- (modified) mlir/include/mlir/Dialect/SPIRV/Transforms/SPIRVConversion.h (+1-1) 
- (modified) mlir/include/mlir/Dialect/SparseTensor/Transforms/Passes.h (+4-4) 
- (modified) mlir/include/mlir/Dialect/Vector/Transforms/VectorRewritePatterns.h (+4-5) 
- (modified) mlir/include/mlir/Dialect/X86Vector/Transforms.h (+1-1) 
- (modified) mlir/include/mlir/Transforms/OneToNTypeConversion.h (+11-10) 
- (modified) mlir/lib/Conversion/AMDGPUToROCDL/AMDGPUToROCDL.cpp (+11-9) 
- (modified) mlir/lib/Conversion/ArithToLLVM/ArithToLLVM.cpp (+1-1) 
- (modified) mlir/lib/Conversion/ArithToSPIRV/ArithToSPIRV.cpp (+1-1) 
- (modified) mlir/lib/Conversion/ComplexToLLVM/ComplexToLLVM.cpp (+1-1) 
- (modified) mlir/lib/Conversion/ComplexToSPIRV/ComplexToSPIRV.cpp (+2-2) 
- (modified) mlir/lib/Conversion/ControlFlowToLLVM/ControlFlowToLLVM.cpp (+3-3) 
- (modified) mlir/lib/Conversion/ControlFlowToSPIRV/ControlFlowToSPIRV.cpp (+1-1) 
- (modified) mlir/lib/Conversion/ConvertToSPIRV/ConvertToSPIRVPass.cpp (+1-1) 
- (modified) mlir/lib/Conversion/FuncToLLVM/FuncToLLVM.cpp (+2-2) 
- (modified) mlir/lib/Conversion/FuncToSPIRV/FuncToSPIRV.cpp (+1-1) 
- (modified) mlir/lib/Conversion/GPUCommon/IndexIntrinsicsOpLowering.h (+2-2) 
- (modified) mlir/lib/Conversion/GPUCommon/OpToFuncCallLowering.h (+1-1) 
- (modified) mlir/lib/Conversion/GPUToLLVMSPV/GPUToLLVMSPV.cpp (+2-2) 
- (modified) mlir/lib/Conversion/GPUToNVVM/LowerGpuOpsToNVVMOps.cpp (+4-4) 
- (modified) mlir/lib/Conversion/GPUToNVVM/WmmaOpsToNvvm.cpp (+1-1) 
- (modified) mlir/lib/Conversion/GPUToROCDL/LowerGpuOpsToROCDLOps.cpp (+2-2) 
- (modified) mlir/lib/Conversion/GPUToSPIRV/GPUToSPIRV.cpp (+3-2) 
- (modified) mlir/lib/Conversion/GPUToSPIRV/WmmaOpsToSPIRV.cpp (+1-1) 
- (modified) mlir/lib/Conversion/IndexToLLVM/IndexToLLVM.cpp (+1-1) 
- (modified) mlir/lib/Conversion/IndexToSPIRV/IndexToSPIRV.cpp (+2-2) 
- (modified) mlir/lib/Conversion/MathToLLVM/MathToLLVM.cpp (+3-3) 
- (modified) mlir/lib/Conversion/MathToROCDL/MathToROCDL.cpp (+3-3) 
- (modified) mlir/lib/Conversion/MathToSPIRV/MathToSPIRV.cpp (+1-1) 
- (modified) mlir/lib/Conversion/MemRefToEmitC/MemRefToEmitC.cpp (+2-2) 
- (modified) mlir/lib/Conversion/MemRefToLLVM/MemRefToLLVM.cpp (+1-1) 
- (modified) mlir/lib/Conversion/MemRefToSPIRV/MemRefToSPIRV.cpp (+1-1) 
- (modified) mlir/lib/Conversion/NVGPUToNVVM/NVGPUToNVVM.cpp (+2-2) 
- (modified) mlir/lib/Conversion/OpenMPToLLVM/OpenMPToLLVM.cpp (+1-1) 
- (modified) mlir/lib/Conversion/SCFToSPIRV/SCFToSPIRV.cpp (+3-3) 
- (modified) mlir/lib/Conversion/SPIRVToLLVM/SPIRVToLLVM.cpp (+54-53) 
- (modified) mlir/lib/Conversion/TensorToSPIRV/TensorToSPIRV.cpp (+4-4) 
- (modified) mlir/lib/Conversion/TosaToLinalg/TosaToLinalg.cpp (+1-1) 
- (modified) mlir/lib/Conversion/TosaToTensor/TosaToTensor.cpp (+40-33) 
- (modified) mlir/lib/Conversion/UBToLLVM/UBToLLVM.cpp (+2-2) 
- (modified) mlir/lib/Conversion/UBToSPIRV/UBToSPIRV.cpp (+1-1) 
- (modified) mlir/lib/Conversion/VectorToLLVM/ConvertVectorToLLVM.cpp (+2-2) 
- (modified) mlir/lib/Conversion/VectorToSPIRV/VectorToSPIRV.cpp (+2-2) 
- (modified) mlir/lib/Dialect/AMX/Transforms/LegalizeForLLVMExport.cpp (+1-1) 
- (modified) mlir/lib/Dialect/Arith/Transforms/EmulateNarrowType.cpp (+2-1) 
- (modified) mlir/lib/Dialect/Arith/Transforms/EmulateUnsupportedFloats.cpp (+3-3) 
- (modified) mlir/lib/Dialect/Arith/Transforms/EmulateWideInt.cpp (+2-1) 
- (modified) mlir/lib/Dialect/ArmSVE/Transforms/LegalizeForLLVMExport.cpp (+1-1) 
- (modified) mlir/lib/Dialect/Bufferization/Transforms/Bufferize.cpp (+1-1) 
- (modified) mlir/lib/Dialect/Func/Transforms/DecomposeCallGraphTypes.cpp (+2-2) 
- (modified) mlir/lib/Dialect/Func/Transforms/FuncConversions.cpp (+8-9) 
- (modified) mlir/lib/Dialect/Func/Transforms/OneToNFuncConversions.cpp (+1-1) 
- (modified) mlir/lib/Dialect/Math/Transforms/ExtendToSupportedTypes.cpp (+2-2) 
- (modified) mlir/lib/Dialect/MemRef/Transforms/EmulateNarrowType.cpp (+1-1) 
- (modified) mlir/lib/Dialect/MemRef/Transforms/EmulateWideInt.cpp (+1-1) 
- (modified) mlir/lib/Dialect/SCF/Transforms/OneToNTypeConversion.cpp (+2-2) 
- (modified) mlir/lib/Dialect/SCF/Transforms/StructuralTypeConversions.cpp (+2-2) 
- (modified) mlir/lib/Dialect/SPIRV/Transforms/SPIRVConversion.cpp (+2-2) 
- (modified) mlir/lib/Dialect/SparseTensor/Transforms/SparseIterationToScf.cpp (+1-1) 
- (modified) mlir/lib/Dialect/SparseTensor/Transforms/SparseStorageSpecifierToLLVM.cpp (+2-2) 
- (modified) mlir/lib/Dialect/SparseTensor/Transforms/SparseTensorCodegen.cpp (+7-7) 
- (modified) mlir/lib/Dialect/SparseTensor/Transforms/SparseTensorConversion.cpp (+2-2) 
- (modified) mlir/lib/Dialect/Vector/Transforms/VectorEmulateNarrowType.cpp (+1-1) 
- (modified) mlir/lib/Dialect/Vector/Transforms/VectorLinearize.cpp (+1-1) 
- (modified) mlir/lib/Dialect/X86Vector/Transforms/LegalizeForLLVMExport.cpp (+3-3) 
- (modified) mlir/lib/Transforms/Utils/OneToNTypeConversion.cpp (+2-2) 
- (modified) mlir/test/lib/Conversion/OneToNTypeConversion/TestOneToNTypeConversionPass.cpp (+3-2) 


``````````diff
diff --git a/flang/include/flang/Optimizer/CodeGen/CodeGen.h b/flang/include/flang/Optimizer/CodeGen/CodeGen.h
index 390f00e1ac77c2..255b1950c84256 100644
--- a/flang/include/flang/Optimizer/CodeGen/CodeGen.h
+++ b/flang/include/flang/Optimizer/CodeGen/CodeGen.h
@@ -72,9 +72,9 @@ std::unique_ptr<mlir::Pass> createLLVMDialectToLLVMPass(
         [](llvm::Module &m, llvm::raw_ostream &out) { m.print(out, nullptr); });
 
 /// Populate the given list with patterns that convert from FIR to LLVM.
-void populateFIRToLLVMConversionPatterns(fir::LLVMTypeConverter &converter,
-                                         mlir::RewritePatternSet &patterns,
-                                         fir::FIRToLLVMPassOptions &options);
+void populateFIRToLLVMConversionPatterns(
+    const fir::LLVMTypeConverter &converter, mlir::RewritePatternSet &patterns,
+    fir::FIRToLLVMPassOptions &options);
 
 /// Populate the pattern set with the PreCGRewrite patterns.
 void populatePreCGRewritePatterns(mlir::RewritePatternSet &patterns,
diff --git a/flang/include/flang/Optimizer/CodeGen/CodeGenOpenMP.h b/flang/include/flang/Optimizer/CodeGen/CodeGenOpenMP.h
index 1832d4967b7ecd..04b59da72f6bae 100644
--- a/flang/include/flang/Optimizer/CodeGen/CodeGenOpenMP.h
+++ b/flang/include/flang/Optimizer/CodeGen/CodeGenOpenMP.h
@@ -19,7 +19,7 @@ class LLVMTypeConverter;
 /// dialect, utilised in cases where the default OpenMP dialect handling cannot
 /// handle all cases for intermingled fir types and operations.
 void populateOpenMPFIRToLLVMConversionPatterns(
-    LLVMTypeConverter &converter, mlir::RewritePatternSet &patterns);
+    const LLVMTypeConverter &converter, mlir::RewritePatternSet &patterns);
 
 } // namespace fir
 
diff --git a/flang/include/flang/Optimizer/Transforms/CufOpConversion.h b/flang/include/flang/Optimizer/Transforms/CufOpConversion.h
index 3e13c72cc0e3e4..79ce4ac5c6cbc0 100644
--- a/flang/include/flang/Optimizer/Transforms/CufOpConversion.h
+++ b/flang/include/flang/Optimizer/Transforms/CufOpConversion.h
@@ -22,7 +22,7 @@ class DataLayout;
 
 namespace cuf {
 
-void populateCUFToFIRConversionPatterns(fir::LLVMTypeConverter &converter,
+void populateCUFToFIRConversionPatterns(const fir::LLVMTypeConverter &converter,
                                         mlir::DataLayout &dl,
                                         mlir::RewritePatternSet &patterns);
 
diff --git a/flang/lib/Optimizer/CodeGen/CodeGen.cpp b/flang/lib/Optimizer/CodeGen/CodeGen.cpp
index 1cb869bfeb95a8..1611de9e6389a5 100644
--- a/flang/lib/Optimizer/CodeGen/CodeGen.cpp
+++ b/flang/lib/Optimizer/CodeGen/CodeGen.cpp
@@ -3823,7 +3823,7 @@ fir::createLLVMDialectToLLVMPass(llvm::raw_ostream &output,
 }
 
 void fir::populateFIRToLLVMConversionPatterns(
-    fir::LLVMTypeConverter &converter, mlir::RewritePatternSet &patterns,
+    const fir::LLVMTypeConverter &converter, mlir::RewritePatternSet &patterns,
     fir::FIRToLLVMPassOptions &options) {
   patterns.insert<
       AbsentOpConversion, AddcOpConversion, AddrOfOpConversion,
diff --git a/flang/lib/Optimizer/CodeGen/CodeGenOpenMP.cpp b/flang/lib/Optimizer/CodeGen/CodeGenOpenMP.cpp
index 48d6c000ee44a3..da13ed648e44e6 100644
--- a/flang/lib/Optimizer/CodeGen/CodeGenOpenMP.cpp
+++ b/flang/lib/Optimizer/CodeGen/CodeGenOpenMP.cpp
@@ -93,6 +93,6 @@ struct MapInfoOpConversion
 } // namespace
 
 void fir::populateOpenMPFIRToLLVMConversionPatterns(
-    LLVMTypeConverter &converter, mlir::RewritePatternSet &patterns) {
+    const LLVMTypeConverter &converter, mlir::RewritePatternSet &patterns) {
   patterns.add<MapInfoOpConversion>(converter);
 }
diff --git a/flang/lib/Optimizer/Transforms/CufOpConversion.cpp b/flang/lib/Optimizer/Transforms/CufOpConversion.cpp
index 24dc8e2354b120..c573506e233599 100644
--- a/flang/lib/Optimizer/Transforms/CufOpConversion.cpp
+++ b/flang/lib/Optimizer/Transforms/CufOpConversion.cpp
@@ -583,7 +583,7 @@ class CufOpConversion : public fir::impl::CufOpConversionBase<CufOpConversion> {
 } // namespace
 
 void cuf::populateCUFToFIRConversionPatterns(
-    fir::LLVMTypeConverter &converter, mlir::DataLayout &dl,
+    const fir::LLVMTypeConverter &converter, mlir::DataLayout &dl,
     mlir::RewritePatternSet &patterns) {
   patterns.insert<CufAllocOpConversion>(patterns.getContext(), &dl, &converter);
   patterns.insert<CufAllocateOpConversion, CufDeallocateOpConversion,
diff --git a/mlir/docs/Bufferization.md b/mlir/docs/Bufferization.md
index 6a49bea9c68c5d..d5a426e09e7ceb 100644
--- a/mlir/docs/Bufferization.md
+++ b/mlir/docs/Bufferization.md
@@ -651,7 +651,7 @@ is very small, and follows the basic pattern of any dialect conversion pass.
 
 ```
 void mlir::populateTensorBufferizePatterns(
-    BufferizeTypeConverter &typeConverter, RewritePatternSet &patterns) {
+    const BufferizeTypeConverter &typeConverter, RewritePatternSet &patterns) {
   patterns.add<BufferizeCastOp, BufferizeExtractOp>(typeConverter,
                                                     patterns.getContext());
 }
diff --git a/mlir/include/mlir/Conversion/AMDGPUToROCDL/AMDGPUToROCDL.h b/mlir/include/mlir/Conversion/AMDGPUToROCDL/AMDGPUToROCDL.h
index e445c58fe6c547..e7637a6013e68a 100644
--- a/mlir/include/mlir/Conversion/AMDGPUToROCDL/AMDGPUToROCDL.h
+++ b/mlir/include/mlir/Conversion/AMDGPUToROCDL/AMDGPUToROCDL.h
@@ -24,7 +24,7 @@ class Pass;
 /// Note: The ROCDL target does not support the LLVM bfloat type at this time
 /// and so this function will add conversions to change all `bfloat` uses
 /// to `i16`.
-void populateAMDGPUToROCDLConversionPatterns(LLVMTypeConverter &converter,
+void populateAMDGPUToROCDLConversionPatterns(const LLVMTypeConverter &converter,
                                              RewritePatternSet &patterns,
                                              amdgpu::Chipset chipset);
 
diff --git a/mlir/include/mlir/Conversion/ArithToLLVM/ArithToLLVM.h b/mlir/include/mlir/Conversion/ArithToLLVM/ArithToLLVM.h
index 25b82aed9c968a..173fea7c352d93 100644
--- a/mlir/include/mlir/Conversion/ArithToLLVM/ArithToLLVM.h
+++ b/mlir/include/mlir/Conversion/ArithToLLVM/ArithToLLVM.h
@@ -22,7 +22,7 @@ class Pass;
 #include "mlir/Conversion/Passes.h.inc"
 
 namespace arith {
-void populateArithToLLVMConversionPatterns(LLVMTypeConverter &converter,
+void populateArithToLLVMConversionPatterns(const LLVMTypeConverter &converter,
                                            RewritePatternSet &patterns);
 
 void registerConvertArithToLLVMInterface(DialectRegistry &registry);
diff --git a/mlir/include/mlir/Conversion/ArithToSPIRV/ArithToSPIRV.h b/mlir/include/mlir/Conversion/ArithToSPIRV/ArithToSPIRV.h
index bb30deb9dc10e5..a15e56bfdf04bf 100644
--- a/mlir/include/mlir/Conversion/ArithToSPIRV/ArithToSPIRV.h
+++ b/mlir/include/mlir/Conversion/ArithToSPIRV/ArithToSPIRV.h
@@ -22,7 +22,7 @@ class Pass;
 #include "mlir/Conversion/Passes.h.inc"
 
 namespace arith {
-void populateArithToSPIRVPatterns(SPIRVTypeConverter &typeConverter,
+void populateArithToSPIRVPatterns(const SPIRVTypeConverter &typeConverter,
                                   RewritePatternSet &patterns);
 
 std::unique_ptr<OperationPass<>> createConvertArithToSPIRVPass();
diff --git a/mlir/include/mlir/Conversion/ComplexToLLVM/ComplexToLLVM.h b/mlir/include/mlir/Conversion/ComplexToLLVM/ComplexToLLVM.h
index 69b01b471dd984..65d6f165c7448d 100644
--- a/mlir/include/mlir/Conversion/ComplexToLLVM/ComplexToLLVM.h
+++ b/mlir/include/mlir/Conversion/ComplexToLLVM/ComplexToLLVM.h
@@ -39,7 +39,7 @@ class ComplexStructBuilder : public StructBuilder {
 };
 
 /// Populate the given list with patterns that convert from Complex to LLVM.
-void populateComplexToLLVMConversionPatterns(LLVMTypeConverter &converter,
+void populateComplexToLLVMConversionPatterns(const LLVMTypeConverter &converter,
                                              RewritePatternSet &patterns);
 
 void registerConvertComplexToLLVMInterface(DialectRegistry &registry);
diff --git a/mlir/include/mlir/Conversion/ComplexToSPIRV/ComplexToSPIRV.h b/mlir/include/mlir/Conversion/ComplexToSPIRV/ComplexToSPIRV.h
index 19dba5b870cb6f..777481f00b3592 100644
--- a/mlir/include/mlir/Conversion/ComplexToSPIRV/ComplexToSPIRV.h
+++ b/mlir/include/mlir/Conversion/ComplexToSPIRV/ComplexToSPIRV.h
@@ -20,7 +20,7 @@ class SPIRVTypeConverter;
 
 /// Appends to a pattern list additional patterns for translating Complex ops
 /// to SPIR-V ops.
-void populateComplexToSPIRVPatterns(SPIRVTypeConverter &typeConverter,
+void populateComplexToSPIRVPatterns(const SPIRVTypeConverter &typeConverter,
                                     RewritePatternSet &patterns);
 
 } // namespace mlir
diff --git a/mlir/include/mlir/Conversion/ControlFlowToLLVM/ControlFlowToLLVM.h b/mlir/include/mlir/Conversion/ControlFlowToLLVM/ControlFlowToLLVM.h
index 35b691b8bc44b5..b88c1e8b20f32b 100644
--- a/mlir/include/mlir/Conversion/ControlFlowToLLVM/ControlFlowToLLVM.h
+++ b/mlir/include/mlir/Conversion/ControlFlowToLLVM/ControlFlowToLLVM.h
@@ -29,13 +29,13 @@ namespace cf {
 /// Collect the patterns to convert from the ControlFlow dialect to LLVM. The
 /// conversion patterns capture the LLVMTypeConverter by reference meaning the
 /// references have to remain alive during the entire pattern lifetime.
-void populateControlFlowToLLVMConversionPatterns(LLVMTypeConverter &converter,
-                                                 RewritePatternSet &patterns);
+void populateControlFlowToLLVMConversionPatterns(
+    const LLVMTypeConverter &converter, RewritePatternSet &patterns);
 
 /// Populate the cf.assert to LLVM conversion pattern. If `abortOnFailure` is
 /// set to false, the program execution continues when a condition is
 /// unsatisfied.
-void populateAssertToLLVMConversionPattern(LLVMTypeConverter &converter,
+void populateAssertToLLVMConversionPattern(const LLVMTypeConverter &converter,
                                            RewritePatternSet &patterns,
                                            bool abortOnFailure = true);
 
diff --git a/mlir/include/mlir/Conversion/ControlFlowToSPIRV/ControlFlowToSPIRV.h b/mlir/include/mlir/Conversion/ControlFlowToSPIRV/ControlFlowToSPIRV.h
index 43578ffffae2dc..6de46960ff8029 100644
--- a/mlir/include/mlir/Conversion/ControlFlowToSPIRV/ControlFlowToSPIRV.h
+++ b/mlir/include/mlir/Conversion/ControlFlowToSPIRV/ControlFlowToSPIRV.h
@@ -20,7 +20,7 @@ class SPIRVTypeConverter;
 namespace cf {
 /// Appends to a pattern list additional patterns for translating ControlFLow
 /// ops to SPIR-V ops.
-void populateControlFlowToSPIRVPatterns(SPIRVTypeConverter &typeConverter,
+void populateControlFlowToSPIRVPatterns(const SPIRVTypeConverter &typeConverter,
                                         RewritePatternSet &patterns);
 } // namespace cf
 } // namespace mlir
diff --git a/mlir/include/mlir/Conversion/FuncToLLVM/ConvertFuncToLLVM.h b/mlir/include/mlir/Conversion/FuncToLLVM/ConvertFuncToLLVM.h
index 76eb3b5dd11e95..b1ea2740c06059 100644
--- a/mlir/include/mlir/Conversion/FuncToLLVM/ConvertFuncToLLVM.h
+++ b/mlir/include/mlir/Conversion/FuncToLLVM/ConvertFuncToLLVM.h
@@ -39,8 +39,8 @@ convertFuncOpToLLVMFuncOp(FunctionOpInterface funcOp,
 /// `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 populateFuncToLLVMFuncOpConversionPattern(LLVMTypeConverter &converter,
-                                               RewritePatternSet &patterns);
+void populateFuncToLLVMFuncOpConversionPattern(
+    const LLVMTypeConverter &converter, RewritePatternSet &patterns);
 
 /// Collect the patterns to convert from the Func dialect to LLVM. The
 /// conversion patterns capture the LLVMTypeConverter and the LowerToLLVMOptions
@@ -56,7 +56,7 @@ void populateFuncToLLVMFuncOpConversionPattern(LLVMTypeConverter &converter,
 /// needed if `converter.getOptions().useBarePtrCallConv` is `true`, but it's
 /// not an error to provide it anyway.
 void populateFuncToLLVMConversionPatterns(
-    LLVMTypeConverter &converter, RewritePatternSet &patterns,
+    const LLVMTypeConverter &converter, RewritePatternSet &patterns,
     const SymbolTable *symbolTable = nullptr);
 
 void registerConvertFuncToLLVMInterface(DialectRegistry &registry);
diff --git a/mlir/include/mlir/Conversion/FuncToSPIRV/FuncToSPIRV.h b/mlir/include/mlir/Conversion/FuncToSPIRV/FuncToSPIRV.h
index 2fa55f40dd9700..68728755a2fbdb 100644
--- a/mlir/include/mlir/Conversion/FuncToSPIRV/FuncToSPIRV.h
+++ b/mlir/include/mlir/Conversion/FuncToSPIRV/FuncToSPIRV.h
@@ -21,7 +21,7 @@ class SPIRVTypeConverter;
 /// Appends to a pattern list additional patterns for translating Func ops
 /// to SPIR-V ops. Also adds the patterns to legalize ops not directly
 /// translated to SPIR-V dialect.
-void populateFuncToSPIRVPatterns(SPIRVTypeConverter &typeConverter,
+void populateFuncToSPIRVPatterns(const SPIRVTypeConverter &typeConverter,
                                  RewritePatternSet &patterns);
 
 } // namespace mlir
diff --git a/mlir/include/mlir/Conversion/GPUToLLVMSPV/GPUToLLVMSPVPass.h b/mlir/include/mlir/Conversion/GPUToLLVMSPV/GPUToLLVMSPVPass.h
index 20c9f9c394525d..3bf30ae99f2bf1 100644
--- a/mlir/include/mlir/Conversion/GPUToLLVMSPV/GPUToLLVMSPVPass.h
+++ b/mlir/include/mlir/Conversion/GPUToLLVMSPV/GPUToLLVMSPVPass.h
@@ -21,7 +21,7 @@ class TypeConverter;
 #define GEN_PASS_DECL_CONVERTGPUOPSTOLLVMSPVOPS
 #include "mlir/Conversion/Passes.h.inc"
 
-void populateGpuToLLVMSPVConversionPatterns(LLVMTypeConverter &converter,
+void populateGpuToLLVMSPVConversionPatterns(const LLVMTypeConverter &converter,
                                             RewritePatternSet &patterns);
 
 /// Populates memory space attribute conversion rules for lowering
diff --git a/mlir/include/mlir/Conversion/GPUToNVVM/GPUToNVVMPass.h b/mlir/include/mlir/Conversion/GPUToNVVM/GPUToNVVMPass.h
index e0f4c71051e506..645e86a4309621 100644
--- a/mlir/include/mlir/Conversion/GPUToNVVM/GPUToNVVMPass.h
+++ b/mlir/include/mlir/Conversion/GPUToNVVM/GPUToNVVMPass.h
@@ -32,16 +32,16 @@ LLVM::LLVMStructType convertMMAToLLVMType(gpu::MMAMatrixType type);
 void configureGpuToNVVMConversionLegality(ConversionTarget &target);
 
 /// Collect a set of patterns to convert from the GPU dialect to NVVM.
-void populateGpuToNVVMConversionPatterns(LLVMTypeConverter &converter,
+void populateGpuToNVVMConversionPatterns(const LLVMTypeConverter &converter,
                                          RewritePatternSet &patterns);
 
 /// Populate GpuSubgroupReduce pattern to NVVM. It generates a specific nvvm
 /// op that is not available on every GPU.
-void populateGpuSubgroupReduceOpLoweringPattern(LLVMTypeConverter &converter,
-                                                RewritePatternSet &patterns);
+void populateGpuSubgroupReduceOpLoweringPattern(
+    const LLVMTypeConverter &converter, RewritePatternSet &patterns);
 
 /// Collect a set of patterns to convert WMMA ops from GPU dialect to NVVM.
-void populateGpuWMMAToNVVMConversionPatterns(LLVMTypeConverter &converter,
+void populateGpuWMMAToNVVMConversionPatterns(const LLVMTypeConverter &converter,
                                              RewritePatternSet &patterns);
 } // namespace mlir
 
diff --git a/mlir/include/mlir/Conversion/GPUToROCDL/GPUToROCDLPass.h b/mlir/include/mlir/Conversion/GPUToROCDL/GPUToROCDLPass.h
index 5647787712997b..1a917932a9a84a 100644
--- a/mlir/include/mlir/Conversion/GPUToROCDL/GPUToROCDLPass.h
+++ b/mlir/include/mlir/Conversion/GPUToROCDL/GPUToROCDLPass.h
@@ -30,7 +30,7 @@ class GPUModuleOp;
 /// Collect a set of patterns to convert from the GPU dialect to ROCDL.
 /// If `runtime` is Unknown, gpu.printf will not be lowered
 /// The resulting pattern set should be run over a gpu.module op
-void populateGpuToROCDLConversionPatterns(LLVMTypeConverter &converter,
+void populateGpuToROCDLConversionPatterns(const LLVMTypeConverter &converter,
                                           RewritePatternSet &patterns,
                                           gpu::amd::Runtime runtime);
 
diff --git a/mlir/include/mlir/Conversion/GPUToSPIRV/GPUToSPIRV.h b/mlir/include/mlir/Conversion/GPUToSPIRV/GPUToSPIRV.h
index d34549432161db..825142d120587f 100644
--- a/mlir/include/mlir/Conversion/GPUToSPIRV/GPUToSPIRV.h
+++ b/mlir/include/mlir/Conversion/GPUToSPIRV/GPUToSPIRV.h
@@ -23,13 +23,13 @@ class SPIRVTypeConverter;
 /// Appends to a pattern list additional patterns for translating GPU Ops to
 /// SPIR-V ops. For a gpu.func to be converted, it should have a
 /// spirv.entry_point_abi attribute.
-void populateGPUToSPIRVPatterns(SPIRVTypeConverter &typeConverter,
+void populateGPUToSPIRVPatterns(const SPIRVTypeConverter &typeConverter,
                                 RewritePatternSet &patterns);
 
 /// Collect a set of patterns to convert WMMA ops from GPU dialect to SPIRV,
 /// using the KHR Cooperative Matrix extension.
 void populateGpuWMMAToSPIRVCoopMatrixKHRConversionPatterns(
-    SPIRVTypeConverter &typeConverter, RewritePatternSet &patterns);
+    const SPIRVTypeConverter &typeConverter, RewritePatternSet &patterns);
 
 /// Adds `MMAMatrixType` conversions to SPIR-V cooperative matrix KHR type
 /// conversion to the type converter.
diff --git a/mlir/include/mlir/Conversion/IndexToLLVM/IndexToLLVM.h b/mlir/include/mlir/Conversion/IndexToLLVM/IndexToLLVM.h
index df605adae669be..16d3d74b135588 100644
--- a/mlir/include/mlir/Conversion/IndexToLLVM/IndexToLLVM.h
+++ b/mlir/include/mlir/Conversion/IndexToLLVM/IndexToLLVM.h
@@ -21,7 +21,7 @@ class Pass;
 #include "mlir/Conversion/Passes.h.inc"
 
 namespace index {
-void populateIndexToLLVMConversionPatterns(LLVMTypeConverter &converter,
+void populateIndexToLLVMConversionPatterns(const LLVMTypeConverter &converter,
                                            RewritePatternSet &patterns);
 
 void registerConvertIndexToLLVMInterface(DialectRegistry &registry);
diff --git a/mlir/include/mlir/Conversion/IndexToSPIRV/IndexToSPIRV.h b/mlir/include/mlir/Conversion/IndexToSPIRV/IndexToSPIRV.h
index 58a1c5246eef99..e5e7d3318a8717 100644
--- a/mlir/include/mlir/Conversion/IndexToSPIRV/IndexToSPIRV.h
+++ b/mlir/include/mlir/Conversion/IndexToSPIRV/IndexToSPIRV.h
@@ -21,7 +21,7 @@ class Pass;
 #include "mlir/Conversion/Passes.h.inc"
 
 namespace index {
-void populateIndexToSPIRVPatterns(SPIRVTypeConverter &converter,
+void populateIndexToSPIRVPatterns(const SPIRVTypeConverter &converter,
                                   RewritePatternSet &patterns);
 std::unique_ptr<OperationPass<>> createConvertIndexToSPIRVPass();
 } // namespace index
diff --git a/mlir/include/mlir/Conversion/MathToLLVM/MathToLLVM.h b/mlir/include/mlir/Conversion/MathToLLVM/MathToLLVM.h
index 4ddc1637000fdb..93cd780bba4381 100644
--- a/mlir/include/mlir/Conversion/MathToLLVM/MathToLLVM.h
+++ b/mlir/include/mlir/Conversion/MathToLLVM/MathToLLVM.h
@@ -21,7 +21,7 @@ class Pass;
 #define GEN_PASS_DECL_CONVERTMATHTOLLVMPASS
 #include "mlir/Conversion/Passes.h.inc"
 
-void populateMathToLLVMConversionPatterns(LLVMTypeConverter &converter,
+void populateMathToLLVMConversionPatterns(const LLVMTypeConverter &converter,
                                           RewritePatternSet &patterns,
                                           bool approximateLog1p = true);
 
diff --git a/mlir/include/mlir/Conversion/MathToROCDL/MathToROCDL.h b/mlir/include/mlir/Conversion/MathToROCDL/MathToROCDL.h
index fa7a635568c7c2..46573e7966cccc 100644
--- a/mlir/include/mlir/Conversion/MathToROCDL/MathToROCDL.h
+++ b/mlir/include/mlir/Conversion/MathToROCDL/MathToROCDL.h
@@ -19,7 +19,7 @@ class Pass;
 #include "mlir/Conversion/Passes.h.inc"
 
 /// Populate the given list with patterns that convert from Math to ROCDL calls.
-void populateMathToROCDLConversionPatterns(LLVMTypeConverter &converter,
+void populateMathToROCDLConversionPatterns(const LLVMTypeConverter &converter,
                                            RewritePatternSet &patterns);
 } // namespace mlir
 
diff --git a/mlir/include/mlir/Conversion/MathToSPIRV/MathToSPIRV.h b/mlir/include/mlir/Conversion/MathToSPIRV/MathToSPIRV.h
index 10090268a46636..452b3f5df931e1 100644
--- a/mlir/include/mlir/Conversion/MathToSPIRV/MathToSPIRV.h
+++ b/mlir/include/mlir/Conversion/MathToSPIRV/MathToSPIRV.h
@@ -20,7 +20,7 @@ class SPIRVTypeConverter;
 
 /// Appends to a pattern list additional patterns for translating Math ops
 /// to SPIR-V ops.
-void populate...
[truncated]

``````````

</details>


https://github.com/llvm/llvm-project/pull/111250


More information about the flang-commits mailing list