added suggesting color support
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@673 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/CodeGen/RegAlloc/LiveRange.h b/lib/CodeGen/RegAlloc/LiveRange.h
index d8e130a..9c4d450 100644
--- a/lib/CodeGen/RegAlloc/LiveRange.h
+++ b/lib/CodeGen/RegAlloc/LiveRange.h
@@ -39,6 +39,9 @@
// bool mustLoadFromStack; // must load from stack at start of method
+
+ int SuggestedColor; // The suggested color for this LR
+
public:
@@ -92,9 +95,27 @@
}
+ inline void setSuggestedColor(int Col) {
+ //assert( (SuggestedColor == -1) && "Changing an already suggested color");
+
+ if(SuggestedColor == -1 )
+ SuggestedColor = Col;
+ else if (DEBUG_RA)
+ cout << "Already has a suggested color " << Col << endl;
+ }
+
+ inline unsigned getSuggestedColor() const {
+ assert( SuggestedColor != -1); // only a valid color is obtained
+ return (unsigned) SuggestedColor;
+ }
+
+ inline bool hasSuggestedColor() const {
+ return ( SuggestedColor > -1);
+ }
+
inline LiveRange() : ValueSet() , CallInterferenceList()
{
- Color = -1; // not yet colored
+ Color = SuggestedColor = -1; // not yet colored
mustSpill = mustSaveAcrossCalls = false;
MyRegClass = NULL;
UserIGNode = NULL;
diff --git a/lib/CodeGen/RegAlloc/LiveRangeInfo.h b/lib/CodeGen/RegAlloc/LiveRangeInfo.h
index da56017..2a8eb2f 100644
--- a/lib/CodeGen/RegAlloc/LiveRangeInfo.h
+++ b/lib/CodeGen/RegAlloc/LiveRangeInfo.h
@@ -42,7 +42,7 @@
typedef hash_map <const Value *, LiveRange *, hashFuncValue> LiveRangeMapType;
-
+typedef vector <const Instruction *> CallRetInstrListType;
class LiveRangeInfo
{
@@ -56,7 +56,9 @@
const TargetMachine& TM; // target machine description
vector<RegClass *> & RegClassList;// a vector containing register classess
+ const MachineRegInfo& MRI; // machine reg info
+ CallRetInstrListType CallRetInstrList; // a list of all call/ret instrs
void unionAndUpdateLRs(LiveRange *L1, LiveRange *L2);
@@ -72,12 +74,22 @@
void constructLiveRanges();
+ inline void addLRToMap(const Value *Val, LiveRange *LR) {
+ assert( Val && LR && "Val/LR is NULL!\n");
+ assert( (! LiveRangeMap[ Val ]) && "LR already set in map");
+ LiveRangeMap[ Val ] = LR;
+ }
+
+
inline const LiveRangeMapType *const getLiveRangeMap() const
{ return &LiveRangeMap; }
inline LiveRange *getLiveRangeForValue( const Value *const Val)
{ return LiveRangeMap[ Val ]; }
+ inline CallRetInstrListType &getCallRetInstrList() {
+ return CallRetInstrList;
+ }
diff --git a/lib/CodeGen/RegAlloc/PhyRegAlloc.h b/lib/CodeGen/RegAlloc/PhyRegAlloc.h
index fcf2832..f96f27b 100644
--- a/lib/CodeGen/RegAlloc/PhyRegAlloc.h
+++ b/lib/CodeGen/RegAlloc/PhyRegAlloc.h
@@ -43,8 +43,8 @@
class AddedInstrns
{
public:
- vector<const MachineInstr *> InstrnsBefore;
- vector<const MachineInstr *> InstrnsAfter;
+ vector<MachineInstr *> InstrnsBefore;
+ vector<MachineInstr *> InstrnsAfter;
AddedInstrns() : InstrnsBefore(), InstrnsAfter() { }
};
@@ -65,8 +65,8 @@
const MachineRegInfo &MRI; // Machine Register information
const unsigned NumOfRegClasses; // recorded here for efficiency
- vector<const Instruction *> CallInstrList; // a list of all call instrs
- vector<const Instruction *> RetInstrList; // a list of all return instrs
+ //vector<const Instruction *> CallInstrList; // a list of all call instrs
+ //vector<const Instruction *> RetInstrList; // a list of all return instrs
AddedInstrMapType AddedInstrMap; // to store instrns added in this phase
@@ -85,7 +85,9 @@
{ LRI.constructLiveRanges(); }
void colorIncomingArgs();
+ void colorCallRetArgs();
void updateMachineCode();
+
void printLabel(const Value *const Val);
void printMachineCode();