28 #define DEBUG_TYPE "dag-printer" 42 return ((
const SDNode *) Node)->getNumValues();
46 return ((
const SDNode *) Node)->getValueType(i).getEVTString();
49 template<
typename EdgeIter>
57 template<
typename EdgeIter>
65 template<
typename EdgeIter>
88 OS << static_cast<const void *>(Node);
95 template<
typename EdgeIter>
98 SDValue Op = EI.getNode()->getOperand(EI.getOperand());
101 return "color=red,style=bold";
103 return "color=blue,style=dashed";
122 if (!Attrs.empty()) {
123 if (Attrs.find(
"shape=") == std::string::npos)
124 return std::string(
"shape=Mrecord,") +
Attrs;
129 return "shape=Mrecord";
137 "color=blue,style=dashed");
157 errs() <<
"SelectionDAG::viewGraph is only available in debug builds on " 158 <<
"systems with Graphviz or gv!\n";
172 NodeGraphAttrs.clear();
174 errs() <<
"SelectionDAG::clearGraphAttrs is only available in debug builds" 175 <<
" on systems with Graphviz or gv!\n";
184 NodeGraphAttrs[
N] =
Attrs;
186 errs() <<
"SelectionDAG::setGraphAttrs is only available in debug builds" 187 <<
" on systems with Graphviz or gv!\n";
196 std::map<const SDNode *, std::string>::const_iterator
I =
197 NodeGraphAttrs.find(N);
199 if (I != NodeGraphAttrs.end())
204 errs() <<
"SelectionDAG::getGraphAttrs is only available in debug builds" 205 <<
" on systems with Graphviz or gv!\n";
206 return std::string();
214 NodeGraphAttrs[
N] = std::string(
"color=") +
Color;
216 errs() <<
"SelectionDAG::setGraphColor is only available in debug builds" 217 <<
" on systems with Graphviz or gv!\n";
225 int level,
bool &printed) {
226 bool hit_limit =
false;
237 unsigned oldSize = visited.
size();
239 if (visited.
size() != oldSize) {
240 setGraphColor(N, Color);
244 hit_limit = setSubgraphColorHelper(*i, Color, visited, level+1, printed) || hit_limit;
248 errs() <<
"SelectionDAG::setSubgraphColor is only available in debug builds" 249 <<
" on systems with Graphviz or gv!\n";
259 bool printed =
false;
260 if (setSubgraphColorHelper(N, Color, visited, 0, printed)) {
262 if (strcmp(Color,
"red") == 0) {
263 setSubgraphColorHelper(N,
"blue", visited, 0, printed);
264 }
else if (strcmp(Color,
"yellow") == 0) {
265 setSubgraphColorHelper(N,
"green", visited, 0, printed);
270 errs() <<
"SelectionDAG::setSubgraphColor is only available in debug builds" 271 <<
" on systems with Graphviz or gv!\n";
278 O <<
"SU(" << SU->
NodeNum <<
"): ";
283 while (!GluedNodes.
empty()) {
284 O << DOTGraphTraits<SelectionDAG*>
285 ::getSimpleNodeLabel(GluedNodes.
back(), DAG);
287 if (!GluedNodes.
empty())
291 O <<
"CROSS RC COPY";
300 const SDNode *N = DAG->getRoot().getNode();
303 "color=blue,style=dashed");
static bool hasEdgeDestLabels()
void push_back(const T &Elt)
EVT getValueType() const
Return the ValueType of the referenced return value.
static bool edgeTargetsEdgeSource(const void *Node, EdgeIter I)
edgeTargetsEdgeSource - This method returns true if this outgoing edge should actually target another...
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
raw_ostream & errs()
This returns a reference to a raw_ostream for standard error.
static std::string getSimpleNodeLabel(const SDNode *Node, const SelectionDAG *G)
std::string getOperationName(const SelectionDAG *G=nullptr) const
Return the opcode of this operation for printing.
Compute iterated dominance frontiers using a linear time algorithm.
SDNode * getNode() const
Returns the representative SDNode for this SUnit.
Implements a dense probed hash-table based set.
const std::string getGraphAttrs(const SDNode *N) const
Get graph attributes for a node.
const SDNode * getNode() const
void print_details(raw_ostream &OS, const SelectionDAG *G) const
virtual void getCustomGraphFeatures(GraphWriter< ScheduleDAG *> &GW) const
void setSubgraphColor(SDNode *N, const char *Color)
Convenience for setting subgraph color attribute.
static std::string getGraphName(const SelectionDAG *G)
SDNode * getNode() const
get the SDNode which holds the desired result
static std::string getEdgeDestLabel(const void *Node, unsigned i)
uint16_t PersistentId
Unique and persistent id per SDNode in the DAG.
This file declares the MachineConstantPool class which is an abstract constant pool to keep track of ...
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 bool isSimple(Instruction *I)
MachineFunction & getMachineFunction() const
static SDNodeIterator begin(const SDNode *N)
std::string itostr(int64_t X)
constexpr char Attrs[]
Key for Kernel::Metadata::mAttrs.
StringRef getName() const
getName - Return the name of the corresponding LLVM function.
void setGraphColor(const SDNode *N, const char *Color)
Convenience for setting node color attribute.
static std::string getNodeIdentifierLabel(const SDNode *Node, const SelectionDAG *Graph)
const SDValue & getOperand(unsigned Num) const
This file contains the declarations for the subclasses of Constant, which represent the different fla...
std::pair< iterator, bool > insert(const ValueT &V)
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...
SDNode * getGluedNode() const
If this node has a glue operand, return the node to which the glue operand points.
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.
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.
DOTGraphTraits - Template class that can be specialized to customize how graphs are converted to 'dot...
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.
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
static void addCustomGraphFeatures(SelectionDAG *G, GraphWriter< SelectionDAG *> &GW)
std::string getGraphNodeLabel(const SUnit *SU) const override
Returns a label for an SUnit node in a visualization of the ScheduleDAG.
int getNodeId() const
Return the unique node id.
LLVM_NODISCARD bool empty() const
static std::string getNodeLabel(const ValueInfo &VI, GlobalValueSummary *GVS)
static bool renderGraphFromBottomUp()
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...
const SDValue & getRoot() const
Return the root tag of the SelectionDAG.
unsigned NodeNum
Entry # of node in the node vector.
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.
unsigned getResNo() const
get the index which selects a specific result in the SDNode
static SDNodeIterator end(const SDNode *N)
DefaultDOTGraphTraits - This class provides the default implementations of all of the DOTGraphTraits ...
Unlike LLVM values, Selection DAG nodes may return multiple values as the result of a computation...
Scheduling unit. This is a node in the scheduling DAG.