Skip to content

Commit 9844ba6

Browse files
authored
[mlir][NFC] update flang/Optimizer/Builder create APIs (9/n) (#149917)
See #147168 for more info.
1 parent 5547c6c commit 9844ba6

File tree

10 files changed

+1308
-1274
lines changed

10 files changed

+1308
-1274
lines changed

flang/lib/Optimizer/Builder/CUFCommon.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ mlir::gpu::GPUModuleOp cuf::getOrCreateGPUModule(mlir::ModuleOp mod,
2525
mlir::UnitAttr::get(ctx));
2626

2727
mlir::OpBuilder builder(ctx);
28-
auto gpuMod = builder.create<mlir::gpu::GPUModuleOp>(mod.getLoc(),
29-
cudaDeviceModuleName);
28+
auto gpuMod = mlir::gpu::GPUModuleOp::create(builder, mod.getLoc(),
29+
cudaDeviceModuleName);
3030
mlir::Block::iterator insertPt(mod.getBodyRegion().front().end());
3131
symTab.insert(gpuMod, insertPt);
3232
return gpuMod;
@@ -84,8 +84,8 @@ void cuf::genPointerSync(const mlir::Value box, fir::FirOpBuilder &builder) {
8484
if (auto globalOp =
8585
mod.lookupSymbol<fir::GlobalOp>(addrOfOp.getSymbol())) {
8686
if (cuf::isRegisteredDeviceGlobal(globalOp)) {
87-
builder.create<cuf::SyncDescriptorOp>(box.getLoc(),
88-
addrOfOp.getSymbol());
87+
cuf::SyncDescriptorOp::create(builder, box.getLoc(),
88+
addrOfOp.getSymbol());
8989
}
9090
}
9191
}

flang/lib/Optimizer/Builder/Character.cpp

Lines changed: 78 additions & 77 deletions
Large diffs are not rendered by default.

flang/lib/Optimizer/Builder/Complex.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ mlir::Type fir::factory::Complex::getComplexPartType(mlir::Value cplx) const {
2424
mlir::Value fir::factory::Complex::createComplex(mlir::Type cplxTy,
2525
mlir::Value real,
2626
mlir::Value imag) {
27-
mlir::Value und = builder.create<fir::UndefOp>(loc, cplxTy);
27+
mlir::Value und = fir::UndefOp::create(builder, loc, cplxTy);
2828
return insert<Part::Imag>(insert<Part::Real>(und, real), imag);
2929
}
3030

flang/lib/Optimizer/Builder/DoLoopHelper.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ fir::factory::DoLoopHelper::createLoop(mlir::Value lb, mlir::Value ub,
2020
auto ubi = builder.convertToIndexType(loc, ub);
2121
assert(step && "step must be an actual Value");
2222
auto inc = builder.convertToIndexType(loc, step);
23-
auto loop = builder.create<fir::DoLoopOp>(loc, lbi, ubi, inc);
23+
auto loop = fir::DoLoopOp::create(builder, loc, lbi, ubi, inc);
2424
auto insertPt = builder.saveInsertionPoint();
2525
builder.setInsertionPointToStart(loop.getBody());
2626
auto index = loop.getInductionVar();
@@ -43,6 +43,6 @@ fir::factory::DoLoopHelper::createLoop(mlir::Value count,
4343
auto indexType = builder.getIndexType();
4444
auto zero = builder.createIntegerConstant(loc, indexType, 0);
4545
auto one = builder.createIntegerConstant(loc, count.getType(), 1);
46-
auto up = builder.create<mlir::arith::SubIOp>(loc, count, one);
46+
auto up = mlir::arith::SubIOp::create(builder, loc, count, one);
4747
return createLoop(zero, up, one, bodyGenerator);
4848
}

flang/lib/Optimizer/Builder/FIRBuilder.cpp

Lines changed: 74 additions & 71 deletions
Large diffs are not rendered by default.

flang/lib/Optimizer/Builder/HLFIRTools.cpp

Lines changed: 90 additions & 91 deletions
Large diffs are not rendered by default.

flang/lib/Optimizer/Builder/IntrinsicCall.cpp

Lines changed: 852 additions & 827 deletions
Large diffs are not rendered by default.

flang/lib/Optimizer/Builder/MutableBox.cpp

Lines changed: 65 additions & 63 deletions
Large diffs are not rendered by default.

flang/lib/Optimizer/Builder/PPCIntrinsicCall.cpp

Lines changed: 127 additions & 123 deletions
Large diffs are not rendered by default.

flang/lib/Optimizer/Builder/TemporaryStorage.cpp

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ fir::factory::Counter::Counter(mlir::Location loc, fir::FirOpBuilder &builder,
2828
one = builder.createIntegerConstant(loc, type, 1);
2929
if (canCountThroughLoops) {
3030
index = builder.createTemporary(loc, type);
31-
builder.create<fir::StoreOp>(loc, initialValue, index);
31+
fir::StoreOp::create(builder, loc, initialValue, index);
3232
} else {
3333
index = initialValue;
3434
}
@@ -38,21 +38,21 @@ mlir::Value
3838
fir::factory::Counter::getAndIncrementIndex(mlir::Location loc,
3939
fir::FirOpBuilder &builder) {
4040
if (canCountThroughLoops) {
41-
mlir::Value indexValue = builder.create<fir::LoadOp>(loc, index);
41+
mlir::Value indexValue = fir::LoadOp::create(builder, loc, index);
4242
mlir::Value newValue =
43-
builder.create<mlir::arith::AddIOp>(loc, indexValue, one);
44-
builder.create<fir::StoreOp>(loc, newValue, index);
43+
mlir::arith::AddIOp::create(builder, loc, indexValue, one);
44+
fir::StoreOp::create(builder, loc, newValue, index);
4545
return indexValue;
4646
}
4747
mlir::Value indexValue = index;
48-
index = builder.create<mlir::arith::AddIOp>(loc, indexValue, one);
48+
index = mlir::arith::AddIOp::create(builder, loc, indexValue, one);
4949
return indexValue;
5050
}
5151

5252
void fir::factory::Counter::reset(mlir::Location loc,
5353
fir::FirOpBuilder &builder) {
5454
if (canCountThroughLoops)
55-
builder.create<fir::StoreOp>(loc, initialValue, index);
55+
fir::StoreOp::create(builder, loc, initialValue, index);
5656
else
5757
index = initialValue;
5858
}
@@ -103,7 +103,7 @@ void fir::factory::HomogeneousScalarStack::pushValue(mlir::Location loc,
103103
// below should not get hit but is added as a remainder/safety.
104104
if (!entity.hasIntrinsicType())
105105
TODO(loc, "creating inlined temporary stack for derived types");
106-
builder.create<hlfir::AssignOp>(loc, value, tempElement);
106+
hlfir::AssignOp::create(builder, loc, value, tempElement);
107107
}
108108

109109
void fir::factory::HomogeneousScalarStack::resetFetchPosition(
@@ -125,14 +125,14 @@ void fir::factory::HomogeneousScalarStack::destroy(mlir::Location loc,
125125
if (allocateOnHeap) {
126126
auto declare = temp.getDefiningOp<hlfir::DeclareOp>();
127127
assert(declare && "temp must have been declared");
128-
builder.create<fir::FreeMemOp>(loc, declare.getMemref());
128+
fir::FreeMemOp::create(builder, loc, declare.getMemref());
129129
}
130130
}
131131

132132
hlfir::Entity fir::factory::HomogeneousScalarStack::moveStackAsArrayExpr(
133133
mlir::Location loc, fir::FirOpBuilder &builder) {
134134
mlir::Value mustFree = builder.createBool(loc, allocateOnHeap);
135-
auto hlfirExpr = builder.create<hlfir::AsExprOp>(loc, temp, mustFree);
135+
auto hlfirExpr = hlfir::AsExprOp::create(builder, loc, temp, mustFree);
136136
return hlfir::Entity{hlfirExpr};
137137
}
138138

@@ -147,14 +147,14 @@ fir::factory::SimpleCopy::SimpleCopy(mlir::Location loc,
147147
// Use hlfir.as_expr and hlfir.associate to create a copy and leave
148148
// bufferization deals with how best to make the copy.
149149
if (source.isVariable())
150-
source = hlfir::Entity{builder.create<hlfir::AsExprOp>(loc, source)};
150+
source = hlfir::Entity{hlfir::AsExprOp::create(builder, loc, source)};
151151
copy = hlfir::genAssociateExpr(loc, builder, source,
152152
source.getFortranElementType(), tempName);
153153
}
154154

155155
void fir::factory::SimpleCopy::destroy(mlir::Location loc,
156156
fir::FirOpBuilder &builder) {
157-
builder.create<hlfir::EndAssociateOp>(loc, copy);
157+
hlfir::EndAssociateOp::create(builder, loc, copy);
158158
}
159159

160160
//===----------------------------------------------------------------------===//
@@ -279,7 +279,7 @@ mlir::Value fir::factory::AnyVariableStack::fetch(mlir::Location loc,
279279
mlir::Value indexValue = counter.getAndIncrementIndex(loc, builder);
280280
fir::runtime::genDescriptorAt(loc, builder, opaquePtr, indexValue,
281281
retValueBox);
282-
hlfir::Entity retBox{builder.create<fir::LoadOp>(loc, retValueBox)};
282+
hlfir::Entity retBox{fir::LoadOp::create(builder, loc, retValueBox)};
283283
// The runtime always tracks variable as address, but the form of the variable
284284
// that was saved may be different (raw address, fir.boxchar), ensure
285285
// the returned variable has the same form of the one that was saved.
@@ -326,7 +326,7 @@ void fir::factory::AnyVectorSubscriptStack::pushShape(
326326
hlfir::getFortranElementOrSequenceType(*boxType));
327327
mlir::Value null = builder.createNullConstant(loc, refType);
328328
mlir::Value descriptor =
329-
builder.create<fir::EmboxOp>(loc, *boxType, null, shape);
329+
fir::EmboxOp::create(builder, loc, *boxType, null, shape);
330330
shapeTemp->pushValue(loc, builder, descriptor);
331331
return;
332332
}
@@ -372,7 +372,7 @@ void fir::factory::AnyAddressStack::pushValue(mlir::Location loc,
372372
mlir::Value cast = variable;
373373
if (auto boxProcType = llvm::dyn_cast<fir::BoxProcType>(variable.getType())) {
374374
cast =
375-
builder.create<fir::BoxAddrOp>(loc, boxProcType.getEleTy(), variable);
375+
fir::BoxAddrOp::create(builder, loc, boxProcType.getEleTy(), variable);
376376
}
377377
cast = builder.createConvert(loc, builder.getIntPtrType(), cast);
378378
static_cast<AnyValueStack *>(this)->pushValue(loc, builder, cast);
@@ -383,7 +383,7 @@ mlir::Value fir::factory::AnyAddressStack::fetch(mlir::Location loc,
383383
mlir::Value addr = static_cast<AnyValueStack *>(this)->fetch(loc, builder);
384384
if (auto boxProcType = llvm::dyn_cast<fir::BoxProcType>(addressType)) {
385385
mlir::Value cast = builder.createConvert(loc, boxProcType.getEleTy(), addr);
386-
return builder.create<fir::EmboxProcOp>(loc, boxProcType, cast);
386+
return fir::EmboxProcOp::create(builder, loc, boxProcType, cast);
387387
}
388388
return builder.createConvert(loc, addressType, addr);
389389
}

0 commit comments

Comments
 (0)