Skip to content

Commit 88df876

Browse files
committed
* Eliminate `using' directive
* Fix order of #includes * Make code layout more consistent * Eliminate extraneous whitespace and comment-lines llvm-svn: 9433
1 parent dc07775 commit 88df876

File tree

2 files changed

+26
-52
lines changed

2 files changed

+26
-52
lines changed

llvm/lib/CodeGen/RegAlloc/InterferenceGraph.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,11 @@
1111
//
1212
//===----------------------------------------------------------------------===//
1313

14-
#include "RegAllocCommon.h"
15-
#include "InterferenceGraph.h"
1614
#include "IGNode.h"
15+
#include "InterferenceGraph.h"
16+
#include "RegAllocCommon.h"
1717
#include "Support/STLExtras.h"
1818
#include <algorithm>
19-
using std::cerr;
2019

2120
// for asserting this IG node is infact in the IGNodeList of this class
2221
inline static void assertIGNode(const InterferenceGraph *IG,

llvm/lib/CodeGen/RegAlloc/RegClass.cpp

Lines changed: 24 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@
1111
//
1212
//===----------------------------------------------------------------------===//
1313

14-
#include "RegClass.h"
15-
#include "RegAllocCommon.h"
1614
#include "IGNode.h"
15+
#include "RegAllocCommon.h"
16+
#include "RegClass.h"
1717
#include "llvm/Target/TargetRegInfo.h"
1818

1919
//----------------------------------------------------------------------------
@@ -26,7 +26,7 @@ RegClass::RegClass(const Function *M,
2626
: Meth(M), MRI(_MRI_), MRC(_MRC_),
2727
RegClassID( _MRC_->getRegClassID() ),
2828
IG(this), IGNodeStack() {
29-
if( DEBUG_RA >= RA_DEBUG_Interference)
29+
if (DEBUG_RA >= RA_DEBUG_Interference)
3030
std::cerr << "Created Reg Class: " << RegClassID << "\n";
3131

3232
IsColorUsedArr.resize(MRC->getNumOfAllRegs());
@@ -39,23 +39,19 @@ RegClass::RegClass(const Function *M,
3939
//----------------------------------------------------------------------------
4040
void RegClass::colorAllRegs()
4141
{
42-
if(DEBUG_RA >= RA_DEBUG_Coloring)
42+
if (DEBUG_RA >= RA_DEBUG_Coloring)
4343
std::cerr << "Coloring IG of reg class " << RegClassID << " ...\n";
44-
4544
// pre-color IGNodes
4645
pushAllIGNodes(); // push all IG Nodes
4746

4847
unsigned int StackSize = IGNodeStack.size();
4948
IGNode *CurIGNode;
50-
5149
// for all LRs on stack
52-
for( unsigned int IGN=0; IGN < StackSize; IGN++) {
53-
50+
for (unsigned int IGN=0; IGN < StackSize; IGN++) {
5451
CurIGNode = IGNodeStack.top(); // pop the IGNode on top of stack
5552
IGNodeStack.pop();
5653
colorIGNode (CurIGNode); // color it
5754
}
58-
5955
}
6056

6157

@@ -73,13 +69,13 @@ void RegClass::pushAllIGNodes()
7369
// push non-constrained IGNodes
7470
bool PushedAll = pushUnconstrainedIGNodes();
7571

76-
if( DEBUG_RA >= RA_DEBUG_Coloring) {
72+
if (DEBUG_RA >= RA_DEBUG_Coloring) {
7773
std::cerr << " Puhsed all-unconstrained IGNodes. ";
7874
if( PushedAll ) std::cerr << " No constrained nodes left.";
7975
std::cerr << "\n";
8076
}
8177

82-
if( PushedAll ) // if NO constrained nodes left
78+
if (PushedAll) // if NO constrained nodes left
8379
return;
8480

8581

@@ -89,24 +85,15 @@ void RegClass::pushAllIGNodes()
8985

9086
do {
9187
//get node with min spill cost
92-
//
9388
IGNode *IGNodeSpill = getIGNodeWithMinSpillCost();
94-
9589
// push that node on to stack
96-
//
9790
IGNodeStack.push(IGNodeSpill);
98-
9991
// set its OnStack flag and decrement degree of neighs
100-
//
10192
IGNodeSpill->pushOnStack();
102-
10393
// now push NON-constrained ones, if any
104-
//
10594
NeedMoreSpills = !pushUnconstrainedIGNodes();
106-
10795
if (DEBUG_RA >= RA_DEBUG_Coloring)
10896
std::cerr << "\nConstrained IG Node found !@!" << IGNodeSpill->getIndex();
109-
11097
} while(NeedMoreSpills); // repeat until we have pushed all
11198

11299
}
@@ -127,21 +114,21 @@ bool RegClass::pushUnconstrainedIGNodes()
127114
bool pushedall = true;
128115

129116
// a pass over IGNodeList
130-
for( unsigned i =0; i < IGNodeListSize; i++) {
117+
for (unsigned i =0; i < IGNodeListSize; i++) {
131118

132119
// get IGNode i from IGNodeList
133120
IGNode *IGNode = IG.getIGNodeList()[i];
134121

135-
if( !IGNode ) // can be null due to merging
122+
if (!IGNode ) // can be null due to merging
136123
continue;
137124

138125
// if already pushed on stack, continue. This can happen since this
139126
// method can be called repeatedly until all constrained nodes are
140127
// pushed
141-
if( IGNode->isOnStack() )
128+
if (IGNode->isOnStack() )
142129
continue;
143130
// if the degree of IGNode is lower
144-
if( (unsigned) IGNode->getCurDegree() < MRC->getNumOfAvailRegs()) {
131+
if ((unsigned) IGNode->getCurDegree() < MRC->getNumOfAvailRegs()) {
145132
IGNodeStack.push( IGNode ); // push IGNode on to the stack
146133
IGNode->pushOnStack(); // set OnStack and dec deg of neighs
147134

@@ -163,55 +150,45 @@ bool RegClass::pushUnconstrainedIGNodes()
163150
//----------------------------------------------------------------------------
164151
// Get the IGNode with the minimum spill cost
165152
//----------------------------------------------------------------------------
166-
IGNode * RegClass::getIGNodeWithMinSpillCost()
167-
{
168-
153+
IGNode * RegClass::getIGNodeWithMinSpillCost() {
169154
unsigned int IGNodeListSize = IG.getIGNodeList().size();
170155
double MinSpillCost = 0;
171156
IGNode *MinCostIGNode = NULL;
172157
bool isFirstNode = true;
173158

174159
// pass over IGNodeList to find the IGNode with minimum spill cost
175160
// among all IGNodes that are not yet pushed on to the stack
176-
//
177-
for( unsigned int i =0; i < IGNodeListSize; i++) {
161+
for (unsigned int i =0; i < IGNodeListSize; i++) {
178162
IGNode *IGNode = IG.getIGNodeList()[i];
179163

180-
if( ! IGNode ) // can be null due to merging
164+
if (!IGNode) // can be null due to merging
181165
continue;
182166

183-
if( ! IGNode->isOnStack() ) {
184-
167+
if (!IGNode->isOnStack()) {
185168
double SpillCost = (double) IGNode->getParentLR()->getSpillCost() /
186169
(double) (IGNode->getCurDegree() + 1);
187170

188-
if( isFirstNode ) { // for the first IG node
171+
if (isFirstNode) { // for the first IG node
189172
MinSpillCost = SpillCost;
190173
MinCostIGNode = IGNode;
191174
isFirstNode = false;
192-
}
193-
194-
else if( MinSpillCost > SpillCost) {
175+
} else if (MinSpillCost > SpillCost) {
195176
MinSpillCost = SpillCost;
196177
MinCostIGNode = IGNode;
197178
}
198-
199179
}
200180
}
201181

202-
assert( MinCostIGNode && "No IGNode to spill");
182+
assert (MinCostIGNode && "No IGNode to spill");
203183
return MinCostIGNode;
204184
}
205185

206186

207-
208187
//----------------------------------------------------------------------------
209188
// Color the IGNode using the machine specific code.
210189
//----------------------------------------------------------------------------
211-
void RegClass::colorIGNode(IGNode *const Node)
212-
{
213-
214-
if( ! Node->hasColor() ) { // not colored as an arg etc.
190+
void RegClass::colorIGNode(IGNode *const Node) {
191+
if (! Node->hasColor()) { // not colored as an arg etc.
215192

216193
// init all elements of to IsColorUsedAr false;
217194
clearColorsUsed();
@@ -242,22 +219,20 @@ void RegClass::colorIGNode(IGNode *const Node)
242219
// call the target specific code for coloring
243220
//
244221
MRC->colorIGNode(Node, IsColorUsedArr);
245-
}
246-
else {
247-
if( DEBUG_RA >= RA_DEBUG_Coloring) {
222+
} else {
223+
if (DEBUG_RA >= RA_DEBUG_Coloring) {
248224
std::cerr << " Node " << Node->getIndex();
249225
std::cerr << " already colored with color " << Node->getColor() << "\n";
250226
}
251227
}
252228

253229

254-
if( !Node->hasColor() ) {
255-
if( DEBUG_RA >= RA_DEBUG_Coloring) {
230+
if (!Node->hasColor() ) {
231+
if (DEBUG_RA >= RA_DEBUG_Coloring) {
256232
std::cerr << " Node " << Node->getIndex();
257233
std::cerr << " - could not find a color (needs spilling)\n";
258234
}
259235
}
260-
261236
}
262237

263238
void RegClass::printIGNodeList() const {

0 commit comments

Comments
 (0)