[Mlir-commits] [mlir] ccfcfa9 - [mlir:Toy][NFC] Switch toy to use prefixed accessors

River Riddle llvmlistbot at llvm.org
Tue Mar 15 17:40:26 PDT 2022


Author: River Riddle
Date: 2022-03-15T17:36:36-07:00
New Revision: ccfcfa942345018535a26cdd5ac3cb988bba9062

URL: https://github.com/llvm/llvm-project/commit/ccfcfa942345018535a26cdd5ac3cb988bba9062
DIFF: https://github.com/llvm/llvm-project/commit/ccfcfa942345018535a26cdd5ac3cb988bba9062.diff

LOG: [mlir:Toy][NFC] Switch toy to use prefixed accessors

Added: 
    

Modified: 
    mlir/examples/toy/Ch2/include/toy/Ops.td
    mlir/examples/toy/Ch2/mlir/Dialect.cpp
    mlir/examples/toy/Ch3/include/toy/Ops.td
    mlir/examples/toy/Ch3/mlir/Dialect.cpp
    mlir/examples/toy/Ch4/include/toy/Ops.td
    mlir/examples/toy/Ch4/mlir/Dialect.cpp
    mlir/examples/toy/Ch5/include/toy/Ops.td
    mlir/examples/toy/Ch5/mlir/Dialect.cpp
    mlir/examples/toy/Ch5/mlir/LowerToAffineLoops.cpp
    mlir/examples/toy/Ch6/include/toy/Ops.td
    mlir/examples/toy/Ch6/mlir/Dialect.cpp
    mlir/examples/toy/Ch6/mlir/LowerToAffineLoops.cpp
    mlir/examples/toy/Ch6/mlir/LowerToLLVM.cpp
    mlir/examples/toy/Ch7/include/toy/Ops.td
    mlir/examples/toy/Ch7/mlir/Dialect.cpp
    mlir/examples/toy/Ch7/mlir/LowerToAffineLoops.cpp
    mlir/examples/toy/Ch7/mlir/LowerToLLVM.cpp
    mlir/examples/toy/Ch7/mlir/ToyCombine.cpp

Removed: 
    


################################################################################
diff  --git a/mlir/examples/toy/Ch2/include/toy/Ops.td b/mlir/examples/toy/Ch2/include/toy/Ops.td
index c00a490ddbe12..e59d4d5c7d988 100644
--- a/mlir/examples/toy/Ch2/include/toy/Ops.td
+++ b/mlir/examples/toy/Ch2/include/toy/Ops.td
@@ -23,6 +23,7 @@ include "mlir/Interfaces/SideEffectInterfaces.td"
 def Toy_Dialect : Dialect {
   let name = "toy";
   let cppNamespace = "::mlir::toy";
+  let emitAccessorPrefix = kEmitAccessorPrefix_Prefixed;
 }
 
 // Base class for toy dialect operations. This operation inherits from the base
@@ -143,21 +144,15 @@ def FuncOp : Toy_Op<"func", [
     CArg<"ArrayRef<NamedAttribute>", "{}">:$attrs)
   >];
   let extraClassDeclaration = [{
-    /// Returns the type of this function.
-    /// FIXME: We should drive this via the ODS `type` param.
-    FunctionType getType() { 
-      return getTypeAttr().getValue().cast<FunctionType>();
-    }
-
     //===------------------------------------------------------------------===//
     // FunctionOpInterface Methods
     //===------------------------------------------------------------------===//
 
     /// Returns the argument types of this function.
-    ArrayRef<Type> getArgumentTypes() { return type().getInputs(); }
+    ArrayRef<Type> getArgumentTypes() { return getType().getInputs(); }
 
     /// Returns the result types of this function.
-    ArrayRef<Type> getResultTypes() { return type().getResults(); }
+    ArrayRef<Type> getResultTypes() { return getType().getResults(); }
   }];
   let hasCustomAssemblyFormat = 1;
   let skipDefaultBuilders = 1;

