15 #ifndef LLVM_CLANG_CODEGEN_CGFUNCTIONINFO_H 16 #define LLVM_CLANG_CODEGEN_CGFUNCTIONINFO_H 23 #include "llvm/IR/DerivedTypes.h" 24 #include "llvm/ADT/FoldingSet.h" 25 #include "llvm/Support/TrailingObjects.h" 90 bool PaddingInReg : 1;
91 bool InAllocaSRet : 1;
92 bool IndirectByVal : 1;
93 bool IndirectRealign : 1;
94 bool SRetAfterThis : 1;
96 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);
140 AI.setCoerceToType(T);
141 AI.setPaddingType(
nullptr);
142 AI.setDirectOffset(0);
150 AI.setCoerceToType(T);
151 AI.setPaddingType(
nullptr);
152 AI.setDirectOffset(0);
153 AI.setSignExt(
false);
175 bool Realign =
false,
178 AI.setIndirectAlign(Alignment);
179 AI.setIndirectByVal(ByVal);
180 AI.setIndirectRealign(Realign);
181 AI.setSRetAfterThis(
false);
182 AI.setPaddingType(Padding);
186 bool Realign =
false) {
193 AI.setInAllocaFieldIndex(FieldIndex);
198 AI.setPaddingType(
nullptr);
204 AI.setPaddingInReg(PaddingInReg);
205 AI.setPaddingType(Padding);
218 auto unpaddedStruct = dyn_cast<llvm::StructType>(unpaddedCoerceToType);
219 assert(!unpaddedStruct || unpaddedStruct->getNumElements() != 1);
223 unsigned unpaddedIndex = 0;
224 for (
auto eltType : coerceToType->elements()) {
226 if (unpaddedStruct) {
227 assert(unpaddedStruct->getElementType(unpaddedIndex) == eltType);
229 assert(unpaddedIndex == 0 && unpaddedCoerceToType == eltType);
235 if (unpaddedStruct) {
236 assert(unpaddedStruct->getNumElements() == unpaddedIndex);
238 assert(unpaddedIndex == 1);
243 AI.setCoerceToType(coerceToType);
244 AI.setUnpaddedCoerceToType(unpaddedCoerceToType);
249 if (eltType->isArrayTy()) {
250 assert(eltType->getArrayElementType()->isIntegerTy(8));
281 assert(
isExtend() &&
"Invalid kind!");
285 assert(
isExtend() &&
"Invalid kind!");
290 return (canHavePaddingType() ?
PaddingType :
nullptr);
312 return cast<llvm::StructType>(TypeData);
324 return structTy->elements();
352 return IndirectByVal;
361 return IndirectRealign;
365 IndirectRealign = IR;
370 return SRetAfterThis;
374 SRetAfterThis = AfterThis;
399 assert(
isDirect() &&
"Invalid kind!");
400 return CanBeFlattened;
404 assert(
isDirect() &&
"Invalid kind!");
405 CanBeFlattened = Flatten;
416 unsigned NumRequired;
431 unsigned additional) {
435 additional += llvm::count_if(
438 return ExtInfo.hasPassObjectSize();
445 unsigned additional) {
446 return forPrototypePlus(prototype.
getTypePtr(), additional);
450 return forPrototypePlus(prototype, 0);
454 return forPrototypePlus(prototype.
getTypePtr(), 0);
459 assert(allowsOptionalArgs());
465 if (value == ~0U)
return All;
480 :
public llvm::FoldingSetNode,
482 FunctionProtoType::ExtParameterInfo> {
488 unsigned CallingConvention : 8;
492 unsigned EffectiveCallingConvention : 8;
495 unsigned ASTCallingConvention : 6;
498 unsigned InstanceMethod : 1;
501 unsigned ChainCall : 1;
504 unsigned NoReturn : 1;
507 unsigned ReturnsRetained : 1;
510 unsigned NoCallerSavedRegs : 1;
513 unsigned HasRegParm : 1;
514 unsigned RegParm : 3;
517 unsigned NoCfCheck : 1;
523 llvm::StructType *ArgStruct;
524 unsigned ArgStructAlign : 31;
525 unsigned HasExtParameterInfos : 1;
529 ArgInfo *getArgsBuffer() {
530 return getTrailingObjects<ArgInfo>();
532 const ArgInfo *getArgsBuffer()
const {
533 return getTrailingObjects<ArgInfo>();
536 ExtParameterInfo *getExtParameterInfosBuffer() {
537 return getTrailingObjects<ExtParameterInfo>();
539 const ExtParameterInfo *getExtParameterInfosBuffer()
const{
540 return getTrailingObjects<ExtParameterInfo>();
546 static CGFunctionInfo *
create(
unsigned llvmCC,
554 void operator delete(
void *
p) { ::operator
delete(
p); }
563 return (HasExtParameterInfos ? NumArgs : 0);
572 arg_range
arguments() {
return arg_range(arg_begin(), arg_end()); }
574 return const_arg_range(arg_begin(), arg_end());
577 const_arg_iterator
arg_begin()
const {
return getArgsBuffer() + 1; }
578 const_arg_iterator
arg_end()
const {
return getArgsBuffer() + 1 + NumArgs; }
579 arg_iterator
arg_begin() {
return getArgsBuffer() + 1; }
580 arg_iterator
arg_end() {
return getArgsBuffer() + 1 + NumArgs; }
587 return isVariadic() ? getRequiredArgs().getNumRequiredArgs() : arg_size();
619 return EffectiveCallingConvention;
622 EffectiveCallingConvention =
Value;
630 getASTCallingConvention(), isReturnsRetained(),
631 isNoCallerSavedRegs(), isNoCfCheck());
640 if (!HasExtParameterInfos)
return {};
641 return llvm::makeArrayRef(getExtParameterInfosBuffer(), NumArgs);
644 assert(argIndex <= NumArgs);
645 if (!HasExtParameterInfos)
return ExtParameterInfo();
646 return getExtParameterInfos()[argIndex];
663 ID.AddInteger(getASTCallingConvention());
664 ID.AddBoolean(InstanceMethod);
665 ID.AddBoolean(ChainCall);
666 ID.AddBoolean(NoReturn);
667 ID.AddBoolean(ReturnsRetained);
668 ID.AddBoolean(NoCallerSavedRegs);
669 ID.AddBoolean(HasRegParm);
670 ID.AddInteger(RegParm);
671 ID.AddBoolean(NoCfCheck);
673 ID.AddBoolean(HasExtParameterInfos);
674 if (HasExtParameterInfos) {
675 for (
auto paramInfo : getExtParameterInfos())
676 ID.AddInteger(paramInfo.getOpaqueValue());
678 getReturnType().Profile(ID);
679 for (
const auto &I : arguments())
690 ID.AddInteger(info.
getCC());
691 ID.AddBoolean(InstanceMethod);
692 ID.AddBoolean(ChainCall);
700 ID.AddBoolean(!paramInfos.empty());
701 if (!paramInfos.empty()) {
702 for (
auto paramInfo : paramInfos)
703 ID.AddInteger(paramInfo.getOpaqueValue());
707 i = argTypes.begin(), e = argTypes.end();
i != e; ++
i) {
Ignore - Ignore the argument (treat as void).
void setEffectiveCallingConvention(unsigned Value)
void setSRetAfterThis(bool AfterThis)
A (possibly-)qualified type.
llvm::Type * UnpaddedCoerceAndExpandType
bool getNoCfCheck() const
bool isReturnsRetained() const
In ARC, whether this function retains its return value.
static RequiredArgs getFromOpaqueData(unsigned value)
bool hasExtParameterInfos() const
Is there any interesting extra information for any of the parameters of this function type...
C Language Family Type Representation.
Extend - Valid only for integer argument types.
bool isNoCfCheck() const
Whether this function has nocf_check attribute.
const_arg_range arguments() const
bool isVariadic() const
Whether this function prototype is variadic.
llvm::iterator_range< const_arg_iterator > const_arg_range
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()
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
void setSignExt(bool SExt)
Indirect - Pass the argument indirectly via a hidden pointer with the specified alignment (0 indicate...
ArrayRef< ExtParameterInfo > getExtParameterInfos() const
RequiredArgs getRequiredArgs() const
CharUnits getArgStructAlignment() const
void setPaddingInReg(bool PIR)
bool isIntegralOrEnumerationType() const
Determine whether this type is an integral or enumeration type.
static ABIArgInfo getIndirectInReg(CharUnits Alignment, bool ByVal=true, bool Realign=false)
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
static ABIArgInfo getExtendInReg(QualType Ty, llvm::Type *T=nullptr)
ABIArgInfo - Helper class to encapsulate information about how a specific C type should be passed to ...
static ABIArgInfo getExpand()
FunctionType::ExtInfo getExtInfo() const
static RequiredArgs forPrototype(CanQual< FunctionProtoType > prototype)
const T * getTypePtr() const
Retrieve the underlying type pointer, which refers to a canonical type.
bool getNoCallerSavedRegs() const
static ABIArgInfo getZeroExtend(QualType Ty, llvm::Type *T=nullptr)
static ABIArgInfo getSignExtend(QualType Ty, llvm::Type *T=nullptr)
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.
static ABIArgInfo getExtend(QualType Ty, llvm::Type *T=nullptr)
llvm::Type * getUnpaddedCoerceAndExpandType() const
bool getHasRegParm() const
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
Interesting information about a specific parameter that can't simply be reflected in parameter's type...
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
static RequiredArgs forPrototype(const FunctionProtoType *prototype)
bool isNoCallerSavedRegs() const
Whether this function no longer saves caller registers.
ArrayRef< llvm::Type * > getCoerceAndExpandTypeSequence() const
static RequiredArgs forPrototypePlus(const FunctionProtoType *prototype, unsigned additional)
Compute the arguments required by the given formal prototype, given that there may be some additional...
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...
bool hasSignedIntegerRepresentation() const
Determine whether this type has an signed integer representation of some sort, e.g., it is an signed integer type or a vector.
CallingConv getASTCallingConvention() const
getASTCallingConvention() - Return the AST-specified calling convention.
unsigned getNumRequiredArgs() const
unsigned getDirectOffset() const
static RequiredArgs forPrototypePlus(CanQual< FunctionProtoType > prototype, unsigned additional)
ExtParameterInfo getExtParameterInfo(unsigned argIndex) 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.