2002-12-28 21:12:10 +01:00
|
|
|
//===-- llvm/Target/TargetFrameInfo.h ---------------------------*- C++ -*-===//
|
2003-10-20 22:19:47 +02: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.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
2002-08-09 22:08:06 +02:00
|
|
|
//
|
2002-12-28 21:12:10 +01:00
|
|
|
// Interface to describe the layout of a stack frame on the target machine.
|
2002-08-09 22:08:06 +02:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
2001-11-08 05:52:27 +01:00
|
|
|
|
2002-12-28 21:12:10 +01:00
|
|
|
#ifndef LLVM_TARGET_TARGETFRAMEINFO_H
|
|
|
|
#define LLVM_TARGET_TARGETFRAMEINFO_H
|
2001-11-08 05:52:27 +01:00
|
|
|
|
2004-08-12 21:01:55 +02:00
|
|
|
#include <utility>
|
|
|
|
|
2003-11-11 23:41:34 +01:00
|
|
|
namespace llvm {
|
|
|
|
|
2002-10-28 01:28:31 +01:00
|
|
|
class MachineFunction;
|
2001-11-08 05:52:27 +01:00
|
|
|
|
2004-06-08 08:23:17 +02: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 18:14:51 +02:00
|
|
|
class TargetFrameInfo {
|
|
|
|
public:
|
2002-12-28 21:12:10 +01: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 05:52:27 +01:00
|
|
|
public:
|
2002-12-28 21:12:10 +01:00
|
|
|
TargetFrameInfo(StackDirection D, unsigned StackAl, int LAO)
|
|
|
|
: StackDir(D), StackAlignment(StackAl), LocalAreaOffset(LAO) {}
|
|
|
|
|
|
|
|
// 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 21:01:55 +02: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.
|
|
|
|
///
|
2004-08-15 11:18:55 +02:00
|
|
|
virtual const std::pair<unsigned, int> *
|
2004-08-12 21:01:55 +02:00
|
|
|
getCalleeSaveSpillSlots(unsigned &NumEntries) const {
|
|
|
|
NumEntries = 0;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2002-12-28 21:12:10 +01:00
|
|
|
//===--------------------------------------------------------------------===//
|
|
|
|
// These methods provide details of the stack frame used by Sparc, thus they
|
|
|
|
// are Sparc specific.
|
|
|
|
//===--------------------------------------------------------------------===//
|
|
|
|
|
2002-09-16 17:57:43 +02:00
|
|
|
// This method adjusts a stack offset to meet alignment rules of target.
|
2002-12-28 21:12:10 +01:00
|
|
|
virtual int adjustAlignment(int unalignedOffset, bool growUp,
|
2004-03-12 00:52:03 +01:00
|
|
|
unsigned align) const;
|
2002-09-16 17:57:43 +02:00
|
|
|
|
2002-12-28 21:12:10 +01: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.
|
2001-11-08 05:52:27 +01:00
|
|
|
//
|
2002-10-28 01:28:31 +01:00
|
|
|
virtual int getIncomingArgOffset (MachineFunction& mcInfo,
|
2004-03-12 00:52:03 +01:00
|
|
|
unsigned argNum) const;
|
2002-10-28 01:28:31 +01:00
|
|
|
virtual int getOutgoingArgOffset (MachineFunction& mcInfo,
|
2004-03-12 00:52:03 +01:00
|
|
|
unsigned argNum) const;
|
2002-04-25 06:48:54 +02:00
|
|
|
|
2002-10-28 01:28:31 +01:00
|
|
|
virtual int getFirstAutomaticVarOffset (MachineFunction& mcInfo,
|
2004-03-12 00:52:03 +01:00
|
|
|
bool& growUp) const;
|
2002-10-28 01:28:31 +01:00
|
|
|
virtual int getRegSpillAreaOffset (MachineFunction& mcInfo,
|
2004-03-12 00:52:03 +01:00
|
|
|
bool& growUp) const;
|
2002-10-28 01:28:31 +01:00
|
|
|
virtual int getTmpAreaOffset (MachineFunction& mcInfo,
|
2004-03-12 00:52:03 +01:00
|
|
|
bool& growUp) const;
|
2002-10-28 01:28:31 +01:00
|
|
|
virtual int getDynamicAreaOffset (MachineFunction& mcInfo,
|
2004-03-12 00:52:03 +01:00
|
|
|
bool& growUp) const;
|
2001-11-08 05:52:27 +01:00
|
|
|
};
|
|
|
|
|
2003-11-11 23:41:34 +01:00
|
|
|
} // End llvm namespace
|
|
|
|
|
2001-11-08 05:52:27 +01:00
|
|
|
#endif
|