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
19 class MachineFunction;
21 /// Information about stack frame layout on the target. It holds the direction
22 /// of stack growth, the known stack alignment on entry to each function, and
23 /// the offset to the locals area.
25 /// The offset to the local area is the offset from the stack pointer on
26 /// function entry to the first location where function data (local variables,
27 /// spill locations) can be stored.
28 struct TargetFrameInfo {
30 StackGrowsUp, // Adding to the stack increases the stack address
31 StackGrowsDown // Adding to the stack decreases the stack address
34 StackDirection StackDir;
35 unsigned StackAlignment;
38 TargetFrameInfo(StackDirection D, unsigned StackAl, int LAO)
39 : StackDir(D), StackAlignment(StackAl), LocalAreaOffset(LAO) {}
41 // These methods return information that describes the abstract stack layout
42 // of the target machine.
44 /// getStackGrowthDirection - Return the direction the stack grows
46 StackDirection getStackGrowthDirection() const { return StackDir; }
48 /// getStackAlignment - This method returns the number of bytes that the stack
49 /// pointer must be aligned to. Typically, this is the largest alignment for
50 /// any data object in the target.
52 unsigned getStackAlignment() const { return StackAlignment; }
54 /// getOffsetOfLocalArea - This method returns the offset of the local area
55 /// from the stack pointer on entrance to a function.
57 int getOffsetOfLocalArea() const { return LocalAreaOffset; }
59 //===--------------------------------------------------------------------===//
60 // These methods provide details of the stack frame used by Sparc, thus they
61 // are Sparc specific.
62 //===--------------------------------------------------------------------===//
64 // This method adjusts a stack offset to meet alignment rules of target.
65 virtual int adjustAlignment(int unalignedOffset, bool growUp,
66 unsigned align) const;
68 // These methods compute offsets using the frame contents for a particular
69 // function. The frame contents are obtained from the MachineFunction object
70 // for the given function. The rest must be implemented by the
71 // machine-specific subclass.
73 virtual int getIncomingArgOffset (MachineFunction& mcInfo,
74 unsigned argNum) const;
75 virtual int getOutgoingArgOffset (MachineFunction& mcInfo,
76 unsigned argNum) const;
78 virtual int getFirstAutomaticVarOffset (MachineFunction& mcInfo,
80 virtual int getRegSpillAreaOffset (MachineFunction& mcInfo,
82 virtual int getTmpAreaOffset (MachineFunction& mcInfo,
84 virtual int getDynamicAreaOffset (MachineFunction& mcInfo,
88 } // End llvm namespace