mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-05-15 00:38:42 +00:00
Go through the machine instruction's operands to make sure that we're not
marking both a super- and sub-register as "killed". This removes implicit uses that are marked as "killed". git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@47862 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
a0a570cec6
commit
4a23d72ec2
@ -678,34 +678,74 @@ void MachineInstr::print(std::ostream &OS, const TargetMachine *TM) const {
|
|||||||
bool MachineInstr::addRegisterKilled(unsigned IncomingReg,
|
bool MachineInstr::addRegisterKilled(unsigned IncomingReg,
|
||||||
const TargetRegisterInfo *RegInfo,
|
const TargetRegisterInfo *RegInfo,
|
||||||
bool AddIfNotFound) {
|
bool AddIfNotFound) {
|
||||||
bool Found = false;
|
// Go through the machine instruction's operands to eliminate any potentially
|
||||||
for (unsigned i = 0, e = getNumOperands(); i != e; ++i) {
|
// illegal conditions. I.e., a super- and sub-register both marked "kill".
|
||||||
|
Restart:
|
||||||
|
for (unsigned i = 0, e = getNumOperands(); i < e; ++i) {
|
||||||
MachineOperand &MO = getOperand(i);
|
MachineOperand &MO = getOperand(i);
|
||||||
|
|
||||||
if (MO.isRegister() && MO.isUse()) {
|
if (MO.isRegister() && MO.isUse()) {
|
||||||
unsigned Reg = MO.getReg();
|
unsigned Reg = MO.getReg();
|
||||||
if (!Reg)
|
|
||||||
|
if (!Reg || IncomingReg == Reg ||
|
||||||
|
!TargetRegisterInfo::isPhysicalRegister(Reg) ||
|
||||||
|
!TargetRegisterInfo::isPhysicalRegister(IncomingReg))
|
||||||
continue;
|
continue;
|
||||||
if (Reg == IncomingReg) {
|
|
||||||
MO.setIsKill();
|
if (RegInfo->isSubRegister(IncomingReg, Reg)) {
|
||||||
Found = true;
|
if (MO.isKill()) {
|
||||||
break;
|
if (MO.isImplicit()) {
|
||||||
} else if (TargetRegisterInfo::isPhysicalRegister(Reg) &&
|
// Remove this implicit use that marks the sub-register "kill". Let
|
||||||
TargetRegisterInfo::isPhysicalRegister(IncomingReg) &&
|
// the super-register take care of this information.
|
||||||
RegInfo->isSuperRegister(IncomingReg, Reg) &&
|
RemoveOperand(i);
|
||||||
MO.isKill())
|
goto Restart; // Instruction was modified, redo checking.
|
||||||
// A super-register kill already exists.
|
} else {
|
||||||
Found = true;
|
// The super-register is going to take care of this kill
|
||||||
|
// information.
|
||||||
|
MO.setIsKill(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (RegInfo->isSuperRegister(IncomingReg, Reg) && MO.isKill()) {
|
||||||
|
// The kill information is already handled by a super-register. Don't
|
||||||
|
// add this sub-register as a kill.
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// If not found, this means an alias of one of the operand is killed. Add a
|
// If the register already exists, then make sure it or its super-register is
|
||||||
|
// marked "kill".
|
||||||
|
for (unsigned i = 0, e = getNumOperands(); i != e; ++i) {
|
||||||
|
MachineOperand &MO = getOperand(i);
|
||||||
|
|
||||||
|
if (MO.isRegister() && MO.isUse()) {
|
||||||
|
unsigned Reg = MO.getReg();
|
||||||
|
if (!Reg) continue;
|
||||||
|
|
||||||
|
if (Reg == IncomingReg) {
|
||||||
|
MO.setIsKill();
|
||||||
|
return true;
|
||||||
|
} else if (TargetRegisterInfo::isPhysicalRegister(Reg) &&
|
||||||
|
TargetRegisterInfo::isPhysicalRegister(IncomingReg) &&
|
||||||
|
RegInfo->isSuperRegister(IncomingReg, Reg) &&
|
||||||
|
MO.isKill()) {
|
||||||
|
// A super-register kill already exists.
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// If not found, this means an alias of one of the operands is killed. Add a
|
||||||
// new implicit operand if required.
|
// new implicit operand if required.
|
||||||
if (!Found && AddIfNotFound) {
|
if (AddIfNotFound) {
|
||||||
addOperand(MachineOperand::CreateReg(IncomingReg, false/*IsDef*/,
|
addOperand(MachineOperand::CreateReg(IncomingReg,
|
||||||
true/*IsImp*/,true/*IsKill*/));
|
false /*IsDef*/,
|
||||||
|
true /*IsImp*/,
|
||||||
|
true /*IsKill*/));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return Found;
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MachineInstr::addRegisterDead(unsigned IncomingReg,
|
bool MachineInstr::addRegisterDead(unsigned IncomingReg,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user