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 virtual int getStackFrameSizeAlignment () const;
65 virtual int getMinStackFrameSize () const;
66 virtual int getNumFixedOutgoingArgs () const;
67 virtual int getSizeOfEachArgOnStack () const;
68 virtual bool argsOnStackHaveFixedSize () const;
70 // This method adjusts a stack offset to meet alignment rules of target.
71 virtual int adjustAlignment(int unalignedOffset, bool growUp,
72 unsigned align) const;
74 // These methods compute offsets using the frame contents for a particular
75 // function. The frame contents are obtained from the MachineFunction object
76 // for the given function. The rest must be implemented by the
77 // machine-specific subclass.
79 virtual int getIncomingArgOffset (MachineFunction& mcInfo,
80 unsigned argNum) const;
81 virtual int getOutgoingArgOffset (MachineFunction& mcInfo,
82 unsigned argNum) const;
84 virtual int getFirstIncomingArgOffset (MachineFunction& mcInfo,
86 virtual int getFirstOutgoingArgOffset (MachineFunction& mcInfo,
88 virtual int getFirstOptionalOutgoingArgOffset (MachineFunction&,
90 virtual int getFirstAutomaticVarOffset (MachineFunction& mcInfo,
92 virtual int getRegSpillAreaOffset (MachineFunction& mcInfo,
94 virtual int getTmpAreaOffset (MachineFunction& mcInfo,
96 virtual int getDynamicAreaOffset (MachineFunction& mcInfo,
100 // These methods specify the base register used for each stack area
101 // (generally FP or SP)
103 virtual int getIncomingArgBaseRegNum() const;
104 virtual int getOutgoingArgBaseRegNum() const;
105 virtual int getOptionalOutgoingArgBaseRegNum() const;
106 virtual int getAutomaticVarBaseRegNum() const;
107 virtual int getRegSpillAreaBaseRegNum() const;
108 virtual int getDynamicAreaBaseRegNum() const;
111 } // End llvm namespace