2002-08-09 22:08:03 +02:00
|
|
|
//===-- MachineFrameInfo.cpp-----------------------------------------------===//
|
2002-04-25 06:35:27 +02:00
|
|
|
//
|
2002-08-09 22:08:03 +02:00
|
|
|
// Interface to layout of stack frame on target machine. Most functions of
|
|
|
|
// class MachineFrameInfo have to be machine-specific so there is little code
|
|
|
|
// here.
|
2002-04-25 06:35:27 +02:00
|
|
|
//
|
2002-08-09 22:08:03 +02:00
|
|
|
//===----------------------------------------------------------------------===//
|
2002-04-25 06:35:27 +02:00
|
|
|
|
|
|
|
#include "llvm/Target/MachineFrameInfo.h"
|
2002-10-28 01:28:31 +01:00
|
|
|
#include "llvm/CodeGen/MachineFunction.h"
|
2002-04-25 06:35:27 +02:00
|
|
|
|
|
|
|
int
|
2002-10-28 01:28:31 +01:00
|
|
|
MachineFrameInfo::getIncomingArgOffset(MachineFunction& mcInfo,
|
2002-04-25 06:35:27 +02:00
|
|
|
unsigned argNum) const
|
|
|
|
{
|
|
|
|
assert(argsOnStackHaveFixedSize());
|
|
|
|
|
|
|
|
unsigned relativeOffset = argNum * getSizeOfEachArgOnStack();
|
|
|
|
bool growUp; // do args grow up or down
|
|
|
|
int firstArg = getFirstIncomingArgOffset(mcInfo, growUp);
|
|
|
|
int offset = growUp? firstArg + relativeOffset
|
|
|
|
: firstArg - relativeOffset;
|
|
|
|
return offset;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int
|
2002-10-28 01:28:31 +01:00
|
|
|
MachineFrameInfo::getOutgoingArgOffset(MachineFunction& mcInfo,
|
2002-04-25 06:35:27 +02:00
|
|
|
unsigned argNum) const
|
|
|
|
{
|
|
|
|
assert(argsOnStackHaveFixedSize());
|
|
|
|
assert(((int) argNum - this->getNumFixedOutgoingArgs())
|
|
|
|
<= (int) mcInfo.getMaxOptionalNumArgs());
|
|
|
|
|
|
|
|
unsigned relativeOffset = argNum * getSizeOfEachArgOnStack();
|
|
|
|
bool growUp; // do args grow up or down
|
|
|
|
int firstArg = getFirstOutgoingArgOffset(mcInfo, growUp);
|
|
|
|
int offset = growUp? firstArg + relativeOffset
|
|
|
|
: firstArg - relativeOffset;
|
|
|
|
|
|
|
|
return offset;
|
|
|
|
}
|