10#include "TargetInfo.h"
12#include "llvm/ADT/StringExtras.h"
13#include "llvm/IR/LLVMContext.h"
14#include "llvm/IR/MemoryModelRelaxationAnnotations.h"
15#include "llvm/Support/AMDGPUAddrSpace.h"
28 static const unsigned MaxNumRegsForArgsRet = 16;
30 uint64_t numRegsForType(QualType Ty)
const;
32 bool isHomogeneousAggregateBaseType(QualType Ty)
const override;
33 bool isHomogeneousAggregateSmallEnough(
const Type *Base,
34 uint64_t Members)
const override;
37 llvm::Type *coerceKernelArgumentType(llvm::Type *Ty,
unsigned FromAS,
38 unsigned ToAS)
const {
40 auto *PtrTy = llvm::dyn_cast<llvm::PointerType>(Ty);
41 if (PtrTy && PtrTy->getAddressSpace() == FromAS)
42 return llvm::PointerType::get(Ty->getContext(), ToAS);
47 explicit AMDGPUABIInfo(CodeGen::CodeGenTypes &CGT) :
48 DefaultABIInfo(CGT) {}
51 ABIArgInfo classifyKernelArgumentType(QualType Ty)
const;
53 unsigned &NumRegsLeft)
const;
55 void computeInfo(CGFunctionInfo &FI)
const override;
56 RValue EmitVAArg(CodeGenFunction &CGF, Address VAListAddr, QualType Ty,
57 AggValueSlot Slot)
const override;
59 llvm::FixedVectorType *
60 getOptimalVectorMemoryType(llvm::FixedVectorType *
T,
61 const LangOptions &Opt)
const override {
65 if (
T->getNumElements() == 3 && getDataLayout().getTypeSizeInBits(
T) == 96)
67 return DefaultABIInfo::getOptimalVectorMemoryType(
T, Opt);
71bool AMDGPUABIInfo::isHomogeneousAggregateBaseType(
QualType Ty)
const {
75bool AMDGPUABIInfo::isHomogeneousAggregateSmallEnough(
76 const Type *Base, uint64_t Members)
const {
77 uint32_t NumRegs = (getContext().getTypeSize(Base) + 31) / 32;
80 return Members * NumRegs <= MaxNumRegsForArgsRet;
84uint64_t AMDGPUABIInfo::numRegsForType(QualType Ty)
const {
87 if (
const VectorType *VT = Ty->
getAs<VectorType>()) {
90 QualType EltTy = VT->getElementType();
91 uint64_t EltSize = getContext().getTypeSize(EltTy);
95 return (VT->getNumElements() + 1) / 2;
97 uint64_t EltNumRegs = (EltSize + 31) / 32;
98 return EltNumRegs * VT->getNumElements();
102 assert(!RD->hasFlexibleArrayMember());
104 for (
const FieldDecl *Field : RD->fields()) {
105 QualType FieldTy =
Field->getType();
106 NumRegs += numRegsForType(FieldTy);
112 return (getContext().getTypeSize(Ty) + 31) / 32;
115void AMDGPUABIInfo::computeInfo(CGFunctionInfo &FI)
const {
121 unsigned ArgumentIndex = 0;
124 unsigned NumRegsLeft = MaxNumRegsForArgsRet;
126 if (CC == llvm::CallingConv::AMDGPU_KERNEL) {
127 Arg.info = classifyKernelArgumentType(Arg.type);
129 bool FixedArgument = ArgumentIndex++ < numFixedArguments;
135RValue AMDGPUABIInfo::EmitVAArg(CodeGenFunction &CGF, Address VAListAddr,
136 QualType Ty, AggValueSlot Slot)
const {
137 const bool IsIndirect =
false;
138 const bool AllowHigherAlign =
false;
140 getContext().getTypeInfoInChars(Ty),
144ABIArgInfo AMDGPUABIInfo::classifyReturnType(QualType RetTy)
const {
170 llvm::Type *I32Ty = llvm::Type::getInt32Ty(getVMContext());
174 if (numRegsForType(RetTy) <= MaxNumRegsForArgsRet)
185ABIArgInfo AMDGPUABIInfo::classifyKernelArgumentType(QualType Ty)
const {
191 Ty = QualType(SeltTy, 0);
193 llvm::Type *OrigLTy = CGT.ConvertType(Ty);
194 llvm::Type *LTy = OrigLTy;
195 if (getContext().getLangOpts().
HIP) {
196 LTy = coerceKernelArgumentType(
197 OrigLTy, getContext().getTargetAddressSpace(LangAS::Default),
198 getContext().getTargetAddressSpace(LangAS::cuda_device));
206 getContext().getTypeAlignInChars(Ty),
207 getContext().getTargetAddressSpace(LangAS::opencl_constant),
217ABIArgInfo AMDGPUABIInfo::classifyArgumentType(QualType Ty,
bool Variadic,
218 unsigned &NumRegsLeft)
const {
219 assert(NumRegsLeft <= MaxNumRegsForArgsRet &&
"register estimate underflow");
235 return getNaturalAlignIndirect(Ty, getDataLayout().getAllocaAddrSpace(),
255 unsigned NumRegs = (
Size + 31) / 32;
256 NumRegsLeft -= std::min(NumRegsLeft, NumRegs);
265 llvm::Type *I32Ty = llvm::Type::getInt32Ty(getVMContext());
269 if (NumRegsLeft > 0) {
270 uint64_t NumRegs = numRegsForType(Ty);
271 if (NumRegsLeft >= NumRegs) {
272 NumRegsLeft -= NumRegs;
280 getContext().getTypeAlignInChars(Ty),
281 getContext().getTargetAddressSpace(LangAS::opencl_private));
287 uint64_t NumRegs = numRegsForType(Ty);
288 NumRegsLeft -= std::min(NumRegs, uint64_t{NumRegsLeft});
294class AMDGPUTargetCodeGenInfo :
public TargetCodeGenInfo {
296 AMDGPUTargetCodeGenInfo(CodeGenTypes &CGT)
297 : TargetCodeGenInfo(std::make_unique<AMDGPUABIInfo>(CGT)) {}
299 bool supportsLibCall()
const override {
return false; }
300 void setFunctionDeclAttributes(
const FunctionDecl *FD, llvm::Function *F,
301 CodeGenModule &CGM)
const;
303 void setTargetAttributes(
const Decl *D, llvm::GlobalValue *GV,
304 CodeGen::CodeGenModule &M)
const override;
305 unsigned getDeviceKernelCallingConv()
const override;
307 llvm::Constant *getNullPointer(
const CodeGen::CodeGenModule &CGM,
308 llvm::PointerType *
T, QualType QT)
const override;
310 LangAS getSRetAddrSpace(
const CXXRecordDecl *RD)
const override;
312 LangAS getGlobalVarAddressSpace(CodeGenModule &CGM,
313 const VarDecl *D)
const override;
314 StringRef getLLVMSyncScopeStr(
const LangOptions &LangOpts,
SyncScope Scope,
315 llvm::AtomicOrdering Ordering)
const override;
316 void setTargetAtomicMetadata(CodeGenFunction &CGF,
317 llvm::Instruction &AtomicInst,
318 const AtomicExpr *Expr =
nullptr)
const override;
319 llvm::Value *createEnqueuedBlockKernel(CodeGenFunction &CGF,
320 llvm::Function *BlockInvokeFunc,
321 llvm::Type *BlockTy)
const override;
322 bool shouldEmitStaticExternCAliases()
const override;
323 bool shouldEmitDWARFBitFieldSeparators()
const override;
329 llvm::GlobalValue *GV) {
330 if (GV->getVisibility() != llvm::GlobalValue::HiddenVisibility)
333 return !D->
hasAttr<OMPDeclareTargetDeclAttr>() &&
334 (D->
hasAttr<DeviceKernelAttr>() ||
337 (D->
hasAttr<CUDADeviceAttr>() || D->
hasAttr<CUDAConstantAttr>() ||
338 cast<VarDecl>(D)->getType()->isCUDADeviceBuiltinSurfaceType() ||
339 cast<VarDecl>(D)->getType()->isCUDADeviceBuiltinTextureType())));
342void AMDGPUTargetCodeGenInfo::setFunctionDeclAttributes(
343 const FunctionDecl *FD, llvm::Function *F, CodeGenModule &M)
const {
344 const auto *ReqdWGS =
346 const bool IsOpenCLKernel =
350 const auto *FlatWGS = FD->
getAttr<AMDGPUFlatWorkGroupSizeAttr>();
356 const auto *LaunchBounds =
358 unsigned LBMaxThreads = 0;
359 unsigned LBMinWaves = 0;
361 LBMaxThreads = LaunchBounds->getMaxThreads()
364 if (
const Expr *MinBlocks = LaunchBounds->getMinBlocks()) {
366 MinBlocks->EvaluateKnownConstInt(M.
getContext()).getExtValue();
370 if (ReqdWGS || FlatWGS) {
372 }
else if (LBMaxThreads > 0) {
373 F->addFnAttr(
"amdgpu-flat-work-group-size",
374 "1," + llvm::utostr(LBMaxThreads));
375 }
else if (IsOpenCLKernel || IsHIPKernel) {
378 const unsigned OpenCLDefaultMaxWorkGroupSize = 256;
379 const unsigned DefaultMaxWorkGroupSize =
380 IsOpenCLKernel ? OpenCLDefaultMaxWorkGroupSize
382 std::string AttrVal =
383 std::string(
"1,") + llvm::utostr(DefaultMaxWorkGroupSize);
384 F->addFnAttr(
"amdgpu-flat-work-group-size", AttrVal);
387 if (
const auto *Attr = FD->
getAttr<AMDGPUWavesPerEUAttr>()) {
389 }
else if (LBMinWaves > 0) {
394 F->addFnAttr(
"amdgpu-waves-per-eu", llvm::utostr(LBMinWaves));
397 if (
const auto *Attr = FD->
getAttr<AMDGPUNumSGPRAttr>()) {
398 unsigned NumSGPR = Attr->getNumSGPR();
401 F->addFnAttr(
"amdgpu-num-sgpr", llvm::utostr(NumSGPR));
404 if (
const auto *Attr = FD->
getAttr<AMDGPUNumVGPRAttr>()) {
405 uint32_t NumVGPR = Attr->getNumVGPR();
408 F->addFnAttr(
"amdgpu-num-vgpr", llvm::utostr(NumVGPR));
411 if (
const auto *Attr = FD->
getAttr<AMDGPUMaxNumWorkGroupsAttr>()) {
412 uint32_t X = Attr->getMaxNumWorkGroupsX()
416 uint32_t Y = Attr->getMaxNumWorkGroupsY()
417 ? Attr->getMaxNumWorkGroupsY()
421 uint32_t Z = Attr->getMaxNumWorkGroupsZ()
422 ? Attr->getMaxNumWorkGroupsZ()
427 llvm::SmallString<32> AttrVal;
428 llvm::raw_svector_ostream
OS(AttrVal);
429 OS <<
X <<
',' << Y <<
',' << Z;
431 F->addFnAttr(
"amdgpu-max-num-workgroups", AttrVal.str());
434 if (
auto *Attr = FD->
getAttr<CUDAClusterDimsAttr>()) {
435 auto GetExprVal = [&](
const auto &E) {
436 return E ? E->EvaluateKnownConstInt(M.
getContext()).getExtValue() : 1;
438 unsigned X = GetExprVal(Attr->getX());
439 unsigned Y = GetExprVal(Attr->getY());
440 unsigned Z = GetExprVal(Attr->getZ());
441 llvm::SmallString<32> AttrVal;
442 llvm::raw_svector_ostream
OS(AttrVal);
443 OS <<
X <<
',' << Y <<
',' << Z;
444 F->addFnAttr(
"amdgpu-cluster-dims", AttrVal.str());
449 if ((IsOpenCLKernel &&
451 FD->
hasAttr<CUDANoClusterAttr>())
452 F->addFnAttr(
"amdgpu-cluster-dims",
"0,0,0");
455void AMDGPUTargetCodeGenInfo::setTargetAttributes(
456 const Decl *D, llvm::GlobalValue *GV, CodeGen::CodeGenModule &M)
const {
458 GV->setVisibility(llvm::GlobalValue::ProtectedVisibility);
459 GV->setDSOLocal(
true);
462 if (GV->isDeclaration())
465 llvm::Function *F = dyn_cast<llvm::Function>(GV);
469 const FunctionDecl *FD = dyn_cast_or_null<FunctionDecl>(D);
471 setFunctionDeclAttributes(FD, F, M);
472 if (!getABIInfo().getCodeGenOpts().EmitIEEENaNCompliantInsts)
473 F->addFnAttr(
"amdgpu-ieee",
"false");
474 if (getABIInfo().getCodeGenOpts().AMDGPUExpandWaitcntProfiling)
475 F->addFnAttr(
"amdgpu-expand-waitcnt-profiling");
478unsigned AMDGPUTargetCodeGenInfo::getDeviceKernelCallingConv()
const {
479 return llvm::CallingConv::AMDGPU_KERNEL;
487llvm::Constant *AMDGPUTargetCodeGenInfo::getNullPointer(
488 const CodeGen::CodeGenModule &CGM, llvm::PointerType *PT,
491 return llvm::ConstantPointerNull::get(PT);
494 auto NPT = llvm::PointerType::get(
495 PT->getContext(), Ctx.getTargetAddressSpace(LangAS::opencl_generic));
496 return llvm::ConstantExpr::getAddrSpaceCast(
497 llvm::ConstantPointerNull::get(NPT), PT);
501AMDGPUTargetCodeGenInfo::getSRetAddrSpace(
const CXXRecordDecl *RD)
const {
505 return LangAS::Default;
507 getABIInfo().getDataLayout().getAllocaAddrSpace());
511AMDGPUTargetCodeGenInfo::getGlobalVarAddressSpace(CodeGenModule &CGM,
512 const VarDecl *D)
const {
515 "Address space agnostic languages only");
519 return DefaultGlobalAS;
522 if (AddrSpace != LangAS::Default)
531 return DefaultGlobalAS;
534StringRef AMDGPUTargetCodeGenInfo::getLLVMSyncScopeStr(
535 const LangOptions &LangOpts,
SyncScope Scope,
536 llvm::AtomicOrdering Ordering)
const {
540 bool IsOneAs = (Scope >= SyncScope::OpenCLWorkGroup &&
541 Scope <= SyncScope::OpenCLSubGroup &&
542 Ordering != llvm::AtomicOrdering::SequentiallyConsistent);
545 assert((AS != llvm::AtomicScope::Cluster || !IsOneAs) &&
546 "OpenCL does not have cluster scope");
547 return *llvm::getAtomicScopeIRString(getABIInfo().getTarget().
getTriple(), AS,
551void AMDGPUTargetCodeGenInfo::setTargetAtomicMetadata(
552 CodeGenFunction &CGF, llvm::Instruction &AtomicInst,
553 const AtomicExpr *AE)
const {
554 auto *RMW = dyn_cast<llvm::AtomicRMWInst>(&AtomicInst);
555 auto *CmpX = dyn_cast<llvm::AtomicCmpXchgInst>(&AtomicInst);
562 if (((RMW && RMW->getPointerAddressSpace() == llvm::AMDGPUAS::FLAT_ADDRESS) ||
564 CmpX->getPointerAddressSpace() == llvm::AMDGPUAS::FLAT_ADDRESS)) &&
567 llvm::MDNode *ASRange = MDHelper.createRange(
568 llvm::APInt(32, llvm::AMDGPUAS::PRIVATE_ADDRESS),
569 llvm::APInt(32, llvm::AMDGPUAS::PRIVATE_ADDRESS + 1));
570 AtomicInst.setMetadata(llvm::LLVMContext::MD_noalias_addrspace, ASRange);
581 RMW->setMetadata(
"amdgpu.no.fine.grained.memory",
Empty);
583 RMW->setMetadata(
"amdgpu.no.remote.memory",
Empty);
585 RMW->getOperation() == llvm::AtomicRMWInst::FAdd &&
586 RMW->getType()->isFloatTy())
587 RMW->setMetadata(llvm::LLVMContext::MD_atomic_ignore_denormal_mode,
Empty);
590bool AMDGPUTargetCodeGenInfo::shouldEmitStaticExternCAliases()
const {
594bool AMDGPUTargetCodeGenInfo::shouldEmitDWARFBitFieldSeparators()
const {
598void AMDGPUTargetCodeGenInfo::setCUDAKernelCallingConvention(
599 const FunctionType *&FT)
const {
600 FT = getABIInfo().getContext().adjustFunctionType(
610static llvm::StructType *
612 llvm::Type *KernelDescriptorPtrTy) {
613 llvm::Type *Int32 = llvm::Type::getInt32Ty(
C);
614 return llvm::StructType::create(
C, {KernelDescriptorPtrTy, Int32, Int32},
615 "block.runtime.handle.t");
626llvm::Value *AMDGPUTargetCodeGenInfo::createEnqueuedBlockKernel(
627 CodeGenFunction &CGF, llvm::Function *Invoke, llvm::Type *BlockTy)
const {
631 auto *InvokeFT = Invoke->getFunctionType();
632 llvm::SmallVector<llvm::Type *, 2> ArgTys;
633 llvm::SmallVector<llvm::Metadata *, 8> AddressQuals;
634 llvm::SmallVector<llvm::Metadata *, 8> AccessQuals;
635 llvm::SmallVector<llvm::Metadata *, 8> ArgTypeNames;
636 llvm::SmallVector<llvm::Metadata *, 8> ArgBaseTypeNames;
637 llvm::SmallVector<llvm::Metadata *, 8> ArgTypeQuals;
638 llvm::SmallVector<llvm::Metadata *, 8> ArgNames;
640 ArgTys.push_back(BlockTy);
641 ArgTypeNames.push_back(llvm::MDString::get(
C,
"__block_literal"));
642 AddressQuals.push_back(llvm::ConstantAsMetadata::get(Builder.getInt32(0)));
643 ArgBaseTypeNames.push_back(llvm::MDString::get(
C,
"__block_literal"));
644 ArgTypeQuals.push_back(llvm::MDString::get(
C,
""));
645 AccessQuals.push_back(llvm::MDString::get(
C,
"none"));
646 ArgNames.push_back(llvm::MDString::get(
C,
"block_literal"));
647 for (
unsigned I = 1, E = InvokeFT->getNumParams(); I < E; ++I) {
648 ArgTys.push_back(InvokeFT->getParamType(I));
649 ArgTypeNames.push_back(llvm::MDString::get(
C,
"void*"));
650 AddressQuals.push_back(llvm::ConstantAsMetadata::get(Builder.getInt32(3)));
651 AccessQuals.push_back(llvm::MDString::get(
C,
"none"));
652 ArgBaseTypeNames.push_back(llvm::MDString::get(
C,
"void*"));
653 ArgTypeQuals.push_back(llvm::MDString::get(
C,
""));
655 llvm::MDString::get(
C, (Twine(
"local_arg") + Twine(I)).str()));
659 const llvm::DataLayout &DL = Mod.getDataLayout();
661 llvm::Twine Name = Invoke->getName() +
"_kernel";
662 auto *FT = llvm::FunctionType::get(llvm::Type::getVoidTy(
C), ArgTys,
false);
666 auto *F = llvm::Function::Create(FT, llvm::GlobalValue::InternalLinkage, Name,
668 F->setCallingConv(getDeviceKernelCallingConv());
670 llvm::AttrBuilder KernelAttrs(
C);
674 F->addFnAttrs(KernelAttrs);
676 auto IP = CGF.
Builder.saveIP();
677 auto *BB = llvm::BasicBlock::Create(
C,
"entry", F);
678 Builder.SetInsertPoint(BB);
679 const auto BlockAlign = DL.getPrefTypeAlign(BlockTy);
680 auto *BlockPtr = Builder.CreateAlloca(BlockTy,
nullptr);
681 BlockPtr->setAlignment(BlockAlign);
682 Builder.CreateAlignedStore(F->arg_begin(), BlockPtr, BlockAlign);
683 auto *
Cast = Builder.CreatePointerCast(BlockPtr, InvokeFT->getParamType(0));
684 llvm::SmallVector<llvm::Value *, 2> Args;
685 Args.push_back(Cast);
686 for (llvm::Argument &A : llvm::drop_begin(F->args()))
688 llvm::CallInst *call = Builder.CreateCall(Invoke, Args);
689 call->setCallingConv(Invoke->getCallingConv());
690 Builder.CreateRetVoid();
691 Builder.restoreIP(IP);
693 F->setMetadata(
"kernel_arg_addr_space", llvm::MDNode::get(
C, AddressQuals));
694 F->setMetadata(
"kernel_arg_access_qual", llvm::MDNode::get(
C, AccessQuals));
695 F->setMetadata(
"kernel_arg_type", llvm::MDNode::get(
C, ArgTypeNames));
696 F->setMetadata(
"kernel_arg_base_type",
697 llvm::MDNode::get(
C, ArgBaseTypeNames));
698 F->setMetadata(
"kernel_arg_type_qual", llvm::MDNode::get(
C, ArgTypeQuals));
700 F->setMetadata(
"kernel_arg_name", llvm::MDNode::get(
C, ArgNames));
703 C, llvm::PointerType::get(
C, DL.getDefaultGlobalsAddressSpace()));
704 llvm::Constant *RuntimeHandleInitializer =
705 llvm::ConstantAggregateZero::get(HandleTy);
707 llvm::Twine RuntimeHandleName = F->getName() +
".runtime.handle";
718 auto *RuntimeHandle =
new llvm::GlobalVariable(
720 true, llvm::GlobalValue::InternalLinkage,
721 RuntimeHandleInitializer, RuntimeHandleName,
722 nullptr, llvm::GlobalValue::NotThreadLocal,
723 DL.getDefaultGlobalsAddressSpace(),
726 llvm::MDNode *HandleAsMD =
727 llvm::MDNode::get(
C, llvm::ValueAsMetadata::get(RuntimeHandle));
728 F->setMetadata(llvm::LLVMContext::MD_associated, HandleAsMD);
730 RuntimeHandle->setSection(
".amdgpu.kernel.runtime.handle");
734 return RuntimeHandle;
738 llvm::Function *F,
const AMDGPUFlatWorkGroupSizeAttr *FlatWGS,
739 const ReqdWorkGroupSizeAttr *ReqdWGS, int32_t *MinThreadsVal,
740 int32_t *MaxThreadsVal) {
743 auto Eval = [&](
Expr *E) {
744 return E->EvaluateKnownConstInt(
getContext()).getExtValue();
747 Min =
Max = Eval(ReqdWGS->getXDim()) * Eval(ReqdWGS->getYDim()) *
748 Eval(ReqdWGS->getZDim());
749 }
else if (FlatWGS) {
750 Min = Eval(FlatWGS->getMin());
751 Max = Eval(FlatWGS->getMax());
754 if (
Min != 0 || ReqdWGS) {
755 assert(
Min <=
Max &&
"Min must be less than or equal Max");
758 *MinThreadsVal =
Min;
760 *MaxThreadsVal =
Max;
761 std::string AttrVal = llvm::utostr(
Min) +
"," + llvm::utostr(
Max);
763 F->addFnAttr(
"amdgpu-flat-work-group-size", AttrVal);
765 assert(
Max == 0 &&
"Max must be zero");
769 llvm::Function *F,
const AMDGPUWavesPerEUAttr *
Attr) {
771 Attr->getMin()->EvaluateKnownConstInt(
getContext()).getExtValue();
774 ?
Attr->getMax()->EvaluateKnownConstInt(
getContext()).getExtValue()
778 assert((
Max == 0 ||
Min <=
Max) &&
"Min must be less than or equal Max");
780 std::string AttrVal = llvm::utostr(
Min);
782 AttrVal = AttrVal +
"," + llvm::utostr(
Max);
783 F->addFnAttr(
"amdgpu-waves-per-eu", AttrVal);
785 assert(
Max == 0 &&
"Max must be zero");
788std::unique_ptr<TargetCodeGenInfo>
790 return std::make_unique<AMDGPUTargetCodeGenInfo>(CGM.
getTypes());
static void setCUDAKernelCallingConvention(CanQualType &funcTy, CIRGenModule &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....
static StringRef getTriple(const Command &Job)
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
void AddAMDGPUAvailableVisibleMMRA(llvm::Instruction *Inst)
Attach the AMDGPU availability/visibility MMRA to Inst when the amdgpu_av attribute is active on the ...
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)
Top level wrappers for InstallAPI frontend operations.
bool isa(CodeGen::Address addr)
nullptr
This class represents a compute construct, representing a 'Kind' of ‘parallel’, 'serial',...
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.
SyncScope
Defines sync scope values used internally by clang.
U cast(CodeGen::Address addr)
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