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
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;
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
// 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: ")
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
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;
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
// 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: ")
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
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;
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
// 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: ")
/// 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
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
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;
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
// 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: ")
/// 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
// 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);
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
// 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.
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
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;
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
// 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: ")
/// 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
// 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);
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
// 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.
// 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}));
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.
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;
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.
/// 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
/// 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
}
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";
// 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);
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
// 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.
// 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}));
} // 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.
if (!structAttr)
return nullptr;
- size_t elementIndex = index();
+ size_t elementIndex = getIndex();
return structAttr[elementIndex];
}