10#include "TargetInfo.h"
12#include "llvm/ADT/StringExtras.h"
13#include "llvm/Support/AMDGPUAddrSpace.h"
26 static const unsigned MaxNumRegsForArgsRet = 16;
28 uint64_t numRegsForType(QualType Ty)
const;
30 bool isHomogeneousAggregateBaseType(QualType Ty)
const override;
31 bool isHomogeneousAggregateSmallEnough(
const Type *Base,
32 uint64_t Members)
const override;
35 llvm::Type *coerceKernelArgumentType(llvm::Type *Ty,
unsigned FromAS,
36 unsigned ToAS)
const {
38 auto *PtrTy = llvm::dyn_cast<llvm::PointerType>(Ty);
39 if (PtrTy && PtrTy->getAddressSpace() == FromAS)
40 return llvm::PointerType::get(Ty->getContext(), ToAS);
45 explicit AMDGPUABIInfo(CodeGen::CodeGenTypes &CGT) :
46 DefaultABIInfo(CGT) {}
49 ABIArgInfo classifyKernelArgumentType(QualType Ty)
const;
51 unsigned &NumRegsLeft)
const;
53 void computeInfo(CGFunctionInfo &FI)
const override;
54 RValue EmitVAArg(CodeGenFunction &CGF, Address VAListAddr, QualType Ty,
55 AggValueSlot Slot)
const override;
57 llvm::FixedVectorType *
58 getOptimalVectorMemoryType(llvm::FixedVectorType *T,
59 const LangOptions &Opt)
const override {
63 if (T->getNumElements() == 3 && getDataLayout().getTypeSizeInBits(T) == 96)
65 return DefaultABIInfo::getOptimalVectorMemoryType(T, Opt);
69bool AMDGPUABIInfo::isHomogeneousAggregateBaseType(
QualType Ty)
const {
73bool AMDGPUABIInfo::isHomogeneousAggregateSmallEnough(
74 const Type *Base, uint64_t Members)
const {
75 uint32_t NumRegs = (getContext().getTypeSize(Base) + 31) / 32;
78 return Members * NumRegs <= MaxNumRegsForArgsRet;
82uint64_t AMDGPUABIInfo::numRegsForType(QualType Ty)
const {
85 if (
const VectorType *VT = Ty->
getAs<VectorType>()) {
88 QualType EltTy = VT->getElementType();
89 uint64_t EltSize = getContext().getTypeSize(EltTy);
93 return (VT->getNumElements() + 1) / 2;
95 uint64_t EltNumRegs = (EltSize + 31) / 32;
96 return EltNumRegs * VT->getNumElements();
100 assert(!RD->hasFlexibleArrayMember());
102 for (
const FieldDecl *Field : RD->fields()) {
103 QualType FieldTy =
Field->getType();
104 NumRegs += numRegsForType(FieldTy);
110 return (getContext().getTypeSize(Ty) + 31) / 32;
113void AMDGPUABIInfo::computeInfo(CGFunctionInfo &FI)
const {
119 unsigned ArgumentIndex = 0;
122 unsigned NumRegsLeft = MaxNumRegsForArgsRet;
124 if (CC == llvm::CallingConv::AMDGPU_KERNEL) {
125 Arg.info = classifyKernelArgumentType(Arg.type);
127 bool FixedArgument = ArgumentIndex++ < numFixedArguments;
133RValue AMDGPUABIInfo::EmitVAArg(CodeGenFunction &CGF, Address VAListAddr,
134 QualType Ty, AggValueSlot Slot)
const {
135 const bool IsIndirect =
false;
136 const bool AllowHigherAlign =
false;
138 getContext().getTypeInfoInChars(Ty),
142ABIArgInfo AMDGPUABIInfo::classifyReturnType(QualType RetTy)
const {
168 llvm::Type *I32Ty = llvm::Type::getInt32Ty(getVMContext());
172 if (numRegsForType(RetTy) <= MaxNumRegsForArgsRet)
183ABIArgInfo AMDGPUABIInfo::classifyKernelArgumentType(QualType Ty)
const {
189 Ty = QualType(SeltTy, 0);
191 llvm::Type *OrigLTy = CGT.ConvertType(Ty);
192 llvm::Type *LTy = OrigLTy;
193 if (getContext().getLangOpts().
HIP) {
194 LTy = coerceKernelArgumentType(
195 OrigLTy, getContext().getTargetAddressSpace(LangAS::Default),
196 getContext().getTargetAddressSpace(LangAS::cuda_device));
204 getContext().getTypeAlignInChars(Ty),
205 getContext().getTargetAddressSpace(LangAS::opencl_constant),
215ABIArgInfo AMDGPUABIInfo::classifyArgumentType(QualType Ty,
bool Variadic,
216 unsigned &NumRegsLeft)
const {
217 assert(NumRegsLeft <= MaxNumRegsForArgsRet &&
"register estimate underflow");
233 return getNaturalAlignIndirect(Ty, getDataLayout().getAllocaAddrSpace(),
253 unsigned NumRegs = (
Size + 31) / 32;
254 NumRegsLeft -= std::min(NumRegsLeft, NumRegs);
263 llvm::Type *I32Ty = llvm::Type::getInt32Ty(getVMContext());
267 if (NumRegsLeft > 0) {
268 uint64_t NumRegs = numRegsForType(Ty);
269 if (NumRegsLeft >= NumRegs) {
270 NumRegsLeft -= NumRegs;
278 getContext().getTypeAlignInChars(Ty),
279 getContext().getTargetAddressSpace(LangAS::opencl_private));
285 uint64_t NumRegs = numRegsForType(Ty);
286 NumRegsLeft -= std::min(NumRegs, uint64_t{NumRegsLeft});
292class AMDGPUTargetCodeGenInfo :
public TargetCodeGenInfo {
294 AMDGPUTargetCodeGenInfo(CodeGenTypes &CGT)
295 : TargetCodeGenInfo(std::make_unique<AMDGPUABIInfo>(CGT)) {}
297 bool supportsLibCall()
const override {
return false; }
298 void setFunctionDeclAttributes(
const FunctionDecl *FD, llvm::Function *F,
299 CodeGenModule &CGM)
const;
301 void setTargetAttributes(
const Decl *D, llvm::GlobalValue *GV,
302 CodeGen::CodeGenModule &M)
const override;
303 unsigned getDeviceKernelCallingConv()
const override;
305 llvm::Constant *getNullPointer(
const CodeGen::CodeGenModule &CGM,
306 llvm::PointerType *T, QualType QT)
const override;
308 LangAS getSRetAddrSpace(
const CXXRecordDecl *RD)
const override;
310 LangAS getGlobalVarAddressSpace(CodeGenModule &CGM,
311 const VarDecl *D)
const override;
312 StringRef getLLVMSyncScopeStr(
const LangOptions &LangOpts,
SyncScope Scope,
313 llvm::AtomicOrdering Ordering)
const override;
314 void setTargetAtomicMetadata(CodeGenFunction &CGF,
315 llvm::Instruction &AtomicInst,
316 const AtomicExpr *Expr =
nullptr)
const override;
317 llvm::Value *createEnqueuedBlockKernel(CodeGenFunction &CGF,
318 llvm::Function *BlockInvokeFunc,
319 llvm::Type *BlockTy)
const override;
320 bool shouldEmitStaticExternCAliases()
const override;
321 bool shouldEmitDWARFBitFieldSeparators()
const override;
327 llvm::GlobalValue *GV) {
328 if (GV->getVisibility() != llvm::GlobalValue::HiddenVisibility)
331 return !D->
hasAttr<OMPDeclareTargetDeclAttr>() &&
332 (D->
hasAttr<DeviceKernelAttr>() ||
335 (D->
hasAttr<CUDADeviceAttr>() || D->
hasAttr<CUDAConstantAttr>() ||
336 cast<VarDecl>(D)->getType()->isCUDADeviceBuiltinSurfaceType() ||
337 cast<VarDecl>(D)->getType()->isCUDADeviceBuiltinTextureType())));
340void AMDGPUTargetCodeGenInfo::setFunctionDeclAttributes(
341 const FunctionDecl *FD, llvm::Function *F, CodeGenModule &M)
const {
342 const auto *ReqdWGS =
344 const bool IsOpenCLKernel =
348 const auto *FlatWGS = FD->
getAttr<AMDGPUFlatWorkGroupSizeAttr>();
349 if (ReqdWGS || FlatWGS) {
351 }
else if (IsOpenCLKernel || IsHIPKernel) {
354 const unsigned OpenCLDefaultMaxWorkGroupSize = 256;
355 const unsigned DefaultMaxWorkGroupSize =
356 IsOpenCLKernel ? OpenCLDefaultMaxWorkGroupSize
358 std::string AttrVal =
359 std::string(
"1,") + llvm::utostr(DefaultMaxWorkGroupSize);
360 F->addFnAttr(
"amdgpu-flat-work-group-size", AttrVal);
363 if (
const auto *Attr = FD->
getAttr<AMDGPUWavesPerEUAttr>())
366 if (
const auto *Attr = FD->
getAttr<AMDGPUNumSGPRAttr>()) {
367 unsigned NumSGPR = Attr->getNumSGPR();
370 F->addFnAttr(
"amdgpu-num-sgpr", llvm::utostr(NumSGPR));
373 if (
const auto *Attr = FD->
getAttr<AMDGPUNumVGPRAttr>()) {
374 uint32_t NumVGPR = Attr->getNumVGPR();
377 F->addFnAttr(
"amdgpu-num-vgpr", llvm::utostr(NumVGPR));
380 if (
const auto *Attr = FD->
getAttr<AMDGPUMaxNumWorkGroupsAttr>()) {
381 uint32_t X = Attr->getMaxNumWorkGroupsX()
385 uint32_t Y = Attr->getMaxNumWorkGroupsY()
386 ? Attr->getMaxNumWorkGroupsY()
390 uint32_t Z = Attr->getMaxNumWorkGroupsZ()
391 ? Attr->getMaxNumWorkGroupsZ()
396 llvm::SmallString<32> AttrVal;
397 llvm::raw_svector_ostream
OS(AttrVal);
398 OS <<
X <<
',' << Y <<
',' << Z;
400 F->addFnAttr(
"amdgpu-max-num-workgroups", AttrVal.str());
403 if (
auto *Attr = FD->
getAttr<CUDAClusterDimsAttr>()) {
404 auto GetExprVal = [&](
const auto &E) {
405 return E ? E->EvaluateKnownConstInt(M.
getContext()).getExtValue() : 1;
407 unsigned X = GetExprVal(Attr->getX());
408 unsigned Y = GetExprVal(Attr->getY());
409 unsigned Z = GetExprVal(Attr->getZ());
410 llvm::SmallString<32> AttrVal;
411 llvm::raw_svector_ostream
OS(AttrVal);
412 OS <<
X <<
',' << Y <<
',' << Z;
413 F->addFnAttr(
"amdgpu-cluster-dims", AttrVal.str());
418 if ((IsOpenCLKernel &&
420 FD->
hasAttr<CUDANoClusterAttr>())
421 F->addFnAttr(
"amdgpu-cluster-dims",
"0,0,0");
424void AMDGPUTargetCodeGenInfo::setTargetAttributes(
425 const Decl *D, llvm::GlobalValue *GV, CodeGen::CodeGenModule &M)
const {
427 GV->setVisibility(llvm::GlobalValue::ProtectedVisibility);
428 GV->setDSOLocal(
true);
431 if (GV->isDeclaration())
434 llvm::Function *F = dyn_cast<llvm::Function>(GV);
438 const FunctionDecl *FD = dyn_cast_or_null<FunctionDecl>(D);
440 setFunctionDeclAttributes(FD, F, M);
441 if (!getABIInfo().getCodeGenOpts().EmitIEEENaNCompliantInsts)
442 F->addFnAttr(
"amdgpu-ieee",
"false");
443 if (getABIInfo().getCodeGenOpts().AMDGPUExpandWaitcntProfiling)
444 F->addFnAttr(
"amdgpu-expand-waitcnt-profiling");
447unsigned AMDGPUTargetCodeGenInfo::getDeviceKernelCallingConv()
const {
448 return llvm::CallingConv::AMDGPU_KERNEL;
456llvm::Constant *AMDGPUTargetCodeGenInfo::getNullPointer(
457 const CodeGen::CodeGenModule &CGM, llvm::PointerType *PT,
460 return llvm::ConstantPointerNull::get(PT);
463 auto NPT = llvm::PointerType::get(
464 PT->getContext(), Ctx.getTargetAddressSpace(LangAS::opencl_generic));
465 return llvm::ConstantExpr::getAddrSpaceCast(
466 llvm::ConstantPointerNull::get(NPT), PT);
470AMDGPUTargetCodeGenInfo::getSRetAddrSpace(
const CXXRecordDecl *RD)
const {
474 return LangAS::Default;
476 getABIInfo().getDataLayout().getAllocaAddrSpace());
480AMDGPUTargetCodeGenInfo::getGlobalVarAddressSpace(CodeGenModule &CGM,
481 const VarDecl *D)
const {
484 "Address space agnostic languages only");
488 return DefaultGlobalAS;
491 if (AddrSpace != LangAS::Default)
500 return DefaultGlobalAS;
503StringRef AMDGPUTargetCodeGenInfo::getLLVMSyncScopeStr(
504 const LangOptions &LangOpts,
SyncScope Scope,
505 llvm::AtomicOrdering Ordering)
const {
509 bool IsOneAs = (Scope >= SyncScope::OpenCLWorkGroup &&
510 Scope <= SyncScope::OpenCLSubGroup &&
511 Ordering != llvm::AtomicOrdering::SequentiallyConsistent);
514 case SyncScope::HIPSingleThread:
515 case SyncScope::SingleScope:
516 return IsOneAs ?
"singlethread-one-as" :
"singlethread";
517 case SyncScope::HIPWavefront:
518 case SyncScope::OpenCLSubGroup:
519 case SyncScope::WavefrontScope:
520 return IsOneAs ?
"wavefront-one-as" :
"wavefront";
521 case SyncScope::HIPCluster:
522 case SyncScope::ClusterScope:
523 assert(!IsOneAs &&
"OpenCL does not have cluster scope");
525 case SyncScope::HIPWorkgroup:
526 case SyncScope::OpenCLWorkGroup:
527 case SyncScope::WorkgroupScope:
528 return IsOneAs ?
"workgroup-one-as" :
"workgroup";
529 case SyncScope::HIPAgent:
530 case SyncScope::OpenCLDevice:
531 case SyncScope::DeviceScope:
532 return IsOneAs ?
"agent-one-as" :
"agent";
533 case SyncScope::SystemScope:
534 case SyncScope::HIPSystem:
535 case SyncScope::OpenCLAllSVMDevices:
536 return IsOneAs ?
"one-as" :
"";
538 llvm_unreachable(
"Unknown SyncScope enum");
541void AMDGPUTargetCodeGenInfo::setTargetAtomicMetadata(
542 CodeGenFunction &CGF, llvm::Instruction &AtomicInst,
543 const AtomicExpr *AE)
const {
544 auto *RMW = dyn_cast<llvm::AtomicRMWInst>(&AtomicInst);
545 auto *CmpX = dyn_cast<llvm::AtomicCmpXchgInst>(&AtomicInst);
552 if (((RMW && RMW->getPointerAddressSpace() == llvm::AMDGPUAS::FLAT_ADDRESS) ||
554 CmpX->getPointerAddressSpace() == llvm::AMDGPUAS::FLAT_ADDRESS)) &&
557 llvm::MDNode *ASRange = MDHelper.createRange(
558 llvm::APInt(32, llvm::AMDGPUAS::PRIVATE_ADDRESS),
559 llvm::APInt(32, llvm::AMDGPUAS::PRIVATE_ADDRESS + 1));
560 AtomicInst.setMetadata(llvm::LLVMContext::MD_noalias_addrspace, ASRange);
569 RMW->setMetadata(
"amdgpu.no.fine.grained.memory",
Empty);
571 RMW->setMetadata(
"amdgpu.no.remote.memory",
Empty);
573 RMW->getOperation() == llvm::AtomicRMWInst::FAdd &&
574 RMW->getType()->isFloatTy())
575 RMW->setMetadata(
"amdgpu.ignore.denormal.mode",
Empty);
578bool AMDGPUTargetCodeGenInfo::shouldEmitStaticExternCAliases()
const {
582bool AMDGPUTargetCodeGenInfo::shouldEmitDWARFBitFieldSeparators()
const {
586void AMDGPUTargetCodeGenInfo::setCUDAKernelCallingConvention(
587 const FunctionType *&FT)
const {
588 FT = getABIInfo().getContext().adjustFunctionType(
598static llvm::StructType *
600 llvm::Type *KernelDescriptorPtrTy) {
601 llvm::Type *Int32 = llvm::Type::getInt32Ty(
C);
602 return llvm::StructType::create(
C, {KernelDescriptorPtrTy, Int32, Int32},
603 "block.runtime.handle.t");
614llvm::Value *AMDGPUTargetCodeGenInfo::createEnqueuedBlockKernel(
615 CodeGenFunction &CGF, llvm::Function *Invoke, llvm::Type *BlockTy)
const {
619 auto *InvokeFT = Invoke->getFunctionType();
620 llvm::SmallVector<llvm::Type *, 2> ArgTys;
621 llvm::SmallVector<llvm::Metadata *, 8> AddressQuals;
622 llvm::SmallVector<llvm::Metadata *, 8> AccessQuals;
623 llvm::SmallVector<llvm::Metadata *, 8> ArgTypeNames;
624 llvm::SmallVector<llvm::Metadata *, 8> ArgBaseTypeNames;
625 llvm::SmallVector<llvm::Metadata *, 8> ArgTypeQuals;
626 llvm::SmallVector<llvm::Metadata *, 8> ArgNames;
628 ArgTys.push_back(BlockTy);
629 ArgTypeNames.push_back(llvm::MDString::get(
C,
"__block_literal"));
630 AddressQuals.push_back(llvm::ConstantAsMetadata::get(Builder.getInt32(0)));
631 ArgBaseTypeNames.push_back(llvm::MDString::get(
C,
"__block_literal"));
632 ArgTypeQuals.push_back(llvm::MDString::get(
C,
""));
633 AccessQuals.push_back(llvm::MDString::get(
C,
"none"));
634 ArgNames.push_back(llvm::MDString::get(
C,
"block_literal"));
635 for (
unsigned I = 1, E = InvokeFT->getNumParams(); I < E; ++I) {
636 ArgTys.push_back(InvokeFT->getParamType(I));
637 ArgTypeNames.push_back(llvm::MDString::get(
C,
"void*"));
638 AddressQuals.push_back(llvm::ConstantAsMetadata::get(Builder.getInt32(3)));
639 AccessQuals.push_back(llvm::MDString::get(
C,
"none"));
640 ArgBaseTypeNames.push_back(llvm::MDString::get(
C,
"void*"));
641 ArgTypeQuals.push_back(llvm::MDString::get(
C,
""));
643 llvm::MDString::get(
C, (Twine(
"local_arg") + Twine(I)).str()));
647 const llvm::DataLayout &DL = Mod.getDataLayout();
649 llvm::Twine Name = Invoke->getName() +
"_kernel";
650 auto *FT = llvm::FunctionType::get(llvm::Type::getVoidTy(
C), ArgTys,
false);
654 auto *F = llvm::Function::Create(FT, llvm::GlobalValue::InternalLinkage, Name,
656 F->setCallingConv(getDeviceKernelCallingConv());
658 llvm::AttrBuilder KernelAttrs(
C);
662 F->addFnAttrs(KernelAttrs);
664 auto IP = CGF.
Builder.saveIP();
665 auto *BB = llvm::BasicBlock::Create(
C,
"entry", F);
666 Builder.SetInsertPoint(BB);
667 const auto BlockAlign = DL.getPrefTypeAlign(BlockTy);
668 auto *BlockPtr = Builder.CreateAlloca(BlockTy,
nullptr);
669 BlockPtr->setAlignment(BlockAlign);
670 Builder.CreateAlignedStore(F->arg_begin(), BlockPtr, BlockAlign);
671 auto *
Cast = Builder.CreatePointerCast(BlockPtr, InvokeFT->getParamType(0));
672 llvm::SmallVector<llvm::Value *, 2> Args;
673 Args.push_back(Cast);
674 for (llvm::Argument &A : llvm::drop_begin(F->args()))
676 llvm::CallInst *call = Builder.CreateCall(Invoke, Args);
677 call->setCallingConv(Invoke->getCallingConv());
678 Builder.CreateRetVoid();
679 Builder.restoreIP(IP);
681 F->setMetadata(
"kernel_arg_addr_space", llvm::MDNode::get(
C, AddressQuals));
682 F->setMetadata(
"kernel_arg_access_qual", llvm::MDNode::get(
C, AccessQuals));
683 F->setMetadata(
"kernel_arg_type", llvm::MDNode::get(
C, ArgTypeNames));
684 F->setMetadata(
"kernel_arg_base_type",
685 llvm::MDNode::get(
C, ArgBaseTypeNames));
686 F->setMetadata(
"kernel_arg_type_qual", llvm::MDNode::get(
C, ArgTypeQuals));
688 F->setMetadata(
"kernel_arg_name", llvm::MDNode::get(
C, ArgNames));
691 C, llvm::PointerType::get(
C, DL.getDefaultGlobalsAddressSpace()));
692 llvm::Constant *RuntimeHandleInitializer =
693 llvm::ConstantAggregateZero::get(HandleTy);
695 llvm::Twine RuntimeHandleName = F->getName() +
".runtime.handle";
706 auto *RuntimeHandle =
new llvm::GlobalVariable(
708 true, llvm::GlobalValue::InternalLinkage,
709 RuntimeHandleInitializer, RuntimeHandleName,
710 nullptr, llvm::GlobalValue::NotThreadLocal,
711 DL.getDefaultGlobalsAddressSpace(),
714 llvm::MDNode *HandleAsMD =
715 llvm::MDNode::get(
C, llvm::ValueAsMetadata::get(RuntimeHandle));
716 F->setMetadata(llvm::LLVMContext::MD_associated, HandleAsMD);
718 RuntimeHandle->setSection(
".amdgpu.kernel.runtime.handle");
722 return RuntimeHandle;
726 llvm::Function *F,
const AMDGPUFlatWorkGroupSizeAttr *FlatWGS,
727 const ReqdWorkGroupSizeAttr *ReqdWGS, int32_t *MinThreadsVal,
728 int32_t *MaxThreadsVal) {
731 auto Eval = [&](
Expr *E) {
732 return E->EvaluateKnownConstInt(
getContext()).getExtValue();
735 Min = Eval(FlatWGS->getMin());
736 Max = Eval(FlatWGS->getMax());
738 if (ReqdWGS &&
Min == 0 &&
Max == 0)
739 Min =
Max = Eval(ReqdWGS->getXDim()) * Eval(ReqdWGS->getYDim()) *
740 Eval(ReqdWGS->getZDim());
743 assert(
Min <=
Max &&
"Min must be less than or equal Max");
746 *MinThreadsVal =
Min;
748 *MaxThreadsVal =
Max;
749 std::string AttrVal = llvm::utostr(
Min) +
"," + llvm::utostr(
Max);
751 F->addFnAttr(
"amdgpu-flat-work-group-size", AttrVal);
753 assert(
Max == 0 &&
"Max must be zero");
757 llvm::Function *F,
const AMDGPUWavesPerEUAttr *
Attr) {
759 Attr->getMin()->EvaluateKnownConstInt(
getContext()).getExtValue();
762 ?
Attr->getMax()->EvaluateKnownConstInt(
getContext()).getExtValue()
766 assert((
Max == 0 ||
Min <=
Max) &&
"Min must be less than or equal Max");
768 std::string AttrVal = llvm::utostr(
Min);
770 AttrVal = AttrVal +
"," + llvm::utostr(
Max);
771 F->addFnAttr(
"amdgpu-waves-per-eu", AttrVal);
773 assert(
Max == 0 &&
"Max must be zero");
776std::unique_ptr<TargetCodeGenInfo>
778 return std::make_unique<AMDGPUTargetCodeGenInfo>(CGM.
getTypes());
static void setCUDAKernelCallingConvention(CanQualType &FTy, CodeGenModule &CGM, const FunctionDecl *FD)
Set calling convention for CUDA/HIP kernel.
static bool requiresAMDGPUProtectedVisibility(const Decl *D, llvm::GlobalValue *GV)
static llvm::StructType * getAMDGPURuntimeHandleType(llvm::LLVMContext &C, llvm::Type *KernelDescriptorPtrTy)
Return IR struct type for rtinfo struct in rocm-device-libs used for device enqueue.
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate....
uint64_t getTargetNullPointerValue(QualType QT) const
Get target-dependent integer value for null pointer which is used for constant folding.
const TargetInfo & getTargetInfo() const
unsigned getTargetAddressSpace(LangAS AS) const
bool threadPrivateMemoryAtomicsAreUndefined() const
Return true if atomics operations targeting allocations in private memory are undefined.
Attr - This represents one attribute.
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.
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.
llvm::Module & getModule() const
void handleAMDGPUWavesPerEUAttr(llvm::Function *F, const AMDGPUWavesPerEUAttr *A)
Emit the IR encoding to attach the AMD GPU waves-per-eu attribute to F.
const LangOptions & getLangOpts() const
CodeGenTypes & getTypes()
const TargetInfo & getTarget() const
void addUsedGlobal(llvm::GlobalValue *GV)
Add a global to a list to be added to the llvm.used metadata.
void handleAMDGPUFlatWorkGroupSizeAttr(llvm::Function *F, const AMDGPUFlatWorkGroupSizeAttr *A, const ReqdWorkGroupSizeAttr *ReqdWGS=nullptr, int32_t *MinThreadsVal=nullptr, int32_t *MaxThreadsVal=nullptr)
Emit the IR encoding to attach the AMD GPU flat-work-group-size attribute to F.
AtomicOptions getAtomicOpts()
Get the current Atomic options.
ASTContext & getContext() const
const CodeGenOptions & getCodeGenOpts() const
void addDefaultFunctionDefinitionAttributes(llvm::AttrBuilder &attrs)
Like the overload taking a Function &, but intended specifically for frontends that want to build on ...
DefaultABIInfo - The default implementation for ABI specific details.
ABIArgInfo classifyArgumentType(QualType RetTy) const
ABIArgInfo classifyReturnType(QualType RetTy) const
Decl - This represents one declaration (or definition), e.g.
This represents one expression.
ExtInfo withCallingConv(CallingConv cc) const
ExtInfo getExtInfo() const
A (possibly-)qualified type.
LangAS getAddressSpace() const
Return the address space of this type.
bool isConstantStorage(const ASTContext &Ctx, bool ExcludeCtor, bool ExcludeDtor)
bool canPassInRegisters() const
Determine whether this class can be passed in registers.
bool hasFlexibleArrayMember() const
TargetOptions & getTargetOpts() const
Retrieve the target options.
virtual std::optional< LangAS > getConstantAddressSpace() const
Return an AST address space which can be used opportunistically for constant global memory.
virtual bool hasFeatureEnabled(const llvm::StringMap< bool > &Features, StringRef Name) const
Check if target has a given feature enabled.
llvm::StringMap< bool > FeatureMap
The map of which features have been enabled disabled based on the command line.
RecordDecl * getAsRecordDecl() const
Retrieves the RecordDecl this type refers to.
const T * getAs() const
Member-template getAs<specific type>'.
bool hasConstantInitialization() const
Determine whether this variable has constant initialization.
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)
std::unique_ptr< TargetCodeGenInfo > createAMDGPUTargetCodeGenInfo(CodeGenModule &CGM)
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.
QualType useFirstFieldIfTransparentUnion(QualType Ty)
Pass transparent unions as if they were the type of the first element.
bool isEmptyRecord(ASTContext &Context, QualType T, bool AllowArrays, bool AsIfNoUniqueAddr=false)
isEmptyRecord - Return true iff a structure contains only empty fields.
@ OS
Indicates that the tracking object is a descendant of a referenced-counted OSObject,...
bool Cast(InterpState &S, CodePtr OpPC)
The JSON file list parser is used to communicate input to InstallAPI.
bool isa(CodeGen::Address addr)
nullptr
This class represents a compute construct, representing a 'Kind' of ‘parallel’, 'serial',...
@ Type
The name was classified as a type.
LangAS
Defines the address space values used by the address space qualifier of QualType.
SyncScope
Defines sync scope values used internally by clang.
U cast(CodeGen::Address addr)
LangAS getLangASFromTargetAS(unsigned TargetAS)
bool getOption(AtomicOptionKind Kind) const