comparison lib/Target/PowerPC/PPCBranchSelector.cpp @ 83:60c9769439b8

LLVM 3.7
author Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
date Wed, 18 Feb 2015 14:55:36 +0900
parents 54457678186b
children 7d135dc70f03
comparison
equal deleted inserted replaced
78:af83660cff7b 83:60c9769439b8
68 static_cast<const PPCInstrInfo *>(Fn.getSubtarget().getInstrInfo()); 68 static_cast<const PPCInstrInfo *>(Fn.getSubtarget().getInstrInfo());
69 // Give the blocks of the function a dense, in-order, numbering. 69 // Give the blocks of the function a dense, in-order, numbering.
70 Fn.RenumberBlocks(); 70 Fn.RenumberBlocks();
71 BlockSizes.resize(Fn.getNumBlockIDs()); 71 BlockSizes.resize(Fn.getNumBlockIDs());
72 72
73 auto GetAlignmentAdjustment =
74 [TII](MachineBasicBlock &MBB, unsigned Offset) -> unsigned {
75 unsigned Align = MBB.getAlignment();
76 if (!Align)
77 return 0;
78
79 unsigned AlignAmt = 1 << Align;
80 unsigned ParentAlign = MBB.getParent()->getAlignment();
81
82 if (Align <= ParentAlign)
83 return OffsetToAlignment(Offset, AlignAmt);
84
85 // The alignment of this MBB is larger than the function's alignment, so we
86 // can't tell whether or not it will insert nops. Assume that it will.
87 return AlignAmt + OffsetToAlignment(Offset, AlignAmt);
88 };
89
73 // Measure each MBB and compute a size for the entire function. 90 // Measure each MBB and compute a size for the entire function.
74 unsigned FuncSize = 0; 91 unsigned FuncSize = 0;
75 for (MachineFunction::iterator MFI = Fn.begin(), E = Fn.end(); MFI != E; 92 for (MachineFunction::iterator MFI = Fn.begin(), E = Fn.end(); MFI != E;
76 ++MFI) { 93 ++MFI) {
77 MachineBasicBlock *MBB = MFI; 94 MachineBasicBlock *MBB = MFI;
95
96 // The end of the previous block may have extra nops if this block has an
97 // alignment requirement.
98 if (MBB->getNumber() > 0) {
99 unsigned AlignExtra = GetAlignmentAdjustment(*MBB, FuncSize);
100 BlockSizes[MBB->getNumber()-1] += AlignExtra;
101 FuncSize += AlignExtra;
102 }
78 103
79 unsigned BlockSize = 0; 104 unsigned BlockSize = 0;
80 for (MachineBasicBlock::iterator MBBI = MBB->begin(), EE = MBB->end(); 105 for (MachineBasicBlock::iterator MBBI = MBB->begin(), EE = MBB->end();
81 MBBI != EE; ++MBBI) 106 MBBI != EE; ++MBBI)
82 BlockSize += TII->GetInstSizeInBytes(MBBI); 107 BlockSize += TII->GetInstSizeInBytes(MBBI);