summaryrefslogtreecommitdiff
path: root/gcc/config/aarch64/arm_fp16.h
blob: 55f9b8cf6df53108267b43fcc0e8754f0fb99d31 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
/* ARM FP16 scalar intrinsics include file.

   Copyright (C) 2016-2017 Free Software Foundation, Inc.
   Contributed by ARM Ltd.

   This file is part of GCC.

   GCC is free software; you can redistribute it and/or modify it
   under the terms of the GNU General Public License as published
   by the Free Software Foundation; either version 3, or (at your
   option) any later version.

   GCC is distributed in the hope that it will be useful, but WITHOUT
   ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
   or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public
   License for more details.

   Under Section 7 of GPL version 3, you are granted additional
   permissions described in the GCC Runtime Library Exception, version
   3.1, as published by the Free Software Foundation.

   You should have received a copy of the GNU General Public License and
   a copy of the GCC Runtime Library Exception along with this program;
   see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
   <http://www.gnu.org/licenses/>.  */

#ifndef _AARCH64_FP16_H_
#define _AARCH64_FP16_H_

#include <stdint.h>

#pragma GCC push_options
#pragma GCC target ("arch=armv8.2-a+fp16")

typedef __fp16 float16_t;

/* ARMv8.2-A FP16 one operand scalar intrinsics.  */

__extension__ static __inline float16_t __attribute__ ((__always_inline__))
vabsh_f16 (float16_t __a)
{
  return __builtin_aarch64_abshf (__a);
}

__extension__ static __inline uint16_t __attribute__ ((__always_inline__))
vceqzh_f16 (float16_t __a)
{
  return __builtin_aarch64_cmeqhf_uss (__a, 0.0f);
}

__extension__ static __inline uint16_t __attribute__ ((__always_inline__))
vcgezh_f16 (float16_t __a)
{
  return __builtin_aarch64_cmgehf_uss (__a, 0.0f);
}

__extension__ static __inline uint16_t __attribute__ ((__always_inline__))
vcgtzh_f16 (float16_t __a)
{
  return __builtin_aarch64_cmgthf_uss (__a, 0.0f);
}

__extension__ static __inline uint16_t __attribute__ ((__always_inline__))
vclezh_f16 (float16_t __a)
{
  return __builtin_aarch64_cmlehf_uss (__a, 0.0f);
}

__extension__ static __inline uint16_t __attribute__ ((__always_inline__))
vcltzh_f16 (float16_t __a)
{
  return __builtin_aarch64_cmlthf_uss (__a, 0.0f);
}

__extension__ static __inline float16_t __attribute__ ((__always_inline__))
vcvth_f16_s16 (int16_t __a)
{
  return __builtin_aarch64_floathihf (__a);
}

__extension__ static __inline float16_t __attribute__ ((__always_inline__))
vcvth_f16_s32 (int32_t __a)
{
  return __builtin_aarch64_floatsihf (__a);
}

__extension__ static __inline float16_t __attribute__ ((__always_inline__))
vcvth_f16_s64 (int64_t __a)
{
  return __builtin_aarch64_floatdihf (__a);
}

__extension__ static __inline float16_t __attribute__ ((__always_inline__))
vcvth_f16_u16 (uint16_t __a)
{
  return __builtin_aarch64_floatunshihf_us (__a);
}

__extension__ static __inline float16_t __attribute__ ((__always_inline__))
vcvth_f16_u32 (uint32_t __a)
{
  return __builtin_aarch64_floatunssihf_us (__a);
}

__extension__ static __inline float16_t __attribute__ ((__always_inline__))
vcvth_f16_u64 (uint64_t __a)
{
  return __builtin_aarch64_floatunsdihf_us (__a);
}

__extension__ static __inline int16_t __attribute__ ((__always_inline__))
vcvth_s16_f16 (float16_t __a)
{
  return __builtin_aarch64_fix_trunchfhi (__a);
}

