blob: 0eeacbc2b0ae7b0718a83a8adfd7ab0785085a21 [file] [log] [blame]
Chris Lattner179cdfb2002-08-09 20:08:03 +00001//===-- MachineFrameInfo.cpp-----------------------------------------------===//
Vikram S. Advea4a943d2002-04-25 04:35:27 +00002//
Chris Lattner179cdfb2002-08-09 20:08:03 +00003// Interface to layout of stack frame on target machine. Most functions of
4// class MachineFrameInfo have to be machine-specific so there is little code
5// here.
Vikram S. Advea4a943d2002-04-25 04:35:27 +00006//
Chris Lattner179cdfb2002-08-09 20:08:03 +00007//===----------------------------------------------------------------------===//
Vikram S. Advea4a943d2002-04-25 04:35:27 +00008
9#include "llvm/Target/MachineFrameInfo.h"
10#include "llvm/CodeGen/MachineCodeForMethod.h"
11
Vikram S. Advea4a943d2002-04-25 04:35:27 +000012int
13MachineFrameInfo::getIncomingArgOffset(MachineCodeForMethod& mcInfo,
14 unsigned argNum) const
15{
16 assert(argsOnStackHaveFixedSize());
17
18 unsigned relativeOffset = argNum * getSizeOfEachArgOnStack();
19 bool growUp; // do args grow up or down
20 int firstArg = getFirstIncomingArgOffset(mcInfo, growUp);
21 int offset = growUp? firstArg + relativeOffset
22 : firstArg - relativeOffset;
23 return offset;
24}
25
26
27int
28MachineFrameInfo::getOutgoingArgOffset(MachineCodeForMethod& mcInfo,
29 unsigned argNum) const
30{
31 assert(argsOnStackHaveFixedSize());
32 assert(((int) argNum - this->getNumFixedOutgoingArgs())
33 <= (int) mcInfo.getMaxOptionalNumArgs());
34
35 unsigned relativeOffset = argNum * getSizeOfEachArgOnStack();
36 bool growUp; // do args grow up or down
37 int firstArg = getFirstOutgoingArgOffset(mcInfo, growUp);
38 int offset = growUp? firstArg + relativeOffset
39 : firstArg - relativeOffset;
40
41 return offset;
42}