mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-02-12 03:32:10 +00:00
AsmWriter/Bitcode: MDImportedEntity
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@229025 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
3bfa8d00ae
commit
6a390dc584
@ -165,7 +165,8 @@ namespace bitc {
|
|||||||
METADATA_GLOBAL_VAR = 27, // [distinct, ...]
|
METADATA_GLOBAL_VAR = 27, // [distinct, ...]
|
||||||
METADATA_LOCAL_VAR = 28, // [distinct, ...]
|
METADATA_LOCAL_VAR = 28, // [distinct, ...]
|
||||||
METADATA_EXPRESSION = 29, // [distinct, n x element]
|
METADATA_EXPRESSION = 29, // [distinct, n x element]
|
||||||
METADATA_OBJC_PROPERTY = 30 // [distinct, name, file, line, ...]
|
METADATA_OBJC_PROPERTY = 30, // [distinct, name, file, line, ...]
|
||||||
|
METADATA_IMPORTED_ENTITY=31 // [distinct, tag, scope, entity, line, name]
|
||||||
};
|
};
|
||||||
|
|
||||||
// The constants block (CONSTANTS_BLOCK_ID) describes emission for each
|
// The constants block (CONSTANTS_BLOCK_ID) describes emission for each
|
||||||
|
@ -1626,6 +1626,8 @@ public:
|
|||||||
Metadata *getEntity() const { return getOperand(1); }
|
Metadata *getEntity() const { return getOperand(1); }
|
||||||
StringRef getName() const { return getStringOperand(2); }
|
StringRef getName() const { return getStringOperand(2); }
|
||||||
|
|
||||||
|
MDString *getRawName() const { return getOperandAs<MDString>(2); }
|
||||||
|
|
||||||
static bool classof(const Metadata *MD) {
|
static bool classof(const Metadata *MD) {
|
||||||
return MD->getMetadataID() == MDImportedEntityKind;
|
return MD->getMetadataID() == MDImportedEntityKind;
|
||||||
}
|
}
|
||||||
|
@ -3658,9 +3658,24 @@ bool LLParser::ParseMDObjCProperty(MDNode *&Result, bool IsDistinct) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// ParseMDImportedEntity:
|
||||||
|
/// ::= !MDImportedEntity(tag: DW_TAG_imported_module, scope: !0, entity: !1,
|
||||||
|
/// line: 7, name: "foo")
|
||||||
bool LLParser::ParseMDImportedEntity(MDNode *&Result, bool IsDistinct) {
|
bool LLParser::ParseMDImportedEntity(MDNode *&Result, bool IsDistinct) {
|
||||||
return TokError("unimplemented parser");
|
#define VISIT_MD_FIELDS(OPTIONAL, REQUIRED) \
|
||||||
|
REQUIRED(tag, DwarfTagField, ); \
|
||||||
|
REQUIRED(scope, MDField, ); \
|
||||||
|
OPTIONAL(entity, MDField, ); \
|
||||||
|
OPTIONAL(line, LineField, ); \
|
||||||
|
OPTIONAL(name, MDStringField, );
|
||||||
|
PARSE_MD_FIELDS();
|
||||||
|
#undef VISIT_MD_FIELDS
|
||||||
|
|
||||||
|
Result = GET_OR_DISTINCT(MDImportedEntity, (Context, tag.Val, scope.Val,
|
||||||
|
entity.Val, line.Val, name.Val));
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
#undef PARSE_MD_FIELD
|
#undef PARSE_MD_FIELD
|
||||||
#undef NOP_FIELD
|
#undef NOP_FIELD
|
||||||
#undef REQUIRE_FIELD
|
#undef REQUIRE_FIELD
|
||||||
|
@ -1575,6 +1575,18 @@ std::error_code BitcodeReader::ParseMetadata() {
|
|||||||
NextMDValueNo++);
|
NextMDValueNo++);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case bitc::METADATA_IMPORTED_ENTITY: {
|
||||||
|
if (Record.size() != 6)
|
||||||
|
return Error("Invalid record");
|
||||||
|
|
||||||
|
MDValueList.AssignValue(
|
||||||
|
GET_OR_DISTINCT(MDImportedEntity, Record[0],
|
||||||
|
(Context, Record[1], getMDOrNull(Record[2]),
|
||||||
|
getMDOrNull(Record[3]), Record[4],
|
||||||
|
getMDString(Record[5]))),
|
||||||
|
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);
|
||||||
|
@ -1124,10 +1124,20 @@ static void WriteMDObjCProperty(const MDObjCProperty *N,
|
|||||||
Record.clear();
|
Record.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void WriteMDImportedEntity(const MDImportedEntity *,
|
static void WriteMDImportedEntity(const MDImportedEntity *N,
|
||||||
const ValueEnumerator &, BitstreamWriter &,
|
const ValueEnumerator &VE,
|
||||||
SmallVectorImpl<uint64_t> &, unsigned) {
|
BitstreamWriter &Stream,
|
||||||
llvm_unreachable("write not implemented");
|
SmallVectorImpl<uint64_t> &Record,
|
||||||
|
unsigned Abbrev) {
|
||||||
|
Record.push_back(N->isDistinct());
|
||||||
|
Record.push_back(N->getTag());
|
||||||
|
Record.push_back(VE.getMetadataOrNullID(N->getScope()));
|
||||||
|
Record.push_back(VE.getMetadataOrNullID(N->getEntity()));
|
||||||
|
Record.push_back(N->getLine());
|
||||||
|
Record.push_back(VE.getMetadataOrNullID(N->getRawName()));
|
||||||
|
|
||||||
|
Stream.EmitRecord(bitc::METADATA_IMPORTED_ENTITY, Record, Abbrev);
|
||||||
|
Record.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void WriteModuleMetadata(const Module *M,
|
static void WriteModuleMetadata(const Module *M,
|
||||||
|
@ -1827,12 +1827,25 @@ static void writeMDObjCProperty(raw_ostream &Out, const MDObjCProperty *N,
|
|||||||
Out << ")";
|
Out << ")";
|
||||||
}
|
}
|
||||||
|
|
||||||
static void writeMDImportedEntity(raw_ostream &, const MDImportedEntity *,
|
static void writeMDImportedEntity(raw_ostream &Out, const MDImportedEntity *N,
|
||||||
TypePrinting *, SlotTracker *,
|
TypePrinting *TypePrinter,
|
||||||
const Module *) {
|
SlotTracker *Machine, const Module *Context) {
|
||||||
llvm_unreachable("write not implemented");
|
Out << "!MDImportedEntity(";
|
||||||
|
FieldSeparator FS;
|
||||||
|
writeTag(Out, FS, N);
|
||||||
|
Out << FS << "scope: ";
|
||||||
|
writeMetadataAsOperand(Out, N->getScope(), TypePrinter, Machine, Context);
|
||||||
|
if (N->getEntity()) {
|
||||||
|
Out << FS << "entity: ";
|
||||||
|
writeMetadataAsOperand(Out, N->getEntity(), TypePrinter, Machine, Context);
|
||||||
|
}
|
||||||
|
if (N->getLine())
|
||||||
|
Out << FS << "line: " << N->getLine();
|
||||||
|
Out << FS << "name: \"" << N->getName() << "\"";
|
||||||
|
Out << ")";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void WriteMDNodeBodyInternal(raw_ostream &Out, const MDNode *Node,
|
static void WriteMDNodeBodyInternal(raw_ostream &Out, const MDNode *Node,
|
||||||
TypePrinting *TypePrinter,
|
TypePrinting *TypePrinter,
|
||||||
SlotTracker *Machine,
|
SlotTracker *Machine,
|
||||||
|
@ -0,0 +1,4 @@
|
|||||||
|
; RUN: not llvm-as < %s -disable-output 2>&1 | FileCheck %s
|
||||||
|
|
||||||
|
; CHECK: [[@LINE+1]]:51: error: missing required field 'scope'
|
||||||
|
!3 = !MDImportedEntity(tag: DW_TAG_imported_module)
|
4
test/Assembler/invalid-mdimportedentity-missing-tag.ll
Normal file
4
test/Assembler/invalid-mdimportedentity-missing-tag.ll
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
; RUN: not llvm-as < %s -disable-output 2>&1 | FileCheck %s
|
||||||
|
|
||||||
|
; CHECK: [[@LINE+1]]:33: error: missing required field 'tag'
|
||||||
|
!3 = !MDImportedEntity(scope: !0)
|
20
test/Assembler/mdimportedentity.ll
Normal file
20
test/Assembler/mdimportedentity.ll
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
; RUN: llvm-as < %s | llvm-dis | llvm-as | llvm-dis | FileCheck %s
|
||||||
|
; RUN: verify-uselistorder %s
|
||||||
|
|
||||||
|
; CHECK: !named = !{!0, !1, !2, !3, !3}
|
||||||
|
!named = !{!0, !1, !2, !3, !4}
|
||||||
|
|
||||||
|
; CHECK: !0 = distinct !{}
|
||||||
|
; CHECK-NEXT: !1 = distinct !{}
|
||||||
|
!0 = distinct !{}
|
||||||
|
!1 = distinct !{}
|
||||||
|
|
||||||
|
; CHECK-NEXT: !2 = !MDImportedEntity(tag: DW_TAG_imported_module, scope: !0, entity: !1, line: 7, name: "foo")
|
||||||
|
!2 = !MDImportedEntity(tag: DW_TAG_imported_module, scope: !0, entity: !1,
|
||||||
|
line: 7, name: "foo")
|
||||||
|
|
||||||
|
; CHECK-NEXT: !3 = !MDImportedEntity(tag: DW_TAG_imported_module, scope: !0, name: "")
|
||||||
|
!3 = !MDImportedEntity(tag: DW_TAG_imported_module, scope: !0)
|
||||||
|
!4 = !MDImportedEntity(tag: DW_TAG_imported_module, scope: !0, entity: null,
|
||||||
|
line: 0, name: "")
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user