libcpp, c, middle-end: Optimize initializers using #embed in C
[official-gcc.git] / gcc / config / aarch64 / arm_acle.h
blobab4e7e60e046a9e9c81237de2ca5463c3d4f96ca
1 /* AArch64 Non-NEON ACLE intrinsics include file.
3 Copyright (C) 2014-2024 Free Software Foundation, Inc.
4 Contributed by ARM Ltd.
6 This file is part of GCC.
8 GCC is free software; you can redistribute it and/or modify it
9 under the terms of the GNU General Public License as published
10 by the Free Software Foundation; either version 3, or (at your
11 option) any later version.
13 GCC is distributed in the hope that it will be useful, but WITHOUT
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
15 or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
16 License for more details.
18 Under Section 7 of GPL version 3, you are granted additional
19 permissions described in the GCC Runtime Library Exception, version
20 3.1, as published by the Free Software Foundation.
22 You should have received a copy of the GNU General Public License and
23 a copy of the GCC Runtime Library Exception along with this program;
24 see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
25 <http://www.gnu.org/licenses/>. */
27 #ifndef _GCC_ARM_ACLE_H
28 #define _GCC_ARM_ACLE_H
30 #include <stdint.h>
31 #include <stddef.h>
33 #pragma GCC aarch64 "arm_acle.h"
35 #ifdef __cplusplus
36 extern "C" {
37 #endif
39 #define _GCC_ARM_ACLE_ROR_FN(NAME, TYPE) \
40 __extension__ extern __inline TYPE \
41 __attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) \
42 NAME (TYPE __value, uint32_t __rotate) \
43 { \
44 size_t __size = sizeof (TYPE) * __CHAR_BIT__; \
45 __rotate = __rotate % __size; \
46 return __value >> __rotate | __value << ((__size - __rotate) % __size); \
49 _GCC_ARM_ACLE_ROR_FN (__ror, uint32_t)
50 _GCC_ARM_ACLE_ROR_FN (__rorl, unsigned long)
51 _GCC_ARM_ACLE_ROR_FN (__rorll, uint64_t)
53 #undef _GCC_ARM_ACLE_ROR_FN
55 #define _GCC_ARM_ACLE_DATA_FN(NAME, BUILTIN, ITYPE, RTYPE) \
56 __extension__ extern __inline RTYPE \
57 __attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) \
58 __##NAME (ITYPE __value) \
59 { \
60 return __builtin_##BUILTIN (__value); \
63 _GCC_ARM_ACLE_DATA_FN (clz, clz, uint32_t, unsigned int)
64 _GCC_ARM_ACLE_DATA_FN (clzl, clzl, unsigned long, unsigned int)
65 _GCC_ARM_ACLE_DATA_FN (clzll, clzll, uint64_t, unsigned int)
66 _GCC_ARM_ACLE_DATA_FN (cls, clrsb, uint32_t, unsigned int)
67 _GCC_ARM_ACLE_DATA_FN (clsl, clrsbl, unsigned long, unsigned int)
68 _GCC_ARM_ACLE_DATA_FN (clsll, clrsbll, uint64_t, unsigned int)
69 _GCC_ARM_ACLE_DATA_FN (rev16, aarch64_rev16, uint32_t, uint32_t)
70 _GCC_ARM_ACLE_DATA_FN (rev16l, aarch64_rev16l, unsigned long, unsigned long)
71 _GCC_ARM_ACLE_DATA_FN (rev16ll, aarch64_rev16ll, uint64_t, uint64_t)
72 _GCC_ARM_ACLE_DATA_FN (rbit, aarch64_rbit, uint32_t, uint32_t)
73 _GCC_ARM_ACLE_DATA_FN (rbitl, aarch64_rbitl, unsigned long, unsigned long)
74 _GCC_ARM_ACLE_DATA_FN (rbitll, aarch64_rbitll, uint64_t, uint64_t)
75 _GCC_ARM_ACLE_DATA_FN (revsh, bswap16, int16_t, int16_t)
76 _GCC_ARM_ACLE_DATA_FN (rev, bswap32, uint32_t, uint32_t)
77 _GCC_ARM_ACLE_DATA_FN (revll, bswap64, uint64_t, uint64_t)
79 #undef _GCC_ARM_ACLE_DATA_FN
81 __extension__ extern __inline void
82 __attribute__ ((__always_inline__, __gnu_inline__, __artificial__))
83 __pld (void const volatile *__addr)
85 return __builtin_aarch64_pld (__addr);
88 __extension__ extern __inline void
89 __attribute__ ((__always_inline__, __gnu_inline__, __artificial__))
90 __pli (void const volatile *__addr)
92 return __builtin_aarch64_pli (__addr);
95 __extension__ extern __inline void
96 __attribute__ ((__always_inline__, __gnu_inline__, __artificial__))
97 __plix (unsigned int __cache, unsigned int __rettn,
98 void const volatile *__addr)
100 return __builtin_aarch64_plix (__cache, __rettn, __addr);
103 __extension__ extern __inline void
104 __attribute__ ((__always_inline__, __gnu_inline__, __artificial__))
105 __pldx (unsigned int __access, unsigned int __cache, unsigned int __rettn,
106 void const volatile *__addr)
108 return __builtin_aarch64_pldx (__access, __cache, __rettn, __addr);
111 __extension__ extern __inline unsigned long
112 __attribute__ ((__always_inline__, __gnu_inline__, __artificial__))
113 __revl (unsigned long __value)
115 if (sizeof (unsigned long) == 8)
116 return __revll (__value);
117 else
118 return __rev (__value);
121 #pragma GCC push_options
122 #pragma GCC target ("arch=armv8.3-a")
123 __extension__ extern __inline int32_t
124 __attribute__ ((__always_inline__, __gnu_inline__, __artificial__))
125 __jcvt (double __a)
127 return __builtin_aarch64_jcvtzs (__a);
130 #pragma GCC pop_options
132 #pragma GCC push_options
133 #pragma GCC target ("arch=armv8.5-a")
134 __extension__ extern __inline float
135 __attribute__ ((__always_inline__, __gnu_inline__, __artificial__))
136 __rint32zf (float __a)
138 return __builtin_aarch64_frint32zsf (__a);
141 __extension__ extern __inline double
142 __attribute__ ((__always_inline__, __gnu_inline__, __artificial__))
143 __rint32z (double __a)
145 return __builtin_aarch64_frint32zdf (__a);
148 __extension__ extern __inline float
149 __attribute__ ((__always_inline__, __gnu_inline__, __artificial__))
150 __rint64zf (float __a)
152 return __builtin_aarch64_frint64zsf (__a);
155 __extension__ extern __inline double
156 __attribute__ ((__always_inline__, __gnu_inline__, __artificial__))
157 __rint64z (double __a)
159 return __builtin_aarch64_frint64zdf (__a);
162 __extension__ extern __inline float
163 __attribute__ ((__always_inline__, __gnu_inline__, __artificial__))
164 __rint32xf (float __a)
166 return __builtin_aarch64_frint32xsf (__a);
169 __extension__ extern __inline double
170 __attribute__ ((__always_inline__, __gnu_inline__, __artificial__))
171 __rint32x (double __a)
173 return __builtin_aarch64_frint32xdf (__a);
176 __extension__ extern __inline float
177 __attribute__ ((__always_inline__, __gnu_inline__, __artificial__))
178 __rint64xf (float __a)
180 return __builtin_aarch64_frint64xsf (__a);
183 __extension__ extern __inline double
184 __attribute__ ((__always_inline__, __gnu_inline__, __artificial__))
185 __rint64x (double __a)
187 return __builtin_aarch64_frint64xdf (__a);
191 #pragma GCC pop_options
193 #pragma GCC push_options
195 #pragma GCC target ("+nothing+crc")
197 __extension__ extern __inline uint32_t
198 __attribute__ ((__always_inline__, __gnu_inline__, __artificial__))
199 __crc32b (uint32_t __a, uint8_t __b)
201 return __builtin_aarch64_crc32b (__a, __b);
204 __extension__ extern __inline uint32_t
205 __attribute__ ((__always_inline__, __gnu_inline__, __artificial__))
206 __crc32cb (uint32_t __a, uint8_t __b)
208 return __builtin_aarch64_crc32cb (__a, __b);
211 __extension__ extern __inline uint32_t
212 __attribute__ ((__always_inline__, __gnu_inline__, __artificial__))
213 __crc32ch (uint32_t __a, uint16_t __b)
215 return __builtin_aarch64_crc32ch (__a, __b);
218 __extension__ extern __inline uint32_t
219 __attribute__ ((__always_inline__, __gnu_inline__, __artificial__))
220 __crc32cw (uint32_t __a, uint32_t __b)
222 return __builtin_aarch64_crc32cw (__a, __b);
225 __extension__ extern __inline uint32_t
226 __attribute__ ((__always_inline__, __gnu_inline__, __artificial__))
227 __crc32cd (uint32_t __a, uint64_t __b)
229 return __builtin_aarch64_crc32cx (__a, __b);
232 __extension__ extern __inline uint32_t
233 __attribute__ ((__always_inline__, __gnu_inline__, __artificial__))
234 __crc32h (uint32_t __a, uint16_t __b)
236 return __builtin_aarch64_crc32h (__a, __b);
239 __extension__ extern __inline uint32_t
240 __attribute__ ((__always_inline__, __gnu_inline__, __artificial__))
241 __crc32w (uint32_t __a, uint32_t __b)
243 return __builtin_aarch64_crc32w (__a, __b);
246 __extension__ extern __inline uint32_t
247 __attribute__ ((__always_inline__, __gnu_inline__, __artificial__))
248 __crc32d (uint32_t __a, uint64_t __b)
250 return __builtin_aarch64_crc32x (__a, __b);
253 #pragma GCC pop_options
255 /* Constants for TME failure reason. */
256 #define _TMFAILURE_REASON 0x00007fffu
257 #define _TMFAILURE_RTRY 0x00008000u
258 #define _TMFAILURE_CNCL 0x00010000u
259 #define _TMFAILURE_MEM 0x00020000u
260 #define _TMFAILURE_IMP 0x00040000u
261 #define _TMFAILURE_ERR 0x00080000u
262 #define _TMFAILURE_SIZE 0x00100000u
263 #define _TMFAILURE_NEST 0x00200000u
264 #define _TMFAILURE_DBG 0x00400000u
265 #define _TMFAILURE_INT 0x00800000u
266 #define _TMFAILURE_TRIVIAL 0x01000000u
268 typedef __arm_data512_t data512_t;
270 #pragma GCC push_options
271 #pragma GCC target ("+nothing+rng")
272 __extension__ extern __inline int
273 __attribute__ ((__always_inline__, __gnu_inline__, __artificial__))
274 __rndr (uint64_t *__res)
276 return __builtin_aarch64_rndr (__res);
279 __extension__ extern __inline int
280 __attribute__ ((__always_inline__, __gnu_inline__, __artificial__))
281 __rndrrs (uint64_t *__res)
283 return __builtin_aarch64_rndrrs (__res);
286 #pragma GCC pop_options
288 #define __arm_rsr(__regname) \
289 __builtin_aarch64_rsr (__regname)
291 #define __arm_rsrp(__regname) \
292 __builtin_aarch64_rsrp (__regname)
294 #define __arm_rsr64(__regname) \
295 __builtin_aarch64_rsr64 (__regname)
297 #define __arm_rsrf(__regname) \
298 __builtin_aarch64_rsrf (__regname)
300 #define __arm_rsrf64(__regname) \
301 __builtin_aarch64_rsrf64 (__regname)
303 #define __arm_wsr(__regname, __value) \
304 __builtin_aarch64_wsr (__regname, __value)
306 #define __arm_wsrp(__regname, __value) \
307 __builtin_aarch64_wsrp (__regname, __value)
309 #define __arm_wsr64(__regname, __value) \
310 __builtin_aarch64_wsr64 (__regname, __value)
312 #define __arm_wsrf(__regname, __value) \
313 __builtin_aarch64_wsrf (__regname, __value)
315 #define __arm_wsrf64(__regname, __value) \
316 __builtin_aarch64_wsrf64 (__regname, __value)
318 #pragma GCC push_options
319 #pragma GCC target ("+nothing+d128")
321 #define __arm_rsr128(__regname) \
322 __builtin_aarch64_rsr128 (__regname)
324 #define __arm_wsr128(__regname, __value) \
325 __builtin_aarch64_wsr128 (__regname, __value)
327 #pragma GCC pop_options
329 #ifdef __cplusplus
331 #endif
333 #endif