Added an additional PBQP problem builder which adds coalescing costs (both between...
[oota-llvm.git] / include / llvm / CodeGen / RegAllocPBQP.h
index ee3baf36a92d0c66448eaf0280c201488c026f19..2d9bac6e0d3a6b16eeb0a99c172ab6b9d02bcb9c 100644 (file)
@@ -27,6 +27,7 @@ namespace llvm {
 
   class LiveInterval;
   class MachineFunction;
+  class MachineLoopInfo;
 
   /// This class wraps up a PBQP instance representing a register allocation
   /// problem, plus the structures necessary to map back from the PBQP solution
@@ -113,7 +114,6 @@ namespace llvm {
 
     typedef std::set<unsigned> RegSet;
  
-
     /// Default constructor.
     PBQPBuilder() {}
 
@@ -125,6 +125,7 @@ namespace llvm {
     virtual std::auto_ptr<PBQPRAProblem> build(
                                               MachineFunction *mf,
                                               const LiveIntervals *lis,
+                                              const MachineLoopInfo *loopInfo,
                                               const RegSet &vregs);
   private:
 
@@ -136,6 +137,29 @@ namespace llvm {
                               const TargetRegisterInfo *tri);
   };
 
+  /// Extended builder which adds coalescing constraints to a problem.
+  class PBQPBuilderWithCoalescing : public PBQPBuilder {
+  public:
+    /// Build a PBQP instance to represent the register allocation problem for
+    /// the given MachineFunction.
+    virtual std::auto_ptr<PBQPRAProblem> build(
+                                              MachineFunction *mf,
+                                              const LiveIntervals *lis,
+                                              const MachineLoopInfo *loopInfo,
+                                              const RegSet &vregs);   
+
+  private:
+
+    void addPhysRegCoalesce(PBQP::Vector &costVec, unsigned pregOption,
+                            PBQP::PBQPNum benefit);
+
+    void addVirtRegCoalesce(PBQP::Matrix &costMat,
+                            const PBQPRAProblem::AllowedSet &vr1Allowed,
+                            const PBQPRAProblem::AllowedSet &vr2Allowed,
+                            PBQP::PBQPNum benefit);
+  };
+
   ///
   /// PBQP based allocators solve the register allocation problem by mapping
   /// register allocation problems to Partitioned Boolean Quadratic