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>();
412 return forPrototypePlus(prototype, 0, FD);
417 return forPrototype(prototype.
getTypePtr(), FD);
423 return forPrototypePlus(prototype.
getTypePtr(), additional, FD);
428 assert(allowsOptionalArgs());
434 if (value == ~0U)
return All;
449 :
public llvm::FoldingSetNode,
451 FunctionProtoType::ExtParameterInfo> {
457 unsigned CallingConvention : 8;
461 unsigned EffectiveCallingConvention : 8;
464 unsigned ASTCallingConvention : 7;
467 unsigned InstanceMethod : 1;
470 unsigned ChainCall : 1;
473 unsigned NoReturn : 1;
476 unsigned ReturnsRetained : 1;
479 unsigned NoCallerSavedRegs : 1;
482 unsigned HasRegParm : 1;
483 unsigned RegParm : 3;
489 llvm::StructType *ArgStruct;
490 unsigned ArgStructAlign : 31;
491 unsigned HasExtParameterInfos : 1;
495 ArgInfo *getArgsBuffer() {
496 return getTrailingObjects<ArgInfo>();
498 const ArgInfo *getArgsBuffer()
const {
499 return getTrailingObjects<ArgInfo>();
502 ExtParameterInfo *getExtParameterInfosBuffer() {
503 return getTrailingObjects<ExtParameterInfo>();
505 const ExtParameterInfo *getExtParameterInfosBuffer()
const{
506 return getTrailingObjects<ExtParameterInfo>();
512 static CGFunctionInfo *
create(
unsigned llvmCC,
520 void operator delete(
void *p) { ::operator
delete(p); }
529 return (HasExtParameterInfos ? NumArgs : 0);
538 arg_range
arguments() {
return arg_range(arg_begin(), arg_end()); }
540 return arg_const_range(arg_begin(), arg_end());
543 const_arg_iterator
arg_begin()
const {
return getArgsBuffer() + 1; }
544 const_arg_iterator
arg_end()
const {
return getArgsBuffer() + 1 + NumArgs; }
545 arg_iterator
arg_begin() {
return getArgsBuffer() + 1; }
546 arg_iterator
arg_end() {
return getArgsBuffer() + 1 + NumArgs; }
553 return isVariadic() ? getRequiredArgs().getNumRequiredArgs() : arg_size();
582 return EffectiveCallingConvention;
585 EffectiveCallingConvention =
Value;
593 getASTCallingConvention(), isReturnsRetained(),
594 isNoCallerSavedRegs());
603 if (!HasExtParameterInfos)
return {};
604 return llvm::makeArrayRef(getExtParameterInfosBuffer(), NumArgs);
607 assert(argIndex <= NumArgs);
608 if (!HasExtParameterInfos)
return ExtParameterInfo();
609 return getExtParameterInfos()[argIndex];
626 ID.AddInteger(getASTCallingConvention());
627 ID.AddBoolean(InstanceMethod);
628 ID.AddBoolean(ChainCall);
629 ID.AddBoolean(NoReturn);
630 ID.AddBoolean(ReturnsRetained);
631 ID.AddBoolean(NoCallerSavedRegs);
632 ID.AddBoolean(HasRegParm);
633 ID.AddInteger(RegParm);
635 ID.AddBoolean(HasExtParameterInfos);
636 if (HasExtParameterInfos) {
637 for (
auto paramInfo : getExtParameterInfos())
638 ID.AddInteger(paramInfo.getOpaqueValue());
640 getReturnType().Profile(ID);
641 for (
const auto &I : arguments())
652 ID.AddInteger(info.
getCC());
653 ID.AddBoolean(InstanceMethod);
654 ID.AddBoolean(ChainCall);
661 ID.AddBoolean(!paramInfos.empty());
662 if (!paramInfos.empty()) {
663 for (
auto paramInfo : paramInfos)
664 ID.AddInteger(paramInfo.getOpaqueValue());
668 i = argTypes.begin(), e = argTypes.end(); i != e; ++i) {
Ignore - Ignore the argument (treat as void).
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
bool isReturnsRetained() const
In ARC, whether this function retains its return value.
static RequiredArgs forPrototype(const FunctionProtoType *prototype, const FunctionDecl *FD)
static RequiredArgs getFromOpaqueData(unsigned value)
C Language Family Type Representation.
Extend - Valid only for integer argument types.
Direct - Pass the argument directly using the normal converted LLVM type, or by coercing to another s...
void setIndirectAlign(CharUnits IA)
void Profile(llvm::FoldingSetNodeID &ID) const
void setCanBeFlattened(bool Flatten)
bool isCoerceAndExpand() const
static void Profile(llvm::FoldingSetNodeID &ID, bool InstanceMethod, bool ChainCall, const FunctionType::ExtInfo &info, ArrayRef< ExtParameterInfo > paramInfos, RequiredArgs required, CanQualType resultType, ArrayRef< CanQualType > argTypes)
unsigned getNumParams() const
void setCoerceToType(llvm::Type *T)
static ABIArgInfo getIgnore()
ParmVarDecl - Represents a parameter to a function.
unsigned AllocaFieldIndex
const ArgInfo * const_arg_iterator
unsigned arg_size() const
void setDirectOffset(unsigned Offset)
bool usesInAlloca() const
Return true if this function uses inalloca arguments.
unsigned getRegParm() const
Indirect - Pass the argument indirectly via a hidden pointer with the specified alignment (0 indicate...
RequiredArgs getRequiredArgs() const
static ABIArgInfo getExtendInReg(llvm::Type *T=nullptr)
CharUnits getArgStructAlignment() const
Interesting information about a specific parameter that can't simply be reflected in parameter's type...
void setPaddingInReg(bool PIR)
static ABIArgInfo getIndirectInReg(CharUnits Alignment, bool ByVal=true, bool Realign=false)
ArrayRef< ParmVarDecl * > parameters() const
bool getProducesResult() const
static ABIArgInfo getDirect(llvm::Type *T=nullptr, unsigned Offset=0, llvm::Type *Padding=nullptr, bool CanBeFlattened=true)
void setInAllocaFieldIndex(unsigned FieldIndex)
bool getHasRegParm() const
static ABIArgInfo getExpandWithPadding(bool PaddingInReg, llvm::Type *Padding)
CharUnits - This is an opaque type for sizes expressed in character units.
llvm::StructType * getCoerceAndExpandType() const
unsigned getInAllocaFieldIndex() const
const_arg_iterator arg_begin() const
ABIArgInfo - Helper class to encapsulate information about how a specific C type should be passed to ...
llvm::iterator_range< const_arg_iterator > arg_const_range
static ABIArgInfo getExpand()
FunctionType::ExtInfo getExtInfo() const
const T * getTypePtr() const
Retrieve the underlying type pointer, which refers to a canonical type.
bool getNoCallerSavedRegs() const
CanQualType getReturnType() const
unsigned getNumRequiredArgs() const
Represents a prototype with parameter type info, e.g.
void setIndirectByVal(bool IBV)
bool allowsOptionalArgs() const
bool getPaddingInReg() const
QuantityType getQuantity() const
getQuantity - Get the raw integer representation of this quantity.
llvm::Type * getUnpaddedCoerceAndExpandType() const
const FunctionProtoType * T
bool getHasRegParm() 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. ...
bool canHaveCoerceToType() const
bool getIndirectByVal() const
void Profile(llvm::FoldingSetNodeID &ID)
size_t numTrailingObjects(OverloadToken< ExtParameterInfo >) const
CallingConv
CallingConv - Specifies the calling convention that a function uses.
The l-value was considered opaque, so the alignment was determined from a type.
unsigned getEffectiveCallingConvention() const
getEffectiveCallingConvention - Return the actual calling convention to use, which may depend on the ...
bool isSRetAfterThis() const
unsigned getRegParm() const
CallingConv getCC() const
void setArgStruct(llvm::StructType *Ty, CharUnits Align)
const_arg_iterator arg_end() const
llvm::StructType * getArgStruct() const
Get the struct type used to represent all the arguments in memory.
bool isInstanceMethod() 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.
llvm::Type * getPaddingType() const
bool getInAllocaSRet() const
Return true if this field of an inalloca struct should be returned to implement a struct return calli...
CGFunctionInfo - Class to encapsulate the information about a function definition.
const ABIArgInfo & getReturnInfo() const
Dataflow Directional Tag Classes.
unsigned getOpaqueData() const
static ABIArgInfo getDirectInReg(llvm::Type *T=nullptr)
ArrayRef< ExtParameterInfo > getExtParameterInfos() const
std::unique_ptr< DiagnosticConsumer > create(StringRef OutputFile, DiagnosticOptions *Diags, bool MergeChildRecords=false)
Returns a DiagnosticConsumer that serializes diagnostics to a bitcode file.
bool getCanBeFlattened() const
bool isNoCallerSavedRegs() const
Whether this function no longer saves caller registers.
ArrayRef< llvm::Type * > getCoerceAndExpandTypeSequence() const
static RequiredArgs forPrototype(CanQual< FunctionProtoType > prototype, const FunctionDecl *FD)
CharUnits getIndirectAlign() const
Expand - Only valid for aggregate argument types.
ABIArgInfo & getReturnInfo()
static ABIArgInfo getInAlloca(unsigned FieldIndex)
static ABIArgInfo getCoerceAndExpand(llvm::StructType *coerceToType, llvm::Type *unpaddedCoerceToType)
unsigned getCallingConvention() const
getCallingConvention - Return the user specified calling convention, which has been translated into a...
CallingConv getASTCallingConvention() const
getASTCallingConvention() - Return the AST-specified calling convention.
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...
unsigned getNumRequiredArgs() const
unsigned getDirectOffset() const
ExtParameterInfo getExtParameterInfo(unsigned argIndex) const
arg_const_range arguments() const
llvm::Type * getCoerceToType() const
void setInAllocaSRet(bool SRet)
size_t numTrailingObjects(OverloadToken< ArgInfo >) const
bool getIndirectRealign() const
static ABIArgInfo getIndirect(CharUnits Alignment, bool ByVal=true, bool Realign=false, llvm::Type *Padding=nullptr)
void setIndirectRealign(bool IR)
A class which abstracts out some details necessary for making a call.