LLVM 22.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 |
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 |
MCContext & | getContext () |
MCStreamer & | getStreamer () |
SourceMgr & | getSourceManager () |
AsmLexer & | getLexer () |
const AsmLexer & | getLexer () const |
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="expected integer") |
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. | |
bool | parseSymbol (MCSymbol *&Res) |
Parse identifier and get or create symbol for it. | |
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=nullptr)=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. | |
bool | parseGNUAttribute (SMLoc L, int64_t &Tag, int64_t &IntegerValue) |
Parse a .gnu_attribute. | |
bool | parseAtSpecifier (const MCExpr *&Res, SMLoc &EndLoc) |
const MCExpr * | applySpecifier (const MCExpr *E, uint32_t Variant) |
Protected Member Functions | |
MCAsmParser (MCContext &, MCStreamer &, SourceMgr &, const MCAsmInfo &) |
Protected Attributes | |
MCContext & | Ctx |
MCStreamer & | Out |
SourceMgr & | SrcMgr |
const MCAsmInfo & | MAI |
AsmLexer | Lexer |
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 124 of file MCAsmParser.h.
using llvm::MCAsmParser::DirectiveHandler = bool (*)(MCAsmParserExtension*, StringRef, SMLoc) |
Definition at line 126 of file MCAsmParser.h.
Definition at line 127 of file MCAsmParser.h.
|
protected |
Definition at line 31 of file MCAsmParser.cpp.
References Ctx, Lexer, MAI, Out, and SrcMgr.
Referenced by MCAsmParser(), and operator=().
|
delete |
References MCAsmParser().
|
virtualdefault |
|
pure virtual |
|
pure virtual |
Definition at line 119 of file MCAsmParser.cpp.
References llvm::AsmToken::Error, getTok(), Lex(), PendingErrors, and llvm::Twine::toVector().
Definition at line 1327 of file AsmParser.cpp.
References applySpecifier(), llvm::MCExpr::Binary, llvm::cast(), llvm::MCExpr::Constant, llvm::MCBinaryExpr::create(), llvm::MCSymbolRefExpr::create(), llvm::MCUnaryExpr::create(), Ctx, getContext(), llvm::MCBinaryExpr::getLHS(), llvm::MCExpr::getLoc(), llvm::MCBinaryExpr::getOpcode(), llvm::MCUnaryExpr::getOpcode(), llvm::MCBinaryExpr::getRHS(), llvm::MCSymbolRefExpr::getSpecifier(), llvm::MCUnaryExpr::getSubExpr(), llvm::MCSymbolRefExpr::getSymbol(), getTargetParser(), getTok(), llvm_unreachable, llvm::MCExpr::Specifier, llvm::Sub, llvm::MCExpr::SymbolRef, llvm::MCExpr::Target, TokError(), and llvm::MCExpr::Unary.
Referenced by applySpecifier(), checkForValidSection(), and parseAtSpecifier().
Definition at line 94 of file MCAsmParser.cpp.
References llvm::Error, and P.
|
pure virtual |
Ensure that we have a valid section set in the streamer.
Otherwise, report an error and switch to .text.
References applySpecifier(), E(), parseAtSpecifier(), parseGNUAttribute(), and llvm::Tag.
|
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 104 of file MCAsmParser.cpp.
References llvm::AsmToken::Error, getLexer(), getTok(), llvm::AsmLexer::Lex(), llvm::MCAsmParser::MCPendingError::Loc, llvm::MCAsmParser::MCPendingError::Msg, PendingErrors, llvm::MCAsmParser::MCPendingError::Range, Range, and llvm::Twine::toVector().
Referenced by llvm::MCParserUtils::parseAssignmentExpression(), and Warning().
|
inlinevirtual |
Definition at line 173 of file MCAsmParser.h.
|
inline |
Definition at line 164 of file MCAsmParser.h.
References Ctx.
Referenced by applySpecifier(), llvm::MCParserUtils::parseAssignmentExpression(), and parseSymbol().
|
inline |
Definition at line 167 of file MCAsmParser.h.
References Lexer.
Referenced by Error(), expectAbsExpression(), getTok(), parseAtSpecifier(), parseExpr(), and TokError().
Definition at line 168 of file MCAsmParser.h.
References Lexer.
|
inline |
Definition at line 176 of file MCAsmParser.h.
References ShowParsedOperands.
|
inline |
Definition at line 166 of file MCAsmParser.h.
References SrcMgr.
|
inline |
Definition at line 165 of file MCAsmParser.h.
References Out.
Referenced by llvm::MCParserUtils::parseAssignmentExpression().
|
inline |
Definition at line 170 of file MCAsmParser.h.
Referenced by applySpecifier().
Get the current AsmToken from the stream.
Definition at line 43 of file MCAsmParser.cpp.
References getLexer(), and llvm::AsmLexer::getTok().
Referenced by addErrorSuffix(), applySpecifier(), check(), Error(), Lex(), llvm::MCParserUtils::parseAssignmentExpression(), parseAtSpecifier(), parseEOL(), 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.
References getTok(), parseOptionalToken(), parseToken(), parseTokenLoc(), Range, T, and TokError().
Referenced by addErrorSuffix(), parseAtSpecifier(), parseEOL(), parseEOL(), parseGNUAttribute(), parseIntToken(), and parseToken().
|
inlinevirtual |
Definition at line 194 of file MCAsmParser.h.
References llvm::sampleprof::Base, and Info.
|
inlinevirtual |
Definition at line 191 of file MCAsmParser.h.
References Info.
|
inlinevirtual |
Definition at line 199 of file MCAsmParser.h.
References Info.
|
pure virtual |
Emit a note at the location L
, with the message Msg
.
References Range.
|
delete |
References MCAsmParser().
|
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.
References llvm::Data.
Definition at line 1423 of file AsmParser.cpp.
References applySpecifier(), llvm::AsmToken::At, getLexer(), getTok(), llvm::AsmToken::Identifier, isNot(), Lex(), MAI, parseOptionalToken(), and TokError().
Referenced by checkForValidSection().
|
inline |
Definition at line 266 of file MCAsmParser.h.
References llvm::AsmToken::Comma, and parseToken().
bool MCAsmParser::parseEOL | ( | ) |
Definition at line 52 of file MCAsmParser.cpp.
References llvm::AsmToken::EndOfStatement, llvm::Error, getTok(), and Lex().
Referenced by llvm::MCParserUtils::parseAssignmentExpression(), and parseToken().
Definition at line 59 of file MCAsmParser.cpp.
References llvm::AsmToken::EndOfStatement, llvm::Error, getTok(), and Lex().
|
pure virtual |
Parse the current token as a string which may include escaped characters and return the string contents.
References llvm::Data.
Definition at line 142 of file MCAsmParser.cpp.
References parseExpression().
|
pure virtual |
Parse an arbitrary expression.
Res | - The value of the expression. The result is undefined on error. |
References parseExpression().
Referenced by llvm::MCParserUtils::parseAssignmentExpression(), parseExpr(), parseExpression(), and parseExpression().
Parse a .gnu_attribute.
Definition at line 147 of file MCAsmParser.cpp.
References llvm::AsmToken::getIntVal(), llvm::AsmToken::getLoc(), getTok(), llvm::AsmToken::Integer, llvm::AsmToken::isNot(), Lex(), and llvm::Tag.
Referenced by checkForValidSection().
Parse an identifier or string (as a quoted identifier) and set Res
to the identifier contents.
References parseSymbol().
Referenced by parseSymbol().
Definition at line 75 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 128 of file MCAsmParser.cpp.
References llvm::AsmToken::Comma, llvm::AsmToken::EndOfStatement, parseOptionalToken(), and parseToken().
|
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 83 of file MCAsmParser.cpp.
References llvm::AsmToken::getKind(), getTok(), parseToken(), and T.
Referenced by Lex(), parseAtSpecifier(), and parseMany().
|
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 a primary expression.
Res | - The value of the expression. The result is undefined on error. |
|
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.
Parse identifier and get or create symbol for it.
Definition at line 166 of file MCAsmParser.cpp.
References getContext(), parseIdentifier(), and llvm::MCContext::parseSymbol().
Referenced by parseIdentifier().
bool MCAsmParser::parseToken | ( | AsmToken::TokenKind | T, |
const Twine & | Msg = "unexpected token" ) |
Definition at line 66 of file MCAsmParser.cpp.
References llvm::AsmToken::EndOfStatement, llvm::Error, getTok(), Lex(), parseEOL(), and T.
Referenced by Lex(), parseComma(), parseMany(), parseOptionalToken(), and parseRParen().
Definition at line 47 of file MCAsmParser.cpp.
References llvm::AsmToken::getLoc(), and getTok().
Referenced by Lex().
|
pure virtual |
Emit an error at the location L
, with the message Msg
.
References Range.
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 37 of file MCAsmParser.cpp.
Report an error at the current lexer location.
Definition at line 100 of file MCAsmParser.cpp.
References llvm::Error, getLexer(), and Range.
Referenced by applySpecifier(), Lex(), llvm::MCParserUtils::parseAssignmentExpression(), parseAtSpecifier(), and parseIntToken().
|
protected |
Definition at line 142 of file MCAsmParser.h.
Referenced by applySpecifier(), getContext(), and MCAsmParser().
|
protected |
Flag tracking whether any errors have been encountered.
Definition at line 150 of file MCAsmParser.h.
|
protected |
Definition at line 146 of file MCAsmParser.h.
Referenced by getLexer(), getLexer(), and MCAsmParser().
Definition at line 145 of file MCAsmParser.h.
Referenced by MCAsmParser(), and parseAtSpecifier().
|
protected |
Definition at line 143 of file MCAsmParser.h.
Referenced by getStreamer(), and MCAsmParser().
|
protected |
Definition at line 147 of file MCAsmParser.h.
Referenced by addErrorSuffix(), clearPendingErrors(), Error(), hasPendingError(), and printPendingErrors().
|
protected |
Definition at line 152 of file MCAsmParser.h.
Referenced by getShowParsedOperands(), and setShowParsedOperands().
|
protected |
Definition at line 144 of file MCAsmParser.h.
Referenced by getSourceManager(), and MCAsmParser().