xref: /llvm-project/clang/test/Sema/arm-bfloat.cpp (revision c17d9b4b125e5561925aa85aaa0b113e383a2ee5)
1 // REQUIRES: aarch64-registered-target || arm-registered-target
2 
3 // RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 \
4 // RUN: -triple aarch64-arm-none-eabi -target-cpu cortex-a75 \
5 // RUN: -target-feature +bf16 -target-feature +neon %s
6 // RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 \
7 // RUN: -triple arm-arm-none-eabi -target-cpu cortex-a53 \
8 // RUN: -target-feature +bf16 -target-feature +neon %s
9 
10 void test(bool b) {
11   __bf16 bf16;
12 
13   bf16 + bf16; // expected-error {{invalid operands to binary expression ('__bf16' and '__bf16')}}
14   bf16 - bf16; // expected-error {{invalid operands to binary expression ('__bf16' and '__bf16')}}
15   bf16 * bf16; // expected-error {{invalid operands to binary expression ('__bf16' and '__bf16')}}
16   bf16 / bf16; // expected-error {{invalid operands to binary expression ('__bf16' and '__bf16')}}
17 
18   __fp16 fp16;
19 
20   bf16 + fp16; // expected-error {{invalid operands to binary expression ('__bf16' and '__fp16')}}
21   fp16 + bf16; // expected-error {{invalid operands to binary expression ('__fp16' and '__bf16')}}
22   bf16 - fp16; // expected-error {{invalid operands to binary expression ('__bf16' and '__fp16')}}
23   fp16 - bf16; // expected-error {{invalid operands to binary expression ('__fp16' and '__bf16')}}
24   bf16 * fp16; // expected-error {{invalid operands to binary expression ('__bf16' and '__fp16')}}
25   fp16 * bf16; // expected-error {{invalid operands to binary expression ('__fp16' and '__bf16')}}
26   bf16 / fp16; // expected-error {{invalid operands to binary expression ('__bf16' and '__fp16')}}
27   fp16 / bf16; // expected-error {{invalid operands to binary expression ('__fp16' and '__bf16')}}
28   bf16 = fp16; // expected-error {{assigning to '__bf16' from incompatible type '__fp16'}}
29   fp16 = bf16; // expected-error {{assigning to '__fp16' from incompatible type '__bf16'}}
30   bf16 + (b ? fp16 : bf16); // expected-error {{incompatible operand types ('__fp16' and '__bf16')}}
31 }
32 
33 #include <arm_neon.h>
34 
35 void test_vector(bfloat16x4_t a, bfloat16x4_t b, float16x4_t c) {
36   a + b; // expected-error {{invalid operands to binary expression ('bfloat16x4_t' (vector of 4 'bfloat16_t' values) and 'bfloat16x4_t')}}
37   a - b; // expected-error {{invalid operands to binary expression ('bfloat16x4_t' (vector of 4 'bfloat16_t' values) and 'bfloat16x4_t')}}
38   a * b; // expected-error {{invalid operands to binary expression ('bfloat16x4_t' (vector of 4 'bfloat16_t' values) and 'bfloat16x4_t')}}
39   a / b; // expected-error {{invalid operands to binary expression ('bfloat16x4_t' (vector of 4 'bfloat16_t' values) and 'bfloat16x4_t')}}
40 
41   a + c; // expected-error {{invalid operands to binary expression ('bfloat16x4_t' (vector of 4 'bfloat16_t' values) and 'float16x4_t' (vector of 4 'float16_t' values))}}
42   a - c; // expected-error {{invalid operands to binary expression ('bfloat16x4_t' (vector of 4 'bfloat16_t' values) and 'float16x4_t' (vector of 4 'float16_t' values))}}
43   a * c; // expected-error {{invalid operands to binary expression ('bfloat16x4_t' (vector of 4 'bfloat16_t' values) and 'float16x4_t' (vector of 4 'float16_t' values))}}
44   a / c; // expected-error {{invalid operands to binary expression ('bfloat16x4_t' (vector of 4 'bfloat16_t' values) and 'float16x4_t' (vector of 4 'float16_t' values))}}
45   c + b; // expected-error {{invalid operands to binary expression ('float16x4_t' (vector of 4 'float16_t' values) and 'bfloat16x4_t' (vector of 4 'bfloat16_t' values))}}
46   c - b; // expected-error {{invalid operands to binary expression ('float16x4_t' (vector of 4 'float16_t' values) and 'bfloat16x4_t' (vector of 4 'bfloat16_t' values))}}
47   c * b; // expected-error {{invalid operands to binary expression ('float16x4_t' (vector of 4 'float16_t' values) and 'bfloat16x4_t' (vector of 4 'bfloat16_t' values))}}
48   c / b; // expected-error {{invalid operands to binary expression ('float16x4_t' (vector of 4 'float16_t' values) and 'bfloat16x4_t' (vector of 4 'bfloat16_t' values))}}
49 }
50