Revert "CalculateSpillWeights does not need to be a pass"
[oota-llvm.git] / include / llvm / CodeGen / CalcSpillWeights.h
index 00d9c6a5e627b4b72a35559e5f4f9d2555382a07..c8ec76410ce71507937c2a3a8e1507f9eed4517e 100644 (file)
@@ -21,9 +21,7 @@ namespace llvm {
   class MachineBlockFrequencyInfo;
   class MachineLoopInfo;
 
-  /// \brief Normalize the spill weight of a live interval
-  ///
-  /// The spill weight of a live interval is computed as:
+  /// normalizeSpillWeight - The spill weight of a live interval is computed as:
   ///
   ///   (sum(use freq) + sum(def freq)) / (K + size)
   ///
@@ -40,8 +38,8 @@ namespace llvm {
     return UseDefFreq / (Size + 25*SlotIndex::InstrDist);
   }
 
-  /// \brief Calculate auxiliary information for a virtual register such as its
-  /// spill weight and allocation hint.
+  /// VirtRegAuxInfo - Calculate auxiliary information for a virtual
+  /// register such as its spill weight and allocation hint.
   class VirtRegAuxInfo {
     MachineFunction &MF;
     LiveIntervals &LIS;
@@ -54,16 +52,29 @@ namespace llvm {
                    const MachineBlockFrequencyInfo &mbfi)
         : MF(mf), LIS(lis), Loops(loops), MBFI(mbfi) {}
 
-    /// \brief (re)compute li's spill weight and allocation hint.
+    /// CalculateWeightAndHint - (re)compute li's spill weight and allocation
+    /// hint.
     void CalculateWeightAndHint(LiveInterval &li);
   };
 
-  /// \brief Compute spill weights and allocation hints for all virtual register
+  /// CalculateSpillWeights - Compute spill weights for all virtual register
   /// live intervals.
-  void calculateSpillWeights(LiveIntervals &LIS,
-                             MachineFunction &MF,
-                             const MachineLoopInfo &MLI,
-                             const MachineBlockFrequencyInfo &MBFI);
+  class CalculateSpillWeights : public MachineFunctionPass {
+  public:
+    static char ID;
+
+    CalculateSpillWeights() : MachineFunctionPass(ID) {
+      initializeCalculateSpillWeightsPass(*PassRegistry::getPassRegistry());
+    }
+
+    virtual void getAnalysisUsage(AnalysisUsage &au) const;
+
+    virtual bool runOnMachineFunction(MachineFunction &fn);
+
+  private:
+    /// Returns true if the given live interval is zero length.
+    bool isZeroLengthInterval(LiveInterval *li) const;
+  };
 
 }