1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-26 06:22:56 +02:00

Code clean up.

llvm-svn: 35220
This commit is contained in:
Lauro Ramos Venancio 2007-03-20 20:09:03 +00:00
parent fe301e0f29
commit 632ac0e289

View File

@ -381,6 +381,20 @@ void ScheduleDAG::AddOperand(MachineInstr *MI, SDOperand Op,
} }
// Returns the Register Class of a physical register
static const TargetRegisterClass *getPhysicalRegisterRegClass(
const MRegisterInfo *MRI,
MVT::ValueType VT,
unsigned reg) {
assert(MRegisterInfo::isPhysicalRegister(reg) &&
"reg must be a physical register");
// Pick the register class of the right type that contains this physreg.
for (MRegisterInfo::regclass_iterator I = MRI->regclass_begin(),
E = MRI->regclass_end(); I != E; ++I)
if ((*I)->hasType(VT) && (*I)->contains(reg))
return *I;
assert(false && "Couldn't find the register class");
}
/// EmitNode - Generate machine code for an node and needed dependencies. /// EmitNode - Generate machine code for an node and needed dependencies.
/// ///
@ -478,20 +492,12 @@ void ScheduleDAG::EmitNode(SDNode *Node,
if (InReg != DestReg) {// Coalesced away the copy? if (InReg != DestReg) {// Coalesced away the copy?
const TargetRegisterClass *TRC = 0; const TargetRegisterClass *TRC = 0;
// Get the target register class // Get the target register class
if (MRegisterInfo::isVirtualRegister(InReg)) { if (MRegisterInfo::isVirtualRegister(InReg))
TRC = RegMap->getRegClass(InReg); TRC = RegMap->getRegClass(InReg);
} else { else
// Pick the register class of the right type that contains this TRC = getPhysicalRegisterRegClass(MRI,
// physreg. Node->getOperand(2).getValueType(),
for (MRegisterInfo::regclass_iterator I = MRI->regclass_begin(), InReg);
E = MRI->regclass_end(); I != E; ++I)
if ((*I)->hasType(Node->getOperand(2).getValueType()) &&
(*I)->contains(InReg)) {
TRC = *I;
break;
}
assert(TRC && "Couldn't find register class for reg copy!");
}
MRI->copyRegToReg(*BB, BB->end(), DestReg, InReg, TRC); MRI->copyRegToReg(*BB, BB->end(), DestReg, InReg, TRC);
} }
break; break;
@ -523,16 +529,7 @@ void ScheduleDAG::EmitNode(SDNode *Node,
if (VRBase) { if (VRBase) {
TRC = RegMap->getRegClass(VRBase); TRC = RegMap->getRegClass(VRBase);
} else { } else {
TRC = getPhysicalRegisterRegClass(MRI, Node->getValueType(0), SrcReg);
// Pick the register class of the right type that contains this physreg.
for (MRegisterInfo::regclass_iterator I = MRI->regclass_begin(),
E = MRI->regclass_end(); I != E; ++I)
if ((*I)->hasType(Node->getValueType(0)) &&
(*I)->contains(SrcReg)) {
TRC = *I;
break;
}
assert(TRC && "Couldn't find register class for reg copy!");
// Create the reg, emit the copy. // Create the reg, emit the copy.
VRBase = RegMap->createVirtualRegister(TRC); VRBase = RegMap->createVirtualRegister(TRC);