xref: /llvm-project/clang/test/CodeGenOpenCL/arm-integer-dot-product.cl (revision b0e4897a1bd2ea5eeeb8c104e32df1402a397ac1)
1// RUN: %clang_cc1 %s -triple spir-unknown-unknown -finclude-default-header -fdeclare-opencl-builtins -cl-std=CL1.2 -emit-llvm -o - -O0 | FileCheck %s
2
3// Pragmas are only accepted for backward compatibility.
4// The builtins are made available with the following defines.
5
6#define cl_arm_integer_dot_product_int8 1
7#define cl_arm_integer_dot_product_accumulate_int8 1
8#define cl_arm_integer_dot_product_accumulate_int16 1
9#define cl_arm_integer_dot_product_accumulate_saturate_int8 1
10
11#pragma OPENCL EXTENSION cl_arm_integer_dot_product_int8 : enable
12#pragma OPENCL EXTENSION cl_arm_integer_dot_product_int8 : disable
13void test_int8(uchar4 ua, uchar4 ub, char4 sa, char4 sb) {
14    uint ur = arm_dot(ua, ub);
15    // CHECK: call spir_func i32 @_Z7arm_dotDv4_hS_
16    int sr = arm_dot(sa, sb);
17    // CHECK: call spir_func i32 @_Z7arm_dotDv4_cS_
18}
19
20#pragma OPENCL EXTENSION cl_arm_integer_dot_product_accumulate_int8 : enable
21#pragma OPENCL EXTENSION cl_arm_integer_dot_product_accumulate_int8 : disable
22void test_accumulate_int8(uchar4 ua, uchar4 ub, uint uc, char4 sa, char4 sb, int c) {
23    uint ur = arm_dot_acc(ua, ub, uc);
24    // CHECK: call spir_func i32 @_Z11arm_dot_accDv4_hS_j
25    int sr = arm_dot_acc(sa, sb, c);
26    // CHECK: call spir_func i32 @_Z11arm_dot_accDv4_cS_i
27}
28
29#pragma OPENCL EXTENSION cl_arm_integer_dot_product_accumulate_int16 : enable
30#pragma OPENCL EXTENSION cl_arm_integer_dot_product_accumulate_int16 : disable
31void test_accumulate_int16(ushort2 ua, ushort2 ub, uint uc, short2 sa, short2 sb, int c) {
32    uint ur = arm_dot_acc(ua, ub, uc);
33    // CHECK: call spir_func i32 @_Z11arm_dot_accDv2_tS_j
34    int sr = arm_dot_acc(sa, sb, c);
35    // CHECK: call spir_func i32 @_Z11arm_dot_accDv2_sS_i
36}
37
38#pragma OPENCL EXTENSION cl_arm_integer_dot_product_accumulate_saturate_int8 : enable
39#pragma OPENCL EXTENSION cl_arm_integer_dot_product_accumulate_saturate_int8 : disable
40void test_accumulate_saturate_int8(uchar4 ua, uchar4 ub, uint uc, char4 sa, char4 sb, int c) {
41    uint ur = arm_dot_acc_sat(ua, ub, uc);
42    // CHECK: call spir_func i32 @_Z15arm_dot_acc_satDv4_hS_j
43    int sr = arm_dot_acc_sat(sa, sb, c);
44    // CHECK: call spir_func i32 @_Z15arm_dot_acc_satDv4_cS_i
45}
46