1 /* Title: SparcRegClassInfo.h -*- C++ -*-
2 Author: Ruchira Sasanka
4 Purpose: Contains the description of integer register class of Sparc
8 #ifndef SPARC_INT_REG_CLASS_H
9 #define SPARC_INT_REG_CLASS_H
11 #include "llvm/Target/RegInfo.h"
12 #include "llvm/CodeGen/IGNode.h"
14 //-----------------------------------------------------------------------------
15 // Integer Register Class
16 //-----------------------------------------------------------------------------
19 // Int register names in same order as enum in class SparcIntRegOrder
21 static string const IntRegNames[] =
22 { "g1", "g2", "g3", "g4", "g5", "g6", "g7",
23 "o0", "o1", "o2", "o3", "o4", "o5", "o7",
24 "l0", "l1", "l2", "l3", "l4", "l5", "l6", "l7",
25 "i0", "i1", "i2", "i3", "i4", "i5",
26 "g0", "i6", "i7", "o6" };
30 class SparcIntRegOrder{
34 enum RegsInPrefOrder // colors possible for a LR (in preferred order)
36 // --- following colors are volatile across function calls
37 // %g0 can't be used for coloring - always 0
39 g1, g2, g3, g4, g5, g6, g7, //%g1-%g7
40 o0, o1, o2, o3, o4, o5, o7, // %o0-%o5,
43 // all %0's can get modified by a call
45 // --- following colors are NON-volatile across function calls
47 l0, l1, l2, l3, l4, l5, l6, l7, // %l0-%l7
48 i0, i1, i2, i3, i4, i5, // %i0-%i5: i's need not be preserved
50 // %i6 is the fp - so not allocated
51 // %i7 is the ret address - can be used if saved
53 // max # of colors reg coloring can allocate (NumOfAvailRegs)
55 // --- following colors are not available for allocation within this phase
56 // --- but can appear for pre-colored ranges
64 // max # of colors reg coloring can allocate
65 static unsigned int const NumOfAvailRegs = g0;
67 static unsigned int const StartOfNonVolatileRegs = l0;
68 static unsigned int const StartOfAllRegs = g1;
69 static unsigned int const NumOfAllRegs = o6 + 1;
72 static const string getRegName(const unsigned reg) {
73 assert( reg < NumOfAllRegs );
74 return IntRegNames[reg];
81 class SparcIntRegClass : public MachineRegClassInfo
85 SparcIntRegClass(unsigned ID)
86 : MachineRegClassInfo(ID,
87 SparcIntRegOrder::NumOfAvailRegs,
88 SparcIntRegOrder::NumOfAllRegs)
91 void colorIGNode(IGNode * Node, bool IsColorUsedArr[] ) const;
95 //-----------------------------------------------------------------------------
96 // Float Register Class
97 //-----------------------------------------------------------------------------
99 static string const FloatRegNames[] =
101 "f0", "f1", "f2", "f3", "f4", "f5", "f6", "f7", "f8", "f9",
102 "f10", "f11", "f12", "f13", "f14", "f15", "f16", "f17", "f18", "f19",
103 "f20", "f21", "f22", "f23", "f24", "f25", "f26", "f27", "f28", "f29",
104 "f30", "f31", "f32", "f33", "f34", "f35", "f36", "f37", "f38", "f39",
105 "f40", "f41", "f42", "f43", "f44", "f45", "f46", "f47", "f48", "f49",
106 "f50", "f51", "f52", "f53", "f54", "f55", "f56", "f57", "f58", "f59",
107 "f60", "f61", "f62", "f63"
111 class SparcFloatRegOrder{
115 enum RegsInPrefOrder {
117 f0, f1, f2, f3, f4, f5, f6, f7, f8, f9,
118 f10, f11, f12, f13, f14, f15, f16, f17, f18, f19,
119 f20, f21, f22, f23, f24, f25, f26, f27, f28, f29,
120 f30, f31, f32, f33, f34, f35, f36, f37, f38, f39,
121 f40, f41, f42, f43, f44, f45, f46, f47, f48, f49,
122 f50, f51, f52, f53, f54, f55, f56, f57, f58, f59,
127 // there are 64 regs alltogether but only 32 regs can be allocated at
130 static unsigned int const NumOfAvailRegs = 32;
131 static unsigned int const NumOfAllRegs = 64;
133 static unsigned int const StartOfNonVolatileRegs = f6;
134 static unsigned int const StartOfAllRegs = f0;
137 static const string getRegName(const unsigned reg) {
138 assert( reg < NumOfAllRegs );
139 return FloatRegNames[reg];
148 class SparcFloatRegClass : public MachineRegClassInfo
152 int findFloatColor(const IGNode *const Node, unsigned Start,
153 unsigned End, bool IsColorUsedArr[] ) const;
157 SparcFloatRegClass(unsigned ID)
158 : MachineRegClassInfo(ID,
159 SparcFloatRegOrder::NumOfAvailRegs,
160 SparcFloatRegOrder::NumOfAllRegs)
163 void colorIGNode(IGNode * Node, bool IsColorUsedArr[] ) const;
170 //-----------------------------------------------------------------------------
171 // Int CC Register Class
172 // Only one integer cc register is available
173 //-----------------------------------------------------------------------------
176 class SparcIntCCRegClass : public MachineRegClassInfo
180 SparcIntCCRegClass(unsigned ID)
181 : MachineRegClassInfo(ID,1, 1) { }
183 inline void colorIGNode(IGNode * Node, bool IsColorUsedArr[] ) const {
184 Node->setColor(0); // only one int cc reg is available
191 //-----------------------------------------------------------------------------
192 // Float CC Register Class
193 // Only 4 Float CC registers are available
194 //-----------------------------------------------------------------------------
197 static string const FloatCCRegNames[] =
199 "fcc0", "fcc1", "fcc2", "fcc3"
203 class SparcFloatCCRegOrder{
207 enum RegsInPrefOrder {
209 fcc0, fcc1, fcc2, fcc3
212 static const string getRegName(const unsigned reg) {
214 return FloatCCRegNames[reg];
221 class SparcFloatCCRegClass : public MachineRegClassInfo
225 SparcFloatCCRegClass(unsigned ID)
226 : MachineRegClassInfo(ID, 4, 4) { }
228 void colorIGNode(IGNode * Node, bool IsColorUsedArr[] ) const {
230 for(c=0; c < 4 && IsColorUsedArr[c] ; ++c) ; // find color
231 assert( (c < 4) && "Can allocate only 4 float cc registers");