11#include "TargetInfo.h"
14#include "llvm/IR/DerivedTypes.h"
15#include "llvm/IR/LLVMContext.h"
31 CommonSPIRABIInfo(CodeGenTypes &CGT) : DefaultABIInfo(CGT) { setCCs(); }
37class SPIRVABIInfo :
public CommonSPIRABIInfo {
39 SPIRVABIInfo(CodeGenTypes &CGT) : CommonSPIRABIInfo(CGT) {}
40 void computeInfo(CGFunctionInfo &FI)
const override;
41 RValue EmitVAArg(CodeGenFunction &CGF, Address VAListAddr, QualType Ty,
42 AggValueSlot Slot)
const override;
44 llvm::FixedVectorType *
45 getOptimalVectorMemoryType(llvm::FixedVectorType *Ty,
46 const LangOptions &LangOpt)
const override;
49 ABIArgInfo classifyKernelArgumentType(QualType Ty)
const;
52class AMDGCNSPIRVABIInfo :
public SPIRVABIInfo {
55 static constexpr unsigned MaxNumRegsForArgsRet = 16;
56 mutable unsigned NumRegsLeft = 0;
58 uint64_t numRegsForType(QualType Ty)
const;
60 bool isHomogeneousAggregateBaseType(QualType Ty)
const override {
63 bool isHomogeneousAggregateSmallEnough(
const Type *Base,
64 uint64_t Members)
const override {
65 uint32_t NumRegs = (getContext().getTypeSize(Base) + 31) / 32;
68 return Members * NumRegs <= MaxNumRegsForArgsRet;
72 llvm::Type *coerceKernelArgumentType(llvm::Type *Ty,
unsigned FromAS,
76 ABIArgInfo classifyKernelArgumentType(QualType Ty)
const;
80 AMDGCNSPIRVABIInfo(CodeGenTypes &CGT) : SPIRVABIInfo(CGT) {}
81 void computeInfo(CGFunctionInfo &FI)
const override;
83 llvm::FixedVectorType *
84 getOptimalVectorMemoryType(llvm::FixedVectorType *Ty,
85 const LangOptions &LangOpt)
const override;
91 CommonSPIRTargetCodeGenInfo(CodeGen::CodeGenTypes &CGT)
92 : TargetCodeGenInfo(std::make_unique<CommonSPIRABIInfo>(CGT)) {}
93 CommonSPIRTargetCodeGenInfo(std::unique_ptr<ABIInfo> ABIInfo)
94 : TargetCodeGenInfo(std::move(ABIInfo)) {}
96 unsigned getDeviceKernelCallingConv()
const override;
97 llvm::Type *getOpenCLType(CodeGenModule &CGM,
const Type *
T)
const override;
98 llvm::Type *getHLSLType(CodeGenModule &CGM,
const Type *Ty,
99 const CGHLSLOffsetInfo &OffsetInfo)
const override;
101 llvm::Type *getHLSLPadding(CodeGenModule &CGM,
102 CharUnits NumBytes)
const override {
104 return llvm::TargetExtType::get(CGM.
getLLVMContext(),
"spirv.Padding", {},
108 bool isHLSLPadding(llvm::Type *Ty)
const override {
109 if (
auto *TET = dyn_cast<llvm::TargetExtType>(Ty))
110 return TET->getName() ==
"spirv.Padding";
114 llvm::Type *getSPIRVImageTypeFromHLSLResource(
115 const HLSLAttributedResourceType::Attributes &attributes,
116 QualType SampledType, CodeGenModule &CGM)
const;
118 setOCLKernelStubCallingConvention(
const FunctionType *&FT)
const override;
119 llvm::Constant *getNullPointer(
const CodeGen::CodeGenModule &CGM,
120 llvm::PointerType *
T,
121 QualType QT)
const override;
123class SPIRVTargetCodeGenInfo :
public CommonSPIRTargetCodeGenInfo {
125 SPIRVTargetCodeGenInfo(CodeGen::CodeGenTypes &CGT)
126 : CommonSPIRTargetCodeGenInfo(
127 (CGT.getTarget().
getTriple().getVendor() == llvm::Triple::AMD)
128 ? std::make_unique<AMDGCNSPIRVABIInfo>(CGT)
129 : std::make_unique<SPIRVABIInfo>(CGT)) {}
131 LangAS getGlobalVarAddressSpace(CodeGenModule &CGM,
132 const VarDecl *D)
const override;
133 void setTargetAttributes(
const Decl *D, llvm::GlobalValue *GV,
134 CodeGen::CodeGenModule &M)
const override;
135 StringRef getLLVMSyncScopeStr(
const LangOptions &LangOpts,
SyncScope Scope,
136 llvm::AtomicOrdering Ordering)
const override;
137 void setTargetAtomicMetadata(CodeGenFunction &CGF,
138 llvm::Instruction &AtomicInst,
139 const AtomicExpr *Expr =
nullptr)
const override;
140 bool supportsLibCall()
const override {
141 return getABIInfo().getTarget().getTriple().getVendor() !=
145 LangAS getSRetAddrSpace(
const CXXRecordDecl *RD)
const override;
149void CommonSPIRABIInfo::setCCs() {
150 assert(getRuntimeCC() == llvm::CallingConv::C);
151 RuntimeCC = llvm::CallingConv::SPIR_FUNC;
154ABIArgInfo SPIRVABIInfo::classifyKernelArgumentType(QualType Ty)
const {
159 llvm::Type *LTy = CGT.ConvertType(Ty);
160 auto DefaultAS = getContext().getTargetAddressSpace(LangAS::Default);
161 auto GlobalAS = getContext().getTargetAddressSpace(LangAS::opencl_global);
162 auto *PtrTy = llvm::dyn_cast<llvm::PointerType>(LTy);
163 if (PtrTy && PtrTy->getAddressSpace() == DefaultAS) {
164 LTy = llvm::PointerType::get(PtrTy->getContext(), GlobalAS);
168 if (getContext().getLangOpts().isTargetDevice() &&
178 return getNaturalAlignIndirect(Ty, 0,
true);
183void SPIRVABIInfo::computeInfo(CGFunctionInfo &FI)
const {
188 for (
auto &&[ArgumentsCount, I] : llvm::enumerate(FI.
arguments()))
191 : ABIArgInfo::getDirect();
197 if (CC == llvm::CallingConv::SPIR_KERNEL) {
198 I.info = classifyKernelArgumentType(I.type);
200 I.info = classifyArgumentType(I.type);
205RValue SPIRVABIInfo::EmitVAArg(CodeGenFunction &CGF, Address VAListAddr,
206 QualType Ty, AggValueSlot Slot)
const {
208 getContext().getTypeInfoInChars(Ty),
213uint64_t AMDGCNSPIRVABIInfo::numRegsForType(QualType Ty)
const {
217 if (
const VectorType *VT = Ty->
getAs<VectorType>()) {
220 QualType EltTy = VT->getElementType();
221 uint64_t EltSize = getContext().getTypeSize(EltTy);
225 return (VT->getNumElements() + 1) / 2;
227 uint64_t EltNumRegs = (EltSize + 31) / 32;
228 return EltNumRegs * VT->getNumElements();
232 assert(!RD->hasFlexibleArrayMember());
234 for (
const FieldDecl *Field : RD->fields()) {
235 QualType FieldTy =
Field->getType();
236 NumRegs += numRegsForType(FieldTy);
242 return (getContext().getTypeSize(Ty) + 31) / 32;
245llvm::Type *AMDGCNSPIRVABIInfo::coerceKernelArgumentType(llvm::Type *Ty,
247 unsigned ToAS)
const {
249 auto *PtrTy = llvm::dyn_cast<llvm::PointerType>(Ty);
250 if (PtrTy && PtrTy->getAddressSpace() == FromAS)
251 return llvm::PointerType::get(Ty->getContext(), ToAS);
255ABIArgInfo AMDGCNSPIRVABIInfo::classifyReturnType(QualType RetTy)
const {
282 llvm::Type *I32Ty = llvm::Type::getInt32Ty(getVMContext());
286 if (numRegsForType(RetTy) <= MaxNumRegsForArgsRet)
293ABIArgInfo AMDGCNSPIRVABIInfo::classifyKernelArgumentType(QualType Ty)
const {
299 Ty = QualType(SeltTy, 0);
301 llvm::Type *OrigLTy = CGT.ConvertType(Ty);
302 llvm::Type *LTy = OrigLTy;
303 if (getContext().getLangOpts().isTargetDevice()) {
304 LTy = coerceKernelArgumentType(
305 OrigLTy, getContext().getTargetAddressSpace(LangAS::Default),
306 getContext().getTargetAddressSpace(LangAS::opencl_global));
314 getContext().getTypeAlignInChars(Ty),
315 getContext().getTargetAddressSpace(LangAS::opencl_constant),
324ABIArgInfo AMDGCNSPIRVABIInfo::classifyArgumentType(QualType Ty,
325 bool Variadic)
const {
326 assert(NumRegsLeft <= MaxNumRegsForArgsRet &&
"register estimate underflow");
341 uint64_t NumRegs = numRegsForType(Ty);
342 NumRegsLeft -= std::min(NumRegs, uint64_t{NumRegsLeft});
351 return getNaturalAlignIndirect(Ty, getDataLayout().getAllocaAddrSpace(),
371 unsigned NumRegs = (
Size + 31) / 32;
372 NumRegsLeft -= std::min(NumRegsLeft, NumRegs);
382 llvm::Type *I32Ty = llvm::Type::getInt32Ty(getVMContext());
386 if (NumRegsLeft > 0) {
387 uint64_t NumRegs = numRegsForType(Ty);
388 if (NumRegsLeft >= NumRegs) {
389 NumRegsLeft -= NumRegs;
397 getContext().getTypeAlignInChars(Ty),
398 getContext().getTargetAddressSpace(LangAS::opencl_private));
401void AMDGCNSPIRVABIInfo::computeInfo(CGFunctionInfo &FI)
const {
407 unsigned ArgumentIndex = 0;
410 NumRegsLeft = MaxNumRegsForArgsRet;
412 if (CC == llvm::CallingConv::SPIR_KERNEL) {
413 I.info = classifyKernelArgumentType(I.type);
415 bool FixedArgument = ArgumentIndex++ < NumRequiredArgs;
421llvm::FixedVectorType *
422SPIRVABIInfo::getOptimalVectorMemoryType(llvm::FixedVectorType *Ty,
423 const LangOptions &LangOpt)
const {
427 if (getTarget().
getTriple().isSPIRVLogical())
429 return DefaultABIInfo::getOptimalVectorMemoryType(Ty, LangOpt);
432llvm::FixedVectorType *AMDGCNSPIRVABIInfo::getOptimalVectorMemoryType(
433 llvm::FixedVectorType *Ty,
const LangOptions &LangOpt)
const {
435 if (Ty->getNumElements() == 3 && getDataLayout().getTypeSizeInBits(Ty) == 96)
437 return DefaultABIInfo::getOptimalVectorMemoryType(Ty, LangOpt);
445 AMDGCNSPIRVABIInfo(CGM.
getTypes()).computeInfo(FI);
447 SPIRVABIInfo(CGM.
getTypes()).computeInfo(FI);
449 CommonSPIRABIInfo(CGM.
getTypes()).computeInfo(FI);
455unsigned CommonSPIRTargetCodeGenInfo::getDeviceKernelCallingConv()
const {
456 return llvm::CallingConv::SPIR_KERNEL;
459LangAS SPIRVTargetCodeGenInfo::getSRetAddrSpace(
const CXXRecordDecl *RD)
const {
463 return LangAS::Default;
465 getABIInfo().getDataLayout().getAllocaAddrSpace());
468void SPIRVTargetCodeGenInfo::setCUDAKernelCallingConvention(
469 const FunctionType *&FT)
const {
471 if (getABIInfo().getContext().getLangOpts().
HIP) {
472 FT = getABIInfo().getContext().adjustFunctionType(
478void CommonSPIRTargetCodeGenInfo::setOCLKernelStubCallingConvention(
479 const FunctionType *&FT)
const {
480 FT = getABIInfo().getContext().adjustFunctionType(
491CommonSPIRTargetCodeGenInfo::getNullPointer(
const CodeGen::CodeGenModule &CGM,
492 llvm::PointerType *PT,
497 unsigned ASAsInt =
static_cast<unsigned>(AS);
498 unsigned FirstTargetASAsInt =
499 static_cast<unsigned>(LangAS::FirstTargetAddressSpace);
500 unsigned CodeSectionINTELAS = FirstTargetASAsInt + 9;
503 bool IsFunctionPtrAS =
504 CGM.
getTriple().isSPIRV() && ASAsInt == CodeSectionINTELAS;
505 if (AS == LangAS::Default || AS == LangAS::opencl_generic ||
506 AS == LangAS::opencl_constant || IsFunctionPtrAS)
507 return llvm::ConstantPointerNull::get(PT);
510 auto NPT = llvm::PointerType::get(
511 PT->getContext(), Ctx.getTargetAddressSpace(LangAS::opencl_generic));
512 return llvm::ConstantExpr::getAddrSpaceCast(
513 llvm::ConstantPointerNull::get(NPT), PT);
517SPIRVTargetCodeGenInfo::getGlobalVarAddressSpace(CodeGenModule &CGM,
518 const VarDecl *D)
const {
521 "Address space agnostic languages only");
529 return DefaultGlobalAS;
532 if (AddrSpace != LangAS::Default)
535 return DefaultGlobalAS;
538void SPIRVTargetCodeGenInfo::setTargetAttributes(
539 const Decl *D, llvm::GlobalValue *GV, CodeGen::CodeGenModule &M)
const {
540 if (GV->isDeclaration())
543 const FunctionDecl *FD = dyn_cast_or_null<FunctionDecl>(D);
547 llvm::Function *F = dyn_cast<llvm::Function>(GV);
548 assert(F &&
"Expected GlobalValue to be a Function");
554 if (!FD->
hasAttr<CUDAGlobalAttr>())
557 unsigned N = M.
getLangOpts().GPUMaxThreadsPerBlock;
558 if (
auto FlatWGS = FD->
getAttr<AMDGPUFlatWorkGroupSizeAttr>()) {
559 N = FlatWGS->getMax()->EvaluateKnownConstInt(M.
getContext()).getExtValue();
560 }
else if (
auto LB = FD->
getAttr<CUDALaunchBoundsAttr>()) {
561 if (uint64_t MaxThreads = LB->getMaxThreads()
571 llvm::Metadata *AttrMDArgs[] = {
572 llvm::ConstantAsMetadata::get(llvm::ConstantInt::get(Int32Ty, N)),
573 llvm::ConstantAsMetadata::get(llvm::ConstantInt::get(Int32Ty, 1)),
574 llvm::ConstantAsMetadata::get(llvm::ConstantInt::get(Int32Ty, 1))};
576 F->setMetadata(
"max_work_group_size",
580StringRef SPIRVTargetCodeGenInfo::getLLVMSyncScopeStr(
581 const LangOptions &,
SyncScope Scope, llvm::AtomicOrdering)
const {
582 return *llvm::getAtomicScopeIRString(getABIInfo().getTarget().
getTriple(),
586void SPIRVTargetCodeGenInfo::setTargetAtomicMetadata(
587 CodeGenFunction &CGF, llvm::Instruction &AtomicInst,
588 const AtomicExpr *AE)
const {
589 if (CGF.
CGM.
getTriple().getVendor() != llvm::Triple::VendorType::AMD)
592 auto *RMW = dyn_cast<llvm::AtomicRMWInst>(&AtomicInst);
599 RMW->setMetadata(
"amdgpu.no.fine.grained.memory",
Empty);
601 RMW->setMetadata(
"amdgpu.no.remote.memory",
Empty);
603 RMW->getOperation() == llvm::AtomicRMWInst::FAdd &&
604 RMW->getType()->isFloatTy())
605 RMW->setMetadata(llvm::LLVMContext::MD_atomic_ignore_denormal_mode,
Empty);
610 StringRef OpenCLName,
611 unsigned AccessQualifier) {
622 if (OpenCLName.starts_with(
"image2d"))
624 else if (OpenCLName.starts_with(
"image3d"))
626 else if (OpenCLName ==
"image1d_buffer")
629 assert(OpenCLName.starts_with(
"image1d") &&
"Unknown image type");
634 if (OpenCLName.contains(
"_depth"))
636 if (OpenCLName.contains(
"_array"))
638 if (OpenCLName.contains(
"_msaa"))
642 IntParams.push_back(AccessQualifier);
644 return llvm::TargetExtType::get(Ctx, BaseType, {llvm::Type::getVoidTy(Ctx)},
648llvm::Type *CommonSPIRTargetCodeGenInfo::getOpenCLType(CodeGenModule &CGM,
649 const Type *Ty)
const {
651 if (
auto *PipeTy = dyn_cast<PipeType>(Ty))
652 return llvm::TargetExtType::get(Ctx,
"spirv.Pipe", {},
653 {!PipeTy->isReadOnly()});
654 if (
auto *BuiltinTy = dyn_cast<BuiltinType>(Ty)) {
655 enum AccessQualifier :
unsigned { AQ_ro = 0, AQ_wo = 1, AQ_rw = 2 };
656 switch (BuiltinTy->getKind()) {
657#define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \
658 case BuiltinType::Id: \
659 return getSPIRVImageType(Ctx, "spirv.Image", #ImgType, AQ_##Suffix);
660#include "clang/Basic/OpenCLImageTypes.def"
661 case BuiltinType::OCLSampler:
662 return llvm::TargetExtType::get(Ctx,
"spirv.Sampler");
663 case BuiltinType::OCLEvent:
664 return llvm::TargetExtType::get(Ctx,
"spirv.Event");
665 case BuiltinType::OCLClkEvent:
666 return llvm::TargetExtType::get(Ctx,
"spirv.DeviceEvent");
667 case BuiltinType::OCLQueue:
668 return llvm::TargetExtType::get(Ctx,
"spirv.Queue");
669 case BuiltinType::OCLReserveID:
670 return llvm::TargetExtType::get(Ctx,
"spirv.ReserveId");
671#define INTEL_SUBGROUP_AVC_TYPE(Name, Id) \
672 case BuiltinType::OCLIntelSubgroupAVC##Id: \
673 return llvm::TargetExtType::get(Ctx, "spirv.Avc" #Id "INTEL");
674#include "clang/Basic/OpenCLExtensionTypes.def"
686 llvm::Type *IntegralType,
693 while (
Value.ugt(0)) {
695 Value.lshrInPlace(32);
697 Words.push_back(Word);
699 if (Words.size() == 0)
703 return llvm::TargetExtType::get(Ctx,
"spirv.IntegralConstant",
704 {IntegralType}, Words);
705 return llvm::TargetExtType::get(Ctx,
"spirv.Literal", {}, Words);
709 const HLSLInlineSpirvType *SpirvType) {
714 for (
auto &Operand : SpirvType->getOperands()) {
715 using SpirvOperandKind = SpirvOperand::SpirvOperandKind;
717 llvm::Type *
Result =
nullptr;
718 switch (Operand.getKind()) {
719 case SpirvOperandKind::ConstantId: {
720 llvm::Type *IntegralType =
726 case SpirvOperandKind::Literal: {
730 case SpirvOperandKind::TypeId: {
731 QualType TypeOperand = Operand.getResultType();
734 "Type completion should have been required in Sema");
739 if (ResourceType->
getAs<HLSLAttributedResourceType>()) {
740 TypeOperand = ResourceType;
748 llvm_unreachable(
"HLSLInlineSpirvType had invalid operand!");
753 Operands.push_back(
Result);
756 return llvm::TargetExtType::get(Ctx,
"spirv.Type", Operands,
757 {SpirvType->getOpcode(), SpirvType->getSize(),
758 SpirvType->getAlignment()});
761llvm::Type *CommonSPIRTargetCodeGenInfo::getHLSLType(
762 CodeGenModule &CGM,
const Type *Ty,
763 const CGHLSLOffsetInfo &OffsetInfo)
const {
766 if (
auto *SpirvType = dyn_cast<HLSLInlineSpirvType>(Ty))
769 auto *ResType = dyn_cast<HLSLAttributedResourceType>(Ty);
773 const HLSLAttributedResourceType::Attributes &ResAttrs = ResType->getAttrs();
774 switch (ResAttrs.ResourceClass) {
775 case llvm::dxil::ResourceClass::UAV:
776 case llvm::dxil::ResourceClass::SRV: {
778 QualType ContainedTy = ResType->getContainedType();
782 assert(!ResAttrs.IsROV &&
783 "Rasterizer order views not implemented for SPIR-V yet");
785 if (!ResAttrs.RawBuffer) {
787 return getSPIRVImageTypeFromHLSLResource(ResAttrs, ContainedTy, CGM);
790 if (ResAttrs.IsCounter) {
791 llvm::Type *ElemType = llvm::Type::getInt32Ty(Ctx);
793 return llvm::TargetExtType::get(Ctx,
"spirv.VulkanBuffer", {ElemType},
797 llvm::ArrayType *RuntimeArrayType = llvm::ArrayType::get(ElemType, 0);
799 bool IsWritable = ResAttrs.ResourceClass == llvm::dxil::ResourceClass::UAV;
800 return llvm::TargetExtType::get(Ctx,
"spirv.VulkanBuffer",
804 case llvm::dxil::ResourceClass::CBuffer: {
805 QualType ContainedTy = ResType->getContainedType();
809 llvm::StructType *BufferLayoutTy =
810 HLSLBufferLayoutBuilder(CGM).layOutStruct(
813 return llvm::TargetExtType::get(Ctx,
"spirv.VulkanBuffer", {BufferLayoutTy},
817 case llvm::dxil::ResourceClass::Sampler:
818 return llvm::TargetExtType::get(Ctx,
"spirv.Sampler");
825 const HLSLAttributedResourceType::Attributes &attributes,
826 llvm::Type *SampledType,
QualType Ty,
unsigned NumChannels) {
831 if (LangOpts.HLSLSpvUseUnknownImageFormat ||
832 attributes.ResourceClass != llvm::dxil::ResourceClass::UAV) {
836 if (SampledType->isIntegerTy(32)) {
838 if (NumChannels == 1)
840 if (NumChannels == 2)
842 if (NumChannels == 4)
845 if (NumChannels == 1)
847 if (NumChannels == 2)
849 if (NumChannels == 4)
852 }
else if (SampledType->isIntegerTy(64)) {
853 if (NumChannels == 1) {
859 }
else if (SampledType->isFloatTy()) {
860 if (NumChannels == 1)
862 if (NumChannels == 2)
864 if (NumChannels == 4)
871llvm::Type *CommonSPIRTargetCodeGenInfo::getSPIRVImageTypeFromHLSLResource(
872 const HLSLAttributedResourceType::Attributes &attributes, QualType Ty,
873 CodeGenModule &CGM)
const {
876 unsigned NumChannels = 1;
878 if (
const VectorType *
V = dyn_cast<VectorType>(Ty)) {
879 NumChannels =
V->getNumElements();
880 Ty =
V->getElementType();
882 assert(!Ty->
isVectorType() &&
"We still have a vector type.");
886 assert((SampledType->isIntegerTy() || SampledType->isFloatingPointTy()) &&
887 "The element type for a SPIR-V resource must be a scalar integer or "
888 "floating point type.");
890 assert((!SampledType->isIntegerTy(64) || NumChannels <= 2) &&
891 "A 64-bit SPIR-V resource element can have at most 2 components.");
896 if (SampledType->isIntegerTy(64) && NumChannels == 2) {
897 SampledType = llvm::Type::getInt32Ty(Ctx);
904 SmallVector<unsigned, 6> IntParams(6, 0);
910 switch (attributes.ResourceDimension) {
911 case llvm::dxil::ResourceDimension::Dim1D:
914 case llvm::dxil::ResourceDimension::Dim2D:
917 case llvm::dxil::ResourceDimension::Dim3D:
920 case llvm::dxil::ResourceDimension::Cube:
923 case llvm::dxil::ResourceDimension::Unknown:
933 IntParams[2] =
static_cast<unsigned>(attributes.IsArray);
936 IntParams[3] =
static_cast<unsigned>(attributes.isMultiSampled());
940 attributes.ResourceClass == llvm::dxil::ResourceClass::UAV ? 2 : 1;
946 llvm::TargetExtType *ImageType =
947 llvm::TargetExtType::get(Ctx, Name, {SampledType}, IntParams);
951std::unique_ptr<TargetCodeGenInfo>
953 return std::make_unique<CommonSPIRTargetCodeGenInfo>(CGM.
getTypes());
956std::unique_ptr<TargetCodeGenInfo>
958 return std::make_unique<SPIRVTargetCodeGenInfo>(CGM.
getTypes());
static void setCUDAKernelCallingConvention(CanQualType &funcTy, CIRGenModule &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.
Top level wrappers for InstallAPI frontend operations.
StorageClass
Storage classes.
const FunctionProtoType * T
@ Type
The name was classified as a type.
LangAS
Defines the address space values used by the address space qualifier of QualType.
llvm::AtomicScope getAtomicScope(SyncScope S)
Collapses a clang sync scope onto the target-neutral llvm::AtomicScope.
for(const auto &A :T->param_types())
SyncScope
Defines sync scope values used internally by clang.
LangAS getLangASFromTargetAS(unsigned TargetAS)
__builtin_elementwise_add_sat __builtin_elementwise_sub_sat uint32_t __packed_splat4 __packed_splat2 __packed_splat8 __packed_splat4 __packed_splat2 __packed_splat4 __packed_splat2 __packed_splat8 __packed_splat4 uint32_t
bool getOption(AtomicOptionKind Kind) const