Physical registers no longer live in the regsUsed set for each machine instr

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@7618 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner
2003-08-05 21:55:58 +00:00
parent 610234d5c9
commit 3bed95b628
2 changed files with 60 additions and 36 deletions

View File

@@ -1150,32 +1150,44 @@ int PhyRegAlloc::getUniRegNotUsedByThisInst(RegClass *RC,
// instructions. Both explicit and implicit operands are set. // instructions. Both explicit and implicit operands are set.
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
void PhyRegAlloc::setRelRegsUsedByThisInst(RegClass *RC, static void markRegisterUsed(int RegNo, RegClass *RC, int RegType,
const int RegType, const TargetRegInfo &TRI) {
const MachineInstr *MInst ) unsigned classId = 0;
int classRegNum = TRI.getClassRegNum(RegNo, classId);
if (RC->getID() == classId)
RC->markColorsUsed(classRegNum, RegType, RegType);
}
void PhyRegAlloc::setRelRegsUsedByThisInst(RegClass *RC, int RegType,
const MachineInstr *MI)
{ {
assert(OperandsColoredMap[MInst] == true && assert(OperandsColoredMap[MI] == true &&
"Illegal to call setRelRegsUsedByThisInst() until colored operands " "Illegal to call setRelRegsUsedByThisInst() until colored operands "
"are marked for an instruction."); "are marked for an instruction.");
// Add the registers already marked as used by the instruction. // Add the registers already marked as used by the instruction.
// This should include any scratch registers that are used to save for (unsigned i = 0, e = MI->getNumOperands(); i != e; ++i)
// values across the instruction (e.g., for saving state register values). if (MI->getOperand(i).hasAllocatedReg())
const std::set<int> &regsUsed = MInst->getRegsUsed(); markRegisterUsed(MI->getOperand(i).getAllocatedRegNum(), RC, RegType,MRI);
for (std::set<int>::iterator I=regsUsed.begin(),E=regsUsed.end(); I != E; ++I)
{ for (unsigned i = 0, e = MI->getNumImplicitRefs(); i != e; ++i)
int i = *I; if (MI->getImplicitOp(i).hasAllocatedReg())
unsigned classId = 0; markRegisterUsed(MI->getImplicitOp(i).getAllocatedRegNum(), RC,
int classRegNum = MRI.getClassRegNum(i, classId); RegType,MRI);
if (RC->getID() == classId)
RC->markColorsUsed(classRegNum, RegType, RegType); // The getRegsUsed() method returns the set of scratch registers that are used
} // to save values across the instruction (e.g., for saving state register
// values).
const std::set<int> &regsUsed = MI->getRegsUsed();
for (std::set<int>::iterator I = regsUsed.begin(),
E = regsUsed.end(); I != E; ++I)
markRegisterUsed(*I, RC, RegType, MRI);
// If there are implicit references, mark their allocated regs as well // If there are implicit references, mark their allocated regs as well
// //
for (unsigned z=0; z < MInst->getNumImplicitRefs(); z++) for (unsigned z=0; z < MI->getNumImplicitRefs(); z++)
if (const LiveRange* if (const LiveRange*
LRofImpRef = LRI.getLiveRangeForValue(MInst->getImplicitRef(z))) LRofImpRef = LRI.getLiveRangeForValue(MI->getImplicitRef(z)))
if (LRofImpRef->hasColor()) if (LRofImpRef->hasColor())
// this implicit reference is in a LR that received a color // this implicit reference is in a LR that received a color
RC->markColorsUsed(LRofImpRef->getColor(), RC->markColorsUsed(LRofImpRef->getColor(),

View File

@@ -1150,32 +1150,44 @@ int PhyRegAlloc::getUniRegNotUsedByThisInst(RegClass *RC,
// instructions. Both explicit and implicit operands are set. // instructions. Both explicit and implicit operands are set.
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
void PhyRegAlloc::setRelRegsUsedByThisInst(RegClass *RC, static void markRegisterUsed(int RegNo, RegClass *RC, int RegType,
const int RegType, const TargetRegInfo &TRI) {
const MachineInstr *MInst ) unsigned classId = 0;
int classRegNum = TRI.getClassRegNum(RegNo, classId);
if (RC->getID() == classId)
RC->markColorsUsed(classRegNum, RegType, RegType);
}
void PhyRegAlloc::setRelRegsUsedByThisInst(RegClass *RC, int RegType,
const MachineInstr *MI)
{ {
assert(OperandsColoredMap[MInst] == true && assert(OperandsColoredMap[MI] == true &&
"Illegal to call setRelRegsUsedByThisInst() until colored operands " "Illegal to call setRelRegsUsedByThisInst() until colored operands "
"are marked for an instruction."); "are marked for an instruction.");
// Add the registers already marked as used by the instruction. // Add the registers already marked as used by the instruction.
// This should include any scratch registers that are used to save for (unsigned i = 0, e = MI->getNumOperands(); i != e; ++i)
// values across the instruction (e.g., for saving state register values). if (MI->getOperand(i).hasAllocatedReg())
const std::set<int> &regsUsed = MInst->getRegsUsed(); markRegisterUsed(MI->getOperand(i).getAllocatedRegNum(), RC, RegType,MRI);
for (std::set<int>::iterator I=regsUsed.begin(),E=regsUsed.end(); I != E; ++I)
{ for (unsigned i = 0, e = MI->getNumImplicitRefs(); i != e; ++i)
int i = *I; if (MI->getImplicitOp(i).hasAllocatedReg())
unsigned classId = 0; markRegisterUsed(MI->getImplicitOp(i).getAllocatedRegNum(), RC,
int classRegNum = MRI.getClassRegNum(i, classId); RegType,MRI);
if (RC->getID() == classId)
RC->markColorsUsed(classRegNum, RegType, RegType); // The getRegsUsed() method returns the set of scratch registers that are used
} // to save values across the instruction (e.g., for saving state register
// values).
const std::set<int> &regsUsed = MI->getRegsUsed();
for (std::set<int>::iterator I = regsUsed.begin(),
E = regsUsed.end(); I != E; ++I)
markRegisterUsed(*I, RC, RegType, MRI);
// If there are implicit references, mark their allocated regs as well // If there are implicit references, mark their allocated regs as well
// //
for (unsigned z=0; z < MInst->getNumImplicitRefs(); z++) for (unsigned z=0; z < MI->getNumImplicitRefs(); z++)
if (const LiveRange* if (const LiveRange*
LRofImpRef = LRI.getLiveRangeForValue(MInst->getImplicitRef(z))) LRofImpRef = LRI.getLiveRangeForValue(MI->getImplicitRef(z)))
if (LRofImpRef->hasColor()) if (LRofImpRef->hasColor())
// this implicit reference is in a LR that received a color // this implicit reference is in a LR that received a color
RC->markColorsUsed(LRofImpRef->getColor(), RC->markColorsUsed(LRofImpRef->getColor(),