LLVM 23.0.0git
llvm::MCTargetAsmParser Class Referenceabstract

MCTargetAsmParser - Generic interface to target specific assembly parsers. More...

#include "llvm/MC/MCParser/MCTargetAsmParser.h"

Inheritance diagram for llvm::MCTargetAsmParser:
[legend]

Public Types

enum  MatchResultTy {
  Match_InvalidOperand , Match_InvalidTiedOperand , Match_MissingFeature , Match_MnemonicFail ,
  Match_Success , Match_NearMisses , FIRST_TARGET_MATCH_RESULT_TY
}

Public Member Functions

 MCTargetAsmParser (const MCTargetAsmParser &)=delete
MCTargetAsmParseroperator= (const MCTargetAsmParser &)=delete
 ~MCTargetAsmParser () override
const MCSubtargetInfogetSTI () const
const FeatureBitsetgetAvailableFeatures () const
void setAvailableFeatures (const FeatureBitset &Value)
bool isParsingMSInlineAsm ()
void setParsingMSInlineAsm (bool Value)
const MCTargetOptionsgetTargetOptions () const
void setSemaCallback (MCAsmParserSemaCallback *Callback)
virtual bool parsePrimaryExpr (const MCExpr *&Res, SMLoc &EndLoc)
virtual bool parseDataExpr (const MCExpr *&Res)
virtual bool parseRegister (MCRegister &Reg, SMLoc &StartLoc, SMLoc &EndLoc)=0
virtual ParseStatus tryParseRegister (MCRegister &Reg, SMLoc &StartLoc, SMLoc &EndLoc)=0
 tryParseRegister - parse one register if possible
virtual bool parseInstruction (ParseInstructionInfo &Info, StringRef Name, SMLoc NameLoc, OperandVector &Operands)=0
 Parse one assembly instruction.
virtual bool parseInstruction (ParseInstructionInfo &Info, StringRef Name, AsmToken Token, OperandVector &Operands)
virtual bool ParseDirective (AsmToken DirectiveID)
 ParseDirective - Parse a target specific assembler directive This method is deprecated, use 'parseDirective' instead.
virtual ParseStatus parseDirective (AsmToken DirectiveID)
 Parses a target-specific assembler directive.
virtual bool matchAndEmitInstruction (SMLoc IDLoc, unsigned &Opcode, OperandVector &Operands, MCStreamer &Out, uint64_t &ErrorInfo, bool MatchingInlineAsm)=0
 Recognize a series of operands of a parsed instruction as an actual MCInst and emit it to the specified MCStreamer.
virtual bool omitRegisterFromClobberLists (MCRegister Reg)
 Allows targets to let registers opt out of clobber lists.
virtual unsigned validateTargetOperandClass (MCParsedAsmOperand &Op, unsigned Kind)
 Allow a target to add special case operand matching for things that tblgen doesn't/can't handle effectively.
virtual unsigned checkEarlyTargetMatchPredicate (MCInst &Inst, const OperandVector &Operands)
 Validate the instruction match against any complex target predicates before rendering any operands to it.
virtual unsigned checkTargetMatchPredicate (MCInst &Inst)
 checkTargetMatchPredicate - Validate the instruction match against any complex target predicates not expressible via match classes.
virtual void convertToMapAndConstraints (unsigned Kind, const OperandVector &Operands)=0
virtual bool areEqualRegs (const MCParsedAsmOperand &Op1, const MCParsedAsmOperand &Op2) const
 Returns whether two operands are registers and are equal.
virtual bool equalIsAsmAssignment ()
virtual bool isLabel (AsmToken &Token)
virtual bool tokenIsStartOfStatement (AsmToken::TokenKind Token)
virtual const MCExprapplySpecifier (const MCExpr *E, uint32_t, MCContext &Ctx)
virtual void doBeforeLabelEmit (MCSymbol *Symbol, SMLoc IDLoc)
virtual void onLabelParsed (MCSymbol *Symbol)
virtual void flushPendingInstructions (MCStreamer &Out)
 Ensure that all previously parsed instructions have been emitted to the output streamer, if the target does not emit them immediately.
