diff options
| author | 2017-01-24 08:32:59 +0000 | |
|---|---|---|
| committer | 2017-01-24 08:32:59 +0000 | |
| commit | 53d771aafdbe5b919f264f53cba3788e2c4cffd2 (patch) | |
| tree | 7eca39498be0ff1e3a6daf583cd9ca5886bb2636 /gnu/llvm/tools/clang/lib/CodeGen/CGOpenCLRuntime.cpp | |
| parent | In preparation of compiling our kernels with -ffreestanding, explicitly map (diff) | |
| download | wireguard-openbsd-53d771aafdbe5b919f264f53cba3788e2c4cffd2.tar.xz wireguard-openbsd-53d771aafdbe5b919f264f53cba3788e2c4cffd2.zip | |
Import LLVM 4.0.0 rc1 including clang and lld to help the current
development effort on OpenBSD/arm64.
Diffstat (limited to 'gnu/llvm/tools/clang/lib/CodeGen/CGOpenCLRuntime.cpp')
| -rw-r--r-- | gnu/llvm/tools/clang/lib/CodeGen/CGOpenCLRuntime.cpp | 38 |
1 files changed, 34 insertions, 4 deletions
diff --git a/gnu/llvm/tools/clang/lib/CodeGen/CGOpenCLRuntime.cpp b/gnu/llvm/tools/clang/lib/CodeGen/CGOpenCLRuntime.cpp index 38aebea18ed..9062936fdd1 100644 --- a/gnu/llvm/tools/clang/lib/CodeGen/CGOpenCLRuntime.cpp +++ b/gnu/llvm/tools/clang/lib/CodeGen/CGOpenCLRuntime.cpp @@ -15,6 +15,7 @@ #include "CGOpenCLRuntime.h" #include "CodeGenFunction.h" +#include "TargetInfo.h" #include "llvm/IR/DerivedTypes.h" #include "llvm/IR/GlobalValue.h" #include <assert.h> @@ -34,10 +35,10 @@ llvm::Type *CGOpenCLRuntime::convertOpenCLSpecificType(const Type *T) { "Not an OpenCL specific type!"); llvm::LLVMContext& Ctx = CGM.getLLVMContext(); - uint32_t ImgAddrSpc = - CGM.getContext().getTargetAddressSpace(LangAS::opencl_global); + 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) \ @@ -47,7 +48,7 @@ llvm::Type *CGOpenCLRuntime::convertOpenCLSpecificType(const Type *T) { ImgAddrSpc); #include "clang/Basic/OpenCLImageTypes.def" case BuiltinType::OCLSampler: - return llvm::IntegerType::get(Ctx, 32); + return getSamplerType(); case BuiltinType::OCLEvent: return llvm::PointerType::get(llvm::StructType::create( Ctx, "opencl.event_t"), 0); @@ -76,3 +77,32 @@ llvm::Type *CGOpenCLRuntime::getPipeType() { return PipeTy; } + +llvm::PointerType *CGOpenCLRuntime::getSamplerType() { + if (!SamplerTy) + SamplerTy = llvm::PointerType::get(llvm::StructType::create( + CGM.getLLVMContext(), "opencl.sampler_t"), + CGM.getContext().getTargetAddressSpace( + 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); +} |
