summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorDuncan P. N. Exon Smith <dexonsmith@apple.com>2015-02-13 01:19:14 +0000
committerDuncan P. N. Exon Smith <dexonsmith@apple.com>2015-02-13 01:19:14 +0000
commitf14b9c7cc16f24357f2c7db95e84015f79be8b38 (patch)
tree5f8cd93291e6a88a92d3b2e005a471f146eaa2c2 /llvm/lib
parentcd6636c3bf05e86396b097ce1623ab9993d5adcb (diff)
downloadbcm5719-llvm-f14b9c7cc16f24357f2c7db95e84015f79be8b38.tar.gz
bcm5719-llvm-f14b9c7cc16f24357f2c7db95e84015f79be8b38.zip
AsmWriter/Bitcode: MDFile
llvm-svn: 229007
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/AsmParser/LLParser.cpp13
-rw-r--r--llvm/lib/Bitcode/Reader/BitcodeReader.cpp10
-rw-r--r--llvm/lib/Bitcode/Writer/BitcodeWriter.cpp15
-rw-r--r--llvm/lib/IR/AsmWriter.cpp10
4 files changed, 41 insertions, 7 deletions
diff --git a/llvm/lib/AsmParser/LLParser.cpp b/llvm/lib/AsmParser/LLParser.cpp
index 992ad1092be..c041a96cfeb 100644
--- a/llvm/lib/AsmParser/LLParser.cpp
+++ b/llvm/lib/AsmParser/LLParser.cpp
@@ -3242,9 +3242,20 @@ bool LLParser::ParseMDCompositeType(MDNode *&Result, bool IsDistinct) {
bool LLParser::ParseMDSubroutineType(MDNode *&Result, bool IsDistinct) {
return TokError("unimplemented parser");
}
+
+/// ParseMDFileType:
+/// ::= !MDFileType(filename: "path/to/file", directory: "/path/to/dir")
bool LLParser::ParseMDFile(MDNode *&Result, bool IsDistinct) {
- return TokError("unimplemented parser");
+#define VISIT_MD_FIELDS(OPTIONAL, REQUIRED) \
+ REQUIRED(filename, MDStringField, ); \
+ REQUIRED(directory, MDStringField, );
+ PARSE_MD_FIELDS();
+#undef VISIT_MD_FIELDS
+
+ Result = GET_OR_DISTINCT(MDFile, (Context, filename.Val, directory.Val));
+ return false;
}
+
bool LLParser::ParseMDCompileUnit(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 2d0364945f7..2220c1dad87 100644
--- a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
+++ b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
@@ -1382,6 +1382,16 @@ std::error_code BitcodeReader::ParseMetadata() {
NextMDValueNo++);
break;
}
+ case bitc::METADATA_FILE: {
+ if (Record.size() != 3)
+ return Error("Invalid record");
+
+ MDValueList.AssignValue(
+ GET_OR_DISTINCT(MDFile, Record[0], (Context, getMDString(Record[1]),
+ getMDString(Record[2]))),
+ 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 47c414eea8a..9460ff0a78b 100644
--- a/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
+++ b/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
@@ -868,11 +868,18 @@ static void WriteMDSubroutineType(const MDSubroutineType *,
SmallVectorImpl<uint64_t> &, unsigned) {
llvm_unreachable("write not implemented");
}
-static void WriteMDFile(const MDFile *, const ValueEnumerator &,
- BitstreamWriter &, SmallVectorImpl<uint64_t> &,
- unsigned) {
- llvm_unreachable("write not implemented");
+
+static void WriteMDFile(const MDFile *N, const ValueEnumerator &VE,
+ BitstreamWriter &Stream,
+ SmallVectorImpl<uint64_t> &Record, unsigned Abbrev) {
+ Record.push_back(N->isDistinct());
+ Record.push_back(VE.getMetadataOrNullID(N->getRawFilename()));
+ Record.push_back(VE.getMetadataOrNullID(N->getRawDirectory()));
+
+ Stream.EmitRecord(bitc::METADATA_FILE, Record, Abbrev);
+ Record.clear();
}
+
static void WriteMDCompileUnit(const MDCompileUnit *, const ValueEnumerator &,
BitstreamWriter &, SmallVectorImpl<uint64_t> &,
unsigned) {
diff --git a/llvm/lib/IR/AsmWriter.cpp b/llvm/lib/IR/AsmWriter.cpp
index c2d25140d7a..826794a2c04 100644
--- a/llvm/lib/IR/AsmWriter.cpp
+++ b/llvm/lib/IR/AsmWriter.cpp
@@ -1401,10 +1401,16 @@ static void writeMDSubroutineType(raw_ostream &, const MDSubroutineType *,
const Module *) {
llvm_unreachable("write not implemented");
}
-static void writeMDFile(raw_ostream &, const MDFile *, TypePrinting *,
+
+static void writeMDFile(raw_ostream &Out, const MDFile *N, TypePrinting *,
SlotTracker *, const Module *) {
- llvm_unreachable("write not implemented");
+ Out << "!MDFile(";
+ FieldSeparator FS;
+ Out << FS << "filename: \"" << N->getFilename() << "\"";
+ Out << FS << "directory: \"" << N->getDirectory() << "\"";
+ Out << ")";
}
+
static void writeMDCompileUnit(raw_ostream &, const MDCompileUnit *,
TypePrinting *, SlotTracker *, const Module *) {
llvm_unreachable("write not implemented");
OpenPOWER on IntegriCloud