1 //===----- CGOpenCLRuntime.h - Interface to OpenCL Runtimes -----*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This provides an abstract class for OpenCL code generation. Concrete
11 // subclasses of this implement code generation for specific OpenCL
14 //===----------------------------------------------------------------------===//
16 #ifndef LLVM_CLANG_LIB_CODEGEN_CGOPENCLRUNTIME_H
17 #define LLVM_CLANG_LIB_CODEGEN_CGOPENCLRUNTIME_H
19 #include "clang/AST/Type.h"
20 #include "llvm/ADT/DenseMap.h"
21 #include "llvm/IR/Type.h"
22 #include "llvm/IR/Value.h"
31 class CodeGenFunction;
34 class CGOpenCLRuntime {
38 llvm::PointerType *SamplerTy;
40 /// Structure for enqueued block information.
41 struct EnqueuedBlockInfo {
42 llvm::Function *Kernel; /// Enqueued block kernel.
43 llvm::Value *BlockArg; /// The first argument to enqueued block kernel.
45 /// Maps block expression to block information.
46 llvm::DenseMap<const Expr *, EnqueuedBlockInfo> EnqueuedBlockMap;
49 CGOpenCLRuntime(CodeGenModule &CGM) : CGM(CGM), PipeTy(nullptr),
51 virtual ~CGOpenCLRuntime();
53 /// Emit the IR required for a work-group-local variable declaration, and add
54 /// an entry to CGF's LocalDeclMap for D. The base class does this using
55 /// CodeGenFunction::EmitStaticVarDecl to emit an internal global for D.
56 virtual void EmitWorkGroupLocalVarDecl(CodeGenFunction &CGF,
59 virtual llvm::Type *convertOpenCLSpecificType(const Type *T);
61 virtual llvm::Type *getPipeType(const PipeType *T);
63 llvm::PointerType *getSamplerType(const Type *T);
65 // \brief Returnes a value which indicates the size in bytes of the pipe
67 virtual llvm::Value *getPipeElemSize(const Expr *PipeArg);
69 // \brief Returnes a value which indicates the alignment in bytes of the pipe
71 virtual llvm::Value *getPipeElemAlign(const Expr *PipeArg);
73 /// \return __generic void* type.
74 llvm::PointerType *getGenericVoidPointerType();
76 /// \return enqueued block information for enqueued block.
77 EnqueuedBlockInfo emitOpenCLEnqueuedBlock(CodeGenFunction &CGF,