llvm.org GIT mirror llvm / df6c8ef
SelectionDAG: add a -filter-view-dags option to llc This option takes the name of the basic block you want to visualize with -view-*-dags Differential Revision: http://reviews.llvm.org/D6948 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@225953 91177308-0d34-0410-b5e6-96231b3b80d8 Mehdi Amini 4 years ago
2 changed file(s) with 30 addition(s) and 11 deletion(s). Raw diff Collapse all Expand all
463463 mov %EAX, %EDX
464464 sar %EDX, 31
465465 idiv %ECX
466 ret
466 ret
467467
468468 This approach is extremely general (if it can handle the X86 architecture, it
469469 can handle anything!) and allows all of the target specific knowledge about the
847847 bundled into a single scheduling-unit node, and with immediate operands and
848848 other nodes that aren't relevant for scheduling omitted.
849849
850 The option ``-filter-view-dags`` allows to select the name of the basic block
851 that you are interested to visualize and filters all the previous
852 ``view-*-dags`` options.
853
850854 .. _Build initial DAG:
851855
852856 Initial SelectionDAG Construction
182182 cl::init(true), cl::Hidden);
183183
184184 #ifndef NDEBUG
185 static cl::opt
186 FilterDAGBasicBlockName("filter-view-dags", cl::Hidden,
187 cl::desc("Only display the basic block whose name "
188 "matches this for all view-*-dags options"));
185189 static cl::opt
186190 ViewDAGCombine1("view-dag-combine1-dags", cl::Hidden,
187191 cl::desc("Pop up a window to show dags before the first "
651655 std::string BlockName;
652656 int BlockNumber = -1;
653657 (void)BlockNumber;
658 bool MatchFilterBB = false; (void)MatchFilterBB;
659 #ifndef NDEBUG
660 MatchFilterBB = (!FilterDAGBasicBlockName.empty() &&
661 FilterDAGBasicBlockName ==
662 FuncInfo->MBB->getBasicBlock()->getName().str());
663 #endif
654664 #ifdef NDEBUG
655665 if (ViewDAGCombine1 || ViewLegalizeTypesDAGs || ViewLegalizeDAGs ||
656666 ViewDAGCombine2 || ViewDAGCombineLT || ViewISelDAGs || ViewSchedDAGs ||
664674 DEBUG(dbgs() << "Initial selection DAG: BB#" << BlockNumber
665675 << " '" << BlockName << "'\n"; CurDAG->dump());
666676
667 if (ViewDAGCombine1) CurDAG->viewGraph("dag-combine1 input for " + BlockName);
677 if (ViewDAGCombine1 && MatchFilterBB)
678 CurDAG->viewGraph("dag-combine1 input for " + BlockName);
668679
669680 // Run the DAG combiner in pre-legalize mode.
670681 {
677688
678689 // Second step, hack on the DAG until it only uses operations and types that
679690 // the target supports.
680 if (ViewLegalizeTypesDAGs) CurDAG->viewGraph("legalize-types input for " +
681 BlockName);
691 if (ViewLegalizeTypesDAGs && MatchFilterBB)
692 CurDAG->viewGraph("legalize-types input for " + BlockName);
682693
683694 bool Changed;
684695 {
692703 CurDAG->NewNodesMustHaveLegalTypes = true;
693704
694705 if (Changed) {
695 if (ViewDAGCombineLT)
706 if (ViewDAGCombineLT && MatchFilterBB)
696707 CurDAG->viewGraph("dag-combine-lt input for " + BlockName);
697708
698709 // Run the DAG combiner in post-type-legalize mode.
718729 CurDAG->LegalizeTypes();
719730 }
720731
721 if (ViewDAGCombineLT)
732 if (ViewDAGCombineLT && MatchFilterBB)
722733 CurDAG->viewGraph("dag-combine-lv input for " + BlockName);
723734
724735 // Run the DAG combiner in post-type-legalize mode.
732743 << BlockNumber << " '" << BlockName << "'\n"; CurDAG->dump());
733744 }
734745
735 if (ViewLegalizeDAGs) CurDAG->viewGraph("legalize input for " + BlockName);
746 if (ViewLegalizeDAGs && MatchFilterBB)
747 CurDAG->viewGraph("legalize input for " + BlockName);
736748
737749 {
738750 NamedRegionTimer T("DAG Legalization", GroupName, TimePassesIsEnabled);
742754 DEBUG(dbgs() << "Legalized selection DAG: BB#" << BlockNumber
743755 << " '" << BlockName << "'\n"; CurDAG->dump());
744756
745 if (ViewDAGCombine2) CurDAG->viewGraph("dag-combine2 input for " + BlockName);
757 if (ViewDAGCombine2 && MatchFilterBB)
758 CurDAG->viewGraph("dag-combine2 input for " + BlockName);
746759
747760 // Run the DAG combiner in post-legalize mode.
748761 {
756769 if (OptLevel != CodeGenOpt::None)
757770 ComputeLiveOutVRegInfo();
758771
759 if (ViewISelDAGs) CurDAG->viewGraph("isel input for " + BlockName);
772 if (ViewISelDAGs && MatchFilterBB)
773 CurDAG->viewGraph("isel input for " + BlockName);
760774
761775 // Third, instruction select all of the operations to machine code, adding the
762776 // code to the MachineBasicBlock.
768782 DEBUG(dbgs() << "Selected selection DAG: BB#" << BlockNumber
769783 << " '" << BlockName << "'\n"; CurDAG->dump());
770784
771 if (ViewSchedDAGs) CurDAG->viewGraph("scheduler input for " + BlockName);
785 if (ViewSchedDAGs && MatchFilterBB)
786 CurDAG->viewGraph("scheduler input for " + BlockName);
772787
773788 // Schedule machine code.
774789 ScheduleDAGSDNodes *Scheduler = CreateScheduler();
778793 Scheduler->Run(CurDAG, FuncInfo->MBB);
779794 }
780795
781 if (ViewSUnitDAGs) Scheduler->viewGraph();
796 if (ViewSUnitDAGs && MatchFilterBB) Scheduler->viewGraph();
782797
783798 // Emit machine code to BB. This can change 'BB' to the last block being
784799 // inserted into.