Path: blob/main/contrib/llvm-project/clang/lib/CodeGen/CGOpenCLRuntime.h
35233 views
//===----- CGOpenCLRuntime.h - Interface to OpenCL Runtimes -----*- C++ -*-===//1//2// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.3// See https://llvm.org/LICENSE.txt for license information.4// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception5//6//===----------------------------------------------------------------------===//7//8// This provides an abstract class for OpenCL code generation. Concrete9// subclasses of this implement code generation for specific OpenCL10// runtime libraries.11//12//===----------------------------------------------------------------------===//1314#ifndef LLVM_CLANG_LIB_CODEGEN_CGOPENCLRUNTIME_H15#define LLVM_CLANG_LIB_CODEGEN_CGOPENCLRUNTIME_H1617#include "clang/AST/Expr.h"18#include "clang/AST/Type.h"19#include "llvm/ADT/DenseMap.h"20#include "llvm/ADT/StringMap.h"21#include "llvm/IR/Type.h"22#include "llvm/IR/Value.h"2324namespace clang {2526class BlockExpr;27class Expr;28class VarDecl;2930namespace CodeGen {3132class CodeGenFunction;33class CodeGenModule;3435class CGOpenCLRuntime {36protected:37CodeGenModule &CGM;38llvm::Type *PipeROTy;39llvm::Type *PipeWOTy;40llvm::Type *SamplerTy;4142/// Structure for enqueued block information.43struct EnqueuedBlockInfo {44llvm::Function *InvokeFunc; /// Block invoke function.45llvm::Value *KernelHandle; /// Enqueued block kernel reference.46llvm::Value *BlockArg; /// The first argument to enqueued block kernel.47llvm::Type *BlockTy; /// Type of the block argument.48};49/// Maps block expression to block information.50llvm::DenseMap<const Expr *, EnqueuedBlockInfo> EnqueuedBlockMap;5152virtual llvm::Type *getPipeType(const PipeType *T, StringRef Name,53llvm::Type *&PipeTy);54llvm::PointerType *getPointerType(const Type *T);5556public:57CGOpenCLRuntime(CodeGenModule &CGM) : CGM(CGM),58PipeROTy(nullptr), PipeWOTy(nullptr), SamplerTy(nullptr) {}59virtual ~CGOpenCLRuntime();6061/// Emit the IR required for a work-group-local variable declaration, and add62/// an entry to CGF's LocalDeclMap for D. The base class does this using63/// CodeGenFunction::EmitStaticVarDecl to emit an internal global for D.64virtual void EmitWorkGroupLocalVarDecl(CodeGenFunction &CGF,65const VarDecl &D);6667virtual llvm::Type *convertOpenCLSpecificType(const Type *T);6869virtual llvm::Type *getPipeType(const PipeType *T);7071llvm::Type *getSamplerType(const Type *T);7273// Returns a value which indicates the size in bytes of the pipe74// element.75virtual llvm::Value *getPipeElemSize(const Expr *PipeArg);7677// Returns a value which indicates the alignment in bytes of the pipe78// element.79virtual llvm::Value *getPipeElemAlign(const Expr *PipeArg);8081/// \return __generic void* type.82llvm::PointerType *getGenericVoidPointerType();8384/// \return enqueued block information for enqueued block.85EnqueuedBlockInfo emitOpenCLEnqueuedBlock(CodeGenFunction &CGF,86const Expr *E);8788/// Record invoke function and block literal emitted during normal89/// codegen for a block expression. The information is used by90/// emitOpenCLEnqueuedBlock to emit wrapper kernel.91///92/// \param InvokeF invoke function emitted for the block expression.93/// \param Block block literal emitted for the block expression.94void recordBlockInfo(const BlockExpr *E, llvm::Function *InvokeF,95llvm::Value *Block, llvm::Type *BlockTy);9697/// \return LLVM block invoke function emitted for an expression derived from98/// the block expression.99llvm::Function *getInvokeFunction(const Expr *E);100};101102}103}104105#endif106107108