__extension__ static __inline int32_t __attribute__ ((__always_inline__))
vcvth_s32_f16 (float16_t __a)
{
  return __builtin_aarch64_fix_trunchfsi (__a);
}

__extension__ static __inline int64_t __attribute__ ((__always_inline__))
vcvth_s64_f16 (float16_t __a)
{
  return __builtin_aarch64_fix_trunchfdi (__a);
}

__extension__ static __inline uint16_t __attribute__ ((__always_inline__))
vcvth_u16_f16 (float16_t __a)
{
  return __builtin_aarch64_fixuns_trunchfhi_us (__a);
}

__extension__ static __inline uint32_t __attribute__ ((__always_inline__))
vcvth_u32_f16 (float16_t __a)
{
  return __builtin_aarch64_fixuns_trunchfsi_us (__a);
}

__extension__ static __inline uint64_t __attribute__ ((__always_inline__))
vcvth_u64_f16 (float16_t __a)
{
  return __builtin_aarch64_fixuns_trunchfdi_us (__a);
}

__extension__ static __inline int16_t __attribute__ ((__always_inline__))
vcvtah_s16_f16 (float16_t __a)
{
  return __builtin_aarch64_lroundhfhi (__a);
}

__extension__ static __inline int32_t __attribute__ ((__always_inline__))
vcvtah_s32_f16 (float16_t __a)
{
  return __builtin_aarch64_lroundhfsi (__a);
}

__extension__ static __inline int64_t __attribute__ ((__always_inline__))
vcvtah_s64_f16 (float16_t __a)
{
  return __builtin_aarch64_lroundhfdi (__a);
}

__extension__ static __inline uint16_t __attribute__ ((__always_inline__))
vcvtah_u16_f16 (float16_t __a)
{
  return __builtin_aarch64_lrounduhfhi_us (__a);
}

__extension__ static __inline uint32_t __attribute__ ((__always_inline__))
vcvtah_u32_f16 (float16_t __a)
{
  return __builtin_aarch64_lrounduhfsi_us (__a);
}

__extension__ static __inline uint64_t __attribute__ ((__always_inline__))
vcvtah_u64_f16 (float16_t __a)
{
  return __builtin_aarch64_lrounduhfdi_us (__a);
}

__extension__ static __inline int16_t __attribute__ ((__always_inline__))
vcvtmh_s16_f16 (float16_t __a)
{
  return __builtin_aarch64_lfloorhfhi (__a);
}

__extension__ static __inline int32_t __attribute__ ((__always_inline__))
vcvtmh_s32_f16 (float16_t __a)
{
  return __builtin_aarch64_lfloorhfsi (__a);
}

__extension__ static __inline int64_t __attribute__ ((__always_inline__))
vcvtmh_s64_f16 (float16_t __a)
{
  return __builtin_aarch64_lfloorhfdi (__a);
}

__extension__ static __inline uint16_t __attribute__ ((__always_inline__))
vcvtmh_u16_f16 (float16_t __a)
{
  return __builtin_aarch64_lflooruhfhi_us (__a);
}

__extension__ static __inline uint32_t __attribute__ ((__always_inline__))
vcvtmh_u32_f16 (float16_t __a)
{
  return __builtin_aarch64_lflooruhfsi_us (__a);
}

__extension__ static __inline uint64_t __attribute__ ((__always_inline__))
vcvtmh_u64_f16 (float16_t __a)
{
  return __builtin_aarch64_lflooruhfdi_us (__a);
}

__extension__ static __inline int16_t __attribute__ ((__always_inline__))
vcvtnh_s16_f16 (float16_t __a)
{
  return __builtin_aarch64_lfrintnhfhi (__a);
}

__extension__ static __inline int32_t __attribute__ ((__always_inline__))
vcvtnh_s32_f16 (float16_t __a)
{
  return __builtin_aarch64_lfrintnhfsi (__a);
}

__extension__ static __inline int64_t __attribute__ ((__always_inline__))
vcvtnh_s64_f16 (float16_t __a)
{
  return __builtin_aarch64_lfrintnhfdi (__a);
}

