5#include "mlir/Dialect/Ptr/IR/MemorySpaceInterfaces.h"
19 if (rd->hasFlexibleArrayMember())
22 if (
const auto *cxxrd = dyn_cast<CXXRecordDecl>(rd)) {
27 if (cxxrd->isDynamicClass())
30 for (
const auto &i : cxxrd->bases())
35 for (
const auto *i : rd->fields())
56 bool wasArray =
false;
60 ft = at->getElementType();
72 (wasArray || !fd->
hasAttr<NoUniqueAddressAttr>()))
80class AMDGPUABIInfo :
public ABIInfo {
87 AMDGPUTargetCIRGenInfo(CIRGenTypes &cgt)
88 : TargetCIRGenInfo(std::make_unique<AMDGPUABIInfo>(cgt)) {}
90 bool supportsLibCall()
const override {
return false; }
92 cir::CallingConv getDeviceKernelCallingConv()
const override {
93 return cir::CallingConv::AMDGPUKernel;
97 ft = getABIInfo().cgt.getASTContext().adjustFunctionType(
101 void setTargetAttributes(
const clang::Decl *
decl, mlir::Operation *global,
102 CIRGenModule &cgm)
const override {
103 if (
auto func = mlir::dyn_cast<cir::FuncOp>(global)) {
106 func.getGlobalVisibility() == cir::VisibilityKind::Hidden)) {
107 func.setGlobalVisibility(cir::VisibilityKind::Protected);
108 func.setDSOLocal(
true);
111 }
else if (
auto gv = mlir::dyn_cast<cir::GlobalOp>(global)) {
113 decl, gv.getGlobalVisibility() == cir::VisibilityKind::Hidden)) {
114 gv.setGlobalVisibility(cir::VisibilityKind::Protected);
115 gv.setDSOLocal(
true);
121 getGlobalVarAddressSpace(CIRGenModule &cgm,
122 const clang::VarDecl *
decl)
const override {
126 "Address space agnostic languages only");
127 LangAS defaultGlobalAS = LangAS::opencl_global;
129 return defaultGlobalAS;
131 LangAS addrSpace =
decl->getType().getAddressSpace();
132 if (addrSpace != LangAS::Default)
137 decl->hasConstantInitialization())
138 return LangAS::opencl_constant;
140 return defaultGlobalAS;
143 mlir::ptr::MemorySpaceAttrInterface
144 getCIRAllocaAddressSpace()
const override {
145 return cir::LangAddressSpaceAttr::get(
146 &getABIInfo().cgt.getMLIRContext(),
147 cir::LangAddressSpace::OffloadPrivate);
155class X8664ABIInfo :
public ABIInfo {
157 X8664ABIInfo(CIRGenTypes &cgt) : ABIInfo(cgt) {}
162 X8664TargetCIRGenInfo(CIRGenTypes &cgt)
163 : TargetCIRGenInfo(std::make_unique<X8664ABIInfo>(cgt)) {}
167std::unique_ptr<TargetCIRGenInfo>
169 return std::make_unique<AMDGPUTargetCIRGenInfo>(cgt);
172std::unique_ptr<TargetCIRGenInfo>
174 return std::make_unique<X8664TargetCIRGenInfo>(cgt);
191 assert(
getABIInfo().cgt.getASTContext().getLangOpts().OpenCL &&
192 "Kernel calling convention only defined for OpenCL");
193 return cir::CallingConv::C;
197 cir::PointerType ptrTy,
199 mlir::Location loc)
const {
208 "Address space agnostic languages only");
Provides definitions for the various language-specific address spaces.
static void setCUDAKernelCallingConvention(CanQualType &funcTy, CIRGenModule &cgm, const FunctionDecl *fd)
Set calling convention for CUDA/HIP kernel.
cir::ConstantOp getNullPtr(mlir::Type ty, mlir::Location loc)
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
const ConstantArrayType * getAsConstantArrayType(QualType T) const
This class organizes the cross-function state that is used while generating CIR code.
clang::ASTContext & getASTContext() const
CIRGenBuilderTy & getBuilder()
const clang::LangOptions & getLangOpts() const
This class organizes the cross-module state that is used while lowering AST types to CIR types.
virtual mlir::Value getNullPointer(CIRGenModule &cgm, cir::PointerType ptrTy, QualType qt, mlir::Location loc) const
Get the CIR value of a null pointer of type ptrTy, where qt is the source pointer type.
const ABIInfo & getABIInfo() const
Returns ABI info helper for the target.
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 cir::CallingConv getDeviceKernelCallingConv() const
Returns the calling convention used for device kernels on this target.
virtual bool isNoProtoCallVariadic(const FunctionNoProtoType *fnType) const
Determine whether a call to an unprototyped functions under the given calling convention should use t...
Represents the canonical version of C arrays with a specified constant size.
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.
ExtInfo withCallingConv(CallingConv cc) const
ExtInfo getExtInfo() const
A (possibly-)qualified type.
LangAS getAddressSpace() const
Return the address space of this type.
RecordDecl * getAsRecordDecl() const
Retrieves the RecordDecl this type refers to.
const T * getAsCanonical() const
If this type is canonically the specified type, return its canonical type cast to that specified type...
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.
bool isEmptyRecordForABI(const ASTContext &context, QualType t)
isEmptyRecordForABI - Return true if a structure contains only empty base classes and fields.
std::unique_ptr< TargetCIRGenInfo > createAMDGPUTargetCIRGenInfo(CIRGenTypes &cgt)
bool isEmptyFieldForABI(const ASTContext &context, const FieldDecl *fd)
isEmptyFieldForABI - Return true if the field is "empty", that is, it is a zero-width bit-field or an...
std::unique_ptr< TargetCIRGenInfo > createX8664TargetCIRGenInfo(CIRGenTypes &cgt)
bool requiresAMDGPUProtectedVisibility(const Decl *D, bool HasHiddenVisibility)
Returns whether D must be given protected visibility on AMDGPU.
const internal::VariadicAllOfMatcher< Decl > decl
Matches declarations.
Top level wrappers for InstallAPI frontend operations.
bool isa(CodeGen::Address addr)
LangAS
Defines the address space values used by the address space qualifier of QualType.