1 //===-- llvm/Target/TargetFrameInfo.h ---------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file was developed by the LLVM research group and is distributed under
6 // the University of Illinois Open Source License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // Interface to describe the layout of a stack frame on the target machine.
12 //===----------------------------------------------------------------------===//
14 #ifndef LLVM_TARGET_TARGETFRAMEINFO_H
15 #define LLVM_TARGET_TARGETFRAMEINFO_H
21 class MachineFunction;
23 /// Information about stack frame layout on the target. It holds the direction
24 /// of stack growth, the known stack alignment on entry to each function, and
25 /// the offset to the locals area.
27 /// The offset to the local area is the offset from the stack pointer on
28 /// function entry to the first location where function data (local variables,
29 /// spill locations) can be stored.
30 class TargetFrameInfo {
33 StackGrowsUp, // Adding to the stack increases the stack address
34 StackGrowsDown // Adding to the stack decreases the stack address
37 StackDirection StackDir;
38 unsigned StackAlignment;
41 TargetFrameInfo(StackDirection D, unsigned StackAl, int LAO)
42 : StackDir(D), StackAlignment(StackAl), LocalAreaOffset(LAO) {}
44 // These methods return information that describes the abstract stack layout
45 // of the target machine.
47 /// getStackGrowthDirection - Return the direction the stack grows
49 StackDirection getStackGrowthDirection() const { return StackDir; }
51 /// getStackAlignment - This method returns the number of bytes that the stack
52 /// pointer must be aligned to. Typically, this is the largest alignment for
53 /// any data object in the target.
55 unsigned getStackAlignment() const { return StackAlignment; }
57 /// getOffsetOfLocalArea - This method returns the offset of the local area
58 /// from the stack pointer on entrance to a function.
60 int getOffsetOfLocalArea() const { return LocalAreaOffset; }
62 /// getCalleeSaveSpillSlots - This method returns a pointer to an array of
63 /// pairs, that contains an entry for each callee save register that must be
64 /// spilled to a particular stack location if it is spilled.
66 /// Each entry in this array contains a <register,offset> pair, indicating the
67 /// fixed offset from the incoming stack pointer that each register should be
68 /// spilled at. If a register is not listed here, the code generator is
69 /// allowed to spill it anywhere it chooses.
71 virtual const std::pair<unsigned, int> *
72 getCalleeSaveSpillSlots(unsigned &NumEntries) const {
77 //===--------------------------------------------------------------------===//
78 // These methods provide details of the stack frame used by Sparc, thus they
79 // are Sparc specific.
80 //===--------------------------------------------------------------------===//
82 // This method adjusts a stack offset to meet alignment rules of target.
83 virtual int adjustAlignment(int unalignedOffset, bool growUp,
84 unsigned align) const;
86 // These methods compute offsets using the frame contents for a particular
87 // function. The frame contents are obtained from the MachineFunction object
88 // for the given function. The rest must be implemented by the
89 // machine-specific subclass.
91 virtual int getIncomingArgOffset (MachineFunction& mcInfo,
92 unsigned argNum) const;
93 virtual int getOutgoingArgOffset (MachineFunction& mcInfo,
94 unsigned argNum) const;
96 virtual int getFirstAutomaticVarOffset (MachineFunction& mcInfo,
98 virtual int getRegSpillAreaOffset (MachineFunction& mcInfo,
100 virtual int getTmpAreaOffset (MachineFunction& mcInfo,
102 virtual int getDynamicAreaOffset (MachineFunction& mcInfo,
106 } // End llvm namespace