Skip to content

[mlir] Migrate away from {TypeRange,ValueRange}(std::nullopt) (NFC) #145445

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 11 additions & 14 deletions mlir/include/mlir/Dialect/Affine/IR/AffineOps.td
Original file line number Diff line number Diff line change
Expand Up @@ -243,17 +243,16 @@ def AffineForOp : Affine_Op<"for",
let regions = (region SizedRegion<1>:$region);

let skipDefaultBuilders = 1;
let builders = [
OpBuilder<(ins "int64_t":$lowerBound, "int64_t":$upperBound,
CArg<"int64_t", "1">:$step, CArg<"ValueRange", "std::nullopt">:$iterArgs,
CArg<"function_ref<void(OpBuilder &, Location, Value, ValueRange)>",
"nullptr">:$bodyBuilder)>,
OpBuilder<(ins "ValueRange":$lbOperands, "AffineMap":$lbMap,
"ValueRange":$ubOperands, "AffineMap":$ubMap, CArg<"int64_t", "1">:$step,
CArg<"ValueRange", "std::nullopt">:$iterArgs,
CArg<"function_ref<void(OpBuilder &, Location, Value, ValueRange)>",
"nullptr">:$bodyBuilder)>
];
let builders =
[OpBuilder<(ins "int64_t":$lowerBound, "int64_t":$upperBound,
CArg<"int64_t", "1">:$step, CArg<"ValueRange", "{}">:$iterArgs,
CArg<"function_ref<void(OpBuilder &, Location, Value, ValueRange)>",
"nullptr">:$bodyBuilder)>,
OpBuilder<(ins "ValueRange":$lbOperands, "AffineMap":$lbMap,
"ValueRange":$ubOperands, "AffineMap":$ubMap,
CArg<"int64_t", "1">:$step, CArg<"ValueRange", "{}">:$iterArgs,
CArg<"function_ref<void(OpBuilder &, Location, Value, ValueRange)>",
"nullptr">:$bodyBuilder)>];

