* Code Cleanups
authorChris Lattner <sabre@nondot.org>
Tue, 5 Feb 2002 03:52:29 +0000 (03:52 +0000)
committerChris Lattner <sabre@nondot.org>
Tue, 5 Feb 2002 03:52:29 +0000 (03:52 +0000)
* Removal dependencies on Type.h & remove uses of getTypeID()

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@1718 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/RegAlloc/LiveRangeInfo.cpp
lib/CodeGen/RegAlloc/PhyRegAlloc.cpp
lib/Target/SparcV9/RegAlloc/LiveRangeInfo.cpp
lib/Target/SparcV9/RegAlloc/PhyRegAlloc.cpp
lib/Target/SparcV9/SparcV9RegClassInfo.cpp
lib/Target/SparcV9/SparcV9RegInfo.cpp

index efa428c9098467365ce14a0fae362c255cfd6972..7d43763a15b544cd3d111c84e81d0e81ea118ce7 100644 (file)
@@ -327,7 +327,7 @@ void LiveRangeInfo::coalesceLRs()
            if( ! LROfUse ) {           // if LR of use is not found
 
              //don't warn about labels
-             if (!((*UseI)->getType())->isLabelType() && DEBUG_RA)
+             if (!isa<BasicBlock>(*UseI) && DEBUG_RA)
                cerr << " !! Warning: No LR for use " << RAV(*UseI) << "\n";
              continue;                 // ignore and continue
            }
@@ -338,21 +338,19 @@ void LiveRangeInfo::coalesceLRs()
            //RegClass *const RCOfUse = LROfUse->getRegClass();
            //if( RCOfDef == RCOfUse ) {  // if the reg classes are the same
 
