Move to TargetMachineImpls.h
[oota-llvm.git] / include / llvm / Target / TargetFrameInfo.h
1 //===-- llvm/CodeGen/MachineFrameInfo.h -------------------------*- C++ -*-===//
2 //
3 // Interface to layout of stack frame on target machine.
4 //
5 //===----------------------------------------------------------------------===//
6
7 #ifndef LLVM_CODEGEN_FRAMEINFO_H
8 #define LLVM_CODEGEN_FRAMEINFO_H
9
10 #include "Support/NonCopyable.h"
11 #include <vector>
12
13 class MachineFunction;
14 class TargetMachine;
15
16 struct MachineFrameInfo : public NonCopyableV {
17   const TargetMachine &target;
18   
19 public:
20   MachineFrameInfo(const TargetMachine& tgt) : target(tgt) {}
21   
22   // These methods provide constant parameters of the frame layout.
23   // 
24   virtual int  getStackFrameSizeAlignment       () const = 0;
25   virtual int  getMinStackFrameSize             () const = 0;
26   virtual int  getNumFixedOutgoingArgs          () const = 0;
27   virtual int  getSizeOfEachArgOnStack          () const = 0;
28   virtual bool argsOnStackHaveFixedSize         () const = 0;
29
30   // This method adjusts a stack offset to meet alignment rules of target.
31   // 
32   virtual int  adjustAlignment                  (int unalignedOffset,
33                                                  bool growUp,
34                                                  unsigned int align) const {
35     return unalignedOffset + (growUp? +1:-1)*(unalignedOffset % align);
36   }
37
38   // These methods compute offsets using the frame contents for a
39   // particular method.  The frame contents are obtained from the
40   // MachineCodeInfoForMethod object for the given method.
41   // The first few methods have default machine-independent implementations.
42   // The rest must be implemented by the machine-specific subclass.
43   // 
44   virtual int getIncomingArgOffset              (MachineFunction& mcInfo,
45                                                  unsigned argNum) const;
46   virtual int getOutgoingArgOffset              (MachineFunction& mcInfo,
47                                                  unsigned argNum) const;
48   
49   virtual int getFirstIncomingArgOffset         (MachineFunction& mcInfo,
50                                                  bool& growUp) const=0;
51   virtual int getFirstOutgoingArgOffset         (MachineFunction& mcInfo,
52                                                  bool& growUp) const=0;
53   virtual int getFirstOptionalOutgoingArgOffset (MachineFunction&,
54                                                  bool& growUp) const=0;
55   virtual int getFirstAutomaticVarOffset        (MachineFunction& mcInfo,
56                                                  bool& growUp) const=0;
57   virtual int getRegSpillAreaOffset             (MachineFunction& mcInfo,
58                                                  bool& growUp) const=0;
59   virtual int getTmpAreaOffset                  (MachineFunction& mcInfo,
60                                                  bool& growUp) const=0;
61   virtual int getDynamicAreaOffset              (MachineFunction& mcInfo,
62                                                  bool& growUp) const=0;
63
64   //
65   // These methods specify the base register used for each stack area
66   // (generally FP or SP)
67   // 
68   virtual int getIncomingArgBaseRegNum()               const=0;
69   virtual int getOutgoingArgBaseRegNum()               const=0;
70   virtual int getOptionalOutgoingArgBaseRegNum()       const=0;
71   virtual int getAutomaticVarBaseRegNum()              const=0;
72   virtual int getRegSpillAreaBaseRegNum()              const=0;
73   virtual int getDynamicAreaBaseRegNum()               const=0;
74 };
75
76 #endif