summaryrefslogtreecommitdiffstats
path: root/llvm/lib/MC/MCParser/AsmParser.cpp
diff options
context:
space:
mode:
authorCraig Topper <craig.topper@intel.com>2018-09-25 20:55:55 +0000
committerCraig Topper <craig.topper@intel.com>2018-09-25 20:55:55 +0000
commitc81aff79d3ae0e81b3183e3f077627ea569ad4fc (patch)
tree0fd2f0ce19758bdcdec87bdc6425075dbe4f596a /llvm/lib/MC/MCParser/AsmParser.cpp
parent96335dd1ecb7ca9cb39144651f93aa123fdf1732 (diff)
downloadbcm5719-llvm-c81aff79d3ae0e81b3183e3f077627ea569ad4fc.tar.gz
bcm5719-llvm-c81aff79d3ae0e81b3183e3f077627ea569ad4fc.zip
[MCAsmParser] Move AltMacroMode tracking out of MCAsmLexer
The Lexer doesn't use this state itself. It is only set and used by AsmParser so it seems like it should just be part of AsmParser. Differential Revision: https://reviews.llvm.org/D52515 llvm-svn: 343027
Diffstat (limited to 'llvm/lib/MC/MCParser/AsmParser.cpp')
-rw-r--r--llvm/lib/MC/MCParser/AsmParser.cpp17
1 files changed, 8 insertions, 9 deletions
diff --git a/llvm/lib/MC/MCParser/AsmParser.cpp b/llvm/lib/MC/MCParser/AsmParser.cpp
index df4e2333d1d..eb76dd07088 100644
--- a/llvm/lib/MC/MCParser/AsmParser.cpp
+++ b/llvm/lib/MC/MCParser/AsmParser.cpp
@@ -180,6 +180,9 @@ private:
/// Did we already inform the user about inconsistent MD5 usage?
bool ReportedInconsistentMD5 = false;
+ // Is alt macro mode enabled.
+ bool AltMacroMode = false;
+
public:
AsmParser(SourceMgr &SM, MCContext &Ctx, MCStreamer &Out,
const MCAsmInfo &MAI, unsigned CB);
@@ -2443,14 +2446,13 @@ bool AsmParser::expandMacro(raw_svector_ostream &OS, StringRef Body,
// Here, we identify the integer token which is the result of the
// absolute expression evaluation and replace it with its string
// representation.
- if (Lexer.IsaAltMacroMode() && Token.getString().front() == '%' &&
+ if (AltMacroMode && Token.getString().front() == '%' &&
Token.is(AsmToken::Integer))
// Emit an integer value to the buffer.
OS << Token.getIntVal();
// Only Token that was validated as a string and begins with '<'
// is considered altMacroString!!!
- else if (Lexer.IsaAltMacroMode() &&
- Token.getString().front() == '<' &&
+ else if (AltMacroMode && Token.getString().front() == '<' &&
Token.is(AsmToken::String)) {
OS << altMacroString(Token.getStringContents());
}
@@ -2634,7 +2636,7 @@ bool AsmParser::parseMacroArguments(const MCAsmMacro *M,
SMLoc StrLoc = Lexer.getLoc();
SMLoc EndLoc;
- if (Lexer.IsaAltMacroMode() && Lexer.is(AsmToken::Percent)) {
+ if (AltMacroMode && Lexer.is(AsmToken::Percent)) {
const MCExpr *AbsoluteExp;
int64_t Value;
/// Eat '%'
@@ -2649,7 +2651,7 @@ bool AsmParser::parseMacroArguments(const MCAsmMacro *M,
AsmToken newToken(AsmToken::Integer,
StringRef(StrChar, EndChar - StrChar), Value);
FA.Value.push_back(newToken);
- } else if (Lexer.IsaAltMacroMode() && Lexer.is(AsmToken::Less) &&
+ } else if (AltMacroMode && Lexer.is(AsmToken::Less) &&
isAltmacroString(StrLoc, EndLoc)) {
const char *StrChar = StrLoc.getPointer();
const char *EndChar = EndLoc.getPointer();
@@ -4186,10 +4188,7 @@ bool AsmParser::parseDirectiveCFIUndefined(SMLoc DirectiveLoc) {
bool AsmParser::parseDirectiveAltmacro(StringRef Directive) {
if (getLexer().isNot(AsmToken::EndOfStatement))
return TokError("unexpected token in '" + Directive + "' directive");
- if (Directive == ".altmacro")
- getLexer().SetAltMacroMode(true);
- else
- getLexer().SetAltMacroMode(false);
+ AltMacroMode = (Directive == ".altmacro");
return false;
}
OpenPOWER on IntegriCloud