[Mlir-commits] [mlir] cd4ca2d - [mlir] Port Conversion Passes to LLVM to use TableGen generated constructors and options
Markus Böck
llvmlistbot at llvm.org
Fri Feb 10 11:55:31 PST 2023
Author: Markus Böck
Date: 2023-02-10T20:47:18+01:00
New Revision: cd4ca2d7f991177b64db9df3c17986dc8e250f1d
URL: https://github.com/llvm/llvm-project/commit/cd4ca2d7f991177b64db9df3c17986dc8e250f1d
DIFF: https://github.com/llvm/llvm-project/commit/cd4ca2d7f991177b64db9df3c17986dc8e250f1d.diff
LOG: [mlir] Port Conversion Passes to LLVM to use TableGen generated constructors and options
See https://github.com/llvm/llvm-project/issues/57475 for more context.
Using auto-generated constructors and options has significant advantages:
* It forces a uniform style and expectation for consuming a pass
* It allows to very easily add, remove or change options to a pass by simply making the changes in TableGen
* Its less code
This patch in particular ports all the conversion passes which lower to LLVM to use the auto generated constructors and options. For the most part, care was taken so that auto generated constructor functions have the same name as they previously did. Only following slight breaking changes (which I consider as worth the churn) have been made:
* `mlir::cf::createConvertControlFlowToLLVMPass` has been moved to the `mlir` namespace. This is consistent with basically all conversion passes
* `createGpuToLLVMConversionPass` now takes a proper options struct array for its pass options. The pass options are now also autogenerated.
* `LowerVectorToLLVMOptions` has been replaced by the autogenerated `ConvertVectorToLLVMPassOptions` which is automatically kept up to date by TableGen
* I had to move one function in the GPU to LLVM lowering as it is used as default value for an option.
* All passes that previously returned `unique_ptr<OperationPass<...>>` now simply return `unique_ptr<Pass>`
Differential Revision: https://reviews.llvm.org/D143773
Added:
Modified:
mlir/include/mlir/Conversion/AsyncToLLVM/AsyncToLLVM.h
mlir/include/mlir/Conversion/ComplexToLLVM/ComplexToLLVM.h
mlir/include/mlir/Conversion/ControlFlowToLLVM/ControlFlowToLLVM.h
mlir/include/mlir/Conversion/GPUCommon/GPUCommonPass.h
mlir/include/mlir/Conversion/LinalgToLLVM/LinalgToLLVM.h
mlir/include/mlir/Conversion/MathToLLVM/MathToLLVM.h
mlir/include/mlir/Conversion/OpenACCToLLVM/ConvertOpenACCToLLVM.h
mlir/include/mlir/Conversion/OpenMPToLLVM/ConvertOpenMPToLLVM.h
mlir/include/mlir/Conversion/Passes.td
mlir/include/mlir/Conversion/SPIRVToLLVM/SPIRVToLLVMPass.h
mlir/include/mlir/Conversion/VectorToLLVM/ConvertVectorToLLVM.h
mlir/include/mlir/Dialect/GPU/Transforms/Passes.h
mlir/include/mlir/Dialect/GPU/Transforms/Utils.h
mlir/include/mlir/Dialect/SparseTensor/Pipelines/Passes.h
mlir/lib/Conversion/AsyncToLLVM/AsyncToLLVM.cpp
mlir/lib/Conversion/ComplexToLLVM/ComplexToLLVM.cpp
mlir/lib/Conversion/ControlFlowToLLVM/ControlFlowToLLVM.cpp
mlir/lib/Conversion/GPUCommon/GPUToLLVMConversion.cpp
mlir/lib/Conversion/LinalgToLLVM/LinalgToLLVM.cpp
mlir/lib/Conversion/MathToLLVM/MathToLLVM.cpp
mlir/lib/Conversion/OpenACCToLLVM/OpenACCToLLVM.cpp
mlir/lib/Conversion/OpenMPToLLVM/OpenMPToLLVM.cpp
mlir/lib/Conversion/SPIRVToLLVM/ConvertLaunchFuncToLLVMCalls.cpp
mlir/lib/Conversion/SPIRVToLLVM/SPIRVToLLVMPass.cpp
mlir/lib/Conversion/VectorToLLVM/ConvertVectorToLLVMPass.cpp
mlir/test/lib/Dialect/LLVM/TestLowerToLLVM.cpp
Removed:
################################################################################
diff --git a/mlir/include/mlir/Conversion/AsyncToLLVM/AsyncToLLVM.h b/mlir/include/mlir/Conversion/AsyncToLLVM/AsyncToLLVM.h
index d487f661a01a2..60441f9faaa60 100644
--- a/mlir/include/mlir/Conversion/AsyncToLLVM/AsyncToLLVM.h
+++ b/mlir/include/mlir/Conversion/AsyncToLLVM/AsyncToLLVM.h
@@ -14,19 +14,14 @@
namespace mlir {
class ConversionTarget;
-class ModuleOp;
-template <typename T>
-class OperationPass;
+class Pass;
class MLIRContext;
class TypeConverter;
class RewritePatternSet;
-#define GEN_PASS_DECL_CONVERTASYNCTOLLVM
+#define GEN_PASS_DECL_CONVERTASYNCTOLLVMPASS
#include "mlir/Conversion/Passes.h.inc"
-/// Create a pass to convert Async operations to the LLVM dialect.
-std::unique_ptr<OperationPass<ModuleOp>> createConvertAsyncToLLVMPass();
-
/// Populates patterns for async structural type conversions.
///
/// A "structural" type conversion is one where the underlying ops are
diff --git a/mlir/include/mlir/Conversion/ComplexToLLVM/ComplexToLLVM.h b/mlir/include/mlir/Conversion/ComplexToLLVM/ComplexToLLVM.h
index 7779321ca46c0..1385618c09800 100644
--- a/mlir/include/mlir/Conversion/ComplexToLLVM/ComplexToLLVM.h
+++ b/mlir/include/mlir/Conversion/ComplexToLLVM/ComplexToLLVM.h
@@ -15,7 +15,7 @@ class LLVMTypeConverter;
class Pass;
class RewritePatternSet;
-#define GEN_PASS_DECL_CONVERTCOMPLEXTOLLVM
+#define GEN_PASS_DECL_CONVERTCOMPLEXTOLLVMPASS
#include "mlir/Conversion/Passes.h.inc"
class ComplexStructBuilder : public StructBuilder {
@@ -40,10 +40,6 @@ class ComplexStructBuilder : public StructBuilder {
/// Populate the given list with patterns that convert from Complex to LLVM.
void populateComplexToLLVMConversionPatterns(LLVMTypeConverter &converter,
RewritePatternSet &patterns);
-
-/// Create a pass to convert Complex operations to the LLVMIR dialect.
-std::unique_ptr<Pass> createConvertComplexToLLVMPass();
-
} // namespace mlir
#endif // MLIR_CONVERSION_COMPLEXTOLLVM_COMPLEXTOLLVM_H_
diff --git a/mlir/include/mlir/Conversion/ControlFlowToLLVM/ControlFlowToLLVM.h b/mlir/include/mlir/Conversion/ControlFlowToLLVM/ControlFlowToLLVM.h
index b9dfaafcf5a58..9cc867238a00d 100644
--- a/mlir/include/mlir/Conversion/ControlFlowToLLVM/ControlFlowToLLVM.h
+++ b/mlir/include/mlir/Conversion/ControlFlowToLLVM/ControlFlowToLLVM.h
@@ -20,10 +20,11 @@ class LLVMTypeConverter;
class RewritePatternSet;
class Pass;
-#define GEN_PASS_DECL_CONVERTCONTROLFLOWTOLLVM
+#define GEN_PASS_DECL_CONVERTCONTROLFLOWTOLLVMPASS
#include "mlir/Conversion/Passes.h.inc"
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.
@@ -36,9 +37,6 @@ void populateControlFlowToLLVMConversionPatterns(LLVMTypeConverter &converter,
void populateAssertToLLVMConversionPattern(LLVMTypeConverter &converter,
RewritePatternSet &patterns,
bool abortOnFailure = true);
-
-/// Creates a pass to convert the ControlFlow dialect into the LLVMIR dialect.
-std::unique_ptr<Pass> createConvertControlFlowToLLVMPass();
} // namespace cf
} // namespace mlir
diff --git a/mlir/include/mlir/Conversion/GPUCommon/GPUCommonPass.h b/mlir/include/mlir/Conversion/GPUCommon/GPUCommonPass.h
index 2c73f43c95419..64a9614ee4397 100644
--- a/mlir/include/mlir/Conversion/GPUCommon/GPUCommonPass.h
+++ b/mlir/include/mlir/Conversion/GPUCommon/GPUCommonPass.h
@@ -8,6 +8,7 @@
#ifndef MLIR_CONVERSION_GPUCOMMON_GPUCOMMONPASS_H_
#define MLIR_CONVERSION_GPUCOMMON_GPUCOMMONPASS_H_
+#include "mlir/Dialect/GPU/Transforms/Utils.h"
#include "mlir/Support/LLVM.h"
#include "llvm/ADT/StringRef.h"
#include <functional>
@@ -27,8 +28,7 @@ class ModuleOp;
class Operation;
class RewritePatternSet;
-template <typename T>
-class OperationPass;
+class Pass;
namespace gpu {
class GPUModuleOp;
@@ -47,15 +47,6 @@ using BlobGenerator =
using LoweringCallback = std::function<std::unique_ptr<llvm::Module>(
Operation *, llvm::LLVMContext &, StringRef)>;
-/// Creates a pass to convert a GPU operations into a sequence of GPU runtime
-/// calls.
-///
-/// This pass does not generate code to call GPU runtime APIs directly but
-/// instead uses a small wrapper library that exports a stable and conveniently
-/// typed ABI on top of GPU runtimes such as CUDA or ROCm (HIP).
-std::unique_ptr<OperationPass<ModuleOp>>
-createGpuToLLVMConversionPass(bool kernelBarePtrCallConv = false);
-
/// Collect a set of patterns to convert from the GPU dialect to LLVM and
/// populate converter for gpu types.
void populateGpuToLLVMConversionPatterns(LLVMTypeConverter &converter,
diff --git a/mlir/include/mlir/Conversion/LinalgToLLVM/LinalgToLLVM.h b/mlir/include/mlir/Conversion/LinalgToLLVM/LinalgToLLVM.h
index b75aa4b5e4287..72d263c488dcb 100644
--- a/mlir/include/mlir/Conversion/LinalgToLLVM/LinalgToLLVM.h
+++ b/mlir/include/mlir/Conversion/LinalgToLLVM/LinalgToLLVM.h
@@ -13,21 +13,16 @@
namespace mlir {
class LLVMTypeConverter;
class MLIRContext;
-class ModuleOp;
-template <typename T>
-class OperationPass;
+class Pass;
class RewritePatternSet;
-#define GEN_PASS_DECL_CONVERTLINALGTOLLVM
+#define GEN_PASS_DECL_CONVERTLINALGTOLLVMPASS
#include "mlir/Conversion/Passes.h.inc"
/// Populate the given list with patterns that convert from Linalg to LLVM.
void populateLinalgToLLVMConversionPatterns(LLVMTypeConverter &converter,
RewritePatternSet &patterns);
-/// Create a pass to convert Linalg operations to the LLVMIR dialect.
-std::unique_ptr<OperationPass<ModuleOp>> createConvertLinalgToLLVMPass();
-
} // namespace mlir
#endif // MLIR_CONVERSION_LINALGTOLLVM_LINALGTOLLVM_H_
diff --git a/mlir/include/mlir/Conversion/MathToLLVM/MathToLLVM.h b/mlir/include/mlir/Conversion/MathToLLVM/MathToLLVM.h
index 0cb1fe33cadb4..d0fc2e390ed79 100644
--- a/mlir/include/mlir/Conversion/MathToLLVM/MathToLLVM.h
+++ b/mlir/include/mlir/Conversion/MathToLLVM/MathToLLVM.h
@@ -17,13 +17,11 @@ class LLVMTypeConverter;
class RewritePatternSet;
class Pass;
-#define GEN_PASS_DECL_CONVERTMATHTOLLVM
+#define GEN_PASS_DECL_CONVERTMATHTOLLVMPASS
#include "mlir/Conversion/Passes.h.inc"
void populateMathToLLVMConversionPatterns(LLVMTypeConverter &converter,
RewritePatternSet &patterns);
-
-std::unique_ptr<Pass> createConvertMathToLLVMPass();
} // namespace mlir
#endif // MLIR_CONVERSION_MATHTOLLVM_MATHTOLLVM_H
diff --git a/mlir/include/mlir/Conversion/OpenACCToLLVM/ConvertOpenACCToLLVM.h b/mlir/include/mlir/Conversion/OpenACCToLLVM/ConvertOpenACCToLLVM.h
index 811533d2775d4..0cbea0c9ef5b6 100644
--- a/mlir/include/mlir/Conversion/OpenACCToLLVM/ConvertOpenACCToLLVM.h
+++ b/mlir/include/mlir/Conversion/OpenACCToLLVM/ConvertOpenACCToLLVM.h
@@ -13,12 +13,10 @@
namespace mlir {
class LLVMTypeConverter;
-class ModuleOp;
-template <typename T>
-class OperationPass;
+class Pass;
class RewritePatternSet;
-#define GEN_PASS_DECL_CONVERTOPENACCTOLLVM
+#define GEN_PASS_DECL_CONVERTOPENACCTOLLVMPASS
#include "mlir/Conversion/Passes.h.inc"
static constexpr unsigned kPtrBasePosInDataDescriptor = 0;
@@ -69,10 +67,6 @@ class DataDescriptor : public StructBuilder {
/// Collect the patterns to convert from the OpenACC dialect LLVMIR dialect.
void populateOpenACCToLLVMConversionPatterns(LLVMTypeConverter &converter,
RewritePatternSet &patterns);
-
-/// Create a pass to convert the OpenACC dialect into the LLVMIR dialect.
-std::unique_ptr<OperationPass<ModuleOp>> createConvertOpenACCToLLVMPass();
-
} // namespace mlir
#endif // MLIR_CONVERSION_OPENACCTOLLVM_CONVERTOPENACCTOLLVM_H
diff --git a/mlir/include/mlir/Conversion/OpenMPToLLVM/ConvertOpenMPToLLVM.h b/mlir/include/mlir/Conversion/OpenMPToLLVM/ConvertOpenMPToLLVM.h
index 6827055b1c101..2ed077f8f83e9 100644
--- a/mlir/include/mlir/Conversion/OpenMPToLLVM/ConvertOpenMPToLLVM.h
+++ b/mlir/include/mlir/Conversion/OpenMPToLLVM/ConvertOpenMPToLLVM.h
@@ -14,12 +14,10 @@ namespace mlir {
class LLVMTypeConverter;
class ConversionTarget;
class MLIRContext;
-class ModuleOp;
-template <typename T>
-class OperationPass;
+class Pass;
class RewritePatternSet;
-#define GEN_PASS_DECL_CONVERTOOPENMPTOLLVM
+#define GEN_PASS_DECL_CONVERTOPENMPTOLLVMPASS
#include "mlir/Conversion/Passes.h.inc"
/// Configure dynamic conversion legality of regionless operations from OpenMP
@@ -30,10 +28,6 @@ void configureOpenMPToLLVMConversionLegality(ConversionTarget &target,
/// Populate the given list with patterns that convert from OpenMP to LLVM.
void populateOpenMPToLLVMConversionPatterns(LLVMTypeConverter &converter,
RewritePatternSet &patterns);
-
-/// Create a pass to convert OpenMP operations to the LLVMIR dialect.
-std::unique_ptr<OperationPass<ModuleOp>> createConvertOpenMPToLLVMPass();
-
} // namespace mlir
#endif // MLIR_CONVERSION_OPENMPTOLLVM_CONVERTOPENMPTOLLVM_H
diff --git a/mlir/include/mlir/Conversion/Passes.td b/mlir/include/mlir/Conversion/Passes.td
index d01e05ce28232..60c28bed55910 100644
--- a/mlir/include/mlir/Conversion/Passes.td
+++ b/mlir/include/mlir/Conversion/Passes.td
@@ -143,14 +143,13 @@ def ConvertArmNeon2dToIntr : Pass<"arm-neon-2d-to-intr"> {
// AsyncToLLVM
//===----------------------------------------------------------------------===//
-def ConvertAsyncToLLVM : Pass<"convert-async-to-llvm", "ModuleOp"> {
+def ConvertAsyncToLLVMPass : Pass<"convert-async-to-llvm", "ModuleOp"> {
let summary = "Convert the operations from the async dialect into the LLVM "
"dialect";
let description = [{
Convert `async.execute` operations to LLVM coroutines and use async runtime
API to execute them.
}];
- let constructor = "mlir::createConvertAsyncToLLVMPass()";
let dependentDialects = [
"arith::ArithDialect",
"async::AsyncDialect",
@@ -203,9 +202,8 @@ def ConvertBufferizationToMemRef : Pass<"convert-bufferization-to-memref"> {
// ComplexToLLVM
//===----------------------------------------------------------------------===//
-def ConvertComplexToLLVM : Pass<"convert-complex-to-llvm"> {
+def ConvertComplexToLLVMPass : Pass<"convert-complex-to-llvm"> {
let summary = "Convert Complex dialect to LLVM dialect";
- let constructor = "mlir::createConvertComplexToLLVMPass()";
let dependentDialects = ["LLVM::LLVMDialect"];
}
@@ -238,7 +236,7 @@ def ConvertComplexToStandard : Pass<"convert-complex-to-standard"> {
// ControlFlowToLLVM
//===----------------------------------------------------------------------===//
-def ConvertControlFlowToLLVM : Pass<"convert-cf-to-llvm", "ModuleOp"> {
+def ConvertControlFlowToLLVMPass : Pass<"convert-cf-to-llvm", "ModuleOp"> {
let summary = "Convert ControlFlow operations to the LLVM dialect";
let description = [{
Convert ControlFlow operations into LLVM IR dialect operations.
@@ -247,7 +245,6 @@ def ConvertControlFlowToLLVM : Pass<"convert-cf-to-llvm", "ModuleOp"> {
IR dialect operations, the pass will fail. Any LLVM IR operations or types
already present in the IR will be kept as is.
}];
- let constructor = "mlir::cf::createConvertControlFlowToLLVMPass()";
let dependentDialects = ["LLVM::LLVMDialect"];
let options = [
Option<"indexBitwidth", "index-bitwidth", "unsigned",
@@ -345,16 +342,48 @@ def ConvertFuncToSPIRV : Pass<"convert-func-to-spirv"> {
def GpuToLLVMConversionPass : Pass<"gpu-to-llvm", "ModuleOp"> {
let summary = "Convert GPU dialect to LLVM dialect with GPU runtime calls";
- let constructor = "mlir::createGpuToLLVMConversionPass()";
+
+ let description = [{
+ Creates a pass to convert a GPU operations into a sequence of GPU runtime
+ calls.
+
+ This pass does not generate code to call GPU runtime APIs directly but
+ instead uses a small wrapper library that exports a stable and conveniently
+ typed ABI on top of GPU runtimes such as CUDA or ROCm (HIP).
+ }];
+
+ let options = [
+ Option<"kernelBarePtrCallConv", "use-bare-pointers-for-kernels", "bool",
+ /*default=*/"false",
+ "Use bare pointers to pass memref arguments to kernels. "
+ "The kernel must use the same setting for this option."
+ >,
+ Option<"gpuBinaryAnnotation", "gpu-binary-annotation", "std::string",
+ /*default=*/"gpu::getDefaultGpuBinaryAnnotation()",
+ "Annotation attribute string for GPU binary"
+ >,
+ ];
+
let dependentDialects = [
"LLVM::LLVMDialect",
"memref::MemRefDialect",
];
}
-def LowerHostCodeToLLVM : Pass<"lower-host-to-llvm", "ModuleOp"> {
+def LowerHostCodeToLLVMPass : Pass<"lower-host-to-llvm", "ModuleOp"> {
let summary = "Lowers the host module code and `gpu.launch_func` to LLVM";
- let constructor = "mlir::createLowerHostCodeToLLVMPass()";
+
+ let description = [{
+ Creates a pass to emulate `gpu.launch_func` call in LLVM dialect and lower
+ the host module code to LLVM.
+
+ This transformation creates a sequence of global variables that are later
+ linked to the variables in the kernel module, and a series of copies to/from
+ them to emulate the memory transfer from the host or to the device sides. It
+ also converts the remaining Arithmetic, Func, and MemRef dialects into LLVM
+ dialect, emitting C wrappers.
+ }];
+
let dependentDialects = ["LLVM::LLVMDialect"];
}
@@ -487,10 +516,9 @@ def ConvertIndexToLLVMPass : Pass<"convert-index-to-llvm"> {
// LinalgToLLVM
//===----------------------------------------------------------------------===//
-def ConvertLinalgToLLVM : Pass<"convert-linalg-to-llvm", "ModuleOp"> {
+def ConvertLinalgToLLVMPass : Pass<"convert-linalg-to-llvm", "ModuleOp"> {
let summary = "Convert the operations from the linalg dialect into the LLVM "
"dialect";
- let constructor = "mlir::createConvertLinalgToLLVMPass()";
let dependentDialects = ["scf::SCFDialect", "LLVM::LLVMDialect"];
}
@@ -526,12 +554,11 @@ def ConvertMathToLibm : Pass<"convert-math-to-libm", "ModuleOp"> {
// MathToLLVM
//===----------------------------------------------------------------------===//
-def ConvertMathToLLVM : Pass<"convert-math-to-llvm"> {
+def ConvertMathToLLVMPass : Pass<"convert-math-to-llvm"> {
let summary = "Convert Math dialect to LLVM dialect";
let description = [{
This pass converts supported Math ops to LLVM dialect intrinsics.
}];
- let constructor = "mlir::createConvertMathToLLVMPass()";
let dependentDialects = ["LLVM::LLVMDialect"];
}
@@ -655,9 +682,8 @@ def ConvertOpenACCToSCF : Pass<"convert-openacc-to-scf", "ModuleOp"> {
// OpenACCToLLVM
//===----------------------------------------------------------------------===//
-def ConvertOpenACCToLLVM : Pass<"convert-openacc-to-llvm", "ModuleOp"> {
+def ConvertOpenACCToLLVMPass : Pass<"convert-openacc-to-llvm", "ModuleOp"> {
let summary = "Convert the OpenACC ops to LLVM dialect";
- let constructor = "mlir::createConvertOpenACCToLLVMPass()";
let dependentDialects = ["LLVM::LLVMDialect"];
}
@@ -665,9 +691,8 @@ def ConvertOpenACCToLLVM : Pass<"convert-openacc-to-llvm", "ModuleOp"> {
// OpenMPToLLVM
//===----------------------------------------------------------------------===//
-def ConvertOpenMPToLLVM : Pass<"convert-openmp-to-llvm", "ModuleOp"> {
+def ConvertOpenMPToLLVMPass : Pass<"convert-openmp-to-llvm", "ModuleOp"> {
let summary = "Convert the OpenMP ops to OpenMP ops with LLVM dialect";
- let constructor = "mlir::createConvertOpenMPToLLVMPass()";
let dependentDialects = ["LLVM::LLVMDialect"];
}
@@ -802,13 +827,12 @@ def ConvertShapeConstraints : Pass<"convert-shape-constraints"> {
// SPIRVToLLVM
//===----------------------------------------------------------------------===//
-def ConvertSPIRVToLLVM : Pass<"convert-spirv-to-llvm", "ModuleOp"> {
+def ConvertSPIRVToLLVMPass : Pass<"convert-spirv-to-llvm", "ModuleOp"> {
let summary = "Convert SPIR-V dialect to LLVM dialect";
let description = [{
See https://mlir.llvm.org/docs/SPIRVToLLVMDialectConversion/
for more details.
}];
- let constructor = "mlir::createConvertSPIRVToLLVMPass()";
let dependentDialects = ["LLVM::LLVMDialect"];
}
@@ -977,7 +1001,7 @@ def ConvertVectorToSCF : Pass<"convert-vector-to-scf"> {
// VectorToLLVM
//===----------------------------------------------------------------------===//
-def ConvertVectorToLLVM : Pass<"convert-vector-to-llvm", "ModuleOp"> {
+def ConvertVectorToLLVMPass : Pass<"convert-vector-to-llvm", "ModuleOp"> {
let summary = "Lower the operations from the vector dialect into the LLVM "
"dialect";
let description = [{
@@ -990,7 +1014,6 @@ def ConvertVectorToLLVM : Pass<"convert-vector-to-llvm", "ModuleOp"> {
architectural-neutral vector dialect lowering.
}];
- let constructor = "mlir::createConvertVectorToLLVMPass()";
// Override explicitly in C++ to allow conditional dialect dependence.
// let dependentDialects;
let options = [
diff --git a/mlir/include/mlir/Conversion/SPIRVToLLVM/SPIRVToLLVMPass.h b/mlir/include/mlir/Conversion/SPIRVToLLVM/SPIRVToLLVMPass.h
index 1e6b322512c6b..c845a745e89d4 100644
--- a/mlir/include/mlir/Conversion/SPIRVToLLVM/SPIRVToLLVMPass.h
+++ b/mlir/include/mlir/Conversion/SPIRVToLLVM/SPIRVToLLVMPass.h
@@ -16,27 +16,12 @@
#include <memory>
namespace mlir {
-class ModuleOp;
-template <typename T>
-class OperationPass;
+class Pass;
-#define GEN_PASS_DECL_LOWERHOSTCODETOLLVM
-#define GEN_PASS_DECL_CONVERTSPIRVTOLLVM
+#define GEN_PASS_DECL_LOWERHOSTCODETOLLVMPASS
+#define GEN_PASS_DECL_CONVERTSPIRVTOLLVMPASS
#include "mlir/Conversion/Passes.h.inc"
-/// Creates a pass to emulate `gpu.launch_func` call in LLVM dialect and lower
-/// the host module code to LLVM.
-///
-/// This transformation creates a sequence of global variables that are later
-/// linked to the variables in the kernel module, and a series of copies to/from
-/// them to emulate the memory transfer from the host or to the device sides. It
-/// also converts the remaining Arithmetic, Func, and MemRef dialects into LLVM
-/// dialect, emitting C wrappers.
-std::unique_ptr<OperationPass<ModuleOp>> createLowerHostCodeToLLVMPass();
-
-/// Creates a pass to convert SPIR-V operations to the LLVMIR dialect.
-std::unique_ptr<OperationPass<ModuleOp>> createConvertSPIRVToLLVMPass();
-
} // namespace mlir
#endif // MLIR_CONVERSION_SPIRVTOLLVM_SPIRVTOLLVMPASS_H
diff --git a/mlir/include/mlir/Conversion/VectorToLLVM/ConvertVectorToLLVM.h b/mlir/include/mlir/Conversion/VectorToLLVM/ConvertVectorToLLVM.h
index 0931af0774fef..0d5d1c8b5ffe1 100644
--- a/mlir/include/mlir/Conversion/VectorToLLVM/ConvertVectorToLLVM.h
+++ b/mlir/include/mlir/Conversion/VectorToLLVM/ConvertVectorToLLVM.h
@@ -12,53 +12,11 @@
namespace mlir {
class LLVMTypeConverter;
-class ModuleOp;
-template <typename T>
-class OperationPass;
+class Pass;
-#define GEN_PASS_DECL_CONVERTVECTORTOLLVM
+#define GEN_PASS_DECL_CONVERTVECTORTOLLVMPASS
#include "mlir/Conversion/Passes.h.inc"
-/// Options to control Vector to LLVM lowering.
-///
-/// This should kept in sync with VectorToLLVM options defined for the
-/// ConvertVectorToLLVM pass in include/mlir/Conversion/Passes.td
-struct LowerVectorToLLVMOptions {
- LowerVectorToLLVMOptions() {}
-
- LowerVectorToLLVMOptions &enableReassociateFPReductions(bool b = true) {
- reassociateFPReductions = b;
- return *this;
- }
- LowerVectorToLLVMOptions &enableIndexOptimizations(bool b = true) {
- force32BitVectorIndices = b;
- return *this;
- }
- LowerVectorToLLVMOptions &enableArmNeon(bool b = true) {
- armNeon = b;
- return *this;
- }
- LowerVectorToLLVMOptions &enableArmSVE(bool b = true) {
- armSVE = b;
- return *this;
- }
- LowerVectorToLLVMOptions &enableAMX(bool b = true) {
- amx = b;
- return *this;
- }
- LowerVectorToLLVMOptions &enableX86Vector(bool b = true) {
- x86Vector = b;
- return *this;
- }
-
- bool reassociateFPReductions{false};
- bool force32BitVectorIndices{true};
- bool armNeon{false};
- bool armSVE{false};
- bool amx{false};
- bool x86Vector{false};
-};
-
/// 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.
@@ -70,10 +28,6 @@ void populateVectorToLLVMConversionPatterns(
LLVMTypeConverter &converter, RewritePatternSet &patterns,
bool reassociateFPReductions = false, bool force32BitVectorIndices = false);
-/// Create a pass to convert vector operations to the LLVMIR dialect.
-std::unique_ptr<OperationPass<ModuleOp>> createConvertVectorToLLVMPass(
- const LowerVectorToLLVMOptions &options = LowerVectorToLLVMOptions());
-
} // namespace mlir
#endif // MLIR_CONVERSION_VECTORTOLLVM_CONVERTVECTORTOLLVM_H_
diff --git a/mlir/include/mlir/Dialect/GPU/Transforms/Passes.h b/mlir/include/mlir/Dialect/GPU/Transforms/Passes.h
index e3eee6de84879..a74db79bcefa2 100644
--- a/mlir/include/mlir/Dialect/GPU/Transforms/Passes.h
+++ b/mlir/include/mlir/Dialect/GPU/Transforms/Passes.h
@@ -13,6 +13,7 @@
#ifndef MLIR_DIALECT_GPU_TRANSFORMS_PASSES_H_
#define MLIR_DIALECT_GPU_TRANSFORMS_PASSES_H_
+#include "Utils.h"
#include "mlir/Dialect/GPU/IR/GPUDialect.h"
#include "mlir/Pass/Pass.h"
#include <optional>
@@ -61,9 +62,6 @@ inline void populateGpuRewritePatterns(RewritePatternSet &patterns) {
}
namespace gpu {
-/// Returns the default annotation name for GPU binary blobs.
-std::string getDefaultGpuBinaryAnnotation();
-
/// Base pass class to serialize kernel functions through LLVM into
/// user-specified IR and add the resulting blob as module attribute.
class SerializeToBlobPass : public OperationPass<gpu::GPUModuleOp> {
diff --git a/mlir/include/mlir/Dialect/GPU/Transforms/Utils.h b/mlir/include/mlir/Dialect/GPU/Transforms/Utils.h
index e72d2bc41c52a..a426bee7686db 100644
--- a/mlir/include/mlir/Dialect/GPU/Transforms/Utils.h
+++ b/mlir/include/mlir/Dialect/GPU/Transforms/Utils.h
@@ -15,6 +15,8 @@
#include "mlir/Support/LLVM.h"
+#include <string>
+
namespace mlir {
struct LogicalResult;
class Operation;
@@ -23,6 +25,9 @@ class Value;
namespace gpu {
class GPUFuncOp;
class LaunchOp;
+
+/// Returns the default annotation name for GPU binary blobs.
+std::string getDefaultGpuBinaryAnnotation();
} // namespace gpu
/// Get a gpu.func created from outlining the region of a gpu.launch op with the
diff --git a/mlir/include/mlir/Dialect/SparseTensor/Pipelines/Passes.h b/mlir/include/mlir/Dialect/SparseTensor/Pipelines/Passes.h
index 4059cd4cc401a..d3a16de8c5519 100644
--- a/mlir/include/mlir/Dialect/SparseTensor/Pipelines/Passes.h
+++ b/mlir/include/mlir/Dialect/SparseTensor/Pipelines/Passes.h
@@ -118,14 +118,14 @@ struct SparseCompilerOptions
}
/// Projects out the options for `createConvertVectorToLLVMPass`.
- LowerVectorToLLVMOptions lowerVectorToLLVMOptions() const {
- LowerVectorToLLVMOptions opts{};
- opts.enableReassociateFPReductions(reassociateFPReductions);
- opts.enableIndexOptimizations(force32BitVectorIndices);
- opts.enableArmNeon(armNeon);
- opts.enableArmSVE(armSVE);
- opts.enableAMX(amx);
- opts.enableX86Vector(x86Vector);
+ ConvertVectorToLLVMPassOptions lowerVectorToLLVMOptions() const {
+ ConvertVectorToLLVMPassOptions opts{};
+ opts.reassociateFPReductions = reassociateFPReductions;
+ opts.force32BitVectorIndices = force32BitVectorIndices;
+ opts.armNeon = armNeon;
+ opts.armSVE = armSVE;
+ opts.amx = amx;
+ opts.x86Vector = x86Vector;
return opts;
}
};
diff --git a/mlir/lib/Conversion/AsyncToLLVM/AsyncToLLVM.cpp b/mlir/lib/Conversion/AsyncToLLVM/AsyncToLLVM.cpp
index f1acd84aae809..38041bdec474a 100644
--- a/mlir/lib/Conversion/AsyncToLLVM/AsyncToLLVM.cpp
+++ b/mlir/lib/Conversion/AsyncToLLVM/AsyncToLLVM.cpp
@@ -25,7 +25,7 @@
#include "llvm/ADT/TypeSwitch.h"
namespace mlir {
-#define GEN_PASS_DEF_CONVERTASYNCTOLLVM
+#define GEN_PASS_DEF_CONVERTASYNCTOLLVMPASS
#include "mlir/Conversion/Passes.h.inc"
} // namespace mlir
@@ -1098,7 +1098,9 @@ class ReturnOpOpConversion : public OpConversionPattern<func::ReturnOp> {
namespace {
struct ConvertAsyncToLLVMPass
- : public impl::ConvertAsyncToLLVMBase<ConvertAsyncToLLVMPass> {
+ : public impl::ConvertAsyncToLLVMPassBase<ConvertAsyncToLLVMPass> {
+ using Base::Base;
+
void runOnOperation() override;
};
} // namespace
@@ -1234,10 +1236,6 @@ class ConvertYieldOpTypes : public OpConversionPattern<async::YieldOp> {
};
} // namespace
-std::unique_ptr<OperationPass<ModuleOp>> mlir::createConvertAsyncToLLVMPass() {
- return std::make_unique<ConvertAsyncToLLVMPass>();
-}
-
void mlir::populateAsyncStructuralTypeConversionsAndLegality(
TypeConverter &typeConverter, RewritePatternSet &patterns,
ConversionTarget &target) {
diff --git a/mlir/lib/Conversion/ComplexToLLVM/ComplexToLLVM.cpp b/mlir/lib/Conversion/ComplexToLLVM/ComplexToLLVM.cpp
index 14f32d66d2447..7185b01afdc00 100644
--- a/mlir/lib/Conversion/ComplexToLLVM/ComplexToLLVM.cpp
+++ b/mlir/lib/Conversion/ComplexToLLVM/ComplexToLLVM.cpp
@@ -16,7 +16,7 @@
#include "mlir/Pass/Pass.h"
namespace mlir {
-#define GEN_PASS_DEF_CONVERTCOMPLEXTOLLVM
+#define GEN_PASS_DEF_CONVERTCOMPLEXTOLLVMPASS
#include "mlir/Conversion/Passes.h.inc"
} // namespace mlir
@@ -323,7 +323,9 @@ void mlir::populateComplexToLLVMConversionPatterns(
namespace {
struct ConvertComplexToLLVMPass
- : public impl::ConvertComplexToLLVMBase<ConvertComplexToLLVMPass> {
+ : public impl::ConvertComplexToLLVMPassBase<ConvertComplexToLLVMPass> {
+ using Base::Base;
+
void runOnOperation() override;
};
} // namespace
@@ -340,7 +342,3 @@ void ConvertComplexToLLVMPass::runOnOperation() {
applyPartialConversion(getOperation(), target, std::move(patterns))))
signalPassFailure();
}
-
-std::unique_ptr<Pass> mlir::createConvertComplexToLLVMPass() {
- return std::make_unique<ConvertComplexToLLVMPass>();
-}
diff --git a/mlir/lib/Conversion/ControlFlowToLLVM/ControlFlowToLLVM.cpp b/mlir/lib/Conversion/ControlFlowToLLVM/ControlFlowToLLVM.cpp
index 6748b7b0543f7..f58f9b4761ad8 100644
--- a/mlir/lib/Conversion/ControlFlowToLLVM/ControlFlowToLLVM.cpp
+++ b/mlir/lib/Conversion/ControlFlowToLLVM/ControlFlowToLLVM.cpp
@@ -27,7 +27,7 @@
#include <functional>
namespace mlir {
-#define GEN_PASS_DEF_CONVERTCONTROLFLOWTOLLVM
+#define GEN_PASS_DEF_CONVERTCONTROLFLOWTOLLVMPASS
#include "mlir/Conversion/Passes.h.inc"
} // namespace mlir
@@ -264,8 +264,9 @@ void mlir::cf::populateAssertToLLVMConversionPattern(
namespace {
/// A pass converting MLIR operations into the LLVM IR dialect.
struct ConvertControlFlowToLLVM
- : public impl::ConvertControlFlowToLLVMBase<ConvertControlFlowToLLVM> {
- ConvertControlFlowToLLVM() = default;
+ : public impl::ConvertControlFlowToLLVMPassBase<ConvertControlFlowToLLVM> {
+
+ using Base::Base;
/// Run the dialect converter on the module.
void runOnOperation() override {
@@ -286,7 +287,3 @@ struct ConvertControlFlowToLLVM
}
};
} // namespace
-
-std::unique_ptr<Pass> mlir::cf::createConvertControlFlowToLLVMPass() {
- return std::make_unique<ConvertControlFlowToLLVM>();
-}
diff --git a/mlir/lib/Conversion/GPUCommon/GPUToLLVMConversion.cpp b/mlir/lib/Conversion/GPUCommon/GPUToLLVMConversion.cpp
index 683ae6dfce2a5..3f61be5471e7b 100644
--- a/mlir/lib/Conversion/GPUCommon/GPUToLLVMConversion.cpp
+++ b/mlir/lib/Conversion/GPUCommon/GPUToLLVMConversion.cpp
@@ -52,30 +52,10 @@ namespace {
class GpuToLLVMConversionPass
: public impl::GpuToLLVMConversionPassBase<GpuToLLVMConversionPass> {
public:
- GpuToLLVMConversionPass() = default;
-
- GpuToLLVMConversionPass(bool kernelBarePtrCallConv)
- : GpuToLLVMConversionPass() {
- if (this->kernelBarePtrCallConv.getNumOccurrences() == 0)
- this->kernelBarePtrCallConv = kernelBarePtrCallConv;
- }
-
- GpuToLLVMConversionPass(const GpuToLLVMConversionPass &other)
- : GpuToLLVMConversionPassBase(other) {}
+ using Base::Base;
// Run the dialect converter on the module.
void runOnOperation() override;
-
-private:
- Option<std::string> gpuBinaryAnnotation{
- *this, "gpu-binary-annotation",
- llvm::cl::desc("Annotation attribute string for GPU binary"),
- llvm::cl::init(gpu::getDefaultGpuBinaryAnnotation())};
- Option<bool> kernelBarePtrCallConv{
- *this, "use-bare-pointers-for-kernels",
- llvm::cl::desc("Use bare pointers to pass memref arguments to kernels. "
- "The kernel must use the same setting for this option."),
- llvm::cl::init(false)};
};
struct FunctionCallBuilder {
@@ -905,11 +885,6 @@ LogicalResult ConvertSetDefaultDeviceOpToGpuRuntimeCallPattern::matchAndRewrite(
return success();
}
-std::unique_ptr<mlir::OperationPass<mlir::ModuleOp>>
-mlir::createGpuToLLVMConversionPass(bool kernelBarePtrCallConv) {
- return std::make_unique<GpuToLLVMConversionPass>(kernelBarePtrCallConv);
-}
-
void mlir::populateGpuToLLVMConversionPatterns(LLVMTypeConverter &converter,
RewritePatternSet &patterns,
StringRef gpuBinaryAnnotation,
diff --git a/mlir/lib/Conversion/LinalgToLLVM/LinalgToLLVM.cpp b/mlir/lib/Conversion/LinalgToLLVM/LinalgToLLVM.cpp
index 8c4f8ac201d3a..8eb7bbe3e5033 100644
--- a/mlir/lib/Conversion/LinalgToLLVM/LinalgToLLVM.cpp
+++ b/mlir/lib/Conversion/LinalgToLLVM/LinalgToLLVM.cpp
@@ -41,7 +41,7 @@
#include "llvm/Support/ErrorHandling.h"
namespace mlir {
-#define GEN_PASS_DEF_CONVERTLINALGTOLLVM
+#define GEN_PASS_DEF_CONVERTLINALGTOLLVMPASS
#include "mlir/Conversion/Passes.h.inc"
} // namespace mlir
@@ -78,7 +78,7 @@ void mlir::populateLinalgToLLVMConversionPatterns(LLVMTypeConverter &converter,
namespace {
struct ConvertLinalgToLLVMPass
- : public impl::ConvertLinalgToLLVMBase<ConvertLinalgToLLVMPass> {
+ : public impl::ConvertLinalgToLLVMPassBase<ConvertLinalgToLLVMPass> {
void runOnOperation() override;
};
} // namespace
@@ -97,7 +97,3 @@ void ConvertLinalgToLLVMPass::runOnOperation() {
if (failed(applyPartialConversion(module, target, std::move(patterns))))
signalPassFailure();
}
-
-std::unique_ptr<OperationPass<ModuleOp>> mlir::createConvertLinalgToLLVMPass() {
- return std::make_unique<ConvertLinalgToLLVMPass>();
-}
diff --git a/mlir/lib/Conversion/MathToLLVM/MathToLLVM.cpp b/mlir/lib/Conversion/MathToLLVM/MathToLLVM.cpp
index ece80921e29b1..888c51238d063 100644
--- a/mlir/lib/Conversion/MathToLLVM/MathToLLVM.cpp
+++ b/mlir/lib/Conversion/MathToLLVM/MathToLLVM.cpp
@@ -18,7 +18,7 @@
#include "mlir/Pass/Pass.h"
namespace mlir {
-#define GEN_PASS_DEF_CONVERTMATHTOLLVM
+#define GEN_PASS_DEF_CONVERTMATHTOLLVMPASS
#include "mlir/Conversion/Passes.h.inc"
} // namespace mlir
@@ -285,8 +285,8 @@ struct RsqrtOpLowering : public ConvertOpToLLVMPattern<math::RsqrtOp> {
};
struct ConvertMathToLLVMPass
- : public impl::ConvertMathToLLVMBase<ConvertMathToLLVMPass> {
- ConvertMathToLLVMPass() = default;
+ : public impl::ConvertMathToLLVMPassBase<ConvertMathToLLVMPass> {
+ using Base::Base;
void runOnOperation() override {
RewritePatternSet patterns(&getContext());
@@ -332,7 +332,3 @@ void mlir::populateMathToLLVMConversionPatterns(LLVMTypeConverter &converter,
>(converter);
// clang-format on
}
-
-std::unique_ptr<Pass> mlir::createConvertMathToLLVMPass() {
- return std::make_unique<ConvertMathToLLVMPass>();
-}
diff --git a/mlir/lib/Conversion/OpenACCToLLVM/OpenACCToLLVM.cpp b/mlir/lib/Conversion/OpenACCToLLVM/OpenACCToLLVM.cpp
index 54f3e44f0c17a..16863206ac051 100644
--- a/mlir/lib/Conversion/OpenACCToLLVM/OpenACCToLLVM.cpp
+++ b/mlir/lib/Conversion/OpenACCToLLVM/OpenACCToLLVM.cpp
@@ -15,7 +15,7 @@
#include "mlir/Pass/Pass.h"
namespace mlir {
-#define GEN_PASS_DEF_CONVERTOPENACCTOLLVM
+#define GEN_PASS_DEF_CONVERTOPENACCTOLLVMPASS
#include "mlir/Conversion/Passes.h.inc"
} // namespace mlir
@@ -154,7 +154,9 @@ void mlir::populateOpenACCToLLVMConversionPatterns(
namespace {
struct ConvertOpenACCToLLVMPass
- : public impl::ConvertOpenACCToLLVMBase<ConvertOpenACCToLLVMPass> {
+ : public impl::ConvertOpenACCToLLVMPassBase<ConvertOpenACCToLLVMPass> {
+ using Base::Base;
+
void runOnOperation() override;
};
} // namespace
@@ -238,8 +240,3 @@ void ConvertOpenACCToLLVMPass::runOnOperation() {
if (failed(applyPartialConversion(op, target, std::move(patterns))))
signalPassFailure();
}
-
-std::unique_ptr<OperationPass<ModuleOp>>
-mlir::createConvertOpenACCToLLVMPass() {
- return std::make_unique<ConvertOpenACCToLLVMPass>();
-}
diff --git a/mlir/lib/Conversion/OpenMPToLLVM/OpenMPToLLVM.cpp b/mlir/lib/Conversion/OpenMPToLLVM/OpenMPToLLVM.cpp
index cbb6f6c24aa9e..c12a2e9bd3348 100644
--- a/mlir/lib/Conversion/OpenMPToLLVM/OpenMPToLLVM.cpp
+++ b/mlir/lib/Conversion/OpenMPToLLVM/OpenMPToLLVM.cpp
@@ -20,7 +20,7 @@
#include "mlir/Pass/Pass.h"
namespace mlir {
-#define GEN_PASS_DEF_CONVERTOPENMPTOLLVM
+#define GEN_PASS_DEF_CONVERTOPENMPTOLLVMPASS
#include "mlir/Conversion/Passes.h.inc"
} // namespace mlir
@@ -153,7 +153,9 @@ void mlir::populateOpenMPToLLVMConversionPatterns(LLVMTypeConverter &converter,
namespace {
struct ConvertOpenMPToLLVMPass
- : public impl::ConvertOpenMPToLLVMBase<ConvertOpenMPToLLVMPass> {
+ : public impl::ConvertOpenMPToLLVMPassBase<ConvertOpenMPToLLVMPass> {
+ using Base::Base;
+
void runOnOperation() override;
};
} // namespace
@@ -177,7 +179,3 @@ void ConvertOpenMPToLLVMPass::runOnOperation() {
if (failed(applyPartialConversion(module, target, std::move(patterns))))
signalPassFailure();
}
-
-std::unique_ptr<OperationPass<ModuleOp>> mlir::createConvertOpenMPToLLVMPass() {
- return std::make_unique<ConvertOpenMPToLLVMPass>();
-}
diff --git a/mlir/lib/Conversion/SPIRVToLLVM/ConvertLaunchFuncToLLVMCalls.cpp b/mlir/lib/Conversion/SPIRVToLLVM/ConvertLaunchFuncToLLVMCalls.cpp
index 919fc3e402dd7..7803593d73a74 100644
--- a/mlir/lib/Conversion/SPIRVToLLVM/ConvertLaunchFuncToLLVMCalls.cpp
+++ b/mlir/lib/Conversion/SPIRVToLLVM/ConvertLaunchFuncToLLVMCalls.cpp
@@ -33,7 +33,7 @@
#include "llvm/Support/FormatVariadic.h"
namespace mlir {
-#define GEN_PASS_DEF_LOWERHOSTCODETOLLVM
+#define GEN_PASS_DEF_LOWERHOSTCODETOLLVMPASS
#include "mlir/Conversion/Passes.h.inc"
} // namespace mlir
@@ -281,8 +281,11 @@ class GPULaunchLowering : public ConvertOpToLLVMPattern<gpu::LaunchFuncOp> {
};
class LowerHostCodeToLLVM
- : public impl::LowerHostCodeToLLVMBase<LowerHostCodeToLLVM> {
+ : public impl::LowerHostCodeToLLVMPassBase<LowerHostCodeToLLVM> {
public:
+
+ using Base::Base;
+
void runOnOperation() override {
ModuleOp module = getOperation();
@@ -327,8 +330,3 @@ class LowerHostCodeToLLVM
}
};
} // namespace
-
-std::unique_ptr<mlir::OperationPass<mlir::ModuleOp>>
-mlir::createLowerHostCodeToLLVMPass() {
- return std::make_unique<LowerHostCodeToLLVM>();
-}
diff --git a/mlir/lib/Conversion/SPIRVToLLVM/SPIRVToLLVMPass.cpp b/mlir/lib/Conversion/SPIRVToLLVM/SPIRVToLLVMPass.cpp
index a2f3c8adf3952..7766d8d9a0c9d 100644
--- a/mlir/lib/Conversion/SPIRVToLLVM/SPIRVToLLVMPass.cpp
+++ b/mlir/lib/Conversion/SPIRVToLLVM/SPIRVToLLVMPass.cpp
@@ -19,7 +19,7 @@
#include "mlir/Pass/Pass.h"
namespace mlir {
-#define GEN_PASS_DEF_CONVERTSPIRVTOLLVM
+#define GEN_PASS_DEF_CONVERTSPIRVTOLLVMPASS
#include "mlir/Conversion/Passes.h.inc"
} // namespace mlir
@@ -28,8 +28,11 @@ using namespace mlir;
namespace {
/// A pass converting MLIR SPIR-V operations into LLVM dialect.
class ConvertSPIRVToLLVMPass
- : public impl::ConvertSPIRVToLLVMBase<ConvertSPIRVToLLVMPass> {
+ : public impl::ConvertSPIRVToLLVMPassBase<ConvertSPIRVToLLVMPass> {
void runOnOperation() override;
+
+public:
+ using Base::Base;
};
} // namespace
@@ -58,7 +61,3 @@ void ConvertSPIRVToLLVMPass::runOnOperation() {
if (failed(applyPartialConversion(module, target, std::move(patterns))))
signalPassFailure();
}
-
-std::unique_ptr<OperationPass<ModuleOp>> mlir::createConvertSPIRVToLLVMPass() {
- return std::make_unique<ConvertSPIRVToLLVMPass>();
-}
diff --git a/mlir/lib/Conversion/VectorToLLVM/ConvertVectorToLLVMPass.cpp b/mlir/lib/Conversion/VectorToLLVM/ConvertVectorToLLVMPass.cpp
index a1667ff25b128..dcf04b7ed58da 100644
--- a/mlir/lib/Conversion/VectorToLLVM/ConvertVectorToLLVMPass.cpp
+++ b/mlir/lib/Conversion/VectorToLLVM/ConvertVectorToLLVMPass.cpp
@@ -26,7 +26,7 @@
#include "mlir/Transforms/GreedyPatternRewriteDriver.h"
namespace mlir {
-#define GEN_PASS_DEF_CONVERTVECTORTOLLVM
+#define GEN_PASS_DEF_CONVERTVECTORTOLLVMPASS
#include "mlir/Conversion/Passes.h.inc"
} // namespace mlir
@@ -35,15 +35,10 @@ using namespace mlir::vector;
namespace {
struct LowerVectorToLLVMPass
- : public impl::ConvertVectorToLLVMBase<LowerVectorToLLVMPass> {
- LowerVectorToLLVMPass(const LowerVectorToLLVMOptions &options) {
- this->reassociateFPReductions = options.reassociateFPReductions;
- this->force32BitVectorIndices = options.force32BitVectorIndices;
- this->armNeon = options.armNeon;
- this->armSVE = options.armSVE;
- this->amx = options.amx;
- this->x86Vector = options.x86Vector;
- }
+ : public impl::ConvertVectorToLLVMPassBase<LowerVectorToLLVMPass> {
+
+ using Base::Base;
+
// Override explicitly to allow conditional dialect dependence.
void getDependentDialects(DialectRegistry ®istry) const override {
registry.insert<LLVM::LLVMDialect>();
@@ -116,8 +111,3 @@ void LowerVectorToLLVMPass::runOnOperation() {
applyPartialConversion(getOperation(), target, std::move(patterns))))
signalPassFailure();
}
-
-std::unique_ptr<OperationPass<ModuleOp>>
-mlir::createConvertVectorToLLVMPass(const LowerVectorToLLVMOptions &options) {
- return std::make_unique<LowerVectorToLLVMPass>(options);
-}
diff --git a/mlir/test/lib/Dialect/LLVM/TestLowerToLLVM.cpp b/mlir/test/lib/Dialect/LLVM/TestLowerToLLVM.cpp
index d7159e66d2c5e..f3506226b16c1 100644
--- a/mlir/test/lib/Dialect/LLVM/TestLowerToLLVM.cpp
+++ b/mlir/test/lib/Dialect/LLVM/TestLowerToLLVM.cpp
@@ -65,8 +65,7 @@ void buildTestLowerToLLVM(OpPassManager &pm,
// Convert vector to LLVM (always needed).
pm.addPass(createConvertVectorToLLVMPass(
// TODO: add more options on a per-need basis.
- LowerVectorToLLVMOptions().enableReassociateFPReductions(
- options.reassociateFPReductions)));
+ ConvertVectorToLLVMPassOptions{options.reassociateFPReductions}));
// Convert Math to LLVM (always needed).
pm.addNestedPass<func::FuncOp>(createConvertMathToLLVMPass());
// Expand complicated MemRef operations before lowering them.
More information about the Mlir-commits
mailing list