MLIR  19.0.0git
Classes | Public Member Functions | List of all members
mlir::OpAsmParser Class Referenceabstract

The OpAsmParser has methods for interacting with the asm parser: parsing things from it, emitting errors etc. More...

#include "mlir/IR/OpImplementation.h"

+ Inheritance diagram for mlir::OpAsmParser:

Classes

struct  Argument
 
struct  UnresolvedOperand
 This is the representation of an operand reference. More...
 

Public Member Functions

 ~OpAsmParser () override
 
virtual ParseResult parseOptionalLocationSpecifier (std::optional< Location > &result)=0
 Parse a loc(...) specifier if present, filling in result if so. More...
 
virtual std::pair< StringRef, unsigned > getResultName (unsigned resultNo) const =0
 Return the name of the specified result in the specified syntax, as well as the sub-element in the name. More...
 
virtual size_t getNumResults () const =0
 Return the number of declared SSA results. More...
 
virtual OperationparseGenericOperation (Block *insertBlock, Block::iterator insertPt)=0
 Parse an operation in its generic form. More...
 
virtual FailureOr< OperationNameparseCustomOperationName ()=0
 Parse the name of an operation, in the custom form. More...
 
virtual ParseResult parseGenericOperationAfterOpName (OperationState &result, std::optional< ArrayRef< UnresolvedOperand >> parsedOperandType=std::nullopt, std::optional< ArrayRef< Block * >> parsedSuccessors=std::nullopt, std::optional< MutableArrayRef< std::unique_ptr< Region >>> parsedRegions=std::nullopt, std::optional< ArrayRef< NamedAttribute >> parsedAttributes=std::nullopt, std::optional< Attribute > parsedPropertiesAttribute=std::nullopt, std::optional< FunctionType > parsedFnType=std::nullopt)=0
 Parse different components, viz., use-info of operand(s), successor(s), region(s), attribute(s) and function-type, of the generic form of an operation instance and populate the input operation-state 'result' with those components. More...
 
virtual ParseResult parseOperand (UnresolvedOperand &result, bool allowResultNumber=true)=0
 Parse a single SSA value operand name along with a result number if allowResultNumber is true. More...
 
virtual OptionalParseResult parseOptionalOperand (UnresolvedOperand &result, bool allowResultNumber=true)=0
 Parse a single operand if present. More...
 
virtual ParseResult parseOperandList (SmallVectorImpl< UnresolvedOperand > &result, Delimiter delimiter=Delimiter::None, bool allowResultNumber=true, int requiredOperandCount=-1)=0
 Parse zero or more SSA comma-separated operand references with a specified surrounding delimiter, and an optional required operand count. More...
 
ParseResult parseOperandList (SmallVectorImpl< UnresolvedOperand > &result, int requiredOperandCount, Delimiter delimiter=Delimiter::None)
 Parse a specified number of comma separated operands. More...
 
ParseResult parseTrailingOperandList (SmallVectorImpl< UnresolvedOperand > &result, Delimiter delimiter=Delimiter::None)
 Parse zero or more trailing SSA comma-separated trailing operand references with a specified surrounding delimiter, and an optional required operand count. More...
 
virtual ParseResult resolveOperand (const UnresolvedOperand &operand, Type type, SmallVectorImpl< Value > &result)=0
 Resolve an operand to an SSA value, emitting an error on failure. More...
 
template<typename Operands = ArrayRef<UnresolvedOperand>>
ParseResult resolveOperands (Operands &&operands, Type type, SmallVectorImpl< Value > &result)
 Resolve a list of operands to SSA values, emitting an error on failure, or appending the results to the list on success. More...
 
template<typename Operands = ArrayRef<UnresolvedOperand>>
ParseResult resolveOperands (Operands &&operands, Type type, SMLoc loc, SmallVectorImpl< Value > &result)
 
template<typename Operands = ArrayRef<UnresolvedOperand>, typename Types = ArrayRef<Type>>
std::enable_if_t<!std::is_convertible< Types, Type >::value, ParseResultresolveOperands (Operands &&operands, Types &&types, SMLoc loc, SmallVectorImpl< Value > &result)
 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. More...
 
virtual ParseResult parseAffineMapOfSSAIds (SmallVectorImpl< UnresolvedOperand > &operands, Attribute &map, StringRef attrName, NamedAttrList &attrs, Delimiter delimiter=Delimiter::Square)=0
 Parses an affine map attribute where dims and symbols are SSA operands. More...
 
