Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 14 additions & 14 deletions flang/lib/Lower/Bridge.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1316,7 +1316,7 @@ class FirConverter : public Fortran::lower::AbstractConverter {
auto copyData = [&](hlfir::Entity l, hlfir::Entity r) {
// Dereference RHS and load it if trivial scalar.
r = hlfir::loadTrivialScalar(loc, *builder, r);
builder->create<hlfir::AssignOp>(loc, r, l, isAllocatable);
hlfir::AssignOp::create(*builder, loc, r, l, isAllocatable);
};

if (isPointer) {
Expand Down Expand Up @@ -3057,11 +3057,11 @@ class FirConverter : public Fortran::lower::AbstractConverter {
exprVal = builder->createConvert(loc, builder->getI1Type(), exprVal);
if (innerInsertionPoint.isSet())
builder->restoreInsertionPoint(innerInsertionPoint);
builder->create<hlfir::YieldOp>(loc, exprVal);
hlfir::YieldOp::create(*builder, loc, exprVal);
};
for (const Fortran::parser::ConcurrentControl &control :
std::get<std::list<Fortran::parser::ConcurrentControl>>(header.t)) {
auto forallOp = builder->create<hlfir::ForallOp>(loc);
auto forallOp = hlfir::ForallOp::create(*builder, loc);
if (isOutterForall && !outerForall)
outerForall = forallOp;
evaluateControl(std::get<1>(control.t), forallOp.getLbRegion());
Expand All @@ -3078,8 +3078,8 @@ class FirConverter : public Fortran::lower::AbstractConverter {
mlir::Type controlVarType = genType(*controlVar);
mlir::Block *forallBody = builder->createBlock(&forallOp.getBody(), {},
{controlVarType}, {loc});
auto forallIndex = builder->create<hlfir::ForallIndexOp>(
loc, fir::ReferenceType::get(controlVarType),
auto forallIndex = hlfir::ForallIndexOp::create(
*builder, loc, fir::ReferenceType::get(controlVarType),
forallBody->getArguments()[0],
builder->getStringAttr(controlVar->name().ToString()));
localSymbols.addVariableDefinition(*controlVar, forallIndex,
Expand All @@ -3092,7 +3092,7 @@ class FirConverter : public Fortran::lower::AbstractConverter {
std::get<std::optional<Fortran::parser::ScalarLogicalExpr>>(
header.t)) {
// Create hlfir.forall_mask and set insertion point in its body.
auto forallMaskOp = builder->create<hlfir::ForallMaskOp>(loc);
auto forallMaskOp = hlfir::ForallMaskOp::create(*builder, loc);
evaluateControl(*maskExpr, forallMaskOp.getMaskRegion(), /*isMask=*/true);
builder->createBlock(&forallMaskOp.getBody());
auto end = fir::FirEndOp::create(*builder, loc);
Expand Down Expand Up @@ -4573,14 +4573,14 @@ class FirConverter : public Fortran::lower::AbstractConverter {
// descriptor address/value and later implemented with a store.
// The RHS is fully prepared in lowering, so that all that is left
// in hlfir.region_assign code generation is the store.
auto regionAssignOp = builder->create<hlfir::RegionAssignOp>(loc);
auto regionAssignOp = hlfir::RegionAssignOp::create(*builder, loc);

// Lower LHS in its own region.
builder->createBlock(&regionAssignOp.getLhsRegion());
Fortran::lower::StatementContext lhsContext;
hlfir::Entity lhs = Fortran::lower::convertExprToHLFIR(
loc, *this, assign.lhs, localSymbols, 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);

Expand All @@ -4589,7 +4589,7 @@ class FirConverter : public Fortran::lower::AbstractConverter {
Fortran::lower::StatementContext rhsContext;
mlir::Value rhs =
genForallPointerAssignmentRhs(loc, lhs, assign, 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);

Expand Down Expand Up @@ -5360,7 +5360,7 @@ class FirConverter : public Fortran::lower::AbstractConverter {
if (!lowerToHighLevelFIR()) {
implicitIterSpace.growStack();
} else {
whereOp = builder->create<hlfir::WhereOp>(loc);
whereOp = hlfir::WhereOp::create(*builder, loc);
builder->createBlock(&whereOp.getMaskRegion());
}

Expand Down Expand Up @@ -5422,7 +5422,7 @@ class FirConverter : public Fortran::lower::AbstractConverter {
hlfir::Entity mask = Fortran::lower::convertExprToHLFIR(
loc, *this, *maskExpr, localSymbols, maskContext);
mask = hlfir::loadTrivialScalar(loc, *builder, mask);
auto yieldOp = builder->create<hlfir::YieldOp>(loc, mask);
auto yieldOp = hlfir::YieldOp::create(*builder, loc, mask);
Fortran::lower::genCleanUpInRegionIfAny(loc, *builder, yieldOp.getCleanup(),
maskContext);
}
Expand All @@ -5438,7 +5438,7 @@ class FirConverter : public Fortran::lower::AbstractConverter {
mlir::Location loc = getCurrentLocation();
hlfir::ElseWhereOp elsewhereOp;
if (lowerToHighLevelFIR()) {
elsewhereOp = builder->create<hlfir::ElseWhereOp>(loc);
elsewhereOp = hlfir::ElseWhereOp::create(*builder, loc);
// Lower mask in the mask region.
builder->createBlock(&elsewhereOp.getMaskRegion());
}
Expand Down Expand Up @@ -5466,7 +5466,7 @@ class FirConverter : public Fortran::lower::AbstractConverter {
void genFIR(const Fortran::parser::WhereConstruct::Elsewhere &ew) {
if (lowerToHighLevelFIR()) {
auto elsewhereOp =
builder->create<hlfir::ElseWhereOp>(getCurrentLocation());
hlfir::ElseWhereOp::create(*builder, getCurrentLocation());
builder->createBlock(&elsewhereOp.getBody());
}
genNestedStatement(
Expand All @@ -5492,7 +5492,7 @@ class FirConverter : public Fortran::lower::AbstractConverter {
std::get<Fortran::parser::LogicalExpr>(stmt.t));
if (lowerToHighLevelFIR()) {
mlir::Location loc = getCurrentLocation();
auto whereOp = builder->create<hlfir::WhereOp>(loc);
auto whereOp = hlfir::WhereOp::create(*builder, loc);
builder->createBlock(&whereOp.getMaskRegion());
lowerWhereMaskToHlfir(loc, mask);
builder->createBlock(&whereOp.getBody());
Expand Down
2 changes: 1 addition & 1 deletion flang/lib/Lower/ConvertArrayConstructor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -795,7 +795,7 @@ hlfir::EntityWithAttributes Fortran::lower::ArrayConstructorBuilder<T>::gen(
// Insert the clean-up for the created hlfir.expr.
fir::FirOpBuilder *bldr = &builder;
stmtCtx.attachCleanup(
[=]() { bldr->create<hlfir::DestroyOp>(loc, hlfirExpr); });
[=]() { hlfir::DestroyOp::create(*bldr, loc, hlfirExpr); });
return hlfir::EntityWithAttributes{hlfirExpr};
}

Expand Down
13 changes: 7 additions & 6 deletions flang/lib/Lower/ConvertCall.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -702,8 +702,8 @@ Fortran::lower::genCallOpAndResult(
fir::FirOpBuilder *bldr = &converter.getFirOpBuilder();
if (!isElemental)
stmtCtx.attachCleanup([bldr, loc, expr, mustFinalizeResult]() {
bldr->create<hlfir::DestroyOp>(loc, expr,
/*finalize=*/mustFinalizeResult);
hlfir::DestroyOp::create(*bldr, loc, expr,
/*finalize=*/mustFinalizeResult);
});
return {LoweredResult{hlfir::EntityWithAttributes{expr}},
mustFinalizeResult};
Expand Down Expand Up @@ -2244,8 +2244,9 @@ class ElementalCallBuilder {
if (hlfir::AssociateOp associate =
preparedActual->associateIfArrayExpr(loc, builder)) {
fir::FirOpBuilder *bldr = &builder;
callContext.stmtCtx.attachCleanup(
[=]() { bldr->create<hlfir::EndAssociateOp>(loc, associate); });
callContext.stmtCtx.attachCleanup([=]() {
hlfir::EndAssociateOp::create(*bldr, loc, associate);
});
}
}
}
Expand Down Expand Up @@ -2314,7 +2315,7 @@ class ElementalCallBuilder {
bool mustFinalizeExpr = impl().resultMayRequireFinalization(callContext);
fir::FirOpBuilder *bldr = &builder;
callContext.stmtCtx.attachCleanup([=]() {
bldr->create<hlfir::DestroyOp>(loc, elemental, mustFinalizeExpr);
hlfir::DestroyOp::create(*bldr, loc, elemental, mustFinalizeExpr);
});
return hlfir::EntityWithAttributes{elemental};
}
Expand Down Expand Up @@ -2739,7 +2740,7 @@ genIntrinsicRef(const Fortran::evaluate::SpecificIntrinsic *intrinsic,
if (result && mlir::isa<hlfir::ExprType>(result->getType())) {
fir::FirOpBuilder *bldr = &callContext.getBuilder();
callContext.stmtCtx.attachCleanup(
[=]() { bldr->create<hlfir::DestroyOp>(loc, *result); });
[=]() { hlfir::DestroyOp::create(*bldr, loc, *result); });
}
return result;
}
Expand Down
8 changes: 4 additions & 4 deletions flang/lib/Lower/ConvertExprToHLFIR.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -911,7 +911,7 @@ class HlfirDesignatorBuilder {
setVectorSubscriptElementAddrOp(std::nullopt);
fir::FirOpBuilder *bldr = &builder;
getStmtCtx().attachCleanup(
[=]() { bldr->create<hlfir::DestroyOp>(loc, elemental); });
[=]() { hlfir::DestroyOp::create(*bldr, loc, elemental); });
return hlfir::EntityWithAttributes{elemental};
}

Expand Down Expand Up @@ -1579,7 +1579,7 @@ class HlfirBuilder {
}

hlfir::EntityWithAttributes gen(const Fortran::evaluate::NullPointer &expr) {
auto nullop = getBuilder().create<hlfir::NullOp>(getLoc());
auto nullop = hlfir::NullOp::create(getBuilder(), getLoc());
return mlir::cast<fir::FortranVariableOpInterface>(nullop.getOperation());
}

Expand Down Expand Up @@ -1685,7 +1685,7 @@ class HlfirBuilder {
/*isUnordered=*/true, left.isPolymorphic() ? left : mlir::Value{});
fir::FirOpBuilder *bldr = &builder;
getStmtCtx().attachCleanup(
[=]() { bldr->create<hlfir::DestroyOp>(loc, elemental); });
[=]() { hlfir::DestroyOp::create(*bldr, loc, elemental); });
return hlfir::EntityWithAttributes{elemental};
}

Expand Down Expand Up @@ -1736,7 +1736,7 @@ class HlfirBuilder {
builder.setIntegerOverflowFlags(iofBackup);
fir::FirOpBuilder *bldr = &builder;
getStmtCtx().attachCleanup(
[=]() { bldr->create<hlfir::DestroyOp>(loc, elemental); });
[=]() { hlfir::DestroyOp::create(*bldr, loc, elemental); });
return hlfir::EntityWithAttributes{elemental};
}

Expand Down
8 changes: 4 additions & 4 deletions flang/lib/Optimizer/Builder/HLFIRTools.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1222,7 +1222,7 @@ hlfir::translateToExtendedValue(mlir::Location loc, fir::FirOpBuilder &builder,
loc, builder, entity, entity.getType(), "", byRefAttr);
auto *bldr = &builder;
hlfir::CleanupFunction cleanup = [bldr, loc, associate]() -> void {
bldr->create<hlfir::EndAssociateOp>(loc, associate);
hlfir::EndAssociateOp::create(*bldr, loc, associate);
};
hlfir::Entity temp{associate.getBase()};
return {translateToExtendedValue(loc, builder, temp).first, cleanup};
Expand Down Expand Up @@ -1502,15 +1502,15 @@ hlfir::genTypeAndKindConvert(mlir::Location loc, fir::FirOpBuilder &builder,
mlir::cast<fir::FortranVariableOpInterface>(declareOp.getOperation());
fir::FirOpBuilder *bldr = &builder;
auto cleanup = [loc, bldr, convertedRhs, associate]() {
bldr->create<hlfir::EndAssociateOp>(loc, associate);
bldr->create<hlfir::DestroyOp>(loc, convertedRhs);
hlfir::EndAssociateOp::create(*bldr, loc, associate);
hlfir::DestroyOp::create(*bldr, loc, convertedRhs);
};
return {castWithLbounds, cleanup};
}

fir::FirOpBuilder *bldr = &builder;
auto cleanup = [loc, bldr, convertedRhs]() {
bldr->create<hlfir::DestroyOp>(loc, convertedRhs);
hlfir::DestroyOp::create(*bldr, loc, convertedRhs);
};
return {hlfir::Entity{convertedRhs}, cleanup};
}
Expand Down
7 changes: 3 additions & 4 deletions flang/lib/Optimizer/Builder/TemporaryStorage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,9 @@ fir::factory::HomogeneousScalarStack::HomogeneousScalarStack(
builder.createTemporary(loc, declaredType, tempName, extents, lengths);

mlir::Value shape = builder.genShape(loc, extents);
temp = builder
.create<hlfir::DeclareOp>(loc, tempStorage, tempName, shape,
lengths, /*dummy_scope=*/nullptr,
fir::FortranVariableFlagsAttr{})
temp = hlfir::DeclareOp::create(builder, loc, tempStorage, tempName, shape,
lengths, /*dummy_scope=*/nullptr,
fir::FortranVariableFlagsAttr{})
.getBase();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -438,15 +438,15 @@ convertToMoldType(mlir::Location loc, fir::FirOpBuilder &builder,
mlir::Value asExpr = hlfir::AsExprOp::create(builder, loc, input);
if (asExpr.getType() != mold.getType())
TODO(loc, "hlfir.expr conversion");
cleanups.emplace_back([=]() { b->create<hlfir::DestroyOp>(loc, asExpr); });
cleanups.emplace_back([=]() { hlfir::DestroyOp::create(*b, loc, asExpr); });
return hlfir::Entity{asExpr};
}
if (input.isValue() && mold.isVariable()) {
// T to fir.ref<T>, or hlfir.expr<T> to fir.ref<T>.
hlfir::AssociateOp associate = hlfir::genAssociateExpr(
loc, builder, input, mold.getFortranElementType(), ".tmp.val2ref");
cleanups.emplace_back(
[=]() { b->create<hlfir::EndAssociateOp>(loc, associate); });
[=]() { hlfir::EndAssociateOp::create(*b, loc, associate); });
return hlfir::Entity{associate.getBase()};
}
// Variable to Variable mismatch (e.g., fir.heap<T> vs fir.ref<T>), or value
Expand Down