aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRuchira Sasanka <sasanka@students.uiuc.edu>2001-10-19 21:39:31 +0000
committerRuchira Sasanka <sasanka@students.uiuc.edu>2001-10-19 21:39:31 +0000
commit0e62aa6d1425e26702b13692a56a966762dbb0d6 (patch)
tree4696a6ee409a9e2c07b584c8bf0bad03ee3ef718
parent33eb292e127a75d51587c390241817d8c355a18b (diff)
Added code to PhyRegAlloc to mark unusable suggested regs
Added initialization to AdjList to IGNode constructor - major bug fix git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@920 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/CodeGen/RegAlloc/IGNode.cpp1
-rw-r--r--lib/CodeGen/RegAlloc/PhyRegAlloc.cpp62
-rw-r--r--lib/Target/SparcV9/RegAlloc/IGNode.cpp1
-rw-r--r--lib/Target/SparcV9/RegAlloc/PhyRegAlloc.cpp62
4 files changed, 114 insertions, 12 deletions
diff --git a/lib/CodeGen/RegAlloc/IGNode.cpp b/lib/CodeGen/RegAlloc/IGNode.cpp
index 0e8a124cd3..75007a0898 100644
--- a/lib/CodeGen/RegAlloc/IGNode.cpp
+++ b/lib/CodeGen/RegAlloc/IGNode.cpp
@@ -2,6 +2,7 @@
IGNode::IGNode(LiveRange *const PLR, unsigned int Ind): Index(Ind),
+ AdjList(),
ParentLR(PLR)
{
OnStack = false;
diff --git a/lib/CodeGen/RegAlloc/PhyRegAlloc.cpp b/lib/CodeGen/RegAlloc/PhyRegAlloc.cpp
index 98300499b1..b36e8e4443 100644
--- a/lib/CodeGen/RegAlloc/PhyRegAlloc.cpp
+++ b/lib/CodeGen/RegAlloc/PhyRegAlloc.cpp
@@ -665,11 +665,7 @@ void PhyRegAlloc::printMachineCode()
// else it must be a register value
const int RegNum = Op.getAllocatedRegNum();
- //if( RegNum != 1000)
-
- cout << "\t" << "%" << MRI.getUnifiedRegName( RegNum );
- // else cout << "\t<*NoReg*>";
-
+ cout << "\t" << "%" << MRI.getUnifiedRegName( RegNum );
}
}
@@ -740,6 +736,8 @@ void PhyRegAlloc::colorCallRetArgs()
}
+
+
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
@@ -772,6 +770,52 @@ void PhyRegAlloc::printLabel(const Value *const Val)
//----------------------------------------------------------------------------
+// This method calls setSugColorUsable method of each live range. This
+// will determine whether the suggested color of LR is really usable.
+// A suggested color is not usable when the suggested color is volatile
+// AND when there are call interferences
+//----------------------------------------------------------------------------
+
+void PhyRegAlloc::markUnusableSugColors()
+{
+ if(DEBUG_RA ) cout << "Creating LR lists ..." << endl;
+
+ // hash map iterator
+ LiveRangeMapType::const_iterator HMI = (LRI.getLiveRangeMap())->begin();
+ LiveRangeMapType::const_iterator HMIEnd = (LRI.getLiveRangeMap())->end();
+
+ for( ; HMI != HMIEnd ; ++HMI ) {
+
+ if( (*HMI).first ) {
+
+ LiveRange *L = (*HMI).second; // get the LiveRange
+
+ if(L) {
+ if( L->hasSuggestedColor() ) {
+
+ int RCID = (L->getRegClass())->getID();
+ if( MRI.isRegVolatile( RCID, L->getSuggestedColor()) &&
+ L->isCallInterference() )
+ L->setSuggestedColorUsable( false );
+ else
+ L->setSuggestedColorUsable( true );
+ }
+ } // if L->hasSuggestedColor()
+ }
+ } // for all LR's in hash map
+}
+
+
+
+
+
+
+
+
+
+
+
+//----------------------------------------------------------------------------
// The entry pont to Register Allocation
//----------------------------------------------------------------------------
@@ -814,7 +858,13 @@ void PhyRegAlloc::allocateRegisters()
RegClassList[ rc ]->printIG();
}
- // color all register classes
+
+ // mark un-usable suggested color before graph coloring algorithm.
+ // When this is done, the graph coloring algo will not reserve
+ // suggested color unnecessarily - they can be used by another LR
+ markUnusableSugColors();
+
+ // color all register classes using the graph coloring algo
for( unsigned int rc=0; rc < NumOfRegClasses ; rc++)
RegClassList[ rc ]->colorAllRegs();
diff --git a/lib/Target/SparcV9/RegAlloc/IGNode.cpp b/lib/Target/SparcV9/RegAlloc/IGNode.cpp
index 0e8a124cd3..75007a0898 100644
--- a/lib/Target/SparcV9/RegAlloc/IGNode.cpp
+++ b/lib/Target/SparcV9/RegAlloc/IGNode.cpp
@@ -2,6 +2,7 @@
IGNode::IGNode(LiveRange *const PLR, unsigned int Ind): Index(Ind),
+ AdjList(),
ParentLR(PLR)
{
OnStack = false;
diff --git a/lib/Target/SparcV9/RegAlloc/PhyRegAlloc.cpp b/lib/Target/SparcV9/RegAlloc/PhyRegAlloc.cpp
index 98300499b1..b36e8e4443 100644
--- a/lib/Target/SparcV9/RegAlloc/PhyRegAlloc.cpp
+++ b/lib/Target/SparcV9/RegAlloc/PhyRegAlloc.cpp
@@ -665,11 +665,7 @@ void PhyRegAlloc::printMachineCode()
// else it must be a register value
const int RegNum = Op.getAllocatedRegNum();
- //if( RegNum != 1000)
-
- cout << "\t" << "%" << MRI.getUnifiedRegName( RegNum );
- // else cout << "\t<*NoReg*>";
-
+ cout << "\t" << "%" << MRI.getUnifiedRegName( RegNum );
}
}
@@ -740,6 +736,8 @@ void PhyRegAlloc::colorCallRetArgs()
}
+
+
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
@@ -772,6 +770,52 @@ void PhyRegAlloc::printLabel(const Value *const Val)
//----------------------------------------------------------------------------
+// This method calls setSugColorUsable method of each live range. This
+// will determine whether the suggested color of LR is really usable.
+// A suggested color is not usable when the suggested color is volatile
+// AND when there are call interferences
+//----------------------------------------------------------------------------
+
+void PhyRegAlloc::markUnusableSugColors()
+{
+ if(DEBUG_RA ) cout << "Creating LR lists ..." << endl;
+
+ // hash map iterator
+ LiveRangeMapType::const_iterator HMI = (LRI.getLiveRangeMap())->begin();
+ LiveRangeMapType::const_iterator HMIEnd = (LRI.getLiveRangeMap())->end();
+
+ for( ; HMI != HMIEnd ; ++HMI ) {
+
+ if( (*HMI).first ) {
+
+ LiveRange *L = (*HMI).second; // get the LiveRange
+
+ if(L) {
+ if( L->hasSuggestedColor() ) {
+
+ int RCID = (L->getRegClass())->getID();
+ if( MRI.isRegVolatile( RCID, L->getSuggestedColor()) &&
+ L->isCallInterference() )
+ L->setSuggestedColorUsable( false );
+ else
+ L->setSuggestedColorUsable( true );
+ }
+ } // if L->hasSuggestedColor()
+ }
+ } // for all LR's in hash map
+}
+
+
+
+
+
+
+
+
+
+
+
+//----------------------------------------------------------------------------
// The entry pont to Register Allocation
//----------------------------------------------------------------------------
@@ -814,7 +858,13 @@ void PhyRegAlloc::allocateRegisters()
RegClassList[ rc ]->printIG();
}
- // color all register classes
+
+ // mark un-usable suggested color before graph coloring algorithm.
+ // When this is done, the graph coloring algo will not reserve
+ // suggested color unnecessarily - they can be used by another LR
+ markUnusableSugColors();
+
+ // color all register classes using the graph coloring algo
for( unsigned int rc=0; rc < NumOfRegClasses ; rc++)
RegClassList[ rc ]->colorAllRegs();