aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Target/MachineFrameInfo.cpp
blob: 4d2fab230e53d309fc539cc3ad1ca4ceee642593 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
//===-- MachineFrameInfo.cpp-----------------------------------------------===//
// 
// 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.
// 
//===----------------------------------------------------------------------===//

#include "llvm/Target/MachineFrameInfo.h"
#include "llvm/CodeGen/MachineFunction.h"

int
MachineFrameInfo::getIncomingArgOffset(MachineFunction& mcInfo,
                                       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
MachineFrameInfo::getOutgoingArgOffset(MachineFunction& mcInfo,
                                       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; 
}