11#include "TargetInfo.h"
13#include "llvm/IR/DerivedTypes.h"
29 CommonSPIRABIInfo(CodeGenTypes &CGT) : DefaultABIInfo(CGT) { setCCs(); }
35class SPIRVABIInfo :
public CommonSPIRABIInfo {
37 SPIRVABIInfo(CodeGenTypes &CGT) : CommonSPIRABIInfo(CGT) {}
38 void computeInfo(CGFunctionInfo &FI)
const override;
39 RValue EmitVAArg(CodeGenFunction &CGF, Address VAListAddr, QualType Ty,
40 AggValueSlot Slot)
const override;
43 ABIArgInfo classifyKernelArgumentType(QualType Ty)
const;
46class AMDGCNSPIRVABIInfo :
public SPIRVABIInfo {
49 static constexpr unsigned MaxNumRegsForArgsRet = 16;
50 mutable unsigned NumRegsLeft = 0;
52 uint64_t numRegsForType(QualType Ty)
const;
54 bool isHomogeneousAggregateBaseType(QualType Ty)
const override {
57 bool isHomogeneousAggregateSmallEnough(
const Type *Base,
58 uint64_t Members)
const override {
59 uint32_t NumRegs = (getContext().getTypeSize(Base) + 31) / 32;
62 return Members * NumRegs <= MaxNumRegsForArgsRet;
66 llvm::Type *coerceKernelArgumentType(llvm::Type *Ty,
unsigned FromAS,
70 ABIArgInfo classifyKernelArgumentType(QualType Ty)
const;
74 AMDGCNSPIRVABIInfo(CodeGenTypes &CGT) : SPIRVABIInfo(CGT) {}
75 void computeInfo(CGFunctionInfo &FI)
const override;
77 llvm::FixedVectorType *
78 getOptimalVectorMemoryType(llvm::FixedVectorType *Ty,
79 const LangOptions &LangOpt)
const override;
85 CommonSPIRTargetCodeGenInfo(CodeGen::CodeGenTypes &CGT)
86 : TargetCodeGenInfo(std::make_unique<CommonSPIRABIInfo>(CGT)) {}
87 CommonSPIRTargetCodeGenInfo(std::unique_ptr<ABIInfo> ABIInfo)
88 : TargetCodeGenInfo(std::move(ABIInfo)) {}
90 LangAS getASTAllocaAddressSpace()
const override {
92 getABIInfo().getDataLayout().getAllocaAddrSpace());
95 unsigned getDeviceKernelCallingConv()
const override;
96 llvm::Type *getOpenCLType(CodeGenModule &CGM,
const Type *T)
const override;
97 llvm::Type *getHLSLType(CodeGenModule &CGM,
const Type *Ty,
98 const CGHLSLOffsetInfo &OffsetInfo)
const override;
100 llvm::Type *getHLSLPadding(CodeGenModule &CGM,
101 CharUnits NumBytes)
const override {
103 return llvm::TargetExtType::get(CGM.
getLLVMContext(),
"spirv.Padding", {},
107 bool isHLSLPadding(llvm::Type *Ty)
const override {
108 if (
auto *TET = dyn_cast<llvm::TargetExtType>(Ty))
109 return TET->getName() ==
"spirv.Padding";
113 llvm::Type *getSPIRVImageTypeFromHLSLResource(
114 const HLSLAttributedResourceType::Attributes &attributes,
115 QualType SampledType, CodeGenModule &CGM)
const;
117 setOCLKernelStubCallingConvention(
const FunctionType *&FT)
const override;
118 llvm::Constant *getNullPointer(
const CodeGen::CodeGenModule &CGM,
119 llvm::PointerType *T,
120 QualType QT)
const override;
122class SPIRVTargetCodeGenInfo :
public CommonSPIRTargetCodeGenInfo {
124 SPIRVTargetCodeGenInfo(CodeGen::CodeGenTypes &CGT)
125 : CommonSPIRTargetCodeGenInfo(
126 (CGT.getTarget().getTriple().getVendor() == llvm::Triple::AMD)
127 ? std::make_unique<AMDGCNSPIRVABIInfo>(CGT)
128 : std::make_unique<SPIRVABIInfo>(CGT)) {}
130 LangAS getGlobalVarAddressSpace(CodeGenModule &CGM,
131 const VarDecl *D)
const override;
132 void setTargetAttributes(
const Decl *D, llvm::GlobalValue *GV,
133 CodeGen::CodeGenModule &M)
const override;
134 StringRef getLLVMSyncScopeStr(
const LangOptions &LangOpts,
SyncScope Scope,
135 llvm::AtomicOrdering Ordering)
const override;
136 bool supportsLibCall()
const override {
137 return getABIInfo().getTarget().getTriple().getVendor() !=
143void CommonSPIRABIInfo::setCCs() {
144 assert(getRuntimeCC() == llvm::CallingConv::C);
145 RuntimeCC = llvm::CallingConv::SPIR_FUNC;
148ABIArgInfo SPIRVABIInfo::classifyKernelArgumentType(QualType Ty)
const {
149 if (getContext().getLangOpts().isTargetDevice()) {
154 llvm::Type *LTy = CGT.ConvertType(Ty);
155 auto DefaultAS = getContext().getTargetAddressSpace(LangAS::Default);
156 auto GlobalAS = getContext().getTargetAddressSpace(LangAS::opencl_global);
157 auto *PtrTy = llvm::dyn_cast<llvm::PointerType>(LTy);
158 if (PtrTy && PtrTy->getAddressSpace() == DefaultAS) {
159 LTy = llvm::PointerType::get(PtrTy->getContext(), GlobalAS);
172 return getNaturalAlignIndirect(Ty, 0,
true);
178void SPIRVABIInfo::computeInfo(CGFunctionInfo &FI)
const {
183 for (
auto &&[ArgumentsCount, I] : llvm::enumerate(FI.
arguments()))
186 : ABIArgInfo::getDirect();
192 if (CC == llvm::CallingConv::SPIR_KERNEL) {
193 I.info = classifyKernelArgumentType(I.type);
195 I.info = classifyArgumentType(I.type);
200RValue SPIRVABIInfo::EmitVAArg(CodeGenFunction &CGF, Address VAListAddr,
201 QualType Ty, AggValueSlot Slot)
const {
203 getContext().getTypeInfoInChars(Ty),
208uint64_t AMDGCNSPIRVABIInfo::numRegsForType(QualType Ty)
const {
212 if (
const VectorType *VT = Ty->
getAs<VectorType>()) {
215 QualType EltTy = VT->getElementType();
216 uint64_t EltSize = getContext().getTypeSize(EltTy);
220 return (VT->getNumElements() + 1) / 2;
222 uint64_t EltNumRegs = (EltSize + 31) / 32;
223 return EltNumRegs * VT->getNumElements();
227 assert(!RD->hasFlexibleArrayMember());
229 for (
const FieldDecl *Field : RD->fields()) {
230 QualType FieldTy =
Field->getType();
231 NumRegs += numRegsForType(FieldTy);
237 return (getContext().getTypeSize(Ty) + 31) / 32;
240llvm::Type *AMDGCNSPIRVABIInfo::coerceKernelArgumentType(llvm::Type *Ty,
242 unsigned ToAS)
const {
244 auto *PtrTy = llvm::dyn_cast<llvm::PointerType>(Ty);
245 if (PtrTy && PtrTy->getAddressSpace() == FromAS)
246 return llvm::PointerType::get(Ty->getContext(), ToAS);
250ABIArgInfo AMDGCNSPIRVABIInfo::classifyReturnType(QualType RetTy)
const {
277 llvm::Type *I32Ty = llvm::Type::getInt32Ty(getVMContext());
281 if (numRegsForType(RetTy) <= MaxNumRegsForArgsRet)
288ABIArgInfo AMDGCNSPIRVABIInfo::classifyKernelArgumentType(QualType Ty)
const {
294 Ty = QualType(SeltTy, 0);
296 llvm::Type *OrigLTy = CGT.ConvertType(Ty);
297 llvm::Type *LTy = OrigLTy;
298 if (getContext().getLangOpts().isTargetDevice()) {
299 LTy = coerceKernelArgumentType(
300 OrigLTy, getContext().getTargetAddressSpace(LangAS::Default),
301 getContext().getTargetAddressSpace(LangAS::opencl_global));
309 getContext().getTypeAlignInChars(Ty),
310 getContext().getTargetAddressSpace(LangAS::opencl_constant),
319ABIArgInfo AMDGCNSPIRVABIInfo::classifyArgumentType(QualType Ty)
const {
320 assert(NumRegsLeft <= MaxNumRegsForArgsRet &&
"register estimate underflow");
329 uint64_t NumRegs = numRegsForType(Ty);
330 NumRegsLeft -= std::min(NumRegs, uint64_t{NumRegsLeft});
339 return getNaturalAlignIndirect(Ty, getDataLayout().getAllocaAddrSpace(),
359 unsigned NumRegs = (
Size + 31) / 32;
360 NumRegsLeft -= std::min(NumRegsLeft, NumRegs);
370 llvm::Type *I32Ty = llvm::Type::getInt32Ty(getVMContext());
374 if (NumRegsLeft > 0) {
375 uint64_t NumRegs = numRegsForType(Ty);
376 if (NumRegsLeft >= NumRegs) {
377 NumRegsLeft -= NumRegs;
385 getContext().getTypeAlignInChars(Ty),
386 getContext().getTargetAddressSpace(LangAS::opencl_private));
389void AMDGCNSPIRVABIInfo::computeInfo(CGFunctionInfo &FI)
const {
395 NumRegsLeft = MaxNumRegsForArgsRet;
397 if (CC == llvm::CallingConv::SPIR_KERNEL)
398 I.info = classifyKernelArgumentType(I.type);
404llvm::FixedVectorType *AMDGCNSPIRVABIInfo::getOptimalVectorMemoryType(
405 llvm::FixedVectorType *Ty,
const LangOptions &LangOpt)
const {
407 if (Ty->getNumElements() == 3 && getDataLayout().getTypeSizeInBits(Ty) == 96)
409 return DefaultABIInfo::getOptimalVectorMemoryType(Ty, LangOpt);
417 AMDGCNSPIRVABIInfo(CGM.
getTypes()).computeInfo(FI);
419 SPIRVABIInfo(CGM.
getTypes()).computeInfo(FI);
421 CommonSPIRABIInfo(CGM.
getTypes()).computeInfo(FI);
427unsigned CommonSPIRTargetCodeGenInfo::getDeviceKernelCallingConv()
const {
428 return llvm::CallingConv::SPIR_KERNEL;
431void SPIRVTargetCodeGenInfo::setCUDAKernelCallingConvention(
432 const FunctionType *&FT)
const {
434 if (getABIInfo().getContext().getLangOpts().
HIP) {
435 FT = getABIInfo().getContext().adjustFunctionType(
441void CommonSPIRTargetCodeGenInfo::setOCLKernelStubCallingConvention(
442 const FunctionType *&FT)
const {
443 FT = getABIInfo().getContext().adjustFunctionType(
454CommonSPIRTargetCodeGenInfo::getNullPointer(
const CodeGen::CodeGenModule &CGM,
455 llvm::PointerType *PT,
460 unsigned ASAsInt =
static_cast<unsigned>(AS);
461 unsigned FirstTargetASAsInt =
462 static_cast<unsigned>(LangAS::FirstTargetAddressSpace);
463 unsigned CodeSectionINTELAS = FirstTargetASAsInt + 9;
466 bool IsFunctionPtrAS =
467 CGM.
getTriple().isSPIRV() && ASAsInt == CodeSectionINTELAS;
468 if (AS == LangAS::Default || AS == LangAS::opencl_generic ||
469 AS == LangAS::opencl_constant || IsFunctionPtrAS)
470 return llvm::ConstantPointerNull::get(PT);
473 auto NPT = llvm::PointerType::get(
474 PT->getContext(), Ctx.getTargetAddressSpace(LangAS::opencl_generic));
475 return llvm::ConstantExpr::getAddrSpaceCast(
476 llvm::ConstantPointerNull::get(NPT), PT);
480SPIRVTargetCodeGenInfo::getGlobalVarAddressSpace(CodeGenModule &CGM,
481 const VarDecl *D)
const {
484 "Address space agnostic languages only");
492 return DefaultGlobalAS;
495 if (AddrSpace != LangAS::Default)
498 return DefaultGlobalAS;
501void SPIRVTargetCodeGenInfo::setTargetAttributes(
502 const Decl *D, llvm::GlobalValue *GV, CodeGen::CodeGenModule &M)
const {
503 if (GV->isDeclaration())
506 const FunctionDecl *FD = dyn_cast_or_null<FunctionDecl>(D);
510 llvm::Function *F = dyn_cast<llvm::Function>(GV);
511 assert(F &&
"Expected GlobalValue to be a Function");
517 if (!FD->
hasAttr<CUDAGlobalAttr>())
520 unsigned N = M.
getLangOpts().GPUMaxThreadsPerBlock;
521 if (
auto FlatWGS = FD->
getAttr<AMDGPUFlatWorkGroupSizeAttr>())
522 N = FlatWGS->getMax()->EvaluateKnownConstInt(M.
getContext()).getExtValue();
528 llvm::Metadata *AttrMDArgs[] = {
529 llvm::ConstantAsMetadata::get(llvm::ConstantInt::get(Int32Ty, N)),
530 llvm::ConstantAsMetadata::get(llvm::ConstantInt::get(Int32Ty, 1)),
531 llvm::ConstantAsMetadata::get(llvm::ConstantInt::get(Int32Ty, 1))};
533 F->setMetadata(
"max_work_group_size",
537StringRef SPIRVTargetCodeGenInfo::getLLVMSyncScopeStr(
538 const LangOptions &,
SyncScope Scope, llvm::AtomicOrdering)
const {
540 case SyncScope::HIPSingleThread:
541 case SyncScope::SingleScope:
542 return "singlethread";
543 case SyncScope::HIPWavefront:
544 case SyncScope::OpenCLSubGroup:
545 case SyncScope::WavefrontScope:
547 case SyncScope::HIPCluster:
548 case SyncScope::ClusterScope:
549 case SyncScope::HIPWorkgroup:
550 case SyncScope::OpenCLWorkGroup:
551 case SyncScope::WorkgroupScope:
553 case SyncScope::HIPAgent:
554 case SyncScope::OpenCLDevice:
555 case SyncScope::DeviceScope:
557 case SyncScope::SystemScope:
558 case SyncScope::HIPSystem:
559 case SyncScope::OpenCLAllSVMDevices:
567 StringRef OpenCLName,
568 unsigned AccessQualifier) {
579 if (OpenCLName.starts_with(
"image2d"))
581 else if (OpenCLName.starts_with(
"image3d"))
583 else if (OpenCLName ==
"image1d_buffer")
586 assert(OpenCLName.starts_with(
"image1d") &&
"Unknown image type");
591 if (OpenCLName.contains(
"_depth"))
593 if (OpenCLName.contains(
"_array"))
595 if (OpenCLName.contains(
"_msaa"))
599 IntParams.push_back(AccessQualifier);
601 return llvm::TargetExtType::get(Ctx, BaseType, {llvm::Type::getVoidTy(Ctx)},
605llvm::Type *CommonSPIRTargetCodeGenInfo::getOpenCLType(CodeGenModule &CGM,
606 const Type *Ty)
const {
608 if (
auto *PipeTy = dyn_cast<PipeType>(Ty))
609 return llvm::TargetExtType::get(Ctx,
"spirv.Pipe", {},
610 {!PipeTy->isReadOnly()});
611 if (
auto *BuiltinTy = dyn_cast<BuiltinType>(Ty)) {
612 enum AccessQualifier :
unsigned { AQ_ro = 0, AQ_wo = 1, AQ_rw = 2 };
613 switch (BuiltinTy->getKind()) {
614#define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \
615 case BuiltinType::Id: \
616 return getSPIRVImageType(Ctx, "spirv.Image", #ImgType, AQ_##Suffix);
617#include "clang/Basic/OpenCLImageTypes.def"
618 case BuiltinType::OCLSampler:
619 return llvm::TargetExtType::get(Ctx,
"spirv.Sampler");
620 case BuiltinType::OCLEvent:
621 return llvm::TargetExtType::get(Ctx,
"spirv.Event");
622 case BuiltinType::OCLClkEvent:
623 return llvm::TargetExtType::get(Ctx,
"spirv.DeviceEvent");
624 case BuiltinType::OCLQueue:
625 return llvm::TargetExtType::get(Ctx,
"spirv.Queue");
626 case BuiltinType::OCLReserveID:
627 return llvm::TargetExtType::get(Ctx,
"spirv.ReserveId");
628#define INTEL_SUBGROUP_AVC_TYPE(Name, Id) \
629 case BuiltinType::OCLIntelSubgroupAVC##Id: \
630 return llvm::TargetExtType::get(Ctx, "spirv.Avc" #Id "INTEL");
631#include "clang/Basic/OpenCLExtensionTypes.def"
643 llvm::Type *IntegralType,
650 while (
Value.ugt(0)) {
651 uint32_t Word =
Value.trunc(32).getZExtValue();
652 Value.lshrInPlace(32);
654 Words.push_back(Word);
656 if (Words.size() == 0)
660 return llvm::TargetExtType::get(Ctx,
"spirv.IntegralConstant",
661 {IntegralType}, Words);
662 return llvm::TargetExtType::get(Ctx,
"spirv.Literal", {}, Words);
666 const HLSLInlineSpirvType *SpirvType) {
671 for (
auto &Operand : SpirvType->getOperands()) {
672 using SpirvOperandKind = SpirvOperand::SpirvOperandKind;
674 llvm::Type *Result =
nullptr;
675 switch (Operand.getKind()) {
676 case SpirvOperandKind::ConstantId: {
677 llvm::Type *IntegralType =
683 case SpirvOperandKind::Literal: {
687 case SpirvOperandKind::TypeId: {
688 QualType TypeOperand = Operand.getResultType();
690 assert(RD->isCompleteDefinition() &&
691 "Type completion should have been required in Sema");
693 const FieldDecl *HandleField = RD->findFirstNamedDataMember();
696 if (ResourceType->
getAs<HLSLAttributedResourceType>()) {
697 TypeOperand = ResourceType;
705 llvm_unreachable(
"HLSLInlineSpirvType had invalid operand!");
710 Operands.push_back(Result);
713 return llvm::TargetExtType::get(Ctx,
"spirv.Type", Operands,
714 {SpirvType->getOpcode(), SpirvType->getSize(),
715 SpirvType->getAlignment()});
718llvm::Type *CommonSPIRTargetCodeGenInfo::getHLSLType(
719 CodeGenModule &CGM,
const Type *Ty,
720 const CGHLSLOffsetInfo &OffsetInfo)
const {
723 if (
auto *SpirvType = dyn_cast<HLSLInlineSpirvType>(Ty))
726 auto *ResType = dyn_cast<HLSLAttributedResourceType>(Ty);
730 const HLSLAttributedResourceType::Attributes &ResAttrs = ResType->getAttrs();
731 switch (ResAttrs.ResourceClass) {
732 case llvm::dxil::ResourceClass::UAV:
733 case llvm::dxil::ResourceClass::SRV: {
735 QualType ContainedTy = ResType->getContainedType();
739 assert(!ResAttrs.IsROV &&
740 "Rasterizer order views not implemented for SPIR-V yet");
742 if (!ResAttrs.RawBuffer) {
744 return getSPIRVImageTypeFromHLSLResource(ResAttrs, ContainedTy, CGM);
747 if (ResAttrs.IsCounter) {
748 llvm::Type *ElemType = llvm::Type::getInt32Ty(Ctx);
750 return llvm::TargetExtType::get(Ctx,
"spirv.VulkanBuffer", {ElemType},
754 llvm::ArrayType *RuntimeArrayType = llvm::ArrayType::get(ElemType, 0);
756 bool IsWritable = ResAttrs.ResourceClass == llvm::dxil::ResourceClass::UAV;
757 return llvm::TargetExtType::get(Ctx,
"spirv.VulkanBuffer",
761 case llvm::dxil::ResourceClass::CBuffer: {
762 QualType ContainedTy = ResType->getContainedType();
766 llvm::StructType *BufferLayoutTy =
767 HLSLBufferLayoutBuilder(CGM).layOutStruct(
770 return llvm::TargetExtType::get(Ctx,
"spirv.VulkanBuffer", {BufferLayoutTy},
774 case llvm::dxil::ResourceClass::Sampler:
775 return llvm::TargetExtType::get(Ctx,
"spirv.Sampler");
782 const HLSLAttributedResourceType::Attributes &attributes,
783 llvm::Type *SampledType,
QualType Ty,
unsigned NumChannels) {
788 if (LangOpts.HLSLSpvUseUnknownImageFormat ||
789 attributes.ResourceClass != llvm::dxil::ResourceClass::UAV) {
793 if (SampledType->isIntegerTy(32)) {
795 if (NumChannels == 1)
797 if (NumChannels == 2)
799 if (NumChannels == 4)
802 if (NumChannels == 1)
804 if (NumChannels == 2)
806 if (NumChannels == 4)
809 }
else if (SampledType->isIntegerTy(64)) {
810 if (NumChannels == 1) {
816 }
else if (SampledType->isFloatTy()) {
817 if (NumChannels == 1)
819 if (NumChannels == 2)
821 if (NumChannels == 4)
828llvm::Type *CommonSPIRTargetCodeGenInfo::getSPIRVImageTypeFromHLSLResource(
829 const HLSLAttributedResourceType::Attributes &attributes, QualType Ty,
830 CodeGenModule &CGM)
const {
833 unsigned NumChannels = 1;
835 if (
const VectorType *
V = dyn_cast<VectorType>(Ty)) {
836 NumChannels =
V->getNumElements();
837 Ty =
V->getElementType();
839 assert(!Ty->
isVectorType() &&
"We still have a vector type.");
843 assert((SampledType->isIntegerTy() || SampledType->isFloatingPointTy()) &&
844 "The element type for a SPIR-V resource must be a scalar integer or "
845 "floating point type.");
850 SmallVector<unsigned, 6> IntParams(6, 0);
856 switch (attributes.ResourceDimension) {
857 case llvm::dxil::ResourceDimension::Dim1D:
860 case llvm::dxil::ResourceDimension::Dim2D:
863 case llvm::dxil::ResourceDimension::Dim3D:
866 case llvm::dxil::ResourceDimension::Cube:
869 case llvm::dxil::ResourceDimension::Unknown:
886 attributes.ResourceClass == llvm::dxil::ResourceClass::UAV ? 2 : 1;
892 llvm::TargetExtType *ImageType =
893 llvm::TargetExtType::get(Ctx, Name, {SampledType}, IntParams);
897std::unique_ptr<TargetCodeGenInfo>
899 return std::make_unique<CommonSPIRTargetCodeGenInfo>(CGM.
getTypes());
902std::unique_ptr<TargetCodeGenInfo>
904 return std::make_unique<SPIRVTargetCodeGenInfo>(CGM.
getTypes());
static void setCUDAKernelCallingConvention(CanQualType &FTy, CodeGenModule &CGM, const FunctionDecl *FD)
Set calling convention for CUDA/HIP kernel.
static llvm::Type * getInlineSpirvType(CodeGenModule &CGM, const HLSLInlineSpirvType *SpirvType)
static llvm::Type * getSPIRVImageType(llvm::LLVMContext &Ctx, StringRef BaseType, StringRef OpenCLName, unsigned AccessQualifier)
Construct a SPIR-V target extension type for the given OpenCL image type.
static unsigned getImageFormat(const LangOptions &LangOpts, const HLSLAttributedResourceType::Attributes &attributes, llvm::Type *SampledType, QualType Ty, unsigned NumChannels)
static llvm::Type * getInlineSpirvConstant(CodeGenModule &CGM, llvm::Type *IntegralType, llvm::APInt Value)
Defines the clang::LangOptions interface.
unsigned getTargetAddressSpace(LangAS AS) const
QuantityType getQuantity() const
getQuantity - Get the raw integer representation of this quantity.
static CharUnits fromQuantity(QuantityType Quantity)
fromQuantity - Construct a CharUnits quantity from a raw integer type.
static ABIArgInfo getIgnore()
static ABIArgInfo getDirect(llvm::Type *T=nullptr, unsigned Offset=0, llvm::Type *Padding=nullptr, bool CanBeFlattened=true, unsigned Align=0)
static ABIArgInfo getIndirectAliased(CharUnits Alignment, unsigned AddrSpace, bool Realign=false, llvm::Type *Padding=nullptr)
Pass this in memory using the IR byref attribute.
@ RAA_DirectInMemory
Pass it on the stack using its defined layout.
CGFunctionInfo - Class to encapsulate the information about a function definition.
ABIArgInfo & getReturnInfo()
unsigned getCallingConvention() const
getCallingConvention - Return the user specified calling convention, which has been translated into a...
CanQualType getReturnType() const
MutableArrayRef< ArgInfo > arguments()
unsigned getNumRequiredArgs() const
This class organizes the cross-function state that is used while generating LLVM code.
const LangOptions & getLangOpts() const
CodeGenTypes & getTypes()
const TargetInfo & getTarget() const
const llvm::Triple & getTriple() const
ASTContext & getContext() const
llvm::LLVMContext & getLLVMContext()
llvm::Type * ConvertType(QualType T)
ConvertType - Convert type T into a llvm::Type.
llvm::Type * ConvertTypeForMem(QualType T)
ConvertTypeForMem - Convert type T into a llvm::Type.
DefaultABIInfo - The default implementation for ABI specific details.
ABIArgInfo classifyArgumentType(QualType RetTy) const
ABIArgInfo classifyReturnType(QualType RetTy) const
TargetCodeGenInfo - This class organizes various target-specific codegeneration issues,...
Represents a member of a struct/union/class.
ExtInfo withCallingConv(CallingConv cc) const
ExtInfo getExtInfo() const
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
A (possibly-)qualified type.
bool isNull() const
Return true if this QualType doesn't point to a type yet.
LangAS getAddressSpace() const
Return the address space of this type.
bool hasFlexibleArrayMember() const
const llvm::Triple & getTriple() const
Returns the target triple of the primary target.
bool isStructureType() const
bool isSignedIntegerType() const
Return true if this is an integer type that is signed, according to C99 6.2.5p4 [char,...
RecordDecl * getAsRecordDecl() const
Retrieves the RecordDecl this type refers to.
CanQualType getCanonicalTypeUnqualified() const
QualType getPointeeType() const
If this is a pointer, ObjC object pointer, or block pointer, this returns the respective pointee.
bool isVectorType() const
const T * getAsCanonical() const
If this type is canonically the specified type, return its canonical type cast to that specified type...
const T * getAs() const
Member-template getAs<specific type>'.
const Type * getUnqualifiedDesugaredType() const
Return the specified type with any "sugar" removed from the type, removing any typedefs,...
bool isNullPtrType() const
ABIArgInfo classifyArgumentType(CodeGenModule &CGM, CanQualType type)
Classify the rules for how to pass a particular type.
@ Decl
The l-value was an access to a declared entity or something equivalently strong, like the address of ...
CGCXXABI::RecordArgABI getRecordArgABI(const RecordType *RT, CGCXXABI &CXXABI)
bool classifyReturnType(const CGCXXABI &CXXABI, CGFunctionInfo &FI, const ABIInfo &Info)
void computeSPIRKernelABIInfo(CodeGenModule &CGM, CGFunctionInfo &FI)
RValue emitVoidPtrVAArg(CodeGenFunction &CGF, Address VAListAddr, QualType ValueTy, bool IsIndirect, TypeInfoChars ValueInfo, CharUnits SlotSizeAndAlign, bool AllowHigherAlign, AggValueSlot Slot, bool ForceRightAdjust=false)
Emit va_arg for a platform using the common void* representation, where arguments are simply emitted ...
bool isAggregateTypeForABI(QualType T)
const Type * isSingleElementStruct(QualType T, ASTContext &Context)
isSingleElementStruct - Determine if a structure is a "singleelement struct", i.e.
std::unique_ptr< TargetCodeGenInfo > createSPIRVTargetCodeGenInfo(CodeGenModule &CGM)
QualType useFirstFieldIfTransparentUnion(QualType Ty)
Pass transparent unions as if they were the type of the first element.
std::unique_ptr< TargetCodeGenInfo > createCommonSPIRTargetCodeGenInfo(CodeGenModule &CGM)
bool isEmptyRecord(ASTContext &Context, QualType T, bool AllowArrays, bool AsIfNoUniqueAddr=false)
isEmptyRecord - Return true iff a structure contains only empty fields.
The JSON file list parser is used to communicate input to InstallAPI.
StorageClass
Storage classes.
@ Type
The name was classified as a type.
LangAS
Defines the address space values used by the address space qualifier of QualType.
for(const auto &A :T->param_types())
SyncScope
Defines sync scope values used internally by clang.
LangAS getLangASFromTargetAS(unsigned TargetAS)