summaryrefslogtreecommitdiffstats
path: root/include/llvm/CodeGen/RegAllocPBQP.h
diff options
context:
space:
mode:
authorLang Hames <lhames@gmail.com>2010-09-23 04:28:54 +0000
committerLang Hames <lhames@gmail.com>2010-09-23 04:28:54 +0000
commitf70e7cc7a2871d498dbecbec2d1c3beb3da2af33 (patch)
treee6a449843c5993f31c5bed3b0f8802b53e400c0d /include/llvm/CodeGen/RegAllocPBQP.h
parent38a9288f78d76ad8f43a0398230c7c420390e606 (diff)
downloadexternal_llvm-f70e7cc7a2871d498dbecbec2d1c3beb3da2af33.zip
external_llvm-f70e7cc7a2871d498dbecbec2d1c3beb3da2af33.tar.gz
external_llvm-f70e7cc7a2871d498dbecbec2d1c3beb3da2af33.tar.bz2
Moved the PBQP allocator class out of the header and back in to the cpp file to hide the gory details.
Allocator instances can now be created by calling createPBQPRegisterAllocator. Tidied up use of CoalescerPair as per Jakob's suggestions. Made the new PBQPBuilder based construction process the default. The internal construction process remains in-place and available via -pbqp-builder=false for now. It will be removed shortly if the new process doesn't cause any regressions. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@114626 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/CodeGen/RegAllocPBQP.h')
-rw-r--r--include/llvm/CodeGen/RegAllocPBQP.h120
1 files changed, 1 insertions, 119 deletions
diff --git a/include/llvm/CodeGen/RegAllocPBQP.h b/include/llvm/CodeGen/RegAllocPBQP.h
index 2d9bac6..008a7b3 100644
--- a/include/llvm/CodeGen/RegAllocPBQP.h
+++ b/include/llvm/CodeGen/RegAllocPBQP.h
@@ -160,125 +160,7 @@ namespace llvm {
PBQP::PBQPNum benefit);
};
- ///
- /// PBQP based allocators solve the register allocation problem by mapping
- /// register allocation problems to Partitioned Boolean Quadratic
- /// Programming problems.
- class RegAllocPBQP : public MachineFunctionPass {
- public:
-
- static char ID;
-
- /// Construct a PBQP register allocator.
- RegAllocPBQP(std::auto_ptr<PBQPBuilder> b) : MachineFunctionPass(ID), builder(b) {}
-
- /// Return the pass name.
- virtual const char* getPassName() const {
- return "PBQP Register Allocator";
- }
-
- /// PBQP analysis usage.
- virtual void getAnalysisUsage(AnalysisUsage &au) const;
-
- /// 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::pair<unsigned, unsigned> RegPair;
- typedef std::map<RegPair, PBQP::PBQPNum> CoalesceMap;
- typedef std::vector<PBQP::Graph::NodeItr> NodeVector;
- typedef std::set<unsigned> RegSet;
-
-
- std::auto_ptr<PBQPBuilder> builder;
-
- MachineFunction *mf;
- const TargetMachine *tm;
- const TargetRegisterInfo *tri;
- const TargetInstrInfo *tii;
- const MachineLoopInfo *loopInfo;
- MachineRegisterInfo *mri;
- RenderMachineFunction *rmf;
-
- LiveIntervals *lis;
- LiveStacks *lss;
- VirtRegMap *vrm;
-
- LI2NodeMap li2Node;
- Node2LIMap node2LI;
- AllowedSetMap allowedSets;
- RegSet vregsToAlloc, emptyIntervalVRegs;
- NodeVector problemNodes;
-
-
- /// Builds a PBQP cost vector.
- template <typename RegContainer>
- PBQP::Vector buildCostVector(unsigned vReg,
- const RegContainer &allowed,
- const CoalesceMap &cealesces,
- PBQP::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 RegContainer>
- PBQP::Matrix* buildInterferenceMatrix(const RegContainer &allowed1,
- const RegContainer &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 RegContainer>
- PBQP::Matrix* buildCoalescingMatrix(const RegContainer &allowed1,
- const RegContainer &allowed2,
- PBQP::PBQPNum cBenefit) const;
-
- /// \brief Finds coalescing opportunities and returns them as a map.
- ///
- /// Any entries in the map are guaranteed coalescable, even if their
- /// corresponding live intervals overlap.
- CoalesceMap findCoalesces();
-
- /// \brief Finds the initial set of vreg intervals to allocate.
- void findVRegIntervalsToAlloc();
-
- /// \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::Graph constructPBQPProblem();
-
- /// \brief Adds a stack interval if the given live interval has been
- /// spilled. Used to support stack slot coloring.
- void addStackInterval(const LiveInterval *spilled,MachineRegisterInfo* mri);
-
- /// \brief Given a solved PBQP problem maps this solution back to a register
- /// assignment.
- bool mapPBQPToRegAlloc(const PBQP::Solution &solution);
-
- /// \brief Given a solved PBQP problem maps this solution back to a register
- /// assignment.
- bool mapPBQPToRegAlloc2(const PBQPRAProblem &problem,
- const PBQP::Solution &solution);
-
- /// \brief Postprocessing before final spilling. Sets basic block "live in"
- /// variables.
- void finalizeAlloc() const;
-
- };
-
+ FunctionPass* createPBQPRegisterAllocator(std::auto_ptr<PBQPBuilder> builder);
}
#endif /* LLVM_CODEGEN_REGALLOCPBQP_H */