diff options
author | Ruchira Sasanka <sasanka@students.uiuc.edu> | 2001-09-08 14:22:50 +0000 |
---|---|---|
committer | Ruchira Sasanka <sasanka@students.uiuc.edu> | 2001-09-08 14:22:50 +0000 |
commit | 7cd2ca13c1920e9db68695a364048cb6586bb324 (patch) | |
tree | e2e68e264d5af71eb75b5338cff0a7316e509f49 /lib/Target/SparcV9/RegAlloc/RegClass.h | |
parent | c7136d2b09a796528d7ce790190394dceb3ab6c3 (diff) | |
download | external_llvm-7cd2ca13c1920e9db68695a364048cb6586bb324.zip external_llvm-7cd2ca13c1920e9db68695a364048cb6586bb324.tar.gz external_llvm-7cd2ca13c1920e9db68695a364048cb6586bb324.tar.bz2 |
Committed for compliation. Not yet final.
--Ruchira
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@505 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Target/SparcV9/RegAlloc/RegClass.h')
-rw-r--r-- | lib/Target/SparcV9/RegAlloc/RegClass.h | 125 |
1 files changed, 125 insertions, 0 deletions
diff --git a/lib/Target/SparcV9/RegAlloc/RegClass.h b/lib/Target/SparcV9/RegAlloc/RegClass.h new file mode 100644 index 0000000..1d08502 --- /dev/null +++ b/lib/Target/SparcV9/RegAlloc/RegClass.h @@ -0,0 +1,125 @@ +/* Title: RegClass.h + Author: Ruchira Sasanka + Date: Aug 20, 01 + Purpose: Contains machine independent methods for register coloring. + + This is the class that contains all data structures and common algos + for coloring a particular register class (e.g., int class, fp class). + This class is hardware independent. This class accepts a hardware + dependent description of machine registers (MachineRegInfo class) to + get hardware specific info and color and indidual IG node. + + This class contains the InterferenceGraph (IG). + Also it contains an IGNode stack that can be used for coloring. + The class provides some easy access methods to the IG methods, since these + methods are called thru a register class. + +*/ + + + +#ifndef REG_CLASS_H +#define REG_CLASS_H + +#include "llvm/CodeGen/IGNode.h" +#include "llvm/CodeGen/InterferenceGraph.h" +#include "llvm/CodeGen/TargetMachine.h" + + +#include <stack> + + +typedef vector<unsigned int> ReservedColorListType; + + +class RegClass +{ + + private: + const Method *const Meth; // Method we are working on + + const MachineRegClassInfo *const MRC; // corresponding MRC + + const unsigned RegClassID; // my int ID + + InterferenceGraph IG; // Interference graph - constructed by + // buildInterferenceGraph + stack <IGNode *> IGNodeStack; // the stack used for coloring + + // for passing registered that are pre-allocated (e.g., %g's) + const ReservedColorListType *const ReservedColorList; + + // An array used for coloring each node. This array must be of size + // MRC->getNumOfAllRegs(). Allocated once in the constructor + // for efficiency. + bool *IsColorUsedArr; + + + //------------ private methods ------------------ + + void pushAllIGNodes(); + bool pushUnconstrainedIGNodes(); + IGNode * getIGNodeWithMinSpillCost(); + void colorIGNode(IGNode *const Node); + + public: + + RegClass(const Method *const M, + const MachineRegClassInfo *const MRC, + const ReservedColorListType *const RCL = NULL); + + inline void createInterferenceGraph() + { IG.createGraph(); } + + inline InterferenceGraph &getIG() { return IG; } + + inline const unsigned getID() const { return RegClassID; } + + void colorAllRegs(); // main method called for coloring regs + + inline unsigned getNumOfAvailRegs() const + { return MRC->getNumOfAvailRegs(); } + + ~RegClass() { delete[] IsColorUsedArr; }; + + + + // --- following methods are provided to access the IG contained within this + // ---- RegClass easilly. + + + inline void addLRToIG(LiveRange *const LR) + { IG.addLRToIG(LR); } + + inline void setInterference(const LiveRange *const LR1, + const LiveRange *const LR2) + { IG.setInterference(LR1, LR2); } + + inline unsigned getInterference(const LiveRange *const LR1, + const LiveRange *const LR2) const + { return IG.getInterference(LR1, LR2); } + + inline void mergeIGNodesOfLRs(const LiveRange *const LR1, + LiveRange *const LR2) + { IG.mergeIGNodesOfLRs(LR1, LR2); } + + + inline void printIGNodeList() const { + cout << "IG Nodes for Register Class " << RegClassID << ":" << endl; + IG.printIGNodeList(); + } + + inline void printIG() { + cout << "IG for Register Class " << RegClassID << ":" << endl; + IG.printIG(); + } + +}; + + + + + + + +#endif |