mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-08-22 10:29:35 +00:00
The PPC MFCR instruction implicitly uses all 8 of the CR
registers. Currently it is not so marked, which leads to VCMPEQ instructions that feed into it getting deleted. If it is so marked, local RA complains about this sequence: vreg = MCRF CR0 MFCR <kill of whatever preg got assigned to vreg> All current uses of this instruction are only interested in one of the 8 CR registers, so redefine MFCR to be a normal unary instruction with a CR input (which is emitted only as a comment). That avoids all problems. 7739628. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@104238 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
69b4d1caff
commit
5f07d5224d
@ -712,8 +712,9 @@ SDNode *PPCDAGToDAGISel::SelectSETCC(SDNode *N) {
|
|||||||
if (PPCSubTarget.isGigaProcessor() && OtherCondIdx == -1)
|
if (PPCSubTarget.isGigaProcessor() && OtherCondIdx == -1)
|
||||||
IntCR = SDValue(CurDAG->getMachineNode(PPC::MFOCRF, dl, MVT::i32, CR7Reg,
|
IntCR = SDValue(CurDAG->getMachineNode(PPC::MFOCRF, dl, MVT::i32, CR7Reg,
|
||||||
CCReg), 0);
|
CCReg), 0);
|
||||||
else
|
else
|
||||||
IntCR = SDValue(CurDAG->getMachineNode(PPC::MFCR, dl, MVT::i32, CCReg), 0);
|
IntCR = SDValue(CurDAG->getMachineNode(PPC::MFCRpseud, dl, MVT::i32,
|
||||||
|
CR7Reg, CCReg), 0);
|
||||||
|
|
||||||
SDValue Ops[] = { IntCR, getI32Imm((32-(3-Idx)) & 31),
|
SDValue Ops[] = { IntCR, getI32Imm((32-(3-Idx)) & 31),
|
||||||
getI32Imm(31), getI32Imm(31) };
|
getI32Imm(31), getI32Imm(31) };
|
||||||
@ -848,7 +849,8 @@ SDNode *PPCDAGToDAGISel::Select(SDNode *N) {
|
|||||||
return CurDAG->getMachineNode(PPC::MFOCRF, dl, MVT::i32,
|
return CurDAG->getMachineNode(PPC::MFOCRF, dl, MVT::i32,
|
||||||
N->getOperand(0), InFlag);
|
N->getOperand(0), InFlag);
|
||||||
else
|
else
|
||||||
return CurDAG->getMachineNode(PPC::MFCR, dl, MVT::i32, InFlag);
|
return CurDAG->getMachineNode(PPC::MFCRpseud, dl, MVT::i32,
|
||||||
|
N->getOperand(0), InFlag);
|
||||||
}
|
}
|
||||||
|
|
||||||
case ISD::SDIV: {
|
case ISD::SDIV: {
|
||||||
|
@ -111,9 +111,10 @@ namespace llvm {
|
|||||||
/// Return with a flag operand, matched by 'blr'
|
/// Return with a flag operand, matched by 'blr'
|
||||||
RET_FLAG,
|
RET_FLAG,
|
||||||
|
|
||||||
/// R32 = MFCR(CRREG, INFLAG) - Represents the MFCR/MFOCRF instructions.
|
/// R32 = MFCR(CRREG, INFLAG) - Represents the MFCRpseud/MFOCRF
|
||||||
/// This copies the bits corresponding to the specified CRREG into the
|
/// instructions. This copies the bits corresponding to the specified
|
||||||
/// resultant GPR. Bits corresponding to other CR regs are undefined.
|
/// CRREG into the resultant GPR. Bits corresponding to other CR regs
|
||||||
|
/// are undefined.
|
||||||
MFCR,
|
MFCR,
|
||||||
|
|
||||||
/// RESVEC = VCMP(LHS, RHS, OPC) - Represents one of the altivec VCMP*
|
/// RESVEC = VCMP(LHS, RHS, OPC) - Represents one of the altivec VCMP*
|
||||||
|
@ -442,7 +442,8 @@ PPCInstrInfo::StoreRegToStackSlot(MachineFunction &MF,
|
|||||||
// issue a MFCR to save all of the CRBits.
|
// issue a MFCR to save all of the CRBits.
|
||||||
unsigned ScratchReg = TM.getSubtargetImpl()->isDarwinABI() ?
|
unsigned ScratchReg = TM.getSubtargetImpl()->isDarwinABI() ?
|
||||||
PPC::R2 : PPC::R0;
|
PPC::R2 : PPC::R0;
|
||||||
NewMIs.push_back(BuildMI(MF, DL, get(PPC::MFCR), ScratchReg));
|
NewMIs.push_back(BuildMI(MF, DL, get(PPC::MFCRpseud), ScratchReg)
|
||||||
|
.addReg(SrcReg, getKillRegState(isKill)));
|
||||||
|
|
||||||
// If the saved register wasn't CR0, shift the bits left so that they are
|
// If the saved register wasn't CR0, shift the bits left so that they are
|
||||||
// in CR0's slot.
|
// in CR0's slot.
|
||||||
|
@ -1117,14 +1117,17 @@ def MFVRSAVE : XFXForm_1_ext<31, 339, 256, (outs GPRC:$rT), (ins),
|
|||||||
def MTCRF : XFXForm_5<31, 144, (outs), (ins crbitm:$FXM, GPRC:$rS),
|
def MTCRF : XFXForm_5<31, 144, (outs), (ins crbitm:$FXM, GPRC:$rS),
|
||||||
"mtcrf $FXM, $rS", BrMCRX>,
|
"mtcrf $FXM, $rS", BrMCRX>,
|
||||||
PPC970_MicroCode, PPC970_Unit_CRU;
|
PPC970_MicroCode, PPC970_Unit_CRU;
|
||||||
// FIXME: this Uses all the CR registers. Marking it as such is
|
|
||||||
// necessary for DeadMachineInstructionElim to do the right thing.
|
// This is a pseudo for MFCR, which implicitly uses all 8 of its subregisters;
|
||||||
// However, marking it also exposes PR 2964, and causes crashes in
|
// declaring that here gives the local register allocator problems with this:
|
||||||
// the Local RA because it doesn't like this sequence:
|
|
||||||
// vreg = MCRF CR0
|
// vreg = MCRF CR0
|
||||||
// MFCR <kill of whatever preg got assigned to vreg>
|
// MFCR <kill of whatever preg got assigned to vreg>
|
||||||
// For now DeadMachineInstructionElim is turned off, so don't do the marking.
|
// while not declaring it breaks DeadMachineInstructionElimination.
|
||||||
def MFCR : XFXForm_3<31, 19, (outs GPRC:$rT), (ins), "mfcr $rT", SprMFCR>,
|
// As it turns out, in all cases where we currently use this,
|
||||||
|
// we're only interested in one subregister of it. Represent this in the
|
||||||
|
// instruction to keep the register allocator from becoming confused.
|
||||||
|
def MFCRpseud: XFXForm_3<31, 19, (outs GPRC:$rT), (ins crbitm:$FXM),
|
||||||
|
"mfcr $rT ${:comment} $FXM", SprMFCR>,
|
||||||
PPC970_MicroCode, PPC970_Unit_CRU;
|
PPC970_MicroCode, PPC970_Unit_CRU;
|
||||||
def MFOCRF: XFXForm_5a<31, 19, (outs GPRC:$rT), (ins crbitm:$FXM),
|
def MFOCRF: XFXForm_5a<31, 19, (outs GPRC:$rT), (ins crbitm:$FXM),
|
||||||
"mfcr $rT, $FXM", SprMFCR>,
|
"mfcr $rT, $FXM", SprMFCR>,
|
||||||
|
@ -689,19 +689,15 @@ void PPCRegisterInfo::lowerCRSpilling(MachineBasicBlock::iterator II,
|
|||||||
const TargetRegisterClass *GPRC = &PPC::GPRCRegClass;
|
const TargetRegisterClass *GPRC = &PPC::GPRCRegClass;
|
||||||
const TargetRegisterClass *RC = Subtarget.isPPC64() ? G8RC : GPRC;
|
const TargetRegisterClass *RC = Subtarget.isPPC64() ? G8RC : GPRC;
|
||||||
unsigned Reg = findScratchRegister(II, RS, RC, SPAdj);
|
unsigned Reg = findScratchRegister(II, RS, RC, SPAdj);
|
||||||
|
unsigned SrcReg = MI.getOperand(0).getReg();
|
||||||
|
|
||||||
// We need to store the CR in the low 4-bits of the saved value. First, issue
|
// We need to store the CR in the low 4-bits of the saved value. First, issue
|
||||||
// an MFCR to save all of the CRBits. Add an implicit kill of the CR.
|
// an MFCRpsued to save all of the CRBits and, if needed, kill the SrcReg.
|
||||||
if (!MI.getOperand(0).isKill())
|
BuildMI(MBB, II, dl, TII.get(PPC::MFCRpseud), Reg)
|
||||||
BuildMI(MBB, II, dl, TII.get(PPC::MFCR), Reg);
|
.addReg(SrcReg, getKillRegState(MI.getOperand(0).isKill()));
|
||||||
else
|
|
||||||
// Implicitly kill the CR register.
|
|
||||||
BuildMI(MBB, II, dl, TII.get(PPC::MFCR), Reg)
|
|
||||||
.addReg(MI.getOperand(0).getReg(), RegState::ImplicitKill);
|
|
||||||
|
|
||||||
// If the saved register wasn't CR0, shift the bits left so that they are in
|
// If the saved register wasn't CR0, shift the bits left so that they are in
|
||||||
// CR0's slot.
|
// CR0's slot.
|
||||||
unsigned SrcReg = MI.getOperand(0).getReg();
|
|
||||||
if (SrcReg != PPC::CR0)
|
if (SrcReg != PPC::CR0)
|
||||||
// rlwinm rA, rA, ShiftBits, 0, 31.
|
// rlwinm rA, rA, ShiftBits, 0, 31.
|
||||||
BuildMI(MBB, II, dl, TII.get(PPC::RLWINM), Reg)
|
BuildMI(MBB, II, dl, TII.get(PPC::RLWINM), Reg)
|
||||||
|
Loading…
Reference in New Issue
Block a user