11#include "TargetInfo.h"
13#include "llvm/IR/DerivedTypes.h"
29 CommonSPIRABIInfo(CodeGenTypes &CGT) : DefaultABIInfo(CGT) { setCCs(); }
35class SPIRVABIInfo :
public CommonSPIRABIInfo {
37 SPIRVABIInfo(CodeGenTypes &CGT) : CommonSPIRABIInfo(CGT) {}
38 void computeInfo(CGFunctionInfo &FI)
const override;
39 RValue EmitVAArg(CodeGenFunction &CGF, Address VAListAddr, QualType Ty,
40 AggValueSlot Slot)
const override;
42 llvm::FixedVectorType *
43 getOptimalVectorMemoryType(llvm::FixedVectorType *Ty,
44 const LangOptions &LangOpt)
const override;
47 ABIArgInfo classifyKernelArgumentType(QualType Ty)
const;
50class AMDGCNSPIRVABIInfo :
public SPIRVABIInfo {
53 static constexpr unsigned MaxNumRegsForArgsRet = 16;
54 mutable unsigned NumRegsLeft = 0;
56 uint64_t numRegsForType(QualType Ty)
const;
58 bool isHomogeneousAggregateBaseType(QualType Ty)
const override {
61 bool isHomogeneousAggregateSmallEnough(
const Type *Base,
62 uint64_t Members)
const override {
63 uint32_t NumRegs = (getContext().getTypeSize(Base) + 31) / 32;
66 return Members * NumRegs <= MaxNumRegsForArgsRet;
70 llvm::Type *coerceKernelArgumentType(llvm::Type *Ty,
unsigned FromAS,
74 ABIArgInfo classifyKernelArgumentType(QualType Ty)
const;
78 AMDGCNSPIRVABIInfo(CodeGenTypes &CGT) : SPIRVABIInfo(CGT) {}
79 void computeInfo(CGFunctionInfo &FI)
const override;
81 llvm::FixedVectorType *
82 getOptimalVectorMemoryType(llvm::FixedVectorType *Ty,
83 const LangOptions &LangOpt)
const override;
89 CommonSPIRTargetCodeGenInfo(CodeGen::CodeGenTypes &CGT)
90 : TargetCodeGenInfo(std::make_unique<CommonSPIRABIInfo>(CGT)) {}
91 CommonSPIRTargetCodeGenInfo(std::unique_ptr<ABIInfo> ABIInfo)
92 : TargetCodeGenInfo(std::move(ABIInfo)) {}
94 LangAS getASTAllocaAddressSpace()
const override {
96 getABIInfo().getDataLayout().getAllocaAddrSpace());
99 unsigned getDeviceKernelCallingConv()
const override;
100 llvm::Type *getOpenCLType(CodeGenModule &CGM,
const Type *T)
const override;
101 llvm::Type *getHLSLType(CodeGenModule &CGM,
const Type *Ty,
102 const CGHLSLOffsetInfo &OffsetInfo)
const override;
104 llvm::Type *getHLSLPadding(CodeGenModule &CGM,
105 CharUnits NumBytes)
const override {
107 return llvm::TargetExtType::get(CGM.
getLLVMContext(),
"spirv.Padding", {},
111 bool isHLSLPadding(llvm::Type *Ty)
const override {
112 if (
auto *TET = dyn_cast<llvm::TargetExtType>(Ty))
113 return TET->getName() ==
"spirv.Padding";
117 llvm::Type *getSPIRVImageTypeFromHLSLResource(
118 const HLSLAttributedResourceType::Attributes &attributes,
119 QualType SampledType, CodeGenModule &CGM)
const;
121 setOCLKernelStubCallingConvention(
const FunctionType *&FT)
const override;
122 llvm::Constant *getNullPointer(
const CodeGen::CodeGenModule &CGM,
123 llvm::PointerType *T,
124 QualType QT)
const override;
126class SPIRVTargetCodeGenInfo :
public CommonSPIRTargetCodeGenInfo {
128 SPIRVTargetCodeGenInfo(CodeGen::CodeGenTypes &CGT)
129 : CommonSPIRTargetCodeGenInfo(
130 (CGT.getTarget().
getTriple().getVendor() == llvm::Triple::AMD)
131 ? std::make_unique<AMDGCNSPIRVABIInfo>(CGT)
132 : std::make_unique<SPIRVABIInfo>(CGT)) {}
134 LangAS getGlobalVarAddressSpace(CodeGenModule &CGM,
135 const VarDecl *D)
const override;
136 void setTargetAttributes(
const Decl *D, llvm::GlobalValue *GV,
137 CodeGen::CodeGenModule &M)
const override;
138 StringRef getLLVMSyncScopeStr(
const LangOptions &LangOpts,
SyncScope Scope,
139 llvm::AtomicOrdering Ordering)
const override;
140 bool supportsLibCall()
const override {
141 return getABIInfo().getTarget().getTriple().getVendor() !=
147void CommonSPIRABIInfo::setCCs() {
148 assert(getRuntimeCC() == llvm::CallingConv::C);
149 RuntimeCC = llvm::CallingConv::SPIR_FUNC;
152ABIArgInfo SPIRVABIInfo::classifyKernelArgumentType(QualType Ty)
const {
157 llvm::Type *LTy = CGT.ConvertType(Ty);
158 auto DefaultAS = getContext().getTargetAddressSpace(LangAS::Default);
159 auto GlobalAS = getContext().getTargetAddressSpace(LangAS::opencl_global);
160 auto *PtrTy = llvm::dyn_cast<llvm::PointerType>(LTy);
161 if (PtrTy && PtrTy->getAddressSpace() == DefaultAS) {
162 LTy = llvm::PointerType::get(PtrTy->getContext(), GlobalAS);
166 if (getContext().getLangOpts().isTargetDevice() &&
176 return getNaturalAlignIndirect(Ty, 0,
true);
181void SPIRVABIInfo::computeInfo(CGFunctionInfo &FI)
const {
186 for (
auto &&[ArgumentsCount, I] : llvm::enumerate(FI.
arguments()))
189 : ABIArgInfo::getDirect();
195 if (CC == llvm::CallingConv::SPIR_KERNEL) {
196 I.info = classifyKernelArgumentType(I.type);
198 I.info = classifyArgumentType(I.type);
203RValue SPIRVABIInfo::EmitVAArg(CodeGenFunction &CGF, Address VAListAddr,
204 QualType Ty, AggValueSlot Slot)
const {
206 getContext().getTypeInfoInChars(Ty),
211uint64_t AMDGCNSPIRVABIInfo::numRegsForType(QualType Ty)
const {
215 if (
const VectorType *VT = Ty->
getAs<VectorType>()) {
218 QualType EltTy = VT->getElementType();
219 uint64_t EltSize = getContext().getTypeSize(EltTy);
223 return (VT->getNumElements() + 1) / 2;
225 uint64_t EltNumRegs = (EltSize + 31) / 32;
226 return EltNumRegs * VT->getNumElements();
230 assert(!RD->hasFlexibleArrayMember());
232 for (
const FieldDecl *Field : RD->fields()) {
233 QualType FieldTy =
Field->getType();
234 NumRegs += numRegsForType(FieldTy);
240 return (getContext().getTypeSize(Ty) + 31) / 32;
243llvm::Type *AMDGCNSPIRVABIInfo::coerceKernelArgumentType(llvm::Type *Ty,
245 unsigned ToAS)
const {
247 auto *PtrTy = llvm::dyn_cast<llvm::PointerType>(Ty);
248 if (PtrTy && PtrTy->getAddressSpace() == FromAS)
249 return llvm::PointerType::get(Ty->getContext(), ToAS);
253ABIArgInfo AMDGCNSPIRVABIInfo::classifyReturnType(QualType RetTy)
const {
280 llvm::Type *I32Ty = llvm::Type::getInt32Ty(getVMContext());
284 if (numRegsForType(RetTy) <= MaxNumRegsForArgsRet)
291ABIArgInfo AMDGCNSPIRVABIInfo::classifyKernelArgumentType(QualType Ty)
const {
297 Ty = QualType(SeltTy, 0);
299 llvm::Type *OrigLTy = CGT.ConvertType(Ty);
300 llvm::Type *LTy = OrigLTy;
301 if (getContext().getLangOpts().isTargetDevice()) {
302 LTy = coerceKernelArgumentType(
303 OrigLTy, getContext().getTargetAddressSpace(LangAS::Default),
304 getContext().getTargetAddressSpace(LangAS::opencl_global));
312 getContext().getTypeAlignInChars(Ty),
313 getContext().getTargetAddressSpace(LangAS::opencl_constant),
322ABIArgInfo AMDGCNSPIRVABIInfo::classifyArgumentType(QualType Ty)
const {
323 assert(NumRegsLeft <= MaxNumRegsForArgsRet &&
"register estimate underflow");
332 uint64_t NumRegs = numRegsForType(Ty);
333 NumRegsLeft -= std::min(NumRegs, uint64_t{NumRegsLeft});
342 return getNaturalAlignIndirect(Ty, getDataLayout().getAllocaAddrSpace(),
362 unsigned NumRegs = (
Size + 31) / 32;
363 NumRegsLeft -= std::min(NumRegsLeft, NumRegs);
373 llvm::Type *I32Ty = llvm::Type::getInt32Ty(getVMContext());
377 if (NumRegsLeft > 0) {
378 uint64_t NumRegs = numRegsForType(Ty);
379 if (NumRegsLeft >= NumRegs) {
380 NumRegsLeft -= NumRegs;
388 getContext().getTypeAlignInChars(Ty),
389 getContext().getTargetAddressSpace(LangAS::opencl_private));
392void AMDGCNSPIRVABIInfo::computeInfo(CGFunctionInfo &FI)
const {
398 NumRegsLeft = MaxNumRegsForArgsRet;
400 if (CC == llvm::CallingConv::SPIR_KERNEL)
401 I.info = classifyKernelArgumentType(I.type);
407llvm::FixedVectorType *
408SPIRVABIInfo::getOptimalVectorMemoryType(llvm::FixedVectorType *Ty,
409 const LangOptions &LangOpt)
const {
413 if (getTarget().
getTriple().isSPIRVLogical())
415 return DefaultABIInfo::getOptimalVectorMemoryType(Ty, LangOpt);
418llvm::FixedVectorType *AMDGCNSPIRVABIInfo::getOptimalVectorMemoryType(
419 llvm::FixedVectorType *Ty,
const LangOptions &LangOpt)
const {
421 if (Ty->getNumElements() == 3 && getDataLayout().getTypeSizeInBits(Ty) == 96)
423 return DefaultABIInfo::getOptimalVectorMemoryType(Ty, LangOpt);
431 AMDGCNSPIRVABIInfo(CGM.
getTypes()).computeInfo(FI);
433 SPIRVABIInfo(CGM.
getTypes()).computeInfo(FI);
435 CommonSPIRABIInfo(CGM.
getTypes()).computeInfo(FI);
441unsigned CommonSPIRTargetCodeGenInfo::getDeviceKernelCallingConv()
const {
442 return llvm::CallingConv::SPIR_KERNEL;
445void SPIRVTargetCodeGenInfo::setCUDAKernelCallingConvention(
446 const FunctionType *&FT)
const {
448 if (getABIInfo().getContext().getLangOpts().
HIP) {
449 FT = getABIInfo().getContext().adjustFunctionType(
455void CommonSPIRTargetCodeGenInfo::setOCLKernelStubCallingConvention(
456 const FunctionType *&FT)
const {
457 FT = getABIInfo().getContext().adjustFunctionType(
468CommonSPIRTargetCodeGenInfo::getNullPointer(
const CodeGen::CodeGenModule &CGM,
469 llvm::PointerType *PT,
474 unsigned ASAsInt =
static_cast<unsigned>(AS);
475 unsigned FirstTargetASAsInt =
476 static_cast<unsigned>(LangAS::FirstTargetAddressSpace);
477 unsigned CodeSectionINTELAS = FirstTargetASAsInt + 9;
480 bool IsFunctionPtrAS =
481 CGM.
getTriple().isSPIRV() && ASAsInt == CodeSectionINTELAS;
482 if (AS == LangAS::Default || AS == LangAS::opencl_generic ||
483 AS == LangAS::opencl_constant || IsFunctionPtrAS)
484 return llvm::ConstantPointerNull::get(PT);
487 auto NPT = llvm::PointerType::get(
488 PT->getContext(), Ctx.getTargetAddressSpace(LangAS::opencl_generic));
489 return llvm::ConstantExpr::getAddrSpaceCast(
490 llvm::ConstantPointerNull::get(NPT), PT);
494SPIRVTargetCodeGenInfo::getGlobalVarAddressSpace(CodeGenModule &CGM,
495 const VarDecl *D)
const {
498 "Address space agnostic languages only");
506 return DefaultGlobalAS;
509 if (AddrSpace != LangAS::Default)
512 return DefaultGlobalAS;
515void SPIRVTargetCodeGenInfo::setTargetAttributes(
516 const Decl *D, llvm::GlobalValue *GV, CodeGen::CodeGenModule &M)
const {
517 if (GV->isDeclaration())
520 const FunctionDecl *FD = dyn_cast_or_null<FunctionDecl>(D);
524 llvm::Function *F = dyn_cast<llvm::Function>(GV);
525 assert(F &&
"Expected GlobalValue to be a Function");
531 if (!FD->
hasAttr<CUDAGlobalAttr>())
534 unsigned N = M.
getLangOpts().GPUMaxThreadsPerBlock;
535 if (
auto FlatWGS = FD->
getAttr<AMDGPUFlatWorkGroupSizeAttr>())
536 N = FlatWGS->getMax()->EvaluateKnownConstInt(M.
getContext()).getExtValue();
542 llvm::Metadata *AttrMDArgs[] = {
543 llvm::ConstantAsMetadata::get(llvm::ConstantInt::get(Int32Ty, N)),
544 llvm::ConstantAsMetadata::get(llvm::ConstantInt::get(Int32Ty, 1)),
545 llvm::ConstantAsMetadata::get(llvm::ConstantInt::get(Int32Ty, 1))};
547 F->setMetadata(
"max_work_group_size",
551StringRef SPIRVTargetCodeGenInfo::getLLVMSyncScopeStr(
552 const LangOptions &,
SyncScope Scope, llvm::AtomicOrdering)
const {
554 case SyncScope::HIPSingleThread:
555 case SyncScope::SingleScope:
556 return "singlethread";
557 case SyncScope::HIPWavefront:
558 case SyncScope::OpenCLSubGroup:
559 case SyncScope::WavefrontScope:
561 case SyncScope::HIPCluster:
562 case SyncScope::ClusterScope:
563 case SyncScope::HIPWorkgroup:
564 case SyncScope::OpenCLWorkGroup:
565 case SyncScope::WorkgroupScope:
567 case SyncScope::HIPAgent:
568 case SyncScope::OpenCLDevice:
569 case SyncScope::DeviceScope:
571 case SyncScope::SystemScope:
572 case SyncScope::HIPSystem:
573 case SyncScope::OpenCLAllSVMDevices:
581 StringRef OpenCLName,
582 unsigned AccessQualifier) {
593 if (OpenCLName.starts_with(
"image2d"))
595 else if (OpenCLName.starts_with(
"image3d"))
597 else if (OpenCLName ==
"image1d_buffer")
600 assert(OpenCLName.starts_with(
"image1d") &&
"Unknown image type");
605 if (OpenCLName.contains(
"_depth"))
607 if (OpenCLName.contains(
"_array"))
609 if (OpenCLName.contains(
"_msaa"))
613 IntParams.push_back(AccessQualifier);
615 return llvm::TargetExtType::get(Ctx, BaseType, {llvm::Type::getVoidTy(Ctx)},
619llvm::Type *CommonSPIRTargetCodeGenInfo::getOpenCLType(CodeGenModule &CGM,
620 const Type *Ty)
const {
622 if (
auto *PipeTy = dyn_cast<PipeType>(Ty))
623 return llvm::TargetExtType::get(Ctx,
"spirv.Pipe", {},
624 {!PipeTy->isReadOnly()});
625 if (
auto *BuiltinTy = dyn_cast<BuiltinType>(Ty)) {
626 enum AccessQualifier :
unsigned { AQ_ro = 0, AQ_wo = 1, AQ_rw = 2 };
627 switch (BuiltinTy->getKind()) {
628#define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \
629 case BuiltinType::Id: \
630 return getSPIRVImageType(Ctx, "spirv.Image", #ImgType, AQ_##Suffix);
631#include "clang/Basic/OpenCLImageTypes.def"
632 case BuiltinType::OCLSampler:
633 return llvm::TargetExtType::get(Ctx,
"spirv.Sampler");
634 case BuiltinType::OCLEvent:
635 return llvm::TargetExtType::get(Ctx,
"spirv.Event");
636 case BuiltinType::OCLClkEvent:
637 return llvm::TargetExtType::get(Ctx,
"spirv.DeviceEvent");
638 case BuiltinType::OCLQueue:
639 return llvm::TargetExtType::get(Ctx,
"spirv.Queue");
640 case BuiltinType::OCLReserveID:
641 return llvm::TargetExtType::get(Ctx,
"spirv.ReserveId");
642#define INTEL_SUBGROUP_AVC_TYPE(Name, Id) \
643 case BuiltinType::OCLIntelSubgroupAVC##Id: \
644 return llvm::TargetExtType::get(Ctx, "spirv.Avc" #Id "INTEL");
645#include "clang/Basic/OpenCLExtensionTypes.def"
657 llvm::Type *IntegralType,
664 while (
Value.ugt(0)) {
665 uint32_t Word =
Value.trunc(32).getZExtValue();
666 Value.lshrInPlace(32);
668 Words.push_back(Word);
670 if (Words.size() == 0)
674 return llvm::TargetExtType::get(Ctx,
"spirv.IntegralConstant",
675 {IntegralType}, Words);
676 return llvm::TargetExtType::get(Ctx,
"spirv.Literal", {}, Words);
680 const HLSLInlineSpirvType *SpirvType) {
685 for (
auto &Operand : SpirvType->getOperands()) {
686 using SpirvOperandKind = SpirvOperand::SpirvOperandKind;
688 llvm::Type *Result =
nullptr;
689 switch (Operand.getKind()) {
690 case SpirvOperandKind::ConstantId: {
691 llvm::Type *IntegralType =
697 case SpirvOperandKind::Literal: {
701 case SpirvOperandKind::TypeId: {
702 QualType TypeOperand = Operand.getResultType();
704 assert(RD->isCompleteDefinition() &&
705 "Type completion should have been required in Sema");
707 const FieldDecl *HandleField = RD->findFirstNamedDataMember();
710 if (ResourceType->
getAs<HLSLAttributedResourceType>()) {
711 TypeOperand = ResourceType;
719 llvm_unreachable(
"HLSLInlineSpirvType had invalid operand!");
724 Operands.push_back(Result);
727 return llvm::TargetExtType::get(Ctx,
"spirv.Type", Operands,
728 {SpirvType->getOpcode(), SpirvType->getSize(),
729 SpirvType->getAlignment()});
732llvm::Type *CommonSPIRTargetCodeGenInfo::getHLSLType(
733 CodeGenModule &CGM,
const Type *Ty,
734 const CGHLSLOffsetInfo &OffsetInfo)
const {
737 if (
auto *SpirvType = dyn_cast<HLSLInlineSpirvType>(Ty))
740 auto *ResType = dyn_cast<HLSLAttributedResourceType>(Ty);
744 const HLSLAttributedResourceType::Attributes &ResAttrs = ResType->getAttrs();
745 switch (ResAttrs.ResourceClass) {
746 case llvm::dxil::ResourceClass::UAV:
747 case llvm::dxil::ResourceClass::SRV: {
749 QualType ContainedTy = ResType->getContainedType();
753 assert(!ResAttrs.IsROV &&
754 "Rasterizer order views not implemented for SPIR-V yet");
756 if (!ResAttrs.RawBuffer) {
758 return getSPIRVImageTypeFromHLSLResource(ResAttrs, ContainedTy, CGM);
761 if (ResAttrs.IsCounter) {
762 llvm::Type *ElemType = llvm::Type::getInt32Ty(Ctx);
764 return llvm::TargetExtType::get(Ctx,
"spirv.VulkanBuffer", {ElemType},
768 llvm::ArrayType *RuntimeArrayType = llvm::ArrayType::get(ElemType, 0);
770 bool IsWritable = ResAttrs.ResourceClass == llvm::dxil::ResourceClass::UAV;
771 return llvm::TargetExtType::get(Ctx,
"spirv.VulkanBuffer",
775 case llvm::dxil::ResourceClass::CBuffer: {
776 QualType ContainedTy = ResType->getContainedType();
780 llvm::StructType *BufferLayoutTy =
781 HLSLBufferLayoutBuilder(CGM).layOutStruct(
784 return llvm::TargetExtType::get(Ctx,
"spirv.VulkanBuffer", {BufferLayoutTy},
788 case llvm::dxil::ResourceClass::Sampler:
789 return llvm::TargetExtType::get(Ctx,
"spirv.Sampler");
796 const HLSLAttributedResourceType::Attributes &attributes,
797 llvm::Type *SampledType,
QualType Ty,
unsigned NumChannels) {
802 if (LangOpts.HLSLSpvUseUnknownImageFormat ||
803 attributes.ResourceClass != llvm::dxil::ResourceClass::UAV) {
807 if (SampledType->isIntegerTy(32)) {
809 if (NumChannels == 1)
811 if (NumChannels == 2)
813 if (NumChannels == 4)
816 if (NumChannels == 1)
818 if (NumChannels == 2)
820 if (NumChannels == 4)
823 }
else if (SampledType->isIntegerTy(64)) {
824 if (NumChannels == 1) {
830 }
else if (SampledType->isFloatTy()) {
831 if (NumChannels == 1)
833 if (NumChannels == 2)
835 if (NumChannels == 4)
842llvm::Type *CommonSPIRTargetCodeGenInfo::getSPIRVImageTypeFromHLSLResource(
843 const HLSLAttributedResourceType::Attributes &attributes, QualType Ty,
844 CodeGenModule &CGM)
const {
847 unsigned NumChannels = 1;
849 if (
const VectorType *
V = dyn_cast<VectorType>(Ty)) {
850 NumChannels =
V->getNumElements();
851 Ty =
V->getElementType();
853 assert(!Ty->
isVectorType() &&
"We still have a vector type.");
857 assert((SampledType->isIntegerTy() || SampledType->isFloatingPointTy()) &&
858 "The element type for a SPIR-V resource must be a scalar integer or "
859 "floating point type.");
864 SmallVector<unsigned, 6> IntParams(6, 0);
870 switch (attributes.ResourceDimension) {
871 case llvm::dxil::ResourceDimension::Dim1D:
874 case llvm::dxil::ResourceDimension::Dim2D:
877 case llvm::dxil::ResourceDimension::Dim3D:
880 case llvm::dxil::ResourceDimension::Cube:
883 case llvm::dxil::ResourceDimension::Unknown:
900 attributes.ResourceClass == llvm::dxil::ResourceClass::UAV ? 2 : 1;
906 llvm::TargetExtType *ImageType =
907 llvm::TargetExtType::get(Ctx, Name, {SampledType}, IntParams);
911std::unique_ptr<TargetCodeGenInfo>
913 return std::make_unique<CommonSPIRTargetCodeGenInfo>(CGM.
getTypes());
916std::unique_ptr<TargetCodeGenInfo>
918 return std::make_unique<SPIRVTargetCodeGenInfo>(CGM.
getTypes());
static void setCUDAKernelCallingConvention(CanQualType &FTy, CodeGenModule &CGM, const FunctionDecl *FD)
Set calling convention for CUDA/HIP kernel.
static llvm::Type * getInlineSpirvType(CodeGenModule &CGM, const HLSLInlineSpirvType *SpirvType)
static llvm::Type * getSPIRVImageType(llvm::LLVMContext &Ctx, StringRef BaseType, StringRef OpenCLName, unsigned AccessQualifier)
Construct a SPIR-V target extension type for the given OpenCL image type.
static unsigned getImageFormat(const LangOptions &LangOpts, const HLSLAttributedResourceType::Attributes &attributes, llvm::Type *SampledType, QualType Ty, unsigned NumChannels)
static llvm::Type * getInlineSpirvConstant(CodeGenModule &CGM, llvm::Type *IntegralType, llvm::APInt Value)
Defines the clang::LangOptions interface.
static StringRef getTriple(const Command &Job)
unsigned getTargetAddressSpace(LangAS AS) const
QuantityType getQuantity() const
getQuantity - Get the raw integer representation of this quantity.
static CharUnits fromQuantity(QuantityType Quantity)
fromQuantity - Construct a CharUnits quantity from a raw integer type.
static ABIArgInfo getIgnore()
static ABIArgInfo getDirect(llvm::Type *T=nullptr, unsigned Offset=0, llvm::Type *Padding=nullptr, bool CanBeFlattened=true, unsigned Align=0)
static ABIArgInfo getIndirectAliased(CharUnits Alignment, unsigned AddrSpace, bool Realign=false, llvm::Type *Padding=nullptr)
Pass this in memory using the IR byref attribute.
@ RAA_DirectInMemory
Pass it on the stack using its defined layout.
CGFunctionInfo - Class to encapsulate the information about a function definition.
ABIArgInfo & getReturnInfo()
unsigned getCallingConvention() const
getCallingConvention - Return the user specified calling convention, which has been translated into a...
CanQualType getReturnType() const
MutableArrayRef< ArgInfo > arguments()
unsigned getNumRequiredArgs() const
This class organizes the cross-function state that is used while generating LLVM code.
const LangOptions & getLangOpts() const
CodeGenTypes & getTypes()
const TargetInfo & getTarget() const
const llvm::Triple & getTriple() const
ASTContext & getContext() const
llvm::LLVMContext & getLLVMContext()
llvm::Type * ConvertType(QualType T)
ConvertType - Convert type T into a llvm::Type.
llvm::Type * ConvertTypeForMem(QualType T)
ConvertTypeForMem - Convert type T into a llvm::Type.
DefaultABIInfo - The default implementation for ABI specific details.
ABIArgInfo classifyArgumentType(QualType RetTy) const
ABIArgInfo classifyReturnType(QualType RetTy) const
TargetCodeGenInfo - This class organizes various target-specific codegeneration issues,...
Represents a member of a struct/union/class.
ExtInfo withCallingConv(CallingConv cc) const
ExtInfo getExtInfo() const
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
A (possibly-)qualified type.
bool isNull() const
Return true if this QualType doesn't point to a type yet.
LangAS getAddressSpace() const
Return the address space of this type.
bool hasFlexibleArrayMember() const
const llvm::Triple & getTriple() const
Returns the target triple of the primary target.
bool isStructureType() const
bool isSignedIntegerType() const
Return true if this is an integer type that is signed, according to C99 6.2.5p4 [char,...
RecordDecl * getAsRecordDecl() const
Retrieves the RecordDecl this type refers to.
CanQualType getCanonicalTypeUnqualified() const
QualType getPointeeType() const
If this is a pointer, ObjC object pointer, or block pointer, this returns the respective pointee.
bool isVectorType() const
const T * getAsCanonical() const
If this type is canonically the specified type, return its canonical type cast to that specified type...
const T * getAs() const
Member-template getAs<specific type>'.
const Type * getUnqualifiedDesugaredType() const
Return the specified type with any "sugar" removed from the type, removing any typedefs,...
bool isNullPtrType() const
ABIArgInfo classifyArgumentType(CodeGenModule &CGM, CanQualType type)
Classify the rules for how to pass a particular type.
@ Decl
The l-value was an access to a declared entity or something equivalently strong, like the address of ...
CGCXXABI::RecordArgABI getRecordArgABI(const RecordType *RT, CGCXXABI &CXXABI)
bool classifyReturnType(const CGCXXABI &CXXABI, CGFunctionInfo &FI, const ABIInfo &Info)
void computeSPIRKernelABIInfo(CodeGenModule &CGM, CGFunctionInfo &FI)
RValue emitVoidPtrVAArg(CodeGenFunction &CGF, Address VAListAddr, QualType ValueTy, bool IsIndirect, TypeInfoChars ValueInfo, CharUnits SlotSizeAndAlign, bool AllowHigherAlign, AggValueSlot Slot, bool ForceRightAdjust=false)
Emit va_arg for a platform using the common void* representation, where arguments are simply emitted ...
bool isAggregateTypeForABI(QualType T)
const Type * isSingleElementStruct(QualType T, ASTContext &Context)
isSingleElementStruct - Determine if a structure is a "singleelement struct", i.e.
std::unique_ptr< TargetCodeGenInfo > createSPIRVTargetCodeGenInfo(CodeGenModule &CGM)
QualType useFirstFieldIfTransparentUnion(QualType Ty)
Pass transparent unions as if they were the type of the first element.
std::unique_ptr< TargetCodeGenInfo > createCommonSPIRTargetCodeGenInfo(CodeGenModule &CGM)
bool isEmptyRecord(ASTContext &Context, QualType T, bool AllowArrays, bool AsIfNoUniqueAddr=false)
isEmptyRecord - Return true iff a structure contains only empty fields.
The JSON file list parser is used to communicate input to InstallAPI.
StorageClass
Storage classes.
@ Type
The name was classified as a type.
LangAS
Defines the address space values used by the address space qualifier of QualType.
for(const auto &A :T->param_types())
SyncScope
Defines sync scope values used internally by clang.
LangAS getLangASFromTargetAS(unsigned TargetAS)