clang  3.9.0
CGFunctionInfo.h
Go to the documentation of this file.
1 //==-- CGFunctionInfo.h - Representation of function argument/return types -==//
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 // Defines CGFunctionInfo and associated types used in representing the
11 // LLVM source types and ABI-coerced types for function arguments and
12 // return values.
13 //
14 //===----------------------------------------------------------------------===//
15 
16 #ifndef LLVM_CLANG_CODEGEN_CGFUNCTIONINFO_H
17 #define LLVM_CLANG_CODEGEN_CGFUNCTIONINFO_H
18 
19 #include "clang/AST/Attr.h"
21 #include "clang/AST/CharUnits.h"
22 #include "clang/AST/Decl.h"
23 #include "clang/AST/Type.h"
24 #include "llvm/IR/DerivedTypes.h"
25 #include "llvm/ADT/FoldingSet.h"
26 #include "llvm/Support/TrailingObjects.h"
27 #include <cassert>
28 
29 namespace clang {
30 namespace CodeGen {
31 
32 /// ABIArgInfo - Helper class to encapsulate information about how a
33 /// specific C type should be passed to or returned from a function.
34 class ABIArgInfo {
35 public:
36  enum Kind : uint8_t {
37  /// Direct - Pass the argument directly using the normal converted LLVM
38  /// type, or by coercing to another specified type stored in
39  /// 'CoerceToType'). If an offset is specified (in UIntData), then the
40  /// argument passed is offset by some number of bytes in the memory
41  /// representation. A dummy argument is emitted before the real argument
42  /// if the specified type stored in "PaddingType" is not zero.
44 
45  /// Extend - Valid only for integer argument types. Same as 'direct'
46  /// but also emit a zero/sign extension attribute.
48 
49  /// Indirect - Pass the argument indirectly via a hidden pointer
50  /// with the specified alignment (0 indicates default alignment).
52 
53  /// Ignore - Ignore the argument (treat as void). Useful for void and
54  /// empty structs.
56 
57  /// Expand - Only valid for aggregate argument types. The structure should
58  /// be expanded into consecutive arguments for its constituent fields.
59  /// Currently expand is only allowed on structures whose fields
60  /// are all scalar types or are themselves expandable types.
62 
63  /// CoerceAndExpand - Only valid for aggregate argument types. The
64  /// structure should be expanded into consecutive arguments corresponding
65  /// to the non-array elements of the type stored in CoerceToType.
66  /// Array elements in the type are assumed to be padding and skipped.
68 
69  /// InAlloca - Pass the argument directly using the LLVM inalloca attribute.
70  /// This is similar to indirect with byval, except it only applies to
71  /// arguments stored in memory and forbids any implicit copies. When
72  /// applied to a return type, it means the value is returned indirectly via
73  /// an implicit sret parameter stored in the argument struct.
77  };
78 
79 private:
80  llvm::Type *TypeData; // canHaveCoerceToType()
81  union {
82  llvm::Type *PaddingType; // canHavePaddingType()
83  llvm::Type *UnpaddedCoerceAndExpandType; // isCoerceAndExpand()
84  };
85  union {
86  unsigned DirectOffset; // isDirect() || isExtend()
87  unsigned IndirectAlign; // isIndirect()
88  unsigned AllocaFieldIndex; // isInAlloca()
89  };
90  Kind TheKind;
91  bool PaddingInReg : 1;
92  bool InAllocaSRet : 1; // isInAlloca()
93  bool IndirectByVal : 1; // isIndirect()
94  bool IndirectRealign : 1; // isIndirect()
95  bool SRetAfterThis : 1; // isIndirect()
96  bool InReg : 1; // isDirect() || isExtend() || isIndirect()
97  bool CanBeFlattened: 1; // isDirect()
98 
99  bool canHavePaddingType() const {
100  return isDirect() || isExtend() || isIndirect() || isExpand();
101  }
102  void setPaddingType(llvm::Type *T) {
103  assert(canHavePaddingType());
104  PaddingType = T;
105  }
106 
107  void setUnpaddedCoerceToType(llvm::Type *T) {
108  assert(isCoerceAndExpand());
110  }
111 
112  ABIArgInfo(Kind K)
113  : TheKind(K), PaddingInReg(false), InReg(false) {
114  }
115 
116 public:
118  : TypeData(nullptr), PaddingType(nullptr), DirectOffset(0),
119  TheKind(Direct), PaddingInReg(false), InReg(false) {}
120 
121  static ABIArgInfo getDirect(llvm::Type *T = nullptr, unsigned Offset = 0,
122  llvm::Type *Padding = nullptr,
123  bool CanBeFlattened = true) {
124  auto AI = ABIArgInfo(Direct);
125  AI.setCoerceToType(T);
126  AI.setPaddingType(Padding);
127  AI.setDirectOffset(Offset);
128  AI.setCanBeFlattened(CanBeFlattened);
129  return AI;
130  }
131  static ABIArgInfo getDirectInReg(llvm::Type *T = nullptr) {
132  auto AI = getDirect(T);
133  AI.setInReg(true);
134  return AI;
135  }
136  static ABIArgInfo getExtend(llvm::Type *T = nullptr) {
137  auto AI = ABIArgInfo(Extend);
138  AI.setCoerceToType(T);
139  AI.setPaddingType(nullptr);
140  AI.setDirectOffset(0);
141  return AI;
142  }
143  static ABIArgInfo getExtendInReg(llvm::Type *T = nullptr) {
144  auto AI = getExtend(T);
145  AI.setInReg(true);
146  return AI;
147  }
149  return ABIArgInfo(Ignore);
150  }
151  static ABIArgInfo getIndirect(CharUnits Alignment, bool ByVal = true,
152  bool Realign = false,
153  llvm::Type *Padding = nullptr) {
154  auto AI = ABIArgInfo(Indirect);
155  AI.setIndirectAlign(Alignment);
156  AI.setIndirectByVal(ByVal);
157  AI.setIndirectRealign(Realign);
158  AI.setSRetAfterThis(false);
159  AI.setPaddingType(Padding);
160  return AI;
161  }
162  static ABIArgInfo getIndirectInReg(CharUnits Alignment, bool ByVal = true,
163  bool Realign = false) {
164  auto AI = getIndirect(Alignment, ByVal, Realign);
165  AI.setInReg(true);
166  return AI;
167  }
168  static ABIArgInfo getInAlloca(unsigned FieldIndex) {
169  auto AI = ABIArgInfo(InAlloca);
170  AI.setInAllocaFieldIndex(FieldIndex);
171  return AI;
172  }
174  auto AI = ABIArgInfo(Expand);
175  AI.setPaddingType(nullptr);
176  return AI;
177  }
178  static ABIArgInfo getExpandWithPadding(bool PaddingInReg,
179  llvm::Type *Padding) {
180  auto AI = getExpand();
181  AI.setPaddingInReg(PaddingInReg);
182  AI.setPaddingType(Padding);
183  return AI;
184  }
185 
186  /// \param unpaddedCoerceToType The coerce-to type with padding elements
187  /// removed, canonicalized to a single element if it would otherwise
188  /// have exactly one element.
189  static ABIArgInfo getCoerceAndExpand(llvm::StructType *coerceToType,
190  llvm::Type *unpaddedCoerceToType) {
191 #ifndef NDEBUG
192  // Sanity checks on unpaddedCoerceToType.
193 
194  // Assert that we only have a struct type if there are multiple elements.
195  auto unpaddedStruct = dyn_cast<llvm::StructType>(unpaddedCoerceToType);
196  assert(!unpaddedStruct || unpaddedStruct->getNumElements() != 1);
197 
198  // Assert that all the non-padding elements have a corresponding element
199  // in the unpadded type.
200  unsigned unpaddedIndex = 0;
201  for (auto eltType : coerceToType->elements()) {
202  if (isPaddingForCoerceAndExpand(eltType)) continue;
203  if (unpaddedStruct) {
204  assert(unpaddedStruct->getElementType(unpaddedIndex) == eltType);
205  } else {
206  assert(unpaddedIndex == 0 && unpaddedCoerceToType == eltType);
207  }
208  unpaddedIndex++;
209  }
210 
211  // Assert that there aren't extra elements in the unpadded type.
212  if (unpaddedStruct) {
213  assert(unpaddedStruct->getNumElements() == unpaddedIndex);
214  } else {
215  assert(unpaddedIndex == 1);
216  }
217 #endif
218 
219  auto AI = ABIArgInfo(CoerceAndExpand);
220  AI.setCoerceToType(coerceToType);
221  AI.setUnpaddedCoerceToType(unpaddedCoerceToType);
222  return AI;
223  }
224 
225  static bool isPaddingForCoerceAndExpand(llvm::Type *eltType) {
226  if (eltType->isArrayTy()) {
227  assert(eltType->getArrayElementType()->isIntegerTy(8));
228  return true;
229  } else {
230  return false;
231  }
232  }
233 
234  Kind getKind() const { return TheKind; }
235  bool isDirect() const { return TheKind == Direct; }
236  bool isInAlloca() const { return TheKind == InAlloca; }
237  bool isExtend() const { return TheKind == Extend; }
238  bool isIgnore() const { return TheKind == Ignore; }
239  bool isIndirect() const { return TheKind == Indirect; }
240  bool isExpand() const { return TheKind == Expand; }
241  bool isCoerceAndExpand() const { return TheKind == CoerceAndExpand; }
242 
243  bool canHaveCoerceToType() const {
244  return isDirect() || isExtend() || isCoerceAndExpand();
245  }
246 
247  // Direct/Extend accessors
248  unsigned getDirectOffset() const {
249  assert((isDirect() || isExtend()) && "Not a direct or extend kind");
250  return DirectOffset;
251  }
252  void setDirectOffset(unsigned Offset) {
253  assert((isDirect() || isExtend()) && "Not a direct or extend kind");
255  }
256 
258  return (canHavePaddingType() ? PaddingType : nullptr);
259  }
260 
261  bool getPaddingInReg() const {
262  return PaddingInReg;
263  }
264  void setPaddingInReg(bool PIR) {
265  PaddingInReg = PIR;
266  }
267 
269  assert(canHaveCoerceToType() && "Invalid kind!");
270  return TypeData;
271  }
272 
274  assert(canHaveCoerceToType() && "Invalid kind!");
275  TypeData = T;
276  }
277 
278  llvm::StructType *getCoerceAndExpandType() const {
279  assert(isCoerceAndExpand());
280  return cast<llvm::StructType>(TypeData);
281  }
282 
284  assert(isCoerceAndExpand());
286  }
287 
289  assert(isCoerceAndExpand());
290  if (auto structTy =
291  dyn_cast<llvm::StructType>(UnpaddedCoerceAndExpandType)) {
292  return structTy->elements();
293  } else {
294  return llvm::makeArrayRef(&UnpaddedCoerceAndExpandType, 1);
295  }
296  }
297 
298  bool getInReg() const {
299  assert((isDirect() || isExtend() || isIndirect()) && "Invalid kind!");
300  return InReg;
301  }
302 
303  void setInReg(bool IR) {
304  assert((isDirect() || isExtend() || isIndirect()) && "Invalid kind!");
305  InReg = IR;
306  }
307 
308  // Indirect accessors
310  assert(isIndirect() && "Invalid kind!");
312  }
314  assert(isIndirect() && "Invalid kind!");
315  IndirectAlign = IA.getQuantity();
316  }
317 
318  bool getIndirectByVal() const {
319  assert(isIndirect() && "Invalid kind!");
320  return IndirectByVal;
321  }
322  void setIndirectByVal(bool IBV) {
323  assert(isIndirect() && "Invalid kind!");
324  IndirectByVal = IBV;
325  }
326 
327  bool getIndirectRealign() const {
328  assert(isIndirect() && "Invalid kind!");
329  return IndirectRealign;
330  }
331  void setIndirectRealign(bool IR) {
332  assert(isIndirect() && "Invalid kind!");
333  IndirectRealign = IR;
334  }
335 
336  bool isSRetAfterThis() const {
337  assert(isIndirect() && "Invalid kind!");
338  return SRetAfterThis;
339  }
340  void setSRetAfterThis(bool AfterThis) {
341  assert(isIndirect() && "Invalid kind!");
342  SRetAfterThis = AfterThis;
343  }
344 
345  unsigned getInAllocaFieldIndex() const {
346  assert(isInAlloca() && "Invalid kind!");
347  return AllocaFieldIndex;
348  }
349  void setInAllocaFieldIndex(unsigned FieldIndex) {
350  assert(isInAlloca() && "Invalid kind!");
351  AllocaFieldIndex = FieldIndex;
352  }
353 
354  /// \brief Return true if this field of an inalloca struct should be returned
355  /// to implement a struct return calling convention.
356  bool getInAllocaSRet() const {
357  assert(isInAlloca() && "Invalid kind!");
358  return InAllocaSRet;
359  }
360 
361  void setInAllocaSRet(bool SRet) {
362  assert(isInAlloca() && "Invalid kind!");
363  InAllocaSRet = SRet;
364  }
365 
366  bool getCanBeFlattened() const {
367  assert(isDirect() && "Invalid kind!");
368  return CanBeFlattened;
369  }
370 
371  void setCanBeFlattened(bool Flatten) {
372  assert(isDirect() && "Invalid kind!");
373  CanBeFlattened = Flatten;
374  }
375 
376  void dump() const;
377 };
378 
379 /// A class for recording the number of arguments that a function
380 /// signature requires.
382  /// The number of required arguments, or ~0 if the signature does
383  /// not permit optional arguments.
384  unsigned NumRequired;
385 public:
386  enum All_t { All };
387 
388  RequiredArgs(All_t _) : NumRequired(~0U) {}
389  explicit RequiredArgs(unsigned n) : NumRequired(n) {
390  assert(n != ~0U);
391  }
392 
393  /// Compute the arguments required by the given formal prototype,
394  /// given that there may be some additional, non-formal arguments
395  /// in play.
396  ///
397  /// If FD is not null, this will consider pass_object_size params in FD.
399  unsigned additional,
400  const FunctionDecl *FD) {
401  if (!prototype->isVariadic()) return All;
402  if (FD)
403  additional +=
404  llvm::count_if(FD->parameters(), [](const ParmVarDecl *PVD) {
405  return PVD->hasAttr<PassObjectSizeAttr>();
406  });
407  return RequiredArgs(prototype->getNumParams() + additional);
408  }
409 
410  static RequiredArgs forPrototype(const FunctionProtoType *prototype,
411  const FunctionDecl *FD) {
412  return forPrototypePlus(prototype, 0, FD);
413  }
414 
416  const FunctionDecl *FD) {
417  return forPrototype(prototype.getTypePtr(), FD);
418  }
419 
421  unsigned additional,
422  const FunctionDecl *FD) {
423  return forPrototypePlus(prototype.getTypePtr(), additional, FD);
424  }
425 
426  bool allowsOptionalArgs() const { return NumRequired != ~0U; }
427  unsigned getNumRequiredArgs() const {
428  assert(allowsOptionalArgs());
429  return NumRequired;
430  }
431 
432  unsigned getOpaqueData() const { return NumRequired; }
433  static RequiredArgs getFromOpaqueData(unsigned value) {
434  if (value == ~0U) return All;
435  return RequiredArgs(value);
436  }
437 };
438 
439 // Implementation detail of CGFunctionInfo, factored out so it can be named
440 // in the TrailingObjects base class of CGFunctionInfo.
444 };
445 
446 /// CGFunctionInfo - Class to encapsulate the information about a
447 /// function definition.
448 class CGFunctionInfo final
449  : public llvm::FoldingSetNode,
450  private llvm::TrailingObjects<CGFunctionInfo, CGFunctionInfoArgInfo,
451  FunctionProtoType::ExtParameterInfo> {
454 
455  /// The LLVM::CallingConv to use for this function (as specified by the
456  /// user).
457  unsigned CallingConvention : 8;
458 
459  /// The LLVM::CallingConv to actually use for this function, which may
460  /// depend on the ABI.
461  unsigned EffectiveCallingConvention : 8;
462 
463  /// The clang::CallingConv that this was originally created with.
464  unsigned ASTCallingConvention : 8;
465 
466  /// Whether this is an instance method.
467  unsigned InstanceMethod : 1;
468 
469  /// Whether this is a chain call.
470  unsigned ChainCall : 1;
471 
472  /// Whether this function is noreturn.
473  unsigned NoReturn : 1;
474 
475  /// Whether this function is returns-retained.
476  unsigned ReturnsRetained : 1;
477 
478  /// How many arguments to pass inreg.
479  unsigned HasRegParm : 1;
480  unsigned RegParm : 3;
481 
482  RequiredArgs Required;
483 
484  /// The struct representing all arguments passed in memory. Only used when
485  /// passing non-trivial types with inalloca. Not part of the profile.
486  llvm::StructType *ArgStruct;
487  unsigned ArgStructAlign : 31;
488  unsigned HasExtParameterInfos : 1;
489 
490  unsigned NumArgs;
491 
492  ArgInfo *getArgsBuffer() {
493  return getTrailingObjects<ArgInfo>();
494  }
495  const ArgInfo *getArgsBuffer() const {
496  return getTrailingObjects<ArgInfo>();
497  }
498 
499  ExtParameterInfo *getExtParameterInfosBuffer() {
500  return getTrailingObjects<ExtParameterInfo>();
501  }
502  const ExtParameterInfo *getExtParameterInfosBuffer() const{
503  return getTrailingObjects<ExtParameterInfo>();
504  }
505 
506  CGFunctionInfo() : Required(RequiredArgs::All) {}
507 
508 public:
509  static CGFunctionInfo *create(unsigned llvmCC,
510  bool instanceMethod,
511  bool chainCall,
512  const FunctionType::ExtInfo &extInfo,
513  ArrayRef<ExtParameterInfo> paramInfos,
514  CanQualType resultType,
515  ArrayRef<CanQualType> argTypes,
516  RequiredArgs required);
517  void operator delete(void *p) { ::operator delete(p); }
518 
519  // Friending class TrailingObjects is apparently not good enough for MSVC,
520  // so these have to be public.
521  friend class TrailingObjects;
522  size_t numTrailingObjects(OverloadToken<ArgInfo>) const {
523  return NumArgs + 1;
524  }
525  size_t numTrailingObjects(OverloadToken<ExtParameterInfo>) const {
526  return (HasExtParameterInfos ? NumArgs : 0);
527  }
528 
529  typedef const ArgInfo *const_arg_iterator;
531 
532  typedef llvm::iterator_range<arg_iterator> arg_range;
533  typedef llvm::iterator_range<const_arg_iterator> arg_const_range;
534 
537  return arg_const_range(arg_begin(), arg_end());
538  }
539 
540  const_arg_iterator arg_begin() const { return getArgsBuffer() + 1; }
541  const_arg_iterator arg_end() const { return getArgsBuffer() + 1 + NumArgs; }
542  arg_iterator arg_begin() { return getArgsBuffer() + 1; }
543  arg_iterator arg_end() { return getArgsBuffer() + 1 + NumArgs; }
544 
545  unsigned arg_size() const { return NumArgs; }
546 
547  bool isVariadic() const { return Required.allowsOptionalArgs(); }
548  RequiredArgs getRequiredArgs() const { return Required; }
549  unsigned getNumRequiredArgs() const {
551  }
552 
553  bool isInstanceMethod() const { return InstanceMethod; }
554 
555  bool isChainCall() const { return ChainCall; }
556 
557  bool isNoReturn() const { return NoReturn; }
558 
559  /// In ARC, whether this function retains its return value. This
560  /// is not always reliable for call sites.
561  bool isReturnsRetained() const { return ReturnsRetained; }
562 
563  /// getASTCallingConvention() - Return the AST-specified calling
564  /// convention.
566  return CallingConv(ASTCallingConvention);
567  }
568 
569  /// getCallingConvention - Return the user specified calling
570  /// convention, which has been translated into an LLVM CC.
571  unsigned getCallingConvention() const { return CallingConvention; }
572 
573  /// getEffectiveCallingConvention - Return the actual calling convention to
574  /// use, which may depend on the ABI.
575  unsigned getEffectiveCallingConvention() const {
576  return EffectiveCallingConvention;
577  }
579  EffectiveCallingConvention = Value;
580  }
581 
582  bool getHasRegParm() const { return HasRegParm; }
583  unsigned getRegParm() const { return RegParm; }
584 
590  }
591 
592  CanQualType getReturnType() const { return getArgsBuffer()[0].type; }
593 
594  ABIArgInfo &getReturnInfo() { return getArgsBuffer()[0].info; }
595  const ABIArgInfo &getReturnInfo() const { return getArgsBuffer()[0].info; }
596 
598  if (!HasExtParameterInfos) return {};
599  return llvm::makeArrayRef(getExtParameterInfosBuffer(), NumArgs);
600  }
601  ExtParameterInfo getExtParameterInfo(unsigned argIndex) const {
602  assert(argIndex <= NumArgs);
603  if (!HasExtParameterInfos) return ExtParameterInfo();
604  return getExtParameterInfos()[argIndex];
605  }
606 
607  /// \brief Return true if this function uses inalloca arguments.
608  bool usesInAlloca() const { return ArgStruct; }
609 
610  /// \brief Get the struct type used to represent all the arguments in memory.
611  llvm::StructType *getArgStruct() const { return ArgStruct; }
613  return CharUnits::fromQuantity(ArgStructAlign);
614  }
615  void setArgStruct(llvm::StructType *Ty, CharUnits Align) {
616  ArgStruct = Ty;
617  ArgStructAlign = Align.getQuantity();
618  }
619 
620  void Profile(llvm::FoldingSetNodeID &ID) {
621  ID.AddInteger(getASTCallingConvention());
622  ID.AddBoolean(InstanceMethod);
623  ID.AddBoolean(ChainCall);
624  ID.AddBoolean(NoReturn);
625  ID.AddBoolean(ReturnsRetained);
626  ID.AddBoolean(HasRegParm);
627  ID.AddInteger(RegParm);
628  ID.AddInteger(Required.getOpaqueData());
629  ID.AddBoolean(HasExtParameterInfos);
630  if (HasExtParameterInfos) {
631  for (auto paramInfo : getExtParameterInfos())
632  ID.AddInteger(paramInfo.getOpaqueValue());
633  }
634  getReturnType().Profile(ID);
635  for (const auto &I : arguments())
636  I.type.Profile(ID);
637  }
638  static void Profile(llvm::FoldingSetNodeID &ID,
639  bool InstanceMethod,
640  bool ChainCall,
641  const FunctionType::ExtInfo &info,
642  ArrayRef<ExtParameterInfo> paramInfos,
643  RequiredArgs required,
644  CanQualType resultType,
645  ArrayRef<CanQualType> argTypes) {
646  ID.AddInteger(info.getCC());
647  ID.AddBoolean(InstanceMethod);
648  ID.AddBoolean(ChainCall);
649  ID.AddBoolean(info.getNoReturn());
650  ID.AddBoolean(info.getProducesResult());
651  ID.AddBoolean(info.getHasRegParm());
652  ID.AddInteger(info.getRegParm());
653  ID.AddInteger(required.getOpaqueData());
654  ID.AddBoolean(!paramInfos.empty());
655  if (!paramInfos.empty()) {
656  for (auto paramInfo : paramInfos)
657  ID.AddInteger(paramInfo.getOpaqueValue());
658  }
659  resultType.Profile(ID);
661  i = argTypes.begin(), e = argTypes.end(); i != e; ++i) {
662  i->Profile(ID);
663  }
664  }
665 };
666 
667 /// CGCalleeInfo - Class to encapsulate the information about a callee to be
668 /// used during the generation of call/invoke instructions.
670  /// \brief The function proto type of the callee.
671  const FunctionProtoType *CalleeProtoTy;
672  /// \brief The function declaration of the callee.
673  const Decl *CalleeDecl;
674 
675 public:
676  explicit CGCalleeInfo() : CalleeProtoTy(nullptr), CalleeDecl(nullptr) {}
677  CGCalleeInfo(const FunctionProtoType *calleeProtoTy, const Decl *calleeDecl)
678  : CalleeProtoTy(calleeProtoTy), CalleeDecl(calleeDecl) {}
679  CGCalleeInfo(const FunctionProtoType *calleeProtoTy)
680  : CalleeProtoTy(calleeProtoTy), CalleeDecl(nullptr) {}
681  CGCalleeInfo(const Decl *calleeDecl)
682  : CalleeProtoTy(nullptr), CalleeDecl(calleeDecl) {}
683 
685  return CalleeProtoTy;
686  }
687  const Decl *getCalleeDecl() { return CalleeDecl; }
688 };
689 
690 } // end namespace CodeGen
691 } // end namespace clang
692 
693 #endif
Ignore - Ignore the argument (treat as void).
FunctionDecl - An instance of this class is created to represent a function declaration or definition...
Definition: Decl.h:1561
bool isVariadic() const
Definition: Type.h:3366
void setEffectiveCallingConvention(unsigned Value)
void setSRetAfterThis(bool AfterThis)
static ABIArgInfo getExtend(llvm::Type *T=nullptr)
llvm::Type * UnpaddedCoerceAndExpandType
static RequiredArgs forPrototype(const FunctionProtoType *prototype, const FunctionDecl *FD)
CanQualType getReturnType() const
unsigned getInAllocaFieldIndex() const
static RequiredArgs getFromOpaqueData(unsigned value)
C Language Family Type Representation.
Extend - Valid only for integer argument types.
QuantityType getQuantity() const
getQuantity - Get the raw integer representation of this quantity.
Definition: CharUnits.h:179
Direct - Pass the argument directly using the normal converted LLVM type, or by coercing to another s...
void setIndirectAlign(CharUnits IA)
void setCanBeFlattened(bool Flatten)
static void Profile(llvm::FoldingSetNodeID &ID, bool InstanceMethod, bool ChainCall, const FunctionType::ExtInfo &info, ArrayRef< ExtParameterInfo > paramInfos, RequiredArgs required, CanQualType resultType, ArrayRef< CanQualType > argTypes)
void setCoerceToType(llvm::Type *T)
static ABIArgInfo getIgnore()
ParmVarDecl - Represents a parameter to a function.
Definition: Decl.h:1377
CGCalleeInfo(const Decl *calleeDecl)
unsigned getNumParams() const
Definition: Type.h:3271
void setDirectOffset(unsigned Offset)
const_arg_iterator arg_end() const
Indirect - Pass the argument indirectly via a hidden pointer with the specified alignment (0 indicate...
static ABIArgInfo getExtendInReg(llvm::Type *T=nullptr)
bool getInAllocaSRet() const
Return true if this field of an inalloca struct should be returned to implement a struct return calli...
Interesting information about a specific parameter that can't simply be reflected in parameter's type...
Definition: Type.h:3094
void setPaddingInReg(bool PIR)
llvm::StructType * getArgStruct() const
Get the struct type used to represent all the arguments in memory.
llvm::Type * getCoerceToType() const
unsigned getRegParm() const
Definition: Type.h:2948
static ABIArgInfo getIndirectInReg(CharUnits Alignment, bool ByVal=true, bool Realign=false)
unsigned getEffectiveCallingConvention() const
getEffectiveCallingConvention - Return the actual calling convention to use, which may depend on the ...
CharUnits getArgStructAlignment() const
const FunctionProtoType * getCalleeFunctionProtoType()
static ABIArgInfo getDirect(llvm::Type *T=nullptr, unsigned Offset=0, llvm::Type *Padding=nullptr, bool CanBeFlattened=true)
void setInAllocaFieldIndex(unsigned FieldIndex)
static ABIArgInfo getExpandWithPadding(bool PaddingInReg, llvm::Type *Padding)
CharUnits - This is an opaque type for sizes expressed in character units.
Definition: CharUnits.h:38
uint32_t Offset
Definition: CacheTokens.cpp:44
size_t numTrailingObjects(OverloadToken< ArgInfo >) const
ABIArgInfo - Helper class to encapsulate information about how a specific C type should be passed to ...
unsigned getCallingConvention() const
getCallingConvention - Return the user specified calling convention, which has been translated into a...
llvm::iterator_range< const_arg_iterator > arg_const_range
static ABIArgInfo getExpand()
detail::InMemoryDirectory::const_iterator I
llvm::StructType * getCoerceAndExpandType() const
unsigned getOpaqueData() const
unsigned getNumRequiredArgs() const
llvm::Type * getUnpaddedCoerceAndExpandType() const
Represents a prototype with parameter type info, e.g.
Definition: Type.h:3073
void setIndirectByVal(bool IBV)
ArrayRef< llvm::Type * > getCoerceAndExpandTypeSequence() const
CGCalleeInfo(const FunctionProtoType *calleeProtoTy)
bool usesInAlloca() const
Return true if this function uses inalloca arguments.
CharUnits getIndirectAlign() const
static RequiredArgs forPrototypePlus(CanQual< FunctionProtoType > prototype, unsigned additional, const FunctionDecl *FD)
bool getNoReturn() const
Definition: Type.h:2945
static CharUnits fromQuantity(QuantityType Quantity)
fromQuantity - Construct a CharUnits quantity from a raw integer type.
Definition: CharUnits.h:63
struct ExtInfo * ExtInfo
Definition: CGCleanup.h:260
static bool isPaddingForCoerceAndExpand(llvm::Type *eltType)
A class for recording the number of arguments that a function signature requires. ...
void Profile(llvm::FoldingSetNodeID &ID)
class LLVM_ALIGNAS(8) TemplateSpecializationType unsigned NumArgs
Represents a type template specialization; the template must be a class template, a type alias templa...
Definition: Type.h:4154
size_t numTrailingObjects(OverloadToken< ExtParameterInfo >) const
void Profile(llvm::FoldingSetNodeID &ID) const
llvm::Type * getPaddingType() const
CallingConv
CallingConv - Specifies the calling convention that a function uses.
Definition: Specifiers.h:231
CallingConv getASTCallingConvention() const
getASTCallingConvention() - Return the AST-specified calling convention.
unsigned getNumRequiredArgs() const
The l-value was considered opaque, so the alignment was determined from a type.
#define false
Definition: stdbool.h:33
Kind
FunctionType::ExtInfo getExtInfo() const
RequiredArgs getRequiredArgs() const
const std::string ID
void setArgStruct(llvm::StructType *Ty, CharUnits Align)
bool isReturnsRetained() const
In ARC, whether this function retains its return value.
ArrayRef< ParmVarDecl * > parameters() const
Definition: Decl.h:1989
CoerceAndExpand - Only valid for aggregate argument types.
llvm::iterator_range< arg_iterator > arg_range
InAlloca - Pass the argument directly using the LLVM inalloca attribute.
const ABIArgInfo & getReturnInfo() const
CGCalleeInfo(const FunctionProtoType *calleeProtoTy, const Decl *calleeDecl)
CGFunctionInfo - Class to encapsulate the information about a function definition.
bool canHaveCoerceToType() const
unsigned getDirectOffset() const
static ABIArgInfo getDirectInReg(llvm::Type *T=nullptr)
bool getProducesResult() const
Definition: Type.h:2946
CallingConv getCC() const
Definition: Type.h:2954
static CGFunctionInfo * create(unsigned llvmCC, bool instanceMethod, bool chainCall, const FunctionType::ExtInfo &extInfo, ArrayRef< ExtParameterInfo > paramInfos, CanQualType resultType, ArrayRef< CanQualType > argTypes, RequiredArgs required)
Definition: CGCall.cpp:727
static RequiredArgs forPrototype(CanQual< FunctionProtoType > prototype, const FunctionDecl *FD)
friend TrailingObjects
Definition: OpenMPClause.h:258
Expand - Only valid for aggregate argument types.
static ABIArgInfo getInAlloca(unsigned FieldIndex)
static ABIArgInfo getCoerceAndExpand(llvm::StructType *coerceToType, llvm::Type *unpaddedCoerceToType)
ArrayRef< ExtParameterInfo > getExtParameterInfos() const
const T * getTypePtr() const
Retrieve the underlying type pointer, which refers to a canonical type.
Definition: CanonicalType.h:70
const_arg_iterator arg_begin() const
bool getHasRegParm() const
Definition: Type.h:2947
static RequiredArgs forPrototypePlus(const FunctionProtoType *prototype, unsigned additional, const FunctionDecl *FD)
Compute the arguments required by the given formal prototype, given that there may be some additional...
arg_const_range arguments() const
bool getIndirectRealign() const
void setInAllocaSRet(bool SRet)
ExtParameterInfo getExtParameterInfo(unsigned argIndex) const
static ABIArgInfo getIndirect(CharUnits Alignment, bool ByVal=true, bool Realign=false, llvm::Type *Padding=nullptr)
void setIndirectRealign(bool IR)
CGCalleeInfo - Class to encapsulate the information about a callee to be used during the generation o...
A class which abstracts out some details necessary for making a call.
Definition: Type.h:2904