mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-10-31 09:11:13 +00:00
d55697cf13
routines supporting machine code optimization. Also added method MachineInstrInfo::getNOPOpCode(). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@3845 91177308-0d34-0410-b5e6-96231b3b80d8
119 lines
4.3 KiB
C++
119 lines
4.3 KiB
C++
//===-- 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.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#include "SparcInternals.h"
|
|
#include "llvm/Target/Sparc.h"
|
|
#include "llvm/Function.h"
|
|
#include "llvm/BasicBlock.h"
|
|
#include "llvm/CodeGen/MachineCodeForMethod.h"
|
|
#include <iostream>
|
|
using std::cerr;
|
|
|
|
// 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"
|
|
};
|
|
|
|
//----------------------------------------------------------------------------
|
|
// allocateSparcTargetMachine - Allocate and return a subclass of TargetMachine
|
|
// that implements the Sparc backend. (the llvm/CodeGen/Sparc.h interface)
|
|
//----------------------------------------------------------------------------
|
|
|
|
TargetMachine *allocateSparcTargetMachine() { return new UltraSparc(); }
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------
|
|
// class UltraSparcFrameInfo
|
|
//
|
|
// Purpose:
|
|
// Interface to stack frame layout info for the UltraSPARC.
|
|
// Starting offsets for each area of the stack frame are aligned at
|
|
// a multiple of getStackFrameSizeAlignment().
|
|
//---------------------------------------------------------------------------
|
|
|
|
int
|
|
UltraSparcFrameInfo::getFirstAutomaticVarOffset(MachineCodeForMethod& ,
|
|
bool& pos) const
|
|
{
|
|
pos = false; // static stack area grows downwards
|
|
return StaticAreaOffsetFromFP;
|
|
}
|
|
|
|
int
|
|
UltraSparcFrameInfo::getRegSpillAreaOffset(MachineCodeForMethod& mcInfo,
|
|
bool& pos) const
|
|
{
|
|
mcInfo.freezeAutomaticVarsArea(); // ensure no more auto vars are added
|
|
|
|
pos = false; // static stack area grows downwards
|
|
unsigned int autoVarsSize = mcInfo.getAutomaticVarsSize();
|
|
return StaticAreaOffsetFromFP - autoVarsSize;
|
|
}
|
|
|
|
int
|
|
UltraSparcFrameInfo::getTmpAreaOffset(MachineCodeForMethod& mcInfo,
|
|
bool& pos) const
|
|
{
|
|
mcInfo.freezeAutomaticVarsArea(); // ensure no more auto vars are added
|
|
mcInfo.freezeSpillsArea(); // ensure no more spill slots are added
|
|
|
|
pos = false; // static stack area grows downwards
|
|
unsigned int autoVarsSize = mcInfo.getAutomaticVarsSize();
|
|
unsigned int spillAreaSize = mcInfo.getRegSpillsSize();
|
|
int offset = autoVarsSize + spillAreaSize;
|
|
return StaticAreaOffsetFromFP - offset;
|
|
}
|
|
|
|
int
|
|
UltraSparcFrameInfo::getDynamicAreaOffset(MachineCodeForMethod& mcInfo,
|
|
bool& pos) const
|
|
{
|
|
// 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;
|
|
unsigned int optArgsSize = mcInfo.getMaxOptionalArgsSize();
|
|
if (int extra = optArgsSize % getStackFrameSizeAlignment())
|
|
optArgsSize += (getStackFrameSizeAlignment() - extra);
|
|
int offset = optArgsSize + FirstOptionalOutgoingArgOffsetFromSP;
|
|
assert((offset - OFFSET) % getStackFrameSizeAlignment() == 0);
|
|
return offset;
|
|
}
|
|
|
|
|
|
//---------------------------------------------------------------------------
|
|
// 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"),
|
|
instrInfo(*this),
|
|
schedInfo(*this),
|
|
regInfo(*this),
|
|
frameInfo(*this),
|
|
cacheInfo(*this),
|
|
optInfo(*this)
|
|
{
|
|
optSizeForSubWordData = 4;
|
|
minMemOpWordSize = 8;
|
|
maxAtomicMemOpWordSize = 8;
|
|
}
|
|
|