let extraClassDeclaration = [{
/// Defining the function type we use for building the body of affine.for.
Expand Down Expand Up @@ -920,9 +919,7 @@ def AffineYieldOp : Affine_Op<"yield", [Pure, Terminator, ReturnLike,

let arguments = (ins Variadic<AnyType>:$operands);

let builders = [
OpBuilder<(ins), [{ build($_builder, $_state, std::nullopt); }]>
];
let builders = [OpBuilder<(ins), [{ build($_builder, $_state, {}); }]>];

let assemblyFormat = "attr-dict ($operands^ `:` type($operands))?";
let hasVerifier = 1;
Expand Down
2 changes: 1 addition & 1 deletion mlir/include/mlir/Dialect/Async/IR/AsyncOps.td
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ def Async_ReturnOp : Async_Op<"return",

let arguments = (ins Variadic<AnyType>:$operands);

let builders = [OpBuilder<(ins), [{build($_builder, $_state, std::nullopt);}]>];
let builders = [OpBuilder<(ins), [{build($_builder, $_state, {});}]>];

let assemblyFormat = "attr-dict ($operands^ `:` type($operands))?";
let hasVerifier = 1;
Expand Down
2 changes: 1 addition & 1 deletion mlir/include/mlir/Dialect/Func/IR/FuncOps.td
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ def ReturnOp : Func_Op<"return", [Pure, HasParent<"FuncOp">,
let arguments = (ins Variadic<AnyType>:$operands);

let builders = [OpBuilder<(ins), [{
build($_builder, $_state, std::nullopt);
build($_builder, $_state, {});
}]>];

let assemblyFormat = "attr-dict ($operands^ `:` type($operands))?";
Expand Down
4 changes: 2 additions & 2 deletions mlir/include/mlir/Dialect/MLProgram/IR/MLProgramOps.td
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,7 @@ def MLProgram_OutputOp : MLProgram_Op<"output", [
let arguments = (ins Variadic<AnyType>:$operands);

let builders = [OpBuilder<(ins), [{
build($_builder, $_state, std::nullopt);
build($_builder, $_state, {});
}]>];

let assemblyFormat = "attr-dict ($operands^ `:` type($operands))?";
Expand All @@ -488,7 +488,7 @@ def MLProgram_ReturnOp : MLProgram_Op<"return", [
let arguments = (ins Variadic<AnyType>:$operands);

let builders = [OpBuilder<(ins), [{
build($_builder, $_state, std::nullopt);
build($_builder, $_state, {});
}]>];

let assemblyFormat = "attr-dict ($operands^ `:` type($operands))?";
Expand Down
8 changes: 3 additions & 5 deletions mlir/include/mlir/Dialect/SCF/IR/SCFOps.td
Original file line number Diff line number Diff line change
Expand Up @@ -248,12 +248,10 @@ def ForOp : SCF_Op<"for",
let regions = (region SizedRegion<1>:$region);

let skipDefaultBuilders = 1;
let builders = [
OpBuilder<(ins "Value":$lowerBound, "Value":$upperBound, "Value":$step,
CArg<"ValueRange", "std::nullopt">:$initArgs,
let builders = [OpBuilder<(ins "Value":$lowerBound, "Value":$upperBound,
"Value":$step, CArg<"ValueRange", "{}">:$initArgs,
CArg<"function_ref<void(OpBuilder &, Location, Value, ValueRange)>",
"nullptr">)>
];
"nullptr">)>];

let extraClassDeclaration = [{
using BodyBuilderFn =
Expand Down
2 changes: 1 addition & 1 deletion mlir/include/mlir/Dialect/SMT/IR/SMTOps.td
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ def YieldOp : SMTOp<"yield", [
let arguments = (ins Variadic<AnyType>:$values);
let assemblyFormat = "($values^ `:` qualified(type($values)))? attr-dict";
let builders = [OpBuilder<(ins), [{
build($_builder, $_state, std::nullopt);
build($_builder, $_state, {});
}]>];
}

Expand Down
4 changes: 1 addition & 3 deletions mlir/include/mlir/Dialect/Shape/IR/ShapeOps.td
Original file line number Diff line number Diff line change
Expand Up @@ -678,9 +678,7 @@ def Shape_YieldOp : Shape_Op<"yield",

let arguments = (ins Variadic<AnyType>:$operands);

let builders = [OpBuilder<(ins),
[{ build($_builder, $_state, std::nullopt); }]>
];
let builders = [OpBuilder<(ins), [{ build($_builder, $_state, {}); }]>];

let assemblyFormat = "attr-dict ($operands^ `:` type($operands))?";
let hasVerifier = 1;
Expand Down
3 changes: 1 addition & 2 deletions mlir/lib/Conversion/GPUToSPIRV/GPUToSPIRV.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -251,8 +251,7 @@ lowerAsEntryFunction(gpu::GPUFuncOp funcOp, const TypeConverter &typeConverter,
}
auto newFuncOp = rewriter.create<spirv::FuncOp>(
funcOp.getLoc(), funcOp.getName(),
rewriter.getFunctionType(signatureConverter.getConvertedTypes(),
std::nullopt));
rewriter.getFunctionType(signatureConverter.getConvertedTypes(), {}));
for (const auto &namedAttr : funcOp->getAttrs()) {
if (namedAttr.getName() == funcOp.getFunctionTypeAttrName() ||
namedAttr.getName() == SymbolTable::getSymbolAttrName())
Expand Down
6 changes: 3 additions & 3 deletions mlir/lib/Conversion/PDLToPDLInterp/PDLToPDLInterp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -636,7 +636,7 @@ SymbolRefAttr PatternLowering::generateRewriter(
builder.setInsertionPointToEnd(rewriterModule.getBody());
auto rewriterFunc = builder.create<pdl_interp::FuncOp>(
pattern.getLoc(), "pdl_generated_rewriter",
builder.getFunctionType(std::nullopt, std::nullopt));
builder.getFunctionType({}, {}));
rewriterSymbolTable.insert(rewriterFunc);

// Generate the rewriter function body.
Expand Down Expand Up @@ -703,7 +703,7 @@ SymbolRefAttr PatternLowering::generateRewriter(
// Update the signature of the rewrite function.
rewriterFunc.setType(builder.getFunctionType(
llvm::to_vector<8>(rewriterFunc.front().getArgumentTypes()),
/*results=*/std::nullopt));
/*results=*/{}));

builder.create<pdl_interp::FinalizeOp>(rewriter.getLoc());
return SymbolRefAttr::get(
Expand Down Expand Up @@ -990,7 +990,7 @@ void PDLToPDLInterpPass::runOnOperation() {
auto matcherFunc = builder.create<pdl_interp::FuncOp>(
module.getLoc(), pdl_interp::PDLInterpDialect::getMatcherFunctionName(),
builder.getFunctionType(builder.getType<pdl::OperationType>(),
/*results=*/std::nullopt),
/*results=*/{}),
/*attrs=*/std::nullopt);

// Create a nested module to hold the functions invoked for rewriting the IR
Expand Down
2 changes: 1 addition & 1 deletion mlir/lib/Dialect/GPU/IR/GPUDialect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2302,7 +2302,7 @@ void WarpExecuteOnLane0Op::build(OpBuilder &builder, OperationState &result,
TypeRange resultTypes, Value laneId,
int64_t warpSize) {
build(builder, result, resultTypes, laneId, warpSize,
/*operands=*/std::nullopt, /*argTypes=*/std::nullopt);
/*operands=*/{}, /*argTypes=*/{});
}

void WarpExecuteOnLane0Op::build(OpBuilder &builder, OperationState &result,
Expand Down
2 changes: 1 addition & 1 deletion mlir/lib/Dialect/SCF/IR/SCF.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -769,7 +769,7 @@ LoopNest mlir::scf::buildLoopNest(
ValueRange steps,
function_ref<void(OpBuilder &, Location, ValueRange)> bodyBuilder) {
// Delegate to the main function by wrapping the body builder.
return buildLoopNest(builder, loc, lbs, ubs, steps, std::nullopt,
return buildLoopNest(builder, loc, lbs, ubs, steps, {},
[&bodyBuilder](OpBuilder &nestedBuilder,
Location nestedLoc, ValueRange ivs,
ValueRange) -> ValueVector {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -282,8 +282,8 @@ LogicalResult ProcessInterfaceVarABI::matchAndRewrite(

// Creates a new function with the update signature.
rewriter.modifyOpInPlace(funcOp, [&] {
funcOp.setType(rewriter.getFunctionType(
signatureConverter.getConvertedTypes(), std::nullopt));
funcOp.setType(
rewriter.getFunctionType(signatureConverter.getConvertedTypes(), {}));
});
return success();
}
Expand Down
6 changes: 3 additions & 3 deletions mlir/unittests/Debug/FileLineColLocBreakpointManagerTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ static Operation *createOp(MLIRContext *context, Location loc,
StringRef operationName,
unsigned int numRegions = 0) {
context->allowUnregisteredDialects();
return Operation::create(loc, OperationName(operationName, context),
std::nullopt, std::nullopt, std::nullopt,
OpaqueProperties(nullptr), std::nullopt, numRegions);
return Operation::create(loc, OperationName(operationName, context), {}, {},
std::nullopt, OpaqueProperties(nullptr),
std::nullopt, numRegions);
}

namespace {
Expand Down
6 changes: 3 additions & 3 deletions mlir/unittests/IR/OperationSupportTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ TEST(OperandStorageTest, NonResizable) {
EXPECT_EQ(user->getNumOperands(), 1u);

// Removing is okay.
user->setOperands(std::nullopt);
user->setOperands({});
EXPECT_EQ(user->getNumOperands(), 0u);

// Destroy the operations.
Expand All @@ -68,7 +68,7 @@ TEST(OperandStorageTest, Resizable) {
EXPECT_EQ(user->getNumOperands(), 1u);

// Removing is okay.
user->setOperands(std::nullopt);
user->setOperands({});
EXPECT_EQ(user->getNumOperands(), 0u);

// Adding more operands is okay.
Expand Down Expand Up @@ -236,7 +236,7 @@ TEST(OperationFormatPrintTest, CanPrintNameAsPrefix) {
context.allowUnregisteredDialects();
Operation *op = Operation::create(
NameLoc::get(StringAttr::get(&context, "my_named_loc")),
OperationName("t.op", &context), builder.getIntegerType(16), std::nullopt,
OperationName("t.op", &context), builder.getIntegerType(16), {},
std::nullopt, nullptr, std::nullopt, 0);

std::string str;
Expand Down
10 changes: 4 additions & 6 deletions mlir/unittests/Pass/AnalysisManagerTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,8 @@ TEST(AnalysisManagerTest, FineGrainFunctionAnalysisPreservation) {

// Create a function and a module.
OwningOpRef<ModuleOp> module(ModuleOp::create(UnknownLoc::get(&context)));
func::FuncOp func1 =
func::FuncOp::create(builder.getUnknownLoc(), "foo",
builder.getFunctionType(std::nullopt, std::nullopt));
func::FuncOp func1 = func::FuncOp::create(builder.getUnknownLoc(), "foo",
builder.getFunctionType({}, {}));
func1.setPrivate();
module->push_back(func1);

Expand Down Expand Up @@ -94,9 +93,8 @@ TEST(AnalysisManagerTest, FineGrainChildFunctionAnalysisPreservation) {

// Create a function and a module.
OwningOpRef<ModuleOp> module(ModuleOp::create(UnknownLoc::get(&context)));
func::FuncOp func1 =
func::FuncOp::create(builder.getUnknownLoc(), "foo",
builder.getFunctionType(std::nullopt, std::nullopt));
func::FuncOp func1 = func::FuncOp::create(builder.getUnknownLoc(), "foo",
builder.getFunctionType({}, {}));
func1.setPrivate();
module->push_back(func1);

Expand Down
10 changes: 4 additions & 6 deletions mlir/unittests/Pass/PassManagerTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,8 @@ TEST(PassManagerTest, OpSpecificAnalysis) {
// Create a module with 2 functions.
OwningOpRef<ModuleOp> module(ModuleOp::create(UnknownLoc::get(&context)));
for (StringRef name : {"secret", "not_secret"}) {
auto func = func::FuncOp::create(
builder.getUnknownLoc(), name,
builder.getFunctionType(std::nullopt, std::nullopt));
auto func = func::FuncOp::create(builder.getUnknownLoc(), name,
builder.getFunctionType({}, {}));
func.setPrivate();
module->push_back(func);
}
Expand Down Expand Up @@ -125,9 +124,8 @@ TEST(PassManagerTest, ExecutionAction) {

// Create a module with 2 functions.
OwningOpRef<ModuleOp> module(ModuleOp::create(UnknownLoc::get(&context)));
auto f =
func::FuncOp::create(builder.getUnknownLoc(), "process_me_once",
builder.getFunctionType(std::nullopt, std::nullopt));
auto f = func::FuncOp::create(builder.getUnknownLoc(), "process_me_once",
builder.getFunctionType({}, {}));
f.setPrivate();
module->push_back(f);

Expand Down
4 changes: 2 additions & 2 deletions mlir/unittests/Transforms/DialectConversion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ using namespace mlir;
static Operation *createOp(MLIRContext *context) {
context->allowUnregisteredDialects();
return Operation::create(
UnknownLoc::get(context), OperationName("foo.bar", context), std::nullopt,
std::nullopt, std::nullopt, /*properties=*/nullptr, std::nullopt, 0);
UnknownLoc::get(context), OperationName("foo.bar", context), {}, {},
std::nullopt, /*properties=*/nullptr, std::nullopt, 0);
}

namespace {
Expand Down
Loading