mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2026-04-26 12:20:42 +00:00
Allow target to place 2-address pass inserted copies in better spots. Thumb2 will use this to try to avoid breaking up IT blocks.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@105745 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -503,3 +503,46 @@ bool llvm::rewriteT2FrameIndex(MachineInstr &MI, unsigned FrameRegIdx,
|
||||
Offset = (isSub) ? -Offset : Offset;
|
||||
return Offset == 0;
|
||||
}
|
||||
|
||||
/// scheduleTwoAddrSource - Schedule the copy / re-mat of the source of the
|
||||
/// two-addrss instruction inserted by two-address pass.
|
||||
void
|
||||
Thumb2InstrInfo::scheduleTwoAddrSource(MachineInstr *SrcMI,
|
||||
MachineInstr *UseMI,
|
||||
const TargetRegisterInfo &TRI) const {
|
||||
if (SrcMI->getOpcode() != ARM::tMOVgpr2gpr ||
|
||||
SrcMI->getOperand(1).isKill())
|
||||
return;
|
||||
|
||||
unsigned PredReg = 0;
|
||||
ARMCC::CondCodes CC = llvm::getInstrPredicate(UseMI, PredReg);
|
||||
if (CC == ARMCC::AL || PredReg != ARM::CPSR)
|
||||
return;
|
||||
|
||||
// Schedule the copy so it doesn't come between previous instructions
|
||||
// and UseMI which can form an IT block.
|
||||
unsigned SrcReg = SrcMI->getOperand(1).getReg();
|
||||
ARMCC::CondCodes OCC = ARMCC::getOppositeCondition(CC);
|
||||
MachineBasicBlock *MBB = UseMI->getParent();
|
||||
MachineBasicBlock::iterator MBBI = SrcMI;
|
||||
unsigned NumInsts = 0;
|
||||
while (--MBBI != MBB->begin()) {
|
||||
if (MBBI->isDebugValue())
|
||||
continue;
|
||||
|
||||
MachineInstr *NMI = &*MBBI;
|
||||
ARMCC::CondCodes NCC = llvm::getInstrPredicate(NMI, PredReg);
|
||||
if (!(NCC == CC || NCC == OCC) ||
|
||||
NMI->modifiesRegister(SrcReg, &TRI) ||
|
||||
NMI->definesRegister(ARM::CPSR))
|
||||
break;
|
||||
if (++NumInsts == 4)
|
||||
// Too many in a row!
|
||||
return;
|
||||
}
|
||||
|
||||
if (NumInsts) {
|
||||
MBB->remove(SrcMI);
|
||||
MBB->insert(++MBBI, SrcMI);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user