Corrected a bug in SparcRegInfo.cpp - to add inserted instructions before a return
authorRuchira Sasanka <sasanka@students.uiuc.edu>
Tue, 23 Oct 2001 21:40:39 +0000 (21:40 +0000)
committerRuchira Sasanka <sasanka@students.uiuc.edu>
Tue, 23 Oct 2001 21:40:39 +0000 (21:40 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@969 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/SparcV9/SparcV9RegClassInfo.h
lib/Target/SparcV9/SparcV9RegInfo.cpp

index 311d035c296ee935bc504099f6244345f038cd0e..4f91268c37440b2149a664e94ac228c5e8c61181 100644 (file)
@@ -66,7 +66,7 @@ class SparcIntRegOrder{
    };
 
   // max # of colors reg coloring  can allocate
-  static unsigned int const NumOfAvailRegs = g0;
+  static unsigned int const NumOfAvailRegs = i6;
 
   static unsigned int const StartOfNonVolatileRegs = l0;
   static unsigned int const StartOfAllRegs = o0;
index b28ce51b9896b74e3dce3429fc70f6dcb8355eb5..0f3f9dc1bbaba27f78bf6e271c43c8dddf68170b 100644 (file)
@@ -621,8 +621,7 @@ void UltraSparcRegInfo::suggestReg4RetValue(const MachineInstr *const RetMI,
 
   assert( (UltraSparcInfo->getInstrInfo()).isReturn( RetMI->getOpCode() ) );
 
-  
-  suggestReg4RetAddr(RetMI, LRI);
+    suggestReg4RetAddr(RetMI, LRI);
 
   // if there is an implicit ref, that has to be the ret value
   if(  RetMI->getNumImplicitRefs() > 0 ) {
@@ -681,37 +680,37 @@ void UltraSparcRegInfo::colorRetValue(const  MachineInstr *const RetMI,
 
     unsigned RegClassID =  getRegClassIDOfValue(RetVal);
     unsigned RegType = getRegType( RetVal );
-    unsigned UniRetReg = InvalidRegNum;
-    
+
+
+    unsigned CorrectCol;
     if(RegClassID == IntRegClassID)
-      UniRetReg = getUnifiedRegNum( RegClassID, SparcIntRegOrder::i0 );
+      CorrectCol = SparcIntRegOrder::i0;
     else if(RegClassID == FloatRegClassID)
-      UniRetReg = getUnifiedRegNum( RegClassID, SparcFloatRegOrder::f0);
-     
+      CorrectCol = SparcFloatRegOrder::f0;
+    else 
+      assert( 0 && "Unknown RegClass");
 
 
     // if the LR received the suggested color, NOTHING to do
 
     if( LR->hasSuggestedColor() && LR->hasColor() )
       if( LR->getSuggestedColor() == LR->getColor() )
-       return;
+       if( LR->getColor() == CorrectCol )
+         return;
+
+    unsigned UniRetReg =  getUnifiedRegNum( RegClassID, CorrectCol );
 
     if( LR->hasColor() ) {
 
-      // We are here because the LR was allocted a regiter, but NOT
-      // the correct register.
+      // We are here because the LR was allocted a regiter
+      // It may be the suggested register or not
 
       // copy the LR of retun value to i0 or f0
 
       unsigned UniLRReg =getUnifiedRegNum( RegClassID, LR->getColor());
 
-      if(RegClassID == IntRegClassID)
-       UniRetReg = getUnifiedRegNum( RegClassID, SparcIntRegOrder::i0);
-      else if(RegClassID == FloatRegClassID)
-       UniRetReg = getUnifiedRegNum( RegClassID, SparcFloatRegOrder::f0);
-      
       AdMI = cpReg2RegMI( UniLRReg, UniRetReg, RegType); 
-
+      RetAI->InstrnsBefore.push_back( AdMI );
     }
     else 
       assert(0 && "TODO: Copy the return value from stack\n");