Skip to content

SILOptimizer: switch to NodeRef #4507

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 25, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 20 additions & 20 deletions include/swift/SIL/CFG.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,71 +29,71 @@ namespace llvm {
template <> struct GraphTraits<swift::SILBasicBlock*> {
typedef swift::SILBasicBlock NodeType;
typedef NodeType::SuccessorListTy::iterator ChildIteratorType;
typedef NodeType *NodeRef;
typedef swift::SILBasicBlock *NodeRef;

static NodeType *getEntryNode(NodeType *BB) { return BB; }
static NodeRef getEntryNode(NodeRef BB) { return BB; }

static ChildIteratorType child_begin(NodeType *N) {
static ChildIteratorType child_begin(NodeRef N) {
return N->getSuccessors().begin();
}
static ChildIteratorType child_end(NodeType *N) {
static ChildIteratorType child_end(NodeRef N) {
return N->getSuccessors().end();
}
};

template <> struct GraphTraits<const swift::SILBasicBlock*> {
typedef const swift::SILBasicBlock NodeType;
typedef NodeType::ConstSuccessorListTy::iterator ChildIteratorType;
typedef NodeType *NodeRef;
typedef const swift::SILBasicBlock *NodeRef;

static NodeType *getEntryNode(NodeType *BB) { return BB; }
static NodeRef getEntryNode(NodeRef BB) { return BB; }

static ChildIteratorType child_begin(NodeType *N) {
static ChildIteratorType child_begin(NodeRef N) {
return N->getSuccessors().begin();
}
static ChildIteratorType child_end(NodeType *N) {
static ChildIteratorType child_end(NodeRef N) {
return N->getSuccessors().end();
}
};

template <> struct GraphTraits<Inverse<swift::SILBasicBlock*> > {
typedef swift::SILBasicBlock NodeType;
typedef NodeType::pred_iterator ChildIteratorType;
typedef NodeType *NodeRef;
typedef swift::SILBasicBlock *NodeRef;

static NodeType *getEntryNode(Inverse<swift::SILBasicBlock *> G) {
static NodeRef getEntryNode(Inverse<swift::SILBasicBlock *> G) {
return G.Graph;
}
static inline ChildIteratorType child_begin(NodeType *N) {
static inline ChildIteratorType child_begin(NodeRef N) {
return N->pred_begin();
}
static inline ChildIteratorType child_end(NodeType *N) {
static inline ChildIteratorType child_end(NodeRef N) {
return N->pred_end();
}
};

template <> struct GraphTraits<Inverse<const swift::SILBasicBlock*> > {
typedef const swift::SILBasicBlock NodeType;
typedef NodeType::pred_iterator ChildIteratorType;
typedef NodeType *NodeRef;
typedef const swift::SILBasicBlock *NodeRef;

static NodeType *getEntryNode(Inverse<const swift::SILBasicBlock *> G) {
static NodeRef getEntryNode(Inverse<const swift::SILBasicBlock *> G) {
return G.Graph;
}
static inline ChildIteratorType child_begin(NodeType *N) {
static inline ChildIteratorType child_begin(NodeRef N) {
return N->pred_begin();
}
static inline ChildIteratorType child_end(NodeType *N) {
static inline ChildIteratorType child_end(NodeRef N) {
return N->pred_end();
}
};

template <> struct GraphTraits<swift::SILFunction*>
: public GraphTraits<swift::SILBasicBlock*> {
typedef swift::SILFunction *GraphType;
typedef NodeType *NodeRef;
typedef swift::SILBasicBlock *NodeRef;

static NodeType *getEntryNode(GraphType F) { return &F->front(); }
static NodeRef getEntryNode(GraphType F) { return &F->front(); }

typedef swift::SILFunction::iterator nodes_iterator;
static nodes_iterator nodes_begin(GraphType F) { return F->begin(); }
Expand All @@ -104,9 +104,9 @@ template <> struct GraphTraits<swift::SILFunction*>
template <> struct GraphTraits<Inverse<swift::SILFunction*> >
: public GraphTraits<Inverse<swift::SILBasicBlock*> > {
typedef Inverse<swift::SILFunction *> GraphType;
typedef NodeType *NodeRef;
typedef NodeRef NodeRef;

static NodeType *getEntryNode(GraphType F) { return &F.Graph->front(); }
static NodeRef getEntryNode(GraphType F) { return &F.Graph->front(); }

typedef swift::SILFunction::iterator nodes_iterator;
static nodes_iterator nodes_begin(GraphType F) { return F.Graph->begin(); }
Expand Down
20 changes: 8 additions & 12 deletions include/swift/SIL/Dominance.h
Original file line number Diff line number Diff line change
Expand Up @@ -170,25 +170,21 @@ namespace llvm {
template <> struct GraphTraits<swift::DominanceInfoNode *> {
using NodeType = swift::DominanceInfoNode;
using ChildIteratorType = NodeType::iterator;
typedef NodeType *NodeRef;
typedef swift::DominanceInfoNode *NodeRef;

static NodeType *getEntryNode(NodeType *N) { return N; }
static inline ChildIteratorType child_begin(NodeType *N) {
return N->begin();
}
static inline ChildIteratorType child_end(NodeType *N) { return N->end(); }
static NodeRef getEntryNode(NodeRef N) { return N; }
static inline ChildIteratorType child_begin(NodeRef N) { return N->begin(); }
static inline ChildIteratorType child_end(NodeRef N) { return N->end(); }
};

template <> struct GraphTraits<const swift::DominanceInfoNode *> {
using NodeType = const swift::DominanceInfoNode;
using ChildIteratorType = NodeType::const_iterator;
typedef NodeType *NodeRef;
typedef const swift::DominanceInfoNode *NodeRef;

static NodeType *getEntryNode(NodeType *N) { return N; }
static inline ChildIteratorType child_begin(NodeType *N) {
return N->begin();
}
static inline ChildIteratorType child_end(NodeType *N) { return N->end(); }
static NodeRef getEntryNode(NodeRef N) { return N; }
static inline ChildIteratorType child_begin(NodeRef N) { return N->begin(); }
static inline ChildIteratorType child_end(NodeRef N) { return N->end(); }
};

} // end namespace llvm
Expand Down
10 changes: 6 additions & 4 deletions lib/SILOptimizer/Analysis/EscapeAnalysis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -731,21 +731,23 @@ namespace llvm {
template <> struct GraphTraits<CGForDotView::Node *> {
typedef CGForDotView::Node NodeType;
typedef CGForDotView::child_iterator ChildIteratorType;
typedef CGForDotView::Node *NodeRef;

static NodeType *getEntryNode(NodeType *N) { return N; }
static inline ChildIteratorType child_begin(NodeType *N) {
static NodeRef getEntryNode(NodeRef N) { return N; }
static inline ChildIteratorType child_begin(NodeRef N) {
return N->Children.begin();
}
static inline ChildIteratorType child_end(NodeType *N) {
static inline ChildIteratorType child_end(NodeRef N) {
return N->Children.end();
}
};

template <> struct GraphTraits<CGForDotView *>
: public GraphTraits<CGForDotView::Node *> {
typedef CGForDotView *GraphType;
typedef CGForDotView::Node *NodeRef;

static NodeType *getEntryNode(GraphType F) { return nullptr; }
static NodeRef getEntryNode(GraphType F) { return nullptr; }

typedef CGForDotView::iterator nodes_iterator;
static nodes_iterator nodes_begin(GraphType OCG) {
Expand Down
10 changes: 6 additions & 4 deletions lib/SILOptimizer/Analysis/LoopRegionAnalysis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1036,19 +1036,21 @@ namespace llvm {
template <> struct GraphTraits<LoopRegionWrapper> {
using NodeType = LoopRegionWrapper;
using ChildIteratorType = alledge_iterator;
typedef LoopRegionWrapper *NodeRef;

static NodeType *getEntryNode(NodeType *BB) { return BB; }
static NodeRef getEntryNode(NodeRef BB) { return BB; }

static ChildIteratorType child_begin(NodeType *N) { return N->begin(); }
static ChildIteratorType child_end(NodeType *N) { return N->end(); }
static ChildIteratorType child_begin(NodeRef N) { return N->begin(); }
static ChildIteratorType child_end(NodeRef N) { return N->end(); }
};

template <>
struct GraphTraits<LoopRegionFunctionInfoGrapherWrapper *>
: public GraphTraits<LoopRegionWrapper> {
using GraphType = LoopRegionFunctionInfoGrapherWrapper;
typedef LoopRegionWrapper *NodeRef;

static NodeType *getEntryNode(GraphType *F) { return &F->Data[0]; }
static NodeRef getEntryNode(GraphType *F) { return &F->Data[0]; }

using nodes_iterator = std::vector<LoopRegionWrapper>::iterator;

Expand Down
10 changes: 6 additions & 4 deletions lib/SILOptimizer/PassManager/PassManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -758,21 +758,23 @@ namespace llvm {
template <> struct GraphTraits<CallGraph::Node *> {
typedef CallGraph::Node NodeType;
typedef CallGraph::child_iterator ChildIteratorType;
typedef CallGraph::Node *NodeRef;

static NodeType *getEntryNode(NodeType *N) { return N; }
static inline ChildIteratorType child_begin(NodeType *N) {
static NodeRef getEntryNode(NodeRef N) { return N; }
static inline ChildIteratorType child_begin(NodeRef N) {
return N->Children.begin();
}
static inline ChildIteratorType child_end(NodeType *N) {
static inline ChildIteratorType child_end(NodeRef N) {
return N->Children.end();
}
};

template <> struct GraphTraits<CallGraph *>
: public GraphTraits<CallGraph::Node *> {
typedef CallGraph *GraphType;
typedef CallGraph::Node *NodeRef;

static NodeType *getEntryNode(GraphType F) { return nullptr; }
static NodeRef getEntryNode(GraphType F) { return nullptr; }

typedef CallGraph::iterator nodes_iterator;
static nodes_iterator nodes_begin(GraphType CG) {
Expand Down
3 changes: 2 additions & 1 deletion lib/SILOptimizer/Transforms/StackPromotion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -429,8 +429,9 @@ namespace llvm {
template <> struct GraphTraits<StackPromoter *>
: public GraphTraits<swift::SILBasicBlock*> {
typedef StackPromoter *GraphType;
typedef swift::SILBasicBlock *NodeRef;

static NodeType *getEntryNode(GraphType SP) {
static NodeRef getEntryNode(GraphType SP) {
return &SP->getFunction()->front();
}

Expand Down