2002-04-09 05:21:26 +00:00
|
|
|
//===-- Sparc.cpp - General implementation file for the Sparc Target ------===//
|
|
|
|
//
|
|
|
|
// This file contains the code for the Sparc Target that does not fit in any of
|
|
|
|
// the other files in this directory.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
2001-10-22 13:44:23 +00:00
|
|
|
|
2001-09-14 03:47:57 +00:00
|
|
|
#include "SparcInternals.h"
|
2001-10-22 13:44:23 +00:00
|
|
|
#include "llvm/Target/Sparc.h"
|
2002-04-07 20:49:59 +00:00
|
|
|
#include "llvm/Function.h"
|
2002-02-12 21:07:25 +00:00
|
|
|
#include "llvm/BasicBlock.h"
|
2002-09-16 15:39:26 +00:00
|
|
|
#include "llvm/CodeGen/MachineCodeForMethod.h"
|
2002-01-20 22:54:45 +00:00
|
|
|
#include <iostream>
|
|
|
|
using std::cerr;
|
2001-09-15 00:30:44 +00:00
|
|
|
|
2001-09-19 15:56:23 +00:00
|
|
|
// Build the MachineInstruction Description Array...
|
|
|
|
const MachineInstrDescriptor SparcMachineInstrDesc[] = {
|
|
|
|
#define I(ENUM, OPCODESTRING, NUMOPERANDS, RESULTPOS, MAXIMM, IMMSE, \
|
|
|
|
NUMDELAYSLOTS, LATENCY, SCHEDCLASS, INSTFLAGS) \
|
|
|
|
{ OPCODESTRING, NUMOPERANDS, RESULTPOS, MAXIMM, IMMSE, \
|
|
|
|
NUMDELAYSLOTS, LATENCY, SCHEDCLASS, INSTFLAGS },
|
|
|
|
#include "SparcInstr.def"
|
|
|
|
};
|
2001-09-18 13:01:29 +00:00
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
2001-09-14 16:56:32 +00:00
|
|
|
// allocateSparcTargetMachine - Allocate and return a subclass of TargetMachine
|
|
|
|
// that implements the Sparc backend. (the llvm/CodeGen/Sparc.h interface)
|
2001-09-18 13:01:29 +00:00
|
|
|
//----------------------------------------------------------------------------
|
2001-10-15 16:25:28 +00:00
|
|
|
|
2001-09-14 16:56:32 +00:00
|
|
|
TargetMachine *allocateSparcTargetMachine() { return new UltraSparc(); }
|
2001-09-14 03:47:57 +00:00
|
|
|
|
|
|
|
|
2001-10-22 13:44:23 +00:00
|
|
|
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
// class UltraSparcFrameInfo
|
|
|
|
//
|
|
|
|
// Purpose:
|
|
|
|
// Interface to stack frame layout info for the UltraSPARC.
|
2001-11-12 23:26:35 +00:00
|
|
|
// Starting offsets for each area of the stack frame are aligned at
|
|
|
|
// a multiple of getStackFrameSizeAlignment().
|
2001-10-22 13:44:23 +00:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
int
|
2001-11-08 04:55:13 +00:00
|
|
|
UltraSparcFrameInfo::getFirstAutomaticVarOffset(MachineCodeForMethod& ,
|
|
|
|
bool& pos) const
|
2001-10-22 13:44:23 +00:00
|
|
|
{
|
2001-11-08 04:55:13 +00:00
|
|
|
pos = false; // static stack area grows downwards
|
|
|
|
return StaticAreaOffsetFromFP;
|
2001-10-22 13:44:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2001-11-08 04:55:13 +00:00
|
|
|
UltraSparcFrameInfo::getRegSpillAreaOffset(MachineCodeForMethod& mcInfo,
|
|
|
|
bool& pos) const
|
2001-10-22 13:44:23 +00:00
|
|
|
{
|
2002-04-25 04:43:45 +00:00
|
|
|
mcInfo.freezeAutomaticVarsArea(); // ensure no more auto vars are added
|
|
|
|
|
2001-11-08 04:55:13 +00:00
|
|
|
pos = false; // static stack area grows downwards
|
|
|
|
unsigned int autoVarsSize = mcInfo.getAutomaticVarsSize();
|
2001-11-12 23:26:35 +00:00
|
|
|
return StaticAreaOffsetFromFP - autoVarsSize;
|
2001-10-22 13:44:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2001-11-08 04:55:13 +00:00
|
|
|
UltraSparcFrameInfo::getTmpAreaOffset(MachineCodeForMethod& mcInfo,
|
|
|
|
bool& pos) const
|
2001-10-22 13:44:23 +00:00
|
|
|
{
|
2002-04-25 04:43:45 +00:00
|
|
|
mcInfo.freezeAutomaticVarsArea(); // ensure no more auto vars are added
|
|
|
|
mcInfo.freezeSpillsArea(); // ensure no more spill slots are added
|
|
|
|
|
2001-11-08 04:55:13 +00:00
|
|
|
pos = false; // static stack area grows downwards
|
|
|
|
unsigned int autoVarsSize = mcInfo.getAutomaticVarsSize();
|
|
|
|
unsigned int spillAreaSize = mcInfo.getRegSpillsSize();
|
2001-11-12 23:26:35 +00:00
|
|
|
int offset = autoVarsSize + spillAreaSize;
|
|
|
|
return StaticAreaOffsetFromFP - offset;
|
2001-10-22 13:44:23 +00:00
|
|
|
}
|
|
|
|
|
2001-11-08 04:55:13 +00:00
|
|
|
int
|
|
|
|
UltraSparcFrameInfo::getDynamicAreaOffset(MachineCodeForMethod& mcInfo,
|
|
|
|
bool& pos) const
|
|
|
|
{
|
2002-03-18 03:08:07 +00:00
|
|
|
// Dynamic stack area grows downwards starting at top of opt-args area.
|
|
|
|
// The opt-args, required-args, and register-save areas are empty except
|
|
|
|
// during calls and traps, so they are shifted downwards on each
|
|
|
|
// dynamic-size alloca.
|
|
|
|
pos = false;
|
2001-11-08 04:55:13 +00:00
|
|
|
unsigned int optArgsSize = mcInfo.getMaxOptionalArgsSize();
|
2002-09-16 15:39:26 +00:00
|
|
|
if (int extra = optArgsSize % getStackFrameSizeAlignment())
|
|
|
|
optArgsSize += (getStackFrameSizeAlignment() - extra);
|
2001-11-12 23:26:35 +00:00
|
|
|
int offset = optArgsSize + FirstOptionalOutgoingArgOffsetFromSP;
|
2002-03-18 03:08:07 +00:00
|
|
|
assert((offset - OFFSET) % getStackFrameSizeAlignment() == 0);
|
2001-11-12 23:26:35 +00:00
|
|
|
return offset;
|
2001-11-08 04:55:13 +00:00
|
|
|
}
|
2001-09-15 00:30:44 +00:00
|
|
|
|
|
|
|
|
2001-09-14 03:47:57 +00:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
// 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.
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2001-09-18 13:01:29 +00:00
|
|
|
UltraSparc::UltraSparc()
|
|
|
|
: TargetMachine("UltraSparc-Native"),
|
2001-11-08 04:55:13 +00:00
|
|
|
instrInfo(*this),
|
|
|
|
schedInfo(*this),
|
|
|
|
regInfo(*this),
|
2001-11-09 02:16:04 +00:00
|
|
|
frameInfo(*this),
|
2002-09-20 00:52:09 +00:00
|
|
|
cacheInfo(*this),
|
|
|
|
optInfo(*this)
|
2001-09-18 13:01:29 +00:00
|
|
|
{
|
2001-09-14 03:47:57 +00:00
|
|
|
optSizeForSubWordData = 4;
|
|
|
|
minMemOpWordSize = 8;
|
|
|
|
maxAtomicMemOpWordSize = 8;
|
|
|
|
}
|
|
|
|
|