[llvm-commits] [llvm] r108822 - in /llvm/trunk/lib/CodeGen: RenderMachineFunction.cpp RenderMachineFunction.h

Daniel Dunbar daniel at zuster.org
Tue Jul 20 08:27:09 PDT 2010


Hi Lang,

This broke the MSVC build here:
  http://google1.osuosl.org:8011/builders/clang-i686-xp-msvc9/builds/7791
Can you take a look? The error is:
--
71>..\..\..\lib\CodeGen\RenderMachineFunction.cpp(519) : error C2893:
Failed to specialize function template 'OStream &llvm::operator
<<(OStream &,const llvm::RenderMachineFunction::Spacer &)'
71>        With the following template arguments:
71>        'llvm::raw_ostream'
71>..\..\..\lib\CodeGen\RenderMachineFunction.cpp(519) : error C2248:
'llvm::RenderMachineFunction::Spacer' : cannot access private class
declared in class 'llvm::RenderMachineFunction'
71>        d:\public\zorg\buildbot\osuosl\slave\clang-i686-xp-msvc9\llvm\lib\codegen\RenderMachineFunction.h(255)
: see declaration of 'llvm::RenderMachineFunction::Spacer'
71>        d:\public\zorg\buildbot\osuosl\slave\clang-i686-xp-msvc9\llvm\lib\codegen\RenderMachineFunction.h(196)
: see declaration of 'llvm::RenderMachineFunction'
--

 - Daniel


