3ebef550f08aeeac04789f1ac7af2dcb7129ee8e
[oota-llvm.git] / lib / Target / SparcV9 / SparcV9RegInfo.h
1 /* Title:   SparcRegClassInfo.h    -*- C++ -*-
2    Author:  Ruchira Sasanka
3    Date:    Aug 20, 01
4    Purpose: Contains the description of integer register class of Sparc
5 */
6
7 #ifndef SPARC_INT_REG_CLASS_H
8 #define SPARC_INT_REG_CLASS_H
9
10 #include "llvm/Target/Machine.h"
11
12 //-----------------------------------------------------------------------------
13 // Integer Register Class
14 //-----------------------------------------------------------------------------
15
16 // Int register names in same order as enum in class SparcIntRegOrder
17 //
18 static string const IntRegNames[] = 
19   {       "g1", "g2", "g3", "g4", "g5", "g6", "g7",
20     "o0", "o1", "o2", "o3", "o4", "o5",       "o7",
21     "l0", "l1", "l2", "l3", "l4", "l5", "l6", "l7",
22     "i0", "i1", "i2", "i3", "i4", "i5", 
23     "g0", "i6", "i7",  "o6" }; 
24
25
26
27 class SparcIntRegOrder{ 
28
29  public:
30
31   enum RegsInPrefOrder   // colors possible for a LR (in preferred order)
32    { 
33      // --- following colors are volatile across function calls
34      // %g0 can't be used for coloring - always 0
35                      
36      g1, g2, g3, g4, g5, g6, g7,  //%g1-%g7  
37      o0, o1, o2, o3, o4, o5, o7,  // %o0-%o5, 
38
39      // %o6 is sp, 
40      // all %0's can get modified by a call
41
42      // --- following colors are NON-volatile across function calls
43       
44      l0, l1, l2, l3, l4, l5, l6, l7,    //  %l0-%l7
45      i0, i1, i2, i3, i4, i5,            // %i0-%i5: i's need not be preserved 
46       
47      // %i6 is the fp - so not allocated
48      // %i7 is the ret address - can be used if saved
49
50      // max # of colors reg coloring  can allocate (NumOfAvailRegs)
51
52      // --- following colors are not available for allocation within this phase
53      // --- but can appear for pre-colored ranges 
54
55      g0, i6, i7,  o6
56
57  
58
59    };
60
61   // max # of colors reg coloring  can allocate
62   static unsigned int const NumOfAvailRegs = g0;
63
64   static unsigned int const StartOfNonVolatileRegs = l0;
65   static unsigned int const StartOfAllRegs = g1;
66   static unsigned int const NumOfAllRegs = o6 + 1; 
67
68
69   static const string  getRegName(const unsigned reg) {
70     assert( reg < NumOfAllRegs );
71     return IntRegNames[reg];
72   }
73
74 };
75
76
77
78 class SparcIntRegClass : public MachineRegClassInfo
79 {
80  public:
81
82   SparcIntRegClass(unsigned ID) 
83     : MachineRegClassInfo(0, 
84                           SparcIntRegOrder::NumOfAvailRegs,
85                           SparcIntRegOrder::NumOfAllRegs)
86     {  }
87
88   void colorIGNode(IGNode * Node, bool IsColorUsedArr[] ) const;
89
90 };
91
92 //-----------------------------------------------------------------------------
93 // Float Register Class
94 //-----------------------------------------------------------------------------
95
96 static string const FloatRegNames[] = 
97   {    
98     "f0",  "f1",  "f2",  "f3",  "f4",  "f5",  "f6",  "f7",  "f8",  "f9", 
99     "f10", "f11", "f12", "f13", "f14", "f15", "f16", "f17", "f18", "f19",
100     "f20", "f21", "f22", "f23", "f24", "f25", "f26", "f27", "f28", "f29",
101     "f30", "f31", "f32", "f33", "f34", "f35", "f36", "f37", "f38", "f39",
102     "f40", "f41", "f42", "f43", "f44", "f45", "f46", "f47", "f48", "f49",
103     "f50", "f51", "f52", "f53", "f54", "f55", "f56", "f57", "f58", "f59",
104     "f60", "f61", "f62", "f63"
105   };
106
107
108 class SparcFloatRegOrder{ 
109
110  public:
111
112   enum RegsInPrefOrder {
113
114     f0, f1, f2, f3, f4, f5, f6, f7, f8, f9, 
115     f10, f11, f12, f13, f14, f15, f16, f17, f18, f19,
116     f20, f21, f22, f23, f24, f25, f26, f27, f28, f29,
117     f30, f31, f32, f33, f34, f35, f36, f37, f38, f39,
118     f40, f41, f42, f43, f44, f45, f46, f47, f48, f49,
119     f50, f51, f52, f53, f54, f55, f56, f57, f58, f59,
120     f60, f61, f62, f63
121
122   };
123
124   // there are 64 regs alltogether but only 32 regs can be allocated at
125   // a time.
126
127   static unsigned int const NumOfAvailRegs = 32;
128   static unsigned int const NumOfAllRegs = 64;
129
130   static unsigned int const StartOfNonVolatileRegs = f6;
131   static unsigned int const StartOfAllRegs = f0;
132
133
134   static const string  getRegName(const unsigned reg) {
135     assert( reg < NumOfAllRegs );
136     return FloatRegNames[reg];
137   }
138
139
140
141 };
142
143
144 class SparcFloatRegClass : public MachineRegClassInfo
145 {
146  private:
147
148   int findFloatColor(const IGNode *const Node, unsigned Start,
149                      unsigned End, bool IsColorUsedArr[] ) const;
150
151  public:
152
153   SparcFloatRegClass(unsigned ID) 
154     : MachineRegClassInfo(1, 
155                           SparcFloatRegOrder::NumOfAvailRegs,
156                           SparcFloatRegOrder::NumOfAllRegs)
157     {  }
158
159   void colorIGNode(IGNode * Node, bool IsColorUsedArr[] ) const;
160
161 };
162
163
164
165 #endif