virtual ParseResult parseAffineExprOfSSAIds (SmallVectorImpl< UnresolvedOperand > &dimOperands, SmallVectorImpl< UnresolvedOperand > &symbOperands, AffineExpr &expr)=0
 Parses an affine expression where dims and symbols are SSA operands. More...
 
virtual ParseResult parseArgument (Argument &result, bool allowType=false, bool allowAttrs=false)=0
 Parse a single argument with the following syntax: More...
 
virtual OptionalParseResult parseOptionalArgument (Argument &result, bool allowType=false, bool allowAttrs=false)=0
 Parse a single argument if present. More...
 
virtual ParseResult parseArgumentList (SmallVectorImpl< Argument > &result, Delimiter delimiter=Delimiter::None, bool allowType=false, bool allowAttrs=false)=0
 Parse zero or more arguments with a specified surrounding delimiter. More...
 
virtual ParseResult parseRegion (Region &region, ArrayRef< Argument > arguments={}, bool enableNameShadowing=false)=0
 Parses a region. More...
 
virtual OptionalParseResult parseOptionalRegion (Region &region, ArrayRef< Argument > arguments={}, bool enableNameShadowing=false)=0
 Parses a region if present. More...
 
virtual OptionalParseResult parseOptionalRegion (std::unique_ptr< Region > &region, ArrayRef< Argument > arguments={}, bool enableNameShadowing=false)=0
 Parses a region if present. More...
 
virtual ParseResult parseSuccessor (Block *&dest)=0
 Parse a single operation successor. More...
 
virtual OptionalParseResult parseOptionalSuccessor (Block *&dest)=0
 Parse an optional operation successor. More...
 
virtual ParseResult parseSuccessorAndUseList (Block *&dest, SmallVectorImpl< Value > &operands)=0
 Parse a single operation successor and its operand list. More...
 
ParseResult parseAssignmentList (SmallVectorImpl< Argument > &lhs, SmallVectorImpl< UnresolvedOperand > &rhs)
 Parse a list of assignments of the form (x1 = y1, x2 = y2, ...) More...
 
virtual OptionalParseResult parseOptionalAssignmentList (SmallVectorImpl< Argument > &lhs, SmallVectorImpl< UnresolvedOperand > &rhs)=0
 
 AsmParser ()=default
 
- Public Member Functions inherited from mlir::AsmParser
 AsmParser ()=default
 
virtual ~AsmParser ()
 
MLIRContextgetContext () const
 
virtual SMLoc getNameLoc () const =0
 Return the location of the original name token. More...
 
virtual InFlightDiagnostic emitError (SMLoc loc, const Twine &message={})=0
 Emit a diagnostic at the specified location and return failure. More...
 
virtual BuildergetBuilder () const =0
 Return a builder which provides useful access to MLIRContext, global objects like types and attributes. More...
 
virtual SMLoc getCurrentLocation ()=0
 Get the location of the next token and store it into the argument. More...
 
ParseResult getCurrentLocation (SMLoc *loc)
 
virtual Location getEncodedSourceLoc (SMLoc loc)=0
 Re-encode the given source location as an MLIR location and return it. More...
 
virtual ParseResult parseArrow ()=0
 Parse a '->' token. More...
 
virtual ParseResult parseOptionalArrow ()=0
 Parse a '->' token if present. More...
 
virtual ParseResult parseLBrace ()=0
 Parse a { token. More...
 
virtual ParseResult parseOptionalLBrace ()=0
 Parse a { token if present. More...
 
virtual ParseResult parseRBrace ()=0
 Parse a } token. More...
 
virtual ParseResult parseOptionalRBrace ()=0
 Parse a } token if present. More...
 
virtual ParseResult parseColon ()=0
 Parse a : token. More...
 
virtual ParseResult parseOptionalColon ()=0
 Parse a : token if present. More...
 
virtual ParseResult parseComma ()=0
 Parse a , token. More...
 
virtual ParseResult parseOptionalComma ()=0
 Parse a , token if present. More...
 
virtual ParseResult parseEqual ()=0
 Parse a = token. More...
 
virtual ParseResult parseOptionalEqual ()=0
 Parse a = token if present. More...
 
virtual ParseResult parseLess ()=0
 Parse a '<' token. More...
 
virtual ParseResult parseOptionalLess ()=0
 Parse a '<' token if present. More...
 