virtual void onBeginOfFile ()
virtual void onEndOfFile ()
Public Member Functions inherited from llvm::MCAsmParserExtension
 MCAsmParserExtension (const MCAsmParserExtension &)=delete
MCAsmParserExtensionoperator= (const MCAsmParserExtension &)=delete
virtual ~MCAsmParserExtension ()
virtual void Initialize (MCAsmParser &Parser)
 Initialize the extension for parsing using the given Parser.
MCContextgetContext ()
AsmLexergetLexer ()
const AsmLexergetLexer () const
MCAsmParsergetParser ()
const MCAsmParsergetParser () const
SourceMgrgetSourceManager ()
MCStreamergetStreamer ()
bool Warning (SMLoc L, const Twine &Msg)
bool Error (SMLoc L, const Twine &Msg, SMRange Range=SMRange())
void Note (SMLoc L, const Twine &Msg)
bool TokError (const Twine &Msg)
const AsmTokenLex ()
const AsmTokengetTok ()
bool parseToken (AsmToken::TokenKind T, const Twine &Msg="unexpected token")
bool parseEOL ()
bool parseMany (function_ref< bool()> parseOne, bool hasComma=true)
bool parseOptionalToken (AsmToken::TokenKind T)
bool parseDirectiveCGProfile (StringRef, SMLoc)
 parseDirectiveCGProfile ::= .cg_profile identifier, identifier, <number>
bool maybeParseUniqueID (int64_t &UniqueID)
bool check (bool P, const Twine &Msg)
bool check (bool P, SMLoc Loc, const Twine &Msg)
bool addErrorSuffix (const Twine &Suffix)
bool HasBracketExpressions () const

Protected Member Functions

 MCTargetAsmParser (const MCSubtargetInfo &STI, const MCInstrInfo &MII)
MCSubtargetInfocopySTI ()
 Create a copy of STI and return a non-const reference to it.
Protected Member Functions inherited from llvm::MCAsmParserExtension
 MCAsmParserExtension ()

Protected Attributes

FeatureBitset AvailableFeatures
 AvailableFeatures - The current set of available features.
bool ParsingMSInlineAsm = false
 ParsingMSInlineAsm - Are we parsing ms-style inline assembly?
MCAsmParserSemaCallbackSemaCallback = nullptr
 SemaCallback - The Sema callback implementation.
const MCSubtargetInfoSTI
 Current STI.
const MCInstrInfoMII
Protected Attributes inherited from llvm::MCAsmParserExtension
bool BracketExpressionsSupported = false

Additional Inherited Members

Static Protected Member Functions inherited from llvm::MCAsmParserExtension
template<typename T, bool(T::*)(StringRef, SMLoc) Handler>
static bool HandleDirective (MCAsmParserExtension *Target, StringRef Directive, SMLoc DirectiveLoc)

Detailed Description

MCTargetAsmParser - Generic interface to target specific assembly parsers.

Definition at line 335 of file MCTargetAsmParser.h.

Member Enumeration Documentation

◆ MatchResultTy

Enumerator
Match_InvalidOperand 
Match_InvalidTiedOperand 
Match_MissingFeature 
Match_MnemonicFail 
Match_Success 
Match_NearMisses 
FIRST_TARGET_MATCH_RESULT_TY 

Definition at line 337 of file MCTargetAsmParser.h.

Constructor & Destructor Documentation

◆ MCTargetAsmParser() [1/2]

MCTargetAsmParser::MCTargetAsmParser ( const MCSubtargetInfo & STI,
const MCInstrInfo & MII )
protected

Definition at line 16 of file MCTargetAsmParser.cpp.

References MII, and STI.

Referenced by getTargetOptions(), MCTargetAsmParser(), operator=(), and XtensaAsmParser::XtensaAsmParser().

◆ MCTargetAsmParser() [2/2]

llvm::MCTargetAsmParser::MCTargetAsmParser ( const MCTargetAsmParser & )
delete

References MCTargetAsmParser().

◆ ~MCTargetAsmParser()

MCTargetAsmParser::~MCTargetAsmParser ( )
overridedefault

References getSTI().

Member Function Documentation

◆ applySpecifier()

