2002-10-28 02:16:38 +01:00
|
|
|
//===-- MachineFunction.cpp -----------------------------------------------===//
|
2002-02-03 08:54:50 +01:00
|
|
|
//
|
2003-10-20 21:43:21 +02: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-10-28 02:16:38 +01:00
|
|
|
// Collect native machine code information for a function. This allows
|
|
|
|
// target-specific information about the generated code to be stored with each
|
|
|
|
// function.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
2002-02-03 08:54:50 +01:00
|
|
|
|
2003-12-20 11:20:58 +01:00
|
|
|
#include "llvm/CodeGen/MachineFunctionPass.h"
|
2002-12-25 06:03:22 +01:00
|
|
|
#include "llvm/CodeGen/MachineInstr.h"
|
2002-10-28 02:12:41 +01:00
|
|
|
#include "llvm/CodeGen/MachineCodeForInstruction.h"
|
2002-12-25 06:03:22 +01:00
|
|
|
#include "llvm/CodeGen/SSARegMap.h"
|
2002-12-28 21:37:16 +01:00
|
|
|
#include "llvm/CodeGen/MachineFunctionInfo.h"
|
2002-12-28 22:08:26 +01:00
|
|
|
#include "llvm/CodeGen/MachineFrameInfo.h"
|
2003-01-13 01:23:03 +01:00
|
|
|
#include "llvm/CodeGen/MachineConstantPool.h"
|
2003-12-20 11:20:58 +01:00
|
|
|
#include "llvm/CodeGen/Passes.h"
|
2002-02-03 08:54:50 +01:00
|
|
|
#include "llvm/Target/TargetMachine.h"
|
2002-12-28 22:00:25 +01:00
|
|
|
#include "llvm/Target/TargetFrameInfo.h"
|
2002-12-29 03:50:35 +01:00
|
|
|
#include "llvm/Target/TargetCacheInfo.h"
|
2002-04-07 22:49:59 +02:00
|
|
|
#include "llvm/Function.h"
|
2002-02-03 08:54:50 +01:00
|
|
|
#include "llvm/iOther.h"
|
2003-12-20 10:17:07 +01:00
|
|
|
using namespace llvm;
|
2002-02-03 08:54:50 +01:00
|
|
|
|
2002-10-30 00:18:43 +01:00
|
|
|
static AnnotationID MF_AID(
|
2002-04-07 22:49:59 +02:00
|
|
|
AnnotationManager::getID("CodeGen::MachineCodeForFunction"));
|
2002-02-03 08:54:50 +01:00
|
|
|
|
2002-10-28 02:12:41 +01:00
|
|
|
|
|
|
|
namespace {
|
2003-12-20 11:20:58 +01:00
|
|
|
struct Printer : public MachineFunctionPass {
|
2002-10-30 01:48:05 +01:00
|
|
|
const char *getPassName() const { return "MachineFunction Printer"; }
|
|
|
|
|
|
|
|
virtual void getAnalysisUsage(AnalysisUsage &AU) const {
|
|
|
|
AU.setPreservesAll();
|
|
|
|
}
|
|
|
|
|
2003-12-20 11:20:58 +01:00
|
|
|
bool runOnMachineFunction(MachineFunction &MF) {
|
|
|
|
MF.dump();
|
2002-10-30 01:48:05 +01:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
};
|
2002-10-28 02:12:41 +01:00
|
|
|
}
|
|
|
|
|
2003-12-20 10:17:07 +01:00
|
|
|
FunctionPass *llvm::createMachineFunctionPrinterPass() {
|
2002-10-30 01:48:05 +01:00
|
|
|
return new Printer();
|
|
|
|
}
|
|
|
|
|
2003-12-20 11:20:58 +01:00
|
|
|
namespace {
|
|
|
|
struct Deleter : public MachineFunctionPass {
|
|
|
|
const char *getPassName() const { return "Machine Code Deleter"; }
|
|
|
|
|
|
|
|
bool runOnMachineFunction(MachineFunction &MF) {
|
|
|
|
// Delete all of the MachineInstrs out of the function. When the sparc
|
|
|
|
// backend gets fixed, this can be dramatically simpler, but actually
|
|
|
|
// putting this stuff into the MachineBasicBlock destructor!
|
|
|
|
for (MachineFunction::iterator BB = MF.begin(), E = MF.end(); BB != E;
|
|
|
|
++BB)
|
|
|
|
while (!BB->empty())
|
|
|
|
delete BB->pop_back();
|
|
|
|
|
|
|
|
// Delete the annotation from the function now.
|
|
|
|
MachineFunction::destruct(MF.getFunction());
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
/// MachineCodeDeletion Pass - This pass deletes all of the machine code for
|
|
|
|
/// the current function, which should happen after the function has been
|
|
|
|
/// emitted to a .s file or to memory.
|
|
|
|
FunctionPass *llvm::createMachineCodeDeleter() {
|
|
|
|
return new Deleter();
|
|
|
|
}
|
|
|
|
|
2002-10-28 02:12:41 +01:00
|
|
|
|
|
|
|
//===---------------------------------------------------------------------===//
|
|
|
|
// MachineFunction implementation
|
|
|
|
//===---------------------------------------------------------------------===//
|
|
|
|
|
2002-10-30 01:48:05 +01:00
|
|
|
MachineFunction::MachineFunction(const Function *F,
|
2002-12-28 21:37:16 +01:00
|
|
|
const TargetMachine &TM)
|
|
|
|
: Annotation(MF_AID), Fn(F), Target(TM) {
|
2002-11-20 19:55:27 +01:00
|
|
|
SSARegMapping = new SSARegMap();
|
2002-12-28 21:37:16 +01:00
|
|
|
MFInfo = new MachineFunctionInfo(*this);
|
2002-12-28 22:08:26 +01:00
|
|
|
FrameInfo = new MachineFrameInfo();
|
2003-01-13 01:23:03 +01:00
|
|
|
ConstantPool = new MachineConstantPool();
|
2002-12-25 06:03:22 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
MachineFunction::~MachineFunction() {
|
|
|
|
delete SSARegMapping;
|
2002-12-28 21:37:16 +01:00
|
|
|
delete MFInfo;
|
|
|
|
delete FrameInfo;
|
2003-01-13 01:23:03 +01:00
|
|
|
delete ConstantPool;
|
2002-10-30 01:48:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void MachineFunction::dump() const { print(std::cerr); }
|
|
|
|
|
|
|
|
void MachineFunction::print(std::ostream &OS) const {
|
2002-12-28 21:37:16 +01:00
|
|
|
OS << "\n" << *(Value*)Fn->getFunctionType() << " \"" << Fn->getName()
|
|
|
|
<< "\"\n";
|
|
|
|
|
|
|
|
// Print Frame Information
|
2003-01-16 19:35:57 +01:00
|
|
|
getFrameInfo()->print(*this, OS);
|
2003-01-13 01:23:03 +01:00
|
|
|
|
|
|
|
// Print Constant Pool
|
|
|
|
getConstantPool()->print(OS);
|
2002-10-30 01:48:05 +01:00
|
|
|
|
|
|
|
for (const_iterator BB = begin(); BB != end(); ++BB) {
|
2003-07-27 01:24:56 +02:00
|
|
|
const BasicBlock *LBB = BB->getBasicBlock();
|
2002-12-15 21:35:25 +01:00
|
|
|
OS << "\n" << LBB->getName() << " (" << (const void*)LBB << "):\n";
|
2002-10-30 01:48:05 +01:00
|
|
|
for (MachineBasicBlock::const_iterator I = BB->begin(); I != BB->end();++I){
|
|
|
|
OS << "\t";
|
|
|
|
(*I)->print(OS, Target);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
OS << "\nEnd function \"" << Fn->getName() << "\"\n\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-02-03 08:54:50 +01:00
|
|
|
// The next two methods are used to construct and to retrieve
|
2002-04-07 22:49:59 +02:00
|
|
|
// the MachineCodeForFunction object for the given function.
|
|
|
|
// construct() -- Allocates and initializes for a given function and target
|
2002-02-03 08:54:50 +01:00
|
|
|
// get() -- Returns a handle to the object.
|
|
|
|
// This should not be called before "construct()"
|
2002-04-07 22:49:59 +02:00
|
|
|
// for a given Function.
|
2002-02-03 08:54:50 +01:00
|
|
|
//
|
2002-10-28 01:28:31 +01:00
|
|
|
MachineFunction&
|
2002-10-28 06:58:46 +01:00
|
|
|
MachineFunction::construct(const Function *Fn, const TargetMachine &Tar)
|
2002-03-18 04:36:30 +01:00
|
|
|
{
|
2002-10-30 00:18:43 +01:00
|
|
|
assert(Fn->getAnnotation(MF_AID) == 0 &&
|
2002-04-07 22:49:59 +02:00
|
|
|
"Object already exists for this function!");
|
2002-10-28 06:58:46 +01:00
|
|
|
MachineFunction* mcInfo = new MachineFunction(Fn, Tar);
|
|
|
|
Fn->addAnnotation(mcInfo);
|
2002-02-03 08:54:50 +01:00
|
|
|
return *mcInfo;
|
|
|
|
}
|
|
|
|
|
2003-12-20 11:20:58 +01:00
|
|
|
void MachineFunction::destruct(const Function *Fn) {
|
2002-10-30 00:18:43 +01:00
|
|
|
bool Deleted = Fn->deleteAnnotation(MF_AID);
|
2002-04-07 22:49:59 +02:00
|
|
|
assert(Deleted && "Machine code did not exist for function!");
|
2002-02-03 08:54:50 +01:00
|
|
|
}
|
|
|
|
|
2002-10-28 06:58:46 +01:00
|
|
|
MachineFunction& MachineFunction::get(const Function *F)
|
2002-03-18 04:36:30 +01:00
|
|
|
{
|
2002-10-30 00:18:43 +01:00
|
|
|
MachineFunction *mc = (MachineFunction*)F->getAnnotation(MF_AID);
|
2002-02-03 08:54:50 +01:00
|
|
|
assert(mc && "Call construct() method first to allocate the object");
|
|
|
|
return *mc;
|
|
|
|
}
|
|
|
|
|
2002-12-25 06:03:22 +01:00
|
|
|
void MachineFunction::clearSSARegMap() {
|
|
|
|
delete SSARegMapping;
|
|
|
|
SSARegMapping = 0;
|
|
|
|
}
|
|
|
|
|
2002-12-28 21:37:16 +01:00
|
|
|
//===----------------------------------------------------------------------===//
|
2002-12-28 22:08:26 +01:00
|
|
|
// MachineFrameInfo implementation
|
2002-12-28 21:37:16 +01:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2003-01-13 01:23:03 +01:00
|
|
|
/// CreateStackObject - Create a stack object for a value of the specified type.
|
|
|
|
///
|
|
|
|
int MachineFrameInfo::CreateStackObject(const Type *Ty, const TargetData &TD) {
|
|
|
|
return CreateStackObject(TD.getTypeSize(Ty), TD.getTypeAlignment(Ty));
|
|
|
|
}
|
|
|
|
|
|
|
|
int MachineFrameInfo::CreateStackObject(const TargetRegisterClass *RC) {
|
|
|
|
return CreateStackObject(RC->getSize(), RC->getAlignment());
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-01-16 19:35:57 +01:00
|
|
|
void MachineFrameInfo::print(const MachineFunction &MF, std::ostream &OS) const{
|
|
|
|
int ValOffset = MF.getTarget().getFrameInfo().getOffsetOfLocalArea();
|
|
|
|
|
2002-12-28 21:37:16 +01:00
|
|
|
for (unsigned i = 0, e = Objects.size(); i != e; ++i) {
|
|
|
|
const StackObject &SO = Objects[i];
|
2003-01-13 01:23:03 +01:00
|
|
|
OS << " <fi #" << (int)(i-NumFixedObjects) << "> is ";
|
2002-12-28 21:37:16 +01:00
|
|
|
if (SO.Size == 0)
|
|
|
|
OS << "variable sized";
|
|
|
|
else
|
|
|
|
OS << SO.Size << " byte" << (SO.Size != 1 ? "s" : " ");
|
|
|
|
|
|
|
|
if (i < NumFixedObjects)
|
|
|
|
OS << " fixed";
|
|
|
|
if (i < NumFixedObjects || SO.SPOffset != -1) {
|
2003-01-16 19:35:57 +01:00
|
|
|
int Off = SO.SPOffset + ValOffset;
|
2002-12-28 21:37:16 +01:00
|
|
|
OS << " at location [SP";
|
2003-01-16 19:35:57 +01:00
|
|
|
if (Off > 0)
|
|
|
|
OS << "+" << Off;
|
|
|
|
else if (Off < 0)
|
|
|
|
OS << Off;
|
2002-12-28 21:37:16 +01:00
|
|
|
OS << "]";
|
|
|
|
}
|
|
|
|
OS << "\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
if (HasVarSizedObjects)
|
|
|
|
OS << " Stack frame contains variable sized objects\n";
|
|
|
|
}
|
|
|
|
|
2003-01-16 19:35:57 +01:00
|
|
|
void MachineFrameInfo::dump(const MachineFunction &MF) const {
|
|
|
|
print(MF, std::cerr);
|
|
|
|
}
|
2002-12-28 21:37:16 +01:00
|
|
|
|
|
|
|
|
2003-01-13 01:23:03 +01:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// MachineConstantPool implementation
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
void MachineConstantPool::print(std::ostream &OS) const {
|
|
|
|
for (unsigned i = 0, e = Constants.size(); i != e; ++i)
|
|
|
|
OS << " <cp #" << i << "> is" << *(Value*)Constants[i] << "\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
void MachineConstantPool::dump() const { print(std::cerr); }
|
|
|
|
|
2002-12-28 21:37:16 +01:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// MachineFunctionInfo implementation
|
|
|
|
//===----------------------------------------------------------------------===//
|
2002-12-25 06:03:22 +01:00
|
|
|
|
2002-02-03 08:54:50 +01:00
|
|
|
static unsigned
|
2002-04-25 06:30:43 +02:00
|
|
|
ComputeMaxOptionalArgsSize(const TargetMachine& target, const Function *F,
|
|
|
|
unsigned &maxOptionalNumArgs)
|
2002-02-03 08:54:50 +01:00
|
|
|
{
|
2002-12-28 21:37:16 +01:00
|
|
|
const TargetFrameInfo &frameInfo = target.getFrameInfo();
|
2002-02-03 08:54:50 +01:00
|
|
|
|
2002-06-25 18:13:21 +02:00
|
|
|
unsigned maxSize = 0;
|
2002-02-03 08:54:50 +01:00
|
|
|
|
2002-06-25 18:13:21 +02:00
|
|
|
for (Function::const_iterator BB = F->begin(), BBE = F->end(); BB !=BBE; ++BB)
|
|
|
|
for (BasicBlock::const_iterator I = BB->begin(), E = BB->end(); I != E; ++I)
|
2003-04-23 18:36:11 +02:00
|
|
|
if (const CallInst *callInst = dyn_cast<CallInst>(I))
|
2002-06-25 18:13:21 +02:00
|
|
|
{
|
|
|
|
unsigned numOperands = callInst->getNumOperands() - 1;
|
|
|
|
int numExtra = (int)numOperands-frameInfo.getNumFixedOutgoingArgs();
|
|
|
|
if (numExtra <= 0)
|
|
|
|
continue;
|
|
|
|
|
2002-12-28 21:37:16 +01:00
|
|
|
unsigned sizeForThisCall;
|
2002-06-25 18:13:21 +02:00
|
|
|
if (frameInfo.argsOnStackHaveFixedSize())
|
|
|
|
{
|
|
|
|
int argSize = frameInfo.getSizeOfEachArgOnStack();
|
|
|
|
sizeForThisCall = numExtra * (unsigned) argSize;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
assert(0 && "UNTESTED CODE: Size per stack argument is not "
|
|
|
|
"fixed on this architecture: use actual arg sizes to "
|
|
|
|
"compute MaxOptionalArgsSize");
|
|
|
|
sizeForThisCall = 0;
|
|
|
|
for (unsigned i = 0; i < numOperands; ++i)
|
2002-12-28 21:37:16 +01:00
|
|
|
sizeForThisCall += target.getTargetData().getTypeSize(callInst->
|
2002-06-25 18:13:21 +02:00
|
|
|
getOperand(i)->getType());
|
|
|
|
}
|
|
|
|
|
|
|
|
if (maxSize < sizeForThisCall)
|
|
|
|
maxSize = sizeForThisCall;
|
|
|
|
|
|
|
|
if ((int)maxOptionalNumArgs < numExtra)
|
|
|
|
maxOptionalNumArgs = (unsigned) numExtra;
|
|
|
|
}
|
2002-03-18 04:36:30 +01:00
|
|
|
|
2002-02-03 08:54:50 +01:00
|
|
|
return maxSize;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Align data larger than one L1 cache line on L1 cache line boundaries.
|
2002-09-16 17:18:16 +02:00
|
|
|
// Align all smaller data on the next higher 2^x boundary (4, 8, ...),
|
|
|
|
// but not higher than the alignment of the largest type we support
|
|
|
|
// (currently a double word). -- see class TargetData).
|
2002-02-03 08:54:50 +01:00
|
|
|
//
|
2002-09-16 17:18:16 +02:00
|
|
|
// This function is similar to the corresponding function in EmitAssembly.cpp
|
|
|
|
// but they are unrelated. This one does not align at more than a
|
|
|
|
// double-word boundary whereas that one might.
|
2002-02-03 08:54:50 +01:00
|
|
|
//
|
2002-12-28 21:37:16 +01:00
|
|
|
inline unsigned
|
|
|
|
SizeToAlignment(unsigned size, const TargetMachine& target)
|
2002-02-03 08:54:50 +01:00
|
|
|
{
|
|
|
|
unsigned short cacheLineSize = target.getCacheInfo().getCacheLineSize(1);
|
|
|
|
if (size > (unsigned) cacheLineSize / 2)
|
|
|
|
return cacheLineSize;
|
|
|
|
else
|
|
|
|
for (unsigned sz=1; /*no condition*/; sz *= 2)
|
2002-12-28 21:37:16 +01:00
|
|
|
if (sz >= size || sz >= target.getTargetData().getDoubleAlignment())
|
2002-02-03 08:54:50 +01:00
|
|
|
return sz;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-12-28 21:37:16 +01:00
|
|
|
void MachineFunctionInfo::CalculateArgSize() {
|
|
|
|
maxOptionalArgsSize = ComputeMaxOptionalArgsSize(MF.getTarget(),
|
|
|
|
MF.getFunction(),
|
2002-04-25 06:30:43 +02:00
|
|
|
maxOptionalNumArgs);
|
2002-03-18 04:36:30 +01:00
|
|
|
staticStackSize = maxOptionalArgsSize
|
2002-12-28 21:37:16 +01:00
|
|
|
+ MF.getTarget().getFrameInfo().getMinStackFrameSize();
|
2002-03-18 04:36:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2002-12-28 21:37:16 +01:00
|
|
|
MachineFunctionInfo::computeOffsetforLocalVar(const Value* val,
|
|
|
|
unsigned &getPaddedSize,
|
|
|
|
unsigned sizeToUse)
|
2002-03-18 04:36:30 +01:00
|
|
|
{
|
2002-03-24 04:39:26 +01:00
|
|
|
if (sizeToUse == 0)
|
2002-12-28 21:37:16 +01:00
|
|
|
sizeToUse = MF.getTarget().findOptimalStorageSize(val->getType());
|
|
|
|
unsigned align = SizeToAlignment(sizeToUse, MF.getTarget());
|
2002-09-16 17:18:16 +02:00
|
|
|
|
|
|
|
bool growUp;
|
2002-12-28 21:37:16 +01:00
|
|
|
int firstOffset = MF.getTarget().getFrameInfo().getFirstAutomaticVarOffset(MF,
|
|
|
|
growUp);
|
2002-09-16 17:18:16 +02:00
|
|
|
int offset = growUp? firstOffset + getAutomaticVarsSize()
|
|
|
|
: firstOffset - (getAutomaticVarsSize() + sizeToUse);
|
|
|
|
|
2002-12-28 21:37:16 +01:00
|
|
|
int aligned = MF.getTarget().getFrameInfo().adjustAlignment(offset, growUp, align);
|
2002-09-16 17:18:16 +02:00
|
|
|
getPaddedSize = sizeToUse + abs(aligned - offset);
|
|
|
|
|
|
|
|
return aligned;
|
2002-02-03 08:54:50 +01:00
|
|
|
}
|
|
|
|
|
2003-12-20 10:17:07 +01:00
|
|
|
|
|
|
|
int MachineFunctionInfo::allocateLocalVar(const Value* val,
|
|
|
|
unsigned sizeToUse) {
|
2002-04-25 06:30:43 +02:00
|
|
|
assert(! automaticVarsAreaFrozen &&
|
|
|
|
"Size of auto vars area has been used to compute an offset so "
|
|
|
|
"no more automatic vars should be allocated!");
|
|
|
|
|
2002-02-03 08:54:50 +01:00
|
|
|
// Check if we've allocated a stack slot for this value already
|
|
|
|
//
|
2003-12-20 10:17:07 +01:00
|
|
|
hash_map<const Value*, int>::const_iterator pair = offsets.find(val);
|
|
|
|
if (pair != offsets.end())
|
|
|
|
return pair->second;
|
|
|
|
|
|
|
|
unsigned getPaddedSize;
|
|
|
|
unsigned offset = computeOffsetforLocalVar(val, getPaddedSize, sizeToUse);
|
|
|
|
offsets[val] = offset;
|
|
|
|
incrementAutomaticVarsSize(getPaddedSize);
|
2002-02-03 08:54:50 +01:00
|
|
|
return offset;
|
|
|
|
}
|
2002-09-16 17:18:16 +02:00
|
|
|
|
2002-02-03 08:54:50 +01:00
|
|
|
int
|
2002-12-28 21:37:16 +01:00
|
|
|
MachineFunctionInfo::allocateSpilledValue(const Type* type)
|
2002-02-03 08:54:50 +01:00
|
|
|
{
|
2002-04-25 06:30:43 +02:00
|
|
|
assert(! spillsAreaFrozen &&
|
|
|
|
"Size of reg spills area has been used to compute an offset so "
|
|
|
|
"no more register spill slots should be allocated!");
|
|
|
|
|
2002-12-28 21:37:16 +01:00
|
|
|
unsigned size = MF.getTarget().getTargetData().getTypeSize(type);
|
|
|
|
unsigned char align = MF.getTarget().getTargetData().getTypeAlignment(type);
|
2002-02-03 08:54:50 +01:00
|
|
|
|
|
|
|
bool growUp;
|
2002-12-28 21:37:16 +01:00
|
|
|
int firstOffset = MF.getTarget().getFrameInfo().getRegSpillAreaOffset(MF, growUp);
|
2002-02-03 08:54:50 +01:00
|
|
|
|
2002-09-16 17:18:16 +02:00
|
|
|
int offset = growUp? firstOffset + getRegSpillsSize()
|
|
|
|
: firstOffset - (getRegSpillsSize() + size);
|
|
|
|
|
2002-12-28 21:37:16 +01:00
|
|
|
int aligned = MF.getTarget().getFrameInfo().adjustAlignment(offset, growUp, align);
|
2002-09-16 17:18:16 +02:00
|
|
|
size += abs(aligned - offset); // include alignment padding in size
|
2002-02-03 08:54:50 +01:00
|
|
|
|
2002-09-16 17:18:16 +02:00
|
|
|
incrementRegSpillsSize(size); // update size of reg. spills area
|
|
|
|
|
|
|
|
return aligned;
|
2002-02-03 08:54:50 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2002-12-28 21:37:16 +01:00
|
|
|
MachineFunctionInfo::pushTempValue(unsigned size)
|
2002-02-03 08:54:50 +01:00
|
|
|
{
|
2002-12-28 21:37:16 +01:00
|
|
|
unsigned align = SizeToAlignment(size, MF.getTarget());
|
2002-09-16 17:18:16 +02:00
|
|
|
|
2002-02-03 08:54:50 +01:00
|
|
|
bool growUp;
|
2002-12-28 21:37:16 +01:00
|
|
|
int firstOffset = MF.getTarget().getFrameInfo().getTmpAreaOffset(MF, growUp);
|
2002-09-16 17:18:16 +02:00
|
|
|
|
|
|
|
int offset = growUp? firstOffset + currentTmpValuesSize
|
|
|
|
: firstOffset - (currentTmpValuesSize + size);
|
|
|
|
|
2002-12-28 21:37:16 +01:00
|
|
|
int aligned = MF.getTarget().getFrameInfo().adjustAlignment(offset, growUp,
|
|
|
|
align);
|
2002-09-16 17:18:16 +02:00
|
|
|
size += abs(aligned - offset); // include alignment padding in size
|
|
|
|
|
|
|
|
incrementTmpAreaSize(size); // update "current" size of tmp area
|
|
|
|
|
|
|
|
return aligned;
|
2002-02-03 08:54:50 +01:00
|
|
|
}
|
|
|
|
|
2002-12-28 21:37:16 +01:00
|
|
|
void MachineFunctionInfo::popAllTempValues() {
|
2002-09-16 17:18:16 +02:00
|
|
|
resetTmpAreaSize(); // clear tmp area to reuse
|
2002-02-03 08:54:50 +01:00
|
|
|
}
|
|
|
|
|