clang  6.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/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 Expr;
27 class VarDecl;
28 
29 namespace CodeGen {
30 
31 class CodeGenFunction;
32 class CodeGenModule;
33 
35 protected:
38  llvm::PointerType *SamplerTy;
39 
40  /// Structure for enqueued block information.
42  llvm::Function *Kernel; /// Enqueued block kernel.
43  llvm::Value *BlockArg; /// The first argument to enqueued block kernel.
44  };
45  /// Maps block expression to block information.
46  llvm::DenseMap<const Expr *, EnqueuedBlockInfo> EnqueuedBlockMap;
47 
48 public:
49  CGOpenCLRuntime(CodeGenModule &CGM) : CGM(CGM), PipeTy(nullptr),
50  SamplerTy(nullptr) {}
51  virtual ~CGOpenCLRuntime();
52 
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.
57  const VarDecl &D);
58 
59  virtual llvm::Type *convertOpenCLSpecificType(const Type *T);
60 
61  virtual llvm::Type *getPipeType(const PipeType *T);
62 
63  llvm::PointerType *getSamplerType(const Type *T);
64 
65  // \brief Returnes a value which indicates the size in bytes of the pipe
66  // element.
67  virtual llvm::Value *getPipeElemSize(const Expr *PipeArg);
68 
69  // \brief Returnes a value which indicates the alignment in bytes of the pipe
70  // element.
71  virtual llvm::Value *getPipeElemAlign(const Expr *PipeArg);
72 
73  /// \return __generic void* type.
74  llvm::PointerType *getGenericVoidPointerType();
75 
76  /// \return enqueued block information for enqueued block.
78  const Expr *E);
79 };
80 
81 }
82 }
83 
84 #endif
C Language Family Type Representation.
The base class of the type hierarchy.
Definition: Type.h:1353
EnqueuedBlockInfo emitOpenCLEnqueuedBlock(CodeGenFunction &CGF, const Expr *E)
llvm::Value * BlockArg
Enqueued block kernel.
virtual llvm::Value * getPipeElemAlign(const Expr *PipeArg)
VarDecl - An instance of this class is created to represent a variable declaration or definition...
Definition: Decl.h:806
PipeType - OpenCL20.
Definition: Type.h:5650
CodeGenFunction - This class organizes the per-function state that is used while generating LLVM code...
llvm::PointerType * getSamplerType(const Type *T)
virtual llvm::Type * convertOpenCLSpecificType(const Type *T)
Expr - This represents one expression.
Definition: Expr.h:106
const FunctionProtoType * T
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...
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.
virtual llvm::Type * getPipeType(const PipeType *T)
llvm::PointerType * getGenericVoidPointerType()