llvm.org GIT mirror llvm / a1f6435
* Use C++ style comments instead of C-style * Make file description more readable * Make code layout more consistent, include comment in assert so it's visible during execution if it hits git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@9430 91177308-0d34-0410-b5e6-96231b3b80d8 Misha Brukman 15 years ago
4 changed file(s) with 50 addition(s) and 60 deletion(s). Raw diff Collapse all Expand all
66 //
77 //===----------------------------------------------------------------------===//
88 //
9 // class IGNode for coloring-based register allocation for LLVM.
9 // This file implements an Interference graph node for coloring-based register
10 // allocation.
1011 //
1112 //===----------------------------------------------------------------------===//
1213
2728 assert(0 && "Invalid adj list size");
2829 }
2930
30 for(int i=0; i < neighs; i++)
31 for (int i=0; i < neighs; i++)
3132 AdjList[i]->decCurDegree();
3233 }
3334
3839
3940 void IGNode::delAdjIGNode(const IGNode *Node) {
4041 std::vector::iterator It=find(AdjList.begin(), AdjList.end(), Node);
41 assert( It != AdjList.end() ); // the node must be there
42 assert(It != AdjList.end() && "The node must be there!");
4243 AdjList.erase(It);
4344 }
4445
4748 //-----------------------------------------------------------------------------
4849
4950 unsigned
50 IGNode::getCombinedDegree(const IGNode* otherNode) const
51 {
51 IGNode::getCombinedDegree(const IGNode* otherNode) const {
5252 std::vector nbrs(AdjList);
5353 nbrs.insert(nbrs.end(), otherNode->AdjList.begin(), otherNode->AdjList.end());
5454 sort(nbrs.begin(), nbrs.end());
5555 std::vector::iterator new_end = unique(nbrs.begin(), nbrs.end());
5656 return new_end - nbrs.begin();
5757 }
58
59
55 // the University of Illinois Open Source License. See LICENSE.TXT for details.
66 //
77 //===----------------------------------------------------------------------===//
8
9 /* Title: IGNode.h -*- C++ -*-
10 Author: Ruchira Sasanka
11 Date: July 25, 01
12 Purpose: Represents a node in an interference graph.
13 Notes:
14
15 For efficiency, the AdjList is updated only once - ie. we can add but not
16 remove nodes from AdjList.
17
18 The removal of nodes from IG is simulated by decrementing the CurDegree.
19 If this node is put on stack (that is removed from IG), the CurDegree of all
20 the neighbors are decremented and this node is marked OnStack. Hence
21 the effective neighbors in the AdjList are the ones that do not have the
22 OnStack flag set (therefore, they are in the IG).
23
24 The methods that modify/use the CurDegree must be called only
25 after all modifications to the IG are over (i.e., all neighbors are fixed).
26
27 The vector representation is the most efficient one for adj list.
28 Though nodes are removed when coalescing is done, we access it in sequence
29 for far many times when coloring (colorNode()).
30 */
8 //
9 // This file represents a node in an interference graph.
10 //
11 // For efficiency, the AdjList is updated only once - ie. we can add but not
12 // remove nodes from AdjList.
13 //
14 // The removal of nodes from IG is simulated by decrementing the CurDegree.
15 // If this node is put on stack (that is removed from IG), the CurDegree of all
16 // the neighbors are decremented and this node is marked OnStack. Hence
17 // the effective neighbors in the AdjList are the ones that do not have the
18 // OnStack flag set (therefore, they are in the IG).
19 //
20 // The methods that modify/use the CurDegree must be called only
21 // after all modifications to the IG are over (i.e., all neighbors are fixed).
22 //
23 // The vector representation is the most efficient one for adj list.
24 // Though nodes are removed when coalescing is done, we access it in sequence
25 // for far many times when coloring (colorNode()).
26 //
27 //===----------------------------------------------------------------------===//
3128
3229 #ifndef IGNODE_H
3330 #define IGNODE_H
66 //
77 //===----------------------------------------------------------------------===//
88 //
9 // class IGNode for coloring-based register allocation for LLVM.
9 // This file implements an Interference graph node for coloring-based register
10 // allocation.
1011 //
1112 //===----------------------------------------------------------------------===//
1213
2728 assert(0 && "Invalid adj list size");
2829 }
2930
30 for(int i=0; i < neighs; i++)
31 for (int i=0; i < neighs; i++)
3132 AdjList[i]->decCurDegree();
3233 }
3334
3839
3940 void IGNode::delAdjIGNode(const IGNode *Node) {
4041 std::vector::iterator It=find(AdjList.begin(), AdjList.end(), Node);
41 assert( It != AdjList.end() ); // the node must be there
42 assert(It != AdjList.end() && "The node must be there!");
4243 AdjList.erase(It);
4344 }
4445
4748 //-----------------------------------------------------------------------------
4849
4950 unsigned
50 IGNode::getCombinedDegree(const IGNode* otherNode) const
51 {
51 IGNode::getCombinedDegree(const IGNode* otherNode) const {
5252 std::vector nbrs(AdjList);
5353 nbrs.insert(nbrs.end(), otherNode->AdjList.begin(), otherNode->AdjList.end());
5454 sort(nbrs.begin(), nbrs.end());
5555 std::vector::iterator new_end = unique(nbrs.begin(), nbrs.end());
5656 return new_end - nbrs.begin();
5757 }
58
59
55 // the University of Illinois Open Source License. See LICENSE.TXT for details.
66 //
77 //===----------------------------------------------------------------------===//
8
9 /* Title: IGNode.h -*- C++ -*-
10 Author: Ruchira Sasanka
11 Date: July 25, 01
12 Purpose: Represents a node in an interference graph.
13 Notes:
14
15 For efficiency, the AdjList is updated only once - ie. we can add but not
16 remove nodes from AdjList.
17
18 The removal of nodes from IG is simulated by decrementing the CurDegree.
19 If this node is put on stack (that is removed from IG), the CurDegree of all
20 the neighbors are decremented and this node is marked OnStack. Hence
21 the effective neighbors in the AdjList are the ones that do not have the
22 OnStack flag set (therefore, they are in the IG).
23
24 The methods that modify/use the CurDegree must be called only
25 after all modifications to the IG are over (i.e., all neighbors are fixed).
26
27 The vector representation is the most efficient one for adj list.
28 Though nodes are removed when coalescing is done, we access it in sequence
29 for far many times when coloring (colorNode()).
30 */
8 //
9 // This file represents a node in an interference graph.
10 //
11 // For efficiency, the AdjList is updated only once - ie. we can add but not
12 // remove nodes from AdjList.
13 //
14 // The removal of nodes from IG is simulated by decrementing the CurDegree.
15 // If this node is put on stack (that is removed from IG), the CurDegree of all
16 // the neighbors are decremented and this node is marked OnStack. Hence
17 // the effective neighbors in the AdjList are the ones that do not have the
18 // OnStack flag set (therefore, they are in the IG).
19 //
20 // The methods that modify/use the CurDegree must be called only
21 // after all modifications to the IG are over (i.e., all neighbors are fixed).
22 //
23 // The vector representation is the most efficient one for adj list.
24 // Though nodes are removed when coalescing is done, we access it in sequence
25 // for far many times when coloring (colorNode()).
26 //
27 //===----------------------------------------------------------------------===//
3128
3229 #ifndef IGNODE_H
3330 #define IGNODE_H