llvm-project/clang/test/CodeGenOpenCL
Alexey Bader 954ba21f85 [OpenCL] Complete image types support.
I. Current implementation of images is not conformant to spec in the following points:
  1. It makes no distinction with respect to access qualifiers and therefore allows to use images with different access type interchangeably. The following code would compile just fine:

        void write_image(write_only image2d_t img);
        kernel void foo(read_only image2d_t img) { write_image(img); } // Accepted code

     which is disallowed according to s6.13.14.

  2. It discards access qualifier on generated code, which leads to generated code for the above example:

        call void @write_image(%opencl.image2d_t* %img);

     In OpenCL2.0 however we can have different calls into write_image with read_only and wite_only images.
     Also generally following compiler steps have no easy way to take different path depending on the image access: linking to the right implementation of image types, performing IR opts and backend codegen differently.

  3. Image types are language keywords and can't be redeclared s6.1.9, which can happen currently as they are just typedef names.
  4. Default access qualifier read_only is to be added if not provided explicitly.

II. This patch corrects the above points as follows:
  1. All images are encapsulated into a separate .def file that is inserted in different points where image handling is required. This avoid a lot of code repetition as all images are handled the same way in the code with no distinction of their exact type.
  2. The Cartesian product of image types and image access qualifiers is added to the builtin types. This simplifies a lot handling of access type mismatch as no operations are allowed by default on distinct Builtin types. Also spec intended access qualifier as special type qualifier that are combined with an image type to form a distinct type (see statement above - images can't be created w/o access qualifiers).
  3. Improves testing of images in Clang.

Author: Anastasia Stulova
Reviewers: bader, mgrang.
Subscribers: pxli168, pekka.jaaskelainen, yaxunl.
Differential Revision: http://reviews.llvm.org/D17821

llvm-svn: 265783
2016-04-08 13:40:33 +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 test for lack of names in release builds 2014-11-26 22:33:04 +00:00
address-spaces-mangling.cl Remove the -cxx-abi command-line flag. 2014-01-14 19:35:09 +00:00
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-num-gpr-attr.cl Fix Clang tests that used CHECK-NEXT-NOT and CHECK-DAG-NOT. 2016-02-26 19:34:01 +00:00
bool_cast.cl [Bugfix] Fix ICE on constexpr vector splat. 2016-01-13 01:52:39 +00:00
builtins-amdgcn.cl AMDGPU: Add frexp_mant + frexp_exp builtins 2016-03-30 22:57:40 +00:00
builtins-r600.cl AMDGPU: Rename builtins to use amdgcn prefix 2016-01-22 21:30:53 +00:00
cl-strict-aliasing.cl Revert r229409: "Hack to try deleting file from build bots" 2015-02-16 18:03:59 +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 OpenCL: Emit global variables in the constant addr space as constant globals 2014-10-16 15:29:19 +00:00
denorms-are-zero.cl Driver: Implement -cl-denorms-are-zero 2014-08-21 13:58:36 +00:00
event_t.cl Account for calling convention specifiers in function definitions in IR test cases 2015-06-29 17:29:50 +00:00
ext-vector-shuffle.cl
fpmath.cl IR: Make metadata typeless in assembly, clang side 2014-12-15 19:10:08 +00:00
half.cl [CodeGen] Support native half inc/dec amounts. 2015-03-24 23:44:42 +00:00
images.cl [OpenCL] Complete image types support. 2016-04-08 13:40:33 +00:00
kernel-arg-info.cl IR: Make metadata typeless in assembly, clang side 2014-12-15 19:10:08 +00:00
kernel-attributes.cl IR: Make metadata typeless in assembly, clang side 2014-12-15 19:10:08 +00:00
kernel-metadata.cl IR: Make metadata typeless in assembly, clang side 2014-12-15 19:10:08 +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
opencl_types.cl [OpenCL] Complete image types support. 2016-04-08 13:40:33 +00:00
pipe_builtin.cl Recommit: R258773 [OpenCL] Pipe builtin functions 2016-01-26 04:03:48 +00:00
pipe_types.cl Add target triple to CodeGenOpenCL/pipe_types.cl test case 2016-01-29 10:45:23 +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
shifts.cl Restores r228382, which was reverted in r228406. 2015-02-25 05:48:23 +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] Add ocl and spir version for spir target 2016-03-24 03:57:17 +00:00
str_literals.cl OpenCL: Emit global variables in the constant addr space as constant globals 2014-10-16 15:29:19 +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