blob: ee3cb3dda0631a8c4eb9d466632c5a93a892166c [file] [log] [blame]
Guy Benyei11169dd2012-12-18 14:30:41 +00001//===----- CGOpenCLRuntime.h - Interface to OpenCL Runtimes -----*- C++ -*-===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9//
10// This provides an abstract class for OpenCL code generation. Concrete
11// subclasses of this implement code generation for specific OpenCL
12// runtime libraries.
13//
14//===----------------------------------------------------------------------===//
15
Benjamin Kramer2f5db8b2014-08-13 16:25:19 +000016#ifndef LLVM_CLANG_LIB_CODEGEN_CGOPENCLRUNTIME_H
17#define LLVM_CLANG_LIB_CODEGEN_CGOPENCLRUNTIME_H
Guy Benyei11169dd2012-12-18 14:30:41 +000018
Guy Benyeid8a08ea2012-12-18 14:38:23 +000019#include "clang/AST/Type.h"
Chandler Carruthffd55512013-01-02 11:45:17 +000020#include "llvm/IR/Type.h"
21#include "llvm/IR/Value.h"
Guy Benyeid8a08ea2012-12-18 14:38:23 +000022
Guy Benyei11169dd2012-12-18 14:30:41 +000023namespace clang {
24
25class VarDecl;
26
27namespace CodeGen {
28
29class CodeGenFunction;
30class CodeGenModule;
31
32class CGOpenCLRuntime {
33protected:
34 CodeGenModule &CGM;
Xiuli Pan9c14e282016-01-09 12:53:17 +000035 llvm::Type *PipeTy;
Yaxun Liu0bc4b2d2016-07-28 19:26:30 +000036 llvm::PointerType *SamplerTy;
Guy Benyei11169dd2012-12-18 14:30:41 +000037
38public:
Yaxun Liu0bc4b2d2016-07-28 19:26:30 +000039 CGOpenCLRuntime(CodeGenModule &CGM) : CGM(CGM), PipeTy(nullptr),
40 SamplerTy(nullptr) {}
Guy Benyei11169dd2012-12-18 14:30:41 +000041 virtual ~CGOpenCLRuntime();
42
43 /// Emit the IR required for a work-group-local variable declaration, and add
44 /// an entry to CGF's LocalDeclMap for D. The base class does this using
45 /// CodeGenFunction::EmitStaticVarDecl to emit an internal global for D.
46 virtual void EmitWorkGroupLocalVarDecl(CodeGenFunction &CGF,
47 const VarDecl &D);
Guy Benyeid8a08ea2012-12-18 14:38:23 +000048
49 virtual llvm::Type *convertOpenCLSpecificType(const Type *T);
Xiuli Pan9c14e282016-01-09 12:53:17 +000050
51 virtual llvm::Type *getPipeType();
Yaxun Liu0bc4b2d2016-07-28 19:26:30 +000052
53 llvm::PointerType *getSamplerType();
Alexey Bader465c1892016-09-23 14:20:00 +000054
55 // \brief Returnes a value which indicates the size in bytes of the pipe
56 // element.
57 virtual llvm::Value *getPipeElemSize(const Expr *PipeArg);
58
59 // \brief Returnes a value which indicates the alignment in bytes of the pipe
60 // element.
61 virtual llvm::Value *getPipeElemAlign(const Expr *PipeArg);
Guy Benyei11169dd2012-12-18 14:30:41 +000062};
63
Alexander Kornienkoab9db512015-06-22 23:07:51 +000064}
65}
Guy Benyei11169dd2012-12-18 14:30:41 +000066
67#endif