virtual ParseResult parseGreater ()=0
 Parse a '>' token. More...
 
virtual ParseResult parseOptionalGreater ()=0
 Parse a '>' token if present. More...
 
virtual ParseResult parseQuestion ()=0
 Parse a '?' token. More...
 
virtual ParseResult parseOptionalQuestion ()=0
 Parse a '?' token if present. More...
 
virtual ParseResult parsePlus ()=0
 Parse a '+' token. More...
 
virtual ParseResult parseOptionalPlus ()=0
 Parse a '+' token if present. More...
 
virtual ParseResult parseStar ()=0
 Parse a '*' token. More...
 
virtual ParseResult parseOptionalStar ()=0
 Parse a '*' token if present. More...
 
virtual ParseResult parseVerticalBar ()=0
 Parse a '|' token. More...
 
virtual ParseResult parseOptionalVerticalBar ()=0
 Parse a '|' token if present. More...
 
ParseResult parseString (std::string *string)
 Parse a quoted string token. More...
 
virtual ParseResult parseOptionalString (std::string *string)=0
 Parse a quoted string token if present. More...
 
virtual ParseResult parseBase64Bytes (std::vector< char > *bytes)=0
 Parses a Base64 encoded string of bytes. More...
 
virtual ParseResult parseLParen ()=0
 Parse a ( token. More...
 
virtual ParseResult parseOptionalLParen ()=0
 Parse a ( token if present. More...
 
virtual ParseResult parseRParen ()=0
 Parse a ) token. More...
 
virtual ParseResult parseOptionalRParen ()=0
 Parse a ) token if present. More...
 
virtual ParseResult parseLSquare ()=0
 Parse a [ token. More...
 
virtual ParseResult parseOptionalLSquare ()=0
 Parse a [ token if present. More...
 
virtual ParseResult parseRSquare ()=0
 Parse a ] token. More...
 
virtual ParseResult parseOptionalRSquare ()=0
 Parse a ] token if present. More...
 
virtual ParseResult parseEllipsis ()=0
 Parse a ... token. More...
 
virtual ParseResult parseOptionalEllipsis ()=0
 Parse a ... token if present;. More...
 
virtual ParseResult parseFloat (double &result)=0
 Parse a floating point value from the stream. More...
 
template<typename IntT >
ParseResult parseInteger (IntT &result)
 Parse an integer value from the stream. More...
 
virtual OptionalParseResult parseOptionalInteger (APInt &result)=0
 Parse an optional integer value from the stream. More...
 
template<typename IntT >
OptionalParseResult parseOptionalInteger (IntT &result)
 
virtual ParseResult parseCommaSeparatedList (Delimiter delimiter, function_ref< ParseResult()> parseElementFn, StringRef contextMessage=StringRef())=0
 Parse a list of comma-separated items with an optional delimiter. More...
 
ParseResult parseCommaSeparatedList (function_ref< ParseResult()> parseElementFn)
 Parse a comma separated list of elements that must have at least one entry in it. More...
 
ParseResult parseKeyword (StringRef keyword)
 Parse a given keyword. More...
 
virtual ParseResult parseKeyword (StringRef keyword, const Twine &msg)=0
 
ParseResult parseKeyword (StringRef *keyword)
 Parse a keyword into 'keyword'. More...
 
virtual ParseResult parseOptionalKeyword (StringRef keyword)=0
 Parse the given keyword if present. More...
 
virtual ParseResult parseOptionalKeyword (StringRef *keyword)=0
 Parse a keyword, if present, into 'keyword'. More...
 
virtual ParseResult parseOptionalKeyword (StringRef *keyword, ArrayRef< StringRef > allowedValues)=0
 Parse a keyword, if present, and if one of the 'allowedValues', into 'keyword'. More...
 
ParseResult parseKeywordOrString (std::string *result)
 Parse a keyword or a quoted string. More...
 
virtual ParseResult parseOptionalKeywordOrString (std::string *result)=0
 Parse an optional keyword or string. More...
 
template<typename T , typename... ParamsT>
auto getChecked (SMLoc loc, ParamsT &&...params)
 Invoke the getChecked method of the given Attribute or Type class, using the provided location to emit errors in the case of failure. More...
 
template<typename T , typename... ParamsT>
auto getChecked (ParamsT &&...params)
 A variant of getChecked that uses the result of getNameLoc to emit errors. More...
 
