clang  9.0.0svn
CGOpenCLRuntime.h
Go to the documentation of this file.
1 //===----- 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 
16 #ifndef LLVM_CLANG_LIB_CODEGEN_CGOPENCLRUNTIME_H
17 #define LLVM_CLANG_LIB_CODEGEN_CGOPENCLRUNTIME_H
18 
19 #include "clang/AST/Expr.h"
20 #include "clang/AST/Type.h"
21 #include "llvm/ADT/DenseMap.h"
22 #include "llvm/IR/Type.h"
23 #include "llvm/IR/Value.h"
24 
25 namespace clang {
26 
27 class BlockExpr;
28 class Expr;
29 class VarDecl;
30 
31 namespace CodeGen {
32 
33 class CodeGenFunction;
34 class CodeGenModule;
35 
37 protected:
41  llvm::PointerType *SamplerTy;
42 
43  /// Structure for enqueued block information.
45  llvm::Function *InvokeFunc; /// Block invoke function.
46  llvm::Function *Kernel; /// Enqueued block kernel.
47  llvm::Value *BlockArg; /// The first argument to enqueued block kernel.
48  };
49  /// Maps block expression to block information.
50  llvm::DenseMap<const Expr *, EnqueuedBlockInfo> EnqueuedBlockMap;
51 
52  virtual llvm::Type *getPipeType(const PipeType *T, StringRef Name,
53  llvm::Type *&PipeTy);
54 
55 public:
56  CGOpenCLRuntime(CodeGenModule &CGM) : CGM(CGM),
57  PipeROTy(nullptr), PipeWOTy(nullptr), SamplerTy(nullptr) {}
58  virtual ~CGOpenCLRuntime();
59 
60  /// Emit the IR required for a work-group-local variable declaration, and add
61  /// an entry to CGF's LocalDeclMap for D. The base class does this using
62  /// CodeGenFunction::EmitStaticVarDecl to emit an internal global for D.
64  const VarDecl &D);
65 
66  virtual llvm::Type *convertOpenCLSpecificType(const Type *T);
67 
68  virtual llvm::Type *getPipeType(const PipeType *T);
69 
70  llvm::PointerType *getSamplerType(const Type *T);
71 
72  // Returns a value which indicates the size in bytes of the pipe
73  // element.
74  virtual llvm::Value *getPipeElemSize(const Expr *PipeArg);
75 
76  // Returns a value which indicates the alignment in bytes of the pipe
77  // element.
78  virtual llvm::Value *getPipeElemAlign(const Expr *PipeArg);
79 
80  /// \return __generic void* type.
81  llvm::PointerType *getGenericVoidPointerType();
82 
83  /// \return enqueued block information for enqueued block.
85  const Expr *E);
86 
87  /// Record invoke function and block literal emitted during normal
88  /// codegen for a block expression. The information is used by
89  /// emitOpenCLEnqueuedBlock to emit wrapper kernel.
90  ///
91  /// \param InvokeF invoke function emitted for the block expression.
92  /// \param Block block literal emitted for the block expression.
93  void recordBlockInfo(const BlockExpr *E, llvm::Function *InvokeF,
94  llvm::Value *Block);
95 };
96 
97 }
98 }
99 
100 #endif
C Language Family Type Representation.
The base class of the type hierarchy.
Definition: Type.h:1407
EnqueuedBlockInfo emitOpenCLEnqueuedBlock(CodeGenFunction &CGF, const Expr *E)
llvm::Value * BlockArg
Enqueued block kernel.
virtual llvm::Value * getPipeElemAlign(const Expr *PipeArg)
Represents a variable declaration or definition.
Definition: Decl.h:813
PipeType - OpenCL20.
Definition: Type.h:6005
CodeGenFunction - This class organizes the per-function state that is used while generating LLVM code...
void recordBlockInfo(const BlockExpr *E, llvm::Function *InvokeF, llvm::Value *Block)
Record invoke function and block literal emitted during normal codegen for a block expression...
virtual llvm::Type * getPipeType(const PipeType *T, StringRef Name, llvm::Type *&PipeTy)
llvm::PointerType * getSamplerType(const Type *T)
virtual llvm::Type * convertOpenCLSpecificType(const Type *T)
This represents one expression.
Definition: Expr.h:106
llvm::DenseMap< const Expr *, EnqueuedBlockInfo > EnqueuedBlockMap
Maps block expression to block information.
virtual void EmitWorkGroupLocalVarDecl(CodeGenFunction &CGF, const VarDecl &D)
Emit the IR required for a work-group-local variable declaration, and add an entry to CGF&#39;s LocalDecl...
BlockExpr - Adaptor class for mixing a BlockDecl with expressions.
Definition: Expr.h:5177
virtual llvm::Value * getPipeElemSize(const Expr *PipeArg)
The l-value was considered opaque, so the alignment was determined from a type.
CGOpenCLRuntime(CodeGenModule &CGM)
This class organizes the cross-function state that is used while generating LLVM code.
Dataflow Directional Tag Classes.
Structure for enqueued block information.
llvm::Function * Kernel
Block invoke function.
llvm::PointerType * getGenericVoidPointerType()