[llvm-commits] [llvm] r146008 - /llvm/trunk/lib/Target/ARM/ARMConstantIslandPass.cpp
Jakob Stoklund Olesen
stoklund at 2pi.dk
Tue Dec 6 17:22:52 PST 2011
Author: stoklund
Date: Tue Dec 6 19:22:52 2011
New Revision: 146008
URL: http://llvm.org/viewvc/llvm-project?rev=146008&view=rev
Log:
Move common expression into a method.
Modified:
llvm/trunk/lib/Target/ARM/ARMConstantIslandPass.cpp
Modified: llvm/trunk/lib/Target/ARM/ARMConstantIslandPass.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMConstantIslandPass.cpp?rev=146008&r1=146007&r2=146008&view=diff
==============================================================================
--- llvm/trunk/lib/Target/ARM/ARMConstantIslandPass.cpp (original)
+++ llvm/trunk/lib/Target/ARM/ARMConstantIslandPass.cpp Tue Dec 6 19:22:52 2011
@@ -84,6 +84,9 @@
BasicBlockInfo() : Offset(0), Size(0) {}
BasicBlockInfo(unsigned o, unsigned s) : Offset(o), Size(s) {}
+
+ /// Compute the offset immediately following this block.
+ unsigned postOffset() const { return Offset + Size; }
};
std::vector<BasicBlockInfo> BBInfo;
@@ -241,7 +244,7 @@
/// verify - check BBOffsets, BBSizes, alignment of islands
void ARMConstantIslands::verify(MachineFunction &MF) {
for (unsigned i = 1, e = BBInfo.size(); i != e; ++i)
- assert(BBInfo[i-1].Offset + BBInfo[i-1].Size == BBInfo[i].Offset);
+ assert(BBInfo[i-1].postOffset() == BBInfo[i].Offset);
if (!isThumb)
return;
#ifndef NDEBUG
@@ -802,7 +805,7 @@
BBInfo[OrigBBI].Size = OrigBBSize;
// ...and adjust BBOffsets for NewBB accordingly.
- BBInfo[NewBBI].Offset = BBInfo[OrigBBI].Offset + BBInfo[OrigBBI].Size;
+ BBInfo[NewBBI].Offset = BBInfo[OrigBBI].postOffset();
// Figure out how large the NewMBB is. As the second half of the original
// block, it may contain a tablejump.
@@ -819,7 +822,7 @@
// means we will always need padding if we didn't before, and vice versa.
// The original offset of the jump instruction was:
- unsigned OrigOffset = BBInfo[OrigBBI].Offset + BBInfo[OrigBBI].Size - delta;
+ unsigned OrigOffset = BBInfo[OrigBBI].postOffset() - delta;
if (OrigOffset%4 == 0) {
// We had padding before and now we don't. No net change in code size.
delta = 0;
@@ -884,8 +887,7 @@
bool ARMConstantIslands::WaterIsInRange(unsigned UserOffset,
MachineBasicBlock* Water, CPUser &U) {
unsigned MaxDisp = U.MaxDisp;
- unsigned CPEOffset = BBInfo[Water->getNumber()].Offset +
- BBInfo[Water->getNumber()].Size;
+ unsigned CPEOffset = BBInfo[Water->getNumber()].postOffset();
// If the CPE is to be inserted before the instruction, that will raise
// the offset of the instruction.
@@ -1094,8 +1096,7 @@
(WaterBB->getNumber() < U.HighWaterMark->getNumber() ||
NewWaterList.count(WaterBB))) {
unsigned WBBId = WaterBB->getNumber();
- if (isThumb &&
- (BBInfo[WBBId].Offset + BBInfo[WBBId].Size)%4 != 0) {
+ if (isThumb && BBInfo[WBBId].postOffset()%4 != 0) {
// This is valid Water, but would introduce padding. Remember
// it in case we don't find any Water that doesn't do this.
if (!FoundWaterThatWouldPad) {
@@ -1131,9 +1132,8 @@
MachineInstr *UserMI = U.MI;
MachineInstr *CPEMI = U.CPEMI;
MachineBasicBlock *UserMBB = UserMI->getParent();
- unsigned OffsetOfNextBlock = BBInfo[UserMBB->getNumber()].Offset +
- BBInfo[UserMBB->getNumber()].Size;
- assert(OffsetOfNextBlock== BBInfo[UserMBB->getNumber()+1].Offset);
+ unsigned OffsetOfNextBlock = BBInfo[UserMBB->getNumber()].postOffset();
+ assert(OffsetOfNextBlock == BBInfo[UserMBB->getNumber()+1].Offset);
// If the block does not end in an unconditional branch already, and if the
// end of the block is within range, make new water there. (The addition
More information about the llvm-commits
mailing list