Go to the documentation of this file.
23 #define DEBUG_TYPE "dag-printer"
37 return ((
const SDNode *) Node)->getNumValues();
41 return ((
const SDNode *) Node)->getValueType(
i).getEVTString();
44 template<
typename EdgeIter>
52 template<
typename EdgeIter>
60 template<
typename EdgeIter>
64 std::advance(NI,
I.getNode()->getOperand(
I.getOperand()).getResNo());
69 return std::string(
G->getMachineFunction().getName());
81 OS <<
't' << Node->PersistentId;
83 OS << static_cast<const void *>(Node);
90 template<
typename EdgeIter>
93 SDValue Op = EI.getNode()->getOperand(EI.getOperand());
94 EVT VT =
Op.getValueType();
96 return "color=red,style=bold";
98 return "color=blue,style=dashed";
105 std::string Result = Node->getOperationName(
G);
108 Node->print_details(OS,
G);
118 if (
Attrs.find(
"shape=") == std::string::npos)
119 return std::string(
"shape=Mrecord,") +
Attrs;
124 return "shape=Mrecord";
130 if (
G->getRoot().getNode())
131 GW.
emitEdge(
nullptr, -1,
G->getRoot().getNode(),
G->getRoot().getResNo(),
132 "color=blue,style=dashed");
152 errs() <<
"SelectionDAG::viewGraph is only available in debug builds on "
153 <<
"systems with Graphviz or gv!\n";
170 #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
172 const Twine &Title) {
180 #if LLVM_ENABLE_ABI_BREAKING_CHECKS
181 NodeGraphAttrs.clear();
183 errs() <<
"SelectionDAG::clearGraphAttrs is only available in builds with "
184 <<
"ABI breaking checks enabled on systems with Graphviz or gv!\n";
192 #if LLVM_ENABLE_ABI_BREAKING_CHECKS
193 NodeGraphAttrs[
N] =
Attrs;
195 errs() <<
"SelectionDAG::setGraphAttrs is only available in builds with "
196 <<
"ABI breaking checks enabled on systems with Graphviz or gv!\n";
204 #if LLVM_ENABLE_ABI_BREAKING_CHECKS
205 std::map<const SDNode *, std::string>::const_iterator
I =
206 NodeGraphAttrs.find(
N);
208 if (
I != NodeGraphAttrs.end())
213 errs() <<
"SelectionDAG::getGraphAttrs is only available in builds with "
214 <<
"ABI breaking checks enabled on systems with Graphviz or gv!\n";
215 return std::string();
222 #if LLVM_ENABLE_ABI_BREAKING_CHECKS
223 NodeGraphAttrs[
N] = std::string(
"color=") + Color;
225 errs() <<
"SelectionDAG::setGraphColor is only available in builds with "
226 <<
"ABI breaking checks enabled on systems with Graphviz or gv!\n";
234 int level,
bool &printed) {
235 bool hit_limit =
false;
246 unsigned oldSize = visited.
size();
248 if (visited.
size() != oldSize) {
253 hit_limit = setSubgraphColorHelper(*
i, Color, visited, level+1, printed) || hit_limit;
257 errs() <<
"SelectionDAG::setSubgraphColor is only available in debug builds"
258 <<
" on systems with Graphviz or gv!\n";
268 bool printed =
false;
269 if (setSubgraphColorHelper(
N, Color, visited, 0, printed)) {
271 if (strcmp(Color,
"red") == 0) {
272 setSubgraphColorHelper(
N,
"blue", visited, 0, printed);
273 }
else if (strcmp(Color,
"yellow") == 0) {
274 setSubgraphColorHelper(
N,
"green", visited, 0, printed);
279 errs() <<
"SelectionDAG::setSubgraphColor is only available in debug builds"
280 <<
" on systems with Graphviz or gv!\n";
291 GluedNodes.push_back(
N);
292 while (!GluedNodes.empty()) {
293 O << DOTGraphTraits<SelectionDAG*>
294 ::getSimpleNodeLabel(GluedNodes.back(),
DAG);
295 GluedNodes.pop_back();
296 if (!GluedNodes.empty())
300 O <<
"CROSS RC COPY";
310 if (
N &&
N->getNodeId() != -1)
312 "color=blue,style=dashed");
static EdgeIter getEdgeTarget(const void *Node, EdgeIter I)
getEdgeTarget - If edgeTargetsEdgeSource returns true, this method is called to determine which outgo...
static StringRef getName(Value *V)
#define LLVM_DUMP_METHOD
Mark debug helper function definitions like dump() that should not be stripped from debug builds.
This is an optimization pass for GlobalISel generic memory operations.
static bool renderGraphFromBottomUp()
static std::string getEdgeAttributes(const void *Node, EdgeIter EI, const SelectionDAG *Graph)
If you want to override the dot attributes printed for a particular edge, override this method.
void setSubgraphColor(SDNode *N, const char *Color)
Convenience for setting subgraph color attribute.
void setGraphColor(const SDNode *N, const char *Color)
Convenience for setting node color attribute.
SDNode * getNode() const
get the SDNode which holds the desired result
A raw_ostream that writes to an std::string.
void setGraphAttrs(const SDNode *N, const char *Attrs)
Set graph attributes for a node. (eg. "color=red".)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
const SDValue & getRoot() const
Return the root tag of the SelectionDAG.
Represents one node in the SelectionDAG.
virtual void getCustomGraphFeatures(GraphWriter< ScheduleDAG * > &GW) const
static std::string getNodeIdentifierLabel(const SDNode *Node, const SelectionDAG *Graph)
raw_fd_ostream & errs()
This returns a reference to a raw_ostream for standard error.
void ViewGraph(const GraphType &G, const Twine &Name, bool ShortNames=false, const Twine &Title="", GraphProgram::Name Program=GraphProgram::DOT)
ViewGraph - Emit a dot graph, run 'dot', run gv on the postscript file, then cleanup.
std::pair< iterator, bool > insert(const ValueT &V)
static bool edgeTargetsEdgeSource(const void *Node, EdgeIter I)
edgeTargetsEdgeSource - This method returns true if this outgoing edge should actually target another...
static SDNodeIterator begin(const SDNode *N)
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
This is used to represent a portion of an LLVM function in a low-level Data Dependence DAG representa...
unsigned NodeNum
Entry # of node in the node vector.
std::string getGraphNodeLabel(const SUnit *SU) const override
Returns a label for an SUnit node in a visualization of the ScheduleDAG.
static std::string getGraphName(const SelectionDAG *G)
static std::string getEdgeDestLabel(const void *Node, unsigned i)
DOTGraphTraits - Template class that can be specialized to customize how graphs are converted to 'dot...
Implements a dense probed hash-table based set.
multiplies can be turned into SHL s
LLVM_DUMP_METHOD void dumpDotGraphToFile(const GraphType &G, const Twine &FileName, const Twine &Title, bool ShortNames=false, const Twine &Name="")
DumpDotGraph - Just dump a dot graph to the user-provided file name.
std::string getGraphAttrs(const SDNode *N) const
Get graph attributes for a node.
static std::string getSimpleNodeLabel(const SDNode *Node, const SelectionDAG *G)
static void addCustomGraphFeatures(SelectionDAG *G, GraphWriter< SelectionDAG * > &GW)
static bool hasEdgeDestLabels()
void clearGraphAttrs()
Clear all previously defined node graph attributes.
void emitSimpleNode(const void *ID, const std::string &Attr, const std::string &Label, unsigned NumEdgeSources=0, const std::vector< std::string > *EdgeSourceLabels=nullptr)
emitSimpleNode - Outputs a simple (non-record) node
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
std::vector< SUnit > SUnits
The scheduling units.
SDNode * getNode() const
Returns the representative SDNode for this SUnit.
LLVM_DUMP_METHOD void dumpDotGraph(const Twine &FileName, const Twine &Title)
Just dump dot graph to a user-provided path and title.
Unlike LLVM values, Selection DAG nodes may return multiple values as the result of a computation.
static bool isSimple(Instruction *I)
DOTGraphTraits(bool isSimple=false)
static unsigned numEdgeDestLabels(const void *Node)
static std::string getEdgeSourceLabel(const void *Node, EdgeIter I)
std::string getNodeLabel(const void *, const GraphType &)
getNodeLabel - Given a node and a pointer to the top level graph, return the label to print in the no...
DefaultDOTGraphTraits - This class provides the default implementations of all of the DOTGraphTraits ...
static std::string getNodeAttributes(const SDNode *N, const SelectionDAG *Graph)
static std::string getNodeLabel(const ValueInfo &VI, GlobalValueSummary *GVS)
Scheduling unit. This is a node in the scheduling DAG.
MachineFunction & getMachineFunction() const
void emitEdge(const void *SrcNodeID, int SrcNodePort, const void *DestNodeID, int DestNodePort, const std::string &Attrs)
emitEdge - Output an edge from a simple node into the graph...
static SDNodeIterator end(const SDNode *N)