virtual ParseResult parseAttribute (Attribute &result, Type type={})=0
 Parse an arbitrary attribute of a given type and return it in result. More...
 
virtual ParseResult parseCustomAttributeWithFallback (Attribute &result, Type type, function_ref< ParseResult(Attribute &result, Type type)> parseAttribute)=0
 Parse a custom attribute with the provided callback, unless the next token is #, in which case the generic parser is invoked. More...
 
template<typename AttrType >
ParseResult parseAttribute (AttrType &result, Type type={})
 Parse an attribute of a specific kind and type. More...
 
ParseResult parseAttribute (Attribute &result, StringRef attrName, NamedAttrList &attrs)
 Parse an arbitrary attribute and return it in result. More...
 
template<typename AttrType >
ParseResult parseAttribute (AttrType &result, StringRef attrName, NamedAttrList &attrs)
 Parse an attribute of a specific kind and type. More...
 
template<typename AttrType >
ParseResult parseAttribute (AttrType &result, Type type, StringRef attrName, NamedAttrList &attrs)
 Parse an arbitrary attribute of a given type and populate it in result. More...
 
template<typename AttrType >
std::enable_if_t< detect_has_parse_method< AttrType >::value, ParseResultparseCustomAttributeWithFallback (AttrType &result, Type type, StringRef attrName, NamedAttrList &attrs)
 Parse a custom attribute of a given type unless the next token is #, in which case the generic parser is invoked. More...
 
template<typename AttrType >
std::enable_if_t<!detect_has_parse_method< AttrType >::value, ParseResultparseCustomAttributeWithFallback (AttrType &result, Type type, StringRef attrName, NamedAttrList &attrs)
 SFINAE parsing method for Attribute that don't implement a parse method. More...
 
template<typename AttrType >
std::enable_if_t< detect_has_parse_method< AttrType >::value, ParseResultparseCustomAttributeWithFallback (AttrType &result, Type type={})
 Parse a custom attribute of a given type unless the next token is #, in which case the generic parser is invoked. More...
 
template<typename AttrType >
std::enable_if_t<!detect_has_parse_method< AttrType >::value, ParseResultparseCustomAttributeWithFallback (AttrType &result, Type type={})
 SFINAE parsing method for Attribute that don't implement a parse method. More...
 
virtual OptionalParseResult parseOptionalAttribute (Attribute &result, Type type={})=0
 Parse an arbitrary optional attribute of a given type and return it in result. More...
 
virtual OptionalParseResult parseOptionalAttribute (ArrayAttr &result, Type type={})=0
 Parse an optional array attribute and return it in result. More...
 
virtual OptionalParseResult parseOptionalAttribute (StringAttr &result, Type type={})=0
 Parse an optional string attribute and return it in result. More...
 
virtual OptionalParseResult parseOptionalAttribute (SymbolRefAttr &result, Type type={})=0
 Parse an optional symbol ref attribute and return it in result. More...
 
template<typename AttrType >
OptionalParseResult parseOptionalAttribute (AttrType &result, StringRef attrName, NamedAttrList &attrs)
 Parse an optional attribute of a specific type and add it to the list with the specified name. More...
 
template<typename AttrType >
OptionalParseResult parseOptionalAttribute (AttrType &result, Type type, StringRef attrName, NamedAttrList &attrs)
 Parse an optional attribute of a specific type and add it to the list with the specified name. More...
 
virtual ParseResult parseOptionalAttrDict (NamedAttrList &result)=0
 Parse a named dictionary into 'result' if it is present. More...
 
virtual ParseResult parseOptionalAttrDictWithKeyword (NamedAttrList &result)=0
 Parse a named dictionary into 'result' if the attributes keyword is present. More...
 
virtual ParseResult parseAffineMap (AffineMap &map)=0
 Parse an affine map instance into 'map'. More...
 
virtual ParseResult parseAffineExpr (ArrayRef< std::pair< StringRef, AffineExpr >> symbolSet, AffineExpr &expr)=0
 Parse an affine expr instance into 'expr' using the already computed mapping from symbols to affine expressions in 'symbolSet'. More...
 
virtual ParseResult parseIntegerSet (IntegerSet &set)=0
 Parse an integer set instance into 'set'. More...
 
ParseResult parseSymbolName (StringAttr &result)
 Parse an -identifier and store it (without the '@' symbol) in a string attribute. More...
 
