2002-08-09 20:08:03 +00:00
|
|
|
//===-- MachineFrameInfo.cpp-----------------------------------------------===//
|
2002-04-25 04:35:27 +00:00
|
|
|
//
|
2002-08-09 20:08:03 +00: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 04:35:27 +00:00
|
|
|
//
|
2002-08-09 20:08:03 +00:00
|
|
|
//===----------------------------------------------------------------------===//
|
2002-04-25 04:35:27 +00:00
|
|
|
|
|
|
|
#include "llvm/Target/MachineFrameInfo.h"
|
2002-10-28 00:28:31 +00:00
|
|
|
#include "llvm/CodeGen/MachineFunction.h"
|
2002-04-25 04:35:27 +00:00
|
|
|
|
|
|
|
int
|
2002-10-28 00:28:31 +00:00
|
|
|
MachineFrameInfo::getIncomingArgOffset(MachineFunction& mcInfo,
|
2002-04-25 04:35:27 +00: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 00:28:31 +00:00
|
|
|
MachineFrameInfo::getOutgoingArgOffset(MachineFunction& mcInfo,
|
2002-04-25 04:35:27 +00: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;
|
|
|
|
}
|