summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/AsmParser/LLParser.cpp12
-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.cpp9
4 files changed, 39 insertions, 7 deletions
diff --git a/llvm/lib/AsmParser/LLParser.cpp b/llvm/lib/AsmParser/LLParser.cpp
index 735cf494cb2..191b6f99557 100644
--- a/llvm/lib/AsmParser/LLParser.cpp
+++ b/llvm/lib/AsmParser/LLParser.cpp
@@ -3181,9 +3181,19 @@ bool LLParser::ParseMDSubrange(MDNode *&Result, bool IsDistinct) {
return false;
}
+/// ParseMDEnumerator:
+/// ::= !MDEnumerator(value: 30, name: "SomeKind")
bool LLParser::ParseMDEnumerator(MDNode *&Result, bool IsDistinct) {
- return TokError("unimplemented parser");
+#define VISIT_MD_FIELDS(OPTIONAL, REQUIRED) \
+ REQUIRED(value, MDSignedField, ); \
+ REQUIRED(name, MDStringField, );
+ PARSE_MD_FIELDS();
+#undef VISIT_MD_FIELDS
+
+ Result = GET_OR_DISTINCT(MDEnumerator, (Context, value.Val, name.Val));
+ return false;
}
+
bool LLParser::ParseMDBasicType(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 f7815810401..f7f0db27285 100644
--- a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
+++ b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
@@ -1361,6 +1361,16 @@ std::error_code BitcodeReader::ParseMetadata() {
NextMDValueNo++);
break;
}
+ case bitc::METADATA_ENUMERATOR: {
+ if (Record.size() != 3)
+ return Error("Invalid record");
+
+ MDValueList.AssignValue(GET_OR_DISTINCT(MDEnumerator, Record[0],
+ (Context, unrotateSign(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 3d1e82d8f8c..dfbfc9c0bea 100644
--- a/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
+++ b/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
@@ -826,11 +826,18 @@ static void WriteMDSubrange(const MDSubrange *N, const ValueEnumerator &,
Record.clear();
}
-static void WriteMDEnumerator(const MDEnumerator *, const ValueEnumerator &,
- BitstreamWriter &, SmallVectorImpl<uint64_t> &,
- unsigned) {
- llvm_unreachable("write not implemented");
+static void WriteMDEnumerator(const MDEnumerator *N, const ValueEnumerator &VE,
+ BitstreamWriter &Stream,
+ SmallVectorImpl<uint64_t> &Record,
+ unsigned Abbrev) {
+ Record.push_back(N->isDistinct());
+ Record.push_back(rotateSign(N->getValue()));
+ Record.push_back(VE.getMetadataOrNullID(N->getRawName()));
+
+ Stream.EmitRecord(bitc::METADATA_ENUMERATOR, Record, Abbrev);
+ Record.clear();
}
+
static void WriteMDBasicType(const MDBasicType *, const ValueEnumerator &,
BitstreamWriter &, SmallVectorImpl<uint64_t> &,
unsigned) {
diff --git a/llvm/lib/IR/AsmWriter.cpp b/llvm/lib/IR/AsmWriter.cpp
index aeed2af7376..b728b22df99 100644
--- a/llvm/lib/IR/AsmWriter.cpp
+++ b/llvm/lib/IR/AsmWriter.cpp
@@ -1357,10 +1357,15 @@ static void writeMDSubrange(raw_ostream &Out, const MDSubrange *N,
Out << ")";
}
-static void writeMDEnumerator(raw_ostream &, const MDEnumerator *,
+static void writeMDEnumerator(raw_ostream &Out, const MDEnumerator *N,
TypePrinting *, SlotTracker *, const Module *) {
- llvm_unreachable("write not implemented");
+ Out << "!MDEnumerator(";
+ FieldSeparator FS;
+ Out << FS << "value: " << N->getValue();
+ Out << FS << "name: \"" << N->getName() << "\"";
+ Out << ")";
}
+
static void writeMDBasicType(raw_ostream &, const MDBasicType *, TypePrinting *,
SlotTracker *, const Module *) {
llvm_unreachable("write not implemented");
OpenPOWER on IntegriCloud