File: arm-bf16-forbidden-ops.c

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 (71 lines) | stat: -rw-r--r-- 2,364 bytes parent folder | download | duplicates (9)
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
// RUN: %clang_cc1 -fsyntax-only -verify -triple aarch64 -target-feature +bf16 %s

__bf16 test_cast_from_float(float in) {
  return (__bf16)in; // expected-error {{cannot type-cast to __bf16}}
}

__bf16 test_cast_from_float_literal(void) {
  return (__bf16)1.0f; // expected-error {{cannot type-cast to __bf16}}
}

__bf16 test_cast_from_int(int in) {
  return (__bf16)in; // expected-error {{cannot type-cast to __bf16}}
}

__bf16 test_cast_from_int_literal(void) {
  return (__bf16)1; // expected-error {{cannot type-cast to __bf16}}
}

__bf16 test_cast_bfloat(__bf16 in) {
  return (__bf16)in; // this one should work
}

float test_cast_to_float(__bf16 in) {
  return (float)in; // expected-error {{cannot type-cast from __bf16}}
}

int test_cast_to_int(__bf16 in) {
  return (int)in; // expected-error {{cannot type-cast from __bf16}}
}

__bf16 test_implicit_from_float(float in) {
  return in; // expected-error {{returning 'float' from a function with incompatible result type '__bf16'}}
}

__bf16 test_implicit_from_float_literal(void) {
  return 1.0f; // expected-error {{returning 'float' from a function with incompatible result type '__bf16'}}
}

__bf16 test_implicit_from_int(int in) {
  return in; // expected-error {{returning 'int' from a function with incompatible result type '__bf16'}}
}

__bf16 test_implicit_from_int_literal(void) {
  return 1; // expected-error {{returning 'int' from a function with incompatible result type '__bf16'}}
}

__bf16 test_implicit_bfloat(__bf16 in) {
  return in; // this one should work
}

float test_implicit_to_float(__bf16 in) {
  return in; // expected-error {{returning '__bf16' from a function with incompatible result type 'float'}}
}

int test_implicit_to_int(__bf16 in) {
  return in; // expected-error {{returning '__bf16' from a function with incompatible result type 'int'}}
}

__bf16 test_cond(__bf16 a, __bf16 b, _Bool which) {
  // Conditional operator _should_ be supported, without nonsense
  // complaints like 'types __bf16 and __bf16 are not compatible'
  return which ? a : b;
}

__bf16 test_cond_float(__bf16 a, __bf16 b, _Bool which) {
  return which ? a : 1.0f; // expected-error {{incompatible operand types ('__bf16' and 'float')}}
}

__bf16 test_cond_int(__bf16 a, __bf16 b, _Bool which) {
  return which ? a : 1; // expected-error {{incompatible operand types ('__bf16' and 'int')}}
}