| 1 |
/* { dg-do assemble { target { aarch64*-*-* } } } */ |
| 2 |
/* { dg-require-effective-target arm_v8_2a_bf16_neon_ok } */ |
| 3 |
/* { dg-additional-options "-march=armv8.2-a -O3 --save-temps" } */ |
| 4 |
/* { dg-final { check-function-bodies "**" "" } } */ |
| 5 |
|
| 6 |
#include <arm_neon.h> |
| 7 |
|
| 8 |
/* |
| 9 |
**stacktest1: |
| 10 |
** sub sp, sp, #16 |
| 11 |
** str h0, \[sp, 14\] |
| 12 |
** ldr h0, \[sp, 14\] |
| 13 |
** add sp, sp, 16 |
| 14 |
** ret |
| 15 |
*/ |
| 16 |
bfloat16_t stacktest1 (bfloat16_t __a) |
| 17 |
{ |
| 18 |
volatile bfloat16_t b = __a; |
| 19 |
return b; |
| 20 |
} |
| 21 |
|
| 22 |
/* |
| 23 |
**stacktest2: |
| 24 |
** sub sp, sp, #16 |
| 25 |
** str d0, \[sp, 8\] |
| 26 |
** ldr d0, \[sp, 8\] |
| 27 |
** add sp, sp, 16 |
| 28 |
** ret |
| 29 |
*/ |
| 30 |
bfloat16x4_t stacktest2 (bfloat16x4_t __a) |
| 31 |
{ |
| 32 |
volatile bfloat16x4_t b = __a; |
| 33 |
return b; |
| 34 |
} |
| 35 |
|
| 36 |
/* |
| 37 |
**stacktest3: |
| 38 |
** sub sp, sp, #16 |
| 39 |
** str q0, \[sp\] |
| 40 |
** ldr q0, \[sp\] |
| 41 |
** add sp, sp, 16 |
| 42 |
** ret |
| 43 |
*/ |
| 44 |
bfloat16x8_t stacktest3 (bfloat16x8_t __a) |
| 45 |
{ |
| 46 |
volatile bfloat16x8_t b = __a; |
| 47 |
return b; |
| 48 |
} |
| 49 |
|
| 50 |
/* Test compilation of __attribute__ vectors of 8, 16, 32, etc. BFloats. */ |
| 51 |
typedef bfloat16_t v8bf __attribute__((vector_size(16))); |
| 52 |
typedef bfloat16_t v16bf __attribute__((vector_size(32))); |
| 53 |
typedef bfloat16_t v32bf __attribute__((vector_size(64))); |
| 54 |
typedef bfloat16_t v64bf __attribute__((vector_size(128))); |
| 55 |
typedef bfloat16_t v128bf __attribute__((vector_size(256))); |
| 56 |
|
| 57 |
v8bf stacktest4 (v8bf __a) |
| 58 |
{ |
| 59 |
volatile v8bf b = __a; |
| 60 |
return b; |
| 61 |
} |
| 62 |
|
| 63 |
v16bf stacktest5 (v16bf __a) |
| 64 |
{ |
| 65 |
volatile v16bf b = __a; |
| 66 |
return b; |
| 67 |
} |
| 68 |
|
| 69 |
v32bf stacktest6 (v32bf __a) |
| 70 |
{ |
| 71 |
volatile v32bf b = __a; |
| 72 |
return b; |
| 73 |
} |
| 74 |
|
| 75 |
v64bf stacktest7 (v64bf __a) |
| 76 |
{ |
| 77 |
volatile v64bf b = __a; |
| 78 |
return b; |
| 79 |
} |
| 80 |
|
| 81 |
v128bf stacktest8 (v128bf __a) |
| 82 |
{ |
| 83 |
volatile v128bf b = __a; |
| 84 |
return b; |
| 85 |
} |
| 86 |
|
| 87 |
/* Test use of constant values to assign values to vectors. */ |
| 88 |
|
| 89 |
typedef bfloat16_t v2bf __attribute__((vector_size(4))); |
| 90 |
v2bf c2 (void) { return (v2bf) 0x12345678; } |
| 91 |
|
| 92 |
bfloat16x4_t c3 (void) { return (bfloat16x4_t) 0x1234567812345678; } |