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";
97 else if (VT == MVT::Other)
98 return "color=blue,style=dashed";
104 if (
Node->isMachineOpcode())
105 return Node->getMachineOpcode();
106 return Node->getOpcode();
111 std::string Result =
Node->getOperationName(
G);
114 Node->print_details(OS,
G);
122 const std::string OpcodeAttrs =
124 "\",llvm_is_machine_opcode=\"" +
125 (
N->isMachineOpcode() ?
"true\"" :
"false\"");
128 const std::string &Attrs =
Graph->getGraphAttrs(
N);
129 if (!Attrs.empty()) {
130 if (Attrs.find(
"shape=") == std::string::npos)
131 return std::string(
"shape=Mrecord,") + OpcodeAttrs +
"," + Attrs;
133 return Attrs +
"," + OpcodeAttrs;
136 return std::string(
"shape=Mrecord,") + OpcodeAttrs;
142 if (
G->getRoot().getNode())
143 GW.
emitEdge(
nullptr, -1,
G->getRoot().getNode(),
144 G->getRoot().getResNo(),
"color=blue,style=dashed");
164 errs() <<
"SelectionDAG::viewGraph is only available in debug builds on "
165 <<
"systems with Graphviz or gv!\n";
182#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
184 const Twine &Title) {
192#if LLVM_ENABLE_ABI_BREAKING_CHECKS
193 NodeGraphAttrs.clear();
195 errs() <<
"SelectionDAG::clearGraphAttrs 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 NodeGraphAttrs[
N] = Attrs;
207 errs() <<
"SelectionDAG::setGraphAttrs is only available in builds with "
208 <<
"ABI breaking checks enabled on systems with Graphviz or gv!\n";
216#if LLVM_ENABLE_ABI_BREAKING_CHECKS
217 std::map<const SDNode *, std::string>::const_iterator
I =
218 NodeGraphAttrs.find(
N);
220 if (
I != NodeGraphAttrs.end())
225 errs() <<
"SelectionDAG::getGraphAttrs is only available in builds with "
226 <<
"ABI breaking checks enabled on systems with Graphviz or gv!\n";
227 return std::string();
234#if LLVM_ENABLE_ABI_BREAKING_CHECKS
235 NodeGraphAttrs[
N] = std::string(
"color=") + Color;
237 errs() <<
"SelectionDAG::setGraphColor is only available in builds with "
238 <<
"ABI breaking checks enabled on systems with Graphviz or gv!\n";
246 int level,
bool &printed) {
247 bool hit_limit =
false;
258 unsigned oldSize = visited.
size();
260 if (visited.
size() != oldSize) {
265 hit_limit = setSubgraphColorHelper(*i, Color, visited, level+1, printed) || hit_limit;
269 errs() <<
"SelectionDAG::setSubgraphColor is only available in debug builds"
270 <<
" on systems with Graphviz or gv!\n";
280 bool printed =
false;
281 if (setSubgraphColorHelper(
N, Color, visited, 0, printed)) {
283 if (strcmp(Color,
"red") == 0) {
284 setSubgraphColorHelper(
N,
"blue", visited, 0, printed);
285 }
else if (strcmp(Color,
"yellow") == 0) {
286 setSubgraphColorHelper(
N,
"green", visited, 0, printed);
291 errs() <<
"SelectionDAG::setSubgraphColor is only available in debug builds"
292 <<
" on systems with Graphviz or gv!\n";
296#if !defined(NDEBUG) && LLVM_ENABLE_ABI_BREAKING_CHECKS
297std::string ScheduleDAGSDNodes::getGraphNodeLabel(
const SUnit *SU)
const {
305 while (!GluedNodes.
empty()) {
306 O << DOTGraphTraits<SelectionDAG*>
307 ::getSimpleNodeLabel(GluedNodes.
back(),
DAG);
309 if (!GluedNodes.
empty())
313 O <<
"CROSS RC COPY";
324 if (
N &&
N->getNodeId() != -1)
326 "color=blue,style=dashed");
#define LLVM_DUMP_METHOD
Mark debug helper function definitions like dump() that should not be stripped from debug builds.
This file defines the DenseSet and SmallDenseSet classes.
static StringRef getName(Value *V)
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
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)
static SDNodeIterator begin(const SDNode *N)
Represents one node in the SelectionDAG.
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.
SDNode * getNode() const
Returns the representative SDNode for this SUnit.
virtual void getCustomGraphFeatures(GraphWriter< ScheduleDAG * > &GW) const
std::vector< SUnit > SUnits
The scheduling units.
This is used to represent a portion of an LLVM function in a low-level Data Dependence DAG representa...
LLVM_ABI void setGraphAttrs(const SDNode *N, const char *Attrs)
Set graph attributes for a node. (eg. "color=red".)
LLVM_ABI void setGraphColor(const SDNode *N, const char *Color)
Convenience for setting node color attribute.
LLVM_ABI void viewGraph()
LLVM_ABI std::string getGraphAttrs(const SDNode *N) const
Get graph attributes for a node.
MachineFunction & getMachineFunction() const
LLVM_ABI void clearGraphAttrs()
Clear all previously defined node graph attributes.
LLVM_ABI void setSubgraphColor(SDNode *N, const char *Color)
Convenience for setting subgraph color attribute.
LLVM_DUMP_METHOD void dumpDotGraph(const Twine &FileName, const Twine &Title)
Just dump dot graph to a user-provided path and title.
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
std::pair< iterator, bool > insert(const ValueT &V)
A raw_ostream that writes to an std::string.
This is an optimization pass for GlobalISel generic memory operations.
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 utostr(uint64_t X, bool isNeg=false)
LLVM_ABI raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
LLVM_ABI raw_fd_ostream & errs()
This returns a reference to a raw_ostream for standard error.
DWARFExpression::Operation Op
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::string itostr(int64_t X)
std::string getNodeLabel(const SDNode *Node, const SelectionDAG *Graph)
static std::string getGraphName(const SelectionDAG *G)
static unsigned numEdgeDestLabels(const void *Node)
DOTGraphTraits(bool isSimple=false)
static std::string getEdgeSourceLabel(const void *Node, EdgeIter I)
static bool edgeTargetsEdgeSource(const void *Node, EdgeIter I)
edgeTargetsEdgeSource - This method returns true if this outgoing edge should actually target another...
static unsigned getRawNodeOpcode(const SDNode *Node)
Return the opcode from its SelectionDAG or machine-opcode domain.
static bool hasEdgeDestLabels()
static void addCustomGraphFeatures(SelectionDAG *G, GraphWriter< SelectionDAG * > &GW)
static std::string getNodeAttributes(const SDNode *N, const SelectionDAG *Graph)
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.
static std::string getSimpleNodeLabel(const SDNode *Node, const SelectionDAG *G)
static EdgeIter getEdgeTarget(const void *Node, EdgeIter I)
getEdgeTarget - If edgeTargetsEdgeSource returns true, this method is called to determine which outgo...
static bool renderGraphFromBottomUp()
static std::string getNodeIdentifierLabel(const SDNode *Node, const SelectionDAG *Graph)
static std::string getEdgeDestLabel(const void *Node, unsigned i)
DOTGraphTraits - Template class that can be specialized to customize how graphs are converted to 'dot...
DefaultDOTGraphTraits(bool simple=false)
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...