Skip to content

Commit f2a8fb5

Browse files
committed
IRGen: add EnumPayload.dump() for debugging
1 parent 24837b4 commit f2a8fb5

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

lib/IRGen/EnumPayload.cpp

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -616,3 +616,28 @@ unsigned EnumPayload::getAllocSizeInBits(const llvm::DataLayout &DL) const {
616616
}
617617
return size;
618618
}
619+
620+
void EnumPayload::print(llvm::raw_ostream &OS) {
621+
if (StorageType) {
622+
OS << "storage-type: ";
623+
StorageType->print(OS);
624+
OS << '\n';
625+
}
626+
for (LazyValue pv : PayloadValues) {
627+
if (auto *v = pv.dyn_cast<llvm::Value*>()) {
628+
OS << "value: ";
629+
v->print(OS);
630+
OS << '\n';
631+
} else {
632+
auto *t = pv.get<llvm::Type*>();
633+
OS << "type: ";
634+
t->print(OS);
635+
OS << '\n';
636+
}
637+
}
638+
}
639+
640+
void EnumPayload::dump() {
641+
print(llvm::errs());
642+
}
643+

lib/IRGen/EnumPayload.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,10 @@ class EnumPayload {
174174
const SpareBitVector &spareBits,
175175
unsigned firstBitOffset,
176176
unsigned bitWidth) const;
177+
178+
void print(llvm::raw_ostream &OS);
179+
void dump();
180+
177181
private:
178182
/// Calculate the total number of bits this payload requires.
179183
/// This will always be a multiple of 8.

0 commit comments

Comments
 (0)