25 #ifndef _JIT_COMPILER2_GRAPHHELPER
26 #define _JIT_COMPILER2_GRAPHHELPER
37 #define DEBUG_NAME "compiler2/GraphHelper"
50 template <
class _NodeTy>
102 LOG(
" node " << (
long) *
i <<
" parent " <<
i.get_parent().get_index() <<
nl);
116 typename IndexMapTy::const_iterator
i =
index.find(v);
117 if (i ==
index.end())
128 bool is_ancestor(
const _NodeTy *v,
const _NodeTy *w)
const {
134 for(;w >= 0; w =
parent[w]) {
142 bool is_decendant(
const _NodeTy *w,
const _NodeTy *v)
const {
150 class iterator :
public std::iterator<std::input_iterator_tag,_NodeTy*> {
237 return iterator(
this);
241 return iterator(
this,-1);
255 template <
class _NodeTy>
260 LOG(
"my_n for " << (
long)v <<
" (" << my_n <<
") " <<
nl);
262 assert(vertex.size() > (unsigned)my_n);
266 succ_v = successor(v, succ_v);
267 LOG(
"number of succ for " << (
long)v <<
" (" << my_n <<
") " <<
" = " << succ_v.size() <<
nl);
275 succ_list.insert(w_n);
277 succ_list.insert(
index[w]);
281 number_decendants[my_n] = n - my_n;
307 for (; !(a == get_root<T>()) ; a =
get_parent(a)) {
314 for (; !(b == get_root<T>()) ; b =
get_parent(b)) {
315 if (ancestors.find(b) !=
e)
318 return get_root<T>();
alloc::vector< int >::type DecendantMapTy
std::set< Key, Compare, Allocator< Key > > type
bool is_decendant(int w, int v) const
int operator[](_NodeTy *v) const
bool operator==(const iterator &other) const
iterator get_parent() const
T find_least_common_ancestor(T a, T b)
This Instruction mark the start of a basic block.
This helper class creates traversal for a graph.
const DFSTraversal< BeginInst > dfs
iterator(DFSTraversal *parent, int index)
bool operator<(const iterator &other) const
alloc::set< int >::type SuccessorListTy
int num_decendants(int v) const
bool is_ancestor(int v, int w) const
bool operator<=(const iterator &other) const
bool operator!=(const iterator &other) const
alloc::vector< _NodeTy * >::type NodeMapTy
Instruction::InstID tmp[]
iterator(const iterator &it)
std::vector< T, Allocator< T > > type
DFSTraversal(_NodeTy *entry)
alloc::vector< int >::type ParentMapTy
iterator reverse_iterator
alloc::set< iterator >::type iterator_list
_NodeTy * operator*() const
reverse_iterator rbegin()
Loop * get_parent(Loop *a)
alloc::set< _NodeTy * >::type NodeListTy
alloc::vector< SuccessorListTy >::type SuccessorListMapTy
DecendantMapTy number_decendants
#define LOG(STMT)
Analogous to DEBUG.
_NodeTy * operator[](unsigned i) const
iterator(DFSTraversal *parent)
bool operator>(const iterator &other) const
bool operator>=(const iterator &other) const
alloc::map< _NodeTy *, int >::type IndexMapTy
iterator_list & get_successors(iterator_list &list) const
NodeListTy & successor(_NodeTy *v, NodeListTy &list)
int num_nodes(_NodeTy *v) const