19 #include "llvm/IR/DerivedTypes.h"
20 #include "llvm/IR/GlobalValue.h"
23 using namespace clang;
24 using namespace CodeGen;
41 switch (cast<BuiltinType>(
T)->
getKind()) {
44 #define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \
45 case BuiltinType::Id: \
46 return llvm::IntegerType::getInt64Ty(CGM.getLLVMContext());
47 #include "clang/Basic/OpenCLImageTypes.def"
48 #define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \
49 case BuiltinType::Sampled##Id: \
50 return llvm::StructType::get( \
51 llvm::IntegerType::getInt64Ty(CGM.getLLVMContext()), \
52 llvm::IntegerType::getInt32Ty(CGM.getLLVMContext()));
53 #define IMAGE_WRITE_TYPE(Type, Id, Ext)
54 #define IMAGE_READ_WRITE_TYPE(Type, Id, Ext)
55 #include "clang/Basic/OpenCLImageTypes.def"
56 case BuiltinType::OCLSampler:
84 llvm::Type *&PipeTy) {
109 return llvm::ConstantInt::get(Int32Ty, TypeSize,
false);
119 return llvm::ConstantInt::get(Int32Ty, TypeSize,
false);
124 return llvm::PointerType::get(
135 const Expr *Prev =
nullptr;
136 while(!isa<BlockExpr>(
E) &&
E != Prev) {
139 if (
auto DR = dyn_cast<DeclRefExpr>(
E)) {
140 E = cast<VarDecl>(DR->getDecl())->getInit();
143 return cast<BlockExpr>(
E);
149 llvm::Function *InvokeF,
150 llvm::Value *Block, llvm::Type *BlockTy) {
152 assert(isa<llvm::Function>(InvokeF) &&
"Invalid invoke function");
153 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)
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)
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
const llvm::Triple & getTriple() const
llvm::LLVMContext & getLLVMContext()
const TargetCodeGenInfo & getTargetCodeGenInfo()
ASTContext & getContext() const
virtual llvm::Value * createEnqueuedBlockKernel(CodeGenFunction &CGF, llvm::Function *BlockInvokeFunc, llvm::Type *BlockTy) const
Create an OpenCL kernel for an enqueued block.
virtual llvm::Type * getOpenCLType(CodeGenModule &CGM, const Type *T) const
Return an LLVM type that corresponds to an OpenCL type.
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.
The JSON file list parser is used to communicate input to InstallAPI.
const FunctionProtoType * T
Structure for enqueued block information.