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
2 changes: 1 addition & 1 deletion flang/lib/Lower/Bridge.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1766,7 +1766,7 @@ class FirConverter : public Fortran::lower::AbstractConverter {
// to a crash due to a block with no terminator. See issue #126452.
mlir::FunctionType funcType = builder->getFunction().getFunctionType();
mlir::Type resultType = funcType.getResult(0);
mlir::Value undefResult = builder->create<fir::UndefOp>(loc, resultType);
mlir::Value undefResult = fir::UndefOp::create(*builder, loc, resultType);
genExitRoutine(false, undefResult);
return;
}
Expand Down
55 changes: 28 additions & 27 deletions flang/lib/Lower/OpenMP/OpenMP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2059,37 +2059,38 @@ static void genCanonicalLoopNest(
// Start lowering
mlir::Value zero = firOpBuilder.createIntegerConstant(loc, loopVarType, 0);
mlir::Value one = firOpBuilder.createIntegerConstant(loc, loopVarType, 1);
mlir::Value isDownwards = firOpBuilder.create<mlir::arith::CmpIOp>(
loc, mlir::arith::CmpIPredicate::slt, loopStepVar, zero);
mlir::Value isDownwards = mlir::arith::CmpIOp::create(
firOpBuilder, loc, mlir::arith::CmpIPredicate::slt, loopStepVar, zero);

// Ensure we are counting upwards. If not, negate step and swap lb and ub.
mlir::Value negStep =
firOpBuilder.create<mlir::arith::SubIOp>(loc, zero, loopStepVar);
mlir::Value incr = firOpBuilder.create<mlir::arith::SelectOp>(
loc, isDownwards, negStep, loopStepVar);
mlir::Value lb = firOpBuilder.create<mlir::arith::SelectOp>(
loc, isDownwards, loopUBVar, loopLBVar);
mlir::Value ub = firOpBuilder.create<mlir::arith::SelectOp>(
loc, isDownwards, loopLBVar, loopUBVar);
mlir::arith::SubIOp::create(firOpBuilder, loc, zero, loopStepVar);
mlir::Value incr = mlir::arith::SelectOp::create(
firOpBuilder, loc, isDownwards, negStep, loopStepVar);
mlir::Value lb = mlir::arith::SelectOp::create(
firOpBuilder, loc, isDownwards, loopUBVar, loopLBVar);
mlir::Value ub = mlir::arith::SelectOp::create(
firOpBuilder, loc, isDownwards, loopLBVar, loopUBVar);

// Compute the trip count assuming lb <= ub. This guarantees that the result
// is non-negative and we can use unsigned arithmetic.
mlir::Value span = firOpBuilder.create<mlir::arith::SubIOp>(
loc, ub, lb, ::mlir::arith::IntegerOverflowFlags::nuw);
mlir::Value span = mlir::arith::SubIOp::create(
firOpBuilder, loc, ub, lb, ::mlir::arith::IntegerOverflowFlags::nuw);
mlir::Value tcMinusOne =
firOpBuilder.create<mlir::arith::DivUIOp>(loc, span, incr);
mlir::Value tcIfLooping = firOpBuilder.create<mlir::arith::AddIOp>(
loc, tcMinusOne, one, ::mlir::arith::IntegerOverflowFlags::nuw);
mlir::arith::DivUIOp::create(firOpBuilder, loc, span, incr);
mlir::Value tcIfLooping =
mlir::arith::AddIOp::create(firOpBuilder, loc, tcMinusOne, one,
::mlir::arith::IntegerOverflowFlags::nuw);

// Fall back to 0 if lb > ub
mlir::Value isZeroTC = firOpBuilder.create<mlir::arith::CmpIOp>(
loc, mlir::arith::CmpIPredicate::slt, ub, lb);
mlir::Value tripcount = firOpBuilder.create<mlir::arith::SelectOp>(
loc, isZeroTC, zero, tcIfLooping);
mlir::Value isZeroTC = mlir::arith::CmpIOp::create(
firOpBuilder, loc, mlir::arith::CmpIPredicate::slt, ub, lb);
mlir::Value tripcount = mlir::arith::SelectOp::create(
firOpBuilder, loc, isZeroTC, zero, tcIfLooping);
tripcounts.push_back(tripcount);

// Create the CLI handle.
auto newcli = firOpBuilder.create<mlir::omp::NewCliOp>(loc);
auto newcli = mlir::omp::NewCliOp::create(firOpBuilder, loc);
mlir::Value cli = newcli.getResult();
clis.push_back(cli);

Expand Down Expand Up @@ -2122,10 +2123,10 @@ static void genCanonicalLoopNest(
"Expecting all block args to have been collected by now");
for (auto j : llvm::seq<size_t>(numLoops)) {
mlir::Value natIterNum = fir::getBase(blockArgs[j]);
mlir::Value scaled = firOpBuilder.create<mlir::arith::MulIOp>(
loc, natIterNum, loopStepVars[j]);
mlir::Value userVal = firOpBuilder.create<mlir::arith::AddIOp>(
loc, loopLBVars[j], scaled);
mlir::Value scaled = mlir::arith::MulIOp::create(
firOpBuilder, loc, natIterNum, loopStepVars[j]);
mlir::Value userVal = mlir::arith::AddIOp::create(
firOpBuilder, loc, loopLBVars[j], scaled);

mlir::OpBuilder::InsertPoint insPt =
firOpBuilder.saveInsertionPoint();
Expand Down Expand Up @@ -2198,9 +2199,9 @@ static void genTileOp(Fortran::lower::AbstractConverter &converter,
gridGeneratees.reserve(numLoops);
intratileGeneratees.reserve(numLoops);
for ([[maybe_unused]] auto i : llvm::seq<int>(0, sizesClause.sizes.size())) {
auto gridCLI = firOpBuilder.create<mlir::omp::NewCliOp>(loc);
auto gridCLI = mlir::omp::NewCliOp::create(firOpBuilder, loc);
gridGeneratees.push_back(gridCLI.getResult());
auto intratileCLI = firOpBuilder.create<mlir::omp::NewCliOp>(loc);
auto intratileCLI = mlir::omp::NewCliOp::create(firOpBuilder, loc);
intratileGeneratees.push_back(intratileCLI.getResult());
}

Expand All @@ -2209,8 +2210,8 @@ static void genTileOp(Fortran::lower::AbstractConverter &converter,
generatees.append(gridGeneratees);
generatees.append(intratileGeneratees);

firOpBuilder.create<mlir::omp::TileOp>(loc, generatees, applyees,
sizesClause.sizes);
mlir::omp::TileOp::create(firOpBuilder, loc, generatees, applyees,
sizesClause.sizes);
}

static void genUnrollOp(Fortran::lower::AbstractConverter &converter,
Expand Down
2 changes: 1 addition & 1 deletion flang/lib/Optimizer/CodeGen/CodeGen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1151,7 +1151,7 @@ struct AllocMemOpConversion : public fir::FIROpConversion<fir::AllocMemOp> {
mlir::Value size = genTypeSizeInBytes(loc, ity, rewriter, llvmObjectTy);
if (auto scaleSize =
fir::genAllocationScaleSize(loc, heap.getInType(), ity, rewriter))
size = rewriter.create<mlir::LLVM::MulOp>(loc, ity, size, scaleSize);
size = mlir::LLVM::MulOp::create(rewriter, loc, ity, size, scaleSize);
for (mlir::Value opnd : adaptor.getOperands())
size = mlir::LLVM::MulOp::create(rewriter, loc, ity, size,
integerCast(loc, rewriter, ity, opnd));
Expand Down
7 changes: 4 additions & 3 deletions flang/lib/Optimizer/CodeGen/CodeGenOpenMP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -242,10 +242,11 @@ struct TargetAllocMemOpConversion
loc, llvmObjectTy, ity, rewriter, lowerTy().getDataLayout());
if (auto scaleSize = fir::genAllocationScaleSize(
loc, allocmemOp.getInType(), ity, rewriter))
size = rewriter.create<mlir::LLVM::MulOp>(loc, ity, size, scaleSize);
size = mlir::LLVM::MulOp::create(rewriter, loc, ity, size, scaleSize);
for (mlir::Value opnd : adaptor.getOperands().drop_front())
size = rewriter.create<mlir::LLVM::MulOp>(
loc, ity, size, integerCast(lowerTy(), loc, rewriter, ity, opnd));
size = mlir::LLVM::MulOp::create(
rewriter, loc, ity, size,
integerCast(lowerTy(), loc, rewriter, ity, opnd));
auto mallocTyWidth = lowerTy().getIndexTypeBitwidth();
auto mallocTy =
mlir::IntegerType::get(rewriter.getContext(), mallocTyWidth);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,13 @@ class BufferizeInterface {

static mlir::Operation *load(mlir::OpBuilder &builder, mlir::Location loc,
mlir::Value value) {
return builder.create<fir::LoadOp>(loc, value);
return fir::LoadOp::create(builder, loc, value);
}

static mlir::Value placeInMemory(mlir::OpBuilder &builder, mlir::Location loc,
mlir::Value value) {
auto alloca = builder.create<fir::AllocaOp>(loc, value.getType());
builder.create<fir::StoreOp>(loc, value, alloca);
auto alloca = fir::AllocaOp::create(builder, loc, value.getType());
fir::StoreOp::create(builder, loc, value, alloca);
return alloca;
}
};
Expand Down
4 changes: 2 additions & 2 deletions flang/lib/Optimizer/OpenMP/AutomapToTargetData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,8 @@ class AutomapToTargetDataPass
builder.getBoolAttr(false));
clauses.mapVars.push_back(mapInfo);
isa<fir::StoreOp>(memOp)
? builder.create<omp::TargetEnterDataOp>(memOp.getLoc(), clauses)
: builder.create<omp::TargetExitDataOp>(memOp.getLoc(), clauses);
? omp::TargetEnterDataOp::create(builder, memOp.getLoc(), clauses)
: omp::TargetExitDataOp::create(builder, memOp.getLoc(), clauses);
};

for (fir::GlobalOp globalOp : automapGlobals) {
Expand Down
22 changes: 11 additions & 11 deletions flang/lib/Optimizer/OpenMP/DoConcurrentConversion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -595,7 +595,7 @@ class DoConcurrentConversion
mlir::omp::TargetOperands &clauseOps,
mlir::omp::LoopNestOperands &loopNestClauseOps,
const LiveInShapeInfoMap &liveInShapeInfoMap) const {
auto targetOp = rewriter.create<mlir::omp::TargetOp>(loc, clauseOps);
auto targetOp = mlir::omp::TargetOp::create(rewriter, loc, clauseOps);
auto argIface = llvm::cast<mlir::omp::BlockArgOpenMPOpInterface>(*targetOp);

mlir::Region &region = targetOp.getRegion();
Expand Down Expand Up @@ -672,7 +672,7 @@ class DoConcurrentConversion
// temporary.
Fortran::utils::openmp::cloneOrMapRegionOutsiders(builder, targetOp);
rewriter.setInsertionPoint(
rewriter.create<mlir::omp::TerminatorOp>(targetOp.getLoc()));
mlir::omp::TerminatorOp::create(rewriter, targetOp.getLoc()));

return targetOp;
}
Expand Down Expand Up @@ -715,8 +715,8 @@ class DoConcurrentConversion

auto shapeShiftType = fir::ShapeShiftType::get(
builder.getContext(), shapeShiftOperands.size() / 2);
return builder.create<fir::ShapeShiftOp>(
liveInArg.getLoc(), shapeShiftType, shapeShiftOperands);
return fir::ShapeShiftOp::create(builder, liveInArg.getLoc(),
shapeShiftType, shapeShiftOperands);
}

