mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-11 21:38:19 +00:00
Use the TargetInstrInfo::commuteInstruction method to commute instructions
instead of doing it manually. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@19685 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -141,14 +141,25 @@ bool TwoAddressInstructionPass::runOnMachineFunction(MachineFunction &MF) {
|
|||||||
unsigned regC = mi->getOperand(2).getReg();
|
unsigned regC = mi->getOperand(2).getReg();
|
||||||
if (LV.KillsRegister(mi, regC)) {
|
if (LV.KillsRegister(mi, regC)) {
|
||||||
DEBUG(std::cerr << "2addr: COMMUTING : " << *mi);
|
DEBUG(std::cerr << "2addr: COMMUTING : " << *mi);
|
||||||
mi->SetMachineOperandReg(2, regB);
|
MachineInstr *NewMI = TII.commuteInstruction(mi);
|
||||||
mi->SetMachineOperandReg(1, regC);
|
if (NewMI == 0) {
|
||||||
DEBUG(std::cerr << "2addr: COMMUTED TO: " << *mi);
|
DEBUG(std::cerr << "2addr: COMMUTING FAILED!\n");
|
||||||
|
} else {
|
||||||
|
DEBUG(std::cerr << "2addr: COMMUTED TO: " << *NewMI);
|
||||||
|
// If the instruction changed to commute it, update livevar.
|
||||||
|
if (NewMI != mi) {
|
||||||
|
LV.instructionChanged(mi, NewMI); // Update live variables
|
||||||
|
mbbi->insert(mi, NewMI); // Insert the new inst
|
||||||
|
mbbi->erase(mi); // Nuke the old inst.
|
||||||
|
mi = NewMI;
|
||||||
|
}
|
||||||
|
|
||||||
++NumCommuted;
|
++NumCommuted;
|
||||||
regB = regC;
|
regB = regC;
|
||||||
goto InstructionRearranged;
|
goto InstructionRearranged;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
// If this instruction is potentially convertible to a true
|
// If this instruction is potentially convertible to a true
|
||||||
// three-address instruction,
|
// three-address instruction,
|
||||||
if (TID.Flags & M_CONVERTIBLE_TO_3_ADDR)
|
if (TID.Flags & M_CONVERTIBLE_TO_3_ADDR)
|
||||||
|
Reference in New Issue
Block a user