virtual const MCExpr * llvm::MCTargetAsmParser::applySpecifier ( const MCExpr * E,
uint32_t ,
MCContext & Ctx )
inlinevirtual

Definition at line 518 of file MCTargetAsmParser.h.

References E().

◆ areEqualRegs()

bool MCTargetAsmParser::areEqualRegs ( const MCParsedAsmOperand & Op1,
const MCParsedAsmOperand & Op2 ) const
virtual

Returns whether two operands are registers and are equal.

This is used by the tied-operands checks in the AsmMatcher. This method can be overridden to allow e.g. a sub- or super-register as the tied operand.

Definition at line 58 of file MCTargetAsmParser.cpp.

References llvm::MCParsedAsmOperand::getReg(), and llvm::MCParsedAsmOperand::isReg().

Referenced by convertToMapAndConstraints().

◆ checkEarlyTargetMatchPredicate()

virtual unsigned llvm::MCTargetAsmParser::checkEarlyTargetMatchPredicate ( MCInst & Inst,
const OperandVector & Operands )
inlinevirtual

Validate the instruction match against any complex target predicates before rendering any operands to it.

Definition at line 490 of file MCTargetAsmParser.h.

References Match_Success.

◆ checkTargetMatchPredicate()

virtual unsigned llvm::MCTargetAsmParser::checkTargetMatchPredicate ( MCInst & Inst)
inlinevirtual

checkTargetMatchPredicate - Validate the instruction match against any complex target predicates not expressible via match classes.

Definition at line 496 of file MCTargetAsmParser.h.

References Match_Success.

◆ convertToMapAndConstraints()

virtual void llvm::MCTargetAsmParser::convertToMapAndConstraints ( unsigned Kind,
const OperandVector & Operands )
pure virtual

References areEqualRegs().

◆ copySTI()

MCSubtargetInfo & MCTargetAsmParser::copySTI ( )
protected

Create a copy of STI and return a non-const reference to it.

Definition at line 22 of file MCTargetAsmParser.cpp.

References llvm::MCAsmParserExtension::getContext(), getSTI(), llvm::MCAsmParserExtension::getStreamer(), llvm::MCContext::getSubtargetCopy(), and STI.

◆ doBeforeLabelEmit()

virtual void llvm::MCTargetAsmParser::doBeforeLabelEmit ( MCSymbol * Symbol,
SMLoc IDLoc )
inlinevirtual

Definition at line 524 of file MCTargetAsmParser.h.

◆ equalIsAsmAssignment()

virtual bool llvm::MCTargetAsmParser::equalIsAsmAssignment ( )
inlinevirtual

Definition at line 510 of file MCTargetAsmParser.h.

◆ flushPendingInstructions()

virtual void llvm::MCTargetAsmParser::flushPendingInstructions ( MCStreamer & Out)
inlinevirtual

Ensure that all previously parsed instructions have been emitted to the output streamer, if the target does not emit them immediately.

Definition at line 530 of file MCTargetAsmParser.h.

◆ getAvailableFeatures()

const FeatureBitset & llvm::MCTargetAsmParser::getAvailableFeatures ( ) const
inline

Definition at line 376 of file MCTargetAsmParser.h.

References AvailableFeatures.

◆ getSTI()

const MCSubtargetInfo & MCTargetAsmParser::getSTI ( ) const

Definition at line 33 of file MCTargetAsmParser.cpp.

References STI.

Referenced by copySTI(), XtensaAsmParser::hasWindowed(), and ~MCTargetAsmParser().

◆ getTargetOptions()

const MCTargetOptions & llvm::MCTargetAsmParser::getTargetOptions ( ) const
inline

◆ isLabel()

virtual bool llvm::MCTargetAsmParser::isLabel ( AsmToken & Token)
inlinevirtual

Definition at line 512 of file MCTargetAsmParser.h.

◆ isParsingMSInlineAsm()

bool llvm::MCTargetAsmParser::isParsingMSInlineAsm ( )
inline

Definition at line 383 of file MCTargetAsmParser.h.

References ParsingMSInlineAsm.

◆ matchAndEmitInstruction()