llvm::SmallVector<mlir::Value> shapeOperands;
Expand All @@ -728,11 +728,11 @@ class DoConcurrentConversion
++shapeIdx;
}

return builder.create<fir::ShapeOp>(liveInArg.getLoc(), shapeOperands);
return fir::ShapeOp::create(builder, liveInArg.getLoc(), shapeOperands);
}();

return builder.create<hlfir::DeclareOp>(liveInArg.getLoc(), liveInArg,
liveInName, shape);
return hlfir::DeclareOp::create(builder, liveInArg.getLoc(), liveInArg,
liveInName, shape);
}

mlir::omp::TeamsOp genTeamsOp(mlir::ConversionPatternRewriter &rewriter,
Expand All @@ -742,13 +742,13 @@ class DoConcurrentConversion
genReductions(rewriter, mapper, loop, teamsOps);

mlir::Location loc = loop.getLoc();
auto teamsOp = rewriter.create<mlir::omp::TeamsOp>(loc, teamsOps);
auto teamsOp = mlir::omp::TeamsOp::create(rewriter, loc, teamsOps);
Fortran::common::openmp::EntryBlockArgs teamsArgs;
teamsArgs.reduction.vars = teamsOps.reductionVars;
Fortran::common::openmp::genEntryBlock(rewriter, teamsArgs,
teamsOp.getRegion());

rewriter.setInsertionPoint(rewriter.create<mlir::omp::TerminatorOp>(loc));
rewriter.setInsertionPoint(mlir::omp::TerminatorOp::create(rewriter, loc));

for (auto [loopVar, teamsArg] : llvm::zip_equal(
loop.getReduceVars(), teamsOp.getRegion().getArguments())) {
Expand All @@ -761,8 +761,8 @@ class DoConcurrentConversion
mlir::omp::DistributeOp
genDistributeOp(mlir::Location loc,
mlir::ConversionPatternRewriter &rewriter) const {
auto distOp = rewriter.create<mlir::omp::DistributeOp>(
loc, /*clauses=*/mlir::omp::DistributeOperands{});
auto distOp = mlir::omp::DistributeOp::create(
rewriter, loc, /*clauses=*/mlir::omp::DistributeOperands{});

rewriter.createBlock(&distOp.getRegion());
return distOp;
Expand Down
Loading