ParseResult parseSymbolName (StringAttr &result, StringRef attrName, NamedAttrList &attrs)
 Parse an -identifier and store it (without the '@' symbol) in a string attribute named 'attrName'. More...
 
virtual ParseResult parseOptionalSymbolName (StringAttr &result)=0
 Parse an optional -identifier and store it (without the '@' symbol) in a string attribute. More...
 
ParseResult parseOptionalSymbolName (StringAttr &result, StringRef attrName, NamedAttrList &attrs)
 Parse an optional -identifier and store it (without the '@' symbol) in a string attribute named 'attrName'. More...
 
template<typename ResourceT >
FailureOr< ResourceT > parseResourceHandle ()
 Parse a handle to a resource within the assembly format. More...
 
virtual ParseResult parseType (Type &result)=0
 Parse a type. More...
 
virtual ParseResult parseCustomTypeWithFallback (Type &result, function_ref< ParseResult(Type &result)> parseType)=0
 Parse a custom type with the provided callback, unless the next token is #, in which case the generic parser is invoked. More...
 
virtual OptionalParseResult parseOptionalType (Type &result)=0
 Parse an optional type. More...
 
template<typename TypeT >
ParseResult parseType (TypeT &result)
 Parse a type of a specific type. More...
 
template<typename TypeT >
std::enable_if_t< detect_type_has_parse_method< TypeT >::value, ParseResultparseCustomTypeWithFallback (TypeT &result)
 Parse a custom Type of a given type unless the next token is #, in which case the generic parser is invoked. More...
 
template<typename TypeT >
std::enable_if_t<!detect_type_has_parse_method< TypeT >::value, ParseResultparseCustomTypeWithFallback (TypeT &result)
 SFINAE parsing method for Type that don't implement a parse method. More...
 
ParseResult parseTypeList (SmallVectorImpl< Type > &result)
 Parse a type list. More...
 
virtual ParseResult parseArrowTypeList (SmallVectorImpl< Type > &result)=0
 Parse an arrow followed by a type list. More...
 
virtual ParseResult parseOptionalArrowTypeList (SmallVectorImpl< Type > &result)=0
 Parse an optional arrow followed by a type list. More...
 
virtual ParseResult parseColonType (Type &result)=0
 Parse a colon followed by a type. More...
 
template<typename TypeType >
ParseResult parseColonType (TypeType &result)
 Parse a colon followed by a type of a specific kind, e.g. a FunctionType. More...
 
virtual ParseResult parseColonTypeList (SmallVectorImpl< Type > &result)=0
 Parse a colon followed by a type list, which must have at least one type. More...
 
virtual ParseResult parseOptionalColonTypeList (SmallVectorImpl< Type > &result)=0
 Parse an optional colon followed by a type list, which if present must have at least one type. More...
 
ParseResult parseKeywordType (const char *keyword, Type &result)
 Parse a keyword followed by a type. More...
 
ParseResult addTypeToList (Type type, SmallVectorImpl< Type > &result)
 Add the specified type to the end of the specified type list and return success. More...
 
ParseResult addTypesToList (ArrayRef< Type > types, SmallVectorImpl< Type > &result)
 Add the specified types to the end of the specified type list and return success. More...
 
virtual ParseResult parseDimensionList (SmallVectorImpl< int64_t > &dimensions, bool allowDynamic=true, bool withTrailingX=true)=0
 Parse a dimension list of a tensor or memref type. More...
 
virtual ParseResult parseXInDimensionList ()=0
 Parse an 'x' token in a dimension list, handling the case where the x is juxtaposed with an element type, as in "xf32", leaving the "f32" as the next token. More...
 
template<class AttrOrTypeT >
FailureOr< CyclicParseResettryStartCyclicParse (AttrOrTypeT attrOrType)
 Attempts to start a cyclic parsing region for attrOrType. More...
 

Additional Inherited Members

- Public Types inherited from mlir::AsmParser
enum class  Delimiter {
  None , Paren , Square , LessGreater ,
  Braces , OptionalParen , OptionalSquare , OptionalLessGreater ,
  OptionalBraces
}
 These are the supported delimiters around operand lists and region argument lists, used by parseOperandList. More...
 
template<typename AttrType >
using has_parse_method = decltype(AttrType::parse(std::declval< AsmParser & >(), std::declval< Type >()))
 Trait to check if AttrType provides a parse method. More...
 
template<typename AttrType >
using detect_has_parse_method = llvm::is_detected< has_parse_method, AttrType >
 
