5#include "mlir/Dialect/Ptr/IR/MemorySpaceInterfaces.h"
21 if (
const CXXRecordDecl *cxxrd = dyn_cast<CXXRecordDecl>(rd)) {
22 if (cxxrd->isDynamicClass())
25 for (
const auto &i : cxxrd->bases())
30 for (
const auto *i : rd->fields())
50class AMDGPUABIInfo :
public ABIInfo {
57 AMDGPUTargetCIRGenInfo(CIRGenTypes &cgt)
58 : TargetCIRGenInfo(std::make_unique<AMDGPUABIInfo>(cgt)) {}
60 bool supportsLibCall()
const override {
return false; }
62 void setTargetAttributes(
const clang::Decl *
decl, mlir::Operation *global,
63 CIRGenModule &cgm)
const override {
64 if (
auto func = mlir::dyn_cast<cir::FuncOp>(global)) {
66 func.setGlobalVisibility(cir::VisibilityKind::Protected);
67 func.setDSOLocal(
true);
70 }
else if (
auto gv = mlir::dyn_cast<cir::GlobalOp>(global)) {
72 gv.setGlobalVisibility(cir::VisibilityKind::Protected);
79 getGlobalVarAddressSpace(CIRGenModule &cgm,
80 const clang::VarDecl *
decl)
const override {
84 "Address space agnostic languages only");
85 LangAS defaultGlobalAS = LangAS::opencl_global;
87 return defaultGlobalAS;
89 LangAS addrSpace =
decl->getType().getAddressSpace();
90 if (addrSpace != LangAS::Default)
95 decl->hasConstantInitialization())
96 return LangAS::opencl_constant;
98 return defaultGlobalAS;
101 mlir::ptr::MemorySpaceAttrInterface
102 getCIRAllocaAddressSpace()
const override {
103 return cir::LangAddressSpaceAttr::get(
104 &getABIInfo().cgt.getMLIRContext(),
105 cir::LangAddressSpace::OffloadPrivate);
113class X8664ABIInfo :
public ABIInfo {
115 X8664ABIInfo(CIRGenTypes &cgt) : ABIInfo(cgt) {}
120 X8664TargetCIRGenInfo(CIRGenTypes &cgt)
121 : TargetCIRGenInfo(std::make_unique<X8664ABIInfo>(cgt)) {}
127class NVPTXABIInfo :
public ABIInfo {
129 NVPTXABIInfo(CIRGenTypes &cgt) : ABIInfo(cgt) {}
134 NVPTXTargetCIRGenInfo(CIRGenTypes &cgt)
135 : TargetCIRGenInfo(std::make_unique<NVPTXABIInfo>(cgt)) {}
137 void setTargetAttributes(
const clang::Decl *
decl, mlir::Operation *global,
138 CIRGenModule &cgm)
const override {
139 auto globalValue = mlir::dyn_cast<cir::CIRGlobalValueInterface>(global);
140 if (globalValue && globalValue.isDeclaration())
143 const auto *vd = dyn_cast_or_null<VarDecl>(
decl);
146 if (vd->getType()->isCUDADeviceBuiltinSurfaceType() ||
147 vd->getType()->isCUDADeviceBuiltinTextureType())
153 const auto *fd = dyn_cast_or_null<FunctionDecl>(
decl);
157 auto func = mlir::cast<cir::FuncOp>(global);
163 if (fd->hasAttr<DeviceKernelAttr>() || fd->hasAttr<CUDAGlobalAttr>()) {
166 func.setInlineKind(cir::InlineKind::NoInline);
167 if (fd->hasAttr<CUDAGlobalAttr>()) {
168 func.setCallingConv(cir::CallingConv::PTXKernel);
171 if (fd->hasAttr<CUDALaunchBoundsAttr>())
179std::unique_ptr<TargetCIRGenInfo>
181 return std::make_unique<AMDGPUTargetCIRGenInfo>(cgt);
184std::unique_ptr<TargetCIRGenInfo>
186 return std::make_unique<NVPTXTargetCIRGenInfo>(cgt);
189std::unique_ptr<TargetCIRGenInfo>
191 return std::make_unique<X8664TargetCIRGenInfo>(cgt);
210 "Address space agnostic languages only");
Provides definitions for the various language-specific address spaces.
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
This class organizes the cross-function state that is used while generating CIR code.
clang::ASTContext & getASTContext() const
const clang::LangOptions & getLangOpts() const
This class organizes the cross-module state that is used while lowering AST types to CIR types.
TargetCIRGenInfo(std::unique_ptr< ABIInfo > info)
virtual clang::LangAS getGlobalVarAddressSpace(CIRGenModule &cgm, const clang::VarDecl *d) const
Get target favored AST address space of a global variable for languages other than OpenCL and CUDA.
virtual bool isNoProtoCallVariadic(const FunctionNoProtoType *fnType) const
Determine whether a call to an unprototyped functions under the given calling convention should use t...
Represents a C++ struct/union/class.
Represents a member of a struct/union/class.
bool isUnnamedBitField() const
Determines whether this is an unnamed bitfield.
bool isZeroLengthBitField() const
Is this a zero-length bit-field?
Represents a K&R-style 'int foo()' function, which has no information available about its arguments.
A (possibly-)qualified type.
LangAS getAddressSpace() const
Return the address space of this type.
RecordDecl * getAsRecordDecl() const
Retrieves the RecordDecl this type refers to.
Represents a variable declaration or definition.
void setAMDGPUTargetFunctionAttributes(const clang::Decl *decl, cir::FuncOp func, CIRGenModule &cgm)
Set AMDGPU-specific function attributes for HIP kernels.
std::unique_ptr< TargetCIRGenInfo > createAMDGPUTargetCIRGenInfo(CIRGenTypes &cgt)
std::unique_ptr< TargetCIRGenInfo > createNVPTXTargetCIRGenInfo(CIRGenTypes &cgt)
std::unique_ptr< TargetCIRGenInfo > createX8664TargetCIRGenInfo(CIRGenTypes &cgt)
bool isEmptyFieldForLayout(const ASTContext &context, const FieldDecl *fd)
isEmptyFieldForLayout - Return true if the field is "empty", that is, either a zero-width bit-field o...
bool isEmptyRecordForLayout(const ASTContext &context, QualType t)
isEmptyRecordForLayout - Return true if a structure contains only empty base classes (per isEmptyReco...
bool requiresAMDGPUProtectedVisibility(const clang::Decl *d, cir::VisibilityKind visibility)
Check if AMDGPU protected visibility is required.
const internal::VariadicAllOfMatcher< Decl > decl
Matches declarations.
The JSON file list parser is used to communicate input to InstallAPI.
LangAS
Defines the address space values used by the address space qualifier of QualType.
static bool emitNVVMMetadata()
static bool handleCUDALaunchBoundsAttr()
static bool opFuncParameterAttributes()