forked from OSchip/llvm-project
[MLIR] Migrate Arithmetic -> LLVM conversion pass to the auto-generated constructor
See #57475 Differential Revision: https://reviews.llvm.org/D134752
This commit is contained in:
parent
c29d911fd3
commit
b1ce63bb5f
|
@ -17,14 +17,12 @@ class LLVMTypeConverter;
|
|||
class RewritePatternSet;
|
||||
class Pass;
|
||||
|
||||
#define GEN_PASS_DECL_CONVERTARITHMETICTOLLVM
|
||||
#define GEN_PASS_DECL_ARITHMETICTOLLVMCONVERSIONPASS
|
||||
#include "mlir/Conversion/Passes.h.inc"
|
||||
|
||||
namespace arith {
|
||||
void populateArithmeticToLLVMConversionPatterns(LLVMTypeConverter &converter,
|
||||
RewritePatternSet &patterns);
|
||||
|
||||
std::unique_ptr<Pass> createConvertArithmeticToLLVMPass();
|
||||
} // namespace arith
|
||||
} // namespace mlir
|
||||
|
||||
|
|
|
@ -96,12 +96,11 @@ def ConvertAMDGPUToROCDL : Pass<"convert-amdgpu-to-rocdl"> {
|
|||
// ArithmeticToLLVM
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
def ConvertArithmeticToLLVM : Pass<"convert-arith-to-llvm"> {
|
||||
def ArithmeticToLLVMConversionPass : Pass<"convert-arith-to-llvm"> {
|
||||
let summary = "Convert Arithmetic dialect to LLVM dialect";
|
||||
let description = [{
|
||||
This pass converts supported Arithmetic ops to LLVM dialect instructions.
|
||||
}];
|
||||
let constructor = "mlir::arith::createConvertArithmeticToLLVMPass()";
|
||||
let dependentDialects = ["LLVM::LLVMDialect"];
|
||||
let options = [
|
||||
Option<"indexBitwidth", "index-bitwidth", "unsigned",
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
#include "mlir/Pass/Pass.h"
|
||||
|
||||
namespace mlir {
|
||||
#define GEN_PASS_DEF_CONVERTARITHMETICTOLLVM
|
||||
#define GEN_PASS_DEF_ARITHMETICTOLLVMCONVERSIONPASS
|
||||
#include "mlir/Conversion/Passes.h.inc"
|
||||
} // namespace mlir
|
||||
|
||||
|
@ -320,9 +320,10 @@ CmpFOpLowering::matchAndRewrite(arith::CmpFOp op, OpAdaptor adaptor,
|
|||
//===----------------------------------------------------------------------===//
|
||||
|
||||
namespace {
|
||||
struct ConvertArithmeticToLLVMPass
|
||||
: public impl::ConvertArithmeticToLLVMBase<ConvertArithmeticToLLVMPass> {
|
||||
ConvertArithmeticToLLVMPass() = default;
|
||||
struct ArithmeticToLLVMConversionPass
|
||||
: public impl::ArithmeticToLLVMConversionPassBase<
|
||||
ArithmeticToLLVMConversionPass> {
|
||||
using Base::Base;
|
||||
|
||||
void runOnOperation() override {
|
||||
LLVMConversionTarget target(getContext());
|
||||
|
@ -395,7 +396,3 @@ void mlir::arith::populateArithmeticToLLVMConversionPatterns(
|
|||
>(converter);
|
||||
// clang-format on
|
||||
}
|
||||
|
||||
std::unique_ptr<Pass> mlir::arith::createConvertArithmeticToLLVMPass() {
|
||||
return std::make_unique<ConvertArithmeticToLLVMPass>();
|
||||
}
|
||||
|
|
|
@ -35,8 +35,8 @@ void lowerModuleToLLVM(MlirContext ctx, MlirModule module) {
|
|||
MlirOpPassManager opm = mlirPassManagerGetNestedUnder(
|
||||
pm, mlirStringRefCreateFromCString("func.func"));
|
||||
mlirPassManagerAddOwnedPass(pm, mlirCreateConversionConvertFuncToLLVM());
|
||||
mlirOpPassManagerAddOwnedPass(opm,
|
||||
mlirCreateConversionConvertArithmeticToLLVM());
|
||||
mlirOpPassManagerAddOwnedPass(
|
||||
opm, mlirCreateConversionArithmeticToLLVMConversionPass());
|
||||
MlirLogicalResult status = mlirPassManagerRun(pm, module);
|
||||
if (mlirLogicalResultIsFailure(status)) {
|
||||
fprintf(stderr, "Unexpected failure running pass pipeline\n");
|
||||
|
|
|
@ -54,8 +54,7 @@ static struct LLVMInitializer {
|
|||
static LogicalResult lowerToLLVMDialect(ModuleOp module) {
|
||||
PassManager pm(module.getContext());
|
||||
pm.addPass(mlir::createMemRefToLLVMConversionPass());
|
||||
pm.addNestedPass<func::FuncOp>(
|
||||
mlir::arith::createConvertArithmeticToLLVMPass());
|
||||
pm.addNestedPass<func::FuncOp>(mlir::createArithmeticToLLVMConversionPass());
|
||||
pm.addPass(mlir::createConvertFuncToLLVMPass());
|
||||
pm.addPass(mlir::createReconcileUnrealizedCastsPass());
|
||||
return pm.run(module);
|
||||
|
|
Loading…
Reference in New Issue