summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/AsmParser/LLParser.cpp14
-rw-r--r--llvm/lib/Bitcode/Reader/BitcodeReader.cpp11
-rw-r--r--llvm/lib/Bitcode/Writer/BitcodeWriter.cpp17
-rw-r--r--llvm/lib/IR/AsmWriter.cpp21
4 files changed, 54 insertions, 9 deletions
diff --git a/llvm/lib/AsmParser/LLParser.cpp b/llvm/lib/AsmParser/LLParser.cpp
index e579b431d26..90a680818f9 100644
--- a/llvm/lib/AsmParser/LLParser.cpp
+++ b/llvm/lib/AsmParser/LLParser.cpp
@@ -3482,9 +3482,21 @@ bool LLParser::ParseMDLexicalBlock(MDNode *&Result, bool IsDistinct) {
return false;
}
+/// ParseMDLexicalBlockFile:
+/// ::= !MDLexicalBlockFile(scope: !0, file: !2, discriminator: 9)
bool LLParser::ParseMDLexicalBlockFile(MDNode *&Result, bool IsDistinct) {
- return TokError("unimplemented parser");
+#define VISIT_MD_FIELDS(OPTIONAL, REQUIRED) \
+ REQUIRED(scope, MDField, ); \
+ OPTIONAL(file, MDField, ); \
+ REQUIRED(discriminator, MDUnsignedField, (0, UINT32_MAX));
+ PARSE_MD_FIELDS();
+#undef VISIT_MD_FIELDS
+
+ Result = GET_OR_DISTINCT(MDLexicalBlockFile,
+ (Context, scope.Val, file.Val, discriminator.Val));
+ return false;
}
+
bool LLParser::ParseMDNamespace(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 22dcd2a0812..fa139d74fba 100644
--- a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
+++ b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
@@ -1479,6 +1479,17 @@ std::error_code BitcodeReader::ParseMetadata() {
NextMDValueNo++);
break;
}
+ case bitc::METADATA_LEXICAL_BLOCK_FILE: {
+ if (Record.size() != 4)
+ return Error("Invalid record");
+
+ MDValueList.AssignValue(
+ GET_OR_DISTINCT(MDLexicalBlockFile, Record[0],
+ (Context, getMDOrNull(Record[1]),
+ getMDOrNull(Record[2]), Record[3])),
+ 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 21dc5349cdc..4643a7236a4 100644
--- a/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
+++ b/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
@@ -993,11 +993,20 @@ static void WriteMDLexicalBlock(const MDLexicalBlock *N,
Record.clear();
}
-static void WriteMDLexicalBlockFile(const MDLexicalBlockFile *,
- const ValueEnumerator &, BitstreamWriter &,
- SmallVectorImpl<uint64_t> &, unsigned) {
- llvm_unreachable("write not implemented");
+static void WriteMDLexicalBlockFile(const MDLexicalBlockFile *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->getDiscriminator());
+
+ Stream.EmitRecord(bitc::METADATA_LEXICAL_BLOCK_FILE, Record, Abbrev);
+ Record.clear();
}
+
static void WriteMDNamespace(const MDNamespace *, const ValueEnumerator &,
BitstreamWriter &, SmallVectorImpl<uint64_t> &,
unsigned) {
diff --git a/llvm/lib/IR/AsmWriter.cpp b/llvm/lib/IR/AsmWriter.cpp
index 7baa6edc950..560f71f7338 100644
--- a/llvm/lib/IR/AsmWriter.cpp
+++ b/llvm/lib/IR/AsmWriter.cpp
@@ -1642,11 +1642,24 @@ static void writeMDLexicalBlock(raw_ostream &Out, const MDLexicalBlock *N,
Out << ")";
}
-static void writeMDLexicalBlockFile(raw_ostream &, const MDLexicalBlockFile *,
- TypePrinting *, SlotTracker *,
- const Module *) {
- llvm_unreachable("write not implemented");
+static void writeMDLexicalBlockFile(raw_ostream &Out,
+ const MDLexicalBlockFile *N,
+ TypePrinting *TypePrinter,
+ SlotTracker *Machine,
+ const Module *Context) {
+ Out << "!MDLexicalBlockFile(";
+ 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);
+ }
+ Out << FS << "discriminator: " << N->getDiscriminator();
+ Out << ")";
}
+
static void writeMDNamespace(raw_ostream &, const MDNamespace *, TypePrinting *,
SlotTracker *, const Module *) {
llvm_unreachable("write not implemented");
OpenPOWER on IntegriCloud