template<typename TypeT >
using type_has_parse_method = decltype(TypeT::parse(std::declval< AsmParser & >()))
 Trait to check if TypeT provides a parse method. More...
 
template<typename TypeT >
using detect_type_has_parse_method = llvm::is_detected< type_has_parse_method, TypeT >
 
- Protected Member Functions inherited from mlir::AsmParser
virtual FailureOr< AsmDialectResourceHandleparseResourceHandle (Dialect *dialect)=0
 Parse a handle to a resource within the assembly format for the given dialect. More...
 
virtual LogicalResult pushCyclicParsing (const void *opaquePointer)=0
 Pushes a new attribute or type in the form of a type erased pointer into an internal set. More...
 
virtual void popCyclicParsing ()=0
 Removes the element that was last inserted with a successful call to pushCyclicParsing. More...
 
virtual ParseResult parseKeywordOrCompletion (StringRef *keyword)=0
 Parse a keyword, or an empty string if the current location signals a code completion. More...
 
virtual void codeCompleteExpectedTokens (ArrayRef< StringRef > tokens)=0
 Signal the code completion of a set of expected tokens. More...
 

Detailed Description

The OpAsmParser has methods for interacting with the asm parser: parsing things from it, emitting errors etc.

It has an intentionally high-level API that is designed to reduce/constrain syntax innovation in individual operations.

For example, consider an op like this:

x = load p[%1, %2] : memref<...>

The "%x = load" tokens are already parsed and therefore invisible to the custom op parser. This can be supported by calling parseOperandList to parse the p, then calling parseOperandList with a SquareDelimiter to parse the indices, then calling parseColonTypeList to parse the result type.

Definition at line 1425 of file OpImplementation.h.

Constructor & Destructor Documentation

◆ ~OpAsmParser()

OpAsmParser::~OpAsmParser ( )
overridedefault

Member Function Documentation

◆ AsmParser()

mlir::AsmParser::AsmParser
default

◆ getNumResults()

virtual size_t mlir::OpAsmParser::getNumResults ( ) const
pure virtual

Return the number of declared SSA results.

This returns 4 for the foo.op example in the comment for getResultName.

Referenced by parseAsyncDependencies().

◆ getResultName()

virtual std::pair<StringRef, unsigned> mlir::OpAsmParser::getResultName ( unsigned  resultNo) const
pure virtual

Return the name of the specified result in the specified syntax, as well as the sub-element in the name.

It returns an empty string and ~0U for invalid result numbers. For example, in this operation:

x, y:2, z = foo.op

getResultName(0) == {"x", 0 } getResultName(1) == {"y", 0 } getResultName(2) == {"y", 1 } getResultName(3) == {"z", 0 } getResultName(4) == {"", ~0U }

◆ parseAffineExprOfSSAIds()

virtual ParseResult mlir::OpAsmParser::parseAffineExprOfSSAIds ( SmallVectorImpl< UnresolvedOperand > &  dimOperands,
SmallVectorImpl< UnresolvedOperand > &  symbOperands,
AffineExpr expr 
)
pure virtual

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.

◆ parseAffineMapOfSSAIds()

virtual ParseResult mlir::OpAsmParser::parseAffineMapOfSSAIds ( SmallVectorImpl< UnresolvedOperand > &  operands,
Attribute map,
StringRef  attrName,
NamedAttrList attrs,
Delimiter  delimiter = Delimiter::Square 
)
pure virtual

Parses an affine map attribute 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.

Referenced by mlir::affine::AffineDmaStartOp::parse(), and mlir::affine::AffineDmaWaitOp::parse().

◆ parseArgument()

virtual ParseResult mlir::OpAsmParser::parseArgument ( Argument result,
bool  allowType = false,
bool  allowAttrs = false 
)
pure virtual

Parse a single argument with the following syntax:

ssaName : !type { optionalAttrDict} loc(optionalSourceLoc)

If allowType is false or allowAttrs are false then the respective parts of the grammar are not parsed.

◆ parseArgumentList()

virtual ParseResult mlir::OpAsmParser::parseArgumentList ( SmallVectorImpl< Argument > &  result,
Delimiter  delimiter = Delimiter::None,
bool  allowType = false,
bool  allowAttrs = false 
)
pure virtual

Parse zero or more arguments with a specified surrounding delimiter.

Referenced by parseAttributions(), parseLoopControl(), and parseWsloop().

