File: overload.cl

package info (click to toggle)
llvm-toolchain-19 1%3A19.1.7-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,998,520 kB
  • sloc: cpp: 6,951,680; ansic: 1,486,157; asm: 913,598; python: 232,024; f90: 80,126; objc: 75,281; lisp: 37,276; pascal: 16,990; sh: 10,009; ml: 5,058; perl: 4,724; awk: 3,523; makefile: 3,167; javascript: 2,504; xml: 892; fortran: 664; cs: 573
file content (47 lines) | stat: -rw-r--r-- 2,515 bytes parent folder | download | duplicates (12)
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
// RUN: %clang_cc1 -cl-std=CL2.0 -emit-llvm -o - -triple spir-unknown-unknown %s | FileCheck %s
// RUN: %clang_cc1 -cl-std=CL3.0 -cl-ext=+__opencl_c_generic_address_space -emit-llvm -o - -triple spir-unknown-unknown %s | FileCheck %s

typedef short short4 __attribute__((ext_vector_type(4)));

// CHECK-DAG: declare spir_func <4 x i16> @_Z5clampDv4_sS_S_(<4 x i16> noundef, <4 x i16> noundef, <4 x i16> noundef)
short4 __attribute__ ((overloadable)) clamp(short4 x, short4 minval, short4 maxval);
// CHECK-DAG: declare spir_func <4 x i16> @_Z5clampDv4_sss(<4 x i16> noundef, i16 noundef signext, i16 noundef signext)
short4 __attribute__ ((overloadable)) clamp(short4 x, short minval, short maxval);
void __attribute__((overloadable)) foo(global int *a, global int *b);
void __attribute__((overloadable)) foo(generic int *a, generic int *b);
void __attribute__((overloadable)) bar(generic int *global *a, generic int *global *b);
void __attribute__((overloadable)) bar(generic int *generic *a, generic int *generic *b);

// Checking address space resolution
void kernel test1() {
  global int *a = 0;
  global int *b = 0;
  generic int *c = 0;
  local int *d = 0;
  generic int *generic *gengen = 0;
  generic int *local *genloc = 0;
  generic int *global *genglob = 0;
  // CHECK-DAG: call spir_func void @_Z3fooPU3AS1iS0_(ptr addrspace(1) noundef {{.*}}, ptr addrspace(1) noundef {{.*}})
  foo(a, b);
  // CHECK-DAG: call spir_func void @_Z3fooPU3AS4iS0_(ptr addrspace(4) noundef {{.*}}, ptr addrspace(4) noundef {{.*}})
  foo(b, c);
  // CHECK-DAG: call spir_func void @_Z3fooPU3AS4iS0_(ptr addrspace(4) noundef {{.*}}, ptr addrspace(4) noundef {{.*}})
  foo(a, d);

  // CHECK-DAG: call spir_func void @_Z3barPU3AS4PU3AS4iS2_(ptr addrspace(4) noundef {{.*}}, ptr addrspace(4) noundef {{.*}})
  bar(gengen, genloc);
  // CHECK-DAG: call spir_func void @_Z3barPU3AS4PU3AS4iS2_(ptr addrspace(4) noundef {{.*}}, ptr addrspace(4) noundef {{.*}})
  bar(gengen, genglob);
  // CHECK-DAG: call spir_func void @_Z3barPU3AS1PU3AS4iS2_(ptr addrspace(1) noundef {{.*}}, ptr addrspace(1) noundef {{.*}})
  bar(genglob, genglob);
}

// Checking vector vs scalar resolution
void kernel test2() {
  short4 e0=0;

  // CHECK-DAG: call spir_func <4 x i16> @_Z5clampDv4_sss(<4 x i16> noundef {{.*}}, i16 noundef signext 0, i16 noundef signext 255)
  clamp(e0, 0, 255);
  // CHECK-DAG: call spir_func <4 x i16> @_Z5clampDv4_sS_S_(<4 x i16> noundef {{.*}}, <4 x i16> noundef {{.*}}, <4 x i16> noundef {{.*}})
  clamp(e0, e0, e0);
}