From: Vikram S. Adve Date: Thu, 25 Apr 2002 04:35:27 +0000 (+0000) Subject: Implementation of class MachineFrameInfo. X-Git-Url: http://plrg.eecs.uci.edu/git/?a=commitdiff_plain;h=a4a943dd5a5af56bb6d050a0a47f947d4b179420;p=oota-llvm.git Implementation of class MachineFrameInfo. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@2313 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Target/MachineFrameInfo.cpp b/lib/Target/MachineFrameInfo.cpp new file mode 100644 index 00000000000..be7feee5eec --- /dev/null +++ b/lib/Target/MachineFrameInfo.cpp @@ -0,0 +1,50 @@ +// $Id$ -*-c++-*- +//*************************************************************************** +// File: +// MachineFrameInfo.cpp +// +// Purpose: +// 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. +// +// History: +// 4/17/02 - Vikram Adve - Created +//**************************************************************************/ + + +#include "llvm/Target/MachineFrameInfo.h" +#include "llvm/CodeGen/MachineCodeForMethod.h" + + +int +MachineFrameInfo::getIncomingArgOffset(MachineCodeForMethod& 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(MachineCodeForMethod& 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; +}