2004-04-25 07:04:49 +00:00
|
|
|
//===-- SparcV9RegClassInfo.cpp - Register class def'ns for SparcV9 -------===//
|
2003-10-20 19:43:21 +00:00
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file was developed by the LLVM research group and is distributed under
|
|
|
|
// the University of Illinois Open Source License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
2002-08-12 21:25:05 +00:00
|
|
|
//
|
2004-04-25 07:04:49 +00:00
|
|
|
// This file defines the methods used by the SparcV9 register allocator
|
|
|
|
// to pick registers of various classes. Most of this code should be
|
|
|
|
// considered part of the register allocator.
|
2002-08-12 21:25:05 +00:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2003-12-17 22:04:00 +00:00
|
|
|
#include "llvm/Type.h"
|
2004-02-25 18:44:15 +00:00
|
|
|
#include "SparcV9RegClassInfo.h"
|
|
|
|
#include "SparcV9Internals.h"
|
|
|
|
#include "SparcV9RegInfo.h"
|
2004-01-09 16:17:09 +00:00
|
|
|
#include "RegAlloc/RegAllocCommon.h"
|
|
|
|
#include "RegAlloc/IGNode.h"
|
2004-07-04 12:19:56 +00:00
|
|
|
#include <iostream>
|
2001-09-18 22:52:44 +00:00
|
|
|
|
2003-11-11 22:41:34 +00:00
|
|
|
namespace llvm {
|
|
|
|
|
2001-09-18 22:52:44 +00:00
|
|
|
//-----------------------------------------------------------------------------
|
2002-01-07 19:20:28 +00:00
|
|
|
// Int Register Class - method for coloring a node in the interference graph.
|
|
|
|
//
|
|
|
|
// Algorithm:
|
|
|
|
// Record the colors/suggested colors of all neighbors.
|
|
|
|
//
|
|
|
|
// If there is a suggested color, try to allocate it
|
|
|
|
// If there is no call interf, try to allocate volatile, then non volatile
|
|
|
|
// If there is call interf, try to allocate non-volatile. If that fails
|
|
|
|
// try to allocate a volatile and insert save across calls
|
|
|
|
// If both above fail, spill.
|
|
|
|
//
|
2001-09-18 22:52:44 +00:00
|
|
|
//-----------------------------------------------------------------------------
|
2004-02-25 18:44:15 +00:00
|
|
|
void SparcV9IntRegClass::colorIGNode(IGNode * Node,
|
2003-07-25 21:12:15 +00:00
|
|
|
const std::vector<bool> &IsColorUsedArr) const
|
2003-05-21 17:59:06 +00:00
|
|
|
{
|
2002-02-04 05:59:25 +00:00
|
|
|
LiveRange *LR = Node->getParentLR();
|
2001-09-18 22:52:44 +00:00
|
|
|
|
2004-07-29 06:43:08 +00:00
|
|
|
if (DEBUG_RA)
|
|
|
|
std::cerr << "\nColoring LR [CallInt=" << LR->isCallInterference() <<"]:"
|
|
|
|
<< *LR << "\n";
|
2001-09-18 22:52:44 +00:00
|
|
|
|
2003-05-21 18:05:35 +00:00
|
|
|
if (LR->hasSuggestedColor()) {
|
2001-10-19 17:23:43 +00:00
|
|
|
unsigned SugCol = LR->getSuggestedColor();
|
2002-05-23 15:50:03 +00:00
|
|
|
if (!IsColorUsedArr[SugCol]) {
|
2003-05-21 18:05:35 +00:00
|
|
|
if (LR->isSuggestedColorUsable()) {
|
2001-10-19 17:23:43 +00:00
|
|
|
// if the suggested color is volatile, we should use it only if
|
|
|
|
// there are no call interferences. Otherwise, it will get spilled.
|
|
|
|
if (DEBUG_RA)
|
2003-05-21 17:59:06 +00:00
|
|
|
std::cerr << "\n -Coloring with sug color: " << SugCol;
|
2001-10-19 17:23:43 +00:00
|
|
|
|
2003-05-21 18:05:35 +00:00
|
|
|
LR->setColor(LR->getSuggestedColor());
|
2001-10-19 17:23:43 +00:00
|
|
|
return;
|
2003-05-21 18:05:35 +00:00
|
|
|
} else if(DEBUG_RA) {
|
2003-05-21 19:34:28 +00:00
|
|
|
std::cerr << "\n Couldn't alloc Sug col - LR volatile & calls interf";
|
2001-10-19 17:23:43 +00:00
|
|
|
}
|
2003-05-21 18:05:35 +00:00
|
|
|
} else if (DEBUG_RA) { // can't allocate the suggested col
|
2004-07-29 06:43:08 +00:00
|
|
|
std::cerr << "\n Could NOT allocate the suggested color (already used) "
|
|
|
|
<< *LR << "\n";
|
2001-09-30 23:16:47 +00:00
|
|
|
}
|
|
|
|
}
|
2001-09-18 22:52:44 +00:00
|
|
|
|
|
|
|
unsigned SearchStart; // start pos of color in pref-order
|
|
|
|
bool ColorFound= false; // have we found a color yet?
|
|
|
|
|
|
|
|
//if this Node is between calls
|
2003-05-21 18:05:35 +00:00
|
|
|
if (! LR->isCallInterference()) {
|
2001-09-18 22:52:44 +00:00
|
|
|
// start with volatiles (we can allocate volatiles safely)
|
2004-02-25 18:44:15 +00:00
|
|
|
SearchStart = SparcV9IntRegClass::StartOfAllRegs;
|
2003-05-21 18:05:35 +00:00
|
|
|
} else {
|
2001-09-18 22:52:44 +00:00
|
|
|
// start with non volatiles (no non-volatiles)
|
2004-02-25 18:44:15 +00:00
|
|
|
SearchStart = SparcV9IntRegClass::StartOfNonVolatileRegs;
|
2001-09-18 22:52:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
unsigned c=0; // color
|
|
|
|
|
|
|
|
// find first unused color
|
2004-02-25 18:44:15 +00:00
|
|
|
for (c=SearchStart; c < SparcV9IntRegClass::NumOfAvailRegs; c++) {
|
2003-05-21 18:05:35 +00:00
|
|
|
if (!IsColorUsedArr[c]) {
|
|
|
|
ColorFound = true;
|
|
|
|
break;
|
|
|
|
}
|
2001-09-18 22:52:44 +00:00
|
|
|
}
|
|
|
|
|
2003-05-21 18:05:35 +00:00
|
|
|
if (ColorFound) {
|
2003-09-23 17:28:11 +00:00
|
|
|
LR->setColor(c); // first color found in preferred order
|
2003-05-21 17:59:06 +00:00
|
|
|
if (DEBUG_RA) std::cerr << "\n Colored after first search with col " << c;
|
2001-10-19 17:23:43 +00:00
|
|
|
}
|
2001-09-18 22:52:44 +00:00
|
|
|
|
|
|
|
// if color is not found because of call interference
|
|
|
|
// try even finding a volatile color and insert save across calls
|
2002-01-07 19:20:28 +00:00
|
|
|
//
|
2003-05-21 18:05:35 +00:00
|
|
|
else if (LR->isCallInterference()) {
|
2001-09-18 22:52:44 +00:00
|
|
|
// start from 0 - try to find even a volatile this time
|
2004-02-25 18:44:15 +00:00
|
|
|
SearchStart = SparcV9IntRegClass::StartOfAllRegs;
|
2001-09-18 22:52:44 +00:00
|
|
|
|
|
|
|
// find first unused volatile color
|
2004-02-25 18:44:15 +00:00
|
|
|
for(c=SearchStart; c < SparcV9IntRegClass::StartOfNonVolatileRegs; c++) {
|
2003-05-21 18:05:35 +00:00
|
|
|
if (! IsColorUsedArr[c]) {
|
|
|
|
ColorFound = true;
|
|
|
|
break;
|
|
|
|
}
|
2001-09-18 22:52:44 +00:00
|
|
|
}
|
|
|
|
|
2002-02-04 05:59:25 +00:00
|
|
|
if (ColorFound) {
|
2003-05-21 18:05:35 +00:00
|
|
|
LR->setColor(c);
|
|
|
|
// get the live range corresponding to live var
|
|
|
|
// since LR span across calls, must save across calls
|
|
|
|
//
|
|
|
|
if (DEBUG_RA)
|
|
|
|
std::cerr << "\n Colored after SECOND search with col " << c;
|
2001-09-18 22:52:44 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-09-30 23:16:47 +00:00
|
|
|
|
2001-09-18 22:52:44 +00:00
|
|
|
// If we couldn't find a color regardless of call interference - i.e., we
|
|
|
|
// don't have either a volatile or non-volatile color left
|
2002-01-07 19:20:28 +00:00
|
|
|
//
|
2002-02-04 05:59:25 +00:00
|
|
|
if (!ColorFound)
|
2001-09-30 23:16:47 +00:00
|
|
|
LR->markForSpill(); // no color found - must spill
|
2001-09-18 22:52:44 +00:00
|
|
|
}
|
|
|
|
|
2003-07-06 20:13:59 +00:00
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// Int CC Register Class - method for coloring a node in the interference graph.
|
|
|
|
//
|
|
|
|
// Algorithm:
|
|
|
|
//
|
2003-07-10 19:42:11 +00:00
|
|
|
// If (node has any interferences)
|
|
|
|
// /* all interference operations can use only one register! */
|
2003-07-06 20:13:59 +00:00
|
|
|
// mark the LR for spilling
|
|
|
|
// else {
|
|
|
|
// if (the LR is a 64-bit comparison) use %xcc
|
|
|
|
// else /*32-bit or smaller*/ use %icc
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
// Note: The third name (%ccr) is essentially an assembly mnemonic and
|
|
|
|
// depends solely on the opcode, so the name can be chosen in EmitAssembly.
|
|
|
|
//-----------------------------------------------------------------------------
|
2004-02-25 18:44:15 +00:00
|
|
|
void SparcV9IntCCRegClass::colorIGNode(IGNode *Node,
|
2003-07-25 21:12:15 +00:00
|
|
|
const std::vector<bool> &IsColorUsedArr) const
|
2003-07-06 20:13:59 +00:00
|
|
|
{
|
2003-07-10 19:42:11 +00:00
|
|
|
if (Node->getNumOfNeighbors() > 0)
|
2003-07-06 20:13:59 +00:00
|
|
|
Node->getParentLR()->markForSpill();
|
2003-07-10 19:42:11 +00:00
|
|
|
|
|
|
|
// Mark the appropriate register in any case (even if it needs to be spilled)
|
|
|
|
// because there is only one possible register, but more importantly, the
|
|
|
|
// spill algorithm cannot find it. In particular, we have to choose
|
|
|
|
// whether to use %xcc or %icc based on type of value compared
|
|
|
|
//
|
|
|
|
const LiveRange* ccLR = Node->getParentLR();
|
|
|
|
const Type* setCCType = (* ccLR->begin())->getType(); // any Value in LR
|
|
|
|
assert(setCCType->isIntegral() || isa<PointerType>(setCCType));
|
|
|
|
int ccReg = ((isa<PointerType>(setCCType) || setCCType == Type::LongTy)
|
|
|
|
? xcc : icc);
|
2003-07-06 20:13:59 +00:00
|
|
|
|
|
|
|
#ifndef NDEBUG
|
2003-07-10 19:42:11 +00:00
|
|
|
// Let's just make sure values of two different types have not been
|
|
|
|
// coalesced into this LR.
|
2004-07-29 06:43:08 +00:00
|
|
|
for (LiveRange::const_iterator I=ccLR->begin(), E=ccLR->end(); I!=E; ++I) {
|
2003-07-10 19:42:11 +00:00
|
|
|
const Type* ccType = (*I)->getType();
|
|
|
|
assert((ccReg == xcc && (isa<PointerType>(ccType)
|
|
|
|
|| ccType == Type::LongTy)) ||
|
|
|
|
(ccReg == icc && ccType->isIntegral() && ccType != Type::LongTy)
|
|
|
|
&& "Comparisons needing different intCC regs coalesced in LR!");
|
|
|
|
}
|
2003-07-06 20:13:59 +00:00
|
|
|
#endif
|
|
|
|
|
2003-07-10 19:42:11 +00:00
|
|
|
Node->setColor(ccReg); // only one int cc reg is available
|
2003-07-06 20:13:59 +00:00
|
|
|
}
|
|
|
|
|
2001-09-18 22:52:44 +00:00
|
|
|
|
2004-02-25 18:44:15 +00:00
|
|
|
void SparcV9FloatCCRegClass::colorIGNode(IGNode *Node,
|
2003-09-01 19:56:48 +00:00
|
|
|
const std::vector<bool> &IsColorUsedArr) const {
|
|
|
|
for(unsigned c = 0; c != 4; ++c)
|
|
|
|
if (!IsColorUsedArr[c]) { // find unused color
|
|
|
|
Node->setColor(c);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
Node->getParentLR()->markForSpill();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2001-09-18 22:52:44 +00:00
|
|
|
//-----------------------------------------------------------------------------
|
2002-01-07 19:20:28 +00:00
|
|
|
// Float Register Class - method for coloring a node in the interference graph.
|
|
|
|
//
|
|
|
|
// Algorithm:
|
|
|
|
//
|
|
|
|
// If the LR is a double try to allocate f32 - f63
|
|
|
|
// If the above fails or LR is single precision
|
|
|
|
// If the LR does not interfere with a call
|
|
|
|
// start allocating from f0
|
|
|
|
// Else start allocating from f6
|
|
|
|
// If a color is still not found because LR interferes with a call
|
|
|
|
// Search in f0 - f6. If found mark for spill across calls.
|
|
|
|
// If a color is still not fond, mark for spilling
|
|
|
|
//
|
|
|
|
//----------------------------------------------------------------------------
|
2004-02-25 18:44:15 +00:00
|
|
|
void SparcV9FloatRegClass::colorIGNode(IGNode * Node,
|
2003-07-25 21:12:15 +00:00
|
|
|
const std::vector<bool> &IsColorUsedArr) const
|
2003-05-21 17:59:06 +00:00
|
|
|
{
|
2002-02-05 03:52:29 +00:00
|
|
|
LiveRange *LR = Node->getParentLR();
|
2001-09-18 22:52:44 +00:00
|
|
|
|
2003-07-25 21:12:15 +00:00
|
|
|
#ifndef NDEBUG
|
|
|
|
// Check that the correct colors have been are marked for fp-doubles.
|
|
|
|
//
|
|
|
|
// FIXME: This is old code that is no longer needed. Temporarily converting
|
|
|
|
// it into a big assertion just to check that the replacement logic
|
2004-02-25 18:44:15 +00:00
|
|
|
// (invoking SparcV9FloatRegClass::markColorsUsed() directly from
|
2003-07-25 21:12:15 +00:00
|
|
|
// RegClass::colorIGNode) works correctly.
|
|
|
|
//
|
|
|
|
// In fact, this entire function should be identical to
|
2004-02-25 18:44:15 +00:00
|
|
|
// SparcV9IntRegClass::colorIGNode(), and perhaps can be
|
2003-07-25 21:12:15 +00:00
|
|
|
// made into a general case in CodeGen/RegAlloc/RegClass.cpp.
|
2002-05-19 15:25:51 +00:00
|
|
|
//
|
|
|
|
unsigned NumNeighbors = Node->getNumOfNeighbors(); // total # of neighbors
|
2001-09-18 22:52:44 +00:00
|
|
|
for(unsigned n=0; n < NumNeighbors; n++) { // for each neigh
|
|
|
|
IGNode *NeighIGNode = Node->getAdjIGNode(n);
|
2001-09-30 23:16:47 +00:00
|
|
|
LiveRange *NeighLR = NeighIGNode->getParentLR();
|
2002-05-19 15:25:51 +00:00
|
|
|
|
2003-09-21 07:55:27 +00:00
|
|
|
if (NeighLR->hasColor()) {
|
|
|
|
assert(IsColorUsedArr[ NeighLR->getColor() ]);
|
|
|
|
if (NeighLR->getType() == Type::DoubleTy)
|
|
|
|
assert(IsColorUsedArr[ NeighLR->getColor()+1 ]);
|
2002-05-19 15:25:51 +00:00
|
|
|
|
|
|
|
} else if (NeighLR->hasSuggestedColor() &&
|
|
|
|
NeighLR-> isSuggestedColorUsable() ) {
|
|
|
|
|
2003-05-21 18:05:35 +00:00
|
|
|
// if the neighbour can use the suggested color
|
2003-07-25 21:12:15 +00:00
|
|
|
assert(IsColorUsedArr[ NeighLR->getSuggestedColor() ]);
|
2003-05-21 18:05:35 +00:00
|
|
|
if (NeighLR->getType() == Type::DoubleTy)
|
2003-07-25 21:12:15 +00:00
|
|
|
assert(IsColorUsedArr[ NeighLR->getSuggestedColor()+1 ]);
|
2002-05-19 15:25:51 +00:00
|
|
|
}
|
2001-09-30 23:16:47 +00:00
|
|
|
}
|
2003-07-25 21:12:15 +00:00
|
|
|
#endif
|
2001-09-30 23:16:47 +00:00
|
|
|
|
2001-10-19 17:23:43 +00:00
|
|
|
// **NOTE: We don't check for call interferences in allocating suggested
|
|
|
|
// color in this class since ALL registers are volatile. If this fact
|
|
|
|
// changes, we should change the following part
|
2004-02-25 18:44:15 +00:00
|
|
|
//- see SparcV9IntRegClass::colorIGNode()
|
2002-05-19 15:25:51 +00:00
|
|
|
//
|
2001-09-30 23:16:47 +00:00
|
|
|
if( LR->hasSuggestedColor() ) {
|
|
|
|
if( ! IsColorUsedArr[ LR->getSuggestedColor() ] ) {
|
|
|
|
LR->setColor( LR->getSuggestedColor() );
|
|
|
|
return;
|
2002-02-05 02:52:05 +00:00
|
|
|
} else if (DEBUG_RA) { // can't allocate the suggested col
|
2004-07-29 06:43:08 +00:00
|
|
|
std::cerr << " Could NOT allocate the suggested color for LR " << *LR
|
|
|
|
<< "\n";
|
2001-09-18 22:52:44 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-09-30 23:16:47 +00:00
|
|
|
|
2001-09-18 22:52:44 +00:00
|
|
|
int ColorFound = -1; // have we found a color yet?
|
2001-10-19 17:23:43 +00:00
|
|
|
bool isCallInterf = LR->isCallInterference();
|
2001-09-18 22:52:44 +00:00
|
|
|
|
2002-05-23 15:50:03 +00:00
|
|
|
// if value is a double - search the double only region (f32 - f63)
|
2002-01-07 19:20:28 +00:00
|
|
|
// i.e. we try to allocate f32 - f63 first for doubles since singles
|
|
|
|
// cannot go there. By doing that, we provide more space for singles
|
|
|
|
// in f0 - f31
|
|
|
|
//
|
2002-02-05 03:52:29 +00:00
|
|
|
if (LR->getType() == Type::DoubleTy)
|
2001-09-30 23:16:47 +00:00
|
|
|
ColorFound = findFloatColor( LR, 32, 64, IsColorUsedArr );
|
2001-09-18 22:52:44 +00:00
|
|
|
|
2003-05-21 18:05:35 +00:00
|
|
|
if (ColorFound >= 0) { // if we could find a color
|
2001-09-30 23:16:47 +00:00
|
|
|
LR->setColor(ColorFound);
|
2001-09-18 22:52:44 +00:00
|
|
|
return;
|
2002-02-04 05:59:25 +00:00
|
|
|
} else {
|
2001-09-18 22:52:44 +00:00
|
|
|
|
2003-10-10 17:57:28 +00:00
|
|
|
// if we didn't find a color because the LR was single precision or
|
2002-01-07 19:20:28 +00:00
|
|
|
// all f32-f63 range is filled, we try to allocate a register from
|
|
|
|
// the f0 - f31 region
|
2001-09-18 22:52:44 +00:00
|
|
|
|
|
|
|
unsigned SearchStart; // start pos of color in pref-order
|
|
|
|
|
|
|
|
//if this Node is between calls (i.e., no call interferences )
|
2003-05-21 18:05:35 +00:00
|
|
|
if (! isCallInterf) {
|
2001-09-18 22:52:44 +00:00
|
|
|
// start with volatiles (we can allocate volatiles safely)
|
2004-02-25 18:44:15 +00:00
|
|
|
SearchStart = SparcV9FloatRegClass::StartOfAllRegs;
|
2003-05-21 18:05:35 +00:00
|
|
|
} else {
|
2001-09-18 22:52:44 +00:00
|
|
|
// start with non volatiles (no non-volatiles)
|
2004-02-25 18:44:15 +00:00
|
|
|
SearchStart = SparcV9FloatRegClass::StartOfNonVolatileRegs;
|
2001-09-18 22:52:44 +00:00
|
|
|
}
|
|
|
|
|
2003-05-21 18:05:35 +00:00
|
|
|
ColorFound = findFloatColor(LR, SearchStart, 32, IsColorUsedArr);
|
2001-09-18 22:52:44 +00:00
|
|
|
}
|
|
|
|
|
2003-05-21 18:05:35 +00:00
|
|
|
if (ColorFound >= 0) { // if we could find a color
|
2001-09-30 23:16:47 +00:00
|
|
|
LR->setColor(ColorFound);
|
2001-09-18 22:52:44 +00:00
|
|
|
return;
|
2003-05-21 18:05:35 +00:00
|
|
|
} else if (isCallInterf) {
|
2001-09-18 22:52:44 +00:00
|
|
|
// We are here because there is a call interference and no non-volatile
|
|
|
|
// color could be found.
|
|
|
|
// Now try to allocate even a volatile color
|
2004-02-25 18:44:15 +00:00
|
|
|
ColorFound = findFloatColor(LR, SparcV9FloatRegClass::StartOfAllRegs,
|
|
|
|
SparcV9FloatRegClass::StartOfNonVolatileRegs,
|
2001-09-18 22:52:44 +00:00
|
|
|
IsColorUsedArr);
|
|
|
|
}
|
|
|
|
|
2003-05-21 18:05:35 +00:00
|
|
|
if (ColorFound >= 0) {
|
2003-10-10 17:57:28 +00:00
|
|
|
LR->setColor(ColorFound); // first color found in preferred order
|
2002-02-04 05:59:25 +00:00
|
|
|
} else {
|
|
|
|
// we are here because no color could be found
|
|
|
|
LR->markForSpill(); // no color found - must spill
|
2001-09-18 22:52:44 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-07-25 21:12:15 +00:00
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// This method marks the registers used for a given register number.
|
|
|
|
// This marks a single register for Float regs, but the R,R+1 pair
|
|
|
|
// for double-precision registers.
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
2004-02-25 18:44:15 +00:00
|
|
|
void SparcV9FloatRegClass::markColorsUsed(unsigned RegInClass,
|
2003-07-25 21:12:15 +00:00
|
|
|
int UserRegType,
|
|
|
|
int RegTypeWanted,
|
|
|
|
std::vector<bool> &IsColorUsedArr) const
|
|
|
|
{
|
2004-02-25 18:44:15 +00:00
|
|
|
if (UserRegType == SparcV9RegInfo::FPDoubleRegType ||
|
|
|
|
RegTypeWanted == SparcV9RegInfo::FPDoubleRegType) {
|
2003-07-25 21:12:15 +00:00
|
|
|
// This register is used as or is needed as a double-precision reg.
|
|
|
|
// We need to mark the [even,odd] pair corresponding to this reg.
|
|
|
|
// Get the even numbered register corresponding to this reg.
|
|
|
|
unsigned EvenRegInClass = RegInClass & ~1u;
|
|
|
|
assert(EvenRegInClass+1 < NumOfAllRegs &&
|
|
|
|
EvenRegInClass+1 < IsColorUsedArr.size());
|
|
|
|
IsColorUsedArr[EvenRegInClass] = true;
|
|
|
|
IsColorUsedArr[EvenRegInClass+1] = true;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
assert(RegInClass < NumOfAllRegs && RegInClass < IsColorUsedArr.size());
|
|
|
|
assert(UserRegType == RegTypeWanted
|
|
|
|
&& "Something other than FP single/double types share a reg class?");
|
|
|
|
IsColorUsedArr[RegInClass] = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// This method finds unused registers of the specified register type,
|
|
|
|
// using the given "used" flag array IsColorUsedArr. It checks a single
|
|
|
|
// entry in the array directly for float regs, and checks the pair [R,R+1]
|
|
|
|
// for double-precision registers
|
|
|
|
// It returns -1 if no unused color is found.
|
|
|
|
//
|
2004-02-25 18:44:15 +00:00
|
|
|
int SparcV9FloatRegClass::findUnusedColor(int RegTypeWanted,
|
2003-07-25 21:12:15 +00:00
|
|
|
const std::vector<bool> &IsColorUsedArr) const
|
|
|
|
{
|
2004-02-25 18:44:15 +00:00
|
|
|
if (RegTypeWanted == SparcV9RegInfo::FPDoubleRegType) {
|
2003-07-25 21:12:15 +00:00
|
|
|
unsigned NC = 2 * this->getNumOfAvailRegs();
|
|
|
|
assert(IsColorUsedArr.size() == NC && "Invalid colors-used array");
|
|
|
|
for (unsigned c = 0; c < NC; c+=2)
|
|
|
|
if (!IsColorUsedArr[c]) {
|
|
|
|
assert(!IsColorUsedArr[c+1] && "Incorrect used regs for FP double!");
|
|
|
|
return c;
|
|
|
|
}
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return TargetRegClassInfo::findUnusedColor(RegTypeWanted, IsColorUsedArr);
|
|
|
|
}
|
2001-09-18 22:52:44 +00:00
|
|
|
|
2002-01-07 19:20:28 +00:00
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// Helper method for coloring a node of Float Reg class.
|
|
|
|
// Finds the first available color in the range [Start,End] depending on the
|
|
|
|
// type of the Node (i.e., float/double)
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
2004-02-25 18:44:15 +00:00
|
|
|
int SparcV9FloatRegClass::findFloatColor(const LiveRange *LR,
|
2003-05-21 18:05:35 +00:00
|
|
|
unsigned Start,
|
|
|
|
unsigned End,
|
2003-07-25 21:12:15 +00:00
|
|
|
const std::vector<bool> &IsColorUsedArr) const
|
2003-05-21 17:59:06 +00:00
|
|
|
{
|
2002-02-05 03:52:29 +00:00
|
|
|
if (LR->getType() == Type::DoubleTy) {
|
2002-01-07 19:20:28 +00:00
|
|
|
// find first unused color for a double
|
2003-07-25 21:12:15 +00:00
|
|
|
assert(Start % 2 == 0 && "Odd register number could be used for double!");
|
|
|
|
for (unsigned c=Start; c < End ; c+= 2)
|
|
|
|
if (!IsColorUsedArr[c]) {
|
|
|
|
assert(!IsColorUsedArr[c+1] &&
|
2004-02-25 18:44:15 +00:00
|
|
|
"Incorrect marking of used regs for SparcV9 FP double!");
|
2002-02-04 05:59:25 +00:00
|
|
|
return c;
|
2003-07-25 21:12:15 +00:00
|
|
|
}
|
2002-01-07 19:20:28 +00:00
|
|
|
} else {
|
|
|
|
// find first unused color for a single
|
2003-07-25 21:12:15 +00:00
|
|
|
for (unsigned c = Start; c < End; c++)
|
2002-02-04 05:59:25 +00:00
|
|
|
if (!IsColorUsedArr[c])
|
|
|
|
return c;
|
2002-01-07 19:20:28 +00:00
|
|
|
}
|
2003-07-25 21:12:15 +00:00
|
|
|
|
2002-02-04 05:59:25 +00:00
|
|
|
return -1;
|
2003-07-25 21:12:15 +00:00
|
|
|
|
2002-01-07 19:20:28 +00:00
|
|
|
}
|
2003-11-11 22:41:34 +00:00
|
|
|
|
|
|
|
} // End llvm namespace
|