2001-09-18 22:52:44 +00:00
|
|
|
/* Title: SparcRegClassInfo.h -*- C++ -*-
|
|
|
|
Author: Ruchira Sasanka
|
|
|
|
Date: Aug 20, 01
|
|
|
|
Purpose: Contains the description of integer register class of Sparc
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef SPARC_REG_INFO_CLASS_H
|
|
|
|
#define SPARC_REG_INFO_CLASS_H
|
|
|
|
|
|
|
|
#include "llvm/Target/MachineRegInfo.h"
|
|
|
|
#include "llvm/CodeGen/IGNode.h"
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// Integer Register Class
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
// Int register names in same order as enum in class SparcIntRegOrder
|
|
|
|
|
2002-01-20 22:54:45 +00:00
|
|
|
static const std::string IntRegNames[] =
|
2001-10-09 23:36:13 +00:00
|
|
|
{
|
2001-09-18 22:52:44 +00:00
|
|
|
"o0", "o1", "o2", "o3", "o4", "o5", "o7",
|
|
|
|
"l0", "l1", "l2", "l3", "l4", "l5", "l6", "l7",
|
2001-10-15 16:25:28 +00:00
|
|
|
"i0", "i1", "i2", "i3", "i4", "i5",
|
2001-10-22 13:43:08 +00:00
|
|
|
"i6", "i7",
|
2001-10-09 23:36:13 +00:00
|
|
|
"g0", "g1", "g2", "g3", "g4", "g5", "g6", "g7",
|
2001-10-22 13:43:08 +00:00
|
|
|
"o6" };
|
2001-09-18 22:52:44 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class SparcIntRegOrder{
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
enum RegsInPrefOrder // colors possible for a LR (in preferred order)
|
|
|
|
{
|
|
|
|
// --- following colors are volatile across function calls
|
|
|
|
// %g0 can't be used for coloring - always 0
|
|
|
|
|
2002-01-07 21:03:42 +00:00
|
|
|
|
2001-09-18 22:52:44 +00:00
|
|
|
o0, o1, o2, o3, o4, o5, o7, // %o0-%o5,
|
|
|
|
|
|
|
|
// %o6 is sp,
|
|
|
|
// all %0's can get modified by a call
|
|
|
|
|
|
|
|
// --- following colors are NON-volatile across function calls
|
|
|
|
|
|
|
|
l0, l1, l2, l3, l4, l5, l6, l7, // %l0-%l7
|
2001-10-15 16:25:28 +00:00
|
|
|
i0, i1, i2, i3, i4, i5, // %i0-%i5: i's need not be preserved
|
2001-09-18 22:52:44 +00:00
|
|
|
|
|
|
|
// %i6 is the fp - so not allocated
|
2001-09-30 23:16:47 +00:00
|
|
|
// %i7 is the ret address by convention - can be used for others
|
2001-09-18 22:52:44 +00:00
|
|
|
|
|
|
|
// max # of colors reg coloring can allocate (NumOfAvailRegs)
|
|
|
|
|
|
|
|
// --- following colors are not available for allocation within this phase
|
|
|
|
// --- but can appear for pre-colored ranges
|
|
|
|
|
2001-10-22 13:43:08 +00:00
|
|
|
i6, i7, g0, g1, g2, g3, g4, g5, g6, g7, o6
|
|
|
|
|
2002-01-07 21:03:42 +00:00
|
|
|
//*** NOTE: If we decide to use some %g regs, they are volatile
|
|
|
|
// (see sparc64ABI)
|
|
|
|
// Move the %g regs from the end of the enumeration to just above the
|
|
|
|
// enumeration of %o0 (change StartOfAllRegs below)
|
|
|
|
// change isRegVloatile method below
|
|
|
|
// Also change IntRegNames above.
|
2001-09-18 22:52:44 +00:00
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
// max # of colors reg coloring can allocate
|
2001-10-23 21:40:39 +00:00
|
|
|
static unsigned int const NumOfAvailRegs = i6;
|
2001-09-18 22:52:44 +00:00
|
|
|
|
|
|
|
static unsigned int const StartOfNonVolatileRegs = l0;
|
2001-10-09 23:36:13 +00:00
|
|
|
static unsigned int const StartOfAllRegs = o0;
|
2001-09-18 22:52:44 +00:00
|
|
|
static unsigned int const NumOfAllRegs = o6 + 1;
|
|
|
|
|
|
|
|
|
2002-01-20 22:54:45 +00:00
|
|
|
static const std::string getRegName(const unsigned reg) {
|
2001-09-18 22:52:44 +00:00
|
|
|
assert( reg < NumOfAllRegs );
|
|
|
|
return IntRegNames[reg];
|
|
|
|
}
|
|
|
|
|
2001-10-22 13:43:08 +00:00
|
|
|
static unsigned int getRegNumInCallersWindow(const unsigned reg) {
|
|
|
|
if (reg <= l7 || reg == o6) {
|
|
|
|
assert(0 && "registers o0-o7 and l0-l7 are not visible in caller");
|
|
|
|
return reg;
|
|
|
|
}
|
|
|
|
if (reg <= i7)
|
|
|
|
return reg - (i0 - o0);
|
|
|
|
assert((reg >= g0 || reg <= g7) && "Unrecognized integer register number");
|
|
|
|
return reg;
|
|
|
|
}
|
2001-09-18 22:52:44 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class SparcIntRegClass : public MachineRegClassInfo
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
|
|
|
SparcIntRegClass(unsigned ID)
|
|
|
|
: MachineRegClassInfo(ID,
|
|
|
|
SparcIntRegOrder::NumOfAvailRegs,
|
|
|
|
SparcIntRegOrder::NumOfAllRegs)
|
|
|
|
{ }
|
|
|
|
|
|
|
|
void colorIGNode(IGNode * Node, bool IsColorUsedArr[] ) const;
|
|
|
|
|
2001-10-16 01:23:19 +00:00
|
|
|
inline bool isRegVolatile(const int Reg) const {
|
|
|
|
return (Reg < (int) SparcIntRegOrder::StartOfNonVolatileRegs);
|
|
|
|
}
|
|
|
|
|
2001-09-18 22:52:44 +00:00
|
|
|
};
|
|
|
|
|
2002-01-07 21:03:42 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
2001-09-18 22:52:44 +00:00
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// Float Register Class
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
2002-01-20 22:54:45 +00:00
|
|
|
static const std::string FloatRegNames[] =
|
2001-09-18 22:52:44 +00:00
|
|
|
{
|
|
|
|
"f0", "f1", "f2", "f3", "f4", "f5", "f6", "f7", "f8", "f9",
|
|
|
|
"f10", "f11", "f12", "f13", "f14", "f15", "f16", "f17", "f18", "f19",
|
|
|
|
"f20", "f21", "f22", "f23", "f24", "f25", "f26", "f27", "f28", "f29",
|
|
|
|
"f30", "f31", "f32", "f33", "f34", "f35", "f36", "f37", "f38", "f39",
|
|
|
|
"f40", "f41", "f42", "f43", "f44", "f45", "f46", "f47", "f48", "f49",
|
|
|
|
"f50", "f51", "f52", "f53", "f54", "f55", "f56", "f57", "f58", "f59",
|
|
|
|
"f60", "f61", "f62", "f63"
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class SparcFloatRegOrder{
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
enum RegsInPrefOrder {
|
|
|
|
|
|
|
|
f0, f1, f2, f3, f4, f5, f6, f7, f8, f9,
|
|
|
|
f10, f11, f12, f13, f14, f15, f16, f17, f18, f19,
|
|
|
|
f20, f21, f22, f23, f24, f25, f26, f27, f28, f29,
|
|
|
|
f30, f31, f32, f33, f34, f35, f36, f37, f38, f39,
|
|
|
|
f40, f41, f42, f43, f44, f45, f46, f47, f48, f49,
|
|
|
|
f50, f51, f52, f53, f54, f55, f56, f57, f58, f59,
|
|
|
|
f60, f61, f62, f63
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
// there are 64 regs alltogether but only 32 regs can be allocated at
|
|
|
|
// a time.
|
|
|
|
|
|
|
|
static unsigned int const NumOfAvailRegs = 32;
|
|
|
|
static unsigned int const NumOfAllRegs = 64;
|
|
|
|
|
2001-09-30 23:16:47 +00:00
|
|
|
static unsigned int const StartOfNonVolatileRegs = f32;
|
2001-09-18 22:52:44 +00:00
|
|
|
static unsigned int const StartOfAllRegs = f0;
|
|
|
|
|
|
|
|
|
2002-01-20 22:54:45 +00:00
|
|
|
static const std::string getRegName(const unsigned reg) {
|
2001-09-18 22:52:44 +00:00
|
|
|
assert( reg < NumOfAllRegs );
|
|
|
|
return FloatRegNames[reg];
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class SparcFloatRegClass : public MachineRegClassInfo
|
|
|
|
{
|
|
|
|
private:
|
|
|
|
|
2001-09-30 23:16:47 +00:00
|
|
|
int findFloatColor(const LiveRange *const LR, unsigned Start,
|
2001-09-18 22:52:44 +00:00
|
|
|
unsigned End, bool IsColorUsedArr[] ) const;
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
SparcFloatRegClass(unsigned ID)
|
|
|
|
: MachineRegClassInfo(ID,
|
|
|
|
SparcFloatRegOrder::NumOfAvailRegs,
|
|
|
|
SparcFloatRegOrder::NumOfAllRegs)
|
|
|
|
{ }
|
|
|
|
|
|
|
|
void colorIGNode(IGNode * Node, bool IsColorUsedArr[] ) const;
|
|
|
|
|
2001-10-16 01:23:19 +00:00
|
|
|
// according to Sparc 64 ABI, all %fp regs are volatile
|
|
|
|
inline bool isRegVolatile(const int Reg) const { return true; }
|
|
|
|
|
|
|
|
|
2001-09-18 22:52:44 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// Int CC Register Class
|
2001-11-03 19:59:59 +00:00
|
|
|
// Only one integer cc register is available. However, this register is
|
|
|
|
// referred to as %xcc when instructions like subcc are executed but
|
|
|
|
// referred to as %ccr (i.e., %xcc + %icc") when this register is moved
|
|
|
|
// into an integer register using RD or WR instrcutions. So, two ids are
|
|
|
|
// allocated for two names.
|
2001-09-18 22:52:44 +00:00
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
2002-01-20 22:54:45 +00:00
|
|
|
static const std::string IntCCRegNames[] =
|
2001-11-03 19:59:59 +00:00
|
|
|
{
|
|
|
|
"xcc", "ccr"
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class SparcIntCCRegOrder{
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
enum RegsInPrefOrder {
|
|
|
|
|
|
|
|
xcc, ccr // only one is available - see the note above
|
|
|
|
};
|
|
|
|
|
2002-01-20 22:54:45 +00:00
|
|
|
static const std::string getRegName(const unsigned reg) {
|
2001-11-03 19:59:59 +00:00
|
|
|
assert( reg < 2 );
|
|
|
|
return IntCCRegNames[reg];
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
2001-09-18 22:52:44 +00:00
|
|
|
class SparcIntCCRegClass : public MachineRegClassInfo
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
|
|
|
SparcIntCCRegClass(unsigned ID)
|
2001-11-03 19:59:59 +00:00
|
|
|
: MachineRegClassInfo(ID, 1, 2) { }
|
2001-09-18 22:52:44 +00:00
|
|
|
|
|
|
|
inline void colorIGNode(IGNode * Node, bool IsColorUsedArr[] ) const {
|
|
|
|
Node->setColor(0); // only one int cc reg is available
|
|
|
|
}
|
|
|
|
|
2002-01-07 21:03:42 +00:00
|
|
|
// according to Sparc 64 ABI, %ccr is volatile
|
|
|
|
//
|
2001-10-16 01:23:19 +00:00
|
|
|
inline bool isRegVolatile(const int Reg) const { return true; }
|
|
|
|
|
2001-09-18 22:52:44 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
2002-01-07 21:03:42 +00:00
|
|
|
|
2001-09-18 22:52:44 +00:00
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// Float CC Register Class
|
|
|
|
// Only 4 Float CC registers are available
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
2002-01-20 22:54:45 +00:00
|
|
|
static const std::string FloatCCRegNames[] =
|
2001-09-18 22:52:44 +00:00
|
|
|
{
|
|
|
|
"fcc0", "fcc1", "fcc2", "fcc3"
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class SparcFloatCCRegOrder{
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
enum RegsInPrefOrder {
|
|
|
|
|
|
|
|
fcc0, fcc1, fcc2, fcc3
|
|
|
|
};
|
|
|
|
|
2002-01-20 22:54:45 +00:00
|
|
|
static const std::string getRegName(const unsigned reg) {
|
2001-09-18 22:52:44 +00:00
|
|
|
assert( reg < 4 );
|
|
|
|
return FloatCCRegNames[reg];
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class SparcFloatCCRegClass : public MachineRegClassInfo
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
|
|
|
SparcFloatCCRegClass(unsigned ID)
|
|
|
|
: MachineRegClassInfo(ID, 4, 4) { }
|
|
|
|
|
|
|
|
void colorIGNode(IGNode * Node, bool IsColorUsedArr[] ) const {
|
|
|
|
int c;
|
|
|
|
for(c=0; c < 4 && IsColorUsedArr[c] ; ++c) ; // find color
|
|
|
|
assert( (c < 4) && "Can allocate only 4 float cc registers");
|
|
|
|
Node->setColor(c);
|
|
|
|
}
|
|
|
|
|
2002-01-07 21:03:42 +00:00
|
|
|
|
|
|
|
// according to Sparc 64 ABI, all %fp CC regs are volatile
|
|
|
|
//
|
2001-10-16 01:23:19 +00:00
|
|
|
inline bool isRegVolatile(const int Reg) const { return true; }
|
|
|
|
|
|
|
|
|
2001-09-18 22:52:44 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#endif
|