virtual bool llvm::MCTargetAsmParser::matchAndEmitInstruction ( SMLoc IDLoc,
unsigned & Opcode,
OperandVector & Operands,
MCStreamer & Out,
uint64_t & ErrorInfo,
bool MatchingInlineAsm )
pure virtual

Recognize a series of operands of a parsed instruction as an actual MCInst and emit it to the specified MCStreamer.

This returns false on success and returns true on failure to match.

On failure, the target parser is responsible for emitting a diagnostic explaining the match failure.

◆ omitRegisterFromClobberLists()

virtual bool llvm::MCTargetAsmParser::omitRegisterFromClobberLists ( MCRegister Reg)
inlinevirtual

Allows targets to let registers opt out of clobber lists.

Definition at line 476 of file MCTargetAsmParser.h.

References Reg.

◆ onBeginOfFile()

virtual void llvm::MCTargetAsmParser::onBeginOfFile ( )
inlinevirtual

Definition at line 533 of file MCTargetAsmParser.h.

◆ onEndOfFile()

virtual void llvm::MCTargetAsmParser::onEndOfFile ( )
inlinevirtual

Definition at line 536 of file MCTargetAsmParser.h.

◆ onLabelParsed()

virtual void llvm::MCTargetAsmParser::onLabelParsed ( MCSymbol * Symbol)
inlinevirtual

Definition at line 526 of file MCTargetAsmParser.h.

◆ operator=()

MCTargetAsmParser & llvm::MCTargetAsmParser::operator= ( const MCTargetAsmParser & )
delete

References MCTargetAsmParser().

◆ parseDataExpr()

virtual bool llvm::MCTargetAsmParser::parseDataExpr ( const MCExpr *& Res)
inlinevirtual

Definition at line 403 of file MCTargetAsmParser.h.

References llvm::MCAsmParserExtension::getParser().

◆ ParseDirective()

virtual bool llvm::MCTargetAsmParser::ParseDirective ( AsmToken DirectiveID)
inlinevirtual

ParseDirective - Parse a target specific assembler directive This method is deprecated, use 'parseDirective' instead.

The parser is positioned following the directive name. The target specific directive parser should parse the entire directive doing or recording any target specific work, or return true and do nothing if the directive is not target specific. If the directive is specific for the target, the entire line is parsed up to and including the end-of-statement token and false is returned.

Parameters
DirectiveID- the identifier token of the directive.

Definition at line 450 of file MCTargetAsmParser.h.

Referenced by parseDirective().

◆ parseDirective()

ParseStatus MCTargetAsmParser::parseDirective ( AsmToken DirectiveID)
virtual

Parses a target-specific assembler directive.

The parser is positioned following the directive name. The target-specific directive parser should parse the entire directive doing or recording any target-specific work, or emit an error. On success, the entire line should be parsed up to and including the end-of-statement token. On failure, the parser is not required to read to the end of the line. If the directive is not target-specific, no tokens should be consumed and NoMatch is returned.

Parameters
DirectiveID- The token identifying the directive.

Definition at line 37 of file MCTargetAsmParser.cpp.

References llvm::ParseStatus::Failure, llvm::AsmToken::getLoc(), llvm::MCAsmParserExtension::getParser(), llvm::MCAsmParserExtension::getTok(), llvm::ParseStatus::NoMatch, ParseDirective(), and llvm::ParseStatus::Success.

◆ parseInstruction() [1/2]

virtual bool llvm::MCTargetAsmParser::parseInstruction ( ParseInstructionInfo & Info,
StringRef Name,
AsmToken Token,
OperandVector & Operands )
inlinevirtual

Definition at line 434 of file MCTargetAsmParser.h.

References llvm::AsmToken::getLoc(), and parseInstruction().

◆ parseInstruction() [2/2]

virtual bool llvm::MCTargetAsmParser::parseInstruction ( ParseInstructionInfo & Info,
StringRef Name,
SMLoc NameLoc,
OperandVector & Operands )
pure virtual

Parse one assembly instruction.

The parser is positioned following the instruction name. The target specific instruction parser should parse the entire instruction and construct the appropriate MCInst, or emit an error. On success, the entire line should be parsed up to and including the end-of-statement token. On failure, the parser is not required to read to the end of the line.

