SmallVector<OpAsmParser::OperandType, 8> indexingsInfo;
SmallVector<Type, 8> types;
if (parser->parseOperand(memRefInfo) ||
- parser->parseOperandList(indexingsInfo, -1,
- OpAsmParser::Delimiter::Square) ||
+ parser->parseOperandList(indexingsInfo, OpAsmParser::Delimiter::Square) ||
parser->parseOptionalAttributeDict(result->attributes) ||
parser->parseColonTypeList(types))
return failure();
/// Get the location of the next token and store it into the argument. This
/// always succeeds.
- virtual ParseResult getCurrentLocation(llvm::SMLoc *loc) = 0;
+ virtual llvm::SMLoc getCurrentLocation() = 0;
+ ParseResult getCurrentLocation(llvm::SMLoc *loc) {
+ *loc = getCurrentLocation();
+ return success();
+ }
/// This parses... a comma!
virtual ParseResult parseComma() = 0;
/// Parse a type of a specific kind, e.g. a FunctionType.
template <typename TypeType> ParseResult parseColonType(TypeType &result) {
- llvm::SMLoc loc;
- getCurrentLocation(&loc);
+ llvm::SMLoc loc = getCurrentLocation();
// Parse any kind of type.
Type type;
template <typename AttrType>
ParseResult parseAttribute(AttrType &result, Type type, StringRef attrName,
SmallVectorImpl<NamedAttribute> &attrs) {
- llvm::SMLoc loc;
- getCurrentLocation(&loc);
+ llvm::SMLoc loc = getCurrentLocation();
// Parse any kind of attribute.
Attribute attr;
/// These are the supported delimiters around operand lists, used by
/// parseOperandList.
- enum Delimiter {
+ enum class Delimiter {
/// Zero or more operands with no delimiters.
None,
/// Parens surrounding zero or more operands.
parseOperandList(SmallVectorImpl<OperandType> &result,
int requiredOperandCount = -1,
Delimiter delimiter = Delimiter::None) = 0;
+ ParseResult parseOperandList(SmallVectorImpl<OperandType> &result,
+ Delimiter delimiter) {
+ return parseOperandList(result, /*requiredOperandCount=*/-1, delimiter);
+ }
/// Parse zero or more trailing SSA comma-separated trailing operand
/// references with a specified surrounding delimiter, and an optional
parseTrailingOperandList(SmallVectorImpl<OperandType> &result,
int requiredOperandCount = -1,
Delimiter delimiter = Delimiter::None) = 0;
+ ParseResult parseTrailingOperandList(SmallVectorImpl<OperandType> &result,
+ Delimiter delimiter) {
+ return parseTrailingOperandList(result, /*requiredOperandCount=*/-1,
+ delimiter);
+ }
/// Parses a region. Any parsed blocks are appended to "region" and must be
/// moved to the op regions after the op is created. The first block of the
}
// Get the attribute location.
- llvm::SMLoc attrLoc;
- p->getCurrentLocation(&attrLoc);
+ llvm::SMLoc attrLoc = p->getCurrentLocation();
Attribute boundAttr;
if (p->parseAttribute(boundAttr, builder.getIndexType(), boundAttrName,
getStepAttrName(),
builder.getIntegerAttr(builder.getIndexType(), /*value=*/1));
} else {
- llvm::SMLoc stepLoc;
+ llvm::SMLoc stepLoc = parser->getCurrentLocation();
IntegerAttr stepAttr;
- if (parser->getCurrentLocation(&stepLoc) ||
- parser->parseAttribute(stepAttr, builder.getIndexType(),
+ if (parser->parseAttribute(stepAttr, builder.getIndexType(),
getStepAttrName().data(), result->attributes))
return failure();
// to resolve the operands passed to the kernel arguments.
SmallVector<Type, 4> dataTypes;
if (!parser->parseOptionalKeyword(getArgsKeyword().data())) {
- llvm::SMLoc argsLoc;
+ llvm::SMLoc argsLoc = parser->getCurrentLocation();
regionArgs.push_back({});
dataOperands.push_back({});
- if (parser->getCurrentLocation(&argsLoc) || parser->parseLParen() ||
+ if (parser->parseLParen() ||
parser->parseRegionArgument(regionArgs.back()) ||
parser->parseEqual() || parser->parseOperand(dataOperands.back()))
return failure();
// types, or just be a type list. It isn't ok to sometimes have SSA ID's and
// sometimes not.
auto parseArgument = [&]() -> ParseResult {
- llvm::SMLoc loc;
- parser->getCurrentLocation(&loc);
+ llvm::SMLoc loc = parser->getCurrentLocation();
// Parse argument name if present.
OpAsmParser::OperandType argument;
Type type;
llvm::SMLoc trailingTypeLoc;
if (parser->parseOperand(base) ||
- parser->parseOperandList(indices, /*requiredOperandCount=*/-1,
- OpAsmParser::Delimiter::Square) ||
+ parser->parseOperandList(indices, OpAsmParser::Delimiter::Square) ||
parser->parseOptionalAttributeDict(attrs) || parser->parseColon() ||
parser->getCurrentLocation(&trailingTypeLoc) || parser->parseType(type))
return failure();
if (parser->parseAttribute(funcAttr, "callee", attrs))
return failure();
- if (parser->parseOperandList(operands, /*requiredOperandCount=*/-1,
- OpAsmParser::Delimiter::Paren) ||
+ if (parser->parseOperandList(operands, OpAsmParser::Delimiter::Paren) ||
parser->parseOptionalAttributeDict(attrs) || parser->parseColon() ||
parser->getCurrentLocation(&trailingTypeLoc) || parser->parseType(type))
return failure();
auto affineIntTy = parser->getBuilder().getIndexType();
return failure(
parser->parseOperand(viewInfo) ||
- parser->parseOperandList(indexInfo, -1, OpAsmParser::Delimiter::Square) ||
+ parser->parseOperandList(indexInfo, OpAsmParser::Delimiter::Square) ||
parser->parseOptionalAttributeDict(result->attributes) ||
parser->parseColonType(type) ||
parser->resolveOperand(viewInfo, type, result->operands) ||
SmallVector<OpAsmParser::OperandType, 8> indexingsInfo;
SmallVector<Type, 8> types;
if (parser->parseOperand(baseInfo) ||
- parser->parseOperandList(indexingsInfo, -1,
- OpAsmParser::Delimiter::Square) ||
+ parser->parseOperandList(indexingsInfo, OpAsmParser::Delimiter::Square) ||
parser->parseOptionalAttributeDict(result->attributes) ||
parser->parseColonTypeList(types))
return failure();
return failure(
parser->parseOperand(storeValueInfo) || parser->parseComma() ||
parser->parseOperand(viewInfo) ||
- parser->parseOperandList(indexInfo, -1, OpAsmParser::Delimiter::Square) ||
+ parser->parseOperandList(indexInfo, OpAsmParser::Delimiter::Square) ||
parser->parseOptionalAttributeDict(result->attributes) ||
parser->parseColonType(viewType) ||
parser->resolveOperand(storeValueInfo, viewType.getElementType(),
SmallVector<OpAsmParser::OperandType, 8> indexingsInfo;
Type type;
if (parser->parseOperand(bufferInfo) ||
- parser->parseOperandList(indexingsInfo, -1,
- OpAsmParser::Delimiter::Square) ||
+ parser->parseOperandList(indexingsInfo, OpAsmParser::Delimiter::Square) ||
parser->parseOptionalAttributeDict(result->attributes) ||
parser->parseColonType(type))
return failure();
OperationState *result) {
SmallVector<OpAsmParser::OperandType, 3> ops;
SmallVector<Type, 3> types;
- return failure(
- parser->parseOperandList(ops, -1, 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));
}
namespace mlir {
// High level parsing methods.
//===--------------------------------------------------------------------===//
- ParseResult getCurrentLocation(llvm::SMLoc *loc) override {
- *loc = parser.getToken().getLoc();
- return success();
+ llvm::SMLoc getCurrentLocation() override {
+ return parser.getToken().getLoc();
}
ParseResult parseComma() override {
SmallVector<Value *, 4> &operands,
unsigned &numDims) {
SmallVector<OpAsmParser::OperandType, 8> opInfos;
- if (parser->parseOperandList(opInfos, -1, OpAsmParser::Delimiter::Paren))
+ if (parser->parseOperandList(opInfos, OpAsmParser::Delimiter::Paren))
return failure();
// Store number of dimensions for validation by caller.
numDims = opInfos.size();
// Parse the optional symbol operands.
auto affineIntTy = parser->getBuilder().getIndexType();
- if (parser->parseOperandList(opInfos, -1,
+ if (parser->parseOperandList(opInfos,
OpAsmParser::Delimiter::OptionalSquare) ||
parser->resolveOperands(opInfos, affineIntTy, operands))
return failure();
SmallVector<OpAsmParser::OperandType, 4> operands;
auto calleeLoc = parser->getNameLoc();
if (parser->parseAttribute(calleeAttr, "callee", result->attributes) ||
- parser->parseOperandList(operands, /*requiredOperandCount=*/-1,
- OpAsmParser::Delimiter::Paren) ||
+ parser->parseOperandList(operands, OpAsmParser::Delimiter::Paren) ||
parser->parseOptionalAttributeDict(result->attributes) ||
parser->parseColonType(calleeType) ||
parser->addTypesToList(calleeType.getResults(), result->types) ||
return failure(
parser->parseOperand(callee) ||
parser->getCurrentLocation(&operandsLoc) ||
- parser->parseOperandList(operands, /*requiredOperandCount=*/-1,
- OpAsmParser::Delimiter::Paren) ||
+ parser->parseOperandList(operands, OpAsmParser::Delimiter::Paren) ||
parser->parseOptionalAttributeDict(result->attributes) ||
parser->parseColonType(calleeType) ||
parser->resolveOperand(callee, calleeType, result->operands) ||
// *) destination memref followed by its indices (in square brackets).
// *) dma size in KiB.
if (parser->parseOperand(srcMemRefInfo) ||
- parser->parseOperandList(srcIndexInfos, -1,
- OpAsmParser::Delimiter::Square) ||
+ parser->parseOperandList(srcIndexInfos, OpAsmParser::Delimiter::Square) ||
parser->parseComma() || parser->parseOperand(dstMemRefInfo) ||
- parser->parseOperandList(dstIndexInfos, -1,
- OpAsmParser::Delimiter::Square) ||
+ parser->parseOperandList(dstIndexInfos, OpAsmParser::Delimiter::Square) ||
parser->parseComma() || parser->parseOperand(numElementsInfo) ||
parser->parseComma() || parser->parseOperand(tagMemrefInfo) ||
- parser->parseOperandList(tagIndexInfos, -1,
- OpAsmParser::Delimiter::Square))
+ parser->parseOperandList(tagIndexInfos, OpAsmParser::Delimiter::Square))
return failure();
// Parse optional stride and elements per stride.
// Parse tag memref, its indices, and dma size.
if (parser->parseOperand(tagMemrefInfo) ||
- parser->parseOperandList(tagIndexInfos, -1,
- OpAsmParser::Delimiter::Square) ||
+ parser->parseOperandList(tagIndexInfos, OpAsmParser::Delimiter::Square) ||
parser->parseComma() || parser->parseOperand(numElementsInfo) ||
parser->parseColonType(type) ||
parser->resolveOperand(tagMemrefInfo, type, result->operands) ||
auto affineIntTy = parser->getBuilder().getIndexType();
return failure(
parser->parseOperand(aggregateInfo) ||
- parser->parseOperandList(indexInfo, -1, OpAsmParser::Delimiter::Square) ||
+ parser->parseOperandList(indexInfo, OpAsmParser::Delimiter::Square) ||
parser->parseOptionalAttributeDict(result->attributes) ||
parser->parseColonType(type) ||
parser->resolveOperand(aggregateInfo, type, result->operands) ||
auto affineIntTy = parser->getBuilder().getIndexType();
return failure(
parser->parseOperand(memrefInfo) ||
- parser->parseOperandList(indexInfo, -1, OpAsmParser::Delimiter::Square) ||
+ parser->parseOperandList(indexInfo, OpAsmParser::Delimiter::Square) ||
parser->parseOptionalAttributeDict(result->attributes) ||
parser->parseColonType(type) ||
parser->resolveOperand(memrefInfo, type, result->operands) ||
static ParseResult parseReturnOp(OpAsmParser *parser, OperationState *result) {
SmallVector<OpAsmParser::OperandType, 2> opInfo;
SmallVector<Type, 2> types;
- llvm::SMLoc loc;
- return failure(parser->getCurrentLocation(&loc) ||
- parser->parseOperandList(opInfo) ||
+ llvm::SMLoc loc = parser->getCurrentLocation();
+ return failure(parser->parseOperandList(opInfo) ||
(!opInfo.empty() && parser->parseColonTypeList(types)) ||
parser->resolveOperands(opInfo, types, loc, result->operands));
}
return failure(
parser->parseOperand(storeValueInfo) || parser->parseComma() ||
parser->parseOperand(memrefInfo) ||
- parser->parseOperandList(indexInfo, -1, OpAsmParser::Delimiter::Square) ||
+ parser->parseOperandList(indexInfo, OpAsmParser::Delimiter::Square) ||
parser->parseOptionalAttributeDict(result->attributes) ||
parser->parseColonType(memrefType) ||
parser->resolveOperand(storeValueInfo, memrefType.getElementType(),
// Parsing with support for optional paddingValue.
if (parser->parseOperand(memrefInfo) ||
- parser->parseOperandList(indexInfo, -1, OpAsmParser::Delimiter::Square) ||
- parser->parseTrailingOperandList(paddingInfo, -1,
+ parser->parseOperandList(indexInfo, OpAsmParser::Delimiter::Square) ||
+ parser->parseTrailingOperandList(paddingInfo,
OpAsmParser::Delimiter::Paren) ||
parser->parseOptionalAttributeDict(result->attributes) ||
parser->parseColonTypeList(types))
auto indexType = parser->getBuilder().getIndexType();
if (parser->parseOperand(storeValueInfo) || parser->parseComma() ||
parser->parseOperand(memrefInfo) ||
- parser->parseOperandList(indexInfo, -1, OpAsmParser::Delimiter::Square) ||
+ parser->parseOperandList(indexInfo, OpAsmParser::Delimiter::Square) ||
parser->parseOptionalAttributeDict(result->attributes) ||
parser->parseColonTypeList(types))
return failure();