mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-04-07 01:38:26 +00:00
Bitcode: Simplify MDNode subclass dispatch, NFC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@226535 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
f638e95852
commit
022707e65a
@ -764,7 +764,7 @@ static void WriteValueAsMetadata(const ValueAsMetadata *MD,
|
||||
|
||||
static void WriteMDTuple(const MDTuple *N, const ValueEnumerator &VE,
|
||||
BitstreamWriter &Stream,
|
||||
SmallVectorImpl<uint64_t> &Record) {
|
||||
SmallVectorImpl<uint64_t> &Record, unsigned Abbrev) {
|
||||
for (unsigned i = 0, e = N->getNumOperands(); i != e; ++i) {
|
||||
Metadata *MD = N->getOperand(i);
|
||||
assert(!(MD && isa<LocalAsMetadata>(MD)) &&
|
||||
@ -773,7 +773,7 @@ static void WriteMDTuple(const MDTuple *N, const ValueEnumerator &VE,
|
||||
}
|
||||
Stream.EmitRecord(N->isDistinct() ? bitc::METADATA_DISTINCT_NODE
|
||||
: bitc::METADATA_NODE,
|
||||
Record);
|
||||
Record, Abbrev);
|
||||
Record.clear();
|
||||
}
|
||||
|
||||
@ -791,6 +791,12 @@ static void WriteMDLocation(const MDLocation *N, const ValueEnumerator &VE,
|
||||
Record.clear();
|
||||
}
|
||||
|
||||
static void WriteGenericDwarfNode(const GenericDwarfNode *,
|
||||
const ValueEnumerator &, BitstreamWriter &,
|
||||
SmallVectorImpl<uint64_t> &, unsigned) {
|
||||
llvm_unreachable("unimplemented");
|
||||
}
|
||||
|
||||
static void WriteModuleMetadata(const Module *M,
|
||||
const ValueEnumerator &VE,
|
||||
BitstreamWriter &Stream) {
|
||||
@ -810,7 +816,7 @@ static void WriteModuleMetadata(const Module *M,
|
||||
MDSAbbrev = Stream.EmitAbbrev(Abbv);
|
||||
}
|
||||
|
||||
unsigned LocAbbrev = 0;
|
||||
unsigned MDLocationAbbrev = 0;
|
||||
if (VE.hasMDLocation()) {
|
||||
// Abbrev for METADATA_LOCATION.
|
||||
//
|
||||
@ -823,7 +829,7 @@ static void WriteModuleMetadata(const Module *M,
|
||||
Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8));
|
||||
Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
|
||||
Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
|
||||
LocAbbrev = Stream.EmitAbbrev(Abbv);
|
||||
MDLocationAbbrev = Stream.EmitAbbrev(Abbv);
|
||||
}
|
||||
|
||||
unsigned NameAbbrev = 0;
|
||||
@ -836,15 +842,20 @@ static void WriteModuleMetadata(const Module *M,
|
||||
NameAbbrev = Stream.EmitAbbrev(Abbv);
|
||||
}
|
||||
|
||||
unsigned MDTupleAbbrev = 0;
|
||||
unsigned GenericDwarfNodeAbbrev = 0;
|
||||
SmallVector<uint64_t, 64> Record;
|
||||
for (const Metadata *MD : MDs) {
|
||||
if (const MDLocation *Loc = dyn_cast<MDLocation>(MD)) {
|
||||
WriteMDLocation(Loc, VE, Stream, Record, LocAbbrev);
|
||||
continue;
|
||||
}
|
||||
if (const MDNode *N = dyn_cast<MDNode>(MD)) {
|
||||
WriteMDTuple(cast<MDTuple>(N), VE, Stream, Record);
|
||||
continue;
|
||||
switch (N->getMetadataID()) {
|
||||
default:
|
||||
llvm_unreachable("Invalid MDNode subclass");
|
||||
#define HANDLE_MDNODE_LEAF(CLASS) \
|
||||
case Metadata::CLASS##Kind: \
|
||||
Write##CLASS(cast<CLASS>(N), VE, Stream, Record, CLASS##Abbrev); \
|
||||
continue;
|
||||
#include "llvm/IR/Metadata.def"
|
||||
}
|
||||
}
|
||||
if (const auto *MDC = dyn_cast<ConstantAsMetadata>(MD)) {
|
||||
WriteValueAsMetadata(MDC, VE, Stream, Record);
|
||||
|
Loading…
x
Reference in New Issue
Block a user