|
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"
|
@@ -2042,13 +2041,13 @@ struct ExtractValueOpConversion
|
2042 | 2041 | /// InsertValue is the generalized instruction for the composition of new
|
2043 | 2042 | /// aggregate type values.
|
2044 | 2043 | struct InsertValueOpConversion
|
2045 |
| - : public fir::FIROpAndTypeConversion<fir::InsertValueOp>, |
| 2044 | + : public mlir::OpConversionPattern<fir::InsertValueOp>, |
2046 | 2045 | public ValueOpCommon {
|
2047 |
| - using FIROpAndTypeConversion::FIROpAndTypeConversion; |
| 2046 | + using OpConversionPattern::OpConversionPattern; |
2048 | 2047 |
|
2049 | 2048 | llvm::LogicalResult
|
2050 |
| - doRewrite(fir::InsertValueOp insertVal, mlir::Type ty, OpAdaptor adaptor, |
2051 |
| - mlir::ConversionPatternRewriter &rewriter) const override { |
| 2049 | + matchAndRewrite(fir::InsertValueOp insertVal, OpAdaptor adaptor, |
| 2050 | + mlir::ConversionPatternRewriter &rewriter) const override { |
2052 | 2051 | mlir::ValueRange operands = adaptor.getOperands();
|
2053 | 2052 | auto indices = collectIndices(rewriter, insertVal.getCoor());
|
2054 | 2053 | toRowMajor(indices, operands[0].getType());
|
@@ -2669,8 +2668,9 @@ struct TypeDescOpConversion : public fir::FIROpConversion<fir::TypeDescOp> {
|
2669 | 2668 | };
|
2670 | 2669 |
|
2671 | 2670 | /// Lower `fir.has_value` operation to `llvm.return` operation.
|
2672 |
| -struct HasValueOpConversion : public fir::FIROpConversion<fir::HasValueOp> { |
2673 |
| - using FIROpConversion::FIROpConversion; |
| 2671 | +struct HasValueOpConversion |
| 2672 | + : public mlir::OpConversionPattern<fir::HasValueOp> { |
| 2673 | + using OpConversionPattern::OpConversionPattern; |
2674 | 2674 |
|
2675 | 2675 | llvm::LogicalResult
|
2676 | 2676 | matchAndRewrite(fir::HasValueOp op, OpAdaptor adaptor,
|
@@ -3515,29 +3515,6 @@ struct MustBeDeadConversion : public fir::FIROpConversion<FromOp> {
|
3515 | 3515 | }
|
3516 | 3516 | };
|
3517 | 3517 |
|
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 | 3518 | struct ShapeOpConversion : public MustBeDeadConversion<fir::ShapeOp> {
|
3542 | 3519 | using MustBeDeadConversion::MustBeDeadConversion;
|
3543 | 3520 | };
|
@@ -3714,7 +3691,8 @@ class FIRToLLVMLowering
|
3714 | 3691 | signalPassFailure();
|
3715 | 3692 | }
|
3716 | 3693 |
|
3717 |
| - // Run pass to add comdats to functions that have weak linkage on relevant platforms |
| 3694 | + // Run pass to add comdats to functions that have weak linkage on relevant |
| 3695 | + // platforms |
3718 | 3696 | if (fir::getTargetTriple(mod).supportsCOMDAT()) {
|
3719 | 3697 | mlir::OpPassManager comdatPM("builtin.module");
|
3720 | 3698 | comdatPM.addPass(mlir::LLVM::createLLVMAddComdats());
|
@@ -3789,16 +3767,19 @@ void fir::populateFIRToLLVMConversionPatterns(
|
3789 | 3767 | DivcOpConversion, EmboxOpConversion, EmboxCharOpConversion,
|
3790 | 3768 | EmboxProcOpConversion, ExtractValueOpConversion, FieldIndexOpConversion,
|
3791 | 3769 | 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, |
3802 |
| - XEmboxOpConversion, XReboxOpConversion, ZeroOpConversion>(converter, |
3803 |
| - options); |
| 3770 | + GlobalOpConversion, InsertOnRangeOpConversion, IsPresentOpConversion, |
| 3771 | + LenParamIndexOpConversion, LoadOpConversion, MulcOpConversion, |
| 3772 | + NegcOpConversion, NoReassocOpConversion, SelectCaseOpConversion, |
| 3773 | + SelectOpConversion, SelectRankOpConversion, SelectTypeOpConversion, |
| 3774 | + ShapeOpConversion, ShapeShiftOpConversion, ShiftOpConversion, |
| 3775 | + SliceOpConversion, StoreOpConversion, StringLitOpConversion, |
| 3776 | + SubcOpConversion, TypeDescOpConversion, TypeInfoOpConversion, |
| 3777 | + UnboxCharOpConversion, UnboxProcOpConversion, UndefOpConversion, |
| 3778 | + UnreachableOpConversion, XArrayCoorOpConversion, XEmboxOpConversion, |
| 3779 | + XReboxOpConversion, ZeroOpConversion>(converter, options); |
| 3780 | + |
| 3781 | + // Patterns that are populated without a type converter do not trigger |
| 3782 | + // target materializations for the operands of the root op. |
| 3783 | + patterns.insert<HasValueOpConversion, InsertValueOpConversion>( |
| 3784 | + patterns.getContext()); |
3804 | 3785 | }
|
0 commit comments