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 {
153 llvm::Type *LTy = CGT.ConvertType(Ty);
154 auto DefaultAS = getContext().getTargetAddressSpace(LangAS::Default);
155 auto GlobalAS = getContext().getTargetAddressSpace(LangAS::opencl_global);
156 auto *PtrTy = llvm::dyn_cast<llvm::PointerType>(LTy);
157 if (PtrTy && PtrTy->getAddressSpace() == DefaultAS) {
158 LTy = llvm::PointerType::get(PtrTy->getContext(), GlobalAS);
162 if (getContext().getLangOpts().isTargetDevice() &&
172 return getNaturalAlignIndirect(Ty, 0,
true);
177void SPIRVABIInfo::computeInfo(CGFunctionInfo &FI)
const {
182 for (
auto &&[ArgumentsCount, I] : llvm::enumerate(FI.
arguments()))
185 : ABIArgInfo::getDirect();
191 if (CC == llvm::CallingConv::SPIR_KERNEL) {
192 I.info = classifyKernelArgumentType(I.type);
194 I.info = classifyArgumentType(I.type);
199RValue SPIRVABIInfo::EmitVAArg(CodeGenFunction &CGF, Address VAListAddr,
200 QualType Ty, AggValueSlot Slot)
const {
202 getContext().getTypeInfoInChars(Ty),
207uint64_t AMDGCNSPIRVABIInfo::numRegsForType(QualType Ty)
const {
211 if (
const VectorType *VT = Ty->
getAs<VectorType>()) {
214 QualType EltTy = VT->getElementType();
215 uint64_t EltSize = getContext().getTypeSize(EltTy);
219 return (VT->getNumElements() + 1) / 2;
221 uint64_t EltNumRegs = (EltSize + 31) / 32;
222 return EltNumRegs * VT->getNumElements();
226 assert(!RD->hasFlexibleArrayMember());
228 for (
const FieldDecl *Field : RD->fields()) {
229 QualType FieldTy =
Field->getType();
230 NumRegs += numRegsForType(FieldTy);
236 return (getContext().getTypeSize(Ty) + 31) / 32;
239llvm::Type *AMDGCNSPIRVABIInfo::coerceKernelArgumentType(llvm::Type *Ty,
241 unsigned ToAS)
const {
243 auto *PtrTy = llvm::dyn_cast<llvm::PointerType>(Ty);
244 if (PtrTy && PtrTy->getAddressSpace() == FromAS)
245 return llvm::PointerType::get(Ty->getContext(), ToAS);
249ABIArgInfo AMDGCNSPIRVABIInfo::classifyReturnType(QualType RetTy)
const {
276 llvm::Type *I32Ty = llvm::Type::getInt32Ty(getVMContext());
280 if (numRegsForType(RetTy) <= MaxNumRegsForArgsRet)
287ABIArgInfo AMDGCNSPIRVABIInfo::classifyKernelArgumentType(QualType Ty)
const {
293 Ty = QualType(SeltTy, 0);
295 llvm::Type *OrigLTy = CGT.ConvertType(Ty);
296 llvm::Type *LTy = OrigLTy;
297 if (getContext().getLangOpts().isTargetDevice()) {
298 LTy = coerceKernelArgumentType(
299 OrigLTy, getContext().getTargetAddressSpace(LangAS::Default),
300 getContext().getTargetAddressSpace(LangAS::opencl_global));
308 getContext().getTypeAlignInChars(Ty),
309 getContext().getTargetAddressSpace(LangAS::opencl_constant),
318ABIArgInfo AMDGCNSPIRVABIInfo::classifyArgumentType(QualType Ty)
const {
319 assert(NumRegsLeft <= MaxNumRegsForArgsRet &&
"register estimate underflow");
328 uint64_t NumRegs = numRegsForType(Ty);
329 NumRegsLeft -= std::min(NumRegs, uint64_t{NumRegsLeft});
338 return getNaturalAlignIndirect(Ty, getDataLayout().getAllocaAddrSpace(),
358 unsigned NumRegs = (
Size + 31) / 32;
359 NumRegsLeft -= std::min(NumRegsLeft, NumRegs);
369 llvm::Type *I32Ty = llvm::Type::getInt32Ty(getVMContext());
373 if (NumRegsLeft > 0) {
374 uint64_t NumRegs = numRegsForType(Ty);
375 if (NumRegsLeft >= NumRegs) {
376 NumRegsLeft -= NumRegs;
384 getContext().getTypeAlignInChars(Ty),
385 getContext().getTargetAddressSpace(LangAS::opencl_private));
388void AMDGCNSPIRVABIInfo::computeInfo(CGFunctionInfo &FI)
const {
394 NumRegsLeft = MaxNumRegsForArgsRet;
396 if (CC == llvm::CallingConv::SPIR_KERNEL)
397 I.info = classifyKernelArgumentType(I.type);
403llvm::FixedVectorType *AMDGCNSPIRVABIInfo::getOptimalVectorMemoryType(
404 llvm::FixedVectorType *Ty,
const LangOptions &LangOpt)
const {
406 if (Ty->getNumElements() == 3 && getDataLayout().getTypeSizeInBits(Ty) == 96)
408 return DefaultABIInfo::getOptimalVectorMemoryType(Ty, LangOpt);
416 AMDGCNSPIRVABIInfo(CGM.
getTypes()).computeInfo(FI);
418 SPIRVABIInfo(CGM.
getTypes()).computeInfo(FI);
420 CommonSPIRABIInfo(CGM.
getTypes()).computeInfo(FI);
426unsigned CommonSPIRTargetCodeGenInfo::getDeviceKernelCallingConv()
const {
427 return llvm::CallingConv::SPIR_KERNEL;
430void SPIRVTargetCodeGenInfo::setCUDAKernelCallingConvention(
431 const FunctionType *&FT)
const {
433 if (getABIInfo().getContext().getLangOpts().
HIP) {
434 FT = getABIInfo().getContext().adjustFunctionType(
440void CommonSPIRTargetCodeGenInfo::setOCLKernelStubCallingConvention(
441 const FunctionType *&FT)
const {
442 FT = getABIInfo().getContext().adjustFunctionType(
453CommonSPIRTargetCodeGenInfo::getNullPointer(
const CodeGen::CodeGenModule &CGM,
454 llvm::PointerType *PT,
459 unsigned ASAsInt =
static_cast<unsigned>(AS);
460 unsigned FirstTargetASAsInt =
461 static_cast<unsigned>(LangAS::FirstTargetAddressSpace);
462 unsigned CodeSectionINTELAS = FirstTargetASAsInt + 9;
465 bool IsFunctionPtrAS =
466 CGM.
getTriple().isSPIRV() && ASAsInt == CodeSectionINTELAS;
467 if (AS == LangAS::Default || AS == LangAS::opencl_generic ||
468 AS == LangAS::opencl_constant || IsFunctionPtrAS)
469 return llvm::ConstantPointerNull::get(PT);
472 auto NPT = llvm::PointerType::get(
473 PT->getContext(), Ctx.getTargetAddressSpace(LangAS::opencl_generic));
474 return llvm::ConstantExpr::getAddrSpaceCast(
475 llvm::ConstantPointerNull::get(NPT), PT);
479SPIRVTargetCodeGenInfo::getGlobalVarAddressSpace(CodeGenModule &CGM,
480 const VarDecl *D)
const {
483 "Address space agnostic languages only");
491 return DefaultGlobalAS;
494 if (AddrSpace != LangAS::Default)
497 return DefaultGlobalAS;
500void SPIRVTargetCodeGenInfo::setTargetAttributes(
501 const Decl *D, llvm::GlobalValue *GV, CodeGen::CodeGenModule &M)
const {
502 if (GV->isDeclaration())
505 const FunctionDecl *FD = dyn_cast_or_null<FunctionDecl>(D);
509 llvm::Function *F = dyn_cast<llvm::Function>(GV);
510 assert(F &&
"Expected GlobalValue to be a Function");
516 if (!FD->
hasAttr<CUDAGlobalAttr>())
519 unsigned N = M.
getLangOpts().GPUMaxThreadsPerBlock;
520 if (
auto FlatWGS = FD->
getAttr<AMDGPUFlatWorkGroupSizeAttr>())
521 N = FlatWGS->getMax()->EvaluateKnownConstInt(M.
getContext()).getExtValue();
527 llvm::Metadata *AttrMDArgs[] = {
528 llvm::ConstantAsMetadata::get(llvm::ConstantInt::get(Int32Ty, N)),
529 llvm::ConstantAsMetadata::get(llvm::ConstantInt::get(Int32Ty, 1)),
530 llvm::ConstantAsMetadata::get(llvm::ConstantInt::get(Int32Ty, 1))};
532 F->setMetadata(
"max_work_group_size",
536StringRef SPIRVTargetCodeGenInfo::getLLVMSyncScopeStr(
537 const LangOptions &,
SyncScope Scope, llvm::AtomicOrdering)
const {
539 case SyncScope::HIPSingleThread:
540 case SyncScope::SingleScope:
541 return "singlethread";
542 case SyncScope::HIPWavefront:
543 case SyncScope::OpenCLSubGroup:
544 case SyncScope::WavefrontScope:
546 case SyncScope::HIPCluster:
547 case SyncScope::ClusterScope:
548 case SyncScope::HIPWorkgroup:
549 case SyncScope::OpenCLWorkGroup:
550 case SyncScope::WorkgroupScope:
552 case SyncScope::HIPAgent:
553 case SyncScope::OpenCLDevice:
554 case SyncScope::DeviceScope:
556 case SyncScope::SystemScope:
557 case SyncScope::HIPSystem:
558 case SyncScope::OpenCLAllSVMDevices:
566 StringRef OpenCLName,
567 unsigned AccessQualifier) {
578 if (OpenCLName.starts_with(
"image2d"))
580 else if (OpenCLName.starts_with(
"image3d"))
582 else if (OpenCLName ==
"image1d_buffer")
585 assert(OpenCLName.starts_with(
"image1d") &&
"Unknown image type");
590 if (OpenCLName.contains(
"_depth"))
592 if (OpenCLName.contains(
"_array"))
594 if (OpenCLName.contains(
"_msaa"))
598 IntParams.push_back(AccessQualifier);
600 return llvm::TargetExtType::get(Ctx, BaseType, {llvm::Type::getVoidTy(Ctx)},
604llvm::Type *CommonSPIRTargetCodeGenInfo::getOpenCLType(CodeGenModule &CGM,
605 const Type *Ty)
const {
607 if (
auto *PipeTy = dyn_cast<PipeType>(Ty))
608 return llvm::TargetExtType::get(Ctx,
"spirv.Pipe", {},
609 {!PipeTy->isReadOnly()});
610 if (
auto *BuiltinTy = dyn_cast<BuiltinType>(Ty)) {
611 enum AccessQualifier :
unsigned { AQ_ro = 0, AQ_wo = 1, AQ_rw = 2 };
612 switch (BuiltinTy->getKind()) {
613#define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \
614 case BuiltinType::Id: \
615 return getSPIRVImageType(Ctx, "spirv.Image", #ImgType, AQ_##Suffix);
616#include "clang/Basic/OpenCLImageTypes.def"
617 case BuiltinType::OCLSampler:
618 return llvm::TargetExtType::get(Ctx,
"spirv.Sampler");
619 case BuiltinType::OCLEvent:
620 return llvm::TargetExtType::get(Ctx,
"spirv.Event");
621 case BuiltinType::OCLClkEvent:
622 return llvm::TargetExtType::get(Ctx,
"spirv.DeviceEvent");
623 case BuiltinType::OCLQueue:
624 return llvm::TargetExtType::get(Ctx,
"spirv.Queue");
625 case BuiltinType::OCLReserveID:
626 return llvm::TargetExtType::get(Ctx,
"spirv.ReserveId");
627#define INTEL_SUBGROUP_AVC_TYPE(Name, Id) \
628 case BuiltinType::OCLIntelSubgroupAVC##Id: \
629 return llvm::TargetExtType::get(Ctx, "spirv.Avc" #Id "INTEL");
630#include "clang/Basic/OpenCLExtensionTypes.def"
642 llvm::Type *IntegralType,
649 while (
Value.ugt(0)) {
650 uint32_t Word =
Value.trunc(32).getZExtValue();
651 Value.lshrInPlace(32);
653 Words.push_back(Word);
655 if (Words.size() == 0)
659 return llvm::TargetExtType::get(Ctx,
"spirv.IntegralConstant",
660 {IntegralType}, Words);
661 return llvm::TargetExtType::get(Ctx,
"spirv.Literal", {}, Words);
665 const HLSLInlineSpirvType *SpirvType) {
670 for (
auto &Operand : SpirvType->getOperands()) {
671 using SpirvOperandKind = SpirvOperand::SpirvOperandKind;
673 llvm::Type *Result =
nullptr;
674 switch (Operand.getKind()) {
675 case SpirvOperandKind::ConstantId: {
676 llvm::Type *IntegralType =
682 case SpirvOperandKind::Literal: {
686 case SpirvOperandKind::TypeId: {
687 QualType TypeOperand = Operand.getResultType();
689 assert(RD->isCompleteDefinition() &&
690 "Type completion should have been required in Sema");
692 const FieldDecl *HandleField = RD->findFirstNamedDataMember();
695 if (ResourceType->
getAs<HLSLAttributedResourceType>()) {
696 TypeOperand = ResourceType;
704 llvm_unreachable(
"HLSLInlineSpirvType had invalid operand!");
709 Operands.push_back(Result);
712 return llvm::TargetExtType::get(Ctx,
"spirv.Type", Operands,
713 {SpirvType->getOpcode(), SpirvType->getSize(),
714 SpirvType->getAlignment()});
717llvm::Type *CommonSPIRTargetCodeGenInfo::getHLSLType(
718 CodeGenModule &CGM,
const Type *Ty,
719 const CGHLSLOffsetInfo &OffsetInfo)
const {
722 if (
auto *SpirvType = dyn_cast<HLSLInlineSpirvType>(Ty))
725 auto *ResType = dyn_cast<HLSLAttributedResourceType>(Ty);
729 const HLSLAttributedResourceType::Attributes &ResAttrs = ResType->getAttrs();
730 switch (ResAttrs.ResourceClass) {
731 case llvm::dxil::ResourceClass::UAV:
732 case llvm::dxil::ResourceClass::SRV: {
734 QualType ContainedTy = ResType->getContainedType();
738 assert(!ResAttrs.IsROV &&
739 "Rasterizer order views not implemented for SPIR-V yet");
741 if (!ResAttrs.RawBuffer) {
743 return getSPIRVImageTypeFromHLSLResource(ResAttrs, ContainedTy, CGM);
746 if (ResAttrs.IsCounter) {
747 llvm::Type *ElemType = llvm::Type::getInt32Ty(Ctx);
749 return llvm::TargetExtType::get(Ctx,
"spirv.VulkanBuffer", {ElemType},
753 llvm::ArrayType *RuntimeArrayType = llvm::ArrayType::get(ElemType, 0);
755 bool IsWritable = ResAttrs.ResourceClass == llvm::dxil::ResourceClass::UAV;
756 return llvm::TargetExtType::get(Ctx,
"spirv.VulkanBuffer",
760 case llvm::dxil::ResourceClass::CBuffer: {
761 QualType ContainedTy = ResType->getContainedType();
765 llvm::StructType *BufferLayoutTy =
766 HLSLBufferLayoutBuilder(CGM).layOutStruct(
769 return llvm::TargetExtType::get(Ctx,
"spirv.VulkanBuffer", {BufferLayoutTy},
773 case llvm::dxil::ResourceClass::Sampler:
774 return llvm::TargetExtType::get(Ctx,
"spirv.Sampler");
781 const HLSLAttributedResourceType::Attributes &attributes,
782 llvm::Type *SampledType,
QualType Ty,
unsigned NumChannels) {
787 if (LangOpts.HLSLSpvUseUnknownImageFormat ||
788 attributes.ResourceClass != llvm::dxil::ResourceClass::UAV) {
792 if (SampledType->isIntegerTy(32)) {
794 if (NumChannels == 1)
796 if (NumChannels == 2)
798 if (NumChannels == 4)
801 if (NumChannels == 1)
803 if (NumChannels == 2)
805 if (NumChannels == 4)
808 }
else if (SampledType->isIntegerTy(64)) {
809 if (NumChannels == 1) {
815 }
else if (SampledType->isFloatTy()) {
816 if (NumChannels == 1)
818 if (NumChannels == 2)
820 if (NumChannels == 4)
827llvm::Type *CommonSPIRTargetCodeGenInfo::getSPIRVImageTypeFromHLSLResource(
828 const HLSLAttributedResourceType::Attributes &attributes, QualType Ty,
829 CodeGenModule &CGM)
const {
832 unsigned NumChannels = 1;
834 if (
const VectorType *
V = dyn_cast<VectorType>(Ty)) {
835 NumChannels =
V->getNumElements();
836 Ty =
V->getElementType();
838 assert(!Ty->
isVectorType() &&
"We still have a vector type.");
842 assert((SampledType->isIntegerTy() || SampledType->isFloatingPointTy()) &&
843 "The element type for a SPIR-V resource must be a scalar integer or "
844 "floating point type.");
849 SmallVector<unsigned, 6> IntParams(6, 0);
855 switch (attributes.ResourceDimension) {
856 case llvm::dxil::ResourceDimension::Dim1D:
859 case llvm::dxil::ResourceDimension::Dim2D:
862 case llvm::dxil::ResourceDimension::Dim3D:
865 case llvm::dxil::ResourceDimension::Cube:
868 case llvm::dxil::ResourceDimension::Unknown:
885 attributes.ResourceClass == llvm::dxil::ResourceClass::UAV ? 2 : 1;
891 llvm::TargetExtType *ImageType =
892 llvm::TargetExtType::get(Ctx, Name, {SampledType}, IntParams);
896std::unique_ptr<TargetCodeGenInfo>
898 return std::make_unique<CommonSPIRTargetCodeGenInfo>(CGM.
getTypes());
901std::unique_ptr<TargetCodeGenInfo>
903 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.
static StringRef getTriple(const Command &Job)
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)