mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-17 04:24:00 +00: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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@108050 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -183,7 +183,6 @@ void llvm::PHIElimination::LowerAtomicPHINode(
|
|||||||
|
|
||||||
// Create a new register for the incoming PHI arguments.
|
// Create a new register for the incoming PHI arguments.
|
||||||
MachineFunction &MF = *MBB.getParent();
|
MachineFunction &MF = *MBB.getParent();
|
||||||
const TargetRegisterClass *RC = MF.getRegInfo().getRegClass(DestReg);
|
|
||||||
unsigned IncomingReg = 0;
|
unsigned IncomingReg = 0;
|
||||||
bool reusedIncoming = false; // Is IncomingReg reused from an earlier PHI?
|
bool reusedIncoming = false; // Is IncomingReg reused from an earlier PHI?
|
||||||
|
|
||||||
@ -207,10 +206,12 @@ void llvm::PHIElimination::LowerAtomicPHINode(
|
|||||||
++NumReused;
|
++NumReused;
|
||||||
DEBUG(dbgs() << "Reusing %reg" << IncomingReg << " for " << *MPhi);
|
DEBUG(dbgs() << "Reusing %reg" << IncomingReg << " for " << *MPhi);
|
||||||
} else {
|
} else {
|
||||||
|
const TargetRegisterClass *RC = MF.getRegInfo().getRegClass(DestReg);
|
||||||
entry = IncomingReg = MF.getRegInfo().createVirtualRegister(RC);
|
entry = IncomingReg = MF.getRegInfo().createVirtualRegister(RC);
|
||||||
}
|
}
|
||||||
TII->copyRegToReg(MBB, AfterPHIsIt, DestReg, IncomingReg, RC, RC,
|
BuildMI(MBB, AfterPHIsIt, MPhi->getDebugLoc(),
|
||||||
MPhi->getDebugLoc());
|
TII->get(TargetOpcode::COPY), DestReg)
|
||||||
|
.addReg(IncomingReg);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update live variable information if there is any.
|
// Update live variable information if there is any.
|
||||||
@ -292,8 +293,8 @@ void llvm::PHIElimination::LowerAtomicPHINode(
|
|||||||
|
|
||||||
// Insert the copy.
|
// Insert the copy.
|
||||||
if (!reusedIncoming && IncomingReg)
|
if (!reusedIncoming && IncomingReg)
|
||||||
TII->copyRegToReg(opBlock, InsertPos, IncomingReg, SrcReg, RC, RC,
|
BuildMI(opBlock, InsertPos, MPhi->getDebugLoc(),
|
||||||
MPhi->getDebugLoc());
|
TII->get(TargetOpcode::COPY), IncomingReg).addReg(SrcReg);
|
||||||
|
|
||||||
// Now update live variable information if we have it. Otherwise we're done
|
// Now update live variable information if we have it. Otherwise we're done
|
||||||
if (!LV) continue;
|
if (!LV) continue;
|
||||||
|
@ -50,11 +50,8 @@ void ScheduleDAG::EmitPhysRegCopy(SUnit *SU,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
bool Success = TII->copyRegToReg(*BB, InsertPos, Reg, VRI->second,
|
BuildMI(*BB, InsertPos, DebugLoc(), TII->get(TargetOpcode::COPY), Reg)
|
||||||
SU->CopyDstRC, SU->CopySrcRC,
|
.addReg(VRI->second);
|
||||||
DebugLoc());
|
|
||||||
(void)Success;
|
|
||||||
assert(Success && "copyRegToReg failed!");
|
|
||||||
} else {
|
} else {
|
||||||
// Copy from physical register.
|
// Copy from physical register.
|
||||||
assert(I->getReg() && "Unknown 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;
|
bool isNew = VRBaseMap.insert(std::make_pair(SU, VRBase)).second;
|
||||||
isNew = isNew; // Silence compiler warning.
|
isNew = isNew; // Silence compiler warning.
|
||||||
assert(isNew && "Node emitted out of order - early");
|
assert(isNew && "Node emitted out of order - early");
|
||||||
bool Success = TII->copyRegToReg(*BB, InsertPos, VRBase, I->getReg(),
|
BuildMI(*BB, InsertPos, DebugLoc(), TII->get(TargetOpcode::COPY), VRBase)
|
||||||
SU->CopyDstRC, SU->CopySrcRC,
|
.addReg(I->getReg());
|
||||||
DebugLoc());
|
|
||||||
(void)Success;
|
|
||||||
assert(Success && "copyRegToReg failed!");
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -142,11 +142,8 @@ EmitCopyFromReg(SDNode *Node, unsigned ResNo, bool IsClone, bool IsCloned,
|
|||||||
} else {
|
} else {
|
||||||
// Create the reg, emit the copy.
|
// Create the reg, emit the copy.
|
||||||
VRBase = MRI->createVirtualRegister(DstRC);
|
VRBase = MRI->createVirtualRegister(DstRC);
|
||||||
bool Emitted = TII->copyRegToReg(*MBB, InsertPos, VRBase, SrcReg,
|
BuildMI(*MBB, InsertPos, Node->getDebugLoc(), TII->get(TargetOpcode::COPY),
|
||||||
DstRC, SrcRC, Node->getDebugLoc());
|
VRBase).addReg(SrcReg);
|
||||||
|
|
||||||
assert(Emitted && "Unable to issue a copy instruction!\n");
|
|
||||||
(void) Emitted;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SDValue Op(Node, ResNo);
|
SDValue Op(Node, ResNo);
|
||||||
@ -288,10 +285,8 @@ InstrEmitter::AddRegisterOperand(MachineInstr *MI, SDValue Op,
|
|||||||
"Don't have operand info for this instruction!");
|
"Don't have operand info for this instruction!");
|
||||||
if (DstRC && SrcRC != DstRC && !SrcRC->hasSuperClass(DstRC)) {
|
if (DstRC && SrcRC != DstRC && !SrcRC->hasSuperClass(DstRC)) {
|
||||||
unsigned NewVReg = MRI->createVirtualRegister(DstRC);
|
unsigned NewVReg = MRI->createVirtualRegister(DstRC);
|
||||||
bool Emitted = TII->copyRegToReg(*MBB, InsertPos, NewVReg, VReg,
|
BuildMI(*MBB, InsertPos, Op.getNode()->getDebugLoc(),
|
||||||
DstRC, SrcRC, Op.getNode()->getDebugLoc());
|
TII->get(TargetOpcode::COPY), NewVReg).addReg(VReg);
|
||||||
assert(Emitted && "Unable to issue a copy instruction!\n");
|
|
||||||
(void) Emitted;
|
|
||||||
VReg = NewVReg;
|
VReg = NewVReg;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -513,18 +508,13 @@ void
|
|||||||
InstrEmitter::EmitCopyToRegClassNode(SDNode *Node,
|
InstrEmitter::EmitCopyToRegClassNode(SDNode *Node,
|
||||||
DenseMap<SDValue, unsigned> &VRBaseMap) {
|
DenseMap<SDValue, unsigned> &VRBaseMap) {
|
||||||
unsigned VReg = getVR(Node->getOperand(0), 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.
|
// 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);
|
unsigned NewVReg = MRI->createVirtualRegister(DstRC);
|
||||||
bool Emitted = TII->copyRegToReg(*MBB, InsertPos, NewVReg, VReg,
|
BuildMI(*MBB, InsertPos, Node->getDebugLoc(), TII->get(TargetOpcode::COPY),
|
||||||
DstRC, SrcRC, Node->getDebugLoc());
|
NewVReg).addReg(VReg);
|
||||||
assert(Emitted &&
|
|
||||||
"Unable to issue a copy instruction for a COPY_TO_REGCLASS node!\n");
|
|
||||||
(void) Emitted;
|
|
||||||
|
|
||||||
SDValue Op(Node, 0);
|
SDValue Op(Node, 0);
|
||||||
bool isNew = VRBaseMap.insert(std::make_pair(Op, NewVReg)).second;
|
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();
|
unsigned DestReg = cast<RegisterSDNode>(Node->getOperand(1))->getReg();
|
||||||
if (SrcReg == DestReg) // Coalesced away the copy? Ignore.
|
if (SrcReg == DestReg) // Coalesced away the copy? Ignore.
|
||||||
break;
|
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))
|
BuildMI(*MBB, InsertPos, Node->getDebugLoc(), TII->get(TargetOpcode::COPY),
|
||||||
DstTRC = MRI->getRegClass(DestReg);
|
DestReg).addReg(SrcReg);
|
||||||
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;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case ISD::CopyFromReg: {
|
case ISD::CopyFromReg: {
|
||||||
|
@ -1154,10 +1154,8 @@ bool TwoAddressInstructionPass::runOnMachineFunction(MachineFunction &MF) {
|
|||||||
ReMatRegs.set(regB);
|
ReMatRegs.set(regB);
|
||||||
++NumReMats;
|
++NumReMats;
|
||||||
} else {
|
} else {
|
||||||
bool Emitted = TII->copyRegToReg(*mbbi, mi, regA, regB, rc, rc,
|
BuildMI(*mbbi, mi, mi->getDebugLoc(), TII->get(TargetOpcode::COPY),
|
||||||
mi->getDebugLoc());
|
regA).addReg(regB);
|
||||||
(void)Emitted;
|
|
||||||
assert(Emitted && "Unable to issue a copy instruction!\n");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
MachineBasicBlock::iterator prevMI = prior(mi);
|
MachineBasicBlock::iterator prevMI = prior(mi);
|
||||||
|
Reference in New Issue
Block a user