summaryrefslogtreecommitdiff
path: root/include/llvm/Target
diff options
context:
space:
mode:
authorVikram S. Adve <vadve@cs.uiuc.edu>2003-07-25 21:01:43 +0000
committerVikram S. Adve <vadve@cs.uiuc.edu>2003-07-25 21:01:43 +0000
commit523eb3f768b8c1252e231acd77d0ee758f5ddcd0 (patch)
treeeb4b14436a49f2afff29af3b7dcc4692abb11503 /include/llvm/Target
parent34a856749fd5563c201e91ce1cd2dfc345f6f49c (diff)
downloadllvm-523eb3f768b8c1252e231acd77d0ee758f5ddcd0.tar.gz
llvm-523eb3f768b8c1252e231acd77d0ee758f5ddcd0.tar.bz2
llvm-523eb3f768b8c1252e231acd77d0ee758f5ddcd0.tar.xz
Change the way unused regs. are marked and found to consider regType
info (since multiple reg types may share the same reg class). Remove machine-specific regalloc. methods that are no longer needed. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@7328 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/Target')
-rw-r--r--include/llvm/Target/TargetRegInfo.h73
1 files changed, 49 insertions, 24 deletions
diff --git a/include/llvm/Target/TargetRegInfo.h b/include/llvm/Target/TargetRegInfo.h
index 505f610894..76e1daf222 100644
--- a/include/llvm/Target/TargetRegInfo.h
+++ b/include/llvm/Target/TargetRegInfo.h
@@ -39,13 +39,45 @@ public:
inline unsigned getNumOfAvailRegs() const { return NumOfAvailRegs; }
inline unsigned getNumOfAllRegs() const { return NumOfAllRegs; }
+ // This method marks the registers used for a given register number.
+ // This defaults to marking a single register but may mark multiple
+ // registers when a single number denotes paired registers.
+ //
+ virtual void markColorsUsed(unsigned RegInClass,
+ int UserRegType,
+ int RegTypeWanted,
+ std::vector<bool> &IsColorUsedArr) const {
+ assert(RegInClass < NumOfAllRegs && RegInClass < IsColorUsedArr.size());
+ assert(UserRegType == RegTypeWanted &&
+ "Default method is probably incorrect for class with multiple types.");
+ IsColorUsedArr[RegInClass] = true;
+ }
+
+ // This method finds unused registers of the specified register type,
+ // using the given "used" flag array IsColorUsedArr. It defaults to
+ // checking a single entry in the array directly, but that can be overridden
+ // for paired registers and other such silliness.
+ // It returns -1 if no unused color is found.
+ //
+ virtual int findUnusedColor(int RegTypeWanted,
+ const std::vector<bool> &IsColorUsedArr) const {
+ // find first unused color in the IsColorUsedArr directly
+ unsigned NC = this->getNumOfAvailRegs();
+ assert(IsColorUsedArr.size() >= NC && "Invalid colors-used array");
+ for (unsigned c = 0; c < NC; c++)
+ if (!IsColorUsedArr[c])
+ return c;
+ return -1;
+ }
+
// This method should find a color which is not used by neighbors
// (i.e., a false position in IsColorUsedArr) and
virtual void colorIGNode(IGNode *Node,
- std::vector<bool> &IsColorUsedArr) const = 0;
+ const std::vector<bool> &IsColorUsedArr) const = 0;
+
virtual bool isRegVolatile(int Reg) const = 0;
- //If any specific register needs extra information
+ // If any specific register needs extra information
virtual bool modifiedByCall(int Reg) const {return false; }
virtual const char* const getRegName(unsigned reg) const = 0;
@@ -130,14 +162,16 @@ public:
virtual void colorMethodArgs(const Function *Func, LiveRangeInfo &LRI,
AddedInstrns *FirstAI) const = 0;
- virtual void colorCallArgs(MachineInstr *CalI,
- LiveRangeInfo& LRI, AddedInstrns *CallAI,
- PhyRegAlloc &PRA, const BasicBlock *BB) const = 0;
-
- virtual void colorRetValue(MachineInstr *RetI, LiveRangeInfo &LRI,
- AddedInstrns *RetAI) const = 0;
-
-
+ // Method for inserting caller saving code. The caller must save all the
+ // volatile registers across a call based on the calling conventions of
+ // an architecture. This must insert code for saving and restoring
+ // such registers on
+ //
+ virtual void insertCallerSavingCode(std::vector<MachineInstr*>& instrnsBefore,
+ std::vector<MachineInstr*>& instrnsAfter,
+ MachineInstr *CallMI,
+ const BasicBlock *BB,
+ PhyRegAlloc &PRA) const = 0;
// The following methods are used to generate "copy" machine instructions
// for an architecture. Currently they are used in TargetRegClass
@@ -227,9 +261,11 @@ public:
}
// Get the register type for a register identified different ways.
- //
- virtual int getRegType(const Type* type) const = 0;
- virtual int getRegType(const LiveRange *LR) const = 0;
+ // Note that getRegTypeForLR(LR) != getRegTypeForDataType(LR->getType())!
+ // The reg class of a LR depends both on the Value types in it and whether
+ // they are CC registers or not (for example).
+ virtual int getRegTypeForDataType(const Type* type) const = 0;
+ virtual int getRegTypeForLR(const LiveRange *LR) const = 0;
virtual int getRegType(int unifiedRegNum) const = 0;
// The following methods are used to get the frame/stack pointers
@@ -237,17 +273,6 @@ public:
virtual unsigned getFramePointer() const = 0;
virtual unsigned getStackPointer() const = 0;
- // Method for inserting caller saving code. The caller must save all the
- // volatile registers across a call based on the calling conventions of
- // an architecture. This must insert code for saving and restoring
- // such registers on
- //
- virtual void insertCallerSavingCode(std::vector<MachineInstr*>& instrnsBefore,
- std::vector<MachineInstr*>& instrnsAfter,
- MachineInstr *MInst,
- const BasicBlock *BB,
- PhyRegAlloc &PRA) const = 0;
-
// This method gives the the number of bytes of stack spaceallocated
// to a register when it is spilled to the stack.
//