19 #include "llvm/IR/DerivedTypes.h" 20 #include "llvm/IR/GlobalValue.h" 23 using namespace clang;
24 using namespace CodeGen;
35 "Not an OpenCL specific type!");
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 llvm::PointerType::get( \ 47 llvm::StructType::create(Ctx, "opencl." #ImgType "_" #Suffix "_t"), \ 49 #include "clang/Basic/OpenCLImageTypes.def" 50 case BuiltinType::OCLSampler:
52 case BuiltinType::OCLEvent:
53 return llvm::PointerType::get(
55 case BuiltinType::OCLClkEvent:
56 return llvm::PointerType::get(
58 case BuiltinType::OCLQueue:
59 return llvm::PointerType::get(
61 case BuiltinType::OCLReserveID:
62 return llvm::PointerType::get(
64 #define EXT_OPAQUE_TYPE(ExtType, Id, Ext) \ 65 case BuiltinType::Id: \ 66 return llvm::PointerType::get( \ 67 llvm::StructType::create(Ctx, "opencl." #ExtType), AddrSpc); 68 #include "clang/Basic/OpenCLExtensionTypes.def" 105 return llvm::ConstantInt::get(Int32Ty, TypeSize,
false);
115 return llvm::ConstantInt::get(Int32Ty, TypeSize,
false);
120 return llvm::IntegerType::getInt8PtrTy(
131 const Expr *Prev =
nullptr;
132 while(!isa<BlockExpr>(E) && E != Prev) {
135 if (
auto DR = dyn_cast<DeclRefExpr>(E)) {
136 E = cast<VarDecl>(DR->getDecl())->getInit();
139 return cast<BlockExpr>(E);
145 llvm::Function *InvokeF,
148 "Block expression emitted twice");
149 assert(isa<llvm::Function>(InvokeF) &&
"Invalid invoke function");
150 assert(Block->getType()->isPointerTy() &&
"Invalid block literal type");
169 "Block expression not emitted");
181 F->addFnAttr(llvm::Attribute::NoUnwind);
void EmitStaticVarDecl(const VarDecl &D, llvm::GlobalValue::LinkageTypes Linkage)
QualType getElementType() const
llvm::LLVMContext & getLLVMContext()
The base class of the type hierarchy.
EnqueuedBlockInfo emitOpenCLEnqueuedBlock(CodeGenFunction &CGF, const Expr *E)
virtual llvm::Value * getPipeElemAlign(const Expr *PipeArg)
Represents a variable declaration or definition.
unsigned ClangCallConvToLLVMCallConv(CallingConv CC)
Convert clang calling convention to LLVM callilng convention.
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 ~CGOpenCLRuntime()
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.
llvm::DenseMap< const Expr *, EnqueuedBlockInfo > EnqueuedBlockMap
Maps block expression to block information.
const T * castAs() const
Member-template castAs<specific type>.
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...
BlockExpr - Adaptor class for mixing a BlockDecl with expressions.
CharUnits getTypeAlignInChars(QualType T) const
Return the ABI-specified alignment of a (complete) type T, in characters.
const LangOptions & getLangOpts() const
ASTContext & getContext() const
virtual llvm::Value * getPipeElemSize(const Expr *PipeArg)
llvm::Function * getInvokeFunction(const Expr *E)
llvm::PointerType * SamplerTy
LangAS getOpenCLTypeAddrSpace(const Type *T) const
Get address space for OpenCL type.
static const BlockExpr * getBlockExpr(const Expr *E)
The l-value was considered opaque, so the alignment was determined from a type.
Expr * IgnoreCasts() LLVM_READONLY
Skip past any casts which might surround this expression until reaching a fixed point.
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, returning the result.
Dataflow Directional Tag Classes.
Structure for enqueued block information.
virtual llvm::Function * createEnqueuedBlockKernel(CodeGenFunction &CGF, llvm::Function *BlockInvokeFunc, llvm::Value *BlockLiteral) const
Create an OpenCL kernel for an enqueued block.
std::unique_ptr< DiagnosticConsumer > create(StringRef OutputFile, DiagnosticOptions *Diags, bool MergeChildRecords=false)
Returns a DiagnosticConsumer that serializes diagnostics to a bitcode file.
CodeGenTypes & getTypes() const
Internal linkage, which indicates that the entity can be referred to from within the translation unit...
CharUnits getTypeSizeInChars(QualType T) const
Return the size of the specified (complete) type T, in characters.
llvm::PointerType * getGenericVoidPointerType()
bool isOpenCLSpecificType() const
unsigned getTargetAddressSpace(QualType T) const