LLVM  10.0.0svn
TargetCallingConv.h
Go to the documentation of this file.
1 //===-- llvm/CodeGen/TargetCallingConv.h - Calling Convention ---*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file defines types for working with calling-convention information.
10 //
11 //===----------------------------------------------------------------------===//
12 
13 #ifndef LLVM_CODEGEN_TARGETCALLINGCONV_H
14 #define LLVM_CODEGEN_TARGETCALLINGCONV_H
15 
17 #include "llvm/Support/Alignment.h"
20 #include <cassert>
21 #include <climits>
22 #include <cstdint>
23 
24 namespace llvm {
25 namespace ISD {
26 
27  struct ArgFlagsTy {
28  private:
29  unsigned IsZExt : 1; ///< Zero extended
30  unsigned IsSExt : 1; ///< Sign extended
31  unsigned IsInReg : 1; ///< Passed in register
32  unsigned IsSRet : 1; ///< Hidden struct-ret ptr
33  unsigned IsByVal : 1; ///< Struct passed by value
34  unsigned IsNest : 1; ///< Nested fn static chain
35  unsigned IsReturned : 1; ///< Always returned
36  unsigned IsSplit : 1;
37  unsigned IsInAlloca : 1; ///< Passed with inalloca
38  unsigned IsSplitEnd : 1; ///< Last part of a split
39  unsigned IsSwiftSelf : 1; ///< Swift self parameter
40  unsigned IsSwiftError : 1; ///< Swift error parameter
41  unsigned IsHva : 1; ///< HVA field for
42  unsigned IsHvaStart : 1; ///< HVA structure start
43  unsigned IsSecArgPass : 1; ///< Second argument
44  unsigned ByValAlign : 4; ///< Log 2 of byval alignment
45  unsigned OrigAlign : 5; ///< Log 2 of original alignment
46  unsigned IsInConsecutiveRegsLast : 1;
47  unsigned IsInConsecutiveRegs : 1;
48  unsigned IsCopyElisionCandidate : 1; ///< Argument copy elision candidate
49  unsigned IsPointer : 1;
50 
51  unsigned ByValSize; ///< Byval struct size
52 
53  unsigned PointerAddrSpace; ///< Address space of pointer argument
54 
55  public:
57  : IsZExt(0), IsSExt(0), IsInReg(0), IsSRet(0), IsByVal(0), IsNest(0),
58  IsReturned(0), IsSplit(0), IsInAlloca(0), IsSplitEnd(0),
59  IsSwiftSelf(0), IsSwiftError(0), IsHva(0), IsHvaStart(0),
60  IsSecArgPass(0), ByValAlign(0), OrigAlign(0),
61  IsInConsecutiveRegsLast(0), IsInConsecutiveRegs(0),
62  IsCopyElisionCandidate(0), IsPointer(0), ByValSize(0),
63  PointerAddrSpace(0) {
64  static_assert(sizeof(*this) == 3 * sizeof(unsigned), "flags are too big");
65  }
66 
67  bool isZExt() const { return IsZExt; }
68  void setZExt() { IsZExt = 1; }
69 
70  bool isSExt() const { return IsSExt; }
71  void setSExt() { IsSExt = 1; }
72 
73  bool isInReg() const { return IsInReg; }
74  void setInReg() { IsInReg = 1; }
75 
76  bool isSRet() const { return IsSRet; }
77  void setSRet() { IsSRet = 1; }
78 
79  bool isByVal() const { return IsByVal; }
80  void setByVal() { IsByVal = 1; }
81 
82  bool isInAlloca() const { return IsInAlloca; }
83  void setInAlloca() { IsInAlloca = 1; }
84 
85  bool isSwiftSelf() const { return IsSwiftSelf; }
86  void setSwiftSelf() { IsSwiftSelf = 1; }
87 
88  bool isSwiftError() const { return IsSwiftError; }
89  void setSwiftError() { IsSwiftError = 1; }
90 
91  bool isHva() const { return IsHva; }
92  void setHva() { IsHva = 1; }
93 
94  bool isHvaStart() const { return IsHvaStart; }
95  void setHvaStart() { IsHvaStart = 1; }
96 
97  bool isSecArgPass() const { return IsSecArgPass; }
98  void setSecArgPass() { IsSecArgPass = 1; }
99 
100  bool isNest() const { return IsNest; }
101  void setNest() { IsNest = 1; }
102 
103  bool isReturned() const { return IsReturned; }
104  void setReturned() { IsReturned = 1; }
105 
106  bool isInConsecutiveRegs() const { return IsInConsecutiveRegs; }
107  void setInConsecutiveRegs() { IsInConsecutiveRegs = 1; }
108 
109  bool isInConsecutiveRegsLast() const { return IsInConsecutiveRegsLast; }
110  void setInConsecutiveRegsLast() { IsInConsecutiveRegsLast = 1; }
111 
112  bool isSplit() const { return IsSplit; }
113  void setSplit() { IsSplit = 1; }
114 
115  bool isSplitEnd() const { return IsSplitEnd; }
116  void setSplitEnd() { IsSplitEnd = 1; }
117 
118  bool isCopyElisionCandidate() const { return IsCopyElisionCandidate; }
119  void setCopyElisionCandidate() { IsCopyElisionCandidate = 1; }
120 
121  bool isPointer() const { return IsPointer; }
122  void setPointer() { IsPointer = 1; }
123 
124  unsigned getByValAlign() const {
125  MaybeAlign A = decodeMaybeAlign(ByValAlign);
126  return A ? A->value() : 0;
127  }
129  ByValAlign = encode(A);
130  assert(getByValAlign() == A.value() && "bitfield overflow");
131  }
132 
133  unsigned getOrigAlign() const {
134  MaybeAlign A = decodeMaybeAlign(OrigAlign);
135  return A ? A->value() : 0;
136  }
137  void setOrigAlign(Align A) {
138  OrigAlign = encode(A);
139  assert(getOrigAlign() == A.value() && "bitfield overflow");
140  }
141 
142  unsigned getByValSize() const { return ByValSize; }
143  void setByValSize(unsigned S) { ByValSize = S; }
144 
145  unsigned getPointerAddrSpace() const { return PointerAddrSpace; }
146  void setPointerAddrSpace(unsigned AS) { PointerAddrSpace = AS; }
147 };
148 
149  /// InputArg - This struct carries flags and type information about a
150  /// single incoming (formal) argument or incoming (from the perspective
151  /// of the caller) return value virtual register.
152  ///
153  struct InputArg {
157  bool Used = false;
158 
159  /// Index original Function's argument.
160  unsigned OrigArgIndex;
161  /// Sentinel value for implicit machine-level input arguments.
162  static const unsigned NoArgIndex = UINT_MAX;
163 
164  /// Offset in bytes of current input value relative to the beginning of
165  /// original argument. E.g. if argument was splitted into four 32 bit
166  /// registers, we got 4 InputArgs with PartOffsets 0, 4, 8 and 12.
167  unsigned PartOffset;
168 
169  InputArg() = default;
170  InputArg(ArgFlagsTy flags, EVT vt, EVT argvt, bool used,
171  unsigned origIdx, unsigned partOffs)
172  : Flags(flags), Used(used), OrigArgIndex(origIdx), PartOffset(partOffs) {
173  VT = vt.getSimpleVT();
174  ArgVT = argvt;
175  }
176 
177  bool isOrigArg() const {
178  return OrigArgIndex != NoArgIndex;
179  }
180 
181  unsigned getOrigArgIndex() const {
182  assert(OrigArgIndex != NoArgIndex && "Implicit machine-level argument");
183  return OrigArgIndex;
184  }
185  };
186 
187  /// OutputArg - This struct carries flags and a value for a
188  /// single outgoing (actual) argument or outgoing (from the perspective
189  /// of the caller) return value virtual register.
190  ///
191  struct OutputArg {
195 
196  /// IsFixed - Is this a "fixed" value, ie not passed through a vararg "...".
197  bool IsFixed = false;
198 
199  /// Index original Function's argument.
200  unsigned OrigArgIndex;
201 
202  /// Offset in bytes of current output value relative to the beginning of
203  /// original argument. E.g. if argument was splitted into four 32 bit
204  /// registers, we got 4 OutputArgs with PartOffsets 0, 4, 8 and 12.
205  unsigned PartOffset;
206 
207  OutputArg() = default;
208  OutputArg(ArgFlagsTy flags, EVT vt, EVT argvt, bool isfixed,
209  unsigned origIdx, unsigned partOffs)
210  : Flags(flags), IsFixed(isfixed), OrigArgIndex(origIdx),
211  PartOffset(partOffs) {
212  VT = vt.getSimpleVT();
213  ArgVT = argvt;
214  }
215  };
216 
217 } // end namespace ISD
218 } // end namespace llvm
219 
220 #endif // LLVM_CODEGEN_TARGETCALLINGCONV_H
This class represents lattice values for constants.
Definition: AllocatorList.h:23
InputArg - This struct carries flags and type information about a single incoming (formal) argument o...
unsigned encode(MaybeAlign A)
Returns a representation of the alignment that encodes undefined as 0.
Definition: Alignment.h:236
MVT getSimpleVT() const
Return the SimpleValueType held in the specified simple EVT.
Definition: ValueTypes.h:252
MaybeAlign decodeMaybeAlign(unsigned Value)
Dual operation of the encode function above.
Definition: Alignment.h:239
unsigned getPointerAddrSpace() const
bool isInConsecutiveRegs() const
void setByValSize(unsigned S)
OutputArg - This struct carries flags and a value for a single outgoing (actual) argument or outgoing...
uint64_t value() const
This is a hole in the type system and should not be abused.
Definition: Alignment.h:86
unsigned getByValSize() const
Machine Value Type.
unsigned getOrigAlign() const
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.
Extended Value Type.
Definition: ValueTypes.h:33
This struct is a compact representation of a valid (non-zero power of two) alignment.
Definition: Alignment.h:40
This struct is a compact representation of a valid (power of two) or undefined (0) alignment...
Definition: Alignment.h:117
bool isCopyElisionCandidate() const
unsigned OrigArgIndex
Index original Function&#39;s argument.
unsigned getByValAlign() const
void setPointerAddrSpace(unsigned AS)
unsigned getOrigArgIndex() const
unsigned PartOffset
Offset in bytes of current output value relative to the beginning of original argument.
bool isInConsecutiveRegsLast() 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&#39;s argument.