[llvm-commits] [llvm] r80929 - in /llvm/trunk: include/llvm/MC/MCAsmLexer.h lib/Target/X86/AsmParser/X86AsmParser.cpp tools/llvm-mc/AsmLexer.cpp tools/llvm-mc/AsmLexer.h tools/llvm-mc/llvm-mc.cpp
Kevin Enderby
enderby at apple.com
Thu Sep 3 10:15:07 PDT 2009
Author: enderby
Date: Thu Sep 3 12:15:07 2009
New Revision: 80929
URL: http://llvm.org/viewvc/llvm-project?rev=80929&view=rev
Log:
Removed the non-target independent AsmToken::Register enum constant
from MCAsmLexer.h in preparation of supporting other targets. Changed the
X86AsmParser code to reflect this by removing AsmLexer::LexPercent and looking
for AsmToken::Percent when parsing in places that used AsmToken::Register.
Then changed X86ATTAsmParser::ParseRegister to parse out registers as an
AsmToken::Percent followed by an AsmToken::Identifier.
Modified:
llvm/trunk/include/llvm/MC/MCAsmLexer.h
llvm/trunk/lib/Target/X86/AsmParser/X86AsmParser.cpp
llvm/trunk/tools/llvm-mc/AsmLexer.cpp
llvm/trunk/tools/llvm-mc/AsmLexer.h
llvm/trunk/tools/llvm-mc/llvm-mc.cpp
Modified: llvm/trunk/include/llvm/MC/MCAsmLexer.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCAsmLexer.h?rev=80929&r1=80928&r2=80929&view=diff
==============================================================================
--- llvm/trunk/include/llvm/MC/MCAsmLexer.h (original)
+++ llvm/trunk/include/llvm/MC/MCAsmLexer.h Thu Sep 3 12:15:07 2009
@@ -27,7 +27,6 @@
// String values.
Identifier,
- Register,
String,
// Integer values.
Modified: llvm/trunk/lib/Target/X86/AsmParser/X86AsmParser.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/AsmParser/X86AsmParser.cpp?rev=80929&r1=80928&r2=80929&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/AsmParser/X86AsmParser.cpp (original)
+++ llvm/trunk/lib/Target/X86/AsmParser/X86AsmParser.cpp Thu Sep 3 12:15:07 2009
@@ -230,20 +230,23 @@
bool X86ATTAsmParser::ParseRegister(X86Operand &Op) {
+ const AsmToken &TokPercent = getLexer().getTok();
+ assert(TokPercent.is(AsmToken::Percent) && "Invalid token kind!");
+ getLexer().Lex(); // Eat percent token.
+
const AsmToken &Tok = getLexer().getTok();
- assert(Tok.is(AsmToken::Register) && "Invalid token kind!");
+ assert(TokPercent.is(AsmToken::Identifier) && "Invalid token kind!");
// FIXME: Validate register for the current architecture; we have to do
// validation later, so maybe there is no need for this here.
unsigned RegNo;
- assert(Tok.getString().startswith("%") && "Invalid register name!");
- RegNo = MatchRegisterName(Tok.getString().substr(1));
+ RegNo = MatchRegisterName(Tok.getString());
if (RegNo == 0)
return Error(Tok.getLoc(), "invalid register name");
Op = X86Operand::CreateReg(RegNo);
- getLexer().Lex(); // Eat register token.
+ getLexer().Lex(); // Eat identifier token.
return false;
}
@@ -252,7 +255,7 @@
switch (getLexer().getKind()) {
default:
return ParseMemOperand(Op);
- case AsmToken::Register:
+ case AsmToken::Percent:
// FIXME: if a segment register, this could either be just the seg reg, or
// the start of a memory operand.
return ParseRegister(Op);
@@ -299,7 +302,7 @@
// so we have to eat the ( to see beyond it.
getLexer().Lex(); // Eat the '('.
- if (getLexer().is(AsmToken::Register) || getLexer().is(AsmToken::Comma)) {
+ if (getLexer().is(AsmToken::Percent) || getLexer().is(AsmToken::Comma)) {
// Nothing to do here, fall into the code below with the '(' part of the
// memory operand consumed.
} else {
@@ -327,7 +330,7 @@
// the rest of the memory operand.
unsigned BaseReg = 0, IndexReg = 0, Scale = 1;
- if (getLexer().is(AsmToken::Register)) {
+ if (getLexer().is(AsmToken::Percent)) {
if (ParseRegister(Op))
return true;
BaseReg = Op.getReg();
@@ -342,7 +345,7 @@
//
// Not that even though it would be completely consistent to support syntax
// like "1(%eax,,1)", the assembler doesn't.
- if (getLexer().is(AsmToken::Register)) {
+ if (getLexer().is(AsmToken::Percent)) {
if (ParseRegister(Op))
return true;
IndexReg = Op.getReg();
Modified: llvm/trunk/tools/llvm-mc/AsmLexer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-mc/AsmLexer.cpp?rev=80929&r1=80928&r2=80929&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-mc/AsmLexer.cpp (original)
+++ llvm/trunk/tools/llvm-mc/AsmLexer.cpp Thu Sep 3 12:15:07 2009
@@ -101,17 +101,6 @@
return AsmToken(AsmToken::Identifier, StringRef(TokStart, CurPtr - TokStart));
}
-/// LexPercent: Register: %[a-zA-Z0-9]+
-AsmToken AsmLexer::LexPercent() {
- if (!isalnum(*CurPtr))
- return AsmToken(AsmToken::Percent, StringRef(CurPtr, 1)); // Single %.
-
- while (isalnum(*CurPtr))
- ++CurPtr;
-
- return AsmToken(AsmToken::Register, StringRef(TokStart, CurPtr - TokStart));
-}
-
/// LexSlash: Slash: /
/// C-Style Comment: /* ... */
AsmToken AsmLexer::LexSlash() {
@@ -298,7 +287,7 @@
if (*CurPtr == '=')
return ++CurPtr, AsmToken(AsmToken::ExclaimEqual, StringRef(TokStart, 2));
return AsmToken(AsmToken::Exclaim, StringRef(TokStart, 1));
- case '%': return LexPercent();
+ case '%': return AsmToken(AsmToken::Percent, StringRef(TokStart, 1));
case '/': return LexSlash();
case '#': return LexLineComment();
case '"': return LexQuote();
Modified: llvm/trunk/tools/llvm-mc/AsmLexer.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-mc/AsmLexer.h?rev=80929&r1=80928&r2=80929&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-mc/AsmLexer.h (original)
+++ llvm/trunk/tools/llvm-mc/AsmLexer.h Thu Sep 3 12:15:07 2009
@@ -64,7 +64,6 @@
AsmToken ReturnError(const char *Loc, const std::string &Msg);
AsmToken LexIdentifier();
- AsmToken LexPercent();
AsmToken LexSlash();
AsmToken LexLineComment();
AsmToken LexDigit();
Modified: llvm/trunk/tools/llvm-mc/llvm-mc.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-mc/llvm-mc.cpp?rev=80929&r1=80928&r2=80929&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-mc/llvm-mc.cpp (original)
+++ llvm/trunk/tools/llvm-mc/llvm-mc.cpp Thu Sep 3 12:15:07 2009
@@ -120,9 +120,6 @@
case AsmToken::Identifier:
outs() << "identifier: " << Lexer.getTok().getString() << '\n';
break;
- case AsmToken::Register:
- outs() << "register: " << Lexer.getTok().getString() << '\n';
- break;
case AsmToken::String:
outs() << "string: " << Lexer.getTok().getString() << '\n';
break;
More information about the llvm-commits
mailing list