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())
52 if (rd->hasFlexibleArrayMember())
55 if (
const auto *cxxrd = dyn_cast<CXXRecordDecl>(rd)) {
60 if (cxxrd->isDynamicClass())
63 for (
const auto &i : cxxrd->bases())
68 for (
const auto *i : rd->fields())
82 bool wasArray =
false;
86 ft = at->getElementType();
98 (wasArray || !fd->
hasAttr<NoUniqueAddressAttr>()))
106class AMDGPUABIInfo :
public ABIInfo {
113 AMDGPUTargetCIRGenInfo(CIRGenTypes &cgt)
114 : TargetCIRGenInfo(std::make_unique<AMDGPUABIInfo>(cgt)) {}
116 bool supportsLibCall()
const override {
return false; }
118 void setTargetAttributes(
const clang::Decl *
decl, mlir::Operation *global,
119 CIRGenModule &cgm)
const override {
120 if (
auto func = mlir::dyn_cast<cir::FuncOp>(global)) {
122 func.setGlobalVisibility(cir::VisibilityKind::Protected);
123 func.setDSOLocal(
true);
126 }
else if (
auto gv = mlir::dyn_cast<cir::GlobalOp>(global)) {
128 gv.setGlobalVisibility(cir::VisibilityKind::Protected);
129 gv.setDSOLocal(
true);
135 getGlobalVarAddressSpace(CIRGenModule &cgm,
136 const clang::VarDecl *
decl)
const override {
140 "Address space agnostic languages only");
141 LangAS defaultGlobalAS = LangAS::opencl_global;
143 return defaultGlobalAS;
145 LangAS addrSpace =
decl->getType().getAddressSpace();
146 if (addrSpace != LangAS::Default)
151 decl->hasConstantInitialization())
152 return LangAS::opencl_constant;
154 return defaultGlobalAS;
157 mlir::ptr::MemorySpaceAttrInterface
158 getCIRAllocaAddressSpace()
const override {
159 return cir::LangAddressSpaceAttr::get(
160 &getABIInfo().cgt.getMLIRContext(),
161 cir::LangAddressSpace::OffloadPrivate);
169class X8664ABIInfo :
public ABIInfo {
171 X8664ABIInfo(CIRGenTypes &cgt) : ABIInfo(cgt) {}
176 X8664TargetCIRGenInfo(CIRGenTypes &cgt)
177 : TargetCIRGenInfo(std::make_unique<X8664ABIInfo>(cgt)) {}
181std::unique_ptr<TargetCIRGenInfo>
183 return std::make_unique<AMDGPUTargetCIRGenInfo>(cgt);
186std::unique_ptr<TargetCIRGenInfo>
188 return std::make_unique<X8664TargetCIRGenInfo>(cgt);
207 "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 ...
const ConstantArrayType * getAsConstantArrayType(QualType T) const
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 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.
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 an unnamed bit-field or an (...
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.
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.