diff options
author | Misha Brukman <brukman+llvm@gmail.com> | 2003-12-17 22:04:00 +0000 |
---|---|---|
committer | Misha Brukman <brukman+llvm@gmail.com> | 2003-12-17 22:04:00 +0000 |
commit | d71295a684fb351e196f4f78ea94e5d1af904eb8 (patch) | |
tree | ebc260c7a6036eb8c698cd062804a8beacbc9e31 /lib/Target/SparcV9/SparcV9FrameInfo.cpp | |
parent | 3e7ada642a00c6904231f2446b33c7f15bb45151 (diff) |
Reorganized the Sparc backend to be more modular -- each different
implementation of a Target{RegInfo, InstrInfo, Machine, etc} now has a separate
header and a separate implementation file.
This means that instead of a massive SparcInternals.h that forces a
recompilation of the whole target whenever a minor detail is changed, you should
only recompile a few files.
Note that SparcInternals.h is still around; its contents should be minimized.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@10500 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Target/SparcV9/SparcV9FrameInfo.cpp')
-rw-r--r-- | lib/Target/SparcV9/SparcV9FrameInfo.cpp | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/lib/Target/SparcV9/SparcV9FrameInfo.cpp b/lib/Target/SparcV9/SparcV9FrameInfo.cpp new file mode 100644 index 0000000000..d283e942bb --- /dev/null +++ b/lib/Target/SparcV9/SparcV9FrameInfo.cpp @@ -0,0 +1,65 @@ +//===-- Sparc.cpp - General implementation file for the Sparc Target ------===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// Interface to stack frame layout info for the UltraSPARC. Starting offsets +// for each area of the stack frame are aligned at a multiple of +// getStackFrameSizeAlignment(). +// +//===----------------------------------------------------------------------===// + +#include "llvm/CodeGen/MachineFunction.h" +#include "llvm/CodeGen/MachineFunctionInfo.h" +#include "llvm/Target/TargetFrameInfo.h" +#include "SparcFrameInfo.h" + +using namespace llvm; + +int +SparcFrameInfo::getFirstAutomaticVarOffset(MachineFunction&, bool& pos) const { + pos = false; // static stack area grows downwards + return StaticAreaOffsetFromFP; +} + +int +SparcFrameInfo::getRegSpillAreaOffset(MachineFunction& mcInfo, bool& pos) const +{ + // ensure no more auto vars are added + mcInfo.getInfo()->freezeAutomaticVarsArea(); + + pos = false; // static stack area grows downwards + unsigned autoVarsSize = mcInfo.getInfo()->getAutomaticVarsSize(); + return StaticAreaOffsetFromFP - autoVarsSize; +} + +int SparcFrameInfo::getTmpAreaOffset(MachineFunction& mcInfo, bool& pos) const { + MachineFunctionInfo *MFI = mcInfo.getInfo(); + MFI->freezeAutomaticVarsArea(); // ensure no more auto vars are added + MFI->freezeSpillsArea(); // ensure no more spill slots are added + + pos = false; // static stack area grows downwards + unsigned autoVarsSize = MFI->getAutomaticVarsSize(); + unsigned spillAreaSize = MFI->getRegSpillsSize(); + int offset = autoVarsSize + spillAreaSize; + return StaticAreaOffsetFromFP - offset; +} + +int +SparcFrameInfo::getDynamicAreaOffset(MachineFunction& mcInfo, bool& pos) const { + // Dynamic stack area grows downwards starting at top of opt-args area. + // The opt-args, required-args, and register-save areas are empty except + // during calls and traps, so they are shifted downwards on each + // dynamic-size alloca. + pos = false; + unsigned optArgsSize = mcInfo.getInfo()->getMaxOptionalArgsSize(); + if (int extra = optArgsSize % getStackFrameSizeAlignment()) + optArgsSize += (getStackFrameSizeAlignment() - extra); + int offset = optArgsSize + FirstOptionalOutgoingArgOffsetFromSP; + assert((offset - OFFSET) % getStackFrameSizeAlignment() == 0); + return offset; +} |