Vikram S. Adve | a4a943d | 2002-04-25 04:35:27 +0000 | [diff] [blame^] | 1 | // $Id$ -*-c++-*- |
| 2 | //*************************************************************************** |
| 3 | // File: |
| 4 | // MachineFrameInfo.cpp |
| 5 | // |
| 6 | // Purpose: |
| 7 | // Interface to layout of stack frame on target machine. |
| 8 | // Most functions of class MachineFrameInfo have to be machine-specific |
| 9 | // so there is little code here. |
| 10 | // |
| 11 | // History: |
| 12 | // 4/17/02 - Vikram Adve - Created |
| 13 | //**************************************************************************/ |
| 14 | |
| 15 | |
| 16 | #include "llvm/Target/MachineFrameInfo.h" |
| 17 | #include "llvm/CodeGen/MachineCodeForMethod.h" |
| 18 | |
| 19 | |
| 20 | int |
| 21 | MachineFrameInfo::getIncomingArgOffset(MachineCodeForMethod& mcInfo, |
| 22 | unsigned argNum) const |
| 23 | { |
| 24 | assert(argsOnStackHaveFixedSize()); |
| 25 | |
| 26 | unsigned relativeOffset = argNum * getSizeOfEachArgOnStack(); |
| 27 | bool growUp; // do args grow up or down |
| 28 | int firstArg = getFirstIncomingArgOffset(mcInfo, growUp); |
| 29 | int offset = growUp? firstArg + relativeOffset |
| 30 | : firstArg - relativeOffset; |
| 31 | return offset; |
| 32 | } |
| 33 | |
| 34 | |
| 35 | int |
| 36 | MachineFrameInfo::getOutgoingArgOffset(MachineCodeForMethod& mcInfo, |
| 37 | unsigned argNum) const |
| 38 | { |
| 39 | assert(argsOnStackHaveFixedSize()); |
| 40 | assert(((int) argNum - this->getNumFixedOutgoingArgs()) |
| 41 | <= (int) mcInfo.getMaxOptionalNumArgs()); |
| 42 | |
| 43 | unsigned relativeOffset = argNum * getSizeOfEachArgOnStack(); |
| 44 | bool growUp; // do args grow up or down |
| 45 | int firstArg = getFirstOutgoingArgOffset(mcInfo, growUp); |
| 46 | int offset = growUp? firstArg + relativeOffset |
| 47 | : firstArg - relativeOffset; |
| 48 | |
| 49 | return offset; |
| 50 | } |