-           if( MRI.getRegType(LROfDef) == MRI.getRegType(LROfUse) ) {
+           if (MRI.getRegType(LROfDef) == MRI.getRegType(LROfUse)) {
 
              // If the two RegTypes are the same
-
-             if( ! RCOfDef->getInterference(LROfDef, LROfUse) ) {
+             if (!RCOfDef->getInterference(LROfDef, LROfUse) ) {
 
                unsigned CombinedDegree =
                  LROfDef->getUserIGNode()->getNumOfNeighbors() + 
                  LROfUse->getUserIGNode()->getNumOfNeighbors();
 
-               if( CombinedDegree <= RCOfDef->getNumOfAvailRegs() ) {
-
+               if (CombinedDegree <= RCOfDef->getNumOfAvailRegs()) {
                  // if both LRs do not have suggested colors
-                 if( ! (LROfDef->hasSuggestedColor() &&  
-                        LROfUse->hasSuggestedColor() ) ) {
+                 if (!(LROfDef->hasSuggestedColor() &&  
+                        LROfUse->hasSuggestedColor())) {
                    
                    RCOfDef->mergeIGNodesOfLRs(LROfDef, LROfUse);
                    unionAndUpdateLRs(LROfDef, LROfUse);
index 938ab1b8512a222092ad6242574e1284c5f10371..01e4879cf87dd534be6ae847ca2a0445bad4882b 100644 (file)
@@ -20,6 +20,7 @@
 #include "llvm/Target/TargetMachine.h"
 #include "llvm/Target/MachineFrameInfo.h"
 #include "llvm/Method.h"
+#include "llvm/Type.h"
 #include <iostream>
 #include <math.h>
 using std::cerr;
@@ -1164,22 +1165,19 @@ void PhyRegAlloc::markUnusableSugColors()
 // this method allocate a new spill position on the stack.
 //----------------------------------------------------------------------------
 
-void PhyRegAlloc::allocateStackSpace4SpilledLRs()
-{
-  if(DEBUG_RA ) cerr << "\nsetting LR stack offsets ...\n";
+void PhyRegAlloc::allocateStackSpace4SpilledLRs() {
+  if (DEBUG_RA) cerr << "\nsetting LR stack offsets ...\n";
 
-  // hash map iterator
-  LiveRangeMapType::const_iterator HMI = (LRI.getLiveRangeMap())->begin();   
-  LiveRangeMapType::const_iterator HMIEnd = (LRI.getLiveRangeMap())->end();   
+  LiveRangeMapType::const_iterator HMI    = LRI.getLiveRangeMap()->begin();   
+  LiveRangeMapType::const_iterator HMIEnd = LRI.getLiveRangeMap()->end();   
 
-    for(  ; HMI != HMIEnd ; ++HMI ) {
-      if(HMI->first && HMI->second) {
-       LiveRange *L = HMI->second;      // get the LiveRange
-        if( ! L->hasColor() ) 
-          //  NOTE: ** allocating the size of long Type **
-          L->setSpillOffFromFP(mcInfo.allocateSpilledValue(TM, Type::LongTy));
-      }
-    } // for all LR's in hash map
+  for( ; HMI != HMIEnd ; ++HMI) {
+    if (HMI->first && HMI->second) {
+      LiveRange *L = HMI->second;      // get the LiveRange
+      if (!L->hasColor())   //  NOTE: ** allocating the size of long Type **
+        L->setSpillOffFromFP(mcInfo.allocateSpilledValue(TM, Type::LongTy));
+    }
+  } // for all LR's in hash map
 }
 
 
index efa428c9098467365ce14a0fae362c255cfd6972..7d43763a15b544cd3d111c84e81d0e81ea118ce7 100644 (file)
@@ -327,7 +327,7 @@ void LiveRangeInfo::coalesceLRs()
            if( ! LROfUse ) {           // if LR of use is not found
 
              //don't warn about labels
-             if (!((*UseI)->getType())->isLabelType() && DEBUG_RA)
+             if (!isa<BasicBlock>(*UseI) && DEBUG_RA)
                cerr << " !! Warning: No LR for use " << RAV(*UseI) << "\n";
              continue;                 // ignore and continue
            }
@@ -338,21 +338,19 @@ void LiveRangeInfo::coalesceLRs()
            //RegClass *const RCOfUse = LROfUse->getRegClass();
            //if( RCOfDef == RCOfUse ) {  // if the reg classes are the same
 
-           if( MRI.getRegType(LROfDef) == MRI.getRegType(LROfUse) ) {
+           if (MRI.getRegType(LROfDef) == MRI.getRegType(LROfUse)) {
 
              // If the two RegTypes are the same
-
-             if( ! RCOfDef->getInterference(LROfDef, LROfUse) ) {
+             if (!RCOfDef->getInterference(LROfDef, LROfUse) ) {
 
                unsigned CombinedDegree =
                  LROfDef->getUserIGNode()->getNumOfNeighbors() + 
                  LROfUse->getUserIGNode()->getNumOfNeighbors();
 
-               if( CombinedDegree <= RCOfDef->getNumOfAvailRegs() ) {
-
+               if (CombinedDegree <= RCOfDef->getNumOfAvailRegs()) {
                  // if both LRs do not have suggested colors
-                 if( ! (LROfDef->hasSuggestedColor() &&  
-                        LROfUse->hasSuggestedColor() ) ) {
+                 if (!(LROfDef->hasSuggestedColor() &&  
+                        LROfUse->hasSuggestedColor())) {
                    
                    RCOfDef->mergeIGNodesOfLRs(LROfDef, LROfUse);
                    unionAndUpdateLRs(LROfDef, LROfUse);
index 938ab1b8512a222092ad6242574e1284c5f10371..01e4879cf87dd534be6ae847ca2a0445bad4882b 100644 (file)
@@ -20,6 +20,7 @@
 #include "llvm/Target/TargetMachine.h"
 #include "llvm/Target/MachineFrameInfo.h"
 #include "llvm/Method.h"
+#include "llvm/Type.h"
 #include <iostream>
 #include <math.h>
 using std::cerr;
@@ -1164,22 +1165,19 @@ void PhyRegAlloc::markUnusableSugColors()
 // this method allocate a new spill position on the stack.
 //----------------------------------------------------------------------------
 
-void PhyRegAlloc::allocateStackSpace4SpilledLRs()
-{
-  if(DEBUG_RA ) cerr << "\nsetting LR stack offsets ...\n";
+void PhyRegAlloc::allocateStackSpace4SpilledLRs() {
+  if (DEBUG_RA) cerr << "\nsetting LR stack offsets ...\n";
 
-  // hash map iterator
-  LiveRangeMapType::const_iterator HMI = (LRI.getLiveRangeMap())->begin();   
-  LiveRangeMapType::const_iterator HMIEnd = (LRI.getLiveRangeMap())->end();   
+  LiveRangeMapType::const_iterator HMI    = LRI.getLiveRangeMap()->begin();   
+  LiveRangeMapType::const_iterator HMIEnd = LRI.getLiveRangeMap()->end();   
 
-    for(  ; HMI != HMIEnd ; ++HMI ) {
-      if(HMI->first && HMI->second) {
-       LiveRange *L = HMI->second;      // get the LiveRange
-        if( ! L->hasColor() ) 
-          //  NOTE: ** allocating the size of long Type **
-          L->setSpillOffFromFP(mcInfo.allocateSpilledValue(TM, Type::LongTy));
-      }
-    } // for all LR's in hash map
+  for( ; HMI != HMIEnd ; ++HMI) {
+    if (HMI->first && HMI->second) {
+      LiveRange *L = HMI->second;      // get the LiveRange
+      if (!L->hasColor())   //  NOTE: ** allocating the size of long Type **
+        L->setSpillOffFromFP(mcInfo.allocateSpilledValue(TM, Type::LongTy));
+    }
+  } // for all LR's in hash map
 }
 
 
index 96ff39ef046ffcebb6bc358fb6512d76482ad572..b25dd01ba93307987e414e6c7c340d47487f0d89 100644 (file)
@@ -1,6 +1,7 @@
 #include "SparcRegClassInfo.h"
 #include "llvm/CodeGen/IGNode.h"
 #include "llvm/Target/Sparc.h"
+#include "llvm/Type.h"
 #include <iostream>
 using std::cerr;
 
@@ -145,10 +146,8 @@ void SparcIntRegClass::colorIGNode(IGNode * Node, bool IsColorUsedArr[]) const {
 //     If a color is still not fond, mark for spilling
 //
 //----------------------------------------------------------------------------
-void SparcFloatRegClass::colorIGNode(IGNode * Node,bool IsColorUsedArr[]) const
-{
-
-  LiveRange * LR = Node->getParentLR();
+void SparcFloatRegClass::colorIGNode(IGNode * Node,bool IsColorUsedArr[]) const{
+  LiveRange *LR = Node->getParentLR();
   unsigned NumNeighbors =  Node->getNumOfNeighbors();   // total # of neighbors
 
   for(unsigned n=0; n < NumNeighbors; n++) {            // for each neigh 
@@ -157,7 +156,7 @@ void SparcFloatRegClass::colorIGNode(IGNode * Node,bool IsColorUsedArr[]) const
 
       if( NeighLR->hasColor() )   {                     // if neigh has a color
        IsColorUsedArr[ NeighLR->getColor() ] = true; // record that color
-       if( NeighLR->getTypeID() == Type::DoubleTyID )
+       if (NeighLR->getType() == Type::DoubleTy)
          IsColorUsedArr[ (NeighLR->getColor()) + 1 ] = true;  
       }
       else if( NeighLR->hasSuggestedColor() )   {   // if neigh has sugg color
@@ -167,7 +166,7 @@ void SparcFloatRegClass::colorIGNode(IGNode * Node,bool IsColorUsedArr[]) const
          // if the neighbout can use the suggested color 
          
          IsColorUsedArr[ NeighLR->getSuggestedColor() ] = true;
-         if( NeighLR->getTypeID() == Type::DoubleTyID )
+         if (NeighLR->getType() == Type::DoubleTy)
            IsColorUsedArr[ (NeighLR->getSuggestedColor()) + 1 ] = true;  
        }
 
@@ -200,7 +199,7 @@ void SparcFloatRegClass::colorIGNode(IGNode * Node,bool IsColorUsedArr[]) const
   // cannot go there. By doing that, we provide more space for singles
   // in f0 - f31
   //
-  if( LR->getTypeID() == Type::DoubleTyID )       
+  if (LR->getType() == Type::DoubleTy)       
     ColorFound = findFloatColor( LR, 32, 64, IsColorUsedArr );
     
 
@@ -265,11 +264,11 @@ void SparcFloatRegClass::colorIGNode(IGNode * Node,bool IsColorUsedArr[]) const
 
 int SparcFloatRegClass::findFloatColor(const LiveRange *LR, 
                                       unsigned Start, unsigned End, 
-                                      bool IsColorUsedArr[] ) const {
+                                      bool IsColorUsedArr[]) const {
   bool ColorFound = false;
   unsigned c;
 
-  if (LR->getTypeID() == Type::DoubleTyID) { 
+  if (LR->getType() == Type::DoubleTy) { 
     // find first unused color for a double 
     for (c=Start; c < End ; c+= 2)
       if (!IsColorUsedArr[c] && !IsColorUsedArr[c+1]) 
index 879b01efc447c9eae39250f18bf5f3be768626e8..9af470aa0124f91c8f867e0c58827b0842eac65b 100644 (file)
@@ -143,17 +143,16 @@ UltraSparcRegInfo::getCallInstRetAddr(const MachineInstr *CallMI) const {
 // of a LiveRange, Value and using the unified RegClassID
 //
 int UltraSparcRegInfo::getRegType(const LiveRange *LR) const {
-  unsigned Typ;
   switch (LR->getRegClass()->getID()) {
   case IntRegClassID: return IntRegType; 
-  case FloatRegClassID: 
-    Typ = LR->getTypeID();
-    if (Typ == Type::FloatTyID
+  case FloatRegClassID: {
+    const Type *Typ = LR->getType();
+    if (Typ == Type::FloatTy) 
       return FPSingleRegType;
-    else if (Typ == Type::DoubleTyID)
+    else if (Typ == Type::DoubleTy)
       return FPDoubleRegType;
     assert(0 && "Unknown type in FloatRegClass");
-    
+  }
   case IntCCRegClassID: return IntCCRegType; 
   case FloatCCRegClassID: return FloatCCRegType; 
   default: assert( 0 && "Unknown reg class ID");
@@ -1444,7 +1443,7 @@ void UltraSparcRegInfo::printReg(const LiveRange *LR) {
 
   } else if (RegClassID == FloatRegClassID) {
     cerr << "[" << SparcFloatRegOrder::getRegName(LR->getColor());
-    if( LR->getTypeID() == Type::DoubleTyID )
+    if( LR->getType() == Type::DoubleTy)
       cerr << "+" << SparcFloatRegOrder::getRegName(LR->getColor()+1);
     cerr << "]\n";
   }