MLIR
20.0.0git
|
This class implement support for parsing global entities like attributes and types. More...
#include "AsmParser/Parser.h"
Public Types | |
using | Delimiter = OpAsmParser::Delimiter |
Public Member Functions | |
Parser (ParserState &state) | |
ParserState & | getState () const |
MLIRContext * | getContext () const |
const llvm::SourceMgr & | getSourceMgr () |
ParseResult | parseCommaSeparatedListUntil (Token::Kind rightToken, function_ref< ParseResult()> parseElement, bool allowEmptyList=true) |
Parse a comma-separated list of elements up until the specified end token. More... | |
ParseResult | parseCommaSeparatedList (Delimiter delimiter, function_ref< ParseResult()> parseElementFn, StringRef contextMessage=StringRef()) |
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 | parseDialectSymbolBody (StringRef &body, bool &isCodeCompletion) |
Parse the body of a dialect symbol, which starts and ends with <>'s, and may be recursive. More... | |
ParseResult | parseDialectSymbolBody (StringRef &body) |
InFlightDiagnostic | emitError (const Twine &message={}) |
Emit an error and return failure. More... | |
InFlightDiagnostic | emitError (SMLoc loc, const Twine &message={}) |
InFlightDiagnostic | emitWrongTokenError (const Twine &message={}) |
Emit an error about a "wrong token". More... | |
Location | getEncodedSourceLocation (SMLoc loc) |
Encode the specified source location information into an attribute for attachment to the IR. More... | |
const Token & | getToken () const |
Return the current token the parser is inspecting. More... | |
StringRef | getTokenSpelling () const |
const Token & | getLastToken () const |
Return the last parsed token. More... | |
bool | consumeIf (Token::Kind kind) |
If the current token has the specified kind, consume it and return true. More... | |
void | consumeToken () |
Advance the current lexer onto the next token. More... | |
void | consumeToken (Token::Kind kind) |
Advance the current lexer onto the next token, asserting what the expected current token is. More... | |
void | resetToken (const char *tokPos) |
Reset the parser to the given lexer position. More... | |
ParseResult | parseToken (Token::Kind expectedToken, const Twine &message) |
Consume the specified token if present and return success. More... | |
OptionalParseResult | parseOptionalInteger (APInt &result) |
Parse an optional integer value from the stream. More... | |
OptionalParseResult | parseOptionalDecimalInteger (APInt &result) |
Parse an optional integer value only in decimal format from the stream. More... | |
ParseResult | parseFloatFromIntegerLiteral (std::optional< APFloat > &result, const Token &tok, bool isNegative, const llvm::fltSemantics &semantics, size_t typeSizeInBits) |
Parse a floating point value from an integer literal token. More... | |
bool | isCurrentTokenAKeyword () const |
Returns true if the current token corresponds to a keyword. More... | |
ParseResult | parseOptionalKeyword (StringRef *keyword) |
Parse a keyword, if present, into 'keyword'. More... | |
FailureOr< AsmDialectResourceHandle > | parseResourceHandle (const OpAsmDialectInterface *dialect, StringRef &name) |
Parse a handle to a dialect resource within the assembly format. More... | |
FailureOr< AsmDialectResourceHandle > | parseResourceHandle (Dialect *dialect) |
template<typename T , typename... ParamsT> | |
T | 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... | |
ParseResult | parseFunctionResultTypes (SmallVectorImpl< Type > &elements) |
Parse a function result type. More... | |
ParseResult | parseTypeListNoParens (SmallVectorImpl< Type > &elements) |
Parse a list of types without an enclosing parenthesis. More... | |
ParseResult | parseTypeListParens (SmallVectorImpl< Type > &elements) |
Parse a parenthesized list of types. More... | |
OptionalParseResult | parseOptionalType (Type &type) |
Optionally parse a type. More... | |
Type | parseType () |
Parse an arbitrary type. More... | |
Type | parseComplexType () |
Parse a complex type. More... | |
Type | parseExtendedType () |
Parse an extended type. More... | |
Type | parseFunctionType () |
Parse a function type. More... | |
Type | parseMemRefType () |
Parse a memref type. More... | |
Type | parseNonFunctionType () |
Parse a non function type. More... | |
Type | parseTensorType () |
Parse a tensor type. More... | |
Type | parseTupleType () |
Parse a tuple type. More... | |
VectorType | parseVectorType () |
Parse a vector type. More... | |
ParseResult | parseVectorDimensionList (SmallVectorImpl< int64_t > &dimensions, SmallVectorImpl< bool > &scalableDims) |
Parse a dimension list in a vector type. More... | |
ParseResult | parseDimensionListRanked (SmallVectorImpl< int64_t > &dimensions, bool allowDynamic=true, bool withTrailingX=true) |
Parse a dimension list of a tensor or memref type. More... | |
ParseResult | parseIntegerInDimensionList (int64_t &value) |
ParseResult | parseXInDimensionList () |
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... | |
Attribute | parseAttribute (Type type={}) |
Parse an arbitrary attribute with an optional type. More... | |
OptionalParseResult | parseOptionalAttribute (Attribute &attribute, Type type={}) |
Parse an optional attribute with the provided type. More... | |
OptionalParseResult | parseOptionalAttribute (ArrayAttr &attribute, Type type) |
OptionalParseResult | parseOptionalAttribute (StringAttr &attribute, Type type) |
OptionalParseResult | parseOptionalAttribute (SymbolRefAttr &result, Type type) |
template<typename AttributeT > | |
OptionalParseResult | parseOptionalAttributeWithToken (Token::Kind kind, AttributeT &attr, Type type={}) |
Parse an optional attribute that is demarcated by a specific token. More... | |
ParseResult | parseAttributeDict (NamedAttrList &attributes) |
Parse an attribute dictionary. More... | |
Attribute | parseDistinctAttr (Type type) |
Parse a distinct attribute. More... | |
Attribute | parseExtendedAttr (Type type) |
Parse an extended attribute. More... | |
Attribute | parseFloatAttr (Type type, bool isNegative) |
Parse a float attribute. More... | |
Attribute | parseDecOrHexAttr (Type type, bool isNegative) |
Parse a decimal or a hexadecimal literal, which can be either an integer or a float attribute. More... | |
Attribute | parseDenseElementsAttr (Type attrType) |
Parse a dense elements attribute. More... | |
ShapedType | parseElementsLiteralType (Type type) |
Shaped type for elements attribute. More... | |
Attribute | parseDenseResourceElementsAttr (Type attrType) |
Parse a dense resource elements attribute. More... | |
Attribute | parseDenseArrayAttr (Type type) |
Parse a DenseArrayAttr. More... | |
Attribute | parseSparseElementsAttr (Type attrType) |
Parse a sparse elements attribute. More... | |
Attribute | parseStridedLayoutAttr () |
Parse a strided layout attribute. More... | |
ParseResult | parseLocationInstance (LocationAttr &loc) |
Parse a raw location instance. More... | |
ParseResult | parseCallSiteLocation (LocationAttr &loc) |
Parse a callsite location instance. More... | |
ParseResult | parseFusedLocation (LocationAttr &loc) |
Parse a fused location instance. More... | |
ParseResult | parseNameOrFileLineColLocation (LocationAttr &loc) |
Parse a name or FileLineCol location instance. More... | |
ParseResult | parseAffineMapOrIntegerSetReference (AffineMap &map, IntegerSet &set) |
Parse a reference to either an affine map, expr, or an integer set. More... | |
ParseResult | parseAffineMapReference (AffineMap &map) |
ParseResult | parseAffineExprReference (ArrayRef< std::pair< StringRef, AffineExpr >> symbolSet, AffineExpr &expr) |
ParseResult | parseIntegerSetReference (IntegerSet &set) |
ParseResult | parseAffineMapOfSSAIds (AffineMap &map, function_ref< ParseResult(bool)> parseElement, Delimiter delimiter) |
Parse an AffineMap where the dim and symbol identifiers are SSA ids. More... | |
ParseResult | parseAffineExprOfSSAIds (AffineExpr &expr, function_ref< ParseResult(bool)> parseElement) |
Parse an AffineExpr where dim and symbol identifiers are SSA ids. More... | |
ParseResult | codeCompleteDialectName () |
The set of various code completion methods. More... | |
ParseResult | codeCompleteOperationName (StringRef dialectName) |
ParseResult | codeCompleteDialectOrElidedOpName (SMLoc loc) |
ParseResult | codeCompleteStringDialectOrOperationName (StringRef name) |
ParseResult | codeCompleteExpectedTokens (ArrayRef< StringRef > tokens) |
ParseResult | codeCompleteOptionalTokens (ArrayRef< StringRef > tokens) |
Attribute | codeCompleteAttribute () |
Type | codeCompleteType () |
Attribute | codeCompleteDialectSymbol (const llvm::StringMap< Attribute > &aliases) |
Type | codeCompleteDialectSymbol (const llvm::StringMap< Type > &aliases) |
Public Attributes | |
Builder | builder |
Protected Attributes | |
ParserState & | state |
The Parser is subclassed and reinstantiated. More... | |
This class implement support for parsing global entities like attributes and types.
It is intended to be subclassed by specialized subparsers that include state.
|
inline |
Attribute Parser::codeCompleteAttribute | ( | ) |
Definition at line 497 of file Parser.cpp.
References mlir::detail::SymbolState::attributeAliasDefinitions, mlir::detail::ParserState::codeCompleteContext, mlir::AsmParserCodeCompleteContext::completeAttribute(), state, and mlir::detail::ParserState::symbols.
Referenced by parseAttribute().
LogicalResult Parser::codeCompleteDialectName | ( | ) |
The set of various code completion methods.
Every completion method returns failure
to signal that parsing should abort after any desired completions have been enqueued. Note that failure
is does not mean completion failed, it's just a signal to the parser to stop.
Definition at line 437 of file Parser.cpp.
References mlir::detail::ParserState::codeCompleteContext, mlir::AsmParserCodeCompleteContext::completeDialectName(), and state.
Referenced by codeCompleteDialectOrElidedOpName(), and codeCompleteStringDialectOrOperationName().
ParseResult Parser::codeCompleteDialectOrElidedOpName | ( | SMLoc | loc | ) |
Definition at line 452 of file Parser.cpp.
References codeCompleteDialectName(), codeCompleteOperationName(), mlir::detail::ParserState::defaultDialectStack, mlir::Lexer::getBufferBegin(), mlir::detail::ParserState::lex, and state.
Definition at line 508 of file Parser.cpp.
References mlir::detail::ParserState::codeCompleteContext, mlir::AsmParserCodeCompleteContext::completeDialectAttributeOrAlias(), and state.
Referenced by parseExtendedSymbol().
Definition at line 512 of file Parser.cpp.
References mlir::detail::ParserState::codeCompleteContext, mlir::AsmParserCodeCompleteContext::completeDialectTypeOrAlias(), and state.
ParseResult Parser::codeCompleteExpectedTokens | ( | ArrayRef< StringRef > | tokens | ) |
Definition at line 488 of file Parser.cpp.
References mlir::detail::ParserState::codeCompleteContext, mlir::AsmParserCodeCompleteContext::completeExpectedTokens(), and state.
Referenced by mlir::detail::AsmParserImpl< BaseT >::codeCompleteExpectedTokens(), and mlir::detail::AsmParserImpl< BaseT >::parseKeyword().
LogicalResult Parser::codeCompleteOperationName | ( | StringRef | dialectName | ) |
Definition at line 442 of file Parser.cpp.
References mlir::detail::ParserState::codeCompleteContext, mlir::AsmParserCodeCompleteContext::completeOperationName(), and state.
Referenced by codeCompleteDialectOrElidedOpName(), and codeCompleteStringDialectOrOperationName().
ParseResult Parser::codeCompleteOptionalTokens | ( | ArrayRef< StringRef > | tokens | ) |
Definition at line 492 of file Parser.cpp.
References mlir::detail::ParserState::codeCompleteContext, mlir::AsmParserCodeCompleteContext::completeExpectedTokens(), and state.
Referenced by mlir::detail::AsmParserImpl< BaseT >::parseOptionalKeyword().
ParseResult Parser::codeCompleteStringDialectOrOperationName | ( | StringRef | name | ) |
Definition at line 475 of file Parser.cpp.
References codeCompleteDialectName(), and codeCompleteOperationName().
Type Parser::codeCompleteType | ( | ) |
Definition at line 502 of file Parser.cpp.
References mlir::detail::ParserState::codeCompleteContext, mlir::AsmParserCodeCompleteContext::completeType(), state, mlir::detail::ParserState::symbols, and mlir::detail::SymbolState::typeAliasDefinitions.
Referenced by parseNonFunctionType().
|
inline |
If the current token has the specified kind, consume it and return true.
If not, return false.
Definition at line 110 of file Parser.h.
Referenced by parseAttribute(), parseAttributeDict(), parseCommaSeparatedList(), parseDecOrHexAttr(), parseDenseArrayAttr(), parseDenseElementsAttr(), parseDimensionListRanked(), mlir::detail::AsmParserImpl< BaseT >::parseFloat(), parseFloatAttr(), parseFusedLocation(), parseMemRefType(), parseNameOrFileLineColLocation(), mlir::detail::AsmParserImpl< BaseT >::parseOptionalArrow(), mlir::detail::AsmParserImpl< BaseT >::parseOptionalArrowTypeList(), mlir::detail::AsmParserImpl< BaseT >::parseOptionalColon(), mlir::detail::AsmParserImpl< BaseT >::parseOptionalColonTypeList(), mlir::detail::AsmParserImpl< BaseT >::parseOptionalComma(), parseOptionalDecimalInteger(), mlir::detail::AsmParserImpl< BaseT >::parseOptionalEllipsis(), mlir::detail::AsmParserImpl< BaseT >::parseOptionalEqual(), mlir::detail::AsmParserImpl< BaseT >::parseOptionalGreater(), parseOptionalInteger(), mlir::detail::AsmParserImpl< BaseT >::parseOptionalLBrace(), mlir::detail::AsmParserImpl< BaseT >::parseOptionalLess(), mlir::detail::AsmParserImpl< BaseT >::parseOptionalLParen(), mlir::detail::AsmParserImpl< BaseT >::parseOptionalLSquare(), mlir::detail::AsmParserImpl< BaseT >::parseOptionalMinus(), mlir::detail::AsmParserImpl< BaseT >::parseOptionalPlus(), mlir::detail::AsmParserImpl< BaseT >::parseOptionalQuestion(), mlir::detail::AsmParserImpl< BaseT >::parseOptionalRBrace(), mlir::detail::AsmParserImpl< BaseT >::parseOptionalRParen(), mlir::detail::AsmParserImpl< BaseT >::parseOptionalRSquare(), mlir::detail::AsmParserImpl< BaseT >::parseOptionalStar(), mlir::detail::AsmParserImpl< BaseT >::parseOptionalVerticalBar(), parseSparseElementsAttr(), parseStridedLayoutAttr(), parseTensorType(), parseToken(), parseTupleType(), and parseVectorDimensionList().
|
inline |
Advance the current lexer onto the next token.
Definition at line 118 of file Parser.h.
References mlir::detail::ParserState::curToken, mlir::Token::isNot(), mlir::detail::ParserState::lastToken, mlir::detail::ParserState::lex, mlir::Lexer::lexToken(), and state.
Referenced by parseAttribute(), parseAttributeDict(), mlir::detail::AsmParserImpl< BaseT >::parseBase64Bytes(), parseCallSiteLocation(), parseCommaSeparatedListUntil(), parseComplexType(), parseDecOrHexAttr(), parseDenseArrayAttr(), parseDenseElementsAttr(), parseDenseResourceElementsAttr(), parseDistinctAttr(), parseExtendedSymbol(), mlir::detail::AsmParserImpl< BaseT >::parseFloat(), parseFloatAttr(), parseFusedLocation(), parseIntegerInDimensionList(), parseLocationInstance(), parseMemRefType(), parseNameOrFileLineColLocation(), parseNonFunctionType(), parseOptionalDecimalInteger(), parseOptionalKeyword(), mlir::detail::AsmParserImpl< BaseT >::parseOptionalKeyword(), mlir::detail::AsmParserImpl< BaseT >::parseOptionalString(), mlir::detail::AsmParserImpl< BaseT >::parseOptionalSymbolName(), parseSparseElementsAttr(), parseStridedLayoutAttr(), parseTensorType(), parseTupleType(), parseTypeListParens(), parseVectorType(), and parseXInDimensionList().
|
inline |
InFlightDiagnostic Parser::emitError | ( | const Twine & | message = {} | ) |
Emit an error and return failure.
Definition at line 192 of file Parser.cpp.
References mlir::detail::ParserState::curToken, mlir::Token::getLoc(), mlir::Token::isNot(), and state.
Referenced by mlir::detail::AsmParserImpl< BaseT >::emitError(), emitWrongTokenError(), getChecked(), parseAffineMapReference(), parseAttribute(), parseAttributeDict(), parseComplexType(), parseDecOrHexAttr(), parseDenseArrayAttr(), parseDenseResourceElementsAttr(), parseDialectSymbolBody(), parseDimensionListRanked(), parseDistinctAttr(), parseElementAttrHexValues(), parseElementsLiteralType(), parseFloatAttr(), parseFloatFromIntegerLiteral(), parseIntegerInDimensionList(), parseIntegerSetReference(), parseLocationInstance(), parseMemRefType(), parseNameOrFileLineColLocation(), parseNonFunctionType(), parseOptionalDecimalInteger(), parseOptionalInteger(), parseResourceHandle(), mlir::detail::AsmParserImpl< BaseT >::parseResourceHandle(), parseStridedLayoutAttr(), and parseTensorType().
InFlightDiagnostic Parser::emitError | ( | SMLoc | loc, |
const Twine & | message = {} |
||
) |
Definition at line 201 of file Parser.cpp.
References diag(), mlir::emitError(), getEncodedSourceLocation(), and getToken().
InFlightDiagnostic Parser::emitWrongTokenError | ( | const Twine & | message = {} | ) |
Emit an error about a "wrong token".
If the current token is at the start of a source line, this will apply heuristics to back up and report the error at the end of the previous line, which is where the expected token is supposed to be.
Definition at line 215 of file Parser.cpp.
References mlir::detail::ParserState::curToken, emitError(), mlir::Lexer::getBufferBegin(), mlir::Token::getLoc(), mlir::Token::is(), mlir::detail::ParserState::lex, and state.
Referenced by parseAttribute(), parseAttributeDict(), parseCallSiteLocation(), parseCommaSeparatedListUntil(), parseExtendedSymbol(), parseLocationInstance(), parseNameOrFileLineColLocation(), parseNonFunctionType(), parseStridedLayoutAttr(), parseToken(), parseVectorDimensionList(), and parseXInDimensionList().
|
inline |
Invoke the getChecked
method of the given Attribute or Type class, using the provided location to emit errors in the case of failure.
Note that unlike OpBuilder::getType
, this method does not implicitly insert a context parameter.
Definition at line 187 of file Parser.h.
References emitError().
|
inline |
Definition at line 37 of file Parser.h.
References mlir::detail::ParserState::config, mlir::ParserConfig::getContext(), and state.
Referenced by parseAttribute(), parseAttributeDict(), parseDenseResourceElementsAttr(), parseExtendedAttr(), parseFusedLocation(), parseLocationInstance(), parseNameOrFileLineColLocation(), parseNonFunctionType(), parseStridedLayoutAttr(), and parseTupleType().
|
inline |
Encode the specified source location information into an attribute for attachment to the IR.
Definition at line 93 of file Parser.h.
References mlir::Lexer::getEncodedSourceLocation(), mlir::detail::ParserState::lex, and state.
Referenced by emitError(), and mlir::detail::AsmParserImpl< BaseT >::getEncodedSourceLoc().
|
inline |
Return the last parsed token.
Definition at line 106 of file Parser.h.
References mlir::detail::ParserState::lastToken, and state.
|
inline |
Definition at line 38 of file Parser.h.
References mlir::Lexer::getSourceMgr(), mlir::detail::ParserState::lex, and state.
|
inline |
Definition at line 36 of file Parser.h.
References state.
Referenced by mlir::detail::AsmParserImpl< BaseT >::parseOptionalSymbolName(), parseResourceHandle(), mlir::detail::AsmParserImpl< BaseT >::popCyclicParsing(), and mlir::detail::AsmParserImpl< BaseT >::pushCyclicParsing().
|
inline |
Return the current token the parser is inspecting.
Definition at line 102 of file Parser.h.
References mlir::detail::ParserState::curToken, and state.
Referenced by mlir::detail::AsmParserImpl< BaseT >::codeCompleteExpectedTokens(), emitError(), mlir::detail::AsmParserImpl< BaseT >::getCurrentLocation(), isCurrentTokenAKeyword(), parseAffineMapReference(), parseAttribute(), parseAttributeDict(), mlir::detail::AsmParserImpl< BaseT >::parseBase64Bytes(), parseCallSiteLocation(), parseCommaSeparatedList(), parseCommaSeparatedListUntil(), parseComplexType(), mlir::detail::AsmParserImpl< BaseT >::parseCustomAttributeWithFallback(), mlir::detail::AsmParserImpl< BaseT >::parseCustomTypeWithFallback(), parseDecOrHexAttr(), parseDenseArrayAttr(), parseDenseElementsAttr(), parseDenseResourceElementsAttr(), parseDimensionListRanked(), parseDistinctAttr(), parseExtendedSymbol(), mlir::detail::AsmParserImpl< BaseT >::parseFloat(), parseFloatAttr(), parseFunctionResultTypes(), parseFunctionType(), parseIntegerInDimensionList(), parseIntegerSetReference(), mlir::detail::AsmParserImpl< BaseT >::parseKeyword(), mlir::detail::AsmParserImpl< BaseT >::parseKeywordOrCompletion(), parseLocationInstance(), parseMemRefType(), parseNameOrFileLineColLocation(), parseNonFunctionType(), mlir::detail::AsmParserImpl< BaseT >::parseOptionalAttrDict(), parseOptionalAttribute(), parseOptionalDecimalInteger(), parseOptionalInteger(), mlir::detail::AsmParserImpl< BaseT >::parseOptionalKeyword(), mlir::detail::AsmParserImpl< BaseT >::parseOptionalString(), mlir::detail::AsmParserImpl< BaseT >::parseOptionalSymbolName(), parseOptionalType(), parseResourceHandle(), parseSparseElementsAttr(), parseStridedLayoutAttr(), parseTensorType(), parseType(), parseTypeListParens(), parseVectorDimensionList(), parseVectorType(), and parseXInDimensionList().
|
inline |
Definition at line 103 of file Parser.h.
References mlir::detail::ParserState::curToken, mlir::Token::getSpelling(), and state.
Referenced by parseAttributeDict(), mlir::detail::AsmParserImpl< BaseT >::parseBase64Bytes(), parseDialectSymbolBody(), parseDimensionListRanked(), parseExtendedSymbol(), parseIntegerInDimensionList(), parseOptionalKeyword(), mlir::detail::AsmParserImpl< BaseT >::parseOptionalKeyword(), and parseXInDimensionList().
|
inline |
Returns true if the current token corresponds to a keyword.
Definition at line 161 of file Parser.h.
References getToken(), mlir::Token::isAny(), and mlir::Token::isKeyword().
Referenced by parseOptionalKeyword(), and mlir::detail::AsmParserImpl< BaseT >::parseOptionalKeyword().
ParseResult Parser::parseAffineExprOfSSAIds | ( | AffineExpr & | expr, |
function_ref< ParseResult(bool)> | parseElement | ||
) |
Parse an AffineExpr where dim and symbol identifiers are SSA ids.
Parse an AffineExpr of SSA ids.
The callback parseElement
is used to parse SSA value uses encountered while parsing.
Definition at line 756 of file AffineParser.cpp.
References state.
ParseResult Parser::parseAffineExprReference | ( | ArrayRef< std::pair< StringRef, AffineExpr >> | symbolSet, |
AffineExpr & | expr | ||
) |
Definition at line 729 of file AffineParser.cpp.
References state.
Referenced by mlir::detail::AsmParserImpl< BaseT >::parseAffineExpr().
ParseResult Parser::parseAffineMapOfSSAIds | ( | AffineMap & | map, |
function_ref< ParseResult(bool)> | parseElement, | ||
OpAsmParser::Delimiter | delimiter | ||
) |
Parse an AffineMap where the dim and symbol identifiers are SSA ids.
Parse an AffineMap of SSA ids.
The callback 'parseElement' is used to parse SSA value uses encountered while parsing affine expressions.
Definition at line 746 of file AffineParser.cpp.
References state.
ParseResult Parser::parseAffineMapOrIntegerSetReference | ( | AffineMap & | map, |
IntegerSet & | set | ||
) |
Parse a reference to either an affine map, expr, or an integer set.
Parse an ambiguous reference to either and affine map or an integer set.
Definition at line 716 of file AffineParser.cpp.
References state.
Referenced by parseAffineMapReference(), and parseIntegerSetReference().
ParseResult Parser::parseAffineMapReference | ( | AffineMap & | map | ) |
Definition at line 720 of file AffineParser.cpp.
References emitError(), mlir::Token::getLoc(), getToken(), and parseAffineMapOrIntegerSetReference().
Referenced by mlir::detail::AsmParserImpl< BaseT >::parseAffineMap(), and parseAttribute().
Parse an arbitrary attribute with an optional type.
Parse an arbitrary attribute.
attribute-value ::= unit
| bool-literal | integer-literal (:
(index-type | integer-type))? | float-literal (:
float-type)? | string-literal (:
type)? | type | [
:
(integer-type | float-type) tensor-literal ]
| [
(attribute-value (,
attribute-value)*)? ]
| {
(attribute-entry (,
attribute-entry)*)? }
| symbol-ref-id (::
symbol-ref-id)* | dense
<
tensor-literal >
:
(tensor-type | vector-type) | sparse
<
attribute-value ,
attribute-value >
:
(tensor-type | vector-type) | strided
<
[
comma-separated-int-or-question ]
(,
offset
:
integer-literal)? >
| distinct-attribute | extended-attribute
Definition at line 52 of file AttributeParser.cpp.
References mlir::AsmParserState::addUses(), mlir::detail::ParserState::asmState, builder, codeCompleteAttribute(), consumeIf(), consumeToken(), emitError(), emitWrongTokenError(), mlir::get(), mlir::Builder::getArrayAttr(), mlir::Builder::getBoolAttr(), getContext(), mlir::NamedAttrList::getDictionary(), mlir::Token::getLoc(), mlir::Token::getStringValue(), mlir::Token::getSymbolReference(), getToken(), mlir::Builder::getUnitAttr(), mlir::OptionalParseResult::has_value(), mlir::detail::ParserState::lex, parseAffineMapReference(), parseAttributeDict(), parseCommaSeparatedListUntil(), parseDecOrHexAttr(), parseDenseArrayAttr(), parseDenseElementsAttr(), parseDenseResourceElementsAttr(), parseDistinctAttr(), parseExtendedAttr(), parseFloatAttr(), parseIntegerSetReference(), parseLocationInstance(), parseOptionalType(), parseSparseElementsAttr(), parseStridedLayoutAttr(), parseToken(), parseType(), mlir::Lexer::resetPointer(), and state.
Referenced by mlir::detail::AsmParserImpl< BaseT >::parseAttribute(), parseAttributeDict(), mlir::detail::AsmParserImpl< BaseT >::parseCustomAttributeWithFallback(), parseDistinctAttr(), parseFusedLocation(), parseMemRefType(), and parseOptionalAttribute().
ParseResult Parser::parseAttributeDict | ( | NamedAttrList & | attributes | ) |
Parse an attribute dictionary.
Attribute dictionary.
attribute-dict ::= {
}
| {
attribute-entry (,
attribute-entry)* }
attribute-entry ::= (bare-id | string-literal) =
attribute-value
Definition at line 299 of file AttributeParser.cpp.
References mlir::AsmParser::Braces, builder, consumeIf(), consumeToken(), emitError(), emitWrongTokenError(), getContext(), mlir::MLIRContext::getOrLoadDialect(), mlir::Builder::getStringAttr(), mlir::Token::getStringValue(), getToken(), getTokenSpelling(), mlir::Builder::getUnitAttr(), mlir::Token::is(), mlir::Token::isAny(), mlir::Token::isKeyword(), parseAttribute(), parseCommaSeparatedList(), and mlir::NamedAttrList::push_back().
Referenced by parseAttribute(), mlir::detail::AsmParserImpl< BaseT >::parseOptionalAttrDict(), and mlir::detail::AsmParserImpl< BaseT >::parseOptionalAttrDictWithKeyword().
ParseResult Parser::parseCallSiteLocation | ( | LocationAttr & | loc | ) |
Parse a callsite location instance.
Specific location instances.
location-inst ::= filelinecol-location | name-location | callsite-location | fused-location | unknown-location filelinecol-location ::= string-literal ':' integer-literal ':' integer-literal name-location ::= string-literal callsite-location ::= 'callsite' '(' location-inst 'at' location-inst ')' fused-location ::= fused ('<' attribute-value '>')? '[' location-inst (location-inst ',')* ']' unknown-location ::= 'unknown'
Definition at line 34 of file LocationParser.cpp.
References consumeToken(), emitWrongTokenError(), mlir::get(), getToken(), parseLocationInstance(), and parseToken().
Referenced by parseLocationInstance().
ParseResult Parser::parseCommaSeparatedList | ( | Delimiter | delimiter, |
function_ref< ParseResult()> | parseElementFn, | ||
StringRef | contextMessage = StringRef() |
||
) |
Parse a list of comma-separated items with an optional delimiter.
If a delimiter is provided, then an empty list is allowed. If not, then at least one element will be parsed.
Definition at line 84 of file Parser.cpp.
References mlir::AsmParser::Braces, consumeIf(), getToken(), mlir::AsmParser::LessGreater, mlir::AsmParser::None, mlir::AsmParser::OptionalBraces, mlir::AsmParser::OptionalLessGreater, mlir::AsmParser::OptionalParen, mlir::AsmParser::OptionalSquare, mlir::AsmParser::Paren, parseToken(), and mlir::AsmParser::Square.
Referenced by parseAttributeDict(), mlir::detail::AsmParserImpl< BaseT >::parseCommaSeparatedList(), parseCommaSeparatedList(), parseCommaSeparatedListUntil(), parseDenseArrayAttr(), parseFusedLocation(), and parseTypeListNoParens().
|
inline |
Parse a comma separated list of elements that must have at least one entry in it.
Definition at line 57 of file Parser.h.
References mlir::AsmParser::None, and parseCommaSeparatedList().
ParseResult Parser::parseCommaSeparatedListUntil | ( | Token::Kind | rightToken, |
function_ref< ParseResult()> | parseElement, | ||
bool | allowEmptyList = true |
||
) |
Parse a comma-separated list of elements up until the specified end token.
Parse a comma-separated list of elements, terminated with an arbitrary token.
This allows empty lists if allowEmptyList is true.
abstract-list ::= rightToken // if allowEmptyList == true abstract-list ::= element (',' element)* rightToken
Definition at line 173 of file Parser.cpp.
References consumeToken(), emitWrongTokenError(), getToken(), mlir::Token::getTokenSpelling(), parseCommaSeparatedList(), and parseToken().
Referenced by parseAttribute(), and parseMemRefType().
Type Parser::parseComplexType | ( | ) |
Parse a complex type.
complex-type ::= complex
<
type >
Definition at line 135 of file TypeParser.cpp.
References consumeToken(), emitError(), mlir::get(), mlir::Token::getLoc(), getToken(), parseToken(), and parseType().
Referenced by parseNonFunctionType().
Parse a decimal or a hexadecimal literal, which can be either an integer or a float attribute.
Definition at line 410 of file AttributeParser.cpp.
References buildAttributeAPInt(), builder, consumeIf(), consumeToken(), emitError(), mlir::get(), mlir::Builder::getIntegerAttr(), mlir::Builder::getIntegerType(), mlir::Token::getLoc(), mlir::Token::getSpelling(), getToken(), mlir::Type::isUnsignedInteger(), parseFloatFromIntegerLiteral(), and parseType().
Referenced by parseAttribute().
Parse a DenseArrayAttr.
Parse a dense array attribute.
Definition at line 938 of file AttributeParser.cpp.
References consumeIf(), consumeToken(), emitError(), mlir::get(), mlir::Type::getIntOrFloatBitWidth(), mlir::Token::getLoc(), getToken(), mlir::Type::isInteger(), mlir::Type::isIntOrIndex(), mlir::Type::isIntOrIndexOrFloat(), parseCommaSeparatedList(), parseToken(), and parseType().
Referenced by parseAttribute().
Parse a dense elements attribute.
Definition at line 984 of file AttributeParser.cpp.
References consumeIf(), consumeToken(), mlir::Token::getLoc(), getToken(), parseElementsLiteralType(), and parseToken().
Referenced by parseAttribute().
Parse a dense resource elements attribute.
Definition at line 1008 of file AttributeParser.cpp.
References consumeToken(), emitError(), mlir::get(), getContext(), mlir::Token::getLoc(), getToken(), parseResourceHandle(), parseToken(), and parseType().
Referenced by parseAttribute().
|
inline |
Definition at line 67 of file Parser.h.
References parseDialectSymbolBody().
ParseResult Parser::parseDialectSymbolBody | ( | StringRef & | body, |
bool & | isCodeCompletion | ||
) |
Parse the body of a dialect symbol, which starts and ends with <>'s, and may be recursive.
pretty-dialect-sym-body ::= '<' pretty-dialect-sym-contents+ '>' pretty-dialect-sym-contents ::= pretty-dialect-sym-body | '(' pretty-dialect-sym-contents+ ')' | '[' pretty-dialect-sym-contents+ ']' | '{' pretty-dialect-sym-contents+ '}' | '[^[<({>])}\0]+'
Return with the 'body' StringRef encompassing the entire body. isCodeCompletion
is set to true if the body contained a code completion location, in which case the body is only populated up to the completion.
Definition at line 66 of file DialectSymbolParser.cpp.
References mlir::detail::ParserState::curToken, emitError(), mlir::Lexer::getCodeCompleteLoc(), mlir::Token::getEndLoc(), getTokenSpelling(), mlir::Token::isCodeCompletion(), mlir::Token::isNot(), mlir::detail::ParserState::lex, resetToken(), and state.
Referenced by parseDialectSymbolBody(), and parseExtendedSymbol().
ParseResult Parser::parseDimensionListRanked | ( | SmallVectorImpl< int64_t > & | dimensions, |
bool | allowDynamic = true , |
||
bool | withTrailingX = true |
||
) |
Parse a dimension list of a tensor or memref type.
This populates the dimension list, using ShapedType::kDynamic for the ?
dimensions if allowDynamic
is set and errors out on ?
otherwise. Parsing the trailing x
is configurable.
dimension-list ::= eps | dimension (x
dimension)* dimension-list-with-trailing-x ::= (dimension x
)* dimension ::= ?
| decimal-literal
When allowDynamic
is not set, this is used to parse:
static-dimension-list ::= eps | decimal-literal (x
decimal-literal)* static-dimension-list-with-trailing-x ::= (dimension x
)*
Definition at line 543 of file TypeParser.cpp.
References consumeIf(), emitError(), mlir::Token::getLoc(), getToken(), getTokenSpelling(), parseIntegerInDimensionList(), and parseXInDimensionList().
Referenced by mlir::detail::AsmParserImpl< BaseT >::parseDimensionList(), parseMemRefType(), and parseTensorType().
Parse a distinct attribute.
distinct-attribute ::= distinct
[
integer-literal ]<
attribute-value >
Definition at line 1227 of file AttributeParser.cpp.
References builder, consumeToken(), mlir::DistinctAttr::create(), mlir::detail::SymbolState::distinctAttributes, emitError(), mlir::Token::getLoc(), getToken(), mlir::Token::getUInt64IntegerValue(), mlir::Builder::getUnitAttr(), parseAttribute(), parseToken(), state, and mlir::detail::ParserState::symbols.
Referenced by parseAttribute().
ShapedType Parser::parseElementsLiteralType | ( | Type | type | ) |
Shaped type for elements attribute.
elements-literal-type ::= vector-type | ranked-tensor-type
This method also checks the type has static shape.
Definition at line 1046 of file AttributeParser.cpp.
References emitError(), parseToken(), and parseType().
Referenced by parseDenseElementsAttr(), and parseSparseElementsAttr().
Parse an extended attribute.
extended-attribute ::= (dialect-attribute | attribute-alias) dialect-attribute ::= #
dialect-namespace <
attr-data >
(:
type)? | #
alias-name pretty-dialect-sym-body? (:
type)? attribute-alias ::= #
alias-name
Definition at line 252 of file DialectSymbolParser.cpp.
References mlir::detail::ParserState::asmState, mlir::detail::SymbolState::attributeAliasDefinitions, mlir::get(), getContext(), state, and mlir::detail::ParserState::symbols.
Referenced by parseAttribute(), and parseLocationInstance().
Type Parser::parseExtendedType | ( | ) |
Parse an extended type.
extended-type ::= (dialect-type | type-alias) dialect-type ::= !
dialect-namespace <
"</tt> type-data <tt>"
>
dialect-type ::= !
alias-name pretty-dialect-attribute-body? type-alias ::= !
alias-name
Definition at line 299 of file DialectSymbolParser.cpp.
References getContext().
Referenced by parseNonFunctionType().
Parse a float attribute.
Definition at line 344 of file AttributeParser.cpp.
References builder, consumeIf(), consumeToken(), emitError(), mlir::get(), mlir::Builder::getF64Type(), mlir::Token::getFloatingPointValue(), getToken(), and parseType().
Referenced by parseAttribute().
ParseResult Parser::parseFloatFromIntegerLiteral | ( | std::optional< APFloat > & | result, |
const Token & | tok, | ||
bool | isNegative, | ||
const llvm::fltSemantics & | semantics, | ||
size_t | typeSizeInBits | ||
) |
Parse a floating point value from an integer literal token.
Definition at line 351 of file Parser.cpp.
References mlir::InFlightDiagnostic::attachNote(), emitError(), mlir::Token::getLoc(), and mlir::Token::getSpelling().
Referenced by parseDecOrHexAttr(), and mlir::detail::AsmParserImpl< BaseT >::parseFloat().
ParseResult Parser::parseFunctionResultTypes | ( | SmallVectorImpl< Type > & | elements | ) |
Parse a function result type.
function-result-type ::= type-list-parens | non-function-type
Definition at line 86 of file TypeParser.cpp.
References getToken(), parseNonFunctionType(), and parseTypeListParens().
Referenced by mlir::detail::AsmParserImpl< BaseT >::parseArrowTypeList(), parseFunctionType(), and mlir::detail::AsmParserImpl< BaseT >::parseOptionalArrowTypeList().
Type Parser::parseFunctionType | ( | ) |
Parse a function type.
function-type ::= type-list-parens ->
function-result-type
Definition at line 158 of file TypeParser.cpp.
References builder, mlir::Builder::getFunctionType(), getToken(), parseFunctionResultTypes(), parseToken(), and parseTypeListParens().
Referenced by parseType().
ParseResult Parser::parseFusedLocation | ( | LocationAttr & | loc | ) |
Parse a fused location instance.
Definition at line 66 of file LocationParser.cpp.
References consumeIf(), consumeToken(), mlir::get(), getContext(), parseAttribute(), parseCommaSeparatedList(), parseLocationInstance(), parseToken(), and mlir::AsmParser::Square.
Referenced by parseLocationInstance().
ParseResult Parser::parseIntegerInDimensionList | ( | int64_t & | value | ) |
Definition at line 580 of file TypeParser.cpp.
References consumeToken(), emitError(), getToken(), getTokenSpelling(), mlir::Token::getUInt64IntegerValue(), mlir::detail::ParserState::lex, max(), mlir::Lexer::resetPointer(), and state.
Referenced by parseDimensionListRanked(), and parseVectorDimensionList().
ParseResult Parser::parseIntegerSetReference | ( | IntegerSet & | set | ) |
Definition at line 733 of file AffineParser.cpp.
References emitError(), mlir::Token::getLoc(), getToken(), and parseAffineMapOrIntegerSetReference().
Referenced by parseAttribute(), and mlir::detail::AsmParserImpl< BaseT >::parseIntegerSet().
ParseResult Parser::parseLocationInstance | ( | LocationAttr & | loc | ) |
Parse a raw location instance.
Definition at line 156 of file LocationParser.cpp.
References consumeToken(), emitError(), emitWrongTokenError(), mlir::get(), getContext(), getToken(), parseCallSiteLocation(), parseExtendedAttr(), parseFusedLocation(), and parseNameOrFileLineColLocation().
Referenced by parseAttribute(), parseCallSiteLocation(), parseFusedLocation(), and parseNameOrFileLineColLocation().
Type Parser::parseMemRefType | ( | ) |
Parse a memref type.
memref-type ::= ranked-memref-type | unranked-memref-type
ranked-memref-type ::= memref
<
dimension-list-ranked type (,
layout-specification)? (,
memory-space)? >
unranked-memref-type ::= memref
<*x
type (,
memory-space)? >
stride-list ::= [
(dimension (,
dimension)*)? ]
strided-layout ::= offset:
dimension ,
strides:
stride-list layout-specification ::= semi-affine-map | strided-layout | attribute memory-space ::= integer-literal | attribute
Definition at line 184 of file TypeParser.cpp.
References consumeIf(), consumeToken(), emitError(), mlir::Token::getLoc(), getToken(), mlir::BaseMemRefType::isValidElementType(), parseAttribute(), parseCommaSeparatedListUntil(), parseDimensionListRanked(), parseToken(), parseType(), and parseXInDimensionList().
Referenced by parseNonFunctionType().
ParseResult Parser::parseNameOrFileLineColLocation | ( | LocationAttr & | loc | ) |
Parse a name or FileLineCol location instance.
Definition at line 100 of file LocationParser.cpp.
References consumeIf(), consumeToken(), emitError(), emitWrongTokenError(), mlir::get(), getContext(), mlir::Token::getStringValue(), getToken(), mlir::Token::getUnsignedIntegerValue(), parseLocationInstance(), and parseToken().
Referenced by parseLocationInstance().
Type Parser::parseNonFunctionType | ( | ) |
Parse a non function type.
Parse any type except the function type.
non-function-type ::= integer-type | index-type | float-type | extended-type | vector-type | tensor-type | memref-type | complex-type | tuple-type | none-type
index-type ::= index
float-type ::= f16
| bf16
| f32
| f64
| f80
| f128
none-type ::= none
Definition at line 276 of file TypeParser.cpp.
References builder, codeCompleteType(), consumeToken(), emitError(), emitWrongTokenError(), mlir::get(), mlir::Builder::getBF16Type(), getContext(), mlir::Builder::getF128Type(), mlir::Builder::getF16Type(), mlir::Builder::getF32Type(), mlir::Builder::getF64Type(), mlir::Builder::getF80Type(), mlir::Builder::getFloat4E2M1FNType(), mlir::Builder::getFloat6E2M3FNType(), mlir::Builder::getFloat6E3M2FNType(), mlir::Builder::getFloat8E3M4Type(), mlir::Builder::getFloat8E4M3B11FNUZType(), mlir::Builder::getFloat8E4M3FNType(), mlir::Builder::getFloat8E4M3FNUZType(), mlir::Builder::getFloat8E4M3Type(), mlir::Builder::getFloat8E5M2FNUZType(), mlir::Builder::getFloat8E5M2Type(), mlir::Builder::getFloat8E8M0FNUType(), mlir::Builder::getIndexType(), mlir::Token::getIntTypeBitwidth(), mlir::Builder::getNoneType(), mlir::Builder::getTF32Type(), getToken(), parseComplexType(), parseExtendedType(), parseMemRefType(), parseTensorType(), parseTupleType(), parseVectorType(), and mlir::quant::QuantizationFlags::Signed.
Referenced by parseFunctionResultTypes(), and parseType().
OptionalParseResult Parser::parseOptionalAttribute | ( | ArrayAttr & | attribute, |
Type | type | ||
) |
Definition at line 280 of file AttributeParser.cpp.
References parseOptionalAttributeWithToken().
OptionalParseResult Parser::parseOptionalAttribute | ( | Attribute & | attribute, |
Type | type = {} |
||
) |
Parse an optional attribute with the provided type.
Definition at line 248 of file AttributeParser.cpp.
References mlir::get(), getToken(), mlir::OptionalParseResult::has_value(), parseAttribute(), and parseOptionalType().
Referenced by mlir::detail::AsmParserImpl< BaseT >::parseOptionalAttribute(), and parseTensorType().
OptionalParseResult Parser::parseOptionalAttribute | ( | StringAttr & | attribute, |
Type | type | ||
) |
Definition at line 284 of file AttributeParser.cpp.
References parseOptionalAttributeWithToken().
OptionalParseResult Parser::parseOptionalAttribute | ( | SymbolRefAttr & | result, |
Type | type | ||
) |
Definition at line 288 of file AttributeParser.cpp.
References parseOptionalAttributeWithToken().
|
inline |
Parse an optional attribute that is demarcated by a specific token.
Definition at line 249 of file Parser.h.
Referenced by parseOptionalAttribute().
OptionalParseResult Parser::parseOptionalDecimalInteger | ( | APInt & | result | ) |
Parse an optional integer value only in decimal format from the stream.
Definition at line 312 of file Parser.cpp.
References consumeIf(), consumeToken(), emitError(), mlir::Token::getLoc(), mlir::Token::getSpelling(), getToken(), mlir::Token::isNot(), mlir::detail::ParserState::lex, parseToken(), mlir::Lexer::resetPointer(), state, and toLower().
Referenced by mlir::detail::AsmParserImpl< BaseT >::parseOptionalDecimalInteger().
OptionalParseResult Parser::parseOptionalInteger | ( | APInt & | result | ) |
Parse an optional integer value from the stream.
Definition at line 275 of file Parser.cpp.
References consumeIf(), emitError(), mlir::Token::getLoc(), mlir::Token::getSpelling(), getToken(), mlir::Token::isNot(), and parseToken().
Referenced by mlir::detail::AsmParserImpl< BaseT >::parseOptionalInteger().
ParseResult Parser::parseOptionalKeyword | ( | StringRef * | keyword | ) |
Parse a keyword, if present, into 'keyword'.
Definition at line 381 of file Parser.cpp.
References consumeToken(), getTokenSpelling(), and isCurrentTokenAKeyword().
Referenced by parseResourceHandle().
OptionalParseResult Parser::parseOptionalType | ( | Type & | type | ) |
Optionally parse a type.
Definition at line 32 of file TypeParser.cpp.
References getToken(), and parseType().
Referenced by parseAttribute(), parseOptionalAttribute(), and mlir::detail::AsmParserImpl< BaseT >::parseOptionalType().
FailureOr< AsmDialectResourceHandle > Parser::parseResourceHandle | ( | const OpAsmDialectInterface * | dialect, |
StringRef & | name | ||
) |
Parse a handle to a dialect resource within the assembly format.
Definition at line 395 of file Parser.cpp.
References mlir::OpAsmDialectInterface::declareResource(), mlir::detail::SymbolState::dialectResources, emitError(), mlir::Token::getLoc(), mlir::OpAsmDialectInterface::getResourceKey(), getState(), getToken(), parseOptionalKeyword(), and mlir::detail::ParserState::symbols.
Referenced by parseDenseResourceElementsAttr(), parseResourceHandle(), and mlir::detail::AsmParserImpl< BaseT >::parseResourceHandle().
FailureOr< AsmDialectResourceHandle > Parser::parseResourceHandle | ( | Dialect * | dialect | ) |
Definition at line 424 of file Parser.cpp.
References emitError(), mlir::Dialect::getNamespace(), and parseResourceHandle().
Parse a sparse elements attribute.
Parse the indices. We don't allow hex values here as we may need to use the inferred shape.
Parse the values.
Definition at line 1068 of file AttributeParser.cpp.
References builder, consumeIf(), consumeToken(), mlir::get(), mlir::DenseElementsAttr::get(), mlir::Builder::getIntegerType(), mlir::Token::getLoc(), getToken(), parseElementsLiteralType(), and parseToken().
Referenced by parseAttribute().
Attribute Parser::parseStridedLayoutAttr | ( | ) |
Parse a strided layout attribute.
Definition at line 1144 of file AttributeParser.cpp.
References consumeIf(), consumeToken(), emitError(), emitWrongTokenError(), mlir::get(), getContext(), mlir::Token::getLoc(), getToken(), mlir::Token::getUInt64IntegerValue(), max(), parseToken(), and mlir::verify().
Referenced by parseAttribute().
Type Parser::parseTensorType | ( | ) |
Parse a tensor type.
tensor-type ::= tensor
<
dimension-list type >
dimension-list ::= dimension-list-ranked | *x
Definition at line 392 of file TypeParser.cpp.
References consumeIf(), consumeToken(), emitError(), mlir::get(), mlir::Token::getLoc(), getToken(), mlir::TensorType::isValidElementType(), parseDimensionListRanked(), parseOptionalAttribute(), parseToken(), parseType(), and parseXInDimensionList().
Referenced by parseNonFunctionType().
ParseResult Parser::parseToken | ( | Token::Kind | expectedToken, |
const Twine & | message | ||
) |
Consume the specified token if present and return success.
On failure, output a diagnostic and return failure.
Definition at line 267 of file Parser.cpp.
References consumeIf(), and emitWrongTokenError().
Referenced by mlir::detail::AsmParserImpl< BaseT >::parseArrow(), parseAttribute(), parseCallSiteLocation(), mlir::detail::AsmParserImpl< BaseT >::parseColon(), mlir::detail::AsmParserImpl< BaseT >::parseColonType(), mlir::detail::AsmParserImpl< BaseT >::parseColonTypeList(), mlir::detail::AsmParserImpl< BaseT >::parseComma(), parseCommaSeparatedList(), parseCommaSeparatedListUntil(), parseComplexType(), parseDenseArrayAttr(), parseDenseElementsAttr(), parseDenseResourceElementsAttr(), parseDistinctAttr(), parseElementsLiteralType(), mlir::detail::AsmParserImpl< BaseT >::parseEllipsis(), mlir::detail::AsmParserImpl< BaseT >::parseEqual(), parseFunctionType(), parseFusedLocation(), mlir::detail::AsmParserImpl< BaseT >::parseGreater(), mlir::detail::AsmParserImpl< BaseT >::parseLBrace(), mlir::detail::AsmParserImpl< BaseT >::parseLess(), mlir::detail::AsmParserImpl< BaseT >::parseLParen(), mlir::detail::AsmParserImpl< BaseT >::parseLSquare(), parseMemRefType(), mlir::detail::AsmParserImpl< BaseT >::parseMinus(), parseNameOrFileLineColLocation(), parseOptionalDecimalInteger(), parseOptionalInteger(), mlir::detail::AsmParserImpl< BaseT >::parsePlus(), mlir::detail::AsmParserImpl< BaseT >::parseQuestion(), mlir::detail::AsmParserImpl< BaseT >::parseRBrace(), mlir::detail::AsmParserImpl< BaseT >::parseRParen(), mlir::detail::AsmParserImpl< BaseT >::parseRSquare(), parseSparseElementsAttr(), mlir::detail::AsmParserImpl< BaseT >::parseStar(), parseStridedLayoutAttr(), parseTensorType(), parseTupleType(), parseTypeListParens(), parseVectorType(), and mlir::detail::AsmParserImpl< BaseT >::parseVerticalBar().
Type Parser::parseTupleType | ( | ) |
Parse a tuple type.
tuple-type ::= tuple
<
(type (,
type)*)? >
Definition at line 450 of file TypeParser.cpp.
References consumeIf(), consumeToken(), mlir::get(), getContext(), parseToken(), and parseTypeListNoParens().
Referenced by parseNonFunctionType().
Type Parser::parseType | ( | ) |
Parse an arbitrary type.
type ::= function-type | non-function-type
Definition at line 75 of file TypeParser.cpp.
References getToken(), parseFunctionType(), and parseNonFunctionType().
Referenced by parseAttribute(), mlir::detail::AsmParserImpl< BaseT >::parseColonType(), parseComplexType(), mlir::detail::AsmParserImpl< BaseT >::parseCustomTypeWithFallback(), parseDecOrHexAttr(), parseDenseArrayAttr(), parseDenseResourceElementsAttr(), parseElementsLiteralType(), parseFloatAttr(), parseMemRefType(), parseOptionalType(), parseTensorType(), mlir::detail::AsmParserImpl< BaseT >::parseType(), parseTypeListNoParens(), and parseVectorType().
ParseResult Parser::parseTypeListNoParens | ( | SmallVectorImpl< Type > & | elements | ) |
Parse a list of types without an enclosing parenthesis.
The list must have at least one member.
type-list-no-parens ::= type (,
type)*
Definition at line 102 of file TypeParser.cpp.
References parseCommaSeparatedList(), and parseType().
Referenced by mlir::detail::AsmParserImpl< BaseT >::parseColonTypeList(), mlir::detail::AsmParserImpl< BaseT >::parseOptionalColonTypeList(), parseTupleType(), and parseTypeListParens().
ParseResult Parser::parseTypeListParens | ( | SmallVectorImpl< Type > & | elements | ) |
Parse a parenthesized list of types.
type-list-parens ::= (
)
| (
type-list-no-parens )
Definition at line 117 of file TypeParser.cpp.
References consumeToken(), getToken(), parseToken(), and parseTypeListNoParens().
Referenced by parseFunctionResultTypes(), and parseFunctionType().
ParseResult Parser::parseVectorDimensionList | ( | SmallVectorImpl< int64_t > & | dimensions, |
SmallVectorImpl< bool > & | scalableDims | ||
) |
Parse a dimension list in a vector type.
This populates the dimension list. For i-th dimension, scalableDims[i]
contains either:
false
for a non-scalable dimension (e.g. 4
),true
for a scalable dimension (e.g. [4]
).vector-dim-list := (static-dim-list x
)? static-dim-list ::= static-dim (x
static-dim)* static-dim ::= (decimal-literal | [
decimal-literal ]
)
Definition at line 507 of file TypeParser.cpp.
References consumeIf(), emitWrongTokenError(), getToken(), parseIntegerInDimensionList(), and parseXInDimensionList().
Referenced by parseVectorType().
VectorType Parser::parseVectorType | ( | ) |
Parse a vector type.
vector-type ::= vector
<
vector-dim-list vector-element-type >
vector-dim-list := (static-dim-list x
)? ([
static-dim-list ]
x
)? static-dim-list ::= decimal-literal (x
decimal-literal)*
Definition at line 476 of file TypeParser.cpp.
References consumeToken(), mlir::Token::getLoc(), getToken(), parseToken(), parseType(), and parseVectorDimensionList().
Referenced by parseNonFunctionType().
ParseResult Parser::parseXInDimensionList | ( | ) |
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.
Definition at line 608 of file TypeParser.cpp.
References consumeToken(), emitWrongTokenError(), getToken(), getTokenSpelling(), mlir::detail::ParserState::lex, mlir::Lexer::resetPointer(), and state.
Referenced by parseDimensionListRanked(), parseMemRefType(), parseTensorType(), parseVectorDimensionList(), and mlir::detail::AsmParserImpl< BaseT >::parseXInDimensionList().
|
inline |
Reset the parser to the given lexer position.
Resetting the parser/lexer position does not update 'state.lastToken'. 'state.lastToken' is the last parsed token, and is used to provide the scope end location for OperationDefinitions. To ensure the correctness of the end location, the last consumed token of an OperationDefinition needs to be the last token belonging to it.
Definition at line 139 of file Parser.h.
References mlir::detail::ParserState::curToken, mlir::detail::ParserState::lex, mlir::Lexer::lexToken(), mlir::Lexer::resetPointer(), and state.
Referenced by parseDialectSymbolBody().
Builder mlir::detail::Parser::builder |
Definition at line 30 of file Parser.h.
Referenced by mlir::detail::AsmParserImpl< BaseT >::getBuilder(), parseAttribute(), parseAttributeDict(), parseDecOrHexAttr(), parseDistinctAttr(), parseFloatAttr(), parseFunctionType(), parseNonFunctionType(), and parseSparseElementsAttr().
|
protected |
The Parser is subclassed and reinstantiated.
Do not add additional non-trivial state here, add it to the ParserState class.
Definition at line 359 of file Parser.h.
Referenced by codeCompleteAttribute(), codeCompleteDialectName(), codeCompleteDialectOrElidedOpName(), codeCompleteDialectSymbol(), codeCompleteExpectedTokens(), codeCompleteOperationName(), codeCompleteOptionalTokens(), codeCompleteType(), consumeToken(), emitError(), emitWrongTokenError(), getContext(), getEncodedSourceLocation(), getLastToken(), getSourceMgr(), getState(), getToken(), getTokenSpelling(), parseAffineExprOfSSAIds(), parseAffineExprReference(), parseAffineMapOfSSAIds(), parseAffineMapOrIntegerSetReference(), parseAttribute(), parseDialectSymbolBody(), parseDistinctAttr(), parseExtendedAttr(), parseIntegerInDimensionList(), parseOptionalDecimalInteger(), parseXInDimensionList(), and resetToken().