[llvm-commits] CVS: llvm/lib/Target/ARM/ARMConstantIslandPass.cpp

Evan Cheng evan.cheng at apple.com
Thu Jan 25 15:19:17 PST 2007



Changes in directory llvm/lib/Target/ARM:

ARMConstantIslandPass.cpp updated: 1.4 -> 1.5
---
Log message:

Add comment, fix typo, reduce memory usage, etc.

---
Diffs of the changes:  (+14 -9)

 ARMConstantIslandPass.cpp |   23 ++++++++++++++---------
 1 files changed, 14 insertions(+), 9 deletions(-)


Index: llvm/lib/Target/ARM/ARMConstantIslandPass.cpp
diff -u llvm/lib/Target/ARM/ARMConstantIslandPass.cpp:1.4 llvm/lib/Target/ARM/ARMConstantIslandPass.cpp:1.5
--- llvm/lib/Target/ARM/ARMConstantIslandPass.cpp:1.4	Thu Jan 25 13:43:52 2007
+++ llvm/lib/Target/ARM/ARMConstantIslandPass.cpp	Thu Jan 25 17:18:59 2007
@@ -79,14 +79,14 @@
     /// opcode.
     struct ImmBranch {
       MachineInstr *MI;
-      bool isCond;
+      unsigned MaxDisp : 31;
+      bool isCond : 1;
       int UncondBr;
-      unsigned MaxDisp;
-      ImmBranch(MachineInstr *mi, bool cond, int ubr, unsigned maxdisp)
-        : MI(mi), isCond(cond), UncondBr(ubr), MaxDisp(maxdisp) {}
+      ImmBranch(MachineInstr *mi, unsigned maxdisp, bool cond, int ubr)
+        : MI(mi), MaxDisp(maxdisp), isCond(cond), UncondBr(ubr) {}
     };
 
-    /// Branches - Keep track of all the immediate branche instructions.
+    /// Branches - Keep track of all the immediate branch instructions.
     ///
     std::vector<ImmBranch> ImmBranches;
 
@@ -107,7 +107,7 @@
     void SplitBlockBeforeInstr(MachineInstr *MI);
     void UpdateForInsertedWaterBlock(MachineBasicBlock *NewBB);
     bool HandleConstantPoolUser(MachineFunction &Fn, CPUser &U);
-    bool ShortenImmediateBranch(MachineFunction &Fn, ImmBranch &Br);
+    bool FixUpImmediateBranch(MachineFunction &Fn, ImmBranch &Br);
 
     unsigned GetInstSize(MachineInstr *MI) const;
     unsigned GetOffsetOf(MachineInstr *MI) const;
@@ -154,7 +154,7 @@
     for (unsigned i = 0, e = CPUsers.size(); i != e; ++i)
       MadeChange |= HandleConstantPoolUser(Fn, CPUsers[i]);
     for (unsigned i = 0, e = ImmBranches.size(); i != e; ++i)
-      MadeChange |= ShortenImmediateBranch(Fn, ImmBranches[i]);
+      MadeChange |= FixUpImmediateBranch(Fn, ImmBranches[i]);
   } while (MadeChange);
   
   BBSizes.clear();
@@ -260,7 +260,7 @@
           break;
         }
         unsigned MaxDisp = (1 << (Bits-1)) * Scale;
-        ImmBranches.push_back(ImmBranch(I, isCond, UOpc, MaxDisp));
+        ImmBranches.push_back(ImmBranch(I, MaxDisp, isCond, UOpc));
       }
 
       // Scan the instructions for constant pool operands.
@@ -560,8 +560,13 @@
   return true;
 }
 
+/// FixUpImmediateBranch - Fix up immediate branches whose destination is too
+/// far away to fit in its displacement field. If it is a conditional branch,
+/// then it is converted to an inverse conditional branch + an unconditional
+/// branch to the destination. If it is an unconditional branch, then it is
+/// converted to a branch to a branch.
 bool
-ARMConstantIslands::ShortenImmediateBranch(MachineFunction &Fn, ImmBranch &Br) {
+ARMConstantIslands::FixUpImmediateBranch(MachineFunction &Fn, ImmBranch &Br) {
   MachineInstr *MI = Br.MI;
   MachineBasicBlock *DestBB = MI->getOperand(0).getMachineBasicBlock();
 






More information about the llvm-commits mailing list