mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-05-21 12:38:45 +00:00
Eliminate delta argument from AdjustBBOffsetsAfter.
The block offset can be computed from the previous block. That is more robust than keeping track of a delta. Eliminate one redundant AdjustBBOffsetsAfter call. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@146018 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
a26811ec83
commit
2fe71c5ef4
@ -215,7 +215,7 @@ namespace {
|
|||||||
const std::vector<MachineInstr*> &CPEMIs);
|
const std::vector<MachineInstr*> &CPEMIs);
|
||||||
MachineBasicBlock *SplitBlockBeforeInstr(MachineInstr *MI);
|
MachineBasicBlock *SplitBlockBeforeInstr(MachineInstr *MI);
|
||||||
void UpdateForInsertedWaterBlock(MachineBasicBlock *NewBB);
|
void UpdateForInsertedWaterBlock(MachineBasicBlock *NewBB);
|
||||||
void AdjustBBOffsetsAfter(MachineBasicBlock *BB, int delta);
|
void AdjustBBOffsetsAfter(MachineBasicBlock *BB);
|
||||||
bool DecrementOldEntry(unsigned CPI, MachineInstr* CPEMI);
|
bool DecrementOldEntry(unsigned CPI, MachineInstr* CPEMI);
|
||||||
int LookForExistingCPEntry(CPUser& U, unsigned UserOffset);
|
int LookForExistingCPEntry(CPUser& U, unsigned UserOffset);
|
||||||
bool LookForWater(CPUser&U, unsigned UserOffset, water_iterator &WaterIter);
|
bool LookForWater(CPUser&U, unsigned UserOffset, water_iterator &WaterIter);
|
||||||
@ -869,7 +869,7 @@ MachineBasicBlock *ARMConstantIslands::SplitBlockBeforeInstr(MachineInstr *MI) {
|
|||||||
|
|
||||||
// All BBOffsets following these blocks must be modified.
|
// All BBOffsets following these blocks must be modified.
|
||||||
if (delta)
|
if (delta)
|
||||||
AdjustBBOffsetsAfter(NewBB, delta);
|
AdjustBBOffsetsAfter(NewBB);
|
||||||
|
|
||||||
return NewBB;
|
return NewBB;
|
||||||
}
|
}
|
||||||
@ -967,12 +967,13 @@ static bool BBIsJumpedOver(MachineBasicBlock *MBB) {
|
|||||||
}
|
}
|
||||||
#endif // NDEBUG
|
#endif // NDEBUG
|
||||||
|
|
||||||
void ARMConstantIslands::AdjustBBOffsetsAfter(MachineBasicBlock *BB,
|
void ARMConstantIslands::AdjustBBOffsetsAfter(MachineBasicBlock *BB) {
|
||||||
int delta) {
|
|
||||||
MachineFunction::iterator MBBI = BB; MBBI = llvm::next(MBBI);
|
MachineFunction::iterator MBBI = BB; MBBI = llvm::next(MBBI);
|
||||||
for(unsigned i = BB->getNumber()+1, e = BB->getParent()->getNumBlockIDs();
|
for(unsigned i = BB->getNumber()+1, e = BB->getParent()->getNumBlockIDs();
|
||||||
i < e; ++i) {
|
i < e; ++i) {
|
||||||
BBInfo[i].Offset += delta;
|
unsigned OldOffset = BBInfo[i].Offset;
|
||||||
|
BBInfo[i].Offset = BBInfo[i-1].postOffset();
|
||||||
|
int delta = BBInfo[i].Offset - OldOffset;
|
||||||
// If some existing blocks have padding, adjust the padding as needed, a
|
// If some existing blocks have padding, adjust the padding as needed, a
|
||||||
// bit tricky. delta can be negative so don't use % on that.
|
// bit tricky. delta can be negative so don't use % on that.
|
||||||
if (!isThumb)
|
if (!isThumb)
|
||||||
@ -981,7 +982,6 @@ void ARMConstantIslands::AdjustBBOffsetsAfter(MachineBasicBlock *BB,
|
|||||||
if (!MBB->empty() && !HasInlineAsm) {
|
if (!MBB->empty() && !HasInlineAsm) {
|
||||||
// Constant pool entries require padding.
|
// Constant pool entries require padding.
|
||||||
if (MBB->begin()->getOpcode() == ARM::CONSTPOOL_ENTRY) {
|
if (MBB->begin()->getOpcode() == ARM::CONSTPOOL_ENTRY) {
|
||||||
unsigned OldOffset = BBInfo[i].Offset - delta;
|
|
||||||
if ((OldOffset%4) == 0 && (BBInfo[i].Offset%4) != 0) {
|
if ((OldOffset%4) == 0 && (BBInfo[i].Offset%4) != 0) {
|
||||||
// add new padding
|
// add new padding
|
||||||
BBInfo[i].Size += 2;
|
BBInfo[i].Size += 2;
|
||||||
@ -1005,15 +1005,11 @@ void ARMConstantIslands::AdjustBBOffsetsAfter(MachineBasicBlock *BB,
|
|||||||
if ((OldMIOffset%4) == 0 && (NewMIOffset%4) != 0) {
|
if ((OldMIOffset%4) == 0 && (NewMIOffset%4) != 0) {
|
||||||
// remove existing padding
|
// remove existing padding
|
||||||
BBInfo[i].Size -= 2;
|
BBInfo[i].Size -= 2;
|
||||||
delta -= 2;
|
|
||||||
} else if ((OldMIOffset%4) != 0 && (NewMIOffset%4) == 0) {
|
} else if ((OldMIOffset%4) != 0 && (NewMIOffset%4) == 0) {
|
||||||
// add new padding
|
// add new padding
|
||||||
BBInfo[i].Size += 2;
|
BBInfo[i].Size += 2;
|
||||||
delta += 2;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (delta==0)
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
MBBI = llvm::next(MBBI);
|
MBBI = llvm::next(MBBI);
|
||||||
}
|
}
|
||||||
@ -1197,7 +1193,7 @@ void ARMConstantIslands::CreateNewWater(unsigned CPUserIndex,
|
|||||||
MaxDisp, false, UncondBr));
|
MaxDisp, false, UncondBr));
|
||||||
int delta = isThumb1 ? 2 : 4;
|
int delta = isThumb1 ? 2 : 4;
|
||||||
BBInfo[UserMBB->getNumber()].Size += delta;
|
BBInfo[UserMBB->getNumber()].Size += delta;
|
||||||
AdjustBBOffsetsAfter(UserMBB, delta);
|
AdjustBBOffsetsAfter(UserMBB);
|
||||||
} else {
|
} else {
|
||||||
// What a big block. Find a place within the block to split it.
|
// What a big block. Find a place within the block to split it.
|
||||||
// This is a little tricky on Thumb1 since instructions are 2 bytes
|
// This is a little tricky on Thumb1 since instructions are 2 bytes
|
||||||
@ -1361,7 +1357,7 @@ bool ARMConstantIslands::HandleConstantPoolUser(MachineFunction &MF,
|
|||||||
Size += 2;
|
Size += 2;
|
||||||
// Increase the size of the island block to account for the new entry.
|
// Increase the size of the island block to account for the new entry.
|
||||||
BBInfo[NewIsland->getNumber()].Size += Size;
|
BBInfo[NewIsland->getNumber()].Size += Size;
|
||||||
AdjustBBOffsetsAfter(NewIsland, Size);
|
AdjustBBOffsetsAfter(NewIsland);
|
||||||
|
|
||||||
// Finally, change the CPI in the instruction operand to be ID.
|
// Finally, change the CPI in the instruction operand to be ID.
|
||||||
for (unsigned i = 0, e = UserMI->getNumOperands(); i != e; ++i)
|
for (unsigned i = 0, e = UserMI->getNumOperands(); i != e; ++i)
|
||||||
@ -1397,7 +1393,7 @@ void ARMConstantIslands::RemoveDeadCPEMI(MachineInstr *CPEMI) {
|
|||||||
// This block no longer needs to be aligned. <rdar://problem/10534709>.
|
// This block no longer needs to be aligned. <rdar://problem/10534709>.
|
||||||
CPEBB->setAlignment(0);
|
CPEBB->setAlignment(0);
|
||||||
}
|
}
|
||||||
AdjustBBOffsetsAfter(CPEBB, -Size);
|
AdjustBBOffsetsAfter(CPEBB);
|
||||||
// An island has only one predecessor BB and one successor BB. Check if
|
// An island has only one predecessor BB and one successor BB. Check if
|
||||||
// this BB's predecessor jumps directly to this BB's successor. This
|
// this BB's predecessor jumps directly to this BB's successor. This
|
||||||
// shouldn't happen currently.
|
// shouldn't happen currently.
|
||||||
@ -1477,7 +1473,7 @@ ARMConstantIslands::FixUpUnconditionalBr(MachineFunction &MF, ImmBranch &Br) {
|
|||||||
Br.MaxDisp = (1 << 21) * 2;
|
Br.MaxDisp = (1 << 21) * 2;
|
||||||
MI->setDesc(TII->get(ARM::tBfar));
|
MI->setDesc(TII->get(ARM::tBfar));
|
||||||
BBInfo[MBB->getNumber()].Size += 2;
|
BBInfo[MBB->getNumber()].Size += 2;
|
||||||
AdjustBBOffsetsAfter(MBB, 2);
|
AdjustBBOffsetsAfter(MBB);
|
||||||
HasFarJump = true;
|
HasFarJump = true;
|
||||||
++NumUBrFixed;
|
++NumUBrFixed;
|
||||||
|
|
||||||
@ -1541,8 +1537,6 @@ ARMConstantIslands::FixUpConditionalBr(MachineFunction &MF, ImmBranch &Br) {
|
|||||||
// branch to the destination.
|
// branch to the destination.
|
||||||
int delta = TII->GetInstSizeInBytes(&MBB->back());
|
int delta = TII->GetInstSizeInBytes(&MBB->back());
|
||||||
BBInfo[MBB->getNumber()].Size -= delta;
|
BBInfo[MBB->getNumber()].Size -= delta;
|
||||||
MachineBasicBlock* SplitBB = llvm::next(MachineFunction::iterator(MBB));
|
|
||||||
AdjustBBOffsetsAfter(SplitBB, -delta);
|
|
||||||
MBB->back().eraseFromParent();
|
MBB->back().eraseFromParent();
|
||||||
// BBInfo[SplitBB].Offset is wrong temporarily, fixed below
|
// BBInfo[SplitBB].Offset is wrong temporarily, fixed below
|
||||||
}
|
}
|
||||||
@ -1570,10 +1564,7 @@ ARMConstantIslands::FixUpConditionalBr(MachineFunction &MF, ImmBranch &Br) {
|
|||||||
// Remove the old conditional branch. It may or may not still be in MBB.
|
// Remove the old conditional branch. It may or may not still be in MBB.
|
||||||
BBInfo[MI->getParent()->getNumber()].Size -= TII->GetInstSizeInBytes(MI);
|
BBInfo[MI->getParent()->getNumber()].Size -= TII->GetInstSizeInBytes(MI);
|
||||||
MI->eraseFromParent();
|
MI->eraseFromParent();
|
||||||
|
AdjustBBOffsetsAfter(MBB);
|
||||||
// The net size change is an addition of one unconditional branch.
|
|
||||||
int delta = TII->GetInstSizeInBytes(&MBB->back());
|
|
||||||
AdjustBBOffsetsAfter(MBB, delta);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1637,7 +1628,7 @@ bool ARMConstantIslands::OptimizeThumb2Instructions(MachineFunction &MF) {
|
|||||||
U.MI->setDesc(TII->get(NewOpc));
|
U.MI->setDesc(TII->get(NewOpc));
|
||||||
MachineBasicBlock *MBB = U.MI->getParent();
|
MachineBasicBlock *MBB = U.MI->getParent();
|
||||||
BBInfo[MBB->getNumber()].Size -= 2;
|
BBInfo[MBB->getNumber()].Size -= 2;
|
||||||
AdjustBBOffsetsAfter(MBB, -2);
|
AdjustBBOffsetsAfter(MBB);
|
||||||
++NumT2CPShrunk;
|
++NumT2CPShrunk;
|
||||||
MadeChange = true;
|
MadeChange = true;
|
||||||
}
|
}
|
||||||
@ -1678,7 +1669,7 @@ bool ARMConstantIslands::OptimizeThumb2Branches(MachineFunction &MF) {
|
|||||||
Br.MI->setDesc(TII->get(NewOpc));
|
Br.MI->setDesc(TII->get(NewOpc));
|
||||||
MachineBasicBlock *MBB = Br.MI->getParent();
|
MachineBasicBlock *MBB = Br.MI->getParent();
|
||||||
BBInfo[MBB->getNumber()].Size -= 2;
|
BBInfo[MBB->getNumber()].Size -= 2;
|
||||||
AdjustBBOffsetsAfter(MBB, -2);
|
AdjustBBOffsetsAfter(MBB);
|
||||||
++NumT2BrShrunk;
|
++NumT2BrShrunk;
|
||||||
MadeChange = true;
|
MadeChange = true;
|
||||||
}
|
}
|
||||||
@ -1720,7 +1711,7 @@ bool ARMConstantIslands::OptimizeThumb2Branches(MachineFunction &MF) {
|
|||||||
Br.MI->eraseFromParent();
|
Br.MI->eraseFromParent();
|
||||||
Br.MI = NewBR;
|
Br.MI = NewBR;
|
||||||
BBInfo[MBB->getNumber()].Size -= 2;
|
BBInfo[MBB->getNumber()].Size -= 2;
|
||||||
AdjustBBOffsetsAfter(MBB, -2);
|
AdjustBBOffsetsAfter(MBB);
|
||||||
++NumCBZ;
|
++NumCBZ;
|
||||||
MadeChange = true;
|
MadeChange = true;
|
||||||
}
|
}
|
||||||
@ -1847,7 +1838,7 @@ bool ARMConstantIslands::OptimizeThumb2JumpTables(MachineFunction &MF) {
|
|||||||
|
|
||||||
int delta = OrigSize - NewSize;
|
int delta = OrigSize - NewSize;
|
||||||
BBInfo[MBB->getNumber()].Size -= delta;
|
BBInfo[MBB->getNumber()].Size -= delta;
|
||||||
AdjustBBOffsetsAfter(MBB, -delta);
|
AdjustBBOffsetsAfter(MBB);
|
||||||
|
|
||||||
++NumTBs;
|
++NumTBs;
|
||||||
MadeChange = true;
|
MadeChange = true;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user