llvm.org GIT mirror llvm / 59b1c56
Use getRegClassID() instead of getRegClass()->getID(), since it's there. Shorten the markSuggestedColorUsable method. Add a switch for saving reg. alloc. state (coming soon). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@8697 91177308-0d34-0410-b5e6-96231b3b80d8 Brian Gaeke 17 years ago
2 changed file(s) with 30 addition(s) and 34 deletion(s). Raw diff Collapse all Expand all
3838 clEnumValN(RA_DEBUG_Verbose, "v", "extra debug output"),
3939 0));
4040
41 static cl::opt
42 SaveRegAllocState("save-ra-state", cl::Hidden,
43 cl::desc("write reg. allocator state into module"));
44
4145 FunctionPass *getRegisterAllocator(TargetMachine &T) {
4246 return new PhyRegAlloc (T);
4347 }
7579 // if the Value * is not null, and LR is not yet written to the IGNodeList
7680 if (!(L->getUserIGNode()) ) {
7781 RegClass *const RC = // RegClass of first value in the LR
78 RegClassList[ L->getRegClass()->getID() ];
82 RegClassList[ L->getRegClassID() ];
7983 RC->addLRToIG(L); // add this LR to an IG
8084 }
8185 }
426430 // An operand may have a color whether or not it needs spilling
427431 if (LR->hasColor())
428432 MInst->SetRegForOperand(OpNum,
429 MRI.getUnifiedRegNum(LR->getRegClass()->getID(),
433 MRI.getUnifiedRegNum(LR->getRegClassID(),
430434 LR->getColor()));
431435 }
432436 }
674678 // This may insert code before and after MInst to free up the value. If so,
675679 // this code should be first/last in the spill sequence before/after MInst.
676680 int TmpRegU=(LR->hasColor()
677 ? MRI.getUnifiedRegNum(LR->getRegClass()->getID(),LR->getColor())
681 ? MRI.getUnifiedRegNum(LR->getRegClassID(),LR->getColor())
678682 : getUsableUniRegAtMI(RegType, &LVSetBef, MInst, MIBef,MIAft));
679683
680684 // Set the operand first so that it this register does not get used
11171121
11181122
11191123 //----------------------------------------------------------------------------
1120 // This method calls setSugColorUsable method of each live range. This
1121 // will determine whether the suggested color of LR is really usable.
1122 // A suggested color is not usable when the suggested color is volatile
1123 // AND when there are call interferences
1124 // This method determines whether the suggested color of each live range
1125 // is really usable, and then calls its setSuggestedColorUsable() method to
1126 // record the answer. A suggested color is NOT usable when the suggested color
1127 // is volatile AND when there are call interferences.
11241128 //----------------------------------------------------------------------------
11251129
11261130 void PhyRegAlloc::markUnusableSugColors()
11311135 for (; HMI != HMIEnd ; ++HMI ) {
11321136 if (HMI->first) {
11331137 LiveRange *L = HMI->second; // get the LiveRange
1134 if (L) {
1135 if (L->hasSuggestedColor()) {
1136 int RCID = L->getRegClass()->getID();
1137 if (MRI.isRegVolatile( RCID, L->getSuggestedColor()) &&
1138 L->isCallInterference() )
1139 L->setSuggestedColorUsable( false );
1140 else
1141 L->setSuggestedColorUsable( true );
1142 }
1143 } // if L->hasSuggestedColor()
1138 if (L && L->hasSuggestedColor ())
1139 L->setSuggestedColorUsable
1140 (!(MRI.isRegVolatile (L->getRegClassID (), L->getSuggestedColor ())
1141 && L->isCallInterference ()));
11441142 }
11451143 } // for all LR's in hash map
11461144 }
3838 clEnumValN(RA_DEBUG_Verbose, "v", "extra debug output"),
3939 0));
4040
41 static cl::opt
42 SaveRegAllocState("save-ra-state", cl::Hidden,
43 cl::desc("write reg. allocator state into module"));
44
4145 FunctionPass *getRegisterAllocator(TargetMachine &T) {
4246 return new PhyRegAlloc (T);
4347 }
7579 // if the Value * is not null, and LR is not yet written to the IGNodeList
7680 if (!(L->getUserIGNode()) ) {
7781 RegClass *const RC = // RegClass of first value in the LR
78 RegClassList[ L->getRegClass()->getID() ];
82 RegClassList[ L->getRegClassID() ];
7983 RC->addLRToIG(L); // add this LR to an IG
8084 }
8185 }
426430 // An operand may have a color whether or not it needs spilling
427431 if (LR->hasColor())
428432 MInst->SetRegForOperand(OpNum,
429 MRI.getUnifiedRegNum(LR->getRegClass()->getID(),
433 MRI.getUnifiedRegNum(LR->getRegClassID(),
430434 LR->getColor()));
431435 }
432436 }
674678 // This may insert code before and after MInst to free up the value. If so,
675679 // this code should be first/last in the spill sequence before/after MInst.
676680 int TmpRegU=(LR->hasColor()
677 ? MRI.getUnifiedRegNum(LR->getRegClass()->getID(),LR->getColor())
681 ? MRI.getUnifiedRegNum(LR->getRegClassID(),LR->getColor())
678682 : getUsableUniRegAtMI(RegType, &LVSetBef, MInst, MIBef,MIAft));
679683
680684 // Set the operand first so that it this register does not get used
11171121
11181122
11191123 //----------------------------------------------------------------------------
1120 // This method calls setSugColorUsable method of each live range. This
1121 // will determine whether the suggested color of LR is really usable.
1122 // A suggested color is not usable when the suggested color is volatile
1123 // AND when there are call interferences
1124 // This method determines whether the suggested color of each live range
1125 // is really usable, and then calls its setSuggestedColorUsable() method to
1126 // record the answer. A suggested color is NOT usable when the suggested color
1127 // is volatile AND when there are call interferences.
11241128 //----------------------------------------------------------------------------
11251129
11261130 void PhyRegAlloc::markUnusableSugColors()
11311135 for (; HMI != HMIEnd ; ++HMI ) {
11321136 if (HMI->first) {
11331137 LiveRange *L = HMI->second; // get the LiveRange
1134 if (L) {
1135 if (L->hasSuggestedColor()) {
1136 int RCID = L->getRegClass()->getID();
1137 if (MRI.isRegVolatile( RCID, L->getSuggestedColor()) &&
1138 L->isCallInterference() )
1139 L->setSuggestedColorUsable( false );
1140 else
1141 L->setSuggestedColorUsable( true );
1142 }
1143 } // if L->hasSuggestedColor()
1138 if (L && L->hasSuggestedColor ())
1139 L->setSuggestedColorUsable
1140 (!(MRI.isRegVolatile (L->getRegClassID (), L->getSuggestedColor ())
1141 && L->isCallInterference ()));
11441142 }
11451143 } // for all LR's in hash map
11461144 }