aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--tools/llvm-mc/AsmLexer.cpp82
-rw-r--r--tools/llvm-mc/AsmLexer.h35
-rw-r--r--tools/llvm-mc/AsmParser.cpp196
-rw-r--r--tools/llvm-mc/MC-X86Specific.cpp38
-rw-r--r--tools/llvm-mc/llvm-mc.cpp72
5 files changed, 213 insertions, 210 deletions
diff --git a/tools/llvm-mc/AsmLexer.cpp b/tools/llvm-mc/AsmLexer.cpp
index 9e777b6e6e..de583ffa8c 100644
--- a/tools/llvm-mc/AsmLexer.cpp
+++ b/tools/llvm-mc/AsmLexer.cpp
@@ -24,7 +24,7 @@ AsmLexer::AsmLexer(SourceMgr &SM) : SrcMgr(SM) {
CurBuffer = 0;
CurBuf = SrcMgr.getMemoryBuffer(CurBuffer);
CurPtr = CurBuf->getBufferStart();
- CurTok = AsmToken(asmtok::Error, StringRef(CurPtr, 0));
+ CurTok = AsmToken(AsmToken::Error, StringRef(CurPtr, 0));
TokStart = 0;
}
@@ -41,10 +41,10 @@ void AsmLexer::PrintMessage(SMLoc Loc, const std::string &Msg,
}
/// ReturnError - Set the error to the specified string at the specified
-/// location. This is defined to always return asmtok::Error.
+/// location. This is defined to always return AsmToken::Error.
AsmToken AsmLexer::ReturnError(const char *Loc, const std::string &Msg) {
SrcMgr.PrintMessage(SMLoc::getFromPointer(Loc), Msg, "error");
- return AsmToken(asmtok::Error, StringRef(Loc, 0));
+ return AsmToken(AsmToken::Error, StringRef(Loc, 0));
}
/// EnterIncludeFile - Enter the specified file. This prints an error and
@@ -99,18 +99,18 @@ AsmToken AsmLexer::LexIdentifier() {
while (isalnum(*CurPtr) || *CurPtr == '_' || *CurPtr == '$' ||
*CurPtr == '.' || *CurPtr == '@')
++CurPtr;
- return AsmToken(asmtok::Identifier, StringRef(TokStart, CurPtr - TokStart));
+ return AsmToken(AsmToken::Identifier, StringRef(TokStart, CurPtr - TokStart));
}
/// LexPercent: Register: %[a-zA-Z0-9]+
AsmToken AsmLexer::LexPercent() {
if (!isalnum(*CurPtr))
- return AsmToken(asmtok::Percent, StringRef(CurPtr, 1)); // Single %.
+ return AsmToken(AsmToken::Percent, StringRef(CurPtr, 1)); // Single %.
while (isalnum(*CurPtr))
++CurPtr;
- return AsmToken(asmtok::Register, StringRef(TokStart, CurPtr - TokStart));
+ return AsmToken(AsmToken::Register, StringRef(TokStart, CurPtr - TokStart));
}
/// LexSlash: Slash: /
@@ -119,7 +119,7 @@ AsmToken AsmLexer::LexSlash() {
switch (*CurPtr) {
case '*': break; // C style comment.
case '/': return ++CurPtr, LexLineComment();
- default: return AsmToken(asmtok::Slash, StringRef(CurPtr, 1));
+ default: return AsmToken(AsmToken::Slash, StringRef(CurPtr, 1));
}
// C Style comment.
@@ -149,8 +149,8 @@ AsmToken AsmLexer::LexLineComment() {
CurChar = getNextChar();
if (CurChar == EOF)
- return AsmToken(asmtok::Eof, StringRef(CurPtr, 0));
- return AsmToken(asmtok::EndOfStatement, StringRef(CurPtr, 0));
+ return AsmToken(AsmToken::Eof, StringRef(CurPtr, 0));
+ return AsmToken(AsmToken::EndOfStatement, StringRef(CurPtr, 0));
}
@@ -172,7 +172,7 @@ AsmToken AsmLexer::LexDigit() {
if (CurPtr[-1] != '0') {
while (isdigit(*CurPtr))
++CurPtr;
- return AsmToken(asmtok::IntVal, StringRef(TokStart, CurPtr - TokStart),
+ return AsmToken(AsmToken::Integer, StringRef(TokStart, CurPtr - TokStart),
strtoll(TokStart, 0, 10));
}
@@ -185,7 +185,7 @@ AsmToken AsmLexer::LexDigit() {
// Requires at least one binary digit.
if (CurPtr == NumStart)
return ReturnError(CurPtr-2, "Invalid binary number");
- return AsmToken(asmtok::IntVal, StringRef(TokStart, CurPtr - TokStart),
+ return AsmToken(AsmToken::Integer, StringRef(TokStart, CurPtr - TokStart),
strtoll(NumStart, 0, 2));
}
@@ -209,14 +209,14 @@ AsmToken AsmLexer::LexDigit() {
if (errno == ERANGE)
return ReturnError(CurPtr-2, "Hexadecimal number out of range");
}
- return AsmToken(asmtok::IntVal, StringRef(TokStart, CurPtr - TokStart),
+ return AsmToken(AsmToken::Integer, StringRef(TokStart, CurPtr - TokStart),
(int64_t) strtoull(NumStart, 0, 16));
}
// Must be an octal number, it starts with 0.
while (*CurPtr >= '0' && *CurPtr <= '7')
++CurPtr;
- return AsmToken(asmtok::IntVal, StringRef(TokStart, CurPtr - TokStart),
+ return AsmToken(AsmToken::Integer, StringRef(TokStart, CurPtr - TokStart),
strtoll(TokStart, 0, 8));
}
@@ -236,7 +236,7 @@ AsmToken AsmLexer::LexQuote() {
CurChar = getNextChar();
}
- return AsmToken(asmtok::String, StringRef(TokStart, CurPtr - TokStart));
+ return AsmToken(AsmToken::String, StringRef(TokStart, CurPtr - TokStart));
}
@@ -253,7 +253,7 @@ AsmToken AsmLexer::LexToken() {
// Unknown character, emit an error.
return ReturnError(TokStart, "invalid character in input");
- case EOF: return AsmToken(asmtok::Eof, StringRef(TokStart, 0));
+ case EOF: return AsmToken(AsmToken::Eof, StringRef(TokStart, 0));
case 0:
case ' ':
case '\t':
@@ -261,33 +261,33 @@ AsmToken AsmLexer::LexToken() {
return LexToken();
case '\n': // FALL THROUGH.
case '\r': // FALL THROUGH.
- case ';': return AsmToken(asmtok::EndOfStatement, StringRef(TokStart, 1));
- case ':': return AsmToken(asmtok::Colon, StringRef(TokStart, 1));
- case '+': return AsmToken(asmtok::Plus, StringRef(TokStart, 1));
- case '-': return AsmToken(asmtok::Minus, StringRef(TokStart, 1));
- case '~': return AsmToken(asmtok::Tilde, StringRef(TokStart, 1));
- case '(': return AsmToken(asmtok::LParen, StringRef(TokStart, 1));
- case ')': return AsmToken(asmtok::RParen, StringRef(TokStart, 1));
- case '*': return AsmToken(asmtok::Star, StringRef(TokStart, 1));
- case ',': return AsmToken(asmtok::Comma, StringRef(TokStart, 1));
- case '$': return AsmToken(asmtok::Dollar, StringRef(TokStart, 1));
+ case ';': return AsmToken(AsmToken::EndOfStatement, StringRef(TokStart, 1));
+ case ':': return AsmToken(AsmToken::Colon, StringRef(TokStart, 1));
+ case '+': return AsmToken(AsmToken::Plus, StringRef(TokStart, 1));
+ case '-': return AsmToken(AsmToken::Minus, StringRef(TokStart, 1));
+ case '~': return AsmToken(AsmToken::Tilde, StringRef(TokStart, 1));
+ case '(': return AsmToken(AsmToken::LParen, StringRef(TokStart, 1));
+ case ')': return AsmToken(AsmToken::RParen, StringRef(TokStart, 1));
+ case '*': return AsmToken(AsmToken::Star, StringRef(TokStart, 1));
+ case ',': return AsmToken(AsmToken::Comma, StringRef(TokStart, 1));
+ case '$': return AsmToken(AsmToken::Dollar, StringRef(TokStart, 1));
case '=':
if (*CurPtr == '=')
- return ++CurPtr, AsmToken(asmtok::EqualEqual, StringRef(TokStart, 2));
- return AsmToken(asmtok::Equal, StringRef(TokStart, 1));
+ return ++CurPtr, AsmToken(AsmToken::EqualEqual, StringRef(TokStart, 2));
+ return AsmToken(AsmToken::Equal, StringRef(TokStart, 1));
case '|':
if (*CurPtr == '|')
- return ++CurPtr, AsmToken(asmtok::PipePipe, StringRef(TokStart, 2));
- return AsmToken(asmtok::Pipe, StringRef(TokStart, 1));
- case '^': return AsmToken(asmtok::Caret, StringRef(TokStart, 1));
+ return ++CurPtr, AsmToken(AsmToken::PipePipe, StringRef(TokStart, 2));
+ return AsmToken(AsmToken::Pipe, StringRef(TokStart, 1));
+ case '^': return AsmToken(AsmToken::Caret, StringRef(TokStart, 1));
case '&':
if (*CurPtr == '&')
- return ++CurPtr, AsmToken(asmtok::AmpAmp, StringRef(TokStart, 2));
- return AsmToken(asmtok::Amp, StringRef(TokStart, 1));
+ return ++CurPtr, AsmToken(AsmToken::AmpAmp, StringRef(TokStart, 2));
+ return AsmToken(AsmToken::Amp, StringRef(TokStart, 1));
case '!':
if (*CurPtr == '=')
- return ++CurPtr, AsmToken(asmtok::ExclaimEqual, StringRef(TokStart, 2));
- return AsmToken(asmtok::Exclaim, StringRef(TokStart, 1));
+ return ++CurPtr, AsmToken(AsmToken::ExclaimEqual, StringRef(TokStart, 2));
+ return AsmToken(AsmToken::Exclaim, StringRef(TokStart, 1));
case '%': return LexPercent();
case '/': return LexSlash();
case '#': return LexLineComment();
@@ -297,21 +297,21 @@ AsmToken AsmLexer::LexToken() {
return LexDigit();
case '<':
switch (*CurPtr) {
- case '<': return ++CurPtr, AsmToken(asmtok::LessLess,
+ case '<': return ++CurPtr, AsmToken(AsmToken::LessLess,
StringRef(TokStart, 2));
- case '=': return ++CurPtr, AsmToken(asmtok::LessEqual,
+ case '=': return ++CurPtr, AsmToken(AsmToken::LessEqual,
StringRef(TokStart, 2));
- case '>': return ++CurPtr, AsmToken(asmtok::LessGreater,
+ case '>': return ++CurPtr, AsmToken(AsmToken::LessGreater,
StringRef(TokStart, 2));
- default: return AsmToken(asmtok::Less, StringRef(TokStart, 1));
+ default: return AsmToken(AsmToken::Less, StringRef(TokStart, 1));
}
case '>':
switch (*CurPtr) {
- case '>': return ++CurPtr, AsmToken(asmtok::GreaterGreater,
+ case '>': return ++CurPtr, AsmToken(AsmToken::GreaterGreater,
StringRef(TokStart, 2));
- case '=': return ++CurPtr, AsmToken(asmtok::GreaterEqual,
+ case '=': return ++CurPtr, AsmToken(AsmToken::GreaterEqual,
StringRef(TokStart, 2));
- default: return AsmToken(asmtok::Greater, StringRef(TokStart, 1));
+ default: return AsmToken(AsmToken::Greater, StringRef(TokStart, 1));
}
// TODO: Quoted identifiers (objc methods etc)
diff --git a/tools/llvm-mc/AsmLexer.h b/tools/llvm-mc/AsmLexer.h
index e60fa201e5..6146499e16 100644
--- a/tools/llvm-mc/AsmLexer.h
+++ b/tools/llvm-mc/AsmLexer.h
@@ -25,8 +25,9 @@ class MemoryBuffer;
class SourceMgr;
class SMLoc;
-namespace asmtok {
- enum TokKind {
+/// AsmToken - Target independent representation for an assembler token.
+struct AsmToken {
+ enum TokenKind {
// Markers
Eof, Error,
@@ -36,7 +37,7 @@ namespace asmtok {
String,
// Integer values.
- IntVal,
+ Integer,
// No-value.
EndOfStatement,
@@ -51,11 +52,8 @@ namespace asmtok {
Less, LessEqual, LessLess, LessGreater,
Greater, GreaterEqual, GreaterGreater
};
-}
-/// AsmToken - Target independent representation for an assembler token.
-struct AsmToken {
- asmtok::TokKind Kind;
+ TokenKind Kind;
/// A reference to the entire token contents; this is always a pointer into
/// a memory buffer owned by the source manager.
@@ -65,19 +63,22 @@ struct AsmToken {
public:
AsmToken() {}
- AsmToken(asmtok::TokKind _Kind, const StringRef &_Str, int64_t _IntVal = 0)
+ AsmToken(TokenKind _Kind, const StringRef &_Str, int64_t _IntVal = 0)
: Kind(_Kind), Str(_Str), IntVal(_IntVal) {}
- asmtok::TokKind getKind() const { return Kind; }
- bool is(asmtok::TokKind K) const { return Kind == K; }
- bool isNot(asmtok::TokKind K) const { return Kind != K; }
+ TokenKind getKind() const { return Kind; }
+ bool is(TokenKind K) const { return Kind == K; }
+ bool isNot(TokenKind K) const { return Kind != K; }
SMLoc getLoc() const;
StringRef getString() const { return Str; }
+ // FIXME: Don't compute this in advance, it makes every token larger, and is
+ // also not generally what we want (it is nicer for recovery etc. to lex 123br
+ // as a single token, then diagnose as an invalid number).
int64_t getIntVal() const {
- assert(Kind == asmtok::IntVal && "This token isn't an integer");
+ assert(Kind == Integer && "This token isn't an integer");
return IntVal;
}
};
@@ -104,13 +105,13 @@ public:
AsmLexer(SourceMgr &SrcMgr);
~AsmLexer();
- asmtok::TokKind Lex() {
+ AsmToken::TokenKind Lex() {
return CurTok = LexToken(), getKind();
}
- asmtok::TokKind getKind() const { return CurTok.getKind(); }
- bool is(asmtok::TokKind K) const { return CurTok.is(K); }
- bool isNot(asmtok::TokKind K) const { return CurTok.isNot(K); }
+ AsmToken::TokenKind getKind() const { return CurTok.getKind(); }
+ bool is(AsmToken::TokenKind K) const { return CurTok.is(K); }
+ bool isNot(AsmToken::TokenKind K) const { return CurTok.isNot(K); }
/// getCurStrVal - Get the string for the current token, this includes all
/// characters (for example, the quotes on strings) in the token.
@@ -125,6 +126,8 @@ public:
}
SMLoc getLoc() const;
+
+ const AsmToken &getTok() const;
/// EnterIncludeFile - Enter the specified file. This returns true on failure.
bool EnterIncludeFile(const std::string &Filename);
diff --git a/tools/llvm-mc/AsmParser.cpp b/tools/llvm-mc/AsmParser.cpp
index 65d48b23cb..4af4bd232a 100644
--- a/tools/llvm-mc/AsmParser.cpp
+++ b/tools/llvm-mc/AsmParser.cpp
@@ -45,7 +45,7 @@ bool AsmParser::Run() {
bool HadError = false;
// While we have input, parse each statement.
- while (Lexer.isNot(asmtok::Eof)) {
+ while (Lexer.isNot(AsmToken::Eof)) {
if (!ParseStatement()) continue;
// If we had an error, remember it and recover by skipping to the next line.
@@ -58,12 +58,12 @@ bool AsmParser::Run() {
/// EatToEndOfStatement - Throw away the rest of the line for testing purposes.
void AsmParser::EatToEndOfStatement() {
- while (Lexer.isNot(asmtok::EndOfStatement) &&
- Lexer.isNot(asmtok::Eof))
+ while (Lexer.isNot(AsmToken::EndOfStatement) &&
+ Lexer.isNot(AsmToken::Eof))
Lexer.Lex();
// Eat EOL.
- if (Lexer.is(asmtok::EndOfStatement))
+ if (Lexer.is(AsmToken::EndOfStatement))
Lexer.Lex();
}
@@ -75,7 +75,7 @@ void AsmParser::EatToEndOfStatement() {
///
bool AsmParser::ParseParenExpr(AsmExpr *&Res) {
if (ParseExpression(Res)) return true;
- if (Lexer.isNot(asmtok::RParen))
+ if (Lexer.isNot(AsmToken::RParen))
return TokError("expected ')' in parentheses expression");
Lexer.Lex();
return false;
@@ -90,13 +90,13 @@ bool AsmParser::ParsePrimaryExpr(AsmExpr *&Res) {
switch (Lexer.getKind()) {
default:
return TokError("unknown token in expression");
- case asmtok::Exclaim:
+ case AsmToken::Exclaim:
Lexer.Lex(); // Eat the operator.
if (ParsePrimaryExpr(Res))
return true;
Res = new AsmUnaryExpr(AsmUnaryExpr::LNot, Res);
return false;
- case asmtok::Identifier: {
+ case AsmToken::Identifier: {
// This is a label, this should be parsed as part of an expression, to
// handle things like LFOO+4.
MCSymbol *Sym = Ctx.GetOrCreateSymbol(Lexer.getCurStrVal());
@@ -109,26 +109,26 @@ bool AsmParser::ParsePrimaryExpr(AsmExpr *&Res) {
Lexer.Lex(); // Eat identifier.
return false;
}
- case asmtok::IntVal:
+ case AsmToken::Integer:
Res = new AsmConstantExpr(Lexer.getCurIntVal());
Lexer.Lex(); // Eat identifier.
return false;
- case asmtok::LParen:
+ case AsmToken::LParen:
Lexer.Lex(); // Eat the '('.
return ParseParenExpr(Res);
- case asmtok::Minus:
+ case AsmToken::Minus:
Lexer.Lex(); // Eat the operator.
if (ParsePrimaryExpr(Res))
return true;
Res = new AsmUnaryExpr(AsmUnaryExpr::Minus, Res);
return false;
- case asmtok::Plus:
+ case AsmToken::Plus:
Lexer.Lex(); // Eat the operator.
if (ParsePrimaryExpr(Res))
return true;
Res = new AsmUnaryExpr(AsmUnaryExpr::Plus, Res);
return false;
- case asmtok::Tilde:
+ case AsmToken::Tilde:
Lexer.Lex(); // Eat the operator.
if (ParsePrimaryExpr(Res))
return true;
@@ -189,73 +189,73 @@ bool AsmParser::ParseParenRelocatableExpression(MCValue &Res) {
return false;
}
-static unsigned getBinOpPrecedence(asmtok::TokKind K,
+static unsigned getBinOpPrecedence(AsmToken::TokenKind K,
AsmBinaryExpr::Opcode &Kind) {
switch (K) {
default: return 0; // not a binop.
// Lowest Precedence: &&, ||
- case asmtok::AmpAmp:
+ case AsmToken::AmpAmp:
Kind = AsmBinaryExpr::LAnd;
return 1;
- case asmtok::PipePipe:
+ case AsmToken::PipePipe:
Kind = AsmBinaryExpr::LOr;
return 1;
// Low Precedence: +, -, ==, !=, <>, <, <=, >, >=
- case asmtok::Plus:
+ case AsmToken::Plus:
Kind = AsmBinaryExpr::Add;
return 2;
- case asmtok::Minus:
+ case AsmToken::Minus:
Kind = AsmBinaryExpr::Sub;
return 2;
- case asmtok::EqualEqual:
+ case AsmToken::EqualEqual:
Kind = AsmBinaryExpr::EQ;
return 2;
- case asmtok::ExclaimEqual:
- case asmtok::LessGreater:
+ case AsmToken::ExclaimEqual:
+ case AsmToken::LessGreater:
Kind = AsmBinaryExpr::NE;
return 2;
- case asmtok::Less:
+ case AsmToken::Less:
Kind = AsmBinaryExpr::LT;
return 2;
- case asmtok::LessEqual:
+ case AsmToken::LessEqual:
Kind = AsmBinaryExpr::LTE;
return 2;
- case asmtok::Greater:
+ case AsmToken::Greater:
Kind = AsmBinaryExpr::GT;
return 2;
- case asmtok::GreaterEqual:
+ case AsmToken::GreaterEqual:
Kind = AsmBinaryExpr::GTE;
return 2;
// Intermediate Precedence: |, &, ^
//
// FIXME: gas seems to support '!' as an infix operator?
- case asmtok::Pipe:
+ case AsmToken::Pipe:
Kind = AsmBinaryExpr::Or;
return 3;
- case asmtok::Caret:
+ case AsmToken::Caret:
Kind = AsmBinaryExpr::Xor;
return 3;
- case asmtok::Amp:
+ case AsmToken::Amp:
Kind = AsmBinaryExpr::And;
return 3;
// Highest Precedence: *, /, %, <<, >>
- case asmtok::Star:
+ case AsmToken::Star:
Kind = AsmBinaryExpr::Mul;
return 4;
- case asmtok::Slash:
+ case AsmToken::Slash:
Kind = AsmBinaryExpr::Div;
return 4;
- case asmtok::Percent:
+ case AsmToken::Percent:
Kind = AsmBinaryExpr::Mod;
return 4;
- case asmtok::LessLess:
+ case AsmToken::LessLess:
Kind = AsmBinaryExpr::Shl;
return 4;
- case asmtok::GreaterGreater:
+ case AsmToken::GreaterGreater:
Kind = AsmBinaryExpr::Shr;
return 4;
}
@@ -304,10 +304,10 @@ bool AsmParser::ParseStatement() {
switch (Lexer.getKind()) {
default:
return TokError("unexpected token at start of statement");
- case asmtok::EndOfStatement:
+ case AsmToken::EndOfStatement:
Lexer.Lex();
return false;
- case asmtok::Identifier:
+ case AsmToken::Identifier:
break;
// TODO: Recurse on local labels etc.
}
@@ -318,7 +318,7 @@ bool AsmParser::ParseStatement() {
// Consume the identifier, see what is after it.
switch (Lexer.Lex()) {
- case asmtok::Colon: {
+ case AsmToken::Colon: {
// identifier ':' -> Label.
Lexer.Lex();
@@ -341,7 +341,7 @@ bool AsmParser::ParseStatement() {
return ParseStatement();
}
- case asmtok::Equal:
+ case AsmToken::Equal:
// identifier '=' ... -> assignment statement
Lexer.Lex();
@@ -554,7 +554,7 @@ bool AsmParser::ParseStatement() {
getTargetParser().ParseInstruction(*this, IDVal, Inst))
return true;
- if (Lexer.isNot(asmtok::EndOfStatement))
+ if (Lexer.isNot(AsmToken::EndOfStatement))
return TokError("unexpected token in argument list");
// Eat the end of statement marker.
@@ -575,7 +575,7 @@ bool AsmParser::ParseAssignment(const StringRef &Name, bool IsDotSet) {
if (ParseRelocatableExpression(Value))
return true;
- if (Lexer.isNot(asmtok::EndOfStatement))
+ if (Lexer.isNot(AsmToken::EndOfStatement))
return TokError("unexpected token in assignment");
// Eat the end of statement marker.
@@ -603,12 +603,12 @@ bool AsmParser::ParseAssignment(const StringRef &Name, bool IsDotSet) {
/// ParseDirectiveSet:
/// ::= .set identifier ',' expression
bool AsmParser::ParseDirectiveSet() {
- if (Lexer.isNot(asmtok::Identifier))
+ if (Lexer.isNot(AsmToken::Identifier))
return TokError("expected identifier after '.set' directive");
StringRef Name = Lexer.getCurStrVal();
- if (Lexer.Lex() != asmtok::Comma)
+ if (Lexer.Lex() != AsmToken::Comma)
return TokError("unexpected token in '.set'");
Lexer.Lex();
@@ -620,24 +620,24 @@ bool AsmParser::ParseDirectiveSet() {
/// FIXME: This should actually parse out the segment, section, attributes and
/// sizeof_stub fields.
bool AsmParser::ParseDirectiveDarwinSection() {
- if (Lexer.isNot(asmtok::Identifier))
+ if (Lexer.isNot(AsmToken::Identifier))
return TokError("expected identifier after '.section' directive");
std::string Section = Lexer.getCurStrVal();
Lexer.Lex();
// Accept a comma separated list of modifiers.
- while (Lexer.is(asmtok::Comma)) {
+ while (Lexer.is(AsmToken::Comma)) {
Lexer.Lex();
- if (Lexer.isNot(asmtok::Identifier))
+ if (Lexer.isNot(AsmToken::Identifier))
return TokError("expected identifier in '.section' directive");
Section += ',';
Section += Lexer.getCurStrVal().str();
Lexer.Lex();
}
- if (Lexer.isNot(asmtok::EndOfStatement))
+ if (Lexer.isNot(AsmToken::EndOfStatement))
return TokError("unexpected token in '.section' directive");
Lexer.Lex();
@@ -647,7 +647,7 @@ bool AsmParser::ParseDirectiveDarwinSection() {
bool AsmParser::ParseDirectiveSectionSwitch(const char *Section,
const char *Directives) {
- if (Lexer.isNot(asmtok::EndOfStatement))
+ if (Lexer.isNot(AsmToken::EndOfStatement))
return TokError("unexpected token in section switching directive");
Lexer.Lex();
@@ -664,9 +664,9 @@ bool AsmParser::ParseDirectiveSectionSwitch(const char *Section,
/// ParseDirectiveAscii:
/// ::= ( .ascii | .asciz ) [ "string" ( , "string" )* ]
bool AsmParser::ParseDirectiveAscii(bool ZeroTerminated) {
- if (Lexer.isNot(asmtok::EndOfStatement)) {
+ if (Lexer.isNot(AsmToken::EndOfStatement)) {
for (;;) {
- if (Lexer.isNot(asmtok::String))
+ if (Lexer.isNot(AsmToken::String))
return TokError("expected string in '.ascii' or '.asciz' directive");
// FIXME: This shouldn't use a const char* + strlen, the string could have
@@ -679,10 +679,10 @@ bool AsmParser::ParseDirectiveAscii(bool ZeroTerminated) {
Lexer.Lex();
- if (Lexer.is(asmtok::EndOfStatement))
+ if (Lexer.is(AsmToken::EndOfStatement))
break;
- if (Lexer.isNot(asmtok::Comma))
+ if (Lexer.isNot(AsmToken::Comma))
return TokError("unexpected token in '.ascii' or '.asciz' directive");
Lexer.Lex();
}
@@ -695,7 +695,7 @@ bool AsmParser::ParseDirectiveAscii(bool ZeroTerminated) {
/// ParseDirectiveValue
/// ::= (.byte | .short | ... ) [ expression (, expression)* ]
bool AsmParser::ParseDirectiveValue(unsigned Size) {
- if (Lexer.isNot(asmtok::EndOfStatement)) {
+ if (Lexer.isNot(AsmToken::EndOfStatement)) {
for (;;) {
MCValue Expr;
if (ParseRelocatableExpression(Expr))
@@ -703,11 +703,11 @@ bool AsmParser::ParseDirectiveValue(unsigned Size) {
Out.EmitValue(Expr, Size);
- if (Lexer.is(asmtok::EndOfStatement))
+ if (Lexer.is(AsmToken::EndOfStatement))
break;
// FIXME: Improve diagnostic.
- if (Lexer.isNot(asmtok::Comma))
+ if (Lexer.isNot(AsmToken::Comma))
return TokError("unexpected token in directive");
Lexer.Lex();
}
@@ -726,8 +726,8 @@ bool AsmParser::ParseDirectiveSpace() {
int64_t FillExpr = 0;
bool HasFillExpr = false;
- if (Lexer.isNot(asmtok::EndOfStatement)) {
- if (Lexer.isNot(asmtok::Comma))
+ if (Lexer.isNot(AsmToken::EndOfStatement)) {
+ if (Lexer.isNot(AsmToken::Comma))
return TokError("unexpected token in '.space' directive");
Lexer.Lex();
@@ -736,7 +736,7 @@ bool AsmParser::ParseDirectiveSpace() {
HasFillExpr = true;
- if (Lexer.isNot(asmtok::EndOfStatement))
+ if (Lexer.isNot(AsmToken::EndOfStatement))
return TokError("unexpected token in '.space' directive");
}
@@ -759,7 +759,7 @@ bool AsmParser::ParseDirectiveFill() {
if (ParseAbsoluteExpression(NumValues))
return true;
- if (Lexer.isNot(asmtok::Comma))
+ if (Lexer.isNot(AsmToken::Comma))
return TokError("unexpected token in '.fill' directive");
Lexer.Lex();
@@ -767,7 +767,7 @@ bool AsmParser::ParseDirectiveFill() {
if (ParseAbsoluteExpression(FillSize))
return true;
- if (Lexer.isNot(asmtok::Comma))
+ if (Lexer.isNot(AsmToken::Comma))
return TokError("unexpected token in '.fill' directive");
Lexer.Lex();
@@ -775,7 +775,7 @@ bool AsmParser::ParseDirectiveFill() {
if (ParseAbsoluteExpression(FillExpr))
return true;
- if (Lexer.isNot(asmtok::EndOfStatement))
+ if (Lexer.isNot(AsmToken::EndOfStatement))
return TokError("unexpected token in '.fill' directive");
Lexer.Lex();
@@ -798,15 +798,15 @@ bool AsmParser::ParseDirectiveOrg() {
// Parse optional fill expression.
int64_t FillExpr = 0;
- if (Lexer.isNot(asmtok::EndOfStatement)) {
- if (Lexer.isNot(asmtok::Comma))
+ if (Lexer.isNot(AsmToken::EndOfStatement)) {
+ if (Lexer.isNot(AsmToken::Comma))
return TokError("unexpected token in '.org' directive");
Lexer.Lex();
if (ParseAbsoluteExpression(FillExpr))
return true;
- if (Lexer.isNot(asmtok::EndOfStatement))
+ if (Lexer.isNot(AsmToken::EndOfStatement))
return TokError("unexpected token in '.org' directive");
}
@@ -830,22 +830,22 @@ bool AsmParser::ParseDirectiveAlign(bool IsPow2, unsigned ValueSize) {
bool HasFillExpr = false;
int64_t FillExpr = 0;
int64_t MaxBytesToFill = 0;
- if (Lexer.isNot(asmtok::EndOfStatement)) {
- if (Lexer.isNot(asmtok::Comma))
+ if (Lexer.isNot(AsmToken::EndOfStatement)) {
+ if (Lexer.isNot(AsmToken::Comma))
return TokError("unexpected token in directive");
Lexer.Lex();
// The fill expression can be omitted while specifying a maximum number of
// alignment bytes, e.g:
// .align 3,,4
- if (Lexer.isNot(asmtok::Comma)) {
+ if (Lexer.isNot(AsmToken::Comma)) {
HasFillExpr = true;
if (ParseAbsoluteExpression(FillExpr))
return true;
}
- if (Lexer.isNot(asmtok::EndOfStatement)) {
- if (Lexer.isNot(asmtok::Comma))
+ if (Lexer.isNot(AsmToken::EndOfStatement)) {
+ if (Lexer.isNot(AsmToken::Comma))
return TokError("unexpected token in directive");
Lexer.Lex();
@@ -853,7 +853,7 @@ bool AsmParser::ParseDirectiveAlign(bool IsPow2, unsigned ValueSize) {
if (ParseAbsoluteExpression(MaxBytesToFill))
return true;
- if (Lexer.isNot(asmtok::EndOfStatement))
+ if (Lexer.isNot(AsmToken::EndOfStatement))
return TokError("unexpected token in directive");
}
}
@@ -895,9 +895,9 @@ bool AsmParser::ParseDirectiveAlign(bool IsPow2, unsigned ValueSize) {
/// ParseDirectiveSymbolAttribute
/// ::= { ".globl", ".weak", ... } [ identifier ( , identifier )* ]
bool AsmParser::ParseDirectiveSymbolAttribute(MCStreamer::SymbolAttr Attr) {
- if (Lexer.isNot(asmtok::EndOfStatement)) {
+ if (Lexer.isNot(AsmToken::EndOfStatement)) {
for (;;) {
- if (Lexer.isNot(asmtok::Identifier))
+ if (Lexer.isNot(AsmToken::Identifier))
return TokError("expected identifier in directive");
MCSymbol *Sym = Ctx.GetOrCreateSymbol(Lexer.getCurStrVal());
@@ -909,10 +909,10 @@ bool AsmParser::ParseDirectiveSymbolAttribute(MCStreamer::SymbolAttr Attr) {
Out.EmitSymbolAttribute(Sym, Attr);
- if (Lexer.is(asmtok::EndOfStatement))
+ if (Lexer.is(AsmToken::EndOfStatement))
break;
- if (Lexer.isNot(asmtok::Comma))
+ if (Lexer.isNot(AsmToken::Comma))
return TokError("unexpected token in directive");
Lexer.Lex();
}
@@ -925,7 +925,7 @@ bool AsmParser::ParseDirectiveSymbolAttribute(MCStreamer::SymbolAttr Attr) {
/// ParseDirectiveDarwinSymbolDesc
/// ::= .desc identifier , expression
bool AsmParser::ParseDirectiveDarwinSymbolDesc() {
- if (Lexer.isNot(asmtok::Identifier))
+ if (Lexer.isNot(AsmToken::Identifier))
return TokError("expected identifier in directive");
// handle the identifier as the key symbol.
@@ -933,7 +933,7 @@ bool AsmParser::ParseDirectiveDarwinSymbolDesc() {
MCSymbol *Sym = Ctx.GetOrCreateSymbol(Lexer.getCurStrVal());
Lexer.Lex();
- if (Lexer.isNot(asmtok::Comma))
+ if (Lexer.isNot(AsmToken::Comma))
return TokError("unexpected token in '.desc' directive");
Lexer.Lex();
@@ -942,7 +942,7 @@ bool AsmParser::ParseDirectiveDarwinSymbolDesc() {
if (ParseAbsoluteExpression(DescValue))
return true;
- if (Lexer.isNot(asmtok::EndOfStatement))
+ if (Lexer.isNot(AsmToken::EndOfStatement))
return TokError("unexpected token in '.desc' directive");
Lexer.Lex();
@@ -956,7 +956,7 @@ bool AsmParser::ParseDirectiveDarwinSymbolDesc() {
/// ParseDirectiveComm
/// ::= ( .comm | .lcomm ) identifier , size_expression [ , align_expression ]
bool AsmParser::ParseDirectiveComm(bool IsLocal) {
- if (Lexer.isNot(asmtok::Identifier))
+ if (Lexer.isNot(AsmToken::Identifier))
return TokError("expected identifier in directive");
// handle the identifier as the key symbol.
@@ -964,7 +964,7 @@ bool AsmParser::ParseDirectiveComm(bool IsLocal) {
MCSymbol *Sym = Ctx.GetOrCreateSymbol(Lexer.getCurStrVal());
Lexer.Lex();
- if (Lexer.isNot(asmtok::Comma))
+ if (Lexer.isNot(AsmToken::Comma))
return TokError("unexpected token in directive");
Lexer.Lex();
@@ -975,14 +975,14 @@ bool AsmParser::ParseDirectiveComm(bool IsLocal) {
int64_t Pow2Alignment = 0;
SMLoc Pow2AlignmentLoc;
- if (Lexer.is(asmtok::Comma)) {
+ if (Lexer.is(AsmToken::Comma)) {
Lexer.Lex();
Pow2AlignmentLoc = Lexer.getLoc();
if (ParseAbsoluteExpression(Pow2Alignment))
return true;
}
- if (Lexer.isNot(asmtok::EndOfStatement))
+ if (Lexer.isNot(AsmToken::EndOfStatement))
return TokError("unexpected token in '.comm' or '.lcomm' directive");
Lexer.Lex();
@@ -1014,17 +1014,17 @@ bool AsmParser::ParseDirectiveComm(bool IsLocal) {
/// ::= .zerofill segname , sectname [, identifier , size_expression [
/// , align_expression ]]
bool AsmParser::ParseDirectiveDarwinZerofill() {
- if (Lexer.isNot(asmtok::Identifier))
+ if (Lexer.isNot(AsmToken::Identifier))
return TokError("expected segment name after '.zerofill' directive");
std::string Section = Lexer.getCurStrVal();
Lexer.Lex();
- if (Lexer.isNot(asmtok::Comma))
+ if (Lexer.isNot(AsmToken::Comma))
return TokError("unexpected token in directive");
Section += ',';
Lexer.Lex();
- if (Lexer.isNot(asmtok::Identifier))
+ if (Lexer.isNot(AsmToken::Identifier))
return TokError("expected section name after comma in '.zerofill' "
"directive");
Section += Lexer.getCurStrVal().str();
@@ -1040,17 +1040,17 @@ bool AsmParser::ParseDirectiveDarwinZerofill() {
// If this is the end of the line all that was wanted was to create the
// the section but with no symbol.
- if (Lexer.is(asmtok::EndOfStatement)) {
+ if (Lexer.is(AsmToken::EndOfStatement)) {
// Create the zerofill section but no symbol
Out.EmitZerofill(Ctx.GetSection(Section.c_str()));
return false;
}
- if (Lexer.isNot(asmtok::Comma))
+ if (Lexer.isNot(AsmToken::Comma))
return TokError("unexpected token in directive");
Lexer.Lex();
- if (Lexer.isNot(asmtok::Identifier))
+ if (Lexer.isNot(AsmToken::Identifier))
return TokError("expected identifier in directive");
// handle the identifier as the key symbol.
@@ -1058,7 +1058,7 @@ bool AsmParser::ParseDirectiveDarwinZerofill() {
MCSymbol *Sym = Ctx.GetOrCreateSymbol(Lexer.getCurStrVal());
Lexer.Lex();
- if (Lexer.isNot(asmtok::Comma))
+ if (Lexer.isNot(AsmToken::Comma))
return TokError("unexpected token in directive");
Lexer.Lex();
@@ -1069,14 +1069,14 @@ bool AsmParser::ParseDirectiveDarwinZerofill() {
int64_t Pow2Alignment = 0;
SMLoc Pow2AlignmentLoc;
- if (Lexer.is(asmtok::Comma)) {
+ if (Lexer.is(AsmToken::Comma)) {
Lexer.Lex();
Pow2AlignmentLoc = Lexer.getLoc();
if (ParseAbsoluteExpression(Pow2Alignment))
return true;
}
- if (Lexer.isNot(asmtok::EndOfStatement))
+ if (Lexer.isNot(AsmToken::EndOfStatement))
return TokError("unexpected token in '.zerofill' directive");
Lexer.Lex();
@@ -1105,7 +1105,7 @@ bool AsmParser::ParseDirectiveDarwinZerofill() {
/// ParseDirectiveDarwinSubsectionsViaSymbols
/// ::= .subsections_via_symbols
bool AsmParser::ParseDirectiveDarwinSubsectionsViaSymbols() {
- if (Lexer.isNot(asmtok::EndOfStatement))
+ if (Lexer.isNot(AsmToken::EndOfStatement))
return TokError("unexpected token in '.subsections_via_symbols' directive");
Lexer.Lex();
@@ -1122,8 +1122,8 @@ bool AsmParser::ParseDirectiveAbort() {
SMLoc Loc = Lexer.getLoc();
StringRef Str = "";
- if (Lexer.isNot(asmtok::EndOfStatement)) {
- if (Lexer.isNot(asmtok::String))
+ if (Lexer.isNot(AsmToken::EndOfStatement)) {
+ if (Lexer.isNot(AsmToken::String))
return TokError("expected string in '.abort' directive");
Str = Lexer.getCurStrVal();
@@ -1131,7 +1131,7 @@ bool AsmParser::ParseDirectiveAbort() {
Lexer.Lex();
}
- if (Lexer.isNot(asmtok::EndOfStatement))
+ if (Lexer.isNot(AsmToken::EndOfStatement))
return TokError("unexpected token in '.abort' directive");
Lexer.Lex();
@@ -1148,7 +1148,7 @@ bool AsmParser::ParseDirectiveAbort() {
/// ParseDirectiveLsym
/// ::= .lsym identifier , expression
bool AsmParser::ParseDirectiveDarwinLsym() {
- if (Lexer.isNot(asmtok::Identifier))
+ if (Lexer.isNot(AsmToken::Identifier))
return TokError("expected identifier in directive");
// handle the identifier as the key symbol.
@@ -1156,7 +1156,7 @@ bool AsmParser::ParseDirectiveDarwinLsym() {
MCSymbol *Sym = Ctx.GetOrCreateSymbol(Lexer.getCurStrVal());
Lexer.Lex();
- if (Lexer.isNot(asmtok::Comma))
+ if (Lexer.isNot(AsmToken::Comma))
return TokError("unexpected token in '.lsym' directive");
Lexer.Lex();
@@ -1164,7 +1164,7 @@ bool AsmParser::ParseDirectiveDarwinLsym() {
if (ParseRelocatableExpression(Expr))
return true;
- if (Lexer.isNot(asmtok::EndOfStatement))
+ if (Lexer.isNot(AsmToken::EndOfStatement))
return TokError("unexpected token in '.lsym' directive");
Lexer.Lex();
@@ -1178,14 +1178,14 @@ bool AsmParser::ParseDirectiveDarwinLsym() {
/// ParseDirectiveInclude
/// ::= .include "filename"
bool AsmParser::ParseDirectiveInclude() {
- if (Lexer.isNot(asmtok::String))
+ if (Lexer.isNot(AsmToken::String))
return TokError("expected string in '.include' directive");
std::string Filename = Lexer.getCurStrVal();
SMLoc IncludeLoc = Lexer.getLoc();
Lexer.Lex();
- if (Lexer.isNot(asmtok::EndOfStatement))
+ if (Lexer.isNot(AsmToken::EndOfStatement))
return TokError("unexpected token in '.include' directive");
// Strip the quotes.
@@ -1206,14 +1206,14 @@ bool AsmParser::ParseDirectiveInclude() {
/// ParseDirectiveDarwinDumpOrLoad
/// ::= ( .dump | .load ) "filename"
bool AsmParser::ParseDirectiveDarwinDumpOrLoad(SMLoc IDLoc, bool IsDump) {
- if (Lexer.isNot(asmtok::String))
+ if (Lexer.isNot(AsmToken::String))
return TokError("expected string i