blob: 6248a833237fd0603ff16aea6af90874a332d489 [file] [log] [blame]
Chris Lattner95685682002-08-12 21:25:05 +00001//===-- SparcRegClassInfo.cpp - Register class def'ns for Sparc -----------===//
2//
3// This file defines the register classes used by the Sparc target description.
4//
5//===----------------------------------------------------------------------===//
6
Chris Lattner699683c2002-02-04 05:59:25 +00007#include "SparcRegClassInfo.h"
Vikram S. Adve7dc7de52003-07-25 21:12:15 +00008#include "SparcInternals.h"
Chris Lattner37730942002-02-05 03:52:29 +00009#include "llvm/Type.h"
Chris Lattner0e104332003-01-15 19:50:44 +000010#include "../../CodeGen/RegAlloc/RegAllocCommon.h" // FIXME!
Chris Lattnerbcc6dec2003-09-01 20:00:08 +000011#include "../../CodeGen/RegAlloc/IGNode.h" // FIXME!
Ruchira Sasanka89fb46b2001-09-18 22:52:44 +000012
13//-----------------------------------------------------------------------------
Ruchira Sasankad00982a2002-01-07 19:20:28 +000014// Int Register Class - method for coloring a node in the interference graph.
15//
16// Algorithm:
17// Record the colors/suggested colors of all neighbors.
18//
19// If there is a suggested color, try to allocate it
20// If there is no call interf, try to allocate volatile, then non volatile
21// If there is call interf, try to allocate non-volatile. If that fails
22// try to allocate a volatile and insert save across calls
23// If both above fail, spill.
24//
Ruchira Sasanka89fb46b2001-09-18 22:52:44 +000025//-----------------------------------------------------------------------------
Misha Brukmanee563cb2003-05-21 17:59:06 +000026void SparcIntRegClass::colorIGNode(IGNode * Node,
Vikram S. Adve7dc7de52003-07-25 21:12:15 +000027 const std::vector<bool> &IsColorUsedArr) const
Misha Brukmanee563cb2003-05-21 17:59:06 +000028{
Chris Lattner699683c2002-02-04 05:59:25 +000029 LiveRange *LR = Node->getParentLR();
Ruchira Sasanka89fb46b2001-09-18 22:52:44 +000030
Misha Brukman77c9fcb2003-05-21 18:05:35 +000031 if (DEBUG_RA) {
Misha Brukmanee563cb2003-05-21 17:59:06 +000032 std::cerr << "\nColoring LR [CallInt=" << LR->isCallInterference() <<"]:";
Chris Lattner296b7732002-02-05 02:52:05 +000033 printSet(*LR);
Ruchira Sasanka0f5e9882001-10-19 17:23:43 +000034 }
Ruchira Sasanka89fb46b2001-09-18 22:52:44 +000035
Misha Brukman77c9fcb2003-05-21 18:05:35 +000036 if (LR->hasSuggestedColor()) {
Ruchira Sasanka0f5e9882001-10-19 17:23:43 +000037 unsigned SugCol = LR->getSuggestedColor();
Chris Lattner85c54652002-05-23 15:50:03 +000038 if (!IsColorUsedArr[SugCol]) {
Misha Brukman77c9fcb2003-05-21 18:05:35 +000039 if (LR->isSuggestedColorUsable()) {
Ruchira Sasanka0f5e9882001-10-19 17:23:43 +000040 // if the suggested color is volatile, we should use it only if
41 // there are no call interferences. Otherwise, it will get spilled.
Ruchira Sasanka0f5e9882001-10-19 17:23:43 +000042 if (DEBUG_RA)
Misha Brukmanee563cb2003-05-21 17:59:06 +000043 std::cerr << "\n -Coloring with sug color: " << SugCol;
Ruchira Sasanka0f5e9882001-10-19 17:23:43 +000044
Misha Brukman77c9fcb2003-05-21 18:05:35 +000045 LR->setColor(LR->getSuggestedColor());
Ruchira Sasanka0f5e9882001-10-19 17:23:43 +000046 return;
Misha Brukman77c9fcb2003-05-21 18:05:35 +000047 } else if(DEBUG_RA) {
Misha Brukmanc97a2072003-05-21 19:34:28 +000048 std::cerr << "\n Couldn't alloc Sug col - LR volatile & calls interf";
Ruchira Sasanka0f5e9882001-10-19 17:23:43 +000049 }
Misha Brukman77c9fcb2003-05-21 18:05:35 +000050 } else if (DEBUG_RA) { // can't allocate the suggested col
Misha Brukmanee563cb2003-05-21 17:59:06 +000051 std::cerr << "\n Could NOT allocate the suggested color (already used) ";
52 printSet(*LR); std::cerr << "\n";
Ruchira Sasanka91442282001-09-30 23:16:47 +000053 }
54 }
Ruchira Sasanka89fb46b2001-09-18 22:52:44 +000055
56 unsigned SearchStart; // start pos of color in pref-order
57 bool ColorFound= false; // have we found a color yet?
58
59 //if this Node is between calls
Misha Brukman77c9fcb2003-05-21 18:05:35 +000060 if (! LR->isCallInterference()) {
Ruchira Sasanka89fb46b2001-09-18 22:52:44 +000061 // start with volatiles (we can allocate volatiles safely)
Chris Lattner95685682002-08-12 21:25:05 +000062 SearchStart = SparcIntRegClass::StartOfAllRegs;
Misha Brukman77c9fcb2003-05-21 18:05:35 +000063 } else {
Ruchira Sasanka89fb46b2001-09-18 22:52:44 +000064 // start with non volatiles (no non-volatiles)
Chris Lattner95685682002-08-12 21:25:05 +000065 SearchStart = SparcIntRegClass::StartOfNonVolatileRegs;
Ruchira Sasanka89fb46b2001-09-18 22:52:44 +000066 }
67
68 unsigned c=0; // color
69
70 // find first unused color
Misha Brukman77c9fcb2003-05-21 18:05:35 +000071 for (c=SearchStart; c < SparcIntRegClass::NumOfAvailRegs; c++) {
72 if (!IsColorUsedArr[c]) {
73 ColorFound = true;
74 break;
75 }
Ruchira Sasanka89fb46b2001-09-18 22:52:44 +000076 }
77
Misha Brukman77c9fcb2003-05-21 18:05:35 +000078 if (ColorFound) {
Misha Brukman452db672003-09-23 17:28:11 +000079 LR->setColor(c); // first color found in preferred order
Misha Brukmanee563cb2003-05-21 17:59:06 +000080 if (DEBUG_RA) std::cerr << "\n Colored after first search with col " << c;
Ruchira Sasanka0f5e9882001-10-19 17:23:43 +000081 }
Ruchira Sasanka89fb46b2001-09-18 22:52:44 +000082
83 // if color is not found because of call interference
84 // try even finding a volatile color and insert save across calls
Ruchira Sasankad00982a2002-01-07 19:20:28 +000085 //
Misha Brukman77c9fcb2003-05-21 18:05:35 +000086 else if (LR->isCallInterference()) {
Ruchira Sasanka89fb46b2001-09-18 22:52:44 +000087 // start from 0 - try to find even a volatile this time
Chris Lattner95685682002-08-12 21:25:05 +000088 SearchStart = SparcIntRegClass::StartOfAllRegs;
Ruchira Sasanka89fb46b2001-09-18 22:52:44 +000089
90 // find first unused volatile color
Chris Lattner95685682002-08-12 21:25:05 +000091 for(c=SearchStart; c < SparcIntRegClass::StartOfNonVolatileRegs; c++) {
Misha Brukman77c9fcb2003-05-21 18:05:35 +000092 if (! IsColorUsedArr[c]) {
93 ColorFound = true;
94 break;
95 }
Ruchira Sasanka89fb46b2001-09-18 22:52:44 +000096 }
97
Chris Lattner699683c2002-02-04 05:59:25 +000098 if (ColorFound) {
Misha Brukman77c9fcb2003-05-21 18:05:35 +000099 LR->setColor(c);
100 // get the live range corresponding to live var
101 // since LR span across calls, must save across calls
102 //
103 LR->markForSaveAcrossCalls();
104 if (DEBUG_RA)
105 std::cerr << "\n Colored after SECOND search with col " << c;
Ruchira Sasanka89fb46b2001-09-18 22:52:44 +0000106 }
Ruchira Sasanka89fb46b2001-09-18 22:52:44 +0000107 }
108
Ruchira Sasanka91442282001-09-30 23:16:47 +0000109
Ruchira Sasanka89fb46b2001-09-18 22:52:44 +0000110 // If we couldn't find a color regardless of call interference - i.e., we
111 // don't have either a volatile or non-volatile color left
Ruchira Sasankad00982a2002-01-07 19:20:28 +0000112 //
Chris Lattner699683c2002-02-04 05:59:25 +0000113 if (!ColorFound)
Ruchira Sasanka91442282001-09-30 23:16:47 +0000114 LR->markForSpill(); // no color found - must spill
Ruchira Sasanka89fb46b2001-09-18 22:52:44 +0000115}
116
Vikram S. Adve786833a2003-07-06 20:13:59 +0000117//-----------------------------------------------------------------------------
118// Int CC Register Class - method for coloring a node in the interference graph.
119//
120// Algorithm:
121//
Vikram S. Adveb15f8d42003-07-10 19:42:11 +0000122// If (node has any interferences)
123// /* all interference operations can use only one register! */
Vikram S. Adve786833a2003-07-06 20:13:59 +0000124// mark the LR for spilling
125// else {
126// if (the LR is a 64-bit comparison) use %xcc
127// else /*32-bit or smaller*/ use %icc
128// }
129//
130// Note: The third name (%ccr) is essentially an assembly mnemonic and
131// depends solely on the opcode, so the name can be chosen in EmitAssembly.
132//-----------------------------------------------------------------------------
133void SparcIntCCRegClass::colorIGNode(IGNode *Node,
Vikram S. Adve7dc7de52003-07-25 21:12:15 +0000134 const std::vector<bool> &IsColorUsedArr) const
Vikram S. Adve786833a2003-07-06 20:13:59 +0000135{
Vikram S. Adveb15f8d42003-07-10 19:42:11 +0000136 if (Node->getNumOfNeighbors() > 0)
Vikram S. Adve786833a2003-07-06 20:13:59 +0000137 Node->getParentLR()->markForSpill();
Vikram S. Adveb15f8d42003-07-10 19:42:11 +0000138
139 // Mark the appropriate register in any case (even if it needs to be spilled)
140 // because there is only one possible register, but more importantly, the
141 // spill algorithm cannot find it. In particular, we have to choose
142 // whether to use %xcc or %icc based on type of value compared
143 //
144 const LiveRange* ccLR = Node->getParentLR();
145 const Type* setCCType = (* ccLR->begin())->getType(); // any Value in LR
146 assert(setCCType->isIntegral() || isa<PointerType>(setCCType));
147 int ccReg = ((isa<PointerType>(setCCType) || setCCType == Type::LongTy)
148 ? xcc : icc);
Vikram S. Adve786833a2003-07-06 20:13:59 +0000149
150#ifndef NDEBUG
Vikram S. Adveb15f8d42003-07-10 19:42:11 +0000151 // Let's just make sure values of two different types have not been
152 // coalesced into this LR.
153 for (ValueSet::const_iterator I=ccLR->begin(), E=ccLR->end(); I!=E; ++I) {
154 const Type* ccType = (*I)->getType();
155 assert((ccReg == xcc && (isa<PointerType>(ccType)
156 || ccType == Type::LongTy)) ||
157 (ccReg == icc && ccType->isIntegral() && ccType != Type::LongTy)
158 && "Comparisons needing different intCC regs coalesced in LR!");
159 }
Vikram S. Adve786833a2003-07-06 20:13:59 +0000160#endif
161
Vikram S. Adveb15f8d42003-07-10 19:42:11 +0000162 Node->setColor(ccReg); // only one int cc reg is available
Vikram S. Adve786833a2003-07-06 20:13:59 +0000163}
164
Ruchira Sasanka89fb46b2001-09-18 22:52:44 +0000165
Chris Lattner87d50f02003-09-01 19:56:48 +0000166void SparcFloatCCRegClass::colorIGNode(IGNode *Node,
167 const std::vector<bool> &IsColorUsedArr) const {
168 for(unsigned c = 0; c != 4; ++c)
169 if (!IsColorUsedArr[c]) { // find unused color
170 Node->setColor(c);
171 return;
172 }
173
174 Node->getParentLR()->markForSpill();
175}
176
177
178
Ruchira Sasanka89fb46b2001-09-18 22:52:44 +0000179//-----------------------------------------------------------------------------
Ruchira Sasankad00982a2002-01-07 19:20:28 +0000180// Float Register Class - method for coloring a node in the interference graph.
181//
182// Algorithm:
183//
184// If the LR is a double try to allocate f32 - f63
185// If the above fails or LR is single precision
186// If the LR does not interfere with a call
187// start allocating from f0
188// Else start allocating from f6
189// If a color is still not found because LR interferes with a call
190// Search in f0 - f6. If found mark for spill across calls.
191// If a color is still not fond, mark for spilling
192//
193//----------------------------------------------------------------------------
Chris Lattner85c54652002-05-23 15:50:03 +0000194void SparcFloatRegClass::colorIGNode(IGNode * Node,
Vikram S. Adve7dc7de52003-07-25 21:12:15 +0000195 const std::vector<bool> &IsColorUsedArr) const
Misha Brukmanee563cb2003-05-21 17:59:06 +0000196{
Chris Lattner37730942002-02-05 03:52:29 +0000197 LiveRange *LR = Node->getParentLR();
Ruchira Sasanka89fb46b2001-09-18 22:52:44 +0000198
Vikram S. Adve7dc7de52003-07-25 21:12:15 +0000199#ifndef NDEBUG
200 // Check that the correct colors have been are marked for fp-doubles.
201 //
202 // FIXME: This is old code that is no longer needed. Temporarily converting
203 // it into a big assertion just to check that the replacement logic
204 // (invoking SparcFloatRegClass::markColorsUsed() directly from
205 // RegClass::colorIGNode) works correctly.
206 //
207 // In fact, this entire function should be identical to
208 // SparcIntRegClass::colorIGNode(), and perhaps can be
209 // made into a general case in CodeGen/RegAlloc/RegClass.cpp.
Vikram S. Adve242a8082002-05-19 15:25:51 +0000210 //
211 unsigned NumNeighbors = Node->getNumOfNeighbors(); // total # of neighbors
Ruchira Sasanka89fb46b2001-09-18 22:52:44 +0000212 for(unsigned n=0; n < NumNeighbors; n++) { // for each neigh
213 IGNode *NeighIGNode = Node->getAdjIGNode(n);
Ruchira Sasanka91442282001-09-30 23:16:47 +0000214 LiveRange *NeighLR = NeighIGNode->getParentLR();
Vikram S. Adve242a8082002-05-19 15:25:51 +0000215
Vikram S. Adve4d436c12003-09-21 07:55:27 +0000216 if (NeighLR->hasColor()) {
217 assert(IsColorUsedArr[ NeighLR->getColor() ]);
218 if (NeighLR->getType() == Type::DoubleTy)
219 assert(IsColorUsedArr[ NeighLR->getColor()+1 ]);
Vikram S. Adve242a8082002-05-19 15:25:51 +0000220
221 } else if (NeighLR->hasSuggestedColor() &&
222 NeighLR-> isSuggestedColorUsable() ) {
Ruchira Sasanka91442282001-09-30 23:16:47 +0000223
Misha Brukman77c9fcb2003-05-21 18:05:35 +0000224 // if the neighbour can use the suggested color
Vikram S. Adve7dc7de52003-07-25 21:12:15 +0000225 assert(IsColorUsedArr[ NeighLR->getSuggestedColor() ]);
Misha Brukman77c9fcb2003-05-21 18:05:35 +0000226 if (NeighLR->getType() == Type::DoubleTy)
Vikram S. Adve7dc7de52003-07-25 21:12:15 +0000227 assert(IsColorUsedArr[ NeighLR->getSuggestedColor()+1 ]);
Vikram S. Adve242a8082002-05-19 15:25:51 +0000228 }
Ruchira Sasanka91442282001-09-30 23:16:47 +0000229 }
Vikram S. Adve7dc7de52003-07-25 21:12:15 +0000230#endif
Ruchira Sasanka91442282001-09-30 23:16:47 +0000231
Ruchira Sasanka0f5e9882001-10-19 17:23:43 +0000232 // **NOTE: We don't check for call interferences in allocating suggested
233 // color in this class since ALL registers are volatile. If this fact
234 // changes, we should change the following part
235 //- see SparcIntRegClass::colorIGNode()
Vikram S. Adve242a8082002-05-19 15:25:51 +0000236 //
Ruchira Sasanka91442282001-09-30 23:16:47 +0000237 if( LR->hasSuggestedColor() ) {
238 if( ! IsColorUsedArr[ LR->getSuggestedColor() ] ) {
239 LR->setColor( LR->getSuggestedColor() );
240 return;
Chris Lattner296b7732002-02-05 02:52:05 +0000241 } else if (DEBUG_RA) { // can't allocate the suggested col
Misha Brukmanee563cb2003-05-21 17:59:06 +0000242 std::cerr << " Could NOT allocate the suggested color for LR ";
243 printSet(*LR); std::cerr << "\n";
Ruchira Sasanka89fb46b2001-09-18 22:52:44 +0000244 }
245 }
246
Ruchira Sasanka91442282001-09-30 23:16:47 +0000247
Ruchira Sasanka89fb46b2001-09-18 22:52:44 +0000248 int ColorFound = -1; // have we found a color yet?
Ruchira Sasanka0f5e9882001-10-19 17:23:43 +0000249 bool isCallInterf = LR->isCallInterference();
Ruchira Sasanka89fb46b2001-09-18 22:52:44 +0000250
Chris Lattner85c54652002-05-23 15:50:03 +0000251 // if value is a double - search the double only region (f32 - f63)
Ruchira Sasankad00982a2002-01-07 19:20:28 +0000252 // i.e. we try to allocate f32 - f63 first for doubles since singles
253 // cannot go there. By doing that, we provide more space for singles
254 // in f0 - f31
255 //
Chris Lattner37730942002-02-05 03:52:29 +0000256 if (LR->getType() == Type::DoubleTy)
Ruchira Sasanka91442282001-09-30 23:16:47 +0000257 ColorFound = findFloatColor( LR, 32, 64, IsColorUsedArr );
Ruchira Sasanka89fb46b2001-09-18 22:52:44 +0000258
Misha Brukman77c9fcb2003-05-21 18:05:35 +0000259 if (ColorFound >= 0) { // if we could find a color
Ruchira Sasanka91442282001-09-30 23:16:47 +0000260 LR->setColor(ColorFound);
Ruchira Sasanka89fb46b2001-09-18 22:52:44 +0000261 return;
Chris Lattner699683c2002-02-04 05:59:25 +0000262 } else {
Ruchira Sasanka89fb46b2001-09-18 22:52:44 +0000263
Misha Brukmancf00c4a2003-10-10 17:57:28 +0000264 // if we didn't find a color because the LR was single precision or
Ruchira Sasankad00982a2002-01-07 19:20:28 +0000265 // all f32-f63 range is filled, we try to allocate a register from
266 // the f0 - f31 region
Ruchira Sasanka89fb46b2001-09-18 22:52:44 +0000267
268 unsigned SearchStart; // start pos of color in pref-order
269
270 //if this Node is between calls (i.e., no call interferences )
Misha Brukman77c9fcb2003-05-21 18:05:35 +0000271 if (! isCallInterf) {
Ruchira Sasanka89fb46b2001-09-18 22:52:44 +0000272 // start with volatiles (we can allocate volatiles safely)
Chris Lattner95685682002-08-12 21:25:05 +0000273 SearchStart = SparcFloatRegClass::StartOfAllRegs;
Misha Brukman77c9fcb2003-05-21 18:05:35 +0000274 } else {
Ruchira Sasanka89fb46b2001-09-18 22:52:44 +0000275 // start with non volatiles (no non-volatiles)
Chris Lattner95685682002-08-12 21:25:05 +0000276 SearchStart = SparcFloatRegClass::StartOfNonVolatileRegs;
Ruchira Sasanka89fb46b2001-09-18 22:52:44 +0000277 }
278
Misha Brukman77c9fcb2003-05-21 18:05:35 +0000279 ColorFound = findFloatColor(LR, SearchStart, 32, IsColorUsedArr);
Ruchira Sasanka89fb46b2001-09-18 22:52:44 +0000280 }
281
Misha Brukman77c9fcb2003-05-21 18:05:35 +0000282 if (ColorFound >= 0) { // if we could find a color
Ruchira Sasanka91442282001-09-30 23:16:47 +0000283 LR->setColor(ColorFound);
Ruchira Sasanka89fb46b2001-09-18 22:52:44 +0000284 return;
Misha Brukman77c9fcb2003-05-21 18:05:35 +0000285 } else if (isCallInterf) {
Ruchira Sasanka89fb46b2001-09-18 22:52:44 +0000286 // We are here because there is a call interference and no non-volatile
287 // color could be found.
288 // Now try to allocate even a volatile color
Misha Brukman77c9fcb2003-05-21 18:05:35 +0000289 ColorFound = findFloatColor(LR, SparcFloatRegClass::StartOfAllRegs,
Chris Lattner95685682002-08-12 21:25:05 +0000290 SparcFloatRegClass::StartOfNonVolatileRegs,
Ruchira Sasanka89fb46b2001-09-18 22:52:44 +0000291 IsColorUsedArr);
292 }
293
Misha Brukman77c9fcb2003-05-21 18:05:35 +0000294 if (ColorFound >= 0) {
Misha Brukmancf00c4a2003-10-10 17:57:28 +0000295 LR->setColor(ColorFound); // first color found in preferred order
Ruchira Sasanka91442282001-09-30 23:16:47 +0000296 LR->markForSaveAcrossCalls();
Chris Lattner699683c2002-02-04 05:59:25 +0000297 } else {
298 // we are here because no color could be found
299 LR->markForSpill(); // no color found - must spill
Ruchira Sasanka89fb46b2001-09-18 22:52:44 +0000300 }
Ruchira Sasanka89fb46b2001-09-18 22:52:44 +0000301}
302
Vikram S. Adve7dc7de52003-07-25 21:12:15 +0000303//-----------------------------------------------------------------------------
304// This method marks the registers used for a given register number.
305// This marks a single register for Float regs, but the R,R+1 pair
306// for double-precision registers.
307//-----------------------------------------------------------------------------
308
309void SparcFloatRegClass::markColorsUsed(unsigned RegInClass,
310 int UserRegType,
311 int RegTypeWanted,
312 std::vector<bool> &IsColorUsedArr) const
313{
314 if (UserRegType == UltraSparcRegInfo::FPDoubleRegType ||
315 RegTypeWanted == UltraSparcRegInfo::FPDoubleRegType) {
316 // This register is used as or is needed as a double-precision reg.
317 // We need to mark the [even,odd] pair corresponding to this reg.
318 // Get the even numbered register corresponding to this reg.
319 unsigned EvenRegInClass = RegInClass & ~1u;
320 assert(EvenRegInClass+1 < NumOfAllRegs &&
321 EvenRegInClass+1 < IsColorUsedArr.size());
322 IsColorUsedArr[EvenRegInClass] = true;
323 IsColorUsedArr[EvenRegInClass+1] = true;
324 }
325 else {
326 assert(RegInClass < NumOfAllRegs && RegInClass < IsColorUsedArr.size());
327 assert(UserRegType == RegTypeWanted
328 && "Something other than FP single/double types share a reg class?");
329 IsColorUsedArr[RegInClass] = true;
330 }
331}
332
333// This method finds unused registers of the specified register type,
334// using the given "used" flag array IsColorUsedArr. It checks a single
335// entry in the array directly for float regs, and checks the pair [R,R+1]
336// for double-precision registers
337// It returns -1 if no unused color is found.
338//
339int SparcFloatRegClass::findUnusedColor(int RegTypeWanted,
340 const std::vector<bool> &IsColorUsedArr) const
341{
342 if (RegTypeWanted == UltraSparcRegInfo::FPDoubleRegType) {
343 unsigned NC = 2 * this->getNumOfAvailRegs();
344 assert(IsColorUsedArr.size() == NC && "Invalid colors-used array");
345 for (unsigned c = 0; c < NC; c+=2)
346 if (!IsColorUsedArr[c]) {
347 assert(!IsColorUsedArr[c+1] && "Incorrect used regs for FP double!");
348 return c;
349 }
350 return -1;
351 }
352 else
353 return TargetRegClassInfo::findUnusedColor(RegTypeWanted, IsColorUsedArr);
354}
Ruchira Sasanka89fb46b2001-09-18 22:52:44 +0000355
Ruchira Sasankad00982a2002-01-07 19:20:28 +0000356//-----------------------------------------------------------------------------
357// Helper method for coloring a node of Float Reg class.
358// Finds the first available color in the range [Start,End] depending on the
359// type of the Node (i.e., float/double)
360//-----------------------------------------------------------------------------
Ruchira Sasankad00982a2002-01-07 19:20:28 +0000361
Misha Brukman77c9fcb2003-05-21 18:05:35 +0000362int SparcFloatRegClass::findFloatColor(const LiveRange *LR,
363 unsigned Start,
364 unsigned End,
Vikram S. Adve7dc7de52003-07-25 21:12:15 +0000365 const std::vector<bool> &IsColorUsedArr) const
Misha Brukmanee563cb2003-05-21 17:59:06 +0000366{
Chris Lattner37730942002-02-05 03:52:29 +0000367 if (LR->getType() == Type::DoubleTy) {
Ruchira Sasankad00982a2002-01-07 19:20:28 +0000368 // find first unused color for a double
Vikram S. Adve7dc7de52003-07-25 21:12:15 +0000369 assert(Start % 2 == 0 && "Odd register number could be used for double!");
370 for (unsigned c=Start; c < End ; c+= 2)
371 if (!IsColorUsedArr[c]) {
372 assert(!IsColorUsedArr[c+1] &&
373 "Incorrect marking of used regs for Sparc FP double!");
Chris Lattner699683c2002-02-04 05:59:25 +0000374 return c;
Vikram S. Adve7dc7de52003-07-25 21:12:15 +0000375 }
Ruchira Sasankad00982a2002-01-07 19:20:28 +0000376 } else {
Ruchira Sasankad00982a2002-01-07 19:20:28 +0000377 // find first unused color for a single
Vikram S. Adve7dc7de52003-07-25 21:12:15 +0000378 for (unsigned c = Start; c < End; c++)
Chris Lattner699683c2002-02-04 05:59:25 +0000379 if (!IsColorUsedArr[c])
380 return c;
Ruchira Sasankad00982a2002-01-07 19:20:28 +0000381 }
Vikram S. Adve7dc7de52003-07-25 21:12:15 +0000382
Chris Lattner699683c2002-02-04 05:59:25 +0000383 return -1;
Vikram S. Adve7dc7de52003-07-25 21:12:15 +0000384
Ruchira Sasankad00982a2002-01-07 19:20:28 +0000385}