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>()) {
44 F->addFnAttr(llvm::Attribute::NoInline);
45 const ReqdWorkGroupSizeAttr *Attr = FD->
getAttr<ReqdWorkGroupSizeAttr>();
48 llvm::LLVMContext &Context = F->getContext();
49 llvm::NamedMDNode *OpenCLMetadata =
51 "opencl.kernel_wg_size_info");
53 auto Eval = [&](Expr *E) {
56 SmallVector<llvm::Metadata *, 5> Operands{
57 llvm::ConstantAsMetadata::get(F),
58 llvm::ConstantAsMetadata::get(llvm::Constant::getIntegerValue(
59 M.
Int32Ty, Eval(Attr->getXDim()))),
60 llvm::ConstantAsMetadata::get(llvm::Constant::getIntegerValue(
61 M.
Int32Ty, Eval(Attr->getYDim()))),
62 llvm::ConstantAsMetadata::get(llvm::Constant::getIntegerValue(
63 M.
Int32Ty, Eval(Attr->getZDim()))),
67 llvm::ConstantAsMetadata::get(llvm::ConstantInt::getTrue(Context))};
68 OpenCLMetadata->addOperand(llvm::MDNode::get(Context, Operands));
76std::unique_ptr<TargetCodeGenInfo>
78 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)
The JSON file list parser is used to communicate input to InstallAPI.
U cast(CodeGen::Address addr)
llvm::IntegerType * Int32Ty