Fix AffineDemotion pass after the DialectConversion change in D111620

This commit is contained in:
River Riddle 2021-10-27 04:11:49 +00:00
parent db2b1e96f0
commit 4283168603
1 changed files with 15 additions and 13 deletions

View File

@ -42,13 +42,14 @@ using namespace fir;
namespace {
class AffineLoadConversion : public OpRewritePattern<mlir::AffineLoadOp> {
class AffineLoadConversion : public OpConversionPattern<mlir::AffineLoadOp> {
public:
using OpRewritePattern<mlir::AffineLoadOp>::OpRewritePattern;
using OpConversionPattern<mlir::AffineLoadOp>::OpConversionPattern;
LogicalResult matchAndRewrite(mlir::AffineLoadOp op,
PatternRewriter &rewriter) const override {
SmallVector<Value> indices(op.getMapOperands());
LogicalResult
matchAndRewrite(mlir::AffineLoadOp op, OpAdaptor adaptor,
ConversionPatternRewriter &rewriter) const override {
SmallVector<Value> indices(adaptor.indices());
auto maybeExpandedMap =
expandAffineMap(rewriter, op.getLoc(), op.getAffineMap(), indices);
if (!maybeExpandedMap)
@ -56,20 +57,21 @@ public:
auto coorOp = rewriter.create<fir::CoordinateOp>(
op.getLoc(), fir::ReferenceType::get(op.getResult().getType()),
op.getMemRef(), *maybeExpandedMap);
adaptor.memref(), *maybeExpandedMap);
rewriter.replaceOpWithNewOp<fir::LoadOp>(op, coorOp.getResult());
return success();
}
};
class AffineStoreConversion : public OpRewritePattern<mlir::AffineStoreOp> {
class AffineStoreConversion : public OpConversionPattern<mlir::AffineStoreOp> {
public:
using OpRewritePattern<mlir::AffineStoreOp>::OpRewritePattern;
using OpConversionPattern<mlir::AffineStoreOp>::OpConversionPattern;
LogicalResult matchAndRewrite(mlir::AffineStoreOp op,
PatternRewriter &rewriter) const override {
SmallVector<Value> indices(op.getMapOperands());
LogicalResult
matchAndRewrite(mlir::AffineStoreOp op, OpAdaptor adaptor,
ConversionPatternRewriter &rewriter) const override {
SmallVector<Value> indices(op.indices());
auto maybeExpandedMap =
expandAffineMap(rewriter, op.getLoc(), op.getAffineMap(), indices);
if (!maybeExpandedMap)
@ -77,8 +79,8 @@ public:
auto coorOp = rewriter.create<fir::CoordinateOp>(
op.getLoc(), fir::ReferenceType::get(op.getValueToStore().getType()),
op.getMemRef(), *maybeExpandedMap);
rewriter.replaceOpWithNewOp<fir::StoreOp>(op, op.getValueToStore(),
adaptor.memref(), *maybeExpandedMap);
rewriter.replaceOpWithNewOp<fir::StoreOp>(op, adaptor.value(),
coorOp.getResult());
return success();
}