mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-21 02:24:22 +00:00
AsmWriter/Bitcode: MDEnumerator
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@229004 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -148,7 +148,8 @@ namespace bitc {
|
|||||||
METADATA_NAMED_NODE = 10, // NAMED_NODE: [n x mdnodes]
|
METADATA_NAMED_NODE = 10, // NAMED_NODE: [n x mdnodes]
|
||||||
METADATA_ATTACHMENT = 11, // [m x [value, [n x [id, mdnode]]]
|
METADATA_ATTACHMENT = 11, // [m x [value, [n x [id, mdnode]]]
|
||||||
METADATA_GENERIC_DEBUG = 12, // [distinct, tag, vers, header, n x md num]
|
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
|
// The constants block (CONSTANTS_BLOCK_ID) describes emission for each
|
||||||
|
@ -309,6 +309,8 @@ public:
|
|||||||
int64_t getValue() const { return Value; }
|
int64_t getValue() const { return Value; }
|
||||||
StringRef getName() const { return getStringOperand(0); }
|
StringRef getName() const { return getStringOperand(0); }
|
||||||
|
|
||||||
|
MDString *getRawName() const { return getOperandAs<MDString>(0); }
|
||||||
|
|
||||||
static bool classof(const Metadata *MD) {
|
static bool classof(const Metadata *MD) {
|
||||||
return MD->getMetadataID() == MDEnumeratorKind;
|
return MD->getMetadataID() == MDEnumeratorKind;
|
||||||
}
|
}
|
||||||
|
@ -3181,9 +3181,19 @@ bool LLParser::ParseMDSubrange(MDNode *&Result, bool IsDistinct) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// ParseMDEnumerator:
|
||||||
|
/// ::= !MDEnumerator(value: 30, name: "SomeKind")
|
||||||
bool LLParser::ParseMDEnumerator(MDNode *&Result, bool IsDistinct) {
|
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) {
|
bool LLParser::ParseMDBasicType(MDNode *&Result, bool IsDistinct) {
|
||||||
return TokError("unimplemented parser");
|
return TokError("unimplemented parser");
|
||||||
}
|
}
|
||||||
|
@ -1361,6 +1361,16 @@ std::error_code BitcodeReader::ParseMetadata() {
|
|||||||
NextMDValueNo++);
|
NextMDValueNo++);
|
||||||
break;
|
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: {
|
case bitc::METADATA_STRING: {
|
||||||
std::string String(Record.begin(), Record.end());
|
std::string String(Record.begin(), Record.end());
|
||||||
llvm::UpgradeMDStringConstant(String);
|
llvm::UpgradeMDStringConstant(String);
|
||||||
|
@ -826,11 +826,18 @@ static void WriteMDSubrange(const MDSubrange *N, const ValueEnumerator &,
|
|||||||
Record.clear();
|
Record.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void WriteMDEnumerator(const MDEnumerator *, const ValueEnumerator &,
|
static void WriteMDEnumerator(const MDEnumerator *N, const ValueEnumerator &VE,
|
||||||
BitstreamWriter &, SmallVectorImpl<uint64_t> &,
|
BitstreamWriter &Stream,
|
||||||
unsigned) {
|
SmallVectorImpl<uint64_t> &Record,
|
||||||
llvm_unreachable("write not implemented");
|
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 &,
|
static void WriteMDBasicType(const MDBasicType *, const ValueEnumerator &,
|
||||||
BitstreamWriter &, SmallVectorImpl<uint64_t> &,
|
BitstreamWriter &, SmallVectorImpl<uint64_t> &,
|
||||||
unsigned) {
|
unsigned) {
|
||||||
|
@ -1357,10 +1357,15 @@ static void writeMDSubrange(raw_ostream &Out, const MDSubrange *N,
|
|||||||
Out << ")";
|
Out << ")";
|
||||||
}
|
}
|
||||||
|
|
||||||
static void writeMDEnumerator(raw_ostream &, const MDEnumerator *,
|
static void writeMDEnumerator(raw_ostream &Out, const MDEnumerator *N,
|
||||||
TypePrinting *, SlotTracker *, const Module *) {
|
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 *,
|
static void writeMDBasicType(raw_ostream &, const MDBasicType *, TypePrinting *,
|
||||||
SlotTracker *, const Module *) {
|
SlotTracker *, const Module *) {
|
||||||
llvm_unreachable("write not implemented");
|
llvm_unreachable("write not implemented");
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
; RUN: llvm-as < %s | llvm-dis | llvm-as | llvm-dis | FileCheck %s
|
; RUN: llvm-as < %s | llvm-dis | llvm-as | llvm-dis | FileCheck %s
|
||||||
; RUN: verify-uselistorder %s
|
; RUN: verify-uselistorder %s
|
||||||
|
|
||||||
; CHECK: !named = !{!0, !0, !1, !2}
|
; CHECK: !named = !{!0, !0, !1, !2, !3, !4, !5}
|
||||||
!named = !{!0, !1, !2, !3}
|
!named = !{!0, !1, !2, !3, !4, !5, !6}
|
||||||
|
|
||||||
; CHECK: !0 = !MDSubrange(count: 3)
|
; CHECK: !0 = !MDSubrange(count: 3)
|
||||||
; CHECK-NEXT: !1 = !MDSubrange(count: 3, lowerBound: 4)
|
; CHECK-NEXT: !1 = !MDSubrange(count: 3, lowerBound: 4)
|
||||||
@ -12,3 +12,10 @@
|
|||||||
|
|
||||||
!2 = !MDSubrange(count: 3, lowerBound: 4)
|
!2 = !MDSubrange(count: 3, lowerBound: 4)
|
||||||
!3 = !MDSubrange(count: 3, lowerBound: -5)
|
!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: "")
|
||||||
|
4
test/Assembler/invalid-mdenumerator-missing-name.ll
Normal file
4
test/Assembler/invalid-mdenumerator-missing-name.ll
Normal file
@ -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)
|
4
test/Assembler/invalid-mdenumerator-missing-value.ll
Normal file
4
test/Assembler/invalid-mdenumerator-missing-value.ll
Normal file
@ -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")
|
Reference in New Issue
Block a user