fix some GCC 4 warnings
[oota-llvm.git] / lib / Target / SparcV9 / SparcV9RegClassInfo.h
1 //===-- SparcV9RegClassInfo.h - Register class def'ns for SparcV9 -*- C++ -*-=//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file was developed by the LLVM research group and is distributed under
6 // the University of Illinois Open Source License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file defines the register classes used by the SparcV9 target. It
11 // implicitly defines (using enums) the "class register numbers" used in
12 // the SparcV9 target, which are converted using a formula in the SparcV9RegInfo
13 // class to "unified register numbers".
14 //
15 //===----------------------------------------------------------------------===//
16
17 #ifndef SPARCV9REGCLASSINFO_H
18 #define SPARCV9REGCLASSINFO_H
19
20 #include "SparcV9RegInfo.h"
21
22 namespace llvm {
23
24 //-----------------------------------------------------------------------------
25 // Integer Register Class
26 //-----------------------------------------------------------------------------
27
28 struct SparcV9IntRegClass : public TargetRegClassInfo {
29   SparcV9IntRegClass(unsigned ID)
30     : TargetRegClassInfo(ID, NumOfAvailRegs, NumOfAllRegs) {  }
31
32   void colorIGNode(IGNode *Node,
33                    const std::vector<bool> &IsColorUsedArr) const;
34
35   inline bool isRegVolatile(int Reg) const {
36     return (Reg < (int)StartOfNonVolatileRegs);
37   }
38
39   inline bool modifiedByCall(int Reg) const {
40     return Reg==(int)ModifiedByCall;
41   }
42
43   enum {   // colors possible for a LR (in preferred order)
44      // --- following colors are volatile across function calls
45      // %g0 can't be used for coloring - always 0
46      o0, o1, o2, o3, o4, o5, o7,  // %o0-%o5,
47
48      // %o6 is sp,
49      // all %0's can get modified by a call
50
51      // --- following colors are NON-volatile across function calls
52      l0, l1, l2, l3, l4, l5, l6, l7,    //  %l0-%l7
53      i0, i1, i2, i3, i4, i5,         // %i0-%i5: i's need not be preserved
54
55      // %i6 is the fp - so not allocated
56      // %i7 is the ret address by convention - can be used for others
57
58      // max # of colors reg coloring  can allocate (NumOfAvailRegs)
59
60      // --- following colors are not available for allocation within this phase
61      // --- but can appear for pre-colored ranges
62
63      i6, i7, g0,  g1, g2, g3, g4, g5, g6, g7, o6,
64
65      NumOfAllRegs,  // Must be first AFTER registers...
66
67      //*** NOTE: If we decide to use some %g regs, they are volatile
68      // (see sparc64ABI)
69      // Move the %g regs from the end of the enumeration to just above the
70      // enumeration of %o0 (change StartOfAllRegs below)
71      // change isRegVloatile method below
72      // Also change IntRegNames above.
73
74      // max # of colors reg coloring  can allocate
75      NumOfAvailRegs = i6,
76
77      StartOfNonVolatileRegs = l0,
78      StartOfAllRegs = o0,
79
80      ModifiedByCall = o7,
81   };
82
83   const char * const getRegName(unsigned reg) const;
84 };
85
86
87 //-----------------------------------------------------------------------------
88 // Float Register Class
89 //-----------------------------------------------------------------------------
90
91 class SparcV9FloatRegClass : public TargetRegClassInfo {
92   int findFloatColor(const LiveRange *LR, unsigned Start,
93                      unsigned End,
94                      const std::vector<bool> &IsColorUsedArr) const;
95 public:
96   SparcV9FloatRegClass(unsigned ID)
97     : TargetRegClassInfo(ID, NumOfAvailRegs, NumOfAllRegs) {}
98
99   // This method marks the registers used for a given register number.
100   // This marks a single register for Float regs, but the R,R+1 pair
101   // for double-precision registers.
102   //
103   virtual void markColorsUsed(unsigned RegInClass,
104                               int UserRegType,
105                               int RegTypeWanted,
106                               std::vector<bool> &IsColorUsedArr) const;
107
108   // This method finds unused registers of the specified register type,
109   // using the given "used" flag array IsColorUsedArr.  It checks a single
110   // entry in the array directly for float regs, and checks the pair [R,R+1]
111   // for double-precision registers
112   // It returns -1 if no unused color is found.
113   //
114   virtual int findUnusedColor(int RegTypeWanted,
115                               const std::vector<bool> &IsColorUsedArr) const;
116
117   void colorIGNode(IGNode *Node,
118                    const std::vector<bool> &IsColorUsedArr) const;
119
120   // according to  SparcV9 64 ABI, all %fp regs are volatile
121   inline bool isRegVolatile(int Reg) const { return true; }
122
123   enum {
124     f0, f1, f2, f3, f4, f5, f6, f7, f8, f9,
125     f10, f11, f12, f13, f14, f15, f16, f17, f18, f19,
126     f20, f21, f22, f23, f24, f25, f26, f27, f28, f29,
127     f30, f31, f32, f33, f34, f35, f36, f37, f38, f39,
128     f40, f41, f42, f43, f44, f45, f46, f47, f48, f49,
129     f50, f51, f52, f53, f54, f55, f56, f57, f58, f59,
130     f60, f61, f62, f63,
131
132     // there are 64 regs alltogether but only 32 regs can be allocated at
133     // a time.
134     //
135     NumOfAvailRegs = 32,
136     NumOfAllRegs = 64,
137
138     StartOfNonVolatileRegs = f32,
139     StartOfAllRegs = f0,
140   };
141
142   const char * const getRegName(unsigned reg) const;
143 };
144
145
146 //-----------------------------------------------------------------------------
147 // Int CC Register Class
148 // Only one integer cc register is available. However, this register is
149 // referred to as %xcc or %icc when instructions like subcc are executed but
150 // referred to as %ccr (i.e., %xcc . %icc") when this register is moved
151 // into an integer register using RD or WR instrcutions. So, three ids are
152 // allocated for the three names.
153 //-----------------------------------------------------------------------------
154
155 struct SparcV9IntCCRegClass : public TargetRegClassInfo {
156   SparcV9IntCCRegClass(unsigned ID)
157     : TargetRegClassInfo(ID, 1, 3) {  }
158
159   void colorIGNode(IGNode *Node,
160                    const std::vector<bool> &IsColorUsedArr) const;
161
162   // according to the 64-bit SparcV9 ABI, all integer CC regs are
163   // volatile.
164   inline bool isRegVolatile(int Reg) const { return true; }
165
166   enum {
167     xcc, icc, ccr   // only one is available - see the note above
168   };
169
170   const char * const getRegName(unsigned reg) const;
171 };
172
173
174 //-----------------------------------------------------------------------------
175 // Float CC Register Class
176 // Only 4 Float CC registers are available for allocation.
177 //-----------------------------------------------------------------------------
178
179 struct SparcV9FloatCCRegClass : public TargetRegClassInfo {
180   SparcV9FloatCCRegClass(unsigned ID)
181     : TargetRegClassInfo(ID, 4, 4) {  }
182
183   void colorIGNode(IGNode *Node,
184                    const std::vector<bool> &IsColorUsedArr) const;
185
186   // according to the 64-bit SparcV9 ABI, all floating-point CC regs are
187   // volatile.
188   inline bool isRegVolatile(int Reg) const { return true; }
189
190   enum {
191     fcc0, fcc1, fcc2, fcc3
192   };
193
194   const char * const getRegName(unsigned reg) const;
195 };
196
197
198 //-----------------------------------------------------------------------------
199 // SparcV9 special register class.  These registers are not used for allocation
200 // but are used as arguments of some instructions.
201 //-----------------------------------------------------------------------------
202
203 struct SparcV9SpecialRegClass : public TargetRegClassInfo {
204   SparcV9SpecialRegClass(unsigned ID)
205     : TargetRegClassInfo(ID, 0, 1) {  }
206
207   void colorIGNode(IGNode *Node,
208                    const std::vector<bool> &IsColorUsedArr) const {
209     assert(0 && "SparcV9SpecialRegClass should never be used for allocation");
210   }
211
212   // all currently included special regs are volatile
213   inline bool isRegVolatile(int Reg) const { return true; }
214
215   enum {
216     fsr                                 // floating point state register
217   };
218
219   const char * const getRegName(unsigned reg) const;
220 };
221
222 } // End llvm namespace
223
224 #endif