20 #include "llvm/IR/DerivedTypes.h" 21 #include "llvm/IR/GlobalValue.h" 24 using namespace clang;
25 using namespace CodeGen;
36 "Not an OpenCL specific type!");
41 switch (cast<BuiltinType>(T)->getKind()) {
43 llvm_unreachable(
"Unexpected opencl builtin type!");
45 #define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \ 46 case BuiltinType::Id: \ 47 return llvm::PointerType::get( \ 48 llvm::StructType::create(Ctx, "opencl." #ImgType "_" #Suffix "_t"), \ 50 #include "clang/Basic/OpenCLImageTypes.def" 51 case BuiltinType::OCLSampler:
53 case BuiltinType::OCLEvent:
54 return llvm::PointerType::get(
56 case BuiltinType::OCLClkEvent:
57 return llvm::PointerType::get(
59 case BuiltinType::OCLQueue:
60 return llvm::PointerType::get(
62 case BuiltinType::OCLReserveID:
63 return llvm::PointerType::get(
95 return llvm::ConstantInt::get(Int32Ty, TypeSize,
false);
105 return llvm::ConstantInt::get(Int32Ty, TypeSize,
false);
110 return llvm::IntegerType::getInt8PtrTy(
119 if (
auto DR = dyn_cast<DeclRefExpr>(E)) {
120 E = cast<VarDecl>(DR->getDecl())->getInit();
122 if (
auto Cast = dyn_cast<CastExpr>(E)) {
123 E = Cast->getSubExpr();
125 auto *Block = cast<BlockExpr>(E);
136 llvm::Function *Invoke;
139 CGF, Invoke, V->stripPointerCasts());
142 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)
VarDecl - An instance of this class is created to represent a variable declaration or definition...
const T * getAs() const
Member-template getAs<specific type>'.
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...
virtual ~CGOpenCLRuntime()
llvm::Value * EmitBlockLiteral(const BlockExpr *, llvm::Function **InvokeF=nullptr)
Emit block literal.
llvm::PointerType * getSamplerType(const Type *T)
virtual llvm::Type * convertOpenCLSpecificType(const Type *T)
Expr - This represents one expression.
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's LocalDecl...
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::PointerType * SamplerTy
LangAS getOpenCLTypeAddrSpace(const Type *T) const
Get address space for OpenCL type.
The l-value was considered opaque, so the alignment was determined from a type.
const TargetCodeGenInfo & getTargetHooks() const
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.
virtual llvm::Type * getPipeType(const PipeType *T)
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