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 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 void setTargetAtomicMetadata(CodeGenFunction &CGF,
137 llvm::Instruction &AtomicInst,
138 const AtomicExpr *Expr =
nullptr)
const override;
139 bool supportsLibCall()
const override {
140 return getABIInfo().getTarget().getTriple().getVendor() !=
144 LangAS getSRetAddrSpace(
const CXXRecordDecl *RD)
const override;
148void CommonSPIRABIInfo::setCCs() {
149 assert(getRuntimeCC() == llvm::CallingConv::C);
150 RuntimeCC = llvm::CallingConv::SPIR_FUNC;
153ABIArgInfo SPIRVABIInfo::classifyKernelArgumentType(QualType Ty)
const {
158 llvm::Type *LTy = CGT.ConvertType(Ty);
159 auto DefaultAS = getContext().getTargetAddressSpace(LangAS::Default);
160 auto GlobalAS = getContext().getTargetAddressSpace(LangAS::opencl_global);
161 auto *PtrTy = llvm::dyn_cast<llvm::PointerType>(LTy);
162 if (PtrTy && PtrTy->getAddressSpace() == DefaultAS) {
163 LTy = llvm::PointerType::get(PtrTy->getContext(), GlobalAS);
167 if (getContext().getLangOpts().isTargetDevice() &&
177 return getNaturalAlignIndirect(Ty, 0,
true);
182void SPIRVABIInfo::computeInfo(CGFunctionInfo &FI)
const {
187 for (
auto &&[ArgumentsCount, I] : llvm::enumerate(FI.
arguments()))
190 : ABIArgInfo::getDirect();
196 if (CC == llvm::CallingConv::SPIR_KERNEL) {
197 I.info = classifyKernelArgumentType(I.type);
199 I.info = classifyArgumentType(I.type);
204RValue SPIRVABIInfo::EmitVAArg(CodeGenFunction &CGF, Address VAListAddr,
205 QualType Ty, AggValueSlot Slot)
const {
207 getContext().getTypeInfoInChars(Ty),
212uint64_t AMDGCNSPIRVABIInfo::numRegsForType(QualType Ty)
const {
216 if (
const VectorType *VT = Ty->
getAs<VectorType>()) {
219 QualType EltTy = VT->getElementType();
220 uint64_t EltSize = getContext().getTypeSize(EltTy);
224 return (VT->getNumElements() + 1) / 2;
226 uint64_t EltNumRegs = (EltSize + 31) / 32;
227 return EltNumRegs * VT->getNumElements();
231 assert(!RD->hasFlexibleArrayMember());
233 for (
const FieldDecl *Field : RD->fields()) {
234 QualType FieldTy =
Field->getType();
235 NumRegs += numRegsForType(FieldTy);
241 return (getContext().getTypeSize(Ty) + 31) / 32;
244llvm::Type *AMDGCNSPIRVABIInfo::coerceKernelArgumentType(llvm::Type *Ty,
246 unsigned ToAS)
const {
248 auto *PtrTy = llvm::dyn_cast<llvm::PointerType>(Ty);
249 if (PtrTy && PtrTy->getAddressSpace() == FromAS)
250 return llvm::PointerType::get(Ty->getContext(), ToAS);
254ABIArgInfo AMDGCNSPIRVABIInfo::classifyReturnType(QualType RetTy)
const {
281 llvm::Type *I32Ty = llvm::Type::getInt32Ty(getVMContext());
285 if (numRegsForType(RetTy) <= MaxNumRegsForArgsRet)
292ABIArgInfo AMDGCNSPIRVABIInfo::classifyKernelArgumentType(QualType Ty)
const {
298 Ty = QualType(SeltTy, 0);
300 llvm::Type *OrigLTy = CGT.ConvertType(Ty);
301 llvm::Type *LTy = OrigLTy;
302 if (getContext().getLangOpts().isTargetDevice()) {
303 LTy = coerceKernelArgumentType(
304 OrigLTy, getContext().getTargetAddressSpace(LangAS::Default),
305 getContext().getTargetAddressSpace(LangAS::opencl_global));
313 getContext().getTypeAlignInChars(Ty),
314 getContext().getTargetAddressSpace(LangAS::opencl_constant),
323ABIArgInfo AMDGCNSPIRVABIInfo::classifyArgumentType(QualType Ty)
const {
324 assert(NumRegsLeft <= MaxNumRegsForArgsRet &&
"register estimate underflow");
333 uint64_t NumRegs = numRegsForType(Ty);
334 NumRegsLeft -= std::min(NumRegs, uint64_t{NumRegsLeft});
343 return getNaturalAlignIndirect(Ty, getDataLayout().getAllocaAddrSpace(),
363 unsigned NumRegs = (
Size + 31) / 32;
364 NumRegsLeft -= std::min(NumRegsLeft, NumRegs);
374 llvm::Type *I32Ty = llvm::Type::getInt32Ty(getVMContext());
378 if (NumRegsLeft > 0) {
379 uint64_t NumRegs = numRegsForType(Ty);
380 if (NumRegsLeft >= NumRegs) {
381 NumRegsLeft -= NumRegs;
389 getContext().getTypeAlignInChars(Ty),
390 getContext().getTargetAddressSpace(LangAS::opencl_private));
393void AMDGCNSPIRVABIInfo::computeInfo(CGFunctionInfo &FI)
const {
399 NumRegsLeft = MaxNumRegsForArgsRet;
401 if (CC == llvm::CallingConv::SPIR_KERNEL)
402 I.info = classifyKernelArgumentType(I.type);
408llvm::FixedVectorType *
409SPIRVABIInfo::getOptimalVectorMemoryType(llvm::FixedVectorType *Ty,
410 const LangOptions &LangOpt)
const {
414 if (getTarget().
getTriple().isSPIRVLogical())
416 return DefaultABIInfo::getOptimalVectorMemoryType(Ty, LangOpt);
419llvm::FixedVectorType *AMDGCNSPIRVABIInfo::getOptimalVectorMemoryType(
420 llvm::FixedVectorType *Ty,
const LangOptions &LangOpt)
const {
422 if (Ty->getNumElements() == 3 && getDataLayout().getTypeSizeInBits(Ty) == 96)
424 return DefaultABIInfo::getOptimalVectorMemoryType(Ty, LangOpt);
432 AMDGCNSPIRVABIInfo(CGM.
getTypes()).computeInfo(FI);
434 SPIRVABIInfo(CGM.
getTypes()).computeInfo(FI);
436 CommonSPIRABIInfo(CGM.
getTypes()).computeInfo(FI);
442unsigned CommonSPIRTargetCodeGenInfo::getDeviceKernelCallingConv()
const {
443 return llvm::CallingConv::SPIR_KERNEL;
446LangAS SPIRVTargetCodeGenInfo::getSRetAddrSpace(
const CXXRecordDecl *RD)
const {
450 return LangAS::Default;
452 getABIInfo().getDataLayout().getAllocaAddrSpace());
455void SPIRVTargetCodeGenInfo::setCUDAKernelCallingConvention(
456 const FunctionType *&FT)
const {
458 if (getABIInfo().getContext().getLangOpts().
HIP) {
459 FT = getABIInfo().getContext().adjustFunctionType(
465void CommonSPIRTargetCodeGenInfo::setOCLKernelStubCallingConvention(
466 const FunctionType *&FT)
const {
467 FT = getABIInfo().getContext().adjustFunctionType(
478CommonSPIRTargetCodeGenInfo::getNullPointer(
const CodeGen::CodeGenModule &CGM,
479 llvm::PointerType *PT,
484 unsigned ASAsInt =
static_cast<unsigned>(AS);
485 unsigned FirstTargetASAsInt =
486 static_cast<unsigned>(LangAS::FirstTargetAddressSpace);
487 unsigned CodeSectionINTELAS = FirstTargetASAsInt + 9;
490 bool IsFunctionPtrAS =
491 CGM.
getTriple().isSPIRV() && ASAsInt == CodeSectionINTELAS;
492 if (AS == LangAS::Default || AS == LangAS::opencl_generic ||
493 AS == LangAS::opencl_constant || IsFunctionPtrAS)
494 return llvm::ConstantPointerNull::get(PT);
497 auto NPT = llvm::PointerType::get(
498 PT->getContext(), Ctx.getTargetAddressSpace(LangAS::opencl_generic));
499 return llvm::ConstantExpr::getAddrSpaceCast(
500 llvm::ConstantPointerNull::get(NPT), PT);
504SPIRVTargetCodeGenInfo::getGlobalVarAddressSpace(CodeGenModule &CGM,
505 const VarDecl *D)
const {
508 "Address space agnostic languages only");
516 return DefaultGlobalAS;
519 if (AddrSpace != LangAS::Default)
522 return DefaultGlobalAS;
525void SPIRVTargetCodeGenInfo::setTargetAttributes(
526 const Decl *D, llvm::GlobalValue *GV, CodeGen::CodeGenModule &M)
const {
527 if (GV->isDeclaration())
530 const FunctionDecl *FD = dyn_cast_or_null<FunctionDecl>(D);
534 llvm::Function *F = dyn_cast<llvm::Function>(GV);
535 assert(F &&
"Expected GlobalValue to be a Function");
541 if (!FD->
hasAttr<CUDAGlobalAttr>())
544 unsigned N = M.
getLangOpts().GPUMaxThreadsPerBlock;
545 if (
auto FlatWGS = FD->
getAttr<AMDGPUFlatWorkGroupSizeAttr>())
546 N = FlatWGS->getMax()->EvaluateKnownConstInt(M.
getContext()).getExtValue();
552 llvm::Metadata *AttrMDArgs[] = {
553 llvm::ConstantAsMetadata::get(llvm::ConstantInt::get(Int32Ty, N)),
554 llvm::ConstantAsMetadata::get(llvm::ConstantInt::get(Int32Ty, 1)),
555 llvm::ConstantAsMetadata::get(llvm::ConstantInt::get(Int32Ty, 1))};
557 F->setMetadata(
"max_work_group_size",
561StringRef SPIRVTargetCodeGenInfo::getLLVMSyncScopeStr(
562 const LangOptions &,
SyncScope Scope, llvm::AtomicOrdering)
const {
564 case SyncScope::HIPSingleThread:
565 case SyncScope::SingleScope:
566 return "singlethread";
567 case SyncScope::HIPWavefront:
568 case SyncScope::OpenCLSubGroup:
569 case SyncScope::WavefrontScope:
571 case SyncScope::HIPCluster:
572 case SyncScope::ClusterScope:
573 case SyncScope::HIPWorkgroup:
574 case SyncScope::OpenCLWorkGroup:
575 case SyncScope::WorkgroupScope:
577 case SyncScope::HIPAgent:
578 case SyncScope::OpenCLDevice:
579 case SyncScope::DeviceScope:
581 case SyncScope::SystemScope:
582 case SyncScope::HIPSystem:
583 case SyncScope::OpenCLAllSVMDevices:
589void SPIRVTargetCodeGenInfo::setTargetAtomicMetadata(
590 CodeGenFunction &CGF, llvm::Instruction &AtomicInst,
591 const AtomicExpr *AE)
const {
592 if (CGF.
CGM.
getTriple().getVendor() != llvm::Triple::VendorType::AMD)
595 auto *RMW = dyn_cast<llvm::AtomicRMWInst>(&AtomicInst);
602 RMW->setMetadata(
"amdgpu.no.fine.grained.memory",
Empty);
604 RMW->setMetadata(
"amdgpu.no.remote.memory",
Empty);
606 RMW->getOperation() == llvm::AtomicRMWInst::FAdd &&
607 RMW->getType()->isFloatTy())
608 RMW->setMetadata(
"amdgpu.ignore.denormal.mode",
Empty);
613 StringRef OpenCLName,
614 unsigned AccessQualifier) {
625 if (OpenCLName.starts_with(
"image2d"))
627 else if (OpenCLName.starts_with(
"image3d"))
629 else if (OpenCLName ==
"image1d_buffer")
632 assert(OpenCLName.starts_with(
"image1d") &&
"Unknown image type");
637 if (OpenCLName.contains(
"_depth"))
639 if (OpenCLName.contains(
"_array"))
641 if (OpenCLName.contains(
"_msaa"))
645 IntParams.push_back(AccessQualifier);
647 return llvm::TargetExtType::get(Ctx, BaseType, {llvm::Type::getVoidTy(Ctx)},
651llvm::Type *CommonSPIRTargetCodeGenInfo::getOpenCLType(CodeGenModule &CGM,
652 const Type *Ty)
const {
654 if (
auto *PipeTy = dyn_cast<PipeType>(Ty))
655 return llvm::TargetExtType::get(Ctx,
"spirv.Pipe", {},
656 {!PipeTy->isReadOnly()});
657 if (
auto *BuiltinTy = dyn_cast<BuiltinType>(Ty)) {
658 enum AccessQualifier :
unsigned { AQ_ro = 0, AQ_wo = 1, AQ_rw = 2 };
659 switch (BuiltinTy->getKind()) {
660#define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \
661 case BuiltinType::Id: \
662 return getSPIRVImageType(Ctx, "spirv.Image", #ImgType, AQ_##Suffix);
663#include "clang/Basic/OpenCLImageTypes.def"
664 case BuiltinType::OCLSampler:
665 return llvm::TargetExtType::get(Ctx,
"spirv.Sampler");
666 case BuiltinType::OCLEvent:
667 return llvm::TargetExtType::get(Ctx,
"spirv.Event");
668 case BuiltinType::OCLClkEvent:
669 return llvm::TargetExtType::get(Ctx,
"spirv.DeviceEvent");
670 case BuiltinType::OCLQueue:
671 return llvm::TargetExtType::get(Ctx,
"spirv.Queue");
672 case BuiltinType::OCLReserveID:
673 return llvm::TargetExtType::get(Ctx,
"spirv.ReserveId");
674#define INTEL_SUBGROUP_AVC_TYPE(Name, Id) \
675 case BuiltinType::OCLIntelSubgroupAVC##Id: \
676 return llvm::TargetExtType::get(Ctx, "spirv.Avc" #Id "INTEL");
677#include "clang/Basic/OpenCLExtensionTypes.def"
689 llvm::Type *IntegralType,
696 while (
Value.ugt(0)) {
697 uint32_t Word =
Value.trunc(32).getZExtValue();
698 Value.lshrInPlace(32);
700 Words.push_back(Word);
702 if (Words.size() == 0)
706 return llvm::TargetExtType::get(Ctx,
"spirv.IntegralConstant",
707 {IntegralType}, Words);
708 return llvm::TargetExtType::get(Ctx,
"spirv.Literal", {}, Words);
712 const HLSLInlineSpirvType *SpirvType) {
717 for (
auto &Operand : SpirvType->getOperands()) {
718 using SpirvOperandKind = SpirvOperand::SpirvOperandKind;
720 llvm::Type *
Result =
nullptr;
721 switch (Operand.getKind()) {
722 case SpirvOperandKind::ConstantId: {
723 llvm::Type *IntegralType =
729 case SpirvOperandKind::Literal: {
733 case SpirvOperandKind::TypeId: {
734 QualType TypeOperand = Operand.getResultType();
737 "Type completion should have been required in Sema");
742 if (ResourceType->
getAs<HLSLAttributedResourceType>()) {
743 TypeOperand = ResourceType;
751 llvm_unreachable(
"HLSLInlineSpirvType had invalid operand!");
756 Operands.push_back(
Result);
759 return llvm::TargetExtType::get(Ctx,
"spirv.Type", Operands,
760 {SpirvType->getOpcode(), SpirvType->getSize(),
761 SpirvType->getAlignment()});
764llvm::Type *CommonSPIRTargetCodeGenInfo::getHLSLType(
765 CodeGenModule &CGM,
const Type *Ty,
766 const CGHLSLOffsetInfo &OffsetInfo)
const {
769 if (
auto *SpirvType = dyn_cast<HLSLInlineSpirvType>(Ty))
772 auto *ResType = dyn_cast<HLSLAttributedResourceType>(Ty);
776 const HLSLAttributedResourceType::Attributes &ResAttrs = ResType->getAttrs();
777 switch (ResAttrs.ResourceClass) {
778 case llvm::dxil::ResourceClass::UAV:
779 case llvm::dxil::ResourceClass::SRV: {
781 QualType ContainedTy = ResType->getContainedType();
785 assert(!ResAttrs.IsROV &&
786 "Rasterizer order views not implemented for SPIR-V yet");
788 if (!ResAttrs.RawBuffer) {
790 return getSPIRVImageTypeFromHLSLResource(ResAttrs, ContainedTy, CGM);
793 if (ResAttrs.IsCounter) {
794 llvm::Type *ElemType = llvm::Type::getInt32Ty(Ctx);
796 return llvm::TargetExtType::get(Ctx,
"spirv.VulkanBuffer", {ElemType},
800 llvm::ArrayType *RuntimeArrayType = llvm::ArrayType::get(ElemType, 0);
802 bool IsWritable = ResAttrs.ResourceClass == llvm::dxil::ResourceClass::UAV;
803 return llvm::TargetExtType::get(Ctx,
"spirv.VulkanBuffer",
807 case llvm::dxil::ResourceClass::CBuffer: {
808 QualType ContainedTy = ResType->getContainedType();
812 llvm::StructType *BufferLayoutTy =
813 HLSLBufferLayoutBuilder(CGM).layOutStruct(
816 return llvm::TargetExtType::get(Ctx,
"spirv.VulkanBuffer", {BufferLayoutTy},
820 case llvm::dxil::ResourceClass::Sampler:
821 return llvm::TargetExtType::get(Ctx,
"spirv.Sampler");
828 const HLSLAttributedResourceType::Attributes &attributes,
829 llvm::Type *SampledType,
QualType Ty,
unsigned NumChannels) {
834 if (LangOpts.HLSLSpvUseUnknownImageFormat ||
835 attributes.ResourceClass != llvm::dxil::ResourceClass::UAV) {
839 if (SampledType->isIntegerTy(32)) {
841 if (NumChannels == 1)
843 if (NumChannels == 2)
845 if (NumChannels == 4)
848 if (NumChannels == 1)
850 if (NumChannels == 2)
852 if (NumChannels == 4)
855 }
else if (SampledType->isIntegerTy(64)) {
856 if (NumChannels == 1) {
862 }
else if (SampledType->isFloatTy()) {
863 if (NumChannels == 1)
865 if (NumChannels == 2)
867 if (NumChannels == 4)
874llvm::Type *CommonSPIRTargetCodeGenInfo::getSPIRVImageTypeFromHLSLResource(
875 const HLSLAttributedResourceType::Attributes &attributes, QualType Ty,
876 CodeGenModule &CGM)
const {
879 unsigned NumChannels = 1;
881 if (
const VectorType *
V = dyn_cast<VectorType>(Ty)) {
882 NumChannels =
V->getNumElements();
883 Ty =
V->getElementType();
885 assert(!Ty->
isVectorType() &&
"We still have a vector type.");
889 assert((SampledType->isIntegerTy() || SampledType->isFloatingPointTy()) &&
890 "The element type for a SPIR-V resource must be a scalar integer or "
891 "floating point type.");
896 SmallVector<unsigned, 6> IntParams(6, 0);
902 switch (attributes.ResourceDimension) {
903 case llvm::dxil::ResourceDimension::Dim1D:
906 case llvm::dxil::ResourceDimension::Dim2D:
909 case llvm::dxil::ResourceDimension::Dim3D:
912 case llvm::dxil::ResourceDimension::Cube:
915 case llvm::dxil::ResourceDimension::Unknown:
932 attributes.ResourceClass == llvm::dxil::ResourceClass::UAV ? 2 : 1;
938 llvm::TargetExtType *ImageType =
939 llvm::TargetExtType::get(Ctx, Name, {SampledType}, IntParams);
943std::unique_ptr<TargetCodeGenInfo>
945 return std::make_unique<CommonSPIRTargetCodeGenInfo>(CGM.
getTypes());
948std::unique_ptr<TargetCodeGenInfo>
950 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