diff options
author | Andrew Trick <atrick@apple.com> | 2013-01-25 07:45:25 +0000 |
---|---|---|
committer | Andrew Trick <atrick@apple.com> | 2013-01-25 07:45:25 +0000 |
commit | c6ada8e5f38168f13830e448f2b9e2d8e3eac72b (patch) | |
tree | 4ea636736947bf200b145430436b821c5a4c50f8 /include/llvm/Support | |
parent | a5a73ad15905c18843a8312bb3f20f5c501744de (diff) |
ScheduleDAG: colorize the DOT graph and improve formatting.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@173431 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/Support')
-rw-r--r-- | include/llvm/Support/DOTGraphTraits.h | 5 | ||||
-rw-r--r-- | include/llvm/Support/GraphWriter.h | 12 |
2 files changed, 17 insertions, 0 deletions
diff --git a/include/llvm/Support/DOTGraphTraits.h b/include/llvm/Support/DOTGraphTraits.h index 483f2674af..95e37c01d7 100644 --- a/include/llvm/Support/DOTGraphTraits.h +++ b/include/llvm/Support/DOTGraphTraits.h @@ -79,6 +79,11 @@ public: return false; } + template<typename GraphType> + static std::string getNodeDescription(const void *, const GraphType &) { + return ""; + } + /// If you want to specify custom node attributes, this is the place to do so /// template<typename GraphType> diff --git a/include/llvm/Support/GraphWriter.h b/include/llvm/Support/GraphWriter.h index 30cfe6124b..22181d4e1d 100644 --- a/include/llvm/Support/GraphWriter.h +++ b/include/llvm/Support/GraphWriter.h @@ -34,6 +34,10 @@ namespace llvm { namespace DOT { // Private functions... std::string EscapeString(const std::string &Label); + + /// \brief Get a color string for this node number. Simply round-robin selects + /// from a reasonable number of colors. + StringRef getColorString(unsigned NodeNumber); } namespace GraphProgram { @@ -173,6 +177,10 @@ public: // If we should include the address of the node in the label, do so now. if (DTraits.hasNodeAddressLabel(Node, G)) O << "|" << static_cast<const void*>(Node); + + std::string NodeDesc = DTraits.getNodeDescription(Node, G); + if (!NodeDesc.empty()) + O << "|" << DOT::EscapeString(NodeDesc); } std::string edgeSourceLabels; @@ -193,6 +201,10 @@ public: // If we should include the address of the node in the label, do so now. if (DTraits.hasNodeAddressLabel(Node, G)) O << "|" << static_cast<const void*>(Node); + + std::string NodeDesc = DTraits.getNodeDescription(Node, G); + if (!NodeDesc.empty()) + O << "|" << DOT::EscapeString(NodeDesc); } if (DTraits.hasEdgeDestLabels()) { |