[mlir][NFC] update flang/Lower create APIs (8/n) (#149912)

See https://github.com/llvm/llvm-project/pull/147168 for more info.
This commit is contained in:
Maksim Levental 2025-07-21 18:54:29 -05:00 committed by GitHub
parent 6fa759b465
commit a3a007ad5f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
24 changed files with 1378 additions and 1336 deletions

View File

@ -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 @@ private:
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 @@ private:
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 @@ private:
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 @@ private:
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 @@ private:
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 @@ private:
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));
}

View File

@ -333,11 +333,12 @@ private:
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 @@ private:
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 @@ private:
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 @@ private:
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 @@ private:
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 @@ private:
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 @@ private:
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 @@ private:
// 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(&regionAssignOp.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 @@ private:
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 @@ private:
builder.createBlock(&regionAssignOp.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()};

View File

@ -137,9 +137,9 @@ public:
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 @@ public:
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 @@ public:
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 @@ public:
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 @@ public:
/*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 @@ public:
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 @@ public:
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 @@ public:
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};
}

View File

@ -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 different 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);

View File

@ -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.

File diff suppressed because it is too large Load Diff

View File

@ -167,7 +167,7 @@ public:
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 @@ private:
// 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 @@ private:
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 @@ private:
} 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 @@ private:
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 @@ private:
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 @@ private:
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 @@ private:
// 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 @@ private:
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 @@ private:
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 @@ private:
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)();
};

View File

@ -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(

View File

@ -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));
}

View File

@ -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));

View File

@ -63,7 +63,7 @@ protected:
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];
}

View File

@ -165,7 +165,7 @@ public:
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 @@ public:
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 @@ public:
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 @@ public:
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 @@ public:
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 @@ public:
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 @@ public:
// 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 @@ public:
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 @@ public:
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());
}

View File

@ -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;

View File

@ -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(

View File

@ -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 &region = updateOp->getRegion(0);
mlir::Block *block = builder.createBlock(&region, {}, {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;

View File

@ -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);
}

View File

@ -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)) {

View File

@ -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(&region);
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 &region = declMapperOp.getRegion();
firOpBuilder.createBlock(&region);
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);

View File

@ -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++;
}
}

View File

@ -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);
}

View File

@ -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 @@ private:
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);

View File

@ -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;
}

View File

@ -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());
}
}

View File

@ -121,8 +121,9 @@ private:
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);