Add getScaledIntervalSize, which gives a measure of the size of an interval that...
[oota-llvm.git] / include / llvm / CodeGen / LiveIntervalAnalysis.h
index 4b5ceffa20a4dc5f7ac12df981a3db6827ba42d2..92c3b844c9cf53b3e67447da8dd2dd845a106151 100644 (file)
@@ -169,6 +169,15 @@ namespace llvm {
       return MBB2IdxMap[MBBNo].second;
     }
 
+    /// getIntervalSize - get the size of an interval in "units,"
+    /// where every function is composed of one thousand units.  This
+    /// measure scales properly with empty index slots in the function.
+    unsigned getScaledIntervalSize(LiveInterval& I) {
+      // Factor of 250 comes from 1000 units per function divided
+      // by four slots per instruction.
+      return (250 * I.getSize()) / i2miMap_.size();
+    }
+
     /// getMBBFromIndex - given an index in any instruction of an
     /// MBB return a pointer the MBB
     MachineBasicBlock* getMBBFromIndex(unsigned index) const {
@@ -220,6 +229,11 @@ namespace llvm {
         I = r2iMap_.insert(I, std::make_pair(reg, createInterval(reg)));
       return I->second;
     }
+    
+    /// addLiveRangeToEndOfBlock - Given a register and an instruction,
+    /// adds a live range from that instruction to the end of its MBB.
+    LiveRange addLiveRangeToEndOfBlock(unsigned reg,
+                                        MachineInstr* startInst);
 
     // Interval removal
 
@@ -278,10 +292,12 @@ namespace llvm {
     }
 
     /// addIntervalsForSpills - Create new intervals for spilled defs / uses of
-    /// the given interval.
+    /// the given interval. FIXME: It also returns the weight of the spill slot
+    /// (if any is created) by reference. This is temporary.
     std::vector<LiveInterval*>
     addIntervalsForSpills(const LiveInterval& i,
-                          const MachineLoopInfo *loopInfo, VirtRegMap& vrm);
+                          const MachineLoopInfo *loopInfo, VirtRegMap& vrm,
+                          float &SSWeight);
 
     /// spillPhysRegAroundRegDefsUses - Spill the specified physical register
     /// around all defs and uses of the specified interval.
@@ -302,13 +318,13 @@ namespace llvm {
     unsigned getNumConflictsWithPhysReg(const LiveInterval &li,
                                         unsigned PhysReg) const;
 
+    /// computeNumbering - Compute the index numbering.
+    void computeNumbering();
+
   private:      
     /// computeIntervals - Compute live intervals.
     void computeIntervals();
     
-    /// computeNumbering - Compute the index numbering.
-    void computeNumbering();
-    
     /// handleRegisterDef - update intervals for a register def
     /// (calls handlePhysicalRegisterDef and
     /// handleVirtualRegisterDef)
@@ -419,7 +435,7 @@ namespace llvm {
         SmallVector<int, 4> &ReMatIds, const MachineLoopInfo *loopInfo,
         unsigned &NewVReg, unsigned ImpUse, bool &HasDef, bool &HasUse,
         std::map<unsigned,unsigned> &MBBVRegsMap,
-        std::vector<LiveInterval*> &NewLIs);
+        std::vector<LiveInterval*> &NewLIs, float &SSWeight);
     void rewriteInstructionsForSpills(const LiveInterval &li, bool TrySplit,
         LiveInterval::Ranges::const_iterator &I,
         MachineInstr *OrigDefMI, MachineInstr *DefMI, unsigned Slot, int LdSlot,
@@ -431,7 +447,7 @@ namespace llvm {
         BitVector &RestoreMBBs,
         std::map<unsigned,std::vector<SRInfo> > &RestoreIdxes,
         std::map<unsigned,unsigned> &MBBVRegsMap,
-        std::vector<LiveInterval*> &NewLIs);
+        std::vector<LiveInterval*> &NewLIs, float &SSWeight);
 
     static LiveInterval createInterval(unsigned Reg);