- //! Perform register allocation
- virtual bool runOnMachineFunction(MachineFunction &MF);
-
- private:
- typedef std::map<const LiveInterval*, unsigned> LI2NodeMap;
- typedef std::vector<const LiveInterval*> Node2LIMap;
- typedef std::vector<unsigned> AllowedSet;
- typedef std::vector<AllowedSet> AllowedSetMap;
- typedef std::set<unsigned> IgnoreSet;
-
- MachineFunction *mf;
- const TargetMachine *tm;
- const TargetRegisterInfo *tri;
- const TargetInstrInfo *tii;
- const MachineLoopInfo *loopInfo;
- MachineRegisterInfo *mri;
-
- LiveIntervals *li;
- VirtRegMap *vrm;
-
- LI2NodeMap li2Node;
- Node2LIMap node2LI;
- AllowedSetMap allowedSets;
- IgnoreSet ignoreSet;
-
- //! Builds a PBQP cost vector.
- template <typename Container>
- PBQPVector* buildCostVector(const Container &allowed,
- PBQPNum spillCost) const;
-
- //! \brief Builds a PBQP interference matrix.
- //!
- //! @return Either a pointer to a non-zero PBQP matrix representing the
- //! allocation option costs, or a null pointer for a zero matrix.
- //!
- //! Expects allowed sets for two interfering LiveIntervals. These allowed
- //! sets should contain only allocable registers from the LiveInterval's
- //! register class, with any interfering pre-colored registers removed.
- template <typename Container>
- PBQPMatrix* buildInterferenceMatrix(const Container &allowed1,
- const Container &allowed2) const;
-
- //!
- //! Expects allowed sets for two potentially coalescable LiveIntervals,
- //! and an estimated benefit due to coalescing. The allowed sets should
- //! contain only allocable registers from the LiveInterval's register
- //! classes, with any interfering pre-colored registers removed.
- template <typename Container>
- PBQPMatrix* buildCoalescingMatrix(const Container &allowed1,
- const Container &allowed2,
- PBQPNum cBenefit) const;
-
- //! \brief Helper function for constructInitialPBQPProblem().
- //!
- //! This function iterates over the Function we are about to allocate for
- //! and computes spill costs.
- void calcSpillCosts();
-
- //! \brief Scans the MachineFunction being allocated to find coalescing
- // opportunities.
- void findCoalescingOpportunities();
-
- //! \brief Constructs a PBQP problem representation of the register
- //! allocation problem for this function.
- //!
- //! @return a PBQP solver object for the register allocation problem.
- pbqp* constructPBQPProblem();
-
- //! \brief Given a solved PBQP problem maps this solution back to a register
- //! assignment.
- bool mapPBQPToRegAlloc(pbqp *problem);
-
- };
-
- char PBQPRegAlloc::ID = 0;
-}