diff options
Diffstat (limited to 'clang/lib/CodeGen')
| -rw-r--r-- | clang/lib/CodeGen/CGBuiltin.cpp | 9 | ||||
| -rw-r--r-- | clang/lib/CodeGen/CGOpenCLRuntime.cpp | 18 | ||||
| -rw-r--r-- | clang/lib/CodeGen/CGOpenCLRuntime.h | 10 |
3 files changed, 25 insertions, 12 deletions
diff --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp index 6a2f2b0a4a1..3987db906d0 100644 --- a/clang/lib/CodeGen/CGBuiltin.cpp +++ b/clang/lib/CodeGen/CGBuiltin.cpp @@ -3051,11 +3051,14 @@ RValue CodeGenFunction::EmitBuiltinExpr(const FunctionDecl *FD, // OpenCL v2.0 s6.13.16.4 Built-in pipe query functions case Builtin::BIget_pipe_num_packets: case Builtin::BIget_pipe_max_packets: { - const char *Name; + const char *BaseName; + const PipeType *PipeTy = E->getArg(0)->getType()->getAs<PipeType>(); if (BuiltinID == Builtin::BIget_pipe_num_packets) - Name = "__get_pipe_num_packets"; + BaseName = "__get_pipe_num_packets"; else - Name = "__get_pipe_max_packets"; + BaseName = "__get_pipe_max_packets"; + auto Name = std::string(BaseName) + + std::string(PipeTy->isReadOnly() ? "_ro" : "_wo"); // Building the generic function prototype. Value *Arg0 = EmitScalarExpr(E->getArg(0)); diff --git a/clang/lib/CodeGen/CGOpenCLRuntime.cpp b/clang/lib/CodeGen/CGOpenCLRuntime.cpp index 15a2221b0f7..1da19a90c38 100644 --- a/clang/lib/CodeGen/CGOpenCLRuntime.cpp +++ b/clang/lib/CodeGen/CGOpenCLRuntime.cpp @@ -66,13 +66,19 @@ llvm::Type *CGOpenCLRuntime::convertOpenCLSpecificType(const Type *T) { } llvm::Type *CGOpenCLRuntime::getPipeType(const PipeType *T) { - if (!PipeTy){ - uint32_t PipeAddrSpc = CGM.getContext().getTargetAddressSpace( - CGM.getContext().getOpenCLTypeAddrSpace(T)); - PipeTy = llvm::PointerType::get(llvm::StructType::create( - CGM.getLLVMContext(), "opencl.pipe_t"), PipeAddrSpc); - } + if (T->isReadOnly()) + return getPipeType(T, "opencl.pipe_ro_t", PipeROTy); + else + return getPipeType(T, "opencl.pipe_wo_t", PipeWOTy); +} +llvm::Type *CGOpenCLRuntime::getPipeType(const PipeType *T, StringRef Name, + llvm::Type *&PipeTy) { + if (!PipeTy) + PipeTy = llvm::PointerType::get(llvm::StructType::create( + CGM.getLLVMContext(), Name), + CGM.getContext().getTargetAddressSpace( + CGM.getContext().getOpenCLTypeAddrSpace(T))); return PipeTy; } diff --git a/clang/lib/CodeGen/CGOpenCLRuntime.h b/clang/lib/CodeGen/CGOpenCLRuntime.h index 9378b6242ca..2df1acd2363 100644 --- a/clang/lib/CodeGen/CGOpenCLRuntime.h +++ b/clang/lib/CodeGen/CGOpenCLRuntime.h @@ -35,7 +35,8 @@ class CodeGenModule; class CGOpenCLRuntime { protected: CodeGenModule &CGM; - llvm::Type *PipeTy; + llvm::Type *PipeROTy; + llvm::Type *PipeWOTy; llvm::PointerType *SamplerTy; /// Structure for enqueued block information. @@ -47,9 +48,12 @@ protected: /// Maps block expression to block information. llvm::DenseMap<const Expr *, EnqueuedBlockInfo> EnqueuedBlockMap; + virtual llvm::Type *getPipeType(const PipeType *T, StringRef Name, + llvm::Type *&PipeTy); + public: - CGOpenCLRuntime(CodeGenModule &CGM) : CGM(CGM), PipeTy(nullptr), - SamplerTy(nullptr) {} + CGOpenCLRuntime(CodeGenModule &CGM) : CGM(CGM), + PipeROTy(nullptr), PipeWOTy(nullptr), SamplerTy(nullptr) {} virtual ~CGOpenCLRuntime(); /// Emit the IR required for a work-group-local variable declaration, and add |