__extension__ static __inline uint16_t __attribute__ ((__always_inline__))
vcvtnh_u16_f16 (float16_t __a)
{
  return __builtin_aarch64_lfrintnuhfhi_us (__a);
}

__extension__ static __inline uint32_t __attribute__ ((__always_inline__))
vcvtnh_u32_f16 (float16_t __a)
{
  return __builtin_aarch64_lfrintnuhfsi_us (__a);
}

__extension__ static __inline uint64_t __attribute__ ((__always_inline__))
vcvtnh_u64_f16 (float16_t __a)
{
  return __builtin_aarch64_lfrintnuhfdi_us (__a);
}

__extension__ static __inline int16_t __attribute__ ((__always_inline__))
vcvtph_s16_f16 (float16_t __a)
{
  return __builtin_aarch64_lceilhfhi (__a);
}

__extension__ static __inline int32_t __attribute__ ((__always_inline__))
vcvtph_s32_f16 (float16_t __a)
{
  return __builtin_aarch64_lceilhfsi (__a);
}

__extension__ static __inline int64_t __attribute__ ((__always_inline__))
vcvtph_s64_f16 (float16_t __a)
{
  return __builtin_aarch64_lceilhfdi (__a);
}

__extension__ static __inline uint16_t __attribute__ ((__always_inline__))
vcvtph_u16_f16 (float16_t __a)
{
  return __builtin_aarch64_lceiluhfhi_us (__a);
}

__extension__ static __inline uint32_t __attribute__ ((__always_inline__))
vcvtph_u32_f16 (float16_t __a)
{
  return __builtin_aarch64_lceiluhfsi_us (__a);
}

__extension__ static __inline uint64_t __attribute__ ((__always_inline__))
vcvtph_u64_f16 (float16_t __a)
{
  return __builtin_aarch64_lceiluhfdi_us (__a);
}

__extension__ static __inline float16_t __attribute__ ((__always_inline__))
vnegh_f16 (float16_t __a)
{
  return __builtin_aarch64_neghf (__a);
}

__extension__ static __inline float16_t __attribute__ ((__always_inline__))
vrecpeh_f16 (float16_t __a)
{
  return __builtin_aarch64_frecpehf (__a);
}

__extension__ static __inline float16_t __attribute__ ((__always_inline__))
vrecpxh_f16 (float16_t __a)
{
  return __builtin_aarch64_frecpxhf (__a);
}

__extension__ static __inline float16_t __attribute__ ((__always_inline__))
vrndh_f16 (float16_t __a)
{
  return __builtin_aarch64_btrunchf (__a);
}

__extension__ static __inline float16_t __attribute__ ((__always_inline__))
vrndah_f16 (float16_t __a)
{
  return __builtin_aarch64_roundhf (__a);
}

__extension__ static __inline float16_t __attribute__ ((__always_inline__))
vrndih_f16 (float16_t __a)
{
  return __builtin_aarch64_nearbyinthf (__a);
}

__extension__ static __inline float16_t __attribute__ ((__always_inline__))
vrndmh_f16 (float16_t __a)
{
  return __builtin_aarch64_floorhf (__a);
}

__extension__ static __inline float16_t __attribute__ ((__always_inline__))
vrndnh_f16 (float16_t __a)
{
  return __builtin_aarch64_frintnhf (__a);
}

__extension__ static __inline float16_t __attribute__ ((__always_inline__))
vrndph_f16 (float16_t __a)
{
  return __builtin_aarch64_ceilhf (__a);
}

__extension__ static __inline float16_t __attribute__ ((__always_inline__))
vrndxh_f16 (float16_t __a)
{
  return __builtin_aarch64_rinthf (__a);
}

__extension__ static __inline float16_t __attribute__ ((__always_inline__))
vrsqrteh_f16 (float16_t __a)
{
  return __builtin_aarch64_rsqrtehf (__a);
}

