1 | |
2 | |
3 | |
4 | |
5 | |
6 | |
7 | |
8 | |
9 | |
10 | |
11 | |
12 | |
13 | |
14 | |
15 | #ifndef LLVM_CLANG_LIB_CODEGEN_CGOPENCLRUNTIME_H |
16 | #define LLVM_CLANG_LIB_CODEGEN_CGOPENCLRUNTIME_H |
17 | |
18 | #include "clang/AST/Expr.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" |
23 | |
24 | namespace clang { |
25 | |
26 | class BlockExpr; |
27 | class Expr; |
28 | class VarDecl; |
29 | |
30 | namespace CodeGen { |
31 | |
32 | class CodeGenFunction; |
33 | class CodeGenModule; |
34 | |
35 | class CGOpenCLRuntime { |
36 | protected: |
37 | CodeGenModule &CGM; |
38 | llvm::Type *PipeROTy; |
39 | llvm::Type *PipeWOTy; |
40 | llvm::PointerType *SamplerTy; |
41 | |
42 | |
43 | struct EnqueuedBlockInfo { |
44 | llvm::Function *InvokeFunc; |
45 | llvm::Function *Kernel; |
46 | llvm::Value *BlockArg; |
47 | }; |
48 | |
49 | llvm::DenseMap<const Expr *, EnqueuedBlockInfo> EnqueuedBlockMap; |
50 | |
51 | virtual llvm::Type *getPipeType(const PipeType *T, StringRef Name, |
52 | llvm::Type *&PipeTy); |
53 | |
54 | public: |
55 | CGOpenCLRuntime(CodeGenModule &CGM) : CGM(CGM), |
56 | PipeROTy(nullptr), PipeWOTy(nullptr), SamplerTy(nullptr) {} |
57 | virtual ~CGOpenCLRuntime(); |
58 | |
59 | |
60 | |
61 | |
62 | virtual void EmitWorkGroupLocalVarDecl(CodeGenFunction &CGF, |
63 | const VarDecl &D); |
64 | |
65 | virtual llvm::Type *convertOpenCLSpecificType(const Type *T); |
66 | |
67 | virtual llvm::Type *getPipeType(const PipeType *T); |
68 | |
69 | llvm::PointerType *getSamplerType(const Type *T); |
70 | |
71 | |
72 | |
73 | virtual llvm::Value *getPipeElemSize(const Expr *PipeArg); |
74 | |
75 | |
76 | |
77 | virtual llvm::Value *getPipeElemAlign(const Expr *PipeArg); |
78 | |
79 | |
80 | llvm::PointerType *getGenericVoidPointerType(); |
81 | |
82 | |
83 | EnqueuedBlockInfo emitOpenCLEnqueuedBlock(CodeGenFunction &CGF, |
84 | const Expr *E); |
85 | |
86 | |
87 | |
88 | |
89 | |
90 | |
91 | |
92 | void recordBlockInfo(const BlockExpr *E, llvm::Function *InvokeF, |
93 | llvm::Value *Block); |
94 | |
95 | |
96 | |
97 | llvm::Function *getInvokeFunction(const Expr *E); |
98 | }; |
99 | |
100 | } |
101 | } |
102 | |
103 | #endif |
104 | |