◆ parseAssignmentList()

ParseResult mlir::OpAsmParser::parseAssignmentList ( SmallVectorImpl< Argument > &  lhs,
SmallVectorImpl< UnresolvedOperand > &  rhs 
)
inline

◆ parseCustomOperationName()

virtual FailureOr<OperationName> mlir::OpAsmParser::parseCustomOperationName ( )
pure virtual

Parse the name of an operation, in the custom form.

On success, return a an object of type 'OperationName'. Otherwise, failure is returned.

◆ parseGenericOperation()

virtual Operation* mlir::OpAsmParser::parseGenericOperation ( Block insertBlock,
Block::iterator  insertPt 
)
pure virtual

Parse an operation in its generic form.

The parsed operation is parsed in the current context and inserted in the provided block and insertion point. The results produced by this operation aren't mapped to any named value in the parser. Returns nullptr on failure.

◆ parseGenericOperationAfterOpName()

virtual ParseResult mlir::OpAsmParser::parseGenericOperationAfterOpName ( OperationState result,
std::optional< ArrayRef< UnresolvedOperand >>  parsedOperandType = std::nullopt,
std::optional< ArrayRef< Block * >>  parsedSuccessors = std::nullopt,
std::optional< MutableArrayRef< std::unique_ptr< Region >>>  parsedRegions = std::nullopt,
std::optional< ArrayRef< NamedAttribute >>  parsedAttributes = std::nullopt,
std::optional< Attribute parsedPropertiesAttribute = std::nullopt,
std::optional< FunctionType >  parsedFnType = std::nullopt 
)
pure virtual

Parse different components, viz., use-info of operand(s), successor(s), region(s), attribute(s) and function-type, of the generic form of an operation instance and populate the input operation-state 'result' with those components.

If any of the components is explicitly provided, then skip parsing that component.

◆ parseOperand()

virtual ParseResult mlir::OpAsmParser::parseOperand ( UnresolvedOperand result,
bool  allowResultNumber = true 
)
pure virtual

◆ parseOperandList() [1/2]

virtual ParseResult mlir::OpAsmParser::parseOperandList ( SmallVectorImpl< UnresolvedOperand > &  result,
Delimiter  delimiter = Delimiter::None,
bool  allowResultNumber = true,
int  requiredOperandCount = -1 
)
pure virtual

◆ parseOperandList() [2/2]

ParseResult mlir::OpAsmParser::parseOperandList ( SmallVectorImpl< UnresolvedOperand > &  result,
int  requiredOperandCount,
Delimiter  delimiter = Delimiter::None 
)
inline

Parse a specified number of comma separated operands.

Definition at line 1517 of file OpImplementation.h.

References parseOperandList().

◆ parseOptionalArgument()

virtual OptionalParseResult mlir::OpAsmParser::parseOptionalArgument ( Argument result,
bool  allowType = false,
bool  allowAttrs = false 
)
pure virtual

Parse a single argument if present.

Referenced by parseFunctionArgumentList().

◆ parseOptionalAssignmentList()

virtual OptionalParseResult mlir::OpAsmParser::parseOptionalAssignmentList ( SmallVectorImpl< Argument > &  lhs,
SmallVectorImpl< UnresolvedOperand > &  rhs 
)
pure virtual

Referenced by parseAssignmentList().

◆ parseOptionalLocationSpecifier()

virtual ParseResult mlir::OpAsmParser::parseOptionalLocationSpecifier ( std::optional< Location > &  result)
pure virtual

Parse a loc(...) specifier if present, filling in result if so.

Location for BlockArgument and Operation may be deferred with an alias, in which case an OpaqueLoc is set and will be resolved when parsing completes.

◆ parseOptionalOperand()

virtual OptionalParseResult mlir::OpAsmParser::parseOptionalOperand ( UnresolvedOperand result,
bool  allowResultNumber = true 
)
pure virtual

Parse a single operand if present.

Referenced by mlir::parseDynamicIndexList(), parseOptionalCallFuncPtr(), and parseSequenceOpOperands().

◆ parseOptionalRegion() [1/2]

virtual OptionalParseResult mlir::OpAsmParser::parseOptionalRegion ( Region region,
ArrayRef< Argument arguments = {},
bool  enableNameShadowing = false 
)
pure virtual

Parses a region if present.

Referenced by mlir::function_interface_impl::parseFunctionOp(), and parseSingleBlockRegion().

