llvm-project/clang/test/CodeGenOpenCL
Yaxun Liu 0bc4b2d337 [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 (3d4eec6162).

Differential Revision: https://reviews.llvm.org/D21567

llvm-svn: 277024
2016-07-28 19:26:30 +00:00
..
2011-04-15-vec-init-from-vec.cl
addr-space-struct-arg.cl Prune CRLF. 2014-10-27 12:37:26 +00:00
address-space-constant-initializers.cl Test case updates for explicit type parameter to the gep operator 2015-03-13 18:21:46 +00:00
address-spaces-conversions.cl [OpenCL] Fix bug in mergeTypes which causes equivalent types treated as different. 2016-04-28 17:34:57 +00:00
address-spaces-mangling.cl
address-spaces.cl [OpenCL 2.0] Apply default address space (AS). 2015-11-23 11:14:44 +00:00
amdgcn-flat-scratch-name.cl AMDGPU: Fix inconsistent register name for flat_scratch 2016-02-27 09:06:22 +00:00
amdgpu-call-kernel.cl AMDGPU: Set amdgpu_kernel calling convention for OpenCL kernels. 2016-06-30 09:06:33 +00:00
amdgpu-calling-conv.cl AMDGPU: Set amdgpu_kernel calling convention for OpenCL kernels. 2016-06-30 09:06:33 +00:00
amdgpu-num-gpr-attr.cl AMDGPU: Set amdgpu_kernel calling convention for OpenCL kernels. 2016-06-30 09:06:33 +00:00
as_type.cl Let FuncAttrs infer the 'returned' argument attribute 2016-07-19 19:59:24 +00:00
bool_cast.cl [Bugfix] Fix ICE on constexpr vector splat. 2016-01-13 01:52:39 +00:00
builtins-amdgcn-error.cl AMDGPU: Verify subtarget specific builtins 2016-06-08 01:56:42 +00:00
builtins-amdgcn-vi.cl AMDGPU: Verify subtarget specific builtins 2016-06-08 01:56:42 +00:00
builtins-amdgcn.cl AMDGPU: Remove legacy ldexp builtin 2016-07-15 21:33:06 +00:00
builtins-generic-amdgcn.cl AMDGPU: Add test for generic builtin behavior 2016-04-14 22:34:39 +00:00
builtins-r600.cl AMDGPU: Remove legacy ldexp builtin 2016-07-15 21:33:06 +00:00
cl-strict-aliasing.cl Revert r229409: "Hack to try deleting file from build bots" 2015-02-16 18:03:59 +00:00
cl20-device-side-enqueue.cl [OpenCL] An implementation of device side enqueue (DSE) from OpenCL v2.0 s6.13.17. 2016-07-05 11:31:24 +00:00
const-str-array-decay.cl Test case updates for explicit type parameter to the gep operator 2015-03-13 18:21:46 +00:00
constant-addr-space-globals.cl Update clang for D20348 2016-06-14 21:02:05 +00:00
denorms-are-zero.cl Driver: Implement -cl-denorms-are-zero 2014-08-21 13:58:36 +00:00
event_t.cl [OpenCL] Allow explicit cast of 0 to event_t. 2016-05-20 17:18:16 +00:00
ext-vector-shuffle.cl
fpmath.cl [OpenCL] Add supported OpenCL extensions to target info. 2016-05-16 17:06:34 +00:00
half.cl [OpenCL] Add supported OpenCL extensions to target info. 2016-05-16 17:06:34 +00:00
images.cl [OpenCL] Complete image types support. 2016-04-08 13:40:33 +00:00
kernel-arg-info.cl [OpenCL] Fix access qualifiers handling for typedefs 2016-07-08 15:34:59 +00:00
kernel-attributes.cl Attempt to fix MIPS buildbots after r273425. 2016-06-23 09:29:38 +00:00
kernel-metadata.cl [OpenCL] Use function metadata to represent kernel attributes 2016-06-22 14:56:35 +00:00
local-initializer-undef.cl Emit OpenCL local global variables without zeorinitializer 2014-11-03 16:51:53 +00:00
local.cl Account for calling convention specifiers in function definitions in IR test cases 2015-06-29 17:29:50 +00:00
logical-ops.cl
memcpy.cl Sema: Accept pointers to any address space for builtin functions 2015-03-31 16:39:02 +00:00
no-signed-zeros.cl [OpenCL] Add missing -cl-no-signed-zeros option into driver 2016-07-08 20:28:29 +00:00
opencl_types.cl [OpenCL] Generate opaque type for sampler_t and function call for the initializer 2016-07-28 19:26:30 +00:00
pipe_builtin.cl Recommit: R258773 [OpenCL] Pipe builtin functions 2016-01-26 04:03:48 +00:00
pipe_types.cl [OpenCL] Fix code generation of kernel pipe parameters. 2016-07-13 10:28:13 +00:00
ptx-calls.cl IR: Make metadata typeless in assembly, clang side 2014-12-15 19:10:08 +00:00
ptx-kernels.cl IR: Make metadata typeless in assembly, clang side 2014-12-15 19:10:08 +00:00
relaxed-fpmath.cl Remove the cl-no-signed-zeros cc1 option 2015-04-04 14:54:24 +00:00
sampler.cl [OpenCL] Generate opaque type for sampler_t and function call for the initializer 2016-07-28 19:26:30 +00:00
shifts.cl Update clang for D20348 2016-06-14 21:02:05 +00:00
single-precision-constant.cl
spir-calling-conv.cl Re-apply "r226548 - Introduce SPIR calling conventions" reverted in r226558. 2015-01-20 11:20:41 +00:00
spir32_target.cl
spir64_target.cl
spir_version.cl [OpenCL] Fixes bug of missing OCL version metadata on the AMDGCN target 2016-07-19 19:39:45 +00:00
str_literals.cl Update clang for D20348 2016-06-14 21:02:05 +00:00
to_addr_builtin.cl [OpenCL] Add to_{global|local|private} builtin functions. 2016-05-20 19:54:38 +00:00
unroll-hint.cl [OpenCL] Generate metadata for opencl_unroll_hint attribute 2016-02-19 18:30:11 +00:00
vectorLoadStore.cl
vector_literals_nested.cl
vector_literals_valid.cl
vector_logops.cl
vector_odd.cl
vector_shufflevector_valid.cl Fix invalid shufflevector operands 2015-08-02 15:28:10 +00:00
vla.cl [OPENCL] Fix wrongly vla error for OpenCL array. 2016-06-07 04:34:00 +00:00