10#include "TargetInfo.h"
25 TCETargetCodeGenInfo(CodeGenTypes &CGT)
26 : TargetCodeGenInfo(std::make_unique<DefaultABIInfo>(CGT)) {}
28 void setTargetAttributes(
const Decl *D, llvm::GlobalValue *GV,
29 CodeGen::CodeGenModule &M)
const override;
32void TCETargetCodeGenInfo::setTargetAttributes(
34 if (GV->isDeclaration())
36 const FunctionDecl *FD = dyn_cast_or_null<FunctionDecl>(D);
42 if (FD->
hasAttr<DeviceKernelAttr>()) {
43 const ReqdWorkGroupSizeAttr *Attr = FD->
getAttr<ReqdWorkGroupSizeAttr>();
46 llvm::LLVMContext &Context = F->getContext();
47 llvm::NamedMDNode *OpenCLMetadata =
49 "opencl.kernel_wg_size_info");
51 auto Eval = [&](Expr *E) {
54 SmallVector<llvm::Metadata *, 5> Operands{
55 llvm::ConstantAsMetadata::get(F),
56 llvm::ConstantAsMetadata::get(llvm::Constant::getIntegerValue(
57 M.
Int32Ty, Eval(Attr->getXDim()))),
58 llvm::ConstantAsMetadata::get(llvm::Constant::getIntegerValue(
59 M.
Int32Ty, Eval(Attr->getYDim()))),
60 llvm::ConstantAsMetadata::get(llvm::Constant::getIntegerValue(
61 M.
Int32Ty, Eval(Attr->getZDim()))),
65 llvm::ConstantAsMetadata::get(llvm::ConstantInt::getTrue(Context))};
66 OpenCLMetadata->addOperand(llvm::MDNode::get(Context, Operands));
74std::unique_ptr<TargetCodeGenInfo>
76 return std::make_unique<TCETargetCodeGenInfo>(CGM.
getTypes());
This class organizes the cross-function state that is used while generating LLVM code.
llvm::Module & getModule() const
const LangOptions & getLangOpts() const
CodeGenTypes & getTypes()
TargetCodeGenInfo - This class organizes various target-specific codegeneration issues,...
Decl - This represents one declaration (or definition), e.g.
ASTContext & getASTContext() const LLVM_READONLY
@ Decl
The l-value was an access to a declared entity or something equivalently strong, like the address of ...
std::unique_ptr< TargetCodeGenInfo > createTCETargetCodeGenInfo(CodeGenModule &CGM)
Top level wrappers for InstallAPI frontend operations.
U cast(CodeGen::Address addr)
llvm::IntegerType * Int32Ty