02bf7cf6fd005986a1e4bf3ee24b9fd3e9c20883
[oota-llvm.git] / lib / Target / ARM64 / ARM64MachineFunctionInfo.h
1 //===- ARM64MachineFuctionInfo.h - ARM64 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 ARM64-specific per-machine-function information.
11 //
12 //===----------------------------------------------------------------------===//
13
14 #ifndef ARM64MACHINEFUNCTIONINFO_H
15 #define ARM64MACHINEFUNCTIONINFO_H
16
17 #include "llvm/ADT/SmallPtrSet.h"
18 #include "llvm/ADT/SmallVector.h"
19 #include "llvm/CodeGen/MachineFunction.h"
20 #include "llvm/MC/MCLinkerOptimizationHint.h"
21
22 namespace llvm {
23
24 /// ARM64FunctionInfo - This class is derived from MachineFunctionInfo and
25 /// contains private ARM64-specific information for each MachineFunction.
26 class ARM64FunctionInfo : public MachineFunctionInfo {
27
28   /// HasStackFrame - True if this function has a stack frame. Set by
29   /// processFunctionBeforeCalleeSavedScan().
30   bool HasStackFrame;
31
32   /// \brief Amount of stack frame size, not including callee-saved registers.
33   unsigned LocalStackSize;
34
35   /// \brief Number of TLS accesses using the special (combinable)
36   /// _TLS_MODULE_BASE_ symbol.
37   unsigned NumLocalDynamicTLSAccesses;
38
39   /// \brief FrameIndex for start of varargs area for arguments passed on the
40   /// stack.
41   int VarArgsStackIndex;
42
43   /// \brief FrameIndex for start of varargs area for arguments passed in
44   /// general purpose registers.
45   int VarArgsGPRIndex;
46
47   /// \brief Size of the varargs area for arguments passed in general purpose
48   /// registers.
49   unsigned VarArgsGPRSize;
50
51   /// \brief FrameIndex for start of varargs area for arguments passed in
52   /// floating-point registers.
53   int VarArgsFPRIndex;
54
55   /// \brief Size of the varargs area for arguments passed in floating-point
56   /// registers.
57   unsigned VarArgsFPRSize;
58
59 public:
60   ARM64FunctionInfo()
61       : HasStackFrame(false), NumLocalDynamicTLSAccesses(0),
62         VarArgsStackIndex(0), VarArgsGPRIndex(0), VarArgsGPRSize(0),
63         VarArgsFPRIndex(0), VarArgsFPRSize(0) {}
64
65   explicit ARM64FunctionInfo(MachineFunction &MF)
66       : HasStackFrame(false), NumLocalDynamicTLSAccesses(0),
67         VarArgsStackIndex(0), VarArgsGPRIndex(0), VarArgsGPRSize(0),
68         VarArgsFPRIndex(0), VarArgsFPRSize(0) {
69     (void)MF;
70   }
71
72   bool hasStackFrame() const { return HasStackFrame; }
73   void setHasStackFrame(bool s) { HasStackFrame = s; }
74
75   void setLocalStackSize(unsigned Size) { LocalStackSize = Size; }
76   unsigned getLocalStackSize() const { return LocalStackSize; }
77
78   void incNumLocalDynamicTLSAccesses() { ++NumLocalDynamicTLSAccesses; }
79   unsigned getNumLocalDynamicTLSAccesses() const {
80     return NumLocalDynamicTLSAccesses;
81   }
82
83   int getVarArgsStackIndex() const { return VarArgsStackIndex; }
84   void setVarArgsStackIndex(int Index) { VarArgsStackIndex = Index; }
85
86   int getVarArgsGPRIndex() const { return VarArgsGPRIndex; }
87   void setVarArgsGPRIndex(int Index) { VarArgsGPRIndex = Index; }
88
89   unsigned getVarArgsGPRSize() const { return VarArgsGPRSize; }
90   void setVarArgsGPRSize(unsigned Size) { VarArgsGPRSize = Size; }
91
92   int getVarArgsFPRIndex() const { return VarArgsFPRIndex; }
93   void setVarArgsFPRIndex(int Index) { VarArgsFPRIndex = Index; }
94
95   unsigned getVarArgsFPRSize() const { return VarArgsFPRSize; }
96   void setVarArgsFPRSize(unsigned Size) { VarArgsFPRSize = Size; }
97
98   typedef SmallPtrSet<const MachineInstr *, 16> SetOfInstructions;
99
100   const SetOfInstructions &getLOHRelated() const { return LOHRelated; }
101
102   // Shortcuts for LOH related types.
103   class MILOHDirective {
104     MCLOHType Kind;
105
106     /// Arguments of this directive. Order matters.
107     SmallVector<const MachineInstr *, 3> Args;
108
109   public:
110     typedef SmallVectorImpl<const MachineInstr *> LOHArgs;
111
112     MILOHDirective(MCLOHType Kind, const LOHArgs &Args)
113         : Kind(Kind), Args(Args.begin(), Args.end()) {
114       assert(isValidMCLOHType(Kind) && "Invalid LOH directive type!");
115     }
116
117     MCLOHType getKind() const { return Kind; }
118     const LOHArgs &getArgs() const { return Args; }
119   };
120
121   typedef MILOHDirective::LOHArgs MILOHArgs;
122   typedef SmallVector<MILOHDirective, 32> MILOHContainer;
123
124   const MILOHContainer &getLOHContainer() const { return LOHContainerSet; }
125
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());
130   }
131
132 private:
133   // Hold the lists of LOHs.
134   MILOHContainer LOHContainerSet;
135   SetOfInstructions LOHRelated;
136 };
137 } // End llvm namespace
138
139 #endif // ARM64MACHINEFUNCTIONINFO_H