diff --git a/mlir/include/mlir/Conversion/FuncToLLVM/ConvertFuncToLLVMPass.h b/mlir/include/mlir/Conversion/FuncToLLVM/ConvertFuncToLLVMPass.h --- a/mlir/include/mlir/Conversion/FuncToLLVM/ConvertFuncToLLVMPass.h +++ b/mlir/include/mlir/Conversion/FuncToLLVM/ConvertFuncToLLVMPass.h @@ -13,20 +13,11 @@ #include namespace mlir { -class LowerToLLVMOptions; -class ModuleOp; -template -class OperationPass; class Pass; -#define GEN_PASS_DECL_CONVERTFUNCTOLLVM +#define GEN_PASS_DECL_CONVERTFUNCTOLLVMPASS #include "mlir/Conversion/Passes.h.inc" -/// Creates a pass to convert the Func dialect into the LLVMIR dialect. -std::unique_ptr> createConvertFuncToLLVMPass(); -std::unique_ptr> -createConvertFuncToLLVMPass(const LowerToLLVMOptions &options); - } // namespace mlir #endif // MLIR_CONVERSION_FUNCTOLLVM_CONVERTFUNCTOLLVMPASS_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 @@ -276,7 +276,7 @@ // FuncToLLVM //===----------------------------------------------------------------------===// -def ConvertFuncToLLVM : Pass<"convert-func-to-llvm", "ModuleOp"> { +def ConvertFuncToLLVMPass : Pass<"convert-func-to-llvm", "ModuleOp"> { let summary = "Convert from the Func dialect to the LLVM dialect"; let description = [{ Convert Func dialect operations into the LLVM IR dialect operations. @@ -300,7 +300,6 @@ returns are updated accordingly. Block argument types are updated to use LLVM IR types. }]; - let constructor = "mlir::createConvertFuncToLLVMPass()"; let dependentDialects = ["LLVM::LLVMDialect"]; let options = [ Option<"useBarePtrCallConv", "use-bare-ptr-memref-call-conv", "bool", diff --git a/mlir/lib/Conversion/FuncToLLVM/FuncToLLVM.cpp b/mlir/lib/Conversion/FuncToLLVM/FuncToLLVM.cpp --- a/mlir/lib/Conversion/FuncToLLVM/FuncToLLVM.cpp +++ b/mlir/lib/Conversion/FuncToLLVM/FuncToLLVM.cpp @@ -48,7 +48,7 @@ #include namespace mlir { -#define GEN_PASS_DEF_CONVERTFUNCTOLLVM +#define GEN_PASS_DEF_CONVERTFUNCTOLLVMPASS #include "mlir/Conversion/Passes.h.inc" } // namespace mlir @@ -711,15 +711,8 @@ namespace { /// A pass converting Func operations into the LLVM IR dialect. struct ConvertFuncToLLVMPass - : public impl::ConvertFuncToLLVMBase { - ConvertFuncToLLVMPass() = default; - ConvertFuncToLLVMPass(bool useBarePtrCallConv, unsigned indexBitwidth, - bool useAlignedAlloc, - const llvm::DataLayout &dataLayout) { - this->useBarePtrCallConv = useBarePtrCallConv; - this->indexBitwidth = indexBitwidth; - this->dataLayout = dataLayout.getStringRepresentation(); - } + : public impl::ConvertFuncToLLVMPassBase { + using Base::Base; /// Run the dialect converter on the module. void runOnOperation() override { @@ -761,21 +754,3 @@ } }; } // namespace - -std::unique_ptr> mlir::createConvertFuncToLLVMPass() { - return std::make_unique(); -} - -std::unique_ptr> -mlir::createConvertFuncToLLVMPass(const LowerToLLVMOptions &options) { - auto allocLowering = options.allocLowering; - // There is no way to provide additional patterns for pass, so - // AllocLowering::None will always fail. - assert(allocLowering != LowerToLLVMOptions::AllocLowering::None && - "ConvertFuncToLLVMPass doesn't support AllocLowering::None"); - bool useAlignedAlloc = - (allocLowering == LowerToLLVMOptions::AllocLowering::AlignedAlloc); - return std::make_unique( - options.useBarePtrCallConv, options.getIndexBitwidth(), useAlignedAlloc, - options.dataLayout); -} diff --git a/mlir/test/CAPI/execution_engine.c b/mlir/test/CAPI/execution_engine.c --- a/mlir/test/CAPI/execution_engine.c +++ b/mlir/test/CAPI/execution_engine.c @@ -34,7 +34,7 @@ MlirPassManager pm = mlirPassManagerCreate(ctx); MlirOpPassManager opm = mlirPassManagerGetNestedUnder( pm, mlirStringRefCreateFromCString("func.func")); - mlirPassManagerAddOwnedPass(pm, mlirCreateConversionConvertFuncToLLVM()); + mlirPassManagerAddOwnedPass(pm, mlirCreateConversionConvertFuncToLLVMPass()); mlirOpPassManagerAddOwnedPass( opm, mlirCreateConversionArithToLLVMConversionPass()); MlirLogicalResult status = mlirPassManagerRun(pm, module); diff --git a/mlir/tools/mlir-vulkan-runner/mlir-vulkan-runner.cpp b/mlir/tools/mlir-vulkan-runner/mlir-vulkan-runner.cpp --- a/mlir/tools/mlir-vulkan-runner/mlir-vulkan-runner.cpp +++ b/mlir/tools/mlir-vulkan-runner/mlir-vulkan-runner.cpp @@ -69,11 +69,13 @@ modulePM.addPass(spirv::createSPIRVWebGPUPreparePass()); passManager.addPass(createConvertGpuLaunchFuncToVulkanLaunchFuncPass()); - LowerToLLVMOptions llvmOptions(module.getContext(), DataLayout(module)); passManager.addPass(createFinalizeMemRefToLLVMConversionPass()); passManager.addPass(createConvertVectorToLLVMPass()); passManager.nest().addPass(LLVM::createRequestCWrappersPass()); - passManager.addPass(createConvertFuncToLLVMPass(llvmOptions)); + ConvertFuncToLLVMPassOptions funcToLLVMOptions{}; + funcToLLVMOptions.indexBitwidth = + DataLayout(module).getTypeSizeInBits(IndexType::get(module.getContext())); + passManager.addPass(createConvertFuncToLLVMPass(funcToLLVMOptions)); passManager.addPass(createReconcileUnrealizedCastsPass()); passManager.addPass(createConvertVulkanLaunchFuncToVulkanCallsPass());