mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-08-09 11:25:55 +00:00
Add setSubgraphColor to color an entire portion of a SelectionDAG. This
will be used to support debug features in TableGen. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@58257 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -16,6 +16,7 @@
|
|||||||
#define LLVM_CODEGEN_SELECTIONDAG_H
|
#define LLVM_CODEGEN_SELECTIONDAG_H
|
||||||
|
|
||||||
#include "llvm/ADT/ilist.h"
|
#include "llvm/ADT/ilist.h"
|
||||||
|
#include "llvm/ADT/DenseSet.h"
|
||||||
#include "llvm/ADT/FoldingSet.h"
|
#include "llvm/ADT/FoldingSet.h"
|
||||||
#include "llvm/ADT/StringMap.h"
|
#include "llvm/ADT/StringMap.h"
|
||||||
#include "llvm/CodeGen/SelectionDAGNodes.h"
|
#include "llvm/CodeGen/SelectionDAGNodes.h"
|
||||||
@@ -102,6 +103,12 @@ class SelectionDAG {
|
|||||||
/// VerifyNode - Sanity check the given node. Aborts if it is invalid.
|
/// VerifyNode - Sanity check the given node. Aborts if it is invalid.
|
||||||
void VerifyNode(SDNode *N);
|
void VerifyNode(SDNode *N);
|
||||||
|
|
||||||
|
/// setGraphColorHelper - Implementation of setSubgraphColor.
|
||||||
|
/// Return whether we had to truncate the search.
|
||||||
|
///
|
||||||
|
bool setSubgraphColorHelper(SDNode *N, const char *Color, DenseSet<SDNode *> &visited,
|
||||||
|
int level, bool &printed);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
SelectionDAG(TargetLowering &tli, FunctionLoweringInfo &fli);
|
SelectionDAG(TargetLowering &tli, FunctionLoweringInfo &fli);
|
||||||
~SelectionDAG();
|
~SelectionDAG();
|
||||||
@@ -147,6 +154,10 @@ public:
|
|||||||
///
|
///
|
||||||
void setGraphColor(const SDNode *N, const char *Color);
|
void setGraphColor(const SDNode *N, const char *Color);
|
||||||
|
|
||||||
|
/// setGraphColor - Convenience for setting subgraph color attribute.
|
||||||
|
///
|
||||||
|
void setSubgraphColor(SDNode *N, const char *Color);
|
||||||
|
|
||||||
typedef ilist<SDNode>::const_iterator allnodes_const_iterator;
|
typedef ilist<SDNode>::const_iterator allnodes_const_iterator;
|
||||||
allnodes_const_iterator allnodes_begin() const { return AllNodes.begin(); }
|
allnodes_const_iterator allnodes_begin() const { return AllNodes.begin(); }
|
||||||
allnodes_const_iterator allnodes_end() const { return AllNodes.end(); }
|
allnodes_const_iterator allnodes_end() const { return AllNodes.end(); }
|
||||||
|
@@ -22,8 +22,10 @@
|
|||||||
#include "llvm/CodeGen/PseudoSourceValue.h"
|
#include "llvm/CodeGen/PseudoSourceValue.h"
|
||||||
#include "llvm/Target/TargetRegisterInfo.h"
|
#include "llvm/Target/TargetRegisterInfo.h"
|
||||||
#include "llvm/Target/TargetMachine.h"
|
#include "llvm/Target/TargetMachine.h"
|
||||||
|
#include "llvm/Support/Debug.h"
|
||||||
#include "llvm/Support/GraphWriter.h"
|
#include "llvm/Support/GraphWriter.h"
|
||||||
#include "llvm/Support/raw_ostream.h"
|
#include "llvm/Support/raw_ostream.h"
|
||||||
|
#include "llvm/ADT/DenseSet.h"
|
||||||
#include "llvm/ADT/StringExtras.h"
|
#include "llvm/ADT/StringExtras.h"
|
||||||
#include "llvm/Config/config.h"
|
#include "llvm/Config/config.h"
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
@@ -326,6 +328,61 @@ void SelectionDAG::setGraphColor(const SDNode *N, const char *Color) {
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// setSubgraphColorHelper - Implement setSubgraphColor. Return
|
||||||
|
/// whether we truncated the search.
|
||||||
|
///
|
||||||
|
bool SelectionDAG::setSubgraphColorHelper(SDNode *N, const char *Color, DenseSet<SDNode *> &visited,
|
||||||
|
int level, bool &printed) {
|
||||||
|
bool hit_limit = false;
|
||||||
|
|
||||||
|
#ifndef NDEBUG
|
||||||
|
if (level >= 20) {
|
||||||
|
if (!printed) {
|
||||||
|
printed = true;
|
||||||
|
DOUT << "setSubgraphColor hit max level\n";
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned oldSize = visited.size();
|
||||||
|
visited.insert(N);
|
||||||
|
if (visited.size() != oldSize) {
|
||||||
|
setGraphColor(N, Color);
|
||||||
|
for(SDNodeIterator i = SDNodeIterator::begin(N), iend = SDNodeIterator::end(N);
|
||||||
|
i != iend;
|
||||||
|
++i) {
|
||||||
|
hit_limit = setSubgraphColorHelper(*i, Color, visited, level+1, printed) || hit_limit;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
cerr << "SelectionDAG::setSubgraphColor is only available in debug builds"
|
||||||
|
<< " on systems with Graphviz or gv!\n";
|
||||||
|
#endif
|
||||||
|
return hit_limit;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// setSubgraphColor - Convenience for setting subgraph color attribute.
|
||||||
|
///
|
||||||
|
void SelectionDAG::setSubgraphColor(SDNode *N, const char *Color) {
|
||||||
|
#ifndef NDEBUG
|
||||||
|
DenseSet<SDNode *> visited;
|
||||||
|
bool printed = false;
|
||||||
|
if (setSubgraphColorHelper(N, Color, visited, 0, printed)) {
|
||||||
|
// Visually mark that we hit the limit
|
||||||
|
if (Color == "red" ) {
|
||||||
|
setSubgraphColorHelper(N, "blue", visited, 0, printed);
|
||||||
|
}
|
||||||
|
else if (Color == "yellow" ) {
|
||||||
|
setSubgraphColorHelper(N, "green", visited, 0, printed);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
|
cerr << "SelectionDAG::setSubgraphColor is only available in debug builds"
|
||||||
|
<< " on systems with Graphviz or gv!\n";
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
namespace llvm {
|
namespace llvm {
|
||||||
template<>
|
template<>
|
||||||
struct DOTGraphTraits<ScheduleDAG*> : public DefaultDOTGraphTraits {
|
struct DOTGraphTraits<ScheduleDAG*> : public DefaultDOTGraphTraits {
|
||||||
|
Reference in New Issue
Block a user