[llvm-commits] [llvm] r172637 - in /llvm/trunk: include/llvm/MC/MCParser/MCAsmParser.h lib/MC/MCParser/AsmParser.cpp
Eli Bendersky
eliben at google.com
Wed Jan 16 10:56:50 PST 2013
Author: eliben
Date: Wed Jan 16 12:56:50 2013
New Revision: 172637
URL: http://llvm.org/viewvc/llvm-project?rev=172637&view=rev
Log:
Now that GenericAsmParser was folded into AsmParser, some methods and types can
return into the safe harbor of AsmParser's private areas.
Modified:
llvm/trunk/include/llvm/MC/MCParser/MCAsmParser.h
llvm/trunk/lib/MC/MCParser/AsmParser.cpp
Modified: llvm/trunk/include/llvm/MC/MCParser/MCAsmParser.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCParser/MCAsmParser.h?rev=172637&r1=172636&r2=172637&view=diff
==============================================================================
--- llvm/trunk/include/llvm/MC/MCParser/MCAsmParser.h (original)
+++ llvm/trunk/include/llvm/MC/MCParser/MCAsmParser.h Wed Jan 16 12:56:50 2013
@@ -44,25 +44,6 @@
};
-/// \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
/// assembly parsers.
class MCAsmParser {
@@ -159,41 +140,6 @@
/// recovery.
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.
///
/// @param Res - The value of the expression. The result is undefined
Modified: llvm/trunk/lib/MC/MCParser/AsmParser.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCParser/AsmParser.cpp?rev=172637&r1=172636&r2=172637&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCParser/AsmParser.cpp (original)
+++ llvm/trunk/lib/MC/MCParser/AsmParser.cpp Wed Jan 16 12:56:50 2013
@@ -50,6 +50,25 @@
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
/// instantiation.
struct MacroInstantiation {
@@ -73,7 +92,6 @@
MemoryBuffer *I);
};
-//struct AsmRewrite;
struct ParseStatementInfo {
/// ParsedOperands - The parsed operands from the last parsed statement.
SmallVector<MCParsedAsmOperand*, 8> ParsedOperands;
@@ -205,25 +223,11 @@
virtual bool ParseParenExpression(const MCExpr *&Res, SMLoc &EndLoc);
virtual bool ParseAbsoluteExpression(int64_t &Res);
- bool ParseMacroArgument(MCAsmMacroArgument &MA,
- AsmToken::TokenKind &ArgumentDelimiter);
-
/// ParseIdentifier - Parse an identifier or string (as a quoted identifier)
/// and set \p Res to the identifier contents.
virtual bool ParseIdentifier(StringRef &Res);
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();
/// }
@@ -238,6 +242,44 @@
const MCAsmMacroArguments &A,
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 PrintMessage(SMLoc Loc, SourceMgr::DiagKind Kind, const Twine &Msg,
ArrayRef<SMRange> Ranges = ArrayRef<SMRange>()) const {
@@ -259,8 +301,6 @@
/// location.
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
/// current token until the end of the statement; the current token on exit
/// will be either the EndOfStatement or EOF.
More information about the llvm-commits
mailing list