1 //===- ARM64MachineFuctionInfo.h - ARM64 machine function info --*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file declares ARM64-specific per-machine-function information.
12 //===----------------------------------------------------------------------===//
14 #ifndef ARM64MACHINEFUNCTIONINFO_H
15 #define ARM64MACHINEFUNCTIONINFO_H
17 #include "llvm/ADT/SmallPtrSet.h"
18 #include "llvm/ADT/SmallVector.h"
19 #include "llvm/CodeGen/MachineFunction.h"
20 #include "llvm/MC/MCLinkerOptimizationHint.h"
24 /// ARM64FunctionInfo - This class is derived from MachineFunctionInfo and
25 /// contains private ARM64-specific information for each MachineFunction.
26 class ARM64FunctionInfo : public MachineFunctionInfo {
28 /// HasStackFrame - True if this function has a stack frame. Set by
29 /// processFunctionBeforeCalleeSavedScan().
32 /// \brief Amount of stack frame size, not including callee-saved registers.
33 unsigned LocalStackSize;
35 /// \brief Number of TLS accesses using the special (combinable)
36 /// _TLS_MODULE_BASE_ symbol.
37 unsigned NumLocalDynamicTLSAccesses;
39 /// \brief FrameIndex for start of varargs area for arguments passed on the
41 int VarArgsStackIndex;
43 /// \brief FrameIndex for start of varargs area for arguments passed in
44 /// general purpose registers.
47 /// \brief Size of the varargs area for arguments passed in general purpose
49 unsigned VarArgsGPRSize;
51 /// \brief FrameIndex for start of varargs area for arguments passed in
52 /// floating-point registers.
55 /// \brief Size of the varargs area for arguments passed in floating-point
57 unsigned VarArgsFPRSize;
61 : HasStackFrame(false), NumLocalDynamicTLSAccesses(0),
62 VarArgsStackIndex(0), VarArgsGPRIndex(0), VarArgsGPRSize(0),
63 VarArgsFPRIndex(0), VarArgsFPRSize(0) {}
65 explicit ARM64FunctionInfo(MachineFunction &MF)
66 : HasStackFrame(false), NumLocalDynamicTLSAccesses(0),
67 VarArgsStackIndex(0), VarArgsGPRIndex(0), VarArgsGPRSize(0),
68 VarArgsFPRIndex(0), VarArgsFPRSize(0) {
72 bool hasStackFrame() const { return HasStackFrame; }
73 void setHasStackFrame(bool s) { HasStackFrame = s; }
75 void setLocalStackSize(unsigned Size) { LocalStackSize = Size; }
76 unsigned getLocalStackSize() const { return LocalStackSize; }
78 void incNumLocalDynamicTLSAccesses() { ++NumLocalDynamicTLSAccesses; }
79 unsigned getNumLocalDynamicTLSAccesses() const {
80 return NumLocalDynamicTLSAccesses;
83 int getVarArgsStackIndex() const { return VarArgsStackIndex; }
84 void setVarArgsStackIndex(int Index) { VarArgsStackIndex = Index; }
86 int getVarArgsGPRIndex() const { return VarArgsGPRIndex; }
87 void setVarArgsGPRIndex(int Index) { VarArgsGPRIndex = Index; }
89 unsigned getVarArgsGPRSize() const { return VarArgsGPRSize; }
90 void setVarArgsGPRSize(unsigned Size) { VarArgsGPRSize = Size; }
92 int getVarArgsFPRIndex() const { return VarArgsFPRIndex; }
93 void setVarArgsFPRIndex(int Index) { VarArgsFPRIndex = Index; }
95 unsigned getVarArgsFPRSize() const { return VarArgsFPRSize; }
96 void setVarArgsFPRSize(unsigned Size) { VarArgsFPRSize = Size; }
98 typedef SmallPtrSet<const MachineInstr *, 16> SetOfInstructions;
100 const SetOfInstructions &getLOHRelated() const { return LOHRelated; }
102 // Shortcuts for LOH related types.
103 class MILOHDirective {
106 /// Arguments of this directive. Order matters.
107 SmallVector<const MachineInstr *, 3> Args;
110 typedef SmallVectorImpl<const MachineInstr *> LOHArgs;
112 MILOHDirective(MCLOHType Kind, const LOHArgs &Args)
113 : Kind(Kind), Args(Args.begin(), Args.end()) {
114 assert(isValidMCLOHType(Kind) && "Invalid LOH directive type!");
117 MCLOHType getKind() const { return Kind; }
118 const LOHArgs &getArgs() const { return Args; }
121 typedef MILOHDirective::LOHArgs MILOHArgs;
122 typedef SmallVector<MILOHDirective, 32> MILOHContainer;
124 const MILOHContainer &getLOHContainer() const { return LOHContainerSet; }
126 /// Add a LOH directive of this @p Kind and this @p Args.
127 void addLOHDirective(MCLOHType Kind, const MILOHArgs &Args) {
128 LOHContainerSet.push_back(MILOHDirective(Kind, Args));
129 LOHRelated.insert(Args.begin(), Args.end());
133 // Hold the lists of LOHs.
134 MILOHContainer LOHContainerSet;
135 SetOfInstructions LOHRelated;
137 } // End llvm namespace
139 #endif // ARM64MACHINEFUNCTIONINFO_H