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 {
563 return *llvm::getAtomicScopeIRString(getABIInfo().getTarget().
getTriple(),
567void SPIRVTargetCodeGenInfo::setTargetAtomicMetadata(
568 CodeGenFunction &CGF, llvm::Instruction &AtomicInst,
569 const AtomicExpr *AE)
const {
570 if (CGF.
CGM.
getTriple().getVendor() != llvm::Triple::VendorType::AMD)
573 auto *RMW = dyn_cast<llvm::AtomicRMWInst>(&AtomicInst);
580 RMW->setMetadata(
"amdgpu.no.fine.grained.memory",
Empty);
582 RMW->setMetadata(
"amdgpu.no.remote.memory",
Empty);
584 RMW->getOperation() == llvm::AtomicRMWInst::FAdd &&
585 RMW->getType()->isFloatTy())
586 RMW->setMetadata(
"amdgpu.ignore.denormal.mode",
Empty);
591 StringRef OpenCLName,
592 unsigned AccessQualifier) {
603 if (OpenCLName.starts_with(
"image2d"))
605 else if (OpenCLName.starts_with(
"image3d"))
607 else if (OpenCLName ==
"image1d_buffer")
610 assert(OpenCLName.starts_with(
"image1d") &&
"Unknown image type");
615 if (OpenCLName.contains(
"_depth"))
617 if (OpenCLName.contains(
"_array"))
619 if (OpenCLName.contains(
"_msaa"))
623 IntParams.push_back(AccessQualifier);
625 return llvm::TargetExtType::get(Ctx, BaseType, {llvm::Type::getVoidTy(Ctx)},
629llvm::Type *CommonSPIRTargetCodeGenInfo::getOpenCLType(CodeGenModule &CGM,
630 const Type *Ty)
const {
632 if (
auto *PipeTy = dyn_cast<PipeType>(Ty))
633 return llvm::TargetExtType::get(Ctx,
"spirv.Pipe", {},
634 {!PipeTy->isReadOnly()});
635 if (
auto *BuiltinTy = dyn_cast<BuiltinType>(Ty)) {
636 enum AccessQualifier :
unsigned { AQ_ro = 0, AQ_wo = 1, AQ_rw = 2 };
637 switch (BuiltinTy->getKind()) {
638#define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \
639 case BuiltinType::Id: \
640 return getSPIRVImageType(Ctx, "spirv.Image", #ImgType, AQ_##Suffix);
641#include "clang/Basic/OpenCLImageTypes.def"
642 case BuiltinType::OCLSampler:
643 return llvm::TargetExtType::get(Ctx,
"spirv.Sampler");
644 case BuiltinType::OCLEvent:
645 return llvm::TargetExtType::get(Ctx,
"spirv.Event");
646 case BuiltinType::OCLClkEvent:
647 return llvm::TargetExtType::get(Ctx,
"spirv.DeviceEvent");
648 case BuiltinType::OCLQueue:
649 return llvm::TargetExtType::get(Ctx,
"spirv.Queue");
650 case BuiltinType::OCLReserveID:
651 return llvm::TargetExtType::get(Ctx,
"spirv.ReserveId");
652#define INTEL_SUBGROUP_AVC_TYPE(Name, Id) \
653 case BuiltinType::OCLIntelSubgroupAVC##Id: \
654 return llvm::TargetExtType::get(Ctx, "spirv.Avc" #Id "INTEL");
655#include "clang/Basic/OpenCLExtensionTypes.def"
667 llvm::Type *IntegralType,
674 while (
Value.ugt(0)) {
676 Value.lshrInPlace(32);
678 Words.push_back(Word);
680 if (Words.size() == 0)
684 return llvm::TargetExtType::get(Ctx,
"spirv.IntegralConstant",
685 {IntegralType}, Words);
686 return llvm::TargetExtType::get(Ctx,
"spirv.Literal", {}, Words);
690 const HLSLInlineSpirvType *SpirvType) {
695 for (
auto &Operand : SpirvType->getOperands()) {
696 using SpirvOperandKind = SpirvOperand::SpirvOperandKind;
698 llvm::Type *
Result =
nullptr;
699 switch (Operand.getKind()) {
700 case SpirvOperandKind::ConstantId: {
701 llvm::Type *IntegralType =
707 case SpirvOperandKind::Literal: {
711 case SpirvOperandKind::TypeId: {
712 QualType TypeOperand = Operand.getResultType();
715 "Type completion should have been required in Sema");
720 if (ResourceType->
getAs<HLSLAttributedResourceType>()) {
721 TypeOperand = ResourceType;
729 llvm_unreachable(
"HLSLInlineSpirvType had invalid operand!");
734 Operands.push_back(
Result);
737 return llvm::TargetExtType::get(Ctx,
"spirv.Type", Operands,
738 {SpirvType->getOpcode(), SpirvType->getSize(),
739 SpirvType->getAlignment()});
742llvm::Type *CommonSPIRTargetCodeGenInfo::getHLSLType(
743 CodeGenModule &CGM,
const Type *Ty,
744 const CGHLSLOffsetInfo &OffsetInfo)
const {
747 if (
auto *SpirvType = dyn_cast<HLSLInlineSpirvType>(Ty))
750 auto *ResType = dyn_cast<HLSLAttributedResourceType>(Ty);
754 const HLSLAttributedResourceType::Attributes &ResAttrs = ResType->getAttrs();
755 switch (ResAttrs.ResourceClass) {
756 case llvm::dxil::ResourceClass::UAV:
757 case llvm::dxil::ResourceClass::SRV: {
759 QualType ContainedTy = ResType->getContainedType();
763 assert(!ResAttrs.IsROV &&
764 "Rasterizer order views not implemented for SPIR-V yet");
766 if (!ResAttrs.RawBuffer) {
768 return getSPIRVImageTypeFromHLSLResource(ResAttrs, ContainedTy, CGM);
771 if (ResAttrs.IsCounter) {
772 llvm::Type *ElemType = llvm::Type::getInt32Ty(Ctx);
774 return llvm::TargetExtType::get(Ctx,
"spirv.VulkanBuffer", {ElemType},
778 llvm::ArrayType *RuntimeArrayType = llvm::ArrayType::get(ElemType, 0);
780 bool IsWritable = ResAttrs.ResourceClass == llvm::dxil::ResourceClass::UAV;
781 return llvm::TargetExtType::get(Ctx,
"spirv.VulkanBuffer",
785 case llvm::dxil::ResourceClass::CBuffer: {
786 QualType ContainedTy = ResType->getContainedType();
790 llvm::StructType *BufferLayoutTy =
791 HLSLBufferLayoutBuilder(CGM).layOutStruct(
794 return llvm::TargetExtType::get(Ctx,
"spirv.VulkanBuffer", {BufferLayoutTy},
798 case llvm::dxil::ResourceClass::Sampler:
799 return llvm::TargetExtType::get(Ctx,
"spirv.Sampler");
806 const HLSLAttributedResourceType::Attributes &attributes,
807 llvm::Type *SampledType,
QualType Ty,
unsigned NumChannels) {
812 if (LangOpts.HLSLSpvUseUnknownImageFormat ||
813 attributes.ResourceClass != llvm::dxil::ResourceClass::UAV) {
817 if (SampledType->isIntegerTy(32)) {
819 if (NumChannels == 1)
821 if (NumChannels == 2)
823 if (NumChannels == 4)
826 if (NumChannels == 1)
828 if (NumChannels == 2)
830 if (NumChannels == 4)
833 }
else if (SampledType->isIntegerTy(64)) {
834 if (NumChannels == 1) {
840 }
else if (SampledType->isFloatTy()) {
841 if (NumChannels == 1)
843 if (NumChannels == 2)
845 if (NumChannels == 4)
852llvm::Type *CommonSPIRTargetCodeGenInfo::getSPIRVImageTypeFromHLSLResource(
853 const HLSLAttributedResourceType::Attributes &attributes, QualType Ty,
854 CodeGenModule &CGM)
const {
857 unsigned NumChannels = 1;
859 if (
const VectorType *
V = dyn_cast<VectorType>(Ty)) {
860 NumChannels =
V->getNumElements();
861 Ty =
V->getElementType();
863 assert(!Ty->
isVectorType() &&
"We still have a vector type.");
867 assert((SampledType->isIntegerTy() || SampledType->isFloatingPointTy()) &&
868 "The element type for a SPIR-V resource must be a scalar integer or "
869 "floating point type.");
871 assert((!SampledType->isIntegerTy(64) || NumChannels <= 2) &&
872 "A 64-bit SPIR-V resource element can have at most 2 components.");
877 if (SampledType->isIntegerTy(64) && NumChannels == 2) {
878 SampledType = llvm::Type::getInt32Ty(Ctx);
885 SmallVector<unsigned, 6> IntParams(6, 0);
891 switch (attributes.ResourceDimension) {
892 case llvm::dxil::ResourceDimension::Dim1D:
895 case llvm::dxil::ResourceDimension::Dim2D:
898 case llvm::dxil::ResourceDimension::Dim3D:
901 case llvm::dxil::ResourceDimension::Cube:
904 case llvm::dxil::ResourceDimension::Unknown:
914 IntParams[2] =
static_cast<unsigned>(attributes.IsArray);
921 attributes.ResourceClass == llvm::dxil::ResourceClass::UAV ? 2 : 1;
927 llvm::TargetExtType *ImageType =
928 llvm::TargetExtType::get(Ctx, Name, {SampledType}, IntParams);
932std::unique_ptr<TargetCodeGenInfo>
934 return std::make_unique<CommonSPIRTargetCodeGenInfo>(CGM.
getTypes());
937std::unique_ptr<TargetCodeGenInfo>
939 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.
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)
__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