LLVM 20.0.0git
|
Generic assembler parser interface, for use by target specific assembly parsers. More...
#include "llvm/MC/MCParser/MCAsmParser.h"
Classes | |
struct | MCPendingError |
Public Types | |
using | DirectiveHandler = bool(*)(MCAsmParserExtension *, StringRef, SMLoc) |
using | ExtensionDirectiveHandler = std::pair< MCAsmParserExtension *, DirectiveHandler > |
Public Member Functions | |
MCAsmParser (const MCAsmParser &)=delete | |
MCAsmParser & | operator= (const MCAsmParser &)=delete |
virtual | ~MCAsmParser () |
virtual void | addDirectiveHandler (StringRef Directive, ExtensionDirectiveHandler Handler)=0 |
virtual void | addAliasForDirective (StringRef Directive, StringRef Alias)=0 |
virtual SourceMgr & | getSourceManager ()=0 |
virtual MCAsmLexer & | getLexer ()=0 |
const MCAsmLexer & | getLexer () const |
virtual MCContext & | getContext ()=0 |
virtual MCStreamer & | getStreamer ()=0 |
Return the output streamer for the assembler. | |
MCTargetAsmParser & | getTargetParser () const |
void | setTargetParser (MCTargetAsmParser &P) |
virtual unsigned | getAssemblerDialect () |
virtual void | setAssemblerDialect (unsigned i) |
bool | getShowParsedOperands () const |
void | setShowParsedOperands (bool Value) |
virtual bool | Run (bool NoInitialTextSection, bool NoFinalize=false)=0 |
Run the parser on the input source buffer. | |
virtual void | setParsingMSInlineAsm (bool V)=0 |
virtual bool | isParsingMSInlineAsm ()=0 |
virtual bool | discardLTOSymbol (StringRef) const |
virtual bool | isParsingMasm () const |
virtual bool | defineMacro (StringRef Name, StringRef Value) |
virtual bool | lookUpField (StringRef Name, AsmFieldInfo &Info) const |
virtual bool | lookUpField (StringRef Base, StringRef Member, AsmFieldInfo &Info) const |
virtual bool | lookUpType (StringRef Name, AsmTypeInfo &Info) const |
virtual bool | parseMSInlineAsm (std::string &AsmString, unsigned &NumOutputs, unsigned &NumInputs, SmallVectorImpl< std::pair< void *, bool > > &OpDecls, SmallVectorImpl< std::string > &Constraints, SmallVectorImpl< std::string > &Clobbers, const MCInstrInfo *MII, MCInstPrinter *IP, MCAsmParserSemaCallback &SI)=0 |
Parse MS-style inline assembly. | |
virtual void | Note (SMLoc L, const Twine &Msg, SMRange Range=std::nullopt)=0 |
Emit a note at the location L , with the message Msg . | |
virtual bool | Warning (SMLoc L, const Twine &Msg, SMRange Range=std::nullopt)=0 |
Emit a warning at the location L , with the message Msg . | |
bool | Error (SMLoc L, const Twine &Msg, SMRange Range=std::nullopt) |
Return an error at the location L , with the message Msg . | |
virtual bool | printError (SMLoc L, const Twine &Msg, SMRange Range=std::nullopt)=0 |
Emit an error at the location L , with the message Msg . | |
bool | hasPendingError () |
bool | printPendingErrors () |
void | clearPendingErrors () |
bool | addErrorSuffix (const Twine &Suffix) |
virtual const AsmToken & | Lex ()=0 |
Get the next AsmToken in the stream, possibly handling file inclusion first. | |
const AsmToken & | getTok () const |
Get the current AsmToken from the stream. | |
bool | TokError (const Twine &Msg, SMRange Range=std::nullopt) |
Report an error at the current lexer location. | |
bool | parseTokenLoc (SMLoc &Loc) |
bool | parseToken (AsmToken::TokenKind T, const Twine &Msg="unexpected token") |
bool | parseOptionalToken (AsmToken::TokenKind T) |
Attempt to parse and consume token, returning true on success. | |
bool | parseComma () |
bool | parseRParen () |
bool | parseEOL () |
bool | parseEOL (const Twine &ErrMsg) |
bool | parseMany (function_ref< bool()> parseOne, bool hasComma=true) |
bool | parseIntToken (int64_t &V, const Twine &ErrMsg) |
bool | check (bool P, const Twine &Msg) |
bool | check (bool P, SMLoc Loc, const Twine &Msg) |
virtual bool | parseIdentifier (StringRef &Res)=0 |
Parse an identifier or string (as a quoted identifier) and set Res to the identifier contents. | |
virtual StringRef | parseStringToEndOfStatement ()=0 |
Parse up to the end of statement and return the contents from the current token until the end of the statement; the current token on exit will be either the EndOfStatement or EOF. | |
virtual bool | parseEscapedString (std::string &Data)=0 |
Parse the current token as a string which may include escaped characters and return the string contents. | |
virtual bool | parseAngleBracketString (std::string &Data)=0 |
Parse an angle-bracket delimited string at the current position if one is present, returning the string contents. | |
virtual void | eatToEndOfStatement ()=0 |
Skip to the end of the current statement, for error recovery. | |
virtual bool | parseExpression (const MCExpr *&Res, SMLoc &EndLoc)=0 |
Parse an arbitrary expression. | |
bool | parseExpression (const MCExpr *&Res) |
virtual bool | parsePrimaryExpr (const MCExpr *&Res, SMLoc &EndLoc, AsmTypeInfo *TypeInfo)=0 |
Parse a primary expression. | |
virtual bool | parseParenExpression (const MCExpr *&Res, SMLoc &EndLoc)=0 |
Parse an arbitrary expression, assuming that an initial '(' has already been consumed. | |
virtual bool | parseAbsoluteExpression (int64_t &Res)=0 |
Parse an expression which must evaluate to an absolute value. | |
virtual bool | checkForValidSection ()=0 |
Ensure that we have a valid section set in the streamer. | |
virtual bool | parseParenExprOfDepth (unsigned ParenDepth, const MCExpr *&Res, SMLoc &EndLoc)=0 |
Parse an arbitrary expression of a specified parenthesis depth, assuming that the initial '(' characters have already been consumed. | |
bool | parseGNUAttribute (SMLoc L, int64_t &Tag, int64_t &IntegerValue) |
Parse a .gnu_attribute. | |
Protected Member Functions | |
MCAsmParser () | |
Protected Attributes | |
SmallVector< MCPendingError, 0 > | PendingErrors |
bool | HadError = false |
Flag tracking whether any errors have been encountered. | |
bool | ShowParsedOperands = false |
Generic assembler parser interface, for use by target specific assembly parsers.
Definition at line 123 of file MCAsmParser.h.
using llvm::MCAsmParser::DirectiveHandler = bool (*)(MCAsmParserExtension*, StringRef, SMLoc) |
Definition at line 125 of file MCAsmParser.h.
using llvm::MCAsmParser::ExtensionDirectiveHandler = std::pair<MCAsmParserExtension*, DirectiveHandler> |
Definition at line 126 of file MCAsmParser.h.
|
protecteddefault |
|
delete |
|
virtualdefault |
|
pure virtual |
|
pure virtual |
Definition at line 116 of file MCAsmParser.cpp.
References llvm::AsmToken::Error, getTok(), Lex(), PendingErrors, and llvm::Twine::toVector().
Referenced by llvm::MCAsmParserExtension::addErrorSuffix().
Definition at line 87 of file MCAsmParser.cpp.
References check(), getTok(), and P.
Referenced by check(), and llvm::MCAsmParserExtension::check().
Definition at line 91 of file MCAsmParser.cpp.
References P.
|
pure virtual |
Ensure that we have a valid section set in the streamer.
Otherwise, report an error and switch to .text.
|
inline |
Definition at line 246 of file MCAsmParser.h.
References PendingErrors.
Definition at line 189 of file MCAsmParser.h.
Definition at line 185 of file MCAsmParser.h.
|
pure virtual |
Skip to the end of the current statement, for error recovery.
Return an error at the location L
, with the message Msg
.
This may be modified before being emitted.
Definition at line 101 of file MCAsmParser.cpp.
References llvm::AsmToken::Error, getLexer(), getTok(), llvm::MCAsmLexer::Lex(), llvm::MCAsmParser::MCPendingError::Loc, llvm::MCAsmParser::MCPendingError::Msg, PendingErrors, llvm::MCAsmParser::MCPendingError::Range, Range, and llvm::Twine::toVector().
Referenced by llvm::MCAsmParserExtension::Error(), and llvm::MCParserUtils::parseAssignmentExpression().
|
inlinevirtual |
Definition at line 173 of file MCAsmParser.h.
|
pure virtual |
|
inline |
Definition at line 161 of file MCAsmParser.h.
References getLexer().
|
pure virtual |
Referenced by Error(), expectAbsExpression(), llvm::MCAsmParserExtension::getLexer(), getLexer(), getTok(), parseExpr(), and TokError().
|
inline |
Definition at line 176 of file MCAsmParser.h.
References ShowParsedOperands.
|
pure virtual |
Referenced by llvm::MCAsmParserExtension::getSourceManager().
|
pure virtual |
Return the output streamer for the assembler.
Referenced by llvm::MCAsmParserExtension::getStreamer(), and llvm::MCParserUtils::parseAssignmentExpression().
|
inline |
Definition at line 170 of file MCAsmParser.h.
Get the current AsmToken from the stream.
Definition at line 40 of file MCAsmParser.cpp.
References getLexer(), and llvm::MCAsmLexer::getTok().
Referenced by addErrorSuffix(), check(), Error(), llvm::MCAsmParserExtension::getTok(), llvm::MCParserUtils::parseAssignmentExpression(), parseEOL(), parseGNUAttribute(), parseIntToken(), parseOptionalToken(), parseToken(), and parseTokenLoc().
|
inline |
Definition at line 235 of file MCAsmParser.h.
References PendingErrors.
|
inlinevirtual |
Definition at line 187 of file MCAsmParser.h.
|
pure virtual |
Get the next AsmToken in the stream, possibly handling file inclusion first.
Referenced by addErrorSuffix(), llvm::MCAsmParserExtension::Lex(), parseEOL(), parseGNUAttribute(), parseIntToken(), and parseToken().
|
inlinevirtual |
Definition at line 194 of file MCAsmParser.h.
|
inlinevirtual |
Definition at line 191 of file MCAsmParser.h.
|
inlinevirtual |
Definition at line 199 of file MCAsmParser.h.
|
pure virtual |
Emit a note at the location L
, with the message Msg
.
Referenced by llvm::MCAsmParserExtension::Note().
|
delete |
|
pure virtual |
Parse an expression which must evaluate to an absolute value.
Res | - The value of the absolute expression. The result is undefined on error. |
Referenced by expectAbsExpression().
|
pure virtual |
Parse an angle-bracket delimited string at the current position if one is present, returning the string contents.
|
inline |
Definition at line 266 of file MCAsmParser.h.
References llvm::AsmToken::Comma, and parseToken().
bool MCAsmParser::parseEOL | ( | ) |
Definition at line 49 of file MCAsmParser.cpp.
References llvm::AsmToken::EndOfStatement, getTok(), and Lex().
Referenced by llvm::MCParserUtils::parseAssignmentExpression(), llvm::MCAsmParserExtension::parseEOL(), and parseToken().
Definition at line 56 of file MCAsmParser.cpp.
References llvm::AsmToken::EndOfStatement, getTok(), and Lex().
|
pure virtual |
Parse the current token as a string which may include escaped characters and return the string contents.
Definition at line 139 of file MCAsmParser.cpp.
References parseExpression().
|
pure virtual |
Parse an arbitrary expression.
Res | - The value of the expression. The result is undefined on error. |
Referenced by llvm::MCParserUtils::parseAssignmentExpression(), parseExpr(), and parseExpression().
Parse a .gnu_attribute.
Definition at line 144 of file MCAsmParser.cpp.
References llvm::AsmToken::getIntVal(), llvm::AsmToken::getLoc(), getTok(), llvm::AsmToken::Integer, llvm::AsmToken::isNot(), Lex(), and llvm::Tag.
Parse an identifier or string (as a quoted identifier) and set Res
to the identifier contents.
Definition at line 72 of file MCAsmParser.cpp.
References llvm::AsmToken::getIntVal(), getTok(), llvm::AsmToken::Integer, Lex(), and TokError().
bool MCAsmParser::parseMany | ( | function_ref< bool()> | parseOne, |
bool | hasComma = true |
||
) |
Definition at line 125 of file MCAsmParser.cpp.
References llvm::AsmToken::Comma, llvm::AsmToken::EndOfStatement, parseOptionalToken(), and parseToken().
Referenced by llvm::MCAsmParserExtension::parseMany().
|
pure virtual |
Parse MS-style inline assembly.
bool MCAsmParser::parseOptionalToken | ( | AsmToken::TokenKind | T | ) |
Attempt to parse and consume token, returning true on success.
Definition at line 80 of file MCAsmParser.cpp.
References llvm::AsmToken::getKind(), getTok(), and parseToken().
Referenced by parseMany(), and llvm::MCAsmParserExtension::parseOptionalToken().
|
pure virtual |
Parse an arbitrary expression, assuming that an initial '(' has already been consumed.
Res | - The value of the expression. The result is undefined on error. |
|
pure virtual |
Parse an arbitrary expression of a specified parenthesis depth, assuming that the initial '(' characters have already been consumed.
ParenDepth | - Specifies how many trailing expressions outside the current parentheses we have to parse. |
Res | - The value of the expression. The result is undefined on error. |
|
pure virtual |
Parse a primary expression.
Res | - The value of the expression. The result is undefined on error. |
Referenced by llvm::MCTargetAsmParser::parsePrimaryExpr().
|
inline |
Definition at line 267 of file MCAsmParser.h.
References parseToken(), and llvm::AsmToken::RParen.
|
pure virtual |
Parse up to the end of statement and return the contents from the current token until the end of the statement; the current token on exit will be either the EndOfStatement or EOF.
bool MCAsmParser::parseToken | ( | AsmToken::TokenKind | T, |
const Twine & | Msg = "unexpected token" |
||
) |
Definition at line 63 of file MCAsmParser.cpp.
References llvm::AsmToken::EndOfStatement, getTok(), Lex(), and parseEOL().
Referenced by parseComma(), parseMany(), parseOptionalToken(), parseRParen(), and llvm::MCAsmParserExtension::parseToken().
Definition at line 44 of file MCAsmParser.cpp.
References llvm::AsmToken::getLoc(), and getTok().
|
pure virtual |
Emit an error at the location L
, with the message Msg
.
Referenced by printPendingErrors().
|
inline |
Definition at line 237 of file MCAsmParser.h.
References PendingErrors, and printError().
|
pure virtual |
Run the parser on the input source buffer.
|
inlinevirtual |
Definition at line 174 of file MCAsmParser.h.
|
pure virtual |
|
inline |
Definition at line 177 of file MCAsmParser.h.
References ShowParsedOperands.
void MCAsmParser::setTargetParser | ( | MCTargetAsmParser & | P | ) |
Definition at line 34 of file MCAsmParser.cpp.
References assert(), llvm::MCAsmParserExtension::Initialize(), and P.
Report an error at the current lexer location.
Definition at line 97 of file MCAsmParser.cpp.
References getLexer(), and Range.
Referenced by llvm::MCParserUtils::parseAssignmentExpression(), parseIntToken(), and llvm::MCAsmParserExtension::TokError().
|
pure virtual |
Emit a warning at the location L
, with the message Msg
.
Referenced by llvm::MCAsmParserExtension::Warning().
|
protected |
Flag tracking whether any errors have been encountered.
Definition at line 144 of file MCAsmParser.h.
|
protected |
Definition at line 141 of file MCAsmParser.h.
Referenced by addErrorSuffix(), clearPendingErrors(), Error(), hasPendingError(), and printPendingErrors().
|
protected |
Definition at line 146 of file MCAsmParser.h.
Referenced by getShowParsedOperands(), and setShowParsedOperands().