11#include "TargetInfo.h"
14#include "llvm/IR/DerivedTypes.h"
30 CommonSPIRABIInfo(CodeGenTypes &CGT) : DefaultABIInfo(CGT) { setCCs(); }
36class SPIRVABIInfo :
public CommonSPIRABIInfo {
38 SPIRVABIInfo(CodeGenTypes &CGT) : CommonSPIRABIInfo(CGT) {}
39 void computeInfo(CGFunctionInfo &FI)
const override;
40 RValue EmitVAArg(CodeGenFunction &CGF, Address VAListAddr, QualType Ty,
41 AggValueSlot Slot)
const override;
43 llvm::FixedVectorType *
44 getOptimalVectorMemoryType(llvm::FixedVectorType *Ty,
45 const LangOptions &LangOpt)
const override;
48 ABIArgInfo classifyKernelArgumentType(QualType Ty)
const;
51class AMDGCNSPIRVABIInfo :
public SPIRVABIInfo {
54 static constexpr unsigned MaxNumRegsForArgsRet = 16;
55 mutable unsigned NumRegsLeft = 0;
57 uint64_t numRegsForType(QualType Ty)
const;
59 bool isHomogeneousAggregateBaseType(QualType Ty)
const override {
62 bool isHomogeneousAggregateSmallEnough(
const Type *Base,
63 uint64_t Members)
const override {
64 uint32_t NumRegs = (getContext().getTypeSize(Base) + 31) / 32;
67 return Members * NumRegs <= MaxNumRegsForArgsRet;
71 llvm::Type *coerceKernelArgumentType(llvm::Type *Ty,
unsigned FromAS,
75 ABIArgInfo classifyKernelArgumentType(QualType Ty)
const;
79 AMDGCNSPIRVABIInfo(CodeGenTypes &CGT) : SPIRVABIInfo(CGT) {}
80 void computeInfo(CGFunctionInfo &FI)
const override;
82 llvm::FixedVectorType *
83 getOptimalVectorMemoryType(llvm::FixedVectorType *Ty,
84 const LangOptions &LangOpt)
const override;
90 CommonSPIRTargetCodeGenInfo(CodeGen::CodeGenTypes &CGT)
91 : TargetCodeGenInfo(std::make_unique<CommonSPIRABIInfo>(CGT)) {}
92 CommonSPIRTargetCodeGenInfo(std::unique_ptr<ABIInfo> ABIInfo)
93 : TargetCodeGenInfo(std::move(ABIInfo)) {}
95 LangAS getASTAllocaAddressSpace()
const override {
97 getABIInfo().getDataLayout().getAllocaAddrSpace());
100 unsigned getDeviceKernelCallingConv()
const override;
101 llvm::Type *getOpenCLType(CodeGenModule &CGM,
const Type *T)
const override;
102 llvm::Type *getHLSLType(CodeGenModule &CGM,
const Type *Ty,
103 const CGHLSLOffsetInfo &OffsetInfo)
const override;
105 llvm::Type *getHLSLPadding(CodeGenModule &CGM,
106 CharUnits NumBytes)
const override {
108 return llvm::TargetExtType::get(CGM.
getLLVMContext(),
"spirv.Padding", {},
112 bool isHLSLPadding(llvm::Type *Ty)
const override {
113 if (
auto *TET = dyn_cast<llvm::TargetExtType>(Ty))
114 return TET->getName() ==
"spirv.Padding";
118 llvm::Type *getSPIRVImageTypeFromHLSLResource(
119 const HLSLAttributedResourceType::Attributes &attributes,
120 QualType SampledType, CodeGenModule &CGM)
const;
122 setOCLKernelStubCallingConvention(
const FunctionType *&FT)
const override;
123 llvm::Constant *getNullPointer(
const CodeGen::CodeGenModule &CGM,
124 llvm::PointerType *T,
125 QualType QT)
const override;
127class SPIRVTargetCodeGenInfo :
public CommonSPIRTargetCodeGenInfo {
129 SPIRVTargetCodeGenInfo(CodeGen::CodeGenTypes &CGT)
130 : CommonSPIRTargetCodeGenInfo(
131 (CGT.getTarget().
getTriple().getVendor() == llvm::Triple::AMD)
132 ? std::make_unique<AMDGCNSPIRVABIInfo>(CGT)
133 : std::make_unique<SPIRVABIInfo>(CGT)) {}
135 LangAS getGlobalVarAddressSpace(CodeGenModule &CGM,
136 const VarDecl *D)
const override;
137 void setTargetAttributes(
const Decl *D, llvm::GlobalValue *GV,
138 CodeGen::CodeGenModule &M)
const override;
139 StringRef getLLVMSyncScopeStr(
const LangOptions &LangOpts,
SyncScope Scope,
140 llvm::AtomicOrdering Ordering)
const override;
141 void setTargetAtomicMetadata(CodeGenFunction &CGF,
142 llvm::Instruction &AtomicInst,
143 const AtomicExpr *Expr =
nullptr)
const override;
144 bool supportsLibCall()
const override {
145 return getABIInfo().getTarget().getTriple().getVendor() !=
149 LangAS getSRetAddrSpace(
const CXXRecordDecl *RD)
const override;
153void CommonSPIRABIInfo::setCCs() {
154 assert(getRuntimeCC() == llvm::CallingConv::C);
155 RuntimeCC = llvm::CallingConv::SPIR_FUNC;
158ABIArgInfo SPIRVABIInfo::classifyKernelArgumentType(QualType Ty)
const {
163 llvm::Type *LTy = CGT.ConvertType(Ty);
164 auto DefaultAS = getContext().getTargetAddressSpace(LangAS::Default);
165 auto GlobalAS = getContext().getTargetAddressSpace(LangAS::opencl_global);
166 auto *PtrTy = llvm::dyn_cast<llvm::PointerType>(LTy);
167 if (PtrTy && PtrTy->getAddressSpace() == DefaultAS) {
168 LTy = llvm::PointerType::get(PtrTy->getContext(), GlobalAS);
172 if (getContext().getLangOpts().isTargetDevice() &&
182 return getNaturalAlignIndirect(Ty, 0,
true);
187void SPIRVABIInfo::computeInfo(CGFunctionInfo &FI)
const {
192 for (
auto &&[ArgumentsCount, I] : llvm::enumerate(FI.
arguments()))
195 : ABIArgInfo::getDirect();
201 if (CC == llvm::CallingConv::SPIR_KERNEL) {
202 I.info = classifyKernelArgumentType(I.type);
204 I.info = classifyArgumentType(I.type);
209RValue SPIRVABIInfo::EmitVAArg(CodeGenFunction &CGF, Address VAListAddr,
210 QualType Ty, AggValueSlot Slot)
const {
212 getContext().getTypeInfoInChars(Ty),
217uint64_t AMDGCNSPIRVABIInfo::numRegsForType(QualType Ty)
const {
221 if (
const VectorType *VT = Ty->
getAs<VectorType>()) {
224 QualType EltTy = VT->getElementType();
225 uint64_t EltSize = getContext().getTypeSize(EltTy);
229 return (VT->getNumElements() + 1) / 2;
231 uint64_t EltNumRegs = (EltSize + 31) / 32;
232 return EltNumRegs * VT->getNumElements();
236 assert(!RD->hasFlexibleArrayMember());
238 for (
const FieldDecl *Field : RD->fields()) {
239 QualType FieldTy =
Field->getType();
240 NumRegs += numRegsForType(FieldTy);
246 return (getContext().getTypeSize(Ty) + 31) / 32;
249llvm::Type *AMDGCNSPIRVABIInfo::coerceKernelArgumentType(llvm::Type *Ty,
251 unsigned ToAS)
const {
253 auto *PtrTy = llvm::dyn_cast<llvm::PointerType>(Ty);
254 if (PtrTy && PtrTy->getAddressSpace() == FromAS)
255 return llvm::PointerType::get(Ty->getContext(), ToAS);
259ABIArgInfo AMDGCNSPIRVABIInfo::classifyReturnType(QualType RetTy)
const {
286 llvm::Type *I32Ty = llvm::Type::getInt32Ty(getVMContext());
290 if (numRegsForType(RetTy) <= MaxNumRegsForArgsRet)
297ABIArgInfo AMDGCNSPIRVABIInfo::classifyKernelArgumentType(QualType Ty)
const {
303 Ty = QualType(SeltTy, 0);
305 llvm::Type *OrigLTy = CGT.ConvertType(Ty);
306 llvm::Type *LTy = OrigLTy;
307 if (getContext().getLangOpts().isTargetDevice()) {
308 LTy = coerceKernelArgumentType(
309 OrigLTy, getContext().getTargetAddressSpace(LangAS::Default),
310 getContext().getTargetAddressSpace(LangAS::opencl_global));
318 getContext().getTypeAlignInChars(Ty),
319 getContext().getTargetAddressSpace(LangAS::opencl_constant),
328ABIArgInfo AMDGCNSPIRVABIInfo::classifyArgumentType(QualType Ty)
const {
329 assert(NumRegsLeft <= MaxNumRegsForArgsRet &&
"register estimate underflow");
338 uint64_t NumRegs = numRegsForType(Ty);
339 NumRegsLeft -= std::min(NumRegs, uint64_t{NumRegsLeft});
348 return getNaturalAlignIndirect(Ty, getDataLayout().getAllocaAddrSpace(),
368 unsigned NumRegs = (
Size + 31) / 32;
369 NumRegsLeft -= std::min(NumRegsLeft, NumRegs);
379 llvm::Type *I32Ty = llvm::Type::getInt32Ty(getVMContext());
383 if (NumRegsLeft > 0) {
384 uint64_t NumRegs = numRegsForType(Ty);
385 if (NumRegsLeft >= NumRegs) {
386 NumRegsLeft -= NumRegs;
394 getContext().getTypeAlignInChars(Ty),
395 getContext().getTargetAddressSpace(LangAS::opencl_private));
398void AMDGCNSPIRVABIInfo::computeInfo(CGFunctionInfo &FI)
const {
404 NumRegsLeft = MaxNumRegsForArgsRet;
406 if (CC == llvm::CallingConv::SPIR_KERNEL)
407 I.info = classifyKernelArgumentType(I.type);
413llvm::FixedVectorType *
414SPIRVABIInfo::getOptimalVectorMemoryType(llvm::FixedVectorType *Ty,
415 const LangOptions &LangOpt)
const {
419 if (getTarget().
getTriple().isSPIRVLogical())
421 return DefaultABIInfo::getOptimalVectorMemoryType(Ty, LangOpt);
424llvm::FixedVectorType *AMDGCNSPIRVABIInfo::getOptimalVectorMemoryType(
425 llvm::FixedVectorType *Ty,
const LangOptions &LangOpt)
const {
427 if (Ty->getNumElements() == 3 && getDataLayout().getTypeSizeInBits(Ty) == 96)
429 return DefaultABIInfo::getOptimalVectorMemoryType(Ty, LangOpt);
437 AMDGCNSPIRVABIInfo(CGM.
getTypes()).computeInfo(FI);
439 SPIRVABIInfo(CGM.
getTypes()).computeInfo(FI);
441 CommonSPIRABIInfo(CGM.
getTypes()).computeInfo(FI);
447unsigned CommonSPIRTargetCodeGenInfo::getDeviceKernelCallingConv()
const {
448 return llvm::CallingConv::SPIR_KERNEL;
451LangAS SPIRVTargetCodeGenInfo::getSRetAddrSpace(
const CXXRecordDecl *RD)
const {
455 return LangAS::Default;
456 return getASTAllocaAddressSpace();
459void SPIRVTargetCodeGenInfo::setCUDAKernelCallingConvention(
460 const FunctionType *&FT)
const {
462 if (getABIInfo().getContext().getLangOpts().
HIP) {
463 FT = getABIInfo().getContext().adjustFunctionType(
469void CommonSPIRTargetCodeGenInfo::setOCLKernelStubCallingConvention(
470 const FunctionType *&FT)
const {
471 FT = getABIInfo().getContext().adjustFunctionType(
482CommonSPIRTargetCodeGenInfo::getNullPointer(
const CodeGen::CodeGenModule &CGM,
483 llvm::PointerType *PT,
488 unsigned ASAsInt =
static_cast<unsigned>(AS);
489 unsigned FirstTargetASAsInt =
490 static_cast<unsigned>(LangAS::FirstTargetAddressSpace);
491 unsigned CodeSectionINTELAS = FirstTargetASAsInt + 9;
494 bool IsFunctionPtrAS =
495 CGM.
getTriple().isSPIRV() && ASAsInt == CodeSectionINTELAS;
496 if (AS == LangAS::Default || AS == LangAS::opencl_generic ||
497 AS == LangAS::opencl_constant || IsFunctionPtrAS)
498 return llvm::ConstantPointerNull::get(PT);
501 auto NPT = llvm::PointerType::get(
502 PT->getContext(), Ctx.getTargetAddressSpace(LangAS::opencl_generic));
503 return llvm::ConstantExpr::getAddrSpaceCast(
504 llvm::ConstantPointerNull::get(NPT), PT);
508SPIRVTargetCodeGenInfo::getGlobalVarAddressSpace(CodeGenModule &CGM,
509 const VarDecl *D)
const {
512 "Address space agnostic languages only");
520 return DefaultGlobalAS;
523 if (AddrSpace != LangAS::Default)
526 return DefaultGlobalAS;
529void SPIRVTargetCodeGenInfo::setTargetAttributes(
530 const Decl *D, llvm::GlobalValue *GV, CodeGen::CodeGenModule &M)
const {
531 if (GV->isDeclaration())
534 const FunctionDecl *FD = dyn_cast_or_null<FunctionDecl>(D);
538 llvm::Function *F = dyn_cast<llvm::Function>(GV);
539 assert(F &&
"Expected GlobalValue to be a Function");
545 if (!FD->
hasAttr<CUDAGlobalAttr>())
548 unsigned N = M.
getLangOpts().GPUMaxThreadsPerBlock;
549 if (
auto FlatWGS = FD->
getAttr<AMDGPUFlatWorkGroupSizeAttr>())
550 N = FlatWGS->getMax()->EvaluateKnownConstInt(M.
getContext()).getExtValue();
556 llvm::Metadata *AttrMDArgs[] = {
557 llvm::ConstantAsMetadata::get(llvm::ConstantInt::get(Int32Ty, N)),
558 llvm::ConstantAsMetadata::get(llvm::ConstantInt::get(Int32Ty, 1)),
559 llvm::ConstantAsMetadata::get(llvm::ConstantInt::get(Int32Ty, 1))};
561 F->setMetadata(
"max_work_group_size",
565StringRef SPIRVTargetCodeGenInfo::getLLVMSyncScopeStr(
566 const LangOptions &,
SyncScope Scope, llvm::AtomicOrdering)
const {
568 case SyncScope::HIPSingleThread:
569 case SyncScope::SingleScope:
570 return "singlethread";
571 case SyncScope::HIPWavefront:
572 case SyncScope::OpenCLSubGroup:
573 case SyncScope::WavefrontScope:
575 case SyncScope::HIPCluster:
576 case SyncScope::ClusterScope:
577 case SyncScope::HIPWorkgroup:
578 case SyncScope::OpenCLWorkGroup:
579 case SyncScope::WorkgroupScope:
581 case SyncScope::HIPAgent:
582 case SyncScope::OpenCLDevice:
583 case SyncScope::DeviceScope:
585 case SyncScope::SystemScope:
586 case SyncScope::HIPSystem:
587 case SyncScope::OpenCLAllSVMDevices:
593void SPIRVTargetCodeGenInfo::setTargetAtomicMetadata(
594 CodeGenFunction &CGF, llvm::Instruction &AtomicInst,
595 const AtomicExpr *AE)
const {
596 if (CGF.
CGM.
getTriple().getVendor() != llvm::Triple::VendorType::AMD)
599 auto *RMW = dyn_cast<llvm::AtomicRMWInst>(&AtomicInst);
606 RMW->setMetadata(
"amdgpu.no.fine.grained.memory",
Empty);
608 RMW->setMetadata(
"amdgpu.no.remote.memory",
Empty);
610 RMW->getOperation() == llvm::AtomicRMWInst::FAdd &&
611 RMW->getType()->isFloatTy())
612 RMW->setMetadata(
"amdgpu.ignore.denormal.mode",
Empty);
617 StringRef OpenCLName,
618 unsigned AccessQualifier) {
629 if (OpenCLName.starts_with(
"image2d"))
631 else if (OpenCLName.starts_with(
"image3d"))
633 else if (OpenCLName ==
"image1d_buffer")
636 assert(OpenCLName.starts_with(
"image1d") &&
"Unknown image type");
641 if (OpenCLName.contains(
"_depth"))
643 if (OpenCLName.contains(
"_array"))
645 if (OpenCLName.contains(
"_msaa"))
649 IntParams.push_back(AccessQualifier);
651 return llvm::TargetExtType::get(Ctx, BaseType, {llvm::Type::getVoidTy(Ctx)},
655llvm::Type *CommonSPIRTargetCodeGenInfo::getOpenCLType(CodeGenModule &CGM,
656 const Type *Ty)
const {
658 if (
auto *PipeTy = dyn_cast<PipeType>(Ty))
659 return llvm::TargetExtType::get(Ctx,
"spirv.Pipe", {},
660 {!PipeTy->isReadOnly()});
661 if (
auto *BuiltinTy = dyn_cast<BuiltinType>(Ty)) {
662 enum AccessQualifier :
unsigned { AQ_ro = 0, AQ_wo = 1, AQ_rw = 2 };
663 switch (BuiltinTy->getKind()) {
664#define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \
665 case BuiltinType::Id: \
666 return getSPIRVImageType(Ctx, "spirv.Image", #ImgType, AQ_##Suffix);
667#include "clang/Basic/OpenCLImageTypes.def"
668 case BuiltinType::OCLSampler:
669 return llvm::TargetExtType::get(Ctx,
"spirv.Sampler");
670 case BuiltinType::OCLEvent:
671 return llvm::TargetExtType::get(Ctx,
"spirv.Event");
672 case BuiltinType::OCLClkEvent:
673 return llvm::TargetExtType::get(Ctx,
"spirv.DeviceEvent");
674 case BuiltinType::OCLQueue:
675 return llvm::TargetExtType::get(Ctx,
"spirv.Queue");
676 case BuiltinType::OCLReserveID:
677 return llvm::TargetExtType::get(Ctx,
"spirv.ReserveId");
678#define INTEL_SUBGROUP_AVC_TYPE(Name, Id) \
679 case BuiltinType::OCLIntelSubgroupAVC##Id: \
680 return llvm::TargetExtType::get(Ctx, "spirv.Avc" #Id "INTEL");
681#include "clang/Basic/OpenCLExtensionTypes.def"
693 llvm::Type *IntegralType,
700 while (
Value.ugt(0)) {
701 uint32_t Word =
Value.trunc(32).getZExtValue();
702 Value.lshrInPlace(32);
704 Words.push_back(Word);
706 if (Words.size() == 0)
710 return llvm::TargetExtType::get(Ctx,
"spirv.IntegralConstant",
711 {IntegralType}, Words);
712 return llvm::TargetExtType::get(Ctx,
"spirv.Literal", {}, Words);
716 const HLSLInlineSpirvType *SpirvType) {
721 for (
auto &Operand : SpirvType->getOperands()) {
722 using SpirvOperandKind = SpirvOperand::SpirvOperandKind;
724 llvm::Type *
Result =
nullptr;
725 switch (Operand.getKind()) {
726 case SpirvOperandKind::ConstantId: {
727 llvm::Type *IntegralType =
733 case SpirvOperandKind::Literal: {
737 case SpirvOperandKind::TypeId: {
738 QualType TypeOperand = Operand.getResultType();
741 "Type completion should have been required in Sema");
746 if (ResourceType->
getAs<HLSLAttributedResourceType>()) {
747 TypeOperand = ResourceType;
755 llvm_unreachable(
"HLSLInlineSpirvType had invalid operand!");
760 Operands.push_back(
Result);
763 return llvm::TargetExtType::get(Ctx,
"spirv.Type", Operands,
764 {SpirvType->getOpcode(), SpirvType->getSize(),
765 SpirvType->getAlignment()});
768llvm::Type *CommonSPIRTargetCodeGenInfo::getHLSLType(
769 CodeGenModule &CGM,
const Type *Ty,
770 const CGHLSLOffsetInfo &OffsetInfo)
const {
773 if (
auto *SpirvType = dyn_cast<HLSLInlineSpirvType>(Ty))
776 auto *ResType = dyn_cast<HLSLAttributedResourceType>(Ty);
780 const HLSLAttributedResourceType::Attributes &ResAttrs = ResType->getAttrs();
781 switch (ResAttrs.ResourceClass) {
782 case llvm::dxil::ResourceClass::UAV:
783 case llvm::dxil::ResourceClass::SRV: {
785 QualType ContainedTy = ResType->getContainedType();
789 assert(!ResAttrs.IsROV &&
790 "Rasterizer order views not implemented for SPIR-V yet");
792 if (!ResAttrs.RawBuffer) {
794 return getSPIRVImageTypeFromHLSLResource(ResAttrs, ContainedTy, CGM);
797 if (ResAttrs.IsCounter) {
798 llvm::Type *ElemType = llvm::Type::getInt32Ty(Ctx);
800 return llvm::TargetExtType::get(Ctx,
"spirv.VulkanBuffer", {ElemType},
804 llvm::ArrayType *RuntimeArrayType = llvm::ArrayType::get(ElemType, 0);
806 bool IsWritable = ResAttrs.ResourceClass == llvm::dxil::ResourceClass::UAV;
807 return llvm::TargetExtType::get(Ctx,
"spirv.VulkanBuffer",
811 case llvm::dxil::ResourceClass::CBuffer: {
812 QualType ContainedTy = ResType->getContainedType();
816 llvm::StructType *BufferLayoutTy =
817 HLSLBufferLayoutBuilder(CGM).layOutStruct(
820 return llvm::TargetExtType::get(Ctx,
"spirv.VulkanBuffer", {BufferLayoutTy},
824 case llvm::dxil::ResourceClass::Sampler:
825 return llvm::TargetExtType::get(Ctx,
"spirv.Sampler");
832 const HLSLAttributedResourceType::Attributes &attributes,
833 llvm::Type *SampledType,
QualType Ty,
unsigned NumChannels) {
838 if (LangOpts.HLSLSpvUseUnknownImageFormat ||
839 attributes.ResourceClass != llvm::dxil::ResourceClass::UAV) {
843 if (SampledType->isIntegerTy(32)) {
845 if (NumChannels == 1)
847 if (NumChannels == 2)
849 if (NumChannels == 4)
852 if (NumChannels == 1)
854 if (NumChannels == 2)
856 if (NumChannels == 4)
859 }
else if (SampledType->isIntegerTy(64)) {
860 if (NumChannels == 1) {
866 }
else if (SampledType->isFloatTy()) {
867 if (NumChannels == 1)
869 if (NumChannels == 2)
871 if (NumChannels == 4)
878llvm::Type *CommonSPIRTargetCodeGenInfo::getSPIRVImageTypeFromHLSLResource(
879 const HLSLAttributedResourceType::Attributes &attributes, QualType Ty,
880 CodeGenModule &CGM)
const {
883 unsigned NumChannels = 1;
885 if (
const VectorType *
V = dyn_cast<VectorType>(Ty)) {
886 NumChannels =
V->getNumElements();
887 Ty =
V->getElementType();
889 assert(!Ty->
isVectorType() &&
"We still have a vector type.");
893 assert((SampledType->isIntegerTy() || SampledType->isFloatingPointTy()) &&
894 "The element type for a SPIR-V resource must be a scalar integer or "
895 "floating point type.");
900 SmallVector<unsigned, 6> IntParams(6, 0);
906 switch (attributes.ResourceDimension) {
907 case llvm::dxil::ResourceDimension::Dim1D:
910 case llvm::dxil::ResourceDimension::Dim2D:
913 case llvm::dxil::ResourceDimension::Dim3D:
916 case llvm::dxil::ResourceDimension::Cube:
919 case llvm::dxil::ResourceDimension::Unknown:
936 attributes.ResourceClass == llvm::dxil::ResourceClass::UAV ? 2 : 1;
942 llvm::TargetExtType *ImageType =
943 llvm::TargetExtType::get(Ctx, Name, {SampledType}, IntParams);
947std::unique_ptr<TargetCodeGenInfo>
949 return std::make_unique<CommonSPIRTargetCodeGenInfo>(CGM.
getTypes());
952std::unique_ptr<TargetCodeGenInfo>
954 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 C++ Decl subclasses, other than those for templates (found in DeclTemplate....
Result
Implement __builtin_bit_cast and related operations.
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
llvm::LLVMContext & getLLVMContext()
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
AtomicOptions getAtomicOpts()
Get the current Atomic options.
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 canPassInRegisters() const
Determine whether this class can be passed in registers.
bool hasFlexibleArrayMember() const
const FieldDecl * findFirstNamedDataMember() const
Finds the first data member which has a name.
bool isCompleteDefinition() const
Return true if this decl has its body fully specified.
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)
bool getOption(AtomicOptionKind Kind) const