From 245581b1aca7c4af512772fcef4bde5fb1ad7e84 Mon Sep 17 00:00:00 2001 From: Lang Hames Date: Tue, 20 Jul 2010 09:13:29 +0000 Subject: Added support for turning HTML indentation on and off (indentation off by default). Reduces output file size ~20% on my test cases. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@108822 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/RenderMachineFunction.cpp | 185 +++++++++++++++++++--------------- 1 file changed, 105 insertions(+), 80 deletions(-) (limited to 'lib/CodeGen/RenderMachineFunction.cpp') diff --git a/lib/CodeGen/RenderMachineFunction.cpp b/lib/CodeGen/RenderMachineFunction.cpp index 2095e2dbe9..a5d8129301 100644 --- a/lib/CodeGen/RenderMachineFunction.cpp +++ b/lib/CodeGen/RenderMachineFunction.cpp @@ -66,6 +66,12 @@ useFancyVerticals("rmf-fancy-verts", cl::desc("Use SVG for vertical text."), cl::init(true), cl::Hidden); +static cl::opt +prettyHTML("rmf-pretty-html", + cl::desc("Pretty print HTML. For debugging the renderer only.."), + cl::init(false), cl::Hidden); + + namespace llvm { bool MFRenderingOptions::renderingOptionsProcessed; @@ -493,6 +499,25 @@ namespace llvm { // ---------- MachineFunctionRenderer implementation ---------- + template + void RenderMachineFunction::Spacer::print(OStream &os) const { + if (!prettyHTML) + return; + for (unsigned i = 0; i < ns; ++i) { + os << " "; + } + } + + RenderMachineFunction::Spacer RenderMachineFunction::s(unsigned ns) const { + return Spacer(ns); + } + + template + OStream& operator<<(OStream &os, const RenderMachineFunction::Spacer &s) { + s.print(os); + return os; + } + template std::string RenderMachineFunction::escapeChars(Iterator sBegin, Iterator sEnd) const { std::string r; @@ -558,22 +583,23 @@ namespace llvm { } template - void RenderMachineFunction::renderVertical(const std::string &indent, + void RenderMachineFunction::renderVertical(const Spacer &indent, OStream &os, const T &t) const { if (ro.fancyVerticals()) { os << indent << "\n" - << indent << " " << t << "\n" - << indent << " \">\n" + << indent + s(2) << "class=\"obj\"\n" + << indent + s(2) << "type=\"image/svg+xml\"\n" + << indent + s(2) << "width=\"14px\"\n" + << indent + s(2) << "height=\"55px\"\n" + << indent + s(2) << "data=\"data:image/svg+xml,\n" + << indent + s(4) << "\n" + << indent + s(6) << "" << t << "\n" + << indent + s(4) << "\">\n" << indent << "\n"; } else { std::ostringstream oss; @@ -583,36 +609,36 @@ namespace llvm { os << indent; for (std::string::iterator tStrItr = tStr.begin(), tStrEnd = tStr.end(); tStrItr != tStrEnd; ++tStrItr) { - os << *tStrItr << "
"; + os << *tStrItr << "
"; } os << "\n"; } } template - void RenderMachineFunction::insertCSS(const std::string &indent, + void RenderMachineFunction::insertCSS(const Spacer &indent, OStream &os) const { os << indent << "\n"; } template void RenderMachineFunction::renderFunctionSummary( - const std::string &indent, OStream &os, + const Spacer &indent, OStream &os, const char * const renderContextStr) const { os << indent << "

Function: " << mf->getFunction()->getName() << "

\n" @@ -622,40 +648,40 @@ namespace llvm { template void RenderMachineFunction::renderPressureTableLegend( - const std::string &indent, + const Spacer &indent, OStream &os) const { os << indent << "

Rendering Pressure Legend:

\n" << indent << "\n" - << indent << " \n" - << indent << " " + << indent + s(2) << "\n" + << indent + s(4) << "" "\n" - << indent << " \n" - << indent << " \n" - << indent << " " - " " - " \n" - << indent << " \n" - << indent << " \n" - << indent << " " - " " - " \n" - << indent << " \n" - << indent << " \n" - << indent << " " - " " - " \n" - << indent << " \n" + << indent + s(2) << "\n" + << indent + s(2) << "\n" + << indent + s(4) << "" + "" + "\n" + << indent + s(2) << "\n" + << indent + s(2) << "\n" + << indent + s(4) << "" + "" + "\n" + << indent + s(2) << "\n" + << indent + s(2) << "\n" + << indent + s(4) << "" + "" + "\n" + << indent + s(2) << "\n" << indent << "
PressureDescription
PressureDescriptionAppearance
No PressureNo physical registers of this class requested.  
Low PressureSufficient physical registers to meet demand.  
High PressurePotentially insufficient physical registers to meet demand.  
No PressureNo physical registers of this class requested.  
Low PressureSufficient physical registers to meet demand.  
High PressurePotentially insufficient physical registers to meet demand.  
\n"; } template - void RenderMachineFunction::renderCodeTablePlusPI(const std::string & indent, + void RenderMachineFunction::renderCodeTablePlusPI(const Spacer &indent, OStream &os) const { os << indent << "\n" - << indent << " \n" - << indent << " \n" - << indent << " \n"; + << indent + s(2) << "\n" + << indent + s(4) << "\n" + << indent + s(4) << "\n"; // Header row: @@ -665,15 +691,15 @@ namespace llvm { rcEnd = ro.regClasses().end(); rcItr != rcEnd; ++rcItr) { const TargetRegisterClass *trc = *rcItr; - os << indent << " \n"; + os << indent + s(4) << "\n"; } } // FIXME: Is there a nicer way to insert space between columns in HTML? if (!ro.regClasses().empty() && !ro.intervals().empty()) - os << indent << " \n"; + os << indent + s(4) << "\n"; if (!ro.intervals().empty()) { for (MFRenderingOptions::IntervalSet::const_iterator @@ -682,13 +708,13 @@ namespace llvm { liItr != liEnd; ++liItr) { const LiveInterval *li = *liItr; - os << indent << " \n"; + os << indent + s(4) << "\n"; } } - os << indent << " \n"; + os << indent + s(2) << "\n"; MachineInstr *mi = 0; @@ -696,7 +722,7 @@ namespace llvm { for (SlotIndex i = sis->getZeroIndex(); i != sis->getLastIndex(); i = i.getNextSlot()) { - os << indent << " \n"; + os << indent + s(2) << "\n"; if (i.getSlot() == SlotIndex::LOAD) { MachineBasicBlock *mbb = sis->getMBBFromIndex(i); @@ -704,19 +730,18 @@ namespace llvm { if (i == sis->getMBBStartIdx(mbb) || mi != 0 || ro.renderEmptyIndexes()) { - os << indent << " \n" - << indent << " \n" + << indent + s(4) << "\n"; + os << indent + s(4) << "\n"; } else { i = i.getStoreIndex(); // <- Will be incremented to the next index. continue; @@ -730,7 +755,7 @@ namespace llvm { rcItr != rcEnd; ++rcItr) { const TargetRegisterClass *trc = *rcItr; - os << indent << " \n"; + os << indent + s(4) << "\n"; if (!ro.intervals().empty()) { for (MFRenderingOptions::IntervalSet::const_iterator @@ -754,7 +779,7 @@ namespace llvm { liEnd = ro.intervals().end(); liItr != liEnd; ++liItr) { const LiveInterval *li = *liItr; - os << indent << " \n"; } } - os << indent << " \n"; + os << indent + s(2) << "\n"; } os << indent << "
indexinstr
indexinstr\n"; - renderVertical(indent + " ", os, trc->getName()); - os << indent << " \n"; + renderVertical(indent + s(6), os, trc->getName()); + os << indent + s(4) << "    \n"; - renderVertical(indent + " ", os, li->reg); - os << indent << " \n"; + renderVertical(indent + s(6), os, li->reg); + os << indent + s(4) << "
" << i << " \n"; + os << indent + s(4) << "" << i << " \n"; if (i == sis->getMBBStartIdx(mbb)) { - os << indent << " BB#" << mbb->getNumber() << ": \n"; + os << indent + s(6) << "BB#" << mbb->getNumber() << ": \n"; } else if (mi != 0) { - os << indent << "   "; + os << indent + s(6) << "  "; renderMachineInstr(os, mi); - os << "\n"; } else { - os << indent << "  \n"; + os << indent + s(6) << " \n"; } - os << indent << "
\n"; @@ -776,7 +801,7 @@ namespace llvm { } template - void RenderMachineFunction::renderWarnings(const std::string &indent, + void RenderMachineFunction::renderWarnings(const Spacer &indent, OStream &os) const { } @@ -785,25 +810,25 @@ namespace llvm { OStream &os, const char * const renderContextStr) const { os << "\n" - << " \n" - << " " << fqn << "\n"; + << s(2) << "\n" + << s(4) << "" << fqn << "\n"; - insertCSS(" ", os); + insertCSS(s(4), os); - os << " \n" - << " \n"; + os << s(2) << "\n" + << s(2) << "\n"; - renderFunctionSummary(" ", os, renderContextStr); + renderFunctionSummary(s(4), os, renderContextStr); - os << "


\n"; + os << s(4) << "


\n"; //renderLiveIntervalInfoTable(" ", os); - os << "


\n"; + os << s(4) << "


\n"; - renderCodeTablePlusPI(" ", os); + renderCodeTablePlusPI(s(4), os); - os << " \n" + os << s(2) << "\n" << "\n"; } -- cgit v1.2.3