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