Add AArch64 as an experimental target.
[oota-llvm.git] / lib / Target / AArch64 / AArch64MachineFunctionInfo.h
1 //=- AArch64MachineFuctionInfo.h - AArch64 machine function info -*- C++ -*-==//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file declares AArch64-specific per-machine-function information.
11 //
12 //===----------------------------------------------------------------------===//
13
14 #ifndef AARCH64MACHINEFUNCTIONINFO_H
15 #define AARCH64MACHINEFUNCTIONINFO_H
16
17 #include "llvm/ADT/DenseMap.h"
18 #include "llvm/CodeGen/MachineFunction.h"
19
20 namespace llvm {
21
22 /// This class is derived from MachineFunctionInfo and contains private AArch64
23 /// target-specific information for each MachineFunction.
24 class AArch64MachineFunctionInfo : public MachineFunctionInfo {
25   virtual void anchor();
26
27   /// Number of bytes of arguments this function has on the stack. If the callee
28   /// is expected to restore the argument stack this should be a multiple of 16,
29   /// all usable during a tail call.
30   ///
31   /// The alternative would forbid tail call optimisation in some cases: if we
32   /// want to transfer control from a function with 8-bytes of stack-argument
33   /// space to a function with 16-bytes then misalignment of this value would
34   /// make a stack adjustment necessary, which could not be undone by the
35   /// callee.
36   unsigned BytesInStackArgArea;
37
38   /// The number of bytes to restore to deallocate space for incoming
39   /// arguments. Canonically 0 in the C calling convention, but non-zero when
40   /// callee is expected to pop the args.
41   unsigned ArgumentStackToRestore;
42
43   /// If the stack needs to be adjusted on frame entry in two stages, this
44   /// records the size of the first adjustment just prior to storing
45   /// callee-saved registers. The callee-saved slots are addressed assuming
46   /// SP == <incoming-SP> - InitialStackAdjust.
47   unsigned InitialStackAdjust;
48
49   /// Number of local-dynamic TLS accesses.
50   unsigned NumLocalDynamics;
51
52   /// Keep track of the next label to be created within this function to
53   /// represent a cloned constant pool entry. Used by constant islands pass.
54   unsigned PICLabelUId;
55
56   /// @see AArch64 Procedure Call Standard, B.3
57   ///
58   /// The Frame index of the area where LowerFormalArguments puts the
59   /// general-purpose registers that might contain variadic parameters.
60   int VariadicGPRIdx;
61
62   /// @see AArch64 Procedure Call Standard, B.3
63   ///
64   /// The size of the frame object used to store the general-purpose registers
65   /// which might contain variadic arguments. This is the offset from
66   /// VariadicGPRIdx to what's stored in __gr_top.
67   unsigned VariadicGPRSize;
68
69   /// @see AArch64 Procedure Call Standard, B.3
70   ///
71   /// The Frame index of the area where LowerFormalArguments puts the
72   /// floating-point registers that might contain variadic parameters.
73   int VariadicFPRIdx;
74
75   /// @see AArch64 Procedure Call Standard, B.3
76   ///
77   /// The size of the frame object used to store the floating-point registers
78   /// which might contain variadic arguments. This is the offset from
79   /// VariadicFPRIdx to what's stored in __vr_top.
80   unsigned VariadicFPRSize;
81
82   /// @see AArch64 Procedure Call Standard, B.3
83   ///
84   /// The Frame index of an object pointing just past the last known stacked
85   /// argument on entry to a variadic function. This goes into the __stack field
86   /// of the va_list type.
87   int VariadicStackIdx;
88
89   /// The offset of the frame pointer from the stack pointer on function
90   /// entry. This is expected to be negative.
91   int FramePointerOffset;
92
93 public:
94   AArch64MachineFunctionInfo()
95     : BytesInStackArgArea(0),
96       ArgumentStackToRestore(0),
97       InitialStackAdjust(0),
98       NumLocalDynamics(0),
99       PICLabelUId(0),
100       VariadicGPRIdx(0),
101       VariadicGPRSize(0),
102       VariadicFPRIdx(0),
103       VariadicFPRSize(0),
104       VariadicStackIdx(0),
105       FramePointerOffset(0) {}
106
107   explicit AArch64MachineFunctionInfo(MachineFunction &MF)
108     : BytesInStackArgArea(0),
109       ArgumentStackToRestore(0),
110       InitialStackAdjust(0),
111       NumLocalDynamics(0),
112       PICLabelUId(0),
113       VariadicGPRIdx(0),
114       VariadicGPRSize(0),
115       VariadicFPRIdx(0),
116       VariadicFPRSize(0),
117       VariadicStackIdx(0),
118       FramePointerOffset(0) {}
119
120   unsigned getBytesInStackArgArea() const { return BytesInStackArgArea; }
121   void setBytesInStackArgArea (unsigned bytes) { BytesInStackArgArea = bytes;}
122
123   unsigned getArgumentStackToRestore() const { return ArgumentStackToRestore; }
124   void setArgumentStackToRestore(unsigned bytes) { ArgumentStackToRestore = bytes; }
125
126   unsigned getInitialStackAdjust() const { return InitialStackAdjust; }
127   void setInitialStackAdjust(unsigned bytes) { InitialStackAdjust = bytes; }
128
129   unsigned getNumLocalDynamicTLSAccesses() const { return NumLocalDynamics; }
130   void incNumLocalDynamicTLSAccesses() { ++NumLocalDynamics; }
131
132   void initPICLabelUId(unsigned UId) { PICLabelUId = UId; }
133   unsigned getNumPICLabels() const { return PICLabelUId; }
134   unsigned createPICLabelUId() { return PICLabelUId++; }
135
136   int getVariadicGPRIdx() const { return VariadicGPRIdx; }
137   void setVariadicGPRIdx(int Idx) { VariadicGPRIdx = Idx; }
138
139   unsigned getVariadicGPRSize() const { return VariadicGPRSize; }
140   void setVariadicGPRSize(unsigned Size) { VariadicGPRSize = Size; }
141
142   int getVariadicFPRIdx() const { return VariadicFPRIdx; }
143   void setVariadicFPRIdx(int Idx) { VariadicFPRIdx = Idx; }
144
145   unsigned getVariadicFPRSize() const { return VariadicFPRSize; }
146   void setVariadicFPRSize(unsigned Size) { VariadicFPRSize = Size; }
147
148   int getVariadicStackIdx() const { return VariadicStackIdx; }
149   void setVariadicStackIdx(int Idx) { VariadicStackIdx = Idx; }
150
151   int getFramePointerOffset() const { return FramePointerOffset; }
152   void setFramePointerOffset(int Idx) { FramePointerOffset = Idx; }
153
154 };
155
156 } // End llvm namespace
157
158 #endif