summaryrefslogtreecommitdiff
path: root/lib/Target/PowerPC/PPCFrameInfo.h
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2007-02-25 05:34:32 +0000
committerChris Lattner <sabre@nondot.org>2007-02-25 05:34:32 +0000
commit9f0bc659c8d2f1e401a9690e4900b0fd2a70bdfe (patch)
tree4e65cf82f1e9e276a5f2194e53b67e1e78d018c0 /lib/Target/PowerPC/PPCFrameInfo.h
parenteb95d41cd364f3526d1c39455a0131185495c51a (diff)
downloadllvm-9f0bc659c8d2f1e401a9690e4900b0fd2a70bdfe.tar.gz
llvm-9f0bc659c8d2f1e401a9690e4900b0fd2a70bdfe.tar.bz2
llvm-9f0bc659c8d2f1e401a9690e4900b0fd2a70bdfe.tar.xz
implement support for the linux/ppc function call ABI. Patch by
Nicolas Geoffray! git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34574 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Target/PowerPC/PPCFrameInfo.h')
-rw-r--r--lib/Target/PowerPC/PPCFrameInfo.h50
1 files changed, 35 insertions, 15 deletions
diff --git a/lib/Target/PowerPC/PPCFrameInfo.h b/lib/Target/PowerPC/PPCFrameInfo.h
index 22b945ea20..0c72824730 100644
--- a/lib/Target/PowerPC/PPCFrameInfo.h
+++ b/lib/Target/PowerPC/PPCFrameInfo.h
@@ -29,41 +29,61 @@ public:
/// getReturnSaveOffset - Return the previous frame offset to save the
/// return address.
- static unsigned getReturnSaveOffset(bool LP64) {
- return LP64 ? 16 : 8;
+ static unsigned getReturnSaveOffset(bool LP64, bool isMacho) {
+ if (isMacho)
+ return LP64 ? 16 : 8;
+ // For ELF ABI:
+ return LP64 ? 8 : 4;
}
/// getFramePointerSaveOffset - Return the previous frame offset to save the
/// frame pointer.
- static unsigned getFramePointerSaveOffset(bool LP64) {
+ static unsigned getFramePointerSaveOffset(bool LP64, bool isMacho) {
+ // For MachO ABI:
// Use the TOC save slot in the PowerPC linkage area for saving the frame
// pointer (if needed.) LLVM does not generate code that uses the TOC (R2
// is treated as a caller saved register.)
- return LP64 ? 40 : 20;
+ if (isMacho)
+ return LP64 ? 40 : 20;
+
+ // For ELF ABI:
+ // Save it right before the link register
+ return LP64 ? -8 : -4;
}
/// getLinkageSize - Return the size of the PowerPC ABI linkage area.
///
- static unsigned getLinkageSize(bool LP64) {
- return 6 * (LP64 ? 8 : 4);
+ static unsigned getLinkageSize(bool LP64, bool isMacho) {
+ if (isMacho)
+ return 6 * (LP64 ? 8 : 4);
+
+ // For ELF ABI:
+ return LP64 ? 16 : 8;
}
/// getMinCallArgumentsSize - Return the size of the minium PowerPC ABI
/// argument area.
- static unsigned getMinCallArgumentsSize(bool LP64) {
- // The prolog code of the callee may store up to 8 GPR argument registers to
- // the stack, allowing va_start to index over them in memory if its varargs.
- // Because we cannot tell if this is needed on the caller side, we have to
- // conservatively assume that it is needed. As such, make sure we have at
- // least enough stack space for the caller to store the 8 GPRs.
- return 8 * (LP64 ? 8 : 4);
+ static unsigned getMinCallArgumentsSize(bool LP64, bool isMacho) {
+ // For Macho ABI:
+ // The prolog code of the callee may store up to 8 GPR argument registers to
+ // the stack, allowing va_start to index over them in memory if its varargs.
+ // Because we cannot tell if this is needed on the caller side, we have to
+ // conservatively assume that it is needed. As such, make sure we have at
+ // least enough stack space for the caller to store the 8 GPRs.
+ if (isMacho)
+ return 8 * (LP64 ? 8 : 4);
+
+ // For Linux ABI:
+ // There is no default stack allocated for the 8 first GPR arguments.
+ return 0;
}
/// getMinCallFrameSize - Return the minimum size a call frame can be using
/// the PowerPC ABI.
- static unsigned getMinCallFrameSize(bool LP64) {
+ static unsigned getMinCallFrameSize(bool LP64, bool isMacho) {
// The call frame needs to be at least big enough for linkage and 8 args.
- return getLinkageSize(LP64) + getMinCallArgumentsSize(LP64);
+ return getLinkageSize(LP64, isMacho) +
+ getMinCallArgumentsSize(LP64, isMacho);
}
};