diff options
| author | Duncan P. N. Exon Smith <dexonsmith@apple.com> | 2015-02-13 01:29:28 +0000 |
|---|---|---|
| committer | Duncan P. N. Exon Smith <dexonsmith@apple.com> | 2015-02-13 01:29:28 +0000 |
| commit | a96d40999702c46894b6aad419e573a4bbc90673 (patch) | |
| tree | bf34989a887523bad13fa9f986b07d72d8c21b7c /llvm/lib | |
| parent | 890533e987c8ba71e09ea3cac19061d520dbbf23 (diff) | |
| download | bcm5719-llvm-a96d40999702c46894b6aad419e573a4bbc90673.tar.gz bcm5719-llvm-a96d40999702c46894b6aad419e573a4bbc90673.zip | |
AsmWriter/Bitcode: MDLexicalBlock
llvm-svn: 229016
Diffstat (limited to 'llvm/lib')
| -rw-r--r-- | llvm/lib/AsmParser/LLParser.cpp | 15 | ||||
| -rw-r--r-- | llvm/lib/Bitcode/Reader/BitcodeReader.cpp | 11 | ||||
| -rw-r--r-- | llvm/lib/Bitcode/Writer/BitcodeWriter.cpp | 18 | ||||
| -rw-r--r-- | llvm/lib/IR/AsmWriter.cpp | 21 |
4 files changed, 57 insertions, 8 deletions
diff --git a/llvm/lib/AsmParser/LLParser.cpp b/llvm/lib/AsmParser/LLParser.cpp index 445c7a405f7..e579b431d26 100644 --- a/llvm/lib/AsmParser/LLParser.cpp +++ b/llvm/lib/AsmParser/LLParser.cpp @@ -3466,9 +3466,22 @@ bool LLParser::ParseMDSubprogram(MDNode *&Result, bool IsDistinct) { return false; } +/// ParseMDLexicalBlock: +/// ::= !MDLexicalBlock(scope: !0, file: !2, line: 7, column: 9) bool LLParser::ParseMDLexicalBlock(MDNode *&Result, bool IsDistinct) { - return TokError("unimplemented parser"); +#define VISIT_MD_FIELDS(OPTIONAL, REQUIRED) \ + REQUIRED(scope, MDField, ); \ + OPTIONAL(file, MDField, ); \ + OPTIONAL(line, LineField, ); \ + OPTIONAL(column, ColumnField, ); + PARSE_MD_FIELDS(); +#undef VISIT_MD_FIELDS + + Result = GET_OR_DISTINCT( + MDLexicalBlock, (Context, scope.Val, file.Val, line.Val, column.Val)); + return false; } + bool LLParser::ParseMDLexicalBlockFile(MDNode *&Result, bool IsDistinct) { return TokError("unimplemented parser"); } diff --git a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp index 12996d19e0d..22dcd2a0812 100644 --- a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp +++ b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp @@ -1468,6 +1468,17 @@ std::error_code BitcodeReader::ParseMetadata() { NextMDValueNo++); break; } + case bitc::METADATA_LEXICAL_BLOCK: { + if (Record.size() != 5) + return Error("Invalid record"); + + MDValueList.AssignValue( + GET_OR_DISTINCT(MDLexicalBlock, Record[0], + (Context, getMDOrNull(Record[1]), + getMDOrNull(Record[2]), Record[3], Record[4])), + NextMDValueNo++); + break; + } case bitc::METADATA_STRING: { std::string String(Record.begin(), Record.end()); llvm::UpgradeMDStringConstant(String); diff --git a/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp b/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp index f0453fff122..21dc5349cdc 100644 --- a/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp +++ b/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp @@ -978,11 +978,21 @@ static void WriteMDSubprogram(const MDSubprogram *N, Record.clear(); } -static void WriteMDLexicalBlock(const MDLexicalBlock *, const ValueEnumerator &, - BitstreamWriter &, SmallVectorImpl<uint64_t> &, - unsigned) { - llvm_unreachable("write not implemented"); +static void WriteMDLexicalBlock(const MDLexicalBlock *N, + const ValueEnumerator &VE, + BitstreamWriter &Stream, + SmallVectorImpl<uint64_t> &Record, + unsigned Abbrev) { + Record.push_back(N->isDistinct()); + Record.push_back(VE.getMetadataOrNullID(N->getScope())); + Record.push_back(VE.getMetadataOrNullID(N->getFile())); + Record.push_back(N->getLine()); + Record.push_back(N->getColumn()); + + Stream.EmitRecord(bitc::METADATA_LEXICAL_BLOCK, Record, Abbrev); + Record.clear(); } + static void WriteMDLexicalBlockFile(const MDLexicalBlockFile *, const ValueEnumerator &, BitstreamWriter &, SmallVectorImpl<uint64_t> &, unsigned) { diff --git a/llvm/lib/IR/AsmWriter.cpp b/llvm/lib/IR/AsmWriter.cpp index bdcf51ba49f..7baa6edc950 100644 --- a/llvm/lib/IR/AsmWriter.cpp +++ b/llvm/lib/IR/AsmWriter.cpp @@ -1623,10 +1623,25 @@ static void writeMDSubprogram(raw_ostream &Out, const MDSubprogram *N, Out << ")"; } -static void writeMDLexicalBlock(raw_ostream &, const MDLexicalBlock *, - TypePrinting *, SlotTracker *, const Module *) { - llvm_unreachable("write not implemented"); +static void writeMDLexicalBlock(raw_ostream &Out, const MDLexicalBlock *N, + TypePrinting *TypePrinter, SlotTracker *Machine, + const Module *Context) { + Out << "!MDLexicalBlock("; + FieldSeparator FS; + Out << FS << "scope: "; + writeMetadataAsOperand(Out, N->getScope(), TypePrinter, Machine, Context); + if (N->getFile()) { + Out << FS << "file: "; + writeMetadataAsOperand(Out, N->getFile(), TypePrinter, Machine, + Context); + } + if (N->getLine()) + Out << FS << "line: " << N->getLine(); + if (N->getColumn()) + Out << FS << "column: " << N->getColumn(); + Out << ")"; } + static void writeMDLexicalBlockFile(raw_ostream &, const MDLexicalBlockFile *, TypePrinting *, SlotTracker *, const Module *) { |

