forked from OSchip/llvm-project
parent
c7363f1147
commit
8775476419
|
@ -148,7 +148,8 @@ namespace bitc {
|
|||
METADATA_NAMED_NODE = 10, // NAMED_NODE: [n x mdnodes]
|
||||
METADATA_ATTACHMENT = 11, // [m x [value, [n x [id, mdnode]]]
|
||||
METADATA_GENERIC_DEBUG = 12, // [distinct, tag, vers, header, n x md num]
|
||||
METADATA_SUBRANGE = 13 // [distinct, count, lo]
|
||||
METADATA_SUBRANGE = 13, // [distinct, count, lo]
|
||||
METADATA_ENUMERATOR = 14 // [distinct, value, name?]
|
||||
};
|
||||
|
||||
// The constants block (CONSTANTS_BLOCK_ID) describes emission for each
|
||||
|
|
|
@ -309,6 +309,8 @@ public:
|
|||
int64_t getValue() const { return Value; }
|
||||
StringRef getName() const { return getStringOperand(0); }
|
||||
|
||||
MDString *getRawName() const { return getOperandAs<MDString>(0); }
|
||||
|
||||
static bool classof(const Metadata *MD) {
|
||||
return MD->getMetadataID() == MDEnumeratorKind;
|
||||
}
|
||||
|
|
|
@ -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");
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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");
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
; RUN: llvm-as < %s | llvm-dis | llvm-as | llvm-dis | FileCheck %s
|
||||
; RUN: verify-uselistorder %s
|
||||
|
||||
; CHECK: !named = !{!0, !0, !1, !2}
|
||||
!named = !{!0, !1, !2, !3}
|
||||
; CHECK: !named = !{!0, !0, !1, !2, !3, !4, !5}
|
||||
!named = !{!0, !1, !2, !3, !4, !5, !6}
|
||||
|
||||
; CHECK: !0 = !MDSubrange(count: 3)
|
||||
; CHECK-NEXT: !1 = !MDSubrange(count: 3, lowerBound: 4)
|
||||
|
@ -12,3 +12,10 @@
|
|||
|
||||
!2 = !MDSubrange(count: 3, lowerBound: 4)
|
||||
!3 = !MDSubrange(count: 3, lowerBound: -5)
|
||||
|
||||
; CHECK-NEXT: !3 = !MDEnumerator(value: 7, name: "seven")
|
||||
; CHECK-NEXT: !4 = !MDEnumerator(value: -8, name: "negeight")
|
||||
; CHECK-NEXT: !5 = !MDEnumerator(value: 0, name: "")
|
||||
!4 = !MDEnumerator(value: 7, name: "seven")
|
||||
!5 = !MDEnumerator(value: -8, name: "negeight")
|
||||
!6 = !MDEnumerator(value: 0, name: "")
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
; RUN: not llvm-as < %s -disable-output 2>&1 | FileCheck %s
|
||||
|
||||
; CHECK: [[@LINE+1]]:28: error: missing required field 'name'
|
||||
!0 = !MDEnumerator(value: 7)
|
|
@ -0,0 +1,4 @@
|
|||
; RUN: not llvm-as < %s -disable-output 2>&1 | FileCheck %s
|
||||
|
||||
; CHECK: [[@LINE+1]]:32: error: missing required field 'value'
|
||||
!0 = !MDEnumerator(name: "name")
|
Loading…
Reference in New Issue