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