mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-02-09 13:33:17 +00:00
Now that GenericAsmParser was folded into AsmParser, some methods and types can
return into the safe harbor of AsmParser's private areas. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@172637 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
1e08165ae9
commit
f9f40bd158
@ -44,25 +44,6 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/// \brief Helper types for tracking macro definitions.
|
|
||||||
typedef std::vector<AsmToken> MCAsmMacroArgument;
|
|
||||||
typedef std::vector<MCAsmMacroArgument> MCAsmMacroArguments;
|
|
||||||
typedef std::pair<StringRef, MCAsmMacroArgument> MCAsmMacroParameter;
|
|
||||||
typedef std::vector<MCAsmMacroParameter> MCAsmMacroParameters;
|
|
||||||
|
|
||||||
struct MCAsmMacro {
|
|
||||||
StringRef Name;
|
|
||||||
StringRef Body;
|
|
||||||
MCAsmMacroParameters Parameters;
|
|
||||||
|
|
||||||
public:
|
|
||||||
MCAsmMacro(StringRef N, StringRef B, const MCAsmMacroParameters &P) :
|
|
||||||
Name(N), Body(B), Parameters(P) {}
|
|
||||||
|
|
||||||
MCAsmMacro(const MCAsmMacro& Other)
|
|
||||||
: Name(Other.Name), Body(Other.Body), Parameters(Other.Parameters) {}
|
|
||||||
};
|
|
||||||
|
|
||||||
/// MCAsmParser - Generic assembler parser interface, for use by target specific
|
/// MCAsmParser - Generic assembler parser interface, for use by target specific
|
||||||
/// assembly parsers.
|
/// assembly parsers.
|
||||||
class MCAsmParser {
|
class MCAsmParser {
|
||||||
@ -159,41 +140,6 @@ public:
|
|||||||
/// recovery.
|
/// recovery.
|
||||||
virtual void EatToEndOfStatement() = 0;
|
virtual void EatToEndOfStatement() = 0;
|
||||||
|
|
||||||
/// \brief Are macros enabled in the parser?
|
|
||||||
virtual bool MacrosEnabled() = 0;
|
|
||||||
|
|
||||||
/// \brief Control a flag in the parser that enables or disables macros.
|
|
||||||
virtual void SetMacrosEnabled(bool flag) = 0;
|
|
||||||
|
|
||||||
/// \brief Lookup a previously defined macro.
|
|
||||||
/// \param Name Macro name.
|
|
||||||
/// \returns Pointer to macro. NULL if no such macro was defined.
|
|
||||||
virtual const MCAsmMacro* LookupMacro(StringRef Name) = 0;
|
|
||||||
|
|
||||||
/// \brief Define a new macro with the given name and information.
|
|
||||||
virtual void DefineMacro(StringRef Name, const MCAsmMacro& Macro) = 0;
|
|
||||||
|
|
||||||
/// \brief Undefine a macro. If no such macro was defined, it's a no-op.
|
|
||||||
virtual void UndefineMacro(StringRef Name) = 0;
|
|
||||||
|
|
||||||
/// \brief Are we inside a macro instantiation?
|
|
||||||
virtual bool InsideMacroInstantiation() = 0;
|
|
||||||
|
|
||||||
/// \brief Handle entry to macro instantiation.
|
|
||||||
///
|
|
||||||
/// \param M The macro.
|
|
||||||
/// \param NameLoc Instantiation location.
|
|
||||||
virtual bool HandleMacroEntry(const MCAsmMacro *M, SMLoc NameLoc) = 0;
|
|
||||||
|
|
||||||
/// \brief Handle exit from macro instantiation.
|
|
||||||
virtual void HandleMacroExit() = 0;
|
|
||||||
|
|
||||||
/// ParseMacroArgument - Extract AsmTokens for a macro argument. If the
|
|
||||||
/// argument delimiter is initially unknown, set it to AsmToken::Eof. It will
|
|
||||||
/// be set to the correct delimiter by the method.
|
|
||||||
virtual bool ParseMacroArgument(MCAsmMacroArgument &MA,
|
|
||||||
AsmToken::TokenKind &ArgumentDelimiter) = 0;
|
|
||||||
|
|
||||||
/// ParseExpression - Parse an arbitrary expression.
|
/// ParseExpression - Parse an arbitrary expression.
|
||||||
///
|
///
|
||||||
/// @param Res - The value of the expression. The result is undefined
|
/// @param Res - The value of the expression. The result is undefined
|
||||||
|
@ -50,6 +50,25 @@ MCAsmParserSemaCallback::~MCAsmParserSemaCallback() {}
|
|||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
|
/// \brief Helper types for tracking macro definitions.
|
||||||
|
typedef std::vector<AsmToken> MCAsmMacroArgument;
|
||||||
|
typedef std::vector<MCAsmMacroArgument> MCAsmMacroArguments;
|
||||||
|
typedef std::pair<StringRef, MCAsmMacroArgument> MCAsmMacroParameter;
|
||||||
|
typedef std::vector<MCAsmMacroParameter> MCAsmMacroParameters;
|
||||||
|
|
||||||
|
struct MCAsmMacro {
|
||||||
|
StringRef Name;
|
||||||
|
StringRef Body;
|
||||||
|
MCAsmMacroParameters Parameters;
|
||||||
|
|
||||||
|
public:
|
||||||
|
MCAsmMacro(StringRef N, StringRef B, const MCAsmMacroParameters &P) :
|
||||||
|
Name(N), Body(B), Parameters(P) {}
|
||||||
|
|
||||||
|
MCAsmMacro(const MCAsmMacro& Other)
|
||||||
|
: Name(Other.Name), Body(Other.Body), Parameters(Other.Parameters) {}
|
||||||
|
};
|
||||||
|
|
||||||
/// \brief Helper class for storing information about an active macro
|
/// \brief Helper class for storing information about an active macro
|
||||||
/// instantiation.
|
/// instantiation.
|
||||||
struct MacroInstantiation {
|
struct MacroInstantiation {
|
||||||
@ -73,7 +92,6 @@ public:
|
|||||||
MemoryBuffer *I);
|
MemoryBuffer *I);
|
||||||
};
|
};
|
||||||
|
|
||||||
//struct AsmRewrite;
|
|
||||||
struct ParseStatementInfo {
|
struct ParseStatementInfo {
|
||||||
/// ParsedOperands - The parsed operands from the last parsed statement.
|
/// ParsedOperands - The parsed operands from the last parsed statement.
|
||||||
SmallVector<MCParsedAsmOperand*, 8> ParsedOperands;
|
SmallVector<MCParsedAsmOperand*, 8> ParsedOperands;
|
||||||
@ -205,25 +223,11 @@ public:
|
|||||||
virtual bool ParseParenExpression(const MCExpr *&Res, SMLoc &EndLoc);
|
virtual bool ParseParenExpression(const MCExpr *&Res, SMLoc &EndLoc);
|
||||||
virtual bool ParseAbsoluteExpression(int64_t &Res);
|
virtual bool ParseAbsoluteExpression(int64_t &Res);
|
||||||
|
|
||||||
bool ParseMacroArgument(MCAsmMacroArgument &MA,
|
|
||||||
AsmToken::TokenKind &ArgumentDelimiter);
|
|
||||||
|
|
||||||
/// ParseIdentifier - Parse an identifier or string (as a quoted identifier)
|
/// ParseIdentifier - Parse an identifier or string (as a quoted identifier)
|
||||||
/// and set \p Res to the identifier contents.
|
/// and set \p Res to the identifier contents.
|
||||||
virtual bool ParseIdentifier(StringRef &Res);
|
virtual bool ParseIdentifier(StringRef &Res);
|
||||||
virtual void EatToEndOfStatement();
|
virtual void EatToEndOfStatement();
|
||||||
|
|
||||||
virtual bool MacrosEnabled() {return MacrosEnabledFlag;}
|
|
||||||
virtual void SetMacrosEnabled(bool flag) {MacrosEnabledFlag = flag;}
|
|
||||||
|
|
||||||
virtual const MCAsmMacro* LookupMacro(StringRef Name);
|
|
||||||
virtual void DefineMacro(StringRef Name, const MCAsmMacro& Macro);
|
|
||||||
virtual void UndefineMacro(StringRef Name);
|
|
||||||
|
|
||||||
virtual bool InsideMacroInstantiation() {return !ActiveMacros.empty();}
|
|
||||||
virtual bool HandleMacroEntry(const MCAsmMacro *M, SMLoc NameLoc);
|
|
||||||
void HandleMacroExit();
|
|
||||||
|
|
||||||
virtual void CheckForValidSection();
|
virtual void CheckForValidSection();
|
||||||
/// }
|
/// }
|
||||||
|
|
||||||
@ -238,6 +242,44 @@ private:
|
|||||||
const MCAsmMacroArguments &A,
|
const MCAsmMacroArguments &A,
|
||||||
const SMLoc &L);
|
const SMLoc &L);
|
||||||
|
|
||||||
|
/// \brief Are macros enabled in the parser?
|
||||||
|
bool MacrosEnabled() {return MacrosEnabledFlag;}
|
||||||
|
|
||||||
|
/// \brief Control a flag in the parser that enables or disables macros.
|
||||||
|
void SetMacrosEnabled(bool Flag) {MacrosEnabledFlag = Flag;}
|
||||||
|
|
||||||
|
/// \brief Lookup a previously defined macro.
|
||||||
|
/// \param Name Macro name.
|
||||||
|
/// \returns Pointer to macro. NULL if no such macro was defined.
|
||||||
|
const MCAsmMacro* LookupMacro(StringRef Name);
|
||||||
|
|
||||||
|
/// \brief Define a new macro with the given name and information.
|
||||||
|
void DefineMacro(StringRef Name, const MCAsmMacro& Macro);
|
||||||
|
|
||||||
|
/// \brief Undefine a macro. If no such macro was defined, it's a no-op.
|
||||||
|
void UndefineMacro(StringRef Name);
|
||||||
|
|
||||||
|
/// \brief Are we inside a macro instantiation?
|
||||||
|
bool InsideMacroInstantiation() {return !ActiveMacros.empty();}
|
||||||
|
|
||||||
|
/// \brief Handle entry to macro instantiation.
|
||||||
|
///
|
||||||
|
/// \param M The macro.
|
||||||
|
/// \param NameLoc Instantiation location.
|
||||||
|
bool HandleMacroEntry(const MCAsmMacro *M, SMLoc NameLoc);
|
||||||
|
|
||||||
|
/// \brief Handle exit from macro instantiation.
|
||||||
|
void HandleMacroExit();
|
||||||
|
|
||||||
|
/// \brief Extract AsmTokens for a macro argument. If the argument delimiter
|
||||||
|
/// is initially unknown, set it to AsmToken::Eof. It will be set to the
|
||||||
|
/// correct delimiter by the method.
|
||||||
|
bool ParseMacroArgument(MCAsmMacroArgument &MA,
|
||||||
|
AsmToken::TokenKind &ArgumentDelimiter);
|
||||||
|
|
||||||
|
/// \brief Parse all macro arguments for a given macro.
|
||||||
|
bool ParseMacroArguments(const MCAsmMacro *M, MCAsmMacroArguments &A);
|
||||||
|
|
||||||
void PrintMacroInstantiations();
|
void PrintMacroInstantiations();
|
||||||
void PrintMessage(SMLoc Loc, SourceMgr::DiagKind Kind, const Twine &Msg,
|
void PrintMessage(SMLoc Loc, SourceMgr::DiagKind Kind, const Twine &Msg,
|
||||||
ArrayRef<SMRange> Ranges = ArrayRef<SMRange>()) const {
|
ArrayRef<SMRange> Ranges = ArrayRef<SMRange>()) const {
|
||||||
@ -259,8 +301,6 @@ private:
|
|||||||
/// location.
|
/// location.
|
||||||
void JumpToLoc(SMLoc Loc, int InBuffer=-1);
|
void JumpToLoc(SMLoc Loc, int InBuffer=-1);
|
||||||
|
|
||||||
bool ParseMacroArguments(const MCAsmMacro *M, MCAsmMacroArguments &A);
|
|
||||||
|
|
||||||
/// \brief Parse up to the end of statement and a return the contents from the
|
/// \brief Parse up to the end of statement and a return the contents from the
|
||||||
/// current token until the end of the statement; the current token on exit
|
/// current token until the end of the statement; the current token on exit
|
||||||
/// will be either the EndOfStatement or EOF.
|
/// will be either the EndOfStatement or EOF.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user