◆ parseOptionalRegion() [2/2]

virtual OptionalParseResult mlir::OpAsmParser::parseOptionalRegion ( std::unique_ptr< Region > &  region,
ArrayRef< Argument arguments = {},
bool  enableNameShadowing = false 
)
pure virtual

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.

◆ parseOptionalSuccessor()

virtual OptionalParseResult mlir::OpAsmParser::parseOptionalSuccessor ( Block *&  dest)
pure virtual

Parse an optional operation successor.

◆ parseRegion()

virtual ParseResult mlir::OpAsmParser::parseRegion ( Region region,
ArrayRef< Argument arguments = {},
bool  enableNameShadowing = false 
)
pure virtual

Parses a region.

Any parsed blocks are appended to 'region' and must be moved to the op regions after the op is created. The first block of the region takes 'arguments'.

If 'enableNameShadowing' is set to true, the argument names are allowed to shadow the names of other existing SSA values defined above the region scope. 'enableNameShadowing' can only be set to true for regions attached to operations that are 'IsolatedFromAbove'.

Referenced by parseAtomicReductionRegion(), parseCleanupReductionRegion(), parseLoopControl(), parseParallelRegion(), parseSwitchCases(), and parseWsloop().

◆ parseSuccessor()

virtual ParseResult mlir::OpAsmParser::parseSuccessor ( Block *&  dest)
pure virtual

Parse a single operation successor.

Referenced by parseSwitchOpCases().

◆ parseSuccessorAndUseList()

virtual ParseResult mlir::OpAsmParser::parseSuccessorAndUseList ( Block *&  dest,
SmallVectorImpl< Value > &  operands 
)
pure virtual

Parse a single operation successor and its operand list.

◆ parseTrailingOperandList()

ParseResult mlir::OpAsmParser::parseTrailingOperandList ( SmallVectorImpl< UnresolvedOperand > &  result,
Delimiter  delimiter = Delimiter::None 
)
inline

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.

Definition at line 1529 of file OpImplementation.h.

References mlir::failed(), parseOperandList(), mlir::AsmParser::parseOptionalComma(), and mlir::success().

Referenced by mlir::affine::AffineDmaStartOp::parse().

◆ resolveOperand()

virtual ParseResult mlir::OpAsmParser::resolveOperand ( const UnresolvedOperand operand,
Type  type,
SmallVectorImpl< Value > &  result 
)
pure virtual

Resolve an operand to an SSA value, emitting an error on failure.

Referenced by mlir::affine::AffineDmaStartOp::parse(), mlir::affine::AffineDmaWaitOp::parse(), parseBound(), parseCmpOp(), and resolveOperands().

◆ resolveOperands() [1/3]

template<typename Operands = ArrayRef<UnresolvedOperand>>
ParseResult mlir::OpAsmParser::resolveOperands ( Operands &&  operands,
Type  type,
SmallVectorImpl< Value > &  result 
)
inline

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.

Definition at line 1545 of file OpImplementation.h.

References mlir::failure(), resolveOperand(), and mlir::success().

Referenced by mlir::affine::AffineDmaStartOp::parse(), mlir::affine::AffineDmaWaitOp::parse(), parseAffineMinMaxOp(), parseArithmeticExtendedBinaryOp(), parseCallTypeAndResolveOperands(), parseCommonStructuredOpParts(), mlir::affine::parseDimAndSymbolList(), parseOneResultSameOperandTypeOp(), and resolveOperands().

◆ resolveOperands() [2/3]

template<typename Operands = ArrayRef<UnresolvedOperand>>
ParseResult mlir::OpAsmParser::resolveOperands ( Operands &&  operands,
Type  type,
SMLoc  loc,
SmallVectorImpl< Value > &  result 
)
inline

Definition at line 1553 of file OpImplementation.h.

References resolveOperands().

◆ resolveOperands() [3/3]

template<typename Operands = ArrayRef<UnresolvedOperand>, typename Types = ArrayRef<Type>>
std::enable_if_t<!std::is_convertible<Types, Type>::value, ParseResult> mlir::OpAsmParser::resolveOperands ( Operands &&  operands,
Types &&  types,
SMLoc  loc,
SmallVectorImpl< Value > &  result 
)
inline

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.

Definition at line 1564 of file OpImplementation.h.

References mlir::AsmParser::emitError(), mlir::failure(), resolveOperand(), and mlir::success().


The documentation for this class was generated from the following files: