summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorDuncan P. N. Exon Smith <dexonsmith@apple.com>2015-02-13 01:22:59 +0000
committerDuncan P. N. Exon Smith <dexonsmith@apple.com>2015-02-13 01:22:59 +0000
commit54e2bc6c9b0047c3dbed74922d44e9e4e7b257cc (patch)
treef398462ba09d103b441e052d5d6b511b534ecb1e /llvm/lib
parentaece2dc3f574fb7390e3e23b21eef5387dd8e716 (diff)
downloadbcm5719-llvm-54e2bc6c9b0047c3dbed74922d44e9e4e7b257cc.tar.gz
bcm5719-llvm-54e2bc6c9b0047c3dbed74922d44e9e4e7b257cc.zip
AsmWriter/Bitcode: MDSubroutineType
llvm-svn: 229011
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/AsmParser/LLParser.cpp9
-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.cpp14
4 files changed, 39 insertions, 9 deletions
diff --git a/llvm/lib/AsmParser/LLParser.cpp b/llvm/lib/AsmParser/LLParser.cpp
index 33f395a1f5a..24442ef127b 100644
--- a/llvm/lib/AsmParser/LLParser.cpp
+++ b/llvm/lib/AsmParser/LLParser.cpp
@@ -3329,7 +3329,14 @@ bool LLParser::ParseMDCompositeType(MDNode *&Result, bool IsDistinct) {
}
bool LLParser::ParseMDSubroutineType(MDNode *&Result, bool IsDistinct) {
- return TokError("unimplemented parser");
+#define VISIT_MD_FIELDS(OPTIONAL, REQUIRED) \
+ OPTIONAL(flags, MDUnsignedField, (0, UINT32_MAX)); \
+ REQUIRED(types, MDField, );
+ PARSE_MD_FIELDS();
+#undef VISIT_MD_FIELDS
+
+ Result = GET_OR_DISTINCT(MDSubroutineType, (Context, flags.Val, types.Val));
+ return false;
}
/// ParseMDFileType:
diff --git a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
index 6c38e0d85b4..5fc758a93cc 100644
--- a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
+++ b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
@@ -1417,6 +1417,16 @@ std::error_code BitcodeReader::ParseMetadata() {
NextMDValueNo++);
break;
}
+ case bitc::METADATA_SUBROUTINE_TYPE: {
+ if (Record.size() != 3)
+ return Error("Invalid record");
+
+ MDValueList.AssignValue(
+ GET_OR_DISTINCT(MDSubroutineType, Record[0],
+ (Context, Record[1], getMDOrNull(Record[2]))),
+ NextMDValueNo++);
+ break;
+ }
case bitc::METADATA_FILE: {
if (Record.size() != 3)
return Error("Invalid record");
diff --git a/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp b/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
index 0c1b1e127b9..6f275ab7962 100644
--- a/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
+++ b/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
@@ -901,10 +901,17 @@ static void WriteMDCompositeType(const MDCompositeType *N,
Record.clear();
}
-static void WriteMDSubroutineType(const MDSubroutineType *,
- const ValueEnumerator &, BitstreamWriter &,
- SmallVectorImpl<uint64_t> &, unsigned) {
- llvm_unreachable("write not implemented");
+static void WriteMDSubroutineType(const MDSubroutineType *N,
+ const ValueEnumerator &VE,
+ BitstreamWriter &Stream,
+ SmallVectorImpl<uint64_t> &Record,
+ unsigned Abbrev) {
+ Record.push_back(N->isDistinct());
+ Record.push_back(N->getFlags());
+ Record.push_back(VE.getMetadataOrNullID(N->getTypeArray()));
+
+ Stream.EmitRecord(bitc::METADATA_SUBROUTINE_TYPE, Record, Abbrev);
+ Record.clear();
}
static void WriteMDFile(const MDFile *N, const ValueEnumerator &VE,
diff --git a/llvm/lib/IR/AsmWriter.cpp b/llvm/lib/IR/AsmWriter.cpp
index 0a585a097e2..b2205a19866 100644
--- a/llvm/lib/IR/AsmWriter.cpp
+++ b/llvm/lib/IR/AsmWriter.cpp
@@ -1484,10 +1484,16 @@ static void writeMDCompositeType(raw_ostream &Out, const MDCompositeType *N,
Out << ")";
}
-static void writeMDSubroutineType(raw_ostream &, const MDSubroutineType *,
- TypePrinting *, SlotTracker *,
- const Module *) {
- llvm_unreachable("write not implemented");
+static void writeMDSubroutineType(raw_ostream &Out, const MDSubroutineType *N,
+ TypePrinting *TypePrinter,
+ SlotTracker *Machine, const Module *Context) {
+ Out << "!MDSubroutineType(";
+ FieldSeparator FS;
+ if (N->getFlags())
+ Out << FS << "flags: " << N->getFlags();
+ Out << FS << "types: ";
+ writeMetadataAsOperand(Out, N->getTypeArray(), TypePrinter, Machine, Context);
+ Out << ")";
}
static void writeMDFile(raw_ostream &Out, const MDFile *N, TypePrinting *,
OpenPOWER on IntegriCloud