diff options
| author | Sven van Haastregt <sven.vanhaastregt@arm.com> | 2019-08-19 11:56:03 +0000 |
|---|---|---|
| committer | Sven van Haastregt <sven.vanhaastregt@arm.com> | 2019-08-19 11:56:03 +0000 |
| commit | b21a3654f0b916e885c6e55af36fecefdd2569b5 (patch) | |
| tree | ed4ec4039a651268da94d18dc916a999b4f02693 /clang/test/SemaOpenCL | |
| parent | 0684132107e51b506b31e3be7dc2e3181b90a4b4 (diff) | |
| download | bcm5719-llvm-b21a3654f0b916e885c6e55af36fecefdd2569b5.tar.gz bcm5719-llvm-b21a3654f0b916e885c6e55af36fecefdd2569b5.zip | |
[OpenCL] Add generic type handling for builtin functions
Generic types are an abstraction of type sets. It mimics the way
functions are defined in the OpenCL specification. For example,
floatN can abstract all the vector sizes of the float type.
This allows to
* stick more closely to the specification, which uses generic types;
* factorize definitions of functions with numerous prototypes in the
tablegen file; and
* reduce the memory impact of functions with many overloads.
Patch by Pierre Gondois and Sven van Haastregt.
Differential Revision: https://reviews.llvm.org/D65456
llvm-svn: 369253
Diffstat (limited to 'clang/test/SemaOpenCL')
| -rw-r--r-- | clang/test/SemaOpenCL/fdeclare-opencl-builtins.cl | 29 |
1 files changed, 21 insertions, 8 deletions
diff --git a/clang/test/SemaOpenCL/fdeclare-opencl-builtins.cl b/clang/test/SemaOpenCL/fdeclare-opencl-builtins.cl index 12a5431e1e9..66afb630d7d 100644 --- a/clang/test/SemaOpenCL/fdeclare-opencl-builtins.cl +++ b/clang/test/SemaOpenCL/fdeclare-opencl-builtins.cl @@ -1,28 +1,41 @@ // RUN: %clang_cc1 %s -triple spir -verify -pedantic -fsyntax-only -cl-std=CL2.0 -fdeclare-opencl-builtins -DNO_HEADER // RUN: %clang_cc1 %s -triple spir -verify -pedantic -fsyntax-only -cl-std=CL2.0 -fdeclare-opencl-builtins -finclude-default-header +// expected-no-diagnostics // Test the -fdeclare-opencl-builtins option. // Provide typedefs when invoking clang without -finclude-default-header. #ifdef NO_HEADER +typedef char char2 __attribute__((ext_vector_type(2))); +typedef char char4 __attribute__((ext_vector_type(4))); 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 int int4 __attribute__((ext_vector_type(4))); +typedef long long2 __attribute__((ext_vector_type(2))); typedef unsigned int uint; typedef __SIZE_TYPE__ size_t; #endif -kernel void basic_conversion(global float4 *buf, global int4 *res) { - res[0] = convert_int4(buf[0]); +kernel void basic_conversion() { + double d; + float f; + char2 c2; + long2 l2; + float4 f4; + int4 i4; + + f = convert_float(d); + d = convert_double_sat_rtp(f); + l2 = convert_long2_rtz(c2); + i4 = convert_int4_sat(f4); } -kernel void basic_readonly_image_type(__read_only image2d_t img, int2 coord, global float4 *out) { - out[0] = read_imagef(img, coord); +char4 test_int(char c, char4 c4) { + char m = max(c, c); + char4 m4 = max(c4, c4); + return max(c4, c); } 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(); } |

