1 //===-- llvm/Target/TargetFrameInfo.h ---------------------------*- C++ -*-===//
3 // Interface to describe the layout of a stack frame on the target machine.
5 //===----------------------------------------------------------------------===//
7 #ifndef LLVM_TARGET_TARGETFRAMEINFO_H
8 #define LLVM_TARGET_TARGETFRAMEINFO_H
10 class MachineFunction;
12 struct TargetFrameInfo {
14 StackGrowsUp, // Adding to the stack increases the stack address
15 StackGrowsDown // Adding to the stack decreases the stack address
18 StackDirection StackDir;
19 unsigned StackAlignment;
22 TargetFrameInfo(StackDirection D, unsigned StackAl, int LAO)
23 : StackDir(D), StackAlignment(StackAl), LocalAreaOffset(LAO) {}
25 // These methods return information that describes the abstract stack layout
26 // of the target machine.
28 /// getStackGrowthDirection - Return the direction the stack grows
30 StackDirection getStackGrowthDirection() const { return StackDir; }
32 /// getStackAlignment - This method returns the number of bytes that the stack
33 /// pointer must be aligned to. Typically, this is the largest alignment for
34 /// any data object in the target.
36 unsigned getStackAlignment() const { return StackAlignment; }
38 /// getOffsetOfLocalArea - This method returns the offset of the local area
39 /// from the stack pointer on entrance to a function.
41 int getOffsetOfLocalArea() const { return LocalAreaOffset; }
43 //===--------------------------------------------------------------------===//
44 // These methods provide details of the stack frame used by Sparc, thus they
45 // are Sparc specific.
46 //===--------------------------------------------------------------------===//
48 virtual int getStackFrameSizeAlignment () const { abort(); }
49 virtual int getMinStackFrameSize () const { abort(); }
50 virtual int getNumFixedOutgoingArgs () const { abort(); }
51 virtual int getSizeOfEachArgOnStack () const { abort(); }
52 virtual bool argsOnStackHaveFixedSize () const { abort(); }
54 // This method adjusts a stack offset to meet alignment rules of target.
55 virtual int adjustAlignment(int unalignedOffset, bool growUp,
56 unsigned align) const { abort(); }
58 // These methods compute offsets using the frame contents for a particular
59 // function. The frame contents are obtained from the MachineFunction object
60 // for the given function. The rest must be implemented by the
61 // machine-specific subclass.
63 virtual int getIncomingArgOffset (MachineFunction& mcInfo,
64 unsigned argNum)const{abort();}
65 virtual int getOutgoingArgOffset (MachineFunction& mcInfo,
66 unsigned argNum)const{abort();}
68 virtual int getFirstIncomingArgOffset (MachineFunction& mcInfo,
69 bool& growUp) const { abort();}
70 virtual int getFirstOutgoingArgOffset (MachineFunction& mcInfo,
71 bool& growUp) const {abort();}
72 virtual int getFirstOptionalOutgoingArgOffset (MachineFunction&,
73 bool& growUp) const {abort();}
74 virtual int getFirstAutomaticVarOffset (MachineFunction& mcInfo,
75 bool& growUp) const {abort();}
76 virtual int getRegSpillAreaOffset (MachineFunction& mcInfo,
77 bool& growUp) const {abort();}
78 virtual int getTmpAreaOffset (MachineFunction& mcInfo,
79 bool& growUp) const {abort();}
80 virtual int getDynamicAreaOffset (MachineFunction& mcInfo,
81 bool& growUp) const {abort();}
84 // These methods specify the base register used for each stack area
85 // (generally FP or SP)
87 virtual int getIncomingArgBaseRegNum() const { abort(); }
88 virtual int getOutgoingArgBaseRegNum() const { abort(); }
89 virtual int getOptionalOutgoingArgBaseRegNum() const { abort(); }
90 virtual int getAutomaticVarBaseRegNum() const { abort(); }
91 virtual int getRegSpillAreaBaseRegNum() const { abort(); }
92 virtual int getDynamicAreaBaseRegNum() const { abort(); }