[flang][NFC] Update more FIR op creation to the new APIs (#152060)

This commit is contained in:
Valentin Clement (バレンタイン クレメン) 2025-08-04 17:53:44 -07:00 committed by GitHub
parent 03e902cc68
commit 3b23fdb35d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
12 changed files with 288 additions and 288 deletions

View File

@ -530,21 +530,21 @@ public:
/// bodies.
IfBuilder genIfOp(mlir::Location loc, mlir::TypeRange results,
mlir::Value cdt, bool withElseRegion) {
auto op = create<fir::IfOp>(loc, results, cdt, withElseRegion);
auto op = fir::IfOp::create(*this, loc, results, cdt, withElseRegion);
return IfBuilder(op, *this);
}
/// Create an IfOp with no "else" region, and no result values.
/// Usage: genIfThen(loc, cdt).genThen(lambda).end();
IfBuilder genIfThen(mlir::Location loc, mlir::Value cdt) {
auto op = create<fir::IfOp>(loc, mlir::TypeRange(), cdt, false);
auto op = fir::IfOp::create(*this, loc, mlir::TypeRange(), cdt, false);
return IfBuilder(op, *this);
}
/// Create an IfOp with an "else" region, and no result values.
/// Usage: genIfThenElse(loc, cdt).genThen(lambda).genElse(lambda).end();
IfBuilder genIfThenElse(mlir::Location loc, mlir::Value cdt) {
auto op = create<fir::IfOp>(loc, mlir::TypeRange(), cdt, true);
auto op = fir::IfOp::create(*this, loc, mlir::TypeRange(), cdt, true);
return IfBuilder(op, *this);
}

View File

@ -49,8 +49,8 @@ void genCharacterCopy(mlir::Value src, mlir::Value srcLen, mlir::Value dst,
if (!srcLen && !dstLen && srcTy.getFKind() == dstTy.getFKind() &&
srcTy.getLen() == dstTy.getLen()) {
// same size, so just use load and store
auto load = builder.template create<fir::LoadOp>(loc, src);
builder.template create<fir::StoreOp>(loc, load, dst);
auto load = fir::LoadOp::create(builder, loc, src);
fir::StoreOp::create(builder, loc, load, dst);
return;
}
auto zero = builder.template create<mlir::arith::ConstantIndexOp>(loc, 0);
@ -70,75 +70,72 @@ void genCharacterCopy(mlir::Value src, mlir::Value srcLen, mlir::Value dst,
if (!srcLen && !dstLen && srcTy.getLen() >= dstTy.getLen()) {
auto upper = builder.template create<mlir::arith::ConstantIndexOp>(
loc, dstTy.getLen() - 1);
auto loop = builder.template create<fir::DoLoopOp>(loc, zero, upper, one);
auto loop = fir::DoLoopOp::create(builder, loc, zero, upper, one);
auto insPt = builder.saveInsertionPoint();
builder.setInsertionPointToStart(loop.getBody());
auto csrcTy = toArrayTy(srcTy);
auto csrc = builder.template create<fir::ConvertOp>(loc, csrcTy, src);
auto in = builder.template create<fir::CoordinateOp>(
loc, toCoorTy(csrcTy), csrc, loop.getInductionVar());
auto load = builder.template create<fir::LoadOp>(loc, in);
auto csrc = fir::ConvertOp::create(builder, loc, csrcTy, src);
auto in = fir::CoordinateOp::create(builder, loc, toCoorTy(csrcTy), csrc,
loop.getInductionVar());
auto load = fir::LoadOp::create(builder, loc, in);
auto cdstTy = toArrayTy(dstTy);
auto cdst = builder.template create<fir::ConvertOp>(loc, cdstTy, dst);
auto out = builder.template create<fir::CoordinateOp>(
loc, toCoorTy(cdstTy), cdst, loop.getInductionVar());
auto cdst = fir::ConvertOp::create(builder, loc, cdstTy, dst);
auto out = fir::CoordinateOp::create(builder, loc, toCoorTy(cdstTy), cdst,
loop.getInductionVar());
mlir::Value cast =
srcTy.getFKind() == dstTy.getFKind()
? load.getResult()
: builder
.template create<fir::ConvertOp>(loc, toEleTy(cdstTy), load)
: fir::ConvertOp::create(builder, loc, toEleTy(cdstTy), load)
.getResult();
builder.template create<fir::StoreOp>(loc, cast, out);
fir::StoreOp::create(builder, loc, cast, out);
builder.restoreInsertionPoint(insPt);
return;
}
auto minusOne = [&](mlir::Value v) -> mlir::Value {
return builder.template create<mlir::arith::SubIOp>(
loc, builder.template create<fir::ConvertOp>(loc, one.getType(), v),
one);
loc, fir::ConvertOp::create(builder, loc, one.getType(), v), one);
};
mlir::Value len = dstLen ? minusOne(dstLen)
: builder
.template create<mlir::arith::ConstantIndexOp>(
loc, dstTy.getLen() - 1)
.getResult();
auto loop = builder.template create<fir::DoLoopOp>(loc, zero, len, one);
auto loop = fir::DoLoopOp::create(builder, loc, zero, len, one);
auto insPt = builder.saveInsertionPoint();
builder.setInsertionPointToStart(loop.getBody());
mlir::Value slen =
srcLen
? builder.template create<fir::ConvertOp>(loc, one.getType(), srcLen)
.getResult()
: builder
.template create<mlir::arith::ConstantIndexOp>(loc,
srcTy.getLen())
.getResult();
srcLen ? fir::ConvertOp::create(builder, loc, one.getType(), srcLen)
.getResult()
: builder
.template create<mlir::arith::ConstantIndexOp>(
loc, srcTy.getLen())
.getResult();
auto cond = builder.template create<mlir::arith::CmpIOp>(
loc, mlir::arith::CmpIPredicate::slt, loop.getInductionVar(), slen);
auto ifOp = builder.template create<fir::IfOp>(loc, cond, /*withElse=*/true);
auto ifOp = fir::IfOp::create(builder, loc, cond, /*withElse=*/true);
builder.setInsertionPointToStart(&ifOp.getThenRegion().front());
auto csrcTy = toArrayTy(srcTy);
auto csrc = builder.template create<fir::ConvertOp>(loc, csrcTy, src);
auto in = builder.template create<fir::CoordinateOp>(
loc, toCoorTy(csrcTy), csrc, loop.getInductionVar());
auto load = builder.template create<fir::LoadOp>(loc, in);
auto csrc = fir::ConvertOp::create(builder, loc, csrcTy, src);
auto in = fir::CoordinateOp::create(builder, loc, toCoorTy(csrcTy), csrc,
loop.getInductionVar());
auto load = fir::LoadOp::create(builder, loc, in);
auto cdstTy = toArrayTy(dstTy);
auto cdst = builder.template create<fir::ConvertOp>(loc, cdstTy, dst);
auto out = builder.template create<fir::CoordinateOp>(
loc, toCoorTy(cdstTy), cdst, loop.getInductionVar());
auto cdst = fir::ConvertOp::create(builder, loc, cdstTy, dst);
auto out = fir::CoordinateOp::create(builder, loc, toCoorTy(cdstTy), cdst,
loop.getInductionVar());
mlir::Value cast =
srcTy.getFKind() == dstTy.getFKind()
? load.getResult()
: builder.template create<fir::ConvertOp>(loc, toEleTy(cdstTy), load)
: fir::ConvertOp::create(builder, loc, toEleTy(cdstTy), load)
.getResult();
builder.template create<fir::StoreOp>(loc, cast, out);
fir::StoreOp::create(builder, loc, cast, out);
builder.setInsertionPointToStart(&ifOp.getElseRegion().front());
auto space = builder.template create<fir::StringLitOp>(
loc, toEleTy(cdstTy), llvm::ArrayRef<char>{' '});
auto cdst2 = builder.template create<fir::ConvertOp>(loc, cdstTy, dst);
auto out2 = builder.template create<fir::CoordinateOp>(
loc, toCoorTy(cdstTy), cdst2, loop.getInductionVar());
builder.template create<fir::StoreOp>(loc, space, out2);
auto space = fir::StringLitOp::create(builder, loc, toEleTy(cdstTy),
llvm::ArrayRef<char>{' '});
auto cdst2 = fir::ConvertOp::create(builder, loc, cdstTy, dst);
auto out2 = fir::CoordinateOp::create(builder, loc, toCoorTy(cdstTy), cdst2,
loop.getInductionVar());
fir::StoreOp::create(builder, loc, space, out2);
builder.restoreInsertionPoint(insPt);
}

View File

@ -796,7 +796,7 @@ public:
auto empty = fir::factory::createUnallocatedBox(
*builder, loc, new_box->getBoxTy(), box.nonDeferredLenParams(),
{});
builder->create<fir::StoreOp>(loc, empty, new_box->getAddr());
fir::StoreOp::create(*builder, loc, empty, new_box->getAddr());
return;
}
// Copy allocation status of Allocatables, creating new storage if
@ -843,7 +843,7 @@ public:
auto empty = fir::factory::createUnallocatedBox(
*builder, loc, new_box->getBoxTy(),
new_box->nonDeferredLenParams(), {});
builder->create<fir::StoreOp>(loc, empty, new_box->getAddr());
fir::StoreOp::create(*builder, loc, empty, new_box->getAddr());
});
if_builder.end();
},
@ -1322,8 +1322,8 @@ private:
if (isPointer) {
// Set LHS target to the target of RHS (do not copy the RHS
// target data into the LHS target storage).
auto loadVal = builder->create<fir::LoadOp>(loc, rhs);
builder->create<fir::StoreOp>(loc, loadVal, lhs);
auto loadVal = fir::LoadOp::create(*builder, loc, rhs);
fir::StoreOp::create(*builder, loc, loadVal, lhs);
} else if (isAllocatable &&
flags.test(Fortran::semantics::Symbol::Flag::OmpCopyIn)) {
// For copyin allocatable variables, RHS must be copied to lhs
@ -1377,8 +1377,8 @@ private:
} else if (lhs.getBoxOf<fir::CharBoxValue>()) {
fir::factory::CharacterExprHelper{*builder, loc}.createAssign(lhs, rhs);
} else {
auto loadVal = builder->create<fir::LoadOp>(loc, fir::getBase(rhs));
builder->create<fir::StoreOp>(loc, loadVal, fir::getBase(lhs));
auto loadVal = fir::LoadOp::create(*builder, loc, fir::getBase(rhs));
fir::StoreOp::create(*builder, loc, loadVal, fir::getBase(lhs));
}
}
@ -1629,7 +1629,7 @@ private:
blockList.push_back(defaultBlock);
if (valueList[branchCount - 1] == 0) // Swap IO ERR and default blocks.
std::swap(blockList[branchCount - 1], blockList[branchCount]);
builder->create<fir::SelectOp>(loc, selector, valueList, blockList);
fir::SelectOp::create(*builder, loc, selector, valueList, blockList);
return;
}
mlir::Type selectorType = selector.getType();
@ -1738,13 +1738,13 @@ private:
mlir::Value resultVal = resultSymBox.match(
[&](const fir::CharBoxValue &x) -> mlir::Value {
if (Fortran::semantics::IsBindCProcedure(functionSymbol))
return builder->create<fir::LoadOp>(loc, x.getBuffer());
return fir::LoadOp::create(*builder, loc, x.getBuffer());
return fir::factory::CharacterExprHelper{*builder, loc}
.createEmboxChar(x.getBuffer(), x.getLen());
},
[&](const fir::MutableBoxValue &x) -> mlir::Value {
mlir::Value resultRef = resultSymBox.getAddr();
mlir::Value load = builder->create<fir::LoadOp>(loc, resultRef);
mlir::Value load = fir::LoadOp::create(*builder, loc, resultRef);
unsigned rank = x.rank();
if (x.isAllocatable() && rank > 0) {
// ALLOCATABLE array result must have default lower bounds.
@ -1760,9 +1760,9 @@ private:
llvm::SmallVector<mlir::Value> lbounds{rank, one};
auto shiftTy = fir::ShiftType::get(builder->getContext(), rank);
mlir::Value shiftOp =
builder->create<fir::ShiftOp>(loc, shiftTy, lbounds);
load = builder->create<fir::ReboxOp>(
loc, load.getType(), load, shiftOp, /*slice=*/mlir::Value{});
fir::ShiftOp::create(*builder, loc, shiftTy, lbounds);
load = fir::ReboxOp::create(*builder, loc, load.getType(), load,
shiftOp, /*slice=*/mlir::Value{});
}
return load;
},
@ -1776,7 +1776,7 @@ private:
if (resultRef.getType() != resultRefType)
resultRef = builder->createConvertWithVolatileCast(
loc, resultRefType, resultRef);
return builder->create<fir::LoadOp>(loc, resultRef);
return fir::LoadOp::create(*builder, loc, resultRef);
});
genExitRoutine(false, resultVal);
}
@ -1802,8 +1802,8 @@ private:
if (Fortran::semantics::IsFunction(symbol)) {
genReturnSymbol(symbol);
} else if (Fortran::semantics::HasAlternateReturns(symbol)) {
mlir::Value retval = builder->create<fir::LoadOp>(
toLocation(), getAltReturnResult(symbol));
mlir::Value retval = fir::LoadOp::create(*builder, toLocation(),
getAltReturnResult(symbol));
genExitRoutine(false, retval);
} else {
genExitRoutine(false);
@ -1956,7 +1956,7 @@ private:
}
if (!labelList.empty()) {
auto selectExpr =
builder->create<fir::LoadOp>(loc, getSymbolAddress(symbol));
fir::LoadOp::create(*builder, loc, getSymbolAddress(symbol));
// Add a default error target in case the goto is nonconforming.
mlir::Block *errorBlock =
builder->getBlock()->splitBlock(builder->getInsertionPoint());
@ -1968,7 +1968,7 @@ private:
*builder, loc,
"Assigned GOTO variable '" + symbol.name().ToString() +
"' does not have a valid target label value");
builder->create<fir::UnreachableOp>(loc);
fir::UnreachableOp::create(*builder, loc);
}
fir::ReduceOperationEnum
@ -2485,7 +2485,7 @@ private:
if (!isConst) {
mlir::Value stepValue = nestSts.back();
info.stepVariable = builder->createTemporary(loc, stepValue.getType());
builder->create<fir::StoreOp>(loc, stepValue, info.stepVariable);
fir::StoreOp::create(*builder, loc, stepValue, info.stepVariable);
}
}
@ -2498,8 +2498,9 @@ private:
// The loop variable is a doLoop op argument.
mlir::Type loopVarType = info.getLoopVariableType();
auto loopOp = builder->create<fir::DoLoopOp>(
loc, lowerValue, upperValue, stepValue, /*unordered=*/false,
auto loopOp = fir::DoLoopOp::create(
*builder, loc, lowerValue, upperValue, stepValue,
/*unordered=*/false,
/*finalCountValue=*/true,
builder->createConvert(loc, loopVarType, lowerValue));
info.loopOp = loopOp;
@ -2507,7 +2508,7 @@ private:
mlir::Value loopValue = loopOp.getRegionIterArgs()[0];
// Update the loop variable value in case it has non-index references.
builder->create<fir::StoreOp>(loc, loopValue, info.loopVariable);
fir::StoreOp::create(*builder, loc, loopValue, info.loopVariable);
addLoopAnnotationAttr(info, dirs);
continue;
}
@ -2539,13 +2540,13 @@ private:
builder->create<mlir::arith::SelectOp>(loc, cond, one, tripCount);
}
info.tripVariable = builder->createTemporary(loc, tripCount.getType());
builder->create<fir::StoreOp>(loc, tripCount, info.tripVariable);
builder->create<fir::StoreOp>(loc, lowerValue, info.loopVariable);
fir::StoreOp::create(*builder, loc, tripCount, info.tripVariable);
fir::StoreOp::create(*builder, loc, lowerValue, info.loopVariable);
// Unstructured loop header - generate loop condition and mask.
// Note - Currently there is no way to tag a loop as a concurrent loop.
startBlock(info.headerBlock);
tripCount = builder->create<fir::LoadOp>(loc, info.tripVariable);
tripCount = fir::LoadOp::create(*builder, loc, info.tripVariable);
mlir::Value zero =
builder->createIntegerConstant(loc, tripCount.getType(), 0);
auto cond = builder->create<mlir::arith::CmpIOp>(
@ -2573,7 +2574,7 @@ private:
}
if (genDoConcurrent) {
auto loopWrapperOp = builder->create<fir::DoConcurrentOp>(loc);
auto loopWrapperOp = fir::DoConcurrentOp::create(*builder, loc);
builder->setInsertionPointToStart(
builder->createBlock(&loopWrapperOp.getRegion()));
@ -2583,8 +2584,8 @@ private:
}
builder->setInsertionPointToEnd(loopWrapperOp.getBody());
auto loopOp = builder->create<fir::DoConcurrentLoopOp>(
loc, nestLBs, nestUBs, nestSts, /*loopAnnotation=*/nullptr,
auto loopOp = fir::DoConcurrentLoopOp::create(
*builder, loc, nestLBs, nestUBs, nestSts, /*loopAnnotation=*/nullptr,
/*local_vars=*/mlir::ValueRange{},
/*local_syms=*/nullptr, /*reduce_vars=*/mlir::ValueRange{},
/*reduce_byref=*/nullptr, /*reduce_syms=*/nullptr,
@ -2604,7 +2605,7 @@ private:
info.loopOp = loopOp;
mlir::Value loopValue =
builder->createConvert(loc, info.getLoopVariableType(), blockArg);
builder->create<fir::StoreOp>(loc, loopValue, info.loopVariable);
fir::StoreOp::create(*builder, loc, loopValue, info.loopVariable);
if (info.maskExpr) {
Fortran::lower::StatementContext stmtCtx;
@ -2612,8 +2613,8 @@ private:
stmtCtx.finalizeAndReset();
mlir::Value maskCondCast =
builder->createConvert(loc, builder->getI1Type(), maskCond);
auto ifOp = builder->create<fir::IfOp>(loc, maskCondCast,
/*withElseRegion=*/false);
auto ifOp = fir::IfOp::create(*builder, loc, maskCondCast,
/*withElseRegion=*/false);
builder->setInsertionPointToStart(&ifOp.getThenRegion().front());
}
}
@ -2659,35 +2660,35 @@ private:
mlir::Value step = builder->createConvert(
loc, info.getLoopVariableType(), doLoopOp.getStep());
mlir::Value loopVar =
builder->create<fir::LoadOp>(loc, info.loopVariable);
fir::LoadOp::create(*builder, loc, info.loopVariable);
results.push_back(
builder->create<mlir::arith::AddIOp>(loc, loopVar, step, iofAttr));
builder->create<fir::ResultOp>(loc, results);
fir::ResultOp::create(*builder, loc, results);
builder->setInsertionPointAfter(doLoopOp);
// The loop control variable may be used after the loop.
builder->create<fir::StoreOp>(loc, doLoopOp.getResult(1),
info.loopVariable);
fir::StoreOp::create(*builder, loc, doLoopOp.getResult(1),
info.loopVariable);
continue;
}
// Unstructured loop - decrement tripVariable and step loopVariable.
mlir::Value tripCount =
builder->create<fir::LoadOp>(loc, info.tripVariable);
fir::LoadOp::create(*builder, loc, info.tripVariable);
mlir::Value one =
builder->createIntegerConstant(loc, tripCount.getType(), 1);
tripCount = builder->create<mlir::arith::SubIOp>(loc, tripCount, one);
builder->create<fir::StoreOp>(loc, tripCount, info.tripVariable);
mlir::Value value = builder->create<fir::LoadOp>(loc, info.loopVariable);
fir::StoreOp::create(*builder, loc, tripCount, info.tripVariable);
mlir::Value value = fir::LoadOp::create(*builder, loc, info.loopVariable);
mlir::Value step;
if (info.stepVariable)
step = builder->create<fir::LoadOp>(loc, info.stepVariable);
step = fir::LoadOp::create(*builder, loc, info.stepVariable);
else
step = genControlValue(info.stepExpr, info);
if (info.hasRealControl)
value = builder->create<mlir::arith::AddFOp>(loc, value, step);
else
value = builder->create<mlir::arith::AddIOp>(loc, value, step, iofAttr);
builder->create<fir::StoreOp>(loc, value, info.loopVariable);
fir::StoreOp::create(*builder, loc, value, info.loopVariable);
genBranch(info.headerBlock);
if (&info != &incrementLoopNestInfo.front()) // not outermost
@ -2708,8 +2709,8 @@ private:
Fortran::lower::pft::Evaluation &succ = *e.controlSuccessor;
bool hasElse = succ.isA<Fortran::parser::ElseIfStmt>() ||
succ.isA<Fortran::parser::ElseStmt>();
auto ifOp = builder->create<fir::IfOp>(toLocation(), cond,
/*withElseRegion=*/hasElse);
auto ifOp = fir::IfOp::create(*builder, toLocation(), cond,
/*withElseRegion=*/hasElse);
builder->setInsertionPointToStart(&ifOp.getThenRegion().front());
return ifOp;
};
@ -2814,7 +2815,7 @@ private:
llvm::ArrayRef<mlir::NamedAttribute>{
fir::getAdaptToByRefAttr(*builder)});
mlir::Value cast = builder->createConvert(loc, toTy, inducVar);
builder->create<fir::StoreOp>(loc, cast, tmp);
fir::StoreOp::create(*builder, loc, cast, tmp);
addSymbol(*sym, tmp, /*force=*/true);
}
@ -2896,11 +2897,11 @@ private:
lowerExpr(*Fortran::semantics::GetExpr(*optStep)))
: builder->createIntegerConstant(loc, idxTy, 1);
}
auto lp = builder->create<fir::DoLoopOp>(
loc, lb, ub, by, /*unordered=*/true,
auto lp = fir::DoLoopOp::create(
*builder, loc, lb, ub, by, /*unordered=*/true,
/*finalCount=*/false, explicitIterSpace.getInnerArgs());
if ((!loops.empty() || !outermost) && !lp.getRegionIterArgs().empty())
builder->create<fir::ResultOp>(loc, lp.getResults());
fir::ResultOp::create(*builder, loc, lp.getResults());
explicitIterSpace.setInnerArgs(lp.getRegionIterArgs());
builder->setInsertionPointToStart(lp.getBody());
forceControlVariableBinding(ctrlVar, lp.getInductionVar());
@ -2918,12 +2919,12 @@ private:
genExprValue(*Fortran::semantics::GetExpr(mask.value()), stmtCtx);
mlir::Value cond =
builder->createConvert(loc, i1Ty, fir::getBase(maskExv));
auto ifOp = builder->create<fir::IfOp>(
loc, explicitIterSpace.innerArgTypes(), cond,
/*withElseRegion=*/true);
builder->create<fir::ResultOp>(loc, ifOp.getResults());
auto ifOp = fir::IfOp::create(*builder, loc,
explicitIterSpace.innerArgTypes(), cond,
/*withElseRegion=*/true);
fir::ResultOp::create(*builder, loc, ifOp.getResults());
builder->setInsertionPointToStart(&ifOp.getElseRegion().front());
builder->create<fir::ResultOp>(loc, explicitIterSpace.getInnerArgs());
fir::ResultOp::create(*builder, loc, explicitIterSpace.getInnerArgs());
builder->setInsertionPointToStart(&ifOp.getThenRegion().front());
}
};
@ -3083,7 +3084,7 @@ private:
builder->getStringAttr(controlVar->name().ToString()));
localSymbols.addVariableDefinition(*controlVar, forallIndex,
/*force=*/true);
auto end = builder->create<fir::FirEndOp>(loc);
auto end = fir::FirEndOp::create(*builder, loc);
builder->setInsertionPoint(end);
}
@ -3094,7 +3095,7 @@ private:
auto forallMaskOp = builder->create<hlfir::ForallMaskOp>(loc);
evaluateControl(*maskExpr, forallMaskOp.getMaskRegion(), /*isMask=*/true);
builder->createBlock(&forallMaskOp.getBody());
auto end = builder->create<fir::FirEndOp>(loc);
auto end = fir::FirEndOp::create(*builder, loc);
builder->setInsertionPoint(end);
}
}
@ -3356,9 +3357,9 @@ private:
loc, 1); // Use index type directly
// Ensure lb, ub, and step are of index type using fir.convert
lb = builder->create<fir::ConvertOp>(loc, idxTy, lb);
ub = builder->create<fir::ConvertOp>(loc, idxTy, ub);
step = builder->create<fir::ConvertOp>(loc, idxTy, step);
lb = fir::ConvertOp::create(*builder, loc, idxTy, lb);
ub = fir::ConvertOp::create(*builder, loc, idxTy, ub);
step = fir::ConvertOp::create(*builder, loc, idxTy, step);
lbs.push_back(lb);
ubs.push_back(ub);
@ -3454,7 +3455,7 @@ private:
op.getLoopRegions().front()->front().getArguments(), ivValues)) {
mlir::Value convArg =
builder->createConvert(loc, fir::unwrapRefType(value.getType()), arg);
builder->create<fir::StoreOp>(loc, convArg, value);
fir::StoreOp::create(*builder, loc, convArg, value);
}
if (crtEval->lowerAsStructured()) {
@ -3467,7 +3468,7 @@ private:
for (Fortran::lower::pft::Evaluation &e : crtEval->getNestedEvaluations())
genFIR(e);
builder->create<fir::FirEndOp>(loc);
fir::FirEndOp::create(*builder, loc);
builder->setInsertionPointAfter(op);
}
@ -3608,8 +3609,8 @@ private:
// The selector is in an ssa register. Any temps that may have been
// generated while evaluating it can be cleaned up now.
stmtCtx.finalizeAndReset();
builder->create<fir::SelectCaseOp>(loc, selector, attrList, valueList,
blockList);
fir::SelectCaseOp::create(*builder, loc, selector, attrList, valueList,
blockList);
return;
}
@ -3832,8 +3833,8 @@ private:
// the default case (F'2023 11.1.10.2.). The selector cannot be an
// assumed-size if it is allocatable or pointer, so the check is skipped.
if (!Fortran::evaluate::IsAllocatableOrPointerObject(*selectorExpr)) {
mlir::Value isAssumedSize = builder->create<fir::IsAssumedSizeOp>(
loc, builder->getI1Type(), selector);
mlir::Value isAssumedSize = fir::IsAssumedSizeOp::create(
*builder, loc, builder->getI1Type(), selector);
// Create new block to hold the fir.select_case for the non assumed-size
// cases.
mlir::Block *selectCaseBlock = insertBlock(blockList[0]);
@ -3845,10 +3846,11 @@ private:
startBlock(selectCaseBlock);
}
// Create fir.select_case for the other rank cases.
mlir::Value rank = builder->create<fir::BoxRankOp>(loc, rankType, selector);
mlir::Value rank =
fir::BoxRankOp::create(*builder, loc, rankType, selector);
stmtCtx.finalizeAndReset();
builder->create<fir::SelectCaseOp>(loc, rank, attrList, valueList,
blockList);
fir::SelectCaseOp::create(*builder, loc, rank, attrList, valueList,
blockList);
}
// Get associating entity symbol inside case statement scope.
@ -4057,8 +4059,8 @@ private:
}
attrList.push_back(mlir::UnitAttr::get(context));
blockList.push_back(defaultBlock);
builder->create<fir::SelectTypeOp>(loc, fir::getBase(selector),
attrList, blockList);
fir::SelectTypeOp::create(*builder, loc, fir::getBase(selector),
attrList, blockList);
// If the actual position of CLASS DEFAULT type guard is not the last
// one, it needs to be put back at its correct position for the rest of
@ -4133,13 +4135,14 @@ private:
fir::ReferenceType::get(addrTy, selectorIsVolatile());
if (isPointer || isAllocatable)
refTy = addrTy;
exactValue = builder->create<fir::BoxAddrOp>(
loc, refTy, fir::getBase(selector));
exactValue = fir::BoxAddrOp::create(*builder, loc, refTy,
fir::getBase(selector));
const Fortran::semantics::IntrinsicTypeSpec *intrinsic =
typeSpec->declTypeSpec->AsIntrinsic();
if (isArray) {
mlir::Value exact = builder->create<fir::ConvertOp>(
loc, fir::BoxType::get(addrTy, selectorIsVolatile()),
mlir::Value exact = fir::ConvertOp::create(
*builder, loc,
fir::BoxType::get(addrTy, selectorIsVolatile()),
fir::getBase(selector));
addAssocEntitySymbol(selectorBox->clone(exact));
} else if (intrinsic->category() ==
@ -4154,8 +4157,8 @@ private:
}
} else if (std::holds_alternative<Fortran::parser::DerivedTypeSpec>(
typeSpec->u)) {
exactValue = builder->create<fir::ConvertOp>(
loc, fir::BoxType::get(addrTy, selectorIsVolatile()),
exactValue = fir::ConvertOp::create(
*builder, loc, fir::BoxType::get(addrTy, selectorIsVolatile()),
fir::getBase(selector));
addAssocEntitySymbol(selectorBox->clone(exactValue));
}
@ -4179,8 +4182,8 @@ private:
if (classTy == baseTy) {
addAssocEntitySymbol(selector);
} else {
mlir::Value derived = builder->create<fir::ConvertOp>(
loc, classTy, fir::getBase(selector));
mlir::Value derived = fir::ConvertOp::create(
*builder, loc, classTy, fir::getBase(selector));
addAssocEntitySymbol(selectorBox->clone(derived));
}
}
@ -4474,21 +4477,21 @@ private:
mlir::Type indexTy = builder->getIndexType();
mlir::Type boundArrayTy = fir::SequenceType::get(
{static_cast<int64_t>(lbounds.size())}, builder->getI64Type());
mlir::Value boundArray = builder->create<fir::AllocaOp>(loc, boundArrayTy);
mlir::Value array = builder->create<fir::UndefOp>(loc, boundArrayTy);
mlir::Value boundArray = fir::AllocaOp::create(*builder, loc, boundArrayTy);
mlir::Value array = fir::UndefOp::create(*builder, loc, boundArrayTy);
for (unsigned i = 0; i < lbounds.size(); ++i) {
array = builder->create<fir::InsertValueOp>(
loc, boundArrayTy, array, lbounds[i],
array = fir::InsertValueOp::create(
*builder, loc, boundArrayTy, array, lbounds[i],
builder->getArrayAttr({builder->getIntegerAttr(
builder->getIndexType(), static_cast<int>(i))}));
}
builder->create<fir::StoreOp>(loc, array, boundArray);
fir::StoreOp::create(*builder, loc, array, boundArray);
mlir::Type boxTy = fir::BoxType::get(boundArrayTy);
mlir::Value ext =
builder->createIntegerConstant(loc, indexTy, lbounds.size());
llvm::SmallVector<mlir::Value> shapes = {ext};
mlir::Value shapeOp = builder->genShape(loc, shapes);
return builder->create<fir::EmboxOp>(loc, boxTy, boundArray, shapeOp);
return fir::EmboxOp::create(*builder, loc, boxTy, boundArray, shapeOp);
}
// Generate pointer assignment with possibly empty bounds-spec. R1035: a
@ -4624,7 +4627,7 @@ private:
loc, *this, assign.rhs, localSymbols, rhsContext);
// Create pointer descriptor value from the RHS.
if (rhs.isMutableBox())
rhs = hlfir::Entity{builder->create<fir::LoadOp>(loc, rhs)};
rhs = hlfir::Entity{fir::LoadOp::create(*builder, loc, rhs)};
mlir::Value rhsBox = hlfir::genVariableBox(
loc, *builder, rhs, lhsBoxType.getBoxTypeWithNewShape(rhs.getRank()));
// Apply lower bounds or reshaping if any.
@ -4636,8 +4639,8 @@ private:
for (const Fortran::evaluate::ExtentExpr &lbExpr : *lbExprs)
lbounds.push_back(lowerToIndexValue(loc, lbExpr, rhsContext));
mlir::Value shift = builder->genShift(loc, lbounds);
rhsBox = builder->create<fir::ReboxOp>(loc, lhsBoxType, rhsBox, shift,
/*slice=*/mlir::Value{});
rhsBox = fir::ReboxOp::create(*builder, loc, lhsBoxType, rhsBox, shift,
/*slice=*/mlir::Value{});
} else if (const auto *boundExprs =
std::get_if<Fortran::evaluate::Assignment::BoundsRemapping>(
&assign.u);
@ -4655,8 +4658,8 @@ private:
*builder, loc, lbounds.back(), ub, zero, one));
}
mlir::Value shape = builder->genShape(loc, lbounds, extents);
rhsBox = builder->create<fir::ReboxOp>(loc, lhsBoxType, rhsBox, shape,
/*slice=*/mlir::Value{});
rhsBox = fir::ReboxOp::create(*builder, loc, lhsBoxType, rhsBox, shape,
/*slice=*/mlir::Value{});
}
return rhsBox;
}
@ -4670,30 +4673,30 @@ private:
mlir::Type indexTy = builder->getIndexType();
mlir::Type boundArrayTy = fir::SequenceType::get(
{2, static_cast<int64_t>(lbounds.size())}, builder->getI64Type());
mlir::Value boundArray = builder->create<fir::AllocaOp>(loc, boundArrayTy);
mlir::Value array = builder->create<fir::UndefOp>(loc, boundArrayTy);
mlir::Value boundArray = fir::AllocaOp::create(*builder, loc, boundArrayTy);
mlir::Value array = fir::UndefOp::create(*builder, loc, boundArrayTy);
for (unsigned i = 0; i < lbounds.size(); ++i) {
array = builder->create<fir::InsertValueOp>(
loc, boundArrayTy, array, lbounds[i],
array = fir::InsertValueOp::create(
*builder, loc, boundArrayTy, array, lbounds[i],
builder->getArrayAttr(
{builder->getIntegerAttr(builder->getIndexType(), 0),
builder->getIntegerAttr(builder->getIndexType(),
static_cast<int>(i))}));
array = builder->create<fir::InsertValueOp>(
loc, boundArrayTy, array, ubounds[i],
array = fir::InsertValueOp::create(
*builder, loc, boundArrayTy, array, ubounds[i],
builder->getArrayAttr(
{builder->getIntegerAttr(builder->getIndexType(), 1),
builder->getIntegerAttr(builder->getIndexType(),
static_cast<int>(i))}));
}
builder->create<fir::StoreOp>(loc, array, boundArray);
fir::StoreOp::create(*builder, loc, array, boundArray);
mlir::Type boxTy = fir::BoxType::get(boundArrayTy);
mlir::Value ext =
builder->createIntegerConstant(loc, indexTy, lbounds.size());
mlir::Value c2 = builder->createIntegerConstant(loc, indexTy, 2);
llvm::SmallVector<mlir::Value> shapes = {c2, ext};
mlir::Value shapeOp = builder->genShape(loc, shapes);
return builder->create<fir::EmboxOp>(loc, boxTy, boundArray, shapeOp);
return fir::EmboxOp::create(*builder, loc, boxTy, boundArray, shapeOp);
}
// Pointer assignment with bounds-remapping. R1036: a bounds-remapping is a
@ -4767,7 +4770,7 @@ private:
if (explicitIterationSpace()) {
mlir::ValueRange inners = explicitIterSpace.getInnerArgs();
if (!inners.empty())
builder->create<fir::ResultOp>(loc, inners);
fir::ResultOp::create(*builder, loc, inners);
}
}
@ -5268,7 +5271,7 @@ private:
mlir::Value pteVal = fir::getBase(pte);
mlir::Value cnvrt = Fortran::lower::addCrayPointerInst(
loc, *builder, ptrVal, ptrTy, pteVal.getType());
addr = builder->create<fir::LoadOp>(loc, cnvrt);
addr = fir::LoadOp::create(*builder, loc, cnvrt);
}
mlir::Value cast =
isVector ? val
@ -5278,7 +5281,7 @@ private:
addr = builder->createConvert(
toLocation(), builder->getRefType(toTy), addr);
}
builder->create<fir::StoreOp>(loc, cast, addr);
fir::StoreOp::create(*builder, loc, cast, addr);
} else if (isCharacterCategory(lhsType->category())) {
// Fortran 2018 10.2.1.3 p10 and p11
fir::factory::CharacterExprHelper{*builder, loc}.createAssign(
@ -5392,7 +5395,7 @@ private:
if (whereOp) {
// For HLFIR, create fir.end terminator in the last hlfir.elsewhere, or
// in the hlfir.where if it had no elsewhere.
builder->create<fir::FirEndOp>(loc);
fir::FirEndOp::create(*builder, loc);
builder->setInsertionPointAfter(whereOp);
}
}
@ -5494,7 +5497,7 @@ private:
lowerWhereMaskToHlfir(loc, mask);
builder->createBlock(&whereOp.getBody());
genAssignment(*assign.typedAssignment->v);
builder->create<fir::FirEndOp>(loc);
fir::FirEndOp::create(*builder, loc);
builder->setInsertionPointAfter(whereOp);
return;
}
@ -5557,12 +5560,12 @@ private:
// If the address points to a boxed pointer, we need to dereference it
if (auto refType = mlir::dyn_cast<fir::ReferenceType>(addr.getType())) {
if (auto boxType = mlir::dyn_cast<fir::BoxType>(refType.getEleTy())) {
mlir::Value boxValue = builder->create<fir::LoadOp>(loc, addr);
addr = builder->create<fir::BoxAddrOp>(loc, boxValue);
mlir::Value boxValue = fir::LoadOp::create(*builder, loc, addr);
addr = fir::BoxAddrOp::create(*builder, loc, boxValue);
}
}
builder->create<fir::StoreOp>(loc, labelValue, addr);
fir::StoreOp::create(*builder, loc, labelValue, addr);
}
void genFIR(const Fortran::parser::FormatStmt &) {
@ -5613,8 +5616,8 @@ private:
assert(expr && "missing alternate return expression");
mlir::Value altReturnIndex = builder->createConvert(
loc, builder->getIndexType(), createFIRExpr(loc, expr, stmtCtx));
builder->create<fir::StoreOp>(loc, altReturnIndex,
getAltReturnResult(symbol));
fir::StoreOp::create(*builder, loc, altReturnIndex,
getAltReturnResult(symbol));
}
}
// Branch to the last block of the SUBROUTINE, which has the actual return.
@ -5725,7 +5728,7 @@ private:
// Always generate fir.dummy_scope even if there are no arguments.
// It is currently used to create proper TBAA forest.
if (lowerToHighLevelFIR()) {
mlir::Value scopeOp = builder->create<fir::DummyScopeOp>(toLocation());
mlir::Value scopeOp = fir::DummyScopeOp::create(*builder, toLocation());
setDummyArgsScope(scopeOp);
}
if (std::optional<Fortran::lower::CalleeInterface::PassedEntity>
@ -5767,10 +5770,10 @@ private:
mlir::Value ones = builder->createIntegerConstant(
loc, testExcept.getFunctionType().getInput(0), -1);
mlir::Value exceptSet =
builder->create<fir::CallOp>(loc, testExcept, ones).getResult(0);
builder->create<fir::CallOp>(loc, clearExcept, exceptSet);
fir::CallOp::create(*builder, loc, testExcept, ones).getResult(0);
fir::CallOp::create(*builder, loc, clearExcept, exceptSet);
bridge.fctCtx().attachCleanup([=]() {
builder->create<fir::CallOp>(endLoc, raiseExcept, exceptSet);
fir::CallOp::create(*builder, endLoc, raiseExcept, exceptSet);
});
}
if (funit.mayModifyHaltingMode) {
@ -5783,12 +5786,12 @@ private:
mlir::func::FuncOp enableExcept =
fir::factory::getFeenableexcept(*builder);
mlir::Value exceptSet =
builder->create<fir::CallOp>(loc, getExcept).getResult(0);
fir::CallOp::create(*builder, loc, getExcept).getResult(0);
mlir::Value ones = builder->createIntegerConstant(
loc, disableExcept.getFunctionType().getInput(0), -1);
bridge.fctCtx().attachCleanup([=]() {
builder->create<fir::CallOp>(endLoc, disableExcept, ones);
builder->create<fir::CallOp>(endLoc, enableExcept, exceptSet);
fir::CallOp::create(*builder, endLoc, disableExcept, ones);
fir::CallOp::create(*builder, endLoc, enableExcept, exceptSet);
});
}
if (funit.mayModifyRoundingMode) {
@ -5800,9 +5803,9 @@ private:
mlir::func::FuncOp setRounding =
fir::factory::getLlvmSetRounding(*builder);
mlir::Value roundingMode =
builder->create<fir::CallOp>(loc, getRounding).getResult(0);
fir::CallOp::create(*builder, loc, getRounding).getResult(0);
bridge.fctCtx().attachCleanup([=]() {
builder->create<fir::CallOp>(endLoc, setRounding, roundingMode);
fir::CallOp::create(*builder, endLoc, setRounding, roundingMode);
});
}
if ((funit.mayModifyUnderflowMode) &&
@ -5960,8 +5963,8 @@ private:
// convert the storage to the symbol type so that the hlfir.declare
// gets the correct type for this symbol
preAlloc = builder->create<fir::ConvertOp>(getCurrentLocation(),
wrappedSymTy, preAlloc);
preAlloc = fir::ConvertOp::create(*builder, getCurrentLocation(),
wrappedSymTy, preAlloc);
}
Fortran::lower::mapSymbolAttributes(*this, altResult, localSymbols,
@ -5997,7 +6000,7 @@ private:
builder->createTemporary(loc, idxTy, toStringRef(symbol.name()));
addSymbol(symbol, altResult);
mlir::Value zero = builder->createIntegerConstant(loc, idxTy, 0);
builder->create<fir::StoreOp>(loc, zero, altResult);
fir::StoreOp::create(*builder, loc, zero, altResult);
}
if (Fortran::lower::pft::Evaluation *alternateEntryEval =
@ -6471,23 +6474,23 @@ private:
// FIXME: Is there a way to create a `zeroinitializer` in LLVM-IR dialect?
// For now, explicitly set lazy ragged header to all zeros.
// auto nilTup = builder->createNullConstant(loc, ty);
// builder->create<fir::StoreOp>(loc, nilTup, hdr);
// fir::StoreOp::create(*builder, loc, nilTup, hdr);
mlir::Type i32Ty = builder->getIntegerType(32);
mlir::Value zero = builder->createIntegerConstant(loc, i32Ty, 0);
mlir::Value zero64 = builder->createIntegerConstant(loc, i64Ty, 0);
mlir::Value flags = builder->create<fir::CoordinateOp>(
loc, builder->getRefType(i64Ty), hdr, zero);
builder->create<fir::StoreOp>(loc, zero64, flags);
mlir::Value flags = fir::CoordinateOp::create(
*builder, loc, builder->getRefType(i64Ty), hdr, zero);
fir::StoreOp::create(*builder, loc, zero64, flags);
mlir::Value one = builder->createIntegerConstant(loc, i32Ty, 1);
mlir::Value nullPtr1 = builder->createNullConstant(loc, buffTy);
mlir::Value var = builder->create<fir::CoordinateOp>(
loc, builder->getRefType(buffTy), hdr, one);
builder->create<fir::StoreOp>(loc, nullPtr1, var);
mlir::Value var = fir::CoordinateOp::create(
*builder, loc, builder->getRefType(buffTy), hdr, one);
fir::StoreOp::create(*builder, loc, nullPtr1, var);
mlir::Value two = builder->createIntegerConstant(loc, i32Ty, 2);
mlir::Value nullPtr2 = builder->createNullConstant(loc, shTy);
mlir::Value shape = builder->create<fir::CoordinateOp>(
loc, builder->getRefType(shTy), hdr, two);
builder->create<fir::StoreOp>(loc, nullPtr2, shape);
mlir::Value shape = fir::CoordinateOp::create(
*builder, loc, builder->getRefType(shTy), hdr, two);
fir::StoreOp::create(*builder, loc, nullPtr2, shape);
implicitIterSpace.addMaskVariable(exp, var, shape, hdr);
explicitIterSpace.outermostContext().attachCleanup(
[builder = this->builder, hdr, loc]() {

View File

@ -2866,10 +2866,9 @@ public:
/*withElseRegion=*/true)
.genThen([&]() {
auto rebox =
builder
.create<fir::ReboxOp>(
loc, actualTy, box, mlir::Value{},
/*slice=*/mlir::Value{})
fir::ReboxOp::create(builder, loc, actualTy,
box, mlir::Value{},
/*slice=*/mlir::Value{})
.getResult();
fir::ResultOp::create(builder, loc, rebox);
})
@ -4209,11 +4208,10 @@ private:
// Adjust indices for any shift of the origin of the array.
llvm::SmallVector<mlir::Value> indices = fir::factory::originateIndices(
loc, *builder, tmp.getType(), shape, iters.iterVec());
auto addr =
builder->create<fir::ArrayCoorOp>(loc, eleRefTy, tmp, shape,
/*slice=*/mlir::Value{}, indices,
/*typeParams=*/mlir::ValueRange{});
auto load = builder->create<fir::LoadOp>(loc, addr);
auto addr = fir::ArrayCoorOp::create(*builder, loc, eleRefTy, tmp, shape,
/*slice=*/mlir::Value{}, indices,
/*typeParams=*/mlir::ValueRange{});
auto load = fir::LoadOp::create(*builder, loc, addr);
return builder->createConvert(loc, i1Ty, load);
};
}
@ -4541,7 +4539,7 @@ private:
mlir::ValueRange{}, shape);
fir::FirOpBuilder *bldr = &converter.getFirOpBuilder();
stmtCtx.attachCleanup(
[bldr, loc, temp]() { bldr->create<fir::FreeMemOp>(loc, temp); });
[bldr, loc, temp]() { fir::FreeMemOp::create(*bldr, loc, temp); });
mlir::Value shapeOp = genShapeOp(shape);
return fir::ArrayLoadOp::create(builder, loc, seqTy, temp, shapeOp,
/*slice=*/mlir::Value{},
@ -5840,9 +5838,8 @@ private:
mlir::isa<fir::BaseBoxType>(memref.getType())
? fir::ReboxOp::create(builder, loc, boxTy, memref, shape, slice)
.getResult()
: builder
.create<fir::EmboxOp>(loc, boxTy, memref, shape, slice,
fir::getTypeParams(extMemref))
: fir::EmboxOp::create(builder, loc, boxTy, memref, shape, slice,
fir::getTypeParams(extMemref))
.getResult();
return [=](IterSpace) -> ExtValue {
return fir::BoxValue(embox, lbounds, nonDeferredLenParams);
@ -6540,7 +6537,7 @@ private:
// Cleanup the temporary.
fir::FirOpBuilder *bldr = &converter.getFirOpBuilder();
stmtCtx.attachCleanup(
[bldr, loc, mem]() { bldr->create<fir::FreeMemOp>(loc, mem); });
[bldr, loc, mem]() { fir::FreeMemOp::create(*bldr, loc, mem); });
// Return the continuation.
if (fir::isa_char(seqTy.getEleTy())) {
@ -6724,8 +6721,8 @@ private:
auto loc = getLoc();
auto newCoorRef = [bldr, coorTy, offsets, currentFunc,
loc](mlir::Value val) -> mlir::Value {
return bldr->create<fir::CoordinateOp>(loc, bldr->getRefType(coorTy),
currentFunc(val), offsets);
return fir::CoordinateOp::create(*bldr, loc, bldr->getRefType(coorTy),
currentFunc(val), offsets);
};
component.extendCoorRef = newCoorRef;
}
@ -6855,7 +6852,8 @@ private:
auto loc = getLoc();
auto *bldr = &converter.getFirOpBuilder();
auto newCoorRef = [=](mlir::Value val) -> mlir::Value {
return bldr->create<fir::LoadOp>(loc, currentFunc(val));
return fir::LoadOp::create(*bldr, loc,
currentFunc(val));
};
components.extendCoorRef = newCoorRef;
deref = true;
@ -7103,7 +7101,7 @@ private:
}
} else {
auto eleVal = convertElementForUpdate(loc, eleTy, iters.getElement());
builder->create<fir::StoreOp>(loc, eleVal, addr);
fir::StoreOp::create(*builder, loc, eleVal, addr);
}
return exv;
};

