NFC: Pass OperationState by reference instead of by pointer.

MLIR follows the LLVM convention of passing by reference instead of by pointer.

PiperOrigin-RevId: 270396945
This commit is contained in:
River Riddle 2019-09-20 19:47:05 -07:00 committed by A. Unique TensorFlower
parent 91125d33ed
commit 729727ebc7
66 changed files with 1085 additions and 1087 deletions

View File

@ -37,11 +37,11 @@ public:
// Hooks to customize the behavior of this op.
//////////////////////////////////////////////////////////////////////////////
static llvm::StringRef getOperationName() { return "linalg.range"; }
static void build(mlir::Builder *b, mlir::OperationState *result,
static void build(mlir::Builder *b, mlir::OperationState &result,
mlir::Value *min, mlir::Value *max, mlir::Value *step);
mlir::LogicalResult verify();
static mlir::ParseResult parse(mlir::OpAsmParser &parser,
mlir::OperationState *result);
mlir::OperationState &result);
void print(mlir::OpAsmPrinter *p);
//////////////////////////////////////////////////////////////////////////////

View File

@ -36,11 +36,11 @@ public:
// Hooks to customize the behavior of this op.
//////////////////////////////////////////////////////////////////////////////
static llvm::StringRef getOperationName() { return "linalg.slice"; }
static void build(mlir::Builder *b, mlir::OperationState *result,
static void build(mlir::Builder *b, mlir::OperationState &result,
mlir::Value *view, mlir::Value *indexing, unsigned dim);
mlir::LogicalResult verify();
static mlir::ParseResult parse(mlir::OpAsmParser &parser,
mlir::OperationState *result);
mlir::OperationState &result);
void print(mlir::OpAsmPrinter *p);
//////////////////////////////////////////////////////////////////////////////

View File

@ -38,12 +38,12 @@ public:
// Hooks to customize the behavior of this op.
//////////////////////////////////////////////////////////////////////////////
static llvm::StringRef getOperationName() { return "linalg.view"; }
static void build(mlir::Builder *b, mlir::OperationState *result,
static void build(mlir::Builder *b, mlir::OperationState &result,
mlir::Value *memRef,
llvm::ArrayRef<mlir::Value *> indexings);
mlir::LogicalResult verify();
static mlir::ParseResult parse(mlir::OpAsmParser &parser,
mlir::OperationState *result);
mlir::OperationState &result);
void print(mlir::OpAsmPrinter *p);
//////////////////////////////////////////////////////////////////////////////

View File

@ -31,10 +31,10 @@ using namespace mlir;
using namespace linalg;
// Minimal example for a new RangeOp operating on RangeType.
void linalg::RangeOp::build(Builder *b, OperationState *result, Value *min,
void linalg::RangeOp::build(Builder *b, OperationState &result, Value *min,
Value *max, Value *step) {
result->addOperands({min, max, step});
result->addTypes({RangeType::get(b->getContext())});
result.addOperands({min, max, step});
result.addTypes({RangeType::get(b->getContext())});
}
// Verification is simply that a RangeOp takes 3 index ssa-value.
@ -49,7 +49,7 @@ mlir::LogicalResult linalg::RangeOp::verify() {
}
ParseResult linalg::RangeOp::parse(OpAsmParser &parser,
OperationState *result) {
OperationState &result) {
SmallVector<OpAsmParser::OperandType, 3> rangeInfo(3);
RangeType type;
auto indexTy = parser.getBuilder().getIndexType();
@ -57,8 +57,8 @@ ParseResult linalg::RangeOp::parse(OpAsmParser &parser,
parser.parseOperand(rangeInfo[1]) || parser.parseColon() ||
parser.parseOperand(rangeInfo[2]) ||
parser.parseColonType(type) ||
parser.resolveOperands(rangeInfo, indexTy, result->operands) ||
parser.addTypeToList(type, result->types));
parser.resolveOperands(rangeInfo, indexTy, result.operands) ||
parser.addTypeToList(type, result.types));
}
// A RangeOp prints as:

View File

