blob: 37c1cc5b29ec5bf7b086cfa7a47bec0ba1e348a0 [file] [log] [blame]
Tim Northover72062f52013-01-31 12:12:40 +00001//=- 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
20namespace llvm {
21
22/// This class is derived from MachineFunctionInfo and contains private AArch64
23/// target-specific information for each MachineFunction.
24class 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
93public:
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; }
Tim Northoverdfe076a2013-02-05 13:24:56 +0000124 void setArgumentStackToRestore(unsigned bytes) {
125 ArgumentStackToRestore = bytes;
126 }
Tim Northover72062f52013-01-31 12:12:40 +0000127
128 unsigned getInitialStackAdjust() const { return InitialStackAdjust; }
129 void setInitialStackAdjust(unsigned bytes) { InitialStackAdjust = bytes; }
130
131 unsigned getNumLocalDynamicTLSAccesses() const { return NumLocalDynamics; }
132 void incNumLocalDynamicTLSAccesses() { ++NumLocalDynamics; }
133
134 void initPICLabelUId(unsigned UId) { PICLabelUId = UId; }
135 unsigned getNumPICLabels() const { return PICLabelUId; }
136 unsigned createPICLabelUId() { return PICLabelUId++; }
137
138 int getVariadicGPRIdx() const { return VariadicGPRIdx; }
139 void setVariadicGPRIdx(int Idx) { VariadicGPRIdx = Idx; }
140
141 unsigned getVariadicGPRSize() const { return VariadicGPRSize; }
142 void setVariadicGPRSize(unsigned Size) { VariadicGPRSize = Size; }
143
144 int getVariadicFPRIdx() const { return VariadicFPRIdx; }
145 void setVariadicFPRIdx(int Idx) { VariadicFPRIdx = Idx; }
146
147 unsigned getVariadicFPRSize() const { return VariadicFPRSize; }
148 void setVariadicFPRSize(unsigned Size) { VariadicFPRSize = Size; }
149
150 int getVariadicStackIdx() const { return VariadicStackIdx; }
151 void setVariadicStackIdx(int Idx) { VariadicStackIdx = Idx; }
152
153 int getFramePointerOffset() const { return FramePointerOffset; }
154 void setFramePointerOffset(int Idx) { FramePointerOffset = Idx; }
155
156};
157
158} // End llvm namespace
159
160#endif