2002-12-28 20:12:10 +00:00
|
|
|
//===-- llvm/Target/TargetFrameInfo.h ---------------------------*- C++ -*-===//
|
2005-04-21 20:59:05 +00:00
|
|
|
//
|
2003-10-20 20:19:47 +00:00
|
|
|
// 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.
|
2005-04-21 20:59:05 +00:00
|
|
|
//
|
2003-10-20 20:19:47 +00:00
|
|
|
//===----------------------------------------------------------------------===//
|
2002-08-09 20:08:06 +00:00
|
|
|
//
|
2002-12-28 20:12:10 +00:00
|
|
|
// Interface to describe the layout of a stack frame on the target machine.
|
2002-08-09 20:08:06 +00:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
2001-11-08 04:52:27 +00:00
|
|
|
|
2002-12-28 20:12:10 +00:00
|
|
|
#ifndef LLVM_TARGET_TARGETFRAMEINFO_H
|
|
|
|
#define LLVM_TARGET_TARGETFRAMEINFO_H
|
2001-11-08 04:52:27 +00:00
|
|
|
|
2004-08-12 19:01:55 +00:00
|
|
|
#include <utility>
|
|
|
|
|
2003-11-11 22:41:34 +00:00
|
|
|
namespace llvm {
|
|
|
|
|
2002-10-28 00:28:31 +00:00
|
|
|
class MachineFunction;
|
2001-11-08 04:52:27 +00:00
|
|
|
|
2004-06-08 06:23:17 +00:00
|
|
|
/// Information about stack frame layout on the target. It holds the direction
|
|
|
|
/// of stack growth, the known stack alignment on entry to each function, and
|
|
|
|
/// the offset to the locals area.
|
|
|
|
///
|
|
|
|
/// The offset to the local area is the offset from the stack pointer on
|
|
|
|
/// function entry to the first location where function data (local variables,
|
|
|
|
/// spill locations) can be stored.
|
2004-10-27 16:14:51 +00:00
|
|
|
class TargetFrameInfo {
|
|
|
|
public:
|
2002-12-28 20:12:10 +00:00
|
|
|
enum StackDirection {
|
|
|
|
StackGrowsUp, // Adding to the stack increases the stack address
|
|
|
|
StackGrowsDown // Adding to the stack decreases the stack address
|
|
|
|
};
|
|
|
|
private:
|
|
|
|
StackDirection StackDir;
|
|
|
|
unsigned StackAlignment;
|
|
|
|
int LocalAreaOffset;
|
2001-11-08 04:52:27 +00:00
|
|
|
public:
|
2002-12-28 20:12:10 +00:00
|
|
|
TargetFrameInfo(StackDirection D, unsigned StackAl, int LAO)
|
|
|
|
: StackDir(D), StackAlignment(StackAl), LocalAreaOffset(LAO) {}
|
|
|
|
|
2005-04-25 02:55:55 +00:00
|
|
|
virtual ~TargetFrameInfo();
|
|
|
|
|
2002-12-28 20:12:10 +00:00
|
|
|
// These methods return information that describes the abstract stack layout
|
|
|
|
// of the target machine.
|
|
|
|
|
|
|
|
/// getStackGrowthDirection - Return the direction the stack grows
|
|
|
|
///
|
|
|
|
StackDirection getStackGrowthDirection() const { return StackDir; }
|
|
|
|
|
|
|
|
/// getStackAlignment - This method returns the number of bytes that the stack
|
|
|
|
/// pointer must be aligned to. Typically, this is the largest alignment for
|
|
|
|
/// any data object in the target.
|
|
|
|
///
|
|
|
|
unsigned getStackAlignment() const { return StackAlignment; }
|
|
|
|
|
|
|
|
/// getOffsetOfLocalArea - This method returns the offset of the local area
|
|
|
|
/// from the stack pointer on entrance to a function.
|
|
|
|
///
|
|
|
|
int getOffsetOfLocalArea() const { return LocalAreaOffset; }
|
|
|
|
|
2004-08-12 19:01:55 +00:00
|
|
|
/// getCalleeSaveSpillSlots - This method returns a pointer to an array of
|
|
|
|
/// pairs, that contains an entry for each callee save register that must be
|
|
|
|
/// spilled to a particular stack location if it is spilled.
|
|
|
|
///
|
|
|
|
/// Each entry in this array contains a <register,offset> pair, indicating the
|
|
|
|
/// fixed offset from the incoming stack pointer that each register should be
|
|
|
|
/// spilled at. If a register is not listed here, the code generator is
|
|
|
|
/// allowed to spill it anywhere it chooses.
|
2005-04-21 20:59:05 +00:00
|
|
|
///
|
2004-08-15 09:18:55 +00:00
|
|
|
virtual const std::pair<unsigned, int> *
|
2004-08-12 19:01:55 +00:00
|
|
|
getCalleeSaveSpillSlots(unsigned &NumEntries) const {
|
|
|
|
NumEntries = 0;
|
|
|
|
return 0;
|
|
|
|
}
|
2005-04-21 20:59:05 +00:00
|
|
|
|
2002-12-28 20:12:10 +00:00
|
|
|
//===--------------------------------------------------------------------===//
|
|
|
|
// These methods provide details of the stack frame used by Sparc, thus they
|
|
|
|
// are Sparc specific.
|
|
|
|
//===--------------------------------------------------------------------===//
|
|
|
|
|
2002-09-16 15:57:43 +00:00
|
|
|
// This method adjusts a stack offset to meet alignment rules of target.
|
2002-12-28 20:12:10 +00:00
|
|
|
virtual int adjustAlignment(int unalignedOffset, bool growUp,
|
2005-04-22 03:46:24 +00:00
|
|
|
unsigned align) const;
|
2002-09-16 15:57:43 +00:00
|
|
|
|
2002-12-28 20:12:10 +00:00
|
|
|
// These methods compute offsets using the frame contents for a particular
|
|
|
|
// function. The frame contents are obtained from the MachineFunction object
|
|
|
|
// for the given function. The rest must be implemented by the
|
|
|
|
// machine-specific subclass.
|
2005-04-21 20:59:05 +00:00
|
|
|
//
|
2005-04-22 03:46:24 +00:00
|
|
|
virtual int getIncomingArgOffset(MachineFunction& mcInfo,
|
|
|
|
unsigned argNum) const;
|
|
|
|
virtual int getOutgoingArgOffset(MachineFunction& mcInfo,
|
|
|
|
unsigned argNum) const;
|
|
|
|
virtual int getFirstAutomaticVarOffset(MachineFunction& mcInfo,
|
|
|
|
bool& growUp) const;
|
|
|
|
virtual int getRegSpillAreaOffset(MachineFunction& mcInfo,
|
|
|
|
bool& growUp) const;
|
|
|
|
virtual int getTmpAreaOffset(MachineFunction& mcInfo, bool& growUp) const;
|
|
|
|
virtual int getDynamicAreaOffset(MachineFunction& mcInfo, bool& growUp) const;
|
2001-11-08 04:52:27 +00:00
|
|
|
};
|
|
|
|
|
2003-11-11 22:41:34 +00:00
|
|
|
} // End llvm namespace
|
|
|
|
|
2001-11-08 04:52:27 +00:00
|
|
|
#endif
|