1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-24 19:52:54 +01:00

Move files.

llvm-svn: 561
This commit is contained in:
Chris Lattner 2001-09-14 03:47:57 +00:00
parent 0cf998996e
commit 1f823b04b3
4 changed files with 2454 additions and 0 deletions

14
lib/Target/Sparc/Makefile Normal file
View File

@ -0,0 +1,14 @@
LEVEL = ../../../..
DIRS =
LIBRARYNAME = sparc
## List source files in link order
Source = \
Sparc.o \
Sparc.burm.o \
SparcInstrSelection.o
include $(LEVEL)/Makefile.common

123
lib/Target/Sparc/Sparc.cpp Normal file
View File

@ -0,0 +1,123 @@
//***************************************************************************
// File:
// Sparc.cpp
//
// Purpose:
//
// History:
// 7/15/01 - Vikram Adve - Created
//**************************************************************************/
#include "SparcInternals.h"
#include "llvm/Method.h"
#include "llvm/CodeGen/InstrScheduling.h"
#include "llvm/CodeGen/InstrSelection.h"
//---------------------------------------------------------------------------
// class UltraSparcInstrInfo
//
// Purpose:
// Information about individual instructions.
// Most information is stored in the SparcMachineInstrDesc array above.
// Other information is computed on demand, and most such functions
// default to member functions in base class MachineInstrInfo.
//---------------------------------------------------------------------------
/*ctor*/
UltraSparcInstrInfo::UltraSparcInstrInfo()
: MachineInstrInfo(SparcMachineInstrDesc,
/*descSize = */ NUM_TOTAL_OPCODES,
/*numRealOpCodes = */ NUM_REAL_OPCODES)
{
}
//---------------------------------------------------------------------------
// class UltraSparcSchedInfo
//
// Purpose:
// Scheduling information for the UltraSPARC.
// Primarily just initializes machine-dependent parameters in
// class MachineSchedInfo.
//---------------------------------------------------------------------------
/*ctor*/
UltraSparcSchedInfo::UltraSparcSchedInfo(const MachineInstrInfo* mii)
: MachineSchedInfo((unsigned int) SPARC_NUM_SCHED_CLASSES,
mii,
SparcRUsageDesc,
SparcInstrUsageDeltas,
SparcInstrIssueDeltas,
sizeof(SparcInstrUsageDeltas)/sizeof(InstrRUsageDelta),
sizeof(SparcInstrIssueDeltas)/sizeof(InstrIssueDelta))
{
maxNumIssueTotal = 4;
longestIssueConflict = 0; // computed from issuesGaps[]
branchMispredictPenalty = 4; // 4 for SPARC IIi
branchTargetUnknownPenalty = 2; // 2 for SPARC IIi
l1DCacheMissPenalty = 8; // 7 or 9 for SPARC IIi
l1ICacheMissPenalty = 8; // ? for SPARC IIi
inOrderLoads = true; // true for SPARC IIi
inOrderIssue = true; // true for SPARC IIi
inOrderExec = false; // false for most architectures
inOrderRetire= true; // true for most architectures
// must be called after above parameters are initialized.
this->initializeResources();
}
void
UltraSparcSchedInfo::initializeResources()
{
// Compute MachineSchedInfo::instrRUsages and MachineSchedInfo::issueGaps
MachineSchedInfo::initializeResources();
// Machine-dependent fixups go here. None for now.
}
//---------------------------------------------------------------------------
// class UltraSparcMachine
//
// Purpose:
// Primary interface to machine description for the UltraSPARC.
// Primarily just initializes machine-dependent parameters in
// class TargetMachine, and creates machine-dependent subclasses
// for classes such as MachineInstrInfo.
//
//---------------------------------------------------------------------------
UltraSparc::UltraSparc() : TargetMachine("UltraSparc-Native") {
machineInstrInfo = new UltraSparcInstrInfo();
machineSchedInfo = new UltraSparcSchedInfo(machineInstrInfo);
optSizeForSubWordData = 4;
minMemOpWordSize = 8;
maxAtomicMemOpWordSize = 8;
zeroRegNum = 0; // %g0 always gives 0 on Sparc
}
UltraSparc::~UltraSparc() {
delete (UltraSparcInstrInfo*) machineInstrInfo;
delete (UltraSparcSchedInfo*) machineSchedInfo;
}
bool UltraSparc::compileMethod(Method *M) {
if (SelectInstructionsForMethod(M, *this)) {
cerr << "Instruction selection failed for method " << M->getName()
<< "\n\n";
return true;
}
if (ScheduleInstructionsWithSSA(M, *this)) {
cerr << "Instruction scheduling before allocation failed for method "
<< M->getName() << "\n\n";
return true;
}
return false;
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,301 @@
#include "SparcInternals.h"
#include "llvm/CodeGen/IGNode.h"
//-----------------------------------------------------------------------------
// Int Register Class
//-----------------------------------------------------------------------------
void SparcIntRegClass::colorIGNode(IGNode * Node, bool IsColorUsedArr[]) const
{
/* Algorithm:
Record the color of all neighbors.
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.
*/
unsigned NumNeighbors = Node->getNumOfNeighbors(); // total # of neighbors
for(unsigned n=0; n < NumNeighbors; n++) { // for each neigh
IGNode *NeighIGNode = Node->getAdjIGNode(n);
if( NeighIGNode->hasColor() ) { // if neigh has a color
IsColorUsedArr[ NeighIGNode->getColor() ] = true; // record that color
}
}
unsigned SearchStart; // start pos of color in pref-order
bool ColorFound= false; // have we found a color yet?
//if this Node is between calls
if( Node->getNumOfCallInterferences() == 0) {
// start with volatiles (we can allocate volatiles safely)
SearchStart = SparcIntRegOrder::StartOfAllRegs;
}
else {
// start with non volatiles (no non-volatiles)
SearchStart = SparcIntRegOrder::StartOfNonVolatileRegs;
}
unsigned c=0; // color
// find first unused color
for( c=SearchStart; c < SparcIntRegOrder::NumOfAvailRegs; c++) {
if( ! IsColorUsedArr[ c ] ) { ColorFound = true; break; }
}
if( ColorFound)
Node->setColor(c); // first color found in preffered order
// if color is not found because of call interference
// try even finding a volatile color and insert save across calls
else if( Node->getNumOfCallInterferences() )
{
// start from 0 - try to find even a volatile this time
SearchStart = SparcIntRegOrder::StartOfAllRegs;
// find first unused volatile color
for(c=SearchStart; c < SparcIntRegOrder::StartOfNonVolatileRegs; c++) {
if( ! IsColorUsedArr[ c ] ) { ColorFound = true; break; }
}
if( ColorFound) {
Node->setColor(c);
// since LR span across calls, must save across calls
Node->markForSaveAcrossCalls();
}
}
// 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
if( !ColorFound )
Node->markForSpill(); // no color found - must spill
if( DEBUG_RA)
UltraSparcRegInfo::printReg( Node->getParentLR() );
}
//-----------------------------------------------------------------------------
// Float Register Class
//-----------------------------------------------------------------------------
// find the first available color in the range [Start,End] depending on the
// type of the Node (i.e., float/double)
int SparcFloatRegClass::findFloatColor(const IGNode *const Node, unsigned Start,
unsigned End,
bool IsColorUsedArr[] ) const
{
bool ColorFound = false;
unsigned c;
if( Node->getTypeID() == Type::DoubleTyID ) {
// find first unused color for a double
for( c=Start; c < End ;c+= 2){
if( ! IsColorUsedArr[ c ] && ! IsColorUsedArr[ c+1 ])
{ ColorFound=true; break; }
}
} else {
// find first unused color for a single
for( c=Start; c < End; c++) {
if( ! IsColorUsedArr[ c ] ) { ColorFound=true; break; }
}
}
if( ColorFound ) return c;
else return -1;
}
void SparcFloatRegClass::colorIGNode(IGNode * Node,bool IsColorUsedArr[]) const
{
/* 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
*/
unsigned NumNeighbors = Node->getNumOfNeighbors(); // total # of neighbors
for(unsigned n=0; n < NumNeighbors; n++) { // for each neigh
IGNode *NeighIGNode = Node->getAdjIGNode(n);
if( NeighIGNode->hasColor() ) { // if neigh has a color
IsColorUsedArr[ NeighIGNode->getColor() ] = true; // record that color
if( NeighIGNode->getTypeID() == Type::DoubleTyID )
IsColorUsedArr[ (NeighIGNode->getColor()) + 1 ] = true;
}
}
int ColorFound = -1; // have we found a color yet?
unsigned NumOfCallInterf = Node->getNumOfCallInterferences();
// if value is a double - search the double only reigon (f32 - f63)
if( Node->getTypeID() == Type::DoubleTyID )
ColorFound = findFloatColor( Node, 32, 64, IsColorUsedArr );
if( ColorFound >= 0 ) {
Node->setColor(ColorFound);
if( DEBUG_RA) UltraSparcRegInfo::printReg( Node->getParentLR() );
return;
}
else { // the above fails or LR is single precision
unsigned SearchStart; // start pos of color in pref-order
//if this Node is between calls (i.e., no call interferences )
if( ! NumOfCallInterf ) {
// start with volatiles (we can allocate volatiles safely)
SearchStart = SparcFloatRegOrder::StartOfAllRegs;
}
else {
// start with non volatiles (no non-volatiles)
SearchStart = SparcFloatRegOrder::StartOfNonVolatileRegs;
}
ColorFound = findFloatColor( Node, SearchStart, 32, IsColorUsedArr );
}
if( ColorFound >= 0 ) {
Node->setColor(ColorFound);
if( DEBUG_RA) UltraSparcRegInfo::printReg( Node->getParentLR() );
return;
}
else if( NumOfCallInterf ) {
// 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
ColorFound = findFloatColor( Node, SparcFloatRegOrder::StartOfAllRegs,
SparcFloatRegOrder::StartOfNonVolatileRegs,
IsColorUsedArr);
}
if( ColorFound >= 0 ) {
Node->setColor(ColorFound); // first color found in preffered order
Node->markForSaveAcrossCalls();
if( DEBUG_RA) UltraSparcRegInfo::printReg( Node->getParentLR() );
return;
}
else {
Node->markForSpill(); // no color found - must spill
if( DEBUG_RA) UltraSparcRegInfo::printReg( Node->getParentLR() );
}
}
#if 0
//-----------------------------------------------------------------------------
// Float Register Class
//-----------------------------------------------------------------------------
void SparcFloatRegClass::colorIGNode(IGNode * Node,bool IsColorUsedArr[]) const
{
/* Algorithm:
Record the color of all neighbors.
Single precision can use f0 - f31
Double precision can use f0 - f63
if LR is a double, try to allocate f32 - f63.
if the above attempt fails, or Value is single presion, try to allcoate
f0 - f31.
*/
unsigned NumNeighbors = Node->getNumOfNeighbors(); // total # of neighbors
for(unsigned n=0; n < NumNeighbors; n++) { // for each neigh
IGNode *NeighIGNode = Node->getAdjIGNode(n);
if( NeighIGNode->hasColor() ) { // if neigh has a color
IsColorUsedArr[ NeighIGNode->getColor() ] = true; // record that color
if( NeighIGNode->getTypeID() == Type::DoubleTyID )
IsColorUsedArr[ (NeighIGNode->getColor()) + 1 ] = true;
}
}
unsigned SearchStart; // start pos of color in pref-order
bool ColorFound= false; // have we found a color yet?
unsigned c;
if( Node->getTypeID() == Type::DoubleTyID ) { // if value is a double
// search the double only reigon (f32 - f63)
for( c=32; c < 64; c+= 2) {
if( ! IsColorUsedArr[ c ] ) { ColorFound = true; break; }
}
// search f0 - f31 region
if( ! ColorFound ) { // if color not found
for( c=0; c < 32; c+= 2) {
if( ! IsColorUsedArr[ c ] ) { ColorFound = true; break; }
}
}
}
else { // value is Single
for( c=0; c < 32; c++) {
if( ! IsColorUsedArr[ c ] ) { ColorFound = true; break; }
}
}
if( ColorFound)
Node->setColor(c); // first color found in preferred order
else
Node->markForSpill(); // no color found - must spill
if( DEBUG_RA)
UltraSparcRegInfo::printReg( Node->getParentLR() );
}
#endif