1 /* ARM FP16 scalar intrinsics include file.
3 Copyright (C) 2016-2018 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 _AARCH64_FP16_H_
28 #define _AARCH64_FP16_H_
32 #pragma GCC push_options
33 #pragma GCC target ("arch=armv8.2-a+fp16")
35 typedef __fp16 float16_t
;
37 /* ARMv8.2-A FP16 one operand scalar intrinsics. */
39 __extension__
static __inline float16_t
__attribute__ ((__always_inline__
))
40 vabsh_f16 (float16_t __a
)
42 return __builtin_aarch64_abshf (__a
);
45 __extension__
static __inline
uint16_t __attribute__ ((__always_inline__
))
46 vceqzh_f16 (float16_t __a
)
48 return __builtin_aarch64_cmeqhf_uss (__a
, 0.0f
);
51 __extension__
static __inline
uint16_t __attribute__ ((__always_inline__
))
52 vcgezh_f16 (float16_t __a
)
54 return __builtin_aarch64_cmgehf_uss (__a
, 0.0f
);
57 __extension__
static __inline
uint16_t __attribute__ ((__always_inline__
))
58 vcgtzh_f16 (float16_t __a
)
60 return __builtin_aarch64_cmgthf_uss (__a
, 0.0f
);
63 __extension__
static __inline
uint16_t __attribute__ ((__always_inline__
))
64 vclezh_f16 (float16_t __a
)
66 return __builtin_aarch64_cmlehf_uss (__a
, 0.0f
);
69 __extension__
static __inline
uint16_t __attribute__ ((__always_inline__
))
70 vcltzh_f16 (float16_t __a
)
72 return __builtin_aarch64_cmlthf_uss (__a
, 0.0f
);
75 __extension__
static __inline float16_t
__attribute__ ((__always_inline__
))
76 vcvth_f16_s16 (int16_t __a
)
78 return __builtin_aarch64_floathihf (__a
);
81 __extension__
static __inline float16_t
__attribute__ ((__always_inline__
))
82 vcvth_f16_s32 (int32_t __a
)
84 return __builtin_aarch64_floatsihf (__a
);
87 __extension__
static __inline float16_t
__attribute__ ((__always_inline__
))
88 vcvth_f16_s64 (int64_t __a
)
90 return __builtin_aarch64_floatdihf (__a
);
93 __extension__
static __inline float16_t
__attribute__ ((__always_inline__
))
94 vcvth_f16_u16 (uint16_t __a
)
96 return __builtin_aarch64_floatunshihf_us (__a
);
99 __extension__
static __inline float16_t
__attribute__ ((__always_inline__
))
100 vcvth_f16_u32 (uint32_t __a
)
102 return __builtin_aarch64_floatunssihf_us (__a
);
105 __extension__
static __inline float16_t
__attribute__ ((__always_inline__
))
106 vcvth_f16_u64 (uint64_t __a
)
108 return __builtin_aarch64_floatunsdihf_us (__a
);
111 __extension__
static __inline
int16_t __attribute__ ((__always_inline__
))
112 vcvth_s16_f16 (float16_t __a
)
114 return __builtin_aarch64_fix_trunchfhi (__a
);
117 __extension__
static __inline
int32_t __attribute__ ((__always_inline__
))
118 vcvth_s32_f16 (float16_t __a
)
120 return __builtin_aarch64_fix_trunchfsi (__a
);
123 __extension__
static __inline
int64_t __attribute__ ((__always_inline__
))
124 vcvth_s64_f16 (float16_t __a
)
126 return __builtin_aarch64_fix_trunchfdi (__a
);
129 __extension__
static __inline
uint16_t __attribute__ ((__always_inline__
))
130 vcvth_u16_f16 (float16_t __a
)
132 return __builtin_aarch64_fixuns_trunchfhi_us (__a
);
135 __extension__
static __inline
uint32_t __attribute__ ((__always_inline__
))
136 vcvth_u32_f16 (float16_t __a
)
138 return __builtin_aarch64_fixuns_trunchfsi_us (__a
);
141 __extension__
static __inline
uint64_t __attribute__ ((__always_inline__
))
142 vcvth_u64_f16 (float16_t __a
)
144 return __builtin_aarch64_fixuns_trunchfdi_us (__a
);
147 __extension__
static __inline
int16_t __attribute__ ((__always_inline__
))
148 vcvtah_s16_f16 (float16_t __a
)
150 return __builtin_aarch64_lroundhfhi (__a
);
153 __extension__
static __inline
int32_t __attribute__ ((__always_inline__
))
154 vcvtah_s32_f16 (float16_t __a
)
156 return __builtin_aarch64_lroundhfsi (__a
);
159 __extension__
static __inline
int64_t __attribute__ ((__always_inline__
))
160 vcvtah_s64_f16 (float16_t __a
)
162 return __builtin_aarch64_lroundhfdi (__a
);
165 __extension__
static __inline
uint16_t __attribute__ ((__always_inline__
))
166 vcvtah_u16_f16 (float16_t __a
)
168 return __builtin_aarch64_lrounduhfhi_us (__a
);
171 __extension__
static __inline
uint32_t __attribute__ ((__always_inline__
))
172 vcvtah_u32_f16 (float16_t __a
)
174 return __builtin_aarch64_lrounduhfsi_us (__a
);
177 __extension__
static __inline
uint64_t __attribute__ ((__always_inline__
))
178 vcvtah_u64_f16 (float16_t __a
)
180 return __builtin_aarch64_lrounduhfdi_us (__a
);
183 __extension__
static __inline
int16_t __attribute__ ((__always_inline__
))
184 vcvtmh_s16_f16 (float16_t __a
)
186 return __builtin_aarch64_lfloorhfhi (__a
);
189 __extension__
static __inline
int32_t __attribute__ ((__always_inline__
))
190 vcvtmh_s32_f16 (float16_t __a
)
192 return __builtin_aarch64_lfloorhfsi (__a
);
195 __extension__
static __inline
int64_t __attribute__ ((__always_inline__
))
196 vcvtmh_s64_f16 (float16_t __a
)
198 return __builtin_aarch64_lfloorhfdi (__a
);
201 __extension__
static __inline
uint16_t __attribute__ ((__always_inline__
))
202 vcvtmh_u16_f16 (float16_t __a
)
204 return __builtin_aarch64_lflooruhfhi_us (__a
);
207 __extension__
static __inline
uint32_t __attribute__ ((__always_inline__
))
208 vcvtmh_u32_f16 (float16_t __a
)
210 return __builtin_aarch64_lflooruhfsi_us (__a
);
213 __extension__
static __inline
uint64_t __attribute__ ((__always_inline__
))
214 vcvtmh_u64_f16 (float16_t __a
)
216 return __builtin_aarch64_lflooruhfdi_us (__a
);
219 __extension__
static __inline
int16_t __attribute__ ((__always_inline__
))
220 vcvtnh_s16_f16 (float16_t __a
)
222 return __builtin_aarch64_lfrintnhfhi (__a
);
225 __extension__
static __inline
int32_t __attribute__ ((__always_inline__
))
226 vcvtnh_s32_f16 (float16_t __a
)
228 return __builtin_aarch64_lfrintnhfsi (__a
);
231 __extension__
static __inline
int64_t __attribute__ ((__always_inline__
))
232 vcvtnh_s64_f16 (float16_t __a
)
234 return __builtin_aarch64_lfrintnhfdi (__a
);
237 __extension__
static __inline
uint16_t __attribute__ ((__always_inline__
))
238 vcvtnh_u16_f16 (float16_t __a
)
240 return __builtin_aarch64_lfrintnuhfhi_us (__a
);
243 __extension__
static __inline
uint32_t __attribute__ ((__always_inline__
))
244 vcvtnh_u32_f16 (float16_t __a
)
246 return __builtin_aarch64_lfrintnuhfsi_us (__a
);
249 __extension__
static __inline
uint64_t __attribute__ ((__always_inline__
))
250 vcvtnh_u64_f16 (float16_t __a
)
252 return __builtin_aarch64_lfrintnuhfdi_us (__a
);
255 __extension__
static __inline
int16_t __attribute__ ((__always_inline__
))
256 vcvtph_s16_f16 (float16_t __a
)
258 return __builtin_aarch64_lceilhfhi (__a
);
261 __extension__
static __inline
int32_t __attribute__ ((__always_inline__
))
262 vcvtph_s32_f16 (float16_t __a
)
264 return __builtin_aarch64_lceilhfsi (__a
);
267 __extension__
static __inline
int64_t __attribute__ ((__always_inline__
))
268 vcvtph_s64_f16 (float16_t __a
)
270 return __builtin_aarch64_lceilhfdi (__a
);
273 __extension__
static __inline
uint16_t __attribute__ ((__always_inline__
))
274 vcvtph_u16_f16 (float16_t __a
)
276 return __builtin_aarch64_lceiluhfhi_us (__a
);
279 __extension__
static __inline
uint32_t __attribute__ ((__always_inline__
))
280 vcvtph_u32_f16 (float16_t __a
)
282 return __builtin_aarch64_lceiluhfsi_us (__a
);
285 __extension__
static __inline
uint64_t __attribute__ ((__always_inline__
))
286 vcvtph_u64_f16 (float16_t __a
)
288 return __builtin_aarch64_lceiluhfdi_us (__a
);
291 __extension__
static __inline float16_t
__attribute__ ((__always_inline__
))
292 vnegh_f16 (float16_t __a
)
294 return __builtin_aarch64_neghf (__a
);
297 __extension__
static __inline float16_t
__attribute__ ((__always_inline__
))
298 vrecpeh_f16 (float16_t __a
)
300 return __builtin_aarch64_frecpehf (__a
);
303 __extension__
static __inline float16_t
__attribute__ ((__always_inline__
))
304 vrecpxh_f16 (float16_t __a
)
306 return __builtin_aarch64_frecpxhf (__a
);
309 __extension__
static __inline float16_t
__attribute__ ((__always_inline__
))
310 vrndh_f16 (float16_t __a
)
312 return __builtin_aarch64_btrunchf (__a
);
315 __extension__
static __inline float16_t
__attribute__ ((__always_inline__
))
316 vrndah_f16 (float16_t __a
)
318 return __builtin_aarch64_roundhf (__a
);
321 __extension__
static __inline float16_t
__attribute__ ((__always_inline__
))
322 vrndih_f16 (float16_t __a
)
324 return __builtin_aarch64_nearbyinthf (__a
);
327 __extension__
static __inline float16_t
__attribute__ ((__always_inline__
))
328 vrndmh_f16 (float16_t __a
)
330 return __builtin_aarch64_floorhf (__a
);
333 __extension__
static __inline float16_t
__attribute__ ((__always_inline__
))
334 vrndnh_f16 (float16_t __a
)
336 return __builtin_aarch64_frintnhf (__a
);
339 __extension__
static __inline float16_t
__attribute__ ((__always_inline__
))
340 vrndph_f16 (float16_t __a
)
342 return __builtin_aarch64_ceilhf (__a
);
345 __extension__
static __inline float16_t
__attribute__ ((__always_inline__
))
346 vrndxh_f16 (float16_t __a
)
348 return __builtin_aarch64_rinthf (__a
);
351 __extension__
static __inline float16_t
__attribute__ ((__always_inline__
))
352 vrsqrteh_f16 (float16_t __a
)
354 return __builtin_aarch64_rsqrtehf (__a
);
357 __extension__
static __inline float16_t
__attribute__ ((__always_inline__
))
358 vsqrth_f16 (float16_t __a
)
360 return __builtin_aarch64_sqrthf (__a
);
363 /* ARMv8.2-A FP16 two operands scalar intrinsics. */
365 __extension__
static __inline float16_t
__attribute__ ((__always_inline__
))
366 vaddh_f16 (float16_t __a
, float16_t __b
)
371 __extension__
static __inline float16_t
__attribute__ ((__always_inline__
))
372 vabdh_f16 (float16_t __a
, float16_t __b
)
374 return __builtin_aarch64_fabdhf (__a
, __b
);
377 __extension__
static __inline
uint16_t __attribute__ ((__always_inline__
))
378 vcageh_f16 (float16_t __a
, float16_t __b
)
380 return __builtin_aarch64_facgehf_uss (__a
, __b
);
383 __extension__
static __inline
uint16_t __attribute__ ((__always_inline__
))
384 vcagth_f16 (float16_t __a
, float16_t __b
)
386 return __builtin_aarch64_facgthf_uss (__a
, __b
);
389 __extension__
static __inline
uint16_t __attribute__ ((__always_inline__
))
390 vcaleh_f16 (float16_t __a
, float16_t __b
)
392 return __builtin_aarch64_faclehf_uss (__a
, __b
);
395 __extension__
static __inline
uint16_t __attribute__ ((__always_inline__
))
396 vcalth_f16 (float16_t __a
, float16_t __b
)
398 return __builtin_aarch64_faclthf_uss (__a
, __b
);
401 __extension__
static __inline
uint16_t __attribute__ ((__always_inline__
))
402 vceqh_f16 (float16_t __a
, float16_t __b
)
404 return __builtin_aarch64_cmeqhf_uss (__a
, __b
);
407 __extension__
static __inline
uint16_t __attribute__ ((__always_inline__
))
408 vcgeh_f16 (float16_t __a
, float16_t __b
)
410 return __builtin_aarch64_cmgehf_uss (__a
, __b
);
413 __extension__
static __inline
uint16_t __attribute__ ((__always_inline__
))
414 vcgth_f16 (float16_t __a
, float16_t __b
)
416 return __builtin_aarch64_cmgthf_uss (__a
, __b
);
419 __extension__
static __inline
uint16_t __attribute__ ((__always_inline__
))
420 vcleh_f16 (float16_t __a
, float16_t __b
)
422 return __builtin_aarch64_cmlehf_uss (__a
, __b
);
425 __extension__
static __inline
uint16_t __attribute__ ((__always_inline__
))
426 vclth_f16 (float16_t __a
, float16_t __b
)
428 return __builtin_aarch64_cmlthf_uss (__a
, __b
);
431 __extension__
static __inline float16_t
__attribute__ ((__always_inline__
))
432 vcvth_n_f16_s16 (int16_t __a
, const int __b
)
434 return __builtin_aarch64_scvtfhi (__a
, __b
);
437 __extension__
static __inline float16_t
__attribute__ ((__always_inline__
))
438 vcvth_n_f16_s32 (int32_t __a
, const int __b
)
440 return __builtin_aarch64_scvtfsihf (__a
, __b
);
443 __extension__
static __inline float16_t
__attribute__ ((__always_inline__
))
444 vcvth_n_f16_s64 (int64_t __a
, const int __b
)
446 return __builtin_aarch64_scvtfdihf (__a
, __b
);
449 __extension__
static __inline float16_t
__attribute__ ((__always_inline__
))
450 vcvth_n_f16_u16 (uint16_t __a
, const int __b
)
452 return __builtin_aarch64_ucvtfhi_sus (__a
, __b
);
455 __extension__
static __inline float16_t
__attribute__ ((__always_inline__
))
456 vcvth_n_f16_u32 (uint32_t __a
, const int __b
)
458 return __builtin_aarch64_ucvtfsihf_sus (__a
, __b
);
461 __extension__
static __inline float16_t
__attribute__ ((__always_inline__
))
462 vcvth_n_f16_u64 (uint64_t __a
, const int __b
)
464 return __builtin_aarch64_ucvtfdihf_sus (__a
, __b
);
467 __extension__
static __inline
int16_t __attribute__ ((__always_inline__
))
468 vcvth_n_s16_f16 (float16_t __a
, const int __b
)
470 return __builtin_aarch64_fcvtzshf (__a
, __b
);
473 __extension__
static __inline
int32_t __attribute__ ((__always_inline__
))
474 vcvth_n_s32_f16 (float16_t __a
, const int __b
)
476 return __builtin_aarch64_fcvtzshfsi (__a
, __b
);
479 __extension__
static __inline
int64_t __attribute__ ((__always_inline__
))
480 vcvth_n_s64_f16 (float16_t __a
, const int __b
)
482 return __builtin_aarch64_fcvtzshfdi (__a
, __b
);
485 __extension__
static __inline
uint16_t __attribute__ ((__always_inline__
))
486 vcvth_n_u16_f16 (float16_t __a
, const int __b
)
488 return __builtin_aarch64_fcvtzuhf_uss (__a
, __b
);
491 __extension__
static __inline
uint32_t __attribute__ ((__always_inline__
))
492 vcvth_n_u32_f16 (float16_t __a
, const int __b
)
494 return __builtin_aarch64_fcvtzuhfsi_uss (__a
, __b
);
497 __extension__
static __inline
uint64_t __attribute__ ((__always_inline__
))
498 vcvth_n_u64_f16 (float16_t __a
, const int __b
)
500 return __builtin_aarch64_fcvtzuhfdi_uss (__a
, __b
);
503 __extension__
static __inline float16_t
__attribute__ ((__always_inline__
))
504 vdivh_f16 (float16_t __a
, float16_t __b
)
509 __extension__
static __inline float16_t
__attribute__ ((__always_inline__
))
510 vmaxh_f16 (float16_t __a
, float16_t __b
)
512 return __builtin_aarch64_fmaxhf (__a
, __b
);
515 __extension__
static __inline float16_t
__attribute__ ((__always_inline__
))
516 vmaxnmh_f16 (float16_t __a
, float16_t __b
)
518 return __builtin_aarch64_fmaxhf (__a
, __b
);
521 __extension__
static __inline float16_t
__attribute__ ((__always_inline__
))
522 vminh_f16 (float16_t __a
, float16_t __b
)
524 return __builtin_aarch64_fminhf (__a
, __b
);
527 __extension__
static __inline float16_t
__attribute__ ((__always_inline__
))
528 vminnmh_f16 (float16_t __a
, float16_t __b
)
530 return __builtin_aarch64_fminhf (__a
, __b
);
533 __extension__
static __inline float16_t
__attribute__ ((__always_inline__
))
534 vmulh_f16 (float16_t __a
, float16_t __b
)
539 __extension__
static __inline float16_t
__attribute__ ((__always_inline__
))
540 vmulxh_f16 (float16_t __a
, float16_t __b
)
542 return __builtin_aarch64_fmulxhf (__a
, __b
);
545 __extension__
static __inline float16_t
__attribute__ ((__always_inline__
))
546 vrecpsh_f16 (float16_t __a
, float16_t __b
)
548 return __builtin_aarch64_frecpshf (__a
, __b
);
551 __extension__
static __inline float16_t
__attribute__ ((__always_inline__
))
552 vrsqrtsh_f16 (float16_t __a
, float16_t __b
)
554 return __builtin_aarch64_rsqrtshf (__a
, __b
);
557 __extension__
static __inline float16_t
__attribute__ ((__always_inline__
))
558 vsubh_f16 (float16_t __a
, float16_t __b
)
563 /* ARMv8.2-A FP16 three operands scalar intrinsics. */
565 __extension__
static __inline float16_t
__attribute__ ((__always_inline__
))
566 vfmah_f16 (float16_t __a
, float16_t __b
, float16_t __c
)
568 return __builtin_aarch64_fmahf (__b
, __c
, __a
);
571 __extension__
static __inline float16_t
__attribute__ ((__always_inline__
))
572 vfmsh_f16 (float16_t __a
, float16_t __b
, float16_t __c
)
574 return __builtin_aarch64_fnmahf (__b
, __c
, __a
);
577 #pragma GCC pop_options