Cleaned up code layout, spacing, etc. for readability purposes and to be more

consistent with the style of LLVM's code base (and itself! it's inconsistent in
some places.)

No functional changes were made.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@6262 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Misha Brukman 2003-05-21 18:05:35 +00:00
parent ee563cb978
commit 77c9fcb797

View File

@ -26,33 +26,26 @@ void SparcIntRegClass::colorIGNode(IGNode * Node,
{ {
LiveRange *LR = Node->getParentLR(); LiveRange *LR = Node->getParentLR();
if( DEBUG_RA ) { if (DEBUG_RA) {
std::cerr << "\nColoring LR [CallInt=" << LR->isCallInterference() <<"]:"; std::cerr << "\nColoring LR [CallInt=" << LR->isCallInterference() <<"]:";
printSet(*LR); printSet(*LR);
} }
if( LR->hasSuggestedColor() ) { if (LR->hasSuggestedColor()) {
unsigned SugCol = LR->getSuggestedColor(); unsigned SugCol = LR->getSuggestedColor();
if (!IsColorUsedArr[SugCol]) { if (!IsColorUsedArr[SugCol]) {
if (LR->isSuggestedColorUsable()) {
if( LR->isSuggestedColorUsable() ) {
// if the suggested color is volatile, we should use it only if // if the suggested color is volatile, we should use it only if
// there are no call interferences. Otherwise, it will get spilled. // there are no call interferences. Otherwise, it will get spilled.
if (DEBUG_RA) if (DEBUG_RA)
std::cerr << "\n -Coloring with sug color: " << SugCol; std::cerr << "\n -Coloring with sug color: " << SugCol;
LR->setColor( LR->getSuggestedColor() ); LR->setColor(LR->getSuggestedColor());
return; return;
} else if(DEBUG_RA) {
std::cerr << "\n Couldn't alloc Sug col - LR voloatile & calls interf";
} }
else if(DEBUG_RA) } else if (DEBUG_RA) { // can't allocate the suggested col
std::cerr << "\n Couldn't alloc Sug col - LR voloatile & calls interf";
}
else if (DEBUG_RA) { // can't allocate the suggested col
std::cerr << "\n Could NOT allocate the suggested color (already used) "; std::cerr << "\n Could NOT allocate the suggested color (already used) ";
printSet(*LR); std::cerr << "\n"; printSet(*LR); std::cerr << "\n";
} }
@ -62,12 +55,10 @@ void SparcIntRegClass::colorIGNode(IGNode * Node,
bool ColorFound= false; // have we found a color yet? bool ColorFound= false; // have we found a color yet?
//if this Node is between calls //if this Node is between calls
if( ! LR->isCallInterference() ) { if (! LR->isCallInterference()) {
// start with volatiles (we can allocate volatiles safely) // start with volatiles (we can allocate volatiles safely)
SearchStart = SparcIntRegClass::StartOfAllRegs; SearchStart = SparcIntRegClass::StartOfAllRegs;
} } else {
else {
// start with non volatiles (no non-volatiles) // start with non volatiles (no non-volatiles)
SearchStart = SparcIntRegClass::StartOfNonVolatileRegs; SearchStart = SparcIntRegClass::StartOfNonVolatileRegs;
} }
@ -75,11 +66,14 @@ void SparcIntRegClass::colorIGNode(IGNode * Node,
unsigned c=0; // color unsigned c=0; // color
// find first unused color // find first unused color
for( c=SearchStart; c < SparcIntRegClass::NumOfAvailRegs; c++) { for (c=SearchStart; c < SparcIntRegClass::NumOfAvailRegs; c++) {
if(!IsColorUsedArr[c] ) { ColorFound = true; break; } if (!IsColorUsedArr[c]) {
ColorFound = true;
break;
}
} }
if( ColorFound) { if (ColorFound) {
LR->setColor(c); // first color found in preffered order LR->setColor(c); // first color found in preffered order
if (DEBUG_RA) std::cerr << "\n Colored after first search with col " << c; if (DEBUG_RA) std::cerr << "\n Colored after first search with col " << c;
} }
@ -87,24 +81,26 @@ void SparcIntRegClass::colorIGNode(IGNode * Node,
// if color is not found because of call interference // if color is not found because of call interference
// try even finding a volatile color and insert save across calls // try even finding a volatile color and insert save across calls
// //
else if( LR->isCallInterference() ) else if (LR->isCallInterference()) {
{
// start from 0 - try to find even a volatile this time // start from 0 - try to find even a volatile this time
SearchStart = SparcIntRegClass::StartOfAllRegs; SearchStart = SparcIntRegClass::StartOfAllRegs;
// find first unused volatile color // find first unused volatile color
for(c=SearchStart; c < SparcIntRegClass::StartOfNonVolatileRegs; c++) { for(c=SearchStart; c < SparcIntRegClass::StartOfNonVolatileRegs; c++) {
if( ! IsColorUsedArr[ c ] ) { ColorFound = true; break; } if (! IsColorUsedArr[c]) {
ColorFound = true;
break;
}
} }
if (ColorFound) { if (ColorFound) {
LR->setColor(c); LR->setColor(c);
// get the live range corresponding to live var // get the live range corresponding to live var
// since LR span across calls, must save across calls // since LR span across calls, must save across calls
// //
LR->markForSaveAcrossCalls(); LR->markForSaveAcrossCalls();
if (DEBUG_RA) if (DEBUG_RA)
std::cerr << "\n Colored after SECOND search with col " << c; std::cerr << "\n Colored after SECOND search with col " << c;
} }
} }
@ -117,10 +113,6 @@ void SparcIntRegClass::colorIGNode(IGNode * Node,
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Float Register Class - method for coloring a node in the interference graph. // Float Register Class - method for coloring a node in the interference graph.
// //
@ -150,17 +142,17 @@ void SparcFloatRegClass::colorIGNode(IGNode * Node,
IGNode *NeighIGNode = Node->getAdjIGNode(n); IGNode *NeighIGNode = Node->getAdjIGNode(n);
LiveRange *NeighLR = NeighIGNode->getParentLR(); LiveRange *NeighLR = NeighIGNode->getParentLR();
if( NeighLR->hasColor() && if (NeighLR->hasColor() &&
NeighLR->getType() == Type::DoubleTy) { NeighLR->getType() == Type::DoubleTy) {
IsColorUsedArr[ (NeighLR->getColor()) + 1 ] = true; IsColorUsedArr[ (NeighLR->getColor()) + 1 ] = true;
} else if (NeighLR->hasSuggestedColor() && } else if (NeighLR->hasSuggestedColor() &&
NeighLR-> isSuggestedColorUsable() ) { NeighLR-> isSuggestedColorUsable() ) {
// if the neighbour can use the suggested color // if the neighbour can use the suggested color
IsColorUsedArr[ NeighLR->getSuggestedColor() ] = true; IsColorUsedArr[ NeighLR->getSuggestedColor() ] = true;
if (NeighLR->getType() == Type::DoubleTy) if (NeighLR->getType() == Type::DoubleTy)
IsColorUsedArr[ (NeighLR->getSuggestedColor()) + 1 ] = true; IsColorUsedArr[ (NeighLR->getSuggestedColor()) + 1 ] = true;
} }
} }
@ -190,9 +182,8 @@ void SparcFloatRegClass::colorIGNode(IGNode * Node,
// //
if (LR->getType() == Type::DoubleTy) if (LR->getType() == Type::DoubleTy)
ColorFound = findFloatColor( LR, 32, 64, IsColorUsedArr ); ColorFound = findFloatColor( LR, 32, 64, IsColorUsedArr );
if( ColorFound >= 0 ) { // if we could find a color if (ColorFound >= 0) { // if we could find a color
LR->setColor(ColorFound); LR->setColor(ColorFound);
return; return;
} else { } else {
@ -204,36 +195,30 @@ void SparcFloatRegClass::colorIGNode(IGNode * Node,
unsigned SearchStart; // start pos of color in pref-order unsigned SearchStart; // start pos of color in pref-order
//if this Node is between calls (i.e., no call interferences ) //if this Node is between calls (i.e., no call interferences )
if( ! isCallInterf ) { if (! isCallInterf) {
// start with volatiles (we can allocate volatiles safely) // start with volatiles (we can allocate volatiles safely)
SearchStart = SparcFloatRegClass::StartOfAllRegs; SearchStart = SparcFloatRegClass::StartOfAllRegs;
} } else {
else {
// start with non volatiles (no non-volatiles) // start with non volatiles (no non-volatiles)
SearchStart = SparcFloatRegClass::StartOfNonVolatileRegs; SearchStart = SparcFloatRegClass::StartOfNonVolatileRegs;
} }
ColorFound = findFloatColor( LR, SearchStart, 32, IsColorUsedArr ); ColorFound = findFloatColor(LR, SearchStart, 32, IsColorUsedArr);
} }
if (ColorFound >= 0) { // if we could find a color
if( ColorFound >= 0 ) { // if we could find a color
LR->setColor(ColorFound); LR->setColor(ColorFound);
return; return;
} } else if (isCallInterf) {
else if( isCallInterf ) {
// We are here because there is a call interference and no non-volatile // We are here because there is a call interference and no non-volatile
// color could be found. // color could be found.
// Now try to allocate even a volatile color // Now try to allocate even a volatile color
ColorFound = findFloatColor(LR, SparcFloatRegClass::StartOfAllRegs,
ColorFound = findFloatColor( LR, SparcFloatRegClass::StartOfAllRegs,
SparcFloatRegClass::StartOfNonVolatileRegs, SparcFloatRegClass::StartOfNonVolatileRegs,
IsColorUsedArr); IsColorUsedArr);
} }
if( ColorFound >= 0 ) { if (ColorFound >= 0) {
LR->setColor(ColorFound); // first color found in prefered order LR->setColor(ColorFound); // first color found in prefered order
LR->markForSaveAcrossCalls(); LR->markForSaveAcrossCalls();
} else { } else {
@ -249,10 +234,10 @@ void SparcFloatRegClass::colorIGNode(IGNode * Node,
// type of the Node (i.e., float/double) // type of the Node (i.e., float/double)
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
int SparcFloatRegClass::findFloatColor int SparcFloatRegClass::findFloatColor(const LiveRange *LR,
(const LiveRange *LR, unsigned Start,
unsigned Start, unsigned End, unsigned End,
std::vector<bool> &IsColorUsedArr) const std::vector<bool> &IsColorUsedArr) const
{ {
bool ColorFound = false; bool ColorFound = false;
unsigned c; unsigned c;