blob: 12a5431e1e9a2a1a7c3dcd49c308e0e4707b3369 [file] [log] [blame]
Sven van Haastregtaf1c2302019-06-19 12:48:22 +00001// RUN: %clang_cc1 %s -triple spir -verify -pedantic -fsyntax-only -cl-std=CL2.0 -fdeclare-opencl-builtins -DNO_HEADER
2// RUN: %clang_cc1 %s -triple spir -verify -pedantic -fsyntax-only -cl-std=CL2.0 -fdeclare-opencl-builtins -finclude-default-header
Sven van Haastregt79a222f2019-06-03 09:39:11 +00003
4// Test the -fdeclare-opencl-builtins option.
5
Sven van Haastregtaf1c2302019-06-19 12:48:22 +00006// Provide typedefs when invoking clang without -finclude-default-header.
7#ifdef NO_HEADER
Sven van Haastregt79a222f2019-06-03 09:39:11 +00008typedef float float4 __attribute__((ext_vector_type(4)));
9typedef int int4 __attribute__((ext_vector_type(4)));
10typedef int int2 __attribute__((ext_vector_type(2)));
11typedef unsigned int uint;
12typedef __SIZE_TYPE__ size_t;
Sven van Haastregtaf1c2302019-06-19 12:48:22 +000013#endif
Sven van Haastregt79a222f2019-06-03 09:39:11 +000014
15kernel void basic_conversion(global float4 *buf, global int4 *res) {
16 res[0] = convert_int4(buf[0]);
17}
18
19kernel void basic_readonly_image_type(__read_only image2d_t img, int2 coord, global float4 *out) {
20 out[0] = read_imagef(img, coord);
21}
22
23kernel void basic_subgroup(global uint *out) {
24 out[0] = get_sub_group_size();
25// expected-error@-1{{use of declaration 'get_sub_group_size' requires cl_khr_subgroups extension to be enabled}}
26#pragma OPENCL EXTENSION cl_khr_subgroups : enable
27 out[1] = get_sub_group_size();
28}