1 //===-- llvm/CodeGen/RenderMachineFunction.cpp - MF->HTML -----s-----------===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #define DEBUG_TYPE "rendermf"
12 #include "RenderMachineFunction.h"
14 #include "VirtRegMap.h"
16 #include "llvm/Function.h"
17 #include "llvm/Module.h"
18 #include "llvm/ADT/SmallVector.h"
19 #include "llvm/CodeGen/LiveIntervalAnalysis.h"
20 #include "llvm/CodeGen/MachineFunction.h"
21 #include "llvm/CodeGen/MachineInstr.h"
22 #include "llvm/CodeGen/MachineRegisterInfo.h"
23 #include "llvm/Support/CommandLine.h"
24 #include "llvm/Support/Debug.h"
25 #include "llvm/Support/raw_ostream.h"
26 #include "llvm/Target/TargetMachine.h"
32 char RenderMachineFunction::ID = 0;
33 static RegisterPass<RenderMachineFunction>
34 X("rendermf", "Render machine functions (and related info) to HTML pages");
36 static cl::opt<std::string>
37 outputFileSuffix("rmf-file-suffix",
38 cl::desc("Appended to function name to get output file name "
39 "(default: \".html\")"),
40 cl::init(".html"), cl::Hidden);
42 static cl::opt<std::string>
43 machineFuncsToRender("rmf-funcs",
44 cl::desc("Coma seperated list of functions to render"
46 cl::init(""), cl::Hidden);
48 static cl::opt<std::string>
49 pressureClasses("rmf-classes",
50 cl::desc("Register classes to render pressure for."),
51 cl::init(""), cl::Hidden);
53 static cl::opt<std::string>
54 showIntervals("rmf-intervals",
55 cl::desc("Live intervals to show alongside code."),
56 cl::init(""), cl::Hidden);
59 showEmptyIndexes("rmf-empty-indexes",
60 cl::desc("Render indexes not associated with instructions or "
62 cl::init(false), cl::Hidden);
65 useFancyVerticals("rmf-fancy-verts",
66 cl::desc("Use SVG for vertical text."),
67 cl::init(true), cl::Hidden);
71 bool MFRenderingOptions::renderingOptionsProcessed;
72 std::set<std::string> MFRenderingOptions::mfNamesToRender;
73 bool MFRenderingOptions::renderAllMFs = false;
75 std::set<std::string> MFRenderingOptions::classNamesToRender;
76 bool MFRenderingOptions::renderAllClasses = false;
78 std::set<std::pair<unsigned, unsigned> >
79 MFRenderingOptions::intervalNumsToRender;
80 unsigned MFRenderingOptions::intervalTypesToRender = ExplicitOnly;
82 template <typename OutputItr>
83 void MFRenderingOptions::splitComaSeperatedList(const std::string &s,
85 std::string::const_iterator curPos = s.begin();
86 std::string::const_iterator nextComa = std::find(curPos, s.end(), ',');
87 while (nextComa != s.end()) {
89 std::copy(curPos, nextComa, std::back_inserter(elem));
92 curPos = llvm::next(nextComa);
93 nextComa = std::find(curPos, s.end(), ',');
96 if (curPos != s.end()) {
98 std::copy(curPos, s.end(), std::back_inserter(elem));
104 void MFRenderingOptions::processOptions() {
105 if (!renderingOptionsProcessed) {
107 processRegClassNames();
108 processIntervalNumbers();
109 renderingOptionsProcessed = true;
113 void MFRenderingOptions::processFuncNames() {
114 if (machineFuncsToRender == "*") {
117 splitComaSeperatedList(machineFuncsToRender,
118 std::inserter(mfNamesToRender,
119 mfNamesToRender.begin()));
123 void MFRenderingOptions::processRegClassNames() {
124 if (pressureClasses == "*") {
125 renderAllClasses = true;
127 splitComaSeperatedList(pressureClasses,
128 std::inserter(classNamesToRender,
129 classNamesToRender.begin()));
133 void MFRenderingOptions::processIntervalNumbers() {
134 std::set<std::string> intervalRanges;
135 splitComaSeperatedList(showIntervals,
136 std::inserter(intervalRanges,
137 intervalRanges.begin()));
138 std::for_each(intervalRanges.begin(), intervalRanges.end(),
139 processIntervalRange);
142 void MFRenderingOptions::processIntervalRange(
143 const std::string &intervalRangeStr) {
144 if (intervalRangeStr == "*") {
145 intervalTypesToRender |= All;
146 } else if (intervalRangeStr == "virt*") {
147 intervalTypesToRender |= VirtPlusExplicit;
148 } else if (intervalRangeStr == "phys*") {
149 intervalTypesToRender |= PhysPlusExplicit;
151 std::istringstream iss(intervalRangeStr);
153 if ((iss >> reg1 >> std::ws)) {
155 intervalNumsToRender.insert(std::make_pair(reg1, reg1 + 1));
159 if (c == '-' && (iss >> reg2)) {
160 intervalNumsToRender.insert(std::make_pair(reg1, reg2 + 1));
162 dbgs() << "Warning: Invalid interval range \""
163 << intervalRangeStr << "\" in -rmf-intervals. Skipping.\n";
167 dbgs() << "Warning: Invalid interval number \""
168 << intervalRangeStr << "\" in -rmf-intervals. Skipping.\n";
173 void MFRenderingOptions::setup(MachineFunction *mf,
174 const TargetRegisterInfo *tri,
175 LiveIntervals *lis) {
183 void MFRenderingOptions::clear() {
184 regClassesTranslatedToCurrentFunction = false;
187 intervalsTranslatedToCurrentFunction = false;
191 void MFRenderingOptions::resetRenderSpecificOptions() {
193 intervalsTranslatedToCurrentFunction = false;
196 bool MFRenderingOptions::shouldRenderCurrentMachineFunction() const {
199 return (renderAllMFs ||
200 mfNamesToRender.find(mf->getFunction()->getName()) !=
201 mfNamesToRender.end());
204 const MFRenderingOptions::RegClassSet& MFRenderingOptions::regClasses() const{
205 translateRegClassNamesToCurrentFunction();
209 const MFRenderingOptions::IntervalSet& MFRenderingOptions::intervals() const {
210 translateIntervalNumbersToCurrentFunction();
214 bool MFRenderingOptions::renderEmptyIndexes() const {
215 return showEmptyIndexes;
218 bool MFRenderingOptions::fancyVerticals() const {
219 return useFancyVerticals;
222 void MFRenderingOptions::translateRegClassNamesToCurrentFunction() const {
223 if (!regClassesTranslatedToCurrentFunction) {
225 for (TargetRegisterInfo::regclass_iterator rcItr = tri->regclass_begin(),
226 rcEnd = tri->regclass_end();
227 rcItr != rcEnd; ++rcItr) {
228 const TargetRegisterClass *trc = *rcItr;
229 if (renderAllClasses ||
230 classNamesToRender.find(trc->getName()) !=
231 classNamesToRender.end()) {
232 regClassSet.insert(trc);
235 regClassesTranslatedToCurrentFunction = true;
239 void MFRenderingOptions::translateIntervalNumbersToCurrentFunction() const {
240 if (!intervalsTranslatedToCurrentFunction) {
243 // If we're not just doing explicit then do a copy over all matching
245 if (intervalTypesToRender != ExplicitOnly) {
246 for (LiveIntervals::iterator liItr = lis->begin(), liEnd = lis->end();
247 liItr != liEnd; ++liItr) {
249 if ((TargetRegisterInfo::isPhysicalRegister(liItr->first) &&
250 (intervalTypesToRender & PhysPlusExplicit)) ||
251 (TargetRegisterInfo::isVirtualRegister(liItr->first) &&
252 (intervalTypesToRender & VirtPlusExplicit))) {
253 intervalSet.insert(liItr->second);
258 // If we need to process the explicit list...
259 if (intervalTypesToRender != All) {
260 for (std::set<std::pair<unsigned, unsigned> >::const_iterator
261 regRangeItr = intervalNumsToRender.begin(),
262 regRangeEnd = intervalNumsToRender.end();
263 regRangeItr != regRangeEnd; ++regRangeItr) {
264 const std::pair<unsigned, unsigned> &range = *regRangeItr;
265 for (unsigned reg = range.first; reg != range.second; ++reg) {
266 if (lis->hasInterval(reg)) {
267 intervalSet.insert(&lis->getInterval(reg));
273 intervalsTranslatedToCurrentFunction = true;
277 // ---------- TargetRegisterExtraInformation implementation ----------
279 TargetRegisterExtraInfo::TargetRegisterExtraInfo()
280 : mapsPopulated(false) {
283 void TargetRegisterExtraInfo::setup(MachineFunction *mf,
284 MachineRegisterInfo *mri,
285 const TargetRegisterInfo *tri,
286 LiveIntervals *lis) {
293 void TargetRegisterExtraInfo::reset() {
294 if (!mapsPopulated) {
298 mapsPopulated = true;
301 resetPressureAndLiveStates();
304 void TargetRegisterExtraInfo::clear() {
309 //liveStatesMap.clear();
310 mapsPopulated = false;
313 void TargetRegisterExtraInfo::initWorst() {
314 assert(!mapsPopulated && prWorst.empty() && vrWorst.empty() &&
315 "Worst map already initialised?");
317 // Start with the physical registers.
318 for (unsigned preg = 1; preg < tri->getNumRegs(); ++preg) {
319 WorstMapLine &pregLine = prWorst[preg];
321 for (TargetRegisterInfo::regclass_iterator rcItr = tri->regclass_begin(),
322 rcEnd = tri->regclass_end();
323 rcItr != rcEnd; ++rcItr) {
324 const TargetRegisterClass *trc = *rcItr;
326 unsigned numOverlaps = 0;
327 for (TargetRegisterClass::iterator rItr = trc->begin(),
329 rItr != rEnd; ++rItr) {
330 unsigned trcPReg = *rItr;
331 if (tri->regsOverlap(preg, trcPReg))
335 pregLine[trc] = numOverlaps;
339 // Now the register classes.
340 for (TargetRegisterInfo::regclass_iterator rc1Itr = tri->regclass_begin(),
341 rcEnd = tri->regclass_end();
342 rc1Itr != rcEnd; ++rc1Itr) {
343 const TargetRegisterClass *trc1 = *rc1Itr;
344 WorstMapLine &classLine = vrWorst[trc1];
346 for (TargetRegisterInfo::regclass_iterator rc2Itr = tri->regclass_begin();
347 rc2Itr != rcEnd; ++rc2Itr) {
348 const TargetRegisterClass *trc2 = *rc2Itr;
352 for (TargetRegisterClass::iterator trc1Itr = trc1->begin(),
353 trc1End = trc1->end();
354 trc1Itr != trc1End; ++trc1Itr) {
355 unsigned trc1Reg = *trc1Itr;
356 unsigned trc1RegWorst = 0;
358 for (TargetRegisterClass::iterator trc2Itr = trc2->begin(),
359 trc2End = trc2->end();
360 trc2Itr != trc2End; ++trc2Itr) {
361 unsigned trc2Reg = *trc2Itr;
362 if (tri->regsOverlap(trc1Reg, trc2Reg))
365 if (trc1RegWorst > worst) {
366 worst = trc1RegWorst;
371 classLine[trc2] = worst;
377 unsigned TargetRegisterExtraInfo::getWorst(
379 const TargetRegisterClass *trc) const {
380 const WorstMapLine *wml = 0;
381 if (TargetRegisterInfo::isPhysicalRegister(reg)) {
382 PRWorstMap::const_iterator prwItr = prWorst.find(reg);
383 assert(prwItr != prWorst.end() && "Missing prWorst entry.");
384 wml = &prwItr->second;
386 const TargetRegisterClass *regTRC = mri->getRegClass(reg);
387 VRWorstMap::const_iterator vrwItr = vrWorst.find(regTRC);
388 assert(vrwItr != vrWorst.end() && "Missing vrWorst entry.");
389 wml = &vrwItr->second;
392 WorstMapLine::const_iterator wmlItr = wml->find(trc);
393 if (wmlItr == wml->end())
396 return wmlItr->second;
399 void TargetRegisterExtraInfo::initCapacity() {
400 assert(!mapsPopulated && capacityMap.empty() &&
401 "Capacity map already initialised?");
403 for (TargetRegisterInfo::regclass_iterator rcItr = tri->regclass_begin(),
404 rcEnd = tri->regclass_end();
405 rcItr != rcEnd; ++rcItr) {
406 const TargetRegisterClass *trc = *rcItr;
407 unsigned capacity = std::distance(trc->allocation_order_begin(*mf),
408 trc->allocation_order_end(*mf));
411 capacityMap[trc] = capacity;
415 unsigned TargetRegisterExtraInfo::getCapacity(
416 const TargetRegisterClass *trc) const {
417 CapacityMap::const_iterator cmItr = capacityMap.find(trc);
418 assert(cmItr != capacityMap.end() &&
419 "vreg with unallocable register class");
420 return cmItr->second;
423 void TargetRegisterExtraInfo::resetPressureAndLiveStates() {
425 //liveStatesMap.clear();
427 // Iterate over all slots.
430 // Iterate over all live intervals.
431 for (LiveIntervals::iterator liItr = lis->begin(),
433 liItr != liEnd; ++liItr) {
434 LiveInterval *li = liItr->second;
436 const TargetRegisterClass *liTRC;
438 if (TargetRegisterInfo::isPhysicalRegister(li->reg))
441 liTRC = mri->getRegClass(li->reg);
444 // For all ranges in the current interal.
445 for (LiveInterval::iterator lrItr = li->begin(),
447 lrItr != lrEnd; ++lrItr) {
448 LiveRange *lr = &*lrItr;
450 // For all slots in the current range.
451 for (SlotIndex i = lr->start; i != lr->end; i = i.getNextSlot()) {
453 // Record increased pressure at index for all overlapping classes.
454 for (TargetRegisterInfo::regclass_iterator
455 rcItr = tri->regclass_begin(),
456 rcEnd = tri->regclass_end();
457 rcItr != rcEnd; ++rcItr) {
458 const TargetRegisterClass *trc = *rcItr;
460 if (trc->allocation_order_begin(*mf) ==
461 trc->allocation_order_end(*mf))
464 unsigned worstAtI = getWorst(li->reg, trc);
467 pressureMap[i][trc] += worstAtI;
475 unsigned TargetRegisterExtraInfo::getPressureAtSlot(
476 const TargetRegisterClass *trc,
478 PressureMap::const_iterator pmItr = pressureMap.find(i);
479 if (pmItr == pressureMap.end())
481 const PressureMapLine &pmLine = pmItr->second;
482 PressureMapLine::const_iterator pmlItr = pmLine.find(trc);
483 if (pmlItr == pmLine.end())
485 return pmlItr->second;
488 bool TargetRegisterExtraInfo::classOverCapacityAtSlot(
489 const TargetRegisterClass *trc,
491 return (getPressureAtSlot(trc, i) > getCapacity(trc));
494 // ---------- MachineFunctionRenderer implementation ----------
496 template <typename Iterator>
497 std::string RenderMachineFunction::escapeChars(Iterator sBegin, Iterator sEnd) const {
500 for (Iterator sItr = sBegin; sItr != sEnd; ++sItr) {
504 case '<': r.append("<"); break;
505 case '>': r.append(">"); break;
506 case '&': r.append("&"); break;
507 case ' ': r.append(" "); break;
508 case '\"': r.append("""); break;
509 default: r.push_back(c); break;
516 RenderMachineFunction::LiveState
517 RenderMachineFunction::getLiveStateAt(const LiveInterval *li,
519 const MachineInstr *mi = sis->getInstructionFromIndex(i);
524 (vrm->getStackSlot(li->reg) == VirtRegMap::NO_STACK_SLOT)) {
530 if (i.getSlot() == SlotIndex::DEF &&
531 mi->definesRegister(li->reg, tri)) {
533 } else if (i.getSlot() == SlotIndex::USE &&
534 mi->readsRegister(li->reg)) {
538 (vrm->getStackSlot(li->reg) == VirtRegMap::NO_STACK_SLOT)) {
549 /// \brief Render a machine instruction.
550 template <typename OStream>
551 void RenderMachineFunction::renderMachineInstr(OStream &os,
552 const MachineInstr *mi) const {
554 raw_string_ostream oss(s);
557 os << escapeChars(oss.str());
560 template <typename OStream, typename T>
561 void RenderMachineFunction::renderVertical(const std::string &indent,
564 if (ro.fancyVerticals()) {
565 os << indent << "<object\n"
566 << indent << " class=\"obj\"\n"
567 << indent << " type=\"image/svg+xml\"\n"
568 << indent << " width=\"14px\"\n"
569 << indent << " height=\"55px\"\n"
570 << indent << " data=\"data:image/svg+xml,\n"
571 << indent << " <svg xmlns='http://www.w3.org/2000/svg'>\n"
572 << indent << " <text x='-55' y='10' "
573 "font-family='Courier' font-size='12' "
574 "transform='rotate(-90)' text-rendering='optimizeSpeed' "
575 "fill='#000'>" << t << "</text>\n"
576 << indent << " </svg>\">\n"
577 << indent << "</object>\n";
579 std::ostringstream oss;
581 std::string tStr(oss.str());
584 for (std::string::iterator tStrItr = tStr.begin(), tStrEnd = tStr.end();
585 tStrItr != tStrEnd; ++tStrItr) {
586 os << *tStrItr << "<br/> ";
592 template <typename OStream>
593 void RenderMachineFunction::insertCSS(const std::string &indent,
595 os << indent << "<style type=\"text/css\">\n"
596 << indent << " body { font-color: black; }\n"
597 << indent << " table.code td { font-family: monospace; "
598 "border-width: 0px; border-style: solid; "
599 "border-bottom: 1px solid #dddddd; white-space: nowrap; }\n"
600 << indent << " table.code td.s-zp { background-color: #000000; }\n"
601 << indent << " table.code td.s-up { background-color: #00ff00; }\n"
602 << indent << " table.code td.s-op { background-color: #ff0000; }\n"
603 << indent << " table.code td.l-na { background-color: #ffffff; }\n"
604 << indent << " table.code td.l-def { background-color: #ff0000; }\n"
605 << indent << " table.code td.l-use { background-color: #ffff00; }\n"
606 << indent << " table.code td.l-sar { background-color: #000000; }\n"
607 << indent << " table.code td.l-sas { background-color: #770000; }\n"
608 << indent << " table.code th { border-width: 0px; "
609 "border-style: solid; }\n"
610 << indent << "</style>\n";
613 template <typename OStream>
614 void RenderMachineFunction::renderFunctionSummary(
615 const std::string &indent, OStream &os,
616 const char * const renderContextStr) const {
617 os << indent << "<h1>Function: " << mf->getFunction()->getName()
619 << indent << "<h2>Rendering context: " << renderContextStr << "</h2>\n";
623 template <typename OStream>
624 void RenderMachineFunction::renderPressureTableLegend(
625 const std::string &indent,
627 os << indent << "<h2>Rendering Pressure Legend:</h2>\n"
628 << indent << "<table class=\"code\">\n"
629 << indent << " <tr>\n"
630 << indent << " <th>Pressure</th><th>Description</th>"
631 "<th>Appearance</th>\n"
632 << indent << " </tr>\n"
633 << indent << " <tr>\n"
634 << indent << " <td>No Pressure</td>"
635 " <td>No physical registers of this class requested.</td>"
636 " <td class=\"s-zp\"> </td>\n"
637 << indent << " </tr>\n"
638 << indent << " <tr>\n"
639 << indent << " <td>Low Pressure</td>"
640 " <td>Sufficient physical registers to meet demand.</td>"
641 " <td class=\"s-up\"> </td>\n"
642 << indent << " </tr>\n"
643 << indent << " <tr>\n"
644 << indent << " <td>High Pressure</td>"
645 " <td>Potentially insufficient physical registers to meet demand.</td>"
646 " <td class=\"s-op\"> </td>\n"
647 << indent << " </tr>\n"
648 << indent << "</table>\n";
651 template <typename OStream>
652 void RenderMachineFunction::renderCodeTablePlusPI(const std::string & indent,
655 os << indent << "<table cellpadding=0 cellspacing=0 class=\"code\">\n"
656 << indent << " <tr>\n"
657 << indent << " <th>index</th>\n"
658 << indent << " <th>instr</th>\n";
662 if (!ro.regClasses().empty()) {
663 for (MFRenderingOptions::RegClassSet::const_iterator
664 rcItr = ro.regClasses().begin(),
665 rcEnd = ro.regClasses().end();
666 rcItr != rcEnd; ++rcItr) {
667 const TargetRegisterClass *trc = *rcItr;
668 os << indent << " <th>\n";
669 renderVertical(indent + " ", os, trc->getName());
670 os << indent << " </th>\n";
674 // FIXME: Is there a nicer way to insert space between columns in HTML?
675 if (!ro.regClasses().empty() && !ro.intervals().empty())
676 os << indent << " <th> </th>\n";
678 if (!ro.intervals().empty()) {
679 for (MFRenderingOptions::IntervalSet::const_iterator
680 liItr = ro.intervals().begin(),
681 liEnd = ro.intervals().end();
682 liItr != liEnd; ++liItr) {
684 const LiveInterval *li = *liItr;
685 os << indent << " <th>\n";
686 renderVertical(indent + " ", os, li->reg);
687 os << indent << " </th>\n";
691 os << indent << " </tr>\n";
693 MachineInstr *mi = 0;
696 for (SlotIndex i = sis->getZeroIndex(); i != sis->getLastIndex();
697 i = i.getNextSlot()) {
699 os << indent << " <tr height=6ex>\n";
701 if (i.getSlot() == SlotIndex::LOAD) {
702 MachineBasicBlock *mbb = sis->getMBBFromIndex(i);
703 mi = sis->getInstructionFromIndex(i);
705 if (i == sis->getMBBStartIdx(mbb) || mi != 0 ||
706 ro.renderEmptyIndexes()) {
707 os << indent << " <td rowspan=4>" << i << " </td>\n"
708 << indent << " <td rowspan=4>\n";
710 if (i == sis->getMBBStartIdx(mbb)) {
711 os << indent << " BB#" << mbb->getNumber() << ": \n";
712 } else if (mi != 0) {
713 os << indent << " ";
714 renderMachineInstr(os, mi);
717 os << indent << " \n";
719 os << indent << " </td>\n";
721 i = i.getStoreIndex(); // <- Will be incremented to the next index.
726 if (!ro.regClasses().empty()) {
727 for (MFRenderingOptions::RegClassSet::const_iterator
728 rcItr = ro.regClasses().begin(),
729 rcEnd = ro.regClasses().end();
730 rcItr != rcEnd; ++rcItr) {
731 const TargetRegisterClass *trc = *rcItr;
733 os << indent << " <td class=\"";
735 if (trei.getPressureAtSlot(trc, i) == 0) {
737 } else if (trei.classOverCapacityAtSlot(trc, i)){
747 // FIXME: Is there a nicer way to insert space between columns in HTML?
748 if (!ro.regClasses().empty() && !ro.intervals().empty())
749 os << indent << " <td width=2em></td>\n";
751 if (!ro.intervals().empty()) {
752 for (MFRenderingOptions::IntervalSet::const_iterator
753 liItr = ro.intervals().begin(),
754 liEnd = ro.intervals().end();
755 liItr != liEnd; ++liItr) {
756 const LiveInterval *li = *liItr;
757 os << indent << " <td class=\"";
758 switch (getLiveStateAt(li, i)) {
759 case Dead: os << "l-na"; break;
760 case Defined: os << "l-def"; break;
761 case Used: os << "l-use"; break;
762 case AliveReg: os << "l-sar"; break;
763 case AliveStack: os << "l-sas"; break;
764 default: assert(false && "Unrecognised live state."); break;
769 os << indent << " </tr>\n";
772 os << indent << "</table>\n";
774 if (!ro.regClasses().empty())
775 renderPressureTableLegend(indent, os);
778 template <typename OStream>
779 void RenderMachineFunction::renderWarnings(const std::string &indent,
783 template <typename OStream>
784 void RenderMachineFunction::renderFunctionPage(
786 const char * const renderContextStr) const {
789 << " <title>" << fqn << "</title>\n";
796 renderFunctionSummary(" ", os, renderContextStr);
798 os << " <br/><br/><br/>\n";
800 //renderLiveIntervalInfoTable(" ", os);
802 os << " <br/><br/><br/>\n";
804 renderCodeTablePlusPI(" ", os);
810 void RenderMachineFunction::getAnalysisUsage(AnalysisUsage &au) const {
811 au.addRequired<SlotIndexes>();
812 au.addRequired<LiveIntervals>();
813 au.setPreservesAll();
814 MachineFunctionPass::getAnalysisUsage(au);
817 bool RenderMachineFunction::runOnMachineFunction(MachineFunction &fn) {
819 mri = &mf->getRegInfo();
820 tri = mf->getTarget().getRegisterInfo();
821 lis = &getAnalysis<LiveIntervals>();
822 sis = &getAnalysis<SlotIndexes>();
824 trei.setup(mf, mri, tri, lis);
825 ro.setup(mf, tri, lis);
827 fqn = mf->getFunction()->getParent()->getModuleIdentifier() + "." +
828 mf->getFunction()->getName().str();
833 void RenderMachineFunction::releaseMemory() {
838 void RenderMachineFunction::renderMachineFunction(
839 const char *renderContextStr,
840 const VirtRegMap *vrm,
841 const char *renderSuffix) {
842 if (!ro.shouldRenderCurrentMachineFunction())
848 std::string rpFileName(mf->getFunction()->getName().str() +
849 (renderSuffix ? renderSuffix : "") +
853 raw_fd_ostream outFile(rpFileName.c_str(), errMsg, raw_fd_ostream::F_Binary);
855 renderFunctionPage(outFile, renderContextStr);
857 ro.resetRenderSpecificOptions();
860 std::string RenderMachineFunction::escapeChars(const std::string &s) const {
861 return escapeChars(s.begin(), s.end());