aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaksim Levental <maksim.levental@gmail.com>2025-07-24 18:05:25 -0500
committerGitHub <noreply@github.com>2025-07-24 19:05:25 -0400
commit3f74334c38120bbdefac012d478dfce8e4eb0906 (patch)
tree7ac32117aacfcb6556c95b3bf139f70f7121ac46
parent77524bcf263d80b2e87a5c9c19f7e5f9fa1cd257 (diff)
downloadllvm-3f74334c38120bbdefac012d478dfce8e4eb0906.zip
llvm-3f74334c38120bbdefac012d478dfce8e4eb0906.tar.gz
llvm-3f74334c38120bbdefac012d478dfce8e4eb0906.tar.bz2
[mlir][NFC] update `flang` create APIs (13/n) (#149913)
See https://github.com/llvm/llvm-project/pull/147168 for more info.
-rw-r--r--flang/include/flang/Lower/DirectivesCommon.h44
-rw-r--r--flang/include/flang/Lower/Support/ReductionProcessor.h10
-rw-r--r--flang/include/flang/Optimizer/Builder/Complex.h8
-rw-r--r--flang/include/flang/Optimizer/Builder/DirectivesCommon.h69
-rw-r--r--flang/include/flang/Optimizer/CodeGen/FIROpPatterns.h2
-rw-r--r--flang/unittests/Frontend/CodeGenActionTest.cpp11
-rw-r--r--flang/unittests/Optimizer/Builder/CharacterTest.cpp6
-rw-r--r--flang/unittests/Optimizer/Builder/ComplexTest.cpp6
-rw-r--r--flang/unittests/Optimizer/Builder/FIRBuilderTest.cpp46
-rw-r--r--flang/unittests/Optimizer/Builder/HLFIRToolsTest.cpp16
-rw-r--r--flang/unittests/Optimizer/Builder/Runtime/CharacterTest.cpp46
-rw-r--r--flang/unittests/Optimizer/Builder/Runtime/NumericTest.cpp12
-rw-r--r--flang/unittests/Optimizer/Builder/Runtime/ReductionTest.cpp50
-rw-r--r--flang/unittests/Optimizer/Builder/Runtime/RuntimeCallTestBase.h6
-rw-r--r--flang/unittests/Optimizer/Builder/Runtime/TransformationalTest.cpp42
15 files changed, 193 insertions, 181 deletions
diff --git a/flang/include/flang/Lower/DirectivesCommon.h b/flang/include/flang/Lower/DirectivesCommon.h
index 93ab2e3..6ed3c1b 100644
--- a/flang/include/flang/Lower/DirectivesCommon.h
+++ b/flang/include/flang/Lower/DirectivesCommon.h
@@ -193,26 +193,27 @@ genBoundsOps(fir::FirOpBuilder &builder, mlir::Location loc,
mlir::Value box =
!fir::isBoxAddress(info.addr.getType())
? info.addr
- : builder.create<fir::LoadOp>(loc, info.addr);
+ : fir::LoadOp::create(builder, loc, info.addr);
mlir::Value d =
builder.createIntegerConstant(loc, idxTy, dimension);
- auto dimInfo = builder.create<fir::BoxDimsOp>(
- loc, idxTy, idxTy, idxTy, box, d);
- builder.create<fir::ResultOp>(loc, dimInfo.getByteStride());
+ auto dimInfo = fir::BoxDimsOp::create(builder, loc, idxTy,
+ idxTy, idxTy, box, d);
+ fir::ResultOp::create(builder, loc,
+ dimInfo.getByteStride());
})
.genElse([&] {
mlir::Value zero =
builder.createIntegerConstant(loc, idxTy, 0);
- builder.create<fir::ResultOp>(loc, zero);
+ fir::ResultOp::create(builder, loc, zero);
})
.getResults()[0];
} else {
mlir::Value box = !fir::isBoxAddress(info.addr.getType())
? info.addr
- : builder.create<fir::LoadOp>(loc, info.addr);
+ : fir::LoadOp::create(builder, loc, info.addr);
mlir::Value d = builder.createIntegerConstant(loc, idxTy, dimension);
auto dimInfo =
- builder.create<fir::BoxDimsOp>(loc, idxTy, idxTy, idxTy, box, d);
+ fir::BoxDimsOp::create(builder, loc, idxTy, idxTy, idxTy, box, d);
stride = dimInfo.getByteStride();
}
strideInBytes = true;
@@ -242,14 +243,14 @@ genBoundsOps(fir::FirOpBuilder &builder, mlir::Location loc,
lbound = builder.createIntegerConstant(loc, idxTy, *lval - 1);
} else {
mlir::Value lb = builder.createIntegerConstant(loc, idxTy, *lval);
- lbound = builder.create<mlir::arith::SubIOp>(loc, lb, baseLb);
+ lbound = mlir::arith::SubIOp::create(builder, loc, lb, baseLb);
}
asFortran << *lval;
} else {
mlir::Value lb =
fir::getBase(converter.genExprValue(loc, *lower, stmtCtx));
lb = builder.createConvert(loc, baseLb.getType(), lb);
- lbound = builder.create<mlir::arith::SubIOp>(loc, lb, baseLb);
+ lbound = mlir::arith::SubIOp::create(builder, loc, lb, baseLb);
asFortran << detail::peelOuterConvert(*lower).AsFortran();
}
} else {
@@ -276,14 +277,14 @@ genBoundsOps(fir::FirOpBuilder &builder, mlir::Location loc,
ubound = builder.createIntegerConstant(loc, idxTy, *uval - 1);
} else {
mlir::Value ub = builder.createIntegerConstant(loc, idxTy, *uval);
- ubound = builder.create<mlir::arith::SubIOp>(loc, ub, baseLb);
+ ubound = mlir::arith::SubIOp::create(builder, loc, ub, baseLb);
}
asFortran << *uval;
} else {
mlir::Value ub =
fir::getBase(converter.genExprValue(loc, *upper, stmtCtx));
ub = builder.createConvert(loc, baseLb.getType(), ub);
- ubound = builder.create<mlir::arith::SubIOp>(loc, ub, baseLb);
+ ubound = mlir::arith::SubIOp::create(builder, loc, ub, baseLb);
asFortran << detail::peelOuterConvert(*upper).AsFortran();
}
}
@@ -310,12 +311,12 @@ genBoundsOps(fir::FirOpBuilder &builder, mlir::Location loc,
.genThen([&]() {
mlir::Value ext = fir::factory::readExtent(
builder, loc, dataExv, dimension);
- builder.create<fir::ResultOp>(loc, ext);
+ fir::ResultOp::create(builder, loc, ext);
})
.genElse([&] {
mlir::Value zero =
builder.createIntegerConstant(loc, idxTy, 0);
- builder.create<fir::ResultOp>(loc, zero);
+ fir::ResultOp::create(builder, loc, zero);
})
.getResults()[0];
} else {
@@ -326,8 +327,8 @@ genBoundsOps(fir::FirOpBuilder &builder, mlir::Location loc,
extent = zero;
if (ubound && lbound) {
mlir::Value diff =
- builder.create<mlir::arith::SubIOp>(loc, ubound, lbound);
- extent = builder.create<mlir::arith::AddIOp>(loc, diff, one);
+ mlir::arith::SubIOp::create(builder, loc, ubound, lbound);
+ extent = mlir::arith::AddIOp::create(builder, loc, diff, one);
}
if (!ubound)
ubound = lbound;
@@ -335,7 +336,7 @@ genBoundsOps(fir::FirOpBuilder &builder, mlir::Location loc,
if (!ubound) {
// ub = extent - 1
- ubound = builder.create<mlir::arith::SubIOp>(loc, extent, one);
+ ubound = mlir::arith::SubIOp::create(builder, loc, extent, one);
}
}
@@ -347,8 +348,9 @@ genBoundsOps(fir::FirOpBuilder &builder, mlir::Location loc,
loc, cumulativeExtent, extent);
}
- mlir::Value bound = builder.create<BoundsOp>(
- loc, boundTy, lbound, ubound, extent, stride, strideInBytes, baseLb);
+ mlir::Value bound =
+ BoundsOp::create(builder, loc, boundTy, lbound, ubound, extent,
+ stride, strideInBytes, baseLb);
bounds.push_back(bound);
++dimension;
}
@@ -461,8 +463,8 @@ fir::factory::AddrAndBoundsInfo gatherDataOperandAddrAndBounds(
asFortran << designator.AsFortran();
if (semantics::IsOptional(compRef->GetLastSymbol())) {
- info.isPresent = builder.create<fir::IsPresentOp>(
- operandLocation, builder.getI1Type(), info.rawInput);
+ info.isPresent = fir::IsPresentOp::create(
+ builder, operandLocation, builder.getI1Type(), info.rawInput);
}
if (unwrapFirBox) {
@@ -472,7 +474,7 @@ fir::factory::AddrAndBoundsInfo gatherDataOperandAddrAndBounds(
fir::isPointerType(loadOp.getType())) {
info.boxType = info.addr.getType();
info.addr =
- builder.create<fir::BoxAddrOp>(operandLocation, info.addr);
+ fir::BoxAddrOp::create(builder, operandLocation, info.addr);
}
info.rawInput = info.addr;
}
diff --git a/flang/include/flang/Lower/Support/ReductionProcessor.h b/flang/include/flang/Lower/Support/ReductionProcessor.h
index 0b49049..66f26b3 100644
--- a/flang/include/flang/Lower/Support/ReductionProcessor.h
+++ b/flang/include/flang/Lower/Support/ReductionProcessor.h
@@ -142,8 +142,8 @@ ReductionProcessor::getReductionOperation(fir::FirOpBuilder &builder,
assert(type.isIntOrIndexOrFloat() &&
"only integer, float and complex types are currently supported");
if (type.isIntOrIndex())
- return builder.create<IntegerOp>(loc, op1, op2);
- return builder.create<FloatOp>(loc, op1, op2);
+ return IntegerOp::create(builder, loc, op1, op2);
+ return FloatOp::create(builder, loc, op1, op2);
}
template <typename FloatOp, typename IntegerOp, typename ComplexOp>
@@ -154,10 +154,10 @@ ReductionProcessor::getReductionOperation(fir::FirOpBuilder &builder,
assert((type.isIntOrIndexOrFloat() || fir::isa_complex(type)) &&
"only integer, float and complex types are currently supported");
if (type.isIntOrIndex())
- return builder.create<IntegerOp>(loc, op1, op2);
+ return IntegerOp::create(builder, loc, op1, op2);
if (fir::isa_real(type))
- return builder.create<FloatOp>(loc, op1, op2);
- return builder.create<ComplexOp>(loc, op1, op2);
+ return FloatOp::create(builder, loc, op1, op2);
+ return ComplexOp::create(builder, loc, op1, op2);
}
} // namespace omp
diff --git a/flang/include/flang/Optimizer/Builder/Complex.h b/flang/include/flang/Optimizer/Builder/Complex.h
index cd0a876..29395ac 100644
--- a/flang/include/flang/Optimizer/Builder/Complex.h
+++ b/flang/include/flang/Optimizer/Builder/Complex.h
@@ -58,16 +58,16 @@ public:
protected:
template <Part partId>
mlir::Value extract(mlir::Value cplx) {
- return builder.create<fir::ExtractValueOp>(
- loc, getComplexPartType(cplx), cplx,
+ return fir::ExtractValueOp::create(
+ builder, loc, getComplexPartType(cplx), cplx,
builder.getArrayAttr({builder.getIntegerAttr(
builder.getIndexType(), static_cast<int>(partId))}));
}
template <Part partId>
mlir::Value insert(mlir::Value cplx, mlir::Value part) {
- return builder.create<fir::InsertValueOp>(
- loc, cplx.getType(), cplx, part,
+ return fir::InsertValueOp::create(
+ builder, loc, cplx.getType(), cplx, part,
builder.getArrayAttr({builder.getIntegerAttr(
builder.getIndexType(), static_cast<int>(partId))}));
}
diff --git a/flang/include/flang/Optimizer/Builder/DirectivesCommon.h b/flang/include/flang/Optimizer/Builder/DirectivesCommon.h
index 78c1bb359..7413e4e 100644
--- a/flang/include/flang/Optimizer/Builder/DirectivesCommon.h
+++ b/flang/include/flang/Optimizer/Builder/DirectivesCommon.h
@@ -71,7 +71,7 @@ inline AddrAndBoundsInfo getDataOperandBaseAddr(fir::FirOpBuilder &builder,
mlir::Value isPresent;
if (isOptional)
isPresent =
- builder.create<fir::IsPresentOp>(loc, builder.getI1Type(), rawInput);
+ fir::IsPresentOp::create(builder, loc, builder.getI1Type(), rawInput);
if (auto boxTy = mlir::dyn_cast<fir::BaseBoxType>(
fir::unwrapRefType(symAddr.getType()))) {
@@ -82,7 +82,7 @@ inline AddrAndBoundsInfo getDataOperandBaseAddr(fir::FirOpBuilder &builder,
// if branches.
if (unwrapFirBox && mlir::isa<fir::ReferenceType>(symAddr.getType()) &&
!isOptional) {
- mlir::Value addr = builder.create<fir::LoadOp>(loc, symAddr);
+ mlir::Value addr = fir::LoadOp::create(builder, loc, symAddr);
return AddrAndBoundsInfo(addr, rawInput, isPresent, boxTy);
}
@@ -94,7 +94,7 @@ inline AddrAndBoundsInfo getDataOperandBaseAddr(fir::FirOpBuilder &builder,
if (auto boxCharType = mlir::dyn_cast<fir::BoxCharType>(
fir::unwrapRefType((symAddr.getType())))) {
if (!isOptional && mlir::isa<fir::ReferenceType>(symAddr.getType())) {
- mlir::Value boxChar = builder.create<fir::LoadOp>(loc, symAddr);
+ mlir::Value boxChar = fir::LoadOp::create(builder, loc, symAddr);
return AddrAndBoundsInfo(boxChar, rawInput, isPresent);
}
}
@@ -117,10 +117,10 @@ gatherBoundsOrBoundValues(fir::FirOpBuilder &builder, mlir::Location loc,
mlir::Value baseLb =
fir::factory::readLowerBound(builder, loc, dataExv, dim, one);
auto dimInfo =
- builder.create<fir::BoxDimsOp>(loc, idxTy, idxTy, idxTy, box, d);
+ fir::BoxDimsOp::create(builder, loc, idxTy, idxTy, idxTy, box, d);
mlir::Value lb = builder.createIntegerConstant(loc, idxTy, 0);
mlir::Value ub =
- builder.create<mlir::arith::SubIOp>(loc, dimInfo.getExtent(), one);
+ mlir::arith::SubIOp::create(builder, loc, dimInfo.getExtent(), one);
if (dim == 0) // First stride is the element size.
byteStride = dimInfo.getByteStride();
if (collectValuesOnly) {
@@ -130,13 +130,14 @@ gatherBoundsOrBoundValues(fir::FirOpBuilder &builder, mlir::Location loc,
values.push_back(byteStride);
values.push_back(baseLb);
} else {
- mlir::Value bound = builder.create<BoundsOp>(
- loc, boundTy, lb, ub, dimInfo.getExtent(), byteStride, true, baseLb);
+ mlir::Value bound =
+ BoundsOp::create(builder, loc, boundTy, lb, ub, dimInfo.getExtent(),
+ byteStride, true, baseLb);
values.push_back(bound);
}
// Compute the stride for the next dimension.
- byteStride = builder.create<mlir::arith::MulIOp>(loc, byteStride,
- dimInfo.getExtent());
+ byteStride = mlir::arith::MulIOp::create(builder, loc, byteStride,
+ dimInfo.getExtent());
}
return values;
}
@@ -162,20 +163,20 @@ genBoundsOpFromBoxChar(fir::FirOpBuilder &builder, mlir::Location loc,
.genThen([&]() {
mlir::Value boxChar =
fir::isa_ref_type(info.addr.getType())
- ? builder.create<fir::LoadOp>(loc, info.addr)
+ ? fir::LoadOp::create(builder, loc, info.addr)
: info.addr;
fir::BoxCharType boxCharType =
mlir::cast<fir::BoxCharType>(boxChar.getType());
mlir::Type refType = builder.getRefType(boxCharType.getEleTy());
- auto unboxed = builder.create<fir::UnboxCharOp>(
- loc, refType, lenType, boxChar);
+ auto unboxed = fir::UnboxCharOp::create(builder, loc, refType,
+ lenType, boxChar);
mlir::SmallVector<mlir::Value> results = {unboxed.getResult(1),
one};
- builder.create<fir::ResultOp>(loc, results);
+ fir::ResultOp::create(builder, loc, results);
})
.genElse([&]() {
mlir::SmallVector<mlir::Value> results = {zero, zero};
- builder.create<fir::ResultOp>(loc, results);
+ fir::ResultOp::create(builder, loc, results);
})
.getResults();
return {ifRes[0], ifRes[1]};
@@ -183,25 +184,25 @@ genBoundsOpFromBoxChar(fir::FirOpBuilder &builder, mlir::Location loc,
// We have already established that info.addr.getType() is a boxchar
// or a boxchar address. If an address, load the boxchar.
mlir::Value boxChar = fir::isa_ref_type(info.addr.getType())
- ? builder.create<fir::LoadOp>(loc, info.addr)
+ ? fir::LoadOp::create(builder, loc, info.addr)
: info.addr;
fir::BoxCharType boxCharType =
mlir::cast<fir::BoxCharType>(boxChar.getType());
mlir::Type refType = builder.getRefType(boxCharType.getEleTy());
auto unboxed =
- builder.create<fir::UnboxCharOp>(loc, refType, lenType, boxChar);
+ fir::UnboxCharOp::create(builder, loc, refType, lenType, boxChar);
return {unboxed.getResult(1), one};
}();
- mlir::Value ub = builder.create<mlir::arith::SubIOp>(loc, extent, one);
+ mlir::Value ub = mlir::arith::SubIOp::create(builder, loc, extent, one);
mlir::Type boundTy = builder.getType<BoundsType>();
- return builder.create<BoundsOp>(loc, boundTy,
- /*lower_bound=*/zero,
- /*upper_bound=*/ub,
- /*extent=*/extent,
- /*stride=*/stride,
- /*stride_in_bytes=*/true,
- /*start_idx=*/zero);
+ return BoundsOp::create(builder, loc, boundTy,
+ /*lower_bound=*/zero,
+ /*upper_bound=*/ub,
+ /*extent=*/extent,
+ /*stride=*/stride,
+ /*stride_in_bytes=*/true,
+ /*start_idx=*/zero);
}
/// Generate the bounds operation from the descriptor information.
@@ -230,12 +231,12 @@ genBoundsOpsFromBox(fir::FirOpBuilder &builder, mlir::Location loc,
mlir::Value box =
!fir::isBoxAddress(info.addr.getType())
? info.addr
- : builder.create<fir::LoadOp>(loc, info.addr);
+ : fir::LoadOp::create(builder, loc, info.addr);
llvm::SmallVector<mlir::Value> boundValues =
gatherBoundsOrBoundValues<BoundsOp, BoundsType>(
builder, loc, dataExv, box,
/*collectValuesOnly=*/true);
- builder.create<fir::ResultOp>(loc, boundValues);
+ fir::ResultOp::create(builder, loc, boundValues);
})
.genElse([&] {
// Box is not present. Populate bound values with default values.
@@ -249,21 +250,21 @@ genBoundsOpsFromBox(fir::FirOpBuilder &builder, mlir::Location loc,
boundValues.push_back(zero); // byteStride
boundValues.push_back(zero); // baseLb
}
- builder.create<fir::ResultOp>(loc, boundValues);
+ fir::ResultOp::create(builder, loc, boundValues);
})
.getResults();
// Create the bound operations outside the if-then-else with the if op
// results.
for (unsigned i = 0; i < ifRes.size(); i += nbValuesPerBound) {
- mlir::Value bound = builder.create<BoundsOp>(
- loc, boundTy, ifRes[i], ifRes[i + 1], ifRes[i + 2], ifRes[i + 3],
- true, ifRes[i + 4]);
+ mlir::Value bound =
+ BoundsOp::create(builder, loc, boundTy, ifRes[i], ifRes[i + 1],
+ ifRes[i + 2], ifRes[i + 3], true, ifRes[i + 4]);
bounds.push_back(bound);
}
} else {
mlir::Value box = !fir::isBoxAddress(info.addr.getType())
? info.addr
- : builder.create<fir::LoadOp>(loc, info.addr);
+ : fir::LoadOp::create(builder, loc, info.addr);
bounds = gatherBoundsOrBoundValues<BoundsOp, BoundsType>(builder, loc,
dataExv, box);
}
@@ -299,7 +300,7 @@ genBaseBoundsOps(fir::FirOpBuilder &builder, mlir::Location loc,
ub = lb;
} else {
// ub = extent - 1
- ub = builder.create<mlir::arith::SubIOp>(loc, extent, one);
+ ub = mlir::arith::SubIOp::create(builder, loc, extent, one);
}
mlir::Value stride = one;
if (strideIncludeLowerExtent) {
@@ -308,8 +309,8 @@ genBaseBoundsOps(fir::FirOpBuilder &builder, mlir::Location loc,
loc, cumulativeExtent, extent);
}
- mlir::Value bound = builder.create<BoundsOp>(loc, boundTy, lb, ub, extent,
- stride, false, baseLb);
+ mlir::Value bound = BoundsOp::create(builder, loc, boundTy, lb, ub, extent,
+ stride, false, baseLb);
bounds.push_back(bound);
}
return bounds;
diff --git a/flang/include/flang/Optimizer/CodeGen/FIROpPatterns.h b/flang/include/flang/Optimizer/CodeGen/FIROpPatterns.h
index cbdcf6b..b7fa8fc 100644
--- a/flang/include/flang/Optimizer/CodeGen/FIROpPatterns.h
+++ b/flang/include/flang/Optimizer/CodeGen/FIROpPatterns.h
@@ -144,7 +144,7 @@ protected:
llvm::SmallVector<mlir::LLVM::GEPArg> cv = {args...};
auto llvmPtrTy =
mlir::LLVM::LLVMPointerType::get(ty.getContext(), /*addressSpace=*/0);
- return rewriter.create<mlir::LLVM::GEPOp>(loc, llvmPtrTy, ty, base, cv);
+ return mlir::LLVM::GEPOp::create(rewriter, loc, llvmPtrTy, ty, base, cv);
}
// Find the Block in which the alloca should be inserted.
diff --git a/flang/unittests/Frontend/CodeGenActionTest.cpp b/flang/unittests/Frontend/CodeGenActionTest.cpp
index 6020abc..e606456 100644
--- a/flang/unittests/Frontend/CodeGenActionTest.cpp
+++ b/flang/unittests/Frontend/CodeGenActionTest.cpp
@@ -50,6 +50,15 @@ public:
static void build(
::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState) {}
+
+ static FakeOp create(
+ ::mlir::OpBuilder &odsBuilder, ::mlir::Location location) {
+ ::mlir::OperationState state(location, getOperationName());
+ build(odsBuilder, state);
+ auto res = ::llvm::dyn_cast<FakeOp>(odsBuilder.create(state));
+ assert(res && "builder didn't return the right type");
+ return res;
+ }
};
} // namespace dummy
} // namespace test
@@ -77,7 +86,7 @@ public:
mlir::OpBuilder builder(mlirCtx.get());
builder.setInsertionPointToStart(&mlirModule->getRegion().front());
// Create a fake op to trip conversion to LLVM.
- builder.create<test::dummy::FakeOp>(loc);
+ test::dummy::FakeOp::create(builder, loc);
llvmCtx = std::make_unique<llvm::LLVMContext>();
}
diff --git a/flang/unittests/Optimizer/Builder/CharacterTest.cpp b/flang/unittests/Optimizer/Builder/CharacterTest.cpp
index d8d2da4..8dca8e2 100644
--- a/flang/unittests/Optimizer/Builder/CharacterTest.cpp
+++ b/flang/unittests/Optimizer/Builder/CharacterTest.cpp
@@ -26,10 +26,10 @@ public:
// Set up a Module with a dummy function operation inside.
// Set the insertion point in the function entry block.
- moduleOp = builder.create<mlir::ModuleOp>(loc);
+ moduleOp = mlir::ModuleOp::create(builder, loc);
builder.setInsertionPointToStart(moduleOp->getBody());
- mlir::func::FuncOp func = builder.create<mlir::func::FuncOp>(
- loc, "func1", builder.getFunctionType({}, {}));
+ mlir::func::FuncOp func = mlir::func::FuncOp::create(
+ builder, loc, "func1", builder.getFunctionType({}, {}));
auto *entryBlock = func.addEntryBlock();
builder.setInsertionPointToStart(entryBlock);
diff --git a/flang/unittests/Optimizer/Builder/ComplexTest.cpp b/flang/unittests/Optimizer/Builder/ComplexTest.cpp
index d5f00c9..668befd 100644
--- a/flang/unittests/Optimizer/Builder/ComplexTest.cpp
+++ b/flang/unittests/Optimizer/Builder/ComplexTest.cpp
@@ -22,10 +22,10 @@ public:
// Set up a Module with a dummy function operation inside.
// Set the insertion point in the function entry block.
- moduleOp = builder.create<mlir::ModuleOp>(loc);
+ moduleOp = mlir::ModuleOp::create(builder, loc);
builder.setInsertionPointToStart(moduleOp->getBody());
- mlir::func::FuncOp func = builder.create<mlir::func::FuncOp>(
- loc, "func1", builder.getFunctionType({}, {}));
+ mlir::func::FuncOp func = mlir::func::FuncOp::create(
+ builder, loc, "func1", builder.getFunctionType({}, {}));
auto *entryBlock = func.addEntryBlock();
builder.setInsertionPointToStart(entryBlock);
diff --git a/flang/unittests/Optimizer/Builder/FIRBuilderTest.cpp b/flang/unittests/Optimizer/Builder/FIRBuilderTest.cpp
index e4c21f6b..e3e3647 100644
--- a/flang/unittests/Optimizer/Builder/FIRBuilderTest.cpp
+++ b/flang/unittests/Optimizer/Builder/FIRBuilderTest.cpp
@@ -26,10 +26,10 @@ public:
// Set up a Module with a dummy function operation inside.
// Set the insertion point in the function entry block.
- moduleOp = builder.create<mlir::ModuleOp>(loc);
+ moduleOp = mlir::ModuleOp::create(builder, loc);
builder.setInsertionPointToStart(moduleOp->getBody());
- mlir::func::FuncOp func = builder.create<mlir::func::FuncOp>(
- loc, "func1", builder.getFunctionType({}, {}));
+ mlir::func::FuncOp func = mlir::func::FuncOp::create(
+ builder, loc, "func1", builder.getFunctionType({}, {}));
auto *entryBlock = func.addEntryBlock();
builder.setInsertionPointToStart(entryBlock);
@@ -47,8 +47,8 @@ static arith::CmpIOp createCondition(fir::FirOpBuilder &builder) {
auto loc = builder.getUnknownLoc();
auto zero1 = builder.createIntegerConstant(loc, builder.getIndexType(), 0);
auto zero2 = builder.createIntegerConstant(loc, builder.getIndexType(), 0);
- return builder.create<arith::CmpIOp>(
- loc, arith::CmpIPredicate::eq, zero1, zero2);
+ return arith::CmpIOp::create(
+ builder, loc, arith::CmpIPredicate::eq, zero1, zero2);
}
static void checkIntegerConstant(mlir::Value value, mlir::Type ty, int64_t v) {
@@ -413,7 +413,7 @@ TEST_F(FIRBuilderTest, getExtents) {
llvm::SmallVector<mlir::Value> extents = {c10, c100};
fir::SequenceType::Shape shape(2, fir::SequenceType::getUnknownExtent());
auto arrayTy = fir::SequenceType::get(shape, builder.getI64Type());
- mlir::Value array = builder.create<fir::UndefOp>(loc, arrayTy);
+ mlir::Value array = fir::UndefOp::create(builder, loc, arrayTy);
fir::ArrayBoxValue aab(array, extents, {});
fir::ExtendedValue ex(aab);
auto readExtents = fir::factory::getExtents(loc, builder, ex);
@@ -468,12 +468,12 @@ TEST_F(FIRBuilderTest, getBaseTypeOf) {
auto boxTyArray = fir::BoxType::get(arrayType);
auto boxTyScalar = fir::BoxType::get(elementType);
- auto ptrValArray = builder.create<fir::UndefOp>(loc, ptrTyArray);
- auto ptrValScalar = builder.create<fir::UndefOp>(loc, ptrTyScalar);
- auto boxRefValArray = builder.create<fir::UndefOp>(loc, boxRefTyArray);
- auto boxRefValScalar = builder.create<fir::UndefOp>(loc, boxRefTyScalar);
- auto boxValArray = builder.create<fir::UndefOp>(loc, boxTyArray);
- auto boxValScalar = builder.create<fir::UndefOp>(loc, boxTyScalar);
+ auto ptrValArray = fir::UndefOp::create(builder, loc, ptrTyArray);
+ auto ptrValScalar = fir::UndefOp::create(builder, loc, ptrTyScalar);
+ auto boxRefValArray = fir::UndefOp::create(builder, loc, boxRefTyArray);
+ auto boxRefValScalar = fir::UndefOp::create(builder, loc, boxRefTyScalar);
+ auto boxValArray = fir::UndefOp::create(builder, loc, boxTyArray);
+ auto boxValScalar = fir::UndefOp::create(builder, loc, boxTyScalar);
llvm::SmallVector<fir::ExtendedValue, 4> scalars;
scalars.emplace_back(fir::UnboxedValue(ptrValScalar));
@@ -482,7 +482,7 @@ TEST_F(FIRBuilderTest, getBaseTypeOf) {
fir::MutableBoxValue(boxRefValScalar, mlir::ValueRange(), {}));
llvm::SmallVector<fir::ExtendedValue, 4> arrays;
- auto extent = builder.create<fir::UndefOp>(loc, builder.getIndexType());
+ auto extent = fir::UndefOp::create(builder, loc, builder.getIndexType());
llvm::SmallVector<mlir::Value> extents(
mlir::dyn_cast<fir::SequenceType>(arrayType).getDimension(),
extent.getResult());
@@ -537,10 +537,10 @@ TEST_F(FIRBuilderTest, genArithFastMath) {
auto loc = builder.getUnknownLoc();
auto realTy = mlir::Float32Type::get(ctx);
- auto arg = builder.create<fir::UndefOp>(loc, realTy);
+ auto arg = fir::UndefOp::create(builder, loc, realTy);
// Test that FastMathFlags is 'none' by default.
- mlir::Operation *op1 = builder.create<mlir::arith::AddFOp>(loc, arg, arg);
+ mlir::Operation *op1 = mlir::arith::AddFOp::create(builder, loc, arg, arg);
auto op1_fmi =
mlir::dyn_cast_or_null<mlir::arith::ArithFastMathInterface>(op1);
EXPECT_TRUE(op1_fmi);
@@ -558,7 +558,7 @@ TEST_F(FIRBuilderTest, genArithFastMath) {
builder_copy.setFastMathFlags(FMF2);
// Modifying FastMathFlags for the copy must not affect the original builder.
- mlir::Operation *op2 = builder.create<mlir::arith::AddFOp>(loc, arg, arg);
+ mlir::Operation *op2 = mlir::arith::AddFOp::create(builder, loc, arg, arg);
auto op2_fmi =
mlir::dyn_cast_or_null<mlir::arith::ArithFastMathInterface>(op2);
EXPECT_TRUE(op2_fmi);
@@ -567,7 +567,7 @@ TEST_F(FIRBuilderTest, genArithFastMath) {
// Modifying FastMathFlags for the original builder must not affect the copy.
mlir::Operation *op3 =
- builder_copy.create<mlir::arith::AddFOp>(loc, arg, arg);
+ mlir::arith::AddFOp::create(builder_copy, loc, arg, arg);
auto op3_fmi =
mlir::dyn_cast_or_null<mlir::arith::ArithFastMathInterface>(op3);
EXPECT_TRUE(op3_fmi);
@@ -578,7 +578,7 @@ TEST_F(FIRBuilderTest, genArithFastMath) {
fir::FirOpBuilder builder_copy2(builder);
mlir::Operation *op4 =
- builder_copy2.create<mlir::arith::AddFOp>(loc, arg, arg);
+ mlir::arith::AddFOp::create(builder_copy2, loc, arg, arg);
auto op4_fmi =
mlir::dyn_cast_or_null<mlir::arith::ArithFastMathInterface>(op4);
EXPECT_TRUE(op4_fmi);
@@ -592,10 +592,10 @@ TEST_F(FIRBuilderTest, genArithIntegerOverflow) {
auto loc = builder.getUnknownLoc();
auto intTy = IntegerType::get(ctx, 32);
- auto arg = builder.create<fir::UndefOp>(loc, intTy);
+ auto arg = fir::UndefOp::create(builder, loc, intTy);
// Test that IntegerOverflowFlags is 'none' by default.
- mlir::Operation *op1 = builder.create<mlir::arith::AddIOp>(loc, arg, arg);
+ mlir::Operation *op1 = mlir::arith::AddIOp::create(builder, loc, arg, arg);
auto op1_iofi =
mlir::dyn_cast_or_null<mlir::arith::ArithIntegerOverflowFlagsInterface>(
op1);
@@ -613,7 +613,7 @@ TEST_F(FIRBuilderTest, genArithIntegerOverflow) {
// Modifying IntegerOverflowFlags for the copy must not affect the original
// builder.
- mlir::Operation *op2 = builder.create<mlir::arith::AddIOp>(loc, arg, arg);
+ mlir::Operation *op2 = mlir::arith::AddIOp::create(builder, loc, arg, arg);
auto op2_iofi =
mlir::dyn_cast_or_null<mlir::arith::ArithIntegerOverflowFlagsInterface>(
op2);
@@ -624,7 +624,7 @@ TEST_F(FIRBuilderTest, genArithIntegerOverflow) {
// Modifying IntegerOverflowFlags for the original builder must not affect the
// copy.
mlir::Operation *op3 =
- builder_copy.create<mlir::arith::AddIOp>(loc, arg, arg);
+ mlir::arith::AddIOp::create(builder_copy, loc, arg, arg);
auto op3_iofi =
mlir::dyn_cast_or_null<mlir::arith::ArithIntegerOverflowFlagsInterface>(
op3);
@@ -636,7 +636,7 @@ TEST_F(FIRBuilderTest, genArithIntegerOverflow) {
fir::FirOpBuilder builder_copy2(builder);
mlir::Operation *op4 =
- builder_copy2.create<mlir::arith::AddIOp>(loc, arg, arg);
+ mlir::arith::AddIOp::create(builder_copy2, loc, arg, arg);
auto op4_iofi =
mlir::dyn_cast_or_null<mlir::arith::ArithIntegerOverflowFlagsInterface>(
op4);
diff --git a/flang/unittests/Optimizer/Builder/HLFIRToolsTest.cpp b/flang/unittests/Optimizer/Builder/HLFIRToolsTest.cpp
index a078519..df1411a 100644
--- a/flang/unittests/Optimizer/Builder/HLFIRToolsTest.cpp
+++ b/flang/unittests/Optimizer/Builder/HLFIRToolsTest.cpp
@@ -25,10 +25,10 @@ public:
// Set up a Module with a dummy function operation inside.
// Set the insertion point in the function entry block.
- moduleOp = builder.create<mlir::ModuleOp>(loc);
+ moduleOp = mlir::ModuleOp::create(builder, loc);
builder.setInsertionPointToStart(moduleOp->getBody());
- mlir::func::FuncOp func = builder.create<mlir::func::FuncOp>(
- loc, "func1", builder.getFunctionType({}, {}));
+ mlir::func::FuncOp func = mlir::func::FuncOp::create(
+ builder, loc, "func1", builder.getFunctionType({}, {}));
auto *entryBlock = func.addEntryBlock();
builder.setInsertionPointToStart(entryBlock);
@@ -61,7 +61,7 @@ TEST_F(HLFIRToolsTest, testScalarRoundTrip) {
mlir::Location loc = getLoc();
mlir::Type f32Type = mlir::Float32Type::get(&context);
mlir::Type scalarf32Type = builder.getRefType(f32Type);
- mlir::Value scalarf32Addr = builder.create<fir::UndefOp>(loc, scalarf32Type);
+ mlir::Value scalarf32Addr = fir::UndefOp::create(builder, loc, scalarf32Type);
fir::ExtendedValue scalarf32{scalarf32Addr};
hlfir::EntityWithAttributes scalarf32Entity(createDeclare(scalarf32));
auto [scalarf32Result, cleanup] =
@@ -85,7 +85,7 @@ TEST_F(HLFIRToolsTest, testArrayRoundTrip) {
mlir::Type f32Type = mlir::Float32Type::get(&context);
mlir::Type seqf32Type = builder.getVarLenSeqTy(f32Type, 2);
mlir::Type arrayf32Type = builder.getRefType(seqf32Type);
- mlir::Value arrayf32Addr = builder.create<fir::UndefOp>(loc, arrayf32Type);
+ mlir::Value arrayf32Addr = fir::UndefOp::create(builder, loc, arrayf32Type);
fir::ArrayBoxValue arrayf32{arrayf32Addr, extents, lbounds};
hlfir::EntityWithAttributes arrayf32Entity(createDeclare(arrayf32));
auto [arrayf32Result, cleanup] =
@@ -113,7 +113,7 @@ TEST_F(HLFIRToolsTest, testScalarCharRoundTrip) {
mlir::Type charType = fir::CharacterType::getUnknownLen(&context, 1);
mlir::Type scalarCharType = builder.getRefType(charType);
mlir::Value scalarCharAddr =
- builder.create<fir::UndefOp>(loc, scalarCharType);
+ fir::UndefOp::create(builder, loc, scalarCharType);
fir::CharBoxValue scalarChar{scalarCharAddr, len};
hlfir::EntityWithAttributes scalarCharEntity(createDeclare(scalarChar));
auto [scalarCharResult, cleanup] =
@@ -138,7 +138,7 @@ TEST_F(HLFIRToolsTest, testArrayCharRoundTrip) {
mlir::Type charType = fir::CharacterType::getUnknownLen(&context, 1);
mlir::Type seqCharType = builder.getVarLenSeqTy(charType, 2);
mlir::Type arrayCharType = builder.getRefType(seqCharType);
- mlir::Value arrayCharAddr = builder.create<fir::UndefOp>(loc, arrayCharType);
+ mlir::Value arrayCharAddr = fir::UndefOp::create(builder, loc, arrayCharType);
fir::CharArrayBoxValue arrayChar{arrayCharAddr, len, extents, lbounds};
hlfir::EntityWithAttributes arrayCharEntity(createDeclare(arrayChar));
auto [arrayCharResult, cleanup] =
@@ -170,7 +170,7 @@ TEST_F(HLFIRToolsTest, testArrayCharBoxRoundTrip) {
mlir::Type seqCharType = builder.getVarLenSeqTy(charType, 2);
mlir::Type arrayCharBoxType = fir::BoxType::get(seqCharType);
mlir::Value arrayCharAddr =
- builder.create<fir::UndefOp>(loc, arrayCharBoxType);
+ fir::UndefOp::create(builder, loc, arrayCharBoxType);
llvm::SmallVector<mlir::Value> explicitTypeParams{len};
fir::BoxValue arrayChar{arrayCharAddr, lbounds, explicitTypeParams};
hlfir::EntityWithAttributes arrayCharEntity(createDeclare(arrayChar));
diff --git a/flang/unittests/Optimizer/Builder/Runtime/CharacterTest.cpp b/flang/unittests/Optimizer/Builder/Runtime/CharacterTest.cpp
index 315f8c8..cfd2d48 100644
--- a/flang/unittests/Optimizer/Builder/Runtime/CharacterTest.cpp
+++ b/flang/unittests/Optimizer/Builder/Runtime/CharacterTest.cpp
@@ -33,10 +33,10 @@ void checkCharCompare1(
fir::FirOpBuilder &builder, mlir::Type type, llvm::StringRef fctName) {
auto loc = builder.getUnknownLoc();
mlir::Type i32Ty = IntegerType::get(builder.getContext(), 32);
- mlir::Value lhsBuff = builder.create<fir::UndefOp>(loc, type);
- mlir::Value lhsLen = builder.create<fir::UndefOp>(loc, i32Ty);
- mlir::Value rhsBuff = builder.create<fir::UndefOp>(loc, type);
- mlir::Value rhsLen = builder.create<fir::UndefOp>(loc, i32Ty);
+ mlir::Value lhsBuff = fir::UndefOp::create(builder, loc, type);
+ mlir::Value lhsLen = fir::UndefOp::create(builder, loc, i32Ty);
+ mlir::Value rhsBuff = fir::UndefOp::create(builder, loc, type);
+ mlir::Value rhsLen = fir::UndefOp::create(builder, loc, i32Ty);
mlir::Value res = fir::runtime::genCharCompare(builder, loc,
mlir::arith::CmpIPredicate::eq, lhsBuff, lhsLen, rhsBuff, rhsLen);
checkCallOpFromResultBox(lhsBuff, fctName, 4, /*addLocArgs=*/false);
@@ -72,10 +72,10 @@ void checkCharCompare2(
fir::factory::CharacterExprHelper charHelper(builder, loc);
mlir::Type i32Ty = IntegerType::get(builder.getContext(), 32);
mlir::Type boxCharTy = fir::BoxCharType::get(builder.getContext(), kind);
- mlir::Value lhsBuff = builder.create<fir::UndefOp>(loc, boxCharTy);
- mlir::Value lhsLen = builder.create<fir::UndefOp>(loc, i32Ty);
- mlir::Value rhsBuff = builder.create<fir::UndefOp>(loc, boxCharTy);
- mlir::Value rhsLen = builder.create<fir::UndefOp>(loc, i32Ty);
+ mlir::Value lhsBuff = fir::UndefOp::create(builder, loc, boxCharTy);
+ mlir::Value lhsLen = fir::UndefOp::create(builder, loc, i32Ty);
+ mlir::Value rhsBuff = fir::UndefOp::create(builder, loc, boxCharTy);
+ mlir::Value rhsLen = fir::UndefOp::create(builder, loc, i32Ty);
fir::ExtendedValue lhs = charHelper.toExtendedValue(lhsBuff, lhsLen);
fir::ExtendedValue rhs = charHelper.toExtendedValue(rhsBuff, rhsLen);
mlir::Value res = fir::runtime::genCharCompare(
@@ -97,11 +97,11 @@ void checkGenIndex(
fir::FirOpBuilder &builder, llvm::StringRef fctName, unsigned kind) {
auto loc = builder.getUnknownLoc();
mlir::Type i32Ty = IntegerType::get(builder.getContext(), 32);
- mlir::Value stringBase = builder.create<fir::UndefOp>(loc, i32Ty);
- mlir::Value stringLen = builder.create<fir::UndefOp>(loc, i32Ty);
- mlir::Value substringBase = builder.create<fir::UndefOp>(loc, i32Ty);
- mlir::Value substringLen = builder.create<fir::UndefOp>(loc, i32Ty);
- mlir::Value back = builder.create<fir::UndefOp>(loc, i32Ty);
+ mlir::Value stringBase = fir::UndefOp::create(builder, loc, i32Ty);
+ mlir::Value stringLen = fir::UndefOp::create(builder, loc, i32Ty);
+ mlir::Value substringBase = fir::UndefOp::create(builder, loc, i32Ty);
+ mlir::Value substringLen = fir::UndefOp::create(builder, loc, i32Ty);
+ mlir::Value back = fir::UndefOp::create(builder, loc, i32Ty);
mlir::Value res = fir::runtime::genIndex(builder, loc, kind, stringBase,
stringLen, substringBase, substringLen, back);
checkCallOp(res.getDefiningOp(), fctName, 5, /*addLocArgs=*/false);
@@ -160,11 +160,11 @@ void checkGenScan(
mlir::Type charTy = fir::CharacterType::get(builder.getContext(), kind, 10);
mlir::Type boxTy = fir::BoxType::get(charTy);
mlir::Type i32Ty = IntegerType::get(builder.getContext(), 32);
- mlir::Value stringBase = builder.create<fir::UndefOp>(loc, boxTy);
- mlir::Value stringLen = builder.create<fir::UndefOp>(loc, i32Ty);
- mlir::Value setBase = builder.create<fir::UndefOp>(loc, boxTy);
- mlir::Value setLen = builder.create<fir::UndefOp>(loc, i32Ty);
- mlir::Value back = builder.create<fir::UndefOp>(loc, i32Ty);
+ mlir::Value stringBase = fir::UndefOp::create(builder, loc, boxTy);
+ mlir::Value stringLen = fir::UndefOp::create(builder, loc, i32Ty);
+ mlir::Value setBase = fir::UndefOp::create(builder, loc, boxTy);
+ mlir::Value setLen = fir::UndefOp::create(builder, loc, i32Ty);
+ mlir::Value back = fir::UndefOp::create(builder, loc, i32Ty);
mlir::Value res = fir::runtime::genScan(
builder, loc, kind, stringBase, stringLen, setBase, setLen, back);
checkCallOp(res.getDefiningOp(), fctName, 5, /*addLocArgs=*/false);
@@ -194,11 +194,11 @@ void checkGenVerify(
mlir::Type charTy = fir::CharacterType::get(builder.getContext(), kind, 10);
mlir::Type boxTy = fir::BoxType::get(charTy);
mlir::Type i32Ty = IntegerType::get(builder.getContext(), 32);
- mlir::Value stringBase = builder.create<fir::UndefOp>(loc, boxTy);
- mlir::Value stringLen = builder.create<fir::UndefOp>(loc, i32Ty);
- mlir::Value setBase = builder.create<fir::UndefOp>(loc, boxTy);
- mlir::Value setLen = builder.create<fir::UndefOp>(loc, i32Ty);
- mlir::Value back = builder.create<fir::UndefOp>(loc, i32Ty);
+ mlir::Value stringBase = fir::UndefOp::create(builder, loc, boxTy);
+ mlir::Value stringLen = fir::UndefOp::create(builder, loc, i32Ty);
+ mlir::Value setBase = fir::UndefOp::create(builder, loc, boxTy);
+ mlir::Value setLen = fir::UndefOp::create(builder, loc, i32Ty);
+ mlir::Value back = fir::UndefOp::create(builder, loc, i32Ty);
mlir::Value res = fir::runtime::genVerify(
builder, loc, kind, stringBase, stringLen, setBase, setLen, back);
checkCallOp(res.getDefiningOp(), fctName, 5, /*addLocArgs=*/false);
diff --git a/flang/unittests/Optimizer/Builder/Runtime/NumericTest.cpp b/flang/unittests/Optimizer/Builder/Runtime/NumericTest.cpp
index 47342da..0e867e98 100644
--- a/flang/unittests/Optimizer/Builder/Runtime/NumericTest.cpp
+++ b/flang/unittests/Optimizer/Builder/Runtime/NumericTest.cpp
@@ -15,7 +15,7 @@ using namespace mlir;
void testGenExponent(fir::FirOpBuilder &builder, mlir::Type resultType,
mlir::Type xType, llvm::StringRef fctName) {
auto loc = builder.getUnknownLoc();
- mlir::Value x = builder.create<fir::UndefOp>(loc, xType);
+ mlir::Value x = fir::UndefOp::create(builder, loc, xType);
mlir::Value exp = fir::runtime::genExponent(builder, loc, resultType, x);
checkCallOp(exp.getDefiningOp(), fctName, 1, /*addLocArg=*/false);
}
@@ -35,7 +35,7 @@ void testGenX(fir::FirOpBuilder &builder, mlir::Type xType,
mlir::Value (*genFct)(fir::FirOpBuilder &, Location, mlir::Value),
llvm::StringRef fctName) {
auto loc = builder.getUnknownLoc();
- mlir::Value x = builder.create<fir::UndefOp>(loc, xType);
+ mlir::Value x = fir::UndefOp::create(builder, loc, xType);
mlir::Value val = genFct(builder, loc, x);
checkCallOp(val.getDefiningOp(), fctName, 1, /*addLocArg=*/false);
}
@@ -52,8 +52,8 @@ TEST_F(RuntimeCallTest, genFractionTest) {
void testGenNearest(fir::FirOpBuilder &builder, mlir::Type xType,
mlir::Type sType, llvm::StringRef fctName) {
auto loc = builder.getUnknownLoc();
- mlir::Value x = builder.create<fir::UndefOp>(loc, xType);
- mlir::Value s = builder.create<fir::UndefOp>(loc, sType);
+ mlir::Value x = fir::UndefOp::create(builder, loc, xType);
+ mlir::Value s = fir::UndefOp::create(builder, loc, sType);
mlir::Value nearest = fir::runtime::genNearest(builder, loc, x, s);
checkCallOp(nearest.getDefiningOp(), fctName, 2, /*addLocArg=*/false);
}
@@ -81,8 +81,8 @@ void testGenXI(fir::FirOpBuilder &builder, mlir::Type xType, mlir::Type iType,
fir::FirOpBuilder &, Location, mlir::Value, mlir::Value),
llvm::StringRef fctName) {
auto loc = builder.getUnknownLoc();
- mlir::Value x = builder.create<fir::UndefOp>(loc, xType);
- mlir::Value i = builder.create<fir::UndefOp>(loc, iType);
+ mlir::Value x = fir::UndefOp::create(builder, loc, xType);
+ mlir::Value i = fir::UndefOp::create(builder, loc, iType);
mlir::Value val = genFct(builder, loc, x, i);
checkCallOp(val.getDefiningOp(), fctName, 2, /*addLocArg=*/false);
}
diff --git a/flang/unittests/Optimizer/Builder/Runtime/ReductionTest.cpp b/flang/unittests/Optimizer/Builder/Runtime/ReductionTest.cpp
index a4006c6..91e2d0b 100644
--- a/flang/unittests/Optimizer/Builder/Runtime/ReductionTest.cpp
+++ b/flang/unittests/Optimizer/Builder/Runtime/ReductionTest.cpp
@@ -68,8 +68,8 @@ void testGenMaxVal(
mlir::Type seqTy =
fir::SequenceType::get(fir::SequenceType::Shape(1, 10), eleTy);
mlir::Type refSeqTy = fir::ReferenceType::get(seqTy);
- mlir::Value undef = builder.create<fir::UndefOp>(loc, refSeqTy);
- mlir::Value mask = builder.create<fir::UndefOp>(loc, seqTy);
+ mlir::Value undef = fir::UndefOp::create(builder, loc, refSeqTy);
+ mlir::Value mask = fir::UndefOp::create(builder, loc, seqTy);
mlir::Value max = fir::runtime::genMaxval(builder, loc, undef, mask);
checkCallOp(max.getDefiningOp(), fctName, 3);
}
@@ -93,8 +93,8 @@ void testGenMinVal(
mlir::Type seqTy =
fir::SequenceType::get(fir::SequenceType::Shape(1, 10), eleTy);
mlir::Type refSeqTy = fir::ReferenceType::get(seqTy);
- mlir::Value undef = builder.create<fir::UndefOp>(loc, refSeqTy);
- mlir::Value mask = builder.create<fir::UndefOp>(loc, seqTy);
+ mlir::Value undef = fir::UndefOp::create(builder, loc, refSeqTy);
+ mlir::Value mask = fir::UndefOp::create(builder, loc, seqTy);
mlir::Value min = fir::runtime::genMinval(builder, loc, undef, mask);
checkCallOp(min.getDefiningOp(), fctName, 3);
}
@@ -135,9 +135,9 @@ void testGenSum(
mlir::Type seqTy =
fir::SequenceType::get(fir::SequenceType::Shape(1, 10), eleTy);
mlir::Type refSeqTy = fir::ReferenceType::get(seqTy);
- mlir::Value undef = builder.create<fir::UndefOp>(loc, refSeqTy);
- mlir::Value mask = builder.create<fir::UndefOp>(loc, seqTy);
- mlir::Value result = builder.create<fir::UndefOp>(loc, seqTy);
+ mlir::Value undef = fir::UndefOp::create(builder, loc, refSeqTy);
+ mlir::Value mask = fir::UndefOp::create(builder, loc, seqTy);
+ mlir::Value result = fir::UndefOp::create(builder, loc, seqTy);
mlir::Value sum = fir::runtime::genSum(builder, loc, undef, mask, result);
if (fir::isa_complex(eleTy))
checkCallOpFromResultBox(result, fctName, 4);
@@ -167,9 +167,9 @@ void testGenProduct(
mlir::Type seqTy =
fir::SequenceType::get(fir::SequenceType::Shape(1, 10), eleTy);
mlir::Type refSeqTy = fir::ReferenceType::get(seqTy);
- mlir::Value undef = builder.create<fir::UndefOp>(loc, refSeqTy);
- mlir::Value mask = builder.create<fir::UndefOp>(loc, seqTy);
- mlir::Value result = builder.create<fir::UndefOp>(loc, seqTy);
+ mlir::Value undef = fir::UndefOp::create(builder, loc, refSeqTy);
+ mlir::Value mask = fir::UndefOp::create(builder, loc, seqTy);
+ mlir::Value result = fir::UndefOp::create(builder, loc, seqTy);
mlir::Value prod =
fir::runtime::genProduct(builder, loc, undef, mask, result);
if (fir::isa_complex(eleTy))
@@ -200,10 +200,10 @@ void testGenDotProduct(
mlir::Type seqTy =
fir::SequenceType::get(fir::SequenceType::Shape(1, 10), eleTy);
mlir::Type refSeqTy = fir::ReferenceType::get(seqTy);
- mlir::Value a = builder.create<fir::UndefOp>(loc, refSeqTy);
- mlir::Value b = builder.create<fir::UndefOp>(loc, refSeqTy);
+ mlir::Value a = fir::UndefOp::create(builder, loc, refSeqTy);
+ mlir::Value b = fir::UndefOp::create(builder, loc, refSeqTy);
mlir::Value result =
- builder.create<fir::UndefOp>(loc, fir::ReferenceType::get(eleTy));
+ fir::UndefOp::create(builder, loc, fir::ReferenceType::get(eleTy));
mlir::Value prod = fir::runtime::genDotProduct(builder, loc, a, b, result);
if (fir::isa_complex(eleTy))
checkCallOpFromResultBox(result, fctName, 3);
@@ -236,9 +236,9 @@ void checkGenMxxloc(fir::FirOpBuilder &builder, mlir::Type eleTy,
mlir::Type seqTy =
fir::SequenceType::get(fir::SequenceType::Shape(1, 10), eleTy);
mlir::Type refSeqTy = fir::ReferenceType::get(seqTy);
- mlir::Value a = builder.create<fir::UndefOp>(loc, refSeqTy);
- mlir::Value result = builder.create<fir::UndefOp>(loc, seqTy);
- mlir::Value mask = builder.create<fir::UndefOp>(loc, seqTy);
+ mlir::Value a = fir::UndefOp::create(builder, loc, refSeqTy);
+ mlir::Value result = fir::UndefOp::create(builder, loc, seqTy);
+ mlir::Value mask = fir::UndefOp::create(builder, loc, seqTy);
mlir::Value kind = builder.createIntegerConstant(loc, i32Ty, 1);
mlir::Value back = builder.createIntegerConstant(loc, i32Ty, 1);
genFct(builder, loc, result, a, mask, kind, back);
@@ -308,9 +308,9 @@ void checkGenMxxlocDim(fir::FirOpBuilder &builder,
mlir::Type seqTy =
fir::SequenceType::get(fir::SequenceType::Shape(1, 10), i32Ty);
mlir::Type refSeqTy = fir::ReferenceType::get(seqTy);
- mlir::Value a = builder.create<fir::UndefOp>(loc, refSeqTy);
- mlir::Value result = builder.create<fir::UndefOp>(loc, seqTy);
- mlir::Value mask = builder.create<fir::UndefOp>(loc, seqTy);
+ mlir::Value a = fir::UndefOp::create(builder, loc, refSeqTy);
+ mlir::Value result = fir::UndefOp::create(builder, loc, seqTy);
+ mlir::Value mask = fir::UndefOp::create(builder, loc, seqTy);
mlir::Value kind = builder.createIntegerConstant(loc, i32Ty, 1);
mlir::Value dim = builder.createIntegerConstant(loc, i32Ty, 1);
mlir::Value back = builder.createIntegerConstant(loc, i32Ty, 1);
@@ -337,9 +337,9 @@ void checkGenMxxvalChar(fir::FirOpBuilder &builder,
mlir::Type seqTy =
fir::SequenceType::get(fir::SequenceType::Shape(1, 10), i32Ty);
mlir::Type refSeqTy = fir::ReferenceType::get(seqTy);
- mlir::Value a = builder.create<fir::UndefOp>(loc, refSeqTy);
- mlir::Value result = builder.create<fir::UndefOp>(loc, seqTy);
- mlir::Value mask = builder.create<fir::UndefOp>(loc, seqTy);
+ mlir::Value a = fir::UndefOp::create(builder, loc, refSeqTy);
+ mlir::Value result = fir::UndefOp::create(builder, loc, seqTy);
+ mlir::Value mask = fir::UndefOp::create(builder, loc, seqTy);
genFct(builder, loc, result, a, mask);
checkCallOpFromResultBox(result, fctName, nbArgs);
}
@@ -363,9 +363,9 @@ void checkGen4argsDim(fir::FirOpBuilder &builder,
mlir::Type seqTy =
fir::SequenceType::get(fir::SequenceType::Shape(1, 10), i32Ty);
mlir::Type refSeqTy = fir::ReferenceType::get(seqTy);
- mlir::Value a = builder.create<fir::UndefOp>(loc, refSeqTy);
- mlir::Value result = builder.create<fir::UndefOp>(loc, seqTy);
- mlir::Value mask = builder.create<fir::UndefOp>(loc, seqTy);
+ mlir::Value a = fir::UndefOp::create(builder, loc, refSeqTy);
+ mlir::Value result = fir::UndefOp::create(builder, loc, seqTy);
+ mlir::Value mask = fir::UndefOp::create(builder, loc, seqTy);
mlir::Value dim = builder.createIntegerConstant(loc, i32Ty, 1);
genFct(builder, loc, result, a, dim, mask);
checkCallOpFromResultBox(result, fctName, nbArgs);
diff --git a/flang/unittests/Optimizer/Builder/Runtime/RuntimeCallTestBase.h b/flang/unittests/Optimizer/Builder/Runtime/RuntimeCallTestBase.h
index 4ecec92..803ea37 100644
--- a/flang/unittests/Optimizer/Builder/Runtime/RuntimeCallTestBase.h
+++ b/flang/unittests/Optimizer/Builder/Runtime/RuntimeCallTestBase.h
@@ -24,10 +24,10 @@ public:
// Set up a Module with a dummy function operation inside.
// Set the insertion point in the function entry block.
- moduleOp = builder.create<mlir::ModuleOp>(loc);
+ moduleOp = mlir::ModuleOp::create(builder, loc);
builder.setInsertionPointToStart(moduleOp->getBody());
- mlir::func::FuncOp func = builder.create<mlir::func::FuncOp>(
- loc, "runtime_unit_tests_func", builder.getFunctionType({}, {}));
+ mlir::func::FuncOp func = mlir::func::FuncOp::create(builder, loc,
+ "runtime_unit_tests_func", builder.getFunctionType({}, {}));
auto *entryBlock = func.addEntryBlock();
builder.setInsertionPointToStart(entryBlock);
diff --git a/flang/unittests/Optimizer/Builder/Runtime/TransformationalTest.cpp b/flang/unittests/Optimizer/Builder/Runtime/TransformationalTest.cpp
index 28266bb..b8e8955 100644
--- a/flang/unittests/Optimizer/Builder/Runtime/TransformationalTest.cpp
+++ b/flang/unittests/Optimizer/Builder/Runtime/TransformationalTest.cpp
@@ -16,12 +16,12 @@ void testGenBesselJn(
mlir::Type i32Ty = builder.getIntegerType(32);
mlir::Type seqTy =
fir::SequenceType::get(fir::SequenceType::Shape(1, 10), realTy);
- mlir::Value result = builder.create<fir::UndefOp>(loc, seqTy);
- mlir::Value n1 = builder.create<fir::UndefOp>(loc, i32Ty);
- mlir::Value n2 = builder.create<fir::UndefOp>(loc, i32Ty);
- mlir::Value x = builder.create<fir::UndefOp>(loc, realTy);
- mlir::Value bn1 = builder.create<fir::UndefOp>(loc, realTy);
- mlir::Value bn2 = builder.create<fir::UndefOp>(loc, realTy);
+ mlir::Value result = fir::UndefOp::create(builder, loc, seqTy);
+ mlir::Value n1 = fir::UndefOp::create(builder, loc, i32Ty);
+ mlir::Value n2 = fir::UndefOp::create(builder, loc, i32Ty);
+ mlir::Value x = fir::UndefOp::create(builder, loc, realTy);
+ mlir::Value bn1 = fir::UndefOp::create(builder, loc, realTy);
+ mlir::Value bn2 = fir::UndefOp::create(builder, loc, realTy);
fir::runtime::genBesselJn(builder, loc, result, n1, n2, x, bn1, bn2);
checkCallOpFromResultBox(result, fctName, 6);
}
@@ -39,9 +39,9 @@ void testGenBesselJnX0(
mlir::Type i32Ty = builder.getIntegerType(32);
mlir::Type seqTy =
fir::SequenceType::get(fir::SequenceType::Shape(1, 10), realTy);
- mlir::Value result = builder.create<fir::UndefOp>(loc, seqTy);
- mlir::Value n1 = builder.create<fir::UndefOp>(loc, i32Ty);
- mlir::Value n2 = builder.create<fir::UndefOp>(loc, i32Ty);
+ mlir::Value result = fir::UndefOp::create(builder, loc, seqTy);
+ mlir::Value n1 = fir::UndefOp::create(builder, loc, i32Ty);
+ mlir::Value n2 = fir::UndefOp::create(builder, loc, i32Ty);
fir::runtime::genBesselJnX0(builder, loc, realTy, result, n1, n2);
checkCallOpFromResultBox(result, fctName, 3);
}
@@ -59,12 +59,12 @@ void testGenBesselYn(
mlir::Type i32Ty = builder.getIntegerType(32);
mlir::Type seqTy =
fir::SequenceType::get(fir::SequenceType::Shape(1, 10), realTy);
- mlir::Value result = builder.create<fir::UndefOp>(loc, seqTy);
- mlir::Value n1 = builder.create<fir::UndefOp>(loc, i32Ty);
- mlir::Value n2 = builder.create<fir::UndefOp>(loc, i32Ty);
- mlir::Value x = builder.create<fir::UndefOp>(loc, realTy);
- mlir::Value bn1 = builder.create<fir::UndefOp>(loc, realTy);
- mlir::Value bn2 = builder.create<fir::UndefOp>(loc, realTy);
+ mlir::Value result = fir::UndefOp::create(builder, loc, seqTy);
+ mlir::Value n1 = fir::UndefOp::create(builder, loc, i32Ty);
+ mlir::Value n2 = fir::UndefOp::create(builder, loc, i32Ty);
+ mlir::Value x = fir::UndefOp::create(builder, loc, realTy);
+ mlir::Value bn1 = fir::UndefOp::create(builder, loc, realTy);
+ mlir::Value bn2 = fir::UndefOp::create(builder, loc, realTy);
fir::runtime::genBesselYn(builder, loc, result, n1, n2, x, bn1, bn2);
checkCallOpFromResultBox(result, fctName, 6);
}
@@ -82,9 +82,9 @@ void testGenBesselYnX0(
mlir::Type i32Ty = builder.getIntegerType(32);
mlir::Type seqTy =
fir::SequenceType::get(fir::SequenceType::Shape(1, 10), realTy);
- mlir::Value result = builder.create<fir::UndefOp>(loc, seqTy);
- mlir::Value n1 = builder.create<fir::UndefOp>(loc, i32Ty);
- mlir::Value n2 = builder.create<fir::UndefOp>(loc, i32Ty);
+ mlir::Value result = fir::UndefOp::create(builder, loc, seqTy);
+ mlir::Value n1 = fir::UndefOp::create(builder, loc, i32Ty);
+ mlir::Value n2 = fir::UndefOp::create(builder, loc, i32Ty);
fir::runtime::genBesselYnX0(builder, loc, realTy, result, n1, n2);
checkCallOpFromResultBox(result, fctName, 3);
}
@@ -155,9 +155,9 @@ void testGenMatmul(fir::FirOpBuilder &builder, mlir::Type eleTy1,
fir::SequenceType::get(fir::SequenceType::Shape(2, 10), eleTy2);
mlir::Type boxTy1 = fir::BoxType::get(seqTy1);
mlir::Type boxTy2 = fir::BoxType::get(seqTy2);
- mlir::Value result = builder.create<fir::UndefOp>(loc, resultTy);
- mlir::Value matrixA = builder.create<fir::UndefOp>(loc, boxTy1);
- mlir::Value matrixB = builder.create<fir::UndefOp>(loc, boxTy2);
+ mlir::Value result = fir::UndefOp::create(builder, loc, resultTy);
+ mlir::Value matrixA = fir::UndefOp::create(builder, loc, boxTy1);
+ mlir::Value matrixB = fir::UndefOp::create(builder, loc, boxTy2);
fir::runtime::genMatmul(builder, loc, result, matrixA, matrixB);
checkCallOpFromResultBox(result, funcName, 3);
}