| 1 |
/* AArch64 Non-NEON ACLE intrinsics include file. |
| 2 |
|
| 3 |
Copyright (C) 2014-2025 Free Software Foundation, Inc. |
| 4 |
Contributed by ARM Ltd. |
| 5 |
|
| 6 |
This file is part of GCC. |
| 7 |
|
| 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. |
| 12 |
|
| 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. |
| 17 |
|
| 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. |
| 21 |
|
| 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/>. */ |
| 26 |
|
| 27 |
#ifndef _GCC_ARM_ACLE_H |
| 28 |
#define _GCC_ARM_ACLE_H |
| 29 |
|
| 30 |
#include <stdint.h> |
| 31 |
#include <stddef.h> |
| 32 |
|
| 33 |
#pragma GCC aarch64 "arm_acle.h" |
| 34 |
|
| 35 |
#ifdef __cplusplus |
| 36 |
extern "C" { |
| 37 |
#endif |
| 38 |
|
| 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); \ |
| 47 |
} |
| 48 |
|
| 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) |
| 52 |
|
| 53 |
#undef _GCC_ARM_ACLE_ROR_FN |
| 54 |
|
| 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); \ |
| 61 |
} |
| 62 |
|
| 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) |
| 78 |
|
| 79 |
#undef _GCC_ARM_ACLE_DATA_FN |
| 80 |
|
| 81 |
__extension__ extern __inline void |
| 82 |
__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) |
| 83 |
__pld (void const volatile *__addr) |
| 84 |
{ |
| 85 |
return __builtin_aarch64_pld (__addr); |
| 86 |
} |
| 87 |
|
| 88 |
__extension__ extern __inline void |
| 89 |
__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) |
| 90 |
__pli (void const volatile *__addr) |
| 91 |
{ |
| 92 |
return __builtin_aarch64_pli (__addr); |
| 93 |
} |
| 94 |
|
| 95 |
__extension__ extern __inline void |
| 96 |
__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) |
| 97 |
__plix (const unsigned int __cache, const unsigned int __rettn, |
| 98 |
void const volatile *__addr) |
| 99 |
{ |
| 100 |
return __builtin_aarch64_plix (__cache, __rettn, __addr); |
| 101 |
} |
| 102 |
|
| 103 |
__extension__ extern __inline void |
| 104 |
__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) |
| 105 |
__pldx (const unsigned int __access, const unsigned int __cache, |
| 106 |
const unsigned int __rettn, void const volatile *__addr) |
| 107 |
{ |
| 108 |
return __builtin_aarch64_pldx (__access, __cache, __rettn, __addr); |
| 109 |
} |
| 110 |
|
| 111 |
__extension__ extern __inline unsigned long |
| 112 |
__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) |
| 113 |
__revl (unsigned long __value) |
| 114 |
{ |
| 115 |
if (sizeof (unsigned long) == 8) |
| 116 |
return __revll (__value); |
| 117 |
else |
| 118 |
return __rev (__value); |
| 119 |
} |
| 120 |
|
| 121 |
#pragma GCC push_options |
| 122 |
#pragma GCC target ("+nothing+jscvt") |
| 123 |
__extension__ extern __inline int32_t |
| 124 |
__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) |
| 125 |
__jcvt (double __a) |
| 126 |
{ |
| 127 |
return __builtin_aarch64_jcvtzs (__a); |
| 128 |
} |
| 129 |
|
| 130 |
#pragma GCC pop_options |
| 131 |
|
| 132 |
__extension__ extern __inline double |
| 133 |
__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) |
| 134 |
__fma (double __x, double __y, double __z) |
| 135 |
{ |
| 136 |
return __builtin_fma (__x, __y, __z); |
| 137 |
} |
| 138 |
|
| 139 |
__extension__ extern __inline float |
| 140 |
__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) |
| 141 |
__fmaf (float __x, float __y, float __z) |
| 142 |
{ |
| 143 |
return __builtin_fmaf (__x, __y, __z); |
| 144 |
} |
| 145 |
|
| 146 |
#pragma GCC push_options |
| 147 |
#pragma GCC target ("+nothing+frintts") |
| 148 |
__extension__ extern __inline float |
| 149 |
__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) |
| 150 |
__rint32zf (float __a) |
| 151 |
{ |
| 152 |
return __builtin_aarch64_frint32zsf (__a); |
| 153 |
} |
| 154 |
|
| 155 |
__extension__ extern __inline double |
| 156 |
__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) |
| 157 |
__rint32z (double __a) |
| 158 |
{ |
| 159 |
return __builtin_aarch64_frint32zdf (__a); |
| 160 |
} |
| 161 |
|
| 162 |
__extension__ extern __inline float |
| 163 |
__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) |
| 164 |
__rint64zf (float __a) |
| 165 |
{ |
| 166 |
return __builtin_aarch64_frint64zsf (__a); |
| 167 |
} |
| 168 |
|
| 169 |
__extension__ extern __inline double |
| 170 |
__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) |
| 171 |
__rint64z (double __a) |
| 172 |
{ |
| 173 |
return __builtin_aarch64_frint64zdf (__a); |
| 174 |
} |
| 175 |
|
| 176 |
__extension__ extern __inline float |
| 177 |
__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) |
| 178 |
__rint32xf (float __a) |
| 179 |
{ |
| 180 |
return __builtin_aarch64_frint32xsf (__a); |
| 181 |
} |
| 182 |
|
| 183 |
__extension__ extern __inline double |
| 184 |
__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) |
| 185 |
__rint32x (double __a) |
| 186 |
{ |
| 187 |
return __builtin_aarch64_frint32xdf (__a); |
| 188 |
} |
| 189 |
|
| 190 |
__extension__ extern __inline float |
| 191 |
__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) |
| 192 |
__rint64xf (float __a) |
| 193 |
{ |
| 194 |
return __builtin_aarch64_frint64xsf (__a); |
| 195 |
} |
| 196 |
|
| 197 |
__extension__ extern __inline double |
| 198 |
__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) |
| 199 |
__rint64x (double __a) |
| 200 |
{ |
| 201 |
return __builtin_aarch64_frint64xdf (__a); |
| 202 |
} |
| 203 |
|
| 204 |
|
| 205 |
#pragma GCC pop_options |
| 206 |
|
| 207 |
|
| 208 |
#pragma GCC push_options |
| 209 |
#pragma GCC target ("+nothing") |
| 210 |
|
| 211 |
/* Feature constants for CHKFEAT operation. */ |
| 212 |
#define _CHKFEAT_GCS 1 |
| 213 |
|
| 214 |
__extension__ extern __inline uint64_t |
| 215 |
__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) |
| 216 |
__chkfeat (uint64_t __feat) |
| 217 |
{ |
| 218 |
return __builtin_aarch64_chkfeat (__feat) ^ __feat; |
| 219 |
} |
| 220 |
|
| 221 |
#define __gcspr() \ |
| 222 |
__builtin_aarch64_gcspr () |
| 223 |
|
| 224 |
#define __gcspopm() \ |
| 225 |
__builtin_aarch64_gcspopm () |
| 226 |
|
| 227 |
#define __gcsss(__stack) \ |
| 228 |
__builtin_aarch64_gcsss (__stack) |
| 229 |
|
| 230 |
#pragma GCC pop_options |
| 231 |
|
| 232 |
|
| 233 |
#pragma GCC push_options |
| 234 |
#pragma GCC target ("+nothing+crc") |
| 235 |
|
| 236 |
__extension__ extern __inline uint32_t |
| 237 |
__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) |
| 238 |
__crc32b (uint32_t __a, uint8_t __b) |
| 239 |
{ |
| 240 |
return __builtin_aarch64_crc32b (__a, __b); |
| 241 |
} |
| 242 |
|
| 243 |
__extension__ extern __inline uint32_t |
| 244 |
__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) |
| 245 |
__crc32cb (uint32_t __a, uint8_t __b) |
| 246 |
{ |
| 247 |
return __builtin_aarch64_crc32cb (__a, __b); |
| 248 |
} |
| 249 |
|
| 250 |
__extension__ extern __inline uint32_t |
| 251 |
__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) |
| 252 |
__crc32ch (uint32_t __a, uint16_t __b) |
| 253 |
{ |
| 254 |
return __builtin_aarch64_crc32ch (__a, __b); |
| 255 |
} |
| 256 |
|
| 257 |
__extension__ extern __inline uint32_t |
| 258 |
__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) |
| 259 |
__crc32cw (uint32_t __a, uint32_t __b) |
| 260 |
{ |
| 261 |
return __builtin_aarch64_crc32cw (__a, __b); |
| 262 |
} |
| 263 |
|
| 264 |
__extension__ extern __inline uint32_t |
| 265 |
__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) |
| 266 |
__crc32cd (uint32_t __a, uint64_t __b) |
| 267 |
{ |
| 268 |
return __builtin_aarch64_crc32cx (__a, __b); |
| 269 |
} |
| 270 |
|
| 271 |
__extension__ extern __inline uint32_t |
| 272 |
__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) |
| 273 |
__crc32h (uint32_t __a, uint16_t __b) |
| 274 |
{ |
| 275 |
return __builtin_aarch64_crc32h (__a, __b); |
| 276 |
} |
| 277 |
|
| 278 |
__extension__ extern __inline uint32_t |
| 279 |
__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) |
| 280 |
__crc32w (uint32_t __a, uint32_t __b) |
| 281 |
{ |
| 282 |
return __builtin_aarch64_crc32w (__a, __b); |
| 283 |
} |
| 284 |
|
| 285 |
__extension__ extern __inline uint32_t |
| 286 |
__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) |
| 287 |
__crc32d (uint32_t __a, uint64_t __b) |
| 288 |
{ |
| 289 |
return __builtin_aarch64_crc32x (__a, __b); |
| 290 |
} |
| 291 |
|
| 292 |
#pragma GCC pop_options |
| 293 |
|
| 294 |
/* Constants for TME failure reason. */ |
| 295 |
#define _TMFAILURE_REASON 0x00007fffu |
| 296 |
#define _TMFAILURE_RTRY 0x00008000u |
| 297 |
#define _TMFAILURE_CNCL 0x00010000u |
| 298 |
#define _TMFAILURE_MEM 0x00020000u |
| 299 |
#define _TMFAILURE_IMP 0x00040000u |
| 300 |
#define _TMFAILURE_ERR 0x00080000u |
| 301 |
#define _TMFAILURE_SIZE 0x00100000u |
| 302 |
#define _TMFAILURE_NEST 0x00200000u |
| 303 |
#define _TMFAILURE_DBG 0x00400000u |
| 304 |
#define _TMFAILURE_INT 0x00800000u |
| 305 |
#define _TMFAILURE_TRIVIAL 0x01000000u |
| 306 |
|
| 307 |
typedef __arm_data512_t data512_t; |
| 308 |
|
| 309 |
#pragma GCC push_options |
| 310 |
#pragma GCC target ("+nothing+rng") |
| 311 |
__extension__ extern __inline int |
| 312 |
__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) |
| 313 |
__rndr (uint64_t *__res) |
| 314 |
{ |
| 315 |
return __builtin_aarch64_rndr (__res); |
| 316 |
} |
| 317 |
|
| 318 |
__extension__ extern __inline int |
| 319 |
__attribute__ ((__always_inline__, __gnu_inline__, __artificial__)) |
| 320 |
__rndrrs (uint64_t *__res) |
| 321 |
{ |
| 322 |
return __builtin_aarch64_rndrrs (__res); |
| 323 |
} |
| 324 |
|
| 325 |
#pragma GCC pop_options |
| 326 |
|
| 327 |
#define __arm_rsr(__regname) \ |
| 328 |
__builtin_aarch64_rsr (__regname) |
| 329 |
|
| 330 |
#define __arm_rsrp(__regname) \ |
| 331 |
__builtin_aarch64_rsrp (__regname) |
| 332 |
|
| 333 |
#define __arm_rsr64(__regname) \ |
| 334 |
__builtin_aarch64_rsr64 (__regname) |
| 335 |
|
| 336 |
#define __arm_rsrf(__regname) \ |
| 337 |
__builtin_aarch64_rsrf (__regname) |
| 338 |
|
| 339 |
#define __arm_rsrf64(__regname) \ |
| 340 |
__builtin_aarch64_rsrf64 (__regname) |
| 341 |
|
| 342 |
#define __arm_wsr(__regname, __value) \ |
| 343 |
__builtin_aarch64_wsr (__regname, __value) |
| 344 |
|
| 345 |
#define __arm_wsrp(__regname, __value) \ |
| 346 |
__builtin_aarch64_wsrp (__regname, __value) |
| 347 |
|
| 348 |
#define __arm_wsr64(__regname, __value) \ |
| 349 |
__builtin_aarch64_wsr64 (__regname, __value) |
| 350 |
|
| 351 |
#define __arm_wsrf(__regname, __value) \ |
| 352 |
__builtin_aarch64_wsrf (__regname, __value) |
| 353 |
|
| 354 |
#define __arm_wsrf64(__regname, __value) \ |
| 355 |
__builtin_aarch64_wsrf64 (__regname, __value) |
| 356 |
|
| 357 |
#pragma GCC push_options |
| 358 |
#pragma GCC target ("+nothing+d128") |
| 359 |
|
| 360 |
#define __arm_rsr128(__regname) \ |
| 361 |
__builtin_aarch64_rsr128 (__regname) |
| 362 |
|
| 363 |
#define __arm_wsr128(__regname, __value) \ |
| 364 |
__builtin_aarch64_wsr128 (__regname, __value) |
| 365 |
|
| 366 |
#pragma GCC pop_options |
| 367 |
|
| 368 |
#ifdef __cplusplus |
| 369 |
} |
| 370 |
#endif |
| 371 |
|
| 372 |
#endif |