From ccfcfa942345018535a26cdd5ac3cb988bba9062 Mon Sep 17 00:00:00 2001 From: River Riddle Date: Tue, 15 Mar 2022 16:09:19 -0700 Subject: [PATCH] [mlir:Toy][NFC] Switch toy to use prefixed accessors --- mlir/examples/toy/Ch2/include/toy/Ops.td | 11 +++-------- mlir/examples/toy/Ch2/mlir/Dialect.cpp | 4 ++-- mlir/examples/toy/Ch3/include/toy/Ops.td | 11 +++-------- mlir/examples/toy/Ch3/mlir/Dialect.cpp | 4 ++-- mlir/examples/toy/Ch4/include/toy/Ops.td | 11 +++-------- mlir/examples/toy/Ch4/mlir/Dialect.cpp | 6 +++--- mlir/examples/toy/Ch5/include/toy/Ops.td | 11 +++-------- mlir/examples/toy/Ch5/mlir/Dialect.cpp | 6 +++--- mlir/examples/toy/Ch5/mlir/LowerToAffineLoops.cpp | 12 ++++++------ mlir/examples/toy/Ch6/include/toy/Ops.td | 11 +++-------- mlir/examples/toy/Ch6/mlir/Dialect.cpp | 6 +++--- mlir/examples/toy/Ch6/mlir/LowerToAffineLoops.cpp | 12 ++++++------ mlir/examples/toy/Ch6/mlir/LowerToLLVM.cpp | 2 +- mlir/examples/toy/Ch7/include/toy/Ops.td | 11 +++-------- mlir/examples/toy/Ch7/mlir/Dialect.cpp | 14 +++++++------- mlir/examples/toy/Ch7/mlir/LowerToAffineLoops.cpp | 12 ++++++------ mlir/examples/toy/Ch7/mlir/LowerToLLVM.cpp | 2 +- mlir/examples/toy/Ch7/mlir/ToyCombine.cpp | 8 +++++--- 18 files changed, 63 insertions(+), 91 deletions(-) diff --git a/mlir/examples/toy/Ch2/include/toy/Ops.td b/mlir/examples/toy/Ch2/include/toy/Ops.td index c00a490..e59d4d5 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", "{}">:$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(); - } - //===------------------------------------------------------------------===// // FunctionOpInterface Methods //===------------------------------------------------------------------===// /// Returns the argument types of this function. - ArrayRef getArgumentTypes() { return type().getInputs(); } + ArrayRef getArgumentTypes() { return getType().getInputs(); } /// Returns the result types of this function. - ArrayRef getResultTypes() { return type().getResults(); } + ArrayRef 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 f1fedcb..0727f94 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(); + auto attrType = getValue().getType().cast(); 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 0ceec6c..a52d827 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", "{}">:$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(); - } - //===------------------------------------------------------------------===// // FunctionOpInterface Methods //===------------------------------------------------------------------===// /// Returns the argument types of this function. - ArrayRef getArgumentTypes() { return type().getInputs(); } + ArrayRef getArgumentTypes() { return getType().getInputs(); } /// Returns the result types of this function. - ArrayRef getResultTypes() { return type().getResults(); } + ArrayRef 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 b3c5c8f..c4f851c 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(); + auto attrType = getValue().getType().cast(); 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 df32a35..c535fff 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", "{}">:$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(); - } - //===------------------------------------------------------------------===// // FunctionOpInterface Methods //===------------------------------------------------------------------===// /// Returns the argument types of this function. - ArrayRef getArgumentTypes() { return type().getInputs(); } + ArrayRef getArgumentTypes() { return getType().getInputs(); } /// Returns the result types of this function. - ArrayRef getResultTypes() { return type().getResults(); } + ArrayRef 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 74ec486..3d6effd 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(); + auto attrType = getValue().getType().cast(); 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 06ce9e3..386d0c7 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", "{}">:$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(); - } - //===------------------------------------------------------------------===// // FunctionOpInterface Methods //===------------------------------------------------------------------===// /// Returns the argument types of this function. - ArrayRef getArgumentTypes() { return type().getInputs(); } + ArrayRef getArgumentTypes() { return getType().getInputs(); } /// Returns the result types of this function. - ArrayRef getResultTypes() { return type().getResults(); } + ArrayRef 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 57d51c5..c3b2841 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(); + auto attrType = getValue().getType().cast(); 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 8a4ff56..36cd3d8 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(loc, binaryAdaptor.lhs(), loopIvs); - auto loadedRhs = - builder.create(loc, binaryAdaptor.rhs(), loopIvs); + auto loadedLhs = builder.create( + loc, binaryAdaptor.getLhs(), loopIvs); + auto loadedRhs = builder.create( + loc, binaryAdaptor.getRhs(), loopIvs); // Create the binary operation performed on the loaded values. return builder.create(loc, loadedLhs, loadedRhs); @@ -138,7 +138,7 @@ struct ConstantOpLowering : public OpRewritePattern { 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 40b7e24..d0bceb1 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", "{}">:$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(); - } - //===------------------------------------------------------------------===// // FunctionOpInterface Methods //===------------------------------------------------------------------===// /// Returns the argument types of this function. - ArrayRef getArgumentTypes() { return type().getInputs(); } + ArrayRef getArgumentTypes() { return getType().getInputs(); } /// Returns the result types of this function. - ArrayRef getResultTypes() { return type().getResults(); } + ArrayRef 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 57d51c5..c3b2841 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(); + auto attrType = getValue().getType().cast(); 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 8a4ff56..36cd3d8 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(loc, binaryAdaptor.lhs(), loopIvs); - auto loadedRhs = - builder.create(loc, binaryAdaptor.rhs(), loopIvs); + auto loadedLhs = builder.create( + loc, binaryAdaptor.getLhs(), loopIvs); + auto loadedRhs = builder.create( + loc, binaryAdaptor.getRhs(), loopIvs); // Create the binary operation performed on the loaded values. return builder.create(loc, loadedLhs, loadedRhs); @@ -138,7 +138,7 @@ struct ConstantOpLowering : public OpRewritePattern { 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 5318b53..83ee010 100644 --- a/mlir/examples/toy/Ch6/mlir/LowerToLLVM.cpp +++ b/mlir/examples/toy/Ch6/mlir/LowerToLLVM.cpp @@ -101,7 +101,7 @@ public: // Generate a call to printf for the current element of the loop. auto printOp = cast(op); auto elementLoad = - rewriter.create(loc, printOp.input(), loopIvs); + rewriter.create(loc, printOp.getInput(), loopIvs); rewriter.create( loc, printfRef, rewriter.getIntegerType(32), ArrayRef({formatSpecifierCst, elementLoad})); diff --git a/mlir/examples/toy/Ch7/include/toy/Ops.td b/mlir/examples/toy/Ch7/include/toy/Ops.td index 7056bc9..5a1d98a 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", "{}">:$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(); - } - //===------------------------------------------------------------------===// // FunctionOpInterface Methods //===------------------------------------------------------------------===// /// Returns the argument types of this function. - ArrayRef getArgumentTypes() { return type().getInputs(); } + ArrayRef getArgumentTypes() { return getType().getInputs(); } /// Returns the result types of this function. - ArrayRef getResultTypes() { return type().getResults(); } + ArrayRef 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 73d770a..f683a37 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(); - size_t indexValue = index(); + StructType structTy = getInput().getType().cast(); + 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 8a4ff56..36cd3d8 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(loc, binaryAdaptor.lhs(), loopIvs); - auto loadedRhs = - builder.create(loc, binaryAdaptor.rhs(), loopIvs); + auto loadedLhs = builder.create( + loc, binaryAdaptor.getLhs(), loopIvs); + auto loadedRhs = builder.create( + loc, binaryAdaptor.getRhs(), loopIvs); // Create the binary operation performed on the loaded values. return builder.create(loc, loadedLhs, loadedRhs); @@ -138,7 +138,7 @@ struct ConstantOpLowering : public OpRewritePattern { 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 5318b53..83ee010 100644 --- a/mlir/examples/toy/Ch7/mlir/LowerToLLVM.cpp +++ b/mlir/examples/toy/Ch7/mlir/LowerToLLVM.cpp @@ -101,7 +101,7 @@ public: // Generate a call to printf for the current element of the loop. auto printOp = cast(op); auto elementLoad = - rewriter.create(loc, printOp.input(), loopIvs); + rewriter.create(loc, printOp.getInput(), loopIvs); rewriter.create( loc, printfRef, rewriter.getIntegerType(32), ArrayRef({formatSpecifierCst, elementLoad})); diff --git a/mlir/examples/toy/Ch7/mlir/ToyCombine.cpp b/mlir/examples/toy/Ch7/mlir/ToyCombine.cpp index 11dba6f..36ba04b 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 operands) { return value(); } +OpFoldResult ConstantOp::fold(ArrayRef operands) { + return getValue(); +} /// Fold struct constants. OpFoldResult StructConstantOp::fold(ArrayRef operands) { - return value(); + return getValue(); } /// Fold simple struct access operations that access into a constant. @@ -37,7 +39,7 @@ OpFoldResult StructAccessOp::fold(ArrayRef operands) { if (!structAttr) return nullptr; - size_t elementIndex = index(); + size_t elementIndex = getIndex(); return structAttr[elementIndex]; } -- 2.7.4