2005-10-16 05:39:50 +00:00
|
|
|
//===-- PPCFrameInfo.h - Define TargetFrameInfo for PowerPC -----*- C++ -*-===//
|
2005-04-21 23:30:14 +00:00
|
|
|
//
|
2004-08-14 22:16:36 +00:00
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
2007-12-29 20:36:04 +00:00
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
2005-04-21 23:30:14 +00:00
|
|
|
//
|
2004-08-14 22:16:36 +00:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
//
|
2005-10-16 05:39:50 +00:00
|
|
|
//===----------------------------------------------------------------------===//
|
2004-08-14 22:16:36 +00:00
|
|
|
|
|
|
|
#ifndef POWERPC_FRAMEINFO_H
|
|
|
|
#define POWERPC_FRAMEINFO_H
|
|
|
|
|
2005-10-14 23:51:18 +00:00
|
|
|
#include "PPC.h"
|
2004-08-14 22:16:36 +00:00
|
|
|
#include "llvm/Target/TargetFrameInfo.h"
|
|
|
|
#include "llvm/Target/TargetMachine.h"
|
|
|
|
|
|
|
|
namespace llvm {
|
|
|
|
|
2005-10-16 05:39:50 +00:00
|
|
|
class PPCFrameInfo: public TargetFrameInfo {
|
2004-08-14 22:16:36 +00:00
|
|
|
const TargetMachine &TM;
|
2005-04-21 23:30:14 +00:00
|
|
|
|
2004-08-14 22:16:36 +00:00
|
|
|
public:
|
2005-10-16 05:39:50 +00:00
|
|
|
PPCFrameInfo(const TargetMachine &tm, bool LP64)
|
2004-08-17 05:09:39 +00:00
|
|
|
: TargetFrameInfo(TargetFrameInfo::StackGrowsDown, 16, 0), TM(tm) {
|
2004-08-14 22:16:36 +00:00
|
|
|
}
|
|
|
|
|
2006-12-06 17:42:06 +00:00
|
|
|
/// getReturnSaveOffset - Return the previous frame offset to save the
|
|
|
|
/// return address.
|
2007-02-25 05:34:32 +00:00
|
|
|
static unsigned getReturnSaveOffset(bool LP64, bool isMacho) {
|
|
|
|
if (isMacho)
|
|
|
|
return LP64 ? 16 : 8;
|
2007-04-03 12:35:28 +00:00
|
|
|
// For ELF 32 ABI:
|
|
|
|
return 4;
|
2004-08-14 22:16:36 +00:00
|
|
|
}
|
2006-12-06 17:42:06 +00:00
|
|
|
|
2006-11-16 22:43:37 +00:00
|
|
|
/// getFramePointerSaveOffset - Return the previous frame offset to save the
|
|
|
|
/// frame pointer.
|
2007-02-25 05:34:32 +00:00
|
|
|
static unsigned getFramePointerSaveOffset(bool LP64, bool isMacho) {
|
|
|
|
// For MachO ABI:
|
2006-11-16 22:43:37 +00:00
|
|
|
// 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.)
|
2007-02-25 05:34:32 +00:00
|
|
|
if (isMacho)
|
|
|
|
return LP64 ? 40 : 20;
|
|
|
|
|
2007-04-03 12:35:28 +00:00
|
|
|
// For ELF 32 ABI:
|
2007-02-25 05:34:32 +00:00
|
|
|
// Save it right before the link register
|
2007-04-04 22:07:24 +00:00
|
|
|
return -4U;
|
2006-11-16 22:43:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/// getLinkageSize - Return the size of the PowerPC ABI linkage area.
|
|
|
|
///
|
2007-02-25 05:34:32 +00:00
|
|
|
static unsigned getLinkageSize(bool LP64, bool isMacho) {
|
|
|
|
if (isMacho)
|
|
|
|
return 6 * (LP64 ? 8 : 4);
|
|
|
|
|
2007-04-03 12:35:28 +00:00
|
|
|
// For ELF 32 ABI:
|
|
|
|
return 8;
|
2006-11-16 22:43:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/// getMinCallArgumentsSize - Return the size of the minium PowerPC ABI
|
|
|
|
/// argument area.
|
2007-02-25 05:34:32 +00:00
|
|
|
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);
|
|
|
|
|
2007-04-03 12:35:28 +00:00
|
|
|
// For ELF 32 ABI:
|
2007-02-25 05:34:32 +00:00
|
|
|
// There is no default stack allocated for the 8 first GPR arguments.
|
|
|
|
return 0;
|
2006-11-16 22:43:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/// getMinCallFrameSize - Return the minimum size a call frame can be using
|
|
|
|
/// the PowerPC ABI.
|
2007-02-25 05:34:32 +00:00
|
|
|
static unsigned getMinCallFrameSize(bool LP64, bool isMacho) {
|
2006-11-16 22:43:37 +00:00
|
|
|
// The call frame needs to be at least big enough for linkage and 8 args.
|
2007-02-25 05:34:32 +00:00
|
|
|
return getLinkageSize(LP64, isMacho) +
|
|
|
|
getMinCallArgumentsSize(LP64, isMacho);
|
2006-11-16 22:43:37 +00:00
|
|
|
}
|
|
|
|
|
2004-08-14 22:16:36 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
} // End llvm namespace
|
|
|
|
|
|
|
|
#endif
|