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 OS << static_cast<const void *>(Node);
97 template<
typename EdgeIter>
100 SDValue Op = EI.getNode()->getOperand(EI.getOperand());
103 return "color=red,style=bold";
105 return "color=blue,style=dashed";
124 if (!Attrs.empty()) {
125 if (Attrs.find(
"shape=") == std::string::npos)
126 return std::string(
"shape=Mrecord,") + Attrs;
131 return "shape=Mrecord";
139 "color=blue,style=dashed");
159 errs() <<
"SelectionDAG::viewGraph is only available in debug builds on "
160 <<
"systems with Graphviz or gv!\n";
176 errs() <<
"SelectionDAG::clearGraphAttrs is only available in debug builds"
177 <<
" on systems with Graphviz or gv!\n";
188 errs() <<
"SelectionDAG::setGraphAttrs is only available in debug builds"
189 <<
" on systems with Graphviz or gv!\n";
198 std::map<const SDNode *, std::string>::const_iterator
I =
206 errs() <<
"SelectionDAG::getGraphAttrs is only available in debug builds"
207 <<
" on systems with Graphviz or gv!\n";
208 return std::string();
218 errs() <<
"SelectionDAG::setGraphColor is only available in debug builds"
219 <<
" on systems with Graphviz or gv!\n";
227 int level,
bool &printed) {
228 bool hit_limit =
false;
234 DEBUG(
dbgs() <<
"setSubgraphColor hit max level\n");
239 unsigned oldSize = visited.
size();
241 if (visited.
size() != oldSize) {
246 hit_limit = setSubgraphColorHelper(*
i, Color, visited, level+1, printed) || hit_limit;
250 errs() <<
"SelectionDAG::setSubgraphColor is only available in debug builds"
251 <<
" on systems with Graphviz or gv!\n";
261 bool printed =
false;
262 if (setSubgraphColorHelper(N, Color, visited, 0, printed)) {
264 if (
strcmp(Color,
"red") == 0) {
265 setSubgraphColorHelper(N,
"blue", visited, 0, printed);
266 }
else if (
strcmp(Color,
"yellow") == 0) {
267 setSubgraphColorHelper(N,
"green", visited, 0, printed);
272 errs() <<
"SelectionDAG::setSubgraphColor is only available in debug builds"
273 <<
" on systems with Graphviz or gv!\n";
280 O <<
"SU(" << SU->
NodeNum <<
"): ";
285 while (!GluedNodes.
empty()) {
286 O << DOTGraphTraits<SelectionDAG*>
287 ::getSimpleNodeLabel(GluedNodes.
back(),
DAG);
289 if (!GluedNodes.
empty())
293 O <<
"CROSS RC COPY";
305 "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)
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
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)
Maximum length of the test input libFuzzer tries to guess a good value based on the corpus and reports it always prefer smaller inputs during the corpus shuffle When libFuzzer itself reports a bug this exit code will be used If indicates the maximal total time in seconds to run the fuzzer minimizes the provided crash input Use with strcmp
uint16_t PersistentId
Unique and persistent id per SDNode in the DAG.
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)
LLVM_NODISCARD bool empty() const
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)
static SDNodeIterator begin(const SDNode *N)
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.
static std::string getNodeIdentifierLabel(const SDNode *Node, const SelectionDAG *Graph)
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...
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...
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.