X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=lib%2FAsmParser%2FLLLexer.cpp;h=eeaadf68ea14ff7abb1bc3a3fa23a337886e6cf2;hb=01b35c25deee3d4cab339e620c12c721e627d609;hp=315048c748a8edd8f8c22bc0cbe6614f04f37c84;hpb=3e0c99a26f365bddb667124db40a5734e35c5a2d;p=oota-llvm.git diff --git a/lib/AsmParser/LLLexer.cpp b/lib/AsmParser/LLLexer.cpp index 315048c748a..eeaadf68ea1 100644 --- a/lib/AsmParser/LLLexer.cpp +++ b/lib/AsmParser/LLLexer.cpp @@ -15,18 +15,19 @@ #include "llvm/DerivedTypes.h" #include "llvm/Instruction.h" #include "llvm/LLVMContext.h" +#include "llvm/ADT/Twine.h" +#include "llvm/Assembly/Parser.h" #include "llvm/Support/ErrorHandling.h" #include "llvm/Support/MemoryBuffer.h" #include "llvm/Support/MathExtras.h" #include "llvm/Support/SourceMgr.h" #include "llvm/Support/raw_ostream.h" -#include "llvm/Assembly/Parser.h" #include #include #include using namespace llvm; -bool LLLexer::Error(LocTy ErrorLoc, const std::string &Msg) const { +bool LLLexer::Error(LocTy ErrorLoc, const Twine &Msg) const { ErrorInfo = SM.GetMessage(ErrorLoc, Msg, "error"); return true; } @@ -254,7 +255,7 @@ lltok::Kind LLLexer::LexToken() { case ';': SkipLineComment(); return LexToken(); - case '!': return LexMetadata(); + case '!': return LexExclaim(); case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': case '-': @@ -422,11 +423,11 @@ static bool JustWhitespaceNewLine(const char *&Ptr) { return false; } -/// LexMetadata: -/// !{...} -/// !42 +/// LexExclaim: /// !foo -lltok::Kind LLLexer::LexMetadata() { +/// ! +lltok::Kind LLLexer::LexExclaim() { + // Lex a metadata name as a MetadataVar. if (isalpha(CurPtr[0])) { ++CurPtr; while (isalnum(CurPtr[0]) || CurPtr[0] == '-' || CurPtr[0] == '$' || @@ -434,9 +435,9 @@ lltok::Kind LLLexer::LexMetadata() { ++CurPtr; StrVal.assign(TokStart+1, CurPtr); // Skip ! - return lltok::NamedMD; + return lltok::MetadataVar; } - return lltok::Metadata; + return lltok::exclaim; } /// LexIdentifier: Handle several related productions: @@ -492,6 +493,8 @@ lltok::Kind LLLexer::LexIdentifier() { KEYWORD(private); KEYWORD(linker_private); + KEYWORD(linker_private_weak); + KEYWORD(linker_private_weak_def_auto); KEYWORD(internal); KEYWORD(available_externally); KEYWORD(linkonce); @@ -529,17 +532,21 @@ lltok::Kind LLLexer::LexIdentifier() { KEYWORD(module); KEYWORD(asm); KEYWORD(sideeffect); + KEYWORD(alignstack); KEYWORD(gc); - KEYWORD(dbg); KEYWORD(ccc); KEYWORD(fastcc); KEYWORD(coldcc); KEYWORD(x86_stdcallcc); KEYWORD(x86_fastcallcc); + KEYWORD(x86_thiscallcc); KEYWORD(arm_apcscc); KEYWORD(arm_aapcscc); KEYWORD(arm_aapcs_vfpcc); + KEYWORD(msp430_intrcc); + KEYWORD(ptx_kernel); + KEYWORD(ptx_device); KEYWORD(cc); KEYWORD(c); @@ -576,6 +583,7 @@ lltok::Kind LLLexer::LexIdentifier() { KEYWORD(oge); KEYWORD(ord); KEYWORD(uno); KEYWORD(ueq); KEYWORD(une); KEYWORD(x); + KEYWORD(blockaddress); #undef KEYWORD // Keywords for types. @@ -590,6 +598,7 @@ lltok::Kind LLLexer::LexIdentifier() { TYPEKEYWORD("ppc_fp128", Type::getPPC_FP128Ty(Context)); TYPEKEYWORD("label", Type::getLabelTy(Context)); TYPEKEYWORD("metadata", Type::getMetadataTy(Context)); + TYPEKEYWORD("x86_mmx", Type::getX86_MMXTy(Context)); #undef TYPEKEYWORD // Handle special forms for autoupgrading. Drop these in LLVM 3.0. This is @@ -602,6 +611,14 @@ lltok::Kind LLLexer::LexIdentifier() { // Scan CurPtr ahead, seeing if there is just whitespace before the newline. if (JustWhitespaceNewLine(CurPtr)) return lltok::kw_zeroext; + } else if (Len == 6 && !memcmp(StartChar, "malloc", 6)) { + // FIXME: Remove in LLVM 3.0. + // Autoupgrade malloc instruction. + return lltok::kw_malloc; + } else if (Len == 4 && !memcmp(StartChar, "free", 4)) { + // FIXME: Remove in LLVM 3.0. + // Autoupgrade malloc instruction. + return lltok::kw_free; } // Keywords for instructions. @@ -637,13 +654,12 @@ lltok::Kind LLLexer::LexIdentifier() { INSTKEYWORD(ret, Ret); INSTKEYWORD(br, Br); INSTKEYWORD(switch, Switch); + INSTKEYWORD(indirectbr, IndirectBr); INSTKEYWORD(invoke, Invoke); INSTKEYWORD(unwind, Unwind); INSTKEYWORD(unreachable, Unreachable); - INSTKEYWORD(malloc, Malloc); INSTKEYWORD(alloca, Alloca); - INSTKEYWORD(free, Free); INSTKEYWORD(load, Load); INSTKEYWORD(store, Store); INSTKEYWORD(getelementptr, GetElementPtr);