5#include "mlir/Dialect/Ptr/IR/MemorySpaceInterfaces.h"
20 if (
const CXXRecordDecl *cxxrd = dyn_cast<CXXRecordDecl>(rd)) {
21 if (cxxrd->isDynamicClass())
24 for (
const auto &i : cxxrd->bases())
29 for (
const auto *i : rd->fields())
49class AMDGPUABIInfo :
public ABIInfo {
56 AMDGPUTargetCIRGenInfo(CIRGenTypes &cgt)
57 : TargetCIRGenInfo(std::make_unique<AMDGPUABIInfo>(cgt)) {}
59 void setTargetAttributes(
const clang::Decl *
decl, mlir::Operation *global,
60 CIRGenModule &cgm)
const override {
61 if (
auto func = mlir::dyn_cast<cir::FuncOp>(global)) {
63 func.setGlobalVisibility(cir::VisibilityKind::Protected);
64 func.setDSOLocal(
true);
67 }
else if (
auto gv = mlir::dyn_cast<cir::GlobalOp>(global)) {
69 gv.setGlobalVisibility(cir::VisibilityKind::Protected);
76 getGlobalVarAddressSpace(CIRGenModule &cgm,
77 const clang::VarDecl *
decl)
const override {
81 "Address space agnostic languages only");
82 LangAS defaultGlobalAS = LangAS::opencl_global;
84 return defaultGlobalAS;
86 LangAS addrSpace =
decl->getType().getAddressSpace();
87 if (addrSpace != LangAS::Default)
92 decl->hasConstantInitialization())
93 return LangAS::opencl_constant;
95 return defaultGlobalAS;
98 mlir::ptr::MemorySpaceAttrInterface
99 getCIRAllocaAddressSpace()
const override {
100 return cir::LangAddressSpaceAttr::get(
101 &getABIInfo().cgt.getMLIRContext(),
102 cir::LangAddressSpace::OffloadPrivate);
110class X8664ABIInfo :
public ABIInfo {
112 X8664ABIInfo(CIRGenTypes &cgt) : ABIInfo(cgt) {}
117 X8664TargetCIRGenInfo(CIRGenTypes &cgt)
118 : TargetCIRGenInfo(std::make_unique<X8664ABIInfo>(cgt)) {}
124class NVPTXABIInfo :
public ABIInfo {
126 NVPTXABIInfo(CIRGenTypes &cgt) : ABIInfo(cgt) {}
131 NVPTXTargetCIRGenInfo(CIRGenTypes &cgt)
132 : TargetCIRGenInfo(std::make_unique<NVPTXABIInfo>(cgt)) {}
136std::unique_ptr<TargetCIRGenInfo>
138 return std::make_unique<AMDGPUTargetCIRGenInfo>(cgt);
141std::unique_ptr<TargetCIRGenInfo>
143 return std::make_unique<NVPTXTargetCIRGenInfo>(cgt);
146std::unique_ptr<TargetCIRGenInfo>
148 return std::make_unique<X8664TargetCIRGenInfo>(cgt);
167 "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.