}
+ if( DEBUG_RA ) {
+ cout << "\nColoring LR [CallInt=" << LR->isCallInterference() <<"]:";
+ LR->printSet();
+ }
if( LR->hasSuggestedColor() ) {
- if( ! IsColorUsedArr[ LR->getSuggestedColor() ] ) {
- LR->setColor( LR->getSuggestedColor() );
- return;
+
+ unsigned SugCol = LR->getSuggestedColor();
+
+ // cout << "\n -Has sug color: " << SugCol;
+
+ if( ! IsColorUsedArr[ SugCol ] ) {
+
+ if(! (isRegVolatile( SugCol ) && LR->isCallInterference()) ) {
+
+ // if the suggested color is volatile, we should use it only if
+ // there are no call interferences. Otherwise, it will get spilled.
+
+ if (DEBUG_RA)
+ cout << "\n -Coloring with sug color: " << SugCol;
+
+ LR->setColor( LR->getSuggestedColor() );
+ return;
+ }
+ else if(DEBUG_RA)
+ cout << "\n Couldn't alloc Sug col - LR voloatile & calls interf";
+
}
else if ( DEBUG_RA ) { // can't allocate the suggested col
- cerr << " Could NOT allocate the suggested color for LR ";
+ cerr << " \n Could NOT allocate the suggested color (already used) ";
LR->printSet(); cerr << endl;
}
}
bool ColorFound= false; // have we found a color yet?
//if this Node is between calls
- if( LR->getNumOfCallInterferences() == 0) {
+ if( ! LR->isCallInterference() ) {
// start with volatiles (we can allocate volatiles safely)
SearchStart = SparcIntRegOrder::StartOfAllRegs;
if( ! IsColorUsedArr[ c ] ) { ColorFound = true; break; }
}
- if( ColorFound)
+ if( ColorFound) {
LR->setColor(c); // first color found in preffered order
-
+ if (DEBUG_RA) cout << "\n Colored after first search with col " << c ;
+ }
// if color is not found because of call interference
// try even finding a volatile color and insert save across calls
- else if( LR->getNumOfCallInterferences() )
+ else if( LR->isCallInterference() )
{
// start from 0 - try to find even a volatile this time
SearchStart = SparcIntRegOrder::StartOfAllRegs;
}
if( ColorFound) {
- LR->setColor(c);
- // since LR span across calls, must save across calls
- LR->markForSaveAcrossCalls();
+ LR->setColor(c);
+ // get the live range corresponding to live var
+ // since LR span across calls, must save across calls
+ LR->markForSaveAcrossCalls();
+
+ if(DEBUG_RA) cout << "\n Colored after SECOND search with col " << c ;
}
}
}
+ // **NOTE: We don't check for call interferences in allocating suggested
+ // color in this class since ALL registers are volatile. If this fact
+ // changes, we should change the following part
+ //- see SparcIntRegClass::colorIGNode()
+
if( LR->hasSuggestedColor() ) {
if( ! IsColorUsedArr[ LR->getSuggestedColor() ] ) {
LR->setColor( LR->getSuggestedColor() );
int ColorFound = -1; // have we found a color yet?
- unsigned NumOfCallInterf = LR->getNumOfCallInterferences();
+ bool isCallInterf = LR->isCallInterference();
// if value is a double - search the double only reigon (f32 - f63)
if( LR->getTypeID() == Type::DoubleTyID )
unsigned SearchStart; // start pos of color in pref-order
//if this Node is between calls (i.e., no call interferences )
- if( ! NumOfCallInterf ) {
+ if( ! isCallInterf ) {
// start with volatiles (we can allocate volatiles safely)
SearchStart = SparcFloatRegOrder::StartOfAllRegs;
}
}
- else if( NumOfCallInterf ) {
+ else if( isCallInterf ) {
// We are here because there is a call interference and no non-volatile
// color could be found.