[llvm-commits] CVS: llvm/lib/Target/Sparc/SparcRegClassInfo.cpp

Misha Brukman brukman at cs.uiuc.edu
Wed May 21 13:06:01 PDT 2003


Changes in directory llvm/lib/Target/Sparc:

SparcRegClassInfo.cpp updated: 1.19 -> 1.20

---
Log message:

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.


---
Diffs of the changes:

Index: llvm/lib/Target/Sparc/SparcRegClassInfo.cpp
diff -u llvm/lib/Target/Sparc/SparcRegClassInfo.cpp:1.19 llvm/lib/Target/Sparc/SparcRegClassInfo.cpp:1.20
--- llvm/lib/Target/Sparc/SparcRegClassInfo.cpp:1.19	Wed May 21 12:59:06 2003
+++ llvm/lib/Target/Sparc/SparcRegClassInfo.cpp	Wed May 21 13:05:35 2003
@@ -26,33 +26,26 @@
 {
   LiveRange *LR = Node->getParentLR();
 
-  if( DEBUG_RA ) {
+  if (DEBUG_RA) {
     std::cerr << "\nColoring LR [CallInt=" << LR->isCallInterference() <<"]:"; 
     printSet(*LR);
   }
 
-  if( LR->hasSuggestedColor() ) {
-
+  if (LR->hasSuggestedColor()) {
     unsigned SugCol = LR->getSuggestedColor();
-
     if (!IsColorUsedArr[SugCol]) {
-
-      if( LR->isSuggestedColorUsable()  ) {
-
+      if (LR->isSuggestedColorUsable()) {
 	// 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)
 	  std::cerr << "\n  -Coloring with sug color: " << SugCol;
 
-	LR->setColor(  LR->getSuggestedColor() );
+	LR->setColor(LR->getSuggestedColor());
 	return;
+      } else if(DEBUG_RA) {
+        std::cerr << "\n Couldn't alloc Sug col - LR voloatile & calls interf";
       }
-       else if(DEBUG_RA)
-	 std::cerr << "\n Couldn't alloc Sug col - LR voloatile & calls interf";
-
-    }
-    else if (DEBUG_RA) {                // can't allocate the suggested col
+    } else if (DEBUG_RA) {                // can't allocate the suggested col
       std::cerr << "\n  Could NOT allocate the suggested color (already used) ";
       printSet(*LR); std::cerr << "\n";
     }
@@ -62,12 +55,10 @@
   bool ColorFound= false;               // have we found a color yet?
 
   //if this Node is between calls
-  if( ! LR->isCallInterference() ) { 
-
+  if (! LR->isCallInterference()) { 
     // start with volatiles (we can  allocate volatiles safely)
     SearchStart = SparcIntRegClass::StartOfAllRegs;  
-  }
-  else {           
+  } else {           
     // start with non volatiles (no non-volatiles)
     SearchStart =  SparcIntRegClass::StartOfNonVolatileRegs;  
   }
@@ -75,11 +66,14 @@
   unsigned c=0;                         // color
  
   // find first unused color
-  for( c=SearchStart; c < SparcIntRegClass::NumOfAvailRegs; c++) { 
-    if(!IsColorUsedArr[c] ) { ColorFound = true; break; }
+  for (c=SearchStart; c < SparcIntRegClass::NumOfAvailRegs; c++) { 
+    if (!IsColorUsedArr[c]) {
+      ColorFound = true;
+      break;
+    }
   }
 
-  if( ColorFound) {
+  if (ColorFound) {
     LR->setColor(c);                  // first color found in preffered order
     if (DEBUG_RA) std::cerr << "\n  Colored after first search with col " << c;
   }
@@ -87,24 +81,26 @@
   // if color is not found because of call interference
   // 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
     SearchStart = SparcIntRegClass::StartOfAllRegs;  
 
     // find first unused volatile color
     for(c=SearchStart; c < SparcIntRegClass::StartOfNonVolatileRegs; c++) { 
-      if( ! IsColorUsedArr[ c ] ) { ColorFound = true; break; }
+      if (! IsColorUsedArr[c]) {
+        ColorFound = true;
+        break;
+      }
     }
 
     if (ColorFound) { 
-       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)
-         std::cerr << "\n  Colored after SECOND search with col " << c;
+      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)
+        std::cerr << "\n  Colored after SECOND search with col " << c;
     }
   }
 
@@ -117,10 +113,6 @@
 }
 
 
-
-
-
-
 //-----------------------------------------------------------------------------
 // Float Register Class - method for coloring a node in the interference graph.
 //
@@ -150,17 +142,17 @@
     IGNode *NeighIGNode = Node->getAdjIGNode(n);
     LiveRange *NeighLR = NeighIGNode->getParentLR();
     
-    if( NeighLR->hasColor() &&
+    if (NeighLR->hasColor() &&
 	NeighLR->getType() == Type::DoubleTy) {
       IsColorUsedArr[ (NeighLR->getColor()) + 1 ] = true;  
       
     } else if (NeighLR->hasSuggestedColor() &&
                NeighLR-> isSuggestedColorUsable() ) {
 
-	  // if the neighbour can use the suggested color 
-	  IsColorUsedArr[ NeighLR->getSuggestedColor() ] = true;
-	  if (NeighLR->getType() == Type::DoubleTy)
-	    IsColorUsedArr[ (NeighLR->getSuggestedColor()) + 1 ] = true;  
+      // if the neighbour can use the suggested color 
+      IsColorUsedArr[ NeighLR->getSuggestedColor() ] = true;
+      if (NeighLR->getType() == Type::DoubleTy)
+        IsColorUsedArr[ (NeighLR->getSuggestedColor()) + 1 ] = true;  
     }
   }
 
@@ -190,9 +182,8 @@
   //
   if (LR->getType() == Type::DoubleTy)       
     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);                
     return;
   } else { 
@@ -204,36 +195,30 @@
     unsigned SearchStart;                 // start pos of color in pref-order
 
     //if this Node is between calls (i.e., no call interferences )
-    if( ! isCallInterf ) {
+    if (! isCallInterf) {
       // start with volatiles (we can  allocate volatiles safely)
       SearchStart = SparcFloatRegClass::StartOfAllRegs;  
-    }
-    else {           
+    } else {
       // start with non volatiles (no non-volatiles)
       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);                  
     return;
-  }
-  else if( isCallInterf ) { 
-
+  } else if (isCallInterf) { 
     // We are here because there is a call interference and no non-volatile
     // color could be found.
     // Now try to allocate even a volatile color
-
-    ColorFound = findFloatColor( LR, SparcFloatRegClass::StartOfAllRegs, 
+    ColorFound = findFloatColor(LR, SparcFloatRegClass::StartOfAllRegs, 
 				SparcFloatRegClass::StartOfNonVolatileRegs,
 				IsColorUsedArr);
   }
 
-  if( ColorFound >= 0 ) {
+  if (ColorFound >= 0) {
     LR->setColor(ColorFound);         // first color found in prefered order
     LR->markForSaveAcrossCalls();  
   } else {
@@ -249,10 +234,10 @@
 // type of the Node (i.e., float/double)
 //-----------------------------------------------------------------------------
 
-int SparcFloatRegClass::findFloatColor
-(const LiveRange *LR, 
- unsigned Start, unsigned End, 
- std::vector<bool> &IsColorUsedArr) const
+int SparcFloatRegClass::findFloatColor(const LiveRange *LR, 
+                                       unsigned Start,
+                                       unsigned End, 
+                                       std::vector<bool> &IsColorUsedArr) const
 {
   bool ColorFound = false;
   unsigned c;





More information about the llvm-commits mailing list