//===-- SelectionDAGPrinter.cpp - Implement SelectionDAG::viewGraph() -----===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // // This implements the SelectionDAG::viewGraph method. // //===----------------------------------------------------------------------===// #include "ScheduleDAGSDNodes.h" #include "llvm/ADT/DenseSet.h" #include "llvm/ADT/StringExtras.h" #include "llvm/CodeGen/MachineFunction.h" #include "llvm/CodeGen/SelectionDAG.h" #include "llvm/Support/Debug.h" #include "llvm/Support/GraphWriter.h" #include "llvm/Support/raw_ostream.h" usingnamespacellvm; #define DEBUG_TYPE … namespace llvm { template<> struct DOTGraphTraits<SelectionDAG*> : public DefaultDOTGraphTraits { … }; } std::string DOTGraphTraits<SelectionDAG*>::getNodeLabel(const SDNode *Node, const SelectionDAG *G) { … } /// viewGraph - Pop up a ghostview window with the reachable parts of the DAG /// rendered using 'dot'. /// void SelectionDAG::viewGraph(const std::string &Title) { … } // This overload is defined out-of-line here instead of just using a // default parameter because this is easiest for gdb to call. void SelectionDAG::viewGraph() { … } /// Just dump dot graph to a user-provided path and title. /// This doesn't open the dot viewer program and /// helps visualization when outside debugging session. /// FileName expects absolute path. If provided /// without any path separators then the file /// will be created in the current directory. /// Error will be emitted if the path is insane. #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP) LLVM_DUMP_METHOD void SelectionDAG::dumpDotGraph(const Twine &FileName, const Twine &Title) { dumpDotGraphToFile(this, FileName, Title); } #endif /// clearGraphAttrs - Clear all previously defined node graph attributes. /// Intended to be used from a debugging tool (eg. gdb). void SelectionDAG::clearGraphAttrs() { … } /// setGraphAttrs - Set graph attributes for a node. (eg. "color=red".) /// void SelectionDAG::setGraphAttrs(const SDNode *N, const char *Attrs) { … } /// getGraphAttrs - Get graph attributes for a node. (eg. "color=red".) /// Used from getNodeAttributes. std::string SelectionDAG::getGraphAttrs(const SDNode *N) const { … } /// setGraphColor - Convenience for setting node color attribute. /// void SelectionDAG::setGraphColor(const SDNode *N, const char *Color) { … } /// setSubgraphColorHelper - Implement setSubgraphColor. Return /// whether we truncated the search. /// bool SelectionDAG::setSubgraphColorHelper(SDNode *N, const char *Color, DenseSet<SDNode *> &visited, int level, bool &printed) { … } /// setSubgraphColor - Convenience for setting subgraph color attribute. /// void SelectionDAG::setSubgraphColor(SDNode *N, const char *Color) { … } std::string ScheduleDAGSDNodes::getGraphNodeLabel(const SUnit *SU) const { … } void ScheduleDAGSDNodes::getCustomGraphFeatures(GraphWriter<ScheduleDAG*> &GW) const { … }