summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/AsmPrinter
diff options
context:
space:
mode:
authorDuncan P. N. Exon Smith <dexonsmith@apple.com>2015-08-02 20:46:49 +0000
committerDuncan P. N. Exon Smith <dexonsmith@apple.com>2015-08-02 20:46:49 +0000
commitc582114d4c67afae86186994e0e9607199a0cf9f (patch)
tree7637bd13118d38f26b786a15679fe335d7745255 /llvm/lib/CodeGen/AsmPrinter
parent55a868a0f6c57e909c16364fa25614cb9d560947 (diff)
downloadbcm5719-llvm-c582114d4c67afae86186994e0e9607199a0cf9f.tar.gz
bcm5719-llvm-c582114d4c67afae86186994e0e9607199a0cf9f.zip
AsmPrinter: Split out non-DIE printing from DIE::print(), NFC
Split out a helper `printValues()` for printing `DIEBlock` and `DIELoc`, instead of relying on `DIE::print()`. The shared code was actually fairly small there. No functionality change intended. llvm-svn: 243856
Diffstat (limited to 'llvm/lib/CodeGen/AsmPrinter')
-rw-r--r--llvm/lib/CodeGen/AsmPrinter/DIE.cpp52
1 files changed, 24 insertions, 28 deletions
diff --git a/llvm/lib/CodeGen/AsmPrinter/DIE.cpp b/llvm/lib/CodeGen/AsmPrinter/DIE.cpp
index bd68a87a6e9..41790bd58bc 100644
--- a/llvm/lib/CodeGen/AsmPrinter/DIE.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/DIE.cpp
@@ -145,35 +145,33 @@ DIEValue DIE::findAttribute(dwarf::Attribute Attribute) const {
}
#ifndef NDEBUG
-void DIE::print(raw_ostream &O, unsigned IndentCount) const {
+static void printValues(raw_ostream &O, const DIEValueList &Values,
+ StringRef Type, unsigned Size, unsigned IndentCount) {
+ O << Type << ": Size: " << Size << "\n";
+
+ unsigned I = 0;
const std::string Indent(IndentCount, ' ');
- bool isBlock = getTag() == 0;
-
- if (!isBlock) {
- O << Indent
- << "Die: "
- << format("0x%lx", (long)(intptr_t)this)
- << ", Offset: " << Offset
- << ", Size: " << Size << "\n";
-
- O << Indent
- << dwarf::TagString(getTag())
- << " "
- << dwarf::ChildrenString(hasChildren()) << "\n";
- } else {
- O << "Size: " << Size << "\n";
+ for (const auto &V : Values.values()) {
+ O << Indent;
+ O << "Blk[" << I++ << "]";
+ O << " " << dwarf::FormEncodingString(V.getForm()) << " ";
+ V.print(O);
+ O << "\n";
}
+}
+
+void DIE::print(raw_ostream &O, unsigned IndentCount) const {
+ const std::string Indent(IndentCount, ' ');
+ O << Indent << "Die: " << format("0x%lx", (long)(intptr_t) this)
+ << ", Offset: " << Offset << ", Size: " << Size << "\n";
+
+ O << Indent << dwarf::TagString(getTag()) << " "
+ << dwarf::ChildrenString(hasChildren()) << "\n";
IndentCount += 2;
- unsigned I = 0;
for (const auto &V : values()) {
O << Indent;
-
- if (!isBlock)
- O << dwarf::AttributeString(V.getAttribute());
- else
- O << "Blk[" << I++ << "]";
-
+ O << dwarf::AttributeString(V.getAttribute());
O << " " << dwarf::FormEncodingString(V.getForm()) << " ";
V.print(O);
O << "\n";
@@ -183,7 +181,7 @@ void DIE::print(raw_ostream &O, unsigned IndentCount) const {
for (const auto &Child : children())
Child.print(O, IndentCount + 4);
- if (!isBlock) O << "\n";
+ O << "\n";
}
void DIE::dump() {
@@ -547,8 +545,7 @@ unsigned DIELoc::SizeOf(const AsmPrinter *AP, dwarf::Form Form) const {
#ifndef NDEBUG
void DIELoc::print(raw_ostream &O) const {
- O << "ExprLoc: ";
- DIE::print(O, 5);
+ printValues(O, *this, "ExprLoc", Size, 5);
}
#endif
@@ -596,8 +593,7 @@ unsigned DIEBlock::SizeOf(const AsmPrinter *AP, dwarf::Form Form) const {
#ifndef NDEBUG
void DIEBlock::print(raw_ostream &O) const {
- O << "Blk: ";
- DIE::print(O, 5);
+ printValues(O, *this, "Blk", Size, 5);
}
#endif
OpenPOWER on IntegriCloud