1// RUN: %clang_cc1 -emit-llvm -o - -O0 -triple spir-unknown-unknown -cl-std=CL1.2 -finclude-default-header %s | FileCheck %s
2// RUN: %clang_cc1 -emit-llvm -o - -O0 -triple spir-unknown-unknown -cl-std=CL1.2 -fdeclare-opencl-builtins -finclude-default-header %s | FileCheck %s
3
4// Test that mix is correctly defined.
5// CHECK-LABEL: @test_float
6// CHECK: call spir_func <4 x float> @_Z3mixDv4_fS_f
7// CHECK: ret
8void test_float(float4 x, float a) {
9  float4 ret = mix(x, x, a);
10}
11
12// Test that Attr.Const from OpenCLBuiltins.td is lowered to a readnone attribute.
13// CHECK-LABEL: @test_const_attr
14// CHECK: call spir_func i32 @_Z3maxii({{.*}}) [[ATTR_CONST:#[0-9]]]
15// CHECK: ret
16int test_const_attr(int a) {
17  return max(a, 2);
18}
19
20// Test that Attr.Pure from OpenCLBuiltins.td is lowered to a readonly attribute.
21// CHECK-LABEL: @test_pure_attr
22// CHECK: call spir_func <4 x float> @_Z11read_imagef{{.*}} [[ATTR_PURE:#[0-9]]]
23// CHECK: ret
24kernel void test_pure_attr(read_only image1d_t img) {
25  float4 resf = read_imagef(img, 42);
26}
27
28// Test that builtins with only one prototype are mangled.
29// CHECK-LABEL: @test_mangling
30// CHECK: call spir_func i32 @_Z12get_local_idj
31kernel void test_mangling() {
32  size_t lid = get_local_id(0);
33}
34
35// CHECK: attributes [[ATTR_CONST]] =
36// CHECK-SAME: readnone
37// CHECK: attributes [[ATTR_PURE]] =
38// CHECK-SAME: readonly
39