30 #define DEBUG_TYPE "dag-printer"
44 return ((
const SDNode *) Node)->getNumValues();
48 return ((
const SDNode *) Node)->getValueType(i).getEVTString();
51 template<
typename EdgeIter>
59 template<
typename EdgeIter>
67 template<
typename EdgeIter>
90 template<
typename EdgeIter>
96 return "color=red,style=bold";
98 return "color=blue,style=dashed";
117 if (!Attrs.empty()) {
118 if (Attrs.find(
"shape=") == std::string::npos)
119 return std::string(
"shape=Mrecord,") + Attrs;
124 return "shape=Mrecord";
132 "color=blue,style=dashed");
152 errs() <<
"SelectionDAG::viewGraph is only available in debug builds on "
153 <<
"systems with Graphviz or gv!\n";
169 errs() <<
"SelectionDAG::clearGraphAttrs is only available in debug builds"
170 <<
" on systems with Graphviz or gv!\n";
181 errs() <<
"SelectionDAG::setGraphAttrs is only available in debug builds"
182 <<
" on systems with Graphviz or gv!\n";
191 std::map<const SDNode *, std::string>::const_iterator
I =
199 errs() <<
"SelectionDAG::getGraphAttrs is only available in debug builds"
200 <<
" on systems with Graphviz or gv!\n";
201 return std::string();
211 errs() <<
"SelectionDAG::setGraphColor is only available in debug builds"
212 <<
" on systems with Graphviz or gv!\n";
220 int level,
bool &printed) {
221 bool hit_limit =
false;
227 DEBUG(
dbgs() <<
"setSubgraphColor hit max level\n");
232 unsigned oldSize = visited.
size();
234 if (visited.
size() != oldSize) {
239 hit_limit = setSubgraphColorHelper(*i, Color, visited, level+1, printed) || hit_limit;
243 errs() <<
"SelectionDAG::setSubgraphColor is only available in debug builds"
244 <<
" on systems with Graphviz or gv!\n";
254 bool printed =
false;
255 if (setSubgraphColorHelper(N, Color, visited, 0, printed)) {
257 if (strcmp(Color,
"red") == 0) {
258 setSubgraphColorHelper(N,
"blue", visited, 0, printed);
259 }
else if (strcmp(Color,
"yellow") == 0) {
260 setSubgraphColorHelper(N,
"green", visited, 0, printed);
265 errs() <<
"SelectionDAG::setSubgraphColor is only available in debug builds"
266 <<
" on systems with Graphviz or gv!\n";
273 O <<
"SU(" << SU->
NodeNum <<
"): ";
278 while (!GluedNodes.
empty()) {
279 O << DOTGraphTraits<SelectionDAG*>
280 ::getSimpleNodeLabel(GluedNodes.
back(),
DAG);
282 if (!GluedNodes.
empty())
286 O <<
"CROSS RC COPY";
298 "color=blue,style=dashed");
static bool hasEdgeDestLabels()
void push_back(const T &Elt)
static bool edgeTargetsEdgeSource(const void *Node, EdgeIter I)
edgeTargetsEdgeSource - This method returns true if this outgoing edge should actually target another...
const std::string getGraphAttrs(const SDNode *N) const
Get graph attributes for a node.
raw_ostream & errs()
This returns a reference to a raw_ostream for standard error.
static std::string getSimpleNodeLabel(const SDNode *Node, const SelectionDAG *G)
static void addCustomGraphFeatures(SelectionDAG *G, GraphWriter< SelectionDAG * > &GW)
DenseSet - This implements a dense probed hash-table based set.
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
SDNode * getGluedNode() const
If this node has a glue operand, return the node to which the glue operand points.
virtual void getCustomGraphFeatures(GraphWriter< ScheduleDAG * > &GW) const
static bool hasNodeAddressLabel(const SDNode *Node, const SelectionDAG *Graph)
void setSubgraphColor(SDNode *N, const char *Color)
Convenience for setting subgraph color attribute.
const SDValue & getOperand(unsigned Num) const
static std::string getGraphName(const SelectionDAG *G)
static std::string getEdgeDestLabel(const void *Node, unsigned i)
unsigned getResNo() const
get the index which selects a specific result in the SDNode
This file declares the MachineConstantPool class which is an abstract constant pool to keep track of ...
MachineFunction & getMachineFunction() const
static void advance(T &it, size_t Val)
static unsigned numEdgeDestLabels(const void *Node)
static StringRef getName(Value *V)
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...
static SDNodeIterator begin(const SDNode *N)
bool LLVM_ATTRIBUTE_UNUSED_RESULT empty() const
std::string getOperationName(const SelectionDAG *G=nullptr) const
Return the opcode of this operation for printing.
SDNode * getNode() const
get the SDNode which holds the desired result
void setGraphColor(const SDNode *N, const char *Color)
Convenience for setting node color attribute.
SDNode * getNode() const
getNode - Return the representative SDNode for this SUnit.
This file contains the declarations for the subclasses of Constant, which represent the different fla...
void clearGraphAttrs()
Clear all previously defined node graph attributes.
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 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.
const SDNode * getNode() const
EVT - Extended Value Type.
static std::string itostr(int64_t X)
static std::string getNodeAttributes(const SDNode *N, const SelectionDAG *Graph)
std::string & str()
Flushes the stream contents to the target string and returns the string's reference.
const SDValue & getRoot() const
Return the root tag of the SelectionDAG.
DOTGraphTraits - Template class that can be specialized to customize how graphs are converted to 'dot...
std::pair< iterator, bool > insert(const ValueT &V)
Color
A "color", which is either even or odd.
DOTGraphTraits(bool isSimple=false)
This is used to represent a portion of an LLVM function in a low-level Data Dependence DAG representa...
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
static EdgeIter getEdgeTarget(const void *Node, EdgeIter I)
getEdgeTarget - If edgeTargetsEdgeSource returns true, this method is called to determine which outgo...
Represents one node in the SelectionDAG.
void print_details(raw_ostream &OS, const SelectionDAG *G) const
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
std::string getGraphNodeLabel(const SUnit *SU) const override
getGraphNodeLabel - Return a label for an SUnit node in a visualization of the ScheduleDAG.
std::map< const SDNode *, std::string > NodeGraphAttrs
static bool renderGraphFromBottomUp()
int getNodeId() const
Return the unique node id.
EVT getValueType() const
Return the ValueType of the referenced return value.
void setGraphAttrs(const SDNode *N, const char *Attrs)
Set graph attributes for a node. (eg. "color=red".)
A raw_ostream that writes to an std::string.
static SDNodeIterator end(const SDNode *N)
DefaultDOTGraphTraits - This class provides the default implementations of all of the DOTGraphTraits ...
StringRef getName() const
getName - Return the name of the corresponding LLVM function.
std::vector< SUnit > SUnits
Unlike LLVM values, Selection DAG nodes may return multiple values as the result of a computation...
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...
SUnit - Scheduling unit. This is a node in the scheduling DAG.