mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-08-09 11:25:55 +00:00
costmetic changes
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@15118 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -95,13 +95,13 @@ bool PNE::EliminatePHINodes(MachineFunction &MF, MachineBasicBlock &MBB) {
|
|||||||
++AfterPHIsIt; // Skip over all of the PHI nodes...
|
++AfterPHIsIt; // Skip over all of the PHI nodes...
|
||||||
|
|
||||||
while (MBB.front().getOpcode() == TargetInstrInfo::PHI) {
|
while (MBB.front().getOpcode() == TargetInstrInfo::PHI) {
|
||||||
// Unlink the PHI node from the basic block... but don't delete the PHI yet
|
// Unlink the PHI node from the basic block, but don't delete the PHI yet.
|
||||||
MachineInstr *MI = MBB.remove(MBB.begin());
|
MachineInstr *MPhi = MBB.remove(MBB.begin());
|
||||||
|
|
||||||
assert(MRegisterInfo::isVirtualRegister(MI->getOperand(0).getReg()) &&
|
assert(MRegisterInfo::isVirtualRegister(MPhi->getOperand(0).getReg()) &&
|
||||||
"PHI node doesn't write virt reg?");
|
"PHI node doesn't write virt reg?");
|
||||||
|
|
||||||
unsigned DestReg = MI->getOperand(0).getReg();
|
unsigned DestReg = MPhi->getOperand(0).getReg();
|
||||||
|
|
||||||
// Create a new register for the incoming PHI arguments
|
// Create a new register for the incoming PHI arguments
|
||||||
const TargetRegisterClass *RC = MF.getSSARegMap()->getRegClass(DestReg);
|
const TargetRegisterClass *RC = MF.getSSARegMap()->getRegClass(DestReg);
|
||||||
@@ -126,10 +126,10 @@ bool PNE::EliminatePHINodes(MachineFunction &MF, MachineBasicBlock &MBB) {
|
|||||||
|
|
||||||
// Since we are going to be deleting the PHI node, if it is the last use
|
// Since we are going to be deleting the PHI node, if it is the last use
|
||||||
// of any registers, or if the value itself is dead, we need to move this
|
// of any registers, or if the value itself is dead, we need to move this
|
||||||
// information over to the new copy we just inserted...
|
// information over to the new copy we just inserted.
|
||||||
//
|
//
|
||||||
std::pair<LiveVariables::killed_iterator, LiveVariables::killed_iterator>
|
std::pair<LiveVariables::killed_iterator, LiveVariables::killed_iterator>
|
||||||
RKs = LV->killed_range(MI);
|
RKs = LV->killed_range(MPhi);
|
||||||
std::vector<std::pair<MachineInstr*, unsigned> > Range;
|
std::vector<std::pair<MachineInstr*, unsigned> > Range;
|
||||||
if (RKs.first != RKs.second) {
|
if (RKs.first != RKs.second) {
|
||||||
// Copy the range into a vector...
|
// Copy the range into a vector...
|
||||||
@@ -143,7 +143,7 @@ bool PNE::EliminatePHINodes(MachineFunction &MF, MachineBasicBlock &MBB) {
|
|||||||
LV->addVirtualRegisterKilled(Range[i].second, PHICopy);
|
LV->addVirtualRegisterKilled(Range[i].second, PHICopy);
|
||||||
}
|
}
|
||||||
|
|
||||||
RKs = LV->dead_range(MI);
|
RKs = LV->dead_range(MPhi);
|
||||||
if (RKs.first != RKs.second) {
|
if (RKs.first != RKs.second) {
|
||||||
// Works as above...
|
// Works as above...
|
||||||
Range.assign(RKs.first, RKs.second);
|
Range.assign(RKs.first, RKs.second);
|
||||||
@@ -155,18 +155,18 @@ bool PNE::EliminatePHINodes(MachineFunction &MF, MachineBasicBlock &MBB) {
|
|||||||
|
|
||||||
// Adjust the VRegPHIUseCount map to account for the removal of this PHI
|
// Adjust the VRegPHIUseCount map to account for the removal of this PHI
|
||||||
// node.
|
// node.
|
||||||
for (unsigned i = 1; i != MI->getNumOperands(); i += 2)
|
for (unsigned i = 1; i != MPhi->getNumOperands(); i += 2)
|
||||||
VRegPHIUseCount[MI->getOperand(i).getReg()] -= BBIsSuccOfPreds;
|
VRegPHIUseCount[MPhi->getOperand(i).getReg()] -= BBIsSuccOfPreds;
|
||||||
|
|
||||||
// Now loop over all of the incoming arguments, changing them to copy into
|
// Now loop over all of the incoming arguments, changing them to copy into
|
||||||
// the IncomingReg register in the corresponding predecessor basic block.
|
// the IncomingReg register in the corresponding predecessor basic block.
|
||||||
//
|
//
|
||||||
for (int i = MI->getNumOperands() - 1; i >= 2; i-=2) {
|
for (int i = MPhi->getNumOperands() - 1; i >= 2; i-=2) {
|
||||||
MachineOperand &opVal = MI->getOperand(i-1);
|
MachineOperand &opVal = MPhi->getOperand(i-1);
|
||||||
|
|
||||||
// Get the MachineBasicBlock equivalent of the BasicBlock that is the
|
// Get the MachineBasicBlock equivalent of the BasicBlock that is the
|
||||||
// source path the PHI.
|
// source path the PHI.
|
||||||
MachineBasicBlock &opBlock = *MI->getOperand(i).getMachineBasicBlock();
|
MachineBasicBlock &opBlock = *MPhi->getOperand(i).getMachineBasicBlock();
|
||||||
|
|
||||||
MachineBasicBlock::iterator I = opBlock.getFirstTerminator();
|
MachineBasicBlock::iterator I = opBlock.getFirstTerminator();
|
||||||
|
|
||||||
@@ -257,8 +257,8 @@ bool PNE::EliminatePHINodes(MachineFunction &MF, MachineBasicBlock &MBB) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// really delete the PHI instruction now!
|
// Really delete the PHI instruction now!
|
||||||
delete MI;
|
delete MPhi;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user