[flang-commits] [flang] a3a007a - [mlir][NFC] update `flang/Lower` create APIs (8/n) (#149912)
via flang-commits
flang-commits at lists.llvm.org
Mon Jul 21 16:54:33 PDT 2025
Author: Maksim Levental
Date: 2025-07-21T19:54:29-04:00
New Revision: a3a007ad5fa20abc90ead4e1030b481bf109b4cf
URL: https://github.com/llvm/llvm-project/commit/a3a007ad5fa20abc90ead4e1030b481bf109b4cf
DIFF: https://github.com/llvm/llvm-project/commit/a3a007ad5fa20abc90ead4e1030b481bf109b4cf.diff
LOG: [mlir][NFC] update `flang/Lower` create APIs (8/n) (#149912)
See https://github.com/llvm/llvm-project/pull/147168 for more info.
Added:
Modified:
flang/lib/Lower/Allocatable.cpp
flang/lib/Lower/Bridge.cpp
flang/lib/Lower/ConvertArrayConstructor.cpp
flang/lib/Lower/ConvertCall.cpp
flang/lib/Lower/ConvertConstant.cpp
flang/lib/Lower/ConvertExpr.cpp
flang/lib/Lower/ConvertExprToHLFIR.cpp
flang/lib/Lower/ConvertProcedureDesignator.cpp
flang/lib/Lower/ConvertVariable.cpp
flang/lib/Lower/CustomIntrinsicCall.cpp
flang/lib/Lower/HlfirIntrinsics.cpp
flang/lib/Lower/HostAssociations.cpp
flang/lib/Lower/IO.cpp
flang/lib/Lower/OpenACC.cpp
flang/lib/Lower/OpenMP/Atomic.cpp
flang/lib/Lower/OpenMP/ClauseProcessor.cpp
flang/lib/Lower/OpenMP/DataSharingProcessor.cpp
flang/lib/Lower/OpenMP/OpenMP.cpp
flang/lib/Lower/OpenMP/Utils.cpp
flang/lib/Lower/Runtime.cpp
flang/lib/Lower/Support/PrivateReductionUtils.cpp
flang/lib/Lower/Support/ReductionProcessor.cpp
flang/lib/Lower/Support/Utils.cpp
flang/lib/Lower/VectorSubscripts.cpp
Removed:
################################################################################
diff --git a/flang/lib/Lower/Allocatable.cpp b/flang/lib/Lower/Allocatable.cpp
index 5536bfe8d63ca..15cd9770b35ba 100644
--- a/flang/lib/Lower/Allocatable.cpp
+++ b/flang/lib/Lower/Allocatable.cpp
@@ -78,8 +78,8 @@ struct ErrorManager {
statExpr && errMsgExpr
? builder.createBox(loc,
converter.genExprAddr(loc, errMsgExpr, stmtCtx))
- : builder.create<fir::AbsentOp>(
- loc,
+ : fir::AbsentOp::create(
+ builder, loc,
fir::BoxType::get(mlir::NoneType::get(builder.getContext())));
sourceFile = fir::factory::locationToFilename(builder, loc);
sourceLine = fir::factory::locationToLineNo(builder, loc,
@@ -92,10 +92,10 @@ struct ErrorManager {
if (statValue) {
mlir::Value zero =
builder.createIntegerConstant(loc, statValue.getType(), 0);
- auto cmp = builder.create<mlir::arith::CmpIOp>(
- loc, mlir::arith::CmpIPredicate::eq, statValue, zero);
- auto ifOp = builder.create<fir::IfOp>(loc, cmp,
- /*withElseRegion=*/false);
+ auto cmp = mlir::arith::CmpIOp::create(
+ builder, loc, mlir::arith::CmpIPredicate::eq, statValue, zero);
+ auto ifOp = fir::IfOp::create(builder, loc, cmp,
+ /*withElseRegion=*/false);
builder.setInsertionPointToStart(&ifOp.getThenRegion().front());
}
}
@@ -106,7 +106,7 @@ struct ErrorManager {
assert(stat && "missing stat value");
mlir::Value castStat = builder.createConvert(
loc, fir::dyn_cast_ptrEleTy(statAddr.getType()), stat);
- builder.create<fir::StoreOp>(loc, castStat, statAddr);
+ fir::StoreOp::create(builder, loc, castStat, statAddr);
statValue = stat;
}
}
@@ -141,7 +141,7 @@ static void genRuntimeSetBounds(fir::FirOpBuilder &builder, mlir::Location loc,
const auto args = fir::runtime::createArguments(
builder, loc, callee.getFunctionType(), box.getAddr(), dimIndex,
lowerBound, upperBound);
- builder.create<fir::CallOp>(loc, callee, args);
+ fir::CallOp::create(builder, loc, callee, args);
}
/// Generate runtime call to set the lengths of a character allocatable or
@@ -171,7 +171,7 @@ static void genRuntimeInitCharacter(fir::FirOpBuilder &builder,
args.push_back(builder.createIntegerConstant(loc, inputTypes[4], corank));
const auto convertedArgs = fir::runtime::createArguments(
builder, loc, callee.getFunctionType(), args);
- builder.create<fir::CallOp>(loc, callee, convertedArgs);
+ fir::CallOp::create(builder, loc, callee, convertedArgs);
}
/// Generate a sequence of runtime calls to allocate memory.
@@ -194,7 +194,7 @@ static mlir::Value genRuntimeAllocate(fir::FirOpBuilder &builder,
args.push_back(errorManager.sourceLine);
const auto convertedArgs = fir::runtime::createArguments(
builder, loc, callee.getFunctionType(), args);
- return builder.create<fir::CallOp>(loc, callee, convertedArgs).getResult(0);
+ return fir::CallOp::create(builder, loc, callee, convertedArgs).getResult(0);
}
/// Generate a sequence of runtime calls to allocate memory and assign with the
@@ -214,7 +214,7 @@ static mlir::Value genRuntimeAllocateSource(fir::FirOpBuilder &builder,
builder, loc, callee.getFunctionType(), box.getAddr(),
fir::getBase(source), errorManager.hasStat, errorManager.errMsgAddr,
errorManager.sourceFile, errorManager.sourceLine);
- return builder.create<fir::CallOp>(loc, callee, args).getResult(0);
+ return fir::CallOp::create(builder, loc, callee, args).getResult(0);
}
/// Generate runtime call to apply mold to the descriptor.
@@ -233,7 +233,7 @@ static void genRuntimeAllocateApplyMold(fir::FirOpBuilder &builder,
fir::factory::getMutableIRBox(builder, loc, box), fir::getBase(mold),
builder.createIntegerConstant(
loc, callee.getFunctionType().getInputs()[2], rank));
- builder.create<fir::CallOp>(loc, callee, args);
+ fir::CallOp::create(builder, loc, callee, args);
}
/// Generate a runtime call to deallocate memory.
@@ -270,7 +270,7 @@ static mlir::Value genRuntimeDeallocate(fir::FirOpBuilder &builder,
errorManager.hasStat, errorManager.errMsgAddr, errorManager.sourceFile,
errorManager.sourceLine);
}
- return builder.create<fir::CallOp>(loc, callee, operands).getResult(0);
+ return fir::CallOp::create(builder, loc, callee, operands).getResult(0);
}
//===----------------------------------------------------------------------===//
@@ -433,9 +433,9 @@ class AllocateStmtHelper {
loc, Fortran::semantics::GetExpr(std::get<1>(shapeSpec.t)), stmtCtx));
ub = builder.createConvert(loc, idxTy, ub);
if (lb) {
- mlir::Value
diff = builder.create<mlir::arith::SubIOp>(loc, ub, lb);
+ mlir::Value
diff = mlir::arith::SubIOp::create(builder, loc, ub, lb);
extents.emplace_back(
- builder.create<mlir::arith::AddIOp>(loc,
diff , one));
+ mlir::arith::AddIOp::create(builder, loc,
diff , one));
} else {
extents.emplace_back(ub);
}
@@ -461,7 +461,7 @@ class AllocateStmtHelper {
mlir::Value falseValue = builder.createBool(loc, false);
mlir::Value falseConv = builder.createConvert(
loc, fir::unwrapRefType(pinned.getType()), falseValue);
- builder.create<fir::StoreOp>(loc, falseConv, pinned);
+ fir::StoreOp::create(builder, loc, falseConv, pinned);
}
void genSimpleAllocation(const Allocation &alloc,
@@ -557,7 +557,7 @@ class AllocateStmtHelper {
mlir::Value nullPointer = fir::factory::createUnallocatedBox(
builder, loc, box.getBoxTy(), box.nonDeferredLenParams(),
/*typeSourceBox=*/{}, allocatorIdx);
- builder.create<fir::StoreOp>(loc, nullPointer, box.getAddr());
+ fir::StoreOp::create(builder, loc, nullPointer, box.getAddr());
} else {
assert(box.isAllocatable() && "must be an allocatable");
// For allocatables, sync the MutableBoxValue and descriptor before the
@@ -597,13 +597,14 @@ class AllocateStmtHelper {
assert(sourceBox && "source expression should be lowered to one box");
for (int i = 0; i < sourceExpr->Rank(); ++i) {
auto dimVal = builder.createIntegerConstant(loc, idxTy, i);
- auto dimInfo = builder.create<fir::BoxDimsOp>(
- loc, idxTy, idxTy, idxTy, sourceBox->getAddr(), dimVal);
+ auto dimInfo = fir::BoxDimsOp::create(builder, loc, idxTy, idxTy, idxTy,
+ sourceBox->getAddr(), dimVal);
mlir::Value lb =
fir::factory::readLowerBound(builder, loc, sourceExv, i, one);
mlir::Value extent = dimInfo.getResult(1);
- mlir::Value ub = builder.create<mlir::arith::SubIOp>(
- loc, builder.create<mlir::arith::AddIOp>(loc, extent, lb), one);
+ mlir::Value ub = mlir::arith::SubIOp::create(
+ builder, loc, mlir::arith::AddIOp::create(builder, loc, extent, lb),
+ one);
mlir::Value dimIndex = builder.createIntegerConstant(loc, i32Ty, i);
genRuntimeSetBounds(builder, loc, box, dimIndex, lb, ub);
}
@@ -668,7 +669,7 @@ class AllocateStmtHelper {
const auto args = fir::runtime::createArguments(
builder, loc, callee.getFunctionType(), box.getAddr(), typeDescAddr,
rankValue, corankValue);
- builder.create<fir::CallOp>(loc, callee, args);
+ fir::CallOp::create(builder, loc, callee, args);
}
/// Generate call to PointerNullifyIntrinsic or AllocatableInitIntrinsic to
@@ -697,7 +698,7 @@ class AllocateStmtHelper {
const auto args = fir::runtime::createArguments(
builder, loc, callee.getFunctionType(), box.getAddr(), categoryValue,
kindValue, rankValue, corankValue);
- builder.create<fir::CallOp>(loc, callee, args);
+ fir::CallOp::create(builder, loc, callee, args);
}
/// Generate call to the AllocatableInitDerived to set up the type descriptor
@@ -909,8 +910,8 @@ void Fortran::lower::genDeallocateIfAllocated(
.genThen([&]() {
if (mlir::Type eleType = box.getEleTy();
mlir::isa<fir::RecordType>(eleType) && box.isPolymorphic()) {
- mlir::Value declaredTypeDesc = builder.create<fir::TypeDescOp>(
- loc, mlir::TypeAttr::get(eleType));
+ mlir::Value declaredTypeDesc = fir::TypeDescOp::create(
+ builder, loc, mlir::TypeAttr::get(eleType));
genDeallocateBox(converter, box, loc, sym, declaredTypeDesc);
} else {
genDeallocateBox(converter, box, loc, sym);
@@ -1151,7 +1152,7 @@ mlir::Value Fortran::lower::getAssumedCharAllocatableOrPointerLen(
// here).
auto readLength = [&]() {
fir::BoxValue boxLoad =
- builder.create<fir::LoadOp>(loc, fir::getBase(box)).getResult();
+ fir::LoadOp::create(builder, loc, fir::getBase(box)).getResult();
return fir::factory::readCharLen(builder, loc, boxLoad);
};
if (Fortran::semantics::IsOptional(sym)) {
@@ -1160,15 +1161,15 @@ mlir::Value Fortran::lower::getAssumedCharAllocatableOrPointerLen(
// they are absents. According to 15.5.2.12 3 (9), it is illegal to
// inquire the length of absent optional, even if non deferred, so
// it's fine to use undefOp in this case.
- auto isPresent = builder.create<fir::IsPresentOp>(loc, builder.getI1Type(),
- fir::getBase(box));
+ auto isPresent = fir::IsPresentOp::create(builder, loc, builder.getI1Type(),
+ fir::getBase(box));
mlir::Value len =
builder.genIfOp(loc, {idxTy}, isPresent, true)
.genThen(
- [&]() { builder.create<fir::ResultOp>(loc, readLength()); })
+ [&]() { fir::ResultOp::create(builder, loc, readLength()); })
.genElse([&]() {
- auto undef = builder.create<fir::UndefOp>(loc, idxTy);
- builder.create<fir::ResultOp>(loc, undef.getResult());
+ auto undef = fir::UndefOp::create(builder, loc, idxTy);
+ fir::ResultOp::create(builder, loc, undef.getResult());
})
.getResults()[0];
return len;
@@ -1183,5 +1184,5 @@ mlir::Value Fortran::lower::getTypeDescAddr(
mlir::Type typeDesc =
Fortran::lower::translateDerivedTypeToFIRType(converter, typeSpec);
fir::FirOpBuilder &builder = converter.getFirOpBuilder();
- return builder.create<fir::TypeDescOp>(loc, mlir::TypeAttr::get(typeDesc));
+ return fir::TypeDescOp::create(builder, loc, mlir::TypeAttr::get(typeDesc));
}
diff --git a/flang/lib/Lower/Bridge.cpp b/flang/lib/Lower/Bridge.cpp
index 7ce397a11861b..b94833d852b2e 100644
--- a/flang/lib/Lower/Bridge.cpp
+++ b/flang/lib/Lower/Bridge.cpp
@@ -333,11 +333,12 @@ class TypeInfoConverter {
if (details.numPrivatesNotOverridden() > 0)
tbpName += "."s + std::to_string(details.numPrivatesNotOverridden());
std::string bindingName = converter.mangleName(details.symbol());
- builder.create<fir::DTEntryOp>(
- info.loc, mlir::StringAttr::get(builder.getContext(), tbpName),
+ fir::DTEntryOp::create(
+ builder, info.loc,
+ mlir::StringAttr::get(builder.getContext(), tbpName),
mlir::SymbolRefAttr::get(builder.getContext(), bindingName));
}
- builder.create<fir::FirEndOp>(info.loc);
+ fir::FirEndOp::create(builder, info.loc);
}
// Gather info about components that is not reflected in fir.type and may be
// needed later: component initial values and array component non default
@@ -360,11 +361,11 @@ class TypeInfoConverter {
componentInfo = builder.createBlock(&dt.getComponentInfo());
auto compName = mlir::StringAttr::get(builder.getContext(),
toStringRef(component.name()));
- builder.create<fir::DTComponentOp>(info.loc, compName, lbs, init_val);
+ fir::DTComponentOp::create(builder, info.loc, compName, lbs, init_val);
}
}
if (componentInfo)
- builder.create<fir::FirEndOp>(info.loc);
+ fir::FirEndOp::create(builder, info.loc);
builder.restoreInsertionPoint(insertPointIfCreated);
}
@@ -4829,18 +4830,18 @@ class FirConverter : public Fortran::lower::AbstractConverter {
base = convertOp.getValue();
// Special case if the rhs is a constant.
if (matchPattern(base.getDefiningOp(), mlir::m_Constant())) {
- builder.create<cuf::DataTransferOp>(loc, base, lhsVal, shape,
- transferKindAttr);
+ cuf::DataTransferOp::create(builder, loc, base, lhsVal, shape,
+ transferKindAttr);
} else {
auto associate = hlfir::genAssociateExpr(
loc, builder, rhs, rhs.getType(), ".cuf_host_tmp");
- builder.create<cuf::DataTransferOp>(loc, associate.getBase(), lhsVal,
- shape, transferKindAttr);
- builder.create<hlfir::EndAssociateOp>(loc, associate);
+ cuf::DataTransferOp::create(builder, loc, associate.getBase(), lhsVal,
+ shape, transferKindAttr);
+ hlfir::EndAssociateOp::create(builder, loc, associate);
}
} else {
- builder.create<cuf::DataTransferOp>(loc, rhsVal, lhsVal, shape,
- transferKindAttr);
+ cuf::DataTransferOp::create(builder, loc, rhsVal, lhsVal, shape,
+ transferKindAttr);
}
return;
}
@@ -4849,8 +4850,8 @@ class FirConverter : public Fortran::lower::AbstractConverter {
if (!lhsIsDevice && rhsIsDevice) {
auto transferKindAttr = cuf::DataTransferKindAttr::get(
builder.getContext(), cuf::DataTransferKind::DeviceHost);
- builder.create<cuf::DataTransferOp>(loc, rhsVal, lhsVal, shape,
- transferKindAttr);
+ cuf::DataTransferOp::create(builder, loc, rhsVal, lhsVal, shape,
+ transferKindAttr);
return;
}
@@ -4859,8 +4860,8 @@ class FirConverter : public Fortran::lower::AbstractConverter {
assert(rhs.isVariable() && "CUDA Fortran assignment rhs is not legal");
auto transferKindAttr = cuf::DataTransferKindAttr::get(
builder.getContext(), cuf::DataTransferKind::DeviceDevice);
- builder.create<cuf::DataTransferOp>(loc, rhsVal, lhsVal, shape,
- transferKindAttr);
+ cuf::DataTransferOp::create(builder, loc, rhsVal, lhsVal, shape,
+ transferKindAttr);
return;
}
llvm_unreachable("Unhandled CUDA data transfer");
@@ -4906,8 +4907,9 @@ class FirConverter : public Fortran::lower::AbstractConverter {
addSymbol(sym,
hlfir::translateToExtendedValue(loc, builder, temp).first,
/*forced=*/true);
- builder.create<cuf::DataTransferOp>(
- loc, addr, temp, /*shape=*/mlir::Value{}, transferKindAttr);
+ cuf::DataTransferOp::create(builder, loc, addr, temp,
+ /*shape=*/mlir::Value{},
+ transferKindAttr);
++nbDeviceResidentObject;
}
}
@@ -4996,13 +4998,13 @@ class FirConverter : public Fortran::lower::AbstractConverter {
if (isCUDATransfer && !hasCUDAImplicitTransfer)
genCUDADataTransfer(builder, loc, assign, lhs, rhs);
else
- builder.create<hlfir::AssignOp>(loc, rhs, lhs,
- isWholeAllocatableAssignment,
- keepLhsLengthInAllocatableAssignment);
+ hlfir::AssignOp::create(builder, loc, rhs, lhs,
+ isWholeAllocatableAssignment,
+ keepLhsLengthInAllocatableAssignment);
if (hasCUDAImplicitTransfer && !isInDeviceContext) {
localSymbols.popScope();
for (mlir::Value temp : implicitTemps)
- builder.create<fir::FreeMemOp>(loc, temp);
+ fir::FreeMemOp::create(builder, loc, temp);
}
return;
}
@@ -5010,13 +5012,13 @@ class FirConverter : public Fortran::lower::AbstractConverter {
// left-hand side requires using an hlfir.region_assign in HLFIR. The
// right-hand side and left-hand side must be evaluated inside the
// hlfir.region_assign regions.
- auto regionAssignOp = builder.create<hlfir::RegionAssignOp>(loc);
+ auto regionAssignOp = hlfir::RegionAssignOp::create(builder, loc);
// Lower RHS in its own region.
builder.createBlock(®ionAssignOp.getRhsRegion());
Fortran::lower::StatementContext rhsContext;
hlfir::Entity rhs = evaluateRhs(rhsContext);
- auto rhsYieldOp = builder.create<hlfir::YieldOp>(loc, rhs);
+ auto rhsYieldOp = hlfir::YieldOp::create(builder, loc, rhs);
Fortran::lower::genCleanUpInRegionIfAny(
loc, builder, rhsYieldOp.getCleanup(), rhsContext);
// Lower LHS in its own region.
@@ -5025,7 +5027,7 @@ class FirConverter : public Fortran::lower::AbstractConverter {
mlir::Value lhsYield = nullptr;
if (!lhsHasVectorSubscripts) {
hlfir::Entity lhs = evaluateLhs(lhsContext);
- auto lhsYieldOp = builder.create<hlfir::YieldOp>(loc, lhs);
+ auto lhsYieldOp = hlfir::YieldOp::create(builder, loc, lhs);
Fortran::lower::genCleanUpInRegionIfAny(
loc, builder, lhsYieldOp.getCleanup(), lhsContext);
lhsYield = lhs;
@@ -5054,7 +5056,7 @@ class FirConverter : public Fortran::lower::AbstractConverter {
builder.createBlock(®ionAssignOp.getUserDefinedAssignment(),
mlir::Region::iterator{}, {rhsType, lhsType},
{loc, loc});
- auto end = builder.create<fir::FirEndOp>(loc);
+ auto end = fir::FirEndOp::create(builder, loc);
builder.setInsertionPoint(end);
hlfir::Entity lhsBlockArg{regionAssignOp.getUserAssignmentLhs()};
hlfir::Entity rhsBlockArg{regionAssignOp.getUserAssignmentRhs()};
diff --git a/flang/lib/Lower/ConvertArrayConstructor.cpp b/flang/lib/Lower/ConvertArrayConstructor.cpp
index 7e2142693eac5..55c4b45554f78 100644
--- a/flang/lib/Lower/ConvertArrayConstructor.cpp
+++ b/flang/lib/Lower/ConvertArrayConstructor.cpp
@@ -137,9 +137,9 @@ class InlinedTempStrategyImpl : public StrategyBase,
mlir::Value stride) {
if constexpr (!hasLoops)
fir::emitFatalError(loc, "array constructor lowering is inconsistent");
- auto loop = builder.create<fir::DoLoopOp>(loc, lower, upper, stride,
- /*unordered=*/false,
- /*finalCount=*/false);
+ auto loop = fir::DoLoopOp::create(builder, loc, lower, upper, stride,
+ /*unordered=*/false,
+ /*finalCount=*/false);
builder.setInsertionPointToStart(loop.getBody());
return loop.getInductionVar();
}
@@ -213,15 +213,15 @@ class AsElementalStrategy : public StrategyBase {
assert(!elementalOp && "expected only one implied-do");
mlir::Value one =
builder.createIntegerConstant(loc, builder.getIndexType(), 1);
- elementalOp = builder.create<hlfir::ElementalOp>(
- loc, exprType, shape,
- /*mold=*/nullptr, lengthParams, /*isUnordered=*/true);
+ elementalOp = hlfir::ElementalOp::create(builder, loc, exprType, shape,
+ /*mold=*/nullptr, lengthParams,
+ /*isUnordered=*/true);
builder.setInsertionPointToStart(elementalOp.getBody());
// implied-do-index = lower+((i-1)*stride)
- mlir::Value
diff = builder.create<mlir::arith::SubIOp>(
- loc, elementalOp.getIndices()[0], one);
- mlir::Value mul = builder.create<mlir::arith::MulIOp>(loc,
diff , stride);
- mlir::Value add = builder.create<mlir::arith::AddIOp>(loc, lower, mul);
+ mlir::Value
diff = mlir::arith::SubIOp::create(
+ builder, loc, elementalOp.getIndices()[0], one);
+ mlir::Value mul = mlir::arith::MulIOp::create(builder, loc,
diff , stride);
+ mlir::Value add = mlir::arith::AddIOp::create(builder, loc, lower, mul);
return add;
}
@@ -260,7 +260,7 @@ class AsElementalStrategy : public StrategyBase {
if (destroyOp)
destroyOp->erase();
- builder.create<hlfir::YieldElementOp>(loc, elementResult);
+ hlfir::YieldElementOp::create(builder, loc, elementResult);
}
// Override the default, because the context scope must be popped in
@@ -315,8 +315,8 @@ class RuntimeTempStrategy : public StrategyBase {
mlir::Value tempStorage = builder.createHeapTemporary(
loc, declaredType, tempName, extents, lengths);
mlir::Value shape = builder.genShape(loc, extents);
- declare = builder.create<hlfir::DeclareOp>(
- loc, tempStorage, tempName, shape, lengths,
+ declare = hlfir::DeclareOp::create(
+ builder, loc, tempStorage, tempName, shape, lengths,
/*dummy_scope=*/nullptr, fir::FortranVariableFlagsAttr{});
initialBoxValue =
builder.createBox(loc, boxType, declare->getOriginalBase(), shape,
@@ -347,7 +347,7 @@ class RuntimeTempStrategy : public StrategyBase {
/*slice=*/mlir::Value{}, emboxLengths,
/*tdesc=*/{});
}
- builder.create<fir::StoreOp>(loc, initialBoxValue, allocatableTemp);
+ fir::StoreOp::create(builder, loc, initialBoxValue, allocatableTemp);
arrayConstructorVector = fir::runtime::genInitArrayConstructorVector(
loc, builder, allocatableTemp,
builder.createBool(loc, missingLengthParameters));
@@ -369,7 +369,7 @@ class RuntimeTempStrategy : public StrategyBase {
loc, builder, value, arrayConstructorElementType);
mlir::Value addr = fir::getBase(addrExv);
if (mlir::isa<fir::BaseBoxType>(addr.getType()))
- addr = builder.create<fir::BoxAddrOp>(loc, addr);
+ addr = fir::BoxAddrOp::create(builder, loc, addr);
fir::runtime::genPushArrayConstructorSimpleScalar(
loc, builder, arrayConstructorVector, addr);
if (cleanUp)
@@ -389,9 +389,9 @@ class RuntimeTempStrategy : public StrategyBase {
mlir::Value startImpliedDo(mlir::Location loc, fir::FirOpBuilder &builder,
mlir::Value lower, mlir::Value upper,
mlir::Value stride) {
- auto loop = builder.create<fir::DoLoopOp>(loc, lower, upper, stride,
- /*unordered=*/false,
- /*finalCount=*/false);
+ auto loop = fir::DoLoopOp::create(builder, loc, lower, upper, stride,
+ /*unordered=*/false,
+ /*finalCount=*/false);
builder.setInsertionPointToStart(loop.getBody());
return loop.getInductionVar();
}
@@ -409,7 +409,7 @@ class RuntimeTempStrategy : public StrategyBase {
else
temp = hlfir::derefPointersAndAllocatables(
loc, builder, hlfir::Entity{allocatableTemp});
- auto hlfirExpr = builder.create<hlfir::AsExprOp>(loc, temp, mustFree);
+ auto hlfirExpr = hlfir::AsExprOp::create(builder, loc, temp, mustFree);
return hlfir::Entity{hlfirExpr};
}
diff --git a/flang/lib/Lower/ConvertCall.cpp b/flang/lib/Lower/ConvertCall.cpp
index 071513303da25..8c3648bcb0f35 100644
--- a/flang/lib/Lower/ConvertCall.cpp
+++ b/flang/lib/Lower/ConvertCall.cpp
@@ -85,7 +85,7 @@ static mlir::Value genRecordCPtrValueArg(fir::FirOpBuilder &builder,
mlir::Location loc, mlir::Value rec,
mlir::Type ty) {
mlir::Value cAddr = fir::factory::genCPtrOrCFunptrAddr(builder, loc, rec, ty);
- mlir::Value cVal = builder.create<fir::LoadOp>(loc, cAddr);
+ mlir::Value cVal = fir::LoadOp::create(builder, loc, cAddr);
return builder.createConvert(loc, cAddr.getType(), cVal);
}
@@ -159,8 +159,8 @@ static mlir::Value readDim3Value(fir::FirOpBuilder &builder, mlir::Location loc,
mlir::Type refI32Ty = fir::ReferenceType::get(i32Ty);
llvm::SmallVector<mlir::Value> lenParams;
- mlir::Value designate = builder.create<hlfir::DesignateOp>(
- loc, refI32Ty, dim3Addr, /*component=*/comp,
+ mlir::Value designate = hlfir::DesignateOp::create(
+ builder, loc, refI32Ty, dim3Addr, /*component=*/comp,
/*componentShape=*/mlir::Value{}, hlfir::DesignateOp::Subscripts{},
/*substring=*/mlir::ValueRange{}, /*complexPartAttr=*/std::nullopt,
mlir::Value{}, lenParams);
@@ -229,8 +229,8 @@ static mlir::Value remapActualToDummyDescriptor(
if (fir::isPolymorphicType(dummyBoxType))
mold = explicitArgument;
mlir::Value remapped =
- builder.create<fir::EmboxOp>(loc, dummyBoxType, baseAddr, shape,
- /*slice=*/mlir::Value{}, lengths, mold);
+ fir::EmboxOp::create(builder, loc, dummyBoxType, baseAddr, shape,
+ /*slice=*/mlir::Value{}, lengths, mold);
if (mapSymbols)
symMap.popScope();
return remapped;
@@ -273,12 +273,12 @@ static void remapActualToDummyDescriptors(
mlir::Value newBox = remapActualToDummyDescriptor(
loc, converter, symMap, argLambdaCapture, caller,
isBindcCall);
- builder.create<fir::ResultOp>(loc, newBox);
+ fir::ResultOp::create(builder, loc, newBox);
})
.genElse([&]() {
mlir::Value absent =
- builder.create<fir::AbsentOp>(loc, dummyType);
- builder.create<fir::ResultOp>(loc, absent);
+ fir::AbsentOp::create(builder, loc, dummyType);
+ fir::ResultOp::create(builder, loc, absent);
})
.getResults()[0];
caller.placeInput(arg, remapped);
@@ -381,8 +381,8 @@ Fortran::lower::genCallOpAndResult(
if (isExprCall) {
mlir::Type exprType = hlfir::getExprType(type);
- evaluateInMemory = builder.create<hlfir::EvaluateInMemoryOp>(
- loc, exprType, arrayResultShape, resultLengths);
+ evaluateInMemory = hlfir::EvaluateInMemoryOp::create(
+ builder, loc, exprType, arrayResultShape, resultLengths);
builder.setInsertionPointToStart(&evaluateInMemory.getBody().front());
return toExtendedValue(loc, evaluateInMemory.getMemory(), extents,
lengths);
@@ -454,7 +454,7 @@ Fortran::lower::genCallOpAndResult(
if (!addHostAssociations &&
mustCastFuncOpToCopeWithImplicitInterfaceMismatch(
loc, converter, callSiteType, funcOpType))
- funcPointer = builder.create<fir::AddrOfOp>(loc, funcOpType, symbolAttr);
+ funcPointer = fir::AddrOfOp::create(builder, loc, funcOpType, symbolAttr);
else
funcSymbolAttr = symbolAttr;
@@ -482,7 +482,7 @@ Fortran::lower::genCallOpAndResult(
if (funcPointer) {
operands.push_back(
mlir::isa<fir::BoxProcType>(funcPointer.getType())
- ? builder.create<fir::BoxAddrOp>(loc, funcType, funcPointer)
+ ? fir::BoxAddrOp::create(builder, loc, funcType, funcPointer)
: builder.createConvert(loc, funcType, funcPointer));
}
@@ -499,10 +499,10 @@ Fortran::lower::genCallOpAndResult(
auto funcTy = mlir::FunctionType::get(context, {}, {});
auto boxProcTy = builder.getBoxProcType(funcTy);
if (mlir::Value host = argumentHostAssocs(converter, fst)) {
- cast = builder.create<fir::EmboxProcOp>(
- loc, boxProcTy, llvm::ArrayRef<mlir::Value>{fst, host});
+ cast = fir::EmboxProcOp::create(builder, loc, boxProcTy,
+ llvm::ArrayRef<mlir::Value>{fst, host});
} else {
- cast = builder.create<fir::EmboxProcOp>(loc, boxProcTy, fst);
+ cast = fir::EmboxProcOp::create(builder, loc, boxProcTy, fst);
}
} else {
mlir::Type fromTy = fir::unwrapRefType(fst.getType());
@@ -613,10 +613,10 @@ Fortran::lower::genCallOpAndResult(
stream = fir::getBase(converter.genExprAddr(
caller.getCallDescription().chevrons()[3], stmtCtx));
- builder.create<cuf::KernelLaunchOp>(
- loc, funcType.getResults(), funcSymbolAttr, grid_x, grid_y, grid_z,
- block_x, block_y, block_z, bytes, stream, operands,
- /*arg_attrs=*/nullptr, /*res_attrs=*/nullptr);
+ cuf::KernelLaunchOp::create(builder, loc, funcType.getResults(),
+ funcSymbolAttr, grid_x, grid_y, grid_z, block_x,
+ block_y, block_z, bytes, stream, operands,
+ /*arg_attrs=*/nullptr, /*res_attrs=*/nullptr);
callNumResults = 0;
} else if (caller.requireDispatchCall()) {
// Procedure call requiring a dynamic dispatch. Call is created with
@@ -640,8 +640,8 @@ Fortran::lower::genCallOpAndResult(
// passed object because interface mismatch issues may have inserted a
// cast to the operand with a
diff erent declared type, which would break
// later type bound call resolution in the FIR to FIR pass.
- dispatch = builder.create<fir::DispatchOp>(
- loc, funcType.getResults(), builder.getStringAttr(procName),
+ dispatch = fir::DispatchOp::create(
+ builder, loc, funcType.getResults(), builder.getStringAttr(procName),
caller.getInputs()[*passArg], operands,
builder.getI32IntegerAttr(*passArg), /*arg_attrs=*/nullptr,
/*res_attrs=*/nullptr, procAttrs);
@@ -656,9 +656,9 @@ Fortran::lower::genCallOpAndResult(
mlir::Value passObject = fir::getBase(dataRefValue);
if (fir::isa_ref_type(passObject.getType()))
- passObject = builder.create<fir::LoadOp>(loc, passObject);
- dispatch = builder.create<fir::DispatchOp>(
- loc, funcType.getResults(), builder.getStringAttr(procName),
+ passObject = fir::LoadOp::create(builder, loc, passObject);
+ dispatch = fir::DispatchOp::create(
+ builder, loc, funcType.getResults(), builder.getStringAttr(procName),
passObject, operands, nullptr, /*arg_attrs=*/nullptr,
/*res_attrs=*/nullptr, procAttrs);
}
@@ -667,8 +667,8 @@ Fortran::lower::genCallOpAndResult(
callResult = dispatch.getResult(0);
} else {
// Standard procedure call with fir.call.
- auto call = builder.create<fir::CallOp>(
- loc, funcType.getResults(), funcSymbolAttr, operands,
+ auto call = fir::CallOp::create(
+ builder, loc, funcType.getResults(), funcSymbolAttr, operands,
/*arg_attrs=*/nullptr, /*res_attrs=*/nullptr, procAttrs);
callNumResults = call.getNumResults();
@@ -691,9 +691,9 @@ Fortran::lower::genCallOpAndResult(
if (caller.mustSaveResult()) {
assert(allocatedResult.has_value());
- builder.create<fir::SaveResultOp>(loc, callResult,
- fir::getBase(*allocatedResult),
- arrayResultShape, resultLengths);
+ fir::SaveResultOp::create(builder, loc, callResult,
+ fir::getBase(*allocatedResult), arrayResultShape,
+ resultLengths);
}
if (evaluateInMemory) {
@@ -864,9 +864,9 @@ static hlfir::EntityWithAttributes genStmtFunctionRef(
// The result must not be a variable.
result = hlfir::loadTrivialScalar(loc, builder, result);
if (result.isVariable())
- result = hlfir::Entity{builder.create<hlfir::AsExprOp>(loc, result)};
+ result = hlfir::Entity{hlfir::AsExprOp::create(builder, loc, result)};
for (auto associate : exprAssociations)
- builder.create<hlfir::EndAssociateOp>(loc, associate);
+ hlfir::EndAssociateOp::create(builder, loc, associate);
return hlfir::EntityWithAttributes{result};
}
@@ -951,9 +951,9 @@ extendedValueToHlfirEntity(mlir::Location loc, fir::FirOpBuilder &builder,
// rid of the memory indirection in a = char(b), so there is
// little incentive to increase the compiler complexity.
hlfir::Entity storage{builder.createTemporary(loc, charTy)};
- builder.create<fir::StoreOp>(loc, firBase, storage);
- auto asExpr = builder.create<hlfir::AsExprOp>(
- loc, storage, /*mustFree=*/builder.createBool(loc, false));
+ fir::StoreOp::create(builder, loc, firBase, storage);
+ auto asExpr = hlfir::AsExprOp::create(
+ builder, loc, storage, /*mustFree=*/builder.createBool(loc, false));
return hlfir::EntityWithAttributes{asExpr.getResult()};
}
return hlfir::genDeclare(loc, builder, exv, name,
@@ -965,7 +965,7 @@ namespace {
struct CallCleanUp {
struct CopyIn {
void genCleanUp(mlir::Location loc, fir::FirOpBuilder &builder) {
- builder.create<hlfir::CopyOutOp>(loc, tempBox, wasCopied, copyBackVar);
+ hlfir::CopyOutOp::create(builder, loc, tempBox, wasCopied, copyBackVar);
}
// address of the descriptor holding the temp if a temp was created.
mlir::Value tempBox;
@@ -976,7 +976,7 @@ struct CallCleanUp {
};
struct ExprAssociate {
void genCleanUp(mlir::Location loc, fir::FirOpBuilder &builder) {
- builder.create<hlfir::EndAssociateOp>(loc, tempVar, mustFree);
+ hlfir::EndAssociateOp::create(builder, loc, tempVar, mustFree);
}
mlir::Value tempVar;
mlir::Value mustFree;
@@ -1074,7 +1074,7 @@ struct ConditionallyPreparedDummy {
/// Generate the "fir.result %preparedDummy" in the then branch of the
/// wrapping fir.if.
void genThenResult(mlir::Location loc, fir::FirOpBuilder &builder) const {
- builder.create<fir::ResultOp>(loc, thenResultValues);
+ fir::ResultOp::create(builder, loc, thenResultValues);
}
/// Generate the "fir.result %absent" in the else branch of the
@@ -1089,7 +1089,7 @@ struct ConditionallyPreparedDummy {
else
elseResultValues.push_back(builder.genAbsentOp(loc, type));
}
- builder.create<fir::ResultOp>(loc, elseResultValues);
+ fir::ResultOp::create(builder, loc, elseResultValues);
}
/// Once the fir.if has been created, get the resulting %conditionallyPrepared
@@ -1134,7 +1134,7 @@ static hlfir::Entity fixProcedureDummyMismatch(mlir::Location loc,
if (mlir::isa<fir::BoxProcType>(actual.getType()) &&
fir::isCharacterProcedureTuple(dummyType)) {
mlir::Value length =
- builder.create<fir::UndefOp>(loc, builder.getCharacterLengthType());
+ fir::UndefOp::create(builder, loc, builder.getCharacterLengthType());
mlir::Value tuple = fir::factory::createCharacterProcedureTuple(
builder, loc, dummyType, actual, length);
return hlfir::Entity{tuple};
@@ -1317,8 +1317,8 @@ static PreparedDummyArgument preparePresentUserCallActualArgument(
mlir::Type tempBoxType = baseBoxTy.getBoxTypeWithNewAttr(
fir::BaseBoxType::Attribute::Allocatable);
mlir::Value tempBox = builder.createTemporary(loc, tempBoxType);
- auto copyIn = builder.create<hlfir::CopyInOp>(
- loc, var, tempBox, /*var_is_present=*/mlir::Value{});
+ auto copyIn = hlfir::CopyInOp::create(builder, loc, var, tempBox,
+ /*var_is_present=*/mlir::Value{});
// Register the copy-out after the call.
preparedDummy.pushCopyInCleanUp(copyIn.getTempBox(), copyIn.getWasCopied(),
doCopyOut ? copyIn.getVar()
@@ -1330,16 +1330,17 @@ static PreparedDummyArgument preparePresentUserCallActualArgument(
fir::BaseBoxType boxType = fir::BoxType::get(
hlfir::getFortranElementOrSequenceType(dummyTypeWithActualRank));
if (actualIsAssumedRank)
- return hlfir::Entity{builder.create<fir::ReboxAssumedRankOp>(
- loc, boxType, var, fir::LowerBoundModifierAttribute::SetToOnes)};
+ return hlfir::Entity{fir::ReboxAssumedRankOp::create(
+ builder, loc, boxType, var,
+ fir::LowerBoundModifierAttribute::SetToOnes)};
// Use actual shape when creating descriptor with dummy type, the dummy
// shape may be unknown in case of sequence association.
mlir::Type actualTy =
hlfir::getFortranElementOrSequenceType(actual.getType());
boxType = boxType.getBoxTypeWithNewShape(actualTy);
- return hlfir::Entity{builder.create<fir::ReboxOp>(loc, boxType, var,
- /*shape=*/mlir::Value{},
- /*slice=*/mlir::Value{})};
+ return hlfir::Entity{fir::ReboxOp::create(builder, loc, boxType, var,
+ /*shape=*/mlir::Value{},
+ /*slice=*/mlir::Value{})};
};
// Step 2: prepare the storage for the dummy arguments, ensuring that it
@@ -1361,7 +1362,7 @@ static PreparedDummyArgument preparePresentUserCallActualArgument(
// generated writes in copy-out.
isParameterObjectOrSubObject(entity)) {
// Make a copy in a temporary.
- auto copy = builder.create<hlfir::AsExprOp>(loc, entity);
+ auto copy = hlfir::AsExprOp::create(builder, loc, entity);
mlir::Type storageType = entity.getType();
mlir::NamedAttribute byRefAttr = fir::getAdaptToByRefAttr(builder);
hlfir::AssociateOp associate = hlfir::genAssociateExpr(
@@ -1441,14 +1442,14 @@ static PreparedDummyArgument preparePresentUserCallActualArgument(
auto lbModifier = needsZeroLowerBounds
? fir::LowerBoundModifierAttribute::SetToZeroes
: fir::LowerBoundModifierAttribute::SetToOnes;
- entity = hlfir::Entity{builder.create<fir::ReboxAssumedRankOp>(
- loc, dummyTypeWithActualRank, entity, lbModifier)};
+ entity = hlfir::Entity{fir::ReboxAssumedRankOp::create(
+ builder, loc, dummyTypeWithActualRank, entity, lbModifier)};
} else {
mlir::Value shift{};
if (needsZeroLowerBounds)
shift = getZeroLowerBounds(loc, builder, entity);
- entity = hlfir::Entity{builder.create<fir::ReboxOp>(
- loc, dummyTypeWithActualRank, entity, /*shape=*/shift,
+ entity = hlfir::Entity{fir::ReboxOp::create(
+ builder, loc, dummyTypeWithActualRank, entity, /*shape=*/shift,
/*slice=*/mlir::Value{})};
}
}
@@ -1501,8 +1502,8 @@ static PreparedDummyArgument prepareUserCallActualArgument(
// for this unusual if/then/else generation is that the number
// and types of the if results will depend on how the argument
// is prepared, and forecasting that here would be brittle.
- auto badIfOp = builder.create<fir::IfOp>(loc, dummyType, isPresent,
- /*withElseRegion=*/false);
+ auto badIfOp = fir::IfOp::create(builder, loc, dummyType, isPresent,
+ /*withElseRegion=*/false);
mlir::Block *preparationBlock = &badIfOp.getThenRegion().front();
builder.setInsertionPointToStart(preparationBlock);
PreparedDummyArgument unconditionalDummy =
@@ -1520,9 +1521,9 @@ static PreparedDummyArgument prepareUserCallActualArgument(
// badIfOp cannot be modified and used here).
llvm::SmallVector<mlir::Type> ifOpResultTypes;
ConditionallyPreparedDummy conditionalDummy(unconditionalDummy);
- auto ifOp = builder.create<fir::IfOp>(loc, conditionalDummy.getIfResulTypes(),
- isPresent,
- /*withElseRegion=*/true);
+ auto ifOp = fir::IfOp::create(builder, loc,
+ conditionalDummy.getIfResulTypes(), isPresent,
+ /*withElseRegion=*/true);
// Move "preparationBlock" into the "then" of the new
// fir.if operation and create fir.result propagating
// unconditionalDummy.
@@ -1559,7 +1560,7 @@ static PreparedDummyArgument prepareProcedurePointerActualArgument(
auto tempBoxProc{builder.createTemporary(loc, boxTy)};
hlfir::Entity nullBoxProc(
fir::factory::createNullBoxProc(builder, loc, boxTy));
- builder.create<fir::StoreOp>(loc, nullBoxProc, tempBoxProc);
+ fir::StoreOp::create(builder, loc, nullBoxProc, tempBoxProc);
return PreparedDummyArgument{tempBoxProc, /*cleanups=*/{}};
}
hlfir::Entity actual = preparedActual.getActual(loc, builder);
@@ -1568,7 +1569,7 @@ static PreparedDummyArgument prepareProcedurePointerActualArgument(
assert(actual.isProcedure());
// Procedure actual to procedure pointer dummy.
auto tempBoxProc{builder.createTemporary(loc, actual.getType())};
- builder.create<fir::StoreOp>(loc, actual, tempBoxProc);
+ fir::StoreOp::create(builder, loc, actual, tempBoxProc);
return PreparedDummyArgument{tempBoxProc, /*cleanups=*/{}};
}
@@ -1607,7 +1608,7 @@ void prepareUserCallArguments(
"adapt.cptrbyval");
value = hlfir::Entity{genRecordCPtrValueArg(
builder, loc, associate.getFirBase(), eleTy)};
- builder.create<hlfir::EndAssociateOp>(loc, associate);
+ hlfir::EndAssociateOp::create(builder, loc, associate);
} else {
value =
hlfir::Entity{genRecordCPtrValueArg(builder, loc, value, eleTy)};
@@ -1626,7 +1627,7 @@ void prepareUserCallArguments(
loadedValue = builder.createConvert(
loc, fir::ReferenceType::get(argTy), loadedValue);
if (fir::isa_ref_type(loadedValue.getType()))
- loadedValue = builder.create<fir::LoadOp>(loc, loadedValue);
+ loadedValue = fir::LoadOp::create(builder, loc, loadedValue);
caller.placeInput(arg, loadedValue);
if (cleanup)
(*cleanup)();
@@ -1811,8 +1812,9 @@ genUserCall(Fortran::lower::PreparedActualArguments &loweredActuals,
// In such case, the expression should not be freed after its use since
// the result is stack allocated or deallocation (for allocatable results)
// was already inserted in genCallOpAndResult.
- auto asExpr = builder.create<hlfir::AsExprOp>(
- loc, resultEntity, /*mustFree=*/builder.createBool(loc, false));
+ auto asExpr =
+ hlfir::AsExprOp::create(builder, loc, resultEntity,
+ /*mustFree=*/builder.createBool(loc, false));
return hlfir::EntityWithAttributes{asExpr.getResult()};
}
return hlfir::EntityWithAttributes{resultEntity};
@@ -1860,12 +1862,12 @@ static ExvAndCleanup genOptionalValue(fir::FirOpBuilder &builder,
"must be a numerical or logical scalar");
mlir::Value val =
hlfir::loadTrivialScalar(loc, builder, entity);
- builder.create<fir::ResultOp>(loc, val);
+ fir::ResultOp::create(builder, loc, val);
})
.genElse([&]() {
mlir::Value zero =
fir::factory::createZeroValue(builder, loc, eleType);
- builder.create<fir::ResultOp>(loc, zero);
+ fir::ResultOp::create(builder, loc, zero);
})
.getResults()[0],
std::nullopt};
@@ -1912,9 +1914,9 @@ static ExvAndCleanup genOptionalBox(fir::FirOpBuilder &builder,
// ensures it won't be.
mlir::Value box = builder.createBox(loc, newExv);
mlir::Type boxType = box.getType();
- auto absent = builder.create<fir::AbsentOp>(loc, boxType);
- auto boxOrAbsent = builder.create<mlir::arith::SelectOp>(
- loc, boxType, isPresent, box, absent);
+ auto absent = fir::AbsentOp::create(builder, loc, boxType);
+ auto boxOrAbsent = mlir::arith::SelectOp::create(builder, loc, boxType,
+ isPresent, box, absent);
return {fir::BoxValue(boxOrAbsent), cleanup};
}
@@ -2142,10 +2144,10 @@ genIntrinsicRefCore(Fortran::lower::PreparedActualArguments &loweredActuals,
// ownership of this address cannot be taken here since it may not be a
// temp.
if (intrinsicName == "merge")
- asExpr = builder.create<hlfir::AsExprOp>(loc, resultEntity);
+ asExpr = hlfir::AsExprOp::create(builder, loc, resultEntity);
else
- asExpr = builder.create<hlfir::AsExprOp>(
- loc, resultEntity, builder.createBool(loc, mustBeFreed));
+ asExpr = hlfir::AsExprOp::create(builder, loc, resultEntity,
+ builder.createBool(loc, mustBeFreed));
resultEntity = hlfir::EntityWithAttributes{asExpr.getResult()};
}
return resultEntity;
@@ -2525,7 +2527,7 @@ genIsPresentIfArgMaybeAbsent(mlir::Location loc, hlfir::Entity actual,
// May fall into the category above if the allocatable is not optional.
// Passing an optional to an optional.
- return builder.create<fir::IsPresentOp>(loc, builder.getI1Type(), actual)
+ return fir::IsPresentOp::create(builder, loc, builder.getI1Type(), actual)
.getResult();
}
@@ -2813,9 +2815,9 @@ genProcedureRef(CallContext &callContext) {
// TYPE(*) cannot be ALLOCATABLE/POINTER (C709) so there is no
// need to cover the case of passing an ALLOCATABLE/POINTER to an
// OPTIONAL.
- isPresent =
- builder.create<fir::IsPresentOp>(loc, builder.getI1Type(), actual)
- .getResult();
+ isPresent = fir::IsPresentOp::create(builder, loc,
+ builder.getI1Type(), actual)
+ .getResult();
}
loweredActuals.push_back(Fortran::lower::PreparedActualArgument{
hlfir::Entity{*var}, isPresent});
@@ -2931,7 +2933,7 @@ std::optional<hlfir::EntityWithAttributes> Fortran::lower::convertCallToHLFIR(
// this can be enforced whenscheduling forall/where expression evaluations.
Fortran::lower::StatementContext localStmtCtx;
mlir::Type bogusType = builder.getIndexType();
- auto exactlyOnce = builder.create<hlfir::ExactlyOnceOp>(loc, bogusType);
+ auto exactlyOnce = hlfir::ExactlyOnceOp::create(builder, loc, bogusType);
mlir::Block *block = builder.createBlock(&exactlyOnce.getBody());
builder.setInsertionPointToStart(block);
CallContext callContext(procRef, resultType, loc, converter, symMap,
@@ -2939,7 +2941,7 @@ std::optional<hlfir::EntityWithAttributes> Fortran::lower::convertCallToHLFIR(
std::optional<hlfir::EntityWithAttributes> res =
genProcedureRef(callContext);
assert(res.has_value() && "must be a function");
- auto yield = builder.create<hlfir::YieldOp>(loc, *res);
+ auto yield = hlfir::YieldOp::create(builder, loc, *res);
Fortran::lower::genCleanUpInRegionIfAny(loc, builder, yield.getCleanup(),
localStmtCtx);
builder.setInsertionPointAfter(exactlyOnce);
diff --git a/flang/lib/Lower/ConvertConstant.cpp b/flang/lib/Lower/ConvertConstant.cpp
index b8ab5d09e3e08..768a237c92396 100644
--- a/flang/lib/Lower/ConvertConstant.cpp
+++ b/flang/lib/Lower/ConvertConstant.cpp
@@ -237,8 +237,8 @@ static mlir::Value genScalarLit(
? value.UnsignedDecimal()
: value.SignedDecimal(),
10);
- return builder.create<mlir::arith::ConstantOp>(
- loc, ty, mlir::IntegerAttr::get(ty, bigInt));
+ return mlir::arith::ConstantOp::create(
+ builder, loc, ty, mlir::IntegerAttr::get(ty, bigInt));
}
return builder.createIntegerConstant(loc, ty, value.ToInt64());
} else if constexpr (TC == Fortran::common::TypeCategory::Logical) {
@@ -302,8 +302,9 @@ createStringLitOp(fir::FirOpBuilder &builder, mlir::Location loc,
auto sizeTag = mlir::StringAttr::get(context, fir::StringLitOp::size());
mlir::NamedAttribute sizeAttr(sizeTag, builder.getI64IntegerAttr(len));
llvm::SmallVector<mlir::NamedAttribute> attrs = {dataAttr, sizeAttr};
- return builder.create<fir::StringLitOp>(
- loc, llvm::ArrayRef<mlir::Type>{type}, mlir::ValueRange{}, attrs);
+ return fir::StringLitOp::create(builder, loc,
+ llvm::ArrayRef<mlir::Type>{type},
+ mlir::ValueRange{}, attrs);
}
}
@@ -340,11 +341,11 @@ genScalarLit(fir::FirOpBuilder &builder, mlir::Location loc,
[&](fir::FirOpBuilder &builder) {
fir::StringLitOp str =
createStringLitOp<KIND>(builder, loc, value, len);
- builder.create<fir::HasValueOp>(loc, str);
+ fir::HasValueOp::create(builder, loc, str);
},
builder.createLinkOnceLinkage());
- return builder.create<fir::AddrOfOp>(loc, global.resultType(),
- global.getSymbol());
+ return fir::AddrOfOp::create(builder, loc, global.resultType(),
+ global.getSymbol());
}
// Helper to generate StructureConstructor component values.
@@ -364,9 +365,9 @@ static mlir::Value genStructureComponentInit(
auto fieldTy = fir::FieldType::get(recTy.getContext());
assert(componentTy && "failed to retrieve component");
// FIXME: type parameters must come from the derived-type-spec
- auto field = builder.create<fir::FieldIndexOp>(
- loc, fieldTy, name, recTy,
- /*typeParams=*/mlir::ValueRange{} /*TODO*/);
+ auto field =
+ fir::FieldIndexOp::create(builder, loc, fieldTy, name, recTy,
+ /*typeParams=*/mlir::ValueRange{} /*TODO*/);
if (Fortran::semantics::IsAllocatable(sym)) {
if (!Fortran::evaluate::IsNullPointerOrAllocatable(&expr)) {
@@ -378,8 +379,8 @@ static mlir::Value genStructureComponentInit(
fir::factory::createUnallocatedBox(builder, loc, componentTy, {})};
componentValue = builder.createConvert(loc, componentTy, componentValue);
- return builder.create<fir::InsertValueOp>(
- loc, recTy, res, componentValue,
+ return fir::InsertValueOp::create(
+ builder, loc, recTy, res, componentValue,
builder.getArrayAttr(field.getAttributes()));
}
}
@@ -400,9 +401,9 @@ static mlir::Value genStructureComponentInit(
} else
initialTarget = Fortran::lower::genInitialDataTarget(converter, loc,
componentTy, expr);
- res = builder.create<fir::InsertValueOp>(
- loc, recTy, res, initialTarget,
- builder.getArrayAttr(field.getAttributes()));
+ res =
+ fir::InsertValueOp::create(builder, loc, recTy, res, initialTarget,
+ builder.getArrayAttr(field.getAttributes()));
return res;
}
@@ -426,7 +427,7 @@ static mlir::Value genStructureComponentInit(
mlir::Value addr = fir::getBase(
Fortran::lower::genExtAddrInInitializer(converter, loc, expr));
if (mlir::isa<fir::BoxProcType>(addr.getType()))
- addr = builder.create<fir::BoxAddrOp>(loc, addr);
+ addr = fir::BoxAddrOp::create(builder, loc, addr);
assert((fir::isa_ref_type(addr.getType()) ||
mlir::isa<mlir::FunctionType>(addr.getType())) &&
"expect reference type for address field");
@@ -435,24 +436,25 @@ static mlir::Value genStructureComponentInit(
auto cPtrRecTy = mlir::cast<fir::RecordType>(componentTy);
llvm::StringRef addrFieldName = Fortran::lower::builtin::cptrFieldName;
mlir::Type addrFieldTy = cPtrRecTy.getType(addrFieldName);
- auto addrField = builder.create<fir::FieldIndexOp>(
- loc, fieldTy, addrFieldName, componentTy,
+ auto addrField = fir::FieldIndexOp::create(
+ builder, loc, fieldTy, addrFieldName, componentTy,
/*typeParams=*/mlir::ValueRange{});
mlir::Value castAddr = builder.createConvert(loc, addrFieldTy, addr);
- auto undef = builder.create<fir::UndefOp>(loc, componentTy);
- addr = builder.create<fir::InsertValueOp>(
- loc, componentTy, undef, castAddr,
+ auto undef = fir::UndefOp::create(builder, loc, componentTy);
+ addr = fir::InsertValueOp::create(
+ builder, loc, componentTy, undef, castAddr,
builder.getArrayAttr(addrField.getAttributes()));
- res = builder.create<fir::InsertValueOp>(
- loc, recTy, res, addr, builder.getArrayAttr(field.getAttributes()));
+ res =
+ fir::InsertValueOp::create(builder, loc, recTy, res, addr,
+ builder.getArrayAttr(field.getAttributes()));
return res;
}
mlir::Value val = fir::getBase(genConstantValue(converter, loc, expr));
assert(!fir::isa_ref_type(val.getType()) && "expecting a constant value");
mlir::Value castVal = builder.createConvert(loc, componentTy, val);
- res = builder.create<fir::InsertValueOp>(
- loc, recTy, res, castVal, builder.getArrayAttr(field.getAttributes()));
+ res = fir::InsertValueOp::create(builder, loc, recTy, res, castVal,
+ builder.getArrayAttr(field.getAttributes()));
return res;
}
@@ -465,7 +467,7 @@ static mlir::Value genInlinedStructureCtorLitImpl(
auto recTy = mlir::cast<fir::RecordType>(type);
if (!converter.getLoweringOptions().getLowerToHighLevelFIR()) {
- mlir::Value res = builder.create<fir::UndefOp>(loc, recTy);
+ mlir::Value res = fir::UndefOp::create(builder, loc, recTy);
for (const auto &[sym, expr] : ctor.values()) {
// Parent components need more work because they do not appear in the
// fir.rec type.
@@ -495,13 +497,13 @@ static mlir::Value genInlinedStructureCtorLitImpl(
break;
}
for (mlir::Type parentType : llvm::reverse(parentTypes)) {
- auto undef = builder.create<fir::UndefOp>(loc, parentType);
+ auto undef = fir::UndefOp::create(builder, loc, parentType);
fir::RecordType parentRecTy = mlir::cast<fir::RecordType>(parentType);
- auto field = builder.create<fir::FieldIndexOp>(
- loc, fieldTy, parentRecTy.getTypeList()[0].first, parentType,
+ auto field = fir::FieldIndexOp::create(
+ builder, loc, fieldTy, parentRecTy.getTypeList()[0].first, parentType,
/*typeParams=*/mlir::ValueRange{} /*TODO*/);
- res = builder.create<fir::InsertValueOp>(
- loc, parentRecTy, undef, res,
+ res = fir::InsertValueOp::create(
+ builder, loc, parentRecTy, undef, res,
builder.getArrayAttr(field.getAttributes()));
}
};
@@ -514,7 +516,7 @@ static mlir::Value genInlinedStructureCtorLitImpl(
if (!res) {
mlir::Type parentType = converter.genType(*componentParentType);
curentType = componentParentType;
- res = builder.create<fir::UndefOp>(loc, parentType);
+ res = fir::UndefOp::create(builder, loc, parentType);
} else if (*componentParentType != *curentType) {
mlir::Type parentType = converter.genType(*componentParentType);
insertParentValueIntoExtension(parentType);
@@ -524,7 +526,7 @@ static mlir::Value genInlinedStructureCtorLitImpl(
}
if (!res) // structure constructor for empty type.
- return builder.create<fir::UndefOp>(loc, recTy);
+ return fir::UndefOp::create(builder, loc, recTy);
// The last component may belong to a parent type.
if (res.getType() != recTy)
@@ -550,12 +552,12 @@ static mlir::Value genScalarLit(
[&](fir::FirOpBuilder &builder) {
mlir::Value result =
genInlinedStructureCtorLitImpl(converter, loc, value, eleTy);
- builder.create<fir::HasValueOp>(loc, result);
+ fir::HasValueOp::create(builder, loc, result);
},
builder.createInternalLinkage());
}
- return builder.create<fir::AddrOfOp>(loc, global.resultType(),
- global.getSymbol());
+ return fir::AddrOfOp::create(builder, loc, global.resultType(),
+ global.getSymbol());
}
/// Create an evaluate::Constant<T> array to a fir.array<> value
@@ -576,7 +578,7 @@ genInlinedArrayLit(Fortran::lower::AbstractConverter &converter,
builder.getIntegerAttr(idxTy, subscripts[i] - con.lbounds()[i]));
return idx;
};
- mlir::Value array = builder.create<fir::UndefOp>(loc, arrayTy);
+ mlir::Value array = fir::UndefOp::create(builder, loc, arrayTy);
if (Fortran::evaluate::GetSize(con.shape()) == 0)
return array;
if constexpr (T::category == Fortran::common::TypeCategory::Character) {
@@ -584,8 +586,9 @@ genInlinedArrayLit(Fortran::lower::AbstractConverter &converter,
mlir::Value elementVal =
genScalarLit<T::kind>(builder, loc, con.At(subscripts), con.LEN(),
/*outlineInReadOnlyMemory=*/false);
- array = builder.create<fir::InsertValueOp>(
- loc, arrayTy, array, elementVal, builder.getArrayAttr(createIdx()));
+ array =
+ fir::InsertValueOp::create(builder, loc, arrayTy, array, elementVal,
+ builder.getArrayAttr(createIdx()));
} while (con.IncrementSubscripts(subscripts));
} else if constexpr (T::category == Fortran::common::TypeCategory::Derived) {
do {
@@ -594,8 +597,9 @@ genInlinedArrayLit(Fortran::lower::AbstractConverter &converter,
mlir::Value elementVal =
genScalarLit(converter, loc, con.At(subscripts), eleTy,
/*outlineInReadOnlyMemory=*/false);
- array = builder.create<fir::InsertValueOp>(
- loc, arrayTy, array, elementVal, builder.getArrayAttr(createIdx()));
+ array =
+ fir::InsertValueOp::create(builder, loc, arrayTy, array, elementVal,
+ builder.getArrayAttr(createIdx()));
} while (con.IncrementSubscripts(subscripts));
} else {
llvm::SmallVector<mlir::Attribute> rangeStartIdx;
@@ -611,9 +615,9 @@ genInlinedArrayLit(Fortran::lower::AbstractConverter &converter,
bool nextIsSame = con.IncrementSubscripts(nextSubscripts) &&
con.At(subscripts) == con.At(nextSubscripts);
if (!rangeSize && !nextIsSame) { // single (non-range) value
- array = builder.create<fir::InsertValueOp>(
- loc, arrayTy, array, getElementVal(),
- builder.getArrayAttr(createIdx()));
+ array = fir::InsertValueOp::create(builder, loc, arrayTy, array,
+ getElementVal(),
+ builder.getArrayAttr(createIdx()));
} else if (!rangeSize) { // start a range
rangeStartIdx = createIdx();
rangeSize = 1;
@@ -629,8 +633,8 @@ genInlinedArrayLit(Fortran::lower::AbstractConverter &converter,
rangeBounds.push_back(
mlir::cast<mlir::IntegerAttr>(idx[i]).getValue().getSExtValue());
}
- array = builder.create<fir::InsertOnRangeOp>(
- loc, arrayTy, array, getElementVal(),
+ array = fir::InsertOnRangeOp::create(
+ builder, loc, arrayTy, array, getElementVal(),
builder.getIndexVectorAttr(rangeBounds));
rangeSize = 0;
}
@@ -679,12 +683,12 @@ genOutlineArrayLit(Fortran::lower::AbstractConverter &converter,
[&](fir::FirOpBuilder &builder) {
mlir::Value result =
genInlinedArrayLit(converter, loc, arrayTy, constant);
- builder.create<fir::HasValueOp>(loc, result);
+ fir::HasValueOp::create(builder, loc, result);
},
builder.createInternalLinkage());
}
- return builder.create<fir::AddrOfOp>(loc, global.resultType(),
- global.getSymbol());
+ return fir::AddrOfOp::create(builder, loc, global.resultType(),
+ global.getSymbol());
}
/// Convert an evaluate::Constant<T> array into an fir::ExtendedValue.
diff --git a/flang/lib/Lower/ConvertExpr.cpp b/flang/lib/Lower/ConvertExpr.cpp
index 281ab229d1b6a..3578f941ec1b4 100644
--- a/flang/lib/Lower/ConvertExpr.cpp
+++ b/flang/lib/Lower/ConvertExpr.cpp
@@ -267,8 +267,8 @@ static mlir::Value genActualIsPresentTest(fir::FirOpBuilder &builder,
// Optional case (not that optional allocatable/pointer cannot be absent
// when passed to CMPLX as per 15.5.2.12 point 3 (7) and (8)). It is
// therefore possible to catch them in the `then` case above.
- return builder.create<fir::IsPresentOp>(loc, builder.getI1Type(),
- fir::getBase(actual));
+ return fir::IsPresentOp::create(builder, loc, builder.getI1Type(),
+ fir::getBase(actual));
}
/// Convert the array_load, `load`, to an extended value. If `path` is not
@@ -345,8 +345,8 @@ arrayLoadExtValue(fir::FirOpBuilder &builder, mlir::Location loc,
auto origins = fir::factory::getNonDefaultLowerBounds(builder, loc, exv);
if (shapeVal) {
// shapeVal is a ShiftOp and load.memref() is a boxed value.
- newBase = builder.create<fir::ReboxOp>(loc, oldBox.getType(), oldBox,
- shapeVal, /*slice=*/mlir::Value{});
+ newBase = fir::ReboxOp::create(builder, loc, oldBox.getType(), oldBox,
+ shapeVal, /*slice=*/mlir::Value{});
origins = fir::factory::getOrigins(shapeVal);
}
return fir::substBase(arrayToExtendedValue(extents, origins), newBase);
@@ -378,7 +378,7 @@ placeScalarValueInMemory(fir::FirOpBuilder &builder, mlir::Location loc,
mlir::Value temp = builder.createTemporary(
loc, storageType,
llvm::ArrayRef<mlir::NamedAttribute>{fir::getAdaptToByRefAttr(builder)});
- builder.create<fir::StoreOp>(loc, val, temp);
+ fir::StoreOp::create(builder, loc, val, temp);
return fir::substBase(exv, temp);
}
@@ -434,14 +434,14 @@ static fir::ExtendedValue genLoad(fir::FirOpBuilder &builder,
if (mlir::isa<fir::RecordType>(
fir::unwrapRefType(fir::getBase(p).getType())))
return p;
- mlir::Value load = builder.create<fir::LoadOp>(loc, fir::getBase(p));
+ mlir::Value load = fir::LoadOp::create(builder, loc, fir::getBase(p));
return fir::PolymorphicValue(load, p.getSourceBox());
},
[&](const fir::UnboxedValue &v) -> fir::ExtendedValue {
if (mlir::isa<fir::RecordType>(
fir::unwrapRefType(fir::getBase(v).getType())))
return v;
- return builder.create<fir::LoadOp>(loc, fir::getBase(v));
+ return fir::LoadOp::create(builder, loc, fir::getBase(v));
},
[&](const fir::MutableBoxValue &box) -> fir::ExtendedValue {
return genLoad(builder, loc,
@@ -473,11 +473,11 @@ static fir::ExtendedValue genOptionalValue(fir::FirOpBuilder &builder,
/*withElseRegion=*/true)
.genThen([&]() {
mlir::Value val = fir::getBase(genLoad(builder, loc, exv));
- builder.create<fir::ResultOp>(loc, val);
+ fir::ResultOp::create(builder, loc, val);
})
.genElse([&]() {
mlir::Value zero = fir::factory::createZeroValue(builder, loc, eleType);
- builder.create<fir::ResultOp>(loc, zero);
+ fir::ResultOp::create(builder, loc, zero);
})
.getResults()[0];
}
@@ -521,9 +521,9 @@ static fir::ExtendedValue genOptionalBox(fir::FirOpBuilder &builder,
// ensures it won't be.
mlir::Value box = builder.createBox(loc, newExv);
mlir::Type boxType = box.getType();
- auto absent = builder.create<fir::AbsentOp>(loc, boxType);
- auto boxOrAbsent = builder.create<mlir::arith::SelectOp>(
- loc, boxType, isPresent, box, absent);
+ auto absent = fir::AbsentOp::create(builder, loc, boxType);
+ auto boxOrAbsent = mlir::arith::SelectOp::create(builder, loc, boxType,
+ isPresent, box, absent);
return fir::BoxValue(boxOrAbsent);
}
@@ -569,13 +569,13 @@ createBoxProcCharTuple(Fortran::lower::AbstractConverter &converter,
if (fir::isa_ref_type(fromTy))
funcAddr = builder.createConvert(loc, toTy, funcAddr);
else if (mlir::isa<fir::BoxProcType>(fromTy))
- funcAddr = builder.create<fir::BoxAddrOp>(loc, toTy, funcAddr);
+ funcAddr = fir::BoxAddrOp::create(builder, loc, toTy, funcAddr);
auto boxProc = [&]() -> mlir::Value {
if (auto host = Fortran::lower::argumentHostAssocs(converter, funcAddr))
- return builder.create<fir::EmboxProcOp>(
- loc, boxTy, llvm::ArrayRef<mlir::Value>{funcAddr, host});
- return builder.create<fir::EmboxProcOp>(loc, boxTy, funcAddr);
+ return fir::EmboxProcOp::create(
+ builder, loc, boxTy, llvm::ArrayRef<mlir::Value>{funcAddr, host});
+ return fir::EmboxProcOp::create(builder, loc, boxTy, funcAddr);
}();
return fir::factory::createCharacterProcedureTuple(builder, loc, argTy,
boxProc, charLen);
@@ -598,7 +598,7 @@ absentBoxToUnallocatedBox(fir::FirOpBuilder &builder, mlir::Location loc,
mlir::Value emptyBox =
fir::factory::createUnallocatedBox(builder, loc, boxType, {});
auto safeToReadBox =
- builder.create<mlir::arith::SelectOp>(loc, isPresent, box, emptyBox);
+ mlir::arith::SelectOp::create(builder, loc, isPresent, box, emptyBox);
return fir::substBase(exv, safeToReadBox);
}
@@ -822,9 +822,9 @@ class ScalarExprLowering {
Fortran::common::TypeCategory::Integer, *unsignedKind);
mlir::Value lhsSL = builder.createConvert(loc, signlessType, *lhs);
mlir::Value rhsSL = builder.createConvert(loc, signlessType, *rhs);
- return builder.create<OpTy>(loc, pred, lhsSL, rhsSL);
+ return OpTy::create(builder, loc, pred, lhsSL, rhsSL);
}
- return builder.create<OpTy>(loc, pred, *lhs, *rhs);
+ return OpTy::create(builder, loc, pred, *lhs, *rhs);
}
}
fir::emitFatalError(getLoc(), "array compare should be handled in genarr");
@@ -841,7 +841,7 @@ class ScalarExprLowering {
const ExtValue &left, const ExtValue &right) {
if (const fir::UnboxedValue *lhs = left.getUnboxed())
if (const fir::UnboxedValue *rhs = right.getUnboxed())
- return builder.create<OpTy>(getLoc(), pred, *lhs, *rhs);
+ return OpTy::create(builder, getLoc(), pred, *lhs, *rhs);
fir::emitFatalError(getLoc(), "array compare should be handled in genarr");
}
template <typename OpTy, typename A>
@@ -904,7 +904,7 @@ class ScalarExprLowering {
mlir::Value cnvrt = Fortran::lower::addCrayPointerInst(
loc, builder, ptrVal, ptrTy, pteVal.getType());
- addr = builder.create<fir::LoadOp>(loc, cnvrt);
+ addr = fir::LoadOp::create(builder, loc, cnvrt);
}
return genLoad(addr);
}
@@ -970,12 +970,12 @@ class ScalarExprLowering {
std::string name = converter.getRecordTypeFieldName(sym);
// FIXME: type parameters must come from the derived-type-spec
- mlir::Value field = builder.create<fir::FieldIndexOp>(
- loc, fieldTy, name, ty,
- /*typeParams=*/mlir::ValueRange{} /*TODO*/);
+ mlir::Value field =
+ fir::FieldIndexOp::create(builder, loc, fieldTy, name, ty,
+ /*typeParams=*/mlir::ValueRange{} /*TODO*/);
mlir::Type coorTy = builder.getRefType(recTy.getType(name));
- auto coor = builder.create<fir::CoordinateOp>(loc, coorTy,
- fir::getBase(res), field);
+ auto coor = fir::CoordinateOp::create(builder, loc, coorTy,
+ fir::getBase(res), field);
ExtValue to = fir::factory::componentToExtendedValue(builder, loc, coor);
to.match(
[&](const fir::UnboxedValue &toPtr) {
@@ -1077,7 +1077,7 @@ class ScalarExprLowering {
mlir::Value input = genunbox(op.left());
// Like LLVM, integer negation is the binary op "0 - value"
mlir::Value zero = genIntegerConstant<KIND>(builder.getContext(), 0);
- return builder.create<mlir::arith::SubIOp>(getLoc(), zero, input);
+ return mlir::arith::SubIOp::create(builder, getLoc(), zero, input);
}
template <int KIND>
ExtValue genval(const Fortran::evaluate::Negate<Fortran::evaluate::Type<
@@ -1088,18 +1088,18 @@ class ScalarExprLowering {
mlir::Value input = genunbox(op.left());
mlir::Value signless = builder.createConvert(loc, signlessType, input);
mlir::Value zero = genIntegerConstant<KIND>(builder.getContext(), 0);
- mlir::Value neg = builder.create<mlir::arith::SubIOp>(loc, zero, signless);
+ mlir::Value neg = mlir::arith::SubIOp::create(builder, loc, zero, signless);
return builder.createConvert(loc, input.getType(), neg);
}
template <int KIND>
ExtValue genval(const Fortran::evaluate::Negate<Fortran::evaluate::Type<
Fortran::common::TypeCategory::Real, KIND>> &op) {
- return builder.create<mlir::arith::NegFOp>(getLoc(), genunbox(op.left()));
+ return mlir::arith::NegFOp::create(builder, getLoc(), genunbox(op.left()));
}
template <int KIND>
ExtValue genval(const Fortran::evaluate::Negate<Fortran::evaluate::Type<
Fortran::common::TypeCategory::Complex, KIND>> &op) {
- return builder.create<fir::NegcOp>(getLoc(), genunbox(op.left()));
+ return fir::NegcOp::create(builder, getLoc(), genunbox(op.left()));
}
template <typename OpTy>
@@ -1312,7 +1312,7 @@ class ScalarExprLowering {
ExtValue input = genval(op.left());
mlir::Value base = fir::getBase(input);
mlir::Value newBase =
- builder.create<fir::NoReassocOp>(getLoc(), base.getType(), base);
+ fir::NoReassocOp::create(builder, getLoc(), base.getType(), base);
return fir::substBase(input, newBase);
}
@@ -1322,7 +1322,7 @@ class ScalarExprLowering {
mlir::Value one = genBoolConstant(true);
mlir::Value val =
builder.createConvert(getLoc(), builder.getI1Type(), logical);
- return builder.create<mlir::arith::XOrIOp>(getLoc(), val, one);
+ return mlir::arith::XOrIOp::create(builder, getLoc(), val, one);
}
template <int KIND>
@@ -1384,8 +1384,9 @@ class ScalarExprLowering {
mlir::Value offset = builder.createIntegerConstant(
loc, idxTy,
x.part() == Fortran::evaluate::ComplexPart::Part::RE ? 0 : 1);
- mlir::Value result = builder.create<fir::CoordinateOp>(
- loc, builder.getRefType(eleTy), base, mlir::ValueRange{offset});
+ mlir::Value result =
+ fir::CoordinateOp::create(builder, loc, builder.getRefType(eleTy), base,
+ mlir::ValueRange{offset});
return {result};
}
ExtValue genval(const Fortran::evaluate::ComplexPart &x) {
@@ -1500,8 +1501,8 @@ class ScalarExprLowering {
auto recTy = mlir::cast<fir::RecordType>(ty);
const Fortran::semantics::Symbol &sym = getLastSym(*field);
std::string name = converter.getRecordTypeFieldName(sym);
- coorArgs.push_back(builder.create<fir::FieldIndexOp>(
- loc, fldTy, name, recTy, fir::getTypeParams(obj)));
+ coorArgs.push_back(fir::FieldIndexOp::create(
+ builder, loc, fldTy, name, recTy, fir::getTypeParams(obj)));
ty = recTy.getType(name);
}
// If parent component is referred then it has no coordinate argument.
@@ -1510,8 +1511,8 @@ class ScalarExprLowering {
ty = builder.getRefType(ty);
return fir::factory::componentToExtendedValue(
builder, loc,
- builder.create<fir::CoordinateOp>(loc, ty, fir::getBase(obj),
- coorArgs));
+ fir::CoordinateOp::create(builder, loc, ty, fir::getBase(obj),
+ coorArgs));
}
ExtValue gen(const Fortran::evaluate::Component &cmpt) {
@@ -1587,7 +1588,7 @@ class ScalarExprLowering {
mlir::Value val = fir::getBase(subVal);
mlir::Type ty = val.getType();
mlir::Value lb = getLBound(array, subsc.index(), ty);
- args.push_back(builder.create<mlir::arith::SubIOp>(loc, ty, val, lb));
+ args.push_back(mlir::arith::SubIOp::create(builder, loc, ty, val, lb));
}
mlir::Value base = fir::getBase(array);
@@ -1602,7 +1603,7 @@ class ScalarExprLowering {
mlir::Value cnvrt = Fortran::lower::addCrayPointerInst(
loc, builder, ptrVal, ptrTy, base.getType());
- base = builder.create<fir::LoadOp>(loc, cnvrt);
+ base = fir::LoadOp::create(builder, loc, cnvrt);
}
mlir::Type eleTy = fir::dyn_cast_ptrOrBoxEleTy(base.getType());
@@ -1611,7 +1612,7 @@ class ScalarExprLowering {
auto seqTy = mlir::cast<fir::SequenceType>(eleTy);
assert(args.size() == seqTy.getDimension());
mlir::Type ty = builder.getRefType(seqTy.getEleTy());
- auto addr = builder.create<fir::CoordinateOp>(loc, ty, base, args);
+ auto addr = fir::CoordinateOp::create(builder, loc, ty, base, args);
return fir::factory::arrayElementToExtendedValue(builder, loc, array, addr);
}
@@ -1648,12 +1649,12 @@ class ScalarExprLowering {
mlir::Value val =
builder.createConvert(loc, idxTy, fir::getBase(subVal));
mlir::Value lb = builder.createConvert(loc, idxTy, getLB(arr, dim));
- mlir::Value
diff = builder.create<mlir::arith::SubIOp>(loc, val, lb);
+ mlir::Value
diff = mlir::arith::SubIOp::create(builder, loc, val, lb);
mlir::Value prod =
- builder.create<mlir::arith::MulIOp>(loc, delta,
diff );
- total = builder.create<mlir::arith::AddIOp>(loc, prod, total);
+ mlir::arith::MulIOp::create(builder, loc, delta,
diff );
+ total = mlir::arith::AddIOp::create(builder, loc, prod, total);
if (ext)
- delta = builder.create<mlir::arith::MulIOp>(loc, delta, ext);
+ delta = mlir::arith::MulIOp::create(builder, loc, delta, ext);
++dim;
}
mlir::Type origRefTy = refTy;
@@ -1672,8 +1673,8 @@ class ScalarExprLowering {
base = builder.createConvert(loc, seqRefTy, base);
}
}
- auto coor = builder.create<fir::CoordinateOp>(
- loc, refTy, base, llvm::ArrayRef<mlir::Value>{total});
+ auto coor = fir::CoordinateOp::create(builder, loc, refTy, base,
+ llvm::ArrayRef<mlir::Value>{total});
// Convert to expected, original type after address arithmetic.
return builder.createConvert(loc, origRefTy, coor);
};
@@ -1725,9 +1726,9 @@ class ScalarExprLowering {
builder.createConvert(loc, idxTy, fir::getBase(subVal)));
}
mlir::Value shape = builder.createShape(loc, exv);
- mlir::Value elementAddr = builder.create<fir::ArrayCoorOp>(
- loc, refTy, addr, shape, /*slice=*/mlir::Value{}, arrayCoorArgs,
- fir::getTypeParams(exv));
+ mlir::Value elementAddr = fir::ArrayCoorOp::create(
+ builder, loc, refTy, addr, shape, /*slice=*/mlir::Value{},
+ arrayCoorArgs, fir::getTypeParams(exv));
return fir::factory::arrayElementToExtendedValue(builder, loc, exv,
elementAddr);
}
@@ -1826,8 +1827,8 @@ class ScalarExprLowering {
if (mlir::isa<mlir::FunctionType>(exvTy)) {
auto boxProcTy =
builder.getBoxProcType(mlir::cast<mlir::FunctionType>(exvTy));
- return builder.create<fir::EmboxProcOp>(loc, boxProcTy,
- fir::getBase(exv));
+ return fir::EmboxProcOp::create(builder, loc, boxProcTy,
+ fir::getBase(exv));
}
mlir::Value box = builder.createBox(loc, exv, exv.isPolymorphic());
if (Fortran::lower::isParentComponent(expr)) {
@@ -2073,8 +2074,8 @@ class ScalarExprLowering {
TODO(loc, "creating temporary for derived type with length parameters");
}
- mlir::Value temp = builder.create<fir::AllocMemOp>(
- loc, type, tempName, allocMemTypeParams, extents);
+ mlir::Value temp = fir::AllocMemOp::create(builder, loc, type, tempName,
+ allocMemTypeParams, extents);
if (mlir::isa<fir::CharacterType>(fir::unwrapSequenceType(type)))
return fir::CharArrayBoxValue{temp, charLen, extents};
return fir::ArrayBoxValue{temp, extents};
@@ -2124,9 +2125,9 @@ class ScalarExprLowering {
mlir::Type type = v.getType();
mlir::Value value = v;
if (fir::isa_ref_type(type))
- value = builder.create<fir::LoadOp>(loc, value);
+ value = fir::LoadOp::create(builder, loc, value);
mlir::Value temp = builder.createTemporary(loc, value.getType());
- builder.create<fir::StoreOp>(loc, value, temp);
+ fir::StoreOp::create(builder, loc, value, temp);
return temp;
},
[&](const fir::BoxValue &x) -> ExtValue {
@@ -2141,9 +2142,9 @@ class ScalarExprLowering {
// created always has the declared type.
mlir::Value var =
fir::getBase(fir::factory::readBoxValue(builder, loc, x));
- auto value = builder.create<fir::LoadOp>(loc, var);
+ auto value = fir::LoadOp::create(builder, loc, var);
mlir::Value temp = builder.createTemporary(loc, value.getType());
- builder.create<fir::StoreOp>(loc, value, temp);
+ fir::StoreOp::create(builder, loc, value, temp);
return temp;
},
[&](const fir::PolymorphicValue &p) -> ExtValue {
@@ -2242,7 +2243,7 @@ class ScalarExprLowering {
// at this point.
mlir::Value destBox = fir::getBase(builder.createBox(loc, temp));
mlir::Value boxRef = builder.createTemporary(loc, destBox.getType());
- builder.create<fir::StoreOp>(loc, destBox, boxRef);
+ fir::StoreOp::create(builder, loc, destBox, boxRef);
fir::runtime::genAssignTemporary(builder, loc, boxRef,
fir::getBase(actualArg));
return temp;
@@ -2250,21 +2251,22 @@ class ScalarExprLowering {
auto noCopy = [&]() {
mlir::Value box = fir::getBase(actualArg);
- mlir::Value boxAddr = builder.create<fir::BoxAddrOp>(loc, addrType, box);
- builder.create<fir::ResultOp>(loc, boxAddr);
+ mlir::Value boxAddr = fir::BoxAddrOp::create(builder, loc, addrType, box);
+ fir::ResultOp::create(builder, loc, boxAddr);
};
auto combinedCondition = [&]() {
if (isActualArgBox) {
mlir::Value zero =
builder.createIntegerConstant(loc, builder.getI1Type(), 0);
- mlir::Value notContiguous = builder.create<mlir::arith::CmpIOp>(
- loc, mlir::arith::CmpIPredicate::eq, isContiguousResult, zero);
+ mlir::Value notContiguous = mlir::arith::CmpIOp::create(
+ builder, loc, mlir::arith::CmpIPredicate::eq, isContiguousResult,
+ zero);
if (!restrictCopyAtRuntime) {
restrictCopyAtRuntime = notContiguous;
} else {
- mlir::Value cond = builder.create<mlir::arith::AndIOp>(
- loc, *restrictCopyAtRuntime, notContiguous);
+ mlir::Value cond = mlir::arith::AndIOp::create(
+ builder, loc, *restrictCopyAtRuntime, notContiguous);
restrictCopyAtRuntime = cond;
}
}
@@ -2280,7 +2282,7 @@ class ScalarExprLowering {
.genThen([&]() { noCopy(); })
.genElse([&] {
ExtValue temp = doCopyIn();
- builder.create<fir::ResultOp>(loc, fir::getBase(temp));
+ fir::ResultOp::create(builder, loc, fir::getBase(temp));
})
.getResults()[0];
fir::ExtendedValue temp =
@@ -2312,19 +2314,19 @@ class ScalarExprLowering {
.genThen([&]() { noCopy(); })
.genElse([&]() {
ExtValue temp = doCopyIn();
- builder.create<fir::ResultOp>(loc,
- fir::getBase(temp));
+ fir::ResultOp::create(builder, loc,
+ fir::getBase(temp));
})
.getResults()[0];
- builder.create<fir::ResultOp>(loc, addr1);
+ fir::ResultOp::create(builder, loc, addr1);
} else {
ExtValue temp = doCopyIn();
- builder.create<fir::ResultOp>(loc, fir::getBase(temp));
+ fir::ResultOp::create(builder, loc, fir::getBase(temp));
}
})
.genElse([&]() {
mlir::Value nullPtr = builder.createNullConstant(loc, addrType);
- builder.create<fir::ResultOp>(loc, nullPtr);
+ fir::ResultOp::create(builder, loc, nullPtr);
})
.getResults()[0];
// Associate the temp address with actualArg lengths and extents if a
@@ -2357,7 +2359,7 @@ class ScalarExprLowering {
tempBox);
}
// Deallocate the top-level entity of the temporary.
- builder.create<fir::FreeMemOp>(loc, fir::getBase(copyOutPair.temp));
+ fir::FreeMemOp::create(builder, loc, fir::getBase(copyOutPair.temp));
return;
}
// Generate CopyOutAssign() call to copy data from the temporary
@@ -2376,11 +2378,11 @@ class ScalarExprLowering {
mlir::Type allocBoxTy =
mlir::cast<fir::BaseBoxType>(srcBox.getType())
.getBoxTypeWithNewAttr(fir::BaseBoxType::Attribute::Allocatable);
- srcBox = builder.create<fir::ReboxOp>(loc, allocBoxTy, srcBox,
- /*shift=*/mlir::Value{},
- /*slice=*/mlir::Value{});
+ srcBox = fir::ReboxOp::create(builder, loc, allocBoxTy, srcBox,
+ /*shift=*/mlir::Value{},
+ /*slice=*/mlir::Value{});
mlir::Value srcBoxRef = builder.createTemporary(loc, srcBox.getType());
- builder.create<fir::StoreOp>(loc, srcBox, srcBoxRef);
+ fir::StoreOp::create(builder, loc, srcBox, srcBoxRef);
// Create descriptor pointer to variable descriptor if copy out is needed,
// and nullptr otherwise.
mlir::Value destBoxRef;
@@ -2388,9 +2390,9 @@ class ScalarExprLowering {
mlir::Value destBox =
fir::getBase(builder.createBox(loc, copyOutPair.var));
destBoxRef = builder.createTemporary(loc, destBox.getType());
- builder.create<fir::StoreOp>(loc, destBox, destBoxRef);
+ fir::StoreOp::create(builder, loc, destBox, destBoxRef);
} else {
- destBoxRef = builder.create<fir::ZeroOp>(loc, srcBoxRef.getType());
+ destBoxRef = fir::ZeroOp::create(builder, loc, srcBoxRef.getType());
}
fir::runtime::genCopyOutAssign(builder, loc, destBoxRef, srcBoxRef);
};
@@ -2436,8 +2438,8 @@ class ScalarExprLowering {
// fir.box is absent.
ExtValue actualArg = gen(expr);
mlir::Value actualArgBase = fir::getBase(actualArg);
- mlir::Value isPresent = builder.create<fir::IsPresentOp>(
- loc, builder.getI1Type(), actualArgBase);
+ mlir::Value isPresent = fir::IsPresentOp::create(
+ builder, loc, builder.getI1Type(), actualArgBase);
if (!mlir::isa<fir::BoxType>(actualArgBase.getType()))
return {actualArg, isPresent};
ExtValue safeToReadBox =
@@ -2457,7 +2459,7 @@ class ScalarExprLowering {
if (const fir::CharBoxValue *charBox = actualArg.getCharBox()) {
mlir::Value len = charBox->getLen();
mlir::Value zero = builder.createIntegerConstant(loc, len.getType(), 0);
- len = builder.create<mlir::arith::SelectOp>(loc, isPresent, len, zero);
+ len = mlir::arith::SelectOp::create(builder, loc, isPresent, len, zero);
mlir::Value temp =
builder.createTemporary(loc, type, /*name=*/{},
/*shape=*/{}, mlir::ValueRange{len},
@@ -2538,12 +2540,12 @@ class ScalarExprLowering {
.genThen([&]() {
fir::factory::genScalarAssignment(builder, loc, temp,
actualArg);
- builder.create<fir::ResultOp>(loc, fir::getBase(temp));
+ fir::ResultOp::create(builder, loc, fir::getBase(temp));
})
.genElse([&]() {
mlir::Value absent =
- builder.create<fir::AbsentOp>(loc, tempAddrTy);
- builder.create<fir::ResultOp>(loc, absent);
+ fir::AbsentOp::create(builder, loc, tempAddrTy);
+ fir::ResultOp::create(builder, loc, absent);
})
.getResults()[0];
return {fir::substBase(temp, selectAddr), isPresent};
@@ -2647,7 +2649,7 @@ class ScalarExprLowering {
mlir::Value boxStorage = builder.createTemporary(loc, boxTy);
mlir::Value nullBox = fir::factory::createUnallocatedBox(
builder, loc, boxTy, /*nonDeferredParams=*/{});
- builder.create<fir::StoreOp>(loc, nullBox, boxStorage);
+ fir::StoreOp::create(builder, loc, nullBox, boxStorage);
caller.placeInput(arg, boxStorage);
continue;
}
@@ -2706,9 +2708,10 @@ class ScalarExprLowering {
mlir::cast<fir::BoxCharType>(funcTy.getResult(0));
mlir::Value ref = builder.createConvertWithVolatileCast(
loc, builder.getRefType(boxTy.getEleTy()), x.getAddr());
- auto len = builder.create<fir::UndefOp>(
- loc, builder.getCharacterLengthType());
- return builder.create<fir::EmboxCharOp>(loc, boxTy, ref, len);
+ auto len = fir::UndefOp::create(
+ builder, loc, builder.getCharacterLengthType());
+ return fir::EmboxCharOp::create(builder, loc, boxTy, ref,
+ len);
}
return helper.createEmbox(x);
},
@@ -2758,10 +2761,10 @@ class ScalarExprLowering {
mlir::Value box = builder.createBox(loc, argAddr);
if (isPresentValue) {
mlir::Value convertedBox = builder.createConvert(loc, argTy, box);
- auto absent = builder.create<fir::AbsentOp>(loc, argTy);
- caller.placeInput(arg,
- builder.create<mlir::arith::SelectOp>(
- loc, *isPresentValue, convertedBox, absent));
+ auto absent = fir::AbsentOp::create(builder, loc, argTy);
+ caller.placeInput(
+ arg, mlir::arith::SelectOp::create(
+ builder, loc, *isPresentValue, convertedBox, absent));
} else {
caller.placeInput(arg, builder.createBox(loc, argAddr));
}
@@ -2782,7 +2785,7 @@ class ScalarExprLowering {
mlir::Value isAllocated =
fir::factory::genIsAllocatedOrAssociatedTest(builder, loc,
mutableBox);
- auto absent = builder.create<fir::AbsentOp>(loc, argTy);
+ auto absent = fir::AbsentOp::create(builder, loc, argTy);
/// For now, assume it is not OK to pass the allocatable/pointer
/// descriptor to a non pointer/allocatable dummy. That is a strict
/// interpretation of 18.3.6 point 4 that stipulates the descriptor
@@ -2801,14 +2804,15 @@ class ScalarExprLowering {
box);
} else if (mlir::isa<fir::BoxType>(box.getType()) &&
fir::isPolymorphicType(argTy)) {
- box = builder.create<fir::ReboxOp>(loc, argTy, box, mlir::Value{},
- /*slice=*/mlir::Value{});
+ box = fir::ReboxOp::create(builder, loc, argTy, box, mlir::Value{},
+ /*slice=*/mlir::Value{});
}
// Need the box types to be exactly similar for the selectOp.
mlir::Value convertedBox = builder.createConvert(loc, argTy, box);
- caller.placeInput(arg, builder.create<mlir::arith::SelectOp>(
- loc, isAllocated, convertedBox, absent));
+ caller.placeInput(
+ arg, mlir::arith::SelectOp::create(builder, loc, isAllocated,
+ convertedBox, absent));
} else {
auto dynamicType = expr->GetType();
mlir::Value box;
@@ -2830,12 +2834,12 @@ class ScalarExprLowering {
.genThen([&]() {
auto boxed = builder.createBox(
loc, genBoxArg(*expr), fir::isPolymorphicType(argTy));
- builder.create<fir::ResultOp>(loc, boxed);
+ fir::ResultOp::create(builder, loc, boxed);
})
.genElse([&]() {
- auto absent =
- builder.create<fir::AbsentOp>(loc, argTy).getResult();
- builder.create<fir::ResultOp>(loc, absent);
+ auto absent = fir::AbsentOp::create(builder, loc, argTy)
+ .getResult();
+ fir::ResultOp::create(builder, loc, absent);
})
.getResults()[0];
} else {
@@ -2867,19 +2871,19 @@ class ScalarExprLowering {
loc, actualTy, box, mlir::Value{},
/*slice=*/mlir::Value{})
.getResult();
- builder.create<fir::ResultOp>(loc, rebox);
+ fir::ResultOp::create(builder, loc, rebox);
})
.genElse([&]() {
auto absent =
- builder.create<fir::AbsentOp>(loc, actualTy)
+ fir::AbsentOp::create(builder, loc, actualTy)
.getResult();
- builder.create<fir::ResultOp>(loc, absent);
+ fir::ResultOp::create(builder, loc, absent);
})
.getResults()[0];
} else {
- box = builder.create<fir::ReboxOp>(loc, actualTy, box,
- mlir::Value{},
- /*slice=*/mlir::Value{});
+ box = fir::ReboxOp::create(builder, loc, actualTy, box,
+ mlir::Value{},
+ /*slice=*/mlir::Value{});
}
} else if (Fortran::lower::isParentComponent(*expr)) {
fir::ExtendedValue newExv =
@@ -3132,12 +3136,12 @@ static void genScalarUserDefinedAssignmentCall(fir::FirOpBuilder &builder,
if (argBaseType != fir::unwrapRefType(from.getType())) {
// With logicals, it is possible that from is i1 here.
if (fir::isa_ref_type(from.getType()))
- from = builder.create<fir::LoadOp>(loc, from);
+ from = fir::LoadOp::create(builder, loc, from);
from = builder.createConvert(loc, argBaseType, from);
}
if (!fir::isa_ref_type(from.getType())) {
mlir::Value temp = builder.createTemporary(loc, argBaseType);
- builder.create<fir::StoreOp>(loc, from, temp);
+ fir::StoreOp::create(builder, loc, from, temp);
from = temp;
}
return builder.createConvert(loc, argType, from);
@@ -3147,7 +3151,7 @@ static void genScalarUserDefinedAssignmentCall(fir::FirOpBuilder &builder,
mlir::Type rhsType = func.getFunctionType().getInput(1);
mlir::Value lhsArg = prepareUserDefinedArg(builder, loc, lhs, lhsType);
mlir::Value rhsArg = prepareUserDefinedArg(builder, loc, rhs, rhsType);
- builder.create<fir::CallOp>(loc, func, mlir::ValueRange{lhsArg, rhsArg});
+ fir::CallOp::create(builder, loc, func, mlir::ValueRange{lhsArg, rhsArg});
}
/// Convert the result of a fir.array_modify to an ExtendedValue given the
@@ -3187,17 +3191,17 @@ createDerivedArrayAmend(mlir::Location loc, fir::ArrayLoadOp destLoad,
fir::factory::genRecordAssignment(builder, loc, destAcc, elementExv);
} else {
auto boxTy = fir::BoxType::get(eleTy);
- auto toBox = builder.create<fir::EmboxOp>(loc, boxTy, destAcc.getResult(),
- mlir::Value{}, mlir::Value{},
- destLoad.getTypeparams());
- auto fromBox = builder.create<fir::EmboxOp>(
- loc, boxTy, fir::getBase(elementExv), mlir::Value{}, mlir::Value{},
- destLoad.getTypeparams());
+ auto toBox = fir::EmboxOp::create(builder, loc, boxTy, destAcc.getResult(),
+ mlir::Value{}, mlir::Value{},
+ destLoad.getTypeparams());
+ auto fromBox = fir::EmboxOp::create(
+ builder, loc, boxTy, fir::getBase(elementExv), mlir::Value{},
+ mlir::Value{}, destLoad.getTypeparams());
fir::factory::genRecordAssignment(builder, loc, fir::BoxValue(toBox),
fir::BoxValue(fromBox));
}
- return builder.create<fir::ArrayAmendOp>(loc, innerArg.getType(), innerArg,
- destAcc);
+ return fir::ArrayAmendOp::create(builder, loc, innerArg.getType(), innerArg,
+ destAcc);
}
inline static fir::ArrayAmendOp
@@ -3219,7 +3223,7 @@ createCharArrayAmend(mlir::Location loc, fir::FirOpBuilder &builder,
helper.createAssign(fir::ExtendedValue{dstChar}, srcExv);
// Mark this array element as amended.
mlir::Type ty = innerArg.getType();
- auto amend = builder.create<fir::ArrayAmendOp>(loc, ty, innerArg, dstOp);
+ auto amend = fir::ArrayAmendOp::create(builder, loc, ty, innerArg, dstOp);
return amend;
}
@@ -3235,7 +3239,7 @@ convertToArrayBoxValue(mlir::Location loc, fir::FirOpBuilder &builder,
mlir::Type ty = fir::unwrapRefType(val.getType());
mlir::IndexType idxTy = builder.getIndexType();
auto seqTy = mlir::cast<fir::SequenceType>(ty);
- auto undef = builder.create<fir::UndefOp>(loc, idxTy);
+ auto undef = fir::UndefOp::create(builder, loc, idxTy);
llvm::SmallVector<mlir::Value> extents(seqTy.getDimension(), undef);
if (fir::isa_char(seqTy.getEleTy()))
return fir::CharArrayBoxValue(val, len ? len : undef, extents);
@@ -3315,10 +3319,10 @@ class ArrayExprLowering {
ExtValue exv = lowerArrayExpression(rhs);
if (explicitSpaceIsActive()) {
explicitSpace->finalizeContext();
- builder.create<fir::ResultOp>(loc, fir::getBase(exv));
+ fir::ResultOp::create(builder, loc, fir::getBase(exv));
} else {
- builder.create<fir::ArrayMergeStoreOp>(
- loc, destination, fir::getBase(exv), destination.getMemref(),
+ fir::ArrayMergeStoreOp::create(
+ builder, loc, destination, fir::getBase(exv), destination.getMemref(),
destination.getSlice(), destination.getTypeparams());
}
}
@@ -3432,8 +3436,8 @@ class ArrayExprLowering {
assert(destination && "destination must have been set");
ExtValue exv = lowerArrayExpression(rhsCC, destination.getType());
if (!explicitSpaceIsActive())
- builder.create<fir::ArrayMergeStoreOp>(
- loc, destination, fir::getBase(exv), destination.getMemref(),
+ fir::ArrayMergeStoreOp::create(
+ builder, loc, destination, fir::getBase(exv), destination.getMemref(),
destination.getSlice(), destination.getTypeparams());
// destShape may originally be null, if rhs did not define a shape.
// In this case the destShape is computed from lhs, and we may have
@@ -3502,7 +3506,7 @@ class ArrayExprLowering {
lengthParams, assignToStorage);
if (explicitSpaceIsActive()) {
explicitSpace->finalizeContext();
- builder.create<fir::ResultOp>(loc, fir::getBase(realloc.newValue));
+ fir::ResultOp::create(builder, loc, fir::getBase(realloc.newValue));
}
fir::factory::finalizeRealloc(builder, loc, mutableBox, lbounds,
takeLboundsIfRealloc, realloc);
@@ -3547,9 +3551,9 @@ class ArrayExprLowering {
mlir::Value tempRes = dest.getMemref();
fir::FirOpBuilder &builder = converter.getFirOpBuilder();
mlir::Location loc = converter.getCurrentLocation();
- builder.create<fir::ArrayMergeStoreOp>(loc, dest, fir::getBase(loopRes),
- tempRes, dest.getSlice(),
- dest.getTypeparams());
+ fir::ArrayMergeStoreOp::create(builder, loc, dest, fir::getBase(loopRes),
+ tempRes, dest.getSlice(),
+ dest.getTypeparams());
auto arrTy = mlir::cast<fir::SequenceType>(
fir::dyn_cast_ptrEleTy(tempRes.getType()));
@@ -3595,26 +3599,26 @@ class ArrayExprLowering {
// as there isn't any necessity for it.
ccLoadDest = [=](llvm::ArrayRef<mlir::Value> shape) -> fir::ArrayLoadOp {
mlir::Value one = builder.createIntegerConstant(loc, i32Ty, 1);
- auto var = builder.create<fir::CoordinateOp>(
- loc, builder.getRefType(hdrTy.getType(1)), header, one);
- auto load = builder.create<fir::LoadOp>(loc, var);
+ auto var = fir::CoordinateOp::create(
+ builder, loc, builder.getRefType(hdrTy.getType(1)), header, one);
+ auto load = fir::LoadOp::create(builder, loc, var);
mlir::Type eleTy =
fir::unwrapSequenceType(fir::unwrapRefType(load.getType()));
auto seqTy = fir::SequenceType::get(eleTy, shape.size());
mlir::Value castTo =
builder.createConvert(loc, fir::HeapType::get(seqTy), load);
mlir::Value shapeOp = builder.genShape(loc, shape);
- return builder.create<fir::ArrayLoadOp>(loc, seqTy, castTo, shapeOp,
- /*slice=*/mlir::Value{},
- mlir::ValueRange{});
+ return fir::ArrayLoadOp::create(builder, loc, seqTy, castTo, shapeOp,
+ /*slice=*/mlir::Value{},
+ mlir::ValueRange{});
};
// Custom lowering of the element store to deal with the extra indirection
// to the lazy allocated buffer.
ccStoreToDest = [=](IterSpace iters) {
mlir::Value one = builder.createIntegerConstant(loc, i32Ty, 1);
- auto var = builder.create<fir::CoordinateOp>(
- loc, builder.getRefType(hdrTy.getType(1)), header, one);
- auto load = builder.create<fir::LoadOp>(loc, var);
+ auto var = fir::CoordinateOp::create(
+ builder, loc, builder.getRefType(hdrTy.getType(1)), header, one);
+ auto load = fir::LoadOp::create(builder, loc, var);
mlir::Type eleTy =
fir::unwrapSequenceType(fir::unwrapRefType(load.getType()));
auto seqTy = fir::SequenceType::get(eleTy, iters.iterVec().size());
@@ -3623,12 +3627,12 @@ class ArrayExprLowering {
mlir::Value shape = builder.genShape(loc, genIterationShape());
llvm::SmallVector<mlir::Value> indices = fir::factory::originateIndices(
loc, builder, castTo.getType(), shape, iters.iterVec());
- auto eleAddr = builder.create<fir::ArrayCoorOp>(
- loc, builder.getRefType(eleTy), castTo, shape,
+ auto eleAddr = fir::ArrayCoorOp::create(
+ builder, loc, builder.getRefType(eleTy), castTo, shape,
/*slice=*/mlir::Value{}, indices, destination.getTypeparams());
mlir::Value eleVal =
builder.createConvert(loc, eleTy, iters.getElement());
- builder.create<fir::StoreOp>(loc, eleVal, eleAddr);
+ fir::StoreOp::create(builder, loc, eleVal, eleAddr);
return iters.innerArgument();
};
@@ -3684,10 +3688,10 @@ class ArrayExprLowering {
auto exv = lowerArrayExpression(rhs);
if (explicitSpaceIsActive()) {
explicitSpace->finalizeContext();
- builder.create<fir::ResultOp>(loc, fir::getBase(exv));
+ fir::ResultOp::create(builder, loc, fir::getBase(exv));
} else {
- builder.create<fir::ArrayMergeStoreOp>(
- loc, destination, fir::getBase(exv), destination.getMemref(),
+ fir::ArrayMergeStoreOp::create(
+ builder, loc, destination, fir::getBase(exv), destination.getMemref(),
destination.getSlice(), destination.getTypeparams());
}
}
@@ -3766,7 +3770,7 @@ class ArrayExprLowering {
std::size_t offset = explicitSpace->argPosition(oldInnerArg);
explicitSpace->setInnerArg(offset, fir::getBase(lexv));
finalizeElementCtx();
- builder.create<fir::ResultOp>(loc, fir::getBase(lexv));
+ fir::ResultOp::create(builder, loc, fir::getBase(lexv));
};
if (mlir::Operation *defOp = fir::getBase(lexv).getDefiningOp()) {
llvm::TypeSwitch<mlir::Operation *>(defOp)
@@ -3836,7 +3840,7 @@ class ArrayExprLowering {
// 5). Thread the array value updated forward.
if (!isIllFormedLHS) {
finalizeElementCtx();
- builder.create<fir::ResultOp>(getLoc(), fir::getBase(lexv));
+ fir::ResultOp::create(builder, getLoc(), fir::getBase(lexv));
}
return lexv;
}
@@ -3979,7 +3983,7 @@ class ArrayExprLowering {
if (auto origEleTy = fir::dyn_cast_ptrEleTy(origVal.getType()))
if (mlir::isa<fir::BaseBoxType>(origEleTy)) {
// If origVal is a box variable, load it so it is in the value domain.
- origVal = builder.create<fir::LoadOp>(loc, origVal);
+ origVal = fir::LoadOp::create(builder, loc, origVal);
}
if (mlir::isa<fir::BoxType>(origVal.getType()) &&
!mlir::isa<fir::BoxType>(eleTy)) {
@@ -3998,7 +4002,7 @@ class ArrayExprLowering {
TODO(loc, "TARGET of pointer assignment with runtime size/shape");
auto memrefTy = fir::boxMemRefType(mlir::cast<fir::BoxType>(eleTy));
auto castTo = builder.createConvert(loc, memrefTy, origVal);
- origVal = builder.create<fir::EmboxOp>(loc, eleTy, castTo);
+ origVal = fir::EmboxOp::create(builder, loc, eleTy, castTo);
}
mlir::Value val = builder.convertWithSemantics(loc, eleTy, origVal);
if (isBoundsSpec()) {
@@ -4007,9 +4011,9 @@ class ArrayExprLowering {
if (lbs.size() > 0) {
// Rebox the value with user-specified shift.
auto shiftTy = fir::ShiftType::get(eleTy.getContext(), lbs.size());
- mlir::Value shiftOp = builder.create<fir::ShiftOp>(loc, shiftTy, lbs);
- val = builder.create<fir::ReboxOp>(loc, eleTy, val, shiftOp,
- mlir::Value{});
+ mlir::Value shiftOp = fir::ShiftOp::create(builder, loc, shiftTy, lbs);
+ val = fir::ReboxOp::create(builder, loc, eleTy, val, shiftOp,
+ mlir::Value{});
}
} else if (isBoundsRemap()) {
assert(lbounds.has_value());
@@ -4020,9 +4024,9 @@ class ArrayExprLowering {
auto shapeShiftArgs = flatZip(lbs, *ubounds);
auto shapeTy = fir::ShapeShiftType::get(eleTy.getContext(), lbs.size());
mlir::Value shapeShift =
- builder.create<fir::ShapeShiftOp>(loc, shapeTy, shapeShiftArgs);
- val = builder.create<fir::ReboxOp>(loc, eleTy, val, shapeShift,
- mlir::Value{});
+ fir::ShapeShiftOp::create(builder, loc, shapeTy, shapeShiftArgs);
+ val = fir::ReboxOp::create(builder, loc, eleTy, val, shapeShift,
+ mlir::Value{});
}
}
return val;
@@ -4045,8 +4049,8 @@ class ArrayExprLowering {
// memory into the destination array.
mlir::Type resRefTy = builder.getRefType(eleTy);
// Get a reference to the array element to be amended.
- auto arrayOp = builder.create<fir::ArrayAccessOp>(
- loc, resRefTy, innerArg, iterSpace.iterVec(),
+ auto arrayOp = fir::ArrayAccessOp::create(
+ builder, loc, resRefTy, innerArg, iterSpace.iterVec(),
fir::factory::getTypeParams(loc, builder, destination));
if (auto charTy = mlir::dyn_cast<fir::CharacterType>(eleTy)) {
llvm::SmallVector<mlir::Value> substringBounds;
@@ -4067,9 +4071,9 @@ class ArrayExprLowering {
}
// By value semantics. The element is being assigned by value.
auto ele = convertElementForUpdate(loc, eleTy, fir::getBase(exv));
- auto update = builder.create<fir::ArrayUpdateOp>(
- loc, arrTy, innerArg, ele, iterSpace.iterVec(),
- destination.getTypeparams());
+ auto update = fir::ArrayUpdateOp::create(builder, loc, arrTy, innerArg,
+ ele, iterSpace.iterVec(),
+ destination.getTypeparams());
return abstractArrayExtValue(update);
};
}
@@ -4094,7 +4098,7 @@ class ArrayExprLowering {
: defaultStoreToDestination(/*substring=*/nullptr);
mlir::Value updVal = fir::getBase(lambda(iterSpace));
finalizeElementCtx();
- builder.create<fir::ResultOp>(loc, updVal);
+ fir::ResultOp::create(builder, loc, updVal);
builder.restoreInsertionPoint(insPt);
return abstractArrayExtValue(iterSpace.outerResult());
}
@@ -4247,31 +4251,34 @@ class ArrayExprLowering {
// Compute the dynamic position into the header.
llvm::SmallVector<mlir::Value> offsets;
for (auto doLoop : loopStack[i]) {
- auto m = builder.create<mlir::arith::SubIOp>(
- loc, doLoop.getInductionVar(), doLoop.getLowerBound());
- auto n = builder.create<mlir::arith::DivSIOp>(loc, m, doLoop.getStep());
+ auto m = mlir::arith::SubIOp::create(
+ builder, loc, doLoop.getInductionVar(), doLoop.getLowerBound());
+ auto n =
+ mlir::arith::DivSIOp::create(builder, loc, m, doLoop.getStep());
mlir::Value one = builder.createIntegerConstant(loc, n.getType(), 1);
- offsets.push_back(builder.create<mlir::arith::AddIOp>(loc, n, one));
+ offsets.push_back(mlir::arith::AddIOp::create(builder, loc, n, one));
}
mlir::IntegerType i32Ty = builder.getIntegerType(32);
mlir::Value uno = builder.createIntegerConstant(loc, i32Ty, 1);
mlir::Type coorTy = builder.getRefType(raggedTy.getType(1));
- auto hdOff = builder.create<fir::CoordinateOp>(loc, coorTy, header, uno);
+ auto hdOff = fir::CoordinateOp::create(builder, loc, coorTy, header, uno);
auto toTy = fir::SequenceType::get(raggedTy, offsets.size());
mlir::Type toRefTy = builder.getRefType(toTy);
- auto ldHdr = builder.create<fir::LoadOp>(loc, hdOff);
+ auto ldHdr = fir::LoadOp::create(builder, loc, hdOff);
mlir::Value hdArr = builder.createConvert(loc, toRefTy, ldHdr);
auto shapeOp = builder.genShape(loc, extents);
- header = builder.create<fir::ArrayCoorOp>(
- loc, builder.getRefType(raggedTy), hdArr, shapeOp,
+ header = fir::ArrayCoorOp::create(
+ builder, loc, builder.getRefType(raggedTy), hdArr, shapeOp,
/*slice=*/mlir::Value{}, offsets,
/*typeparams=*/mlir::ValueRange{});
- auto hdrVar = builder.create<fir::CoordinateOp>(loc, coorTy, header, uno);
- auto inVar = builder.create<fir::LoadOp>(loc, hdrVar);
+ auto hdrVar =
+ fir::CoordinateOp::create(builder, loc, coorTy, header, uno);
+ auto inVar = fir::LoadOp::create(builder, loc, hdrVar);
mlir::Value two = builder.createIntegerConstant(loc, i32Ty, 2);
mlir::Type coorTy2 = builder.getRefType(raggedTy.getType(2));
- auto hdrSh = builder.create<fir::CoordinateOp>(loc, coorTy2, header, two);
- auto shapePtr = builder.create<fir::LoadOp>(loc, hdrSh);
+ auto hdrSh =
+ fir::CoordinateOp::create(builder, loc, coorTy2, header, two);
+ auto shapePtr = fir::LoadOp::create(builder, loc, hdrSh);
// Replace the binding.
implicitSpace->rebind(expr, genMaskAccess(inVar, shapePtr));
if (i < depth - 1)
@@ -4301,7 +4308,7 @@ class ArrayExprLowering {
Fortran::lower::createLazyArrayTempValue(converter, *e, header,
symMap, stmtCtx);
// Close the explicit loops.
- builder.create<fir::ResultOp>(loc, explicitSpace->getInnerArgs());
+ fir::ResultOp::create(builder, loc, explicitSpace->getInnerArgs());
builder.setInsertionPointAfter(explicitSpace->getOuterLoop());
// Open a new copy of the explicit loop nest.
explicitSpace->genLoopNest();
@@ -4327,9 +4334,10 @@ class ArrayExprLowering {
fir::factory::getRaggedArrayHeaderType(builder);
mlir::IntegerType i32Ty = builder.getIntegerType(32);
mlir::Value one = builder.createIntegerConstant(loc, i32Ty, 1);
- auto coor1 = builder.create<fir::CoordinateOp>(
- loc, builder.getRefType(raggedTy.getType(1)), header, one);
- auto db = builder.create<fir::LoadOp>(loc, coor1);
+ auto coor1 = fir::CoordinateOp::create(
+ builder, loc, builder.getRefType(raggedTy.getType(1)), header,
+ one);
+ auto db = fir::LoadOp::create(builder, loc, coor1);
mlir::Type eleTy =
fir::unwrapSequenceType(fir::unwrapRefType(db.getType()));
mlir::Type buffTy =
@@ -4338,17 +4346,18 @@ class ArrayExprLowering {
mlir::Value buff = builder.createConvert(loc, buffTy, db);
mlir::Value two = builder.createIntegerConstant(loc, i32Ty, 2);
- auto coor2 = builder.create<fir::CoordinateOp>(
- loc, builder.getRefType(raggedTy.getType(2)), header, two);
- auto shBuff = builder.create<fir::LoadOp>(loc, coor2);
+ auto coor2 = fir::CoordinateOp::create(
+ builder, loc, builder.getRefType(raggedTy.getType(2)), header,
+ two);
+ auto shBuff = fir::LoadOp::create(builder, loc, coor2);
mlir::IntegerType i64Ty = builder.getIntegerType(64);
mlir::IndexType idxTy = builder.getIndexType();
llvm::SmallVector<mlir::Value> extents;
for (std::remove_const_t<decltype(rank)> i = 0; i < rank; ++i) {
mlir::Value off = builder.createIntegerConstant(loc, i32Ty, i);
- auto coor = builder.create<fir::CoordinateOp>(
- loc, builder.getRefType(i64Ty), shBuff, off);
- auto ldExt = builder.create<fir::LoadOp>(loc, coor);
+ auto coor = fir::CoordinateOp::create(
+ builder, loc, builder.getRefType(i64Ty), shBuff, off);
+ auto ldExt = fir::LoadOp::create(builder, loc, coor);
extents.push_back(builder.createConvert(loc, idxTy, ldExt));
}
if (destShape.empty())
@@ -4376,7 +4385,7 @@ class ArrayExprLowering {
// run from 0 to `extent - 1` inclusive.
for (auto extent : shape)
loopUppers.push_back(
- builder.create<mlir::arith::SubIOp>(loc, extent, one));
+ mlir::arith::SubIOp::create(builder, loc, extent, one));
// Iteration space is created with outermost columns, innermost rows
llvm::SmallVector<fir::DoLoopOp> loops;
@@ -4391,16 +4400,16 @@ class ArrayExprLowering {
}
fir::DoLoopOp loop;
if (innerArg) {
- loop = builder.create<fir::DoLoopOp>(
- loc, zero, i.value(), one, isUnordered(),
+ loop = fir::DoLoopOp::create(
+ builder, loc, zero, i.value(), one, isUnordered(),
/*finalCount=*/false, mlir::ValueRange{innerArg});
innerArg = loop.getRegionIterArgs().front();
if (explicitSpaceIsActive())
explicitSpace->setInnerArg(0, innerArg);
} else {
- loop = builder.create<fir::DoLoopOp>(loc, zero, i.value(), one,
- isUnordered(),
- /*finalCount=*/false);
+ loop = fir::DoLoopOp::create(builder, loc, zero, i.value(), one,
+ isUnordered(),
+ /*finalCount=*/false);
}
ivars.push_back(loop.getInductionVar());
loops.push_back(loop);
@@ -4410,7 +4419,7 @@ class ArrayExprLowering {
for (std::remove_const_t<decltype(loopDepth)> i = 0; i + 1 < loopDepth;
++i) {
builder.setInsertionPointToEnd(loops[i].getBody());
- builder.create<fir::ResultOp>(loc, loops[i + 1].getResult(0));
+ fir::ResultOp::create(builder, loc, loops[i + 1].getResult(0));
}
// Move insertion point to the start of the innermost loop in the nest.
@@ -4468,21 +4477,23 @@ class ArrayExprLowering {
implicitSpace->getMasks()) {
const std::size_t size = maskExprs.size() - 1;
auto genFalseBlock = [&](const auto *e, auto &&cond) {
- auto ifOp = builder.create<fir::IfOp>(
- loc, mlir::TypeRange{innerArg.getType()}, fir::getBase(cond),
- /*withElseRegion=*/true);
- builder.create<fir::ResultOp>(loc, ifOp.getResult(0));
+ auto ifOp = fir::IfOp::create(builder, loc,
+ mlir::TypeRange{innerArg.getType()},
+ fir::getBase(cond),
+ /*withElseRegion=*/true);
+ fir::ResultOp::create(builder, loc, ifOp.getResult(0));
builder.setInsertionPointToStart(&ifOp.getThenRegion().front());
- builder.create<fir::ResultOp>(loc, innerArg);
+ fir::ResultOp::create(builder, loc, innerArg);
builder.setInsertionPointToStart(&ifOp.getElseRegion().front());
};
auto genTrueBlock = [&](const auto *e, auto &&cond) {
- auto ifOp = builder.create<fir::IfOp>(
- loc, mlir::TypeRange{innerArg.getType()}, fir::getBase(cond),
- /*withElseRegion=*/true);
- builder.create<fir::ResultOp>(loc, ifOp.getResult(0));
+ auto ifOp = fir::IfOp::create(builder, loc,
+ mlir::TypeRange{innerArg.getType()},
+ fir::getBase(cond),
+ /*withElseRegion=*/true);
+ fir::ResultOp::create(builder, loc, ifOp.getResult(0));
builder.setInsertionPointToStart(&ifOp.getElseRegion().front());
- builder.create<fir::ResultOp>(loc, innerArg);
+ fir::ResultOp::create(builder, loc, innerArg);
builder.setInsertionPointToStart(&ifOp.getThenRegion().front());
};
for (std::remove_const_t<decltype(size)> i = 0; i < size; ++i)
@@ -4525,16 +4536,16 @@ class ArrayExprLowering {
"allocatable members");
mlir::Value temp =
!seqTy.hasDynamicExtents()
- ? builder.create<fir::AllocMemOp>(loc, type)
- : builder.create<fir::AllocMemOp>(loc, type, ".array.expr",
- mlir::ValueRange{}, shape);
+ ? fir::AllocMemOp::create(builder, loc, type)
+ : fir::AllocMemOp::create(builder, loc, type, ".array.expr",
+ mlir::ValueRange{}, shape);
fir::FirOpBuilder *bldr = &converter.getFirOpBuilder();
stmtCtx.attachCleanup(
[bldr, loc, temp]() { bldr->create<fir::FreeMemOp>(loc, temp); });
mlir::Value shapeOp = genShapeOp(shape);
- return builder.create<fir::ArrayLoadOp>(loc, seqTy, temp, shapeOp,
- /*slice=*/mlir::Value{},
- mlir::ValueRange{});
+ return fir::ArrayLoadOp::create(builder, loc, seqTy, temp, shapeOp,
+ /*slice=*/mlir::Value{},
+ mlir::ValueRange{});
}
static fir::ShapeOp genShapeOp(mlir::Location loc, fir::FirOpBuilder &builder,
@@ -4543,7 +4554,7 @@ class ArrayExprLowering {
llvm::SmallVector<mlir::Value> idxShape;
for (auto s : shape)
idxShape.push_back(builder.createConvert(loc, idxTy, s));
- return builder.create<fir::ShapeOp>(loc, idxShape);
+ return fir::ShapeOp::create(builder, loc, idxShape);
}
fir::ShapeOp genShapeOp(llvm::ArrayRef<mlir::Value> shape) {
@@ -4791,7 +4802,7 @@ class ArrayExprLowering {
mlir::Type argTy = callSiteType.getInput(arg.firArgument);
if (!actual) {
// Optional dummy argument for which there is no actual argument.
- auto absent = builder.create<fir::AbsentOp>(loc, argTy);
+ auto absent = fir::AbsentOp::create(builder, loc, argTy);
operands.emplace_back([=](IterSpace) { return absent; });
continue;
}
@@ -4824,7 +4835,7 @@ class ArrayExprLowering {
builder.createTemporary(loc, val.getType(),
llvm::ArrayRef<mlir::NamedAttribute>{
fir::getAdaptToByRefAttr(builder)});
- builder.create<fir::StoreOp>(loc, val, temp);
+ fir::StoreOp::create(builder, loc, val, temp);
operands.emplace_back(
[=](IterSpace iters) -> ExtValue { return temp; });
}
@@ -4883,14 +4894,14 @@ class ArrayExprLowering {
fir::dyn_cast_ptrOrBoxEleTy(fir::getBase(exv).getType());
mlir::Type innerTy = fir::unwrapSequenceType(baseTy);
operands.emplace_back([=](IterSpace iters) -> ExtValue {
- mlir::Value coord = builder.create<fir::CoordinateOp>(
- loc, fir::ReferenceType::get(innerTy), fir::getBase(exv),
- iters.iterVec());
+ mlir::Value coord = fir::CoordinateOp::create(
+ builder, loc, fir::ReferenceType::get(innerTy),
+ fir::getBase(exv), iters.iterVec());
mlir::Value empty;
mlir::ValueRange emptyRange;
- return builder.create<fir::EmboxOp>(
- loc, fir::ClassType::get(innerTy), coord, empty, empty,
- emptyRange, sourceBox);
+ return fir::EmboxOp::create(builder, loc,
+ fir::ClassType::get(innerTy), coord,
+ empty, empty, emptyRange, sourceBox);
});
} else {
ExtValue exv = asScalarRef(*expr);
@@ -4903,9 +4914,9 @@ class ArrayExprLowering {
operands.emplace_back([=](IterSpace iters) -> ExtValue {
mlir::Value empty;
mlir::ValueRange emptyRange;
- return builder.create<fir::EmboxOp>(
- loc, fir::ClassType::get(baseTy), fir::getBase(exv), empty,
- empty, emptyRange);
+ return fir::EmboxOp::create(
+ builder, loc, fir::ClassType::get(baseTy),
+ fir::getBase(exv), empty, empty, emptyRange);
});
}
}
@@ -5097,8 +5108,8 @@ class ArrayExprLowering {
return exv.match(
[&](const fir::CharBoxValue &cb) -> ExtValue {
mlir::Value len = cb.getLen();
- auto mem =
- builder.create<fir::AllocaOp>(loc, toType, mlir::ValueRange{len});
+ auto mem = fir::AllocaOp::create(builder, loc, toType,
+ mlir::ValueRange{len});
fir::CharBoxValue result(mem, len);
fir::factory::CharacterExprHelper{builder, loc}.createAssign(
ExtValue{result}, exv);
@@ -5153,7 +5164,7 @@ class ArrayExprLowering {
auto val = f(iters);
mlir::Value base = fir::getBase(val);
auto newBase =
- builder.create<fir::NoReassocOp>(loc, base.getType(), base);
+ fir::NoReassocOp::create(builder, loc, base.getType(), base);
return fir::substBase(val, newBase);
};
}
@@ -5170,10 +5181,10 @@ class ArrayExprLowering {
if constexpr (CAT == Fortran::common::TypeCategory::Unsigned) {
mlir::Value signless = builder.createConvert(loc, ty, val);
mlir::Value neg =
- builder.create<mlir::arith::SubIOp>(loc, zero, signless);
+ mlir::arith::SubIOp::create(builder, loc, zero, signless);
return builder.createConvert(loc, val.getType(), neg);
}
- return builder.create<mlir::arith::SubIOp>(loc, zero, val);
+ return mlir::arith::SubIOp::create(builder, loc, zero, val);
};
}
template <int KIND>
@@ -5192,7 +5203,7 @@ class ArrayExprLowering {
mlir::Location loc = getLoc();
auto f = genarr(x.left());
return [=](IterSpace iters) -> ExtValue {
- return builder.create<mlir::arith::NegFOp>(loc, fir::getBase(f(iters)));
+ return mlir::arith::NegFOp::create(builder, loc, fir::getBase(f(iters)));
};
}
template <int KIND>
@@ -5201,7 +5212,7 @@ class ArrayExprLowering {
mlir::Location loc = getLoc();
auto f = genarr(x.left());
return [=](IterSpace iters) -> ExtValue {
- return builder.create<fir::NegcOp>(loc, fir::getBase(f(iters)));
+ return fir::NegcOp::create(builder, loc, fir::getBase(f(iters)));
};
}
@@ -5426,8 +5437,8 @@ class ArrayExprLowering {
mlir::Location loc = getLoc();
mlir::Value lb = getLBound(x, dim, one);
mlir::Value extent = fir::factory::readExtent(builder, loc, x, dim);
- auto add = builder.create<mlir::arith::AddIOp>(loc, lb, extent);
- return builder.create<mlir::arith::SubIOp>(loc, add, one);
+ auto add = mlir::arith::AddIOp::create(builder, loc, lb, extent);
+ return mlir::arith::SubIOp::create(builder, loc, add, one);
}
/// Return the extent of the boxed array `x` in dimesion `dim`.
@@ -5469,11 +5480,11 @@ class ArrayExprLowering {
if (destShape[0] != savedDestShape[dim]) {
// Not the same, so choose the smaller value.
mlir::Location loc = getLoc();
- auto cmp = builder.create<mlir::arith::CmpIOp>(
- loc, mlir::arith::CmpIPredicate::sgt, destShape[0],
- savedDestShape[dim]);
- auto sel = builder.create<mlir::arith::SelectOp>(
- loc, cmp, savedDestShape[dim], destShape[0]);
+ auto cmp = mlir::arith::CmpIOp::create(builder, loc,
+ mlir::arith::CmpIPredicate::sgt,
+ destShape[0], savedDestShape[dim]);
+ auto sel = mlir::arith::SelectOp::create(
+ builder, loc, cmp, savedDestShape[dim], destShape[0]);
savedDestShape[dim] = sel;
destShape = savedDestShape;
}
@@ -5549,12 +5560,12 @@ class ArrayExprLowering {
// FIXME: must use the lower bound of this component.
auto arrLowerBound =
atBase ? getLBound(arrayExv, subsIndex, one) : one;
- auto initial = builder.create<mlir::arith::SubIOp>(
- loc, lowerBound, arrLowerBound);
- auto prod = builder.create<mlir::arith::MulIOp>(
- loc, impliedIter, stride);
- auto result =
- builder.create<mlir::arith::AddIOp>(loc, initial, prod);
+ auto initial = mlir::arith::SubIOp::create(
+ builder, loc, lowerBound, arrLowerBound);
+ auto prod = mlir::arith::MulIOp::create(
+ builder, loc, impliedIter, stride);
+ auto result = mlir::arith::AddIOp::create(builder, loc,
+ initial, prod);
newIters.setIndexValue(subsIndex, result);
return newIters;
};
@@ -5588,15 +5599,15 @@ class ArrayExprLowering {
// using the base array's lower bound value.
mlir::Value lb = fir::factory::readLowerBound(
builder, loc, arrayExv, subsIndex, one);
- auto origin = builder.create<mlir::arith::SubIOp>(
- loc, idxTy, val, lb);
+ auto origin = mlir::arith::SubIOp::create(builder, loc,
+ idxTy, val, lb);
newIters.setIndexValue(subsIndex, origin);
return newIters;
};
if (useTripsForSlice) {
LLVM_ATTRIBUTE_UNUSED auto vectorSubscriptShape =
getShape(arrayOperands.back());
- auto undef = builder.create<fir::UndefOp>(loc, idxTy);
+ auto undef = fir::UndefOp::create(builder, loc, idxTy);
trips.push_back(undef);
trips.push_back(undef);
trips.push_back(undef);
@@ -5614,7 +5625,7 @@ class ArrayExprLowering {
// the array's declared rank.
mlir::Value v = fir::getBase(asScalarArray(e));
trips.push_back(v);
- auto undef = builder.create<fir::UndefOp>(loc, idxTy);
+ auto undef = fir::UndefOp::create(builder, loc, idxTy);
trips.push_back(undef);
trips.push_back(undef);
auto currentPC = pc;
@@ -5623,8 +5634,8 @@ class ArrayExprLowering {
// Normalize `e` by subtracting the declared lbound.
mlir::Value lb = fir::factory::readLowerBound(
builder, loc, arrayExv, subsIndex, one);
- mlir::Value ivAdj =
- builder.create<mlir::arith::SubIOp>(loc, idxTy, iv, lb);
+ mlir::Value ivAdj = mlir::arith::SubIOp::create(
+ builder, loc, idxTy, iv, lb);
// Add lbound adjusted value of `e` to the iteration vector
// (except when creating a box because the iteration vector
// is empty).
@@ -5641,8 +5652,8 @@ class ArrayExprLowering {
builder.createConvert(loc, idxTy, newValue);
mlir::Value lb = fir::factory::readLowerBound(
builder, loc, arrayExv, subsIndex, one);
- result = builder.create<mlir::arith::SubIOp>(loc, idxTy,
- result, lb);
+ result = mlir::arith::SubIOp::create(builder, loc, idxTy,
+ result, lb);
pc = [=](IterSpace iters) {
IterationSpace newIters = currentPC(iters);
newIters.insertIndexValue(subsIndex, result);
@@ -5671,7 +5682,7 @@ class ArrayExprLowering {
auto seqType = mlir::cast<fir::SequenceType>(ty);
for (auto extent : seqType.getShape()) {
auto v = extent == fir::SequenceType::getUnknownExtent()
- ? builder.create<fir::UndefOp>(loc, idxTy).getResult()
+ ? fir::UndefOp::create(builder, loc, idxTy).getResult()
: builder.createIntegerConstant(loc, idxTy, extent);
result.push_back(v);
}
@@ -5764,20 +5775,20 @@ class ArrayExprLowering {
mlir::Value one =
builder.createIntegerConstant(loc, substringBounds[0].getType(), 1);
substringBounds[0] =
- builder.create<mlir::arith::SubIOp>(loc, substringBounds[0], one);
+ mlir::arith::SubIOp::create(builder, loc, substringBounds[0], one);
// Convert the upper bound to a length.
mlir::Value cast = builder.createConvert(loc, iTy, substringBounds[1]);
mlir::Value zero = builder.createIntegerConstant(loc, iTy, 0);
auto size =
- builder.create<mlir::arith::SubIOp>(loc, cast, substringBounds[0]);
- auto cmp = builder.create<mlir::arith::CmpIOp>(
- loc, mlir::arith::CmpIPredicate::sgt, size, zero);
+ mlir::arith::SubIOp::create(builder, loc, cast, substringBounds[0]);
+ auto cmp = mlir::arith::CmpIOp::create(
+ builder, loc, mlir::arith::CmpIPredicate::sgt, size, zero);
// size = MAX(upper - (lower - 1), 0)
substringBounds[1] =
- builder.create<mlir::arith::SelectOp>(loc, cmp, size, zero);
- slice = builder.create<fir::SliceOp>(
- loc, padSlice(components.trips, shape), components.suffixComponents,
- substringBounds);
+ mlir::arith::SelectOp::create(builder, loc, cmp, size, zero);
+ slice = fir::SliceOp::create(
+ builder, loc, padSlice(components.trips, shape),
+ components.suffixComponents, substringBounds);
} else {
slice = builder.createSlice(loc, extMemref, components.trips,
components.suffixComponents);
@@ -5827,7 +5838,7 @@ class ArrayExprLowering {
}
mlir::Value embox =
mlir::isa<fir::BaseBoxType>(memref.getType())
- ? builder.create<fir::ReboxOp>(loc, boxTy, memref, shape, slice)
+ ? fir::ReboxOp::create(builder, loc, boxTy, memref, shape, slice)
.getResult()
: builder
.create<fir::EmboxOp>(loc, boxTy, memref, shape, slice,
@@ -5849,8 +5860,8 @@ class ArrayExprLowering {
// ArrayCoorOp does not expect zero based indices.
llvm::SmallVector<mlir::Value> indices = fir::factory::originateIndices(
loc, builder, memref.getType(), shape, iters.iterVec());
- mlir::Value coor = builder.create<fir::ArrayCoorOp>(
- loc, refEleTy, memref, shape, slice, indices,
+ mlir::Value coor = fir::ArrayCoorOp::create(
+ builder, loc, refEleTy, memref, shape, slice, indices,
fir::getTypeParams(extMemref));
if (auto charTy = mlir::dyn_cast<fir::CharacterType>(eleTy)) {
llvm::SmallVector<mlir::Value> substringBounds;
@@ -5869,16 +5880,17 @@ class ArrayExprLowering {
builder, loc, extMemref, coor, slice);
};
}
- auto arrLoad = builder.create<fir::ArrayLoadOp>(
- loc, arrTy, memref, shape, slice, fir::getTypeParams(extMemref));
+ auto arrLoad =
+ fir::ArrayLoadOp::create(builder, loc, arrTy, memref, shape, slice,
+ fir::getTypeParams(extMemref));
if (CrayPtr) {
mlir::Type ptrTy = CrayPtr.getType();
mlir::Value cnvrt = Fortran::lower::addCrayPointerInst(
loc, builder, CrayPtr, ptrTy, memref.getType());
- auto addr = builder.create<fir::LoadOp>(loc, cnvrt);
- arrLoad = builder.create<fir::ArrayLoadOp>(loc, arrTy, addr, shape, slice,
- fir::getTypeParams(extMemref));
+ auto addr = fir::LoadOp::create(builder, loc, cnvrt);
+ arrLoad = fir::ArrayLoadOp::create(builder, loc, arrTy, addr, shape,
+ slice, fir::getTypeParams(extMemref));
}
mlir::Value arrLd = arrLoad.getResult();
@@ -5906,9 +5918,9 @@ class ArrayExprLowering {
mlir::Type eleTy = fir::applyPathToType(resTy, iters.iterVec());
mlir::Type refEleTy =
fir::isa_ref_type(eleTy) ? eleTy : builder.getRefType(eleTy);
- auto arrModify = builder.create<fir::ArrayModifyOp>(
- loc, mlir::TypeRange{refEleTy, resTy}, innerArg, iters.iterVec(),
- destination.getTypeparams());
+ auto arrModify = fir::ArrayModifyOp::create(
+ builder, loc, mlir::TypeRange{refEleTy, resTy}, innerArg,
+ iters.iterVec(), destination.getTypeparams());
return abstractArrayExtValue(arrModify.getResult(1));
};
}
@@ -5932,17 +5944,17 @@ class ArrayExprLowering {
mlir::Type eleTy = fir::applyPathToType(arrTy, iters.iterVec());
if (isAdjustedArrayElementType(eleTy)) {
mlir::Type eleRefTy = builder.getRefType(eleTy);
- base = builder.create<fir::ArrayAccessOp>(
- loc, eleRefTy, arrLd, iters.iterVec(), arrLdTypeParams);
+ base = fir::ArrayAccessOp::create(builder, loc, eleRefTy, arrLd,
+ iters.iterVec(), arrLdTypeParams);
} else {
- base = builder.create<fir::ArrayFetchOp>(
- loc, eleTy, arrLd, iters.iterVec(), arrLdTypeParams);
+ base = fir::ArrayFetchOp::create(builder, loc, eleTy, arrLd,
+ iters.iterVec(), arrLdTypeParams);
}
mlir::Value temp =
builder.createTemporary(loc, base.getType(),
llvm::ArrayRef<mlir::NamedAttribute>{
fir::getAdaptToByRefAttr(builder)});
- builder.create<fir::StoreOp>(loc, base, temp);
+ fir::StoreOp::create(builder, loc, base, temp);
return fir::factory::arraySectionElementToExtendedValue(
builder, loc, extMemref, temp, slice);
};
@@ -5953,8 +5965,8 @@ class ArrayExprLowering {
mlir::Type eleTy = fir::applyPathToType(arrTy, iters.iterVec());
if (isAdjustedArrayElementType(eleTy)) {
mlir::Type eleRefTy = builder.getRefType(eleTy);
- mlir::Value arrayOp = builder.create<fir::ArrayAccessOp>(
- loc, eleRefTy, arrLd, iters.iterVec(), arrLdTypeParams);
+ mlir::Value arrayOp = fir::ArrayAccessOp::create(
+ builder, loc, eleRefTy, arrLd, iters.iterVec(), arrLdTypeParams);
if (auto charTy = mlir::dyn_cast<fir::CharacterType>(eleTy)) {
llvm::SmallVector<mlir::Value> substringBounds;
populateBounds(substringBounds, components.substring);
@@ -5969,8 +5981,8 @@ class ArrayExprLowering {
return fir::factory::arraySectionElementToExtendedValue(
builder, loc, extMemref, arrayOp, slice);
}
- auto arrFetch = builder.create<fir::ArrayFetchOp>(
- loc, eleTy, arrLd, iters.iterVec(), arrLdTypeParams);
+ auto arrFetch = fir::ArrayFetchOp::create(
+ builder, loc, eleTy, arrLd, iters.iterVec(), arrLdTypeParams);
return fir::factory::arraySectionElementToExtendedValue(
builder, loc, extMemref, arrFetch, slice);
};
@@ -6009,8 +6021,8 @@ class ArrayExprLowering {
mlir::Value memref = fir::getBase(exv);
mlir::Value shape = builder.createShape(loc, exv);
mlir::Value noSlice;
- auto arrLoad = builder.create<fir::ArrayLoadOp>(
- loc, arrType, memref, shape, noSlice, fir::getTypeParams(exv));
+ auto arrLoad = fir::ArrayLoadOp::create(
+ builder, loc, arrType, memref, shape, noSlice, fir::getTypeParams(exv));
mlir::Operation::operand_range arrLdTypeParams = arrLoad.getTypeparams();
mlir::Value arrLd = arrLoad.getResult();
// Mark the load to tell later passes it is unsafe to use this array_load
@@ -6025,8 +6037,8 @@ class ArrayExprLowering {
// By value semantics.
auto cc = [=](IterSpace iters) -> ExtValue {
- auto arrFetch = builder.create<fir::ArrayFetchOp>(
- loc, eleType, arrLd, iters.iterVec(), arrLdTypeParams);
+ auto arrFetch = fir::ArrayFetchOp::create(
+ builder, loc, eleType, arrLd, iters.iterVec(), arrLdTypeParams);
return fir::factory::arraySectionElementToExtendedValue(
builder, loc, exv, arrFetch, noSlice);
};
@@ -6064,12 +6076,12 @@ class ArrayExprLowering {
.genIfOp(loc, {eleType}, isPresent,
/*withElseRegion=*/true)
.genThen([&]() {
- builder.create<fir::ResultOp>(loc, fir::getBase(cc(iters)));
+ fir::ResultOp::create(builder, loc, fir::getBase(cc(iters)));
})
.genElse([&]() {
mlir::Value zero =
fir::factory::createZeroValue(builder, loc, eleType);
- builder.create<fir::ResultOp>(loc, zero);
+ fir::ResultOp::create(builder, loc, zero);
})
.getResults()[0];
return elementValue;
@@ -6178,8 +6190,8 @@ class ArrayExprLowering {
mlir::Type eleRefTy = builder.getRefType(eleTy);
mlir::Type resRefTy = builder.getRefType(resTy);
mlir::Value nullPtr = builder.createNullConstant(loc, resRefTy);
- auto offset = builder.create<fir::CoordinateOp>(
- loc, eleRefTy, nullPtr, mlir::ValueRange{multiplier});
+ auto offset = fir::CoordinateOp::create(builder, loc, eleRefTy, nullPtr,
+ mlir::ValueRange{multiplier});
return builder.createConvert(loc, idxTy, offset);
}
@@ -6193,8 +6205,8 @@ class ArrayExprLowering {
/// Create a call to the LLVM memcpy intrinsic.
void createCallMemcpy(llvm::ArrayRef<mlir::Value> args, bool isVolatile) {
mlir::Location loc = getLoc();
- builder.create<mlir::LLVM::MemcpyOp>(loc, args[0], args[1], args[2],
- isVolatile);
+ mlir::LLVM::MemcpyOp::create(builder, loc, args[0], args[1], args[2],
+ isVolatile);
}
// Construct code to check for a buffer overrun and realloc the buffer when
@@ -6204,32 +6216,33 @@ class ArrayExprLowering {
mlir::Value eleSz) {
mlir::Location loc = getLoc();
mlir::func::FuncOp reallocFunc = fir::factory::getRealloc(builder);
- auto cond = builder.create<mlir::arith::CmpIOp>(
- loc, mlir::arith::CmpIPredicate::sle, bufferSize, needed);
- auto ifOp = builder.create<fir::IfOp>(loc, mem.getType(), cond,
- /*withElseRegion=*/true);
+ auto cond = mlir::arith::CmpIOp::create(
+ builder, loc, mlir::arith::CmpIPredicate::sle, bufferSize, needed);
+ auto ifOp = fir::IfOp::create(builder, loc, mem.getType(), cond,
+ /*withElseRegion=*/true);
auto insPt = builder.saveInsertionPoint();
builder.setInsertionPointToStart(&ifOp.getThenRegion().front());
// Not enough space, resize the buffer.
mlir::IndexType idxTy = builder.getIndexType();
mlir::Value two = builder.createIntegerConstant(loc, idxTy, 2);
- auto newSz = builder.create<mlir::arith::MulIOp>(loc, needed, two);
- builder.create<fir::StoreOp>(loc, newSz, buffSize);
- mlir::Value byteSz = builder.create<mlir::arith::MulIOp>(loc, newSz, eleSz);
+ auto newSz = mlir::arith::MulIOp::create(builder, loc, needed, two);
+ fir::StoreOp::create(builder, loc, newSz, buffSize);
+ mlir::Value byteSz =
+ mlir::arith::MulIOp::create(builder, loc, newSz, eleSz);
mlir::SymbolRefAttr funcSymAttr =
builder.getSymbolRefAttr(reallocFunc.getName());
mlir::FunctionType funcTy = reallocFunc.getFunctionType();
- auto newMem = builder.create<fir::CallOp>(
- loc, funcSymAttr, funcTy.getResults(),
+ auto newMem = fir::CallOp::create(
+ builder, loc, funcSymAttr, funcTy.getResults(),
llvm::ArrayRef<mlir::Value>{
builder.createConvert(loc, funcTy.getInputs()[0], mem),
builder.createConvert(loc, funcTy.getInputs()[1], byteSz)});
mlir::Value castNewMem =
builder.createConvert(loc, mem.getType(), newMem.getResult(0));
- builder.create<fir::ResultOp>(loc, castNewMem);
+ fir::ResultOp::create(builder, loc, castNewMem);
builder.setInsertionPointToStart(&ifOp.getElseRegion().front());
// Otherwise, just forward the buffer.
- builder.create<fir::ResultOp>(loc, mem);
+ fir::ResultOp::create(builder, loc, mem);
builder.restoreInsertionPoint(insPt);
return ifOp.getResult(0);
}
@@ -6241,8 +6254,8 @@ class ArrayExprLowering {
mlir::Value eleSz, mlir::Type eleTy,
mlir::Type eleRefTy, mlir::Type resTy) {
mlir::Location loc = getLoc();
- auto off = builder.create<fir::LoadOp>(loc, buffPos);
- auto limit = builder.create<fir::LoadOp>(loc, buffSize);
+ auto off = fir::LoadOp::create(builder, loc, buffPos);
+ auto limit = fir::LoadOp::create(builder, loc, buffSize);
mlir::IndexType idxTy = builder.getIndexType();
mlir::Value one = builder.createIntegerConstant(loc, idxTy, 1);
@@ -6260,7 +6273,7 @@ class ArrayExprLowering {
mlir::Value length = fir::getLen(exv);
if (!length)
fir::emitFatalError(loc, "result is not boxed character");
- eleSz = builder.create<mlir::arith::MulIOp>(loc, bytes, length);
+ eleSz = mlir::arith::MulIOp::create(builder, loc, bytes, length);
} else {
TODO(loc, "PDT size");
// Will call the PDT's size function with the type parameters.
@@ -6279,13 +6292,13 @@ class ArrayExprLowering {
refTy = builder.getRefType(chTy);
mlir::Type toTy = builder.getRefType(builder.getVarLenSeqTy(chTy));
buff = builder.createConvert(loc, toTy, buff);
- off = builder.create<mlir::arith::MulIOp>(loc, off, eleSz);
+ off = mlir::arith::MulIOp::create(builder, loc, off, eleSz);
} else {
TODO(loc, "PDT offset");
}
}
- auto coor = builder.create<fir::CoordinateOp>(loc, refTy, buff,
- mlir::ValueRange{off});
+ auto coor = fir::CoordinateOp::create(builder, loc, refTy, buff,
+ mlir::ValueRange{off});
return builder.createConvert(loc, eleRefTy, coor);
};
@@ -6294,15 +6307,15 @@ class ArrayExprLowering {
// Compute the array size.
mlir::Value arrSz = one;
for (auto ext : v.getExtents())
- arrSz = builder.create<mlir::arith::MulIOp>(loc, arrSz, ext);
+ arrSz = mlir::arith::MulIOp::create(builder, loc, arrSz, ext);
// Grow the buffer as needed.
- auto endOff = builder.create<mlir::arith::AddIOp>(loc, off, arrSz);
+ auto endOff = mlir::arith::AddIOp::create(builder, loc, off, arrSz);
mem = growBuffer(mem, endOff, limit, buffSize, eleSz);
// Copy the elements to the buffer.
mlir::Value byteSz =
- builder.create<mlir::arith::MulIOp>(loc, arrSz, eleSz);
+ mlir::arith::MulIOp::create(builder, loc, arrSz, eleSz);
auto buff = builder.createConvert(loc, fir::HeapType::get(resTy), mem);
mlir::Value buffi = computeCoordinate(buff, off);
llvm::SmallVector<mlir::Value> args = fir::runtime::createArguments(
@@ -6311,13 +6324,13 @@ class ArrayExprLowering {
createCallMemcpy(args, isVolatile);
// Save the incremented buffer position.
- builder.create<fir::StoreOp>(loc, endOff, buffPos);
+ fir::StoreOp::create(builder, loc, endOff, buffPos);
};
// Copy a trivial scalar value into the buffer.
auto doTrivialScalar = [&](const ExtValue &v, mlir::Value len = {}) {
// Increment the buffer position.
- auto plusOne = builder.create<mlir::arith::AddIOp>(loc, off, one);
+ auto plusOne = mlir::arith::AddIOp::create(builder, loc, off, one);
// Grow the buffer as needed.
mem = growBuffer(mem, plusOne, limit, buffSize, eleSz);
@@ -6325,8 +6338,8 @@ class ArrayExprLowering {
// Store the element in the buffer.
mlir::Value buff =
builder.createConvert(loc, fir::HeapType::get(resTy), mem);
- auto buffi = builder.create<fir::CoordinateOp>(loc, eleRefTy, buff,
- mlir::ValueRange{off});
+ auto buffi = fir::CoordinateOp::create(builder, loc, eleRefTy, buff,
+ mlir::ValueRange{off});
fir::factory::genScalarAssignment(
builder, loc,
[&]() -> ExtValue {
@@ -6335,7 +6348,7 @@ class ArrayExprLowering {
return buffi;
}(),
v);
- builder.create<fir::StoreOp>(loc, plusOne, buffPos);
+ fir::StoreOp::create(builder, loc, plusOne, buffPos);
};
// Copy the value.
@@ -6347,7 +6360,7 @@ class ArrayExprLowering {
doTrivialScalar(exv, eleSz);
} else {
// Increment the buffer position.
- auto plusOne = builder.create<mlir::arith::AddIOp>(loc, off, one);
+ auto plusOne = mlir::arith::AddIOp::create(builder, loc, off, one);
// Grow the buffer as needed.
mem = growBuffer(mem, plusOne, limit, buffSize, eleSz);
@@ -6362,7 +6375,7 @@ class ArrayExprLowering {
fir::isa_volatile_type(v.getAddr().getType());
createCallMemcpy(args, isVolatile);
- builder.create<fir::StoreOp>(loc, plusOne, buffPos);
+ fir::StoreOp::create(builder, loc, plusOne, buffPos);
}
},
[&](const fir::ArrayBoxValue &v) { doAbstractArray(v); },
@@ -6403,8 +6416,8 @@ class ArrayExprLowering {
auto seqTy = mlir::cast<fir::SequenceType>(resTy);
mlir::Type eleTy = fir::unwrapSequenceType(seqTy);
auto loop =
- builder.create<fir::DoLoopOp>(loc, lo, up, step, /*unordered=*/false,
- /*finalCount=*/false, mem);
+ fir::DoLoopOp::create(builder, loc, lo, up, step, /*unordered=*/false,
+ /*finalCount=*/false, mem);
// create a new binding for x.name(), to ac-do-variable, to the iteration
// value.
symMap.pushImpliedDoBinding(toStringRef(x.name()), loop.getInductionVar());
@@ -6434,22 +6447,22 @@ class ArrayExprLowering {
mlir::Value castLen =
builder.createConvert(loc, builder.getI64Type(), fir::getLen(exv));
assert(charLen.has_value());
- builder.create<fir::StoreOp>(loc, castLen, *charLen);
+ fir::StoreOp::create(builder, loc, castLen, *charLen);
}
}
stmtCtx.finalizeAndPop();
- builder.create<fir::ResultOp>(loc, mem);
+ fir::ResultOp::create(builder, loc, mem);
builder.restoreInsertionPoint(insPt);
mem = loop.getResult(0);
symMap.popImpliedDoBinding();
llvm::SmallVector<mlir::Value> extents = {
- builder.create<fir::LoadOp>(loc, buffPos).getResult()};
+ fir::LoadOp::create(builder, loc, buffPos).getResult()};
// Convert to extended value.
if (fir::isa_char(seqTy.getEleTy())) {
assert(charLen.has_value());
- auto len = builder.create<fir::LoadOp>(loc, *charLen);
+ auto len = fir::LoadOp::create(builder, loc, *charLen);
return {fir::CharArrayBoxValue{mem, len, extents}, /*needCopy=*/false};
}
return {fir::ArrayBoxValue{mem, extents}, /*needCopy=*/false};
@@ -6472,7 +6485,7 @@ class ArrayExprLowering {
mlir::Value buffSize = builder.createTemporary(loc, idxTy, ".buff.size");
mlir::Value zero = builder.createIntegerConstant(loc, idxTy, 0);
mlir::Value buffPos = builder.createTemporary(loc, idxTy, ".buff.pos");
- builder.create<fir::StoreOp>(loc, zero, buffPos);
+ fir::StoreOp::create(builder, loc, zero, buffPos);
// Allocate space for the array to be constructed.
mlir::Value mem;
if (fir::hasDynamicSize(resTy)) {
@@ -6480,22 +6493,22 @@ class ArrayExprLowering {
// The size of each element may depend on a general expression. Defer
// creating the buffer until after the expression is evaluated.
mem = builder.createNullConstant(loc, builder.getRefType(eleTy));
- builder.create<fir::StoreOp>(loc, zero, buffSize);
+ fir::StoreOp::create(builder, loc, zero, buffSize);
} else {
mlir::Value initBuffSz =
builder.createIntegerConstant(loc, idxTy, clInitialBufferSize);
- mem = builder.create<fir::AllocMemOp>(
- loc, eleTy, /*typeparams=*/mlir::ValueRange{}, initBuffSz);
- builder.create<fir::StoreOp>(loc, initBuffSz, buffSize);
+ mem = fir::AllocMemOp::create(
+ builder, loc, eleTy, /*typeparams=*/mlir::ValueRange{}, initBuffSz);
+ fir::StoreOp::create(builder, loc, initBuffSz, buffSize);
}
} else {
- mem = builder.create<fir::AllocMemOp>(loc, resTy);
+ mem = fir::AllocMemOp::create(builder, loc, resTy);
int64_t buffSz = 1;
for (auto extent : seqTy.getShape())
buffSz *= extent;
mlir::Value initBuffSz =
builder.createIntegerConstant(loc, idxTy, buffSz);
- builder.create<fir::StoreOp>(loc, initBuffSz, buffSize);
+ fir::StoreOp::create(builder, loc, initBuffSz, buffSize);
}
// Compute size of element
mlir::Type eleRefTy = builder.getRefType(eleTy);
@@ -6517,12 +6530,12 @@ class ArrayExprLowering {
charLen = builder.createTemporary(loc, builder.getI64Type());
mlir::Value castLen =
builder.createConvert(loc, builder.getI64Type(), fir::getLen(exv));
- builder.create<fir::StoreOp>(loc, castLen, *charLen);
+ fir::StoreOp::create(builder, loc, castLen, *charLen);
}
}
mem = builder.createConvert(loc, fir::HeapType::get(resTy), mem);
llvm::SmallVector<mlir::Value> extents = {
- builder.create<fir::LoadOp>(loc, buffPos)};
+ fir::LoadOp::create(builder, loc, buffPos)};
// Cleanup the temporary.
fir::FirOpBuilder *bldr = &converter.getFirOpBuilder();
@@ -6532,7 +6545,7 @@ class ArrayExprLowering {
// Return the continuation.
if (fir::isa_char(seqTy.getEleTy())) {
if (charLen) {
- auto len = builder.create<fir::LoadOp>(loc, *charLen);
+ auto len = fir::LoadOp::create(builder, loc, *charLen);
return genarr(fir::CharArrayBoxValue{mem, len, extents});
}
return genarr(fir::CharArrayBoxValue{mem, zero, extents});
@@ -6569,7 +6582,7 @@ class ArrayExprLowering {
return [=](IterSpace iters) -> ExtValue {
mlir::Value logical = fir::getBase(lambda(iters));
mlir::Value val = builder.createConvert(loc, i1Ty, logical);
- return builder.create<mlir::arith::XOrIOp>(loc, val, truth);
+ return mlir::arith::XOrIOp::create(builder, loc, val, truth);
};
}
template <typename OP, typename A>
@@ -6583,7 +6596,7 @@ class ArrayExprLowering {
mlir::Value right = fir::getBase(rf(iters));
mlir::Value lhs = builder.createConvert(loc, i1Ty, left);
mlir::Value rhs = builder.createConvert(loc, i1Ty, right);
- return builder.create<OP>(loc, lhs, rhs);
+ return OP::create(builder, loc, lhs, rhs);
};
}
template <typename OP, typename A>
@@ -6597,7 +6610,7 @@ class ArrayExprLowering {
mlir::Value right = fir::getBase(rf(iters));
mlir::Value lhs = builder.createConvert(loc, i1Ty, left);
mlir::Value rhs = builder.createConvert(loc, i1Ty, right);
- return builder.create<OP>(loc, pred, lhs, rhs);
+ return OP::create(builder, loc, pred, lhs, rhs);
};
}
template <int KIND>
@@ -6637,9 +6650,9 @@ class ArrayExprLowering {
Fortran::common::TypeCategory::Integer, *unsignedKind);
mlir::Value lhsSL = builder.createConvert(loc, signlessType, lhs);
mlir::Value rhsSL = builder.createConvert(loc, signlessType, rhs);
- return builder.create<OP>(loc, pred, lhsSL, rhsSL);
+ return OP::create(builder, loc, pred, lhsSL, rhsSL);
}
- return builder.create<OP>(loc, pred, lhs, rhs);
+ return OP::create(builder, loc, pred, lhs, rhs);
};
}
template <typename A>
@@ -6806,9 +6819,8 @@ class ArrayExprLowering {
: one;
mlir::Value val = builder.createConvert(
loc, idxTy, subscriptVal);
- mlir::Value ivAdj =
- builder.create<mlir::arith::SubIOp>(
- loc, idxTy, val, lb);
+ mlir::Value ivAdj = mlir::arith::SubIOp::create(
+ builder, loc, idxTy, val, lb);
componentsToAdd.push_back(
builder.createConvert(loc, idxTy, ivAdj));
},
@@ -6830,8 +6842,9 @@ class ArrayExprLowering {
converter.getRecordTypeFieldName(getLastSym(*x));
if (auto recTy = mlir::dyn_cast<fir::RecordType>(ty)) {
ty = recTy.getType(name);
- auto fld = builder.create<fir::FieldIndexOp>(
- loc, fieldTy, name, recTy, fir::getTypeParams(arrayExv));
+ auto fld = fir::FieldIndexOp::create(
+ builder, loc, fieldTy, name, recTy,
+ fir::getTypeParams(arrayExv));
addComponentList(ty, {fld});
if (index != revPath.size() - 1 || !isPointerAssignment()) {
// Need an intermediate dereference if the boxed value
@@ -6852,8 +6865,9 @@ class ArrayExprLowering {
ty = fir::unwrapRefType(boxTy.getEleTy());
auto recTy = mlir::cast<fir::RecordType>(ty);
ty = recTy.getType(name);
- auto fld = builder.create<fir::FieldIndexOp>(
- loc, fieldTy, name, recTy, fir::getTypeParams(arrayExv));
+ auto fld = fir::FieldIndexOp::create(
+ builder, loc, fieldTy, name, recTy,
+ fir::getTypeParams(arrayExv));
extendComponent(components, ty, {fld});
} else {
TODO(loc, "other component type");
@@ -6896,8 +6910,8 @@ class ArrayExprLowering {
mlir::Value innerArg = esp->findArgumentOfLoad(load);
if (isAdjustedArrayElementType(eleTy)) {
mlir::Type eleRefTy = builder.getRefType(eleTy);
- auto arrayOp = builder.create<fir::ArrayAccessOp>(
- loc, eleRefTy, innerArg, iters.iterVec(),
+ auto arrayOp = fir::ArrayAccessOp::create(
+ builder, loc, eleRefTy, innerArg, iters.iterVec(),
fir::factory::getTypeParams(loc, builder, load));
if (auto charTy = mlir::dyn_cast<fir::CharacterType>(eleTy)) {
mlir::Value dstLen = fir::factory::genLenOfCharacter(
@@ -6924,9 +6938,9 @@ class ArrayExprLowering {
if (!eleBoxTy || !mlir::isa<fir::BoxType>(eleBoxTy))
TODO(loc, "assignment in a FORALL involving a designator with a "
"POINTER or ALLOCATABLE component part-ref");
- auto arrayOp = builder.create<fir::ArrayAccessOp>(
- loc, builder.getRefType(eleBoxTy), innerArg, iters.iterVec(),
- fir::factory::getTypeParams(loc, builder, load));
+ auto arrayOp = fir::ArrayAccessOp::create(
+ builder, loc, builder.getRefType(eleBoxTy), innerArg,
+ iters.iterVec(), fir::factory::getTypeParams(loc, builder, load));
mlir::Value addr = components.getExtendCoorRef()(arrayOp);
components.resetExtendCoorRef();
// When the lhs is a boxed value and the context is not a pointer
@@ -6935,19 +6949,19 @@ class ArrayExprLowering {
if (!isPointerAssignment()) {
if (auto boxTy = mlir::dyn_cast<fir::BaseBoxType>(eleTy)) {
eleTy = fir::boxMemRefType(boxTy);
- addr = builder.create<fir::BoxAddrOp>(loc, eleTy, addr);
+ addr = fir::BoxAddrOp::create(builder, loc, eleTy, addr);
eleTy = fir::unwrapRefType(eleTy);
}
}
auto ele = convertElementForUpdate(loc, eleTy, iters.getElement());
- builder.create<fir::StoreOp>(loc, ele, addr);
- auto amend = builder.create<fir::ArrayAmendOp>(
- loc, innerArg.getType(), innerArg, arrayOp);
+ fir::StoreOp::create(builder, loc, ele, addr);
+ auto amend = fir::ArrayAmendOp::create(
+ builder, loc, innerArg.getType(), innerArg, arrayOp);
return arrayLoadExtValue(builder, loc, load, iters.iterVec(), amend);
}
auto ele = convertElementForUpdate(loc, eleTy, iters.getElement());
- auto update = builder.create<fir::ArrayUpdateOp>(
- loc, innerArg.getType(), innerArg, ele, iters.iterVec(),
+ auto update = fir::ArrayUpdateOp::create(
+ builder, loc, innerArg.getType(), innerArg, ele, iters.iterVec(),
fir::factory::getTypeParams(loc, builder, load));
return arrayLoadExtValue(builder, loc, load, iters.iterVec(), update);
};
@@ -6961,9 +6975,9 @@ class ArrayExprLowering {
mlir::Value innerArg = explicitSpace->findArgumentOfLoad(load);
mlir::Type refEleTy =
fir::isa_ref_type(eleTy) ? eleTy : builder.getRefType(eleTy);
- auto arrModify = builder.create<fir::ArrayModifyOp>(
- loc, mlir::TypeRange{refEleTy, innerArg.getType()}, innerArg,
- iters.iterVec(), load.getTypeparams());
+ auto arrModify = fir::ArrayModifyOp::create(
+ builder, loc, mlir::TypeRange{refEleTy, innerArg.getType()},
+ innerArg, iters.iterVec(), load.getTypeparams());
return arrayLoadExtValue(builder, loc, load, iters.iterVec(),
arrModify.getResult(1));
};
@@ -6974,8 +6988,8 @@ class ArrayExprLowering {
isAdjustedArrayElementType(eleTy)) {
mlir::Type resTy = builder.getRefType(eleTy);
// Use array element reference semantics.
- auto access = builder.create<fir::ArrayAccessOp>(
- loc, resTy, load, iters.iterVec(),
+ auto access = fir::ArrayAccessOp::create(
+ builder, loc, resTy, load, iters.iterVec(),
fir::factory::getTypeParams(loc, builder, load));
mlir::Value newBase = access;
if (fir::isa_char(eleTy)) {
@@ -6997,8 +7011,8 @@ class ArrayExprLowering {
if (!eleBoxTy || !mlir::isa<fir::BoxType>(eleBoxTy))
TODO(loc, "assignment in a FORALL involving a designator with a "
"POINTER or ALLOCATABLE component part-ref");
- auto access = builder.create<fir::ArrayAccessOp>(
- loc, builder.getRefType(eleBoxTy), load, iters.iterVec(),
+ auto access = fir::ArrayAccessOp::create(
+ builder, loc, builder.getRefType(eleBoxTy), load, iters.iterVec(),
fir::factory::getTypeParams(loc, builder, load));
mlir::Value addr = components.getExtendCoorRef()(access);
components.resetExtendCoorRef();
@@ -7010,8 +7024,8 @@ class ArrayExprLowering {
// Rhs is a regular expression that will need to be boxed before
// assigning to the boxed variable.
auto typeParams = fir::factory::getTypeParams(loc, builder, load);
- auto access = builder.create<fir::ArrayAccessOp>(
- loc, builder.getRefType(eleTy), load, iters.iterVec(),
+ auto access = fir::ArrayAccessOp::create(
+ builder, loc, builder.getRefType(eleTy), load, iters.iterVec(),
typeParams);
auto addr = components.getExtendCoorRef()(access);
components.resetExtendCoorRef();
@@ -7025,14 +7039,14 @@ class ArrayExprLowering {
TODO(loc, "need to adjust typeparameter(s) to reflect the final "
"component");
mlir::Value embox =
- builder.create<fir::EmboxOp>(loc, boxTy, ptrAddr,
- /*shape=*/mlir::Value{},
- /*slice=*/mlir::Value{}, typeParams);
+ fir::EmboxOp::create(builder, loc, boxTy, ptrAddr,
+ /*shape=*/mlir::Value{},
+ /*slice=*/mlir::Value{}, typeParams);
return arrayLoadExtValue(builder, loc, load, iters.iterVec(), embox);
}
}
- auto fetch = builder.create<fir::ArrayFetchOp>(
- loc, eleTy, load, iters.iterVec(), load.getTypeparams());
+ auto fetch = fir::ArrayFetchOp::create(
+ builder, loc, eleTy, load, iters.iterVec(), load.getTypeparams());
return arrayLoadExtValue(builder, loc, load, iters.iterVec(), fetch);
};
return [=](IterSpace iters) mutable { return lambda(pc(iters)); };
@@ -7541,24 +7555,25 @@ fir::ExtendedValue Fortran::lower::updateBoxForParentComponent(
if (op) {
if (auto embox = mlir::dyn_cast<fir::EmboxOp>(op)) {
- auto newBox = builder.create<fir::EmboxOp>(
- loc, fir::BoxType::get(actualTy), embox.getMemref(), embox.getShape(),
- embox.getSlice(), embox.getTypeparams());
+ auto newBox = fir::EmboxOp::create(
+ builder, loc, fir::BoxType::get(actualTy), embox.getMemref(),
+ embox.getShape(), embox.getSlice(), embox.getTypeparams());
return fir::substBase(box, newBox);
}
if (auto rebox = mlir::dyn_cast<fir::ReboxOp>(op)) {
- auto newBox = builder.create<fir::ReboxOp>(
- loc, fir::BoxType::get(actualTy), rebox.getBox(), rebox.getShape(),
- rebox.getSlice());
+ auto newBox = fir::ReboxOp::create(
+ builder, loc, fir::BoxType::get(actualTy), rebox.getBox(),
+ rebox.getShape(), rebox.getSlice());
return fir::substBase(box, newBox);
}
}
mlir::Value empty;
mlir::ValueRange emptyRange;
- return builder.create<fir::ReboxOp>(loc, fir::BoxType::get(actualTy), boxBase,
- /*shape=*/empty,
- /*slice=*/empty);
+ return fir::ReboxOp::create(builder, loc, fir::BoxType::get(actualTy),
+ boxBase,
+ /*shape=*/empty,
+ /*slice=*/empty);
}
fir::ExtendedValue Fortran::lower::createBoxValue(
@@ -7649,9 +7664,9 @@ fir::ArrayLoadOp genArrayLoad(mlir::Location loc,
mlir::Value addr = fir::getBase(exv);
mlir::Value shapeOp = builder.createShape(loc, exv);
mlir::Type arrTy = fir::dyn_cast_ptrOrBoxEleTy(addr.getType());
- return builder.create<fir::ArrayLoadOp>(loc, arrTy, addr, shapeOp,
- /*slice=*/mlir::Value{},
- fir::getTypeParams(exv));
+ return fir::ArrayLoadOp::create(builder, loc, arrTy, addr, shapeOp,
+ /*slice=*/mlir::Value{},
+ fir::getTypeParams(exv));
}
template <>
fir::ArrayLoadOp
@@ -7698,9 +7713,9 @@ void Fortran::lower::createArrayMergeStores(
for (auto i : llvm::enumerate(esp.getOuterLoop().getResults()))
if (std::optional<fir::ArrayLoadOp> ldOpt = esp.getLhsLoad(i.index())) {
fir::ArrayLoadOp load = *ldOpt;
- builder.create<fir::ArrayMergeStoreOp>(loc, load, i.value(),
- load.getMemref(), load.getSlice(),
- load.getTypeparams());
+ fir::ArrayMergeStoreOp::create(builder, loc, load, i.value(),
+ load.getMemref(), load.getSlice(),
+ load.getTypeparams());
}
if (esp.loopCleanup) {
(*esp.loopCleanup)(builder);
@@ -7722,12 +7737,12 @@ mlir::Value Fortran::lower::addCrayPointerInst(mlir::Location loc,
mlir::Value empty;
mlir::ValueRange emptyRange;
auto boxTy = fir::BoxType::get(ptrTy);
- auto box = builder.create<fir::EmboxOp>(loc, boxTy, ptrVal, empty, empty,
- emptyRange);
- mlir::Value addrof =
- (mlir::isa<fir::ReferenceType>(ptrTy))
- ? builder.create<fir::BoxAddrOp>(loc, ptrTy, box)
- : builder.create<fir::BoxAddrOp>(loc, builder.getRefType(ptrTy), box);
+ auto box = fir::EmboxOp::create(builder, loc, boxTy, ptrVal, empty, empty,
+ emptyRange);
+ mlir::Value addrof = (mlir::isa<fir::ReferenceType>(ptrTy))
+ ? fir::BoxAddrOp::create(builder, loc, ptrTy, box)
+ : fir::BoxAddrOp::create(
+ builder, loc, builder.getRefType(ptrTy), box);
auto refPtrTy =
builder.getRefType(fir::PointerType::get(fir::dyn_cast_ptrEleTy(pteTy)));
diff --git a/flang/lib/Lower/ConvertExprToHLFIR.cpp b/flang/lib/Lower/ConvertExprToHLFIR.cpp
index 7de433d6a201a..46be111242bf7 100644
--- a/flang/lib/Lower/ConvertExprToHLFIR.cpp
+++ b/flang/lib/Lower/ConvertExprToHLFIR.cpp
@@ -167,7 +167,7 @@ class HlfirDesignatorBuilder {
extents.push_back(builder.createIntegerConstant(loc, idxTy, extent));
}
if (!mayHaveNonDefaultLowerBounds(componentSym))
- return builder.create<fir::ShapeOp>(loc, extents);
+ return fir::ShapeOp::create(builder, loc, extents);
llvm::SmallVector<mlir::Value> lbounds;
if (const auto *objDetails =
@@ -312,8 +312,8 @@ class HlfirDesignatorBuilder {
// hlfir.elemental_addr.
if (auto elementalAddrOp = getVectorSubscriptElementAddrOp())
builder.setInsertionPointToEnd(&elementalAddrOp->getBody().front());
- auto designate = builder.create<hlfir::DesignateOp>(
- getLoc(), designatorType, partInfo.base.value().getBase(),
+ auto designate = hlfir::DesignateOp::create(
+ builder, getLoc(), designatorType, partInfo.base.value().getBase(),
partInfo.componentName, partInfo.componentShape, partInfo.subscripts,
partInfo.substring, partInfo.complexPart, partInfo.resultShape,
partInfo.typeParams, attributes);
@@ -344,7 +344,7 @@ class HlfirDesignatorBuilder {
mlir::Type refPtrType = builder.getRefType(
fir::PointerType::get(fir::dyn_cast_ptrEleTy(ptrAddr.getType())));
mlir::Value cast = builder.createConvert(loc, refPtrType, ptrAddr);
- mlir::Value ptrVal = builder.create<fir::LoadOp>(loc, cast);
+ mlir::Value ptrVal = fir::LoadOp::create(builder, loc, cast);
// Update the base_addr to the value of the Cray pointer.
// This is a hacky way to do the update, and it may harm
@@ -442,9 +442,9 @@ class HlfirDesignatorBuilder {
} else {
// Compute "len = max(ub-lb+1,0)" (Fortran 2018 9.4.1).
mlir::Value one = builder.createIntegerConstant(loc, idxTy, 1);
- auto boundsDiff = builder.create<mlir::arith::SubIOp>(
- loc, partInfo.substring[1], partInfo.substring[0]);
- auto rawLen = builder.create<mlir::arith::AddIOp>(loc, boundsDiff, one);
+ auto boundsDiff = mlir::arith::SubIOp::create(
+ builder, loc, partInfo.substring[1], partInfo.substring[0]);
+ auto rawLen = mlir::arith::AddIOp::create(builder, loc, boundsDiff, one);
partInfo.typeParams[0] =
fir::factory::genMaxWithZero(builder, loc, rawLen);
}
@@ -803,10 +803,10 @@ class HlfirDesignatorBuilder {
mlir::Value one = builder.createIntegerConstant(loc, idxTy, 1);
oneBasedIndex = builder.createConvert(loc, idxTy, oneBasedIndex);
mlir::Value zeroBased =
- builder.create<mlir::arith::SubIOp>(loc, oneBasedIndex, one);
+ mlir::arith::SubIOp::create(builder, loc, oneBasedIndex, one);
mlir::Value offset =
- builder.create<mlir::arith::MulIOp>(loc, zeroBased, step);
- return builder.create<mlir::arith::AddIOp>(loc, lb, offset);
+ mlir::arith::MulIOp::create(builder, loc, zeroBased, step);
+ return mlir::arith::AddIOp::create(builder, loc, lb, offset);
}
/// Create an hlfir.element_addr operation to deal with vector subscripted
@@ -836,8 +836,8 @@ class HlfirDesignatorBuilder {
assert(partInfo.base.has_value() &&
"vector subscripted part must have a base");
mlir::Value mold = *partInfo.base;
- auto elementalAddrOp = builder.create<hlfir::ElementalAddrOp>(
- loc, shape, mold, mlir::ValueRange{},
+ auto elementalAddrOp = hlfir::ElementalAddrOp::create(
+ builder, loc, shape, mold, mlir::ValueRange{},
/*isUnordered=*/true);
setVectorSubscriptElementAddrOp(elementalAddrOp);
builder.setInsertionPointToEnd(&elementalAddrOp.getBody().front());
@@ -881,7 +881,7 @@ class HlfirDesignatorBuilder {
builder.setInsertionPointToEnd(&elementalAddrOp.getBody().front());
if (!elementAddr.isPolymorphic())
elementalAddrOp.getMoldMutable().clear();
- builder.create<hlfir::YieldOp>(loc, elementAddr);
+ hlfir::YieldOp::create(builder, loc, elementAddr);
builder.setInsertionPointAfter(elementalAddrOp);
}
@@ -1001,7 +1001,7 @@ HlfirDesignatorBuilder::convertVectorSubscriptedExprToElementalAddr(
elementalAddrOp.getMoldMutable().clear();
// Create the hlfir.yield terminator inside the hlfir.elemental_body.
builder.setInsertionPointToEnd(&elementalAddrOp.getBody().front());
- builder.create<hlfir::YieldOp>(loc, elementAddrEntity);
+ hlfir::YieldOp::create(builder, loc, elementAddrEntity);
builder.setInsertionPointAfter(elementalAddrOp);
// Reset the HlfirDesignatorBuilder state, in case it is used on a new
// designator.
@@ -1034,7 +1034,7 @@ struct BinaryOp {};
rhs)}; \
} else { \
return hlfir::EntityWithAttributes{ \
- builder.create<GenBinFirOp>(loc, lhs, rhs)}; \
+ GenBinFirOp::create(builder, loc, lhs, rhs)}; \
} \
} \
};
@@ -1075,7 +1075,7 @@ struct BinaryOp<Fortran::evaluate::Divide<
fir::genDivC(builder, loc, ty, lhs, rhs)};
} else {
return hlfir::EntityWithAttributes{
- builder.create<mlir::complex::DivOp>(loc, lhs, rhs)};
+ mlir::complex::DivOp::create(builder, loc, lhs, rhs)};
}
}
};
@@ -1219,8 +1219,8 @@ struct BinaryOp<Fortran::evaluate::Relational<
fir::FirOpBuilder &builder,
const Op &op, hlfir::Entity lhs,
hlfir::Entity rhs) {
- auto cmp = builder.create<mlir::arith::CmpIOp>(
- loc, translateSignedRelational(op.opr), lhs, rhs);
+ auto cmp = mlir::arith::CmpIOp::create(
+ builder, loc, translateSignedRelational(op.opr), lhs, rhs);
return hlfir::EntityWithAttributes{cmp};
}
};
@@ -1241,8 +1241,8 @@ struct BinaryOp<Fortran::evaluate::Relational<
mlir::IntegerType::SignednessSemantics::Signless);
mlir::Value lhsSL = builder.createConvert(loc, signlessType, lhs);
mlir::Value rhsSL = builder.createConvert(loc, signlessType, rhs);
- auto cmp = builder.create<mlir::arith::CmpIOp>(
- loc, translateUnsignedRelational(op.opr), lhsSL, rhsSL);
+ auto cmp = mlir::arith::CmpIOp::create(
+ builder, loc, translateUnsignedRelational(op.opr), lhsSL, rhsSL);
return hlfir::EntityWithAttributes{cmp};
}
};
@@ -1256,8 +1256,8 @@ struct BinaryOp<Fortran::evaluate::Relational<
fir::FirOpBuilder &builder,
const Op &op, hlfir::Entity lhs,
hlfir::Entity rhs) {
- auto cmp = builder.create<mlir::arith::CmpFOp>(
- loc, translateFloatRelational(op.opr), lhs, rhs);
+ auto cmp = mlir::arith::CmpFOp::create(
+ builder, loc, translateFloatRelational(op.opr), lhs, rhs);
return hlfir::EntityWithAttributes{cmp};
}
};
@@ -1271,8 +1271,8 @@ struct BinaryOp<Fortran::evaluate::Relational<
fir::FirOpBuilder &builder,
const Op &op, hlfir::Entity lhs,
hlfir::Entity rhs) {
- auto cmp = builder.create<fir::CmpcOp>(
- loc, translateFloatRelational(op.opr), lhs, rhs);
+ auto cmp = fir::CmpcOp::create(builder, loc,
+ translateFloatRelational(op.opr), lhs, rhs);
return hlfir::EntityWithAttributes{cmp};
}
};
@@ -1313,16 +1313,16 @@ struct BinaryOp<Fortran::evaluate::LogicalOperation<KIND>> {
switch (op.logicalOperator) {
case Fortran::evaluate::LogicalOperator::And:
return hlfir::EntityWithAttributes{
- builder.create<mlir::arith::AndIOp>(loc, i1Lhs, i1Rhs)};
+ mlir::arith::AndIOp::create(builder, loc, i1Lhs, i1Rhs)};
case Fortran::evaluate::LogicalOperator::Or:
return hlfir::EntityWithAttributes{
- builder.create<mlir::arith::OrIOp>(loc, i1Lhs, i1Rhs)};
+ mlir::arith::OrIOp::create(builder, loc, i1Lhs, i1Rhs)};
case Fortran::evaluate::LogicalOperator::Eqv:
- return hlfir::EntityWithAttributes{builder.create<mlir::arith::CmpIOp>(
- loc, mlir::arith::CmpIPredicate::eq, i1Lhs, i1Rhs)};
+ return hlfir::EntityWithAttributes{mlir::arith::CmpIOp::create(
+ builder, loc, mlir::arith::CmpIPredicate::eq, i1Lhs, i1Rhs)};
case Fortran::evaluate::LogicalOperator::Neqv:
- return hlfir::EntityWithAttributes{builder.create<mlir::arith::CmpIOp>(
- loc, mlir::arith::CmpIPredicate::ne, i1Lhs, i1Rhs)};
+ return hlfir::EntityWithAttributes{mlir::arith::CmpIOp::create(
+ builder, loc, mlir::arith::CmpIPredicate::ne, i1Lhs, i1Rhs)};
case Fortran::evaluate::LogicalOperator::Not:
// lib/evaluate expression for .NOT. is Fortran::evaluate::Not<KIND>.
llvm_unreachable(".NOT. is not a binary operator");
@@ -1354,7 +1354,7 @@ struct BinaryOp<Fortran::evaluate::SetLength<KIND>> {
// Fortran 2018 7.4.4.2 point 5.
mlir::Value safeLength = fir::factory::genMaxWithZero(builder, loc, length);
return hlfir::EntityWithAttributes{
- builder.create<hlfir::SetLengthOp>(loc, string, safeLength)};
+ hlfir::SetLengthOp::create(builder, loc, string, safeLength)};
}
static void
genResultTypeParams(mlir::Location, fir::FirOpBuilder &, hlfir::Entity,
@@ -1372,7 +1372,7 @@ struct BinaryOp<Fortran::evaluate::Concat<KIND>> {
hlfir::Entity lhs, hlfir::Entity rhs) {
assert(len && "genResultTypeParams must have been called");
auto concat =
- builder.create<hlfir::ConcatOp>(loc, mlir::ValueRange{lhs, rhs}, len);
+ hlfir::ConcatOp::create(builder, loc, mlir::ValueRange{lhs, rhs}, len);
return hlfir::EntityWithAttributes{concat.getResult()};
}
void
@@ -1386,7 +1386,7 @@ struct BinaryOp<Fortran::evaluate::Concat<KIND>> {
mlir::Type idxType = builder.getIndexType();
mlir::Value lhsLen = builder.createConvert(loc, idxType, lengths[0]);
mlir::Value rhsLen = builder.createConvert(loc, idxType, lengths[1]);
- len = builder.create<mlir::arith::AddIOp>(loc, lhsLen, rhsLen);
+ len = mlir::arith::AddIOp::create(builder, loc, lhsLen, rhsLen);
resultTypeParams.push_back(len);
}
@@ -1410,7 +1410,7 @@ struct UnaryOp<Fortran::evaluate::Not<KIND>> {
mlir::Value one = builder.createBool(loc, true);
mlir::Value val = builder.createConvert(loc, builder.getI1Type(), lhs);
return hlfir::EntityWithAttributes{
- builder.create<mlir::arith::XOrIOp>(loc, val, one)};
+ mlir::arith::XOrIOp::create(builder, loc, val, one)};
}
};
@@ -1428,7 +1428,7 @@ struct UnaryOp<Fortran::evaluate::Negate<
/*params=*/{});
mlir::Value zero = builder.createIntegerConstant(loc, type, 0);
return hlfir::EntityWithAttributes{
- builder.create<mlir::arith::SubIOp>(loc, zero, lhs)};
+ mlir::arith::SubIOp::create(builder, loc, zero, lhs)};
}
};
@@ -1448,7 +1448,7 @@ struct UnaryOp<Fortran::evaluate::Negate<
mlir::Value zero = builder.createIntegerConstant(loc, signlessType, 0);
mlir::Value signless = builder.createConvert(loc, signlessType, lhs);
mlir::Value negated =
- builder.create<mlir::arith::SubIOp>(loc, zero, signless);
+ mlir::arith::SubIOp::create(builder, loc, zero, signless);
return hlfir::EntityWithAttributes(
builder.createConvert(loc, lhs.getType(), negated));
}
@@ -1463,7 +1463,7 @@ struct UnaryOp<Fortran::evaluate::Negate<
fir::FirOpBuilder &builder, const Op &,
hlfir::Entity lhs) {
return hlfir::EntityWithAttributes{
- builder.create<mlir::arith::NegFOp>(loc, lhs)};
+ mlir::arith::NegFOp::create(builder, loc, lhs)};
}
};
@@ -1475,7 +1475,7 @@ struct UnaryOp<Fortran::evaluate::Negate<
static hlfir::EntityWithAttributes gen(mlir::Location loc,
fir::FirOpBuilder &builder, const Op &,
hlfir::Entity lhs) {
- return hlfir::EntityWithAttributes{builder.create<fir::NegcOp>(loc, lhs)};
+ return hlfir::EntityWithAttributes{fir::NegcOp::create(builder, loc, lhs)};
}
};
@@ -1499,9 +1499,9 @@ struct UnaryOp<Fortran::evaluate::Parentheses<T>> {
const Op &op, hlfir::Entity lhs) {
if (lhs.isVariable())
return hlfir::EntityWithAttributes{
- builder.create<hlfir::AsExprOp>(loc, lhs)};
+ hlfir::AsExprOp::create(builder, loc, lhs)};
return hlfir::EntityWithAttributes{
- builder.create<hlfir::NoReassocOp>(loc, lhs.getType(), lhs)};
+ hlfir::NoReassocOp::create(builder, loc, lhs.getType(), lhs)};
}
static void
@@ -1822,8 +1822,8 @@ class HlfirBuilder {
// Allocate scalar temporary that will be initialized
// with the values specified by the constructor.
mlir::Value storagePtr = builder.createTemporary(loc, recTy);
- auto varOp = hlfir::EntityWithAttributes{builder.create<hlfir::DeclareOp>(
- loc, storagePtr, "ctor.temp", /*shape=*/nullptr,
+ auto varOp = hlfir::EntityWithAttributes{hlfir::DeclareOp::create(
+ builder, loc, storagePtr, "ctor.temp", /*shape=*/nullptr,
/*typeparams=*/mlir::ValueRange{}, /*dummy_scope=*/nullptr,
fir::FortranVariableFlagsAttr{})};
@@ -1855,8 +1855,8 @@ class HlfirBuilder {
auto parentCompType = baseRecTy.getType(parentName);
assert(parentCompType && "failed to retrieve parent component type");
mlir::Type designatorType = builder.getRefType(parentCompType);
- mlir::Value newParent = builder.create<hlfir::DesignateOp>(
- loc, designatorType, currentParent, parentName,
+ mlir::Value newParent = hlfir::DesignateOp::create(
+ builder, loc, designatorType, currentParent, parentName,
/*compShape=*/mlir::Value{}, hlfir::DesignateOp::Subscripts{},
/*substring=*/mlir::ValueRange{},
/*complexPart=*/std::nullopt,
@@ -1912,8 +1912,8 @@ class HlfirBuilder {
extraAttributeFlags);
// Get the component designator.
- auto lhs = builder.create<hlfir::DesignateOp>(
- loc, designatorType, baseOp, name, compShape,
+ auto lhs = hlfir::DesignateOp::create(
+ builder, loc, designatorType, baseOp, name, compShape,
hlfir::DesignateOp::Subscripts{},
/*substring=*/mlir::ValueRange{},
/*complexPart=*/std::nullopt,
@@ -1997,10 +1997,10 @@ class HlfirBuilder {
auto rhsCastAndCleanup =
hlfir::genTypeAndKindConvert(loc, builder, rhs, lhs.getType(),
/*preserveLowerBounds=*/allowRealloc);
- builder.create<hlfir::AssignOp>(loc, rhsCastAndCleanup.first, lhs,
- allowRealloc,
- allowRealloc ? keepLhsLength : false,
- /*temporary_lhs=*/true);
+ hlfir::AssignOp::create(builder, loc, rhsCastAndCleanup.first, lhs,
+ allowRealloc,
+ allowRealloc ? keepLhsLength : false,
+ /*temporary_lhs=*/true);
if (rhsCastAndCleanup.second)
(*rhsCastAndCleanup.second)();
};
diff --git a/flang/lib/Lower/ConvertProcedureDesignator.cpp b/flang/lib/Lower/ConvertProcedureDesignator.cpp
index b528544ec245c..d4c535d71cb5f 100644
--- a/flang/lib/Lower/ConvertProcedureDesignator.cpp
+++ b/flang/lib/Lower/ConvertProcedureDesignator.cpp
@@ -49,7 +49,7 @@ fir::ExtendedValue Fortran::lower::convertProcedureDesignator(
fir::getUnrestrictedIntrinsicSymbolRefAttr(builder, loc, genericName,
signature);
mlir::Value funcPtr =
- builder.create<fir::AddrOfOp>(loc, signature, symbolRefAttr);
+ fir::AddrOfOp::create(builder, loc, signature, symbolRefAttr);
return funcPtr;
}
const Fortran::semantics::Symbol *symbol = proc.GetSymbol();
@@ -69,7 +69,7 @@ fir::ExtendedValue Fortran::lower::convertProcedureDesignator(
Fortran::lower::getOrDeclareFunction(proc, converter);
mlir::SymbolRefAttr nameAttr = builder.getSymbolRefAttr(func.getSymName());
funcPtr =
- builder.create<fir::AddrOfOp>(loc, func.getFunctionType(), nameAttr);
+ fir::AddrOfOp::create(builder, loc, func.getFunctionType(), nameAttr);
}
if (Fortran::lower::mustPassLengthWithDummyProcedure(proc, converter)) {
// The result length, if available here, must be propagated along the
@@ -114,7 +114,7 @@ static hlfir::EntityWithAttributes designateProcedurePointerComponent(
/// Passed argument may be a descriptor. This is a scalar reference, so the
/// base address can be directly addressed.
if (mlir::isa<fir::BaseBoxType>(base.getType()))
- base = builder.create<fir::BoxAddrOp>(loc, base);
+ base = fir::BoxAddrOp::create(builder, loc, base);
std::string fieldName = converter.getRecordTypeFieldName(procComponentSym);
auto recordType =
mlir::cast<fir::RecordType>(hlfir::getFortranElementType(base.getType()));
@@ -124,8 +124,8 @@ static hlfir::EntityWithAttributes designateProcedurePointerComponent(
if (!fieldType)
TODO(loc, "passing type bound procedure (extension)");
mlir::Type designatorType = fir::ReferenceType::get(fieldType);
- mlir::Value compRef = builder.create<hlfir::DesignateOp>(
- loc, designatorType, base, fieldName,
+ mlir::Value compRef = hlfir::DesignateOp::create(
+ builder, loc, designatorType, base, fieldName,
/*compShape=*/mlir::Value{}, hlfir::DesignateOp::Subscripts{},
/*substring=*/mlir::ValueRange{},
/*complexPart=*/std::nullopt,
@@ -174,10 +174,10 @@ hlfir::EntityWithAttributes Fortran::lower::convertProcedureDesignatorToHLFIR(
mlir::Type boxTy =
Fortran::lower::getUntypedBoxProcType(&converter.getMLIRContext());
if (auto host = Fortran::lower::argumentHostAssocs(converter, funcAddr))
- funcAddr = builder.create<fir::EmboxProcOp>(
- loc, boxTy, llvm::ArrayRef<mlir::Value>{funcAddr, host});
+ funcAddr = fir::EmboxProcOp::create(
+ builder, loc, boxTy, llvm::ArrayRef<mlir::Value>{funcAddr, host});
else
- funcAddr = builder.create<fir::EmboxProcOp>(loc, boxTy, funcAddr);
+ funcAddr = fir::EmboxProcOp::create(builder, loc, boxTy, funcAddr);
}
mlir::Value res = procExv.match(
diff --git a/flang/lib/Lower/ConvertVariable.cpp b/flang/lib/Lower/ConvertVariable.cpp
index cacf4e249aa28..647bd0d079985 100644
--- a/flang/lib/Lower/ConvertVariable.cpp
+++ b/flang/lib/Lower/ConvertVariable.cpp
@@ -312,8 +312,8 @@ mlir::Value Fortran::lower::genInitialDataTarget(
// initial value of the descriptor).
// Create a fir.rebox to set the attribute correctly, and use targetShift
// to preserve the target lower bounds if any.
- return builder.create<fir::ReboxOp>(loc, boxType, targetBox, targetShift,
- /*slice=*/mlir::Value{});
+ return fir::ReboxOp::create(builder, loc, boxType, targetBox, targetShift,
+ /*slice=*/mlir::Value{});
}
/// Generate default initial value for a derived type object \p sym with mlir
@@ -362,7 +362,7 @@ static mlir::Value genComponentDefaultInit(
} else {
// Component has no initial value. Set its bits to zero by extension
// to match what is expected because other compilers are doing it.
- componentValue = builder.create<fir::ZeroOp>(loc, componentTy);
+ componentValue = fir::ZeroOp::create(builder, loc, componentTy);
}
} else if (const auto *proc{
component
@@ -377,17 +377,17 @@ static mlir::Value genComponentDefaultInit(
componentValue =
fir::factory::createNullBoxProc(builder, loc, componentTy);
} else
- componentValue = builder.create<fir::ZeroOp>(loc, componentTy);
+ componentValue = fir::ZeroOp::create(builder, loc, componentTy);
}
assert(componentValue && "must have been computed");
componentValue = builder.createConvert(loc, componentTy, componentValue);
auto fieldTy = fir::FieldType::get(recTy.getContext());
// FIXME: type parameters must come from the derived-type-spec
- auto field = builder.create<fir::FieldIndexOp>(
- loc, fieldTy, name, recTy,
- /*typeParams=*/mlir::ValueRange{} /*TODO*/);
- return builder.create<fir::InsertValueOp>(
- loc, recTy, insertInto, componentValue,
+ auto field =
+ fir::FieldIndexOp::create(builder, loc, fieldTy, name, recTy,
+ /*typeParams=*/mlir::ValueRange{} /*TODO*/);
+ return fir::InsertValueOp::create(
+ builder, loc, recTy, insertInto, componentValue,
builder.getArrayAttr(field.getAttributes()));
}
@@ -405,7 +405,7 @@ static mlir::Value genDefaultInitializerValue(
// Build a scalar default value of the symbol type, looping through the
// components to build each component initial value.
auto recTy = mlir::cast<fir::RecordType>(scalarType);
- mlir::Value initialValue = builder.create<fir::UndefOp>(loc, scalarType);
+ mlir::Value initialValue = fir::UndefOp::create(builder, loc, scalarType);
const Fortran::semantics::DeclTypeSpec *declTy = sym.GetType();
assert(declTy && "var with default initialization must have a type");
@@ -444,7 +444,7 @@ static mlir::Value genDefaultInitializerValue(
if (sequenceType) {
// For arrays, duplicate the scalar value to all elements with an
// fir.insert_range covering the whole array.
- auto arrayInitialValue = builder.create<fir::UndefOp>(loc, sequenceType);
+ auto arrayInitialValue = fir::UndefOp::create(builder, loc, sequenceType);
llvm::SmallVector<int64_t> rangeBounds;
for (int64_t extent : sequenceType.getShape()) {
if (extent == fir::SequenceType::getUnknownExtent())
@@ -453,8 +453,8 @@ static mlir::Value genDefaultInitializerValue(
rangeBounds.push_back(0);
rangeBounds.push_back(extent - 1);
}
- return builder.create<fir::InsertOnRangeOp>(
- loc, sequenceType, arrayInitialValue, initialValue,
+ return fir::InsertOnRangeOp::create(
+ builder, loc, sequenceType, arrayInitialValue, initialValue,
builder.getIndexVectorAttr(rangeBounds));
}
return initialValue;
@@ -546,7 +546,7 @@ fir::GlobalOp Fortran::lower::defineGlobal(
createGlobalInitialization(builder, global, [&](fir::FirOpBuilder &b) {
mlir::Value box =
Fortran::lower::genInitialDataTarget(converter, loc, symTy, expr);
- b.create<fir::HasValueOp>(loc, box);
+ fir::HasValueOp::create(b, loc, box);
});
} else {
// Create unallocated/disassociated descriptor if no explicit init
@@ -555,7 +555,7 @@ fir::GlobalOp Fortran::lower::defineGlobal(
b, loc, symTy,
/*nonDeferredParams=*/{},
/*typeSourceBox=*/{}, getAllocatorIdxFromDataAttr(dataAttr));
- b.create<fir::HasValueOp>(loc, box);
+ fir::HasValueOp::create(b, loc, box);
});
}
} else if (const auto *details =
@@ -569,7 +569,7 @@ fir::GlobalOp Fortran::lower::defineGlobal(
converter, loc, details->init().value(), stmtCtx);
mlir::Value castTo =
builder.createConvert(loc, symTy, fir::getBase(initVal));
- builder.create<fir::HasValueOp>(loc, castTo);
+ fir::HasValueOp::create(builder, loc, castTo);
});
} else if (Fortran::lower::hasDefaultInitialization(sym)) {
createGlobalInitialization(
@@ -579,7 +579,7 @@ fir::GlobalOp Fortran::lower::defineGlobal(
mlir::Value initVal =
genDefaultInitializerValue(converter, loc, sym, symTy, stmtCtx);
mlir::Value castTo = builder.createConvert(loc, symTy, initVal);
- builder.create<fir::HasValueOp>(loc, castTo);
+ fir::HasValueOp::create(builder, loc, castTo);
});
}
} else if (Fortran::semantics::IsProcedurePointer(sym)) {
@@ -594,19 +594,19 @@ fir::GlobalOp Fortran::lower::defineGlobal(
auto box{Fortran::lower::convertProcedureDesignatorInitialTarget(
converter, loc, *sym)};
auto castTo{builder.createConvert(loc, symTy, box)};
- b.create<fir::HasValueOp>(loc, castTo);
+ fir::HasValueOp::create(b, loc, castTo);
});
else { // Has NULL() target.
createGlobalInitialization(builder, global, [&](fir::FirOpBuilder &b) {
auto box{fir::factory::createNullBoxProc(b, loc, symTy)};
- b.create<fir::HasValueOp>(loc, box);
+ fir::HasValueOp::create(b, loc, box);
});
}
} else {
// No initialization.
createGlobalInitialization(builder, global, [&](fir::FirOpBuilder &b) {
auto box{fir::factory::createNullBoxProc(b, loc, symTy)};
- b.create<fir::HasValueOp>(loc, box);
+ fir::HasValueOp::create(b, loc, box);
});
}
} else if (sym.has<Fortran::semantics::CommonBlockDetails>()) {
@@ -632,10 +632,10 @@ fir::GlobalOp Fortran::lower::defineGlobal(
builder, global, [&](fir::FirOpBuilder &builder) {
mlir::Value initValue;
if (converter.getLoweringOptions().getInitGlobalZero())
- initValue = builder.create<fir::ZeroOp>(loc, symTy);
+ initValue = fir::ZeroOp::create(builder, loc, symTy);
else
- initValue = builder.create<fir::UndefOp>(loc, symTy);
- builder.create<fir::HasValueOp>(loc, initValue);
+ initValue = fir::UndefOp::create(builder, loc, symTy);
+ fir::HasValueOp::create(builder, loc, initValue);
});
}
// Set public visibility to prevent global definition to be optimized out
@@ -690,8 +690,8 @@ static void instantiateGlobal(Fortran::lower::AbstractConverter &converter,
sym);
global = defineGlobal(converter, var, globalName, linkage, dataAttr);
}
- auto addrOf = builder.create<fir::AddrOfOp>(loc, global.resultType(),
- global.getSymbol());
+ auto addrOf = fir::AddrOfOp::create(builder, loc, global.resultType(),
+ global.getSymbol());
// The type of the global cannot be trusted to be the same as the one
// of the variable as some existing programs map common blocks to
// BIND(C) module variables (e.g. mpi_argv_null in MPI and MPI_F08).
@@ -752,7 +752,7 @@ static mlir::Value createNewLocal(Fortran::lower::AbstractConverter &converter,
// would be a waste of space, and incorrect if the pointee is a non dummy
// assumed-size (possible with cray pointee).
if (ultimateSymbol.test(Fortran::semantics::Symbol::Flag::CrayPointee))
- return builder.create<fir::ZeroOp>(loc, fir::ReferenceType::get(ty));
+ return fir::ZeroOp::create(builder, loc, fir::ReferenceType::get(ty));
if (needCUDAAlloc(ultimateSymbol)) {
cuf::DataAttributeAttr dataAttr =
@@ -767,12 +767,12 @@ static mlir::Value createNewLocal(Fortran::lower::AbstractConverter &converter,
for (mlir::Value sh : elidedShape)
indices.push_back(builder.createConvert(loc, idxTy, sh));
if (dataAttr.getValue() == cuf::DataAttribute::Shared)
- return builder.create<cuf::SharedMemoryOp>(loc, ty, nm, symNm, lenParams,
- indices);
+ return cuf::SharedMemoryOp::create(builder, loc, ty, nm, symNm, lenParams,
+ indices);
if (!cuf::isCUDADeviceContext(builder.getRegion()))
- return builder.create<cuf::AllocOp>(loc, ty, nm, symNm, dataAttr,
- lenParams, indices);
+ return cuf::AllocOp::create(builder, loc, ty, nm, symNm, dataAttr,
+ lenParams, indices);
}
// Let the builder do all the heavy lifting.
@@ -782,7 +782,7 @@ static mlir::Value createNewLocal(Fortran::lower::AbstractConverter &converter,
// Local procedure pointer.
auto res{builder.allocateLocal(loc, ty, nm, symNm, shape, lenParams, isTarg)};
auto box{fir::factory::createNullBoxProc(builder, loc, ty)};
- builder.create<fir::StoreOp>(loc, box, res);
+ fir::StoreOp::create(builder, loc, box, res);
return res;
}
@@ -833,9 +833,9 @@ initializeDeviceComponentAllocator(Fortran::lower::AbstractConverter &converter,
// Field found in the base record type.
auto fieldName = recTy.getTypeList()[fieldIdx].first;
fieldTy = recTy.getTypeList()[fieldIdx].second;
- mlir::Value fieldIndex = builder.create<fir::FieldIndexOp>(
- loc, fir::FieldType::get(fieldTy.getContext()), fieldName,
- recTy,
+ mlir::Value fieldIndex = fir::FieldIndexOp::create(
+ builder, loc, fir::FieldType::get(fieldTy.getContext()),
+ fieldName, recTy,
/*typeParams=*/mlir::ValueRange{});
coordinates.push_back(fieldIndex);
} else {
@@ -846,19 +846,18 @@ initializeDeviceComponentAllocator(Fortran::lower::AbstractConverter &converter,
mlir::dyn_cast<fir::RecordType>(component.second)) {
fieldIdx = childRecTy.getFieldIndex(sym.name().ToString());
if (fieldIdx != std::numeric_limits<unsigned>::max()) {
- mlir::Value parentFieldIndex =
- builder.create<fir::FieldIndexOp>(
- loc, fir::FieldType::get(childRecTy.getContext()),
- component.first, recTy,
- /*typeParams=*/mlir::ValueRange{});
+ mlir::Value parentFieldIndex = fir::FieldIndexOp::create(
+ builder, loc,
+ fir::FieldType::get(childRecTy.getContext()),
+ component.first, recTy,
+ /*typeParams=*/mlir::ValueRange{});
coordinates.push_back(parentFieldIndex);
auto fieldName = childRecTy.getTypeList()[fieldIdx].first;
fieldTy = childRecTy.getTypeList()[fieldIdx].second;
- mlir::Value childFieldIndex =
- builder.create<fir::FieldIndexOp>(
- loc, fir::FieldType::get(fieldTy.getContext()),
- fieldName, childRecTy,
- /*typeParams=*/mlir::ValueRange{});
+ mlir::Value childFieldIndex = fir::FieldIndexOp::create(
+ builder, loc, fir::FieldType::get(fieldTy.getContext()),
+ fieldName, childRecTy,
+ /*typeParams=*/mlir::ValueRange{});
coordinates.push_back(childFieldIndex);
break;
}
@@ -873,25 +872,25 @@ initializeDeviceComponentAllocator(Fortran::lower::AbstractConverter &converter,
mlir::Value base = fir::getBase(exv);
mlir::Value comp;
if (mlir::isa<fir::BaseBoxType>(fir::unwrapRefType(base.getType()))) {
- mlir::Value box = builder.create<fir::LoadOp>(loc, base);
- mlir::Value addr = builder.create<fir::BoxAddrOp>(loc, box);
+ mlir::Value box = fir::LoadOp::create(builder, loc, base);
+ mlir::Value addr = fir::BoxAddrOp::create(builder, loc, box);
llvm::SmallVector<mlir::Value> lenParams;
assert(coordinates.size() == 1 && "expect one coordinate");
auto field = mlir::dyn_cast<fir::FieldIndexOp>(
coordinates[0].getDefiningOp());
- comp = builder.create<hlfir::DesignateOp>(
- loc, builder.getRefType(fieldTy), addr,
+ comp = hlfir::DesignateOp::create(
+ builder, loc, builder.getRefType(fieldTy), addr,
/*component=*/field.getFieldName(),
/*componentShape=*/mlir::Value{},
hlfir::DesignateOp::Subscripts{});
} else {
- comp = builder.create<fir::CoordinateOp>(
- loc, builder.getRefType(fieldTy), base, coordinates);
+ comp = fir::CoordinateOp::create(
+ builder, loc, builder.getRefType(fieldTy), base, coordinates);
}
cuf::DataAttributeAttr dataAttr =
Fortran::lower::translateSymbolCUFDataAttribute(
builder.getContext(), sym);
- builder.create<cuf::SetAllocatorIndexOp>(loc, comp, dataAttr);
+ cuf::SetAllocatorIndexOp::create(builder, loc, comp, dataAttr);
}
}
}
@@ -933,8 +932,8 @@ void Fortran::lower::defaultInitializeAtRuntime(
// 15.5.2.12 point 3, absent optional dummies are not initialized.
// Creating descriptor/passing null descriptor to the runtime would
// create runtime crashes.
- auto isPresent = builder.create<fir::IsPresentOp>(loc, builder.getI1Type(),
- fir::getBase(exv));
+ auto isPresent = fir::IsPresentOp::create(builder, loc, builder.getI1Type(),
+ fir::getBase(exv));
builder.genIfThen(loc, isPresent)
.genThen([&]() {
auto box = builder.createBox(loc, exv);
@@ -976,7 +975,7 @@ void Fortran::lower::defaultInitializeAtRuntime(
converter, loc, details->init().value(), stmtCtx);
mlir::Value castTo =
builder.createConvert(loc, symTy, fir::getBase(initVal));
- builder.create<fir::HasValueOp>(loc, castTo);
+ fir::HasValueOp::create(builder, loc, castTo);
});
} else if (!global) {
global = builder.createGlobal(loc, symTy, globalName, linkage,
@@ -991,13 +990,13 @@ void Fortran::lower::defaultInitializeAtRuntime(
mlir::Value initVal = genDefaultInitializerValue(
converter, loc, sym, symTy, stmtCtx);
mlir::Value castTo = builder.createConvert(loc, symTy, initVal);
- builder.create<fir::HasValueOp>(loc, castTo);
+ fir::HasValueOp::create(builder, loc, castTo);
});
}
- auto addrOf = builder.create<fir::AddrOfOp>(loc, global.resultType(),
- global.getSymbol());
- builder.create<fir::CopyOp>(loc, addrOf, fir::getBase(exv),
- /*noOverlap=*/true);
+ auto addrOf = fir::AddrOfOp::create(builder, loc, global.resultType(),
+ global.getSymbol());
+ fir::CopyOp::create(builder, loc, addrOf, fir::getBase(exv),
+ /*noOverlap=*/true);
} else {
mlir::Value box = builder.createBox(loc, exv);
fir::runtime::genDerivedTypeInitialize(builder, loc, box);
@@ -1097,8 +1096,8 @@ static void finalizeAtRuntime(Fortran::lower::AbstractConverter &converter,
fir::ExtendedValue exv = converter.getSymbolExtendedValue(sym, &symMap);
if (Fortran::semantics::IsOptional(sym)) {
// Only finalize if present.
- auto isPresent = builder.create<fir::IsPresentOp>(loc, builder.getI1Type(),
- fir::getBase(exv));
+ auto isPresent = fir::IsPresentOp::create(builder, loc, builder.getI1Type(),
+ fir::getBase(exv));
builder.genIfThen(loc, isPresent)
.genThen([&]() {
auto box = builder.createBox(loc, exv);
@@ -1144,8 +1143,8 @@ static void deallocateIntentOut(Fortran::lower::AbstractConverter &converter,
fir::FirOpBuilder &builder = converter.getFirOpBuilder();
if (Fortran::semantics::IsOptional(sym)) {
- auto isPresent = builder.create<fir::IsPresentOp>(
- loc, builder.getI1Type(), fir::getBase(extVal));
+ auto isPresent = fir::IsPresentOp::create(
+ builder, loc, builder.getI1Type(), fir::getBase(extVal));
builder.genIfThen(loc, isPresent)
.genThen([&]() {
Fortran::lower::genDeallocateIfAllocated(converter, *mutBox, loc);
@@ -1358,7 +1357,7 @@ static fir::GlobalOp defineGlobalAggregateStore(
Fortran::lower::StatementContext stmtCtx;
mlir::Value initVal = fir::getBase(genInitializerExprValue(
converter, loc, objectDetails->init().value(), stmtCtx));
- builder.create<fir::HasValueOp>(loc, initVal);
+ fir::HasValueOp::create(builder, loc, initVal);
});
return global;
}
@@ -1367,8 +1366,8 @@ static fir::GlobalOp defineGlobalAggregateStore(
// of the linkage.
createGlobalInitialization(builder, global, [&](fir::FirOpBuilder &builder) {
Fortran::lower::StatementContext stmtCtx;
- mlir::Value initVal = builder.create<fir::ZeroOp>(loc, aggTy);
- builder.create<fir::HasValueOp>(loc, initVal);
+ mlir::Value initVal = fir::ZeroOp::create(builder, loc, aggTy);
+ fir::HasValueOp::create(builder, loc, initVal);
});
return global;
}
@@ -1418,8 +1417,8 @@ instantiateAggregateStore(Fortran::lower::AbstractConverter &converter,
global =
defineGlobalAggregateStore(converter, aggregate, aggName, linkage);
}
- auto addr = builder.create<fir::AddrOfOp>(loc, global.resultType(),
- global.getSymbol());
+ auto addr = fir::AddrOfOp::create(builder, loc, global.resultType(),
+ global.getSymbol());
auto size = std::get<1>(var.getInterval());
fir::SequenceType::Shape shape(1, size);
auto seqTy = fir::SequenceType::get(shape, i8Ty);
@@ -1466,8 +1465,8 @@ static void instantiateAlias(Fortran::lower::AbstractConverter &converter,
std::size_t off = sym.GetUltimate().offset() - var.getAliasOffset();
mlir::Value storeAddr = getAggregateStore(storeMap, var);
mlir::Value offset = builder.createIntegerConstant(loc, idxTy, off);
- mlir::Value bytePtr = builder.create<fir::CoordinateOp>(
- loc, i8Ptr, storeAddr, mlir::ValueRange{offset});
+ mlir::Value bytePtr = fir::CoordinateOp::create(
+ builder, loc, i8Ptr, storeAddr, mlir::ValueRange{offset});
mlir::Value typedPtr = castAliasToPointer(builder, loc, symType, bytePtr);
Fortran::lower::StatementContext stmtCtx;
mapSymbolAttributes(converter, var, symMap, stmtCtx, typedPtr);
@@ -1656,7 +1655,7 @@ static void finalizeCommonBlockDefinition(
mlir::TupleType commonTy = mlir::cast<mlir::TupleType>(global.getType());
auto initFunc = [&](fir::FirOpBuilder &builder) {
mlir::IndexType idxTy = builder.getIndexType();
- mlir::Value cb = builder.create<fir::ZeroOp>(loc, commonTy);
+ mlir::Value cb = fir::ZeroOp::create(builder, loc, commonTy);
unsigned tupIdx = 0;
std::size_t offset = 0;
LLVM_DEBUG(llvm::dbgs() << "block {\n");
@@ -1680,15 +1679,15 @@ static void finalizeCommonBlockDefinition(
mlir::IntegerAttr offVal = builder.getIntegerAttr(idxTy, tupIdx);
mlir::Value castVal = builder.createConvert(
loc, commonTy.getType(tupIdx), fir::getBase(initVal));
- cb = builder.create<fir::InsertValueOp>(loc, commonTy, cb, castVal,
- builder.getArrayAttr(offVal));
+ cb = fir::InsertValueOp::create(builder, loc, commonTy, cb, castVal,
+ builder.getArrayAttr(offVal));
++tupIdx;
offset = mem->offset() + mem->size();
}
}
}
LLVM_DEBUG(llvm::dbgs() << "}\n");
- builder.create<fir::HasValueOp>(loc, cb);
+ fir::HasValueOp::create(builder, loc, cb);
};
createGlobalInitialization(builder, global, initFunc);
}
@@ -1722,8 +1721,8 @@ mlir::Value Fortran::lower::genCommonBlockMember(
mlir::Value offs =
builder.createIntegerConstant(loc, builder.getIndexType(), byteOffset);
- mlir::Value varAddr = builder.create<fir::CoordinateOp>(
- loc, i8Ptr, base, mlir::ValueRange{offs});
+ mlir::Value varAddr = fir::CoordinateOp::create(builder, loc, i8Ptr, base,
+ mlir::ValueRange{offs});
mlir::Type symType = converter.genType(sym);
return Fortran::semantics::FindEquivalenceSet(sym) != nullptr
@@ -1748,8 +1747,8 @@ static void instantiateCommon(Fortran::lower::AbstractConverter &converter,
if (!commonAddr) {
// introduce a local AddrOf and add it to the map
fir::GlobalOp global = getCommonBlockGlobal(converter, common);
- commonAddr = builder.create<fir::AddrOfOp>(loc, global.resultType(),
- global.getSymbol());
+ commonAddr = fir::AddrOfOp::create(builder, loc, global.resultType(),
+ global.getSymbol());
symMap.addSymbol(common, commonAddr);
}
@@ -2031,8 +2030,8 @@ static void genDeclareSymbol(Fortran::lower::AbstractConverter &converter,
Fortran::semantics::GetCUDADataAttr(&sym.GetUltimate()));
// Declare a local pointer variable.
- auto newBase = builder.create<hlfir::DeclareOp>(
- loc, boxAlloc, name, /*shape=*/nullptr, lenParams,
+ auto newBase = hlfir::DeclareOp::create(
+ builder, loc, boxAlloc, name, /*shape=*/nullptr, lenParams,
/*dummy_scope=*/nullptr, attributes);
mlir::Value nullAddr = builder.createNullConstant(
loc, llvm::cast<fir::BaseBoxType>(ptrBoxType).getEleTy());
@@ -2047,9 +2046,9 @@ static void genDeclareSymbol(Fortran::lower::AbstractConverter &converter,
// Inherit the shape (and maybe length parameters) from the pointee
// declaration.
mlir::Value initVal =
- builder.create<fir::EmboxOp>(loc, ptrBoxType, nullAddr, shapeOrShift,
- /*slice=*/nullptr, lenParams);
- builder.create<fir::StoreOp>(loc, initVal, newBase.getBase());
+ fir::EmboxOp::create(builder, loc, ptrBoxType, nullAddr, shapeOrShift,
+ /*slice=*/nullptr, lenParams);
+ fir::StoreOp::create(builder, loc, initVal, newBase.getBase());
// Any reference to the pointee is going to be using the pointer
// box from now on. The base_addr of the descriptor must be updated
@@ -2063,9 +2062,9 @@ static void genDeclareSymbol(Fortran::lower::AbstractConverter &converter,
mlir::Value dummyScope;
if (converter.isRegisteredDummySymbol(sym))
dummyScope = converter.dummyArgsScopeValue();
- auto newBase = builder.create<hlfir::DeclareOp>(
- loc, base, name, shapeOrShift, lenParams, dummyScope, attributes,
- dataAttr);
+ auto newBase =
+ hlfir::DeclareOp::create(builder, loc, base, name, shapeOrShift,
+ lenParams, dummyScope, attributes, dataAttr);
symMap.addVariableDefinition(sym, newBase, force);
return;
}
@@ -2214,7 +2213,7 @@ void Fortran::lower::mapSymbolAttributes(
// Additional discussion below.
mlir::Type dummyProcType =
Fortran::lower::getDummyProcedureType(sym, converter);
- mlir::Value undefOp = builder.create<fir::UndefOp>(loc, dummyProcType);
+ mlir::Value undefOp = fir::UndefOp::create(builder, loc, dummyProcType);
Fortran::lower::genDeclareSymbol(converter, symMap, sym, undefOp);
}
@@ -2304,32 +2303,32 @@ void Fortran::lower::mapSymbolAttributes(
mlir::Type lenType = builder.getCharacterLengthType();
mlir::Value addr, len;
if (Fortran::semantics::IsOptional(sym)) {
- auto isPresent = builder.create<fir::IsPresentOp>(
- loc, builder.getI1Type(), dummyArg);
+ auto isPresent = fir::IsPresentOp::create(
+ builder, loc, builder.getI1Type(), dummyArg);
auto addrAndLen =
builder
.genIfOp(loc, {refTy, lenType}, isPresent,
/*withElseRegion=*/true)
.genThen([&]() {
mlir::Value readAddr =
- builder.create<fir::BoxAddrOp>(loc, refTy, dummyArg);
+ fir::BoxAddrOp::create(builder, loc, refTy, dummyArg);
mlir::Value readLength =
charHelp.readLengthFromBox(dummyArg);
- builder.create<fir::ResultOp>(
- loc, mlir::ValueRange{readAddr, readLength});
+ fir::ResultOp::create(
+ builder, loc, mlir::ValueRange{readAddr, readLength});
})
.genElse([&] {
mlir::Value readAddr = builder.genAbsentOp(loc, refTy);
mlir::Value readLength =
fir::factory::createZeroValue(builder, loc, lenType);
- builder.create<fir::ResultOp>(
- loc, mlir::ValueRange{readAddr, readLength});
+ fir::ResultOp::create(
+ builder, loc, mlir::ValueRange{readAddr, readLength});
})
.getResults();
addr = addrAndLen[0];
len = addrAndLen[1];
} else {
- addr = builder.create<fir::BoxAddrOp>(loc, refTy, dummyArg);
+ addr = fir::BoxAddrOp::create(builder, loc, refTy, dummyArg);
len = charHelp.readLengthFromBox(dummyArg);
}
if (!explicitParams.empty())
@@ -2428,7 +2427,7 @@ void Fortran::lower::mapSymbolAttributes(
mlir::Value dim =
builder.createIntegerConstant(loc, idxTy, iter.index());
auto dimInfo =
- builder.create<fir::BoxDimsOp>(loc, idxTy, idxTy, idxTy, box, dim);
+ fir::BoxDimsOp::create(builder, loc, idxTy, idxTy, idxTy, box, dim);
shapes.emplace_back(dimInfo.getResult(1));
} else if (spec->ubound().isStar()) {
shapes.emplace_back(getAssumedSizeExtent(loc, builder));
@@ -2452,7 +2451,7 @@ void Fortran::lower::mapSymbolAttributes(
mlir::Value dim =
builder.createIntegerConstant(loc, idxTy, iter.index());
dimInfo =
- builder.create<fir::BoxDimsOp>(loc, idxTy, idxTy, idxTy, box, dim);
+ fir::BoxDimsOp::create(builder, loc, idxTy, idxTy, idxTy, box, dim);
extents.emplace_back(dimInfo.getResult(1));
if (auto low = spec->lbound().GetExplicit()) {
auto expr = Fortran::lower::SomeExpr{*low};
@@ -2501,7 +2500,7 @@ void Fortran::lower::mapSymbolAttributes(
if (auto boxTy = mlir::dyn_cast<fir::BaseBoxType>(arg.getType())) {
// Contiguous assumed shape that can be tracked without a fir.box.
mlir::Type refTy = builder.getRefType(boxTy.getEleTy());
- addr = builder.create<fir::BoxAddrOp>(loc, refTy, arg);
+ addr = fir::BoxAddrOp::create(builder, loc, refTy, arg);
}
// Compute/Extract character length.
@@ -2512,8 +2511,8 @@ void Fortran::lower::mapSymbolAttributes(
std::tie(addr, len) = charHelp.createUnboxChar(arg);
} else if (mlir::isa<fir::CharacterType>(arg.getType())) {
// fir.char<1> passed by value (BIND(C) with VALUE attribute).
- addr = builder.create<fir::AllocaOp>(loc, arg.getType());
- builder.create<fir::StoreOp>(loc, arg, addr);
+ addr = fir::AllocaOp::create(builder, loc, arg.getType());
+ fir::StoreOp::create(builder, loc, arg, addr);
} else if (!addr) {
addr = arg;
}
@@ -2583,7 +2582,7 @@ void Fortran::lower::mapSymbolAttributes(
// Dummy argument passed in register. Place the value in memory at that
// point since lowering expect symbols to be mapped to memory addresses.
mlir::Type symType = converter.genType(sym);
- addr = builder.create<fir::AllocaOp>(loc, symType);
+ addr = fir::AllocaOp::create(builder, loc, symType);
if (isCptrByVal) {
// Place the void* address into the CPTR address component.
mlir::Value addrComponent =
@@ -2803,8 +2802,8 @@ Fortran::lower::genPackArray(Fortran::lower::AbstractConverter &converter,
mlir::Type elementType = boxType.unwrapInnerType();
llvm::SmallVector<mlir::Value> elidedLenParams =
fir::factory::elideLengthsAlreadyInType(elementType, lenParams);
- auto packOp = builder.create<fir::PackArrayOp>(
- loc, fir::getBase(exv), stackAlloc, isInnermostMode, noCopy,
+ auto packOp = fir::PackArrayOp::create(
+ builder, loc, fir::getBase(exv), stackAlloc, isInnermostMode, noCopy,
/*max_size=*/mlir::IntegerAttr{},
/*max_element_size=*/mlir::IntegerAttr{},
/*min_stride=*/mlir::IntegerAttr{}, fir::PackArrayHeuristics::None,
@@ -2842,6 +2841,6 @@ void Fortran::lower::genUnpackArray(
// Avoid copy-out for 'intent(in)' variables.
bool noCopy = Fortran::semantics::IsIntentIn(sym);
fir::FirOpBuilder &builder = converter.getFirOpBuilder();
- builder.create<fir::UnpackArrayOp>(loc, temp, original, stackAlloc, noCopy,
- getSafeRepackAttrs(converter));
+ fir::UnpackArrayOp::create(builder, loc, temp, original, stackAlloc, noCopy,
+ getSafeRepackAttrs(converter));
}
diff --git a/flang/lib/Lower/CustomIntrinsicCall.cpp b/flang/lib/Lower/CustomIntrinsicCall.cpp
index 30c6ce7f53b3f..2c5233bdd15ee 100644
--- a/flang/lib/Lower/CustomIntrinsicCall.cpp
+++ b/flang/lib/Lower/CustomIntrinsicCall.cpp
@@ -101,7 +101,7 @@ Fortran::lower::genIntrinsicCall(fir::FirOpBuilder &builder, mlir::Location loc,
mlir::Value addr = fir::getBase(result);
if (auto *box = result.getBoxOf<fir::BoxValue>())
addr =
- builder.create<fir::BoxAddrOp>(loc, box->getMemTy(), box->getAddr());
+ fir::BoxAddrOp::create(builder, loc, box->getMemTy(), box->getAddr());
fir::FirOpBuilder *bldr = &builder;
stmtCtx.attachCleanup([=]() { bldr->create<fir::FreeMemOp>(loc, addr); });
}
@@ -171,9 +171,9 @@ lowerMinOrMax(fir::FirOpBuilder &builder, mlir::Location loc,
args.emplace_back(getOperand(opIndex, loadOperand));
fir::ExtendedValue newExtremum = genIntrinsicCall(
builder, loc, name, resultType, args, stmtCtx);
- builder.create<fir::ResultOp>(loc, fir::getBase(newExtremum));
+ fir::ResultOp::create(builder, loc, fir::getBase(newExtremum));
})
- .genElse([&]() { builder.create<fir::ResultOp>(loc, extremum); })
+ .genElse([&]() { fir::ResultOp::create(builder, loc, extremum); })
.getResults()[0];
} else {
// Argument is know to be present at compile time.
@@ -235,13 +235,13 @@ lowerIshftc(fir::FirOpBuilder &builder, mlir::Location loc,
fir::ExtendedValue sizeExv = getOperand(2, loadOperand);
mlir::Value size =
builder.createConvert(loc, resultType, fir::getBase(sizeExv));
- builder.create<fir::ResultOp>(loc, size);
+ fir::ResultOp::create(builder, loc, size);
})
.genElse([&]() {
mlir::Value bitSize = builder.createIntegerConstant(
loc, resultType,
mlir::cast<mlir::IntegerType>(resultType).getWidth());
- builder.create<fir::ResultOp>(loc, bitSize);
+ fir::ResultOp::create(builder, loc, bitSize);
})
.getResults()[0]);
return genIntrinsicCall(builder, loc, name, resultType, args, stmtCtx);
@@ -280,7 +280,7 @@ lowerAssociated(fir::FirOpBuilder &builder, mlir::Location loc,
// while the optionality of the target pointer/allocatable is what must be
// checked here.
mlir::Value isPresent =
- builder.create<fir::IsPresentOp>(loc, builder.getI1Type(), targetBase);
+ fir::IsPresentOp::create(builder, loc, builder.getI1Type(), targetBase);
mlir::Type targetType = fir::unwrapRefType(targetBase.getType());
mlir::Type targetValueType = fir::unwrapPassByRefType(targetType);
mlir::Type boxType = mlir::isa<fir::BaseBoxType>(targetType)
@@ -293,11 +293,12 @@ lowerAssociated(fir::FirOpBuilder &builder, mlir::Location loc,
.genThen([&]() {
mlir::Value box = builder.createBox(loc, targetExv);
mlir::Value cast = builder.createConvert(loc, boxType, box);
- builder.create<fir::ResultOp>(loc, cast);
+ fir::ResultOp::create(builder, loc, cast);
})
.genElse([&]() {
- mlir::Value absentBox = builder.create<fir::AbsentOp>(loc, boxType);
- builder.create<fir::ResultOp>(loc, absentBox);
+ mlir::Value absentBox =
+ fir::AbsentOp::create(builder, loc, boxType);
+ fir::ResultOp::create(builder, loc, absentBox);
})
.getResults()[0];
args.emplace_back(std::move(targetBox));
diff --git a/flang/lib/Lower/HlfirIntrinsics.cpp b/flang/lib/Lower/HlfirIntrinsics.cpp
index 8b96b209ddb00..6e1d06a25924b 100644
--- a/flang/lib/Lower/HlfirIntrinsics.cpp
+++ b/flang/lib/Lower/HlfirIntrinsics.cpp
@@ -63,7 +63,7 @@ class HlfirTransformationalIntrinsic {
template <typename OP, typename... BUILD_ARGS>
inline OP createOp(BUILD_ARGS... args) {
- return builder.create<OP>(loc, args...);
+ return OP::create(builder, loc, args...);
}
mlir::Value loadBoxAddress(
@@ -195,7 +195,7 @@ mlir::Value HlfirTransformationalIntrinsic::loadBoxAddress(
// this is a box address type but is not dynamically optional. Just load
// the box, assuming it is well formed (!fir.ref<!fir.box<...>> ->
// !fir.box<...>)
- return builder.create<fir::LoadOp>(loc, actual.getBase());
+ return fir::LoadOp::create(builder, loc, actual.getBase());
}
return actual;
}
@@ -209,9 +209,9 @@ mlir::Value HlfirTransformationalIntrinsic::loadBoxAddress(
// ensures it won't be.
mlir::Value box = builder.createBox(loc, exv);
mlir::Type boxType = box.getType();
- auto absent = builder.create<fir::AbsentOp>(loc, boxType);
- auto boxOrAbsent = builder.create<mlir::arith::SelectOp>(
- loc, boxType, isPresent, box, absent);
+ auto absent = fir::AbsentOp::create(builder, loc, boxType);
+ auto boxOrAbsent = mlir::arith::SelectOp::create(builder, loc, boxType,
+ isPresent, box, absent);
return boxOrAbsent;
}
@@ -232,11 +232,11 @@ static mlir::Value loadOptionalValue(
assert(actual.isScalar() && fir::isa_trivial(eleType) &&
"must be a numerical or logical scalar");
hlfir::Entity val = hlfir::loadTrivialScalar(loc, builder, actual);
- builder.create<fir::ResultOp>(loc, val);
+ fir::ResultOp::create(builder, loc, val);
})
.genElse([&]() {
mlir::Value zero = fir::factory::createZeroValue(builder, loc, eleType);
- builder.create<fir::ResultOp>(loc, zero);
+ fir::ResultOp::create(builder, loc, zero);
})
.getResults()[0];
}
diff --git a/flang/lib/Lower/HostAssociations.cpp b/flang/lib/Lower/HostAssociations.cpp
index 95ea74b791b47..2a330ccc4eebb 100644
--- a/flang/lib/Lower/HostAssociations.cpp
+++ b/flang/lib/Lower/HostAssociations.cpp
@@ -165,7 +165,7 @@ class CapturedSimpleScalars : public CapturedSymbols<CapturedSimpleScalars> {
assert(typeInTuple && "addrInTuple must be an address");
mlir::Value castBox = builder.createConvertWithVolatileCast(
args.loc, typeInTuple, fir::getBase(args.hostValue));
- builder.create<fir::StoreOp>(args.loc, castBox, args.addrInTuple);
+ fir::StoreOp::create(builder, args.loc, castBox, args.addrInTuple);
}
static void getFromTuple(const GetFromTuple &args,
@@ -196,7 +196,7 @@ class CapturedProcedure : public CapturedSymbols<CapturedProcedure> {
assert(typeInTuple && "addrInTuple must be an address");
mlir::Value castBox = builder.createConvertWithVolatileCast(
args.loc, typeInTuple, fir::getBase(args.hostValue));
- builder.create<fir::StoreOp>(args.loc, castBox, args.addrInTuple);
+ fir::StoreOp::create(builder, args.loc, castBox, args.addrInTuple);
}
static void getFromTuple(const GetFromTuple &args,
@@ -231,7 +231,7 @@ class CapturedCharacterScalars
fir::FirOpBuilder &builder = converter.getFirOpBuilder();
mlir::Value boxchar = fir::factory::CharacterExprHelper(builder, args.loc)
.createEmbox(*charBox);
- builder.create<fir::StoreOp>(args.loc, boxchar, args.addrInTuple);
+ fir::StoreOp::create(builder, args.loc, boxchar, args.addrInTuple);
}
static void getFromTuple(const GetFromTuple &args,
@@ -269,20 +269,20 @@ class CapturedPolymorphicScalar
args.loc, typeInTuple, fir::getBase(args.hostValue));
if (Fortran::semantics::IsOptional(sym)) {
auto isPresent =
- builder.create<fir::IsPresentOp>(loc, builder.getI1Type(), castBox);
+ fir::IsPresentOp::create(builder, loc, builder.getI1Type(), castBox);
builder.genIfThenElse(loc, isPresent)
.genThen([&]() {
- builder.create<fir::StoreOp>(loc, castBox, args.addrInTuple);
+ fir::StoreOp::create(builder, loc, castBox, args.addrInTuple);
})
.genElse([&]() {
mlir::Value null = fir::factory::createUnallocatedBox(
builder, loc, typeInTuple,
/*nonDeferredParams=*/mlir::ValueRange{});
- builder.create<fir::StoreOp>(loc, null, args.addrInTuple);
+ fir::StoreOp::create(builder, loc, null, args.addrInTuple);
})
.end();
} else {
- builder.create<fir::StoreOp>(loc, castBox, args.addrInTuple);
+ fir::StoreOp::create(builder, loc, castBox, args.addrInTuple);
}
}
static void getFromTuple(const GetFromTuple &args,
@@ -297,11 +297,11 @@ class CapturedPolymorphicScalar
auto eleTy = boxTy.getEleTy();
if (!fir::isa_ref_type(eleTy))
eleTy = builder.getRefType(eleTy);
- auto addr = builder.create<fir::BoxAddrOp>(loc, eleTy, box);
+ auto addr = fir::BoxAddrOp::create(builder, loc, eleTy, box);
mlir::Value isPresent = builder.genIsNotNullAddr(loc, addr);
- auto absentBox = builder.create<fir::AbsentOp>(loc, boxTy);
- box =
- builder.create<mlir::arith::SelectOp>(loc, isPresent, box, absentBox);
+ auto absentBox = fir::AbsentOp::create(builder, loc, boxTy);
+ box = mlir::arith::SelectOp::create(builder, loc, isPresent, box,
+ absentBox);
}
bindCapturedSymbol(sym, box, converter, args.symMap);
}
@@ -331,7 +331,7 @@ class CapturedAllocatableAndPointer
assert(typeInTuple && "addrInTuple must be an address");
mlir::Value castBox = builder.createConvertWithVolatileCast(
args.loc, typeInTuple, fir::getBase(args.hostValue));
- builder.create<fir::StoreOp>(args.loc, castBox, args.addrInTuple);
+ fir::StoreOp::create(builder, args.loc, castBox, args.addrInTuple);
}
static void getFromTuple(const GetFromTuple &args,
Fortran::lower::AbstractConverter &converter,
@@ -404,8 +404,8 @@ class CapturedArrays : public CapturedSymbols<CapturedArrays> {
// done on present optional. For absent optionals, simply create a
// disassociated pointer (it is illegal to inquire about lower bounds or
// lengths of optional according to 15.5.2.12 3 (9) and 10.1.11 2 (7)b).
- auto isPresent = builder.create<fir::IsPresentOp>(
- loc, builder.getI1Type(), fir::getBase(args.hostValue));
+ auto isPresent = fir::IsPresentOp::create(
+ builder, loc, builder.getI1Type(), fir::getBase(args.hostValue));
builder.genIfThenElse(loc, isPresent)
.genThen([&]() {
fir::factory::associateMutableBox(builder, loc, boxInTuple,
@@ -441,8 +441,8 @@ class CapturedArrays : public CapturedSymbols<CapturedArrays> {
const unsigned rank = sym.Rank();
for (unsigned dim = 0; dim < rank; ++dim) {
mlir::Value dimVal = builder.createIntegerConstant(loc, idxTy, dim);
- auto dims = builder.create<fir::BoxDimsOp>(loc, idxTy, idxTy, idxTy,
- box, dimVal);
+ auto dims = fir::BoxDimsOp::create(builder, loc, idxTy, idxTy, idxTy,
+ box, dimVal);
lbounds.emplace_back(dims.getResult(0));
}
}
@@ -464,11 +464,11 @@ class CapturedArrays : public CapturedSymbols<CapturedArrays> {
auto eleTy = boxTy.getEleTy();
if (!fir::isa_ref_type(eleTy))
eleTy = builder.getRefType(eleTy);
- auto addr = builder.create<fir::BoxAddrOp>(loc, eleTy, box);
+ auto addr = fir::BoxAddrOp::create(builder, loc, eleTy, box);
mlir::Value isPresent = builder.genIsNotNullAddr(loc, addr);
- auto absentBox = builder.create<fir::AbsentOp>(loc, boxTy);
- box = builder.create<mlir::arith::SelectOp>(loc, isPresent, box,
- absentBox);
+ auto absentBox = fir::AbsentOp::create(builder, loc, boxTy);
+ box = mlir::arith::SelectOp::create(builder, loc, isPresent, box,
+ absentBox);
}
fir::BoxValue boxValue(box, lbounds, /*explicitParams=*/{});
bindCapturedSymbol(sym, boxValue, converter, args.symMap);
@@ -540,7 +540,7 @@ static mlir::Value genTupleCoor(fir::FirOpBuilder &builder, mlir::Location loc,
auto ty = mlir::isa<fir::ReferenceType>(varTy)
? mlir::Type(fir::LLVMPointerType::get(varTy))
: mlir::Type(builder.getRefType(varTy));
- return builder.create<fir::CoordinateOp>(loc, ty, tupleArg, offset);
+ return fir::CoordinateOp::create(builder, loc, ty, tupleArg, offset);
}
void Fortran::lower::HostAssociations::addSymbolsToBind(
@@ -572,7 +572,7 @@ void Fortran::lower::HostAssociations::hostProcedureBindings(
mlir::TupleType tupTy = unwrapTupleTy(getArgumentType(converter));
fir::FirOpBuilder &builder = converter.getFirOpBuilder();
mlir::Location loc = converter.getCurrentLocation();
- auto hostTuple = builder.create<fir::AllocaOp>(loc, tupTy);
+ auto hostTuple = fir::AllocaOp::create(builder, loc, tupTy);
mlir::IntegerType offTy = builder.getIntegerType(32);
// Walk the list of tupleSymbols and update the pointers in the tuple.
@@ -639,7 +639,7 @@ void Fortran::lower::HostAssociations::internalProcedureBindings(
mlir::Value off = builder.createIntegerConstant(loc, offTy, s.index());
mlir::Type varTy = tupTy.getType(s.index());
mlir::Value eleOff = genTupleCoor(builder, loc, varTy, tupleArg, off);
- mlir::Value valueInTuple = builder.create<fir::LoadOp>(loc, eleOff);
+ mlir::Value valueInTuple = fir::LoadOp::create(builder, loc, eleOff);
GetFromTuple getFromTuple{symMap, valueInTuple, loc};
walkCaptureCategories(getFromTuple, converter, *s.value());
}
diff --git a/flang/lib/Lower/IO.cpp b/flang/lib/Lower/IO.cpp
index 53bf61922392d..c95c3404a8e26 100644
--- a/flang/lib/Lower/IO.cpp
+++ b/flang/lib/Lower/IO.cpp
@@ -153,8 +153,8 @@ static mlir::Value genEndIO(Fortran::lower::AbstractConverter &converter,
if (csi.ioMsg) {
mlir::func::FuncOp getIoMsg =
fir::runtime::getIORuntimeFunc<mkIOKey(GetIoMsg)>(loc, builder);
- builder.create<fir::CallOp>(
- loc, getIoMsg,
+ fir::CallOp::create(
+ builder, loc, getIoMsg,
mlir::ValueRange{
cookie,
builder.createConvert(loc, getIoMsg.getFunctionType().getInput(1),
@@ -164,12 +164,12 @@ static mlir::Value genEndIO(Fortran::lower::AbstractConverter &converter,
}
mlir::func::FuncOp endIoStatement =
fir::runtime::getIORuntimeFunc<mkIOKey(EndIoStatement)>(loc, builder);
- auto call = builder.create<fir::CallOp>(loc, endIoStatement,
- mlir::ValueRange{cookie});
+ auto call = fir::CallOp::create(builder, loc, endIoStatement,
+ mlir::ValueRange{cookie});
mlir::Value iostat = call.getResult(0);
if (csi.bigUnitIfOp) {
stmtCtx.finalizeAndPop();
- builder.create<fir::ResultOp>(loc, iostat);
+ fir::ResultOp::create(builder, loc, iostat);
builder.setInsertionPointAfter(csi.bigUnitIfOp);
iostat = csi.bigUnitIfOp.getResult(0);
}
@@ -178,7 +178,7 @@ static mlir::Value genEndIO(Fortran::lower::AbstractConverter &converter,
fir::getBase(converter.genExprAddr(loc, csi.ioStatExpr, stmtCtx));
mlir::Value ioStatResult =
builder.createConvert(loc, converter.genType(*csi.ioStatExpr), iostat);
- builder.create<fir::StoreOp>(loc, ioStatResult, ioStatVar);
+ fir::StoreOp::create(builder, loc, ioStatResult, ioStatVar);
}
return csi.hasTransferConditionSpec() ? iostat : mlir::Value{};
}
@@ -203,8 +203,8 @@ static void makeNextConditionalOn(fir::FirOpBuilder &builder,
mlir::IntegerType boolTy = builder.getI1Type();
if (inLoop)
resTy = boolTy;
- auto ifOp = builder.create<fir::IfOp>(loc, resTy, ok,
- /*withElseRegion=*/inLoop);
+ auto ifOp = fir::IfOp::create(builder, loc, resTy, ok,
+ /*withElseRegion=*/inLoop);
builder.setInsertionPointToStart(&ifOp.getThenRegion().front());
}
@@ -259,10 +259,10 @@ getNonTbpDefinedIoTableAddr(Fortran::lower::AbstractConverter &converter,
? fir::NameUniquer::doGenerated("default" + suffix)
: converter.mangleName(suffix);
if (auto table = builder.getNamedGlobal(tableMangleName))
- return builder.createConvert(
- loc, refTy,
- builder.create<fir::AddrOfOp>(loc, table.resultType(),
- table.getSymbol()));
+ return builder.createConvert(loc, refTy,
+ fir::AddrOfOp::create(builder, loc,
+ table.resultType(),
+ table.getSymbol()));
mlir::StringAttr linkOnce = builder.createLinkOnceLinkage();
mlir::Type idxTy = builder.getIndexType();
@@ -281,11 +281,12 @@ getNonTbpDefinedIoTableAddr(Fortran::lower::AbstractConverter &converter,
// Define the list of NonTbpDefinedIo procedures.
bool tableIsLocal =
!definedIoProcMap.empty() && hasLocalDefinedIoProc(definedIoProcMap);
- mlir::Value listAddr =
- tableIsLocal ? builder.create<fir::AllocaOp>(loc, listTy) : mlir::Value{};
+ mlir::Value listAddr = tableIsLocal
+ ? fir::AllocaOp::create(builder, loc, listTy)
+ : mlir::Value{};
std::string listMangleName = tableMangleName + ".list";
auto listFunc = [&](fir::FirOpBuilder &builder) {
- mlir::Value list = builder.create<fir::UndefOp>(loc, listTy);
+ mlir::Value list = fir::UndefOp::create(builder, loc, listTy);
mlir::IntegerAttr intAttr[4];
for (int i = 0; i < 4; ++i)
intAttr[i] = builder.getIntegerAttr(idxTy, i);
@@ -294,8 +295,8 @@ getNonTbpDefinedIoTableAddr(Fortran::lower::AbstractConverter &converter,
int n0 = 0, n1;
auto insert = [&](mlir::Value val) {
idx[1] = intAttr[n1++];
- list = builder.create<fir::InsertValueOp>(loc, listTy, list, val,
- builder.getArrayAttr(idx));
+ list = fir::InsertValueOp::create(builder, loc, listTy, list, val,
+ builder.getArrayAttr(idx));
};
for (auto &iface : definedIoProcMap) {
idx[0] = builder.getIntegerAttr(idxTy, n0++);
@@ -305,8 +306,8 @@ getNonTbpDefinedIoTableAddr(Fortran::lower::AbstractConverter &converter,
std::string dtName = converter.mangleName(dtSym);
insert(builder.createConvert(
loc, refTy,
- builder.create<fir::AddrOfOp>(
- loc, fir::ReferenceType::get(converter.genType(dtSym)),
+ fir::AddrOfOp::create(
+ builder, loc, fir::ReferenceType::get(converter.genType(dtSym)),
builder.getSymbolRefAttr(dtName))));
// defined IO procedure [void (*subroutine)()], may be null
const Fortran::semantics::Symbol *procSym = iface.second.subroutine;
@@ -316,8 +317,8 @@ getNonTbpDefinedIoTableAddr(Fortran::lower::AbstractConverter &converter,
TODO(loc, "defined IO procedure pointers");
} else if (Fortran::semantics::IsDummy(*procSym)) {
Fortran::lower::StatementContext stmtCtx;
- insert(builder.create<fir::BoxAddrOp>(
- loc, refTy,
+ insert(fir::BoxAddrOp::create(
+ builder, loc, refTy,
fir::getBase(converter.genExprAddr(
loc,
Fortran::lower::SomeExpr{
@@ -330,8 +331,8 @@ getNonTbpDefinedIoTableAddr(Fortran::lower::AbstractConverter &converter,
builder.getSymbolRefAttr(procDef.getSymName());
insert(builder.createConvert(
loc, refTy,
- builder.create<fir::AddrOfOp>(loc, procDef.getFunctionType(),
- nameAttr)));
+ fir::AddrOfOp::create(builder, loc, procDef.getFunctionType(),
+ nameAttr)));
}
} else {
insert(builder.createNullConstant(loc, refTy));
@@ -346,9 +347,9 @@ getNonTbpDefinedIoTableAddr(Fortran::lower::AbstractConverter &converter,
insert(builder.createIntegerConstant(loc, byteTy, iface.second.flags));
}
if (tableIsLocal)
- builder.create<fir::StoreOp>(loc, list, listAddr);
+ fir::StoreOp::create(builder, loc, list, listAddr);
else
- builder.create<fir::HasValueOp>(loc, list);
+ fir::HasValueOp::create(builder, loc, list);
};
if (!definedIoProcMap.empty()) {
if (tableIsLocal)
@@ -360,33 +361,34 @@ getNonTbpDefinedIoTableAddr(Fortran::lower::AbstractConverter &converter,
// Define the NonTbpDefinedIoTable.
mlir::Value tableAddr = tableIsLocal
- ? builder.create<fir::AllocaOp>(loc, tableTy)
+ ? fir::AllocaOp::create(builder, loc, tableTy)
: mlir::Value{};
auto tableFunc = [&](fir::FirOpBuilder &builder) {
- mlir::Value table = builder.create<fir::UndefOp>(loc, tableTy);
+ mlir::Value table = fir::UndefOp::create(builder, loc, tableTy);
// list item count [std::size_t items]
- table = builder.create<fir::InsertValueOp>(
- loc, tableTy, table,
+ table = fir::InsertValueOp::create(
+ builder, loc, tableTy, table,
builder.createIntegerConstant(loc, sizeTy, definedIoProcMap.size()),
builder.getArrayAttr(builder.getIntegerAttr(idxTy, 0)));
// item list [const NonTbpDefinedIo *item]
if (definedIoProcMap.empty())
listAddr = builder.createNullConstant(loc, builder.getRefType(listTy));
else if (fir::GlobalOp list = builder.getNamedGlobal(listMangleName))
- listAddr = builder.create<fir::AddrOfOp>(loc, list.resultType(),
- list.getSymbol());
+ listAddr = fir::AddrOfOp::create(builder, loc, list.resultType(),
+ list.getSymbol());
assert(listAddr && "missing namelist object list");
- table = builder.create<fir::InsertValueOp>(
- loc, tableTy, table, listAddr,
+ table = fir::InsertValueOp::create(
+ builder, loc, tableTy, table, listAddr,
builder.getArrayAttr(builder.getIntegerAttr(idxTy, 1)));
// [bool ignoreNonTbpEntries] conservatively set to true
- table = builder.create<fir::InsertValueOp>(
- loc, tableTy, table, builder.createIntegerConstant(loc, boolTy, true),
+ table = fir::InsertValueOp::create(
+ builder, loc, tableTy, table,
+ builder.createIntegerConstant(loc, boolTy, true),
builder.getArrayAttr(builder.getIntegerAttr(idxTy, 2)));
if (tableIsLocal)
- builder.create<fir::StoreOp>(loc, table, tableAddr);
+ fir::StoreOp::create(builder, loc, table, tableAddr);
else
- builder.create<fir::HasValueOp>(loc, table);
+ fir::HasValueOp::create(builder, loc, table);
};
if (tableIsLocal) {
tableFunc(builder);
@@ -394,8 +396,8 @@ getNonTbpDefinedIoTableAddr(Fortran::lower::AbstractConverter &converter,
fir::GlobalOp table = builder.createGlobal(
loc, tableTy, tableMangleName,
/*isConst=*/true, /*isTarget=*/false, tableFunc, linkOnce);
- tableAddr = builder.create<fir::AddrOfOp>(
- loc, fir::ReferenceType::get(tableTy), table.getSymbol());
+ tableAddr = fir::AddrOfOp::create(
+ builder, loc, fir::ReferenceType::get(tableTy), table.getSymbol());
}
assert(tableAddr && "missing NonTbpDefinedIo table result");
return builder.createConvert(loc, refTy, tableAddr);
@@ -420,8 +422,8 @@ getNamelistGroup(Fortran::lower::AbstractConverter &converter,
mlir::Location loc = converter.getCurrentLocation();
std::string groupMangleName = converter.mangleName(symbol);
if (auto group = builder.getNamedGlobal(groupMangleName))
- return builder.create<fir::AddrOfOp>(loc, group.resultType(),
- group.getSymbol());
+ return fir::AddrOfOp::create(builder, loc, group.resultType(),
+ group.getSymbol());
const auto &details =
symbol.GetUltimate().get<Fortran::semantics::NamelistDetails>();
@@ -468,18 +470,19 @@ getNamelistGroup(Fortran::lower::AbstractConverter &converter,
auto descFunc = [&](fir::FirOpBuilder &b) {
auto box = Fortran::lower::genInitialDataTarget(
converter, loc, boxTy, *expr, /*couldBeInEquivalence=*/true);
- b.create<fir::HasValueOp>(loc, box);
+ fir::HasValueOp::create(b, loc, box);
};
builder.createGlobalConstant(loc, boxTy, mangleName, descFunc, linkOnce);
}
}
// Define the list of Items.
- mlir::Value listAddr =
- groupIsLocal ? builder.create<fir::AllocaOp>(loc, listTy) : mlir::Value{};
+ mlir::Value listAddr = groupIsLocal
+ ? fir::AllocaOp::create(builder, loc, listTy)
+ : mlir::Value{};
std::string listMangleName = groupMangleName + ".list";
auto listFunc = [&](fir::FirOpBuilder &builder) {
- mlir::Value list = builder.create<fir::UndefOp>(loc, listTy);
+ mlir::Value list = fir::UndefOp::create(builder, loc, listTy);
mlir::IntegerAttr zero = builder.getIntegerAttr(idxTy, 0);
mlir::IntegerAttr one = builder.getIntegerAttr(idxTy, 1);
llvm::SmallVector<mlir::Attribute, 2> idx = {mlir::Attribute{},
@@ -490,14 +493,14 @@ getNamelistGroup(Fortran::lower::AbstractConverter &converter,
idx[1] = zero;
mlir::Value nameAddr =
builder.createConvert(loc, charRefTy, fir::getBase(stringAddress(s)));
- list = builder.create<fir::InsertValueOp>(loc, listTy, list, nameAddr,
- builder.getArrayAttr(idx));
+ list = fir::InsertValueOp::create(builder, loc, listTy, list, nameAddr,
+ builder.getArrayAttr(idx));
idx[1] = one;
mlir::Value descAddr;
if (auto desc = builder.getNamedGlobal(
Fortran::lower::mangle::globalNamelistDescriptorName(s))) {
- descAddr = builder.create<fir::AddrOfOp>(loc, desc.resultType(),
- desc.getSymbol());
+ descAddr = fir::AddrOfOp::create(builder, loc, desc.resultType(),
+ desc.getSymbol());
} else if (Fortran::semantics::FindCommonBlockContaining(s) &&
IsAllocatableOrPointer(s)) {
mlir::Type symType = converter.genType(s);
@@ -505,8 +508,8 @@ getNamelistGroup(Fortran::lower::AbstractConverter &converter,
Fortran::semantics::FindCommonBlockContaining(s);
std::string commonBlockName = converter.mangleName(*commonBlockSym);
fir::GlobalOp commonGlobal = builder.getNamedGlobal(commonBlockName);
- mlir::Value commonBlockAddr = builder.create<fir::AddrOfOp>(
- loc, commonGlobal.resultType(), commonGlobal.getSymbol());
+ mlir::Value commonBlockAddr = fir::AddrOfOp::create(
+ builder, loc, commonGlobal.resultType(), commonGlobal.getSymbol());
mlir::IntegerType i8Ty = builder.getIntegerType(8);
mlir::Type i8Ptr = builder.getRefType(i8Ty);
mlir::Type seqTy = builder.getRefType(builder.getVarLenSeqTy(i8Ty));
@@ -514,8 +517,8 @@ getNamelistGroup(Fortran::lower::AbstractConverter &converter,
std::size_t byteOffset = s.GetUltimate().offset();
mlir::Value offs = builder.createIntegerConstant(
loc, builder.getIndexType(), byteOffset);
- mlir::Value varAddr = builder.create<fir::CoordinateOp>(
- loc, i8Ptr, base, mlir::ValueRange{offs});
+ mlir::Value varAddr = fir::CoordinateOp::create(
+ builder, loc, i8Ptr, base, mlir::ValueRange{offs});
descAddr =
builder.createConvert(loc, builder.getRefType(symType), varAddr);
} else {
@@ -531,13 +534,13 @@ getNamelistGroup(Fortran::lower::AbstractConverter &converter,
/*lbounds=*/{});
}
descAddr = builder.createConvert(loc, descRefTy, descAddr);
- list = builder.create<fir::InsertValueOp>(loc, listTy, list, descAddr,
- builder.getArrayAttr(idx));
+ list = fir::InsertValueOp::create(builder, loc, listTy, list, descAddr,
+ builder.getArrayAttr(idx));
}
if (groupIsLocal)
- builder.create<fir::StoreOp>(loc, list, listAddr);
+ fir::StoreOp::create(builder, loc, list, listAddr);
else
- builder.create<fir::HasValueOp>(loc, list);
+ fir::HasValueOp::create(builder, loc, list);
};
if (groupIsLocal)
listFunc(builder);
@@ -547,39 +550,39 @@ getNamelistGroup(Fortran::lower::AbstractConverter &converter,
// Define the group.
mlir::Value groupAddr = groupIsLocal
- ? builder.create<fir::AllocaOp>(loc, groupTy)
+ ? fir::AllocaOp::create(builder, loc, groupTy)
: mlir::Value{};
auto groupFunc = [&](fir::FirOpBuilder &builder) {
- mlir::Value group = builder.create<fir::UndefOp>(loc, groupTy);
+ mlir::Value group = fir::UndefOp::create(builder, loc, groupTy);
// group name [const char *groupName]
- group = builder.create<fir::InsertValueOp>(
- loc, groupTy, group,
+ group = fir::InsertValueOp::create(
+ builder, loc, groupTy, group,
builder.createConvert(loc, charRefTy,
fir::getBase(stringAddress(symbol))),
builder.getArrayAttr(builder.getIntegerAttr(idxTy, 0)));
// list item count [std::size_t items]
- group = builder.create<fir::InsertValueOp>(
- loc, groupTy, group,
+ group = fir::InsertValueOp::create(
+ builder, loc, groupTy, group,
builder.createIntegerConstant(loc, sizeTy, details.objects().size()),
builder.getArrayAttr(builder.getIntegerAttr(idxTy, 1)));
// item list [const Item *item]
if (fir::GlobalOp list = builder.getNamedGlobal(listMangleName))
- listAddr = builder.create<fir::AddrOfOp>(loc, list.resultType(),
- list.getSymbol());
+ listAddr = fir::AddrOfOp::create(builder, loc, list.resultType(),
+ list.getSymbol());
assert(listAddr && "missing namelist object list");
- group = builder.create<fir::InsertValueOp>(
- loc, groupTy, group, listAddr,
+ group = fir::InsertValueOp::create(
+ builder, loc, groupTy, group, listAddr,
builder.getArrayAttr(builder.getIntegerAttr(idxTy, 2)));
// non-type-bound defined IO procedures
// [const NonTbpDefinedIoTable *nonTbpDefinedIo]
- group = builder.create<fir::InsertValueOp>(
- loc, groupTy, group,
+ group = fir::InsertValueOp::create(
+ builder, loc, groupTy, group,
getNonTbpDefinedIoTableAddr(converter, definedIoProcMap),
builder.getArrayAttr(builder.getIntegerAttr(idxTy, 3)));
if (groupIsLocal)
- builder.create<fir::StoreOp>(loc, group, groupAddr);
+ fir::StoreOp::create(builder, loc, group, groupAddr);
else
- builder.create<fir::HasValueOp>(loc, group);
+ fir::HasValueOp::create(builder, loc, group);
};
if (groupIsLocal) {
groupFunc(builder);
@@ -587,8 +590,8 @@ getNamelistGroup(Fortran::lower::AbstractConverter &converter,
fir::GlobalOp group = builder.createGlobal(
loc, groupTy, groupMangleName,
/*isConst=*/true, /*isTarget=*/false, groupFunc, linkOnce);
- groupAddr = builder.create<fir::AddrOfOp>(loc, group.resultType(),
- group.getSymbol());
+ groupAddr = fir::AddrOfOp::create(builder, loc, group.resultType(),
+ group.getSymbol());
}
assert(groupAddr && "missing namelist group result");
return groupAddr;
@@ -608,7 +611,7 @@ static void genNamelistIO(Fortran::lower::AbstractConverter &converter,
getNamelistGroup(converter, symbol.GetUltimate(), stmtCtx);
groupAddr = builder.createConvert(loc, argType, groupAddr);
llvm::SmallVector<mlir::Value> args = {cookie, groupAddr};
- ok = builder.create<fir::CallOp>(loc, funcOp, args).getResult(0);
+ ok = fir::CallOp::create(builder, loc, funcOp, args).getResult(0);
}
/// Is \p type a derived type or an array of derived type?
@@ -751,7 +754,7 @@ static void genOutputItemList(
outputFuncArgs.push_back(itemValue);
}
}
- ok = builder.create<fir::CallOp>(loc, outputFunc, outputFuncArgs)
+ ok = fir::CallOp::create(builder, loc, outputFunc, outputFuncArgs)
.getResult(0);
}
}
@@ -812,12 +815,12 @@ static void boolRefToLogical(mlir::Location loc, fir::FirOpBuilder &builder,
mlir::Value addr) {
auto boolType = builder.getRefType(builder.getI1Type());
auto boolAddr = builder.createConvert(loc, boolType, addr);
- auto boolValue = builder.create<fir::LoadOp>(loc, boolAddr);
+ auto boolValue = fir::LoadOp::create(builder, loc, boolAddr);
auto logicalType = fir::unwrapPassByRefType(addr.getType());
// The convert avoid making any assumptions about how LOGICALs are actually
// represented (it might end-up being either a signed or zero extension).
auto logicalValue = builder.createConvert(loc, logicalType, boolValue);
- builder.create<fir::StoreOp>(loc, logicalValue, addr);
+ fir::StoreOp::create(builder, loc, logicalValue, addr);
}
static mlir::Value
@@ -849,12 +852,13 @@ createIoRuntimeCallForItem(Fortran::lower::AbstractConverter &converter,
inputFuncArgs.push_back(builder.createConvert(
loc, inputFunc.getFunctionType().getInput(2), len));
} else if (mlir::isa<mlir::IntegerType>(itemTy)) {
- inputFuncArgs.push_back(builder.create<mlir::arith::ConstantOp>(
- loc, builder.getI32IntegerAttr(
- mlir::cast<mlir::IntegerType>(itemTy).getWidth() / 8)));
+ inputFuncArgs.push_back(mlir::arith::ConstantOp::create(
+ builder, loc,
+ builder.getI32IntegerAttr(
+ mlir::cast<mlir::IntegerType>(itemTy).getWidth() / 8)));
}
}
- auto call = builder.create<fir::CallOp>(loc, inputFunc, inputFuncArgs);
+ auto call = fir::CallOp::create(builder, loc, inputFunc, inputFuncArgs);
auto itemAddr = fir::getBase(item);
auto itemTy = fir::unwrapRefType(itemAddr.getType());
if (mlir::isa<fir::LogicalType>(itemTy))
@@ -951,7 +955,7 @@ static void genIoLoop(Fortran::lower::AbstractConverter &converter,
mlir::Value stepValue =
control.step.has_value()
? genControlValue(*control.step)
- : builder.create<mlir::arith::ConstantIndexOp>(loc, 1);
+ : mlir::arith::ConstantIndexOp::create(builder, loc, 1);
auto genItemList = [&](const D &ioImpliedDo) {
if constexpr (std::is_same_v<D, Fortran::parser::InputImpliedDo>)
genInputItemList(converter, cookie, itemList, isFormatted, checkResult,
@@ -962,35 +966,36 @@ static void genIoLoop(Fortran::lower::AbstractConverter &converter,
};
if (!checkResult) {
// No IO call result checks - the loop is a fir.do_loop op.
- auto doLoopOp = builder.create<fir::DoLoopOp>(
- loc, lowerValue, upperValue, stepValue, /*unordered=*/false,
- /*finalCountValue=*/true);
+ auto doLoopOp = fir::DoLoopOp::create(builder, loc, lowerValue, upperValue,
+ stepValue, /*unordered=*/false,
+ /*finalCountValue=*/true);
builder.setInsertionPointToStart(doLoopOp.getBody());
mlir::Value lcv = builder.createConvert(
loc, fir::unwrapRefType(loopVar.getType()), doLoopOp.getInductionVar());
- builder.create<fir::StoreOp>(loc, lcv, loopVar);
+ fir::StoreOp::create(builder, loc, lcv, loopVar);
genItemList(ioImpliedDo);
builder.setInsertionPointToEnd(doLoopOp.getBody());
- mlir::Value result = builder.create<mlir::arith::AddIOp>(
- loc, doLoopOp.getInductionVar(), doLoopOp.getStep(), iofAttr);
- builder.create<fir::ResultOp>(loc, result);
+ mlir::Value result = mlir::arith::AddIOp::create(
+ builder, loc, doLoopOp.getInductionVar(), doLoopOp.getStep(), iofAttr);
+ fir::ResultOp::create(builder, loc, result);
builder.setInsertionPointAfter(doLoopOp);
// The loop control variable may be used after the loop.
lcv = builder.createConvert(loc, fir::unwrapRefType(loopVar.getType()),
doLoopOp.getResult(0));
- builder.create<fir::StoreOp>(loc, lcv, loopVar);
+ fir::StoreOp::create(builder, loc, lcv, loopVar);
return;
}
// Check IO call results - the loop is a fir.iterate_while op.
if (!ok)
ok = builder.createBool(loc, true);
- auto iterWhileOp = builder.create<fir::IterWhileOp>(
- loc, lowerValue, upperValue, stepValue, ok, /*finalCountValue*/ true);
+ auto iterWhileOp =
+ fir::IterWhileOp::create(builder, loc, lowerValue, upperValue, stepValue,
+ ok, /*finalCountValue*/ true);
builder.setInsertionPointToStart(iterWhileOp.getBody());
mlir::Value lcv =
builder.createConvert(loc, fir::unwrapRefType(loopVar.getType()),
iterWhileOp.getInductionVar());
- builder.create<fir::StoreOp>(loc, lcv, loopVar);
+ fir::StoreOp::create(builder, loc, lcv, loopVar);
ok = iterWhileOp.getIterateVar();
mlir::Value falseValue =
builder.createIntegerConstant(loc, builder.getI1Type(), 0);
@@ -1003,28 +1008,28 @@ static void genIoLoop(Fortran::lower::AbstractConverter &converter,
builder.setInsertionPointAfter(lastOp);
// The primary ifOp result is the result of an IO call or loop.
if (mlir::isa<fir::CallOp, fir::IfOp>(*lastOp))
- builder.create<fir::ResultOp>(loc, lastOp->getResult(0));
+ fir::ResultOp::create(builder, loc, lastOp->getResult(0));
else
- builder.create<fir::ResultOp>(loc, ok); // loop result
+ fir::ResultOp::create(builder, loc, ok); // loop result
// The else branch propagates an early exit false result.
builder.setInsertionPointToStart(&ifOp.getElseRegion().front());
- builder.create<fir::ResultOp>(loc, falseValue);
+ fir::ResultOp::create(builder, loc, falseValue);
}
builder.setInsertionPointToEnd(iterWhileOp.getBody());
mlir::OpResult iterateResult = builder.getBlock()->back().getResult(0);
mlir::Value inductionResult0 = iterWhileOp.getInductionVar();
- auto inductionResult1 = builder.create<mlir::arith::AddIOp>(
- loc, inductionResult0, iterWhileOp.getStep(), iofAttr);
- auto inductionResult = builder.create<mlir::arith::SelectOp>(
- loc, iterateResult, inductionResult1, inductionResult0);
+ auto inductionResult1 = mlir::arith::AddIOp::create(
+ builder, loc, inductionResult0, iterWhileOp.getStep(), iofAttr);
+ auto inductionResult = mlir::arith::SelectOp::create(
+ builder, loc, iterateResult, inductionResult1, inductionResult0);
llvm::SmallVector<mlir::Value> results = {inductionResult, iterateResult};
- builder.create<fir::ResultOp>(loc, results);
+ fir::ResultOp::create(builder, loc, results);
ok = iterWhileOp.getResult(1);
builder.setInsertionPointAfter(iterWhileOp);
// The loop control variable may be used after the loop.
lcv = builder.createConvert(loc, fir::unwrapRefType(loopVar.getType()),
iterWhileOp.getResult(0));
- builder.create<fir::StoreOp>(loc, lcv, loopVar);
+ fir::StoreOp::create(builder, loc, lcv, loopVar);
}
//===----------------------------------------------------------------------===//
@@ -1046,15 +1051,15 @@ static mlir::Value locToLineNo(Fortran::lower::AbstractConverter &converter,
static mlir::Value getDefaultScratch(fir::FirOpBuilder &builder,
mlir::Location loc, mlir::Type toType) {
- mlir::Value null = builder.create<mlir::arith::ConstantOp>(
- loc, builder.getI64IntegerAttr(0));
+ mlir::Value null = mlir::arith::ConstantOp::create(
+ builder, loc, builder.getI64IntegerAttr(0));
return builder.createConvert(loc, toType, null);
}
static mlir::Value getDefaultScratchLen(fir::FirOpBuilder &builder,
mlir::Location loc, mlir::Type toType) {
- return builder.create<mlir::arith::ConstantOp>(
- loc, builder.getIntegerAttr(toType, 0));
+ return mlir::arith::ConstantOp::create(builder, loc,
+ builder.getIntegerAttr(toType, 0));
}
/// Generate a reference to a buffer and the length of buffer given
@@ -1105,8 +1110,8 @@ lowerStringLit(Fortran::lower::AbstractConverter &converter, mlir::Location loc,
mlir::Value kind;
if (ty2) {
auto kindVal = expr->GetType().value().kind();
- kind = builder.create<mlir::arith::ConstantOp>(
- loc, builder.getIntegerAttr(ty2, kindVal));
+ kind = mlir::arith::ConstantOp::create(
+ builder, loc, builder.getIntegerAttr(ty2, kindVal));
}
return {buff, len, kind};
}
@@ -1146,7 +1151,7 @@ mlir::Value genIntIOOption(Fortran::lower::AbstractConverter &converter,
loc, Fortran::semantics::GetExpr(spec.v), localStatementCtx));
mlir::Value val = builder.createConvert(loc, ioFuncTy.getInput(1), expr);
llvm::SmallVector<mlir::Value> ioArgs = {cookie, val};
- return builder.create<fir::CallOp>(loc, ioFunc, ioArgs).getResult(0);
+ return fir::CallOp::create(builder, loc, ioFunc, ioArgs).getResult(0);
}
/// Generic to build a string argument to the runtime. This passes a CHARACTER
@@ -1164,7 +1169,7 @@ mlir::Value genCharIOOption(Fortran::lower::AbstractConverter &converter,
ioFuncTy.getInput(1), ioFuncTy.getInput(2));
llvm::SmallVector<mlir::Value> ioArgs = {cookie, std::get<0>(tup),
std::get<1>(tup)};
- return builder.create<fir::CallOp>(loc, ioFunc, ioArgs).getResult(0);
+ return fir::CallOp::create(builder, loc, ioFunc, ioArgs).getResult(0);
}
template <typename A>
@@ -1197,7 +1202,7 @@ mlir::Value genIOOption<Fortran::parser::FileNameExpr>(
ioFuncTy.getInput(1), ioFuncTy.getInput(2));
llvm::SmallVector<mlir::Value> ioArgs{cookie, std::get<0>(tup),
std::get<1>(tup)};
- return builder.create<fir::CallOp>(loc, ioFunc, ioArgs).getResult(0);
+ return fir::CallOp::create(builder, loc, ioFunc, ioArgs).getResult(0);
}
template <>
@@ -1262,7 +1267,7 @@ mlir::Value genIOOption<Fortran::parser::ConnectSpec::CharExpr>(
ioFuncTy.getInput(1), ioFuncTy.getInput(2));
llvm::SmallVector<mlir::Value> ioArgs = {cookie, std::get<0>(tup),
std::get<1>(tup)};
- return builder.create<fir::CallOp>(loc, ioFunc, ioArgs).getResult(0);
+ return fir::CallOp::create(builder, loc, ioFunc, ioArgs).getResult(0);
}
template <>
@@ -1316,7 +1321,7 @@ mlir::Value genIOOption<Fortran::parser::IoControlSpec::CharExpr>(
ioFuncTy.getInput(1), ioFuncTy.getInput(2));
llvm::SmallVector<mlir::Value> ioArgs = {cookie, std::get<0>(tup),
std::get<1>(tup)};
- return builder.create<fir::CallOp>(loc, ioFunc, ioArgs).getResult(0);
+ return fir::CallOp::create(builder, loc, ioFunc, ioArgs).getResult(0);
}
template <>
@@ -1352,7 +1357,7 @@ static void genIOGetVar(Fortran::lower::AbstractConverter &converter,
mlir::func::FuncOp ioFunc =
fir::runtime::getIORuntimeFunc<IoRuntimeKey>(loc, builder);
mlir::Value value =
- builder.create<fir::CallOp>(loc, ioFunc, mlir::ValueRange{cookie})
+ fir::CallOp::create(builder, loc, ioFunc, mlir::ValueRange{cookie})
.getResult(0);
Fortran::lower::StatementContext localStatementCtx;
fir::ExtendedValue var = converter.genExprAddr(
@@ -1480,8 +1485,8 @@ genConditionHandlerCall(Fortran::lower::AbstractConverter &converter,
fir::runtime::getIORuntimeFunc<mkIOKey(EnableHandlers)>(loc, builder);
mlir::Type boolType = enableHandlers.getFunctionType().getInput(1);
auto boolValue = [&](bool specifierIsPresent) {
- return builder.create<mlir::arith::ConstantOp>(
- loc, builder.getIntegerAttr(boolType, specifierIsPresent));
+ return mlir::arith::ConstantOp::create(
+ builder, loc, builder.getIntegerAttr(boolType, specifierIsPresent));
};
llvm::SmallVector<mlir::Value> ioArgs = {cookie,
boolValue(csi.ioStatExpr != nullptr),
@@ -1489,7 +1494,7 @@ genConditionHandlerCall(Fortran::lower::AbstractConverter &converter,
boolValue(csi.hasEnd),
boolValue(csi.hasEor),
boolValue(csi.ioMsg.has_value())};
- builder.create<fir::CallOp>(loc, enableHandlers, ioArgs);
+ fir::CallOp::create(builder, loc, enableHandlers, ioArgs);
}
//===----------------------------------------------------------------------===//
@@ -1663,7 +1668,7 @@ lowerReferenceAsStringSelect(Fortran::lower::AbstractConverter &converter,
// Pass the format string reference and the string length out of the select
// statement.
llvm::SmallVector<mlir::Value> args = {stringRef, stringLen};
- builder.create<mlir::cf::BranchOp>(loc, endBlock, args);
+ mlir::cf::BranchOp::create(builder, loc, endBlock, args);
// Add block to the list of cases and make a new one.
blockList.push_back(block);
@@ -1678,13 +1683,13 @@ lowerReferenceAsStringSelect(Fortran::lower::AbstractConverter &converter,
builder, loc,
"Assigned format variable '" + symbol->name().ToString() +
"' has not been assigned a valid format label");
- builder.create<fir::UnreachableOp>(loc);
+ fir::UnreachableOp::create(builder, loc);
blockList.push_back(unitBlock);
// Lower the selectOp.
builder.setInsertionPointToEnd(startBlock);
auto label = fir::getBase(converter.genExprValue(loc, &expr, stmtCtx));
- builder.create<fir::SelectOp>(loc, label, indexList, blockList);
+ fir::SelectOp::create(builder, loc, label, indexList, blockList);
builder.setInsertionPointToEnd(endBlock);
endBlock->addArgument(strTy, loc);
@@ -1814,17 +1819,17 @@ static mlir::Value genIOUnitNumber(Fortran::lower::AbstractConverter &converter,
mlir::Value line = locToLineNo(converter, loc, funcTy.getInput(5));
args.push_back(file);
args.push_back(line);
- auto checkCall = builder.create<fir::CallOp>(loc, check, args);
+ auto checkCall = fir::CallOp::create(builder, loc, check, args);
if (csi.hasErrorConditionSpec()) {
mlir::Value iostat = checkCall.getResult(0);
mlir::Type iostatTy = iostat.getType();
mlir::Value zero = fir::factory::createZeroValue(builder, loc, iostatTy);
- mlir::Value unitIsOK = builder.create<mlir::arith::CmpIOp>(
- loc, mlir::arith::CmpIPredicate::eq, iostat, zero);
- auto ifOp = builder.create<fir::IfOp>(loc, iostatTy, unitIsOK,
- /*withElseRegion=*/true);
+ mlir::Value unitIsOK = mlir::arith::CmpIOp::create(
+ builder, loc, mlir::arith::CmpIPredicate::eq, iostat, zero);
+ auto ifOp = fir::IfOp::create(builder, loc, iostatTy, unitIsOK,
+ /*withElseRegion=*/true);
builder.setInsertionPointToStart(&ifOp.getElseRegion().front());
- builder.create<fir::ResultOp>(loc, iostat);
+ fir::ResultOp::create(builder, loc, iostat);
builder.setInsertionPointToStart(&ifOp.getThenRegion().front());
stmtCtx.pushScope();
csi.bigUnitIfOp = ifOp;
@@ -1846,8 +1851,8 @@ static mlir::Value genIOUnit(Fortran::lower::AbstractConverter &converter,
&iounit->u))
return genIOUnitNumber(converter, loc, Fortran::semantics::GetExpr(*e),
ty, csi, stmtCtx);
- return builder.create<mlir::arith::ConstantOp>(
- loc, builder.getIntegerAttr(ty, defaultUnitNumber));
+ return mlir::arith::ConstantOp::create(
+ builder, loc, builder.getIntegerAttr(ty, defaultUnitNumber));
}
template <typename A>
@@ -1879,8 +1884,8 @@ static mlir::Value genBasicIOStmt(Fortran::lower::AbstractConverter &converter,
mlir::Value un = builder.createConvert(loc, beginFuncTy.getInput(0), unit);
mlir::Value file = locToFilename(converter, loc, beginFuncTy.getInput(1));
mlir::Value line = locToLineNo(converter, loc, beginFuncTy.getInput(2));
- auto call = builder.create<fir::CallOp>(loc, beginFunc,
- mlir::ValueRange{un, file, line});
+ auto call = fir::CallOp::create(builder, loc, beginFunc,
+ mlir::ValueRange{un, file, line});
mlir::Value cookie = call.getResult(0);
genConditionHandlerCall(converter, loc, cookie, stmt.v, csi);
mlir::Value ok;
@@ -1934,7 +1939,7 @@ genNewunitSpec(Fortran::lower::AbstractConverter &converter, mlir::Location loc,
auto kind = builder.createIntegerConstant(loc, ioFuncTy.getInput(2),
var->GetType().value().kind());
llvm::SmallVector<mlir::Value> ioArgs = {cookie, addr, kind};
- return builder.create<fir::CallOp>(loc, ioFunc, ioArgs).getResult(0);
+ return fir::CallOp::create(builder, loc, ioFunc, ioArgs).getResult(0);
}
llvm_unreachable("missing Newunit spec");
}
@@ -1969,7 +1974,7 @@ Fortran::lower::genOpenStatement(Fortran::lower::AbstractConverter &converter,
beginArgs.push_back(locToLineNo(converter, loc, beginFuncTy.getInput(1)));
}
auto cookie =
- builder.create<fir::CallOp>(loc, beginFunc, beginArgs).getResult(0);
+ fir::CallOp::create(builder, loc, beginFunc, beginArgs).getResult(0);
genConditionHandlerCall(converter, loc, cookie, stmt.v, csi);
mlir::Value ok;
auto insertPt = builder.saveInsertionPoint();
@@ -2013,7 +2018,7 @@ Fortran::lower::genWaitStatement(Fortran::lower::AbstractConverter &converter,
args.push_back(locToFilename(converter, loc, beginFuncTy.getInput(1)));
args.push_back(locToLineNo(converter, loc, beginFuncTy.getInput(2)));
}
- auto cookie = builder.create<fir::CallOp>(loc, beginFunc, args).getResult(0);
+ auto cookie = fir::CallOp::create(builder, loc, beginFunc, args).getResult(0);
genConditionHandlerCall(converter, loc, cookie, stmt.v, csi);
return genEndIO(converter, converter.getCurrentLocation(), cookie, csi,
stmtCtx);
@@ -2149,9 +2154,10 @@ void genBeginDataTransferCallArgs(
}
} else { // PRINT - maybe explicit format; default unit
maybeGetFormatArgs();
- ioArgs.push_back(builder.create<mlir::arith::ConstantOp>(
- loc, builder.getIntegerAttr(ioFuncTy.getInput(ioArgs.size()),
- defaultUnitNumber)));
+ ioArgs.push_back(mlir::arith::ConstantOp::create(
+ builder, loc,
+ builder.getIntegerAttr(ioFuncTy.getInput(ioArgs.size()),
+ defaultUnitNumber)));
}
// File name and line number are always the last two arguments.
ioArgs.push_back(
@@ -2198,7 +2204,7 @@ genDataTransferStmt(Fortran::lower::AbstractConverter &converter,
ioArgs, converter, loc, stmt, ioFunc.getFunctionType(), isFormatted,
isList || isNml, isInternal, descRef, csi, stmtCtx);
mlir::Value cookie =
- builder.create<fir::CallOp>(loc, ioFunc, ioArgs).getResult(0);
+ fir::CallOp::create(builder, loc, ioFunc, ioArgs).getResult(0);
auto insertPt = builder.saveInsertionPoint();
mlir::Value ok;
@@ -2332,7 +2338,7 @@ mlir::Value genInquireSpec<Fortran::parser::InquireSpec::CharVar>(
.c_str())),
builder.createConvert(loc, specFuncTy.getInput(2), fir::getBase(str)),
builder.createConvert(loc, specFuncTy.getInput(3), fir::getLen(str))};
- return builder.create<fir::CallOp>(loc, specFunc, args).getResult(0);
+ return fir::CallOp::create(builder, loc, specFunc, args).getResult(0);
}
/// Specialization for INTEGER.
template <>
@@ -2369,7 +2375,7 @@ mlir::Value genInquireSpec<Fortran::parser::InquireSpec::IntVar>(
.c_str())),
builder.createConvert(loc, specFuncTy.getInput(2), addr),
builder.createConvert(loc, specFuncTy.getInput(3), kind)};
- return builder.create<fir::CallOp>(loc, specFunc, args).getResult(0);
+ return fir::CallOp::create(builder, loc, specFunc, args).getResult(0);
}
/// Specialization for LOGICAL and (PENDING + ID).
template <>
@@ -2406,7 +2412,7 @@ mlir::Value genInquireSpec<Fortran::parser::InquireSpec::LogVar>(
Fortran::parser::InquireSpec::LogVar::EnumToString(logVarKind)}
.c_str())));
args.push_back(builder.createConvert(loc, specFuncTy.getInput(2), addr));
- auto call = builder.create<fir::CallOp>(loc, specFunc, args);
+ auto call = fir::CallOp::create(builder, loc, specFunc, args);
boolRefToLogical(loc, builder, addr);
return call.getResult(0);
}
@@ -2502,7 +2508,7 @@ mlir::Value Fortran::lower::genInquireStatement(
beginArgs = {locToFilename(converter, loc, beginFuncTy.getInput(0)),
locToLineNo(converter, loc, beginFuncTy.getInput(1))};
auto cookie =
- builder.create<fir::CallOp>(loc, beginFunc, beginArgs).getResult(0);
+ fir::CallOp::create(builder, loc, beginFunc, beginArgs).getResult(0);
mlir::Value ok;
genOutputItemList(
converter, cookie,
@@ -2523,14 +2529,14 @@ mlir::Value Fortran::lower::genInquireStatement(
.getResult(0);
mlir::Value length1 =
builder.createConvert(loc, converter.genType(*ioLengthVar), length);
- builder.create<fir::StoreOp>(loc, length1, ioLengthVarAddr);
+ fir::StoreOp::create(builder, loc, length1, ioLengthVarAddr);
return genEndIO(converter, loc, cookie, csi, stmtCtx);
}
// Common handling for inquire by unit or file.
assert(list && "inquire-spec list must be present");
auto cookie =
- builder.create<fir::CallOp>(loc, beginFunc, beginArgs).getResult(0);
+ fir::CallOp::create(builder, loc, beginFunc, beginArgs).getResult(0);
genConditionHandlerCall(converter, loc, cookie, *list, csi);
// Handle remaining arguments in specifier list.
mlir::Value ok;
diff --git a/flang/lib/Lower/OpenACC.cpp b/flang/lib/Lower/OpenACC.cpp
index 51eb33dec186b..471f3685974cd 100644
--- a/flang/lib/Lower/OpenACC.cpp
+++ b/flang/lib/Lower/OpenACC.cpp
@@ -132,21 +132,21 @@ createDataEntryOp(fir::FirOpBuilder &builder, mlir::Location loc,
/*withElseRegion=*/true)
.genThen([&]() {
if (fir::isBoxAddress(baseAddr.getType()))
- baseAddr = builder.create<fir::LoadOp>(loc, baseAddr);
+ baseAddr = fir::LoadOp::create(builder, loc, baseAddr);
mlir::Value boxAddr =
- builder.create<fir::BoxAddrOp>(loc, baseAddr);
- builder.create<fir::ResultOp>(loc, mlir::ValueRange{boxAddr});
+ fir::BoxAddrOp::create(builder, loc, baseAddr);
+ fir::ResultOp::create(builder, loc, mlir::ValueRange{boxAddr});
})
.genElse([&] {
mlir::Value absent =
- builder.create<fir::AbsentOp>(loc, ifRetTy);
- builder.create<fir::ResultOp>(loc, mlir::ValueRange{absent});
+ fir::AbsentOp::create(builder, loc, ifRetTy);
+ fir::ResultOp::create(builder, loc, mlir::ValueRange{absent});
})
.getResults()[0];
} else {
if (fir::isBoxAddress(baseAddr.getType()))
- baseAddr = builder.create<fir::LoadOp>(loc, baseAddr);
- baseAddr = builder.create<fir::BoxAddrOp>(loc, baseAddr);
+ baseAddr = fir::LoadOp::create(builder, loc, baseAddr);
+ baseAddr = fir::BoxAddrOp::create(builder, loc, baseAddr);
}
retTy = baseAddr.getType();
}
@@ -159,7 +159,7 @@ createDataEntryOp(fir::FirOpBuilder &builder, mlir::Location loc,
addOperands(operands, operandSegments, bounds);
addOperands(operands, operandSegments, async);
- Op op = builder.create<Op>(loc, retTy, operands);
+ Op op = Op::create(builder, loc, retTy, operands);
op.setNameAttr(builder.getStringAttr(name.str()));
op.setStructured(structured);
op.setImplicit(implicit);
@@ -198,12 +198,12 @@ createDeclareFunc(mlir::OpBuilder &modBuilder, fir::FirOpBuilder &builder,
llvm::SmallVector<mlir::Type> argsTy = {},
llvm::SmallVector<mlir::Location> locs = {}) {
auto funcTy = mlir::FunctionType::get(modBuilder.getContext(), argsTy, {});
- auto funcOp = modBuilder.create<mlir::func::FuncOp>(loc, funcName, funcTy);
+ auto funcOp = mlir::func::FuncOp::create(modBuilder, loc, funcName, funcTy);
funcOp.setVisibility(mlir::SymbolTable::Visibility::Private);
builder.createBlock(&funcOp.getRegion(), funcOp.getRegion().end(), argsTy,
locs);
builder.setInsertionPointToEnd(&funcOp.getRegion().back());
- builder.create<mlir::func::ReturnOp>(loc);
+ mlir::func::ReturnOp::create(builder, loc);
builder.setInsertionPointToStart(&funcOp.getRegion().back());
return funcOp;
}
@@ -214,7 +214,7 @@ createSimpleOp(fir::FirOpBuilder &builder, mlir::Location loc,
const llvm::SmallVectorImpl<mlir::Value> &operands,
const llvm::SmallVectorImpl<int32_t> &operandSegments) {
llvm::ArrayRef<mlir::Type> argTy;
- Op op = builder.create<Op>(loc, argTy, operands);
+ Op op = Op::create(builder, loc, argTy, operands);
op->setAttr(Op::getOperandSegmentSizeAttr(),
builder.getDenseI32ArrayAttr(operandSegments));
return op;
@@ -257,15 +257,15 @@ static void createDeclareAllocFuncWithArg(mlir::OpBuilder &modBuilder,
if (unwrapFirBox) {
mlir::Value desc =
- builder.create<fir::LoadOp>(loc, registerFuncOp.getArgument(0));
- fir::BoxAddrOp boxAddrOp = builder.create<fir::BoxAddrOp>(loc, desc);
+ fir::LoadOp::create(builder, loc, registerFuncOp.getArgument(0));
+ fir::BoxAddrOp boxAddrOp = fir::BoxAddrOp::create(builder, loc, desc);
addDeclareAttr(builder, boxAddrOp.getOperation(), clause);
EntryOp entryOp = createDataEntryOp<EntryOp>(
builder, loc, boxAddrOp.getResult(), asFortran, bounds,
/*structured=*/false, /*implicit=*/false, clause, boxAddrOp.getType(),
/*async=*/{}, /*asyncDeviceTypes=*/{}, /*asyncOnlyDeviceTypes=*/{});
- builder.create<mlir::acc::DeclareEnterOp>(
- loc, mlir::acc::DeclareTokenType::get(entryOp.getContext()),
+ mlir::acc::DeclareEnterOp::create(
+ builder, loc, mlir::acc::DeclareTokenType::get(entryOp.getContext()),
mlir::ValueRange(entryOp.getAccVar()));
}
@@ -291,8 +291,8 @@ static void createDeclareDeallocFuncWithArg(
mlir::Value var = preDeallocOp.getArgument(0);
if (unwrapFirBox) {
mlir::Value loadOp =
- builder.create<fir::LoadOp>(loc, preDeallocOp.getArgument(0));
- fir::BoxAddrOp boxAddrOp = builder.create<fir::BoxAddrOp>(loc, loadOp);
+ fir::LoadOp::create(builder, loc, preDeallocOp.getArgument(0));
+ fir::BoxAddrOp boxAddrOp = fir::BoxAddrOp::create(builder, loc, loadOp);
addDeclareAttr(builder, boxAddrOp.getOperation(), clause);
var = boxAddrOp.getResult();
}
@@ -303,25 +303,25 @@ static void createDeclareDeallocFuncWithArg(
builder, loc, var, asFortran, bounds,
/*structured=*/false, /*implicit=*/false, clause, var.getType(),
/*async=*/{}, /*asyncDeviceTypes=*/{}, /*asyncOnlyDeviceTypes=*/{});
- builder.create<mlir::acc::DeclareExitOp>(
- loc, mlir::Value{}, mlir::ValueRange(entryOp.getAccVar()));
+ mlir::acc::DeclareExitOp::create(builder, loc, mlir::Value{},
+ mlir::ValueRange(entryOp.getAccVar()));
if constexpr (std::is_same_v<ExitOp, mlir::acc::CopyoutOp> ||
std::is_same_v<ExitOp, mlir::acc::UpdateHostOp>)
- builder.create<ExitOp>(entryOp.getLoc(), entryOp.getAccVar(),
- entryOp.getVar(), entryOp.getVarType(),
- entryOp.getBounds(), entryOp.getAsyncOperands(),
- entryOp.getAsyncOperandsDeviceTypeAttr(),
- entryOp.getAsyncOnlyAttr(), entryOp.getDataClause(),
- /*structured=*/false, /*implicit=*/false,
- builder.getStringAttr(*entryOp.getName()));
+ ExitOp::create(builder, entryOp.getLoc(), entryOp.getAccVar(),
+ entryOp.getVar(), entryOp.getVarType(), entryOp.getBounds(),
+ entryOp.getAsyncOperands(),
+ entryOp.getAsyncOperandsDeviceTypeAttr(),
+ entryOp.getAsyncOnlyAttr(), entryOp.getDataClause(),
+ /*structured=*/false, /*implicit=*/false,
+ builder.getStringAttr(*entryOp.getName()));
else
- builder.create<ExitOp>(entryOp.getLoc(), entryOp.getAccVar(),
- entryOp.getBounds(), entryOp.getAsyncOperands(),
- entryOp.getAsyncOperandsDeviceTypeAttr(),
- entryOp.getAsyncOnlyAttr(), entryOp.getDataClause(),
- /*structured=*/false, /*implicit=*/false,
- builder.getStringAttr(*entryOp.getName()));
+ ExitOp::create(builder, entryOp.getLoc(), entryOp.getAccVar(),
+ entryOp.getBounds(), entryOp.getAsyncOperands(),
+ entryOp.getAsyncOperandsDeviceTypeAttr(),
+ entryOp.getAsyncOnlyAttr(), entryOp.getDataClause(),
+ /*structured=*/false, /*implicit=*/false,
+ builder.getStringAttr(*entryOp.getName()));
// Generate the post dealloc function.
modBuilder.setInsertionPointAfter(preDeallocOp);
@@ -333,7 +333,7 @@ static void createDeclareDeallocFuncWithArg(
var = postDeallocOp.getArgument(0);
if (unwrapFirBox) {
- var = builder.create<fir::LoadOp>(loc, postDeallocOp.getArgument(0));
+ var = fir::LoadOp::create(builder, loc, postDeallocOp.getArgument(0));
asFortran << accFirDescriptorPostfix.str();
}
@@ -385,8 +385,8 @@ genAtomicCaptureStatement(Fortran::lower::AbstractConverter &converter,
// Generate `atomic.read` operation for atomic assigment statements
fir::FirOpBuilder &firOpBuilder = converter.getFirOpBuilder();
- firOpBuilder.create<mlir::acc::AtomicReadOp>(
- loc, fromAddress, toAddress, mlir::TypeAttr::get(elementType));
+ mlir::acc::AtomicReadOp::create(firOpBuilder, loc, fromAddress, toAddress,
+ mlir::TypeAttr::get(elementType));
}
/// Used to generate atomic.write operation which is created in existing
@@ -406,7 +406,7 @@ genAtomicWriteStatement(Fortran::lower::AbstractConverter &converter,
rhsExpr = firOpBuilder.createConvert(loc, varType, rhsExpr);
firOpBuilder.restoreInsertionPoint(insertionPoint);
- firOpBuilder.create<mlir::acc::AtomicWriteOp>(loc, lhsAddr, rhsExpr);
+ mlir::acc::AtomicWriteOp::create(firOpBuilder, loc, lhsAddr, rhsExpr);
}
/// Used to generate atomic.update operation which is created in existing
@@ -522,7 +522,7 @@ static inline void genAtomicUpdateStatement(
mlir::Operation *atomicUpdateOp = nullptr;
atomicUpdateOp =
- firOpBuilder.create<mlir::acc::AtomicUpdateOp>(currentLocation, lhsAddr);
+ mlir::acc::AtomicUpdateOp::create(firOpBuilder, currentLocation, lhsAddr);
llvm::SmallVector<mlir::Type> varTys = {varType};
llvm::SmallVector<mlir::Location> locs = {currentLocation};
@@ -540,7 +540,7 @@ static inline void genAtomicUpdateStatement(
*Fortran::semantics::GetExpr(assignmentStmtExpr), atomicStmtCtx));
mlir::Value convertResult =
firOpBuilder.createConvert(currentLocation, varType, rhsExpr);
- firOpBuilder.create<mlir::acc::YieldOp>(currentLocation, convertResult);
+ mlir::acc::YieldOp::create(firOpBuilder, currentLocation, convertResult);
converter.resetExprOverrides();
}
firOpBuilder.setInsertionPointAfter(atomicUpdateOp);
@@ -647,7 +647,7 @@ void genAtomicCapture(Fortran::lower::AbstractConverter &converter,
fir::getBase(converter.genExprValue(assign2.lhs, stmtCtx)).getType();
mlir::Operation *atomicCaptureOp = nullptr;
- atomicCaptureOp = firOpBuilder.create<mlir::acc::AtomicCaptureOp>(loc);
+ atomicCaptureOp = mlir::acc::AtomicCaptureOp::create(firOpBuilder, loc);
firOpBuilder.createBlock(&(atomicCaptureOp->getRegion(0)));
mlir::Block &block = atomicCaptureOp->getRegion(0).back();
@@ -688,7 +688,7 @@ void genAtomicCapture(Fortran::lower::AbstractConverter &converter,
loc);
}
firOpBuilder.setInsertionPointToEnd(&block);
- firOpBuilder.create<mlir::acc::TerminatorOp>(loc);
+ mlir::acc::TerminatorOp::create(firOpBuilder, loc);
// The clean-ups associated with the statements inside the capture
// construct must be generated after the AtomicCaptureOp.
firOpBuilder.setInsertionPointAfter(atomicCaptureOp);
@@ -839,15 +839,15 @@ genDataExitOperations(fir::FirOpBuilder &builder,
mlir::Location opLoc = exitLoc ? *exitLoc : entryOp.getLoc();
if constexpr (std::is_same_v<ExitOp, mlir::acc::CopyoutOp> ||
std::is_same_v<ExitOp, mlir::acc::UpdateHostOp>)
- builder.create<ExitOp>(
- opLoc, entryOp.getAccVar(), entryOp.getVar(), entryOp.getVarType(),
- entryOp.getBounds(), entryOp.getAsyncOperands(),
+ ExitOp::create(
+ builder, opLoc, entryOp.getAccVar(), entryOp.getVar(),
+ entryOp.getVarType(), entryOp.getBounds(), entryOp.getAsyncOperands(),
entryOp.getAsyncOperandsDeviceTypeAttr(), entryOp.getAsyncOnlyAttr(),
entryOp.getDataClause(), structured, entryOp.getImplicit(),
builder.getStringAttr(*entryOp.getName()));
else
- builder.create<ExitOp>(
- opLoc, entryOp.getAccVar(), entryOp.getBounds(),
+ ExitOp::create(
+ builder, opLoc, entryOp.getAccVar(), entryOp.getBounds(),
entryOp.getAsyncOperands(), entryOp.getAsyncOperandsDeviceTypeAttr(),
entryOp.getAsyncOnlyAttr(), entryOp.getDataClause(), structured,
entryOp.getImplicit(), builder.getStringAttr(*entryOp.getName()));
@@ -859,9 +859,9 @@ fir::ShapeOp genShapeOp(mlir::OpBuilder &builder, fir::SequenceType seqTy,
llvm::SmallVector<mlir::Value> extents;
mlir::Type idxTy = builder.getIndexType();
for (auto extent : seqTy.getShape())
- extents.push_back(builder.create<mlir::arith::ConstantOp>(
- loc, idxTy, builder.getIntegerAttr(idxTy, extent)));
- return builder.create<fir::ShapeOp>(loc, extents);
+ extents.push_back(mlir::arith::ConstantOp::create(
+ builder, loc, idxTy, builder.getIntegerAttr(idxTy, extent)));
+ return fir::ShapeOp::create(builder, loc, extents);
}
/// Get the initial value for reduction operator.
@@ -936,8 +936,8 @@ static mlir::Value getReductionInitValue(fir::FirOpBuilder &builder,
return builder.createBool(loc, value);
}
if (ty.isIntOrIndex())
- return builder.create<mlir::arith::ConstantOp>(
- loc, ty,
+ return mlir::arith::ConstantOp::create(
+ builder, loc, ty,
builder.getIntegerAttr(ty, getReductionInitValue<llvm::APInt>(op, ty)));
if (op == mlir::acc::ReductionOperator::AccMin ||
op == mlir::acc::ReductionOperator::AccMax) {
@@ -945,13 +945,13 @@ static mlir::Value getReductionInitValue(fir::FirOpBuilder &builder,
llvm::report_fatal_error(
"min/max reduction not supported for complex type");
if (auto floatTy = mlir::dyn_cast_or_null<mlir::FloatType>(ty))
- return builder.create<mlir::arith::ConstantOp>(
- loc, ty,
+ return mlir::arith::ConstantOp::create(
+ builder, loc, ty,
builder.getFloatAttr(ty,
getReductionInitValue<llvm::APFloat>(op, ty)));
} else if (auto floatTy = mlir::dyn_cast_or_null<mlir::FloatType>(ty)) {
- return builder.create<mlir::arith::ConstantOp>(
- loc, ty,
+ return mlir::arith::ConstantOp::create(
+ builder, loc, ty,
builder.getFloatAttr(ty, getReductionInitValue<int64_t>(op, ty)));
} else if (auto cmplxTy = mlir::dyn_cast_or_null<mlir::ComplexType>(ty)) {
mlir::Type floatTy = cmplxTy.getElementType();
@@ -985,10 +985,10 @@ static RecipeOp genRecipeOp(
mlir::OpBuilder modBuilder(mod.getBodyRegion());
RecipeOp recipe;
if constexpr (std::is_same_v<RecipeOp, mlir::acc::ReductionRecipeOp>) {
- recipe = modBuilder.create<mlir::acc::ReductionRecipeOp>(loc, recipeName,
- ty, op);
+ recipe = mlir::acc::ReductionRecipeOp::create(modBuilder, loc, recipeName,
+ ty, op);
} else {
- recipe = modBuilder.create<RecipeOp>(loc, recipeName, ty);
+ recipe = RecipeOp::create(modBuilder, loc, recipeName, ty);
}
llvm::SmallVector<mlir::Type> argsTy{ty};
@@ -1032,8 +1032,8 @@ static RecipeOp genRecipeOp(
initName,
initBlock->getArguments().take_back(initBlock->getArguments().size() - 1),
initValue);
- builder.create<mlir::acc::YieldOp>(loc, retVal ? retVal
- : initBlock->getArgument(0));
+ mlir::acc::YieldOp::create(builder, loc,
+ retVal ? retVal : initBlock->getArgument(0));
return recipe;
}
@@ -1132,15 +1132,17 @@ static mlir::Value genShapeFromBoundsOrArgs(
mlir::Value zero = builder.createIntegerConstant(loc, idxTy, 0);
for (unsigned i = 0; i < args.size(); i += 3) {
mlir::Value s1 =
- builder.create<mlir::arith::SubIOp>(loc, args[i + 1], args[0]);
- mlir::Value s2 = builder.create<mlir::arith::AddIOp>(loc, s1, one);
- mlir::Value s3 = builder.create<mlir::arith::DivSIOp>(loc, s2, args[i + 2]);
- mlir::Value cmp = builder.create<mlir::arith::CmpIOp>(
- loc, mlir::arith::CmpIPredicate::sgt, s3, zero);
- mlir::Value ext = builder.create<mlir::arith::SelectOp>(loc, cmp, s3, zero);
+ mlir::arith::SubIOp::create(builder, loc, args[i + 1], args[0]);
+ mlir::Value s2 = mlir::arith::AddIOp::create(builder, loc, s1, one);
+ mlir::Value s3 =
+ mlir::arith::DivSIOp::create(builder, loc, s2, args[i + 2]);
+ mlir::Value cmp = mlir::arith::CmpIOp::create(
+ builder, loc, mlir::arith::CmpIPredicate::sgt, s3, zero);
+ mlir::Value ext =
+ mlir::arith::SelectOp::create(builder, loc, cmp, s3, zero);
extents.push_back(ext);
}
- return builder.create<fir::ShapeOp>(loc, extents);
+ return fir::ShapeOp::create(builder, loc, extents);
}
static hlfir::DesignateOp::Subscripts
@@ -1157,8 +1159,8 @@ static hlfir::Entity genDesignateWithTriplets(
hlfir::DesignateOp::Subscripts &triplets, mlir::Value shape) {
llvm::SmallVector<mlir::Value> lenParams;
hlfir::genLengthParameters(loc, builder, entity, lenParams);
- auto designate = builder.create<hlfir::DesignateOp>(
- loc, entity.getBase().getType(), entity, /*component=*/"",
+ auto designate = hlfir::DesignateOp::create(
+ builder, loc, entity.getBase().getType(), entity, /*component=*/"",
/*componentShape=*/mlir::Value{}, triplets,
/*substring=*/mlir::ValueRange{}, /*complexPartAttr=*/std::nullopt, shape,
lenParams);
@@ -1198,22 +1200,22 @@ mlir::acc::FirstprivateRecipeOp Fortran::lower::createOrGetFirstprivateRecipe(
builder.setInsertionPointToEnd(&recipe.getCopyRegion().back());
ty = fir::unwrapRefType(ty);
if (fir::isa_trivial(ty)) {
- mlir::Value initValue = builder.create<fir::LoadOp>(
- loc, recipe.getCopyRegion().front().getArgument(0));
- builder.create<fir::StoreOp>(loc, initValue,
- recipe.getCopyRegion().front().getArgument(1));
+ mlir::Value initValue = fir::LoadOp::create(
+ builder, loc, recipe.getCopyRegion().front().getArgument(0));
+ fir::StoreOp::create(builder, loc, initValue,
+ recipe.getCopyRegion().front().getArgument(1));
} else if (auto seqTy = mlir::dyn_cast_or_null<fir::SequenceType>(ty)) {
fir::FirOpBuilder firBuilder{builder, recipe.getOperation()};
auto shape = genShapeFromBoundsOrArgs(
loc, firBuilder, seqTy, bounds, recipe.getCopyRegion().getArguments());
- auto leftDeclOp = builder.create<hlfir::DeclareOp>(
- loc, recipe.getCopyRegion().getArgument(0), llvm::StringRef{}, shape,
- llvm::ArrayRef<mlir::Value>{}, /*dummy_scope=*/nullptr,
+ auto leftDeclOp = hlfir::DeclareOp::create(
+ builder, loc, recipe.getCopyRegion().getArgument(0), llvm::StringRef{},
+ shape, llvm::ArrayRef<mlir::Value>{}, /*dummy_scope=*/nullptr,
fir::FortranVariableFlagsAttr{});
- auto rightDeclOp = builder.create<hlfir::DeclareOp>(
- loc, recipe.getCopyRegion().getArgument(1), llvm::StringRef{}, shape,
- llvm::ArrayRef<mlir::Value>{}, /*dummy_scope=*/nullptr,
+ auto rightDeclOp = hlfir::DeclareOp::create(
+ builder, loc, recipe.getCopyRegion().getArgument(1), llvm::StringRef{},
+ shape, llvm::ArrayRef<mlir::Value>{}, /*dummy_scope=*/nullptr,
fir::FortranVariableFlagsAttr{});
hlfir::DesignateOp::Subscripts triplets =
@@ -1225,7 +1227,7 @@ mlir::acc::FirstprivateRecipeOp Fortran::lower::createOrGetFirstprivateRecipe(
auto right =
genDesignateWithTriplets(firBuilder, loc, rightEntity, triplets, shape);
- firBuilder.create<hlfir::AssignOp>(loc, left, right);
+ hlfir::AssignOp::create(firBuilder, loc, left, right);
} else if (auto boxTy = mlir::dyn_cast_or_null<fir::BaseBoxType>(ty)) {
fir::FirOpBuilder firBuilder{builder, recipe.getOperation()};
@@ -1246,10 +1248,10 @@ mlir::acc::FirstprivateRecipeOp Fortran::lower::createOrGetFirstprivateRecipe(
auto rightEntity = hlfir::Entity{recipe.getCopyRegion().getArgument(1)};
auto right =
genDesignateWithTriplets(firBuilder, loc, rightEntity, triplets, shape);
- firBuilder.create<hlfir::AssignOp>(loc, left, right);
+ hlfir::AssignOp::create(firBuilder, loc, left, right);
}
- builder.create<mlir::acc::TerminatorOp>(loc);
+ mlir::acc::TerminatorOp::create(builder, loc);
builder.restoreInsertionPoint(ip);
return recipe;
}
@@ -1414,10 +1416,10 @@ static mlir::Value genLogicalCombiner(fir::FirOpBuilder &builder,
mlir::Location loc, mlir::Value value1,
mlir::Value value2) {
mlir::Type i1 = builder.getI1Type();
- mlir::Value v1 = builder.create<fir::ConvertOp>(loc, i1, value1);
- mlir::Value v2 = builder.create<fir::ConvertOp>(loc, i1, value2);
- mlir::Value combined = builder.create<Op>(loc, v1, v2);
- return builder.create<fir::ConvertOp>(loc, value1.getType(), combined);
+ mlir::Value v1 = fir::ConvertOp::create(builder, loc, i1, value1);
+ mlir::Value v2 = fir::ConvertOp::create(builder, loc, i1, value2);
+ mlir::Value combined = Op::create(builder, loc, v1, v2);
+ return fir::ConvertOp::create(builder, loc, value1.getType(), combined);
}
static mlir::Value genComparisonCombiner(fir::FirOpBuilder &builder,
@@ -1426,10 +1428,10 @@ static mlir::Value genComparisonCombiner(fir::FirOpBuilder &builder,
mlir::Value value1,
mlir::Value value2) {
mlir::Type i1 = builder.getI1Type();
- mlir::Value v1 = builder.create<fir::ConvertOp>(loc, i1, value1);
- mlir::Value v2 = builder.create<fir::ConvertOp>(loc, i1, value2);
- mlir::Value add = builder.create<mlir::arith::CmpIOp>(loc, pred, v1, v2);
- return builder.create<fir::ConvertOp>(loc, value1.getType(), add);
+ mlir::Value v1 = fir::ConvertOp::create(builder, loc, i1, value1);
+ mlir::Value v2 = fir::ConvertOp::create(builder, loc, i1, value2);
+ mlir::Value add = mlir::arith::CmpIOp::create(builder, loc, pred, v1, v2);
+ return fir::ConvertOp::create(builder, loc, value1.getType(), add);
}
static mlir::Value genScalarCombiner(fir::FirOpBuilder &builder,
@@ -1441,21 +1443,21 @@ static mlir::Value genScalarCombiner(fir::FirOpBuilder &builder,
value2 = builder.loadIfRef(loc, value2);
if (op == mlir::acc::ReductionOperator::AccAdd) {
if (ty.isIntOrIndex())
- return builder.create<mlir::arith::AddIOp>(loc, value1, value2);
+ return mlir::arith::AddIOp::create(builder, loc, value1, value2);
if (mlir::isa<mlir::FloatType>(ty))
- return builder.create<mlir::arith::AddFOp>(loc, value1, value2);
+ return mlir::arith::AddFOp::create(builder, loc, value1, value2);
if (auto cmplxTy = mlir::dyn_cast_or_null<mlir::ComplexType>(ty))
- return builder.create<fir::AddcOp>(loc, value1, value2);
+ return fir::AddcOp::create(builder, loc, value1, value2);
TODO(loc, "reduction add type");
}
if (op == mlir::acc::ReductionOperator::AccMul) {
if (ty.isIntOrIndex())
- return builder.create<mlir::arith::MulIOp>(loc, value1, value2);
+ return mlir::arith::MulIOp::create(builder, loc, value1, value2);
if (mlir::isa<mlir::FloatType>(ty))
- return builder.create<mlir::arith::MulFOp>(loc, value1, value2);
+ return mlir::arith::MulFOp::create(builder, loc, value1, value2);
if (mlir::isa<mlir::ComplexType>(ty))
- return builder.create<fir::MulcOp>(loc, value1, value2);
+ return fir::MulcOp::create(builder, loc, value1, value2);
TODO(loc, "reduction mul type");
}
@@ -1466,13 +1468,13 @@ static mlir::Value genScalarCombiner(fir::FirOpBuilder &builder,
return fir::genMax(builder, loc, {value1, value2});
if (op == mlir::acc::ReductionOperator::AccIand)
- return builder.create<mlir::arith::AndIOp>(loc, value1, value2);
+ return mlir::arith::AndIOp::create(builder, loc, value1, value2);
if (op == mlir::acc::ReductionOperator::AccIor)
- return builder.create<mlir::arith::OrIOp>(loc, value1, value2);
+ return mlir::arith::OrIOp::create(builder, loc, value1, value2);
if (op == mlir::acc::ReductionOperator::AccXor)
- return builder.create<mlir::arith::XOrIOp>(loc, value1, value2);
+ return mlir::arith::XOrIOp::create(builder, loc, value1, value2);
if (op == mlir::acc::ReductionOperator::AccLand)
return genLogicalCombiner<mlir::arith::AndIOp>(builder, loc, value1,
@@ -1520,19 +1522,21 @@ static void genCombiner(fir::FirOpBuilder &builder, mlir::Location loc,
auto shape =
genShapeFromBoundsOrArgs(loc, builder, seqTy, bounds,
recipe.getCombinerRegion().getArguments());
- auto v1DeclareOp = builder.create<hlfir::DeclareOp>(
- loc, value1, llvm::StringRef{}, shape, llvm::ArrayRef<mlir::Value>{},
+ auto v1DeclareOp = hlfir::DeclareOp::create(
+ builder, loc, value1, llvm::StringRef{}, shape,
+ llvm::ArrayRef<mlir::Value>{},
/*dummy_scope=*/nullptr, fir::FortranVariableFlagsAttr{});
- auto v2DeclareOp = builder.create<hlfir::DeclareOp>(
- loc, value2, llvm::StringRef{}, shape, llvm::ArrayRef<mlir::Value>{},
+ auto v2DeclareOp = hlfir::DeclareOp::create(
+ builder, loc, value2, llvm::StringRef{}, shape,
+ llvm::ArrayRef<mlir::Value>{},
/*dummy_scope=*/nullptr, fir::FortranVariableFlagsAttr{});
hlfir::DesignateOp::Subscripts triplets = getTripletsFromArgs(recipe);
llvm::SmallVector<mlir::Value> lenParamsLeft;
auto leftEntity = hlfir::Entity{v1DeclareOp.getBase()};
hlfir::genLengthParameters(loc, builder, leftEntity, lenParamsLeft);
- auto leftDesignate = builder.create<hlfir::DesignateOp>(
- loc, v1DeclareOp.getBase().getType(), v1DeclareOp.getBase(),
+ auto leftDesignate = hlfir::DesignateOp::create(
+ builder, loc, v1DeclareOp.getBase().getType(), v1DeclareOp.getBase(),
/*component=*/"",
/*componentShape=*/mlir::Value{}, triplets,
/*substring=*/mlir::ValueRange{}, /*complexPartAttr=*/std::nullopt,
@@ -1542,8 +1546,8 @@ static void genCombiner(fir::FirOpBuilder &builder, mlir::Location loc,
llvm::SmallVector<mlir::Value> lenParamsRight;
auto rightEntity = hlfir::Entity{v2DeclareOp.getBase()};
hlfir::genLengthParameters(loc, builder, rightEntity, lenParamsLeft);
- auto rightDesignate = builder.create<hlfir::DesignateOp>(
- loc, v2DeclareOp.getBase().getType(), v2DeclareOp.getBase(),
+ auto rightDesignate = hlfir::DesignateOp::create(
+ builder, loc, v2DeclareOp.getBase().getType(), v2DeclareOp.getBase(),
/*component=*/"",
/*componentShape=*/mlir::Value{}, triplets,
/*substring=*/mlir::ValueRange{}, /*complexPartAttr=*/std::nullopt,
@@ -1564,21 +1568,21 @@ static void genCombiner(fir::FirOpBuilder &builder, mlir::Location loc,
mlir::Value elemental = hlfir::genElementalOp(
loc, builder, seqTy.getEleTy(), shape, typeParams, genKernel,
/*isUnordered=*/true);
- builder.create<hlfir::AssignOp>(loc, elemental, v1DeclareOp.getBase());
+ hlfir::AssignOp::create(builder, loc, elemental, v1DeclareOp.getBase());
return;
}
if (bounds.empty()) {
llvm::SmallVector<mlir::Value> extents;
mlir::Type idxTy = builder.getIndexType();
for (auto extent : seqTy.getShape()) {
- mlir::Value lb = builder.create<mlir::arith::ConstantOp>(
- loc, idxTy, builder.getIntegerAttr(idxTy, 0));
- mlir::Value ub = builder.create<mlir::arith::ConstantOp>(
- loc, idxTy, builder.getIntegerAttr(idxTy, extent - 1));
- mlir::Value step = builder.create<mlir::arith::ConstantOp>(
- loc, idxTy, builder.getIntegerAttr(idxTy, 1));
- auto loop = builder.create<fir::DoLoopOp>(loc, lb, ub, step,
- /*unordered=*/false);
+ mlir::Value lb = mlir::arith::ConstantOp::create(
+ builder, loc, idxTy, builder.getIntegerAttr(idxTy, 0));
+ mlir::Value ub = mlir::arith::ConstantOp::create(
+ builder, loc, idxTy, builder.getIntegerAttr(idxTy, extent - 1));
+ mlir::Value step = mlir::arith::ConstantOp::create(
+ builder, loc, idxTy, builder.getIntegerAttr(idxTy, 1));
+ auto loop = fir::DoLoopOp::create(builder, loc, lb, ub, step,
+ /*unordered=*/false);
builder.setInsertionPointToStart(loop.getBody());
loops.push_back(loop);
ivs.push_back(loop.getInductionVar());
@@ -1594,8 +1598,8 @@ static void genCombiner(fir::FirOpBuilder &builder, mlir::Location loc,
llvm::SmallVector<mlir::Value> values =
genConstantBounds(builder, loc, dataBound);
auto loop =
- builder.create<fir::DoLoopOp>(loc, values[0], values[1], values[2],
- /*unordered=*/false);
+ fir::DoLoopOp::create(builder, loc, values[0], values[1], values[2],
+ /*unordered=*/false);
builder.setInsertionPointToStart(loop.getBody());
loops.push_back(loop);
ivs.push_back(loop.getInductionVar());
@@ -1611,31 +1615,31 @@ static void genCombiner(fir::FirOpBuilder &builder, mlir::Location loc,
mlir::Value lb = recipe.getCombinerRegion().getArgument(i);
mlir::Value ub = recipe.getCombinerRegion().getArgument(i + 1);
mlir::Value step = recipe.getCombinerRegion().getArgument(i + 2);
- auto loop = builder.create<fir::DoLoopOp>(loc, lb, ub, step,
- /*unordered=*/false);
+ auto loop = fir::DoLoopOp::create(builder, loc, lb, ub, step,
+ /*unordered=*/false);
builder.setInsertionPointToStart(loop.getBody());
loops.push_back(loop);
ivs.push_back(loop.getInductionVar());
}
}
- auto addr1 = builder.create<fir::CoordinateOp>(loc, refTy, value1, ivs);
- auto addr2 = builder.create<fir::CoordinateOp>(loc, refTy, value2, ivs);
- auto load1 = builder.create<fir::LoadOp>(loc, addr1);
- auto load2 = builder.create<fir::LoadOp>(loc, addr2);
+ auto addr1 = fir::CoordinateOp::create(builder, loc, refTy, value1, ivs);
+ auto addr2 = fir::CoordinateOp::create(builder, loc, refTy, value2, ivs);
+ auto load1 = fir::LoadOp::create(builder, loc, addr1);
+ auto load2 = fir::LoadOp::create(builder, loc, addr2);
mlir::Value res =
genScalarCombiner(builder, loc, op, seqTy.getEleTy(), load1, load2);
- builder.create<fir::StoreOp>(loc, res, addr1);
+ fir::StoreOp::create(builder, loc, res, addr1);
builder.setInsertionPointAfter(loops[0]);
} else if (auto boxTy = mlir::dyn_cast<fir::BaseBoxType>(ty)) {
mlir::Type innerTy = fir::unwrapRefType(boxTy.getEleTy());
if (fir::isa_trivial(innerTy)) {
mlir::Value boxAddr1 = value1, boxAddr2 = value2;
if (fir::isBoxAddress(boxAddr1.getType()))
- boxAddr1 = builder.create<fir::LoadOp>(loc, boxAddr1);
+ boxAddr1 = fir::LoadOp::create(builder, loc, boxAddr1);
if (fir::isBoxAddress(boxAddr2.getType()))
- boxAddr2 = builder.create<fir::LoadOp>(loc, boxAddr2);
- boxAddr1 = builder.create<fir::BoxAddrOp>(loc, boxAddr1);
- boxAddr2 = builder.create<fir::BoxAddrOp>(loc, boxAddr2);
+ boxAddr2 = fir::LoadOp::create(builder, loc, boxAddr2);
+ boxAddr1 = fir::BoxAddrOp::create(builder, loc, boxAddr1);
+ boxAddr2 = fir::BoxAddrOp::create(builder, loc, boxAddr2);
auto leftEntity = hlfir::Entity{boxAddr1};
auto rightEntity = hlfir::Entity{boxAddr2};
@@ -1643,7 +1647,7 @@ static void genCombiner(fir::FirOpBuilder &builder, mlir::Location loc,
auto rightVal = hlfir::loadTrivialScalar(loc, builder, rightEntity);
mlir::Value res =
genScalarCombiner(builder, loc, op, innerTy, leftVal, rightVal);
- builder.create<hlfir::AssignOp>(loc, res, boxAddr1);
+ hlfir::AssignOp::create(builder, loc, res, boxAddr1);
} else {
mlir::Type innerTy = fir::extractSequenceType(boxTy);
fir::SequenceType seqTy =
@@ -1658,14 +1662,14 @@ static void genCombiner(fir::FirOpBuilder &builder, mlir::Location loc,
getSubscriptsFromArgs(recipe.getCombinerRegion().getArguments());
auto leftEntity = hlfir::Entity{value1};
if (fir::isBoxAddress(value1.getType()))
- leftEntity =
- hlfir::Entity{builder.create<fir::LoadOp>(loc, value1).getResult()};
+ leftEntity = hlfir::Entity{
+ fir::LoadOp::create(builder, loc, value1).getResult()};
auto left =
genDesignateWithTriplets(builder, loc, leftEntity, triplets, shape);
auto rightEntity = hlfir::Entity{value2};
if (fir::isBoxAddress(value2.getType()))
- rightEntity =
- hlfir::Entity{builder.create<fir::LoadOp>(loc, value2).getResult()};
+ rightEntity = hlfir::Entity{
+ fir::LoadOp::create(builder, loc, value2).getResult()};
auto right =
genDesignateWithTriplets(builder, loc, rightEntity, triplets, shape);
@@ -1683,11 +1687,11 @@ static void genCombiner(fir::FirOpBuilder &builder, mlir::Location loc,
mlir::Value elemental = hlfir::genElementalOp(
loc, builder, seqTy.getEleTy(), shape, typeParams, genKernel,
/*isUnordered=*/true);
- builder.create<hlfir::AssignOp>(loc, elemental, value1);
+ hlfir::AssignOp::create(builder, loc, elemental, value1);
}
} else {
mlir::Value res = genScalarCombiner(builder, loc, op, ty, value1, value2);
- builder.create<fir::StoreOp>(loc, res, value1);
+ fir::StoreOp::create(builder, loc, res, value1);
}
}
@@ -1729,7 +1733,7 @@ mlir::acc::ReductionRecipeOp Fortran::lower::createOrGetReductionRecipe(
mlir::Value v1 = recipe.getCombinerRegion().front().getArgument(0);
mlir::Value v2 = recipe.getCombinerRegion().front().getArgument(1);
genCombiner(builder, loc, op, ty, v1, v2, recipe, bounds, allConstantBound);
- builder.create<mlir::acc::YieldOp>(loc, v1);
+ mlir::acc::YieldOp::create(builder, loc, v1);
builder.restoreInsertionPoint(ip);
return recipe;
}
@@ -1821,7 +1825,7 @@ createRegionOp(fir::FirOpBuilder &builder, mlir::Location loc,
llvm::SmallVector<mlir::Type> retTy = {},
mlir::Value yieldValue = {}, mlir::TypeRange argsTy = {},
llvm::SmallVector<mlir::Location> locs = {}) {
- Op op = builder.create<Op>(loc, retTy, operands);
+ Op op = Op::create(builder, loc, retTy, operands);
builder.createBlock(&op.getRegion(), op.getRegion().end(), argsTy, locs);
mlir::Block &block = op.getRegion().back();
builder.setInsertionPointToStart(&block);
@@ -1841,13 +1845,13 @@ createRegionOp(fir::FirOpBuilder &builder, mlir::Location loc,
if (yieldValue) {
if constexpr (std::is_same_v<Terminator, mlir::acc::YieldOp>) {
- Terminator yieldOp = builder.create<Terminator>(returnLoc, yieldValue);
+ Terminator yieldOp = Terminator::create(builder, returnLoc, yieldValue);
yieldValue.getDefiningOp()->moveBefore(yieldOp);
} else {
- builder.create<Terminator>(returnLoc);
+ Terminator::create(builder, returnLoc);
}
} else {
- builder.create<Terminator>(returnLoc);
+ Terminator::create(builder, returnLoc);
}
builder.setInsertionPointToStart(&block);
return op;
@@ -2437,7 +2441,7 @@ static mlir::acc::LoopOp createLoopOp(
for (auto [arg, value] : llvm::zip(
loopOp.getLoopRegions().front()->front().getArguments(), ivPrivate))
- builder.create<fir::StoreOp>(currentLocation, arg, value);
+ fir::StoreOp::create(builder, currentLocation, arg, value);
loopOp.setInclusiveUpperbound(inclusiveBounds);
@@ -3750,8 +3754,8 @@ genACCUpdateOp(Fortran::lower::AbstractConverter &converter,
dataClauseOperands.append(updateHostOperands);
- builder.create<mlir::acc::UpdateOp>(
- currentLocation, ifCond, asyncOperands,
+ mlir::acc::UpdateOp::create(
+ builder, currentLocation, ifCond, asyncOperands,
getArrayAttr(builder, asyncOperandsDeviceTypes),
getArrayAttr(builder, asyncOnlyDeviceTypes), waitOperands,
getDenseI32ArrayAttr(builder, waitOperandsSegments),
@@ -3873,13 +3877,14 @@ static void createDeclareGlobalOp(mlir::OpBuilder &modBuilder,
const std::string &declareGlobalName,
bool implicit, std::stringstream &asFortran) {
GlobalOp declareGlobalOp =
- modBuilder.create<GlobalOp>(loc, declareGlobalName);
+ GlobalOp::create(modBuilder, loc, declareGlobalName);
builder.createBlock(&declareGlobalOp.getRegion(),
declareGlobalOp.getRegion().end(), {}, {});
builder.setInsertionPointToEnd(&declareGlobalOp.getRegion().back());
- fir::AddrOfOp addrOp = builder.create<fir::AddrOfOp>(
- loc, fir::ReferenceType::get(globalOp.getType()), globalOp.getSymbol());
+ fir::AddrOfOp addrOp = fir::AddrOfOp::create(
+ builder, loc, fir::ReferenceType::get(globalOp.getType()),
+ globalOp.getSymbol());
addDeclareAttr(builder, addrOp, clause);
llvm::SmallVector<mlir::Value> bounds;
@@ -3888,21 +3893,21 @@ static void createDeclareGlobalOp(mlir::OpBuilder &modBuilder,
/*structured=*/false, implicit, clause, addrOp.getResTy().getType(),
/*async=*/{}, /*asyncDeviceTypes=*/{}, /*asyncOnlyDeviceTypes=*/{});
if constexpr (std::is_same_v<DeclareOp, mlir::acc::DeclareEnterOp>)
- builder.create<DeclareOp>(
- loc, mlir::acc::DeclareTokenType::get(entryOp.getContext()),
- mlir::ValueRange(entryOp.getAccVar()));
+ DeclareOp::create(builder, loc,
+ mlir::acc::DeclareTokenType::get(entryOp.getContext()),
+ mlir::ValueRange(entryOp.getAccVar()));
else
- builder.create<DeclareOp>(loc, mlir::Value{},
- mlir::ValueRange(entryOp.getAccVar()));
+ DeclareOp::create(builder, loc, mlir::Value{},
+ mlir::ValueRange(entryOp.getAccVar()));
if constexpr (std::is_same_v<GlobalOp, mlir::acc::GlobalDestructorOp>) {
- builder.create<ExitOp>(entryOp.getLoc(), entryOp.getAccVar(),
- entryOp.getBounds(), entryOp.getAsyncOperands(),
- entryOp.getAsyncOperandsDeviceTypeAttr(),
- entryOp.getAsyncOnlyAttr(), entryOp.getDataClause(),
- /*structured=*/false, /*implicit=*/false,
- builder.getStringAttr(*entryOp.getName()));
+ ExitOp::create(builder, entryOp.getLoc(), entryOp.getAccVar(),
+ entryOp.getBounds(), entryOp.getAsyncOperands(),
+ entryOp.getAsyncOperandsDeviceTypeAttr(),
+ entryOp.getAsyncOnlyAttr(), entryOp.getDataClause(),
+ /*structured=*/false, /*implicit=*/false,
+ builder.getStringAttr(*entryOp.getName()));
}
- builder.create<mlir::acc::TerminatorOp>(loc);
+ mlir::acc::TerminatorOp::create(builder, loc);
modBuilder.setInsertionPointAfter(declareGlobalOp);
}
@@ -3917,8 +3922,9 @@ static void createDeclareAllocFunc(mlir::OpBuilder &modBuilder,
auto registerFuncOp =
createDeclareFunc(modBuilder, builder, loc, registerFuncName.str());
- fir::AddrOfOp addrOp = builder.create<fir::AddrOfOp>(
- loc, fir::ReferenceType::get(globalOp.getType()), globalOp.getSymbol());
+ fir::AddrOfOp addrOp = fir::AddrOfOp::create(
+ builder, loc, fir::ReferenceType::get(globalOp.getType()),
+ globalOp.getSymbol());
std::stringstream asFortran;
asFortran << Fortran::lower::mangle::demangleName(globalOp.getSymName());
@@ -3941,15 +3947,15 @@ static void createDeclareAllocFunc(mlir::OpBuilder &modBuilder,
createSimpleOp<mlir::acc::UpdateOp>(builder, loc, operands, operandSegments);
if (unwrapFirBox) {
- auto loadOp = builder.create<fir::LoadOp>(loc, addrOp.getResult());
- fir::BoxAddrOp boxAddrOp = builder.create<fir::BoxAddrOp>(loc, loadOp);
+ auto loadOp = fir::LoadOp::create(builder, loc, addrOp.getResult());
+ fir::BoxAddrOp boxAddrOp = fir::BoxAddrOp::create(builder, loc, loadOp);
addDeclareAttr(builder, boxAddrOp.getOperation(), clause);
EntryOp entryOp = createDataEntryOp<EntryOp>(
builder, loc, boxAddrOp.getResult(), asFortran, bounds,
/*structured=*/false, /*implicit=*/false, clause, boxAddrOp.getType(),
/*async=*/{}, /*asyncDeviceTypes=*/{}, /*asyncOnlyDeviceTypes=*/{});
- builder.create<mlir::acc::DeclareEnterOp>(
- loc, mlir::acc::DeclareTokenType::get(entryOp.getContext()),
+ mlir::acc::DeclareEnterOp::create(
+ builder, loc, mlir::acc::DeclareTokenType::get(entryOp.getContext()),
mlir::ValueRange(entryOp.getAccVar()));
}
@@ -3980,10 +3986,11 @@ static void createDeclareDeallocFunc(mlir::OpBuilder &modBuilder,
auto preDeallocOp =
createDeclareFunc(modBuilder, builder, loc, preDeallocFuncName.str());
- fir::AddrOfOp addrOp = builder.create<fir::AddrOfOp>(
- loc, fir::ReferenceType::get(globalOp.getType()), globalOp.getSymbol());
- auto loadOp = builder.create<fir::LoadOp>(loc, addrOp.getResult());
- fir::BoxAddrOp boxAddrOp = builder.create<fir::BoxAddrOp>(loc, loadOp);
+ fir::AddrOfOp addrOp = fir::AddrOfOp::create(
+ builder, loc, fir::ReferenceType::get(globalOp.getType()),
+ globalOp.getSymbol());
+ auto loadOp = fir::LoadOp::create(builder, loc, addrOp.getResult());
+ fir::BoxAddrOp boxAddrOp = fir::BoxAddrOp::create(builder, loc, loadOp);
mlir::Value var = boxAddrOp.getResult();
addDeclareAttr(builder, var.getDefiningOp(), clause);
@@ -3994,25 +4001,25 @@ static void createDeclareDeallocFunc(mlir::OpBuilder &modBuilder,
/*structured=*/false, /*implicit=*/false, clause, var.getType(),
/*async=*/{}, /*asyncDeviceTypes=*/{}, /*asyncOnlyDeviceTypes=*/{});
- builder.create<mlir::acc::DeclareExitOp>(
- loc, mlir::Value{}, mlir::ValueRange(entryOp.getAccVar()));
+ mlir::acc::DeclareExitOp::create(builder, loc, mlir::Value{},
+ mlir::ValueRange(entryOp.getAccVar()));
if constexpr (std::is_same_v<ExitOp, mlir::acc::CopyoutOp> ||
std::is_same_v<ExitOp, mlir::acc::UpdateHostOp>)
- builder.create<ExitOp>(
- entryOp.getLoc(), entryOp.getAccVar(), entryOp.getVar(),
- entryOp.getBounds(), entryOp.getAsyncOperands(),
- entryOp.getAsyncOperandsDeviceTypeAttr(), entryOp.getAsyncOnlyAttr(),
- entryOp.getDataClause(),
- /*structured=*/false, /*implicit=*/false,
- builder.getStringAttr(*entryOp.getName()));
+ ExitOp::create(builder, entryOp.getLoc(), entryOp.getAccVar(),
+ entryOp.getVar(), entryOp.getBounds(),
+ entryOp.getAsyncOperands(),
+ entryOp.getAsyncOperandsDeviceTypeAttr(),
+ entryOp.getAsyncOnlyAttr(), entryOp.getDataClause(),
+ /*structured=*/false, /*implicit=*/false,
+ builder.getStringAttr(*entryOp.getName()));
else
- builder.create<ExitOp>(
- entryOp.getLoc(), entryOp.getAccVar(), entryOp.getBounds(),
- entryOp.getAsyncOperands(), entryOp.getAsyncOperandsDeviceTypeAttr(),
- entryOp.getAsyncOnlyAttr(), entryOp.getDataClause(),
- /*structured=*/false, /*implicit=*/false,
- builder.getStringAttr(*entryOp.getName()));
+ ExitOp::create(builder, entryOp.getLoc(), entryOp.getAccVar(),
+ entryOp.getBounds(), entryOp.getAsyncOperands(),
+ entryOp.getAsyncOperandsDeviceTypeAttr(),
+ entryOp.getAsyncOnlyAttr(), entryOp.getDataClause(),
+ /*structured=*/false, /*implicit=*/false,
+ builder.getStringAttr(*entryOp.getName()));
// Generate the post dealloc function.
modBuilder.setInsertionPointAfter(preDeallocOp);
@@ -4024,8 +4031,9 @@ static void createDeclareDeallocFunc(mlir::OpBuilder &modBuilder,
auto postDeallocOp =
createDeclareFunc(modBuilder, builder, loc, postDeallocFuncName.str());
- fir::AddrOfOp addrOp = builder.create<fir::AddrOfOp>(
- loc, fir::ReferenceType::get(globalOp.getType()), globalOp.getSymbol());
+ fir::AddrOfOp addrOp = fir::AddrOfOp::create(
+ builder, loc, fir::ReferenceType::get(globalOp.getType()),
+ globalOp.getSymbol());
if (unwrapFirBox)
asFortran << accFirDescriptorPostfix.str();
llvm::SmallVector<mlir::Value> bounds;
@@ -4262,13 +4270,13 @@ genDeclareInFunction(Fortran::lower::AbstractConverter &converter,
auto ops = funcOp.getOps<mlir::acc::DeclareEnterOp>();
mlir::Value declareToken;
if (ops.empty()) {
- declareToken = builder.create<mlir::acc::DeclareEnterOp>(
- loc, mlir::acc::DeclareTokenType::get(builder.getContext()),
+ declareToken = mlir::acc::DeclareEnterOp::create(
+ builder, loc, mlir::acc::DeclareTokenType::get(builder.getContext()),
dataClauseOperands);
} else {
auto declareOp = *ops.begin();
- auto newDeclareOp = builder.create<mlir::acc::DeclareEnterOp>(
- loc, mlir::acc::DeclareTokenType::get(builder.getContext()),
+ auto newDeclareOp = mlir::acc::DeclareEnterOp::create(
+ builder, loc, mlir::acc::DeclareTokenType::get(builder.getContext()),
declareOp.getDataClauseOperands());
newDeclareOp.getDataClauseOperandsMutable().append(dataClauseOperands);
declareToken = newDeclareOp.getToken();
@@ -4290,7 +4298,7 @@ genDeclareInFunction(Fortran::lower::AbstractConverter &converter,
mlir::func::FuncOp funcOp = builder.getFunction();
auto ops = funcOp.getOps<mlir::acc::DeclareExitOp>();
if (ops.empty()) {
- builder.create<mlir::acc::DeclareExitOp>(loc, declareToken, operands);
+ mlir::acc::DeclareExitOp::create(builder, loc, declareToken, operands);
} else {
auto declareOp = *ops.begin();
declareOp.getDataClauseOperandsMutable().append(operands);
@@ -4535,8 +4543,8 @@ void createOpenACCRoutineConstruct(
std::string routineOpStr = routineOpName.str();
mlir::OpBuilder modBuilder(mod.getBodyRegion());
fir::FirOpBuilder &builder = converter.getFirOpBuilder();
- modBuilder.create<mlir::acc::RoutineOp>(
- loc, routineOpStr,
+ mlir::acc::RoutineOp::create(
+ modBuilder, loc, routineOpStr,
mlir::SymbolRefAttr::get(builder.getContext(), funcName),
getArrayAttrOrNull(builder, bindIdNames),
getArrayAttrOrNull(builder, bindStrNames),
@@ -4880,9 +4888,9 @@ void Fortran::lower::genOpenACCTerminator(fir::FirOpBuilder &builder,
mlir::Operation *op,
mlir::Location loc) {
if (mlir::isa<mlir::acc::ParallelOp, mlir::acc::LoopOp>(op))
- builder.create<mlir::acc::YieldOp>(loc);
+ mlir::acc::YieldOp::create(builder, loc);
else
- builder.create<mlir::acc::TerminatorOp>(loc);
+ mlir::acc::TerminatorOp::create(builder, loc);
}
bool Fortran::lower::isInOpenACCLoop(fir::FirOpBuilder &builder) {
@@ -4902,7 +4910,7 @@ void Fortran::lower::genEarlyReturnInOpenACCLoop(fir::FirOpBuilder &builder,
mlir::Location loc) {
mlir::Value yieldValue =
builder.createIntegerConstant(loc, builder.getI1Type(), 1);
- builder.create<mlir::acc::YieldOp>(loc, yieldValue);
+ mlir::acc::YieldOp::create(builder, loc, yieldValue);
}
int64_t Fortran::lower::getLoopCountForCollapseAndTile(
diff --git a/flang/lib/Lower/OpenMP/Atomic.cpp b/flang/lib/Lower/OpenMP/Atomic.cpp
index 6ea331c370640..9a233d2d8cb08 100644
--- a/flang/lib/Lower/OpenMP/Atomic.cpp
+++ b/flang/lib/Lower/OpenMP/Atomic.cpp
@@ -528,8 +528,8 @@ genAtomicRead(lower::AbstractConverter &converter,
}();
builder.restoreInsertionPoint(atomicAt);
- mlir::Operation *op = builder.create<mlir::omp::AtomicReadOp>(
- loc, atomAddr, toAddr, mlir::TypeAttr::get(atomType), hint,
+ mlir::Operation *op = mlir::omp::AtomicReadOp::create(
+ builder, loc, atomAddr, toAddr, mlir::TypeAttr::get(atomType), hint,
makeMemOrderAttr(converter, memOrder));
if (atomType != storeType) {
@@ -537,7 +537,7 @@ genAtomicRead(lower::AbstractConverter &converter,
// The READ operation could be a part of UPDATE CAPTURE, so make sure
// we don't emit extra code into the body of the atomic op.
builder.restoreInsertionPoint(postAt);
- mlir::Value load = builder.create<fir::LoadOp>(loc, toAddr);
+ mlir::Value load = fir::LoadOp::create(builder, loc, toAddr);
overrides.try_emplace(&atom, load);
converter.overrideExprValues(&overrides);
@@ -545,7 +545,7 @@ genAtomicRead(lower::AbstractConverter &converter,
fir::getBase(converter.genExprValue(assign.rhs, stmtCtx, &loc));
converter.resetExprOverrides();
- builder.create<fir::StoreOp>(loc, value, storeAddr);
+ fir::StoreOp::create(builder, loc, value, storeAddr);
}
return op;
}
@@ -581,8 +581,9 @@ genAtomicWrite(lower::AbstractConverter &converter,
mlir::Value converted = builder.createConvert(loc, atomType, value);
builder.restoreInsertionPoint(atomicAt);
- mlir::Operation *op = builder.create<mlir::omp::AtomicWriteOp>(
- loc, atomAddr, converted, hint, makeMemOrderAttr(converter, memOrder));
+ mlir::Operation *op =
+ mlir::omp::AtomicWriteOp::create(builder, loc, atomAddr, converted, hint,
+ makeMemOrderAttr(converter, memOrder));
return op;
}
@@ -635,8 +636,8 @@ genAtomicUpdate(lower::AbstractConverter &converter,
}
builder.restoreInsertionPoint(atomicAt);
- auto updateOp = builder.create<mlir::omp::AtomicUpdateOp>(
- loc, atomAddr, hint, makeMemOrderAttr(converter, memOrder));
+ auto updateOp = mlir::omp::AtomicUpdateOp::create(
+ builder, loc, atomAddr, hint, makeMemOrderAttr(converter, memOrder));
mlir::Region ®ion = updateOp->getRegion(0);
mlir::Block *block = builder.createBlock(®ion, {}, {atomType}, {loc});
@@ -647,7 +648,7 @@ genAtomicUpdate(lower::AbstractConverter &converter,
mlir::Value updated =
fir::getBase(converter.genExprValue(rhs, stmtCtx, &loc));
mlir::Value converted = builder.createConvert(loc, atomType, updated);
- builder.create<mlir::omp::YieldOp>(loc, converted);
+ mlir::omp::YieldOp::create(builder, loc, converted);
converter.resetExprOverrides();
builder.restoreInsertionPoint(postAt); // For naCtx cleanups
@@ -731,8 +732,8 @@ void Fortran::lower::omp::lowerAtomic(
"Expexcing two actions");
(void)action0;
(void)action1;
- captureOp = builder.create<mlir::omp::AtomicCaptureOp>(
- loc, hint, makeMemOrderAttr(converter, memOrder));
+ captureOp = mlir::omp::AtomicCaptureOp::create(
+ builder, loc, hint, makeMemOrderAttr(converter, memOrder));
// Set the non-atomic insertion point to before the atomic.capture.
preAt = getInsertionPointBefore(captureOp);
@@ -740,7 +741,7 @@ void Fortran::lower::omp::lowerAtomic(
builder.setInsertionPointToEnd(block);
// Set the atomic insertion point to before the terminator inside
// atomic.capture.
- mlir::Operation *term = builder.create<mlir::omp::TerminatorOp>(loc);
+ mlir::Operation *term = mlir::omp::TerminatorOp::create(builder, loc);
atomicAt = getInsertionPointBefore(term);
postAt = getInsertionPointAfter(captureOp);
hint = nullptr;
diff --git a/flang/lib/Lower/OpenMP/ClauseProcessor.cpp b/flang/lib/Lower/OpenMP/ClauseProcessor.cpp
index 74087d42a8e6e..498eea471f3db 100644
--- a/flang/lib/Lower/OpenMP/ClauseProcessor.cpp
+++ b/flang/lib/Lower/OpenMP/ClauseProcessor.cpp
@@ -723,7 +723,7 @@ bool ClauseProcessor::processCopyin() const {
// barrier is inserted following all of them.
firOpBuilder.restoreInsertionPoint(insPt);
if (hasCopyin)
- firOpBuilder.create<mlir::omp::BarrierOp>(converter.getCurrentLocation());
+ mlir::omp::BarrierOp::create(firOpBuilder, converter.getCurrentLocation());
return hasCopyin;
}
@@ -803,7 +803,7 @@ createCopyFunc(mlir::Location loc, lower::AbstractConverter &converter,
llvm::SmallVector<mlir::Type> argsTy = {varType, varType};
auto funcType = mlir::FunctionType::get(builder.getContext(), argsTy, {});
mlir::func::FuncOp funcOp =
- modBuilder.create<mlir::func::FuncOp>(loc, copyFuncName, funcType);
+ mlir::func::FuncOp::create(modBuilder, loc, copyFuncName, funcType);
funcOp.setVisibility(mlir::SymbolTable::Visibility::Private);
fir::factory::setInternalLinkage(funcOp);
builder.createBlock(&funcOp.getRegion(), funcOp.getRegion().end(), argsTy,
@@ -819,22 +819,22 @@ createCopyFunc(mlir::Location loc, lower::AbstractConverter &converter,
for (auto extent : typeInfo.getShape())
extents.push_back(
builder.createIntegerConstant(loc, builder.getIndexType(), extent));
- shape = builder.create<fir::ShapeOp>(loc, extents);
+ shape = fir::ShapeOp::create(builder, loc, extents);
}
mlir::Value dst = funcOp.getArgument(0);
mlir::Value src = funcOp.getArgument(1);
llvm::SmallVector<mlir::Value> typeparams;
if (typeInfo.isBoxChar()) {
// fir.boxchar will be passed here as fir.ref<fir.boxchar>
- auto loadDst = builder.create<fir::LoadOp>(loc, dst);
- auto loadSrc = builder.create<fir::LoadOp>(loc, src);
+ auto loadDst = fir::LoadOp::create(builder, loc, dst);
+ auto loadSrc = fir::LoadOp::create(builder, loc, src);
// get the actual fir.ref<fir.char> type
mlir::Type refType =
fir::ReferenceType::get(mlir::cast<fir::BoxCharType>(eleTy).getEleTy());
- auto unboxedDst = builder.create<fir::UnboxCharOp>(
- loc, refType, builder.getIndexType(), loadDst);
- auto unboxedSrc = builder.create<fir::UnboxCharOp>(
- loc, refType, builder.getIndexType(), loadSrc);
+ auto unboxedDst = fir::UnboxCharOp::create(builder, loc, refType,
+ builder.getIndexType(), loadDst);
+ auto unboxedSrc = fir::UnboxCharOp::create(builder, loc, refType,
+ builder.getIndexType(), loadSrc);
// Add length to type parameters
typeparams.push_back(unboxedDst.getResult(1));
dst = unboxedDst.getResult(0);
@@ -844,14 +844,14 @@ createCopyFunc(mlir::Location loc, lower::AbstractConverter &converter,
loc, builder.getCharacterLengthType(), *typeInfo.getCharLength());
typeparams.push_back(charLen);
}
- auto declDst = builder.create<hlfir::DeclareOp>(
- loc, dst, copyFuncName + "_dst", shape, typeparams,
+ auto declDst = hlfir::DeclareOp::create(
+ builder, loc, dst, copyFuncName + "_dst", shape, typeparams,
/*dummy_scope=*/nullptr, attrs);
- auto declSrc = builder.create<hlfir::DeclareOp>(
- loc, src, copyFuncName + "_src", shape, typeparams,
+ auto declSrc = hlfir::DeclareOp::create(
+ builder, loc, src, copyFuncName + "_src", shape, typeparams,
/*dummy_scope=*/nullptr, attrs);
converter.copyVar(loc, declDst.getBase(), declSrc.getBase(), varAttrs);
- builder.create<mlir::func::ReturnOp>(loc);
+ mlir::func::ReturnOp::create(builder, loc);
return funcOp;
}
@@ -882,8 +882,8 @@ bool ClauseProcessor::processCopyprivate(
if (mlir::isa<fir::BaseBoxType>(symType) ||
mlir::isa<fir::BoxCharType>(symType)) {
fir::FirOpBuilder &builder = converter.getFirOpBuilder();
- auto alloca = builder.create<fir::AllocaOp>(currentLocation, symType);
- builder.create<fir::StoreOp>(currentLocation, symVal, alloca);
+ auto alloca = fir::AllocaOp::create(builder, currentLocation, symType);
+ fir::StoreOp::create(builder, currentLocation, symVal, alloca);
cpVar = alloca;
}
@@ -1002,8 +1002,8 @@ bool ClauseProcessor::processDepend(lower::SymMap &symMap,
// allocations so this is not a reliable way to identify the dependency.
if (auto ref = mlir::dyn_cast<fir::ReferenceType>(dependVar.getType()))
if (fir::isa_box_type(ref.getElementType()))
- dependVar = builder.create<fir::LoadOp>(
- converter.getCurrentLocation(), dependVar);
+ dependVar = fir::LoadOp::create(
+ builder, converter.getCurrentLocation(), dependVar);
// The openmp dialect doesn't know what to do with boxes (and it would
// break layering to teach it about them). The dependency variable can be
@@ -1012,8 +1012,8 @@ bool ClauseProcessor::processDepend(lower::SymMap &symMap,
// Getting the address of the box data is okay because all the runtime
// ultimately cares about is the base address of the array.
if (fir::isa_box_type(dependVar.getType()))
- dependVar = builder.create<fir::BoxAddrOp>(
- converter.getCurrentLocation(), dependVar);
+ dependVar = fir::BoxAddrOp::create(
+ builder, converter.getCurrentLocation(), dependVar);
result.dependVars.push_back(dependVar);
}
diff --git a/flang/lib/Lower/OpenMP/DataSharingProcessor.cpp b/flang/lib/Lower/OpenMP/DataSharingProcessor.cpp
index 675a58e4f35a1..11e488371b886 100644
--- a/flang/lib/Lower/OpenMP/DataSharingProcessor.cpp
+++ b/flang/lib/Lower/OpenMP/DataSharingProcessor.cpp
@@ -291,7 +291,7 @@ void DataSharingProcessor::insertBarrier(
clauseOps->privateNeedsBarrier =
mlir::UnitAttr::get(&converter.getMLIRContext());
} else {
- firOpBuilder.create<mlir::omp::BarrierOp>(converter.getCurrentLocation());
+ mlir::omp::BarrierOp::create(firOpBuilder, converter.getCurrentLocation());
}
}
@@ -351,32 +351,32 @@ void DataSharingProcessor::insertLastPrivateCompare(mlir::Operation *op) {
loopOp.getIVs(), result.loopUpperBounds, result.loopSteps)) {
// v = iv + step
// cmp = step < 0 ? v < ub : v > ub
- mlir::Value v = firOpBuilder.create<mlir::arith::AddIOp>(loc, iv, step);
+ mlir::Value v = mlir::arith::AddIOp::create(firOpBuilder, loc, iv, step);
vs.push_back(v);
mlir::Value zero =
firOpBuilder.createIntegerConstant(loc, step.getType(), 0);
- mlir::Value negativeStep = firOpBuilder.create<mlir::arith::CmpIOp>(
- loc, mlir::arith::CmpIPredicate::slt, step, zero);
- mlir::Value vLT = firOpBuilder.create<mlir::arith::CmpIOp>(
- loc, mlir::arith::CmpIPredicate::slt, v, ub);
- mlir::Value vGT = firOpBuilder.create<mlir::arith::CmpIOp>(
- loc, mlir::arith::CmpIPredicate::sgt, v, ub);
- mlir::Value icmpOp = firOpBuilder.create<mlir::arith::SelectOp>(
- loc, negativeStep, vLT, vGT);
+ mlir::Value negativeStep = mlir::arith::CmpIOp::create(
+ firOpBuilder, loc, mlir::arith::CmpIPredicate::slt, step, zero);
+ mlir::Value vLT = mlir::arith::CmpIOp::create(
+ firOpBuilder, loc, mlir::arith::CmpIPredicate::slt, v, ub);
+ mlir::Value vGT = mlir::arith::CmpIOp::create(
+ firOpBuilder, loc, mlir::arith::CmpIPredicate::sgt, v, ub);
+ mlir::Value icmpOp = mlir::arith::SelectOp::create(
+ firOpBuilder, loc, negativeStep, vLT, vGT);
if (cmpOp)
- cmpOp = firOpBuilder.create<mlir::arith::AndIOp>(loc, cmpOp, icmpOp);
+ cmpOp = mlir::arith::AndIOp::create(firOpBuilder, loc, cmpOp, icmpOp);
else
cmpOp = icmpOp;
}
- auto ifOp = firOpBuilder.create<fir::IfOp>(loc, cmpOp, /*else*/ false);
+ auto ifOp = fir::IfOp::create(firOpBuilder, loc, cmpOp, /*else*/ false);
firOpBuilder.setInsertionPointToStart(&ifOp.getThenRegion().front());
for (auto [v, loopIV] : llvm::zip_equal(vs, loopIVs)) {
hlfir::Entity loopIVEntity{loopIV};
loopIVEntity =
hlfir::derefPointersAndAllocatables(loc, firOpBuilder, loopIVEntity);
- firOpBuilder.create<hlfir::AssignOp>(loc, v, loopIVEntity);
+ hlfir::AssignOp::create(firOpBuilder, loc, v, loopIVEntity);
}
lastPrivIP = firOpBuilder.saveInsertionPoint();
} else if (mlir::isa<mlir::omp::SectionsOp>(op)) {
diff --git a/flang/lib/Lower/OpenMP/OpenMP.cpp b/flang/lib/Lower/OpenMP/OpenMP.cpp
index fcb20fdf187ff..80905aa2979a8 100644
--- a/flang/lib/Lower/OpenMP/OpenMP.cpp
+++ b/flang/lib/Lower/OpenMP/OpenMP.cpp
@@ -642,8 +642,8 @@ static void threadPrivatizeVars(lower::AbstractConverter &converter,
op = declOp.getMemref().getDefiningOp();
if (mlir::isa<mlir::omp::ThreadprivateOp>(op))
symValue = mlir::dyn_cast<mlir::omp::ThreadprivateOp>(op).getSymAddr();
- return firOpBuilder.create<mlir::omp::ThreadprivateOp>(
- currentLocation, symValue.getType(), symValue);
+ return mlir::omp::ThreadprivateOp::create(firOpBuilder, currentLocation,
+ symValue.getType(), symValue);
};
llvm::SetVector<const semantics::Symbol *> threadprivateSyms;
@@ -710,7 +710,7 @@ createAndSetPrivatizedLoopVar(lower::AbstractConverter &converter,
lhs = hlfir::derefPointersAndAllocatables(loc, firOpBuilder, lhs);
mlir::Operation *storeOp =
- firOpBuilder.create<hlfir::AssignOp>(loc, cvtVal, lhs);
+ hlfir::AssignOp::create(firOpBuilder, loc, cvtVal, lhs);
return storeOp;
}
@@ -1156,8 +1156,8 @@ static void createBodyOfOp(mlir::Operation &op, const OpWithBodyGenInfo &info,
fir::FirOpBuilder &firOpBuilder = info.converter.getFirOpBuilder();
auto insertMarker = [](fir::FirOpBuilder &builder) {
- mlir::Value undef = builder.create<fir::UndefOp>(builder.getUnknownLoc(),
- builder.getIndexType());
+ mlir::Value undef = fir::UndefOp::create(builder, builder.getUnknownLoc(),
+ builder.getIndexType());
return undef.getDefiningOp();
};
@@ -1271,7 +1271,7 @@ static void createBodyOfOp(mlir::Operation &op, const OpWithBodyGenInfo &info,
mlir::Block *exit = firOpBuilder.createBlock(®ion);
for (mlir::Block *b : exits) {
firOpBuilder.setInsertionPointToEnd(b);
- firOpBuilder.create<mlir::cf::BranchOp>(info.loc, exit);
+ mlir::cf::BranchOp::create(firOpBuilder, info.loc, exit);
}
return exit;
};
@@ -1332,8 +1332,8 @@ static void genBodyOfTargetDataOp(
// Remembering the position for further insertion is important since
// there are hlfir.declares inserted above while setting block arguments
// and new code from the body should be inserted after that.
- mlir::Value undefMarker = firOpBuilder.create<fir::UndefOp>(
- dataOp.getLoc(), firOpBuilder.getIndexType());
+ mlir::Value undefMarker = fir::UndefOp::create(firOpBuilder, dataOp.getLoc(),
+ firOpBuilder.getIndexType());
// Create blocks for unstructured regions. This has to be done since
// blocks are initially allocated with the function as the parent region.
@@ -1342,7 +1342,7 @@ static void genBodyOfTargetDataOp(
firOpBuilder, eval.getNestedEvaluations());
}
- firOpBuilder.create<mlir::omp::TerminatorOp>(currentLocation);
+ mlir::omp::TerminatorOp::create(firOpBuilder, currentLocation);
// Set the insertion point after the marker.
firOpBuilder.setInsertionPointAfter(undefMarker.getDefiningOp());
@@ -1496,8 +1496,8 @@ static void genBodyOfTargetOp(
insertIndex, copyVal.getType(), copyVal.getLoc());
firOpBuilder.setInsertionPointToStart(entryBlock);
- auto loadOp = firOpBuilder.create<fir::LoadOp>(clonedValArg.getLoc(),
- clonedValArg);
+ auto loadOp = fir::LoadOp::create(firOpBuilder, clonedValArg.getLoc(),
+ clonedValArg);
val.replaceUsesWithIf(loadOp->getResult(0),
[entryBlock](mlir::OpOperand &use) {
return use.getOwner()->getBlock() == entryBlock;
@@ -1513,8 +1513,8 @@ static void genBodyOfTargetOp(
// marker will be deleted since there are not uses.
// In the HLFIR flow there are hlfir.declares inserted above while
// setting block arguments.
- mlir::Value undefMarker = firOpBuilder.create<fir::UndefOp>(
- targetOp.getLoc(), firOpBuilder.getIndexType());
+ mlir::Value undefMarker = fir::UndefOp::create(
+ firOpBuilder, targetOp.getLoc(), firOpBuilder.getIndexType());
// Create blocks for unstructured regions. This has to be done since
// blocks are initially allocated with the function as the parent region.
@@ -1524,7 +1524,7 @@ static void genBodyOfTargetOp(
firOpBuilder, eval.getNestedEvaluations());
}
- firOpBuilder.create<mlir::omp::TerminatorOp>(currentLocation);
+ mlir::omp::TerminatorOp::create(firOpBuilder, currentLocation);
// Create the insertion point after the marker.
firOpBuilder.setInsertionPointAfter(undefMarker.getDefiningOp());
@@ -1570,7 +1570,7 @@ static OpTy genWrapperOp(lower::AbstractConverter &converter,
fir::FirOpBuilder &firOpBuilder = converter.getFirOpBuilder();
// Create wrapper.
- auto op = firOpBuilder.create<OpTy>(loc, clauseOps);
+ auto op = OpTy::create(firOpBuilder, loc, clauseOps);
// Create entry block with arguments.
genEntryBlock(firOpBuilder, args, op.getRegion());
@@ -1983,7 +1983,7 @@ genCriticalOp(lower::AbstractConverter &converter, lower::SymMap &symTable,
clauseOps, nameStr);
mlir::OpBuilder modBuilder(mod.getBodyRegion());
- global = modBuilder.create<mlir::omp::CriticalDeclareOp>(loc, clauseOps);
+ global = mlir::omp::CriticalDeclareOp::create(modBuilder, loc, clauseOps);
}
nameAttr = mlir::FlatSymbolRefAttr::get(firOpBuilder.getContext(),
global.getSymName());
@@ -2201,7 +2201,7 @@ genSectionsOp(lower::AbstractConverter &converter, lower::SymMap &symTable,
}
// SECTIONS construct.
- auto sectionsOp = builder.create<mlir::omp::SectionsOp>(loc, clauseOps);
+ auto sectionsOp = mlir::omp::SectionsOp::create(builder, loc, clauseOps);
// Create entry block with reduction variables as arguments.
EntryBlockArgs args;
@@ -2277,7 +2277,7 @@ genSectionsOp(lower::AbstractConverter &converter, lower::SymMap &symTable,
// races on post-update of lastprivate variables when `nowait`
// clause is present.
if (clauseOps.nowait && !lastprivates.empty())
- builder.create<mlir::omp::BarrierOp>(loc);
+ mlir::omp::BarrierOp::create(builder, loc);
return sectionsOp;
}
@@ -2429,7 +2429,7 @@ genTargetOp(lower::AbstractConverter &converter, lower::SymMap &symTable,
};
lower::pft::visitAllSymbols(eval, captureImplicitMap);
- auto targetOp = firOpBuilder.create<mlir::omp::TargetOp>(loc, clauseOps);
+ auto targetOp = mlir::omp::TargetOp::create(firOpBuilder, loc, clauseOps);
llvm::SmallVector<mlir::Value> hasDeviceAddrBaseValues, mapBaseValues;
extractMappedBaseValues(clauseOps.hasDeviceAddrVars, hasDeviceAddrBaseValues);
@@ -2509,7 +2509,7 @@ static OpTy genTargetEnterExitUpdateDataOp(
genTargetEnterExitUpdateDataClauses(converter, semaCtx, symTable, stmtCtx,
item->clauses, loc, directive, clauseOps);
- return firOpBuilder.create<OpTy>(loc, clauseOps);
+ return OpTy::create(firOpBuilder, loc, clauseOps);
}
static mlir::omp::TaskOp
@@ -3342,8 +3342,8 @@ genOMP(lower::AbstractConverter &converter, lower::SymMap &symTable,
firOpBuilder.setInsertionPointToStart(converter.getModuleOp().getBody());
auto mlirType = converter.genType(varType.declTypeSpec->derivedTypeSpec());
- auto declMapperOp = firOpBuilder.create<mlir::omp::DeclareMapperOp>(
- loc, mapperNameStr, mlirType);
+ auto declMapperOp = mlir::omp::DeclareMapperOp::create(
+ firOpBuilder, loc, mapperNameStr, mlirType);
auto ®ion = declMapperOp.getRegion();
firOpBuilder.createBlock(®ion);
auto varVal = region.addArgument(firOpBuilder.getRefType(mlirType), loc);
@@ -3356,7 +3356,7 @@ genOMP(lower::AbstractConverter &converter, lower::SymMap &symTable,
List<Clause> clauses = makeClauses(*clauseList, semaCtx);
ClauseProcessor cp(converter, semaCtx, clauses);
cp.processMap(loc, stmtCtx, clauseOps);
- firOpBuilder.create<mlir::omp::DeclareMapperInfoOp>(loc, clauseOps.mapVars);
+ mlir::omp::DeclareMapperInfoOp::create(firOpBuilder, loc, clauseOps.mapVars);
}
static void
@@ -3758,8 +3758,8 @@ mlir::Operation *Fortran::lower::genOpenMPTerminator(fir::FirOpBuilder &builder,
mlir::Location loc) {
if (mlir::isa<mlir::omp::AtomicUpdateOp, mlir::omp::DeclareReductionOp,
mlir::omp::LoopNestOp>(op))
- return builder.create<mlir::omp::YieldOp>(loc);
- return builder.create<mlir::omp::TerminatorOp>(loc);
+ return mlir::omp::YieldOp::create(builder, loc);
+ return mlir::omp::TerminatorOp::create(builder, loc);
}
void Fortran::lower::genOpenMPConstruct(lower::AbstractConverter &converter,
@@ -3819,9 +3819,8 @@ void Fortran::lower::genThreadprivateOp(lower::AbstractConverter &converter,
return;
}
// Generate ThreadprivateOp and rebind the common block.
- mlir::Value commonThreadprivateValue =
- firOpBuilder.create<mlir::omp::ThreadprivateOp>(
- currentLocation, commonValue.getType(), commonValue);
+ mlir::Value commonThreadprivateValue = mlir::omp::ThreadprivateOp::create(
+ firOpBuilder, currentLocation, commonValue.getType(), commonValue);
converter.bindSymbol(*common, commonThreadprivateValue);
// Generate the threadprivate value for the common block member.
symThreadprivateValue = genCommonBlockMember(converter, currentLocation,
@@ -3841,10 +3840,10 @@ void Fortran::lower::genThreadprivateOp(lower::AbstractConverter &converter,
global = globalInitialization(converter, firOpBuilder, sym, var,
currentLocation);
- mlir::Value symValue = firOpBuilder.create<fir::AddrOfOp>(
- currentLocation, global.resultType(), global.getSymbol());
- symThreadprivateValue = firOpBuilder.create<mlir::omp::ThreadprivateOp>(
- currentLocation, symValue.getType(), symValue);
+ mlir::Value symValue = fir::AddrOfOp::create(
+ firOpBuilder, currentLocation, global.resultType(), global.getSymbol());
+ symThreadprivateValue = mlir::omp::ThreadprivateOp::create(
+ firOpBuilder, currentLocation, symValue.getType(), symValue);
} else {
mlir::Value symValue = converter.getSymbolAddress(sym);
@@ -3859,8 +3858,8 @@ void Fortran::lower::genThreadprivateOp(lower::AbstractConverter &converter,
if (mlir::isa<mlir::omp::ThreadprivateOp>(op))
return;
- symThreadprivateValue = firOpBuilder.create<mlir::omp::ThreadprivateOp>(
- currentLocation, symValue.getType(), symValue);
+ symThreadprivateValue = mlir::omp::ThreadprivateOp::create(
+ firOpBuilder, currentLocation, symValue.getType(), symValue);
}
fir::ExtendedValue sexv = converter.getSymbolExtendedValue(sym);
diff --git a/flang/lib/Lower/OpenMP/Utils.cpp b/flang/lib/Lower/OpenMP/Utils.cpp
index b194150c0f7f0..b1716d6afb200 100644
--- a/flang/lib/Lower/OpenMP/Utils.cpp
+++ b/flang/lib/Lower/OpenMP/Utils.cpp
@@ -115,7 +115,7 @@ createMapInfoOp(fir::FirOpBuilder &builder, mlir::Location loc,
mlir::omp::VariableCaptureKind mapCaptureType, mlir::Type retTy,
bool partialMap, mlir::FlatSymbolRefAttr mapperId) {
if (auto boxTy = llvm::dyn_cast<fir::BaseBoxType>(baseAddr.getType())) {
- baseAddr = builder.create<fir::BoxAddrOp>(loc, baseAddr);
+ baseAddr = fir::BoxAddrOp::create(builder, loc, baseAddr);
retTy = baseAddr.getType();
}
@@ -129,8 +129,8 @@ createMapInfoOp(fir::FirOpBuilder &builder, mlir::Location loc,
if (seqType.hasDynamicExtents())
varType = mlir::TypeAttr::get(seqType.getEleTy());
- mlir::omp::MapInfoOp op = builder.create<mlir::omp::MapInfoOp>(
- loc, retTy, baseAddr, varType,
+ mlir::omp::MapInfoOp op = mlir::omp::MapInfoOp::create(
+ builder, loc, retTy, baseAddr, varType,
builder.getIntegerAttr(builder.getIntegerType(64, false), mapType),
builder.getAttr<mlir::omp::VariableCaptureKindAttr>(mapCaptureType),
varPtrPtr, members, membersIndex, bounds, mapperId,
@@ -195,8 +195,8 @@ static void generateArrayIndices(lower::AbstractConverter &converter,
clauseLocation, firOpBuilder.getIndexType(), 1);
subscript = firOpBuilder.createConvert(
clauseLocation, firOpBuilder.getIndexType(), subscript);
- indices.push_back(firOpBuilder.create<mlir::arith::SubIOp>(clauseLocation,
- subscript, one));
+ indices.push_back(mlir::arith::SubIOp::create(firOpBuilder, clauseLocation,
+ subscript, one));
}
}
@@ -329,9 +329,10 @@ mlir::Value createParentSymAndGenIntermediateMaps(
subscriptIndices, objectList[i]);
assert(!subscriptIndices.empty() &&
"missing expected indices for map clause");
- curValue = firOpBuilder.create<fir::CoordinateOp>(
- clauseLocation, firOpBuilder.getRefType(arrType.getEleTy()),
- curValue, subscriptIndices);
+ curValue = fir::CoordinateOp::create(
+ firOpBuilder, clauseLocation,
+ firOpBuilder.getRefType(arrType.getEleTy()), curValue,
+ subscriptIndices);
}
}
@@ -345,9 +346,9 @@ mlir::Value createParentSymAndGenIntermediateMaps(
fir::IntOrValue idxConst = mlir::IntegerAttr::get(
firOpBuilder.getI32Type(), indices[currentIndicesIdx]);
mlir::Type memberTy = recordType.getType(indices[currentIndicesIdx]);
- curValue = firOpBuilder.create<fir::CoordinateOp>(
- clauseLocation, firOpBuilder.getRefType(memberTy), curValue,
- llvm::SmallVector<fir::IntOrValue, 1>{idxConst});
+ curValue = fir::CoordinateOp::create(
+ firOpBuilder, clauseLocation, firOpBuilder.getRefType(memberTy),
+ curValue, llvm::SmallVector<fir::IntOrValue, 1>{idxConst});
// If we're a final member, the map will be generated by the processMap
// call that invoked this function.
@@ -417,7 +418,7 @@ mlir::Value createParentSymAndGenIntermediateMaps(
// Load the currently accessed member, so we can continue to access
// further segments.
- curValue = firOpBuilder.create<fir::LoadOp>(clauseLocation, curValue);
+ curValue = fir::LoadOp::create(firOpBuilder, clauseLocation, curValue);
currentIndicesIdx++;
}
}
diff --git a/flang/lib/Lower/Runtime.cpp b/flang/lib/Lower/Runtime.cpp
index ae8bf0e1630aa..fc59a2414d539 100644
--- a/flang/lib/Lower/Runtime.cpp
+++ b/flang/lib/Lower/Runtime.cpp
@@ -43,7 +43,7 @@ static void genUnreachable(fir::FirOpBuilder &builder, mlir::Location loc) {
mlir::acc::OpenACCDialect::getDialectNamespace())
Fortran::lower::genOpenACCTerminator(builder, parentOp, loc);
else
- builder.create<fir::UnreachableOp>(loc);
+ fir::UnreachableOp::create(builder, loc);
mlir::Block *newBlock = curBlock->splitBlock(builder.getInsertionPoint());
builder.setInsertionPointToStart(newBlock);
}
@@ -118,7 +118,7 @@ void Fortran::lower::genStopStatement(
loc, calleeType.getInput(operands.size()), 0));
}
- builder.create<fir::CallOp>(loc, callee, operands);
+ fir::CallOp::create(builder, loc, callee, operands);
auto blockIsUnterminated = [&builder]() {
mlir::Block *currentBlock = builder.getBlock();
return currentBlock->empty() ||
@@ -134,7 +134,7 @@ void Fortran::lower::genFailImageStatement(
mlir::Location loc = converter.getCurrentLocation();
mlir::func::FuncOp callee =
fir::runtime::getRuntimeFunc<mkRTKey(FailImageStatement)>(loc, builder);
- builder.create<fir::CallOp>(loc, callee, mlir::ValueRange{});
+ fir::CallOp::create(builder, loc, callee, mlir::ValueRange{});
genUnreachable(builder, loc);
}
@@ -199,7 +199,7 @@ void Fortran::lower::genPauseStatement(
mlir::Location loc = converter.getCurrentLocation();
mlir::func::FuncOp callee =
fir::runtime::getRuntimeFunc<mkRTKey(PauseStatement)>(loc, builder);
- builder.create<fir::CallOp>(loc, callee, mlir::ValueRange{});
+ fir::CallOp::create(builder, loc, callee, mlir::ValueRange{});
}
void Fortran::lower::genPointerAssociate(fir::FirOpBuilder &builder,
@@ -210,7 +210,7 @@ void Fortran::lower::genPointerAssociate(fir::FirOpBuilder &builder,
fir::runtime::getRuntimeFunc<mkRTKey(PointerAssociate)>(loc, builder);
llvm::SmallVector<mlir::Value> args = fir::runtime::createArguments(
builder, loc, func.getFunctionType(), pointer, target);
- builder.create<fir::CallOp>(loc, func, args);
+ fir::CallOp::create(builder, loc, func, args);
}
void Fortran::lower::genPointerAssociateRemapping(
@@ -229,7 +229,7 @@ void Fortran::lower::genPointerAssociateRemapping(
llvm::SmallVector<mlir::Value> args = fir::runtime::createArguments(
builder, loc, func.getFunctionType(), pointer, target, bounds, sourceFile,
sourceLine);
- builder.create<fir::CallOp>(loc, func, args);
+ fir::CallOp::create(builder, loc, func, args);
}
void Fortran::lower::genPointerAssociateLowerBounds(fir::FirOpBuilder &builder,
@@ -242,5 +242,5 @@ void Fortran::lower::genPointerAssociateLowerBounds(fir::FirOpBuilder &builder,
loc, builder);
llvm::SmallVector<mlir::Value> args = fir::runtime::createArguments(
builder, loc, func.getFunctionType(), pointer, target, lbounds);
- builder.create<fir::CallOp>(loc, func, args);
+ fir::CallOp::create(builder, loc, func, args);
}
diff --git a/flang/lib/Lower/Support/PrivateReductionUtils.cpp b/flang/lib/Lower/Support/PrivateReductionUtils.cpp
index c3a5b6101ce00..fff060b79c9fe 100644
--- a/flang/lib/Lower/Support/PrivateReductionUtils.cpp
+++ b/flang/lib/Lower/Support/PrivateReductionUtils.cpp
@@ -75,9 +75,9 @@ static void createCleanupRegion(Fortran::lower::AbstractConverter &converter,
/*mutableProperties=*/{}};
Fortran::lower::genDeallocateIfAllocated(converter, mutableBox, loc);
if (isDoConcurrent)
- builder.create<fir::YieldOp>(loc);
+ fir::YieldOp::create(builder, loc);
else
- builder.create<mlir::omp::YieldOp>(loc);
+ mlir::omp::YieldOp::create(builder, loc);
return;
}
}
@@ -97,18 +97,18 @@ static void createCleanupRegion(Fortran::lower::AbstractConverter &converter,
hlfir::genVariableRawAddress(loc, builder, hlfir::Entity{arg});
mlir::Value isAllocated = builder.genIsNotNullAddr(loc, addr);
fir::IfOp ifOp =
- builder.create<fir::IfOp>(loc, isAllocated, /*withElseRegion=*/false);
+ fir::IfOp::create(builder, loc, isAllocated, /*withElseRegion=*/false);
builder.setInsertionPointToStart(&ifOp.getThenRegion().front());
mlir::Value cast = builder.createConvert(
loc, fir::HeapType::get(fir::dyn_cast_ptrEleTy(addr.getType())), addr);
- builder.create<fir::FreeMemOp>(loc, cast);
+ fir::FreeMemOp::create(builder, loc, cast);
builder.setInsertionPointAfter(ifOp);
if (isDoConcurrent)
- builder.create<fir::YieldOp>(loc);
+ fir::YieldOp::create(builder, loc);
else
- builder.create<mlir::omp::YieldOp>(loc);
+ mlir::omp::YieldOp::create(builder, loc);
return;
}
@@ -122,11 +122,11 @@ static void createCleanupRegion(Fortran::lower::AbstractConverter &converter,
auto heapTy = fir::HeapType::get(refTy.getEleTy());
addr = builder.createConvert(loc, heapTy, addr);
- builder.create<fir::FreeMemOp>(loc, addr);
+ fir::FreeMemOp::create(builder, loc, addr);
if (isDoConcurrent)
- builder.create<fir::YieldOp>(loc);
+ fir::YieldOp::create(builder, loc);
else
- builder.create<mlir::omp::YieldOp>(loc);
+ mlir::omp::YieldOp::create(builder, loc);
return;
}
@@ -172,7 +172,7 @@ fir::ShapeShiftOp Fortran::lower::getShapeShift(
// OpenACC does
mlir::Value dim = builder.createIntegerConstant(loc, idxTy, i);
auto dimInfo =
- builder.create<fir::BoxDimsOp>(loc, idxTy, idxTy, idxTy, box, dim);
+ fir::BoxDimsOp::create(builder, loc, idxTy, idxTy, idxTy, box, dim);
lbAndExtents.push_back(useDefaultLowerBounds ? one()
: dimInfo.getLowerBound());
lbAndExtents.push_back(dimInfo.getExtent());
@@ -181,7 +181,7 @@ fir::ShapeShiftOp Fortran::lower::getShapeShift(
auto shapeShiftTy = fir::ShapeShiftType::get(builder.getContext(), rank);
auto shapeShift =
- builder.create<fir::ShapeShiftOp>(loc, shapeShiftTy, lbAndExtents);
+ fir::ShapeShiftOp::create(builder, loc, shapeShiftTy, lbAndExtents);
return shapeShift;
}
@@ -270,7 +270,7 @@ static mlir::Value generateZeroShapeForRank(fir::FirOpBuilder &builder,
mlir::SmallVector<mlir::Value> dims;
dims.resize(rank, zero);
mlir::Type shapeTy = fir::ShapeType::get(builder.getContext(), rank);
- return builder.create<fir::ShapeOp>(loc, shapeTy, dims);
+ return fir::ShapeOp::create(builder, loc, shapeTy, dims);
}
namespace {
@@ -341,9 +341,9 @@ class PopulateInitAndCleanupRegionsHelper {
void createYield(mlir::Value ret) {
if (isDoConcurrent)
- builder.create<fir::YieldOp>(loc, ret);
+ fir::YieldOp::create(builder, loc, ret);
else
- builder.create<mlir::omp::YieldOp>(loc, ret);
+ mlir::omp::YieldOp::create(builder, loc, ret);
}
void initTrivialType() {
@@ -392,9 +392,9 @@ void PopulateInitAndCleanupRegionsHelper::initBoxedPrivatePointer(
// Just incase, do initialize the box with a null value
mlir::Value null = builder.createNullConstant(loc, boxTy.getEleTy());
mlir::Value nullBox;
- nullBox = builder.create<fir::EmboxOp>(loc, boxTy, null, shape,
- /*slice=*/mlir::Value{}, lenParams);
- builder.create<fir::StoreOp>(loc, nullBox, allocatedPrivVarArg);
+ nullBox = fir::EmboxOp::create(builder, loc, boxTy, null, shape,
+ /*slice=*/mlir::Value{}, lenParams);
+ fir::StoreOp::create(builder, loc, nullBox, allocatedPrivVarArg);
createYield(allocatedPrivVarArg);
}
/// Check if an allocatable box is unallocated. If so, initialize the boxAlloca
@@ -410,10 +410,10 @@ void PopulateInitAndCleanupRegionsHelper::initBoxedPrivatePointer(
/// }
/// omp.yield %box_alloca
fir::IfOp PopulateInitAndCleanupRegionsHelper::handleNullAllocatable() {
- mlir::Value addr = builder.create<fir::BoxAddrOp>(loc, getLoadedMoldArg());
+ mlir::Value addr = fir::BoxAddrOp::create(builder, loc, getLoadedMoldArg());
mlir::Value isNotAllocated = builder.genIsNullAddr(loc, addr);
- fir::IfOp ifOp = builder.create<fir::IfOp>(loc, isNotAllocated,
- /*withElseRegion=*/true);
+ fir::IfOp ifOp = fir::IfOp::create(builder, loc, isNotAllocated,
+ /*withElseRegion=*/true);
builder.setInsertionPointToStart(&ifOp.getThenRegion().front());
// Just embox the null address and return.
// We have to give the embox a shape so that the LLVM box structure has the
@@ -421,9 +421,9 @@ fir::IfOp PopulateInitAndCleanupRegionsHelper::handleNullAllocatable() {
mlir::Value shape = generateZeroShapeForRank(builder, loc, moldArg);
mlir::Value nullBox =
- builder.create<fir::EmboxOp>(loc, valType, addr, shape,
- /*slice=*/mlir::Value{}, lenParams);
- builder.create<fir::StoreOp>(loc, nullBox, allocatedPrivVarArg);
+ fir::EmboxOp::create(builder, loc, valType, addr, shape,
+ /*slice=*/mlir::Value{}, lenParams);
+ fir::StoreOp::create(builder, loc, nullBox, allocatedPrivVarArg);
return ifOp;
}
@@ -442,14 +442,14 @@ void PopulateInitAndCleanupRegionsHelper::initAndCleanupBoxedScalar(
/*shape=*/{}, lenParams);
if (scalarInitValue)
builder.createStoreWithConvert(loc, scalarInitValue, valAlloc);
- mlir::Value box = builder.create<fir::EmboxOp>(
- loc, valType, valAlloc, /*shape=*/mlir::Value{},
- /*slice=*/mlir::Value{}, lenParams);
+ mlir::Value box = fir::EmboxOp::create(builder, loc, valType, valAlloc,
+ /*shape=*/mlir::Value{},
+ /*slice=*/mlir::Value{}, lenParams);
initializeIfDerivedTypeBox(
builder, loc, box, getLoadedMoldArg(), needsInitialization,
/*isFirstPrivate=*/kind == DeclOperationKind::FirstPrivateOrLocalInit);
fir::StoreOp lastOp =
- builder.create<fir::StoreOp>(loc, box, allocatedPrivVarArg);
+ fir::StoreOp::create(builder, loc, box, allocatedPrivVarArg);
createCleanupRegion(converter, loc, argType, cleanupRegion, sym,
isDoConcurrent);
@@ -483,14 +483,15 @@ void PopulateInitAndCleanupRegionsHelper::initAndCleanupBoxedArray(
fir::ShapeShiftOp shape =
getShapeShift(builder, loc, source, cannotHaveNonDefaultLowerBounds);
mlir::Type arrayType = source.getElementOrSequenceType();
- mlir::Value allocatedArray = builder.create<fir::AllocMemOp>(
- loc, arrayType, /*typeparams=*/mlir::ValueRange{}, shape.getExtents());
- mlir::Value firClass = builder.create<fir::EmboxOp>(loc, source.getType(),
- allocatedArray, shape);
+ mlir::Value allocatedArray = fir::AllocMemOp::create(
+ builder, loc, arrayType, /*typeparams=*/mlir::ValueRange{},
+ shape.getExtents());
+ mlir::Value firClass = fir::EmboxOp::create(builder, loc, source.getType(),
+ allocatedArray, shape);
initializeIfDerivedTypeBox(
builder, loc, firClass, source, needsInitialization,
/*isFirstprivate=*/kind == DeclOperationKind::FirstPrivateOrLocalInit);
- builder.create<fir::StoreOp>(loc, firClass, allocatedPrivVarArg);
+ fir::StoreOp::create(builder, loc, firClass, allocatedPrivVarArg);
if (ifUnallocated)
builder.setInsertionPointAfter(ifUnallocated);
createYield(allocatedPrivVarArg);
@@ -543,22 +544,21 @@ void PopulateInitAndCleanupRegionsHelper::initAndCleanupBoxedArray(
if (mlir::isa<fir::BaseBoxType>(temp.getType()))
// the box created by the declare form createTempFromMold is missing
// lower bounds info
- box = builder.create<fir::ReboxOp>(loc, boxType, temp, shapeShift,
- /*shift=*/mlir::Value{});
+ box = fir::ReboxOp::create(builder, loc, boxType, temp, shapeShift,
+ /*shift=*/mlir::Value{});
else
- box = builder.create<fir::EmboxOp>(
- loc, boxType, temp, shapeShift,
- /*slice=*/mlir::Value{},
- /*typeParams=*/llvm::ArrayRef<mlir::Value>{});
+ box = fir::EmboxOp::create(builder, loc, boxType, temp, shapeShift,
+ /*slice=*/mlir::Value{},
+ /*typeParams=*/llvm::ArrayRef<mlir::Value>{});
if (scalarInitValue)
- builder.create<hlfir::AssignOp>(loc, scalarInitValue, box);
+ hlfir::AssignOp::create(builder, loc, scalarInitValue, box);
initializeIfDerivedTypeBox(
builder, loc, box, getLoadedMoldArg(), needsInitialization,
/*isFirstPrivate=*/kind == DeclOperationKind::FirstPrivateOrLocalInit);
- builder.create<fir::StoreOp>(loc, box, allocatedPrivVarArg);
+ fir::StoreOp::create(builder, loc, box, allocatedPrivVarArg);
if (ifUnallocated)
builder.setInsertionPointAfter(ifUnallocated);
createYield(allocatedPrivVarArg);
@@ -596,8 +596,8 @@ void PopulateInitAndCleanupRegionsHelper::initAndCleanupUnboxedDerivedType(
builder.setInsertionPointToStart(initBlock);
mlir::Type boxedTy = fir::BoxType::get(valType);
mlir::Value newBox =
- builder.create<fir::EmboxOp>(loc, boxedTy, allocatedPrivVarArg);
- mlir::Value moldBox = builder.create<fir::EmboxOp>(loc, boxedTy, moldArg);
+ fir::EmboxOp::create(builder, loc, boxedTy, allocatedPrivVarArg);
+ mlir::Value moldBox = fir::EmboxOp::create(builder, loc, boxedTy, moldArg);
initializeIfDerivedTypeBox(builder, loc, newBox, moldBox, needsInitialization,
/*isFirstPrivate=*/kind ==
DeclOperationKind::FirstPrivateOrLocalInit);
diff --git a/flang/lib/Lower/Support/ReductionProcessor.cpp b/flang/lib/Lower/Support/ReductionProcessor.cpp
index c0be1e229f825..80c32d066a38d 100644
--- a/flang/lib/Lower/Support/ReductionProcessor.cpp
+++ b/flang/lib/Lower/Support/ReductionProcessor.cpp
@@ -260,20 +260,20 @@ ReductionProcessor::getReductionInitValue(mlir::Location loc, mlir::Type type,
initIm);
}
if (mlir::isa<mlir::FloatType>(type))
- return builder.create<mlir::arith::ConstantOp>(
- loc, type,
+ return mlir::arith::ConstantOp::create(
+ builder, loc, type,
builder.getFloatAttr(type, (double)getOperationIdentity(redId, loc)));
if (mlir::isa<fir::LogicalType>(type)) {
- mlir::Value intConst = builder.create<mlir::arith::ConstantOp>(
- loc, builder.getI1Type(),
+ mlir::Value intConst = mlir::arith::ConstantOp::create(
+ builder, loc, builder.getI1Type(),
builder.getIntegerAttr(builder.getI1Type(),
getOperationIdentity(redId, loc)));
return builder.createConvert(loc, type, intConst);
}
- return builder.create<mlir::arith::ConstantOp>(
- loc, type,
+ return mlir::arith::ConstantOp::create(
+ builder, loc, type,
builder.getIntegerAttr(type, getOperationIdentity(redId, loc)));
case ReductionIdentifier::ID:
case ReductionIdentifier::USER_DEF_OP:
@@ -301,15 +301,15 @@ mlir::Value ReductionProcessor::createScalarCombiner(
break;
case ReductionIdentifier::IOR:
assert((type.isIntOrIndex()) && "only integer is expected");
- reductionOp = builder.create<mlir::arith::OrIOp>(loc, op1, op2);
+ reductionOp = mlir::arith::OrIOp::create(builder, loc, op1, op2);
break;
case ReductionIdentifier::IEOR:
assert((type.isIntOrIndex()) && "only integer is expected");
- reductionOp = builder.create<mlir::arith::XOrIOp>(loc, op1, op2);
+ reductionOp = mlir::arith::XOrIOp::create(builder, loc, op1, op2);
break;
case ReductionIdentifier::IAND:
assert((type.isIntOrIndex()) && "only integer is expected");
- reductionOp = builder.create<mlir::arith::AndIOp>(loc, op1, op2);
+ reductionOp = mlir::arith::AndIOp::create(builder, loc, op1, op2);
break;
case ReductionIdentifier::ADD:
reductionOp =
@@ -325,7 +325,8 @@ mlir::Value ReductionProcessor::createScalarCombiner(
mlir::Value op1I1 = builder.createConvert(loc, builder.getI1Type(), op1);
mlir::Value op2I1 = builder.createConvert(loc, builder.getI1Type(), op2);
- mlir::Value andiOp = builder.create<mlir::arith::AndIOp>(loc, op1I1, op2I1);
+ mlir::Value andiOp =
+ mlir::arith::AndIOp::create(builder, loc, op1I1, op2I1);
reductionOp = builder.createConvert(loc, type, andiOp);
break;
@@ -334,7 +335,7 @@ mlir::Value ReductionProcessor::createScalarCombiner(
mlir::Value op1I1 = builder.createConvert(loc, builder.getI1Type(), op1);
mlir::Value op2I1 = builder.createConvert(loc, builder.getI1Type(), op2);
- mlir::Value oriOp = builder.create<mlir::arith::OrIOp>(loc, op1I1, op2I1);
+ mlir::Value oriOp = mlir::arith::OrIOp::create(builder, loc, op1I1, op2I1);
reductionOp = builder.createConvert(loc, type, oriOp);
break;
@@ -343,8 +344,8 @@ mlir::Value ReductionProcessor::createScalarCombiner(
mlir::Value op1I1 = builder.createConvert(loc, builder.getI1Type(), op1);
mlir::Value op2I1 = builder.createConvert(loc, builder.getI1Type(), op2);
- mlir::Value cmpiOp = builder.create<mlir::arith::CmpIOp>(
- loc, mlir::arith::CmpIPredicate::eq, op1I1, op2I1);
+ mlir::Value cmpiOp = mlir::arith::CmpIOp::create(
+ builder, loc, mlir::arith::CmpIPredicate::eq, op1I1, op2I1);
reductionOp = builder.createConvert(loc, type, cmpiOp);
break;
@@ -353,8 +354,8 @@ mlir::Value ReductionProcessor::createScalarCombiner(
mlir::Value op1I1 = builder.createConvert(loc, builder.getI1Type(), op1);
mlir::Value op2I1 = builder.createConvert(loc, builder.getI1Type(), op2);
- mlir::Value cmpiOp = builder.create<mlir::arith::CmpIOp>(
- loc, mlir::arith::CmpIPredicate::ne, op1I1, op2I1);
+ mlir::Value cmpiOp = mlir::arith::CmpIOp::create(
+ builder, loc, mlir::arith::CmpIPredicate::ne, op1I1, op2I1);
reductionOp = builder.createConvert(loc, type, cmpiOp);
break;
@@ -370,9 +371,9 @@ template <typename ParentDeclOpType>
static void genYield(fir::FirOpBuilder &builder, mlir::Location loc,
mlir::Value yieldedValue) {
if constexpr (std::is_same_v<ParentDeclOpType, mlir::omp::DeclareReductionOp>)
- builder.create<mlir::omp::YieldOp>(loc, yieldedValue);
+ mlir::omp::YieldOp::create(builder, loc, yieldedValue);
else
- builder.create<fir::YieldOp>(loc, yieldedValue);
+ fir::YieldOp::create(builder, loc, yieldedValue);
}
/// Create reduction combiner region for reduction variables which are boxed
@@ -393,24 +394,24 @@ static void genBoxCombiner(fir::FirOpBuilder &builder, mlir::Location loc,
// load fir.ref<fir.box<...>>
mlir::Value lhsAddr = lhs;
- lhs = builder.create<fir::LoadOp>(loc, lhs);
- rhs = builder.create<fir::LoadOp>(loc, rhs);
+ lhs = fir::LoadOp::create(builder, loc, lhs);
+ rhs = fir::LoadOp::create(builder, loc, rhs);
if ((heapTy || ptrTy) && !seqTy) {
// get box contents (heap pointers)
- lhs = builder.create<fir::BoxAddrOp>(loc, lhs);
- rhs = builder.create<fir::BoxAddrOp>(loc, rhs);
+ lhs = fir::BoxAddrOp::create(builder, loc, lhs);
+ rhs = fir::BoxAddrOp::create(builder, loc, rhs);
mlir::Value lhsValAddr = lhs;
// load heap pointers
- lhs = builder.create<fir::LoadOp>(loc, lhs);
- rhs = builder.create<fir::LoadOp>(loc, rhs);
+ lhs = fir::LoadOp::create(builder, loc, lhs);
+ rhs = fir::LoadOp::create(builder, loc, rhs);
mlir::Type eleTy = heapTy ? heapTy.getEleTy() : ptrTy.getEleTy();
mlir::Value result = ReductionProcessor::createScalarCombiner(
builder, loc, redId, eleTy, lhs, rhs);
- builder.create<fir::StoreOp>(loc, result, lhsValAddr);
+ fir::StoreOp::create(builder, loc, result, lhsValAddr);
genYield<DeclRedOpType>(builder, loc, lhsAddr);
return;
}
@@ -437,17 +438,17 @@ static void genBoxCombiner(fir::FirOpBuilder &builder, mlir::Location loc,
builder.setInsertionPointToStart(nest.body);
const bool seqIsVolatile = fir::isa_volatile_type(seqTy.getEleTy());
mlir::Type refTy = fir::ReferenceType::get(seqTy.getEleTy(), seqIsVolatile);
- auto lhsEleAddr = builder.create<fir::ArrayCoorOp>(
- loc, refTy, lhs, shapeShift, /*slice=*/mlir::Value{},
+ auto lhsEleAddr = fir::ArrayCoorOp::create(
+ builder, loc, refTy, lhs, shapeShift, /*slice=*/mlir::Value{},
nest.oneBasedIndices, /*typeparms=*/mlir::ValueRange{});
- auto rhsEleAddr = builder.create<fir::ArrayCoorOp>(
- loc, refTy, rhs, shapeShift, /*slice=*/mlir::Value{},
+ auto rhsEleAddr = fir::ArrayCoorOp::create(
+ builder, loc, refTy, rhs, shapeShift, /*slice=*/mlir::Value{},
nest.oneBasedIndices, /*typeparms=*/mlir::ValueRange{});
- auto lhsEle = builder.create<fir::LoadOp>(loc, lhsEleAddr);
- auto rhsEle = builder.create<fir::LoadOp>(loc, rhsEleAddr);
+ auto lhsEle = fir::LoadOp::create(builder, loc, lhsEleAddr);
+ auto rhsEle = fir::LoadOp::create(builder, loc, rhsEleAddr);
mlir::Value scalarReduction = ReductionProcessor::createScalarCombiner(
builder, loc, redId, refTy, lhsEle, rhsEle);
- builder.create<fir::StoreOp>(loc, scalarReduction, lhsEleAddr);
+ fir::StoreOp::create(builder, loc, scalarReduction, lhsEleAddr);
builder.setInsertionPointAfter(nest.outerOp);
genYield<DeclRedOpType>(builder, loc, lhsAddr);
@@ -468,7 +469,7 @@ static void genCombiner(fir::FirOpBuilder &builder, mlir::Location loc,
mlir::Value result = ReductionProcessor::createScalarCombiner(
builder, loc, redId, ty, lhsLoaded, rhsLoaded);
if (isByRef) {
- builder.create<fir::StoreOp>(loc, result, lhs);
+ fir::StoreOp::create(builder, loc, result, lhs);
genYield<DeclRedOpType>(builder, loc, lhs);
} else {
genYield<DeclRedOpType>(builder, loc, result);
@@ -539,7 +540,7 @@ static void createReductionAllocAndInitRegions(
if (isByRef) {
// alloc region
builder.setInsertionPointToEnd(allocBlock);
- mlir::Value alloca = builder.create<fir::AllocaOp>(loc, ty);
+ mlir::Value alloca = fir::AllocaOp::create(builder, loc, ty);
yield(alloca);
return;
}
@@ -551,7 +552,7 @@ static void createReductionAllocAndInitRegions(
// alloc region
builder.setInsertionPointToEnd(allocBlock);
- mlir::Value boxAlloca = builder.create<fir::AllocaOp>(loc, ty);
+ mlir::Value boxAlloca = fir::AllocaOp::create(builder, loc, ty);
yield(boxAlloca);
}
@@ -575,7 +576,7 @@ OpType ReductionProcessor::createDeclareReduction(
if (!isByRef)
type = valTy;
- decl = modBuilder.create<OpType>(loc, reductionOpName, type);
+ decl = OpType::create(modBuilder, loc, reductionOpName, type);
createReductionAllocAndInitRegions(converter, loc, decl, redId, type,
isByRef);
@@ -672,8 +673,8 @@ void ReductionProcessor::processReductionArguments(
// Always pass the box by reference so that the OpenMP dialect
// verifiers don't need to know anything about fir.box
auto alloca =
- builder.create<fir::AllocaOp>(currentLocation, box.getType());
- builder.create<fir::StoreOp>(currentLocation, box, alloca);
+ fir::AllocaOp::create(builder, currentLocation, box.getType());
+ fir::StoreOp::create(builder, currentLocation, box, alloca);
symVal = alloca;
} else if (mlir::isa<fir::BaseBoxType>(symVal.getType())) {
@@ -683,9 +684,9 @@ void ReductionProcessor::processReductionArguments(
auto oldIP = builder.saveInsertionPoint();
builder.setInsertionPointToStart(builder.getAllocaBlock());
auto alloca =
- builder.create<fir::AllocaOp>(currentLocation, symVal.getType());
+ fir::AllocaOp::create(builder, currentLocation, symVal.getType());
builder.restoreInsertionPoint(oldIP);
- builder.create<fir::StoreOp>(currentLocation, symVal, alloca);
+ fir::StoreOp::create(builder, currentLocation, symVal, alloca);
symVal = alloca;
}
diff --git a/flang/lib/Lower/Support/Utils.cpp b/flang/lib/Lower/Support/Utils.cpp
index b9d2574a76ad0..881401e11fee4 100644
--- a/flang/lib/Lower/Support/Utils.cpp
+++ b/flang/lib/Lower/Support/Utils.cpp
@@ -702,9 +702,10 @@ void privatizeSymbol(
// Boxes should be passed by reference into nested regions:
auto oldIP = firOpBuilder.saveInsertionPoint();
firOpBuilder.setInsertionPointToStart(firOpBuilder.getAllocaBlock());
- auto alloca = firOpBuilder.create<fir::AllocaOp>(symLoc, privVal.getType());
+ auto alloca =
+ fir::AllocaOp::create(firOpBuilder, symLoc, privVal.getType());
firOpBuilder.restoreInsertionPoint(oldIP);
- firOpBuilder.create<fir::StoreOp>(symLoc, privVal, alloca);
+ fir::StoreOp::create(firOpBuilder, symLoc, privVal, alloca);
privVal = alloca;
}
@@ -726,15 +727,15 @@ void privatizeSymbol(
OpType result;
if constexpr (std::is_same_v<OpType, mlir::omp::PrivateClauseOp>) {
- result = firOpBuilder.create<OpType>(
- symLoc, uniquePrivatizerName, allocType,
+ result = OpType::create(
+ firOpBuilder, symLoc, uniquePrivatizerName, allocType,
emitCopyRegion ? mlir::omp::DataSharingClauseType::FirstPrivate
: mlir::omp::DataSharingClauseType::Private);
} else {
- result = firOpBuilder.create<OpType>(
- symLoc, uniquePrivatizerName, allocType,
- emitCopyRegion ? fir::LocalitySpecifierType::LocalInit
- : fir::LocalitySpecifierType::Local);
+ result =
+ OpType::create(firOpBuilder, symLoc, uniquePrivatizerName, allocType,
+ emitCopyRegion ? fir::LocalitySpecifierType::LocalInit
+ : fir::LocalitySpecifierType::Local);
}
fir::ExtendedValue symExV = converter.getSymbolExtendedValue(*sym);
@@ -815,12 +816,12 @@ void privatizeSymbol(
copyFirstPrivateSymbol(converter, symToPrivatize, &ip);
if constexpr (std::is_same_v<OpType, mlir::omp::PrivateClauseOp>) {
- firOpBuilder.create<mlir::omp::YieldOp>(
- hsb.getAddr().getLoc(),
+ mlir::omp::YieldOp::create(
+ firOpBuilder, hsb.getAddr().getLoc(),
symTable.shallowLookupSymbol(*symToPrivatize).getAddr());
} else {
- firOpBuilder.create<fir::YieldOp>(
- hsb.getAddr().getLoc(),
+ fir::YieldOp::create(
+ firOpBuilder, hsb.getAddr().getLoc(),
symTable.shallowLookupSymbol(*symToPrivatize).getAddr());
}
}
diff --git a/flang/lib/Lower/VectorSubscripts.cpp b/flang/lib/Lower/VectorSubscripts.cpp
index c7b3e11728cea..4d1d6fb28b365 100644
--- a/flang/lib/Lower/VectorSubscripts.cpp
+++ b/flang/lib/Lower/VectorSubscripts.cpp
@@ -121,8 +121,9 @@ class VectorSubscriptBoxBuilder {
if (recTy.getNumLenParams() != 0)
TODO(loc, "threading length parameters in field index op");
fir::FirOpBuilder &builder = converter.getFirOpBuilder();
- componentPath.emplace_back(builder.create<fir::FieldIndexOp>(
- loc, fldTy, componentName, recTy, /*typeParams=*/mlir::ValueRange{}));
+ componentPath.emplace_back(
+ fir::FieldIndexOp::create(builder, loc, fldTy, componentName, recTy,
+ /*typeParams=*/mlir::ValueRange{}));
return fir::unwrapSequenceType(recTy.getType(componentName));
}
@@ -269,16 +270,16 @@ mlir::Value Fortran::lower::VectorSubscriptBox::loopOverElementsBase(
for (auto [lb, ub, step] : genLoopBounds(builder, loc)) {
LoopType loop;
if constexpr (std::is_same_v<LoopType, fir::IterWhileOp>) {
- loop =
- builder.create<fir::IterWhileOp>(loc, lb, ub, step, initialCondition);
+ loop = fir::IterWhileOp::create(builder, loc, lb, ub, step,
+ initialCondition);
initialCondition = loop.getIterateVar();
if (!outerLoop)
outerLoop = loop;
else
- builder.create<fir::ResultOp>(loc, loop.getResult(0));
+ fir::ResultOp::create(builder, loc, loop.getResult(0));
} else {
- loop =
- builder.create<fir::DoLoopOp>(loc, lb, ub, step, /*unordered=*/false);
+ loop = fir::DoLoopOp::create(builder, loc, lb, ub, step,
+ /*unordered=*/false);
if (!outerLoop)
outerLoop = loop;
}
@@ -293,7 +294,7 @@ mlir::Value Fortran::lower::VectorSubscriptBox::loopOverElementsBase(
if constexpr (std::is_same_v<LoopType, fir::IterWhileOp>) {
auto res = elementalGenerator(elem);
- builder.create<fir::ResultOp>(loc, res);
+ fir::ResultOp::create(builder, loc, res);
builder.setInsertionPointAfter(outerLoop);
return outerLoop.getResult(0);
} else {
@@ -326,7 +327,7 @@ Fortran::lower::VectorSubscriptBox::createSlice(fir::FirOpBuilder &builder,
mlir::Type idxTy = builder.getIndexType();
llvm::SmallVector<mlir::Value> triples;
mlir::Value one = builder.createIntegerConstant(loc, idxTy, 1);
- auto undef = builder.create<fir::UndefOp>(loc, idxTy);
+ auto undef = fir::UndefOp::create(builder, loc, idxTy);
for (const LoweredSubscript &subscript : loweredSubscripts)
Fortran::common::visit(Fortran::common::visitors{
[&](const LoweredTriplet &triplet) {
@@ -346,7 +347,7 @@ Fortran::lower::VectorSubscriptBox::createSlice(fir::FirOpBuilder &builder,
},
},
subscript);
- return builder.create<fir::SliceOp>(loc, triples, componentPath);
+ return fir::SliceOp::create(builder, loc, triples, componentPath);
}
llvm::SmallVector<std::tuple<mlir::Value, mlir::Value, mlir::Value>>
@@ -369,13 +370,13 @@ Fortran::lower::VectorSubscriptBox::genLoopBounds(fir::FirOpBuilder &builder,
builder, loc, loweredBase, dimension, one);
baseLb = builder.createConvert(loc, idxTy, baseLb);
lb = baseLb;
- ub = builder.create<mlir::arith::SubIOp>(loc, idxTy, extent, one);
- ub = builder.create<mlir::arith::AddIOp>(loc, idxTy, ub, baseLb);
+ ub = mlir::arith::SubIOp::create(builder, loc, idxTy, extent, one);
+ ub = mlir::arith::AddIOp::create(builder, loc, idxTy, ub, baseLb);
step = one;
} else {
const auto &vector = std::get<LoweredVectorSubscript>(subscript);
lb = zero;
- ub = builder.create<mlir::arith::SubIOp>(loc, idxTy, vector.size, one);
+ ub = mlir::arith::SubIOp::create(builder, loc, idxTy, vector.size, one);
step = one;
}
bounds.emplace_back(lb, ub, step);
@@ -402,10 +403,10 @@ fir::ExtendedValue Fortran::lower::VectorSubscriptBox::getElementAt(
mlir::Type vecEleTy = fir::unwrapSequenceType(
fir::unwrapPassByRefType(vecBase.getType()));
mlir::Type refTy = builder.getRefType(vecEleTy);
- auto vecEltRef = builder.create<fir::CoordinateOp>(
- loc, refTy, vecBase, vecIndex);
+ auto vecEltRef = fir::CoordinateOp::create(builder, loc, refTy,
+ vecBase, vecIndex);
auto vecElt =
- builder.create<fir::LoadOp>(loc, vecEleTy, vecEltRef);
+ fir::LoadOp::create(builder, loc, vecEleTy, vecEltRef);
indexes.emplace_back(builder.createConvert(loc, idxTy, vecElt));
},
[&](const mlir::Value &i) {
@@ -414,8 +415,8 @@ fir::ExtendedValue Fortran::lower::VectorSubscriptBox::getElementAt(
},
subscript);
mlir::Type refTy = builder.getRefType(getElementType());
- auto elementAddr = builder.create<fir::ArrayCoorOp>(
- loc, refTy, fir::getBase(loweredBase), shape, slice, indexes,
+ auto elementAddr = fir::ArrayCoorOp::create(
+ builder, loc, refTy, fir::getBase(loweredBase), shape, slice, indexes,
fir::getTypeParams(loweredBase));
fir::ExtendedValue element = fir::factory::arraySectionElementToExtendedValue(
builder, loc, loweredBase, elementAddr, slice);
More information about the flang-commits
mailing list