File: fdeclare-opencl-builtins.cl

package info (click to toggle)
llvm-toolchain-15 1%3A15.0.6-4
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 1,554,644 kB
  • sloc: cpp: 5,922,452; ansic: 1,012,136; asm: 674,362; python: 191,568; objc: 73,855; f90: 42,327; lisp: 31,913; pascal: 11,973; javascript: 10,144; sh: 9,421; perl: 7,447; ml: 5,527; awk: 3,523; makefile: 2,520; xml: 885; cs: 573; fortran: 567
file content (54 lines) | stat: -rw-r--r-- 2,271 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
// RUN: %clang_cc1 -emit-llvm -o - -O0 -triple spir-unknown-unknown -cl-std=CL1.2 -finclude-default-header %s \
// RUN: | FileCheck %s --check-prefixes CHECK,CHECK-NOGAS
// RUN: %clang_cc1 -emit-llvm -o - -O0 -triple spir-unknown-unknown -cl-std=CL1.2 -fdeclare-opencl-builtins -finclude-default-header %s \
// RUN: | FileCheck %s --check-prefixes CHECK,CHECK-NOGAS
// RUN: %clang_cc1 -emit-llvm -o - -O0 -triple spir-unknown-unknown -cl-std=CL3.0 -fdeclare-opencl-builtins -finclude-default-header %s \
// RUN: | FileCheck %s --check-prefixes CHECK,CHECK-GAS
// RUN: %clang_cc1 -emit-llvm -o - -O0 -triple spir-unknown-unknown -cl-std=CL3.0 -fdeclare-opencl-builtins -finclude-default-header \
// RUN: -cl-ext=-__opencl_c_generic_address_space,-__opencl_c_pipes,-__opencl_c_device_enqueue %s \
// RUN: | FileCheck %s --check-prefixes CHECK,CHECK-NOGAS

// Test that mix is correctly defined.
// CHECK-LABEL: @test_float
// CHECK: call spir_func <4 x float> @_Z3mixDv4_fS_f
// CHECK: ret
void test_float(float4 x, float a) {
  float4 ret = mix(x, x, a);
}

// Test that Attr.Const from OpenCLBuiltins.td is lowered to a readnone attribute.
// CHECK-LABEL: @test_const_attr
// CHECK: call spir_func i32 @_Z3maxii({{.*}}) [[ATTR_CONST:#[0-9]]]
// CHECK: ret
int test_const_attr(int a) {
  return max(a, 2);
}

// Test that Attr.Pure from OpenCLBuiltins.td is lowered to a readonly attribute.
// CHECK-LABEL: @test_pure_attr
// CHECK: call spir_func <4 x float> @_Z11read_imagef{{.*}} [[ATTR_PURE:#[0-9]]]
// CHECK: ret
kernel void test_pure_attr(read_only image1d_t img) {
  float4 resf = read_imagef(img, 42);
}

// Test that builtins with only one prototype are mangled.
// CHECK-LABEL: @test_mangling
// CHECK: call spir_func i32 @_Z12get_local_idj
kernel void test_mangling() {
  size_t lid = get_local_id(0);
}

// Test that the correct builtin is called depending on the generic address
// space feature availability.
// CHECK-LABEL: @test_generic_optionality
// CHECK-GAS: call spir_func float @_Z5fractfPU3AS4f
// CHECK-NOGAS: call spir_func float @_Z5fractfPf
void test_generic_optionality(float a, float *b) {
  float res = fract(a, b);
}

// CHECK: attributes [[ATTR_CONST]] =
// CHECK-SAME: readnone
// CHECK: attributes [[ATTR_PURE]] =
// CHECK-SAME: readonly