]> git.proxmox.com Git - rustc.git/blame - src/llvm/lib/Target/AArch64/AArch64MachineFunctionInfo.h
Imported Upstream version 1.0.0+dfsg1
[rustc.git] / src / llvm / lib / Target / AArch64 / AArch64MachineFunctionInfo.h
CommitLineData
1a4d82fc 1//=- AArch64MachineFuctionInfo.h - AArch64 machine function info --*- C++ -*-=//
970d7e83
LB
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
1a4d82fc
JJ
14#ifndef LLVM_LIB_TARGET_AARCH64_AARCH64MACHINEFUNCTIONINFO_H
15#define LLVM_LIB_TARGET_AARCH64_AARCH64MACHINEFUNCTIONINFO_H
970d7e83 16
1a4d82fc
JJ
17#include "llvm/ADT/SmallPtrSet.h"
18#include "llvm/ADT/SmallVector.h"
970d7e83 19#include "llvm/CodeGen/MachineFunction.h"
1a4d82fc 20#include "llvm/MC/MCLinkerOptimizationHint.h"
970d7e83
LB
21
22namespace llvm {
23
1a4d82fc
JJ
24/// AArch64FunctionInfo - This class is derived from MachineFunctionInfo and
25/// contains private AArch64-specific information for each MachineFunction.
26class AArch64FunctionInfo : public MachineFunctionInfo {
970d7e83
LB
27
28 /// Number of bytes of arguments this function has on the stack. If the callee
29 /// is expected to restore the argument stack this should be a multiple of 16,
30 /// all usable during a tail call.
31 ///
32 /// The alternative would forbid tail call optimisation in some cases: if we
33 /// want to transfer control from a function with 8-bytes of stack-argument
34 /// space to a function with 16-bytes then misalignment of this value would
35 /// make a stack adjustment necessary, which could not be undone by the
36 /// callee.
37 unsigned BytesInStackArgArea;
38
39 /// The number of bytes to restore to deallocate space for incoming
40 /// arguments. Canonically 0 in the C calling convention, but non-zero when
41 /// callee is expected to pop the args.
42 unsigned ArgumentStackToRestore;
43
1a4d82fc
JJ
44 /// HasStackFrame - True if this function has a stack frame. Set by
45 /// processFunctionBeforeCalleeSavedScan().
46 bool HasStackFrame;
970d7e83 47
1a4d82fc
JJ
48 /// \brief Amount of stack frame size, not including callee-saved registers.
49 unsigned LocalStackSize;
970d7e83 50
1a4d82fc
JJ
51 /// \brief Number of TLS accesses using the special (combinable)
52 /// _TLS_MODULE_BASE_ symbol.
53 unsigned NumLocalDynamicTLSAccesses;
970d7e83 54
1a4d82fc
JJ
55 /// \brief FrameIndex for start of varargs area for arguments passed on the
56 /// stack.
57 int VarArgsStackIndex;
970d7e83 58
1a4d82fc
JJ
59 /// \brief FrameIndex for start of varargs area for arguments passed in
60 /// general purpose registers.
61 int VarArgsGPRIndex;
970d7e83 62
1a4d82fc
JJ
63 /// \brief Size of the varargs area for arguments passed in general purpose
64 /// registers.
65 unsigned VarArgsGPRSize;
970d7e83 66
1a4d82fc
JJ
67 /// \brief FrameIndex for start of varargs area for arguments passed in
68 /// floating-point registers.
69 int VarArgsFPRIndex;
970d7e83 70
1a4d82fc
JJ
71 /// \brief Size of the varargs area for arguments passed in floating-point
72 /// registers.
73 unsigned VarArgsFPRSize;
970d7e83
LB
74
75public:
1a4d82fc
JJ
76 AArch64FunctionInfo()
77 : BytesInStackArgArea(0), ArgumentStackToRestore(0), HasStackFrame(false),
78 NumLocalDynamicTLSAccesses(0), VarArgsStackIndex(0), VarArgsGPRIndex(0),
79 VarArgsGPRSize(0), VarArgsFPRIndex(0), VarArgsFPRSize(0) {}
80
81 explicit AArch64FunctionInfo(MachineFunction &MF)
82 : BytesInStackArgArea(0), ArgumentStackToRestore(0), HasStackFrame(false),
83 NumLocalDynamicTLSAccesses(0), VarArgsStackIndex(0), VarArgsGPRIndex(0),
84 VarArgsGPRSize(0), VarArgsFPRIndex(0), VarArgsFPRSize(0) {
85 (void)MF;
86 }
970d7e83
LB
87
88 unsigned getBytesInStackArgArea() const { return BytesInStackArgArea; }
1a4d82fc 89 void setBytesInStackArgArea(unsigned bytes) { BytesInStackArgArea = bytes; }
970d7e83
LB
90
91 unsigned getArgumentStackToRestore() const { return ArgumentStackToRestore; }
92 void setArgumentStackToRestore(unsigned bytes) {
93 ArgumentStackToRestore = bytes;
94 }
95
1a4d82fc
JJ
96 bool hasStackFrame() const { return HasStackFrame; }
97 void setHasStackFrame(bool s) { HasStackFrame = s; }
970d7e83 98
1a4d82fc
JJ
99 void setLocalStackSize(unsigned Size) { LocalStackSize = Size; }
100 unsigned getLocalStackSize() const { return LocalStackSize; }
970d7e83 101
1a4d82fc
JJ
102 void incNumLocalDynamicTLSAccesses() { ++NumLocalDynamicTLSAccesses; }
103 unsigned getNumLocalDynamicTLSAccesses() const {
104 return NumLocalDynamicTLSAccesses;
105 }
970d7e83 106
1a4d82fc
JJ
107 int getVarArgsStackIndex() const { return VarArgsStackIndex; }
108 void setVarArgsStackIndex(int Index) { VarArgsStackIndex = Index; }
970d7e83 109
1a4d82fc
JJ
110 int getVarArgsGPRIndex() const { return VarArgsGPRIndex; }
111 void setVarArgsGPRIndex(int Index) { VarArgsGPRIndex = Index; }
970d7e83 112
1a4d82fc
JJ
113 unsigned getVarArgsGPRSize() const { return VarArgsGPRSize; }
114 void setVarArgsGPRSize(unsigned Size) { VarArgsGPRSize = Size; }
970d7e83 115
1a4d82fc
JJ
116 int getVarArgsFPRIndex() const { return VarArgsFPRIndex; }
117 void setVarArgsFPRIndex(int Index) { VarArgsFPRIndex = Index; }
970d7e83 118
1a4d82fc
JJ
119 unsigned getVarArgsFPRSize() const { return VarArgsFPRSize; }
120 void setVarArgsFPRSize(unsigned Size) { VarArgsFPRSize = Size; }
970d7e83 121
1a4d82fc
JJ
122 typedef SmallPtrSet<const MachineInstr *, 16> SetOfInstructions;
123
124 const SetOfInstructions &getLOHRelated() const { return LOHRelated; }
125
126 // Shortcuts for LOH related types.
127 class MILOHDirective {
128 MCLOHType Kind;
970d7e83 129
1a4d82fc
JJ
130 /// Arguments of this directive. Order matters.
131 SmallVector<const MachineInstr *, 3> Args;
132
133 public:
134 typedef SmallVectorImpl<const MachineInstr *> LOHArgs;
135
136 MILOHDirective(MCLOHType Kind, const LOHArgs &Args)
137 : Kind(Kind), Args(Args.begin(), Args.end()) {
138 assert(isValidMCLOHType(Kind) && "Invalid LOH directive type!");
139 }
140
141 MCLOHType getKind() const { return Kind; }
142 const LOHArgs &getArgs() const { return Args; }
143 };
144
145 typedef MILOHDirective::LOHArgs MILOHArgs;
146 typedef SmallVector<MILOHDirective, 32> MILOHContainer;
147
148 const MILOHContainer &getLOHContainer() const { return LOHContainerSet; }
149
150 /// Add a LOH directive of this @p Kind and this @p Args.
151 void addLOHDirective(MCLOHType Kind, const MILOHArgs &Args) {
152 LOHContainerSet.push_back(MILOHDirective(Kind, Args));
153 LOHRelated.insert(Args.begin(), Args.end());
154 }
155
156private:
157 // Hold the lists of LOHs.
158 MILOHContainer LOHContainerSet;
159 SetOfInstructions LOHRelated;
160};
970d7e83
LB
161} // End llvm namespace
162
163#endif