mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-23 03:02:36 +01:00
Emit COPY instructions instead of using copyRegToReg in InstrEmitter,
ScheduleDAGEmit, TwoAddressLowering, and PHIElimination. This switches the bulk of register copies to using COPY, but many less used copyRegToReg calls remain. llvm-svn: 108050
This commit is contained in:
parent
48c8ee1c11
commit
609d345349
@ -183,7 +183,6 @@ void llvm::PHIElimination::LowerAtomicPHINode(
|
||||
|
||||
// Create a new register for the incoming PHI arguments.
|
||||
MachineFunction &MF = *MBB.getParent();
|
||||
const TargetRegisterClass *RC = MF.getRegInfo().getRegClass(DestReg);
|
||||
unsigned IncomingReg = 0;
|
||||
bool reusedIncoming = false; // Is IncomingReg reused from an earlier PHI?
|
||||
|
||||
@ -207,10 +206,12 @@ void llvm::PHIElimination::LowerAtomicPHINode(
|
||||
++NumReused;
|
||||
DEBUG(dbgs() << "Reusing %reg" << IncomingReg << " for " << *MPhi);
|
||||
} else {
|
||||
const TargetRegisterClass *RC = MF.getRegInfo().getRegClass(DestReg);
|
||||
entry = IncomingReg = MF.getRegInfo().createVirtualRegister(RC);
|
||||
}
|
||||
TII->copyRegToReg(MBB, AfterPHIsIt, DestReg, IncomingReg, RC, RC,
|
||||
MPhi->getDebugLoc());
|
||||
BuildMI(MBB, AfterPHIsIt, MPhi->getDebugLoc(),
|
||||
TII->get(TargetOpcode::COPY), DestReg)
|
||||
.addReg(IncomingReg);
|
||||
}
|
||||
|
||||
// Update live variable information if there is any.
|
||||
@ -292,8 +293,8 @@ void llvm::PHIElimination::LowerAtomicPHINode(
|
||||
|
||||
// Insert the copy.
|
||||
if (!reusedIncoming && IncomingReg)
|
||||
TII->copyRegToReg(opBlock, InsertPos, IncomingReg, SrcReg, RC, RC,
|
||||
MPhi->getDebugLoc());
|
||||
BuildMI(opBlock, InsertPos, MPhi->getDebugLoc(),
|
||||
TII->get(TargetOpcode::COPY), IncomingReg).addReg(SrcReg);
|
||||
|
||||
// Now update live variable information if we have it. Otherwise we're done
|
||||
if (!LV) continue;
|
||||
|
@ -50,11 +50,8 @@ void ScheduleDAG::EmitPhysRegCopy(SUnit *SU,
|
||||
break;
|
||||
}
|
||||
}
|
||||
bool Success = TII->copyRegToReg(*BB, InsertPos, Reg, VRI->second,
|
||||
SU->CopyDstRC, SU->CopySrcRC,
|
||||
DebugLoc());
|
||||
(void)Success;
|
||||
assert(Success && "copyRegToReg failed!");
|
||||
BuildMI(*BB, InsertPos, DebugLoc(), TII->get(TargetOpcode::COPY), Reg)
|
||||
.addReg(VRI->second);
|
||||
} else {
|
||||
// Copy from physical register.
|
||||
assert(I->getReg() && "Unknown physical register!");
|
||||
@ -62,11 +59,8 @@ void ScheduleDAG::EmitPhysRegCopy(SUnit *SU,
|
||||
bool isNew = VRBaseMap.insert(std::make_pair(SU, VRBase)).second;
|
||||
isNew = isNew; // Silence compiler warning.
|
||||
assert(isNew && "Node emitted out of order - early");
|
||||
bool Success = TII->copyRegToReg(*BB, InsertPos, VRBase, I->getReg(),
|
||||
SU->CopyDstRC, SU->CopySrcRC,
|
||||
DebugLoc());
|
||||
(void)Success;
|
||||
assert(Success && "copyRegToReg failed!");
|
||||
BuildMI(*BB, InsertPos, DebugLoc(), TII->get(TargetOpcode::COPY), VRBase)
|
||||
.addReg(I->getReg());
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -142,11 +142,8 @@ EmitCopyFromReg(SDNode *Node, unsigned ResNo, bool IsClone, bool IsCloned,
|
||||
} else {
|
||||
// Create the reg, emit the copy.
|
||||
VRBase = MRI->createVirtualRegister(DstRC);
|
||||
bool Emitted = TII->copyRegToReg(*MBB, InsertPos, VRBase, SrcReg,
|
||||
DstRC, SrcRC, Node->getDebugLoc());
|
||||
|
||||
assert(Emitted && "Unable to issue a copy instruction!\n");
|
||||
(void) Emitted;
|
||||
BuildMI(*MBB, InsertPos, Node->getDebugLoc(), TII->get(TargetOpcode::COPY),
|
||||
VRBase).addReg(SrcReg);
|
||||
}
|
||||
|
||||
SDValue Op(Node, ResNo);
|
||||
@ -288,10 +285,8 @@ InstrEmitter::AddRegisterOperand(MachineInstr *MI, SDValue Op,
|
||||
"Don't have operand info for this instruction!");
|
||||
if (DstRC && SrcRC != DstRC && !SrcRC->hasSuperClass(DstRC)) {
|
||||
unsigned NewVReg = MRI->createVirtualRegister(DstRC);
|
||||
bool Emitted = TII->copyRegToReg(*MBB, InsertPos, NewVReg, VReg,
|
||||
DstRC, SrcRC, Op.getNode()->getDebugLoc());
|
||||
assert(Emitted && "Unable to issue a copy instruction!\n");
|
||||
(void) Emitted;
|
||||
BuildMI(*MBB, InsertPos, Op.getNode()->getDebugLoc(),
|
||||
TII->get(TargetOpcode::COPY), NewVReg).addReg(VReg);
|
||||
VReg = NewVReg;
|
||||
}
|
||||
}
|
||||
@ -513,18 +508,13 @@ void
|
||||
InstrEmitter::EmitCopyToRegClassNode(SDNode *Node,
|
||||
DenseMap<SDValue, unsigned> &VRBaseMap) {
|
||||
unsigned VReg = getVR(Node->getOperand(0), VRBaseMap);
|
||||
const TargetRegisterClass *SrcRC = MRI->getRegClass(VReg);
|
||||
|
||||
unsigned DstRCIdx = cast<ConstantSDNode>(Node->getOperand(1))->getZExtValue();
|
||||
const TargetRegisterClass *DstRC = TRI->getRegClass(DstRCIdx);
|
||||
|
||||
// Create the new VReg in the destination class and emit a copy.
|
||||
unsigned DstRCIdx = cast<ConstantSDNode>(Node->getOperand(1))->getZExtValue();
|
||||
const TargetRegisterClass *DstRC = TRI->getRegClass(DstRCIdx);
|
||||
unsigned NewVReg = MRI->createVirtualRegister(DstRC);
|
||||
bool Emitted = TII->copyRegToReg(*MBB, InsertPos, NewVReg, VReg,
|
||||
DstRC, SrcRC, Node->getDebugLoc());
|
||||
assert(Emitted &&
|
||||
"Unable to issue a copy instruction for a COPY_TO_REGCLASS node!\n");
|
||||
(void) Emitted;
|
||||
BuildMI(*MBB, InsertPos, Node->getDebugLoc(), TII->get(TargetOpcode::COPY),
|
||||
NewVReg).addReg(VReg);
|
||||
|
||||
SDValue Op(Node, 0);
|
||||
bool isNew = VRBaseMap.insert(std::make_pair(Op, NewVReg)).second;
|
||||
@ -799,24 +789,9 @@ EmitSpecialNode(SDNode *Node, bool IsClone, bool IsCloned,
|
||||
unsigned DestReg = cast<RegisterSDNode>(Node->getOperand(1))->getReg();
|
||||
if (SrcReg == DestReg) // Coalesced away the copy? Ignore.
|
||||
break;
|
||||
|
||||
const TargetRegisterClass *SrcTRC = 0, *DstTRC = 0;
|
||||
// Get the register classes of the src/dst.
|
||||
if (TargetRegisterInfo::isVirtualRegister(SrcReg))
|
||||
SrcTRC = MRI->getRegClass(SrcReg);
|
||||
else
|
||||
SrcTRC = TRI->getMinimalPhysRegClass(SrcReg,SrcVal.getValueType());
|
||||
|
||||
if (TargetRegisterInfo::isVirtualRegister(DestReg))
|
||||
DstTRC = MRI->getRegClass(DestReg);
|
||||
else
|
||||
DstTRC = TRI->getMinimalPhysRegClass(DestReg,
|
||||
Node->getOperand(1).getValueType());
|
||||
|
||||
bool Emitted = TII->copyRegToReg(*MBB, InsertPos, DestReg, SrcReg,
|
||||
DstTRC, SrcTRC, Node->getDebugLoc());
|
||||
assert(Emitted && "Unable to issue a copy instruction!\n");
|
||||
(void) Emitted;
|
||||
BuildMI(*MBB, InsertPos, Node->getDebugLoc(), TII->get(TargetOpcode::COPY),
|
||||
DestReg).addReg(SrcReg);
|
||||
break;
|
||||
}
|
||||
case ISD::CopyFromReg: {
|
||||
|
@ -1154,10 +1154,8 @@ bool TwoAddressInstructionPass::runOnMachineFunction(MachineFunction &MF) {
|
||||
ReMatRegs.set(regB);
|
||||
++NumReMats;
|
||||
} else {
|
||||
bool Emitted = TII->copyRegToReg(*mbbi, mi, regA, regB, rc, rc,
|
||||
mi->getDebugLoc());
|
||||
(void)Emitted;
|
||||
assert(Emitted && "Unable to issue a copy instruction!\n");
|
||||
BuildMI(*mbbi, mi, mi->getDebugLoc(), TII->get(TargetOpcode::COPY),
|
||||
regA).addReg(regB);
|
||||
}
|
||||
|
||||
MachineBasicBlock::iterator prevMI = prior(mi);
|
||||
|
Loading…
Reference in New Issue
Block a user