[flang-commits] [flang] 149ad3d - [flang][mlir][NFC] Replace uses of raw accessors with prefixed accessors
Shraiysh Vaishay via flang-commits
flang-commits at lists.llvm.org
Tue Feb 15 07:38:01 PST 2022
Author: Shraiysh Vaishay
Date: 2022-02-15T21:07:46+05:30
New Revision: 149ad3d554c6e901a57c7e34e29fba334dcd283c
URL: https://github.com/llvm/llvm-project/commit/149ad3d554c6e901a57c7e34e29fba334dcd283c
DIFF: https://github.com/llvm/llvm-project/commit/149ad3d554c6e901a57c7e34e29fba334dcd283c.diff
LOG: [flang][mlir][NFC] Replace uses of raw accessors with prefixed accessors
`kEmitAccessorPrefix_Raw ` is being removed, and so updating the
accessors to `kEmitAccessorPrefix_Prefixed`.
Reviewed By: clementval
Differential Revision: https://reviews.llvm.org/D119812
Added:
Modified:
flang/include/flang/Optimizer/Builder/FIRBuilder.h
flang/include/flang/Optimizer/Dialect/FIRDialect.td
flang/include/flang/Optimizer/Dialect/FIROps.td
flang/lib/Optimizer/Builder/Character.cpp
flang/lib/Optimizer/Builder/MutableBox.cpp
flang/lib/Optimizer/CodeGen/CodeGen.cpp
flang/lib/Optimizer/CodeGen/PreCGRewrite.cpp
flang/lib/Optimizer/CodeGen/TargetRewrite.cpp
flang/lib/Optimizer/Dialect/FIROps.cpp
flang/lib/Optimizer/Transforms/AbstractResult.cpp
flang/lib/Optimizer/Transforms/AffineDemotion.cpp
flang/lib/Optimizer/Transforms/AffinePromotion.cpp
flang/lib/Optimizer/Transforms/ArrayValueCopy.cpp
flang/lib/Optimizer/Transforms/CharacterConversion.cpp
flang/lib/Optimizer/Transforms/ExternalNameConversion.cpp
flang/lib/Optimizer/Transforms/MemRefDataFlowOpt.cpp
flang/lib/Optimizer/Transforms/MemoryAllocation.cpp
flang/lib/Optimizer/Transforms/RewriteLoop.cpp
flang/unittests/Optimizer/Builder/DoLoopHelperTest.cpp
flang/unittests/Optimizer/Builder/FIRBuilderTest.cpp
flang/unittests/Optimizer/Builder/Runtime/RuntimeCallTestBase.h
Removed:
################################################################################
diff --git a/flang/include/flang/Optimizer/Builder/FIRBuilder.h b/flang/include/flang/Optimizer/Builder/FIRBuilder.h
index 3ed4917616f46..f064ceba94650 100644
--- a/flang/include/flang/Optimizer/Builder/FIRBuilder.h
+++ b/flang/include/flang/Optimizer/Builder/FIRBuilder.h
@@ -294,14 +294,14 @@ class FirOpBuilder : public mlir::OpBuilder {
: ifOp{ifOp}, builder{builder} {}
template <typename CC>
IfBuilder &genThen(CC func) {
- builder.setInsertionPointToStart(&ifOp.thenRegion().front());
+ builder.setInsertionPointToStart(&ifOp.getThenRegion().front());
func();
return *this;
}
template <typename CC>
IfBuilder &genElse(CC func) {
- assert(!ifOp.elseRegion().empty() && "must have else region");
- builder.setInsertionPointToStart(&ifOp.elseRegion().front());
+ assert(!ifOp.getElseRegion().empty() && "must have else region");
+ builder.setInsertionPointToStart(&ifOp.getElseRegion().front());
func();
return *this;
}
diff --git a/flang/include/flang/Optimizer/Dialect/FIRDialect.td b/flang/include/flang/Optimizer/Dialect/FIRDialect.td
index 34008dc46370f..77d34c1d301d1 100644
--- a/flang/include/flang/Optimizer/Dialect/FIRDialect.td
+++ b/flang/include/flang/Optimizer/Dialect/FIRDialect.td
@@ -24,7 +24,7 @@ include "mlir/Interfaces/SideEffectInterfaces.td"
def fir_Dialect : Dialect {
let name = "fir";
let cppNamespace = "::fir";
- let emitAccessorPrefix = kEmitAccessorPrefix_Both;
+ let emitAccessorPrefix = kEmitAccessorPrefix_Prefixed;
let useDefaultTypePrinterParser = 0;
let useDefaultAttributePrinterParser = 0;
}
diff --git a/flang/include/flang/Optimizer/Dialect/FIROps.td b/flang/include/flang/Optimizer/Dialect/FIROps.td
index 8a06f188bf7d4..bc9f1fdae5f53 100644
--- a/flang/include/flang/Optimizer/Dialect/FIROps.td
+++ b/flang/include/flang/Optimizer/Dialect/FIROps.td
@@ -167,12 +167,12 @@ def fir_AllocaOp : fir_Op<"alloca", [AttrSizedOperandSegments,
let extraClassDeclaration = [{
mlir::Type getAllocatedType();
- bool hasLenParams() { return !typeparams().empty(); }
- bool hasShapeOperands() { return !shape().empty(); }
- unsigned numLenParams() { return typeparams().size(); }
- operand_range getLenParams() { return typeparams(); }
- unsigned numShapeOperands() { return shape().size(); }
- operand_range getShapeOperands() { return shape(); }
+ bool hasLenParams() { return !getTypeparams().empty(); }
+ bool hasShapeOperands() { return !getShape().empty(); }
+ unsigned numLenParams() { return getTypeparams().size(); }
+ operand_range getLenParams() { return getTypeparams(); }
+ unsigned numShapeOperands() { return getShape().size(); }
+ operand_range getShapeOperands() { return getShape(); }
static mlir::Type getRefTy(mlir::Type ty);
}];
}
@@ -221,12 +221,12 @@ def fir_AllocMemOp : fir_Op<"allocmem",
let extraClassDeclaration = [{
mlir::Type getAllocatedType();
- bool hasLenParams() { return !typeparams().empty(); }
- bool hasShapeOperands() { return !shape().empty(); }
- unsigned numLenParams() { return typeparams().size(); }
- operand_range getLenParams() { return typeparams(); }
- unsigned numShapeOperands() { return shape().size(); }
- operand_range getShapeOperands() { return shape(); }
+ bool hasLenParams() { return !getTypeparams().empty(); }
+ bool hasShapeOperands() { return !getShape().empty(); }
+ unsigned numLenParams() { return getTypeparams().size(); }
+ operand_range getLenParams() { return getTypeparams(); }
+ unsigned numShapeOperands() { return getShape().size(); }
+ operand_range getShapeOperands() { return getShape(); }
static mlir::Type getRefTy(mlir::Type ty);
}];
}
@@ -872,8 +872,8 @@ def fir_EmboxOp : fir_Op<"embox", [NoSideEffect, AttrSizedOperandSegments]> {
let hasVerifier = 1;
let extraClassDeclaration = [{
- bool hasLenParams() { return !typeparams().empty(); }
- unsigned numLenParams() { return typeparams().size(); }
+ bool hasLenParams() { return !getTypeparams().empty(); }
+ unsigned numLenParams() { return getTypeparams().size(); }
}];
}
@@ -1804,7 +1804,7 @@ def fir_FieldIndexOp : fir_OneResultOp<"field_index", [NoSideEffect]> {
let extraClassDeclaration = [{
static constexpr llvm::StringRef fieldAttrName() { return "field_id"; }
static constexpr llvm::StringRef typeAttrName() { return "on_type"; }
- llvm::StringRef getFieldName() { return field_id(); }
+ llvm::StringRef getFieldName() { return getFieldId(); }
}];
}
@@ -1868,7 +1868,7 @@ def fir_ShapeShiftOp : fir_Op<"shape_shift", [NoSideEffect]> {
// Logically unzip the origins from the extent values.
std::vector<mlir::Value> getOrigins() {
std::vector<mlir::Value> result;
- for (auto i : llvm::enumerate(pairs()))
+ for (auto i : llvm::enumerate(getPairs()))
if (!(i.index() & 1))
result.push_back(i.value());
return result;
@@ -1877,7 +1877,7 @@ def fir_ShapeShiftOp : fir_Op<"shape_shift", [NoSideEffect]> {
// Logically unzip the extents from the origin values.
std::vector<mlir::Value> getExtents() {
std::vector<mlir::Value> result;
- for (auto i : llvm::enumerate(pairs()))
+ for (auto i : llvm::enumerate(getPairs()))
if (i.index() & 1)
result.push_back(i.value());
return result;
@@ -1970,7 +1970,7 @@ def fir_SliceOp : fir_Op<"slice", [NoSideEffect, AttrSizedOperandSegments]> {
let hasVerifier = 1;
let extraClassDeclaration = [{
- unsigned getOutRank() { return getOutputRank(triples()); }
+ unsigned getOutRank() { return getOutputRank(getTriples()); }
static unsigned getOutputRank(mlir::ValueRange triples);
}];
}
@@ -2182,10 +2182,10 @@ def fir_DoLoopOp : region_Op<"do_loop",
}
/// Get the body of the loop
- mlir::Block *getBody() { return ®ion().front(); }
+ mlir::Block *getBody() { return &getRegion().front(); }
void setUnordered() {
- unorderedAttr(mlir::UnitAttr::get(getContext()));
+ setUnorderedAttr(mlir::UnitAttr::get(getContext()));
}
mlir::BlockArgument iterArgToBlockArg(mlir::Value iterArg);
@@ -2229,13 +2229,13 @@ def fir_IfOp : region_Op<"if", [NoRegionArguments]> {
let extraClassDeclaration = [{
mlir::OpBuilder getThenBodyBuilder() {
- assert(!thenRegion().empty() && "Unexpected empty 'where' region.");
- mlir::Block &body = thenRegion().front();
+ assert(!getThenRegion().empty() && "Unexpected empty 'where' region.");
+ mlir::Block &body = getThenRegion().front();
return mlir::OpBuilder(&body, std::prev(body.end()));
}
mlir::OpBuilder getElseBodyBuilder() {
- assert(!elseRegion().empty() && "Unexpected empty 'other' region.");
- mlir::Block &body = elseRegion().front();
+ assert(!getElseRegion().empty() && "Unexpected empty 'other' region.");
+ mlir::Block &body = getElseRegion().front();
return mlir::OpBuilder(&body, std::prev(body.end()));
}
@@ -2298,7 +2298,7 @@ def fir_IterWhileOp : region_Op<"iterate_while",
static constexpr llvm::StringRef getFinalValueAttrNameStr() {
return "finalValue";
}
- mlir::Block *getBody() { return ®ion().front(); }
+ mlir::Block *getBody() { return &getRegion().front(); }
mlir::Value getIterateVar() { return getBody()->getArgument(1); }
mlir::Value getInductionVar() { return getBody()->getArgument(0); }
mlir::OpBuilder getBodyBuilder() {
@@ -2777,7 +2777,7 @@ def fir_GlobalOp : fir_Op<"global", [IsolatedFromAbove, Symbol]> {
mlir::Type resultType();
/// Return the initializer attribute if it exists, or a null attribute.
- Attribute getValueOrNull() { return initVal().getValueOr(Attribute()); }
+ Attribute getValueOrNull() { return getInitVal().getValueOr(Attribute()); }
/// Append the next initializer value to the `GlobalOp` to construct
/// the variable's initial value.
diff --git a/flang/lib/Optimizer/Builder/Character.cpp b/flang/lib/Optimizer/Builder/Character.cpp
index e4719133f3fa0..b10535635a13d 100644
--- a/flang/lib/Optimizer/Builder/Character.cpp
+++ b/flang/lib/Optimizer/Builder/Character.cpp
@@ -138,8 +138,8 @@ fir::factory::CharacterExprHelper::toExtendedValue(mlir::Value character,
mlir::Value boxCharLen;
if (auto *definingOp = character.getDefiningOp()) {
if (auto box = dyn_cast<fir::EmboxCharOp>(definingOp)) {
- base = box.memref();
- boxCharLen = box.len();
+ base = box.getMemref();
+ boxCharLen = box.getLen();
}
}
if (!boxCharLen) {
diff --git a/flang/lib/Optimizer/Builder/MutableBox.cpp b/flang/lib/Optimizer/Builder/MutableBox.cpp
index 3b9fe3c52b971..5584e7a939132 100644
--- a/flang/lib/Optimizer/Builder/MutableBox.cpp
+++ b/flang/lib/Optimizer/Builder/MutableBox.cpp
@@ -436,7 +436,7 @@ void fir::factory::genFinalization(fir::FirOpBuilder &builder,
auto ifOp = builder.create<fir::IfOp>(loc, isAllocated,
/*withElseRegion=*/false);
auto insPt = builder.saveInsertionPoint();
- builder.setInsertionPointToStart(&ifOp.thenRegion().front());
+ builder.setInsertionPointToStart(&ifOp.getThenRegion().front());
genFinalizeAndFree(builder, loc, addr);
builder.restoreInsertionPoint(insPt);
}
diff --git a/flang/lib/Optimizer/CodeGen/CodeGen.cpp b/flang/lib/Optimizer/CodeGen/CodeGen.cpp
index 331de10c9b1c1..fc32ea633e41b 100644
--- a/flang/lib/Optimizer/CodeGen/CodeGen.cpp
+++ b/flang/lib/Optimizer/CodeGen/CodeGen.cpp
@@ -309,7 +309,7 @@ struct AddrOfOpConversion : public FIROpConversion<fir::AddrOfOp> {
mlir::ConversionPatternRewriter &rewriter) const override {
auto ty = convertType(addr.getType());
rewriter.replaceOpWithNewOp<mlir::LLVM::AddressOfOp>(
- addr, ty, addr.symbol().getRootReference().getValue());
+ addr, ty, addr.getSymbol().getRootReference().getValue());
return success();
}
};
@@ -416,7 +416,7 @@ struct BoxAddrOpConversion : public FIROpConversion<fir::BoxAddrOp> {
mlir::Value a = adaptor.getOperands()[0];
auto loc = boxaddr.getLoc();
mlir::Type ty = convertType(boxaddr.getType());
- if (auto argty = boxaddr.val().getType().dyn_cast<fir::BoxType>()) {
+ if (auto argty = boxaddr.getVal().getType().dyn_cast<fir::BoxType>()) {
rewriter.replaceOp(boxaddr, loadBaseAddrFromBox(loc, ty, a, rewriter));
} else {
auto c0attr = rewriter.getI32IntegerAttr(0);
@@ -640,7 +640,7 @@ struct CmpcOpConversion : public FIROpConversion<fir::CmpcOp> {
mlir::ConversionPatternRewriter &rewriter) const override {
mlir::ValueRange operands = adaptor.getOperands();
mlir::MLIRContext *ctxt = cmp.getContext();
- mlir::Type eleTy = convertType(getComplexEleTy(cmp.lhs().getType()));
+ mlir::Type eleTy = convertType(getComplexEleTy(cmp.getLhs().getType()));
mlir::Type resTy = convertType(cmp.getType());
mlir::Location loc = cmp.getLoc();
auto pos0 = mlir::ArrayAttr::get(ctxt, rewriter.getI32IntegerAttr(0));
@@ -716,8 +716,8 @@ struct ConvertOpConversion : public FIROpConversion<fir::ConvertOp> {
mlir::LogicalResult
matchAndRewrite(fir::ConvertOp convert, OpAdaptor adaptor,
mlir::ConversionPatternRewriter &rewriter) const override {
- auto fromTy = convertType(convert.value().getType());
- auto toTy = convertType(convert.res().getType());
+ auto fromTy = convertType(convert.getValue().getType());
+ auto toTy = convertType(convert.getRes().getType());
mlir::Value op0 = adaptor.getOperands()[0];
if (fromTy == toTy) {
rewriter.replaceOp(convert, op0);
@@ -739,18 +739,18 @@ struct ConvertOpConversion : public FIROpConversion<fir::ConvertOp> {
return rewriter.create<mlir::LLVM::FPExtOp>(loc, toTy, val);
};
// Complex to complex conversion.
- if (fir::isa_complex(convert.value().getType()) &&
- fir::isa_complex(convert.res().getType())) {
+ if (fir::isa_complex(convert.getValue().getType()) &&
+ fir::isa_complex(convert.getRes().getType())) {
// Special case: handle the conversion of a complex such that both the
// real and imaginary parts are converted together.
auto zero = mlir::ArrayAttr::get(convert.getContext(),
rewriter.getI32IntegerAttr(0));
auto one = mlir::ArrayAttr::get(convert.getContext(),
rewriter.getI32IntegerAttr(1));
- auto ty = convertType(getComplexEleTy(convert.value().getType()));
+ auto ty = convertType(getComplexEleTy(convert.getValue().getType()));
auto rp = rewriter.create<mlir::LLVM::ExtractValueOp>(loc, ty, op0, zero);
auto ip = rewriter.create<mlir::LLVM::ExtractValueOp>(loc, ty, op0, one);
- auto nt = convertType(getComplexEleTy(convert.res().getType()));
+ auto nt = convertType(getComplexEleTy(convert.getRes().getType()));
auto fromBits = mlir::LLVM::getPrimitiveTypeSizeInBits(ty);
auto toBits = mlir::LLVM::getPrimitiveTypeSizeInBits(nt);
auto rc = convertFpToFp(rp, fromBits, toBits, nt);
@@ -1051,29 +1051,29 @@ struct GlobalOpConversion : public FIROpConversion<fir::GlobalOp> {
tyAttr = tyAttr.cast<mlir::LLVM::LLVMPointerType>().getElementType();
auto loc = global.getLoc();
mlir::Attribute initAttr{};
- if (global.initVal())
- initAttr = global.initVal().getValue();
- auto linkage = convertLinkage(global.linkName());
- auto isConst = global.constant().hasValue();
+ if (global.getInitVal())
+ initAttr = global.getInitVal().getValue();
+ auto linkage = convertLinkage(global.getLinkName());
+ auto isConst = global.getConstant().hasValue();
auto g = rewriter.create<mlir::LLVM::GlobalOp>(
loc, tyAttr, isConst, linkage, global.getSymName(), initAttr);
auto &gr = g.getInitializerRegion();
- rewriter.inlineRegionBefore(global.region(), gr, gr.end());
+ rewriter.inlineRegionBefore(global.getRegion(), gr, gr.end());
if (!gr.empty()) {
// Replace insert_on_range with a constant dense attribute if the
// initialization is on the full range.
auto insertOnRangeOps = gr.front().getOps<fir::InsertOnRangeOp>();
for (auto insertOp : insertOnRangeOps) {
- if (isFullRange(insertOp.coor(), insertOp.getType())) {
+ if (isFullRange(insertOp.getCoor(), insertOp.getType())) {
auto seqTyAttr = convertType(insertOp.getType());
- auto *op = insertOp.val().getDefiningOp();
+ auto *op = insertOp.getVal().getDefiningOp();
auto constant = mlir::dyn_cast<mlir::arith::ConstantOp>(op);
if (!constant) {
auto convertOp = mlir::dyn_cast<fir::ConvertOp>(op);
if (!convertOp)
continue;
constant = cast<mlir::arith::ConstantOp>(
- convertOp.value().getDefiningOp());
+ convertOp.getValue().getDefiningOp());
}
mlir::Type vecType = mlir::VectorType::get(
insertOp.getType().getShape(), constant.getType());
@@ -1248,7 +1248,7 @@ static void selectMatchAndRewrite(fir::LLVMTypeConverter &lowering, OP select,
mlir::ConversionPatternRewriter &rewriter) {
unsigned conds = select.getNumConditions();
auto cases = select.getCases().getValue();
- mlir::Value selector = adaptor.selector();
+ mlir::Value selector = adaptor.getSelector();
auto loc = select.getLoc();
assert(conds > 0 && "select must have cases");
@@ -1372,7 +1372,7 @@ struct StoreOpConversion : public FIROpConversion<fir::StoreOp> {
mlir::LogicalResult
matchAndRewrite(fir::StoreOp store, OpAdaptor adaptor,
mlir::ConversionPatternRewriter &rewriter) const override {
- if (store.value().getType().isa<fir::BoxType>()) {
+ if (store.getValue().getType().isa<fir::BoxType>()) {
// fir.box value is actually in memory, load it first before storing it.
mlir::Location loc = store.getLoc();
mlir::Type boxPtrTy = adaptor.getOperands()[0].getType();
@@ -2277,7 +2277,7 @@ struct ExtractValueOpConversion
mlir::LogicalResult
doRewrite(fir::ExtractValueOp extractVal, mlir::Type ty, OpAdaptor adaptor,
mlir::ConversionPatternRewriter &rewriter) const override {
- auto attrs = collectIndices(rewriter, extractVal.coor());
+ auto attrs = collectIndices(rewriter, extractVal.getCoor());
toRowMajor(attrs, adaptor.getOperands()[0].getType());
auto position = mlir::ArrayAttr::get(extractVal.getContext(), attrs);
rewriter.replaceOpWithNewOp<mlir::LLVM::ExtractValueOp>(
@@ -2296,7 +2296,7 @@ struct InsertValueOpConversion
mlir::LogicalResult
doRewrite(fir::InsertValueOp insertVal, mlir::Type ty, OpAdaptor adaptor,
mlir::ConversionPatternRewriter &rewriter) const override {
- auto attrs = collectIndices(rewriter, insertVal.coor());
+ auto attrs = collectIndices(rewriter, insertVal.getCoor());
toRowMajor(attrs, adaptor.getOperands()[0].getType());
auto position = mlir::ArrayAttr::get(insertVal.getContext(), attrs);
rewriter.replaceOpWithNewOp<mlir::LLVM::InsertValueOp>(
@@ -2339,7 +2339,7 @@ struct InsertOnRangeOpConversion
SmallVector<uint64_t> uBounds;
// Unzip the upper and lower bound and convert to a row major format.
- mlir::DenseIntElementsAttr coor = range.coor();
+ mlir::DenseIntElementsAttr coor = range.getCoor();
auto reversedCoor = llvm::reverse(coor.getValues<int64_t>());
for (auto i = reversedCoor.begin(), e = reversedCoor.end(); i != e; ++i) {
uBounds.push_back(*i++);
@@ -2759,7 +2759,7 @@ struct IsPresentOpConversion : public FIROpConversion<fir::IsPresentOp> {
mlir::Location loc = isPresent.getLoc();
auto ptr = adaptor.getOperands()[0];
- if (isPresent.val().getType().isa<fir::BoxCharType>()) {
+ if (isPresent.getVal().getType().isa<fir::BoxCharType>()) {
auto structTy = ptr.getType().cast<mlir::LLVM::LLVMStructType>();
assert(!structTy.isOpaque() && !structTy.getBody().empty());
@@ -2900,8 +2900,8 @@ struct FieldIndexOpConversion : public FIROpConversion<fir::FieldIndexOp> {
mlir::LogicalResult
matchAndRewrite(fir::FieldIndexOp field, OpAdaptor adaptor,
mlir::ConversionPatternRewriter &rewriter) const override {
- auto recTy = field.on_type().cast<fir::RecordType>();
- unsigned index = recTy.getFieldIndex(field.field_id());
+ auto recTy = field.getOnType().cast<fir::RecordType>();
+ unsigned index = recTy.getFieldIndex(field.getFieldId());
if (!fir::hasDynamicSize(recTy)) {
// Derived type has compile-time constant layout. Return index of the
@@ -2915,7 +2915,7 @@ struct FieldIndexOpConversion : public FIROpConversion<fir::FieldIndexOp> {
// generated function to determine the byte offset of the field at runtime.
// This returns a non-constant.
FlatSymbolRefAttr symAttr = mlir::SymbolRefAttr::get(
- field.getContext(), getOffsetMethodName(recTy, field.field_id()));
+ field.getContext(), getOffsetMethodName(recTy, field.getFieldId()));
NamedAttribute callAttr = rewriter.getNamedAttr("callee", symAttr);
NamedAttribute fieldAttr = rewriter.getNamedAttr(
"field", mlir::IntegerAttr::get(lowerTy().indexType(), index));
@@ -3069,7 +3069,8 @@ struct CoordinateOpConversion
// %lenp = fir.len_param_index len1, !fir.type<derived{len1:i32}>
// %addr = coordinate_of %box, %lenp
if (coor.getNumOperands() == 2) {
- mlir::Operation *coordinateDef = (*coor.coor().begin()).getDefiningOp();
+ mlir::Operation *coordinateDef =
+ (*coor.getCoor().begin()).getDefiningOp();
if (isa_and_nonnull<fir::LenParamIndexOp>(coordinateDef)) {
TODO(loc,
"fir.coordinate_of - fir.len_param_index is not supported yet");
diff --git a/flang/lib/Optimizer/CodeGen/PreCGRewrite.cpp b/flang/lib/Optimizer/CodeGen/PreCGRewrite.cpp
index fc0642e698af7..a4c9305daa708 100644
--- a/flang/lib/Optimizer/CodeGen/PreCGRewrite.cpp
+++ b/flang/lib/Optimizer/CodeGen/PreCGRewrite.cpp
@@ -31,15 +31,15 @@ using namespace fir;
static void populateShape(llvm::SmallVectorImpl<mlir::Value> &vec,
ShapeOp shape) {
- vec.append(shape.extents().begin(), shape.extents().end());
+ vec.append(shape.getExtents().begin(), shape.getExtents().end());
}
// Operands of fir.shape_shift split into two vectors.
static void populateShapeAndShift(llvm::SmallVectorImpl<mlir::Value> &shapeVec,
llvm::SmallVectorImpl<mlir::Value> &shiftVec,
ShapeShiftOp shift) {
- auto endIter = shift.pairs().end();
- for (auto i = shift.pairs().begin(); i != endIter;) {
+ auto endIter = shift.getPairs().end();
+ for (auto i = shift.getPairs().begin(); i != endIter;) {
shiftVec.push_back(*i++);
shapeVec.push_back(*i++);
}
@@ -47,7 +47,7 @@ static void populateShapeAndShift(llvm::SmallVectorImpl<mlir::Value> &shapeVec,
static void populateShift(llvm::SmallVectorImpl<mlir::Value> &vec,
ShiftOp shift) {
- vec.append(shift.origins().begin(), shift.origins().end());
+ vec.append(shift.getOrigins().begin(), shift.getOrigins().end());
}
namespace {
@@ -101,8 +101,8 @@ class EmboxConversion : public mlir::OpRewritePattern<EmboxOp> {
shapeOpers.push_back(extVal);
}
auto xbox = rewriter.create<cg::XEmboxOp>(
- loc, embox.getType(), embox.memref(), shapeOpers, llvm::None,
- llvm::None, llvm::None, llvm::None, embox.typeparams());
+ loc, embox.getType(), embox.getMemref(), shapeOpers, llvm::None,
+ llvm::None, llvm::None, llvm::None, embox.getTypeparams());
LLVM_DEBUG(llvm::dbgs() << "rewriting " << embox << " to " << xbox << '\n');
rewriter.replaceOp(embox, xbox.getOperation()->getResults());
return mlir::success();
@@ -127,13 +127,16 @@ class EmboxConversion : public mlir::OpRewritePattern<EmboxOp> {
llvm::SmallVector<mlir::Value> substrOpers;
if (auto s = embox.getSlice())
if (auto sliceOp = dyn_cast_or_null<SliceOp>(s.getDefiningOp())) {
- sliceOpers.assign(sliceOp.triples().begin(), sliceOp.triples().end());
- subcompOpers.assign(sliceOp.fields().begin(), sliceOp.fields().end());
- substrOpers.assign(sliceOp.substr().begin(), sliceOp.substr().end());
+ sliceOpers.assign(sliceOp.getTriples().begin(),
+ sliceOp.getTriples().end());
+ subcompOpers.assign(sliceOp.getFields().begin(),
+ sliceOp.getFields().end());
+ substrOpers.assign(sliceOp.getSubstr().begin(),
+ sliceOp.getSubstr().end());
}
auto xbox = rewriter.create<cg::XEmboxOp>(
- loc, embox.getType(), embox.memref(), shapeOpers, shiftOpers,
- sliceOpers, subcompOpers, substrOpers, embox.typeparams());
+ loc, embox.getType(), embox.getMemref(), shapeOpers, shiftOpers,
+ sliceOpers, subcompOpers, substrOpers, embox.getTypeparams());
LLVM_DEBUG(llvm::dbgs() << "rewriting " << embox << " to " << xbox << '\n');
rewriter.replaceOp(embox, xbox.getOperation()->getResults());
return mlir::success();
@@ -162,7 +165,7 @@ class ReboxConversion : public mlir::OpRewritePattern<ReboxOp> {
auto loc = rebox.getLoc();
llvm::SmallVector<mlir::Value> shapeOpers;
llvm::SmallVector<mlir::Value> shiftOpers;
- if (auto shapeVal = rebox.shape()) {
+ if (auto shapeVal = rebox.getShape()) {
if (auto shapeOp = dyn_cast<ShapeOp>(shapeVal.getDefiningOp()))
populateShape(shapeOpers, shapeOp);
else if (auto shiftOp = dyn_cast<ShapeShiftOp>(shapeVal.getDefiningOp()))
@@ -175,16 +178,19 @@ class ReboxConversion : public mlir::OpRewritePattern<ReboxOp> {
llvm::SmallVector<mlir::Value> sliceOpers;
llvm::SmallVector<mlir::Value> subcompOpers;
llvm::SmallVector<mlir::Value> substrOpers;
- if (auto s = rebox.slice())
+ if (auto s = rebox.getSlice())
if (auto sliceOp = dyn_cast_or_null<SliceOp>(s.getDefiningOp())) {
- sliceOpers.append(sliceOp.triples().begin(), sliceOp.triples().end());
- subcompOpers.append(sliceOp.fields().begin(), sliceOp.fields().end());
- substrOpers.append(sliceOp.substr().begin(), sliceOp.substr().end());
+ sliceOpers.append(sliceOp.getTriples().begin(),
+ sliceOp.getTriples().end());
+ subcompOpers.append(sliceOp.getFields().begin(),
+ sliceOp.getFields().end());
+ substrOpers.append(sliceOp.getSubstr().begin(),
+ sliceOp.getSubstr().end());
}
auto xRebox = rewriter.create<cg::XReboxOp>(
- loc, rebox.getType(), rebox.box(), shapeOpers, shiftOpers, sliceOpers,
- subcompOpers, substrOpers);
+ loc, rebox.getType(), rebox.getBox(), shapeOpers, shiftOpers,
+ sliceOpers, subcompOpers, substrOpers);
LLVM_DEBUG(llvm::dbgs()
<< "rewriting " << rebox << " to " << xRebox << '\n');
rewriter.replaceOp(rebox, xRebox.getOperation()->getResults());
@@ -215,7 +221,7 @@ class ArrayCoorConversion : public mlir::OpRewritePattern<ArrayCoorOp> {
auto loc = arrCoor.getLoc();
llvm::SmallVector<mlir::Value> shapeOpers;
llvm::SmallVector<mlir::Value> shiftOpers;
- if (auto shapeVal = arrCoor.shape()) {
+ if (auto shapeVal = arrCoor.getShape()) {
if (auto shapeOp = dyn_cast<ShapeOp>(shapeVal.getDefiningOp()))
populateShape(shapeOpers, shapeOp);
else if (auto shiftOp = dyn_cast<ShapeShiftOp>(shapeVal.getDefiningOp()))
@@ -227,17 +233,20 @@ class ArrayCoorConversion : public mlir::OpRewritePattern<ArrayCoorOp> {
}
llvm::SmallVector<mlir::Value> sliceOpers;
llvm::SmallVector<mlir::Value> subcompOpers;
- if (auto s = arrCoor.slice())
+ if (auto s = arrCoor.getSlice())
if (auto sliceOp = dyn_cast_or_null<SliceOp>(s.getDefiningOp())) {
- sliceOpers.append(sliceOp.triples().begin(), sliceOp.triples().end());
- subcompOpers.append(sliceOp.fields().begin(), sliceOp.fields().end());
- assert(sliceOp.substr().empty() &&
+ sliceOpers.append(sliceOp.getTriples().begin(),
+ sliceOp.getTriples().end());
+ subcompOpers.append(sliceOp.getFields().begin(),
+ sliceOp.getFields().end());
+ assert(sliceOp.getSubstr().empty() &&
"Don't allow substring operations on array_coor. This "
"restriction may be lifted in the future.");
}
auto xArrCoor = rewriter.create<cg::XArrayCoorOp>(
- loc, arrCoor.getType(), arrCoor.memref(), shapeOpers, shiftOpers,
- sliceOpers, subcompOpers, arrCoor.indices(), arrCoor.typeparams());
+ loc, arrCoor.getType(), arrCoor.getMemref(), shapeOpers, shiftOpers,
+ sliceOpers, subcompOpers, arrCoor.getIndices(),
+ arrCoor.getTypeparams());
LLVM_DEBUG(llvm::dbgs()
<< "rewriting " << arrCoor << " to " << xArrCoor << '\n');
rewriter.replaceOp(arrCoor, xArrCoor.getOperation()->getResults());
diff --git a/flang/lib/Optimizer/CodeGen/TargetRewrite.cpp b/flang/lib/Optimizer/CodeGen/TargetRewrite.cpp
index f1c7ee668fda1..575d267495404 100644
--- a/flang/lib/Optimizer/CodeGen/TargetRewrite.cpp
+++ b/flang/lib/Optimizer/CodeGen/TargetRewrite.cpp
@@ -199,7 +199,7 @@ class TargetRewrite : public TargetRewriteBase<TargetRewrite> {
// to call.
int dropFront = 0;
if constexpr (std::is_same_v<std::decay_t<A>, fir::CallOp>) {
- if (!callOp.callee().hasValue()) {
+ if (!callOp.getCallee().hasValue()) {
newInTys.push_back(fnTy.getInput(0));
newOpers.push_back(callOp.getOperand(0));
dropFront = 1;
@@ -236,10 +236,10 @@ class TargetRewrite : public TargetRewriteBase<TargetRewrite> {
.template Case<BoxCharType>([&](BoxCharType boxTy) {
bool sret;
if constexpr (std::is_same_v<std::decay_t<A>, fir::CallOp>) {
- sret = callOp.callee() &&
+ sret = callOp.getCallee() &&
functionArgIsSRet(index,
getModule().lookupSymbol<mlir::FuncOp>(
- *callOp.callee()));
+ *callOp.getCallee()));
} else {
// TODO: dispatch case; how do we put arguments on a call?
// We cannot put both an sret and the dispatch object first.
@@ -274,7 +274,7 @@ class TargetRewrite : public TargetRewriteBase<TargetRewrite> {
if (factory::isCharacterProcedureTuple(tuple)) {
mlir::ModuleOp module = getModule();
if constexpr (std::is_same_v<std::decay_t<A>, fir::CallOp>) {
- if (callOp.callee()) {
+ if (callOp.getCallee()) {
llvm::StringRef charProcAttr =
fir::getCharacterProcedureDummyAttrName();
// The charProcAttr attribute is only used as a safety to
@@ -282,7 +282,7 @@ class TargetRewrite : public TargetRewriteBase<TargetRewrite> {
// It cannot be used to match because attributes are not
// available in case of indirect calls.
auto funcOp =
- module.lookupSymbol<mlir::FuncOp>(*callOp.callee());
+ module.lookupSymbol<mlir::FuncOp>(*callOp.getCallee());
if (funcOp &&
!funcOp.template getArgAttrOfType<mlir::UnitAttr>(
index, charProcAttr))
@@ -314,8 +314,8 @@ class TargetRewrite : public TargetRewriteBase<TargetRewrite> {
newOpers.insert(newOpers.end(), trailingOpers.begin(), trailingOpers.end());
if constexpr (std::is_same_v<std::decay_t<A>, fir::CallOp>) {
fir::CallOp newCall;
- if (callOp.callee().hasValue()) {
- newCall = rewriter->create<A>(loc, callOp.callee().getValue(),
+ if (callOp.getCallee().hasValue()) {
+ newCall = rewriter->create<A>(loc, callOp.getCallee().getValue(),
newResTys, newOpers);
} else {
// Force new type on the input operand.
@@ -414,7 +414,7 @@ class TargetRewrite : public TargetRewriteBase<TargetRewrite> {
// replace this op with a new one with the updated signature
auto newTy = rewriter->getFunctionType(newInTys, newResTys);
auto newOp =
- rewriter->create<AddrOfOp>(addrOp.getLoc(), newTy, addrOp.symbol());
+ rewriter->create<AddrOfOp>(addrOp.getLoc(), newTy, addrOp.getSymbol());
replaceOp(addrOp, newOp.getResult());
}
diff --git a/flang/lib/Optimizer/Dialect/FIROps.cpp b/flang/lib/Optimizer/Dialect/FIROps.cpp
index 8d2a2ff64a83c..cd6930ea2d5bb 100644
--- a/flang/lib/Optimizer/Dialect/FIROps.cpp
+++ b/flang/lib/Optimizer/Dialect/FIROps.cpp
@@ -135,12 +135,13 @@ static mlir::ParseResult parseAllocatableOp(FN wrapResultType,
template <typename OP>
static void printAllocatableOp(mlir::OpAsmPrinter &p, OP &op) {
- p << ' ' << op.in_type();
- if (!op.typeparams().empty()) {
- p << '(' << op.typeparams() << " : " << op.typeparams().getTypes() << ')';
+ p << ' ' << op.getInType();
+ if (!op.getTypeparams().empty()) {
+ p << '(' << op.getTypeparams() << " : " << op.getTypeparams().getTypes()
+ << ')';
}
// print the shape of the allocation (if any); all must be index type
- for (auto sh : op.shape()) {
+ for (auto sh : op.getShape()) {
p << ", ";
p.printOperand(sh);
}
@@ -339,13 +340,13 @@ mlir::LogicalResult AllocMemOp::verify() {
//===----------------------------------------------------------------------===//
mlir::LogicalResult ArrayCoorOp::verify() {
- auto eleTy = fir::dyn_cast_ptrOrBoxEleTy(memref().getType());
+ auto eleTy = fir::dyn_cast_ptrOrBoxEleTy(getMemref().getType());
auto arrTy = eleTy.dyn_cast<fir::SequenceType>();
if (!arrTy)
return emitOpError("must be a reference to an array");
auto arrDim = arrTy.getDimension();
- if (auto shapeOp = shape()) {
+ if (auto shapeOp = getShape()) {
auto shapeTy = shapeOp.getType();
unsigned shapeTyRank = 0;
if (auto s = shapeTy.dyn_cast<fir::ShapeType>()) {
@@ -355,18 +356,18 @@ mlir::LogicalResult ArrayCoorOp::verify() {
} else {
auto s = shapeTy.cast<fir::ShiftType>();
shapeTyRank = s.getRank();
- if (!memref().getType().isa<fir::BoxType>())
+ if (!getMemref().getType().isa<fir::BoxType>())
return emitOpError("shift can only be provided with fir.box memref");
}
if (arrDim && arrDim != shapeTyRank)
return emitOpError("rank of dimension mismatched");
- if (shapeTyRank != indices().size())
+ if (shapeTyRank != getIndices().size())
return emitOpError("number of indices do not match dim rank");
}
- if (auto sliceOp = slice()) {
+ if (auto sliceOp = getSlice()) {
if (auto sl = mlir::dyn_cast_or_null<fir::SliceOp>(sliceOp.getDefiningOp()))
- if (!sl.substr().empty())
+ if (!sl.getSubstr().empty())
return emitOpError("array_coor cannot take a slice with substring");
if (auto sliceTy = sliceOp.getType().dyn_cast<fir::SliceType>())
if (sliceTy.getRank() != arrDim)
@@ -394,7 +395,7 @@ static mlir::Type adjustedElementType(mlir::Type t) {
}
std::vector<mlir::Value> fir::ArrayLoadOp::getExtents() {
- if (auto sh = shape())
+ if (auto sh = getShape())
if (auto *op = sh.getDefiningOp()) {
if (auto shOp = dyn_cast<fir::ShapeOp>(op)) {
auto extents = shOp.getExtents();
@@ -406,13 +407,13 @@ std::vector<mlir::Value> fir::ArrayLoadOp::getExtents() {
}
mlir::LogicalResult ArrayLoadOp::verify() {
- auto eleTy = fir::dyn_cast_ptrOrBoxEleTy(memref().getType());
+ auto eleTy = fir::dyn_cast_ptrOrBoxEleTy(getMemref().getType());
auto arrTy = eleTy.dyn_cast<fir::SequenceType>();
if (!arrTy)
return emitOpError("must be a reference to an array");
auto arrDim = arrTy.getDimension();
- if (auto shapeOp = shape()) {
+ if (auto shapeOp = getShape()) {
auto shapeTy = shapeOp.getType();
unsigned shapeTyRank = 0;
if (auto s = shapeTy.dyn_cast<fir::ShapeType>()) {
@@ -422,16 +423,16 @@ mlir::LogicalResult ArrayLoadOp::verify() {
} else {
auto s = shapeTy.cast<fir::ShiftType>();
shapeTyRank = s.getRank();
- if (!memref().getType().isa<fir::BoxType>())
+ if (!getMemref().getType().isa<fir::BoxType>())
return emitOpError("shift can only be provided with fir.box memref");
}
if (arrDim && arrDim != shapeTyRank)
return emitOpError("rank of dimension mismatched");
}
- if (auto sliceOp = slice()) {
+ if (auto sliceOp = getSlice()) {
if (auto sl = mlir::dyn_cast_or_null<fir::SliceOp>(sliceOp.getDefiningOp()))
- if (!sl.substr().empty())
+ if (!sl.getSubstr().empty())
return emitOpError("array_load cannot take a slice with substring");
if (auto sliceTy = sliceOp.getType().dyn_cast<fir::SliceType>())
if (sliceTy.getRank() != arrDim)
@@ -446,25 +447,25 @@ mlir::LogicalResult ArrayLoadOp::verify() {
//===----------------------------------------------------------------------===//
mlir::LogicalResult ArrayMergeStoreOp::verify() {
- if (!isa<ArrayLoadOp>(original().getDefiningOp()))
+ if (!isa<ArrayLoadOp>(getOriginal().getDefiningOp()))
return emitOpError("operand #0 must be result of a fir.array_load op");
- if (auto sl = slice()) {
+ if (auto sl = getSlice()) {
if (auto sliceOp =
mlir::dyn_cast_or_null<fir::SliceOp>(sl.getDefiningOp())) {
- if (!sliceOp.substr().empty())
+ if (!sliceOp.getSubstr().empty())
return emitOpError(
"array_merge_store cannot take a slice with substring");
- if (!sliceOp.fields().empty()) {
+ if (!sliceOp.getFields().empty()) {
// This is an intra-object merge, where the slice is projecting the
// subfields that are to be overwritten by the merge operation.
- auto eleTy = fir::dyn_cast_ptrOrBoxEleTy(memref().getType());
+ auto eleTy = fir::dyn_cast_ptrOrBoxEleTy(getMemref().getType());
if (auto seqTy = eleTy.dyn_cast<fir::SequenceType>()) {
auto projTy =
- fir::applyPathToType(seqTy.getEleTy(), sliceOp.fields());
- if (fir::unwrapSequenceType(original().getType()) != projTy)
+ fir::applyPathToType(seqTy.getEleTy(), sliceOp.getFields());
+ if (fir::unwrapSequenceType(getOriginal().getType()) != projTy)
return emitOpError(
"type of origin does not match sliced memref type");
- if (fir::unwrapSequenceType(sequence().getType()) != projTy)
+ if (fir::unwrapSequenceType(getSequence().getType()) != projTy)
return emitOpError(
"type of sequence does not match sliced memref type");
return mlir::success();
@@ -474,10 +475,10 @@ mlir::LogicalResult ArrayMergeStoreOp::verify() {
}
return mlir::success();
}
- auto eleTy = fir::dyn_cast_ptrOrBoxEleTy(memref().getType());
- if (original().getType() != eleTy)
+ auto eleTy = fir::dyn_cast_ptrOrBoxEleTy(getMemref().getType());
+ if (getOriginal().getType() != eleTy)
return emitOpError("type of origin does not match memref element type");
- if (sequence().getType() != eleTy)
+ if (getSequence().getType() != eleTy)
return emitOpError("type of sequence does not match memref element type");
return mlir::success();
}
@@ -489,22 +490,22 @@ mlir::LogicalResult ArrayMergeStoreOp::verify() {
// Template function used for both array_fetch and array_update verification.
template <typename A>
mlir::Type validArraySubobject(A op) {
- auto ty = op.sequence().getType();
- return fir::applyPathToType(ty, op.indices());
+ auto ty = op.getSequence().getType();
+ return fir::applyPathToType(ty, op.getIndices());
}
mlir::LogicalResult ArrayFetchOp::verify() {
- auto arrTy = sequence().getType().cast<fir::SequenceType>();
- auto indSize = indices().size();
+ auto arrTy = getSequence().getType().cast<fir::SequenceType>();
+ auto indSize = getIndices().size();
if (indSize < arrTy.getDimension())
return emitOpError("number of indices != dimension of array");
if (indSize == arrTy.getDimension() &&
- ::adjustedElementType(element().getType()) != arrTy.getEleTy())
+ ::adjustedElementType(getElement().getType()) != arrTy.getEleTy())
return emitOpError("return type does not match array");
auto ty = validArraySubobject(*this);
if (!ty || ty != ::adjustedElementType(getType()))
return emitOpError("return type and/or indices do not type check");
- if (!isa<fir::ArrayLoadOp>(sequence().getDefiningOp()))
+ if (!isa<fir::ArrayLoadOp>(getSequence().getDefiningOp()))
return emitOpError("argument #0 must be result of fir.array_load");
return mlir::success();
}
@@ -514,12 +515,12 @@ mlir::LogicalResult ArrayFetchOp::verify() {
//===----------------------------------------------------------------------===//
mlir::LogicalResult ArrayAccessOp::verify() {
- auto arrTy = sequence().getType().cast<fir::SequenceType>();
- std::size_t indSize = indices().size();
+ auto arrTy = getSequence().getType().cast<fir::SequenceType>();
+ std::size_t indSize = getIndices().size();
if (indSize < arrTy.getDimension())
return emitOpError("number of indices != dimension of array");
if (indSize == arrTy.getDimension() &&
- element().getType() != fir::ReferenceType::get(arrTy.getEleTy()))
+ getElement().getType() != fir::ReferenceType::get(arrTy.getEleTy()))
return emitOpError("return type does not match array");
mlir::Type ty = validArraySubobject(*this);
if (!ty || fir::ReferenceType::get(ty) != getType())
@@ -532,17 +533,17 @@ mlir::LogicalResult ArrayAccessOp::verify() {
//===----------------------------------------------------------------------===//
mlir::LogicalResult ArrayUpdateOp::verify() {
- if (fir::isa_ref_type(merge().getType()))
+ if (fir::isa_ref_type(getMerge().getType()))
return emitOpError("does not support reference type for merge");
- auto arrTy = sequence().getType().cast<fir::SequenceType>();
- auto indSize = indices().size();
+ auto arrTy = getSequence().getType().cast<fir::SequenceType>();
+ auto indSize = getIndices().size();
if (indSize < arrTy.getDimension())
return emitOpError("number of indices != dimension of array");
if (indSize == arrTy.getDimension() &&
- ::adjustedElementType(merge().getType()) != arrTy.getEleTy())
+ ::adjustedElementType(getMerge().getType()) != arrTy.getEleTy())
return emitOpError("merged value does not have element type");
auto ty = validArraySubobject(*this);
- if (!ty || ty != ::adjustedElementType(merge().getType()))
+ if (!ty || ty != ::adjustedElementType(getMerge().getType()))
return emitOpError("merged value and/or indices do not type check");
return mlir::success();
}
@@ -552,8 +553,8 @@ mlir::LogicalResult ArrayUpdateOp::verify() {
//===----------------------------------------------------------------------===//
mlir::LogicalResult ArrayModifyOp::verify() {
- auto arrTy = sequence().getType().cast<fir::SequenceType>();
- auto indSize = indices().size();
+ auto arrTy = getSequence().getType().cast<fir::SequenceType>();
+ auto indSize = getIndices().size();
if (indSize < arrTy.getDimension())
return emitOpError("number of indices must match array dimension");
return mlir::success();
@@ -564,11 +565,11 @@ mlir::LogicalResult ArrayModifyOp::verify() {
//===----------------------------------------------------------------------===//
mlir::OpFoldResult fir::BoxAddrOp::fold(llvm::ArrayRef<mlir::Attribute> opnds) {
- if (auto v = val().getDefiningOp()) {
+ if (auto v = getVal().getDefiningOp()) {
if (auto box = dyn_cast<fir::EmboxOp>(v))
- return box.memref();
+ return box.getMemref();
if (auto box = dyn_cast<fir::EmboxCharOp>(v))
- return box.memref();
+ return box.getMemref();
}
return {};
}
@@ -579,9 +580,9 @@ mlir::OpFoldResult fir::BoxAddrOp::fold(llvm::ArrayRef<mlir::Attribute> opnds) {
mlir::OpFoldResult
fir::BoxCharLenOp::fold(llvm::ArrayRef<mlir::Attribute> opnds) {
- if (auto v = val().getDefiningOp()) {
+ if (auto v = getVal().getDefiningOp()) {
if (auto box = dyn_cast<fir::EmboxCharOp>(v))
- return box.len();
+ return box.getLen();
}
return {};
}
@@ -608,10 +609,10 @@ mlir::FunctionType fir::CallOp::getFunctionType() {
}
void fir::CallOp::print(mlir::OpAsmPrinter &p) {
- bool isDirect = callee().hasValue();
+ bool isDirect = getCallee().hasValue();
p << ' ';
if (isDirect)
- p << callee().getValue();
+ p << getCallee().getValue();
else
p << getOperand(0);
p << '(' << (*this)->getOperands().drop_front(isDirect ? 0 : 1) << ')';
@@ -694,12 +695,12 @@ static void printCmpOp(OpAsmPrinter &p, OPTY op) {
assert(predSym.hasValue() && "invalid symbol value for predicate");
p << '"' << mlir::arith::stringifyCmpFPredicate(predSym.getValue()) << '"'
<< ", ";
- p.printOperand(op.lhs());
+ p.printOperand(op.getLhs());
p << ", ";
- p.printOperand(op.rhs());
+ p.printOperand(op.getRhs());
p.printOptionalAttrDict(op->getAttrs(),
/*elidedAttrs=*/{OPTY::getPredicateAttrName()});
- p << " : " << op.lhs().getType();
+ p << " : " << op.getLhs().getType();
}
template <typename OPTY>
@@ -742,8 +743,8 @@ mlir::LogicalResult CharConvertOp::verify() {
t = fir::unwrapSequenceType(fir::dyn_cast_ptrEleTy(t));
return t.dyn_cast<fir::CharacterType>();
};
- auto inTy = unwrap(from().getType());
- auto outTy = unwrap(to().getType());
+ auto inTy = unwrap(getFrom().getType());
+ auto outTy = unwrap(getTo().getType());
if (!(inTy && outTy))
return emitOpError("not a reference to a character");
if (inTy.getFKind() == outTy.getFKind())
@@ -824,21 +825,22 @@ void fir::ConvertOp::getCanonicalizationPatterns(RewritePatternSet &results,
}
mlir::OpFoldResult fir::ConvertOp::fold(llvm::ArrayRef<mlir::Attribute> opnds) {
- if (value().getType() == getType())
- return value();
- if (matchPattern(value(), m_Op<fir::ConvertOp>())) {
- auto inner = cast<fir::ConvertOp>(value().getDefiningOp());
+ if (getValue().getType() == getType())
+ return getValue();
+ if (matchPattern(getValue(), m_Op<fir::ConvertOp>())) {
+ auto inner = cast<fir::ConvertOp>(getValue().getDefiningOp());
// (convert (convert 'a : logical -> i1) : i1 -> logical) ==> forward 'a
if (auto toTy = getType().dyn_cast<fir::LogicalType>())
- if (auto fromTy = inner.value().getType().dyn_cast<fir::LogicalType>())
+ if (auto fromTy = inner.getValue().getType().dyn_cast<fir::LogicalType>())
if (inner.getType().isa<mlir::IntegerType>() && (toTy == fromTy))
- return inner.value();
+ return inner.getValue();
// (convert (convert 'a : i1 -> logical) : logical -> i1) ==> forward 'a
if (auto toTy = getType().dyn_cast<mlir::IntegerType>())
- if (auto fromTy = inner.value().getType().dyn_cast<mlir::IntegerType>())
+ if (auto fromTy =
+ inner.getValue().getType().dyn_cast<mlir::IntegerType>())
if (inner.getType().isa<fir::LogicalType>() && (toTy == fromTy) &&
(fromTy.getWidth() == 1))
- return inner.value();
+ return inner.getValue();
}
return {};
}
@@ -860,7 +862,7 @@ bool fir::ConvertOp::isPointerCompatible(mlir::Type ty) {
}
mlir::LogicalResult ConvertOp::verify() {
- auto inType = value().getType();
+ auto inType = getValue().getType();
auto outType = getType();
if (inType == outType)
return mlir::success();
@@ -882,7 +884,7 @@ mlir::LogicalResult ConvertOp::verify() {
//===----------------------------------------------------------------------===//
void CoordinateOp::print(mlir::OpAsmPrinter &p) {
- p << ' ' << ref() << ", " << coor();
+ p << ' ' << getRef() << ", " << getCoor();
p.printOptionalAttrDict((*this)->getAttrs(), /*elideAttrs=*/{"baseType"});
p << " : ";
p.printFunctionalType(getOperandTypes(), (*this)->getResultTypes());
@@ -912,7 +914,7 @@ mlir::ParseResult CoordinateOp::parse(mlir::OpAsmParser &parser,
}
mlir::LogicalResult CoordinateOp::verify() {
- auto refTy = ref().getType();
+ auto refTy = getRef().getType();
if (fir::isa_ref_type(refTy)) {
auto eleTy = fir::dyn_cast_ptrEleTy(refTy);
if (auto arrTy = eleTy.dyn_cast<fir::SequenceType>()) {
@@ -928,11 +930,11 @@ mlir::LogicalResult CoordinateOp::verify() {
// Recovering a LEN type parameter only makes sense from a boxed value. For a
// bare reference, the LEN type parameters must be passed as additional
// arguments to `op`.
- for (auto co : coor())
+ for (auto co : getCoor())
if (dyn_cast_or_null<fir::LenParamIndexOp>(co.getDefiningOp())) {
if (getNumOperands() != 2)
return emitOpError("len_param_index must be last argument");
- if (!ref().getType().isa<BoxType>())
+ if (!getRef().getType().isa<BoxType>())
return emitOpError("len_param_index must be used on box type");
}
return mlir::success();
@@ -975,10 +977,10 @@ mlir::ParseResult DispatchOp::parse(mlir::OpAsmParser &parser,
void DispatchOp::print(mlir::OpAsmPrinter &p) {
p << ' ' << getMethodAttr() << '(';
- p.printOperand(object());
- if (!args().empty()) {
+ p.printOperand(getObject());
+ if (!getArgs().empty()) {
p << ", ";
- p.printOperands(args());
+ p.printOperands(getArgs());
}
p << ") : ";
p.printFunctionalType(getOperation()->getOperandTypes(),
@@ -1045,7 +1047,7 @@ mlir::LogicalResult DispatchTableOp::verify() {
//===----------------------------------------------------------------------===//
mlir::LogicalResult EmboxOp::verify() {
- auto eleTy = fir::dyn_cast_ptrEleTy(memref().getType());
+ auto eleTy = fir::dyn_cast_ptrEleTy(getMemref().getType());
bool isArray = false;
if (auto seqTy = eleTy.dyn_cast<fir::SequenceType>()) {
eleTy = seqTy.getEleTy();
@@ -1063,7 +1065,7 @@ mlir::LogicalResult EmboxOp::verify() {
} else {
return emitOpError("LEN parameters require CHARACTER or derived type");
}
- for (auto lp : typeparams())
+ for (auto lp : getTypeparams())
if (!fir::isa_integer(lp.getType()))
return emitOpError("LEN parameters must be integral type");
}
@@ -1079,7 +1081,7 @@ mlir::LogicalResult EmboxOp::verify() {
//===----------------------------------------------------------------------===//
mlir::LogicalResult EmboxCharOp::verify() {
- auto eleTy = fir::dyn_cast_ptrEleTy(memref().getType());
+ auto eleTy = fir::dyn_cast_ptrEleTy(getMemref().getType());
if (!eleTy.dyn_cast_or_null<CharacterType>())
return mlir::failure();
return mlir::success();
@@ -1120,7 +1122,7 @@ mlir::ParseResult EmboxProcOp::parse(mlir::OpAsmParser &parser,
void EmboxProcOp::print(mlir::OpAsmPrinter &p) {
p << ' ' << getOperation()->getAttr("funcname");
- auto h = host();
+ auto h = getHost();
if (h) {
p << ", ";
p.printOperand(h);
@@ -1133,7 +1135,7 @@ void EmboxProcOp::print(mlir::OpAsmPrinter &p) {
mlir::LogicalResult EmboxProcOp::verify() {
// host bindings (optional) must be a reference to a tuple
- if (auto h = host()) {
+ if (auto h = getHost()) {
if (auto r = h.getType().dyn_cast<ReferenceType>()) {
if (!r.getEleTy().dyn_cast<mlir::TupleType>())
return mlir::failure();
@@ -1244,8 +1246,8 @@ ParseResult GlobalOp::parse(OpAsmParser &parser, OperationState &result) {
}
void GlobalOp::print(mlir::OpAsmPrinter &p) {
- if (linkName().hasValue())
- p << ' ' << linkName().getValue();
+ if (getLinkName().hasValue())
+ p << ' ' << getLinkName().getValue();
p << ' ';
p.printAttributeWithoutType(getSymrefAttr());
if (auto val = getValueOrNull())
@@ -1277,9 +1279,10 @@ void fir::GlobalOp::build(mlir::OpBuilder &builder, OperationState &result,
result.addAttribute(symbolAttrNameStr(),
SymbolRefAttr::get(builder.getContext(), name));
if (isConstant)
- result.addAttribute(constantAttrName(result.name), builder.getUnitAttr());
+ result.addAttribute(getConstantAttrName(result.name),
+ builder.getUnitAttr());
if (initialVal)
- result.addAttribute(initValAttrName(result.name), initialVal);
+ result.addAttribute(getInitValAttrName(result.name), initialVal);
if (linkage)
result.addAttribute(linkageAttrName(), linkage);
result.attributes.append(attrs.begin(), attrs.end());
@@ -1391,9 +1394,9 @@ void FieldIndexOp::print(mlir::OpAsmPrinter &p) {
<< ", " << getOperation()->getAttr(fir::FieldIndexOp::typeAttrName());
if (getNumOperands()) {
p << '(';
- p.printOperands(typeparams());
+ p.printOperands(getTypeparams());
const auto *sep = ") : ";
- for (auto op : typeparams()) {
+ for (auto op : getTypeparams()) {
p << sep;
if (op)
p.printType(op.getType());
@@ -1462,9 +1465,9 @@ void printCustomRangeSubscript(mlir::OpAsmPrinter &printer, InsertOnRangeOp op,
/// Range bounds must be nonnegative, and the range must not be empty.
mlir::LogicalResult InsertOnRangeOp::verify() {
- if (fir::hasDynamicSize(seq().getType()))
+ if (fir::hasDynamicSize(getSeq().getType()))
return emitOpError("must have constant shape and size");
- mlir::DenseIntElementsAttr coorAttr = coor();
+ mlir::DenseIntElementsAttr coorAttr = getCoor();
if (coorAttr.size() < 2 || coorAttr.size() % 2 != 0)
return emitOpError("has uneven number of values in ranges");
bool rangeIsKnownToBeNonempty = false;
@@ -1510,14 +1513,14 @@ struct UndoComplexPattern : public mlir::RewritePattern {
if (!insval || !insval.getType().isa<fir::ComplexType>())
return mlir::failure();
auto insval2 =
- dyn_cast_or_null<fir::InsertValueOp>(insval.adt().getDefiningOp());
- if (!insval2 || !isa<fir::UndefOp>(insval2.adt().getDefiningOp()))
+ dyn_cast_or_null<fir::InsertValueOp>(insval.getAdt().getDefiningOp());
+ if (!insval2 || !isa<fir::UndefOp>(insval2.getAdt().getDefiningOp()))
return mlir::failure();
- auto binf = dyn_cast_or_null<FltOp>(insval.val().getDefiningOp());
- auto binf2 = dyn_cast_or_null<FltOp>(insval2.val().getDefiningOp());
- if (!binf || !binf2 || insval.coor().size() != 1 ||
- !isOne(insval.coor()[0]) || insval2.coor().size() != 1 ||
- !isZero(insval2.coor()[0]))
+ auto binf = dyn_cast_or_null<FltOp>(insval.getVal().getDefiningOp());
+ auto binf2 = dyn_cast_or_null<FltOp>(insval2.getVal().getDefiningOp());
+ if (!binf || !binf2 || insval.getCoor().size() != 1 ||
+ !isOne(insval.getCoor()[0]) || insval2.getCoor().size() != 1 ||
+ !isZero(insval2.getCoor()[0]))
return mlir::failure();
auto eai =
dyn_cast_or_null<fir::ExtractValueOp>(binf.getLhs().getDefiningOp());
@@ -1527,14 +1530,14 @@ struct UndoComplexPattern : public mlir::RewritePattern {
dyn_cast_or_null<fir::ExtractValueOp>(binf2.getLhs().getDefiningOp());
auto ebr =
dyn_cast_or_null<fir::ExtractValueOp>(binf2.getRhs().getDefiningOp());
- if (!eai || !ebi || !ear || !ebr || ear.adt() != eai.adt() ||
- ebr.adt() != ebi.adt() || eai.coor().size() != 1 ||
- !isOne(eai.coor()[0]) || ebi.coor().size() != 1 ||
- !isOne(ebi.coor()[0]) || ear.coor().size() != 1 ||
- !isZero(ear.coor()[0]) || ebr.coor().size() != 1 ||
- !isZero(ebr.coor()[0]))
+ if (!eai || !ebi || !ear || !ebr || ear.getAdt() != eai.getAdt() ||
+ ebr.getAdt() != ebi.getAdt() || eai.getCoor().size() != 1 ||
+ !isOne(eai.getCoor()[0]) || ebi.getCoor().size() != 1 ||
+ !isOne(ebi.getCoor()[0]) || ear.getCoor().size() != 1 ||
+ !isZero(ear.getCoor()[0]) || ebr.getCoor().size() != 1 ||
+ !isZero(ebr.getCoor()[0]))
return mlir::failure();
- rewriter.replaceOpWithNewOp<CpxOp>(op, ear.adt(), ebr.adt());
+ rewriter.replaceOpWithNewOp<CpxOp>(op, ear.getAdt(), ebr.getAdt());
return mlir::success();
}
};
@@ -1687,7 +1690,7 @@ static mlir::LogicalResult verify(fir::IterWhileOp op) {
"the induction variable");
auto opNumResults = op.getNumResults();
- if (op.finalValue()) {
+ if (op.getFinalValue()) {
// Result type must be "(index, i1, ...)".
if (!op.getResult(0).getType().isa<mlir::IndexType>())
return op.emitOpError("result #0 expected to be index");
@@ -1711,7 +1714,7 @@ static mlir::LogicalResult verify(fir::IterWhileOp op) {
auto iterOperands = op.getIterOperands();
auto iterArgs = op.getRegionIterArgs();
auto opResults =
- op.finalValue() ? op.getResults().drop_front() : op.getResults();
+ op.getFinalValue() ? op.getResults().drop_front() : op.getResults();
unsigned i = 0;
for (auto e : llvm::zip(iterOperands, iterArgs, opResults)) {
if (std::get<0>(e).getType() != std::get<2>(e).getType())
@@ -1727,8 +1730,8 @@ static mlir::LogicalResult verify(fir::IterWhileOp op) {
}
static void print(mlir::OpAsmPrinter &p, fir::IterWhileOp op) {
- p << " (" << op.getInductionVar() << " = " << op.lowerBound() << " to "
- << op.upperBound() << " step " << op.step() << ") and (";
+ p << " (" << op.getInductionVar() << " = " << op.getLowerBound() << " to "
+ << op.getUpperBound() << " step " << op.getStep() << ") and (";
assert(op.hasIterOperands());
auto regionArgs = op.getRegionIterArgs();
auto operands = op.getIterOperands();
@@ -1740,22 +1743,22 @@ static void print(mlir::OpAsmPrinter &p, fir::IterWhileOp op) {
[&](auto it) { p << std::get<0>(it) << " = " << std::get<1>(it); });
p << ") -> (";
llvm::interleaveComma(
- llvm::drop_begin(op.getResultTypes(), op.finalValue() ? 0 : 1), p);
+ llvm::drop_begin(op.getResultTypes(), op.getFinalValue() ? 0 : 1), p);
p << ")";
- } else if (op.finalValue()) {
+ } else if (op.getFinalValue()) {
p << " -> (" << op.getResultTypes() << ')';
}
p.printOptionalAttrDictWithKeyword(op->getAttrs(),
{op.getFinalValueAttrNameStr()});
p << ' ';
- p.printRegion(op.region(), /*printEntryBlockArgs=*/false,
+ p.printRegion(op.getRegion(), /*printEntryBlockArgs=*/false,
/*printBlockTerminators=*/true);
}
-mlir::Region &fir::IterWhileOp::getLoopBody() { return region(); }
+mlir::Region &fir::IterWhileOp::getLoopBody() { return getRegion(); }
bool fir::IterWhileOp::isDefinedOutsideOfLoop(mlir::Value value) {
- return !region().isAncestor(value.getParentRegion());
+ return !getRegion().isAncestor(value.getParentRegion());
}
mlir::LogicalResult
@@ -1766,23 +1769,23 @@ fir::IterWhileOp::moveOutOfLoop(llvm::ArrayRef<mlir::Operation *> ops) {
}
mlir::BlockArgument fir::IterWhileOp::iterArgToBlockArg(mlir::Value iterArg) {
- for (auto i : llvm::enumerate(initArgs()))
+ for (auto i : llvm::enumerate(getInitArgs()))
if (iterArg == i.value())
- return region().front().getArgument(i.index() + 1);
+ return getRegion().front().getArgument(i.index() + 1);
return {};
}
void fir::IterWhileOp::resultToSourceOps(
llvm::SmallVectorImpl<mlir::Value> &results, unsigned resultNum) {
- auto oper = finalValue() ? resultNum + 1 : resultNum;
- auto *term = region().front().getTerminator();
+ auto oper = getFinalValue() ? resultNum + 1 : resultNum;
+ auto *term = getRegion().front().getTerminator();
if (oper < term->getNumOperands())
results.push_back(term->getOperand(oper));
}
mlir::Value fir::IterWhileOp::blockArgToSourceOp(unsigned blockArgNum) {
- if (blockArgNum > 0 && blockArgNum <= initArgs().size())
- return initArgs()[blockArgNum - 1];
+ if (blockArgNum > 0 && blockArgNum <= getInitArgs().size())
+ return getInitArgs()[blockArgNum - 1];
return {};
}
@@ -1862,9 +1865,9 @@ mlir::ParseResult LoadOp::parse(mlir::OpAsmParser &parser,
void LoadOp::print(mlir::OpAsmPrinter &p) {
p << ' ';
- p.printOperand(memref());
+ p.printOperand(getMemref());
p.printOptionalAttrDict(getOperation()->getAttrs(), {});
- p << " : " << memref().getType();
+ p << " : " << getMemref().getType();
}
//===----------------------------------------------------------------------===//
@@ -1880,7 +1883,8 @@ void fir::DoLoopOp::build(mlir::OpBuilder &builder,
result.addOperands(iterArgs);
if (finalCountValue) {
result.addTypes(builder.getIndexType());
- result.addAttribute(finalValueAttrName(result.name), builder.getUnitAttr());
+ result.addAttribute(getFinalValueAttrName(result.name),
+ builder.getUnitAttr());
}
for (auto v : iterArgs)
result.addTypes(v.getType());
@@ -1893,7 +1897,8 @@ void fir::DoLoopOp::build(mlir::OpBuilder &builder,
iterArgs.getTypes(),
SmallVector<Location>(iterArgs.size(), result.location));
if (unordered)
- result.addAttribute(unorderedAttrName(result.name), builder.getUnitAttr());
+ result.addAttribute(getUnorderedAttrName(result.name),
+ builder.getUnitAttr());
result.addAttributes(attributes);
}
@@ -1950,7 +1955,7 @@ static mlir::ParseResult parseDoLoopOp(mlir::OpAsmParser &parser,
// Induction variable.
if (prependCount)
- result.addAttribute(DoLoopOp::finalValueAttrName(result.name),
+ result.addAttribute(DoLoopOp::getFinalValueAttrName(result.name),
builder.getUnitAttr());
else
argTypes.push_back(indexType);
@@ -1994,8 +1999,8 @@ static mlir::LogicalResult verify(fir::DoLoopOp op) {
if (opNumResults == 0)
return success();
- if (op.finalValue()) {
- if (op.unordered())
+ if (op.getFinalValue()) {
+ if (op.getUnordered())
return op.emitOpError("unordered loop has no final value");
opNumResults--;
}
@@ -2008,7 +2013,7 @@ static mlir::LogicalResult verify(fir::DoLoopOp op) {
auto iterOperands = op.getIterOperands();
auto iterArgs = op.getRegionIterArgs();
auto opResults =
- op.finalValue() ? op.getResults().drop_front() : op.getResults();
+ op.getFinalValue() ? op.getResults().drop_front() : op.getResults();
unsigned i = 0;
for (auto e : llvm::zip(iterOperands, iterArgs, opResults)) {
if (std::get<0>(e).getType() != std::get<2>(e).getType())
@@ -2025,9 +2030,9 @@ static mlir::LogicalResult verify(fir::DoLoopOp op) {
static void print(mlir::OpAsmPrinter &p, fir::DoLoopOp op) {
bool printBlockTerminators = false;
- p << ' ' << op.getInductionVar() << " = " << op.lowerBound() << " to "
- << op.upperBound() << " step " << op.step();
- if (op.unordered())
+ p << ' ' << op.getInductionVar() << " = " << op.getLowerBound() << " to "
+ << op.getUpperBound() << " step " << op.getStep();
+ if (op.getUnordered())
p << " unordered";
if (op.hasIterOperands()) {
p << " iter_args(";
@@ -2038,21 +2043,21 @@ static void print(mlir::OpAsmPrinter &p, fir::DoLoopOp op) {
});
p << ") -> (" << op.getResultTypes() << ')';
printBlockTerminators = true;
- } else if (op.finalValue()) {
+ } else if (op.getFinalValue()) {
p << " -> " << op.getResultTypes();
printBlockTerminators = true;
}
p.printOptionalAttrDictWithKeyword(op->getAttrs(),
{"unordered", "finalValue"});
p << ' ';
- p.printRegion(op.region(), /*printEntryBlockArgs=*/false,
+ p.printRegion(op.getRegion(), /*printEntryBlockArgs=*/false,
printBlockTerminators);
}
-mlir::Region &fir::DoLoopOp::getLoopBody() { return region(); }
+mlir::Region &fir::DoLoopOp::getLoopBody() { return getRegion(); }
bool fir::DoLoopOp::isDefinedOutsideOfLoop(mlir::Value value) {
- return !region().isAncestor(value.getParentRegion());
+ return !getRegion().isAncestor(value.getParentRegion());
}
mlir::LogicalResult
@@ -2065,9 +2070,9 @@ fir::DoLoopOp::moveOutOfLoop(llvm::ArrayRef<mlir::Operation *> ops) {
/// Translate a value passed as an iter_arg to the corresponding block
/// argument in the body of the loop.
mlir::BlockArgument fir::DoLoopOp::iterArgToBlockArg(mlir::Value iterArg) {
- for (auto i : llvm::enumerate(initArgs()))
+ for (auto i : llvm::enumerate(getInitArgs()))
if (iterArg == i.value())
- return region().front().getArgument(i.index() + 1);
+ return getRegion().front().getArgument(i.index() + 1);
return {};
}
@@ -2075,8 +2080,8 @@ mlir::BlockArgument fir::DoLoopOp::iterArgToBlockArg(mlir::Value iterArg) {
/// to the `fir.result` Op.
void fir::DoLoopOp::resultToSourceOps(
llvm::SmallVectorImpl<mlir::Value> &results, unsigned resultNum) {
- auto oper = finalValue() ? resultNum + 1 : resultNum;
- auto *term = region().front().getTerminator();
+ auto oper = getFinalValue() ? resultNum + 1 : resultNum;
+ auto *term = getRegion().front().getTerminator();
if (oper < term->getNumOperands())
results.push_back(term->getOperand(oper));
}
@@ -2084,8 +2089,8 @@ void fir::DoLoopOp::resultToSourceOps(
/// Translate the block argument (by index number) to the corresponding value
/// passed as an iter_arg to the parent DoLoopOp.
mlir::Value fir::DoLoopOp::blockArgToSourceOp(unsigned blockArgNum) {
- if (blockArgNum > 0 && blockArgNum <= initArgs().size())
- return initArgs()[blockArgNum - 1];
+ if (blockArgNum > 0 && blockArgNum <= getInitArgs().size())
+ return getInitArgs()[blockArgNum - 1];
return {};
}
@@ -2141,7 +2146,7 @@ static unsigned getBoxRank(mlir::Type boxTy) {
}
mlir::LogicalResult ReboxOp::verify() {
- auto inputBoxTy = box().getType();
+ auto inputBoxTy = getBox().getType();
if (fir::isa_unknown_size_box(inputBoxTy))
return emitOpError("box operand must not have unknown rank or type");
auto outBoxTy = getType();
@@ -2152,11 +2157,11 @@ mlir::LogicalResult ReboxOp::verify() {
auto outRank = getBoxRank(outBoxTy);
auto outEleTy = getBoxScalarEleTy(outBoxTy);
- if (auto sliceVal = slice()) {
+ if (auto sliceVal = getSlice()) {
// Slicing case
if (sliceVal.getType().cast<fir::SliceType>().getRank() != inputRank)
return emitOpError("slice operand rank must match box operand rank");
- if (auto shapeVal = shape()) {
+ if (auto shapeVal = getShape()) {
if (auto shiftTy = shapeVal.getType().dyn_cast<fir::ShiftType>()) {
if (shiftTy.getRank() != inputRank)
return emitOpError("shape operand and input box ranks must match "
@@ -2175,7 +2180,7 @@ mlir::LogicalResult ReboxOp::verify() {
} else {
// Reshaping case
unsigned shapeRank = inputRank;
- if (auto shapeVal = shape()) {
+ if (auto shapeVal = getShape()) {
auto ty = shapeVal.getType();
if (auto shapeTy = ty.dyn_cast<fir::ShapeType>()) {
shapeRank = shapeTy.getRank();
@@ -2224,14 +2229,14 @@ mlir::LogicalResult ResultOp::verify() {
//===----------------------------------------------------------------------===//
mlir::LogicalResult SaveResultOp::verify() {
- auto resultType = value().getType();
- if (resultType != fir::dyn_cast_ptrEleTy(memref().getType()))
+ auto resultType = getValue().getType();
+ if (resultType != fir::dyn_cast_ptrEleTy(getMemref().getType()))
return emitOpError("value type must match memory reference type");
if (fir::isa_unknown_size_box(resultType))
return emitOpError("cannot save !fir.box of unknown rank or type");
if (resultType.isa<fir::BoxType>()) {
- if (shape() || !typeparams().empty())
+ if (getShape() || !getTypeparams().empty())
return emitOpError(
"must not have shape or length operands if the value is a fir.box");
return mlir::success();
@@ -2239,7 +2244,7 @@ mlir::LogicalResult SaveResultOp::verify() {
// fir.record or fir.array case.
unsigned shapeTyRank = 0;
- if (auto shapeVal = shape()) {
+ if (auto shapeVal = getShape()) {
auto shapeTy = shapeVal.getType();
if (auto s = shapeTy.dyn_cast<fir::ShapeType>())
shapeTyRank = s.getRank();
@@ -2260,15 +2265,15 @@ mlir::LogicalResult SaveResultOp::verify() {
}
if (auto recTy = eleTy.dyn_cast<fir::RecordType>()) {
- if (recTy.getNumLenParams() != typeparams().size())
+ if (recTy.getNumLenParams() != getTypeparams().size())
emitOpError("length parameters number must match with the value type "
"length parameters");
} else if (auto charTy = eleTy.dyn_cast<fir::CharacterType>()) {
- if (typeparams().size() > 1)
+ if (getTypeparams().size() > 1)
emitOpError("no more than one length parameter must be provided for "
"character value");
} else {
- if (!typeparams().empty())
+ if (!getTypeparams().empty())
emitOpError("length parameters must not be provided for this value type");
}
@@ -2324,7 +2329,7 @@ fir::SelectOp::getCompareOperands(llvm::ArrayRef<mlir::Value>, unsigned) {
llvm::Optional<mlir::MutableOperandRange>
fir::SelectOp::getMutableSuccessorOperands(unsigned oper) {
- return ::getMutableSuccessorOperands(oper, targetArgsMutable(),
+ return ::getMutableSuccessorOperands(oper, getTargetArgsMutable(),
getTargetOffsetAttr());
}
@@ -2360,7 +2365,7 @@ llvm::Optional<mlir::OperandRange>
fir::SelectCaseOp::getCompareOperands(unsigned cond) {
auto a = (*this)->getAttrOfType<mlir::DenseIntElementsAttr>(
getCompareOffsetAttr());
- return {getSubOperands(cond, compareArgs(), a)};
+ return {getSubOperands(cond, getCompareArgs(), a)};
}
llvm::Optional<llvm::ArrayRef<mlir::Value>>
@@ -2385,7 +2390,7 @@ fir::SelectCaseOp::getCompareOperands(mlir::ValueRange operands,
llvm::Optional<mlir::MutableOperandRange>
fir::SelectCaseOp::getMutableSuccessorOperands(unsigned oper) {
- return ::getMutableSuccessorOperands(oper, targetArgsMutable(),
+ return ::getMutableSuccessorOperands(oper, getTargetArgsMutable(),
getTargetOffsetAttr());
}
@@ -2643,7 +2648,7 @@ fir::SelectRankOp::getCompareOperands(llvm::ArrayRef<mlir::Value>, unsigned) {
llvm::Optional<mlir::MutableOperandRange>
fir::SelectRankOp::getMutableSuccessorOperands(unsigned oper) {
- return ::getMutableSuccessorOperands(oper, targetArgsMutable(),
+ return ::getMutableSuccessorOperands(oper, getTargetArgsMutable(),
getTargetOffsetAttr());
}
@@ -2688,7 +2693,7 @@ fir::SelectTypeOp::getCompareOperands(llvm::ArrayRef<mlir::Value>, unsigned) {
llvm::Optional<mlir::MutableOperandRange>
fir::SelectTypeOp::getMutableSuccessorOperands(unsigned oper) {
- return ::getMutableSuccessorOperands(oper, targetArgsMutable(),
+ return ::getMutableSuccessorOperands(oper, getTargetArgsMutable(),
getTargetOffsetAttr());
}
@@ -2828,7 +2833,7 @@ void fir::SelectTypeOp::build(mlir::OpBuilder &builder,
//===----------------------------------------------------------------------===//
mlir::LogicalResult ShapeOp::verify() {
- auto size = extents().size();
+ auto size = getExtents().size();
auto shapeTy = getType().dyn_cast<fir::ShapeType>();
assert(shapeTy && "must be a shape type");
if (shapeTy.getRank() != size)
@@ -2841,7 +2846,7 @@ mlir::LogicalResult ShapeOp::verify() {
//===----------------------------------------------------------------------===//
mlir::LogicalResult ShapeShiftOp::verify() {
- auto size = pairs().size();
+ auto size = getPairs().size();
if (size < 2 || size > 16 * 2)
return emitOpError("incorrect number of args");
if (size % 2 != 0)
@@ -2858,7 +2863,7 @@ mlir::LogicalResult ShapeShiftOp::verify() {
//===----------------------------------------------------------------------===//
mlir::LogicalResult ShiftOp::verify() {
- auto size = origins().size();
+ auto size = getOrigins().size();
auto shiftTy = getType().dyn_cast<fir::ShiftType>();
assert(shiftTy && "must be a shift type");
if (shiftTy.getRank() != size)
@@ -2894,7 +2899,7 @@ unsigned fir::SliceOp::getOutputRank(mlir::ValueRange triples) {
}
mlir::LogicalResult SliceOp::verify() {
- auto size = triples().size();
+ auto size = getTriples().size();
if (size < 3 || size > 16 * 3)
return emitOpError("incorrect number of args for triple");
if (size % 3 != 0)
@@ -2932,17 +2937,17 @@ mlir::ParseResult StoreOp::parse(mlir::OpAsmParser &parser,
void StoreOp::print(mlir::OpAsmPrinter &p) {
p << ' ';
- p.printOperand(value());
+ p.printOperand(getValue());
p << " to ";
- p.printOperand(memref());
+ p.printOperand(getMemref());
p.printOptionalAttrDict(getOperation()->getAttrs(), {});
- p << " : " << memref().getType();
+ p << " : " << getMemref().getType();
}
mlir::LogicalResult StoreOp::verify() {
- if (value().getType() != fir::dyn_cast_ptrEleTy(memref().getType()))
+ if (getValue().getType() != fir::dyn_cast_ptrEleTy(getMemref().getType()))
return emitOpError("store value type must match memory reference type");
- if (fir::isa_unknown_size_box(value().getType()))
+ if (fir::isa_unknown_size_box(getValue().getType()))
return emitOpError("cannot store !fir.box of unknown rank or type");
return mlir::success();
}
@@ -3076,7 +3081,7 @@ mlir::LogicalResult StringLitOp::verify() {
//===----------------------------------------------------------------------===//
mlir::LogicalResult UnboxProcOp::verify() {
- if (auto eleTy = fir::dyn_cast_ptrEleTy(refTuple().getType()))
+ if (auto eleTy = fir::dyn_cast_ptrEleTy(getRefTuple().getType()))
if (eleTy.isa<mlir::TupleType>())
return mlir::success();
return emitOpError("second output argument has bad type");
@@ -3143,7 +3148,7 @@ static mlir::ParseResult parseIfOp(OpAsmParser &parser,
}
static LogicalResult verify(fir::IfOp op) {
- if (op.getNumResults() != 0 && op.elseRegion().empty())
+ if (op.getNumResults() != 0 && op.getElseRegion().empty())
return op.emitOpError("must have an else block if defining values");
return mlir::success();
@@ -3151,17 +3156,17 @@ static LogicalResult verify(fir::IfOp op) {
static void print(mlir::OpAsmPrinter &p, fir::IfOp op) {
bool printBlockTerminators = false;
- p << ' ' << op.condition();
- if (!op.results().empty()) {
+ p << ' ' << op.getCondition();
+ if (!op.getResults().empty()) {
p << " -> (" << op.getResultTypes() << ')';
printBlockTerminators = true;
}
p << ' ';
- p.printRegion(op.thenRegion(), /*printEntryBlockArgs=*/false,
+ p.printRegion(op.getThenRegion(), /*printEntryBlockArgs=*/false,
printBlockTerminators);
// Print the 'else' regions if it exists and has a block.
- auto &otherReg = op.elseRegion();
+ auto &otherReg = op.getElseRegion();
if (!otherReg.empty()) {
p << " else ";
p.printRegion(otherReg, /*printEntryBlockArgs=*/false,
@@ -3172,10 +3177,10 @@ static void print(mlir::OpAsmPrinter &p, fir::IfOp op) {
void fir::IfOp::resultToSourceOps(llvm::SmallVectorImpl<mlir::Value> &results,
unsigned resultNum) {
- auto *term = thenRegion().front().getTerminator();
+ auto *term = getThenRegion().front().getTerminator();
if (resultNum < term->getNumOperands())
results.push_back(term->getOperand(resultNum));
- term = elseRegion().front().getTerminator();
+ term = getElseRegion().front().getTerminator();
if (resultNum < term->getNumOperands())
results.push_back(term->getOperand(resultNum));
}
@@ -3252,7 +3257,7 @@ bool fir::valueHasFirAttribute(mlir::Value value,
if (value.getType().isa<fir::BoxType>())
if (auto definingOp = value.getDefiningOp())
if (auto loadOp = mlir::dyn_cast<fir::LoadOp>(definingOp))
- value = loadOp.memref();
+ value = loadOp.getMemref();
// If this is a function argument, look in the argument attributes.
if (auto blockArg = value.dyn_cast<mlir::BlockArgument>()) {
if (blockArg.getOwner() && blockArg.getOwner()->isEntryBlock())
@@ -3277,7 +3282,7 @@ bool fir::valueHasFirAttribute(mlir::Value value,
return true;
if (auto module = definingOp->getParentOfType<mlir::ModuleOp>())
if (auto globalOp =
- module.lookupSymbol<fir::GlobalOp>(addressOfOp.symbol()))
+ module.lookupSymbol<fir::GlobalOp>(addressOfOp.getSymbol()))
return globalOp->hasAttr(attributeName);
}
}
diff --git a/flang/lib/Optimizer/Transforms/AbstractResult.cpp b/flang/lib/Optimizer/Transforms/AbstractResult.cpp
index 7a7207c91645c..156ff413d29c9 100644
--- a/flang/lib/Optimizer/Transforms/AbstractResult.cpp
+++ b/flang/lib/Optimizer/Transforms/AbstractResult.cpp
@@ -95,19 +95,19 @@ class CallOpConversion : public mlir::OpRewritePattern<fir::CallOp> {
return mlir::failure();
}
auto argType = getResultArgumentType(result.getType(), options);
- auto buffer = saveResult.memref();
+ auto buffer = saveResult.getMemref();
mlir::Value arg = buffer;
if (mustEmboxResult(result.getType(), options))
arg = rewriter.create<fir::EmboxOp>(
- loc, argType, buffer, saveResult.shape(), /*slice*/ mlir::Value{},
- saveResult.typeparams());
+ loc, argType, buffer, saveResult.getShape(), /*slice*/ mlir::Value{},
+ saveResult.getTypeparams());
llvm::SmallVector<mlir::Type> newResultTypes;
- if (callOp.callee()) {
+ if (callOp.getCallee()) {
llvm::SmallVector<mlir::Value> newOperands = {arg};
newOperands.append(callOp.getOperands().begin(),
callOp.getOperands().end());
- rewriter.create<fir::CallOp>(loc, callOp.callee().getValue(),
+ rewriter.create<fir::CallOp>(loc, callOp.getCallee().getValue(),
newResultTypes, newOperands);
} else {
// Indirect calls.
@@ -163,8 +163,8 @@ class ReturnOpConversion : public mlir::OpRewritePattern<mlir::ReturnOp> {
bool replacedStorage = false;
if (auto *op = returnedValue.getDefiningOp())
if (auto load = mlir::dyn_cast<fir::LoadOp>(op)) {
- auto resultStorage = load.memref();
- load.memref().replaceAllUsesWith(options.newArg);
+ auto resultStorage = load.getMemref();
+ load.getMemref().replaceAllUsesWith(options.newArg);
replacedStorage = true;
if (auto *alloc = resultStorage.getDefiningOp())
if (alloc->use_empty())
@@ -197,7 +197,7 @@ class AddrOfOpConversion : public mlir::OpRewritePattern<fir::AddrOfOp> {
auto oldFuncTy = addrOf.getType().cast<mlir::FunctionType>();
auto newFuncTy = getNewFunctionType(oldFuncTy, options);
auto newAddrOf = rewriter.create<fir::AddrOfOp>(addrOf.getLoc(), newFuncTy,
- addrOf.symbol());
+ addrOf.getSymbol());
// Rather than converting all op a function pointer might transit through
// (e.g calls, stores, loads, converts...), cast new type to the abstract
// type. A conversion will be added when calling indirect calls of abstract
diff --git a/flang/lib/Optimizer/Transforms/AffineDemotion.cpp b/flang/lib/Optimizer/Transforms/AffineDemotion.cpp
index 411db4e5088ea..ceebc26bf25b5 100644
--- a/flang/lib/Optimizer/Transforms/AffineDemotion.cpp
+++ b/flang/lib/Optimizer/Transforms/AffineDemotion.cpp
@@ -92,23 +92,24 @@ class ConvertConversion : public mlir::OpRewritePattern<fir::ConvertOp> {
mlir::LogicalResult
matchAndRewrite(fir::ConvertOp op,
mlir::PatternRewriter &rewriter) const override {
- if (op.res().getType().isa<mlir::MemRefType>()) {
+ if (op.getRes().getType().isa<mlir::MemRefType>()) {
// due to index calculation moving to affine maps we still need to
// add converts for sequence types this has a side effect of losing
// some information about arrays with known dimensions by creating:
// fir.convert %arg0 : (!fir.ref<!fir.array<5xi32>>) ->
// !fir.ref<!fir.array<?xi32>>
- if (auto refTy = op.value().getType().dyn_cast<fir::ReferenceType>())
+ if (auto refTy = op.getValue().getType().dyn_cast<fir::ReferenceType>())
if (auto arrTy = refTy.getEleTy().dyn_cast<fir::SequenceType>()) {
fir::SequenceType::Shape flatShape = {
fir::SequenceType::getUnknownExtent()};
auto flatArrTy = fir::SequenceType::get(flatShape, arrTy.getEleTy());
auto flatTy = fir::ReferenceType::get(flatArrTy);
- rewriter.replaceOpWithNewOp<fir::ConvertOp>(op, flatTy, op.value());
+ rewriter.replaceOpWithNewOp<fir::ConvertOp>(op, flatTy,
+ op.getValue());
return success();
}
rewriter.startRootUpdate(op->getParentOp());
- op.getResult().replaceAllUsesWith(op.value());
+ op.getResult().replaceAllUsesWith(op.getValue());
rewriter.finalizeRootUpdate(op->getParentOp());
rewriter.eraseOp(op);
}
@@ -151,7 +152,7 @@ class AffineDialectDemotion
mlir::ConversionTarget target(*context);
target.addIllegalOp<memref::AllocOp>();
target.addDynamicallyLegalOp<fir::ConvertOp>([](fir::ConvertOp op) {
- if (op.res().getType().isa<mlir::MemRefType>())
+ if (op.getRes().getType().isa<mlir::MemRefType>())
return false;
return true;
});
diff --git a/flang/lib/Optimizer/Transforms/AffinePromotion.cpp b/flang/lib/Optimizer/Transforms/AffinePromotion.cpp
index 3f45aa4f8dc5f..daf84b65ef6cc 100644
--- a/flang/lib/Optimizer/Transforms/AffinePromotion.cpp
+++ b/flang/lib/Optimizer/Transforms/AffinePromotion.cpp
@@ -106,7 +106,7 @@ struct AffineLoopAnalysis {
bool analyzeReference(mlir::Value memref, mlir::Operation *op) {
if (auto acoOp = memref.getDefiningOp<ArrayCoorOp>()) {
- if (acoOp.memref().getType().isa<fir::BoxType>()) {
+ if (acoOp.getMemref().getType().isa<fir::BoxType>()) {
// TODO: Look if and how fir.box can be promoted to affine.
LLVM_DEBUG(llvm::dbgs() << "AffineLoopAnalysis: cannot promote loop, "
"array memory operation uses fir.box\n";
@@ -114,7 +114,7 @@ struct AffineLoopAnalysis {
return false;
}
bool canPromote = true;
- for (auto coordinate : acoOp.indices())
+ for (auto coordinate : acoOp.getIndices())
canPromote = canPromote && analyzeCoordinate(coordinate, op);
return canPromote;
}
@@ -134,10 +134,10 @@ struct AffineLoopAnalysis {
bool analyzeMemoryAccess(fir::DoLoopOp loopOperation) {
for (auto loadOp : loopOperation.getOps<fir::LoadOp>())
- if (!analyzeReference(loadOp.memref(), loadOp))
+ if (!analyzeReference(loadOp.getMemref(), loadOp))
return false;
for (auto storeOp : loopOperation.getOps<fir::StoreOp>())
- if (!analyzeReference(storeOp.memref(), storeOp))
+ if (!analyzeReference(storeOp.getMemref(), storeOp))
return false;
return true;
}
@@ -334,7 +334,8 @@ static Optional<int64_t> constantIntegerLike(const mlir::Value value) {
}
static mlir::Type coordinateArrayElement(fir::ArrayCoorOp op) {
- if (auto refType = op.memref().getType().dyn_cast_or_null<ReferenceType>()) {
+ if (auto refType =
+ op.getMemref().getType().dyn_cast_or_null<ReferenceType>()) {
if (auto seqType = refType.getEleTy().dyn_cast_or_null<SequenceType>()) {
return seqType.getEleTy();
}
@@ -349,7 +350,7 @@ static void populateIndexArgs(fir::ArrayCoorOp acoOp, fir::ShapeOp shape,
mlir::PatternRewriter &rewriter) {
auto one = rewriter.create<mlir::arith::ConstantOp>(
acoOp.getLoc(), rewriter.getIndexType(), rewriter.getIndexAttr(1));
- auto extents = shape.extents();
+ auto extents = shape.getExtents();
for (auto i = extents.begin(); i < extents.end(); i++) {
indexArgs.push_back(one);
indexArgs.push_back(*i);
@@ -362,7 +363,7 @@ static void populateIndexArgs(fir::ArrayCoorOp acoOp, fir::ShapeShiftOp shape,
mlir::PatternRewriter &rewriter) {
auto one = rewriter.create<mlir::arith::ConstantOp>(
acoOp.getLoc(), rewriter.getIndexType(), rewriter.getIndexAttr(1));
- auto extents = shape.pairs();
+ auto extents = shape.getPairs();
for (auto i = extents.begin(); i < extents.end();) {
indexArgs.push_back(*i++);
indexArgs.push_back(*i++);
@@ -373,7 +374,7 @@ static void populateIndexArgs(fir::ArrayCoorOp acoOp, fir::ShapeShiftOp shape,
static void populateIndexArgs(fir::ArrayCoorOp acoOp, fir::SliceOp slice,
SmallVectorImpl<mlir::Value> &indexArgs,
mlir::PatternRewriter &rewriter) {
- auto extents = slice.triples();
+ auto extents = slice.getTriples();
for (auto i = extents.begin(); i < extents.end();) {
indexArgs.push_back(*i++);
indexArgs.push_back(*i++);
@@ -384,11 +385,11 @@ static void populateIndexArgs(fir::ArrayCoorOp acoOp, fir::SliceOp slice,
static void populateIndexArgs(fir::ArrayCoorOp acoOp,
SmallVectorImpl<mlir::Value> &indexArgs,
mlir::PatternRewriter &rewriter) {
- if (auto shape = acoOp.shape().getDefiningOp<ShapeOp>())
+ if (auto shape = acoOp.getShape().getDefiningOp<ShapeOp>())
return populateIndexArgs(acoOp, shape, indexArgs, rewriter);
- if (auto shapeShift = acoOp.shape().getDefiningOp<ShapeShiftOp>())
+ if (auto shapeShift = acoOp.getShape().getDefiningOp<ShapeShiftOp>())
return populateIndexArgs(acoOp, shapeShift, indexArgs, rewriter);
- if (auto slice = acoOp.shape().getDefiningOp<SliceOp>())
+ if (auto slice = acoOp.getShape().getDefiningOp<SliceOp>())
return populateIndexArgs(acoOp, slice, indexArgs, rewriter);
return;
}
@@ -398,9 +399,9 @@ static std::pair<mlir::AffineApplyOp, fir::ConvertOp>
createAffineOps(mlir::Value arrayRef, mlir::PatternRewriter &rewriter) {
auto acoOp = arrayRef.getDefiningOp<ArrayCoorOp>();
auto affineMap =
- createArrayIndexAffineMap(acoOp.indices().size(), acoOp.getContext());
+ createArrayIndexAffineMap(acoOp.getIndices().size(), acoOp.getContext());
SmallVector<mlir::Value> indexArgs;
- indexArgs.append(acoOp.indices().begin(), acoOp.indices().end());
+ indexArgs.append(acoOp.getIndices().begin(), acoOp.getIndices().end());
populateIndexArgs(acoOp, indexArgs, rewriter);
@@ -408,14 +409,14 @@ createAffineOps(mlir::Value arrayRef, mlir::PatternRewriter &rewriter) {
affineMap, indexArgs);
auto arrayElementType = coordinateArrayElement(acoOp);
auto newType = mlir::MemRefType::get({-1}, arrayElementType);
- auto arrayConvert =
- rewriter.create<fir::ConvertOp>(acoOp.getLoc(), newType, acoOp.memref());
+ auto arrayConvert = rewriter.create<fir::ConvertOp>(acoOp.getLoc(), newType,
+ acoOp.getMemref());
return std::make_pair(affineApply, arrayConvert);
}
static void rewriteLoad(fir::LoadOp loadOp, mlir::PatternRewriter &rewriter) {
rewriter.setInsertionPoint(loadOp);
- auto affineOps = createAffineOps(loadOp.memref(), rewriter);
+ auto affineOps = createAffineOps(loadOp.getMemref(), rewriter);
rewriter.replaceOpWithNewOp<mlir::AffineLoadOp>(
loadOp, affineOps.second.getResult(), affineOps.first.getResult());
}
@@ -423,8 +424,8 @@ static void rewriteLoad(fir::LoadOp loadOp, mlir::PatternRewriter &rewriter) {
static void rewriteStore(fir::StoreOp storeOp,
mlir::PatternRewriter &rewriter) {
rewriter.setInsertionPoint(storeOp);
- auto affineOps = createAffineOps(storeOp.memref(), rewriter);
- rewriter.replaceOpWithNewOp<mlir::AffineStoreOp>(storeOp, storeOp.value(),
+ auto affineOps = createAffineOps(storeOp.getMemref(), rewriter);
+ rewriter.replaceOpWithNewOp<mlir::AffineStoreOp>(storeOp, storeOp.getValue(),
affineOps.second.getResult(),
affineOps.first.getResult());
}
@@ -481,7 +482,7 @@ class AffineLoopConversion : public mlir::OpRewritePattern<fir::DoLoopOp> {
private:
std::pair<mlir::AffineForOp, mlir::Value>
createAffineFor(fir::DoLoopOp op, mlir::PatternRewriter &rewriter) const {
- if (auto constantStep = constantIntegerLike(op.step()))
+ if (auto constantStep = constantIntegerLike(op.getStep()))
if (constantStep.getValue() > 0)
return positiveConstantStep(op, constantStep.getValue(), rewriter);
return genericBounds(op, rewriter);
@@ -492,10 +493,10 @@ class AffineLoopConversion : public mlir::OpRewritePattern<fir::DoLoopOp> {
positiveConstantStep(fir::DoLoopOp op, int64_t step,
mlir::PatternRewriter &rewriter) const {
auto affineFor = rewriter.create<mlir::AffineForOp>(
- op.getLoc(), ValueRange(op.lowerBound()),
+ op.getLoc(), ValueRange(op.getLowerBound()),
mlir::AffineMap::get(0, 1,
mlir::getAffineSymbolExpr(0, op.getContext())),
- ValueRange(op.upperBound()),
+ ValueRange(op.getUpperBound()),
mlir::AffineMap::get(0, 1,
1 + mlir::getAffineSymbolExpr(0, op.getContext())),
step);
@@ -511,7 +512,7 @@ class AffineLoopConversion : public mlir::OpRewritePattern<fir::DoLoopOp> {
0, 3, (upperBound - lowerBound + step).floorDiv(step));
auto genericUpperBound = rewriter.create<mlir::AffineApplyOp>(
op.getLoc(), upperBoundMap,
- ValueRange({op.lowerBound(), op.upperBound(), op.step()}));
+ ValueRange({op.getLowerBound(), op.getUpperBound(), op.getStep()}));
auto actualIndexMap = mlir::AffineMap::get(
1, 2,
(lowerBound + mlir::getAffineDimExpr(0, op.getContext())) *
@@ -527,7 +528,8 @@ class AffineLoopConversion : public mlir::OpRewritePattern<fir::DoLoopOp> {
rewriter.setInsertionPointToStart(affineFor.getBody());
auto actualIndex = rewriter.create<mlir::AffineApplyOp>(
op.getLoc(), actualIndexMap,
- ValueRange({affineFor.getInductionVar(), op.lowerBound(), op.step()}));
+ ValueRange(
+ {affineFor.getInductionVar(), op.getLowerBound(), op.getStep()}));
return std::make_pair(affineFor, actualIndex.getResult());
}
@@ -545,8 +547,8 @@ class AffineIfConversion : public mlir::OpRewritePattern<fir::IfOp> {
mlir::PatternRewriter &rewriter) const override {
LLVM_DEBUG(llvm::dbgs() << "AffineIfConversion: rewriting if:\n";
op.dump(););
- auto &ifOps = op.thenRegion().front().getOperations();
- auto affineCondition = AffineIfCondition(op.condition());
+ auto &ifOps = op.getThenRegion().front().getOperations();
+ auto affineCondition = AffineIfCondition(op.getCondition());
if (!affineCondition.hasIntegerSet()) {
LLVM_DEBUG(
llvm::dbgs()
@@ -555,13 +557,13 @@ class AffineIfConversion : public mlir::OpRewritePattern<fir::IfOp> {
}
auto affineIf = rewriter.create<mlir::AffineIfOp>(
op.getLoc(), affineCondition.getIntegerSet(),
- affineCondition.getAffineArgs(), !op.elseRegion().empty());
+ affineCondition.getAffineArgs(), !op.getElseRegion().empty());
rewriter.startRootUpdate(affineIf);
affineIf.getThenBlock()->getOperations().splice(
std::prev(affineIf.getThenBlock()->end()), ifOps, ifOps.begin(),
std::prev(ifOps.end()));
- if (!op.elseRegion().empty()) {
- auto &otherOps = op.elseRegion().front().getOperations();
+ if (!op.getElseRegion().empty()) {
+ auto &otherOps = op.getElseRegion().front().getOperations();
affineIf.getElseBlock()->getOperations().splice(
std::prev(affineIf.getElseBlock()->end()), otherOps, otherOps.begin(),
std::prev(otherOps.end()));
diff --git a/flang/lib/Optimizer/Transforms/ArrayValueCopy.cpp b/flang/lib/Optimizer/Transforms/ArrayValueCopy.cpp
index d433069cc7c77..81e37f6f32bbe 100644
--- a/flang/lib/Optimizer/Transforms/ArrayValueCopy.cpp
+++ b/flang/lib/Optimizer/Transforms/ArrayValueCopy.cpp
@@ -139,7 +139,7 @@ class ReachCollector {
}
if (auto mergeStore = mlir::dyn_cast<ArrayMergeStoreOp>(op)) {
if (opIsInsideLoops(mergeStore))
- collectArrayAccessFrom(mergeStore.sequence());
+ collectArrayAccessFrom(mergeStore.getSequence());
return;
}
@@ -149,7 +149,7 @@ class ReachCollector {
for (mlir::Operation *user : op->getUsers())
if (auto store = mlir::dyn_cast<fir::StoreOp>(user))
if (opIsInsideLoops(store))
- collectArrayAccessFrom(store.value());
+ collectArrayAccessFrom(store.getValue());
return;
}
@@ -285,7 +285,7 @@ ArrayCopyAnalysis::arrayAccesses(ArrayLoadOp load) {
auto structuredLoop = [&](auto ro) {
if (auto blockArg = ro.iterArgToBlockArg(operand->get())) {
int64_t arg = blockArg.getArgNumber();
- mlir::Value output = ro.getResult(ro.finalValue() ? arg : arg - 1);
+ mlir::Value output = ro.getResult(ro.getFinalValue() ? arg : arg - 1);
appendToQueue(output);
appendToQueue(blockArg);
}
@@ -353,19 +353,19 @@ ArrayCopyAnalysis::arrayAccesses(ArrayLoadOp load) {
static bool conflictOnLoad(llvm::ArrayRef<mlir::Operation *> reach,
ArrayMergeStoreOp st) {
mlir::Value load;
- mlir::Value addr = st.memref();
+ mlir::Value addr = st.getMemref();
auto stEleTy = fir::dyn_cast_ptrOrBoxEleTy(addr.getType());
for (auto *op : reach) {
auto ld = mlir::dyn_cast<ArrayLoadOp>(op);
if (!ld)
continue;
- mlir::Type ldTy = ld.memref().getType();
+ mlir::Type ldTy = ld.getMemref().getType();
if (auto boxTy = ldTy.dyn_cast<fir::BoxType>())
ldTy = boxTy.getEleTy();
if (ldTy.isa<fir::PointerType>() && stEleTy == dyn_cast_ptrEleTy(ldTy))
return true;
- if (ld.memref() == addr) {
- if (ld.getResult() != st.original())
+ if (ld.getMemref() == addr) {
+ if (ld.getResult() != st.getOriginal())
return true;
if (load)
return true;
@@ -391,22 +391,22 @@ static bool conflictOnMerge(llvm::ArrayRef<mlir::Operation *> accesses) {
llvm::SmallVector<mlir::Value> compareVector;
if (auto u = mlir::dyn_cast<ArrayUpdateOp>(op)) {
if (indices.empty()) {
- indices = u.indices();
+ indices = u.getIndices();
continue;
}
- compareVector = u.indices();
+ compareVector = u.getIndices();
} else if (auto f = mlir::dyn_cast<ArrayModifyOp>(op)) {
if (indices.empty()) {
- indices = f.indices();
+ indices = f.getIndices();
continue;
}
- compareVector = f.indices();
+ compareVector = f.getIndices();
} else if (auto f = mlir::dyn_cast<ArrayFetchOp>(op)) {
if (indices.empty()) {
- indices = f.indices();
+ indices = f.getIndices();
continue;
}
- compareVector = f.indices();
+ compareVector = f.getIndices();
}
if (compareVector != indices)
return true;
@@ -428,18 +428,18 @@ void ArrayCopyAnalysis::construct(mlir::Operation *topLevelOp) {
topLevelOp->walk([&](Operation *op) {
if (auto st = mlir::dyn_cast<fir::ArrayMergeStoreOp>(op)) {
llvm::SmallVector<Operation *> values;
- ReachCollector::reachingValues(values, st.sequence());
- const llvm::SmallVector<Operation *> &accesses =
- arrayAccesses(mlir::cast<ArrayLoadOp>(st.original().getDefiningOp()));
+ ReachCollector::reachingValues(values, st.getSequence());
+ const llvm::SmallVector<Operation *> &accesses = arrayAccesses(
+ mlir::cast<ArrayLoadOp>(st.getOriginal().getDefiningOp()));
if (conflictDetected(values, accesses, st)) {
LLVM_DEBUG(llvm::dbgs()
<< "CONFLICT: copies required for " << st << '\n'
<< " adding conflicts on: " << op << " and "
- << st.original() << '\n');
+ << st.getOriginal() << '\n');
conflicts.insert(op);
- conflicts.insert(st.original().getDefiningOp());
+ conflicts.insert(st.getOriginal().getDefiningOp());
}
- auto *ld = st.original().getDefiningOp();
+ auto *ld = st.getOriginal().getDefiningOp();
LLVM_DEBUG(llvm::dbgs()
<< "map: adding {" << *ld << " -> " << st << "}\n");
useMap.insert({ld, op});
@@ -533,22 +533,22 @@ getOrReadExtentsAndShapeOp(mlir::Location loc, mlir::PatternRewriter &rewriter,
fir::ArrayLoadOp loadOp,
llvm::SmallVectorImpl<mlir::Value> &result) {
assert(result.empty());
- if (auto boxTy = loadOp.memref().getType().dyn_cast<fir::BoxType>()) {
+ if (auto boxTy = loadOp.getMemref().getType().dyn_cast<fir::BoxType>()) {
auto rank = fir::dyn_cast_ptrOrBoxEleTy(boxTy)
.cast<fir::SequenceType>()
.getDimension();
auto idxTy = rewriter.getIndexType();
for (decltype(rank) dim = 0; dim < rank; ++dim) {
auto dimVal = rewriter.create<arith::ConstantIndexOp>(loc, dim);
- auto dimInfo = rewriter.create<fir::BoxDimsOp>(loc, idxTy, idxTy, idxTy,
- loadOp.memref(), dimVal);
+ auto dimInfo = rewriter.create<fir::BoxDimsOp>(
+ loc, idxTy, idxTy, idxTy, loadOp.getMemref(), dimVal);
result.emplace_back(dimInfo.getResult(1));
}
auto shapeType = fir::ShapeType::get(rewriter.getContext(), rank);
return rewriter.create<fir::ShapeOp>(loc, shapeType, result);
}
- getExtents(result, loadOp.shape());
- return loadOp.shape();
+ getExtents(result, loadOp.getShape());
+ return loadOp.getShape();
}
static mlir::Type toRefType(mlir::Type ty) {
@@ -657,22 +657,22 @@ class ArrayUpdateConversionBase : public mlir::OpRewritePattern<ArrayOp> {
mlir::Value shapeOp =
getOrReadExtentsAndShapeOp(loc, rewriter, load, extents);
auto allocmem = rewriter.create<AllocMemOp>(
- loc, dyn_cast_ptrOrBoxEleTy(load.memref().getType()),
- load.typeparams(), extents);
- genArrayCopy(load.getLoc(), rewriter, allocmem, load.memref(), shapeOp,
+ loc, dyn_cast_ptrOrBoxEleTy(load.getMemref().getType()),
+ load.getTypeparams(), extents);
+ genArrayCopy(load.getLoc(), rewriter, allocmem, load.getMemref(), shapeOp,
load.getType());
rewriter.setInsertionPoint(op);
mlir::Value coor = genCoorOp(
rewriter, loc, getEleTy(load.getType()), lhsEltRefType, allocmem,
- shapeOp, load.slice(), update.indices(), load.typeparams(),
+ shapeOp, load.getSlice(), update.getIndices(), load.getTypeparams(),
update->hasAttr(fir::factory::attrFortranArrayOffsets()));
assignElement(coor);
mlir::Operation *storeOp = useMap.lookup(loadOp);
auto store = mlir::cast<ArrayMergeStoreOp>(storeOp);
rewriter.setInsertionPoint(storeOp);
// Copy out.
- genArrayCopy(store.getLoc(), rewriter, store.memref(), allocmem, shapeOp,
- load.getType());
+ genArrayCopy(store.getLoc(), rewriter, store.getMemref(), allocmem,
+ shapeOp, load.getType());
rewriter.create<FreeMemOp>(loc, allocmem);
return {coor, load.getResult()};
}
@@ -682,8 +682,8 @@ class ArrayUpdateConversionBase : public mlir::OpRewritePattern<ArrayOp> {
rewriter.setInsertionPoint(op);
auto coorTy = getEleTy(load.getType());
mlir::Value coor = genCoorOp(
- rewriter, loc, coorTy, lhsEltRefType, load.memref(), load.shape(),
- load.slice(), update.indices(), load.typeparams(),
+ rewriter, loc, coorTy, lhsEltRefType, load.getMemref(), load.getShape(),
+ load.getSlice(), update.getIndices(), load.getTypeparams(),
update->hasAttr(fir::factory::attrFortranArrayOffsets()));
assignElement(coor);
return {coor, load.getResult()};
@@ -706,9 +706,9 @@ class ArrayUpdateConversion : public ArrayUpdateConversionBase<ArrayUpdateOp> {
mlir::PatternRewriter &rewriter) const override {
auto loc = update.getLoc();
auto assignElement = [&](mlir::Value coor) {
- rewriter.create<fir::StoreOp>(loc, update.merge(), coor);
+ rewriter.create<fir::StoreOp>(loc, update.getMerge(), coor);
};
- auto lhsEltRefType = toRefType(update.merge().getType());
+ auto lhsEltRefType = toRefType(update.getMerge().getType());
auto [_, lhsLoadResult] = materializeAssignment(
loc, rewriter, update, assignElement, lhsEltRefType);
update.replaceAllUsesWith(lhsLoadResult);
@@ -755,8 +755,8 @@ class ArrayFetchConversion : public mlir::OpRewritePattern<ArrayFetchOp> {
auto loc = fetch.getLoc();
mlir::Value coor =
genCoorOp(rewriter, loc, getEleTy(load.getType()),
- toRefType(fetch.getType()), load.memref(), load.shape(),
- load.slice(), fetch.indices(), load.typeparams(),
+ toRefType(fetch.getType()), load.getMemref(), load.getShape(),
+ load.getSlice(), fetch.getIndices(), load.getTypeparams(),
fetch->hasAttr(fir::factory::attrFortranArrayOffsets()));
rewriter.replaceOpWithNewOp<fir::LoadOp>(fetch, coor);
return mlir::success();
diff --git a/flang/lib/Optimizer/Transforms/CharacterConversion.cpp b/flang/lib/Optimizer/Transforms/CharacterConversion.cpp
index d166d5165dd34..f58d03c5c4fe3 100644
--- a/flang/lib/Optimizer/Transforms/CharacterConversion.cpp
+++ b/flang/lib/Optimizer/Transforms/CharacterConversion.cpp
@@ -46,7 +46,7 @@ class CharacterConvertConversion
auto zero = rewriter.create<mlir::arith::ConstantIndexOp>(loc, 0);
auto one = rewriter.create<mlir::arith::ConstantIndexOp>(loc, 1);
auto idxTy = rewriter.getIndexType();
- auto castCnt = rewriter.create<fir::ConvertOp>(loc, idxTy, conv.count());
+ auto castCnt = rewriter.create<fir::ConvertOp>(loc, idxTy, conv.getCount());
auto countm1 = rewriter.create<mlir::arith::SubIOp>(loc, castCnt, one);
auto loop = rewriter.create<fir::DoLoopOp>(loc, zero, countm1, one);
auto insPt = rewriter.saveInsertionPoint();
@@ -59,8 +59,8 @@ class CharacterConvertConversion
.cast<fir::CharacterType>();
return kindMap.getCharacterBitsize(chrTy.getFKind());
};
- auto fromBits = getCharBits(conv.from().getType());
- auto toBits = getCharBits(conv.to().getType());
+ auto fromBits = getCharBits(conv.getFrom().getType());
+ auto toBits = getCharBits(conv.getTo().getType());
auto pointerType = [&](unsigned bits) {
return fir::ReferenceType::get(fir::SequenceType::get(
fir::SequenceType::ShapeRef{fir::SequenceType::getUnknownExtent()},
@@ -69,8 +69,9 @@ class CharacterConvertConversion
auto fromPtrTy = pointerType(fromBits);
auto toTy = rewriter.getIntegerType(toBits);
auto toPtrTy = pointerType(toBits);
- auto fromPtr = rewriter.create<fir::ConvertOp>(loc, fromPtrTy, conv.from());
- auto toPtr = rewriter.create<fir::ConvertOp>(loc, toPtrTy, conv.to());
+ auto fromPtr =
+ rewriter.create<fir::ConvertOp>(loc, fromPtrTy, conv.getFrom());
+ auto toPtr = rewriter.create<fir::ConvertOp>(loc, toPtrTy, conv.getTo());
auto getEleTy = [&](unsigned bits) {
return fir::ReferenceType::get(rewriter.getIntegerType(bits));
};
diff --git a/flang/lib/Optimizer/Transforms/ExternalNameConversion.cpp b/flang/lib/Optimizer/Transforms/ExternalNameConversion.cpp
index 28852a50f5d90..4c2ff9ab09166 100644
--- a/flang/lib/Optimizer/Transforms/ExternalNameConversion.cpp
+++ b/flang/lib/Optimizer/Transforms/ExternalNameConversion.cpp
@@ -46,12 +46,12 @@ class MangleNameOnCallOp : public mlir::OpRewritePattern<fir::CallOp> {
matchAndRewrite(fir::CallOp op,
mlir::PatternRewriter &rewriter) const override {
rewriter.startRootUpdate(op);
- auto callee = op.callee();
+ auto callee = op.getCallee();
if (callee.hasValue()) {
auto result = fir::NameUniquer::deconstruct(
callee.getValue().getRootReference().getValue());
if (fir::NameUniquer::isExternalFacingUniquedName(result))
- op.calleeAttr(
+ op.setCalleeAttr(
SymbolRefAttr::get(op.getContext(), mangleExternalName(result)));
}
rewriter.finalizeRootUpdate(op);
@@ -87,10 +87,10 @@ struct MangleNameForCommonBlock : public mlir::OpRewritePattern<fir::GlobalOp> {
mlir::PatternRewriter &rewriter) const override {
rewriter.startRootUpdate(op);
auto result = fir::NameUniquer::deconstruct(
- op.symref().getRootReference().getValue());
+ op.getSymref().getRootReference().getValue());
if (fir::NameUniquer::isExternalFacingUniquedName(result)) {
auto newName = mangleExternalName(result);
- op.symrefAttr(mlir::SymbolRefAttr::get(op.getContext(), newName));
+ op.setSymrefAttr(mlir::SymbolRefAttr::get(op.getContext(), newName));
SymbolTable::setSymbolName(op, newName);
}
rewriter.finalizeRootUpdate(op);
@@ -106,11 +106,11 @@ struct MangleNameOnAddrOfOp : public mlir::OpRewritePattern<fir::AddrOfOp> {
matchAndRewrite(fir::AddrOfOp op,
mlir::PatternRewriter &rewriter) const override {
auto result = fir::NameUniquer::deconstruct(
- op.symbol().getRootReference().getValue());
+ op.getSymbol().getRootReference().getValue());
if (fir::NameUniquer::isExternalFacingUniquedName(result)) {
auto newName =
SymbolRefAttr::get(op.getContext(), mangleExternalName(result));
- rewriter.replaceOpWithNewOp<fir::AddrOfOp>(op, op.resTy().getType(),
+ rewriter.replaceOpWithNewOp<fir::AddrOfOp>(op, op.getResTy().getType(),
newName);
}
return success();
@@ -127,9 +127,9 @@ struct MangleNameOnEmboxProcOp
mlir::PatternRewriter &rewriter) const override {
rewriter.startRootUpdate(op);
auto result = fir::NameUniquer::deconstruct(
- op.funcname().getRootReference().getValue());
+ op.getFuncname().getRootReference().getValue());
if (fir::NameUniquer::isExternalFacingUniquedName(result))
- op.funcnameAttr(
+ op.setFuncnameAttr(
SymbolRefAttr::get(op.getContext(), mangleExternalName(result)));
rewriter.finalizeRootUpdate(op);
return success();
@@ -158,9 +158,9 @@ void ExternalNameConversionPass::runOnOperation() {
acc::OpenACCDialect, omp::OpenMPDialect>();
target.addDynamicallyLegalOp<fir::CallOp>([](fir::CallOp op) {
- if (op.callee().hasValue())
+ if (op.getCallee().hasValue())
return !fir::NameUniquer::needExternalNameMangling(
- op.callee().getValue().getRootReference().getValue());
+ op.getCallee().getValue().getRootReference().getValue());
return true;
});
@@ -170,17 +170,17 @@ void ExternalNameConversionPass::runOnOperation() {
target.addDynamicallyLegalOp<fir::GlobalOp>([](fir::GlobalOp op) {
return !fir::NameUniquer::needExternalNameMangling(
- op.symref().getRootReference().getValue());
+ op.getSymref().getRootReference().getValue());
});
target.addDynamicallyLegalOp<fir::AddrOfOp>([](fir::AddrOfOp op) {
return !fir::NameUniquer::needExternalNameMangling(
- op.symbol().getRootReference().getValue());
+ op.getSymbol().getRootReference().getValue());
});
target.addDynamicallyLegalOp<fir::EmboxProcOp>([](fir::EmboxProcOp op) {
return !fir::NameUniquer::needExternalNameMangling(
- op.funcname().getRootReference().getValue());
+ op.getFuncname().getRootReference().getValue());
});
if (failed(applyPartialConversion(op, target, std::move(patterns))))
diff --git a/flang/lib/Optimizer/Transforms/MemRefDataFlowOpt.cpp b/flang/lib/Optimizer/Transforms/MemRefDataFlowOpt.cpp
index 37ff895e85909..f3f86cb3047e6 100644
--- a/flang/lib/Optimizer/Transforms/MemRefDataFlowOpt.cpp
+++ b/flang/lib/Optimizer/Transforms/MemRefDataFlowOpt.cpp
@@ -101,20 +101,20 @@ class MemDataFlowOpt : public fir::MemRefDataFlowOptBase<MemDataFlowOpt> {
LoadStoreForwarding<fir::LoadOp, fir::StoreOp> lsf(domInfo);
f.walk([&](fir::LoadOp loadOp) {
auto maybeStore = lsf.findStoreToForward(
- loadOp, getSpecificUsers<fir::StoreOp>(loadOp.memref()));
+ loadOp, getSpecificUsers<fir::StoreOp>(loadOp.getMemref()));
if (maybeStore) {
auto storeOp = maybeStore.getValue();
LLVM_DEBUG(llvm::dbgs() << "FlangMemDataFlowOpt: In " << f.getName()
<< " erasing load " << loadOp
<< " with value from " << storeOp << '\n');
- loadOp.getResult().replaceAllUsesWith(storeOp.value());
+ loadOp.getResult().replaceAllUsesWith(storeOp.getValue());
loadOp.erase();
}
});
f.walk([&](fir::AllocaOp alloca) {
for (auto &storeOp : getSpecificUsers<fir::StoreOp>(alloca.getResult())) {
if (!lsf.findReadForWrite(
- storeOp, getSpecificUsers<fir::LoadOp>(storeOp.memref()))) {
+ storeOp, getSpecificUsers<fir::LoadOp>(storeOp.getMemref()))) {
LLVM_DEBUG(llvm::dbgs() << "FlangMemDataFlowOpt: In " << f.getName()
<< " erasing store " << storeOp << '\n');
storeOp.erase();
diff --git a/flang/lib/Optimizer/Transforms/MemoryAllocation.cpp b/flang/lib/Optimizer/Transforms/MemoryAllocation.cpp
index faaea1931a9ce..76ca3fd5e1fc4 100644
--- a/flang/lib/Optimizer/Transforms/MemoryAllocation.cpp
+++ b/flang/lib/Optimizer/Transforms/MemoryAllocation.cpp
@@ -115,10 +115,11 @@ class AllocaOpConversion : public mlir::OpRewritePattern<fir::AllocaOp> {
return *opt;
return {};
};
- auto uniqName = unpackName(alloca.uniq_name());
- auto bindcName = unpackName(alloca.bindc_name());
+ auto uniqName = unpackName(alloca.getUniqName());
+ auto bindcName = unpackName(alloca.getBindcName());
auto heap = rewriter.create<fir::AllocMemOp>(
- loc, varTy, uniqName, bindcName, alloca.typeparams(), alloca.shape());
+ loc, varTy, uniqName, bindcName, alloca.getTypeparams(),
+ alloca.getShape());
auto insPt = rewriter.saveInsertionPoint();
for (mlir::Operation *retOp : returnOps) {
rewriter.setInsertionPoint(retOp);
diff --git a/flang/lib/Optimizer/Transforms/RewriteLoop.cpp b/flang/lib/Optimizer/Transforms/RewriteLoop.cpp
index e8eefb5c3f4f6..4e20a4b862bf4 100644
--- a/flang/lib/Optimizer/Transforms/RewriteLoop.cpp
+++ b/flang/lib/Optimizer/Transforms/RewriteLoop.cpp
@@ -49,20 +49,20 @@ class CfgLoopConv : public mlir::OpRewritePattern<fir::DoLoopOp> {
// Split the first DoLoopOp block in two parts. The part before will be the
// conditional block since it already has the induction variable and
// loop-carried values as arguments.
- auto *conditionalBlock = &loop.region().front();
+ auto *conditionalBlock = &loop.getRegion().front();
conditionalBlock->addArgument(rewriter.getIndexType(), loc);
auto *firstBlock =
rewriter.splitBlock(conditionalBlock, conditionalBlock->begin());
- auto *lastBlock = &loop.region().back();
+ auto *lastBlock = &loop.getRegion().back();
// Move the blocks from the DoLoopOp between initBlock and endBlock
- rewriter.inlineRegionBefore(loop.region(), endBlock);
+ rewriter.inlineRegionBefore(loop.getRegion(), endBlock);
// Get loop values from the DoLoopOp
- auto low = loop.lowerBound();
- auto high = loop.upperBound();
+ auto low = loop.getLowerBound();
+ auto high = loop.getUpperBound();
assert(low && high && "must be a Value");
- auto step = loop.step();
+ auto step = loop.getStep();
// Initalization block
rewriter.setInsertionPointToEnd(initBlock);
@@ -102,8 +102,8 @@ class CfgLoopConv : public mlir::OpRewritePattern<fir::DoLoopOp> {
llvm::SmallVector<mlir::Value> loopCarried;
loopCarried.push_back(steppedIndex);
- auto begin = loop.finalValue() ? std::next(terminator->operand_begin())
- : terminator->operand_begin();
+ auto begin = loop.getFinalValue() ? std::next(terminator->operand_begin())
+ : terminator->operand_begin();
loopCarried.append(begin, terminator->operand_end());
loopCarried.push_back(itersMinusOne);
rewriter.create<mlir::cf::BranchOp>(loc, conditionalBlock, loopCarried);
@@ -121,7 +121,7 @@ class CfgLoopConv : public mlir::OpRewritePattern<fir::DoLoopOp> {
// The result of the loop operation is the values of the condition block
// arguments except the induction variable on the last iteration.
- auto args = loop.finalValue()
+ auto args = loop.getFinalValue()
? conditionalBlock->getArguments()
: conditionalBlock->getArguments().drop_front();
rewriter.replaceOp(loop, args.drop_back());
@@ -161,7 +161,7 @@ class CfgIfConv : public mlir::OpRewritePattern<fir::IfOp> {
// Move blocks from the "then" region to the region containing 'fir.if',
// place it before the continuation block, and branch to it.
- auto &ifOpRegion = ifOp.thenRegion();
+ auto &ifOpRegion = ifOp.getThenRegion();
auto *ifOpBlock = &ifOpRegion.front();
auto *ifOpTerminator = ifOpRegion.back().getTerminator();
auto ifOpTerminatorOperands = ifOpTerminator->getOperands();
@@ -175,7 +175,7 @@ class CfgIfConv : public mlir::OpRewritePattern<fir::IfOp> {
// 'fir.if', place it before the continuation block and branch to it. It
// will be placed after the "then" regions.
auto *otherwiseBlock = continueBlock;
- auto &otherwiseRegion = ifOp.elseRegion();
+ auto &otherwiseRegion = ifOp.getElseRegion();
if (!otherwiseRegion.empty()) {
otherwiseBlock = &otherwiseRegion.front();
auto *otherwiseTerm = otherwiseRegion.back().getTerminator();
@@ -189,7 +189,7 @@ class CfgIfConv : public mlir::OpRewritePattern<fir::IfOp> {
rewriter.setInsertionPointToEnd(condBlock);
rewriter.create<mlir::cf::CondBranchOp>(
- loc, ifOp.condition(), ifOpBlock, llvm::ArrayRef<mlir::Value>(),
+ loc, ifOp.getCondition(), ifOpBlock, llvm::ArrayRef<mlir::Value>(),
otherwiseBlock, llvm::ArrayRef<mlir::Value>());
rewriter.replaceOp(ifOp, continueBlock->getArguments());
return success();
@@ -221,11 +221,11 @@ class CfgIterWhileConv : public mlir::OpRewritePattern<fir::IterWhileOp> {
// arguments. Split out all operations from the first block into a new
// block. Move all body blocks from the loop body region to the region
// containing the loop.
- auto *conditionBlock = &whileOp.region().front();
+ auto *conditionBlock = &whileOp.getRegion().front();
auto *firstBodyBlock =
rewriter.splitBlock(conditionBlock, conditionBlock->begin());
- auto *lastBodyBlock = &whileOp.region().back();
- rewriter.inlineRegionBefore(whileOp.region(), endBlock);
+ auto *lastBodyBlock = &whileOp.getRegion().back();
+ rewriter.inlineRegionBefore(whileOp.getRegion(), endBlock);
auto iv = conditionBlock->getArgument(0);
auto iterateVar = conditionBlock->getArgument(1);
@@ -234,22 +234,23 @@ class CfgIterWhileConv : public mlir::OpRewritePattern<fir::IterWhileOp> {
// operands of the loop terminator.
auto *terminator = lastBodyBlock->getTerminator();
rewriter.setInsertionPointToEnd(lastBodyBlock);
- auto step = whileOp.step();
+ auto step = whileOp.getStep();
mlir::Value stepped = rewriter.create<mlir::arith::AddIOp>(loc, iv, step);
assert(stepped && "must be a Value");
llvm::SmallVector<mlir::Value> loopCarried;
loopCarried.push_back(stepped);
- auto begin = whileOp.finalValue() ? std::next(terminator->operand_begin())
- : terminator->operand_begin();
+ auto begin = whileOp.getFinalValue()
+ ? std::next(terminator->operand_begin())
+ : terminator->operand_begin();
loopCarried.append(begin, terminator->operand_end());
rewriter.create<mlir::cf::BranchOp>(loc, conditionBlock, loopCarried);
rewriter.eraseOp(terminator);
// Compute loop bounds before branching to the condition.
rewriter.setInsertionPointToEnd(initBlock);
- auto lowerBound = whileOp.lowerBound();
- auto upperBound = whileOp.upperBound();
+ auto lowerBound = whileOp.getLowerBound();
+ auto upperBound = whileOp.getUpperBound();
assert(lowerBound && upperBound && "must be a Value");
// The initial values of loop-carried values is obtained from the operands
@@ -285,7 +286,7 @@ class CfgIterWhileConv : public mlir::OpRewritePattern<fir::IterWhileOp> {
endBlock, llvm::ArrayRef<mlir::Value>());
// The result of the loop operation is the values of the condition block
// arguments except the induction variable on the last iteration.
- auto args = whileOp.finalValue()
+ auto args = whileOp.getFinalValue()
? conditionBlock->getArguments()
: conditionBlock->getArguments().drop_front();
rewriter.replaceOp(whileOp, args);
diff --git a/flang/unittests/Optimizer/Builder/DoLoopHelperTest.cpp b/flang/unittests/Optimizer/Builder/DoLoopHelperTest.cpp
index 0808c4eb5d3bd..54bcf7f5f42f4 100644
--- a/flang/unittests/Optimizer/Builder/DoLoopHelperTest.cpp
+++ b/flang/unittests/Optimizer/Builder/DoLoopHelperTest.cpp
@@ -44,9 +44,9 @@ TEST_F(DoLoopHelperTest, createLoopWithCountTest) {
firBuilder.getUnknownLoc(), firBuilder.getIndexType(), 10);
auto loop =
helper.createLoop(c10, [&](fir::FirOpBuilder &, mlir::Value index) {});
- checkConstantValue(loop.lowerBound(), 0);
- EXPECT_TRUE(mlir::isa<arith::SubIOp>(loop.upperBound().getDefiningOp()));
- auto subOp = dyn_cast<arith::SubIOp>(loop.upperBound().getDefiningOp());
+ checkConstantValue(loop.getLowerBound(), 0);
+ EXPECT_TRUE(mlir::isa<arith::SubIOp>(loop.getUpperBound().getDefiningOp()));
+ auto subOp = dyn_cast<arith::SubIOp>(loop.getUpperBound().getDefiningOp());
EXPECT_EQ(c10, subOp.getLhs());
checkConstantValue(subOp.getRhs(), 1);
checkConstantValue(loop.getStep(), 1);
diff --git a/flang/unittests/Optimizer/Builder/FIRBuilderTest.cpp b/flang/unittests/Optimizer/Builder/FIRBuilderTest.cpp
index bb16db9720cf9..d19f6d0cec298 100644
--- a/flang/unittests/Optimizer/Builder/FIRBuilderTest.cpp
+++ b/flang/unittests/Optimizer/Builder/FIRBuilderTest.cpp
@@ -185,13 +185,13 @@ TEST_F(FIRBuilderTest, createGlobal1) {
auto global = builder.createGlobal(
loc, i64Type, "global1", builder.createInternalLinkage(), {}, true);
EXPECT_TRUE(mlir::isa<fir::GlobalOp>(global));
- EXPECT_EQ("global1", global.sym_name());
- EXPECT_TRUE(global.constant().hasValue());
+ EXPECT_EQ("global1", global.getSymName());
+ EXPECT_TRUE(global.getConstant().hasValue());
EXPECT_EQ(i64Type, global.type());
- EXPECT_TRUE(global.linkName().hasValue());
- EXPECT_EQ(
- builder.createInternalLinkage().getValue(), global.linkName().getValue());
- EXPECT_FALSE(global.initVal().hasValue());
+ EXPECT_TRUE(global.getLinkName().hasValue());
+ EXPECT_EQ(builder.createInternalLinkage().getValue(),
+ global.getLinkName().getValue());
+ EXPECT_FALSE(global.getInitVal().hasValue());
auto g1 = builder.getNamedGlobal("global1");
EXPECT_EQ(global, g1);
@@ -209,16 +209,16 @@ TEST_F(FIRBuilderTest, createGlobal2) {
auto global = builder.createGlobal(
loc, i32Type, "global2", builder.createLinkOnceLinkage(), attr, false);
EXPECT_TRUE(mlir::isa<fir::GlobalOp>(global));
- EXPECT_EQ("global2", global.sym_name());
- EXPECT_FALSE(global.constant().hasValue());
+ EXPECT_EQ("global2", global.getSymName());
+ EXPECT_FALSE(global.getConstant().hasValue());
EXPECT_EQ(i32Type, global.type());
- EXPECT_TRUE(global.initVal().hasValue());
- EXPECT_TRUE(global.initVal().getValue().isa<mlir::IntegerAttr>());
- EXPECT_EQ(
- 16, global.initVal().getValue().cast<mlir::IntegerAttr>().getValue());
- EXPECT_TRUE(global.linkName().hasValue());
+ EXPECT_TRUE(global.getInitVal().hasValue());
+ EXPECT_TRUE(global.getInitVal().getValue().isa<mlir::IntegerAttr>());
EXPECT_EQ(
- builder.createLinkOnceLinkage().getValue(), global.linkName().getValue());
+ 16, global.getInitVal().getValue().cast<mlir::IntegerAttr>().getValue());
+ EXPECT_TRUE(global.getLinkName().hasValue());
+ EXPECT_EQ(builder.createLinkOnceLinkage().getValue(),
+ global.getLinkName().getValue());
}
TEST_F(FIRBuilderTest, uniqueCFIdent) {
@@ -263,7 +263,7 @@ TEST_F(FIRBuilderTest, locationToFilename) {
mlir::FileLineColLoc::get(builder.getStringAttr("file1.f90"), 10, 5);
mlir::Value locToFile = fir::factory::locationToFilename(builder, loc);
auto addrOp = dyn_cast<fir::AddrOfOp>(locToFile.getDefiningOp());
- auto symbol = addrOp.symbol().getRootReference().getValue();
+ auto symbol = addrOp.getSymbol().getRootReference().getValue();
auto global = builder.getNamedGlobal(symbol);
auto stringLitOps = global.getRegion().front().getOps<fir::StringLitOp>();
EXPECT_TRUE(llvm::hasSingleElement(stringLitOps));
@@ -305,10 +305,10 @@ TEST_F(FIRBuilderTest, createStringLiteral) {
auto addr = charBox->getBuffer();
EXPECT_TRUE(mlir::isa<fir::AddrOfOp>(addr.getDefiningOp()));
auto addrOp = dyn_cast<fir::AddrOfOp>(addr.getDefiningOp());
- auto symbol = addrOp.symbol().getRootReference().getValue();
+ auto symbol = addrOp.getSymbol().getRootReference().getValue();
auto global = builder.getNamedGlobal(symbol);
- EXPECT_EQ(
- builder.createLinkOnceLinkage().getValue(), global.linkName().getValue());
+ EXPECT_EQ(builder.createLinkOnceLinkage().getValue(),
+ global.getLinkName().getValue());
EXPECT_EQ(fir::CharacterType::get(builder.getContext(), 1, strValue.size()),
global.type());
@@ -329,13 +329,13 @@ TEST_F(FIRBuilderTest, allocateLocal) {
loc, builder.getI64Type(), "", varName, {}, {}, false);
EXPECT_TRUE(mlir::isa<fir::AllocaOp>(var.getDefiningOp()));
auto allocaOp = dyn_cast<fir::AllocaOp>(var.getDefiningOp());
- EXPECT_EQ(builder.getI64Type(), allocaOp.in_type());
- EXPECT_TRUE(allocaOp.bindc_name().hasValue());
- EXPECT_EQ(varName, allocaOp.bindc_name().getValue());
- EXPECT_FALSE(allocaOp.uniq_name().hasValue());
- EXPECT_FALSE(allocaOp.pinned());
- EXPECT_EQ(0u, allocaOp.typeparams().size());
- EXPECT_EQ(0u, allocaOp.shape().size());
+ EXPECT_EQ(builder.getI64Type(), allocaOp.getInType());
+ EXPECT_TRUE(allocaOp.getBindcName().hasValue());
+ EXPECT_EQ(varName, allocaOp.getBindcName().getValue());
+ EXPECT_FALSE(allocaOp.getUniqName().hasValue());
+ EXPECT_FALSE(allocaOp.getPinned());
+ EXPECT_EQ(0u, allocaOp.getTypeparams().size());
+ EXPECT_EQ(0u, allocaOp.getShape().size());
}
static void checkShapeOp(mlir::Value shape, mlir::Value c10, mlir::Value c100) {
diff --git a/flang/unittests/Optimizer/Builder/Runtime/RuntimeCallTestBase.h b/flang/unittests/Optimizer/Builder/Runtime/RuntimeCallTestBase.h
index 264ae2018ae77..6ce204d35e0c6 100644
--- a/flang/unittests/Optimizer/Builder/Runtime/RuntimeCallTestBase.h
+++ b/flang/unittests/Optimizer/Builder/Runtime/RuntimeCallTestBase.h
@@ -85,13 +85,13 @@ static inline void checkCallOp(mlir::Operation *op, llvm::StringRef fctName,
unsigned nbArgs, bool addLocArgs = true) {
EXPECT_TRUE(mlir::isa<fir::CallOp>(*op));
auto callOp = mlir::dyn_cast<fir::CallOp>(*op);
- EXPECT_TRUE(callOp.callee().hasValue());
- mlir::SymbolRefAttr callee = *callOp.callee();
+ EXPECT_TRUE(callOp.getCallee().hasValue());
+ mlir::SymbolRefAttr callee = *callOp.getCallee();
EXPECT_EQ(fctName, callee.getRootReference().getValue());
// sourceFile and sourceLine are added arguments.
if (addLocArgs)
nbArgs += 2;
- EXPECT_EQ(nbArgs, callOp.args().size());
+ EXPECT_EQ(nbArgs, callOp.getArgs().size());
}
/// Check the call operation from the \p result value. In some cases the
@@ -133,8 +133,8 @@ static inline void checkBlockForCallOp(
assert(block && "mlir::Block given is a nullptr");
for (auto &op : block->getOperations()) {
if (auto callOp = mlir::dyn_cast<fir::CallOp>(op)) {
- if (fctName == callOp.callee()->getRootReference().getValue()) {
- EXPECT_EQ(nbArgs, callOp.args().size());
+ if (fctName == callOp.getCallee()->getRootReference().getValue()) {
+ EXPECT_EQ(nbArgs, callOp.getArgs().size());
return;
}
}
More information about the flang-commits
mailing list