mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-09-25 17:20:48 +00:00
Prepare to make r0 an allocatable register on PPC
Currently the PPC r0 register is unconditionally reserved. There are two reasons for this: 1. r0 is treated specially (as the constant 0) by certain instructions, and so cannot be used with those instructions as a regular register. 2. r0 is used as a temporary register in the CR-register spilling process (where, under some circumstances, we require two GPRs). This change addresses the first reason by introducing a restricted register class (without r0) for use by those instructions that treat r0 specially. These register classes have a new pseudo-register, ZERO, which represents the r0-as-0 use. This has the side benefit of making the existing target code simpler (and easier to understand), and will make it clear to the register allocator that uses of r0 as 0 don't conflict will real uses of the r0 register. Once the CR spilling code is improved, we'll be able to allocate r0. Adding these extra register classes, for some reason unclear to me, causes requests to the target to copy 32-bit registers to 64-bit registers. The resulting code seems correct (and causes no test-suite failures), and the new test case covers this new kind of asymmetric copy. As r0 is still reserved, no functionality change intended. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@177423 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -1031,8 +1031,7 @@ bool PPCTargetLowering::SelectAddressRegImm(SDValue N, SDValue &Disp,
|
||||
short Imm;
|
||||
if (isIntS16Immediate(CN, Imm)) {
|
||||
Disp = DAG.getTargetConstant(Imm, CN->getValueType(0));
|
||||
Base = DAG.getRegister(PPCSubTarget.isPPC64() ? PPC::X0 : PPC::R0,
|
||||
CN->getValueType(0));
|
||||
Base = DAG.getRegister(PPC::ZERO, CN->getValueType(0));
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1080,8 +1079,7 @@ bool PPCTargetLowering::SelectAddressRegRegOnly(SDValue N, SDValue &Base,
|
||||
}
|
||||
|
||||
// Otherwise, do it the hard way, using R0 as the base register.
|
||||
Base = DAG.getRegister(PPCSubTarget.isPPC64() ? PPC::X0 : PPC::R0,
|
||||
N.getValueType());
|
||||
Base = DAG.getRegister(PPC::ZERO, N.getValueType());
|
||||
Index = N;
|
||||
return true;
|
||||
}
|
||||
@@ -1143,8 +1141,7 @@ bool PPCTargetLowering::SelectAddressRegImmShift(SDValue N, SDValue &Disp,
|
||||
short Imm;
|
||||
if (isIntS16Immediate(CN, Imm)) {
|
||||
Disp = DAG.getTargetConstant((unsigned short)Imm >> 2, getPointerTy());
|
||||
Base = DAG.getRegister(PPCSubTarget.isPPC64() ? PPC::X0 : PPC::R0,
|
||||
CN->getValueType(0));
|
||||
Base = DAG.getRegister(PPC::ZERO, CN->getValueType(0));
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -5753,7 +5750,7 @@ PPCTargetLowering::EmitPartwordAtomicBinary(MachineInstr *MI,
|
||||
// registers without caring whether they're 32 or 64, but here we're
|
||||
// doing actual arithmetic on the addresses.
|
||||
bool is64bit = PPCSubTarget.isPPC64();
|
||||
unsigned ZeroReg = is64bit ? PPC::X0 : PPC::R0;
|
||||
unsigned ZeroReg = PPC::ZERO;
|
||||
|
||||
const BasicBlock *LLVM_BB = BB->getBasicBlock();
|
||||
MachineFunction *F = BB->getParent();
|
||||
@@ -6142,7 +6139,7 @@ PPCTargetLowering::EmitInstrWithCustomInserter(MachineInstr *MI,
|
||||
unsigned TmpDestReg = RegInfo.createVirtualRegister(RC);
|
||||
unsigned Ptr1Reg;
|
||||
unsigned TmpReg = RegInfo.createVirtualRegister(RC);
|
||||
unsigned ZeroReg = is64bit ? PPC::X0 : PPC::R0;
|
||||
unsigned ZeroReg = PPC::ZERO;
|
||||
// thisMBB:
|
||||
// ...
|
||||
// fallthrough --> loopMBB
|
||||
@@ -6631,6 +6628,9 @@ PPCTargetLowering::getRegForInlineAsmConstraint(const std::string &Constraint,
|
||||
// GCC RS6000 Constraint Letters
|
||||
switch (Constraint[0]) {
|
||||
case 'b': // R1-R31
|
||||
if (VT == MVT::i64 && PPCSubTarget.isPPC64())
|
||||
return std::make_pair(0U, &PPC::G8RC_NOX0RegClass);
|
||||
return std::make_pair(0U, &PPC::GPRC_NOR0RegClass);
|
||||
case 'r': // R0-R31
|
||||
if (VT == MVT::i64 && PPCSubTarget.isPPC64())
|
||||
return std::make_pair(0U, &PPC::G8RCRegClass);
|
||||
|
Reference in New Issue
Block a user