[PATCH] Adding altmacro support in integrated assembler.
Rafael Ávila de Espíndola
rafael.espindola at gmail.com
Mon Jun 22 08:02:40 PDT 2015
================
Comment at: include/llvm/MC/MCParser/AsmLexer.h:58
@@ -57,2 +57,3 @@
private:
+ bool isAtString(const char* stringLine);
int getNextChar();
----------------
Variable name starts with uppercase.
================
Comment at: include/llvm/MC/MCParser/AsmLexer.h:69
@@ -67,1 +68,3 @@
+ AsmToken LexQuote(char FirstChar = '"');
+ AsmToken LexStringHandel(char FirstChar = '"');
AsmToken LexFloatLiteral();
----------------
Function name starts with a lowercase. You can just update the existing ones in a cleanup patch first if you want.
================
Comment at: lib/MC/MCParser/AsmLexer.cpp:367
@@ -364,1 +366,3 @@
+ if (AltMacroMode)
+ return LexStringHandel('\'');
int CurChar = getNextChar();
----------------
Handel?
================
Comment at: lib/MC/MCParser/AsmLexer.cpp:419
@@ +418,3 @@
+ if (FirstChar == '"')
+ return ReturnError(TokStart, "unterminated string constant - missing '\"' at the end");
+ else if (FirstChar == '\'')
----------------
Using LastChar you can have a single ReturnError, no?
================
Comment at: lib/MC/MCParser/AsmLexer.cpp:501
@@ -478,121 +500,3 @@
-AsmToken AsmLexer::LexToken() {
- TokStart = CurPtr;
- // This always consumes at least one character.
- int CurChar = getNextChar();
-
- if (isAtStartOfComment(TokStart)) {
- // If this comment starts with a '#', then return the Hash token and let
- // the assembler parser see if it can be parsed as a cpp line filename
- // comment. We do this only if we are at the start of a line.
- if (CurChar == '#' && isAtStartOfLine)
- return AsmToken(AsmToken::Hash, StringRef(TokStart, 1));
- isAtStartOfLine = true;
- return LexLineComment();
- }
- if (isAtStatementSeparator(TokStart)) {
- CurPtr += strlen(MAI.getSeparatorString()) - 1;
- return AsmToken(AsmToken::EndOfStatement,
- StringRef(TokStart, strlen(MAI.getSeparatorString())));
- }
-
- // If we're missing a newline at EOF, make sure we still get an
- // EndOfStatement token before the Eof token.
- if (CurChar == EOF && !isAtStartOfLine) {
- isAtStartOfLine = true;
- return AsmToken(AsmToken::EndOfStatement, StringRef(TokStart, 1));
- }
-
- isAtStartOfLine = false;
- switch (CurChar) {
- default:
- // Handle identifier: [a-zA-Z_.][a-zA-Z0-9_$.@]*
- if (isalpha(CurChar) || CurChar == '_' || CurChar == '.')
- return LexIdentifier();
-
- // Unknown character, emit an error.
- return ReturnError(TokStart, "invalid character in input");
- case EOF: return AsmToken(AsmToken::Eof, StringRef(TokStart, 0));
- case 0:
- case ' ':
- case '\t':
- if (SkipSpace) {
- // Ignore whitespace.
- return LexToken();
- } else {
- int len = 1;
- while (*CurPtr==' ' || *CurPtr=='\t') {
- CurPtr++;
- len++;
- }
- return AsmToken(AsmToken::Space, StringRef(TokStart, len));
- }
- case '\n': // FALL THROUGH.
- case '\r':
- isAtStartOfLine = true;
- 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::LBrac, StringRef(TokStart, 1));
- case ']': return AsmToken(AsmToken::RBrac, StringRef(TokStart, 1));
- case '{': return AsmToken(AsmToken::LCurly, StringRef(TokStart, 1));
- case '}': return AsmToken(AsmToken::RCurly, 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 '@': return AsmToken(AsmToken::At, StringRef(TokStart, 1));
- case '\\': return AsmToken(AsmToken::BackSlash, StringRef(TokStart, 1));
- case '=':
- if (*CurPtr == '=')
- return ++CurPtr, AsmToken(AsmToken::EqualEqual, StringRef(TokStart, 2));
- return AsmToken(AsmToken::Equal, StringRef(TokStart, 1));
- case '|':
- if (*CurPtr == '|')
- 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(AsmToken::AmpAmp, StringRef(TokStart, 2));
- return AsmToken(AsmToken::Amp, StringRef(TokStart, 1));
- case '!':
- if (*CurPtr == '=')
- return ++CurPtr, AsmToken(AsmToken::ExclaimEqual, StringRef(TokStart, 2));
- return AsmToken(AsmToken::Exclaim, StringRef(TokStart, 1));
- case '%': return AsmToken(AsmToken::Percent, StringRef(TokStart, 1));
- case '/': return LexSlash();
- case '#': return AsmToken(AsmToken::Hash, StringRef(TokStart, 1));
- case '\'': return LexSingleQuote();
- case '"': return LexQuote();
- case '0': case '1': case '2': case '3': case '4':
- case '5': case '6': case '7': case '8': case '9':
- return LexDigit();
- case '<':
- switch (*CurPtr) {
- case '<': return ++CurPtr, AsmToken(AsmToken::LessLess,
- StringRef(TokStart, 2));
- case '=': return ++CurPtr, AsmToken(AsmToken::LessEqual,
- StringRef(TokStart, 2));
- case '>': return ++CurPtr, AsmToken(AsmToken::LessGreater,
- StringRef(TokStart, 2));
- default: return AsmToken(AsmToken::Less, StringRef(TokStart, 1));
- }
- case '>':
- switch (*CurPtr) {
- case '>': return ++CurPtr, AsmToken(AsmToken::GreaterGreater,
- StringRef(TokStart, 2));
- case '=': return ++CurPtr, AsmToken(AsmToken::GreaterEqual,
- StringRef(TokStart, 2));
- default: return AsmToken(AsmToken::Greater, StringRef(TokStart, 1));
- }
-
- // TODO: Quoted identifiers (objc methods etc)
- // local labels: [0-9][:]
- // Forward/backward labels: [0-9][fb]
- // Integers, fp constants, character constants.
- }
-}
+/// isAtString check if the next token is <string> type or arithmetic.
+/// string that begin with char '<' must to end with char '>' otherwise it is no a string.
----------------
Don't repeat name in comment.
This description should probably be at the declaration.
================
Comment at: lib/MC/MCParser/AsmLexer.cpp:585
@@ +584,3 @@
+ case '@': return AsmToken(AsmToken::At, StringRef(TokStart, 1));
+ case '\\':return AsmToken(AsmToken::BackSlash, StringRef(TokStart, 1));
+ case '=':
----------------
Please commit the format only changes first and rebase.
================
Comment at: lib/MC/MCParser/AsmParser.cpp:1242
@@ -1231,1 +1241,3 @@
+ }
+ else if (parseIdentifier(IDVal)) {
if (!TheCondState.Ignore)
----------------
The old formatting looks like the more common one.
http://reviews.llvm.org/D10591
EMAIL PREFERENCES
http://reviews.llvm.org/settings/panel/emailpreferences/
More information about the llvm-commits
mailing list