Debian Codegraph @

gcc/testsuite/gcc.target/x86_64/abi/bf16/bf16-helper.h

raw
1 typedef __bf16 __m128bf16 __attribute__((__vector_size__(16), __aligned__(16)));
2 typedef __bf16 __m256bf16 __attribute__((__vector_size__(32), __aligned__(32)));
3 typedef __bf16 __m512bf16 __attribute__((__vector_size__(64), __aligned__(64)));
4
5 typedef union
6 {
7 float f;
8 unsigned int u;
9 __bf16 b[2];
10 } unionf_b;
11
12 static __bf16 make_f32_bf16 (float f)
13 {
14 unionf_b tmp;
15 tmp.f = f;
16 return tmp.b[1];
17 }
18
19 static float make_bf16_f32 (__bf16 bf)
20 {
21 unionf_b tmp;
22 tmp.u = 0;
23 tmp.b[1] = bf;
24 return tmp.f;
25 }
26
27 static int check_bf16 (__bf16 bf1, __bf16 bf2)
28 {
29 unionf_b tmp1, tmp2;
30 tmp1.u = 0;
31 tmp2.u = 0;
32 tmp1.b[1] = bf1;
33 tmp2.b[1] = bf2;
34 return (tmp1.u == tmp2.u);
35 }
36
37 static int check_bf16_float (__bf16 bf, float f)
38 {
39 unionf_b tmp1, tmp2;
40 tmp1.u = 0;
41 tmp1.b[0] = bf;
42 tmp2.f = f;
43 tmp2.u >>= 16;
44 return (tmp1.u == tmp2.u);
45 }