more cleanups

llvm-svn: 106724
This commit is contained in:
Chris Lattner 2010-06-24 07:18:14 +00:00
parent 056fd06c5f
commit c4e84309c4
1 changed files with 15 additions and 21 deletions

View File

@ -33,13 +33,11 @@ class X86AsmLexer : public TargetAsmLexer {
} }
const AsmToken &lexDefinite() { const AsmToken &lexDefinite() {
if(tentativeIsValid) { if (tentativeIsValid) {
tentativeIsValid = false; tentativeIsValid = false;
return tentativeToken; return tentativeToken;
} }
else { return getLexer()->Lex();
return getLexer()->Lex();
}
} }
AsmToken LexTokenATT(); AsmToken LexTokenATT();
@ -72,18 +70,19 @@ public:
static unsigned MatchRegisterName(StringRef Name); static unsigned MatchRegisterName(StringRef Name);
AsmToken X86AsmLexer::LexTokenATT() { AsmToken X86AsmLexer::LexTokenATT() {
const AsmToken lexedToken = lexDefinite(); AsmToken lexedToken = lexDefinite();
switch (lexedToken.getKind()) { switch (lexedToken.getKind()) {
default: default:
return AsmToken(lexedToken); return lexedToken;
case AsmToken::Error: case AsmToken::Error:
SetError(Lexer->getErrLoc(), Lexer->getErr()); SetError(Lexer->getErrLoc(), Lexer->getErr());
return AsmToken(lexedToken); return lexedToken;
case AsmToken::Percent: {
case AsmToken::Percent: {
const AsmToken &nextToken = lexTentative(); const AsmToken &nextToken = lexTentative();
if (nextToken.getKind() != AsmToken::Identifier) if (nextToken.getKind() != AsmToken::Identifier)
return AsmToken(lexedToken); return lexedToken;
if (unsigned regID = MatchRegisterName(nextToken.getString())) { if (unsigned regID = MatchRegisterName(nextToken.getString())) {
@ -93,12 +92,11 @@ AsmToken X86AsmLexer::LexTokenATT() {
lexedToken.getString().size() + lexedToken.getString().size() +
nextToken.getString().size()); nextToken.getString().size());
return AsmToken(AsmToken::Register, return AsmToken(AsmToken::Register, regStr,
regStr,
static_cast<int64_t>(regID)); static_cast<int64_t>(regID));
} }
return AsmToken(lexedToken); return lexedToken;
} }
} }
} }
@ -108,26 +106,22 @@ AsmToken X86AsmLexer::LexTokenIntel() {
switch(lexedToken.getKind()) { switch(lexedToken.getKind()) {
default: default:
return AsmToken(lexedToken); return lexedToken;
case AsmToken::Error: case AsmToken::Error:
SetError(Lexer->getErrLoc(), Lexer->getErr()); SetError(Lexer->getErrLoc(), Lexer->getErr());
return AsmToken(lexedToken); return lexedToken;
case AsmToken::Identifier: case AsmToken::Identifier: {
{
std::string upperCase = lexedToken.getString().str(); std::string upperCase = lexedToken.getString().str();
std::string lowerCase = LowercaseString(upperCase); std::string lowerCase = LowercaseString(upperCase);
StringRef lowerRef(lowerCase); StringRef lowerRef(lowerCase);
unsigned regID = MatchRegisterName(lowerRef); unsigned regID = MatchRegisterName(lowerRef);
if (regID) { if (regID)
return AsmToken(AsmToken::Register, return AsmToken(AsmToken::Register,
lexedToken.getString(), lexedToken.getString(),
static_cast<int64_t>(regID)); static_cast<int64_t>(regID));
} return lexedToken;
else {
return AsmToken(lexedToken);
}
} }
} }
} }