mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2026-04-25 21:18:19 +00:00
[PowerPC] Use 16-byte alignment for modern cores for functions/loops
Most modern PowerPC cores prefer that functions and loops start on
16-byte-aligned boundaries (*), so instruct block placement, etc. to make this
happen. The branch selector has also been adjusted so account for the extra
nops that might now be inserted before loop headers.
(*) Some cores actually prefer other alignments for small loops, but that will
be addressed in a follow-up commit.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@225115 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -70,12 +70,37 @@ bool PPCBSel::runOnMachineFunction(MachineFunction &Fn) {
|
||||
Fn.RenumberBlocks();
|
||||
BlockSizes.resize(Fn.getNumBlockIDs());
|
||||
|
||||
auto GetAlignmentAdjustment =
|
||||
[TII](MachineBasicBlock &MBB, unsigned Offset) -> unsigned {
|
||||
unsigned Align = MBB.getAlignment();
|
||||
if (!Align)
|
||||
return 0;
|
||||
|
||||
unsigned AlignAmt = 1 << Align;
|
||||
unsigned ParentAlign = MBB.getParent()->getAlignment();
|
||||
|
||||
if (Align <= ParentAlign)
|
||||
return OffsetToAlignment(Offset, AlignAmt);
|
||||
|
||||
// The alignment of this MBB is larger than the function's alignment, so we
|
||||
// can't tell whether or not it will insert nops. Assume that it will.
|
||||
return AlignAmt + OffsetToAlignment(Offset, AlignAmt);
|
||||
};
|
||||
|
||||
// Measure each MBB and compute a size for the entire function.
|
||||
unsigned FuncSize = 0;
|
||||
for (MachineFunction::iterator MFI = Fn.begin(), E = Fn.end(); MFI != E;
|
||||
++MFI) {
|
||||
MachineBasicBlock *MBB = MFI;
|
||||
|
||||
// The end of the previous block may have extra nops if this block has an
|
||||
// alignment requirement.
|
||||
if (MBB->getNumber() > 0) {
|
||||
unsigned AlignExtra = GetAlignmentAdjustment(*MBB, FuncSize);
|
||||
BlockSizes[MBB->getNumber()-1] += AlignExtra;
|
||||
FuncSize += AlignExtra;
|
||||
}
|
||||
|
||||
unsigned BlockSize = 0;
|
||||
for (MachineBasicBlock::iterator MBBI = MBB->begin(), EE = MBB->end();
|
||||
MBBI != EE; ++MBBI)
|
||||
|
||||
Reference in New Issue
Block a user