[llvm-commits] CVS: llvm/include/llvm/Target/TargetRegInfo.h
Vikram Adve
vadve at cs.uiuc.edu
Mon May 26 19:08:01 PDT 2003
Changes in directory llvm/include/llvm/Target:
TargetRegInfo.h updated: 1.33 -> 1.34
---
Log message:
(1) Added special register class containing (for now) %fsr.
Fixed spilling of %fcc[0-3] which are part of %fsr.
(2) Moved some machine-independent reg-class code to class TargetRegInfo
from SparcReg{Class,}Info.
---
Diffs of the changes:
Index: llvm/include/llvm/Target/TargetRegInfo.h
diff -u llvm/include/llvm/Target/TargetRegInfo.h:1.33 llvm/include/llvm/Target/TargetRegInfo.h:1.34
--- llvm/include/llvm/Target/TargetRegInfo.h:1.33 Sun May 25 11:02:05 2003
+++ llvm/include/llvm/Target/TargetRegInfo.h Mon May 26 19:07:13 2003
@@ -45,6 +45,8 @@
std::vector<bool> &IsColorUsedArr) const = 0;
virtual bool isRegVolatile(int Reg) const = 0;
+ virtual const char* const getRegName(unsigned reg) const = 0;
+
TargetRegClassInfo(unsigned ID, unsigned NVR, unsigned NAR)
: RegClassID(ID), NumOfAvailRegs(NVR), NumOfAllRegs(NAR) {}
};
@@ -75,11 +77,16 @@
// code register class will be returned. Otherwise, the normal register
// class (eg. int, float) must be returned.
virtual unsigned getRegClassIDOfType (const Type *type,
- bool isCCReg = false) const =0;
- virtual unsigned getRegClassIDOfReg (int unifiedRegNum) const =0;
- virtual unsigned getRegClassIDOfRegType(int regType) const =0;
-
- inline unsigned int getNumOfRegClasses() const {
+ bool isCCReg = false) const = 0;
+ virtual unsigned getRegClassIDOfRegType(int regType) const = 0;
+
+ unsigned getRegClassIDOfReg(int unifiedRegNum) const {
+ unsigned classId = 0;
+ (void) getClassRegNum(unifiedRegNum, classId);
+ return classId;
+ }
+
+ unsigned int getNumOfRegClasses() const {
return MachineRegClassArr.size();
}
@@ -169,13 +176,43 @@
// Each register class has a seperate space for register IDs. To convert
// a regId in a register class to a common Id, or vice versa,
- // we use the folloing methods.
+ // we use the folloing two methods.
//
- virtual int getUnifiedRegNum(unsigned regClassID, int reg) const = 0;
- virtual int getClassRegNum(int unifiedRegNum, unsigned& regClassID) const =0;
+ // Thsi method converts from class reg. number to unified register number.
+ int getUnifiedRegNum(unsigned regClassID, int reg) const {
+ if (reg == getInvalidRegNum()) { return getInvalidRegNum(); }
+ assert(regClassID < getNumOfRegClasses() && "Invalid register class");
+ int totalRegs = 0;
+ for (unsigned rcid = 0; rcid < regClassID; ++rcid)
+ totalRegs += MachineRegClassArr[rcid]->getNumOfAllRegs();
+ return reg + totalRegs;
+ }
+
+ // This method converts the unified number to the number in its class,
+ // and returns the class ID in regClassID.
+ int getClassRegNum(int uRegNum, unsigned& regClassID) const {
+ if (uRegNum == getInvalidRegNum()) { return getInvalidRegNum(); }
+
+ int totalRegs = 0, rcid = 0, NC = getNumOfRegClasses();
+ while (rcid < NC &&
+ uRegNum >= totalRegs + (int) MachineRegClassArr[rcid]->getNumOfAllRegs()) {
+ totalRegs += MachineRegClassArr[rcid]->getNumOfAllRegs();
+ rcid++;
+ }
+ if (rcid == NC) {
+ assert(0 && "getClassRegNum(): Invalid register number");
+ return getInvalidRegNum();
+ }
+ regClassID = rcid;
+ return uRegNum - totalRegs;
+ }
// Returns the assembly-language name of the specified machine register.
- virtual const char * const getUnifiedRegName(int UnifiedRegNum) const = 0;
+ const char * const getUnifiedRegName(int UnifiedRegNum) const {
+ unsigned regClassID = getNumOfRegClasses(); // initialize to invalid value
+ int regNumInClass = getClassRegNum(UnifiedRegNum, regClassID);
+ return MachineRegClassArr[regClassID]->getRegName(regNumInClass);
+ }
virtual int getRegType(const Type* type) const = 0;
virtual int getRegType(const LiveRange *LR) const = 0;
@@ -190,7 +227,6 @@
// be obtained using this method.
//
virtual int getInvalidRegNum() 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
More information about the llvm-commits
mailing list