On Tue, Jul 20, 2010 at 2:13 AM, Lang Hames <lhames at gmail.com> wrote:
> Author: lhames
> Date: Tue Jul 20 04:13:29 2010
> New Revision: 108822
>
> URL: http://llvm.org/viewvc/llvm-project?rev=108822&view=rev
> Log:
> Added support for turning HTML indentation on and off (indentation off by default).
>
> Reduces output file size ~20% on my test cases.
>
>
> Modified:
>    llvm/trunk/lib/CodeGen/RenderMachineFunction.cpp
>    llvm/trunk/lib/CodeGen/RenderMachineFunction.h
>
> Modified: llvm/trunk/lib/CodeGen/RenderMachineFunction.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/RenderMachineFunction.cpp?rev=108822&r1=108821&r2=108822&view=diff
> ==============================================================================
> --- llvm/trunk/lib/CodeGen/RenderMachineFunction.cpp (original)
> +++ llvm/trunk/lib/CodeGen/RenderMachineFunction.cpp Tue Jul 20 04:13:29 2010
> @@ -66,6 +66,12 @@
>                   cl::desc("Use SVG for vertical text."),
>                   cl::init(true), cl::Hidden);
>
> +static cl::opt<bool>
> +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 @@
>
>   // ---------- MachineFunctionRenderer implementation ----------
>
> +  template <typename OStream>
> +  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 <typename OStream>
> +  OStream& operator<<(OStream &os, const RenderMachineFunction::Spacer &s) {
> +    s.print(os);
> +    return os;
> +  }
> +
>   template <typename Iterator>
>   std::string RenderMachineFunction::escapeChars(Iterator sBegin, Iterator sEnd) const {
>     std::string r;
> @@ -558,22 +583,23 @@
>   }
>
>   template <typename OStream, typename T>
> -  void RenderMachineFunction::renderVertical(const std::string &indent,
> +  void RenderMachineFunction::renderVertical(const Spacer &indent,
>                                              OStream &os,
>                                              const T &t) const {
>     if (ro.fancyVerticals()) {
>       os << indent << "<object\n"
> -         << indent << "  class=\"obj\"\n"
> -         << indent << "  type=\"image/svg+xml\"\n"
> -         << indent << "  width=\"14px\"\n"
> -         << indent << "  height=\"55px\"\n"
> -         << indent << "  data=\"data:image/svg+xml,\n"
> -         << indent << "    <svg xmlns='http://www.w3.org/2000/svg'>\n"
> -         << indent << "      <text x='-55' y='10' "
> -                      "font-family='Courier' font-size='12' "
> -                      "transform='rotate(-90)' text-rendering='optimizeSpeed' "
> -                      "fill='#000'>" << t << "</text>\n"
> -         << indent << "    </svg>\">\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) << "<svg xmlns='http://www.w3.org/2000/svg'>\n"
> +         << indent + s(6) << "<text x='-55' y='10' "
> +                             "font-family='Courier' font-size='12' "
> +                             "transform='rotate(-90)' "
> +                             "text-rendering='optimizeSpeed' "
> +                             "fill='#000'>" << t << "</text>\n"
> +         << indent + s(4) << "</svg>\">\n"
>          << indent << "</object>\n";
>     } else {
>       std::ostringstream oss;
> @@ -583,36 +609,36 @@
>       os << indent;
>       for (std::string::iterator tStrItr = tStr.begin(), tStrEnd = tStr.end();
>            tStrItr != tStrEnd; ++tStrItr) {
> -        os << *tStrItr << "<br/> ";
> +        os << *tStrItr << "<br/>";
>       }
>       os << "\n";
>     }
>   }
>
>   template <typename OStream>
> -  void RenderMachineFunction::insertCSS(const std::string &indent,
> +  void RenderMachineFunction::insertCSS(const Spacer &indent,
>                                         OStream &os) const {
>     os << indent << "<style type=\"text/css\">\n"
> -       << indent << "  body { font-color: black; }\n"
> -       << indent << "  table.code td { font-family: monospace; "
> +       << indent + s(2) << "body { font-color: black; }\n"
> +       << indent + s(2) << "table.code td { font-family: monospace; "
>                     "border-width: 0px; border-style: solid; "
>                     "border-bottom: 1px solid #dddddd; white-space: nowrap; }\n"
> -       << indent << "  table.code td.s-zp { background-color: #000000; }\n"
> -       << indent << "  table.code td.s-up { background-color: #00ff00; }\n"
> -       << indent << "  table.code td.s-op { background-color: #ff0000; }\n"
> -       << indent << "  table.code td.l-na { background-color: #ffffff; }\n"
> -       << indent << "  table.code td.l-def { background-color: #ff0000; }\n"
> -       << indent << "  table.code td.l-use { background-color: #ffff00; }\n"
> -       << indent << "  table.code td.l-sar { background-color: #000000; }\n"
> -       << indent << "  table.code td.l-sas { background-color: #770000; }\n"
> -       << indent << "  table.code th { border-width: 0px; "
> +       << indent + s(2) << "table.code td.s-zp { background-color: #000000; }\n"
> +       << indent + s(2) << "table.code td.s-up { background-color: #00ff00; }\n"
> +       << indent + s(2) << "table.code td.s-op { background-color: #ff0000; }\n"
> +       << indent + s(2) << "table.code td.l-na { background-color: #ffffff; }\n"
> +       << indent + s(2) << "table.code td.l-def { background-color: #ff0000; }\n"
> +       << indent + s(2) << "table.code td.l-use { background-color: #ffff00; }\n"
> +       << indent + s(2) << "table.code td.l-sar { background-color: #000000; }\n"
> +       << indent + s(2) << "table.code td.l-sas { background-color: #770000; }\n"
> +       << indent + s(2) << "table.code th { border-width: 0px; "
>                     "border-style: solid; }\n"
>        << indent << "</style>\n";
>   }
>
>   template <typename OStream>
>   void RenderMachineFunction::renderFunctionSummary(
> -                                    const std::string &indent, OStream &os,
> +                                    const Spacer &indent, OStream &os,
>                                     const char * const renderContextStr) const {
>     os << indent << "<h1>Function: " << mf->getFunction()->getName()
>                  << "</h1>\n"
> @@ -622,40 +648,40 @@
>
>   template <typename OStream>
>   void RenderMachineFunction::renderPressureTableLegend(
> -                                                      const std::string &indent,
> +                                                      const Spacer &indent,
>                                                       OStream &os) const {
>     os << indent << "<h2>Rendering Pressure Legend:</h2>\n"
>        << indent << "<table class=\"code\">\n"
> -       << indent << "  <tr>\n"
> -       << indent << "    <th>Pressure</th><th>Description</th>"
> +       << indent + s(2) << "<tr>\n"
> +       << indent + s(4) << "<th>Pressure</th><th>Description</th>"
>                     "<th>Appearance</th>\n"
> -       << indent << "  </tr>\n"
> -       << indent << "  <tr>\n"
> -       << indent << "    <td>No Pressure</td>"
> -                    "    <td>No physical registers of this class requested.</td>"
> -                    "    <td class=\"s-zp\">  </td>\n"
> -       << indent << "  </tr>\n"
> -       << indent << "  <tr>\n"
> -       << indent << "    <td>Low Pressure</td>"
> -                    "    <td>Sufficient physical registers to meet demand.</td>"
> -                    "    <td class=\"s-up\">  </td>\n"
> -       << indent << "  </tr>\n"
> -       << indent << "  <tr>\n"
> -       << indent << "    <td>High Pressure</td>"
> -                    "    <td>Potentially insufficient physical registers to meet demand.</td>"
> -                    "    <td class=\"s-op\">  </td>\n"
> -       << indent << "  </tr>\n"
> +       << indent + s(2) << "</tr>\n"
> +       << indent + s(2) << "<tr>\n"
> +       << indent + s(4) << "<td>No Pressure</td>"
> +                    "<td>No physical registers of this class requested.</td>"
> +                    "<td class=\"s-zp\">  </td>\n"
> +       << indent + s(2) << "</tr>\n"
> +       << indent + s(2) << "<tr>\n"
> +       << indent + s(4) << "<td>Low Pressure</td>"
> +                    "<td>Sufficient physical registers to meet demand.</td>"
> +                    "<td class=\"s-up\">  </td>\n"
> +       << indent + s(2) << "</tr>\n"
> +       << indent + s(2) << "<tr>\n"
> +       << indent + s(4) << "<td>High Pressure</td>"
> +                    "<td>Potentially insufficient physical registers to meet demand.</td>"
> +                    "<td class=\"s-op\">  </td>\n"
> +       << indent + s(2) << "</tr>\n"
>        << indent << "</table>\n";
>   }
>
>   template <typename OStream>
> -  void RenderMachineFunction::renderCodeTablePlusPI(const std::string & indent,
> +  void RenderMachineFunction::renderCodeTablePlusPI(const Spacer &indent,
>                                                     OStream &os) const {
>
>     os << indent << "<table cellpadding=0 cellspacing=0 class=\"code\">\n"
> -       << indent << "  <tr>\n"
> -       << indent << "    <th>index</th>\n"
> -       << indent << "    <th>instr</th>\n";
> +       << indent + s(2) << "<tr>\n"
> +       << indent + s(4) << "<th>index</th>\n"
> +       << indent + s(4) << "<th>instr</th>\n";
>
>     // Header row:
>
> @@ -665,15 +691,15 @@
>              rcEnd = ro.regClasses().end();
>            rcItr != rcEnd; ++rcItr) {
>         const TargetRegisterClass *trc = *rcItr;
> -        os << indent << "    <th>\n";
> -        renderVertical(indent + "      ", os, trc->getName());
> -        os << indent << "    </th>\n";
> +        os << indent + s(4) << "<th>\n";
> +        renderVertical(indent + s(6), os, trc->getName());
> +        os << indent + s(4) << "</th>\n";
>       }
>     }
>
>     // FIXME: Is there a nicer way to insert space between columns in HTML?
>     if (!ro.regClasses().empty() && !ro.intervals().empty())
> -      os << indent << "    <th>  </th>\n";
> +      os << indent + s(4) << "<th>  </th>\n";
>
>     if (!ro.intervals().empty()) {
>       for (MFRenderingOptions::IntervalSet::const_iterator
> @@ -682,13 +708,13 @@
>            liItr != liEnd; ++liItr) {
>
>         const LiveInterval *li = *liItr;
> -        os << indent << "    <th>\n";
> -        renderVertical(indent + "      ", os, li->reg);
> -        os << indent << "    </th>\n";
> +        os << indent + s(4) << "<th>\n";
> +        renderVertical(indent + s(6), os, li->reg);
> +        os << indent + s(4) << "</th>\n";
>       }
>     }
>
> -    os << indent << "  </tr>\n";
> +    os << indent + s(2) << "</tr>\n";
>
>     MachineInstr *mi = 0;
>
> @@ -696,7 +722,7 @@
>     for (SlotIndex i = sis->getZeroIndex(); i != sis->getLastIndex();
>          i = i.getNextSlot()) {
>
> -      os << indent << "  <tr height=6ex>\n";
> +      os << indent + s(2) << "<tr height=6ex>\n";
>
>       if (i.getSlot() == SlotIndex::LOAD) {
>         MachineBasicBlock *mbb = sis->getMBBFromIndex(i);
> @@ -704,19 +730,18 @@
>
>         if (i == sis->getMBBStartIdx(mbb) || mi != 0 ||
>             ro.renderEmptyIndexes()) {
> -          os << indent << "    <td rowspan=4>" << i << " </td>\n"
> -             << indent << "    <td rowspan=4>\n";
> +          os << indent + s(4) << "<td rowspan=4>" << i << " </td>\n"
> +             << indent + s(4) << "<td rowspan=4>\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 << "    </td>\n";
> +          os << indent + s(4) << "</td>\n";
>         } else {
>           i = i.getStoreIndex(); // <- Will be incremented to the next index.
>           continue;
> @@ -730,7 +755,7 @@
>              rcItr != rcEnd; ++rcItr) {
>           const TargetRegisterClass *trc = *rcItr;
>
> -          os << indent << "    <td class=\"";
> +          os << indent + s(4) << "<td class=\"";
>
>           if (trei.getPressureAtSlot(trc, i) == 0) {
>             os << "s-zp";
> @@ -746,7 +771,7 @@
>
>       // FIXME: Is there a nicer way to insert space between columns in HTML?
>       if (!ro.regClasses().empty() && !ro.intervals().empty())
> -        os << indent << "    <td width=2em></td>\n";
> +        os << indent + s(4) << "<td width=2em></td>\n";
>
>       if (!ro.intervals().empty()) {
>         for (MFRenderingOptions::IntervalSet::const_iterator
> @@ -754,7 +779,7 @@
>                liEnd = ro.intervals().end();
>              liItr != liEnd; ++liItr) {
>           const LiveInterval *li = *liItr;
> -          os << indent << "    <td class=\"";
> +          os << indent + s(4) << "<td class=\"";
>           switch (getLiveStateAt(li, i)) {
>             case Dead: os << "l-na"; break;
>             case Defined: os << "l-def"; break;
> @@ -766,7 +791,7 @@
>           os << "\"></td>\n";
>         }
>       }
> -      os << indent << "  </tr>\n";
> +      os << indent + s(2) << "</tr>\n";
>     }
>
>     os << indent << "</table>\n";
> @@ -776,7 +801,7 @@
>   }
>
>   template <typename OStream>
> -  void RenderMachineFunction::renderWarnings(const std::string &indent,
> +  void RenderMachineFunction::renderWarnings(const Spacer &indent,
>                                              OStream &os) const {
>   }
>
> @@ -785,25 +810,25 @@
>                                     OStream &os,
>                                     const char * const renderContextStr) const {
>     os << "<html>\n"
> -       << "  <head>\n"
> -       << "    <title>" << fqn << "</title>\n";
> +       << s(2) << "<head>\n"
> +       << s(4) << "<title>" << fqn << "</title>\n";
>
> -    insertCSS("    ", os);
> +    insertCSS(s(4), os);
>
> -    os << "  <head>\n"
> -       << "  <body >\n";
> +    os << s(2) << "<head>\n"
> +       << s(2) << "<body >\n";
>
> -    renderFunctionSummary("    ", os, renderContextStr);
> +    renderFunctionSummary(s(4), os, renderContextStr);
>
> -    os << "    <br/><br/><br/>\n";
> +    os << s(4) << "<br/><br/><br/>\n";
>
>     //renderLiveIntervalInfoTable("    ", os);
>
> -    os << "    <br/><br/><br/>\n";
> +    os << s(4) << "<br/><br/><br/>\n";
>
> -    renderCodeTablePlusPI("    ", os);
> +    renderCodeTablePlusPI(s(4), os);
>
> -    os << "  </body>\n"
> +    os << s(2) << "</body>\n"
>        << "</html>\n";
>   }
>
>
> Modified: llvm/trunk/lib/CodeGen/RenderMachineFunction.h
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/RenderMachineFunction.h?rev=108822&r1=108821&r2=108822&view=diff
> ==============================================================================
> --- llvm/trunk/lib/CodeGen/RenderMachineFunction.h (original)
> +++ llvm/trunk/lib/CodeGen/RenderMachineFunction.h Tue Jul 20 04:13:29 2010
> @@ -243,6 +243,18 @@
>
>     // ---------- Rendering methods ----------
>
> +    /// For inserting spaces when pretty printing.
> +    class Spacer {
> +    public:
> +      explicit Spacer(unsigned numSpaces) : ns(numSpaces) {}
> +      Spacer operator+(const Spacer &o) const { return Spacer(ns + o.ns); }
> +      template <typename OStream> void print(OStream &os) const;
> +    private:
> +      unsigned ns;
> +    };
> +
> +    Spacer s(unsigned ns) const;
> +
>     template <typename Iterator>
>     std::string escapeChars(Iterator sBegin, Iterator sEnd) const;
>
> @@ -253,38 +265,38 @@
>
>     /// \brief Render vertical text.
>     template <typename OStream, typename T>
> -    void renderVertical(const std::string &indent,
> +    void renderVertical(const Spacer &indent,
>                         OStream &os,
>                         const T &t) const;
>
>     /// \brief Insert CSS layout info.
>     template <typename OStream>
> -    void insertCSS(const std::string &indent,
> +    void insertCSS(const Spacer &indent,
>                    OStream &os) const;
>
>     /// \brief Render a brief summary of the function (including rendering
>     ///        context).
>     template <typename OStream>
> -    void renderFunctionSummary(const std::string &indent,
> +    void renderFunctionSummary(const Spacer &indent,
>                                OStream &os,
>                                const char * const renderContextStr) const;
>
>     /// \brief Render a legend for the pressure table.
>     template <typename OStream>
> -    void renderPressureTableLegend(const std::string &indent,
> +    void renderPressureTableLegend(const Spacer &indent,
>                                    OStream &os) const;
>
>     /// \brief Render code listing, potentially with register pressure
>     ///        and live intervals shown alongside.
>     template <typename OStream>
> -    void renderCodeTablePlusPI(const std::string &indent,
> +    void renderCodeTablePlusPI(const Spacer &indent,
>                                OStream &os) const;
>
>     /// \brief Render warnings about the machine function, or weird rendering
>     ///        parameter combinations (e.g. rendering specified live intervals
>     ///        over more than one machine function).
>     template <typename OStream>
> -    void renderWarnings(const std::string &indent,
> +    void renderWarnings(const Spacer &indent,
>                         OStream &os) const;
>
>     /// \brief Render the HTML page representing the MachineFunction.
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>




More information about the llvm-commits mailing list