diff  --git a/mlir/examples/toy/Ch2/mlir/Dialect.cpp b/mlir/examples/toy/Ch2/mlir/Dialect.cpp
index f1fedcb701525..0727f9466b80a 100644
--- a/mlir/examples/toy/Ch2/mlir/Dialect.cpp
+++ b/mlir/examples/toy/Ch2/mlir/Dialect.cpp
@@ -125,7 +125,7 @@ mlir::ParseResult ConstantOp::parse(mlir::OpAsmParser &parser,
 void ConstantOp::print(mlir::OpAsmPrinter &printer) {
   printer << " ";
   printer.printOptionalAttrDict((*this)->getAttrs(), /*elidedAttrs=*/{"value"});
-  printer << value();
+  printer << getValue();
 }
 
 /// Verifier for the constant operation. This corresponds to the
@@ -139,7 +139,7 @@ mlir::LogicalResult ConstantOp::verify() {
 
   // Check that the rank of the attribute type matches the rank of the constant
   // result type.
-  auto attrType = value().getType().cast<mlir::TensorType>();
+  auto attrType = getValue().getType().cast<mlir::TensorType>();
   if (attrType.getRank() != resultType.getRank()) {
     return emitOpError("return type must match the one of the attached value "
                        "attribute: ")

diff  --git a/mlir/examples/toy/Ch3/include/toy/Ops.td b/mlir/examples/toy/Ch3/include/toy/Ops.td
index 0ceec6cbd884c..a52d827219d1f 100644
--- a/mlir/examples/toy/Ch3/include/toy/Ops.td
+++ b/mlir/examples/toy/Ch3/include/toy/Ops.td
@@ -22,6 +22,7 @@ include "mlir/Interfaces/SideEffectInterfaces.td"
 def Toy_Dialect : Dialect {
   let name = "toy";
   let cppNamespace = "::mlir::toy";
+  let emitAccessorPrefix = kEmitAccessorPrefix_Prefixed;
 }
 
 // Base class for toy dialect operations. This operation inherits from the base
@@ -142,21 +143,15 @@ def FuncOp : Toy_Op<"func", [
     CArg<"ArrayRef<NamedAttribute>", "{}">:$attrs)
   >];
   let extraClassDeclaration = [{
-    /// Returns the type of this function.
-    /// FIXME: We should drive this via the ODS `type` param.
-    FunctionType getType() { 
-      return getTypeAttr().getValue().cast<FunctionType>();
-    }
-
     //===------------------------------------------------------------------===//
     // FunctionOpInterface Methods
     //===------------------------------------------------------------------===//
 
     /// Returns the argument types of this function.
-    ArrayRef<Type> getArgumentTypes() { return type().getInputs(); }
+    ArrayRef<Type> getArgumentTypes() { return getType().getInputs(); }
 
     /// Returns the result types of this function.
-    ArrayRef<Type> getResultTypes() { return type().getResults(); }
+    ArrayRef<Type> getResultTypes() { return getType().getResults(); }
   }];
   let hasCustomAssemblyFormat = 1;
   let skipDefaultBuilders = 1;

diff  --git a/mlir/examples/toy/Ch3/mlir/Dialect.cpp b/mlir/examples/toy/Ch3/mlir/Dialect.cpp
index b3c5c8fee647d..c4f851c408ef1 100644
--- a/mlir/examples/toy/Ch3/mlir/Dialect.cpp
+++ b/mlir/examples/toy/Ch3/mlir/Dialect.cpp
@@ -125,7 +125,7 @@ mlir::ParseResult ConstantOp::parse(mlir::OpAsmParser &parser,
 void ConstantOp::print(mlir::OpAsmPrinter &printer) {
   printer << " ";
   printer.printOptionalAttrDict((*this)->getAttrs(), /*elidedAttrs=*/{"value"});
-  printer << value();
+  printer << getValue();
 }
 
 /// Verifier for the constant operation. This corresponds to the
@@ -139,7 +139,7 @@ mlir::LogicalResult ConstantOp::verify() {
 
   // Check that the rank of the attribute type matches the rank of the constant
   // result type.
-  auto attrType = value().getType().cast<mlir::TensorType>();
+  auto attrType = getValue().getType().cast<mlir::TensorType>();
   if (attrType.getRank() != resultType.getRank()) {
     return emitOpError("return type must match the one of the attached value "
                        "attribute: ")

diff  --git a/mlir/examples/toy/Ch4/include/toy/Ops.td b/mlir/examples/toy/Ch4/include/toy/Ops.td
index df32a353b7abe..c535fff829ee5 100644
--- a/mlir/examples/toy/Ch4/include/toy/Ops.td
+++ b/mlir/examples/toy/Ch4/include/toy/Ops.td
@@ -25,6 +25,7 @@ include "toy/ShapeInferenceInterface.td"
 def Toy_Dialect : Dialect {
   let name = "toy";
   let cppNamespace = "::mlir::toy";
+  let emitAccessorPrefix = kEmitAccessorPrefix_Prefixed;
 }
 
 // Base class for toy dialect operations. This operation inherits from the base
@@ -172,21 +173,15 @@ def FuncOp : Toy_Op<"func", [
     CArg<"ArrayRef<NamedAttribute>", "{}">:$attrs)
   >];
   let extraClassDeclaration = [{
-    /// Returns the type of this function.
-    /// FIXME: We should drive this via the ODS `type` param.
-    FunctionType getType() { 
-      return getTypeAttr().getValue().cast<FunctionType>();
-    }
-
     //===------------------------------------------------------------------===//
     // FunctionOpInterface Methods
     //===------------------------------------------------------------------===//
 
     /// Returns the argument types of this function.
-    ArrayRef<Type> getArgumentTypes() { return type().getInputs(); }
+    ArrayRef<Type> getArgumentTypes() { return getType().getInputs(); }
 
     /// Returns the result types of this function.
-    ArrayRef<Type> getResultTypes() { return type().getResults(); }
+    ArrayRef<Type> getResultTypes() { return getType().getResults(); }
   }];
   let hasCustomAssemblyFormat = 1;
   let skipDefaultBuilders = 1;

diff  --git a/mlir/examples/toy/Ch4/mlir/Dialect.cpp b/mlir/examples/toy/Ch4/mlir/Dialect.cpp
index 74ec486554c17..3d6effdd26a9f 100644
--- a/mlir/examples/toy/Ch4/mlir/Dialect.cpp
+++ b/mlir/examples/toy/Ch4/mlir/Dialect.cpp
@@ -187,7 +187,7 @@ mlir::ParseResult ConstantOp::parse(mlir::OpAsmParser &parser,
 void ConstantOp::print(mlir::OpAsmPrinter &printer) {
   printer << " ";
   printer.printOptionalAttrDict((*this)->getAttrs(), /*elidedAttrs=*/{"value"});
-  printer << value();
+  printer << getValue();
 }
 
 /// Verifier for the constant operation. This corresponds to the
@@ -201,7 +201,7 @@ mlir::LogicalResult ConstantOp::verify() {
 
   // Check that the rank of the attribute type matches the rank of the constant
   // result type.
-  auto attrType = value().getType().cast<mlir::TensorType>();
+  auto attrType = getValue().getType().cast<mlir::TensorType>();
   if (attrType.getRank() != resultType.getRank()) {
     return emitOpError("return type must match the one of the attached value "
                        "attribute: ")
@@ -327,7 +327,7 @@ CallInterfaceCallable GenericCallOp::getCallableForCallee() {
 
 /// Get the argument operands to the called function, this is required by the
 /// call interface.
-Operation::operand_range GenericCallOp::getArgOperands() { return inputs(); }
+Operation::operand_range GenericCallOp::getArgOperands() { return getInputs(); }
 
 //===----------------------------------------------------------------------===//
 // MulOp

diff  --git a/mlir/examples/toy/Ch5/include/toy/Ops.td b/mlir/examples/toy/Ch5/include/toy/Ops.td
index 06ce9e363cd91..386d0c71920ee 100644
--- a/mlir/examples/toy/Ch5/include/toy/Ops.td
+++ b/mlir/examples/toy/Ch5/include/toy/Ops.td
@@ -25,6 +25,7 @@ include "toy/ShapeInferenceInterface.td"
 def Toy_Dialect : Dialect {
   let name = "toy";
   let cppNamespace = "::mlir::toy";
+  let emitAccessorPrefix = kEmitAccessorPrefix_Prefixed;
 }
 
 // Base class for toy dialect operations. This operation inherits from the base
@@ -172,21 +173,15 @@ def FuncOp : Toy_Op<"func", [
     CArg<"ArrayRef<NamedAttribute>", "{}">:$attrs)
   >];
   let extraClassDeclaration = [{
-    /// Returns the type of this function.
-    /// FIXME: We should drive this via the ODS `type` param.
-    FunctionType getType() { 
-      return getTypeAttr().getValue().cast<FunctionType>();
-    }
-
     //===------------------------------------------------------------------===//
     // FunctionOpInterface Methods
     //===------------------------------------------------------------------===//
 
     /// Returns the argument types of this function.
-    ArrayRef<Type> getArgumentTypes() { return type().getInputs(); }
+    ArrayRef<Type> getArgumentTypes() { return getType().getInputs(); }
 
     /// Returns the result types of this function.
-    ArrayRef<Type> getResultTypes() { return type().getResults(); }
+    ArrayRef<Type> getResultTypes() { return getType().getResults(); }
   }];
   let hasCustomAssemblyFormat = 1;
   let skipDefaultBuilders = 1;

diff  --git a/mlir/examples/toy/Ch5/mlir/Dialect.cpp b/mlir/examples/toy/Ch5/mlir/Dialect.cpp
index 57d51c5ec782a..c3b28417f9cc3 100644
--- a/mlir/examples/toy/Ch5/mlir/Dialect.cpp
+++ b/mlir/examples/toy/Ch5/mlir/Dialect.cpp
@@ -187,7 +187,7 @@ mlir::ParseResult ConstantOp::parse(mlir::OpAsmParser &parser,
 void ConstantOp::print(mlir::OpAsmPrinter &printer) {
   printer << " ";
   printer.printOptionalAttrDict((*this)->getAttrs(), /*elidedAttrs=*/{"value"});
-  printer << value();
+  printer << getValue();
 }
 
 /// Verifier for the constant operation. This corresponds to the
@@ -201,7 +201,7 @@ mlir::LogicalResult ConstantOp::verify() {
 
   // Check that the rank of the attribute type matches the rank of the constant
   // result type.
-  auto attrType = value().getType().cast<mlir::TensorType>();
+  auto attrType = getValue().getType().cast<mlir::TensorType>();
   if (attrType.getRank() != resultType.getRank()) {
     return emitOpError("return type must match the one of the attached value "
                        "attribute: ")
@@ -327,7 +327,7 @@ CallInterfaceCallable GenericCallOp::getCallableForCallee() {
 
 /// Get the argument operands to the called function, this is required by the
 /// call interface.
-Operation::operand_range GenericCallOp::getArgOperands() { return inputs(); }
+Operation::operand_range GenericCallOp::getArgOperands() { return getInputs(); }
 
 //===----------------------------------------------------------------------===//
 // MulOp

diff  --git a/mlir/examples/toy/Ch5/mlir/LowerToAffineLoops.cpp b/mlir/examples/toy/Ch5/mlir/LowerToAffineLoops.cpp
index 8a4ff560e3e80..36cd3d8708a39 100644
--- a/mlir/examples/toy/Ch5/mlir/LowerToAffineLoops.cpp
+++ b/mlir/examples/toy/Ch5/mlir/LowerToAffineLoops.cpp
@@ -115,10 +115,10 @@ struct BinaryOpLowering : public ConversionPattern {
 
           // Generate loads for the element of 'lhs' and 'rhs' at the inner
           // loop.
-          auto loadedLhs =
-              builder.create<AffineLoadOp>(loc, binaryAdaptor.lhs(), loopIvs);
-          auto loadedRhs =
-              builder.create<AffineLoadOp>(loc, binaryAdaptor.rhs(), loopIvs);
+          auto loadedLhs = builder.create<AffineLoadOp>(
+              loc, binaryAdaptor.getLhs(), loopIvs);
+          auto loadedRhs = builder.create<AffineLoadOp>(
+              loc, binaryAdaptor.getRhs(), loopIvs);
 
           // Create the binary operation performed on the loaded values.
           return builder.create<LoweredBinaryOp>(loc, loadedLhs, loadedRhs);
@@ -138,7 +138,7 @@ struct ConstantOpLowering : public OpRewritePattern<toy::ConstantOp> {
 
   LogicalResult matchAndRewrite(toy::ConstantOp op,
                                 PatternRewriter &rewriter) const final {
-    DenseElementsAttr constantValue = op.value();
+    DenseElementsAttr constantValue = op.getValue();
     Location loc = op.getLoc();
 
     // When lowering the constant operation, we allocate and assign the constant
@@ -286,7 +286,7 @@ struct TransposeOpLowering : public ConversionPattern {
                      // TransposeOp. This allows for using the nice named
                      // accessors that are generated by the ODS.
                      toy::TransposeOpAdaptor transposeAdaptor(memRefOperands);
-                     Value input = transposeAdaptor.input();
+                     Value input = transposeAdaptor.getInput();
 
                      // Transpose the elements by generating a load from the
                      // reverse indices.

diff  --git a/mlir/examples/toy/Ch6/include/toy/Ops.td b/mlir/examples/toy/Ch6/include/toy/Ops.td
index 40b7e24e68398..d0bceb1f6aa53 100644
--- a/mlir/examples/toy/Ch6/include/toy/Ops.td
+++ b/mlir/examples/toy/Ch6/include/toy/Ops.td
@@ -25,6 +25,7 @@ include "toy/ShapeInferenceInterface.td"
 def Toy_Dialect : Dialect {
   let name = "toy";
   let cppNamespace = "::mlir::toy";
+  let emitAccessorPrefix = kEmitAccessorPrefix_Prefixed;
 }
 
 // Base class for toy dialect operations. This operation inherits from the base
@@ -172,21 +173,15 @@ def FuncOp : Toy_Op<"func", [
     CArg<"ArrayRef<NamedAttribute>", "{}">:$attrs)
   >];
   let extraClassDeclaration = [{
-    /// Returns the type of this function.
-    /// FIXME: We should drive this via the ODS `type` param.
-    FunctionType getType() { 
-      return getTypeAttr().getValue().cast<FunctionType>();
-    }
-
     //===------------------------------------------------------------------===//
     // FunctionOpInterface Methods
     //===------------------------------------------------------------------===//
 
     /// Returns the argument types of this function.
-    ArrayRef<Type> getArgumentTypes() { return type().getInputs(); }
+    ArrayRef<Type> getArgumentTypes() { return getType().getInputs(); }
 
     /// Returns the result types of this function.
-    ArrayRef<Type> getResultTypes() { return type().getResults(); }
+    ArrayRef<Type> getResultTypes() { return getType().getResults(); }
   }];
   let hasCustomAssemblyFormat = 1;
   let skipDefaultBuilders = 1;

diff  --git a/mlir/examples/toy/Ch6/mlir/Dialect.cpp b/mlir/examples/toy/Ch6/mlir/Dialect.cpp
index 57d51c5ec782a..c3b28417f9cc3 100644
--- a/mlir/examples/toy/Ch6/mlir/Dialect.cpp
+++ b/mlir/examples/toy/Ch6/mlir/Dialect.cpp
@@ -187,7 +187,7 @@ mlir::ParseResult ConstantOp::parse(mlir::OpAsmParser &parser,
 void ConstantOp::print(mlir::OpAsmPrinter &printer) {
   printer << " ";
   printer.printOptionalAttrDict((*this)->getAttrs(), /*elidedAttrs=*/{"value"});
-  printer << value();
+  printer << getValue();
 }
 
 /// Verifier for the constant operation. This corresponds to the
@@ -201,7 +201,7 @@ mlir::LogicalResult ConstantOp::verify() {
 
   // Check that the rank of the attribute type matches the rank of the constant
   // result type.
-  auto attrType = value().getType().cast<mlir::TensorType>();
+  auto attrType = getValue().getType().cast<mlir::TensorType>();
   if (attrType.getRank() != resultType.getRank()) {
     return emitOpError("return type must match the one of the attached value "
                        "attribute: ")
@@ -327,7 +327,7 @@ CallInterfaceCallable GenericCallOp::getCallableForCallee() {
 
 /// Get the argument operands to the called function, this is required by the
 /// call interface.
-Operation::operand_range GenericCallOp::getArgOperands() { return inputs(); }
+Operation::operand_range GenericCallOp::getArgOperands() { return getInputs(); }
 
 //===----------------------------------------------------------------------===//
 // MulOp

diff  --git a/mlir/examples/toy/Ch6/mlir/LowerToAffineLoops.cpp b/mlir/examples/toy/Ch6/mlir/LowerToAffineLoops.cpp
index 8a4ff560e3e80..36cd3d8708a39 100644
--- a/mlir/examples/toy/Ch6/mlir/LowerToAffineLoops.cpp
+++ b/mlir/examples/toy/Ch6/mlir/LowerToAffineLoops.cpp
@@ -115,10 +115,10 @@ struct BinaryOpLowering : public ConversionPattern {
 
           // Generate loads for the element of 'lhs' and 'rhs' at the inner
           // loop.
-          auto loadedLhs =
-              builder.create<AffineLoadOp>(loc, binaryAdaptor.lhs(), loopIvs);
-          auto loadedRhs =
-              builder.create<AffineLoadOp>(loc, binaryAdaptor.rhs(), loopIvs);
+          auto loadedLhs = builder.create<AffineLoadOp>(
+              loc, binaryAdaptor.getLhs(), loopIvs);
+          auto loadedRhs = builder.create<AffineLoadOp>(
+              loc, binaryAdaptor.getRhs(), loopIvs);
 
           // Create the binary operation performed on the loaded values.
           return builder.create<LoweredBinaryOp>(loc, loadedLhs, loadedRhs);
@@ -138,7 +138,7 @@ struct ConstantOpLowering : public OpRewritePattern<toy::ConstantOp> {
 
   LogicalResult matchAndRewrite(toy::ConstantOp op,
                                 PatternRewriter &rewriter) const final {
-    DenseElementsAttr constantValue = op.value();
+    DenseElementsAttr constantValue = op.getValue();
     Location loc = op.getLoc();
 
     // When lowering the constant operation, we allocate and assign the constant
@@ -286,7 +286,7 @@ struct TransposeOpLowering : public ConversionPattern {
                      // TransposeOp. This allows for using the nice named
                      // accessors that are generated by the ODS.
                      toy::TransposeOpAdaptor transposeAdaptor(memRefOperands);
-                     Value input = transposeAdaptor.input();
+                     Value input = transposeAdaptor.getInput();
 
                      // Transpose the elements by generating a load from the
                      // reverse indices.

diff  --git a/mlir/examples/toy/Ch6/mlir/LowerToLLVM.cpp b/mlir/examples/toy/Ch6/mlir/LowerToLLVM.cpp
index 5318b53cc09d6..83ee0104a32ab 100644
--- a/mlir/examples/toy/Ch6/mlir/LowerToLLVM.cpp
+++ b/mlir/examples/toy/Ch6/mlir/LowerToLLVM.cpp
@@ -101,7 +101,7 @@ class PrintOpLowering : public ConversionPattern {
     // Generate a call to printf for the current element of the loop.
     auto printOp = cast<toy::PrintOp>(op);
     auto elementLoad =
-        rewriter.create<memref::LoadOp>(loc, printOp.input(), loopIvs);
+        rewriter.create<memref::LoadOp>(loc, printOp.getInput(), loopIvs);
     rewriter.create<func::CallOp>(
         loc, printfRef, rewriter.getIntegerType(32),
         ArrayRef<Value>({formatSpecifierCst, elementLoad}));

diff  --git a/mlir/examples/toy/Ch7/include/toy/Ops.td b/mlir/examples/toy/Ch7/include/toy/Ops.td
index 7056bc94e5ef1..5a1d98a6fe75c 100644
--- a/mlir/examples/toy/Ch7/include/toy/Ops.td
+++ b/mlir/examples/toy/Ch7/include/toy/Ops.td
@@ -25,6 +25,7 @@ include "toy/ShapeInferenceInterface.td"
 def Toy_Dialect : Dialect {
   let name = "toy";
   let cppNamespace = "::mlir::toy";
+  let emitAccessorPrefix = kEmitAccessorPrefix_Prefixed;
 
   // We set this bit to generate a declaration of the `materializeConstant`
   // method so that we can materialize constants for our toy operations.
@@ -191,21 +192,15 @@ def FuncOp : Toy_Op<"func", [
     CArg<"ArrayRef<NamedAttribute>", "{}">:$attrs)
   >];
   let extraClassDeclaration = [{
-    /// Returns the type of this function.
-    /// FIXME: We should drive this via the ODS `type` param.
-    FunctionType getType() { 
-      return getTypeAttr().getValue().cast<FunctionType>();
-    }
-
     //===------------------------------------------------------------------===//
     // FunctionOpInterface Methods
     //===------------------------------------------------------------------===//
 
     /// Returns the argument types of this function.
-    ArrayRef<Type> getArgumentTypes() { return type().getInputs(); }
+    ArrayRef<Type> getArgumentTypes() { return getType().getInputs(); }
 
     /// Returns the result types of this function.
-    ArrayRef<Type> getResultTypes() { return type().getResults(); }
+    ArrayRef<Type> getResultTypes() { return getType().getResults(); }
   }];
   let hasCustomAssemblyFormat = 1;
   let skipDefaultBuilders = 1;

diff  --git a/mlir/examples/toy/Ch7/mlir/Dialect.cpp b/mlir/examples/toy/Ch7/mlir/Dialect.cpp
index 73d770a24821f..f683a37fc70d1 100644
--- a/mlir/examples/toy/Ch7/mlir/Dialect.cpp
+++ b/mlir/examples/toy/Ch7/mlir/Dialect.cpp
@@ -174,7 +174,7 @@ mlir::ParseResult ConstantOp::parse(mlir::OpAsmParser &parser,
 void ConstantOp::print(mlir::OpAsmPrinter &printer) {
   printer << " ";
   printer.printOptionalAttrDict((*this)->getAttrs(), /*elidedAttrs=*/{"value"});
-  printer << value();
+  printer << getValue();
 }
 
 /// Verify that the given attribute value is valid for the given type.
@@ -236,16 +236,16 @@ static mlir::LogicalResult verifyConstantForType(mlir::Type type,
 /// Verifier for the constant operation. This corresponds to the `::verify(...)`
 /// in the op definition.
 mlir::LogicalResult ConstantOp::verify() {
-  return verifyConstantForType(getResult().getType(), value(), *this);
+  return verifyConstantForType(getResult().getType(), getValue(), *this);
 }
 
 mlir::LogicalResult StructConstantOp::verify() {
-  return verifyConstantForType(getResult().getType(), value(), *this);
+  return verifyConstantForType(getResult().getType(), getValue(), *this);
 }
 
 /// Infer the output shape of the ConstantOp, this is required by the shape
 /// inference interface.
-void ConstantOp::inferShapes() { getResult().setType(value().getType()); }
+void ConstantOp::inferShapes() { getResult().setType(getValue().getType()); }
 
 //===----------------------------------------------------------------------===//
 // AddOp
@@ -354,7 +354,7 @@ CallInterfaceCallable GenericCallOp::getCallableForCallee() {
 
 /// Get the argument operands to the called function, this is required by the
 /// call interface.
-Operation::operand_range GenericCallOp::getArgOperands() { return inputs(); }
+Operation::operand_range GenericCallOp::getArgOperands() { return getInputs(); }
 
 //===----------------------------------------------------------------------===//
 // MulOp
@@ -430,8 +430,8 @@ void StructAccessOp::build(mlir::OpBuilder &b, mlir::OperationState &state,
 }
 
 mlir::LogicalResult StructAccessOp::verify() {
-  StructType structTy = input().getType().cast<StructType>();
-  size_t indexValue = index();
+  StructType structTy = getInput().getType().cast<StructType>();
+  size_t indexValue = getIndex();
   if (indexValue >= structTy.getNumElementTypes())
     return emitOpError()
            << "index should be within the range of the input struct type";

diff  --git a/mlir/examples/toy/Ch7/mlir/LowerToAffineLoops.cpp b/mlir/examples/toy/Ch7/mlir/LowerToAffineLoops.cpp
index 8a4ff560e3e80..36cd3d8708a39 100644
--- a/mlir/examples/toy/Ch7/mlir/LowerToAffineLoops.cpp
+++ b/mlir/examples/toy/Ch7/mlir/LowerToAffineLoops.cpp
@@ -115,10 +115,10 @@ struct BinaryOpLowering : public ConversionPattern {
 
           // Generate loads for the element of 'lhs' and 'rhs' at the inner
           // loop.
-          auto loadedLhs =
-              builder.create<AffineLoadOp>(loc, binaryAdaptor.lhs(), loopIvs);
-          auto loadedRhs =
-              builder.create<AffineLoadOp>(loc, binaryAdaptor.rhs(), loopIvs);
+          auto loadedLhs = builder.create<AffineLoadOp>(
+              loc, binaryAdaptor.getLhs(), loopIvs);
+          auto loadedRhs = builder.create<AffineLoadOp>(
+              loc, binaryAdaptor.getRhs(), loopIvs);
 
           // Create the binary operation performed on the loaded values.
           return builder.create<LoweredBinaryOp>(loc, loadedLhs, loadedRhs);
@@ -138,7 +138,7 @@ struct ConstantOpLowering : public OpRewritePattern<toy::ConstantOp> {
 
   LogicalResult matchAndRewrite(toy::ConstantOp op,
                                 PatternRewriter &rewriter) const final {
-    DenseElementsAttr constantValue = op.value();
+    DenseElementsAttr constantValue = op.getValue();
     Location loc = op.getLoc();
 
     // When lowering the constant operation, we allocate and assign the constant
@@ -286,7 +286,7 @@ struct TransposeOpLowering : public ConversionPattern {
                      // TransposeOp. This allows for using the nice named
                      // accessors that are generated by the ODS.
                      toy::TransposeOpAdaptor transposeAdaptor(memRefOperands);
-                     Value input = transposeAdaptor.input();
+                     Value input = transposeAdaptor.getInput();
 
                      // Transpose the elements by generating a load from the
                      // reverse indices.

diff  --git a/mlir/examples/toy/Ch7/mlir/LowerToLLVM.cpp b/mlir/examples/toy/Ch7/mlir/LowerToLLVM.cpp
index 5318b53cc09d6..83ee0104a32ab 100644
--- a/mlir/examples/toy/Ch7/mlir/LowerToLLVM.cpp
+++ b/mlir/examples/toy/Ch7/mlir/LowerToLLVM.cpp
@@ -101,7 +101,7 @@ class PrintOpLowering : public ConversionPattern {
     // Generate a call to printf for the current element of the loop.
     auto printOp = cast<toy::PrintOp>(op);
     auto elementLoad =
-        rewriter.create<memref::LoadOp>(loc, printOp.input(), loopIvs);
+        rewriter.create<memref::LoadOp>(loc, printOp.getInput(), loopIvs);
     rewriter.create<func::CallOp>(
         loc, printfRef, rewriter.getIntegerType(32),
         ArrayRef<Value>({formatSpecifierCst, elementLoad}));

diff  --git a/mlir/examples/toy/Ch7/mlir/ToyCombine.cpp b/mlir/examples/toy/Ch7/mlir/ToyCombine.cpp
index 11dba6f55c4a0..36ba04bdc5c41 100644
--- a/mlir/examples/toy/Ch7/mlir/ToyCombine.cpp
+++ b/mlir/examples/toy/Ch7/mlir/ToyCombine.cpp
@@ -24,11 +24,13 @@ namespace {
 } // namespace
 
 /// Fold constants.
-OpFoldResult ConstantOp::fold(ArrayRef<Attribute> operands) { return value(); }
+OpFoldResult ConstantOp::fold(ArrayRef<Attribute> operands) {
+  return getValue();
+}
 
 /// Fold struct constants.
 OpFoldResult StructConstantOp::fold(ArrayRef<Attribute> operands) {
-  return value();
+  return getValue();
 }
 
 /// Fold simple struct access operations that access into a constant.
@@ -37,7 +39,7 @@ OpFoldResult StructAccessOp::fold(ArrayRef<Attribute> operands) {
   if (!structAttr)
     return nullptr;
 
-  size_t elementIndex = index();
+  size_t elementIndex = getIndex();
   return structAttr[elementIndex];
 }
 


        


More information about the Mlir-commits mailing list