19#include "llvm/IR/DerivedTypes.h"
20#include "llvm/IR/GlobalValue.h"
24using namespace CodeGen;
40 switch (cast<BuiltinType>(T)->
getKind()) {
42 llvm_unreachable(
"Unexpected opencl builtin type!");
44#define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \
45 case BuiltinType::Id: \
46 return getPointerType(T, "opencl." #ImgType "_" #Suffix "_t");
47#include "clang/Basic/OpenCLImageTypes.def"
48 case BuiltinType::OCLSampler:
50 case BuiltinType::OCLEvent:
52 case BuiltinType::OCLClkEvent:
54 case BuiltinType::OCLQueue:
56 case BuiltinType::OCLReserveID:
58#define EXT_OPAQUE_TYPE(ExtType, Id, Ext) \
59 case BuiltinType::Id: \
60 return getPointerType(T, "opencl." #ExtType);
61#include "clang/Basic/OpenCLExtensionTypes.def"
75 llvm::PointerType::get(llvm::StructType::create(Ctx, Name), AddrSpc);
91 llvm::Type *&PipeTy) {
93 PipeTy = llvm::PointerType::get(llvm::StructType::create(
122 return llvm::ConstantInt::get(Int32Ty, TypeSize,
false);
132 return llvm::ConstantInt::get(Int32Ty, TypeSize,
false);
137 return llvm::IntegerType::getInt8PtrTy(
148 const Expr *Prev =
nullptr;
149 while(!isa<BlockExpr>(E) && E != Prev) {
152 if (
auto DR = dyn_cast<DeclRefExpr>(E)) {
153 E = cast<VarDecl>(DR->getDecl())->getInit();
156 return cast<BlockExpr>(E);
162 llvm::Function *InvokeF,
163 llvm::Value *
Block, llvm::Type *BlockTy) {
165 assert(isa<llvm::Function>(InvokeF) &&
"Invalid invoke function");
166 assert(
Block->getType()->isPointerTy() &&
"Invalid block literal type");
static const BlockExpr * getBlockExpr(const Expr *E)
static Decl::Kind getKind(const Decl *D)
LangAS getOpenCLTypeAddrSpace(const Type *T) const
Get address space for OpenCL type.
CharUnits getTypeAlignInChars(QualType T) const
Return the ABI-specified alignment of a (complete) type T, in characters.
CharUnits getTypeSizeInChars(QualType T) const
Return the size of the specified (complete) type T, in characters.
unsigned getTargetAddressSpace(LangAS AS) const
BlockExpr - Adaptor class for mixing a BlockDecl with expressions.
const T * getTypePtr() const
Retrieve the underlying type pointer, which refers to a canonical type.
QuantityType getQuantity() const
getQuantity - Get the raw integer representation of this quantity.
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, StringRef Name)
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.
virtual llvm::Type * convertOpenCLSpecificType(const Type *T)
llvm::StringMap< llvm::PointerType * > CachedTys
virtual llvm::Value * getPipeElemSize(const Expr *PipeArg)
virtual ~CGOpenCLRuntime()
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...
void EmitStaticVarDecl(const VarDecl &D, llvm::GlobalValue::LinkageTypes Linkage)
const TargetCodeGenInfo & getTargetHooks() const
llvm::Value * EmitScalarExpr(const Expr *E, bool IgnoreResultAssign=false)
EmitScalarExpr - Emit the computation of the specified expression of LLVM scalar type,...
const LangOptions & getLangOpts() const
ASTContext & getContext() const
const TargetCodeGenInfo & getTargetCodeGenInfo()
llvm::LLVMContext & getLLVMContext()
virtual llvm::Type * getOpenCLType(CodeGenModule &CGM, const Type *T) const
Return an LLVM type that corresponds to an OpenCL type.
virtual llvm::Value * createEnqueuedBlockKernel(CodeGenFunction &CGF, llvm::Function *BlockInvokeFunc, llvm::Type *BlockTy) const
Create an OpenCL kernel for an enqueued block.
This represents one expression.
Expr * IgnoreCasts() LLVM_READONLY
Skip past any casts which might surround this expression until reaching a fixed point.
QualType getElementType() const
The base class of the type hierarchy.
const T * castAs() const
Member-template castAs<specific type>.
bool isOpenCLSpecificType() const
Represents a variable declaration or definition.
Structure for enqueued block information.