LLVM API Documentation
00001 //=- AArch64MachineFuctionInfo.h - AArch64 machine function info --*- C++ -*-=// 00002 // 00003 // The LLVM Compiler Infrastructure 00004 // 00005 // This file is distributed under the University of Illinois Open Source 00006 // License. See LICENSE.TXT for details. 00007 // 00008 //===----------------------------------------------------------------------===// 00009 // 00010 // This file declares AArch64-specific per-machine-function information. 00011 // 00012 //===----------------------------------------------------------------------===// 00013 00014 #ifndef LLVM_LIB_TARGET_AARCH64_AARCH64MACHINEFUNCTIONINFO_H 00015 #define LLVM_LIB_TARGET_AARCH64_AARCH64MACHINEFUNCTIONINFO_H 00016 00017 #include "llvm/ADT/SmallPtrSet.h" 00018 #include "llvm/ADT/SmallVector.h" 00019 #include "llvm/CodeGen/MachineFunction.h" 00020 #include "llvm/MC/MCLinkerOptimizationHint.h" 00021 00022 namespace llvm { 00023 00024 /// AArch64FunctionInfo - This class is derived from MachineFunctionInfo and 00025 /// contains private AArch64-specific information for each MachineFunction. 00026 class AArch64FunctionInfo : public MachineFunctionInfo { 00027 00028 /// Number of bytes of arguments this function has on the stack. If the callee 00029 /// is expected to restore the argument stack this should be a multiple of 16, 00030 /// all usable during a tail call. 00031 /// 00032 /// The alternative would forbid tail call optimisation in some cases: if we 00033 /// want to transfer control from a function with 8-bytes of stack-argument 00034 /// space to a function with 16-bytes then misalignment of this value would 00035 /// make a stack adjustment necessary, which could not be undone by the 00036 /// callee. 00037 unsigned BytesInStackArgArea; 00038 00039 /// The number of bytes to restore to deallocate space for incoming 00040 /// arguments. Canonically 0 in the C calling convention, but non-zero when 00041 /// callee is expected to pop the args. 00042 unsigned ArgumentStackToRestore; 00043 00044 /// HasStackFrame - True if this function has a stack frame. Set by 00045 /// processFunctionBeforeCalleeSavedScan(). 00046 bool HasStackFrame; 00047 00048 /// \brief Amount of stack frame size, not including callee-saved registers. 00049 unsigned LocalStackSize; 00050 00051 /// \brief Number of TLS accesses using the special (combinable) 00052 /// _TLS_MODULE_BASE_ symbol. 00053 unsigned NumLocalDynamicTLSAccesses; 00054 00055 /// \brief FrameIndex for start of varargs area for arguments passed on the 00056 /// stack. 00057 int VarArgsStackIndex; 00058 00059 /// \brief FrameIndex for start of varargs area for arguments passed in 00060 /// general purpose registers. 00061 int VarArgsGPRIndex; 00062 00063 /// \brief Size of the varargs area for arguments passed in general purpose 00064 /// registers. 00065 unsigned VarArgsGPRSize; 00066 00067 /// \brief FrameIndex for start of varargs area for arguments passed in 00068 /// floating-point registers. 00069 int VarArgsFPRIndex; 00070 00071 /// \brief Size of the varargs area for arguments passed in floating-point 00072 /// registers. 00073 unsigned VarArgsFPRSize; 00074 00075 public: 00076 AArch64FunctionInfo() 00077 : BytesInStackArgArea(0), ArgumentStackToRestore(0), HasStackFrame(false), 00078 NumLocalDynamicTLSAccesses(0), VarArgsStackIndex(0), VarArgsGPRIndex(0), 00079 VarArgsGPRSize(0), VarArgsFPRIndex(0), VarArgsFPRSize(0) {} 00080 00081 explicit AArch64FunctionInfo(MachineFunction &MF) 00082 : BytesInStackArgArea(0), ArgumentStackToRestore(0), HasStackFrame(false), 00083 NumLocalDynamicTLSAccesses(0), VarArgsStackIndex(0), VarArgsGPRIndex(0), 00084 VarArgsGPRSize(0), VarArgsFPRIndex(0), VarArgsFPRSize(0) { 00085 (void)MF; 00086 } 00087 00088 unsigned getBytesInStackArgArea() const { return BytesInStackArgArea; } 00089 void setBytesInStackArgArea(unsigned bytes) { BytesInStackArgArea = bytes; } 00090 00091 unsigned getArgumentStackToRestore() const { return ArgumentStackToRestore; } 00092 void setArgumentStackToRestore(unsigned bytes) { 00093 ArgumentStackToRestore = bytes; 00094 } 00095 00096 bool hasStackFrame() const { return HasStackFrame; } 00097 void setHasStackFrame(bool s) { HasStackFrame = s; } 00098 00099 void setLocalStackSize(unsigned Size) { LocalStackSize = Size; } 00100 unsigned getLocalStackSize() const { return LocalStackSize; } 00101 00102 void incNumLocalDynamicTLSAccesses() { ++NumLocalDynamicTLSAccesses; } 00103 unsigned getNumLocalDynamicTLSAccesses() const { 00104 return NumLocalDynamicTLSAccesses; 00105 } 00106 00107 int getVarArgsStackIndex() const { return VarArgsStackIndex; } 00108 void setVarArgsStackIndex(int Index) { VarArgsStackIndex = Index; } 00109 00110 int getVarArgsGPRIndex() const { return VarArgsGPRIndex; } 00111 void setVarArgsGPRIndex(int Index) { VarArgsGPRIndex = Index; } 00112 00113 unsigned getVarArgsGPRSize() const { return VarArgsGPRSize; } 00114 void setVarArgsGPRSize(unsigned Size) { VarArgsGPRSize = Size; } 00115 00116 int getVarArgsFPRIndex() const { return VarArgsFPRIndex; } 00117 void setVarArgsFPRIndex(int Index) { VarArgsFPRIndex = Index; } 00118 00119 unsigned getVarArgsFPRSize() const { return VarArgsFPRSize; } 00120 void setVarArgsFPRSize(unsigned Size) { VarArgsFPRSize = Size; } 00121 00122 typedef SmallPtrSet<const MachineInstr *, 16> SetOfInstructions; 00123 00124 const SetOfInstructions &getLOHRelated() const { return LOHRelated; } 00125 00126 // Shortcuts for LOH related types. 00127 class MILOHDirective { 00128 MCLOHType Kind; 00129 00130 /// Arguments of this directive. Order matters. 00131 SmallVector<const MachineInstr *, 3> Args; 00132 00133 public: 00134 typedef SmallVectorImpl<const MachineInstr *> LOHArgs; 00135 00136 MILOHDirective(MCLOHType Kind, const LOHArgs &Args) 00137 : Kind(Kind), Args(Args.begin(), Args.end()) { 00138 assert(isValidMCLOHType(Kind) && "Invalid LOH directive type!"); 00139 } 00140 00141 MCLOHType getKind() const { return Kind; } 00142 const LOHArgs &getArgs() const { return Args; } 00143 }; 00144 00145 typedef MILOHDirective::LOHArgs MILOHArgs; 00146 typedef SmallVector<MILOHDirective, 32> MILOHContainer; 00147 00148 const MILOHContainer &getLOHContainer() const { return LOHContainerSet; } 00149 00150 /// Add a LOH directive of this @p Kind and this @p Args. 00151 void addLOHDirective(MCLOHType Kind, const MILOHArgs &Args) { 00152 LOHContainerSet.push_back(MILOHDirective(Kind, Args)); 00153 LOHRelated.insert(Args.begin(), Args.end()); 00154 } 00155 00156 private: 00157 // Hold the lists of LOHs. 00158 MILOHContainer LOHContainerSet; 00159 SetOfInstructions LOHRelated; 00160 }; 00161 } // End llvm namespace 00162 00163 #endif