16 #ifndef LLVM_CLANG_CODEGEN_CGFUNCTIONINFO_H
17 #define LLVM_CLANG_CODEGEN_CGFUNCTIONINFO_H
24 #include "llvm/IR/DerivedTypes.h"
25 #include "llvm/ADT/FoldingSet.h"
26 #include "llvm/Support/TrailingObjects.h"
91 bool PaddingInReg : 1;
92 bool InAllocaSRet : 1;
93 bool IndirectByVal : 1;
94 bool IndirectRealign : 1;
95 bool SRetAfterThis : 1;
97 bool CanBeFlattened: 1;
99 bool canHavePaddingType()
const {
103 assert(canHavePaddingType());
113 : TheKind(K), PaddingInReg(
false), InReg(
false) {
123 bool CanBeFlattened =
true) {
125 AI.setCoerceToType(T);
126 AI.setPaddingType(Padding);
127 AI.setDirectOffset(
Offset);
128 AI.setCanBeFlattened(CanBeFlattened);
138 AI.setCoerceToType(T);
139 AI.setPaddingType(
nullptr);
140 AI.setDirectOffset(0);
152 bool Realign =
false,
155 AI.setIndirectAlign(Alignment);
156 AI.setIndirectByVal(ByVal);
157 AI.setIndirectRealign(Realign);
158 AI.setSRetAfterThis(
false);
159 AI.setPaddingType(Padding);
163 bool Realign =
false) {
170 AI.setInAllocaFieldIndex(FieldIndex);
175 AI.setPaddingType(
nullptr);
181 AI.setPaddingInReg(PaddingInReg);
182 AI.setPaddingType(Padding);
195 auto unpaddedStruct = dyn_cast<llvm::StructType>(unpaddedCoerceToType);
196 assert(!unpaddedStruct || unpaddedStruct->getNumElements() != 1);
200 unsigned unpaddedIndex = 0;
201 for (
auto eltType : coerceToType->elements()) {
203 if (unpaddedStruct) {
204 assert(unpaddedStruct->getElementType(unpaddedIndex) == eltType);
206 assert(unpaddedIndex == 0 && unpaddedCoerceToType == eltType);
212 if (unpaddedStruct) {
213 assert(unpaddedStruct->getNumElements() == unpaddedIndex);
215 assert(unpaddedIndex == 1);
220 AI.setCoerceToType(coerceToType);
221 AI.setUnpaddedCoerceToType(unpaddedCoerceToType);
226 if (eltType->isArrayTy()) {
227 assert(eltType->getArrayElementType()->isIntegerTy(8));
258 return (canHavePaddingType() ?
PaddingType :
nullptr);
280 return cast<llvm::StructType>(TypeData);
292 return structTy->elements();
320 return IndirectByVal;
329 return IndirectRealign;
333 IndirectRealign = IR;
338 return SRetAfterThis;
342 SRetAfterThis = AfterThis;
367 assert(
isDirect() &&
"Invalid kind!");
368 return CanBeFlattened;
372 assert(
isDirect() &&
"Invalid kind!");
373 CanBeFlattened = Flatten;
384 unsigned NumRequired;
405 return PVD->hasAttr<PassObjectSizeAttr>();
434 if (value == ~0U)
return All;
449 :
public llvm::FoldingSetNode,
451 FunctionProtoType::ExtParameterInfo> {
457 unsigned CallingConvention : 8;
461 unsigned EffectiveCallingConvention : 8;
464 unsigned ASTCallingConvention : 8;
467 unsigned InstanceMethod : 1;
470 unsigned ChainCall : 1;
473 unsigned NoReturn : 1;
476 unsigned ReturnsRetained : 1;
479 unsigned HasRegParm : 1;
480 unsigned RegParm : 3;
486 llvm::StructType *ArgStruct;
487 unsigned ArgStructAlign : 31;
488 unsigned HasExtParameterInfos : 1;
493 return getTrailingObjects<ArgInfo>();
495 const ArgInfo *getArgsBuffer()
const {
496 return getTrailingObjects<ArgInfo>();
500 return getTrailingObjects<ExtParameterInfo>();
503 return getTrailingObjects<ExtParameterInfo>();
517 void operator delete(
void *p) { ::operator
delete(p); }
526 return (HasExtParameterInfos ?
NumArgs : 0);
576 return EffectiveCallingConvention;
579 EffectiveCallingConvention =
Value;
598 if (!HasExtParameterInfos)
return {};
599 return llvm::makeArrayRef(getExtParameterInfosBuffer(),
NumArgs);
622 ID.AddBoolean(InstanceMethod);
623 ID.AddBoolean(ChainCall);
624 ID.AddBoolean(NoReturn);
625 ID.AddBoolean(ReturnsRetained);
626 ID.AddBoolean(HasRegParm);
627 ID.AddInteger(RegParm);
629 ID.AddBoolean(HasExtParameterInfos);
630 if (HasExtParameterInfos) {
632 ID.AddInteger(paramInfo.getOpaqueValue());
646 ID.AddInteger(info.
getCC());
647 ID.AddBoolean(InstanceMethod);
648 ID.AddBoolean(ChainCall);
654 ID.AddBoolean(!paramInfos.empty());
655 if (!paramInfos.empty()) {
656 for (
auto paramInfo : paramInfos)
657 ID.AddInteger(paramInfo.getOpaqueValue());
661 i = argTypes.begin(), e = argTypes.end(); i != e; ++i) {
673 const Decl *CalleeDecl;
676 explicit CGCalleeInfo() : CalleeProtoTy(nullptr), CalleeDecl(nullptr) {}
678 : CalleeProtoTy(calleeProtoTy), CalleeDecl(calleeDecl) {}
680 : CalleeProtoTy(calleeProtoTy), CalleeDecl(nullptr) {}
682 : CalleeProtoTy(nullptr), CalleeDecl(calleeDecl) {}
685 return CalleeProtoTy;
Ignore - Ignore the argument (treat as void).
FunctionDecl - An instance of this class is created to represent a function declaration or definition...
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)
bool isCoerceAndExpand() const
C Language Family Type Representation.
Extend - Valid only for integer argument types.
QuantityType getQuantity() const
getQuantity - Get the raw integer representation of this quantity.
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.
CGCalleeInfo(const Decl *calleeDecl)
unsigned AllocaFieldIndex
const ArgInfo * const_arg_iterator
unsigned getNumParams() const
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...
void setPaddingInReg(bool PIR)
llvm::StructType * getArgStruct() const
Get the struct type used to represent all the arguments in memory.
llvm::Type * getCoerceToType() const
bool getCanBeFlattened() const
unsigned getRegParm() const
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.
size_t numTrailingObjects(OverloadToken< ArgInfo >) const
ABIArgInfo - Helper class to encapsulate information about how a specific C type should be passed to ...
bool allowsOptionalArgs() const
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.
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)
static CharUnits fromQuantity(QuantityType Quantity)
fromQuantity - Construct a CharUnits quantity from a raw integer type.
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...
unsigned getRegParm() const
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.
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.
FunctionType::ExtInfo getExtInfo() const
RequiredArgs getRequiredArgs() const
void setArgStruct(llvm::StructType *Ty, CharUnits Align)
bool getPaddingInReg() const
bool isReturnsRetained() const
In ARC, whether this function retains its return value.
ArrayRef< ParmVarDecl * > parameters() const
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)
bool isSRetAfterThis() const
CGFunctionInfo - Class to encapsulate the information about a function definition.
bool canHaveCoerceToType() const
unsigned getDirectOffset() const
static ABIArgInfo getDirectInReg(llvm::Type *T=nullptr)
bool isInstanceMethod() const
bool getProducesResult() const
friend class TrailingObjects
CallingConv getCC() const
static CGFunctionInfo * create(unsigned llvmCC, bool instanceMethod, bool chainCall, const FunctionType::ExtInfo &extInfo, ArrayRef< ExtParameterInfo > paramInfos, CanQualType resultType, ArrayRef< CanQualType > argTypes, RequiredArgs required)
static RequiredArgs forPrototype(CanQual< FunctionProtoType > prototype, const FunctionDecl *FD)
Expand - Only valid for aggregate argument types.
ABIArgInfo & getReturnInfo()
static ABIArgInfo getInAlloca(unsigned FieldIndex)
const Decl * getCalleeDecl()
static ABIArgInfo getCoerceAndExpand(llvm::StructType *coerceToType, llvm::Type *unpaddedCoerceToType)
bool getHasRegParm() const
ArrayRef< ExtParameterInfo > getExtParameterInfos() const
const T * getTypePtr() const
Retrieve the underlying type pointer, which refers to a canonical type.
const_arg_iterator arg_begin() const
bool getIndirectByVal() const
bool getHasRegParm() const
unsigned arg_size() const
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.