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 @@ -14,19 +14,14 @@ namespace mlir { class ConversionTarget; -class ModuleOp; -template -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> 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 --- a/mlir/include/mlir/Conversion/ComplexToLLVM/ComplexToLLVM.h +++ b/mlir/include/mlir/Conversion/ComplexToLLVM/ComplexToLLVM.h @@ -15,7 +15,7 @@ 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 @@ /// 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 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 --- a/mlir/include/mlir/Conversion/ControlFlowToLLVM/ControlFlowToLLVM.h +++ b/mlir/include/mlir/Conversion/ControlFlowToLLVM/ControlFlowToLLVM.h @@ -20,10 +20,11 @@ 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 populateAssertToLLVMConversionPattern(LLVMTypeConverter &converter, RewritePatternSet &patterns, bool abortOnFailure = true); - -/// Creates a pass to convert the ControlFlow dialect into the LLVMIR dialect. -std::unique_ptr createConvertControlFlowToLLVMPass(); } // namespace cf } // namespace mlir diff --git a/mlir/include/mlir/Conversion/GPUCommon/GPUCommonPass.h b/mlir/include/mlir/Conversion/GPUCommon/GPUCommonPass.h --- 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 @@ -27,8 +28,7 @@ class Operation; class RewritePatternSet; -template -class OperationPass; +class Pass; namespace gpu { class GPUModuleOp; @@ -47,15 +47,6 @@ using LoweringCallback = std::function( 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> -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 --- 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 -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> 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 --- a/mlir/include/mlir/Conversion/MathToLLVM/MathToLLVM.h +++ b/mlir/include/mlir/Conversion/MathToLLVM/MathToLLVM.h @@ -17,13 +17,11 @@ 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 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 --- 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 -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 @@ /// 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> 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 --- a/mlir/include/mlir/Conversion/OpenMPToLLVM/ConvertOpenMPToLLVM.h +++ b/mlir/include/mlir/Conversion/OpenMPToLLVM/ConvertOpenMPToLLVM.h @@ -14,12 +14,10 @@ class LLVMTypeConverter; class ConversionTarget; class MLIRContext; -class ModuleOp; -template -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 @@ /// 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> 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 --- a/mlir/include/mlir/Conversion/Passes.td +++ b/mlir/include/mlir/Conversion/Passes.td @@ -143,14 +143,13 @@ // 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 @@ // 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 @@ // 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 @@ 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 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 @@ // 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 @@ // 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 @@ // 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 @@ // 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 @@ // 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 @@ // 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 @@ 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 --- a/mlir/include/mlir/Conversion/SPIRVToLLVM/SPIRVToLLVMPass.h +++ b/mlir/include/mlir/Conversion/SPIRVToLLVM/SPIRVToLLVMPass.h @@ -16,27 +16,12 @@ #include namespace mlir { -class ModuleOp; -template -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> createLowerHostCodeToLLVMPass(); - -/// Creates a pass to convert SPIR-V operations to the LLVMIR dialect. -std::unique_ptr> 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 --- 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 -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 @@ LLVMTypeConverter &converter, RewritePatternSet &patterns, bool reassociateFPReductions = false, bool force32BitVectorIndices = false); -/// Create a pass to convert vector operations to the LLVMIR dialect. -std::unique_ptr> 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 --- 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 @@ -61,9 +62,6 @@ } 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 { diff --git a/mlir/include/mlir/Dialect/GPU/Transforms/Utils.h b/mlir/include/mlir/Dialect/GPU/Transforms/Utils.h --- 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 + namespace mlir { struct LogicalResult; class Operation; @@ -23,6 +25,9 @@ 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 --- a/mlir/include/mlir/Dialect/SparseTensor/Pipelines/Passes.h +++ b/mlir/include/mlir/Dialect/SparseTensor/Pipelines/Passes.h @@ -118,14 +118,14 @@ } /// 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 --- 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 @@ namespace { struct ConvertAsyncToLLVMPass - : public impl::ConvertAsyncToLLVMBase { + : public impl::ConvertAsyncToLLVMPassBase { + using Base::Base; + void runOnOperation() override; }; } // namespace @@ -1234,10 +1236,6 @@ }; } // namespace -std::unique_ptr> mlir::createConvertAsyncToLLVMPass() { - return std::make_unique(); -} - 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 --- 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 @@ namespace { struct ConvertComplexToLLVMPass - : public impl::ConvertComplexToLLVMBase { + : public impl::ConvertComplexToLLVMPassBase { + using Base::Base; + void runOnOperation() override; }; } // namespace @@ -340,7 +342,3 @@ applyPartialConversion(getOperation(), target, std::move(patterns)))) signalPassFailure(); } - -std::unique_ptr mlir::createConvertComplexToLLVMPass() { - return std::make_unique(); -} diff --git a/mlir/lib/Conversion/ControlFlowToLLVM/ControlFlowToLLVM.cpp b/mlir/lib/Conversion/ControlFlowToLLVM/ControlFlowToLLVM.cpp --- a/mlir/lib/Conversion/ControlFlowToLLVM/ControlFlowToLLVM.cpp +++ b/mlir/lib/Conversion/ControlFlowToLLVM/ControlFlowToLLVM.cpp @@ -27,7 +27,7 @@ #include namespace mlir { -#define GEN_PASS_DEF_CONVERTCONTROLFLOWTOLLVM +#define GEN_PASS_DEF_CONVERTCONTROLFLOWTOLLVMPASS #include "mlir/Conversion/Passes.h.inc" } // namespace mlir @@ -264,8 +264,9 @@ namespace { /// A pass converting MLIR operations into the LLVM IR dialect. struct ConvertControlFlowToLLVM - : public impl::ConvertControlFlowToLLVMBase { - ConvertControlFlowToLLVM() = default; + : public impl::ConvertControlFlowToLLVMPassBase { + + using Base::Base; /// Run the dialect converter on the module. void runOnOperation() override { @@ -286,7 +287,3 @@ } }; } // namespace - -std::unique_ptr mlir::cf::createConvertControlFlowToLLVMPass() { - return std::make_unique(); -} diff --git a/mlir/lib/Conversion/GPUCommon/GPUToLLVMConversion.cpp b/mlir/lib/Conversion/GPUCommon/GPUToLLVMConversion.cpp --- a/mlir/lib/Conversion/GPUCommon/GPUToLLVMConversion.cpp +++ b/mlir/lib/Conversion/GPUCommon/GPUToLLVMConversion.cpp @@ -52,30 +52,10 @@ class GpuToLLVMConversionPass : public impl::GpuToLLVMConversionPassBase { 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 gpuBinaryAnnotation{ - *this, "gpu-binary-annotation", - llvm::cl::desc("Annotation attribute string for GPU binary"), - llvm::cl::init(gpu::getDefaultGpuBinaryAnnotation())}; - Option 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 @@ return success(); } -std::unique_ptr> -mlir::createGpuToLLVMConversionPass(bool kernelBarePtrCallConv) { - return std::make_unique(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 --- 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 @@ namespace { struct ConvertLinalgToLLVMPass - : public impl::ConvertLinalgToLLVMBase { + : public impl::ConvertLinalgToLLVMPassBase { void runOnOperation() override; }; } // namespace @@ -97,7 +97,3 @@ if (failed(applyPartialConversion(module, target, std::move(patterns)))) signalPassFailure(); } - -std::unique_ptr> mlir::createConvertLinalgToLLVMPass() { - return std::make_unique(); -} diff --git a/mlir/lib/Conversion/MathToLLVM/MathToLLVM.cpp b/mlir/lib/Conversion/MathToLLVM/MathToLLVM.cpp --- 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 ConvertMathToLLVMPass - : public impl::ConvertMathToLLVMBase { - ConvertMathToLLVMPass() = default; + : public impl::ConvertMathToLLVMPassBase { + using Base::Base; void runOnOperation() override { RewritePatternSet patterns(&getContext()); @@ -332,7 +332,3 @@ >(converter); // clang-format on } - -std::unique_ptr mlir::createConvertMathToLLVMPass() { - return std::make_unique(); -} diff --git a/mlir/lib/Conversion/OpenACCToLLVM/OpenACCToLLVM.cpp b/mlir/lib/Conversion/OpenACCToLLVM/OpenACCToLLVM.cpp --- 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 @@ namespace { struct ConvertOpenACCToLLVMPass - : public impl::ConvertOpenACCToLLVMBase { + : public impl::ConvertOpenACCToLLVMPassBase { + using Base::Base; + void runOnOperation() override; }; } // namespace @@ -238,8 +240,3 @@ if (failed(applyPartialConversion(op, target, std::move(patterns)))) signalPassFailure(); } - -std::unique_ptr> -mlir::createConvertOpenACCToLLVMPass() { - return std::make_unique(); -} diff --git a/mlir/lib/Conversion/OpenMPToLLVM/OpenMPToLLVM.cpp b/mlir/lib/Conversion/OpenMPToLLVM/OpenMPToLLVM.cpp --- 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 @@ namespace { struct ConvertOpenMPToLLVMPass - : public impl::ConvertOpenMPToLLVMBase { + : public impl::ConvertOpenMPToLLVMPassBase { + using Base::Base; + void runOnOperation() override; }; } // namespace @@ -177,7 +179,3 @@ if (failed(applyPartialConversion(module, target, std::move(patterns)))) signalPassFailure(); } - -std::unique_ptr> mlir::createConvertOpenMPToLLVMPass() { - return std::make_unique(); -} diff --git a/mlir/lib/Conversion/SPIRVToLLVM/ConvertLaunchFuncToLLVMCalls.cpp b/mlir/lib/Conversion/SPIRVToLLVM/ConvertLaunchFuncToLLVMCalls.cpp --- 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 LowerHostCodeToLLVM - : public impl::LowerHostCodeToLLVMBase { + : public impl::LowerHostCodeToLLVMPassBase { public: + + using Base::Base; + void runOnOperation() override { ModuleOp module = getOperation(); @@ -327,8 +330,3 @@ } }; } // namespace - -std::unique_ptr> -mlir::createLowerHostCodeToLLVMPass() { - return std::make_unique(); -} diff --git a/mlir/lib/Conversion/SPIRVToLLVM/SPIRVToLLVMPass.cpp b/mlir/lib/Conversion/SPIRVToLLVM/SPIRVToLLVMPass.cpp --- 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 @@ namespace { /// A pass converting MLIR SPIR-V operations into LLVM dialect. class ConvertSPIRVToLLVMPass - : public impl::ConvertSPIRVToLLVMBase { + : public impl::ConvertSPIRVToLLVMPassBase { void runOnOperation() override; + +public: + using Base::Base; }; } // namespace @@ -58,7 +61,3 @@ if (failed(applyPartialConversion(module, target, std::move(patterns)))) signalPassFailure(); } - -std::unique_ptr> mlir::createConvertSPIRVToLLVMPass() { - return std::make_unique(); -} diff --git a/mlir/lib/Conversion/VectorToLLVM/ConvertVectorToLLVMPass.cpp b/mlir/lib/Conversion/VectorToLLVM/ConvertVectorToLLVMPass.cpp --- 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 @@ namespace { struct LowerVectorToLLVMPass - : public impl::ConvertVectorToLLVMBase { - 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 { + + using Base::Base; + // Override explicitly to allow conditional dialect dependence. void getDependentDialects(DialectRegistry ®istry) const override { registry.insert(); @@ -116,8 +111,3 @@ applyPartialConversion(getOperation(), target, std::move(patterns)))) signalPassFailure(); } - -std::unique_ptr> -mlir::createConvertVectorToLLVMPass(const LowerVectorToLLVMOptions &options) { - return std::make_unique(options); -} diff --git a/mlir/test/lib/Dialect/LLVM/TestLowerToLLVM.cpp b/mlir/test/lib/Dialect/LLVM/TestLowerToLLVM.cpp --- a/mlir/test/lib/Dialect/LLVM/TestLowerToLLVM.cpp +++ b/mlir/test/lib/Dialect/LLVM/TestLowerToLLVM.cpp @@ -65,8 +65,7 @@ // 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(createConvertMathToLLVMPass()); // Expand complicated MemRef operations before lowering them.