diff options
Diffstat (limited to 'clang/lib/CodeGen/CGOpenCLRuntime.cpp')
-rw-r--r-- | clang/lib/CodeGen/CGOpenCLRuntime.cpp | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/clang/lib/CodeGen/CGOpenCLRuntime.cpp b/clang/lib/CodeGen/CGOpenCLRuntime.cpp index 8983fdeafbc..9062936fdd1 100644 --- a/clang/lib/CodeGen/CGOpenCLRuntime.cpp +++ b/clang/lib/CodeGen/CGOpenCLRuntime.cpp @@ -38,7 +38,7 @@ llvm::Type *CGOpenCLRuntime::convertOpenCLSpecificType(const Type *T) { uint32_t ImgAddrSpc = CGM.getContext().getTargetAddressSpace( CGM.getTarget().getOpenCLImageAddrSpace()); switch (cast<BuiltinType>(T)->getKind()) { - default: + default: llvm_unreachable("Unexpected opencl builtin type!"); return nullptr; #define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \ @@ -86,3 +86,23 @@ llvm::PointerType *CGOpenCLRuntime::getSamplerType() { LangAS::opencl_constant)); return SamplerTy; } + +llvm::Value *CGOpenCLRuntime::getPipeElemSize(const Expr *PipeArg) { + const PipeType *PipeTy = PipeArg->getType()->getAs<PipeType>(); + // The type of the last (implicit) argument to be passed. + llvm::Type *Int32Ty = llvm::IntegerType::getInt32Ty(CGM.getLLVMContext()); + unsigned TypeSize = CGM.getContext() + .getTypeSizeInChars(PipeTy->getElementType()) + .getQuantity(); + return llvm::ConstantInt::get(Int32Ty, TypeSize, false); +} + +llvm::Value *CGOpenCLRuntime::getPipeElemAlign(const Expr *PipeArg) { + const PipeType *PipeTy = PipeArg->getType()->getAs<PipeType>(); + // The type of the last (implicit) argument to be passed. + llvm::Type *Int32Ty = llvm::IntegerType::getInt32Ty(CGM.getLLVMContext()); + unsigned TypeSize = CGM.getContext() + .getTypeAlignInChars(PipeTy->getElementType()) + .getQuantity(); + return llvm::ConstantInt::get(Int32Ty, TypeSize, false); +} |