View File

@ -212,5 +212,5 @@ mlir::Value Fortran::lower::derefPassProcPointerComponent(
"failed to retrieve pointer procedure component symbol");
hlfir::EntityWithAttributes pointerComp = designateProcedurePointerComponent(
loc, converter, *procComponentSym, passedArg, symMap, stmtCtx);
return converter.getFirOpBuilder().create<fir::LoadOp>(loc, pointerComp);
return fir::LoadOp::create(converter.getFirOpBuilder(), loc, pointerComp);
}

View File

@ -103,7 +103,7 @@ Fortran::lower::genIntrinsicCall(fir::FirOpBuilder &builder, mlir::Location loc,
addr =
fir::BoxAddrOp::create(builder, loc, box->getMemTy(), box->getAddr());
fir::FirOpBuilder *bldr = &builder;
stmtCtx.attachCleanup([=]() { bldr->create<fir::FreeMemOp>(loc, addr); });
stmtCtx.attachCleanup([=]() { fir::FreeMemOp::create(*bldr, loc, addr); });
}
return result;
}

View File

@ -2522,12 +2522,10 @@ mlir::Value Fortran::lower::genInquireStatement(
fir::getBase(converter.genExprAddr(loc, ioLengthVar, stmtCtx));
llvm::SmallVector<mlir::Value> args = {cookie};
mlir::Value length =
builder
.create<fir::CallOp>(
loc,
fir::runtime::getIORuntimeFunc<mkIOKey(GetIoLength)>(loc,
builder),
args)
fir::CallOp::create(
builder, loc,
fir::runtime::getIORuntimeFunc<mkIOKey(GetIoLength)>(loc, builder),
args)
.getResult(0);
mlir::Value length1 =
builder.createConvert(loc, converter.genType(*ioLengthVar), length);

View File

@ -138,7 +138,7 @@ mlir::Type fir::FirOpBuilder::getRealType(int kind) {
mlir::Value fir::FirOpBuilder::createNullConstant(mlir::Location loc,
mlir::Type ptrType) {
auto ty = ptrType ? ptrType : getRefType(getNoneType());
return create<fir::ZeroOp>(loc, ty);
return fir::ZeroOp::create(*this, loc, ty);
}
mlir::Value fir::FirOpBuilder::createIntegerConstant(mlir::Location loc,
@ -242,13 +242,13 @@ mlir::Value fir::FirOpBuilder::allocateLocal(
// Create the local variable.
if (name.empty()) {
if (uniqName.empty())
return create<fir::AllocaOp>(loc, ty, pinned, elidedLenParams, indices,
attrs);
return create<fir::AllocaOp>(loc, ty, uniqName, pinned, elidedLenParams,
indices, attrs);
return fir::AllocaOp::create(*this, loc, ty, pinned, elidedLenParams,
indices, attrs);
return fir::AllocaOp::create(*this, loc, ty, uniqName, pinned,
elidedLenParams, indices, attrs);
}
return create<fir::AllocaOp>(loc, ty, uniqName, name, pinned, elidedLenParams,
indices, attrs);
return fir::AllocaOp::create(*this, loc, ty, uniqName, name, pinned,
elidedLenParams, indices, attrs);
}
mlir::Value fir::FirOpBuilder::allocateLocal(
@ -328,8 +328,9 @@ mlir::Value fir::FirOpBuilder::createTemporaryAlloc(
/*unique_name=*/llvm::StringRef{}, name, attr,
lenParams, shape, attrs);
} else {
return create<fir::AllocaOp>(loc, type, /*unique_name=*/llvm::StringRef{},
name, pinned, lenParams, shape, attrs);
return fir::AllocaOp::create(*this, loc, type,
/*unique_name=*/llvm::StringRef{}, name,
pinned, lenParams, shape, attrs);
}
}
@ -369,8 +370,9 @@ mlir::Value fir::FirOpBuilder::createHeapTemporary(
fir::factory::elideLengthsAlreadyInType(type, lenParams);
assert(!mlir::isa<fir::ReferenceType>(type) && "cannot be a reference");
return create<fir::AllocMemOp>(loc, type, /*unique_name=*/llvm::StringRef{},
name, dynamicLength, dynamicShape, attrs);
return fir::AllocMemOp::create(*this, loc, type,
/*unique_name=*/llvm::StringRef{}, name,
dynamicLength, dynamicShape, attrs);
}
std::pair<mlir::Value, bool> fir::FirOpBuilder::createAndDeclareTemp(
@ -385,7 +387,7 @@ std::pair<mlir::Value, bool> fir::FirOpBuilder::createAndDeclareTemp(
mlir::Value boxAddress = fir::factory::getAndEstablishBoxStorage(
*this, loc, boxType, shape, typeParams, polymorphicMold);
fir::runtime::genAllocatableAllocate(*this, loc, boxAddress);
mlir::Value box = create<fir::LoadOp>(loc, boxAddress);
mlir::Value box = fir::LoadOp::create(*this, loc, boxAddress);
mlir::Value base =
genDeclare(*this, loc, box, tmpName, /*shape=*/mlir::Value{},
typeParams, fir::FortranVariableFlagsAttr{});
@ -442,8 +444,8 @@ fir::GlobalOp fir::FirOpBuilder::createGlobal(
attrs.push_back(mlir::NamedAttribute(
fir::GlobalOp::getDataAttrAttrName(globalOpName), dataAttr));
}
auto glob = create<fir::GlobalOp>(loc, name, isConst, isTarget, type, value,
linkage, attrs);
auto glob = fir::GlobalOp::create(*this, loc, name, isConst, isTarget, type,
value, linkage, attrs);
restoreInsertionPoint(insertPt);
if (symbolTable)
symbolTable->insert(glob);
@ -459,7 +461,7 @@ fir::GlobalOp fir::FirOpBuilder::createGlobal(
auto module = getModule();
auto insertPt = saveInsertionPoint();
setInsertionPoint(module.getBody(), module.getBody()->end());
auto glob = create<fir::GlobalOp>(loc, name, isConst, isTarget, type,
auto glob = fir::GlobalOp::create(*this, loc, name, isConst, isTarget, type,
mlir::Attribute{}, linkage);
auto &region = glob.getRegion();
region.push_back(new mlir::Block);
@ -482,7 +484,7 @@ fir::FirOpBuilder::createTypeInfoOp(mlir::Location loc,
return {typeInfo, InsertPoint{}};
InsertPoint insertPoint = saveInsertionPoint();
setInsertionPoint(module.getBody(), module.getBody()->end());
auto typeInfo = create<fir::TypeInfoOp>(loc, recordType, parentType);
auto typeInfo = fir::TypeInfoOp::create(*this, loc, recordType, parentType);
if (symbolTable)
symbolTable->insert(typeInfo);
return {typeInfo, insertPoint};
@ -538,14 +540,14 @@ mlir::Value fir::FirOpBuilder::convertWithSemantics(
assert((fir::unwrapRefType(toTy) ==
fir::unwrapRefType(fir::unwrapPassByRefType(fromTy)) &&
"element types expected to match"));
return create<fir::BoxAddrOp>(loc, toTy, val);
return fir::BoxAddrOp::create(*this, loc, toTy, val);
}
if (fir::isa_ref_type(fromTy) && mlir::isa<fir::BoxProcType>(toTy)) {
// Call is expecting a boxed procedure, not a reference to other data type.
// Convert the reference to a procedure and embox it.
mlir::Type procTy = mlir::cast<fir::BoxProcType>(toTy).getEleTy();
mlir::Value proc = createConvert(loc, procTy, val);
return create<fir::EmboxProcOp>(loc, toTy, proc);
return fir::EmboxProcOp::create(*this, loc, toTy, proc);
}
// Legacy: remove when removing non HLFIR lowering path.
@ -555,7 +557,7 @@ mlir::Value fir::FirOpBuilder::convertWithSemantics(
fir::isPolymorphicType(toTy)) ||
(fir::isPolymorphicType(fromTy) && mlir::isa<fir::BoxType>(toTy))) &&
!(fir::isUnlimitedPolymorphicType(fromTy) && fir::isAssumedType(toTy)))
return create<fir::ReboxOp>(loc, toTy, val, mlir::Value{},
return fir::ReboxOp::create(*this, loc, toTy, val, mlir::Value{},
/*slice=*/mlir::Value{});
return createConvert(loc, toTy, val);
@ -568,7 +570,7 @@ mlir::Value fir::FirOpBuilder::createVolatileCast(mlir::Location loc,
fir::updateTypeWithVolatility(val.getType(), isVolatile);
if (volatileAdjustedType == val.getType())
return val;
return create<fir::VolatileCastOp>(loc, volatileAdjustedType, val);
return fir::VolatileCastOp::create(*this, loc, volatileAdjustedType, val);
}
mlir::Value fir::FirOpBuilder::createConvertWithVolatileCast(mlir::Location loc,
@ -602,12 +604,12 @@ void fir::FirOpBuilder::createStoreWithConvert(mlir::Location loc,
mlir::Type unwrapedRefType = fir::unwrapRefType(addr.getType());
val = createVolatileCast(loc, fir::isa_volatile_type(unwrapedRefType), val);
mlir::Value cast = createConvert(loc, unwrapedRefType, val);
create<fir::StoreOp>(loc, cast, addr);
fir::StoreOp::create(*this, loc, cast, addr);
}
mlir::Value fir::FirOpBuilder::loadIfRef(mlir::Location loc, mlir::Value val) {
if (fir::isa_ref_type(val.getType()))
return create<fir::LoadOp>(loc, val);
return fir::LoadOp::create(*this, loc, val);
return val;
}
@ -620,13 +622,13 @@ fir::StringLitOp fir::FirOpBuilder::createStringLitOp(mlir::Location loc,
auto sizeTag = mlir::StringAttr::get(getContext(), fir::StringLitOp::size());
mlir::NamedAttribute sizeAttr(sizeTag, getI64IntegerAttr(data.size()));
llvm::SmallVector<mlir::NamedAttribute> attrs{dataAttr, sizeAttr};
return create<fir::StringLitOp>(loc, llvm::ArrayRef<mlir::Type>{type},
return fir::StringLitOp::create(*this, loc, llvm::ArrayRef<mlir::Type>{type},
mlir::ValueRange{}, attrs);
}
mlir::Value fir::FirOpBuilder::genShape(mlir::Location loc,
llvm::ArrayRef<mlir::Value> exts) {
return create<fir::ShapeOp>(loc, exts);
return fir::ShapeOp::create(*this, loc, exts);
}
mlir::Value fir::FirOpBuilder::genShape(mlir::Location loc,
@ -640,7 +642,7 @@ mlir::Value fir::FirOpBuilder::genShape(mlir::Location loc,
shapeArgs.push_back(lb);
shapeArgs.push_back(ext);
}
return create<fir::ShapeShiftOp>(loc, shapeType, shapeArgs);
return fir::ShapeShiftOp::create(*this, loc, shapeType, shapeArgs);
}
mlir::Value fir::FirOpBuilder::genShape(mlir::Location loc,
@ -653,7 +655,7 @@ mlir::Value fir::FirOpBuilder::genShape(mlir::Location loc,
mlir::Value fir::FirOpBuilder::genShift(mlir::Location loc,
llvm::ArrayRef<mlir::Value> shift) {
auto shiftType = fir::ShiftType::get(getContext(), shift.size());
return create<fir::ShiftOp>(loc, shiftType, shift);
return fir::ShiftOp::create(*this, loc, shiftType, shift);
}
mlir::Value fir::FirOpBuilder::createShape(mlir::Location loc,
@ -665,7 +667,7 @@ mlir::Value fir::FirOpBuilder::createShape(mlir::Location loc,
if (!box.getLBounds().empty()) {
auto shiftType =
fir::ShiftType::get(getContext(), box.getLBounds().size());
return create<fir::ShiftOp>(loc, shiftType, box.getLBounds());
return fir::ShiftOp::create(*this, loc, shiftType, box.getLBounds());
}
return {};
},
@ -694,7 +696,7 @@ mlir::Value fir::FirOpBuilder::createSlice(mlir::Location loc,
trips.push_back(v);
trips.push_back(one);
}
return create<fir::SliceOp>(loc, trips, path);
return fir::SliceOp::create(*this, loc, trips, path);
}
for (auto [lbnd, extent] : llvm::zip(lbounds, extents)) {
auto lb = createConvert(loc, idxTy, lbnd);
@ -705,7 +707,7 @@ mlir::Value fir::FirOpBuilder::createSlice(mlir::Location loc,
trips.push_back(ub);
trips.push_back(one);
}
return create<fir::SliceOp>(loc, trips, path);
return fir::SliceOp::create(*this, loc, trips, path);
};
return exv.match(
[&](const fir::ArrayBoxValue &box) {
@ -725,7 +727,7 @@ mlir::Value fir::FirOpBuilder::createSlice(mlir::Location loc,
},
[&](auto) -> mlir::Value { fir::emitFatalError(loc, "not an array"); });
}
return create<fir::SliceOp>(loc, triples, path);
return fir::SliceOp::create(*this, loc, triples, path);
}
mlir::Value fir::FirOpBuilder::createBox(mlir::Location loc,
@ -763,43 +765,44 @@ mlir::Value fir::FirOpBuilder::createBox(mlir::Location loc,
mlir::Value empty;
mlir::ValueRange emptyRange;
mlir::Value s = createShape(loc, exv);
return create<fir::EmboxOp>(loc, boxTy, itemAddr, s, /*slice=*/empty,
return fir::EmboxOp::create(*this, loc, boxTy, itemAddr, s,
/*slice=*/empty,
/*typeparams=*/emptyRange,
isPolymorphic ? box.getSourceBox() : tdesc);
},
[&](const fir::CharArrayBoxValue &box) -> mlir::Value {
mlir::Value s = createShape(loc, exv);
if (fir::factory::CharacterExprHelper::hasConstantLengthInType(exv))
return create<fir::EmboxOp>(loc, boxTy, itemAddr, s);
return fir::EmboxOp::create(*this, loc, boxTy, itemAddr, s);
mlir::Value emptySlice;
llvm::SmallVector<mlir::Value> lenParams{box.getLen()};
return create<fir::EmboxOp>(loc, boxTy, itemAddr, s, emptySlice,
return fir::EmboxOp::create(*this, loc, boxTy, itemAddr, s, emptySlice,
lenParams);
},
[&](const fir::CharBoxValue &box) -> mlir::Value {
if (fir::factory::CharacterExprHelper::hasConstantLengthInType(exv))
return create<fir::EmboxOp>(loc, boxTy, itemAddr);
return fir::EmboxOp::create(*this, loc, boxTy, itemAddr);
mlir::Value emptyShape, emptySlice;
llvm::SmallVector<mlir::Value> lenParams{box.getLen()};
return create<fir::EmboxOp>(loc, boxTy, itemAddr, emptyShape,
return fir::EmboxOp::create(*this, loc, boxTy, itemAddr, emptyShape,
emptySlice, lenParams);
},
[&](const fir::MutableBoxValue &x) -> mlir::Value {
return create<fir::LoadOp>(
loc, fir::factory::getMutableIRBox(*this, loc, x));
return fir::LoadOp::create(
*this, loc, fir::factory::getMutableIRBox(*this, loc, x));
},
[&](const fir::PolymorphicValue &p) -> mlir::Value {
mlir::Value empty;
mlir::ValueRange emptyRange;
return create<fir::EmboxOp>(loc, boxTy, itemAddr, empty, empty,
return fir::EmboxOp::create(*this, loc, boxTy, itemAddr, empty, empty,
emptyRange,
isPolymorphic ? p.getSourceBox() : tdesc);
},
[&](const auto &) -> mlir::Value {
mlir::Value empty;
mlir::ValueRange emptyRange;
return create<fir::EmboxOp>(loc, boxTy, itemAddr, empty, empty,
return fir::EmboxOp::create(*this, loc, boxTy, itemAddr, empty, empty,
emptyRange, tdesc);
});
}
@ -810,8 +813,8 @@ mlir::Value fir::FirOpBuilder::createBox(mlir::Location loc, mlir::Type boxType,
llvm::ArrayRef<mlir::Value> lengths,
mlir::Value tdesc) {
mlir::Type valueOrSequenceType = fir::unwrapPassByRefType(boxType);
return create<fir::EmboxOp>(
loc, boxType, addr, shape, slice,
return fir::EmboxOp::create(
*this, loc, boxType, addr, shape, slice,
fir::factory::elideLengthsAlreadyInType(valueOrSequenceType, lengths),
tdesc);
}
@ -860,11 +863,12 @@ mlir::Value fir::FirOpBuilder::genExtentFromTriplet(mlir::Location loc,
mlir::Value fir::FirOpBuilder::genAbsentOp(mlir::Location loc,
mlir::Type argTy) {
if (!fir::isCharacterProcedureTuple(argTy))
return create<fir::AbsentOp>(loc, argTy);
return fir::AbsentOp::create(*this, loc, argTy);
auto boxProc =
create<fir::AbsentOp>(loc, mlir::cast<mlir::TupleType>(argTy).getType(0));
mlir::Value charLen = create<fir::UndefOp>(loc, getCharacterLengthType());
auto boxProc = fir::AbsentOp::create(
*this, loc, mlir::cast<mlir::TupleType>(argTy).getType(0));
mlir::Value charLen =
fir::UndefOp::create(*this, loc, getCharacterLengthType());
return fir::factory::createCharacterProcedureTuple(*this, loc, argTy, boxProc,
charLen);
}
@ -972,9 +976,8 @@ mlir::Value fir::factory::readExtent(fir::FirOpBuilder &builder,
return x.getExplicitExtents()[dim];
auto idxTy = builder.getIndexType();
auto dimVal = builder.createIntegerConstant(loc, idxTy, dim);
return builder
.create<fir::BoxDimsOp>(loc, idxTy, idxTy, idxTy, x.getAddr(),
dimVal)
return fir::BoxDimsOp::create(builder, loc, idxTy, idxTy, idxTy,
x.getAddr(), dimVal)
.getResult(1);
},
[&](const fir::MutableBoxValue &x) -> mlir::Value {

View File

@ -2402,7 +2402,7 @@ mlir::func::FuncOp IntrinsicLibrary::getWrapper(GeneratorType generator,
for (mlir::BlockArgument bArg : function.front().getArguments()) {
auto refType = mlir::dyn_cast<fir::ReferenceType>(bArg.getType());
if (loadRefArguments && refType) {
auto loaded = localBuilder->create<fir::LoadOp>(localLoc, bArg);
auto loaded = fir::LoadOp::create(*localBuilder, localLoc, bArg);
localArguments.push_back(loaded);
} else {
localArguments.push_back(bArg);
@ -3480,9 +3480,9 @@ void IntrinsicLibrary::genCFPointer(llvm::ArrayRef<fir::ExtendedValue> args) {
fir::unwrapSequenceType(fir::unwrapPassByRefType(lower.getType()));
for (int i = 0; i < arrayRank; ++i) {
mlir::Value index = builder.createIntegerConstant(loc, idxType, i);
mlir::Value var = builder.create<fir::CoordinateOp>(
loc, builder.getRefType(lowerElementType), lower, index);
mlir::Value load = builder.create<fir::LoadOp>(loc, var);
mlir::Value var = fir::CoordinateOp::create(
builder, loc, builder.getRefType(lowerElementType), lower, index);
mlir::Value load = fir::LoadOp::create(builder, loc, var);
lbounds.push_back(builder.createConvert(loc, idxType, load));
}
}

View File

@ -174,9 +174,8 @@ mlir::Value fir::runtime::genMalloc(fir::FirOpBuilder &builder,
auto runtimeFunc =
fir::runtime::getRuntimeFunc<mkRTKey(Malloc)>(loc, builder);
auto argTy = runtimeFunc.getArgumentTypes()[0];
return builder
.create<fir::CallOp>(loc, runtimeFunc,
builder.createConvert(loc, argTy, size))
return fir::CallOp::create(builder, loc, runtimeFunc,
builder.createConvert(loc, argTy, size))
.getResult(0);
}

View File

@ -178,13 +178,13 @@ public:
if (!savedStackPtr)
savedStackPtr = genStackSave(loc);
mlir::Value stack =
rewriter->create<fir::AllocaOp>(loc, fir::dyn_cast_ptrEleTy(resTy));
fir::AllocaOp::create(*rewriter, loc, fir::dyn_cast_ptrEleTy(resTy));
newInTyAndAttrs.push_back(m[0]);
newOpers.push_back(stack);
return [=](mlir::Operation *) -> mlir::Value {
auto memTy = fir::ReferenceType::get(originalResTy);
auto cast = rewriter->create<fir::ConvertOp>(loc, memTy, stack);
return rewriter->create<fir::LoadOp>(loc, cast);
auto cast = fir::ConvertOp::create(*rewriter, loc, memTy, stack);
return fir::LoadOp::create(*rewriter, loc, cast);
};
}
newResTys.push_back(resTy);
@ -238,10 +238,10 @@ public:
if (!savedStackPtr)
savedStackPtr = genStackSave(loc);
if (attr.isByVal()) {
mlir::Value mem = rewriter->create<fir::AllocaOp>(loc, oldType);
rewriter->create<fir::StoreOp>(loc, oper, mem);
mlir::Value mem = fir::AllocaOp::create(*rewriter, loc, oldType);
fir::StoreOp::create(*rewriter, loc, oper, mem);
if (mem.getType() != resTy)
mem = rewriter->create<fir::ConvertOp>(loc, resTy, mem);
mem = fir::ConvertOp::create(*rewriter, loc, resTy, mem);
newOpers.push_back(mem);
} else {
mlir::Value bitcast =
@ -261,16 +261,16 @@ public:
mlir::Type newType, bool inputMayBeBigger) {
if (inputMayBeBigger) {
auto newRefTy = fir::ReferenceType::get(newType);
auto mem = rewriter->create<fir::AllocaOp>(loc, value.getType());
rewriter->create<fir::StoreOp>(loc, value, mem);
auto cast = rewriter->create<fir::ConvertOp>(loc, newRefTy, mem);
return rewriter->create<fir::LoadOp>(loc, cast);
auto mem = fir::AllocaOp::create(*rewriter, loc, value.getType());
fir::StoreOp::create(*rewriter, loc, value, mem);
auto cast = fir::ConvertOp::create(*rewriter, loc, newRefTy, mem);
return fir::LoadOp::create(*rewriter, loc, cast);
} else {
auto oldRefTy = fir::ReferenceType::get(value.getType());
auto mem = rewriter->create<fir::AllocaOp>(loc, newType);
auto cast = rewriter->create<fir::ConvertOp>(loc, oldRefTy, mem);
rewriter->create<fir::StoreOp>(loc, value, cast);
return rewriter->create<fir::LoadOp>(loc, mem);
auto mem = fir::AllocaOp::create(*rewriter, loc, newType);
auto cast = fir::ConvertOp::create(*rewriter, loc, oldRefTy, mem);
fir::StoreOp::create(*rewriter, loc, value, cast);
return fir::LoadOp::create(*rewriter, loc, mem);
}
}
@ -299,8 +299,8 @@ public:
auto ty = std::get<mlir::Type>(tup);
auto index = e.index();
auto idx = rewriter->getIntegerAttr(iTy, index);
auto val = rewriter->create<fir::ExtractValueOp>(
loc, ty, oper, rewriter->getArrayAttr(idx));
auto val = fir::ExtractValueOp::create(*rewriter, loc, ty, oper,
rewriter->getArrayAttr(idx));
newOpers.push_back(val);
}
}
@ -437,9 +437,9 @@ public:
TODO(loc, "ABI of fir.dispatch with character arguments");
}
auto m = specifics->boxcharArgumentType(boxTy.getEleTy());
auto unbox = rewriter->create<fir::UnboxCharOp>(
loc, std::get<mlir::Type>(m[0]), std::get<mlir::Type>(m[1]),
oper);
auto unbox = fir::UnboxCharOp::create(
*rewriter, loc, std::get<mlir::Type>(m[0]),
std::get<mlir::Type>(m[1]), oper);
// unboxed CHARACTER arguments
for (auto e : llvm::enumerate(m)) {
unsigned idx = e.index();
@ -539,13 +539,13 @@ public:
} else if constexpr (std::is_same_v<std::decay_t<A>, fir::CallOp>) {
fir::CallOp newCall;
if (callOp.getCallee()) {
newCall = rewriter->create<fir::CallOp>(loc, *callOp.getCallee(),
newResTys, newOpers);
newCall = fir::CallOp::create(*rewriter, loc, *callOp.getCallee(),
newResTys, newOpers);
} else {
newOpers[0].setType(mlir::FunctionType::get(
callOp.getContext(),
mlir::TypeRange{newInTypes}.drop_front(dropFront), newResTys));
newCall = rewriter->create<fir::CallOp>(loc, newResTys, newOpers);
newCall = fir::CallOp::create(*rewriter, loc, newResTys, newOpers);
}
newCall.setFastmathAttr(callOp.getFastmathAttr());
// Always set ABI argument attributes on call operations, even when
@ -754,8 +754,8 @@ public:
trailingInTys.end());
// replace this op with a new one with the updated signature
auto newTy = rewriter->getFunctionType(newInTypes, newResTys);
auto newOp = rewriter->create<fir::AddrOfOp>(addrOp.getLoc(), newTy,
addrOp.getSymbol());
auto newOp = fir::AddrOfOp::create(*rewriter, addrOp.getLoc(), newTy,
addrOp.getSymbol());
replaceOp(addrOp, newOp.getResult());
}
@ -1002,8 +1002,8 @@ public:
rewriter->setInsertionPointToStart(&func.front());
auto oldArgTy =
fir::ReferenceType::get(oldArgTys[fixup.index - offset]);
auto cast = rewriter->create<fir::ConvertOp>(loc, oldArgTy, newArg);
auto load = rewriter->create<fir::LoadOp>(loc, cast);
auto cast = fir::ConvertOp::create(*rewriter, loc, oldArgTy, newArg);
auto load = fir::LoadOp::create(*rewriter, loc, cast);
func.getArgument(fixup.index + 1).replaceAllUsesWith(load);
func.front().eraseArgument(fixup.index + 1);
} break;
@ -1035,8 +1035,9 @@ public:
if (fixup.second == 1) {
rewriter->setInsertionPointToStart(&func.front());
auto boxTy = oldArgTys[fixup.index - offset - fixup.second];
auto box = rewriter->create<fir::EmboxCharOp>(
loc, boxTy, func.front().getArgument(fixup.index - 1), newArg);
auto box = fir::EmboxCharOp::create(
*rewriter, loc, boxTy,
func.front().getArgument(fixup.index - 1), newArg);
func.getArgument(fixup.index + 1).replaceAllUsesWith(box);
func.front().eraseArgument(fixup.index + 1);
offset++;
@ -1053,8 +1054,8 @@ public:
auto oldOper = ret.getOperand(0);
auto oldOperTy = fir::ReferenceType::get(oldOper.getType());
auto cast =
rewriter->create<fir::ConvertOp>(loc, oldOperTy, newArg);
rewriter->create<fir::StoreOp>(loc, oldOper, cast);
fir::ConvertOp::create(*rewriter, loc, oldOperTy, newArg);
fir::StoreOp::create(*rewriter, loc, oldOper, cast);
rewriter->create<ReturnOpTy>(loc);
ret.erase();
});
@ -1089,14 +1090,16 @@ public:
originalTy.getContext(),
mlir::TypeRange{firstArg.getType(), newArg.getType()});
}
auto undef = rewriter->create<fir::UndefOp>(loc, pairTy);
auto undef = fir::UndefOp::create(*rewriter, loc, pairTy);
auto iTy = rewriter->getIntegerType(32);
auto zero = rewriter->getIntegerAttr(iTy, 0);
auto one = rewriter->getIntegerAttr(iTy, 1);
mlir::Value pair1 = rewriter->create<fir::InsertValueOp>(
loc, pairTy, undef, firstArg, rewriter->getArrayAttr(zero));
mlir::Value pair = rewriter->create<fir::InsertValueOp>(
loc, pairTy, pair1, newArg, rewriter->getArrayAttr(one));
mlir::Value pair1 = fir::InsertValueOp::create(
*rewriter, loc, pairTy, undef, firstArg,
rewriter->getArrayAttr(zero));
mlir::Value pair =
fir::InsertValueOp::create(*rewriter, loc, pairTy, pair1,
newArg, rewriter->getArrayAttr(one));
// Cast local argument tuple to original type via memory if needed.
if (pairTy != originalTy)
pair = convertValueInMemory(loc, pair, originalTy,
@ -1117,8 +1120,8 @@ public:
func.front().addArgument(trailingTys[fixup.second], loc);
auto boxTy = oldArgTys[fixup.index - offset];
rewriter->setInsertionPointToStart(&func.front());
auto box = rewriter->create<fir::EmboxCharOp>(loc, boxTy, newBufArg,
newLenArg);
auto box = fir::EmboxCharOp::create(*rewriter, loc, boxTy, newBufArg,
newLenArg);
func.getArgument(fixup.index + 1).replaceAllUsesWith(box);
func.front().eraseArgument(fixup.index + 1);
} break;

View File

@ -447,9 +447,8 @@ llvm::LogicalResult SelectTypeConv::genTypeLadderStep(
rewriter.getI1Type()),
{runtimeAttr});
}
cmp = rewriter
.create<fir::CallOp>(loc, callee,
mlir::ValueRange{descSelector, typeDesc})
cmp = fir::CallOp::create(rewriter, loc, callee,
mlir::ValueRange{descSelector, typeDesc})
.getResult(0);
}