llvm.org GIT mirror llvm / 94d1092
Move the HasLoop method from the SCC class to the iterator class git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@8268 91177308-0d34-0410-b5e6-96231b3b80d8 Chris Lattner 16 years ago
2 changed file(s) with 26 addition(s) and 24 deletion(s). Raw diff Collapse all Expand all
3434 typedef typename super::const_iterator const_iterator;
3535 typedef typename super::reverse_iterator reverse_iterator;
3636 typedef typename super::const_reverse_iterator const_reverse_iterator;
37
38 // HasLoop() -- Test if this SCC has a loop. If it has more than one
39 // node, this is trivially true. If not, it may still contain a loop
40 // if the node has an edge back to itself.
41 bool HasLoop() const {
42 if (size() > 1) return true;
43 NodeType* N = front();
44 for (ChildItTy CI = GT::child_begin(N), CE=GT::child_end(N); CI != CE; ++CI)
45 if (*CI == N)
46 return true;
47 return false;
48 }
4937 };
5038
5139 //--------------------------------------------------------------------------
191179 assert(!CurrentSCC.empty() && "Dereferencing END SCC iterator!");
192180 return CurrentSCC;
193181 }
182
183 // hasLoop() -- Test if the current SCC has a loop. If it has more than one
184 // node, this is trivially true. If not, it may still contain a loop if the
185 // node has an edge back to itself.
186 bool hasLoop() const {
187 assert(!CurrentSCC.empty() && "Dereferencing END SCC iterator!");
188 if (CurrentSCC.size() > 1) return true;
189 NodeType *N = CurrentSCC.front();
190 for (ChildItTy CI = GT::child_begin(N), CE=GT::child_end(N); CI != CE; ++CI)
191 if (*CI == N)
192 return true;
193 return false;
194 }
194195 };
195196
196197
3434 typedef typename super::const_iterator const_iterator;
3535 typedef typename super::reverse_iterator reverse_iterator;
3636 typedef typename super::const_reverse_iterator const_reverse_iterator;
37
38 // HasLoop() -- Test if this SCC has a loop. If it has more than one
39 // node, this is trivially true. If not, it may still contain a loop
40 // if the node has an edge back to itself.
41 bool HasLoop() const {
42 if (size() > 1) return true;
43 NodeType* N = front();
44 for (ChildItTy CI = GT::child_begin(N), CE=GT::child_end(N); CI != CE; ++CI)
45 if (*CI == N)
46 return true;
47 return false;
48 }
4937 };
5038
5139 //--------------------------------------------------------------------------
191179 assert(!CurrentSCC.empty() && "Dereferencing END SCC iterator!");
192180 return CurrentSCC;
193181 }
182
183 // hasLoop() -- Test if the current SCC has a loop. If it has more than one
184 // node, this is trivially true. If not, it may still contain a loop if the
185 // node has an edge back to itself.
186 bool hasLoop() const {
187 assert(!CurrentSCC.empty() && "Dereferencing END SCC iterator!");
188 if (CurrentSCC.size() > 1) return true;
189 NodeType *N = CurrentSCC.front();
190 for (ChildItTy CI = GT::child_begin(N), CE=GT::child_end(N); CI != CE; ++CI)
191 if (*CI == N)
192 return true;
193 return false;
194 }
194195 };
195196
196197