|
35 | 35 | #include "mlir/Conversion/MathToLLVM/MathToLLVM.h"
|
36 | 36 | #include "mlir/Conversion/MathToLibm/MathToLibm.h"
|
37 | 37 | #include "mlir/Conversion/OpenMPToLLVM/ConvertOpenMPToLLVM.h"
|
38 |
| -#include "mlir/Conversion/ReconcileUnrealizedCasts/ReconcileUnrealizedCasts.h" |
39 | 38 | #include "mlir/Conversion/VectorToLLVM/ConvertVectorToLLVM.h"
|
40 | 39 | #include "mlir/Dialect/Arith/IR/Arith.h"
|
41 | 40 | #include "mlir/Dialect/DLTI/DLTI.h"
|
@@ -1726,10 +1725,9 @@ struct XReboxOpConversion : public EmboxCommonConversion<fir::cg::XReboxOp> {
|
1726 | 1725 | // fir.box was translated to an llvm.ptr<llvm.struct<>> and the MLIR pass
|
1727 | 1726 | // manager inserted a builtin.unrealized_conversion_cast that was inserted
|
1728 | 1727 | // and needs to be removed here.
|
1729 |
| - if (isInGlobalOp(rewriter)) |
1730 |
| - if (auto unrealizedCast = |
1731 |
| - loweredBox.getDefiningOp<mlir::UnrealizedConversionCastOp>()) |
1732 |
| - loweredBox = unrealizedCast.getInputs()[0]; |
| 1728 | + if (auto unrealizedCast = |
| 1729 | + loweredBox.getDefiningOp<mlir::UnrealizedConversionCastOp>()) |
| 1730 | + loweredBox = unrealizedCast.getInputs()[0]; |
1733 | 1731 |
|
1734 | 1732 | TypePair inputBoxTyPair = getBoxTypePair(rebox.getBox().getType());
|
1735 | 1733 |
|
@@ -2669,8 +2667,9 @@ struct TypeDescOpConversion : public fir::FIROpConversion<fir::TypeDescOp> {
|
2669 | 2667 | };
|
2670 | 2668 |
|
2671 | 2669 | /// Lower `fir.has_value` operation to `llvm.return` operation.
|
2672 |
| -struct HasValueOpConversion : public fir::FIROpConversion<fir::HasValueOp> { |
2673 |
| - using FIROpConversion::FIROpConversion; |
| 2670 | +struct HasValueOpConversion |
| 2671 | + : public mlir::OpConversionPattern<fir::HasValueOp> { |
| 2672 | + using OpConversionPattern::OpConversionPattern; |
2674 | 2673 |
|
2675 | 2674 | llvm::LogicalResult
|
2676 | 2675 | matchAndRewrite(fir::HasValueOp op, OpAdaptor adaptor,
|
@@ -3515,29 +3514,6 @@ struct MustBeDeadConversion : public fir::FIROpConversion<FromOp> {
|
3515 | 3514 | }
|
3516 | 3515 | };
|
3517 | 3516 |
|
3518 |
| -struct UnrealizedConversionCastOpConversion |
3519 |
| - : public fir::FIROpConversion<mlir::UnrealizedConversionCastOp> { |
3520 |
| - using FIROpConversion::FIROpConversion; |
3521 |
| - |
3522 |
| - llvm::LogicalResult |
3523 |
| - matchAndRewrite(mlir::UnrealizedConversionCastOp op, OpAdaptor adaptor, |
3524 |
| - mlir::ConversionPatternRewriter &rewriter) const override { |
3525 |
| - assert(op.getOutputs().getTypes().size() == 1 && "expect a single type"); |
3526 |
| - mlir::Type convertedType = convertType(op.getOutputs().getTypes()[0]); |
3527 |
| - if (convertedType == adaptor.getInputs().getTypes()[0]) { |
3528 |
| - rewriter.replaceOp(op, adaptor.getInputs()); |
3529 |
| - return mlir::success(); |
3530 |
| - } |
3531 |
| - |
3532 |
| - convertedType = adaptor.getInputs().getTypes()[0]; |
3533 |
| - if (convertedType == op.getOutputs().getType()[0]) { |
3534 |
| - rewriter.replaceOp(op, adaptor.getInputs()); |
3535 |
| - return mlir::success(); |
3536 |
| - } |
3537 |
| - return mlir::failure(); |
3538 |
| - } |
3539 |
| -}; |
3540 |
| - |
3541 | 3517 | struct ShapeOpConversion : public MustBeDeadConversion<fir::ShapeOp> {
|
3542 | 3518 | using MustBeDeadConversion::MustBeDeadConversion;
|
3543 | 3519 | };
|
@@ -3714,7 +3690,8 @@ class FIRToLLVMLowering
|
3714 | 3690 | signalPassFailure();
|
3715 | 3691 | }
|
3716 | 3692 |
|
3717 |
| - // Run pass to add comdats to functions that have weak linkage on relevant platforms |
| 3693 | + // Run pass to add comdats to functions that have weak linkage on relevant |
| 3694 | + // platforms |
3718 | 3695 | if (fir::getTargetTriple(mod).supportsCOMDAT()) {
|
3719 | 3696 | mlir::OpPassManager comdatPM("builtin.module");
|
3720 | 3697 | comdatPM.addPass(mlir::LLVM::createLLVMAddComdats());
|
@@ -3789,16 +3766,17 @@ void fir::populateFIRToLLVMConversionPatterns(
|
3789 | 3766 | DivcOpConversion, EmboxOpConversion, EmboxCharOpConversion,
|
3790 | 3767 | EmboxProcOpConversion, ExtractValueOpConversion, FieldIndexOpConversion,
|
3791 | 3768 | FirEndOpConversion, FreeMemOpConversion, GlobalLenOpConversion,
|
3792 |
| - GlobalOpConversion, HasValueOpConversion, InsertOnRangeOpConversion, |
3793 |
| - InsertValueOpConversion, IsPresentOpConversion, LenParamIndexOpConversion, |
3794 |
| - LoadOpConversion, MulcOpConversion, NegcOpConversion, |
3795 |
| - NoReassocOpConversion, SelectCaseOpConversion, SelectOpConversion, |
3796 |
| - SelectRankOpConversion, SelectTypeOpConversion, ShapeOpConversion, |
3797 |
| - ShapeShiftOpConversion, ShiftOpConversion, SliceOpConversion, |
3798 |
| - StoreOpConversion, StringLitOpConversion, SubcOpConversion, |
3799 |
| - TypeDescOpConversion, TypeInfoOpConversion, UnboxCharOpConversion, |
3800 |
| - UnboxProcOpConversion, UndefOpConversion, UnreachableOpConversion, |
3801 |
| - UnrealizedConversionCastOpConversion, XArrayCoorOpConversion, |
| 3769 | + GlobalOpConversion, InsertOnRangeOpConversion, InsertValueOpConversion, |
| 3770 | + IsPresentOpConversion, LenParamIndexOpConversion, LoadOpConversion, |
| 3771 | + MulcOpConversion, NegcOpConversion, NoReassocOpConversion, |
| 3772 | + SelectCaseOpConversion, SelectOpConversion, SelectRankOpConversion, |
| 3773 | + SelectTypeOpConversion, ShapeOpConversion, ShapeShiftOpConversion, |
| 3774 | + ShiftOpConversion, SliceOpConversion, StoreOpConversion, |
| 3775 | + StringLitOpConversion, SubcOpConversion, TypeDescOpConversion, |
| 3776 | + TypeInfoOpConversion, UnboxCharOpConversion, UnboxProcOpConversion, |
| 3777 | + UndefOpConversion, UnreachableOpConversion, XArrayCoorOpConversion, |
3802 | 3778 | XEmboxOpConversion, XReboxOpConversion, ZeroOpConversion>(converter,
|
3803 | 3779 | options);
|
| 3780 | + |
| 3781 | + patterns.insert<HasValueOpConversion>(patterns.getContext()); |
3804 | 3782 | }
|
0 commit comments