diff options
author | Vikram S. Adve <vadve@cs.uiuc.edu> | 2003-07-25 21:06:09 +0000 |
---|---|---|
committer | Vikram S. Adve <vadve@cs.uiuc.edu> | 2003-07-25 21:06:09 +0000 |
commit | bc001b24a17a2329dfd96bc22b8862b645603058 (patch) | |
tree | 673e44bf002a0f934b35e62e4f3dcdae592c7751 /lib/CodeGen/RegAlloc/RegClass.h | |
parent | 523eb3f768b8c1252e231acd77d0ee758f5ddcd0 (diff) |
(1) Change the way unused regs. are marked and found to consider regType
info (since multiple reg types may share the same reg class).
(2) Remove machine-specific regalloc. methods that are no longer needed.
In particular, arguments and return value from a call do not need
machine-specific code for allocation.
(3) Rename TargetRegInfo::getRegType variants to avoid unintentional
overloading when an include file is omitted.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@7329 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/RegAlloc/RegClass.h')
-rw-r--r-- | lib/CodeGen/RegAlloc/RegClass.h | 42 |
1 files changed, 30 insertions, 12 deletions
diff --git a/lib/CodeGen/RegAlloc/RegClass.h b/lib/CodeGen/RegAlloc/RegClass.h index 7e1eb6590d..aa5b29da38 100644 --- a/lib/CodeGen/RegAlloc/RegClass.h +++ b/lib/CodeGen/RegAlloc/RegClass.h @@ -13,8 +13,6 @@ #include <stack> class TargetRegClassInfo; -typedef std::vector<unsigned> ReservedColorListType; - //----------------------------------------------------------------------------- // Class RegClass @@ -35,18 +33,14 @@ typedef std::vector<unsigned> ReservedColorListType; //----------------------------------------------------------------------------- class RegClass { const Function *const Meth; // Function we are working on - const TargetRegClassInfo *const MRC; // corresponding MRC + const TargetRegInfo *MRI; // Machine register information + const TargetRegClassInfo *const MRC; // Machine reg. class for this RegClass const unsigned RegClassID; // my int ID InterferenceGraph IG; // Interference graph - constructed by // buildInterferenceGraph std::stack<IGNode *> IGNodeStack; // the stack used for coloring - // ReservedColorList - for passing registers that are pre-allocated and cannot - // be used by the register allocator for this function. - // - const ReservedColorListType *const ReservedColorList; - // IsColorUsedArr - An array used for coloring each node. This array must be // of size MRC->getNumOfAllRegs(). Allocated once in the constructor for // efficiency. @@ -65,12 +59,24 @@ class RegClass { void colorIGNode(IGNode *const Node); + // This directly marks the colors used by a particular register number + // within the register class. External users should use the public + // versions of this function below. + inline void markColorUsed(unsigned classRegNum) { + assert(classRegNum < IsColorUsedArr.size() && "Invalid register used?"); + IsColorUsedArr[classRegNum] = true; + } + + inline bool isColorUsed(unsigned regNum) const { + assert(regNum < IsColorUsedArr.size() && "Invalid register used?"); + return IsColorUsedArr[regNum]; + } public: RegClass(const Function *M, - const TargetRegClassInfo *MRC, - const ReservedColorListType *RCL = 0); + const TargetRegInfo *_MRI_, + const TargetRegClassInfo *_MRC_); inline void createInterferenceGraph() { IG.createGraph(); } @@ -78,6 +84,8 @@ class RegClass { inline const unsigned getID() const { return RegClassID; } + inline const TargetRegClassInfo* getTargetRegClass() const { return MRC; } + // main method called for coloring regs // void colorAllRegs(); @@ -105,8 +113,18 @@ class RegClass { { IG.mergeIGNodesOfLRs(LR1, LR2); } - inline std::vector<bool> &getIsColorUsedArr() { return IsColorUsedArr; } - + inline void clearColorsUsed() { + IsColorUsedArr.clear(); + IsColorUsedArr.resize(MRC->getNumOfAllRegs()); + } + inline void markColorsUsed(unsigned ClassRegNum, + int UserRegType, + int RegTypeWanted) { + MRC->markColorsUsed(ClassRegNum, UserRegType, RegTypeWanted,IsColorUsedArr); + } + inline int getUnusedColor(int machineRegType) const { + return MRC->findUnusedColor(machineRegType, IsColorUsedArr); + } void printIGNodeList() const; void printIG(); |