summaryrefslogtreecommitdiffstats
path: root/clang/lib/Edit
diff options
context:
space:
mode:
authorYaxun Liu <Yaxun.Liu@amd.com>2016-07-28 19:26:30 +0000
committerYaxun Liu <Yaxun.Liu@amd.com>2016-07-28 19:26:30 +0000
commit0bc4b2d33731279e41c4ce581a26a9f4386e08bb (patch)
tree9d28cbcc5c46af479aff8ba948633ab4dc3ec9ae /clang/lib/Edit
parent3e6b02770572bf728d33c36d9c38e9be6b23423c (diff)
downloadbcm5719-llvm-0bc4b2d33731279e41c4ce581a26a9f4386e08bb.tar.gz
bcm5719-llvm-0bc4b2d33731279e41c4ce581a26a9f4386e08bb.zip
[OpenCL] Generate opaque type for sampler_t and function call for the initializer
Currently Clang use int32 to represent sampler_t, which have been a source of issue for some backends, because in some backends sampler_t cannot be represented by int32. They have to depend on kernel argument metadata and use IPA to find the sampler arguments and global variables and transform them to target specific sampler type. This patch uses opaque pointer type opencl.sampler_t* for sampler_t. For each use of file-scope sampler variable, it generates a function call of __translate_sampler_initializer. For each initialization of function-scope sampler variable, it generates a function call of __translate_sampler_initializer. Each builtin library can implement its own __translate_sampler_initializer(). Since the real sampler type tends to be architecture dependent, allowing it to be initialized by a library function simplifies backend design. A typical implementation of __translate_sampler_initializer could be a table lookup of real sampler literal values. Since its argument is always a literal, the returned pointer is known at compile time and easily optimized to finally become some literal values directly put into image read instructions. This patch is partially based on Alexey Sotkin's work in Khronos Clang (https://github.com/KhronosGroup/SPIR/commit/3d4eec61623502fc306e8c67c9868be2b136e42b). Differential Revision: https://reviews.llvm.org/D21567 llvm-svn: 277024
Diffstat (limited to 'clang/lib/Edit')
-rw-r--r--clang/lib/Edit/RewriteObjCFoundationAPI.cpp1
1 files changed, 1 insertions, 0 deletions
diff --git a/clang/lib/Edit/RewriteObjCFoundationAPI.cpp b/clang/lib/Edit/RewriteObjCFoundationAPI.cpp
index 482c0f6f856..0ae1ec7e4b1 100644
--- a/clang/lib/Edit/RewriteObjCFoundationAPI.cpp
+++ b/clang/lib/Edit/RewriteObjCFoundationAPI.cpp
@@ -1076,6 +1076,7 @@ static bool rewriteToNumericBoxedExpression(const ObjCMessageExpr *Msg,
case CK_CopyAndAutoreleaseBlockObject:
case CK_BuiltinFnToFnPtr:
case CK_ZeroToOCLEvent:
+ case CK_IntToOCLSampler:
return false;
case CK_BooleanToSignedIntegral:
OpenPOWER on IntegriCloud