__extension__ static __inline float16_t __attribute__ ((__always_inline__))
vsqrth_f16 (float16_t __a)
{
  return __builtin_aarch64_sqrthf (__a);
}

/* ARMv8.2-A FP16 two operands scalar intrinsics.  */

__extension__ static __inline float16_t __attribute__ ((__always_inline__))
vaddh_f16 (float16_t __a, float16_t __b)
{
  return __a + __b;
}

__extension__ static __inline float16_t __attribute__ ((__always_inline__))
vabdh_f16 (float16_t __a, float16_t __b)
{
  return __builtin_aarch64_fabdhf (__a, __b);
}

__extension__ static __inline uint16_t __attribute__ ((__always_inline__))
vcageh_f16 (float16_t __a, float16_t __b)
{
  return __builtin_aarch64_facgehf_uss (__a, __b);
}

__extension__ static __inline uint16_t __attribute__ ((__always_inline__))
vcagth_f16 (float16_t __a, float16_t __b)
{
  return __builtin_aarch64_facgthf_uss (__a, __b);
}

__extension__ static __inline uint16_t __attribute__ ((__always_inline__))
vcaleh_f16 (float16_t __a, float16_t __b)
{
  return __builtin_aarch64_faclehf_uss (__a, __b);
}

__extension__ static __inline uint16_t __attribute__ ((__always_inline__))
vcalth_f16 (float16_t __a, float16_t __b)
{
  return __builtin_aarch64_faclthf_uss (__a, __b);
}

__extension__ static __inline uint16_t __attribute__ ((__always_inline__))
vceqh_f16 (float16_t __a, float16_t __b)
{
  return __builtin_aarch64_cmeqhf_uss (__a, __b);
}

__extension__ static __inline uint16_t __attribute__ ((__always_inline__))
vcgeh_f16 (float16_t __a, float16_t __b)
{
  return __builtin_aarch64_cmgehf_uss (__a, __b);
}

__extension__ static __inline uint16_t __attribute__ ((__always_inline__))
vcgth_f16 (float16_t __a, float16_t __b)
{
  return __builtin_aarch64_cmgthf_uss (__a, __b);
}

__extension__ static __inline uint16_t __attribute__ ((__always_inline__))
vcleh_f16 (float16_t __a, float16_t __b)
{
  return __builtin_aarch64_cmlehf_uss (__a, __b);
}

__extension__ static __inline uint16_t __attribute__ ((__always_inline__))
vclth_f16 (float16_t __a, float16_t __b)
{
  return __builtin_aarch64_cmlthf_uss (__a, __b);
}

__extension__ static __inline float16_t __attribute__ ((__always_inline__))
vcvth_n_f16_s16 (int16_t __a, const int __b)
{
  return __builtin_aarch64_scvtfhi (__a, __b);
}

__extension__ static __inline float16_t __attribute__ ((__always_inline__))
vcvth_n_f16_s32 (int32_t __a, const int __b)
{
  return __builtin_aarch64_scvtfsihf (__a, __b);
}

__extension__ static __inline float16_t __attribute__ ((__always_inline__))
vcvth_n_f16_s64 (int64_t __a, const int __b)
{
  return __builtin_aarch64_scvtfdihf (__a, __b);
}

__extension__ static __inline float16_t __attribute__ ((__always_inline__))
vcvth_n_f16_u16 (uint16_t __a, const int __b)
{
  return __builtin_aarch64_ucvtfhi_sus (__a, __b);
}

__extension__ static __inline float16_t __attribute__ ((__always_inline__))
vcvth_n_f16_u32 (uint32_t __a, const int __b)
{
  return __builtin_aarch64_ucvtfsihf_sus (__a, __b);
}

__extension__ static __inline float16_t __attribute__ ((__always_inline__))
vcvth_n_f16_u64 (uint64_t __a, const int __b)
{
  return __builtin_aarch64_ucvtfdihf_sus (__a, __b);
}

