aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen/RegAlloc/LiveRangeInfo.cpp
diff options
context:
space:
mode:
authorRuchira Sasanka <sasanka@students.uiuc.edu>2001-10-15 16:26:38 +0000
committerRuchira Sasanka <sasanka@students.uiuc.edu>2001-10-15 16:26:38 +0000
commita90e77061d52076d9edf09b2f1ae42db04ff14d4 (patch)
treec4631cec13b5904f3a741dea4c89090151929429 /lib/CodeGen/RegAlloc/LiveRangeInfo.cpp
parentcc3ccac238054147fdedfc2a137a33d524cbaa1d (diff)
updated suggesting/coloring of call & return args & implicit operands.
Changed added instr to a deque (from a vector) git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@831 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/RegAlloc/LiveRangeInfo.cpp')
-rw-r--r--lib/CodeGen/RegAlloc/LiveRangeInfo.cpp95
1 files changed, 43 insertions, 52 deletions
diff --git a/lib/CodeGen/RegAlloc/LiveRangeInfo.cpp b/lib/CodeGen/RegAlloc/LiveRangeInfo.cpp
index 242b30cc57..c137e676b1 100644
--- a/lib/CodeGen/RegAlloc/LiveRangeInfo.cpp
+++ b/lib/CodeGen/RegAlloc/LiveRangeInfo.cpp
@@ -108,30 +108,27 @@ void LiveRangeInfo::constructLiveRanges()
const MachineInstr * MInst = *MInstIterator;
- // Now if the machine instruction has special operands that must be
- // set with a "suggested color", do it here.
- // This will be true for call/return instructions
+ // Now if the machine instruction is a call/return instruction,
+ // add it to CallRetInstrList for processing its implicit operands
-
- if( MRI.handleSpecialMInstr(MInst, *this, RegClassList) )
- continue;
-
-
+ if( (TM.getInstrInfo()).isReturn( MInst->getOpCode()) ||
+ (TM.getInstrInfo()).isCall( MInst->getOpCode()) )
+ CallRetInstrList.push_back( MInst );
+
+
// iterate over MI operands to find defs
for( MachineInstr::val_op_const_iterator OpI(MInst);!OpI.done(); ++OpI) {
-
- // delete later from here ************
- MachineOperand::MachineOperandType OpTyp =
- OpI.getMachineOperand().getOperandType();
-
- if (DEBUG_RA && OpTyp == MachineOperand::MO_CCRegister) {
- cout << "\n**CC reg found. Is Def=" << OpI.isDef() << " Val:";
- printValue( OpI.getMachineOperand().getVRegValue() );
- cout << endl;
+ if( DEBUG_RA) {
+ MachineOperand::MachineOperandType OpTyp =
+ OpI.getMachineOperand().getOperandType();
+
+ if ( OpTyp == MachineOperand::MO_CCRegister) {
+ cout << "\n**CC reg found. Is Def=" << OpI.isDef() << " Val:";
+ printValue( OpI.getMachineOperand().getVRegValue() );
+ cout << endl;
+ }
}
- // ************* to here
-
// create a new LR iff this operand is a def
if( OpI.isDef() ) {
@@ -193,60 +190,56 @@ void LiveRangeInfo::constructLiveRanges()
}
}
-
-
-
} // if isDef()
} // for all opereands in machine instructions
} // for all machine instructions in the BB
-
} // for all BBs in method
- // go thru LLVM instructions in the basic block and suggest colors
- // for their args. Also record all CALL
- // instructions and Return instructions in the CallRetInstrList
- // This is done because since there are no reverse pointers in machine
- // instructions to find the llvm instruction, when we encounter a call
- // or a return whose args must be specailly colored (e.g., %o's for args)
- // We have to makes sure that all LRs of call/ret args are added before
- // doing this. But return value of call will not have a LR.
- BBI = Meth->begin(); // random iterator for BBs
+ // Now we have to suggest clors for call and return arg live ranges.
+ // Also, if there are implicit defs (e.g., retun value of a call inst)
+ // they must be added to the live range list
- for( ; BBI != Meth->end(); ++BBI) { // go thru BBs in random order
+ suggestRegs4CallRets();
- BasicBlock::const_iterator InstIt = (*BBI)->begin();
+ if( DEBUG_RA)
+ cout << "Initial Live Ranges constructed!" << endl;
- for( ; InstIt != (*BBI)->end() ; ++InstIt) {
+}
- const Instruction *const CallRetI = *InstIt;
- unsigned OpCode = (CallRetI)->getOpcode();
-
- if( (OpCode == Instruction::Call) ) {
- CallRetInstrList.push_back(CallRetI );
- MRI.suggestRegs4CallArgs( (CallInst *) CallRetI, *this, RegClassList );
- }
- else if (OpCode == Instruction::Ret ) {
- CallRetInstrList.push_back( CallRetI );
- MRI.suggestReg4RetValue( (ReturnInst *) CallRetI, *this);
- }
+// Suggest colors for call and return args.
+// Also create new LRs for implicit defs
- } // for each llvm instr in BB
+void LiveRangeInfo::suggestRegs4CallRets()
+{
- } // for all BBs in method
+ CallRetInstrListType::const_iterator It = CallRetInstrList.begin();
- if( DEBUG_RA)
- cout << "Initial Live Ranges constructed!" << endl;
+ for( ; It != CallRetInstrList.end(); ++It ) {
+
+ const MachineInstr *MInst = *It;
+ MachineOpCode OpCode = MInst->getOpCode();
+
+ if( (TM.getInstrInfo()).isReturn(OpCode) )
+ MRI.suggestReg4RetValue( MInst, *this);
+
+ else if( (TM.getInstrInfo()).isCall( OpCode ) )
+ MRI.suggestRegs4CallArgs( MInst, *this, RegClassList );
+
+ else
+ assert( 0 && "Non call/ret instr in CallRetInstrList" );
+ }
}
+
void LiveRangeInfo::coalesceLRs()
{
@@ -318,8 +311,6 @@ void LiveRangeInfo::coalesceLRs()
if( RCOfDef == RCOfUse ) { // if the reg classes are the same
- // if( LROfUse->getTypeID() == LROfDef->getTypeID() ) {
-
if( ! RCOfDef->getInterference(LROfDef, LROfUse) ) {
unsigned CombinedDegree =