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 struct TargetFrameInfo {
23 StackGrowsUp, // Adding to the stack increases the stack address
24 StackGrowsDown // Adding to the stack decreases the stack address
27 StackDirection StackDir;
28 unsigned StackAlignment;
31 TargetFrameInfo(StackDirection D, unsigned StackAl, int LAO)
32 : StackDir(D), StackAlignment(StackAl), LocalAreaOffset(LAO) {}
34 // These methods return information that describes the abstract stack layout
35 // of the target machine.
37 /// getStackGrowthDirection - Return the direction the stack grows
39 StackDirection getStackGrowthDirection() const { return StackDir; }
41 /// getStackAlignment - This method returns the number of bytes that the stack
42 /// pointer must be aligned to. Typically, this is the largest alignment for
43 /// any data object in the target.
45 unsigned getStackAlignment() const { return StackAlignment; }
47 /// getOffsetOfLocalArea - This method returns the offset of the local area
48 /// from the stack pointer on entrance to a function.
50 int getOffsetOfLocalArea() const { return LocalAreaOffset; }
52 //===--------------------------------------------------------------------===//
53 // These methods provide details of the stack frame used by Sparc, thus they
54 // are Sparc specific.
55 //===--------------------------------------------------------------------===//
57 virtual int getStackFrameSizeAlignment () const;
58 virtual int getMinStackFrameSize () const;
59 virtual int getNumFixedOutgoingArgs () const;
60 virtual int getSizeOfEachArgOnStack () const;
61 virtual bool argsOnStackHaveFixedSize () const;
63 // This method adjusts a stack offset to meet alignment rules of target.
64 virtual int adjustAlignment(int unalignedOffset, bool growUp,
65 unsigned align) const;
67 // These methods compute offsets using the frame contents for a particular
68 // function. The frame contents are obtained from the MachineFunction object
69 // for the given function. The rest must be implemented by the
70 // machine-specific subclass.
72 virtual int getIncomingArgOffset (MachineFunction& mcInfo,
73 unsigned argNum) const;
74 virtual int getOutgoingArgOffset (MachineFunction& mcInfo,
75 unsigned argNum) const;
77 virtual int getFirstIncomingArgOffset (MachineFunction& mcInfo,
79 virtual int getFirstOutgoingArgOffset (MachineFunction& mcInfo,
81 virtual int getFirstOptionalOutgoingArgOffset (MachineFunction&,
83 virtual int getFirstAutomaticVarOffset (MachineFunction& mcInfo,
85 virtual int getRegSpillAreaOffset (MachineFunction& mcInfo,
87 virtual int getTmpAreaOffset (MachineFunction& mcInfo,
89 virtual int getDynamicAreaOffset (MachineFunction& mcInfo,
93 // These methods specify the base register used for each stack area
94 // (generally FP or SP)
96 virtual int getIncomingArgBaseRegNum() const;
97 virtual int getOutgoingArgBaseRegNum() const;
98 virtual int getOptionalOutgoingArgBaseRegNum() const;
99 virtual int getAutomaticVarBaseRegNum() const;
100 virtual int getRegSpillAreaBaseRegNum() const;
101 virtual int getDynamicAreaBaseRegNum() const;
104 } // End llvm namespace