no really, I can spell!
[oota-llvm.git] / include / llvm / CodeGen / LiveVariables.h
index e2bed5c2ef992df242623fad1e52704cad55ea22..26c036269d68ce2db4fbe38a087c8d83719ce29d 100644 (file)
@@ -32,8 +32,8 @@
 #include "llvm/CodeGen/MachineFunctionPass.h"
 #include "llvm/ADT/BitVector.h"
 #include "llvm/ADT/DenseMap.h"
-#include "llvm/ADT/SmallSet.h"
 #include "llvm/ADT/SmallVector.h"
+#include "llvm/ADT/SparseBitVector.h"
 
 namespace llvm {
 
@@ -43,24 +43,24 @@ class TargetRegisterInfo;
 class LiveVariables : public MachineFunctionPass {
 public:
   static char ID; // Pass identification, replacement for typeid
-  LiveVariables() : MachineFunctionPass((intptr_t)&ID) {}
+  LiveVariables() : MachineFunctionPass(&ID) {}
 
   /// VarInfo - This represents the regions where a virtual register is live in
   /// the program.  We represent this with three different pieces of
-  /// information: the instruction that uniquely defines the value, the set of
-  /// blocks the instruction is live into and live out of, and the set of 
-  /// non-phi instructions that are the last users of the value.
+  /// information: the set of blocks in which the instruction is live
+  /// throughout, the set of blocks in which the instruction is actually used,
+  /// and the set of non-phi instructions that are the last users of the value.
   ///
   /// In the common case where a value is defined and killed in the same block,
-  /// There is one killing instruction, and  AliveBlocks is empty.
+  /// There is one killing instruction, and AliveBlocks is empty.
   ///
   /// Otherwise, the value is live out of the block.  If the value is live
-  /// across any blocks, these blocks are listed in AliveBlocks.  Blocks where
-  /// the liveness range ends are not included in AliveBlocks, instead being
-  /// captured by the Kills set.  In these blocks, the value is live into the
-  /// block (unless the value is defined and killed in the same block) and lives
-  /// until the specified instruction.  Note that there cannot ever be a value
-  /// whose Kills set contains two instructions from the same basic block.
+  /// throughout any blocks, these blocks are listed in AliveBlocks.  Blocks
+  /// where the liveness range ends are not included in AliveBlocks, instead
+  /// being captured by the Kills set.  In these blocks, the value is live into
+  /// the block (unless the value is defined and killed in the same block) and
+  /// lives until the specified instruction.  Note that there cannot ever be a
+  /// value whose Kills set contains two instructions from the same basic block.
   ///
   /// PHI nodes complicate things a bit.  If a PHI node is the last user of a
   /// value in one of its predecessor blocks, it is not listed in the kills set,
@@ -72,15 +72,11 @@ public:
   /// included). This is sensical because the value must be live to the end of
   /// the block, but is not live in any successor blocks.
   struct VarInfo {
-    /// AliveBlocks - Set of blocks of which this value is alive completely
+    /// AliveBlocks - Set of blocks in which this value is alive completely
     /// through.  This is a bit set which uses the basic block number as an
     /// index.
     ///
-    BitVector AliveBlocks;
-
-    /// UsedBlocks - Set of blocks of which this value is actually used. This
-    /// is a bit set which uses the basic block number as an index.
-    BitVector UsedBlocks;
+    SparseBitVector<> AliveBlocks;
 
     /// NumUses - Number of uses of this register across the entire function.
     ///
@@ -147,7 +143,7 @@ private:   // Intermediate data structures
   /// HandlePhysRegKill - Add kills of Reg and its sub-registers to the
   /// uses. Pay special attention to the sub-register uses which may come below
   /// the last use of the whole register.
-  bool HandlePhysRegKill(unsigned Reg);
+  bool HandlePhysRegKill(unsigned Reg, MachineInstr *MI);
 
   void HandlePhysRegUse(unsigned Reg, MachineInstr *MI);
   void HandlePhysRegDef(unsigned Reg, MachineInstr *MI);
@@ -203,7 +199,7 @@ public:
     bool Removed = false;
     for (unsigned i = 0, e = MI->getNumOperands(); i != e; ++i) {
       MachineOperand &MO = MI->getOperand(i);
-      if (MO.isRegister() && MO.isKill() && MO.getReg() == reg) {
+      if (MO.isReg() && MO.isKill() && MO.getReg() == reg) {
         MO.setIsKill(false);
         Removed = true;
         break;
@@ -238,7 +234,7 @@ public:
     bool Removed = false;
     for (unsigned i = 0, e = MI->getNumOperands(); i != e; ++i) {
       MachineOperand &MO = MI->getOperand(i);
-      if (MO.isRegister() && MO.isDef() && MO.getReg() == reg) {
+      if (MO.isReg() && MO.isDef() && MO.getReg() == reg) {
         MO.setIsDead(false);
         Removed = true;
         break;
@@ -263,6 +259,7 @@ public:
   void MarkVirtRegAliveInBlock(VarInfo& VRInfo, MachineBasicBlock* DefBlock,
                                MachineBasicBlock *BB,
                                std::vector<MachineBasicBlock*> &WorkList);
+  void HandleVirtRegDef(unsigned reg, MachineInstr *MI);
   void HandleVirtRegUse(unsigned reg, MachineBasicBlock *MBB,
                         MachineInstr *MI);
 };