clang 19.0.0git
CGOpenCLRuntime.h
Go to the documentation of this file.
1//===----- CGOpenCLRuntime.h - Interface to OpenCL Runtimes -----*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// This provides an abstract class for OpenCL code generation. Concrete
10// subclasses of this implement code generation for specific OpenCL
11// runtime libraries.
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/ADT/StringMap.h"
22#include "llvm/IR/Type.h"
23#include "llvm/IR/Value.h"
24
25namespace clang {
26
27class BlockExpr;
28class Expr;
29class VarDecl;
30
31namespace CodeGen {
32
33class CodeGenFunction;
34class CodeGenModule;
35
37protected:
39 llvm::Type *PipeROTy;
40 llvm::Type *PipeWOTy;
41 llvm::Type *SamplerTy;
42
43 /// Structure for enqueued block information.
45 llvm::Function *InvokeFunc; /// Block invoke function.
46 llvm::Value *KernelHandle; /// Enqueued block kernel reference.
47 llvm::Value *BlockArg; /// The first argument to enqueued block kernel.
48 llvm::Type *BlockTy; /// Type of the block argument.
49 };
50 /// Maps block expression to block information.
51 llvm::DenseMap<const Expr *, EnqueuedBlockInfo> EnqueuedBlockMap;
52
53 virtual llvm::Type *getPipeType(const PipeType *T, StringRef Name,
54 llvm::Type *&PipeTy);
55 llvm::PointerType *getPointerType(const Type *T);
56
57public:
59 PipeROTy(nullptr), PipeWOTy(nullptr), SamplerTy(nullptr) {}
60 virtual ~CGOpenCLRuntime();
61
62 /// Emit the IR required for a work-group-local variable declaration, and add
63 /// an entry to CGF's LocalDeclMap for D. The base class does this using
64 /// CodeGenFunction::EmitStaticVarDecl to emit an internal global for D.
66 const VarDecl &D);
67
68 virtual llvm::Type *convertOpenCLSpecificType(const Type *T);
69
70 virtual llvm::Type *getPipeType(const PipeType *T);
71
72 llvm::Type *getSamplerType(const Type *T);
73
74 // Returns a value which indicates the size in bytes of the pipe
75 // element.
76 virtual llvm::Value *getPipeElemSize(const Expr *PipeArg);
77
78 // Returns a value which indicates the alignment in bytes of the pipe
79 // element.
80 virtual llvm::Value *getPipeElemAlign(const Expr *PipeArg);
81
82 /// \return __generic void* type.
83 llvm::PointerType *getGenericVoidPointerType();
84
85 /// \return enqueued block information for enqueued block.
86 EnqueuedBlockInfo emitOpenCLEnqueuedBlock(CodeGenFunction &CGF,
87 const Expr *E);
88
89 /// Record invoke function and block literal emitted during normal
90 /// codegen for a block expression. The information is used by
91 /// emitOpenCLEnqueuedBlock to emit wrapper kernel.
92 ///
93 /// \param InvokeF invoke function emitted for the block expression.
94 /// \param Block block literal emitted for the block expression.
95 void recordBlockInfo(const BlockExpr *E, llvm::Function *InvokeF,
96 llvm::Value *Block, llvm::Type *BlockTy);
97
98 /// \return LLVM block invoke function emitted for an expression derived from
99 /// the block expression.
100 llvm::Function *getInvokeFunction(const Expr *E);
101};
102
103}
104}
105
106#endif
C Language Family Type Representation.
BlockExpr - Adaptor class for mixing a BlockDecl with expressions.
Definition: Expr.h:6156
virtual llvm::Type * getPipeType(const PipeType *T, StringRef Name, llvm::Type *&PipeTy)
EnqueuedBlockInfo emitOpenCLEnqueuedBlock(CodeGenFunction &CGF, const Expr *E)
llvm::PointerType * getPointerType(const Type *T)
virtual llvm::Value * getPipeElemAlign(const Expr *PipeArg)
llvm::Function * getInvokeFunction(const Expr *E)
void recordBlockInfo(const BlockExpr *E, llvm::Function *InvokeF, llvm::Value *Block, llvm::Type *BlockTy)
Record invoke function and block literal emitted during normal codegen for a block expression.
llvm::PointerType * getGenericVoidPointerType()
llvm::DenseMap< const Expr *, EnqueuedBlockInfo > EnqueuedBlockMap
Maps block expression to block information.
CGOpenCLRuntime(CodeGenModule &CGM)
virtual llvm::Type * convertOpenCLSpecificType(const Type *T)
virtual llvm::Value * getPipeElemSize(const Expr *PipeArg)
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's LocalDecl...
llvm::Type * getSamplerType(const Type *T)
CodeGenFunction - This class organizes the per-function state that is used while generating LLVM code...
This class organizes the cross-function state that is used while generating LLVM code.
This represents one expression.
Definition: Expr.h:110
PipeType - OpenCL20.
Definition: Type.h:6750
The base class of the type hierarchy.
Definition: Type.h:1606
Represents a variable declaration or definition.
Definition: Decl.h:918
The JSON file list parser is used to communicate input to InstallAPI.
Structure for enqueued block information.
llvm::Type * BlockTy
The first argument to enqueued block kernel.
llvm::Value * BlockArg
Enqueued block kernel reference.
llvm::Value * KernelHandle
Block invoke function.