[flang-commits] [flang] [mlir][NFC] update `flang` create APIs (13/n) (#149687) (PR #149913)
Maksim Levental via flang-commits
flang-commits at lists.llvm.org
Mon Jul 21 14:58:57 PDT 2025
https://github.com/makslevental created https://github.com/llvm/llvm-project/pull/149913
See https://github.com/llvm/llvm-project/pull/147168 for more info.
>From c2805351265edb5dea16d7b770701e33a59ea0e4 Mon Sep 17 00:00:00 2001
From: max <maksim.levental at gmail.com>
Date: Mon, 21 Jul 2025 17:58:28 -0400
Subject: [PATCH] [mlir][NFC] update `flang` create APIs (13/n) (#149687)
See https://github.com/llvm/llvm-project/pull/147168 for more info.
---
flang/include/flang/Lower/DirectivesCommon.h | 36 ++++++-------
.../flang/Lower/Support/ReductionProcessor.h | 10 ++--
.../include/flang/Optimizer/Builder/Complex.h | 4 +-
.../Optimizer/Builder/DirectivesCommon.h | 44 ++++++++--------
.../flang/Optimizer/CodeGen/FIROpPatterns.h | 2 +-
.../unittests/Frontend/CodeGenActionTest.cpp | 2 +-
.../Optimizer/Builder/CharacterTest.cpp | 4 +-
.../Optimizer/Builder/ComplexTest.cpp | 4 +-
.../Optimizer/Builder/FIRBuilderTest.cpp | 42 ++++++++--------
.../Optimizer/Builder/HLFIRToolsTest.cpp | 14 +++---
.../Builder/Runtime/CharacterTest.cpp | 46 ++++++++---------
.../Optimizer/Builder/Runtime/NumericTest.cpp | 12 ++---
.../Builder/Runtime/ReductionTest.cpp | 50 +++++++++----------
.../Builder/Runtime/RuntimeCallTestBase.h | 4 +-
.../Builder/Runtime/TransformationalTest.cpp | 42 ++++++++--------
15 files changed, 158 insertions(+), 158 deletions(-)
diff --git a/flang/include/flang/Lower/DirectivesCommon.h b/flang/include/flang/Lower/DirectivesCommon.h
index 93ab2e350d035..c8d5780bcd9d7 100644
--- a/flang/include/flang/Lower/DirectivesCommon.h
+++ b/flang/include/flang/Lower/DirectivesCommon.h
@@ -193,26 +193,26 @@ 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>(
+ auto dimInfo = fir::BoxDimsOp::create(builder,
loc, idxTy, idxTy, idxTy, box, d);
- builder.create<fir::ResultOp>(loc, dimInfo.getByteStride());
+ 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 +242,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 +276,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 +310,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 +326,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 +335,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,7 +347,7 @@ genBoundsOps(fir::FirOpBuilder &builder, mlir::Location loc,
loc, cumulativeExtent, extent);
}
- mlir::Value bound = builder.create<BoundsOp>(
+ mlir::Value bound = BoundsOp::create(builder,
loc, boundTy, lbound, ubound, extent, stride, strideInBytes, baseLb);
bounds.push_back(bound);
++dimension;
@@ -461,7 +461,7 @@ fir::factory::AddrAndBoundsInfo gatherDataOperandAddrAndBounds(
asFortran << designator.AsFortran();
if (semantics::IsOptional(compRef->GetLastSymbol())) {
- info.isPresent = builder.create<fir::IsPresentOp>(
+ info.isPresent = fir::IsPresentOp::create(builder,
operandLocation, builder.getI1Type(), info.rawInput);
}
@@ -472,7 +472,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 72d8a0096f511..e97ebeca4ebc7 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 cd0a876a4cef0..063cd4b026f5e 100644
--- a/flang/include/flang/Optimizer/Builder/Complex.h
+++ b/flang/include/flang/Optimizer/Builder/Complex.h
@@ -58,7 +58,7 @@ class Complex {
protected:
template <Part partId>
mlir::Value extract(mlir::Value cplx) {
- return builder.create<fir::ExtractValueOp>(
+ return fir::ExtractValueOp::create(builder,
loc, getComplexPartType(cplx), cplx,
builder.getArrayAttr({builder.getIntegerAttr(
builder.getIndexType(), static_cast<int>(partId))}));
@@ -66,7 +66,7 @@ class Complex {
template <Part partId>
mlir::Value insert(mlir::Value cplx, mlir::Value part) {
- return builder.create<fir::InsertValueOp>(
+ 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 78c1bb359c804..8c9b22a1342f2 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,12 +130,12 @@ gatherBoundsOrBoundValues(fir::FirOpBuilder &builder, mlir::Location loc,
values.push_back(byteStride);
values.push_back(baseLb);
} else {
- mlir::Value bound = builder.create<BoundsOp>(
+ 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,
+ byteStride = mlir::arith::MulIOp::create(builder, loc, byteStride,
dimInfo.getExtent());
}
return values;
@@ -162,20 +162,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>(
+ 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,19 +183,19 @@ 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,
+ return BoundsOp::create(builder, loc, boundTy,
/*lower_bound=*/zero,
/*upper_bound=*/ub,
/*extent=*/extent,
@@ -230,12 +230,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,13 +249,13 @@ 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>(
+ 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);
@@ -263,7 +263,7 @@ genBoundsOpsFromBox(fir::FirOpBuilder &builder, mlir::Location loc,
} 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 +299,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,7 +308,7 @@ genBaseBoundsOps(fir::FirOpBuilder &builder, mlir::Location loc,
loc, cumulativeExtent, extent);
}
- mlir::Value bound = builder.create<BoundsOp>(loc, boundTy, lb, ub, extent,
+ mlir::Value bound = BoundsOp::create(builder, loc, boundTy, lb, ub, extent,
stride, false, baseLb);
bounds.push_back(bound);
}
diff --git a/flang/include/flang/Optimizer/CodeGen/FIROpPatterns.h b/flang/include/flang/Optimizer/CodeGen/FIROpPatterns.h
index cbdcf6b501b8e..b7fa8fc3848f2 100644
--- a/flang/include/flang/Optimizer/CodeGen/FIROpPatterns.h
+++ b/flang/include/flang/Optimizer/CodeGen/FIROpPatterns.h
@@ -144,7 +144,7 @@ class ConvertFIRToLLVMPattern : public mlir::ConvertToLLVMPattern {
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 6020abc463eda..419a76f218f28 100644
--- a/flang/unittests/Frontend/CodeGenActionTest.cpp
+++ b/flang/unittests/Frontend/CodeGenActionTest.cpp
@@ -77,7 +77,7 @@ class LLVMConversionFailureCodeGenAction : public CodeGenAction {
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 d8d2da40ba9a6..824bcbb11c7cf 100644
--- a/flang/unittests/Optimizer/Builder/CharacterTest.cpp
+++ b/flang/unittests/Optimizer/Builder/CharacterTest.cpp
@@ -26,9 +26,9 @@ struct CharacterTest : public testing::Test {
// 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>(
+ 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 d5f00c9b61108..1794e69e915a1 100644
--- a/flang/unittests/Optimizer/Builder/ComplexTest.cpp
+++ b/flang/unittests/Optimizer/Builder/ComplexTest.cpp
@@ -22,9 +22,9 @@ struct ComplexTest : public testing::Test {
// 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>(
+ 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 e4c21f6b65a36..1c54c6ed33962 100644
--- a/flang/unittests/Optimizer/Builder/FIRBuilderTest.cpp
+++ b/flang/unittests/Optimizer/Builder/FIRBuilderTest.cpp
@@ -26,9 +26,9 @@ struct FIRBuilderTest : public testing::Test {
// 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>(
+ mlir::func::FuncOp func = mlir::func::FuncOp::create(builder,
loc, "func1", builder.getFunctionType({}, {}));
auto *entryBlock = func.addEntryBlock();
builder.setInsertionPointToStart(entryBlock);
@@ -47,7 +47,7 @@ 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>(
+ return arith::CmpIOp::create(builder,
loc, arith::CmpIPredicate::eq, zero1, zero2);
}
@@ -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 a0785198b078d..783b2a38266a9 100644
--- a/flang/unittests/Optimizer/Builder/HLFIRToolsTest.cpp
+++ b/flang/unittests/Optimizer/Builder/HLFIRToolsTest.cpp
@@ -25,9 +25,9 @@ struct HLFIRToolsTest : public testing::Test {
// 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>(
+ 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 315f8c80dc33f..cfd2d489ac578 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 47342da07f060..0e867e98a5eef 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 a4006c6b59c12..91e2d0b41cd47 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 4ecec92f42dc2..37f97df0352f7 100644
--- a/flang/unittests/Optimizer/Builder/Runtime/RuntimeCallTestBase.h
+++ b/flang/unittests/Optimizer/Builder/Runtime/RuntimeCallTestBase.h
@@ -24,9 +24,9 @@ struct RuntimeCallTest : public testing::Test {
// 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>(
+ 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 28266bb90400b..b8e89556f1fc8 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);
}
More information about the flang-commits
mailing list