__extension__ static __inline int16_t __attribute__ ((__always_inline__))
vcvth_n_s16_f16 (float16_t __a, const int __b)
{
  return __builtin_aarch64_fcvtzshf (__a, __b);
}

__extension__ static __inline int32_t __attribute__ ((__always_inline__))
vcvth_n_s32_f16 (float16_t __a, const int __b)
{
  return __builtin_aarch64_fcvtzshfsi (__a, __b);
}

__extension__ static __inline int64_t __attribute__ ((__always_inline__))
vcvth_n_s64_f16 (float16_t __a, const int __b)
{
  return __builtin_aarch64_fcvtzshfdi (__a, __b);
}

__extension__ static __inline uint16_t __attribute__ ((__always_inline__))
vcvth_n_u16_f16 (float16_t __a, const int __b)
{
  return __builtin_aarch64_fcvtzuhf_uss (__a, __b);
}

__extension__ static __inline uint32_t __attribute__ ((__always_inline__))
vcvth_n_u32_f16 (float16_t __a, const int __b)
{
  return __builtin_aarch64_fcvtzuhfsi_uss (__a, __b);
}

__extension__ static __inline uint64_t __attribute__ ((__always_inline__))
vcvth_n_u64_f16 (float16_t __a, const int __b)
{
  return __builtin_aarch64_fcvtzuhfdi_uss (__a, __b);
}

__extension__ static __inline float16_t __attribute__ ((__always_inline__))
vdivh_f16 (float16_t __a, float16_t __b)
{
  return __a / __b;
}

__extension__ static __inline float16_t __attribute__ ((__always_inline__))
vmaxh_f16 (float16_t __a, float16_t __b)
{
  return __builtin_aarch64_fmaxhf (__a, __b);
}

__extension__ static __inline float16_t __attribute__ ((__always_inline__))
vmaxnmh_f16 (float16_t __a, float16_t __b)
{
  return __builtin_aarch64_fmaxhf (__a, __b);
}

__extension__ static __inline float16_t __attribute__ ((__always_inline__))
vminh_f16 (float16_t __a, float16_t __b)
{
  return __builtin_aarch64_fminhf (__a, __b);
}

__extension__ static __inline float16_t __attribute__ ((__always_inline__))
vminnmh_f16 (float16_t __a, float16_t __b)
{
  return __builtin_aarch64_fminhf (__a, __b);
}

__extension__ static __inline float16_t __attribute__ ((__always_inline__))
vmulh_f16 (float16_t __a, float16_t __b)
{
  return __a * __b;
}

__extension__ static __inline float16_t __attribute__ ((__always_inline__))
vmulxh_f16 (float16_t __a, float16_t __b)
{
  return __builtin_aarch64_fmulxhf (__a, __b);
}

__extension__ static __inline float16_t __attribute__ ((__always_inline__))
vrecpsh_f16 (float16_t __a, float16_t __b)
{
  return __builtin_aarch64_frecpshf (__a, __b);
}

__extension__ static __inline float16_t __attribute__ ((__always_inline__))
vrsqrtsh_f16 (float16_t __a, float16_t __b)
{
  return __builtin_aarch64_rsqrtshf (__a, __b);
}

__extension__ static __inline float16_t __attribute__ ((__always_inline__))
vsubh_f16 (float16_t __a, float16_t __b)
{
  return __a - __b;
}

/* ARMv8.2-A FP16 three operands scalar intrinsics.  */

__extension__ static __inline float16_t __attribute__ ((__always_inline__))
vfmah_f16 (float16_t __a, float16_t __b, float16_t __c)
{
  return __builtin_aarch64_fmahf (__b, __c, __a);
}

__extension__ static __inline float16_t __attribute__ ((__always_inline__))
vfmsh_f16 (float16_t __a, float16_t __b, float16_t __c)
{
  return __builtin_aarch64_fnmahf (__b, __c, __a);
}

#pragma GCC pop_options

#endif