1 // RUN
: %clang_cc1 -emit-llvm -o - -O0 -triple spir-unknown-unknown -cl-std
=CL1.2 -finclude-default-header %s \
2 // RUN
: | FileCheck %s --check-prefixes CHECK
,CHECK-NOGAS
3 // RUN
: %clang_cc1 -emit-llvm -o - -O0 -triple spir-unknown-unknown -cl-std
=CL1.2 -fdeclare-opencl-builtins -finclude-default-header %s \
4 // RUN
: | FileCheck %s --check-prefixes CHECK
,CHECK-NOGAS
5 // RUN
: %clang_cc1 -emit-llvm -o - -O0 -triple spir-unknown-unknown -cl-std
=CL3.0 -fdeclare-opencl-builtins -finclude-default-header %s \
6 // RUN
: | FileCheck %s --check-prefixes CHECK
,CHECK-GAS
7 // RUN
: %clang_cc1 -emit-llvm -o - -O0 -triple spir-unknown-unknown -cl-std
=CL3.0 -fdeclare-opencl-builtins -finclude-default-header \
8 // RUN
: -cl-ext
=-__opencl_c_generic_address_space
,-__opencl_c_pipes
,-__opencl_c_device_enqueue %s \
9 // RUN
: | FileCheck %s --check-prefixes CHECK
,CHECK-NOGAS
11 // Test that mix is correctly defined.
12 // CHECK-LABEL
: @test_float
13 // CHECK
: call spir_func
<4 x float
> @_Z3mixDv4_fS_f
15 void test_float
(float4 x
, float a
) {
16 float4 ret
= mix
(x, x
, a
);
19 // Test that Attr.Const from OpenCLBuiltins.td is lowered to a readnone attribute.
20 // CHECK-LABEL
: @test_const_attr
21 // CHECK
: call spir_func i32
@_Z3maxii
({{.
*}}) [[ATTR_CONST
:#[0-
9]]]
23 int test_const_attr
(int a
) {
27 // Test that Attr.Pure from OpenCLBuiltins.td is lowered to a readonly attribute.
28 // CHECK-LABEL
: @test_pure_attr
29 // CHECK
: call spir_func
<4 x float
> @_Z11read_imagef
{{.
*}} [[ATTR_PURE
:#[0-
9]]]
31 kernel void test_pure_attr
(read_only image1d_t img
) {
32 float4 resf
= read_imagef
(img, 42);
35 // Test that builtins with only one prototype are mangled.
36 // CHECK-LABEL
: @test_mangling
37 // CHECK
: call spir_func i32
@_Z12get_local_idj
38 kernel void test_mangling
() {
39 size_t lid
= get_local_id
(0);
42 // Test that the correct builtin is called depending on the generic address
43 // space feature availability.
44 // CHECK-LABEL
: @test_generic_optionality
45 // CHECK-GAS
: call spir_func float
@_Z5fractfPU3AS4f
46 // CHECK-NOGAS
: call spir_func float
@_Z5fractfPf
47 void test_generic_optionality
(float a
, float
*b
) {
48 float res
= fract
(a, b
);
51 // CHECK
: attributes
[[ATTR_CONST]] =
52 // CHECK-SAME: readnone
53 // CHECK: attributes [[ATTR_PURE]] =
54 // CHECK-SAME: readonly