1249259Sdim//=- AArch64MachineFuctionInfo.h - AArch64 machine function info -*- C++ -*-==//
2249259Sdim//
3249259Sdim//                     The LLVM Compiler Infrastructure
4249259Sdim//
5249259Sdim// This file is distributed under the University of Illinois Open Source
6249259Sdim// License. See LICENSE.TXT for details.
7249259Sdim//
8249259Sdim//===----------------------------------------------------------------------===//
9249259Sdim//
10249259Sdim// This file declares AArch64-specific per-machine-function information.
11249259Sdim//
12249259Sdim//===----------------------------------------------------------------------===//
13249259Sdim
14249259Sdim#ifndef AARCH64MACHINEFUNCTIONINFO_H
15249259Sdim#define AARCH64MACHINEFUNCTIONINFO_H
16249259Sdim
17249259Sdim#include "llvm/CodeGen/MachineFunction.h"
18249259Sdim
19249259Sdimnamespace llvm {
20249259Sdim
21249259Sdim/// This class is derived from MachineFunctionInfo and contains private AArch64
22249259Sdim/// target-specific information for each MachineFunction.
23249259Sdimclass AArch64MachineFunctionInfo : public MachineFunctionInfo {
24249259Sdim  virtual void anchor();
25249259Sdim
26249259Sdim  /// Number of bytes of arguments this function has on the stack. If the callee
27249259Sdim  /// is expected to restore the argument stack this should be a multiple of 16,
28249259Sdim  /// all usable during a tail call.
29249259Sdim  ///
30249259Sdim  /// The alternative would forbid tail call optimisation in some cases: if we
31249259Sdim  /// want to transfer control from a function with 8-bytes of stack-argument
32249259Sdim  /// space to a function with 16-bytes then misalignment of this value would
33249259Sdim  /// make a stack adjustment necessary, which could not be undone by the
34249259Sdim  /// callee.
35249259Sdim  unsigned BytesInStackArgArea;
36249259Sdim
37249259Sdim  /// The number of bytes to restore to deallocate space for incoming
38249259Sdim  /// arguments. Canonically 0 in the C calling convention, but non-zero when
39249259Sdim  /// callee is expected to pop the args.
40249259Sdim  unsigned ArgumentStackToRestore;
41249259Sdim
42249259Sdim  /// If the stack needs to be adjusted on frame entry in two stages, this
43249259Sdim  /// records the size of the first adjustment just prior to storing
44249259Sdim  /// callee-saved registers. The callee-saved slots are addressed assuming
45249259Sdim  /// SP == <incoming-SP> - InitialStackAdjust.
46249259Sdim  unsigned InitialStackAdjust;
47249259Sdim
48249259Sdim  /// Number of local-dynamic TLS accesses.
49249259Sdim  unsigned NumLocalDynamics;
50249259Sdim
51249259Sdim  /// @see AArch64 Procedure Call Standard, B.3
52249259Sdim  ///
53249259Sdim  /// The Frame index of the area where LowerFormalArguments puts the
54249259Sdim  /// general-purpose registers that might contain variadic parameters.
55249259Sdim  int VariadicGPRIdx;
56249259Sdim
57249259Sdim  /// @see AArch64 Procedure Call Standard, B.3
58249259Sdim  ///
59249259Sdim  /// The size of the frame object used to store the general-purpose registers
60249259Sdim  /// which might contain variadic arguments. This is the offset from
61249259Sdim  /// VariadicGPRIdx to what's stored in __gr_top.
62249259Sdim  unsigned VariadicGPRSize;
63249259Sdim
64249259Sdim  /// @see AArch64 Procedure Call Standard, B.3
65249259Sdim  ///
66249259Sdim  /// The Frame index of the area where LowerFormalArguments puts the
67249259Sdim  /// floating-point registers that might contain variadic parameters.
68249259Sdim  int VariadicFPRIdx;
69249259Sdim
70249259Sdim  /// @see AArch64 Procedure Call Standard, B.3
71249259Sdim  ///
72249259Sdim  /// The size of the frame object used to store the floating-point registers
73249259Sdim  /// which might contain variadic arguments. This is the offset from
74249259Sdim  /// VariadicFPRIdx to what's stored in __vr_top.
75249259Sdim  unsigned VariadicFPRSize;
76249259Sdim
77249259Sdim  /// @see AArch64 Procedure Call Standard, B.3
78249259Sdim  ///
79249259Sdim  /// The Frame index of an object pointing just past the last known stacked
80249259Sdim  /// argument on entry to a variadic function. This goes into the __stack field
81249259Sdim  /// of the va_list type.
82249259Sdim  int VariadicStackIdx;
83249259Sdim
84249259Sdim  /// The offset of the frame pointer from the stack pointer on function
85249259Sdim  /// entry. This is expected to be negative.
86249259Sdim  int FramePointerOffset;
87249259Sdim
88249259Sdimpublic:
89249259Sdim  AArch64MachineFunctionInfo()
90249259Sdim    : BytesInStackArgArea(0),
91249259Sdim      ArgumentStackToRestore(0),
92249259Sdim      InitialStackAdjust(0),
93249259Sdim      NumLocalDynamics(0),
94249259Sdim      VariadicGPRIdx(0),
95249259Sdim      VariadicGPRSize(0),
96249259Sdim      VariadicFPRIdx(0),
97249259Sdim      VariadicFPRSize(0),
98249259Sdim      VariadicStackIdx(0),
99249259Sdim      FramePointerOffset(0) {}
100249259Sdim
101249259Sdim  explicit AArch64MachineFunctionInfo(MachineFunction &MF)
102249259Sdim    : BytesInStackArgArea(0),
103249259Sdim      ArgumentStackToRestore(0),
104249259Sdim      InitialStackAdjust(0),
105249259Sdim      NumLocalDynamics(0),
106249259Sdim      VariadicGPRIdx(0),
107249259Sdim      VariadicGPRSize(0),
108249259Sdim      VariadicFPRIdx(0),
109249259Sdim      VariadicFPRSize(0),
110249259Sdim      VariadicStackIdx(0),
111249259Sdim      FramePointerOffset(0) {}
112249259Sdim
113249259Sdim  unsigned getBytesInStackArgArea() const { return BytesInStackArgArea; }
114249259Sdim  void setBytesInStackArgArea (unsigned bytes) { BytesInStackArgArea = bytes;}
115249259Sdim
116249259Sdim  unsigned getArgumentStackToRestore() const { return ArgumentStackToRestore; }
117249259Sdim  void setArgumentStackToRestore(unsigned bytes) {
118249259Sdim    ArgumentStackToRestore = bytes;
119249259Sdim  }
120249259Sdim
121249259Sdim  unsigned getInitialStackAdjust() const { return InitialStackAdjust; }
122249259Sdim  void setInitialStackAdjust(unsigned bytes) { InitialStackAdjust = bytes; }
123249259Sdim
124249259Sdim  unsigned getNumLocalDynamicTLSAccesses() const { return NumLocalDynamics; }
125249259Sdim  void incNumLocalDynamicTLSAccesses() { ++NumLocalDynamics; }
126249259Sdim
127249259Sdim  int getVariadicGPRIdx() const { return VariadicGPRIdx; }
128249259Sdim  void setVariadicGPRIdx(int Idx) { VariadicGPRIdx = Idx; }
129249259Sdim
130249259Sdim  unsigned getVariadicGPRSize() const { return VariadicGPRSize; }
131249259Sdim  void setVariadicGPRSize(unsigned Size) { VariadicGPRSize = Size; }
132249259Sdim
133249259Sdim  int getVariadicFPRIdx() const { return VariadicFPRIdx; }
134249259Sdim  void setVariadicFPRIdx(int Idx) { VariadicFPRIdx = Idx; }
135249259Sdim
136249259Sdim  unsigned getVariadicFPRSize() const { return VariadicFPRSize; }
137249259Sdim  void setVariadicFPRSize(unsigned Size) { VariadicFPRSize = Size; }
138249259Sdim
139249259Sdim  int getVariadicStackIdx() const { return VariadicStackIdx; }
140249259Sdim  void setVariadicStackIdx(int Idx) { VariadicStackIdx = Idx; }
141249259Sdim
142249259Sdim  int getFramePointerOffset() const { return FramePointerOffset; }
143249259Sdim  void setFramePointerOffset(int Idx) { FramePointerOffset = Idx; }
144249259Sdim
145249259Sdim};
146249259Sdim
147249259Sdim} // End llvm namespace
148249259Sdim
149249259Sdim#endif
150