mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-09-27 00:21:03 +00:00
Teach PHI elimination to remove REG_SEQUENCE instructions and update references of the source operands with references of the destination with subreg indices. e.g.
%reg1029<def>, %reg1030<def> = VLD1q16 %reg1024<kill>, ... %reg1031<def> = REG_SEQUENCE %reg1029<kill>, 5, %reg1030<kill>, 6 => %reg1031:5<def>, %reg1031:6<def> = VLD1q16 %reg1024<kill>, ... PHI elimination now does more than phi elimination. It is really a de-SSA pass. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@103039 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -262,6 +262,23 @@ static void printRegName(unsigned reg, const TargetRegisterInfo* tri_) {
|
||||
}
|
||||
#endif
|
||||
|
||||
static
|
||||
bool MultipleDefsByMI(const MachineInstr &MI, unsigned MOIdx) {
|
||||
unsigned Reg = MI.getOperand(MOIdx).getReg();
|
||||
for (unsigned i = MOIdx+1, e = MI.getNumOperands(); i < e; ++i) {
|
||||
const MachineOperand &MO = MI.getOperand(i);
|
||||
if (!MO.isReg())
|
||||
continue;
|
||||
if (MO.getReg() == Reg && MO.isDef()) {
|
||||
assert(MI.getOperand(MOIdx).getSubReg() != MO.getSubReg() &&
|
||||
MI.getOperand(MOIdx).getSubReg() &&
|
||||
MO.getSubReg());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void LiveIntervals::handleVirtualRegisterDef(MachineBasicBlock *mbb,
|
||||
MachineBasicBlock::iterator mi,
|
||||
SlotIndex MIIdx,
|
||||
@@ -372,6 +389,13 @@ void LiveIntervals::handleVirtualRegisterDef(MachineBasicBlock *mbb,
|
||||
}
|
||||
|
||||
} else {
|
||||
if (MultipleDefsByMI(*mi, MOIdx))
|
||||
// Mutple defs of the same virtual register by the same instruction. e.g.
|
||||
// %reg1031:5<def>, %reg1031:6<def> = VLD1q16 %reg1024<kill>, ...
|
||||
// This is likely due to elimination of REG_SEQUENCE instructions. Return
|
||||
// here since there is nothing to do.
|
||||
return;
|
||||
|
||||
// If this is the second time we see a virtual register definition, it
|
||||
// must be due to phi elimination or two addr elimination. If this is
|
||||
// the result of two address elimination, then the vreg is one of the
|
||||
|
Reference in New Issue
Block a user