Debian Codegraph @

llvm-project/llvm/projects/llvm-spirv/test/negative/InvalidAtomicBuiltins.cl

raw
1 // Check that translator doesn't generate atomic instructions for atomic builtins
2 // which are not defined in the spec.
3
4 // RUN: %clang_cc1 -triple spir -O1 -cl-std=cl2.0 -fdeclare-opencl-builtins -finclude-default-header %s -emit-llvm-bc -o %t.bc
5 // RUN: llvm-spirv %t.bc -spirv-text -o - | FileCheck %s
6 // RUN: llvm-spirv %t.bc -o %t.spv
7 // RUN: spirv-val %t.spv
8
9 // CHECK-LABEL: Label
10 // CHECK-NOT: Atomic
11
12 #pragma OPENCL EXTENSION cl_khr_int64_base_atomics : enable
13 #pragma OPENCL EXTENSION cl_khr_int64_extended_atomics : enable
14
15 float __attribute__((overloadable)) atomic_add(volatile __global float *p, float val);
16 float __attribute__((overloadable)) atomic_sub(volatile __global float *p, float val);
17 float __attribute__((overloadable)) atomic_inc(volatile __global float *p, float val);
18 float __attribute__((overloadable)) atomic_dec(volatile __global float *p, float val);
19 float __attribute__((overloadable)) atomic_cmpxchg(volatile __global float *p, float val);
20 double __attribute__((overloadable)) atomic_min(volatile __global double *p, double val);
21 double __attribute__((overloadable)) atomic_max(volatile __global double *p, double val);
22 double __attribute__((overloadable)) atomic_and(volatile __global double *p, double val);
23 double __attribute__((overloadable)) atomic_or(volatile __global double *p, double val);
24 double __attribute__((overloadable)) atomic_xor(volatile __global double *p, double val);
25
26 float __attribute__((overloadable)) atom_add(volatile __global float *p, float val);
27 float __attribute__((overloadable)) atom_sub(volatile __global float *p, float val);
28 float __attribute__((overloadable)) atom_inc(volatile __global float *p, float val);
29 float __attribute__((overloadable)) atom_dec(volatile __global float *p, float val);
30 float __attribute__((overloadable)) atom_cmpxchg(volatile __global float *p, float val);
31 double __attribute__((overloadable)) atom_min(volatile __global double *p, double val);
32 double __attribute__((overloadable)) atom_max(volatile __global double *p, double val);
33 double __attribute__((overloadable)) atom_and(volatile __global double *p, double val);
34 double __attribute__((overloadable)) atom_or(volatile __global double *p, double val);
35 double __attribute__((overloadable)) atom_xor(volatile __global double *p, double val);
36
37 float __attribute__((overloadable)) atomic_fetch_or(volatile generic atomic_float *object, float operand, memory_order order);
38 float __attribute__((overloadable)) atomic_fetch_xor(volatile generic atomic_float *object, float operand, memory_order order);
39 double __attribute__((overloadable)) atomic_fetch_and(volatile generic atomic_double *object, double operand, memory_order order);
40 float __attribute__((overloadable)) atomic_fetch_or_explicit(volatile generic atomic_float *object, float operand, memory_order order);
41 float __attribute__((overloadable)) atomic_fetch_xor_explicit(volatile generic atomic_float *object, float operand, memory_order order);
42 double __attribute__((overloadable)) atomic_fetch_and_explicit(volatile generic atomic_double *object, double operand, memory_order order);
43
44 __kernel void test_atomic_fn(volatile __global float *p,
45 volatile __global double *pp,
46 float val,
47 memory_order order)
48 {
49 float f = 0.0f;
50 double d = 0.0;
51
52 f = atomic_add(p, val);
53 f = atomic_sub(p, val);
54 f = atomic_inc(p, val);
55 f = atomic_dec(p, val);
56 f = atomic_cmpxchg(p, val);
57 d = atomic_min(pp, val);
58 d = atomic_max(pp, val);
59 d = atomic_and(pp, val);
60 d = atomic_or(pp, val);
61 d = atomic_xor(pp, val);
62
63 f = atom_add(p, val);
64 f = atom_sub(p, val);
65 f = atom_inc(p, val);
66 f = atom_dec(p, val);
67 f = atom_cmpxchg(p, val);
68 d = atom_min(pp, val);
69 d = atom_max(pp, val);
70 d = atom_and(pp, val);
71 d = atom_or(pp, val);
72 d = atom_xor(pp, val);
73
74 f = atomic_fetch_or(p, val, order);
75 f = atomic_fetch_xor(p, val, order);
76 d = atomic_fetch_and(pp, val, order);
77 f = atomic_fetch_or_explicit(p, val, order);
78 f = atomic_fetch_xor_explicit(p, val, order);
79 d = atomic_fetch_and_explicit(pp, val, order);
80 }