From 7dcef4c47578befe40d488c953e3f5b328667300 Mon Sep 17 00:00:00 2001 From: Sean Callanan Date: Tue, 26 Jan 2010 01:00:10 +0000 Subject: [PATCH] Added the implementation of the Intel-specific TargetAsmLexer. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@94482 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Target/X86/AsmParser/X86AsmLexer.cpp | 28 +++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/lib/Target/X86/AsmParser/X86AsmLexer.cpp b/lib/Target/X86/AsmParser/X86AsmLexer.cpp index f35cb10db3d..e350515f3aa 100644 --- a/lib/Target/X86/AsmParser/X86AsmLexer.cpp +++ b/lib/Target/X86/AsmParser/X86AsmLexer.cpp @@ -8,6 +8,7 @@ //===----------------------------------------------------------------------===// #include "llvm/ADT/SmallVector.h" +#include "llvm/ADT/StringExtras.h" #include "llvm/Target/TargetAsmLexer.h" #include "llvm/Target/TargetRegistry.h" #include "llvm/MC/MCAsmInfo.h" @@ -113,7 +114,32 @@ AsmToken X86AsmLexer::LexTokenATT() { } AsmToken X86AsmLexer::LexTokenIntel() { - return AsmToken(AsmToken::Error, "", 0); + const AsmToken &lexedToken = lexDefinite(); + + switch(lexedToken.getKind()) { + default: + return AsmToken(lexedToken); + case AsmToken::Error: + SetError(Lexer->getErrLoc(), Lexer->getErr()); + return AsmToken(lexedToken); + case AsmToken::Identifier: + { + std::string upperCase = lexedToken.getString().str(); + std::string lowerCase = LowercaseString(upperCase); + StringRef lowerRef(lowerCase); + + unsigned regID = MatchRegisterName(lowerRef); + + if (regID) { + return AsmToken(AsmToken::Register, + lexedToken.getString(), + static_cast(regID)); + } + else { + return AsmToken(lexedToken); + } + } + } } extern "C" void LLVMInitializeX86AsmLexer() {