[llvm-commits] CVS: llvm/lib/Target/Sparc/SparcInternals.h SparcRegInfo.cpp
Chris Lattner
lattner at cs.uiuc.edu
Wed Jan 15 15:15:04 PST 2003
Changes in directory llvm/lib/Target/Sparc:
SparcInternals.h updated: 1.78 -> 1.79
SparcRegInfo.cpp updated: 1.88 -> 1.89
---
Log message:
Adjust to simpler interfaces
Eliminate dependency on RegClass.h
---
Diffs of the changes:
Index: llvm/lib/Target/Sparc/SparcInternals.h
diff -u llvm/lib/Target/Sparc/SparcInternals.h:1.78 llvm/lib/Target/Sparc/SparcInternals.h:1.79
--- llvm/lib/Target/Sparc/SparcInternals.h:1.78 Tue Jan 14 15:59:15 2003
+++ llvm/lib/Target/Sparc/SparcInternals.h Wed Jan 15 15:14:32 2003
@@ -275,14 +275,8 @@
std::vector<MachineInstr *>& AddedInstrnsBefore)
const;
- // The following 4 methods are used to find the RegType (see enum above)
- // for a reg class and a given primitive type, a LiveRange, a Value,
- // or a particular machine register.
- // The fifth function gives the reg class of the given RegType.
- //
- int getRegType(unsigned regClassID, const Type* type) const;
+ int getRegType(const Type* type) const;
int getRegType(const LiveRange *LR) const;
- int getRegType(const Value *Val) const;
int getRegType(int unifiedRegNum) const;
// Used to generate a copy instruction based on the register class of
@@ -322,13 +316,6 @@
//
unsigned getRegClassIDOfType(const Type *type,
bool isCCReg = false) const;
-
- // To find the register class of a Value
- //
- inline unsigned getRegClassIDOfValue(const Value *Val,
- bool isCCReg = false) const {
- return getRegClassIDOfType(Val->getType(), isCCReg);
- }
// To find the register class to which a specified register belongs
//
Index: llvm/lib/Target/Sparc/SparcRegInfo.cpp
diff -u llvm/lib/Target/Sparc/SparcRegInfo.cpp:1.88 llvm/lib/Target/Sparc/SparcRegInfo.cpp:1.89
--- llvm/lib/Target/Sparc/SparcRegInfo.cpp:1.88 Wed Jan 15 13:57:07 2003
+++ llvm/lib/Target/Sparc/SparcRegInfo.cpp Wed Jan 15 15:14:32 2003
@@ -14,7 +14,6 @@
#include "llvm/CodeGen/MachineInstrBuilder.h"
#include "llvm/CodeGen/MachineInstrAnnot.h"
#include "llvm/CodeGen/FunctionLiveVarInfo.h" // FIXME: Remove
-#include "llvm/CodeGen/RegClass.h"
#include "../../CodeGen/RegAlloc/RegAllocCommon.h" // FIXME!
#include "llvm/iTerminators.h"
#include "llvm/iOther.h"
@@ -233,8 +232,8 @@
// The following 4 methods are used to find the RegType (SparcInternals.h)
// of a LiveRange, a Value, and for a given register unified reg number.
//
-int UltraSparcRegInfo::getRegType(unsigned regClassID,
- const Type* type) const {
+int UltraSparcRegInfo::getRegType(const Type* type) const {
+ unsigned regClassID = getRegClassIDOfType(type);
switch (regClassID) {
case IntRegClassID: return IntRegType;
case FloatRegClassID: {
@@ -251,13 +250,25 @@
}
int UltraSparcRegInfo::getRegType(const LiveRange *LR) const {
- return getRegType(LR->getRegClass()->getID(), LR->getType());
-}
+ const Type* type = LR->getType();
-int UltraSparcRegInfo::getRegType(const Value *Val) const {
- return getRegType(getRegClassIDOfValue(Val), Val->getType());
+ unsigned regClassID = LR->getRegClassID();
+ switch (regClassID) {
+ case IntRegClassID: return IntRegType;
+ case FloatRegClassID:
+ if (type == Type::FloatTy)
+ return FPSingleRegType;
+ else if (type == Type::DoubleTy)
+ return FPDoubleRegType;
+ break;
+ assert(0 && "Unknown type in FloatRegClass");
+ case IntCCRegClassID: return IntCCRegType; break;
+ case FloatCCRegClassID: return FloatCCRegType; break;
+ default: assert( 0 && "Unknown reg class ID"); return 0;
+ }
}
+
int UltraSparcRegInfo::getRegType(int unifiedRegNum) const {
if (unifiedRegNum < 32)
return IntRegType;
@@ -294,8 +305,8 @@
return 0;
}
- if(isCCReg)
- return res + 2; // corresponidng condition code regiser
+ if (isCCReg)
+ return res + 2; // corresponding condition code register
else
return res;
}
@@ -365,7 +376,7 @@
LiveRange *RetAddrLR = LRI.getLiveRangeForValue(RetAddrVal);
assert(RetAddrLR && "INTERNAL ERROR: No LR for return address of call!");
- unsigned RegClassID = RetAddrLR->getRegClass()->getID();
+ unsigned RegClassID = RetAddrLR->getRegClassID();
RetAddrLR->setColor(getUnifiedRegNum(IntRegClassID, SparcIntRegClass::o7));
}
@@ -429,8 +440,8 @@
LiveRange *LR = LRI.getLiveRangeForValue(I);
assert( LR && "No live range found for method arg");
- unsigned regType = getRegType( LR );
- unsigned RegClassID = (LR->getRegClass())->getID();
+ unsigned regType = getRegType(LR);
+ unsigned RegClassID = LR->getRegClassID();
// Find whether this argument is coming in a register (if not, on stack)
// Also find the correct register the argument must use (UniArgReg)
@@ -580,7 +591,7 @@
LiveRange *RetValLR = LRI.getLiveRangeForValue(RetVal);
assert(RetValLR && "No LR for return Value of call!");
- unsigned RegClassID = RetValLR->getRegClass()->getID();
+ unsigned RegClassID = RetValLR->getRegClassID();
// now suggest a register depending on the register class of ret arg
if( RegClassID == IntRegClassID )
@@ -607,7 +618,7 @@
assert (LR && "Must have a LR for all arguments since "
"all args (even consts) must be defined before");
- unsigned regType = getRegType( LR );
+ unsigned regType = getRegType(LR);
unsigned regClassIDOfArgReg = BadRegClass; // reg class of chosen reg (unused)
// Choose a register for this arg depending on whether it is
@@ -706,7 +717,7 @@
// Use TReg to load and store the value.
// Use TmpOff to save TReg, since that may have a live value.
//
- int TReg = PRA.getUniRegNotUsedByThisInst( LR->getRegClass(), CallMI );
+ int TReg = PRA.getUniRegNotUsedByThisInst(LR->getRegClass(), CallMI);
int TmpOff = PRA.MF.getInfo()->
pushTempValue(getSpilledRegSize(getRegType(LR)));
const TargetFrameInfo& frameInfo = target.getFrameInfo();
@@ -772,7 +783,7 @@
assert(RetValLR && "ERR:No LR for non-void return value");
}
- unsigned RegClassID = (RetValLR->getRegClass())->getID();
+ unsigned RegClassID = RetValLR->getRegClassID();
bool recvCorrectColor;
unsigned CorrectCol; // correct color for ret value
unsigned UniRetReg; // unified number for CorrectCol
@@ -800,7 +811,7 @@
// put copy instruction
if( !recvCorrectColor ) {
- unsigned regType = getRegType( RetValLR );
+ unsigned regType = getRegType(RetValLR);
if( RetValLR->hasColor() ) {
@@ -842,8 +853,8 @@
// get the LR of call operand (parameter)
LiveRange *const LR = LRI.getLiveRangeForValue(CallArg);
- unsigned RegClassID = getRegClassIDOfValue( CallArg);
- unsigned regType = getRegType( RegClassID, CallArg->getType() );
+ unsigned RegClassID = getRegClassIDOfType(CallArg->getType());
+ unsigned regType = getRegType(CallArg->getType());
// Find whether this argument is coming in a register (if not, on stack)
// Also find the correct register the argument must use (UniArgReg)
@@ -889,8 +900,8 @@
assert(regType != IntRegType && argCopy->getType()->isInteger()
&& "Must be passing copy of FP argument in int register");
- unsigned copyRegClassID = getRegClassIDOfValue(argCopy);
- unsigned copyRegType = getRegType(copyRegClassID, argCopy->getType());
+ unsigned copyRegClassID = getRegClassIDOfType(argCopy->getType());
+ unsigned copyRegType = getRegType(argCopy->getType());
int copyRegNum = regNumForIntArg(/*inCallee*/false, /*isVarArgs*/false,
argNo, intArgNo, fpArgNo-1,
@@ -974,8 +985,7 @@
assert(0 && "No LR for return value of non-void method");
}
- unsigned RegClassID = (LR->getRegClass())->getID();
-
+ unsigned RegClassID = LR->getRegClassID();
if (RegClassID == IntRegClassID)
LR->setSuggestedColor(SparcIntRegClass::i0);
else if (RegClassID == FloatRegClassID)
@@ -1011,8 +1021,8 @@
return;
}
- unsigned RegClassID = getRegClassIDOfValue(RetVal);
- unsigned regType = getRegType( RetVal );
+ unsigned RegClassID = getRegClassIDOfType(RetVal->getType());
+ unsigned regType = getRegType(RetVal->getType());
unsigned CorrectCol;
if(RegClassID == IntRegClassID)
@@ -1256,10 +1266,7 @@
void
UltraSparcRegInfo::cpValue2Value(Value *Src, Value *Dest,
vector<MachineInstr*>& mvec) const {
- int RegType = getRegType( Src );
-
- assert( (RegType==getRegType(Src)) && "Src & Dest are diff types");
-
+ int RegType = getRegType(Src->getType());
MachineInstr * MI = NULL;
switch( RegType ) {
@@ -1328,9 +1335,8 @@
assert(RetValLR && "No LR for RetValue of call");
if (RetValLR->hasColor())
- PushedRegSet.insert(
- getUnifiedRegNum((RetValLR->getRegClass())->getID(),
- RetValLR->getColor() ) );
+ PushedRegSet.insert(getUnifiedRegNum(RetValLR->getRegClassID(),
+ RetValLR->getColor()));
}
const ValueSet &LVSetAft = PRA.LVI->getLiveVarSetAfterMInst(CallMI, BB);
@@ -1348,7 +1354,7 @@
if( LR->hasColor() ) {
- unsigned RCID = (LR->getRegClass())->getID();
+ unsigned RCID = LR->getRegClassID();
unsigned Color = LR->getColor();
if ( isRegVolatile(RCID, Color) ) {
@@ -1362,7 +1368,7 @@
// if we haven't already pushed that register
- unsigned RegType = getRegType( LR );
+ unsigned RegType = getRegType(LR);
// Now get two instructions - to push on stack and pop from stack
// and add them to InstrnsBefore and InstrnsAfter of the
@@ -1458,7 +1464,7 @@
//---------------------------------------------------------------------------
void UltraSparcRegInfo::printReg(const LiveRange *LR) {
- unsigned RegClassID = (LR->getRegClass())->getID();
+ unsigned RegClassID = LR->getRegClassID();
cerr << " *Node " << (LR->getUserIGNode())->getIndex();
if (!LR->hasColor()) {
More information about the llvm-commits
mailing list