X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=lib%2FAsmParser%2FLLLexer.cpp;h=857fa1ef626f01d9e4437b2b6fcf49e1a1b5e379;hb=bea4626f93c830e31f82cc947df28fdae583cd09;hp=315048c748a8edd8f8c22bc0cbe6614f04f37c84;hpb=3e0c99a26f365bddb667124db40a5734e35c5a2d;p=oota-llvm.git diff --git a/lib/AsmParser/LLLexer.cpp b/lib/AsmParser/LLLexer.cpp index 315048c748a..857fa1ef626 100644 --- a/lib/AsmParser/LLLexer.cpp +++ b/lib/AsmParser/LLLexer.cpp @@ -15,18 +15,20 @@ #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 #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 +256,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 +424,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 +436,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 +494,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); @@ -505,6 +509,7 @@ lltok::Kind LLLexer::LexIdentifier() { KEYWORD(default); KEYWORD(hidden); KEYWORD(protected); + KEYWORD(unnamed_addr); KEYWORD(extern_weak); KEYWORD(external); KEYWORD(thread_local); @@ -529,17 +534,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); @@ -566,6 +575,7 @@ lltok::Kind LLLexer::LexIdentifier() { KEYWORD(noredzone); KEYWORD(noimplicitfloat); KEYWORD(naked); + KEYWORD(hotpatch); KEYWORD(type); KEYWORD(opaque); @@ -576,6 +586,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 +601,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 +614,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 +657,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); @@ -665,7 +684,7 @@ lltok::Kind LLLexer::LexIdentifier() { APInt Tmp(bits, StringRef(TokStart+3, len), 16); uint32_t activeBits = Tmp.getActiveBits(); if (activeBits > 0 && activeBits < bits) - Tmp.trunc(activeBits); + Tmp = Tmp.trunc(activeBits); APSIntVal = APSInt(Tmp, TokStart[0] == 'u'); return lltok::APSInt; } @@ -792,12 +811,12 @@ lltok::Kind LLLexer::LexDigitOrNegative() { if (TokStart[0] == '-') { uint32_t minBits = Tmp.getMinSignedBits(); if (minBits > 0 && minBits < numBits) - Tmp.trunc(minBits); + Tmp = Tmp.trunc(minBits); APSIntVal = APSInt(Tmp, false); } else { uint32_t activeBits = Tmp.getActiveBits(); if (activeBits > 0 && activeBits < numBits) - Tmp.trunc(activeBits); + Tmp = Tmp.trunc(activeBits); APSIntVal = APSInt(Tmp, true); } return lltok::APSInt; @@ -816,7 +835,7 @@ lltok::Kind LLLexer::LexDigitOrNegative() { } } - APFloatVal = APFloat(atof(TokStart)); + APFloatVal = APFloat(std::atof(TokStart)); return lltok::APFloat; } @@ -850,6 +869,6 @@ lltok::Kind LLLexer::LexPositive() { } } - APFloatVal = APFloat(atof(TokStart)); + APFloatVal = APFloat(std::atof(TokStart)); return lltok::APFloat; }