diff options
| author | Sven van Haastregt <sven.vanhaastregt@arm.com> | 2019-06-03 09:39:11 +0000 |
|---|---|---|
| committer | Sven van Haastregt <sven.vanhaastregt@arm.com> | 2019-06-03 09:39:11 +0000 |
| commit | 79a222fcf8c40a8a90e76118e2412e8697d02a89 (patch) | |
| tree | 37712489e82e193408f08b9c7558d1a09928adca /clang/test/SemaOpenCL/fdeclare-opencl-builtins.cl | |
| parent | 301f8fd6327932f0abc03da252aa294bdf6be6df (diff) | |
| download | bcm5719-llvm-79a222fcf8c40a8a90e76118e2412e8697d02a89.tar.gz bcm5719-llvm-79a222fcf8c40a8a90e76118e2412e8697d02a89.zip | |
[OpenCL] Declare builtin functions using TableGen
This patch adds a `-fdeclare-opencl-builtins` command line option to
the clang frontend. This enables clang to verify OpenCL C builtin
function declarations using a fast StringMatcher lookup, instead of
including the opencl-c.h file with the `-finclude-default-header`
option. This avoids the large parse time penalty of the header file.
This commit only adds the basic infrastructure and some of the OpenCL
builtins. It does not cover all builtins defined by the various OpenCL
specifications. As such, it is not a replacement for
`-finclude-default-header` yet.
RFC: http://lists.llvm.org/pipermail/cfe-dev/2018-November/060041.html
Co-authored-by: Pierre Gondois
Co-authored-by: Joey Gouly
Co-authored-by: Sven van Haastregt
Differential Revision: https://reviews.llvm.org/D60763
llvm-svn: 362371
Diffstat (limited to 'clang/test/SemaOpenCL/fdeclare-opencl-builtins.cl')
| -rw-r--r-- | clang/test/SemaOpenCL/fdeclare-opencl-builtins.cl | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/clang/test/SemaOpenCL/fdeclare-opencl-builtins.cl b/clang/test/SemaOpenCL/fdeclare-opencl-builtins.cl new file mode 100644 index 00000000000..a19664f3104 --- /dev/null +++ b/clang/test/SemaOpenCL/fdeclare-opencl-builtins.cl @@ -0,0 +1,24 @@ +// RUN: %clang_cc1 %s -triple spir -verify -pedantic -fsyntax-only -cl-std=CL2.0 -fdeclare-opencl-builtins + +// Test the -fdeclare-opencl-builtins option. + +typedef float float4 __attribute__((ext_vector_type(4))); +typedef int int4 __attribute__((ext_vector_type(4))); +typedef int int2 __attribute__((ext_vector_type(2))); +typedef unsigned int uint; +typedef __SIZE_TYPE__ size_t; + +kernel void basic_conversion(global float4 *buf, global int4 *res) { + res[0] = convert_int4(buf[0]); +} + +kernel void basic_readonly_image_type(__read_only image2d_t img, int2 coord, global float4 *out) { + out[0] = read_imagef(img, coord); +} + +kernel void basic_subgroup(global uint *out) { + out[0] = get_sub_group_size(); +// expected-error@-1{{use of declaration 'get_sub_group_size' requires cl_khr_subgroups extension to be enabled}} +#pragma OPENCL EXTENSION cl_khr_subgroups : enable + out[1] = get_sub_group_size(); +} |

