LLVM  4.0.0
TargetCallingConv.h
Go to the documentation of this file.
1 //===-- llvm/Target/TargetCallingConv.h - Calling Convention ----*- 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 defines types for working with calling-convention information.
11 //
12 //===----------------------------------------------------------------------===//
13 
14 #ifndef LLVM_TARGET_TARGETCALLINGCONV_H
15 #define LLVM_TARGET_TARGETCALLINGCONV_H
16 
18 #include "llvm/Support/DataTypes.h"
20 #include <climits>
21 
22 namespace llvm {
23 
24 namespace ISD {
25  struct ArgFlagsTy {
26  private:
27  static const uint64_t NoFlagSet = 0ULL;
28  static const uint64_t ZExt = 1ULL<<0; ///< Zero extended
29  static const uint64_t ZExtOffs = 0;
30  static const uint64_t SExt = 1ULL<<1; ///< Sign extended
31  static const uint64_t SExtOffs = 1;
32  static const uint64_t InReg = 1ULL<<2; ///< Passed in register
33  static const uint64_t InRegOffs = 2;
34  static const uint64_t SRet = 1ULL<<3; ///< Hidden struct-ret ptr
35  static const uint64_t SRetOffs = 3;
36  static const uint64_t ByVal = 1ULL<<4; ///< Struct passed by value
37  static const uint64_t ByValOffs = 4;
38  static const uint64_t Nest = 1ULL<<5; ///< Nested fn static chain
39  static const uint64_t NestOffs = 5;
40  static const uint64_t Returned = 1ULL<<6; ///< Always returned
41  static const uint64_t ReturnedOffs = 6;
42  static const uint64_t ByValAlign = 0xFULL<<7; ///< Struct alignment
43  static const uint64_t ByValAlignOffs = 7;
44  static const uint64_t Split = 1ULL<<11;
45  static const uint64_t SplitOffs = 11;
46  static const uint64_t InAlloca = 1ULL<<12; ///< Passed with inalloca
47  static const uint64_t InAllocaOffs = 12;
48  static const uint64_t SplitEnd = 1ULL<<13; ///< Last part of a split
49  static const uint64_t SplitEndOffs = 13;
50  static const uint64_t SwiftSelf = 1ULL<<14; ///< Swift self parameter
51  static const uint64_t SwiftSelfOffs = 14;
52  static const uint64_t SwiftError = 1ULL<<15; ///< Swift error parameter
53  static const uint64_t SwiftErrorOffs = 15;
54  static const uint64_t Hva = 1ULL << 16; ///< HVA field for
55  ///< vectorcall
56  static const uint64_t HvaOffs = 16;
57  static const uint64_t HvaStart = 1ULL << 17; ///< HVA structure start
58  ///< for vectorcall
59  static const uint64_t HvaStartOffs = 17;
60  static const uint64_t SecArgPass = 1ULL << 18; ///< Second argument
61  ///< pass for vectorcall
62  static const uint64_t SecArgPassOffs = 18;
63  static const uint64_t OrigAlign = 0x1FULL<<27;
64  static const uint64_t OrigAlignOffs = 27;
65  static const uint64_t ByValSize = 0x3fffffffULL<<32; ///< Struct size
66  static const uint64_t ByValSizeOffs = 32;
67  static const uint64_t InConsecutiveRegsLast = 0x1ULL<<62; ///< Struct size
68  static const uint64_t InConsecutiveRegsLastOffs = 62;
69  static const uint64_t InConsecutiveRegs = 0x1ULL<<63; ///< Struct size
70  static const uint64_t InConsecutiveRegsOffs = 63;
71 
72  static const uint64_t One = 1ULL; ///< 1 of this type, for shifts
73 
74  uint64_t Flags;
75 
76  public:
77  ArgFlagsTy() : Flags(0) { }
78 
79  bool isZExt() const { return Flags & ZExt; }
80  void setZExt() { Flags |= One << ZExtOffs; }
81 
82  bool isSExt() const { return Flags & SExt; }
83  void setSExt() { Flags |= One << SExtOffs; }
84 
85  bool isInReg() const { return Flags & InReg; }
86  void setInReg() { Flags |= One << InRegOffs; }
87 
88  bool isSRet() const { return Flags & SRet; }
89  void setSRet() { Flags |= One << SRetOffs; }
90 
91  bool isByVal() const { return Flags & ByVal; }
92  void setByVal() { Flags |= One << ByValOffs; }
93 
94  bool isInAlloca() const { return Flags & InAlloca; }
95  void setInAlloca() { Flags |= One << InAllocaOffs; }
96 
97  bool isSwiftSelf() const { return Flags & SwiftSelf; }
98  void setSwiftSelf() { Flags |= One << SwiftSelfOffs; }
99 
100  bool isSwiftError() const { return Flags & SwiftError; }
101  void setSwiftError() { Flags |= One << SwiftErrorOffs; }
102 
103  bool isHva() const { return Flags & Hva; }
104  void setHva() { Flags |= One << HvaOffs; }
105 
106  bool isHvaStart() const { return Flags & HvaStart; }
107  void setHvaStart() { Flags |= One << HvaStartOffs; }
108 
109  bool isSecArgPass() const { return Flags & SecArgPass; }
110  void setSecArgPass() { Flags |= One << SecArgPassOffs; }
111 
112  bool isNest() const { return Flags & Nest; }
113  void setNest() { Flags |= One << NestOffs; }
114 
115  bool isReturned() const { return Flags & Returned; }
116  void setReturned() { Flags |= One << ReturnedOffs; }
117 
118  bool isInConsecutiveRegs() const { return Flags & InConsecutiveRegs; }
119  void setInConsecutiveRegs() { Flags |= One << InConsecutiveRegsOffs; }
120 
121  bool isInConsecutiveRegsLast() const { return Flags & InConsecutiveRegsLast; }
122  void setInConsecutiveRegsLast() { Flags |= One << InConsecutiveRegsLastOffs; }
123 
124  unsigned getByValAlign() const {
125  return (unsigned)
126  ((One << ((Flags & ByValAlign) >> ByValAlignOffs)) / 2);
127  }
128  void setByValAlign(unsigned A) {
129  Flags = (Flags & ~ByValAlign) |
130  (uint64_t(Log2_32(A) + 1) << ByValAlignOffs);
131  }
132 
133  bool isSplit() const { return Flags & Split; }
134  void setSplit() { Flags |= One << SplitOffs; }
135 
136  bool isSplitEnd() const { return Flags & SplitEnd; }
137  void setSplitEnd() { Flags |= One << SplitEndOffs; }
138 
139  unsigned getOrigAlign() const {
140  return (unsigned)
141  ((One << ((Flags & OrigAlign) >> OrigAlignOffs)) / 2);
142  }
143  void setOrigAlign(unsigned A) {
144  Flags = (Flags & ~OrigAlign) |
145  (uint64_t(Log2_32(A) + 1) << OrigAlignOffs);
146  }
147 
148  unsigned getByValSize() const {
149  return (unsigned)((Flags & ByValSize) >> ByValSizeOffs);
150  }
151  void setByValSize(unsigned S) {
152  Flags = (Flags & ~ByValSize) | (uint64_t(S) << ByValSizeOffs);
153  }
154 
155  /// getRawBits - Represent the flags as a bunch of bits.
156  uint64_t getRawBits() const { return Flags; }
157  };
158 
159  /// InputArg - This struct carries flags and type information about a
160  /// single incoming (formal) argument or incoming (from the perspective
161  /// of the caller) return value virtual register.
162  ///
163  struct InputArg {
167  bool Used;
168 
169  /// Index original Function's argument.
170  unsigned OrigArgIndex;
171  /// Sentinel value for implicit machine-level input arguments.
172  static const unsigned NoArgIndex = UINT_MAX;
173 
174  /// Offset in bytes of current input value relative to the beginning of
175  /// original argument. E.g. if argument was splitted into four 32 bit
176  /// registers, we got 4 InputArgs with PartOffsets 0, 4, 8 and 12.
177  unsigned PartOffset;
178 
180  InputArg(ArgFlagsTy flags, EVT vt, EVT argvt, bool used,
181  unsigned origIdx, unsigned partOffs)
182  : Flags(flags), Used(used), OrigArgIndex(origIdx), PartOffset(partOffs) {
183  VT = vt.getSimpleVT();
184  ArgVT = argvt;
185  }
186 
187  bool isOrigArg() const {
188  return OrigArgIndex != NoArgIndex;
189  }
190 
191  unsigned getOrigArgIndex() const {
192  assert(OrigArgIndex != NoArgIndex && "Implicit machine-level argument");
193  return OrigArgIndex;
194  }
195  };
196 
197  /// OutputArg - This struct carries flags and a value for a
198  /// single outgoing (actual) argument or outgoing (from the perspective
199  /// of the caller) return value virtual register.
200  ///
201  struct OutputArg {
205 
206  /// IsFixed - Is this a "fixed" value, ie not passed through a vararg "...".
207  bool IsFixed;
208 
209  /// Index original Function's argument.
210  unsigned OrigArgIndex;
211 
212  /// Offset in bytes of current output value relative to the beginning of
213  /// original argument. E.g. if argument was splitted into four 32 bit
214  /// registers, we got 4 OutputArgs with PartOffsets 0, 4, 8 and 12.
215  unsigned PartOffset;
216 
218  OutputArg(ArgFlagsTy flags, EVT vt, EVT argvt, bool isfixed,
219  unsigned origIdx, unsigned partOffs)
220  : Flags(flags), IsFixed(isfixed), OrigArgIndex(origIdx),
221  PartOffset(partOffs) {
222  VT = vt.getSimpleVT();
223  ArgVT = argvt;
224  }
225  };
226 } // end namespace ISD
227 
228 } // end llvm namespace
229 
230 #endif // LLVM_TARGET_TARGETCALLINGCONV_H
void setByValAlign(unsigned A)
InputArg - This struct carries flags and type information about a single incoming (formal) argument o...
unsigned getByValSize() const
void setByValSize(unsigned S)
ELFYAML::ELF_STO Other
Definition: ELFYAML.cpp:662
OutputArg - This struct carries flags and a value for a single outgoing (actual) argument or outgoing...
bool isInConsecutiveRegs() const
Function Alias Analysis false
bool isInConsecutiveRegsLast() const
void setOrigAlign(unsigned A)
bool IsFixed
IsFixed - Is this a "fixed" value, ie not passed through a vararg "...".
MVT - Machine Value Type.
OutputArg(ArgFlagsTy flags, EVT vt, EVT argvt, bool isfixed, unsigned origIdx, unsigned partOffs)
unsigned PartOffset
Offset in bytes of current input value relative to the beginning of original argument.
EVT - Extended Value Type.
Definition: ValueTypes.h:31
unsigned getByValAlign() const
static const unsigned NoArgIndex
Sentinel value for implicit machine-level input arguments.
unsigned Log2_32(uint32_t Value)
Log2_32 - This function returns the floor log base 2 of the specified value, -1 if the value is zero...
Definition: MathExtras.h:513
unsigned OrigArgIndex
Index original Function's argument.
uint64_t getRawBits() const
getRawBits - Represent the flags as a bunch of bits.
unsigned PartOffset
Offset in bytes of current output value relative to the beginning of original argument.
unsigned getOrigArgIndex() const
InputArg(ArgFlagsTy flags, EVT vt, EVT argvt, bool used, unsigned origIdx, unsigned partOffs)
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
unsigned OrigArgIndex
Index original Function's argument.
unsigned getOrigAlign() const
static GCRegistry::Add< ErlangGC > A("erlang","erlang-compatible garbage collector")
MVT getSimpleVT() const
getSimpleVT - Return the SimpleValueType held in the specified simple EVT.
Definition: ValueTypes.h:226