From: Markus Böck Date: Mon, 21 Mar 2022 20:42:13 +0000 (+0100) Subject: [mlir] Rename `OpAsmParser::OperandType` to `OpAsmParser::UnresolvedOperand` X-Git-Tag: upstream/15.0.7~12845 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=e13d23bc6ccd3ae4fad5824282a09b48822c177f;p=platform%2Fupstream%2Fllvm.git [mlir] Rename `OpAsmParser::OperandType` to `OpAsmParser::UnresolvedOperand` I am not sure about the meaning of Type in the name (was it meant be interpreted as Kind?), and given the importance and meaning of Type in the context of MLIR, its probably better to rename it. Given the comment in the source code, the suggestion in the GitHub issue and the final discussions in the review, this patch renames the OperandType to UnresolvedOperand. Fixes https://github.com/llvm/llvm-project/issues/54446 Differential Revision: https://reviews.llvm.org/D122142 --- diff --git a/flang/include/flang/Optimizer/Dialect/FIROps.h b/flang/include/flang/Optimizer/Dialect/FIROps.h index 8858976..68202a1 100644 --- a/flang/include/flang/Optimizer/Dialect/FIROps.h +++ b/flang/include/flang/Optimizer/Dialect/FIROps.h @@ -33,7 +33,7 @@ mlir::ParseResult parseCmpcOp(mlir::OpAsmParser &parser, mlir::OperationState &result); mlir::ParseResult parseSelector(mlir::OpAsmParser &parser, mlir::OperationState &result, - mlir::OpAsmParser::OperandType &selector, + mlir::OpAsmParser::UnresolvedOperand &selector, mlir::Type &type); static constexpr llvm::StringRef getAdaptToByRefAttrName() { diff --git a/flang/lib/Optimizer/Dialect/FIROps.cpp b/flang/lib/Optimizer/Dialect/FIROps.cpp index 4d36ec4..159b0be 100644 --- a/flang/lib/Optimizer/Dialect/FIROps.cpp +++ b/flang/lib/Optimizer/Dialect/FIROps.cpp @@ -94,7 +94,7 @@ static mlir::ParseResult parseAllocatableOp(FN wrapResultType, return mlir::failure(); auto &builder = parser.getBuilder(); result.addAttribute("in_type", mlir::TypeAttr::get(intype)); - llvm::SmallVector operands; + llvm::SmallVector operands; llvm::SmallVector typeVec; bool hasOperands = false; std::int32_t typeparamsSize = 0; @@ -627,7 +627,7 @@ void fir::CallOp::print(mlir::OpAsmPrinter &p) { mlir::ParseResult fir::CallOp::parse(mlir::OpAsmParser &parser, mlir::OperationState &result) { - llvm::SmallVector operands; + llvm::SmallVector operands; if (parser.parseOperandList(operands)) return mlir::failure(); @@ -654,7 +654,8 @@ mlir::ParseResult fir::CallOp::parse(mlir::OpAsmParser &parser, return mlir::failure(); } else { auto funcArgs = - llvm::ArrayRef(operands).drop_front(); + llvm::ArrayRef(operands) + .drop_front(); if (parser.resolveOperand(operands[0], funcType, result.operands) || parser.resolveOperands(funcArgs, funcType.getInputs(), parser.getNameLoc(), result.operands)) @@ -707,7 +708,7 @@ static void printCmpOp(OpAsmPrinter &p, OPTY op) { template static mlir::ParseResult parseCmpOp(mlir::OpAsmParser &parser, mlir::OperationState &result) { - llvm::SmallVector ops; + llvm::SmallVector ops; mlir::NamedAttrList attrs; mlir::Attribute predicateNameAttr; mlir::Type type; @@ -895,13 +896,13 @@ void CoordinateOp::print(mlir::OpAsmPrinter &p) { mlir::ParseResult CoordinateOp::parse(mlir::OpAsmParser &parser, mlir::OperationState &result) { - mlir::OpAsmParser::OperandType memref; + mlir::OpAsmParser::UnresolvedOperand memref; if (parser.parseOperand(memref) || parser.parseComma()) return mlir::failure(); - llvm::SmallVector coorOperands; + llvm::SmallVector coorOperands; if (parser.parseOperandList(coorOperands)) return mlir::failure(); - llvm::SmallVector allOperands; + llvm::SmallVector allOperands; allOperands.push_back(memref); allOperands.append(coorOperands.begin(), coorOperands.end()); mlir::FunctionType funcTy; @@ -955,7 +956,7 @@ mlir::FunctionType fir::DispatchOp::getFunctionType() { mlir::ParseResult DispatchOp::parse(mlir::OpAsmParser &parser, mlir::OperationState &result) { mlir::FunctionType calleeType; - llvm::SmallVector operands; + llvm::SmallVector operands; auto calleeLoc = parser.getNameLoc(); llvm::StringRef calleeName; if (failed(parser.parseOptionalKeyword(&calleeName))) { @@ -1100,7 +1101,7 @@ mlir::ParseResult EmboxProcOp::parse(mlir::OpAsmParser &parser, if (parser.parseAttribute(procRef, "funcname", result.attributes)) return mlir::failure(); bool hasTuple = false; - mlir::OpAsmParser::OperandType tupleRef; + mlir::OpAsmParser::UnresolvedOperand tupleRef; if (!parser.parseOptionalComma()) { if (parser.parseOperand(tupleRef)) return mlir::failure(); @@ -1376,7 +1377,7 @@ mlir::ParseResult FieldIndexOp::parse(mlir::OpAsmParser &parser, result.addAttribute(fir::FieldIndexOp::typeAttrName(), mlir::TypeAttr::get(recty)); if (!parser.parseOptionalLParen()) { - llvm::SmallVector operands; + llvm::SmallVector operands; llvm::SmallVector types; auto loc = parser.getNameLoc(); if (parser.parseOperandList(operands, mlir::OpAsmParser::Delimiter::None) || @@ -1591,7 +1592,7 @@ void fir::IterWhileOp::build(mlir::OpBuilder &builder, mlir::ParseResult IterWhileOp::parse(mlir::OpAsmParser &parser, mlir::OperationState &result) { auto &builder = parser.getBuilder(); - mlir::OpAsmParser::OperandType inductionVariable, lb, ub, step; + mlir::OpAsmParser::UnresolvedOperand inductionVariable, lb, ub, step; if (parser.parseLParen() || parser.parseRegionArgument(inductionVariable) || parser.parseEqual()) return mlir::failure(); @@ -1608,7 +1609,7 @@ mlir::ParseResult IterWhileOp::parse(mlir::OpAsmParser &parser, parser.resolveOperand(step, indexType, result.operands)) return mlir::failure(); - mlir::OpAsmParser::OperandType iterateVar, iterateInput; + mlir::OpAsmParser::UnresolvedOperand iterateVar, iterateInput; if (parser.parseKeyword("and") || parser.parseLParen() || parser.parseRegionArgument(iterateVar) || parser.parseEqual() || parser.parseOperand(iterateInput) || parser.parseRParen() || @@ -1616,7 +1617,7 @@ mlir::ParseResult IterWhileOp::parse(mlir::OpAsmParser &parser, return mlir::failure(); // Parse the initial iteration arguments. - llvm::SmallVector regionArgs; + llvm::SmallVector regionArgs; auto prependCount = false; // Induction variable. @@ -1624,7 +1625,7 @@ mlir::ParseResult IterWhileOp::parse(mlir::OpAsmParser &parser, regionArgs.push_back(iterateVar); if (succeeded(parser.parseOptionalKeyword("iter_args"))) { - llvm::SmallVector operands; + llvm::SmallVector operands; llvm::SmallVector regionTypes; // Parse assignment list and results type list. if (parser.parseAssignmentList(regionArgs, operands) || @@ -1860,7 +1861,7 @@ mlir::ParseResult fir::LoadOp::getElementOf(mlir::Type &ele, mlir::Type ref) { mlir::ParseResult LoadOp::parse(mlir::OpAsmParser &parser, mlir::OperationState &result) { mlir::Type type; - mlir::OpAsmParser::OperandType oper; + mlir::OpAsmParser::UnresolvedOperand oper; if (parser.parseOperand(oper) || parser.parseOptionalAttrDict(result.attributes) || parser.parseColonType(type) || @@ -1915,7 +1916,7 @@ void fir::DoLoopOp::build(mlir::OpBuilder &builder, mlir::ParseResult DoLoopOp::parse(mlir::OpAsmParser &parser, mlir::OperationState &result) { auto &builder = parser.getBuilder(); - mlir::OpAsmParser::OperandType inductionVariable, lb, ub, step; + mlir::OpAsmParser::UnresolvedOperand inductionVariable, lb, ub, step; // Parse the induction variable followed by '='. if (parser.parseRegionArgument(inductionVariable) || parser.parseEqual()) return mlir::failure(); @@ -1934,7 +1935,7 @@ mlir::ParseResult DoLoopOp::parse(mlir::OpAsmParser &parser, result.addAttribute("unordered", builder.getUnitAttr()); // Parse the optional initial iteration arguments. - llvm::SmallVector regionArgs, operands; + llvm::SmallVector regionArgs, operands; llvm::SmallVector argTypes; auto prependCount = false; regionArgs.push_back(inductionVariable); @@ -2346,7 +2347,7 @@ static LogicalResult verifyIntegralSwitchTerminator(OpT op) { static mlir::ParseResult parseIntegralSwitchTerminator( mlir::OpAsmParser &parser, mlir::OperationState &result, llvm::StringRef casesAttr, llvm::StringRef operandSegmentAttr) { - mlir::OpAsmParser::OperandType selector; + mlir::OpAsmParser::UnresolvedOperand selector; mlir::Type type; if (parseSelector(parser, result, selector, type)) return mlir::failure(); @@ -2556,13 +2557,13 @@ fir::SelectCaseOp::getSuccessorOperands(mlir::ValueRange operands, // parser for fir.select_case Op mlir::ParseResult SelectCaseOp::parse(mlir::OpAsmParser &parser, mlir::OperationState &result) { - mlir::OpAsmParser::OperandType selector; + mlir::OpAsmParser::UnresolvedOperand selector; mlir::Type type; if (parseSelector(parser, result, selector, type)) return mlir::failure(); llvm::SmallVector attrs; - llvm::SmallVector opers; + llvm::SmallVector opers; llvm::SmallVector dests; llvm::SmallVector> destArgs; llvm::SmallVector argOffs; @@ -2579,8 +2580,8 @@ mlir::ParseResult SelectCaseOp::parse(mlir::OpAsmParser &parser, if (attr.dyn_cast_or_null()) { argOffs.push_back(0); } else if (attr.dyn_cast_or_null()) { - mlir::OpAsmParser::OperandType oper1; - mlir::OpAsmParser::OperandType oper2; + mlir::OpAsmParser::UnresolvedOperand oper1; + mlir::OpAsmParser::UnresolvedOperand oper2; if (parser.parseOperand(oper1) || parser.parseComma() || parser.parseOperand(oper2) || parser.parseComma()) return mlir::failure(); @@ -2589,7 +2590,7 @@ mlir::ParseResult SelectCaseOp::parse(mlir::OpAsmParser &parser, argOffs.push_back(2); offSize += 2; } else { - mlir::OpAsmParser::OperandType oper; + mlir::OpAsmParser::UnresolvedOperand oper; if (parser.parseOperand(oper) || parser.parseComma()) return mlir::failure(); opers.push_back(oper); @@ -2861,7 +2862,7 @@ fir::SelectTypeOp::getSuccessorOperands(llvm::ArrayRef operands, } ParseResult SelectTypeOp::parse(OpAsmParser &parser, OperationState &result) { - mlir::OpAsmParser::OperandType selector; + mlir::OpAsmParser::UnresolvedOperand selector; mlir::Type type; if (parseSelector(parser, result, selector, type)) return mlir::failure(); @@ -3075,8 +3076,8 @@ mlir::Type fir::StoreOp::elementType(mlir::Type refType) { mlir::ParseResult StoreOp::parse(mlir::OpAsmParser &parser, mlir::OperationState &result) { mlir::Type type; - mlir::OpAsmParser::OperandType oper; - mlir::OpAsmParser::OperandType store; + mlir::OpAsmParser::UnresolvedOperand oper; + mlir::OpAsmParser::UnresolvedOperand store; if (parser.parseOperand(oper) || parser.parseKeyword("to") || parser.parseOperand(store) || parser.parseOptionalAttrDict(result.attributes) || @@ -3274,7 +3275,7 @@ mlir::ParseResult IfOp::parse(OpAsmParser &parser, OperationState &result) { mlir::Region *elseRegion = result.addRegion(); auto &builder = parser.getBuilder(); - OpAsmParser::OperandType cond; + OpAsmParser::UnresolvedOperand cond; mlir::Type i1Type = builder.getIntegerType(1); if (parser.parseOperand(cond) || parser.resolveOperand(cond, i1Type, result.operands)) @@ -3363,10 +3364,10 @@ unsigned fir::getCaseArgumentOffset(llvm::ArrayRef cases, return o; } -mlir::ParseResult fir::parseSelector(mlir::OpAsmParser &parser, - mlir::OperationState &result, - mlir::OpAsmParser::OperandType &selector, - mlir::Type &type) { +mlir::ParseResult +fir::parseSelector(mlir::OpAsmParser &parser, mlir::OperationState &result, + mlir::OpAsmParser::UnresolvedOperand &selector, + mlir::Type &type) { if (parser.parseOperand(selector) || parser.parseColonType(type) || parser.resolveOperand(selector, type, result.operands) || parser.parseLSquare()) diff --git a/mlir/docs/OpDefinitions.md b/mlir/docs/OpDefinitions.md index f5b67e2..eab13fd 100644 --- a/mlir/docs/OpDefinitions.md +++ b/mlir/docs/OpDefinitions.md @@ -778,11 +778,11 @@ declarative parameter to `parse` method argument is detailed below: - Single: `(e.g. Attribute) &` - Optional: `(e.g. Attribute) &` * Operand Variables - - Single: `OpAsmParser::OperandType &` - - Optional: `Optional &` - - Variadic: `SmallVectorImpl &` + - Single: `OpAsmParser::UnresolvedOperand &` + - Optional: `Optional &` + - Variadic: `SmallVectorImpl &` - VariadicOfVariadic: - `SmallVectorImpl> &` + `SmallVectorImpl> &` * Ref Directives - A reference directive is passed to the parser using the same mapping as the input operand. For example, a single region would be passed as a diff --git a/mlir/docs/Tutorials/Toy/Ch-2.md b/mlir/docs/Tutorials/Toy/Ch-2.md index a47d420..99e6cfe 100644 --- a/mlir/docs/Tutorials/Toy/Ch-2.md +++ b/mlir/docs/Tutorials/Toy/Ch-2.md @@ -639,7 +639,7 @@ mlir::ParseResult PrintOp::parse(mlir::OpAsmParser &parser, mlir::OperationState &result) { // Parse the input operand, the attribute dictionary, and the type of the // input. - mlir::OpAsmParser::OperandType inputOperand; + mlir::OpAsmParser::UnresolvedOperand inputOperand; mlir::Type inputType; if (parser.parseOperand(inputOperand) || parser.parseOptionalAttrDict(result.attributes) || parser.parseColon() || diff --git a/mlir/examples/toy/Ch2/mlir/Dialect.cpp b/mlir/examples/toy/Ch2/mlir/Dialect.cpp index f6cf3fd..dbc1efb 100644 --- a/mlir/examples/toy/Ch2/mlir/Dialect.cpp +++ b/mlir/examples/toy/Ch2/mlir/Dialect.cpp @@ -44,7 +44,7 @@ void ToyDialect::initialize() { /// of 'printBinaryOp' below. static mlir::ParseResult parseBinaryOp(mlir::OpAsmParser &parser, mlir::OperationState &result) { - SmallVector operands; + SmallVector operands; SMLoc operandsLoc = parser.getCurrentLocation(); Type type; if (parser.parseOperandList(operands, /*requiredOperandCount=*/2) || diff --git a/mlir/examples/toy/Ch3/mlir/Dialect.cpp b/mlir/examples/toy/Ch3/mlir/Dialect.cpp index 4b8b978..50e2dfc 100644 --- a/mlir/examples/toy/Ch3/mlir/Dialect.cpp +++ b/mlir/examples/toy/Ch3/mlir/Dialect.cpp @@ -44,7 +44,7 @@ void ToyDialect::initialize() { /// of 'printBinaryOp' below. static mlir::ParseResult parseBinaryOp(mlir::OpAsmParser &parser, mlir::OperationState &result) { - SmallVector operands; + SmallVector operands; SMLoc operandsLoc = parser.getCurrentLocation(); Type type; if (parser.parseOperandList(operands, /*requiredOperandCount=*/2) || diff --git a/mlir/examples/toy/Ch4/mlir/Dialect.cpp b/mlir/examples/toy/Ch4/mlir/Dialect.cpp index 1bd6c9f..0a6195b 100644 --- a/mlir/examples/toy/Ch4/mlir/Dialect.cpp +++ b/mlir/examples/toy/Ch4/mlir/Dialect.cpp @@ -106,7 +106,7 @@ void ToyDialect::initialize() { /// of 'printBinaryOp' below. static mlir::ParseResult parseBinaryOp(mlir::OpAsmParser &parser, mlir::OperationState &result) { - SmallVector operands; + SmallVector operands; SMLoc operandsLoc = parser.getCurrentLocation(); Type type; if (parser.parseOperandList(operands, /*requiredOperandCount=*/2) || diff --git a/mlir/examples/toy/Ch5/mlir/Dialect.cpp b/mlir/examples/toy/Ch5/mlir/Dialect.cpp index ecff264..f236a1f 100644 --- a/mlir/examples/toy/Ch5/mlir/Dialect.cpp +++ b/mlir/examples/toy/Ch5/mlir/Dialect.cpp @@ -106,7 +106,7 @@ void ToyDialect::initialize() { /// of 'printBinaryOp' below. static mlir::ParseResult parseBinaryOp(mlir::OpAsmParser &parser, mlir::OperationState &result) { - SmallVector operands; + SmallVector operands; SMLoc operandsLoc = parser.getCurrentLocation(); Type type; if (parser.parseOperandList(operands, /*requiredOperandCount=*/2) || diff --git a/mlir/examples/toy/Ch6/mlir/Dialect.cpp b/mlir/examples/toy/Ch6/mlir/Dialect.cpp index ecff264..f236a1f 100644 --- a/mlir/examples/toy/Ch6/mlir/Dialect.cpp +++ b/mlir/examples/toy/Ch6/mlir/Dialect.cpp @@ -106,7 +106,7 @@ void ToyDialect::initialize() { /// of 'printBinaryOp' below. static mlir::ParseResult parseBinaryOp(mlir::OpAsmParser &parser, mlir::OperationState &result) { - SmallVector operands; + SmallVector operands; SMLoc operandsLoc = parser.getCurrentLocation(); Type type; if (parser.parseOperandList(operands, /*requiredOperandCount=*/2) || diff --git a/mlir/examples/toy/Ch7/mlir/Dialect.cpp b/mlir/examples/toy/Ch7/mlir/Dialect.cpp index bd2edce..cc66a5d 100644 --- a/mlir/examples/toy/Ch7/mlir/Dialect.cpp +++ b/mlir/examples/toy/Ch7/mlir/Dialect.cpp @@ -93,7 +93,7 @@ struct ToyInlinerInterface : public DialectInlinerInterface { /// of 'printBinaryOp' below. static mlir::ParseResult parseBinaryOp(mlir::OpAsmParser &parser, mlir::OperationState &result) { - SmallVector operands; + SmallVector operands; SMLoc operandsLoc = parser.getCurrentLocation(); Type type; if (parser.parseOperandList(operands, /*requiredOperandCount=*/2) || diff --git a/mlir/include/mlir/IR/FunctionImplementation.h b/mlir/include/mlir/IR/FunctionImplementation.h index 271b089..3d65452 100644 --- a/mlir/include/mlir/IR/FunctionImplementation.h +++ b/mlir/include/mlir/IR/FunctionImplementation.h @@ -58,7 +58,7 @@ using FuncTypeBuilder = function_ref &argNames, + SmallVectorImpl &argNames, SmallVectorImpl &argTypes, SmallVectorImpl &argAttrs, SmallVectorImpl &argLocations, bool &isVariadic); @@ -66,14 +66,13 @@ ParseResult parseFunctionArgumentList( /// indicates whether functions with variadic arguments are supported. The /// trailing arguments are populated by this function with names, types, /// attributes and locations of the arguments and those of the results. -ParseResult -parseFunctionSignature(OpAsmParser &parser, bool allowVariadic, - SmallVectorImpl &argNames, - SmallVectorImpl &argTypes, - SmallVectorImpl &argAttrs, - SmallVectorImpl &argLocations, - bool &isVariadic, SmallVectorImpl &resultTypes, - SmallVectorImpl &resultAttrs); +ParseResult parseFunctionSignature( + OpAsmParser &parser, bool allowVariadic, + SmallVectorImpl &argNames, + SmallVectorImpl &argTypes, SmallVectorImpl &argAttrs, + SmallVectorImpl &argLocations, bool &isVariadic, + SmallVectorImpl &resultTypes, + SmallVectorImpl &resultAttrs); /// Parser implementation for function-like operations. Uses /// `funcTypeBuilder` to construct the custom function type given lists of diff --git a/mlir/include/mlir/IR/OpImplementation.h b/mlir/include/mlir/IR/OpImplementation.h index 0218e6b..2cdce8b 100644 --- a/mlir/include/mlir/IR/OpImplementation.h +++ b/mlir/include/mlir/IR/OpImplementation.h @@ -1083,10 +1083,10 @@ public: //===--------------------------------------------------------------------===// /// This is the representation of an operand reference. - struct OperandType { - SMLoc location; // Location of the token. - StringRef name; // Value name, e.g. %42 or %abc - unsigned number; // Number, e.g. 12 for an operand like %xyz#12 + struct UnresolvedOperand { + SMLoc location; // Location of the token. + StringRef name; // Value name, e.g. %42 or %abc + unsigned number; // Number, e.g. 12 for an operand like %xyz#12 }; /// Parse different components, viz., use-info of operand(s), successor(s), @@ -1096,7 +1096,7 @@ public: /// skip parsing that component. virtual ParseResult parseGenericOperationAfterOpName( OperationState &result, - Optional> parsedOperandType = llvm::None, + Optional> parsedOperandType = llvm::None, Optional> parsedSuccessors = llvm::None, Optional>> parsedRegions = llvm::None, @@ -1104,18 +1104,19 @@ public: Optional parsedFnType = llvm::None) = 0; /// Parse a single operand. - virtual ParseResult parseOperand(OperandType &result) = 0; + virtual ParseResult parseOperand(UnresolvedOperand &result) = 0; /// Parse a single operand if present. - virtual OptionalParseResult parseOptionalOperand(OperandType &result) = 0; + virtual OptionalParseResult + parseOptionalOperand(UnresolvedOperand &result) = 0; /// Parse zero or more SSA comma-separated operand references with a specified /// surrounding delimiter, and an optional required operand count. virtual ParseResult - parseOperandList(SmallVectorImpl &result, + parseOperandList(SmallVectorImpl &result, int requiredOperandCount = -1, Delimiter delimiter = Delimiter::None) = 0; - ParseResult parseOperandList(SmallVectorImpl &result, + ParseResult parseOperandList(SmallVectorImpl &result, Delimiter delimiter) { return parseOperandList(result, /*requiredOperandCount=*/-1, delimiter); } @@ -1124,23 +1125,25 @@ public: /// references with a specified surrounding delimiter, and an optional /// required operand count. A leading comma is expected before the operands. virtual ParseResult - parseTrailingOperandList(SmallVectorImpl &result, + parseTrailingOperandList(SmallVectorImpl &result, int requiredOperandCount = -1, Delimiter delimiter = Delimiter::None) = 0; - ParseResult parseTrailingOperandList(SmallVectorImpl &result, - Delimiter delimiter) { + ParseResult + parseTrailingOperandList(SmallVectorImpl &result, + Delimiter delimiter) { return parseTrailingOperandList(result, /*requiredOperandCount=*/-1, delimiter); } /// Resolve an operand to an SSA value, emitting an error on failure. - virtual ParseResult resolveOperand(const OperandType &operand, Type type, + virtual ParseResult resolveOperand(const UnresolvedOperand &operand, + Type type, SmallVectorImpl &result) = 0; /// Resolve a list of operands to SSA values, emitting an error on failure, or /// appending the results to the list on success. This method should be used /// when all operands have the same type. - ParseResult resolveOperands(ArrayRef operands, Type type, + ParseResult resolveOperands(ArrayRef operands, Type type, SmallVectorImpl &result) { for (auto elt : operands) if (resolveOperand(elt, type, result)) @@ -1151,7 +1154,7 @@ public: /// Resolve a list of operands and a list of operand types to SSA values, /// emitting an error and returning failure, or appending the results /// to the list on success. - ParseResult resolveOperands(ArrayRef operands, + ParseResult resolveOperands(ArrayRef operands, ArrayRef types, SMLoc loc, SmallVectorImpl &result) { if (operands.size() != types.size()) @@ -1190,16 +1193,17 @@ public: /// Operand values must come from single-result sources, and be valid /// dimensions/symbol identifiers according to mlir::isValidDim/Symbol. virtual ParseResult - parseAffineMapOfSSAIds(SmallVectorImpl &operands, Attribute &map, - StringRef attrName, NamedAttrList &attrs, + parseAffineMapOfSSAIds(SmallVectorImpl &operands, + Attribute &map, StringRef attrName, + NamedAttrList &attrs, Delimiter delimiter = Delimiter::Square) = 0; /// Parses an affine expression where dims and symbols are SSA operands. /// Operand values must come from single-result sources, and be valid /// dimensions/symbol identifiers according to mlir::isValidDim/Symbol. virtual ParseResult - parseAffineExprOfSSAIds(SmallVectorImpl &dimOperands, - SmallVectorImpl &symbOperands, + parseAffineExprOfSSAIds(SmallVectorImpl &dimOperands, + SmallVectorImpl &symbOperands, AffineExpr &expr) = 0; //===--------------------------------------------------------------------===// @@ -1215,46 +1219,48 @@ public: /// scope. 'enableNameShadowing' can only be set to true for regions attached /// to operations that are 'IsolatedFromAbove'. virtual ParseResult parseRegion(Region ®ion, - ArrayRef arguments = {}, + ArrayRef arguments = {}, ArrayRef argTypes = {}, ArrayRef argLocations = {}, bool enableNameShadowing = false) = 0; /// Parses a region if present. - virtual OptionalParseResult - parseOptionalRegion(Region ®ion, ArrayRef arguments = {}, - ArrayRef argTypes = {}, - ArrayRef argLocations = {}, - bool enableNameShadowing = false) = 0; + virtual OptionalParseResult parseOptionalRegion( + Region ®ion, ArrayRef arguments = {}, + ArrayRef argTypes = {}, ArrayRef argLocations = {}, + bool enableNameShadowing = false) = 0; /// Parses a region if present. If the region is present, a new region is /// allocated and placed in `region`. If no region is present or on failure, /// `region` remains untouched. - virtual OptionalParseResult parseOptionalRegion( - std::unique_ptr ®ion, ArrayRef arguments = {}, - ArrayRef argTypes = {}, bool enableNameShadowing = false) = 0; + virtual OptionalParseResult + parseOptionalRegion(std::unique_ptr ®ion, + ArrayRef arguments = {}, + ArrayRef argTypes = {}, + bool enableNameShadowing = false) = 0; /// Parse a region argument, this argument is resolved when calling /// 'parseRegion'. - virtual ParseResult parseRegionArgument(OperandType &argument) = 0; + virtual ParseResult parseRegionArgument(UnresolvedOperand &argument) = 0; /// Parse zero or more region arguments with a specified surrounding /// delimiter, and an optional required argument count. Region arguments /// define new values; so this also checks if values with the same names have /// not been defined yet. virtual ParseResult - parseRegionArgumentList(SmallVectorImpl &result, + parseRegionArgumentList(SmallVectorImpl &result, int requiredOperandCount = -1, Delimiter delimiter = Delimiter::None) = 0; virtual ParseResult - parseRegionArgumentList(SmallVectorImpl &result, + parseRegionArgumentList(SmallVectorImpl &result, Delimiter delimiter) { return parseRegionArgumentList(result, /*requiredOperandCount=*/-1, delimiter); } /// Parse a region argument if present. - virtual ParseResult parseOptionalRegionArgument(OperandType &argument) = 0; + virtual ParseResult + parseOptionalRegionArgument(UnresolvedOperand &argument) = 0; //===--------------------------------------------------------------------===// // Successor Parsing @@ -1276,8 +1282,8 @@ public: /// Parse a list of assignments of the form /// (%x1 = %y1, %x2 = %y2, ...) - ParseResult parseAssignmentList(SmallVectorImpl &lhs, - SmallVectorImpl &rhs) { + ParseResult parseAssignmentList(SmallVectorImpl &lhs, + SmallVectorImpl &rhs) { OptionalParseResult result = parseOptionalAssignmentList(lhs, rhs); if (!result.hasValue()) return emitError(getCurrentLocation(), "expected '('"); @@ -1285,14 +1291,15 @@ public: } virtual OptionalParseResult - parseOptionalAssignmentList(SmallVectorImpl &lhs, - SmallVectorImpl &rhs) = 0; + parseOptionalAssignmentList(SmallVectorImpl &lhs, + SmallVectorImpl &rhs) = 0; /// Parse a list of assignments of the form /// (%x1 = %y1 : type1, %x2 = %y2 : type2, ...) - ParseResult parseAssignmentListWithTypes(SmallVectorImpl &lhs, - SmallVectorImpl &rhs, - SmallVectorImpl &types) { + ParseResult + parseAssignmentListWithTypes(SmallVectorImpl &lhs, + SmallVectorImpl &rhs, + SmallVectorImpl &types) { OptionalParseResult result = parseOptionalAssignmentListWithTypes(lhs, rhs, types); if (!result.hasValue()) @@ -1301,17 +1308,17 @@ public: } virtual OptionalParseResult - parseOptionalAssignmentListWithTypes(SmallVectorImpl &lhs, - SmallVectorImpl &rhs, + parseOptionalAssignmentListWithTypes(SmallVectorImpl &lhs, + SmallVectorImpl &rhs, SmallVectorImpl &types) = 0; private: /// Parse either an operand list or a region argument list depending on /// whether isOperandList is true. - ParseResult parseOperandOrRegionArgList(SmallVectorImpl &result, - bool isOperandList, - int requiredOperandCount, - Delimiter delimiter); + ParseResult + parseOperandOrRegionArgList(SmallVectorImpl &result, + bool isOperandList, int requiredOperandCount, + Delimiter delimiter); }; //===--------------------------------------------------------------------===// diff --git a/mlir/include/mlir/Interfaces/ViewLikeInterface.h b/mlir/include/mlir/Interfaces/ViewLikeInterface.h index 8b07972..8c18ab3 100644 --- a/mlir/include/mlir/Interfaces/ViewLikeInterface.h +++ b/mlir/include/mlir/Interfaces/ViewLikeInterface.h @@ -105,7 +105,8 @@ void printOperandsOrIntegersSizesList(OpAsmPrinter &printer, Operation *op, /// 1. `result` is filled with the i64 ArrayAttr "[`dynVal`, 7, 42, `dynVal`]" /// 2. `ssa` is filled with "[%arg0, %arg1]". ParseResult parseOperandsOrIntegersOffsetsOrStridesList( - OpAsmParser &parser, SmallVectorImpl &values, + OpAsmParser &parser, + SmallVectorImpl &values, ArrayAttr &integers); /// Pasrer hook for custom directive in assemblyFormat. @@ -122,7 +123,8 @@ ParseResult parseOperandsOrIntegersOffsetsOrStridesList( /// 1. `result` is filled with the i64 ArrayAttr "[`dynVal`, 7, 42, `dynVal`]" /// 2. `ssa` is filled with "[%arg0, %arg1]". ParseResult parseOperandsOrIntegersSizesList( - OpAsmParser &parser, SmallVectorImpl &values, + OpAsmParser &parser, + SmallVectorImpl &values, ArrayAttr &integers); /// Verify that a the `values` has as many elements as the number of entries in diff --git a/mlir/lib/Dialect/Affine/IR/AffineOps.cpp b/mlir/lib/Dialect/Affine/IR/AffineOps.cpp index a43da29..09b9aca 100644 --- a/mlir/lib/Dialect/Affine/IR/AffineOps.cpp +++ b/mlir/lib/Dialect/Affine/IR/AffineOps.cpp @@ -446,7 +446,7 @@ static void printDimAndSymbolList(Operation::operand_iterator begin, ParseResult mlir::parseDimAndSymbolList(OpAsmParser &parser, SmallVectorImpl &operands, unsigned &numDims) { - SmallVector opInfos; + SmallVector opInfos; if (parser.parseOperandList(opInfos, OpAsmParser::Delimiter::Paren)) return failure(); // Store number of dimensions for validation by caller. @@ -1041,17 +1041,17 @@ void AffineDmaStartOp::print(OpAsmPrinter &p) { // ParseResult AffineDmaStartOp::parse(OpAsmParser &parser, OperationState &result) { - OpAsmParser::OperandType srcMemRefInfo; + OpAsmParser::UnresolvedOperand srcMemRefInfo; AffineMapAttr srcMapAttr; - SmallVector srcMapOperands; - OpAsmParser::OperandType dstMemRefInfo; + SmallVector srcMapOperands; + OpAsmParser::UnresolvedOperand dstMemRefInfo; AffineMapAttr dstMapAttr; - SmallVector dstMapOperands; - OpAsmParser::OperandType tagMemRefInfo; + SmallVector dstMapOperands; + OpAsmParser::UnresolvedOperand tagMemRefInfo; AffineMapAttr tagMapAttr; - SmallVector tagMapOperands; - OpAsmParser::OperandType numElementsInfo; - SmallVector strideInfo; + SmallVector tagMapOperands; + OpAsmParser::UnresolvedOperand numElementsInfo; + SmallVector strideInfo; SmallVector types; auto indexType = parser.getBuilder().getIndexType(); @@ -1186,12 +1186,12 @@ void AffineDmaWaitOp::print(OpAsmPrinter &p) { // ParseResult AffineDmaWaitOp::parse(OpAsmParser &parser, OperationState &result) { - OpAsmParser::OperandType tagMemRefInfo; + OpAsmParser::UnresolvedOperand tagMemRefInfo; AffineMapAttr tagMapAttr; - SmallVector tagMapOperands; + SmallVector tagMapOperands; Type type; auto indexType = parser.getBuilder().getIndexType(); - OpAsmParser::OperandType numElementsInfo; + OpAsmParser::UnresolvedOperand numElementsInfo; // Parse tag memref, its map operands, and dma size. if (parser.parseOperand(tagMemRefInfo) || @@ -1349,7 +1349,7 @@ static ParseResult parseBound(bool isLower, OperationState &result, : AffineForOp::getUpperBoundAttrName(); // Parse ssa-id as identity map. - SmallVector boundOpInfos; + SmallVector boundOpInfos; if (p.parseOperandList(boundOpInfos)) return failure(); @@ -1430,7 +1430,7 @@ static ParseResult parseBound(bool isLower, OperationState &result, ParseResult AffineForOp::parse(OpAsmParser &parser, OperationState &result) { auto &builder = parser.getBuilder(); - OpAsmParser::OperandType inductionVariable; + OpAsmParser::UnresolvedOperand inductionVariable; // Parse the induction variable followed by '='. if (parser.parseRegionArgument(inductionVariable) || parser.parseEqual()) return failure(); @@ -1461,7 +1461,7 @@ ParseResult AffineForOp::parse(OpAsmParser &parser, OperationState &result) { } // Parse the optional initial iteration arguments. - SmallVector regionArgs, operands; + SmallVector regionArgs, operands; SmallVector argTypes; regionArgs.push_back(inductionVariable); @@ -2317,9 +2317,9 @@ ParseResult AffineLoadOp::parse(OpAsmParser &parser, OperationState &result) { auto indexTy = builder.getIndexType(); MemRefType type; - OpAsmParser::OperandType memrefInfo; + OpAsmParser::UnresolvedOperand memrefInfo; AffineMapAttr mapAttr; - SmallVector mapOperands; + SmallVector mapOperands; return failure( parser.parseOperand(memrefInfo) || parser.parseAffineMapOfSSAIds(mapOperands, mapAttr, @@ -2453,10 +2453,10 @@ ParseResult AffineStoreOp::parse(OpAsmParser &parser, OperationState &result) { auto indexTy = parser.getBuilder().getIndexType(); MemRefType type; - OpAsmParser::OperandType storeValueInfo; - OpAsmParser::OperandType memrefInfo; + OpAsmParser::UnresolvedOperand storeValueInfo; + OpAsmParser::UnresolvedOperand memrefInfo; AffineMapAttr mapAttr; - SmallVector mapOperands; + SmallVector mapOperands; return failure(parser.parseOperand(storeValueInfo) || parser.parseComma() || parser.parseOperand(memrefInfo) || parser.parseAffineMapOfSSAIds(mapOperands, mapAttr, @@ -2539,8 +2539,8 @@ static ParseResult parseAffineMinMaxOp(OpAsmParser &parser, OperationState &result) { auto &builder = parser.getBuilder(); auto indexType = builder.getIndexType(); - SmallVector dimInfos; - SmallVector symInfos; + SmallVector dimInfos; + SmallVector symInfos; AffineMapAttr mapAttr; return failure( parser.parseAttribute(mapAttr, T::getMapAttrName(), result.attributes) || @@ -2789,13 +2789,13 @@ ParseResult AffinePrefetchOp::parse(OpAsmParser &parser, auto indexTy = builder.getIndexType(); MemRefType type; - OpAsmParser::OperandType memrefInfo; + OpAsmParser::UnresolvedOperand memrefInfo; IntegerAttr hintInfo; auto i32Type = parser.getBuilder().getIntegerType(32); StringRef readOrWrite, cacheType; AffineMapAttr mapAttr; - SmallVector mapOperands; + SmallVector mapOperands; if (parser.parseOperand(memrefInfo) || parser.parseAffineMapOfSSAIds(mapOperands, mapAttr, AffinePrefetchOp::getMapAttrName(), @@ -3262,7 +3262,7 @@ void AffineParallelOp::print(OpAsmPrinter &p) { /// `operands` to accept `uniqueOperands` instead. static void deduplicateAndResolveOperands( OpAsmParser &parser, - ArrayRef> operands, + ArrayRef> operands, SmallVectorImpl &uniqueOperands, SmallVectorImpl &replacements, AffineExprKind kind) { assert((kind == AffineExprKind::DimId || kind == AffineExprKind::SymbolId) && @@ -3328,10 +3328,10 @@ static ParseResult parseAffineMapWithMinMax(OpAsmParser &parser, } SmallVector flatExprs; - SmallVector> flatDimOperands; - SmallVector> flatSymOperands; + SmallVector> flatDimOperands; + SmallVector> flatSymOperands; SmallVector numMapsPerGroup; - SmallVector mapOperands; + SmallVector mapOperands; do { if (succeeded(parser.parseOptionalKeyword( kind == MinMaxKind::Min ? "min" : "max"))) { @@ -3345,11 +3345,11 @@ static ParseResult parseAffineMapWithMinMax(OpAsmParser &parser, llvm::append_range(flatExprs, map.getValue().getResults()); auto operandsRef = llvm::makeArrayRef(mapOperands); auto dimsRef = operandsRef.take_front(map.getValue().getNumDims()); - SmallVector dims(dimsRef.begin(), - dimsRef.end()); + SmallVector dims(dimsRef.begin(), + dimsRef.end()); auto symsRef = operandsRef.drop_front(map.getValue().getNumDims()); - SmallVector syms(symsRef.begin(), - symsRef.end()); + SmallVector syms(symsRef.begin(), + symsRef.end()); flatDimOperands.append(map.getValue().getNumResults(), dims); flatSymOperands.append(map.getValue().getNumResults(), syms); numMapsPerGroup.push_back(map.getValue().getNumResults()); @@ -3408,7 +3408,7 @@ ParseResult AffineParallelOp::parse(OpAsmParser &parser, OperationState &result) { auto &builder = parser.getBuilder(); auto indexType = builder.getIndexType(); - SmallVector ivs; + SmallVector ivs; if (parser.parseRegionArgumentList(ivs, /*requiredOperandCount=*/-1, OpAsmParser::Delimiter::Paren) || parser.parseEqual() || @@ -3419,7 +3419,7 @@ ParseResult AffineParallelOp::parse(OpAsmParser &parser, AffineMapAttr stepsMapAttr; NamedAttrList stepsAttrs; - SmallVector stepsMapOperands; + SmallVector stepsMapOperands; if (failed(parser.parseOptionalKeyword("step"))) { SmallVector steps(ivs.size(), 1); result.addAttribute(AffineParallelOp::getStepsAttrName(), @@ -3561,9 +3561,9 @@ ParseResult AffineVectorLoadOp::parse(OpAsmParser &parser, MemRefType memrefType; VectorType resultType; - OpAsmParser::OperandType memrefInfo; + OpAsmParser::UnresolvedOperand memrefInfo; AffineMapAttr mapAttr; - SmallVector mapOperands; + SmallVector mapOperands; return failure( parser.parseOperand(memrefInfo) || parser.parseAffineMapOfSSAIds(mapOperands, mapAttr, @@ -3650,10 +3650,10 @@ ParseResult AffineVectorStoreOp::parse(OpAsmParser &parser, MemRefType memrefType; VectorType resultType; - OpAsmParser::OperandType storeValueInfo; - OpAsmParser::OperandType memrefInfo; + OpAsmParser::UnresolvedOperand storeValueInfo; + OpAsmParser::UnresolvedOperand memrefInfo; AffineMapAttr mapAttr; - SmallVector mapOperands; + SmallVector mapOperands; return failure( parser.parseOperand(storeValueInfo) || parser.parseComma() || parser.parseOperand(memrefInfo) || diff --git a/mlir/lib/Dialect/Arithmetic/IR/ArithmeticOps.cpp b/mlir/lib/Dialect/Arithmetic/IR/ArithmeticOps.cpp index fd19cda..74b77dc 100644 --- a/mlir/lib/Dialect/Arithmetic/IR/ArithmeticOps.cpp +++ b/mlir/lib/Dialect/Arithmetic/IR/ArithmeticOps.cpp @@ -1806,7 +1806,7 @@ OpFoldResult arith::SelectOp::fold(ArrayRef operands) { ParseResult SelectOp::parse(OpAsmParser &parser, OperationState &result) { Type conditionType, resultType; - SmallVector operands; + SmallVector operands; if (parser.parseOperandList(operands, /*requiredOperandCount=*/3) || parser.parseOptionalAttrDict(result.attributes) || parser.parseColonType(resultType)) diff --git a/mlir/lib/Dialect/Async/IR/Async.cpp b/mlir/lib/Dialect/Async/IR/Async.cpp index 546a39f..55f7f7a 100644 --- a/mlir/lib/Dialect/Async/IR/Async.cpp +++ b/mlir/lib/Dialect/Async/IR/Async.cpp @@ -167,7 +167,7 @@ ParseResult ExecuteOp::parse(OpAsmParser &parser, OperationState &result) { // Parse dependency tokens. if (succeeded(parser.parseOptionalLSquare())) { - SmallVector tokenArgs; + SmallVector tokenArgs; if (parser.parseOperandList(tokenArgs) || parser.resolveOperands(tokenArgs, tokenTy, result.operands) || parser.parseRSquare()) @@ -177,8 +177,8 @@ ParseResult ExecuteOp::parse(OpAsmParser &parser, OperationState &result) { } // Parse async value operands (%value as %unwrapped : !async.value). - SmallVector valueArgs; - SmallVector unwrappedArgs; + SmallVector valueArgs; + SmallVector unwrappedArgs; SmallVector valueTypes; SmallVector unwrappedTypes; diff --git a/mlir/lib/Dialect/ControlFlow/IR/ControlFlowOps.cpp b/mlir/lib/Dialect/ControlFlow/IR/ControlFlowOps.cpp index 11d719a..03f0998 100644 --- a/mlir/lib/Dialect/ControlFlow/IR/ControlFlowOps.cpp +++ b/mlir/lib/Dialect/ControlFlow/IR/ControlFlowOps.cpp @@ -481,11 +481,11 @@ void SwitchOp::build(OpBuilder &builder, OperationState &result, Value value, /// ( `,` integer `:` bb-id (`(` ssa-use-and-type-list `)`)? )* static ParseResult parseSwitchOpCases( OpAsmParser &parser, Type &flagType, Block *&defaultDestination, - SmallVectorImpl &defaultOperands, + SmallVectorImpl &defaultOperands, SmallVectorImpl &defaultOperandTypes, DenseIntElementsAttr &caseValues, SmallVectorImpl &caseDestinations, - SmallVectorImpl> &caseOperands, + SmallVectorImpl> &caseOperands, SmallVectorImpl> &caseOperandTypes) { if (parser.parseKeyword("default") || parser.parseColon() || parser.parseSuccessor(defaultDestination)) @@ -505,7 +505,7 @@ static ParseResult parseSwitchOpCases( values.push_back(APInt(bitWidth, value)); Block *destination; - SmallVector operands; + SmallVector operands; SmallVector operandTypes; if (failed(parser.parseColon()) || failed(parser.parseSuccessor(destination))) diff --git a/mlir/lib/Dialect/GPU/IR/GPUDialect.cpp b/mlir/lib/Dialect/GPU/IR/GPUDialect.cpp index 673ca4e..990a2dc 100644 --- a/mlir/lib/Dialect/GPU/IR/GPUDialect.cpp +++ b/mlir/lib/Dialect/GPU/IR/GPUDialect.cpp @@ -475,11 +475,11 @@ void LaunchOp::print(OpAsmPrinter &p) { // SSA value uses. static ParseResult parseSizeAssignment(OpAsmParser &parser, - MutableArrayRef sizes, - MutableArrayRef regionSizes, - MutableArrayRef indices) { + MutableArrayRef sizes, + MutableArrayRef regionSizes, + MutableArrayRef indices) { assert(indices.size() == 3 && "space for three indices expected"); - SmallVector args; + SmallVector args; if (parser.parseRegionArgumentList(args, /*requiredOperandCount=*/3, OpAsmParser::Delimiter::Paren) || parser.parseKeyword("in") || parser.parseLParen()) @@ -506,17 +506,17 @@ parseSizeAssignment(OpAsmParser &parser, /// ssa-reassignment ::= `(` ssa-id `=` ssa-use (`,` ssa-id `=` ssa-use)* `)` ParseResult LaunchOp::parse(OpAsmParser &parser, OperationState &result) { // Sizes of the grid and block. - SmallVector sizes( - LaunchOp::kNumConfigOperands); - MutableArrayRef sizesRef(sizes); + SmallVector + sizes(LaunchOp::kNumConfigOperands); + MutableArrayRef sizesRef(sizes); // Actual (data) operands passed to the kernel. - SmallVector dataOperands; + SmallVector dataOperands; // Region arguments to be created. - SmallVector regionArgs( + SmallVector regionArgs( LaunchOp::kNumConfigRegionAttributes); - MutableArrayRef regionArgsRef(regionArgs); + MutableArrayRef regionArgsRef(regionArgs); // Parse the size assignment segments: the first segment assigns grid sizes // and defines values for block identifiers; the second segment assigns block @@ -535,7 +535,7 @@ ParseResult LaunchOp::parse(OpAsmParser &parser, OperationState &result) { result.operands)) return failure(); - OpAsmParser::OperandType dynamicSharedMemorySize; + OpAsmParser::UnresolvedOperand dynamicSharedMemorySize; if (!parser.parseOptionalKeyword( LaunchOp::getDynamicSharedMemorySizeKeyword())) if (parser.parseOperand(dynamicSharedMemorySize) || @@ -667,10 +667,10 @@ LogicalResult LaunchFuncOp::verify() { return success(); } -static ParseResult -parseLaunchFuncOperands(OpAsmParser &parser, - SmallVectorImpl &argNames, - SmallVectorImpl &argTypes) { +static ParseResult parseLaunchFuncOperands( + OpAsmParser &parser, + SmallVectorImpl &argNames, + SmallVectorImpl &argTypes) { if (parser.parseOptionalKeyword("args")) return success(); SmallVector argAttrs; @@ -769,7 +769,7 @@ void GPUFuncOp::build(OpBuilder &builder, OperationState &result, /// keyword provided as argument. static ParseResult parseAttributions(OpAsmParser &parser, StringRef keyword, - SmallVectorImpl &args, + SmallVectorImpl &args, SmallVectorImpl &argTypes) { // If we could not parse the keyword, just assume empty list and succeed. if (failed(parser.parseOptionalKeyword(keyword))) @@ -783,7 +783,7 @@ parseAttributions(OpAsmParser &parser, StringRef keyword, return success(); do { - OpAsmParser::OperandType arg; + OpAsmParser::UnresolvedOperand arg; Type type; if (parser.parseRegionArgument(arg) || parser.parseColonType(type)) @@ -802,7 +802,7 @@ parseAttributions(OpAsmParser &parser, StringRef keyword, /// (`->` function-result-list)? memory-attribution `kernel`? /// function-attributes? region ParseResult GPUFuncOp::parse(OpAsmParser &parser, OperationState &result) { - SmallVector entryArgs; + SmallVector entryArgs; SmallVector argAttrs; SmallVector resultAttrs; SmallVector argTypes; @@ -1041,7 +1041,7 @@ LogicalResult MemcpyOp::verify() { static ParseResult parseAsyncDependencies( OpAsmParser &parser, Type &asyncTokenType, - SmallVectorImpl &asyncDependencies) { + SmallVectorImpl &asyncDependencies) { auto loc = parser.getCurrentLocation(); if (succeeded(parser.parseOptionalKeyword("async"))) { if (parser.getNumResults() == 0) diff --git a/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp b/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp index 0184c51..ff93a50 100644 --- a/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp +++ b/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp @@ -113,7 +113,7 @@ static ParseResult parseCmpOp(OpAsmParser &parser, OperationState &result) { Builder &builder = parser.getBuilder(); StringAttr predicateAttr; - OpAsmParser::OperandType lhs, rhs; + OpAsmParser::UnresolvedOperand lhs, rhs; Type type; SMLoc predicateLoc, trailingTypeLoc; if (parser.getCurrentLocation(&predicateLoc) || @@ -200,7 +200,7 @@ void AllocaOp::print(OpAsmPrinter &p) { // ::= `llvm.alloca` ssa-use `x` type attribute-dict? // `:` type `,` type ParseResult AllocaOp::parse(OpAsmParser &parser, OperationState &result) { - OpAsmParser::OperandType arraySize; + OpAsmParser::UnresolvedOperand arraySize; Type type, elemType; SMLoc trailingTypeLoc; if (parser.parseOperand(arraySize) || parser.parseKeyword("x") || @@ -283,7 +283,7 @@ void SwitchOp::build(OpBuilder &builder, OperationState &result, Value value, static ParseResult parseSwitchOpCases( OpAsmParser &parser, Type flagType, ElementsAttr &caseValues, SmallVectorImpl &caseDestinations, - SmallVectorImpl> &caseOperands, + SmallVectorImpl> &caseOperands, SmallVectorImpl> &caseOperandTypes) { SmallVector values; unsigned bitWidth = flagType.getIntOrFloatBitWidth(); @@ -298,7 +298,7 @@ static ParseResult parseSwitchOpCases( values.push_back(APInt(bitWidth, value)); Block *destination; - SmallVector operands; + SmallVector operands; SmallVector operandTypes; if (parser.parseColon() || parser.parseSuccessor(destination)) return failure(); @@ -489,7 +489,7 @@ void GEPOp::build(OpBuilder &builder, OperationState &result, Type resultType, static ParseResult parseGEPIndices(OpAsmParser &parser, - SmallVectorImpl &indices, + SmallVectorImpl &indices, DenseIntElementsAttr &structIndices) { SmallVector constantIndices; do { @@ -657,7 +657,7 @@ static Type getLoadStoreElementType(OpAsmParser &parser, Type type, // ::= `llvm.load` `volatile` ssa-use attribute-dict? `:` type ParseResult LoadOp::parse(OpAsmParser &parser, OperationState &result) { - OpAsmParser::OperandType addr; + OpAsmParser::UnresolvedOperand addr; Type type; SMLoc trailingTypeLoc; @@ -707,7 +707,7 @@ void StoreOp::print(OpAsmPrinter &p) { // ::= `llvm.store` `volatile` ssa-use `,` ssa-use // attribute-dict? `:` type ParseResult StoreOp::parse(OpAsmParser &parser, OperationState &result) { - OpAsmParser::OperandType addr, value; + OpAsmParser::UnresolvedOperand addr, value; Type type; SMLoc trailingTypeLoc; @@ -788,7 +788,7 @@ void InvokeOp::print(OpAsmPrinter &p) { /// `unwind` bb-id (`[` ssa-use-and-type-list `]`)? /// attribute-dict? `:` function-type ParseResult InvokeOp::parse(OpAsmParser &parser, OperationState &result) { - SmallVector operands; + SmallVector operands; FunctionType funcType; SymbolRefAttr funcAttr; SMLoc trailingTypeLoc; @@ -948,7 +948,7 @@ ParseResult LandingpadOp::parse(OpAsmParser &parser, OperationState &result) { while (succeeded(parser.parseOptionalLParen()) && (succeeded(parser.parseOptionalKeyword("filter")) || succeeded(parser.parseOptionalKeyword("catch")))) { - OpAsmParser::OperandType operand; + OpAsmParser::UnresolvedOperand operand; Type ty; if (parser.parseOperand(operand) || parser.parseColon() || parser.parseType(ty) || @@ -1075,7 +1075,7 @@ void CallOp::print(OpAsmPrinter &p) { // ::= `llvm.call` (function-id | ssa-use) `(` ssa-use-list `)` // attribute-dict? `:` function-type ParseResult CallOp::parse(OpAsmParser &parser, OperationState &result) { - SmallVector operands; + SmallVector operands; Type type; SymbolRefAttr funcAttr; SMLoc trailingTypeLoc; @@ -1137,7 +1137,7 @@ ParseResult CallOp::parse(OpAsmParser &parser, OperationState &result) { auto wrappedFuncType = LLVM::LLVMPointerType::get(llvmFuncType); auto funcArguments = - ArrayRef(operands).drop_front(); + ArrayRef(operands).drop_front(); // Make sure that the first operand (indirect callee) matches the wrapped // LLVM IR function type, and that the types of the other call operands @@ -1180,7 +1180,7 @@ void ExtractElementOp::print(OpAsmPrinter &p) { ParseResult ExtractElementOp::parse(OpAsmParser &parser, OperationState &result) { SMLoc loc; - OpAsmParser::OperandType vector, position; + OpAsmParser::UnresolvedOperand vector, position; Type type, positionType; if (parser.getCurrentLocation(&loc) || parser.parseOperand(vector) || parser.parseLSquare() || parser.parseOperand(position) || @@ -1315,7 +1315,7 @@ static Type getInsertExtractValueElementType(Type containerType, // `[` integer-literal (`,` integer-literal)* `]` // attribute-dict? `:` type ParseResult ExtractValueOp::parse(OpAsmParser &parser, OperationState &result) { - OpAsmParser::OperandType container; + OpAsmParser::UnresolvedOperand container; Type containerType; ArrayAttr positionAttr; SMLoc attributeLoc, trailingTypeLoc; @@ -1400,7 +1400,7 @@ void InsertElementOp::print(OpAsmPrinter &p) { ParseResult InsertElementOp::parse(OpAsmParser &parser, OperationState &result) { SMLoc loc; - OpAsmParser::OperandType vector, value, position; + OpAsmParser::UnresolvedOperand vector, value, position; Type vectorType, positionType; if (parser.getCurrentLocation(&loc) || parser.parseOperand(value) || parser.parseComma() || parser.parseOperand(vector) || @@ -1449,7 +1449,7 @@ void InsertValueOp::print(OpAsmPrinter &p) { // `[` integer-literal (`,` integer-literal)* `]` // attribute-dict? `:` type ParseResult InsertValueOp::parse(OpAsmParser &parser, OperationState &result) { - OpAsmParser::OperandType container, value; + OpAsmParser::UnresolvedOperand container, value; Type containerType; ArrayAttr positionAttr; SMLoc attributeLoc, trailingTypeLoc; @@ -1917,7 +1917,7 @@ void ShuffleVectorOp::print(OpAsmPrinter &p) { ParseResult ShuffleVectorOp::parse(OpAsmParser &parser, OperationState &result) { SMLoc loc; - OpAsmParser::OperandType v1, v2; + OpAsmParser::UnresolvedOperand v1, v2; ArrayAttr maskAttr; Type typeV1, typeV2; if (parser.getCurrentLocation(&loc) || parser.parseOperand(v1) || @@ -2046,7 +2046,7 @@ ParseResult LLVMFuncOp::parse(OpAsmParser &parser, OperationState &result) { parser, result, LLVM::Linkage::External))); StringAttr nameAttr; - SmallVector entryArgs; + SmallVector entryArgs; SmallVector argAttrs; SmallVector resultAttrs; SmallVector argTypes; @@ -2287,7 +2287,7 @@ void AtomicRMWOp::print(OpAsmPrinter &p) { // attribute-dict? `:` type ParseResult AtomicRMWOp::parse(OpAsmParser &parser, OperationState &result) { Type type; - OpAsmParser::OperandType ptr, val; + OpAsmParser::UnresolvedOperand ptr, val; if (parseAtomicBinOp(parser, result, "bin_op") || parser.parseOperand(ptr) || parser.parseComma() || parser.parseOperand(val) || parseAtomicOrdering(parser, result, "ordering") || @@ -2359,7 +2359,7 @@ ParseResult AtomicCmpXchgOp::parse(OpAsmParser &parser, OperationState &result) { auto &builder = parser.getBuilder(); Type type; - OpAsmParser::OperandType ptr, cmp, val; + OpAsmParser::UnresolvedOperand ptr, cmp, val; if (parser.parseOperand(ptr) || parser.parseComma() || parser.parseOperand(cmp) || parser.parseComma() || parser.parseOperand(val) || diff --git a/mlir/lib/Dialect/LLVMIR/IR/NVVMDialect.cpp b/mlir/lib/Dialect/LLVMIR/IR/NVVMDialect.cpp index 5256be0..9b909a2 100644 --- a/mlir/lib/Dialect/LLVMIR/IR/NVVMDialect.cpp +++ b/mlir/lib/Dialect/LLVMIR/IR/NVVMDialect.cpp @@ -51,7 +51,7 @@ ParseResult VoteBallotOp::parse(OpAsmParser &parser, OperationState &result) { auto int32Ty = IntegerType::get(context, 32); auto int1Ty = IntegerType::get(context, 1); - SmallVector ops; + SmallVector ops; Type type; return failure(parser.parseOperandList(ops) || parser.parseOptionalAttrDict(result.attributes) || diff --git a/mlir/lib/Dialect/LLVMIR/IR/ROCDLDialect.cpp b/mlir/lib/Dialect/LLVMIR/IR/ROCDLDialect.cpp index 278f236..0efb282 100644 --- a/mlir/lib/Dialect/LLVMIR/IR/ROCDLDialect.cpp +++ b/mlir/lib/Dialect/LLVMIR/IR/ROCDLDialect.cpp @@ -40,7 +40,7 @@ using namespace ROCDL; // `llvm.amdgcn.buffer.load.* %rsrc, %vindex, %offset, %glc, %slc : // result_type` ParseResult MubufLoadOp::parse(OpAsmParser &parser, OperationState &result) { - SmallVector ops; + SmallVector ops; Type type; if (parser.parseOperandList(ops, 5) || parser.parseColonType(type) || parser.addTypeToList(type, result.types)) @@ -63,7 +63,7 @@ void MubufLoadOp::print(OpAsmPrinter &p) { // `llvm.amdgcn.buffer.store.* %vdata, %rsrc, %vindex, %offset, %glc, %slc : // result_type` ParseResult MubufStoreOp::parse(OpAsmParser &parser, OperationState &result) { - SmallVector ops; + SmallVector ops; Type type; if (parser.parseOperandList(ops, 6) || parser.parseColonType(type)) return failure(); diff --git a/mlir/lib/Dialect/Linalg/IR/LinalgOps.cpp b/mlir/lib/Dialect/Linalg/IR/LinalgOps.cpp index 34f264b..d62192d 100644 --- a/mlir/lib/Dialect/Linalg/IR/LinalgOps.cpp +++ b/mlir/lib/Dialect/Linalg/IR/LinalgOps.cpp @@ -638,7 +638,7 @@ ParseResult GenericOp::parse(OpAsmParser &parser, OperationState &result) { failed(parser.parseOptionalAttrDict(result.attributes))) return failure(); - SmallVector regionOperands; + SmallVector regionOperands; std::unique_ptr region = std::make_unique(); SmallVector operandTypes, regionTypes; if (parser.parseRegion(*region, regionOperands, regionTypes)) @@ -1237,7 +1237,7 @@ void linalg::YieldOp::print(OpAsmPrinter &p) { } ParseResult YieldOp::parse(OpAsmParser &parser, OperationState &result) { - SmallVector opInfo; + SmallVector opInfo; SmallVector types; SMLoc loc = parser.getCurrentLocation(); return failure(parser.parseOperandList(opInfo) || @@ -1457,7 +1457,8 @@ parseCommonStructuredOpParts(OpAsmParser &parser, OperationState &result, SmallVectorImpl &inputTypes, SmallVectorImpl &outputTypes) { SMLoc inputsOperandsLoc, outputsOperandsLoc; - SmallVector inputsOperands, outputsOperands; + SmallVector inputsOperands, + outputsOperands; parser.parseOptionalAttrDict(result.attributes); diff --git a/mlir/lib/Dialect/MemRef/IR/MemRefOps.cpp b/mlir/lib/Dialect/MemRef/IR/MemRefOps.cpp index 93dd6f0..7622994 100644 --- a/mlir/lib/Dialect/MemRef/IR/MemRefOps.cpp +++ b/mlir/lib/Dialect/MemRef/IR/MemRefOps.cpp @@ -959,14 +959,14 @@ void DmaStartOp::print(OpAsmPrinter &p) { // memref<1 x i32> // ParseResult DmaStartOp::parse(OpAsmParser &parser, OperationState &result) { - OpAsmParser::OperandType srcMemRefInfo; - SmallVector srcIndexInfos; - OpAsmParser::OperandType dstMemRefInfo; - SmallVector dstIndexInfos; - OpAsmParser::OperandType numElementsInfo; - OpAsmParser::OperandType tagMemrefInfo; - SmallVector tagIndexInfos; - SmallVector strideInfo; + OpAsmParser::UnresolvedOperand srcMemRefInfo; + SmallVector srcIndexInfos; + OpAsmParser::UnresolvedOperand dstMemRefInfo; + SmallVector dstIndexInfos; + OpAsmParser::UnresolvedOperand numElementsInfo; + OpAsmParser::UnresolvedOperand tagMemrefInfo; + SmallVector tagIndexInfos; + SmallVector strideInfo; SmallVector types; auto indexType = parser.getBuilder().getIndexType(); @@ -1153,9 +1153,9 @@ LogicalResult GenericAtomicRMWOp::verify() { ParseResult GenericAtomicRMWOp::parse(OpAsmParser &parser, OperationState &result) { - OpAsmParser::OperandType memref; + OpAsmParser::UnresolvedOperand memref; Type memrefType; - SmallVector ivs; + SmallVector ivs; Type indexType = parser.getBuilder().getIndexType(); if (parser.parseOperand(memref) || @@ -1341,8 +1341,8 @@ void PrefetchOp::print(OpAsmPrinter &p) { } ParseResult PrefetchOp::parse(OpAsmParser &parser, OperationState &result) { - OpAsmParser::OperandType memrefInfo; - SmallVector indexInfo; + OpAsmParser::UnresolvedOperand memrefInfo; + SmallVector indexInfo; IntegerAttr localityHint; MemRefType type; StringRef readOrWrite, cacheType; @@ -2422,7 +2422,7 @@ void TransposeOp::print(OpAsmPrinter &p) { } ParseResult TransposeOp::parse(OpAsmParser &parser, OperationState &result) { - OpAsmParser::OperandType in; + OpAsmParser::UnresolvedOperand in; AffineMap permutation; MemRefType srcType, dstType; if (parser.parseOperand(in) || parser.parseAffineMap(permutation) || diff --git a/mlir/lib/Dialect/OpenACC/IR/OpenACC.cpp b/mlir/lib/Dialect/OpenACC/IR/OpenACC.cpp index fe5af72..e4c881a 100644 --- a/mlir/lib/Dialect/OpenACC/IR/OpenACC.cpp +++ b/mlir/lib/Dialect/OpenACC/IR/OpenACC.cpp @@ -54,7 +54,7 @@ static ParseResult parseRegions(OpAsmParser &parser, OperationState &state, static ParseResult parseOperandList(OpAsmParser &parser, StringRef keyword, - SmallVectorImpl &args, + SmallVectorImpl &args, SmallVectorImpl &argTypes, OperationState &result) { if (failed(parser.parseOptionalKeyword(keyword))) return success(); @@ -67,7 +67,7 @@ parseOperandList(OpAsmParser &parser, StringRef keyword, return success(); do { - OpAsmParser::OperandType arg; + OpAsmParser::UnresolvedOperand arg; Type type; if (parser.parseRegionArgument(arg) || parser.parseColonType(type)) @@ -97,7 +97,7 @@ static void printOperandList(Operation::operand_range operands, } static ParseResult parseOptionalOperand(OpAsmParser &parser, StringRef keyword, - OpAsmParser::OperandType &operand, + OpAsmParser::UnresolvedOperand &operand, Type type, bool &hasOptional, OperationState &result) { hasOptional = false; @@ -113,7 +113,7 @@ static ParseResult parseOptionalOperand(OpAsmParser &parser, StringRef keyword, static ParseResult parseOperandAndType(OpAsmParser &parser, OperationState &result) { - OpAsmParser::OperandType operand; + OpAsmParser::UnresolvedOperand operand; Type type; if (parser.parseOperand(operand) || parser.parseColonType(type) || parser.resolveOperand(operand, type, result.operands)) @@ -128,7 +128,7 @@ static ParseResult parseOperandAndType(OpAsmParser &parser, static OptionalParseResult parseOptionalOperandAndType(OpAsmParser &parser, StringRef keyword, OperationState &result) { - OpAsmParser::OperandType operand; + OpAsmParser::UnresolvedOperand operand; if (succeeded(parser.parseOptionalKeyword(keyword))) { return failure(parser.parseLParen() || parseOperandAndType(parser, result) || parser.parseRParen()); @@ -220,7 +220,7 @@ struct RemoveConstantIfCondition : public OpRewritePattern { /// region attr-dict? ParseResult ParallelOp::parse(OpAsmParser &parser, OperationState &result) { Builder &builder = parser.getBuilder(); - SmallVector privateOperands, + SmallVector privateOperands, firstprivateOperands, copyOperands, copyinOperands, copyinReadonlyOperands, copyoutOperands, copyoutZeroOperands, createOperands, createZeroOperands, noCreateOperands, presentOperands, @@ -233,7 +233,7 @@ ParseResult ParallelOp::parse(OpAsmParser &parser, OperationState &result) { firstprivateOperandTypes; SmallVector operandTypes; - OpAsmParser::OperandType ifCond, selfCond; + OpAsmParser::UnresolvedOperand ifCond, selfCond; bool hasIfCond = false, hasSelfCond = false; OptionalParseResult async, numGangs, numWorkers, vectorLength; Type i1Type = builder.getI1Type(); @@ -516,8 +516,9 @@ ParseResult LoopOp::parse(OpAsmParser &parser, OperationState &result) { Builder &builder = parser.getBuilder(); unsigned executionMapping = OpenACCExecMapping::NONE; SmallVector operandTypes; - SmallVector privateOperands, reductionOperands; - SmallVector tileOperands; + SmallVector privateOperands, + reductionOperands; + SmallVector tileOperands; OptionalParseResult gangNum, gangStatic, worker, vector; // gang? diff --git a/mlir/lib/Dialect/OpenMP/IR/OpenMPDialect.cpp b/mlir/lib/Dialect/OpenMP/IR/OpenMPDialect.cpp index 602b26c..0194132 100644 --- a/mlir/lib/Dialect/OpenMP/IR/OpenMPDialect.cpp +++ b/mlir/lib/Dialect/OpenMP/IR/OpenMPDialect.cpp @@ -83,13 +83,13 @@ void ParallelOp::build(OpBuilder &builder, OperationState &state, /// ssa-id-and-type ::= ssa-id `:` type static ParseResult parseAllocateAndAllocator( OpAsmParser &parser, - SmallVectorImpl &operandsAllocate, + SmallVectorImpl &operandsAllocate, SmallVectorImpl &typesAllocate, - SmallVectorImpl &operandsAllocator, + SmallVectorImpl &operandsAllocator, SmallVectorImpl &typesAllocator) { return parser.parseCommaSeparatedList([&]() -> ParseResult { - OpAsmParser::OperandType operand; + OpAsmParser::UnresolvedOperand operand; Type type; if (parser.parseOperand(operand) || parser.parseColonType(type)) return failure(); @@ -177,16 +177,16 @@ LogicalResult ParallelOp::verify() { /// linear-val := ssa-id-and-type `=` ssa-id-and-type static ParseResult parseLinearClause(OpAsmParser &parser, - SmallVectorImpl &vars, + SmallVectorImpl &vars, SmallVectorImpl &types, - SmallVectorImpl &stepVars) { + SmallVectorImpl &stepVars) { if (parser.parseLParen()) return failure(); do { - OpAsmParser::OperandType var; + OpAsmParser::UnresolvedOperand var; Type type; - OpAsmParser::OperandType stepVar; + OpAsmParser::UnresolvedOperand stepVar; if (parser.parseOperand(var) || parser.parseEqual() || parser.parseOperand(stepVar) || parser.parseColonType(type)) return failure(); @@ -264,7 +264,7 @@ verifyScheduleModifiers(OpAsmParser &parser, static ParseResult parseScheduleClause(OpAsmParser &parser, SmallString<8> &schedule, SmallVectorImpl> &modifiers, - Optional &chunkSize, + Optional &chunkSize, Type &chunkType) { if (parser.parseLParen()) return failure(); @@ -276,7 +276,7 @@ parseScheduleClause(OpAsmParser &parser, SmallString<8> &schedule, schedule = keyword; if (keyword == "static" || keyword == "dynamic" || keyword == "guided") { if (succeeded(parser.parseOptionalEqual())) { - chunkSize = OpAsmParser::OperandType{}; + chunkSize = OpAsmParser::UnresolvedOperand{}; if (parser.parseOperand(*chunkSize) || parser.parseColonType(chunkType)) return failure(); } else { @@ -326,9 +326,11 @@ static void printScheduleClause(OpAsmPrinter &p, ClauseScheduleKind sched, /// reduction-entry-list ::= reduction-entry /// | reduction-entry-list `,` reduction-entry /// reduction-entry ::= symbol-ref `->` ssa-id `:` type -static ParseResult parseReductionVarList( - OpAsmParser &parser, SmallVectorImpl &operands, - SmallVectorImpl &types, ArrayAttr &redcuctionSymbols) { +static ParseResult +parseReductionVarList(OpAsmParser &parser, + SmallVectorImpl &operands, + SmallVectorImpl &types, + ArrayAttr &redcuctionSymbols) { SmallVector reductionVec; do { if (parser.parseAttribute(reductionVec.emplace_back()) || @@ -524,20 +526,20 @@ static ParseResult parseClauses(OpAsmParser &parser, OperationState &result, StringRef opName = result.name.getStringRef(); // Containers for storing operands, types and attributes for various clauses - SmallVector allocates, allocators; + SmallVector allocates, allocators; SmallVector allocateTypes, allocatorTypes; ArrayAttr reductions; - SmallVector reductionVars; + SmallVector reductionVars; SmallVector reductionVarTypes; - SmallVector linears; + SmallVector linears; SmallVector linearTypes; - SmallVector linearSteps; + SmallVector linearSteps; SmallString<8> schedule; SmallVector> modifiers; - Optional scheduleChunkSize; + Optional scheduleChunkSize; Type scheduleChunkType; // Compute the position of clauses in operand segments @@ -746,7 +748,7 @@ LogicalResult SectionsOp::verifyRegions() { /// | reduction ParseResult WsLoopOp::parse(OpAsmParser &parser, OperationState &result) { // Parse an opening `(` followed by induction variables followed by `)` - SmallVector ivs; + SmallVector ivs; if (parser.parseRegionArgumentList(ivs, /*requiredOperandCount=*/-1, OpAsmParser::Delimiter::Paren)) return failure(); @@ -757,13 +759,13 @@ ParseResult WsLoopOp::parse(OpAsmParser &parser, OperationState &result) { return failure(); // Parse loop bounds. - SmallVector lower; + SmallVector lower; if (parser.parseEqual() || parser.parseOperandList(lower, numIVs, OpAsmParser::Delimiter::Paren) || parser.resolveOperands(lower, loopVarType, result.operands)) return failure(); - SmallVector upper; + SmallVector upper; if (parser.parseKeyword("to") || parser.parseOperandList(upper, numIVs, OpAsmParser::Delimiter::Paren) || parser.resolveOperands(upper, loopVarType, result.operands)) @@ -775,7 +777,7 @@ ParseResult WsLoopOp::parse(OpAsmParser &parser, OperationState &result) { } // Parse step values. - SmallVector steps; + SmallVector steps; if (parser.parseKeyword("step") || parser.parseOperandList(steps, numIVs, OpAsmParser::Delimiter::Paren) || parser.resolveOperands(steps, loopVarType, result.operands)) @@ -794,7 +796,7 @@ ParseResult WsLoopOp::parse(OpAsmParser &parser, OperationState &result) { // Now parse the body. Region *body = result.addRegion(); SmallVector ivTypes(numIVs, loopVarType); - SmallVector blockArgs(ivs); + SmallVector blockArgs(ivs); if (parser.parseRegion(*body, blockArgs, ivTypes)) return failure(); return success(); @@ -851,7 +853,7 @@ void WsLoopOp::print(OpAsmPrinter &p) { /// clause ::= TODO ParseResult SimdLoopOp::parse(OpAsmParser &parser, OperationState &result) { // Parse an opening `(` followed by induction variables followed by `)` - SmallVector ivs; + SmallVector ivs; if (parser.parseRegionArgumentList(ivs, /*requiredOperandCount=*/-1, OpAsmParser::Delimiter::Paren)) return failure(); @@ -860,19 +862,19 @@ ParseResult SimdLoopOp::parse(OpAsmParser &parser, OperationState &result) { if (parser.parseColonType(loopVarType)) return failure(); // Parse loop bounds. - SmallVector lower; + SmallVector lower; if (parser.parseEqual() || parser.parseOperandList(lower, numIVs, OpAsmParser::Delimiter::Paren) || parser.resolveOperands(lower, loopVarType, result.operands)) return failure(); - SmallVector upper; + SmallVector upper; if (parser.parseKeyword("to") || parser.parseOperandList(upper, numIVs, OpAsmParser::Delimiter::Paren) || parser.resolveOperands(upper, loopVarType, result.operands)) return failure(); // Parse step values. - SmallVector steps; + SmallVector steps; if (parser.parseKeyword("step") || parser.parseOperandList(steps, numIVs, OpAsmParser::Delimiter::Paren) || parser.resolveOperands(steps, loopVarType, result.operands)) @@ -886,7 +888,7 @@ ParseResult SimdLoopOp::parse(OpAsmParser &parser, OperationState &result) { // Now parse the body. Region *body = result.addRegion(); SmallVector ivTypes(numIVs, loopVarType); - SmallVector blockArgs(ivs); + SmallVector blockArgs(ivs); if (parser.parseRegion(*body, blockArgs, ivTypes)) return failure(); return success(); diff --git a/mlir/lib/Dialect/PDL/IR/PDL.cpp b/mlir/lib/Dialect/PDL/IR/PDL.cpp index 3a0280c..1d22cf5 100644 --- a/mlir/lib/Dialect/PDL/IR/PDL.cpp +++ b/mlir/lib/Dialect/PDL/IR/PDL.cpp @@ -142,14 +142,15 @@ LogicalResult OperandsOp::verify() { return verifyHasBindingUse(*this); } //===----------------------------------------------------------------------===// static ParseResult parseOperationOpAttributes( - OpAsmParser &p, SmallVectorImpl &attrOperands, + OpAsmParser &p, + SmallVectorImpl &attrOperands, ArrayAttr &attrNamesAttr) { Builder &builder = p.getBuilder(); SmallVector attrNames; if (succeeded(p.parseOptionalLBrace())) { do { StringAttr nameAttr; - OpAsmParser::OperandType operand; + OpAsmParser::UnresolvedOperand operand; if (p.parseAttribute(nameAttr) || p.parseEqual() || p.parseOperand(operand)) return failure(); diff --git a/mlir/lib/Dialect/PDLInterp/IR/PDLInterp.cpp b/mlir/lib/Dialect/PDLInterp/IR/PDLInterp.cpp index 9b740e5..a5415e5 100644 --- a/mlir/lib/Dialect/PDLInterp/IR/PDLInterp.cpp +++ b/mlir/lib/Dialect/PDLInterp/IR/PDLInterp.cpp @@ -48,14 +48,15 @@ static LogicalResult verifySwitchOp(OpT op) { //===----------------------------------------------------------------------===// static ParseResult parseCreateOperationOpAttributes( - OpAsmParser &p, SmallVectorImpl &attrOperands, + OpAsmParser &p, + SmallVectorImpl &attrOperands, ArrayAttr &attrNamesAttr) { Builder &builder = p.getBuilder(); SmallVector attrNames; if (succeeded(p.parseOptionalLBrace())) { do { StringAttr nameAttr; - OpAsmParser::OperandType operand; + OpAsmParser::UnresolvedOperand operand; if (p.parseAttribute(nameAttr) || p.parseEqual() || p.parseOperand(operand)) return failure(); @@ -100,7 +101,7 @@ void ForEachOp::build(::mlir::OpBuilder &builder, ::mlir::OperationState &state, ParseResult ForEachOp::parse(OpAsmParser &parser, OperationState &result) { // Parse the loop variable followed by type. - OpAsmParser::OperandType loopVariable; + OpAsmParser::UnresolvedOperand loopVariable; Type loopVariableType; if (parser.parseRegionArgument(loopVariable) || parser.parseColonType(loopVariableType)) @@ -111,7 +112,7 @@ ParseResult ForEachOp::parse(OpAsmParser &parser, OperationState &result) { return failure(); // Parse the operand (value range). - OpAsmParser::OperandType operandInfo; + OpAsmParser::UnresolvedOperand operandInfo; if (parser.parseOperand(operandInfo)) return failure(); diff --git a/mlir/lib/Dialect/SCF/SCF.cpp b/mlir/lib/Dialect/SCF/SCF.cpp index 114d93b..8410f89 100644 --- a/mlir/lib/Dialect/SCF/SCF.cpp +++ b/mlir/lib/Dialect/SCF/SCF.cpp @@ -393,7 +393,7 @@ void ForOp::print(OpAsmPrinter &p) { ParseResult ForOp::parse(OpAsmParser &parser, OperationState &result) { auto &builder = parser.getBuilder(); - OpAsmParser::OperandType inductionVariable, lb, ub, step; + OpAsmParser::UnresolvedOperand inductionVariable, lb, ub, step; // Parse the induction variable followed by '='. if (parser.parseRegionArgument(inductionVariable) || parser.parseEqual()) return failure(); @@ -409,7 +409,7 @@ ParseResult ForOp::parse(OpAsmParser &parser, OperationState &result) { return failure(); // Parse the optional initial iteration arguments. - SmallVector regionArgs, operands; + SmallVector regionArgs, operands; SmallVector argTypes; regionArgs.push_back(inductionVariable); @@ -1125,7 +1125,7 @@ ParseResult IfOp::parse(OpAsmParser &parser, OperationState &result) { Region *elseRegion = result.addRegion(); auto &builder = parser.getBuilder(); - OpAsmParser::OperandType cond; + OpAsmParser::UnresolvedOperand cond; Type i1Type = builder.getIntegerType(1); if (parser.parseOperand(cond) || parser.resolveOperand(cond, i1Type, result.operands)) @@ -1979,20 +1979,20 @@ LogicalResult ParallelOp::verify() { ParseResult ParallelOp::parse(OpAsmParser &parser, OperationState &result) { auto &builder = parser.getBuilder(); // Parse an opening `(` followed by induction variables followed by `)` - SmallVector ivs; + SmallVector ivs; if (parser.parseRegionArgumentList(ivs, /*requiredOperandCount=*/-1, OpAsmParser::Delimiter::Paren)) return failure(); // Parse loop bounds. - SmallVector lower; + SmallVector lower; if (parser.parseEqual() || parser.parseOperandList(lower, ivs.size(), OpAsmParser::Delimiter::Paren) || parser.resolveOperands(lower, builder.getIndexType(), result.operands)) return failure(); - SmallVector upper; + SmallVector upper; if (parser.parseKeyword("to") || parser.parseOperandList(upper, ivs.size(), OpAsmParser::Delimiter::Paren) || @@ -2000,7 +2000,7 @@ ParseResult ParallelOp::parse(OpAsmParser &parser, OperationState &result) { return failure(); // Parse step values. - SmallVector steps; + SmallVector steps; if (parser.parseKeyword("step") || parser.parseOperandList(steps, ivs.size(), OpAsmParser::Delimiter::Paren) || @@ -2008,7 +2008,7 @@ ParseResult ParallelOp::parse(OpAsmParser &parser, OperationState &result) { return failure(); // Parse init values. - SmallVector initVals; + SmallVector initVals; if (succeeded(parser.parseOptionalKeyword("init"))) { if (parser.parseOperandList(initVals, /*requiredOperandCount=*/-1, OpAsmParser::Delimiter::Paren)) @@ -2290,7 +2290,7 @@ LogicalResult ReduceOp::verifyRegions() { ParseResult ReduceOp::parse(OpAsmParser &parser, OperationState &result) { // Parse an opening `(` followed by the reduced value followed by `)` - OpAsmParser::OperandType operand; + OpAsmParser::UnresolvedOperand operand; if (parser.parseLParen() || parser.parseOperand(operand) || parser.parseRParen()) return failure(); @@ -2385,7 +2385,7 @@ void WhileOp::getSuccessorRegions(Optional index, /// assignment-list ::= assignment | assignment `,` assignment-list /// assignment ::= ssa-value `=` ssa-value ParseResult scf::WhileOp::parse(OpAsmParser &parser, OperationState &result) { - SmallVector regionArgs, operands; + SmallVector regionArgs, operands; Region *before = result.addRegion(); Region *after = result.addRegion(); diff --git a/mlir/lib/Dialect/SPIRV/IR/SPIRVOps.cpp b/mlir/lib/Dialect/SPIRV/IR/SPIRVOps.cpp index fae7a69..4ffde49 100644 --- a/mlir/lib/Dialect/SPIRV/IR/SPIRVOps.cpp +++ b/mlir/lib/Dialect/SPIRV/IR/SPIRVOps.cpp @@ -66,7 +66,7 @@ static constexpr const char kCompositeSpecConstituentsName[] = "constituents"; static ParseResult parseOneResultSameOperandTypeOp(OpAsmParser &parser, OperationState &result) { - SmallVector ops; + SmallVector ops; Type type; // If the operand list is in-between parentheses, then we have a generic form. // (see the fallback in `printOneResultOp`). @@ -766,8 +766,8 @@ static ParseResult parseAtomicUpdateOp(OpAsmParser &parser, OperationState &state, bool hasValue) { spirv::Scope scope; spirv::MemorySemantics memoryScope; - SmallVector operandInfo; - OpAsmParser::OperandType ptrInfo, valueInfo; + SmallVector operandInfo; + OpAsmParser::UnresolvedOperand ptrInfo, valueInfo; Type type; SMLoc loc; if (parseEnumStrAttr(scope, parser, state, kMemoryScopeAttrName) || @@ -846,7 +846,7 @@ static ParseResult parseGroupNonUniformArithmeticOp(OpAsmParser &parser, OperationState &state) { spirv::Scope executionScope; spirv::GroupOperation groupOperation; - OpAsmParser::OperandType valueInfo; + OpAsmParser::UnresolvedOperand valueInfo; if (parseEnumStrAttr(executionScope, parser, state, kExecutionScopeAttrName) || parseEnumStrAttr(groupOperation, parser, state, @@ -854,9 +854,9 @@ static ParseResult parseGroupNonUniformArithmeticOp(OpAsmParser &parser, parser.parseOperand(valueInfo)) return failure(); - Optional clusterSizeInfo; + Optional clusterSizeInfo; if (succeeded(parser.parseOptionalKeyword(kClusterSize))) { - clusterSizeInfo = OpAsmParser::OperandType(); + clusterSizeInfo = OpAsmParser::UnresolvedOperand(); if (parser.parseLParen() || parser.parseOperand(*clusterSizeInfo) || parser.parseRParen()) return failure(); @@ -1029,8 +1029,8 @@ void spirv::AccessChainOp::build(OpBuilder &builder, OperationState &state, ParseResult spirv::AccessChainOp::parse(OpAsmParser &parser, OperationState &state) { - OpAsmParser::OperandType ptrInfo; - SmallVector indicesInfo; + OpAsmParser::UnresolvedOperand ptrInfo; + SmallVector indicesInfo; Type type; auto loc = parser.getCurrentLocation(); SmallVector indicesTypes; @@ -1143,7 +1143,7 @@ static ParseResult parseAtomicCompareExchangeImpl(OpAsmParser &parser, OperationState &state) { spirv::Scope memoryScope; spirv::MemorySemantics equalSemantics, unequalSemantics; - SmallVector operandInfo; + SmallVector operandInfo; Type type; if (parseEnumStrAttr(memoryScope, parser, state, kMemoryScopeAttrName) || parseEnumStrAttr(equalSemantics, parser, state, @@ -1265,7 +1265,7 @@ ParseResult spirv::AtomicExchangeOp::parse(OpAsmParser &parser, OperationState &state) { spirv::Scope memoryScope; spirv::MemorySemantics semantics; - SmallVector operandInfo; + SmallVector operandInfo; Type type; if (parseEnumStrAttr(memoryScope, parser, state, kMemoryScopeAttrName) || parseEnumStrAttr(semantics, parser, state, kSemanticsAttrName) || @@ -1535,7 +1535,7 @@ spirv::BranchConditionalOp::getMutableSuccessorOperands(unsigned index) { ParseResult spirv::BranchConditionalOp::parse(OpAsmParser &parser, OperationState &state) { auto &builder = parser.getBuilder(); - OpAsmParser::OperandType condInfo; + OpAsmParser::UnresolvedOperand condInfo; Block *dest; // Parse the condition. @@ -1620,7 +1620,7 @@ LogicalResult spirv::BranchConditionalOp::verify() { ParseResult spirv::CompositeConstructOp::parse(OpAsmParser &parser, OperationState &state) { - SmallVector operands; + SmallVector operands; Type type; auto loc = parser.getCurrentLocation(); @@ -1699,7 +1699,7 @@ void spirv::CompositeExtractOp::build(OpBuilder &builder, OperationState &state, ParseResult spirv::CompositeExtractOp::parse(OpAsmParser &parser, OperationState &state) { - OpAsmParser::OperandType compositeInfo; + OpAsmParser::UnresolvedOperand compositeInfo; Attribute indicesAttr; Type compositeType; SMLoc attrLocation; @@ -1753,7 +1753,7 @@ void spirv::CompositeInsertOp::build(OpBuilder &builder, OperationState &state, ParseResult spirv::CompositeInsertOp::parse(OpAsmParser &parser, OperationState &state) { - SmallVector operands; + SmallVector operands; Type objectType, compositeType; Attribute indicesAttr; auto loc = parser.getCurrentLocation(); @@ -2071,7 +2071,7 @@ void spirv::EntryPointOp::build(OpBuilder &builder, OperationState &state, ParseResult spirv::EntryPointOp::parse(OpAsmParser &parser, OperationState &state) { spirv::ExecutionModel execModel; - SmallVector identifiers; + SmallVector identifiers; SmallVector idTypes; SmallVector interfaceVars; @@ -2194,7 +2194,7 @@ LogicalResult spirv::UConvertOp::verify() { //===----------------------------------------------------------------------===// ParseResult spirv::FuncOp::parse(OpAsmParser &parser, OperationState &state) { - SmallVector entryArgs; + SmallVector entryArgs; SmallVector argAttrs; SmallVector resultAttrs; SmallVector argTypes; @@ -2601,7 +2601,7 @@ ParseResult spirv::SubgroupBlockReadINTELOp::parse(OpAsmParser &parser, OperationState &state) { // Parse the storage class specification spirv::StorageClass storageClass; - OpAsmParser::OperandType ptrInfo; + OpAsmParser::UnresolvedOperand ptrInfo; Type elementType; if (parseEnumStrAttr(storageClass, parser) || parser.parseOperand(ptrInfo) || parser.parseColon() || parser.parseType(elementType)) { @@ -2639,7 +2639,7 @@ ParseResult spirv::SubgroupBlockWriteINTELOp::parse(OpAsmParser &parser, OperationState &state) { // Parse the storage class specification spirv::StorageClass storageClass; - SmallVector operandInfo; + SmallVector operandInfo; auto loc = parser.getCurrentLocation(); Type elementType; if (parseEnumStrAttr(storageClass, parser) || @@ -2857,7 +2857,7 @@ void spirv::LoadOp::build(OpBuilder &builder, OperationState &state, ParseResult spirv::LoadOp::parse(OpAsmParser &parser, OperationState &state) { // Parse the storage class specification spirv::StorageClass storageClass; - OpAsmParser::OperandType ptrInfo; + OpAsmParser::UnresolvedOperand ptrInfo; Type elementType; if (parseEnumStrAttr(storageClass, parser) || parser.parseOperand(ptrInfo) || parseMemoryAccessAttributes(parser, state) || @@ -3477,7 +3477,7 @@ LogicalResult spirv::SpecConstantOp::verify() { ParseResult spirv::StoreOp::parse(OpAsmParser &parser, OperationState &state) { // Parse the storage class specification spirv::StorageClass storageClass; - SmallVector operandInfo; + SmallVector operandInfo; auto loc = parser.getCurrentLocation(); Type elementType; if (parseEnumStrAttr(storageClass, parser) || @@ -3541,9 +3541,9 @@ LogicalResult spirv::UnreachableOp::verify() { ParseResult spirv::VariableOp::parse(OpAsmParser &parser, OperationState &state) { // Parse optional initializer - Optional initInfo; + Optional initInfo; if (succeeded(parser.parseOptionalKeyword("init"))) { - initInfo = OpAsmParser::OperandType(); + initInfo = OpAsmParser::UnresolvedOperand(); if (parser.parseLParen() || parser.parseOperand(*initInfo) || parser.parseRParen()) return failure(); @@ -3670,7 +3670,7 @@ LogicalResult spirv::VectorShuffleOp::verify() { ParseResult spirv::CooperativeMatrixLoadNVOp::parse(OpAsmParser &parser, OperationState &state) { - SmallVector operandInfo; + SmallVector operandInfo; Type strideType = parser.getBuilder().getIntegerType(32); Type columnMajorType = parser.getBuilder().getIntegerType(1); Type ptrType; @@ -3728,7 +3728,7 @@ LogicalResult spirv::CooperativeMatrixLoadNVOp::verify() { ParseResult spirv::CooperativeMatrixStoreNVOp::parse(OpAsmParser &parser, OperationState &state) { - SmallVector operandInfo; + SmallVector operandInfo; Type strideType = parser.getBuilder().getIntegerType(32); Type columnMajorType = parser.getBuilder().getIntegerType(1); Type ptrType; @@ -3859,10 +3859,10 @@ void spirv::CopyMemoryOp::print(OpAsmPrinter &printer) { ParseResult spirv::CopyMemoryOp::parse(OpAsmParser &parser, OperationState &state) { spirv::StorageClass targetStorageClass; - OpAsmParser::OperandType targetPtrInfo; + OpAsmParser::UnresolvedOperand targetPtrInfo; spirv::StorageClass sourceStorageClass; - OpAsmParser::OperandType sourcePtrInfo; + OpAsmParser::UnresolvedOperand sourcePtrInfo; Type elementType; @@ -4325,8 +4325,8 @@ LogicalResult spirv::ImageQuerySizeOp::verify() { static ParseResult parsePtrAccessChainOpImpl(StringRef opName, OpAsmParser &parser, OperationState &state) { - OpAsmParser::OperandType ptrInfo; - SmallVector indicesInfo; + OpAsmParser::UnresolvedOperand ptrInfo; + SmallVector indicesInfo; Type type; auto loc = parser.getCurrentLocation(); SmallVector indicesTypes; diff --git a/mlir/lib/Dialect/Shape/IR/Shape.cpp b/mlir/lib/Dialect/Shape/IR/Shape.cpp index 4a21081..32be1db 100644 --- a/mlir/lib/Dialect/Shape/IR/Shape.cpp +++ b/mlir/lib/Dialect/Shape/IR/Shape.cpp @@ -257,7 +257,7 @@ ParseResult AssumingOp::parse(OpAsmParser &parser, OperationState &result) { Region *doRegion = result.addRegion(); auto &builder = parser.getBuilder(); - OpAsmParser::OperandType cond; + OpAsmParser::UnresolvedOperand cond; if (parser.parseOperand(cond) || parser.resolveOperand(cond, builder.getType(), result.operands)) @@ -1832,7 +1832,7 @@ LogicalResult ReduceOp::verify() { ParseResult ReduceOp::parse(OpAsmParser &parser, OperationState &result) { // Parse operands. - SmallVector operands; + SmallVector operands; Type shapeOrExtentTensorType; if (parser.parseOperandList(operands, /*requiredOperandCount=*/-1, OpAsmParser::Delimiter::Paren) || diff --git a/mlir/lib/Dialect/Tensor/IR/TensorOps.cpp b/mlir/lib/Dialect/Tensor/IR/TensorOps.cpp index b95a214..1c8065ec 100644 --- a/mlir/lib/Dialect/Tensor/IR/TensorOps.cpp +++ b/mlir/lib/Dialect/Tensor/IR/TensorOps.cpp @@ -1734,7 +1734,7 @@ void printInferType(OpAsmPrinter &printer, Operation *op, Value optOperand, Type typeToInfer, Type typeToInferFrom) {} ParseResult parseInferType(OpAsmParser &parser, - Optional optOperand, + Optional optOperand, Type &typeToInfer, Type typeToInferFrom) { if (optOperand) typeToInfer = typeToInferFrom; diff --git a/mlir/lib/Dialect/Vector/IR/VectorOps.cpp b/mlir/lib/Dialect/Vector/IR/VectorOps.cpp index fd6fea2..da52e1b 100644 --- a/mlir/lib/Dialect/Vector/IR/VectorOps.cpp +++ b/mlir/lib/Dialect/Vector/IR/VectorOps.cpp @@ -416,7 +416,7 @@ LogicalResult ReductionOp::verify() { } ParseResult ReductionOp::parse(OpAsmParser &parser, OperationState &result) { - SmallVector operandsInfo; + SmallVector operandsInfo; Type redType; Type resType; CombiningKindAttr kindAttr; @@ -526,10 +526,10 @@ void vector::ContractionOp::build(OpBuilder &builder, OperationState &result, } ParseResult ContractionOp::parse(OpAsmParser &parser, OperationState &result) { - OpAsmParser::OperandType lhsInfo; - OpAsmParser::OperandType rhsInfo; - OpAsmParser::OperandType accInfo; - SmallVector masksInfo; + OpAsmParser::UnresolvedOperand lhsInfo; + OpAsmParser::UnresolvedOperand rhsInfo; + OpAsmParser::UnresolvedOperand accInfo; + SmallVector masksInfo; SmallVector types; Type resultType; auto loc = parser.getCurrentLocation(); @@ -2097,7 +2097,7 @@ void OuterProductOp::print(OpAsmPrinter &p) { } ParseResult OuterProductOp::parse(OpAsmParser &parser, OperationState &result) { - SmallVector operandsInfo; + SmallVector operandsInfo; Type tLHS, tRHS; if (parser.parseOperandList(operandsInfo) || parser.parseOptionalAttrDict(result.attributes) || @@ -2736,11 +2736,11 @@ void TransferReadOp::print(OpAsmPrinter &p) { ParseResult TransferReadOp::parse(OpAsmParser &parser, OperationState &result) { auto &builder = parser.getBuilder(); SMLoc typesLoc; - OpAsmParser::OperandType sourceInfo; - SmallVector indexInfo; - OpAsmParser::OperandType paddingInfo; + OpAsmParser::UnresolvedOperand sourceInfo; + SmallVector indexInfo; + OpAsmParser::UnresolvedOperand paddingInfo; SmallVector types; - OpAsmParser::OperandType maskInfo; + OpAsmParser::UnresolvedOperand maskInfo; // Parsing with support for paddingValue. if (parser.parseOperand(sourceInfo) || parser.parseOperandList(indexInfo, OpAsmParser::Delimiter::Square) || @@ -3115,10 +3115,10 @@ ParseResult TransferWriteOp::parse(OpAsmParser &parser, OperationState &result) { auto &builder = parser.getBuilder(); SMLoc typesLoc; - OpAsmParser::OperandType vectorInfo, sourceInfo; - SmallVector indexInfo; + OpAsmParser::UnresolvedOperand vectorInfo, sourceInfo; + SmallVector indexInfo; SmallVector types; - OpAsmParser::OperandType maskInfo; + OpAsmParser::UnresolvedOperand maskInfo; if (parser.parseOperand(vectorInfo) || parser.parseComma() || parser.parseOperand(sourceInfo) || parser.parseOperandList(indexInfo, OpAsmParser::Delimiter::Square)) diff --git a/mlir/lib/IR/FunctionImplementation.cpp b/mlir/lib/IR/FunctionImplementation.cpp index 0da923d..2725d48 100644 --- a/mlir/lib/IR/FunctionImplementation.cpp +++ b/mlir/lib/IR/FunctionImplementation.cpp @@ -15,7 +15,7 @@ using namespace mlir; ParseResult mlir::function_interface_impl::parseFunctionArgumentList( OpAsmParser &parser, bool allowAttributes, bool allowVariadic, - SmallVectorImpl &argNames, + SmallVectorImpl &argNames, SmallVectorImpl &argTypes, SmallVectorImpl &argAttrs, SmallVectorImpl &argLocations, bool &isVariadic) { if (parser.parseLParen()) @@ -28,7 +28,7 @@ ParseResult mlir::function_interface_impl::parseFunctionArgumentList( SMLoc loc = parser.getCurrentLocation(); // Parse argument name if present. - OpAsmParser::OperandType argument; + OpAsmParser::UnresolvedOperand argument; Type argumentType; if (succeeded(parser.parseOptionalRegionArgument(argument)) && !argument.name.empty()) { @@ -133,7 +133,7 @@ parseFunctionResultList(OpAsmParser &parser, SmallVectorImpl &resultTypes, ParseResult mlir::function_interface_impl::parseFunctionSignature( OpAsmParser &parser, bool allowVariadic, - SmallVectorImpl &argNames, + SmallVectorImpl &argNames, SmallVectorImpl &argTypes, SmallVectorImpl &argAttrs, SmallVectorImpl &argLocations, bool &isVariadic, SmallVectorImpl &resultTypes, @@ -194,7 +194,7 @@ void mlir::function_interface_impl::addArgAndResultAttrs( ParseResult mlir::function_interface_impl::parseFunctionOp( OpAsmParser &parser, OperationState &result, bool allowVariadic, FuncTypeBuilder funcTypeBuilder) { - SmallVector entryArgs; + SmallVector entryArgs; SmallVector argAttrs; SmallVector resultAttrs; SmallVector argTypes; diff --git a/mlir/lib/Interfaces/ViewLikeInterface.cpp b/mlir/lib/Interfaces/ViewLikeInterface.cpp index 0e772ef..6f575cf 100644 --- a/mlir/lib/Interfaces/ViewLikeInterface.cpp +++ b/mlir/lib/Interfaces/ViewLikeInterface.cpp @@ -105,10 +105,10 @@ void mlir::printOperandsOrIntegersSizesList(OpAsmPrinter &p, Operation *op, } template -static ParseResult -parseOperandsOrIntegersImpl(OpAsmParser &parser, - SmallVectorImpl &values, - ArrayAttr &integers) { +static ParseResult parseOperandsOrIntegersImpl( + OpAsmParser &parser, + SmallVectorImpl &values, + ArrayAttr &integers) { if (failed(parser.parseLSquare())) return failure(); // 0-D. @@ -119,7 +119,7 @@ parseOperandsOrIntegersImpl(OpAsmParser &parser, SmallVector attrVals; while (true) { - OpAsmParser::OperandType operand; + OpAsmParser::UnresolvedOperand operand; auto res = parser.parseOptionalOperand(operand); if (res.hasValue() && succeeded(res.getValue())) { values.push_back(operand); @@ -143,14 +143,16 @@ parseOperandsOrIntegersImpl(OpAsmParser &parser, } ParseResult mlir::parseOperandsOrIntegersOffsetsOrStridesList( - OpAsmParser &parser, SmallVectorImpl &values, + OpAsmParser &parser, + SmallVectorImpl &values, ArrayAttr &integers) { return parseOperandsOrIntegersImpl( parser, values, integers); } ParseResult mlir::parseOperandsOrIntegersSizesList( - OpAsmParser &parser, SmallVectorImpl &values, + OpAsmParser &parser, + SmallVectorImpl &values, ArrayAttr &integers) { return parseOperandsOrIntegersImpl(parser, values, integers); diff --git a/mlir/lib/Parser/Parser.cpp b/mlir/lib/Parser/Parser.cpp index c750275..178926c 100644 --- a/mlir/lib/Parser/Parser.cpp +++ b/mlir/lib/Parser/Parser.cpp @@ -334,7 +334,7 @@ public: using OpOrArgument = llvm::PointerUnion; /// Parse an optional trailing location and add it to the specifier Operation - /// or `OperandType` if present. + /// or `UnresolvedOperand` if present. /// /// trailing-location ::= (`loc` (`(` location `)` | attribute-alias))? /// @@ -1216,29 +1216,30 @@ public: ParseResult parseGenericOperationAfterOpName( OperationState &result, - Optional> parsedOperandTypes, + Optional> parsedUnresolvedOperands, Optional> parsedSuccessors, Optional>> parsedRegions, Optional> parsedAttributes, Optional parsedFnType) final { - // TODO: The types, OperandType and SSAUseInfo, both share the same members - // but in different order. It would be cleaner to make one alias of the - // other, making the following code redundant. + // TODO: The types, UnresolvedOperand and SSAUseInfo, both share the same + // members but in different order. It would be cleaner to make one alias of + // the other, making the following code redundant. SmallVector parsedOperandUseInfo; - if (parsedOperandTypes) { - for (const OperandType &parsedOperandType : *parsedOperandTypes) + if (parsedUnresolvedOperands) { + for (const UnresolvedOperand &parsedUnresolvedOperand : + *parsedUnresolvedOperands) parsedOperandUseInfo.push_back({ - parsedOperandType.name, - parsedOperandType.number, - parsedOperandType.location, + parsedUnresolvedOperand.name, + parsedUnresolvedOperand.number, + parsedUnresolvedOperand.location, }); } return parser.parseGenericOperationAfterOpName( result, - parsedOperandTypes ? llvm::makeArrayRef(parsedOperandUseInfo) - : llvm::None, + parsedUnresolvedOperands ? llvm::makeArrayRef(parsedOperandUseInfo) + : llvm::None, parsedSuccessors, parsedRegions, parsedAttributes, parsedFnType); } //===--------------------------------------------------------------------===// @@ -1290,7 +1291,7 @@ public: //===--------------------------------------------------------------------===// /// Parse a single operand. - ParseResult parseOperand(OperandType &result) override { + ParseResult parseOperand(UnresolvedOperand &result) override { OperationParser::SSAUseInfo useInfo; if (parser.parseSSAUse(useInfo)) return failure(); @@ -1300,7 +1301,7 @@ public: } /// Parse a single operand if present. - OptionalParseResult parseOptionalOperand(OperandType &result) override { + OptionalParseResult parseOptionalOperand(UnresolvedOperand &result) override { if (parser.getToken().is(Token::percent_identifier)) return parseOperand(result); return llvm::None; @@ -1308,7 +1309,7 @@ public: /// Parse zero or more SSA comma-separated operand references with a specified /// surrounding delimiter, and an optional required operand count. - ParseResult parseOperandList(SmallVectorImpl &result, + ParseResult parseOperandList(SmallVectorImpl &result, int requiredOperandCount = -1, Delimiter delimiter = Delimiter::None) override { return parseOperandOrRegionArgList(result, /*isOperandList=*/true, @@ -1318,7 +1319,7 @@ public: /// Parse zero or more SSA comma-separated operand or region arguments with /// optional surrounding delimiter and required operand count. ParseResult - parseOperandOrRegionArgList(SmallVectorImpl &result, + parseOperandOrRegionArgList(SmallVectorImpl &result, bool isOperandList, int requiredOperandCount = -1, Delimiter delimiter = Delimiter::None) { auto startLoc = parser.getToken().getLoc(); @@ -1342,7 +1343,7 @@ public: } auto parseOneOperand = [&]() -> ParseResult { - OperandType operandOrArg; + UnresolvedOperand operandOrArg; if (isOperandList ? parseOperand(operandOrArg) : parseRegionArgument(operandOrArg)) return failure(); @@ -1364,9 +1365,10 @@ public: /// Parse zero or more trailing SSA comma-separated trailing operand /// references with a specified surrounding delimiter, and an optional /// required operand count. A leading comma is expected before the operands. - ParseResult parseTrailingOperandList(SmallVectorImpl &result, - int requiredOperandCount, - Delimiter delimiter) override { + ParseResult + parseTrailingOperandList(SmallVectorImpl &result, + int requiredOperandCount, + Delimiter delimiter) override { if (parser.getToken().is(Token::comma)) { parseComma(); return parseOperandList(result, requiredOperandCount, delimiter); @@ -1378,7 +1380,7 @@ public: } /// Resolve an operand to an SSA value, emitting an error on failure. - ParseResult resolveOperand(const OperandType &operand, Type type, + ParseResult resolveOperand(const UnresolvedOperand &operand, Type type, SmallVectorImpl &result) override { OperationParser::SSAUseInfo operandInfo = {operand.name, operand.number, operand.location}; @@ -1390,15 +1392,15 @@ public: } /// Parse an AffineMap of SSA ids. - ParseResult parseAffineMapOfSSAIds(SmallVectorImpl &operands, - Attribute &mapAttr, StringRef attrName, - NamedAttrList &attrs, - Delimiter delimiter) override { - SmallVector dimOperands; - SmallVector symOperands; + ParseResult + parseAffineMapOfSSAIds(SmallVectorImpl &operands, + Attribute &mapAttr, StringRef attrName, + NamedAttrList &attrs, Delimiter delimiter) override { + SmallVector dimOperands; + SmallVector symOperands; auto parseElement = [&](bool isSymbol) -> ParseResult { - OperandType operand; + UnresolvedOperand operand; if (parseOperand(operand)) return failure(); if (isSymbol) @@ -1425,11 +1427,11 @@ public: /// Parse an AffineExpr of SSA ids. ParseResult - parseAffineExprOfSSAIds(SmallVectorImpl &dimOperands, - SmallVectorImpl &symbOperands, + parseAffineExprOfSSAIds(SmallVectorImpl &dimOperands, + SmallVectorImpl &symbOperands, AffineExpr &expr) override { auto parseElement = [&](bool isSymbol) -> ParseResult { - OperandType operand; + UnresolvedOperand operand; if (parseOperand(operand)) return failure(); if (isSymbol) @@ -1448,7 +1450,7 @@ public: /// Parse a region that takes `arguments` of `argTypes` types. This /// effectively defines the SSA values of `arguments` and assigns their type. - ParseResult parseRegion(Region ®ion, ArrayRef arguments, + ParseResult parseRegion(Region ®ion, ArrayRef arguments, ArrayRef argTypes, ArrayRef argLocations, bool enableNameShadowing) override { @@ -1458,7 +1460,7 @@ public: SmallVector, 2> regionArguments; for (auto pair : llvm::zip(arguments, argTypes)) { - const OperandType &operand = std::get<0>(pair); + const UnresolvedOperand &operand = std::get<0>(pair); Type type = std::get<1>(pair); OperationParser::SSAUseInfo operandInfo = {operand.name, operand.number, operand.location}; @@ -1477,7 +1479,7 @@ public: /// Parses a region if present. OptionalParseResult parseOptionalRegion(Region ®ion, - ArrayRef arguments, + ArrayRef arguments, ArrayRef argTypes, ArrayRef argLocations, bool enableNameShadowing) override { @@ -1490,10 +1492,9 @@ public: /// Parses a region if present. If the region is present, a new region is /// allocated and placed in `region`. If no region is present, `region` /// remains untouched. - OptionalParseResult - parseOptionalRegion(std::unique_ptr ®ion, - ArrayRef arguments, ArrayRef argTypes, - bool enableNameShadowing = false) override { + OptionalParseResult parseOptionalRegion( + std::unique_ptr ®ion, ArrayRef arguments, + ArrayRef argTypes, bool enableNameShadowing = false) override { if (parser.getToken().isNot(Token::l_brace)) return llvm::None; std::unique_ptr newRegion = std::make_unique(); @@ -1507,19 +1508,20 @@ public: /// Parse a region argument. The type of the argument will be resolved later /// by a call to `parseRegion`. - ParseResult parseRegionArgument(OperandType &argument) override { + ParseResult parseRegionArgument(UnresolvedOperand &argument) override { return parseOperand(argument); } /// Parse a region argument if present. - ParseResult parseOptionalRegionArgument(OperandType &argument) override { + ParseResult + parseOptionalRegionArgument(UnresolvedOperand &argument) override { if (parser.getToken().isNot(Token::percent_identifier)) return success(); return parseRegionArgument(argument); } ParseResult - parseRegionArgumentList(SmallVectorImpl &result, + parseRegionArgumentList(SmallVectorImpl &result, int requiredOperandCount = -1, Delimiter delimiter = Delimiter::None) override { return parseOperandOrRegionArgList(result, /*isOperandList=*/false, @@ -1563,14 +1565,14 @@ public: /// Parse a list of assignments of the form /// (%x1 = %y1, %x2 = %y2, ...). - OptionalParseResult - parseOptionalAssignmentList(SmallVectorImpl &lhs, - SmallVectorImpl &rhs) override { + OptionalParseResult parseOptionalAssignmentList( + SmallVectorImpl &lhs, + SmallVectorImpl &rhs) override { if (failed(parseOptionalLParen())) return llvm::None; auto parseElt = [&]() -> ParseResult { - OperandType regionArg, operand; + UnresolvedOperand regionArg, operand; if (parseRegionArgument(regionArg) || parseEqual() || parseOperand(operand)) return failure(); @@ -1584,14 +1586,14 @@ public: /// Parse a list of assignments of the form /// (%x1 = %y1 : type1, %x2 = %y2 : type2, ...). OptionalParseResult - parseOptionalAssignmentListWithTypes(SmallVectorImpl &lhs, - SmallVectorImpl &rhs, + parseOptionalAssignmentListWithTypes(SmallVectorImpl &lhs, + SmallVectorImpl &rhs, SmallVectorImpl &types) override { if (failed(parseOptionalLParen())) return llvm::None; auto parseElt = [&]() -> ParseResult { - OperandType regionArg, operand; + UnresolvedOperand regionArg, operand; Type type; if (parseRegionArgument(regionArg) || parseEqual() || parseOperand(operand) || parseColon() || parseType(type)) diff --git a/mlir/test/lib/Dialect/Test/TestDialect.cpp b/mlir/test/lib/Dialect/Test/TestDialect.cpp index 8c8a230..5d4289a 100644 --- a/mlir/test/lib/Dialect/Test/TestDialect.cpp +++ b/mlir/test/lib/Dialect/Test/TestDialect.cpp @@ -415,9 +415,8 @@ void FoldToCallOp::getCanonicalizationPatterns(RewritePatternSet &results, //===----------------------------------------------------------------------===// // Parsing -static ParseResult -parseCustomOptionalOperand(OpAsmParser &parser, - Optional &optOperand) { +static ParseResult parseCustomOptionalOperand( + OpAsmParser &parser, Optional &optOperand) { if (succeeded(parser.parseOptionalLParen())) { optOperand.emplace(); if (parser.parseOperand(*optOperand) || parser.parseRParen()) @@ -427,9 +426,9 @@ parseCustomOptionalOperand(OpAsmParser &parser, } static ParseResult parseCustomDirectiveOperands( - OpAsmParser &parser, OpAsmParser::OperandType &operand, - Optional &optOperand, - SmallVectorImpl &varOperands) { + OpAsmParser &parser, OpAsmParser::UnresolvedOperand &operand, + Optional &optOperand, + SmallVectorImpl &varOperands) { if (parser.parseOperand(operand)) return failure(); if (succeeded(parser.parseOptionalComma())) { @@ -480,10 +479,11 @@ parseCustomDirectiveWithTypeRefs(OpAsmParser &parser, Type operandType, return success(); } static ParseResult parseCustomDirectiveOperandsAndTypes( - OpAsmParser &parser, OpAsmParser::OperandType &operand, - Optional &optOperand, - SmallVectorImpl &varOperands, Type &operandType, - Type &optOperandType, SmallVectorImpl &varOperandTypes) { + OpAsmParser &parser, OpAsmParser::UnresolvedOperand &operand, + Optional &optOperand, + SmallVectorImpl &varOperands, + Type &operandType, Type &optOperandType, + SmallVectorImpl &varOperandTypes) { if (parseCustomDirectiveOperands(parser, operand, optOperand, varOperands) || parseCustomDirectiveResults(parser, operandType, optOperandType, varOperandTypes)) @@ -533,7 +533,7 @@ static ParseResult parseCustomDirectiveAttrDict(OpAsmParser &parser, return parser.parseOptionalAttrDict(attrs); } static ParseResult parseCustomDirectiveOptionalOperandRef( - OpAsmParser &parser, Optional &optOperand) { + OpAsmParser &parser, Optional &optOperand) { int64_t operandCount = 0; if (parser.parseInteger(operandCount)) return failure(); @@ -624,7 +624,7 @@ static void printCustomDirectiveOptionalOperandRef(OpAsmPrinter &printer, ParseResult IsolatedRegionOp::parse(OpAsmParser &parser, OperationState &result) { - OpAsmParser::OperandType argInfo; + OpAsmParser::UnresolvedOperand argInfo; Type argType = parser.getBuilder().getIndexType(); // Parse the input operand. @@ -774,7 +774,7 @@ ParseResult PrettyPrintedRegionOp::parse(OpAsmParser &parser, Location currLocation = parser.getEncodedSourceLoc(loc); // Parse the operands. - SmallVector operands; + SmallVector operands; if (parser.parseOperandList(operands)) return failure(); @@ -867,7 +867,7 @@ void PrettyPrintedRegionOp::print(OpAsmPrinter &p) { //===----------------------------------------------------------------------===// ParseResult PolyForOp::parse(OpAsmParser &parser, OperationState &result) { - SmallVector ivsInfo; + SmallVector ivsInfo; // Parse list of region arguments without a delimiter. if (parser.parseRegionArgumentList(ivsInfo)) return failure(); @@ -1205,7 +1205,7 @@ void RegionIfOp::print(OpAsmPrinter &p) { } ParseResult RegionIfOp::parse(OpAsmParser &parser, OperationState &result) { - SmallVector operandInfos; + SmallVector operandInfos; SmallVector operandTypes; result.regions.reserve(3); diff --git a/mlir/tools/mlir-tblgen/OpFormatGen.cpp b/mlir/tools/mlir-tblgen/OpFormatGen.cpp index 044f1b0..3bf9ad9 100644 --- a/mlir/tools/mlir-tblgen/OpFormatGen.cpp +++ b/mlir/tools/mlir-tblgen/OpFormatGen.cpp @@ -471,7 +471,7 @@ const char *const variadicOperandParserCode = R"( const char *const optionalOperandParserCode = R"( { {0}OperandsLoc = parser.getCurrentLocation(); - ::mlir::OpAsmParser::OperandType operand; + ::mlir::OpAsmParser::UnresolvedOperand operand; ::mlir::OptionalParseResult parseResult = parser.parseOptionalOperand(operand); if (parseResult.hasValue()) { @@ -787,7 +787,7 @@ static void genElementParserStorage(FormatElement *element, const Operator &op, genElementParserStorage(paramElement, op, body); } else if (isa(element)) { - body << " ::mlir::SmallVector<::mlir::OpAsmParser::OperandType, 4> " + body << " ::mlir::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> " "allOperands;\n"; } else if (isa(element)) { @@ -805,17 +805,18 @@ static void genElementParserStorage(FormatElement *element, const Operator &op, } else if (auto *operand = dyn_cast(element)) { StringRef name = operand->getVar()->name; if (operand->getVar()->isVariableLength()) { - body << " ::mlir::SmallVector<::mlir::OpAsmParser::OperandType, 4> " - << name << "Operands;\n"; + body + << " ::mlir::SmallVector<::mlir::OpAsmParser::UnresolvedOperand, 4> " + << name << "Operands;\n"; if (operand->getVar()->isVariadicOfVariadic()) { body << " llvm::SmallVector " << name << "OperandGroupSizes;\n"; } } else { - body << " ::mlir::OpAsmParser::OperandType " << name + body << " ::mlir::OpAsmParser::UnresolvedOperand " << name << "RawOperands[1];\n" - << " ::llvm::ArrayRef<::mlir::OpAsmParser::OperandType> " << name - << "Operands(" << name << "RawOperands);"; + << " ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> " + << name << "Operands(" << name << "RawOperands);"; } body << llvm::formatv(" ::llvm::SMLoc {0}OperandsLoc;\n" " (void){0}OperandsLoc;\n", @@ -929,13 +930,13 @@ static void genCustomDirectiveParser(CustomDirective *dir, MethodBody &body) { << "OperandsLoc = parser.getCurrentLocation();\n"; if (var->isOptional()) { body << llvm::formatv( - " ::llvm::Optional<::mlir::OpAsmParser::OperandType> " + " ::llvm::Optional<::mlir::OpAsmParser::UnresolvedOperand> " "{0}Operand;\n", var->name); } else if (var->isVariadicOfVariadic()) { body << llvm::formatv(" " "::llvm::SmallVector<::llvm::SmallVector<::mlir::" - "OpAsmParser::OperandType>> " + "OpAsmParser::UnresolvedOperand>> " "{0}OperandGroups;\n", var->name); } @@ -958,7 +959,7 @@ static void genCustomDirectiveParser(CustomDirective *dir, MethodBody &body) { body << llvm::formatv( " {0} {1}Operand = {1}Operands.empty() ? {0}() : " "{1}Operands[0];\n", - "::llvm::Optional<::mlir::OpAsmParser::OperandType>", + "::llvm::Optional<::mlir::OpAsmParser::UnresolvedOperand>", operand->getVar()->name); } else if (auto *type = dyn_cast(input)) { @@ -1432,7 +1433,7 @@ void OperationFormat::genParserOperandTypeResolution( // llvm::concat does not allow the case of a single range, so guard it here. body << " if (parser.resolveOperands("; if (op.getNumOperands() > 1) { - body << "::llvm::concat("; + body << "::llvm::concat("; llvm::interleaveComma(op.getOperands(), body, [&](auto &operand) { body << operand.name << "Operands"; });