[Mlir-commits] [mlir] [mlir][SCF][NFC] `scf.for`/`scf.while`: rename builder args (PR #111493)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Tue Oct 8 00:43:24 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-mlir-scf
Author: Matthias Springer (matthias-springer)
<details>
<summary>Changes</summary>
Rename builder args to make them consistent with the `args` in the TableGen definition.
---
Full diff: https://github.com/llvm/llvm-project/pull/111493.diff
2 Files Affected:
- (modified) mlir/include/mlir/Dialect/SCF/IR/SCFOps.td (+2-2)
- (modified) mlir/lib/Dialect/SCF/IR/SCF.cpp (+11-11)
``````````diff
diff --git a/mlir/include/mlir/Dialect/SCF/IR/SCFOps.td b/mlir/include/mlir/Dialect/SCF/IR/SCFOps.td
index 847040466a85fd..361f8e0cf79ec6 100644
--- a/mlir/include/mlir/Dialect/SCF/IR/SCFOps.td
+++ b/mlir/include/mlir/Dialect/SCF/IR/SCFOps.td
@@ -249,7 +249,7 @@ def ForOp : SCF_Op<"for",
let skipDefaultBuilders = 1;
let builders = [
OpBuilder<(ins "Value":$lowerBound, "Value":$upperBound, "Value":$step,
- CArg<"ValueRange", "std::nullopt">:$iterArgs,
+ CArg<"ValueRange", "std::nullopt">:$initArgs,
CArg<"function_ref<void(OpBuilder &, Location, Value, ValueRange)>",
"nullptr">)>
];
@@ -1074,7 +1074,7 @@ def WhileOp : SCF_Op<"while",
let regions = (region SizedRegion<1>:$before, SizedRegion<1>:$after);
let builders = [
- OpBuilder<(ins "TypeRange":$resultTypes, "ValueRange":$operands,
+ OpBuilder<(ins "TypeRange":$resultTypes, "ValueRange":$inits,
"function_ref<void(OpBuilder &, Location, ValueRange)>":$beforeBuilder,
"function_ref<void(OpBuilder &, Location, ValueRange)>":$afterBuilder)>
];
diff --git a/mlir/lib/Dialect/SCF/IR/SCF.cpp b/mlir/lib/Dialect/SCF/IR/SCF.cpp
index d1c9fd2d217dad..2582d4e0df1920 100644
--- a/mlir/lib/Dialect/SCF/IR/SCF.cpp
+++ b/mlir/lib/Dialect/SCF/IR/SCF.cpp
@@ -312,25 +312,25 @@ void ConditionOp::getSuccessorRegions(
//===----------------------------------------------------------------------===//
void ForOp::build(OpBuilder &builder, OperationState &result, Value lb,
- Value ub, Value step, ValueRange iterArgs,
+ Value ub, Value step, ValueRange initArgs,
BodyBuilderFn bodyBuilder) {
OpBuilder::InsertionGuard guard(builder);
result.addOperands({lb, ub, step});
- result.addOperands(iterArgs);
- for (Value v : iterArgs)
+ result.addOperands(initArgs);
+ for (Value v : initArgs)
result.addTypes(v.getType());
Type t = lb.getType();
Region *bodyRegion = result.addRegion();
Block *bodyBlock = builder.createBlock(bodyRegion);
bodyBlock->addArgument(t, result.location);
- for (Value v : iterArgs)
+ for (Value v : initArgs)
bodyBlock->addArgument(v.getType(), v.getLoc());
// Create the default terminator if the builder is not provided and if the
// iteration arguments are not provided. Otherwise, leave this to the caller
// because we don't know which values to return from the loop.
- if (iterArgs.empty() && !bodyBuilder) {
+ if (initArgs.empty() && !bodyBuilder) {
ForOp::ensureTerminator(*bodyRegion, builder, result.location);
} else if (bodyBuilder) {
OpBuilder::InsertionGuard guard(builder);
@@ -3260,23 +3260,23 @@ LogicalResult ReduceReturnOp::verify() {
void WhileOp::build(::mlir::OpBuilder &odsBuilder,
::mlir::OperationState &odsState, TypeRange resultTypes,
- ValueRange operands, BodyBuilderFn beforeBuilder,
+ ValueRange inits, BodyBuilderFn beforeBuilder,
BodyBuilderFn afterBuilder) {
- odsState.addOperands(operands);
+ odsState.addOperands(inits);
odsState.addTypes(resultTypes);
OpBuilder::InsertionGuard guard(odsBuilder);
// Build before region.
SmallVector<Location, 4> beforeArgLocs;
- beforeArgLocs.reserve(operands.size());
- for (Value operand : operands) {
+ beforeArgLocs.reserve(inits.size());
+ for (Value operand : inits) {
beforeArgLocs.push_back(operand.getLoc());
}
Region *beforeRegion = odsState.addRegion();
- Block *beforeBlock = odsBuilder.createBlock(
- beforeRegion, /*insertPt=*/{}, operands.getTypes(), beforeArgLocs);
+ Block *beforeBlock = odsBuilder.createBlock(beforeRegion, /*insertPt=*/{},
+ inits.getTypes(), beforeArgLocs);
if (beforeBuilder)
beforeBuilder(odsBuilder, odsState.location, beforeBlock->getArguments());
``````````
</details>
https://github.com/llvm/llvm-project/pull/111493
More information about the Mlir-commits
mailing list