Parameters
Name- The instruction name.
NameLoc- The source location of the name.
Operands[out] - The list of parsed operands, this returns ownership of them to the caller.
Returns
True on failure.

Referenced by parseInstruction().

◆ parsePrimaryExpr()

virtual bool llvm::MCTargetAsmParser::parsePrimaryExpr ( const MCExpr *& Res,
SMLoc & EndLoc )
inlinevirtual

Definition at line 398 of file MCTargetAsmParser.h.

References llvm::MCAsmParserExtension::getParser().

◆ parseRegister()

virtual bool llvm::MCTargetAsmParser::parseRegister ( MCRegister & Reg,
SMLoc & StartLoc,
SMLoc & EndLoc )
pure virtual

References Reg.

◆ setAvailableFeatures()

void llvm::MCTargetAsmParser::setAvailableFeatures ( const FeatureBitset & Value)
inline

Definition at line 379 of file MCTargetAsmParser.h.

References AvailableFeatures.

Referenced by XtensaAsmParser::XtensaAsmParser().

◆ setParsingMSInlineAsm()

void llvm::MCTargetAsmParser::setParsingMSInlineAsm ( bool Value)
inline

Definition at line 384 of file MCTargetAsmParser.h.

References ParsingMSInlineAsm.

◆ setSemaCallback()

void llvm::MCTargetAsmParser::setSemaCallback ( MCAsmParserSemaCallback * Callback)
inline

Definition at line 393 of file MCTargetAsmParser.h.

References SemaCallback.

◆ tokenIsStartOfStatement()

virtual bool llvm::MCTargetAsmParser::tokenIsStartOfStatement ( AsmToken::TokenKind Token)
inlinevirtual

Definition at line 514 of file MCTargetAsmParser.h.

◆ tryParseRegister()

virtual ParseStatus llvm::MCTargetAsmParser::tryParseRegister ( MCRegister & Reg,
SMLoc & StartLoc,
SMLoc & EndLoc )
pure virtual

tryParseRegister - parse one register if possible

Check whether a register specification can be parsed at the current location, without failing the entire parse if it can't. Must not consume tokens if the parse fails.

References Reg.

◆ validateTargetOperandClass()

virtual unsigned llvm::MCTargetAsmParser::validateTargetOperandClass ( MCParsedAsmOperand & Op,
unsigned Kind )
inlinevirtual

Allow a target to add special case operand matching for things that tblgen doesn't/can't handle effectively.

For example, literal immediates on ARM. TableGen expects a token operand, but the parser will recognize them as immediates.

Definition at line 482 of file MCTargetAsmParser.h.

References Match_InvalidOperand.

Member Data Documentation

◆ AvailableFeatures

FeatureBitset llvm::MCTargetAsmParser::AvailableFeatures
protected

AvailableFeatures - The current set of available features.

Definition at line 354 of file MCTargetAsmParser.h.

Referenced by getAvailableFeatures(), and setAvailableFeatures().

◆ MII

const MCInstrInfo& llvm::MCTargetAsmParser::MII
protected

Definition at line 366 of file MCTargetAsmParser.h.

Referenced by MCTargetAsmParser(), and XtensaAsmParser::XtensaAsmParser().

◆ ParsingMSInlineAsm

bool llvm::MCTargetAsmParser::ParsingMSInlineAsm = false
protected

ParsingMSInlineAsm - Are we parsing ms-style inline assembly?

Definition at line 357 of file MCTargetAsmParser.h.

Referenced by isParsingMSInlineAsm(), and setParsingMSInlineAsm().

◆ SemaCallback

MCAsmParserSemaCallback* llvm::MCTargetAsmParser::SemaCallback = nullptr
protected

SemaCallback - The Sema callback implementation.

Must be set when parsing ms-style inline assembly.

Definition at line 361 of file MCTargetAsmParser.h.

Referenced by setSemaCallback().

◆ STI

const MCSubtargetInfo* llvm::MCTargetAsmParser::STI
protected

Current STI.

Definition at line 364 of file MCTargetAsmParser.h.

Referenced by copySTI(), getSTI(), MCTargetAsmParser(), and XtensaAsmParser::XtensaAsmParser().


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