@ -36,23 +36,23 @@ using namespace linalg;
// A view may itself be coming either from a ViewOp or from a SliceOp.
// TODO assert statically or dynamically that indexing is within the bounds of
// view.
void linalg::SliceOp::build(Builder *b, OperationState *result, Value *view,
void linalg::SliceOp::build(Builder *b, OperationState &result, Value *view,
Value *indexing, unsigned dim) {
// Early sanity checks + extract rank.
unsigned rank = getViewRank(view);
ViewType viewType = view->getType().cast<ViewType>();
Type elementType = viewType.getElementType();
result->addOperands({view, indexing});
result->addAttribute(getSlicingDimAttrName(),
b->getIntegerAttr(b->getIndexType(), dim));
result.addOperands({view, indexing});
result.addAttribute(getSlicingDimAttrName(),
b->getIntegerAttr(b->getIndexType(), dim));
if (indexing->getType().isa<RangeType>()) {
// Taking a range slice does not decrease the rank, the view has the same
// type.
result->addTypes({viewType});
result.addTypes({viewType});
} else {
assert(indexing->getType().cast<IndexType>());
result->addTypes(
result.addTypes(
{linalg::ViewType::get(b->getContext(), elementType, rank - 1)});
}
}
@ -75,14 +75,14 @@ mlir::LogicalResult linalg::SliceOp::verify() {
}
ParseResult linalg::SliceOp::parse(OpAsmParser &parser,
OperationState *result) {
OperationState &result) {
OpAsmParser::OperandType viewInfo;
SmallVector<OpAsmParser::OperandType, 1> indexingInfo;
SmallVector<Type, 8> types;
if (parser.parseOperand(viewInfo) ||
parser.parseOperandList(indexingInfo, 1,
OpAsmParser::Delimiter::Square) ||
parser.parseOptionalAttributeDict(result->attributes) ||
parser.parseOptionalAttributeDict(result.attributes) ||
parser.parseColonTypeList(types))
return failure();
@ -109,9 +109,9 @@ ParseResult linalg::SliceOp::parse(OpAsmParser &parser,
ViewType::get(viewType.getContext(), viewType.getElementType(), rank);
return failure(
parser.resolveOperand(viewInfo, viewType, result->operands) ||
parser.resolveOperands(indexingInfo[0], types.back(), result->operands) ||
parser.addTypeToList(resultViewType, result->types));
parser.resolveOperand(viewInfo, viewType, result.operands) ||
parser.resolveOperands(indexingInfo[0], types.back(), result.operands) ||
parser.addTypeToList(resultViewType, result.types));
}
// A SliceOp prints as:

View File

@ -36,14 +36,14 @@ using llvm::Twine;
using namespace mlir;
using namespace linalg;
void linalg::ViewOp::build(Builder *b, OperationState *result, Value *memRef,
void linalg::ViewOp::build(Builder *b, OperationState &result, Value *memRef,
ArrayRef<Value *> indexings) {
MemRefType memRefType = memRef->getType().cast<MemRefType>();
result->addOperands({memRef});
result.addOperands({memRef});
assert(static_cast<int64_t>(indexings.size()) == memRefType.getRank() &&
"unexpected number of indexings (must match the memref rank)");
result->addOperands(indexings);
result.addOperands(indexings);
unsigned rank = memRefType.getRank();
for (auto *v : indexings) {
if (!v->getType().isa<RangeType>()) {
@ -51,7 +51,7 @@ void linalg::ViewOp::build(Builder *b, OperationState *result, Value *memRef,
}
}
Type elementType = memRefType.getElementType();
result->addTypes({linalg::ViewType::get(b->getContext(), elementType, rank)});
result.addTypes({linalg::ViewType::get(b->getContext(), elementType, rank)});
}
LogicalResult linalg::ViewOp::verify() {
@ -89,13 +89,13 @@ LogicalResult linalg::ViewOp::verify() {
return success();
}
ParseResult linalg::ViewOp::parse(OpAsmParser &parser, OperationState *result) {
ParseResult linalg::ViewOp::parse(OpAsmParser &parser, OperationState &result) {
OpAsmParser::OperandType memRefInfo;
SmallVector<OpAsmParser::OperandType, 8> indexingsInfo;
SmallVector<Type, 8> types;
if (parser.parseOperand(memRefInfo) ||
parser.parseOperandList(indexingsInfo, OpAsmParser::Delimiter::Square) ||
parser.parseOptionalAttributeDict(result->attributes) ||
parser.parseOptionalAttributeDict(result.attributes) ||
parser.parseColonTypeList(types))
return failure();
@ -119,12 +119,12 @@ ParseResult linalg::ViewOp::parse(OpAsmParser &parser, OperationState *result) {
"expected " + Twine(memRefType.getRank()) +
" indexing types");
return failure(
parser.resolveOperand(memRefInfo, memRefType, result->operands) ||
parser.resolveOperand(memRefInfo, memRefType, result.operands) ||
(!indexingsInfo.empty() &&
parser.resolveOperands(indexingsInfo, indexingTypes,
indexingsInfo.front().location,
result->operands)) ||
parser.addTypeToList(viewType, result->types));
result.operands)) ||
parser.addTypeToList(viewType, result.types));
}
// A ViewOp prints as:

View File

@ -85,7 +85,7 @@ mlir::LogicalResult linalg::TensorContractionBase<ConcreteOp>::verify() {
template <class ConcreteOp>
mlir::ParseResult
linalg::TensorContractionBase<ConcreteOp>::parse(mlir::OpAsmParser &parser,
mlir::OperationState *result) {
mlir::OperationState &result) {
llvm_unreachable("Parsing linalg dialect is not supported in this tutorial");
}

View File

@ -39,7 +39,7 @@ protected:
/// Generic implementation of hooks that should be called from `ConcreteType`s
mlir::LogicalResult verify();
static mlir::ParseResult parse(mlir::OpAsmParser &parser,
mlir::OperationState *result);
mlir::OperationState &result);
void print(mlir::OpAsmPrinter *p);
public:
@ -111,15 +111,15 @@ public:
// Hooks to customize the behavior of this op.
//////////////////////////////////////////////////////////////////////////////
static llvm::StringRef getOperationName() { return "linalg.dot"; }
static void build(mlir::Builder *b, mlir::OperationState *result,
static void build(mlir::Builder *b, mlir::OperationState &result,
llvm::ArrayRef<mlir::Value *> operands);
static void build(mlir::Builder *b, mlir::OperationState *result,
static void build(mlir::Builder *b, mlir::OperationState &result,
mlir::Value *A, mlir::Value *B, mlir::Value *C) {
return build(b, result, {A, B, C});
}
mlir::LogicalResult verify();
static mlir::ParseResult parse(mlir::OpAsmParser &parser,
mlir::OperationState *result);
mlir::OperationState &result);
void print(mlir::OpAsmPrinter *p);
//////////////////////////////////////////////////////////////////////////////
@ -172,15 +172,15 @@ public:
// Hooks to customize the behavior of this op.
//////////////////////////////////////////////////////////////////////////////
static llvm::StringRef getOperationName() { return "linalg.matvec"; }
static void build(mlir::Builder *b, mlir::OperationState *result,
static void build(mlir::Builder *b, mlir::OperationState &result,
llvm::ArrayRef<mlir::Value *> operands);
static void build(mlir::Builder *b, mlir::OperationState *result,
static void build(mlir::Builder *b, mlir::OperationState &result,
mlir::Value *A, mlir::Value *B, mlir::Value *C) {
return build(b, result, {A, B, C});
}
mlir::LogicalResult verify();
static mlir::ParseResult parse(mlir::OpAsmParser &parser,
mlir::OperationState *result);
mlir::OperationState &result);
void print(mlir::OpAsmPrinter *p);
//////////////////////////////////////////////////////////////////////////////
@ -233,15 +233,15 @@ public:
// Hooks to customize the behavior of this op.
//////////////////////////////////////////////////////////////////////////////
static llvm::StringRef getOperationName() { return "linalg.matmul"; }
static void build(mlir::Builder *b, mlir::OperationState *result,
static void build(mlir::Builder *b, mlir::OperationState &result,
llvm::ArrayRef<mlir::Value *> operands);
static void build(mlir::Builder *b, mlir::OperationState *result,
static void build(mlir::Builder *b, mlir::OperationState &result,
mlir::Value *A, mlir::Value *B, mlir::Value *C) {
return build(b, result, {A, B, C});
}
mlir::LogicalResult verify();
static mlir::ParseResult parse(mlir::OpAsmParser &parser,
mlir::OperationState *result);
mlir::OperationState &result);
void print(mlir::OpAsmPrinter *p);
//////////////////////////////////////////////////////////////////////////////

View File

@ -37,9 +37,9 @@ using namespace linalg;
//////////////////////////////////////////////////////////////////////////////
// Op-specific Dot.
//////////////////////////////////////////////////////////////////////////////
void linalg::DotOp::build(Builder *b, OperationState *result,
void linalg::DotOp::build(Builder *b, OperationState &result,
ArrayRef<Value *> operands) {
result->addOperands(operands);
result.addOperands(operands);
}
LogicalResult linalg::DotOp::verify() {
@ -59,7 +59,7 @@ LogicalResult linalg::DotOp::verify() {
// Parsing of the linalg dialect is not supported in this tutorial.
ParseResult linalg::DotOp::parse(mlir::OpAsmParser &parser,
mlir::OperationState *result) {
mlir::OperationState &result) {
return TensorContractionBaseType::parse(parser, result);
}
@ -70,9 +70,9 @@ void linalg::DotOp::print(mlir::OpAsmPrinter *p) {
//////////////////////////////////////////////////////////////////////////////
// Op-specific Matvec.
//////////////////////////////////////////////////////////////////////////////
void linalg::MatvecOp::build(Builder *b, OperationState *result,
void linalg::MatvecOp::build(Builder *b, OperationState &result,
ArrayRef<Value *> operands) {
result->addOperands(operands);
result.addOperands(operands);
}
LogicalResult linalg::MatvecOp::verify() {
@ -93,7 +93,7 @@ LogicalResult linalg::MatvecOp::verify() {
// Parsing of the linalg dialect is not supported in this tutorial.
ParseResult linalg::MatvecOp::parse(mlir::OpAsmParser &parser,
mlir::OperationState *result) {
mlir::OperationState &result) {
return TensorContractionBaseType::parse(parser, result);
}
@ -104,9 +104,9 @@ void linalg::MatvecOp::print(mlir::OpAsmPrinter *p) {
//////////////////////////////////////////////////////////////////////////////
// Op-specific Matmul.
//////////////////////////////////////////////////////////////////////////////
void linalg::MatmulOp::build(Builder *b, OperationState *result,
void linalg::MatmulOp::build(Builder *b, OperationState &result,
ArrayRef<Value *> operands) {
result->addOperands(operands);
result.addOperands(operands);
}
LogicalResult linalg::MatmulOp::verify() {
@ -124,7 +124,7 @@ LogicalResult linalg::MatmulOp::verify() {
// Parsing of the linalg dialect is not supported in this tutorial.
ParseResult linalg::MatmulOp::parse(mlir::OpAsmParser &parser,
mlir::OperationState *result) {
mlir::OperationState &result) {
return TensorContractionBaseType::parse(parser, result);
}

View File

@ -36,12 +36,12 @@ public:
// Hooks to customize the behavior of this op.
//////////////////////////////////////////////////////////////////////////////
static llvm::StringRef getOperationName() { return "linalg.load"; }
static void build(mlir::Builder *b, mlir::OperationState *result,
static void build(mlir::Builder *b, mlir::OperationState &result,
mlir::Value *view,
mlir::ArrayRef<mlir::Value *> indices = {});
mlir::LogicalResult verify();
static mlir::ParseResult parse(mlir::OpAsmParser &parser,
mlir::OperationState *result);
mlir::OperationState &result);
void print(mlir::OpAsmPrinter *p);
//////////////////////////////////////////////////////////////////////////////
@ -66,12 +66,12 @@ public:
// Hooks to customize the behavior of this op.
//////////////////////////////////////////////////////////////////////////////
static llvm::StringRef getOperationName() { return "linalg.store"; }
static void build(mlir::Builder *b, mlir::OperationState *result,
static void build(mlir::Builder *b, mlir::OperationState &result,
mlir::Value *valueToStore, mlir::Value *view,
mlir::ArrayRef<mlir::Value *> indices = {});
mlir::LogicalResult verify();
static mlir::ParseResult parse(mlir::OpAsmParser &parser,
mlir::OperationState *result);
mlir::OperationState &result);
void print(mlir::OpAsmPrinter *p);
//////////////////////////////////////////////////////////////////////////////

View File

@ -33,12 +33,12 @@ using namespace linalg;
////////////////////////////////////////////////////////////////////////////////
// LoadOp.
////////////////////////////////////////////////////////////////////////////////
void linalg::LoadOp::build(Builder *b, OperationState *result, Value *view,
void linalg::LoadOp::build(Builder *b, OperationState &result, Value *view,
ArrayRef<Value *> indices) {
auto viewType = view->getType().cast<ViewType>();
result->addOperands(view);
result->addOperands(indices);
result->addTypes(viewType.getElementType());
result.addOperands(view);
result.addOperands(indices);
result.addTypes(viewType.getElementType());
}
void linalg::LoadOp::print(OpAsmPrinter *p) {
@ -49,7 +49,7 @@ void linalg::LoadOp::print(OpAsmPrinter *p) {
*p << " : " << getViewType();
}
ParseResult linalg::LoadOp::parse(OpAsmParser &parser, OperationState *result) {
ParseResult linalg::LoadOp::parse(OpAsmParser &parser, OperationState &result) {
llvm_unreachable("Parsing linalg dialect is not supported in this tutorial");
return success();
}
@ -84,12 +84,12 @@ unsigned linalg::LoadOp::getRank() { return getViewType().getRank(); }
////////////////////////////////////////////////////////////////////////////////
// StoreOp.
////////////////////////////////////////////////////////////////////////////////
void linalg::StoreOp::build(Builder *b, OperationState *result,
void linalg::StoreOp::build(Builder *b, OperationState &result,
Value *valueToStore, Value *view,
ArrayRef<Value *> indices) {
result->addOperands(valueToStore);
result->addOperands(view);
result->addOperands(indices);
result.addOperands(valueToStore);
result.addOperands(view);
result.addOperands(indices);
}
void linalg::StoreOp::print(OpAsmPrinter *p) {
@ -102,7 +102,7 @@ void linalg::StoreOp::print(OpAsmPrinter *p) {
}
ParseResult linalg::StoreOp::parse(OpAsmParser &parser,
OperationState *result) {
OperationState &result) {
assert(false && "NYI");
return success();
}

View File

@ -135,13 +135,13 @@ public:
/// This method populates the `state` that MLIR uses to create operations.
/// The `toy.constant` operation does not have arguments but attaches a
/// constant array as an attribute and returns it as an SSA value.
static void build(mlir::Builder *builder, mlir::OperationState *state,
static void build(mlir::Builder *builder, mlir::OperationState &state,
llvm::ArrayRef<int64_t> shape,
mlir::DenseElementsAttr value);
/// Similar to the one above, but takes a single float and returns a
/// !toy.array<1>.
static void build(mlir::Builder *builder, mlir::OperationState *state,
static void build(mlir::Builder *builder, mlir::OperationState &state,
mlir::FloatAttr value);
/// Inherit constructor.
@ -173,7 +173,7 @@ public:
/// This method populate the `state` that MLIR use to create operations.
/// The `toy.generic_call` operation accepts a callee name and a list of
/// arguments for the call.
static void build(mlir::Builder *builder, mlir::OperationState *state,
static void build(mlir::Builder *builder, mlir::OperationState &state,
llvm::StringRef callee,
llvm::ArrayRef<mlir::Value *> arguments);
@ -199,7 +199,7 @@ public:
/// This method populate the `state` that MLIR use to create operations.
/// The `toy.return` operation accepts an optional single array as an argument
/// and does not have any returned value.
static void build(mlir::Builder *builder, mlir::OperationState *state,
static void build(mlir::Builder *builder, mlir::OperationState &state,
mlir::Value *value = nullptr);
/// Return true if there is a returned value.
@ -226,7 +226,7 @@ public:
/// This method populate the `state` that MLIR use to create operations.
/// The `toy.print` operation accepts a single array as argument and does
/// not have any returned value.
static void build(mlir::Builder *builder, mlir::OperationState *state,
static void build(mlir::Builder *builder, mlir::OperationState &state,
mlir::Value *value);
/// Inherit constructor.
@ -245,7 +245,7 @@ public:
/// This method populate the `state` that MLIR use to create operations.
/// The `toy.transpose` operation accepts a single array as argument and
/// returns the transposed array as its only result.
static void build(mlir::Builder *builder, mlir::OperationState *state,
static void build(mlir::Builder *builder, mlir::OperationState &state,
mlir::Value *value);
/// Inherit constructor.
@ -269,7 +269,7 @@ public:
/// This method populate the `state` that MLIR use to create operations.
/// The `toy.reshape` operation accepts a single array as argument and
/// returns the array with the specified reshapedType as its only result.
static void build(mlir::Builder *builder, mlir::OperationState *state,
static void build(mlir::Builder *builder, mlir::OperationState &state,
mlir::Value *value, ToyArrayType reshapedType);
/// Inherit constructor.
@ -291,7 +291,7 @@ public:
/// This method populate the `state` that MLIR use to create operations.
/// The `toy.mul` operation accepts two operands as argument and returns
/// a single value.
static void build(mlir::Builder *builder, mlir::OperationState *state,
static void build(mlir::Builder *builder, mlir::OperationState &state,
mlir::Value *lhs, mlir::Value *rhs);
/// Convenience accessor for LHS of the expression.
@ -317,7 +317,7 @@ public:
/// This method populate the `state` that MLIR use to create operations.
/// The `toy.mul` operation accepts two operands as argument and returns
/// a single value.
static void build(mlir::Builder *builder, mlir::OperationState *state,
static void build(mlir::Builder *builder, mlir::OperationState &state,
mlir::Value *lhs, mlir::Value *rhs);
/// Convenience accessor for LHS of the expression.

View File

@ -197,17 +197,17 @@ template <typename T> static mlir::LogicalResult verifyToyBinOperands(T *op) {
/// Build a constant operation.
/// The builder is passed as an argument, so is the state that this method is
/// expected to fill in order to build the operation.
void ConstantOp::build(mlir::Builder *builder, mlir::OperationState *state,
void ConstantOp::build(mlir::Builder *builder, mlir::OperationState &state,
ArrayRef<int64_t> shape, mlir::DenseElementsAttr value) {
state->types.push_back(ToyArrayType::get(builder->getContext(), shape));
state.types.push_back(ToyArrayType::get(builder->getContext(), shape));
auto dataAttribute = builder->getNamedAttr("value", value);
state->attributes.push_back(dataAttribute);
state.attributes.push_back(dataAttribute);
}
/// Build a constant operation.
/// The builder is passed as an argument, so is the state that this method is
/// expected to fill in order to build the operation.
void ConstantOp::build(mlir::Builder *builder, mlir::OperationState *state,
void ConstantOp::build(mlir::Builder *builder, mlir::OperationState &state,
mlir::FloatAttr value) {
// Broadcast and forward to the other build factory
mlir::Type elementType = mlir::FloatType::getF64(builder->getContext());
@ -261,13 +261,13 @@ mlir::LogicalResult ConstantOp::verify() {
return mlir::success();
}
void GenericCallOp::build(mlir::Builder *builder, mlir::OperationState *state,
void GenericCallOp::build(mlir::Builder *builder, mlir::OperationState &state,
StringRef callee, ArrayRef<mlir::Value *> arguments) {
// Generic call always returns a generic ToyArray initially
state->types.push_back(ToyArrayType::get(builder->getContext()));
state->operands.assign(arguments.begin(), arguments.end());
state.types.push_back(ToyArrayType::get(builder->getContext()));
state.operands.assign(arguments.begin(), arguments.end());
auto calleeAttr = builder->getStringAttr(callee);
state->attributes.push_back(builder->getNamedAttr("callee", calleeAttr));
state.attributes.push_back(builder->getNamedAttr("callee", calleeAttr));
}
mlir::LogicalResult GenericCallOp::verify() {
@ -300,11 +300,11 @@ template <typename T> static mlir::LogicalResult verifyToySingleOperand(T *op) {
return mlir::success();
}
void ReturnOp::build(mlir::Builder *builder, mlir::OperationState *state,
void ReturnOp::build(mlir::Builder *builder, mlir::OperationState &state,
mlir::Value *value) {
// Return does not return any value and has an optional single argument
if (value)
state->operands.push_back(value);
state.operands.push_back(value);
}
mlir::LogicalResult ReturnOp::verify() {
@ -319,10 +319,10 @@ mlir::LogicalResult ReturnOp::verify() {
return mlir::success();
}
void PrintOp::build(mlir::Builder *builder, mlir::OperationState *state,
void PrintOp::build(mlir::Builder *builder, mlir::OperationState &state,
mlir::Value *value) {
// Print does not return any value and has a single argument
state->operands.push_back(value);
state.operands.push_back(value);
}
mlir::LogicalResult PrintOp::verify() {
@ -331,10 +331,10 @@ mlir::LogicalResult PrintOp::verify() {
return mlir::success();
}
void TransposeOp::build(mlir::Builder *builder, mlir::OperationState *state,
void TransposeOp::build(mlir::Builder *builder, mlir::OperationState &state,
mlir::Value *value) {
state->types.push_back(ToyArrayType::get(builder->getContext()));
state->operands.push_back(value);
state.types.push_back(ToyArrayType::get(builder->getContext()));
state.operands.push_back(value);
}
mlir::LogicalResult TransposeOp::verify() {
@ -343,10 +343,10 @@ mlir::LogicalResult TransposeOp::verify() {
return mlir::success();
}
void ReshapeOp::build(mlir::Builder *builder, mlir::OperationState *state,
void ReshapeOp::build(mlir::Builder *builder, mlir::OperationState &state,
mlir::Value *value, ToyArrayType reshapedType) {
state->types.push_back(reshapedType);
state->operands.push_back(value);
state.types.push_back(reshapedType);
state.operands.push_back(value);
}
mlir::LogicalResult ReshapeOp::verify() {
@ -361,11 +361,11 @@ mlir::LogicalResult ReshapeOp::verify() {
return mlir::success();
}
void AddOp::build(mlir::Builder *builder, mlir::OperationState *state,
void AddOp::build(mlir::Builder *builder, mlir::OperationState &state,
mlir::Value *lhs, mlir::Value *rhs) {
state->types.push_back(ToyArrayType::get(builder->getContext()));
state->operands.push_back(lhs);
state->operands.push_back(rhs);
state.types.push_back(ToyArrayType::get(builder->getContext()));
state.operands.push_back(lhs);
state.operands.push_back(rhs);
}
mlir::LogicalResult AddOp::verify() {
@ -374,11 +374,11 @@ mlir::LogicalResult AddOp::verify() {
return mlir::success();
}
void MulOp::build(mlir::Builder *builder, mlir::OperationState *state,
void MulOp::build(mlir::Builder *builder, mlir::OperationState &state,
mlir::Value *lhs, mlir::Value *rhs) {
state->types.push_back(ToyArrayType::get(builder->getContext()));
state->operands.push_back(lhs);
state->operands.push_back(rhs);
state.types.push_back(ToyArrayType::get(builder->getContext()));
state.operands.push_back(lhs);
state.operands.push_back(rhs);
}
mlir::LogicalResult MulOp::verify() {

View File

@ -135,13 +135,13 @@ public:
/// This method populates the `state` that MLIR uses to create operations.
/// The `toy.constant` operation does not have arguments but attaches a
/// constant array as an attribute and returns it as an SSA value.
static void build(mlir::Builder *builder, mlir::OperationState *state,
static void build(mlir::Builder *builder, mlir::OperationState &state,
llvm::ArrayRef<int64_t> shape,
mlir::DenseElementsAttr value);
/// Similar to the one above, but takes a single float and returns a
/// !toy.array<1>.
static void build(mlir::Builder *builder, mlir::OperationState *state,
static void build(mlir::Builder *builder, mlir::OperationState &state,
mlir::FloatAttr value);
/// Inherit constructor.
@ -173,7 +173,7 @@ public:
/// This method populate the `state` that MLIR use to create operations.
/// The `toy.generic_call` operation accepts a callee name and a list of
/// arguments for the call.
static void build(mlir::Builder *builder, mlir::OperationState *state,
static void build(mlir::Builder *builder, mlir::OperationState &state,
llvm::StringRef callee,
llvm::ArrayRef<mlir::Value *> arguments);
@ -199,7 +199,7 @@ public:
/// This method populate the `state` that MLIR use to create operations.
/// The `toy.return` operation accepts an optional single array as an argument
/// and does not have any returned value.
static void build(mlir::Builder *builder, mlir::OperationState *state,
static void build(mlir::Builder *builder, mlir::OperationState &state,
mlir::Value *value = nullptr);
/// Return true if there is a returned value.
@ -226,7 +226,7 @@ public:
/// This method populate the `state` that MLIR use to create operations.
/// The `toy.print` operation accepts a single array as argument and does
/// not have any returned value.
static void build(mlir::Builder *builder, mlir::OperationState *state,
static void build(mlir::Builder *builder, mlir::OperationState &state,
mlir::Value *value);
/// Inherit constructor.
@ -246,7 +246,7 @@ public:
/// This method populate the `state` that MLIR use to create operations.
/// The `toy.transpose` operation accepts a single array as argument and
/// returns the transposed array as its only result.
static void build(mlir::Builder *builder, mlir::OperationState *state,
static void build(mlir::Builder *builder, mlir::OperationState &state,
mlir::Value *value);
// Register our patterns for rewrite by the Canonicalization framework.
@ -276,7 +276,7 @@ public:
/// This method populate the `state` that MLIR use to create operations.
/// The `toy.reshape` operation accepts a single array as argument and
/// returns the array with the specified reshapedType as its only result.
static void build(mlir::Builder *builder, mlir::OperationState *state,
static void build(mlir::Builder *builder, mlir::OperationState &state,
mlir::Value *value, ToyArrayType reshapedType);
// Register our patterns for rewrite by the Canonicalization framework.
@ -304,7 +304,7 @@ public:
/// This method populate the `state` that MLIR use to create operations.
/// The `toy.mul` operation accepts two operands as argument and returns
/// a single value.
static void build(mlir::Builder *builder, mlir::OperationState *state,
static void build(mlir::Builder *builder, mlir::OperationState &state,
mlir::Value *lhs, mlir::Value *rhs);
/// Convenience accessor for LHS of the expression.
@ -331,7 +331,7 @@ public:
/// This method populate the `state` that MLIR use to create operations.
/// The `toy.mul` operation accepts two operands as argument and returns
/// a single value.
static void build(mlir::Builder *builder, mlir::OperationState *state,
static void build(mlir::Builder *builder, mlir::OperationState &state,
mlir::Value *lhs, mlir::Value *rhs);
/// Convenience accessor for LHS of the expression.

View File

@ -197,17 +197,17 @@ template <typename T> static mlir::LogicalResult verifyToyBinOperands(T *op) {
/// Build a constant operation.
/// The builder is passed as an argument, so is the state that this method is
/// expected to fill in order to build the operation.
void ConstantOp::build(mlir::Builder *builder, mlir::OperationState *state,
void ConstantOp::build(mlir::Builder *builder, mlir::OperationState &state,
ArrayRef<int64_t> shape, mlir::DenseElementsAttr value) {
state->types.push_back(ToyArrayType::get(builder->getContext(), shape));
state.types.push_back(ToyArrayType::get(builder->getContext(), shape));
auto dataAttribute = builder->getNamedAttr("value", value);
state->attributes.push_back(dataAttribute);
state.attributes.push_back(dataAttribute);
}
/// Build a constant operation.
/// The builder is passed as an argument, so is the state that this method is
/// expected to fill in order to build the operation.
void ConstantOp::build(mlir::Builder *builder, mlir::OperationState *state,
void ConstantOp::build(mlir::Builder *builder, mlir::OperationState &state,
mlir::FloatAttr value) {
// Broadcast and forward to the other build factory
mlir::Type elementType = mlir::FloatType::getF64(builder->getContext());
@ -261,13 +261,13 @@ mlir::LogicalResult ConstantOp::verify() {
return mlir::success();
}
void GenericCallOp::build(mlir::Builder *builder, mlir::OperationState *state,
void GenericCallOp::build(mlir::Builder *builder, mlir::OperationState &state,
StringRef callee, ArrayRef<mlir::Value *> arguments) {
// Generic call always returns a generic ToyArray initially
state->types.push_back(ToyArrayType::get(builder->getContext()));
state->operands.assign(arguments.begin(), arguments.end());
state.types.push_back(ToyArrayType::get(builder->getContext()));
state.operands.assign(arguments.begin(), arguments.end());
auto calleeAttr = builder->getStringAttr(callee);
state->attributes.push_back(builder->getNamedAttr("callee", calleeAttr));
state.attributes.push_back(builder->getNamedAttr("callee", calleeAttr));
}
mlir::LogicalResult GenericCallOp::verify() {
@ -300,11 +300,11 @@ template <typename T> static mlir::LogicalResult verifyToySingleOperand(T *op) {
return mlir::success();
}
void ReturnOp::build(mlir::Builder *builder, mlir::OperationState *state,
void ReturnOp::build(mlir::Builder *builder, mlir::OperationState &state,
mlir::Value *value) {
// Return does not return any value and has an optional single argument
if (value)
state->operands.push_back(value);
state.operands.push_back(value);
}
mlir::LogicalResult ReturnOp::verify() {
@ -316,10 +316,10 @@ mlir::LogicalResult ReturnOp::verify() {
return mlir::success();
}
void PrintOp::build(mlir::Builder *builder, mlir::OperationState *state,
void PrintOp::build(mlir::Builder *builder, mlir::OperationState &state,
mlir::Value *value) {
// Print does not return any value and has a single argument
state->operands.push_back(value);
state.operands.push_back(value);
}
mlir::LogicalResult PrintOp::verify() {
@ -328,10 +328,10 @@ mlir::LogicalResult PrintOp::verify() {
return mlir::success();
}
void TransposeOp::build(mlir::Builder *builder, mlir::OperationState *state,
void TransposeOp::build(mlir::Builder *builder, mlir::OperationState &state,
mlir::Value *value) {
state->types.push_back(ToyArrayType::get(builder->getContext()));
state->operands.push_back(value);
state.types.push_back(ToyArrayType::get(builder->getContext()));
state.operands.push_back(value);
}
mlir::LogicalResult TransposeOp::verify() {
@ -340,10 +340,10 @@ mlir::LogicalResult TransposeOp::verify() {
return mlir::success();
}
void ReshapeOp::build(mlir::Builder *builder, mlir::OperationState *state,
void ReshapeOp::build(mlir::Builder *builder, mlir::OperationState &state,
mlir::Value *value, ToyArrayType reshapedType) {
state->types.push_back(reshapedType);
state->operands.push_back(value);
state.types.push_back(reshapedType);
state.operands.push_back(value);
}
mlir::LogicalResult ReshapeOp::verify() {
@ -358,11 +358,11 @@ mlir::LogicalResult ReshapeOp::verify() {
return mlir::success();
}
void AddOp::build(mlir::Builder *builder, mlir::OperationState *state,
void AddOp::build(mlir::Builder *builder, mlir::OperationState &state,
mlir::Value *lhs, mlir::Value *rhs) {
state->types.push_back(ToyArrayType::get(builder->getContext()));
state->operands.push_back(lhs);
state->operands.push_back(rhs);
state.types.push_back(ToyArrayType::get(builder->getContext()));
state.operands.push_back(lhs);
state.operands.push_back(rhs);
}
mlir::LogicalResult AddOp::verify() {
@ -371,11 +371,11 @@ mlir::LogicalResult AddOp::verify() {
return mlir::success();
}
void MulOp::build(mlir::Builder *builder, mlir::OperationState *state,
void MulOp::build(mlir::Builder *builder, mlir::OperationState &state,
mlir::Value *lhs, mlir::Value *rhs) {
state->types.push_back(ToyArrayType::get(builder->getContext()));
state->operands.push_back(lhs);
state->operands.push_back(rhs);
state.types.push_back(ToyArrayType::get(builder->getContext()));
state.operands.push_back(lhs);
state.operands.push_back(rhs);
}
mlir::LogicalResult MulOp::verify() {

View File

@ -139,13 +139,13 @@ public:
/// This method populates the `state` that MLIR uses to create operations.
/// The `toy.constant` operation does not have arguments but attaches a
/// constant array as an attribute and returns it as an SSA value.
static void build(mlir::Builder *builder, mlir::OperationState *state,
static void build(mlir::Builder *builder, mlir::OperationState &state,
llvm::ArrayRef<int64_t> shape,
mlir::DenseElementsAttr value);
/// Similar to the one above, but takes a single float and returns a
/// !toy<"array<1>">.
static void build(mlir::Builder *builder, mlir::OperationState *state,
static void build(mlir::Builder *builder, mlir::OperationState &state,
mlir::FloatAttr value);
mlir::DenseElementsAttr getValue() {
@ -181,7 +181,7 @@ public:
/// This method populate the `state` that MLIR use to create operations.
/// The `toy.generic_call` operation accepts a callee name and a list of
/// arguments for the call.
static void build(mlir::Builder *builder, mlir::OperationState *state,
static void build(mlir::Builder *builder, mlir::OperationState &state,
llvm::StringRef callee,
llvm::ArrayRef<mlir::Value *> arguments);
@ -207,7 +207,7 @@ public:
/// This method populate the `state` that MLIR use to create operations.
/// The `toy.return` operation accepts an optional single array as an argument
/// and does not have any returned value.
static void build(mlir::Builder *builder, mlir::OperationState *state,
static void build(mlir::Builder *builder, mlir::OperationState &state,
mlir::Value *value = nullptr);
/// Return true if there is a returned value.
@ -234,7 +234,7 @@ public:
/// This method populate the `state` that MLIR use to create operations.
/// The `toy.print` operation accepts a single array as argument and does
/// not have any returned value.
static void build(mlir::Builder *builder, mlir::OperationState *state,
static void build(mlir::Builder *builder, mlir::OperationState &state,
mlir::Value *value);
/// Inherit constructor.
@ -254,7 +254,7 @@ public:
/// This method populate the `state` that MLIR use to create operations.
/// The `toy.transpose` operation accepts a single array as argument and
/// returns the transposed array as its only result.
static void build(mlir::Builder *builder, mlir::OperationState *state,
static void build(mlir::Builder *builder, mlir::OperationState &state,
mlir::Value *value);
// Register our patterns for rewrite by the Canonicalization framework.
@ -284,7 +284,7 @@ public:
/// This method populate the `state` that MLIR use to create operations.
/// The `toy.reshape` operation accepts a single array as argument and
/// returns the array with the specified reshapedType as its only result.
static void build(mlir::Builder *builder, mlir::OperationState *state,
static void build(mlir::Builder *builder, mlir::OperationState &state,
mlir::Value *value, ToyArrayType reshapedType);
// Register our patterns for rewrite by the Canonicalization framework.
@ -312,7 +312,7 @@ public:
/// This method populate the `state` that MLIR use to create operations.
/// The `toy.mul` operation accepts two operands as argument and returns
/// a single value.
static void build(mlir::Builder *builder, mlir::OperationState *state,
static void build(mlir::Builder *builder, mlir::OperationState &state,
mlir::Value *lhs, mlir::Value *rhs);
/// Convenience accessor for LHS of the expression.
@ -339,7 +339,7 @@ public:
/// This method populate the `state` that MLIR use to create operations.
/// The `toy.mul` operation accepts two operands as argument and returns
/// a single value.
static void build(mlir::Builder *builder, mlir::OperationState *state,
static void build(mlir::Builder *builder, mlir::OperationState &state,
mlir::Value *lhs, mlir::Value *rhs);
/// Convenience accessor for LHS of the expression.
@ -362,7 +362,7 @@ public:
/// Interface to mlir::Builder::create<AllocOp>(...)
/// This method populate the `state` that MLIR use to create operations.
/// `toy.alloc` does not have any argument and returns a toy array.
static void build(mlir::Builder *builder, mlir::OperationState *state,
static void build(mlir::Builder *builder, mlir::OperationState &state,
mlir::Type retType);
/// Inherit constructor.
@ -376,7 +376,7 @@ class TypeCastOp : public mlir::Op<TypeCastOp, mlir::OpTrait::OneOperand,
public:
static llvm::StringRef getOperationName() { return "toy.cast"; }
static void build(mlir::Builder *builder, mlir::OperationState *state,
static void build(mlir::Builder *builder, mlir::OperationState &state,
mlir::Value *value, mlir::Type destTy);
// Register our patterns for rewrite by the Canonicalization framework.

View File

@ -202,17 +202,17 @@ template <typename T> static mlir::LogicalResult verifyToyBinOperands(T *op) {
/// Build a constant operation.
/// The builder is passed as an argument, so is the state that this method is
/// expected to fill in order to build the operation.
void ConstantOp::build(mlir::Builder *builder, mlir::OperationState *state,
void ConstantOp::build(mlir::Builder *builder, mlir::OperationState &state,
ArrayRef<int64_t> shape, mlir::DenseElementsAttr value) {
state->types.push_back(ToyArrayType::get(builder->getContext(), shape));
state.types.push_back(ToyArrayType::get(builder->getContext(), shape));
auto dataAttribute = builder->getNamedAttr("value", value);
state->attributes.push_back(dataAttribute);
state.attributes.push_back(dataAttribute);
}
/// Build a constant operation.
/// The builder is passed as an argument, so is the state that this method is
/// expected to fill in order to build the operation.
void ConstantOp::build(mlir::Builder *builder, mlir::OperationState *state,
void ConstantOp::build(mlir::Builder *builder, mlir::OperationState &state,
mlir::FloatAttr value) {
// Broadcast and forward to the other build factory
mlir::Type elementType = mlir::FloatType::getF64(builder->getContext());
@ -266,13 +266,13 @@ mlir::LogicalResult ConstantOp::verify() {
return mlir::success();
}
void GenericCallOp::build(mlir::Builder *builder, mlir::OperationState *state,
void GenericCallOp::build(mlir::Builder *builder, mlir::OperationState &state,
StringRef callee, ArrayRef<mlir::Value *> arguments) {
// Generic call always returns a generic ToyArray initially
state->types.push_back(ToyArrayType::get(builder->getContext()));
state->operands.assign(arguments.begin(), arguments.end());
state.types.push_back(ToyArrayType::get(builder->getContext()));
state.operands.assign(arguments.begin(), arguments.end());
auto calleeAttr = builder->getStringAttr(callee);
state->attributes.push_back(builder->getNamedAttr("callee", calleeAttr));
state.attributes.push_back(builder->getNamedAttr("callee", calleeAttr));
}
mlir::LogicalResult GenericCallOp::verify() {
@ -305,11 +305,11 @@ template <typename T> static mlir::LogicalResult verifyToySingleOperand(T *op) {
return mlir::success();
}
void ReturnOp::build(mlir::Builder *builder, mlir::OperationState *state,
void ReturnOp::build(mlir::Builder *builder, mlir::OperationState &state,
mlir::Value *value) {
// Return does not return any value and has an optional single argument
if (value)
state->operands.push_back(value);
state.operands.push_back(value);
}
mlir::LogicalResult ReturnOp::verify() {
@ -321,10 +321,10 @@ mlir::LogicalResult ReturnOp::verify() {
return mlir::success();
}
void PrintOp::build(mlir::Builder *builder, mlir::OperationState *state,
void PrintOp::build(mlir::Builder *builder, mlir::OperationState &state,
mlir::Value *value) {
// Print does not return any value and has a single argument
state->operands.push_back(value);
state.operands.push_back(value);
}
mlir::LogicalResult PrintOp::verify() {
@ -333,10 +333,10 @@ mlir::LogicalResult PrintOp::verify() {
return mlir::success();
}
void TransposeOp::build(mlir::Builder *builder, mlir::OperationState *state,
void TransposeOp::build(mlir::Builder *builder, mlir::OperationState &state,
mlir::Value *value) {
state->types.push_back(ToyArrayType::get(builder->getContext()));
state->operands.push_back(value);
state.types.push_back(ToyArrayType::get(builder->getContext()));
state.operands.push_back(value);
}
mlir::LogicalResult TransposeOp::verify() {
@ -345,10 +345,10 @@ mlir::LogicalResult TransposeOp::verify() {
return mlir::success();
}
void ReshapeOp::build(mlir::Builder *builder, mlir::OperationState *state,
void ReshapeOp::build(mlir::Builder *builder, mlir::OperationState &state,
mlir::Value *value, ToyArrayType reshapedType) {
state->types.push_back(reshapedType);
state->operands.push_back(value);
state.types.push_back(reshapedType);
state.operands.push_back(value);
}
mlir::LogicalResult ReshapeOp::verify() {
@ -363,11 +363,11 @@ mlir::LogicalResult ReshapeOp::verify() {
return mlir::success();
}
void AddOp::build(mlir::Builder *builder, mlir::OperationState *state,
void AddOp::build(mlir::Builder *builder, mlir::OperationState &state,
mlir::Value *lhs, mlir::Value *rhs) {
state->types.push_back(ToyArrayType::get(builder->getContext()));
state->operands.push_back(lhs);
state->operands.push_back(rhs);
state.types.push_back(ToyArrayType::get(builder->getContext()));
state.operands.push_back(lhs);
state.operands.push_back(rhs);
}
mlir::LogicalResult AddOp::verify() {
@ -376,11 +376,11 @@ mlir::LogicalResult AddOp::verify() {
return mlir::success();
}
void MulOp::build(mlir::Builder *builder, mlir::OperationState *state,
void MulOp::build(mlir::Builder *builder, mlir::OperationState &state,
mlir::Value *lhs, mlir::Value *rhs) {
state->types.push_back(ToyArrayType::get(builder->getContext()));
state->operands.push_back(lhs);
state->operands.push_back(rhs);
state.types.push_back(ToyArrayType::get(builder->getContext()));
state.operands.push_back(lhs);
state.operands.push_back(rhs);
}
mlir::LogicalResult MulOp::verify() {
@ -389,15 +389,15 @@ mlir::LogicalResult MulOp::verify() {
return mlir::success();
}
void AllocOp::build(mlir::Builder *builder, mlir::OperationState *state,
void AllocOp::build(mlir::Builder *builder, mlir::OperationState &state,
mlir::Type retType) {
state->types.push_back(retType);
state.types.push_back(retType);
}
void TypeCastOp::build(mlir::Builder *builder, mlir::OperationState *state,
void TypeCastOp::build(mlir::Builder *builder, mlir::OperationState &state,
mlir::Value *value, mlir::Type destTy) {
state->operands.push_back(value);
state->types.push_back(destTy);
state.operands.push_back(value);
state.types.push_back(destTy);
}
} // namespace toy

View File

@ -363,12 +363,12 @@ For each operation, there are two builder automatically generated based on the
arguments and returns types:
```c++
static void build(Builder *, OperationState *tblgen_state,
static void build(Builder *, OperationState &tblgen_state,
Type <result0-name>, Type <result1-name>, ...,
Value <arg0-name>, Value <arg1-name>, ...,
Attribute <attr0-name>, Attribute <attr1-name>, ...);
static void build(Builder *, OperationState *tblgen_state,
static void build(Builder *, OperationState &tblgen_state,
ArrayRef<Type> resultTypes,
ArrayRef<Value> operands,
ArrayRef<NamedAttribute> attributes);
@ -383,10 +383,10 @@ convenience build methods with `OpBuilder`.
`OpBuilder` is a class that takes the parameter list and the optional `build()`
method body. They are separated because we need to generate op declaration and
definition into separate files. The parameter list should _include_
`Builder *builder, OperationState *state`. If the `body` is not provided, _only_
the builder declaration will be generated; this provides a way to define
complicated builders entirely in C++ files.
definition into separate files. The parameter list should _include_ `Builder
*builder, OperationState &state`. If the `body` is not provided, _only_ the
builder declaration will be generated; this provides a way to define complicated
builders entirely in C++ files.
For example, for the following op:
@ -406,8 +406,8 @@ def MyOp : ... {
...
let builders = [
OpBuilder<"Builder *builder, OperationState *state, float val = 0.5f", [{
state->addAttribute("attr", builder->getF32FloatAttr(val));
OpBuilder<"Builder *builder, OperationState &state, float val = 0.5f", [{
state.addAttribute("attr", builder->getF32FloatAttr(val));
]}>
]
}
@ -416,8 +416,8 @@ def MyOp : ... {
The generated builder will look like:
```c++
static void build(Builder *builder, OperationState *state, float val = 0.5f) {
state->addAttribute("attr", builder->getF32FloatAttr(val));
static void build(Builder *builder, OperationState &state, float val = 0.5f) {
state.addAttribute("attr", builder->getF32FloatAttr(val));
}
```

View File

@ -148,7 +148,7 @@ order to fold chains of slice operations (introduced in the following paragraph)
and capture enough information in the ViewOp so it can be lowered to LLVM.
The entry point to the builder is the method: `static void
ViewOp::build(mlir::Builder *b, mlir::OperationState *result, mlir::Value
ViewOp::build(mlir::Builder *b, mlir::OperationState &result, mlir::Value
*memRef, llvm::ArrayRef<mlir::Value *> indexings = {});`
A `ViewOp` pretty-prints as: `%1 = linalg.view %0[%m, %n, %k] :

View File

@ -206,7 +206,7 @@ class GenericCallOp
/// This method populate the `state` that MLIR use to create operations.
/// The `toy.generic_call` operation accepts a callee name and a list of
/// arguments for the call.
static void build(mlir::OpBuilder &builder, mlir::OperationState *state,
static void build(mlir::OpBuilder &builder, mlir::OperationState &state,
llvm::StringRef callee,
llvm::ArrayRef<mlir::Value *> arguments);

View File

@ -67,7 +67,7 @@ public:
using Op::Op;
/// Builds an affine apply op with the specified map and operands.
static void build(Builder *builder, OperationState *result, AffineMap map,
static void build(Builder *builder, OperationState &result, AffineMap map,
ArrayRef<Value *> operands);
/// Returns the affine map to be applied by this operation.
@ -86,7 +86,7 @@ public:
operand_range getMapOperands() { return getOperands(); }
// Hooks to customize behavior of this op.
static ParseResult parse(OpAsmParser &parser, OperationState *result);
static ParseResult parse(OpAsmParser &parser, OperationState &result);
void print(OpAsmPrinter *p);
LogicalResult verify();
OpFoldResult fold(ArrayRef<Attribute> operands);
@ -141,7 +141,7 @@ class AffineDmaStartOp : public Op<AffineDmaStartOp, OpTrait::VariadicOperands,
public:
using Op::Op;
static void build(Builder *builder, OperationState *result, Value *srcMemRef,
static void build(Builder *builder, OperationState &result, Value *srcMemRef,
AffineMap srcMap, ArrayRef<Value *> srcIndices,
Value *destMemRef, AffineMap dstMap,
ArrayRef<Value *> destIndices, Value *tagMemRef,
@ -286,7 +286,7 @@ public:
static StringRef getTagMapAttrName() { return "tag_map"; }
static StringRef getOperationName() { return "affine.dma_start"; }
static ParseResult parse(OpAsmParser &parser, OperationState *result);
static ParseResult parse(OpAsmParser &parser, OperationState &result);
void print(OpAsmPrinter *p);
LogicalResult verify();
static void getCanonicalizationPatterns(OwningRewritePatternList &results,
@ -331,7 +331,7 @@ class AffineDmaWaitOp : public Op<AffineDmaWaitOp, OpTrait::VariadicOperands,
public:
using Op::Op;
static void build(Builder *builder, OperationState *result, Value *tagMemRef,
static void build(Builder *builder, OperationState &result, Value *tagMemRef,
AffineMap tagMap, ArrayRef<Value *> tagIndices,
Value *numElements);
@ -371,7 +371,7 @@ public:
Value *getNumElements() { return getOperand(1 + getTagMap().getNumInputs()); }
static StringRef getTagMapAttrName() { return "tag_map"; }
static ParseResult parse(OpAsmParser &parser, OperationState *result);
static ParseResult parse(OpAsmParser &parser, OperationState &result);
void print(OpAsmPrinter *p);
LogicalResult verify();
static void getCanonicalizationPatterns(OwningRewritePatternList &results,
@ -400,13 +400,13 @@ public:
using Op::Op;
/// Builds an affine load op with the specified map and operands.
static void build(Builder *builder, OperationState *result, AffineMap map,
static void build(Builder *builder, OperationState &result, AffineMap map,
ArrayRef<Value *> operands);
/// Builds an affine load op with an identity map and operands.
static void build(Builder *builder, OperationState *result, Value *memref,
static void build(Builder *builder, OperationState &result, Value *memref,
ArrayRef<Value *> indices = {});
/// Builds an affine load op with the specified map and its operands.
static void build(Builder *builder, OperationState *result, Value *memref,
static void build(Builder *builder, OperationState &result, Value *memref,
AffineMap map, ArrayRef<Value *> mapOperands);
/// Returns the operand index of the memref.
@ -439,7 +439,7 @@ public:
static StringRef getOperationName() { return "affine.load"; }
// Hooks to customize behavior of this op.
static ParseResult parse(OpAsmParser &parser, OperationState *result);
static ParseResult parse(OpAsmParser &parser, OperationState &result);
void print(OpAsmPrinter *p);
LogicalResult verify();
static void getCanonicalizationPatterns(OwningRewritePatternList &results,
@ -468,11 +468,11 @@ public:
using Op::Op;
/// Builds an affine store operation with the provided indices (identity map).
static void build(Builder *builder, OperationState *result,
static void build(Builder *builder, OperationState &result,
Value *valueToStore, Value *memref,
ArrayRef<Value *> indices);
/// Builds an affine store operation with the specified map and its operands.
static void build(Builder *builder, OperationState *result,
static void build(Builder *builder, OperationState &result,
Value *valueToStore, Value *memref, AffineMap map,
ArrayRef<Value *> mapOperands);
@ -510,7 +510,7 @@ public:
static StringRef getOperationName() { return "affine.store"; }
// Hooks to customize behavior of this op.
static ParseResult parse(OpAsmParser &parser, OperationState *result);
static ParseResult parse(OpAsmParser &parser, OperationState &result);
void print(OpAsmPrinter *p);
LogicalResult verify();
static void getCanonicalizationPatterns(OwningRewritePatternList &results,

View File

@ -42,7 +42,7 @@ class Affine_Op<string mnemonic, list<OpTrait> traits = []> :
// * void print(OpAsmPrinter *p, ${C++ class of Op} op)
// * LogicalResult verify(${C++ class of Op} op)
// * ParseResult parse${C++ class of Op}(OpAsmParser &parser,
// OperationState *result)
// OperationState &result)
// functions.
let printer = [{ return ::print(p, *this); }];
let verifier = [{ return ::verify(*this); }];
@ -89,9 +89,9 @@ def AffineForOp : Affine_Op<"for", [ImplicitAffineTerminator]> {
let skipDefaultBuilders = 1;
let builders = [
OpBuilder<"Builder *builder, OperationState *result, "
OpBuilder<"Builder *builder, OperationState &result, "
"int64_t lowerBound, int64_t upperBound, int64_t step = 1">,
OpBuilder<"Builder *builder, OperationState *result, "
OpBuilder<"Builder *builder, OperationState &result, "
"ArrayRef<Value *> lbOperands, AffineMap lbMap, "
"ArrayRef<Value *> ubOperands, AffineMap ubMap, "
"int64_t step = 1">
@ -214,7 +214,7 @@ def AffineIfOp : Affine_Op<"if", [ImplicitAffineTerminator]> {
let skipDefaultBuilders = 1;
let builders = [
OpBuilder<"Builder *builder, OperationState *result, "
OpBuilder<"Builder *builder, OperationState &result, "
"IntegerSet set, ArrayRef<Value *> args, bool withElseRegion">
];

View File

@ -66,7 +66,7 @@ class LaunchOp : public Op<LaunchOp, OpTrait::AtLeastNOperands<6>::Impl,
public:
using Op::Op;
static void build(Builder *builder, OperationState *result, Value *gridSizeX,
static void build(Builder *builder, OperationState &result, Value *gridSizeX,
Value *gridSizeY, Value *gridSizeZ, Value *blockSizeX,
Value *blockSizeY, Value *blockSizeZ,
ArrayRef<Value *> operands);
@ -99,7 +99,7 @@ public:
/// Custom syntax support.
void print(OpAsmPrinter *p);
static ParseResult parse(OpAsmParser &parser, OperationState *result);
static ParseResult parse(OpAsmParser &parser, OperationState &result);
static StringRef getOperationName() { return "gpu.launch"; }
@ -131,12 +131,12 @@ class LaunchFuncOp : public Op<LaunchFuncOp, OpTrait::AtLeastNOperands<6>::Impl,
public:
using Op::Op;
static void build(Builder *builder, OperationState *result, FuncOp kernelFunc,
static void build(Builder *builder, OperationState &result, FuncOp kernelFunc,
Value *gridSizeX, Value *gridSizeY, Value *gridSizeZ,
Value *blockSizeX, Value *blockSizeY, Value *blockSizeZ,
ArrayRef<Value *> kernelOperands);
static void build(Builder *builder, OperationState *result, FuncOp kernelFunc,
static void build(Builder *builder, OperationState &result, FuncOp kernelFunc,
KernelDim3 gridSize, KernelDim3 blockSize,
ArrayRef<Value *> kernelOperands);

View File

@ -38,23 +38,23 @@ class LLVM_Builder<string builder> {
}
def LLVM_OneResultOpBuilder : OpBuilder<
"Builder *, OperationState *result, Type resultType, "
"Builder *, OperationState &result, Type resultType, "
"ArrayRef<Value *> operands, ArrayRef<NamedAttribute> attributes = {}",
[{
if (resultType) result->addTypes(resultType);
result->addOperands(operands);
if (resultType) result.addTypes(resultType);
result.addOperands(operands);
for (auto namedAttr : attributes) {
result->addAttribute(namedAttr.first, namedAttr.second);
result.addAttribute(namedAttr.first, namedAttr.second);
}
}]>;
def LLVM_ZeroResultOpBuilder : OpBuilder<
"Builder *, OperationState *result, ArrayRef<Value *> operands, "
"Builder *, OperationState &result, ArrayRef<Value *> operands, "
"ArrayRef<NamedAttribute> attributes = {}",
[{
result->addOperands(operands);
result.addOperands(operands);
for (auto namedAttr : attributes) {
result->addAttribute(namedAttr.first, namedAttr.second);
result.addAttribute(namedAttr.first, namedAttr.second);
}
}]>;
@ -71,7 +71,7 @@ class LLVM_OneResultOp<string mnemonic, list<OpTrait> traits = []> :
// Compatibility builder that takes an instance of wrapped llvm::VoidType
// to indicate no result.
def LLVM_VoidResultTypeOpBuilder : OpBuilder<
"Builder *builder, OperationState *result, Type resultType, "
"Builder *builder, OperationState &result, Type resultType, "
"ArrayRef<Value *> operands, ArrayRef<NamedAttribute> attributes = {}",
[{
auto llvmType = resultType.dyn_cast<LLVM::LLVMType>(); (void)llvmType;
@ -94,23 +94,23 @@ class LLVM_TerminatorOp<string mnemonic, list<OpTrait> traits = []> :
Arguments<(ins Variadic<LLVM_Type>:$args)>, Results<(outs)> {
let builders = [
OpBuilder<
"Builder *, OperationState *result, "
"Builder *, OperationState &result, "
"ArrayRef<Value *> properOperands, "
"ArrayRef<Block *> destinations, "
"ArrayRef<ArrayRef<Value *>> operands, "
"ArrayRef<NamedAttribute> attributes = {}",
[{
result->addOperands(properOperands);
result.addOperands(properOperands);
for (auto kvp : llvm::zip(destinations, operands)) {
result->addSuccessor(std::get<0>(kvp), std::get<1>(kvp));
result.addSuccessor(std::get<0>(kvp), std::get<1>(kvp));
}
for (auto namedAttr : attributes) {
result->addAttribute(namedAttr.first, namedAttr.second);
result.addAttribute(namedAttr.first, namedAttr.second);
}
}]
>,
OpBuilder<
"Builder *builder, OperationState *result, "
"Builder *builder, OperationState &result, "
"ArrayRef<Value *> properOperands, "
"ArrayRef<Block *> destinations, "
"ArrayRef<NamedAttribute> attributes = {}",
@ -178,7 +178,7 @@ def LLVM_ICmpOp : LLVM_OneResultOp<"icmp", [NoSideEffect]>,
$res = builder.CreateICmp(getLLVMCmpPredicate($predicate), $lhs, $rhs);
}];
let builders = [OpBuilder<
"Builder *b, OperationState *result, ICmpPredicate predicate, Value *lhs, "
"Builder *b, OperationState &result, ICmpPredicate predicate, Value *lhs, "
"Value *rhs", [{
LLVMDialect *dialect = &lhs->getType().cast<LLVMType>().getDialect();
build(b, result, LLVMType::getInt1Ty(dialect),
@ -254,7 +254,7 @@ def LLVM_AllocaOp :
$res = alloca;
}];
let builders = [OpBuilder<
"Builder *b, OperationState *result, Type resultType, Value *arraySize, "
"Builder *b, OperationState &result, Type resultType, Value *arraySize, "
"unsigned alignment",
[{
if (alignment == 0)
@ -281,7 +281,7 @@ def LLVM_GEPOp : LLVM_OneResultOp<"getelementptr", [NoSideEffect]>,
def LLVM_LoadOp : LLVM_OneResultOp<"load">, Arguments<(ins LLVM_Type:$addr)>,
LLVM_Builder<"$res = builder.CreateLoad($addr);"> {
let builders = [OpBuilder<
"Builder *b, OperationState *result, Value *addr",
"Builder *b, OperationState &result, Value *addr",
[{
auto type = addr->getType().cast<LLVM::LLVMType>().getPointerElementTy();
build(b, result, type, addr);
@ -341,7 +341,7 @@ def LLVM_ExtractElementOp : LLVM_OneResultOp<"extractelement", [NoSideEffect]>,
$res = builder.CreateExtractElement($vector, $position);
}];
let builders = [OpBuilder<
"Builder *b, OperationState *result, Value *vector, Value *position,"
"Builder *b, OperationState &result, Value *vector, Value *position,"
"ArrayRef<NamedAttribute> attrs = {}">];
let parser = [{ return parseExtractElementOp(parser, result); }];
let printer = [{ printExtractElementOp(p, *this); }];
@ -372,7 +372,7 @@ def LLVM_InsertValueOp : LLVM_OneResultOp<"insertvalue", [NoSideEffect]>,
extractPosition($position));
}];
let builders = [OpBuilder<
"Builder *b, OperationState *result, Value *container, Value *value, "
"Builder *b, OperationState &result, Value *container, Value *value, "
"ArrayAttr position",
[{
build(b, result, container->getType(), container, value, position);
@ -386,7 +386,7 @@ def LLVM_ShuffleVectorOp
LLVM_Builder<
"$res = builder.CreateShuffleVector($v1, $v2, extractPosition($mask));"> {
let builders = [OpBuilder<
"Builder *b, OperationState *result, Value *v1, Value *v2, "
"Builder *b, OperationState &result, Value *v1, Value *v2, "
"ArrayAttr mask, ArrayRef<NamedAttribute> attrs = {}">];
let verifier = [{
auto wrappedVectorType1 = v1()->getType().cast<LLVM::LLVMType>();
@ -410,7 +410,7 @@ def LLVM_SelectOp
LLVM_Builder<
"$res = builder.CreateSelect($condition, $trueValue, $falseValue);"> {
let builders = [OpBuilder<
"Builder *b, OperationState *result, Value *condition, Value *lhs, "
"Builder *b, OperationState &result, Value *condition, Value *lhs, "
"Value *rhs", [{
build(b, result, lhs->getType(), condition, lhs, rhs);
}]>];
@ -461,13 +461,13 @@ def LLVM_AddressOfOp
: LLVM_OneResultOp<"mlir.addressof">,
Arguments<(ins SymbolRefAttr:$global_name)> {
let builders = [
OpBuilder<"Builder *builder, OperationState *result, LLVMType resType, "
OpBuilder<"Builder *builder, OperationState &result, LLVMType resType, "
"StringRef name, ArrayRef<NamedAttribute> attrs = {}", [{
result->addAttribute("global_name", builder->getSymbolRefAttr(name));
result->addAttributes(attrs);
result->addTypes(resType);}]>,
result.addAttribute("global_name", builder->getSymbolRefAttr(name));
result.addAttributes(attrs);
result.addTypes(resType);}]>,
OpBuilder<"Builder *builder, OperationState *result, GlobalOp global, "
OpBuilder<"Builder *builder, OperationState &result, GlobalOp global, "
"ArrayRef<NamedAttribute> attrs = {}", [{
build(builder, result, global.getType().getPointerTo(), global.sym_name(),
attrs);}]>
@ -491,7 +491,7 @@ def LLVM_GlobalOp
DefaultValuedAttr<NonNegativeI32Attr, "0">:$addr_space)> {
let builders = [
OpBuilder<"Builder *builder, OperationState *result, LLVMType type, "
OpBuilder<"Builder *builder, OperationState &result, LLVMType type, "
"bool isConstant, StringRef name, Attribute value, "
"ArrayRef<NamedAttribute> attrs = {}">
];
@ -517,7 +517,7 @@ def LLVM_LLVMFuncOp : LLVM_ZeroResultOp<"func",
let skipDefaultBuilders = 1;
let builders = [
OpBuilder<"Builder *builder, OperationState *result, StringRef name, "
OpBuilder<"Builder *builder, OperationState &result, StringRef name, "
"LLVMType type, ArrayRef<NamedAttribute> attrs, "
"ArrayRef<NamedAttributeList> argAttrs = {}">
];

View File

@ -194,7 +194,7 @@ def CopyOp : LinalgLibrary_Op<"copy", [NInputsAndOutputs<1, 1>]> {
// TODO(ntv) this should go away once the usage of OptionalAttr triggers
// emission of builders with default arguments left unspecified.
let builders = [OpBuilder<
"Builder *builder, OperationState *result, Value *input, Value *output", [{
"Builder *builder, OperationState &result, Value *input, Value *output", [{
return build(
builder, result, input, output, AffineMapAttr(), AffineMapAttr());
}]>];

View File

@ -33,7 +33,7 @@ class Linalg_Op<string mnemonic, list<OpTrait> traits = []> :
// * void print(OpAsmPrinter *p, ${C++ class of Op} op)
// * LogicalResult verify(${C++ class of Op} op)
// * ParseResult parse${C++ class of Op}(OpAsmParser &parser,
// OperationState *result)
// OperationState &result)
// functions.
let printer = [{ return ::print(p, *this); }];
let verifier = [{ return ::verify(*this); }];
@ -71,29 +71,29 @@ def BufferAllocOp :
}];
let builders = [
OpBuilder<
"Builder *b, OperationState *result, BufferType bufferType", [{
result->addTypes(bufferType);
"Builder *b, OperationState &result, BufferType bufferType", [{
result.addTypes(bufferType);
}]>,
OpBuilder<
"Builder *b, OperationState *result, BufferType bufferType, "
"Builder *b, OperationState &result, BufferType bufferType, "
"unsigned alignment", [{
build(b, result, bufferType);
if (alignment != 0)
result->addAttribute(BufferAllocOp::getAlignmentAttrName(),
result.addAttribute(BufferAllocOp::getAlignmentAttrName(),
b->getI64IntegerAttr(alignment));
}]>,
OpBuilder<
"Builder *b, OperationState *result, BufferType bufferType, "
"Builder *b, OperationState &result, BufferType bufferType, "
"Value *size, unsigned alignment", [{
if (alignment == 0)
return build(b, result, bufferType, size);
build(b, result, bufferType, size, b->getI64IntegerAttr(alignment));
}]>,
OpBuilder<
"Builder *b, OperationState *result, BufferType bufferType, Value *size",
"Builder *b, OperationState &result, BufferType bufferType, Value *size",
[{
result->addOperands(size);
result->addTypes(bufferType);
result.addOperands(size);
result.addTypes(bufferType);
}]>
];
let extraClassDeclaration = [{
@ -163,12 +163,12 @@ def DimOp : Linalg_Op<"dim", [NoSideEffect]>,
}];
let builders = [OpBuilder<
"Builder *builder, OperationState *result, Value *view, unsigned index",
"Builder *builder, OperationState &result, Value *view, unsigned index",
[{
result->addOperands(view);
result->addAttribute(
result.addOperands(view);
result.addAttribute(
"index", builder->getIntegerAttr(builder->getIndexType(), index));
result->types.push_back(builder->getIndexType());
result.types.push_back(builder->getIndexType());
}]>];
let extraClassDeclaration = [{
@ -200,7 +200,7 @@ def LoadOp :
%0 = linalg.load %V[%c0] : !linalg.view<?xf32>
}];
let builders = [OpBuilder<
"Builder *builder, OperationState *result, Value *view, "
"Builder *builder, OperationState &result, Value *view, "
"ArrayRef<Value*> indices",
[{
auto viewType = view->getType().cast<ViewType>();
@ -226,7 +226,7 @@ def RangeOp :
%3 = linalg.range %0:%1:%2 : !linalg.range
}];
let builders = [OpBuilder<
"Builder *builder, OperationState *result, Value *min, Value *max, "
"Builder *builder, OperationState &result, Value *min, Value *max, "
"Value *step",
[{
auto rangeType = RangeType::get(builder->getContext());
@ -274,7 +274,7 @@ def SliceOp : Linalg_Op<"slice", [NoSideEffect]>,
}];
let builders = [OpBuilder<
"Builder *b, OperationState *result, Value *base, "
"Builder *b, OperationState &result, Value *base, "
"ArrayRef<Value *> indexings">];
let extraClassDeclaration = [{
@ -351,12 +351,12 @@ def SubViewOp : Linalg_Op<"subview", [NoSideEffect]>,
// linalg.subview %0[%1:%2:%3][%4:%5:%6] : view<?x?xf32>
let builders = [OpBuilder<
"Builder *builder, OperationState *result, Value *view, "
"Builder *builder, OperationState &result, Value *view, "
"ArrayRef<Value *> ranges",
[{
result->addOperands(view);
result->addOperands(ranges);
result->types.push_back(view->getType());
result.addOperands(view);
result.addOperands(ranges);
result.types.push_back(view->getType());
}]>];
let verifier = [{
@ -389,12 +389,12 @@ def SubViewOp : Linalg_Op<"subview", [NoSideEffect]>,
// This requires `SubViewOp` to be declared, in the future it should be
// folded into the builders.
static void build(Builder *builder, OperationState *result, Value *view,
static void build(Builder *builder, OperationState &result, Value *view,
ArrayRef<SubViewOp::Range> ranges) {
result->addOperands(view);
result.addOperands(view);
for (auto r : ranges)
result->addOperands({r.min, r.max, r.step});
result->types.push_back(view->getType());
result.addOperands({r.min, r.max, r.step});
result.types.push_back(view->getType());
}
}];
}
@ -413,7 +413,7 @@ def TransposeOp : Linalg_Op<"transpose", [NoSideEffect]>,
}];
let builders = [OpBuilder<
"Builder *b, OperationState *result, Value *view, "
"Builder *b, OperationState &result, Value *view, "
"AffineMapAttr permutation, ArrayRef<NamedAttribute> attrs = {}">];
let verifier = [{
@ -451,7 +451,7 @@ def ViewOp : Linalg_Op<"view", [NoSideEffect]>,
}];
let builders = [OpBuilder<
"Builder *b, OperationState *result, Value *buffer, "
"Builder *b, OperationState &result, Value *buffer, "
"ArrayRef<Value *> ranges, Type resultType = Type(), "
"ArrayRef<NamedAttribute> attrs = {}">];

View File

@ -40,7 +40,7 @@ class Loop_Op<string mnemonic, list<OpTrait> traits = []> :
// * void print(OpAsmPrinter *p, ${C++ class of Op} op)
// * LogicalResult verify(${C++ class of Op} op)
// * ParseResult parse${C++ class of Op}(OpAsmParser &parser,
// OperationState *result)
// OperationState &result)
// functions.
let printer = [{ return ::print(p, *this); }];
let verifier = [{ return ::verify(*this); }];
@ -75,7 +75,7 @@ def ForOp : Loop_Op<"for",
let skipDefaultBuilders = 1;
let builders = [
OpBuilder<"Builder *builder, OperationState *result, "
OpBuilder<"Builder *builder, OperationState &result, "
"Value *lowerBound, Value *upperBound, Value *step">
];
@ -117,7 +117,7 @@ def IfOp : Loop_Op<"if",
let skipDefaultBuilders = 1;
let builders = [
OpBuilder<"Builder *builder, OperationState *result, "
OpBuilder<"Builder *builder, OperationState &result, "
"Value *cond, bool withElseRegion">
];

View File

@ -1137,7 +1137,7 @@ class SPV_Op<string mnemonic, list<OpTrait> traits = []> :
// in SPVOps.cpp:
//
// * static ParseResult parse<op-c++-class-name>(OpAsmParser &parser,
// OperationState *result)
// OperationState &result)
// * static void print(OpAsmPrinter *p, <op-c++-class-name> op)
// * static LogicalResult verify(<op-c++-class-name> op)
let parser = [{ return ::parse$cppClass(parser, result); }];

View File

@ -56,8 +56,8 @@ def SPV_BranchOp : SPV_Op<"Branch", [Terminator]> {
let builders = [
OpBuilder<
"Builder *, OperationState *state, Block *successor", [{
state->addSuccessor(successor, {});
"Builder *, OperationState &state, Block *successor", [{
state.addSuccessor(successor, {});
}]
>
];
@ -118,18 +118,18 @@ def SPV_BranchConditionalOp : SPV_Op<"BranchConditional", [Terminator]> {
let builders = [
OpBuilder<
"Builder *builder, OperationState *state, Value *condition, "
"Builder *builder, OperationState &state, Value *condition, "
"Block *trueBranch, Block *falseBranch, "
"Optional<std::pair<uint32_t, uint32_t>> weights",
[{
state->addOperands(condition);
state->addSuccessor(trueBranch, {});
state->addSuccessor(falseBranch, {});
state.addOperands(condition);
state.addSuccessor(trueBranch, {});
state.addSuccessor(falseBranch, {});
if (weights) {
auto attr =
builder->getI32ArrayAttr({static_cast<int32_t>(weights->first),
static_cast<int32_t>(weights->second)});
state->addAttribute("branch_weights", attr);
state.addAttribute("branch_weights", attr);
}
}]
>

View File

@ -120,7 +120,7 @@ def SPV_AccessChainOp : SPV_Op<"AccessChain", [NoSideEffect]> {
SPV_AnyPtr:$component_ptr
);
let builders = [OpBuilder<[{Builder *builder, OperationState *state,
let builders = [OpBuilder<[{Builder *builder, OperationState &state,
Value *basePtr, ArrayRef<Value *> indices}]>];
}

View File

@ -306,8 +306,8 @@ def SPV_ModuleOp : SPV_Op<"module",
let regions = (region SizedRegion<1>:$body);
let builders = [OpBuilder<"Builder *, OperationState *state">,
OpBuilder<[{Builder *, OperationState *state,
let builders = [OpBuilder<"Builder *, OperationState &state">,
OpBuilder<[{Builder *, OperationState &state,
IntegerAttr addressing_model,
IntegerAttr memory_model,
/*optional*/ArrayAttr capabilities = nullptr,

View File

@ -106,7 +106,7 @@ public:
using ConstantOp::ConstantOp;
/// Builds a constant float op producing a float of the specified type.
static void build(Builder *builder, OperationState *result,
static void build(Builder *builder, OperationState &result,
const APFloat &value, FloatType type);
APFloat getValue() { return getAttrOfType<FloatAttr>("value").getValue(); }
@ -123,12 +123,12 @@ class ConstantIntOp : public ConstantOp {
public:
using ConstantOp::ConstantOp;
/// Build a constant int op producing an integer of the specified width.
static void build(Builder *builder, OperationState *result, int64_t value,
static void build(Builder *builder, OperationState &result, int64_t value,
unsigned width);
/// Build a constant int op producing an integer with the specified type,
/// which must be an integer type.
static void build(Builder *builder, OperationState *result, int64_t value,
static void build(Builder *builder, OperationState &result, int64_t value,
Type type);
int64_t getValue() { return getAttrOfType<IntegerAttr>("value").getInt(); }
@ -146,7 +146,7 @@ public:
using ConstantOp::ConstantOp;
/// Build a constant int op producing an index.
static void build(Builder *builder, OperationState *result, int64_t value);
static void build(Builder *builder, OperationState &result, int64_t value);
int64_t getValue() { return getAttrOfType<IntegerAttr>("value").getInt(); }
@ -195,7 +195,7 @@ class DmaStartOp
public:
using Op::Op;
static void build(Builder *builder, OperationState *result, Value *srcMemRef,
static void build(Builder *builder, OperationState &result, Value *srcMemRef,
ArrayRef<Value *> srcIndices, Value *destMemRef,
ArrayRef<Value *> destIndices, Value *numElements,
Value *tagMemRef, ArrayRef<Value *> tagIndices,
@ -277,7 +277,7 @@ public:
}
static StringRef getOperationName() { return "std.dma_start"; }
static ParseResult parse(OpAsmParser &parser, OperationState *result);
static ParseResult parse(OpAsmParser &parser, OperationState &result);
void print(OpAsmPrinter *p);
LogicalResult verify();
@ -320,7 +320,7 @@ class DmaWaitOp
public:
using Op::Op;
static void build(Builder *builder, OperationState *result, Value *tagMemRef,
static void build(Builder *builder, OperationState &result, Value *tagMemRef,
ArrayRef<Value *> tagIndices, Value *numElements);
static StringRef getOperationName() { return "std.dma_wait"; }
@ -342,7 +342,7 @@ public:
// Returns the number of elements transferred in the associated DMA operation.
Value *getNumElements() { return getOperand(1 + getTagMemRefRank()); }
static ParseResult parse(OpAsmParser &parser, OperationState *result);
static ParseResult parse(OpAsmParser &parser, OperationState &result);
void print(OpAsmPrinter *p);
static void getCanonicalizationPatterns(OwningRewritePatternList &results,
MLIRContext *context);

View File

@ -40,7 +40,7 @@ class Std_Op<string mnemonic, list<OpTrait> traits = []> :
// * void print(OpAsmPrinter *p, ${C++ class of Op} op)
// * LogicalResult verify(${C++ class of Op} op)
// * ParseResult parse${C++ class of Op}(OpAsmParser &parser,
// OperationState *result)
// OperationState &result)
// functions.
let printer = [{ return ::print(p, *this); }];
let verifier = [{ return ::verify(*this); }];
@ -55,7 +55,7 @@ class CastOp<string mnemonic, list<OpTrait> traits = []> :
let results = (outs AnyType);
let builders = [OpBuilder<
"Builder *builder, OperationState *result, Value *source, Type destType", [{
"Builder *builder, OperationState &result, Value *source, Type destType", [{
impl::buildCastOp(builder, result, source, destType);
}]>];
@ -149,8 +149,8 @@ def AllocOp : Std_Op<"alloc"> {
let results = (outs AnyMemRef);
let builders = [OpBuilder<
"Builder *builder, OperationState *result, MemRefType memrefType", [{
result->types.push_back(memrefType);
"Builder *builder, OperationState &result, MemRefType memrefType", [{
result.types.push_back(memrefType);
}]
>];
@ -195,9 +195,9 @@ def BranchOp : Std_Op<"br", [Terminator]> {
let arguments = (ins Variadic<AnyType>:$operands);
let builders = [OpBuilder<
"Builder *, OperationState *result, Block *dest,"
"Builder *, OperationState &result, Block *dest,"
"ArrayRef<Value *> operands = {}", [{
result->addSuccessor(dest, operands);
result.addSuccessor(dest, operands);
}]>];
// BranchOp is fully verified by traits.
@ -226,17 +226,17 @@ def CallOp : Std_Op<"call"> {
let results = (outs Variadic<AnyType>);
let builders = [OpBuilder<
"Builder *builder, OperationState *result, FuncOp callee,"
"Builder *builder, OperationState &result, FuncOp callee,"
"ArrayRef<Value *> operands = {}", [{
result->addOperands(operands);
result->addAttribute("callee", builder->getSymbolRefAttr(callee));
result->addTypes(callee.getType().getResults());
result.addOperands(operands);
result.addAttribute("callee", builder->getSymbolRefAttr(callee));
result.addTypes(callee.getType().getResults());
}]>, OpBuilder<
"Builder *builder, OperationState *result, StringRef callee,"
"Builder *builder, OperationState &result, StringRef callee,"
"ArrayRef<Type> results, ArrayRef<Value *> operands = {}", [{
result->addOperands(operands);
result->addAttribute("callee", builder->getSymbolRefAttr(callee));
result->addTypes(results);
result.addOperands(operands);
result.addAttribute("callee", builder->getSymbolRefAttr(callee));
result.addTypes(results);
}]>];
let extraClassDeclaration = [{
@ -268,11 +268,11 @@ def CallIndirectOp : Std_Op<"call_indirect"> {
let results = (outs Variadic<AnyType>);
let builders = [OpBuilder<
"Builder *, OperationState *result, Value *callee,"
"Builder *, OperationState &result, Value *callee,"
"ArrayRef<Value *> operands = {}", [{
result->operands.push_back(callee);
result->addOperands(operands);
result->addTypes(callee->getType().cast<FunctionType>().getResults());
result.operands.push_back(callee);
result.addOperands(operands);
result.addTypes(callee->getType().cast<FunctionType>().getResults());
}]>];
let extraClassDeclaration = [{
@ -317,7 +317,7 @@ def CmpIOp : Std_Op<"cmpi", [NoSideEffect, SameTypeOperands, SameOperandsAndResu
let results = (outs BoolLike);
let builders = [OpBuilder<
"Builder *builder, OperationState *result, CmpIPredicate predicate,"
"Builder *builder, OperationState &result, CmpIPredicate predicate,"
"Value *lhs, Value *rhs", [{
::buildCmpIOp(builder, result, predicate, lhs, rhs);
}]>];
@ -363,7 +363,7 @@ def CmpFOp : Std_Op<"cmpf", [NoSideEffect, SameTypeOperands, SameOperandsAndResu
let results = (outs BoolLike);
let builders = [OpBuilder<
"Builder *builder, OperationState *result, CmpFPredicate predicate,"
"Builder *builder, OperationState &result, CmpFPredicate predicate,"
"Value *lhs, Value *rhs", [{
::buildCmpFOp(builder, result, predicate, lhs, rhs);
}]>];
@ -401,12 +401,12 @@ def CondBranchOp : Std_Op<"cond_br", [Terminator]> {
let arguments = (ins I1:$condition, Variadic<AnyType>:$branchOperands);
let builders = [OpBuilder<
"Builder *, OperationState *result, Value *condition,"
"Builder *, OperationState &result, Value *condition,"
"Block *trueDest, ArrayRef<Value *> trueOperands,"
"Block *falseDest, ArrayRef<Value *> falseOperands", [{
result->addOperands(condition);
result->addSuccessor(trueDest, trueOperands);
result->addSuccessor(falseDest, falseOperands);
result.addOperands(condition);
result.addSuccessor(trueDest, trueOperands);
result.addSuccessor(falseDest, falseOperands);
}]>];
// CondBranchOp is fully verified by traits.
@ -506,7 +506,7 @@ def ConstantOp : Std_Op<"constant", [NoSideEffect]> {
let results = (outs AnyType);
let builders = [OpBuilder<
"Builder *builder, OperationState *result, Attribute value",
"Builder *builder, OperationState &result, Attribute value",
[{ build(builder, result, value.getType(), value); }]>];
let extraClassDeclaration = [{
@ -554,7 +554,7 @@ def DimOp : Std_Op<"dim", [NoSideEffect]> {
let results = (outs Index);
let builders = [OpBuilder<
"Builder *builder, OperationState *result, Value *memrefOrTensor,"
"Builder *builder, OperationState &result, Value *memrefOrTensor,"
"unsigned index", [{
auto indexType = builder->getIndexType();
auto indexAttr = builder->getIntegerAttr(indexType, index);
@ -603,7 +603,7 @@ def ExtractElementOp : Std_Op<"extract_element", [NoSideEffect]> {
let results = (outs AnyType);
let builders = [OpBuilder<
"Builder *builder, OperationState *result, Value *aggregate,"
"Builder *builder, OperationState &result, Value *aggregate,"
"ArrayRef<Value *> indices = {}", [{
auto resType = aggregate->getType().cast<ShapedType>()
.getElementType();
@ -673,12 +673,12 @@ def LoadOp : Std_Op<"load"> {
let results = (outs AnyType);
let builders = [OpBuilder<
"Builder *, OperationState *result, Value *memref,"
"Builder *, OperationState &result, Value *memref,"
"ArrayRef<Value *> indices = {}", [{
auto memrefType = memref->getType().cast<MemRefType>();
result->addOperands(memref);
result->addOperands(indices);
result->types.push_back(memrefType.getElementType());
result.addOperands(memref);
result.addOperands(indices);
result.types.push_back(memrefType.getElementType());
}]>];
let extraClassDeclaration = [{
@ -756,7 +756,7 @@ def RankOp : Std_Op<"rank", [NoSideEffect]> {
let verifier = ?;
let builders = [OpBuilder<
"Builder *builder, OperationState *result, Value *tensor", [{
"Builder *builder, OperationState &result, Value *tensor", [{
auto indexType = builder->getIndexType();
build(builder, result, indexType, tensor);
}]>];
@ -794,7 +794,7 @@ def ReturnOp : Std_Op<"return", [Terminator, HasParent<"FuncOp">]> {
let arguments = (ins Variadic<AnyType>:$operands);
let builders = [OpBuilder<
"Builder *b, OperationState *result", [{ build(b, result, llvm::None); }]
"Builder *b, OperationState &result", [{ build(b, result, llvm::None); }]
>];
}
@ -818,10 +818,10 @@ def SelectOp : Std_Op<"select", [NoSideEffect, SameOperandsAndResultShape]> {
let results = (outs AnyType);
let builders = [OpBuilder<
"Builder *builder, OperationState *result, Value *condition,"
"Builder *builder, OperationState &result, Value *condition,"
"Value *trueValue, Value *falseValue", [{
result->addOperands({condition, trueValue, falseValue});
result->addTypes(trueValue->getType());
result.addOperands({condition, trueValue, falseValue});
result.addTypes(trueValue->getType());
}]>];
let extraClassDeclaration = [{
@ -862,9 +862,9 @@ def StoreOp : Std_Op<"store"> {
let arguments = (ins AnyType:$value, AnyMemRef:$memref, Variadic<Index>:$indices);
let builders = [OpBuilder<
"Builder *, OperationState *result, Value *valueToStore, Value *memref", [{
result->addOperands(valueToStore);
result->addOperands(memref);
"Builder *, OperationState &result, Value *valueToStore, Value *memref", [{
result.addOperands(valueToStore);
result.addOperands(memref);
}]>];
let extraClassDeclaration = [{
@ -928,12 +928,12 @@ def TensorLoadOp : Std_Op<"tensor_load",
let verifier = ?;
let builders = [OpBuilder<
"Builder *builder, OperationState *result, Value *memref", [{
"Builder *builder, OperationState &result, Value *memref", [{
auto memrefType = memref->getType().cast<MemRefType>();
auto resultType = builder->getTensorType(memrefType.getShape(),
memrefType.getElementType());
result->addOperands(memref);
result->addTypes(resultType);
result.addOperands(memref);
result.addTypes(resultType);
}]>];

View File

@ -98,7 +98,7 @@ public:
static StringRef getOperationName() { return "vector.transfer_read"; }
static StringRef getPermutationMapAttrName() { return "permutation_map"; }
static void build(Builder *builder, OperationState *result,
static void build(Builder *builder, OperationState &result,
VectorType vectorType, Value *srcMemRef,
ArrayRef<Value *> srcIndices, AffineMap permutationMap,
Optional<Value *> paddingValue = None);
@ -115,7 +115,7 @@ public:
Optional<Value *> getPaddingValue();
AffineMap getPermutationMap();
static ParseResult parse(OpAsmParser &parser, OperationState *result);
static ParseResult parse(OpAsmParser &parser, OperationState &result);
void print(OpAsmPrinter *p);
LogicalResult verify();
};
@ -162,7 +162,7 @@ public:
static StringRef getOperationName() { return "vector.transfer_write"; }
static StringRef getPermutationMapAttrName() { return "permutation_map"; }
static void build(Builder *builder, OperationState *result, Value *srcVector,
static void build(Builder *builder, OperationState &result, Value *srcVector,
Value *dstMemRef, ArrayRef<Value *> dstIndices,
AffineMap permutationMap);
Value *getVector() { return getOperand(Offsets::VectorOffset); }
@ -176,7 +176,7 @@ public:
operand_range getIndices();
AffineMap getPermutationMap();
static ParseResult parse(OpAsmParser &parser, OperationState *result);
static ParseResult parse(OpAsmParser &parser, OperationState &result);
void print(OpAsmPrinter *p);
LogicalResult verify();
};
@ -196,9 +196,9 @@ public:
using Op::Op;
static StringRef getOperationName() { return "vector.type_cast"; }
static void build(Builder *builder, OperationState *result, Value *srcVector,
static void build(Builder *builder, OperationState &result, Value *srcVector,
Type dstType);
static ParseResult parse(OpAsmParser &parser, OperationState *result);
static ParseResult parse(OpAsmParser &parser, OperationState &result);
void print(OpAsmPrinter *p);
LogicalResult verify();
};

View File

@ -40,7 +40,7 @@ class Vector_Op<string mnemonic, list<OpTrait> traits = []> :
// * void print(OpAsmPrinter *p, ${C++ class of Op} op)
// * LogicalResult verify(${C++ class of Op} op)
// * ParseResult parse${C++ class of Op}(OpAsmParser &parser,
// OperationState *result)
// OperationState &result)
// functions.
let printer = [{ return ::print(p, *this); }];
let verifier = [{ return ::verify(*this); }];

View File

@ -315,7 +315,7 @@ public:
template <typename OpTy, typename... Args>
OpTy create(Location location, Args &&... args) {
OperationState state(location, OpTy::getOperationName());
OpTy::build(this, &state, std::forward<Args>(args)...);
OpTy::build(this, state, std::forward<Args>(args)...);
auto *op = createOperation(state);
auto result = dyn_cast<OpTy>(op);
assert(result && "Builder didn't return the right type");

View File

@ -52,14 +52,14 @@ public:
ArrayRef<NamedAttribute> attrs,
ArrayRef<NamedAttributeList> argAttrs);
static void build(Builder *builder, OperationState *result, StringRef name,
static void build(Builder *builder, OperationState &result, StringRef name,
FunctionType type, ArrayRef<NamedAttribute> attrs);
static void build(Builder *builder, OperationState *result, StringRef name,
static void build(Builder *builder, OperationState &result, StringRef name,
FunctionType type, ArrayRef<NamedAttribute> attrs,
ArrayRef<NamedAttributeList> argAttrs);
/// Operation hooks.
static ParseResult parse(OpAsmParser &parser, OperationState *result);
static ParseResult parse(OpAsmParser &parser, OperationState &result);
void print(OpAsmPrinter *p);
LogicalResult verify();

View File

@ -79,7 +79,7 @@ using FuncTypeBuilder = llvm::function_ref<Type(
/// whether the function is variadic. If the builder returns a null type,
/// `result` will not contain the `type` attribute. The caller can then add a
/// type, report the error or delegate the reporting to the op's verifier.
ParseResult parseFunctionLikeOp(OpAsmParser &parser, OperationState *result,
ParseResult parseFunctionLikeOp(OpAsmParser &parser, OperationState &result,
bool allowVariadic,
FuncTypeBuilder funcTypeBuilder);

View File

@ -46,13 +46,13 @@ public:
static StringRef getOperationName() { return "module"; }
static void build(Builder *builder, OperationState *result);
static void build(Builder *builder, OperationState &result);
/// Construct a module from the given location.
static ModuleOp create(Location loc);
/// Operation hooks.
static ParseResult parse(OpAsmParser &parser, OperationState *result);
static ParseResult parse(OpAsmParser &parser, OperationState &result);
void print(OpAsmPrinter *p);
LogicalResult verify();
@ -111,7 +111,7 @@ class ModuleTerminatorOp
public:
using Op::Op;
static StringRef getOperationName() { return "module_terminator"; }
static void build(Builder *, OperationState *) {}
static void build(Builder *, OperationState &) {}
};
//===----------------------------------------------------------------------===//

View File

@ -1277,14 +1277,14 @@ def region;
// The signature of the builder is always
//
// ```c++
// static void build(Builder *builder, OperationState *state,
// static void build(Builder *builder, OperationState &state,
// <other-parameters>...) {
// <body>...
// }
// ```
//
// To define a custom builder, the parameter list (*including* the `Builder
// *builder, OperationState *state` part) and body should be passed in
// *builder, OperationState &state` part) and body should be passed in
// as separate template arguments to this class. This is because we generate
// op declaration and definition into separate files. If an empty string is
// passed in for `body`, then *only* the builder declaration will be
@ -1331,7 +1331,7 @@ class Op<Dialect dialect, string mnemonic, list<OpTrait> props = []> {
// following signatures:
//
// ```c++
// static void build(Builder *, OperationState *tblgen_state,
// static void build(Builder *, OperationState &tblgen_state,
// Type <result0-name>, Type <result1-name>, ...,
// Value <arg0-name>, Value <arg1-name>, ...,
// Attribute <attr0-name>, Attribute <attr1-name>, ...);
@ -1339,7 +1339,7 @@ class Op<Dialect dialect, string mnemonic, list<OpTrait> props = []> {
// * where the attributes follow the same declaration order as in the op.
//
// ```c++
// static void build(Builder *, OperationState *tblgen_state,
// static void build(Builder *, OperationState &tblgen_state,
// ArrayRef<Type> resultTypes,
// ArrayRef<Value> operands,
// ArrayRef<NamedAttribute> attributes);

View File

@ -69,7 +69,7 @@ template <typename OpTy>
void ensureRegionTerminator(Region &region, Builder &builder, Location loc) {
ensureRegionTerminator(region, loc, [&] {
OperationState state(loc, OpTy::getOperationName());
OpTy::build(&builder, &state);
OpTy::build(&builder, state);
return Operation::create(state);
});
}
@ -210,7 +210,7 @@ protected:
/// Unless overridden, the custom assembly form of an op is always rejected.
/// Op implementations should implement this to return failure.
/// On success, they should fill in result with the fields to use.
static ParseResult parse(OpAsmParser &parser, OperationState *result);
static ParseResult parse(OpAsmParser &parser, OperationState &result);
// The fallback for the printer is to print it the generic assembly form.
void print(OpAsmPrinter *p);
@ -935,7 +935,7 @@ public:
/// which returns failure. On success, they should return fill in result with
/// the fields to use.
static ParseResult parseAssembly(OpAsmParser &parser,
OperationState *result) {
OperationState &result) {
return ConcreteType::parse(parser, result);
}
@ -1143,9 +1143,9 @@ private:
// These functions are out-of-line implementations of the methods in BinaryOp,
// which avoids them being template instantiated/duplicated.
namespace impl {
void buildBinaryOp(Builder *builder, OperationState *result, Value *lhs,
void buildBinaryOp(Builder *builder, OperationState &result, Value *lhs,
Value *rhs);
ParseResult parseBinaryOp(OpAsmParser &parser, OperationState *result);
ParseResult parseBinaryOp(OpAsmParser &parser, OperationState &result);
// Prints the given binary `op` in custom assembly form if both the two operands
// and the result have the same time. Otherwise, prints the generic assembly
// form.
@ -1155,9 +1155,9 @@ void printBinaryOp(Operation *op, OpAsmPrinter *p);
// These functions are out-of-line implementations of the methods in CastOp,
// which avoids them being template instantiated/duplicated.
namespace impl {
void buildCastOp(Builder *builder, OperationState *result, Value *source,
void buildCastOp(Builder *builder, OperationState &result, Value *source,
Type destType);
ParseResult parseCastOp(OpAsmParser &parser, OperationState *result);
ParseResult parseCastOp(OpAsmParser &parser, OperationState &result);
void printCastOp(Operation *op, OpAsmPrinter *p);
Value *foldCastOp(Operation *op);
} // namespace impl

View File

@ -98,7 +98,7 @@ public:
bool (&classof)(Operation *op);
/// Use the specified object to parse this ops custom assembly format.
ParseResult (&parseAssembly)(OpAsmParser &parser, OperationState *result);
ParseResult (&parseAssembly)(OpAsmParser &parser, OperationState &result);
/// This hook implements the AsmPrinter for this operation.
void (&printAssembly)(Operation *op, OpAsmPrinter *p);
@ -171,7 +171,7 @@ private:
AbstractOperation(
StringRef name, Dialect &dialect, OperationProperties opProperties,
bool (&classof)(Operation *op),
ParseResult (&parseAssembly)(OpAsmParser &parser, OperationState *result),
ParseResult (&parseAssembly)(OpAsmParser &parser, OperationState &result),
void (&printAssembly)(Operation *op, OpAsmPrinter *p),
LogicalResult (&verifyInvariants)(Operation *op),
LogicalResult (&foldHook)(Operation *op, ArrayRef<Attribute> operands,

View File

@ -273,7 +273,7 @@ public:
template <typename OpTy, typename... Args>
OpTy create(Location location, Args... args) {
OperationState state(location, OpTy::getOperationName());
OpTy::build(this, &state, args...);
OpTy::build(this, state, args...);
auto *op = createOperation(state);
auto result = dyn_cast<OpTy>(op);
assert(result && "Builder didn't return the right type");
@ -286,7 +286,7 @@ public:
template <typename OpTy, typename... Args>
OpTy createChecked(Location location, Args... args) {
OperationState state(location, OpTy::getOperationName());
OpTy::build(this, &state, args...);
OpTy::build(this, state, args...);
auto *op = createOperation(state);
// If the Operation we produce is valid, return it.

View File

@ -179,32 +179,32 @@ verifyDimAndSymbolIdentifiers(OpTy &op, Operation::operand_range operands,
// AffineApplyOp
//===----------------------------------------------------------------------===//
void AffineApplyOp::build(Builder *builder, OperationState *result,
void AffineApplyOp::build(Builder *builder, OperationState &result,
AffineMap map, ArrayRef<Value *> operands) {
result->addOperands(operands);
result->types.append(map.getNumResults(), builder->getIndexType());
result->addAttribute("map", builder->getAffineMapAttr(map));
result.addOperands(operands);
result.types.append(map.getNumResults(), builder->getIndexType());
result.addAttribute("map", builder->getAffineMapAttr(map));
}
ParseResult AffineApplyOp::parse(OpAsmParser &parser, OperationState *result) {
ParseResult AffineApplyOp::parse(OpAsmParser &parser, OperationState &result) {
auto &builder = parser.getBuilder();
auto affineIntTy = builder.getIndexType();
AffineMapAttr mapAttr;
unsigned numDims;
if (parser.parseAttribute(mapAttr, "map", result->attributes) ||
parseDimAndSymbolList(parser, result->operands, numDims) ||
parser.parseOptionalAttributeDict(result->attributes))
if (parser.parseAttribute(mapAttr, "map", result.attributes) ||
parseDimAndSymbolList(parser, result.operands, numDims) ||
parser.parseOptionalAttributeDict(result.attributes))
return failure();
auto map = mapAttr.getValue();
if (map.getNumDims() != numDims ||
numDims + map.getNumSymbols() != result->operands.size()) {
numDims + map.getNumSymbols() != result.operands.size()) {
return parser.emitError(parser.getNameLoc(),
"dimension or symbol index mismatch");
}
result->types.append(map.getNumResults(), affineIntTy);
result.types.append(map.getNumResults(), affineIntTy);
return success();
}
@ -794,25 +794,25 @@ struct MemRefCastFolder : public RewritePattern {
//===----------------------------------------------------------------------===//
// TODO(b/133776335) Check that map operands are loop IVs or symbols.
void AffineDmaStartOp::build(Builder *builder, OperationState *result,
void AffineDmaStartOp::build(Builder *builder, OperationState &result,
Value *srcMemRef, AffineMap srcMap,
ArrayRef<Value *> srcIndices, Value *destMemRef,
AffineMap dstMap, ArrayRef<Value *> destIndices,
Value *tagMemRef, AffineMap tagMap,
ArrayRef<Value *> tagIndices, Value *numElements,
Value *stride, Value *elementsPerStride) {
result->addOperands(srcMemRef);
result->addAttribute(getSrcMapAttrName(), builder->getAffineMapAttr(srcMap));
result->addOperands(srcIndices);
result->addOperands(destMemRef);
result->addAttribute(getDstMapAttrName(), builder->getAffineMapAttr(dstMap));
result->addOperands(destIndices);
result->addOperands(tagMemRef);
result->addAttribute(getTagMapAttrName(), builder->getAffineMapAttr(tagMap));
result->addOperands(tagIndices);
result->addOperands(numElements);
result.addOperands(srcMemRef);
result.addAttribute(getSrcMapAttrName(), builder->getAffineMapAttr(srcMap));
result.addOperands(srcIndices);
result.addOperands(destMemRef);
result.addAttribute(getDstMapAttrName(), builder->getAffineMapAttr(dstMap));
result.addOperands(destIndices);
result.addOperands(tagMemRef);
result.addAttribute(getTagMapAttrName(), builder->getAffineMapAttr(tagMap));
result.addOperands(tagIndices);
result.addOperands(numElements);
if (stride) {
result->addOperands({stride, elementsPerStride});
result.addOperands({stride, elementsPerStride});
}
}
@ -842,7 +842,7 @@ void AffineDmaStartOp::print(OpAsmPrinter *p) {
// : memref<3076 x f32, 0>, memref<1024 x f32, 2>, memref<1 x i32>
//
ParseResult AffineDmaStartOp::parse(OpAsmParser &parser,
OperationState *result) {
OperationState &result) {
OpAsmParser::OperandType srcMemRefInfo;
AffineMapAttr srcMapAttr;
SmallVector<OpAsmParser::OperandType, 4> srcMapOperands;
@ -865,13 +865,13 @@ ParseResult AffineDmaStartOp::parse(OpAsmParser &parser,
// *) number of elements transferred by DMA operation.
if (parser.parseOperand(srcMemRefInfo) ||
parser.parseAffineMapOfSSAIds(srcMapOperands, srcMapAttr,
getSrcMapAttrName(), result->attributes) ||
getSrcMapAttrName(), result.attributes) ||
parser.parseComma() || parser.parseOperand(dstMemRefInfo) ||
parser.parseAffineMapOfSSAIds(dstMapOperands, dstMapAttr,
getDstMapAttrName(), result->attributes) ||
getDstMapAttrName(), result.attributes) ||
parser.parseComma() || parser.parseOperand(tagMemRefInfo) ||
parser.parseAffineMapOfSSAIds(tagMapOperands, tagMapAttr,
getTagMapAttrName(), result->attributes) ||
getTagMapAttrName(), result.attributes) ||
parser.parseComma() || parser.parseOperand(numElementsInfo))
return failure();
@ -891,17 +891,17 @@ ParseResult AffineDmaStartOp::parse(OpAsmParser &parser,
if (types.size() != 3)
return parser.emitError(parser.getNameLoc(), "expected three types");
if (parser.resolveOperand(srcMemRefInfo, types[0], result->operands) ||
parser.resolveOperands(srcMapOperands, indexType, result->operands) ||
parser.resolveOperand(dstMemRefInfo, types[1], result->operands) ||
parser.resolveOperands(dstMapOperands, indexType, result->operands) ||
parser.resolveOperand(tagMemRefInfo, types[2], result->operands) ||
parser.resolveOperands(tagMapOperands, indexType, result->operands) ||
parser.resolveOperand(numElementsInfo, indexType, result->operands))
if (parser.resolveOperand(srcMemRefInfo, types[0], result.operands) ||
parser.resolveOperands(srcMapOperands, indexType, result.operands) ||
parser.resolveOperand(dstMemRefInfo, types[1], result.operands) ||
parser.resolveOperands(dstMapOperands, indexType, result.operands) ||
parser.resolveOperand(tagMemRefInfo, types[2], result.operands) ||
parser.resolveOperands(tagMapOperands, indexType, result.operands) ||
parser.resolveOperand(numElementsInfo, indexType, result.operands))
return failure();
if (isStrided) {
if (parser.resolveOperands(strideInfo, indexType, result->operands))
if (parser.resolveOperands(strideInfo, indexType, result.operands))
return failure();
}
@ -966,13 +966,13 @@ void AffineDmaStartOp::getCanonicalizationPatterns(
//===----------------------------------------------------------------------===//
// TODO(b/133776335) Check that map operands are loop IVs or symbols.
void AffineDmaWaitOp::build(Builder *builder, OperationState *result,
void AffineDmaWaitOp::build(Builder *builder, OperationState &result,
Value *tagMemRef, AffineMap tagMap,
ArrayRef<Value *> tagIndices, Value *numElements) {
result->addOperands(tagMemRef);
result->addAttribute(getTagMapAttrName(), builder->getAffineMapAttr(tagMap));
result->addOperands(tagIndices);
result->addOperands(numElements);
result.addOperands(tagMemRef);
result.addAttribute(getTagMapAttrName(), builder->getAffineMapAttr(tagMap));
result.addOperands(tagIndices);
result.addOperands(numElements);
}
void AffineDmaWaitOp::print(OpAsmPrinter *p) {
@ -990,7 +990,7 @@ void AffineDmaWaitOp::print(OpAsmPrinter *p) {
// : memref<1 x i32, (d0) -> (d0), 4>
//
ParseResult AffineDmaWaitOp::parse(OpAsmParser &parser,
OperationState *result) {
OperationState &result) {
OpAsmParser::OperandType tagMemRefInfo;
AffineMapAttr tagMapAttr;
SmallVector<OpAsmParser::OperandType, 2> tagMapOperands;
@ -1001,12 +1001,12 @@ ParseResult AffineDmaWaitOp::parse(OpAsmParser &parser,
// Parse tag memref, its map operands, and dma size.
if (parser.parseOperand(tagMemRefInfo) ||
parser.parseAffineMapOfSSAIds(tagMapOperands, tagMapAttr,
getTagMapAttrName(), result->attributes) ||
getTagMapAttrName(), result.attributes) ||
parser.parseComma() || parser.parseOperand(numElementsInfo) ||
parser.parseColonType(type) ||
parser.resolveOperand(tagMemRefInfo, type, result->operands) ||
parser.resolveOperands(tagMapOperands, indexType, result->operands) ||
parser.resolveOperand(numElementsInfo, indexType, result->operands))
parser.resolveOperand(tagMemRefInfo, type, result.operands) ||
parser.resolveOperands(tagMapOperands, indexType, result.operands) ||
parser.resolveOperand(numElementsInfo, indexType, result.operands))
return failure();
if (!type.isa<MemRefType>())
@ -1041,7 +1041,7 @@ void AffineDmaWaitOp::getCanonicalizationPatterns(
// AffineForOp
//===----------------------------------------------------------------------===//
void AffineForOp::build(Builder *builder, OperationState *result,
void AffineForOp::build(Builder *builder, OperationState &result,
ArrayRef<Value *> lbOperands, AffineMap lbMap,
ArrayRef<Value *> ubOperands, AffineMap ubMap,
int64_t step) {
@ -1054,32 +1054,32 @@ void AffineForOp::build(Builder *builder, OperationState *result,
assert(step > 0 && "step has to be a positive integer constant");
// Add an attribute for the step.
result->addAttribute(getStepAttrName(),
builder->getIntegerAttr(builder->getIndexType(), step));
result.addAttribute(getStepAttrName(),
builder->getIntegerAttr(builder->getIndexType(), step));
// Add the lower bound.
result->addAttribute(getLowerBoundAttrName(),
builder->getAffineMapAttr(lbMap));
result->addOperands(lbOperands);
result.addAttribute(getLowerBoundAttrName(),
builder->getAffineMapAttr(lbMap));
result.addOperands(lbOperands);
// Add the upper bound.
result->addAttribute(getUpperBoundAttrName(),
builder->getAffineMapAttr(ubMap));
result->addOperands(ubOperands);
result.addAttribute(getUpperBoundAttrName(),
builder->getAffineMapAttr(ubMap));
result.addOperands(ubOperands);
// Create a region and a block for the body. The argument of the region is
// the loop induction variable.
Region *bodyRegion = result->addRegion();
Region *bodyRegion = result.addRegion();
Block *body = new Block();
body->addArgument(IndexType::get(builder->getContext()));
bodyRegion->push_back(body);
ensureTerminator(*bodyRegion, *builder, result->location);
ensureTerminator(*bodyRegion, *builder, result.location);
// Set the operands list as resizable so that we can freely modify the bounds.
result->setOperandListToResizable();
result.setOperandListToResizable();
}
void AffineForOp::build(Builder *builder, OperationState *result, int64_t lb,
void AffineForOp::build(Builder *builder, OperationState &result, int64_t lb,
int64_t ub, int64_t step) {
auto lbMap = AffineMap::getConstantMap(lb, builder->getContext());
auto ubMap = AffineMap::getConstantMap(ub, builder->getContext());
@ -1117,7 +1117,7 @@ static LogicalResult verify(AffineForOp op) {
}
/// Parse a for operation loop bounds.
static ParseResult parseBound(bool isLower, OperationState *result,
static ParseResult parseBound(bool isLower, OperationState &result,
OpAsmParser &p) {
// 'min' / 'max' prefixes are generally syntactic sugar, but are required if
// the map has multiple results.
@ -1142,14 +1142,14 @@ static ParseResult parseBound(bool isLower, OperationState *result,
// TODO: improve error message when SSA value is not an affine integer.
// Currently it is 'use of value ... expects different type than prior uses'
if (p.resolveOperand(boundOpInfos.front(), builder.getIndexType(),
result->operands))
result.operands))
return failure();
// Create an identity map using symbol id. This representation is optimized
// for storage. Analysis passes may expand it into a multi-dimensional map
// if desired.
AffineMap map = builder.getSymbolIdentityMap();
result->addAttribute(boundAttrName, builder.getAffineMapAttr(map));
result.addAttribute(boundAttrName, builder.getAffineMapAttr(map));
return success();
}
@ -1158,14 +1158,14 @@ static ParseResult parseBound(bool isLower, OperationState *result,
Attribute boundAttr;
if (p.parseAttribute(boundAttr, builder.getIndexType(), boundAttrName,
result->attributes))
result.attributes))
return failure();
// Parse full form - affine map followed by dim and symbol list.
if (auto affineMapAttr = boundAttr.dyn_cast<AffineMapAttr>()) {
unsigned currentNumOperands = result->operands.size();
unsigned currentNumOperands = result.operands.size();
unsigned numDims;
if (parseDimAndSymbolList(p, result->operands, numDims))
if (parseDimAndSymbolList(p, result.operands, numDims))
return failure();
auto map = affineMapAttr.getValue();
@ -1175,7 +1175,7 @@ static ParseResult parseBound(bool isLower, OperationState *result,
"dim operand count and integer set dim count must match");
unsigned numDimAndSymbolOperands =
result->operands.size() - currentNumOperands;
result.operands.size() - currentNumOperands;
if (numDims + map.getNumSymbols() != numDimAndSymbolOperands)
return p.emitError(
p.getNameLoc(),
@ -1196,8 +1196,8 @@ static ParseResult parseBound(bool isLower, OperationState *result,
// Parse custom assembly form.
if (auto integerAttr = boundAttr.dyn_cast<IntegerAttr>()) {
result->attributes.pop_back();
result->addAttribute(
result.attributes.pop_back();
result.addAttribute(
boundAttrName, builder.getAffineMapAttr(
builder.getConstantAffineMap(integerAttr.getInt())));
return success();
@ -1208,7 +1208,7 @@ static ParseResult parseBound(bool isLower, OperationState *result,
"expected valid affine map representation for loop bounds");
}
ParseResult parseAffineForOp(OpAsmParser &parser, OperationState *result) {
ParseResult parseAffineForOp(OpAsmParser &parser, OperationState &result) {
auto &builder = parser.getBuilder();
OpAsmParser::OperandType inductionVariable;
// Parse the induction variable followed by '='.
@ -1223,7 +1223,7 @@ ParseResult parseAffineForOp(OpAsmParser &parser, OperationState *result) {
// Parse the optional loop step, we default to 1 if one is not present.
if (parser.parseOptionalKeyword("step")) {
result->addAttribute(
result.addAttribute(
AffineForOp::getStepAttrName(),
builder.getIntegerAttr(builder.getIndexType(), /*value=*/1));
} else {
@ -1231,7 +1231,7 @@ ParseResult parseAffineForOp(OpAsmParser &parser, OperationState *result) {
IntegerAttr stepAttr;
if (parser.parseAttribute(stepAttr, builder.getIndexType(),
AffineForOp::getStepAttrName().data(),
result->attributes))
result.attributes))
return failure();
if (stepAttr.getValue().getSExtValue() < 0)
@ -1241,18 +1241,18 @@ ParseResult parseAffineForOp(OpAsmParser &parser, OperationState *result) {
}
// Parse the body region.
Region *body = result->addRegion();
Region *body = result.addRegion();
if (parser.parseRegion(*body, inductionVariable, builder.getIndexType()))
return failure();
AffineForOp::ensureTerminator(*body, builder, result->location);
AffineForOp::ensureTerminator(*body, builder, result.location);
// Parse the optional attribute list.
if (parser.parseOptionalAttributeDict(result->attributes))
if (parser.parseOptionalAttributeDict(result.attributes))
return failure();
// Set the operands list as resizable so that we can freely modify the bounds.
result->setOperandListToResizable();
result.setOperandListToResizable();
return success();
}
@ -1589,13 +1589,13 @@ static LogicalResult verify(AffineIfOp op) {
return success();
}
ParseResult parseAffineIfOp(OpAsmParser &parser, OperationState *result) {
ParseResult parseAffineIfOp(OpAsmParser &parser, OperationState &result) {
// Parse the condition attribute set.
IntegerSetAttr conditionAttr;
unsigned numDims;
if (parser.parseAttribute(conditionAttr, AffineIfOp::getConditionAttrName(),
result->attributes) ||
parseDimAndSymbolList(parser, result->operands, numDims))
result.attributes) ||
parseDimAndSymbolList(parser, result.operands, numDims))
return failure();
// Verify the condition operands.
@ -1604,33 +1604,33 @@ ParseResult parseAffineIfOp(OpAsmParser &parser, OperationState *result) {
return parser.emitError(
parser.getNameLoc(),
"dim operand count and integer set dim count must match");
if (numDims + set.getNumSymbols() != result->operands.size())
if (numDims + set.getNumSymbols() != result.operands.size())
return parser.emitError(
parser.getNameLoc(),
"symbol operand count and integer set symbol count must match");
// Create the regions for 'then' and 'else'. The latter must be created even
// if it remains empty for the validity of the operation.
result->regions.reserve(2);
Region *thenRegion = result->addRegion();
Region *elseRegion = result->addRegion();
result.regions.reserve(2);
Region *thenRegion = result.addRegion();
Region *elseRegion = result.addRegion();
// Parse the 'then' region.
if (parser.parseRegion(*thenRegion, {}, {}))
return failure();
AffineIfOp::ensureTerminator(*thenRegion, parser.getBuilder(),
result->location);
result.location);
// If we find an 'else' keyword then parse the 'else' region.
if (!parser.parseOptionalKeyword("else")) {
if (parser.parseRegion(*elseRegion, {}, {}))
return failure();
AffineIfOp::ensureTerminator(*elseRegion, parser.getBuilder(),
result->location);
result.location);
}
// Parse the optional attribute list.
if (parser.parseOptionalAttributeDict(result->attributes))
if (parser.parseOptionalAttributeDict(result.attributes))
return failure();
return success();
@ -1672,15 +1672,15 @@ void AffineIfOp::setConditional(IntegerSet set, ArrayRef<Value *> operands) {
getOperation()->setOperands(operands);
}
void AffineIfOp::build(Builder *builder, OperationState *result, IntegerSet set,
void AffineIfOp::build(Builder *builder, OperationState &result, IntegerSet set,
ArrayRef<Value *> args, bool withElseRegion) {
result->addOperands(args);
result->addAttribute(getConditionAttrName(), IntegerSetAttr::get(set));
Region *thenRegion = result->addRegion();
Region *elseRegion = result->addRegion();
AffineIfOp::ensureTerminator(*thenRegion, *builder, result->location);
result.addOperands(args);
result.addAttribute(getConditionAttrName(), IntegerSetAttr::get(set));
Region *thenRegion = result.addRegion();
Region *elseRegion = result.addRegion();
AffineIfOp::ensureTerminator(*thenRegion, *builder, result.location);
if (withElseRegion)
AffineIfOp::ensureTerminator(*elseRegion, *builder, result->location);
AffineIfOp::ensureTerminator(*elseRegion, *builder, result.location);
}
namespace {
@ -1720,28 +1720,28 @@ void AffineIfOp::getCanonicalizationPatterns(OwningRewritePatternList &results,
// AffineLoadOp
//===----------------------------------------------------------------------===//
void AffineLoadOp::build(Builder *builder, OperationState *result,
void AffineLoadOp::build(Builder *builder, OperationState &result,
AffineMap map, ArrayRef<Value *> operands) {
assert(operands.size() == 1 + map.getNumInputs() && "inconsistent operands");
result->addOperands(operands);
result.addOperands(operands);
if (map)
result->addAttribute(getMapAttrName(), builder->getAffineMapAttr(map));
result.addAttribute(getMapAttrName(), builder->getAffineMapAttr(map));
auto memrefType = operands[0]->getType().cast<MemRefType>();
result->types.push_back(memrefType.getElementType());
result.types.push_back(memrefType.getElementType());
}
void AffineLoadOp::build(Builder *builder, OperationState *result,
void AffineLoadOp::build(Builder *builder, OperationState &result,
Value *memref, AffineMap map,
ArrayRef<Value *> mapOperands) {
assert(map.getNumInputs() == mapOperands.size() && "inconsistent index info");
result->addOperands(memref);
result->addOperands(mapOperands);
result.addOperands(memref);
result.addOperands(mapOperands);
auto memrefType = memref->getType().cast<MemRefType>();
result->addAttribute(getMapAttrName(), builder->getAffineMapAttr(map));
result->types.push_back(memrefType.getElementType());
result.addAttribute(getMapAttrName(), builder->getAffineMapAttr(map));
result.types.push_back(memrefType.getElementType());
}
void AffineLoadOp::build(Builder *builder, OperationState *result,
void AffineLoadOp::build(Builder *builder, OperationState &result,
Value *memref, ArrayRef<Value *> indices) {
auto memrefType = memref->getType().cast<MemRefType>();
auto rank = memrefType.getRank();
@ -1752,7 +1752,7 @@ void AffineLoadOp::build(Builder *builder, OperationState *result,
build(builder, result, memref, map, indices);
}
ParseResult AffineLoadOp::parse(OpAsmParser &parser, OperationState *result) {
ParseResult AffineLoadOp::parse(OpAsmParser &parser, OperationState &result) {
auto &builder = parser.getBuilder();
auto affineIntTy = builder.getIndexType();
@ -1763,12 +1763,12 @@ ParseResult AffineLoadOp::parse(OpAsmParser &parser, OperationState *result) {
return failure(
parser.parseOperand(memrefInfo) ||
parser.parseAffineMapOfSSAIds(mapOperands, mapAttr, getMapAttrName(),
result->attributes) ||
parser.parseOptionalAttributeDict(result->attributes) ||
result.attributes) ||
parser.parseOptionalAttributeDict(result.attributes) ||
parser.parseColonType(type) ||
parser.resolveOperand(memrefInfo, type, result->operands) ||
parser.resolveOperands(mapOperands, affineIntTy, result->operands) ||
parser.addTypeToList(type.getElementType(), result->types));
parser.resolveOperand(memrefInfo, type, result.operands) ||
parser.resolveOperands(mapOperands, affineIntTy, result.operands) ||
parser.addTypeToList(type.getElementType(), result.types));
}
void AffineLoadOp::print(OpAsmPrinter *p) {
@ -1821,18 +1821,18 @@ void AffineLoadOp::getCanonicalizationPatterns(
// AffineStoreOp
//===----------------------------------------------------------------------===//
void AffineStoreOp::build(Builder *builder, OperationState *result,
void AffineStoreOp::build(Builder *builder, OperationState &result,
Value *valueToStore, Value *memref, AffineMap map,
ArrayRef<Value *> mapOperands) {
assert(map.getNumInputs() == mapOperands.size() && "inconsistent index info");
result->addOperands(valueToStore);
result->addOperands(memref);
result->addOperands(mapOperands);
result->addAttribute(getMapAttrName(), builder->getAffineMapAttr(map));
result.addOperands(valueToStore);
result.addOperands(memref);
result.addOperands(mapOperands);
result.addAttribute(getMapAttrName(), builder->getAffineMapAttr(map));
}
// Use identity map.
void AffineStoreOp::build(Builder *builder, OperationState *result,
void AffineStoreOp::build(Builder *builder, OperationState &result,
Value *valueToStore, Value *memref,
ArrayRef<Value *> indices) {
auto memrefType = memref->getType().cast<MemRefType>();
@ -1844,7 +1844,7 @@ void AffineStoreOp::build(Builder *builder, OperationState *result,
build(builder, result, valueToStore, memref, map, indices);
}
ParseResult AffineStoreOp::parse(OpAsmParser &parser, OperationState *result) {
ParseResult AffineStoreOp::parse(OpAsmParser &parser, OperationState &result) {
auto affineIntTy = parser.getBuilder().getIndexType();
MemRefType type;
@ -1856,13 +1856,13 @@ ParseResult AffineStoreOp::parse(OpAsmParser &parser, OperationState *result) {
parser.parseOperand(storeValueInfo) || parser.parseComma() ||
parser.parseOperand(memrefInfo) ||
parser.parseAffineMapOfSSAIds(mapOperands, mapAttr, getMapAttrName(),
result->attributes) ||
parser.parseOptionalAttributeDict(result->attributes) ||
result.attributes) ||
parser.parseOptionalAttributeDict(result.attributes) ||
parser.parseColonType(type) ||
parser.resolveOperand(storeValueInfo, type.getElementType(),
result->operands) ||
parser.resolveOperand(memrefInfo, type, result->operands) ||
parser.resolveOperands(mapOperands, affineIntTy, result->operands));
result.operands) ||
parser.resolveOperand(memrefInfo, type, result.operands) ||
parser.resolveOperands(mapOperands, affineIntTy, result.operands));
}
void AffineStoreOp::print(OpAsmPrinter *p) {

View File

@ -69,19 +69,19 @@ static SmallVector<Type, 4> getValueTypes(ArrayRef<Value *> values) {
return types;
}
void LaunchOp::build(Builder *builder, OperationState *result, Value *gridSizeX,
void LaunchOp::build(Builder *builder, OperationState &result, Value *gridSizeX,
Value *gridSizeY, Value *gridSizeZ, Value *blockSizeX,
Value *blockSizeY, Value *blockSizeZ,
ArrayRef<Value *> operands) {
// Add grid and block sizes as op operands, followed by the data operands.
result->addOperands(
result.addOperands(
{gridSizeX, gridSizeY, gridSizeZ, blockSizeX, blockSizeY, blockSizeZ});
result->addOperands(operands);
result.addOperands(operands);
// Create a kernel body region with kNumConfigRegionAttributes + N arguments,
// where the first kNumConfigRegionAttributes arguments have `index` type and
// the rest have the same types as the data operands.
Region *kernelRegion = result->addRegion();
Region *kernelRegion = result.addRegion();
Block *body = new Block();
body->addArguments(
std::vector<Type>(kNumConfigRegionAttributes, builder->getIndexType()));
@ -253,7 +253,7 @@ parseSizeAssignment(OpAsmParser &parser,
// (`args` ssa-reassignment `:` type-list)?
// region attr-dict?
// ssa-reassignment ::= `(` ssa-id `=` ssa-use (`,` ssa-id `=` ssa-use)* `)`
ParseResult LaunchOp::parse(OpAsmParser &parser, OperationState *result) {
ParseResult LaunchOp::parse(OpAsmParser &parser, OperationState &result) {
// Sizes of the grid and block.
SmallVector<OpAsmParser::OperandType, kNumConfigOperands> sizes(
kNumConfigOperands);
@ -281,7 +281,7 @@ ParseResult LaunchOp::parse(OpAsmParser &parser, OperationState *result) {
regionArgsRef.slice(9, 3),
regionArgsRef.slice(3, 3)) ||
parser.resolveOperands(sizes, parser.getBuilder().getIndexType(),
result->operands))
result.operands))
return failure();
// If kernel argument renaming segment is present, parse it. When present,
@ -308,7 +308,7 @@ ParseResult LaunchOp::parse(OpAsmParser &parser, OperationState *result) {
if (parser.parseRParen() || parser.parseColonTypeList(dataTypes) ||
parser.resolveOperands(dataOperands, dataTypes, argsLoc,
result->operands))
result.operands))
return failure();
}
@ -318,9 +318,9 @@ ParseResult LaunchOp::parse(OpAsmParser &parser, OperationState *result) {
// Follow the actual kernel arguments.
Type index = parser.getBuilder().getIndexType();
dataTypes.insert(dataTypes.begin(), kNumConfigRegionAttributes, index);
Region *body = result->addRegion();
Region *body = result.addRegion();
return failure(parser.parseRegion(*body, regionArgs, dataTypes) ||
parser.parseOptionalAttributeDict(result->attributes));
parser.parseOptionalAttributeDict(result.attributes));
}
void LaunchOp::eraseKernelArgument(unsigned index) {
@ -385,19 +385,19 @@ void LaunchOp::getCanonicalizationPatterns(OwningRewritePatternList &results,
// LaunchFuncOp
//===----------------------------------------------------------------------===//
void LaunchFuncOp::build(Builder *builder, OperationState *result,
void LaunchFuncOp::build(Builder *builder, OperationState &result,
FuncOp kernelFunc, Value *gridSizeX, Value *gridSizeY,
Value *gridSizeZ, Value *blockSizeX, Value *blockSizeY,
Value *blockSizeZ, ArrayRef<Value *> kernelOperands) {
// Add grid and block sizes as op operands, followed by the data operands.
result->addOperands(
result.addOperands(
{gridSizeX, gridSizeY, gridSizeZ, blockSizeX, blockSizeY, blockSizeZ});
result->addOperands(kernelOperands);
result->addAttribute(getKernelAttrName(),
builder->getSymbolRefAttr(kernelFunc));
result.addOperands(kernelOperands);
result.addAttribute(getKernelAttrName(),
builder->getSymbolRefAttr(kernelFunc));
}
void LaunchFuncOp::build(Builder *builder, OperationState *result,
void LaunchFuncOp::build(Builder *builder, OperationState &result,
FuncOp kernelFunc, KernelDim3 gridSize,
KernelDim3 blockSize,
ArrayRef<Value *> kernelOperands) {

View File

@ -59,7 +59,7 @@ static void printFCmpOp(OpAsmPrinter *p, FCmpOp &op) {
// <operation> ::= `llvm.fcmp` string-literal ssa-use `,` ssa-use
// attribute-dict? `:` type
template <typename CmpPredicateType>
static ParseResult parseCmpOp(OpAsmParser &parser, OperationState *result) {
static ParseResult parseCmpOp(OpAsmParser &parser, OperationState &result) {
Builder &builder = parser.getBuilder();
Attribute predicate;
@ -73,8 +73,8 @@ static ParseResult parseCmpOp(OpAsmParser &parser, OperationState *result) {
parser.parseOperand(rhs) || parser.parseOptionalAttributeDict(attrs) ||
parser.parseColon() || parser.getCurrentLocation(&trailingTypeLoc) ||
parser.parseType(type) ||
parser.resolveOperand(lhs, type, result->operands) ||
parser.resolveOperand(rhs, type, result->operands))
parser.resolveOperand(lhs, type, result.operands) ||
parser.resolveOperand(rhs, type, result.operands))
return failure();
// Replace the string attribute `predicate` with an integer attribute.
@ -115,8 +115,8 @@ static ParseResult parseCmpOp(OpAsmParser &parser, OperationState *result) {
resultType = LLVMType::getVectorTy(
resultType, argType.getUnderlyingType()->getVectorNumElements());
result->attributes = attrs;
result->addTypes({resultType});
result.attributes = attrs;
result.addTypes({resultType});
return success();
}
@ -140,7 +140,7 @@ static void printAllocaOp(OpAsmPrinter *p, AllocaOp &op) {
// <operation> ::= `llvm.alloca` ssa-use `x` type attribute-dict?
// `:` type `,` type
static ParseResult parseAllocaOp(OpAsmParser &parser, OperationState *result) {
static ParseResult parseAllocaOp(OpAsmParser &parser, OperationState &result) {
SmallVector<NamedAttribute, 4> attrs;
OpAsmParser::OperandType arraySize;
Type type, elemType;
@ -159,11 +159,11 @@ static ParseResult parseAllocaOp(OpAsmParser &parser, OperationState *result) {
trailingTypeLoc,
"expected trailing function type with one argument and one result");
if (parser.resolveOperand(arraySize, funcType.getInput(0), result->operands))
if (parser.resolveOperand(arraySize, funcType.getInput(0), result.operands))
return failure();
result->attributes = attrs;
result->addTypes({funcType.getResult(0)});
result.attributes = attrs;
result.addTypes({funcType.getResult(0)});
return success();
}
@ -184,7 +184,7 @@ static void printGEPOp(OpAsmPrinter *p, GEPOp &op) {
// <operation> ::= `llvm.getelementptr` ssa-use `[` ssa-use-list `]`
// attribute-dict? `:` type
static ParseResult parseGEPOp(OpAsmParser &parser, OperationState *result) {
static ParseResult parseGEPOp(OpAsmParser &parser, OperationState &result) {
SmallVector<NamedAttribute, 4> attrs;
OpAsmParser::OperandType base;
SmallVector<OpAsmParser::OperandType, 8> indices;
@ -205,13 +205,13 @@ static ParseResult parseGEPOp(OpAsmParser &parser, OperationState *result) {
"expected trailing function type with at least "
"one argument and one result");
if (parser.resolveOperand(base, funcType.getInput(0), result->operands) ||
if (parser.resolveOperand(base, funcType.getInput(0), result.operands) ||
parser.resolveOperands(indices, funcType.getInputs().drop_front(),
parser.getNameLoc(), result->operands))
parser.getNameLoc(), result.operands))
return failure();
result->attributes = attrs;
result->addTypes(funcType.getResults());
result.attributes = attrs;
result.addTypes(funcType.getResults());
return success();
}
@ -240,7 +240,7 @@ static Type getLoadStoreElementType(OpAsmParser &parser, Type type,
}
// <operation> ::= `llvm.load` ssa-use attribute-dict? `:` type
static ParseResult parseLoadOp(OpAsmParser &parser, OperationState *result) {
static ParseResult parseLoadOp(OpAsmParser &parser, OperationState &result) {
SmallVector<NamedAttribute, 4> attrs;
OpAsmParser::OperandType addr;
Type type;
@ -249,13 +249,13 @@ static ParseResult parseLoadOp(OpAsmParser &parser, OperationState *result) {
if (parser.parseOperand(addr) || parser.parseOptionalAttributeDict(attrs) ||
parser.parseColon() || parser.getCurrentLocation(&trailingTypeLoc) ||
parser.parseType(type) ||
parser.resolveOperand(addr, type, result->operands))
parser.resolveOperand(addr, type, result.operands))
return failure();
Type elemTy = getLoadStoreElementType(parser, type, trailingTypeLoc);
result->attributes = attrs;
result->addTypes(elemTy);
result.attributes = attrs;
result.addTypes(elemTy);
return success();
}
@ -270,7 +270,7 @@ static void printStoreOp(OpAsmPrinter *p, StoreOp &op) {
}
// <operation> ::= `llvm.store` ssa-use `,` ssa-use attribute-dict? `:` type
static ParseResult parseStoreOp(OpAsmParser &parser, OperationState *result) {
static ParseResult parseStoreOp(OpAsmParser &parser, OperationState &result) {
SmallVector<NamedAttribute, 4> attrs;
OpAsmParser::OperandType addr, value;
Type type;
@ -286,11 +286,11 @@ static ParseResult parseStoreOp(OpAsmParser &parser, OperationState *result) {
if (!elemTy)
return failure();
if (parser.resolveOperand(value, elemTy, result->operands) ||
parser.resolveOperand(addr, type, result->operands))
if (parser.resolveOperand(value, elemTy, result.operands) ||
parser.resolveOperand(addr, type, result.operands))
return failure();
result->attributes = attrs;
result.attributes = attrs;
return success();
}
@ -326,7 +326,7 @@ static void printCallOp(OpAsmPrinter *p, CallOp &op) {
// <operation> ::= `llvm.call` (function-id | ssa-use) `(` ssa-use-list `)`
// attribute-dict? `:` function-type
static ParseResult parseCallOp(OpAsmParser &parser, OperationState *result) {
static ParseResult parseCallOp(OpAsmParser &parser, OperationState &result) {
SmallVector<NamedAttribute, 4> attrs;
SmallVector<OpAsmParser::OperandType, 8> operands;
Type type;
@ -357,9 +357,9 @@ static ParseResult parseCallOp(OpAsmParser &parser, OperationState *result) {
if (isDirect) {
// Make sure types match.
if (parser.resolveOperands(operands, funcType.getInputs(),
parser.getNameLoc(), result->operands))
parser.getNameLoc(), result.operands))
return failure();
result->addTypes(funcType.getResults());
result.addTypes(funcType.getResults());
} else {
// Construct the LLVM IR Dialect function type that the first operand
// should match.
@ -399,15 +399,15 @@ static ParseResult parseCallOp(OpAsmParser &parser, OperationState *result) {
// Make sure that the first operand (indirect callee) matches the wrapped
// LLVM IR function type, and that the types of the other call operands
// match the types of the function arguments.
if (parser.resolveOperand(operands[0], wrappedFuncType, result->operands) ||
if (parser.resolveOperand(operands[0], wrappedFuncType, result.operands) ||
parser.resolveOperands(funcArguments, funcType.getInputs(),
parser.getNameLoc(), result->operands))
parser.getNameLoc(), result.operands))
return failure();
result->addTypes(llvmResultType);
result.addTypes(llvmResultType);
}
result->attributes = attrs;
result.attributes = attrs;
return success();
}
@ -416,13 +416,13 @@ static ParseResult parseCallOp(OpAsmParser &parser, OperationState *result) {
//===----------------------------------------------------------------------===//
// Expects vector to be of wrapped LLVM vector type and position to be of
// wrapped LLVM i32 type.
void LLVM::ExtractElementOp::build(Builder *b, OperationState *result,
void LLVM::ExtractElementOp::build(Builder *b, OperationState &result,
Value *vector, Value *position,
ArrayRef<NamedAttribute> attrs) {
auto wrappedVectorType = vector->getType().cast<LLVM::LLVMType>();
auto llvmType = wrappedVectorType.getVectorElementType();
build(b, result, llvmType, vector, position);
result->addAttributes(attrs);
result.addAttributes(attrs);
}
static void printExtractElementOp(OpAsmPrinter *p, ExtractElementOp &op) {
@ -434,7 +434,7 @@ static void printExtractElementOp(OpAsmPrinter *p, ExtractElementOp &op) {
// <operation> ::= `llvm.extractelement` ssa-use `, ` ssa-use
// attribute-dict? `:` type
static ParseResult parseExtractElementOp(OpAsmParser &parser,
OperationState *result) {
OperationState &result) {
llvm::SMLoc loc;
OpAsmParser::OperandType vector, position;
auto *llvmDialect = parser.getBuilder()
@ -443,17 +443,17 @@ static ParseResult parseExtractElementOp(OpAsmParser &parser,
Type type, i32Type = LLVMType::getInt32Ty(llvmDialect);
if (parser.getCurrentLocation(&loc) || parser.parseOperand(vector) ||
parser.parseComma() || parser.parseOperand(position) ||
parser.parseOptionalAttributeDict(result->attributes) ||
parser.parseOptionalAttributeDict(result.attributes) ||
parser.parseColonType(type) ||
parser.resolveOperand(vector, type, result->operands) ||
parser.resolveOperand(position, i32Type, result->operands))
parser.resolveOperand(vector, type, result.operands) ||
parser.resolveOperand(position, i32Type, result.operands))
return failure();
auto wrappedVectorType = type.dyn_cast<LLVM::LLVMType>();
if (!wrappedVectorType ||
!wrappedVectorType.getUnderlyingType()->isVectorTy())
return parser.emitError(
loc, "expected LLVM IR dialect vector type for operand #1");
result->addTypes(wrappedVectorType.getVectorElementType());
result.addTypes(wrappedVectorType.getVectorElementType());
return success();
}
@ -523,7 +523,7 @@ static LLVM::LLVMType getInsertExtractValueElementType(OpAsmParser &parser,
// `[` integer-literal (`,` integer-literal)* `]`
// attribute-dict? `:` type
static ParseResult parseExtractValueOp(OpAsmParser &parser,
OperationState *result) {
OperationState &result) {
SmallVector<NamedAttribute, 4> attrs;
OpAsmParser::OperandType container;
Type containerType;
@ -536,7 +536,7 @@ static ParseResult parseExtractValueOp(OpAsmParser &parser,
parser.parseOptionalAttributeDict(attrs) || parser.parseColon() ||
parser.getCurrentLocation(&trailingTypeLoc) ||
parser.parseType(containerType) ||
parser.resolveOperand(container, containerType, result->operands))
parser.resolveOperand(container, containerType, result.operands))
return failure();
auto elementType = getInsertExtractValueElementType(
@ -544,8 +544,8 @@ static ParseResult parseExtractValueOp(OpAsmParser &parser,
if (!elementType)
return failure();
result->attributes = attrs;
result->addTypes(elementType);
result.attributes = attrs;
result.addTypes(elementType);
return success();
}
@ -563,7 +563,7 @@ static void printInsertElementOp(OpAsmPrinter *p, InsertElementOp &op) {
// <operation> ::= `llvm.insertelement` ssa-use `,` ssa-use `,` ssa-use
// attribute-dict? `:` type
static ParseResult parseInsertElementOp(OpAsmParser &parser,
OperationState *result) {
OperationState &result) {
llvm::SMLoc loc;
OpAsmParser::OperandType vector, value, position;
auto *llvmDialect = parser.getBuilder()
@ -573,7 +573,7 @@ static ParseResult parseInsertElementOp(OpAsmParser &parser,
if (parser.getCurrentLocation(&loc) || parser.parseOperand(vector) ||
parser.parseComma() || parser.parseOperand(value) ||
parser.parseComma() || parser.parseOperand(position) ||
parser.parseOptionalAttributeDict(result->attributes) ||
parser.parseOptionalAttributeDict(result.attributes) ||
parser.parseColonType(vectorType))
return failure();
@ -586,12 +586,12 @@ static ParseResult parseInsertElementOp(OpAsmParser &parser,
if (!valueType)
return failure();
if (parser.resolveOperand(vector, vectorType, result->operands) ||
parser.resolveOperand(value, valueType, result->operands) ||
parser.resolveOperand(position, i32Type, result->operands))
if (parser.resolveOperand(vector, vectorType, result.operands) ||
parser.resolveOperand(value, valueType, result.operands) ||
parser.resolveOperand(position, i32Type, result.operands))
return failure();
result->addTypes(vectorType);
result.addTypes(vectorType);
return success();
}
@ -610,7 +610,7 @@ static void printInsertValueOp(OpAsmPrinter *p, InsertValueOp &op) {
// `[` integer-literal (`,` integer-literal)* `]`
// attribute-dict? `:` type
static ParseResult parseInsertValueOp(OpAsmParser &parser,
OperationState *result) {
OperationState &result) {
OpAsmParser::OperandType container, value;
Type containerType;
Attribute positionAttr;
@ -619,8 +619,8 @@ static ParseResult parseInsertValueOp(OpAsmParser &parser,
if (parser.parseOperand(value) || parser.parseComma() ||
parser.parseOperand(container) ||
parser.getCurrentLocation(&attributeLoc) ||
parser.parseAttribute(positionAttr, "position", result->attributes) ||
parser.parseOptionalAttributeDict(result->attributes) ||
parser.parseAttribute(positionAttr, "position", result.attributes) ||
parser.parseOptionalAttributeDict(result.attributes) ||
parser.parseColon() || parser.getCurrentLocation(&trailingTypeLoc) ||
parser.parseType(containerType))
return failure();
@ -630,11 +630,11 @@ static ParseResult parseInsertValueOp(OpAsmParser &parser,
if (!valueType)
return failure();
if (parser.resolveOperand(container, containerType, result->operands) ||
parser.resolveOperand(value, valueType, result->operands))
if (parser.resolveOperand(container, containerType, result.operands) ||
parser.resolveOperand(value, valueType, result.operands))
return failure();
result->addTypes(containerType);
result.addTypes(containerType);
return success();
}
@ -651,24 +651,24 @@ static void printSelectOp(OpAsmPrinter *p, SelectOp &op) {
// <operation> ::= `llvm.select` ssa-use `,` ssa-use `,` ssa-use
// attribute-dict? `:` type, type
static ParseResult parseSelectOp(OpAsmParser &parser, OperationState *result) {
static ParseResult parseSelectOp(OpAsmParser &parser, OperationState &result) {
OpAsmParser::OperandType condition, trueValue, falseValue;
Type conditionType, argType;
if (parser.parseOperand(condition) || parser.parseComma() ||
parser.parseOperand(trueValue) || parser.parseComma() ||
parser.parseOperand(falseValue) ||
parser.parseOptionalAttributeDict(result->attributes) ||
parser.parseOptionalAttributeDict(result.attributes) ||
parser.parseColonType(conditionType) || parser.parseComma() ||
parser.parseType(argType))
return failure();
if (parser.resolveOperand(condition, conditionType, result->operands) ||
parser.resolveOperand(trueValue, argType, result->operands) ||
parser.resolveOperand(falseValue, argType, result->operands))
if (parser.resolveOperand(condition, conditionType, result.operands) ||
parser.resolveOperand(trueValue, argType, result.operands) ||
parser.resolveOperand(falseValue, argType, result.operands))
return failure();
result->addTypes(argType);
result.addTypes(argType);
return success();
}
@ -684,14 +684,14 @@ static void printBrOp(OpAsmPrinter *p, BrOp &op) {
// <operation> ::= `llvm.br` bb-id (`[` ssa-use-and-type-list `]`)?
// attribute-dict?
static ParseResult parseBrOp(OpAsmParser &parser, OperationState *result) {
static ParseResult parseBrOp(OpAsmParser &parser, OperationState &result) {
Block *dest;
SmallVector<Value *, 4> operands;
if (parser.parseSuccessorAndUseList(dest, operands) ||
parser.parseOptionalAttributeDict(result->attributes))
parser.parseOptionalAttributeDict(result.attributes))
return failure();
result->addSuccessor(dest, operands);
result.addSuccessor(dest, operands);
return success();
}
@ -710,7 +710,7 @@ static void printCondBrOp(OpAsmPrinter *p, CondBrOp &op) {
// <operation> ::= `llvm.cond_br` ssa-use `,`
// bb-id (`[` ssa-use-and-type-list `]`)? `,`
// bb-id (`[` ssa-use-and-type-list `]`)? attribute-dict?
static ParseResult parseCondBrOp(OpAsmParser &parser, OperationState *result) {
static ParseResult parseCondBrOp(OpAsmParser &parser, OperationState &result) {
Block *trueDest;
Block *falseDest;
SmallVector<Value *, 4> trueOperands;
@ -726,12 +726,12 @@ static ParseResult parseCondBrOp(OpAsmParser &parser, OperationState *result) {
parser.parseSuccessorAndUseList(trueDest, trueOperands) ||
parser.parseComma() ||
parser.parseSuccessorAndUseList(falseDest, falseOperands) ||
parser.parseOptionalAttributeDict(result->attributes) ||
parser.resolveOperand(condition, i1Type, result->operands))
parser.parseOptionalAttributeDict(result.attributes) ||
parser.resolveOperand(condition, i1Type, result.operands))
return failure();
result->addSuccessor(trueDest, trueOperands);
result->addSuccessor(falseDest, falseOperands);
result.addSuccessor(trueDest, trueOperands);
result.addSuccessor(falseDest, falseOperands);
return success();
}
@ -752,18 +752,18 @@ static void printReturnOp(OpAsmPrinter *p, ReturnOp &op) {
// <operation> ::= `llvm.return` ssa-use-list attribute-dict? `:`
// type-list-no-parens
static ParseResult parseReturnOp(OpAsmParser &parser, OperationState *result) {
static ParseResult parseReturnOp(OpAsmParser &parser, OperationState &result) {
SmallVector<OpAsmParser::OperandType, 1> operands;
Type type;
if (parser.parseOperandList(operands) ||
parser.parseOptionalAttributeDict(result->attributes))
parser.parseOptionalAttributeDict(result.attributes))
return failure();
if (operands.empty())
return success();
if (parser.parseColonType(type) ||
parser.resolveOperand(operands[0], type, result->operands))
parser.resolveOperand(operands[0], type, result.operands))
return failure();
return success();
}
@ -779,14 +779,14 @@ static void printUndefOp(OpAsmPrinter *p, UndefOp &op) {
}
// <operation> ::= `llvm.mlir.undef` attribute-dict? : type
static ParseResult parseUndefOp(OpAsmParser &parser, OperationState *result) {
static ParseResult parseUndefOp(OpAsmParser &parser, OperationState &result) {
Type type;
if (parser.parseOptionalAttributeDict(result->attributes) ||
if (parser.parseOptionalAttributeDict(result.attributes) ||
parser.parseColonType(type))
return failure();
result->addTypes(type);
result.addTypes(type);
return success();
}
@ -807,12 +807,12 @@ static void printAddressOfOp(OpAsmPrinter *p, AddressOfOp op) {
}
static ParseResult parseAddressOfOp(OpAsmParser &parser,
OperationState *result) {
OperationState &result) {
Attribute symRef;
Type type;
if (parser.parseAttribute(symRef, "global_name", result->attributes) ||
parser.parseOptionalAttributeDict(result->attributes) ||
parser.parseColonType(type) || parser.addTypeToList(type, result->types))
if (parser.parseAttribute(symRef, "global_name", result.attributes) ||
parser.parseOptionalAttributeDict(result.attributes) ||
parser.parseColonType(type) || parser.addTypeToList(type, result.types))
return failure();
if (!symRef.isa<SymbolRefAttr>())
@ -845,18 +845,18 @@ static void printConstantOp(OpAsmPrinter *p, ConstantOp &op) {
// <operation> ::= `llvm.mlir.constant` `(` attribute `)` attribute-list? : type
static ParseResult parseConstantOp(OpAsmParser &parser,
OperationState *result) {
OperationState &result) {
Attribute valueAttr;
Type type;
if (parser.parseLParen() ||
parser.parseAttribute(valueAttr, "value", result->attributes) ||
parser.parseAttribute(valueAttr, "value", result.attributes) ||
parser.parseRParen() ||
parser.parseOptionalAttributeDict(result->attributes) ||
parser.parseOptionalAttributeDict(result.attributes) ||
parser.parseColonType(type))
return failure();
result->addTypes(type);
result.addTypes(type);
return success();
}
@ -864,16 +864,16 @@ static ParseResult parseConstantOp(OpAsmParser &parser,
// Builder, printer and verifier for LLVM::GlobalOp.
//===----------------------------------------------------------------------===//
void GlobalOp::build(Builder *builder, OperationState *result, LLVMType type,
void GlobalOp::build(Builder *builder, OperationState &result, LLVMType type,
bool isConstant, StringRef name, Attribute value,
ArrayRef<NamedAttribute> attrs) {
result->addAttribute(SymbolTable::getSymbolAttrName(),
builder->getStringAttr(name));
result->addAttribute("type", builder->getTypeAttr(type));
result.addAttribute(SymbolTable::getSymbolAttrName(),
builder->getStringAttr(name));
result.addAttribute("type", builder->getTypeAttr(type));
if (isConstant)
result->addAttribute("constant", builder->getUnitAttr());
result->addAttribute("value", value);
result->attributes.append(attrs.begin(), attrs.end());
result.addAttribute("constant", builder->getUnitAttr());
result.addAttribute("value", value);
result.attributes.append(attrs.begin(), attrs.end());
}
static void printGlobalOp(OpAsmPrinter *p, GlobalOp op) {
@ -898,19 +898,19 @@ static void printGlobalOp(OpAsmPrinter *p, GlobalOp op) {
//
// The type can be omitted for string attributes, in which case it will be
// inferred from the value of the string as [strlen(value) x i8].
static ParseResult parseGlobalOp(OpAsmParser &parser, OperationState *result) {
static ParseResult parseGlobalOp(OpAsmParser &parser, OperationState &result) {
if (succeeded(parser.parseOptionalKeyword("constant")))
result->addAttribute("constant", parser.getBuilder().getUnitAttr());
result.addAttribute("constant", parser.getBuilder().getUnitAttr());
Attribute value;
StringAttr name;
SmallVector<Type, 1> types;
if (parser.parseSymbolName(name, SymbolTable::getSymbolAttrName(),
result->attributes) ||
result.attributes) ||
parser.parseLParen() ||
parser.parseAttribute(value, "value", result->attributes) ||
parser.parseAttribute(value, "value", result.attributes) ||
parser.parseRParen() ||
parser.parseOptionalAttributeDict(result->attributes) ||
parser.parseOptionalAttributeDict(result.attributes) ||
parser.parseOptionalColonTypeList(types))
return failure();
@ -930,7 +930,7 @@ static ParseResult parseGlobalOp(OpAsmParser &parser, OperationState *result) {
}
}
result->addAttribute("type", parser.getBuilder().getTypeAttr(types[0]));
result.addAttribute("type", parser.getBuilder().getTypeAttr(types[0]));
return success();
}
@ -957,14 +957,14 @@ static LogicalResult verify(GlobalOp op) {
//===----------------------------------------------------------------------===//
// Expects vector to be of wrapped LLVM vector type and position to be of
// wrapped LLVM i32 type.
void LLVM::ShuffleVectorOp::build(Builder *b, OperationState *result, Value *v1,
void LLVM::ShuffleVectorOp::build(Builder *b, OperationState &result, Value *v1,
Value *v2, ArrayAttr mask,
ArrayRef<NamedAttribute> attrs) {
auto wrappedContainerType1 = v1->getType().cast<LLVM::LLVMType>();
auto vType = LLVMType::getVectorTy(
wrappedContainerType1.getVectorElementType(), mask.size());
build(b, result, vType, v1, v2, mask);
result->addAttributes(attrs);
result.addAttributes(attrs);
}
static void printShuffleVectorOp(OpAsmPrinter *p, ShuffleVectorOp &op) {
@ -978,7 +978,7 @@ static void printShuffleVectorOp(OpAsmPrinter *p, ShuffleVectorOp &op) {
// `[` integer-literal (`,` integer-literal)* `]`
// attribute-dict? `:` type
static ParseResult parseShuffleVectorOp(OpAsmParser &parser,
OperationState *result) {
OperationState &result) {
llvm::SMLoc loc;
SmallVector<NamedAttribute, 4> attrs;
OpAsmParser::OperandType v1, v2;
@ -990,8 +990,8 @@ static ParseResult parseShuffleVectorOp(OpAsmParser &parser,
parser.parseOptionalAttributeDict(attrs) ||
parser.parseColonType(typeV1) || parser.parseComma() ||
parser.parseType(typeV2) ||
parser.resolveOperand(v1, typeV1, result->operands) ||
parser.resolveOperand(v2, typeV2, result->operands))
parser.resolveOperand(v1, typeV1, result.operands) ||
parser.resolveOperand(v2, typeV2, result.operands))
return failure();
auto wrappedContainerType1 = typeV1.dyn_cast<LLVM::LLVMType>();
if (!wrappedContainerType1 ||
@ -1001,8 +1001,8 @@ static ParseResult parseShuffleVectorOp(OpAsmParser &parser,
auto vType =
LLVMType::getVectorTy(wrappedContainerType1.getVectorElementType(),
maskAttr.cast<ArrayAttr>().size());
result->attributes = attrs;
result->addTypes(vType);
result.attributes = attrs;
result.addTypes(vType);
return success();
}
@ -1010,14 +1010,14 @@ static ParseResult parseShuffleVectorOp(OpAsmParser &parser,
// Builder, printer and verifier for LLVM::LLVMFuncOp.
//===----------------------------------------------------------------------===//
void LLVMFuncOp::build(Builder *builder, OperationState *result, StringRef name,
void LLVMFuncOp::build(Builder *builder, OperationState &result, StringRef name,
LLVMType type, ArrayRef<NamedAttribute> attrs,
ArrayRef<NamedAttributeList> argAttrs) {
result->addRegion();
result->addAttribute(SymbolTable::getSymbolAttrName(),
builder->getStringAttr(name));
result->addAttribute("type", builder->getTypeAttr(type));
result->attributes.append(attrs.begin(), attrs.end());
result.addRegion();
result.addAttribute(SymbolTable::getSymbolAttrName(),
builder->getStringAttr(name));
result.addAttribute("type", builder->getTypeAttr(type));
result.attributes.append(attrs.begin(), attrs.end());
if (argAttrs.empty())
return;
@ -1027,7 +1027,7 @@ void LLVMFuncOp::build(Builder *builder, OperationState *result, StringRef name,
SmallString<8> argAttrName;
for (unsigned i = 0; i < numInputs; ++i)
if (auto argDict = argAttrs[i].getDictionary())
result->addAttribute(getArgAttrName(i, argAttrName), argDict);
result.addAttribute(getArgAttrName(i, argAttrName), argDict);
}
// Build an LLVM function type from the given lists of input and output types.

View File

@ -52,13 +52,13 @@ static void printNVVMIntrinsicOp(OpAsmPrinter *p, Operation *op) {
// <operation> ::= `llvm.nvvm.XYZ` : type
static ParseResult parseNVVMSpecialRegisterOp(OpAsmParser &parser,
OperationState *result) {
OperationState &result) {
Type type;
if (parser.parseOptionalAttributeDict(result->attributes) ||
if (parser.parseOptionalAttributeDict(result.attributes) ||
parser.parseColonType(type))
return failure();
result->addTypes(type);
result.addTypes(type);
return success();
}
@ -72,23 +72,23 @@ static LLVM::LLVMDialect *getLlvmDialect(OpAsmParser &parser) {
// `llvm.nvvm.shfl.sync.bfly %dst, %val, %offset, %clamp_and_mask`
// : result_type
static ParseResult parseNVVMShflSyncBflyOp(OpAsmParser &parser,
OperationState *result) {
OperationState &result) {
auto llvmDialect = getLlvmDialect(parser);
auto int32Ty = LLVM::LLVMType::getInt32Ty(llvmDialect);
SmallVector<OpAsmParser::OperandType, 8> ops;
Type type;
return failure(parser.parseOperandList(ops) ||
parser.parseOptionalAttributeDict(result->attributes) ||
parser.parseOptionalAttributeDict(result.attributes) ||
parser.parseColonType(type) ||
parser.addTypeToList(type, result->types) ||
parser.addTypeToList(type, result.types) ||
parser.resolveOperands(ops, {int32Ty, type, int32Ty, int32Ty},
parser.getNameLoc(), result->operands));
parser.getNameLoc(), result.operands));
}
// <operation> ::= `llvm.nvvm.vote.ballot.sync %mask, %pred` : result_type
static ParseResult parseNVVMVoteBallotOp(OpAsmParser &parser,
OperationState *result) {
OperationState &result) {
auto llvmDialect = getLlvmDialect(parser);
auto int32Ty = LLVM::LLVMType::getInt32Ty(llvmDialect);
auto int1Ty = LLVM::LLVMType::getInt1Ty(llvmDialect);
@ -96,11 +96,11 @@ static ParseResult parseNVVMVoteBallotOp(OpAsmParser &parser,
SmallVector<OpAsmParser::OperandType, 8> ops;
Type type;
return failure(parser.parseOperandList(ops) ||
parser.parseOptionalAttributeDict(result->attributes) ||
parser.parseOptionalAttributeDict(result.attributes) ||
parser.parseColonType(type) ||
parser.addTypeToList(type, result->types) ||
parser.addTypeToList(type, result.types) ||
parser.resolveOperands(ops, {int32Ty, int1Ty},
parser.getNameLoc(), result->operands));
parser.getNameLoc(), result.operands));
}
//===----------------------------------------------------------------------===//

View File

@ -141,18 +141,18 @@ static void print(OpAsmPrinter *p, BufferAllocOp op) {
}
static ParseResult parseBufferAllocOp(OpAsmParser &parser,
OperationState *result) {
OperationState &result) {
SmallVector<OpAsmParser::OperandType, 1> sizeInfo;
BufferType bufferType;
auto indexTy = parser.getBuilder().getIndexType();
if (parser.parseOperandList(sizeInfo) ||
parser.parseOptionalAttributeDict(result->attributes) ||
parser.parseOptionalAttributeDict(result.attributes) ||
parser.parseColonType(bufferType))
return failure();
if (sizeInfo.empty())
return parser.addTypeToList(bufferType, result->types);
return failure(parser.resolveOperands(sizeInfo, indexTy, result->operands) ||
parser.addTypeToList(bufferType, result->types));
return parser.addTypeToList(bufferType, result.types);
return failure(parser.resolveOperands(sizeInfo, indexTy, result.operands) ||
parser.addTypeToList(bufferType, result.types));
}
static LogicalResult verify(BufferAllocOp op) {
@ -188,14 +188,14 @@ static void print(OpAsmPrinter *p, BufferDeallocOp op) {
}
static ParseResult parseBufferDeallocOp(OpAsmParser &parser,
OperationState *result) {
OperationState &result) {
OpAsmParser::OperandType bufferInfo;
BufferType bufferType;
if (parser.parseOperand(bufferInfo) ||
parser.parseOptionalAttributeDict(result->attributes) ||
parser.parseOptionalAttributeDict(result.attributes) ||
parser.parseColonType(bufferType))
return failure();
return parser.resolveOperands(bufferInfo, bufferType, result->operands);
return parser.resolveOperands(bufferInfo, bufferType, result.operands);
}
//===----------------------------------------------------------------------===//
@ -209,15 +209,15 @@ static void print(OpAsmPrinter *p, BufferSizeOp op) {
}
static ParseResult parseBufferSizeOp(OpAsmParser &parser,
OperationState *result) {
OperationState &result) {
OpAsmParser::OperandType op;
Type type;
return failure(
parser.parseOperand(op) ||
parser.parseOptionalAttributeDict(result->attributes) ||
parser.parseOptionalAttributeDict(result.attributes) ||
parser.parseColonType(type) ||
parser.resolveOperand(op, type, result->operands) ||
parser.addTypeToList(parser.getBuilder().getIndexType(), result->types));
parser.resolveOperand(op, type, result.operands) ||
parser.addTypeToList(parser.getBuilder().getIndexType(), result.types));
}
//===----------------------------------------------------------------------===//
@ -235,18 +235,18 @@ static void print(OpAsmPrinter *p, linalg::DimOp op) {
*p << " : " << op.getOperand()->getType();
}
static ParseResult parseDimOp(OpAsmParser &parser, OperationState *result) {
static ParseResult parseDimOp(OpAsmParser &parser, OperationState &result) {
OpAsmParser::OperandType operandInfo;
IntegerAttr indexAttr;
Type type;
Type indexType = parser.getBuilder().getIndexType();
return failure(parser.parseOperand(operandInfo) || parser.parseComma() ||
parser.parseAttribute(indexAttr, indexType, "index",
result->attributes) ||
parser.parseOptionalAttributeDict(result->attributes) ||
parser.parseColonType(type) ||
parser.resolveOperand(operandInfo, type, result->operands) ||
parser.addTypeToList(indexType, result->types));
return failure(
parser.parseOperand(operandInfo) || parser.parseComma() ||
parser.parseAttribute(indexAttr, indexType, "index", result.attributes) ||
parser.parseOptionalAttributeDict(result.attributes) ||
parser.parseColonType(type) ||
parser.resolveOperand(operandInfo, type, result.operands) ||
parser.addTypeToList(indexType, result.types));
}
//===----------------------------------------------------------------------===//
@ -272,31 +272,31 @@ static void print(OpAsmPrinter *p, GenericOp op) {
interleaveComma(op.getOperandTypes(), *p);
}
static ParseResult parseGenericOp(OpAsmParser &parser, OperationState *result) {
static ParseResult parseGenericOp(OpAsmParser &parser, OperationState &result) {
SmallVector<OpAsmParser::OperandType, 8> operandsInfo, regionOperandsInfo;
DictionaryAttr dictAttr;
// Parse the core linalg traits that must check into a dictAttr.
// The name is unimportant as we will overwrite result->attributes.
// The name is unimportant as we will overwrite result.attributes.
// The core linalg traits must contain the information necessary to pass the
// verifier.
if (parser.parseAttribute(dictAttr, "_", result->attributes) ||
if (parser.parseAttribute(dictAttr, "_", result.attributes) ||
parser.parseOperandList(operandsInfo))
return failure();
result->attributes.assign(dictAttr.getValue().begin(),
dictAttr.getValue().end());
result.attributes.assign(dictAttr.getValue().begin(),
dictAttr.getValue().end());
Region &region = *result->addRegion();
Region &region = *result.addRegion();
SmallVector<Type, 8> operandTypes, regionTypes;
// Optional attributes may be added.
// Either Optional "fun" attribute or region must be specified.
if (!dictAttr.get("fun") &&
parser.parseOptionalRegion(region, regionOperandsInfo, regionTypes))
return failure();
if (parser.parseOptionalAttributeDict(result->attributes) ||
if (parser.parseOptionalAttributeDict(result.attributes) ||
parser.parseColonTypeList(operandTypes))
return failure();
return parser.resolveOperands(operandsInfo, operandTypes,
parser.getCurrentLocation(), result->operands);
parser.getCurrentLocation(), result.operands);
}
static LogicalResult verify(GenericOp op) {
@ -401,7 +401,7 @@ static void print(OpAsmPrinter *p, linalg::LoadOp op) {
*p << " : " << op.getViewType();
}
static ParseResult parseLoadOp(OpAsmParser &parser, OperationState *result) {
static ParseResult parseLoadOp(OpAsmParser &parser, OperationState &result) {
OpAsmParser::OperandType viewInfo;
SmallVector<OpAsmParser::OperandType, 4> indexInfo;
ViewType type;
@ -410,11 +410,11 @@ static ParseResult parseLoadOp(OpAsmParser &parser, OperationState *result) {
return failure(
parser.parseOperand(viewInfo) ||
parser.parseOperandList(indexInfo, OpAsmParser::Delimiter::Square) ||
parser.parseOptionalAttributeDict(result->attributes) ||
parser.parseOptionalAttributeDict(result.attributes) ||
parser.parseColonType(type) ||
parser.resolveOperand(viewInfo, type, result->operands) ||
parser.resolveOperands(indexInfo, affineIntTy, result->operands) ||
parser.addTypeToList(type.getElementType(), result->types));
parser.resolveOperand(viewInfo, type, result.operands) ||
parser.resolveOperands(indexInfo, affineIntTy, result.operands) ||
parser.addTypeToList(type.getElementType(), result.types));
}
static LogicalResult verify(linalg::LoadOp op) {
@ -435,7 +435,7 @@ static void print(OpAsmPrinter *p, RangeOp op) {
*p << " : " << op.getResult()->getType();
}
static ParseResult parseRangeOp(OpAsmParser &parser, OperationState *result) {
static ParseResult parseRangeOp(OpAsmParser &parser, OperationState &result) {
SmallVector<OpAsmParser::OperandType, 3> rangeInfo(3);
RangeType type;
auto affineIntTy = parser.getBuilder().getIndexType();
@ -443,20 +443,20 @@ static ParseResult parseRangeOp(OpAsmParser &parser, OperationState *result) {
parser.parseOperand(rangeInfo[0]) || parser.parseColon() ||
parser.parseOperand(rangeInfo[1]) || parser.parseColon() ||
parser.parseOperand(rangeInfo[2]) ||
parser.parseOptionalAttributeDict(result->attributes) ||
parser.parseOptionalAttributeDict(result.attributes) ||
parser.parseColonType(type) ||
parser.resolveOperands(rangeInfo, affineIntTy, result->operands) ||
parser.addTypeToList(type, result->types));
parser.resolveOperands(rangeInfo, affineIntTy, result.operands) ||
parser.addTypeToList(type, result.types));
}
//===----------------------------------------------------------------------===//
// SliceOp
//===----------------------------------------------------------------------===//
void mlir::linalg::SliceOp::build(Builder *b, OperationState *result,
void mlir::linalg::SliceOp::build(Builder *b, OperationState &result,
Value *base, ArrayRef<Value *> indexings) {
result->addOperands(base);
result->addOperands(indexings);
result.addOperands(base);
result.addOperands(indexings);
ViewType viewType = base->getType().cast<ViewType>();
unsigned rank = viewType.getRank();
@ -464,7 +464,7 @@ void mlir::linalg::SliceOp::build(Builder *b, OperationState *result,
if (!i->getType().isa<RangeType>())
rank--;
Type elementType = viewType.getElementType();
result->addTypes({ViewType::get(b->getContext(), elementType, rank)});
result.addTypes({ViewType::get(b->getContext(), elementType, rank)});
}
static void print(OpAsmPrinter *p, SliceOp op) {
@ -479,13 +479,13 @@ static void print(OpAsmPrinter *p, SliceOp op) {
*p << ", " << op.getType();
}
static ParseResult parseSliceOp(OpAsmParser &parser, OperationState *result) {
static ParseResult parseSliceOp(OpAsmParser &parser, OperationState &result) {
OpAsmParser::OperandType baseInfo;
SmallVector<OpAsmParser::OperandType, 8> operands;
SmallVector<Type, 8> types;
if (parser.parseOperand(baseInfo) ||
parser.parseOperandList(operands, OpAsmParser::Delimiter::Square) ||
parser.parseOptionalAttributeDict(result->attributes) ||
parser.parseOptionalAttributeDict(result.attributes) ||
parser.parseColonTypeList(types))
return failure();
@ -495,11 +495,11 @@ static ParseResult parseSliceOp(OpAsmParser &parser, OperationState *result) {
ArrayRef<Type> indexingTypes = ArrayRef<Type>(types).drop_front().drop_back();
return failure(
parser.resolveOperand(baseInfo, types.front(), result->operands) ||
parser.resolveOperand(baseInfo, types.front(), result.operands) ||
(!operands.empty() &&
parser.resolveOperands(operands, indexingTypes,
operands.front().location, result->operands)) ||
parser.addTypeToList(types.back(), result->types));
operands.front().location, result.operands)) ||
parser.addTypeToList(types.back(), result.types));
}
static LogicalResult verify(SliceOp op) {
@ -532,7 +532,7 @@ static void print(OpAsmPrinter *p, linalg::StoreOp op) {
*p << " : " << op.getViewType();
}
static ParseResult parseStoreOp(OpAsmParser &parser, OperationState *result) {
static ParseResult parseStoreOp(OpAsmParser &parser, OperationState &result) {
OpAsmParser::OperandType storeValueInfo;
OpAsmParser::OperandType viewInfo;
SmallVector<OpAsmParser::OperandType, 4> indexInfo;
@ -543,12 +543,12 @@ static ParseResult parseStoreOp(OpAsmParser &parser, OperationState *result) {
parser.parseOperand(storeValueInfo) || parser.parseComma() ||
parser.parseOperand(viewInfo) ||
parser.parseOperandList(indexInfo, OpAsmParser::Delimiter::Square) ||
parser.parseOptionalAttributeDict(result->attributes) ||
parser.parseOptionalAttributeDict(result.attributes) ||
parser.parseColonType(viewType) ||
parser.resolveOperand(storeValueInfo, viewType.getElementType(),
result->operands) ||
parser.resolveOperand(viewInfo, viewType, result->operands) ||
parser.resolveOperands(indexInfo, affineIntTy, result->operands));
result.operands) ||
parser.resolveOperand(viewInfo, viewType, result.operands) ||
parser.resolveOperands(indexInfo, affineIntTy, result.operands));
}
static LogicalResult verify(linalg::StoreOp op) {
@ -575,7 +575,7 @@ static void print(OpAsmPrinter *p, SubViewOp op) {
*p << " : " << op.getViewType();
}
static ParseResult parseSubViewOp(OpAsmParser &parser, OperationState *result) {
static ParseResult parseSubViewOp(OpAsmParser &parser, OperationState &result) {
OpAsmParser::OperandType inputView, resultView;
Type viewType;
if (parser.parseOperand(inputView))
@ -587,25 +587,25 @@ static ParseResult parseSubViewOp(OpAsmParser &parser, OperationState *result) {
// to something resembling
// linalg.subview %0[%1:%2:%3][%4:%5:%6]
if (parser.parseOperandList(ops, OpAsmParser::Delimiter::Square) ||
parser.parseOptionalAttributeDict(result->attributes) ||
parser.parseOptionalAttributeDict(result.attributes) ||
parser.parseColonType(viewType))
return failure();
auto indexTy = parser.getBuilder().getIndexType();
return failure(parser.resolveOperand(inputView, viewType, result->operands) ||
parser.resolveOperands(ops, indexTy, result->operands) ||
parser.addTypeToList(viewType, result->types));
return failure(parser.resolveOperand(inputView, viewType, result.operands) ||
parser.resolveOperands(ops, indexTy, result.operands) ||
parser.addTypeToList(viewType, result.types));
}
//===----------------------------------------------------------------------===//
// TransposeOp
//===----------------------------------------------------------------------===//
void mlir::linalg::TransposeOp::build(Builder *b, OperationState *result,
void mlir::linalg::TransposeOp::build(Builder *b, OperationState &result,
Value *view, AffineMapAttr permutation,
ArrayRef<NamedAttribute> attrs) {
// TODO(ntv): once views have static dimensions, compute the permuted type.
build(b, result, view->getType(), view, attrs);
result->addAttribute(TransposeOp::getPermutationAttrName(), permutation);
result.addAttribute(TransposeOp::getPermutationAttrName(), permutation);
}
static void print(OpAsmPrinter *p, TransposeOp op) {
@ -616,24 +616,24 @@ static void print(OpAsmPrinter *p, TransposeOp op) {
}
static ParseResult parseTransposeOp(OpAsmParser &parser,
OperationState *result) {
OperationState &result) {
OpAsmParser::OperandType view;
AffineMapAttr permutation;
Type type;
return failure(parser.parseOperand(view) ||
parser.parseAttribute(permutation,
TransposeOp::getPermutationAttrName(),
result->attributes) ||
parser.parseOptionalAttributeDict(result->attributes) ||
result.attributes) ||
parser.parseOptionalAttributeDict(result.attributes) ||
parser.parseColonType(type) ||
parser.resolveOperand(view, type, result->operands) ||
parser.addTypeToList(type, result->types));
parser.resolveOperand(view, type, result.operands) ||
parser.addTypeToList(type, result.types));
}
//===----------------------------------------------------------------------===//
// ViewOp
//===----------------------------------------------------------------------===//
void mlir::linalg::ViewOp::build(Builder *b, OperationState *result,
void mlir::linalg::ViewOp::build(Builder *b, OperationState &result,
Value *buffer, ArrayRef<Value *> ranges,
Type resultType,
ArrayRef<NamedAttribute> attrs) {
@ -642,7 +642,7 @@ void mlir::linalg::ViewOp::build(Builder *b, OperationState *result,
resultType = ViewType::get(b->getContext(), elementType, ranges.size());
}
build(b, result, resultType, buffer, ranges);
result->addAttributes(attrs);
result.addAttributes(attrs);
}
static void print(OpAsmPrinter *p, ViewOp op) {
@ -653,13 +653,13 @@ static void print(OpAsmPrinter *p, ViewOp op) {
*p << " : " << op.buffer()->getType() << " -> " << op.getType();
}
static ParseResult parseViewOp(OpAsmParser &parser, OperationState *result) {
static ParseResult parseViewOp(OpAsmParser &parser, OperationState &result) {
OpAsmParser::OperandType bufferInfo;
SmallVector<OpAsmParser::OperandType, 8> rangesInfo;
Type bType, vType;
if (parser.parseOperand(bufferInfo) ||
parser.parseOperandList(rangesInfo, OpAsmParser::Delimiter::Square) ||
parser.parseOptionalAttributeDict(result->attributes) ||
parser.parseOptionalAttributeDict(result.attributes) ||
parser.parseColon() || parser.parseType(bType) || parser.parseArrow() ||
parser.parseType(vType)) {
return failure();
@ -672,11 +672,11 @@ static ParseResult parseViewOp(OpAsmParser &parser, OperationState *result) {
return parser.emitError(parser.getNameLoc(), "expected ")
<< viewType.getRank() << " ranges";
return failure(
parser.resolveOperand(bufferInfo, bType, result->operands) ||
parser.resolveOperand(bufferInfo, bType, result.operands) ||
(!rangesInfo.empty() &&
parser.resolveOperands(rangesInfo, RangeType::get(vType.getContext()),
result->operands)) ||
parser.addTypeToList(viewType, result->types));
result.operands)) ||
parser.addTypeToList(viewType, result.types));
}
//===----------------------------------------------------------------------===//
@ -697,14 +697,14 @@ static void print(OpAsmPrinter *p, YieldOp op) {
}
}
static ParseResult parseYieldOp(OpAsmParser &parser, OperationState *result) {
static ParseResult parseYieldOp(OpAsmParser &parser, OperationState &result) {
SmallVector<OpAsmParser::OperandType, 2> opInfo;
SmallVector<Type, 2> types;
llvm::SMLoc loc = parser.getCurrentLocation();
return failure(parser.parseOperandList(opInfo) ||
parser.parseOptionalAttributeDict(result->attributes) ||
parser.parseOptionalAttributeDict(result.attributes) ||
(!opInfo.empty() && parser.parseColonTypeList(types)) ||
parser.resolveOperands(opInfo, types, loc, result->operands));
parser.resolveOperands(opInfo, types, loc, result.operands));
}
static LogicalResult verify(YieldOp op) {
@ -767,14 +767,14 @@ static void printLinalgLibraryOp(OpAsmPrinter *p, Operation *op) {
}
static ParseResult parseLinalgLibraryOp(OpAsmParser &parser,
OperationState *result) {
OperationState &result) {
SmallVector<OpAsmParser::OperandType, 3> ops;
SmallVector<Type, 3> types;
return failure(parser.parseOperandList(ops, OpAsmParser::Delimiter::Paren) ||
parser.parseOptionalAttributeDict(result->attributes) ||
parser.parseColonTypeList(types) ||
parser.resolveOperands(ops, types, parser.getNameLoc(),
result->operands));
return failure(
parser.parseOperandList(ops, OpAsmParser::Delimiter::Paren) ||
parser.parseOptionalAttributeDict(result.attributes) ||
parser.parseColonTypeList(types) ||
parser.resolveOperands(ops, types, parser.getNameLoc(), result.operands));
}
static LogicalResult verify(FillOp op) {

View File

@ -49,11 +49,11 @@ LoopOpsDialect::LoopOpsDialect(MLIRContext *context)
// ForOp
//===----------------------------------------------------------------------===//
void ForOp::build(Builder *builder, OperationState *result, Value *lb,
void ForOp::build(Builder *builder, OperationState &result, Value *lb,
Value *ub, Value *step) {
result->addOperands({lb, ub, step});
Region *bodyRegion = result->addRegion();
ForOp::ensureTerminator(*bodyRegion, *builder, result->location);
result.addOperands({lb, ub, step});
Region *bodyRegion = result.addRegion();
ForOp::ensureTerminator(*bodyRegion, *builder, result.location);
bodyRegion->front().addArgument(builder->getIndexType());
}
@ -82,7 +82,7 @@ static void print(OpAsmPrinter *p, ForOp op) {
p->printOptionalAttrDict(op.getAttrs());
}
static ParseResult parseForOp(OpAsmParser &parser, OperationState *result) {
static ParseResult parseForOp(OpAsmParser &parser, OperationState &result) {
auto &builder = parser.getBuilder();
OpAsmParser::OperandType inductionVariable, lb, ub, step;
// Parse the induction variable followed by '='.
@ -92,22 +92,22 @@ static ParseResult parseForOp(OpAsmParser &parser, OperationState *result) {
// Parse loop bounds.
Type indexType = builder.getIndexType();
if (parser.parseOperand(lb) ||
parser.resolveOperand(lb, indexType, result->operands) ||
parser.resolveOperand(lb, indexType, result.operands) ||
parser.parseKeyword("to") || parser.parseOperand(ub) ||
parser.resolveOperand(ub, indexType, result->operands) ||
parser.resolveOperand(ub, indexType, result.operands) ||
parser.parseKeyword("step") || parser.parseOperand(step) ||
parser.resolveOperand(step, indexType, result->operands))
parser.resolveOperand(step, indexType, result.operands))
return failure();
// Parse the body region.
Region *body = result->addRegion();
Region *body = result.addRegion();
if (parser.parseRegion(*body, inductionVariable, indexType))
return failure();
ForOp::ensureTerminator(*body, builder, result->location);
ForOp::ensureTerminator(*body, builder, result.location);
// Parse the optional attribute list.
if (parser.parseOptionalAttributeDict(result->attributes))
if (parser.parseOptionalAttributeDict(result.attributes))
return failure();
return success();
@ -126,14 +126,14 @@ ForOp mlir::loop::getForInductionVarOwner(Value *val) {
// IfOp
//===----------------------------------------------------------------------===//
void IfOp::build(Builder *builder, OperationState *result, Value *cond,
void IfOp::build(Builder *builder, OperationState &result, Value *cond,
bool withElseRegion) {
result->addOperands(cond);
Region *thenRegion = result->addRegion();
Region *elseRegion = result->addRegion();
IfOp::ensureTerminator(*thenRegion, *builder, result->location);
result.addOperands(cond);
Region *thenRegion = result.addRegion();
Region *elseRegion = result.addRegion();
IfOp::ensureTerminator(*thenRegion, *builder, result.location);
if (withElseRegion)
IfOp::ensureTerminator(*elseRegion, *builder, result->location);
IfOp::ensureTerminator(*elseRegion, *builder, result.location);
}
static LogicalResult verify(IfOp op) {
@ -150,33 +150,33 @@ static LogicalResult verify(IfOp op) {
return success();
}
static ParseResult parseIfOp(OpAsmParser &parser, OperationState *result) {
static ParseResult parseIfOp(OpAsmParser &parser, OperationState &result) {
// Create the regions for 'then'.
result->regions.reserve(2);
Region *thenRegion = result->addRegion();
Region *elseRegion = result->addRegion();
result.regions.reserve(2);
Region *thenRegion = result.addRegion();
Region *elseRegion = result.addRegion();
auto &builder = parser.getBuilder();
OpAsmParser::OperandType cond;
Type i1Type = builder.getIntegerType(1);
if (parser.parseOperand(cond) ||
parser.resolveOperand(cond, i1Type, result->operands))
parser.resolveOperand(cond, i1Type, result.operands))
return failure();
// Parse the 'then' region.
if (parser.parseRegion(*thenRegion, {}, {}))
return failure();
IfOp::ensureTerminator(*thenRegion, parser.getBuilder(), result->location);
IfOp::ensureTerminator(*thenRegion, parser.getBuilder(), result.location);
// If we find an 'else' keyword then parse the 'else' region.
if (!parser.parseOptionalKeyword("else")) {
if (parser.parseRegion(*elseRegion, {}, {}))
return failure();
IfOp::ensureTerminator(*elseRegion, parser.getBuilder(), result->location);
IfOp::ensureTerminator(*elseRegion, parser.getBuilder(), result.location);
}
// Parse the optional attribute list.
if (parser.parseOptionalAttributeDict(result->attributes))
if (parser.parseOptionalAttributeDict(result.attributes))
return failure();
return success();

View File

@ -76,11 +76,11 @@ static LogicalResult extractValueFromConstOp(Operation *op,
}
static ParseResult parseBinaryLogicalOp(OpAsmParser &parser,
OperationState *result) {
OperationState &result) {
SmallVector<OpAsmParser::OperandType, 2> ops;
Type type;
if (parser.parseOperandList(ops, 2) || parser.parseColonType(type) ||
parser.resolveOperands(ops, type, result->operands)) {
parser.resolveOperands(ops, type, result.operands)) {
return failure();
}
// Result must be a scalar or vector of boolean type.
@ -88,7 +88,7 @@ static ParseResult parseBinaryLogicalOp(OpAsmParser &parser,
if (auto opsType = type.dyn_cast<VectorType>()) {
resultType = VectorType::get(opsType.getNumElements(), resultType);
}
result->addTypes(resultType);
result.addTypes(resultType);
return success();
}
@ -119,18 +119,18 @@ static ParseResult parseEnumAttribute(EnumClass &value, OpAsmParser &parser) {
template <typename EnumClass>
static ParseResult parseEnumAttribute(EnumClass &value, OpAsmParser &parser,
OperationState *state) {
OperationState &state) {
if (parseEnumAttribute(value, parser)) {
return failure();
}
state->addAttribute(
state.addAttribute(
spirv::attributeName<EnumClass>(),
parser.getBuilder().getI32IntegerAttr(bitwiseCast<int32_t>(value)));
return success();
}
static ParseResult parseMemoryAccessAttributes(OpAsmParser &parser,
OperationState *state) {
OperationState &state) {
// Parse an optional list of attributes staring with '['
if (parser.parseOptionalLSquare()) {
// Nothing to do
@ -148,7 +148,7 @@ static ParseResult parseMemoryAccessAttributes(OpAsmParser &parser,
Type i32Type = parser.getBuilder().getIntegerType(32);
if (parser.parseComma() ||
parser.parseAttribute(alignmentAttr, i32Type, kAlignmentAttrName,
state->attributes)) {
state.attributes)) {
return failure();
}
}
@ -156,8 +156,8 @@ static ParseResult parseMemoryAccessAttributes(OpAsmParser &parser,
}
// Parses an op that has no inputs and no outputs.
static ParseResult parseNoIOOp(OpAsmParser &parser, OperationState *state) {
if (parser.parseOptionalAttributeDict(state->attributes))
static ParseResult parseNoIOOp(OpAsmParser &parser, OperationState &state) {
if (parser.parseOptionalAttributeDict(state.attributes))
return failure();
return success();
}
@ -249,7 +249,7 @@ static void printNoIOOp(Operation *op, OpAsmPrinter *printer) {
}
static ParseResult parseVariableDecorations(OpAsmParser &parser,
OperationState *state) {
OperationState &state) {
auto builtInName =
convertToSnakeCase(stringifyDecoration(spirv::Decoration::BuiltIn));
if (succeeded(parser.parseOptionalKeyword("bind"))) {
@ -262,24 +262,24 @@ static ParseResult parseVariableDecorations(OpAsmParser &parser,
Type i32Type = parser.getBuilder().getIntegerType(32);
if (parser.parseLParen() ||
parser.parseAttribute(set, i32Type, descriptorSetName,
state->attributes) ||
state.attributes) ||
parser.parseComma() ||
parser.parseAttribute(binding, i32Type, bindingName,
state->attributes) ||
state.attributes) ||
parser.parseRParen()) {
return failure();
}
} else if (succeeded(parser.parseOptionalKeyword(builtInName))) {
StringAttr builtIn;
if (parser.parseLParen() ||
parser.parseAttribute(builtIn, builtInName, state->attributes) ||
parser.parseAttribute(builtIn, builtInName, state.attributes) ||
parser.parseRParen()) {
return failure();
}
}
// Parse other attributes
if (parser.parseOptionalAttributeDict(state->attributes))
if (parser.parseOptionalAttributeDict(state.attributes))
return failure();
return success();
@ -396,15 +396,15 @@ static Type getElementPtrType(Type type, ArrayRef<Value *> indices,
return spirv::PointerType::get(resultType, resultStorageClass);
}
void spirv::AccessChainOp::build(Builder *builder, OperationState *state,
void spirv::AccessChainOp::build(Builder *builder, OperationState &state,
Value *basePtr, ArrayRef<Value *> indices) {
auto type = getElementPtrType(basePtr->getType(), indices, state->location);
auto type = getElementPtrType(basePtr->getType(), indices, state.location);
assert(type && "Unable to deduce return type based on basePtr and indices");
build(builder, state, type, basePtr, indices);
}
static ParseResult parseAccessChainOp(OpAsmParser &parser,
OperationState *state) {
OperationState &state) {
OpAsmParser::OperandType ptrInfo;
SmallVector<OpAsmParser::OperandType, 4> indicesInfo;
Type type;
@ -416,18 +416,18 @@ static ParseResult parseAccessChainOp(OpAsmParser &parser,
if (parser.parseOperand(ptrInfo) ||
parser.parseOperandList(indicesInfo, OpAsmParser::Delimiter::Square) ||
parser.parseColonType(type) ||
parser.resolveOperand(ptrInfo, type, state->operands) ||
parser.resolveOperands(indicesInfo, indicesType, state->operands)) {
parser.resolveOperand(ptrInfo, type, state.operands) ||
parser.resolveOperands(indicesInfo, indicesType, state.operands)) {
return failure();
}
auto resultType = getElementPtrType(
type, llvm::makeArrayRef(state->operands).drop_front(), state->location);
type, llvm::makeArrayRef(state.operands).drop_front(), state.location);
if (!resultType) {
return failure();
}
state->addTypes(resultType);
state.addTypes(resultType);
return success();
}
@ -468,11 +468,11 @@ static LogicalResult verify(spirv::AccessChainOp accessChainOp) {
//===----------------------------------------------------------------------===//
static ParseResult parseAddressOfOp(OpAsmParser &parser,
OperationState *state) {
OperationState &state) {
SymbolRefAttr varRefAttr;
Type type;
if (parser.parseAttribute(varRefAttr, Type(), kVariableAttrName,
state->attributes) ||
state.attributes) ||
parser.parseColonType(type)) {
return failure();
}
@ -481,7 +481,7 @@ static ParseResult parseAddressOfOp(OpAsmParser &parser,
return parser.emitError(parser.getCurrentLocation(),
"expected spv.ptr type");
}
state->addTypes(ptrType);
state.addTypes(ptrType);
return success();
}
@ -514,12 +514,12 @@ static LogicalResult verify(spirv::AddressOfOp addressOfOp) {
// spv.BranchOp
//===----------------------------------------------------------------------===//
static ParseResult parseBranchOp(OpAsmParser &parser, OperationState *state) {
static ParseResult parseBranchOp(OpAsmParser &parser, OperationState &state) {
Block *dest;
SmallVector<Value *, 4> destOperands;
if (parser.parseSuccessorAndUseList(dest, destOperands))
return failure();
state->addSuccessor(dest, destOperands);
state.addSuccessor(dest, destOperands);
return success();
}
@ -541,7 +541,7 @@ static LogicalResult verify(spirv::BranchOp branchOp) {
//===----------------------------------------------------------------------===//
static ParseResult parseBranchConditionalOp(OpAsmParser &parser,
OperationState *state) {
OperationState &state) {
auto &builder = parser.getBuilder();
OpAsmParser::OperandType condInfo;
Block *dest;
@ -550,7 +550,7 @@ static ParseResult parseBranchConditionalOp(OpAsmParser &parser,
// Parse the condition.
Type boolTy = builder.getI1Type();
if (parser.parseOperand(condInfo) ||
parser.resolveOperand(condInfo, boolTy, state->operands))
parser.resolveOperand(condInfo, boolTy, state.operands))
return failure();
// Parse the optional branch weights.
@ -565,22 +565,22 @@ static ParseResult parseBranchConditionalOp(OpAsmParser &parser,
parser.parseRSquare())
return failure();
state->addAttribute(kBranchWeightAttrName,
builder.getArrayAttr({trueWeight, falseWeight}));
state.addAttribute(kBranchWeightAttrName,
builder.getArrayAttr({trueWeight, falseWeight}));
}
// Parse the true branch.
if (parser.parseComma() ||
parser.parseSuccessorAndUseList(dest, destOperands))
return failure();
state->addSuccessor(dest, destOperands);
state.addSuccessor(dest, destOperands);
// Parse the false branch.
destOperands.clear();
if (parser.parseComma() ||
parser.parseSuccessorAndUseList(dest, destOperands))
return failure();
state->addSuccessor(dest, destOperands);
state.addSuccessor(dest, destOperands);
return success();
}
@ -628,7 +628,7 @@ static LogicalResult verify(spirv::BranchConditionalOp branchOp) {
//===----------------------------------------------------------------------===//
static ParseResult parseCompositeExtractOp(OpAsmParser &parser,
OperationState *state) {
OperationState &state) {
OpAsmParser::OperandType compositeInfo;
Attribute indicesAttr;
Type compositeType;
@ -637,9 +637,9 @@ static ParseResult parseCompositeExtractOp(OpAsmParser &parser,
if (parser.parseOperand(compositeInfo) ||
parser.getCurrentLocation(&attrLocation) ||
parser.parseAttribute(indicesAttr, kIndicesAttrName, state->attributes) ||
parser.parseAttribute(indicesAttr, kIndicesAttrName, state.attributes) ||
parser.parseColonType(compositeType) ||
parser.resolveOperand(compositeInfo, compositeType, state->operands)) {
parser.resolveOperand(compositeInfo, compositeType, state.operands)) {
return failure();
}
@ -679,7 +679,7 @@ static ParseResult parseCompositeExtractOp(OpAsmParser &parser,
}
}
state->addTypes(resultType);
state.addTypes(resultType);
return success();
}
@ -736,9 +736,9 @@ OpFoldResult spirv::CompositeExtractOp::fold(ArrayRef<Attribute> operands) {
// spv.constant
//===----------------------------------------------------------------------===//
static ParseResult parseConstantOp(OpAsmParser &parser, OperationState *state) {
static ParseResult parseConstantOp(OpAsmParser &parser, OperationState &state) {
Attribute value;
if (parser.parseAttribute(value, kValueAttrName, state->attributes))
if (parser.parseAttribute(value, kValueAttrName, state.attributes))
return failure();
Type type;
@ -749,7 +749,7 @@ static ParseResult parseConstantOp(OpAsmParser &parser, OperationState *state) {
type = value.getType();
}
return parser.addTypeToList(type, state->types);
return parser.addTypeToList(type, state.types);
}
static void print(spirv::ConstantOp constOp, OpAsmPrinter *printer) {
@ -823,14 +823,14 @@ bool spirv::ConstantOp::isBuildableWith(Type type) {
//===----------------------------------------------------------------------===//
static ParseResult parseEntryPointOp(OpAsmParser &parser,
OperationState *state) {
OperationState &state) {
spirv::ExecutionModel execModel;
SmallVector<OpAsmParser::OperandType, 0> identifiers;
SmallVector<Type, 0> idTypes;
SymbolRefAttr fn;
if (parseEnumAttribute(execModel, parser, state) ||
parser.parseAttribute(fn, Type(), kFnNameAttrName, state->attributes)) {
parser.parseAttribute(fn, Type(), kFnNameAttrName, state.attributes)) {
return failure();
}
@ -847,8 +847,8 @@ static ParseResult parseEntryPointOp(OpAsmParser &parser,
}
interfaceVars.push_back(var);
} while (!parser.parseOptionalComma());
state->addAttribute(kInterfaceAttrName,
parser.getBuilder().getArrayAttr(interfaceVars));
state.addAttribute(kInterfaceAttrName,
parser.getBuilder().getArrayAttr(interfaceVars));
}
return success();
}
@ -874,10 +874,10 @@ static LogicalResult verify(spirv::EntryPointOp entryPointOp) {
//===----------------------------------------------------------------------===//
static ParseResult parseExecutionModeOp(OpAsmParser &parser,
OperationState *state) {
OperationState &state) {
spirv::ExecutionMode execMode;
Attribute fn;
if (parser.parseAttribute(fn, kFnNameAttrName, state->attributes) ||
if (parser.parseAttribute(fn, kFnNameAttrName, state.attributes) ||
parseEnumAttribute(execMode, parser, state)) {
return failure();
}
@ -892,8 +892,8 @@ static ParseResult parseExecutionModeOp(OpAsmParser &parser,
}
values.push_back(value.cast<IntegerAttr>().getInt());
}
state->addAttribute(kValuesAttrName,
parser.getBuilder().getI32ArrayAttr(values));
state.addAttribute(kValuesAttrName,
parser.getBuilder().getI32ArrayAttr(values));
return success();
}
@ -916,12 +916,12 @@ static void print(spirv::ExecutionModeOp execModeOp, OpAsmPrinter *printer) {
//===----------------------------------------------------------------------===//
static ParseResult parseFunctionCallOp(OpAsmParser &parser,
OperationState *state) {
OperationState &state) {
SymbolRefAttr calleeAttr;
FunctionType type;
SmallVector<OpAsmParser::OperandType, 4> operands;
auto loc = parser.getNameLoc();
if (parser.parseAttribute(calleeAttr, kCallee, state->attributes) ||
if (parser.parseAttribute(calleeAttr, kCallee, state.attributes) ||
parser.parseOperandList(operands, OpAsmParser::Delimiter::Paren) ||
parser.parseColonType(type)) {
return failure();
@ -939,9 +939,9 @@ static ParseResult parseFunctionCallOp(OpAsmParser &parser,
<< funcType.getNumResults();
}
return failure(parser.addTypesToList(funcType.getResults(), state->types) ||
return failure(parser.addTypesToList(funcType.getResults(), state.types) ||
parser.resolveOperands(operands, funcType.getInputs(), loc,
state->operands));
state.operands));
}
static void print(spirv::FunctionCallOp functionCallOp, OpAsmPrinter *printer) {
@ -1018,14 +1018,14 @@ static LogicalResult verify(spirv::FunctionCallOp functionCallOp) {
//===----------------------------------------------------------------------===//
static ParseResult parseGLSLUnaryOp(OpAsmParser &parser,
OperationState *state) {
OperationState &state) {
OpAsmParser::OperandType operandInfo;
Type type;
if (parser.parseOperand(operandInfo) || parser.parseColonType(type) ||
parser.resolveOperands(operandInfo, type, state->operands)) {
parser.resolveOperands(operandInfo, type, state.operands)) {
return failure();
}
state->addTypes(type);
state.addTypes(type);
return success();
}
@ -1039,11 +1039,11 @@ static void printGLSLUnaryOp(Operation *unaryOp, OpAsmPrinter *printer) {
//===----------------------------------------------------------------------===//
static ParseResult parseGlobalVariableOp(OpAsmParser &parser,
OperationState *state) {
OperationState &state) {
// Parse variable name.
StringAttr nameAttr;
if (parser.parseSymbolName(nameAttr, SymbolTable::getSymbolAttrName(),
state->attributes)) {
state.attributes)) {
return failure();
}
@ -1052,7 +1052,7 @@ static ParseResult parseGlobalVariableOp(OpAsmParser &parser,
SymbolRefAttr initSymbol;
if (parser.parseLParen() ||
parser.parseAttribute(initSymbol, Type(), kInitializerAttrName,
state->attributes) ||
state.attributes) ||
parser.parseRParen())
return failure();
}
@ -1069,7 +1069,7 @@ static ParseResult parseGlobalVariableOp(OpAsmParser &parser,
if (!type.isa<spirv::PointerType>()) {
return parser.emitError(loc, "expected spv.ptr type");
}
state->addAttribute(kTypeAttrName, parser.getBuilder().getTypeAttr(type));
state.addAttribute(kTypeAttrName, parser.getBuilder().getTypeAttr(type));
return success();
}
@ -1123,7 +1123,7 @@ static LogicalResult verify(spirv::GlobalVariableOp varOp) {
// spv.LoadOp
//===----------------------------------------------------------------------===//
static ParseResult parseLoadOp(OpAsmParser &parser, OperationState *state) {
static ParseResult parseLoadOp(OpAsmParser &parser, OperationState &state) {
// Parse the storage class specification
spirv::StorageClass storageClass;
OpAsmParser::OperandType ptrInfo;
@ -1131,17 +1131,17 @@ static ParseResult parseLoadOp(OpAsmParser &parser, OperationState *state) {
if (parseEnumAttribute(storageClass, parser) ||
parser.parseOperand(ptrInfo) ||
parseMemoryAccessAttributes(parser, state) ||
parser.parseOptionalAttributeDict(state->attributes) ||
parser.parseOptionalAttributeDict(state.attributes) ||
parser.parseColon() || parser.parseType(elementType)) {
return failure();
}
auto ptrType = spirv::PointerType::get(elementType, storageClass);
if (parser.resolveOperand(ptrInfo, ptrType, state->operands)) {
if (parser.resolveOperand(ptrInfo, ptrType, state.operands)) {
return failure();
}
state->addTypes(elementType);
state.addTypes(elementType);
return success();
}
@ -1175,14 +1175,14 @@ static LogicalResult verify(spirv::LoadOp loadOp) {
// spv.loop
//===----------------------------------------------------------------------===//
static ParseResult parseLoopOp(OpAsmParser &parser, OperationState *state) {
static ParseResult parseLoopOp(OpAsmParser &parser, OperationState &state) {
// TODO(antiagainst): support loop control properly
Builder builder = parser.getBuilder();
state->addAttribute("loop_control",
builder.getI32IntegerAttr(
static_cast<uint32_t>(spirv::LoopControl::None)));
state.addAttribute("loop_control",
builder.getI32IntegerAttr(
static_cast<uint32_t>(spirv::LoopControl::None)));
return parser.parseRegion(*state->addRegion(), /*arguments=*/{},
return parser.parseRegion(*state.addRegion(), /*arguments=*/{},
/*argTypes=*/{});
}
@ -1338,28 +1338,28 @@ static LogicalResult verify(spirv::MergeOp mergeOp) {
// spv.module
//===----------------------------------------------------------------------===//
void spirv::ModuleOp::build(Builder *builder, OperationState *state) {
ensureTerminator(*state->addRegion(), *builder, state->location);
void spirv::ModuleOp::build(Builder *builder, OperationState &state) {
ensureTerminator(*state.addRegion(), *builder, state.location);
}
void spirv::ModuleOp::build(Builder *builder, OperationState *state,
void spirv::ModuleOp::build(Builder *builder, OperationState &state,
IntegerAttr addressing_model,
IntegerAttr memory_model, ArrayAttr capabilities,
ArrayAttr extensions,
ArrayAttr extended_instruction_sets) {
state->addAttribute("addressing_model", addressing_model);
state->addAttribute("memory_model", memory_model);
state.addAttribute("addressing_model", addressing_model);
state.addAttribute("memory_model", memory_model);
if (capabilities)
state->addAttribute("capabilities", capabilities);
state.addAttribute("capabilities", capabilities);
if (extensions)
state->addAttribute("extensions", extensions);
state.addAttribute("extensions", extensions);
if (extended_instruction_sets)
state->addAttribute("extended_instruction_sets", extended_instruction_sets);
ensureTerminator(*state->addRegion(), *builder, state->location);
state.addAttribute("extended_instruction_sets", extended_instruction_sets);
ensureTerminator(*state.addRegion(), *builder, state.location);
}
static ParseResult parseModuleOp(OpAsmParser &parser, OperationState *state) {
Region *body = state->addRegion();
static ParseResult parseModuleOp(OpAsmParser &parser, OperationState &state) {
Region *body = state.addRegion();
// Parse attributes
spirv::AddressingModel addrModel;
@ -1373,12 +1373,11 @@ static ParseResult parseModuleOp(OpAsmParser &parser, OperationState *state) {
return failure();
if (succeeded(parser.parseOptionalKeyword("attributes"))) {
if (parser.parseOptionalAttributeDict(state->attributes))
if (parser.parseOptionalAttributeDict(state.attributes))
return failure();
}
spirv::ModuleOp::ensureTerminator(*body, parser.getBuilder(),
state->location);
spirv::ModuleOp::ensureTerminator(*body, parser.getBuilder(), state.location);
return success();
}
@ -1514,15 +1513,15 @@ static LogicalResult verify(spirv::ModuleOp moduleOp) {
//===----------------------------------------------------------------------===//
static ParseResult parseReferenceOfOp(OpAsmParser &parser,
OperationState *state) {
OperationState &state) {
SymbolRefAttr constRefAttr;
Type type;
if (parser.parseAttribute(constRefAttr, Type(), kSpecConstAttrName,
state->attributes) ||
state.attributes) ||
parser.parseColonType(type)) {
return failure();
}
return parser.addTypeToList(type, state->types);
return parser.addTypeToList(type, state.types);
}
static void print(spirv::ReferenceOfOp referenceOfOp, OpAsmPrinter *printer) {
@ -1565,12 +1564,12 @@ static LogicalResult verify(spirv::ReturnOp returnOp) {
//===----------------------------------------------------------------------===//
static ParseResult parseReturnValueOp(OpAsmParser &parser,
OperationState *state) {
OperationState &state) {
OpAsmParser::OperandType retValInfo;
Type retValType;
return failure(
parser.parseOperand(retValInfo) || parser.parseColonType(retValType) ||
parser.resolveOperand(retValInfo, retValType, state->operands));
return failure(parser.parseOperand(retValInfo) ||
parser.parseColonType(retValType) ||
parser.resolveOperand(retValInfo, retValType, state.operands));
}
static void print(spirv::ReturnValueOp retValOp, OpAsmPrinter *printer) {
@ -1601,7 +1600,7 @@ static LogicalResult verify(spirv::ReturnValueOp retValOp) {
// spv.Select
//===----------------------------------------------------------------------===//
static ParseResult parseSelectOp(OpAsmParser &parser, OperationState *state) {
static ParseResult parseSelectOp(OpAsmParser &parser, OperationState &state) {
OpAsmParser::OperandType condition;
SmallVector<OpAsmParser::OperandType, 2> operands;
SmallVector<Type, 2> types;
@ -1615,11 +1614,11 @@ static ParseResult parseSelectOp(OpAsmParser &parser, OperationState *state) {
return parser.emitError(
loc, "need exactly two trailing types for select condition and object");
}
if (parser.resolveOperand(condition, types[0], state->operands) ||
parser.resolveOperands(operands, types[1], state->operands)) {
if (parser.resolveOperand(condition, types[0], state.operands) ||
parser.resolveOperands(operands, types[1], state.operands)) {
return failure();
}
return parser.addTypesToList(types[1], state->types);
return parser.addTypesToList(types[1], state.types);
}
static void print(spirv::SelectOp op, OpAsmPrinter *printer) {
@ -1660,15 +1659,14 @@ static LogicalResult verify(spirv::SelectOp op) {
//===----------------------------------------------------------------------===//
static ParseResult parseSpecConstantOp(OpAsmParser &parser,
OperationState *state) {
OperationState &state) {
StringAttr nameAttr;
Attribute valueAttr;
if (parser.parseSymbolName(nameAttr, SymbolTable::getSymbolAttrName(),
state->attributes) ||
state.attributes) ||
parser.parseEqual() ||
parser.parseAttribute(valueAttr, kDefaultValueAttrName,
state->attributes))
parser.parseAttribute(valueAttr, kDefaultValueAttrName, state.attributes))
return failure();
return success();
@ -1702,7 +1700,7 @@ static LogicalResult verify(spirv::SpecConstantOp constOp) {
// spv.StoreOp
//===----------------------------------------------------------------------===//
static ParseResult parseStoreOp(OpAsmParser &parser, OperationState *state) {
static ParseResult parseStoreOp(OpAsmParser &parser, OperationState &state) {
// Parse the storage class specification
spirv::StorageClass storageClass;
SmallVector<OpAsmParser::OperandType, 2> operandInfo;
@ -1717,7 +1715,7 @@ static ParseResult parseStoreOp(OpAsmParser &parser, OperationState *state) {
auto ptrType = spirv::PointerType::get(elementType, storageClass);
if (parser.resolveOperands(operandInfo, {ptrType, elementType}, loc,
state->operands)) {
state.operands)) {
return failure();
}
return success();
@ -1756,7 +1754,7 @@ static LogicalResult verify(spirv::StoreOp storeOp) {
// spv.Variable
//===----------------------------------------------------------------------===//
static ParseResult parseVariableOp(OpAsmParser &parser, OperationState *state) {
static ParseResult parseVariableOp(OpAsmParser &parser, OperationState &state) {
// Parse optional initializer
Optional<OpAsmParser::OperandType> initInfo;
if (succeeded(parser.parseOptionalKeyword("init"))) {
@ -1781,19 +1779,19 @@ static ParseResult parseVariableOp(OpAsmParser &parser, OperationState *state) {
auto ptrType = type.dyn_cast<spirv::PointerType>();
if (!ptrType)
return parser.emitError(loc, "expected spv.ptr type");
state->addTypes(ptrType);
state.addTypes(ptrType);
// Resolve the initializer operand
SmallVector<Value *, 1> init;
if (initInfo) {
if (parser.resolveOperand(*initInfo, ptrType.getPointeeType(), init))
return failure();
state->addOperands(init);
state.addOperands(init);
}
auto attr = parser.getBuilder().getI32IntegerAttr(
bitwiseCast<int32_t>(ptrType.getStorageClass()));
state->addAttribute(spirv::attributeName<spirv::StorageClass>(), attr);
state.addAttribute(spirv::attributeName<spirv::StorageClass>(), attr);
return success();
}

View File

@ -471,7 +471,7 @@ spirv::ModuleOp Deserializer::createModuleOp() {
// TODO(antiagainst): use target environment to select the version
state.addAttribute("major_version", builder.getI32IntegerAttr(1));
state.addAttribute("minor_version", builder.getI32IntegerAttr(0));
spirv::ModuleOp::build(&builder, &state);
spirv::ModuleOp::build(&builder, state);
return cast<spirv::ModuleOp>(Operation::create(state));
}

View File

@ -316,14 +316,14 @@ static void print(OpAsmPrinter *p, AllocOp op) {
*p << " : " << type;
}
static ParseResult parseAllocOp(OpAsmParser &parser, OperationState *result) {
static ParseResult parseAllocOp(OpAsmParser &parser, OperationState &result) {
MemRefType type;
// Parse the dimension operands and optional symbol operands, followed by a
// memref type.
unsigned numDimOperands;
if (parseDimAndSymbolList(parser, result->operands, numDimOperands) ||
parser.parseOptionalAttributeDict(result->attributes) ||
if (parseDimAndSymbolList(parser, result.operands, numDimOperands) ||
parser.parseOptionalAttributeDict(result.attributes) ||
parser.parseColonType(type))
return failure();
@ -337,7 +337,7 @@ static ParseResult parseAllocOp(OpAsmParser &parser, OperationState *result) {
return parser.emitError(parser.getNameLoc())
<< "dimension operand count does not equal memref dynamic dimension "
"count";
result->types.push_back(type);
result.types.push_back(type);
return success();
}
@ -459,12 +459,12 @@ void AllocOp::getCanonicalizationPatterns(OwningRewritePatternList &results,
// BranchOp
//===----------------------------------------------------------------------===//
static ParseResult parseBranchOp(OpAsmParser &parser, OperationState *result) {
static ParseResult parseBranchOp(OpAsmParser &parser, OperationState &result) {
Block *dest;
SmallVector<Value *, 4> destOperands;
if (parser.parseSuccessorAndUseList(dest, destOperands))
return failure();
result->addSuccessor(dest, destOperands);
result.addSuccessor(dest, destOperands);
return success();
}
@ -487,18 +487,18 @@ void BranchOp::eraseOperand(unsigned index) {
// CallOp
//===----------------------------------------------------------------------===//
static ParseResult parseCallOp(OpAsmParser &parser, OperationState *result) {
static ParseResult parseCallOp(OpAsmParser &parser, OperationState &result) {
SymbolRefAttr calleeAttr;
FunctionType calleeType;
SmallVector<OpAsmParser::OperandType, 4> operands;
auto calleeLoc = parser.getNameLoc();
if (parser.parseAttribute(calleeAttr, "callee", result->attributes) ||
if (parser.parseAttribute(calleeAttr, "callee", result.attributes) ||
parser.parseOperandList(operands, OpAsmParser::Delimiter::Paren) ||
parser.parseOptionalAttributeDict(result->attributes) ||
parser.parseOptionalAttributeDict(result.attributes) ||
parser.parseColonType(calleeType) ||
parser.addTypesToList(calleeType.getResults(), result->types) ||
parser.addTypesToList(calleeType.getResults(), result.types) ||
parser.resolveOperands(operands, calleeType.getInputs(), calleeLoc,
result->operands))
result.operands))
return failure();
return success();
@ -576,7 +576,7 @@ struct SimplifyIndirectCallWithKnownCallee
} // end anonymous namespace.
static ParseResult parseCallIndirectOp(OpAsmParser &parser,
OperationState *result) {
OperationState &result) {
FunctionType calleeType;
OpAsmParser::OperandType callee;
llvm::SMLoc operandsLoc;
@ -584,12 +584,12 @@ static ParseResult parseCallIndirectOp(OpAsmParser &parser,
return failure(
parser.parseOperand(callee) || parser.getCurrentLocation(&operandsLoc) ||
parser.parseOperandList(operands, OpAsmParser::Delimiter::Paren) ||
parser.parseOptionalAttributeDict(result->attributes) ||
parser.parseOptionalAttributeDict(result.attributes) ||
parser.parseColonType(calleeType) ||
parser.resolveOperand(callee, calleeType, result->operands) ||
parser.resolveOperand(callee, calleeType, result.operands) ||
parser.resolveOperands(operands, calleeType.getInputs(), operandsLoc,
result->operands) ||
parser.addTypesToList(calleeType.getResults(), result->types));
result.operands) ||
parser.addTypesToList(calleeType.getResults(), result.types));
}
static void print(OpAsmPrinter *p, CallIndirectOp op) {
@ -696,16 +696,16 @@ CmpIPredicate CmpIOp::getPredicateByName(StringRef name) {
.Default(CmpIPredicate::NumPredicates);
}
static void buildCmpIOp(Builder *build, OperationState *result,
static void buildCmpIOp(Builder *build, OperationState &result,
CmpIPredicate predicate, Value *lhs, Value *rhs) {
result->addOperands({lhs, rhs});
result->types.push_back(getI1SameShape(build, lhs->getType()));
result->addAttribute(
result.addOperands({lhs, rhs});
result.types.push_back(getI1SameShape(build, lhs->getType()));
result.addAttribute(
CmpIOp::getPredicateAttrName(),
build->getI64IntegerAttr(static_cast<int64_t>(predicate)));
}
static ParseResult parseCmpIOp(OpAsmParser &parser, OperationState *result) {
static ParseResult parseCmpIOp(OpAsmParser &parser, OperationState &result) {
SmallVector<OpAsmParser::OperandType, 2> ops;
SmallVector<NamedAttribute, 4> attrs;
Attribute predicateNameAttr;
@ -714,7 +714,7 @@ static ParseResult parseCmpIOp(OpAsmParser &parser, OperationState *result) {
attrs) ||
parser.parseComma() || parser.parseOperandList(ops, 2) ||
parser.parseOptionalAttributeDict(attrs) || parser.parseColonType(type) ||
parser.resolveOperands(ops, type, result->operands))
parser.resolveOperands(ops, type, result.operands))
return failure();
if (!predicateNameAttr.isa<StringAttr>())
@ -735,9 +735,9 @@ static ParseResult parseCmpIOp(OpAsmParser &parser, OperationState *result) {
"expected type with valid i1 shape");
attrs[0].second = builder.getI64IntegerAttr(static_cast<int64_t>(predicate));
result->attributes = attrs;
result.attributes = attrs;
result->addTypes({i1Type});
result.addTypes({i1Type});
return success();
}
@ -872,16 +872,16 @@ CmpFPredicate CmpFOp::getPredicateByName(StringRef name) {
.Default(CmpFPredicate::NumPredicates);
}
static void buildCmpFOp(Builder *build, OperationState *result,
static void buildCmpFOp(Builder *build, OperationState &result,
CmpFPredicate predicate, Value *lhs, Value *rhs) {
result->addOperands({lhs, rhs});
result->types.push_back(getI1SameShape(build, lhs->getType()));
result->addAttribute(
result.addOperands({lhs, rhs});
result.types.push_back(getI1SameShape(build, lhs->getType()));
result.addAttribute(
CmpFOp::getPredicateAttrName(),
build->getI64IntegerAttr(static_cast<int64_t>(predicate)));
}
static ParseResult parseCmpFOp(OpAsmParser &parser, OperationState *result) {
static ParseResult parseCmpFOp(OpAsmParser &parser, OperationState &result) {
SmallVector<OpAsmParser::OperandType, 2> ops;
SmallVector<NamedAttribute, 4> attrs;
Attribute predicateNameAttr;
@ -890,7 +890,7 @@ static ParseResult parseCmpFOp(OpAsmParser &parser, OperationState *result) {
attrs) ||
parser.parseComma() || parser.parseOperandList(ops, 2) ||
parser.parseOptionalAttributeDict(attrs) || parser.parseColonType(type) ||
parser.resolveOperands(ops, type, result->operands))
parser.resolveOperands(ops, type, result.operands))
return failure();
if (!predicateNameAttr.isa<StringAttr>())
@ -912,9 +912,9 @@ static ParseResult parseCmpFOp(OpAsmParser &parser, OperationState *result) {
"expected type with valid i1 shape");
attrs[0].second = builder.getI64IntegerAttr(static_cast<int64_t>(predicate));
result->attributes = attrs;
result.attributes = attrs;
result->addTypes({i1Type});
result.addTypes({i1Type});
return success();
}
@ -1057,7 +1057,7 @@ struct SimplifyConstCondBranchPred : public OpRewritePattern<CondBranchOp> {
} // end anonymous namespace.
static ParseResult parseCondBranchOp(OpAsmParser &parser,
OperationState *result) {
OperationState &result) {
SmallVector<Value *, 4> destOperands;
Block *dest;
OpAsmParser::OperandType condInfo;
@ -1065,7 +1065,7 @@ static ParseResult parseCondBranchOp(OpAsmParser &parser,
// Parse the condition.
Type int1Ty = parser.getBuilder().getI1Type();
if (parser.parseOperand(condInfo) || parser.parseComma() ||
parser.resolveOperand(condInfo, int1Ty, result->operands)) {
parser.resolveOperand(condInfo, int1Ty, result.operands)) {
return parser.emitError(parser.getNameLoc(),
"expected condition type was boolean (i1)");
}
@ -1073,14 +1073,14 @@ static ParseResult parseCondBranchOp(OpAsmParser &parser,
// Parse the true successor.
if (parser.parseSuccessorAndUseList(dest, destOperands))
return failure();
result->addSuccessor(dest, destOperands);
result.addSuccessor(dest, destOperands);
// Parse the false successor.
destOperands.clear();
if (parser.parseComma() ||
parser.parseSuccessorAndUseList(dest, destOperands))
return failure();
result->addSuccessor(dest, destOperands);
result.addSuccessor(dest, destOperands);
return success();
}
@ -1117,10 +1117,10 @@ static void print(OpAsmPrinter *p, ConstantOp &op) {
}
static ParseResult parseConstantOp(OpAsmParser &parser,
OperationState *result) {
OperationState &result) {
Attribute valueAttr;
if (parser.parseOptionalAttributeDict(result->attributes) ||
parser.parseAttribute(valueAttr, "value", result->attributes))
if (parser.parseOptionalAttributeDict(result.attributes) ||
parser.parseAttribute(valueAttr, "value", result.attributes))
return failure();
// If the attribute is a symbol reference, then we expect a trailing type.
@ -1131,7 +1131,7 @@ static ParseResult parseConstantOp(OpAsmParser &parser,
return failure();
// Add the attribute type to the list.
return parser.addTypeToList(type, result->types);
return parser.addTypeToList(type, result.types);
}
/// The constant op requires an attribute, and furthermore requires that it
@ -1216,7 +1216,7 @@ bool ConstantOp::isBuildableWith(Attribute value, Type type) {
value.isa<UnitAttr>();
}
void ConstantFloatOp::build(Builder *builder, OperationState *result,
void ConstantFloatOp::build(Builder *builder, OperationState &result,
const APFloat &value, FloatType type) {
ConstantOp::build(builder, result, type, builder->getFloatAttr(type, value));
}
@ -1232,7 +1232,7 @@ bool ConstantIntOp::classof(Operation *op) {
op->getResult(0)->getType().isa<IntegerType>();
}
void ConstantIntOp::build(Builder *builder, OperationState *result,
void ConstantIntOp::build(Builder *builder, OperationState &result,
int64_t value, unsigned width) {
Type type = builder->getIntegerType(width);
ConstantOp::build(builder, result, type,
@ -1241,7 +1241,7 @@ void ConstantIntOp::build(Builder *builder, OperationState *result,
/// Build a constant int op producing an integer with the specified type,
/// which must be an integer type.
void ConstantIntOp::build(Builder *builder, OperationState *result,
void ConstantIntOp::build(Builder *builder, OperationState &result,
int64_t value, Type type) {
assert(type.isa<IntegerType>() && "ConstantIntOp can only have integer type");
ConstantOp::build(builder, result, type,
@ -1253,7 +1253,7 @@ bool ConstantIndexOp::classof(Operation *op) {
return ConstantOp::classof(op) && op->getResult(0)->getType().isIndex();
}
void ConstantIndexOp::build(Builder *builder, OperationState *result,
void ConstantIndexOp::build(Builder *builder, OperationState &result,
int64_t value) {
Type type = builder->getIndexType();
ConstantOp::build(builder, result, type,
@ -1292,13 +1292,13 @@ static void print(OpAsmPrinter *p, DeallocOp op) {
*p << "dealloc " << *op.memref() << " : " << op.memref()->getType();
}
static ParseResult parseDeallocOp(OpAsmParser &parser, OperationState *result) {
static ParseResult parseDeallocOp(OpAsmParser &parser, OperationState &result) {
OpAsmParser::OperandType memrefInfo;
MemRefType type;
return failure(parser.parseOperand(memrefInfo) ||
parser.parseColonType(type) ||
parser.resolveOperand(memrefInfo, type, result->operands));
parser.resolveOperand(memrefInfo, type, result.operands));
}
static LogicalResult verify(DeallocOp op) {
@ -1324,19 +1324,19 @@ static void print(OpAsmPrinter *p, DimOp op) {
*p << " : " << op.getOperand()->getType();
}
static ParseResult parseDimOp(OpAsmParser &parser, OperationState *result) {
static ParseResult parseDimOp(OpAsmParser &parser, OperationState &result) {
OpAsmParser::OperandType operandInfo;
IntegerAttr indexAttr;
Type type;
Type indexType = parser.getBuilder().getIndexType();
return failure(parser.parseOperand(operandInfo) || parser.parseComma() ||
parser.parseAttribute(indexAttr, indexType, "index",
result->attributes) ||
parser.parseOptionalAttributeDict(result->attributes) ||
parser.parseColonType(type) ||
parser.resolveOperand(operandInfo, type, result->operands) ||
parser.addTypeToList(indexType, result->types));
return failure(
parser.parseOperand(operandInfo) || parser.parseComma() ||
parser.parseAttribute(indexAttr, indexType, "index", result.attributes) ||
parser.parseOptionalAttributeDict(result.attributes) ||
parser.parseColonType(type) ||
parser.resolveOperand(operandInfo, type, result.operands) ||
parser.addTypeToList(indexType, result.types));
}
static LogicalResult verify(DimOp op) {
@ -1430,20 +1430,20 @@ OpFoldResult DivIUOp::fold(ArrayRef<Attribute> operands) {
// DmaStartOp
// ---------------------------------------------------------------------------
void DmaStartOp::build(Builder *builder, OperationState *result,
void DmaStartOp::build(Builder *builder, OperationState &result,
Value *srcMemRef, ArrayRef<Value *> srcIndices,
Value *destMemRef, ArrayRef<Value *> destIndices,
Value *numElements, Value *tagMemRef,
ArrayRef<Value *> tagIndices, Value *stride,
Value *elementsPerStride) {
result->addOperands(srcMemRef);
result->addOperands(srcIndices);
result->addOperands(destMemRef);
result->addOperands(destIndices);
result->addOperands({numElements, tagMemRef});
result->addOperands(tagIndices);
result.addOperands(srcMemRef);
result.addOperands(srcIndices);
result.addOperands(destMemRef);
result.addOperands(destIndices);
result.addOperands({numElements, tagMemRef});
result.addOperands(tagIndices);
if (stride)
result->addOperands({stride, elementsPerStride});
result.addOperands({stride, elementsPerStride});
}
void DmaStartOp::print(OpAsmPrinter *p) {
@ -1473,7 +1473,7 @@ void DmaStartOp::print(OpAsmPrinter *p) {
// memref<1024 x f32, 2>,
// memref<1 x i32>
//
ParseResult DmaStartOp::parse(OpAsmParser &parser, OperationState *result) {
ParseResult DmaStartOp::parse(OpAsmParser &parser, OperationState &result) {
OpAsmParser::OperandType srcMemRefInfo;
SmallVector<OpAsmParser::OperandType, 4> srcIndexInfos;
OpAsmParser::OperandType dstMemRefInfo;
@ -1514,15 +1514,15 @@ ParseResult DmaStartOp::parse(OpAsmParser &parser, OperationState *result) {
if (types.size() != 3)
return parser.emitError(parser.getNameLoc(), "fewer/more types expected");
if (parser.resolveOperand(srcMemRefInfo, types[0], result->operands) ||
parser.resolveOperands(srcIndexInfos, indexType, result->operands) ||
parser.resolveOperand(dstMemRefInfo, types[1], result->operands) ||
parser.resolveOperands(dstIndexInfos, indexType, result->operands) ||
if (parser.resolveOperand(srcMemRefInfo, types[0], result.operands) ||
parser.resolveOperands(srcIndexInfos, indexType, result.operands) ||
parser.resolveOperand(dstMemRefInfo, types[1], result.operands) ||
parser.resolveOperands(dstIndexInfos, indexType, result.operands) ||
// size should be an index.
parser.resolveOperand(numElementsInfo, indexType, result->operands) ||
parser.resolveOperand(tagMemrefInfo, types[2], result->operands) ||
parser.resolveOperand(numElementsInfo, indexType, result.operands) ||
parser.resolveOperand(tagMemrefInfo, types[2], result.operands) ||
// tag indices should be index.
parser.resolveOperands(tagIndexInfos, indexType, result->operands))
parser.resolveOperands(tagIndexInfos, indexType, result.operands))
return failure();
auto memrefType0 = types[0].dyn_cast<MemRefType>();
@ -1541,7 +1541,7 @@ ParseResult DmaStartOp::parse(OpAsmParser &parser, OperationState *result) {
"expected tag to be of memref type");
if (isStrided) {
if (parser.resolveOperands(strideInfo, indexType, result->operands))
if (parser.resolveOperands(strideInfo, indexType, result.operands))
return failure();
}
@ -1581,12 +1581,12 @@ void DmaStartOp::getCanonicalizationPatterns(OwningRewritePatternList &results,
// DmaWaitOp
// ---------------------------------------------------------------------------
void DmaWaitOp::build(Builder *builder, OperationState *result,
void DmaWaitOp::build(Builder *builder, OperationState &result,
Value *tagMemRef, ArrayRef<Value *> tagIndices,
Value *numElements) {
result->addOperands(tagMemRef);
result->addOperands(tagIndices);
result->addOperands(numElements);
result.addOperands(tagMemRef);
result.addOperands(tagIndices);
result.addOperands(numElements);
}
void DmaWaitOp::print(OpAsmPrinter *p) {
@ -1604,7 +1604,7 @@ void DmaWaitOp::print(OpAsmPrinter *p) {
// Eg:
// dma_wait %tag[%index], %num_elements : memref<1 x i32, (d0) -> (d0), 4>
//
ParseResult DmaWaitOp::parse(OpAsmParser &parser, OperationState *result) {
ParseResult DmaWaitOp::parse(OpAsmParser &parser, OperationState &result) {
OpAsmParser::OperandType tagMemrefInfo;
SmallVector<OpAsmParser::OperandType, 2> tagIndexInfos;
Type type;
@ -1616,9 +1616,9 @@ ParseResult DmaWaitOp::parse(OpAsmParser &parser, OperationState *result) {
parser.parseOperandList(tagIndexInfos, OpAsmParser::Delimiter::Square) ||
parser.parseComma() || parser.parseOperand(numElementsInfo) ||
parser.parseColonType(type) ||
parser.resolveOperand(tagMemrefInfo, type, result->operands) ||
parser.resolveOperands(tagIndexInfos, indexType, result->operands) ||
parser.resolveOperand(numElementsInfo, indexType, result->operands))
parser.resolveOperand(tagMemrefInfo, type, result.operands) ||
parser.resolveOperands(tagIndexInfos, indexType, result.operands) ||
parser.resolveOperand(numElementsInfo, indexType, result.operands))
return failure();
auto memrefType = type.dyn_cast<MemRefType>();
@ -1652,7 +1652,7 @@ static void print(OpAsmPrinter *p, ExtractElementOp op) {
}
static ParseResult parseExtractElementOp(OpAsmParser &parser,
OperationState *result) {
OperationState &result) {
OpAsmParser::OperandType aggregateInfo;
SmallVector<OpAsmParser::OperandType, 4> indexInfo;
ShapedType type;
@ -1661,11 +1661,11 @@ static ParseResult parseExtractElementOp(OpAsmParser &parser,
return failure(
parser.parseOperand(aggregateInfo) ||
parser.parseOperandList(indexInfo, OpAsmParser::Delimiter::Square) ||
parser.parseOptionalAttributeDict(result->attributes) ||
parser.parseOptionalAttributeDict(result.attributes) ||
parser.parseColonType(type) ||
parser.resolveOperand(aggregateInfo, type, result->operands) ||
parser.resolveOperands(indexInfo, affineIntTy, result->operands) ||
parser.addTypeToList(type.getElementType(), result->types));
parser.resolveOperand(aggregateInfo, type, result.operands) ||
parser.resolveOperands(indexInfo, affineIntTy, result.operands) ||
parser.addTypeToList(type.getElementType(), result.types));
}
static LogicalResult verify(ExtractElementOp op) {
@ -1733,7 +1733,7 @@ static void print(OpAsmPrinter *p, LoadOp op) {
*p << " : " << op.getMemRefType();
}
static ParseResult parseLoadOp(OpAsmParser &parser, OperationState *result) {
static ParseResult parseLoadOp(OpAsmParser &parser, OperationState &result) {
OpAsmParser::OperandType memrefInfo;
SmallVector<OpAsmParser::OperandType, 4> indexInfo;
MemRefType type;
@ -1742,11 +1742,11 @@ static ParseResult parseLoadOp(OpAsmParser &parser, OperationState *result) {
return failure(
parser.parseOperand(memrefInfo) ||
parser.parseOperandList(indexInfo, OpAsmParser::Delimiter::Square) ||
parser.parseOptionalAttributeDict(result->attributes) ||
parser.parseOptionalAttributeDict(result.attributes) ||
parser.parseColonType(type) ||
parser.resolveOperand(memrefInfo, type, result->operands) ||
parser.resolveOperands(indexInfo, affineIntTy, result->operands) ||
parser.addTypeToList(type.getElementType(), result->types));
parser.resolveOperand(memrefInfo, type, result.operands) ||
parser.resolveOperands(indexInfo, affineIntTy, result.operands) ||
parser.addTypeToList(type.getElementType(), result.types));
}
static LogicalResult verify(LoadOp op) {
@ -1841,14 +1841,14 @@ static void print(OpAsmPrinter *p, RankOp op) {
*p << "rank " << *op.getOperand() << " : " << op.getOperand()->getType();
}
static ParseResult parseRankOp(OpAsmParser &parser, OperationState *result) {
static ParseResult parseRankOp(OpAsmParser &parser, OperationState &result) {
OpAsmParser::OperandType operandInfo;
Type type;
Type indexType = parser.getBuilder().getIndexType();
return failure(parser.parseOperand(operandInfo) ||
parser.parseColonType(type) ||
parser.resolveOperand(operandInfo, type, result->operands) ||
parser.addTypeToList(indexType, result->types));
parser.resolveOperand(operandInfo, type, result.operands) ||
parser.addTypeToList(indexType, result.types));
}
OpFoldResult RankOp::fold(ArrayRef<Attribute> operands) {
@ -1915,13 +1915,13 @@ OpFoldResult RemIUOp::fold(ArrayRef<Attribute> operands) {
// ReturnOp
//===----------------------------------------------------------------------===//
static ParseResult parseReturnOp(OpAsmParser &parser, OperationState *result) {
static ParseResult parseReturnOp(OpAsmParser &parser, OperationState &result) {
SmallVector<OpAsmParser::OperandType, 2> opInfo;
SmallVector<Type, 2> types;
llvm::SMLoc loc = parser.getCurrentLocation();
return failure(parser.parseOperandList(opInfo) ||
(!opInfo.empty() && parser.parseColonTypeList(types)) ||
parser.resolveOperands(opInfo, types, loc, result->operands));
parser.resolveOperands(opInfo, types, loc, result.operands));
}
static void print(OpAsmPrinter *p, ReturnOp op) {
@ -1967,12 +1967,12 @@ bool SIToFPOp::areCastCompatible(Type a, Type b) {
// SelectOp
//===----------------------------------------------------------------------===//
static ParseResult parseSelectOp(OpAsmParser &parser, OperationState *result) {
static ParseResult parseSelectOp(OpAsmParser &parser, OperationState &result) {
SmallVector<OpAsmParser::OperandType, 3> ops;
SmallVector<NamedAttribute, 4> attrs;
Type type;
if (parser.parseOperandList(ops, 3) ||
parser.parseOptionalAttributeDict(result->attributes) ||
parser.parseOptionalAttributeDict(result.attributes) ||
parser.parseColonType(type))
return failure();
@ -1983,8 +1983,8 @@ static ParseResult parseSelectOp(OpAsmParser &parser, OperationState *result) {
SmallVector<Type, 3> types = {i1Type, type, type};
return failure(parser.resolveOperands(ops, types, parser.getNameLoc(),
result->operands) ||
parser.addTypeToList(type, result->types));
result.operands) ||
parser.addTypeToList(type, result.types));
}
static void print(OpAsmPrinter *p, SelectOp op) {
@ -2031,7 +2031,7 @@ static void print(OpAsmPrinter *p, StoreOp op) {
*p << " : " << op.getMemRefType();
}
static ParseResult parseStoreOp(OpAsmParser &parser, OperationState *result) {
static ParseResult parseStoreOp(OpAsmParser &parser, OperationState &result) {
OpAsmParser::OperandType storeValueInfo;
OpAsmParser::OperandType memrefInfo;
SmallVector<OpAsmParser::OperandType, 4> indexInfo;
@ -2042,12 +2042,12 @@ static ParseResult parseStoreOp(OpAsmParser &parser, OperationState *result) {
parser.parseOperand(storeValueInfo) || parser.parseComma() ||
parser.parseOperand(memrefInfo) ||
parser.parseOperandList(indexInfo, OpAsmParser::Delimiter::Square) ||
parser.parseOptionalAttributeDict(result->attributes) ||
parser.parseOptionalAttributeDict(result.attributes) ||
parser.parseColonType(memrefType) ||
parser.resolveOperand(storeValueInfo, memrefType.getElementType(),
result->operands) ||
parser.resolveOperand(memrefInfo, memrefType, result->operands) ||
parser.resolveOperands(indexInfo, affineIntTy, result->operands));
result.operands) ||
parser.resolveOperand(memrefInfo, memrefType, result.operands) ||
parser.resolveOperands(indexInfo, affineIntTy, result.operands));
}
static LogicalResult verify(StoreOp op) {
@ -2204,16 +2204,16 @@ static void print(OpAsmPrinter *p, TensorLoadOp op) {
}
static ParseResult parseTensorLoadOp(OpAsmParser &parser,
OperationState *result) {
OperationState &result) {
OpAsmParser::OperandType op;
Type type;
return failure(parser.parseOperand(op) ||
parser.parseOptionalAttributeDict(result->attributes) ||
parser.parseOptionalAttributeDict(result.attributes) ||
parser.parseColonType(type) ||
parser.resolveOperand(op, type, result->operands) ||
parser.resolveOperand(op, type, result.operands) ||
parser.addTypeToList(
getTensorTypeFromMemRefType(parser.getBuilder(), type),
result->types));
result.types));
}
//===----------------------------------------------------------------------===//
@ -2227,17 +2227,17 @@ static void print(OpAsmPrinter *p, TensorStoreOp op) {
}
static ParseResult parseTensorStoreOp(OpAsmParser &parser,
OperationState *result) {
OperationState &result) {
SmallVector<OpAsmParser::OperandType, 2> ops;
Type type;
llvm::SMLoc loc = parser.getCurrentLocation();
return failure(
parser.parseOperandList(ops, /*requiredOperandCount=*/2) ||
parser.parseOptionalAttributeDict(result->attributes) ||
parser.parseOptionalAttributeDict(result.attributes) ||
parser.parseColonType(type) ||
parser.resolveOperands(
ops, {getTensorTypeFromMemRefType(parser.getBuilder(), type), type},
loc, result->operands));
loc, result.operands));
}
//===----------------------------------------------------------------------===//

View File

@ -56,7 +56,7 @@ static void print(OpAsmPrinter *p, ExtractElementOp op) {
}
static ParseResult parseExtractElementOp(OpAsmParser &parser,
OperationState *result) {
OperationState &result) {
llvm::SMLoc attributeLoc, typeLoc;
SmallVector<NamedAttribute, 4> attrs;
OpAsmParser::OperandType vector;
@ -86,9 +86,9 @@ static ParseResult parseExtractElementOp(OpAsmParser &parser,
vectorType.getShape().drop_front(positionAttr.size()),
vectorType.getElementType());
result->attributes = attrs;
return failure(parser.resolveOperand(vector, type, result->operands) ||
parser.addTypeToList(resType, result->types));
result.attributes = attrs;
return failure(parser.resolveOperand(vector, type, result.operands) ||
parser.addTypeToList(resType, result.types));
}
static LogicalResult verify(ExtractElementOp op) {
@ -121,7 +121,7 @@ static void print(OpAsmPrinter *p, OuterProductOp op) {
}
static ParseResult parseOuterProductOp(OpAsmParser &parser,
OperationState *result) {
OperationState &result) {
SmallVector<OpAsmParser::OperandType, 3> operandsInfo;
Type tLHS, tRHS;
if (parser.parseOperandList(operandsInfo) || parser.parseColonType(tLHS) ||
@ -137,11 +137,11 @@ static ParseResult parseOuterProductOp(OpAsmParser &parser,
VectorType resType = VectorType::get({vLHS.getDimSize(0), vRHS.getDimSize(0)},
vLHS.getElementType());
return failure(
parser.resolveOperand(operandsInfo[0], tLHS, result->operands) ||
parser.resolveOperand(operandsInfo[1], tRHS, result->operands) ||
parser.resolveOperand(operandsInfo[0], tLHS, result.operands) ||
parser.resolveOperand(operandsInfo[1], tRHS, result.operands) ||
(operandsInfo.size() > 2 &&
parser.resolveOperand(operandsInfo[2], resType, result->operands)) ||
parser.addTypeToList(resType, result->types));
parser.resolveOperand(operandsInfo[2], resType, result.operands)) ||
parser.addTypeToList(resType, result.types));
}
static LogicalResult verify(OuterProductOp op) {
@ -195,19 +195,19 @@ static LogicalResult verifyPermutationMap(AffineMap permutationMap,
return success();
}
void VectorTransferReadOp::build(Builder *builder, OperationState *result,
void VectorTransferReadOp::build(Builder *builder, OperationState &result,
VectorType vectorType, Value *srcMemRef,
ArrayRef<Value *> srcIndices,
AffineMap permutationMap,
Optional<Value *> paddingValue) {
result->addOperands(srcMemRef);
result->addOperands(srcIndices);
result.addOperands(srcMemRef);
result.addOperands(srcIndices);
if (paddingValue) {
result->addOperands({*paddingValue});
result.addOperands({*paddingValue});
}
result->addAttribute(getPermutationMapAttrName(),
builder->getAffineMapAttr(permutationMap));
result->addTypes(vectorType);
result.addAttribute(getPermutationMapAttrName(),
builder->getAffineMapAttr(permutationMap));
result.addTypes(vectorType);
}
auto VectorTransferReadOp::getIndices() -> operand_range {
@ -246,7 +246,7 @@ void VectorTransferReadOp::print(OpAsmPrinter *p) {
}
ParseResult VectorTransferReadOp::parse(OpAsmParser &parser,
OperationState *result) {
OperationState &result) {
OpAsmParser::OperandType memrefInfo;
SmallVector<OpAsmParser::OperandType, 8> indexInfo;
SmallVector<OpAsmParser::OperandType, 8> paddingInfo;
@ -257,7 +257,7 @@ ParseResult VectorTransferReadOp::parse(OpAsmParser &parser,
parser.parseOperandList(indexInfo, OpAsmParser::Delimiter::Square) ||
parser.parseTrailingOperandList(paddingInfo,
OpAsmParser::Delimiter::Paren) ||
parser.parseOptionalAttributeDict(result->attributes) ||
parser.parseOptionalAttributeDict(result.attributes) ||
parser.parseColonTypeList(types))
return failure();
@ -288,11 +288,11 @@ ParseResult VectorTransferReadOp::parse(OpAsmParser &parser,
}
auto indexType = parser.getBuilder().getIndexType();
return failure(
parser.resolveOperand(memrefInfo, memrefType, result->operands) ||
parser.resolveOperands(indexInfo, indexType, result->operands) ||
parser.resolveOperand(memrefInfo, memrefType, result.operands) ||
parser.resolveOperands(indexInfo, indexType, result.operands) ||
(hasOptionalPaddingValue &&
parser.resolveOperand(paddingInfo[0], paddingType, result->operands)) ||
parser.addTypeToList(vectorType, result->types));
parser.resolveOperand(paddingInfo[0], paddingType, result.operands)) ||
parser.addTypeToList(vectorType, result.types));
}
LogicalResult VectorTransferReadOp::verify() {
@ -376,14 +376,14 @@ LogicalResult VectorTransferReadOp::verify() {
//===----------------------------------------------------------------------===//
// VectorTransferWriteOp
//===----------------------------------------------------------------------===//
void VectorTransferWriteOp::build(Builder *builder, OperationState *result,
void VectorTransferWriteOp::build(Builder *builder, OperationState &result,
Value *srcVector, Value *dstMemRef,
ArrayRef<Value *> dstIndices,
AffineMap permutationMap) {
result->addOperands({srcVector, dstMemRef});
result->addOperands(dstIndices);
result->addAttribute(getPermutationMapAttrName(),
builder->getAffineMapAttr(permutationMap));
result.addOperands({srcVector, dstMemRef});
result.addOperands(dstIndices);
result.addAttribute(getPermutationMapAttrName(),
builder->getAffineMapAttr(permutationMap));
}
auto VectorTransferWriteOp::getIndices() -> operand_range {
@ -411,7 +411,7 @@ void VectorTransferWriteOp::print(OpAsmPrinter *p) {
}
ParseResult VectorTransferWriteOp::parse(OpAsmParser &parser,
OperationState *result) {
OperationState &result) {
OpAsmParser::OperandType storeValueInfo;
OpAsmParser::OperandType memrefInfo;
SmallVector<OpAsmParser::OperandType, 4> indexInfo;
@ -420,7 +420,7 @@ ParseResult VectorTransferWriteOp::parse(OpAsmParser &parser,
if (parser.parseOperand(storeValueInfo) || parser.parseComma() ||
parser.parseOperand(memrefInfo) ||
parser.parseOperandList(indexInfo, OpAsmParser::Delimiter::Square) ||
parser.parseOptionalAttributeDict(result->attributes) ||
parser.parseOptionalAttributeDict(result.attributes) ||
parser.parseColonTypeList(types))
return failure();
@ -434,9 +434,9 @@ ParseResult VectorTransferWriteOp::parse(OpAsmParser &parser,
return parser.emitError(parser.getNameLoc(), "memRef type expected");
return failure(
parser.resolveOperands(storeValueInfo, vectorType, result->operands) ||
parser.resolveOperands(memrefInfo, memrefType, result->operands) ||
parser.resolveOperands(indexInfo, indexType, result->operands));
parser.resolveOperands(storeValueInfo, vectorType, result.operands) ||
parser.resolveOperands(memrefInfo, memrefType, result.operands) ||
parser.resolveOperands(indexInfo, indexType, result.operands));
}
LogicalResult VectorTransferWriteOp::verify() {
@ -506,22 +506,22 @@ LogicalResult VectorTransferWriteOp::verify() {
//===----------------------------------------------------------------------===//
// VectorTypeCastOp
//===----------------------------------------------------------------------===//
void VectorTypeCastOp::build(Builder *builder, OperationState *result,
void VectorTypeCastOp::build(Builder *builder, OperationState &result,
Value *srcVector, Type dstType) {
result->addOperands(srcVector);
result->addTypes(dstType);
result.addOperands(srcVector);
result.addTypes(dstType);
}
ParseResult VectorTypeCastOp::parse(OpAsmParser &parser,
OperationState *result) {
OperationState &result) {
OpAsmParser::OperandType operand;
Type srcType, dstType;
return failure(parser.parseOperand(operand) ||
parser.parseOptionalAttributeDict(result->attributes) ||
parser.parseOptionalAttributeDict(result.attributes) ||
parser.parseColonType(srcType) || parser.parseComma() ||
parser.parseType(dstType) ||
parser.addTypeToList(dstType, result->types) ||
parser.resolveOperand(operand, srcType, result->operands));
parser.addTypeToList(dstType, result.types) ||
parser.resolveOperand(operand, srcType, result.operands));
}
void VectorTypeCastOp::print(OpAsmPrinter *p) {

View File

@ -37,7 +37,7 @@ FuncOp FuncOp::create(Location location, StringRef name, FunctionType type,
ArrayRef<NamedAttribute> attrs) {
OperationState state(location, "func");
Builder builder(location->getContext());
FuncOp::build(&builder, &state, name, type, attrs);
FuncOp::build(&builder, state, name, type, attrs);
return llvm::cast<FuncOp>(Operation::create(state));
}
FuncOp FuncOp::create(Location location, StringRef name, FunctionType type,
@ -53,16 +53,16 @@ FuncOp FuncOp::create(Location location, StringRef name, FunctionType type,
return func;
}
void FuncOp::build(Builder *builder, OperationState *result, StringRef name,
void FuncOp::build(Builder *builder, OperationState &result, StringRef name,
FunctionType type, ArrayRef<NamedAttribute> attrs) {
result->addAttribute(SymbolTable::getSymbolAttrName(),
builder->getStringAttr(name));
result->addAttribute(getTypeAttrName(), builder->getTypeAttr(type));
result->attributes.append(attrs.begin(), attrs.end());
result->addRegion();
result.addAttribute(SymbolTable::getSymbolAttrName(),
builder->getStringAttr(name));
result.addAttribute(getTypeAttrName(), builder->getTypeAttr(type));
result.attributes.append(attrs.begin(), attrs.end());
result.addRegion();
}
void FuncOp::build(Builder *builder, OperationState *result, StringRef name,
void FuncOp::build(Builder *builder, OperationState &result, StringRef name,
FunctionType type, ArrayRef<NamedAttribute> attrs,
ArrayRef<NamedAttributeList> argAttrs) {
build(builder, result, name, type, attrs);
@ -70,12 +70,12 @@ void FuncOp::build(Builder *builder, OperationState *result, StringRef name,
SmallString<8> argAttrName;
for (unsigned i = 0, e = type.getNumInputs(); i != e; ++i)
if (auto argDict = argAttrs[i].getDictionary())
result->addAttribute(getArgAttrName(i, argAttrName), argDict);
result.addAttribute(getArgAttrName(i, argAttrName), argDict);
}
/// Parsing/Printing methods.
ParseResult FuncOp::parse(OpAsmParser &parser, OperationState *result) {
ParseResult FuncOp::parse(OpAsmParser &parser, OperationState &result) {
auto buildFuncType = [](Builder &builder, ArrayRef<Type> argTypes,
ArrayRef<Type> results, impl::VariadicFlag,
std::string &) {

View File

@ -106,7 +106,7 @@ static ParseResult parseFunctionSignature(
/// Parser implementation for function-like operations. Uses `funcTypeBuilder`
/// to construct the custom function type given lists of input and output types.
ParseResult
mlir::impl::parseFunctionLikeOp(OpAsmParser &parser, OperationState *result,
mlir::impl::parseFunctionLikeOp(OpAsmParser &parser, OperationState &result,
bool allowVariadic,
mlir::impl::FuncTypeBuilder funcTypeBuilder) {
SmallVector<OpAsmParser::OperandType, 4> entryArgs;
@ -118,10 +118,10 @@ mlir::impl::parseFunctionLikeOp(OpAsmParser &parser, OperationState *result,
// Parse the name as a symbol reference attribute.
SymbolRefAttr nameAttr;
if (parser.parseAttribute(nameAttr, ::mlir::SymbolTable::getSymbolAttrName(),
result->attributes))
result.attributes))
return failure();
// Convert the parsed function attr into a string attr.
result->attributes.back().second = builder.getStringAttr(nameAttr.getValue());
result.attributes.back().second = builder.getStringAttr(nameAttr.getValue());
// Parse the function signature.
auto signatureLocation = parser.getCurrentLocation();
@ -133,7 +133,7 @@ mlir::impl::parseFunctionLikeOp(OpAsmParser &parser, OperationState *result,
std::string errorMessage;
if (auto type = funcTypeBuilder(builder, argTypes, results,
impl::VariadicFlag(isVariadic), errorMessage))
result->addAttribute(getTypeAttrName(), builder.getTypeAttr(type));
result.addAttribute(getTypeAttrName(), builder.getTypeAttr(type));
else
return parser.emitError(signatureLocation)
<< "failed to construct function type"
@ -141,18 +141,18 @@ mlir::impl::parseFunctionLikeOp(OpAsmParser &parser, OperationState *result,
// If function attributes are present, parse them.
if (succeeded(parser.parseOptionalKeyword("attributes")))
if (parser.parseOptionalAttributeDict(result->attributes))
if (parser.parseOptionalAttributeDict(result.attributes))
return failure();
// Add the attributes to the function arguments.
SmallString<8> argAttrName;
for (unsigned i = 0, e = argTypes.size(); i != e; ++i)
if (!argAttrs[i].empty())
result->addAttribute(getArgAttrName(i, argAttrName),
builder.getDictionaryAttr(argAttrs[i]));
result.addAttribute(getArgAttrName(i, argAttrName),
builder.getDictionaryAttr(argAttrs[i]));
// Parse the optional function body.
auto *body = result->addRegion();
auto *body = result.addRegion();
if (parser.parseOptionalRegion(*body, entryArgs,
entryArgs.empty() ? llvm::ArrayRef<Type>()
: argTypes))

View File

@ -25,31 +25,31 @@ using namespace mlir;
// Module Operation.
//===----------------------------------------------------------------------===//
void ModuleOp::build(Builder *builder, OperationState *result) {
ensureTerminator(*result->addRegion(), *builder, result->location);
void ModuleOp::build(Builder *builder, OperationState &result) {
ensureTerminator(*result.addRegion(), *builder, result.location);
}
/// Construct a module from the given context.
ModuleOp ModuleOp::create(Location loc) {
OperationState state(loc, "module");
Builder builder(loc->getContext());
ModuleOp::build(&builder, &state);
ModuleOp::build(&builder, state);
return llvm::cast<ModuleOp>(Operation::create(state));
}
ParseResult ModuleOp::parse(OpAsmParser &parser, OperationState *result) {
ParseResult ModuleOp::parse(OpAsmParser &parser, OperationState &result) {
// If module attributes are present, parse them.
if (succeeded(parser.parseOptionalKeyword("attributes")))
if (parser.parseOptionalAttributeDict(result->attributes))
if (parser.parseOptionalAttributeDict(result.attributes))
return failure();
// Parse the module body.
auto *body = result->addRegion();
auto *body = result.addRegion();
if (parser.parseRegion(*body, llvm::None, llvm::None))
return failure();
// Ensure that this module has a valid terminator.
ensureTerminator(*body, parser.getBuilder(), result->location);
ensureTerminator(*body, parser.getBuilder(), result.location);
return success();
}

View File

@ -612,7 +612,7 @@ Operation *Operation::clone() {
//===----------------------------------------------------------------------===//
// The fallback for the parser is to reject the custom assembly form.
ParseResult OpState::parse(OpAsmParser &parser, OperationState *result) {
ParseResult OpState::parse(OpAsmParser &parser, OperationState &result) {
return parser.emitError(parser.getNameLoc(), "has no custom assembly form");
}
@ -943,21 +943,21 @@ LogicalResult OpTrait::impl::verifyResultsAreIntegerLike(Operation *op) {
// These functions are out-of-line implementations of the methods in BinaryOp,
// which avoids them being template instantiated/duplicated.
void impl::buildBinaryOp(Builder *builder, OperationState *result, Value *lhs,
void impl::buildBinaryOp(Builder *builder, OperationState &result, Value *lhs,
Value *rhs) {
assert(lhs->getType() == rhs->getType());
result->addOperands({lhs, rhs});
result->types.push_back(lhs->getType());
result.addOperands({lhs, rhs});
result.types.push_back(lhs->getType());
}
ParseResult impl::parseBinaryOp(OpAsmParser &parser, OperationState *result) {
ParseResult impl::parseBinaryOp(OpAsmParser &parser, OperationState &result) {
SmallVector<OpAsmParser::OperandType, 2> ops;
Type type;
return failure(parser.parseOperandList(ops, 2) ||
parser.parseOptionalAttributeDict(result->attributes) ||
parser.parseOptionalAttributeDict(result.attributes) ||
parser.parseColonType(type) ||
parser.resolveOperands(ops, type, result->operands) ||
parser.addTypeToList(type, result->types));
parser.resolveOperands(ops, type, result.operands) ||
parser.addTypeToList(type, result.types));
}
void impl::printBinaryOp(Operation *op, OpAsmPrinter *p) {
@ -984,21 +984,21 @@ void impl::printBinaryOp(Operation *op, OpAsmPrinter *p) {
// CastOp implementation
//===----------------------------------------------------------------------===//
void impl::buildCastOp(Builder *builder, OperationState *result, Value *source,
void impl::buildCastOp(Builder *builder, OperationState &result, Value *source,
Type destType) {
result->addOperands(source);
result->addTypes(destType);
result.addOperands(source);
result.addTypes(destType);
}
ParseResult impl::parseCastOp(OpAsmParser &parser, OperationState *result) {
ParseResult impl::parseCastOp(OpAsmParser &parser, OperationState &result) {
OpAsmParser::OperandType srcInfo;
Type srcType, dstType;
return failure(parser.parseOperand(srcInfo) ||
parser.parseOptionalAttributeDict(result->attributes) ||
parser.parseOptionalAttributeDict(result.attributes) ||
parser.parseColonType(srcType) ||
parser.resolveOperand(srcInfo, srcType, result->operands) ||
parser.resolveOperand(srcInfo, srcType, result.operands) ||
parser.parseKeywordType("to", dstType) ||
parser.addTypeToList(dstType, result->types));
parser.addTypeToList(dstType, result.types));
}
void impl::printCastOp(Operation *op, OpAsmPrinter *p) {

View File

@ -3276,7 +3276,7 @@ public:
/// Parse an instance of the operation described by 'opDefinition' into the
/// provided operation state.
ParseResult parseOperation(OperationState *opState) {
ParseResult parseOperation(OperationState &opState) {
if (opDefinition->parseAssembly(*this, opState))
return failure();
return success();
@ -3782,7 +3782,7 @@ Operation *OperationParser::parseCustomOperation() {
OperationState opState(srcLocation, opDefinition->name);
CleanupOpStateRegions guard{opState};
CustomOpAsmParser opAsmParser(opLoc, opDefinition, *this);
if (opAsmParser.parseOperation(&opState))
if (opAsmParser.parseOperation(opState))
return nullptr;
// If it emitted an error, we failed.

View File

@ -100,17 +100,17 @@ TestDialect::TestDialect(MLIRContext *context)
//===----------------------------------------------------------------------===//
static ParseResult parseIsolatedRegionOp(OpAsmParser &parser,
OperationState *result) {
OperationState &result) {
OpAsmParser::OperandType argInfo;
Type argType = parser.getBuilder().getIndexType();
// Parse the input operand.
if (parser.parseOperand(argInfo) ||
parser.resolveOperand(argInfo, argType, result->operands))
parser.resolveOperand(argInfo, argType, result.operands))
return failure();
// Parse the body region, and reuse the operand info as the argument info.
Region *body = result->addRegion();
Region *body = result.addRegion();
return parser.parseRegion(*body, argInfo, argType,
/*enableNameShadowing=*/true);
}
@ -127,11 +127,11 @@ static void print(OpAsmPrinter *p, IsolatedRegionOp op) {
//===----------------------------------------------------------------------===//
static ParseResult parseWrappedKeywordOp(OpAsmParser &parser,
OperationState *result) {
OperationState &result) {
StringRef keyword;
if (parser.parseKeyword(&keyword))
return failure();
result->addAttribute("keyword", parser.getBuilder().getStringAttr(keyword));
result.addAttribute("keyword", parser.getBuilder().getStringAttr(keyword));
return success();
}
@ -143,12 +143,12 @@ static void print(OpAsmPrinter *p, WrappedKeywordOp op) {
// Test WrapRegionOp - wrapping op exercising `parseGenericOperation()`.
static ParseResult parseWrappingRegionOp(OpAsmParser &parser,
OperationState *result) {
OperationState &result) {
if (parser.parseKeyword("wraps"))
return failure();
// Parse the wrapped op in a region
Region &body = *result->addRegion();
Region &body = *result.addRegion();
body.push_back(new Block);
Block &block = body.back();
Operation *wrapped_op = parser.parseGenericOperation(&block, block.begin());
@ -160,12 +160,12 @@ static ParseResult parseWrappingRegionOp(OpAsmParser &parser,
SmallVector<Value *, 8> return_operands(wrapped_op->getResults());
OpBuilder builder(parser.getBuilder().getContext());
builder.setInsertionPointToEnd(&block);
builder.create<TestReturnOp>(result->location, return_operands);
builder.create<TestReturnOp>(result.location, return_operands);
// Get the results type for the wrapping op from the terminator operands.
Operation &return_op = body.back().back();
result->types.append(return_op.operand_type_begin(),
return_op.operand_type_end());
result.types.append(return_op.operand_type_begin(),
return_op.operand_type_end());
return success();
}
@ -177,14 +177,14 @@ static void print(OpAsmPrinter *p, WrappingRegionOp op) {
//===----------------------------------------------------------------------===//
// Test PolyForOp - parse list of region arguments.
//===----------------------------------------------------------------------===//
static ParseResult parsePolyForOp(OpAsmParser &parser, OperationState *result) {
static ParseResult parsePolyForOp(OpAsmParser &parser, OperationState &result) {
SmallVector<OpAsmParser::OperandType, 4> ivsInfo;
// Parse list of region arguments without a delimiter.
if (parser.parseRegionArgumentList(ivsInfo))
return failure();
// Parse the body region.
Region *body = result->addRegion();
Region *body = result.addRegion();
auto &builder = parser.getBuilder();
SmallVector<Type, 4> argTypes(ivsInfo.size(), builder.getIndexType());
return parser.parseRegion(*body, ivsInfo, argTypes);

View File

@ -123,9 +123,9 @@ def TypeStringAttrWithTypeOp : TEST_Op<"string_attr_with_type"> {
let parser = [{
Attribute attr;
Type stringType = OpaqueType::get(Identifier::get("foo",
result->getContext()), "string",
result->getContext());
return parser.parseAttribute(attr, stringType, "attr", result->attributes);
result.getContext()), "string",
result.getContext());
return parser.parseAttribute(attr, stringType, "attr", result.attributes);
}];
}
@ -430,10 +430,10 @@ def OpSymbolBindingB : TEST_Op<"symbol_binding_b", []> {
let builders = [
OpBuilder<
"Builder *builder, OperationState *state, Value *operand",
"Builder *builder, OperationState &state, Value *operand",
[{
state->types.assign({builder->getIntegerType(32)});
state->addOperands({operand});
state.types.assign({builder->getIntegerType(32)});
state.addOperands({operand});
}]>
];
}
@ -534,12 +534,12 @@ def TwoResultOp : TEST_Op<"two_result"> {
let builders = [
OpBuilder<
"Builder *builder, OperationState *state, IntegerAttr kind",
"Builder *builder, OperationState &state, IntegerAttr kind",
[{
auto i32 = builder->getIntegerType(32);
auto f32 = builder->getF32Type();
state->types.assign({i32, f32});
state->addAttribute("kind", kind);
state.types.assign({i32, f32});
state.addAttribute("kind", kind);
}]>
];
}
@ -690,14 +690,14 @@ def MixedVResultOp3 : TEST_Op<"mixed_variadic_out3",
// result type. So need to provide a builder not requiring result types.
let builders = [
OpBuilder<
"Builder *builder, OperationState *state, IntegerAttr count",
"Builder *builder, OperationState &state, IntegerAttr count",
[{
auto i32Type = builder->getIntegerType(32);
state->addTypes(i32Type); // $ouput1
state.addTypes(i32Type); // $ouput1
SmallVector<Type, 4> types(count.getInt(), i32Type);
state->addTypes(types); // $ouput2
state->addTypes(types); // $ouput3
state->addAttribute("count", count);
state.addTypes(types); // $ouput2
state.addTypes(types); // $ouput3
state.addAttribute("count", count);
}]>
];
}

View File

@ -49,15 +49,15 @@ def AOp : NS_Op<"a_op", []> {
// ---
// CHECK: void AOp::build(
// CHECK: tblgen_state->addAttribute("aAttr", aAttr);
// CHECK: tblgen_state->addAttribute("bAttr", bAttr);
// CHECK: tblgen_state.addAttribute("aAttr", aAttr);
// CHECK: tblgen_state.addAttribute("bAttr", bAttr);
// CHECK: if (cAttr) {
// CHECK-NEXT: tblgen_state->addAttribute("cAttr", cAttr);
// CHECK-NEXT: tblgen_state.addAttribute("cAttr", cAttr);
// CHECK: void AOp::build(
// CHECK-SAME: ArrayRef<NamedAttribute> attributes
// CHECK: for (const auto& pair : attributes)
// CHECK-NEXT: tblgen_state->addAttribute(pair.first, pair.second);
// CHECK-NEXT: tblgen_state.addAttribute(pair.first, pair.second);
// Test verify method
// ---
@ -158,7 +158,7 @@ def MixOperandsAndAttrs : NS_Op<"mix_operands_and_attrs", []> {
// CHECK-LABEL: MixOperandsAndAttrs definitions
// CHECK-DAG: Value *MixOperandsAndAttrs::operand()
// CHECK-DAG: Value *MixOperandsAndAttrs::otherArg()
// CHECK-DAG: void MixOperandsAndAttrs::build(Builder *, OperationState *tblgen_state, FloatAttr attr, Value *operand, FloatAttr otherAttr, Value *otherArg)
// CHECK-DAG: void MixOperandsAndAttrs::build(Builder *, OperationState &tblgen_state, FloatAttr attr, Value *operand, FloatAttr otherAttr, Value *otherArg)
// CHECK-DAG: APFloat MixOperandsAndAttrs::attr()
// CHECK-DAG: APFloat MixOperandsAndAttrs::otherAttr()
@ -173,4 +173,4 @@ def UnitAttrOp : NS_Op<"unit_attr_op", []> {
// CHECK: bool UnitAttrOp::attr() {
// CHECK: return {{.*}} != nullptr
// CHECK: build(Builder *, OperationState *tblgen_state, /*optional*/UnitAttr attr)
// CHECK: build(Builder *, OperationState &tblgen_state, /*optional*/UnitAttr attr)

View File

@ -66,9 +66,9 @@ def NS_AOp : NS_Op<"a_op", [NoSideEffect]> {
// CHECK: APInt attr1();
// CHECK: Optional< APFloat > attr2();
// CHECK: static void build(Value *val);
// CHECK: static void build(Builder *, OperationState *tblgen_state, Type r, ArrayRef<Type> s, Value *a, ArrayRef<Value *> b, IntegerAttr attr1, /*optional*/FloatAttr attr2);
// CHECK: static void build(Builder *, OperationState *tblgen_state, ArrayRef<Type> resultTypes, ArrayRef<Value *> operands, ArrayRef<NamedAttribute> attributes);
// CHECK: static ParseResult parse(OpAsmParser &parser, OperationState *result);
// CHECK: static void build(Builder *, OperationState &tblgen_state, Type r, ArrayRef<Type> s, Value *a, ArrayRef<Value *> b, IntegerAttr attr1, /*optional*/FloatAttr attr2);
// CHECK: static void build(Builder *, OperationState &tblgen_state, ArrayRef<Type> resultTypes, ArrayRef<Value *> operands, ArrayRef<NamedAttribute> attributes);
// CHECK: static ParseResult parse(OpAsmParser &parser, OperationState &result);
// CHECK: void print(OpAsmPrinter *p);
// CHECK: LogicalResult verify();
// CHECK: static void getCanonicalizationPatterns(OwningRewritePatternList &results, MLIRContext *context);

View File

@ -19,12 +19,12 @@ def OpA : NS_Op<"one_normal_operand_op", []> {
// CHECK: void OpA::build
// CHECK-SAME: Value *input
// CHECK: tblgen_state->addOperands(input);
// CHECK: tblgen_state.addOperands(input);
// CHECK: void OpA::build
// CHECK-SAME: ArrayRef<Value *> operands
// CHECK: assert(operands.size() == 1u && "mismatched number of parameters");
// CHECK: tblgen_state->addOperands(operands);
// CHECK: tblgen_state.addOperands(operands);
def OpB : NS_Op<"one_variadic_operand_op", []> {
let arguments = (ins Variadic<I32>:$input);
@ -33,7 +33,7 @@ def OpB : NS_Op<"one_variadic_operand_op", []> {
// CHECK-LABEL: OpB::build
// CHECK-SAME: ArrayRef<Value *> input
// CHECK-NOT: assert
// CHECK: tblgen_state->addOperands(input);
// CHECK: tblgen_state.addOperands(input);
def OpD : NS_Op<"mix_variadic_and_normal_inputs_op", [SameVariadicOperandSize]> {
let arguments = (ins Variadic<AnyTensor>:$input1, AnyTensor:$input2, Variadic<AnyTensor>:$input3);
@ -55,6 +55,6 @@ def OpD : NS_Op<"mix_variadic_and_normal_inputs_op", [SameVariadicOperandSize]>
// CHECK-NEXT: return *getODSOperands(1).begin();
// CHECK-LABEL: OpD::build
// CHECK-NEXT: tblgen_state->addOperands(input1);
// CHECK-NEXT: tblgen_state->addOperands(input2);
// CHECK-NEXT: tblgen_state->addOperands(input3);
// CHECK-NEXT: tblgen_state.addOperands(input1);
// CHECK-NEXT: tblgen_state.addOperands(input2);
// CHECK-NEXT: tblgen_state.addOperands(input3);

View File

@ -15,7 +15,7 @@ def OpA : NS_Op<"one_normal_result_op", []> {
// CHECK-LABEL: void OpA::build
// CHECK: ArrayRef<Type> resultTypes, ArrayRef<Value *> operands
// CHECK: assert(resultTypes.size() == 1u && "mismatched number of return types");
// CHECK-NEXT: tblgen_state->addTypes(resultTypes);
// CHECK-NEXT: tblgen_state.addTypes(resultTypes);
def OpB : NS_Op<"same_input_output_type_op", [SameOperandsAndResultType]> {
let arguments = (ins I32:$x);
@ -23,20 +23,20 @@ def OpB : NS_Op<"same_input_output_type_op", [SameOperandsAndResultType]> {
}
// CHECK-LABEL: OpB definitions
// CHECK: void OpB::build(Builder *, OperationState *tblgen_state, Type y, Value *x)
// CHECK: tblgen_state->addTypes(y);
// CHECK: void OpB::build(Builder *, OperationState *tblgen_state, Value *x)
// CHECK: tblgen_state->addTypes({x->getType()});
// CHECK: void OpB::build(Builder *, OperationState &tblgen_state, Type y, Value *x)
// CHECK: tblgen_state.addTypes(y);
// CHECK: void OpB::build(Builder *, OperationState &tblgen_state, Value *x)
// CHECK: tblgen_state.addTypes({x->getType()});
def OpC : NS_Op<"three_normal_result_op", []> {
let results = (outs I32:$x, /*unnamed*/I32, I32:$z);
}
// CHECK-LABEL: OpC definitions
// CHECK: void OpC::build(Builder *, OperationState *tblgen_state, Type x, Type resultType1, Type z)
// CHECK-NEXT: tblgen_state->addTypes(x)
// CHECK-NEXT: tblgen_state->addTypes(resultType1)
// CHECK-NEXT: tblgen_state->addTypes(z)
// CHECK: void OpC::build(Builder *, OperationState &tblgen_state, Type x, Type resultType1, Type z)
// CHECK-NEXT: tblgen_state.addTypes(x)
// CHECK-NEXT: tblgen_state.addTypes(resultType1)
// CHECK-NEXT: tblgen_state.addTypes(z)
def IntegerTypeAttr : TypeAttrBase<"IntegerType", "Integer type attribute">;
def OpD : NS_Op<"type_attr_as_result_type", [FirstAttrDerivedResultType]> {
@ -45,8 +45,8 @@ def OpD : NS_Op<"type_attr_as_result_type", [FirstAttrDerivedResultType]> {
}
// CHECK-LABEL: OpD definitions
// CHECK: void OpD::build(Builder *, OperationState *tblgen_state, Value *x, TypeAttr attr, FloatAttr f32)
// CHECK: tblgen_state->addTypes({attr.getValue()});
// CHECK: void OpD::build(Builder *, OperationState &tblgen_state, Value *x, TypeAttr attr, FloatAttr f32)
// CHECK: tblgen_state.addTypes({attr.getValue()});
def OpE : NS_Op<"value_attr_as_result_type", [FirstAttrDerivedResultType]> {
let arguments = (ins I32:$x, F32Attr:$attr);
@ -54,8 +54,8 @@ def OpE : NS_Op<"value_attr_as_result_type", [FirstAttrDerivedResultType]> {
}
// CHECK-LABEL: OpE definitions
// CHECK: void OpE::build(Builder *, OperationState *tblgen_state, Value *x, FloatAttr attr)
// CHECK: tblgen_state->addTypes({attr.getType()});
// CHECK: void OpE::build(Builder *, OperationState &tblgen_state, Value *x, FloatAttr attr)
// CHECK: tblgen_state.addTypes({attr.getType()});
def OpF : NS_Op<"one_variadic_result_op", []> {
let results = (outs Variadic<I32>:$x);
@ -64,7 +64,7 @@ def OpF : NS_Op<"one_variadic_result_op", []> {
// CHECK-LABEL: void OpF::build
// CHECK-SAME: ArrayRef<Type> x
// CHECK-NOT: assert
// CHECK: tblgen_state->addTypes(x);
// CHECK: tblgen_state.addTypes(x);
def OpG : NS_Op<"one_normal_and_one_variadic_result_op", []> {
@ -73,14 +73,14 @@ def OpG : NS_Op<"one_normal_and_one_variadic_result_op", []> {
// CHECK-LABEL: OpG definitions
// CHECK: void OpG::build(Builder *, OperationState *tblgen_state, Type x, ArrayRef<Type> y)
// CHECK-NEXT: tblgen_state->addTypes(x);
// CHECK-NEXT: tblgen_state->addTypes(y);
// CHECK: void OpG::build(Builder *, OperationState &tblgen_state, Type x, ArrayRef<Type> y)
// CHECK-NEXT: tblgen_state.addTypes(x);
// CHECK-NEXT: tblgen_state.addTypes(y);
// CHECK: void OpG::build
// CHECK: ArrayRef<Type> resultTypes
// CHECK: assert(resultTypes.size() >= 1u && "mismatched number of return types");
// CHECK-NEXT: tblgen_state->addTypes(resultTypes);
// CHECK-NEXT: tblgen_state.addTypes(resultTypes);
def OpI : NS_Op<"mix_variadic_and_normal_results_op", [SameVariadicResultSize]> {
let results = (outs Variadic<AnyTensor>:$output1, AnyTensor:$output2, Variadic<AnyTensor>:$output3);
@ -93,9 +93,9 @@ def OpI : NS_Op<"mix_variadic_and_normal_results_op", [SameVariadicResultSize]>
// CHECK-NEXT: return *getODSResults(1).begin();
// CHECK-LABEL: OpI::build
// CHECK-NEXT: tblgen_state->addTypes(output1);
// CHECK-NEXT: tblgen_state->addTypes(output2);
// CHECK-NEXT: tblgen_state->addTypes(output3);
// CHECK-NEXT: tblgen_state.addTypes(output1);
// CHECK-NEXT: tblgen_state.addTypes(output2);
// CHECK-NEXT: tblgen_state.addTypes(output3);
// Test that if the only operand is variadic, we acess the first value in the
// pack to set result type
@ -105,5 +105,5 @@ def OpK : NS_Op<"only_input_is_variadic_with_same_value_type_op", [SameOperandsA
let results = (outs AnyTensor:$result);
}
// CHECK-LABEL: OpK::build(Builder *, OperationState *tblgen_state, ArrayRef<Value *> input)
// CHECK: tblgen_state->addTypes({input.front()->getType()});
// CHECK-LABEL: OpK::build(Builder *, OperationState &tblgen_state, ArrayRef<Value *> input)
// CHECK: tblgen_state.addTypes({input.front()->getType()});

View File

@ -778,7 +778,7 @@ void OpEmitter::genSeparateParamBuilder() {
// Push all result types to the operation state
for (int i = 0, e = op.getNumResults(); i < e; ++i) {
m.body() << " " << builderOpState << "->addTypes(" << resultNames[i]
m.body() << " " << builderOpState << ".addTypes(" << resultNames[i]
<< ");\n";
}
}
@ -805,7 +805,7 @@ void OpEmitter::genCollectiveTypeParamBuilder() {
genCodeForAddingArgAndRegionForBuilder(m.body());
// Push all result types to the operation state
m.body() << formatv(" {0}->addTypes(resultTypes);\n", builderOpState);
m.body() << formatv(" {0}.addTypes(resultTypes);\n", builderOpState);
}
void OpEmitter::genUseOperandAsResultTypeBuilder() {
@ -824,7 +824,7 @@ void OpEmitter::genUseOperandAsResultTypeBuilder() {
const char *index = op.getOperand(0).isVariadic() ? ".front()" : "";
std::string resultType =
formatv("{0}{1}->getType()", getArgumentName(op, 0), index).str();
m.body() << " " << builderOpState << "->addTypes({" << resultType;
m.body() << " " << builderOpState << ".addTypes({" << resultType;
for (int i = 1; i != numResults; ++i)
m.body() << ", " << resultType;
m.body() << "});\n\n";
@ -850,7 +850,7 @@ void OpEmitter::genUseAttrAsResultTypeBuilder() {
} else {
resultType = formatv("{0}.getType()", namedAttr.name);
}
m.body() << " " << builderOpState << "->addTypes({" << resultType;
m.body() << " " << builderOpState << ".addTypes({" << resultType;
for (int i = 1; i != numResults; ++i)
m.body() << ", " << resultType;
m.body() << "});\n\n";
@ -919,7 +919,7 @@ void OpEmitter::genCollectiveParamBuilder() {
int numNonVariadicOperands = numOperands - numVariadicOperands;
// Signature
std::string params =
std::string("Builder *, OperationState *") + builderOpState +
std::string("Builder *, OperationState &") + builderOpState +
", ArrayRef<Type> resultTypes, ArrayRef<Value *> operands, "
"ArrayRef<NamedAttribute> attributes";
auto &m = opClass.newMethod("void", "build", params, OpMethod::MP_Static);
@ -930,7 +930,7 @@ void OpEmitter::genCollectiveParamBuilder() {
body << " assert(resultTypes.size()"
<< (numVariadicResults != 0 ? " >= " : " == ") << numNonVariadicResults
<< "u && \"mismatched number of return types\");\n";
body << " " << builderOpState << "->addTypes(resultTypes);\n";
body << " " << builderOpState << ".addTypes(resultTypes);\n";
// Operands
if (numVariadicOperands == 0 || numNonVariadicOperands != 0)
@ -938,17 +938,17 @@ void OpEmitter::genCollectiveParamBuilder() {
<< (numVariadicOperands != 0 ? " >= " : " == ")
<< numNonVariadicOperands
<< "u && \"mismatched number of parameters\");\n";
body << " " << builderOpState << "->addOperands(operands);\n\n";
body << " " << builderOpState << ".addOperands(operands);\n\n";
// Attributes
body << " for (const auto& pair : attributes)\n"
<< " " << builderOpState
<< "->addAttribute(pair.first, pair.second);\n";
<< ".addAttribute(pair.first, pair.second);\n";
// Create the correct number of regions
if (int numRegions = op.getNumRegions()) {
for (int i = 0; i < numRegions; ++i)
m.body() << " (void)" << builderOpState << "->addRegion();\n";
m.body() << " (void)" << builderOpState << ".addRegion();\n";
}
}
@ -959,7 +959,7 @@ void OpEmitter::buildParamList(std::string &paramList,
auto numResults = op.getNumResults();
resultTypeNames.reserve(numResults);
paramList = "Builder *, OperationState *";
paramList = "Builder *, OperationState &";
paramList.append(builderOpState);
switch (kind) {
@ -1018,7 +1018,7 @@ void OpEmitter::buildParamList(std::string &paramList,
void OpEmitter::genCodeForAddingArgAndRegionForBuilder(OpMethodBody &body) {
// Push all operands to the result
for (int i = 0, e = op.getNumOperands(); i < e; ++i) {
body << " " << builderOpState << "->addOperands(" << getArgumentName(op, i)
body << " " << builderOpState << ".addOperands(" << getArgumentName(op, i)
<< ");\n";
}
@ -1029,7 +1029,7 @@ void OpEmitter::genCodeForAddingArgAndRegionForBuilder(OpMethodBody &body) {
if (emitNotNullCheck) {
body << formatv(" if ({0}) ", namedAttr.name) << "{\n";
}
body << formatv(" {0}->addAttribute(\"{1}\", {1});\n", builderOpState,
body << formatv(" {0}.addAttribute(\"{1}\", {1});\n", builderOpState,
namedAttr.name);
if (emitNotNullCheck) {
body << " }\n";
@ -1040,7 +1040,7 @@ void OpEmitter::genCodeForAddingArgAndRegionForBuilder(OpMethodBody &body) {
// Create the correct number of regions
if (int numRegions = op.getNumRegions()) {
for (int i = 0; i < numRegions; ++i)
body << " (void)" << builderOpState << "->addRegion();\n";
body << " (void)" << builderOpState << ".addRegion();\n";
}
}
@ -1076,7 +1076,7 @@ void OpEmitter::genParser() {
return;
auto &method = opClass.newMethod(
"ParseResult", "parse", "OpAsmParser &parser, OperationState *result",
"ParseResult", "parse", "OpAsmParser &parser, OperationState &result",
OpMethod::MP_Static);
FmtContext fctx;
fctx.addSubst("cppClass", opClass.getClassName());

View File

@ -55,7 +55,7 @@ protected:
state.addAttribute("memory_model",
builder.getI32IntegerAttr(
static_cast<uint32_t>(spirv::MemoryModel::GLSL450)));
spirv::ModuleOp::build(&builder, &state);
spirv::ModuleOp::build(&builder, state);
module = cast<spirv::ModuleOp>(Operation::create(state));
}