Tim Northover | 72062f5 | 2013-01-31 12:12:40 +0000 | [diff] [blame] | 1 | //=- 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 | |
Tim Northover | 72062f5 | 2013-01-31 12:12:40 +0000 | [diff] [blame] | 17 | #include "llvm/CodeGen/MachineFunction.h" |
| 18 | |
| 19 | namespace llvm { |
| 20 | |
| 21 | /// This class is derived from MachineFunctionInfo and contains private AArch64 |
| 22 | /// target-specific information for each MachineFunction. |
| 23 | class AArch64MachineFunctionInfo : public MachineFunctionInfo { |
| 24 | virtual void anchor(); |
| 25 | |
| 26 | /// Number of bytes of arguments this function has on the stack. If the callee |
| 27 | /// is expected to restore the argument stack this should be a multiple of 16, |
| 28 | /// all usable during a tail call. |
| 29 | /// |
| 30 | /// The alternative would forbid tail call optimisation in some cases: if we |
| 31 | /// want to transfer control from a function with 8-bytes of stack-argument |
| 32 | /// space to a function with 16-bytes then misalignment of this value would |
| 33 | /// make a stack adjustment necessary, which could not be undone by the |
| 34 | /// callee. |
| 35 | unsigned BytesInStackArgArea; |
| 36 | |
| 37 | /// The number of bytes to restore to deallocate space for incoming |
| 38 | /// arguments. Canonically 0 in the C calling convention, but non-zero when |
| 39 | /// callee is expected to pop the args. |
| 40 | unsigned ArgumentStackToRestore; |
| 41 | |
| 42 | /// If the stack needs to be adjusted on frame entry in two stages, this |
| 43 | /// records the size of the first adjustment just prior to storing |
| 44 | /// callee-saved registers. The callee-saved slots are addressed assuming |
| 45 | /// SP == <incoming-SP> - InitialStackAdjust. |
| 46 | unsigned InitialStackAdjust; |
| 47 | |
| 48 | /// Number of local-dynamic TLS accesses. |
| 49 | unsigned NumLocalDynamics; |
| 50 | |
Tim Northover | 72062f5 | 2013-01-31 12:12:40 +0000 | [diff] [blame] | 51 | /// @see AArch64 Procedure Call Standard, B.3 |
| 52 | /// |
| 53 | /// The Frame index of the area where LowerFormalArguments puts the |
| 54 | /// general-purpose registers that might contain variadic parameters. |
| 55 | int VariadicGPRIdx; |
| 56 | |
| 57 | /// @see AArch64 Procedure Call Standard, B.3 |
| 58 | /// |
| 59 | /// The size of the frame object used to store the general-purpose registers |
| 60 | /// which might contain variadic arguments. This is the offset from |
| 61 | /// VariadicGPRIdx to what's stored in __gr_top. |
| 62 | unsigned VariadicGPRSize; |
| 63 | |
| 64 | /// @see AArch64 Procedure Call Standard, B.3 |
| 65 | /// |
| 66 | /// The Frame index of the area where LowerFormalArguments puts the |
| 67 | /// floating-point registers that might contain variadic parameters. |
| 68 | int VariadicFPRIdx; |
| 69 | |
| 70 | /// @see AArch64 Procedure Call Standard, B.3 |
| 71 | /// |
| 72 | /// The size of the frame object used to store the floating-point registers |
| 73 | /// which might contain variadic arguments. This is the offset from |
| 74 | /// VariadicFPRIdx to what's stored in __vr_top. |
| 75 | unsigned VariadicFPRSize; |
| 76 | |
| 77 | /// @see AArch64 Procedure Call Standard, B.3 |
| 78 | /// |
| 79 | /// The Frame index of an object pointing just past the last known stacked |
| 80 | /// argument on entry to a variadic function. This goes into the __stack field |
| 81 | /// of the va_list type. |
| 82 | int VariadicStackIdx; |
| 83 | |
| 84 | /// The offset of the frame pointer from the stack pointer on function |
| 85 | /// entry. This is expected to be negative. |
| 86 | int FramePointerOffset; |
| 87 | |
| 88 | public: |
| 89 | AArch64MachineFunctionInfo() |
| 90 | : BytesInStackArgArea(0), |
| 91 | ArgumentStackToRestore(0), |
| 92 | InitialStackAdjust(0), |
| 93 | NumLocalDynamics(0), |
Tim Northover | 72062f5 | 2013-01-31 12:12:40 +0000 | [diff] [blame] | 94 | VariadicGPRIdx(0), |
| 95 | VariadicGPRSize(0), |
| 96 | VariadicFPRIdx(0), |
| 97 | VariadicFPRSize(0), |
| 98 | VariadicStackIdx(0), |
| 99 | FramePointerOffset(0) {} |
| 100 | |
| 101 | explicit AArch64MachineFunctionInfo(MachineFunction &MF) |
| 102 | : BytesInStackArgArea(0), |
| 103 | ArgumentStackToRestore(0), |
| 104 | InitialStackAdjust(0), |
| 105 | NumLocalDynamics(0), |
Tim Northover | 72062f5 | 2013-01-31 12:12:40 +0000 | [diff] [blame] | 106 | VariadicGPRIdx(0), |
| 107 | VariadicGPRSize(0), |
| 108 | VariadicFPRIdx(0), |
| 109 | VariadicFPRSize(0), |
| 110 | VariadicStackIdx(0), |
| 111 | FramePointerOffset(0) {} |
| 112 | |
| 113 | unsigned getBytesInStackArgArea() const { return BytesInStackArgArea; } |
| 114 | void setBytesInStackArgArea (unsigned bytes) { BytesInStackArgArea = bytes;} |
| 115 | |
| 116 | unsigned getArgumentStackToRestore() const { return ArgumentStackToRestore; } |
Tim Northover | dfe076a | 2013-02-05 13:24:56 +0000 | [diff] [blame] | 117 | void setArgumentStackToRestore(unsigned bytes) { |
| 118 | ArgumentStackToRestore = bytes; |
| 119 | } |
Tim Northover | 72062f5 | 2013-01-31 12:12:40 +0000 | [diff] [blame] | 120 | |
| 121 | unsigned getInitialStackAdjust() const { return InitialStackAdjust; } |
| 122 | void setInitialStackAdjust(unsigned bytes) { InitialStackAdjust = bytes; } |
| 123 | |
| 124 | unsigned getNumLocalDynamicTLSAccesses() const { return NumLocalDynamics; } |
| 125 | void incNumLocalDynamicTLSAccesses() { ++NumLocalDynamics; } |
| 126 | |
Tim Northover | 72062f5 | 2013-01-31 12:12:40 +0000 | [diff] [blame] | 127 | int getVariadicGPRIdx() const { return VariadicGPRIdx; } |
| 128 | void setVariadicGPRIdx(int Idx) { VariadicGPRIdx = Idx; } |
| 129 | |
| 130 | unsigned getVariadicGPRSize() const { return VariadicGPRSize; } |
| 131 | void setVariadicGPRSize(unsigned Size) { VariadicGPRSize = Size; } |
| 132 | |
| 133 | int getVariadicFPRIdx() const { return VariadicFPRIdx; } |
| 134 | void setVariadicFPRIdx(int Idx) { VariadicFPRIdx = Idx; } |
| 135 | |
| 136 | unsigned getVariadicFPRSize() const { return VariadicFPRSize; } |
| 137 | void setVariadicFPRSize(unsigned Size) { VariadicFPRSize = Size; } |
| 138 | |
| 139 | int getVariadicStackIdx() const { return VariadicStackIdx; } |
| 140 | void setVariadicStackIdx(int Idx) { VariadicStackIdx = Idx; } |
| 141 | |
| 142 | int getFramePointerOffset() const { return FramePointerOffset; } |
| 143 | void setFramePointerOffset(int Idx) { FramePointerOffset = Idx; } |
| 144 | |
| 145 | }; |
| 146 | |
| 147 | } // End llvm namespace |
| 148 | |
| 149 | #endif |