[llvm-commits] CVS: llvm/lib/Target/X86/X86InstrInfo.cpp X86InstrInfo.h

Evan Cheng evan.cheng at apple.com
Thu May 17 17:17:27 PDT 2007



Changes in directory llvm/lib/Target/X86:

X86InstrInfo.cpp updated: 1.85 -> 1.86
X86InstrInfo.h updated: 1.63 -> 1.64
---
Log message:

RemoveBranch() and InsertBranch() now returns number of instructions deleted / inserted.

---
Diffs of the changes:  (+16 -13)

 X86InstrInfo.cpp |   21 ++++++++++++---------
 X86InstrInfo.h   |    8 ++++----
 2 files changed, 16 insertions(+), 13 deletions(-)


Index: llvm/lib/Target/X86/X86InstrInfo.cpp
diff -u llvm/lib/Target/X86/X86InstrInfo.cpp:1.85 llvm/lib/Target/X86/X86InstrInfo.cpp:1.86
--- llvm/lib/Target/X86/X86InstrInfo.cpp:1.85	Wed Apr 25 02:12:14 2007
+++ llvm/lib/Target/X86/X86InstrInfo.cpp	Thu May 17 19:17:09 2007
@@ -431,31 +431,33 @@
   return true;
 }
 
-void X86InstrInfo::RemoveBranch(MachineBasicBlock &MBB) const {
+unsigned X86InstrInfo::RemoveBranch(MachineBasicBlock &MBB) const {
   MachineBasicBlock::iterator I = MBB.end();
-  if (I == MBB.begin()) return;
+  if (I == MBB.begin()) return 0;
   --I;
   if (I->getOpcode() != X86::JMP && 
       GetCondFromBranchOpc(I->getOpcode()) == X86::COND_INVALID)
-    return;
+    return 0;
   
   // Remove the branch.
   I->eraseFromParent();
   
   I = MBB.end();
   
-  if (I == MBB.begin()) return;
+  if (I == MBB.begin()) return 1;
   --I;
   if (GetCondFromBranchOpc(I->getOpcode()) == X86::COND_INVALID)
-    return;
+    return 1;
   
   // Remove the branch.
   I->eraseFromParent();
+  return 2;
 }
 
-void X86InstrInfo::InsertBranch(MachineBasicBlock &MBB, MachineBasicBlock *TBB,
-                                MachineBasicBlock *FBB,
-                                const std::vector<MachineOperand> &Cond) const {
+unsigned
+X86InstrInfo::InsertBranch(MachineBasicBlock &MBB, MachineBasicBlock *TBB,
+                           MachineBasicBlock *FBB,
+                           const std::vector<MachineOperand> &Cond) const {
   // Shouldn't be a fall through.
   assert(TBB && "InsertBranch must not be told to insert a fallthrough");
   assert((Cond.size() == 1 || Cond.size() == 0) &&
@@ -470,13 +472,14 @@
       unsigned Opc = GetCondBranchFromCond((X86::CondCode)Cond[0].getImm());
       BuildMI(&MBB, get(Opc)).addMBB(TBB);
     }
-    return;
+    return 1;
   }
   
   // Two-way Conditional branch.
   unsigned Opc = GetCondBranchFromCond((X86::CondCode)Cond[0].getImm());
   BuildMI(&MBB, get(Opc)).addMBB(TBB);
   BuildMI(&MBB, get(X86::JMP)).addMBB(FBB);
+  return 2;
 }
 
 bool X86InstrInfo::BlockHasNoFallThrough(MachineBasicBlock &MBB) const {


Index: llvm/lib/Target/X86/X86InstrInfo.h
diff -u llvm/lib/Target/X86/X86InstrInfo.h:1.63 llvm/lib/Target/X86/X86InstrInfo.h:1.64
--- llvm/lib/Target/X86/X86InstrInfo.h:1.63	Tue Apr 10 17:10:25 2007
+++ llvm/lib/Target/X86/X86InstrInfo.h	Thu May 17 19:17:09 2007
@@ -263,10 +263,10 @@
   virtual bool AnalyzeBranch(MachineBasicBlock &MBB, MachineBasicBlock *&TBB,
                              MachineBasicBlock *&FBB,
                              std::vector<MachineOperand> &Cond) const;
-  virtual void RemoveBranch(MachineBasicBlock &MBB) const;
-  virtual void InsertBranch(MachineBasicBlock &MBB, MachineBasicBlock *TBB,
-                            MachineBasicBlock *FBB,
-                            const std::vector<MachineOperand> &Cond) const;
+  virtual unsigned RemoveBranch(MachineBasicBlock &MBB) const;
+  virtual unsigned InsertBranch(MachineBasicBlock &MBB, MachineBasicBlock *TBB,
+                                MachineBasicBlock *FBB,
+                                const std::vector<MachineOperand> &Cond) const;
   virtual bool BlockHasNoFallThrough(MachineBasicBlock &MBB) const;
   virtual bool ReverseBranchCondition(std::vector<MachineOperand> &Cond) const;
 






More information about the llvm-commits mailing list