| 1 |
/* AArch64 FP8 helper functions. |
| 2 |
Do not include this file directly. Use one of arm_neon.h |
| 3 |
arm_sme.h arm_sve.h instead. |
| 4 |
|
| 5 |
Copyright (C) 2024-2025 Free Software Foundation, Inc. |
| 6 |
Contributed by ARM Ltd. |
| 7 |
|
| 8 |
This file is part of GCC. |
| 9 |
|
| 10 |
GCC is free software; you can redistribute it and/or modify it |
| 11 |
under the terms of the GNU General Public License as published |
| 12 |
by the Free Software Foundation; either version 3, or (at your |
| 13 |
option) any later version. |
| 14 |
|
| 15 |
GCC is distributed in the hope that it will be useful, but WITHOUT |
| 16 |
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY |
| 17 |
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public |
| 18 |
License for more details. |
| 19 |
|
| 20 |
Under Section 7 of GPL version 3, you are granted additional |
| 21 |
permissions described in the GCC Runtime Library Exception, version |
| 22 |
3.1, as published by the Free Software Foundation. |
| 23 |
|
| 24 |
You should have received a copy of the GNU General Public License and |
| 25 |
a copy of the GCC Runtime Library Exception along with this program; |
| 26 |
see the files COPYING3 and COPYING.RUNTIME respectively. If not, see |
| 27 |
<http://www.gnu.org/licenses/>. */ |
| 28 |
|
| 29 |
#ifndef _GCC_ARM_PRIVATE_FP8_H |
| 30 |
#define _GCC_ARM_PRIVATE_FP8_H |
| 31 |
|
| 32 |
#if !defined(_AARCH64_NEON_H_) && !defined(_ARM_SVE_H_) |
| 33 |
#error "This file should not be used standalone. Please include one of arm_neon.h arm_sve.h arm_sme.h instead." |
| 34 |
#endif |
| 35 |
|
| 36 |
#include <stdint.h> |
| 37 |
|
| 38 |
#ifdef __cplusplus |
| 39 |
extern "C" |
| 40 |
{ |
| 41 |
#endif |
| 42 |
|
| 43 |
typedef __mfp8 mfloat8_t; |
| 44 |
|
| 45 |
typedef uint64_t fpm_t; |
| 46 |
|
| 47 |
enum __ARM_FPM_FORMAT |
| 48 |
{ |
| 49 |
__ARM_FPM_E5M2, |
| 50 |
__ARM_FPM_E4M3, |
| 51 |
}; |
| 52 |
|
| 53 |
enum __ARM_FPM_OVERFLOW |
| 54 |
{ |
| 55 |
__ARM_FPM_INFNAN, |
| 56 |
__ARM_FPM_SATURATE, |
| 57 |
}; |
| 58 |
|
| 59 |
#define __arm_fpm_init() (0) |
| 60 |
|
| 61 |
#define __arm_set_fpm_src1_format(__fpm, __format) \ |
| 62 |
((__fpm & ~(uint64_t)0x7) | (__format & (uint64_t)0x7)) |
| 63 |
#define __arm_set_fpm_src2_format(__fpm, __format) \ |
| 64 |
((__fpm & ~((uint64_t)0x7 << 3)) | ((__format & (uint64_t)0x7) << 3)) |
| 65 |
#define __arm_set_fpm_dst_format(__fpm, __format) \ |
| 66 |
((__fpm & ~((uint64_t)0x7 << 6)) | ((__format & (uint64_t)0x7) << 6)) |
| 67 |
#define __arm_set_fpm_overflow_cvt(__fpm, __behaviour) \ |
| 68 |
((__fpm & ~((uint64_t)0x1 << 15)) | ((__behaviour & (uint64_t)0x1) << 15)) |
| 69 |
#define __arm_set_fpm_overflow_mul(__fpm, __behaviour) \ |
| 70 |
((__fpm & ~((uint64_t)0x1 << 14)) | ((__behaviour & (uint64_t)0x1) << 14)) |
| 71 |
#define __arm_set_fpm_lscale(__fpm, __scale) \ |
| 72 |
((__fpm & ~((uint64_t)0x7f << 16)) | ((__scale & (uint64_t)0x7f) << 16)) |
| 73 |
#define __arm_set_fpm_lscale2(__fpm, __scale) \ |
| 74 |
((__fpm & ~((uint64_t)0x3f << 32)) | ((__scale & (uint64_t)0x3f) << 32)) |
| 75 |
#define __arm_set_fpm_nscale(__fpm, __scale) \ |
| 76 |
((__fpm & ~((uint64_t)0xff << 24)) | ((__scale & (uint64_t)0xff) << 24)) |
| 77 |
|
| 78 |
#ifdef __cplusplus |
| 79 |
} |
| 80 |
#endif |
| 81 |
|
| 82 |
#endif |