diff options
| author | Duncan P. N. Exon Smith <dexonsmith@apple.com> | 2015-02-13 01:42:09 +0000 |
|---|---|---|
| committer | Duncan P. N. Exon Smith <dexonsmith@apple.com> | 2015-02-13 01:42:09 +0000 |
| commit | 0c5c0124acc84754fdf81bf5a98a807ee33c9bae (patch) | |
| tree | bba3cae61af33ef739b738ccfa01f20febddbad2 /llvm/lib/AsmParser/LLParser.cpp | |
| parent | 72fe2d0b7928257881bdaba31984ccfc127eed08 (diff) | |
| download | bcm5719-llvm-0c5c0124acc84754fdf81bf5a98a807ee33c9bae.tar.gz bcm5719-llvm-0c5c0124acc84754fdf81bf5a98a807ee33c9bae.zip | |
AsmWriter/Bitcode: MDExpression
llvm-svn: 229023
Diffstat (limited to 'llvm/lib/AsmParser/LLParser.cpp')
| -rw-r--r-- | llvm/lib/AsmParser/LLParser.cpp | 37 |
1 files changed, 36 insertions, 1 deletions
diff --git a/llvm/lib/AsmParser/LLParser.cpp b/llvm/lib/AsmParser/LLParser.cpp index 48dbaeeb76a..dc8367c5626 100644 --- a/llvm/lib/AsmParser/LLParser.cpp +++ b/llvm/lib/AsmParser/LLParser.cpp @@ -3599,9 +3599,44 @@ bool LLParser::ParseMDLocalVariable(MDNode *&Result, bool IsDistinct) { return false; } +/// ParseMDExpression: +/// ::= !MDExpression(0, 7, -1) bool LLParser::ParseMDExpression(MDNode *&Result, bool IsDistinct) { - return TokError("unimplemented parser"); + assert(Lex.getKind() == lltok::MetadataVar && "Expected metadata type name"); + Lex.Lex(); + + if (ParseToken(lltok::lparen, "expected '(' here")) + return true; + + SmallVector<uint64_t, 8> Elements; + if (Lex.getKind() != lltok::rparen) + do { + if (Lex.getKind() == lltok::DwarfOp) { + if (unsigned Op = dwarf::getOperationEncoding(Lex.getStrVal())) { + Lex.Lex(); + Elements.push_back(Op); + continue; + } + return TokError(Twine("invalid DWARF op '") + Lex.getStrVal() + "'"); + } + + if (Lex.getKind() != lltok::APSInt || Lex.getAPSIntVal().isSigned()) + return TokError("expected unsigned integer"); + + auto &U = Lex.getAPSIntVal(); + if (U.ugt(UINT64_MAX)) + return TokError("element too large, limit is " + Twine(UINT64_MAX)); + Elements.push_back(U.getZExtValue()); + Lex.Lex(); + } while (EatIfPresent(lltok::comma)); + + if (ParseToken(lltok::rparen, "expected ')' here")) + return true; + + Result = GET_OR_DISTINCT(MDExpression, (Context, Elements)); + return false; } + bool LLParser::ParseMDObjCProperty(MDNode *&Result, bool IsDistinct) { return TokError("unimplemented parser"); } |

