15#ifndef LLVM_CLANG_CODEGEN_CGFUNCTIONINFO_H
16#define LLVM_CLANG_CODEGEN_CGFUNCTIONINFO_H
21#include "llvm/ADT/FoldingSet.h"
22#include "llvm/IR/DerivedTypes.h"
23#include "llvm/Support/TrailingObjects.h"
100 struct DirectAttrInfo {
104 struct IndirectAttrInfo {
114 bool PaddingInReg : 1;
115 bool InAllocaSRet : 1;
116 bool InAllocaIndirect : 1;
117 bool IndirectByVal : 1;
118 bool IndirectRealign : 1;
119 bool SRetAfterThis : 1;
121 bool CanBeFlattened: 1;
124 bool Conservative : 1;
126 bool canHavePaddingType()
const {
130 void setPaddingType(llvm::Type *
T) {
131 assert(canHavePaddingType());
135 void setUnpaddedCoerceToType(llvm::Type *T) {
146 Conservative(
false) {}
149 llvm::Type *Padding =
nullptr,
150 bool CanBeFlattened =
true,
unsigned Align = 0) {
152 AI.setCoerceToType(
T);
153 AI.setPaddingType(Padding);
154 AI.setDirectOffset(Offset);
155 AI.setDirectAlign(Align);
156 AI.setCanBeFlattened(CanBeFlattened);
166 llvm::Type *Padding =
nullptr) {
169 AI.setCoerceToType(
T);
170 AI.setPaddingType(Padding);
171 AI.setDirectOffset(0);
172 AI.setDirectAlign(0);
178 llvm::Type *Padding =
nullptr) {
181 AI.setCoerceToType(
T);
182 AI.setPaddingType(Padding);
183 AI.setDirectOffset(0);
184 AI.setDirectAlign(0);
192 llvm::Type *Padding =
nullptr) {
202 AI.setCoerceToType(
T);
203 AI.setPaddingType(
nullptr);
204 AI.setDirectOffset(0);
205 AI.setDirectAlign(0);
210 llvm::Type *
T =
nullptr) {
212 AI.setConservative(
true);
217 llvm::Type *
T =
nullptr) {
232 bool ByVal =
true,
bool Realign =
false,
233 llvm::Type *Padding =
nullptr) {
235 AI.setIndirectAlign(Alignment);
236 AI.setIndirectByVal(ByVal);
237 AI.setIndirectRealign(Realign);
238 AI.setSRetAfterThis(
false);
239 AI.setPaddingType(Padding);
240 AI.setIndirectAddrSpace(AddrSpace);
246 bool Realign =
false,
247 llvm::Type *Padding =
nullptr) {
249 AI.setIndirectAlign(Alignment);
250 AI.setIndirectRealign(Realign);
251 AI.setPaddingType(Padding);
252 AI.setIndirectAddrSpace(AddrSpace);
257 bool Realign =
false) {
258 auto AI =
getIndirect(Alignment, 0, ByVal, Realign);
264 AI.setInAllocaFieldIndex(FieldIndex);
270 AI.setPaddingType(
nullptr);
274 llvm::Type *Padding) {
276 AI.setPaddingInReg(PaddingInReg);
277 AI.setPaddingType(Padding);
285 llvm::Type *unpaddedCoerceToType) {
290 auto unpaddedStruct = dyn_cast<llvm::StructType>(unpaddedCoerceToType);
291 assert(!unpaddedStruct || unpaddedStruct->getNumElements() != 1);
295 unsigned unpaddedIndex = 0;
296 for (
auto eltType : coerceToType->elements()) {
303 if (unpaddedStruct) {
304 assert(unpaddedStruct->getNumElements() == unpaddedIndex);
306 assert(unpaddedIndex == 1);
311 AI.setCoerceToType(coerceToType);
312 AI.setUnpaddedCoerceToType(unpaddedCoerceToType);
318 llvm::Type *Padding =
nullptr,
319 bool CanBeFlattened =
true,
320 unsigned Align = 0) {
322 AI.setCoerceToType(
T);
323 AI.setPaddingType(Padding);
324 AI.setDirectOffset(Offset);
325 AI.setDirectAlign(Align);
326 AI.setCanBeFlattened(CanBeFlattened);
331 return eltType->isArrayTy() &&
332 eltType->getArrayElementType()->isIntegerTy(8);
354 "Not a direct or extend or target specific kind");
359 "Not a direct or extend or target specific kind");
365 "Not a direct or extend or target specific kind");
370 "Not a direct or extend or target specific kind");
375 assert(
isExtend() && (SignExt + ZeroExt <= 1) &&
"Invalid kind / flags!");
379 assert(
isExtend() &&
"Invalid kind!");
384 assert(
isExtend() && (SignExt + ZeroExt <= 1) &&
"Invalid kind / flags!");
388 assert(
isExtend() &&
"Invalid kind!");
393 assert(
isExtend() && (SignExt + ZeroExt <= 1) &&
"Invalid kind / flags!");
394 return !SignExt && !ZeroExt;
401 assert(
isExtend() &&
"Invalid kind");
405 assert(
isExtend() &&
"Invalid kind");
410 return (canHavePaddingType() ?
PaddingType :
nullptr);
444 return structTy->elements();
474 return IndirectByVal;
493 return IndirectRealign;
497 IndirectRealign = IR;
502 return SRetAfterThis;
506 SRetAfterThis = AfterThis;
520 return InAllocaIndirect;
541 return CanBeFlattened;
546 CanBeFlattened = Flatten;
557 unsigned NumRequired;
572 unsigned additional) {
576 additional += llvm::count_if(
579 return ExtInfo.hasPassObjectSize();
586 unsigned additional) {
606 return argIdx == ~0
U || argIdx < NumRequired;
611 if (value == ~0
U)
return All;
625class CGFunctionInfo final
626 :
public llvm::FoldingSetNode,
627 private llvm::TrailingObjects<CGFunctionInfo, CGFunctionInfoArgInfo,
628 FunctionProtoType::ExtParameterInfo> {
634 unsigned CallingConvention : 8;
638 unsigned EffectiveCallingConvention : 8;
642 unsigned ASTCallingConvention : 6;
645 LLVM_PREFERRED_TYPE(
bool)
646 unsigned InstanceMethod : 1;
649 LLVM_PREFERRED_TYPE(
bool)
650 unsigned ChainCall : 1;
654 LLVM_PREFERRED_TYPE(
bool)
655 unsigned DelegateCall : 1;
658 LLVM_PREFERRED_TYPE(
bool)
659 unsigned CmseNSCall : 1;
662 LLVM_PREFERRED_TYPE(
bool)
663 unsigned NoReturn : 1;
666 LLVM_PREFERRED_TYPE(
bool)
667 unsigned ReturnsRetained : 1;
670 LLVM_PREFERRED_TYPE(
bool)
671 unsigned NoCallerSavedRegs : 1;
674 LLVM_PREFERRED_TYPE(
bool)
675 unsigned HasRegParm : 1;
676 unsigned RegParm : 3;
679 LLVM_PREFERRED_TYPE(
bool)
680 unsigned NoCfCheck : 1;
683 unsigned MaxVectorWidth : 4;
687 unsigned X86ABIAVXLevel = 0;
693 llvm::StructType *ArgStruct;
694 unsigned ArgStructAlign : 31;
695 LLVM_PREFERRED_TYPE(
bool)
696 unsigned HasExtParameterInfos : 1;
700 ArgInfo *getArgsBuffer() {
701 return getTrailingObjects<ArgInfo>();
703 const ArgInfo *getArgsBuffer()
const {
704 return getTrailingObjects<ArgInfo>();
707 ExtParameterInfo *getExtParameterInfosBuffer() {
708 return getTrailingObjects<ExtParameterInfo>();
710 const ExtParameterInfo *getExtParameterInfosBuffer()
const{
711 return getTrailingObjects<ExtParameterInfo>();
717 static CGFunctionInfo *
718 create(
unsigned llvmCC,
bool instanceMethod,
bool chainCall,
719 bool delegateCall,
unsigned X86ABIAVXLevel,
723 void operator delete(
void *p) { ::operator
delete(p); }
732 return (HasExtParameterInfos ? NumArgs : 0);
752 bool isVariadic()
const {
return Required.allowsOptionalArgs(); }
791 return EffectiveCallingConvention;
794 EffectiveCallingConvention =
Value;
813 if (!HasExtParameterInfos)
return {};
817 assert(argIndex <= NumArgs);
818 if (!HasExtParameterInfos)
return ExtParameterInfo();
837 return MaxVectorWidth ? 1U << (MaxVectorWidth - 1) : 0;
842 assert(llvm::isPowerOf2_32(Width) &&
"Expected power of 2 vector");
843 MaxVectorWidth = llvm::countr_zero(Width) + 1;
850 ID.AddBoolean(InstanceMethod);
851 ID.AddBoolean(ChainCall);
852 ID.AddBoolean(DelegateCall);
853 ID.AddBoolean(NoReturn);
854 ID.AddBoolean(ReturnsRetained);
855 ID.AddBoolean(NoCallerSavedRegs);
856 ID.AddBoolean(HasRegParm);
857 ID.AddInteger(RegParm);
858 ID.AddBoolean(NoCfCheck);
859 ID.AddBoolean(CmseNSCall);
860 ID.AddInteger(X86ABIAVXLevel);
861 ID.AddInteger(Required.getOpaqueData());
862 ID.AddBoolean(HasExtParameterInfos);
863 if (HasExtParameterInfos) {
865 ID.AddInteger(paramInfo.getOpaqueValue());
871 static void Profile(llvm::FoldingSetNodeID &ID,
bool InstanceMethod,
873 unsigned X86ABIAVXLevel,
878 ID.AddInteger(info.getCC());
879 ID.AddBoolean(InstanceMethod);
880 ID.AddBoolean(ChainCall);
882 ID.AddBoolean(info.getNoReturn());
883 ID.AddBoolean(info.getProducesResult());
884 ID.AddBoolean(info.getNoCallerSavedRegs());
885 ID.AddBoolean(info.getHasRegParm());
886 ID.AddInteger(info.getRegParm());
887 ID.AddBoolean(info.getNoCfCheck());
888 ID.AddBoolean(info.getCmseNSCall());
889 ID.AddInteger(X86ABIAVXLevel);
891 ID.AddBoolean(!paramInfos.empty());
892 if (!paramInfos.empty()) {
893 for (
auto paramInfo : paramInfos)
894 ID.AddInteger(paramInfo.getOpaqueValue());
C Language Family Type Representation.
Represents a canonical, potentially-qualified type.
void Profile(llvm::FoldingSetNodeID &ID) const
const T * getTypePtr() const
Retrieve the underlying type pointer, which refers to a canonical type.
This is an opaque type for sizes expressed in character units.
QuantityType getQuantity() const
Get the raw integer representation of this quantity.
static constexpr CharUnits fromQuantity(QuantityType Quantity)
Construct a CharUnits quantity from a raw integer type.
ABIArgInfo - Helper class to encapsulate information about how a specific C type should be passed to ...
static ABIArgInfo getZeroExtend(QualType Ty, llvm::Type *T=nullptr, llvm::Type *Padding=nullptr)
void setZeroExt(bool ZExt)
unsigned getInAllocaFieldIndex() const
static ABIArgInfo getSignExtend(QualType Ty, llvm::Type *T=nullptr, llvm::Type *Padding=nullptr)
void setIndirectAddrSpace(unsigned AddrSpace)
void setConservative(bool Val)
static ABIArgInfo getNoExtend(llvm::IntegerType *T)
bool getIndirectByVal() const
bool isConservative() const
Whether the extension is conservative, i.e.
llvm::StructType * getCoerceAndExpandType() const
bool getIndirectRealign() const
static ABIArgInfo getInAlloca(unsigned FieldIndex, bool Indirect=false)
static ABIArgInfo getIgnore()
static ABIArgInfo getExpand()
void setCoerceToType(llvm::Type *T)
llvm::Type * getUnpaddedCoerceAndExpandType() const
static ABIArgInfo getConservativeExtendInReg(QualType Ty, llvm::Type *T=nullptr)
bool getCanBeFlattened() const
unsigned getDirectOffset() const
static bool isPaddingForCoerceAndExpand(llvm::Type *eltType)
void setDirectOffset(unsigned Offset)
static ABIArgInfo getTargetSpecific(llvm::Type *T=nullptr, unsigned Offset=0, llvm::Type *Padding=nullptr, bool CanBeFlattened=true, unsigned Align=0)
void setPaddingInReg(bool PIR)
bool getInAllocaSRet() const
Return true if this field of an inalloca struct should be returned to implement a struct return calli...
void setIndirectAlign(CharUnits IA)
llvm::Type * getPaddingType() const
void setIndirectByVal(bool IBV)
static ABIArgInfo getExtendInReg(QualType Ty, llvm::Type *T=nullptr)
bool getPaddingInReg() const
static ABIArgInfo getExpandWithPadding(bool PaddingInReg, llvm::Type *Padding)
unsigned getDirectAlign() const
unsigned getIndirectAddrSpace() const
ABIArgInfo(Kind K=Direct)
static ABIArgInfo getIndirectInReg(CharUnits Alignment, bool ByVal=true, bool Realign=false)
void setIndirectRealign(bool IR)
static ABIArgInfo getDirect(llvm::Type *T=nullptr, unsigned Offset=0, llvm::Type *Padding=nullptr, bool CanBeFlattened=true, unsigned Align=0)
@ Extend
Extend - Valid only for integer argument types.
@ Ignore
Ignore - Ignore the argument (treat as void).
@ IndirectAliased
IndirectAliased - Similar to Indirect, but the pointer may be to an object that is otherwise referenc...
@ Expand
Expand - Only valid for aggregate argument types.
@ TargetSpecific
TargetSpecific - Some argument types are passed as target specific types such as RISC-V's tuple type,...
@ InAlloca
InAlloca - Pass the argument directly using the LLVM inalloca attribute.
@ Indirect
Indirect - Pass the argument indirectly via a hidden pointer with the specified alignment (0 indicate...
@ CoerceAndExpand
CoerceAndExpand - Only valid for aggregate argument types.
@ Direct
Direct - Pass the argument directly using the normal converted LLVM type, or by coercing to another s...
static ABIArgInfo getExtend(QualType Ty, llvm::Type *T=nullptr, llvm::Type *Padding=nullptr)
static ABIArgInfo getIndirect(CharUnits Alignment, unsigned AddrSpace, bool ByVal=true, bool Realign=false, llvm::Type *Padding=nullptr)
ArrayRef< llvm::Type * > getCoerceAndExpandTypeSequence() const
static ABIArgInfo getConservativeExtend(QualType Ty, llvm::Type *T=nullptr)
static ABIArgInfo getIndirectAliased(CharUnits Alignment, unsigned AddrSpace, bool Realign=false, llvm::Type *Padding=nullptr)
Pass this in memory using the IR byref attribute.
void setSRetAfterThis(bool AfterThis)
bool isTargetSpecific() const
void setInAllocaIndirect(bool Indirect)
void setInAllocaSRet(bool SRet)
bool isCoerceAndExpand() const
DirectAttrInfo DirectAttr
static ABIArgInfo getCoerceAndExpand(llvm::StructType *coerceToType, llvm::Type *unpaddedCoerceToType)
unsigned AllocaFieldIndex
unsigned getInAllocaIndirect() const
llvm::Type * getCoerceToType() const
bool isIndirectAliased() const
void setInAllocaFieldIndex(unsigned FieldIndex)
bool isSRetAfterThis() const
IndirectAttrInfo IndirectAttr
bool canHaveCoerceToType() const
llvm::Type * UnpaddedCoerceAndExpandType
void setSignExt(bool SExt)
void setCanBeFlattened(bool Flatten)
void setDirectAlign(unsigned Align)
CharUnits getIndirectAlign() const
static ABIArgInfo getDirectInReg(llvm::Type *T=nullptr)
bool usesInAlloca() const
Return true if this function uses inalloca arguments.
FunctionType::ExtInfo getExtInfo() const
bool isInstanceMethod() const
ABIArgInfo & getReturnInfo()
bool isReturnsRetained() const
In ARC, whether this function retains its return value.
unsigned getCallingConvention() const
getCallingConvention - Return the user specified calling convention, which has been translated into a...
void Profile(llvm::FoldingSetNodeID &ID)
const_arg_iterator arg_begin() const
bool isNoCallerSavedRegs() const
Whether this function no longer saves caller registers.
unsigned getRegParm() const
ArrayRef< ExtParameterInfo > getExtParameterInfos() const
static void Profile(llvm::FoldingSetNodeID &ID, bool InstanceMethod, bool ChainCall, bool IsDelegateCall, unsigned X86ABIAVXLevel, const FunctionType::ExtInfo &info, ArrayRef< ExtParameterInfo > paramInfos, RequiredArgs required, CanQualType resultType, ArrayRef< CanQualType > argTypes)
CanQualType getReturnType() const
static CGFunctionInfo * create(unsigned llvmCC, bool instanceMethod, bool chainCall, bool delegateCall, unsigned X86ABIAVXLevel, const FunctionType::ExtInfo &extInfo, ArrayRef< ExtParameterInfo > paramInfos, CanQualType resultType, ArrayRef< CanQualType > argTypes, RequiredArgs required)
bool isNoCfCheck() const
Whether this function has nocf_check attribute.
CallingConv getASTCallingConvention() const
getASTCallingConvention() - Return the AST-specified calling convention.
const ABIArgInfo & getReturnInfo() const
bool getHasRegParm() const
ArrayRef< ArgInfo > arguments() const
const ArgInfo * const_arg_iterator
friend class TrailingObjects
bool isCmseNSCall() const
bool isDelegateCall() const
MutableArrayRef< ArgInfo > arguments()
const_arg_iterator arg_end() const
unsigned getEffectiveCallingConvention() const
getEffectiveCallingConvention - Return the actual calling convention to use, which may depend on the ...
unsigned getX86ABIAVXLevel() const
void setArgStruct(llvm::StructType *Ty, CharUnits Align)
size_t numTrailingObjects(OverloadToken< ArgInfo >) const
ExtParameterInfo getExtParameterInfo(unsigned argIndex) const
unsigned getMaxVectorWidth() const
Return the maximum vector width in the arguments.
CharUnits getArgStructAlignment() const
size_t numTrailingObjects(OverloadToken< ExtParameterInfo >) const
unsigned arg_size() const
RequiredArgs getRequiredArgs() const
void setEffectiveCallingConvention(unsigned Value)
unsigned getNumRequiredArgs() const
llvm::StructType * getArgStruct() const
Get the struct type used to represent all the arguments in memory.
void setMaxVectorWidth(unsigned Width)
Set the maximum vector width in the arguments.
A class for recording the number of arguments that a function signature requires.
static RequiredArgs forPrototypePlus(CanQual< FunctionProtoType > prototype, unsigned additional)
bool allowsOptionalArgs() const
unsigned getNumRequiredArgs() const
static RequiredArgs forPrototype(CanQual< FunctionProtoType > prototype)
static RequiredArgs forPrototypePlus(const FunctionProtoType *prototype, unsigned additional)
Compute the arguments required by the given formal prototype, given that there may be some additional...
static RequiredArgs getFromOpaqueData(unsigned value)
bool isRequiredArg(unsigned argIdx) const
Return true if the argument at a given index is required.
static RequiredArgs forPrototype(const FunctionProtoType *prototype)
unsigned getOpaqueData() const
Represents a prototype with parameter type info, e.g.
unsigned getNumParams() const
bool isVariadic() const
Whether this function prototype is variadic.
ArrayRef< ExtParameterInfo > getExtParameterInfos() const
bool hasExtParameterInfos() const
Is there any interesting extra information for any of the parameters of this function type?
A class which abstracts out some details necessary for making a call.
Interesting information about a specific parameter that can't simply be reflected in parameter's type...
A (possibly-)qualified type.
bool isIntegralOrEnumerationType() const
Determine whether this type is an integral or enumeration type.
bool hasSignedIntegerRepresentation() const
Determine whether this type has an signed integer representation of some sort, e.g....
Top level wrappers for InstallAPI frontend operations.
CanQual< Type > CanQualType
Represents a canonical, potentially-qualified type.
nullptr
This class represents a compute construct, representing a 'Kind' of ‘parallel’, 'serial',...
const FunctionProtoType * T
CallingConv
CallingConv - Specifies the calling convention that a function uses.
U cast(CodeGen::Address addr)
int32_t uint32_t uint32_t __builtin_riscv_mhracc_i32 __builtin_riscv_mhraccu_u32 __builtin_riscv_mhraccsu_i32 __builtin_riscv_mhacc_h1_i32 __builtin_riscv_mhaccsu_h1_i32 __builtin_riscv_mulqr_i32 __builtin_riscv_mqrwacc_i64 __packed_splat4 __packed_splat2 __packed_splat8 __packed_splat4 __packed_splat2 uint8_t