[Mlir-commits] [mlir] [mlir][SCF][NFC] `scf.for`/`scf.while`: rename builder args (PR #111493)

Matthias Springer llvmlistbot at llvm.org
Tue Oct 8 00:42:51 PDT 2024


https://github.com/matthias-springer created https://github.com/llvm/llvm-project/pull/111493

Rename builder args to make them consistent with the `args` in the TableGen definition.

>From 21bceb5123e23ad20f562ce2fed491e06925f63e Mon Sep 17 00:00:00 2001
From: Matthias Springer <mspringer at nvidia.com>
Date: Tue, 8 Oct 2024 09:40:29 +0200
Subject: [PATCH] [mlir][SCF][NFC] `scf.for`/`scf.while`: rename builder args

Rename builder args to make them consistent with the `args` in the TableGen definition.
---
 mlir/include/mlir/Dialect/SCF/IR/SCFOps.td |  4 ++--
 mlir/lib/Dialect/SCF/IR/SCF.cpp            | 22 +++++++++++-----------
 2 files changed, 13 insertions(+), 13 deletions(-)

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());
 



More information about the Mlir-commits mailing list