]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/doc/gcc/extensions-to-the-c-language-family/target-builtins/basic-powerpc-built-in-functions.rst
sphinx: add missing trailing newline
[thirdparty/gcc.git] / gcc / doc / gcc / extensions-to-the-c-language-family / target-builtins / basic-powerpc-built-in-functions.rst
CommitLineData
c63539ff
ML
1..
2 Copyright 1988-2022 Free Software Foundation, Inc.
3 This is part of the GCC manual.
4 For copying conditions, see the copyright.rst file.
5
6.. _basic-powerpc-built-in-functions:
7
8Basic PowerPC Built-in Functions
9^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
10
11.. toctree::
12 :maxdepth: 2
13
14
15This section describes PowerPC built-in functions that do not require
16the inclusion of any special header files to declare prototypes or
17provide macro definitions. The sections that follow describe
18additional PowerPC built-in functions.
19
20.. _basic-powerpc-built-in-functions-available-on-all-configurations:
21
22Basic PowerPC Built-in Functions Available on all Configurations
23~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
24
25.. function:: void __builtin_cpu_init (void)
26
27 This function is a ``nop`` on the PowerPC platform and is included solely
28 to maintain API compatibility with the x86 builtins.
29
30.. function:: int __builtin_cpu_is (const char *cpuname)
31
32 This function returns a value of ``1`` if the run-time CPU is of type
33 :samp:`{cpuname}` and returns ``0`` otherwise
34
35 The ``__builtin_cpu_is`` function requires GLIBC 2.23 or newer
36 which exports the hardware capability bits. GCC defines the macro
37 ``__BUILTIN_CPU_SUPPORTS__`` if the ``__builtin_cpu_supports``
38 built-in function is fully supported.
39
40 If GCC was configured to use a GLIBC before 2.23, the built-in
41 function ``__builtin_cpu_is`` always returns a 0 and the compiler
42 issues a warning.
43
44 The following CPU names can be detected:
45
46 :samp:`power10`
47 IBM POWER10 Server CPU.
48
49 :samp:`power9`
50 IBM POWER9 Server CPU.
51
52 :samp:`power8`
53 IBM POWER8 Server CPU.
54
55 :samp:`power7`
56 IBM POWER7 Server CPU.
57
58 :samp:`power6x`
59 IBM POWER6 Server CPU (RAW mode).
60
61 :samp:`power6`
62 IBM POWER6 Server CPU (Architected mode).
63
64 :samp:`power5+`
65 IBM POWER5+ Server CPU.
66
67 :samp:`power5`
68 IBM POWER5 Server CPU.
69
70 :samp:`ppc970`
71 IBM 970 Server CPU (ie, Apple G5).
72
73 :samp:`power4`
74 IBM POWER4 Server CPU.
75
76 :samp:`ppca2`
77 IBM A2 64-bit Embedded CPU
78
79 :samp:`ppc476`
80 IBM PowerPC 476FP 32-bit Embedded CPU.
81
82 :samp:`ppc464`
83 IBM PowerPC 464 32-bit Embedded CPU.
84
85 :samp:`ppc440`
86 PowerPC 440 32-bit Embedded CPU.
87
88 :samp:`ppc405`
89 PowerPC 405 32-bit Embedded CPU.
90
91 :samp:`ppc-cell-be`
92 IBM PowerPC Cell Broadband Engine Architecture CPU.
93
94 Here is an example:
95
96 .. code-block:: c++
97
98 #ifdef __BUILTIN_CPU_SUPPORTS__
99 if (__builtin_cpu_is ("power8"))
100 {
101 do_power8 (); // POWER8 specific implementation.
102 }
103 else
104 #endif
105 {
106 do_generic (); // Generic implementation.
107 }
108
109.. function:: int __builtin_cpu_supports (const char *feature)
110
111 This function returns a value of ``1`` if the run-time CPU supports the HWCAP
112 feature :samp:`{feature}` and returns ``0`` otherwise.
113
114 The ``__builtin_cpu_supports`` function requires GLIBC 2.23 or
115 newer which exports the hardware capability bits. GCC defines the
116 macro ``__BUILTIN_CPU_SUPPORTS__`` if the
117 ``__builtin_cpu_supports`` built-in function is fully supported.
118
119 If GCC was configured to use a GLIBC before 2.23, the built-in
120 function ``__builtin_cpu_supports`` always returns a 0 and the
121 compiler issues a warning.
122
123 The following features can be
124 detected:
125
126 :samp:`4xxmac`
127 4xx CPU has a Multiply Accumulator.
128
129 :samp:`altivec`
130 CPU has a SIMD/Vector Unit.
131
132 :samp:`arch_2_05`
133 CPU supports ISA 2.05 (eg, POWER6)
134
135 :samp:`arch_2_06`
136 CPU supports ISA 2.06 (eg, POWER7)
137
138 :samp:`arch_2_07`
139 CPU supports ISA 2.07 (eg, POWER8)
140
141 :samp:`arch_3_00`
142 CPU supports ISA 3.0 (eg, POWER9)
143
144 :samp:`arch_3_1`
145 CPU supports ISA 3.1 (eg, POWER10)
146
147 :samp:`archpmu`
148 CPU supports the set of compatible performance monitoring events.
149
150 :samp:`booke`
151 CPU supports the Embedded ISA category.
152
153 :samp:`cellbe`
154 CPU has a CELL broadband engine.
155
156 :samp:`darn`
157 CPU supports the ``darn`` (deliver a random number) instruction.
158
159 :samp:`dfp`
160 CPU has a decimal floating point unit.
161
162 :samp:`dscr`
163 CPU supports the data stream control register.
164
165 :samp:`ebb`
166 CPU supports event base branching.
167
168 :samp:`efpdouble`
169 CPU has a SPE double precision floating point unit.
170
171 :samp:`efpsingle`
172 CPU has a SPE single precision floating point unit.
173
174 :samp:`fpu`
175 CPU has a floating point unit.
176
177 :samp:`htm`
178 CPU has hardware transaction memory instructions.
179
180 :samp:`htm-nosc`
181 Kernel aborts hardware transactions when a syscall is made.
182
183 :samp:`htm-no-suspend`
184 CPU supports hardware transaction memory but does not support the
185 ``tsuspend.`` instruction.
186
187 :samp:`ic_snoop`
188 CPU supports icache snooping capabilities.
189
190 :samp:`ieee128`
191 CPU supports 128-bit IEEE binary floating point instructions.
192
193 :samp:`isel`
194 CPU supports the integer select instruction.
195
196 :samp:`mma`
197 CPU supports the matrix-multiply assist instructions.
198
199 :samp:`mmu`
200 CPU has a memory management unit.
201
202 :samp:`notb`
203 CPU does not have a timebase (eg, 601 and 403gx).
204
205 :samp:`pa6t`
206 CPU supports the PA Semi 6T CORE ISA.
207
208 :samp:`power4`
209 CPU supports ISA 2.00 (eg, POWER4)
210
211 :samp:`power5`
212 CPU supports ISA 2.02 (eg, POWER5)
213
214 :samp:`power5+`
215 CPU supports ISA 2.03 (eg, POWER5+)
216
217 :samp:`power6x`
218 CPU supports ISA 2.05 (eg, POWER6) extended opcodes mffgpr and mftgpr.
219
220 :samp:`ppc32`
221 CPU supports 32-bit mode execution.
222
223 :samp:`ppc601`
224 CPU supports the old POWER ISA (eg, 601)
225
226 :samp:`ppc64`
227 CPU supports 64-bit mode execution.
228
229 :samp:`ppcle`
230 CPU supports a little-endian mode that uses address swizzling.
231
232 :samp:`scv`
233 Kernel supports system call vectored.
234
235 :samp:`smt`
236 CPU support simultaneous multi-threading.
237
238 :samp:`spe`
239 CPU has a signal processing extension unit.
240
241 :samp:`tar`
242 CPU supports the target address register.
243
244 :samp:`true_le`
245 CPU supports true little-endian mode.
246
247 :samp:`ucache`
248 CPU has unified I/D cache.
249
250 :samp:`vcrypto`
251 CPU supports the vector cryptography instructions.
252
253 :samp:`vsx`
254 CPU supports the vector-scalar extension.
255
256 Here is an example:
257
258 .. code-block:: c++
259
260 #ifdef __BUILTIN_CPU_SUPPORTS__
261 if (__builtin_cpu_supports ("fpu"))
262 {
263 asm("fadd %0,%1,%2" : "=d"(dst) : "d"(src1), "d"(src2));
264 }
265 else
266 #endif
267 {
268 dst = __fadd (src1, src2); // Software FP addition function.
269 }
270
271The following built-in functions are also available on all PowerPC
272processors:
273
274.. code-block:: c++
275
276 uint64_t __builtin_ppc_get_timebase ();
277 unsigned long __builtin_ppc_mftb ();
278 double __builtin_unpack_ibm128 (__ibm128, int);
279 __ibm128 __builtin_pack_ibm128 (double, double);
280 double __builtin_mffs (void);
281 void __builtin_mtfsf (const int, double);
282 void __builtin_mtfsb0 (const int);
283 void __builtin_mtfsb1 (const int);
284 void __builtin_set_fpscr_rn (int);
285
286The ``__builtin_ppc_get_timebase`` and ``__builtin_ppc_mftb``
287functions generate instructions to read the Time Base Register. The
288``__builtin_ppc_get_timebase`` function may generate multiple
289instructions and always returns the 64 bits of the Time Base Register.
290The ``__builtin_ppc_mftb`` function always generates one instruction and
291returns the Time Base Register value as an unsigned long, throwing away
292the most significant word on 32-bit environments. The ``__builtin_mffs``
293return the value of the FPSCR register. Note, ISA 3.0 supports the
294``__builtin_mffsl()`` which permits software to read the control and
295non-sticky status bits in the FSPCR without the higher latency associated with
296accessing the sticky status bits. The ``__builtin_mtfsf`` takes a constant
2978-bit integer field mask and a double precision floating point argument
298and generates the ``mtfsf`` (extended mnemonic) instruction to write new
299values to selected fields of the FPSCR. The
300``__builtin_mtfsb0`` and ``__builtin_mtfsb1`` take the bit to change
301as an argument. The valid bit range is between 0 and 31. The builtins map to
302the ``mtfsb0`` and ``mtfsb1`` instructions which take the argument and
303add 32. Hence these instructions only modify the FPSCR[32:63] bits by
304changing the specified bit to a zero or one respectively. The
305``__builtin_set_fpscr_rn`` builtin allows changing both of the floating
306point rounding mode bits. The argument is a 2-bit value. The argument can
307either be a ``const int`` or stored in a variable. The builtin uses
308the ISA 3.0
309instruction ``mffscrn`` if available, otherwise it reads the FPSCR, masks
310the current rounding mode bits out and OR's in the new value.
311
312.. _basic-powerpc-built-in-functions-available-on-isa-2.05:
313
314Basic PowerPC Built-in Functions Available on ISA 2.05
315~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
316
317The basic built-in functions described in this section are
318available on the PowerPC family of processors starting with ISA 2.05
319or later. Unless specific options are explicitly disabled on the
320command line, specifying option :option:`-mcpu=power6` has the effect of
321enabling the :option:`-mpowerpc64`, :option:`-mpowerpc-gpopt`,
322:option:`-mpowerpc-gfxopt`, :option:`-mmfcrf`, :option:`-mpopcntb`,
323:option:`-mfprnd`, :option:`-mcmpb`, :option:`-mhard-dfp`, and
324:option:`-mrecip-precision` options. Specify the
325:option:`-maltivec` option explicitly in
326combination with the above options if desired.
327
328The following functions require option :option:`-mcmpb`.
329
330.. code-block:: c++
331
332 unsigned long long __builtin_cmpb (unsigned long long int, unsigned long long int);
333 unsigned int __builtin_cmpb (unsigned int, unsigned int);
334
335The ``__builtin_cmpb`` function
336performs a byte-wise compare on the contents of its two arguments,
337returning the result of the byte-wise comparison as the returned
338value. For each byte comparison, the corresponding byte of the return
339value holds 0xff if the input bytes are equal and 0 if the input bytes
340are not equal. If either of the arguments to this built-in function
341is wider than 32 bits, the function call expands into the form that
342expects ``unsigned long long int`` arguments
343which is only available on 64-bit targets.
344
345The following built-in functions are available
346when hardware decimal floating point
347(:option:`-mhard-dfp`) is available:
348
349.. code-block:: c++
350
351 void __builtin_set_fpscr_drn(int);
352 _Decimal64 __builtin_ddedpd (int, _Decimal64);
353 _Decimal128 __builtin_ddedpdq (int, _Decimal128);
354 _Decimal64 __builtin_denbcd (int, _Decimal64);
355 _Decimal128 __builtin_denbcdq (int, _Decimal128);
356 _Decimal64 __builtin_diex (long long, _Decimal64);
357 _Decimal128 _builtin_diexq (long long, _Decimal128);
358 _Decimal64 __builtin_dscli (_Decimal64, int);
359 _Decimal128 __builtin_dscliq (_Decimal128, int);
360 _Decimal64 __builtin_dscri (_Decimal64, int);
361 _Decimal128 __builtin_dscriq (_Decimal128, int);
362 long long __builtin_dxex (_Decimal64);
363 long long __builtin_dxexq (_Decimal128);
364 _Decimal128 __builtin_pack_dec128 (unsigned long long, unsigned long long);
365 unsigned long long __builtin_unpack_dec128 (_Decimal128, int);
366
367The __builtin_set_fpscr_drn builtin allows changing the three decimal
368floating point rounding mode bits. The argument is a 3-bit value. The
369argument can either be a const int or the value can be stored in
370a variable.
371The builtin uses the ISA 3.0 instruction mffscdrn if available.
372Otherwise the builtin reads the FPSCR, masks the current decimal rounding
373mode bits out and OR's in the new value.
374
375The following functions require :option:`-mhard-float`,
376:option:`-mpowerpc-gfxopt`, and :option:`-mpopcntb` options.
377
378.. code-block:: c++
379
380 double __builtin_recipdiv (double, double);
381 float __builtin_recipdivf (float, float);
382 double __builtin_rsqrt (double);
383 float __builtin_rsqrtf (float);
384
385The ``vec_rsqrt``, ``__builtin_rsqrt``, and
386``__builtin_rsqrtf`` functions generate multiple instructions to
387implement the reciprocal sqrt functionality using reciprocal sqrt
388estimate instructions.
389
390The ``__builtin_recipdiv``, and ``__builtin_recipdivf``
391functions generate multiple instructions to implement division using
392the reciprocal estimate instructions.
393
394The following functions require :option:`-mhard-float` and
395:option:`-mmultiple` options.
396
397The ``__builtin_unpack_longdouble`` function takes a
398``long double`` argument and a compile time constant of 0 or 1. If
399the constant is 0, the first ``double`` within the
400``long double`` is returned, otherwise the second ``double``
401is returned. The ``__builtin_unpack_longdouble`` function is only
402available if ``long double`` uses the IBM extended double
403representation.
404
405The ``__builtin_pack_longdouble`` function takes two ``double``
406arguments and returns a ``long double`` value that combines the two
407arguments. The ``__builtin_pack_longdouble`` function is only
408available if ``long double`` uses the IBM extended double
409representation.
410
411The ``__builtin_unpack_ibm128`` function takes a ``__ibm128``
412argument and a compile time constant of 0 or 1. If the constant is 0,
413the first ``double`` within the ``__ibm128`` is returned,
414otherwise the second ``double`` is returned.
415
416The ``__builtin_pack_ibm128`` function takes two ``double``
417arguments and returns a ``__ibm128`` value that combines the two
418arguments.
419
420Additional built-in functions are available for the 64-bit PowerPC
421family of processors, for efficient use of 128-bit floating point
422(``__float128``) values.
423
424.. _basic-powerpc-built-in-functions-available-on-isa-2.06:
425
426Basic PowerPC Built-in Functions Available on ISA 2.06
427~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
428
429The basic built-in functions described in this section are
430available on the PowerPC family of processors starting with ISA 2.05
431or later. Unless specific options are explicitly disabled on the
432command line, specifying option :option:`-mcpu=power7` has the effect of
433enabling all the same options as for :option:`-mcpu=power6` in
434addition to the :option:`-maltivec`, :option:`-mpopcntd`, and
435:option:`-mvsx` options.
436
437The following basic built-in functions require :option:`-mpopcntd` :
438
439.. code-block:: c++
440
441 unsigned int __builtin_addg6s (unsigned int, unsigned int);
442 long long __builtin_bpermd (long long, long long);
443 unsigned int __builtin_cbcdtd (unsigned int);
444 unsigned int __builtin_cdtbcd (unsigned int);
445 long long __builtin_divde (long long, long long);
446 unsigned long long __builtin_divdeu (unsigned long long, unsigned long long);
447 int __builtin_divwe (int, int);
448 unsigned int __builtin_divweu (unsigned int, unsigned int);
449 vector __int128 __builtin_pack_vector_int128 (long long, long long);
450 void __builtin_rs6000_speculation_barrier (void);
451 long long __builtin_unpack_vector_int128 (vector __int128, signed char);
452
453Of these, the ``__builtin_divde`` and ``__builtin_divdeu`` functions
454require a 64-bit environment.
455
456The following basic built-in functions, which are also supported on
457x86 targets, require :option:`-mfloat128`.
458
459.. code-block:: c++
460
461 __float128 __builtin_fabsq (__float128);
462 __float128 __builtin_copysignq (__float128, __float128);
463 __float128 __builtin_infq (void);
464 __float128 __builtin_huge_valq (void);
465 __float128 __builtin_nanq (void);
466 __float128 __builtin_nansq (void);
467
468 __float128 __builtin_sqrtf128 (__float128);
469 __float128 __builtin_fmaf128 (__float128, __float128, __float128);
470
471.. _basic-powerpc-built-in-functions-available-on-isa-2.07:
472
473Basic PowerPC Built-in Functions Available on ISA 2.07
474~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
475
476The basic built-in functions described in this section are
477available on the PowerPC family of processors starting with ISA 2.07
478or later. Unless specific options are explicitly disabled on the
479command line, specifying option :option:`-mcpu=power8` has the effect of
480enabling all the same options as for :option:`-mcpu=power7` in
481addition to the :option:`-mpower8-fusion`, :option:`-mpower8-vector`,
482:option:`-mcrypto`, :option:`-mhtm`, :option:`-mquad-memory`, and
483:option:`-mquad-memory-atomic` options.
484
485This section intentionally empty.
486
487.. _basic-powerpc-built-in-functions-available-on-isa-3.0:
488
489Basic PowerPC Built-in Functions Available on ISA 3.0
490~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
491
492The basic built-in functions described in this section are
493available on the PowerPC family of processors starting with ISA 3.0
494or later. Unless specific options are explicitly disabled on the
495command line, specifying option :option:`-mcpu=power9` has the effect of
496enabling all the same options as for :option:`-mcpu=power8` in
497addition to the :option:`-misel` option.
498
499The following built-in functions are available on Linux 64-bit systems
500that use the ISA 3.0 instruction set (:option:`-mcpu=power9`):
501
502.. function:: __float128 __builtin_addf128_round_to_odd (__float128, __float128)
503
504 Perform a 128-bit IEEE floating point add using round to odd as the
505 rounding mode.
506
507 .. index:: __builtin_addf128_round_to_odd
508
509.. function:: __float128 __builtin_subf128_round_to_odd (__float128, __float128)
510
511 Perform a 128-bit IEEE floating point subtract using round to odd as
512 the rounding mode.
513
514 .. index:: __builtin_subf128_round_to_odd
515
516.. function:: __float128 __builtin_mulf128_round_to_odd (__float128, __float128)
517
518 Perform a 128-bit IEEE floating point multiply using round to odd as
519 the rounding mode.
520
521 .. index:: __builtin_mulf128_round_to_odd
522
523.. function:: __float128 __builtin_divf128_round_to_odd (__float128, __float128)
524
525 Perform a 128-bit IEEE floating point divide using round to odd as
526 the rounding mode.
527
528 .. index:: __builtin_divf128_round_to_odd
529
530.. function:: __float128 __builtin_sqrtf128_round_to_odd (__float128)
531
532 Perform a 128-bit IEEE floating point square root using round to odd
533 as the rounding mode.
534
535 .. index:: __builtin_sqrtf128_round_to_odd
536
537.. function:: __float128 __builtin_fmaf128_round_to_odd (__float128, __float128, __float128)
538
539 Perform a 128-bit IEEE floating point fused multiply and add operation
540 using round to odd as the rounding mode.
541
542 .. index:: __builtin_fmaf128_round_to_odd
543
544.. function:: double __builtin_truncf128_round_to_odd (__float128)
545
546 Convert a 128-bit IEEE floating point value to ``double`` using
547 round to odd as the rounding mode.
548
549 .. index:: __builtin_truncf128_round_to_odd
550
551The following additional built-in functions are also available for the
552PowerPC family of processors, starting with ISA 3.0 or later:
553
554.. code-block:: c++
555
556 long long __builtin_darn (void);
557 long long __builtin_darn_raw (void);
558 int __builtin_darn_32 (void);
559
560The ``__builtin_darn`` and ``__builtin_darn_raw``
561functions require a
56264-bit environment supporting ISA 3.0 or later.
563The ``__builtin_darn`` function provides a 64-bit conditioned
564random number. The ``__builtin_darn_raw`` function provides a
56564-bit raw random number. The ``__builtin_darn_32`` function
566provides a 32-bit conditioned random number.
567
568The following additional built-in functions are also available for the
569PowerPC family of processors, starting with ISA 3.0 or later:
570
571.. code-block:: c++
572
573 int __builtin_byte_in_set (unsigned char u, unsigned long long set);
574 int __builtin_byte_in_range (unsigned char u, unsigned int range);
575 int __builtin_byte_in_either_range (unsigned char u, unsigned int ranges);
576
577 int __builtin_dfp_dtstsfi_lt (unsigned int comparison, _Decimal64 value);
578 int __builtin_dfp_dtstsfi_lt (unsigned int comparison, _Decimal128 value);
579 int __builtin_dfp_dtstsfi_lt_dd (unsigned int comparison, _Decimal64 value);
580 int __builtin_dfp_dtstsfi_lt_td (unsigned int comparison, _Decimal128 value);
581
582 int __builtin_dfp_dtstsfi_gt (unsigned int comparison, _Decimal64 value);
583 int __builtin_dfp_dtstsfi_gt (unsigned int comparison, _Decimal128 value);
584 int __builtin_dfp_dtstsfi_gt_dd (unsigned int comparison, _Decimal64 value);
585 int __builtin_dfp_dtstsfi_gt_td (unsigned int comparison, _Decimal128 value);
586
587 int __builtin_dfp_dtstsfi_eq (unsigned int comparison, _Decimal64 value);
588 int __builtin_dfp_dtstsfi_eq (unsigned int comparison, _Decimal128 value);
589 int __builtin_dfp_dtstsfi_eq_dd (unsigned int comparison, _Decimal64 value);
590 int __builtin_dfp_dtstsfi_eq_td (unsigned int comparison, _Decimal128 value);
591
592 int __builtin_dfp_dtstsfi_ov (unsigned int comparison, _Decimal64 value);
593 int __builtin_dfp_dtstsfi_ov (unsigned int comparison, _Decimal128 value);
594 int __builtin_dfp_dtstsfi_ov_dd (unsigned int comparison, _Decimal64 value);
595 int __builtin_dfp_dtstsfi_ov_td (unsigned int comparison, _Decimal128 value);
596
597 double __builtin_mffsl(void);
598
599The ``__builtin_byte_in_set`` function requires a
60064-bit environment supporting ISA 3.0 or later. This function returns
601a non-zero value if and only if its ``u`` argument exactly equals one of
602the eight bytes contained within its 64-bit ``set`` argument.
603
604The ``__builtin_byte_in_range`` and
605``__builtin_byte_in_either_range`` require an environment
606supporting ISA 3.0 or later. For these two functions, the
607``range`` argument is encoded as 4 bytes, organized as
608``hi_1:lo_1:hi_2:lo_2``.
609The ``__builtin_byte_in_range`` function returns a
610non-zero value if and only if its ``u`` argument is within the
611range bounded between ``lo_2`` and ``hi_2`` inclusive.
612The ``__builtin_byte_in_either_range`` function returns non-zero if
613and only if its ``u`` argument is within either the range bounded
614between ``lo_1`` and ``hi_1`` inclusive or the range bounded
615between ``lo_2`` and ``hi_2`` inclusive.
616
617The ``__builtin_dfp_dtstsfi_lt`` function returns a non-zero value
618if and only if the number of signficant digits of its ``value`` argument
619is less than its ``comparison`` argument. The
620``__builtin_dfp_dtstsfi_lt_dd`` and
621``__builtin_dfp_dtstsfi_lt_td`` functions behave similarly, but
622require that the type of the ``value`` argument be
623``__Decimal64`` and ``__Decimal128`` respectively.
624
625The ``__builtin_dfp_dtstsfi_gt`` function returns a non-zero value
626if and only if the number of signficant digits of its ``value`` argument
627is greater than its ``comparison`` argument. The
628``__builtin_dfp_dtstsfi_gt_dd`` and
629``__builtin_dfp_dtstsfi_gt_td`` functions behave similarly, but
630require that the type of the ``value`` argument be
631``__Decimal64`` and ``__Decimal128`` respectively.
632
633The ``__builtin_dfp_dtstsfi_eq`` function returns a non-zero value
634if and only if the number of signficant digits of its ``value`` argument
635equals its ``comparison`` argument. The
636``__builtin_dfp_dtstsfi_eq_dd`` and
637``__builtin_dfp_dtstsfi_eq_td`` functions behave similarly, but
638require that the type of the ``value`` argument be
639``__Decimal64`` and ``__Decimal128`` respectively.
640
641The ``__builtin_dfp_dtstsfi_ov`` function returns a non-zero value
642if and only if its ``value`` argument has an undefined number of
643significant digits, such as when ``value`` is an encoding of ``NaN``.
644The ``__builtin_dfp_dtstsfi_ov_dd`` and
645``__builtin_dfp_dtstsfi_ov_td`` functions behave similarly, but
646require that the type of the ``value`` argument be
647``__Decimal64`` and ``__Decimal128`` respectively.
648
649The ``__builtin_mffsl`` uses the ISA 3.0 ``mffsl`` instruction to read
650the FPSCR. The instruction is a lower latency version of the ``mffs``
651instruction. If the ``mffsl`` instruction is not available, then the
652builtin uses the older ``mffs`` instruction to read the FPSCR.
653
654.. _basic-powerpc-built-in-functions-available-on-isa-3.1:
655
656Basic PowerPC Built-in Functions Available on ISA 3.1
657~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
658
659The basic built-in functions described in this section are
660available on the PowerPC family of processors starting with ISA 3.1.
661Unless specific options are explicitly disabled on the
662command line, specifying option :option:`-mcpu=power10` has the effect of
663enabling all the same options as for :option:`-mcpu=power9`.
664
665The following built-in functions are available on Linux 64-bit systems
666that use a future architecture instruction set (:option:`-mcpu=power10`):
667
668.. function:: unsigned long long __builtin_cfuged (unsigned long long, unsigned long long int)
669
670 Perform a 64-bit centrifuge operation, as if implemented by the
671 ``cfuged`` instruction.
672
673.. function:: unsigned long long __builtin_cntlzdm (unsigned long long int, unsigned long long int)
674
675 Perform a 64-bit count leading zeros operation under mask, as if
676 implemented by the ``cntlzdm`` instruction.
677
678.. function:: unsigned long long __builtin_cnttzdm (unsigned long long, unsigned long long)
679
680 Perform a 64-bit count trailing zeros operation under mask, as if
681 implemented by the ``cnttzdm`` instruction.
682
683.. function:: unsigned long long __builtin_pdepd (unsigned long long int, unsigned long long int)
684
685 Perform a 64-bit parallel bits deposit operation, as if implemented by the
686 ``pdepd`` instruction.
687
688.. function:: unsigned long long __builtin_pextd (unsigned long long, unsigned long long)
689
690 Perform a 64-bit parallel bits extract operation, as if implemented by the
691 ``pextd`` instruction.
692
693.. code-block:: c++
694
695 vector signed __int128 vsx_xl_sext (signed long long, signed char *)
696 vector signed __int128 vsx_xl_sext (signed long long, signed short *)
697 vector signed __int128 vsx_xl_sext (signed long long, signed int *)
698 vector signed __int128 vsx_xl_sext (signed long long, signed long long *)
699 vector unsigned __int128 vsx_xl_zext (signed long long, unsigned char *)
700 vector unsigned __int128 vsx_xl_zext (signed long long, unsigned short *)
701 vector unsigned __int128 vsx_xl_zext (signed long long, unsigned int *)
702 vector unsigned __int128 vsx_xl_zext (signed long long, unsigned long long *)
703
704Load (and sign extend) to an __int128 vector, as if implemented by the ISA 3.1
705``lxvrbx``, ``lxvrhx``, ``lxvrwx``, and ``lxvrdx`` instructions.
706
707.. index:: vsx_xl_sext, vsx_xl_zext
708
709.. code-block:: c++
710
711 void vec_xst_trunc (vector signed __int128, signed long long, signed char *)
712 void vec_xst_trunc (vector signed __int128, signed long long, signed short *)
713 void vec_xst_trunc (vector signed __int128, signed long long, signed int *)
714 void vec_xst_trunc (vector signed __int128, signed long long, signed long long *)
715 void vec_xst_trunc (vector unsigned __int128, signed long long, unsigned char *)
716 void vec_xst_trunc (vector unsigned __int128, signed long long, unsigned short *)
717 void vec_xst_trunc (vector unsigned __int128, signed long long, unsigned int *)
718 void vec_xst_trunc (vector unsigned __int128, signed long long, unsigned long long *)
719
720Truncate and store the rightmost element of a vector, as if implemented by the
721ISA 3.1 ``stxvrbx``, ``stxvrhx``, ``stxvrwx``, and ``stxvrdx``
722instructions.
723
3ed1b4ce 724.. index:: vec_xst_trunc