diff options
author | Teresa Johnson <tejohnson@google.com> | 2018-05-26 02:34:13 +0000 |
---|---|---|
committer | Teresa Johnson <tejohnson@google.com> | 2018-05-26 02:34:13 +0000 |
commit | 08d5b4ef0d0839761e3b7546efcd3ee0454742ea (patch) | |
tree | 1962452dfea56ccff172d7612ec1a8c982de27e2 /llvm/lib/AsmParser/LLLexer.cpp | |
parent | ffebfe10c1cfc2eae92ddd0dc1b212595ac47864 (diff) | |
download | bcm5719-llvm-08d5b4ef0d0839761e3b7546efcd3ee0454742ea.tar.gz bcm5719-llvm-08d5b4ef0d0839761e3b7546efcd3ee0454742ea.zip |
[ThinLTO] Print module summary index to assembly
Summary:
Implements AsmWriter support for printing the module summary index to
assembly with the format discussed in the RFC "LLVM Assembly format for
ThinLTO Summary".
Implements just enough of the parsing support to recognize and ignore
the summary entries. As agreed in the RFC thread, this will be the
behavior when assembling the IR. A follow on change will implement
parsing/assembling of the summary entries for use by tools that
currently build the summary index from bitcode.
Reviewers: dexonsmith, pcc
Subscribers: inglorion, eraman, steven_wu, dblaikie, llvm-commits
Differential Revision: https://reviews.llvm.org/D46699
llvm-svn: 333335
Diffstat (limited to 'llvm/lib/AsmParser/LLLexer.cpp')
-rw-r--r-- | llvm/lib/AsmParser/LLLexer.cpp | 50 |
1 files changed, 27 insertions, 23 deletions
diff --git a/llvm/lib/AsmParser/LLLexer.cpp b/llvm/lib/AsmParser/LLLexer.cpp index 54c4c595c34..640b825e485 100644 --- a/llvm/lib/AsmParser/LLLexer.cpp +++ b/llvm/lib/AsmParser/LLLexer.cpp @@ -219,6 +219,8 @@ lltok::Kind LLLexer::LexToken() { SkipLineComment(); continue; case '!': return LexExclaim(); + case '^': + return LexCaret(); case '#': return LexHash(); case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': @@ -328,6 +330,22 @@ bool LLLexer::ReadVarName() { return false; } +// Lex an ID: [0-9]+. On success, the ID is stored in UIntVal and Token is +// returned, otherwise the Error token is returned. +lltok::Kind LLLexer::LexUIntID(lltok::Kind Token) { + if (!isdigit(static_cast<unsigned char>(CurPtr[0]))) + return lltok::Error; + + for (++CurPtr; isdigit(static_cast<unsigned char>(CurPtr[0])); ++CurPtr) + /*empty*/; + + uint64_t Val = atoull(TokStart + 1, CurPtr); + if ((unsigned)Val != Val) + Error("invalid value number (too large)!"); + UIntVal = unsigned(Val); + return Token; +} + lltok::Kind LLLexer::LexVar(lltok::Kind Var, lltok::Kind VarID) { // Handle StringConstant: \"[^\"]*\" if (CurPtr[0] == '"') { @@ -357,17 +375,7 @@ lltok::Kind LLLexer::LexVar(lltok::Kind Var, lltok::Kind VarID) { return Var; // Handle VarID: [0-9]+ - if (isdigit(static_cast<unsigned char>(CurPtr[0]))) { - for (++CurPtr; isdigit(static_cast<unsigned char>(CurPtr[0])); ++CurPtr) - /*empty*/; - - uint64_t Val = atoull(TokStart+1, CurPtr); - if ((unsigned)Val != Val) - Error("invalid value number (too large)!"); - UIntVal = unsigned(Val); - return VarID; - } - return lltok::Error; + return LexUIntID(VarID); } /// Lex all tokens that start with a % character. @@ -420,22 +428,18 @@ lltok::Kind LLLexer::LexExclaim() { return lltok::exclaim; } +/// Lex all tokens that start with a ^ character. +/// SummaryID ::= ^[0-9]+ +lltok::Kind LLLexer::LexCaret() { + // Handle SummaryID: ^[0-9]+ + return LexUIntID(lltok::SummaryID); +} + /// Lex all tokens that start with a # character. /// AttrGrpID ::= #[0-9]+ lltok::Kind LLLexer::LexHash() { // Handle AttrGrpID: #[0-9]+ - if (isdigit(static_cast<unsigned char>(CurPtr[0]))) { - for (++CurPtr; isdigit(static_cast<unsigned char>(CurPtr[0])); ++CurPtr) - /*empty*/; - - uint64_t Val = atoull(TokStart+1, CurPtr); - if ((unsigned)Val != Val) - Error("invalid value number (too large)!"); - UIntVal = unsigned(Val); - return lltok::AttrGrpID; - } - - return lltok::Error; + return LexUIntID(lltok::AttrGrpID); } /// Lex a label, integer type, keyword, or hexadecimal integer constant. |