Enable prange support.
[official-gcc.git] / gcc / doc / extend.texi
blob267fccd1512e60b8a40f6df06b702c3d28c2e785
1 @c Copyright (C) 1988-2024 Free Software Foundation, Inc.
3 @c This is part of the GCC manual.
4 @c For copying conditions, see the file gcc.texi.
6 @node C Extensions
7 @chapter Extensions to the C Language Family
8 @cindex extensions, C language
9 @cindex C language extensions
11 @opindex pedantic
12 GNU C provides several language features not found in ISO standard C@.
13 (The @option{-pedantic} option directs GCC to print a warning message if
14 any of these features is used.)  To test for the availability of these
15 features in conditional compilation, check for a predefined macro
16 @code{__GNUC__}, which is always defined under GCC@.
18 These extensions are available in C and Objective-C@.  Most of them are
19 also available in C++.  @xref{C++ Extensions,,Extensions to the
20 C++ Language}, for extensions that apply @emph{only} to C++.
22 Some features that are in ISO C99 but not C90 or C++ are also, as
23 extensions, accepted by GCC in C90 mode and in C++.
25 @menu
26 * Statement Exprs::     Putting statements and declarations inside expressions.
27 * Local Labels::        Labels local to a block.
28 * Labels as Values::    Getting pointers to labels, and computed gotos.
29 * Nested Functions::    Nested function in GNU C.
30 * Nonlocal Gotos::      Nonlocal gotos.
31 * Constructing Calls::  Dispatching a call to another function.
32 * Typeof::              @code{typeof}: referring to the type of an expression.
33 * Conditionals::        Omitting the middle operand of a @samp{?:} expression.
34 * __int128::            128-bit integers---@code{__int128}.
35 * Long Long::           Double-word integers---@code{long long int}.
36 * Complex::             Data types for complex numbers.
37 * Floating Types::      Additional Floating Types.
38 * Half-Precision::      Half-Precision Floating Point.
39 * Decimal Float::       Decimal Floating Types.
40 * Hex Floats::          Hexadecimal floating-point constants.
41 * Fixed-Point::         Fixed-Point Types.
42 * Named Address Spaces::Named address spaces.
43 * Zero Length::         Zero-length arrays.
44 * Empty Structures::    Structures with no members.
45 * Flexible Array Members in Unions::  Unions with Flexible Array Members.
46 * Flexible Array Members alone in Structures::  Structures with only Flexible Array Members.
47 * Variable Length::     Arrays whose length is computed at run time.
48 * Variadic Macros::     Macros with a variable number of arguments.
49 * Escaped Newlines::    Slightly looser rules for escaped newlines.
50 * Subscripting::        Any array can be subscripted, even if not an lvalue.
51 * Pointer Arith::       Arithmetic on @code{void}-pointers and function pointers.
52 * Variadic Pointer Args::  Pointer arguments to variadic functions.
53 * Pointers to Arrays::  Pointers to arrays with qualifiers work as expected.
54 * Initializers::        Non-constant initializers.
55 * Compound Literals::   Compound literals give structures, unions
56                         or arrays as values.
57 * Designated Inits::    Labeling elements of initializers.
58 * Case Ranges::         `case 1 ... 9' and such.
59 * Cast to Union::       Casting to union type from any member of the union.
60 * Mixed Labels and Declarations::  Mixing declarations, labels and code.
61 * Function Attributes:: Declaring that functions have no side effects,
62                         or that they can never return.
63 * Variable Attributes:: Specifying attributes of variables.
64 * Type Attributes::     Specifying attributes of types.
65 * Label Attributes::    Specifying attributes on labels.
66 * Enumerator Attributes:: Specifying attributes on enumerators.
67 * Statement Attributes:: Specifying attributes on statements.
68 * Attribute Syntax::    Formal syntax for attributes.
69 * Function Prototypes:: Prototype declarations and old-style definitions.
70 * C++ Comments::        C++ comments are recognized.
71 * Dollar Signs::        Dollar sign is allowed in identifiers.
72 * Character Escapes::   @samp{\e} stands for the character @key{ESC}.
73 * Alignment::           Determining the alignment of a function, type or variable.
74 * Inline::              Defining inline functions (as fast as macros).
75 * Const and Volatile Functions :: GCC interprets these specially in C.
76 * Volatiles::           What constitutes an access to a volatile object.
77 * Using Assembly Language with C:: Instructions and extensions for interfacing C with assembler.
78 * Alternate Keywords::  @code{__const__}, @code{__asm__}, etc., for header files.
79 * Incomplete Enums::    @code{enum foo;}, with details to follow.
80 * Function Names::      Printable strings which are the name of the current
81                         function.
82 * Return Address::      Getting the return or frame address of a function.
83 * Stack Scrubbing::     Stack scrubbing internal interfaces.
84 * Vector Extensions::   Using vector instructions through built-in functions.
85 * Offsetof::            Special syntax for implementing @code{offsetof}.
86 * __sync Builtins::     Legacy built-in functions for atomic memory access.
87 * __atomic Builtins::   Atomic built-in functions with memory model.
88 * Integer Overflow Builtins:: Built-in functions to perform arithmetics and
89                         arithmetic overflow checking.
90 * x86 specific memory model extensions for transactional memory:: x86 memory models.
91 * Object Size Checking:: Built-in functions for limited buffer overflow
92                         checking.
93 * Other Builtins::      Other built-in functions.
94 * Target Builtins::     Built-in functions specific to particular targets.
95 * Target Format Checks:: Format checks specific to particular targets.
96 * Pragmas::             Pragmas accepted by GCC.
97 * Unnamed Fields::      Unnamed struct/union fields within structs/unions.
98 * Thread-Local::        Per-thread variables.
99 * Binary constants::    Binary constants using the @samp{0b} prefix.
100 @end menu
102 @node Statement Exprs
103 @section Statements and Declarations in Expressions
104 @cindex statements inside expressions
105 @cindex declarations inside expressions
106 @cindex expressions containing statements
107 @cindex macros, statements in expressions
109 @c the above section title wrapped and causes an underfull hbox.. i
110 @c changed it from "within" to "in". --mew 4feb93
111 A compound statement enclosed in parentheses may appear as an expression
112 in GNU C@.  This allows you to use loops, switches, and local variables
113 within an expression.
115 Recall that a compound statement is a sequence of statements surrounded
116 by braces; in this construct, parentheses go around the braces.  For
117 example:
119 @smallexample
120 (@{ int y = foo (); int z;
121    if (y > 0) z = y;
122    else z = - y;
123    z; @})
124 @end smallexample
126 @noindent
127 is a valid (though slightly more complex than necessary) expression
128 for the absolute value of @code{foo ()}.
130 The last thing in the compound statement should be an expression
131 followed by a semicolon; the value of this subexpression serves as the
132 value of the entire construct.  (If you use some other kind of statement
133 last within the braces, the construct has type @code{void}, and thus
134 effectively no value.)
136 This feature is especially useful in making macro definitions ``safe'' (so
137 that they evaluate each operand exactly once).  For example, the
138 ``maximum'' function is commonly defined as a macro in standard C as
139 follows:
141 @smallexample
142 #define max(a,b) ((a) > (b) ? (a) : (b))
143 @end smallexample
145 @noindent
146 @cindex side effects, macro argument
147 But this definition computes either @var{a} or @var{b} twice, with bad
148 results if the operand has side effects.  In GNU C, if you know the
149 type of the operands (here taken as @code{int}), you can avoid this
150 problem by defining the macro as follows:
152 @smallexample
153 #define maxint(a,b) \
154   (@{int _a = (a), _b = (b); _a > _b ? _a : _b; @})
155 @end smallexample
157 Note that introducing variable declarations (as we do in @code{maxint}) can
158 cause variable shadowing, so while this example using the @code{max} macro
159 produces correct results:
160 @smallexample
161 int _a = 1, _b = 2, c;
162 c = max (_a, _b);
163 @end smallexample
164 @noindent
165 this example using maxint will not:
166 @smallexample
167 int _a = 1, _b = 2, c;
168 c = maxint (_a, _b);
169 @end smallexample
171 This problem may for instance occur when we use this pattern recursively, like
174 @smallexample
175 #define maxint3(a, b, c) \
176   (@{int _a = (a), _b = (b), _c = (c); maxint (maxint (_a, _b), _c); @})
177 @end smallexample
179 Embedded statements are not allowed in constant expressions, such as
180 the value of an enumeration constant, the width of a bit-field, or
181 the initial value of a static variable.
183 If you don't know the type of the operand, you can still do this, but you
184 must use @code{typeof} or @code{__auto_type} (@pxref{Typeof}).
186 In G++, the result value of a statement expression undergoes array and
187 function pointer decay, and is returned by value to the enclosing
188 expression.  For instance, if @code{A} is a class, then
190 @smallexample
191         A a;
193         (@{a;@}).Foo ()
194 @end smallexample
196 @noindent
197 constructs a temporary @code{A} object to hold the result of the
198 statement expression, and that is used to invoke @code{Foo}.
199 Therefore the @code{this} pointer observed by @code{Foo} is not the
200 address of @code{a}.
202 In a statement expression, any temporaries created within a statement
203 are destroyed at that statement's end.  This makes statement
204 expressions inside macros slightly different from function calls.  In
205 the latter case temporaries introduced during argument evaluation are
206 destroyed at the end of the statement that includes the function
207 call.  In the statement expression case they are destroyed during
208 the statement expression.  For instance,
210 @smallexample
211 #define macro(a)  (@{__typeof__(a) b = (a); b + 3; @})
212 template<typename T> T function(T a) @{ T b = a; return b + 3; @}
214 void foo ()
216   macro (X ());
217   function (X ());
219 @end smallexample
221 @noindent
222 has different places where temporaries are destroyed.  For the
223 @code{macro} case, the temporary @code{X} is destroyed just after
224 the initialization of @code{b}.  In the @code{function} case that
225 temporary is destroyed when the function returns.
227 These considerations mean that it is probably a bad idea to use
228 statement expressions of this form in header files that are designed to
229 work with C++.  (Note that some versions of the GNU C Library contained
230 header files using statement expressions that lead to precisely this
231 bug.)
233 Jumping into a statement expression with @code{goto} or using a
234 @code{switch} statement outside the statement expression with a
235 @code{case} or @code{default} label inside the statement expression is
236 not permitted.  Jumping into a statement expression with a computed
237 @code{goto} (@pxref{Labels as Values}) has undefined behavior.
238 Jumping out of a statement expression is permitted, but if the
239 statement expression is part of a larger expression then it is
240 unspecified which other subexpressions of that expression have been
241 evaluated except where the language definition requires certain
242 subexpressions to be evaluated before or after the statement
243 expression.  A @code{break} or @code{continue} statement inside of
244 a statement expression used in @code{while}, @code{do} or @code{for}
245 loop or @code{switch} statement condition
246 or @code{for} statement init or increment expressions jumps to an
247 outer loop or @code{switch} statement if any (otherwise it is an error),
248 rather than to the loop or @code{switch} statement in whose condition
249 or init or increment expression it appears.
250 In any case, as with a function call, the evaluation of a
251 statement expression is not interleaved with the evaluation of other
252 parts of the containing expression.  For example,
254 @smallexample
255   foo (), ((@{ bar1 (); goto a; 0; @}) + bar2 ()), baz();
256 @end smallexample
258 @noindent
259 calls @code{foo} and @code{bar1} and does not call @code{baz} but
260 may or may not call @code{bar2}.  If @code{bar2} is called, it is
261 called after @code{foo} and before @code{bar1}.
263 @node Local Labels
264 @section Locally Declared Labels
265 @cindex local labels
266 @cindex macros, local labels
268 GCC allows you to declare @dfn{local labels} in any nested block
269 scope.  A local label is just like an ordinary label, but you can
270 only reference it (with a @code{goto} statement, or by taking its
271 address) within the block in which it is declared.
273 A local label declaration looks like this:
275 @smallexample
276 __label__ @var{label};
277 @end smallexample
279 @noindent
282 @smallexample
283 __label__ @var{label1}, @var{label2}, /* @r{@dots{}} */;
284 @end smallexample
286 Local label declarations must come at the beginning of the block,
287 before any ordinary declarations or statements.
289 The label declaration defines the label @emph{name}, but does not define
290 the label itself.  You must do this in the usual way, with
291 @code{@var{label}:}, within the statements of the statement expression.
293 The local label feature is useful for complex macros.  If a macro
294 contains nested loops, a @code{goto} can be useful for breaking out of
295 them.  However, an ordinary label whose scope is the whole function
296 cannot be used: if the macro can be expanded several times in one
297 function, the label is multiply defined in that function.  A
298 local label avoids this problem.  For example:
300 @smallexample
301 #define SEARCH(value, array, target)              \
302 do @{                                              \
303   __label__ found;                                \
304   typeof (target) _SEARCH_target = (target);      \
305   typeof (*(array)) *_SEARCH_array = (array);     \
306   int i, j;                                       \
307   int value;                                      \
308   for (i = 0; i < max; i++)                       \
309     for (j = 0; j < max; j++)                     \
310       if (_SEARCH_array[i][j] == _SEARCH_target)  \
311         @{ (value) = i; goto found; @}              \
312   (value) = -1;                                   \
313  found:;                                          \
314 @} while (0)
315 @end smallexample
317 This could also be written using a statement expression:
319 @smallexample
320 #define SEARCH(array, target)                     \
321 (@{                                                \
322   __label__ found;                                \
323   typeof (target) _SEARCH_target = (target);      \
324   typeof (*(array)) *_SEARCH_array = (array);     \
325   int i, j;                                       \
326   int value;                                      \
327   for (i = 0; i < max; i++)                       \
328     for (j = 0; j < max; j++)                     \
329       if (_SEARCH_array[i][j] == _SEARCH_target)  \
330         @{ value = i; goto found; @}                \
331   value = -1;                                     \
332  found:                                           \
333   value;                                          \
335 @end smallexample
337 Local label declarations also make the labels they declare visible to
338 nested functions, if there are any.  @xref{Nested Functions}, for details.
340 @node Labels as Values
341 @section Labels as Values
342 @cindex labels as values
343 @cindex computed gotos
344 @cindex goto with computed label
345 @cindex address of a label
347 You can get the address of a label defined in the current function
348 (or a containing function) with the unary operator @samp{&&}.  The
349 value has type @code{void *}.  This value is a constant and can be used
350 wherever a constant of that type is valid.  For example:
352 @smallexample
353 void *ptr;
354 /* @r{@dots{}} */
355 ptr = &&foo;
356 @end smallexample
358 To use these values, you need to be able to jump to one.  This is done
359 with the computed goto statement@footnote{The analogous feature in
360 Fortran is called an assigned goto, but that name seems inappropriate in
361 C, where one can do more than simply store label addresses in label
362 variables.}, @code{goto *@var{exp};}.  For example,
364 @smallexample
365 goto *ptr;
366 @end smallexample
368 @noindent
369 Any expression of type @code{void *} is allowed.
371 One way of using these constants is in initializing a static array that
372 serves as a jump table:
374 @smallexample
375 static void *array[] = @{ &&foo, &&bar, &&hack @};
376 @end smallexample
378 @noindent
379 Then you can select a label with indexing, like this:
381 @smallexample
382 goto *array[i];
383 @end smallexample
385 @noindent
386 Note that this does not check whether the subscript is in bounds---array
387 indexing in C never does that.
389 Such an array of label values serves a purpose much like that of the
390 @code{switch} statement.  The @code{switch} statement is cleaner, so
391 use that rather than an array unless the problem does not fit a
392 @code{switch} statement very well.
394 Another use of label values is in an interpreter for threaded code.
395 The labels within the interpreter function can be stored in the
396 threaded code for super-fast dispatching.
398 You may not use this mechanism to jump to code in a different function.
399 If you do that, totally unpredictable things happen.  The best way to
400 avoid this is to store the label address only in automatic variables and
401 never pass it as an argument.
403 An alternate way to write the above example is
405 @smallexample
406 static const int array[] = @{ &&foo - &&foo, &&bar - &&foo,
407                              &&hack - &&foo @};
408 goto *(&&foo + array[i]);
409 @end smallexample
411 @noindent
412 This is more friendly to code living in shared libraries, as it reduces
413 the number of dynamic relocations that are needed, and by consequence,
414 allows the data to be read-only.
415 This alternative with label differences is not supported for the AVR target,
416 please use the first approach for AVR programs.
418 The @code{&&foo} expressions for the same label might have different
419 values if the containing function is inlined or cloned.  If a program
420 relies on them being always the same,
421 @code{__attribute__((__noinline__,__noclone__))} should be used to
422 prevent inlining and cloning.  If @code{&&foo} is used in a static
423 variable initializer, inlining and cloning is forbidden.
425 Unlike a normal goto, in GNU C++ a computed goto will not call
426 destructors for objects that go out of scope.
428 @node Nested Functions
429 @section Nested Functions
430 @cindex nested functions
431 @cindex downward funargs
432 @cindex thunks
434 A @dfn{nested function} is a function defined inside another function.
435 Nested functions are supported as an extension in GNU C, but are not
436 supported by GNU C++.
438 The nested function's name is local to the block where it is defined.
439 For example, here we define a nested function named @code{square}, and
440 call it twice:
442 @smallexample
443 @group
444 foo (double a, double b)
446   double square (double z) @{ return z * z; @}
448   return square (a) + square (b);
450 @end group
451 @end smallexample
453 The nested function can access all the variables of the containing
454 function that are visible at the point of its definition.  This is
455 called @dfn{lexical scoping}.  For example, here we show a nested
456 function which uses an inherited variable named @code{offset}:
458 @smallexample
459 @group
460 bar (int *array, int offset, int size)
462   int access (int *array, int index)
463     @{ return array[index + offset]; @}
464   int i;
465   /* @r{@dots{}} */
466   for (i = 0; i < size; i++)
467     /* @r{@dots{}} */ access (array, i) /* @r{@dots{}} */
469 @end group
470 @end smallexample
472 Nested function definitions are permitted within functions in the places
473 where variable definitions are allowed; that is, in any block, mixed
474 with the other declarations and statements in the block.
476 It is possible to call the nested function from outside the scope of its
477 name by storing its address or passing the address to another function:
479 @smallexample
480 hack (int *array, int size)
482   void store (int index, int value)
483     @{ array[index] = value; @}
485   intermediate (store, size);
487 @end smallexample
489 Here, the function @code{intermediate} receives the address of
490 @code{store} as an argument.  If @code{intermediate} calls @code{store},
491 the arguments given to @code{store} are used to store into @code{array}.
492 But this technique works only so long as the containing function
493 (@code{hack}, in this example) does not exit.
495 If you try to call the nested function through its address after the
496 containing function exits, all hell breaks loose.  If you try
497 to call it after a containing scope level exits, and if it refers
498 to some of the variables that are no longer in scope, you may be lucky,
499 but it's not wise to take the risk.  If, however, the nested function
500 does not refer to anything that has gone out of scope, you should be
501 safe.
503 GCC implements taking the address of a nested function using a technique
504 called @dfn{trampolines}.  This technique was described in
505 @cite{Lexical Closures for C++} (Thomas M. Breuel, USENIX
506 C++ Conference Proceedings, October 17-21, 1988).
508 A nested function can jump to a label inherited from a containing
509 function, provided the label is explicitly declared in the containing
510 function (@pxref{Local Labels}).  Such a jump returns instantly to the
511 containing function, exiting the nested function that did the
512 @code{goto} and any intermediate functions as well.  Here is an example:
514 @smallexample
515 @group
516 bar (int *array, int offset, int size)
518   __label__ failure;
519   int access (int *array, int index)
520     @{
521       if (index > size)
522         goto failure;
523       return array[index + offset];
524     @}
525   int i;
526   /* @r{@dots{}} */
527   for (i = 0; i < size; i++)
528     /* @r{@dots{}} */ access (array, i) /* @r{@dots{}} */
529   /* @r{@dots{}} */
530   return 0;
532  /* @r{Control comes here from @code{access}
533     if it detects an error.}  */
534  failure:
535   return -1;
537 @end group
538 @end smallexample
540 A nested function always has no linkage.  Declaring one with
541 @code{extern} or @code{static} is erroneous.  If you need to declare the nested function
542 before its definition, use @code{auto} (which is otherwise meaningless
543 for function declarations).
545 @smallexample
546 bar (int *array, int offset, int size)
548   __label__ failure;
549   auto int access (int *, int);
550   /* @r{@dots{}} */
551   int access (int *array, int index)
552     @{
553       if (index > size)
554         goto failure;
555       return array[index + offset];
556     @}
557   /* @r{@dots{}} */
559 @end smallexample
561 @node Nonlocal Gotos
562 @section Nonlocal Gotos
563 @cindex nonlocal gotos
565 GCC provides the built-in functions @code{__builtin_setjmp} and
566 @code{__builtin_longjmp} which are similar to, but not interchangeable
567 with, the C library functions @code{setjmp} and @code{longjmp}.  
568 The built-in versions are used internally by GCC's libraries
569 to implement exception handling on some targets.  You should use the 
570 standard C library functions declared in @code{<setjmp.h>} in user code
571 instead of the builtins.
573 The built-in versions of these functions use GCC's normal
574 mechanisms to save and restore registers using the stack on function
575 entry and exit.  The jump buffer argument @var{buf} holds only the
576 information needed to restore the stack frame, rather than the entire 
577 set of saved register values.  
579 An important caveat is that GCC arranges to save and restore only
580 those registers known to the specific architecture variant being
581 compiled for.  This can make @code{__builtin_setjmp} and
582 @code{__builtin_longjmp} more efficient than their library
583 counterparts in some cases, but it can also cause incorrect and
584 mysterious behavior when mixing with code that uses the full register
585 set.
587 You should declare the jump buffer argument @var{buf} to the
588 built-in functions as:
590 @smallexample
591 #include <stdint.h>
592 intptr_t @var{buf}[5];
593 @end smallexample
595 @defbuiltin{{int} __builtin_setjmp (intptr_t *@var{buf})}
596 This function saves the current stack context in @var{buf}.  
597 @code{__builtin_setjmp} returns 0 when returning directly,
598 and 1 when returning from @code{__builtin_longjmp} using the same
599 @var{buf}.
600 @enddefbuiltin
602 @defbuiltin{{void} __builtin_longjmp (intptr_t *@var{buf}, int @var{val})}
603 This function restores the stack context in @var{buf}, 
604 saved by a previous call to @code{__builtin_setjmp}.  After
605 @code{__builtin_longjmp} is finished, the program resumes execution as
606 if the matching @code{__builtin_setjmp} returns the value @var{val},
607 which must be 1.
609 Because @code{__builtin_longjmp} depends on the function return
610 mechanism to restore the stack context, it cannot be called
611 from the same function calling @code{__builtin_setjmp} to
612 initialize @var{buf}.  It can only be called from a function called
613 (directly or indirectly) from the function calling @code{__builtin_setjmp}.
614 @enddefbuiltin
616 @node Constructing Calls
617 @section Constructing Function Calls
618 @cindex constructing calls
619 @cindex forwarding calls
621 Using the built-in functions described below, you can record
622 the arguments a function received, and call another function
623 with the same arguments, without knowing the number or types
624 of the arguments.
626 You can also record the return value of that function call,
627 and later return that value, without knowing what data type
628 the function tried to return (as long as your caller expects
629 that data type).
631 However, these built-in functions may interact badly with some
632 sophisticated features or other extensions of the language.  It
633 is, therefore, not recommended to use them outside very simple
634 functions acting as mere forwarders for their arguments.
636 @defbuiltin{{void *} __builtin_apply_args ()}
637 This built-in function returns a pointer to data
638 describing how to perform a call with the same arguments as are passed
639 to the current function.
641 The function saves the arg pointer register, structure value address,
642 and all registers that might be used to pass arguments to a function
643 into a block of memory allocated on the stack.  Then it returns the
644 address of that block.
645 @enddefbuiltin
647 @defbuiltin{{void *} __builtin_apply (void (*@var{function})(), void *@var{arguments}, size_t @var{size})}
648 This built-in function invokes @var{function}
649 with a copy of the parameters described by @var{arguments}
650 and @var{size}.
652 The value of @var{arguments} should be the value returned by
653 @code{__builtin_apply_args}.  The argument @var{size} specifies the size
654 of the stack argument data, in bytes.
656 This function returns a pointer to data describing
657 how to return whatever value is returned by @var{function}.  The data
658 is saved in a block of memory allocated on the stack.
660 It is not always simple to compute the proper value for @var{size}.  The
661 value is used by @code{__builtin_apply} to compute the amount of data
662 that should be pushed on the stack and copied from the incoming argument
663 area.
664 @enddefbuiltin
666 @defbuiltin{{void} __builtin_return (void *@var{result})}
667 This built-in function returns the value described by @var{result} from
668 the containing function.  You should specify, for @var{result}, a value
669 returned by @code{__builtin_apply}.
670 @enddefbuiltin
672 @defbuiltin{{} __builtin_va_arg_pack ()}
673 This built-in function represents all anonymous arguments of an inline
674 function.  It can be used only in inline functions that are always
675 inlined, never compiled as a separate function, such as those using
676 @code{__attribute__ ((__always_inline__))} or
677 @code{__attribute__ ((__gnu_inline__))} extern inline functions.
678 It must be only passed as last argument to some other function
679 with variable arguments.  This is useful for writing small wrapper
680 inlines for variable argument functions, when using preprocessor
681 macros is undesirable.  For example:
682 @smallexample
683 extern int myprintf (FILE *f, const char *format, ...);
684 extern inline __attribute__ ((__gnu_inline__)) int
685 myprintf (FILE *f, const char *format, ...)
687   int r = fprintf (f, "myprintf: ");
688   if (r < 0)
689     return r;
690   int s = fprintf (f, format, __builtin_va_arg_pack ());
691   if (s < 0)
692     return s;
693   return r + s;
695 @end smallexample
696 @enddefbuiltin
698 @defbuiltin{int __builtin_va_arg_pack_len ()}
699 This built-in function returns the number of anonymous arguments of
700 an inline function.  It can be used only in inline functions that
701 are always inlined, never compiled as a separate function, such
702 as those using @code{__attribute__ ((__always_inline__))} or
703 @code{__attribute__ ((__gnu_inline__))} extern inline functions.
704 For example following does link- or run-time checking of open
705 arguments for optimized code:
706 @smallexample
707 #ifdef __OPTIMIZE__
708 extern inline __attribute__((__gnu_inline__)) int
709 myopen (const char *path, int oflag, ...)
711   if (__builtin_va_arg_pack_len () > 1)
712     warn_open_too_many_arguments ();
714   if (__builtin_constant_p (oflag))
715     @{
716       if ((oflag & O_CREAT) != 0 && __builtin_va_arg_pack_len () < 1)
717         @{
718           warn_open_missing_mode ();
719           return __open_2 (path, oflag);
720         @}
721       return open (path, oflag, __builtin_va_arg_pack ());
722     @}
724   if (__builtin_va_arg_pack_len () < 1)
725     return __open_2 (path, oflag);
727   return open (path, oflag, __builtin_va_arg_pack ());
729 #endif
730 @end smallexample
731 @enddefbuiltin
733 @node Typeof
734 @section Referring to a Type with @code{typeof}
735 @findex typeof
736 @findex sizeof
737 @cindex macros, types of arguments
739 Another way to refer to the type of an expression is with @code{typeof}.
740 The syntax of using of this keyword looks like @code{sizeof}, but the
741 construct acts semantically like a type name defined with @code{typedef}.
743 There are two ways of writing the argument to @code{typeof}: with an
744 expression or with a type.  Here is an example with an expression:
746 @smallexample
747 typeof (x[0](1))
748 @end smallexample
750 @noindent
751 This assumes that @code{x} is an array of pointers to functions;
752 the type described is that of the values of the functions.
754 Here is an example with a typename as the argument:
756 @smallexample
757 typeof (int *)
758 @end smallexample
760 @noindent
761 Here the type described is that of pointers to @code{int}.
763 If you are writing a header file that must work when included in ISO C
764 programs, write @code{__typeof__} instead of @code{typeof}.
765 @xref{Alternate Keywords}.
767 A @code{typeof} construct can be used anywhere a typedef name can be
768 used.  For example, you can use it in a declaration, in a cast, or inside
769 of @code{sizeof} or @code{typeof}.
771 The operand of @code{typeof} is evaluated for its side effects if and
772 only if it is an expression of variably modified type or the name of
773 such a type.
775 @code{typeof} is often useful in conjunction with
776 statement expressions (@pxref{Statement Exprs}).
777 Here is how the two together can
778 be used to define a safe ``maximum'' macro which operates on any
779 arithmetic type and evaluates each of its arguments exactly once:
781 @smallexample
782 #define max(a,b) \
783   (@{ typeof (a) _a = (a); \
784       typeof (b) _b = (b); \
785     _a > _b ? _a : _b; @})
786 @end smallexample
788 @cindex underscores in variables in macros
789 @cindex @samp{_} in variables in macros
790 @cindex local variables in macros
791 @cindex variables, local, in macros
792 @cindex macros, local variables in
794 The reason for using names that start with underscores for the local
795 variables is to avoid conflicts with variable names that occur within the
796 expressions that are substituted for @code{a} and @code{b}.  Eventually we
797 hope to design a new form of declaration syntax that allows you to declare
798 variables whose scopes start only after their initializers; this will be a
799 more reliable way to prevent such conflicts.
801 @noindent
802 Some more examples of the use of @code{typeof}:
804 @itemize @bullet
805 @item
806 This declares @code{y} with the type of what @code{x} points to.
808 @smallexample
809 typeof (*x) y;
810 @end smallexample
812 @item
813 This declares @code{y} as an array of such values.
815 @smallexample
816 typeof (*x) y[4];
817 @end smallexample
819 @item
820 This declares @code{y} as an array of pointers to characters:
822 @smallexample
823 typeof (typeof (char *)[4]) y;
824 @end smallexample
826 @noindent
827 It is equivalent to the following traditional C declaration:
829 @smallexample
830 char *y[4];
831 @end smallexample
833 To see the meaning of the declaration using @code{typeof}, and why it
834 might be a useful way to write, rewrite it with these macros:
836 @smallexample
837 #define pointer(T)  typeof(T *)
838 #define array(T, N) typeof(T [N])
839 @end smallexample
841 @noindent
842 Now the declaration can be rewritten this way:
844 @smallexample
845 array (pointer (char), 4) y;
846 @end smallexample
848 @noindent
849 Thus, @code{array (pointer (char), 4)} is the type of arrays of 4
850 pointers to @code{char}.
851 @end itemize
853 The ISO C23 operator @code{typeof_unqual} is available in ISO C23 mode
854 and its result is the non-atomic unqualified version of what @code{typeof}
855 operator returns.  Alternate spelling @code{__typeof_unqual__} is
856 available in all C modes and provides non-atomic unqualified version of
857 what @code{__typeof__} operator returns.
858 @xref{Alternate Keywords}.
860 @cindex @code{__auto_type} in GNU C
861 In GNU C, but not GNU C++, you may also declare the type of a variable
862 as @code{__auto_type}.  In that case, the declaration must declare
863 only one variable, whose declarator must just be an identifier, the
864 declaration must be initialized, and the type of the variable is
865 determined by the initializer; the name of the variable is not in
866 scope until after the initializer.  (In C++, you should use C++11
867 @code{auto} for this purpose.)  Using @code{__auto_type}, the
868 ``maximum'' macro above could be written as:
870 @smallexample
871 #define max(a,b) \
872   (@{ __auto_type _a = (a); \
873       __auto_type _b = (b); \
874     _a > _b ? _a : _b; @})
875 @end smallexample
877 Using @code{__auto_type} instead of @code{typeof} has two advantages:
879 @itemize @bullet
880 @item Each argument to the macro appears only once in the expansion of
881 the macro.  This prevents the size of the macro expansion growing
882 exponentially when calls to such macros are nested inside arguments of
883 such macros.
885 @item If the argument to the macro has variably modified type, it is
886 evaluated only once when using @code{__auto_type}, but twice if
887 @code{typeof} is used.
888 @end itemize
890 @node Conditionals
891 @section Conditionals with Omitted Operands
892 @cindex conditional expressions, extensions
893 @cindex omitted middle-operands
894 @cindex middle-operands, omitted
895 @cindex extensions, @code{?:}
896 @cindex @code{?:} extensions
898 The middle operand in a conditional expression may be omitted.  Then
899 if the first operand is nonzero, its value is the value of the conditional
900 expression.
902 Therefore, the expression
904 @smallexample
905 x ? : y
906 @end smallexample
908 @noindent
909 has the value of @code{x} if that is nonzero; otherwise, the value of
910 @code{y}.
912 This example is perfectly equivalent to
914 @smallexample
915 x ? x : y
916 @end smallexample
918 @cindex side effect in @code{?:}
919 @cindex @code{?:} side effect
920 @noindent
921 In this simple case, the ability to omit the middle operand is not
922 especially useful.  When it becomes useful is when the first operand does,
923 or may (if it is a macro argument), contain a side effect.  Then repeating
924 the operand in the middle would perform the side effect twice.  Omitting
925 the middle operand uses the value already computed without the undesirable
926 effects of recomputing it.
928 @node __int128
929 @section 128-bit Integers
930 @cindex @code{__int128} data types
932 As an extension the integer scalar type @code{__int128} is supported for
933 targets which have an integer mode wide enough to hold 128 bits.
934 Simply write @code{__int128} for a signed 128-bit integer, or
935 @code{unsigned __int128} for an unsigned 128-bit integer.  There is no
936 support in GCC for expressing an integer constant of type @code{__int128}
937 for targets with @code{long long} integer less than 128 bits wide.
939 @node Long Long
940 @section Double-Word Integers
941 @cindex @code{long long} data types
942 @cindex double-word arithmetic
943 @cindex multiprecision arithmetic
944 @cindex @code{LL} integer suffix
945 @cindex @code{ULL} integer suffix
947 ISO C99 and ISO C++11 support data types for integers that are at least
948 64 bits wide, and as an extension GCC supports them in C90 and C++98 modes.
949 Simply write @code{long long int} for a signed integer, or
950 @code{unsigned long long int} for an unsigned integer.  To make an
951 integer constant of type @code{long long int}, add the suffix @samp{LL}
952 to the integer.  To make an integer constant of type @code{unsigned long
953 long int}, add the suffix @samp{ULL} to the integer.
955 You can use these types in arithmetic like any other integer types.
956 Addition, subtraction, and bitwise boolean operations on these types
957 are open-coded on all types of machines.  Multiplication is open-coded
958 if the machine supports a fullword-to-doubleword widening multiply
959 instruction.  Division and shifts are open-coded only on machines that
960 provide special support.  The operations that are not open-coded use
961 special library routines that come with GCC@.
963 There may be pitfalls when you use @code{long long} types for function
964 arguments without function prototypes.  If a function
965 expects type @code{int} for its argument, and you pass a value of type
966 @code{long long int}, confusion results because the caller and the
967 subroutine disagree about the number of bytes for the argument.
968 Likewise, if the function expects @code{long long int} and you pass
969 @code{int}.  The best way to avoid such problems is to use prototypes.
971 @node Complex
972 @section Complex Numbers
973 @cindex complex numbers
974 @cindex @code{_Complex} keyword
975 @cindex @code{__complex__} keyword
977 ISO C99 supports complex floating data types, and as an extension GCC
978 supports them in C90 mode and in C++.  GCC also supports complex integer data
979 types which are not part of ISO C99.  You can declare complex types
980 using the keyword @code{_Complex}.  As an extension, the older GNU
981 keyword @code{__complex__} is also supported.
983 For example, @samp{_Complex double x;} declares @code{x} as a
984 variable whose real part and imaginary part are both of type
985 @code{double}.  @samp{_Complex short int y;} declares @code{y} to
986 have real and imaginary parts of type @code{short int}; this is not
987 likely to be useful, but it shows that the set of complex types is
988 complete.
990 To write a constant with a complex data type, use the suffix @samp{i} or
991 @samp{j} (either one; they are equivalent).  For example, @code{2.5fi}
992 has type @code{_Complex float} and @code{3i} has type
993 @code{_Complex int}.  Such a constant always has a pure imaginary
994 value, but you can form any complex value you like by adding one to a
995 real constant.  This is a GNU extension; if you have an ISO C99
996 conforming C library (such as the GNU C Library), and want to construct complex
997 constants of floating type, you should include @code{<complex.h>} and
998 use the macros @code{I} or @code{_Complex_I} instead.
1000 The ISO C++14 library also defines the @samp{i} suffix, so C++14 code
1001 that includes the @samp{<complex>} header cannot use @samp{i} for the
1002 GNU extension.  The @samp{j} suffix still has the GNU meaning.
1004 GCC can handle both implicit and explicit casts between the @code{_Complex}
1005 types and other @code{_Complex} types as casting both the real and imaginary
1006 parts to the scalar type.
1007 GCC can handle implicit and explicit casts from a scalar type to a @code{_Complex}
1008 type and where the imaginary part will be considered zero.
1009 The C front-end can handle implicit and explicit casts from a @code{_Complex} type
1010 to a scalar type where the imaginary part will be ignored. In C++ code, this cast
1011 is considered illformed and G++ will error out.
1013 GCC provides a built-in function @code{__builtin_complex} will can be used to
1014 construct a complex value.
1016 @cindex @code{__real__} keyword
1017 @cindex @code{__imag__} keyword
1019 GCC has a few extensions which can be used to extract the real
1020 and the imaginary part of the complex-valued expression. Note
1021 these expressions are lvalues if the @var{exp} is an lvalue.
1022 These expressions operands have the type of a complex type
1023 which might get prompoted to a complex type from a scalar type.
1024 E.g. @code{__real__ (int)@var{x}} is the same as casting to
1025 @code{_Complex int} before @code{__real__} is done.
1027 @multitable @columnfractions .4 .6
1028 @headitem Expression @tab Description
1029 @item @code{__real__ @var{exp}}
1030 @tab Extract the real part of @var{exp}.
1031 @item @code{__imag__ @var{exp}}
1032 @tab Extract the imaginary part of @var{exp}.
1033 @end multitable
1035 For values of floating point, you should use the ISO C99
1036 functions, declared in @code{<complex.h>} and also provided as
1037 built-in functions by GCC@.
1039 @multitable @columnfractions .4 .2 .2 .2
1040 @headitem Expression @tab float @tab double @tab long double
1041 @item @code{__real__ @var{exp}}
1042 @tab @code{crealf} @tab @code{creal} @tab @code{creall}
1043 @item @code{__imag__ @var{exp}}
1044 @tab @code{cimagf} @tab @code{cimag} @tab @code{cimagl}
1045 @end multitable
1047 @cindex complex conjugation
1048 The operator @samp{~} performs complex conjugation when used on a value
1049 with a complex type.  This is a GNU extension; for values of
1050 floating type, you should use the ISO C99 functions @code{conjf},
1051 @code{conj} and @code{conjl}, declared in @code{<complex.h>} and also
1052 provided as built-in functions by GCC@. Note unlike the @code{__real__}
1053 and @code{__imag__} operators, this operator will not do an implicit cast
1054 to the complex type because the @samp{~} is already a normal operator.
1056 GCC can allocate complex automatic variables in a noncontiguous
1057 fashion; it's even possible for the real part to be in a register while
1058 the imaginary part is on the stack (or vice versa).  Only the DWARF
1059 debug info format can represent this, so use of DWARF is recommended.
1060 If you are using the stabs debug info format, GCC describes a noncontiguous
1061 complex variable as if it were two separate variables of noncomplex type.
1062 If the variable's actual name is @code{foo}, the two fictitious
1063 variables are named @code{foo$real} and @code{foo$imag}.  You can
1064 examine and set these two fictitious variables with your debugger.
1066 @defbuiltin{@var{type} __builtin_complex (@var{real}, @var{imag})}
1068 The built-in function @code{__builtin_complex} is provided for use in
1069 implementing the ISO C11 macros @code{CMPLXF}, @code{CMPLX} and
1070 @code{CMPLXL}.  @var{real} and @var{imag} must have the same type, a
1071 real binary floating-point type, and the result has the corresponding
1072 complex type with real and imaginary parts @var{real} and @var{imag}.
1073 Unlike @samp{@var{real} + I * @var{imag}}, this works even when
1074 infinities, NaNs and negative zeros are involved.
1076 @enddefbuiltin
1078 @node Floating Types
1079 @section Additional Floating Types
1080 @cindex additional floating types
1081 @cindex @code{_Float@var{n}} data types
1082 @cindex @code{_Float@var{n}x} data types
1083 @cindex @code{__float80} data type
1084 @cindex @code{__float128} data type
1085 @cindex @code{__ibm128} data type
1086 @cindex @code{w} floating point suffix
1087 @cindex @code{q} floating point suffix
1088 @cindex @code{W} floating point suffix
1089 @cindex @code{Q} floating point suffix
1091 ISO/IEC TS 18661-3:2015 defines C support for additional floating
1092 types @code{_Float@var{n}} and @code{_Float@var{n}x}, and GCC supports
1093 these type names; the set of types supported depends on the target
1094 architecture.
1095 Constants with these types use suffixes @code{f@var{n}} or
1096 @code{F@var{n}} and @code{f@var{n}x} or @code{F@var{n}x}.  These type
1097 names can be used together with @code{_Complex} to declare complex
1098 types.
1100 As an extension, GNU C and GNU C++ support additional floating
1101 types, which are not supported by all targets.
1102 @itemize @bullet
1103 @item @code{__float128} is available on i386, x86_64, IA-64, LoongArch
1104 and hppa HP-UX, as well as on PowerPC GNU/Linux targets that enable
1105 the vector scalar (VSX) instruction set.  @code{__float128} supports
1106 the 128-bit floating type.  On i386, x86_64, PowerPC, LoongArch and IA-64,
1107 other than HP-UX, @code{__float128} is an alias for @code{_Float128}.
1108 On hppa and IA-64 HP-UX, @code{__float128} is an alias for @code{long
1109 double}.
1111 @item @code{__float80} is available on the i386, x86_64, and IA-64
1112 targets, and supports the 80-bit (@code{XFmode}) floating type.  It is
1113 an alias for the type name @code{_Float64x} on these targets.
1115 @item @code{__ibm128} is available on PowerPC targets, and provides
1116 access to the IBM extended double format which is the current format
1117 used for @code{long double}.  When @code{long double} transitions to
1118 @code{__float128} on PowerPC in the future, @code{__ibm128} will remain
1119 for use in conversions between the two types.
1120 @end itemize
1122 Support for these additional types includes the arithmetic operators:
1123 add, subtract, multiply, divide; unary arithmetic operators;
1124 relational operators; equality operators; and conversions to and from
1125 integer and other floating types.  Use a suffix @samp{w} or @samp{W}
1126 in a literal constant of type @code{__float80} or type
1127 @code{__ibm128}.  Use a suffix @samp{q} or @samp{Q} for @code{__float128}.
1129 In order to use @code{_Float128}, @code{__float128}, and @code{__ibm128}
1130 on PowerPC Linux systems, you must use the @option{-mfloat128} option. It is
1131 expected in future versions of GCC that @code{_Float128} and @code{__float128}
1132 will be enabled automatically.
1134 The @code{_Float128} type is supported on all systems where
1135 @code{__float128} is supported or where @code{long double} has the
1136 IEEE binary128 format.  The @code{_Float64x} type is supported on all
1137 systems where @code{__float128} is supported.  The @code{_Float32}
1138 type is supported on all systems supporting IEEE binary32; the
1139 @code{_Float64} and @code{_Float32x} types are supported on all systems
1140 supporting IEEE binary64.  The @code{_Float16} type is supported on AArch64
1141 systems by default, on ARM systems when the IEEE format for 16-bit
1142 floating-point types is selected with @option{-mfp16-format=ieee} and,
1143 for both C and C++, on x86 systems with SSE2 enabled. GCC does not currently
1144 support @code{_Float128x} on any systems.
1146 On the i386, x86_64, IA-64, and HP-UX targets, you can declare complex
1147 types using the corresponding internal complex type, @code{XCmode} for
1148 @code{__float80} type and @code{TCmode} for @code{__float128} type:
1150 @smallexample
1151 typedef _Complex float __attribute__((mode(TC))) _Complex128;
1152 typedef _Complex float __attribute__((mode(XC))) _Complex80;
1153 @end smallexample
1155 On the PowerPC Linux VSX targets, you can declare complex types using
1156 the corresponding internal complex type, @code{KCmode} for
1157 @code{__float128} type and @code{ICmode} for @code{__ibm128} type:
1159 @smallexample
1160 typedef _Complex float __attribute__((mode(KC))) _Complex_float128;
1161 typedef _Complex float __attribute__((mode(IC))) _Complex_ibm128;
1162 @end smallexample
1164 @node Half-Precision
1165 @section Half-Precision Floating Point
1166 @cindex half-precision floating point
1167 @cindex @code{__fp16} data type
1168 @cindex @code{__Float16} data type
1170 On ARM and AArch64 targets, GCC supports half-precision (16-bit) floating
1171 point via the @code{__fp16} type defined in the ARM C Language Extensions.
1172 On ARM systems, you must enable this type explicitly with the
1173 @option{-mfp16-format} command-line option in order to use it.
1174 On x86 targets with SSE2 enabled, GCC supports half-precision (16-bit)
1175 floating point via the @code{_Float16} type. For C++, x86 provides a builtin
1176 type named @code{_Float16} which contains same data format as C.
1178 ARM targets support two incompatible representations for half-precision
1179 floating-point values.  You must choose one of the representations and
1180 use it consistently in your program.
1182 Specifying @option{-mfp16-format=ieee} selects the IEEE 754-2008 format.
1183 This format can represent normalized values in the range of @math{2^{-14}} to 65504.
1184 There are 11 bits of significand precision, approximately 3
1185 decimal digits.
1187 Specifying @option{-mfp16-format=alternative} selects the ARM
1188 alternative format.  This representation is similar to the IEEE
1189 format, but does not support infinities or NaNs.  Instead, the range
1190 of exponents is extended, so that this format can represent normalized
1191 values in the range of @math{2^{-14}} to 131008.
1193 The GCC port for AArch64 only supports the IEEE 754-2008 format, and does
1194 not require use of the @option{-mfp16-format} command-line option.
1196 The @code{__fp16} type may only be used as an argument to intrinsics defined
1197 in @code{<arm_fp16.h>}, or as a storage format.  For purposes of
1198 arithmetic and other operations, @code{__fp16} values in C or C++
1199 expressions are automatically promoted to @code{float}.
1201 The ARM target provides hardware support for conversions between
1202 @code{__fp16} and @code{float} values
1203 as an extension to VFP and NEON (Advanced SIMD), and from ARMv8-A provides
1204 hardware support for conversions between @code{__fp16} and @code{double}
1205 values.  GCC generates code using these hardware instructions if you
1206 compile with options to select an FPU that provides them;
1207 for example, @option{-mfpu=neon-fp16 -mfloat-abi=softfp},
1208 in addition to the @option{-mfp16-format} option to select
1209 a half-precision format.
1211 Language-level support for the @code{__fp16} data type is
1212 independent of whether GCC generates code using hardware floating-point
1213 instructions.  In cases where hardware support is not specified, GCC
1214 implements conversions between @code{__fp16} and other types as library
1215 calls.
1217 It is recommended that portable code use the @code{_Float16} type defined
1218 by ISO/IEC TS 18661-3:2015.  @xref{Floating Types}.
1220 On x86 targets with SSE2 enabled, without @option{-mavx512fp16},
1221 all operations will be emulated by software emulation and the @code{float}
1222 instructions. The default behavior for @code{FLT_EVAL_METHOD} is to keep the
1223 intermediate result of the operation as 32-bit precision. This may lead to
1224 inconsistent behavior between software emulation and AVX512-FP16 instructions.
1225 Using @option{-fexcess-precision=16} will force round back after each operation.
1227 Using @option{-mavx512fp16} will generate AVX512-FP16 instructions instead of
1228 software emulation. The default behavior of @code{FLT_EVAL_METHOD} is to round
1229 after each operation. The same is true with @option{-fexcess-precision=standard}
1230 and @option{-mfpmath=sse}. If there is no @option{-mfpmath=sse},
1231 @option{-fexcess-precision=standard} alone does the same thing as before,
1232 It is useful for code that does not have @code{_Float16} and runs on the x87
1233 FPU.
1235 @node Decimal Float
1236 @section Decimal Floating Types
1237 @cindex decimal floating types
1238 @cindex @code{_Decimal32} data type
1239 @cindex @code{_Decimal64} data type
1240 @cindex @code{_Decimal128} data type
1241 @cindex @code{df} integer suffix
1242 @cindex @code{dd} integer suffix
1243 @cindex @code{dl} integer suffix
1244 @cindex @code{DF} integer suffix
1245 @cindex @code{DD} integer suffix
1246 @cindex @code{DL} integer suffix
1248 As an extension, GNU C supports decimal floating types as
1249 defined in the N1312 draft of ISO/IEC WDTR24732.  Support for decimal
1250 floating types in GCC will evolve as the draft technical report changes.
1251 Calling conventions for any target might also change.  Not all targets
1252 support decimal floating types.
1254 The decimal floating types are @code{_Decimal32}, @code{_Decimal64}, and
1255 @code{_Decimal128}.  They use a radix of ten, unlike the floating types
1256 @code{float}, @code{double}, and @code{long double} whose radix is not
1257 specified by the C standard but is usually two.
1259 Support for decimal floating types includes the arithmetic operators
1260 add, subtract, multiply, divide; unary arithmetic operators;
1261 relational operators; equality operators; and conversions to and from
1262 integer and other floating types.  Use a suffix @samp{df} or
1263 @samp{DF} in a literal constant of type @code{_Decimal32}, @samp{dd}
1264 or @samp{DD} for @code{_Decimal64}, and @samp{dl} or @samp{DL} for
1265 @code{_Decimal128}.
1267 GCC support of decimal float as specified by the draft technical report
1268 is incomplete:
1270 @itemize @bullet
1271 @item
1272 When the value of a decimal floating type cannot be represented in the
1273 integer type to which it is being converted, the result is undefined
1274 rather than the result value specified by the draft technical report.
1276 @item
1277 GCC does not provide the C library functionality associated with
1278 @file{math.h}, @file{fenv.h}, @file{stdio.h}, @file{stdlib.h}, and
1279 @file{wchar.h}, which must come from a separate C library implementation.
1280 Because of this the GNU C compiler does not define macro
1281 @code{__STDC_DEC_FP__} to indicate that the implementation conforms to
1282 the technical report.
1283 @end itemize
1285 Types @code{_Decimal32}, @code{_Decimal64}, and @code{_Decimal128}
1286 are supported by the DWARF debug information format.
1288 @node Hex Floats
1289 @section Hex Floats
1290 @cindex hex floats
1292 ISO C99 and ISO C++17 support floating-point numbers written not only in
1293 the usual decimal notation, such as @code{1.55e1}, but also numbers such as
1294 @code{0x1.fp3} written in hexadecimal format.  As a GNU extension, GCC
1295 supports this in C90 mode (except in some cases when strictly
1296 conforming) and in C++98, C++11 and C++14 modes.  In that format the
1297 @samp{0x} hex introducer and the @samp{p} or @samp{P} exponent field are
1298 mandatory.  The exponent is a decimal number that indicates the power of
1299 2 by which the significant part is multiplied.  Thus @samp{0x1.f} is
1300 @tex
1301 $1 {15\over16}$,
1302 @end tex
1303 @ifnottex
1304 1 15/16,
1305 @end ifnottex
1306 @samp{p3} multiplies it by 8, and the value of @code{0x1.fp3}
1307 is the same as @code{1.55e1}.
1309 Unlike for floating-point numbers in the decimal notation the exponent
1310 is always required in the hexadecimal notation.  Otherwise the compiler
1311 would not be able to resolve the ambiguity of, e.g., @code{0x1.f}.  This
1312 could mean @code{1.0f} or @code{1.9375} since @samp{f} is also the
1313 extension for floating-point constants of type @code{float}.
1315 @node Fixed-Point
1316 @section Fixed-Point Types
1317 @cindex fixed-point types
1318 @cindex @code{_Fract} data type
1319 @cindex @code{_Accum} data type
1320 @cindex @code{_Sat} data type
1321 @cindex @code{hr} fixed-suffix
1322 @cindex @code{r} fixed-suffix
1323 @cindex @code{lr} fixed-suffix
1324 @cindex @code{llr} fixed-suffix
1325 @cindex @code{uhr} fixed-suffix
1326 @cindex @code{ur} fixed-suffix
1327 @cindex @code{ulr} fixed-suffix
1328 @cindex @code{ullr} fixed-suffix
1329 @cindex @code{hk} fixed-suffix
1330 @cindex @code{k} fixed-suffix
1331 @cindex @code{lk} fixed-suffix
1332 @cindex @code{llk} fixed-suffix
1333 @cindex @code{uhk} fixed-suffix
1334 @cindex @code{uk} fixed-suffix
1335 @cindex @code{ulk} fixed-suffix
1336 @cindex @code{ullk} fixed-suffix
1337 @cindex @code{HR} fixed-suffix
1338 @cindex @code{R} fixed-suffix
1339 @cindex @code{LR} fixed-suffix
1340 @cindex @code{LLR} fixed-suffix
1341 @cindex @code{UHR} fixed-suffix
1342 @cindex @code{UR} fixed-suffix
1343 @cindex @code{ULR} fixed-suffix
1344 @cindex @code{ULLR} fixed-suffix
1345 @cindex @code{HK} fixed-suffix
1346 @cindex @code{K} fixed-suffix
1347 @cindex @code{LK} fixed-suffix
1348 @cindex @code{LLK} fixed-suffix
1349 @cindex @code{UHK} fixed-suffix
1350 @cindex @code{UK} fixed-suffix
1351 @cindex @code{ULK} fixed-suffix
1352 @cindex @code{ULLK} fixed-suffix
1354 As an extension, GNU C supports fixed-point types as
1355 defined in the N1169 draft of ISO/IEC DTR 18037.  Support for fixed-point
1356 types in GCC will evolve as the draft technical report changes.
1357 Calling conventions for any target might also change.  Not all targets
1358 support fixed-point types.
1360 The fixed-point types are
1361 @code{short _Fract},
1362 @code{_Fract},
1363 @code{long _Fract},
1364 @code{long long _Fract},
1365 @code{unsigned short _Fract},
1366 @code{unsigned _Fract},
1367 @code{unsigned long _Fract},
1368 @code{unsigned long long _Fract},
1369 @code{_Sat short _Fract},
1370 @code{_Sat _Fract},
1371 @code{_Sat long _Fract},
1372 @code{_Sat long long _Fract},
1373 @code{_Sat unsigned short _Fract},
1374 @code{_Sat unsigned _Fract},
1375 @code{_Sat unsigned long _Fract},
1376 @code{_Sat unsigned long long _Fract},
1377 @code{short _Accum},
1378 @code{_Accum},
1379 @code{long _Accum},
1380 @code{long long _Accum},
1381 @code{unsigned short _Accum},
1382 @code{unsigned _Accum},
1383 @code{unsigned long _Accum},
1384 @code{unsigned long long _Accum},
1385 @code{_Sat short _Accum},
1386 @code{_Sat _Accum},
1387 @code{_Sat long _Accum},
1388 @code{_Sat long long _Accum},
1389 @code{_Sat unsigned short _Accum},
1390 @code{_Sat unsigned _Accum},
1391 @code{_Sat unsigned long _Accum},
1392 @code{_Sat unsigned long long _Accum}.
1394 Fixed-point data values contain fractional and optional integral parts.
1395 The format of fixed-point data varies and depends on the target machine.
1397 Support for fixed-point types includes:
1398 @itemize @bullet
1399 @item
1400 prefix and postfix increment and decrement operators (@code{++}, @code{--})
1401 @item
1402 unary arithmetic operators (@code{+}, @code{-}, @code{!})
1403 @item
1404 binary arithmetic operators (@code{+}, @code{-}, @code{*}, @code{/})
1405 @item
1406 binary shift operators (@code{<<}, @code{>>})
1407 @item
1408 relational operators (@code{<}, @code{<=}, @code{>=}, @code{>})
1409 @item
1410 equality operators (@code{==}, @code{!=})
1411 @item
1412 assignment operators (@code{+=}, @code{-=}, @code{*=}, @code{/=},
1413 @code{<<=}, @code{>>=})
1414 @item
1415 conversions to and from integer, floating-point, or fixed-point types
1416 @end itemize
1418 Use a suffix in a fixed-point literal constant:
1419 @itemize
1420 @item @samp{hr} or @samp{HR} for @code{short _Fract} and
1421 @code{_Sat short _Fract}
1422 @item @samp{r} or @samp{R} for @code{_Fract} and @code{_Sat _Fract}
1423 @item @samp{lr} or @samp{LR} for @code{long _Fract} and
1424 @code{_Sat long _Fract}
1425 @item @samp{llr} or @samp{LLR} for @code{long long _Fract} and
1426 @code{_Sat long long _Fract}
1427 @item @samp{uhr} or @samp{UHR} for @code{unsigned short _Fract} and
1428 @code{_Sat unsigned short _Fract}
1429 @item @samp{ur} or @samp{UR} for @code{unsigned _Fract} and
1430 @code{_Sat unsigned _Fract}
1431 @item @samp{ulr} or @samp{ULR} for @code{unsigned long _Fract} and
1432 @code{_Sat unsigned long _Fract}
1433 @item @samp{ullr} or @samp{ULLR} for @code{unsigned long long _Fract}
1434 and @code{_Sat unsigned long long _Fract}
1435 @item @samp{hk} or @samp{HK} for @code{short _Accum} and
1436 @code{_Sat short _Accum}
1437 @item @samp{k} or @samp{K} for @code{_Accum} and @code{_Sat _Accum}
1438 @item @samp{lk} or @samp{LK} for @code{long _Accum} and
1439 @code{_Sat long _Accum}
1440 @item @samp{llk} or @samp{LLK} for @code{long long _Accum} and
1441 @code{_Sat long long _Accum}
1442 @item @samp{uhk} or @samp{UHK} for @code{unsigned short _Accum} and
1443 @code{_Sat unsigned short _Accum}
1444 @item @samp{uk} or @samp{UK} for @code{unsigned _Accum} and
1445 @code{_Sat unsigned _Accum}
1446 @item @samp{ulk} or @samp{ULK} for @code{unsigned long _Accum} and
1447 @code{_Sat unsigned long _Accum}
1448 @item @samp{ullk} or @samp{ULLK} for @code{unsigned long long _Accum}
1449 and @code{_Sat unsigned long long _Accum}
1450 @end itemize
1452 GCC support of fixed-point types as specified by the draft technical report
1453 is incomplete:
1455 @itemize @bullet
1456 @item
1457 Pragmas to control overflow and rounding behaviors are not implemented.
1458 @end itemize
1460 Fixed-point types are supported by the DWARF debug information format.
1462 @node Named Address Spaces
1463 @section Named Address Spaces
1464 @cindex Named Address Spaces
1466 As an extension, GNU C supports named address spaces as
1467 defined in the N1275 draft of ISO/IEC DTR 18037.  Support for named
1468 address spaces in GCC will evolve as the draft technical report
1469 changes.  Calling conventions for any target might also change.  At
1470 present, only the AVR, M32C, PRU, RL78, and x86 targets support
1471 address spaces other than the generic address space.
1473 Address space identifiers may be used exactly like any other C type
1474 qualifier (e.g., @code{const} or @code{volatile}).  See the N1275
1475 document for more details.
1477 @anchor{AVR Named Address Spaces}
1478 @subsection AVR Named Address Spaces
1480 On the AVR target, there are several address spaces that can be used
1481 in order to put read-only data into the flash memory and access that
1482 data by means of the special instructions @code{LPM} or @code{ELPM}
1483 needed to read from flash.
1485 Devices belonging to @code{avrtiny} and @code{avrxmega3} can access
1486 flash memory by means of @code{LD*} instructions because the flash
1487 memory is mapped into the RAM address space.  There is @emph{no need}
1488 for language extensions like @code{__flash} or attribute
1489 @ref{AVR Variable Attributes,,@code{progmem}}.
1490 The default linker description files for these devices cater for that
1491 feature and @code{.rodata} stays in flash: The compiler just generates
1492 @code{LD*} instructions, and the linker script adds core specific
1493 offsets to all @code{.rodata} symbols: @code{0x4000} in the case of
1494 @code{avrtiny} and @code{0x8000} in the case of @code{avrxmega3}.
1495 See @ref{AVR Options} for a list of respective devices.
1497 For devices not in @code{avrtiny} or @code{avrxmega3},
1498 any data including read-only data is located in RAM (the generic
1499 address space) because flash memory is not visible in the RAM address
1500 space.  In order to locate read-only data in flash memory @emph{and}
1501 to generate the right instructions to access this data without
1502 using (inline) assembler code, special address spaces are needed.
1504 @table @code
1505 @cindex @code{__flash} AVR Named Address Spaces
1506 @item __flash
1507 The @code{__flash} qualifier locates data in the
1508 @code{.progmem.data} section. Data is read using the @code{LPM}
1509 instruction. Pointers to this address space are 16 bits wide.
1511 @cindex @code{__flash1} AVR Named Address Spaces
1512 @cindex @code{__flash2} AVR Named Address Spaces
1513 @cindex @code{__flash3} AVR Named Address Spaces
1514 @cindex @code{__flash4} AVR Named Address Spaces
1515 @cindex @code{__flash5} AVR Named Address Spaces
1516 @item __flash1
1517 @itemx __flash2
1518 @itemx __flash3
1519 @itemx __flash4
1520 @itemx __flash5
1521 These are 16-bit address spaces locating data in section
1522 @code{.progmem@var{N}.data} where @var{N} refers to
1523 address space @code{__flash@var{N}}.
1524 The compiler sets the @code{RAMPZ} segment register appropriately 
1525 before reading data by means of the @code{ELPM} instruction.
1527 @cindex @code{__memx} AVR Named Address Spaces
1528 @item __memx
1529 This is a 24-bit address space that linearizes flash and RAM:
1530 If the high bit of the address is set, data is read from
1531 RAM using the lower two bytes as RAM address.
1532 If the high bit of the address is clear, data is read from flash
1533 with @code{RAMPZ} set according to the high byte of the address.
1534 @xref{AVR Built-in Functions,,@code{__builtin_avr_flash_segment}}.
1536 Objects in this address space are located in @code{.progmemx.data}.
1537 @end table
1539 @b{Example}
1541 @smallexample
1542 char my_read (const __flash char ** p)
1544     /* p is a pointer to RAM that points to a pointer to flash.
1545        The first indirection of p reads that flash pointer
1546        from RAM and the second indirection reads a char from this
1547        flash address.  */
1549     return **p;
1552 /* Locate array[] in flash memory */
1553 const __flash int array[] = @{ 3, 5, 7, 11, 13, 17, 19 @};
1555 int i = 1;
1557 int main (void)
1559    /* Return 17 by reading from flash memory */
1560    return array[array[i]];
1562 @end smallexample
1564 @noindent
1565 For each named address space supported by avr-gcc there is an equally
1566 named but uppercase built-in macro defined. 
1567 The purpose is to facilitate testing if respective address space
1568 support is available or not:
1570 @smallexample
1571 #ifdef __FLASH
1572 const __flash int var = 1;
1574 int read_var (void)
1576     return var;
1578 #else
1579 #include <avr/pgmspace.h> /* From AVR-LibC */
1581 const int var PROGMEM = 1;
1583 int read_var (void)
1585     return (int) pgm_read_word (&var);
1587 #endif /* __FLASH */
1588 @end smallexample
1590 @noindent
1591 Notice that attribute @ref{AVR Variable Attributes,,@code{progmem}}
1592 locates data in flash but
1593 accesses to these data read from generic address space, i.e.@:
1594 from RAM,
1595 so that you need special accessors like @code{pgm_read_byte}
1596 from @w{@uref{https://www.nongnu.org/avr-libc/user-manual/,AVR-LibC}}
1597 together with attribute @code{progmem}.
1599 @noindent
1600 @b{Limitations and Caveats}
1602 @itemize
1603 @item
1604 Reading across the 64@tie{}KiB section boundary of
1605 the @code{__flash} or @code{__flash@var{N}} address spaces
1606 shows undefined behavior. The only address space that
1607 supports reading across the 64@tie{}KiB flash segment boundaries is
1608 @code{__memx}.
1610 @item
1611 If you use one of the @code{__flash@var{N}} address spaces
1612 you must arrange your linker script to locate the
1613 @code{.progmem@var{N}.data} sections according to your needs.
1614 For an example, see the
1615 @w{@uref{https://gcc.gnu.org/wiki/avr-gcc#Address_Spaces,avr-gcc wiki}}
1617 @item
1618 Any data or pointers to the non-generic address spaces must
1619 be qualified as @code{const}, i.e.@: as read-only data.
1620 This still applies if the data in one of these address
1621 spaces like software version number or calibration lookup table are intended to
1622 be changed after load time by, say, a boot loader. In this case
1623 the right qualification is @code{const} @code{volatile} so that the compiler
1624 must not optimize away known values or insert them
1625 as immediates into operands of instructions.
1627 @item
1628 The following code initializes a variable @code{pfoo}
1629 located in static storage with a 24-bit address:
1630 @smallexample
1631 extern const __memx char foo;
1632 const __memx void *pfoo = &foo;
1633 @end smallexample
1635 @item
1636 On the reduced Tiny devices like ATtiny40, no address spaces are supported.
1637 Just use vanilla C / C++ code without overhead as outlined above.
1638 Attribute @code{progmem} is supported but works differently,
1639 see @ref{AVR Variable Attributes}.
1641 @end itemize
1643 @subsection M32C Named Address Spaces
1644 @cindex @code{__far} M32C Named Address Spaces
1646 On the M32C target, with the R8C and M16C CPU variants, variables
1647 qualified with @code{__far} are accessed using 32-bit addresses in
1648 order to access memory beyond the first 64@tie{}Ki bytes.  If
1649 @code{__far} is used with the M32CM or M32C CPU variants, it has no
1650 effect.
1652 @subsection PRU Named Address Spaces
1653 @cindex @code{__regio_symbol} PRU Named Address Spaces
1655 On the PRU target, variables qualified with @code{__regio_symbol} are
1656 aliases used to access the special I/O CPU registers.  They must be
1657 declared as @code{extern} because such variables will not be allocated in
1658 any data memory.  They must also be marked as @code{volatile}, and can
1659 only be 32-bit integer types.  The only names those variables can have
1660 are @code{__R30} and @code{__R31}, representing respectively the
1661 @code{R30} and @code{R31} special I/O CPU registers.  Hence the following
1662 example is the only valid usage of @code{__regio_symbol}:
1664 @smallexample
1665 extern volatile __regio_symbol uint32_t __R30;
1666 extern volatile __regio_symbol uint32_t __R31;
1667 @end smallexample
1669 @subsection RL78 Named Address Spaces
1670 @cindex @code{__far} RL78 Named Address Spaces
1672 On the RL78 target, variables qualified with @code{__far} are accessed
1673 with 32-bit pointers (20-bit addresses) rather than the default 16-bit
1674 addresses.  Non-far variables are assumed to appear in the topmost
1675 64@tie{}KiB of the address space.
1677 @subsection x86 Named Address Spaces
1678 @cindex x86 named address spaces
1680 On the x86 target, variables may be declared as being relative
1681 to the @code{%fs} or @code{%gs} segments.
1683 @table @code
1684 @cindex @code{__seg_fs} x86 named address space
1685 @cindex @code{__seg_gs} x86 named address space
1686 @item __seg_fs
1687 @itemx __seg_gs
1688 The object is accessed with the respective segment override prefix.
1690 The respective segment base must be set via some method specific to
1691 the operating system.  Rather than require an expensive system call
1692 to retrieve the segment base, these address spaces are not considered
1693 to be subspaces of the generic (flat) address space.  This means that
1694 explicit casts are required to convert pointers between these address
1695 spaces and the generic address space.  In practice the application
1696 should cast to @code{uintptr_t} and apply the segment base offset
1697 that it installed previously.
1699 The preprocessor symbols @code{__SEG_FS} and @code{__SEG_GS} are
1700 defined when these address spaces are supported.
1701 @end table
1703 @node Zero Length
1704 @section Arrays of Length Zero
1705 @cindex arrays of length zero
1706 @cindex zero-length arrays
1707 @cindex length-zero arrays
1708 @cindex flexible array members
1710 Declaring zero-length arrays is allowed in GNU C as an extension.
1711 A zero-length array can be useful as the last element of a structure
1712 that is really a header for a variable-length object:
1714 @smallexample
1715 struct line @{
1716   int length;
1717   char contents[0];
1720 struct line *thisline = (struct line *)
1721   malloc (sizeof (struct line) + this_length);
1722 thisline->length = this_length;
1723 @end smallexample
1725 In this example, @code{thisline->contents} is an array of @code{char} that
1726 can hold up to @code{thisline->length} bytes.
1728 Although the size of a zero-length array is zero, an array member of
1729 this kind may increase the size of the enclosing type as a result of tail
1730 padding.  The offset of a zero-length array member from the beginning
1731 of the enclosing structure is the same as the offset of an array with
1732 one or more elements of the same type.  The alignment of a zero-length
1733 array is the same as the alignment of its elements.
1735 Declaring zero-length arrays in other contexts, including as interior
1736 members of structure objects or as non-member objects, is discouraged.
1737 Accessing elements of zero-length arrays declared in such contexts is
1738 undefined and may be diagnosed.
1740 In the absence of the zero-length array extension, in ISO C90
1741 the @code{contents} array in the example above would typically be declared
1742 to have a single element.  Unlike a zero-length array which only contributes
1743 to the size of the enclosing structure for the purposes of alignment,
1744 a one-element array always occupies at least as much space as a single
1745 object of the type.  Although using one-element arrays this way is
1746 discouraged, GCC handles accesses to trailing one-element array members
1747 analogously to zero-length arrays.
1749 The preferred mechanism to declare variable-length types like
1750 @code{struct line} above is the ISO C99 @dfn{flexible array member},
1751 with slightly different syntax and semantics:
1753 @itemize @bullet
1754 @item
1755 Flexible array members are written as @code{contents[]} without
1756 the @code{0}.
1758 @item
1759 Flexible array members have incomplete type, and so the @code{sizeof}
1760 operator may not be applied.  As a quirk of the original implementation
1761 of zero-length arrays, @code{sizeof} evaluates to zero.
1763 @item
1764 Flexible array members may only appear as the last member of a
1765 @code{struct} that is otherwise non-empty.
1767 @item
1768 A structure containing a flexible array member, or a union containing
1769 such a structure (possibly recursively), may not be a member of a
1770 structure or an element of an array.  (However, these uses are
1771 permitted by GCC as extensions, see details below.)
1772 @end itemize
1774 The GCC extension accepts a structure containing an ISO C99 @dfn{flexible array
1775 member}, or a union containing such a structure (possibly recursively)
1776 to be a member of a structure.
1778 There are two situations:
1780 @itemize @bullet
1781 @item
1782 A structure containing a C99 flexible array member, or a union containing
1783 such a structure, is the last field of another structure, for example:
1785 @smallexample
1786 struct flex  @{ int length; char data[]; @};
1787 union union_flex @{ int others; struct flex f; @};
1789 struct out_flex_struct @{ int m; struct flex flex_data; @};
1790 struct out_flex_union @{ int n; union union_flex flex_data; @};
1791 @end smallexample
1793 In the above, both @code{out_flex_struct.flex_data.data[]} and
1794 @code{out_flex_union.flex_data.f.data[]} are considered as flexible arrays too.
1796 @item
1797 A structure containing a C99 flexible array member, or a union containing
1798 such a structure, is not the last field of another structure, for example:
1800 @smallexample
1801 struct flex  @{ int length; char data[]; @};
1803 struct mid_flex @{ int m; struct flex flex_data; int n; @};
1804 @end smallexample
1806 In the above, accessing a member of the array @code{mid_flex.flex_data.data[]}
1807 might have undefined behavior.  Compilers do not handle such a case
1808 consistently.  Any code relying on this case should be modified to ensure
1809 that flexible array members only end up at the ends of structures.
1811 Please use the warning option @option{-Wflex-array-member-not-at-end} to
1812 identify all such cases in the source code and modify them.  This extension
1813 is now deprecated.
1814 @end itemize
1816 Non-empty initialization of zero-length
1817 arrays is treated like any case where there are more initializer
1818 elements than the array holds, in that a suitable warning about ``excess
1819 elements in array'' is given, and the excess elements (all of them, in
1820 this case) are ignored.
1822 GCC allows static initialization of flexible array members.
1823 This is equivalent to defining a new structure containing the original
1824 structure followed by an array of sufficient size to contain the data.
1825 E.g.@: in the following, @code{f1} is constructed as if it were declared
1826 like @code{f2}.
1828 @smallexample
1829 struct f1 @{
1830   int x; int y[];
1831 @} f1 = @{ 1, @{ 2, 3, 4 @} @};
1833 struct f2 @{
1834   struct f1 f1; int data[3];
1835 @} f2 = @{ @{ 1 @}, @{ 2, 3, 4 @} @};
1836 @end smallexample
1838 @noindent
1839 The convenience of this extension is that @code{f1} has the desired
1840 type, eliminating the need to consistently refer to @code{f2.f1}.
1842 This has symmetry with normal static arrays, in that an array of
1843 unknown size is also written with @code{[]}.
1845 Of course, this extension only makes sense if the extra data comes at
1846 the end of a top-level object, as otherwise we would be overwriting
1847 data at subsequent offsets.  To avoid undue complication and confusion
1848 with initialization of deeply nested arrays, we simply disallow any
1849 non-empty initialization except when the structure is the top-level
1850 object.  For example:
1852 @smallexample
1853 struct foo @{ int x; int y[]; @};
1854 struct bar @{ struct foo z; @};
1856 struct foo a = @{ 1, @{ 2, 3, 4 @} @};        // @r{Valid.}
1857 struct bar b = @{ @{ 1, @{ 2, 3, 4 @} @} @};    // @r{Invalid.}
1858 struct bar c = @{ @{ 1, @{ @} @} @};            // @r{Valid.}
1859 struct foo d[1] = @{ @{ 1, @{ 2, 3, 4 @} @} @};  // @r{Invalid.}
1860 @end smallexample
1862 @node Empty Structures
1863 @section Structures with No Members
1864 @cindex empty structures
1865 @cindex zero-size structures
1867 GCC permits a C structure to have no members:
1869 @smallexample
1870 struct empty @{
1872 @end smallexample
1874 The structure has size zero.  In C++, empty structures are part
1875 of the language.  G++ treats empty structures as if they had a single
1876 member of type @code{char}.
1878 @node Flexible Array Members in Unions
1879 @section Unions with Flexible Array Members
1880 @cindex unions with flexible array members
1881 @cindex unions with FAMs
1883 GCC permits a C99 flexible array member (FAM) to be in a union:
1885 @smallexample
1886 union with_fam @{
1887   int a;
1888   int b[];
1890 @end smallexample
1892 If every member of a union is a flexible array member, the size of
1893 such a union is zero.
1895 @node Flexible Array Members alone in Structures
1896 @section Structures with only Flexible Array Members
1897 @cindex structures with only flexible array members
1898 @cindex structures with only FAMs
1900 GCC permits a C99 flexible array member (FAM) to be alone in a structure:
1902 @smallexample
1903 struct only_fam @{
1904   int b[];
1906 @end smallexample
1908 The size of such a structure is zero.
1910 @node Variable Length
1911 @section Arrays of Variable Length
1912 @cindex variable-length arrays
1913 @cindex arrays of variable length
1914 @cindex VLAs
1916 Variable-length automatic arrays are allowed in ISO C99, and as an
1917 extension GCC accepts them in C90 mode and in C++.  These arrays are
1918 declared like any other automatic arrays, but with a length that is not
1919 a constant expression.  The storage is allocated at the point of
1920 declaration and deallocated when the block scope containing the declaration
1921 exits.  For
1922 example:
1924 @smallexample
1925 FILE *
1926 concat_fopen (char *s1, char *s2, char *mode)
1928   char str[strlen (s1) + strlen (s2) + 1];
1929   strcpy (str, s1);
1930   strcat (str, s2);
1931   return fopen (str, mode);
1933 @end smallexample
1935 @cindex scope of a variable length array
1936 @cindex variable-length array scope
1937 @cindex deallocating variable length arrays
1938 Jumping or breaking out of the scope of the array name deallocates the
1939 storage.  Jumping into the scope is not allowed; you get an error
1940 message for it.
1942 @cindex variable-length array in a structure
1943 As an extension, GCC accepts variable-length arrays as a member of
1944 a structure or a union.  For example:
1946 @smallexample
1947 void
1948 foo (int n)
1950   struct S @{ int x[n]; @};
1952 @end smallexample
1954 @cindex @code{alloca} vs variable-length arrays
1955 You can use the function @code{alloca} to get an effect much like
1956 variable-length arrays.  The function @code{alloca} is available in
1957 many other C implementations (but not in all).  On the other hand,
1958 variable-length arrays are more elegant.
1960 There are other differences between these two methods.  Space allocated
1961 with @code{alloca} exists until the containing @emph{function} returns.
1962 The space for a variable-length array is deallocated as soon as the array
1963 name's scope ends, unless you also use @code{alloca} in this scope.
1965 You can also use variable-length arrays as arguments to functions:
1967 @smallexample
1968 struct entry
1969 tester (int len, char data[len][len])
1971   /* @r{@dots{}} */
1973 @end smallexample
1975 The length of an array is computed once when the storage is allocated
1976 and is remembered for the scope of the array in case you access it with
1977 @code{sizeof}.
1979 If you want to pass the array first and the length afterward, you can
1980 use a forward declaration in the parameter list---another GNU extension.
1982 @smallexample
1983 struct entry
1984 tester (int len; char data[len][len], int len)
1986   /* @r{@dots{}} */
1988 @end smallexample
1990 @cindex parameter forward declaration
1991 The @samp{int len} before the semicolon is a @dfn{parameter forward
1992 declaration}, and it serves the purpose of making the name @code{len}
1993 known when the declaration of @code{data} is parsed.
1995 You can write any number of such parameter forward declarations in the
1996 parameter list.  They can be separated by commas or semicolons, but the
1997 last one must end with a semicolon, which is followed by the ``real''
1998 parameter declarations.  Each forward declaration must match a ``real''
1999 declaration in parameter name and data type.  ISO C99 does not support
2000 parameter forward declarations.
2002 @node Variadic Macros
2003 @section Macros with a Variable Number of Arguments.
2004 @cindex variable number of arguments
2005 @cindex macro with variable arguments
2006 @cindex rest argument (in macro)
2007 @cindex variadic macros
2009 In the ISO C standard of 1999, a macro can be declared to accept a
2010 variable number of arguments much as a function can.  The syntax for
2011 defining the macro is similar to that of a function.  Here is an
2012 example:
2014 @smallexample
2015 #define debug(format, ...) fprintf (stderr, format, __VA_ARGS__)
2016 @end smallexample
2018 @noindent
2019 Here @samp{@dots{}} is a @dfn{variable argument}.  In the invocation of
2020 such a macro, it represents the zero or more tokens until the closing
2021 parenthesis that ends the invocation, including any commas.  This set of
2022 tokens replaces the identifier @code{__VA_ARGS__} in the macro body
2023 wherever it appears.  See the CPP manual for more information.
2025 GCC has long supported variadic macros, and used a different syntax that
2026 allowed you to give a name to the variable arguments just like any other
2027 argument.  Here is an example:
2029 @smallexample
2030 #define debug(format, args...) fprintf (stderr, format, args)
2031 @end smallexample
2033 @noindent
2034 This is in all ways equivalent to the ISO C example above, but arguably
2035 more readable and descriptive.
2037 GNU CPP has two further variadic macro extensions, and permits them to
2038 be used with either of the above forms of macro definition.
2040 In standard C, you are not allowed to leave the variable argument out
2041 entirely; but you are allowed to pass an empty argument.  For example,
2042 this invocation is invalid in ISO C, because there is no comma after
2043 the string:
2045 @smallexample
2046 debug ("A message")
2047 @end smallexample
2049 GNU CPP permits you to completely omit the variable arguments in this
2050 way.  In the above examples, the compiler would complain, though since
2051 the expansion of the macro still has the extra comma after the format
2052 string.
2054 To help solve this problem, CPP behaves specially for variable arguments
2055 used with the token paste operator, @samp{##}.  If instead you write
2057 @smallexample
2058 #define debug(format, ...) fprintf (stderr, format, ## __VA_ARGS__)
2059 @end smallexample
2061 @noindent
2062 and if the variable arguments are omitted or empty, the @samp{##}
2063 operator causes the preprocessor to remove the comma before it.  If you
2064 do provide some variable arguments in your macro invocation, GNU CPP
2065 does not complain about the paste operation and instead places the
2066 variable arguments after the comma.  Just like any other pasted macro
2067 argument, these arguments are not macro expanded.
2069 @node Escaped Newlines
2070 @section Slightly Looser Rules for Escaped Newlines
2071 @cindex escaped newlines
2072 @cindex newlines (escaped)
2074 The preprocessor treatment of escaped newlines is more relaxed 
2075 than that specified by the C90 standard, which requires the newline
2076 to immediately follow a backslash.  
2077 GCC's implementation allows whitespace in the form
2078 of spaces, horizontal and vertical tabs, and form feeds between the
2079 backslash and the subsequent newline.  The preprocessor issues a
2080 warning, but treats it as a valid escaped newline and combines the two
2081 lines to form a single logical line.  This works within comments and
2082 tokens, as well as between tokens.  Comments are @emph{not} treated as
2083 whitespace for the purposes of this relaxation, since they have not
2084 yet been replaced with spaces.
2086 @node Subscripting
2087 @section Non-Lvalue Arrays May Have Subscripts
2088 @cindex subscripting
2089 @cindex arrays, non-lvalue
2091 @cindex subscripting and function values
2092 In ISO C99, arrays that are not lvalues still decay to pointers, and
2093 may be subscripted, although they may not be modified or used after
2094 the next sequence point and the unary @samp{&} operator may not be
2095 applied to them.  As an extension, GNU C allows such arrays to be
2096 subscripted in C90 mode, though otherwise they do not decay to
2097 pointers outside C99 mode.  For example,
2098 this is valid in GNU C though not valid in C90:
2100 @smallexample
2101 @group
2102 struct foo @{int a[4];@};
2104 struct foo f();
2106 bar (int index)
2108   return f().a[index];
2110 @end group
2111 @end smallexample
2113 @node Pointer Arith
2114 @section Arithmetic on @code{void}- and Function-Pointers
2115 @cindex void pointers, arithmetic
2116 @cindex void, size of pointer to
2117 @cindex function pointers, arithmetic
2118 @cindex function, size of pointer to
2120 In GNU C, addition and subtraction operations are supported on pointers to
2121 @code{void} and on pointers to functions.  This is done by treating the
2122 size of a @code{void} or of a function as 1.
2124 A consequence of this is that @code{sizeof} is also allowed on @code{void}
2125 and on function types, and returns 1.
2127 @opindex Wpointer-arith
2128 The option @option{-Wpointer-arith} requests a warning if these extensions
2129 are used.
2131 @node Variadic Pointer Args
2132 @section Pointer Arguments in Variadic Functions
2133 @cindex pointer arguments in variadic functions
2134 @cindex variadic functions, pointer arguments
2136 Standard C requires that pointer types used with @code{va_arg} in
2137 functions with variable argument lists either must be compatible with
2138 that of the actual argument, or that one type must be a pointer to
2139 @code{void} and the other a pointer to a character type.  GNU C
2140 implements the POSIX XSI extension that additionally permits the use
2141 of @code{va_arg} with a pointer type to receive arguments of any other
2142 pointer type.
2144 In particular, in GNU C @samp{va_arg (ap, void *)} can safely be used
2145 to consume an argument of any pointer type.
2147 @node Pointers to Arrays
2148 @section Pointers to Arrays with Qualifiers Work as Expected
2149 @cindex pointers to arrays
2150 @cindex const qualifier
2152 In GNU C, pointers to arrays with qualifiers work similar to pointers
2153 to other qualified types. For example, a value of type @code{int (*)[5]}
2154 can be used to initialize a variable of type @code{const int (*)[5]}.
2155 These types are incompatible in ISO C because the @code{const} qualifier
2156 is formally attached to the element type of the array and not the
2157 array itself.
2159 @smallexample
2160 extern void
2161 transpose (int N, int M, double out[M][N], const double in[N][M]);
2162 double x[3][2];
2163 double y[2][3];
2164 @r{@dots{}}
2165 transpose(3, 2, y, x);
2166 @end smallexample
2168 @node Initializers
2169 @section Non-Constant Initializers
2170 @cindex initializers, non-constant
2171 @cindex non-constant initializers
2173 As in standard C++ and ISO C99, the elements of an aggregate initializer for an
2174 automatic variable are not required to be constant expressions in GNU C@.
2175 Here is an example of an initializer with run-time varying elements:
2177 @smallexample
2178 foo (float f, float g)
2180   float beat_freqs[2] = @{ f-g, f+g @};
2181   /* @r{@dots{}} */
2183 @end smallexample
2185 @node Compound Literals
2186 @section Compound Literals
2187 @cindex constructor expressions
2188 @cindex initializations in expressions
2189 @cindex structures, constructor expression
2190 @cindex expressions, constructor
2191 @cindex compound literals
2192 @c The GNU C name for what C99 calls compound literals was "constructor expressions".
2194 A compound literal looks like a cast of a brace-enclosed aggregate
2195 initializer list.  Its value is an object of the type specified in
2196 the cast, containing the elements specified in the initializer.
2197 Unlike the result of a cast, a compound literal is an lvalue.  ISO
2198 C99 and later support compound literals.  As an extension, GCC
2199 supports compound literals also in C90 mode and in C++, although
2200 as explained below, the C++ semantics are somewhat different.
2202 Usually, the specified type of a compound literal is a structure.  Assume
2203 that @code{struct foo} and @code{structure} are declared as shown:
2205 @smallexample
2206 struct foo @{int a; char b[2];@} structure;
2207 @end smallexample
2209 @noindent
2210 Here is an example of constructing a @code{struct foo} with a compound literal:
2212 @smallexample
2213 structure = ((struct foo) @{x + y, 'a', 0@});
2214 @end smallexample
2216 @noindent
2217 This is equivalent to writing the following:
2219 @smallexample
2221   struct foo temp = @{x + y, 'a', 0@};
2222   structure = temp;
2224 @end smallexample
2226 You can also construct an array, though this is dangerous in C++, as
2227 explained below.  If all the elements of the compound literal are
2228 (made up of) simple constant expressions suitable for use in
2229 initializers of objects of static storage duration, then the compound
2230 literal can be coerced to a pointer to its first element and used in
2231 such an initializer, as shown here:
2233 @smallexample
2234 char **foo = (char *[]) @{ "x", "y", "z" @};
2235 @end smallexample
2237 Compound literals for scalar types and union types are also allowed.  In
2238 the following example the variable @code{i} is initialized to the value
2239 @code{2}, the result of incrementing the unnamed object created by
2240 the compound literal.
2242 @smallexample
2243 int i = ++(int) @{ 1 @};
2244 @end smallexample
2246 As a GNU extension, GCC allows initialization of objects with static storage
2247 duration by compound literals (which is not possible in ISO C99 because
2248 the initializer is not a constant).
2249 It is handled as if the object were initialized only with the brace-enclosed
2250 list if the types of the compound literal and the object match.
2251 The elements of the compound literal must be constant.
2252 If the object being initialized has array type of unknown size, the size is
2253 determined by the size of the compound literal.
2255 @smallexample
2256 static struct foo x = (struct foo) @{1, 'a', 'b'@};
2257 static int y[] = (int []) @{1, 2, 3@};
2258 static int z[] = (int [3]) @{1@};
2259 @end smallexample
2261 @noindent
2262 The above lines are equivalent to the following:
2263 @smallexample
2264 static struct foo x = @{1, 'a', 'b'@};
2265 static int y[] = @{1, 2, 3@};
2266 static int z[] = @{1, 0, 0@};
2267 @end smallexample
2269 In C, a compound literal designates an unnamed object with static or
2270 automatic storage duration.  In C++, a compound literal designates a
2271 temporary object that only lives until the end of its full-expression.
2272 As a result, well-defined C code that takes the address of a subobject
2273 of a compound literal can be undefined in C++, so G++ rejects
2274 the conversion of a temporary array to a pointer.  For instance, if
2275 the array compound literal example above appeared inside a function,
2276 any subsequent use of @code{foo} in C++ would have undefined behavior
2277 because the lifetime of the array ends after the declaration of @code{foo}.
2279 As an optimization, G++ sometimes gives array compound literals longer
2280 lifetimes: when the array either appears outside a function or has
2281 a @code{const}-qualified type.  If @code{foo} and its initializer had
2282 elements of type @code{char *const} rather than @code{char *}, or if
2283 @code{foo} were a global variable, the array would have static storage
2284 duration.  But it is probably safest just to avoid the use of array
2285 compound literals in C++ code.
2287 @node Designated Inits
2288 @section Designated Initializers
2289 @cindex initializers with labeled elements
2290 @cindex labeled elements in initializers
2291 @cindex case labels in initializers
2292 @cindex designated initializers
2294 Standard C90 requires the elements of an initializer to appear in a fixed
2295 order, the same as the order of the elements in the array or structure
2296 being initialized.
2298 In ISO C99 you can give the elements in any order, specifying the array
2299 indices or structure field names they apply to, and GNU C allows this as
2300 an extension in C90 mode as well.  This extension is not
2301 implemented in GNU C++.
2303 To specify an array index, write
2304 @samp{[@var{index}] =} before the element value.  For example,
2306 @smallexample
2307 int a[6] = @{ [4] = 29, [2] = 15 @};
2308 @end smallexample
2310 @noindent
2311 is equivalent to
2313 @smallexample
2314 int a[6] = @{ 0, 0, 15, 0, 29, 0 @};
2315 @end smallexample
2317 @noindent
2318 The index values must be constant expressions, even if the array being
2319 initialized is automatic.
2321 An alternative syntax for this that has been obsolete since GCC 2.5 but
2322 GCC still accepts is to write @samp{[@var{index}]} before the element
2323 value, with no @samp{=}.
2325 To initialize a range of elements to the same value, write
2326 @samp{[@var{first} ... @var{last}] = @var{value}}.  This is a GNU
2327 extension.  For example,
2329 @smallexample
2330 int widths[] = @{ [0 ... 9] = 1, [10 ... 99] = 2, [100] = 3 @};
2331 @end smallexample
2333 @noindent
2334 If the value in it has side effects, the side effects happen only once,
2335 not for each initialized field by the range initializer.
2337 @noindent
2338 Note that the length of the array is the highest value specified
2339 plus one.
2341 In a structure initializer, specify the name of a field to initialize
2342 with @samp{.@var{fieldname} =} before the element value.  For example,
2343 given the following structure,
2345 @smallexample
2346 struct point @{ int x, y; @};
2347 @end smallexample
2349 @noindent
2350 the following initialization
2352 @smallexample
2353 struct point p = @{ .y = yvalue, .x = xvalue @};
2354 @end smallexample
2356 @noindent
2357 is equivalent to
2359 @smallexample
2360 struct point p = @{ xvalue, yvalue @};
2361 @end smallexample
2363 Another syntax that has the same meaning, obsolete since GCC 2.5, is
2364 @samp{@var{fieldname}:}, as shown here:
2366 @smallexample
2367 struct point p = @{ y: yvalue, x: xvalue @};
2368 @end smallexample
2370 Omitted fields are implicitly initialized the same as for objects
2371 that have static storage duration.
2373 @cindex designators
2374 The @samp{[@var{index}]} or @samp{.@var{fieldname}} is known as a
2375 @dfn{designator}.  You can also use a designator (or the obsolete colon
2376 syntax) when initializing a union, to specify which element of the union
2377 should be used.  For example,
2379 @smallexample
2380 union foo @{ int i; double d; @};
2382 union foo f = @{ .d = 4 @};
2383 @end smallexample
2385 @noindent
2386 converts 4 to a @code{double} to store it in the union using
2387 the second element.  By contrast, casting 4 to type @code{union foo}
2388 stores it into the union as the integer @code{i}, since it is
2389 an integer.  @xref{Cast to Union}.
2391 You can combine this technique of naming elements with ordinary C
2392 initialization of successive elements.  Each initializer element that
2393 does not have a designator applies to the next consecutive element of the
2394 array or structure.  For example,
2396 @smallexample
2397 int a[6] = @{ [1] = v1, v2, [4] = v4 @};
2398 @end smallexample
2400 @noindent
2401 is equivalent to
2403 @smallexample
2404 int a[6] = @{ 0, v1, v2, 0, v4, 0 @};
2405 @end smallexample
2407 Labeling the elements of an array initializer is especially useful
2408 when the indices are characters or belong to an @code{enum} type.
2409 For example:
2411 @smallexample
2412 int whitespace[256]
2413   = @{ [' '] = 1, ['\t'] = 1, ['\h'] = 1,
2414       ['\f'] = 1, ['\n'] = 1, ['\r'] = 1 @};
2415 @end smallexample
2417 @cindex designator lists
2418 You can also write a series of @samp{.@var{fieldname}} and
2419 @samp{[@var{index}]} designators before an @samp{=} to specify a
2420 nested subobject to initialize; the list is taken relative to the
2421 subobject corresponding to the closest surrounding brace pair.  For
2422 example, with the @samp{struct point} declaration above:
2424 @smallexample
2425 struct point ptarray[10] = @{ [2].y = yv2, [2].x = xv2, [0].x = xv0 @};
2426 @end smallexample
2428 If the same field is initialized multiple times, or overlapping
2429 fields of a union are initialized, the value from the last
2430 initialization is used.  When a field of a union is itself a structure, 
2431 the entire structure from the last field initialized is used.  If any previous
2432 initializer has side effect, it is unspecified whether the side effect
2433 happens or not.  Currently, GCC discards the side-effecting
2434 initializer expressions and issues a warning.
2436 @node Case Ranges
2437 @section Case Ranges
2438 @cindex case ranges
2439 @cindex ranges in case statements
2441 You can specify a range of consecutive values in a single @code{case} label,
2442 like this:
2444 @smallexample
2445 case @var{low} ... @var{high}:
2446 @end smallexample
2448 @noindent
2449 This has the same effect as the proper number of individual @code{case}
2450 labels, one for each integer value from @var{low} to @var{high}, inclusive.
2452 This feature is especially useful for ranges of ASCII character codes:
2454 @smallexample
2455 case 'A' ... 'Z':
2456 @end smallexample
2458 @strong{Be careful:} Write spaces around the @code{...}, for otherwise
2459 it may be parsed wrong when you use it with integer values.  For example,
2460 write this:
2462 @smallexample
2463 case 1 ... 5:
2464 @end smallexample
2466 @noindent
2467 rather than this:
2469 @smallexample
2470 case 1...5:
2471 @end smallexample
2473 @node Cast to Union
2474 @section Cast to a Union Type
2475 @cindex cast to a union
2476 @cindex union, casting to a
2478 A cast to a union type is a C extension not available in C++.  It looks
2479 just like ordinary casts with the constraint that the type specified is
2480 a union type.  You can specify the type either with the @code{union}
2481 keyword or with a @code{typedef} name that refers to a union.  The result
2482 of a cast to a union is a temporary rvalue of the union type with a member
2483 whose type matches that of the operand initialized to the value of
2484 the operand.  The effect of a cast to a union is similar to a compound
2485 literal except that it yields an rvalue like standard casts do.
2486 @xref{Compound Literals}.
2488 Expressions that may be cast to the union type are those whose type matches
2489 at least one of the members of the union.  Thus, given the following union
2490 and variables:
2492 @smallexample
2493 union foo @{ int i; double d; @};
2494 int x;
2495 double y;
2496 union foo z;
2497 @end smallexample
2499 @noindent
2500 both @code{x} and @code{y} can be cast to type @code{union foo} and
2501 the following assignments
2502 @smallexample
2503   z = (union foo) x;
2504   z = (union foo) y;
2505 @end smallexample
2506 are shorthand equivalents of these
2507 @smallexample
2508   z = (union foo) @{ .i = x @};
2509   z = (union foo) @{ .d = y @};
2510 @end smallexample
2512 However, @code{(union foo) FLT_MAX;} is not a valid cast because the union
2513 has no member of type @code{float}.
2515 Using the cast as the right-hand side of an assignment to a variable of
2516 union type is equivalent to storing in a member of the union with
2517 the same type
2519 @smallexample
2520 union foo u;
2521 /* @r{@dots{}} */
2522 u = (union foo) x  @equiv{}  u.i = x
2523 u = (union foo) y  @equiv{}  u.d = y
2524 @end smallexample
2526 You can also use the union cast as a function argument:
2528 @smallexample
2529 void hack (union foo);
2530 /* @r{@dots{}} */
2531 hack ((union foo) x);
2532 @end smallexample
2534 @node Mixed Labels and Declarations
2535 @section Mixed Declarations, Labels and Code
2536 @cindex mixed declarations and code
2537 @cindex declarations, mixed with code
2538 @cindex code, mixed with declarations
2540 ISO C99 and ISO C++ allow declarations and code to be freely mixed
2541 within compound statements.  ISO C23 allows labels to be
2542 placed before declarations and at the end of a compound statement.
2543 As an extension, GNU C also allows all this in C90 mode.  For example,
2544 you could do:
2546 @smallexample
2547 int i;
2548 /* @r{@dots{}} */
2549 i++;
2550 int j = i + 2;
2551 @end smallexample
2553 Each identifier is visible from where it is declared until the end of
2554 the enclosing block.
2556 @node Function Attributes
2557 @section Declaring Attributes of Functions
2558 @cindex function attributes
2559 @cindex declaring attributes of functions
2561 In GNU C and C++, you can use function attributes to specify certain
2562 function properties that may help the compiler optimize calls or
2563 check code more carefully for correctness.  For example, you
2564 can use attributes to specify that a function never returns
2565 (@code{noreturn}), returns a value depending only on the values of
2566 its arguments (@code{const}), or has @code{printf}-style arguments
2567 (@code{format}).
2569 You can also use attributes to control memory placement, code
2570 generation options or call/return conventions within the function
2571 being annotated.  Many of these attributes are target-specific.  For
2572 example, many targets support attributes for defining interrupt
2573 handler functions, which typically must follow special register usage
2574 and return conventions.  Such attributes are described in the subsection
2575 for each target.  However, a considerable number of attributes are
2576 supported by most, if not all targets.  Those are described in
2577 the @ref{Common Function Attributes} section.
2579 GCC provides two different ways to specify attributes: the traditional
2580 GNU syntax using @samp{__attribute__ ((...))} annotations, and the
2581 newer standard C and C++ syntax using @samp{[[...]]} with the
2582 @samp{gnu::} prefix on attribute names.  Note that the exact rules for
2583 placement of attributes in your source code are different depending on
2584 which syntax you use.  @xref{Attribute Syntax}, for details.
2586 Compatible attribute specifications on distinct declarations
2587 of the same function are merged.  An attribute specification that is not
2588 compatible with attributes already applied to a declaration of the same
2589 function is ignored with a warning.
2591 Some function attributes take one or more arguments that refer to
2592 the function's parameters by their positions within the function parameter
2593 list.  Such attribute arguments are referred to as @dfn{positional arguments}.
2594 Unless specified otherwise, positional arguments that specify properties
2595 of parameters with pointer types can also specify the same properties of
2596 the implicit C++ @code{this} argument in non-static member functions, and
2597 of parameters of reference to a pointer type.  For ordinary functions,
2598 position one refers to the first parameter on the list.  In C++ non-static
2599 member functions, position one refers to the implicit @code{this} pointer.
2600 The same restrictions and effects apply to function attributes used with
2601 ordinary functions or C++ member functions.
2603 GCC also supports attributes on
2604 variable declarations (@pxref{Variable Attributes}),
2605 labels (@pxref{Label Attributes}),
2606 enumerators (@pxref{Enumerator Attributes}),
2607 statements (@pxref{Statement Attributes}),
2608 types (@pxref{Type Attributes}),
2609 and on field declarations (for @code{tainted_args}).
2611 There is some overlap between the purposes of attributes and pragmas
2612 (@pxref{Pragmas,,Pragmas Accepted by GCC}).  It has been
2613 found convenient to use @code{__attribute__} to achieve a natural
2614 attachment of attributes to their corresponding declarations, whereas
2615 @code{#pragma} is of use for compatibility with other compilers
2616 or constructs that do not naturally form part of the grammar.
2618 In addition to the attributes documented here,
2619 GCC plugins may provide their own attributes.
2621 @menu
2622 * Common Function Attributes::
2623 * AArch64 Function Attributes::
2624 * AMD GCN Function Attributes::
2625 * ARC Function Attributes::
2626 * ARM Function Attributes::
2627 * AVR Function Attributes::
2628 * Blackfin Function Attributes::
2629 * BPF Function Attributes::
2630 * C-SKY Function Attributes::
2631 * Epiphany Function Attributes::
2632 * H8/300 Function Attributes::
2633 * IA-64 Function Attributes::
2634 * M32C Function Attributes::
2635 * M32R/D Function Attributes::
2636 * m68k Function Attributes::
2637 * MCORE Function Attributes::
2638 * MicroBlaze Function Attributes::
2639 * Microsoft Windows Function Attributes::
2640 * MIPS Function Attributes::
2641 * MSP430 Function Attributes::
2642 * NDS32 Function Attributes::
2643 * Nios II Function Attributes::
2644 * Nvidia PTX Function Attributes::
2645 * PowerPC Function Attributes::
2646 * RISC-V Function Attributes::
2647 * RL78 Function Attributes::
2648 * RX Function Attributes::
2649 * S/390 Function Attributes::
2650 * SH Function Attributes::
2651 * Symbian OS Function Attributes::
2652 * V850 Function Attributes::
2653 * Visium Function Attributes::
2654 * x86 Function Attributes::
2655 * Xstormy16 Function Attributes::
2656 @end menu
2658 @node Common Function Attributes
2659 @subsection Common Function Attributes
2661 The following attributes are supported on most targets.
2663 @table @code
2664 @c Keep this table alphabetized by attribute name.  Treat _ as space.
2666 @cindex @code{access} function attribute
2667 @item access (@var{access-mode}, @var{ref-index})
2668 @itemx access (@var{access-mode}, @var{ref-index}, @var{size-index})
2670 The @code{access} attribute enables the detection of invalid or unsafe
2671 accesses by functions to which they apply or their callers, as well as
2672 write-only accesses to objects that are never read from.  Such accesses
2673 may be diagnosed by warnings such as @option{-Wstringop-overflow},
2674 @option{-Wuninitialized}, @option{-Wunused}, and others.
2676 The @code{access} attribute specifies that a function to whose by-reference
2677 arguments the attribute applies accesses the referenced object according to
2678 @var{access-mode}.  The @var{access-mode} argument is required and must be
2679 one of four names: @code{read_only}, @code{read_write}, @code{write_only},
2680 or @code{none}.  The remaining two are positional arguments.
2682 The required @var{ref-index} positional argument  denotes a function
2683 argument of pointer (or in C++, reference) type that is subject to
2684 the access.  The same pointer argument can be referenced by at most one
2685 distinct @code{access} attribute.
2687 The optional @var{size-index} positional argument denotes a function
2688 argument of integer type that specifies the maximum size of the access.
2689 The size is the number of elements of the type referenced by @var{ref-index},
2690 or the number of bytes when the pointer type is @code{void*}.  When no
2691 @var{size-index} argument is specified, the pointer argument must be either
2692 null or point to a space that is suitably aligned and large for at least one
2693 object of the referenced type (this implies that a past-the-end pointer is
2694 not a valid argument).  The actual size of the access may be less but it
2695 must not be more.
2697 The @code{read_only} access mode specifies that the pointer to which it
2698 applies is used to read the referenced object but not write to it.  Unless
2699 the argument specifying the size of the access denoted by @var{size-index}
2700 is zero, the referenced object must be initialized.  The mode implies
2701 a stronger guarantee than the @code{const} qualifier which, when cast away
2702 from a pointer, does not prevent the pointed-to object from being modified.
2703 Examples of the use of the @code{read_only} access mode is the argument to
2704 the @code{puts} function, or the second and third arguments to
2705 the @code{memcpy} function.
2707 @smallexample
2708 __attribute__ ((access (read_only, 1)))
2709 int puts (const char*);
2711 __attribute__ ((access (read_only, 2, 3)))
2712 void* memcpy (void*, const void*, size_t);
2713 @end smallexample
2715 The @code{read_write} access mode applies to arguments of pointer types
2716 without the @code{const} qualifier.  It specifies that the pointer to which
2717 it applies is used to both read and write the referenced object.  Unless
2718 the argument specifying the size of the access denoted by @var{size-index}
2719 is zero, the object referenced by the pointer must be initialized.  An example
2720 of the use of the @code{read_write} access mode is the first argument to
2721 the @code{strcat} function.
2723 @smallexample
2724 __attribute__ ((access (read_write, 1), access (read_only, 2)))
2725 char* strcat (char*, const char*);
2726 @end smallexample
2728 The @code{write_only} access mode applies to arguments of pointer types
2729 without the @code{const} qualifier.  It specifies that the pointer to which
2730 it applies is used to write to the referenced object but not read from it.
2731 The object referenced by the pointer need not be initialized.  An example
2732 of the use of the @code{write_only} access mode is the first argument to
2733 the @code{strcpy} function, or the first two arguments to the @code{fgets}
2734 function.
2736 @smallexample
2737 __attribute__ ((access (write_only, 1), access (read_only, 2)))
2738 char* strcpy (char*, const char*);
2740 __attribute__ ((access (write_only, 1, 2), access (read_write, 3)))
2741 int fgets (char*, int, FILE*);
2742 @end smallexample
2744 The access mode @code{none} specifies that the pointer to which it applies
2745 is not used to access the referenced object at all.  Unless the pointer is
2746 null the pointed-to object must exist and have at least the size as denoted
2747 by the @var{size-index} argument.  When the optional @var{size-index}
2748 argument is omitted for an argument of @code{void*} type the actual pointer
2749 agument is ignored.  The referenced object need not be initialized.
2750 The mode is intended to be used as a means to help validate the expected
2751 object size, for example in functions that call @code{__builtin_object_size}.
2752 @xref{Object Size Checking}.
2754 Note that the @code{access} attribute merely specifies how an object
2755 referenced by the pointer argument can be accessed; it does not imply that
2756 an access @strong{will} happen.  Also, the @code{access} attribute does not
2757 imply the attribute @code{nonnull}; it may be appropriate to add both attributes
2758 at the declaration of a function that unconditionally manipulates a buffer via
2759 a pointer argument.  See the @code{nonnull} attribute for more information and
2760 caveats.
2762 @cindex @code{alias} function attribute
2763 @item alias ("@var{target}")
2764 The @code{alias} attribute causes the declaration to be emitted as an alias
2765 for another symbol, which must have been previously declared with the same
2766 type, and for variables, also the same size and alignment.  Declaring an alias
2767 with a different type than the target is undefined and may be diagnosed.  As
2768 an example, the following declarations:
2770 @smallexample
2771 void __f () @{ /* @r{Do something.} */; @}
2772 void f () __attribute__ ((weak, alias ("__f")));
2773 @end smallexample
2775 @noindent
2776 define @samp{f} to be a weak alias for @samp{__f}.  In C++, the mangled name
2777 for the target must be used.  It is an error if @samp{__f} is not defined in
2778 the same translation unit.
2780 This attribute requires assembler and object file support,
2781 and may not be available on all targets.
2783 @cindex @code{aligned} function attribute
2784 @item aligned
2785 @itemx aligned (@var{alignment})
2786 The @code{aligned} attribute specifies a minimum alignment for
2787 the first instruction of the function, measured in bytes.  When specified,
2788 @var{alignment} must be an integer constant power of 2.  Specifying no
2789 @var{alignment} argument implies the ideal alignment for the target.
2790 The @code{__alignof__} operator can be used to determine what that is
2791 (@pxref{Alignment}).  The attribute has no effect when a definition for
2792 the function is not provided in the same translation unit.
2794 The attribute cannot be used to decrease the alignment of a function
2795 previously declared with a more restrictive alignment; only to increase
2796 it.  Attempts to do otherwise are diagnosed.  Some targets specify
2797 a minimum default alignment for functions that is greater than 1.  On
2798 such targets, specifying a less restrictive alignment is silently ignored.
2799 Using the attribute overrides the effect of the @option{-falign-functions}
2800 (@pxref{Optimize Options}) option for this function.
2802 Note that the effectiveness of @code{aligned} attributes may be
2803 limited by inherent limitations in the system linker 
2804 and/or object file format.  On some systems, the
2805 linker is only able to arrange for functions to be aligned up to a
2806 certain maximum alignment.  (For some linkers, the maximum supported
2807 alignment may be very very small.)  See your linker documentation for
2808 further information.
2810 The @code{aligned} attribute can also be used for variables and fields
2811 (@pxref{Variable Attributes}.)
2813 @cindex @code{alloc_align} function attribute
2814 @item alloc_align (@var{position})
2815 The @code{alloc_align} attribute may be applied to a function that
2816 returns a pointer and takes at least one argument of an integer or
2817 enumerated type.
2818 It indicates that the returned pointer is aligned on a boundary given
2819 by the function argument at @var{position}.  Meaningful alignments are
2820 powers of 2 greater than one.  GCC uses this information to improve
2821 pointer alignment analysis.
2823 The function parameter denoting the allocated alignment is specified by
2824 one constant integer argument whose number is the argument of the attribute.
2825 Argument numbering starts at one.
2827 For instance,
2829 @smallexample
2830 void* my_memalign (size_t, size_t) __attribute__ ((alloc_align (1)));
2831 @end smallexample
2833 @noindent
2834 declares that @code{my_memalign} returns memory with minimum alignment
2835 given by parameter 1.
2837 @cindex @code{alloc_size} function attribute
2838 @item alloc_size (@var{position})
2839 @itemx alloc_size (@var{position-1}, @var{position-2})
2840 The @code{alloc_size} attribute may be applied to a function that
2841 returns a pointer and takes at least one argument of an integer or
2842 enumerated type.
2843 It indicates that the returned pointer points to memory whose size is
2844 given by the function argument at @var{position-1}, or by the product
2845 of the arguments at @var{position-1} and @var{position-2}.  Meaningful
2846 sizes are positive values less than @code{PTRDIFF_MAX}.  GCC uses this
2847 information to improve the results of @code{__builtin_object_size}.
2849 The function parameter(s) denoting the allocated size are specified by
2850 one or two integer arguments supplied to the attribute.  The allocated size
2851 is either the value of the single function argument specified or the product
2852 of the two function arguments specified.  Argument numbering starts at
2853 one for ordinary functions, and at two for C++ non-static member functions.
2855 For instance,
2857 @smallexample
2858 void* my_calloc (size_t, size_t) __attribute__ ((alloc_size (1, 2)));
2859 void* my_realloc (void*, size_t) __attribute__ ((alloc_size (2)));
2860 @end smallexample
2862 @noindent
2863 declares that @code{my_calloc} returns memory of the size given by
2864 the product of parameter 1 and 2 and that @code{my_realloc} returns memory
2865 of the size given by parameter 2.
2867 @cindex @code{always_inline} function attribute
2868 @item always_inline
2869 Generally, functions are not inlined unless optimization is specified.
2870 For functions declared inline, this attribute inlines the function
2871 independent of any restrictions that otherwise apply to inlining.
2872 Failure to inline such a function is diagnosed as an error.
2873 Note that if such a function is called indirectly the compiler may
2874 or may not inline it depending on optimization level and a failure
2875 to inline an indirect call may or may not be diagnosed.
2877 @cindex @code{artificial} function attribute
2878 @item artificial
2879 This attribute is useful for small inline wrappers that if possible
2880 should appear during debugging as a unit.  Depending on the debug
2881 info format it either means marking the function as artificial
2882 or using the caller location for all instructions within the inlined
2883 body.
2885 @cindex @code{assume_aligned} function attribute
2886 @item assume_aligned (@var{alignment})
2887 @itemx assume_aligned (@var{alignment}, @var{offset})
2888 The @code{assume_aligned} attribute may be applied to a function that
2889 returns a pointer.  It indicates that the returned pointer is aligned
2890 on a boundary given by @var{alignment}.  If the attribute has two
2891 arguments, the second argument is misalignment @var{offset}.  Meaningful
2892 values of @var{alignment} are powers of 2 greater than one.  Meaningful
2893 values of @var{offset} are greater than zero and less than @var{alignment}.
2895 For instance
2897 @smallexample
2898 void* my_alloc1 (size_t) __attribute__((assume_aligned (16)));
2899 void* my_alloc2 (size_t) __attribute__((assume_aligned (32, 8)));
2900 @end smallexample
2902 @noindent
2903 declares that @code{my_alloc1} returns 16-byte aligned pointers and
2904 that @code{my_alloc2} returns a pointer whose value modulo 32 is equal
2905 to 8.
2907 @cindex @code{cold} function attribute
2908 @item cold
2909 The @code{cold} attribute on functions is used to inform the compiler that
2910 the function is unlikely to be executed.  The function is optimized for
2911 size rather than speed and on many targets it is placed into a special
2912 subsection of the text section so all cold functions appear close together,
2913 improving code locality of non-cold parts of program.  The paths leading
2914 to calls of cold functions within code are marked as unlikely by the branch
2915 prediction mechanism.  It is thus useful to mark functions used to handle
2916 unlikely conditions, such as @code{perror}, as cold to improve optimization
2917 of hot functions that do call marked functions in rare occasions.  In C++,
2918 the @code{cold} attribute can be applied to types with the effect of being
2919 propagated to member functions.  See
2920 @ref{C++ Attributes}.
2922 When profile feedback is available, via @option{-fprofile-use}, cold functions
2923 are automatically detected and this attribute is ignored.
2925 @cindex @code{const} function attribute
2926 @cindex functions that have no side effects
2927 @item const
2928 Calls to functions whose return value is not affected by changes to
2929 the observable state of the program and that have no observable effects
2930 on such state other than to return a value may lend themselves to
2931 optimizations such as common subexpression elimination.  Declaring such
2932 functions with the @code{const} attribute allows GCC to avoid emitting
2933 some calls in repeated invocations of the function with the same argument
2934 values.
2936 For example,
2938 @smallexample
2939 int square (int) __attribute__ ((const));
2940 @end smallexample
2942 @noindent
2943 tells GCC that subsequent calls to function @code{square} with the same
2944 argument value can be replaced by the result of the first call regardless
2945 of the statements in between.
2947 The @code{const} attribute prohibits a function from reading objects
2948 that affect its return value between successive invocations.  However,
2949 functions declared with the attribute can safely read objects that do
2950 not change their return value, such as non-volatile constants.
2952 The @code{const} attribute imposes greater restrictions on a function's
2953 definition than the similar @code{pure} attribute.  Declaring the same
2954 function with both the @code{const} and the @code{pure} attribute is
2955 diagnosed.  Because a const function cannot have any observable side
2956 effects it does not make sense for it to return @code{void}.  Declaring
2957 such a function is diagnosed.
2959 @cindex pointer arguments
2960 Note that a function that has pointer arguments and examines the data
2961 pointed to must @emph{not} be declared @code{const} if the pointed-to
2962 data might change between successive invocations of the function.  In
2963 general, since a function cannot distinguish data that might change
2964 from data that cannot, const functions should never take pointer or,
2965 in C++, reference arguments. Likewise, a function that calls a non-const
2966 function usually must not be const itself.
2968 @cindex @code{constructor} function attribute
2969 @cindex @code{destructor} function attribute
2970 @item constructor
2971 @itemx destructor
2972 @itemx constructor (@var{priority})
2973 @itemx destructor (@var{priority})
2974 The @code{constructor} attribute causes the function to be called
2975 automatically before execution enters @code{main ()}.  Similarly, the
2976 @code{destructor} attribute causes the function to be called
2977 automatically after @code{main ()} completes or @code{exit ()} is
2978 called.  Functions with these attributes are useful for
2979 initializing data that is used implicitly during the execution of
2980 the program.
2982 On some targets the attributes also accept an integer argument to
2983 specify a priority to control the order in which constructor and
2984 destructor functions are run.  A constructor
2985 with a smaller priority number runs before a constructor with a larger
2986 priority number; the opposite relationship holds for destructors.  Note
2987 that priorities 0-100 are reserved.  So, if you have a constructor that
2988 allocates a resource and a destructor that deallocates the same
2989 resource, both functions typically have the same priority.  The
2990 priorities for constructor and destructor functions are the same as
2991 those specified for namespace-scope C++ objects (@pxref{C++ Attributes}).
2992 However, at present, the order in which constructors for C++ objects
2993 with static storage duration and functions decorated with attribute
2994 @code{constructor} are invoked is unspecified. In mixed declarations,
2995 attribute @code{init_priority} can be used to impose a specific ordering.
2997 Using the argument forms of the @code{constructor} and @code{destructor}
2998 attributes on targets where the feature is not supported is rejected with
2999 an error.
3001 @cindex @code{copy} function attribute
3002 @item copy
3003 @itemx copy (@var{function})
3004 The @code{copy} attribute applies the set of attributes with which
3005 @var{function} has been declared to the declaration of the function
3006 to which the attribute is applied.  The attribute is designed for
3007 libraries that define aliases or function resolvers that are expected
3008 to specify the same set of attributes as their targets.  The @code{copy}
3009 attribute can be used with functions, variables, or types.  However,
3010 the kind of symbol to which the attribute is applied (either function
3011 or variable) must match the kind of symbol to which the argument refers.
3012 The @code{copy} attribute copies only syntactic and semantic attributes
3013 but not attributes that affect a symbol's linkage or visibility such as
3014 @code{alias}, @code{visibility}, or @code{weak}.  The @code{deprecated}
3015 and @code{target_clones} attribute are also not copied.
3016 @xref{Common Type Attributes}.
3017 @xref{Common Variable Attributes}.
3019 For example, the @var{StrongAlias} macro below makes use of the @code{alias}
3020 and @code{copy} attributes to define an alias named @var{alloc} for function
3021 @var{allocate} declared with attributes @var{alloc_size}, @var{malloc}, and
3022 @var{nothrow}.  Thanks to the @code{__typeof__} operator the alias has
3023 the same type as the target function.  As a result of the @code{copy}
3024 attribute the alias also shares the same attributes as the target.
3026 @smallexample
3027 #define StrongAlias(TargetFunc, AliasDecl)  \
3028   extern __typeof__ (TargetFunc) AliasDecl  \
3029     __attribute__ ((alias (#TargetFunc), copy (TargetFunc)));
3031 extern __attribute__ ((alloc_size (1), malloc, nothrow))
3032   void* allocate (size_t);
3033 StrongAlias (allocate, alloc);
3034 @end smallexample
3036 @cindex @code{deprecated} function attribute
3037 @item deprecated
3038 @itemx deprecated (@var{msg})
3039 The @code{deprecated} attribute results in a warning if the function
3040 is used anywhere in the source file.  This is useful when identifying
3041 functions that are expected to be removed in a future version of a
3042 program.  The warning also includes the location of the declaration
3043 of the deprecated function, to enable users to easily find further
3044 information about why the function is deprecated, or what they should
3045 do instead.  Note that the warnings only occurs for uses:
3047 @smallexample
3048 int old_fn () __attribute__ ((deprecated));
3049 int old_fn ();
3050 int (*fn_ptr)() = old_fn;
3051 @end smallexample
3053 @noindent
3054 results in a warning on line 3 but not line 2.  The optional @var{msg}
3055 argument, which must be a string, is printed in the warning if
3056 present.
3058 The @code{deprecated} attribute can also be used for variables and
3059 types (@pxref{Variable Attributes}, @pxref{Type Attributes}.)
3061 The message attached to the attribute is affected by the setting of
3062 the @option{-fmessage-length} option.
3064 @cindex @code{error} function attribute
3065 @cindex @code{warning} function attribute
3066 @item error ("@var{message}")
3067 @itemx warning ("@var{message}")
3068 If the @code{error} or @code{warning} attribute 
3069 is used on a function declaration and a call to such a function
3070 is not eliminated through dead code elimination or other optimizations, 
3071 an error or warning (respectively) that includes @var{message} is diagnosed.  
3072 This is useful
3073 for compile-time checking, especially together with @code{__builtin_constant_p}
3074 and inline functions where checking the inline function arguments is not
3075 possible through @code{extern char [(condition) ? 1 : -1];} tricks.
3077 While it is possible to leave the function undefined and thus invoke
3078 a link failure (to define the function with
3079 a message in @code{.gnu.warning*} section),
3080 when using these attributes the problem is diagnosed
3081 earlier and with exact location of the call even in presence of inline
3082 functions or when not emitting debugging information.
3084 @cindex @code{expected_throw} function attribute
3085 @item expected_throw
3086 This attribute, attached to a function, tells the compiler the function
3087 is more likely to raise or propagate an exception than to return, loop
3088 forever, or terminate the program.
3090 This hint is mostly ignored by the compiler.  The only effect is when
3091 it's applied to @code{noreturn} functions and
3092 @samp{-fharden-control-flow-redundancy} is enabled, and
3093 @samp{-fhardcfr-check-noreturn-calls=not-always} is not overridden.
3095 @cindex @code{externally_visible} function attribute
3096 @item externally_visible
3097 This attribute, attached to a global variable or function, nullifies
3098 the effect of the @option{-fwhole-program} command-line option, so the
3099 object remains visible outside the current compilation unit.
3101 If @option{-fwhole-program} is used together with @option{-flto} and 
3102 @command{gold} is used as the linker plugin, 
3103 @code{externally_visible} attributes are automatically added to functions 
3104 (not variable yet due to a current @command{gold} issue) 
3105 that are accessed outside of LTO objects according to resolution file
3106 produced by @command{gold}.
3107 For other linkers that cannot generate resolution file,
3108 explicit @code{externally_visible} attributes are still necessary.
3110 @cindex @code{fd_arg} function attribute
3111 @item fd_arg
3112 @itemx fd_arg (@var{N})
3113 The @code{fd_arg} attribute may be applied to a function that takes an open
3114 file descriptor at referenced argument @var{N}.
3116 It indicates that the passed filedescriptor must not have been closed.
3117 Therefore, when the analyzer is enabled with @option{-fanalyzer}, the
3118 analyzer may emit a @option{-Wanalyzer-fd-use-after-close} diagnostic
3119 if it detects a code path in which a function with this attribute is
3120 called with a closed file descriptor.
3122 The attribute also indicates that the file descriptor must have been checked for
3123 validity before usage. Therefore, analyzer may emit
3124 @option{-Wanalyzer-fd-use-without-check} diagnostic if it detects a code path in
3125 which a function with this attribute is called with a file descriptor that has
3126 not been checked for validity.
3128 @cindex @code{fd_arg_read} function attribute
3129 @item fd_arg_read
3130 @itemx fd_arg_read (@var{N})
3131 The @code{fd_arg_read} is identical to @code{fd_arg}, but with the additional
3132 requirement that it might read from the file descriptor, and thus, the file
3133 descriptor must not have been opened as write-only.
3135 The analyzer may emit a @option{-Wanalyzer-access-mode-mismatch}
3136 diagnostic if it detects a code path in which a function with this
3137 attribute is called on a file descriptor opened with @code{O_WRONLY}.
3139 @cindex @code{fd_arg_write} function attribute
3140 @item fd_arg_write
3141 @itemx fd_arg_write (@var{N})
3142 The @code{fd_arg_write} is identical to @code{fd_arg_read} except that the
3143 analyzer may emit a @option{-Wanalyzer-access-mode-mismatch} diagnostic if
3144 it detects a code path in which a function with this attribute is called on a
3145 file descriptor opened with @code{O_RDONLY}.
3147 @cindex @code{flatten} function attribute
3148 @item flatten
3149 Generally, inlining into a function is limited.  For a function marked with
3150 this attribute, every call inside this function is inlined including the
3151 calls such inlining introduces to the function (but not recursive calls
3152 to the function itself), if possible.
3153 Functions declared with attribute @code{noinline} and similar are not
3154 inlined.  Whether the function itself is considered for inlining depends
3155 on its size and the current inlining parameters.
3157 @cindex @code{format} function attribute
3158 @cindex functions with @code{printf}, @code{scanf}, @code{strftime} or @code{strfmon} style arguments
3159 @opindex Wformat
3160 @item format (@var{archetype}, @var{string-index}, @var{first-to-check})
3161 The @code{format} attribute specifies that a function takes @code{printf},
3162 @code{scanf}, @code{strftime} or @code{strfmon} style arguments that
3163 should be type-checked against a format string.  For example, the
3164 declaration:
3166 @smallexample
3167 extern int
3168 my_printf (void *my_object, const char *my_format, ...)
3169       __attribute__ ((format (printf, 2, 3)));
3170 @end smallexample
3172 @noindent
3173 causes the compiler to check the arguments in calls to @code{my_printf}
3174 for consistency with the @code{printf} style format string argument
3175 @code{my_format}.
3177 The parameter @var{archetype} determines how the format string is
3178 interpreted, and should be @code{printf}, @code{scanf}, @code{strftime},
3179 @code{gnu_printf}, @code{gnu_scanf}, @code{gnu_strftime} or
3180 @code{strfmon}.  (You can also use @code{__printf__},
3181 @code{__scanf__}, @code{__strftime__} or @code{__strfmon__}.)  On
3182 MinGW targets, @code{ms_printf}, @code{ms_scanf}, and
3183 @code{ms_strftime} are also present.
3184 @var{archetype} values such as @code{printf} refer to the formats accepted
3185 by the system's C runtime library,
3186 while values prefixed with @samp{gnu_} always refer
3187 to the formats accepted by the GNU C Library.  On Microsoft Windows
3188 targets, values prefixed with @samp{ms_} refer to the formats accepted by the
3189 @file{msvcrt.dll} library.
3190 The parameter @var{string-index}
3191 specifies which argument is the format string argument (starting
3192 from 1), while @var{first-to-check} is the number of the first
3193 argument to check against the format string.  For functions
3194 where the arguments are not available to be checked (such as
3195 @code{vprintf}), specify the third parameter as zero.  In this case the
3196 compiler only checks the format string for consistency.  For
3197 @code{strftime} formats, the third parameter is required to be zero.
3198 Since non-static C++ methods have an implicit @code{this} argument, the
3199 arguments of such methods should be counted from two, not one, when
3200 giving values for @var{string-index} and @var{first-to-check}.
3202 In the example above, the format string (@code{my_format}) is the second
3203 argument of the function @code{my_print}, and the arguments to check
3204 start with the third argument, so the correct parameters for the format
3205 attribute are 2 and 3.
3207 @opindex ffreestanding
3208 @opindex fno-builtin
3209 The @code{format} attribute allows you to identify your own functions
3210 that take format strings as arguments, so that GCC can check the
3211 calls to these functions for errors.  The compiler always (unless
3212 @option{-ffreestanding} or @option{-fno-builtin} is used) checks formats
3213 for the standard library functions @code{printf}, @code{fprintf},
3214 @code{sprintf}, @code{scanf}, @code{fscanf}, @code{sscanf}, @code{strftime},
3215 @code{vprintf}, @code{vfprintf} and @code{vsprintf} whenever such
3216 warnings are requested (using @option{-Wformat}), so there is no need to
3217 modify the header file @file{stdio.h}.  In C99 mode, the functions
3218 @code{snprintf}, @code{vsnprintf}, @code{vscanf}, @code{vfscanf} and
3219 @code{vsscanf} are also checked.  Except in strictly conforming C
3220 standard modes, the X/Open function @code{strfmon} is also checked as
3221 are @code{printf_unlocked} and @code{fprintf_unlocked}.
3222 @xref{C Dialect Options,,Options Controlling C Dialect}.
3224 For Objective-C dialects, @code{NSString} (or @code{__NSString__}) is
3225 recognized in the same context.  Declarations including these format attributes
3226 are parsed for correct syntax, however the result of checking of such format
3227 strings is not yet defined, and is not carried out by this version of the
3228 compiler.
3230 The target may also provide additional types of format checks.
3231 @xref{Target Format Checks,,Format Checks Specific to Particular
3232 Target Machines}.
3234 @cindex @code{format_arg} function attribute
3235 @opindex Wformat-nonliteral
3236 @item format_arg (@var{string-index})
3237 The @code{format_arg} attribute specifies that a function takes one or
3238 more format strings for a @code{printf}, @code{scanf}, @code{strftime} or
3239 @code{strfmon} style function and modifies it (for example, to translate
3240 it into another language), so the result can be passed to a
3241 @code{printf}, @code{scanf}, @code{strftime} or @code{strfmon} style
3242 function (with the remaining arguments to the format function the same
3243 as they would have been for the unmodified string).  Multiple
3244 @code{format_arg} attributes may be applied to the same function, each
3245 designating a distinct parameter as a format string.  For example, the
3246 declaration:
3248 @smallexample
3249 extern char *
3250 my_dgettext (char *my_domain, const char *my_format)
3251       __attribute__ ((format_arg (2)));
3252 @end smallexample
3254 @noindent
3255 causes the compiler to check the arguments in calls to a @code{printf},
3256 @code{scanf}, @code{strftime} or @code{strfmon} type function, whose
3257 format string argument is a call to the @code{my_dgettext} function, for
3258 consistency with the format string argument @code{my_format}.  If the
3259 @code{format_arg} attribute had not been specified, all the compiler
3260 could tell in such calls to format functions would be that the format
3261 string argument is not constant; this would generate a warning when
3262 @option{-Wformat-nonliteral} is used, but the calls could not be checked
3263 without the attribute.
3265 In calls to a function declared with more than one @code{format_arg}
3266 attribute, each with a distinct argument value, the corresponding
3267 actual function arguments are checked against all format strings
3268 designated by the attributes.  This capability is designed to support
3269 the GNU @code{ngettext} family of functions.
3271 The parameter @var{string-index} specifies which argument is the format
3272 string argument (starting from one).  Since non-static C++ methods have
3273 an implicit @code{this} argument, the arguments of such methods should
3274 be counted from two.
3276 The @code{format_arg} attribute allows you to identify your own
3277 functions that modify format strings, so that GCC can check the
3278 calls to @code{printf}, @code{scanf}, @code{strftime} or @code{strfmon}
3279 type function whose operands are a call to one of your own function.
3280 The compiler always treats @code{gettext}, @code{dgettext}, and
3281 @code{dcgettext} in this manner except when strict ISO C support is
3282 requested by @option{-ansi} or an appropriate @option{-std} option, or
3283 @option{-ffreestanding} or @option{-fno-builtin}
3284 is used.  @xref{C Dialect Options,,Options
3285 Controlling C Dialect}.
3287 For Objective-C dialects, the @code{format-arg} attribute may refer to an
3288 @code{NSString} reference for compatibility with the @code{format} attribute
3289 above.
3291 The target may also allow additional types in @code{format-arg} attributes.
3292 @xref{Target Format Checks,,Format Checks Specific to Particular
3293 Target Machines}.
3295 @cindex @code{gnu_inline} function attribute
3296 @item gnu_inline
3297 This attribute should be used with a function that is also declared
3298 with the @code{inline} keyword.  It directs GCC to treat the function
3299 as if it were defined in gnu90 mode even when compiling in C99 or
3300 gnu99 mode.
3302 If the function is declared @code{extern}, then this definition of the
3303 function is used only for inlining.  In no case is the function
3304 compiled as a standalone function, not even if you take its address
3305 explicitly.  Such an address becomes an external reference, as if you
3306 had only declared the function, and had not defined it.  This has
3307 almost the effect of a macro.  The way to use this is to put a
3308 function definition in a header file with this attribute, and put
3309 another copy of the function, without @code{extern}, in a library
3310 file.  The definition in the header file causes most calls to the
3311 function to be inlined.  If any uses of the function remain, they
3312 refer to the single copy in the library.  Note that the two
3313 definitions of the functions need not be precisely the same, although
3314 if they do not have the same effect your program may behave oddly.
3316 In C, if the function is neither @code{extern} nor @code{static}, then
3317 the function is compiled as a standalone function, as well as being
3318 inlined where possible.
3320 This is how GCC traditionally handled functions declared
3321 @code{inline}.  Since ISO C99 specifies a different semantics for
3322 @code{inline}, this function attribute is provided as a transition
3323 measure and as a useful feature in its own right.  This attribute is
3324 available in GCC 4.1.3 and later.  It is available if either of the
3325 preprocessor macros @code{__GNUC_GNU_INLINE__} or
3326 @code{__GNUC_STDC_INLINE__} are defined.  @xref{Inline,,An Inline
3327 Function is As Fast As a Macro}.
3329 In C++, this attribute does not depend on @code{extern} in any way,
3330 but it still requires the @code{inline} keyword to enable its special
3331 behavior.
3333 @cindex @code{hot} function attribute
3334 @item hot
3335 The @code{hot} attribute on a function is used to inform the compiler that
3336 the function is a hot spot of the compiled program.  The function is
3337 optimized more aggressively and on many targets it is placed into a special
3338 subsection of the text section so all hot functions appear close together,
3339 improving locality.  In C++, the @code{hot} attribute can be applied to types
3340 with the effect of being propagated to member functions.  See
3341 @ref{C++ Attributes}.
3343 When profile feedback is available, via @option{-fprofile-use}, hot functions
3344 are automatically detected and this attribute is ignored.
3346 @cindex @code{ifunc} function attribute
3347 @cindex indirect functions
3348 @cindex functions that are dynamically resolved
3349 @item ifunc ("@var{resolver}")
3350 The @code{ifunc} attribute is used to mark a function as an indirect
3351 function using the STT_GNU_IFUNC symbol type extension to the ELF
3352 standard.  This allows the resolution of the symbol value to be
3353 determined dynamically at load time, and an optimized version of the
3354 routine to be selected for the particular processor or other system
3355 characteristics determined then.  To use this attribute, first define
3356 the implementation functions available, and a resolver function that
3357 returns a pointer to the selected implementation function.  The
3358 implementation functions' declarations must match the API of the
3359 function being implemented.  The resolver should be declared to
3360 be a function taking no arguments and returning a pointer to
3361 a function of the same type as the implementation.  For example:
3363 @smallexample
3364 void *my_memcpy (void *dst, const void *src, size_t len)
3366   @dots{}
3367   return dst;
3370 static void * (*resolve_memcpy (void))(void *, const void *, size_t)
3372   return my_memcpy; // we will just always select this routine
3374 @end smallexample
3376 @noindent
3377 The exported header file declaring the function the user calls would
3378 contain:
3380 @smallexample
3381 extern void *memcpy (void *, const void *, size_t);
3382 @end smallexample
3384 @noindent
3385 allowing the user to call @code{memcpy} as a regular function, unaware of
3386 the actual implementation.  Finally, the indirect function needs to be
3387 defined in the same translation unit as the resolver function:
3389 @smallexample
3390 void *memcpy (void *, const void *, size_t)
3391      __attribute__ ((ifunc ("resolve_memcpy")));
3392 @end smallexample
3394 In C++, the @code{ifunc} attribute takes a string that is the mangled name
3395 of the resolver function.  A C++ resolver for a non-static member function
3396 of class @code{C} should be declared to return a pointer to a non-member
3397 function taking pointer to @code{C} as the first argument, followed by
3398 the same arguments as of the implementation function.  G++ checks
3399 the signatures of the two functions and issues
3400 a @option{-Wattribute-alias} warning for mismatches.  To suppress a warning
3401 for the necessary cast from a pointer to the implementation member function
3402 to the type of the corresponding non-member function use
3403 the @option{-Wno-pmf-conversions} option.  For example:
3405 @smallexample
3406 class S
3408 private:
3409   int debug_impl (int);
3410   int optimized_impl (int);
3412   typedef int Func (S*, int);
3414   static Func* resolver ();
3415 public:
3417   int interface (int);
3420 int S::debug_impl (int) @{ /* @r{@dots{}} */ @}
3421 int S::optimized_impl (int) @{ /* @r{@dots{}} */ @}
3423 S::Func* S::resolver ()
3425   int (S::*pimpl) (int)
3426     = getenv ("DEBUG") ? &S::debug_impl : &S::optimized_impl;
3428   // Cast triggers -Wno-pmf-conversions.
3429   return reinterpret_cast<Func*>(pimpl);
3432 int S::interface (int) __attribute__ ((ifunc ("_ZN1S8resolverEv")));
3433 @end smallexample
3435 Indirect functions cannot be weak.  Binutils version 2.20.1 or higher
3436 and GNU C Library version 2.11.1 are required to use this feature.
3438 @cindex @code{interrupt_handler} function attribute
3439 @cindex @code{interrupt} function attribute
3440 @item interrupt
3441 @itemx interrupt_handler
3442 Many GCC back ends support attributes to indicate that a function is
3443 an interrupt handler, which tells the compiler to generate function
3444 entry and exit sequences that differ from those from regular
3445 functions.  The exact syntax and behavior are target-specific;
3446 refer to the following subsections for details.
3448 @cindex @code{leaf} function attribute
3449 @item leaf
3450 Calls to external functions with this attribute must return to the
3451 current compilation unit only by return or by exception handling.  In
3452 particular, a leaf function is not allowed to invoke callback functions
3453 passed to it from the current compilation unit, directly call functions
3454 exported by the unit, or @code{longjmp} into the unit.  Leaf functions
3455 might still call functions from other compilation units and thus they
3456 are not necessarily leaf in the sense that they contain no function
3457 calls at all.
3459 The attribute is intended for library functions to improve dataflow
3460 analysis.  The compiler takes the hint that any data not escaping the
3461 current compilation unit cannot be used or modified by the leaf
3462 function.  For example, the @code{sin} function is a leaf function, but
3463 @code{qsort} is not.
3465 Note that leaf functions might indirectly run a signal handler defined
3466 in the current compilation unit that uses static variables.  Similarly,
3467 when lazy symbol resolution is in effect, leaf functions might invoke
3468 indirect functions whose resolver function or implementation function is
3469 defined in the current compilation unit and uses static variables.  There
3470 is no standard-compliant way to write such a signal handler, resolver
3471 function, or implementation function, and the best that you can do is to
3472 remove the @code{leaf} attribute or mark all such static variables
3473 @code{volatile}.  Lastly, for ELF-based systems that support symbol
3474 interposition, care should be taken that functions defined in the
3475 current compilation unit do not unexpectedly interpose other symbols
3476 based on the defined standards mode and defined feature test macros;
3477 otherwise an inadvertent callback would be added.
3479 The attribute has no effect on functions defined within the current
3480 compilation unit.  This is to allow easy merging of multiple compilation
3481 units into one, for example, by using the link-time optimization.  For
3482 this reason the attribute is not allowed on types to annotate indirect
3483 calls.
3485 @cindex @code{malloc} function attribute
3486 @cindex functions that behave like malloc
3487 @item malloc
3488 @item malloc (@var{deallocator})
3489 @item malloc (@var{deallocator}, @var{ptr-index})
3490 Attribute @code{malloc} indicates that a function is @code{malloc}-like,
3491 i.e., that the pointer @var{P} returned by the function cannot alias any
3492 other pointer valid when the function returns, and moreover no
3493 pointers to valid objects occur in any storage addressed by @var{P}. In
3494 addition, GCC predicts that a function with the attribute returns
3495 non-null in most cases.
3497 Independently, the form of the attribute with one or two arguments
3498 associates @code{deallocator} as a suitable deallocation function for
3499 pointers returned from the @code{malloc}-like function.  @var{ptr-index}
3500 denotes the positional argument to which when the pointer is passed in
3501 calls to @code{deallocator} has the effect of deallocating it.
3503 Using the attribute with no arguments is designed to improve optimization
3504 by relying on the aliasing property it implies.  Functions like @code{malloc}
3505 and @code{calloc} have this property because they return a pointer to
3506 uninitialized or zeroed-out, newly obtained storage.  However, functions
3507 like @code{realloc} do not have this property, as they may return pointers
3508 to storage containing pointers to existing objects.  Additionally, since
3509 all such functions are assumed to return null only infrequently, callers
3510 can be optimized based on that assumption.
3512 Associating a function with a @var{deallocator} helps detect calls to
3513 mismatched allocation and deallocation functions and diagnose them under
3514 the control of options such as @option{-Wmismatched-dealloc}.  It also
3515 makes it possible to diagnose attempts to deallocate objects that were not
3516 allocated dynamically, by @option{-Wfree-nonheap-object}.  To indicate
3517 that an allocation function both satisifies the nonaliasing property and
3518 has a deallocator associated with it, both the plain form of the attribute
3519 and the one with the @var{deallocator} argument must be used.  The same
3520 function can be both an allocator and a deallocator.  Since inlining one
3521 of the associated functions but not the other could result in apparent
3522 mismatches, this form of attribute @code{malloc} is not accepted on inline
3523 functions.  For the same reason, using the attribute prevents both
3524 the allocation and deallocation functions from being expanded inline.
3526 For example, besides stating that the functions return pointers that do
3527 not alias any others, the following declarations make @code{fclose}
3528 a suitable deallocator for pointers returned from all functions except
3529 @code{popen}, and @code{pclose} as the only suitable deallocator for
3530 pointers returned from @code{popen}.  The deallocator functions must
3531 be declared before they can be referenced in the attribute.
3533 @smallexample
3534 int fclose (FILE*);
3535 int pclose (FILE*);
3537 __attribute__ ((malloc, malloc (fclose, 1)))
3538   FILE* fdopen (int, const char*);
3539 __attribute__ ((malloc, malloc (fclose, 1)))
3540   FILE* fopen (const char*, const char*);
3541 __attribute__ ((malloc, malloc (fclose, 1)))
3542   FILE* fmemopen(void *, size_t, const char *);
3543 __attribute__ ((malloc, malloc (pclose, 1)))
3544   FILE* popen (const char*, const char*);
3545 __attribute__ ((malloc, malloc (fclose, 1)))
3546   FILE* tmpfile (void);
3547 @end smallexample
3549 The warnings guarded by @option{-fanalyzer} respect allocation and
3550 deallocation pairs marked with the @code{malloc}.  In particular:
3552 @itemize @bullet
3554 @item
3555 The analyzer emits a @option{-Wanalyzer-mismatching-deallocation}
3556 diagnostic if there is an execution path in which the result of an
3557 allocation call is passed to a different deallocator.
3559 @item
3560 The analyzer emits a @option{-Wanalyzer-double-free}
3561 diagnostic if there is an execution path in which a value is passed
3562 more than once to a deallocation call.
3564 @item
3565 The analyzer considers the possibility that an allocation function
3566 could fail and return null.  If there are
3567 execution paths in which an unchecked result of an allocation call is
3568 dereferenced or passed to a function requiring a non-null argument,
3569 it emits
3570 @option{-Wanalyzer-possible-null-dereference} and
3571 @option{-Wanalyzer-possible-null-argument} diagnostics.
3572 If the allocator always returns non-null, use
3573 @code{__attribute__ ((returns_nonnull))} to suppress these warnings.
3574 For example:
3575 @smallexample
3576 char *xstrdup (const char *)
3577   __attribute__((malloc (free), returns_nonnull));
3578 @end smallexample
3580 @item
3581 The analyzer emits a @option{-Wanalyzer-use-after-free}
3582 diagnostic if there is an execution path in which the memory passed
3583 by pointer to a deallocation call is used after the deallocation.
3585 @item
3586 The analyzer emits a @option{-Wanalyzer-malloc-leak} diagnostic if
3587 there is an execution path in which the result of an allocation call
3588 is leaked (without being passed to the deallocation function).
3590 @item
3591 The analyzer emits a @option{-Wanalyzer-free-of-non-heap} diagnostic
3592 if a deallocation function is used on a global or on-stack variable.
3594 @end itemize
3596 The analyzer assumes that deallocators can gracefully handle the null
3597 pointer.  If this is not the case, the deallocator can be marked with
3598 @code{__attribute__((nonnull))} so that @option{-fanalyzer} can emit
3599 a @option{-Wanalyzer-possible-null-argument} diagnostic for code paths
3600 in which the deallocator is called with null.
3602 @cindex @code{no_icf} function attribute
3603 @item no_icf
3604 This function attribute prevents a functions from being merged with another
3605 semantically equivalent function.
3607 @cindex @code{no_instrument_function} function attribute
3608 @opindex finstrument-functions
3609 @opindex p
3610 @opindex pg
3611 @item no_instrument_function
3612 If any of @option{-finstrument-functions}, @option{-p}, or @option{-pg} are 
3613 given, profiling function calls are
3614 generated at entry and exit of most user-compiled functions.
3615 Functions with this attribute are not so instrumented.
3617 @cindex @code{no_profile_instrument_function} function attribute
3618 @item no_profile_instrument_function
3619 The @code{no_profile_instrument_function} attribute on functions is used
3620 to inform the compiler that it should not process any profile feedback based
3621 optimization code instrumentation.
3623 @cindex @code{no_reorder} function attribute
3624 @item no_reorder
3625 Do not reorder functions or variables marked @code{no_reorder}
3626 against each other or top level assembler statements the executable.
3627 The actual order in the program will depend on the linker command
3628 line. Static variables marked like this are also not removed.
3629 This has a similar effect
3630 as the @option{-fno-toplevel-reorder} option, but only applies to the
3631 marked symbols.
3633 @cindex @code{no_sanitize} function attribute
3634 @item no_sanitize ("@var{sanitize_option}")
3635 The @code{no_sanitize} attribute on functions is used
3636 to inform the compiler that it should not do sanitization of any option
3637 mentioned in @var{sanitize_option}.  A list of values acceptable by
3638 the @option{-fsanitize} option can be provided.
3640 @smallexample
3641 void __attribute__ ((no_sanitize ("alignment", "object-size")))
3642 f () @{ /* @r{Do something.} */; @}
3643 void __attribute__ ((no_sanitize ("alignment,object-size")))
3644 g () @{ /* @r{Do something.} */; @}
3645 @end smallexample
3647 @cindex @code{no_sanitize_address} function attribute
3648 @item no_sanitize_address
3649 @itemx no_address_safety_analysis
3650 The @code{no_sanitize_address} attribute on functions is used
3651 to inform the compiler that it should not instrument memory accesses
3652 in the function when compiling with the @option{-fsanitize=address} option.
3653 The @code{no_address_safety_analysis} is a deprecated alias of the
3654 @code{no_sanitize_address} attribute, new code should use
3655 @code{no_sanitize_address}.
3657 @cindex @code{no_sanitize_thread} function attribute
3658 @item no_sanitize_thread
3659 The @code{no_sanitize_thread} attribute on functions is used
3660 to inform the compiler that it should not instrument memory accesses
3661 in the function when compiling with the @option{-fsanitize=thread} option.
3663 @cindex @code{no_sanitize_undefined} function attribute
3664 @item no_sanitize_undefined
3665 The @code{no_sanitize_undefined} attribute on functions is used
3666 to inform the compiler that it should not check for undefined behavior
3667 in the function when compiling with the @option{-fsanitize=undefined} option.
3669 @cindex @code{no_sanitize_coverage} function attribute
3670 @item no_sanitize_coverage
3671 The @code{no_sanitize_coverage} attribute on functions is used
3672 to inform the compiler that it should not do coverage-guided
3673 fuzzing code instrumentation (@option{-fsanitize-coverage}).
3675 @cindex @code{no_split_stack} function attribute
3676 @opindex fsplit-stack
3677 @item no_split_stack
3678 If @option{-fsplit-stack} is given, functions have a small
3679 prologue which decides whether to split the stack.  Functions with the
3680 @code{no_split_stack} attribute do not have that prologue, and thus
3681 may run with only a small amount of stack space available.
3683 @cindex @code{no_stack_limit} function attribute
3684 @item no_stack_limit
3685 This attribute locally overrides the @option{-fstack-limit-register}
3686 and @option{-fstack-limit-symbol} command-line options; it has the effect
3687 of disabling stack limit checking in the function it applies to.
3689 @cindex @code{no_stack_protector} function attribute
3690 @item no_stack_protector
3691 This attribute prevents stack protection code for the function.
3693 @cindex @code{noclone} function attribute
3694 @item noclone
3695 This function attribute prevents a function from being considered for
3696 cloning---a mechanism that produces specialized copies of functions
3697 and which is (currently) performed by interprocedural constant
3698 propagation.
3700 @cindex @code{noinline} function attribute
3701 @item noinline
3702 This function attribute prevents a function from being considered for
3703 inlining.  It also disables some other interprocedural optimizations; it's
3704 preferable to use the more comprehensive @code{noipa} attribute instead
3705 if that is your goal.
3707 @c Don't enumerate the optimizations by name here; we try to be
3708 @c future-compatible with this mechanism.
3709 Even if a function is declared with the @code{noinline} attribute,
3710 there are optimizations other than inlining that can cause calls to be
3711 optimized away if it does not have side effects, although the function
3712 call is live.  To keep such calls from being optimized away, put
3714 @smallexample
3715 asm ("");
3716 @end smallexample
3718 @noindent
3719 (@pxref{Extended Asm}) in the called function, to serve as a special
3720 side effect.
3722 @cindex @code{noipa} function attribute
3723 @item noipa
3724 Disable interprocedural optimizations between the function with this
3725 attribute and its callers, as if the body of the function is not available
3726 when optimizing callers and the callers are unavailable when optimizing
3727 the body.  This attribute implies @code{noinline}, @code{noclone} and
3728 @code{no_icf} attributes.    However, this attribute is not equivalent
3729 to a combination of other attributes, because its purpose is to suppress
3730 existing and future optimizations employing interprocedural analysis,
3731 including those that do not have an attribute suitable for disabling
3732 them individually.
3734 @cindex @code{nonnull} function attribute
3735 @cindex functions with non-null pointer arguments
3736 @item nonnull
3737 @itemx nonnull (@var{arg-index}, @dots{})
3738 The @code{nonnull} attribute may be applied to a function that takes at
3739 least one argument of a pointer type.  It indicates that the referenced
3740 arguments must be non-null pointers.  For instance, the declaration:
3742 @smallexample
3743 extern void *
3744 my_memcpy (void *dest, const void *src, size_t len)
3745         __attribute__((nonnull (1, 2)));
3746 @end smallexample
3748 @noindent
3749 informs the compiler that, in calls to @code{my_memcpy}, arguments
3750 @var{dest} and @var{src} must be non-null.
3752 The attribute has an effect both on functions calls and function definitions.
3754 For function calls:
3755 @itemize @bullet
3756 @item If the compiler determines that a null pointer is
3757 passed in an argument slot marked as non-null, and the
3758 @option{-Wnonnull} option is enabled, a warning is issued.
3759 @xref{Warning Options}.
3760 @item The @option{-fisolate-erroneous-paths-attribute} option can be
3761 specified to have GCC transform calls with null arguments to non-null
3762 functions into traps.  @xref{Optimize Options}.
3763 @item The compiler may also perform optimizations based on the
3764 knowledge that certain function arguments cannot be null.  These
3765 optimizations can be disabled by the
3766 @option{-fno-delete-null-pointer-checks} option. @xref{Optimize Options}.
3767 @end itemize
3769 For function definitions:
3770 @itemize @bullet
3771 @item If the compiler determines that a function parameter that is
3772 marked with nonnull is compared with null, and
3773 @option{-Wnonnull-compare} option is enabled, a warning is issued.
3774 @xref{Warning Options}.
3775 @item The compiler may also perform optimizations based on the
3776 knowledge that @code{nonnull} parameters cannot be null.  This can
3777 currently not be disabled other than by removing the nonnull
3778 attribute.
3779 @end itemize
3781 If no @var{arg-index} is given to the @code{nonnull} attribute,
3782 all pointer arguments are marked as non-null.  To illustrate, the
3783 following declaration is equivalent to the previous example:
3785 @smallexample
3786 extern void *
3787 my_memcpy (void *dest, const void *src, size_t len)
3788         __attribute__((nonnull));
3789 @end smallexample
3791 @cindex @code{noplt} function attribute
3792 @item noplt
3793 The @code{noplt} attribute is the counterpart to option @option{-fno-plt}.
3794 Calls to functions marked with this attribute in position-independent code
3795 do not use the PLT.
3797 @smallexample
3798 @group
3799 /* Externally defined function foo.  */
3800 int foo () __attribute__ ((noplt));
3803 main (/* @r{@dots{}} */)
3805   /* @r{@dots{}} */
3806   foo ();
3807   /* @r{@dots{}} */
3809 @end group
3810 @end smallexample
3812 The @code{noplt} attribute on function @code{foo}
3813 tells the compiler to assume that
3814 the function @code{foo} is externally defined and that the call to
3815 @code{foo} must avoid the PLT
3816 in position-independent code.
3818 In position-dependent code, a few targets also convert calls to
3819 functions that are marked to not use the PLT to use the GOT instead.
3821 @cindex @code{noreturn} function attribute
3822 @cindex functions that never return
3823 @item noreturn
3824 A few standard library functions, such as @code{abort} and @code{exit},
3825 cannot return.  GCC knows this automatically.  Some programs define
3826 their own functions that never return.  You can declare them
3827 @code{noreturn} to tell the compiler this fact.  For example,
3829 @smallexample
3830 @group
3831 void fatal () __attribute__ ((noreturn));
3833 void
3834 fatal (/* @r{@dots{}} */)
3836   /* @r{@dots{}} */ /* @r{Print error message.} */ /* @r{@dots{}} */
3837   exit (1);
3839 @end group
3840 @end smallexample
3842 The @code{noreturn} keyword tells the compiler to assume that
3843 @code{fatal} cannot return.  It can then optimize without regard to what
3844 would happen if @code{fatal} ever did return.  This makes slightly
3845 better code.  More importantly, it helps avoid spurious warnings of
3846 uninitialized variables.
3848 The @code{noreturn} keyword does not affect the exceptional path when that
3849 applies: a @code{noreturn}-marked function may still return to the caller
3850 by throwing an exception or calling @code{longjmp}.
3852 In order to preserve backtraces, GCC will never turn calls to
3853 @code{noreturn} functions into tail calls.
3855 Do not assume that registers saved by the calling function are
3856 restored before calling the @code{noreturn} function.
3858 It does not make sense for a @code{noreturn} function to have a return
3859 type other than @code{void}.
3861 @cindex @code{nothrow} function attribute
3862 @item nothrow
3863 The @code{nothrow} attribute is used to inform the compiler that a
3864 function cannot throw an exception.  For example, most functions in
3865 the standard C library can be guaranteed not to throw an exception
3866 with the notable exceptions of @code{qsort} and @code{bsearch} that
3867 take function pointer arguments.
3869 @cindex @code{null_terminated_string_arg} function attribute
3870 @item null_terminated_string_arg
3871 @itemx null_terminated_string_arg (@var{N})
3872 The @code{null_terminated_string_arg} attribute may be applied to a
3873 function that takes a @code{char *} or @code{const char *} at
3874 referenced argument @var{N}.
3876 It indicates that the passed argument must be a C-style null-terminated
3877 string.  Specifically, the presence of the attribute implies that, if
3878 the pointer is non-null, the function may scan through the referenced
3879 buffer looking for the first zero byte.
3881 In particular, when the analyzer is enabled (via @option{-fanalyzer}),
3882 if the pointer is non-null, it will simulate scanning for the first
3883 zero byte in the referenced buffer, and potentially emit
3884 @option{-Wanalyzer-use-of-uninitialized-value}
3885 or @option{-Wanalyzer-out-of-bounds} on improperly terminated buffers.
3887 For example, given the following:
3889 @smallexample
3890 char *example_1 (const char *p)
3891   __attribute__((null_terminated_string_arg (1)));
3892 @end smallexample
3894 the analyzer will check that any non-null pointers passed to the function
3895 are validly terminated.
3897 If the parameter must be non-null, it is appropriate to use both this
3898 attribute and the attribute @code{nonnull}, such as in:
3900 @smallexample
3901 extern char *example_2 (const char *p)
3902   __attribute__((null_terminated_string_arg (1),
3903                  nonnull (1)));
3904 @end smallexample
3906 See the @code{nonnull} attribute for more information and
3907 caveats.
3909 If the pointer argument is also referred to by an @code{access} attribute on the
3910 function with @var{access-mode} either @code{read_only} or @code{read_write}
3911 and the latter attribute has the optional @var{size-index} argument
3912 referring to a size argument, this expressses the maximum size of the access.
3913 For example, given:
3915 @smallexample
3916 extern char *example_fn (const char *p, size_t n)
3917   __attribute__((null_terminated_string_arg (1),
3918                  access (read_only, 1, 2),
3919                  nonnull (1)));
3920 @end smallexample
3922 the analyzer will require the first parameter to be non-null, and either
3923 be validly null-terminated, or validly readable up to the size specified by
3924 the second parameter.
3926 @cindex @code{optimize} function attribute
3927 @item optimize (@var{level}, @dots{})
3928 @item optimize (@var{string}, @dots{})
3929 The @code{optimize} attribute is used to specify that a function is to
3930 be compiled with different optimization options than specified on the
3931 command line.  The optimize attribute arguments of a function behave
3932 as if appended to the command-line.
3934 Valid arguments are constant non-negative integers and
3935 strings.  Each numeric argument specifies an optimization @var{level}.
3936 Each @var{string} argument consists of one or more comma-separated
3937 substrings.  Each substring that begins with the letter @code{O} refers
3938 to an optimization option such as @option{-O0} or @option{-Os}.  Other
3939 substrings are taken as suffixes to the @code{-f} prefix jointly
3940 forming the name of an optimization option.  @xref{Optimize Options}.
3942 @samp{#pragma GCC optimize} can be used to set optimization options
3943 for more than one function.  @xref{Function Specific Option Pragmas},
3944 for details about the pragma.
3946 Providing multiple strings as arguments separated by commas to specify
3947 multiple options is equivalent to separating the option suffixes with
3948 a comma (@samp{,}) within a single string.  Spaces are not permitted
3949 within the strings.
3951 Not every optimization option that starts with the @var{-f} prefix
3952 specified by the attribute necessarily has an effect on the function.
3953 The @code{optimize} attribute should be used for debugging purposes only.
3954 It is not suitable in production code.
3956 @cindex @code{patchable_function_entry} function attribute
3957 @cindex extra NOP instructions at the function entry point
3958 @item patchable_function_entry
3959 In case the target's text segment can be made writable at run time by
3960 any means, padding the function entry with a number of NOPs can be
3961 used to provide a universal tool for instrumentation.
3963 The @code{patchable_function_entry} function attribute can be used to
3964 change the number of NOPs to any desired value.  The two-value syntax
3965 is the same as for the command-line switch
3966 @option{-fpatchable-function-entry=N,M}, generating @var{N} NOPs, with
3967 the function entry point before the @var{M}th NOP instruction.
3968 @var{M} defaults to 0 if omitted e.g.@: function entry point is before
3969 the first NOP.
3971 If patchable function entries are enabled globally using the command-line
3972 option @option{-fpatchable-function-entry=N,M}, then you must disable
3973 instrumentation on all functions that are part of the instrumentation
3974 framework with the attribute @code{patchable_function_entry (0)}
3975 to prevent recursion.
3977 @cindex @code{pure} function attribute
3978 @cindex functions that have no side effects
3979 @item pure
3981 Calls to functions that have no observable effects on the state of
3982 the program other than to return a value may lend themselves to optimizations
3983 such as common subexpression elimination.  Declaring such functions with
3984 the @code{pure} attribute allows GCC to avoid emitting some calls in repeated
3985 invocations of the function with the same argument values.
3987 The @code{pure} attribute prohibits a function from modifying the state
3988 of the program that is observable by means other than inspecting
3989 the function's return value.  However, functions declared with the @code{pure}
3990 attribute can safely read any non-volatile objects, and modify the value of
3991 objects in a way that does not affect their return value or the observable
3992 state of the program.
3994 For example,
3996 @smallexample
3997 int hash (char *) __attribute__ ((pure));
3998 @end smallexample
4000 @noindent
4001 tells GCC that subsequent calls to the function @code{hash} with the same
4002 string can be replaced by the result of the first call provided the state
4003 of the program observable by @code{hash}, including the contents of the array
4004 itself, does not change in between.  Even though @code{hash} takes a non-const
4005 pointer argument it must not modify the array it points to, or any other object
4006 whose value the rest of the program may depend on.  However, the caller may
4007 safely change the contents of the array between successive calls to
4008 the function (doing so disables the optimization).  The restriction also
4009 applies to member objects referenced by the @code{this} pointer in C++
4010 non-static member functions.
4012 Some common examples of pure functions are @code{strlen} or @code{memcmp}.
4013 Interesting non-pure functions are functions with infinite loops or those
4014 depending on volatile memory or other system resource, that may change between
4015 consecutive calls (such as the standard C @code{feof} function in
4016 a multithreading environment).
4018 The @code{pure} attribute imposes similar but looser restrictions on
4019 a function's definition than the @code{const} attribute: @code{pure}
4020 allows the function to read any non-volatile memory, even if it changes
4021 in between successive invocations of the function.  Declaring the same
4022 function with both the @code{pure} and the @code{const} attribute is
4023 diagnosed.  Because a pure function cannot have any observable side
4024 effects it does not make sense for such a function to return @code{void}.
4025 Declaring such a function is diagnosed.
4027 @cindex @code{retain} function attribute
4028 @item retain
4029 For ELF targets that support the GNU or FreeBSD OSABIs, this attribute
4030 will save the function from linker garbage collection.  To support
4031 this behavior, functions that have not been placed in specific sections
4032 (e.g. by the @code{section} attribute, or the @code{-ffunction-sections}
4033 option), will be placed in new, unique sections.
4035 This additional functionality requires Binutils version 2.36 or later.
4037 @cindex @code{returns_nonnull} function attribute
4038 @item returns_nonnull
4039 The @code{returns_nonnull} attribute specifies that the function
4040 return value should be a non-null pointer.  For instance, the declaration:
4042 @smallexample
4043 extern void *
4044 mymalloc (size_t len) __attribute__((returns_nonnull));
4045 @end smallexample
4047 @noindent
4048 lets the compiler optimize callers based on the knowledge
4049 that the return value will never be null.
4051 @cindex @code{returns_twice} function attribute
4052 @cindex functions that return more than once
4053 @item returns_twice
4054 The @code{returns_twice} attribute tells the compiler that a function may
4055 return more than one time.  The compiler ensures that all registers
4056 are dead before calling such a function and emits a warning about
4057 the variables that may be clobbered after the second return from the
4058 function.  Examples of such functions are @code{setjmp} and @code{vfork}.
4059 The @code{longjmp}-like counterpart of such function, if any, might need
4060 to be marked with the @code{noreturn} attribute.
4062 @cindex @code{section} function attribute
4063 @cindex functions in arbitrary sections
4064 @item section ("@var{section-name}")
4065 Normally, the compiler places the code it generates in the @code{text} section.
4066 Sometimes, however, you need additional sections, or you need certain
4067 particular functions to appear in special sections.  The @code{section}
4068 attribute specifies that a function lives in a particular section.
4069 For example, the declaration:
4071 @smallexample
4072 extern void foobar (void) __attribute__ ((section ("bar")));
4073 @end smallexample
4075 @noindent
4076 puts the function @code{foobar} in the @code{bar} section.
4078 Some file formats do not support arbitrary sections so the @code{section}
4079 attribute is not available on all platforms.
4080 If you need to map the entire contents of a module to a particular
4081 section, consider using the facilities of the linker instead.
4083 @cindex @code{sentinel} function attribute
4084 @item sentinel
4085 @itemx sentinel (@var{position})
4086 This function attribute indicates that an argument in a call to the function
4087 is expected to be an explicit @code{NULL}.  The attribute is only valid on
4088 variadic functions.  By default, the sentinel is expected to be the last
4089 argument of the function call.  If the optional @var{position} argument
4090 is specified to the attribute, the sentinel must be located at
4091 @var{position} counting backwards from the end of the argument list.
4093 @smallexample
4094 __attribute__ ((sentinel))
4095 is equivalent to
4096 __attribute__ ((sentinel(0)))
4097 @end smallexample
4099 The attribute is automatically set with a position of 0 for the built-in
4100 functions @code{execl} and @code{execlp}.  The built-in function
4101 @code{execle} has the attribute set with a position of 1.
4103 A valid @code{NULL} in this context is defined as zero with any object
4104 pointer type.  If your system defines the @code{NULL} macro with
4105 an integer type then you need to add an explicit cast.  During
4106 installation GCC replaces the system @code{<stddef.h>} header with
4107 a copy that redefines NULL appropriately.
4109 The warnings for missing or incorrect sentinels are enabled with
4110 @option{-Wformat}.
4112 @cindex @code{simd} function attribute
4113 @item simd
4114 @itemx simd("@var{mask}")
4115 This attribute enables creation of one or more function versions that
4116 can process multiple arguments using SIMD instructions from a
4117 single invocation.  Specifying this attribute allows compiler to
4118 assume that such versions are available at link time (provided
4119 in the same or another translation unit).  Generated versions are
4120 target-dependent and described in the corresponding Vector ABI document.  For
4121 x86_64 target this document can be found
4122 @w{@uref{https://sourceware.org/glibc/wiki/libmvec?action=AttachFile&do=view&target=VectorABI.txt,here}}.
4124 The optional argument @var{mask} may have the value
4125 @code{notinbranch} or @code{inbranch},
4126 and instructs the compiler to generate non-masked or masked
4127 clones correspondingly. By default, all clones are generated.
4129 If the attribute is specified and @code{#pragma omp declare simd} is
4130 present on a declaration and the @option{-fopenmp} or @option{-fopenmp-simd}
4131 switch is specified, then the attribute is ignored.
4133 @cindex @code{stack_protect} function attribute
4134 @item stack_protect
4135 This attribute adds stack protection code to the function if 
4136 flags @option{-fstack-protector}, @option{-fstack-protector-strong}
4137 or @option{-fstack-protector-explicit} are set.
4139 @cindex @code{symver} function attribute
4140 @item symver ("@var{name2}@@@var{nodename}")
4141 On ELF targets this attribute creates a symbol version.  The @var{name2} part
4142 of the parameter is the actual name of the symbol by which it will be
4143 externally referenced.  The @code{nodename} portion should be the name of a
4144 node specified in the version script supplied to the linker when building a
4145 shared library.  Versioned symbol must be defined and must be exported with
4146 default visibility.
4148 @smallexample
4149 __attribute__ ((__symver__ ("foo@@VERS_1"))) int
4150 foo_v1 (void)
4153 @end smallexample
4155 Will produce a @code{.symver foo_v1, foo@@VERS_1} directive in the assembler
4156 output. 
4158 One can also define multiple version for a given symbol
4159 (starting from binutils 2.35).
4161 @smallexample
4162 __attribute__ ((__symver__ ("foo@@VERS_2"), __symver__ ("foo@@VERS_3")))
4163 int symver_foo_v1 (void)
4166 @end smallexample
4168 This example creates a symbol name @code{symver_foo_v1}
4169 which will be version @code{VERS_2} and @code{VERS_3} of @code{foo}.
4171 If you have an older release of binutils, then symbol alias needs to
4172 be used:
4174 @smallexample
4175 __attribute__ ((__symver__ ("foo@@VERS_2")))
4176 int foo_v1 (void)
4178   return 0;
4181 __attribute__ ((__symver__ ("foo@@VERS_3")))
4182 __attribute__ ((alias ("foo_v1")))
4183 int symver_foo_v1 (void);
4184 @end smallexample
4186 Finally if the parameter is @code{"@var{name2}@@@@@var{nodename}"} then in
4187 addition to creating a symbol version (as if
4188 @code{"@var{name2}@@@var{nodename}"} was used) the version will be also used
4189 to resolve @var{name2} by the linker.
4191 @cindex @code{tainted_args} function attribute
4192 @item tainted_args
4193 The @code{tainted_args} attribute is used to specify that a function is called
4194 in a way that requires sanitization of its arguments, such as a system
4195 call in an operating system kernel.  Such a function can be considered part
4196 of the ``attack surface'' of the program.  The attribute can be used both
4197 on function declarations, and on field declarations containing function
4198 pointers.  In the latter case, any function used as an initializer of
4199 such a callback field will be treated as being called with tainted
4200 arguments.
4202 The analyzer will pay particular attention to such functions when
4203 @option{-fanalyzer} is supplied, potentially issuing warnings guarded by
4204 @option{-Wanalyzer-tainted-allocation-size},
4205 @option{-Wanalyzer-tainted-array-index},
4206 @option{-Wanalyzer-tainted-divisor},
4207 @option{-Wanalyzer-tainted-offset},
4208 and @option{-Wanalyzer-tainted-size}.
4210 @cindex @code{target} function attribute
4211 @item target (@var{string}, @dots{})
4212 Multiple target back ends implement the @code{target} attribute
4213 to specify that a function is to
4214 be compiled with different target options than specified on the
4215 command line.  The original target command-line options are ignored.
4216 One or more strings can be provided as arguments.
4217 Each string consists of one or more comma-separated suffixes to
4218 the @code{-m} prefix jointly forming the name of a machine-dependent
4219 option.  @xref{Submodel Options,,Machine-Dependent Options}.
4221 The @code{target} attribute can be used for instance to have a function
4222 compiled with a different ISA (instruction set architecture) than the
4223 default.  @samp{#pragma GCC target} can be used to specify target-specific
4224 options for more than one function.  @xref{Function Specific Option Pragmas},
4225 for details about the pragma.
4227 For instance, on an x86, you could declare one function with the
4228 @code{target("sse4.1,arch=core2")} attribute and another with
4229 @code{target("sse4a,arch=amdfam10")}.  This is equivalent to
4230 compiling the first function with @option{-msse4.1} and
4231 @option{-march=core2} options, and the second function with
4232 @option{-msse4a} and @option{-march=amdfam10} options.  It is up to you
4233 to make sure that a function is only invoked on a machine that
4234 supports the particular ISA it is compiled for (for example by using
4235 @code{cpuid} on x86 to determine what feature bits and architecture
4236 family are used).
4238 @smallexample
4239 int core2_func (void) __attribute__ ((__target__ ("arch=core2")));
4240 int sse3_func (void) __attribute__ ((__target__ ("sse3")));
4241 @end smallexample
4243 Providing multiple strings as arguments separated by commas to specify
4244 multiple options is equivalent to separating the option suffixes with
4245 a comma (@samp{,}) within a single string.  Spaces are not permitted
4246 within the strings.
4248 The options supported are specific to each target; refer to @ref{x86
4249 Function Attributes}, @ref{PowerPC Function Attributes},
4250 @ref{ARM Function Attributes}, @ref{AArch64 Function Attributes},
4251 @ref{Nios II Function Attributes}, and @ref{S/390 Function Attributes}
4252 for details.
4254 @cindex @code{target_clones} function attribute
4255 @item target_clones (@var{options})
4256 The @code{target_clones} attribute is used to specify that a function
4257 be cloned into multiple versions compiled with different target options
4258 than specified on the command line.  The supported options and restrictions
4259 are the same as for @code{target} attribute.
4261 For instance, on an x86, you could compile a function with
4262 @code{target_clones("sse4.1,avx")}.  GCC creates two function clones,
4263 one compiled with @option{-msse4.1} and another with @option{-mavx}.
4265 On a PowerPC, you can compile a function with
4266 @code{target_clones("cpu=power9,default")}.  GCC will create two
4267 function clones, one compiled with @option{-mcpu=power9} and another
4268 with the default options.  GCC must be configured to use GLIBC 2.23 or
4269 newer in order to use the @code{target_clones} attribute.
4271 It also creates a resolver function (see
4272 the @code{ifunc} attribute above) that dynamically selects a clone
4273 suitable for current architecture.  The resolver is created only if there
4274 is a usage of a function with @code{target_clones} attribute.
4276 Note that any subsequent call of a function without @code{target_clone}
4277 from a @code{target_clone} caller will not lead to copying
4278 (target clone) of the called function.
4279 If you want to enforce such behaviour,
4280 we recommend declaring the calling function with the @code{flatten} attribute?
4282 @cindex @code{unavailable} function attribute
4283 @item unavailable
4284 @itemx unavailable (@var{msg})
4285 The @code{unavailable} attribute results in an error if the function
4286 is used anywhere in the source file.  This is useful when identifying
4287 functions that have been removed from a particular variation of an
4288 interface.  Other than emitting an error rather than a warning, the
4289 @code{unavailable} attribute behaves in the same manner as
4290 @code{deprecated}.
4292 The @code{unavailable} attribute can also be used for variables and
4293 types (@pxref{Variable Attributes}, @pxref{Type Attributes}.)
4295 @cindex @code{unused} function attribute
4296 @item unused
4297 This attribute, attached to a function, means that the function is meant
4298 to be possibly unused.  GCC does not produce a warning for this
4299 function.
4301 @cindex @code{used} function attribute
4302 @item used
4303 This attribute, attached to a function, means that code must be emitted
4304 for the function even if it appears that the function is not referenced.
4305 This is useful, for example, when the function is referenced only in
4306 inline assembly.
4308 When applied to a member function of a C++ class template, the
4309 attribute also means that the function is instantiated if the
4310 class itself is instantiated.
4312 @cindex @code{visibility} function attribute
4313 @item visibility ("@var{visibility_type}")
4314 This attribute affects the linkage of the declaration to which it is attached.
4315 It can be applied to variables (@pxref{Common Variable Attributes}) and types
4316 (@pxref{Common Type Attributes}) as well as functions.
4318 There are four supported @var{visibility_type} values: default,
4319 hidden, protected or internal visibility.
4321 @smallexample
4322 void __attribute__ ((visibility ("protected")))
4323 f () @{ /* @r{Do something.} */; @}
4324 int i __attribute__ ((visibility ("hidden")));
4325 @end smallexample
4327 The possible values of @var{visibility_type} correspond to the
4328 visibility settings in the ELF gABI.
4330 @table @code
4331 @c keep this list of visibilities in alphabetical order.
4333 @item default
4334 Default visibility is the normal case for the object file format.
4335 This value is available for the visibility attribute to override other
4336 options that may change the assumed visibility of entities.
4338 On ELF, default visibility means that the declaration is visible to other
4339 modules and, in shared libraries, means that the declared entity may be
4340 overridden.
4342 On Darwin, default visibility means that the declaration is visible to
4343 other modules.
4345 Default visibility corresponds to ``external linkage'' in the language.
4347 @item hidden
4348 Hidden visibility indicates that the entity declared has a new
4349 form of linkage, which we call ``hidden linkage''.  Two
4350 declarations of an object with hidden linkage refer to the same object
4351 if they are in the same shared object.
4353 @item internal
4354 Internal visibility is like hidden visibility, but with additional
4355 processor specific semantics.  Unless otherwise specified by the
4356 psABI, GCC defines internal visibility to mean that a function is
4357 @emph{never} called from another module.  Compare this with hidden
4358 functions which, while they cannot be referenced directly by other
4359 modules, can be referenced indirectly via function pointers.  By
4360 indicating that a function cannot be called from outside the module,
4361 GCC may for instance omit the load of a PIC register since it is known
4362 that the calling function loaded the correct value.
4364 @item protected
4365 Protected visibility is like default visibility except that it
4366 indicates that references within the defining module bind to the
4367 definition in that module.  That is, the declared entity cannot be
4368 overridden by another module.
4370 @end table
4372 All visibilities are supported on many, but not all, ELF targets
4373 (supported when the assembler supports the @samp{.visibility}
4374 pseudo-op).  Default visibility is supported everywhere.  Hidden
4375 visibility is supported on Darwin targets.
4377 The visibility attribute should be applied only to declarations that
4378 would otherwise have external linkage.  The attribute should be applied
4379 consistently, so that the same entity should not be declared with
4380 different settings of the attribute.
4382 In C++, the visibility attribute applies to types as well as functions
4383 and objects, because in C++ types have linkage.  A class must not have
4384 greater visibility than its non-static data member types and bases,
4385 and class members default to the visibility of their class.  Also, a
4386 declaration without explicit visibility is limited to the visibility
4387 of its type.
4389 In C++, you can mark member functions and static member variables of a
4390 class with the visibility attribute.  This is useful if you know a
4391 particular method or static member variable should only be used from
4392 one shared object; then you can mark it hidden while the rest of the
4393 class has default visibility.  Care must be taken to avoid breaking
4394 the One Definition Rule; for example, it is usually not useful to mark
4395 an inline method as hidden without marking the whole class as hidden.
4397 A C++ namespace declaration can also have the visibility attribute.
4399 @smallexample
4400 namespace nspace1 __attribute__ ((visibility ("protected")))
4401 @{ /* @r{Do something.} */; @}
4402 @end smallexample
4404 This attribute applies only to the particular namespace body, not to
4405 other definitions of the same namespace; it is equivalent to using
4406 @samp{#pragma GCC visibility} before and after the namespace
4407 definition (@pxref{Visibility Pragmas}).
4409 In C++, if a template argument has limited visibility, this
4410 restriction is implicitly propagated to the template instantiation.
4411 Otherwise, template instantiations and specializations default to the
4412 visibility of their template.
4414 If both the template and enclosing class have explicit visibility, the
4415 visibility from the template is used.
4417 @cindex @code{warn_unused_result} function attribute
4418 @item warn_unused_result
4419 The @code{warn_unused_result} attribute causes a warning to be emitted
4420 if a caller of the function with this attribute does not use its
4421 return value.  This is useful for functions where not checking
4422 the result is either a security problem or always a bug, such as
4423 @code{realloc}.
4425 @smallexample
4426 int fn () __attribute__ ((warn_unused_result));
4427 int foo ()
4429   if (fn () < 0) return -1;
4430   fn ();
4431   return 0;
4433 @end smallexample
4435 @noindent
4436 results in warning on line 5.
4438 @cindex @code{weak} function attribute
4439 @item weak
4440 The @code{weak} attribute causes a declaration of an external symbol
4441 to be emitted as a weak symbol rather than a global.  This is primarily
4442 useful in defining library functions that can be overridden in user code,
4443 though it can also be used with non-function declarations.  The overriding
4444 symbol must have the same type as the weak symbol.  In addition, if it
4445 designates a variable it must also have the same size and alignment as
4446 the weak symbol.  Weak symbols are supported for ELF targets, and also
4447 for a.out targets when using the GNU assembler and linker.
4449 @cindex @code{weakref} function attribute
4450 @item weakref
4451 @itemx weakref ("@var{target}")
4452 The @code{weakref} attribute marks a declaration as a weak reference.
4453 Without arguments, it should be accompanied by an @code{alias} attribute
4454 naming the target symbol.  Alternatively, @var{target} may be given as
4455 an argument to @code{weakref} itself, naming the target definition of
4456 the alias.  The @var{target} must have the same type as the declaration.
4457 In addition, if it designates a variable it must also have the same size
4458 and alignment as the declaration.  In either form of the declaration
4459 @code{weakref} implicitly marks the declared symbol as @code{weak}.  Without
4460 a @var{target} given as an argument to @code{weakref} or to @code{alias},
4461 @code{weakref} is equivalent to @code{weak} (in that case the declaration
4462 may be @code{extern}).
4464 @smallexample
4465 /* Given the declaration: */
4466 extern int y (void);
4468 /* the following... */
4469 static int x (void) __attribute__ ((weakref ("y")));
4471 /* is equivalent to... */
4472 static int x (void) __attribute__ ((weakref, alias ("y")));
4474 /* or, alternatively, to... */
4475 static int x (void) __attribute__ ((weakref));
4476 static int x (void) __attribute__ ((alias ("y")));
4477 @end smallexample
4479 A weak reference is an alias that does not by itself require a
4480 definition to be given for the target symbol.  If the target symbol is
4481 only referenced through weak references, then it becomes a @code{weak}
4482 undefined symbol.  If it is directly referenced, however, then such
4483 strong references prevail, and a definition is required for the
4484 symbol, not necessarily in the same translation unit.
4486 The effect is equivalent to moving all references to the alias to a
4487 separate translation unit, renaming the alias to the aliased symbol,
4488 declaring it as weak, compiling the two separate translation units and
4489 performing a link with relocatable output (i.e.@: @code{ld -r}) on them.
4491 A declaration to which @code{weakref} is attached and that is associated
4492 with a named @code{target} must be @code{static}.
4494 @cindex @code{zero_call_used_regs} function attribute
4495 @item zero_call_used_regs ("@var{choice}")
4497 The @code{zero_call_used_regs} attribute causes the compiler to zero
4498 a subset of all call-used registers@footnote{A ``call-used'' register
4499 is a register whose contents can be changed by a function call;
4500 therefore, a caller cannot assume that the register has the same contents
4501 on return from the function as it had before calling the function.  Such
4502 registers are also called ``call-clobbered'', ``caller-saved'', or
4503 ``volatile''.} at function return.
4504 This is used to increase program security by either mitigating
4505 Return-Oriented Programming (ROP) attacks or preventing information leakage
4506 through registers.
4508 In order to satisfy users with different security needs and control the
4509 run-time overhead at the same time, the @var{choice} parameter provides a
4510 flexible way to choose the subset of the call-used registers to be zeroed.
4511 The four basic values of @var{choice} are:
4513 @itemize @bullet
4514 @item
4515 @samp{skip} doesn't zero any call-used registers.
4517 @item
4518 @samp{used} only zeros call-used registers that are used in the function.
4519 A ``used'' register is one whose content has been set or referenced in
4520 the function.
4522 @item
4523 @samp{all} zeros all call-used registers.
4525 @item
4526 @samp{leafy} behaves like @samp{used} in a leaf function, and like
4527 @samp{all} in a nonleaf function.  This makes for leaner zeroing in leaf
4528 functions, where the set of used registers is known, and that may be
4529 enough for some purposes of register zeroing.
4530 @end itemize
4532 In addition to these three basic choices, it is possible to modify
4533 @samp{used}, @samp{all}, and @samp{leafy} as follows:
4535 @itemize @bullet
4536 @item
4537 Adding @samp{-gpr} restricts the zeroing to general-purpose registers.
4539 @item
4540 Adding @samp{-arg} restricts the zeroing to registers that can sometimes
4541 be used to pass function arguments.  This includes all argument registers
4542 defined by the platform's calling conversion, regardless of whether the
4543 function uses those registers for function arguments or not.
4544 @end itemize
4546 The modifiers can be used individually or together.  If they are used
4547 together, they must appear in the order above.
4549 The full list of @var{choice}s is therefore:
4551 @table @code
4552 @item skip
4553 doesn't zero any call-used register.
4555 @item used
4556 only zeros call-used registers that are used in the function.
4558 @item used-gpr
4559 only zeros call-used general purpose registers that are used in the function.
4561 @item used-arg
4562 only zeros call-used registers that are used in the function and pass arguments.
4564 @item used-gpr-arg
4565 only zeros call-used general purpose registers that are used in the function
4566 and pass arguments.
4568 @item all
4569 zeros all call-used registers.
4571 @item all-gpr
4572 zeros all call-used general purpose registers.
4574 @item all-arg
4575 zeros all call-used registers that pass arguments.
4577 @item all-gpr-arg
4578 zeros all call-used general purpose registers that pass
4579 arguments.
4581 @item leafy
4582 Same as @samp{used} in a leaf function, and same as @samp{all} in a
4583 nonleaf function.
4585 @item leafy-gpr
4586 Same as @samp{used-gpr} in a leaf function, and same as @samp{all-gpr}
4587 in a nonleaf function.
4589 @item leafy-arg
4590 Same as @samp{used-arg} in a leaf function, and same as @samp{all-arg}
4591 in a nonleaf function.
4593 @item leafy-gpr-arg
4594 Same as @samp{used-gpr-arg} in a leaf function, and same as
4595 @samp{all-gpr-arg} in a nonleaf function.
4597 @end table
4599 Of this list, @samp{used-arg}, @samp{used-gpr-arg}, @samp{all-arg},
4600 @samp{all-gpr-arg}, @samp{leafy-arg}, and @samp{leafy-gpr-arg} are
4601 mainly used for ROP mitigation.
4603 The default for the attribute is controlled by @option{-fzero-call-used-regs}.
4604 @end table
4606 @c This is the end of the target-independent attribute table
4608 @node AArch64 Function Attributes
4609 @subsection AArch64 Function Attributes
4611 The following target-specific function attributes are available for the
4612 AArch64 target.  For the most part, these options mirror the behavior of
4613 similar command-line options (@pxref{AArch64 Options}), but on a
4614 per-function basis.
4616 @table @code
4617 @cindex @code{general-regs-only} function attribute, AArch64
4618 @item general-regs-only
4619 Indicates that no floating-point or Advanced SIMD registers should be
4620 used when generating code for this function.  If the function explicitly
4621 uses floating-point code, then the compiler gives an error.  This is
4622 the same behavior as that of the command-line option
4623 @option{-mgeneral-regs-only}.
4625 @cindex @code{fix-cortex-a53-835769} function attribute, AArch64
4626 @item fix-cortex-a53-835769
4627 Indicates that the workaround for the Cortex-A53 erratum 835769 should be
4628 applied to this function.  To explicitly disable the workaround for this
4629 function specify the negated form: @code{no-fix-cortex-a53-835769}.
4630 This corresponds to the behavior of the command line options
4631 @option{-mfix-cortex-a53-835769} and @option{-mno-fix-cortex-a53-835769}.
4633 @cindex @code{cmodel=} function attribute, AArch64
4634 @item cmodel=
4635 Indicates that code should be generated for a particular code model for
4636 this function.  The behavior and permissible arguments are the same as
4637 for the command line option @option{-mcmodel=}.
4639 @cindex @code{strict-align} function attribute, AArch64
4640 @item strict-align
4641 @itemx no-strict-align
4642 @code{strict-align} indicates that the compiler should not assume that unaligned
4643 memory references are handled by the system.  To allow the compiler to assume
4644 that aligned memory references are handled by the system, the inverse attribute
4645 @code{no-strict-align} can be specified.  The behavior is same as for the
4646 command-line option @option{-mstrict-align} and @option{-mno-strict-align}.
4648 @cindex @code{omit-leaf-frame-pointer} function attribute, AArch64
4649 @item omit-leaf-frame-pointer
4650 Indicates that the frame pointer should be omitted for a leaf function call.
4651 To keep the frame pointer, the inverse attribute
4652 @code{no-omit-leaf-frame-pointer} can be specified.  These attributes have
4653 the same behavior as the command-line options @option{-momit-leaf-frame-pointer}
4654 and @option{-mno-omit-leaf-frame-pointer}.
4656 @cindex @code{tls-dialect=} function attribute, AArch64
4657 @item tls-dialect=
4658 Specifies the TLS dialect to use for this function.  The behavior and
4659 permissible arguments are the same as for the command-line option
4660 @option{-mtls-dialect=}.
4662 @cindex @code{arch=} function attribute, AArch64
4663 @item arch=
4664 Specifies the architecture version and architectural extensions to use
4665 for this function.  The behavior and permissible arguments are the same as
4666 for the @option{-march=} command-line option.
4668 @cindex @code{tune=} function attribute, AArch64
4669 @item tune=
4670 Specifies the core for which to tune the performance of this function.
4671 The behavior and permissible arguments are the same as for the @option{-mtune=}
4672 command-line option.
4674 @cindex @code{cpu=} function attribute, AArch64
4675 @item cpu=
4676 Specifies the core for which to tune the performance of this function and also
4677 whose architectural features to use.  The behavior and valid arguments are the
4678 same as for the @option{-mcpu=} command-line option.
4680 @cindex @code{sign-return-address} function attribute, AArch64
4681 @item sign-return-address
4682 Select the function scope on which return address signing will be applied.  The
4683 behavior and permissible arguments are the same as for the command-line option
4684 @option{-msign-return-address=}.  The default value is @code{none}.  This
4685 attribute is deprecated.  The @code{branch-protection} attribute should
4686 be used instead.
4688 @cindex @code{branch-protection} function attribute, AArch64
4689 @item branch-protection
4690 Select the function scope on which branch protection will be applied.  The
4691 behavior and permissible arguments are the same as for the command-line option
4692 @option{-mbranch-protection=}.  The default value is @code{none}.
4694 @cindex @code{outline-atomics} function attribute, AArch64
4695 @item outline-atomics
4696 Enable or disable calls to out-of-line helpers to implement atomic operations.
4697 This corresponds to the behavior of the command line options
4698 @option{-moutline-atomics} and @option{-mno-outline-atomics}.
4700 @end table
4702 The above target attributes can be specified as follows:
4704 @smallexample
4705 __attribute__((target("@var{attr-string}")))
4707 f (int a)
4709   return a + 5;
4711 @end smallexample
4713 where @code{@var{attr-string}} is one of the attribute strings specified above.
4715 Additionally, the architectural extension string may be specified on its
4716 own.  This can be used to turn on and off particular architectural extensions
4717 without having to specify a particular architecture version or core.  Example:
4719 @smallexample
4720 __attribute__((target("+crc+nocrypto")))
4722 foo (int a)
4724   return a + 5;
4726 @end smallexample
4728 In this example @code{target("+crc+nocrypto")} enables the @code{crc}
4729 extension and disables the @code{crypto} extension for the function @code{foo}
4730 without modifying an existing @option{-march=} or @option{-mcpu} option.
4732 Multiple target function attributes can be specified by separating them with
4733 a comma.  For example:
4734 @smallexample
4735 __attribute__((target("arch=armv8-a+crc+crypto,tune=cortex-a53")))
4737 foo (int a)
4739   return a + 5;
4741 @end smallexample
4743 is valid and compiles function @code{foo} for ARMv8-A with @code{crc}
4744 and @code{crypto} extensions and tunes it for @code{cortex-a53}.
4746 @subsubsection Inlining rules
4747 Specifying target attributes on individual functions or performing link-time
4748 optimization across translation units compiled with different target options
4749 can affect function inlining rules:
4751 In particular, a caller function can inline a callee function only if the
4752 architectural features available to the callee are a subset of the features
4753 available to the caller.
4754 For example: A function @code{foo} compiled with @option{-march=armv8-a+crc},
4755 or tagged with the equivalent @code{arch=armv8-a+crc} attribute,
4756 can inline a function @code{bar} compiled with @option{-march=armv8-a+nocrc}
4757 because the all the architectural features that function @code{bar} requires
4758 are available to function @code{foo}.  Conversely, function @code{bar} cannot
4759 inline function @code{foo}.
4761 Additionally inlining a function compiled with @option{-mstrict-align} into a
4762 function compiled without @code{-mstrict-align} is not allowed.
4763 However, inlining a function compiled without @option{-mstrict-align} into a
4764 function compiled with @option{-mstrict-align} is allowed.
4766 Note that CPU tuning options and attributes such as the @option{-mcpu=},
4767 @option{-mtune=} do not inhibit inlining unless the CPU specified by the
4768 @option{-mcpu=} option or the @code{cpu=} attribute conflicts with the
4769 architectural feature rules specified above.
4771 @node AMD GCN Function Attributes
4772 @subsection AMD GCN Function Attributes
4774 These function attributes are supported by the AMD GCN back end:
4776 @table @code
4777 @cindex @code{amdgpu_hsa_kernel} function attribute, AMD GCN
4778 @item amdgpu_hsa_kernel
4779 This attribute indicates that the corresponding function should be compiled as
4780 a kernel function, that is an entry point that can be invoked from the host
4781 via the HSA runtime library.  By default functions are only callable only from
4782 other GCN functions.
4784 This attribute is implicitly applied to any function named @code{main}, using
4785 default parameters.
4787 Kernel functions may return an integer value, which will be written to a
4788 conventional place within the HSA "kernargs" region.
4790 The attribute parameters configure what values are passed into the kernel
4791 function by the GPU drivers, via the initial register state.  Some values are
4792 used by the compiler, and therefore forced on.  Enabling other options may
4793 break assumptions in the compiler and/or run-time libraries.
4795 @table @code
4796 @item private_segment_buffer
4797 Set @code{enable_sgpr_private_segment_buffer} flag.  Always on (required to
4798 locate the stack).
4800 @item dispatch_ptr
4801 Set @code{enable_sgpr_dispatch_ptr} flag.  Always on (required to locate the
4802 launch dimensions).
4804 @item queue_ptr
4805 Set @code{enable_sgpr_queue_ptr} flag.  Always on (required to convert address
4806 spaces).
4808 @item kernarg_segment_ptr
4809 Set @code{enable_sgpr_kernarg_segment_ptr} flag.  Always on (required to
4810 locate the kernel arguments, "kernargs").
4812 @item dispatch_id
4813 Set @code{enable_sgpr_dispatch_id} flag.
4815 @item flat_scratch_init
4816 Set @code{enable_sgpr_flat_scratch_init} flag.
4818 @item private_segment_size
4819 Set @code{enable_sgpr_private_segment_size} flag.
4821 @item grid_workgroup_count_X
4822 Set @code{enable_sgpr_grid_workgroup_count_x} flag.  Always on (required to
4823 use OpenACC/OpenMP).
4825 @item grid_workgroup_count_Y
4826 Set @code{enable_sgpr_grid_workgroup_count_y} flag.
4828 @item grid_workgroup_count_Z
4829 Set @code{enable_sgpr_grid_workgroup_count_z} flag.
4831 @item workgroup_id_X
4832 Set @code{enable_sgpr_workgroup_id_x} flag.
4834 @item workgroup_id_Y
4835 Set @code{enable_sgpr_workgroup_id_y} flag.
4837 @item workgroup_id_Z
4838 Set @code{enable_sgpr_workgroup_id_z} flag.
4840 @item workgroup_info
4841 Set @code{enable_sgpr_workgroup_info} flag.
4843 @item private_segment_wave_offset
4844 Set @code{enable_sgpr_private_segment_wave_byte_offset} flag.  Always on
4845 (required to locate the stack).
4847 @item work_item_id_X
4848 Set @code{enable_vgpr_workitem_id} parameter.  Always on (can't be disabled).
4850 @item work_item_id_Y
4851 Set @code{enable_vgpr_workitem_id} parameter.  Always on (required to enable
4852 vectorization.)
4854 @item work_item_id_Z
4855 Set @code{enable_vgpr_workitem_id} parameter.  Always on (required to use
4856 OpenACC/OpenMP).
4858 @end table
4859 @end table
4861 @node ARC Function Attributes
4862 @subsection ARC Function Attributes
4864 These function attributes are supported by the ARC back end:
4866 @table @code
4867 @cindex @code{interrupt} function attribute, ARC
4868 @item interrupt
4869 Use this attribute to indicate
4870 that the specified function is an interrupt handler.  The compiler generates
4871 function entry and exit sequences suitable for use in an interrupt handler
4872 when this attribute is present.
4874 On the ARC, you must specify the kind of interrupt to be handled
4875 in a parameter to the interrupt attribute like this:
4877 @smallexample
4878 void f () __attribute__ ((interrupt ("ilink1")));
4879 @end smallexample
4881 Permissible values for this parameter are: @w{@code{ilink1}} and
4882 @w{@code{ilink2}} for ARCv1 architecture, and @w{@code{ilink}} and
4883 @w{@code{firq}} for ARCv2 architecture.
4885 @cindex @code{long_call} function attribute, ARC
4886 @cindex @code{medium_call} function attribute, ARC
4887 @cindex @code{short_call} function attribute, ARC
4888 @cindex indirect calls, ARC
4889 @item long_call
4890 @itemx medium_call
4891 @itemx short_call
4892 These attributes specify how a particular function is called.
4893 These attributes override the
4894 @option{-mlong-calls} and @option{-mmedium-calls} (@pxref{ARC Options})
4895 command-line switches and @code{#pragma long_calls} settings.
4897 For ARC, a function marked with the @code{long_call} attribute is
4898 always called using register-indirect jump-and-link instructions,
4899 thereby enabling the called function to be placed anywhere within the
4900 32-bit address space.  A function marked with the @code{medium_call}
4901 attribute will always be close enough to be called with an unconditional
4902 branch-and-link instruction, which has a 25-bit offset from
4903 the call site.  A function marked with the @code{short_call}
4904 attribute will always be close enough to be called with a conditional
4905 branch-and-link instruction, which has a 21-bit offset from
4906 the call site.
4908 @cindex @code{jli_always} function attribute, ARC
4909 @item jli_always
4910 Forces a particular function to be called using @code{jli}
4911 instruction.  The @code{jli} instruction makes use of a table stored
4912 into @code{.jlitab} section, which holds the location of the functions
4913 which are addressed using this instruction.
4915 @cindex @code{jli_fixed} function attribute, ARC
4916 @item jli_fixed
4917 Identical like the above one, but the location of the function in the
4918 @code{jli} table is known and given as an attribute parameter.
4920 @cindex @code{secure_call} function attribute, ARC
4921 @item secure_call
4922 This attribute allows one to mark secure-code functions that are
4923 callable from normal mode.  The location of the secure call function
4924 into the @code{sjli} table needs to be passed as argument.
4926 @cindex @code{naked} function attribute, ARC
4927 @item naked
4928 This attribute allows the compiler to construct the requisite function
4929 declaration, while allowing the body of the function to be assembly
4930 code.  The specified function will not have prologue/epilogue
4931 sequences generated by the compiler.  Only basic @code{asm} statements
4932 can safely be included in naked functions (@pxref{Basic Asm}).  While
4933 using extended @code{asm} or a mixture of basic @code{asm} and C code
4934 may appear to work, they cannot be depended upon to work reliably and
4935 are not supported.
4937 @end table
4939 @node ARM Function Attributes
4940 @subsection ARM Function Attributes
4942 These function attributes are supported for ARM targets:
4944 @table @code
4946 @cindex @code{general-regs-only} function attribute, ARM
4947 @item general-regs-only
4948 Indicates that no floating-point or Advanced SIMD registers should be
4949 used when generating code for this function.  If the function explicitly
4950 uses floating-point code, then the compiler gives an error.  This is
4951 the same behavior as that of the command-line option
4952 @option{-mgeneral-regs-only}.
4954 @cindex @code{interrupt} function attribute, ARM
4955 @item interrupt
4956 Use this attribute to indicate
4957 that the specified function is an interrupt handler.  The compiler generates
4958 function entry and exit sequences suitable for use in an interrupt handler
4959 when this attribute is present.
4961 You can specify the kind of interrupt to be handled by
4962 adding an optional parameter to the interrupt attribute like this:
4964 @smallexample
4965 void f () __attribute__ ((interrupt ("IRQ")));
4966 @end smallexample
4968 @noindent
4969 Permissible values for this parameter are: @code{IRQ}, @code{FIQ},
4970 @code{SWI}, @code{ABORT} and @code{UNDEF}.
4972 On ARMv7-M the interrupt type is ignored, and the attribute means the function
4973 may be called with a word-aligned stack pointer.
4975 @cindex @code{isr} function attribute, ARM
4976 @item isr
4977 Use this attribute on ARM to write Interrupt Service Routines. This is an
4978 alias to the @code{interrupt} attribute above.
4980 @cindex @code{long_call} function attribute, ARM
4981 @cindex @code{short_call} function attribute, ARM
4982 @cindex indirect calls, ARM
4983 @item long_call
4984 @itemx short_call
4985 These attributes specify how a particular function is called.
4986 These attributes override the
4987 @option{-mlong-calls} (@pxref{ARM Options})
4988 command-line switch and @code{#pragma long_calls} settings.  For ARM, the
4989 @code{long_call} attribute indicates that the function might be far
4990 away from the call site and require a different (more expensive)
4991 calling sequence.   The @code{short_call} attribute always places
4992 the offset to the function from the call site into the @samp{BL}
4993 instruction directly.
4995 @cindex @code{naked} function attribute, ARM
4996 @item naked
4997 This attribute allows the compiler to construct the
4998 requisite function declaration, while allowing the body of the
4999 function to be assembly code. The specified function will not have
5000 prologue/epilogue sequences generated by the compiler. Only basic
5001 @code{asm} statements can safely be included in naked functions
5002 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
5003 basic @code{asm} and C code may appear to work, they cannot be
5004 depended upon to work reliably and are not supported.
5006 @cindex @code{pcs} function attribute, ARM
5007 @item pcs
5009 The @code{pcs} attribute can be used to control the calling convention
5010 used for a function on ARM.  The attribute takes an argument that specifies
5011 the calling convention to use.
5013 When compiling using the AAPCS ABI (or a variant of it) then valid
5014 values for the argument are @code{"aapcs"} and @code{"aapcs-vfp"}.  In
5015 order to use a variant other than @code{"aapcs"} then the compiler must
5016 be permitted to use the appropriate co-processor registers (i.e., the
5017 VFP registers must be available in order to use @code{"aapcs-vfp"}).
5018 For example,
5020 @smallexample
5021 /* Argument passed in r0, and result returned in r0+r1.  */
5022 double f2d (float) __attribute__((pcs("aapcs")));
5023 @end smallexample
5025 Variadic functions always use the @code{"aapcs"} calling convention and
5026 the compiler rejects attempts to specify an alternative.
5028 @cindex @code{target} function attribute
5029 @item target (@var{options})
5030 As discussed in @ref{Common Function Attributes}, this attribute 
5031 allows specification of target-specific compilation options.
5033 On ARM, the following options are allowed:
5035 @table @samp
5036 @cindex @code{target("thumb")} function attribute, ARM
5037 @item thumb
5038 Force code generation in the Thumb (T16/T32) ISA, depending on the
5039 architecture level.
5041 @cindex @code{target("arm")} function attribute, ARM
5042 @item arm
5043 Force code generation in the ARM (A32) ISA.
5045 Functions from different modes can be inlined in the caller's mode.
5047 @cindex @code{target("fpu=")} function attribute, ARM
5048 @item fpu=
5049 Specifies the fpu for which to tune the performance of this function.
5050 The behavior and permissible arguments are the same as for the @option{-mfpu=}
5051 command-line option.
5053 @cindex @code{arch=} function attribute, ARM
5054 @item arch=
5055 Specifies the architecture version and architectural extensions to use
5056 for this function.  The behavior and permissible arguments are the same as
5057 for the @option{-march=} command-line option.
5059 The above target attributes can be specified as follows:
5061 @smallexample
5062 __attribute__((target("arch=armv8-a+crc")))
5064 f (int a)
5066   return a + 5;
5068 @end smallexample
5070 Additionally, the architectural extension string may be specified on its
5071 own.  This can be used to turn on and off particular architectural extensions
5072 without having to specify a particular architecture version or core.  Example:
5074 @smallexample
5075 __attribute__((target("+crc+nocrypto")))
5077 foo (int a)
5079   return a + 5;
5081 @end smallexample
5083 In this example @code{target("+crc+nocrypto")} enables the @code{crc}
5084 extension and disables the @code{crypto} extension for the function @code{foo}
5085 without modifying an existing @option{-march=} or @option{-mcpu} option.
5087 @end table
5089 @end table
5091 @node AVR Function Attributes
5092 @subsection AVR Function Attributes
5094 These function attributes are supported by the AVR back end:
5096 @table @code
5097 @cindex @code{signal} function attribute, AVR
5098 @cindex @code{interrupt} function attribute, AVR
5099 @item signal
5100 @itemx interrupt
5101 The function is an interrupt service routine (ISR).  The compiler generates
5102 function entry and exit sequences suitable for use in an interrupt handler
5103 when one of the attributes is present.
5105 The AVR hardware globally disables interrupts when an interrupt is executed.
5107 @itemize @bullet
5108 @item ISRs with the @code{signal} attribute do not re-enable interrupts.
5109 It is save to enable interrupts in a @code{signal} handler.
5110 This ``save'' only applies to the code
5111 generated by the compiler and not to the IRQ layout of the
5112 application which is responsibility of the application.
5114 @item ISRs with the @code{interrupt} attribute re-enable interrupts.
5115 The first instruction of the routine is a @code{SEI} instruction to
5116 globally enable interrupts.
5117 @end itemize
5119 The recommended way to use these attributes is by means of the
5120 @code{ISR} macro provided by @code{avr/interrupt.h} from
5121 @w{@uref{https://www.nongnu.org/avr-libc/user-manual/group__avr__interrupts.html,,AVR-LibC}}:
5122 @example
5123 #include <avr/interrupt.h>
5125 ISR (INT0_vect) // Uses the "signal" attribute.
5127     // Code
5130 ISR (ADC_vect, ISR_NOBLOCK) // Uses the "interrupt" attribute.
5132     // Code
5134 @end example
5136 When both @code{signal} and @code{interrupt} are specified for the same
5137 function, then @code{signal} is silently ignored.
5139 @cindex @code{naked} function attribute, AVR
5140 @item naked
5141 This attribute allows the compiler to construct the
5142 requisite function declaration, while allowing the body of the
5143 function to be assembly code. The specified function will not have
5144 prologue/epilogue sequences generated by the compiler. Only basic
5145 @code{asm} statements can safely be included in naked functions
5146 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
5147 basic @code{asm} and C code may appear to work, they cannot be
5148 depended upon to work reliably and are not supported.
5150 @cindex @code{no_gccisr} function attribute, AVR
5151 @item no_gccisr
5152 Do not use the @code{__gcc_isr}
5153 @uref{https://sourceware.org/binutils/docs/as/AVR-Pseudo-Instructions.html,pseudo instruction}
5154 in a function with
5155 the @code{interrupt} or @code{signal} attribute aka. interrupt
5156 service routine (ISR).
5157 Use this attribute if the preamble of the ISR prologue should always read
5158 @example
5159 push  __zero_reg__
5160 push  __tmp_reg__
5161 in    __tmp_reg__, __SREG__
5162 push  __tmp_reg__
5163 clr   __zero_reg__
5164 @end example
5165 and accordingly for the postamble of the epilogue --- no matter whether
5166 the mentioned registers are actually used in the ISR or not.
5167 Situations where you might want to use this attribute include:
5168 @itemize @bullet
5169 @item
5170 Code that (effectively) clobbers bits of @code{SREG} other than the
5171 @code{I}-flag by writing to the memory location of @code{SREG}.
5172 @item
5173 Code that uses inline assembler to jump to a different function which
5174 expects (parts of) the prologue code as outlined above to be present.
5175 @end itemize
5176 To disable @code{__gcc_isr} generation for the whole compilation unit,
5177 there is option @option{-mno-gas-isr-prologues}, @pxref{AVR Options}.
5179 @cindex @code{OS_main} function attribute, AVR
5180 @cindex @code{OS_task} function attribute, AVR
5181 @item OS_main
5182 @itemx OS_task
5183 On AVR, functions with the @code{OS_main} or @code{OS_task} attribute
5184 do not save/restore any call-saved register in their prologue/epilogue.
5186 The @code{OS_main} attribute can be used when there @emph{is
5187 guarantee} that interrupts are disabled at the time when the function
5188 is entered.  This saves resources when the stack pointer has to be
5189 changed to set up a frame for local variables.
5191 The @code{OS_task} attribute can be used when there is @emph{no
5192 guarantee} that interrupts are disabled at that time when the function
5193 is entered like for, e@.g@. task functions in a multi-threading operating
5194 system. In that case, changing the stack pointer register is
5195 guarded by save/clear/restore of the global interrupt enable flag.
5197 The differences to the @code{naked} function attribute are:
5198 @itemize @bullet
5199 @item @code{naked} functions do not have a return instruction whereas 
5200 @code{OS_main} and @code{OS_task} functions have a @code{RET} or
5201 @code{RETI} return instruction.
5202 @item @code{naked} functions do not set up a frame for local variables
5203 or a frame pointer whereas @code{OS_main} and @code{OS_task} do this
5204 as needed.
5205 @end itemize
5207 @end table
5209 @node Blackfin Function Attributes
5210 @subsection Blackfin Function Attributes
5212 These function attributes are supported by the Blackfin back end:
5214 @table @code
5216 @cindex @code{exception_handler} function attribute
5217 @cindex exception handler functions, Blackfin
5218 @item exception_handler
5219 Use this attribute on the Blackfin to indicate that the specified function
5220 is an exception handler.  The compiler generates function entry and
5221 exit sequences suitable for use in an exception handler when this
5222 attribute is present.
5224 @cindex @code{interrupt_handler} function attribute, Blackfin
5225 @item interrupt_handler
5226 Use this attribute to
5227 indicate that the specified function is an interrupt handler.  The compiler
5228 generates function entry and exit sequences suitable for use in an
5229 interrupt handler when this attribute is present.
5231 @cindex @code{kspisusp} function attribute, Blackfin
5232 @cindex User stack pointer in interrupts on the Blackfin
5233 @item kspisusp
5234 When used together with @code{interrupt_handler}, @code{exception_handler}
5235 or @code{nmi_handler}, code is generated to load the stack pointer
5236 from the USP register in the function prologue.
5238 @cindex @code{l1_text} function attribute, Blackfin
5239 @item l1_text
5240 This attribute specifies a function to be placed into L1 Instruction
5241 SRAM@. The function is put into a specific section named @code{.l1.text}.
5242 With @option{-mfdpic}, function calls with a such function as the callee
5243 or caller uses inlined PLT.
5245 @cindex @code{l2} function attribute, Blackfin
5246 @item l2
5247 This attribute specifies a function to be placed into L2
5248 SRAM. The function is put into a specific section named
5249 @code{.l2.text}. With @option{-mfdpic}, callers of such functions use
5250 an inlined PLT.
5252 @cindex indirect calls, Blackfin
5253 @cindex @code{longcall} function attribute, Blackfin
5254 @cindex @code{shortcall} function attribute, Blackfin
5255 @item longcall
5256 @itemx shortcall
5257 The @code{longcall} attribute
5258 indicates that the function might be far away from the call site and
5259 require a different (more expensive) calling sequence.  The
5260 @code{shortcall} attribute indicates that the function is always close
5261 enough for the shorter calling sequence to be used.  These attributes
5262 override the @option{-mlongcall} switch.
5264 @cindex @code{nesting} function attribute, Blackfin
5265 @cindex Allow nesting in an interrupt handler on the Blackfin processor
5266 @item nesting
5267 Use this attribute together with @code{interrupt_handler},
5268 @code{exception_handler} or @code{nmi_handler} to indicate that the function
5269 entry code should enable nested interrupts or exceptions.
5271 @cindex @code{nmi_handler} function attribute, Blackfin
5272 @cindex NMI handler functions on the Blackfin processor
5273 @item nmi_handler
5274 Use this attribute on the Blackfin to indicate that the specified function
5275 is an NMI handler.  The compiler generates function entry and
5276 exit sequences suitable for use in an NMI handler when this
5277 attribute is present.
5279 @cindex @code{saveall} function attribute, Blackfin
5280 @cindex save all registers on the Blackfin
5281 @item saveall
5282 Use this attribute to indicate that
5283 all registers except the stack pointer should be saved in the prologue
5284 regardless of whether they are used or not.
5285 @end table
5287 @node BPF Function Attributes
5288 @subsection BPF Function Attributes
5290 These function attributes are supported by the BPF back end:
5292 @table @code
5293 @cindex @code{kernel helper}, function attribute, BPF
5294 @item kernel_helper
5295 use this attribute to indicate the specified function declaration is a
5296 kernel helper.  The helper function is passed as an argument to the
5297 attribute.  Example:
5299 @smallexample
5300 int bpf_probe_read (void *dst, int size, const void *unsafe_ptr)
5301   __attribute__ ((kernel_helper (4)));
5302 @end smallexample
5304 @cindex @code{naked} function attribute, BPF
5305 @item naked
5306 This attribute allows the compiler to construct the requisite function
5307 declaration, while allowing the body of the function to be assembly
5308 code.  The specified function will not have prologue/epilogue
5309 sequences generated by the compiler.  Only basic @code{asm} statements
5310 can safely be included in naked functions (@pxref{Basic Asm}).  While
5311 using extended @code{asm} or a mixture of basic @code{asm} and C code
5312 may appear to work, they cannot be depended upon to work reliably and
5313 are not supported.
5314 @end table
5316 @node C-SKY Function Attributes
5317 @subsection C-SKY Function Attributes
5319 These function attributes are supported by the C-SKY back end:
5321 @table @code
5322 @cindex @code{interrupt} function attribute, C-SKY
5323 @cindex @code{isr} function attribute, C-SKY
5324 @item interrupt
5325 @itemx isr
5326 Use these attributes to indicate that the specified function
5327 is an interrupt handler.
5328 The compiler generates function entry and exit sequences suitable for
5329 use in an interrupt handler when either of these attributes are present.
5331 Use of these options requires the @option{-mistack} command-line option
5332 to enable support for the necessary interrupt stack instructions.  They
5333 are ignored with a warning otherwise.  @xref{C-SKY Options}.
5335 @cindex @code{naked} function attribute, C-SKY
5336 @item naked
5337 This attribute allows the compiler to construct the
5338 requisite function declaration, while allowing the body of the
5339 function to be assembly code. The specified function will not have
5340 prologue/epilogue sequences generated by the compiler. Only basic
5341 @code{asm} statements can safely be included in naked functions
5342 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
5343 basic @code{asm} and C code may appear to work, they cannot be
5344 depended upon to work reliably and are not supported.
5345 @end table
5348 @node Epiphany Function Attributes
5349 @subsection Epiphany Function Attributes
5351 These function attributes are supported by the Epiphany back end:
5353 @table @code
5354 @cindex @code{disinterrupt} function attribute, Epiphany
5355 @item disinterrupt
5356 This attribute causes the compiler to emit
5357 instructions to disable interrupts for the duration of the given
5358 function.
5360 @cindex @code{forwarder_section} function attribute, Epiphany
5361 @item forwarder_section
5362 This attribute modifies the behavior of an interrupt handler.
5363 The interrupt handler may be in external memory which cannot be
5364 reached by a branch instruction, so generate a local memory trampoline
5365 to transfer control.  The single parameter identifies the section where
5366 the trampoline is placed.
5368 @cindex @code{interrupt} function attribute, Epiphany
5369 @item interrupt
5370 Use this attribute to indicate
5371 that the specified function is an interrupt handler.  The compiler generates
5372 function entry and exit sequences suitable for use in an interrupt handler
5373 when this attribute is present.  It may also generate
5374 a special section with code to initialize the interrupt vector table.
5376 On Epiphany targets one or more optional parameters can be added like this:
5378 @smallexample
5379 void __attribute__ ((interrupt ("dma0, dma1"))) universal_dma_handler ();
5380 @end smallexample
5382 Permissible values for these parameters are: @w{@code{reset}},
5383 @w{@code{software_exception}}, @w{@code{page_miss}},
5384 @w{@code{timer0}}, @w{@code{timer1}}, @w{@code{message}},
5385 @w{@code{dma0}}, @w{@code{dma1}}, @w{@code{wand}} and @w{@code{swi}}.
5386 Multiple parameters indicate that multiple entries in the interrupt
5387 vector table should be initialized for this function, i.e.@: for each
5388 parameter @w{@var{name}}, a jump to the function is emitted in
5389 the section @w{ivt_entry_@var{name}}.  The parameter(s) may be omitted
5390 entirely, in which case no interrupt vector table entry is provided.
5392 Note that interrupts are enabled inside the function
5393 unless the @code{disinterrupt} attribute is also specified.
5395 The following examples are all valid uses of these attributes on
5396 Epiphany targets:
5397 @smallexample
5398 void __attribute__ ((interrupt)) universal_handler ();
5399 void __attribute__ ((interrupt ("dma1"))) dma1_handler ();
5400 void __attribute__ ((interrupt ("dma0, dma1"))) 
5401   universal_dma_handler ();
5402 void __attribute__ ((interrupt ("timer0"), disinterrupt))
5403   fast_timer_handler ();
5404 void __attribute__ ((interrupt ("dma0, dma1"), 
5405                      forwarder_section ("tramp")))
5406   external_dma_handler ();
5407 @end smallexample
5409 @cindex @code{long_call} function attribute, Epiphany
5410 @cindex @code{short_call} function attribute, Epiphany
5411 @cindex indirect calls, Epiphany
5412 @item long_call
5413 @itemx short_call
5414 These attributes specify how a particular function is called.
5415 These attributes override the
5416 @option{-mlong-calls} (@pxref{Adapteva Epiphany Options})
5417 command-line switch and @code{#pragma long_calls} settings.
5418 @end table
5421 @node H8/300 Function Attributes
5422 @subsection H8/300 Function Attributes
5424 These function attributes are available for H8/300 targets:
5426 @table @code
5427 @cindex @code{function_vector} function attribute, H8/300
5428 @item function_vector
5429 Use this attribute on the H8/300, H8/300H, and H8S to indicate 
5430 that the specified function should be called through the function vector.
5431 Calling a function through the function vector reduces code size; however,
5432 the function vector has a limited size (maximum 128 entries on the H8/300
5433 and 64 entries on the H8/300H and H8S)
5434 and shares space with the interrupt vector.
5436 @cindex @code{interrupt_handler} function attribute, H8/300
5437 @item interrupt_handler
5438 Use this attribute on the H8/300, H8/300H, and H8S to
5439 indicate that the specified function is an interrupt handler.  The compiler
5440 generates function entry and exit sequences suitable for use in an
5441 interrupt handler when this attribute is present.
5443 @cindex @code{saveall} function attribute, H8/300
5444 @cindex save all registers on the H8/300, H8/300H, and H8S
5445 @item saveall
5446 Use this attribute on the H8/300, H8/300H, and H8S to indicate that
5447 all registers except the stack pointer should be saved in the prologue
5448 regardless of whether they are used or not.
5449 @end table
5451 @node IA-64 Function Attributes
5452 @subsection IA-64 Function Attributes
5454 These function attributes are supported on IA-64 targets:
5456 @table @code
5457 @cindex @code{syscall_linkage} function attribute, IA-64
5458 @item syscall_linkage
5459 This attribute is used to modify the IA-64 calling convention by marking
5460 all input registers as live at all function exits.  This makes it possible
5461 to restart a system call after an interrupt without having to save/restore
5462 the input registers.  This also prevents kernel data from leaking into
5463 application code.
5465 @cindex @code{version_id} function attribute, IA-64
5466 @item version_id
5467 This IA-64 HP-UX attribute, attached to a global variable or function, renames a
5468 symbol to contain a version string, thus allowing for function level
5469 versioning.  HP-UX system header files may use function level versioning
5470 for some system calls.
5472 @smallexample
5473 extern int foo () __attribute__((version_id ("20040821")));
5474 @end smallexample
5476 @noindent
5477 Calls to @code{foo} are mapped to calls to @code{foo@{20040821@}}.
5478 @end table
5480 @node M32C Function Attributes
5481 @subsection M32C Function Attributes
5483 These function attributes are supported by the M32C back end:
5485 @table @code
5486 @cindex @code{bank_switch} function attribute, M32C
5487 @item bank_switch
5488 When added to an interrupt handler with the M32C port, causes the
5489 prologue and epilogue to use bank switching to preserve the registers
5490 rather than saving them on the stack.
5492 @cindex @code{fast_interrupt} function attribute, M32C
5493 @item fast_interrupt
5494 Use this attribute on the M32C port to indicate that the specified
5495 function is a fast interrupt handler.  This is just like the
5496 @code{interrupt} attribute, except that @code{freit} is used to return
5497 instead of @code{reit}.
5499 @cindex @code{function_vector} function attribute, M16C/M32C
5500 @item function_vector
5501 On M16C/M32C targets, the @code{function_vector} attribute declares a
5502 special page subroutine call function. Use of this attribute reduces
5503 the code size by 2 bytes for each call generated to the
5504 subroutine. The argument to the attribute is the vector number entry
5505 from the special page vector table which contains the 16 low-order
5506 bits of the subroutine's entry address. Each vector table has special
5507 page number (18 to 255) that is used in @code{jsrs} instructions.
5508 Jump addresses of the routines are generated by adding 0x0F0000 (in
5509 case of M16C targets) or 0xFF0000 (in case of M32C targets), to the
5510 2-byte addresses set in the vector table. Therefore you need to ensure
5511 that all the special page vector routines should get mapped within the
5512 address range 0x0F0000 to 0x0FFFFF (for M16C) and 0xFF0000 to 0xFFFFFF
5513 (for M32C).
5515 In the following example 2 bytes are saved for each call to
5516 function @code{foo}.
5518 @smallexample
5519 void foo (void) __attribute__((function_vector(0x18)));
5520 void foo (void)
5524 void bar (void)
5526     foo();
5528 @end smallexample
5530 If functions are defined in one file and are called in another file,
5531 then be sure to write this declaration in both files.
5533 This attribute is ignored for R8C target.
5535 @cindex @code{interrupt} function attribute, M32C
5536 @item interrupt
5537 Use this attribute to indicate
5538 that the specified function is an interrupt handler.  The compiler generates
5539 function entry and exit sequences suitable for use in an interrupt handler
5540 when this attribute is present.
5541 @end table
5543 @node M32R/D Function Attributes
5544 @subsection M32R/D Function Attributes
5546 These function attributes are supported by the M32R/D back end:
5548 @table @code
5549 @cindex @code{interrupt} function attribute, M32R/D
5550 @item interrupt
5551 Use this attribute to indicate
5552 that the specified function is an interrupt handler.  The compiler generates
5553 function entry and exit sequences suitable for use in an interrupt handler
5554 when this attribute is present.
5556 @cindex @code{model} function attribute, M32R/D
5557 @cindex function addressability on the M32R/D
5558 @item model (@var{model-name})
5560 On the M32R/D, use this attribute to set the addressability of an
5561 object, and of the code generated for a function.  The identifier
5562 @var{model-name} is one of @code{small}, @code{medium}, or
5563 @code{large}, representing each of the code models.
5565 Small model objects live in the lower 16MB of memory (so that their
5566 addresses can be loaded with the @code{ld24} instruction), and are
5567 callable with the @code{bl} instruction.
5569 Medium model objects may live anywhere in the 32-bit address space (the
5570 compiler generates @code{seth/add3} instructions to load their addresses),
5571 and are callable with the @code{bl} instruction.
5573 Large model objects may live anywhere in the 32-bit address space (the
5574 compiler generates @code{seth/add3} instructions to load their addresses),
5575 and may not be reachable with the @code{bl} instruction (the compiler
5576 generates the much slower @code{seth/add3/jl} instruction sequence).
5577 @end table
5579 @node m68k Function Attributes
5580 @subsection m68k Function Attributes
5582 These function attributes are supported by the m68k back end:
5584 @table @code
5585 @cindex @code{interrupt} function attribute, m68k
5586 @cindex @code{interrupt_handler} function attribute, m68k
5587 @item interrupt
5588 @itemx interrupt_handler
5589 Use this attribute to
5590 indicate that the specified function is an interrupt handler.  The compiler
5591 generates function entry and exit sequences suitable for use in an
5592 interrupt handler when this attribute is present.  Either name may be used.
5594 @cindex @code{interrupt_thread} function attribute, fido
5595 @item interrupt_thread
5596 Use this attribute on fido, a subarchitecture of the m68k, to indicate
5597 that the specified function is an interrupt handler that is designed
5598 to run as a thread.  The compiler omits generate prologue/epilogue
5599 sequences and replaces the return instruction with a @code{sleep}
5600 instruction.  This attribute is available only on fido.
5601 @end table
5603 @node MCORE Function Attributes
5604 @subsection MCORE Function Attributes
5606 These function attributes are supported by the MCORE back end:
5608 @table @code
5609 @cindex @code{naked} function attribute, MCORE
5610 @item naked
5611 This attribute allows the compiler to construct the
5612 requisite function declaration, while allowing the body of the
5613 function to be assembly code. The specified function will not have
5614 prologue/epilogue sequences generated by the compiler. Only basic
5615 @code{asm} statements can safely be included in naked functions
5616 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
5617 basic @code{asm} and C code may appear to work, they cannot be
5618 depended upon to work reliably and are not supported.
5619 @end table
5621 @node MicroBlaze Function Attributes
5622 @subsection MicroBlaze Function Attributes
5624 These function attributes are supported on MicroBlaze targets:
5626 @table @code
5627 @cindex @code{save_volatiles} function attribute, MicroBlaze
5628 @item save_volatiles
5629 Use this attribute to indicate that the function is
5630 an interrupt handler.  All volatile registers (in addition to non-volatile
5631 registers) are saved in the function prologue.  If the function is a leaf
5632 function, only volatiles used by the function are saved.  A normal function
5633 return is generated instead of a return from interrupt.
5635 @cindex @code{break_handler} function attribute, MicroBlaze
5636 @cindex break handler functions
5637 @item break_handler
5638 Use this attribute to indicate that
5639 the specified function is a break handler.  The compiler generates function
5640 entry and exit sequences suitable for use in an break handler when this
5641 attribute is present. The return from @code{break_handler} is done through
5642 the @code{rtbd} instead of @code{rtsd}.
5644 @smallexample
5645 void f () __attribute__ ((break_handler));
5646 @end smallexample
5648 @cindex @code{interrupt_handler} function attribute, MicroBlaze
5649 @cindex @code{fast_interrupt} function attribute, MicroBlaze
5650 @item interrupt_handler
5651 @itemx fast_interrupt
5652 These attributes indicate that the specified function is an interrupt
5653 handler.  Use the @code{fast_interrupt} attribute to indicate handlers
5654 used in low-latency interrupt mode, and @code{interrupt_handler} for
5655 interrupts that do not use low-latency handlers.  In both cases, GCC
5656 emits appropriate prologue code and generates a return from the handler
5657 using @code{rtid} instead of @code{rtsd}.
5658 @end table
5660 @node Microsoft Windows Function Attributes
5661 @subsection Microsoft Windows Function Attributes
5663 The following attributes are available on Microsoft Windows and Symbian OS
5664 targets.
5666 @table @code
5667 @cindex @code{dllexport} function attribute
5668 @cindex @code{__declspec(dllexport)}
5669 @item dllexport
5670 On Microsoft Windows targets and Symbian OS targets the
5671 @code{dllexport} attribute causes the compiler to provide a global
5672 pointer to a pointer in a DLL, so that it can be referenced with the
5673 @code{dllimport} attribute.  On Microsoft Windows targets, the pointer
5674 name is formed by combining @code{_imp__} and the function or variable
5675 name.
5677 You can use @code{__declspec(dllexport)} as a synonym for
5678 @code{__attribute__ ((dllexport))} for compatibility with other
5679 compilers.
5681 On systems that support the @code{visibility} attribute, this
5682 attribute also implies ``default'' visibility.  It is an error to
5683 explicitly specify any other visibility.
5685 GCC's default behavior is to emit all inline functions with the
5686 @code{dllexport} attribute.  Since this can cause object file-size bloat,
5687 you can use @option{-fno-keep-inline-dllexport}, which tells GCC to
5688 ignore the attribute for inlined functions unless the 
5689 @option{-fkeep-inline-functions} flag is used instead.
5691 The attribute is ignored for undefined symbols.
5693 When applied to C++ classes, the attribute marks defined non-inlined
5694 member functions and static data members as exports.  Static consts
5695 initialized in-class are not marked unless they are also defined
5696 out-of-class.
5698 For Microsoft Windows targets there are alternative methods for
5699 including the symbol in the DLL's export table such as using a
5700 @file{.def} file with an @code{EXPORTS} section or, with GNU ld, using
5701 the @option{--export-all} linker flag.
5703 @cindex @code{dllimport} function attribute
5704 @cindex @code{__declspec(dllimport)}
5705 @item dllimport
5706 On Microsoft Windows and Symbian OS targets, the @code{dllimport}
5707 attribute causes the compiler to reference a function or variable via
5708 a global pointer to a pointer that is set up by the DLL exporting the
5709 symbol.  The attribute implies @code{extern}.  On Microsoft Windows
5710 targets, the pointer name is formed by combining @code{_imp__} and the
5711 function or variable name.
5713 You can use @code{__declspec(dllimport)} as a synonym for
5714 @code{__attribute__ ((dllimport))} for compatibility with other
5715 compilers.
5717 On systems that support the @code{visibility} attribute, this
5718 attribute also implies ``default'' visibility.  It is an error to
5719 explicitly specify any other visibility.
5721 Currently, the attribute is ignored for inlined functions.  If the
5722 attribute is applied to a symbol @emph{definition}, an error is reported.
5723 If a symbol previously declared @code{dllimport} is later defined, the
5724 attribute is ignored in subsequent references, and a warning is emitted.
5725 The attribute is also overridden by a subsequent declaration as
5726 @code{dllexport}.
5728 When applied to C++ classes, the attribute marks non-inlined
5729 member functions and static data members as imports.  However, the
5730 attribute is ignored for virtual methods to allow creation of vtables
5731 using thunks.
5733 On the SH Symbian OS target the @code{dllimport} attribute also has
5734 another affect---it can cause the vtable and run-time type information
5735 for a class to be exported.  This happens when the class has a
5736 dllimported constructor or a non-inline, non-pure virtual function
5737 and, for either of those two conditions, the class also has an inline
5738 constructor or destructor and has a key function that is defined in
5739 the current translation unit.
5741 For Microsoft Windows targets the use of the @code{dllimport}
5742 attribute on functions is not necessary, but provides a small
5743 performance benefit by eliminating a thunk in the DLL@.  The use of the
5744 @code{dllimport} attribute on imported variables can be avoided by passing the
5745 @option{--enable-auto-import} switch to the GNU linker.  As with
5746 functions, using the attribute for a variable eliminates a thunk in
5747 the DLL@.
5749 One drawback to using this attribute is that a pointer to a
5750 @emph{variable} marked as @code{dllimport} cannot be used as a constant
5751 address. However, a pointer to a @emph{function} with the
5752 @code{dllimport} attribute can be used as a constant initializer; in
5753 this case, the address of a stub function in the import lib is
5754 referenced.  On Microsoft Windows targets, the attribute can be disabled
5755 for functions by setting the @option{-mnop-fun-dllimport} flag.
5756 @end table
5758 @node MIPS Function Attributes
5759 @subsection MIPS Function Attributes
5761 These function attributes are supported by the MIPS back end:
5763 @table @code
5764 @cindex @code{interrupt} function attribute, MIPS
5765 @item interrupt
5766 Use this attribute to indicate that the specified function is an interrupt
5767 handler.  The compiler generates function entry and exit sequences suitable
5768 for use in an interrupt handler when this attribute is present.
5769 An optional argument is supported for the interrupt attribute which allows
5770 the interrupt mode to be described.  By default GCC assumes the external
5771 interrupt controller (EIC) mode is in use, this can be explicitly set using
5772 @code{eic}.  When interrupts are non-masked then the requested Interrupt
5773 Priority Level (IPL) is copied to the current IPL which has the effect of only
5774 enabling higher priority interrupts.  To use vectored interrupt mode use
5775 the argument @code{vector=[sw0|sw1|hw0|hw1|hw2|hw3|hw4|hw5]}, this will change
5776 the behavior of the non-masked interrupt support and GCC will arrange to mask
5777 all interrupts from sw0 up to and including the specified interrupt vector.
5779 You can use the following attributes to modify the behavior
5780 of an interrupt handler:
5781 @table @code
5782 @cindex @code{use_shadow_register_set} function attribute, MIPS
5783 @item use_shadow_register_set
5784 Assume that the handler uses a shadow register set, instead of
5785 the main general-purpose registers.  An optional argument @code{intstack} is
5786 supported to indicate that the shadow register set contains a valid stack
5787 pointer.
5789 @cindex @code{keep_interrupts_masked} function attribute, MIPS
5790 @item keep_interrupts_masked
5791 Keep interrupts masked for the whole function.  Without this attribute,
5792 GCC tries to reenable interrupts for as much of the function as it can.
5794 @cindex @code{use_debug_exception_return} function attribute, MIPS
5795 @item use_debug_exception_return
5796 Return using the @code{deret} instruction.  Interrupt handlers that don't
5797 have this attribute return using @code{eret} instead.
5798 @end table
5800 You can use any combination of these attributes, as shown below:
5801 @smallexample
5802 void __attribute__ ((interrupt)) v0 ();
5803 void __attribute__ ((interrupt, use_shadow_register_set)) v1 ();
5804 void __attribute__ ((interrupt, keep_interrupts_masked)) v2 ();
5805 void __attribute__ ((interrupt, use_debug_exception_return)) v3 ();
5806 void __attribute__ ((interrupt, use_shadow_register_set,
5807                      keep_interrupts_masked)) v4 ();
5808 void __attribute__ ((interrupt, use_shadow_register_set,
5809                      use_debug_exception_return)) v5 ();
5810 void __attribute__ ((interrupt, keep_interrupts_masked,
5811                      use_debug_exception_return)) v6 ();
5812 void __attribute__ ((interrupt, use_shadow_register_set,
5813                      keep_interrupts_masked,
5814                      use_debug_exception_return)) v7 ();
5815 void __attribute__ ((interrupt("eic"))) v8 ();
5816 void __attribute__ ((interrupt("vector=hw3"))) v9 ();
5817 @end smallexample
5819 @cindex indirect calls, MIPS
5820 @cindex @code{long_call} function attribute, MIPS
5821 @cindex @code{short_call} function attribute, MIPS
5822 @cindex @code{near} function attribute, MIPS
5823 @cindex @code{far} function attribute, MIPS
5824 @item long_call
5825 @itemx short_call
5826 @itemx near
5827 @itemx far
5828 These attributes specify how a particular function is called on MIPS@.
5829 The attributes override the @option{-mlong-calls} (@pxref{MIPS Options})
5830 command-line switch.  The @code{long_call} and @code{far} attributes are
5831 synonyms, and cause the compiler to always call
5832 the function by first loading its address into a register, and then using
5833 the contents of that register.  The @code{short_call} and @code{near}
5834 attributes are synonyms, and have the opposite
5835 effect; they specify that non-PIC calls should be made using the more
5836 efficient @code{jal} instruction.
5838 @cindex @code{mips16} function attribute, MIPS
5839 @cindex @code{nomips16} function attribute, MIPS
5840 @item mips16
5841 @itemx nomips16
5843 On MIPS targets, you can use the @code{mips16} and @code{nomips16}
5844 function attributes to locally select or turn off MIPS16 code generation.
5845 A function with the @code{mips16} attribute is emitted as MIPS16 code,
5846 while MIPS16 code generation is disabled for functions with the
5847 @code{nomips16} attribute.  These attributes override the
5848 @option{-mips16} and @option{-mno-mips16} options on the command line
5849 (@pxref{MIPS Options}).
5851 When compiling files containing mixed MIPS16 and non-MIPS16 code, the
5852 preprocessor symbol @code{__mips16} reflects the setting on the command line,
5853 not that within individual functions.  Mixed MIPS16 and non-MIPS16 code
5854 may interact badly with some GCC extensions such as @code{__builtin_apply}
5855 (@pxref{Constructing Calls}).
5857 @cindex @code{micromips} function attribute
5858 @cindex @code{nomicromips} function attribute
5859 @item micromips, MIPS
5860 @itemx nomicromips, MIPS
5862 On MIPS targets, you can use the @code{micromips} and @code{nomicromips}
5863 function attributes to locally select or turn off microMIPS code generation.
5864 A function with the @code{micromips} attribute is emitted as microMIPS code,
5865 while microMIPS code generation is disabled for functions with the
5866 @code{nomicromips} attribute.  These attributes override the
5867 @option{-mmicromips} and @option{-mno-micromips} options on the command line
5868 (@pxref{MIPS Options}).
5870 When compiling files containing mixed microMIPS and non-microMIPS code, the
5871 preprocessor symbol @code{__mips_micromips} reflects the setting on the
5872 command line,
5873 not that within individual functions.  Mixed microMIPS and non-microMIPS code
5874 may interact badly with some GCC extensions such as @code{__builtin_apply}
5875 (@pxref{Constructing Calls}).
5877 @cindex @code{nocompression} function attribute, MIPS
5878 @item nocompression
5879 On MIPS targets, you can use the @code{nocompression} function attribute
5880 to locally turn off MIPS16 and microMIPS code generation.  This attribute
5881 overrides the @option{-mips16} and @option{-mmicromips} options on the
5882 command line (@pxref{MIPS Options}).
5884 @cindex @code{use_hazard_barrier_return} function attribute, MIPS
5885 @item use_hazard_barrier_return
5886 This function attribute instructs the compiler to generate a hazard barrier
5887 return that clears all execution and instruction hazards while returning,
5888 instead of generating a normal return instruction.
5890 @item code_readable
5891 @cindex @code{code_readable} function attribute, MIPS
5892 For MIPS targets that support PC-relative addressing modes, this attribute
5893 can be used to control how an object is addressed.  The attribute takes
5894 a single optional argument:
5896 @table @samp
5897 @item no
5898 The function should not read the instruction stream as data.
5899 @item yes
5900 The function can read the instruction stream as data.
5901 @item pcrel
5902 The function can read the instruction stream in a pc-relative mode.
5903 @end table
5905 If there is no argument supplied, the default of @code{"yes"} applies.
5906 @end table
5908 @node MSP430 Function Attributes
5909 @subsection MSP430 Function Attributes
5911 These function attributes are supported by the MSP430 back end:
5913 @table @code
5914 @cindex @code{critical} function attribute, MSP430
5915 @item critical
5916 Critical functions disable interrupts upon entry and restore the
5917 previous interrupt state upon exit.  Critical functions cannot also
5918 have the @code{naked}, @code{reentrant} or @code{interrupt} attributes.
5920 The MSP430 hardware ensures that interrupts are disabled on entry to
5921 @code{interrupt} functions, and restores the previous interrupt state
5922 on exit. The @code{critical} attribute is therefore redundant on
5923 @code{interrupt} functions.
5925 @cindex @code{interrupt} function attribute, MSP430
5926 @item interrupt
5927 Use this attribute to indicate
5928 that the specified function is an interrupt handler.  The compiler generates
5929 function entry and exit sequences suitable for use in an interrupt handler
5930 when this attribute is present.
5932 You can provide an argument to the interrupt
5933 attribute which specifies a name or number.  If the argument is a
5934 number it indicates the slot in the interrupt vector table (0 - 31) to
5935 which this handler should be assigned.  If the argument is a name it
5936 is treated as a symbolic name for the vector slot.  These names should
5937 match up with appropriate entries in the linker script.  By default
5938 the names @code{watchdog} for vector 26, @code{nmi} for vector 30 and
5939 @code{reset} for vector 31 are recognized.
5941 @cindex @code{naked} function attribute, MSP430
5942 @item naked
5943 This attribute allows the compiler to construct the
5944 requisite function declaration, while allowing the body of the
5945 function to be assembly code. The specified function will not have
5946 prologue/epilogue sequences generated by the compiler. Only basic
5947 @code{asm} statements can safely be included in naked functions
5948 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
5949 basic @code{asm} and C code may appear to work, they cannot be
5950 depended upon to work reliably and are not supported.
5952 @cindex @code{reentrant} function attribute, MSP430
5953 @item reentrant
5954 Reentrant functions disable interrupts upon entry and enable them
5955 upon exit.  Reentrant functions cannot also have the @code{naked}
5956 or @code{critical} attributes.  They can have the @code{interrupt}
5957 attribute.
5959 @cindex @code{wakeup} function attribute, MSP430
5960 @item wakeup
5961 This attribute only applies to interrupt functions.  It is silently
5962 ignored if applied to a non-interrupt function.  A wakeup interrupt
5963 function will rouse the processor from any low-power state that it
5964 might be in when the function exits.
5966 @cindex @code{lower} function attribute, MSP430
5967 @cindex @code{upper} function attribute, MSP430
5968 @cindex @code{either} function attribute, MSP430
5969 @item lower
5970 @itemx upper
5971 @itemx either
5972 On the MSP430 target these attributes can be used to specify whether
5973 the function or variable should be placed into low memory, high
5974 memory, or the placement should be left to the linker to decide.  The
5975 attributes are only significant if compiling for the MSP430X
5976 architecture in the large memory model.
5978 The attributes work in conjunction with a linker script that has been
5979 augmented to specify where to place sections with a @code{.lower} and
5980 a @code{.upper} prefix.  So, for example, as well as placing the
5981 @code{.data} section, the script also specifies the placement of a
5982 @code{.lower.data} and a @code{.upper.data} section.  The intention
5983 is that @code{lower} sections are placed into a small but easier to
5984 access memory region and the upper sections are placed into a larger, but
5985 slower to access, region.
5987 The @code{either} attribute is special.  It tells the linker to place
5988 the object into the corresponding @code{lower} section if there is
5989 room for it.  If there is insufficient room then the object is placed
5990 into the corresponding @code{upper} section instead.  Note that the
5991 placement algorithm is not very sophisticated.  It does not attempt to
5992 find an optimal packing of the @code{lower} sections.  It just makes
5993 one pass over the objects and does the best that it can.  Using the
5994 @option{-ffunction-sections} and @option{-fdata-sections} command-line
5995 options can help the packing, however, since they produce smaller,
5996 easier to pack regions.
5997 @end table
5999 @node NDS32 Function Attributes
6000 @subsection NDS32 Function Attributes
6002 These function attributes are supported by the NDS32 back end:
6004 @table @code
6005 @cindex @code{exception} function attribute
6006 @cindex exception handler functions, NDS32
6007 @item exception
6008 Use this attribute on the NDS32 target to indicate that the specified function
6009 is an exception handler.  The compiler will generate corresponding sections
6010 for use in an exception handler.
6012 @cindex @code{interrupt} function attribute, NDS32
6013 @item interrupt
6014 On NDS32 target, this attribute indicates that the specified function
6015 is an interrupt handler.  The compiler generates corresponding sections
6016 for use in an interrupt handler.  You can use the following attributes
6017 to modify the behavior:
6018 @table @code
6019 @cindex @code{nested} function attribute, NDS32
6020 @item nested
6021 This interrupt service routine is interruptible.
6022 @cindex @code{not_nested} function attribute, NDS32
6023 @item not_nested
6024 This interrupt service routine is not interruptible.
6025 @cindex @code{nested_ready} function attribute, NDS32
6026 @item nested_ready
6027 This interrupt service routine is interruptible after @code{PSW.GIE}
6028 (global interrupt enable) is set.  This allows interrupt service routine to
6029 finish some short critical code before enabling interrupts.
6030 @cindex @code{save_all} function attribute, NDS32
6031 @item save_all
6032 The system will help save all registers into stack before entering
6033 interrupt handler.
6034 @cindex @code{partial_save} function attribute, NDS32
6035 @item partial_save
6036 The system will help save caller registers into stack before entering
6037 interrupt handler.
6038 @end table
6040 @cindex @code{naked} function attribute, NDS32
6041 @item naked
6042 This attribute allows the compiler to construct the
6043 requisite function declaration, while allowing the body of the
6044 function to be assembly code. The specified function will not have
6045 prologue/epilogue sequences generated by the compiler. Only basic
6046 @code{asm} statements can safely be included in naked functions
6047 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
6048 basic @code{asm} and C code may appear to work, they cannot be
6049 depended upon to work reliably and are not supported.
6051 @cindex @code{reset} function attribute, NDS32
6052 @cindex reset handler functions
6053 @item reset
6054 Use this attribute on the NDS32 target to indicate that the specified function
6055 is a reset handler.  The compiler will generate corresponding sections
6056 for use in a reset handler.  You can use the following attributes
6057 to provide extra exception handling:
6058 @table @code
6059 @cindex @code{nmi} function attribute, NDS32
6060 @item nmi
6061 Provide a user-defined function to handle NMI exception.
6062 @cindex @code{warm} function attribute, NDS32
6063 @item warm
6064 Provide a user-defined function to handle warm reset exception.
6065 @end table
6066 @end table
6068 @node Nios II Function Attributes
6069 @subsection Nios II Function Attributes
6071 These function attributes are supported by the Nios II back end:
6073 @table @code
6074 @cindex @code{target} function attribute
6075 @item target (@var{options})
6076 As discussed in @ref{Common Function Attributes}, this attribute 
6077 allows specification of target-specific compilation options.
6079 When compiling for Nios II, the following options are allowed:
6081 @table @samp
6082 @cindex @code{target("custom-@var{insn}=@var{N}")} function attribute, Nios II
6083 @cindex @code{target("no-custom-@var{insn}")} function attribute, Nios II
6084 @item custom-@var{insn}=@var{N}
6085 @itemx no-custom-@var{insn}
6086 Each @samp{custom-@var{insn}=@var{N}} attribute locally enables use of a
6087 custom instruction with encoding @var{N} when generating code that uses 
6088 @var{insn}.  Similarly, @samp{no-custom-@var{insn}} locally inhibits use of
6089 the custom instruction @var{insn}.
6090 These target attributes correspond to the
6091 @option{-mcustom-@var{insn}=@var{N}} and @option{-mno-custom-@var{insn}}
6092 command-line options, and support the same set of @var{insn} keywords.
6093 @xref{Nios II Options}, for more information.
6095 @cindex @code{target("custom-fpu-cfg=@var{name}")} function attribute, Nios II
6096 @item custom-fpu-cfg=@var{name}
6097 This attribute corresponds to the @option{-mcustom-fpu-cfg=@var{name}}
6098 command-line option, to select a predefined set of custom instructions
6099 named @var{name}.
6100 @xref{Nios II Options}, for more information.
6101 @end table
6102 @end table
6104 @node Nvidia PTX Function Attributes
6105 @subsection Nvidia PTX Function Attributes
6107 These function attributes are supported by the Nvidia PTX back end:
6109 @table @code
6110 @cindex @code{kernel} attribute, Nvidia PTX
6111 @item kernel
6112 This attribute indicates that the corresponding function should be compiled
6113 as a kernel function, which can be invoked from the host via the CUDA RT 
6114 library.
6115 By default functions are only callable only from other PTX functions.
6117 Kernel functions must have @code{void} return type.
6118 @end table
6120 @node PowerPC Function Attributes
6121 @subsection PowerPC Function Attributes
6123 These function attributes are supported by the PowerPC back end:
6125 @table @code
6126 @cindex indirect calls, PowerPC
6127 @cindex @code{longcall} function attribute, PowerPC
6128 @cindex @code{shortcall} function attribute, PowerPC
6129 @item longcall
6130 @itemx shortcall
6131 The @code{longcall} attribute
6132 indicates that the function might be far away from the call site and
6133 require a different (more expensive) calling sequence.  The
6134 @code{shortcall} attribute indicates that the function is always close
6135 enough for the shorter calling sequence to be used.  These attributes
6136 override both the @option{-mlongcall} switch and
6137 the @code{#pragma longcall} setting.
6139 @xref{RS/6000 and PowerPC Options}, for more information on whether long
6140 calls are necessary.
6142 @cindex @code{target} function attribute
6143 @item target (@var{options})
6144 As discussed in @ref{Common Function Attributes}, this attribute 
6145 allows specification of target-specific compilation options.
6147 On the PowerPC, the following options are allowed:
6149 @table @samp
6150 @cindex @code{target("altivec")} function attribute, PowerPC
6151 @item altivec
6152 @itemx no-altivec
6153 Generate code that uses (does not use) AltiVec instructions.  In
6154 32-bit code, you cannot enable AltiVec instructions unless
6155 @option{-mabi=altivec} is used on the command line.
6157 @cindex @code{target("cmpb")} function attribute, PowerPC
6158 @item cmpb
6159 @itemx no-cmpb
6160 Generate code that uses (does not use) the compare bytes instruction
6161 implemented on the POWER6 processor and other processors that support
6162 the PowerPC V2.05 architecture.
6164 @cindex @code{target("dlmzb")} function attribute, PowerPC
6165 @item dlmzb
6166 @itemx no-dlmzb
6167 Generate code that uses (does not use) the string-search @samp{dlmzb}
6168 instruction on the IBM 405, 440, 464 and 476 processors.  This instruction is
6169 generated by default when targeting those processors.
6171 @cindex @code{target("fprnd")} function attribute, PowerPC
6172 @item fprnd
6173 @itemx no-fprnd
6174 Generate code that uses (does not use) the FP round to integer
6175 instructions implemented on the POWER5+ processor and other processors
6176 that support the PowerPC V2.03 architecture.
6178 @cindex @code{target("hard-dfp")} function attribute, PowerPC
6179 @item hard-dfp
6180 @itemx no-hard-dfp
6181 Generate code that uses (does not use) the decimal floating-point
6182 instructions implemented on some POWER processors.
6184 @cindex @code{target("isel")} function attribute, PowerPC
6185 @item isel
6186 @itemx no-isel
6187 Generate code that uses (does not use) ISEL instruction.
6189 @cindex @code{target("mfcrf")} function attribute, PowerPC
6190 @item mfcrf
6191 @itemx no-mfcrf
6192 Generate code that uses (does not use) the move from condition
6193 register field instruction implemented on the POWER4 processor and
6194 other processors that support the PowerPC V2.01 architecture.
6196 @cindex @code{target("mulhw")} function attribute, PowerPC
6197 @item mulhw
6198 @itemx no-mulhw
6199 Generate code that uses (does not use) the half-word multiply and
6200 multiply-accumulate instructions on the IBM 405, 440, 464 and 476 processors.
6201 These instructions are generated by default when targeting those
6202 processors.
6204 @cindex @code{target("multiple")} function attribute, PowerPC
6205 @item multiple
6206 @itemx no-multiple
6207 Generate code that uses (does not use) the load multiple word
6208 instructions and the store multiple word instructions.
6210 @cindex @code{target("update")} function attribute, PowerPC
6211 @item update
6212 @itemx no-update
6213 Generate code that uses (does not use) the load or store instructions
6214 that update the base register to the address of the calculated memory
6215 location.
6217 @cindex @code{target("popcntb")} function attribute, PowerPC
6218 @item popcntb
6219 @itemx no-popcntb
6220 Generate code that uses (does not use) the popcount and double-precision
6221 FP reciprocal estimate instruction implemented on the POWER5
6222 processor and other processors that support the PowerPC V2.02
6223 architecture.
6225 @cindex @code{target("popcntd")} function attribute, PowerPC
6226 @item popcntd
6227 @itemx no-popcntd
6228 Generate code that uses (does not use) the popcount instruction
6229 implemented on the POWER7 processor and other processors that support
6230 the PowerPC V2.06 architecture.
6232 @cindex @code{target("powerpc-gfxopt")} function attribute, PowerPC
6233 @item powerpc-gfxopt
6234 @itemx no-powerpc-gfxopt
6235 Generate code that uses (does not use) the optional PowerPC
6236 architecture instructions in the Graphics group, including
6237 floating-point select.
6239 @cindex @code{target("powerpc-gpopt")} function attribute, PowerPC
6240 @item powerpc-gpopt
6241 @itemx no-powerpc-gpopt
6242 Generate code that uses (does not use) the optional PowerPC
6243 architecture instructions in the General Purpose group, including
6244 floating-point square root.
6246 @cindex @code{target("recip-precision")} function attribute, PowerPC
6247 @item recip-precision
6248 @itemx no-recip-precision
6249 Assume (do not assume) that the reciprocal estimate instructions
6250 provide higher-precision estimates than is mandated by the PowerPC
6251 ABI.
6253 @cindex @code{target("string")} function attribute, PowerPC
6254 @item string
6255 @itemx no-string
6256 Generate code that uses (does not use) the load string instructions
6257 and the store string word instructions to save multiple registers and
6258 do small block moves.
6260 @cindex @code{target("vsx")} function attribute, PowerPC
6261 @item vsx
6262 @itemx no-vsx
6263 Generate code that uses (does not use) vector/scalar (VSX)
6264 instructions, and also enable the use of built-in functions that allow
6265 more direct access to the VSX instruction set.  In 32-bit code, you
6266 cannot enable VSX or AltiVec instructions unless
6267 @option{-mabi=altivec} is used on the command line.
6269 @cindex @code{target("friz")} function attribute, PowerPC
6270 @item friz
6271 @itemx no-friz
6272 Generate (do not generate) the @code{friz} instruction when the
6273 @option{-funsafe-math-optimizations} option is used to optimize
6274 rounding a floating-point value to 64-bit integer and back to floating
6275 point.  The @code{friz} instruction does not return the same value if
6276 the floating-point number is too large to fit in an integer.
6278 @cindex @code{target("avoid-indexed-addresses")} function attribute, PowerPC
6279 @item avoid-indexed-addresses
6280 @itemx no-avoid-indexed-addresses
6281 Generate code that tries to avoid (not avoid) the use of indexed load
6282 or store instructions.
6284 @cindex @code{target("paired")} function attribute, PowerPC
6285 @item paired
6286 @itemx no-paired
6287 Generate code that uses (does not use) the generation of PAIRED simd
6288 instructions.
6290 @cindex @code{target("longcall")} function attribute, PowerPC
6291 @item longcall
6292 @itemx no-longcall
6293 Generate code that assumes (does not assume) that all calls are far
6294 away so that a longer more expensive calling sequence is required.
6296 @cindex @code{target("cpu=@var{CPU}")} function attribute, PowerPC
6297 @item cpu=@var{CPU}
6298 Specify the architecture to generate code for when compiling the
6299 function.  If you select the @code{target("cpu=power7")} attribute when
6300 generating 32-bit code, VSX and AltiVec instructions are not generated
6301 unless you use the @option{-mabi=altivec} option on the command line.
6303 @cindex @code{target("tune=@var{TUNE}")} function attribute, PowerPC
6304 @item tune=@var{TUNE}
6305 Specify the architecture to tune for when compiling the function.  If
6306 you do not specify the @code{target("tune=@var{TUNE}")} attribute and
6307 you do specify the @code{target("cpu=@var{CPU}")} attribute,
6308 compilation tunes for the @var{CPU} architecture, and not the
6309 default tuning specified on the command line.
6310 @end table
6312 On the PowerPC, the inliner does not inline a
6313 function that has different target options than the caller, unless the
6314 callee has a subset of the target options of the caller.
6315 @end table
6317 @node RISC-V Function Attributes
6318 @subsection RISC-V Function Attributes
6320 These function attributes are supported by the RISC-V back end:
6322 @table @code
6323 @cindex @code{naked} function attribute, RISC-V
6324 @item naked
6325 This attribute allows the compiler to construct the
6326 requisite function declaration, while allowing the body of the
6327 function to be assembly code. The specified function will not have
6328 prologue/epilogue sequences generated by the compiler. Only basic
6329 @code{asm} statements can safely be included in naked functions
6330 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
6331 basic @code{asm} and C code may appear to work, they cannot be
6332 depended upon to work reliably and are not supported.
6334 @cindex @code{interrupt} function attribute, RISC-V
6335 @item interrupt
6336 Use this attribute to indicate that the specified function is an interrupt
6337 handler.  The compiler generates function entry and exit sequences suitable
6338 for use in an interrupt handler when this attribute is present.
6340 You can specify the kind of interrupt to be handled by adding an optional
6341 parameter to the interrupt attribute like this:
6343 @smallexample
6344 void f (void) __attribute__ ((interrupt ("user")));
6345 @end smallexample
6347 Permissible values for this parameter are @code{user}, @code{supervisor},
6348 and @code{machine}.  If there is no parameter, then it defaults to
6349 @code{machine}.
6351 @cindex @code{riscv_vector_cc} function attribute, RISC-V
6352 @item riscv_vector_cc
6353 Use this attribute to force the function to use the vector calling
6354 convention variant.
6356 @smallexample
6357 void foo() __attribute__((riscv_vector_cc));
6358 [[riscv::vector_cc]] void foo(); // For C++11 and C23
6359 @end smallexample
6361 @end table
6363 The following target-specific function attributes are available for the
6364 RISC-V target.  For the most part, these options mirror the behavior of
6365 similar command-line options (@pxref{RISC-V Options}), but on a
6366 per-function basis.
6368 @table @code
6369 @cindex @code{arch=} function attribute, RISC-V
6370 @item arch=
6371 Specifies the architecture version and architectural extensions to use
6372 for this function.  The behavior and permissible arguments are the same as
6373 for the @option{-march=} command-line option, in addtion, it also support
6374 extension enablement list, a list of extension name and prefixed with @code{+},
6375 like @code{arch=+zba} means enable @code{zba} extension.
6376 Multiple extension can be enabled by separating them with a comma.  For example:
6377 @code{arch=+zba,+zbb}.
6379 @cindex @code{tune=} function attribute, RISC-V
6380 @item tune=
6381 Specifies the core for which to tune the performance of this function.
6382 The behavior and permissible arguments are the same as for the @option{-mtune=}
6383 command-line option.
6385 @cindex @code{cpu=} function attribute, RISC-V
6386 @item cpu=
6387 Specifies the core for which to tune the performance of this function and also
6388 whose architectural features to use.  The behavior and valid arguments are the
6389 same as for the @option{-mcpu=} command-line option.
6391 @end table
6393 The above target attributes can be specified as follows:
6395 @smallexample
6396 __attribute__((target("@var{attr-string}")))
6398 f (int a)
6400   return a + 5;
6402 @end smallexample
6404 where @code{@var{attr-string}} is one of the attribute strings specified above.
6406 Multiple target function attributes can be specified by separating them with
6407 a semicolon.  For example:
6408 @smallexample
6409 __attribute__((target("arch=+zba,+zbb;tune=rocket")))
6411 foo (int a)
6413   return a + 5;
6415 @end smallexample
6417 is valid and compiles function @code{foo} with @code{zba}
6418 and @code{zbb} extensions and tunes it for @code{rocket}.
6420 @node RL78 Function Attributes
6421 @subsection RL78 Function Attributes
6423 These function attributes are supported by the RL78 back end:
6425 @table @code
6426 @cindex @code{interrupt} function attribute, RL78
6427 @cindex @code{brk_interrupt} function attribute, RL78
6428 @item interrupt
6429 @itemx brk_interrupt
6430 These attributes indicate
6431 that the specified function is an interrupt handler.  The compiler generates
6432 function entry and exit sequences suitable for use in an interrupt handler
6433 when this attribute is present.
6435 Use @code{brk_interrupt} instead of @code{interrupt} for
6436 handlers intended to be used with the @code{BRK} opcode (i.e.@: those
6437 that must end with @code{RETB} instead of @code{RETI}).
6439 @cindex @code{naked} function attribute, RL78
6440 @item naked
6441 This attribute allows the compiler to construct the
6442 requisite function declaration, while allowing the body of the
6443 function to be assembly code. The specified function will not have
6444 prologue/epilogue sequences generated by the compiler. Only basic
6445 @code{asm} statements can safely be included in naked functions
6446 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
6447 basic @code{asm} and C code may appear to work, they cannot be
6448 depended upon to work reliably and are not supported.
6449 @end table
6451 @node RX Function Attributes
6452 @subsection RX Function Attributes
6454 These function attributes are supported by the RX back end:
6456 @table @code
6457 @cindex @code{fast_interrupt} function attribute, RX
6458 @item fast_interrupt
6459 Use this attribute on the RX port to indicate that the specified
6460 function is a fast interrupt handler.  This is just like the
6461 @code{interrupt} attribute, except that @code{freit} is used to return
6462 instead of @code{reit}.
6464 @cindex @code{interrupt} function attribute, RX
6465 @item interrupt
6466 Use this attribute to indicate
6467 that the specified function is an interrupt handler.  The compiler generates
6468 function entry and exit sequences suitable for use in an interrupt handler
6469 when this attribute is present.
6471 On RX and RL78 targets, you may specify one or more vector numbers as arguments
6472 to the attribute, as well as naming an alternate table name.
6473 Parameters are handled sequentially, so one handler can be assigned to
6474 multiple entries in multiple tables.  One may also pass the magic
6475 string @code{"$default"} which causes the function to be used for any
6476 unfilled slots in the current table.
6478 This example shows a simple assignment of a function to one vector in
6479 the default table (note that preprocessor macros may be used for
6480 chip-specific symbolic vector names):
6481 @smallexample
6482 void __attribute__ ((interrupt (5))) txd1_handler ();
6483 @end smallexample
6485 This example assigns a function to two slots in the default table
6486 (using preprocessor macros defined elsewhere) and makes it the default
6487 for the @code{dct} table:
6488 @smallexample
6489 void __attribute__ ((interrupt (RXD1_VECT,RXD2_VECT,"dct","$default")))
6490         txd1_handler ();
6491 @end smallexample
6493 @cindex @code{naked} function attribute, RX
6494 @item naked
6495 This attribute allows the compiler to construct the
6496 requisite function declaration, while allowing the body of the
6497 function to be assembly code. The specified function will not have
6498 prologue/epilogue sequences generated by the compiler. Only basic
6499 @code{asm} statements can safely be included in naked functions
6500 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
6501 basic @code{asm} and C code may appear to work, they cannot be
6502 depended upon to work reliably and are not supported.
6504 @cindex @code{vector} function attribute, RX
6505 @item vector
6506 This RX attribute is similar to the @code{interrupt} attribute, including its
6507 parameters, but does not make the function an interrupt-handler type
6508 function (i.e.@: it retains the normal C function calling ABI).  See the
6509 @code{interrupt} attribute for a description of its arguments.
6510 @end table
6512 @node S/390 Function Attributes
6513 @subsection S/390 Function Attributes
6515 These function attributes are supported on the S/390:
6517 @table @code
6518 @cindex @code{hotpatch} function attribute, S/390
6519 @item hotpatch (@var{halfwords-before-function-label},@var{halfwords-after-function-label})
6521 On S/390 System z targets, you can use this function attribute to
6522 make GCC generate a ``hot-patching'' function prologue.  If the
6523 @option{-mhotpatch=} command-line option is used at the same time,
6524 the @code{hotpatch} attribute takes precedence.  The first of the
6525 two arguments specifies the number of halfwords to be added before
6526 the function label.  A second argument can be used to specify the
6527 number of halfwords to be added after the function label.  For
6528 both arguments the maximum allowed value is 1000000.
6530 If both arguments are zero, hotpatching is disabled.
6532 @cindex @code{target} function attribute
6533 @item target (@var{options})
6534 As discussed in @ref{Common Function Attributes}, this attribute
6535 allows specification of target-specific compilation options.
6537 On S/390, the following options are supported:
6539 @table @samp
6540 @item arch=
6541 @item tune=
6542 @item stack-guard=
6543 @item stack-size=
6544 @item branch-cost=
6545 @item warn-framesize=
6546 @item backchain
6547 @itemx no-backchain
6548 @item hard-dfp
6549 @itemx no-hard-dfp
6550 @item hard-float
6551 @itemx soft-float
6552 @item htm
6553 @itemx no-htm
6554 @item vx
6555 @itemx no-vx
6556 @item packed-stack
6557 @itemx no-packed-stack
6558 @item small-exec
6559 @itemx no-small-exec
6560 @item mvcle
6561 @itemx no-mvcle
6562 @item warn-dynamicstack
6563 @itemx no-warn-dynamicstack
6564 @end table
6566 The options work exactly like the S/390 specific command line
6567 options (without the prefix @option{-m}) except that they do not
6568 change any feature macros.  For example,
6570 @smallexample
6571 @code{target("no-vx")}
6572 @end smallexample
6574 does not undefine the @code{__VEC__} macro.
6575 @end table
6577 @node SH Function Attributes
6578 @subsection SH Function Attributes
6580 These function attributes are supported on the SH family of processors:
6582 @table @code
6583 @cindex @code{function_vector} function attribute, SH
6584 @cindex calling functions through the function vector on SH2A
6585 @item function_vector
6586 On SH2A targets, this attribute declares a function to be called using the
6587 TBR relative addressing mode.  The argument to this attribute is the entry
6588 number of the same function in a vector table containing all the TBR
6589 relative addressable functions.  For correct operation the TBR must be setup
6590 accordingly to point to the start of the vector table before any functions with
6591 this attribute are invoked.  Usually a good place to do the initialization is
6592 the startup routine.  The TBR relative vector table can have at max 256 function
6593 entries.  The jumps to these functions are generated using a SH2A specific,
6594 non delayed branch instruction JSR/N @@(disp8,TBR).  You must use GAS and GLD
6595 from GNU binutils version 2.7 or later for this attribute to work correctly.
6597 In an application, for a function being called once, this attribute
6598 saves at least 8 bytes of code; and if other successive calls are being
6599 made to the same function, it saves 2 bytes of code per each of these
6600 calls.
6602 @cindex @code{interrupt_handler} function attribute, SH
6603 @item interrupt_handler
6604 Use this attribute to
6605 indicate that the specified function is an interrupt handler.  The compiler
6606 generates function entry and exit sequences suitable for use in an
6607 interrupt handler when this attribute is present.
6609 @cindex @code{nosave_low_regs} function attribute, SH
6610 @item nosave_low_regs
6611 Use this attribute on SH targets to indicate that an @code{interrupt_handler}
6612 function should not save and restore registers R0..R7.  This can be used on SH3*
6613 and SH4* targets that have a second R0..R7 register bank for non-reentrant
6614 interrupt handlers.
6616 @cindex @code{renesas} function attribute, SH
6617 @item renesas
6618 On SH targets this attribute specifies that the function or struct follows the
6619 Renesas ABI.
6621 @cindex @code{resbank} function attribute, SH
6622 @item resbank
6623 On the SH2A target, this attribute enables the high-speed register
6624 saving and restoration using a register bank for @code{interrupt_handler}
6625 routines.  Saving to the bank is performed automatically after the CPU
6626 accepts an interrupt that uses a register bank.
6628 The nineteen 32-bit registers comprising general register R0 to R14,
6629 control register GBR, and system registers MACH, MACL, and PR and the
6630 vector table address offset are saved into a register bank.  Register
6631 banks are stacked in first-in last-out (FILO) sequence.  Restoration
6632 from the bank is executed by issuing a RESBANK instruction.
6634 @cindex @code{sp_switch} function attribute, SH
6635 @item sp_switch
6636 Use this attribute on the SH to indicate an @code{interrupt_handler}
6637 function should switch to an alternate stack.  It expects a string
6638 argument that names a global variable holding the address of the
6639 alternate stack.
6641 @smallexample
6642 void *alt_stack;
6643 void f () __attribute__ ((interrupt_handler,
6644                           sp_switch ("alt_stack")));
6645 @end smallexample
6647 @cindex @code{trap_exit} function attribute, SH
6648 @item trap_exit
6649 Use this attribute on the SH for an @code{interrupt_handler} to return using
6650 @code{trapa} instead of @code{rte}.  This attribute expects an integer
6651 argument specifying the trap number to be used.
6653 @cindex @code{trapa_handler} function attribute, SH
6654 @item trapa_handler
6655 On SH targets this function attribute is similar to @code{interrupt_handler}
6656 but it does not save and restore all registers.
6657 @end table
6659 @node Symbian OS Function Attributes
6660 @subsection Symbian OS Function Attributes
6662 @xref{Microsoft Windows Function Attributes}, for discussion of the
6663 @code{dllexport} and @code{dllimport} attributes.
6665 @node V850 Function Attributes
6666 @subsection V850 Function Attributes
6668 The V850 back end supports these function attributes:
6670 @table @code
6671 @cindex @code{interrupt} function attribute, V850
6672 @cindex @code{interrupt_handler} function attribute, V850
6673 @item interrupt
6674 @itemx interrupt_handler
6675 Use these attributes to indicate
6676 that the specified function is an interrupt handler.  The compiler generates
6677 function entry and exit sequences suitable for use in an interrupt handler
6678 when either attribute is present.
6679 @end table
6681 @node Visium Function Attributes
6682 @subsection Visium Function Attributes
6684 These function attributes are supported by the Visium back end:
6686 @table @code
6687 @cindex @code{interrupt} function attribute, Visium
6688 @item interrupt
6689 Use this attribute to indicate
6690 that the specified function is an interrupt handler.  The compiler generates
6691 function entry and exit sequences suitable for use in an interrupt handler
6692 when this attribute is present.
6693 @end table
6695 @node x86 Function Attributes
6696 @subsection x86 Function Attributes
6698 These function attributes are supported by the x86 back end:
6700 @table @code
6701 @cindex @code{cdecl} function attribute, x86-32
6702 @cindex functions that pop the argument stack on x86-32
6703 @opindex mrtd
6704 @item cdecl
6705 On the x86-32 targets, the @code{cdecl} attribute causes the compiler to
6706 assume that the calling function pops off the stack space used to
6707 pass arguments.  This is
6708 useful to override the effects of the @option{-mrtd} switch.
6710 @cindex @code{fastcall} function attribute, x86-32
6711 @cindex functions that pop the argument stack on x86-32
6712 @item fastcall
6713 On x86-32 targets, the @code{fastcall} attribute causes the compiler to
6714 pass the first argument (if of integral type) in the register ECX and
6715 the second argument (if of integral type) in the register EDX@.  Subsequent
6716 and other typed arguments are passed on the stack.  The called function
6717 pops the arguments off the stack.  If the number of arguments is variable all
6718 arguments are pushed on the stack.
6720 @cindex @code{thiscall} function attribute, x86-32
6721 @cindex functions that pop the argument stack on x86-32
6722 @item thiscall
6723 On x86-32 targets, the @code{thiscall} attribute causes the compiler to
6724 pass the first argument (if of integral type) in the register ECX.
6725 Subsequent and other typed arguments are passed on the stack. The called
6726 function pops the arguments off the stack.
6727 If the number of arguments is variable all arguments are pushed on the
6728 stack.
6729 The @code{thiscall} attribute is intended for C++ non-static member functions.
6730 As a GCC extension, this calling convention can be used for C functions
6731 and for static member methods.
6733 @cindex @code{ms_abi} function attribute, x86
6734 @cindex @code{sysv_abi} function attribute, x86
6735 @item ms_abi
6736 @itemx sysv_abi
6738 On 32-bit and 64-bit x86 targets, you can use an ABI attribute
6739 to indicate which calling convention should be used for a function.  The
6740 @code{ms_abi} attribute tells the compiler to use the Microsoft ABI,
6741 while the @code{sysv_abi} attribute tells the compiler to use the System V
6742 ELF ABI, which is used on GNU/Linux and other systems.  The default is to use
6743 the Microsoft ABI when targeting Windows.  On all other systems, the default
6744 is the System V ELF ABI.
6746 Note, the @code{ms_abi} attribute for Microsoft Windows 64-bit targets currently
6747 requires the @option{-maccumulate-outgoing-args} option.
6749 @cindex @code{callee_pop_aggregate_return} function attribute, x86
6750 @item callee_pop_aggregate_return (@var{number})
6752 On x86-32 targets, you can use this attribute to control how
6753 aggregates are returned in memory.  If the caller is responsible for
6754 popping the hidden pointer together with the rest of the arguments, specify
6755 @var{number} equal to zero.  If callee is responsible for popping the
6756 hidden pointer, specify @var{number} equal to one.  
6758 The default x86-32 ABI assumes that the callee pops the
6759 stack for hidden pointer.  However, on x86-32 Microsoft Windows targets,
6760 the compiler assumes that the
6761 caller pops the stack for hidden pointer.
6763 @cindex @code{ms_hook_prologue} function attribute, x86
6764 @item ms_hook_prologue
6766 On 32-bit and 64-bit x86 targets, you can use
6767 this function attribute to make GCC generate the ``hot-patching'' function
6768 prologue used in Win32 API functions in Microsoft Windows XP Service Pack 2
6769 and newer.
6771 @cindex @code{naked} function attribute, x86
6772 @item naked
6773 This attribute allows the compiler to construct the
6774 requisite function declaration, while allowing the body of the
6775 function to be assembly code. The specified function will not have
6776 prologue/epilogue sequences generated by the compiler. Only basic
6777 @code{asm} statements can safely be included in naked functions
6778 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
6779 basic @code{asm} and C code may appear to work, they cannot be
6780 depended upon to work reliably and are not supported.
6782 @cindex @code{regparm} function attribute, x86
6783 @cindex functions that are passed arguments in registers on x86-32
6784 @item regparm (@var{number})
6785 On x86-32 targets, the @code{regparm} attribute causes the compiler to
6786 pass arguments number one to @var{number} if they are of integral type
6787 in registers EAX, EDX, and ECX instead of on the stack.  Functions that
6788 take a variable number of arguments continue to be passed all of their
6789 arguments on the stack.
6791 Beware that on some ELF systems this attribute is unsuitable for
6792 global functions in shared libraries with lazy binding (which is the
6793 default).  Lazy binding sends the first call via resolving code in
6794 the loader, which might assume EAX, EDX and ECX can be clobbered, as
6795 per the standard calling conventions.  Solaris 8 is affected by this.
6796 Systems with the GNU C Library version 2.1 or higher
6797 and FreeBSD are believed to be
6798 safe since the loaders there save EAX, EDX and ECX.  (Lazy binding can be
6799 disabled with the linker or the loader if desired, to avoid the
6800 problem.)
6802 @cindex @code{sseregparm} function attribute, x86
6803 @item sseregparm
6804 On x86-32 targets with SSE support, the @code{sseregparm} attribute
6805 causes the compiler to pass up to 3 floating-point arguments in
6806 SSE registers instead of on the stack.  Functions that take a
6807 variable number of arguments continue to pass all of their
6808 floating-point arguments on the stack.
6810 @cindex @code{force_align_arg_pointer} function attribute, x86
6811 @item force_align_arg_pointer
6812 On x86 targets, the @code{force_align_arg_pointer} attribute may be
6813 applied to individual function definitions, generating an alternate
6814 prologue and epilogue that realigns the run-time stack if necessary.
6815 This supports mixing legacy codes that run with a 4-byte aligned stack
6816 with modern codes that keep a 16-byte stack for SSE compatibility.
6818 @cindex @code{stdcall} function attribute, x86-32
6819 @cindex functions that pop the argument stack on x86-32
6820 @item stdcall
6821 On x86-32 targets, the @code{stdcall} attribute causes the compiler to
6822 assume that the called function pops off the stack space used to
6823 pass arguments, unless it takes a variable number of arguments.
6825 @cindex @code{no_callee_saved_registers} function attribute, x86
6826 @item no_callee_saved_registers
6827 Use this attribute to indicate that the specified function has no
6828 callee-saved registers. That is, all registers can be used as scratch
6829 registers. For example, this attribute can be used for a function
6830 called from the interrupt handler assembly stub which will preserve
6831 all registers and return from interrupt.
6833 @cindex @code{no_caller_saved_registers} function attribute, x86
6834 @item no_caller_saved_registers
6835 Use this attribute to indicate that the specified function has no
6836 caller-saved registers. That is, all registers are callee-saved. For
6837 example, this attribute can be used for a function called from an
6838 interrupt handler. The compiler generates proper function entry and
6839 exit sequences to save and restore any modified registers, except for
6840 the EFLAGS register.  Since GCC doesn't preserve SSE, MMX nor x87
6841 states, the GCC option @option{-mgeneral-regs-only} should be used to
6842 compile functions with @code{no_caller_saved_registers} attribute.
6844 @cindex @code{interrupt} function attribute, x86
6845 @item interrupt
6846 Use this attribute to indicate that the specified function is an
6847 interrupt handler or an exception handler (depending on parameters passed
6848 to the function, explained further).  The compiler generates function
6849 entry and exit sequences suitable for use in an interrupt handler when
6850 this attribute is present.  The @code{IRET} instruction, instead of the
6851 @code{RET} instruction, is used to return from interrupt handlers.  All
6852 registers, except for the EFLAGS register which is restored by the
6853 @code{IRET} instruction, are preserved by the compiler.  Since GCC
6854 doesn't preserve SSE, MMX nor x87 states, the GCC option
6855 @option{-mgeneral-regs-only} should be used to compile interrupt and
6856 exception handlers.
6858 Any interruptible-without-stack-switch code must be compiled with
6859 @option{-mno-red-zone} since interrupt handlers can and will, because
6860 of the hardware design, touch the red zone.
6862 An interrupt handler must be declared with a mandatory pointer
6863 argument:
6865 @smallexample
6866 struct interrupt_frame;
6868 __attribute__ ((interrupt))
6869 void
6870 f (struct interrupt_frame *frame)
6873 @end smallexample
6875 @noindent
6876 and you must define @code{struct interrupt_frame} as described in the
6877 processor's manual.
6879 Exception handlers differ from interrupt handlers because the system
6880 pushes an error code on the stack.  An exception handler declaration is
6881 similar to that for an interrupt handler, but with a different mandatory
6882 function signature.  The compiler arranges to pop the error code off the
6883 stack before the @code{IRET} instruction.
6885 @smallexample
6886 #ifdef __x86_64__
6887 typedef unsigned long long int uword_t;
6888 #else
6889 typedef unsigned int uword_t;
6890 #endif
6892 struct interrupt_frame;
6894 __attribute__ ((interrupt))
6895 void
6896 f (struct interrupt_frame *frame, uword_t error_code)
6898   ...
6900 @end smallexample
6902 Exception handlers should only be used for exceptions that push an error
6903 code; you should use an interrupt handler in other cases.  The system
6904 will crash if the wrong kind of handler is used.
6906 @cindex @code{target} function attribute
6907 @item target (@var{options})
6908 As discussed in @ref{Common Function Attributes}, this attribute 
6909 allows specification of target-specific compilation options.
6911 On the x86, the following options are allowed:
6912 @table @samp
6913 @cindex @code{target("3dnow")} function attribute, x86
6914 @item 3dnow
6915 @itemx no-3dnow
6916 Enable/disable the generation of the 3DNow!@: instructions.
6918 @cindex @code{target("3dnowa")} function attribute, x86
6919 @item 3dnowa
6920 @itemx no-3dnowa
6921 Enable/disable the generation of the enhanced 3DNow!@: instructions.
6923 @cindex @code{target("abm")} function attribute, x86
6924 @item abm
6925 @itemx no-abm
6926 Enable/disable the generation of the advanced bit instructions.
6928 @cindex @code{target("adx")} function attribute, x86
6929 @item adx
6930 @itemx no-adx
6931 Enable/disable the generation of the ADX instructions.
6933 @cindex @code{target("aes")} function attribute, x86
6934 @item aes
6935 @itemx no-aes
6936 Enable/disable the generation of the AES instructions.
6938 @cindex @code{target("avx")} function attribute, x86
6939 @item avx
6940 @itemx no-avx
6941 Enable/disable the generation of the AVX instructions.
6943 @cindex @code{target("avx2")} function attribute, x86
6944 @item avx2
6945 @itemx no-avx2
6946 Enable/disable the generation of the AVX2 instructions.
6948 @cindex @code{target("avx5124fmaps")} function attribute, x86
6949 @item avx5124fmaps
6950 @itemx no-avx5124fmaps
6951 Enable/disable the generation of the AVX5124FMAPS instructions.
6953 @cindex @code{target("avx5124vnniw")} function attribute, x86
6954 @item avx5124vnniw
6955 @itemx no-avx5124vnniw
6956 Enable/disable the generation of the AVX5124VNNIW instructions.
6958 @cindex @code{target("avx512bitalg")} function attribute, x86
6959 @item avx512bitalg
6960 @itemx no-avx512bitalg
6961 Enable/disable the generation of the AVX512BITALG instructions.
6963 @cindex @code{target("avx512bw")} function attribute, x86
6964 @item avx512bw
6965 @itemx no-avx512bw
6966 Enable/disable the generation of the AVX512BW instructions.
6968 @cindex @code{target("avx512cd")} function attribute, x86
6969 @item avx512cd
6970 @itemx no-avx512cd
6971 Enable/disable the generation of the AVX512CD instructions.
6973 @cindex @code{target("avx512dq")} function attribute, x86
6974 @item avx512dq
6975 @itemx no-avx512dq
6976 Enable/disable the generation of the AVX512DQ instructions.
6978 @cindex @code{target("avx512er")} function attribute, x86
6979 @item avx512er
6980 @itemx no-avx512er
6981 Enable/disable the generation of the AVX512ER instructions.
6983 @cindex @code{target("avx512f")} function attribute, x86
6984 @item avx512f
6985 @itemx no-avx512f
6986 Enable/disable the generation of the AVX512F instructions.
6988 @cindex @code{target("avx512ifma")} function attribute, x86
6989 @item avx512ifma
6990 @itemx no-avx512ifma
6991 Enable/disable the generation of the AVX512IFMA instructions.
6993 @cindex @code{target("avx512pf")} function attribute, x86
6994 @item avx512pf
6995 @itemx no-avx512pf
6996 Enable/disable the generation of the AVX512PF instructions.
6998 @cindex @code{target("avx512vbmi")} function attribute, x86
6999 @item avx512vbmi
7000 @itemx no-avx512vbmi
7001 Enable/disable the generation of the AVX512VBMI instructions.
7003 @cindex @code{target("avx512vbmi2")} function attribute, x86
7004 @item avx512vbmi2
7005 @itemx no-avx512vbmi2
7006 Enable/disable the generation of the AVX512VBMI2 instructions.
7008 @cindex @code{target("avx512vl")} function attribute, x86
7009 @item avx512vl
7010 @itemx no-avx512vl
7011 Enable/disable the generation of the AVX512VL instructions.
7013 @cindex @code{target("avx512vnni")} function attribute, x86
7014 @item avx512vnni
7015 @itemx no-avx512vnni
7016 Enable/disable the generation of the AVX512VNNI instructions.
7018 @cindex @code{target("avx512vpopcntdq")} function attribute, x86
7019 @item avx512vpopcntdq
7020 @itemx no-avx512vpopcntdq
7021 Enable/disable the generation of the AVX512VPOPCNTDQ instructions.
7023 @cindex @code{target("bmi")} function attribute, x86
7024 @item bmi
7025 @itemx no-bmi
7026 Enable/disable the generation of the BMI instructions.
7028 @cindex @code{target("bmi2")} function attribute, x86
7029 @item bmi2
7030 @itemx no-bmi2
7031 Enable/disable the generation of the BMI2 instructions.
7033 @cindex @code{target("cldemote")} function attribute, x86
7034 @item cldemote
7035 @itemx no-cldemote
7036 Enable/disable the generation of the CLDEMOTE instructions.
7038 @cindex @code{target("clflushopt")} function attribute, x86
7039 @item clflushopt
7040 @itemx no-clflushopt
7041 Enable/disable the generation of the CLFLUSHOPT instructions.
7043 @cindex @code{target("clwb")} function attribute, x86
7044 @item clwb
7045 @itemx no-clwb
7046 Enable/disable the generation of the CLWB instructions.
7048 @cindex @code{target("clzero")} function attribute, x86
7049 @item clzero
7050 @itemx no-clzero
7051 Enable/disable the generation of the CLZERO instructions.
7053 @cindex @code{target("crc32")} function attribute, x86
7054 @item crc32
7055 @itemx no-crc32
7056 Enable/disable the generation of the CRC32 instructions.
7058 @cindex @code{target("cx16")} function attribute, x86
7059 @item cx16
7060 @itemx no-cx16
7061 Enable/disable the generation of the CMPXCHG16B instructions.
7063 @cindex @code{target("default")} function attribute, x86
7064 @item default
7065 @xref{Function Multiversioning}, where it is used to specify the
7066 default function version.
7068 @cindex @code{target("f16c")} function attribute, x86
7069 @item f16c
7070 @itemx no-f16c
7071 Enable/disable the generation of the F16C instructions.
7073 @cindex @code{target("fma")} function attribute, x86
7074 @item fma
7075 @itemx no-fma
7076 Enable/disable the generation of the FMA instructions.
7078 @cindex @code{target("fma4")} function attribute, x86
7079 @item fma4
7080 @itemx no-fma4
7081 Enable/disable the generation of the FMA4 instructions.
7083 @cindex @code{target("fsgsbase")} function attribute, x86
7084 @item fsgsbase
7085 @itemx no-fsgsbase
7086 Enable/disable the generation of the FSGSBASE instructions.
7088 @cindex @code{target("fxsr")} function attribute, x86
7089 @item fxsr
7090 @itemx no-fxsr
7091 Enable/disable the generation of the FXSR instructions.
7093 @cindex @code{target("gfni")} function attribute, x86
7094 @item gfni
7095 @itemx no-gfni
7096 Enable/disable the generation of the GFNI instructions.
7098 @cindex @code{target("hle")} function attribute, x86
7099 @item hle
7100 @itemx no-hle
7101 Enable/disable the generation of the HLE instruction prefixes.
7103 @cindex @code{target("lwp")} function attribute, x86
7104 @item lwp
7105 @itemx no-lwp
7106 Enable/disable the generation of the LWP instructions.
7108 @cindex @code{target("lzcnt")} function attribute, x86
7109 @item lzcnt
7110 @itemx no-lzcnt
7111 Enable/disable the generation of the LZCNT instructions.
7113 @cindex @code{target("mmx")} function attribute, x86
7114 @item mmx
7115 @itemx no-mmx
7116 Enable/disable the generation of the MMX instructions.
7118 @cindex @code{target("movbe")} function attribute, x86
7119 @item movbe
7120 @itemx no-movbe
7121 Enable/disable the generation of the MOVBE instructions.
7123 @cindex @code{target("movdir64b")} function attribute, x86
7124 @item movdir64b
7125 @itemx no-movdir64b
7126 Enable/disable the generation of the MOVDIR64B instructions.
7128 @cindex @code{target("movdiri")} function attribute, x86
7129 @item movdiri
7130 @itemx no-movdiri
7131 Enable/disable the generation of the MOVDIRI instructions.
7133 @cindex @code{target("mwait")} function attribute, x86
7134 @item mwait
7135 @itemx no-mwait
7136 Enable/disable the generation of the MWAIT and MONITOR instructions.
7138 @cindex @code{target("mwaitx")} function attribute, x86
7139 @item mwaitx
7140 @itemx no-mwaitx
7141 Enable/disable the generation of the MWAITX instructions.
7143 @cindex @code{target("pclmul")} function attribute, x86
7144 @item pclmul
7145 @itemx no-pclmul
7146 Enable/disable the generation of the PCLMUL instructions.
7148 @cindex @code{target("pconfig")} function attribute, x86
7149 @item pconfig
7150 @itemx no-pconfig
7151 Enable/disable the generation of the PCONFIG instructions.
7153 @cindex @code{target("pku")} function attribute, x86
7154 @item pku
7155 @itemx no-pku
7156 Enable/disable the generation of the PKU instructions.
7158 @cindex @code{target("popcnt")} function attribute, x86
7159 @item popcnt
7160 @itemx no-popcnt
7161 Enable/disable the generation of the POPCNT instruction.
7163 @cindex @code{target("prefetchwt1")} function attribute, x86
7164 @item prefetchwt1
7165 @itemx no-prefetchwt1
7166 Enable/disable the generation of the PREFETCHWT1 instructions.
7168 @cindex @code{target("prfchw")} function attribute, x86
7169 @item prfchw
7170 @itemx no-prfchw
7171 Enable/disable the generation of the PREFETCHW instruction.
7173 @cindex @code{target("ptwrite")} function attribute, x86
7174 @item ptwrite
7175 @itemx no-ptwrite
7176 Enable/disable the generation of the PTWRITE instructions.
7178 @cindex @code{target("rdpid")} function attribute, x86
7179 @item rdpid
7180 @itemx no-rdpid
7181 Enable/disable the generation of the RDPID instructions.
7183 @cindex @code{target("rdrnd")} function attribute, x86
7184 @item rdrnd
7185 @itemx no-rdrnd
7186 Enable/disable the generation of the RDRND instructions.
7188 @cindex @code{target("rdseed")} function attribute, x86
7189 @item rdseed
7190 @itemx no-rdseed
7191 Enable/disable the generation of the RDSEED instructions.
7193 @cindex @code{target("rtm")} function attribute, x86
7194 @item rtm
7195 @itemx no-rtm
7196 Enable/disable the generation of the RTM instructions.
7198 @cindex @code{target("sahf")} function attribute, x86
7199 @item sahf
7200 @itemx no-sahf
7201 Enable/disable the generation of the SAHF instructions.
7203 @cindex @code{target("sgx")} function attribute, x86
7204 @item sgx
7205 @itemx no-sgx
7206 Enable/disable the generation of the SGX instructions.
7208 @cindex @code{target("sha")} function attribute, x86
7209 @item sha
7210 @itemx no-sha
7211 Enable/disable the generation of the SHA instructions.
7213 @cindex @code{target("shstk")} function attribute, x86
7214 @item shstk
7215 @itemx no-shstk
7216 Enable/disable the shadow stack built-in functions from CET.
7218 @cindex @code{target("sse")} function attribute, x86
7219 @item sse
7220 @itemx no-sse
7221 Enable/disable the generation of the SSE instructions.
7223 @cindex @code{target("sse2")} function attribute, x86
7224 @item sse2
7225 @itemx no-sse2
7226 Enable/disable the generation of the SSE2 instructions.
7228 @cindex @code{target("sse3")} function attribute, x86
7229 @item sse3
7230 @itemx no-sse3
7231 Enable/disable the generation of the SSE3 instructions.
7233 @cindex @code{target("sse4")} function attribute, x86
7234 @item sse4
7235 @itemx no-sse4
7236 Enable/disable the generation of the SSE4 instructions (both SSE4.1
7237 and SSE4.2).
7239 @cindex @code{target("sse4.1")} function attribute, x86
7240 @item sse4.1
7241 @itemx no-sse4.1
7242 Enable/disable the generation of the SSE4.1 instructions.
7244 @cindex @code{target("sse4.2")} function attribute, x86
7245 @item sse4.2
7246 @itemx no-sse4.2
7247 Enable/disable the generation of the SSE4.2 instructions.
7249 @cindex @code{target("sse4a")} function attribute, x86
7250 @item sse4a
7251 @itemx no-sse4a
7252 Enable/disable the generation of the SSE4A instructions.
7254 @cindex @code{target("ssse3")} function attribute, x86
7255 @item ssse3
7256 @itemx no-ssse3
7257 Enable/disable the generation of the SSSE3 instructions.
7259 @cindex @code{target("tbm")} function attribute, x86
7260 @item tbm
7261 @itemx no-tbm
7262 Enable/disable the generation of the TBM instructions.
7264 @cindex @code{target("vaes")} function attribute, x86
7265 @item vaes
7266 @itemx no-vaes
7267 Enable/disable the generation of the VAES instructions.
7269 @cindex @code{target("vpclmulqdq")} function attribute, x86
7270 @item vpclmulqdq
7271 @itemx no-vpclmulqdq
7272 Enable/disable the generation of the VPCLMULQDQ instructions.
7274 @cindex @code{target("waitpkg")} function attribute, x86
7275 @item waitpkg
7276 @itemx no-waitpkg
7277 Enable/disable the generation of the WAITPKG instructions.
7279 @cindex @code{target("wbnoinvd")} function attribute, x86
7280 @item wbnoinvd
7281 @itemx no-wbnoinvd
7282 Enable/disable the generation of the WBNOINVD instructions.
7284 @cindex @code{target("xop")} function attribute, x86
7285 @item xop
7286 @itemx no-xop
7287 Enable/disable the generation of the XOP instructions.
7289 @cindex @code{target("xsave")} function attribute, x86
7290 @item xsave
7291 @itemx no-xsave
7292 Enable/disable the generation of the XSAVE instructions.
7294 @cindex @code{target("xsavec")} function attribute, x86
7295 @item xsavec
7296 @itemx no-xsavec
7297 Enable/disable the generation of the XSAVEC instructions.
7299 @cindex @code{target("xsaveopt")} function attribute, x86
7300 @item xsaveopt
7301 @itemx no-xsaveopt
7302 Enable/disable the generation of the XSAVEOPT instructions.
7304 @cindex @code{target("xsaves")} function attribute, x86
7305 @item xsaves
7306 @itemx no-xsaves
7307 Enable/disable the generation of the XSAVES instructions.
7309 @cindex @code{target("amx-tile")} function attribute, x86
7310 @item amx-tile
7311 @itemx no-amx-tile
7312 Enable/disable the generation of the AMX-TILE instructions.
7314 @cindex @code{target("amx-int8")} function attribute, x86
7315 @item amx-int8
7316 @itemx no-amx-int8
7317 Enable/disable the generation of the AMX-INT8 instructions.
7319 @cindex @code{target("amx-bf16")} function attribute, x86
7320 @item amx-bf16
7321 @itemx no-amx-bf16
7322 Enable/disable the generation of the AMX-BF16 instructions.
7324 @cindex @code{target("uintr")} function attribute, x86
7325 @item uintr
7326 @itemx no-uintr
7327 Enable/disable the generation of the UINTR instructions.
7329 @cindex @code{target("hreset")} function attribute, x86
7330 @item hreset
7331 @itemx no-hreset
7332 Enable/disable the generation of the HRESET instruction.
7334 @cindex @code{target("kl")} function attribute, x86
7335 @item kl
7336 @itemx no-kl
7337 Enable/disable the generation of the KEYLOCKER instructions.
7339 @cindex @code{target("widekl")} function attribute, x86
7340 @item widekl
7341 @itemx no-widekl
7342 Enable/disable the generation of the WIDEKL instructions.
7344 @cindex @code{target("avxvnni")} function attribute, x86
7345 @item avxvnni
7346 @itemx no-avxvnni
7347 Enable/disable the generation of the AVXVNNI instructions.
7349 @cindex @code{target("avxifma")} function attribute, x86
7350 @item avxifma
7351 @itemx no-avxifma
7352 Enable/disable the generation of the AVXIFMA instructions.
7354 @cindex @code{target("avxvnniint8")} function attribute, x86
7355 @item avxvnniint8
7356 @itemx no-avxvnniint8
7357 Enable/disable the generation of the AVXVNNIINT8 instructions.
7359 @cindex @code{target("avxneconvert")} function attribute, x86
7360 @item avxneconvert
7361 @itemx no-avxneconvert
7362 Enable/disable the generation of the AVXNECONVERT instructions.
7364 @cindex @code{target("cmpccxadd")} function attribute, x86
7365 @item cmpccxadd
7366 @itemx no-cmpccxadd
7367 Enable/disable the generation of the CMPccXADD instructions.
7369 @cindex @code{target("amx-fp16")} function attribute, x86
7370 @item amx-fp16
7371 @itemx no-amx-fp16
7372 Enable/disable the generation of the AMX-FP16 instructions.
7374 @cindex @code{target("prefetchi")} function attribute, x86
7375 @item prefetchi
7376 @itemx no-prefetchi
7377 Enable/disable the generation of the PREFETCHI instructions.
7379 @cindex @code{target("raoint")} function attribute, x86
7380 @item raoint
7381 @itemx no-raoint
7382 Enable/disable the generation of the RAOINT instructions.
7384 @cindex @code{target("amx-complex")} function attribute, x86
7385 @item amx-complex
7386 @itemx no-amx-complex
7387 Enable/disable the generation of the AMX-COMPLEX instructions.
7389 @cindex @code{target("avxvnniint16")} function attribute, x86
7390 @item avxvnniint16
7391 @itemx no-avxvnniint16
7392 Enable/disable the generation of the AVXVNNIINT16 instructions.
7394 @cindex @code{target("sm3")} function attribute, x86
7395 @item sm3
7396 @itemx no-sm3
7397 Enable/disable the generation of the SM3 instructions.
7399 @cindex @code{target("sha512")} function attribute, x86
7400 @item sha512
7401 @itemx no-sha512
7402 Enable/disable the generation of the SHA512 instructions.
7404 @cindex @code{target("sm4")} function attribute, x86
7405 @item sm4
7406 @itemx no-sm4
7407 Enable/disable the generation of the SM4 instructions.
7409 @cindex @code{target("usermsr")} function attribute, x86
7410 @item usermsr
7411 @itemx no-usermsr
7412 Enable/disable the generation of the USER_MSR instructions.
7414 @cindex @code{target("apxf")} function attribute, x86
7415 @item apxf
7416 @itemx no-apxf
7417 Enable/disable the generation of the APX features, including
7418 EGPR, PUSH2POP2, NDD and PPX.
7420 @cindex @code{target("avx10.1")} function attribute, x86
7421 @item avx10.1
7422 @itemx no-avx10.1
7423 Enable/disable the generation of the AVX10.1 instructions.
7425 @cindex @code{target("avx10.1-256")} function attribute, x86
7426 @item avx10.1-256
7427 @itemx no-avx10.1-256
7428 Enable/disable the generation of the AVX10.1 instructions.
7430 @cindex @code{target("avx10.1-512")} function attribute, x86
7431 @item avx10.1-512
7432 @itemx no-avx10.1-512
7433 Enable/disable the generation of the AVX10.1 512 bit instructions.
7435 @cindex @code{target("cld")} function attribute, x86
7436 @item cld
7437 @itemx no-cld
7438 Enable/disable the generation of the CLD before string moves.
7440 @cindex @code{target("fancy-math-387")} function attribute, x86
7441 @item fancy-math-387
7442 @itemx no-fancy-math-387
7443 Enable/disable the generation of the @code{sin}, @code{cos}, and
7444 @code{sqrt} instructions on the 387 floating-point unit.
7446 @cindex @code{target("ieee-fp")} function attribute, x86
7447 @item ieee-fp
7448 @itemx no-ieee-fp
7449 Enable/disable the generation of floating point that depends on IEEE arithmetic.
7451 @cindex @code{target("inline-all-stringops")} function attribute, x86
7452 @item inline-all-stringops
7453 @itemx no-inline-all-stringops
7454 Enable/disable inlining of string operations.
7456 @cindex @code{target("inline-stringops-dynamically")} function attribute, x86
7457 @item inline-stringops-dynamically
7458 @itemx no-inline-stringops-dynamically
7459 Enable/disable the generation of the inline code to do small string
7460 operations and calling the library routines for large operations.
7462 @cindex @code{target("align-stringops")} function attribute, x86
7463 @item align-stringops
7464 @itemx no-align-stringops
7465 Do/do not align destination of inlined string operations.
7467 @cindex @code{target("recip")} function attribute, x86
7468 @item recip
7469 @itemx no-recip
7470 Enable/disable the generation of RCPSS, RCPPS, RSQRTSS and RSQRTPS
7471 instructions followed an additional Newton-Raphson step instead of
7472 doing a floating-point division.
7474 @cindex @code{target("general-regs-only")} function attribute, x86
7475 @item general-regs-only
7476 Generate code which uses only the general registers.
7478 @cindex @code{target("arch=@var{ARCH}")} function attribute, x86
7479 @item arch=@var{ARCH}
7480 Specify the architecture to generate code for in compiling the function.
7482 @cindex @code{target("tune=@var{TUNE}")} function attribute, x86
7483 @item tune=@var{TUNE}
7484 Specify the architecture to tune for in compiling the function.
7486 @cindex @code{target("fpmath=@var{FPMATH}")} function attribute, x86
7487 @item fpmath=@var{FPMATH}
7488 Specify which floating-point unit to use.  You must specify the
7489 @code{target("fpmath=sse,387")} option as
7490 @code{target("fpmath=sse+387")} because the comma would separate
7491 different options.
7493 @cindex @code{prefer-vector-width} function attribute, x86
7494 @item prefer-vector-width=@var{OPT}
7495 On x86 targets, the @code{prefer-vector-width} attribute informs the
7496 compiler to use @var{OPT}-bit vector width in instructions
7497 instead of the default on the selected platform.
7499 Valid @var{OPT} values are:
7501 @table @samp
7502 @item none
7503 No extra limitations applied to GCC other than defined by the selected platform.
7505 @item 128
7506 Prefer 128-bit vector width for instructions.
7508 @item 256
7509 Prefer 256-bit vector width for instructions.
7511 @item 512
7512 Prefer 512-bit vector width for instructions.
7513 @end table
7515 @end table
7517 @cindex @code{indirect_branch} function attribute, x86
7518 @item indirect_branch("@var{choice}")
7519 On x86 targets, the @code{indirect_branch} attribute causes the compiler
7520 to convert indirect call and jump with @var{choice}.  @samp{keep}
7521 keeps indirect call and jump unmodified.  @samp{thunk} converts indirect
7522 call and jump to call and return thunk.  @samp{thunk-inline} converts
7523 indirect call and jump to inlined call and return thunk.
7524 @samp{thunk-extern} converts indirect call and jump to external call
7525 and return thunk provided in a separate object file.
7527 @cindex @code{function_return} function attribute, x86
7528 @item function_return("@var{choice}")
7529 On x86 targets, the @code{function_return} attribute causes the compiler
7530 to convert function return with @var{choice}.  @samp{keep} keeps function
7531 return unmodified.  @samp{thunk} converts function return to call and
7532 return thunk.  @samp{thunk-inline} converts function return to inlined
7533 call and return thunk.  @samp{thunk-extern} converts function return to
7534 external call and return thunk provided in a separate object file.
7536 @cindex @code{nocf_check} function attribute
7537 @item nocf_check
7538 The @code{nocf_check} attribute on a function is used to inform the
7539 compiler that the function's prologue should not be instrumented when
7540 compiled with the @option{-fcf-protection=branch} option.  The
7541 compiler assumes that the function's address is a valid target for a
7542 control-flow transfer.
7544 The @code{nocf_check} attribute on a type of pointer to function is
7545 used to inform the compiler that a call through the pointer should
7546 not be instrumented when compiled with the
7547 @option{-fcf-protection=branch} option.  The compiler assumes
7548 that the function's address from the pointer is a valid target for
7549 a control-flow transfer.  A direct function call through a function
7550 name is assumed to be a safe call thus direct calls are not
7551 instrumented by the compiler.
7553 The @code{nocf_check} attribute is applied to an object's type.
7554 In case of assignment of a function address or a function pointer to
7555 another pointer, the attribute is not carried over from the right-hand
7556 object's type; the type of left-hand object stays unchanged.  The
7557 compiler checks for @code{nocf_check} attribute mismatch and reports
7558 a warning in case of mismatch.
7560 @smallexample
7562 int foo (void) __attribute__(nocf_check);
7563 void (*foo1)(void) __attribute__(nocf_check);
7564 void (*foo2)(void);
7566 /* foo's address is assumed to be valid.  */
7568 foo (void) 
7570   /* This call site is not checked for control-flow 
7571      validity.  */
7572   (*foo1)();
7574   /* A warning is issued about attribute mismatch.  */
7575   foo1 = foo2; 
7577   /* This call site is still not checked.  */
7578   (*foo1)();
7580   /* This call site is checked.  */
7581   (*foo2)();
7583   /* A warning is issued about attribute mismatch.  */
7584   foo2 = foo1; 
7586   /* This call site is still checked.  */
7587   (*foo2)();
7589   return 0;
7591 @end smallexample
7593 @cindex @code{cf_check} function attribute, x86
7594 @item cf_check
7596 The @code{cf_check} attribute on a function is used to inform the
7597 compiler that ENDBR instruction should be placed at the function
7598 entry when @option{-fcf-protection=branch} is enabled.
7600 @cindex @code{indirect_return} function attribute, x86
7601 @item indirect_return
7603 The @code{indirect_return} attribute can be applied to a function,
7604 as well as variable or type of function pointer to inform the
7605 compiler that the function may return via indirect branch.
7607 @cindex @code{fentry_name} function attribute, x86
7608 @item fentry_name("@var{name}")
7609 On x86 targets, the @code{fentry_name} attribute sets the function to
7610 call on function entry when function instrumentation is enabled
7611 with @option{-pg -mfentry}. When @var{name} is nop then a 5 byte
7612 nop sequence is generated.
7614 @cindex @code{fentry_section} function attribute, x86
7615 @item fentry_section("@var{name}")
7616 On x86 targets, the @code{fentry_section} attribute sets the name
7617 of the section to record function entry instrumentation calls in when
7618 enabled with @option{-pg -mrecord-mcount}
7620 @cindex @code{nodirect_extern_access} function attribute
7621 @opindex mno-direct-extern-access
7622 @item nodirect_extern_access
7623 This attribute, attached to a global variable or function, is the
7624 counterpart to option @option{-mno-direct-extern-access}.
7626 @end table
7628 @subsubsection Inlining rules
7629 On the x86, the inliner does not inline a
7630 function that has different target options than the caller, unless the
7631 callee has a subset of the target options of the caller.  For example
7632 a function declared with @code{target("sse3")} can inline a function
7633 with @code{target("sse2")}, since @code{-msse3} implies @code{-msse2}.
7635 Besides the basic rule, when a function specifies
7636 @code{target("arch=@var{ARCH}")} or @code{target("tune=@var{TUNE}")}
7637 attribute, the inlining rule will be different. It allows inlining of
7638 a function with default @option{-march=x86-64} and
7639 @option{-mtune=generic} specified, or a function that has a subset
7640 of ISA features and marked with always_inline.
7642 @node Xstormy16 Function Attributes
7643 @subsection Xstormy16 Function Attributes
7645 These function attributes are supported by the Xstormy16 back end:
7647 @table @code
7648 @cindex @code{interrupt} function attribute, Xstormy16
7649 @item interrupt
7650 Use this attribute to indicate
7651 that the specified function is an interrupt handler.  The compiler generates
7652 function entry and exit sequences suitable for use in an interrupt handler
7653 when this attribute is present.
7654 @end table
7656 @node Variable Attributes
7657 @section Specifying Attributes of Variables
7658 @cindex attribute of variables
7659 @cindex variable attributes
7661 You can use attributes to specify special properties
7662 of variables, function parameters, or structure, union, and, in C++, class
7663 members.  Some attributes are currently
7664 defined generically for variables.  Other attributes are defined for
7665 variables on particular target systems.  Other attributes are available
7666 for functions (@pxref{Function Attributes}), labels (@pxref{Label Attributes}),
7667 enumerators (@pxref{Enumerator Attributes}), statements
7668 (@pxref{Statement Attributes}), and for types (@pxref{Type Attributes}).
7669 Other front ends might define more attributes
7670 (@pxref{C++ Extensions,,Extensions to the C++ Language}).
7672 GCC provides two different ways to specify attributes: the traditional
7673 GNU syntax using @samp{__attribute__ ((...))} annotations, and the
7674 newer standard C and C++ syntax using @samp{[[...]]} with the
7675 @samp{gnu::} prefix on attribute names.  Note that the exact rules for
7676 placement of attributes in your source code are different depending on
7677 which syntax you use.  @xref{Attribute Syntax}, for details.
7679 @menu
7680 * Common Variable Attributes::
7681 * ARC Variable Attributes::
7682 * AVR Variable Attributes::
7683 * Blackfin Variable Attributes::
7684 * H8/300 Variable Attributes::
7685 * IA-64 Variable Attributes::
7686 * LoongArch Variable Attributes::
7687 * M32R/D Variable Attributes::
7688 * Microsoft Windows Variable Attributes::
7689 * MSP430 Variable Attributes::
7690 * Nvidia PTX Variable Attributes::
7691 * PowerPC Variable Attributes::
7692 * RL78 Variable Attributes::
7693 * V850 Variable Attributes::
7694 * x86 Variable Attributes::
7695 * Xstormy16 Variable Attributes::
7696 @end menu
7698 @node Common Variable Attributes
7699 @subsection Common Variable Attributes
7701 The following attributes are supported on most targets.
7703 @table @code
7704 @c Keep this table alphabetized by attribute name.  Treat _ as space.
7706 @cindex @code{alias} variable attribute
7707 @item alias ("@var{target}")
7708 The @code{alias} variable attribute causes the declaration to be emitted
7709 as an alias for another symbol known as an @dfn{alias target}.  Except
7710 for top-level qualifiers the alias target must have the same type as
7711 the alias.  For instance, the following
7713 @smallexample
7714 int var_target;
7715 extern int __attribute__ ((alias ("var_target"))) var_alias;
7716 @end smallexample
7718 @noindent
7719 defines @code{var_alias} to be an alias for the @code{var_target} variable.
7721 It is an error if the alias target is not defined in the same translation
7722 unit as the alias.
7724 Note that in the absence of the attribute GCC assumes that distinct
7725 declarations with external linkage denote distinct objects.  Using both
7726 the alias and the alias target to access the same object is undefined
7727 in a translation unit without a declaration of the alias with the attribute.
7729 This attribute requires assembler and object file support, and may not be
7730 available on all targets.
7732 @cindex @code{aligned} variable attribute
7733 @item aligned
7734 @itemx aligned (@var{alignment})
7735 The @code{aligned} attribute specifies a minimum alignment for the variable
7736 or structure field, measured in bytes.  When specified, @var{alignment} must
7737 be an integer constant power of 2.  Specifying no @var{alignment} argument
7738 implies the maximum alignment for the target, which is often, but by no
7739 means always, 8 or 16 bytes.
7741 For example, the declaration:
7743 @smallexample
7744 int x __attribute__ ((aligned (16))) = 0;
7745 @end smallexample
7747 @noindent
7748 causes the compiler to allocate the global variable @code{x} on a
7749 16-byte boundary.  On a 68040, this could be used in conjunction with
7750 an @code{asm} expression to access the @code{move16} instruction which
7751 requires 16-byte aligned operands.
7753 You can also specify the alignment of structure fields.  For example, to
7754 create a double-word aligned @code{int} pair, you could write:
7756 @smallexample
7757 struct foo @{ int x[2] __attribute__ ((aligned (8))); @};
7758 @end smallexample
7760 @noindent
7761 This is an alternative to creating a union with a @code{double} member,
7762 which forces the union to be double-word aligned.
7764 As in the preceding examples, you can explicitly specify the alignment
7765 (in bytes) that you wish the compiler to use for a given variable or
7766 structure field.  Alternatively, you can leave out the alignment factor
7767 and just ask the compiler to align a variable or field to the
7768 default alignment for the target architecture you are compiling for.
7769 The default alignment is sufficient for all scalar types, but may not be
7770 enough for all vector types on a target that supports vector operations.
7771 The default alignment is fixed for a particular target ABI.
7773 GCC also provides a target specific macro @code{__BIGGEST_ALIGNMENT__},
7774 which is the largest alignment ever used for any data type on the
7775 target machine you are compiling for.  For example, you could write:
7777 @smallexample
7778 short array[3] __attribute__ ((aligned (__BIGGEST_ALIGNMENT__)));
7779 @end smallexample
7781 The compiler automatically sets the alignment for the declared
7782 variable or field to @code{__BIGGEST_ALIGNMENT__}.  Doing this can
7783 often make copy operations more efficient, because the compiler can
7784 use whatever instructions copy the biggest chunks of memory when
7785 performing copies to or from the variables or fields that you have
7786 aligned this way.  Note that the value of @code{__BIGGEST_ALIGNMENT__}
7787 may change depending on command-line options.
7789 When used on a struct, or struct member, the @code{aligned} attribute can
7790 only increase the alignment; in order to decrease it, the @code{packed}
7791 attribute must be specified as well.  When used as part of a typedef, the
7792 @code{aligned} attribute can both increase and decrease alignment, and
7793 specifying the @code{packed} attribute generates a warning.
7795 Note that the effectiveness of @code{aligned} attributes for static
7796 variables may be limited by inherent limitations in the system linker
7797 and/or object file format.  On some systems, the linker is
7798 only able to arrange for variables to be aligned up to a certain maximum
7799 alignment.  (For some linkers, the maximum supported alignment may
7800 be very very small.)  If your linker is only able to align variables
7801 up to a maximum of 8-byte alignment, then specifying @code{aligned(16)}
7802 in an @code{__attribute__} still only provides you with 8-byte
7803 alignment.  See your linker documentation for further information.
7805 Stack variables are not affected by linker restrictions; GCC can properly
7806 align them on any target.
7808 The @code{aligned} attribute can also be used for functions
7809 (@pxref{Common Function Attributes}.)
7811 @cindex @code{alloc_size} variable attribute
7812 @item alloc_size (@var{position})
7813 @itemx alloc_size (@var{position-1}, @var{position-2})
7814 The @code{alloc_size} variable attribute may be applied to the declaration
7815 of a pointer to a function that returns a pointer and takes at least one
7816 argument of an integer type.  It indicates that the returned pointer points
7817 to an object whose size is given by the function argument at @var{position},
7818 or by the product of the arguments at @var{position-1} and @var{position-2}.
7819 Meaningful sizes are positive values less than @code{PTRDIFF_MAX}.  Other
7820 sizes are diagnosed when detected.  GCC uses this information to improve
7821 the results of @code{__builtin_object_size}.
7823 For instance, the following declarations
7825 @smallexample
7826 typedef __attribute__ ((alloc_size (1, 2))) void*
7827   (*calloc_ptr) (size_t, size_t);
7828 typedef __attribute__ ((alloc_size (1))) void*
7829   (*malloc_ptr) (size_t);
7830 @end smallexample
7832 @noindent
7833 specify that @code{calloc_ptr} is a pointer of a function that, like
7834 the standard C function @code{calloc}, returns an object whose size
7835 is given by the product of arguments 1 and 2, and similarly, that
7836 @code{malloc_ptr}, like the standard C function @code{malloc},
7837 returns an object whose size is given by argument 1 to the function.
7839 @cindex @code{cleanup} variable attribute
7840 @item cleanup (@var{cleanup_function})
7841 The @code{cleanup} attribute runs a function when the variable goes
7842 out of scope.  This attribute can only be applied to auto function
7843 scope variables; it may not be applied to parameters or variables
7844 with static storage duration.  The function must take one parameter,
7845 a pointer to a type compatible with the variable.  The return value
7846 of the function (if any) is ignored.
7848 When multiple variables in the same scope have @code{cleanup}
7849 attributes, at exit from the scope their associated cleanup functions
7850 are run in reverse order of definition (last defined, first
7851 cleanup).
7853 If @option{-fexceptions} is enabled, then @var{cleanup_function}
7854 is run during the stack unwinding that happens during the
7855 processing of the exception.  Note that the @code{cleanup} attribute
7856 does not allow the exception to be caught, only to perform an action.
7857 It is undefined what happens if @var{cleanup_function} does not
7858 return normally.
7860 @cindex @code{common} variable attribute
7861 @cindex @code{nocommon} variable attribute
7862 @opindex fcommon
7863 @opindex fno-common
7864 @item common
7865 @itemx nocommon
7866 The @code{common} attribute requests GCC to place a variable in
7867 ``common'' storage.  The @code{nocommon} attribute requests the
7868 opposite---to allocate space for it directly.
7870 These attributes override the default chosen by the
7871 @option{-fno-common} and @option{-fcommon} flags respectively.
7873 @cindex @code{copy} variable attribute
7874 @item copy
7875 @itemx copy (@var{variable})
7876 The @code{copy} attribute applies the set of attributes with which
7877 @var{variable} has been declared to the declaration of the variable
7878 to which the attribute is applied.  The attribute is designed for
7879 libraries that define aliases that are expected to specify the same
7880 set of attributes as the aliased symbols.  The @code{copy} attribute
7881 can be used with variables, functions or types.  However, the kind
7882 of symbol to which the attribute is applied (either varible or
7883 function) must match the kind of symbol to which the argument refers.
7884 The @code{copy} attribute copies only syntactic and semantic attributes
7885 but not attributes that affect a symbol's linkage or visibility such as
7886 @code{alias}, @code{visibility}, or @code{weak}.  The @code{deprecated}
7887 attribute is also not copied.  @xref{Common Function Attributes}.
7888 @xref{Common Type Attributes}.
7890 @cindex @code{deprecated} variable attribute
7891 @item deprecated
7892 @itemx deprecated (@var{msg})
7893 The @code{deprecated} attribute results in a warning if the variable
7894 is used anywhere in the source file.  This is useful when identifying
7895 variables that are expected to be removed in a future version of a
7896 program.  The warning also includes the location of the declaration
7897 of the deprecated variable, to enable users to easily find further
7898 information about why the variable is deprecated, or what they should
7899 do instead.  Note that the warning only occurs for uses:
7901 @smallexample
7902 extern int old_var __attribute__ ((deprecated));
7903 extern int old_var;
7904 int new_fn () @{ return old_var; @}
7905 @end smallexample
7907 @noindent
7908 results in a warning on line 3 but not line 2.  The optional @var{msg}
7909 argument, which must be a string, is printed in the warning if
7910 present.
7912 The @code{deprecated} attribute can also be used for functions and
7913 types (@pxref{Common Function Attributes},
7914 @pxref{Common Type Attributes}).
7916 The message attached to the attribute is affected by the setting of
7917 the @option{-fmessage-length} option.
7919 @cindex @code{mode} variable attribute
7920 @item mode (@var{mode})
7921 This attribute specifies the data type for the declaration---whichever
7922 type corresponds to the mode @var{mode}.  This in effect lets you
7923 request an integer or floating-point type according to its width.
7925 @xref{Machine Modes,,, gccint, GNU Compiler Collection (GCC) Internals},
7926 for a list of the possible keywords for @var{mode}.
7927 You may also specify a mode of @code{byte} or @code{__byte__} to
7928 indicate the mode corresponding to a one-byte integer, @code{word} or
7929 @code{__word__} for the mode of a one-word integer, and @code{pointer}
7930 or @code{__pointer__} for the mode used to represent pointers.
7932 @cindex @code{no_icf} variable attribute
7933 @item no_icf
7934 This variable attribute prevents a variable from being merged with another
7935 equivalent variable.
7937 @cindex @code{noinit} variable attribute
7938 @item noinit
7939 Any data with the @code{noinit} attribute will not be initialized by
7940 the C runtime startup code, or the program loader.  Not initializing
7941 data in this way can reduce program startup times.
7943 This attribute is specific to ELF targets and relies on the linker
7944 script to place sections with the @code{.noinit} prefix in the right
7945 location.
7947 @cindex @code{nonstring} variable attribute
7948 @item nonstring
7949 The @code{nonstring} variable attribute specifies that an object or member
7950 declaration with type array of @code{char}, @code{signed char}, or
7951 @code{unsigned char}, or pointer to such a type is intended to store
7952 character arrays that do not necessarily contain a terminating @code{NUL}.
7953 This is useful in detecting uses of such arrays or pointers with functions
7954 that expect @code{NUL}-terminated strings, and to avoid warnings when such
7955 an array or pointer is used as an argument to a bounded string manipulation
7956 function such as @code{strncpy}.  For example, without the attribute, GCC
7957 will issue a warning for the @code{strncpy} call below because it may
7958 truncate the copy without appending the terminating @code{NUL} character.
7959 Using the attribute makes it possible to suppress the warning.  However,
7960 when the array is declared with the attribute the call to @code{strlen} is
7961 diagnosed because when the array doesn't contain a @code{NUL}-terminated
7962 string the call is undefined.  To copy, compare, of search non-string
7963 character arrays use the @code{memcpy}, @code{memcmp}, @code{memchr},
7964 and other functions that operate on arrays of bytes.  In addition,
7965 calling @code{strnlen} and @code{strndup} with such arrays is safe
7966 provided a suitable bound is specified, and not diagnosed.
7968 @smallexample
7969 struct Data
7971   char name [32] __attribute__ ((nonstring));
7974 int f (struct Data *pd, const char *s)
7976   strncpy (pd->name, s, sizeof pd->name);
7977   @dots{}
7978   return strlen (pd->name);   // unsafe, gets a warning
7980 @end smallexample
7982 @cindex @code{objc_nullability} variable attribute
7983 @item objc_nullability (@var{nullability kind}) @r{(Objective-C and Objective-C++ only)}
7984 This attribute applies to pointer variables only.  It allows marking the
7985 pointer with one of four possible values describing the conditions under
7986 which the pointer might have a @code{nil} value. In most cases, the
7987 attribute is intended to be an internal representation for property and
7988 method nullability (specified by language keywords); it is not recommended
7989 to use it directly.
7991 When @var{nullability kind} is @code{"unspecified"} or @code{0}, nothing is
7992 known about the conditions in which the pointer might be @code{nil}. Making
7993 this state specific serves to avoid false positives in diagnostics.
7995 When @var{nullability kind} is @code{"nonnull"} or @code{1}, the pointer has
7996 no meaning if it is @code{nil} and thus the compiler is free to emit
7997 diagnostics if it can be determined that the value will be @code{nil}.
7999 When @var{nullability kind} is @code{"nullable"} or @code{2}, the pointer might
8000 be @code{nil} and carry meaning as such.
8002 When @var{nullability kind} is @code{"resettable"} or @code{3} (used only in
8003 the context of property attribute lists) this describes the case in which a
8004 property setter may take the value @code{nil} (which perhaps causes the
8005 property to be reset in some manner to a default) but for which the property
8006 getter will never validly return @code{nil}.
8008 @cindex @code{packed} variable attribute
8009 @item packed
8010 The @code{packed} attribute specifies that a structure member should have
8011 the smallest possible alignment---one bit for a bit-field and one byte
8012 otherwise, unless a larger value is specified with the @code{aligned}
8013 attribute.  The attribute does not apply to non-member objects.
8015 For example in the structure below, the member array @code{x} is packed
8016 so that it immediately follows @code{a} with no intervening padding:
8018 @smallexample
8019 struct foo
8021   char a;
8022   int x[2] __attribute__ ((packed));
8024 @end smallexample
8026 @emph{Note:} The 4.1, 4.2 and 4.3 series of GCC ignore the
8027 @code{packed} attribute on bit-fields of type @code{char}.  This has
8028 been fixed in GCC 4.4 but the change can lead to differences in the
8029 structure layout.  See the documentation of
8030 @option{-Wpacked-bitfield-compat} for more information.
8032 @cindex @code{persistent} variable attribute
8033 @item persistent
8034 Any data with the @code{persistent} attribute will not be initialized by
8035 the C runtime startup code, but will be initialized by the program
8036 loader.  This enables the value of the variable to @samp{persist}
8037 between processor resets.
8039 This attribute is specific to ELF targets and relies on the linker
8040 script to place the sections with the @code{.persistent} prefix in the
8041 right location.  Specifically, some type of non-volatile, writeable
8042 memory is required.
8044 @cindex @code{section} variable attribute
8045 @item section ("@var{section-name}")
8046 Normally, the compiler places the objects it generates in sections like
8047 @code{data} and @code{bss}.  Sometimes, however, you need additional sections,
8048 or you need certain particular variables to appear in special sections,
8049 for example to map to special hardware.  The @code{section}
8050 attribute specifies that a variable (or function) lives in a particular
8051 section.  For example, this small program uses several specific section names:
8053 @smallexample
8054 struct duart a __attribute__ ((section ("DUART_A"))) = @{ 0 @};
8055 struct duart b __attribute__ ((section ("DUART_B"))) = @{ 0 @};
8056 char stack[10000] __attribute__ ((section ("STACK"))) = @{ 0 @};
8057 int init_data __attribute__ ((section ("INITDATA")));
8059 main()
8061   /* @r{Initialize stack pointer} */
8062   init_sp (stack + sizeof (stack));
8064   /* @r{Initialize initialized data} */
8065   memcpy (&init_data, &data, &edata - &data);
8067   /* @r{Turn on the serial ports} */
8068   init_duart (&a);
8069   init_duart (&b);
8071 @end smallexample
8073 @noindent
8074 Use the @code{section} attribute with
8075 @emph{global} variables and not @emph{local} variables,
8076 as shown in the example.
8078 You may use the @code{section} attribute with initialized or
8079 uninitialized global variables but the linker requires
8080 each object be defined once, with the exception that uninitialized
8081 variables tentatively go in the @code{common} (or @code{bss}) section
8082 and can be multiply ``defined''.  Using the @code{section} attribute
8083 changes what section the variable goes into and may cause the
8084 linker to issue an error if an uninitialized variable has multiple
8085 definitions.  You can force a variable to be initialized with the
8086 @option{-fno-common} flag or the @code{nocommon} attribute.
8088 Some file formats do not support arbitrary sections so the @code{section}
8089 attribute is not available on all platforms.
8090 If you need to map the entire contents of a module to a particular
8091 section, consider using the facilities of the linker instead.
8093 @cindex @code{strict_flex_array} variable attribute
8094 @item strict_flex_array (@var{level})
8095 The @code{strict_flex_array} attribute should be attached to the trailing
8096 array field of a structure.  It controls when to treat the trailing array
8097 field of a structure as a flexible array member for the purposes of accessing
8098 the elements of such an array.
8099 @var{level} must be an integer betwen 0 to 3.
8101 @var{level}=0 is the least strict level, all trailing arrays of structures
8102 are treated as flexible array members. @var{level}=3 is the strictest level,
8103 only when the trailing array is declared as a flexible array member per C99
8104 standard onwards (@samp{[]}), it is treated as a flexible array member.
8106 There are two more levels in between 0 and 3, which are provided to
8107 support older codes that use GCC zero-length array extension
8108 (@samp{[0]}) or one-element array as flexible array members
8109 (@samp{[1]}).  When @var{level} is 1, the trailing array is treated as
8110 a flexible array member when it is declared as either @samp{[]},
8111 @samp{[0]}, or @samp{[1]}; When @var{level} is 2, the trailing array
8112 is treated as a flexible array member when it is declared as either
8113 @samp{[]}, or @samp{[0]}.
8115 This attribute can be used with or without the
8116 @option{-fstrict-flex-arrays} command-line option.  When both the
8117 attribute and the option are present at the same time, the level of
8118 the strictness for the specific trailing array field is determined by
8119 the attribute.
8121 The @code{strict_flex_array} attribute interacts with the
8122 @option{-Wstrict-flex-arrays} option.  @xref{Warning Options}, for more
8123 information.
8125 @cindex @code{tls_model} variable attribute
8126 @item tls_model ("@var{tls_model}")
8127 The @code{tls_model} attribute sets thread-local storage model
8128 (@pxref{Thread-Local}) of a particular @code{__thread} variable,
8129 overriding @option{-ftls-model=} command-line switch on a per-variable
8130 basis.
8131 The @var{tls_model} argument should be one of @code{global-dynamic},
8132 @code{local-dynamic}, @code{initial-exec} or @code{local-exec}.
8134 Not all targets support this attribute.
8136 @cindex @code{unavailable} variable attribute
8137 @item unavailable
8138 @itemx unavailable (@var{msg})
8139 The @code{unavailable} attribute indicates that the variable so marked
8140 is not available, if it is used anywhere in the source file.  It behaves
8141 in the same manner as the @code{deprecated} attribute except that the
8142 compiler will emit an error rather than a warning.
8144 It is expected that items marked as @code{deprecated} will eventually be
8145 withdrawn from interfaces, and then become unavailable.  This attribute
8146 allows for marking them appropriately.
8148 The @code{unavailable} attribute can also be used for functions and
8149 types (@pxref{Common Function Attributes},
8150 @pxref{Common Type Attributes}).
8152 @cindex @code{unused} variable attribute
8153 @item unused
8154 This attribute, attached to a variable or structure field, means that
8155 the variable or field is meant to be possibly unused.  GCC does not
8156 produce a warning for this variable or field.
8158 @cindex @code{used} variable attribute
8159 @item used
8160 This attribute, attached to a variable with static storage, means that
8161 the variable must be emitted even if it appears that the variable is not
8162 referenced.
8164 When applied to a static data member of a C++ class template, the
8165 attribute also means that the member is instantiated if the
8166 class itself is instantiated.
8168 @cindex @code{retain} variable attribute
8169 @item retain
8170 For ELF targets that support the GNU or FreeBSD OSABIs, this attribute
8171 will save the variable from linker garbage collection.  To support
8172 this behavior, variables that have not been placed in specific sections
8173 (e.g. by the @code{section} attribute, or the @code{-fdata-sections} option),
8174 will be placed in new, unique sections.
8176 This additional functionality requires Binutils version 2.36 or later.
8178 @cindex @code{uninitialized} variable attribute
8179 @item uninitialized
8180 This attribute, attached to a variable with automatic storage, means that
8181 the variable should not be automatically initialized by the compiler when
8182 the option @code{-ftrivial-auto-var-init} presents.
8184 With the option @code{-ftrivial-auto-var-init}, all the automatic variables
8185 that do not have explicit initializers will be initialized by the compiler.
8186 These additional compiler initializations might incur run-time overhead,
8187 sometimes dramatically.  This attribute can be used to mark some variables
8188 to be excluded from such automatical initialization in order to reduce runtime
8189 overhead.
8191 This attribute has no effect when the option @code{-ftrivial-auto-var-init}
8192 does not present.
8194 @cindex @code{vector_size} variable attribute
8195 @item vector_size (@var{bytes})
8196 This attribute specifies the vector size for the type of the declared
8197 variable, measured in bytes.  The type to which it applies is known as
8198 the @dfn{base type}.  The @var{bytes} argument must be a positive
8199 power-of-two multiple of the base type size.  For example, the declaration:
8201 @smallexample
8202 int foo __attribute__ ((vector_size (16)));
8203 @end smallexample
8205 @noindent
8206 causes the compiler to set the mode for @code{foo}, to be 16 bytes,
8207 divided into @code{int} sized units.  Assuming a 32-bit @code{int},
8208 @code{foo}'s type is a vector of four units of four bytes each, and
8209 the corresponding mode of @code{foo} is @code{V4SI}.
8210 @xref{Vector Extensions}, for details of manipulating vector variables.
8212 This attribute is only applicable to integral and floating scalars,
8213 although arrays, pointers, and function return values are allowed in
8214 conjunction with this construct.
8216 Aggregates with this attribute are invalid, even if they are of the same
8217 size as a corresponding scalar.  For example, the declaration:
8219 @smallexample
8220 struct S @{ int a; @};
8221 struct S  __attribute__ ((vector_size (16))) foo;
8222 @end smallexample
8224 @noindent
8225 is invalid even if the size of the structure is the same as the size of
8226 the @code{int}.
8228 @cindex @code{visibility} variable attribute
8229 @item visibility ("@var{visibility_type}")
8230 This attribute affects the linkage of the declaration to which it is attached.
8231 The @code{visibility} attribute is described in
8232 @ref{Common Function Attributes}.
8234 @cindex @code{warn_if_not_aligned} variable attribute
8235 @item warn_if_not_aligned (@var{alignment})
8236 This attribute specifies a threshold for the structure field, measured
8237 in bytes.  If the structure field is aligned below the threshold, a
8238 warning will be issued.  For example, the declaration:
8240 @smallexample
8241 struct foo
8243   int i1;
8244   int i2;
8245   unsigned long long x __attribute__ ((warn_if_not_aligned (16)));
8247 @end smallexample
8249 @noindent
8250 causes the compiler to issue an warning on @code{struct foo}, like
8251 @samp{warning: alignment 8 of 'struct foo' is less than 16}.
8252 The compiler also issues a warning, like @samp{warning: 'x' offset
8253 8 in 'struct foo' isn't aligned to 16}, when the structure field has
8254 the misaligned offset:
8256 @smallexample
8257 struct __attribute__ ((aligned (16))) foo
8259   int i1;
8260   int i2;
8261   unsigned long long x __attribute__ ((warn_if_not_aligned (16)));
8263 @end smallexample
8265 This warning can be disabled by @option{-Wno-if-not-aligned}.
8266 The @code{warn_if_not_aligned} attribute can also be used for types
8267 (@pxref{Common Type Attributes}.)
8269 @cindex @code{weak} variable attribute
8270 @item weak
8271 The @code{weak} attribute is described in
8272 @ref{Common Function Attributes}.
8274 @end table
8276 @node ARC Variable Attributes
8277 @subsection ARC Variable Attributes
8279 @table @code
8280 @cindex @code{aux} variable attribute, ARC
8281 @item aux
8282 The @code{aux} attribute is used to directly access the ARC's
8283 auxiliary register space from C.  The auxilirary register number is
8284 given via attribute argument.
8286 @end table
8288 @node AVR Variable Attributes
8289 @subsection AVR Variable Attributes
8291 @table @code
8292 @cindex @code{progmem} variable attribute, AVR
8293 @item progmem
8294 The @code{progmem} attribute is used on the AVR to place read-only
8295 data in the non-volatile program memory (flash). The @code{progmem}
8296 attribute accomplishes this by putting respective variables into a
8297 section whose name starts with @code{.progmem}.
8299 This attribute works similar to the @code{section} attribute
8300 but adds additional checking.
8302 @table @asis
8303 @item @bullet{} Ordinary AVR cores with 32 general purpose registers:
8304 @code{progmem} affects the location
8305 of the data but not how this data is accessed.
8306 In order to read data located with the @code{progmem} attribute
8307 (inline) assembler must be used.
8308 @smallexample
8309 /* Use custom macros from AVR-LibC */
8310 #include <avr/pgmspace.h> 
8312 /* Locate var in flash memory */
8313 const int var[2] PROGMEM = @{ 1, 2 @};
8315 int read_var (int i)
8317     /* Access var[] by accessor macro from avr/pgmspace.h */
8318     return (int) pgm_read_word (& var[i]);
8320 @end smallexample
8322 AVR is a Harvard architecture processor and data and read-only data
8323 normally resides in the data memory (RAM).
8325 See also the @ref{AVR Named Address Spaces} section for
8326 an alternate way to locate and access data in flash memory.
8328 @item @bullet{} AVR cores with flash memory visible in the RAM address range:
8329 On such devices, there is no need for attribute @code{progmem} or
8330 @ref{AVR Named Address Spaces,,@code{__flash}} qualifier at all.
8331 Just use standard C / C++.  The compiler will generate @code{LD*}
8332 instructions.  As flash memory is visible in the RAM address range,
8333 and the default linker script does @emph{not} locate @code{.rodata} in
8334 RAM, no special features are needed in order not to waste RAM for
8335 read-only data or to read from flash.  You might even get slightly better
8336 performance by
8337 avoiding @code{progmem} and @code{__flash}.  This applies to devices from
8338 families @code{avrtiny} and @code{avrxmega3}, see @ref{AVR Options} for
8339 an overview.
8341 @item @bullet{} Reduced AVR Tiny cores like ATtiny40:
8342 The compiler adds @code{0x4000}
8343 to the addresses of objects and declarations in @code{progmem} and locates
8344 the objects in flash memory, namely in section @code{.progmem.data}.
8345 The offset is needed because the flash memory is visible in the RAM
8346 address space starting at address @code{0x4000}.
8348 Data in @code{progmem} can be accessed by means of ordinary C@tie{}code,
8349 no special functions or macros are needed.
8351 @smallexample
8352 /* var is located in flash memory */
8353 extern const int var[2] __attribute__((progmem));
8355 int read_var (int i)
8357     return var[i];
8359 @end smallexample
8361 Please notice that on these devices, there is no need for @code{progmem}
8362 at all.
8364 @end table
8366 @cindex @code{io} variable attribute, AVR
8367 @item io
8368 @itemx io (@var{addr})
8369 Variables with the @code{io} attribute are used to address
8370 memory-mapped peripherals in the I/O address range.
8371 No memory is allocated.
8372 If an address is specified, the variable
8373 is assigned that address, and the value is interpreted as an
8374 address in the data address space.
8375 Example:
8377 @smallexample
8378 volatile int porta __attribute__((io (__AVR_SFR_OFFSET__ + 0x2)));
8379 @end smallexample
8381 Otherwise, the variable is not assigned an address, but the
8382 compiler will still use @code{in} and @code{out} instructions where applicable,
8383 assuming some other module assigns an address in the I/O address range.
8384 Example:
8386 @smallexample
8387 extern volatile int porta __attribute__((io));
8388 @end smallexample
8390 @cindex @code{io_low} variable attribute, AVR
8391 @item io_low
8392 @itemx io_low (@var{addr})
8393 This is like the @code{io} attribute, but additionally it informs the
8394 compiler that the object lies in the lower half of the I/O area,
8395 allowing the use of @code{cbi}, @code{sbi}, @code{sbic} and @code{sbis}
8396 instructions.
8398 @cindex @code{address} variable attribute, AVR
8399 @item address (@var{addr})
8400 Variables with the @code{address} attribute can be used to address
8401 memory-mapped peripherals that may lie outside the I/O address range.
8402 Just like with the @code{io} and @code{io_low} attributes, no memory is
8403 allocated.
8405 @smallexample
8406 volatile int porta __attribute__((address (0x600)));
8407 @end smallexample
8409 This attribute can also be used to define symbols in C/C++
8410 code which otherwise would require assembly, a linker description file
8411 or command line options like @code{-Wl,--defsym,a_symbol=@var{value}}.
8412 For example,
8413 @smallexample
8414 int a_symbol __attribute__((weak, address (1234)));
8415 @end smallexample
8416 will be compiled to
8417 @smallexample
8418 .weak a_symbol
8419 a_symbol = 1234
8420 @end smallexample
8422 @cindex @code{absdata} variable attribute, AVR
8423 @item absdata
8424 Variables in static storage and with the @code{absdata} attribute can
8425 be accessed by the @code{LDS} and @code{STS} instructions which take
8426 absolute addresses.
8428 @itemize @bullet
8429 @item
8430 This attribute is only supported for the reduced AVR Tiny core
8431 like ATtiny40.
8433 @item
8434 You must make sure that respective data is located in the
8435 address range @code{0x40}@dots{}@code{0xbf} accessible by
8436 @code{LDS} and @code{STS}.  One way to achieve this as an
8437 appropriate linker description file.
8439 @item
8440 If the location does not fit the address range of @code{LDS}
8441 and @code{STS}, there is currently (Binutils 2.26) just an unspecific
8442 warning like
8443 @quotation
8444 @code{module.cc:(.text+0x1c): warning: internal error: out of range error}
8445 @end quotation
8447 @end itemize
8449 See also the @option{-mabsdata} @ref{AVR Options,command-line option}.
8451 @end table
8453 @node Blackfin Variable Attributes
8454 @subsection Blackfin Variable Attributes
8456 Three attributes are currently defined for the Blackfin.
8458 @table @code
8459 @cindex @code{l1_data} variable attribute, Blackfin
8460 @cindex @code{l1_data_A} variable attribute, Blackfin
8461 @cindex @code{l1_data_B} variable attribute, Blackfin
8462 @item l1_data
8463 @itemx l1_data_A
8464 @itemx l1_data_B
8465 Use these attributes on the Blackfin to place the variable into L1 Data SRAM.
8466 Variables with @code{l1_data} attribute are put into the specific section
8467 named @code{.l1.data}. Those with @code{l1_data_A} attribute are put into
8468 the specific section named @code{.l1.data.A}. Those with @code{l1_data_B}
8469 attribute are put into the specific section named @code{.l1.data.B}.
8471 @cindex @code{l2} variable attribute, Blackfin
8472 @item l2
8473 Use this attribute on the Blackfin to place the variable into L2 SRAM.
8474 Variables with @code{l2} attribute are put into the specific section
8475 named @code{.l2.data}.
8476 @end table
8478 @node H8/300 Variable Attributes
8479 @subsection H8/300 Variable Attributes
8481 These variable attributes are available for H8/300 targets:
8483 @table @code
8484 @cindex @code{eightbit_data} variable attribute, H8/300
8485 @cindex eight-bit data on the H8/300, H8/300H, and H8S
8486 @item eightbit_data
8487 Use this attribute on the H8/300, H8/300H, and H8S to indicate that the specified
8488 variable should be placed into the eight-bit data section.
8489 The compiler generates more efficient code for certain operations
8490 on data in the eight-bit data area.  Note the eight-bit data area is limited to
8491 256 bytes of data.
8493 You must use GAS and GLD from GNU binutils version 2.7 or later for
8494 this attribute to work correctly.
8496 @cindex @code{tiny_data} variable attribute, H8/300
8497 @cindex tiny data section on the H8/300H and H8S
8498 @item tiny_data
8499 Use this attribute on the H8/300H and H8S to indicate that the specified
8500 variable should be placed into the tiny data section.
8501 The compiler generates more efficient code for loads and stores
8502 on data in the tiny data section.  Note the tiny data area is limited to
8503 slightly under 32KB of data.
8505 @end table
8507 @node IA-64 Variable Attributes
8508 @subsection IA-64 Variable Attributes
8510 The IA-64 back end supports the following variable attribute:
8512 @table @code
8513 @cindex @code{model} variable attribute, IA-64
8514 @item model (@var{model-name})
8516 On IA-64, use this attribute to set the addressability of an object.
8517 At present, the only supported identifier for @var{model-name} is
8518 @code{small}, indicating addressability via ``small'' (22-bit)
8519 addresses (so that their addresses can be loaded with the @code{addl}
8520 instruction).  Caveat: such addressing is by definition not position
8521 independent and hence this attribute must not be used for objects
8522 defined by shared libraries.
8524 @end table
8526 @node LoongArch Variable Attributes
8527 @subsection LoongArch Variable Attributes
8529 One attribute is currently defined for the LoongArch.
8531 @table @code
8532 @cindex @code{model} variable attribute, LoongArch
8533 @item model("@var{name}")
8534 Use this attribute on the LoongArch to use a different code model for
8535 addressing this variable, than the code model specified by the global
8536 @option{-mcmodel} option.  This attribute is mostly useful if a
8537 @code{section} attribute and/or a linker script will locate this object
8538 specially.  Currently the only supported values of @var{name} are
8539 @code{normal} and @code{extreme}.
8540 @end table
8542 @node M32R/D Variable Attributes
8543 @subsection M32R/D Variable Attributes
8545 One attribute is currently defined for the M32R/D@.
8547 @table @code
8548 @cindex @code{model-name} variable attribute, M32R/D
8549 @cindex variable addressability on the M32R/D
8550 @item model (@var{model-name})
8551 Use this attribute on the M32R/D to set the addressability of an object.
8552 The identifier @var{model-name} is one of @code{small}, @code{medium},
8553 or @code{large}, representing each of the code models.
8555 Small model objects live in the lower 16MB of memory (so that their
8556 addresses can be loaded with the @code{ld24} instruction).
8558 Medium and large model objects may live anywhere in the 32-bit address space
8559 (the compiler generates @code{seth/add3} instructions to load their
8560 addresses).
8561 @end table
8563 @node Microsoft Windows Variable Attributes
8564 @subsection Microsoft Windows Variable Attributes
8566 You can use these attributes on Microsoft Windows targets.
8567 @ref{x86 Variable Attributes} for additional Windows compatibility
8568 attributes available on all x86 targets.
8570 @table @code
8571 @cindex @code{dllimport} variable attribute
8572 @cindex @code{dllexport} variable attribute
8573 @item dllimport
8574 @itemx dllexport
8575 The @code{dllimport} and @code{dllexport} attributes are described in
8576 @ref{Microsoft Windows Function Attributes}.
8578 @cindex @code{selectany} variable attribute
8579 @item selectany
8580 The @code{selectany} attribute causes an initialized global variable to
8581 have link-once semantics.  When multiple definitions of the variable are
8582 encountered by the linker, the first is selected and the remainder are
8583 discarded.  Following usage by the Microsoft compiler, the linker is told
8584 @emph{not} to warn about size or content differences of the multiple
8585 definitions.
8587 Although the primary usage of this attribute is for POD types, the
8588 attribute can also be applied to global C++ objects that are initialized
8589 by a constructor.  In this case, the static initialization and destruction
8590 code for the object is emitted in each translation defining the object,
8591 but the calls to the constructor and destructor are protected by a
8592 link-once guard variable.
8594 The @code{selectany} attribute is only available on Microsoft Windows
8595 targets.  You can use @code{__declspec (selectany)} as a synonym for
8596 @code{__attribute__ ((selectany))} for compatibility with other
8597 compilers.
8599 @cindex @code{shared} variable attribute
8600 @item shared
8601 On Microsoft Windows, in addition to putting variable definitions in a named
8602 section, the section can also be shared among all running copies of an
8603 executable or DLL@.  For example, this small program defines shared data
8604 by putting it in a named section @code{shared} and marking the section
8605 shareable:
8607 @smallexample
8608 int foo __attribute__((section ("shared"), shared)) = 0;
8611 main()
8613   /* @r{Read and write foo.  All running
8614      copies see the same value.}  */
8615   return 0;
8617 @end smallexample
8619 @noindent
8620 You may only use the @code{shared} attribute along with @code{section}
8621 attribute with a fully-initialized global definition because of the way
8622 linkers work.  See @code{section} attribute for more information.
8624 The @code{shared} attribute is only available on Microsoft Windows@.
8626 @end table
8628 @node MSP430 Variable Attributes
8629 @subsection MSP430 Variable Attributes
8631 @table @code
8632 @cindex @code{upper} variable attribute, MSP430 
8633 @cindex @code{either} variable attribute, MSP430 
8634 @item upper
8635 @itemx either
8636 These attributes are the same as the MSP430 function attributes of the
8637 same name (@pxref{MSP430 Function Attributes}).  
8639 @cindex @code{lower} variable attribute, MSP430
8640 @item lower
8641 This option behaves mostly the same as the MSP430 function attribute of the
8642 same name (@pxref{MSP430 Function Attributes}), but it has some additional
8643 functionality.
8645 If @option{-mdata-region=}@{@code{upper,either,none}@} has been passed, or
8646 the @code{section} attribute is applied to a variable, the compiler will
8647 generate 430X instructions to handle it.  This is because the compiler has
8648 to assume that the variable could get placed in the upper memory region
8649 (above address 0xFFFF).  Marking the variable with the @code{lower} attribute
8650 informs the compiler that the variable will be placed in lower memory so it
8651 is safe to use 430 instructions to handle it.
8653 In the case of the @code{section} attribute, the section name given
8654 will be used, and the @code{.lower} prefix will not be added.
8656 @end table
8658 @node Nvidia PTX Variable Attributes
8659 @subsection Nvidia PTX Variable Attributes
8661 These variable attributes are supported by the Nvidia PTX back end:
8663 @table @code
8664 @cindex @code{shared} attribute, Nvidia PTX
8665 @item shared
8666 Use this attribute to place a variable in the @code{.shared} memory space.
8667 This memory space is private to each cooperative thread array; only threads
8668 within one thread block refer to the same instance of the variable.
8669 The runtime does not initialize variables in this memory space.
8670 @end table
8672 @node PowerPC Variable Attributes
8673 @subsection PowerPC Variable Attributes
8675 Three attributes currently are defined for PowerPC configurations:
8676 @code{altivec}, @code{ms_struct} and @code{gcc_struct}.
8678 @cindex @code{ms_struct} variable attribute, PowerPC
8679 @cindex @code{gcc_struct} variable attribute, PowerPC
8680 For full documentation of the struct attributes please see the
8681 documentation in @ref{x86 Variable Attributes}.
8683 @cindex @code{altivec} variable attribute, PowerPC
8684 For documentation of @code{altivec} attribute please see the
8685 documentation in @ref{PowerPC Type Attributes}.
8687 @node RL78 Variable Attributes
8688 @subsection RL78 Variable Attributes
8690 @cindex @code{saddr} variable attribute, RL78
8691 The RL78 back end supports the @code{saddr} variable attribute.  This
8692 specifies placement of the corresponding variable in the SADDR area,
8693 which can be accessed more efficiently than the default memory region.
8695 @node V850 Variable Attributes
8696 @subsection V850 Variable Attributes
8698 These variable attributes are supported by the V850 back end:
8700 @table @code
8702 @cindex @code{sda} variable attribute, V850
8703 @item sda
8704 Use this attribute to explicitly place a variable in the small data area,
8705 which can hold up to 64 kilobytes.
8707 @cindex @code{tda} variable attribute, V850
8708 @item tda
8709 Use this attribute to explicitly place a variable in the tiny data area,
8710 which can hold up to 256 bytes in total.
8712 @cindex @code{zda} variable attribute, V850
8713 @item zda
8714 Use this attribute to explicitly place a variable in the first 32 kilobytes
8715 of memory.
8716 @end table
8718 @node x86 Variable Attributes
8719 @subsection x86 Variable Attributes
8721 Two attributes are currently defined for x86 configurations:
8722 @code{ms_struct} and @code{gcc_struct}.
8724 @table @code
8725 @cindex @code{ms_struct} variable attribute, x86
8726 @cindex @code{gcc_struct} variable attribute, x86
8727 @item ms_struct
8728 @itemx gcc_struct
8730 If @code{packed} is used on a structure, or if bit-fields are used,
8731 it may be that the Microsoft ABI lays out the structure differently
8732 than the way GCC normally does.  Particularly when moving packed
8733 data between functions compiled with GCC and the native Microsoft compiler
8734 (either via function call or as data in a file), it may be necessary to access
8735 either format.
8737 The @code{ms_struct} and @code{gcc_struct} attributes correspond
8738 to the @option{-mms-bitfields} and @option{-mno-ms-bitfields}
8739 command-line options, respectively;
8740 see @ref{x86 Options}, for details of how structure layout is affected.
8741 @xref{x86 Type Attributes}, for information about the corresponding
8742 attributes on types.
8744 @end table
8746 @node Xstormy16 Variable Attributes
8747 @subsection Xstormy16 Variable Attributes
8749 One attribute is currently defined for xstormy16 configurations:
8750 @code{below100}.
8752 @table @code
8753 @cindex @code{below100} variable attribute, Xstormy16
8754 @item below100
8756 If a variable has the @code{below100} attribute (@code{BELOW100} is
8757 allowed also), GCC places the variable in the first 0x100 bytes of
8758 memory and use special opcodes to access it.  Such variables are
8759 placed in either the @code{.bss_below100} section or the
8760 @code{.data_below100} section.
8762 @end table
8764 @node Type Attributes
8765 @section Specifying Attributes of Types
8766 @cindex attribute of types
8767 @cindex type attributes
8769 You can use attributes to specify various special
8770 properties of types.  Some type attributes apply only to structure and
8771 union types, and in C++, also class types, while others can apply to
8772 any type defined via a @code{typedef} declaration.  Unless otherwise
8773 specified, the same restrictions and effects apply to attributes regardless
8774 of whether a type is a trivial structure or a C++ class with user-defined
8775 constructors, destructors, or a copy assignment.
8777 Other attributes are defined for functions (@pxref{Function Attributes}),
8778 labels (@pxref{Label  Attributes}), enumerators (@pxref{Enumerator
8779 Attributes}), statements (@pxref{Statement Attributes}), and for variables
8780 (@pxref{Variable Attributes}).
8782 GCC provides two different ways to specify attributes: the traditional
8783 GNU syntax using @samp{__attribute__ ((...))} annotations, and the
8784 newer standard C and C++ syntax using @samp{[[...]]} with the
8785 @samp{gnu::} prefix on attribute names.  Note that the exact rules for
8786 placement of attributes in your source code are different depending on
8787 which syntax you use.  @xref{Attribute Syntax}, for details.
8789 You may specify type attributes in an enum, struct or union type
8790 declaration or definition by placing them immediately after the
8791 @code{struct}, @code{union} or @code{enum} keyword.  You can also place
8792 them just past the closing curly brace of the definition, but this is less
8793 preferred because logically the type should be fully defined at 
8794 the closing brace.  You can also include type attributes in a
8795 @code{typedef} declaration.
8797 @menu
8798 * Common Type Attributes::
8799 * ARC Type Attributes::
8800 * ARM Type Attributes::
8801 * BPF Type Attributes::
8802 * PowerPC Type Attributes::
8803 * x86 Type Attributes::
8804 @end menu
8806 @node Common Type Attributes
8807 @subsection Common Type Attributes
8809 The following type attributes are supported on most targets.
8811 @table @code
8812 @c Keep this table alphabetized by attribute name.  Treat _ as space.
8814 @cindex @code{aligned} type attribute
8815 @item aligned
8816 @itemx aligned (@var{alignment})
8817 The @code{aligned} attribute specifies a minimum alignment (in bytes) for
8818 variables of the specified type.  When specified, @var{alignment} must be
8819 a power of 2.  Specifying no @var{alignment} argument implies the maximum
8820 alignment for the target, which is often, but by no means always, 8 or 16
8821 bytes.  For example, the declarations:
8823 @smallexample
8824 struct __attribute__ ((aligned (8))) S @{ short f[3]; @};
8825 typedef int more_aligned_int __attribute__ ((aligned (8)));
8826 @end smallexample
8828 @noindent
8829 force the compiler to ensure (as far as it can) that each variable whose
8830 type is @code{struct S} or @code{more_aligned_int} is allocated and
8831 aligned @emph{at least} on a 8-byte boundary.  On a SPARC, having all
8832 variables of type @code{struct S} aligned to 8-byte boundaries allows
8833 the compiler to use the @code{ldd} and @code{std} (doubleword load and
8834 store) instructions when copying one variable of type @code{struct S} to
8835 another, thus improving run-time efficiency.
8837 Note that the alignment of any given @code{struct} or @code{union} type
8838 is required by the ISO C standard to be at least a perfect multiple of
8839 the lowest common multiple of the alignments of all of the members of
8840 the @code{struct} or @code{union} in question.  This means that you @emph{can}
8841 effectively adjust the alignment of a @code{struct} or @code{union}
8842 type by attaching an @code{aligned} attribute to any one of the members
8843 of such a type, but the notation illustrated in the example above is a
8844 more obvious, intuitive, and readable way to request the compiler to
8845 adjust the alignment of an entire @code{struct} or @code{union} type.
8847 As in the preceding example, you can explicitly specify the alignment
8848 (in bytes) that you wish the compiler to use for a given @code{struct}
8849 or @code{union} type.  Alternatively, you can leave out the alignment factor
8850 and just ask the compiler to align a type to the maximum
8851 useful alignment for the target machine you are compiling for.  For
8852 example, you could write:
8854 @smallexample
8855 struct __attribute__ ((aligned)) S @{ short f[3]; @};
8856 @end smallexample
8858 Whenever you leave out the alignment factor in an @code{aligned}
8859 attribute specification, the compiler automatically sets the alignment
8860 for the type to the largest alignment that is ever used for any data
8861 type on the target machine you are compiling for.  Doing this can often
8862 make copy operations more efficient, because the compiler can use
8863 whatever instructions copy the biggest chunks of memory when performing
8864 copies to or from the variables that have types that you have aligned
8865 this way.
8867 In the example above, if the size of each @code{short} is 2 bytes, then
8868 the size of the entire @code{struct S} type is 6 bytes.  The smallest
8869 power of two that is greater than or equal to that is 8, so the
8870 compiler sets the alignment for the entire @code{struct S} type to 8
8871 bytes.
8873 Note that although you can ask the compiler to select a time-efficient
8874 alignment for a given type and then declare only individual stand-alone
8875 objects of that type, the compiler's ability to select a time-efficient
8876 alignment is primarily useful only when you plan to create arrays of
8877 variables having the relevant (efficiently aligned) type.  If you
8878 declare or use arrays of variables of an efficiently-aligned type, then
8879 it is likely that your program also does pointer arithmetic (or
8880 subscripting, which amounts to the same thing) on pointers to the
8881 relevant type, and the code that the compiler generates for these
8882 pointer arithmetic operations is often more efficient for
8883 efficiently-aligned types than for other types.
8885 Note that the effectiveness of @code{aligned} attributes may be limited
8886 by inherent limitations in your linker.  On many systems, the linker is
8887 only able to arrange for variables to be aligned up to a certain maximum
8888 alignment.  (For some linkers, the maximum supported alignment may
8889 be very very small.)  If your linker is only able to align variables
8890 up to a maximum of 8-byte alignment, then specifying @code{aligned (16)}
8891 in an @code{__attribute__} still only provides you with 8-byte
8892 alignment.  See your linker documentation for further information.
8894 When used on a struct, or struct member, the @code{aligned} attribute can
8895 only increase the alignment; in order to decrease it, the @code{packed}
8896 attribute must be specified as well.  When used as part of a typedef, the
8897 @code{aligned} attribute can both increase and decrease alignment, and
8898 specifying the @code{packed} attribute generates a warning.
8900 @cindex @code{alloc_size} type attribute
8901 @item alloc_size (@var{position})
8902 @itemx alloc_size (@var{position-1}, @var{position-2})
8903 The @code{alloc_size} type attribute may be applied to the definition
8904 of a type of a function that returns a pointer and takes at least one
8905 argument of an integer type.  It indicates that the returned pointer
8906 points to an object whose size is given by the function argument at
8907 @var{position-1}, or by the product of the arguments at @var{position-1}
8908 and @var{position-2}.  Meaningful sizes are positive values less than
8909 @code{PTRDIFF_MAX}.  Other sizes are disagnosed when detected.  GCC uses
8910 this information to improve the results of @code{__builtin_object_size}.
8912 For instance, the following declarations
8914 @smallexample
8915 typedef __attribute__ ((alloc_size (1, 2))) void*
8916   calloc_type (size_t, size_t);
8917 typedef __attribute__ ((alloc_size (1))) void*
8918   malloc_type (size_t);
8919 @end smallexample
8921 @noindent
8922 specify that @code{calloc_type} is a type of a function that, like
8923 the standard C function @code{calloc}, returns an object whose size
8924 is given by the product of arguments 1 and 2, and that
8925 @code{malloc_type}, like the standard C function @code{malloc},
8926 returns an object whose size is given by argument 1 to the function.
8928 @cindex @code{copy} type attribute
8929 @item copy
8930 @itemx copy (@var{expression})
8931 The @code{copy} attribute applies the set of attributes with which
8932 the type of the @var{expression} has been declared to the declaration
8933 of the type to which the attribute is applied.  The attribute is
8934 designed for libraries that define aliases that are expected to
8935 specify the same set of attributes as the aliased symbols.
8936 The @code{copy} attribute can be used with types, variables, or
8937 functions.  However, the kind of symbol to which the attribute is
8938 applied (either varible or function) must match the kind of symbol
8939 to which the argument refers.
8940 The @code{copy} attribute copies only syntactic and semantic attributes
8941 but not attributes that affect a symbol's linkage or visibility such as
8942 @code{alias}, @code{visibility}, or @code{weak}.  The @code{deprecated}
8943 attribute is also not copied.  @xref{Common Function Attributes}.
8944 @xref{Common Variable Attributes}.
8946 For example, suppose @code{struct A} below is defined in some third
8947 party library header to have the alignment requirement @code{N} and
8948 to force a warning whenever a variable of the type is not so aligned
8949 due to attribute @code{packed}.  Specifying the @code{copy} attribute
8950 on the definition on the unrelated @code{struct B} has the effect of
8951 copying all relevant attributes from the type referenced by the pointer
8952 expression to @code{struct B}.
8954 @smallexample
8955 struct __attribute__ ((aligned (N), warn_if_not_aligned (N)))
8956 A @{ /* @r{@dots{}} */ @};
8957 struct __attribute__ ((copy ( (struct A *)0)) B @{ /* @r{@dots{}} */ @};
8958 @end smallexample
8960 @cindex @code{deprecated} type attribute
8961 @item deprecated
8962 @itemx deprecated (@var{msg})
8963 The @code{deprecated} attribute results in a warning if the type
8964 is used anywhere in the source file.  This is useful when identifying
8965 types that are expected to be removed in a future version of a program.
8966 If possible, the warning also includes the location of the declaration
8967 of the deprecated type, to enable users to easily find further
8968 information about why the type is deprecated, or what they should do
8969 instead.  Note that the warnings only occur for uses and then only
8970 if the type is being applied to an identifier that itself is not being
8971 declared as deprecated.
8973 @smallexample
8974 typedef int T1 __attribute__ ((deprecated));
8975 T1 x;
8976 typedef T1 T2;
8977 T2 y;
8978 typedef T1 T3 __attribute__ ((deprecated));
8979 T3 z __attribute__ ((deprecated));
8980 @end smallexample
8982 @noindent
8983 results in a warning on line 2 and 3 but not lines 4, 5, or 6.  No
8984 warning is issued for line 4 because T2 is not explicitly
8985 deprecated.  Line 5 has no warning because T3 is explicitly
8986 deprecated.  Similarly for line 6.  The optional @var{msg}
8987 argument, which must be a string, is printed in the warning if
8988 present.  Control characters in the string will be replaced with
8989 escape sequences, and if the @option{-fmessage-length} option is set
8990 to 0 (its default value) then any newline characters will be ignored.
8992 The @code{deprecated} attribute can also be used for functions and
8993 variables (@pxref{Function Attributes}, @pxref{Variable Attributes}.)
8995 The message attached to the attribute is affected by the setting of
8996 the @option{-fmessage-length} option.
8998 @cindex @code{designated_init} type attribute
8999 @item designated_init
9000 This attribute may only be applied to structure types.  It indicates
9001 that any initialization of an object of this type must use designated
9002 initializers rather than positional initializers.  The intent of this
9003 attribute is to allow the programmer to indicate that a structure's
9004 layout may change, and that therefore relying on positional
9005 initialization will result in future breakage.
9007 GCC emits warnings based on this attribute by default; use
9008 @option{-Wno-designated-init} to suppress them.
9010 @cindex @code{hardbool} type attribute
9011 @item hardbool
9012 @itemx hardbool (@var{false_value})
9013 @itemx hardbool (@var{false_value}, @var{true_value})
9014 This attribute may only be applied to integral types in C, to introduce
9015 hardened boolean types.  It turns the integral type into a boolean-like
9016 type with the same size and precision, that uses the specified values as
9017 representations for @code{false} and @code{true}.  Underneath, it is
9018 actually an enumerated type, but its observable behavior is like that of
9019 @code{_Bool}, except for the strict internal representations, verified
9020 by runtime checks.
9022 If @var{true_value} is omitted, the bitwise negation of
9023 @var{false_value} is used.  If @var{false_value} is omitted, zero is
9024 used.  The named representation values must be different when converted
9025 to the original integral type.  Narrower bitfields are rejected if the
9026 representations become indistinguishable.
9028 Values of such types automatically decay to @code{_Bool}, at which
9029 point, the selected representation values are mapped to the
9030 corresponding @code{_Bool} values.  When the represented value is not
9031 determined, at compile time, to be either @var{false_value} or
9032 @var{true_value}, runtime verification calls @code{__builtin_trap} if it
9033 is neither.  This is what makes them hardened boolean types.
9035 When converting scalar types to such hardened boolean types, implicitly
9036 or explicitly, behavior corresponds to a conversion to @code{_Bool},
9037 followed by a mapping from @code{false} and @code{true} to
9038 @var{false_value} and @var{true_value}, respectively.
9040 @smallexample
9041 typedef char __attribute__ ((__hardbool__ (0x5a))) hbool;
9042 hbool first = 0;       /* False, stored as (char)0x5a.  */
9043 hbool second = !first; /* True, stored as ~(char)0x5a.  */
9045 static hbool zeroinit; /* False, stored as (char)0x5a.  */
9046 auto hbool uninit;     /* Undefined, may trap.  */
9047 @end smallexample
9049 When zero-initializing a variable or field of hardened boolean type
9050 (presumably held in static storage) the implied zero initializer gets
9051 converted to @code{_Bool}, and then to the hardened boolean type, so
9052 that the initial value is the hardened representation for @code{false}.
9053 Using that value is well defined.  This is @emph{not} the case when
9054 variables and fields of such types are uninitialized (presumably held in
9055 automatic or dynamic storage): their values are indeterminate, and using
9056 them invokes undefined behavior.  Using them may trap or not, depending
9057 on the bits held in the storage (re)used for the variable, if any, and
9058 on optimizations the compiler may perform on the grounds that using
9059 uninitialized values invokes undefined behavior.
9061 Users of @option{-ftrivial-auto-var-init} should be aware that the bit
9062 patterns used as initializers are @emph{not} converted to
9063 @code{hardbool} types, so using a @code{hardbool} variable that is
9064 implicitly initialized by the @option{-ftrivial-auto-var-init} may trap
9065 if the representations values chosen for @code{false} and @code{true} do
9066 not match the initializer.
9068 Since this is a language extension only available in C, interoperation
9069 with other languages may pose difficulties.  It should interoperate with
9070 Ada Booleans defined with the same size and equivalent representation
9071 clauses, and with enumerations or other languages' integral types that
9072 correspond to C's chosen integral type.
9075 @cindex @code{may_alias} type attribute
9076 @item may_alias
9077 Accesses through pointers to types with this attribute are not subject
9078 to type-based alias analysis, but are instead assumed to be able to alias
9079 any other type of objects.
9080 In the context of section 6.5 paragraph 7 of the C99 standard,
9081 an lvalue expression
9082 dereferencing such a pointer is treated like having a character type.
9083 See @option{-fstrict-aliasing} for more information on aliasing issues.
9084 This extension exists to support some vector APIs, in which pointers to
9085 one vector type are permitted to alias pointers to a different vector type.
9087 Note that an object of a type with this attribute does not have any
9088 special semantics.
9090 Example of use:
9092 @smallexample
9093 typedef short __attribute__ ((__may_alias__)) short_a;
9096 main (void)
9098   int a = 0x12345678;
9099   short_a *b = (short_a *) &a;
9101   b[1] = 0;
9103   if (a == 0x12345678)
9104     abort();
9106   exit(0);
9108 @end smallexample
9110 @noindent
9111 If you replaced @code{short_a} with @code{short} in the variable
9112 declaration, the above program would abort when compiled with
9113 @option{-fstrict-aliasing}, which is on by default at @option{-O2} or
9114 above.
9116 @cindex @code{mode} type attribute
9117 @item mode (@var{mode})
9118 This attribute specifies the data type for the declaration---whichever
9119 type corresponds to the mode @var{mode}.  This in effect lets you
9120 request an integer or floating-point type according to its width.
9122 @xref{Machine Modes,,, gccint, GNU Compiler Collection (GCC) Internals},
9123 for a list of the possible keywords for @var{mode}.
9124 You may also specify a mode of @code{byte} or @code{__byte__} to
9125 indicate the mode corresponding to a one-byte integer, @code{word} or
9126 @code{__word__} for the mode of a one-word integer, and @code{pointer}
9127 or @code{__pointer__} for the mode used to represent pointers.
9129 @cindex @code{objc_root_class} type attribute
9130 @item objc_root_class @r{(Objective-C and Objective-C++ only)}
9131 This attribute marks a class as being a root class, and thus allows
9132 the compiler to elide any warnings about a missing superclass and to
9133 make additional checks for mandatory methods as needed.
9135 @cindex @code{packed} type attribute
9136 @item packed
9137 This attribute, attached to a @code{struct}, @code{union}, or C++ @code{class}
9138 type definition, specifies that each of its members (other than zero-width
9139 bit-fields) is placed to minimize the memory required.  This is equivalent
9140 to specifying the @code{packed} attribute on each of the members.
9142 @opindex fshort-enums
9143 When attached to an @code{enum} definition, the @code{packed} attribute
9144 indicates that the smallest integral type should be used.
9145 Specifying the @option{-fshort-enums} flag on the command line
9146 is equivalent to specifying the @code{packed}
9147 attribute on all @code{enum} definitions.
9149 In the following example @code{struct my_packed_struct}'s members are
9150 packed closely together, but the internal layout of its @code{s} member
9151 is not packed---to do that, @code{struct my_unpacked_struct} needs to
9152 be packed too.
9154 @smallexample
9155 struct my_unpacked_struct
9156  @{
9157     char c;
9158     int i;
9159  @};
9161 struct __attribute__ ((__packed__)) my_packed_struct
9162   @{
9163      char c;
9164      int  i;
9165      struct my_unpacked_struct s;
9166   @};
9167 @end smallexample
9169 You may only specify the @code{packed} attribute on the definition
9170 of an @code{enum}, @code{struct}, @code{union}, or @code{class}, 
9171 not on a @code{typedef} that does not also define the enumerated type,
9172 structure, union, or class.
9174 @cindex @code{scalar_storage_order} type attribute
9175 @item scalar_storage_order ("@var{endianness}")
9176 When attached to a @code{union} or a @code{struct}, this attribute sets
9177 the storage order, aka endianness, of the scalar fields of the type, as
9178 well as the array fields whose component is scalar.  The supported
9179 endiannesses are @code{big-endian} and @code{little-endian}.  The attribute
9180 has no effects on fields which are themselves a @code{union}, a @code{struct}
9181 or an array whose component is a @code{union} or a @code{struct}, and it is
9182 possible for these fields to have a different scalar storage order than the
9183 enclosing type.
9185 Note that neither pointer nor vector fields are considered scalar fields in
9186 this context, so the attribute has no effects on these fields.
9188 This attribute is supported only for targets that use a uniform default
9189 scalar storage order (fortunately, most of them), i.e.@: targets that store
9190 the scalars either all in big-endian or all in little-endian.
9192 Additional restrictions are enforced for types with the reverse scalar
9193 storage order with regard to the scalar storage order of the target:
9195 @itemize
9196 @item Taking the address of a scalar field of a @code{union} or a
9197 @code{struct} with reverse scalar storage order is not permitted and yields
9198 an error.
9199 @item Taking the address of an array field, whose component is scalar, of
9200 a @code{union} or a @code{struct} with reverse scalar storage order is
9201 permitted but yields a warning, unless @option{-Wno-scalar-storage-order}
9202 is specified.
9203 @item Taking the address of a @code{union} or a @code{struct} with reverse
9204 scalar storage order is permitted.
9205 @end itemize
9207 These restrictions exist because the storage order attribute is lost when
9208 the address of a scalar or the address of an array with scalar component is
9209 taken, so storing indirectly through this address generally does not work.
9210 The second case is nevertheless allowed to be able to perform a block copy
9211 from or to the array.
9213 Moreover, the use of type punning or aliasing to toggle the storage order
9214 is not supported; that is to say, if a given scalar object can be accessed
9215 through distinct types that assign a different storage order to it, then the
9216 behavior is undefined.
9218 @cindex @code{strub} type attribute
9219 @item strub
9220 This attribute defines stack-scrubbing properties of functions and
9221 variables, so that functions that access sensitive data can have their
9222 stack frames zeroed-out upon returning or propagating exceptions.  This
9223 may be enabled explicitly, by selecting certain @code{strub} modes for
9224 specific functions, or implicitly, by means of @code{strub} variables.
9226 Being a type attribute, it attaches to types, even when specified in
9227 function and variable declarations.  When applied to function types, it
9228 takes an optional string argument.  When applied to a
9229 pointer-to-function type, if the optional argument is given, it gets
9230 propagated to the function type.
9232 @smallexample
9233 /* A strub variable.  */
9234 int __attribute__ ((strub)) var;
9235 /* A strub variable that happens to be a pointer.  */
9236 __attribute__ ((strub)) int *strub_ptr_to_int;
9237 /* A pointer type that may point to a strub variable.  */
9238 typedef int __attribute__ ((strub)) *ptr_to_strub_int_type;
9240 /* A declaration of a strub function.  */
9241 extern int __attribute__ ((strub)) foo (void);
9242 /* A pointer to that strub function.  */
9243 int __attribute__ ((strub ("at-calls"))) (*ptr_to_strub_fn)(void) = foo;
9244 @end smallexample
9246 A function associated with @code{at-calls} @code{strub} mode
9247 (@code{strub("at-calls")}, or just @code{strub}) undergoes interface
9248 changes.  Its callers are adjusted to match the changes, and to scrub
9249 (overwrite with zeros) the stack space used by the called function after
9250 it returns.  The interface change makes the function type incompatible
9251 with an unadorned but otherwise equivalent type, so @emph{every}
9252 declaration and every type that may be used to call the function must be
9253 associated with this strub mode.
9255 A function associated with @code{internal} @code{strub} mode
9256 (@code{strub("internal")}) retains an unmodified, type-compatible
9257 interface, but it may be turned into a wrapper that calls the wrapped
9258 body using a custom interface.  The wrapper then scrubs the stack space
9259 used by the wrapped body.  Though the wrapped body has its stack space
9260 scrubbed, the wrapper does not, so arguments and return values may
9261 remain unscrubbed even when such a function is called by another
9262 function that enables @code{strub}.  This is why, when compiling with
9263 @option{-fstrub=strict}, a @code{strub} context is not allowed to call
9264 @code{internal} @code{strub} functions.
9266 @smallexample
9267 /* A declaration of an internal-strub function.  */
9268 extern int __attribute__ ((strub ("internal"))) bar (void);
9270 int __attribute__ ((strub))
9271 baz (void)
9273   /* Ok, foo was declared above as an at-calls strub function.  */
9274   foo ();
9275   /* Not allowed in strict mode, otherwise allowed.  */
9276   bar ();
9278 @end smallexample
9280 An automatically-allocated variable associated with the @code{strub}
9281 attribute causes the (immediately) enclosing function to have
9282 @code{strub} enabled.
9284 A statically-allocated variable associated with the @code{strub}
9285 attribute causes functions that @emph{read} it, through its @code{strub}
9286 data type, to have @code{strub} enabled.  Reading data by dereferencing
9287 a pointer to a @code{strub} data type has the same effect.  Note: The
9288 attribute does not carry over from a composite type to the types of its
9289 components, so the intended effect may not be obtained with non-scalar
9290 types.
9292 When selecting a @code{strub}-enabled mode for a function that is not
9293 explicitly associated with one, because of @code{strub} variables or
9294 data pointers, the function must satisfy @code{internal} mode viability
9295 requirements (see below), even when @code{at-calls} mode is also viable
9296 and, being more efficient, ends up selected as an optimization.
9298 @smallexample
9299 /* zapme is implicitly strub-enabled because of strub variables.
9300    Optimization may change its strub mode, but not the requirements.  */
9301 static int
9302 zapme (int i)
9304   /* A local strub variable enables strub.  */
9305   int __attribute__ ((strub)) lvar;
9306   /* Reading strub data through a pointer-to-strub enables strub.  */
9307   lvar = * (ptr_to_strub_int_type) &i;
9308   /* Writing to a global strub variable does not enable strub.  */
9309   var = lvar;
9310   /* Reading from a global strub variable enables strub.  */
9311   return var;
9313 @end smallexample
9315 A @code{strub} context is the body (as opposed to the interface) of a
9316 function that has @code{strub} enabled, be it explicitly, by
9317 @code{at-calls} or @code{internal} mode, or implicitly, due to
9318 @code{strub} variables or command-line options.
9320 A function of a type associated with the @code{disabled} @code{strub}
9321 mode (@code{strub("disabled")} will not have its own stack space
9322 scrubbed.  Such functions @emph{cannot} be called from within
9323 @code{strub} contexts.
9325 In order to enable a function to be called from within @code{strub}
9326 contexts without having its stack space scrubbed, associate it with the
9327 @code{callable} @code{strub} mode (@code{strub("callable")}).
9329 When a function is not assigned a @code{strub} mode, explicitly or
9330 implicitly, the mode defaults to @code{callable}, except when compiling
9331 with @option{-fstrub=strict}, that causes @code{strub} mode to default
9332 to @code{disabled}.
9334 @example
9335 extern int __attribute__ ((strub ("callable"))) bac (void);
9336 extern int __attribute__ ((strub ("disabled"))) bad (void);
9337  /* Implicitly disabled with -fstrub=strict, otherwise callable.  */
9338 extern int bah (void);
9340 int __attribute__ ((strub))
9341 bal (void)
9343   /* Not allowed, bad is not strub-callable.  */
9344   bad ();
9345   /* Ok, bac is strub-callable.  */
9346   bac ();
9347   /* Not allowed with -fstrub=strict, otherwise allowed.  */
9348   bah ();
9350 @end example
9352 Function types marked @code{callable} and @code{disabled} are not
9353 mutually compatible types, but the underlying interfaces are compatible,
9354 so it is safe to convert pointers between them, and to use such pointers
9355 or alternate declarations to call them.  Interfaces are also
9356 interchangeable between them and @code{internal} (but not
9357 @code{at-calls}!), but adding @code{internal} to a pointer type will not
9358 cause the pointed-to function to perform stack scrubbing.
9360 @example
9361 void __attribute__ ((strub))
9362 bap (void)
9364   /* Assign a callable function to pointer-to-disabled.
9365      Flagged as not quite compatible with -Wpedantic.  */
9366   int __attribute__ ((strub ("disabled"))) (*d_p) (void) = bac;
9367   /* Not allowed: calls disabled type in a strub context.  */
9368   d_p ();
9370   /* Assign a disabled function to pointer-to-callable.
9371      Flagged as not quite compatible with -Wpedantic.  */
9372   int __attribute__ ((strub ("callable"))) (*c_p) (void) = bad;
9373   /* Ok, safe.  */
9374   c_p ();
9376   /* Assign an internal function to pointer-to-callable.
9377      Flagged as not quite compatible with -Wpedantic.  */
9378   c_p = bar;
9379   /* Ok, safe.  */
9380   c_p ();
9382   /* Assign an at-calls function to pointer-to-callable.
9383      Flaggged as incompatible.  */
9384   c_p = bal;
9385   /* The call through an interface-incompatible type will not use the
9386      modified interface expected by the at-calls function, so it is
9387      likely to misbehave at runtime.  */
9388   c_p ();
9390 @end example
9392 @code{Strub} contexts are never inlined into non-@code{strub} contexts.
9393 When an @code{internal}-strub function is split up, the wrapper can
9394 often be inlined, but the wrapped body @emph{never} is.  A function
9395 marked as @code{always_inline}, even if explicitly assigned
9396 @code{internal} strub mode, will not undergo wrapping, so its body gets
9397 inlined as required.
9399 @example
9400 inline int __attribute__ ((strub ("at-calls")))
9401 inl_atc (void)
9403   /* This body may get inlined into strub contexts.  */
9406 inline int __attribute__ ((strub ("internal")))
9407 inl_int (void)
9409   /* This body NEVER gets inlined, though its wrapper may.  */
9412 inline int __attribute__ ((strub ("internal"), always_inline))
9413 inl_int_ali (void)
9415   /* No internal wrapper, so this body ALWAYS gets inlined,
9416      but it cannot be called from non-strub contexts.  */
9419 void __attribute__ ((strub ("disabled")))
9420 bat (void)
9422   /* Not allowed, cannot inline into a non-strub context.  */
9423   inl_int_ali ();
9425 @end example
9427 @cindex strub eligibility and viability
9428 Some @option{-fstrub=*} command line options enable @code{strub} modes
9429 implicitly where viable.  A @code{strub} mode is only viable for a
9430 function if the function is eligible for that mode, and if other
9431 conditions, detailed below, are satisfied.  If it's not eligible for a
9432 mode, attempts to explicitly associate it with that mode are rejected
9433 with an error message.  If it is eligible, that mode may be assigned
9434 explicitly through this attribute, but implicit assignment through
9435 command-line options may involve additional viability requirements.
9437 A function is ineligible for @code{at-calls} @code{strub} mode if a
9438 different @code{strub} mode is explicitly requested, if attribute
9439 @code{noipa} is present, or if it calls @code{__builtin_apply_args}.
9440 @code{At-calls} @code{strub} mode, if not requested through the function
9441 type, is only viable for an eligible function if the function is not
9442 visible to other translation units, if it doesn't have its address
9443 taken, and if it is never called with a function type overrider.
9445 @smallexample
9446 /* bar is eligible for at-calls strub mode,
9447    but not viable for that mode because it is visible to other units.
9448    It is eligible and viable for internal strub mode.  */
9449 void bav () @{@}
9451 /* setp is eligible for at-calls strub mode,
9452    but not viable for that mode because its address is taken.
9453    It is eligible and viable for internal strub mode.  */
9454 void setp (void) @{ static void (*p)(void); = setp; @}
9455 @end smallexample
9457 A function is ineligible for @code{internal} @code{strub} mode if a
9458 different @code{strub} mode is explicitly requested, or if attribute
9459 @code{noipa} is present.  For an @code{always_inline} function, meeting
9460 these requirements is enough to make it eligible.  Any function that has
9461 attribute @code{noclone}, that uses such extensions as non-local labels,
9462 computed gotos, alternate variable argument passing interfaces,
9463 @code{__builtin_next_arg}, or @code{__builtin_return_address}, or that
9464 takes too many (about 64Ki) arguments is ineligible, unless it is
9465 @code{always_inline}.  For @code{internal} @code{strub} mode, all
9466 eligible functions are viable.
9468 @smallexample
9469 /* flop is not eligible, thus not viable, for at-calls strub mode.
9470    Likewise for internal strub mode.  */
9471 __attribute__ ((noipa)) void flop (void) @{@}
9473 /* flip is eligible and viable for at-calls strub mode.
9474    It would be ineligible for internal strub mode, because of noclone,
9475    if it weren't for always_inline.  With always_inline, noclone is not
9476    an obstacle, so it is also eligible and viable for internal strub mode.  */
9477 inline __attribute__ ((noclone, always_inline)) void flip (void) @{@}
9478 @end smallexample
9480 @cindex @code{transparent_union} type attribute
9481 @item transparent_union
9483 This attribute, attached to a @code{union} type definition, indicates
9484 that any function parameter having that union type causes calls to that
9485 function to be treated in a special way.
9487 First, the argument corresponding to a transparent union type can be of
9488 any type in the union; no cast is required.  Also, if the union contains
9489 a pointer type, the corresponding argument can be a null pointer
9490 constant or a void pointer expression; and if the union contains a void
9491 pointer type, the corresponding argument can be any pointer expression.
9492 If the union member type is a pointer, qualifiers like @code{const} on
9493 the referenced type must be respected, just as with normal pointer
9494 conversions.
9496 Second, the argument is passed to the function using the calling
9497 conventions of the first member of the transparent union, not the calling
9498 conventions of the union itself.  All members of the union must have the
9499 same machine representation; this is necessary for this argument passing
9500 to work properly.
9502 Transparent unions are designed for library functions that have multiple
9503 interfaces for compatibility reasons.  For example, suppose the
9504 @code{wait} function must accept either a value of type @code{int *} to
9505 comply with POSIX, or a value of type @code{union wait *} to comply with
9506 the 4.1BSD interface.  If @code{wait}'s parameter were @code{void *},
9507 @code{wait} would accept both kinds of arguments, but it would also
9508 accept any other pointer type and this would make argument type checking
9509 less useful.  Instead, @code{<sys/wait.h>} might define the interface
9510 as follows:
9512 @smallexample
9513 typedef union __attribute__ ((__transparent_union__))
9514   @{
9515     int *__ip;
9516     union wait *__up;
9517   @} wait_status_ptr_t;
9519 pid_t wait (wait_status_ptr_t);
9520 @end smallexample
9522 @noindent
9523 This interface allows either @code{int *} or @code{union wait *}
9524 arguments to be passed, using the @code{int *} calling convention.
9525 The program can call @code{wait} with arguments of either type:
9527 @smallexample
9528 int w1 () @{ int w; return wait (&w); @}
9529 int w2 () @{ union wait w; return wait (&w); @}
9530 @end smallexample
9532 @noindent
9533 With this interface, @code{wait}'s implementation might look like this:
9535 @smallexample
9536 pid_t wait (wait_status_ptr_t p)
9538   return waitpid (-1, p.__ip, 0);
9540 @end smallexample
9542 @cindex @code{unavailable} type attribute
9543 @item unavailable
9544 @itemx unavailable (@var{msg})
9545 The @code{unavailable} attribute behaves in the same manner as the
9546 @code{deprecated} one, but emits an error rather than a warning.  It is
9547 used to indicate that a (perhaps previously @code{deprecated}) type is
9548 no longer usable.
9550 The @code{unavailable} attribute can also be used for functions and
9551 variables (@pxref{Function Attributes}, @pxref{Variable Attributes}.)
9553 @cindex @code{unused} type attribute
9554 @item unused
9555 When attached to a type (including a @code{union} or a @code{struct}),
9556 this attribute means that variables of that type are meant to appear
9557 possibly unused.  GCC does not produce a warning for any variables of
9558 that type, even if the variable appears to do nothing.  This is often
9559 the case with lock or thread classes, which are usually defined and then
9560 not referenced, but contain constructors and destructors that have
9561 nontrivial bookkeeping functions.
9563 @cindex @code{vector_size} type attribute
9564 @item vector_size (@var{bytes})
9565 This attribute specifies the vector size for the type, measured in bytes.
9566 The type to which it applies is known as the @dfn{base type}.  The @var{bytes}
9567 argument must be a positive power-of-two multiple of the base type size.  For
9568 example, the following declarations:
9570 @smallexample
9571 typedef __attribute__ ((vector_size (32))) int int_vec32_t ;
9572 typedef __attribute__ ((vector_size (32))) int* int_vec32_ptr_t;
9573 typedef __attribute__ ((vector_size (32))) int int_vec32_arr3_t[3];
9574 @end smallexample
9576 @noindent
9577 define @code{int_vec32_t} to be a 32-byte vector type composed of @code{int}
9578 sized units.  With @code{int} having a size of 4 bytes, the type defines
9579 a vector of eight units, four bytes each.  The mode of variables of type
9580 @code{int_vec32_t} is @code{V8SI}.  @code{int_vec32_ptr_t} is then defined
9581 to be a pointer to such a vector type, and @code{int_vec32_arr3_t} to be
9582 an array of three such vectors.  @xref{Vector Extensions}, for details of
9583 manipulating objects of vector types.
9585 This attribute is only applicable to integral and floating scalar types.
9586 In function declarations the attribute applies to the function return
9587 type.
9589 For example, the following:
9590 @smallexample
9591 __attribute__ ((vector_size (16))) float get_flt_vec16 (void);
9592 @end smallexample
9593 declares @code{get_flt_vec16} to be a function returning a 16-byte vector
9594 with the base type @code{float}.
9596 @cindex @code{visibility} type attribute
9597 @item visibility
9598 In C++, attribute visibility (@pxref{Function Attributes}) can also be
9599 applied to class, struct, union and enum types.  Unlike other type
9600 attributes, the attribute must appear between the initial keyword and
9601 the name of the type; it cannot appear after the body of the type.
9603 Note that the type visibility is applied to vague linkage entities
9604 associated with the class (vtable, typeinfo node, etc.).  In
9605 particular, if a class is thrown as an exception in one shared object
9606 and caught in another, the class must have default visibility.
9607 Otherwise the two shared objects are unable to use the same
9608 typeinfo node and exception handling will break.
9610 @cindex @code{warn_if_not_aligned} type attribute
9611 @item warn_if_not_aligned (@var{alignment})
9612 This attribute specifies a threshold for the structure field, measured
9613 in bytes.  If the structure field is aligned below the threshold, a
9614 warning will be issued.  For example, the declaration:
9616 @smallexample
9617 typedef unsigned long long __u64
9618    __attribute__((aligned (4), warn_if_not_aligned (8)));
9620 struct foo
9622   int i1;
9623   int i2;
9624   __u64 x;
9626 @end smallexample
9628 @noindent
9629 causes the compiler to issue an warning on @code{struct foo}, like
9630 @samp{warning: alignment 4 of 'struct foo' is less than 8}.
9631 It is used to define @code{struct foo} in such a way that
9632 @code{struct foo} has the same layout and the structure field @code{x}
9633 has the same alignment when @code{__u64} is aligned at either 4 or
9634 8 bytes.  Align @code{struct foo} to 8 bytes:
9636 @smallexample
9637 struct __attribute__ ((aligned (8))) foo
9639   int i1;
9640   int i2;
9641   __u64 x;
9643 @end smallexample
9645 @noindent
9646 silences the warning.  The compiler also issues a warning, like
9647 @samp{warning: 'x' offset 12 in 'struct foo' isn't aligned to 8},
9648 when the structure field has the misaligned offset:
9650 @smallexample
9651 struct __attribute__ ((aligned (8))) foo
9653   int i1;
9654   int i2;
9655   int i3;
9656   __u64 x;
9658 @end smallexample
9660 This warning can be disabled by @option{-Wno-if-not-aligned}.
9662 @end table
9664 To specify multiple attributes, separate them by commas within the
9665 double parentheses: for example, @samp{__attribute__ ((aligned (16),
9666 packed))}.
9668 @node ARC Type Attributes
9669 @subsection ARC Type Attributes
9671 @cindex @code{uncached} type attribute, ARC
9672 Declaring objects with @code{uncached} allows you to exclude
9673 data-cache participation in load and store operations on those objects
9674 without involving the additional semantic implications of
9675 @code{volatile}.  The @code{.di} instruction suffix is used for all
9676 loads and stores of data declared @code{uncached}.
9678 @node ARM Type Attributes
9679 @subsection ARM Type Attributes
9681 @cindex @code{notshared} type attribute, ARM
9682 On those ARM targets that support @code{dllimport} (such as Symbian
9683 OS), you can use the @code{notshared} attribute to indicate that the
9684 virtual table and other similar data for a class should not be
9685 exported from a DLL@.  For example:
9687 @smallexample
9688 class __declspec(notshared) C @{
9689 public:
9690   __declspec(dllimport) C();
9691   virtual void f();
9694 __declspec(dllexport)
9695 C::C() @{@}
9696 @end smallexample
9698 @noindent
9699 In this code, @code{C::C} is exported from the current DLL, but the
9700 virtual table for @code{C} is not exported.  (You can use
9701 @code{__attribute__} instead of @code{__declspec} if you prefer, but
9702 most Symbian OS code uses @code{__declspec}.)
9704 @node BPF Type Attributes
9705 @subsection BPF Type Attributes
9707 @cindex @code{preserve_access_index} type attribute, BPF
9708 BPF Compile Once - Run Everywhere (CO-RE) support. When attached to a
9709 @code{struct} or @code{union} type definition, indicates that CO-RE
9710 relocation information should be generated for any access to a variable
9711 of that type. The behavior is equivalent to the programmer manually
9712 wrapping every such access with @code{__builtin_preserve_access_index}.
9715 @node PowerPC Type Attributes
9716 @subsection PowerPC Type Attributes
9718 Three attributes currently are defined for PowerPC configurations:
9719 @code{altivec}, @code{ms_struct} and @code{gcc_struct}.
9721 @cindex @code{ms_struct} type attribute, PowerPC
9722 @cindex @code{gcc_struct} type attribute, PowerPC
9723 For full documentation of the @code{ms_struct} and @code{gcc_struct}
9724 attributes please see the documentation in @ref{x86 Type Attributes}.
9726 @cindex @code{altivec} type attribute, PowerPC
9727 The @code{altivec} attribute allows one to declare AltiVec vector data
9728 types supported by the AltiVec Programming Interface Manual.  The
9729 attribute requires an argument to specify one of three vector types:
9730 @code{vector__}, @code{pixel__} (always followed by unsigned short),
9731 and @code{bool__} (always followed by unsigned).
9733 @smallexample
9734 __attribute__((altivec(vector__)))
9735 __attribute__((altivec(pixel__))) unsigned short
9736 __attribute__((altivec(bool__))) unsigned
9737 @end smallexample
9739 These attributes mainly are intended to support the @code{__vector},
9740 @code{__pixel}, and @code{__bool} AltiVec keywords.
9742 @node x86 Type Attributes
9743 @subsection x86 Type Attributes
9745 Two attributes are currently defined for x86 configurations:
9746 @code{ms_struct} and @code{gcc_struct}.
9748 @table @code
9750 @cindex @code{ms_struct} type attribute, x86
9751 @cindex @code{gcc_struct} type attribute, x86
9752 @item ms_struct
9753 @itemx gcc_struct
9755 If @code{packed} is used on a structure, or if bit-fields are used
9756 it may be that the Microsoft ABI packs them differently
9757 than GCC normally packs them.  Particularly when moving packed
9758 data between functions compiled with GCC and the native Microsoft compiler
9759 (either via function call or as data in a file), it may be necessary to access
9760 either format.
9762 The @code{ms_struct} and @code{gcc_struct} attributes correspond
9763 to the @option{-mms-bitfields} and @option{-mno-ms-bitfields}
9764 command-line options, respectively;
9765 see @ref{x86 Options}, for details of how structure layout is affected.
9766 @xref{x86 Variable Attributes}, for information about the corresponding
9767 attributes on variables.
9769 @end table
9771 @node Label Attributes
9772 @section Label Attributes
9773 @cindex Label Attributes
9775 GCC allows attributes to be set on C labels.  @xref{Attribute Syntax}, for 
9776 details of the exact syntax for using attributes.  Other attributes are 
9777 available for functions (@pxref{Function Attributes}), variables 
9778 (@pxref{Variable Attributes}), enumerators (@pxref{Enumerator Attributes}),
9779 statements (@pxref{Statement Attributes}), and for types
9780 (@pxref{Type Attributes}). A label attribute followed
9781 by a declaration appertains to the label and not the declaration.
9783 This example uses the @code{cold} label attribute to indicate the 
9784 @code{ErrorHandling} branch is unlikely to be taken and that the
9785 @code{ErrorHandling} label is unused:
9787 @smallexample
9789    asm goto ("some asm" : : : : NoError);
9791 /* This branch (the fall-through from the asm) is less commonly used */
9792 ErrorHandling: 
9793    __attribute__((cold, unused)); /* Semi-colon is required here */
9794    printf("error\n");
9795    return 0;
9797 NoError:
9798    printf("no error\n");
9799    return 1;
9800 @end smallexample
9802 @table @code
9803 @cindex @code{unused} label attribute
9804 @item unused
9805 This feature is intended for program-generated code that may contain 
9806 unused labels, but which is compiled with @option{-Wall}.  It is
9807 not normally appropriate to use in it human-written code, though it
9808 could be useful in cases where the code that jumps to the label is
9809 contained within an @code{#ifdef} conditional.
9811 @cindex @code{hot} label attribute
9812 @item hot
9813 The @code{hot} attribute on a label is used to inform the compiler that
9814 the path following the label is more likely than paths that are not so
9815 annotated.  This attribute is used in cases where @code{__builtin_expect}
9816 cannot be used, for instance with computed goto or @code{asm goto}.
9818 @cindex @code{cold} label attribute
9819 @item cold
9820 The @code{cold} attribute on labels is used to inform the compiler that
9821 the path following the label is unlikely to be executed.  This attribute
9822 is used in cases where @code{__builtin_expect} cannot be used, for instance
9823 with computed goto or @code{asm goto}.
9825 @end table
9827 @node Enumerator Attributes
9828 @section Enumerator Attributes
9829 @cindex Enumerator Attributes
9831 GCC allows attributes to be set on enumerators.  @xref{Attribute Syntax}, for
9832 details of the exact syntax for using attributes.  Other attributes are
9833 available for functions (@pxref{Function Attributes}), variables
9834 (@pxref{Variable Attributes}), labels (@pxref{Label Attributes}), statements
9835 (@pxref{Statement Attributes}), and for types (@pxref{Type Attributes}).
9837 This example uses the @code{deprecated} enumerator attribute to indicate the
9838 @code{oldval} enumerator is deprecated:
9840 @smallexample
9841 enum E @{
9842   oldval __attribute__((deprecated)),
9843   newval
9847 fn (void)
9849   return oldval;
9851 @end smallexample
9853 @table @code
9854 @cindex @code{deprecated} enumerator attribute
9855 @item deprecated
9856 The @code{deprecated} attribute results in a warning if the enumerator
9857 is used anywhere in the source file.  This is useful when identifying
9858 enumerators that are expected to be removed in a future version of a
9859 program.  The warning also includes the location of the declaration
9860 of the deprecated enumerator, to enable users to easily find further
9861 information about why the enumerator is deprecated, or what they should
9862 do instead.  Note that the warnings only occurs for uses.
9864 @cindex @code{unavailable} enumerator attribute
9865 @item unavailable
9866 The @code{unavailable} attribute results in an error if the enumerator
9867 is used anywhere in the source file.  In other respects it behaves in the
9868 same manner as the @code{deprecated} attribute.
9870 @end table
9872 @node Statement Attributes
9873 @section Statement Attributes
9874 @cindex Statement Attributes
9876 GCC allows attributes to be set on null statements.  @xref{Attribute Syntax},
9877 for details of the exact syntax for using attributes.  Other attributes are
9878 available for functions (@pxref{Function Attributes}), variables
9879 (@pxref{Variable Attributes}), labels (@pxref{Label Attributes}), enumerators
9880 (@pxref{Enumerator Attributes}), and for types (@pxref{Type Attributes}).
9882 @table @code
9883 @cindex @code{fallthrough} statement attribute
9884 @item fallthrough
9885 The @code{fallthrough} attribute with a null statement serves as a
9886 fallthrough statement.  It hints to the compiler that a statement
9887 that falls through to another case label, or user-defined label
9888 in a switch statement is intentional and thus the
9889 @option{-Wimplicit-fallthrough} warning must not trigger.  The
9890 fallthrough attribute may appear at most once in each attribute
9891 list, and may not be mixed with other attributes.  It can only
9892 be used in a switch statement (the compiler will issue an error
9893 otherwise), after a preceding statement and before a logically
9894 succeeding case label, or user-defined label.
9896 This example uses the @code{fallthrough} statement attribute to indicate that
9897 the @option{-Wimplicit-fallthrough} warning should not be emitted:
9899 @smallexample
9900 switch (cond)
9901   @{
9902   case 1:
9903     bar (1);
9904     __attribute__((fallthrough));
9905   case 2:
9906     @dots{}
9907   @}
9908 @end smallexample
9910 @cindex @code{assume} statement attribute
9911 @item assume
9912 The @code{assume} attribute with a null statement serves as portable
9913 assumption.  It should have a single argument, a conditional expression,
9914 which is not evaluated.  If the argument would evaluate to true
9915 at the point where it appears, it has no effect, otherwise there
9916 is undefined behavior.  This is a GNU variant of the ISO C++23
9917 standard @code{assume} attribute, but it can be used in any version of
9918 both C and C++.
9920 @smallexample
9922 foo (int x, int y)
9924   __attribute__((assume(x == 42)));
9925   __attribute__((assume(++y == 43)));
9926   return x + y;
9928 @end smallexample
9930 @code{y} is not actually incremented and the compiler can but does not
9931 have to optimize it to just @code{return 42 + 42;}.
9933 @end table
9935 @node Attribute Syntax
9936 @section Attribute Syntax
9937 @cindex attribute syntax
9938 @cindex C standard attributes
9939 @cindex C++ standard attributes
9940 @cindex standard attribute syntax
9941 @cindex GNU attribute syntax
9943 GCC provides two different ways to specify attributes: the standard C
9944 and C++ syntax using double square brackets, and the older GNU
9945 extension syntax using the @code{@w{__attribute__}} keyword, which predates
9946 the adoption of the standard syntax and is still widely used in older
9947 code.
9949 The standard @samp{[[]]} attribute syntax is recognized by GCC's
9950 default language dialect for both C and C++.  More specifically, this
9951 syntax was first introduced in the C++11 language standard
9952 (@pxref{Standards}), and is supported by GCC in C++ code with
9953 @option{-std=c++11} or @option{-std=gnu++11} or later.  It is also
9954 part of the C23 language standard and is supported when compiling C
9955 code with @option{-std=c23} or @option{-std=gnu17} or later.
9957 When using GNU-specific attributes in the standard syntax, you must
9958 prefix their names with @samp{gnu::}, such as @code{gnu::section}.
9959 Refer to the relevant language standards for exact details on the
9960 placement of @samp{[[]]} attributes within your code, as they differ
9961 in some details from the rules for the GNU attribute syntax.
9963 The remainder of this section describes the details of the GNU extension
9964 @code{__attribute__} syntax,
9965 and the constructs to which attribute specifiers bind, for the C
9966 language.  Some details may vary for C++ and Objective-C@.  Because of
9967 limitations in the grammar for attributes, some forms described here
9968 may not be successfully parsed in all cases.
9970 There are some problems with the semantics of attributes in C++.  For
9971 example, there are no manglings for attributes, although they may affect
9972 code generation, so problems may arise when attributed types are used in
9973 conjunction with templates or overloading.  Similarly, @code{typeid}
9974 does not distinguish between types with different attributes.  Support
9975 for attributes in C++ may be restricted in future to attributes on
9976 declarations only, but not on nested declarators.
9978 @xref{Function Attributes}, for details of the semantics of attributes
9979 applying to functions.  @xref{Variable Attributes}, for details of the
9980 semantics of attributes applying to variables.  @xref{Type Attributes},
9981 for details of the semantics of attributes applying to structure, union
9982 and enumerated types.
9983 @xref{Label Attributes}, for details of the semantics of attributes 
9984 applying to labels.
9985 @xref{Enumerator Attributes}, for details of the semantics of attributes
9986 applying to enumerators.
9987 @xref{Statement Attributes}, for details of the semantics of attributes
9988 applying to statements.
9990 An @dfn{attribute specifier} is of the form
9991 @code{__attribute__ ((@var{attribute-list}))}.  An @dfn{attribute list}
9992 is a possibly empty comma-separated sequence of @dfn{attributes}, where
9993 each attribute is one of the following:
9995 @itemize @bullet
9996 @item
9997 Empty.  Empty attributes are ignored.
9999 @item
10000 An attribute name
10001 (which may be an identifier such as @code{unused}, or a reserved
10002 word such as @code{const}).
10004 @item
10005 An attribute name followed by a parenthesized list of
10006 parameters for the attribute.
10007 These parameters take one of the following forms:
10009 @itemize @bullet
10010 @item
10011 An identifier.  For example, @code{mode} attributes use this form.
10013 @item
10014 An identifier followed by a comma and a non-empty comma-separated list
10015 of expressions.  For example, @code{format} attributes use this form.
10017 @item
10018 A possibly empty comma-separated list of expressions.  For example,
10019 @code{format_arg} attributes use this form with the list being a single
10020 integer constant expression, and @code{alias} attributes use this form
10021 with the list being a single string constant.
10022 @end itemize
10023 @end itemize
10025 An @dfn{attribute specifier list} is a sequence of one or more attribute
10026 specifiers, not separated by any other tokens.
10028 You may optionally specify attribute names with @samp{__}
10029 preceding and following the name.
10030 This allows you to use them in header files without
10031 being concerned about a possible macro of the same name.  For example,
10032 you may use the attribute name @code{__noreturn__} instead of @code{noreturn}.
10035 @subsubheading Label Attributes
10037 In GNU C, an attribute specifier list may appear after the colon following a
10038 label, other than a @code{case} or @code{default} label.  GNU C++ only permits
10039 attributes on labels if the attribute specifier is immediately
10040 followed by a semicolon (i.e., the label applies to an empty
10041 statement).  If the semicolon is missing, C++ label attributes are
10042 ambiguous, as it is permissible for a declaration, which could begin
10043 with an attribute list, to be labelled in C++.  Declarations cannot be
10044 labelled in C90 or C99, so the ambiguity does not arise there.
10046 @subsubheading Enumerator Attributes
10048 In GNU C, an attribute specifier list may appear as part of an enumerator.
10049 The attribute goes after the enumeration constant, before @code{=}, if
10050 present.  The optional attribute in the enumerator appertains to the
10051 enumeration constant.  It is not possible to place the attribute after
10052 the constant expression, if present.
10054 @subsubheading Statement Attributes
10055 In GNU C, an attribute specifier list may appear as part of a null
10056 statement.  The attribute goes before the semicolon.
10058 @subsubheading Type Attributes
10060 An attribute specifier list may appear as part of a @code{struct},
10061 @code{union} or @code{enum} specifier.  It may go either immediately
10062 after the @code{struct}, @code{union} or @code{enum} keyword, or after
10063 the closing brace.  The former syntax is preferred.
10064 Where attribute specifiers follow the closing brace, they are considered
10065 to relate to the structure, union or enumerated type defined, not to any
10066 enclosing declaration the type specifier appears in, and the type
10067 defined is not complete until after the attribute specifiers.
10068 @c Otherwise, there would be the following problems: a shift/reduce
10069 @c conflict between attributes binding the struct/union/enum and
10070 @c binding to the list of specifiers/qualifiers; and "aligned"
10071 @c attributes could use sizeof for the structure, but the size could be
10072 @c changed later by "packed" attributes.
10075 @subsubheading All other attributes
10077 Otherwise, an attribute specifier appears as part of a declaration,
10078 counting declarations of unnamed parameters and type names, and relates
10079 to that declaration (which may be nested in another declaration, for
10080 example in the case of a parameter declaration), or to a particular declarator
10081 within a declaration.  Where an
10082 attribute specifier is applied to a parameter declared as a function or
10083 an array, it should apply to the function or array rather than the
10084 pointer to which the parameter is implicitly converted, but this is not
10085 yet correctly implemented.
10087 Any list of specifiers and qualifiers at the start of a declaration may
10088 contain attribute specifiers, whether or not such a list may in that
10089 context contain storage class specifiers.  (Some attributes, however,
10090 are essentially in the nature of storage class specifiers, and only make
10091 sense where storage class specifiers may be used; for example,
10092 @code{section}.)  There is one necessary limitation to this syntax: the
10093 first old-style parameter declaration in a function definition cannot
10094 begin with an attribute specifier, because such an attribute applies to
10095 the function instead by syntax described below (which, however, is not
10096 yet implemented in this case).  In some other cases, attribute
10097 specifiers are permitted by this grammar but not yet supported by the
10098 compiler.  All attribute specifiers in this place relate to the
10099 declaration as a whole.  In the obsolescent usage where a type of
10100 @code{int} is implied by the absence of type specifiers, such a list of
10101 specifiers and qualifiers may be an attribute specifier list with no
10102 other specifiers or qualifiers.
10104 At present, the first parameter in a function prototype must have some
10105 type specifier that is not an attribute specifier; this resolves an
10106 ambiguity in the interpretation of @code{void f(int
10107 (__attribute__((foo)) x))}, but is subject to change.  At present, if
10108 the parentheses of a function declarator contain only attributes then
10109 those attributes are ignored, rather than yielding an error or warning
10110 or implying a single parameter of type int, but this is subject to
10111 change.
10113 An attribute specifier list may appear immediately before a declarator
10114 (other than the first) in a comma-separated list of declarators in a
10115 declaration of more than one identifier using a single list of
10116 specifiers and qualifiers.  Such attribute specifiers apply
10117 only to the identifier before whose declarator they appear.  For
10118 example, in
10120 @smallexample
10121 __attribute__((noreturn)) void d0 (void),
10122     __attribute__((format(printf, 1, 2))) d1 (const char *, ...),
10123      d2 (void);
10124 @end smallexample
10126 @noindent
10127 the @code{noreturn} attribute applies to all the functions
10128 declared; the @code{format} attribute only applies to @code{d1}.
10130 An attribute specifier list may appear immediately before the comma,
10131 @code{=} or semicolon terminating the declaration of an identifier other
10132 than a function definition.  Such attribute specifiers apply
10133 to the declared object or function.  Where an
10134 assembler name for an object or function is specified (@pxref{Asm
10135 Labels}), the attribute must follow the @code{asm}
10136 specification.
10138 An attribute specifier list may, in future, be permitted to appear after
10139 the declarator in a function definition (before any old-style parameter
10140 declarations or the function body).
10142 Attribute specifiers may be mixed with type qualifiers appearing inside
10143 the @code{[]} of a parameter array declarator, in the C99 construct by
10144 which such qualifiers are applied to the pointer to which the array is
10145 implicitly converted.  Such attribute specifiers apply to the pointer,
10146 not to the array, but at present this is not implemented and they are
10147 ignored.
10149 An attribute specifier list may appear at the start of a nested
10150 declarator.  At present, there are some limitations in this usage: the
10151 attributes correctly apply to the declarator, but for most individual
10152 attributes the semantics this implies are not implemented.
10153 When attribute specifiers follow the @code{*} of a pointer
10154 declarator, they may be mixed with any type qualifiers present.
10155 The following describes the formal semantics of this syntax.  It makes the
10156 most sense if you are familiar with the formal specification of
10157 declarators in the ISO C standard.
10159 Consider (as in C99 subclause 6.7.5 paragraph 4) a declaration @code{T
10160 D1}, where @code{T} contains declaration specifiers that specify a type
10161 @var{Type} (such as @code{int}) and @code{D1} is a declarator that
10162 contains an identifier @var{ident}.  The type specified for @var{ident}
10163 for derived declarators whose type does not include an attribute
10164 specifier is as in the ISO C standard.
10166 If @code{D1} has the form @code{( @var{attribute-specifier-list} D )},
10167 and the declaration @code{T D} specifies the type
10168 ``@var{derived-declarator-type-list} @var{Type}'' for @var{ident}, then
10169 @code{T D1} specifies the type ``@var{derived-declarator-type-list}
10170 @var{attribute-specifier-list} @var{Type}'' for @var{ident}.
10172 If @code{D1} has the form @code{*
10173 @var{type-qualifier-and-attribute-specifier-list} D}, and the
10174 declaration @code{T D} specifies the type
10175 ``@var{derived-declarator-type-list} @var{Type}'' for @var{ident}, then
10176 @code{T D1} specifies the type ``@var{derived-declarator-type-list}
10177 @var{type-qualifier-and-attribute-specifier-list} pointer to @var{Type}'' for
10178 @var{ident}.
10180 For example,
10182 @smallexample
10183 void (__attribute__((noreturn)) ****f) (void);
10184 @end smallexample
10186 @noindent
10187 specifies the type ``pointer to pointer to pointer to pointer to
10188 non-returning function returning @code{void}''.  As another example,
10190 @smallexample
10191 char *__attribute__((aligned(8))) *f;
10192 @end smallexample
10194 @noindent
10195 specifies the type ``pointer to 8-byte-aligned pointer to @code{char}''.
10196 Note again that this does not work with most attributes; for example,
10197 the usage of @samp{aligned} and @samp{noreturn} attributes given above
10198 is not yet supported.
10200 For compatibility with existing code written for compiler versions that
10201 did not implement attributes on nested declarators, some laxity is
10202 allowed in the placing of attributes.  If an attribute that only applies
10203 to types is applied to a declaration, it is treated as applying to
10204 the type of that declaration.  If an attribute that only applies to
10205 declarations is applied to the type of a declaration, it is treated
10206 as applying to that declaration; and, for compatibility with code
10207 placing the attributes immediately before the identifier declared, such
10208 an attribute applied to a function return type is treated as
10209 applying to the function type, and such an attribute applied to an array
10210 element type is treated as applying to the array type.  If an
10211 attribute that only applies to function types is applied to a
10212 pointer-to-function type, it is treated as applying to the pointer
10213 target type; if such an attribute is applied to a function return type
10214 that is not a pointer-to-function type, it is treated as applying
10215 to the function type.
10217 @node Function Prototypes
10218 @section Prototypes and Old-Style Function Definitions
10219 @cindex function prototype declarations
10220 @cindex old-style function definitions
10221 @cindex promotion of formal parameters
10223 GNU C extends ISO C to allow a function prototype to override a later
10224 old-style non-prototype definition.  Consider the following example:
10226 @smallexample
10227 /* @r{Use prototypes unless the compiler is old-fashioned.}  */
10228 #ifdef __STDC__
10229 #define P(x) x
10230 #else
10231 #define P(x) ()
10232 #endif
10234 /* @r{Prototype function declaration.}  */
10235 int isroot P((uid_t));
10237 /* @r{Old-style function definition.}  */
10239 isroot (x)   /* @r{??? lossage here ???} */
10240      uid_t x;
10242   return x == 0;
10244 @end smallexample
10246 Suppose the type @code{uid_t} happens to be @code{short}.  ISO C does
10247 not allow this example, because subword arguments in old-style
10248 non-prototype definitions are promoted.  Therefore in this example the
10249 function definition's argument is really an @code{int}, which does not
10250 match the prototype argument type of @code{short}.
10252 This restriction of ISO C makes it hard to write code that is portable
10253 to traditional C compilers, because the programmer does not know
10254 whether the @code{uid_t} type is @code{short}, @code{int}, or
10255 @code{long}.  Therefore, in cases like these GNU C allows a prototype
10256 to override a later old-style definition.  More precisely, in GNU C, a
10257 function prototype argument type overrides the argument type specified
10258 by a later old-style definition if the former type is the same as the
10259 latter type before promotion.  Thus in GNU C the above example is
10260 equivalent to the following:
10262 @smallexample
10263 int isroot (uid_t);
10266 isroot (uid_t x)
10268   return x == 0;
10270 @end smallexample
10272 @noindent
10273 GNU C++ does not support old-style function definitions, so this
10274 extension is irrelevant.
10276 @node C++ Comments
10277 @section C++ Style Comments
10278 @cindex @code{//}
10279 @cindex C++ comments
10280 @cindex comments, C++ style
10282 In GNU C, you may use C++ style comments, which start with @samp{//} and
10283 continue until the end of the line.  Many other C implementations allow
10284 such comments, and they are included in the 1999 C standard.  However,
10285 C++ style comments are not recognized if you specify an @option{-std}
10286 option specifying a version of ISO C before C99, or @option{-ansi}
10287 (equivalent to @option{-std=c90}).
10289 @node Dollar Signs
10290 @section Dollar Signs in Identifier Names
10291 @cindex $
10292 @cindex dollar signs in identifier names
10293 @cindex identifier names, dollar signs in
10295 In GNU C, you may normally use dollar signs in identifier names.
10296 This is because many traditional C implementations allow such identifiers.
10297 However, dollar signs in identifiers are not supported on a few target
10298 machines, typically because the target assembler does not allow them.
10300 @node Character Escapes
10301 @section The Character @key{ESC} in Constants
10303 You can use the sequence @samp{\e} in a string or character constant to
10304 stand for the ASCII character @key{ESC}.
10306 @node Alignment
10307 @section Determining the Alignment of Functions, Types or Variables
10308 @cindex alignment
10309 @cindex type alignment
10310 @cindex variable alignment
10312 The keyword @code{__alignof__} determines the alignment requirement of
10313 a function, object, or a type, or the minimum alignment usually required
10314 by a type.  Its syntax is just like @code{sizeof} and C11 @code{_Alignof}.
10316 For example, if the target machine requires a @code{double} value to be
10317 aligned on an 8-byte boundary, then @code{__alignof__ (double)} is 8.
10318 This is true on many RISC machines.  On more traditional machine
10319 designs, @code{__alignof__ (double)} is 4 or even 2.
10321 Some machines never actually require alignment; they allow references to any
10322 data type even at an odd address.  For these machines, @code{__alignof__}
10323 reports the smallest alignment that GCC gives the data type, usually as
10324 mandated by the target ABI.
10326 If the operand of @code{__alignof__} is an lvalue rather than a type,
10327 its value is the required alignment for its type, taking into account
10328 any minimum alignment specified by attribute @code{aligned}
10329 (@pxref{Common Variable Attributes}).  For example, after this
10330 declaration:
10332 @smallexample
10333 struct foo @{ int x; char y; @} foo1;
10334 @end smallexample
10336 @noindent
10337 the value of @code{__alignof__ (foo1.y)} is 1, even though its actual
10338 alignment is probably 2 or 4, the same as @code{__alignof__ (int)}.
10339 It is an error to ask for the alignment of an incomplete type other
10340 than @code{void}.
10342 If the operand of the @code{__alignof__} expression is a function,
10343 the expression evaluates to the alignment of the function which may
10344 be specified by attribute @code{aligned} (@pxref{Common Function Attributes}).
10346 @node Inline
10347 @section An Inline Function is As Fast As a Macro
10348 @cindex inline functions
10349 @cindex integrating function code
10350 @cindex open coding
10351 @cindex macros, inline alternative
10353 By declaring a function inline, you can direct GCC to make
10354 calls to that function faster.  One way GCC can achieve this is to
10355 integrate that function's code into the code for its callers.  This
10356 makes execution faster by eliminating the function-call overhead; in
10357 addition, if any of the actual argument values are constant, their
10358 known values may permit simplifications at compile time so that not
10359 all of the inline function's code needs to be included.  The effect on
10360 code size is less predictable; object code may be larger or smaller
10361 with function inlining, depending on the particular case.  You can
10362 also direct GCC to try to integrate all ``simple enough'' functions
10363 into their callers with the option @option{-finline-functions}.
10365 GCC implements three different semantics of declaring a function
10366 inline.  One is available with @option{-std=gnu89} or
10367 @option{-fgnu89-inline} or when @code{gnu_inline} attribute is present
10368 on all inline declarations, another when
10369 @option{-std=c99},
10370 @option{-std=gnu99} or an option for a later C version is used
10371 (without @option{-fgnu89-inline}), and the third
10372 is used when compiling C++.
10374 To declare a function inline, use the @code{inline} keyword in its
10375 declaration, like this:
10377 @smallexample
10378 static inline int
10379 inc (int *a)
10381   return (*a)++;
10383 @end smallexample
10385 If you are writing a header file to be included in ISO C90 programs, write
10386 @code{__inline__} instead of @code{inline}.  @xref{Alternate Keywords}.
10388 The three types of inlining behave similarly in two important cases:
10389 when the @code{inline} keyword is used on a @code{static} function,
10390 like the example above, and when a function is first declared without
10391 using the @code{inline} keyword and then is defined with
10392 @code{inline}, like this:
10394 @smallexample
10395 extern int inc (int *a);
10396 inline int
10397 inc (int *a)
10399   return (*a)++;
10401 @end smallexample
10403 In both of these common cases, the program behaves the same as if you
10404 had not used the @code{inline} keyword, except for its speed.
10406 @cindex inline functions, omission of
10407 @opindex fkeep-inline-functions
10408 When a function is both inline and @code{static}, if all calls to the
10409 function are integrated into the caller, and the function's address is
10410 never used, then the function's own assembler code is never referenced.
10411 In this case, GCC does not actually output assembler code for the
10412 function, unless you specify the option @option{-fkeep-inline-functions}.
10413 If there is a nonintegrated call, then the function is compiled to
10414 assembler code as usual.  The function must also be compiled as usual if
10415 the program refers to its address, because that cannot be inlined.
10417 @opindex Winline
10418 Note that certain usages in a function definition can make it unsuitable
10419 for inline substitution.  Among these usages are: variadic functions,
10420 use of @code{alloca}, use of computed goto (@pxref{Labels as Values}),
10421 use of nonlocal goto, use of nested functions, use of @code{setjmp}, use
10422 of @code{__builtin_longjmp} and use of @code{__builtin_return} or
10423 @code{__builtin_apply_args}.  Using @option{-Winline} warns when a
10424 function marked @code{inline} could not be substituted, and gives the
10425 reason for the failure.
10427 @cindex automatic @code{inline} for C++ member fns
10428 @cindex @code{inline} automatic for C++ member fns
10429 @cindex member fns, automatically @code{inline}
10430 @cindex C++ member fns, automatically @code{inline}
10431 @opindex fno-default-inline
10432 As required by ISO C++, GCC considers member functions defined within
10433 the body of a class to be marked inline even if they are
10434 not explicitly declared with the @code{inline} keyword.  You can
10435 override this with @option{-fno-default-inline}; @pxref{C++ Dialect
10436 Options,,Options Controlling C++ Dialect}.
10438 GCC does not inline any functions when not optimizing unless you specify
10439 the @samp{always_inline} attribute for the function, like this:
10441 @smallexample
10442 /* @r{Prototype.}  */
10443 inline void foo (const char) __attribute__((always_inline));
10444 @end smallexample
10446 The remainder of this section is specific to GNU C90 inlining.
10448 @cindex non-static inline function
10449 When an inline function is not @code{static}, then the compiler must assume
10450 that there may be calls from other source files; since a global symbol can
10451 be defined only once in any program, the function must not be defined in
10452 the other source files, so the calls therein cannot be integrated.
10453 Therefore, a non-@code{static} inline function is always compiled on its
10454 own in the usual fashion.
10456 If you specify both @code{inline} and @code{extern} in the function
10457 definition, then the definition is used only for inlining.  In no case
10458 is the function compiled on its own, not even if you refer to its
10459 address explicitly.  Such an address becomes an external reference, as
10460 if you had only declared the function, and had not defined it.
10462 This combination of @code{inline} and @code{extern} has almost the
10463 effect of a macro.  The way to use it is to put a function definition in
10464 a header file with these keywords, and put another copy of the
10465 definition (lacking @code{inline} and @code{extern}) in a library file.
10466 The definition in the header file causes most calls to the function
10467 to be inlined.  If any uses of the function remain, they refer to
10468 the single copy in the library.
10470 @node Const and Volatile Functions
10471 @section Const and Volatile Functions
10472 @cindex @code{const} applied to function
10473 @cindex @code{volatile} applied to function
10475 The C standard explicitly leaves the behavior of the @code{const} and
10476 @code{volatile} type qualifiers applied to functions undefined; these
10477 constructs can only arise through the use of @code{typedef}.  As an extension,
10478 GCC defines this use of the @code{const} qualifier to have the same meaning
10479 as the GCC @code{const} function attribute, and the @code{volatile} qualifier
10480 to be equivalent to the @code{noreturn} attribute.
10481 @xref{Common Function Attributes}, for more information.
10483 As examples of this usage,
10485 @smallexample
10487 /* @r{Equivalent to:}
10488    void fatal () __attribute__ ((noreturn));  */
10489 typedef void voidfn ();
10490 volatile voidfn fatal;
10492 /* @r{Equivalent to:}
10493    extern int square (int) __attribute__ ((const));  */
10494 typedef int intfn (int);
10495 extern const intfn square;
10496 @end smallexample
10498 In general, using function attributes instead is preferred, since the
10499 attributes make both the intent of the code and its reliance on a GNU
10500 extension explicit.  Additionally, using @code{const} and
10501 @code{volatile} in this way is specific to GNU C and does not work in
10502 GNU C++.
10504 @node Volatiles
10505 @section When is a Volatile Object Accessed?
10506 @cindex accessing volatiles
10507 @cindex volatile read
10508 @cindex volatile write
10509 @cindex volatile access
10511 C has the concept of volatile objects.  These are normally accessed by
10512 pointers and used for accessing hardware or inter-thread
10513 communication.  The standard encourages compilers to refrain from
10514 optimizations concerning accesses to volatile objects, but leaves it
10515 implementation defined as to what constitutes a volatile access.  The
10516 minimum requirement is that at a sequence point all previous accesses
10517 to volatile objects have stabilized and no subsequent accesses have
10518 occurred.  Thus an implementation is free to reorder and combine
10519 volatile accesses that occur between sequence points, but cannot do
10520 so for accesses across a sequence point.  The use of volatile does
10521 not allow you to violate the restriction on updating objects multiple
10522 times between two sequence points.
10524 Accesses to non-volatile objects are not ordered with respect to
10525 volatile accesses.  You cannot use a volatile object as a memory
10526 barrier to order a sequence of writes to non-volatile memory.  For
10527 instance:
10529 @smallexample
10530 int *ptr = @var{something};
10531 volatile int vobj;
10532 *ptr = @var{something};
10533 vobj = 1;
10534 @end smallexample
10536 @noindent
10537 Unless @var{*ptr} and @var{vobj} can be aliased, it is not guaranteed
10538 that the write to @var{*ptr} occurs by the time the update
10539 of @var{vobj} happens.  If you need this guarantee, you must use
10540 a stronger memory barrier such as:
10542 @smallexample
10543 int *ptr = @var{something};
10544 volatile int vobj;
10545 *ptr = @var{something};
10546 asm volatile ("" : : : "memory");
10547 vobj = 1;
10548 @end smallexample
10550 A scalar volatile object is read when it is accessed in a void context:
10552 @smallexample
10553 volatile int *src = @var{somevalue};
10554 *src;
10555 @end smallexample
10557 Such expressions are rvalues, and GCC implements this as a
10558 read of the volatile object being pointed to.
10560 Assignments are also expressions and have an rvalue.  However when
10561 assigning to a scalar volatile, the volatile object is not reread,
10562 regardless of whether the assignment expression's rvalue is used or
10563 not.  If the assignment's rvalue is used, the value is that assigned
10564 to the volatile object.  For instance, there is no read of @var{vobj}
10565 in all the following cases:
10567 @smallexample
10568 int obj;
10569 volatile int vobj;
10570 vobj = @var{something};
10571 obj = vobj = @var{something};
10572 obj ? vobj = @var{onething} : vobj = @var{anotherthing};
10573 obj = (@var{something}, vobj = @var{anotherthing});
10574 @end smallexample
10576 If you need to read the volatile object after an assignment has
10577 occurred, you must use a separate expression with an intervening
10578 sequence point.
10580 As bit-fields are not individually addressable, volatile bit-fields may
10581 be implicitly read when written to, or when adjacent bit-fields are
10582 accessed.  Bit-field operations may be optimized such that adjacent
10583 bit-fields are only partially accessed, if they straddle a storage unit
10584 boundary.  For these reasons it is unwise to use volatile bit-fields to
10585 access hardware.
10587 @node Using Assembly Language with C
10588 @section How to Use Inline Assembly Language in C Code
10589 @cindex @code{asm} keyword
10590 @cindex assembly language in C
10591 @cindex inline assembly language
10592 @cindex mixing assembly language and C
10594 The @code{asm} keyword allows you to embed assembler instructions
10595 within C code.  GCC provides two forms of inline @code{asm}
10596 statements.  A @dfn{basic @code{asm}} statement is one with no
10597 operands (@pxref{Basic Asm}), while an @dfn{extended @code{asm}}
10598 statement (@pxref{Extended Asm}) includes one or more operands.  
10599 The extended form is preferred for mixing C and assembly language
10600 within a function, but to include assembly language at
10601 top level you must use basic @code{asm}.
10603 You can also use the @code{asm} keyword to override the assembler name
10604 for a C symbol, or to place a C variable in a specific register.
10606 @menu
10607 * Basic Asm::          Inline assembler without operands.
10608 * Extended Asm::       Inline assembler with operands.
10609 * Constraints::        Constraints for @code{asm} operands
10610 * Asm Labels::         Specifying the assembler name to use for a C symbol.
10611 * Explicit Register Variables::  Defining variables residing in specified 
10612                        registers.
10613 * Size of an asm::     How GCC calculates the size of an @code{asm} block.
10614 @end menu
10616 @node Basic Asm
10617 @subsection Basic Asm --- Assembler Instructions Without Operands
10618 @cindex basic @code{asm}
10619 @cindex assembly language in C, basic
10621 A basic @code{asm} statement has the following syntax:
10623 @example
10624 asm @var{asm-qualifiers} ( @var{AssemblerInstructions} )
10625 @end example
10627 For the C language, the @code{asm} keyword is a GNU extension.
10628 When writing C code that can be compiled with @option{-ansi} and the
10629 @option{-std} options that select C dialects without GNU extensions, use
10630 @code{__asm__} instead of @code{asm} (@pxref{Alternate Keywords}).  For
10631 the C++ language, @code{asm} is a standard keyword, but @code{__asm__}
10632 can be used for code compiled with @option{-fno-asm}.
10634 @subsubheading Qualifiers
10635 @table @code
10636 @item volatile
10637 The optional @code{volatile} qualifier has no effect. 
10638 All basic @code{asm} blocks are implicitly volatile.
10640 @item inline
10641 If you use the @code{inline} qualifier, then for inlining purposes the size
10642 of the @code{asm} statement is taken as the smallest size possible (@pxref{Size
10643 of an asm}).
10644 @end table
10646 @subsubheading Parameters
10647 @table @var
10649 @item AssemblerInstructions
10650 This is a literal string that specifies the assembler code. The string can 
10651 contain any instructions recognized by the assembler, including directives. 
10652 GCC does not parse the assembler instructions themselves and 
10653 does not know what they mean or even whether they are valid assembler input. 
10655 You may place multiple assembler instructions together in a single @code{asm} 
10656 string, separated by the characters normally used in assembly code for the 
10657 system. A combination that works in most places is a newline to break the 
10658 line, plus a tab character (written as @samp{\n\t}).
10659 Some assemblers allow semicolons as a line separator. However, 
10660 note that some assembler dialects use semicolons to start a comment. 
10661 @end table
10663 @subsubheading Remarks
10664 Using extended @code{asm} (@pxref{Extended Asm}) typically produces
10665 smaller, safer, and more efficient code, and in most cases it is a
10666 better solution than basic @code{asm}.  However, there are two
10667 situations where only basic @code{asm} can be used:
10669 @itemize @bullet
10670 @item
10671 Extended @code{asm} statements have to be inside a C
10672 function, so to write inline assembly language at file scope (``top-level''),
10673 outside of C functions, you must use basic @code{asm}.
10674 You can use this technique to emit assembler directives,
10675 define assembly language macros that can be invoked elsewhere in the file,
10676 or write entire functions in assembly language.
10677 Basic @code{asm} statements outside of functions may not use any
10678 qualifiers.
10680 @item
10681 Functions declared
10682 with the @code{naked} attribute also require basic @code{asm}
10683 (@pxref{Function Attributes}).
10684 @end itemize
10686 Safely accessing C data and calling functions from basic @code{asm} is more 
10687 complex than it may appear. To access C data, it is better to use extended 
10688 @code{asm}.
10690 Do not expect a sequence of @code{asm} statements to remain perfectly 
10691 consecutive after compilation. If certain instructions need to remain 
10692 consecutive in the output, put them in a single multi-instruction @code{asm}
10693 statement. Note that GCC's optimizers can move @code{asm} statements 
10694 relative to other code, including across jumps.
10696 @code{asm} statements may not perform jumps into other @code{asm} statements. 
10697 GCC does not know about these jumps, and therefore cannot take 
10698 account of them when deciding how to optimize. Jumps from @code{asm} to C 
10699 labels are only supported in extended @code{asm}.
10701 Under certain circumstances, GCC may duplicate (or remove duplicates of) your 
10702 assembly code when optimizing. This can lead to unexpected duplicate 
10703 symbol errors during compilation if your assembly code defines symbols or 
10704 labels.
10706 @strong{Warning:} The C standards do not specify semantics for @code{asm},
10707 making it a potential source of incompatibilities between compilers.  These
10708 incompatibilities may not produce compiler warnings/errors.
10710 GCC does not parse basic @code{asm}'s @var{AssemblerInstructions}, which
10711 means there is no way to communicate to the compiler what is happening
10712 inside them.  GCC has no visibility of symbols in the @code{asm} and may
10713 discard them as unreferenced.  It also does not know about side effects of
10714 the assembler code, such as modifications to memory or registers.  Unlike
10715 some compilers, GCC assumes that no changes to general purpose registers
10716 occur.  This assumption may change in a future release.
10718 To avoid complications from future changes to the semantics and the
10719 compatibility issues between compilers, consider replacing basic @code{asm}
10720 with extended @code{asm}.  See
10721 @uref{https://gcc.gnu.org/wiki/ConvertBasicAsmToExtended, How to convert
10722 from basic asm to extended asm} for information about how to perform this
10723 conversion.
10725 The compiler copies the assembler instructions in a basic @code{asm} 
10726 verbatim to the assembly language output file, without 
10727 processing dialects or any of the @samp{%} operators that are available with
10728 extended @code{asm}. This results in minor differences between basic 
10729 @code{asm} strings and extended @code{asm} templates. For example, to refer to 
10730 registers you might use @samp{%eax} in basic @code{asm} and
10731 @samp{%%eax} in extended @code{asm}.
10733 On targets such as x86 that support multiple assembler dialects,
10734 all basic @code{asm} blocks use the assembler dialect specified by the 
10735 @option{-masm} command-line option (@pxref{x86 Options}).  
10736 Basic @code{asm} provides no
10737 mechanism to provide different assembler strings for different dialects.
10739 For basic @code{asm} with non-empty assembler string GCC assumes
10740 the assembler block does not change any general purpose registers,
10741 but it may read or write any globally accessible variable.
10743 Here is an example of basic @code{asm} for i386:
10745 @example
10746 /* Note that this code will not compile with -masm=intel */
10747 #define DebugBreak() asm("int $3")
10748 @end example
10750 @node Extended Asm
10751 @subsection Extended Asm - Assembler Instructions with C Expression Operands
10752 @cindex extended @code{asm}
10753 @cindex assembly language in C, extended
10755 With extended @code{asm} you can read and write C variables from 
10756 assembler and perform jumps from assembler code to C labels.  
10757 Extended @code{asm} syntax uses colons (@samp{:}) to delimit
10758 the operand parameters after the assembler template:
10760 @example
10761 asm @var{asm-qualifiers} ( @var{AssemblerTemplate} 
10762                  : @var{OutputOperands} 
10763                  @r{[} : @var{InputOperands}
10764                  @r{[} : @var{Clobbers} @r{]} @r{]})
10766 asm @var{asm-qualifiers} ( @var{AssemblerTemplate} 
10767                       : @var{OutputOperands}
10768                       : @var{InputOperands}
10769                       : @var{Clobbers}
10770                       : @var{GotoLabels})
10771 @end example
10772 where in the last form, @var{asm-qualifiers} contains @code{goto} (and in the
10773 first form, not).
10775 The @code{asm} keyword is a GNU extension.
10776 When writing code that can be compiled with @option{-ansi} and the
10777 various @option{-std} options, use @code{__asm__} instead of 
10778 @code{asm} (@pxref{Alternate Keywords}).
10780 @subsubheading Qualifiers
10781 @table @code
10783 @item volatile
10784 The typical use of extended @code{asm} statements is to manipulate input 
10785 values to produce output values. However, your @code{asm} statements may 
10786 also produce side effects. If so, you may need to use the @code{volatile} 
10787 qualifier to disable certain optimizations. @xref{Volatile}.
10789 @item inline
10790 If you use the @code{inline} qualifier, then for inlining purposes the size
10791 of the @code{asm} statement is taken as the smallest size possible
10792 (@pxref{Size of an asm}).
10794 @item goto
10795 This qualifier informs the compiler that the @code{asm} statement may 
10796 perform a jump to one of the labels listed in the @var{GotoLabels}.
10797 @xref{GotoLabels}.
10798 @end table
10800 @subsubheading Parameters
10801 @table @var
10802 @item AssemblerTemplate
10803 This is a literal string that is the template for the assembler code. It is a 
10804 combination of fixed text and tokens that refer to the input, output, 
10805 and goto parameters. @xref{AssemblerTemplate}.
10807 @item OutputOperands
10808 A comma-separated list of the C variables modified by the instructions in the 
10809 @var{AssemblerTemplate}.  An empty list is permitted.  @xref{OutputOperands}.
10811 @item InputOperands
10812 A comma-separated list of C expressions read by the instructions in the 
10813 @var{AssemblerTemplate}.  An empty list is permitted.  @xref{InputOperands}.
10815 @item Clobbers
10816 A comma-separated list of registers or other values changed by the 
10817 @var{AssemblerTemplate}, beyond those listed as outputs.
10818 An empty list is permitted.  @xref{Clobbers and Scratch Registers}.
10820 @item GotoLabels
10821 When you are using the @code{goto} form of @code{asm}, this section contains 
10822 the list of all C labels to which the code in the 
10823 @var{AssemblerTemplate} may jump. 
10824 @xref{GotoLabels}.
10826 @code{asm} statements may not perform jumps into other @code{asm} statements,
10827 only to the listed @var{GotoLabels}.
10828 GCC's optimizers do not know about other jumps; therefore they cannot take 
10829 account of them when deciding how to optimize.
10830 @end table
10832 The total number of input + output + goto operands is limited to 30.
10834 @subsubheading Remarks
10835 The @code{asm} statement allows you to include assembly instructions directly 
10836 within C code. This may help you to maximize performance in time-sensitive 
10837 code or to access assembly instructions that are not readily available to C 
10838 programs.
10840 Note that extended @code{asm} statements must be inside a function. Only 
10841 basic @code{asm} may be outside functions (@pxref{Basic Asm}).
10842 Functions declared with the @code{naked} attribute also require basic 
10843 @code{asm} (@pxref{Function Attributes}).
10845 While the uses of @code{asm} are many and varied, it may help to think of an 
10846 @code{asm} statement as a series of low-level instructions that convert input 
10847 parameters to output parameters. So a simple (if not particularly useful) 
10848 example for i386 using @code{asm} might look like this:
10850 @example
10851 int src = 1;
10852 int dst;   
10854 asm ("mov %1, %0\n\t"
10855     "add $1, %0"
10856     : "=r" (dst) 
10857     : "r" (src));
10859 printf("%d\n", dst);
10860 @end example
10862 This code copies @code{src} to @code{dst} and add 1 to @code{dst}.
10864 @anchor{Volatile}
10865 @subsubsection Volatile
10866 @cindex volatile @code{asm}
10867 @cindex @code{asm} volatile
10869 GCC's optimizers sometimes discard @code{asm} statements if they determine 
10870 there is no need for the output variables. Also, the optimizers may move 
10871 code out of loops if they believe that the code will always return the same 
10872 result (i.e.@: none of its input values change between calls). Using the 
10873 @code{volatile} qualifier disables these optimizations. @code{asm} statements 
10874 that have no output operands and @code{asm goto} statements, 
10875 are implicitly volatile.
10877 This i386 code demonstrates a case that does not use (or require) the 
10878 @code{volatile} qualifier. If it is performing assertion checking, this code 
10879 uses @code{asm} to perform the validation. Otherwise, @code{dwRes} is 
10880 unreferenced by any code. As a result, the optimizers can discard the 
10881 @code{asm} statement, which in turn removes the need for the entire 
10882 @code{DoCheck} routine. By omitting the @code{volatile} qualifier when it 
10883 isn't needed you allow the optimizers to produce the most efficient code 
10884 possible.
10886 @example
10887 void DoCheck(uint32_t dwSomeValue)
10889    uint32_t dwRes;
10891    // Assumes dwSomeValue is not zero.
10892    asm ("bsfl %1,%0"
10893      : "=r" (dwRes)
10894      : "r" (dwSomeValue)
10895      : "cc");
10897    assert(dwRes > 3);
10899 @end example
10901 The next example shows a case where the optimizers can recognize that the input 
10902 (@code{dwSomeValue}) never changes during the execution of the function and can 
10903 therefore move the @code{asm} outside the loop to produce more efficient code. 
10904 Again, using the @code{volatile} qualifier disables this type of optimization.
10906 @example
10907 void do_print(uint32_t dwSomeValue)
10909    uint32_t dwRes;
10911    for (uint32_t x=0; x < 5; x++)
10912    @{
10913       // Assumes dwSomeValue is not zero.
10914       asm ("bsfl %1,%0"
10915         : "=r" (dwRes)
10916         : "r" (dwSomeValue)
10917         : "cc");
10919       printf("%u: %u %u\n", x, dwSomeValue, dwRes);
10920    @}
10922 @end example
10924 The following example demonstrates a case where you need to use the 
10925 @code{volatile} qualifier. 
10926 It uses the x86 @code{rdtsc} instruction, which reads 
10927 the computer's time-stamp counter. Without the @code{volatile} qualifier, 
10928 the optimizers might assume that the @code{asm} block will always return the 
10929 same value and therefore optimize away the second call.
10931 @example
10932 uint64_t msr;
10934 asm volatile ( "rdtsc\n\t"    // Returns the time in EDX:EAX.
10935         "shl $32, %%rdx\n\t"  // Shift the upper bits left.
10936         "or %%rdx, %0"        // 'Or' in the lower bits.
10937         : "=a" (msr)
10938         : 
10939         : "rdx");
10941 printf("msr: %llx\n", msr);
10943 // Do other work...
10945 // Reprint the timestamp
10946 asm volatile ( "rdtsc\n\t"    // Returns the time in EDX:EAX.
10947         "shl $32, %%rdx\n\t"  // Shift the upper bits left.
10948         "or %%rdx, %0"        // 'Or' in the lower bits.
10949         : "=a" (msr)
10950         : 
10951         : "rdx");
10953 printf("msr: %llx\n", msr);
10954 @end example
10956 GCC's optimizers do not treat this code like the non-volatile code in the 
10957 earlier examples. They do not move it out of loops or omit it on the 
10958 assumption that the result from a previous call is still valid.
10960 Note that the compiler can move even @code{volatile asm} instructions relative
10961 to other code, including across jump instructions. For example, on many 
10962 targets there is a system register that controls the rounding mode of 
10963 floating-point operations. Setting it with a @code{volatile asm} statement,
10964 as in the following PowerPC example, does not work reliably.
10966 @example
10967 asm volatile("mtfsf 255, %0" : : "f" (fpenv));
10968 sum = x + y;
10969 @end example
10971 The compiler may move the addition back before the @code{volatile asm}
10972 statement. To make it work as expected, add an artificial dependency to
10973 the @code{asm} by referencing a variable in the subsequent code, for
10974 example:
10976 @example
10977 asm volatile ("mtfsf 255,%1" : "=X" (sum) : "f" (fpenv));
10978 sum = x + y;
10979 @end example
10981 Under certain circumstances, GCC may duplicate (or remove duplicates of) your 
10982 assembly code when optimizing. This can lead to unexpected duplicate symbol 
10983 errors during compilation if your @code{asm} code defines symbols or labels. 
10984 Using @samp{%=} 
10985 (@pxref{AssemblerTemplate}) may help resolve this problem.
10987 @anchor{AssemblerTemplate}
10988 @subsubsection Assembler Template
10989 @cindex @code{asm} assembler template
10991 An assembler template is a literal string containing assembler instructions.
10992 The compiler replaces tokens in the template that refer 
10993 to inputs, outputs, and goto labels,
10994 and then outputs the resulting string to the assembler. The 
10995 string can contain any instructions recognized by the assembler, including 
10996 directives. GCC does not parse the assembler instructions 
10997 themselves and does not know what they mean or even whether they are valid 
10998 assembler input. However, it does count the statements 
10999 (@pxref{Size of an asm}).
11001 You may place multiple assembler instructions together in a single @code{asm} 
11002 string, separated by the characters normally used in assembly code for the 
11003 system. A combination that works in most places is a newline to break the 
11004 line, plus a tab character to move to the instruction field (written as 
11005 @samp{\n\t}). 
11006 Some assemblers allow semicolons as a line separator. However, note 
11007 that some assembler dialects use semicolons to start a comment. 
11009 Do not expect a sequence of @code{asm} statements to remain perfectly 
11010 consecutive after compilation, even when you are using the @code{volatile} 
11011 qualifier. If certain instructions need to remain consecutive in the output, 
11012 put them in a single multi-instruction @code{asm} statement.
11014 Accessing data from C programs without using input/output operands (such as 
11015 by using global symbols directly from the assembler template) may not work as 
11016 expected. Similarly, calling functions directly from an assembler template 
11017 requires a detailed understanding of the target assembler and ABI.
11019 Since GCC does not parse the assembler template,
11020 it has no visibility of any 
11021 symbols it references. This may result in GCC discarding those symbols as 
11022 unreferenced unless they are also listed as input, output, or goto operands.
11024 @subsubheading Special format strings
11026 In addition to the tokens described by the input, output, and goto operands, 
11027 these tokens have special meanings in the assembler template:
11029 @table @samp
11030 @item %% 
11031 Outputs a single @samp{%} into the assembler code.
11033 @item %= 
11034 Outputs a number that is unique to each instance of the @code{asm} 
11035 statement in the entire compilation. This option is useful when creating local 
11036 labels and referring to them multiple times in a single template that 
11037 generates multiple assembler instructions. 
11039 @item %@{
11040 @itemx %|
11041 @itemx %@}
11042 Outputs @samp{@{}, @samp{|}, and @samp{@}} characters (respectively)
11043 into the assembler code.  When unescaped, these characters have special
11044 meaning to indicate multiple assembler dialects, as described below.
11045 @end table
11047 @subsubheading Multiple assembler dialects in @code{asm} templates
11049 On targets such as x86, GCC supports multiple assembler dialects.
11050 The @option{-masm} option controls which dialect GCC uses as its 
11051 default for inline assembler. The target-specific documentation for the 
11052 @option{-masm} option contains the list of supported dialects, as well as the 
11053 default dialect if the option is not specified. This information may be 
11054 important to understand, since assembler code that works correctly when 
11055 compiled using one dialect will likely fail if compiled using another.
11056 @xref{x86 Options}.
11058 If your code needs to support multiple assembler dialects (for example, if 
11059 you are writing public headers that need to support a variety of compilation 
11060 options), use constructs of this form:
11062 @example
11063 @{ dialect0 | dialect1 | dialect2... @}
11064 @end example
11066 This construct outputs @code{dialect0} 
11067 when using dialect #0 to compile the code, 
11068 @code{dialect1} for dialect #1, etc. If there are fewer alternatives within the 
11069 braces than the number of dialects the compiler supports, the construct 
11070 outputs nothing.
11072 For example, if an x86 compiler supports two dialects
11073 (@samp{att}, @samp{intel}), an 
11074 assembler template such as this:
11076 @example
11077 "bt@{l %[Offset],%[Base] | %[Base],%[Offset]@}; jc %l2"
11078 @end example
11080 @noindent
11081 is equivalent to one of
11083 @example
11084 "btl %[Offset],%[Base] ; jc %l2"   @r{/* att dialect */}
11085 "bt %[Base],%[Offset]; jc %l2"     @r{/* intel dialect */}
11086 @end example
11088 Using that same compiler, this code:
11090 @example
11091 "xchg@{l@}\t@{%%@}ebx, %1"
11092 @end example
11094 @noindent
11095 corresponds to either
11097 @example
11098 "xchgl\t%%ebx, %1"                 @r{/* att dialect */}
11099 "xchg\tebx, %1"                    @r{/* intel dialect */}
11100 @end example
11102 There is no support for nesting dialect alternatives.
11104 @anchor{OutputOperands}
11105 @subsubsection Output Operands
11106 @cindex @code{asm} output operands
11108 An @code{asm} statement has zero or more output operands indicating the names
11109 of C variables modified by the assembler code.
11111 In this i386 example, @code{old} (referred to in the template string as 
11112 @code{%0}) and @code{*Base} (as @code{%1}) are outputs and @code{Offset} 
11113 (@code{%2}) is an input:
11115 @example
11116 bool old;
11118 __asm__ ("btsl %2,%1\n\t" // Turn on zero-based bit #Offset in Base.
11119          "sbb %0,%0"      // Use the CF to calculate old.
11120    : "=r" (old), "+rm" (*Base)
11121    : "Ir" (Offset)
11122    : "cc");
11124 return old;
11125 @end example
11127 Operands are separated by commas.  Each operand has this format:
11129 @example
11130 @r{[} [@var{asmSymbolicName}] @r{]} @var{constraint} (@var{cvariablename})
11131 @end example
11133 @table @var
11134 @item asmSymbolicName
11135 Specifies a symbolic name for the operand.
11136 Reference the name in the assembler template 
11137 by enclosing it in square brackets 
11138 (i.e.@: @samp{%[Value]}). The scope of the name is the @code{asm} statement 
11139 that contains the definition. Any valid C variable name is acceptable, 
11140 including names already defined in the surrounding code. No two operands 
11141 within the same @code{asm} statement can use the same symbolic name.
11143 When not using an @var{asmSymbolicName}, use the (zero-based) position
11144 of the operand 
11145 in the list of operands in the assembler template. For example if there are 
11146 three output operands, use @samp{%0} in the template to refer to the first, 
11147 @samp{%1} for the second, and @samp{%2} for the third. 
11149 @item constraint
11150 A string constant specifying constraints on the placement of the operand; 
11151 @xref{Constraints}, for details.
11153 Output constraints must begin with either @samp{=} (a variable overwriting an 
11154 existing value) or @samp{+} (when reading and writing). When using 
11155 @samp{=}, do not assume the location contains the existing value
11156 on entry to the @code{asm}, except 
11157 when the operand is tied to an input; @pxref{InputOperands,,Input Operands}.
11159 After the prefix, there must be one or more additional constraints 
11160 (@pxref{Constraints}) that describe where the value resides. Common 
11161 constraints include @samp{r} for register and @samp{m} for memory. 
11162 When you list more than one possible location (for example, @code{"=rm"}),
11163 the compiler chooses the most efficient one based on the current context. 
11164 If you list as many alternates as the @code{asm} statement allows, you permit 
11165 the optimizers to produce the best possible code. 
11166 If you must use a specific register, but your Machine Constraints do not
11167 provide sufficient control to select the specific register you want, 
11168 local register variables may provide a solution (@pxref{Local Register 
11169 Variables}).
11171 @item cvariablename
11172 Specifies a C lvalue expression to hold the output, typically a variable name.
11173 The enclosing parentheses are a required part of the syntax.
11175 @end table
11177 When the compiler selects the registers to use to 
11178 represent the output operands, it does not use any of the clobbered registers 
11179 (@pxref{Clobbers and Scratch Registers}).
11181 Output operand expressions must be lvalues. The compiler cannot check whether 
11182 the operands have data types that are reasonable for the instruction being 
11183 executed. For output expressions that are not directly addressable (for 
11184 example a bit-field), the constraint must allow a register. In that case, GCC 
11185 uses the register as the output of the @code{asm}, and then stores that 
11186 register into the output. 
11188 Operands using the @samp{+} constraint modifier count as two operands 
11189 (that is, both as input and output) towards the total maximum of 30 operands
11190 per @code{asm} statement.
11192 Use the @samp{&} constraint modifier (@pxref{Modifiers}) on all output
11193 operands that must not overlap an input.  Otherwise, 
11194 GCC may allocate the output operand in the same register as an unrelated 
11195 input operand, on the assumption that the assembler code consumes its 
11196 inputs before producing outputs. This assumption may be false if the assembler 
11197 code actually consists of more than one instruction.
11199 The same problem can occur if one output parameter (@var{a}) allows a register 
11200 constraint and another output parameter (@var{b}) allows a memory constraint.
11201 The code generated by GCC to access the memory address in @var{b} can contain
11202 registers which @emph{might} be shared by @var{a}, and GCC considers those 
11203 registers to be inputs to the asm. As above, GCC assumes that such input
11204 registers are consumed before any outputs are written. This assumption may 
11205 result in incorrect behavior if the @code{asm} statement writes to @var{a}
11206 before using
11207 @var{b}. Combining the @samp{&} modifier with the register constraint on @var{a}
11208 ensures that modifying @var{a} does not affect the address referenced by 
11209 @var{b}. Otherwise, the location of @var{b} 
11210 is undefined if @var{a} is modified before using @var{b}.
11212 @code{asm} supports operand modifiers on operands (for example @samp{%k2} 
11213 instead of simply @samp{%2}). @ref{GenericOperandmodifiers,
11214 Generic Operand modifiers} lists the modifiers that are available
11215 on all targets.  Other modifiers are hardware dependent.
11216 For example, the list of supported modifiers for x86 is found at
11217 @ref{x86Operandmodifiers,x86 Operand modifiers}.
11219 If the C code that follows the @code{asm} makes no use of any of the output 
11220 operands, use @code{volatile} for the @code{asm} statement to prevent the 
11221 optimizers from discarding the @code{asm} statement as unneeded 
11222 (see @ref{Volatile}).
11224 This code makes no use of the optional @var{asmSymbolicName}. Therefore it 
11225 references the first output operand as @code{%0} (were there a second, it 
11226 would be @code{%1}, etc). The number of the first input operand is one greater 
11227 than that of the last output operand. In this i386 example, that makes 
11228 @code{Mask} referenced as @code{%1}:
11230 @example
11231 uint32_t Mask = 1234;
11232 uint32_t Index;
11234   asm ("bsfl %1, %0"
11235      : "=r" (Index)
11236      : "r" (Mask)
11237      : "cc");
11238 @end example
11240 That code overwrites the variable @code{Index} (@samp{=}),
11241 placing the value in a register (@samp{r}).
11242 Using the generic @samp{r} constraint instead of a constraint for a specific 
11243 register allows the compiler to pick the register to use, which can result 
11244 in more efficient code. This may not be possible if an assembler instruction 
11245 requires a specific register.
11247 The following i386 example uses the @var{asmSymbolicName} syntax.
11248 It produces the 
11249 same result as the code above, but some may consider it more readable or more 
11250 maintainable since reordering index numbers is not necessary when adding or 
11251 removing operands. The names @code{aIndex} and @code{aMask}
11252 are only used in this example to emphasize which 
11253 names get used where.
11254 It is acceptable to reuse the names @code{Index} and @code{Mask}.
11256 @example
11257 uint32_t Mask = 1234;
11258 uint32_t Index;
11260   asm ("bsfl %[aMask], %[aIndex]"
11261      : [aIndex] "=r" (Index)
11262      : [aMask] "r" (Mask)
11263      : "cc");
11264 @end example
11266 Here are some more examples of output operands.
11268 @example
11269 uint32_t c = 1;
11270 uint32_t d;
11271 uint32_t *e = &c;
11273 asm ("mov %[e], %[d]"
11274    : [d] "=rm" (d)
11275    : [e] "rm" (*e));
11276 @end example
11278 Here, @code{d} may either be in a register or in memory. Since the compiler 
11279 might already have the current value of the @code{uint32_t} location
11280 pointed to by @code{e}
11281 in a register, you can enable it to choose the best location
11282 for @code{d} by specifying both constraints.
11284 @anchor{FlagOutputOperands}
11285 @subsubsection Flag Output Operands
11286 @cindex @code{asm} flag output operands
11288 Some targets have a special register that holds the ``flags'' for the
11289 result of an operation or comparison.  Normally, the contents of that
11290 register are either unmodifed by the asm, or the @code{asm} statement is
11291 considered to clobber the contents.
11293 On some targets, a special form of output operand exists by which
11294 conditions in the flags register may be outputs of the asm.  The set of
11295 conditions supported are target specific, but the general rule is that
11296 the output variable must be a scalar integer, and the value is boolean.
11297 When supported, the target defines the preprocessor symbol
11298 @code{__GCC_ASM_FLAG_OUTPUTS__}.
11300 Because of the special nature of the flag output operands, the constraint
11301 may not include alternatives.
11303 Most often, the target has only one flags register, and thus is an implied
11304 operand of many instructions.  In this case, the operand should not be
11305 referenced within the assembler template via @code{%0} etc, as there's
11306 no corresponding text in the assembly language.
11308 @table @asis
11309 @item ARM
11310 @itemx AArch64
11311 The flag output constraints for the ARM family are of the form
11312 @samp{=@@cc@var{cond}} where @var{cond} is one of the standard
11313 conditions defined in the ARM ARM for @code{ConditionHolds}.
11315 @table @code
11316 @item eq
11317 Z flag set, or equal
11318 @item ne
11319 Z flag clear or not equal
11320 @item cs
11321 @itemx hs
11322 C flag set or unsigned greater than equal
11323 @item cc
11324 @itemx lo
11325 C flag clear or unsigned less than
11326 @item mi
11327 N flag set or ``minus''
11328 @item pl
11329 N flag clear or ``plus''
11330 @item vs
11331 V flag set or signed overflow
11332 @item vc
11333 V flag clear
11334 @item hi
11335 unsigned greater than
11336 @item ls
11337 unsigned less than equal
11338 @item ge
11339 signed greater than equal
11340 @item lt
11341 signed less than
11342 @item gt
11343 signed greater than
11344 @item le
11345 signed less than equal
11346 @end table
11348 The flag output constraints are not supported in thumb1 mode.
11350 @item x86 family
11351 The flag output constraints for the x86 family are of the form
11352 @samp{=@@cc@var{cond}} where @var{cond} is one of the standard
11353 conditions defined in the ISA manual for @code{j@var{cc}} or
11354 @code{set@var{cc}}.
11356 @table @code
11357 @item a
11358 ``above'' or unsigned greater than
11359 @item ae
11360 ``above or equal'' or unsigned greater than or equal
11361 @item b
11362 ``below'' or unsigned less than
11363 @item be
11364 ``below or equal'' or unsigned less than or equal
11365 @item c
11366 carry flag set
11367 @item e
11368 @itemx z
11369 ``equal'' or zero flag set
11370 @item g
11371 signed greater than
11372 @item ge
11373 signed greater than or equal
11374 @item l
11375 signed less than
11376 @item le
11377 signed less than or equal
11378 @item o
11379 overflow flag set
11380 @item p
11381 parity flag set
11382 @item s
11383 sign flag set
11384 @item na
11385 @itemx nae
11386 @itemx nb
11387 @itemx nbe
11388 @itemx nc
11389 @itemx ne
11390 @itemx ng
11391 @itemx nge
11392 @itemx nl
11393 @itemx nle
11394 @itemx no
11395 @itemx np
11396 @itemx ns
11397 @itemx nz
11398 ``not'' @var{flag}, or inverted versions of those above
11399 @end table
11401 @item s390
11402 The flag output constraint for s390 is @samp{=@@cc}.  Only one such
11403 constraint is allowed.  The variable has to be stored in a @samp{int}
11404 variable.
11406 @end table
11408 @anchor{InputOperands}
11409 @subsubsection Input Operands
11410 @cindex @code{asm} input operands
11411 @cindex @code{asm} expressions
11413 Input operands make values from C variables and expressions available to the 
11414 assembly code.
11416 Operands are separated by commas.  Each operand has this format:
11418 @example
11419 @r{[} [@var{asmSymbolicName}] @r{]} @var{constraint} (@var{cexpression})
11420 @end example
11422 @table @var
11423 @item asmSymbolicName
11424 Specifies a symbolic name for the operand.
11425 Reference the name in the assembler template 
11426 by enclosing it in square brackets 
11427 (i.e.@: @samp{%[Value]}). The scope of the name is the @code{asm} statement 
11428 that contains the definition. Any valid C variable name is acceptable, 
11429 including names already defined in the surrounding code. No two operands 
11430 within the same @code{asm} statement can use the same symbolic name.
11432 When not using an @var{asmSymbolicName}, use the (zero-based) position
11433 of the operand 
11434 in the list of operands in the assembler template. For example if there are
11435 two output operands and three inputs,
11436 use @samp{%2} in the template to refer to the first input operand,
11437 @samp{%3} for the second, and @samp{%4} for the third. 
11439 @item constraint
11440 A string constant specifying constraints on the placement of the operand; 
11441 @xref{Constraints}, for details.
11443 Input constraint strings may not begin with either @samp{=} or @samp{+}.
11444 When you list more than one possible location (for example, @samp{"irm"}), 
11445 the compiler chooses the most efficient one based on the current context.
11446 If you must use a specific register, but your Machine Constraints do not
11447 provide sufficient control to select the specific register you want, 
11448 local register variables may provide a solution (@pxref{Local Register 
11449 Variables}).
11451 Input constraints can also be digits (for example, @code{"0"}). This indicates 
11452 that the specified input must be in the same place as the output constraint 
11453 at the (zero-based) index in the output constraint list. 
11454 When using @var{asmSymbolicName} syntax for the output operands,
11455 you may use these names (enclosed in brackets @samp{[]}) instead of digits.
11457 @item cexpression
11458 This is the C variable or expression being passed to the @code{asm} statement 
11459 as input.  The enclosing parentheses are a required part of the syntax.
11461 @end table
11463 When the compiler selects the registers to use to represent the input 
11464 operands, it does not use any of the clobbered registers
11465 (@pxref{Clobbers and Scratch Registers}).
11467 If there are no output operands but there are input operands, place two 
11468 consecutive colons where the output operands would go:
11470 @example
11471 __asm__ ("some instructions"
11472    : /* No outputs. */
11473    : "r" (Offset / 8));
11474 @end example
11476 @strong{Warning:} Do @emph{not} modify the contents of input-only operands 
11477 (except for inputs tied to outputs). The compiler assumes that on exit from 
11478 the @code{asm} statement these operands contain the same values as they 
11479 had before executing the statement. 
11480 It is @emph{not} possible to use clobbers
11481 to inform the compiler that the values in these inputs are changing. One 
11482 common work-around is to tie the changing input variable to an output variable 
11483 that never gets used. Note, however, that if the code that follows the 
11484 @code{asm} statement makes no use of any of the output operands, the GCC 
11485 optimizers may discard the @code{asm} statement as unneeded 
11486 (see @ref{Volatile}).
11488 @code{asm} supports operand modifiers on operands (for example @samp{%k2} 
11489 instead of simply @samp{%2}). @ref{GenericOperandmodifiers,
11490 Generic Operand modifiers} lists the modifiers that are available
11491 on all targets.  Other modifiers are hardware dependent.
11492 For example, the list of supported modifiers for x86 is found at
11493 @ref{x86Operandmodifiers,x86 Operand modifiers}.
11495 In this example using the fictitious @code{combine} instruction, the 
11496 constraint @code{"0"} for input operand 1 says that it must occupy the same 
11497 location as output operand 0. Only input operands may use numbers in 
11498 constraints, and they must each refer to an output operand. Only a number (or 
11499 the symbolic assembler name) in the constraint can guarantee that one operand 
11500 is in the same place as another. The mere fact that @code{foo} is the value of 
11501 both operands is not enough to guarantee that they are in the same place in 
11502 the generated assembler code.
11504 @example
11505 asm ("combine %2, %0" 
11506    : "=r" (foo) 
11507    : "0" (foo), "g" (bar));
11508 @end example
11510 Here is an example using symbolic names.
11512 @example
11513 asm ("cmoveq %1, %2, %[result]" 
11514    : [result] "=r"(result) 
11515    : "r" (test), "r" (new), "[result]" (old));
11516 @end example
11518 @anchor{Clobbers and Scratch Registers}
11519 @subsubsection Clobbers and Scratch Registers
11520 @cindex @code{asm} clobbers
11521 @cindex @code{asm} scratch registers
11523 While the compiler is aware of changes to entries listed in the output 
11524 operands, the inline @code{asm} code may modify more than just the outputs. For 
11525 example, calculations may require additional registers, or the processor may 
11526 overwrite a register as a side effect of a particular assembler instruction. 
11527 In order to inform the compiler of these changes, list them in the clobber 
11528 list. Clobber list items are either register names or the special clobbers 
11529 (listed below). Each clobber list item is a string constant 
11530 enclosed in double quotes and separated by commas.
11532 Clobber descriptions may not in any way overlap with an input or output 
11533 operand. For example, you may not have an operand describing a register class 
11534 with one member when listing that register in the clobber list. Variables 
11535 declared to live in specific registers (@pxref{Explicit Register 
11536 Variables}) and used 
11537 as @code{asm} input or output operands must have no part mentioned in the 
11538 clobber description. In particular, there is no way to specify that input 
11539 operands get modified without also specifying them as output operands.
11541 When the compiler selects which registers to use to represent input and output 
11542 operands, it does not use any of the clobbered registers. As a result, 
11543 clobbered registers are available for any use in the assembler code.
11545 Another restriction is that the clobber list should not contain the
11546 stack pointer register.  This is because the compiler requires the
11547 value of the stack pointer to be the same after an @code{asm}
11548 statement as it was on entry to the statement.  However, previous
11549 versions of GCC did not enforce this rule and allowed the stack
11550 pointer to appear in the list, with unclear semantics.  This behavior
11551 is deprecated and listing the stack pointer may become an error in
11552 future versions of GCC@.
11554 Here is a realistic example for the VAX showing the use of clobbered 
11555 registers: 
11557 @example
11558 asm volatile ("movc3 %0, %1, %2"
11559                    : /* No outputs. */
11560                    : "g" (from), "g" (to), "g" (count)
11561                    : "r0", "r1", "r2", "r3", "r4", "r5", "memory");
11562 @end example
11564 Also, there are two special clobber arguments:
11566 @table @code
11567 @item "cc"
11568 The @code{"cc"} clobber indicates that the assembler code modifies the flags 
11569 register. On some machines, GCC represents the condition codes as a specific 
11570 hardware register; @code{"cc"} serves to name this register.
11571 On other machines, condition code handling is different, 
11572 and specifying @code{"cc"} has no effect. But 
11573 it is valid no matter what the target.
11575 @item "memory"
11576 The @code{"memory"} clobber tells the compiler that the assembly code
11577 performs memory 
11578 reads or writes to items other than those listed in the input and output 
11579 operands (for example, accessing the memory pointed to by one of the input 
11580 parameters). To ensure memory contains correct values, GCC may need to flush 
11581 specific register values to memory before executing the @code{asm}. Further, 
11582 the compiler does not assume that any values read from memory before an 
11583 @code{asm} remain unchanged after that @code{asm}; it reloads them as 
11584 needed.  
11585 Using the @code{"memory"} clobber effectively forms a read/write
11586 memory barrier for the compiler.
11588 Note that this clobber does not prevent the @emph{processor} from doing 
11589 speculative reads past the @code{asm} statement. To prevent that, you need 
11590 processor-specific fence instructions.
11592 @end table
11594 Flushing registers to memory has performance implications and may be
11595 an issue for time-sensitive code.  You can provide better information
11596 to GCC to avoid this, as shown in the following examples.  At a
11597 minimum, aliasing rules allow GCC to know what memory @emph{doesn't}
11598 need to be flushed.
11600 Here is a fictitious sum of squares instruction, that takes two
11601 pointers to floating point values in memory and produces a floating
11602 point register output.
11603 Notice that @code{x}, and @code{y} both appear twice in the @code{asm}
11604 parameters, once to specify memory accessed, and once to specify a
11605 base register used by the @code{asm}.  You won't normally be wasting a
11606 register by doing this as GCC can use the same register for both
11607 purposes.  However, it would be foolish to use both @code{%1} and
11608 @code{%3} for @code{x} in this @code{asm} and expect them to be the
11609 same.  In fact, @code{%3} may well not be a register.  It might be a
11610 symbolic memory reference to the object pointed to by @code{x}.
11612 @smallexample
11613 asm ("sumsq %0, %1, %2"
11614      : "+f" (result)
11615      : "r" (x), "r" (y), "m" (*x), "m" (*y));
11616 @end smallexample
11618 Here is a fictitious @code{*z++ = *x++ * *y++} instruction.
11619 Notice that the @code{x}, @code{y} and @code{z} pointer registers
11620 must be specified as input/output because the @code{asm} modifies
11621 them.
11623 @smallexample
11624 asm ("vecmul %0, %1, %2"
11625      : "+r" (z), "+r" (x), "+r" (y), "=m" (*z)
11626      : "m" (*x), "m" (*y));
11627 @end smallexample
11629 An x86 example where the string memory argument is of unknown length.
11631 @smallexample
11632 asm("repne scasb"
11633     : "=c" (count), "+D" (p)
11634     : "m" (*(const char (*)[]) p), "0" (-1), "a" (0));
11635 @end smallexample
11637 If you know the above will only be reading a ten byte array then you
11638 could instead use a memory input like:
11639 @code{"m" (*(const char (*)[10]) p)}.
11641 Here is an example of a PowerPC vector scale implemented in assembly,
11642 complete with vector and condition code clobbers, and some initialized
11643 offset registers that are unchanged by the @code{asm}.
11645 @smallexample
11646 void
11647 dscal (size_t n, double *x, double alpha)
11649   asm ("/* lots of asm here */"
11650        : "+m" (*(double (*)[n]) x), "+&r" (n), "+b" (x)
11651        : "d" (alpha), "b" (32), "b" (48), "b" (64),
11652          "b" (80), "b" (96), "b" (112)
11653        : "cr0",
11654          "vs32","vs33","vs34","vs35","vs36","vs37","vs38","vs39",
11655          "vs40","vs41","vs42","vs43","vs44","vs45","vs46","vs47");
11657 @end smallexample
11659 Rather than allocating fixed registers via clobbers to provide scratch
11660 registers for an @code{asm} statement, an alternative is to define a
11661 variable and make it an early-clobber output as with @code{a2} and
11662 @code{a3} in the example below.  This gives the compiler register
11663 allocator more freedom.  You can also define a variable and make it an
11664 output tied to an input as with @code{a0} and @code{a1}, tied
11665 respectively to @code{ap} and @code{lda}.  Of course, with tied
11666 outputs your @code{asm} can't use the input value after modifying the
11667 output register since they are one and the same register.  What's
11668 more, if you omit the early-clobber on the output, it is possible that
11669 GCC might allocate the same register to another of the inputs if GCC
11670 could prove they had the same value on entry to the @code{asm}.  This
11671 is why @code{a1} has an early-clobber.  Its tied input, @code{lda}
11672 might conceivably be known to have the value 16 and without an
11673 early-clobber share the same register as @code{%11}.  On the other
11674 hand, @code{ap} can't be the same as any of the other inputs, so an
11675 early-clobber on @code{a0} is not needed.  It is also not desirable in
11676 this case.  An early-clobber on @code{a0} would cause GCC to allocate
11677 a separate register for the @code{"m" (*(const double (*)[]) ap)}
11678 input.  Note that tying an input to an output is the way to set up an
11679 initialized temporary register modified by an @code{asm} statement.
11680 An input not tied to an output is assumed by GCC to be unchanged, for
11681 example @code{"b" (16)} below sets up @code{%11} to 16, and GCC might
11682 use that register in following code if the value 16 happened to be
11683 needed.  You can even use a normal @code{asm} output for a scratch if
11684 all inputs that might share the same register are consumed before the
11685 scratch is used.  The VSX registers clobbered by the @code{asm}
11686 statement could have used this technique except for GCC's limit on the
11687 number of @code{asm} parameters.
11689 @smallexample
11690 static void
11691 dgemv_kernel_4x4 (long n, const double *ap, long lda,
11692                   const double *x, double *y, double alpha)
11694   double *a0;
11695   double *a1;
11696   double *a2;
11697   double *a3;
11699   __asm__
11700     (
11701      /* lots of asm here */
11702      "#n=%1 ap=%8=%12 lda=%13 x=%7=%10 y=%0=%2 alpha=%9 o16=%11\n"
11703      "#a0=%3 a1=%4 a2=%5 a3=%6"
11704      :
11705        "+m" (*(double (*)[n]) y),
11706        "+&r" (n),       // 1
11707        "+b" (y),        // 2
11708        "=b" (a0),       // 3
11709        "=&b" (a1),      // 4
11710        "=&b" (a2),      // 5
11711        "=&b" (a3)       // 6
11712      :
11713        "m" (*(const double (*)[n]) x),
11714        "m" (*(const double (*)[]) ap),
11715        "d" (alpha),     // 9
11716        "r" (x),         // 10
11717        "b" (16),        // 11
11718        "3" (ap),        // 12
11719        "4" (lda)        // 13
11720      :
11721        "cr0",
11722        "vs32","vs33","vs34","vs35","vs36","vs37",
11723        "vs40","vs41","vs42","vs43","vs44","vs45","vs46","vs47"
11724      );
11726 @end smallexample
11728 @anchor{GotoLabels}
11729 @subsubsection Goto Labels
11730 @cindex @code{asm} goto labels
11732 @code{asm goto} allows assembly code to jump to one or more C labels.  The
11733 @var{GotoLabels} section in an @code{asm goto} statement contains 
11734 a comma-separated 
11735 list of all C labels to which the assembler code may jump. GCC assumes that 
11736 @code{asm} execution falls through to the next statement (if this is not the 
11737 case, consider using the @code{__builtin_unreachable} intrinsic after the 
11738 @code{asm} statement). Optimization of @code{asm goto} may be improved by 
11739 using the @code{hot} and @code{cold} label attributes (@pxref{Label 
11740 Attributes}).
11742 If the assembler code does modify anything, use the @code{"memory"} clobber 
11743 to force the 
11744 optimizers to flush all register values to memory and reload them if 
11745 necessary after the @code{asm} statement.
11747 Also note that an @code{asm goto} statement is always implicitly
11748 considered volatile.
11750 Be careful when you set output operands inside @code{asm goto} only on
11751 some possible control flow paths.  If you don't set up the output on
11752 given path and never use it on this path, it is okay.  Otherwise, you
11753 should use @samp{+} constraint modifier meaning that the operand is
11754 input and output one.  With this modifier you will have the correct
11755 values on all possible paths from the @code{asm goto}.
11757 To reference a label in the assembler template, prefix it with
11758 @samp{%l} (lowercase @samp{L}) followed by its (zero-based) position
11759 in @var{GotoLabels} plus the number of input and output operands.
11760 Output operand with constraint modifier @samp{+} is counted as two
11761 operands because it is considered as one output and one input operand.
11762 For example, if the @code{asm} has three inputs, one output operand
11763 with constraint modifier @samp{+} and one output operand with
11764 constraint modifier @samp{=} and references two labels, refer to the
11765 first label as @samp{%l6} and the second as @samp{%l7}).
11767 Alternately, you can reference labels using the actual C label name
11768 enclosed in brackets.  For example, to reference a label named
11769 @code{carry}, you can use @samp{%l[carry]}.  The label must still be
11770 listed in the @var{GotoLabels} section when using this approach.  It
11771 is better to use the named references for labels as in this case you
11772 can avoid counting input and output operands and special treatment of
11773 output operands with constraint modifier @samp{+}.
11775 Here is an example of @code{asm goto} for i386:
11777 @example
11778 asm goto (
11779     "btl %1, %0\n\t"
11780     "jc %l2"
11781     : /* No outputs. */
11782     : "r" (p1), "r" (p2) 
11783     : "cc" 
11784     : carry);
11786 return 0;
11788 carry:
11789 return 1;
11790 @end example
11792 The following example shows an @code{asm goto} that uses a memory clobber.
11794 @example
11795 int frob(int x)
11797   int y;
11798   asm goto ("frob %%r5, %1; jc %l[error]; mov (%2), %%r5"
11799             : /* No outputs. */
11800             : "r"(x), "r"(&y)
11801             : "r5", "memory" 
11802             : error);
11803   return y;
11804 error:
11805   return -1;
11807 @end example
11809 The following example shows an @code{asm goto} that uses an output.
11811 @example
11812 int foo(int count)
11814   asm goto ("dec %0; jb %l[stop]"
11815             : "+r" (count)
11816             :
11817             :
11818             : stop);
11819   return count;
11820 stop:
11821   return 0;
11823 @end example
11825 The following artificial example shows an @code{asm goto} that sets
11826 up an output only on one path inside the @code{asm goto}.  Usage of
11827 constraint modifier @code{=} instead of @code{+} would be wrong as
11828 @code{factor} is used on all paths from the @code{asm goto}.
11830 @example
11831 int foo(int inp)
11833   int factor = 0;
11834   asm goto ("cmp %1, 10; jb %l[lab]; mov 2, %0"
11835             : "+r" (factor)
11836             : "r" (inp)
11837             :
11838             : lab);
11839 lab:
11840   return inp * factor; /* return 2 * inp or 0 if inp < 10 */
11842 @end example
11844 @anchor{GenericOperandmodifiers}
11845 @subsubsection Generic Operand Modifiers
11846 @noindent
11847 The following table shows the modifiers supported by all targets and their effects:
11849 @multitable @columnfractions 0.15 0.7 0.15
11850 @headitem Modifier @tab Description @tab Example
11851 @item @code{c}
11852 @tab Require a constant operand and print the constant expression with no punctuation.
11853 @tab @code{%c0}
11854 @item @code{n}
11855 @tab Like @samp{%c} except that the value of the constant is negated before printing.
11856 @tab @code{%n0}
11857 @item @code{a}
11858 @tab Substitute a memory reference, with the actual operand treated as the address.
11859 This may be useful when outputting a ``load address'' instruction, because
11860 often the assembler syntax for such an instruction requires you to write the
11861 operand as if it were a memory reference.
11862 @tab @code{%a0}
11863 @item @code{l}
11864 @tab Print the label name with no punctuation.
11865 @tab @code{%l0}
11866 @end multitable
11868 @anchor{aarch64Operandmodifiers}
11869 @subsubsection AArch64 Operand Modifiers
11871 The following table shows the modifiers supported by AArch64 and their effects:
11873 @multitable @columnfractions .10 .90
11874 @headitem Modifier @tab Description
11875 @item @code{w} @tab Print a 32-bit general-purpose register name or, given a
11876 constant zero operand, the 32-bit zero register (@code{wzr}).
11877 @item @code{x} @tab Print a 64-bit general-purpose register name or, given a
11878 constant zero operand, the 64-bit zero register (@code{xzr}).
11879 @item @code{b} @tab Print an FP/SIMD register name with a @code{b} (byte, 8-bit)
11880 prefix.
11881 @item @code{h} @tab Print an FP/SIMD register name with an @code{h} (halfword,
11882 16-bit) prefix.
11883 @item @code{s} @tab Print an FP/SIMD register name with an @code{s} (single
11884 word, 32-bit) prefix.
11885 @item @code{d} @tab Print an FP/SIMD register name with a @code{d} (doubleword,
11886 64-bit) prefix.
11887 @item @code{q} @tab Print an FP/SIMD register name with a @code{q} (quadword,
11888 128-bit) prefix.
11889 @item @code{Z} @tab Print an FP/SIMD register name as an SVE register (i.e. with
11890 a @code{z} prefix).  This is a no-op for SVE register operands.
11891 @end multitable
11893 @anchor{x86Operandmodifiers}
11894 @subsubsection x86 Operand Modifiers
11896 References to input, output, and goto operands in the assembler template
11897 of extended @code{asm} statements can use 
11898 modifiers to affect the way the operands are formatted in 
11899 the code output to the assembler. For example, the 
11900 following code uses the @samp{h} and @samp{b} modifiers for x86:
11902 @example
11903 uint16_t  num;
11904 asm volatile ("xchg %h0, %b0" : "+a" (num) );
11905 @end example
11907 @noindent
11908 These modifiers generate this assembler code:
11910 @example
11911 xchg %ah, %al
11912 @end example
11914 The rest of this discussion uses the following code for illustrative purposes.
11916 @example
11917 int main()
11919    int iInt = 1;
11921 top:
11923    asm volatile goto ("some assembler instructions here"
11924    : /* No outputs. */
11925    : "q" (iInt), "X" (sizeof(unsigned char) + 1), "i" (42)
11926    : /* No clobbers. */
11927    : top);
11929 @end example
11931 With no modifiers, this is what the output from the operands would be
11932 for the @samp{att} and @samp{intel} dialects of assembler:
11934 @multitable {Operand} {$.L2} {OFFSET FLAT:.L2}
11935 @headitem Operand @tab @samp{att} @tab @samp{intel}
11936 @item @code{%0}
11937 @tab @code{%eax}
11938 @tab @code{eax}
11939 @item @code{%1}
11940 @tab @code{$2}
11941 @tab @code{2}
11942 @item @code{%3}
11943 @tab @code{$.L3}
11944 @tab @code{OFFSET FLAT:.L3}
11945 @item @code{%4}
11946 @tab @code{$8}
11947 @tab @code{8}
11948 @item @code{%5}
11949 @tab @code{%xmm0}
11950 @tab @code{xmm0}
11951 @item @code{%7}
11952 @tab @code{$0}
11953 @tab @code{0}
11954 @end multitable
11956 The table below shows the list of supported modifiers and their effects.
11958 @multitable {Modifier} {Print the opcode suffix for the size of th} {Operand} {@samp{att}} {@samp{intel}}
11959 @headitem Modifier @tab Description @tab Operand @tab @samp{att} @tab @samp{intel}
11960 @item @code{A}
11961 @tab Print an absolute memory reference.
11962 @tab @code{%A0}
11963 @tab @code{*%rax}
11964 @tab @code{rax}
11965 @item @code{b}
11966 @tab Print the QImode name of the register.
11967 @tab @code{%b0}
11968 @tab @code{%al}
11969 @tab @code{al}
11970 @item @code{B}
11971 @tab print the opcode suffix of b.
11972 @tab @code{%B0}
11973 @tab @code{b}
11974 @tab
11975 @item @code{c}
11976 @tab Require a constant operand and print the constant expression with no punctuation.
11977 @tab @code{%c1}
11978 @tab @code{2}
11979 @tab @code{2}
11980 @item @code{d}
11981 @tab print duplicated register operand for AVX instruction.
11982 @tab @code{%d5}
11983 @tab @code{%xmm0, %xmm0}
11984 @tab @code{xmm0, xmm0}
11985 @item @code{E}
11986 @tab Print the address in Double Integer (DImode) mode (8 bytes) when the target is 64-bit.
11987 Otherwise mode is unspecified (VOIDmode).
11988 @tab @code{%E1}
11989 @tab @code{%(rax)}
11990 @tab @code{[rax]}
11991 @item @code{g}
11992 @tab Print the V16SFmode name of the register.
11993 @tab @code{%g0}
11994 @tab @code{%zmm0}
11995 @tab @code{zmm0}
11996 @item @code{h}
11997 @tab Print the QImode name for a ``high'' register.
11998 @tab @code{%h0}
11999 @tab @code{%ah}
12000 @tab @code{ah}
12001 @item @code{H}
12002 @tab Add 8 bytes to an offsettable memory reference. Useful when accessing the
12003 high 8 bytes of SSE values. For a memref in (%rax), it generates
12004 @tab @code{%H0}
12005 @tab @code{8(%rax)}
12006 @tab @code{8[rax]}
12007 @item @code{k}
12008 @tab Print the SImode name of the register.
12009 @tab @code{%k0}
12010 @tab @code{%eax}
12011 @tab @code{eax}
12012 @item @code{l}
12013 @tab Print the label name with no punctuation.
12014 @tab @code{%l3}
12015 @tab @code{.L3}
12016 @tab @code{.L3}
12017 @item @code{L}
12018 @tab print the opcode suffix of l.
12019 @tab @code{%L0}
12020 @tab @code{l}
12021 @tab
12022 @item @code{N}
12023 @tab print maskz.
12024 @tab @code{%N7}
12025 @tab @code{@{z@}}
12026 @tab @code{@{z@}}
12027 @item @code{p}
12028 @tab Print raw symbol name (without syntax-specific prefixes).
12029 @tab @code{%p2}
12030 @tab @code{42}
12031 @tab @code{42}
12032 @item @code{P}
12033 @tab If used for a function, print the PLT suffix and generate PIC code.
12034 For example, emit @code{foo@@PLT} instead of 'foo' for the function
12035 foo(). If used for a constant, drop all syntax-specific prefixes and
12036 issue the bare constant. See @code{p} above.
12037 @item @code{q}
12038 @tab Print the DImode name of the register.
12039 @tab @code{%q0}
12040 @tab @code{%rax}
12041 @tab @code{rax}
12042 @item @code{Q}
12043 @tab print the opcode suffix of q.
12044 @tab @code{%Q0}
12045 @tab @code{q}
12046 @tab
12047 @item @code{R}
12048 @tab print embedded rounding and sae.
12049 @tab @code{%R4}
12050 @tab @code{@{rn-sae@}, }
12051 @tab @code{, @{rn-sae@}}
12052 @item @code{r}
12053 @tab print only sae.
12054 @tab @code{%r4}
12055 @tab @code{@{sae@}, }
12056 @tab @code{, @{sae@}}
12057 @item @code{s}
12058 @tab print a shift double count, followed by the assemblers argument
12059 delimiterprint the opcode suffix of s.
12060 @tab @code{%s1}
12061 @tab @code{$2, }
12062 @tab @code{2, }
12063 @item @code{S}
12064 @tab print the opcode suffix of s.
12065 @tab @code{%S0}
12066 @tab @code{s}
12067 @tab
12068 @item @code{t}
12069 @tab print the V8SFmode name of the register.
12070 @tab @code{%t5}
12071 @tab @code{%ymm0}
12072 @tab @code{ymm0}
12073 @item @code{T}
12074 @tab print the opcode suffix of t.
12075 @tab @code{%T0}
12076 @tab @code{t}
12077 @tab
12078 @item @code{V}
12079 @tab print naked full integer register name without %.
12080 @tab @code{%V0}
12081 @tab @code{eax}
12082 @tab @code{eax}
12083 @item @code{w}
12084 @tab Print the HImode name of the register.
12085 @tab @code{%w0}
12086 @tab @code{%ax}
12087 @tab @code{ax}
12088 @item @code{W}
12089 @tab print the opcode suffix of w.
12090 @tab @code{%W0}
12091 @tab @code{w}
12092 @tab
12093 @item @code{x}
12094 @tab print the V4SFmode name of the register.
12095 @tab @code{%x5}
12096 @tab @code{%xmm0}
12097 @tab @code{xmm0}
12098 @item @code{y}
12099 @tab print "st(0)" instead of "st" as a register.
12100 @tab @code{%y6}
12101 @tab @code{%st(0)}
12102 @tab @code{st(0)}
12103 @item @code{z}
12104 @tab Print the opcode suffix for the size of the current integer operand (one of @code{b}/@code{w}/@code{l}/@code{q}).
12105 @tab @code{%z0}
12106 @tab @code{l}
12107 @tab 
12108 @item @code{Z}
12109 @tab Like @code{z}, with special suffixes for x87 instructions.
12110 @end multitable
12113 @anchor{x86floatingpointasmoperands}
12114 @subsubsection x86 Floating-Point @code{asm} Operands
12116 On x86 targets, there are several rules on the usage of stack-like registers
12117 in the operands of an @code{asm}.  These rules apply only to the operands
12118 that are stack-like registers:
12120 @enumerate
12121 @item
12122 Given a set of input registers that die in an @code{asm}, it is
12123 necessary to know which are implicitly popped by the @code{asm}, and
12124 which must be explicitly popped by GCC@.
12126 An input register that is implicitly popped by the @code{asm} must be
12127 explicitly clobbered, unless it is constrained to match an
12128 output operand.
12130 @item
12131 For any input register that is implicitly popped by an @code{asm}, it is
12132 necessary to know how to adjust the stack to compensate for the pop.
12133 If any non-popped input is closer to the top of the reg-stack than
12134 the implicitly popped register, it would not be possible to know what the
12135 stack looked like---it's not clear how the rest of the stack ``slides
12136 up''.
12138 All implicitly popped input registers must be closer to the top of
12139 the reg-stack than any input that is not implicitly popped.
12141 It is possible that if an input dies in an @code{asm}, the compiler might
12142 use the input register for an output reload.  Consider this example:
12144 @smallexample
12145 asm ("foo" : "=t" (a) : "f" (b));
12146 @end smallexample
12148 @noindent
12149 This code says that input @code{b} is not popped by the @code{asm}, and that
12150 the @code{asm} pushes a result onto the reg-stack, i.e., the stack is one
12151 deeper after the @code{asm} than it was before.  But, it is possible that
12152 reload may think that it can use the same register for both the input and
12153 the output.
12155 To prevent this from happening,
12156 if any input operand uses the @samp{f} constraint, all output register
12157 constraints must use the @samp{&} early-clobber modifier.
12159 The example above is correctly written as:
12161 @smallexample
12162 asm ("foo" : "=&t" (a) : "f" (b));
12163 @end smallexample
12165 @item
12166 Some operands need to be in particular places on the stack.  All
12167 output operands fall in this category---GCC has no other way to
12168 know which registers the outputs appear in unless you indicate
12169 this in the constraints.
12171 Output operands must specifically indicate which register an output
12172 appears in after an @code{asm}.  @samp{=f} is not allowed: the operand
12173 constraints must select a class with a single register.
12175 @item
12176 Output operands may not be ``inserted'' between existing stack registers.
12177 Since no 387 opcode uses a read/write operand, all output operands
12178 are dead before the @code{asm}, and are pushed by the @code{asm}.
12179 It makes no sense to push anywhere but the top of the reg-stack.
12181 Output operands must start at the top of the reg-stack: output
12182 operands may not ``skip'' a register.
12184 @item
12185 Some @code{asm} statements may need extra stack space for internal
12186 calculations.  This can be guaranteed by clobbering stack registers
12187 unrelated to the inputs and outputs.
12189 @end enumerate
12191 This @code{asm}
12192 takes one input, which is internally popped, and produces two outputs.
12194 @smallexample
12195 asm ("fsincos" : "=t" (cos), "=u" (sin) : "0" (inp));
12196 @end smallexample
12198 @noindent
12199 This @code{asm} takes two inputs, which are popped by the @code{fyl2xp1} opcode,
12200 and replaces them with one output.  The @code{st(1)} clobber is necessary 
12201 for the compiler to know that @code{fyl2xp1} pops both inputs.
12203 @smallexample
12204 asm ("fyl2xp1" : "=t" (result) : "0" (x), "u" (y) : "st(1)");
12205 @end smallexample
12207 @anchor{msp430Operandmodifiers}
12208 @subsubsection MSP430 Operand Modifiers
12210 The list below describes the supported modifiers and their effects for MSP430.
12212 @multitable @columnfractions .10 .90
12213 @headitem Modifier @tab Description
12214 @item @code{A} @tab Select low 16-bits of the constant/register/memory operand.
12215 @item @code{B} @tab Select high 16-bits of the constant/register/memory
12216 operand.
12217 @item @code{C} @tab Select bits 32-47 of the constant/register/memory operand.
12218 @item @code{D} @tab Select bits 48-63 of the constant/register/memory operand.
12219 @item @code{H} @tab Equivalent to @code{B} (for backwards compatibility).
12220 @item @code{I} @tab Print the inverse (logical @code{NOT}) of the constant
12221 value.
12222 @item @code{J} @tab Print an integer without a @code{#} prefix.
12223 @item @code{L} @tab Equivalent to @code{A} (for backwards compatibility).
12224 @item @code{O} @tab Offset of the current frame from the top of the stack.
12225 @item @code{Q} @tab Use the @code{A} instruction postfix.
12226 @item @code{R} @tab Inverse of condition code, for unsigned comparisons.
12227 @item @code{W} @tab Subtract 16 from the constant value.
12228 @item @code{X} @tab Use the @code{X} instruction postfix.
12229 @item @code{Y} @tab Subtract 4 from the constant value.
12230 @item @code{Z} @tab Subtract 1 from the constant value.
12231 @item @code{b} @tab Append @code{.B}, @code{.W} or @code{.A} to the
12232 instruction, depending on the mode.
12233 @item @code{d} @tab Offset 1 byte of a memory reference or constant value.
12234 @item @code{e} @tab Offset 3 bytes of a memory reference or constant value.
12235 @item @code{f} @tab Offset 5 bytes of a memory reference or constant value.
12236 @item @code{g} @tab Offset 7 bytes of a memory reference or constant value.
12237 @item @code{p} @tab Print the value of 2, raised to the power of the given
12238 constant.  Used to select the specified bit position.
12239 @item @code{r} @tab Inverse of condition code, for signed comparisons.
12240 @item @code{x} @tab Equivialent to @code{X}, but only for pointers.
12241 @end multitable
12243 @anchor{loongarchOperandmodifiers}
12244 @subsubsection LoongArch Operand Modifiers
12246 The list below describes the supported modifiers and their effects for LoongArch.
12248 @multitable @columnfractions .10 .90
12249 @headitem Modifier @tab Description
12250 @item @code{d} @tab Same as @code{c}.
12251 @item @code{i} @tab Print the character ''@code{i}'' if the operand is not a register.
12252 @item @code{m} @tab Same as @code{c}, but the printed value is @code{operand - 1}.
12253 @item @code{u} @tab Print a LASX register.
12254 @item @code{w} @tab Print a LSX register.
12255 @item @code{X} @tab Print a constant integer operand in hexadecimal.
12256 @item @code{z} @tab Print the operand in its unmodified form, followed by a comma.
12257 @end multitable
12259 References to input and output operands in the assembler template of extended
12260 asm statements can use modifiers to affect the way the operands are formatted
12261 in the code output to the assembler.  For example, the following code uses the
12262 'w' modifier for LoongArch:
12264 @example
12265 test-asm.c:
12267 #include <lsxintrin.h>
12269 __m128i foo (void)
12271 __m128i  a,b,c;
12272 __asm__ ("vadd.d %w0,%w1,%w2\n\t"
12273    :"=f" (c)
12274    :"f" (a),"f" (b));
12276 return c;
12279 @end example
12281 @noindent
12282 The compile command for the test case is as follows:
12284 @example
12285 gcc test-asm.c -mlsx -S -o test-asm.s
12286 @end example
12288 @noindent
12289 The assembly statement produces the following assembly code:
12291 @example
12292 vadd.d $vr0,$vr0,$vr1
12293 @end example
12295 This is a 128-bit vector addition instruction, @code{c} (referred to in the
12296 template string as %0) is the output, and @code{a} (%1) and @code{b} (%2) are
12297 the inputs.  @code{__m128i} is a vector data type defined in the  file
12298 @code{lsxintrin.h} (@xref{LoongArch SX Vector Intrinsics}).  The symbol '=f'
12299 represents a constraint using a floating-point register as an output type, and
12300 the 'f' in the input operand represents a constraint using a floating-point
12301 register operand, which can refer to the definition of a constraint
12302 (@xref{Constraints}) in gcc.
12304 @anchor{riscvOperandmodifiers}
12305 @subsubsection RISC-V Operand Modifiers
12307 The list below describes the supported modifiers and their effects for RISC-V.
12309 @multitable @columnfractions .10 .90
12310 @headitem Modifier @tab Description
12311 @item @code{z} @tab Print ''@code{zero}'' instead of 0 if the operand is an immediate with a value of zero.
12312 @item @code{i} @tab Print the character ''@code{i}'' if the operand is an immediate.
12313 @end multitable
12315 @lowersections
12316 @include md.texi
12317 @raisesections
12319 @node Asm Labels
12320 @subsection Controlling Names Used in Assembler Code
12321 @cindex assembler names for identifiers
12322 @cindex names used in assembler code
12323 @cindex identifiers, names in assembler code
12325 You can specify the name to be used in the assembler code for a C
12326 function or variable by writing the @code{asm} (or @code{__asm__})
12327 keyword after the declarator.
12328 It is up to you to make sure that the assembler names you choose do not
12329 conflict with any other assembler symbols, or reference registers.
12331 @subsubheading Assembler names for data
12333 This sample shows how to specify the assembler name for data:
12335 @smallexample
12336 int foo asm ("myfoo") = 2;
12337 @end smallexample
12339 @noindent
12340 This specifies that the name to be used for the variable @code{foo} in
12341 the assembler code should be @samp{myfoo} rather than the usual
12342 @samp{_foo}.
12344 On systems where an underscore is normally prepended to the name of a C
12345 variable, this feature allows you to define names for the
12346 linker that do not start with an underscore.
12348 GCC does not support using this feature with a non-static local variable 
12349 since such variables do not have assembler names.  If you are
12350 trying to put the variable in a particular register, see 
12351 @ref{Explicit Register Variables}.
12353 @subsubheading Assembler names for functions
12355 To specify the assembler name for functions, write a declaration for the 
12356 function before its definition and put @code{asm} there, like this:
12358 @smallexample
12359 int func (int x, int y) asm ("MYFUNC");
12360      
12361 int func (int x, int y)
12363    /* @r{@dots{}} */
12364 @end smallexample
12366 @noindent
12367 This specifies that the name to be used for the function @code{func} in
12368 the assembler code should be @code{MYFUNC}.
12370 @node Explicit Register Variables
12371 @subsection Variables in Specified Registers
12372 @anchor{Explicit Reg Vars}
12373 @cindex explicit register variables
12374 @cindex variables in specified registers
12375 @cindex specified registers
12377 GNU C allows you to associate specific hardware registers with C 
12378 variables.  In almost all cases, allowing the compiler to assign
12379 registers produces the best code.  However under certain unusual
12380 circumstances, more precise control over the variable storage is 
12381 required.
12383 Both global and local variables can be associated with a register.  The
12384 consequences of performing this association are very different between
12385 the two, as explained in the sections below.
12387 @menu
12388 * Global Register Variables::   Variables declared at global scope.
12389 * Local Register Variables::    Variables declared within a function.
12390 @end menu
12392 @node Global Register Variables
12393 @subsubsection Defining Global Register Variables
12394 @anchor{Global Reg Vars}
12395 @cindex global register variables
12396 @cindex registers, global variables in
12397 @cindex registers, global allocation
12399 You can define a global register variable and associate it with a specified 
12400 register like this:
12402 @smallexample
12403 register int *foo asm ("r12");
12404 @end smallexample
12406 @noindent
12407 Here @code{r12} is the name of the register that should be used. Note that 
12408 this is the same syntax used for defining local register variables, but for 
12409 a global variable the declaration appears outside a function. The 
12410 @code{register} keyword is required, and cannot be combined with 
12411 @code{static}. The register name must be a valid register name for the
12412 target platform.
12414 Do not use type qualifiers such as @code{const} and @code{volatile}, as
12415 the outcome may be contrary to expectations.  In  particular, using the
12416 @code{volatile} qualifier does not fully prevent the compiler from
12417 optimizing accesses to the register.
12419 Registers are a scarce resource on most systems and allowing the 
12420 compiler to manage their usage usually results in the best code. However, 
12421 under special circumstances it can make sense to reserve some globally.
12422 For example this may be useful in programs such as programming language 
12423 interpreters that have a couple of global variables that are accessed 
12424 very often.
12426 After defining a global register variable, for the current compilation
12427 unit:
12429 @itemize @bullet
12430 @item If the register is a call-saved register, call ABI is affected:
12431 the register will not be restored in function epilogue sequences after
12432 the variable has been assigned.  Therefore, functions cannot safely
12433 return to callers that assume standard ABI.
12434 @item Conversely, if the register is a call-clobbered register, making
12435 calls to functions that use standard ABI may lose contents of the variable.
12436 Such calls may be created by the compiler even if none are evident in
12437 the original program, for example when libgcc functions are used to
12438 make up for unavailable instructions.
12439 @item Accesses to the variable may be optimized as usual and the register
12440 remains available for allocation and use in any computations, provided that
12441 observable values of the variable are not affected.
12442 @item If the variable is referenced in inline assembly, the type of access
12443 must be provided to the compiler via constraints (@pxref{Constraints}).
12444 Accesses from basic asms are not supported.
12445 @end itemize
12447 Note that these points @emph{only} apply to code that is compiled with the
12448 definition. The behavior of code that is merely linked in (for example 
12449 code from libraries) is not affected.
12451 If you want to recompile source files that do not actually use your global 
12452 register variable so they do not use the specified register for any other 
12453 purpose, you need not actually add the global register declaration to 
12454 their source code. It suffices to specify the compiler option 
12455 @option{-ffixed-@var{reg}} (@pxref{Code Gen Options}) to reserve the 
12456 register.
12458 @subsubheading Declaring the variable
12460 Global register variables cannot have initial values, because an
12461 executable file has no means to supply initial contents for a register.
12463 When selecting a register, choose one that is normally saved and 
12464 restored by function calls on your machine. This ensures that code
12465 which is unaware of this reservation (such as library routines) will 
12466 restore it before returning.
12468 On machines with register windows, be sure to choose a global
12469 register that is not affected magically by the function call mechanism.
12471 @subsubheading Using the variable
12473 @cindex @code{qsort}, and global register variables
12474 When calling routines that are not aware of the reservation, be 
12475 cautious if those routines call back into code which uses them. As an 
12476 example, if you call the system library version of @code{qsort}, it may 
12477 clobber your registers during execution, but (if you have selected 
12478 appropriate registers) it will restore them before returning. However 
12479 it will @emph{not} restore them before calling @code{qsort}'s comparison 
12480 function. As a result, global values will not reliably be available to 
12481 the comparison function unless the @code{qsort} function itself is rebuilt.
12483 Similarly, it is not safe to access the global register variables from signal
12484 handlers or from more than one thread of control. Unless you recompile 
12485 them specially for the task at hand, the system library routines may 
12486 temporarily use the register for other things.  Furthermore, since the register
12487 is not reserved exclusively for the variable, accessing it from handlers of
12488 asynchronous signals may observe unrelated temporary values residing in the
12489 register.
12491 @cindex register variable after @code{longjmp}
12492 @cindex global register after @code{longjmp}
12493 @cindex value after @code{longjmp}
12494 @findex longjmp
12495 @findex setjmp
12496 On most machines, @code{longjmp} restores to each global register
12497 variable the value it had at the time of the @code{setjmp}. On some
12498 machines, however, @code{longjmp} does not change the value of global
12499 register variables. To be portable, the function that called @code{setjmp}
12500 should make other arrangements to save the values of the global register
12501 variables, and to restore them in a @code{longjmp}. This way, the same
12502 thing happens regardless of what @code{longjmp} does.
12504 @node Local Register Variables
12505 @subsubsection Specifying Registers for Local Variables
12506 @anchor{Local Reg Vars}
12507 @cindex local variables, specifying registers
12508 @cindex specifying registers for local variables
12509 @cindex registers for local variables
12511 You can define a local register variable and associate it with a specified 
12512 register like this:
12514 @smallexample
12515 register int *foo asm ("r12");
12516 @end smallexample
12518 @noindent
12519 Here @code{r12} is the name of the register that should be used.  Note
12520 that this is the same syntax used for defining global register variables, 
12521 but for a local variable the declaration appears within a function.  The 
12522 @code{register} keyword is required, and cannot be combined with 
12523 @code{static}.  The register name must be a valid register name for the
12524 target platform.
12526 Do not use type qualifiers such as @code{const} and @code{volatile}, as
12527 the outcome may be contrary to expectations. In particular, when the
12528 @code{const} qualifier is used, the compiler may substitute the
12529 variable with its initializer in @code{asm} statements, which may cause
12530 the corresponding operand to appear in a different register.
12532 As with global register variables, it is recommended that you choose 
12533 a register that is normally saved and restored by function calls on your 
12534 machine, so that calls to library routines will not clobber it.
12536 The only supported use for this feature is to specify registers
12537 for input and output operands when calling Extended @code{asm} 
12538 (@pxref{Extended Asm}).  This may be necessary if the constraints for a 
12539 particular machine don't provide sufficient control to select the desired 
12540 register.  To force an operand into a register, create a local variable 
12541 and specify the register name after the variable's declaration.  Then use 
12542 the local variable for the @code{asm} operand and specify any constraint 
12543 letter that matches the register:
12545 @smallexample
12546 register int *p1 asm ("r0") = @dots{};
12547 register int *p2 asm ("r1") = @dots{};
12548 register int *result asm ("r0");
12549 asm ("sysint" : "=r" (result) : "0" (p1), "r" (p2));
12550 @end smallexample
12552 @emph{Warning:} In the above example, be aware that a register (for example 
12553 @code{r0}) can be call-clobbered by subsequent code, including function 
12554 calls and library calls for arithmetic operators on other variables (for 
12555 example the initialization of @code{p2}).  In this case, use temporary 
12556 variables for expressions between the register assignments:
12558 @smallexample
12559 int t1 = @dots{};
12560 register int *p1 asm ("r0") = @dots{};
12561 register int *p2 asm ("r1") = t1;
12562 register int *result asm ("r0");
12563 asm ("sysint" : "=r" (result) : "0" (p1), "r" (p2));
12564 @end smallexample
12566 Defining a register variable does not reserve the register.  Other than
12567 when invoking the Extended @code{asm}, the contents of the specified 
12568 register are not guaranteed.  For this reason, the following uses 
12569 are explicitly @emph{not} supported.  If they appear to work, it is only 
12570 happenstance, and may stop working as intended due to (seemingly) 
12571 unrelated changes in surrounding code, or even minor changes in the 
12572 optimization of a future version of gcc:
12574 @itemize @bullet
12575 @item Passing parameters to or from Basic @code{asm}
12576 @item Passing parameters to or from Extended @code{asm} without using input 
12577 or output operands.
12578 @item Passing parameters to or from routines written in assembler (or
12579 other languages) using non-standard calling conventions.
12580 @end itemize
12582 Some developers use Local Register Variables in an attempt to improve 
12583 gcc's allocation of registers, especially in large functions.  In this 
12584 case the register name is essentially a hint to the register allocator.
12585 While in some instances this can generate better code, improvements are
12586 subject to the whims of the allocator/optimizers.  Since there are no
12587 guarantees that your improvements won't be lost, this usage of Local
12588 Register Variables is discouraged.
12590 On the MIPS platform, there is related use for local register variables 
12591 with slightly different characteristics (@pxref{MIPS Coprocessors,, 
12592 Defining coprocessor specifics for MIPS targets, gccint, 
12593 GNU Compiler Collection (GCC) Internals}).
12595 @node Size of an asm
12596 @subsection Size of an @code{asm}
12598 Some targets require that GCC track the size of each instruction used
12599 in order to generate correct code.  Because the final length of the
12600 code produced by an @code{asm} statement is only known by the
12601 assembler, GCC must make an estimate as to how big it will be.  It
12602 does this by counting the number of instructions in the pattern of the
12603 @code{asm} and multiplying that by the length of the longest
12604 instruction supported by that processor.  (When working out the number
12605 of instructions, it assumes that any occurrence of a newline or of
12606 whatever statement separator character is supported by the assembler ---
12607 typically @samp{;} --- indicates the end of an instruction.)
12609 Normally, GCC's estimate is adequate to ensure that correct
12610 code is generated, but it is possible to confuse the compiler if you use
12611 pseudo instructions or assembler macros that expand into multiple real
12612 instructions, or if you use assembler directives that expand to more
12613 space in the object file than is needed for a single instruction.
12614 If this happens then the assembler may produce a diagnostic saying that
12615 a label is unreachable.
12617 @cindex @code{asm inline}
12618 This size is also used for inlining decisions.  If you use @code{asm inline}
12619 instead of just @code{asm}, then for inlining purposes the size of the asm
12620 is taken as the minimum size, ignoring how many instructions GCC thinks it is.
12622 @node Alternate Keywords
12623 @section Alternate Keywords
12624 @cindex alternate keywords
12625 @cindex keywords, alternate
12627 @option{-ansi} and the various @option{-std} options disable certain
12628 keywords.  This causes trouble when you want to use GNU C extensions, or
12629 a general-purpose header file that should be usable by all programs,
12630 including ISO C programs.  The keywords @code{asm}, @code{typeof} and
12631 @code{inline} are not available in programs compiled with
12632 @option{-ansi} or @option{-std} (although @code{inline} can be used in a
12633 program compiled with @option{-std=c99} or a later standard).  The
12634 ISO C99 keyword
12635 @code{restrict} is only available when @option{-std=gnu99} (which will
12636 eventually be the default) or @option{-std=c99} (or the equivalent
12637 @option{-std=iso9899:1999}), or an option for a later standard
12638 version, is used.
12640 The way to solve these problems is to put @samp{__} at the beginning and
12641 end of each problematical keyword.  For example, use @code{__asm__}
12642 instead of @code{asm}, and @code{__inline__} instead of @code{inline}.
12644 Other C compilers won't accept these alternative keywords; if you want to
12645 compile with another compiler, you can define the alternate keywords as
12646 macros to replace them with the customary keywords.  It looks like this:
12648 @smallexample
12649 #ifndef __GNUC__
12650 #define __asm__ asm
12651 #endif
12652 @end smallexample
12654 @findex __extension__
12655 @opindex pedantic
12656 @option{-pedantic} and other options cause warnings for many GNU C extensions.
12657 You can suppress such warnings using the keyword @code{__extension__}.
12658 Specifically:
12660 @itemize @bullet
12661 @item
12662 Writing @code{__extension__} before an expression prevents warnings
12663 about extensions within that expression.
12665 @item
12666 In C, writing:
12668 @smallexample
12669 [[__extension__ @dots{}]]
12670 @end smallexample
12672 suppresses warnings about using @samp{[[]]} attributes in C versions
12673 that predate C23@.
12674 @end itemize
12676 @code{__extension__} has no effect aside from this.
12678 @node Incomplete Enums
12679 @section Incomplete @code{enum} Types
12681 You can define an @code{enum} tag without specifying its possible values.
12682 This results in an incomplete type, much like what you get if you write
12683 @code{struct foo} without describing the elements.  A later declaration
12684 that does specify the possible values completes the type.
12686 You cannot allocate variables or storage using the type while it is
12687 incomplete.  However, you can work with pointers to that type.
12689 This extension may not be very useful, but it makes the handling of
12690 @code{enum} more consistent with the way @code{struct} and @code{union}
12691 are handled.
12693 This extension is not supported by GNU C++.
12695 @node Function Names
12696 @section Function Names as Strings
12697 @cindex @code{__func__} identifier
12698 @cindex @code{__FUNCTION__} identifier
12699 @cindex @code{__PRETTY_FUNCTION__} identifier
12701 GCC provides three magic constants that hold the name of the current
12702 function as a string.  In C++11 and later modes, all three are treated
12703 as constant expressions and can be used in @code{constexpr} constexts.
12704 The first of these constants is @code{__func__}, which is part of
12705 the C99 standard:
12707 The identifier @code{__func__} is implicitly declared by the translator
12708 as if, immediately following the opening brace of each function
12709 definition, the declaration
12711 @smallexample
12712 static const char __func__[] = "function-name";
12713 @end smallexample
12715 @noindent
12716 appeared, where function-name is the name of the lexically-enclosing
12717 function.  This name is the unadorned name of the function.  As an
12718 extension, at file (or, in C++, namespace scope), @code{__func__}
12719 evaluates to the empty string.
12721 @code{__FUNCTION__} is another name for @code{__func__}, provided for
12722 backward compatibility with old versions of GCC.
12724 In C, @code{__PRETTY_FUNCTION__} is yet another name for
12725 @code{__func__}, except that at file scope (or, in C++, namespace scope),
12726 it evaluates to the string @code{"top level"}.  In addition, in C++,
12727 @code{__PRETTY_FUNCTION__} contains the signature of the function as
12728 well as its bare name.  For example, this program:
12730 @smallexample
12731 extern "C" int printf (const char *, ...);
12733 class a @{
12734  public:
12735   void sub (int i)
12736     @{
12737       printf ("__FUNCTION__ = %s\n", __FUNCTION__);
12738       printf ("__PRETTY_FUNCTION__ = %s\n", __PRETTY_FUNCTION__);
12739     @}
12743 main (void)
12745   a ax;
12746   ax.sub (0);
12747   return 0;
12749 @end smallexample
12751 @noindent
12752 gives this output:
12754 @smallexample
12755 __FUNCTION__ = sub
12756 __PRETTY_FUNCTION__ = void a::sub(int)
12757 @end smallexample
12759 These identifiers are variables, not preprocessor macros, and may not
12760 be used to initialize @code{char} arrays or be concatenated with string
12761 literals.
12763 @node Return Address
12764 @section Getting the Return or Frame Address of a Function
12766 These functions may be used to get information about the callers of a
12767 function.
12769 @defbuiltin{{void *} __builtin_return_address (unsigned int @var{level})}
12770 This function returns the return address of the current function, or of
12771 one of its callers.  The @var{level} argument is number of frames to
12772 scan up the call stack.  A value of @code{0} yields the return address
12773 of the current function, a value of @code{1} yields the return address
12774 of the caller of the current function, and so forth.  When inlining
12775 the expected behavior is that the function returns the address of
12776 the function that is returned to.  To work around this behavior use
12777 the @code{noinline} function attribute.
12779 The @var{level} argument must be a constant integer.
12781 On some machines it may be impossible to determine the return address of
12782 any function other than the current one; in such cases, or when the top
12783 of the stack has been reached, this function returns an unspecified
12784 value.  In addition, @code{__builtin_frame_address} may be used
12785 to determine if the top of the stack has been reached.
12787 Additional post-processing of the returned value may be needed, see
12788 @code{__builtin_extract_return_addr}.
12790 The stored representation of the return address in memory may be different
12791 from the address returned by @code{__builtin_return_address}.  For example,
12792 on AArch64 the stored address may be mangled with return address signing
12793 whereas the address returned by @code{__builtin_return_address} is not.
12795 Calling this function with a nonzero argument can have unpredictable
12796 effects, including crashing the calling program.  As a result, calls
12797 that are considered unsafe are diagnosed when the @option{-Wframe-address}
12798 option is in effect.  Such calls should only be made in debugging
12799 situations.
12801 On targets where code addresses are representable as @code{void *},
12802 @smallexample
12803 void *addr = __builtin_extract_return_addr (__builtin_return_address (0));
12804 @end smallexample
12805 gives the code address where the current function would return.  For example,
12806 such an address may be used with @code{dladdr} or other interfaces that work
12807 with code addresses.
12808 @enddefbuiltin
12810 @defbuiltin{{void *} __builtin_extract_return_addr (void *@var{addr})}
12811 The address as returned by @code{__builtin_return_address} may have to be fed
12812 through this function to get the actual encoded address.  For example, on the
12813 31-bit S/390 platform the highest bit has to be masked out, or on SPARC
12814 platforms an offset has to be added for the true next instruction to be
12815 executed.
12817 If no fixup is needed, this function simply passes through @var{addr}.
12818 @enddefbuiltin
12820 @defbuiltin{{void *} __builtin_frob_return_addr (void *@var{addr})}
12821 This function does the reverse of @code{__builtin_extract_return_addr}.
12822 @enddefbuiltin
12824 @defbuiltin{{void *} __builtin_frame_address (unsigned int @var{level})}
12825 This function is similar to @code{__builtin_return_address}, but it
12826 returns the address of the function frame rather than the return address
12827 of the function.  Calling @code{__builtin_frame_address} with a value of
12828 @code{0} yields the frame address of the current function, a value of
12829 @code{1} yields the frame address of the caller of the current function,
12830 and so forth.
12832 The frame is the area on the stack that holds local variables and saved
12833 registers.  The frame address is normally the address of the first word
12834 pushed on to the stack by the function.  However, the exact definition
12835 depends upon the processor and the calling convention.  If the processor
12836 has a dedicated frame pointer register, and the function has a frame,
12837 then @code{__builtin_frame_address} returns the value of the frame
12838 pointer register.
12840 On some machines it may be impossible to determine the frame address of
12841 any function other than the current one; in such cases, or when the top
12842 of the stack has been reached, this function returns @code{0} if
12843 the first frame pointer is properly initialized by the startup code.
12845 Calling this function with a nonzero argument can have unpredictable
12846 effects, including crashing the calling program.  As a result, calls
12847 that are considered unsafe are diagnosed when the @option{-Wframe-address}
12848 option is in effect.  Such calls should only be made in debugging
12849 situations.
12850 @enddefbuiltin
12852 @deftypefn {Built-in Function} {void *} __builtin_stack_address ()
12853 This function returns the stack pointer register, offset by
12854 @code{STACK_ADDRESS_OFFSET} if that's defined.
12856 Conceptually, the returned address returned by this built-in function is
12857 the boundary between the stack area allocated for use by its caller, and
12858 the area that could be modified by a function call, that the caller
12859 could safely zero-out before or after (but not during) the call
12860 sequence.
12862 Arguments for a callee may be preallocated as part of the caller's stack
12863 frame, or allocated on a per-call basis, depending on the target, so
12864 they may be on either side of this boundary.
12866 Even if the stack pointer is biased, the result is not.  The register
12867 save area on SPARC is regarded as modifiable by calls, rather than as
12868 allocated for use by the caller function, since it is never in use while
12869 the caller function itself is running.
12871 Red zones that only leaf functions could use are also regarded as
12872 modifiable by calls, rather than as allocated for use by the caller.
12873 This is only theoretical, since leaf functions do not issue calls, but a
12874 constant offset makes this built-in function more predictable.
12875 @end deftypefn
12877 @node Stack Scrubbing
12878 @section Stack scrubbing internal interfaces
12880 Stack scrubbing involves cooperation between a @code{strub} context,
12881 i.e., a function whose stack frame is to be zeroed-out, and its callers.
12882 The caller initializes a stack watermark, the @code{strub} context
12883 updates the watermark according to its stack use, and the caller zeroes
12884 it out once it regains control, whether by the callee's returning or by
12885 an exception.
12887 Each of these steps is performed by a different builtin function call.
12888 Calls to these builtins are introduced automatically, in response to
12889 @code{strub} attributes and command-line options; they are not expected
12890 to be explicitly called by source code.
12892 The functions that implement the builtins are available in libgcc but,
12893 depending on optimization levels, they are expanded internally, adjusted
12894 to account for inlining, and sometimes combined/deferred (e.g. passing
12895 the caller-supplied watermark on to callees, refraining from erasing
12896 stack areas that the caller will) to enable tail calls and to optimize
12897 for code size.
12899 @deftypefn {Built-in Function} {void} __builtin___strub_enter (void **@var{wmptr})
12900 This function initializes a stack @var{watermark} variable with the
12901 current top of the stack.  A call to this builtin function is introduced
12902 before entering a @code{strub} context.  It remains as a function call
12903 if optimization is not enabled.
12904 @end deftypefn
12906 @deftypefn {Built-in Function} {void} __builtin___strub_update (void **@var{wmptr})
12907 This function updates a stack @var{watermark} variable with the current
12908 top of the stack, if it tops the previous watermark.  A call to this
12909 builtin function is inserted within @code{strub} contexts, whenever
12910 additional stack space may have been used.  It remains as a function
12911 call at optimization levels lower than 2.
12912 @end deftypefn
12914 @deftypefn {Built-in Function} {void} __builtin___strub_leave (void **@var{wmptr})
12915 This function overwrites the memory area between the current top of the
12916 stack, and the @var{watermark}ed address.  A call to this builtin
12917 function is inserted after leaving a @code{strub} context.  It remains
12918 as a function call at optimization levels lower than 3, and it is guarded by
12919 a condition at level 2.
12920 @end deftypefn
12922 @node Vector Extensions
12923 @section Using Vector Instructions through Built-in Functions
12925 On some targets, the instruction set contains SIMD vector instructions which
12926 operate on multiple values contained in one large register at the same time.
12927 For example, on the x86 the MMX, 3DNow!@: and SSE extensions can be used
12928 this way.
12930 The first step in using these extensions is to provide the necessary data
12931 types.  This should be done using an appropriate @code{typedef}:
12933 @smallexample
12934 typedef int v4si __attribute__ ((vector_size (16)));
12935 @end smallexample
12937 @noindent
12938 The @code{int} type specifies the @dfn{base type} (which can be a
12939 @code{typedef}), while the attribute specifies the vector size for the
12940 variable, measured in bytes. For example, the declaration above causes
12941 the compiler to set the mode for the @code{v4si} type to be 16 bytes wide
12942 and divided into @code{int} sized units.  For a 32-bit @code{int} this
12943 means a vector of 4 units of 4 bytes, and the corresponding mode of
12944 @code{foo} is @acronym{V4SI}.
12946 The @code{vector_size} attribute is only applicable to integral and
12947 floating scalars, although arrays, pointers, and function return values
12948 are allowed in conjunction with this construct. Only sizes that are
12949 positive power-of-two multiples of the base type size are currently allowed.
12951 All the basic integer types can be used as base types, both as signed
12952 and as unsigned: @code{char}, @code{short}, @code{int}, @code{long},
12953 @code{long long}.  In addition, @code{float} and @code{double} can be
12954 used to build floating-point vector types.
12956 Specifying a combination that is not valid for the current architecture
12957 causes GCC to synthesize the instructions using a narrower mode.
12958 For example, if you specify a variable of type @code{V4SI} and your
12959 architecture does not allow for this specific SIMD type, GCC
12960 produces code that uses 4 @code{SIs}.
12962 The types defined in this manner can be used with a subset of normal C
12963 operations.  Currently, GCC allows using the following operators
12964 on these types: @code{+, -, *, /, unary minus, ^, |, &, ~, %}@.
12966 The operations behave like C++ @code{valarrays}.  Addition is defined as
12967 the addition of the corresponding elements of the operands.  For
12968 example, in the code below, each of the 4 elements in @var{a} is
12969 added to the corresponding 4 elements in @var{b} and the resulting
12970 vector is stored in @var{c}.
12972 @smallexample
12973 typedef int v4si __attribute__ ((vector_size (16)));
12975 v4si a, b, c;
12977 c = a + b;
12978 @end smallexample
12980 Subtraction, multiplication, division, and the logical operations
12981 operate in a similar manner.  Likewise, the result of using the unary
12982 minus or complement operators on a vector type is a vector whose
12983 elements are the negative or complemented values of the corresponding
12984 elements in the operand.
12986 It is possible to use shifting operators @code{<<}, @code{>>} on
12987 integer-type vectors. The operation is defined as following: @code{@{a0,
12988 a1, @dots{}, an@} >> @{b0, b1, @dots{}, bn@} == @{a0 >> b0, a1 >> b1,
12989 @dots{}, an >> bn@}}@.  Unlike OpenCL, values of @code{b} are not
12990 implicitly taken modulo bit width of the base type @code{B}, and the behavior
12991 is undefined if any @code{bi} is greater than or equal to @code{B}.
12993 In contrast to scalar operations in C and C++, operands of integer vector
12994 operations do not undergo integer promotions.
12996 Operands of binary vector operations must have the same number of
12997 elements. 
12999 For convenience, it is allowed to use a binary vector operation
13000 where one operand is a scalar. In that case the compiler transforms
13001 the scalar operand into a vector where each element is the scalar from
13002 the operation. The transformation happens only if the scalar could be
13003 safely converted to the vector-element type.
13004 Consider the following code.
13006 @smallexample
13007 typedef int v4si __attribute__ ((vector_size (16)));
13009 v4si a, b, c;
13010 long l;
13012 a = b + 1;    /* a = b + @{1,1,1,1@}; */
13013 a = 2 * b;    /* a = @{2,2,2,2@} * b; */
13015 a = l + a;    /* Error, cannot convert long to int. */
13016 @end smallexample
13018 Vectors can be subscripted as if the vector were an array with
13019 the same number of elements and base type.  Out of bound accesses
13020 invoke undefined behavior at run time.  Warnings for out of bound
13021 accesses for vector subscription can be enabled with
13022 @option{-Warray-bounds}.
13024 Vector comparison is supported with standard comparison
13025 operators: @code{==, !=, <, <=, >, >=}. Comparison operands can be
13026 vector expressions of integer-type or real-type. Comparison between
13027 integer-type vectors and real-type vectors are not supported.  The
13028 result of the comparison is a vector of the same width and number of
13029 elements as the comparison operands with a signed integral element
13030 type.
13032 Vectors are compared element-wise producing 0 when comparison is false
13033 and -1 (constant of the appropriate type where all bits are set)
13034 otherwise. Consider the following example.
13036 @smallexample
13037 typedef int v4si __attribute__ ((vector_size (16)));
13039 v4si a = @{1,2,3,4@};
13040 v4si b = @{3,2,1,4@};
13041 v4si c;
13043 c = a >  b;     /* The result would be @{0, 0,-1, 0@}  */
13044 c = a == b;     /* The result would be @{0,-1, 0,-1@}  */
13045 @end smallexample
13047 In C++, the ternary operator @code{?:} is available. @code{a?b:c}, where
13048 @code{b} and @code{c} are vectors of the same type and @code{a} is an
13049 integer vector with the same number of elements of the same size as @code{b}
13050 and @code{c}, computes all three arguments and creates a vector
13051 @code{@{a[0]?b[0]:c[0], a[1]?b[1]:c[1], @dots{}@}}.  Note that unlike in
13052 OpenCL, @code{a} is thus interpreted as @code{a != 0} and not @code{a < 0}.
13053 As in the case of binary operations, this syntax is also accepted when
13054 one of @code{b} or @code{c} is a scalar that is then transformed into a
13055 vector. If both @code{b} and @code{c} are scalars and the type of
13056 @code{true?b:c} has the same size as the element type of @code{a}, then
13057 @code{b} and @code{c} are converted to a vector type whose elements have
13058 this type and with the same number of elements as @code{a}.
13060 In C++, the logic operators @code{!, &&, ||} are available for vectors.
13061 @code{!v} is equivalent to @code{v == 0}, @code{a && b} is equivalent to
13062 @code{a!=0 & b!=0} and @code{a || b} is equivalent to @code{a!=0 | b!=0}.
13063 For mixed operations between a scalar @code{s} and a vector @code{v},
13064 @code{s && v} is equivalent to @code{s?v!=0:0} (the evaluation is
13065 short-circuit) and @code{v && s} is equivalent to @code{v!=0 & (s?-1:0)}.
13067 @findex __builtin_shuffle
13068 Vector shuffling is available using functions
13069 @code{__builtin_shuffle (vec, mask)} and
13070 @code{__builtin_shuffle (vec0, vec1, mask)}.
13071 Both functions construct a permutation of elements from one or two
13072 vectors and return a vector of the same type as the input vector(s).
13073 The @var{mask} is an integral vector with the same width (@var{W})
13074 and element count (@var{N}) as the output vector.
13076 The elements of the input vectors are numbered in memory ordering of
13077 @var{vec0} beginning at 0 and @var{vec1} beginning at @var{N}.  The
13078 elements of @var{mask} are considered modulo @var{N} in the single-operand
13079 case and modulo @math{2*@var{N}} in the two-operand case.
13081 Consider the following example,
13083 @smallexample
13084 typedef int v4si __attribute__ ((vector_size (16)));
13086 v4si a = @{1,2,3,4@};
13087 v4si b = @{5,6,7,8@};
13088 v4si mask1 = @{0,1,1,3@};
13089 v4si mask2 = @{0,4,2,5@};
13090 v4si res;
13092 res = __builtin_shuffle (a, mask1);       /* res is @{1,2,2,4@}  */
13093 res = __builtin_shuffle (a, b, mask2);    /* res is @{1,5,3,6@}  */
13094 @end smallexample
13096 Note that @code{__builtin_shuffle} is intentionally semantically
13097 compatible with the OpenCL @code{shuffle} and @code{shuffle2} functions.
13099 You can declare variables and use them in function calls and returns, as
13100 well as in assignments and some casts.  You can specify a vector type as
13101 a return type for a function.  Vector types can also be used as function
13102 arguments.  It is possible to cast from one vector type to another,
13103 provided they are of the same size (in fact, you can also cast vectors
13104 to and from other datatypes of the same size).
13106 You cannot operate between vectors of different lengths or different
13107 signedness without a cast.
13109 @findex __builtin_shufflevector
13110 Vector shuffling is available using the
13111 @code{__builtin_shufflevector (vec1, vec2, index...)}
13112 function.  @var{vec1} and @var{vec2} must be expressions with
13113 vector type with a compatible element type.  The result of
13114 @code{__builtin_shufflevector} is a vector with the same element type
13115 as @var{vec1} and @var{vec2} but that has an element count equal to
13116 the number of indices specified.
13118 The @var{index} arguments are a list of integers that specify the
13119 elements indices of the first two vectors that should be extracted and
13120 returned in a new vector. These element indices are numbered sequentially
13121 starting with the first vector, continuing into the second vector.
13122 An index of -1 can be used to indicate that the corresponding element in
13123 the returned vector is a don't care and can be freely chosen to optimized
13124 the generated code sequence performing the shuffle operation.
13126 Consider the following example,
13127 @smallexample
13128 typedef int v4si __attribute__ ((vector_size (16)));
13129 typedef int v8si __attribute__ ((vector_size (32)));
13131 v8si a = @{1,-2,3,-4,5,-6,7,-8@};
13132 v4si b = __builtin_shufflevector (a, a, 0, 2, 4, 6); /* b is @{1,3,5,7@} */
13133 v4si c = @{-2,-4,-6,-8@};
13134 v8si d = __builtin_shufflevector (c, b, 4, 0, 5, 1, 6, 2, 7, 3); /* d is a */
13135 @end smallexample
13137 @findex __builtin_convertvector
13138 Vector conversion is available using the
13139 @code{__builtin_convertvector (vec, vectype)}
13140 function.  @var{vec} must be an expression with integral or floating
13141 vector type and @var{vectype} an integral or floating vector type with the
13142 same number of elements.  The result has @var{vectype} type and value of
13143 a C cast of every element of @var{vec} to the element type of @var{vectype}.
13145 Consider the following example,
13146 @smallexample
13147 typedef int v4si __attribute__ ((vector_size (16)));
13148 typedef float v4sf __attribute__ ((vector_size (16)));
13149 typedef double v4df __attribute__ ((vector_size (32)));
13150 typedef unsigned long long v4di __attribute__ ((vector_size (32)));
13152 v4si a = @{1,-2,3,-4@};
13153 v4sf b = @{1.5f,-2.5f,3.f,7.f@};
13154 v4di c = @{1ULL,5ULL,0ULL,10ULL@};
13155 v4sf d = __builtin_convertvector (a, v4sf); /* d is @{1.f,-2.f,3.f,-4.f@} */
13156 /* Equivalent of:
13157    v4sf d = @{ (float)a[0], (float)a[1], (float)a[2], (float)a[3] @}; */
13158 v4df e = __builtin_convertvector (a, v4df); /* e is @{1.,-2.,3.,-4.@} */
13159 v4df f = __builtin_convertvector (b, v4df); /* f is @{1.5,-2.5,3.,7.@} */
13160 v4si g = __builtin_convertvector (f, v4si); /* g is @{1,-2,3,7@} */
13161 v4si h = __builtin_convertvector (c, v4si); /* h is @{1,5,0,10@} */
13162 @end smallexample
13164 @cindex vector types, using with x86 intrinsics
13165 Sometimes it is desirable to write code using a mix of generic vector
13166 operations (for clarity) and machine-specific vector intrinsics (to
13167 access vector instructions that are not exposed via generic built-ins).
13168 On x86, intrinsic functions for integer vectors typically use the same
13169 vector type @code{__m128i} irrespective of how they interpret the vector,
13170 making it necessary to cast their arguments and return values from/to
13171 other vector types.  In C, you can make use of a @code{union} type:
13172 @c In C++ such type punning via a union is not allowed by the language
13173 @smallexample
13174 #include <immintrin.h>
13176 typedef unsigned char u8x16 __attribute__ ((vector_size (16)));
13177 typedef unsigned int  u32x4 __attribute__ ((vector_size (16)));
13179 typedef union @{
13180         __m128i mm;
13181         u8x16   u8;
13182         u32x4   u32;
13183 @} v128;
13184 @end smallexample
13186 @noindent
13187 for variables that can be used with both built-in operators and x86
13188 intrinsics:
13190 @smallexample
13191 v128 x, y = @{ 0 @};
13192 memcpy (&x, ptr, sizeof x);
13193 y.u8  += 0x80;
13194 x.mm  = _mm_adds_epu8 (x.mm, y.mm);
13195 x.u32 &= 0xffffff;
13197 /* Instead of a variable, a compound literal may be used to pass the
13198    return value of an intrinsic call to a function expecting the union: */
13199 v128 foo (v128);
13200 x = foo ((v128) @{_mm_adds_epu8 (x.mm, y.mm)@});
13201 @c This could be done implicitly with __attribute__((transparent_union)),
13202 @c but GCC does not accept it for unions of vector types (PR 88955).
13203 @end smallexample
13205 @node Offsetof
13206 @section Support for @code{offsetof}
13207 @findex __builtin_offsetof
13209 GCC implements for both C and C++ a syntactic extension to implement
13210 the @code{offsetof} macro.
13212 @smallexample
13213 primary:
13214         "__builtin_offsetof" "(" @code{typename} "," offsetof_member_designator ")"
13216 offsetof_member_designator:
13217           @code{identifier}
13218         | offsetof_member_designator "." @code{identifier}
13219         | offsetof_member_designator "[" @code{expr} "]"
13220 @end smallexample
13222 This extension is sufficient such that
13224 @smallexample
13225 #define offsetof(@var{type}, @var{member})  __builtin_offsetof (@var{type}, @var{member})
13226 @end smallexample
13228 @noindent
13229 is a suitable definition of the @code{offsetof} macro.  In C++, @var{type}
13230 may be dependent.  In either case, @var{member} may consist of a single
13231 identifier, or a sequence of member accesses and array references.
13233 @node __sync Builtins
13234 @section Legacy @code{__sync} Built-in Functions for Atomic Memory Access
13236 The following built-in functions
13237 are intended to be compatible with those described
13238 in the @cite{Intel Itanium Processor-specific Application Binary Interface},
13239 section 7.4.  As such, they depart from normal GCC practice by not using
13240 the @samp{__builtin_} prefix and also by being overloaded so that they
13241 work on multiple types.
13243 The definition given in the Intel documentation allows only for the use of
13244 the types @code{int}, @code{long}, @code{long long} or their unsigned
13245 counterparts.  GCC allows any scalar type that is 1, 2, 4 or 8 bytes in
13246 size other than the C type @code{_Bool} or the C++ type @code{bool}.
13247 Operations on pointer arguments are performed as if the operands were
13248 of the @code{uintptr_t} type.  That is, they are not scaled by the size
13249 of the type to which the pointer points.
13251 These functions are implemented in terms of the @samp{__atomic}
13252 builtins (@pxref{__atomic Builtins}).  They should not be used for new
13253 code which should use the @samp{__atomic} builtins instead.
13255 Not all operations are supported by all target processors.  If a particular
13256 operation cannot be implemented on the target processor, a warning is
13257 generated and a call to an external function is generated.  The external
13258 function carries the same name as the built-in version,
13259 with an additional suffix
13260 @samp{_@var{n}} where @var{n} is the size of the data type.
13262 @c ??? Should we have a mechanism to suppress this warning?  This is almost
13263 @c useful for implementing the operation under the control of an external
13264 @c mutex.
13266 In most cases, these built-in functions are considered a @dfn{full barrier}.
13267 That is,
13268 no memory operand is moved across the operation, either forward or
13269 backward.  Further, instructions are issued as necessary to prevent the
13270 processor from speculating loads across the operation and from queuing stores
13271 after the operation.
13273 All of the routines are described in the Intel documentation to take
13274 ``an optional list of variables protected by the memory barrier''.  It's
13275 not clear what is meant by that; it could mean that @emph{only} the
13276 listed variables are protected, or it could mean a list of additional
13277 variables to be protected.  The list is ignored by GCC which treats it as
13278 empty.  GCC interprets an empty list as meaning that all globally
13279 accessible variables should be protected.
13281 @defbuiltin{@var{type} __sync_fetch_and_add (@var{type} *@var{ptr}, @var{type} @var{value}, ...)}
13282 @defbuiltinx{@var{type} __sync_fetch_and_sub (@var{type} *@var{ptr}, @var{type} @var{value}, ...)}
13283 @defbuiltinx{@var{type} __sync_fetch_and_or (@var{type} *@var{ptr}, @var{type} @var{value}, ...)}
13284 @defbuiltinx{@var{type} __sync_fetch_and_and (@var{type} *@var{ptr}, @var{type} @var{value}, ...)}
13285 @defbuiltinx{@var{type} __sync_fetch_and_xor (@var{type} *@var{ptr}, @var{type} @var{value}, ...)}
13286 @defbuiltinx{@var{type} __sync_fetch_and_nand (@var{type} *@var{ptr}, @var{type} @var{value}, ...)}
13287 These built-in functions perform the operation suggested by the name, and
13288 returns the value that had previously been in memory.  That is, operations
13289 on integer operands have the following semantics.  Operations on pointer
13290 arguments are performed as if the operands were of the @code{uintptr_t}
13291 type.  That is, they are not scaled by the size of the type to which
13292 the pointer points.
13294 @smallexample
13295 @{ tmp = *ptr; *ptr @var{op}= value; return tmp; @}
13296 @{ tmp = *ptr; *ptr = ~(tmp & value); return tmp; @}   // nand
13297 @end smallexample
13299 The object pointed to by the first argument must be of integer or pointer
13300 type.  It must not be a boolean type.
13302 @emph{Note:} GCC 4.4 and later implement @code{__sync_fetch_and_nand}
13303 as @code{*ptr = ~(tmp & value)} instead of @code{*ptr = ~tmp & value}.
13304 @enddefbuiltin
13306 @defbuiltin{@var{type} __sync_add_and_fetch (@var{type} *@var{ptr}, @
13307                                              @var{type} @var{value}, ...)}
13308 @defbuiltinx{@var{type} __sync_sub_and_fetch (@var{type} *@var{ptr}, @var{type} @var{value}, ...)}
13309 @defbuiltinx{@var{type} __sync_or_and_fetch (@var{type} *@var{ptr}, @var{type} @var{value}, ...)}
13310 @defbuiltinx{@var{type} __sync_and_and_fetch (@var{type} *@var{ptr}, @var{type} @var{value}, ...)}
13311 @defbuiltinx{@var{type} __sync_xor_and_fetch (@var{type} *@var{ptr}, @var{type} @var{value}, ...)}
13312 @defbuiltinx{@var{type} __sync_nand_and_fetch (@var{type} *@var{ptr}, @var{type} @var{value}, ...)}
13313 These built-in functions perform the operation suggested by the name, and
13314 return the new value.  That is, operations on integer operands have
13315 the following semantics.  Operations on pointer operands are performed as
13316 if the operand's type were @code{uintptr_t}.
13318 @smallexample
13319 @{ *ptr @var{op}= value; return *ptr; @}
13320 @{ *ptr = ~(*ptr & value); return *ptr; @}   // nand
13321 @end smallexample
13323 The same constraints on arguments apply as for the corresponding
13324 @code{__sync_op_and_fetch} built-in functions.
13326 @emph{Note:} GCC 4.4 and later implement @code{__sync_nand_and_fetch}
13327 as @code{*ptr = ~(*ptr & value)} instead of
13328 @code{*ptr = ~*ptr & value}.
13329 @enddefbuiltin
13331 @defbuiltin{bool __sync_bool_compare_and_swap (@var{type} *@var{ptr}, @var{type} @var{oldval}, @var{type} @var{newval}, ...)}
13332 @defbuiltinx{@var{type} __sync_val_compare_and_swap (@var{type} *@var{ptr}, @var{type} @var{oldval}, @var{type} @var{newval}, ...)}
13333 These built-in functions perform an atomic compare and swap.
13334 That is, if the current
13335 value of @code{*@var{ptr}} is @var{oldval}, then write @var{newval} into
13336 @code{*@var{ptr}}.
13338 The ``bool'' version returns @code{true} if the comparison is successful and
13339 @var{newval} is written.  The ``val'' version returns the contents
13340 of @code{*@var{ptr}} before the operation.
13341 @enddefbuiltin
13343 @defbuiltin{void __sync_synchronize (...)}
13344 This built-in function issues a full memory barrier.
13345 @enddefbuiltin
13347 @defbuiltin{@var{type} __sync_lock_test_and_set (@var{type} *@var{ptr}, @var{type} @var{value}, ...)}
13348 This built-in function, as described by Intel, is not a traditional test-and-set
13349 operation, but rather an atomic exchange operation.  It writes @var{value}
13350 into @code{*@var{ptr}}, and returns the previous contents of
13351 @code{*@var{ptr}}.
13353 Many targets have only minimal support for such locks, and do not support
13354 a full exchange operation.  In this case, a target may support reduced
13355 functionality here by which the @emph{only} valid value to store is the
13356 immediate constant 1.  The exact value actually stored in @code{*@var{ptr}}
13357 is implementation defined.
13359 This built-in function is not a full barrier,
13360 but rather an @dfn{acquire barrier}.
13361 This means that references after the operation cannot move to (or be
13362 speculated to) before the operation, but previous memory stores may not
13363 be globally visible yet, and previous memory loads may not yet be
13364 satisfied.
13365 @enddefbuiltin
13367 @defbuiltin{void __sync_lock_release (@var{type} *@var{ptr}, ...)}
13368 This built-in function releases the lock acquired by
13369 @code{__sync_lock_test_and_set}.
13370 Normally this means writing the constant 0 to @code{*@var{ptr}}.
13372 This built-in function is not a full barrier,
13373 but rather a @dfn{release barrier}.
13374 This means that all previous memory stores are globally visible, and all
13375 previous memory loads have been satisfied, but following memory reads
13376 are not prevented from being speculated to before the barrier.
13377 @enddefbuiltin
13379 @node __atomic Builtins
13380 @section Built-in Functions for Memory Model Aware Atomic Operations
13382 The following built-in functions approximately match the requirements
13383 for the C++11 memory model.  They are all
13384 identified by being prefixed with @samp{__atomic} and most are
13385 overloaded so that they work with multiple types.
13387 These functions are intended to replace the legacy @samp{__sync}
13388 builtins.  The main difference is that the memory order that is requested
13389 is a parameter to the functions.  New code should always use the
13390 @samp{__atomic} builtins rather than the @samp{__sync} builtins.
13392 Note that the @samp{__atomic} builtins assume that programs will
13393 conform to the C++11 memory model.  In particular, they assume
13394 that programs are free of data races.  See the C++11 standard for
13395 detailed requirements.
13397 The @samp{__atomic} builtins can be used with any integral scalar or
13398 pointer type that is 1, 2, 4, or 8 bytes in length.  16-byte integral
13399 types are also allowed if @samp{__int128} (@pxref{__int128}) is
13400 supported by the architecture.
13402 The four non-arithmetic functions (load, store, exchange, and 
13403 compare_exchange) all have a generic version as well.  This generic
13404 version works on any data type.  It uses the lock-free built-in function
13405 if the specific data type size makes that possible; otherwise, an
13406 external call is left to be resolved at run time.  This external call is
13407 the same format with the addition of a @samp{size_t} parameter inserted
13408 as the first parameter indicating the size of the object being pointed to.
13409 All objects must be the same size.
13411 There are 6 different memory orders that can be specified.  These map
13412 to the C++11 memory orders with the same names, see the C++11 standard
13413 or the @uref{https://gcc.gnu.org/wiki/Atomic/GCCMM/AtomicSync,GCC wiki
13414 on atomic synchronization} for detailed definitions.  Individual
13415 targets may also support additional memory orders for use on specific
13416 architectures.  Refer to the target documentation for details of
13417 these.
13419 An atomic operation can both constrain code motion and
13420 be mapped to hardware instructions for synchronization between threads
13421 (e.g., a fence).  To which extent this happens is controlled by the
13422 memory orders, which are listed here in approximately ascending order of
13423 strength.  The description of each memory order is only meant to roughly
13424 illustrate the effects and is not a specification; see the C++11
13425 memory model for precise semantics.
13427 @table  @code
13428 @item __ATOMIC_RELAXED
13429 Implies no inter-thread ordering constraints.
13430 @item __ATOMIC_CONSUME
13431 This is currently implemented using the stronger @code{__ATOMIC_ACQUIRE}
13432 memory order because of a deficiency in C++11's semantics for
13433 @code{memory_order_consume}.
13434 @item __ATOMIC_ACQUIRE
13435 Creates an inter-thread happens-before constraint from the release (or
13436 stronger) semantic store to this acquire load.  Can prevent hoisting
13437 of code to before the operation.
13438 @item __ATOMIC_RELEASE
13439 Creates an inter-thread happens-before constraint to acquire (or stronger)
13440 semantic loads that read from this release store.  Can prevent sinking
13441 of code to after the operation.
13442 @item __ATOMIC_ACQ_REL
13443 Combines the effects of both @code{__ATOMIC_ACQUIRE} and
13444 @code{__ATOMIC_RELEASE}.
13445 @item __ATOMIC_SEQ_CST
13446 Enforces total ordering with all other @code{__ATOMIC_SEQ_CST} operations.
13447 @end table
13449 Note that in the C++11 memory model, @emph{fences} (e.g.,
13450 @samp{__atomic_thread_fence}) take effect in combination with other
13451 atomic operations on specific memory locations (e.g., atomic loads);
13452 operations on specific memory locations do not necessarily affect other
13453 operations in the same way.
13455 Target architectures are encouraged to provide their own patterns for
13456 each of the atomic built-in functions.  If no target is provided, the original
13457 non-memory model set of @samp{__sync} atomic built-in functions are
13458 used, along with any required synchronization fences surrounding it in
13459 order to achieve the proper behavior.  Execution in this case is subject
13460 to the same restrictions as those built-in functions.
13462 If there is no pattern or mechanism to provide a lock-free instruction
13463 sequence, a call is made to an external routine with the same parameters
13464 to be resolved at run time.
13466 When implementing patterns for these built-in functions, the memory order
13467 parameter can be ignored as long as the pattern implements the most
13468 restrictive @code{__ATOMIC_SEQ_CST} memory order.  Any of the other memory
13469 orders execute correctly with this memory order but they may not execute as
13470 efficiently as they could with a more appropriate implementation of the
13471 relaxed requirements.
13473 Note that the C++11 standard allows for the memory order parameter to be
13474 determined at run time rather than at compile time.  These built-in
13475 functions map any run-time value to @code{__ATOMIC_SEQ_CST} rather
13476 than invoke a runtime library call or inline a switch statement.  This is
13477 standard compliant, safe, and the simplest approach for now.
13479 The memory order parameter is a signed int, but only the lower 16 bits are
13480 reserved for the memory order.  The remainder of the signed int is reserved
13481 for target use and should be 0.  Use of the predefined atomic values
13482 ensures proper usage.
13484 @defbuiltin{@var{type} __atomic_load_n (@var{type} *@var{ptr}, int @var{memorder})}
13485 This built-in function implements an atomic load operation.  It returns the
13486 contents of @code{*@var{ptr}}.
13488 The valid memory order variants are
13489 @code{__ATOMIC_RELAXED}, @code{__ATOMIC_SEQ_CST}, @code{__ATOMIC_ACQUIRE},
13490 and @code{__ATOMIC_CONSUME}.
13492 @enddefbuiltin
13494 @defbuiltin{void __atomic_load (@var{type} *@var{ptr}, @var{type} *@var{ret}, int @var{memorder})}
13495 This is the generic version of an atomic load.  It returns the
13496 contents of @code{*@var{ptr}} in @code{*@var{ret}}.
13498 @enddefbuiltin
13500 @defbuiltin{void __atomic_store_n (@var{type} *@var{ptr}, @var{type} @var{val}, int @var{memorder})}
13501 This built-in function implements an atomic store operation.  It writes 
13502 @code{@var{val}} into @code{*@var{ptr}}.  
13504 The valid memory order variants are
13505 @code{__ATOMIC_RELAXED}, @code{__ATOMIC_SEQ_CST}, and @code{__ATOMIC_RELEASE}.
13507 @enddefbuiltin
13509 @defbuiltin{void __atomic_store (@var{type} *@var{ptr}, @var{type} *@var{val}, int @var{memorder})}
13510 This is the generic version of an atomic store.  It stores the value
13511 of @code{*@var{val}} into @code{*@var{ptr}}.
13513 @enddefbuiltin
13515 @defbuiltin{@var{type} __atomic_exchange_n (@var{type} *@var{ptr}, @var{type} @var{val}, int @var{memorder})}
13516 This built-in function implements an atomic exchange operation.  It writes
13517 @var{val} into @code{*@var{ptr}}, and returns the previous contents of
13518 @code{*@var{ptr}}.
13520 All memory order variants are valid.
13522 @enddefbuiltin
13524 @defbuiltin{void __atomic_exchange (@var{type} *@var{ptr}, @var{type} *@var{val}, @var{type} *@var{ret}, int @var{memorder})}
13525 This is the generic version of an atomic exchange.  It stores the
13526 contents of @code{*@var{val}} into @code{*@var{ptr}}. The original value
13527 of @code{*@var{ptr}} is copied into @code{*@var{ret}}.
13529 @enddefbuiltin
13531 @defbuiltin{bool __atomic_compare_exchange_n (@var{type} *@var{ptr}, @var{type} *@var{expected}, @var{type} @var{desired}, bool @var{weak}, int @var{success_memorder}, int @var{failure_memorder})}
13532 This built-in function implements an atomic compare and exchange operation.
13533 This compares the contents of @code{*@var{ptr}} with the contents of
13534 @code{*@var{expected}}. If equal, the operation is a @emph{read-modify-write}
13535 operation that writes @var{desired} into @code{*@var{ptr}}.  If they are not
13536 equal, the operation is a @emph{read} and the current contents of
13537 @code{*@var{ptr}} are written into @code{*@var{expected}}.  @var{weak} is @code{true}
13538 for weak compare_exchange, which may fail spuriously, and @code{false} for
13539 the strong variation, which never fails spuriously.  Many targets
13540 only offer the strong variation and ignore the parameter.  When in doubt, use
13541 the strong variation.
13543 If @var{desired} is written into @code{*@var{ptr}} then @code{true} is returned
13544 and memory is affected according to the
13545 memory order specified by @var{success_memorder}.  There are no
13546 restrictions on what memory order can be used here.
13548 Otherwise, @code{false} is returned and memory is affected according
13549 to @var{failure_memorder}. This memory order cannot be
13550 @code{__ATOMIC_RELEASE} nor @code{__ATOMIC_ACQ_REL}.  It also cannot be a
13551 stronger order than that specified by @var{success_memorder}.
13553 @enddefbuiltin
13555 @defbuiltin{bool __atomic_compare_exchange (@var{type} *@var{ptr}, @var{type} *@var{expected}, @var{type} *@var{desired}, bool @var{weak}, int @var{success_memorder}, int @var{failure_memorder})}
13556 This built-in function implements the generic version of
13557 @code{__atomic_compare_exchange}.  The function is virtually identical to
13558 @code{__atomic_compare_exchange_n}, except the desired value is also a
13559 pointer.
13561 @enddefbuiltin
13563 @defbuiltin{@var{type} __atomic_add_fetch (@var{type} *@var{ptr}, @var{type} @var{val}, int @var{memorder})}
13564 @defbuiltinx{@var{type} __atomic_sub_fetch (@var{type} *@var{ptr}, @var{type} @var{val}, int @var{memorder})}
13565 @defbuiltinx{@var{type} __atomic_and_fetch (@var{type} *@var{ptr}, @var{type} @var{val}, int @var{memorder})}
13566 @defbuiltinx{@var{type} __atomic_xor_fetch (@var{type} *@var{ptr}, @var{type} @var{val}, int @var{memorder})}
13567 @defbuiltinx{@var{type} __atomic_or_fetch (@var{type} *@var{ptr}, @var{type} @var{val}, int @var{memorder})}
13568 @defbuiltinx{@var{type} __atomic_nand_fetch (@var{type} *@var{ptr}, @var{type} @var{val}, int @var{memorder})}
13569 These built-in functions perform the operation suggested by the name, and
13570 return the result of the operation.  Operations on pointer arguments are
13571 performed as if the operands were of the @code{uintptr_t} type.  That is,
13572 they are not scaled by the size of the type to which the pointer points.
13574 @smallexample
13575 @{ *ptr @var{op}= val; return *ptr; @}
13576 @{ *ptr = ~(*ptr & val); return *ptr; @} // nand
13577 @end smallexample
13579 The object pointed to by the first argument must be of integer or pointer
13580 type.  It must not be a boolean type.  All memory orders are valid.
13582 @enddefbuiltin
13584 @defbuiltin{@var{type} __atomic_fetch_add (@var{type} *@var{ptr}, @var{type} @var{val}, int @var{memorder})}
13585 @defbuiltinx{@var{type} __atomic_fetch_sub (@var{type} *@var{ptr}, @var{type} @var{val}, int @var{memorder})}
13586 @defbuiltinx{@var{type} __atomic_fetch_and (@var{type} *@var{ptr}, @var{type} @var{val}, int @var{memorder})}
13587 @defbuiltinx{@var{type} __atomic_fetch_xor (@var{type} *@var{ptr}, @var{type} @var{val}, int @var{memorder})}
13588 @defbuiltinx{@var{type} __atomic_fetch_or (@var{type} *@var{ptr}, @var{type} @var{val}, int @var{memorder})}
13589 @defbuiltinx{@var{type} __atomic_fetch_nand (@var{type} *@var{ptr}, @var{type} @var{val}, int @var{memorder})}
13590 These built-in functions perform the operation suggested by the name, and
13591 return the value that had previously been in @code{*@var{ptr}}.  Operations
13592 on pointer arguments are performed as if the operands were of
13593 the @code{uintptr_t} type.  That is, they are not scaled by the size of
13594 the type to which the pointer points.
13596 @smallexample
13597 @{ tmp = *ptr; *ptr @var{op}= val; return tmp; @}
13598 @{ tmp = *ptr; *ptr = ~(*ptr & val); return tmp; @} // nand
13599 @end smallexample
13601 The same constraints on arguments apply as for the corresponding
13602 @code{__atomic_op_fetch} built-in functions.  All memory orders are valid.
13604 @enddefbuiltin
13606 @defbuiltin{bool __atomic_test_and_set (void *@var{ptr}, int @var{memorder})}
13608 This built-in function performs an atomic test-and-set operation on
13609 the byte at @code{*@var{ptr}}.  The byte is set to some implementation
13610 defined nonzero ``set'' value and the return value is @code{true} if and only
13611 if the previous contents were ``set''.
13612 It should be only used for operands of type @code{bool} or @code{char}. For 
13613 other types only part of the value may be set.
13615 All memory orders are valid.
13617 @enddefbuiltin
13619 @defbuiltin{void __atomic_clear (bool *@var{ptr}, int @var{memorder})}
13621 This built-in function performs an atomic clear operation on
13622 @code{*@var{ptr}}.  After the operation, @code{*@var{ptr}} contains 0.
13623 It should be only used for operands of type @code{bool} or @code{char} and 
13624 in conjunction with @code{__atomic_test_and_set}.
13625 For other types it may only clear partially. If the type is not @code{bool}
13626 prefer using @code{__atomic_store}.
13628 The valid memory order variants are
13629 @code{__ATOMIC_RELAXED}, @code{__ATOMIC_SEQ_CST}, and
13630 @code{__ATOMIC_RELEASE}.
13632 @enddefbuiltin
13634 @defbuiltin{void __atomic_thread_fence (int @var{memorder})}
13636 This built-in function acts as a synchronization fence between threads
13637 based on the specified memory order.
13639 All memory orders are valid.
13641 @enddefbuiltin
13643 @defbuiltin{void __atomic_signal_fence (int @var{memorder})}
13645 This built-in function acts as a synchronization fence between a thread
13646 and signal handlers based in the same thread.
13648 All memory orders are valid.
13650 @enddefbuiltin
13652 @defbuiltin{bool __atomic_always_lock_free (size_t @var{size},  void *@var{ptr})}
13654 This built-in function returns @code{true} if objects of @var{size} bytes always
13655 generate lock-free atomic instructions for the target architecture.
13656 @var{size} must resolve to a compile-time constant and the result also
13657 resolves to a compile-time constant.
13659 @var{ptr} is an optional pointer to the object that may be used to determine
13660 alignment.  A value of 0 indicates typical alignment should be used.  The 
13661 compiler may also ignore this parameter.
13663 @smallexample
13664 if (__atomic_always_lock_free (sizeof (long long), 0))
13665 @end smallexample
13667 @enddefbuiltin
13669 @defbuiltin{bool __atomic_is_lock_free (size_t @var{size}, void *@var{ptr})}
13671 This built-in function returns @code{true} if objects of @var{size} bytes always
13672 generate lock-free atomic instructions for the target architecture.  If
13673 the built-in function is not known to be lock-free, a call is made to a
13674 runtime routine named @code{__atomic_is_lock_free}.
13676 @var{ptr} is an optional pointer to the object that may be used to determine
13677 alignment.  A value of 0 indicates typical alignment should be used.  The 
13678 compiler may also ignore this parameter.
13679 @enddefbuiltin
13681 @node Integer Overflow Builtins
13682 @section Built-in Functions to Perform Arithmetic with Overflow Checking
13684 The following built-in functions allow performing simple arithmetic operations
13685 together with checking whether the operations overflowed.
13687 @defbuiltin{bool __builtin_add_overflow (@var{type1} @var{a}, @var{type2} @var{b}, @var{type3} *@var{res})}
13688 @defbuiltinx{bool __builtin_sadd_overflow (int @var{a}, int @var{b}, int *@var{res})}
13689 @defbuiltinx{bool __builtin_saddl_overflow (long int @var{a}, long int @var{b}, long int *@var{res})}
13690 @defbuiltinx{bool __builtin_saddll_overflow (long long int @var{a}, long long int @var{b}, long long int *@var{res})}
13691 @defbuiltinx{bool __builtin_uadd_overflow (unsigned int @var{a}, unsigned int @var{b}, unsigned int *@var{res})}
13692 @defbuiltinx{bool __builtin_uaddl_overflow (unsigned long int @var{a}, unsigned long int @var{b}, unsigned long int *@var{res})}
13693 @defbuiltinx{bool __builtin_uaddll_overflow (unsigned long long int @var{a}, unsigned long long int @var{b}, unsigned long long int *@var{res})}
13695 These built-in functions promote the first two operands into infinite precision signed
13696 type and perform addition on those promoted operands.  The result is then
13697 cast to the type the third pointer argument points to and stored there.
13698 If the stored result is equal to the infinite precision result, the built-in
13699 functions return @code{false}, otherwise they return @code{true}.  As the addition is
13700 performed in infinite signed precision, these built-in functions have fully defined
13701 behavior for all argument values.
13703 The first built-in function allows arbitrary integral types for operands and
13704 the result type must be pointer to some integral type other than enumerated or
13705 boolean type, the rest of the built-in functions have explicit integer types.
13707 The compiler will attempt to use hardware instructions to implement
13708 these built-in functions where possible, like conditional jump on overflow
13709 after addition, conditional jump on carry etc.
13711 @enddefbuiltin
13713 @defbuiltin{bool __builtin_sub_overflow (@var{type1} @var{a}, @var{type2} @var{b}, @var{type3} *@var{res})}
13714 @defbuiltinx{bool __builtin_ssub_overflow (int @var{a}, int @var{b}, int *@var{res})}
13715 @defbuiltinx{bool __builtin_ssubl_overflow (long int @var{a}, long int @var{b}, long int *@var{res})}
13716 @defbuiltinx{bool __builtin_ssubll_overflow (long long int @var{a}, long long int @var{b}, long long int *@var{res})}
13717 @defbuiltinx{bool __builtin_usub_overflow (unsigned int @var{a}, unsigned int @var{b}, unsigned int *@var{res})}
13718 @defbuiltinx{bool __builtin_usubl_overflow (unsigned long int @var{a}, unsigned long int @var{b}, unsigned long int *@var{res})}
13719 @defbuiltinx{bool __builtin_usubll_overflow (unsigned long long int @var{a}, unsigned long long int @var{b}, unsigned long long int *@var{res})}
13721 These built-in functions are similar to the add overflow checking built-in
13722 functions above, except they perform subtraction, subtract the second argument
13723 from the first one, instead of addition.
13725 @enddefbuiltin
13727 @defbuiltin{bool __builtin_mul_overflow (@var{type1} @var{a}, @var{type2} @var{b}, @var{type3} *@var{res})}
13728 @defbuiltinx{bool __builtin_smul_overflow (int @var{a}, int @var{b}, int *@var{res})}
13729 @defbuiltinx{bool __builtin_smull_overflow (long int @var{a}, long int @var{b}, long int *@var{res})}
13730 @defbuiltinx{bool __builtin_smulll_overflow (long long int @var{a}, long long int @var{b}, long long int *@var{res})}
13731 @defbuiltinx{bool __builtin_umul_overflow (unsigned int @var{a}, unsigned int @var{b}, unsigned int *@var{res})}
13732 @defbuiltinx{bool __builtin_umull_overflow (unsigned long int @var{a}, unsigned long int @var{b}, unsigned long int *@var{res})}
13733 @defbuiltinx{bool __builtin_umulll_overflow (unsigned long long int @var{a}, unsigned long long int @var{b}, unsigned long long int *@var{res})}
13735 These built-in functions are similar to the add overflow checking built-in
13736 functions above, except they perform multiplication, instead of addition.
13738 @enddefbuiltin
13740 The following built-in functions allow checking if simple arithmetic operation
13741 would overflow.
13743 @defbuiltin{bool __builtin_add_overflow_p (@var{type1} @var{a}, @var{type2} @var{b}, @var{type3} @var{c})}
13744 @defbuiltinx{bool __builtin_sub_overflow_p (@var{type1} @var{a}, @var{type2} @var{b}, @var{type3} @var{c})}
13745 @defbuiltinx{bool __builtin_mul_overflow_p (@var{type1} @var{a}, @var{type2} @var{b}, @var{type3} @var{c})}
13747 These built-in functions are similar to @code{__builtin_add_overflow},
13748 @code{__builtin_sub_overflow}, or @code{__builtin_mul_overflow}, except that
13749 they don't store the result of the arithmetic operation anywhere and the
13750 last argument is not a pointer, but some expression with integral type other
13751 than enumerated or boolean type.
13753 The built-in functions promote the first two operands into infinite precision signed type
13754 and perform addition on those promoted operands. The result is then
13755 cast to the type of the third argument.  If the cast result is equal to the infinite
13756 precision result, the built-in functions return @code{false}, otherwise they return @code{true}.
13757 The value of the third argument is ignored, just the side effects in the third argument
13758 are evaluated, and no integral argument promotions are performed on the last argument.
13759 If the third argument is a bit-field, the type used for the result cast has the
13760 precision and signedness of the given bit-field, rather than precision and signedness
13761 of the underlying type.
13763 For example, the following macro can be used to portably check, at
13764 compile-time, whether or not adding two constant integers will overflow,
13765 and perform the addition only when it is known to be safe and not to trigger
13766 a @option{-Woverflow} warning.
13768 @smallexample
13769 #define INT_ADD_OVERFLOW_P(a, b) \
13770    __builtin_add_overflow_p (a, b, (__typeof__ ((a) + (b))) 0)
13772 enum @{
13773     A = INT_MAX, B = 3,
13774     C = INT_ADD_OVERFLOW_P (A, B) ? 0 : A + B,
13775     D = __builtin_add_overflow_p (1, SCHAR_MAX, (signed char) 0)
13777 @end smallexample
13779 The compiler will attempt to use hardware instructions to implement
13780 these built-in functions where possible, like conditional jump on overflow
13781 after addition, conditional jump on carry etc.
13783 @enddefbuiltin
13785 @defbuiltin{{unsigned int} __builtin_addc (unsigned int @var{a}, unsigned int @var{b}, unsigned int @var{carry_in}, unsigned int *@var{carry_out})}
13786 @defbuiltinx{{unsigned long int} __builtin_addcl (unsigned long int @var{a}, unsigned long int @var{b}, unsigned int @var{carry_in}, unsigned long int *@var{carry_out})}
13787 @defbuiltinx{{unsigned long long int} __builtin_addcll (unsigned long long int @var{a}, unsigned long long int @var{b}, unsigned long long int @var{carry_in}, unsigned long long int *@var{carry_out})}
13789 These built-in functions are equivalent to:
13790 @smallexample
13791   (@{ __typeof__ (@var{a}) s; \
13792       __typeof__ (@var{a}) c1 = __builtin_add_overflow (@var{a}, @var{b}, &s); \
13793       __typeof__ (@var{a}) c2 = __builtin_add_overflow (s, @var{carry_in}, &s); \
13794       *(@var{carry_out}) = c1 | c2; \
13795       s; @})
13796 @end smallexample
13798 i.e.@: they add 3 unsigned values, set what the last argument
13799 points to to 1 if any of the two additions overflowed (otherwise 0)
13800 and return the sum of those 3 unsigned values.  Note, while all
13801 the first 3 arguments can have arbitrary values, better code will be
13802 emitted if one of them (preferrably the third one) has only values
13803 0 or 1 (i.e.@: carry-in).
13805 @enddefbuiltin
13807 @defbuiltin{{unsigned int} __builtin_subc (unsigned int @var{a}, unsigned int @var{b}, unsigned int @var{carry_in}, unsigned int *@var{carry_out})}
13808 @defbuiltinx{{unsigned long int} __builtin_subcl (unsigned long int @var{a}, unsigned long int @var{b}, unsigned int @var{carry_in}, unsigned long int *@var{carry_out})}
13809 @defbuiltinx{{unsigned long long int} __builtin_subcll (unsigned long long int @var{a}, unsigned long long int @var{b}, unsigned long long int @var{carry_in}, unsigned long long int *@var{carry_out})}
13811 These built-in functions are equivalent to:
13812 @smallexample
13813   (@{ __typeof__ (@var{a}) s; \
13814       __typeof__ (@var{a}) c1 = __builtin_sub_overflow (@var{a}, @var{b}, &s); \
13815       __typeof__ (@var{a}) c2 = __builtin_sub_overflow (s, @var{carry_in}, &s); \
13816       *(@var{carry_out}) = c1 | c2; \
13817       s; @})
13818 @end smallexample
13820 i.e.@: they subtract 2 unsigned values from the first unsigned value,
13821 set what the last argument points to to 1 if any of the two subtractions
13822 overflowed (otherwise 0) and return the result of the subtractions.
13823 Note, while all the first 3 arguments can have arbitrary values, better code
13824 will be emitted if one of them (preferrably the third one) has only values
13825 0 or 1 (i.e.@: carry-in).
13827 @enddefbuiltin
13829 @node x86 specific memory model extensions for transactional memory
13830 @section x86-Specific Memory Model Extensions for Transactional Memory
13832 The x86 architecture supports additional memory ordering flags
13833 to mark critical sections for hardware lock elision. 
13834 These must be specified in addition to an existing memory order to
13835 atomic intrinsics.
13837 @table @code
13838 @item __ATOMIC_HLE_ACQUIRE
13839 Start lock elision on a lock variable.
13840 Memory order must be @code{__ATOMIC_ACQUIRE} or stronger.
13841 @item __ATOMIC_HLE_RELEASE
13842 End lock elision on a lock variable.
13843 Memory order must be @code{__ATOMIC_RELEASE} or stronger.
13844 @end table
13846 When a lock acquire fails, it is required for good performance to abort
13847 the transaction quickly. This can be done with a @code{_mm_pause}.
13849 @smallexample
13850 #include <immintrin.h> // For _mm_pause
13852 int lockvar;
13854 /* Acquire lock with lock elision */
13855 while (__atomic_exchange_n(&lockvar, 1, __ATOMIC_ACQUIRE|__ATOMIC_HLE_ACQUIRE))
13856     _mm_pause(); /* Abort failed transaction */
13858 /* Free lock with lock elision */
13859 __atomic_store_n(&lockvar, 0, __ATOMIC_RELEASE|__ATOMIC_HLE_RELEASE);
13860 @end smallexample
13862 @node Object Size Checking
13863 @section Object Size Checking
13865 @subsection Object Size Checking Built-in Functions
13866 @findex __builtin___memcpy_chk
13867 @findex __builtin___mempcpy_chk
13868 @findex __builtin___memmove_chk
13869 @findex __builtin___memset_chk
13870 @findex __builtin___strcpy_chk
13871 @findex __builtin___stpcpy_chk
13872 @findex __builtin___strncpy_chk
13873 @findex __builtin___strcat_chk
13874 @findex __builtin___strncat_chk
13876 GCC implements a limited buffer overflow protection mechanism that can
13877 prevent some buffer overflow attacks by determining the sizes of objects
13878 into which data is about to be written and preventing the writes when
13879 the size isn't sufficient.  The built-in functions described below yield
13880 the best results when used together and when optimization is enabled.
13881 For example, to detect object sizes across function boundaries or to
13882 follow pointer assignments through non-trivial control flow they rely
13883 on various optimization passes enabled with @option{-O2}.  However, to
13884 a limited extent, they can be used without optimization as well.
13886 @defbuiltin{size_t __builtin_object_size (const void * @var{ptr}, int @var{type})}
13887 is a built-in construct that returns a constant number of bytes from
13888 @var{ptr} to the end of the object @var{ptr} pointer points to
13889 (if known at compile time).  To determine the sizes of dynamically allocated
13890 objects the function relies on the allocation functions called to obtain
13891 the storage to be declared with the @code{alloc_size} attribute (@pxref{Common
13892 Function Attributes}).  @code{__builtin_object_size} never evaluates
13893 its arguments for side effects.  If there are any side effects in them, it
13894 returns @code{(size_t) -1} for @var{type} 0 or 1 and @code{(size_t) 0}
13895 for @var{type} 2 or 3.  If there are multiple objects @var{ptr} can
13896 point to and all of them are known at compile time, the returned number
13897 is the maximum of remaining byte counts in those objects if @var{type} & 2 is
13898 0 and minimum if nonzero.  If it is not possible to determine which objects
13899 @var{ptr} points to at compile time, @code{__builtin_object_size} should
13900 return @code{(size_t) -1} for @var{type} 0 or 1 and @code{(size_t) 0}
13901 for @var{type} 2 or 3.
13903 @var{type} is an integer constant from 0 to 3.  If the least significant
13904 bit is clear, objects are whole variables, if it is set, a closest
13905 surrounding subobject is considered the object a pointer points to.
13906 The second bit determines if maximum or minimum of remaining bytes
13907 is computed.
13909 @smallexample
13910 struct V @{ char buf1[10]; int b; char buf2[10]; @} var;
13911 char *p = &var.buf1[1], *q = &var.b;
13913 /* Here the object p points to is var.  */
13914 assert (__builtin_object_size (p, 0) == sizeof (var) - 1);
13915 /* The subobject p points to is var.buf1.  */
13916 assert (__builtin_object_size (p, 1) == sizeof (var.buf1) - 1);
13917 /* The object q points to is var.  */
13918 assert (__builtin_object_size (q, 0)
13919         == (char *) (&var + 1) - (char *) &var.b);
13920 /* The subobject q points to is var.b.  */
13921 assert (__builtin_object_size (q, 1) == sizeof (var.b));
13922 @end smallexample
13923 @enddefbuiltin
13925 @defbuiltin{{size_t} __builtin_dynamic_object_size (const void * @var{ptr}, int @var{type})}
13926 is similar to @code{__builtin_object_size} in that it returns a number of bytes
13927 from @var{ptr} to the end of the object @var{ptr} pointer points to, except
13928 that the size returned may not be a constant.  This results in successful
13929 evaluation of object size estimates in a wider range of use cases and can be
13930 more precise than @code{__builtin_object_size}, but it incurs a performance
13931 penalty since it may add a runtime overhead on size computation.  Semantics of
13932 @var{type} as well as return values in case it is not possible to determine
13933 which objects @var{ptr} points to at compile time are the same as in the case
13934 of @code{__builtin_object_size}.
13935 @enddefbuiltin
13937 @subsection Object Size Checking and Source Fortification
13939 Hardening of function calls using the @code{_FORTIFY_SOURCE} macro is
13940 one of the key uses of the object size checking built-in functions.  To
13941 make implementation of these features more convenient and improve
13942 optimization and diagnostics, there are built-in functions added for
13943 many common string operation functions, e.g., for @code{memcpy}
13944 @code{__builtin___memcpy_chk} built-in is provided.  This built-in has
13945 an additional last argument, which is the number of bytes remaining in
13946 the object the @var{dest} argument points to or @code{(size_t) -1} if
13947 the size is not known.
13949 The built-in functions are optimized into the normal string functions
13950 like @code{memcpy} if the last argument is @code{(size_t) -1} or if
13951 it is known at compile time that the destination object will not
13952 be overflowed.  If the compiler can determine at compile time that the
13953 object will always be overflowed, it issues a warning.
13955 The intended use can be e.g.@:
13957 @smallexample
13958 #undef memcpy
13959 #define bos0(dest) __builtin_object_size (dest, 0)
13960 #define memcpy(dest, src, n) \
13961   __builtin___memcpy_chk (dest, src, n, bos0 (dest))
13963 char *volatile p;
13964 char buf[10];
13965 /* It is unknown what object p points to, so this is optimized
13966    into plain memcpy - no checking is possible.  */
13967 memcpy (p, "abcde", n);
13968 /* Destination is known and length too.  It is known at compile
13969    time there will be no overflow.  */
13970 memcpy (&buf[5], "abcde", 5);
13971 /* Destination is known, but the length is not known at compile time.
13972    This will result in __memcpy_chk call that can check for overflow
13973    at run time.  */
13974 memcpy (&buf[5], "abcde", n);
13975 /* Destination is known and it is known at compile time there will
13976    be overflow.  There will be a warning and __memcpy_chk call that
13977    will abort the program at run time.  */
13978 memcpy (&buf[6], "abcde", 5);
13979 @end smallexample
13981 Such built-in functions are provided for @code{memcpy}, @code{mempcpy},
13982 @code{memmove}, @code{memset}, @code{strcpy}, @code{stpcpy}, @code{strncpy},
13983 @code{strcat} and @code{strncat}.
13985 @subsubsection Formatted Output Function Checking
13986 @defbuiltin{int __builtin___sprintf_chk @
13987             (char *@var{s}, int @var{flag}, size_t @var{os}, @
13988             const char *@var{fmt}, ...)}
13989 @defbuiltinx{int __builtin___snprintf_chk @
13990              (char *@var{s}, size_t @var{maxlen}, int @var{flag}, @
13991              size_t @var{os}, const char *@var{fmt}, ...)}
13992 @defbuiltinx{int __builtin___vsprintf_chk @
13993              (char *@var{s}, int @var{flag}, size_t @var{os}, @
13994              const char *@var{fmt}, va_list @var{ap})}
13995 @defbuiltinx{int __builtin___vsnprintf_chk @
13996              (char *@var{s}, size_t @var{maxlen}, int @var{flag}, @
13997              size_t @var{os}, const char *@var{fmt}, @
13998              va_list @var{ap})}
14000 The added @var{flag} argument is passed unchanged to @code{__sprintf_chk}
14001 etc.@: functions and can contain implementation specific flags on what
14002 additional security measures the checking function might take, such as
14003 handling @code{%n} differently.
14005 The @var{os} argument is the object size @var{s} points to, like in the
14006 other built-in functions.  There is a small difference in the behavior
14007 though, if @var{os} is @code{(size_t) -1}, the built-in functions are
14008 optimized into the non-checking functions only if @var{flag} is 0, otherwise
14009 the checking function is called with @var{os} argument set to
14010 @code{(size_t) -1}.
14012 In addition to this, there are checking built-in functions
14013 @code{__builtin___printf_chk}, @code{__builtin___vprintf_chk},
14014 @code{__builtin___fprintf_chk} and @code{__builtin___vfprintf_chk}.
14015 These have just one additional argument, @var{flag}, right before
14016 format string @var{fmt}.  If the compiler is able to optimize them to
14017 @code{fputc} etc.@: functions, it does, otherwise the checking function
14018 is called and the @var{flag} argument passed to it.
14019 @enddefbuiltin
14021 @node Other Builtins
14022 @section Other Built-in Functions Provided by GCC
14023 @cindex built-in functions
14024 @findex __builtin_iseqsig
14025 @findex __builtin_isfinite
14026 @findex __builtin_isnormal
14027 @findex __builtin_isgreater
14028 @findex __builtin_isgreaterequal
14029 @findex __builtin_isunordered
14030 @findex __builtin_speculation_safe_value
14031 @findex _Exit
14032 @findex _exit
14033 @findex abort
14034 @findex abs
14035 @findex acos
14036 @findex acosf
14037 @findex acosh
14038 @findex acoshf
14039 @findex acoshl
14040 @findex acosl
14041 @findex alloca
14042 @findex asin
14043 @findex asinf
14044 @findex asinh
14045 @findex asinhf
14046 @findex asinhl
14047 @findex asinl
14048 @findex atan
14049 @findex atan2
14050 @findex atan2f
14051 @findex atan2l
14052 @findex atanf
14053 @findex atanh
14054 @findex atanhf
14055 @findex atanhl
14056 @findex atanl
14057 @findex bcmp
14058 @findex bzero
14059 @findex cabs
14060 @findex cabsf
14061 @findex cabsl
14062 @findex cacos
14063 @findex cacosf
14064 @findex cacosh
14065 @findex cacoshf
14066 @findex cacoshl
14067 @findex cacosl
14068 @findex calloc
14069 @findex carg
14070 @findex cargf
14071 @findex cargl
14072 @findex casin
14073 @findex casinf
14074 @findex casinh
14075 @findex casinhf
14076 @findex casinhl
14077 @findex casinl
14078 @findex catan
14079 @findex catanf
14080 @findex catanh
14081 @findex catanhf
14082 @findex catanhl
14083 @findex catanl
14084 @findex cbrt
14085 @findex cbrtf
14086 @findex cbrtl
14087 @findex ccos
14088 @findex ccosf
14089 @findex ccosh
14090 @findex ccoshf
14091 @findex ccoshl
14092 @findex ccosl
14093 @findex ceil
14094 @findex ceilf
14095 @findex ceill
14096 @findex cexp
14097 @findex cexpf
14098 @findex cexpl
14099 @findex cimag
14100 @findex cimagf
14101 @findex cimagl
14102 @findex clog
14103 @findex clogf
14104 @findex clogl
14105 @findex clog10
14106 @findex clog10f
14107 @findex clog10l
14108 @findex conj
14109 @findex conjf
14110 @findex conjl
14111 @findex copysign
14112 @findex copysignf
14113 @findex copysignl
14114 @findex cos
14115 @findex cosf
14116 @findex cosh
14117 @findex coshf
14118 @findex coshl
14119 @findex cosl
14120 @findex cpow
14121 @findex cpowf
14122 @findex cpowl
14123 @findex cproj
14124 @findex cprojf
14125 @findex cprojl
14126 @findex creal
14127 @findex crealf
14128 @findex creall
14129 @findex csin
14130 @findex csinf
14131 @findex csinh
14132 @findex csinhf
14133 @findex csinhl
14134 @findex csinl
14135 @findex csqrt
14136 @findex csqrtf
14137 @findex csqrtl
14138 @findex ctan
14139 @findex ctanf
14140 @findex ctanh
14141 @findex ctanhf
14142 @findex ctanhl
14143 @findex ctanl
14144 @findex dcgettext
14145 @findex dgettext
14146 @findex drem
14147 @findex dremf
14148 @findex dreml
14149 @findex erf
14150 @findex erfc
14151 @findex erfcf
14152 @findex erfcl
14153 @findex erff
14154 @findex erfl
14155 @findex exit
14156 @findex exp
14157 @findex exp10
14158 @findex exp10f
14159 @findex exp10l
14160 @findex exp2
14161 @findex exp2f
14162 @findex exp2l
14163 @findex expf
14164 @findex expl
14165 @findex expm1
14166 @findex expm1f
14167 @findex expm1l
14168 @findex fabs
14169 @findex fabsf
14170 @findex fabsl
14171 @findex fdim
14172 @findex fdimf
14173 @findex fdiml
14174 @findex ffs
14175 @findex floor
14176 @findex floorf
14177 @findex floorl
14178 @findex fma
14179 @findex fmaf
14180 @findex fmal
14181 @findex fmax
14182 @findex fmaxf
14183 @findex fmaxl
14184 @findex fmin
14185 @findex fminf
14186 @findex fminl
14187 @findex fmod
14188 @findex fmodf
14189 @findex fmodl
14190 @findex fprintf
14191 @findex fprintf_unlocked
14192 @findex fputs
14193 @findex fputs_unlocked
14194 @findex free
14195 @findex frexp
14196 @findex frexpf
14197 @findex frexpl
14198 @findex fscanf
14199 @findex gamma
14200 @findex gammaf
14201 @findex gammal
14202 @findex gamma_r
14203 @findex gammaf_r
14204 @findex gammal_r
14205 @findex gettext
14206 @findex hypot
14207 @findex hypotf
14208 @findex hypotl
14209 @findex ilogb
14210 @findex ilogbf
14211 @findex ilogbl
14212 @findex imaxabs
14213 @findex index
14214 @findex isalnum
14215 @findex isalpha
14216 @findex isascii
14217 @findex isblank
14218 @findex iscntrl
14219 @findex isdigit
14220 @findex isgraph
14221 @findex islower
14222 @findex isprint
14223 @findex ispunct
14224 @findex isspace
14225 @findex isupper
14226 @findex iswalnum
14227 @findex iswalpha
14228 @findex iswblank
14229 @findex iswcntrl
14230 @findex iswdigit
14231 @findex iswgraph
14232 @findex iswlower
14233 @findex iswprint
14234 @findex iswpunct
14235 @findex iswspace
14236 @findex iswupper
14237 @findex iswxdigit
14238 @findex isxdigit
14239 @findex j0
14240 @findex j0f
14241 @findex j0l
14242 @findex j1
14243 @findex j1f
14244 @findex j1l
14245 @findex jn
14246 @findex jnf
14247 @findex jnl
14248 @findex labs
14249 @findex ldexp
14250 @findex ldexpf
14251 @findex ldexpl
14252 @findex lgamma
14253 @findex lgammaf
14254 @findex lgammal
14255 @findex lgamma_r
14256 @findex lgammaf_r
14257 @findex lgammal_r
14258 @findex llabs
14259 @findex llrint
14260 @findex llrintf
14261 @findex llrintl
14262 @findex llround
14263 @findex llroundf
14264 @findex llroundl
14265 @findex log
14266 @findex log10
14267 @findex log10f
14268 @findex log10l
14269 @findex log1p
14270 @findex log1pf
14271 @findex log1pl
14272 @findex log2
14273 @findex log2f
14274 @findex log2l
14275 @findex logb
14276 @findex logbf
14277 @findex logbl
14278 @findex logf
14279 @findex logl
14280 @findex lrint
14281 @findex lrintf
14282 @findex lrintl
14283 @findex lround
14284 @findex lroundf
14285 @findex lroundl
14286 @findex malloc
14287 @findex memchr
14288 @findex memcmp
14289 @findex memcpy
14290 @findex mempcpy
14291 @findex memset
14292 @findex modf
14293 @findex modff
14294 @findex modfl
14295 @findex nearbyint
14296 @findex nearbyintf
14297 @findex nearbyintl
14298 @findex nextafter
14299 @findex nextafterf
14300 @findex nextafterl
14301 @findex nexttoward
14302 @findex nexttowardf
14303 @findex nexttowardl
14304 @findex pow
14305 @findex pow10
14306 @findex pow10f
14307 @findex pow10l
14308 @findex powf
14309 @findex powl
14310 @findex printf
14311 @findex printf_unlocked
14312 @findex putchar
14313 @findex puts
14314 @findex realloc
14315 @findex remainder
14316 @findex remainderf
14317 @findex remainderl
14318 @findex remquo
14319 @findex remquof
14320 @findex remquol
14321 @findex rindex
14322 @findex rint
14323 @findex rintf
14324 @findex rintl
14325 @findex round
14326 @findex roundf
14327 @findex roundl
14328 @findex scalb
14329 @findex scalbf
14330 @findex scalbl
14331 @findex scalbln
14332 @findex scalblnf
14333 @findex scalblnf
14334 @findex scalbn
14335 @findex scalbnf
14336 @findex scanfnl
14337 @findex signbit
14338 @findex signbitf
14339 @findex signbitl
14340 @findex signbitd32
14341 @findex signbitd64
14342 @findex signbitd128
14343 @findex significand
14344 @findex significandf
14345 @findex significandl
14346 @findex sin
14347 @findex sincos
14348 @findex sincosf
14349 @findex sincosl
14350 @findex sinf
14351 @findex sinh
14352 @findex sinhf
14353 @findex sinhl
14354 @findex sinl
14355 @findex snprintf
14356 @findex sprintf
14357 @findex sqrt
14358 @findex sqrtf
14359 @findex sqrtl
14360 @findex sscanf
14361 @findex stpcpy
14362 @findex stpncpy
14363 @findex strcasecmp
14364 @findex strcat
14365 @findex strchr
14366 @findex strcmp
14367 @findex strcpy
14368 @findex strcspn
14369 @findex strdup
14370 @findex strfmon
14371 @findex strftime
14372 @findex strlen
14373 @findex strncasecmp
14374 @findex strncat
14375 @findex strncmp
14376 @findex strncpy
14377 @findex strndup
14378 @findex strnlen
14379 @findex strpbrk
14380 @findex strrchr
14381 @findex strspn
14382 @findex strstr
14383 @findex tan
14384 @findex tanf
14385 @findex tanh
14386 @findex tanhf
14387 @findex tanhl
14388 @findex tanl
14389 @findex tgamma
14390 @findex tgammaf
14391 @findex tgammal
14392 @findex toascii
14393 @findex tolower
14394 @findex toupper
14395 @findex towlower
14396 @findex towupper
14397 @findex trunc
14398 @findex truncf
14399 @findex truncl
14400 @findex vfprintf
14401 @findex vfscanf
14402 @findex vprintf
14403 @findex vscanf
14404 @findex vsnprintf
14405 @findex vsprintf
14406 @findex vsscanf
14407 @findex y0
14408 @findex y0f
14409 @findex y0l
14410 @findex y1
14411 @findex y1f
14412 @findex y1l
14413 @findex yn
14414 @findex ynf
14415 @findex ynl
14417 GCC provides a large number of built-in functions other than the ones
14418 mentioned above.  Some of these are for internal use in the processing
14419 of exceptions or variable-length argument lists and are not
14420 documented here because they may change from time to time; we do not
14421 recommend general use of these functions.
14423 The remaining functions are provided for optimization purposes.
14425 With the exception of built-ins that have library equivalents such as
14426 the standard C library functions discussed below, or that expand to
14427 library calls, GCC built-in functions are always expanded inline and
14428 thus do not have corresponding entry points and their address cannot
14429 be obtained.  Attempting to use them in an expression other than
14430 a function call results in a compile-time error.
14432 @opindex fno-builtin
14433 GCC includes built-in versions of many of the functions in the standard
14434 C library.  These functions come in two forms: one whose names start with
14435 the @code{__builtin_} prefix, and the other without.  Both forms have the
14436 same type (including prototype), the same address (when their address is
14437 taken), and the same meaning as the C library functions even if you specify
14438 the @option{-fno-builtin} option @pxref{C Dialect Options}).  Many of these
14439 functions are only optimized in certain cases; if they are not optimized in
14440 a particular case, a call to the library function is emitted.
14442 @opindex ansi
14443 @opindex std
14444 Outside strict ISO C mode (@option{-ansi}, @option{-std=c90},
14445 @option{-std=c99} or @option{-std=c11}), the functions
14446 @code{_exit}, @code{alloca}, @code{bcmp}, @code{bzero},
14447 @code{dcgettext}, @code{dgettext}, @code{dremf}, @code{dreml},
14448 @code{drem}, @code{exp10f}, @code{exp10l}, @code{exp10}, @code{ffsll},
14449 @code{ffsl}, @code{ffs}, @code{fprintf_unlocked},
14450 @code{fputs_unlocked}, @code{gammaf}, @code{gammal}, @code{gamma},
14451 @code{gammaf_r}, @code{gammal_r}, @code{gamma_r}, @code{gettext},
14452 @code{index}, @code{isascii}, @code{j0f}, @code{j0l}, @code{j0},
14453 @code{j1f}, @code{j1l}, @code{j1}, @code{jnf}, @code{jnl}, @code{jn},
14454 @code{lgammaf_r}, @code{lgammal_r}, @code{lgamma_r}, @code{mempcpy},
14455 @code{pow10f}, @code{pow10l}, @code{pow10}, @code{printf_unlocked},
14456 @code{rindex}, @code{roundeven}, @code{roundevenf}, @code{roundevenl},
14457 @code{scalbf}, @code{scalbl}, @code{scalb},
14458 @code{signbit}, @code{signbitf}, @code{signbitl}, @code{signbitd32},
14459 @code{signbitd64}, @code{signbitd128}, @code{significandf},
14460 @code{significandl}, @code{significand}, @code{sincosf},
14461 @code{sincosl}, @code{sincos}, @code{stpcpy}, @code{stpncpy},
14462 @code{strcasecmp}, @code{strdup}, @code{strfmon}, @code{strncasecmp},
14463 @code{strndup}, @code{strnlen}, @code{toascii}, @code{y0f}, @code{y0l},
14464 @code{y0}, @code{y1f}, @code{y1l}, @code{y1}, @code{ynf}, @code{ynl} and
14465 @code{yn}
14466 may be handled as built-in functions.
14467 All these functions have corresponding versions
14468 prefixed with @code{__builtin_}, which may be used even in strict C90
14469 mode.
14471 The ISO C99 functions
14472 @code{_Exit}, @code{acoshf}, @code{acoshl}, @code{acosh}, @code{asinhf},
14473 @code{asinhl}, @code{asinh}, @code{atanhf}, @code{atanhl}, @code{atanh},
14474 @code{cabsf}, @code{cabsl}, @code{cabs}, @code{cacosf}, @code{cacoshf},
14475 @code{cacoshl}, @code{cacosh}, @code{cacosl}, @code{cacos},
14476 @code{cargf}, @code{cargl}, @code{carg}, @code{casinf}, @code{casinhf},
14477 @code{casinhl}, @code{casinh}, @code{casinl}, @code{casin},
14478 @code{catanf}, @code{catanhf}, @code{catanhl}, @code{catanh},
14479 @code{catanl}, @code{catan}, @code{cbrtf}, @code{cbrtl}, @code{cbrt},
14480 @code{ccosf}, @code{ccoshf}, @code{ccoshl}, @code{ccosh}, @code{ccosl},
14481 @code{ccos}, @code{cexpf}, @code{cexpl}, @code{cexp}, @code{cimagf},
14482 @code{cimagl}, @code{cimag}, @code{clogf}, @code{clogl}, @code{clog},
14483 @code{conjf}, @code{conjl}, @code{conj}, @code{copysignf}, @code{copysignl},
14484 @code{copysign}, @code{cpowf}, @code{cpowl}, @code{cpow}, @code{cprojf},
14485 @code{cprojl}, @code{cproj}, @code{crealf}, @code{creall}, @code{creal},
14486 @code{csinf}, @code{csinhf}, @code{csinhl}, @code{csinh}, @code{csinl},
14487 @code{csin}, @code{csqrtf}, @code{csqrtl}, @code{csqrt}, @code{ctanf},
14488 @code{ctanhf}, @code{ctanhl}, @code{ctanh}, @code{ctanl}, @code{ctan},
14489 @code{erfcf}, @code{erfcl}, @code{erfc}, @code{erff}, @code{erfl},
14490 @code{erf}, @code{exp2f}, @code{exp2l}, @code{exp2}, @code{expm1f},
14491 @code{expm1l}, @code{expm1}, @code{fdimf}, @code{fdiml}, @code{fdim},
14492 @code{fmaf}, @code{fmal}, @code{fmaxf}, @code{fmaxl}, @code{fmax},
14493 @code{fma}, @code{fminf}, @code{fminl}, @code{fmin}, @code{hypotf},
14494 @code{hypotl}, @code{hypot}, @code{ilogbf}, @code{ilogbl}, @code{ilogb},
14495 @code{imaxabs}, @code{isblank}, @code{iswblank}, @code{lgammaf},
14496 @code{lgammal}, @code{lgamma}, @code{llabs}, @code{llrintf}, @code{llrintl},
14497 @code{llrint}, @code{llroundf}, @code{llroundl}, @code{llround},
14498 @code{log1pf}, @code{log1pl}, @code{log1p}, @code{log2f}, @code{log2l},
14499 @code{log2}, @code{logbf}, @code{logbl}, @code{logb}, @code{lrintf},
14500 @code{lrintl}, @code{lrint}, @code{lroundf}, @code{lroundl},
14501 @code{lround}, @code{nearbyintf}, @code{nearbyintl}, @code{nearbyint},
14502 @code{nextafterf}, @code{nextafterl}, @code{nextafter},
14503 @code{nexttowardf}, @code{nexttowardl}, @code{nexttoward},
14504 @code{remainderf}, @code{remainderl}, @code{remainder}, @code{remquof},
14505 @code{remquol}, @code{remquo}, @code{rintf}, @code{rintl}, @code{rint},
14506 @code{roundf}, @code{roundl}, @code{round}, @code{scalblnf},
14507 @code{scalblnl}, @code{scalbln}, @code{scalbnf}, @code{scalbnl},
14508 @code{scalbn}, @code{snprintf}, @code{tgammaf}, @code{tgammal},
14509 @code{tgamma}, @code{truncf}, @code{truncl}, @code{trunc},
14510 @code{vfscanf}, @code{vscanf}, @code{vsnprintf} and @code{vsscanf}
14511 are handled as built-in functions
14512 except in strict ISO C90 mode (@option{-ansi} or @option{-std=c90}).
14514 There are also built-in versions of the ISO C99 functions
14515 @code{acosf}, @code{acosl}, @code{asinf}, @code{asinl}, @code{atan2f},
14516 @code{atan2l}, @code{atanf}, @code{atanl}, @code{ceilf}, @code{ceill},
14517 @code{cosf}, @code{coshf}, @code{coshl}, @code{cosl}, @code{expf},
14518 @code{expl}, @code{fabsf}, @code{fabsl}, @code{floorf}, @code{floorl},
14519 @code{fmodf}, @code{fmodl}, @code{frexpf}, @code{frexpl}, @code{ldexpf},
14520 @code{ldexpl}, @code{log10f}, @code{log10l}, @code{logf}, @code{logl},
14521 @code{modfl}, @code{modff}, @code{powf}, @code{powl}, @code{sinf},
14522 @code{sinhf}, @code{sinhl}, @code{sinl}, @code{sqrtf}, @code{sqrtl},
14523 @code{tanf}, @code{tanhf}, @code{tanhl} and @code{tanl}
14524 that are recognized in any mode since ISO C90 reserves these names for
14525 the purpose to which ISO C99 puts them.  All these functions have
14526 corresponding versions prefixed with @code{__builtin_}.
14528 There are also built-in functions @code{__builtin_fabsf@var{n}},
14529 @code{__builtin_fabsf@var{n}x}, @code{__builtin_copysignf@var{n}} and
14530 @code{__builtin_copysignf@var{n}x}, corresponding to the TS 18661-3
14531 functions @code{fabsf@var{n}}, @code{fabsf@var{n}x},
14532 @code{copysignf@var{n}} and @code{copysignf@var{n}x}, for supported
14533 types @code{_Float@var{n}} and @code{_Float@var{n}x}.
14535 There are also GNU extension functions @code{clog10}, @code{clog10f} and
14536 @code{clog10l} which names are reserved by ISO C99 for future use.
14537 All these functions have versions prefixed with @code{__builtin_}.
14539 The ISO C94 functions
14540 @code{iswalnum}, @code{iswalpha}, @code{iswcntrl}, @code{iswdigit},
14541 @code{iswgraph}, @code{iswlower}, @code{iswprint}, @code{iswpunct},
14542 @code{iswspace}, @code{iswupper}, @code{iswxdigit}, @code{towlower} and
14543 @code{towupper}
14544 are handled as built-in functions
14545 except in strict ISO C90 mode (@option{-ansi} or @option{-std=c90}).
14547 The ISO C90 functions
14548 @code{abort}, @code{abs}, @code{acos}, @code{asin}, @code{atan2},
14549 @code{atan}, @code{calloc}, @code{ceil}, @code{cosh}, @code{cos},
14550 @code{exit}, @code{exp}, @code{fabs}, @code{floor}, @code{fmod},
14551 @code{fprintf}, @code{fputs}, @code{free}, @code{frexp}, @code{fscanf},
14552 @code{isalnum}, @code{isalpha}, @code{iscntrl}, @code{isdigit},
14553 @code{isgraph}, @code{islower}, @code{isprint}, @code{ispunct},
14554 @code{isspace}, @code{isupper}, @code{isxdigit}, @code{tolower},
14555 @code{toupper}, @code{labs}, @code{ldexp}, @code{log10}, @code{log},
14556 @code{malloc}, @code{memchr}, @code{memcmp}, @code{memcpy},
14557 @code{memset}, @code{modf}, @code{pow}, @code{printf}, @code{putchar},
14558 @code{puts}, @code{realloc}, @code{scanf}, @code{sinh}, @code{sin},
14559 @code{snprintf}, @code{sprintf}, @code{sqrt}, @code{sscanf}, @code{strcat},
14560 @code{strchr}, @code{strcmp}, @code{strcpy}, @code{strcspn},
14561 @code{strlen}, @code{strncat}, @code{strncmp}, @code{strncpy},
14562 @code{strpbrk}, @code{strrchr}, @code{strspn}, @code{strstr},
14563 @code{tanh}, @code{tan}, @code{vfprintf}, @code{vprintf} and @code{vsprintf}
14564 are all recognized as built-in functions unless
14565 @option{-fno-builtin} is specified (or @option{-fno-builtin-@var{function}}
14566 is specified for an individual function).  All of these functions have
14567 corresponding versions prefixed with @code{__builtin_}.
14569 GCC provides built-in versions of the ISO C99 floating-point comparison
14570 macros that avoid raising exceptions for unordered operands.  They have
14571 the same names as the standard macros ( @code{isgreater},
14572 @code{isgreaterequal}, @code{isless}, @code{islessequal},
14573 @code{islessgreater}, and @code{isunordered}) , with @code{__builtin_}
14574 prefixed.  We intend for a library implementor to be able to simply
14575 @code{#define} each standard macro to its built-in equivalent.
14576 In the same fashion, GCC provides @code{fpclassify}, @code{iseqsig},
14577 @code{isfinite}, @code{isinf_sign}, @code{isnormal} and @code{signbit} built-ins
14578 used with @code{__builtin_} prefixed.  The @code{isinf} and @code{isnan}
14579 built-in functions appear both with and without the @code{__builtin_} prefix.
14580 With @code{-ffinite-math-only} option the @code{isinf} and @code{isnan}
14581 built-in functions will always return 0.
14583 GCC provides built-in versions of the ISO C99 floating-point rounding and
14584 exceptions handling functions @code{fegetround}, @code{feclearexcept} and
14585 @code{feraiseexcept}.  They may not be available for all targets, and because
14586 they need close interaction with libc internal values, they may not be available
14587 for all target libcs, but in all cases they will gracefully fallback to libc
14588 calls.  These built-in functions appear both with and without the
14589 @code{__builtin_} prefix.
14591 @defbuiltin{{void *} __builtin_alloca (size_t @var{size})}
14592 The @code{__builtin_alloca} function must be called at block scope.
14593 The function allocates an object @var{size} bytes large on the stack
14594 of the calling function.  The object is aligned on the default stack
14595 alignment boundary for the target determined by the
14596 @code{__BIGGEST_ALIGNMENT__} macro.  The @code{__builtin_alloca}
14597 function returns a pointer to the first byte of the allocated object.
14598 The lifetime of the allocated object ends just before the calling
14599 function returns to its caller.   This is so even when
14600 @code{__builtin_alloca} is called within a nested block.
14602 For example, the following function allocates eight objects of @code{n}
14603 bytes each on the stack, storing a pointer to each in consecutive elements
14604 of the array @code{a}.  It then passes the array to function @code{g}
14605 which can safely use the storage pointed to by each of the array elements.
14607 @smallexample
14608 void f (unsigned n)
14610   void *a [8];
14611   for (int i = 0; i != 8; ++i)
14612     a [i] = __builtin_alloca (n);
14614   g (a, n);   // @r{safe}
14616 @end smallexample
14618 Since the @code{__builtin_alloca} function doesn't validate its argument
14619 it is the responsibility of its caller to make sure the argument doesn't
14620 cause it to exceed the stack size limit.
14621 The @code{__builtin_alloca} function is provided to make it possible to
14622 allocate on the stack arrays of bytes with an upper bound that may be
14623 computed at run time.  Since C99 Variable Length Arrays offer
14624 similar functionality under a portable, more convenient, and safer
14625 interface they are recommended instead, in both C99 and C++ programs
14626 where GCC provides them as an extension.
14627 @xref{Variable Length}, for details.
14629 @enddefbuiltin
14631 @defbuiltin{{void *} __builtin_alloca_with_align (size_t @var{size}, size_t @var{alignment})}
14632 The @code{__builtin_alloca_with_align} function must be called at block
14633 scope.  The function allocates an object @var{size} bytes large on
14634 the stack of the calling function.  The allocated object is aligned on
14635 the boundary specified by the argument @var{alignment} whose unit is given
14636 in bits (not bytes).  The @var{size} argument must be positive and not
14637 exceed the stack size limit.  The @var{alignment} argument must be a constant
14638 integer expression that evaluates to a power of 2 greater than or equal to
14639 @code{CHAR_BIT} and less than some unspecified maximum.  Invocations
14640 with other values are rejected with an error indicating the valid bounds.
14641 The function returns a pointer to the first byte of the allocated object.
14642 The lifetime of the allocated object ends at the end of the block in which
14643 the function was called.  The allocated storage is released no later than
14644 just before the calling function returns to its caller, but may be released
14645 at the end of the block in which the function was called.
14647 For example, in the following function the call to @code{g} is unsafe
14648 because when @code{overalign} is non-zero, the space allocated by
14649 @code{__builtin_alloca_with_align} may have been released at the end
14650 of the @code{if} statement in which it was called.
14652 @smallexample
14653 void f (unsigned n, bool overalign)
14655   void *p;
14656   if (overalign)
14657     p = __builtin_alloca_with_align (n, 64 /* bits */);
14658   else
14659     p = __builtin_alloc (n);
14661   g (p, n);   // @r{unsafe}
14663 @end smallexample
14665 Since the @code{__builtin_alloca_with_align} function doesn't validate its
14666 @var{size} argument it is the responsibility of its caller to make sure
14667 the argument doesn't cause it to exceed the stack size limit.
14668 The @code{__builtin_alloca_with_align} function is provided to make
14669 it possible to allocate on the stack overaligned arrays of bytes with
14670 an upper bound that may be computed at run time.  Since C99
14671 Variable Length Arrays offer the same functionality under
14672 a portable, more convenient, and safer interface they are recommended
14673 instead, in both C99 and C++ programs where GCC provides them as
14674 an extension.  @xref{Variable Length}, for details.
14676 @enddefbuiltin
14678 @defbuiltin{{void *} __builtin_alloca_with_align_and_max (size_t @var{size}, size_t @var{alignment}, size_t @var{max_size})}
14679 Similar to @code{__builtin_alloca_with_align} but takes an extra argument
14680 specifying an upper bound for @var{size} in case its value cannot be computed
14681 at compile time, for use by @option{-fstack-usage}, @option{-Wstack-usage}
14682 and @option{-Walloca-larger-than}.  @var{max_size} must be a constant integer
14683 expression, it has no effect on code generation and no attempt is made to
14684 check its compatibility with @var{size}.
14686 @enddefbuiltin
14688 @defbuiltin{bool __builtin_has_attribute (@var{type-or-expression}, @var{attribute})}
14689 The @code{__builtin_has_attribute} function evaluates to an integer constant
14690 expression equal to @code{true} if the symbol or type referenced by
14691 the @var{type-or-expression} argument has been declared with
14692 the @var{attribute} referenced by the second argument.  For
14693 an @var{type-or-expression} argument that does not reference a symbol,
14694 since attributes do not apply to expressions the built-in consider
14695 the type of the argument.  Neither argument is evaluated.
14696 The @var{type-or-expression} argument is subject to the same
14697 restrictions as the argument to @code{typeof} (@pxref{Typeof}).  The
14698 @var{attribute} argument is an attribute name optionally followed by
14699 a comma-separated list of arguments enclosed in parentheses.  Both forms
14700 of attribute names---with and without double leading and trailing
14701 underscores---are recognized.  @xref{Attribute Syntax}, for details.
14702 When no attribute arguments are specified for an attribute that expects
14703 one or more arguments the function returns @code{true} if
14704 @var{type-or-expression} has been declared with the attribute regardless
14705 of the attribute argument values.  Arguments provided for an attribute
14706 that expects some are validated and matched up to the provided number.
14707 The function returns @code{true} if all provided arguments match.  For
14708 example, the first call to the function below evaluates to @code{true}
14709 because @code{x} is declared with the @code{aligned} attribute but
14710 the second call evaluates to @code{false} because @code{x} is declared
14711 @code{aligned (8)} and not @code{aligned (4)}.
14713 @smallexample
14714 __attribute__ ((aligned (8))) int x;
14715 _Static_assert (__builtin_has_attribute (x, aligned), "aligned");
14716 _Static_assert (!__builtin_has_attribute (x, aligned (4)), "aligned (4)");
14717 @end smallexample
14719 Due to a limitation the @code{__builtin_has_attribute} function returns
14720 @code{false} for the @code{mode} attribute even if the type or variable
14721 referenced by the @var{type-or-expression} argument was declared with one.
14722 The function is also not supported with labels, and in C with enumerators.
14724 Note that unlike the @code{__has_attribute} preprocessor operator which
14725 is suitable for use in @code{#if} preprocessing directives
14726 @code{__builtin_has_attribute} is an intrinsic function that is not
14727 recognized in such contexts.
14729 @enddefbuiltin
14731 @defbuiltin{@var{type} __builtin_speculation_safe_value (@var{type} @var{val}, @var{type} @var{failval})}
14733 This built-in function can be used to help mitigate against unsafe
14734 speculative execution.  @var{type} may be any integral type or any
14735 pointer type.
14737 @enumerate
14738 @item
14739 If the CPU is not speculatively executing the code, then @var{val}
14740 is returned.
14741 @item
14742 If the CPU is executing speculatively then either:
14743 @itemize
14744 @item
14745 The function may cause execution to pause until it is known that the
14746 code is no-longer being executed speculatively (in which case
14747 @var{val} can be returned, as above); or
14748 @item
14749 The function may use target-dependent speculation tracking state to cause
14750 @var{failval} to be returned when it is known that speculative
14751 execution has incorrectly predicted a conditional branch operation.
14752 @end itemize
14753 @end enumerate
14755 The second argument, @var{failval}, is optional and defaults to zero
14756 if omitted.
14758 GCC defines the preprocessor macro
14759 @code{__HAVE_BUILTIN_SPECULATION_SAFE_VALUE} for targets that have been
14760 updated to support this builtin.
14762 The built-in function can be used where a variable appears to be used in a
14763 safe way, but the CPU, due to speculative execution may temporarily ignore
14764 the bounds checks.  Consider, for example, the following function:
14766 @smallexample
14767 int array[500];
14768 int f (unsigned untrusted_index)
14770   if (untrusted_index < 500)
14771     return array[untrusted_index];
14772   return 0;
14774 @end smallexample
14776 If the function is called repeatedly with @code{untrusted_index} less
14777 than the limit of 500, then a branch predictor will learn that the
14778 block of code that returns a value stored in @code{array} will be
14779 executed.  If the function is subsequently called with an
14780 out-of-range value it will still try to execute that block of code
14781 first until the CPU determines that the prediction was incorrect
14782 (the CPU will unwind any incorrect operations at that point).
14783 However, depending on how the result of the function is used, it might be
14784 possible to leave traces in the cache that can reveal what was stored
14785 at the out-of-bounds location.  The built-in function can be used to
14786 provide some protection against leaking data in this way by changing
14787 the code to:
14789 @smallexample
14790 int array[500];
14791 int f (unsigned untrusted_index)
14793   if (untrusted_index < 500)
14794     return array[__builtin_speculation_safe_value (untrusted_index)];
14795   return 0;
14797 @end smallexample
14799 The built-in function will either cause execution to stall until the
14800 conditional branch has been fully resolved, or it may permit
14801 speculative execution to continue, but using 0 instead of
14802 @code{untrusted_value} if that exceeds the limit.
14804 If accessing any memory location is potentially unsafe when speculative
14805 execution is incorrect, then the code can be rewritten as
14807 @smallexample
14808 int array[500];
14809 int f (unsigned untrusted_index)
14811   if (untrusted_index < 500)
14812     return *__builtin_speculation_safe_value (&array[untrusted_index], NULL);
14813   return 0;
14815 @end smallexample
14817 which will cause a @code{NULL} pointer to be used for the unsafe case.
14819 @enddefbuiltin
14821 @defbuiltin{int __builtin_types_compatible_p (@var{type1}, @var{type2})}
14823 You can use the built-in function @code{__builtin_types_compatible_p} to
14824 determine whether two types are the same.
14826 This built-in function returns 1 if the unqualified versions of the
14827 types @var{type1} and @var{type2} (which are types, not expressions) are
14828 compatible, 0 otherwise.  The result of this built-in function can be
14829 used in integer constant expressions.
14831 This built-in function ignores top level qualifiers (e.g., @code{const},
14832 @code{volatile}).  For example, @code{int} is equivalent to @code{const
14833 int}.
14835 The type @code{int[]} and @code{int[5]} are compatible.  On the other
14836 hand, @code{int} and @code{char *} are not compatible, even if the size
14837 of their types, on the particular architecture are the same.  Also, the
14838 amount of pointer indirection is taken into account when determining
14839 similarity.  Consequently, @code{short *} is not similar to
14840 @code{short **}.  Furthermore, two types that are typedefed are
14841 considered compatible if their underlying types are compatible.
14843 An @code{enum} type is not considered to be compatible with another
14844 @code{enum} type even if both are compatible with the same integer
14845 type; this is what the C standard specifies.
14846 For example, @code{enum @{foo, bar@}} is not similar to
14847 @code{enum @{hot, dog@}}.
14849 You typically use this function in code whose execution varies
14850 depending on the arguments' types.  For example:
14852 @smallexample
14853 #define foo(x)                                                  \
14854   (@{                                                           \
14855     typeof (x) tmp = (x);                                       \
14856     if (__builtin_types_compatible_p (typeof (x), long double)) \
14857       tmp = foo_long_double (tmp);                              \
14858     else if (__builtin_types_compatible_p (typeof (x), double)) \
14859       tmp = foo_double (tmp);                                   \
14860     else if (__builtin_types_compatible_p (typeof (x), float))  \
14861       tmp = foo_float (tmp);                                    \
14862     else                                                        \
14863       abort ();                                                 \
14864     tmp;                                                        \
14865   @})
14866 @end smallexample
14868 @emph{Note:} This construct is only available for C@.
14870 @enddefbuiltin
14872 @defbuiltin{@var{type} __builtin_call_with_static_chain (@var{call_exp}, @var{pointer_exp})}
14874 The @var{call_exp} expression must be a function call, and the
14875 @var{pointer_exp} expression must be a pointer.  The @var{pointer_exp}
14876 is passed to the function call in the target's static chain location.
14877 The result of builtin is the result of the function call.
14879 @emph{Note:} This builtin is only available for C@.
14880 This builtin can be used to call Go closures from C.
14882 @enddefbuiltin
14884 @defbuiltin{@var{type} __builtin_choose_expr (@var{const_exp}, @var{exp1}, @var{exp2})}
14886 You can use the built-in function @code{__builtin_choose_expr} to
14887 evaluate code depending on the value of a constant expression.  This
14888 built-in function returns @var{exp1} if @var{const_exp}, which is an
14889 integer constant expression, is nonzero.  Otherwise it returns @var{exp2}.
14891 This built-in function is analogous to the @samp{? :} operator in C,
14892 except that the expression returned has its type unaltered by promotion
14893 rules.  Also, the built-in function does not evaluate the expression
14894 that is not chosen.  For example, if @var{const_exp} evaluates to @code{true},
14895 @var{exp2} is not evaluated even if it has side effects.
14897 This built-in function can return an lvalue if the chosen argument is an
14898 lvalue.
14900 If @var{exp1} is returned, the return type is the same as @var{exp1}'s
14901 type.  Similarly, if @var{exp2} is returned, its return type is the same
14902 as @var{exp2}.
14904 Example:
14906 @smallexample
14907 #define foo(x)                                                    \
14908   __builtin_choose_expr (                                         \
14909     __builtin_types_compatible_p (typeof (x), double),            \
14910     foo_double (x),                                               \
14911     __builtin_choose_expr (                                       \
14912       __builtin_types_compatible_p (typeof (x), float),           \
14913       foo_float (x),                                              \
14914       /* @r{The void expression results in a compile-time error}  \
14915          @r{when assigning the result to something.}  */          \
14916       (void)0))
14917 @end smallexample
14919 @emph{Note:} This construct is only available for C@.  Furthermore, the
14920 unused expression (@var{exp1} or @var{exp2} depending on the value of
14921 @var{const_exp}) may still generate syntax errors.  This may change in
14922 future revisions.
14924 @enddefbuiltin
14926 @defbuiltin{@var{type} __builtin_tgmath (@var{functions}, @var{arguments})}
14928 The built-in function @code{__builtin_tgmath}, available only for C
14929 and Objective-C, calls a function determined according to the rules of
14930 @code{<tgmath.h>} macros.  It is intended to be used in
14931 implementations of that header, so that expansions of macros from that
14932 header only expand each of their arguments once, to avoid problems
14933 when calls to such macros are nested inside the arguments of other
14934 calls to such macros; in addition, it results in better diagnostics
14935 for invalid calls to @code{<tgmath.h>} macros than implementations
14936 using other GNU C language features.  For example, the @code{pow}
14937 type-generic macro might be defined as:
14939 @smallexample
14940 #define pow(a, b) __builtin_tgmath (powf, pow, powl, \
14941                                     cpowf, cpow, cpowl, a, b)
14942 @end smallexample
14944 The arguments to @code{__builtin_tgmath} are at least two pointers to
14945 functions, followed by the arguments to the type-generic macro (which
14946 will be passed as arguments to the selected function).  All the
14947 pointers to functions must be pointers to prototyped functions, none
14948 of which may have variable arguments, and all of which must have the
14949 same number of parameters; the number of parameters of the first
14950 function determines how many arguments to @code{__builtin_tgmath} are
14951 interpreted as function pointers, and how many as the arguments to the
14952 called function.
14954 The types of the specified functions must all be different, but
14955 related to each other in the same way as a set of functions that may
14956 be selected between by a macro in @code{<tgmath.h>}.  This means that
14957 the functions are parameterized by a floating-point type @var{t},
14958 different for each such function.  The function return types may all
14959 be the same type, or they may be @var{t} for each function, or they
14960 may be the real type corresponding to @var{t} for each function (if
14961 some of the types @var{t} are complex).  Likewise, for each parameter
14962 position, the type of the parameter in that position may always be the
14963 same type, or may be @var{t} for each function (this case must apply
14964 for at least one parameter position), or may be the real type
14965 corresponding to @var{t} for each function.
14967 The standard rules for @code{<tgmath.h>} macros are used to find a
14968 common type @var{u} from the types of the arguments for parameters
14969 whose types vary between the functions; complex integer types (a GNU
14970 extension) are treated like the complex type corresponding to the real
14971 floating type that would be chosen for the corresponding real integer type.
14972 If the function return types vary, or are all the same integer type,
14973 the function called is the one for which @var{t} is @var{u}, and it is
14974 an error if there is no such function.  If the function return types
14975 are all the same floating-point type, the type-generic macro is taken
14976 to be one of those from TS 18661 that rounds the result to a narrower
14977 type; if there is a function for which @var{t} is @var{u}, it is
14978 called, and otherwise the first function, if any, for which @var{t}
14979 has at least the range and precision of @var{u} is called, and it is
14980 an error if there is no such function.
14982 @enddefbuiltin
14984 @defbuiltin{int __builtin_constant_p (@var{exp})}
14985 You can use the built-in function @code{__builtin_constant_p} to
14986 determine if the expression @var{exp} is known to be constant at
14987 compile time and hence that GCC can perform constant-folding on expressions
14988 involving that value.  The argument of the function is the expression to test.
14989 The expression is not evaluated, side-effects are discarded.  The function
14990 returns the integer 1 if the argument is known to be a compile-time
14991 constant and 0 if it is not known to be a compile-time constant.
14992 Any expression that has side-effects makes the function return 0.
14993 A return of 0 does not indicate that the expression is @emph{not} a constant,
14994 but merely that GCC cannot prove it is a constant within the constraints
14995 of the active set of optimization options.
14997 You typically use this function in an embedded application where
14998 memory is a critical resource.  If you have some complex calculation,
14999 you may want it to be folded if it involves constants, but need to call
15000 a function if it does not.  For example:
15002 @smallexample
15003 #define Scale_Value(X)      \
15004   (__builtin_constant_p (X) \
15005   ? ((X) * SCALE + OFFSET) : Scale (X))
15006 @end smallexample
15008 You may use this built-in function in either a macro or an inline
15009 function.  However, if you use it in an inlined function and pass an
15010 argument of the function as the argument to the built-in, GCC 
15011 never returns 1 when you call the inline function with a string constant
15012 or compound literal (@pxref{Compound Literals}) and does not return 1
15013 when you pass a constant numeric value to the inline function unless you
15014 specify the @option{-O} option.
15016 You may also use @code{__builtin_constant_p} in initializers for static
15017 data.  For instance, you can write
15019 @smallexample
15020 static const int table[] = @{
15021    __builtin_constant_p (EXPRESSION) ? (EXPRESSION) : -1,
15022    /* @r{@dots{}} */
15024 @end smallexample
15026 @noindent
15027 This is an acceptable initializer even if @var{EXPRESSION} is not a
15028 constant expression, including the case where
15029 @code{__builtin_constant_p} returns 1 because @var{EXPRESSION} can be
15030 folded to a constant but @var{EXPRESSION} contains operands that are
15031 not otherwise permitted in a static initializer (for example,
15032 @code{0 && foo ()}).  GCC must be more conservative about evaluating the
15033 built-in in this case, because it has no opportunity to perform
15034 optimization.
15035 @enddefbuiltin
15037 @defbuiltin{bool __builtin_is_constant_evaluated (void)}
15038 The @code{__builtin_is_constant_evaluated} function is available only
15039 in C++.  The built-in is intended to be used by implementations of
15040 the @code{std::is_constant_evaluated} C++ function.  Programs should make
15041 use of the latter function rather than invoking the built-in directly.
15043 The main use case of the built-in is to determine whether a @code{constexpr}
15044 function is being called in a @code{constexpr} context.  A call to
15045 the function evaluates to a core constant expression with the value
15046 @code{true} if and only if it occurs within the evaluation of an expression
15047 or conversion that is manifestly constant-evaluated as defined in the C++
15048 standard.  Manifestly constant-evaluated contexts include constant-expressions,
15049 the conditions of @code{constexpr if} statements, constraint-expressions, and
15050 initializers of variables usable in constant expressions.   For more details
15051 refer to the latest revision of the C++ standard.
15052 @enddefbuiltin
15054 @defbuiltin{void __builtin_clear_padding (@var{ptr})}
15055 The built-in function @code{__builtin_clear_padding} function clears
15056 padding bits inside of the object representation of object pointed by
15057 @var{ptr}, which has to be a pointer.  The value representation of the
15058 object is not affected.  The type of the object is assumed to be the type
15059 the pointer points to.  Inside of a union, the only cleared bits are
15060 bits that are padding bits for all the union members.
15062 This built-in-function is useful if the padding bits of an object might
15063 have intederminate values and the object representation needs to be
15064 bitwise compared to some other object, for example for atomic operations.
15066 For C++, @var{ptr} argument type should be pointer to trivially-copyable
15067 type, unless the argument is address of a variable or parameter, because
15068 otherwise it isn't known if the type isn't just a base class whose padding
15069 bits are reused or laid out differently in a derived class.
15070 @enddefbuiltin
15072 @defbuiltin{@var{type} __builtin_bit_cast (@var{type}, @var{arg})}
15073 The @code{__builtin_bit_cast} function is available only
15074 in C++.  The built-in is intended to be used by implementations of
15075 the @code{std::bit_cast} C++ template function.  Programs should make
15076 use of the latter function rather than invoking the built-in directly.
15078 This built-in function allows reinterpreting the bits of the @var{arg}
15079 argument as if it had type @var{type}.  @var{type} and the type of the
15080 @var{arg} argument need to be trivially copyable types with the same size.
15081 When manifestly constant-evaluated, it performs extra diagnostics required
15082 for @code{std::bit_cast} and returns a constant expression if @var{arg}
15083 is a constant expression.  For more details
15084 refer to the latest revision of the C++ standard.
15085 @enddefbuiltin
15087 @defbuiltin{long __builtin_expect (long @var{exp}, long @var{c})}
15088 @opindex fprofile-arcs
15089 You may use @code{__builtin_expect} to provide the compiler with
15090 branch prediction information.  In general, you should prefer to
15091 use actual profile feedback for this (@option{-fprofile-arcs}), as
15092 programmers are notoriously bad at predicting how their programs
15093 actually perform.  However, there are applications in which this
15094 data is hard to collect.
15096 The return value is the value of @var{exp}, which should be an integral
15097 expression.  The semantics of the built-in are that it is expected that
15098 @var{exp} == @var{c}.  For example:
15100 @smallexample
15101 if (__builtin_expect (x, 0))
15102   foo ();
15103 @end smallexample
15105 @noindent
15106 indicates that we do not expect to call @code{foo}, since
15107 we expect @code{x} to be zero.  Since you are limited to integral
15108 expressions for @var{exp}, you should use constructions such as
15110 @smallexample
15111 if (__builtin_expect (ptr != NULL, 1))
15112   foo (*ptr);
15113 @end smallexample
15115 @noindent
15116 when testing pointer or floating-point values.
15118 For the purposes of branch prediction optimizations, the probability that
15119 a @code{__builtin_expect} expression is @code{true} is controlled by GCC's
15120 @code{builtin-expect-probability} parameter, which defaults to 90%.  
15122 You can also use @code{__builtin_expect_with_probability} to explicitly 
15123 assign a probability value to individual expressions.  If the built-in
15124 is used in a loop construct, the provided probability will influence
15125 the expected number of iterations made by loop optimizations.
15126 @enddefbuiltin
15128 @defbuiltin{long __builtin_expect_with_probability}
15129 (long @var{exp}, long @var{c}, double @var{probability})
15131 This function has the same semantics as @code{__builtin_expect},
15132 but the caller provides the expected probability that @var{exp} == @var{c}.
15133 The last argument, @var{probability}, is a floating-point value in the
15134 range 0.0 to 1.0, inclusive.  The @var{probability} argument must be
15135 constant floating-point expression.
15136 @enddefbuiltin
15138 @defbuiltin{void __builtin_trap (void)}
15139 This function causes the program to exit abnormally.  GCC implements
15140 this function by using a target-dependent mechanism (such as
15141 intentionally executing an illegal instruction) or by calling
15142 @code{abort}.  The mechanism used may vary from release to release so
15143 you should not rely on any particular implementation.
15144 @enddefbuiltin
15146 @defbuiltin{void __builtin_unreachable (void)}
15147 If control flow reaches the point of the @code{__builtin_unreachable},
15148 the program is undefined.  It is useful in situations where the
15149 compiler cannot deduce the unreachability of the code.
15151 One such case is immediately following an @code{asm} statement that
15152 either never terminates, or one that transfers control elsewhere
15153 and never returns.  In this example, without the
15154 @code{__builtin_unreachable}, GCC issues a warning that control
15155 reaches the end of a non-void function.  It also generates code
15156 to return after the @code{asm}.
15158 @smallexample
15159 int f (int c, int v)
15161   if (c)
15162     @{
15163       return v;
15164     @}
15165   else
15166     @{
15167       asm("jmp error_handler");
15168       __builtin_unreachable ();
15169     @}
15171 @end smallexample
15173 @noindent
15174 Because the @code{asm} statement unconditionally transfers control out
15175 of the function, control never reaches the end of the function
15176 body.  The @code{__builtin_unreachable} is in fact unreachable and
15177 communicates this fact to the compiler.
15179 Another use for @code{__builtin_unreachable} is following a call a
15180 function that never returns but that is not declared
15181 @code{__attribute__((noreturn))}, as in this example:
15183 @smallexample
15184 void function_that_never_returns (void);
15186 int g (int c)
15188   if (c)
15189     @{
15190       return 1;
15191     @}
15192   else
15193     @{
15194       function_that_never_returns ();
15195       __builtin_unreachable ();
15196     @}
15198 @end smallexample
15200 @enddefbuiltin
15202 @defbuiltin{@var{type} __builtin_assoc_barrier (@var{type} @var{expr})}
15203 This built-in inhibits re-association of the floating-point expression
15204 @var{expr} with expressions consuming the return value of the built-in. The
15205 expression @var{expr} itself can be reordered, and the whole expression
15206 @var{expr} can be reordered with operands after the barrier. The barrier is
15207 only relevant when @code{-fassociative-math} is active, since otherwise
15208 floating-point is not treated as associative.
15210 @smallexample
15211 float x0 = a + b - b;
15212 float x1 = __builtin_assoc_barrier(a + b) - b;
15213 @end smallexample
15215 @noindent
15216 means that, with @code{-fassociative-math}, @code{x0} can be optimized to
15217 @code{x0 = a} but @code{x1} cannot.
15218 @enddefbuiltin
15220 @defbuiltin{{void *} __builtin_assume_aligned (const void *@var{exp}, size_t @var{align}, ...)}
15221 This function returns its first argument, and allows the compiler
15222 to assume that the returned pointer is at least @var{align} bytes
15223 aligned.  This built-in can have either two or three arguments,
15224 if it has three, the third argument should have integer type, and
15225 if it is nonzero means misalignment offset.  For example:
15227 @smallexample
15228 void *x = __builtin_assume_aligned (arg, 16);
15229 @end smallexample
15231 @noindent
15232 means that the compiler can assume @code{x}, set to @code{arg}, is at least
15233 16-byte aligned, while:
15235 @smallexample
15236 void *x = __builtin_assume_aligned (arg, 32, 8);
15237 @end smallexample
15239 @noindent
15240 means that the compiler can assume for @code{x}, set to @code{arg}, that
15241 @code{(char *) x - 8} is 32-byte aligned.
15242 @enddefbuiltin
15244 @defbuiltin{int __builtin_LINE ()}
15245 This function is the equivalent of the preprocessor @code{__LINE__}
15246 macro and returns a constant integer expression that evaluates to
15247 the line number of the invocation of the built-in.  When used as a C++
15248 default argument for a function @var{F}, it returns the line number
15249 of the call to @var{F}.
15250 @enddefbuiltin
15252 @defbuiltin{{const char *} __builtin_FUNCTION ()}
15253 This function is the equivalent of the @code{__FUNCTION__} symbol
15254 and returns an address constant pointing to the name of the function
15255 from which the built-in was invoked, or the empty string if
15256 the invocation is not at function scope.  When used as a C++ default
15257 argument for a function @var{F}, it returns the name of @var{F}'s
15258 caller or the empty string if the call was not made at function
15259 scope.
15260 @enddefbuiltin
15262 @defbuiltin{{const char *} __builtin_FILE ()}
15263 This function is the equivalent of the preprocessor @code{__FILE__}
15264 macro and returns an address constant pointing to the file name
15265 containing the invocation of the built-in, or the empty string if
15266 the invocation is not at function scope.  When used as a C++ default
15267 argument for a function @var{F}, it returns the file name of the call
15268 to @var{F} or the empty string if the call was not made at function
15269 scope.
15271 For example, in the following, each call to function @code{foo} will
15272 print a line similar to @code{"file.c:123: foo: message"} with the name
15273 of the file and the line number of the @code{printf} call, the name of
15274 the function @code{foo}, followed by the word @code{message}.
15276 @smallexample
15277 const char*
15278 function (const char *func = __builtin_FUNCTION ())
15280   return func;
15283 void foo (void)
15285   printf ("%s:%i: %s: message\n", file (), line (), function ());
15287 @end smallexample
15289 @enddefbuiltin
15291 @defbuiltin{void __builtin___clear_cache (void *@var{begin}, void *@var{end})}
15292 This function is used to flush the processor's instruction cache for
15293 the region of memory between @var{begin} inclusive and @var{end}
15294 exclusive.  Some targets require that the instruction cache be
15295 flushed, after modifying memory containing code, in order to obtain
15296 deterministic behavior.
15298 If the target does not require instruction cache flushes,
15299 @code{__builtin___clear_cache} has no effect.  Otherwise either
15300 instructions are emitted in-line to clear the instruction cache or a
15301 call to the @code{__clear_cache} function in libgcc is made.
15302 @enddefbuiltin
15304 @defbuiltin{void __builtin_prefetch (const void *@var{addr}, ...)}
15305 This function is used to minimize cache-miss latency by moving data into
15306 a cache before it is accessed.
15307 You can insert calls to @code{__builtin_prefetch} into code for which
15308 you know addresses of data in memory that is likely to be accessed soon.
15309 If the target supports them, data prefetch instructions are generated.
15310 If the prefetch is done early enough before the access then the data will
15311 be in the cache by the time it is accessed.
15313 The value of @var{addr} is the address of the memory to prefetch.
15314 There are two optional arguments, @var{rw} and @var{locality}.
15315 The value of @var{rw} is a compile-time constant one or zero; one
15316 means that the prefetch is preparing for a write to the memory address
15317 and zero, the default, means that the prefetch is preparing for a read.
15318 The value @var{locality} must be a compile-time constant integer between
15319 zero and three.  A value of zero means that the data has no temporal
15320 locality, so it need not be left in the cache after the access.  A value
15321 of three means that the data has a high degree of temporal locality and
15322 should be left in all levels of cache possible.  Values of one and two
15323 mean, respectively, a low or moderate degree of temporal locality.  The
15324 default is three.
15326 @smallexample
15327 for (i = 0; i < n; i++)
15328   @{
15329     a[i] = a[i] + b[i];
15330     __builtin_prefetch (&a[i+j], 1, 1);
15331     __builtin_prefetch (&b[i+j], 0, 1);
15332     /* @r{@dots{}} */
15333   @}
15334 @end smallexample
15336 Data prefetch does not generate faults if @var{addr} is invalid, but
15337 the address expression itself must be valid.  For example, a prefetch
15338 of @code{p->next} does not fault if @code{p->next} is not a valid
15339 address, but evaluation faults if @code{p} is not a valid address.
15341 If the target does not support data prefetch, the address expression
15342 is evaluated if it includes side effects but no other code is generated
15343 and GCC does not issue a warning.
15344 @enddefbuiltin
15346 @defbuiltin{{size_t} __builtin_object_size (const void * @var{ptr}, int @var{type})}
15347 Returns a constant size estimate of an object pointed to by @var{ptr}.
15348 @xref{Object Size Checking}, for a detailed description of the function.
15349 @enddefbuiltin
15351 @defbuiltin{{size_t} __builtin_dynamic_object_size (const void * @var{ptr}, int @var{type})}
15352 Similar to @code{__builtin_object_size} except that the return value
15353 need not be a constant.  @xref{Object Size Checking}, for a detailed
15354 description of the function.
15355 @enddefbuiltin
15357 @defbuiltin{int __builtin_classify_type (@var{arg})}
15358 @defbuiltinx{int __builtin_classify_type (@var{type})}
15359 The @code{__builtin_classify_type} returns a small integer with a category
15360 of @var{arg} argument's type, like void type, integer type, enumeral type,
15361 boolean type, pointer type, reference type, offset type, real type, complex
15362 type, function type, method type, record type, union type, array type,
15363 string type, bit-precise integer type, vector type, etc.  When the argument
15364 is an expression, for backwards compatibility reason the argument is promoted
15365 like arguments passed to @code{...} in varargs function, so some classes are
15366 never returned in certain languages.  Alternatively, the argument of the
15367 built-in function can be a typename, such as the @code{typeof} specifier.
15369 @smallexample
15370 int a[2];
15371 __builtin_classify_type (a) == __builtin_classify_type (int[5]);
15372 __builtin_classify_type (a) == __builtin_classify_type (void*);
15373 __builtin_classify_type (typeof (a)) == __builtin_classify_type (int[5]);
15374 @end smallexample
15376 The first comparison will never be true, as @var{a} is implicitly converted
15377 to pointer.  The last two comparisons will be true as they classify
15378 pointers in the second case and arrays in the last case.
15379 @enddefbuiltin
15381 @defbuiltin{double __builtin_huge_val (void)}
15382 Returns a positive infinity, if supported by the floating-point format,
15383 else @code{DBL_MAX}.  This function is suitable for implementing the
15384 ISO C macro @code{HUGE_VAL}.
15385 @enddefbuiltin
15387 @defbuiltin{float __builtin_huge_valf (void)}
15388 Similar to @code{__builtin_huge_val}, except the return type is @code{float}.
15389 @enddefbuiltin
15391 @defbuiltin{{long double} __builtin_huge_vall (void)}
15392 Similar to @code{__builtin_huge_val}, except the return
15393 type is @code{long double}.
15394 @enddefbuiltin
15396 @defbuiltin{_Float@var{n} __builtin_huge_valf@var{n} (void)}
15397 Similar to @code{__builtin_huge_val}, except the return type is
15398 @code{_Float@var{n}}.
15399 @enddefbuiltin
15401 @defbuiltin{_Float@var{n}x __builtin_huge_valf@var{n}x (void)}
15402 Similar to @code{__builtin_huge_val}, except the return type is
15403 @code{_Float@var{n}x}.
15404 @enddefbuiltin
15406 @defbuiltin{int __builtin_fpclassify (int, int, int, int, int, ...)}
15407 This built-in implements the C99 fpclassify functionality.  The first
15408 five int arguments should be the target library's notion of the
15409 possible FP classes and are used for return values.  They must be
15410 constant values and they must appear in this order: @code{FP_NAN},
15411 @code{FP_INFINITE}, @code{FP_NORMAL}, @code{FP_SUBNORMAL} and
15412 @code{FP_ZERO}.  The ellipsis is for exactly one floating-point value
15413 to classify.  GCC treats the last argument as type-generic, which
15414 means it does not do default promotion from float to double.
15415 @enddefbuiltin
15417 @defbuiltin{double __builtin_inf (void)}
15418 Similar to @code{__builtin_huge_val}, except a warning is generated
15419 if the target floating-point format does not support infinities.
15420 @enddefbuiltin
15422 @defbuiltin{_Decimal32 __builtin_infd32 (void)}
15423 Similar to @code{__builtin_inf}, except the return type is @code{_Decimal32}.
15424 @enddefbuiltin
15426 @defbuiltin{_Decimal64 __builtin_infd64 (void)}
15427 Similar to @code{__builtin_inf}, except the return type is @code{_Decimal64}.
15428 @enddefbuiltin
15430 @defbuiltin{_Decimal128 __builtin_infd128 (void)}
15431 Similar to @code{__builtin_inf}, except the return type is @code{_Decimal128}.
15432 @enddefbuiltin
15434 @defbuiltin{float __builtin_inff (void)}
15435 Similar to @code{__builtin_inf}, except the return type is @code{float}.
15436 This function is suitable for implementing the ISO C99 macro @code{INFINITY}.
15437 @enddefbuiltin
15439 @defbuiltin{{long double} __builtin_infl (void)}
15440 Similar to @code{__builtin_inf}, except the return
15441 type is @code{long double}.
15442 @enddefbuiltin
15444 @defbuiltin{_Float@var{n} __builtin_inff@var{n} (void)}
15445 Similar to @code{__builtin_inf}, except the return
15446 type is @code{_Float@var{n}}.
15447 @enddefbuiltin
15449 @defbuiltin{_Float@var{n} __builtin_inff@var{n}x (void)}
15450 Similar to @code{__builtin_inf}, except the return
15451 type is @code{_Float@var{n}x}.
15452 @enddefbuiltin
15454 @defbuiltin{int __builtin_isinf_sign (...)}
15455 Similar to @code{isinf}, except the return value is -1 for
15456 an argument of @code{-Inf} and 1 for an argument of @code{+Inf}.
15457 Note while the parameter list is an
15458 ellipsis, this function only accepts exactly one floating-point
15459 argument.  GCC treats this parameter as type-generic, which means it
15460 does not do default promotion from float to double.
15461 @enddefbuiltin
15463 @defbuiltin{double __builtin_nan (const char *@var{str})}
15464 This is an implementation of the ISO C99 function @code{nan}.
15466 Since ISO C99 defines this function in terms of @code{strtod}, which we
15467 do not implement, a description of the parsing is in order.  The string
15468 is parsed as by @code{strtol}; that is, the base is recognized by
15469 leading @samp{0} or @samp{0x} prefixes.  The number parsed is placed
15470 in the significand such that the least significant bit of the number
15471 is at the least significant bit of the significand.  The number is
15472 truncated to fit the significand field provided.  The significand is
15473 forced to be a quiet NaN@.
15475 This function, if given a string literal all of which would have been
15476 consumed by @code{strtol}, is evaluated early enough that it is considered a
15477 compile-time constant.
15478 @enddefbuiltin
15480 @defbuiltin{_Decimal32 __builtin_nand32 (const char *@var{str})}
15481 Similar to @code{__builtin_nan}, except the return type is @code{_Decimal32}.
15482 @enddefbuiltin
15484 @defbuiltin{_Decimal64 __builtin_nand64 (const char *@var{str})}
15485 Similar to @code{__builtin_nan}, except the return type is @code{_Decimal64}.
15486 @enddefbuiltin
15488 @defbuiltin{_Decimal128 __builtin_nand128 (const char *@var{str})}
15489 Similar to @code{__builtin_nan}, except the return type is @code{_Decimal128}.
15490 @enddefbuiltin
15492 @defbuiltin{float __builtin_nanf (const char *@var{str})}
15493 Similar to @code{__builtin_nan}, except the return type is @code{float}.
15494 @enddefbuiltin
15496 @defbuiltin{{long double} __builtin_nanl (const char *@var{str})}
15497 Similar to @code{__builtin_nan}, except the return type is @code{long double}.
15498 @enddefbuiltin
15500 @defbuiltin{_Float@var{n} __builtin_nanf@var{n} (const char *@var{str})}
15501 Similar to @code{__builtin_nan}, except the return type is
15502 @code{_Float@var{n}}.
15503 @enddefbuiltin
15505 @defbuiltin{_Float@var{n}x __builtin_nanf@var{n}x (const char *@var{str})}
15506 Similar to @code{__builtin_nan}, except the return type is
15507 @code{_Float@var{n}x}.
15508 @enddefbuiltin
15510 @defbuiltin{double __builtin_nans (const char *@var{str})}
15511 Similar to @code{__builtin_nan}, except the significand is forced
15512 to be a signaling NaN@.  The @code{nans} function is proposed by
15513 @uref{https://www.open-std.org/jtc1/sc22/wg14/www/docs/n965.htm,,WG14 N965}.
15514 @enddefbuiltin
15516 @defbuiltin{_Decimal32 __builtin_nansd32 (const char *@var{str})}
15517 Similar to @code{__builtin_nans}, except the return type is @code{_Decimal32}.
15518 @enddefbuiltin
15520 @defbuiltin{_Decimal64 __builtin_nansd64 (const char *@var{str})}
15521 Similar to @code{__builtin_nans}, except the return type is @code{_Decimal64}.
15522 @enddefbuiltin
15524 @defbuiltin{_Decimal128 __builtin_nansd128 (const char *@var{str})}
15525 Similar to @code{__builtin_nans}, except the return type is @code{_Decimal128}.
15526 @enddefbuiltin
15528 @defbuiltin{float __builtin_nansf (const char *@var{str})}
15529 Similar to @code{__builtin_nans}, except the return type is @code{float}.
15530 @enddefbuiltin
15532 @defbuiltin{{long double} __builtin_nansl (const char *@var{str})}
15533 Similar to @code{__builtin_nans}, except the return type is @code{long double}.
15534 @enddefbuiltin
15536 @defbuiltin{_Float@var{n} __builtin_nansf@var{n} (const char *@var{str})}
15537 Similar to @code{__builtin_nans}, except the return type is
15538 @code{_Float@var{n}}.
15539 @enddefbuiltin
15541 @defbuiltin{_Float@var{n}x __builtin_nansf@var{n}x (const char *@var{str})}
15542 Similar to @code{__builtin_nans}, except the return type is
15543 @code{_Float@var{n}x}.
15544 @enddefbuiltin
15546 @defbuiltin{int __builtin_issignaling (...)}
15547 Return non-zero if the argument is a signaling NaN and zero otherwise.
15548 Note while the parameter list is an
15549 ellipsis, this function only accepts exactly one floating-point
15550 argument.  GCC treats this parameter as type-generic, which means it
15551 does not do default promotion from float to double.
15552 This built-in function can work even without the non-default
15553 @code{-fsignaling-nans} option, although if a signaling NaN is computed,
15554 stored or passed as argument to some function other than this built-in
15555 in the current translation unit, it is safer to use @code{-fsignaling-nans}.
15556 With @code{-ffinite-math-only} option this built-in function will always
15557 return 0.
15558 @enddefbuiltin
15560 @defbuiltin{int __builtin_ffs (int @var{x})}
15561 Returns one plus the index of the least significant 1-bit of @var{x}, or
15562 if @var{x} is zero, returns zero.
15563 @enddefbuiltin
15565 @defbuiltin{int __builtin_clz (unsigned int @var{x})}
15566 Returns the number of leading 0-bits in @var{x}, starting at the most
15567 significant bit position.  If @var{x} is 0, the result is undefined.
15568 @enddefbuiltin
15570 @defbuiltin{int __builtin_ctz (unsigned int @var{x})}
15571 Returns the number of trailing 0-bits in @var{x}, starting at the least
15572 significant bit position.  If @var{x} is 0, the result is undefined.
15573 @enddefbuiltin
15575 @defbuiltin{int __builtin_clrsb (int @var{x})}
15576 Returns the number of leading redundant sign bits in @var{x}, i.e.@: the
15577 number of bits following the most significant bit that are identical
15578 to it.  There are no special cases for 0 or other values. 
15579 @enddefbuiltin
15581 @defbuiltin{int __builtin_popcount (unsigned int @var{x})}
15582 Returns the number of 1-bits in @var{x}.
15583 @enddefbuiltin
15585 @defbuiltin{int __builtin_parity (unsigned int @var{x})}
15586 Returns the parity of @var{x}, i.e.@: the number of 1-bits in @var{x}
15587 modulo 2.
15588 @enddefbuiltin
15590 @defbuiltin{int __builtin_ffsl (long)}
15591 Similar to @code{__builtin_ffs}, except the argument type is
15592 @code{long}.
15593 @enddefbuiltin
15595 @defbuiltin{int __builtin_clzl (unsigned long)}
15596 Similar to @code{__builtin_clz}, except the argument type is
15597 @code{unsigned long}.
15598 @enddefbuiltin
15600 @defbuiltin{int __builtin_ctzl (unsigned long)}
15601 Similar to @code{__builtin_ctz}, except the argument type is
15602 @code{unsigned long}.
15603 @enddefbuiltin
15605 @defbuiltin{int __builtin_clrsbl (long)}
15606 Similar to @code{__builtin_clrsb}, except the argument type is
15607 @code{long}.
15608 @enddefbuiltin
15610 @defbuiltin{int __builtin_popcountl (unsigned long)}
15611 Similar to @code{__builtin_popcount}, except the argument type is
15612 @code{unsigned long}.
15613 @enddefbuiltin
15615 @defbuiltin{int __builtin_parityl (unsigned long)}
15616 Similar to @code{__builtin_parity}, except the argument type is
15617 @code{unsigned long}.
15618 @enddefbuiltin
15620 @defbuiltin{int __builtin_ffsll (long long)}
15621 Similar to @code{__builtin_ffs}, except the argument type is
15622 @code{long long}.
15623 @enddefbuiltin
15625 @defbuiltin{int __builtin_clzll (unsigned long long)}
15626 Similar to @code{__builtin_clz}, except the argument type is
15627 @code{unsigned long long}.
15628 @enddefbuiltin
15630 @defbuiltin{int __builtin_ctzll (unsigned long long)}
15631 Similar to @code{__builtin_ctz}, except the argument type is
15632 @code{unsigned long long}.
15633 @enddefbuiltin
15635 @defbuiltin{int __builtin_clrsbll (long long)}
15636 Similar to @code{__builtin_clrsb}, except the argument type is
15637 @code{long long}.
15638 @enddefbuiltin
15640 @defbuiltin{int __builtin_popcountll (unsigned long long)}
15641 Similar to @code{__builtin_popcount}, except the argument type is
15642 @code{unsigned long long}.
15643 @enddefbuiltin
15645 @defbuiltin{int __builtin_parityll (unsigned long long)}
15646 Similar to @code{__builtin_parity}, except the argument type is
15647 @code{unsigned long long}.
15648 @enddefbuiltin
15650 @defbuiltin{int __builtin_ffsg (...)}
15651 Similar to @code{__builtin_ffs}, except the argument is type-generic
15652 signed integer (standard, extended or bit-precise).  No integral argument
15653 promotions are performed on the argument.
15654 @enddefbuiltin
15656 @defbuiltin{int __builtin_clzg (...)}
15657 Similar to @code{__builtin_clz}, except the argument is type-generic
15658 unsigned integer (standard, extended or bit-precise) and there is
15659 optional second argument with int type.  No integral argument promotions
15660 are performed on the first argument.  If two arguments are specified,
15661 and first argument is 0, the result is the second argument.  If only
15662 one argument is specified and it is 0, the result is undefined.
15663 @enddefbuiltin
15665 @defbuiltin{int __builtin_ctzg (...)}
15666 Similar to @code{__builtin_ctz}, except the argument is type-generic
15667 unsigned integer (standard, extended or bit-precise) and there is
15668 optional second argument with int type.  No integral argument promotions
15669 are performed on the first argument.  If two arguments are specified,
15670 and first argument is 0, the result is the second argument.  If only
15671 one argument is specified and it is 0, the result is undefined.
15672 @enddefbuiltin
15674 @defbuiltin{int __builtin_clrsbg (...)}
15675 Similar to @code{__builtin_clrsb}, except the argument is type-generic
15676 signed integer (standard, extended or bit-precise).  No integral argument
15677 promotions are performed on the argument.
15678 @enddefbuiltin
15680 @defbuiltin{int __builtin_popcountg (...)}
15681 Similar to @code{__builtin_popcount}, except the argument is type-generic
15682 unsigned integer (standard, extended or bit-precise).  No integral argument
15683 promotions are performed on the argument.
15684 @enddefbuiltin
15686 @defbuiltin{int __builtin_parityg (...)}
15687 Similar to @code{__builtin_parity}, except the argument is type-generic
15688 unsigned integer (standard, extended or bit-precise).  No integral argument
15689 promotions are performed on the argument.
15690 @enddefbuiltin
15692 @defbuiltin{@var{type} __builtin_stdc_bit_ceil (@var{type} @var{arg})}
15693 The @code{__builtin_stdc_bit_ceil} function is available only
15694 in C.  It is type-generic, the argument can be any unsigned integer
15695 (standard, extended or bit-precise).  No integral argument promotions are
15696 performed on the argument.  It is equivalent to
15697 @code{@var{arg} <= 1 ? (@var{type}) 1
15698 : (@var{type}) 2 << (@var{prec} - 1 - __builtin_clzg ((@var{type}) (@var{arg} - 1)))}
15699 where @var{prec} is bit width of @var{type}, except that side-effects
15700 in @var{arg} are evaluated just once.
15701 @enddefbuiltin
15703 @defbuiltin{@var{type} __builtin_stdc_bit_floor (@var{type} @var{arg})}
15704 The @code{__builtin_stdc_bit_floor} function is available only
15705 in C.  It is type-generic, the argument can be any unsigned integer
15706 (standard, extended or bit-precise).  No integral argument promotions are
15707 performed on the argument.  It is equivalent to
15708 @code{@var{arg} == 0 ? (@var{type}) 0
15709 : (@var{type}) 1 << (@var{prec} - 1 - __builtin_clzg (@var{arg}))}
15710 where @var{prec} is bit width of @var{type}, except that side-effects
15711 in @var{arg} are evaluated just once.
15712 @enddefbuiltin
15714 @defbuiltin{{unsigned int} __builtin_stdc_bit_width (@var{type} @var{arg})}
15715 The @code{__builtin_stdc_bit_width} function is available only
15716 in C.  It is type-generic, the argument can be any unsigned integer
15717 (standard, extended or bit-precise).  No integral argument promotions are
15718 performed on the argument.  It is equivalent to
15719 @code{(unsigned int) (@var{prec} - __builtin_clzg (@var{arg}, @var{prec}))}
15720 where @var{prec} is bit width of @var{type}.
15721 @enddefbuiltin
15723 @defbuiltin{{unsigned int} __builtin_stdc_count_ones (@var{type} @var{arg})}
15724 The @code{__builtin_stdc_count_ones} function is available only
15725 in C.  It is type-generic, the argument can be any unsigned integer
15726 (standard, extended or bit-precise).  No integral argument promotions are
15727 performed on the argument.  It is equivalent to
15728 @code{(unsigned int) __builtin_popcountg (@var{arg})}
15729 @enddefbuiltin
15731 @defbuiltin{{unsigned int} __builtin_stdc_count_zeros (@var{type} @var{arg})}
15732 The @code{__builtin_stdc_count_zeros} function is available only
15733 in C.  It is type-generic, the argument can be any unsigned integer
15734 (standard, extended or bit-precise).  No integral argument promotions are
15735 performed on the argument.  It is equivalent to
15736 @code{(unsigned int) __builtin_popcountg ((@var{type}) ~@var{arg})}
15737 @enddefbuiltin
15739 @defbuiltin{{unsigned int} __builtin_stdc_first_leading_one (@var{type} @var{arg})}
15740 The @code{__builtin_stdc_first_leading_one} function is available only
15741 in C.  It is type-generic, the argument can be any unsigned integer
15742 (standard, extended or bit-precise).  No integral argument promotions are
15743 performed on the argument.  It is equivalent to
15744 @code{__builtin_clzg (@var{arg}, -1) + 1U}
15745 @enddefbuiltin
15747 @defbuiltin{{unsigned int} __builtin_stdc_first_leading_zero (@var{type} @var{arg})}
15748 The @code{__builtin_stdc_first_leading_zero} function is available only
15749 in C.  It is type-generic, the argument can be any unsigned integer
15750 (standard, extended or bit-precise).  No integral argument promotions are
15751 performed on the argument.  It is equivalent to
15752 @code{__builtin_clzg ((@var{type}) ~@var{arg}, -1) + 1U}
15753 @enddefbuiltin
15755 @defbuiltin{{unsigned int} __builtin_stdc_first_trailing_one (@var{type} @var{arg})}
15756 The @code{__builtin_stdc_first_trailing_one} function is available only
15757 in C.  It is type-generic, the argument can be any unsigned integer
15758 (standard, extended or bit-precise).  No integral argument promotions are
15759 performed on the argument.  It is equivalent to
15760 @code{__builtin_ctzg (@var{arg}, -1) + 1U}
15761 @enddefbuiltin
15763 @defbuiltin{{unsigned int} __builtin_stdc_first_trailing_zero (@var{type} @var{arg})}
15764 The @code{__builtin_stdc_first_trailing_zero} function is available only
15765 in C.  It is type-generic, the argument can be any unsigned integer
15766 (standard, extended or bit-precise).  No integral argument promotions are
15767 performed on the argument.  It is equivalent to
15768 @code{__builtin_ctzg ((@var{type}) ~@var{arg}, -1) + 1U}
15769 @enddefbuiltin
15771 @defbuiltin{{unsigned int} __builtin_stdc_has_single_bit (@var{type} @var{arg})}
15772 The @code{__builtin_stdc_has_single_bit} function is available only
15773 in C.  It is type-generic, the argument can be any unsigned integer
15774 (standard, extended or bit-precise).  No integral argument promotions are
15775 performed on the argument.  It is equivalent to
15776 @code{(_Bool) (__builtin_popcountg (@var{arg}) == 1)}
15777 @enddefbuiltin
15779 @defbuiltin{{unsigned int} __builtin_stdc_leading_ones (@var{type} @var{arg})}
15780 The @code{__builtin_stdc_leading_ones} function is available only
15781 in C.  It is type-generic, the argument can be any unsigned integer
15782 (standard, extended or bit-precise).  No integral argument promotions are
15783 performed on the argument.  It is equivalent to
15784 @code{(unsigned int) __builtin_clzg ((@var{type}) ~@var{arg}, @var{prec})}
15785 @enddefbuiltin
15787 @defbuiltin{{unsigned int} __builtin_stdc_leading_zeros (@var{type} @var{arg})}
15788 The @code{__builtin_stdc_leading_zeros} function is available only
15789 in C.  It is type-generic, the argument can be any unsigned integer
15790 (standard, extended or bit-precise).  No integral argument promotions are
15791 performed on the argument.  It is equivalent to
15792 @code{(unsigned int) __builtin_clzg (@var{arg}, @var{prec})}
15793 @enddefbuiltin
15795 @defbuiltin{{unsigned int} __builtin_stdc_trailing_ones (@var{type} @var{arg})}
15796 The @code{__builtin_stdc_trailing_ones} function is available only
15797 in C.  It is type-generic, the argument can be any unsigned integer
15798 (standard, extended or bit-precise).  No integral argument promotions are
15799 performed on the argument.  It is equivalent to
15800 @code{(unsigned int) __builtin_ctzg ((@var{type}) ~@var{arg}, @var{prec})}
15801 @enddefbuiltin
15803 @defbuiltin{{unsigned int} __builtin_stdc_trailing_zeros (@var{type} @var{arg})}
15804 The @code{__builtin_stdc_trailing_zeros} function is available only
15805 in C.  It is type-generic, the argument can be any unsigned integer
15806 (standard, extended or bit-precise).  No integral argument promotions are
15807 performed on the argument.  It is equivalent to
15808 @code{(unsigned int) __builtin_ctzg (@var{arg}, @var{prec})}
15809 @enddefbuiltin
15811 @defbuiltin{double __builtin_powi (double, int)}
15812 @defbuiltinx{float __builtin_powif (float, int)}
15813 @defbuiltinx{{long double} __builtin_powil (long double, int)}
15814 Returns the first argument raised to the power of the second.  Unlike the
15815 @code{pow} function no guarantees about precision and rounding are made.
15816 @enddefbuiltin
15818 @defbuiltin{uint16_t __builtin_bswap16 (uint16_t @var{x})}
15819 Returns @var{x} with the order of the bytes reversed; for example,
15820 @code{0xaabb} becomes @code{0xbbaa}.  Byte here always means
15821 exactly 8 bits.
15822 @enddefbuiltin
15824 @defbuiltin{uint32_t __builtin_bswap32 (uint32_t @var{x})}
15825 Similar to @code{__builtin_bswap16}, except the argument and return types
15826 are 32-bit.
15827 @enddefbuiltin
15829 @defbuiltin{uint64_t __builtin_bswap64 (uint64_t @var{x})}
15830 Similar to @code{__builtin_bswap32}, except the argument and return types
15831 are 64-bit.
15832 @enddefbuiltin
15834 @defbuiltin{uint128_t __builtin_bswap128 (uint128_t @var{x})}
15835 Similar to @code{__builtin_bswap64}, except the argument and return types
15836 are 128-bit.  Only supported on targets when 128-bit types are supported.
15837 @enddefbuiltin
15840 @defbuiltin{Pmode __builtin_extend_pointer (void * @var{x})}
15841 On targets where the user visible pointer size is smaller than the size
15842 of an actual hardware address this function returns the extended user
15843 pointer.  Targets where this is true included ILP32 mode on x86_64 or
15844 Aarch64.  This function is mainly useful when writing inline assembly
15845 code.
15846 @enddefbuiltin
15848 @defbuiltin{int __builtin_goacc_parlevel_id (int @var{x})}
15849 Returns the openacc gang, worker or vector id depending on whether @var{x} is
15850 0, 1 or 2.
15851 @enddefbuiltin
15853 @defbuiltin{int __builtin_goacc_parlevel_size (int @var{x})}
15854 Returns the openacc gang, worker or vector size depending on whether @var{x} is
15855 0, 1 or 2.
15856 @enddefbuiltin
15858 @node Target Builtins
15859 @section Built-in Functions Specific to Particular Target Machines
15861 On some target machines, GCC supports many built-in functions specific
15862 to those machines.  Generally these generate calls to specific machine
15863 instructions, but allow the compiler to schedule those calls.
15865 @menu
15866 * AArch64 Built-in Functions::
15867 * Alpha Built-in Functions::
15868 * Altera Nios II Built-in Functions::
15869 * ARC Built-in Functions::
15870 * ARC SIMD Built-in Functions::
15871 * ARM iWMMXt Built-in Functions::
15872 * ARM C Language Extensions (ACLE)::
15873 * ARM Floating Point Status and Control Intrinsics::
15874 * ARM ARMv8-M Security Extensions::
15875 * AVR Built-in Functions::
15876 * Blackfin Built-in Functions::
15877 * BPF Built-in Functions::
15878 * FR-V Built-in Functions::
15879 * LoongArch Base Built-in Functions::
15880 * LoongArch SX Vector Intrinsics::
15881 * LoongArch ASX Vector Intrinsics::
15882 * MIPS DSP Built-in Functions::
15883 * MIPS Paired-Single Support::
15884 * MIPS Loongson Built-in Functions::
15885 * MIPS SIMD Architecture (MSA) Support::
15886 * Other MIPS Built-in Functions::
15887 * MSP430 Built-in Functions::
15888 * NDS32 Built-in Functions::
15889 * Nvidia PTX Built-in Functions::
15890 * Basic PowerPC Built-in Functions::
15891 * PowerPC AltiVec/VSX Built-in Functions::
15892 * PowerPC Hardware Transactional Memory Built-in Functions::
15893 * PowerPC Atomic Memory Operation Functions::
15894 * PowerPC Matrix-Multiply Assist Built-in Functions::
15895 * PRU Built-in Functions::
15896 * RISC-V Built-in Functions::
15897 * RISC-V Vector Intrinsics::
15898 * CORE-V Built-in Functions::
15899 * RX Built-in Functions::
15900 * S/390 System z Built-in Functions::
15901 * SH Built-in Functions::
15902 * SPARC VIS Built-in Functions::
15903 * TI C6X Built-in Functions::
15904 * x86 Built-in Functions::
15905 * x86 transactional memory intrinsics::
15906 * x86 control-flow protection intrinsics::
15907 @end menu
15909 @node AArch64 Built-in Functions
15910 @subsection AArch64 Built-in Functions
15912 These built-in functions are available for the AArch64 family of
15913 processors.
15914 @smallexample
15915 unsigned int __builtin_aarch64_get_fpcr ();
15916 void __builtin_aarch64_set_fpcr (unsigned int);
15917 unsigned int __builtin_aarch64_get_fpsr ();
15918 void __builtin_aarch64_set_fpsr (unsigned int);
15920 unsigned long long __builtin_aarch64_get_fpcr64 ();
15921 void __builtin_aarch64_set_fpcr64 (unsigned long long);
15922 unsigned long long __builtin_aarch64_get_fpsr64 ();
15923 void __builtin_aarch64_set_fpsr64 (unsigned long long);
15924 @end smallexample
15926 @node Alpha Built-in Functions
15927 @subsection Alpha Built-in Functions
15929 These built-in functions are available for the Alpha family of
15930 processors, depending on the command-line switches used.
15932 The following built-in functions are always available.  They
15933 all generate the machine instruction that is part of the name.
15935 @smallexample
15936 long __builtin_alpha_implver (void);
15937 long __builtin_alpha_rpcc (void);
15938 long __builtin_alpha_amask (long);
15939 long __builtin_alpha_cmpbge (long, long);
15940 long __builtin_alpha_extbl (long, long);
15941 long __builtin_alpha_extwl (long, long);
15942 long __builtin_alpha_extll (long, long);
15943 long __builtin_alpha_extql (long, long);
15944 long __builtin_alpha_extwh (long, long);
15945 long __builtin_alpha_extlh (long, long);
15946 long __builtin_alpha_extqh (long, long);
15947 long __builtin_alpha_insbl (long, long);
15948 long __builtin_alpha_inswl (long, long);
15949 long __builtin_alpha_insll (long, long);
15950 long __builtin_alpha_insql (long, long);
15951 long __builtin_alpha_inswh (long, long);
15952 long __builtin_alpha_inslh (long, long);
15953 long __builtin_alpha_insqh (long, long);
15954 long __builtin_alpha_mskbl (long, long);
15955 long __builtin_alpha_mskwl (long, long);
15956 long __builtin_alpha_mskll (long, long);
15957 long __builtin_alpha_mskql (long, long);
15958 long __builtin_alpha_mskwh (long, long);
15959 long __builtin_alpha_msklh (long, long);
15960 long __builtin_alpha_mskqh (long, long);
15961 long __builtin_alpha_umulh (long, long);
15962 long __builtin_alpha_zap (long, long);
15963 long __builtin_alpha_zapnot (long, long);
15964 @end smallexample
15966 The following built-in functions are always with @option{-mmax}
15967 or @option{-mcpu=@var{cpu}} where @var{cpu} is @code{pca56} or
15968 later.  They all generate the machine instruction that is part
15969 of the name.
15971 @smallexample
15972 long __builtin_alpha_pklb (long);
15973 long __builtin_alpha_pkwb (long);
15974 long __builtin_alpha_unpkbl (long);
15975 long __builtin_alpha_unpkbw (long);
15976 long __builtin_alpha_minub8 (long, long);
15977 long __builtin_alpha_minsb8 (long, long);
15978 long __builtin_alpha_minuw4 (long, long);
15979 long __builtin_alpha_minsw4 (long, long);
15980 long __builtin_alpha_maxub8 (long, long);
15981 long __builtin_alpha_maxsb8 (long, long);
15982 long __builtin_alpha_maxuw4 (long, long);
15983 long __builtin_alpha_maxsw4 (long, long);
15984 long __builtin_alpha_perr (long, long);
15985 @end smallexample
15987 The following built-in functions are always with @option{-mcix}
15988 or @option{-mcpu=@var{cpu}} where @var{cpu} is @code{ev67} or
15989 later.  They all generate the machine instruction that is part
15990 of the name.
15992 @smallexample
15993 long __builtin_alpha_cttz (long);
15994 long __builtin_alpha_ctlz (long);
15995 long __builtin_alpha_ctpop (long);
15996 @end smallexample
15998 The following built-in functions are available on systems that use the OSF/1
15999 PALcode.  Normally they invoke the @code{rduniq} and @code{wruniq}
16000 PAL calls, but when invoked with @option{-mtls-kernel}, they invoke
16001 @code{rdval} and @code{wrval}.
16003 @smallexample
16004 void *__builtin_thread_pointer (void);
16005 void __builtin_set_thread_pointer (void *);
16006 @end smallexample
16008 @node Altera Nios II Built-in Functions
16009 @subsection Altera Nios II Built-in Functions
16011 These built-in functions are available for the Altera Nios II
16012 family of processors.
16014 The following built-in functions are always available.  They
16015 all generate the machine instruction that is part of the name.
16017 @example
16018 int __builtin_ldbio (volatile const void *);
16019 int __builtin_ldbuio (volatile const void *);
16020 int __builtin_ldhio (volatile const void *);
16021 int __builtin_ldhuio (volatile const void *);
16022 int __builtin_ldwio (volatile const void *);
16023 void __builtin_stbio (volatile void *, int);
16024 void __builtin_sthio (volatile void *, int);
16025 void __builtin_stwio (volatile void *, int);
16026 void __builtin_sync (void);
16027 int __builtin_rdctl (int);
16028 int __builtin_rdprs (int, int);
16029 void __builtin_wrctl (int, int);
16030 void __builtin_flushd (volatile void *);
16031 void __builtin_flushda (volatile void *);
16032 int __builtin_wrpie (int);
16033 void __builtin_eni (int);
16034 int __builtin_ldex (volatile const void *);
16035 int __builtin_stex (volatile void *, int);
16036 int __builtin_ldsex (volatile const void *);
16037 int __builtin_stsex (volatile void *, int);
16038 @end example
16040 The following built-in functions are always available.  They
16041 all generate a Nios II Custom Instruction. The name of the
16042 function represents the types that the function takes and
16043 returns. The letter before the @code{n} is the return type
16044 or void if absent. The @code{n} represents the first parameter
16045 to all the custom instructions, the custom instruction number.
16046 The two letters after the @code{n} represent the up to two
16047 parameters to the function.
16049 The letters represent the following data types:
16050 @table @code
16051 @item <no letter>
16052 @code{void} for return type and no parameter for parameter types.
16054 @item i
16055 @code{int} for return type and parameter type
16057 @item f
16058 @code{float} for return type and parameter type
16060 @item p
16061 @code{void *} for return type and parameter type
16063 @end table
16065 And the function names are:
16066 @example
16067 void __builtin_custom_n (void);
16068 void __builtin_custom_ni (int);
16069 void __builtin_custom_nf (float);
16070 void __builtin_custom_np (void *);
16071 void __builtin_custom_nii (int, int);
16072 void __builtin_custom_nif (int, float);
16073 void __builtin_custom_nip (int, void *);
16074 void __builtin_custom_nfi (float, int);
16075 void __builtin_custom_nff (float, float);
16076 void __builtin_custom_nfp (float, void *);
16077 void __builtin_custom_npi (void *, int);
16078 void __builtin_custom_npf (void *, float);
16079 void __builtin_custom_npp (void *, void *);
16080 int __builtin_custom_in (void);
16081 int __builtin_custom_ini (int);
16082 int __builtin_custom_inf (float);
16083 int __builtin_custom_inp (void *);
16084 int __builtin_custom_inii (int, int);
16085 int __builtin_custom_inif (int, float);
16086 int __builtin_custom_inip (int, void *);
16087 int __builtin_custom_infi (float, int);
16088 int __builtin_custom_inff (float, float);
16089 int __builtin_custom_infp (float, void *);
16090 int __builtin_custom_inpi (void *, int);
16091 int __builtin_custom_inpf (void *, float);
16092 int __builtin_custom_inpp (void *, void *);
16093 float __builtin_custom_fn (void);
16094 float __builtin_custom_fni (int);
16095 float __builtin_custom_fnf (float);
16096 float __builtin_custom_fnp (void *);
16097 float __builtin_custom_fnii (int, int);
16098 float __builtin_custom_fnif (int, float);
16099 float __builtin_custom_fnip (int, void *);
16100 float __builtin_custom_fnfi (float, int);
16101 float __builtin_custom_fnff (float, float);
16102 float __builtin_custom_fnfp (float, void *);
16103 float __builtin_custom_fnpi (void *, int);
16104 float __builtin_custom_fnpf (void *, float);
16105 float __builtin_custom_fnpp (void *, void *);
16106 void * __builtin_custom_pn (void);
16107 void * __builtin_custom_pni (int);
16108 void * __builtin_custom_pnf (float);
16109 void * __builtin_custom_pnp (void *);
16110 void * __builtin_custom_pnii (int, int);
16111 void * __builtin_custom_pnif (int, float);
16112 void * __builtin_custom_pnip (int, void *);
16113 void * __builtin_custom_pnfi (float, int);
16114 void * __builtin_custom_pnff (float, float);
16115 void * __builtin_custom_pnfp (float, void *);
16116 void * __builtin_custom_pnpi (void *, int);
16117 void * __builtin_custom_pnpf (void *, float);
16118 void * __builtin_custom_pnpp (void *, void *);
16119 @end example
16121 @node ARC Built-in Functions
16122 @subsection ARC Built-in Functions
16124 The following built-in functions are provided for ARC targets.  The
16125 built-ins generate the corresponding assembly instructions.  In the
16126 examples given below, the generated code often requires an operand or
16127 result to be in a register.  Where necessary further code will be
16128 generated to ensure this is true, but for brevity this is not
16129 described in each case.
16131 @emph{Note:} Using a built-in to generate an instruction not supported
16132 by a target may cause problems. At present the compiler is not
16133 guaranteed to detect such misuse, and as a result an internal compiler
16134 error may be generated.
16136 @defbuiltin{int __builtin_arc_aligned (void *@var{val}, int @var{alignval})}
16137 Return 1 if @var{val} is known to have the byte alignment given
16138 by @var{alignval}, otherwise return 0.
16139 Note that this is different from
16140 @smallexample
16141 __alignof__(*(char *)@var{val}) >= alignval
16142 @end smallexample
16143 because __alignof__ sees only the type of the dereference, whereas
16144 __builtin_arc_align uses alignment information from the pointer
16145 as well as from the pointed-to type.
16146 The information available will depend on optimization level.
16147 @enddefbuiltin
16149 @defbuiltin{void __builtin_arc_brk (void)}
16150 Generates
16151 @example
16153 @end example
16154 @enddefbuiltin
16156 @defbuiltin{{unsigned int} __builtin_arc_core_read (unsigned int @var{regno})}
16157 The operand is the number of a register to be read.  Generates:
16158 @example
16159 mov  @var{dest}, r@var{regno}
16160 @end example
16161 where the value in @var{dest} will be the result returned from the
16162 built-in.
16163 @enddefbuiltin
16165 @defbuiltin{void __builtin_arc_core_write (unsigned int @var{regno}, unsigned int @var{val})}
16166 The first operand is the number of a register to be written, the
16167 second operand is a compile time constant to write into that
16168 register.  Generates:
16169 @example
16170 mov  r@var{regno}, @var{val}
16171 @end example
16172 @enddefbuiltin
16174 @defbuiltin{int __builtin_arc_divaw (int @var{a}, int @var{b})}
16175 Only available if either @option{-mcpu=ARC700} or @option{-meA} is set.
16176 Generates:
16177 @example
16178 divaw  @var{dest}, @var{a}, @var{b}
16179 @end example
16180 where the value in @var{dest} will be the result returned from the
16181 built-in.
16182 @enddefbuiltin
16184 @defbuiltin{void __builtin_arc_flag (unsigned int @var{a})}
16185 Generates
16186 @example
16187 flag  @var{a}
16188 @end example
16189 @enddefbuiltin
16191 @defbuiltin{{unsigned int} __builtin_arc_lr (unsigned int @var{auxr})}
16192 The operand, @var{auxv}, is the address of an auxiliary register and
16193 must be a compile time constant.  Generates:
16194 @example
16195 lr  @var{dest}, [@var{auxr}]
16196 @end example
16197 Where the value in @var{dest} will be the result returned from the
16198 built-in.
16199 @enddefbuiltin
16201 @defbuiltin{void __builtin_arc_mul64 (int @var{a}, int @var{b})}
16202 Only available with @option{-mmul64}.  Generates:
16203 @example
16204 mul64  @var{a}, @var{b}
16205 @end example
16206 @enddefbuiltin
16208 @defbuiltin{void __builtin_arc_mulu64 (unsigned int @var{a}, unsigned int @var{b})}
16209 Only available with @option{-mmul64}.  Generates:
16210 @example
16211 mulu64  @var{a}, @var{b}
16212 @end example
16213 @enddefbuiltin
16215 @defbuiltin{void __builtin_arc_nop (void)}
16216 Generates:
16217 @example
16219 @end example
16220 @enddefbuiltin
16222 @defbuiltin{int __builtin_arc_norm (int @var{src})}
16223 Only valid if the @samp{norm} instruction is available through the
16224 @option{-mnorm} option or by default with @option{-mcpu=ARC700}.
16225 Generates:
16226 @example
16227 norm  @var{dest}, @var{src}
16228 @end example
16229 Where the value in @var{dest} will be the result returned from the
16230 built-in.
16231 @enddefbuiltin
16233 @defbuiltin{{short int} __builtin_arc_normw (short int @var{src})}
16234 Only valid if the @samp{normw} instruction is available through the
16235 @option{-mnorm} option or by default with @option{-mcpu=ARC700}.
16236 Generates:
16237 @example
16238 normw  @var{dest}, @var{src}
16239 @end example
16240 Where the value in @var{dest} will be the result returned from the
16241 built-in.
16242 @enddefbuiltin
16244 @defbuiltin{void __builtin_arc_rtie (void)}
16245 Generates:
16246 @example
16247 rtie
16248 @end example
16249 @enddefbuiltin
16251 @defbuiltin{void __builtin_arc_sleep (int @var{a}}
16252 Generates:
16253 @example
16254 sleep  @var{a}
16255 @end example
16256 @enddefbuiltin
16258 @defbuiltin{void __builtin_arc_sr (unsigned int @var{val}, unsigned int @var{auxr})}
16259 The first argument, @var{val}, is a compile time constant to be
16260 written to the register, the second argument, @var{auxr}, is the
16261 address of an auxiliary register.  Generates:
16262 @example
16263 sr  @var{val}, [@var{auxr}]
16264 @end example
16265 @enddefbuiltin
16267 @defbuiltin{int __builtin_arc_swap (int @var{src})}
16268 Only valid with @option{-mswap}.  Generates:
16269 @example
16270 swap  @var{dest}, @var{src}
16271 @end example
16272 Where the value in @var{dest} will be the result returned from the
16273 built-in.
16274 @enddefbuiltin
16276 @defbuiltin{void __builtin_arc_swi (void)}
16277 Generates:
16278 @example
16280 @end example
16281 @enddefbuiltin
16283 @defbuiltin{void __builtin_arc_sync (void)}
16284 Only available with @option{-mcpu=ARC700}.  Generates:
16285 @example
16286 sync
16287 @end example
16288 @enddefbuiltin
16290 @defbuiltin{void __builtin_arc_trap_s (unsigned int @var{c})}
16291 Only available with @option{-mcpu=ARC700}.  Generates:
16292 @example
16293 trap_s  @var{c}
16294 @end example
16295 @enddefbuiltin
16297 @defbuiltin{void __builtin_arc_unimp_s (void)}
16298 Only available with @option{-mcpu=ARC700}.  Generates:
16299 @example
16300 unimp_s
16301 @end example
16302 @enddefbuiltin
16304 The instructions generated by the following builtins are not
16305 considered as candidates for scheduling.  They are not moved around by
16306 the compiler during scheduling, and thus can be expected to appear
16307 where they are put in the C code:
16308 @example
16309 __builtin_arc_brk()
16310 __builtin_arc_core_read()
16311 __builtin_arc_core_write()
16312 __builtin_arc_flag()
16313 __builtin_arc_lr()
16314 __builtin_arc_sleep()
16315 __builtin_arc_sr()
16316 __builtin_arc_swi()
16317 @end example
16319 The following built-in functions are available for the ARCv2 family of
16320 processors.
16322 @example
16323 int __builtin_arc_clri ();
16324 void __builtin_arc_kflag (unsigned);
16325 void __builtin_arc_seti (int);
16326 @end example
16328 The following built-in functions are available for the ARCv2 family
16329 and uses @option{-mnorm}.
16331 @example
16332 int __builtin_arc_ffs (int);
16333 int __builtin_arc_fls (int);
16334 @end example
16336 @node ARC SIMD Built-in Functions
16337 @subsection ARC SIMD Built-in Functions
16339 SIMD builtins provided by the compiler can be used to generate the
16340 vector instructions.  This section describes the available builtins
16341 and their usage in programs.  With the @option{-msimd} option, the
16342 compiler provides 128-bit vector types, which can be specified using
16343 the @code{vector_size} attribute.  The header file @file{arc-simd.h}
16344 can be included to use the following predefined types:
16345 @example
16346 typedef int __v4si   __attribute__((vector_size(16)));
16347 typedef short __v8hi __attribute__((vector_size(16)));
16348 @end example
16350 These types can be used to define 128-bit variables.  The built-in
16351 functions listed in the following section can be used on these
16352 variables to generate the vector operations.
16354 For all builtins, @code{__builtin_arc_@var{someinsn}}, the header file
16355 @file{arc-simd.h} also provides equivalent macros called
16356 @code{_@var{someinsn}} that can be used for programming ease and
16357 improved readability.  The following macros for DMA control are also
16358 provided:
16359 @example
16360 #define _setup_dma_in_channel_reg _vdiwr
16361 #define _setup_dma_out_channel_reg _vdowr
16362 @end example
16364 The following is a complete list of all the SIMD built-ins provided
16365 for ARC, grouped by calling signature.
16367 The following take two @code{__v8hi} arguments and return a
16368 @code{__v8hi} result:
16369 @example
16370 __v8hi __builtin_arc_vaddaw (__v8hi, __v8hi);
16371 __v8hi __builtin_arc_vaddw (__v8hi, __v8hi);
16372 __v8hi __builtin_arc_vand (__v8hi, __v8hi);
16373 __v8hi __builtin_arc_vandaw (__v8hi, __v8hi);
16374 __v8hi __builtin_arc_vavb (__v8hi, __v8hi);
16375 __v8hi __builtin_arc_vavrb (__v8hi, __v8hi);
16376 __v8hi __builtin_arc_vbic (__v8hi, __v8hi);
16377 __v8hi __builtin_arc_vbicaw (__v8hi, __v8hi);
16378 __v8hi __builtin_arc_vdifaw (__v8hi, __v8hi);
16379 __v8hi __builtin_arc_vdifw (__v8hi, __v8hi);
16380 __v8hi __builtin_arc_veqw (__v8hi, __v8hi);
16381 __v8hi __builtin_arc_vh264f (__v8hi, __v8hi);
16382 __v8hi __builtin_arc_vh264ft (__v8hi, __v8hi);
16383 __v8hi __builtin_arc_vh264fw (__v8hi, __v8hi);
16384 __v8hi __builtin_arc_vlew (__v8hi, __v8hi);
16385 __v8hi __builtin_arc_vltw (__v8hi, __v8hi);
16386 __v8hi __builtin_arc_vmaxaw (__v8hi, __v8hi);
16387 __v8hi __builtin_arc_vmaxw (__v8hi, __v8hi);
16388 __v8hi __builtin_arc_vminaw (__v8hi, __v8hi);
16389 __v8hi __builtin_arc_vminw (__v8hi, __v8hi);
16390 __v8hi __builtin_arc_vmr1aw (__v8hi, __v8hi);
16391 __v8hi __builtin_arc_vmr1w (__v8hi, __v8hi);
16392 __v8hi __builtin_arc_vmr2aw (__v8hi, __v8hi);
16393 __v8hi __builtin_arc_vmr2w (__v8hi, __v8hi);
16394 __v8hi __builtin_arc_vmr3aw (__v8hi, __v8hi);
16395 __v8hi __builtin_arc_vmr3w (__v8hi, __v8hi);
16396 __v8hi __builtin_arc_vmr4aw (__v8hi, __v8hi);
16397 __v8hi __builtin_arc_vmr4w (__v8hi, __v8hi);
16398 __v8hi __builtin_arc_vmr5aw (__v8hi, __v8hi);
16399 __v8hi __builtin_arc_vmr5w (__v8hi, __v8hi);
16400 __v8hi __builtin_arc_vmr6aw (__v8hi, __v8hi);
16401 __v8hi __builtin_arc_vmr6w (__v8hi, __v8hi);
16402 __v8hi __builtin_arc_vmr7aw (__v8hi, __v8hi);
16403 __v8hi __builtin_arc_vmr7w (__v8hi, __v8hi);
16404 __v8hi __builtin_arc_vmrb (__v8hi, __v8hi);
16405 __v8hi __builtin_arc_vmulaw (__v8hi, __v8hi);
16406 __v8hi __builtin_arc_vmulfaw (__v8hi, __v8hi);
16407 __v8hi __builtin_arc_vmulfw (__v8hi, __v8hi);
16408 __v8hi __builtin_arc_vmulw (__v8hi, __v8hi);
16409 __v8hi __builtin_arc_vnew (__v8hi, __v8hi);
16410 __v8hi __builtin_arc_vor (__v8hi, __v8hi);
16411 __v8hi __builtin_arc_vsubaw (__v8hi, __v8hi);
16412 __v8hi __builtin_arc_vsubw (__v8hi, __v8hi);
16413 __v8hi __builtin_arc_vsummw (__v8hi, __v8hi);
16414 __v8hi __builtin_arc_vvc1f (__v8hi, __v8hi);
16415 __v8hi __builtin_arc_vvc1ft (__v8hi, __v8hi);
16416 __v8hi __builtin_arc_vxor (__v8hi, __v8hi);
16417 __v8hi __builtin_arc_vxoraw (__v8hi, __v8hi);
16418 @end example
16420 The following take one @code{__v8hi} and one @code{int} argument and return a
16421 @code{__v8hi} result:
16423 @example
16424 __v8hi __builtin_arc_vbaddw (__v8hi, int);
16425 __v8hi __builtin_arc_vbmaxw (__v8hi, int);
16426 __v8hi __builtin_arc_vbminw (__v8hi, int);
16427 __v8hi __builtin_arc_vbmulaw (__v8hi, int);
16428 __v8hi __builtin_arc_vbmulfw (__v8hi, int);
16429 __v8hi __builtin_arc_vbmulw (__v8hi, int);
16430 __v8hi __builtin_arc_vbrsubw (__v8hi, int);
16431 __v8hi __builtin_arc_vbsubw (__v8hi, int);
16432 @end example
16434 The following take one @code{__v8hi} argument and one @code{int} argument which
16435 must be a 3-bit compile time constant indicating a register number
16436 I0-I7.  They return a @code{__v8hi} result.
16437 @example
16438 __v8hi __builtin_arc_vasrw (__v8hi, const int);
16439 __v8hi __builtin_arc_vsr8 (__v8hi, const int);
16440 __v8hi __builtin_arc_vsr8aw (__v8hi, const int);
16441 @end example
16443 The following take one @code{__v8hi} argument and one @code{int}
16444 argument which must be a 6-bit compile time constant.  They return a
16445 @code{__v8hi} result.
16446 @example
16447 __v8hi __builtin_arc_vasrpwbi (__v8hi, const int);
16448 __v8hi __builtin_arc_vasrrpwbi (__v8hi, const int);
16449 __v8hi __builtin_arc_vasrrwi (__v8hi, const int);
16450 __v8hi __builtin_arc_vasrsrwi (__v8hi, const int);
16451 __v8hi __builtin_arc_vasrwi (__v8hi, const int);
16452 __v8hi __builtin_arc_vsr8awi (__v8hi, const int);
16453 __v8hi __builtin_arc_vsr8i (__v8hi, const int);
16454 @end example
16456 The following take one @code{__v8hi} argument and one @code{int} argument which
16457 must be a 8-bit compile time constant.  They return a @code{__v8hi}
16458 result.
16459 @example
16460 __v8hi __builtin_arc_vd6tapf (__v8hi, const int);
16461 __v8hi __builtin_arc_vmvaw (__v8hi, const int);
16462 __v8hi __builtin_arc_vmvw (__v8hi, const int);
16463 __v8hi __builtin_arc_vmvzw (__v8hi, const int);
16464 @end example
16466 The following take two @code{int} arguments, the second of which which
16467 must be a 8-bit compile time constant.  They return a @code{__v8hi}
16468 result:
16469 @example
16470 __v8hi __builtin_arc_vmovaw (int, const int);
16471 __v8hi __builtin_arc_vmovw (int, const int);
16472 __v8hi __builtin_arc_vmovzw (int, const int);
16473 @end example
16475 The following take a single @code{__v8hi} argument and return a
16476 @code{__v8hi} result:
16477 @example
16478 __v8hi __builtin_arc_vabsaw (__v8hi);
16479 __v8hi __builtin_arc_vabsw (__v8hi);
16480 __v8hi __builtin_arc_vaddsuw (__v8hi);
16481 __v8hi __builtin_arc_vexch1 (__v8hi);
16482 __v8hi __builtin_arc_vexch2 (__v8hi);
16483 __v8hi __builtin_arc_vexch4 (__v8hi);
16484 __v8hi __builtin_arc_vsignw (__v8hi);
16485 __v8hi __builtin_arc_vupbaw (__v8hi);
16486 __v8hi __builtin_arc_vupbw (__v8hi);
16487 __v8hi __builtin_arc_vupsbaw (__v8hi);
16488 __v8hi __builtin_arc_vupsbw (__v8hi);
16489 @end example
16491 The following take two @code{int} arguments and return no result:
16492 @example
16493 void __builtin_arc_vdirun (int, int);
16494 void __builtin_arc_vdorun (int, int);
16495 @end example
16497 The following take two @code{int} arguments and return no result.  The
16498 first argument must a 3-bit compile time constant indicating one of
16499 the DR0-DR7 DMA setup channels:
16500 @example
16501 void __builtin_arc_vdiwr (const int, int);
16502 void __builtin_arc_vdowr (const int, int);
16503 @end example
16505 The following take an @code{int} argument and return no result:
16506 @example
16507 void __builtin_arc_vendrec (int);
16508 void __builtin_arc_vrec (int);
16509 void __builtin_arc_vrecrun (int);
16510 void __builtin_arc_vrun (int);
16511 @end example
16513 The following take a @code{__v8hi} argument and two @code{int}
16514 arguments and return a @code{__v8hi} result.  The second argument must
16515 be a 3-bit compile time constants, indicating one the registers I0-I7,
16516 and the third argument must be an 8-bit compile time constant.
16518 @emph{Note:} Although the equivalent hardware instructions do not take
16519 an SIMD register as an operand, these builtins overwrite the relevant
16520 bits of the @code{__v8hi} register provided as the first argument with
16521 the value loaded from the @code{[Ib, u8]} location in the SDM.
16523 @example
16524 __v8hi __builtin_arc_vld32 (__v8hi, const int, const int);
16525 __v8hi __builtin_arc_vld32wh (__v8hi, const int, const int);
16526 __v8hi __builtin_arc_vld32wl (__v8hi, const int, const int);
16527 __v8hi __builtin_arc_vld64 (__v8hi, const int, const int);
16528 @end example
16530 The following take two @code{int} arguments and return a @code{__v8hi}
16531 result.  The first argument must be a 3-bit compile time constants,
16532 indicating one the registers I0-I7, and the second argument must be an
16533 8-bit compile time constant.
16535 @example
16536 __v8hi __builtin_arc_vld128 (const int, const int);
16537 __v8hi __builtin_arc_vld64w (const int, const int);
16538 @end example
16540 The following take a @code{__v8hi} argument and two @code{int}
16541 arguments and return no result.  The second argument must be a 3-bit
16542 compile time constants, indicating one the registers I0-I7, and the
16543 third argument must be an 8-bit compile time constant.
16545 @example
16546 void __builtin_arc_vst128 (__v8hi, const int, const int);
16547 void __builtin_arc_vst64 (__v8hi, const int, const int);
16548 @end example
16550 The following take a @code{__v8hi} argument and three @code{int}
16551 arguments and return no result.  The second argument must be a 3-bit
16552 compile-time constant, identifying the 16-bit sub-register to be
16553 stored, the third argument must be a 3-bit compile time constants,
16554 indicating one the registers I0-I7, and the fourth argument must be an
16555 8-bit compile time constant.
16557 @example
16558 void __builtin_arc_vst16_n (__v8hi, const int, const int, const int);
16559 void __builtin_arc_vst32_n (__v8hi, const int, const int, const int);
16560 @end example
16562 The following built-in functions are available on systems that uses
16563 @option{-mmpy-option=6} or higher.
16565 @example
16566 __v2hi __builtin_arc_dmach (__v2hi, __v2hi);
16567 __v2hi __builtin_arc_dmachu (__v2hi, __v2hi);
16568 __v2hi __builtin_arc_dmpyh (__v2hi, __v2hi);
16569 __v2hi __builtin_arc_dmpyhu (__v2hi, __v2hi);
16570 __v2hi __builtin_arc_vaddsub2h (__v2hi, __v2hi);
16571 __v2hi __builtin_arc_vsubadd2h (__v2hi, __v2hi);
16572 @end example
16574 The following built-in functions are available on systems that uses
16575 @option{-mmpy-option=7} or higher.
16577 @example
16578 __v2si __builtin_arc_vmac2h (__v2hi, __v2hi);
16579 __v2si __builtin_arc_vmac2hu (__v2hi, __v2hi);
16580 __v2si __builtin_arc_vmpy2h (__v2hi, __v2hi);
16581 __v2si __builtin_arc_vmpy2hu (__v2hi, __v2hi);
16582 @end example
16584 The following built-in functions are available on systems that uses
16585 @option{-mmpy-option=8} or higher.
16587 @example
16588 long long __builtin_arc_qmach (__v4hi, __v4hi);
16589 long long __builtin_arc_qmachu (__v4hi, __v4hi);
16590 long long __builtin_arc_qmpyh (__v4hi, __v4hi);
16591 long long __builtin_arc_qmpyhu (__v4hi, __v4hi);
16592 long long __builtin_arc_dmacwh (__v2si, __v2hi);
16593 long long __builtin_arc_dmacwhu (__v2si, __v2hi);
16594 _v2si __builtin_arc_vaddsub (__v2si, __v2si);
16595 _v2si __builtin_arc_vsubadd (__v2si, __v2si);
16596 _v4hi __builtin_arc_vaddsub4h (__v4hi, __v4hi);
16597 _v4hi __builtin_arc_vsubadd4h (__v4hi, __v4hi);
16598 @end example
16600 @node ARM iWMMXt Built-in Functions
16601 @subsection ARM iWMMXt Built-in Functions
16603 These built-in functions are available for the ARM family of
16604 processors when the @option{-mcpu=iwmmxt} switch is used:
16606 @smallexample
16607 typedef int v2si __attribute__ ((vector_size (8)));
16608 typedef short v4hi __attribute__ ((vector_size (8)));
16609 typedef char v8qi __attribute__ ((vector_size (8)));
16611 int __builtin_arm_getwcgr0 (void);
16612 void __builtin_arm_setwcgr0 (int);
16613 int __builtin_arm_getwcgr1 (void);
16614 void __builtin_arm_setwcgr1 (int);
16615 int __builtin_arm_getwcgr2 (void);
16616 void __builtin_arm_setwcgr2 (int);
16617 int __builtin_arm_getwcgr3 (void);
16618 void __builtin_arm_setwcgr3 (int);
16619 int __builtin_arm_textrmsb (v8qi, int);
16620 int __builtin_arm_textrmsh (v4hi, int);
16621 int __builtin_arm_textrmsw (v2si, int);
16622 int __builtin_arm_textrmub (v8qi, int);
16623 int __builtin_arm_textrmuh (v4hi, int);
16624 int __builtin_arm_textrmuw (v2si, int);
16625 v8qi __builtin_arm_tinsrb (v8qi, int, int);
16626 v4hi __builtin_arm_tinsrh (v4hi, int, int);
16627 v2si __builtin_arm_tinsrw (v2si, int, int);
16628 long long __builtin_arm_tmia (long long, int, int);
16629 long long __builtin_arm_tmiabb (long long, int, int);
16630 long long __builtin_arm_tmiabt (long long, int, int);
16631 long long __builtin_arm_tmiaph (long long, int, int);
16632 long long __builtin_arm_tmiatb (long long, int, int);
16633 long long __builtin_arm_tmiatt (long long, int, int);
16634 int __builtin_arm_tmovmskb (v8qi);
16635 int __builtin_arm_tmovmskh (v4hi);
16636 int __builtin_arm_tmovmskw (v2si);
16637 long long __builtin_arm_waccb (v8qi);
16638 long long __builtin_arm_wacch (v4hi);
16639 long long __builtin_arm_waccw (v2si);
16640 v8qi __builtin_arm_waddb (v8qi, v8qi);
16641 v8qi __builtin_arm_waddbss (v8qi, v8qi);
16642 v8qi __builtin_arm_waddbus (v8qi, v8qi);
16643 v4hi __builtin_arm_waddh (v4hi, v4hi);
16644 v4hi __builtin_arm_waddhss (v4hi, v4hi);
16645 v4hi __builtin_arm_waddhus (v4hi, v4hi);
16646 v2si __builtin_arm_waddw (v2si, v2si);
16647 v2si __builtin_arm_waddwss (v2si, v2si);
16648 v2si __builtin_arm_waddwus (v2si, v2si);
16649 v8qi __builtin_arm_walign (v8qi, v8qi, int);
16650 long long __builtin_arm_wand(long long, long long);
16651 long long __builtin_arm_wandn (long long, long long);
16652 v8qi __builtin_arm_wavg2b (v8qi, v8qi);
16653 v8qi __builtin_arm_wavg2br (v8qi, v8qi);
16654 v4hi __builtin_arm_wavg2h (v4hi, v4hi);
16655 v4hi __builtin_arm_wavg2hr (v4hi, v4hi);
16656 v8qi __builtin_arm_wcmpeqb (v8qi, v8qi);
16657 v4hi __builtin_arm_wcmpeqh (v4hi, v4hi);
16658 v2si __builtin_arm_wcmpeqw (v2si, v2si);
16659 v8qi __builtin_arm_wcmpgtsb (v8qi, v8qi);
16660 v4hi __builtin_arm_wcmpgtsh (v4hi, v4hi);
16661 v2si __builtin_arm_wcmpgtsw (v2si, v2si);
16662 v8qi __builtin_arm_wcmpgtub (v8qi, v8qi);
16663 v4hi __builtin_arm_wcmpgtuh (v4hi, v4hi);
16664 v2si __builtin_arm_wcmpgtuw (v2si, v2si);
16665 long long __builtin_arm_wmacs (long long, v4hi, v4hi);
16666 long long __builtin_arm_wmacsz (v4hi, v4hi);
16667 long long __builtin_arm_wmacu (long long, v4hi, v4hi);
16668 long long __builtin_arm_wmacuz (v4hi, v4hi);
16669 v4hi __builtin_arm_wmadds (v4hi, v4hi);
16670 v4hi __builtin_arm_wmaddu (v4hi, v4hi);
16671 v8qi __builtin_arm_wmaxsb (v8qi, v8qi);
16672 v4hi __builtin_arm_wmaxsh (v4hi, v4hi);
16673 v2si __builtin_arm_wmaxsw (v2si, v2si);
16674 v8qi __builtin_arm_wmaxub (v8qi, v8qi);
16675 v4hi __builtin_arm_wmaxuh (v4hi, v4hi);
16676 v2si __builtin_arm_wmaxuw (v2si, v2si);
16677 v8qi __builtin_arm_wminsb (v8qi, v8qi);
16678 v4hi __builtin_arm_wminsh (v4hi, v4hi);
16679 v2si __builtin_arm_wminsw (v2si, v2si);
16680 v8qi __builtin_arm_wminub (v8qi, v8qi);
16681 v4hi __builtin_arm_wminuh (v4hi, v4hi);
16682 v2si __builtin_arm_wminuw (v2si, v2si);
16683 v4hi __builtin_arm_wmulsm (v4hi, v4hi);
16684 v4hi __builtin_arm_wmulul (v4hi, v4hi);
16685 v4hi __builtin_arm_wmulum (v4hi, v4hi);
16686 long long __builtin_arm_wor (long long, long long);
16687 v2si __builtin_arm_wpackdss (long long, long long);
16688 v2si __builtin_arm_wpackdus (long long, long long);
16689 v8qi __builtin_arm_wpackhss (v4hi, v4hi);
16690 v8qi __builtin_arm_wpackhus (v4hi, v4hi);
16691 v4hi __builtin_arm_wpackwss (v2si, v2si);
16692 v4hi __builtin_arm_wpackwus (v2si, v2si);
16693 long long __builtin_arm_wrord (long long, long long);
16694 long long __builtin_arm_wrordi (long long, int);
16695 v4hi __builtin_arm_wrorh (v4hi, long long);
16696 v4hi __builtin_arm_wrorhi (v4hi, int);
16697 v2si __builtin_arm_wrorw (v2si, long long);
16698 v2si __builtin_arm_wrorwi (v2si, int);
16699 v2si __builtin_arm_wsadb (v2si, v8qi, v8qi);
16700 v2si __builtin_arm_wsadbz (v8qi, v8qi);
16701 v2si __builtin_arm_wsadh (v2si, v4hi, v4hi);
16702 v2si __builtin_arm_wsadhz (v4hi, v4hi);
16703 v4hi __builtin_arm_wshufh (v4hi, int);
16704 long long __builtin_arm_wslld (long long, long long);
16705 long long __builtin_arm_wslldi (long long, int);
16706 v4hi __builtin_arm_wsllh (v4hi, long long);
16707 v4hi __builtin_arm_wsllhi (v4hi, int);
16708 v2si __builtin_arm_wsllw (v2si, long long);
16709 v2si __builtin_arm_wsllwi (v2si, int);
16710 long long __builtin_arm_wsrad (long long, long long);
16711 long long __builtin_arm_wsradi (long long, int);
16712 v4hi __builtin_arm_wsrah (v4hi, long long);
16713 v4hi __builtin_arm_wsrahi (v4hi, int);
16714 v2si __builtin_arm_wsraw (v2si, long long);
16715 v2si __builtin_arm_wsrawi (v2si, int);
16716 long long __builtin_arm_wsrld (long long, long long);
16717 long long __builtin_arm_wsrldi (long long, int);
16718 v4hi __builtin_arm_wsrlh (v4hi, long long);
16719 v4hi __builtin_arm_wsrlhi (v4hi, int);
16720 v2si __builtin_arm_wsrlw (v2si, long long);
16721 v2si __builtin_arm_wsrlwi (v2si, int);
16722 v8qi __builtin_arm_wsubb (v8qi, v8qi);
16723 v8qi __builtin_arm_wsubbss (v8qi, v8qi);
16724 v8qi __builtin_arm_wsubbus (v8qi, v8qi);
16725 v4hi __builtin_arm_wsubh (v4hi, v4hi);
16726 v4hi __builtin_arm_wsubhss (v4hi, v4hi);
16727 v4hi __builtin_arm_wsubhus (v4hi, v4hi);
16728 v2si __builtin_arm_wsubw (v2si, v2si);
16729 v2si __builtin_arm_wsubwss (v2si, v2si);
16730 v2si __builtin_arm_wsubwus (v2si, v2si);
16731 v4hi __builtin_arm_wunpckehsb (v8qi);
16732 v2si __builtin_arm_wunpckehsh (v4hi);
16733 long long __builtin_arm_wunpckehsw (v2si);
16734 v4hi __builtin_arm_wunpckehub (v8qi);
16735 v2si __builtin_arm_wunpckehuh (v4hi);
16736 long long __builtin_arm_wunpckehuw (v2si);
16737 v4hi __builtin_arm_wunpckelsb (v8qi);
16738 v2si __builtin_arm_wunpckelsh (v4hi);
16739 long long __builtin_arm_wunpckelsw (v2si);
16740 v4hi __builtin_arm_wunpckelub (v8qi);
16741 v2si __builtin_arm_wunpckeluh (v4hi);
16742 long long __builtin_arm_wunpckeluw (v2si);
16743 v8qi __builtin_arm_wunpckihb (v8qi, v8qi);
16744 v4hi __builtin_arm_wunpckihh (v4hi, v4hi);
16745 v2si __builtin_arm_wunpckihw (v2si, v2si);
16746 v8qi __builtin_arm_wunpckilb (v8qi, v8qi);
16747 v4hi __builtin_arm_wunpckilh (v4hi, v4hi);
16748 v2si __builtin_arm_wunpckilw (v2si, v2si);
16749 long long __builtin_arm_wxor (long long, long long);
16750 long long __builtin_arm_wzero ();
16751 @end smallexample
16754 @node ARM C Language Extensions (ACLE)
16755 @subsection ARM C Language Extensions (ACLE)
16757 GCC implements extensions for C as described in the ARM C Language
16758 Extensions (ACLE) specification, which can be found at
16759 @uref{https://developer.arm.com/documentation/ihi0053/latest/}.
16761 As a part of ACLE, GCC implements extensions for Advanced SIMD as described in
16762 the ARM C Language Extensions Specification.  The complete list of Advanced SIMD
16763 intrinsics can be found at
16764 @uref{https://developer.arm.com/documentation/ihi0073/latest/}.
16765 The built-in intrinsics for the Advanced SIMD extension are available when
16766 NEON is enabled.
16768 Currently, ARM and AArch64 back ends do not support ACLE 2.0 fully.  Both
16769 back ends support CRC32 intrinsics and the ARM back end supports the
16770 Coprocessor intrinsics, all from @file{arm_acle.h}.  The ARM back end's 16-bit
16771 floating-point Advanced SIMD intrinsics currently comply to ACLE v1.1.
16772 AArch64's back end does not have support for 16-bit floating point Advanced SIMD
16773 intrinsics yet.
16775 See @ref{ARM Options} and @ref{AArch64 Options} for more information on the
16776 availability of extensions.
16778 @node ARM Floating Point Status and Control Intrinsics
16779 @subsection ARM Floating Point Status and Control Intrinsics
16781 These built-in functions are available for the ARM family of
16782 processors with floating-point unit.
16784 @smallexample
16785 unsigned int __builtin_arm_get_fpscr ();
16786 void __builtin_arm_set_fpscr (unsigned int);
16787 @end smallexample
16789 @node ARM ARMv8-M Security Extensions
16790 @subsection ARM ARMv8-M Security Extensions
16792 GCC implements the ARMv8-M Security Extensions as described in the ARMv8-M
16793 Security Extensions: Requirements on Development Tools Engineering
16794 Specification, which can be found at
16795 @uref{https://developer.arm.com/documentation/ecm0359818/latest/}.
16797 As part of the Security Extensions GCC implements two new function attributes:
16798 @code{cmse_nonsecure_entry} and @code{cmse_nonsecure_call}.
16800 As part of the Security Extensions GCC implements the intrinsics below.  FPTR
16801 is used here to mean any function pointer type.
16803 @smallexample
16804 cmse_address_info_t cmse_TT (void *);
16805 cmse_address_info_t cmse_TT_fptr (FPTR);
16806 cmse_address_info_t cmse_TTT (void *);
16807 cmse_address_info_t cmse_TTT_fptr (FPTR);
16808 cmse_address_info_t cmse_TTA (void *);
16809 cmse_address_info_t cmse_TTA_fptr (FPTR);
16810 cmse_address_info_t cmse_TTAT (void *);
16811 cmse_address_info_t cmse_TTAT_fptr (FPTR);
16812 void * cmse_check_address_range (void *, size_t, int);
16813 typeof(p) cmse_nsfptr_create (FPTR p);
16814 intptr_t cmse_is_nsfptr (FPTR);
16815 int cmse_nonsecure_caller (void);
16816 @end smallexample
16818 @node AVR Built-in Functions
16819 @subsection AVR Built-in Functions
16821 For each built-in function for AVR, there is an equally named,
16822 uppercase built-in macro defined. That way users can easily query if
16823 or if not a specific built-in is implemented or not. For example, if
16824 @code{__builtin_avr_nop} is available the macro
16825 @code{__BUILTIN_AVR_NOP} is defined to @code{1} and undefined otherwise.
16827 @defbuiltin{void __builtin_avr_nop (void)}
16828 @defbuiltinx{void __builtin_avr_sei (void)}
16829 @defbuiltinx{void __builtin_avr_cli (void)}
16830 @defbuiltinx{void __builtin_avr_sleep (void)}
16831 @defbuiltinx{void __builtin_avr_wdr (void)}
16832 @defbuiltinx{uint8_t __builtin_avr_swap (uint8_t)}
16833 @defbuiltinx{uint16_t __builtin_avr_fmul (uint8_t, uint8_t)}
16834 @defbuiltinx{int16_t __builtin_avr_fmuls (int8_t, int8_t)}
16835 @defbuiltinx{int16_t __builtin_avr_fmulsu (int8_t, uint8_t)}
16837 These built-in functions map to the respective machine
16838 instruction, i.e.@: @code{nop}, @code{sei}, @code{cli}, @code{sleep},
16839 @code{wdr}, @code{swap}, @code{fmul}, @code{fmuls}
16840 resp. @code{fmulsu}. The three @code{fmul*} built-ins are implemented
16841 as library call if no hardware multiplier is available.
16842 @enddefbuiltin
16844 @defbuiltin{void __builtin_avr_delay_cycles (uint32_t @var{ticks})}
16845 Delay execution for @var{ticks} cycles. Note that this
16846 built-in does not take into account the effect of interrupts that
16847 might increase delay time. @var{ticks} must be a compile-time
16848 integer constant; delays with a variable number of cycles are not supported.
16849 @enddefbuiltin
16851 @defbuiltin{int8_t __builtin_avr_flash_segment (const __memx void*)}
16852 This built-in takes a byte address to the 24-bit
16853 @ref{AVR Named Address Spaces,address space} @code{__memx} and returns
16854 the number of the flash segment (the 64 KiB chunk) where the address
16855 points to.  Counting starts at @code{0}.
16856 If the address does not point to flash memory, return @code{-1}.
16857 @enddefbuiltin
16859 @defbuiltin{uint8_t __builtin_avr_insert_bits (uint32_t @var{map}, uint8_t @var{bits}, uint8_t @var{val})}
16860 Insert bits from @var{bits} into @var{val} and return the resulting
16861 value. The nibbles of @var{map} determine how the insertion is
16862 performed: Let @var{X} be the @var{n}-th nibble of @var{map}
16863 @enumerate
16864 @item If @var{X} is @code{0xf},
16865 then the @var{n}-th bit of @var{val} is returned unaltered.
16867 @item If X is in the range 0@dots{}7,
16868 then the @var{n}-th result bit is set to the @var{X}-th bit of @var{bits}
16870 @item If X is in the range 8@dots{}@code{0xe},
16871 then the @var{n}-th result bit is undefined.
16872 @end enumerate
16874 @noindent
16875 One typical use case for this built-in is adjusting input and
16876 output values to non-contiguous port layouts. Some examples:
16878 @smallexample
16879 // same as val, bits is unused
16880 __builtin_avr_insert_bits (0xffffffff, bits, val);
16881 @end smallexample
16883 @smallexample
16884 // same as bits, val is unused
16885 __builtin_avr_insert_bits (0x76543210, bits, val);
16886 @end smallexample
16888 @smallexample
16889 // same as rotating bits by 4
16890 __builtin_avr_insert_bits (0x32107654, bits, 0);
16891 @end smallexample
16893 @smallexample
16894 // high nibble of result is the high nibble of val
16895 // low nibble of result is the low nibble of bits
16896 __builtin_avr_insert_bits (0xffff3210, bits, val);
16897 @end smallexample
16899 @smallexample
16900 // reverse the bit order of bits
16901 __builtin_avr_insert_bits (0x01234567, bits, 0);
16902 @end smallexample
16903 @enddefbuiltin
16905 @defbuiltin{void __builtin_avr_nops (uint16_t @var{count})}
16906 Insert @var{count} @code{NOP} instructions.
16907 The number of instructions must be a compile-time integer constant.
16908 @enddefbuiltin
16910 @noindent
16911 There are many more AVR-specific built-in functions that are used to
16912 implement the ISO/IEC TR 18037 ``Embedded C'' fixed-point functions of
16913 section 7.18a.6.  You don't need to use these built-ins directly.
16914 Instead, use the declarations as supplied by the @code{stdfix.h} header
16915 with GNU-C99:
16917 @smallexample
16918 #include <stdfix.h>
16920 // Re-interpret the bit representation of unsigned 16-bit
16921 // integer @var{uval} as Q-format 0.16 value.
16922 unsigned fract get_bits (uint_ur_t uval)
16924     return urbits (uval);
16926 @end smallexample
16928 @node Blackfin Built-in Functions
16929 @subsection Blackfin Built-in Functions
16931 Currently, there are two Blackfin-specific built-in functions.  These are
16932 used for generating @code{CSYNC} and @code{SSYNC} machine insns without
16933 using inline assembly; by using these built-in functions the compiler can
16934 automatically add workarounds for hardware errata involving these
16935 instructions.  These functions are named as follows:
16937 @smallexample
16938 void __builtin_bfin_csync (void);
16939 void __builtin_bfin_ssync (void);
16940 @end smallexample
16942 @node BPF Built-in Functions
16943 @subsection BPF Built-in Functions
16945 The following built-in functions are available for eBPF targets.
16947 @defbuiltin{{unsigned long long} __builtin_bpf_load_byte (unsigned long long @var{offset})}
16948 Load a byte from the @code{struct sk_buff} packet data pointed to by the
16949 register @code{%r6}, and return it.
16950 @enddefbuiltin
16952 @defbuiltin{{unsigned long long} __builtin_bpf_load_half (unsigned long long @var{offset})}
16953 Load 16 bits from the @code{struct sk_buff} packet data pointed to by the
16954 register @code{%r6}, and return it.
16955 @enddefbuiltin
16957 @defbuiltin{{unsigned long long} __builtin_bpf_load_word (unsigned long long @var{offset})}
16958 Load 32 bits from the @code{struct sk_buff} packet data pointed to by the
16959 register @code{%r6}, and return it.
16960 @enddefbuiltin
16962 @defbuiltin{@var{type} __builtin_preserve_access_index (@var{type} @var{expr})}
16963 BPF Compile Once-Run Everywhere (CO-RE) support.  Instruct GCC to
16964 generate CO-RE relocation records for any accesses to aggregate
16965 data structures (struct, union, array types) in @var{expr}.  This builtin
16966 is otherwise transparent; @var{expr} may have any type and its value is
16967 returned.  This builtin has no effect if @code{-mco-re} is not in effect
16968 (either specified or implied).
16969 @enddefbuiltin
16971 @defbuiltin{{unsigned int} __builtin_preserve_field_info (@var{expr}, unsigned int @var{kind})}
16972 BPF Compile Once-Run Everywhere (CO-RE) support. This builtin is used to
16973 extract information to aid in struct/union relocations.  @var{expr} is
16974 an access to a field of a struct or union. Depending on @var{kind}, different
16975 information is returned to the program. A CO-RE relocation for the access in
16976 @var{expr} with kind @var{kind} is recorded if @code{-mco-re} is in effect.
16978 The following values are supported for @var{kind}:
16979 @table @code
16980 @item FIELD_BYTE_OFFSET = 0
16981 The returned value is the offset, in bytes, of the field from the
16982 beginning of the containing structure. For bit-fields, this is the byte offset
16983 of the containing word.
16985 @item FIELD_BYTE_SIZE = 1
16986 The returned value is the size, in bytes, of the field. For bit-fields,
16987 this is the size in bytes of the containing word.
16989 @item FIELD_EXISTENCE = 2
16990 The returned value is 1 if the field exists, 0 otherwise. Always 1 at
16991 compile time.
16993 @item FIELD_SIGNEDNESS = 3
16994 The returned value is 1 if the field is signed, 0 otherwise.
16996 @item FIELD_LSHIFT_U64 = 4
16997 @itemx FIELD_RSHIFT_U64 = 5
16998 The returned value is the number of bits of left- or right-shifting
16999 (respectively) needed in order to recover the original value of the field,
17000 after it has been loaded by a read of @code{FIELD_BYTE_SIZE} bytes into an
17001 unsigned 64-bit value. Primarily useful for reading bit-field values
17002 from structures that may change between kernel versions.
17004 @end table
17006 Note that the return value is a constant which is known at
17007 compile time. If the field has a variable offset then
17008 @code{FIELD_BYTE_OFFSET}, @code{FIELD_LSHIFT_U64},
17009 and @code{FIELD_RSHIFT_U64} are not supported.
17010 Similarly, if the field has a variable size then
17011 @code{FIELD_BYTE_SIZE}, @code{FIELD_LSHIFT_U64},
17012 and @code{FIELD_RSHIFT_U64} are not supported.
17014 For example, @code{__builtin_preserve_field_info} can be used to reliably
17015 extract bit-field values from a structure that may change between
17016 kernel versions:
17018 @smallexample
17019 struct S
17021   short a;
17022   int x:7;
17023   int y:5;
17027 read_y (struct S *arg)
17029   unsigned long long val;
17030   unsigned int offset
17031     = __builtin_preserve_field_info (arg->y, FIELD_BYTE_OFFSET);
17032   unsigned int size
17033     = __builtin_preserve_field_info (arg->y, FIELD_BYTE_SIZE);
17035   /* Read size bytes from arg + offset into val.  */
17036   bpf_probe_read (&val, size, arg + offset);
17038   val <<= __builtin_preserve_field_info (arg->y, FIELD_LSHIFT_U64);
17040   if (__builtin_preserve_field_info (arg->y, FIELD_SIGNEDNESS))
17041     val = ((long long) val
17042            >> __builtin_preserve_field_info (arg->y, FIELD_RSHIFT_U64));
17043   else
17044     val >>= __builtin_preserve_field_info (arg->y, FIELD_RSHIFT_U64);
17046   return val;
17049 @end smallexample
17050 @enddefbuiltin
17052 @defbuiltin{{unsigned int} __builtin_preserve_enum_value (@var{type}, @var{enum}, unsigned int @var{kind})}
17053 BPF Compile Once-Run Everywhere (CO-RE) support. This builtin collects enum
17054 information and creates a CO-RE relocation relative to @var{enum} that should
17055 be of @var{type}.  The @var{kind} specifies the action performed.
17057 The following values are supported for @var{kind}:
17058 @table @code
17059 @item ENUM_VALUE_EXISTS = 0
17060 The return value is either 0 or 1 depending if the enum value exists in the
17061 target.
17063 @item ENUM_VALUE = 1
17064 The return value is the enum value in the target kernel.
17065 @end table
17066 @enddefbuiltin
17068 @defbuiltin{{unsigned int} __builtin_btf_type_id (@var{type}, unsigned int @var{kind})}
17069 BPF Compile Once-Run Everywhere (CO-RE) support. This builtin is used to get
17070 the BTF type ID of a specified @var{type}.
17071 Depending on the @var{kind} argument, it
17072 either returns the ID of the local BTF information, or the BTF type ID in
17073 the target kernel.
17075 The following values are supported for @var{kind}:
17076 @table @code
17077 @item BTF_TYPE_ID_LOCAL = 0
17078 Return the local BTF type ID.  Always succeeds.
17080 @item BTF_TYPE_ID_TARGET = 1
17081 Return the target BTF type ID.  If @var{type} does not exist in the target,
17082 returns 0.
17083 @end table
17084 @enddefbuiltin
17086 @defbuiltin{{unsigned int} __builtin_preserve_type_info (@var{type}, unsigned int @var{kind})}
17087 BPF Compile Once-Run Everywhere (CO-RE) support. This builtin performs named
17088 type (struct/union/enum/typedef) verifications. The type of verification
17089 depends on the @var{kind} argument provided.  This builtin always
17090 returns 0 if @var{type} does not exist in the target kernel.
17092 The following values are supported for @var{kind}:
17093 @table @code
17094 @item BTF_TYPE_EXISTS = 0
17095 Checks if @var{type} exists in the target.
17097 @item BTF_TYPE_MATCHES = 1
17098 Checks if @var{type} matches the local definition in the target kernel.
17100 @item BTF_TYPE_SIZE = 2
17101 Returns the size of the @var{type} within the target.
17102 @end table
17103 @enddefbuiltin
17105 @node FR-V Built-in Functions
17106 @subsection FR-V Built-in Functions
17108 GCC provides many FR-V-specific built-in functions.  In general,
17109 these functions are intended to be compatible with those described
17110 by @cite{FR-V Family, Softune C/C++ Compiler Manual (V6), Fujitsu
17111 Semiconductor}.  The two exceptions are @code{__MDUNPACKH} and
17112 @code{__MBTOHE}, the GCC forms of which pass 128-bit values by
17113 pointer rather than by value.
17115 Most of the functions are named after specific FR-V instructions.
17116 Such functions are said to be ``directly mapped'' and are summarized
17117 here in tabular form.
17119 @menu
17120 * Argument Types::
17121 * Directly-mapped Integer Functions::
17122 * Directly-mapped Media Functions::
17123 * Raw read/write Functions::
17124 * Other Built-in Functions::
17125 @end menu
17127 @node Argument Types
17128 @subsubsection Argument Types
17130 The arguments to the built-in functions can be divided into three groups:
17131 register numbers, compile-time constants and run-time values.  In order
17132 to make this classification clear at a glance, the arguments and return
17133 values are given the following pseudo types:
17135 @multitable @columnfractions .20 .30 .15 .35
17136 @headitem Pseudo type @tab Real C type @tab Constant? @tab Description
17137 @item @code{uh} @tab @code{unsigned short} @tab No @tab an unsigned halfword
17138 @item @code{uw1} @tab @code{unsigned int} @tab No @tab an unsigned word
17139 @item @code{sw1} @tab @code{int} @tab No @tab a signed word
17140 @item @code{uw2} @tab @code{unsigned long long} @tab No
17141 @tab an unsigned doubleword
17142 @item @code{sw2} @tab @code{long long} @tab No @tab a signed doubleword
17143 @item @code{const} @tab @code{int} @tab Yes @tab an integer constant
17144 @item @code{acc} @tab @code{int} @tab Yes @tab an ACC register number
17145 @item @code{iacc} @tab @code{int} @tab Yes @tab an IACC register number
17146 @end multitable
17148 These pseudo types are not defined by GCC, they are simply a notational
17149 convenience used in this manual.
17151 Arguments of type @code{uh}, @code{uw1}, @code{sw1}, @code{uw2}
17152 and @code{sw2} are evaluated at run time.  They correspond to
17153 register operands in the underlying FR-V instructions.
17155 @code{const} arguments represent immediate operands in the underlying
17156 FR-V instructions.  They must be compile-time constants.
17158 @code{acc} arguments are evaluated at compile time and specify the number
17159 of an accumulator register.  For example, an @code{acc} argument of 2
17160 selects the ACC2 register.
17162 @code{iacc} arguments are similar to @code{acc} arguments but specify the
17163 number of an IACC register.  See @pxref{Other Built-in Functions}
17164 for more details.
17166 @node Directly-mapped Integer Functions
17167 @subsubsection Directly-Mapped Integer Functions
17169 The functions listed below map directly to FR-V I-type instructions.
17171 @multitable @columnfractions .45 .32 .23
17172 @headitem Function prototype @tab Example usage @tab Assembly output
17173 @item @code{sw1 __ADDSS (sw1, sw1)}
17174 @tab @code{@var{c} = __ADDSS (@var{a}, @var{b})}
17175 @tab @code{ADDSS @var{a},@var{b},@var{c}}
17176 @item @code{sw1 __SCAN (sw1, sw1)}
17177 @tab @code{@var{c} = __SCAN (@var{a}, @var{b})}
17178 @tab @code{SCAN @var{a},@var{b},@var{c}}
17179 @item @code{sw1 __SCUTSS (sw1)}
17180 @tab @code{@var{b} = __SCUTSS (@var{a})}
17181 @tab @code{SCUTSS @var{a},@var{b}}
17182 @item @code{sw1 __SLASS (sw1, sw1)}
17183 @tab @code{@var{c} = __SLASS (@var{a}, @var{b})}
17184 @tab @code{SLASS @var{a},@var{b},@var{c}}
17185 @item @code{void __SMASS (sw1, sw1)}
17186 @tab @code{__SMASS (@var{a}, @var{b})}
17187 @tab @code{SMASS @var{a},@var{b}}
17188 @item @code{void __SMSSS (sw1, sw1)}
17189 @tab @code{__SMSSS (@var{a}, @var{b})}
17190 @tab @code{SMSSS @var{a},@var{b}}
17191 @item @code{void __SMU (sw1, sw1)}
17192 @tab @code{__SMU (@var{a}, @var{b})}
17193 @tab @code{SMU @var{a},@var{b}}
17194 @item @code{sw2 __SMUL (sw1, sw1)}
17195 @tab @code{@var{c} = __SMUL (@var{a}, @var{b})}
17196 @tab @code{SMUL @var{a},@var{b},@var{c}}
17197 @item @code{sw1 __SUBSS (sw1, sw1)}
17198 @tab @code{@var{c} = __SUBSS (@var{a}, @var{b})}
17199 @tab @code{SUBSS @var{a},@var{b},@var{c}}
17200 @item @code{uw2 __UMUL (uw1, uw1)}
17201 @tab @code{@var{c} = __UMUL (@var{a}, @var{b})}
17202 @tab @code{UMUL @var{a},@var{b},@var{c}}
17203 @end multitable
17205 @node Directly-mapped Media Functions
17206 @subsubsection Directly-Mapped Media Functions
17208 The functions listed below map directly to FR-V M-type instructions.
17210 @multitable @columnfractions .45 .32 .23
17211 @headitem Function prototype @tab Example usage @tab Assembly output
17212 @item @code{uw1 __MABSHS (sw1)}
17213 @tab @code{@var{b} = __MABSHS (@var{a})}
17214 @tab @code{MABSHS @var{a},@var{b}}
17215 @item @code{void __MADDACCS (acc, acc)}
17216 @tab @code{__MADDACCS (@var{b}, @var{a})}
17217 @tab @code{MADDACCS @var{a},@var{b}}
17218 @item @code{sw1 __MADDHSS (sw1, sw1)}
17219 @tab @code{@var{c} = __MADDHSS (@var{a}, @var{b})}
17220 @tab @code{MADDHSS @var{a},@var{b},@var{c}}
17221 @item @code{uw1 __MADDHUS (uw1, uw1)}
17222 @tab @code{@var{c} = __MADDHUS (@var{a}, @var{b})}
17223 @tab @code{MADDHUS @var{a},@var{b},@var{c}}
17224 @item @code{uw1 __MAND (uw1, uw1)}
17225 @tab @code{@var{c} = __MAND (@var{a}, @var{b})}
17226 @tab @code{MAND @var{a},@var{b},@var{c}}
17227 @item @code{void __MASACCS (acc, acc)}
17228 @tab @code{__MASACCS (@var{b}, @var{a})}
17229 @tab @code{MASACCS @var{a},@var{b}}
17230 @item @code{uw1 __MAVEH (uw1, uw1)}
17231 @tab @code{@var{c} = __MAVEH (@var{a}, @var{b})}
17232 @tab @code{MAVEH @var{a},@var{b},@var{c}}
17233 @item @code{uw2 __MBTOH (uw1)}
17234 @tab @code{@var{b} = __MBTOH (@var{a})}
17235 @tab @code{MBTOH @var{a},@var{b}}
17236 @item @code{void __MBTOHE (uw1 *, uw1)}
17237 @tab @code{__MBTOHE (&@var{b}, @var{a})}
17238 @tab @code{MBTOHE @var{a},@var{b}}
17239 @item @code{void __MCLRACC (acc)}
17240 @tab @code{__MCLRACC (@var{a})}
17241 @tab @code{MCLRACC @var{a}}
17242 @item @code{void __MCLRACCA (void)}
17243 @tab @code{__MCLRACCA ()}
17244 @tab @code{MCLRACCA}
17245 @item @code{uw1 __Mcop1 (uw1, uw1)}
17246 @tab @code{@var{c} = __Mcop1 (@var{a}, @var{b})}
17247 @tab @code{Mcop1 @var{a},@var{b},@var{c}}
17248 @item @code{uw1 __Mcop2 (uw1, uw1)}
17249 @tab @code{@var{c} = __Mcop2 (@var{a}, @var{b})}
17250 @tab @code{Mcop2 @var{a},@var{b},@var{c}}
17251 @item @code{uw1 __MCPLHI (uw2, const)}
17252 @tab @code{@var{c} = __MCPLHI (@var{a}, @var{b})}
17253 @tab @code{MCPLHI @var{a},#@var{b},@var{c}}
17254 @item @code{uw1 __MCPLI (uw2, const)}
17255 @tab @code{@var{c} = __MCPLI (@var{a}, @var{b})}
17256 @tab @code{MCPLI @var{a},#@var{b},@var{c}}
17257 @item @code{void __MCPXIS (acc, sw1, sw1)}
17258 @tab @code{__MCPXIS (@var{c}, @var{a}, @var{b})}
17259 @tab @code{MCPXIS @var{a},@var{b},@var{c}}
17260 @item @code{void __MCPXIU (acc, uw1, uw1)}
17261 @tab @code{__MCPXIU (@var{c}, @var{a}, @var{b})}
17262 @tab @code{MCPXIU @var{a},@var{b},@var{c}}
17263 @item @code{void __MCPXRS (acc, sw1, sw1)}
17264 @tab @code{__MCPXRS (@var{c}, @var{a}, @var{b})}
17265 @tab @code{MCPXRS @var{a},@var{b},@var{c}}
17266 @item @code{void __MCPXRU (acc, uw1, uw1)}
17267 @tab @code{__MCPXRU (@var{c}, @var{a}, @var{b})}
17268 @tab @code{MCPXRU @var{a},@var{b},@var{c}}
17269 @item @code{uw1 __MCUT (acc, uw1)}
17270 @tab @code{@var{c} = __MCUT (@var{a}, @var{b})}
17271 @tab @code{MCUT @var{a},@var{b},@var{c}}
17272 @item @code{uw1 __MCUTSS (acc, sw1)}
17273 @tab @code{@var{c} = __MCUTSS (@var{a}, @var{b})}
17274 @tab @code{MCUTSS @var{a},@var{b},@var{c}}
17275 @item @code{void __MDADDACCS (acc, acc)}
17276 @tab @code{__MDADDACCS (@var{b}, @var{a})}
17277 @tab @code{MDADDACCS @var{a},@var{b}}
17278 @item @code{void __MDASACCS (acc, acc)}
17279 @tab @code{__MDASACCS (@var{b}, @var{a})}
17280 @tab @code{MDASACCS @var{a},@var{b}}
17281 @item @code{uw2 __MDCUTSSI (acc, const)}
17282 @tab @code{@var{c} = __MDCUTSSI (@var{a}, @var{b})}
17283 @tab @code{MDCUTSSI @var{a},#@var{b},@var{c}}
17284 @item @code{uw2 __MDPACKH (uw2, uw2)}
17285 @tab @code{@var{c} = __MDPACKH (@var{a}, @var{b})}
17286 @tab @code{MDPACKH @var{a},@var{b},@var{c}}
17287 @item @code{uw2 __MDROTLI (uw2, const)}
17288 @tab @code{@var{c} = __MDROTLI (@var{a}, @var{b})}
17289 @tab @code{MDROTLI @var{a},#@var{b},@var{c}}
17290 @item @code{void __MDSUBACCS (acc, acc)}
17291 @tab @code{__MDSUBACCS (@var{b}, @var{a})}
17292 @tab @code{MDSUBACCS @var{a},@var{b}}
17293 @item @code{void __MDUNPACKH (uw1 *, uw2)}
17294 @tab @code{__MDUNPACKH (&@var{b}, @var{a})}
17295 @tab @code{MDUNPACKH @var{a},@var{b}}
17296 @item @code{uw2 __MEXPDHD (uw1, const)}
17297 @tab @code{@var{c} = __MEXPDHD (@var{a}, @var{b})}
17298 @tab @code{MEXPDHD @var{a},#@var{b},@var{c}}
17299 @item @code{uw1 __MEXPDHW (uw1, const)}
17300 @tab @code{@var{c} = __MEXPDHW (@var{a}, @var{b})}
17301 @tab @code{MEXPDHW @var{a},#@var{b},@var{c}}
17302 @item @code{uw1 __MHDSETH (uw1, const)}
17303 @tab @code{@var{c} = __MHDSETH (@var{a}, @var{b})}
17304 @tab @code{MHDSETH @var{a},#@var{b},@var{c}}
17305 @item @code{sw1 __MHDSETS (const)}
17306 @tab @code{@var{b} = __MHDSETS (@var{a})}
17307 @tab @code{MHDSETS #@var{a},@var{b}}
17308 @item @code{uw1 __MHSETHIH (uw1, const)}
17309 @tab @code{@var{b} = __MHSETHIH (@var{b}, @var{a})}
17310 @tab @code{MHSETHIH #@var{a},@var{b}}
17311 @item @code{sw1 __MHSETHIS (sw1, const)}
17312 @tab @code{@var{b} = __MHSETHIS (@var{b}, @var{a})}
17313 @tab @code{MHSETHIS #@var{a},@var{b}}
17314 @item @code{uw1 __MHSETLOH (uw1, const)}
17315 @tab @code{@var{b} = __MHSETLOH (@var{b}, @var{a})}
17316 @tab @code{MHSETLOH #@var{a},@var{b}}
17317 @item @code{sw1 __MHSETLOS (sw1, const)}
17318 @tab @code{@var{b} = __MHSETLOS (@var{b}, @var{a})}
17319 @tab @code{MHSETLOS #@var{a},@var{b}}
17320 @item @code{uw1 __MHTOB (uw2)}
17321 @tab @code{@var{b} = __MHTOB (@var{a})}
17322 @tab @code{MHTOB @var{a},@var{b}}
17323 @item @code{void __MMACHS (acc, sw1, sw1)}
17324 @tab @code{__MMACHS (@var{c}, @var{a}, @var{b})}
17325 @tab @code{MMACHS @var{a},@var{b},@var{c}}
17326 @item @code{void __MMACHU (acc, uw1, uw1)}
17327 @tab @code{__MMACHU (@var{c}, @var{a}, @var{b})}
17328 @tab @code{MMACHU @var{a},@var{b},@var{c}}
17329 @item @code{void __MMRDHS (acc, sw1, sw1)}
17330 @tab @code{__MMRDHS (@var{c}, @var{a}, @var{b})}
17331 @tab @code{MMRDHS @var{a},@var{b},@var{c}}
17332 @item @code{void __MMRDHU (acc, uw1, uw1)}
17333 @tab @code{__MMRDHU (@var{c}, @var{a}, @var{b})}
17334 @tab @code{MMRDHU @var{a},@var{b},@var{c}}
17335 @item @code{void __MMULHS (acc, sw1, sw1)}
17336 @tab @code{__MMULHS (@var{c}, @var{a}, @var{b})}
17337 @tab @code{MMULHS @var{a},@var{b},@var{c}}
17338 @item @code{void __MMULHU (acc, uw1, uw1)}
17339 @tab @code{__MMULHU (@var{c}, @var{a}, @var{b})}
17340 @tab @code{MMULHU @var{a},@var{b},@var{c}}
17341 @item @code{void __MMULXHS (acc, sw1, sw1)}
17342 @tab @code{__MMULXHS (@var{c}, @var{a}, @var{b})}
17343 @tab @code{MMULXHS @var{a},@var{b},@var{c}}
17344 @item @code{void __MMULXHU (acc, uw1, uw1)}
17345 @tab @code{__MMULXHU (@var{c}, @var{a}, @var{b})}
17346 @tab @code{MMULXHU @var{a},@var{b},@var{c}}
17347 @item @code{uw1 __MNOT (uw1)}
17348 @tab @code{@var{b} = __MNOT (@var{a})}
17349 @tab @code{MNOT @var{a},@var{b}}
17350 @item @code{uw1 __MOR (uw1, uw1)}
17351 @tab @code{@var{c} = __MOR (@var{a}, @var{b})}
17352 @tab @code{MOR @var{a},@var{b},@var{c}}
17353 @item @code{uw1 __MPACKH (uh, uh)}
17354 @tab @code{@var{c} = __MPACKH (@var{a}, @var{b})}
17355 @tab @code{MPACKH @var{a},@var{b},@var{c}}
17356 @item @code{sw2 __MQADDHSS (sw2, sw2)}
17357 @tab @code{@var{c} = __MQADDHSS (@var{a}, @var{b})}
17358 @tab @code{MQADDHSS @var{a},@var{b},@var{c}}
17359 @item @code{uw2 __MQADDHUS (uw2, uw2)}
17360 @tab @code{@var{c} = __MQADDHUS (@var{a}, @var{b})}
17361 @tab @code{MQADDHUS @var{a},@var{b},@var{c}}
17362 @item @code{void __MQCPXIS (acc, sw2, sw2)}
17363 @tab @code{__MQCPXIS (@var{c}, @var{a}, @var{b})}
17364 @tab @code{MQCPXIS @var{a},@var{b},@var{c}}
17365 @item @code{void __MQCPXIU (acc, uw2, uw2)}
17366 @tab @code{__MQCPXIU (@var{c}, @var{a}, @var{b})}
17367 @tab @code{MQCPXIU @var{a},@var{b},@var{c}}
17368 @item @code{void __MQCPXRS (acc, sw2, sw2)}
17369 @tab @code{__MQCPXRS (@var{c}, @var{a}, @var{b})}
17370 @tab @code{MQCPXRS @var{a},@var{b},@var{c}}
17371 @item @code{void __MQCPXRU (acc, uw2, uw2)}
17372 @tab @code{__MQCPXRU (@var{c}, @var{a}, @var{b})}
17373 @tab @code{MQCPXRU @var{a},@var{b},@var{c}}
17374 @item @code{sw2 __MQLCLRHS (sw2, sw2)}
17375 @tab @code{@var{c} = __MQLCLRHS (@var{a}, @var{b})}
17376 @tab @code{MQLCLRHS @var{a},@var{b},@var{c}}
17377 @item @code{sw2 __MQLMTHS (sw2, sw2)}
17378 @tab @code{@var{c} = __MQLMTHS (@var{a}, @var{b})}
17379 @tab @code{MQLMTHS @var{a},@var{b},@var{c}}
17380 @item @code{void __MQMACHS (acc, sw2, sw2)}
17381 @tab @code{__MQMACHS (@var{c}, @var{a}, @var{b})}
17382 @tab @code{MQMACHS @var{a},@var{b},@var{c}}
17383 @item @code{void __MQMACHU (acc, uw2, uw2)}
17384 @tab @code{__MQMACHU (@var{c}, @var{a}, @var{b})}
17385 @tab @code{MQMACHU @var{a},@var{b},@var{c}}
17386 @item @code{void __MQMACXHS (acc, sw2, sw2)}
17387 @tab @code{__MQMACXHS (@var{c}, @var{a}, @var{b})}
17388 @tab @code{MQMACXHS @var{a},@var{b},@var{c}}
17389 @item @code{void __MQMULHS (acc, sw2, sw2)}
17390 @tab @code{__MQMULHS (@var{c}, @var{a}, @var{b})}
17391 @tab @code{MQMULHS @var{a},@var{b},@var{c}}
17392 @item @code{void __MQMULHU (acc, uw2, uw2)}
17393 @tab @code{__MQMULHU (@var{c}, @var{a}, @var{b})}
17394 @tab @code{MQMULHU @var{a},@var{b},@var{c}}
17395 @item @code{void __MQMULXHS (acc, sw2, sw2)}
17396 @tab @code{__MQMULXHS (@var{c}, @var{a}, @var{b})}
17397 @tab @code{MQMULXHS @var{a},@var{b},@var{c}}
17398 @item @code{void __MQMULXHU (acc, uw2, uw2)}
17399 @tab @code{__MQMULXHU (@var{c}, @var{a}, @var{b})}
17400 @tab @code{MQMULXHU @var{a},@var{b},@var{c}}
17401 @item @code{sw2 __MQSATHS (sw2, sw2)}
17402 @tab @code{@var{c} = __MQSATHS (@var{a}, @var{b})}
17403 @tab @code{MQSATHS @var{a},@var{b},@var{c}}
17404 @item @code{uw2 __MQSLLHI (uw2, int)}
17405 @tab @code{@var{c} = __MQSLLHI (@var{a}, @var{b})}
17406 @tab @code{MQSLLHI @var{a},@var{b},@var{c}}
17407 @item @code{sw2 __MQSRAHI (sw2, int)}
17408 @tab @code{@var{c} = __MQSRAHI (@var{a}, @var{b})}
17409 @tab @code{MQSRAHI @var{a},@var{b},@var{c}}
17410 @item @code{sw2 __MQSUBHSS (sw2, sw2)}
17411 @tab @code{@var{c} = __MQSUBHSS (@var{a}, @var{b})}
17412 @tab @code{MQSUBHSS @var{a},@var{b},@var{c}}
17413 @item @code{uw2 __MQSUBHUS (uw2, uw2)}
17414 @tab @code{@var{c} = __MQSUBHUS (@var{a}, @var{b})}
17415 @tab @code{MQSUBHUS @var{a},@var{b},@var{c}}
17416 @item @code{void __MQXMACHS (acc, sw2, sw2)}
17417 @tab @code{__MQXMACHS (@var{c}, @var{a}, @var{b})}
17418 @tab @code{MQXMACHS @var{a},@var{b},@var{c}}
17419 @item @code{void __MQXMACXHS (acc, sw2, sw2)}
17420 @tab @code{__MQXMACXHS (@var{c}, @var{a}, @var{b})}
17421 @tab @code{MQXMACXHS @var{a},@var{b},@var{c}}
17422 @item @code{uw1 __MRDACC (acc)}
17423 @tab @code{@var{b} = __MRDACC (@var{a})}
17424 @tab @code{MRDACC @var{a},@var{b}}
17425 @item @code{uw1 __MRDACCG (acc)}
17426 @tab @code{@var{b} = __MRDACCG (@var{a})}
17427 @tab @code{MRDACCG @var{a},@var{b}}
17428 @item @code{uw1 __MROTLI (uw1, const)}
17429 @tab @code{@var{c} = __MROTLI (@var{a}, @var{b})}
17430 @tab @code{MROTLI @var{a},#@var{b},@var{c}}
17431 @item @code{uw1 __MROTRI (uw1, const)}
17432 @tab @code{@var{c} = __MROTRI (@var{a}, @var{b})}
17433 @tab @code{MROTRI @var{a},#@var{b},@var{c}}
17434 @item @code{sw1 __MSATHS (sw1, sw1)}
17435 @tab @code{@var{c} = __MSATHS (@var{a}, @var{b})}
17436 @tab @code{MSATHS @var{a},@var{b},@var{c}}
17437 @item @code{uw1 __MSATHU (uw1, uw1)}
17438 @tab @code{@var{c} = __MSATHU (@var{a}, @var{b})}
17439 @tab @code{MSATHU @var{a},@var{b},@var{c}}
17440 @item @code{uw1 __MSLLHI (uw1, const)}
17441 @tab @code{@var{c} = __MSLLHI (@var{a}, @var{b})}
17442 @tab @code{MSLLHI @var{a},#@var{b},@var{c}}
17443 @item @code{sw1 __MSRAHI (sw1, const)}
17444 @tab @code{@var{c} = __MSRAHI (@var{a}, @var{b})}
17445 @tab @code{MSRAHI @var{a},#@var{b},@var{c}}
17446 @item @code{uw1 __MSRLHI (uw1, const)}
17447 @tab @code{@var{c} = __MSRLHI (@var{a}, @var{b})}
17448 @tab @code{MSRLHI @var{a},#@var{b},@var{c}}
17449 @item @code{void __MSUBACCS (acc, acc)}
17450 @tab @code{__MSUBACCS (@var{b}, @var{a})}
17451 @tab @code{MSUBACCS @var{a},@var{b}}
17452 @item @code{sw1 __MSUBHSS (sw1, sw1)}
17453 @tab @code{@var{c} = __MSUBHSS (@var{a}, @var{b})}
17454 @tab @code{MSUBHSS @var{a},@var{b},@var{c}}
17455 @item @code{uw1 __MSUBHUS (uw1, uw1)}
17456 @tab @code{@var{c} = __MSUBHUS (@var{a}, @var{b})}
17457 @tab @code{MSUBHUS @var{a},@var{b},@var{c}}
17458 @item @code{void __MTRAP (void)}
17459 @tab @code{__MTRAP ()}
17460 @tab @code{MTRAP}
17461 @item @code{uw2 __MUNPACKH (uw1)}
17462 @tab @code{@var{b} = __MUNPACKH (@var{a})}
17463 @tab @code{MUNPACKH @var{a},@var{b}}
17464 @item @code{uw1 __MWCUT (uw2, uw1)}
17465 @tab @code{@var{c} = __MWCUT (@var{a}, @var{b})}
17466 @tab @code{MWCUT @var{a},@var{b},@var{c}}
17467 @item @code{void __MWTACC (acc, uw1)}
17468 @tab @code{__MWTACC (@var{b}, @var{a})}
17469 @tab @code{MWTACC @var{a},@var{b}}
17470 @item @code{void __MWTACCG (acc, uw1)}
17471 @tab @code{__MWTACCG (@var{b}, @var{a})}
17472 @tab @code{MWTACCG @var{a},@var{b}}
17473 @item @code{uw1 __MXOR (uw1, uw1)}
17474 @tab @code{@var{c} = __MXOR (@var{a}, @var{b})}
17475 @tab @code{MXOR @var{a},@var{b},@var{c}}
17476 @end multitable
17478 @node Raw read/write Functions
17479 @subsubsection Raw Read/Write Functions
17481 This sections describes built-in functions related to read and write
17482 instructions to access memory.  These functions generate
17483 @code{membar} instructions to flush the I/O load and stores where
17484 appropriate, as described in Fujitsu's manual described above.
17486 @table @code
17488 @item unsigned char __builtin_read8 (void *@var{data})
17489 @item unsigned short __builtin_read16 (void *@var{data})
17490 @item unsigned long __builtin_read32 (void *@var{data})
17491 @item unsigned long long __builtin_read64 (void *@var{data})
17493 @item void __builtin_write8 (void *@var{data}, unsigned char @var{datum})
17494 @item void __builtin_write16 (void *@var{data}, unsigned short @var{datum})
17495 @item void __builtin_write32 (void *@var{data}, unsigned long @var{datum})
17496 @item void __builtin_write64 (void *@var{data}, unsigned long long @var{datum})
17497 @end table
17499 @node Other Built-in Functions
17500 @subsubsection Other Built-in Functions
17502 This section describes built-in functions that are not named after
17503 a specific FR-V instruction.
17505 @table @code
17506 @item sw2 __IACCreadll (iacc @var{reg})
17507 Return the full 64-bit value of IACC0@.  The @var{reg} argument is reserved
17508 for future expansion and must be 0.
17510 @item sw1 __IACCreadl (iacc @var{reg})
17511 Return the value of IACC0H if @var{reg} is 0 and IACC0L if @var{reg} is 1.
17512 Other values of @var{reg} are rejected as invalid.
17514 @item void __IACCsetll (iacc @var{reg}, sw2 @var{x})
17515 Set the full 64-bit value of IACC0 to @var{x}.  The @var{reg} argument
17516 is reserved for future expansion and must be 0.
17518 @item void __IACCsetl (iacc @var{reg}, sw1 @var{x})
17519 Set IACC0H to @var{x} if @var{reg} is 0 and IACC0L to @var{x} if @var{reg}
17520 is 1.  Other values of @var{reg} are rejected as invalid.
17522 @item void __data_prefetch0 (const void *@var{x})
17523 Use the @code{dcpl} instruction to load the contents of address @var{x}
17524 into the data cache.
17526 @item void __data_prefetch (const void *@var{x})
17527 Use the @code{nldub} instruction to load the contents of address @var{x}
17528 into the data cache.  The instruction is issued in slot I1@.
17529 @end table
17531 @node LoongArch Base Built-in Functions
17532 @subsection LoongArch Base Built-in Functions
17534 These built-in functions are available for LoongArch.
17536 Data Type Description:
17537 @itemize
17538 @item @code{imm0_31}, a compile-time constant in range 0 to 31;
17539 @item @code{imm0_16383}, a compile-time constant in range 0 to 16383;
17540 @item @code{imm0_32767}, a compile-time constant in range 0 to 32767;
17541 @item @code{imm_n2048_2047}, a compile-time constant in range -2048 to 2047;
17542 @end itemize
17544 The intrinsics provided are listed below:
17545 @smallexample
17546     unsigned int __builtin_loongarch_movfcsr2gr (imm0_31)
17547     void __builtin_loongarch_movgr2fcsr (imm0_31, unsigned int)
17548     void __builtin_loongarch_cacop_d (imm0_31, unsigned long int, imm_n2048_2047)
17549     unsigned int __builtin_loongarch_cpucfg (unsigned int)
17550     void __builtin_loongarch_asrtle_d (long int, long int)
17551     void __builtin_loongarch_asrtgt_d (long int, long int)
17552     long int __builtin_loongarch_lddir_d (long int, imm0_31)
17553     void __builtin_loongarch_ldpte_d (long int, imm0_31)
17555     int __builtin_loongarch_crc_w_b_w (char, int)
17556     int __builtin_loongarch_crc_w_h_w (short, int)
17557     int __builtin_loongarch_crc_w_w_w (int, int)
17558     int __builtin_loongarch_crc_w_d_w (long int, int)
17559     int __builtin_loongarch_crcc_w_b_w (char, int)
17560     int __builtin_loongarch_crcc_w_h_w (short, int)
17561     int __builtin_loongarch_crcc_w_w_w (int, int)
17562     int __builtin_loongarch_crcc_w_d_w (long int, int)
17564     unsigned int __builtin_loongarch_csrrd_w (imm0_16383)
17565     unsigned int __builtin_loongarch_csrwr_w (unsigned int, imm0_16383)
17566     unsigned int __builtin_loongarch_csrxchg_w (unsigned int, unsigned int, imm0_16383)
17567     unsigned long int __builtin_loongarch_csrrd_d (imm0_16383)
17568     unsigned long int __builtin_loongarch_csrwr_d (unsigned long int, imm0_16383)
17569     unsigned long int __builtin_loongarch_csrxchg_d (unsigned long int, unsigned long int, imm0_16383)
17571     unsigned char __builtin_loongarch_iocsrrd_b (unsigned int)
17572     unsigned short __builtin_loongarch_iocsrrd_h (unsigned int)
17573     unsigned int __builtin_loongarch_iocsrrd_w (unsigned int)
17574     unsigned long int __builtin_loongarch_iocsrrd_d (unsigned int)
17575     void __builtin_loongarch_iocsrwr_b (unsigned char, unsigned int)
17576     void __builtin_loongarch_iocsrwr_h (unsigned short, unsigned int)
17577     void __builtin_loongarch_iocsrwr_w (unsigned int, unsigned int)
17578     void __builtin_loongarch_iocsrwr_d (unsigned long int, unsigned int)
17580     void __builtin_loongarch_dbar (imm0_32767)
17581     void __builtin_loongarch_ibar (imm0_32767)
17583     void __builtin_loongarch_syscall (imm0_32767)
17584     void __builtin_loongarch_break (imm0_32767)
17585 @end smallexample
17587 These instrisic functions are available by using @option{-mfrecipe}.
17588 @smallexample
17589     float __builtin_loongarch_frecipe_s (float);
17590     double  __builtin_loongarch_frecipe_d (double);
17591     float __builtin_loongarch_frsqrte_s (float);
17592     double  __builtin_loongarch_frsqrte_d (double);
17593 @end smallexample
17595 @emph{Note:}Since the control register is divided into 32-bit and 64-bit,
17596 but the access instruction is not distinguished. So GCC renames the control
17597 instructions when implementing intrinsics.
17599 Take the csrrd instruction as an example, built-in functions are implemented as follows:
17600 @smallexample
17601   __builtin_loongarch_csrrd_w  // When reading the 32-bit control register use.
17602   __builtin_loongarch_csrrd_d  // When reading the 64-bit control register use.
17603 @end smallexample
17605 For the convenience of use, the built-in functions are encapsulated,
17606 the encapsulated functions and @code{__drdtime_t, __rdtime_t} are
17607 defined in the @code{larchintrin.h}. So if you call the following
17608 function you need to include @code{larchintrin.h}.
17610 @smallexample
17611      typedef struct drdtime@{
17612             unsigned long dvalue;
17613             unsigned long dtimeid;
17614      @} __drdtime_t;
17616      typedef struct rdtime@{
17617             unsigned int value;
17618             unsigned int timeid;
17619      @} __rdtime_t;
17620 @end smallexample
17622 @smallexample
17623     __drdtime_t __rdtime_d (void)
17624     __rdtime_t  __rdtimel_w (void)
17625     __rdtime_t  __rdtimeh_w (void)
17626     unsigned int  __movfcsr2gr (imm0_31)
17627     void __movgr2fcsr (imm0_31, unsigned int)
17628     void __cacop_d (imm0_31, unsigned long, imm_n2048_2047)
17629     unsigned int  __cpucfg (unsigned int)
17630     void __asrtle_d (long int, long int)
17631     void __asrtgt_d (long int, long int)
17632     long int  __lddir_d (long int, imm0_31)
17633     void __ldpte_d (long int, imm0_31)
17635     int  __crc_w_b_w (char, int)
17636     int  __crc_w_h_w (short, int)
17637     int  __crc_w_w_w (int, int)
17638     int  __crc_w_d_w (long int, int)
17639     int  __crcc_w_b_w (char, int)
17640     int  __crcc_w_h_w (short, int)
17641     int  __crcc_w_w_w (int, int)
17642     int  __crcc_w_d_w (long int, int)
17644     unsigned int  __csrrd_w (imm0_16383)
17645     unsigned int  __csrwr_w (unsigned int, imm0_16383)
17646     unsigned int  __csrxchg_w (unsigned int, unsigned int, imm0_16383)
17647     unsigned long  __csrrd_d (imm0_16383)
17648     unsigned long  __csrwr_d (unsigned long, imm0_16383)
17649     unsigned long  __csrxchg_d (unsigned long, unsigned long, imm0_16383)
17651     unsigned char   __iocsrrd_b (unsigned int)
17652     unsigned short  __iocsrrd_h (unsigned int)
17653     unsigned int  __iocsrrd_w (unsigned int)
17654     unsigned long  __iocsrrd_d (unsigned int)
17655     void __iocsrwr_b (unsigned char, unsigned int)
17656     void __iocsrwr_h (unsigned short, unsigned int)
17657     void __iocsrwr_w (unsigned int, unsigned int)
17658     void __iocsrwr_d (unsigned long, unsigned int)
17660     void __dbar (imm0_32767)
17661     void __ibar (imm0_32767)
17663     void __syscall (imm0_32767)
17664     void __break (imm0_32767)
17665 @end smallexample
17667 These instrisic functions are available by including @code{larchintrin.h} and
17668 using @option{-mfrecipe}.
17669 @smallexample
17670     float __frecipe_s (float);
17671     double __frecipe_d (double);
17672     float __frsqrte_s (float);
17673     double __frsqrte_d (double);
17674 @end smallexample
17676 Additional built-in functions are available for LoongArch family
17677 processors to efficiently use 128-bit floating-point (__float128)
17678 values.
17680 The following are the basic built-in functions supported.
17681 @smallexample
17682 __float128 __builtin_fabsq (__float128);
17683 __float128 __builtin_copysignq (__float128, __float128);
17684 __float128 __builtin_infq (void);
17685 __float128 __builtin_huge_valq (void);
17686 __float128 __builtin_nanq (void);
17687 __float128 __builtin_nansq (void);
17688 @end smallexample
17690 Returns the value that is currently set in the @samp{tp} register.
17691 @smallexample
17692     void * __builtin_thread_pointer (void)
17693 @end smallexample
17695 @node LoongArch SX Vector Intrinsics
17696 @subsection LoongArch SX Vector Intrinsics
17698 GCC provides intrinsics to access the LSX (Loongson SIMD Extension) instructions.
17699 The interface is made available by including @code{<lsxintrin.h>} and using
17700 @option{-mlsx}.
17702 The following vectors typedefs are included in @code{lsxintrin.h}:
17704 @itemize
17705 @item @code{__m128i}, a 128-bit vector of fixed point;
17706 @item @code{__m128}, a 128-bit vector of single precision floating point;
17707 @item @code{__m128d}, a 128-bit vector of double precision floating point.
17708 @end itemize
17710 Instructions and corresponding built-ins may have additional restrictions and/or
17711 input/output values manipulated:
17712 @itemize
17713 @item @code{imm0_1}, an integer literal in range 0 to 1;
17714 @item @code{imm0_3}, an integer literal in range 0 to 3;
17715 @item @code{imm0_7}, an integer literal in range 0 to 7;
17716 @item @code{imm0_15}, an integer literal in range 0 to 15;
17717 @item @code{imm0_31}, an integer literal in range 0 to 31;
17718 @item @code{imm0_63}, an integer literal in range 0 to 63;
17719 @item @code{imm0_127}, an integer literal in range 0 to 127;
17720 @item @code{imm0_255}, an integer literal in range 0 to 255;
17721 @item @code{imm_n16_15}, an integer literal in range -16 to 15;
17722 @item @code{imm_n128_127}, an integer literal in range -128 to 127;
17723 @item @code{imm_n256_255}, an integer literal in range -256 to 255;
17724 @item @code{imm_n512_511}, an integer literal in range -512 to 511;
17725 @item @code{imm_n1024_1023}, an integer literal in range -1024 to 1023;
17726 @item @code{imm_n2048_2047}, an integer literal in range -2048 to 2047.
17727 @end itemize
17729 For convenience, GCC defines functions @code{__lsx_vrepli_@{b/h/w/d@}} and
17730 @code{__lsx_b[n]z_@{v/b/h/w/d@}}, which are implemented as follows:
17732 @smallexample
17733 a. @code{__lsx_vrepli_@{b/h/w/d@}}: Implemented the case where the highest
17734    bit of @code{vldi} instruction @code{i13} is 1.
17736    i13[12] == 1'b0
17737    case i13[11:10] of :
17738      2'b00: __lsx_vrepli_b (imm_n512_511)
17739      2'b01: __lsx_vrepli_h (imm_n512_511)
17740      2'b10: __lsx_vrepli_w (imm_n512_511)
17741      2'b11: __lsx_vrepli_d (imm_n512_511)
17743 b. @code{__lsx_b[n]z_@{v/b/h/w/d@}}: Since the @code{vseteqz} class directive
17744    cannot be used on its own, this function is defined.
17746    _lsx_bz_v  => vseteqz.v + bcnez
17747    _lsx_bnz_v => vsetnez.v + bcnez
17748    _lsx_bz_b  => vsetanyeqz.b + bcnez
17749    _lsx_bz_h  => vsetanyeqz.h + bcnez
17750    _lsx_bz_w  => vsetanyeqz.w + bcnez
17751    _lsx_bz_d  => vsetanyeqz.d + bcnez
17752    _lsx_bnz_b => vsetallnez.b + bcnez
17753    _lsx_bnz_h => vsetallnez.h + bcnez
17754    _lsx_bnz_w => vsetallnez.w + bcnez
17755    _lsx_bnz_d => vsetallnez.d + bcnez
17756 @end smallexample
17758 @smallexample
17760   #include <lsxintrin.h>
17762   extern __m128i @var{a};
17764   void
17765   test (void)
17766   @{
17767     if (__lsx_bz_v (@var{a}))
17768       printf ("1\n");
17769     else
17770       printf ("2\n");
17771   @}
17772 @end smallexample
17774 @emph{Note:} For directives where the intent operand is also the source operand
17775 (modifying only part of the bitfield of the intent register), the first parameter
17776 in the builtin call function is used as the intent operand.
17778 @smallexample
17780   #include <lsxintrin.h>
17782   extern __m128i @var{dst};
17783   extern int @var{src};
17785   void
17786   test (void)
17787   @{
17788     @var{dst} = __lsx_vinsgr2vr_b (@var{dst}, @var{src}, 3);
17789   @}
17790 @end smallexample
17792 The intrinsics provided are listed below:
17793 @smallexample
17794 int __lsx_bnz_b (__m128i);
17795 int __lsx_bnz_d (__m128i);
17796 int __lsx_bnz_h (__m128i);
17797 int __lsx_bnz_v (__m128i);
17798 int __lsx_bnz_w (__m128i);
17799 int __lsx_bz_b (__m128i);
17800 int __lsx_bz_d (__m128i);
17801 int __lsx_bz_h (__m128i);
17802 int __lsx_bz_v (__m128i);
17803 int __lsx_bz_w (__m128i);
17804 __m128i __lsx_vabsd_b (__m128i, __m128i);
17805 __m128i __lsx_vabsd_bu (__m128i, __m128i);
17806 __m128i __lsx_vabsd_d (__m128i, __m128i);
17807 __m128i __lsx_vabsd_du (__m128i, __m128i);
17808 __m128i __lsx_vabsd_h (__m128i, __m128i);
17809 __m128i __lsx_vabsd_hu (__m128i, __m128i);
17810 __m128i __lsx_vabsd_w (__m128i, __m128i);
17811 __m128i __lsx_vabsd_wu (__m128i, __m128i);
17812 __m128i __lsx_vadda_b (__m128i, __m128i);
17813 __m128i __lsx_vadda_d (__m128i, __m128i);
17814 __m128i __lsx_vadda_h (__m128i, __m128i);
17815 __m128i __lsx_vadda_w (__m128i, __m128i);
17816 __m128i __lsx_vadd_b (__m128i, __m128i);
17817 __m128i __lsx_vadd_d (__m128i, __m128i);
17818 __m128i __lsx_vadd_h (__m128i, __m128i);
17819 __m128i __lsx_vaddi_bu (__m128i, imm0_31);
17820 __m128i __lsx_vaddi_du (__m128i, imm0_31);
17821 __m128i __lsx_vaddi_hu (__m128i, imm0_31);
17822 __m128i __lsx_vaddi_wu (__m128i, imm0_31);
17823 __m128i __lsx_vadd_q (__m128i, __m128i);
17824 __m128i __lsx_vadd_w (__m128i, __m128i);
17825 __m128i __lsx_vaddwev_d_w (__m128i, __m128i);
17826 __m128i __lsx_vaddwev_d_wu (__m128i, __m128i);
17827 __m128i __lsx_vaddwev_d_wu_w (__m128i, __m128i);
17828 __m128i __lsx_vaddwev_h_b (__m128i, __m128i);
17829 __m128i __lsx_vaddwev_h_bu (__m128i, __m128i);
17830 __m128i __lsx_vaddwev_h_bu_b (__m128i, __m128i);
17831 __m128i __lsx_vaddwev_q_d (__m128i, __m128i);
17832 __m128i __lsx_vaddwev_q_du (__m128i, __m128i);
17833 __m128i __lsx_vaddwev_q_du_d (__m128i, __m128i);
17834 __m128i __lsx_vaddwev_w_h (__m128i, __m128i);
17835 __m128i __lsx_vaddwev_w_hu (__m128i, __m128i);
17836 __m128i __lsx_vaddwev_w_hu_h (__m128i, __m128i);
17837 __m128i __lsx_vaddwod_d_w (__m128i, __m128i);
17838 __m128i __lsx_vaddwod_d_wu (__m128i, __m128i);
17839 __m128i __lsx_vaddwod_d_wu_w (__m128i, __m128i);
17840 __m128i __lsx_vaddwod_h_b (__m128i, __m128i);
17841 __m128i __lsx_vaddwod_h_bu (__m128i, __m128i);
17842 __m128i __lsx_vaddwod_h_bu_b (__m128i, __m128i);
17843 __m128i __lsx_vaddwod_q_d (__m128i, __m128i);
17844 __m128i __lsx_vaddwod_q_du (__m128i, __m128i);
17845 __m128i __lsx_vaddwod_q_du_d (__m128i, __m128i);
17846 __m128i __lsx_vaddwod_w_h (__m128i, __m128i);
17847 __m128i __lsx_vaddwod_w_hu (__m128i, __m128i);
17848 __m128i __lsx_vaddwod_w_hu_h (__m128i, __m128i);
17849 __m128i __lsx_vandi_b (__m128i, imm0_255);
17850 __m128i __lsx_vandn_v (__m128i, __m128i);
17851 __m128i __lsx_vand_v (__m128i, __m128i);
17852 __m128i __lsx_vavg_b (__m128i, __m128i);
17853 __m128i __lsx_vavg_bu (__m128i, __m128i);
17854 __m128i __lsx_vavg_d (__m128i, __m128i);
17855 __m128i __lsx_vavg_du (__m128i, __m128i);
17856 __m128i __lsx_vavg_h (__m128i, __m128i);
17857 __m128i __lsx_vavg_hu (__m128i, __m128i);
17858 __m128i __lsx_vavgr_b (__m128i, __m128i);
17859 __m128i __lsx_vavgr_bu (__m128i, __m128i);
17860 __m128i __lsx_vavgr_d (__m128i, __m128i);
17861 __m128i __lsx_vavgr_du (__m128i, __m128i);
17862 __m128i __lsx_vavgr_h (__m128i, __m128i);
17863 __m128i __lsx_vavgr_hu (__m128i, __m128i);
17864 __m128i __lsx_vavgr_w (__m128i, __m128i);
17865 __m128i __lsx_vavgr_wu (__m128i, __m128i);
17866 __m128i __lsx_vavg_w (__m128i, __m128i);
17867 __m128i __lsx_vavg_wu (__m128i, __m128i);
17868 __m128i __lsx_vbitclr_b (__m128i, __m128i);
17869 __m128i __lsx_vbitclr_d (__m128i, __m128i);
17870 __m128i __lsx_vbitclr_h (__m128i, __m128i);
17871 __m128i __lsx_vbitclri_b (__m128i, imm0_7);
17872 __m128i __lsx_vbitclri_d (__m128i, imm0_63);
17873 __m128i __lsx_vbitclri_h (__m128i, imm0_15);
17874 __m128i __lsx_vbitclri_w (__m128i, imm0_31);
17875 __m128i __lsx_vbitclr_w (__m128i, __m128i);
17876 __m128i __lsx_vbitrev_b (__m128i, __m128i);
17877 __m128i __lsx_vbitrev_d (__m128i, __m128i);
17878 __m128i __lsx_vbitrev_h (__m128i, __m128i);
17879 __m128i __lsx_vbitrevi_b (__m128i, imm0_7);
17880 __m128i __lsx_vbitrevi_d (__m128i, imm0_63);
17881 __m128i __lsx_vbitrevi_h (__m128i, imm0_15);
17882 __m128i __lsx_vbitrevi_w (__m128i, imm0_31);
17883 __m128i __lsx_vbitrev_w (__m128i, __m128i);
17884 __m128i __lsx_vbitseli_b (__m128i, __m128i, imm0_255);
17885 __m128i __lsx_vbitsel_v (__m128i, __m128i, __m128i);
17886 __m128i __lsx_vbitset_b (__m128i, __m128i);
17887 __m128i __lsx_vbitset_d (__m128i, __m128i);
17888 __m128i __lsx_vbitset_h (__m128i, __m128i);
17889 __m128i __lsx_vbitseti_b (__m128i, imm0_7);
17890 __m128i __lsx_vbitseti_d (__m128i, imm0_63);
17891 __m128i __lsx_vbitseti_h (__m128i, imm0_15);
17892 __m128i __lsx_vbitseti_w (__m128i, imm0_31);
17893 __m128i __lsx_vbitset_w (__m128i, __m128i);
17894 __m128i __lsx_vbsll_v (__m128i, imm0_31);
17895 __m128i __lsx_vbsrl_v (__m128i, imm0_31);
17896 __m128i __lsx_vclo_b (__m128i);
17897 __m128i __lsx_vclo_d (__m128i);
17898 __m128i __lsx_vclo_h (__m128i);
17899 __m128i __lsx_vclo_w (__m128i);
17900 __m128i __lsx_vclz_b (__m128i);
17901 __m128i __lsx_vclz_d (__m128i);
17902 __m128i __lsx_vclz_h (__m128i);
17903 __m128i __lsx_vclz_w (__m128i);
17904 __m128i __lsx_vdiv_b (__m128i, __m128i);
17905 __m128i __lsx_vdiv_bu (__m128i, __m128i);
17906 __m128i __lsx_vdiv_d (__m128i, __m128i);
17907 __m128i __lsx_vdiv_du (__m128i, __m128i);
17908 __m128i __lsx_vdiv_h (__m128i, __m128i);
17909 __m128i __lsx_vdiv_hu (__m128i, __m128i);
17910 __m128i __lsx_vdiv_w (__m128i, __m128i);
17911 __m128i __lsx_vdiv_wu (__m128i, __m128i);
17912 __m128i __lsx_vexth_du_wu (__m128i);
17913 __m128i __lsx_vexth_d_w (__m128i);
17914 __m128i __lsx_vexth_h_b (__m128i);
17915 __m128i __lsx_vexth_hu_bu (__m128i);
17916 __m128i __lsx_vexth_q_d (__m128i);
17917 __m128i __lsx_vexth_qu_du (__m128i);
17918 __m128i __lsx_vexth_w_h (__m128i);
17919 __m128i __lsx_vexth_wu_hu (__m128i);
17920 __m128i __lsx_vextl_q_d (__m128i);
17921 __m128i __lsx_vextl_qu_du (__m128i);
17922 __m128i __lsx_vextrins_b (__m128i, __m128i, imm0_255);
17923 __m128i __lsx_vextrins_d (__m128i, __m128i, imm0_255);
17924 __m128i __lsx_vextrins_h (__m128i, __m128i, imm0_255);
17925 __m128i __lsx_vextrins_w (__m128i, __m128i, imm0_255);
17926 __m128d __lsx_vfadd_d (__m128d, __m128d);
17927 __m128 __lsx_vfadd_s (__m128, __m128);
17928 __m128i __lsx_vfclass_d (__m128d);
17929 __m128i __lsx_vfclass_s (__m128);
17930 __m128i __lsx_vfcmp_caf_d (__m128d, __m128d);
17931 __m128i __lsx_vfcmp_caf_s (__m128, __m128);
17932 __m128i __lsx_vfcmp_ceq_d (__m128d, __m128d);
17933 __m128i __lsx_vfcmp_ceq_s (__m128, __m128);
17934 __m128i __lsx_vfcmp_cle_d (__m128d, __m128d);
17935 __m128i __lsx_vfcmp_cle_s (__m128, __m128);
17936 __m128i __lsx_vfcmp_clt_d (__m128d, __m128d);
17937 __m128i __lsx_vfcmp_clt_s (__m128, __m128);
17938 __m128i __lsx_vfcmp_cne_d (__m128d, __m128d);
17939 __m128i __lsx_vfcmp_cne_s (__m128, __m128);
17940 __m128i __lsx_vfcmp_cor_d (__m128d, __m128d);
17941 __m128i __lsx_vfcmp_cor_s (__m128, __m128);
17942 __m128i __lsx_vfcmp_cueq_d (__m128d, __m128d);
17943 __m128i __lsx_vfcmp_cueq_s (__m128, __m128);
17944 __m128i __lsx_vfcmp_cule_d (__m128d, __m128d);
17945 __m128i __lsx_vfcmp_cule_s (__m128, __m128);
17946 __m128i __lsx_vfcmp_cult_d (__m128d, __m128d);
17947 __m128i __lsx_vfcmp_cult_s (__m128, __m128);
17948 __m128i __lsx_vfcmp_cun_d (__m128d, __m128d);
17949 __m128i __lsx_vfcmp_cune_d (__m128d, __m128d);
17950 __m128i __lsx_vfcmp_cune_s (__m128, __m128);
17951 __m128i __lsx_vfcmp_cun_s (__m128, __m128);
17952 __m128i __lsx_vfcmp_saf_d (__m128d, __m128d);
17953 __m128i __lsx_vfcmp_saf_s (__m128, __m128);
17954 __m128i __lsx_vfcmp_seq_d (__m128d, __m128d);
17955 __m128i __lsx_vfcmp_seq_s (__m128, __m128);
17956 __m128i __lsx_vfcmp_sle_d (__m128d, __m128d);
17957 __m128i __lsx_vfcmp_sle_s (__m128, __m128);
17958 __m128i __lsx_vfcmp_slt_d (__m128d, __m128d);
17959 __m128i __lsx_vfcmp_slt_s (__m128, __m128);
17960 __m128i __lsx_vfcmp_sne_d (__m128d, __m128d);
17961 __m128i __lsx_vfcmp_sne_s (__m128, __m128);
17962 __m128i __lsx_vfcmp_sor_d (__m128d, __m128d);
17963 __m128i __lsx_vfcmp_sor_s (__m128, __m128);
17964 __m128i __lsx_vfcmp_sueq_d (__m128d, __m128d);
17965 __m128i __lsx_vfcmp_sueq_s (__m128, __m128);
17966 __m128i __lsx_vfcmp_sule_d (__m128d, __m128d);
17967 __m128i __lsx_vfcmp_sule_s (__m128, __m128);
17968 __m128i __lsx_vfcmp_sult_d (__m128d, __m128d);
17969 __m128i __lsx_vfcmp_sult_s (__m128, __m128);
17970 __m128i __lsx_vfcmp_sun_d (__m128d, __m128d);
17971 __m128i __lsx_vfcmp_sune_d (__m128d, __m128d);
17972 __m128i __lsx_vfcmp_sune_s (__m128, __m128);
17973 __m128i __lsx_vfcmp_sun_s (__m128, __m128);
17974 __m128d __lsx_vfcvth_d_s (__m128);
17975 __m128i __lsx_vfcvt_h_s (__m128, __m128);
17976 __m128 __lsx_vfcvth_s_h (__m128i);
17977 __m128d __lsx_vfcvtl_d_s (__m128);
17978 __m128 __lsx_vfcvtl_s_h (__m128i);
17979 __m128 __lsx_vfcvt_s_d (__m128d, __m128d);
17980 __m128d __lsx_vfdiv_d (__m128d, __m128d);
17981 __m128 __lsx_vfdiv_s (__m128, __m128);
17982 __m128d __lsx_vffint_d_l (__m128i);
17983 __m128d __lsx_vffint_d_lu (__m128i);
17984 __m128d __lsx_vffinth_d_w (__m128i);
17985 __m128d __lsx_vffintl_d_w (__m128i);
17986 __m128 __lsx_vffint_s_l (__m128i, __m128i);
17987 __m128 __lsx_vffint_s_w (__m128i);
17988 __m128 __lsx_vffint_s_wu (__m128i);
17989 __m128d __lsx_vflogb_d (__m128d);
17990 __m128 __lsx_vflogb_s (__m128);
17991 __m128d __lsx_vfmadd_d (__m128d, __m128d, __m128d);
17992 __m128 __lsx_vfmadd_s (__m128, __m128, __m128);
17993 __m128d __lsx_vfmaxa_d (__m128d, __m128d);
17994 __m128 __lsx_vfmaxa_s (__m128, __m128);
17995 __m128d __lsx_vfmax_d (__m128d, __m128d);
17996 __m128 __lsx_vfmax_s (__m128, __m128);
17997 __m128d __lsx_vfmina_d (__m128d, __m128d);
17998 __m128 __lsx_vfmina_s (__m128, __m128);
17999 __m128d __lsx_vfmin_d (__m128d, __m128d);
18000 __m128 __lsx_vfmin_s (__m128, __m128);
18001 __m128d __lsx_vfmsub_d (__m128d, __m128d, __m128d);
18002 __m128 __lsx_vfmsub_s (__m128, __m128, __m128);
18003 __m128d __lsx_vfmul_d (__m128d, __m128d);
18004 __m128 __lsx_vfmul_s (__m128, __m128);
18005 __m128d __lsx_vfnmadd_d (__m128d, __m128d, __m128d);
18006 __m128 __lsx_vfnmadd_s (__m128, __m128, __m128);
18007 __m128d __lsx_vfnmsub_d (__m128d, __m128d, __m128d);
18008 __m128 __lsx_vfnmsub_s (__m128, __m128, __m128);
18009 __m128d __lsx_vfrecip_d (__m128d);
18010 __m128 __lsx_vfrecip_s (__m128);
18011 __m128d __lsx_vfrint_d (__m128d);
18012 __m128d __lsx_vfrintrm_d (__m128d);
18013 __m128 __lsx_vfrintrm_s (__m128);
18014 __m128d __lsx_vfrintrne_d (__m128d);
18015 __m128 __lsx_vfrintrne_s (__m128);
18016 __m128d __lsx_vfrintrp_d (__m128d);
18017 __m128 __lsx_vfrintrp_s (__m128);
18018 __m128d __lsx_vfrintrz_d (__m128d);
18019 __m128 __lsx_vfrintrz_s (__m128);
18020 __m128 __lsx_vfrint_s (__m128);
18021 __m128d __lsx_vfrsqrt_d (__m128d);
18022 __m128 __lsx_vfrsqrt_s (__m128);
18023 __m128i __lsx_vfrstp_b (__m128i, __m128i, __m128i);
18024 __m128i __lsx_vfrstp_h (__m128i, __m128i, __m128i);
18025 __m128i __lsx_vfrstpi_b (__m128i, __m128i, imm0_31);
18026 __m128i __lsx_vfrstpi_h (__m128i, __m128i, imm0_31);
18027 __m128d __lsx_vfsqrt_d (__m128d);
18028 __m128 __lsx_vfsqrt_s (__m128);
18029 __m128d __lsx_vfsub_d (__m128d, __m128d);
18030 __m128 __lsx_vfsub_s (__m128, __m128);
18031 __m128i __lsx_vftinth_l_s (__m128);
18032 __m128i __lsx_vftint_l_d (__m128d);
18033 __m128i __lsx_vftintl_l_s (__m128);
18034 __m128i __lsx_vftint_lu_d (__m128d);
18035 __m128i __lsx_vftintrmh_l_s (__m128);
18036 __m128i __lsx_vftintrm_l_d (__m128d);
18037 __m128i __lsx_vftintrml_l_s (__m128);
18038 __m128i __lsx_vftintrm_w_d (__m128d, __m128d);
18039 __m128i __lsx_vftintrm_w_s (__m128);
18040 __m128i __lsx_vftintrneh_l_s (__m128);
18041 __m128i __lsx_vftintrne_l_d (__m128d);
18042 __m128i __lsx_vftintrnel_l_s (__m128);
18043 __m128i __lsx_vftintrne_w_d (__m128d, __m128d);
18044 __m128i __lsx_vftintrne_w_s (__m128);
18045 __m128i __lsx_vftintrph_l_s (__m128);
18046 __m128i __lsx_vftintrp_l_d (__m128d);
18047 __m128i __lsx_vftintrpl_l_s (__m128);
18048 __m128i __lsx_vftintrp_w_d (__m128d, __m128d);
18049 __m128i __lsx_vftintrp_w_s (__m128);
18050 __m128i __lsx_vftintrzh_l_s (__m128);
18051 __m128i __lsx_vftintrz_l_d (__m128d);
18052 __m128i __lsx_vftintrzl_l_s (__m128);
18053 __m128i __lsx_vftintrz_lu_d (__m128d);
18054 __m128i __lsx_vftintrz_w_d (__m128d, __m128d);
18055 __m128i __lsx_vftintrz_w_s (__m128);
18056 __m128i __lsx_vftintrz_wu_s (__m128);
18057 __m128i __lsx_vftint_w_d (__m128d, __m128d);
18058 __m128i __lsx_vftint_w_s (__m128);
18059 __m128i __lsx_vftint_wu_s (__m128);
18060 __m128i __lsx_vhaddw_du_wu (__m128i, __m128i);
18061 __m128i __lsx_vhaddw_d_w (__m128i, __m128i);
18062 __m128i __lsx_vhaddw_h_b (__m128i, __m128i);
18063 __m128i __lsx_vhaddw_hu_bu (__m128i, __m128i);
18064 __m128i __lsx_vhaddw_q_d (__m128i, __m128i);
18065 __m128i __lsx_vhaddw_qu_du (__m128i, __m128i);
18066 __m128i __lsx_vhaddw_w_h (__m128i, __m128i);
18067 __m128i __lsx_vhaddw_wu_hu (__m128i, __m128i);
18068 __m128i __lsx_vhsubw_du_wu (__m128i, __m128i);
18069 __m128i __lsx_vhsubw_d_w (__m128i, __m128i);
18070 __m128i __lsx_vhsubw_h_b (__m128i, __m128i);
18071 __m128i __lsx_vhsubw_hu_bu (__m128i, __m128i);
18072 __m128i __lsx_vhsubw_q_d (__m128i, __m128i);
18073 __m128i __lsx_vhsubw_qu_du (__m128i, __m128i);
18074 __m128i __lsx_vhsubw_w_h (__m128i, __m128i);
18075 __m128i __lsx_vhsubw_wu_hu (__m128i, __m128i);
18076 __m128i __lsx_vilvh_b (__m128i, __m128i);
18077 __m128i __lsx_vilvh_d (__m128i, __m128i);
18078 __m128i __lsx_vilvh_h (__m128i, __m128i);
18079 __m128i __lsx_vilvh_w (__m128i, __m128i);
18080 __m128i __lsx_vilvl_b (__m128i, __m128i);
18081 __m128i __lsx_vilvl_d (__m128i, __m128i);
18082 __m128i __lsx_vilvl_h (__m128i, __m128i);
18083 __m128i __lsx_vilvl_w (__m128i, __m128i);
18084 __m128i __lsx_vinsgr2vr_b (__m128i, int, imm0_15);
18085 __m128i __lsx_vinsgr2vr_d (__m128i, long int, imm0_1);
18086 __m128i __lsx_vinsgr2vr_h (__m128i, int, imm0_7);
18087 __m128i __lsx_vinsgr2vr_w (__m128i, int, imm0_3);
18088 __m128i __lsx_vld (void *, imm_n2048_2047);
18089 __m128i __lsx_vldi (imm_n1024_1023);
18090 __m128i __lsx_vldrepl_b (void *, imm_n2048_2047);
18091 __m128i __lsx_vldrepl_d (void *, imm_n256_255);
18092 __m128i __lsx_vldrepl_h (void *, imm_n1024_1023);
18093 __m128i __lsx_vldrepl_w (void *, imm_n512_511);
18094 __m128i __lsx_vldx (void *, long int);
18095 __m128i __lsx_vmadd_b (__m128i, __m128i, __m128i);
18096 __m128i __lsx_vmadd_d (__m128i, __m128i, __m128i);
18097 __m128i __lsx_vmadd_h (__m128i, __m128i, __m128i);
18098 __m128i __lsx_vmadd_w (__m128i, __m128i, __m128i);
18099 __m128i __lsx_vmaddwev_d_w (__m128i, __m128i, __m128i);
18100 __m128i __lsx_vmaddwev_d_wu (__m128i, __m128i, __m128i);
18101 __m128i __lsx_vmaddwev_d_wu_w (__m128i, __m128i, __m128i);
18102 __m128i __lsx_vmaddwev_h_b (__m128i, __m128i, __m128i);
18103 __m128i __lsx_vmaddwev_h_bu (__m128i, __m128i, __m128i);
18104 __m128i __lsx_vmaddwev_h_bu_b (__m128i, __m128i, __m128i);
18105 __m128i __lsx_vmaddwev_q_d (__m128i, __m128i, __m128i);
18106 __m128i __lsx_vmaddwev_q_du (__m128i, __m128i, __m128i);
18107 __m128i __lsx_vmaddwev_q_du_d (__m128i, __m128i, __m128i);
18108 __m128i __lsx_vmaddwev_w_h (__m128i, __m128i, __m128i);
18109 __m128i __lsx_vmaddwev_w_hu (__m128i, __m128i, __m128i);
18110 __m128i __lsx_vmaddwev_w_hu_h (__m128i, __m128i, __m128i);
18111 __m128i __lsx_vmaddwod_d_w (__m128i, __m128i, __m128i);
18112 __m128i __lsx_vmaddwod_d_wu (__m128i, __m128i, __m128i);
18113 __m128i __lsx_vmaddwod_d_wu_w (__m128i, __m128i, __m128i);
18114 __m128i __lsx_vmaddwod_h_b (__m128i, __m128i, __m128i);
18115 __m128i __lsx_vmaddwod_h_bu (__m128i, __m128i, __m128i);
18116 __m128i __lsx_vmaddwod_h_bu_b (__m128i, __m128i, __m128i);
18117 __m128i __lsx_vmaddwod_q_d (__m128i, __m128i, __m128i);
18118 __m128i __lsx_vmaddwod_q_du (__m128i, __m128i, __m128i);
18119 __m128i __lsx_vmaddwod_q_du_d (__m128i, __m128i, __m128i);
18120 __m128i __lsx_vmaddwod_w_h (__m128i, __m128i, __m128i);
18121 __m128i __lsx_vmaddwod_w_hu (__m128i, __m128i, __m128i);
18122 __m128i __lsx_vmaddwod_w_hu_h (__m128i, __m128i, __m128i);
18123 __m128i __lsx_vmax_b (__m128i, __m128i);
18124 __m128i __lsx_vmax_bu (__m128i, __m128i);
18125 __m128i __lsx_vmax_d (__m128i, __m128i);
18126 __m128i __lsx_vmax_du (__m128i, __m128i);
18127 __m128i __lsx_vmax_h (__m128i, __m128i);
18128 __m128i __lsx_vmax_hu (__m128i, __m128i);
18129 __m128i __lsx_vmaxi_b (__m128i, imm_n16_15);
18130 __m128i __lsx_vmaxi_bu (__m128i, imm0_31);
18131 __m128i __lsx_vmaxi_d (__m128i, imm_n16_15);
18132 __m128i __lsx_vmaxi_du (__m128i, imm0_31);
18133 __m128i __lsx_vmaxi_h (__m128i, imm_n16_15);
18134 __m128i __lsx_vmaxi_hu (__m128i, imm0_31);
18135 __m128i __lsx_vmaxi_w (__m128i, imm_n16_15);
18136 __m128i __lsx_vmaxi_wu (__m128i, imm0_31);
18137 __m128i __lsx_vmax_w (__m128i, __m128i);
18138 __m128i __lsx_vmax_wu (__m128i, __m128i);
18139 __m128i __lsx_vmin_b (__m128i, __m128i);
18140 __m128i __lsx_vmin_bu (__m128i, __m128i);
18141 __m128i __lsx_vmin_d (__m128i, __m128i);
18142 __m128i __lsx_vmin_du (__m128i, __m128i);
18143 __m128i __lsx_vmin_h (__m128i, __m128i);
18144 __m128i __lsx_vmin_hu (__m128i, __m128i);
18145 __m128i __lsx_vmini_b (__m128i, imm_n16_15);
18146 __m128i __lsx_vmini_bu (__m128i, imm0_31);
18147 __m128i __lsx_vmini_d (__m128i, imm_n16_15);
18148 __m128i __lsx_vmini_du (__m128i, imm0_31);
18149 __m128i __lsx_vmini_h (__m128i, imm_n16_15);
18150 __m128i __lsx_vmini_hu (__m128i, imm0_31);
18151 __m128i __lsx_vmini_w (__m128i, imm_n16_15);
18152 __m128i __lsx_vmini_wu (__m128i, imm0_31);
18153 __m128i __lsx_vmin_w (__m128i, __m128i);
18154 __m128i __lsx_vmin_wu (__m128i, __m128i);
18155 __m128i __lsx_vmod_b (__m128i, __m128i);
18156 __m128i __lsx_vmod_bu (__m128i, __m128i);
18157 __m128i __lsx_vmod_d (__m128i, __m128i);
18158 __m128i __lsx_vmod_du (__m128i, __m128i);
18159 __m128i __lsx_vmod_h (__m128i, __m128i);
18160 __m128i __lsx_vmod_hu (__m128i, __m128i);
18161 __m128i __lsx_vmod_w (__m128i, __m128i);
18162 __m128i __lsx_vmod_wu (__m128i, __m128i);
18163 __m128i __lsx_vmskgez_b (__m128i);
18164 __m128i __lsx_vmskltz_b (__m128i);
18165 __m128i __lsx_vmskltz_d (__m128i);
18166 __m128i __lsx_vmskltz_h (__m128i);
18167 __m128i __lsx_vmskltz_w (__m128i);
18168 __m128i __lsx_vmsknz_b (__m128i);
18169 __m128i __lsx_vmsub_b (__m128i, __m128i, __m128i);
18170 __m128i __lsx_vmsub_d (__m128i, __m128i, __m128i);
18171 __m128i __lsx_vmsub_h (__m128i, __m128i, __m128i);
18172 __m128i __lsx_vmsub_w (__m128i, __m128i, __m128i);
18173 __m128i __lsx_vmuh_b (__m128i, __m128i);
18174 __m128i __lsx_vmuh_bu (__m128i, __m128i);
18175 __m128i __lsx_vmuh_d (__m128i, __m128i);
18176 __m128i __lsx_vmuh_du (__m128i, __m128i);
18177 __m128i __lsx_vmuh_h (__m128i, __m128i);
18178 __m128i __lsx_vmuh_hu (__m128i, __m128i);
18179 __m128i __lsx_vmuh_w (__m128i, __m128i);
18180 __m128i __lsx_vmuh_wu (__m128i, __m128i);
18181 __m128i __lsx_vmul_b (__m128i, __m128i);
18182 __m128i __lsx_vmul_d (__m128i, __m128i);
18183 __m128i __lsx_vmul_h (__m128i, __m128i);
18184 __m128i __lsx_vmul_w (__m128i, __m128i);
18185 __m128i __lsx_vmulwev_d_w (__m128i, __m128i);
18186 __m128i __lsx_vmulwev_d_wu (__m128i, __m128i);
18187 __m128i __lsx_vmulwev_d_wu_w (__m128i, __m128i);
18188 __m128i __lsx_vmulwev_h_b (__m128i, __m128i);
18189 __m128i __lsx_vmulwev_h_bu (__m128i, __m128i);
18190 __m128i __lsx_vmulwev_h_bu_b (__m128i, __m128i);
18191 __m128i __lsx_vmulwev_q_d (__m128i, __m128i);
18192 __m128i __lsx_vmulwev_q_du (__m128i, __m128i);
18193 __m128i __lsx_vmulwev_q_du_d (__m128i, __m128i);
18194 __m128i __lsx_vmulwev_w_h (__m128i, __m128i);
18195 __m128i __lsx_vmulwev_w_hu (__m128i, __m128i);
18196 __m128i __lsx_vmulwev_w_hu_h (__m128i, __m128i);
18197 __m128i __lsx_vmulwod_d_w (__m128i, __m128i);
18198 __m128i __lsx_vmulwod_d_wu (__m128i, __m128i);
18199 __m128i __lsx_vmulwod_d_wu_w (__m128i, __m128i);
18200 __m128i __lsx_vmulwod_h_b (__m128i, __m128i);
18201 __m128i __lsx_vmulwod_h_bu (__m128i, __m128i);
18202 __m128i __lsx_vmulwod_h_bu_b (__m128i, __m128i);
18203 __m128i __lsx_vmulwod_q_d (__m128i, __m128i);
18204 __m128i __lsx_vmulwod_q_du (__m128i, __m128i);
18205 __m128i __lsx_vmulwod_q_du_d (__m128i, __m128i);
18206 __m128i __lsx_vmulwod_w_h (__m128i, __m128i);
18207 __m128i __lsx_vmulwod_w_hu (__m128i, __m128i);
18208 __m128i __lsx_vmulwod_w_hu_h (__m128i, __m128i);
18209 __m128i __lsx_vneg_b (__m128i);
18210 __m128i __lsx_vneg_d (__m128i);
18211 __m128i __lsx_vneg_h (__m128i);
18212 __m128i __lsx_vneg_w (__m128i);
18213 __m128i __lsx_vnori_b (__m128i, imm0_255);
18214 __m128i __lsx_vnor_v (__m128i, __m128i);
18215 __m128i __lsx_vori_b (__m128i, imm0_255);
18216 __m128i __lsx_vorn_v (__m128i, __m128i);
18217 __m128i __lsx_vor_v (__m128i, __m128i);
18218 __m128i __lsx_vpackev_b (__m128i, __m128i);
18219 __m128i __lsx_vpackev_d (__m128i, __m128i);
18220 __m128i __lsx_vpackev_h (__m128i, __m128i);
18221 __m128i __lsx_vpackev_w (__m128i, __m128i);
18222 __m128i __lsx_vpackod_b (__m128i, __m128i);
18223 __m128i __lsx_vpackod_d (__m128i, __m128i);
18224 __m128i __lsx_vpackod_h (__m128i, __m128i);
18225 __m128i __lsx_vpackod_w (__m128i, __m128i);
18226 __m128i __lsx_vpcnt_b (__m128i);
18227 __m128i __lsx_vpcnt_d (__m128i);
18228 __m128i __lsx_vpcnt_h (__m128i);
18229 __m128i __lsx_vpcnt_w (__m128i);
18230 __m128i __lsx_vpermi_w (__m128i, __m128i, imm0_255);
18231 __m128i __lsx_vpickev_b (__m128i, __m128i);
18232 __m128i __lsx_vpickev_d (__m128i, __m128i);
18233 __m128i __lsx_vpickev_h (__m128i, __m128i);
18234 __m128i __lsx_vpickev_w (__m128i, __m128i);
18235 __m128i __lsx_vpickod_b (__m128i, __m128i);
18236 __m128i __lsx_vpickod_d (__m128i, __m128i);
18237 __m128i __lsx_vpickod_h (__m128i, __m128i);
18238 __m128i __lsx_vpickod_w (__m128i, __m128i);
18239 int __lsx_vpickve2gr_b (__m128i, imm0_15);
18240 unsigned int __lsx_vpickve2gr_bu (__m128i, imm0_15);
18241 long int __lsx_vpickve2gr_d (__m128i, imm0_1);
18242 unsigned long int __lsx_vpickve2gr_du (__m128i, imm0_1);
18243 int __lsx_vpickve2gr_h (__m128i, imm0_7);
18244 unsigned int __lsx_vpickve2gr_hu (__m128i, imm0_7);
18245 int __lsx_vpickve2gr_w (__m128i, imm0_3);
18246 unsigned int __lsx_vpickve2gr_wu (__m128i, imm0_3);
18247 __m128i __lsx_vreplgr2vr_b (int);
18248 __m128i __lsx_vreplgr2vr_d (long int);
18249 __m128i __lsx_vreplgr2vr_h (int);
18250 __m128i __lsx_vreplgr2vr_w (int);
18251 __m128i __lsx_vrepli_b (imm_n512_511);
18252 __m128i __lsx_vrepli_d (imm_n512_511);
18253 __m128i __lsx_vrepli_h (imm_n512_511);
18254 __m128i __lsx_vrepli_w (imm_n512_511);
18255 __m128i __lsx_vreplve_b (__m128i, int);
18256 __m128i __lsx_vreplve_d (__m128i, int);
18257 __m128i __lsx_vreplve_h (__m128i, int);
18258 __m128i __lsx_vreplvei_b (__m128i, imm0_15);
18259 __m128i __lsx_vreplvei_d (__m128i, imm0_1);
18260 __m128i __lsx_vreplvei_h (__m128i, imm0_7);
18261 __m128i __lsx_vreplvei_w (__m128i, imm0_3);
18262 __m128i __lsx_vreplve_w (__m128i, int);
18263 __m128i __lsx_vrotr_b (__m128i, __m128i);
18264 __m128i __lsx_vrotr_d (__m128i, __m128i);
18265 __m128i __lsx_vrotr_h (__m128i, __m128i);
18266 __m128i __lsx_vrotri_b (__m128i, imm0_7);
18267 __m128i __lsx_vrotri_d (__m128i, imm0_63);
18268 __m128i __lsx_vrotri_h (__m128i, imm0_15);
18269 __m128i __lsx_vrotri_w (__m128i, imm0_31);
18270 __m128i __lsx_vrotr_w (__m128i, __m128i);
18271 __m128i __lsx_vsadd_b (__m128i, __m128i);
18272 __m128i __lsx_vsadd_bu (__m128i, __m128i);
18273 __m128i __lsx_vsadd_d (__m128i, __m128i);
18274 __m128i __lsx_vsadd_du (__m128i, __m128i);
18275 __m128i __lsx_vsadd_h (__m128i, __m128i);
18276 __m128i __lsx_vsadd_hu (__m128i, __m128i);
18277 __m128i __lsx_vsadd_w (__m128i, __m128i);
18278 __m128i __lsx_vsadd_wu (__m128i, __m128i);
18279 __m128i __lsx_vsat_b (__m128i, imm0_7);
18280 __m128i __lsx_vsat_bu (__m128i, imm0_7);
18281 __m128i __lsx_vsat_d (__m128i, imm0_63);
18282 __m128i __lsx_vsat_du (__m128i, imm0_63);
18283 __m128i __lsx_vsat_h (__m128i, imm0_15);
18284 __m128i __lsx_vsat_hu (__m128i, imm0_15);
18285 __m128i __lsx_vsat_w (__m128i, imm0_31);
18286 __m128i __lsx_vsat_wu (__m128i, imm0_31);
18287 __m128i __lsx_vseq_b (__m128i, __m128i);
18288 __m128i __lsx_vseq_d (__m128i, __m128i);
18289 __m128i __lsx_vseq_h (__m128i, __m128i);
18290 __m128i __lsx_vseqi_b (__m128i, imm_n16_15);
18291 __m128i __lsx_vseqi_d (__m128i, imm_n16_15);
18292 __m128i __lsx_vseqi_h (__m128i, imm_n16_15);
18293 __m128i __lsx_vseqi_w (__m128i, imm_n16_15);
18294 __m128i __lsx_vseq_w (__m128i, __m128i);
18295 __m128i __lsx_vshuf4i_b (__m128i, imm0_255);
18296 __m128i __lsx_vshuf4i_d (__m128i, __m128i, imm0_255);
18297 __m128i __lsx_vshuf4i_h (__m128i, imm0_255);
18298 __m128i __lsx_vshuf4i_w (__m128i, imm0_255);
18299 __m128i __lsx_vshuf_b (__m128i, __m128i, __m128i);
18300 __m128i __lsx_vshuf_d (__m128i, __m128i, __m128i);
18301 __m128i __lsx_vshuf_h (__m128i, __m128i, __m128i);
18302 __m128i __lsx_vshuf_w (__m128i, __m128i, __m128i);
18303 __m128i __lsx_vsigncov_b (__m128i, __m128i);
18304 __m128i __lsx_vsigncov_d (__m128i, __m128i);
18305 __m128i __lsx_vsigncov_h (__m128i, __m128i);
18306 __m128i __lsx_vsigncov_w (__m128i, __m128i);
18307 __m128i __lsx_vsle_b (__m128i, __m128i);
18308 __m128i __lsx_vsle_bu (__m128i, __m128i);
18309 __m128i __lsx_vsle_d (__m128i, __m128i);
18310 __m128i __lsx_vsle_du (__m128i, __m128i);
18311 __m128i __lsx_vsle_h (__m128i, __m128i);
18312 __m128i __lsx_vsle_hu (__m128i, __m128i);
18313 __m128i __lsx_vslei_b (__m128i, imm_n16_15);
18314 __m128i __lsx_vslei_bu (__m128i, imm0_31);
18315 __m128i __lsx_vslei_d (__m128i, imm_n16_15);
18316 __m128i __lsx_vslei_du (__m128i, imm0_31);
18317 __m128i __lsx_vslei_h (__m128i, imm_n16_15);
18318 __m128i __lsx_vslei_hu (__m128i, imm0_31);
18319 __m128i __lsx_vslei_w (__m128i, imm_n16_15);
18320 __m128i __lsx_vslei_wu (__m128i, imm0_31);
18321 __m128i __lsx_vsle_w (__m128i, __m128i);
18322 __m128i __lsx_vsle_wu (__m128i, __m128i);
18323 __m128i __lsx_vsll_b (__m128i, __m128i);
18324 __m128i __lsx_vsll_d (__m128i, __m128i);
18325 __m128i __lsx_vsll_h (__m128i, __m128i);
18326 __m128i __lsx_vslli_b (__m128i, imm0_7);
18327 __m128i __lsx_vslli_d (__m128i, imm0_63);
18328 __m128i __lsx_vslli_h (__m128i, imm0_15);
18329 __m128i __lsx_vslli_w (__m128i, imm0_31);
18330 __m128i __lsx_vsll_w (__m128i, __m128i);
18331 __m128i __lsx_vsllwil_du_wu (__m128i, imm0_31);
18332 __m128i __lsx_vsllwil_d_w (__m128i, imm0_31);
18333 __m128i __lsx_vsllwil_h_b (__m128i, imm0_7);
18334 __m128i __lsx_vsllwil_hu_bu (__m128i, imm0_7);
18335 __m128i __lsx_vsllwil_w_h (__m128i, imm0_15);
18336 __m128i __lsx_vsllwil_wu_hu (__m128i, imm0_15);
18337 __m128i __lsx_vslt_b (__m128i, __m128i);
18338 __m128i __lsx_vslt_bu (__m128i, __m128i);
18339 __m128i __lsx_vslt_d (__m128i, __m128i);
18340 __m128i __lsx_vslt_du (__m128i, __m128i);
18341 __m128i __lsx_vslt_h (__m128i, __m128i);
18342 __m128i __lsx_vslt_hu (__m128i, __m128i);
18343 __m128i __lsx_vslti_b (__m128i, imm_n16_15);
18344 __m128i __lsx_vslti_bu (__m128i, imm0_31);
18345 __m128i __lsx_vslti_d (__m128i, imm_n16_15);
18346 __m128i __lsx_vslti_du (__m128i, imm0_31);
18347 __m128i __lsx_vslti_h (__m128i, imm_n16_15);
18348 __m128i __lsx_vslti_hu (__m128i, imm0_31);
18349 __m128i __lsx_vslti_w (__m128i, imm_n16_15);
18350 __m128i __lsx_vslti_wu (__m128i, imm0_31);
18351 __m128i __lsx_vslt_w (__m128i, __m128i);
18352 __m128i __lsx_vslt_wu (__m128i, __m128i);
18353 __m128i __lsx_vsra_b (__m128i, __m128i);
18354 __m128i __lsx_vsra_d (__m128i, __m128i);
18355 __m128i __lsx_vsra_h (__m128i, __m128i);
18356 __m128i __lsx_vsrai_b (__m128i, imm0_7);
18357 __m128i __lsx_vsrai_d (__m128i, imm0_63);
18358 __m128i __lsx_vsrai_h (__m128i, imm0_15);
18359 __m128i __lsx_vsrai_w (__m128i, imm0_31);
18360 __m128i __lsx_vsran_b_h (__m128i, __m128i);
18361 __m128i __lsx_vsran_h_w (__m128i, __m128i);
18362 __m128i __lsx_vsrani_b_h (__m128i, __m128i, imm0_15);
18363 __m128i __lsx_vsrani_d_q (__m128i, __m128i, imm0_127);
18364 __m128i __lsx_vsrani_h_w (__m128i, __m128i, imm0_31);
18365 __m128i __lsx_vsrani_w_d (__m128i, __m128i, imm0_63);
18366 __m128i __lsx_vsran_w_d (__m128i, __m128i);
18367 __m128i __lsx_vsrar_b (__m128i, __m128i);
18368 __m128i __lsx_vsrar_d (__m128i, __m128i);
18369 __m128i __lsx_vsrar_h (__m128i, __m128i);
18370 __m128i __lsx_vsrari_b (__m128i, imm0_7);
18371 __m128i __lsx_vsrari_d (__m128i, imm0_63);
18372 __m128i __lsx_vsrari_h (__m128i, imm0_15);
18373 __m128i __lsx_vsrari_w (__m128i, imm0_31);
18374 __m128i __lsx_vsrarn_b_h (__m128i, __m128i);
18375 __m128i __lsx_vsrarn_h_w (__m128i, __m128i);
18376 __m128i __lsx_vsrarni_b_h (__m128i, __m128i, imm0_15);
18377 __m128i __lsx_vsrarni_d_q (__m128i, __m128i, imm0_127);
18378 __m128i __lsx_vsrarni_h_w (__m128i, __m128i, imm0_31);
18379 __m128i __lsx_vsrarni_w_d (__m128i, __m128i, imm0_63);
18380 __m128i __lsx_vsrarn_w_d (__m128i, __m128i);
18381 __m128i __lsx_vsrar_w (__m128i, __m128i);
18382 __m128i __lsx_vsra_w (__m128i, __m128i);
18383 __m128i __lsx_vsrl_b (__m128i, __m128i);
18384 __m128i __lsx_vsrl_d (__m128i, __m128i);
18385 __m128i __lsx_vsrl_h (__m128i, __m128i);
18386 __m128i __lsx_vsrli_b (__m128i, imm0_7);
18387 __m128i __lsx_vsrli_d (__m128i, imm0_63);
18388 __m128i __lsx_vsrli_h (__m128i, imm0_15);
18389 __m128i __lsx_vsrli_w (__m128i, imm0_31);
18390 __m128i __lsx_vsrln_b_h (__m128i, __m128i);
18391 __m128i __lsx_vsrln_h_w (__m128i, __m128i);
18392 __m128i __lsx_vsrlni_b_h (__m128i, __m128i, imm0_15);
18393 __m128i __lsx_vsrlni_d_q (__m128i, __m128i, imm0_127);
18394 __m128i __lsx_vsrlni_h_w (__m128i, __m128i, imm0_31);
18395 __m128i __lsx_vsrlni_w_d (__m128i, __m128i, imm0_63);
18396 __m128i __lsx_vsrln_w_d (__m128i, __m128i);
18397 __m128i __lsx_vsrlr_b (__m128i, __m128i);
18398 __m128i __lsx_vsrlr_d (__m128i, __m128i);
18399 __m128i __lsx_vsrlr_h (__m128i, __m128i);
18400 __m128i __lsx_vsrlri_b (__m128i, imm0_7);
18401 __m128i __lsx_vsrlri_d (__m128i, imm0_63);
18402 __m128i __lsx_vsrlri_h (__m128i, imm0_15);
18403 __m128i __lsx_vsrlri_w (__m128i, imm0_31);
18404 __m128i __lsx_vsrlrn_b_h (__m128i, __m128i);
18405 __m128i __lsx_vsrlrn_h_w (__m128i, __m128i);
18406 __m128i __lsx_vsrlrni_b_h (__m128i, __m128i, imm0_15);
18407 __m128i __lsx_vsrlrni_d_q (__m128i, __m128i, imm0_127);
18408 __m128i __lsx_vsrlrni_h_w (__m128i, __m128i, imm0_31);
18409 __m128i __lsx_vsrlrni_w_d (__m128i, __m128i, imm0_63);
18410 __m128i __lsx_vsrlrn_w_d (__m128i, __m128i);
18411 __m128i __lsx_vsrlr_w (__m128i, __m128i);
18412 __m128i __lsx_vsrl_w (__m128i, __m128i);
18413 __m128i __lsx_vssran_b_h (__m128i, __m128i);
18414 __m128i __lsx_vssran_bu_h (__m128i, __m128i);
18415 __m128i __lsx_vssran_hu_w (__m128i, __m128i);
18416 __m128i __lsx_vssran_h_w (__m128i, __m128i);
18417 __m128i __lsx_vssrani_b_h (__m128i, __m128i, imm0_15);
18418 __m128i __lsx_vssrani_bu_h (__m128i, __m128i, imm0_15);
18419 __m128i __lsx_vssrani_d_q (__m128i, __m128i, imm0_127);
18420 __m128i __lsx_vssrani_du_q (__m128i, __m128i, imm0_127);
18421 __m128i __lsx_vssrani_hu_w (__m128i, __m128i, imm0_31);
18422 __m128i __lsx_vssrani_h_w (__m128i, __m128i, imm0_31);
18423 __m128i __lsx_vssrani_w_d (__m128i, __m128i, imm0_63);
18424 __m128i __lsx_vssrani_wu_d (__m128i, __m128i, imm0_63);
18425 __m128i __lsx_vssran_w_d (__m128i, __m128i);
18426 __m128i __lsx_vssran_wu_d (__m128i, __m128i);
18427 __m128i __lsx_vssrarn_b_h (__m128i, __m128i);
18428 __m128i __lsx_vssrarn_bu_h (__m128i, __m128i);
18429 __m128i __lsx_vssrarn_hu_w (__m128i, __m128i);
18430 __m128i __lsx_vssrarn_h_w (__m128i, __m128i);
18431 __m128i __lsx_vssrarni_b_h (__m128i, __m128i, imm0_15);
18432 __m128i __lsx_vssrarni_bu_h (__m128i, __m128i, imm0_15);
18433 __m128i __lsx_vssrarni_d_q (__m128i, __m128i, imm0_127);
18434 __m128i __lsx_vssrarni_du_q (__m128i, __m128i, imm0_127);
18435 __m128i __lsx_vssrarni_hu_w (__m128i, __m128i, imm0_31);
18436 __m128i __lsx_vssrarni_h_w (__m128i, __m128i, imm0_31);
18437 __m128i __lsx_vssrarni_w_d (__m128i, __m128i, imm0_63);
18438 __m128i __lsx_vssrarni_wu_d (__m128i, __m128i, imm0_63);
18439 __m128i __lsx_vssrarn_w_d (__m128i, __m128i);
18440 __m128i __lsx_vssrarn_wu_d (__m128i, __m128i);
18441 __m128i __lsx_vssrln_b_h (__m128i, __m128i);
18442 __m128i __lsx_vssrln_bu_h (__m128i, __m128i);
18443 __m128i __lsx_vssrln_hu_w (__m128i, __m128i);
18444 __m128i __lsx_vssrln_h_w (__m128i, __m128i);
18445 __m128i __lsx_vssrlni_b_h (__m128i, __m128i, imm0_15);
18446 __m128i __lsx_vssrlni_bu_h (__m128i, __m128i, imm0_15);
18447 __m128i __lsx_vssrlni_d_q (__m128i, __m128i, imm0_127);
18448 __m128i __lsx_vssrlni_du_q (__m128i, __m128i, imm0_127);
18449 __m128i __lsx_vssrlni_hu_w (__m128i, __m128i, imm0_31);
18450 __m128i __lsx_vssrlni_h_w (__m128i, __m128i, imm0_31);
18451 __m128i __lsx_vssrlni_w_d (__m128i, __m128i, imm0_63);
18452 __m128i __lsx_vssrlni_wu_d (__m128i, __m128i, imm0_63);
18453 __m128i __lsx_vssrln_w_d (__m128i, __m128i);
18454 __m128i __lsx_vssrln_wu_d (__m128i, __m128i);
18455 __m128i __lsx_vssrlrn_b_h (__m128i, __m128i);
18456 __m128i __lsx_vssrlrn_bu_h (__m128i, __m128i);
18457 __m128i __lsx_vssrlrn_hu_w (__m128i, __m128i);
18458 __m128i __lsx_vssrlrn_h_w (__m128i, __m128i);
18459 __m128i __lsx_vssrlrni_b_h (__m128i, __m128i, imm0_15);
18460 __m128i __lsx_vssrlrni_bu_h (__m128i, __m128i, imm0_15);
18461 __m128i __lsx_vssrlrni_d_q (__m128i, __m128i, imm0_127);
18462 __m128i __lsx_vssrlrni_du_q (__m128i, __m128i, imm0_127);
18463 __m128i __lsx_vssrlrni_hu_w (__m128i, __m128i, imm0_31);
18464 __m128i __lsx_vssrlrni_h_w (__m128i, __m128i, imm0_31);
18465 __m128i __lsx_vssrlrni_w_d (__m128i, __m128i, imm0_63);
18466 __m128i __lsx_vssrlrni_wu_d (__m128i, __m128i, imm0_63);
18467 __m128i __lsx_vssrlrn_w_d (__m128i, __m128i);
18468 __m128i __lsx_vssrlrn_wu_d (__m128i, __m128i);
18469 __m128i __lsx_vssub_b (__m128i, __m128i);
18470 __m128i __lsx_vssub_bu (__m128i, __m128i);
18471 __m128i __lsx_vssub_d (__m128i, __m128i);
18472 __m128i __lsx_vssub_du (__m128i, __m128i);
18473 __m128i __lsx_vssub_h (__m128i, __m128i);
18474 __m128i __lsx_vssub_hu (__m128i, __m128i);
18475 __m128i __lsx_vssub_w (__m128i, __m128i);
18476 __m128i __lsx_vssub_wu (__m128i, __m128i);
18477 void __lsx_vst (__m128i, void *, imm_n2048_2047);
18478 void __lsx_vstelm_b (__m128i, void *, imm_n128_127, imm0_15);
18479 void __lsx_vstelm_d (__m128i, void *, imm_n128_127, imm0_1);
18480 void __lsx_vstelm_h (__m128i, void *, imm_n128_127, imm0_7);
18481 void __lsx_vstelm_w (__m128i, void *, imm_n128_127, imm0_3);
18482 void __lsx_vstx (__m128i, void *, long int);
18483 __m128i __lsx_vsub_b (__m128i, __m128i);
18484 __m128i __lsx_vsub_d (__m128i, __m128i);
18485 __m128i __lsx_vsub_h (__m128i, __m128i);
18486 __m128i __lsx_vsubi_bu (__m128i, imm0_31);
18487 __m128i __lsx_vsubi_du (__m128i, imm0_31);
18488 __m128i __lsx_vsubi_hu (__m128i, imm0_31);
18489 __m128i __lsx_vsubi_wu (__m128i, imm0_31);
18490 __m128i __lsx_vsub_q (__m128i, __m128i);
18491 __m128i __lsx_vsub_w (__m128i, __m128i);
18492 __m128i __lsx_vsubwev_d_w (__m128i, __m128i);
18493 __m128i __lsx_vsubwev_d_wu (__m128i, __m128i);
18494 __m128i __lsx_vsubwev_h_b (__m128i, __m128i);
18495 __m128i __lsx_vsubwev_h_bu (__m128i, __m128i);
18496 __m128i __lsx_vsubwev_q_d (__m128i, __m128i);
18497 __m128i __lsx_vsubwev_q_du (__m128i, __m128i);
18498 __m128i __lsx_vsubwev_w_h (__m128i, __m128i);
18499 __m128i __lsx_vsubwev_w_hu (__m128i, __m128i);
18500 __m128i __lsx_vsubwod_d_w (__m128i, __m128i);
18501 __m128i __lsx_vsubwod_d_wu (__m128i, __m128i);
18502 __m128i __lsx_vsubwod_h_b (__m128i, __m128i);
18503 __m128i __lsx_vsubwod_h_bu (__m128i, __m128i);
18504 __m128i __lsx_vsubwod_q_d (__m128i, __m128i);
18505 __m128i __lsx_vsubwod_q_du (__m128i, __m128i);
18506 __m128i __lsx_vsubwod_w_h (__m128i, __m128i);
18507 __m128i __lsx_vsubwod_w_hu (__m128i, __m128i);
18508 __m128i __lsx_vxori_b (__m128i, imm0_255);
18509 __m128i __lsx_vxor_v (__m128i, __m128i);
18510 @end smallexample
18512 These instrisic functions are available by including @code{lsxintrin.h} and
18513 using @option{-mfrecipe} and @option{-mlsx}.
18514 @smallexample
18515 __m128d __lsx_vfrecipe_d (__m128d);
18516 __m128 __lsx_vfrecipe_s (__m128);
18517 __m128d __lsx_vfrsqrte_d (__m128d);
18518 __m128 __lsx_vfrsqrte_s (__m128);
18519 @end smallexample
18521 @node LoongArch ASX Vector Intrinsics
18522 @subsection LoongArch ASX Vector Intrinsics
18524 GCC provides intrinsics to access the LASX (Loongson Advanced SIMD Extension)
18525 instructions. The interface is made available by including @code{<lasxintrin.h>}
18526 and using @option{-mlasx}.
18528 The following vectors typedefs are included in @code{lasxintrin.h}:
18530 @itemize
18531 @item @code{__m256i}, a 256-bit vector of fixed point;
18532 @item @code{__m256}, a 256-bit vector of single precision floating point;
18533 @item @code{__m256d}, a 256-bit vector of double precision floating point.
18534 @end itemize
18536 Instructions and corresponding built-ins may have additional restrictions and/or
18537 input/output values manipulated:
18539 @itemize
18540 @item @code{imm0_1}, an integer literal in range 0 to 1.
18541 @item @code{imm0_3}, an integer literal in range 0 to 3.
18542 @item @code{imm0_7}, an integer literal in range 0 to 7.
18543 @item @code{imm0_15}, an integer literal in range 0 to 15.
18544 @item @code{imm0_31}, an integer literal in range 0 to 31.
18545 @item @code{imm0_63}, an integer literal in range 0 to 63.
18546 @item @code{imm0_127}, an integer literal in range 0 to 127.
18547 @item @code{imm0_255}, an integer literal in range 0 to 255.
18548 @item @code{imm_n16_15}, an integer literal in range -16 to 15.
18549 @item @code{imm_n128_127}, an integer literal in range -128 to 127.
18550 @item @code{imm_n256_255}, an integer literal in range -256 to 255.
18551 @item @code{imm_n512_511}, an integer literal in range -512 to 511.
18552 @item @code{imm_n1024_1023}, an integer literal in range -1024 to 1023.
18553 @item @code{imm_n2048_2047}, an integer literal in range -2048 to 2047.
18554 @end itemize
18556 For convenience, GCC defines functions @code{__lasx_xvrepli_@{b/h/w/d@}} and
18557 @code{__lasx_b[n]z_@{v/b/h/w/d@}}, which are implemented as follows:
18559 @smallexample
18560 a. @code{__lasx_xvrepli_@{b/h/w/d@}}: Implemented the case where the highest
18561    bit of @code{xvldi} instruction @code{i13} is 1.
18563    i13[12] == 1'b0
18564    case i13[11:10] of :
18565      2'b00: __lasx_xvrepli_b (imm_n512_511)
18566      2'b01: __lasx_xvrepli_h (imm_n512_511)
18567      2'b10: __lasx_xvrepli_w (imm_n512_511)
18568      2'b11: __lasx_xvrepli_d (imm_n512_511)
18570 b. @code{__lasx_b[n]z_@{v/b/h/w/d@}}: Since the @code{xvseteqz} class directive
18571    cannot be used on its own, this function is defined.
18573    __lasx_xbz_v  => xvseteqz.v + bcnez
18574    __lasx_xbnz_v => xvsetnez.v + bcnez
18575    __lasx_xbz_b  => xvsetanyeqz.b + bcnez
18576    __lasx_xbz_h  => xvsetanyeqz.h + bcnez
18577    __lasx_xbz_w  => xvsetanyeqz.w + bcnez
18578    __lasx_xbz_d  => xvsetanyeqz.d + bcnez
18579    __lasx_xbnz_b => xvsetallnez.b + bcnez
18580    __lasx_xbnz_h => xvsetallnez.h + bcnez
18581    __lasx_xbnz_w => xvsetallnez.w + bcnez
18582    __lasx_xbnz_d => xvsetallnez.d + bcnez
18583 @end smallexample
18585 @smallexample
18587   #include <lasxintrin.h>
18589   extern __m256i @var{a};
18591   void
18592   test (void)
18593   @{
18594     if (__lasx_xbz_v (@var{a}))
18595       printf ("1\n");
18596     else
18597       printf ("2\n");
18598   @}
18599 @end smallexample
18601 @emph{Note:} For directives where the intent operand is also the source operand
18602 (modifying only part of the bitfield of the intent register), the first parameter
18603 in the builtin call function is used as the intent operand.
18605 @smallexample
18607   #include <lasxintrin.h>
18608   extern __m256i @var{dst};
18609   int @var{src};
18611   void
18612   test (void)
18613   @{
18614     @var{dst} = __lasx_xvinsgr2vr_w (@var{dst}, @var{src}, 3);
18615   @}
18616 @end smallexample
18619 The intrinsics provided are listed below:
18621 @smallexample
18622 __m256i __lasx_vext2xv_d_b (__m256i);
18623 __m256i __lasx_vext2xv_d_h (__m256i);
18624 __m256i __lasx_vext2xv_du_bu (__m256i);
18625 __m256i __lasx_vext2xv_du_hu (__m256i);
18626 __m256i __lasx_vext2xv_du_wu (__m256i);
18627 __m256i __lasx_vext2xv_d_w (__m256i);
18628 __m256i __lasx_vext2xv_h_b (__m256i);
18629 __m256i __lasx_vext2xv_hu_bu (__m256i);
18630 __m256i __lasx_vext2xv_w_b (__m256i);
18631 __m256i __lasx_vext2xv_w_h (__m256i);
18632 __m256i __lasx_vext2xv_wu_bu (__m256i);
18633 __m256i __lasx_vext2xv_wu_hu (__m256i);
18634 int __lasx_xbnz_b (__m256i);
18635 int __lasx_xbnz_d (__m256i);
18636 int __lasx_xbnz_h (__m256i);
18637 int __lasx_xbnz_v (__m256i);
18638 int __lasx_xbnz_w (__m256i);
18639 int __lasx_xbz_b (__m256i);
18640 int __lasx_xbz_d (__m256i);
18641 int __lasx_xbz_h (__m256i);
18642 int __lasx_xbz_v (__m256i);
18643 int __lasx_xbz_w (__m256i);
18644 __m256i __lasx_xvabsd_b (__m256i, __m256i);
18645 __m256i __lasx_xvabsd_bu (__m256i, __m256i);
18646 __m256i __lasx_xvabsd_d (__m256i, __m256i);
18647 __m256i __lasx_xvabsd_du (__m256i, __m256i);
18648 __m256i __lasx_xvabsd_h (__m256i, __m256i);
18649 __m256i __lasx_xvabsd_hu (__m256i, __m256i);
18650 __m256i __lasx_xvabsd_w (__m256i, __m256i);
18651 __m256i __lasx_xvabsd_wu (__m256i, __m256i);
18652 __m256i __lasx_xvadda_b (__m256i, __m256i);
18653 __m256i __lasx_xvadda_d (__m256i, __m256i);
18654 __m256i __lasx_xvadda_h (__m256i, __m256i);
18655 __m256i __lasx_xvadda_w (__m256i, __m256i);
18656 __m256i __lasx_xvadd_b (__m256i, __m256i);
18657 __m256i __lasx_xvadd_d (__m256i, __m256i);
18658 __m256i __lasx_xvadd_h (__m256i, __m256i);
18659 __m256i __lasx_xvaddi_bu (__m256i, imm0_31);
18660 __m256i __lasx_xvaddi_du (__m256i, imm0_31);
18661 __m256i __lasx_xvaddi_hu (__m256i, imm0_31);
18662 __m256i __lasx_xvaddi_wu (__m256i, imm0_31);
18663 __m256i __lasx_xvadd_q (__m256i, __m256i);
18664 __m256i __lasx_xvadd_w (__m256i, __m256i);
18665 __m256i __lasx_xvaddwev_d_w (__m256i, __m256i);
18666 __m256i __lasx_xvaddwev_d_wu (__m256i, __m256i);
18667 __m256i __lasx_xvaddwev_d_wu_w (__m256i, __m256i);
18668 __m256i __lasx_xvaddwev_h_b (__m256i, __m256i);
18669 __m256i __lasx_xvaddwev_h_bu (__m256i, __m256i);
18670 __m256i __lasx_xvaddwev_h_bu_b (__m256i, __m256i);
18671 __m256i __lasx_xvaddwev_q_d (__m256i, __m256i);
18672 __m256i __lasx_xvaddwev_q_du (__m256i, __m256i);
18673 __m256i __lasx_xvaddwev_q_du_d (__m256i, __m256i);
18674 __m256i __lasx_xvaddwev_w_h (__m256i, __m256i);
18675 __m256i __lasx_xvaddwev_w_hu (__m256i, __m256i);
18676 __m256i __lasx_xvaddwev_w_hu_h (__m256i, __m256i);
18677 __m256i __lasx_xvaddwod_d_w (__m256i, __m256i);
18678 __m256i __lasx_xvaddwod_d_wu (__m256i, __m256i);
18679 __m256i __lasx_xvaddwod_d_wu_w (__m256i, __m256i);
18680 __m256i __lasx_xvaddwod_h_b (__m256i, __m256i);
18681 __m256i __lasx_xvaddwod_h_bu (__m256i, __m256i);
18682 __m256i __lasx_xvaddwod_h_bu_b (__m256i, __m256i);
18683 __m256i __lasx_xvaddwod_q_d (__m256i, __m256i);
18684 __m256i __lasx_xvaddwod_q_du (__m256i, __m256i);
18685 __m256i __lasx_xvaddwod_q_du_d (__m256i, __m256i);
18686 __m256i __lasx_xvaddwod_w_h (__m256i, __m256i);
18687 __m256i __lasx_xvaddwod_w_hu (__m256i, __m256i);
18688 __m256i __lasx_xvaddwod_w_hu_h (__m256i, __m256i);
18689 __m256i __lasx_xvandi_b (__m256i, imm0_255);
18690 __m256i __lasx_xvandn_v (__m256i, __m256i);
18691 __m256i __lasx_xvand_v (__m256i, __m256i);
18692 __m256i __lasx_xvavg_b (__m256i, __m256i);
18693 __m256i __lasx_xvavg_bu (__m256i, __m256i);
18694 __m256i __lasx_xvavg_d (__m256i, __m256i);
18695 __m256i __lasx_xvavg_du (__m256i, __m256i);
18696 __m256i __lasx_xvavg_h (__m256i, __m256i);
18697 __m256i __lasx_xvavg_hu (__m256i, __m256i);
18698 __m256i __lasx_xvavgr_b (__m256i, __m256i);
18699 __m256i __lasx_xvavgr_bu (__m256i, __m256i);
18700 __m256i __lasx_xvavgr_d (__m256i, __m256i);
18701 __m256i __lasx_xvavgr_du (__m256i, __m256i);
18702 __m256i __lasx_xvavgr_h (__m256i, __m256i);
18703 __m256i __lasx_xvavgr_hu (__m256i, __m256i);
18704 __m256i __lasx_xvavgr_w (__m256i, __m256i);
18705 __m256i __lasx_xvavgr_wu (__m256i, __m256i);
18706 __m256i __lasx_xvavg_w (__m256i, __m256i);
18707 __m256i __lasx_xvavg_wu (__m256i, __m256i);
18708 __m256i __lasx_xvbitclr_b (__m256i, __m256i);
18709 __m256i __lasx_xvbitclr_d (__m256i, __m256i);
18710 __m256i __lasx_xvbitclr_h (__m256i, __m256i);
18711 __m256i __lasx_xvbitclri_b (__m256i, imm0_7);
18712 __m256i __lasx_xvbitclri_d (__m256i, imm0_63);
18713 __m256i __lasx_xvbitclri_h (__m256i, imm0_15);
18714 __m256i __lasx_xvbitclri_w (__m256i, imm0_31);
18715 __m256i __lasx_xvbitclr_w (__m256i, __m256i);
18716 __m256i __lasx_xvbitrev_b (__m256i, __m256i);
18717 __m256i __lasx_xvbitrev_d (__m256i, __m256i);
18718 __m256i __lasx_xvbitrev_h (__m256i, __m256i);
18719 __m256i __lasx_xvbitrevi_b (__m256i, imm0_7);
18720 __m256i __lasx_xvbitrevi_d (__m256i, imm0_63);
18721 __m256i __lasx_xvbitrevi_h (__m256i, imm0_15);
18722 __m256i __lasx_xvbitrevi_w (__m256i, imm0_31);
18723 __m256i __lasx_xvbitrev_w (__m256i, __m256i);
18724 __m256i __lasx_xvbitseli_b (__m256i, __m256i, imm0_255);
18725 __m256i __lasx_xvbitsel_v (__m256i, __m256i, __m256i);
18726 __m256i __lasx_xvbitset_b (__m256i, __m256i);
18727 __m256i __lasx_xvbitset_d (__m256i, __m256i);
18728 __m256i __lasx_xvbitset_h (__m256i, __m256i);
18729 __m256i __lasx_xvbitseti_b (__m256i, imm0_7);
18730 __m256i __lasx_xvbitseti_d (__m256i, imm0_63);
18731 __m256i __lasx_xvbitseti_h (__m256i, imm0_15);
18732 __m256i __lasx_xvbitseti_w (__m256i, imm0_31);
18733 __m256i __lasx_xvbitset_w (__m256i, __m256i);
18734 __m256i __lasx_xvbsll_v (__m256i, imm0_31);
18735 __m256i __lasx_xvbsrl_v (__m256i, imm0_31);
18736 __m256i __lasx_xvclo_b (__m256i);
18737 __m256i __lasx_xvclo_d (__m256i);
18738 __m256i __lasx_xvclo_h (__m256i);
18739 __m256i __lasx_xvclo_w (__m256i);
18740 __m256i __lasx_xvclz_b (__m256i);
18741 __m256i __lasx_xvclz_d (__m256i);
18742 __m256i __lasx_xvclz_h (__m256i);
18743 __m256i __lasx_xvclz_w (__m256i);
18744 __m256i __lasx_xvdiv_b (__m256i, __m256i);
18745 __m256i __lasx_xvdiv_bu (__m256i, __m256i);
18746 __m256i __lasx_xvdiv_d (__m256i, __m256i);
18747 __m256i __lasx_xvdiv_du (__m256i, __m256i);
18748 __m256i __lasx_xvdiv_h (__m256i, __m256i);
18749 __m256i __lasx_xvdiv_hu (__m256i, __m256i);
18750 __m256i __lasx_xvdiv_w (__m256i, __m256i);
18751 __m256i __lasx_xvdiv_wu (__m256i, __m256i);
18752 __m256i __lasx_xvexth_du_wu (__m256i);
18753 __m256i __lasx_xvexth_d_w (__m256i);
18754 __m256i __lasx_xvexth_h_b (__m256i);
18755 __m256i __lasx_xvexth_hu_bu (__m256i);
18756 __m256i __lasx_xvexth_q_d (__m256i);
18757 __m256i __lasx_xvexth_qu_du (__m256i);
18758 __m256i __lasx_xvexth_w_h (__m256i);
18759 __m256i __lasx_xvexth_wu_hu (__m256i);
18760 __m256i __lasx_xvextl_q_d (__m256i);
18761 __m256i __lasx_xvextl_qu_du (__m256i);
18762 __m256i __lasx_xvextrins_b (__m256i, __m256i, imm0_255);
18763 __m256i __lasx_xvextrins_d (__m256i, __m256i, imm0_255);
18764 __m256i __lasx_xvextrins_h (__m256i, __m256i, imm0_255);
18765 __m256i __lasx_xvextrins_w (__m256i, __m256i, imm0_255);
18766 __m256d __lasx_xvfadd_d (__m256d, __m256d);
18767 __m256 __lasx_xvfadd_s (__m256, __m256);
18768 __m256i __lasx_xvfclass_d (__m256d);
18769 __m256i __lasx_xvfclass_s (__m256);
18770 __m256i __lasx_xvfcmp_caf_d (__m256d, __m256d);
18771 __m256i __lasx_xvfcmp_caf_s (__m256, __m256);
18772 __m256i __lasx_xvfcmp_ceq_d (__m256d, __m256d);
18773 __m256i __lasx_xvfcmp_ceq_s (__m256, __m256);
18774 __m256i __lasx_xvfcmp_cle_d (__m256d, __m256d);
18775 __m256i __lasx_xvfcmp_cle_s (__m256, __m256);
18776 __m256i __lasx_xvfcmp_clt_d (__m256d, __m256d);
18777 __m256i __lasx_xvfcmp_clt_s (__m256, __m256);
18778 __m256i __lasx_xvfcmp_cne_d (__m256d, __m256d);
18779 __m256i __lasx_xvfcmp_cne_s (__m256, __m256);
18780 __m256i __lasx_xvfcmp_cor_d (__m256d, __m256d);
18781 __m256i __lasx_xvfcmp_cor_s (__m256, __m256);
18782 __m256i __lasx_xvfcmp_cueq_d (__m256d, __m256d);
18783 __m256i __lasx_xvfcmp_cueq_s (__m256, __m256);
18784 __m256i __lasx_xvfcmp_cule_d (__m256d, __m256d);
18785 __m256i __lasx_xvfcmp_cule_s (__m256, __m256);
18786 __m256i __lasx_xvfcmp_cult_d (__m256d, __m256d);
18787 __m256i __lasx_xvfcmp_cult_s (__m256, __m256);
18788 __m256i __lasx_xvfcmp_cun_d (__m256d, __m256d);
18789 __m256i __lasx_xvfcmp_cune_d (__m256d, __m256d);
18790 __m256i __lasx_xvfcmp_cune_s (__m256, __m256);
18791 __m256i __lasx_xvfcmp_cun_s (__m256, __m256);
18792 __m256i __lasx_xvfcmp_saf_d (__m256d, __m256d);
18793 __m256i __lasx_xvfcmp_saf_s (__m256, __m256);
18794 __m256i __lasx_xvfcmp_seq_d (__m256d, __m256d);
18795 __m256i __lasx_xvfcmp_seq_s (__m256, __m256);
18796 __m256i __lasx_xvfcmp_sle_d (__m256d, __m256d);
18797 __m256i __lasx_xvfcmp_sle_s (__m256, __m256);
18798 __m256i __lasx_xvfcmp_slt_d (__m256d, __m256d);
18799 __m256i __lasx_xvfcmp_slt_s (__m256, __m256);
18800 __m256i __lasx_xvfcmp_sne_d (__m256d, __m256d);
18801 __m256i __lasx_xvfcmp_sne_s (__m256, __m256);
18802 __m256i __lasx_xvfcmp_sor_d (__m256d, __m256d);
18803 __m256i __lasx_xvfcmp_sor_s (__m256, __m256);
18804 __m256i __lasx_xvfcmp_sueq_d (__m256d, __m256d);
18805 __m256i __lasx_xvfcmp_sueq_s (__m256, __m256);
18806 __m256i __lasx_xvfcmp_sule_d (__m256d, __m256d);
18807 __m256i __lasx_xvfcmp_sule_s (__m256, __m256);
18808 __m256i __lasx_xvfcmp_sult_d (__m256d, __m256d);
18809 __m256i __lasx_xvfcmp_sult_s (__m256, __m256);
18810 __m256i __lasx_xvfcmp_sun_d (__m256d, __m256d);
18811 __m256i __lasx_xvfcmp_sune_d (__m256d, __m256d);
18812 __m256i __lasx_xvfcmp_sune_s (__m256, __m256);
18813 __m256i __lasx_xvfcmp_sun_s (__m256, __m256);
18814 __m256d __lasx_xvfcvth_d_s (__m256);
18815 __m256i __lasx_xvfcvt_h_s (__m256, __m256);
18816 __m256 __lasx_xvfcvth_s_h (__m256i);
18817 __m256d __lasx_xvfcvtl_d_s (__m256);
18818 __m256 __lasx_xvfcvtl_s_h (__m256i);
18819 __m256 __lasx_xvfcvt_s_d (__m256d, __m256d);
18820 __m256d __lasx_xvfdiv_d (__m256d, __m256d);
18821 __m256 __lasx_xvfdiv_s (__m256, __m256);
18822 __m256d __lasx_xvffint_d_l (__m256i);
18823 __m256d __lasx_xvffint_d_lu (__m256i);
18824 __m256d __lasx_xvffinth_d_w (__m256i);
18825 __m256d __lasx_xvffintl_d_w (__m256i);
18826 __m256 __lasx_xvffint_s_l (__m256i, __m256i);
18827 __m256 __lasx_xvffint_s_w (__m256i);
18828 __m256 __lasx_xvffint_s_wu (__m256i);
18829 __m256d __lasx_xvflogb_d (__m256d);
18830 __m256 __lasx_xvflogb_s (__m256);
18831 __m256d __lasx_xvfmadd_d (__m256d, __m256d, __m256d);
18832 __m256 __lasx_xvfmadd_s (__m256, __m256, __m256);
18833 __m256d __lasx_xvfmaxa_d (__m256d, __m256d);
18834 __m256 __lasx_xvfmaxa_s (__m256, __m256);
18835 __m256d __lasx_xvfmax_d (__m256d, __m256d);
18836 __m256 __lasx_xvfmax_s (__m256, __m256);
18837 __m256d __lasx_xvfmina_d (__m256d, __m256d);
18838 __m256 __lasx_xvfmina_s (__m256, __m256);
18839 __m256d __lasx_xvfmin_d (__m256d, __m256d);
18840 __m256 __lasx_xvfmin_s (__m256, __m256);
18841 __m256d __lasx_xvfmsub_d (__m256d, __m256d, __m256d);
18842 __m256 __lasx_xvfmsub_s (__m256, __m256, __m256);
18843 __m256d __lasx_xvfmul_d (__m256d, __m256d);
18844 __m256 __lasx_xvfmul_s (__m256, __m256);
18845 __m256d __lasx_xvfnmadd_d (__m256d, __m256d, __m256d);
18846 __m256 __lasx_xvfnmadd_s (__m256, __m256, __m256);
18847 __m256d __lasx_xvfnmsub_d (__m256d, __m256d, __m256d);
18848 __m256 __lasx_xvfnmsub_s (__m256, __m256, __m256);
18849 __m256d __lasx_xvfrecip_d (__m256d);
18850 __m256 __lasx_xvfrecip_s (__m256);
18851 __m256d __lasx_xvfrint_d (__m256d);
18852 __m256d __lasx_xvfrintrm_d (__m256d);
18853 __m256 __lasx_xvfrintrm_s (__m256);
18854 __m256d __lasx_xvfrintrne_d (__m256d);
18855 __m256 __lasx_xvfrintrne_s (__m256);
18856 __m256d __lasx_xvfrintrp_d (__m256d);
18857 __m256 __lasx_xvfrintrp_s (__m256);
18858 __m256d __lasx_xvfrintrz_d (__m256d);
18859 __m256 __lasx_xvfrintrz_s (__m256);
18860 __m256 __lasx_xvfrint_s (__m256);
18861 __m256d __lasx_xvfrsqrt_d (__m256d);
18862 __m256 __lasx_xvfrsqrt_s (__m256);
18863 __m256i __lasx_xvfrstp_b (__m256i, __m256i, __m256i);
18864 __m256i __lasx_xvfrstp_h (__m256i, __m256i, __m256i);
18865 __m256i __lasx_xvfrstpi_b (__m256i, __m256i, imm0_31);
18866 __m256i __lasx_xvfrstpi_h (__m256i, __m256i, imm0_31);
18867 __m256d __lasx_xvfsqrt_d (__m256d);
18868 __m256 __lasx_xvfsqrt_s (__m256);
18869 __m256d __lasx_xvfsub_d (__m256d, __m256d);
18870 __m256 __lasx_xvfsub_s (__m256, __m256);
18871 __m256i __lasx_xvftinth_l_s (__m256);
18872 __m256i __lasx_xvftint_l_d (__m256d);
18873 __m256i __lasx_xvftintl_l_s (__m256);
18874 __m256i __lasx_xvftint_lu_d (__m256d);
18875 __m256i __lasx_xvftintrmh_l_s (__m256);
18876 __m256i __lasx_xvftintrm_l_d (__m256d);
18877 __m256i __lasx_xvftintrml_l_s (__m256);
18878 __m256i __lasx_xvftintrm_w_d (__m256d, __m256d);
18879 __m256i __lasx_xvftintrm_w_s (__m256);
18880 __m256i __lasx_xvftintrneh_l_s (__m256);
18881 __m256i __lasx_xvftintrne_l_d (__m256d);
18882 __m256i __lasx_xvftintrnel_l_s (__m256);
18883 __m256i __lasx_xvftintrne_w_d (__m256d, __m256d);
18884 __m256i __lasx_xvftintrne_w_s (__m256);
18885 __m256i __lasx_xvftintrph_l_s (__m256);
18886 __m256i __lasx_xvftintrp_l_d (__m256d);
18887 __m256i __lasx_xvftintrpl_l_s (__m256);
18888 __m256i __lasx_xvftintrp_w_d (__m256d, __m256d);
18889 __m256i __lasx_xvftintrp_w_s (__m256);
18890 __m256i __lasx_xvftintrzh_l_s (__m256);
18891 __m256i __lasx_xvftintrz_l_d (__m256d);
18892 __m256i __lasx_xvftintrzl_l_s (__m256);
18893 __m256i __lasx_xvftintrz_lu_d (__m256d);
18894 __m256i __lasx_xvftintrz_w_d (__m256d, __m256d);
18895 __m256i __lasx_xvftintrz_w_s (__m256);
18896 __m256i __lasx_xvftintrz_wu_s (__m256);
18897 __m256i __lasx_xvftint_w_d (__m256d, __m256d);
18898 __m256i __lasx_xvftint_w_s (__m256);
18899 __m256i __lasx_xvftint_wu_s (__m256);
18900 __m256i __lasx_xvhaddw_du_wu (__m256i, __m256i);
18901 __m256i __lasx_xvhaddw_d_w (__m256i, __m256i);
18902 __m256i __lasx_xvhaddw_h_b (__m256i, __m256i);
18903 __m256i __lasx_xvhaddw_hu_bu (__m256i, __m256i);
18904 __m256i __lasx_xvhaddw_q_d (__m256i, __m256i);
18905 __m256i __lasx_xvhaddw_qu_du (__m256i, __m256i);
18906 __m256i __lasx_xvhaddw_w_h (__m256i, __m256i);
18907 __m256i __lasx_xvhaddw_wu_hu (__m256i, __m256i);
18908 __m256i __lasx_xvhsubw_du_wu (__m256i, __m256i);
18909 __m256i __lasx_xvhsubw_d_w (__m256i, __m256i);
18910 __m256i __lasx_xvhsubw_h_b (__m256i, __m256i);
18911 __m256i __lasx_xvhsubw_hu_bu (__m256i, __m256i);
18912 __m256i __lasx_xvhsubw_q_d (__m256i, __m256i);
18913 __m256i __lasx_xvhsubw_qu_du (__m256i, __m256i);
18914 __m256i __lasx_xvhsubw_w_h (__m256i, __m256i);
18915 __m256i __lasx_xvhsubw_wu_hu (__m256i, __m256i);
18916 __m256i __lasx_xvilvh_b (__m256i, __m256i);
18917 __m256i __lasx_xvilvh_d (__m256i, __m256i);
18918 __m256i __lasx_xvilvh_h (__m256i, __m256i);
18919 __m256i __lasx_xvilvh_w (__m256i, __m256i);
18920 __m256i __lasx_xvilvl_b (__m256i, __m256i);
18921 __m256i __lasx_xvilvl_d (__m256i, __m256i);
18922 __m256i __lasx_xvilvl_h (__m256i, __m256i);
18923 __m256i __lasx_xvilvl_w (__m256i, __m256i);
18924 __m256i __lasx_xvinsgr2vr_d (__m256i, long int, imm0_3);
18925 __m256i __lasx_xvinsgr2vr_w (__m256i, int, imm0_7);
18926 __m256i __lasx_xvinsve0_d (__m256i, __m256i, imm0_3);
18927 __m256i __lasx_xvinsve0_w (__m256i, __m256i, imm0_7);
18928 __m256i __lasx_xvld (void *, imm_n2048_2047);
18929 __m256i __lasx_xvldi (imm_n1024_1023);
18930 __m256i __lasx_xvldrepl_b (void *, imm_n2048_2047);
18931 __m256i __lasx_xvldrepl_d (void *, imm_n256_255);
18932 __m256i __lasx_xvldrepl_h (void *, imm_n1024_1023);
18933 __m256i __lasx_xvldrepl_w (void *, imm_n512_511);
18934 __m256i __lasx_xvldx (void *, long int);
18935 __m256i __lasx_xvmadd_b (__m256i, __m256i, __m256i);
18936 __m256i __lasx_xvmadd_d (__m256i, __m256i, __m256i);
18937 __m256i __lasx_xvmadd_h (__m256i, __m256i, __m256i);
18938 __m256i __lasx_xvmadd_w (__m256i, __m256i, __m256i);
18939 __m256i __lasx_xvmaddwev_d_w (__m256i, __m256i, __m256i);
18940 __m256i __lasx_xvmaddwev_d_wu (__m256i, __m256i, __m256i);
18941 __m256i __lasx_xvmaddwev_d_wu_w (__m256i, __m256i, __m256i);
18942 __m256i __lasx_xvmaddwev_h_b (__m256i, __m256i, __m256i);
18943 __m256i __lasx_xvmaddwev_h_bu (__m256i, __m256i, __m256i);
18944 __m256i __lasx_xvmaddwev_h_bu_b (__m256i, __m256i, __m256i);
18945 __m256i __lasx_xvmaddwev_q_d (__m256i, __m256i, __m256i);
18946 __m256i __lasx_xvmaddwev_q_du (__m256i, __m256i, __m256i);
18947 __m256i __lasx_xvmaddwev_q_du_d (__m256i, __m256i, __m256i);
18948 __m256i __lasx_xvmaddwev_w_h (__m256i, __m256i, __m256i);
18949 __m256i __lasx_xvmaddwev_w_hu (__m256i, __m256i, __m256i);
18950 __m256i __lasx_xvmaddwev_w_hu_h (__m256i, __m256i, __m256i);
18951 __m256i __lasx_xvmaddwod_d_w (__m256i, __m256i, __m256i);
18952 __m256i __lasx_xvmaddwod_d_wu (__m256i, __m256i, __m256i);
18953 __m256i __lasx_xvmaddwod_d_wu_w (__m256i, __m256i, __m256i);
18954 __m256i __lasx_xvmaddwod_h_b (__m256i, __m256i, __m256i);
18955 __m256i __lasx_xvmaddwod_h_bu (__m256i, __m256i, __m256i);
18956 __m256i __lasx_xvmaddwod_h_bu_b (__m256i, __m256i, __m256i);
18957 __m256i __lasx_xvmaddwod_q_d (__m256i, __m256i, __m256i);
18958 __m256i __lasx_xvmaddwod_q_du (__m256i, __m256i, __m256i);
18959 __m256i __lasx_xvmaddwod_q_du_d (__m256i, __m256i, __m256i);
18960 __m256i __lasx_xvmaddwod_w_h (__m256i, __m256i, __m256i);
18961 __m256i __lasx_xvmaddwod_w_hu (__m256i, __m256i, __m256i);
18962 __m256i __lasx_xvmaddwod_w_hu_h (__m256i, __m256i, __m256i);
18963 __m256i __lasx_xvmax_b (__m256i, __m256i);
18964 __m256i __lasx_xvmax_bu (__m256i, __m256i);
18965 __m256i __lasx_xvmax_d (__m256i, __m256i);
18966 __m256i __lasx_xvmax_du (__m256i, __m256i);
18967 __m256i __lasx_xvmax_h (__m256i, __m256i);
18968 __m256i __lasx_xvmax_hu (__m256i, __m256i);
18969 __m256i __lasx_xvmaxi_b (__m256i, imm_n16_15);
18970 __m256i __lasx_xvmaxi_bu (__m256i, imm0_31);
18971 __m256i __lasx_xvmaxi_d (__m256i, imm_n16_15);
18972 __m256i __lasx_xvmaxi_du (__m256i, imm0_31);
18973 __m256i __lasx_xvmaxi_h (__m256i, imm_n16_15);
18974 __m256i __lasx_xvmaxi_hu (__m256i, imm0_31);
18975 __m256i __lasx_xvmaxi_w (__m256i, imm_n16_15);
18976 __m256i __lasx_xvmaxi_wu (__m256i, imm0_31);
18977 __m256i __lasx_xvmax_w (__m256i, __m256i);
18978 __m256i __lasx_xvmax_wu (__m256i, __m256i);
18979 __m256i __lasx_xvmin_b (__m256i, __m256i);
18980 __m256i __lasx_xvmin_bu (__m256i, __m256i);
18981 __m256i __lasx_xvmin_d (__m256i, __m256i);
18982 __m256i __lasx_xvmin_du (__m256i, __m256i);
18983 __m256i __lasx_xvmin_h (__m256i, __m256i);
18984 __m256i __lasx_xvmin_hu (__m256i, __m256i);
18985 __m256i __lasx_xvmini_b (__m256i, imm_n16_15);
18986 __m256i __lasx_xvmini_bu (__m256i, imm0_31);
18987 __m256i __lasx_xvmini_d (__m256i, imm_n16_15);
18988 __m256i __lasx_xvmini_du (__m256i, imm0_31);
18989 __m256i __lasx_xvmini_h (__m256i, imm_n16_15);
18990 __m256i __lasx_xvmini_hu (__m256i, imm0_31);
18991 __m256i __lasx_xvmini_w (__m256i, imm_n16_15);
18992 __m256i __lasx_xvmini_wu (__m256i, imm0_31);
18993 __m256i __lasx_xvmin_w (__m256i, __m256i);
18994 __m256i __lasx_xvmin_wu (__m256i, __m256i);
18995 __m256i __lasx_xvmod_b (__m256i, __m256i);
18996 __m256i __lasx_xvmod_bu (__m256i, __m256i);
18997 __m256i __lasx_xvmod_d (__m256i, __m256i);
18998 __m256i __lasx_xvmod_du (__m256i, __m256i);
18999 __m256i __lasx_xvmod_h (__m256i, __m256i);
19000 __m256i __lasx_xvmod_hu (__m256i, __m256i);
19001 __m256i __lasx_xvmod_w (__m256i, __m256i);
19002 __m256i __lasx_xvmod_wu (__m256i, __m256i);
19003 __m256i __lasx_xvmskgez_b (__m256i);
19004 __m256i __lasx_xvmskltz_b (__m256i);
19005 __m256i __lasx_xvmskltz_d (__m256i);
19006 __m256i __lasx_xvmskltz_h (__m256i);
19007 __m256i __lasx_xvmskltz_w (__m256i);
19008 __m256i __lasx_xvmsknz_b (__m256i);
19009 __m256i __lasx_xvmsub_b (__m256i, __m256i, __m256i);
19010 __m256i __lasx_xvmsub_d (__m256i, __m256i, __m256i);
19011 __m256i __lasx_xvmsub_h (__m256i, __m256i, __m256i);
19012 __m256i __lasx_xvmsub_w (__m256i, __m256i, __m256i);
19013 __m256i __lasx_xvmuh_b (__m256i, __m256i);
19014 __m256i __lasx_xvmuh_bu (__m256i, __m256i);
19015 __m256i __lasx_xvmuh_d (__m256i, __m256i);
19016 __m256i __lasx_xvmuh_du (__m256i, __m256i);
19017 __m256i __lasx_xvmuh_h (__m256i, __m256i);
19018 __m256i __lasx_xvmuh_hu (__m256i, __m256i);
19019 __m256i __lasx_xvmuh_w (__m256i, __m256i);
19020 __m256i __lasx_xvmuh_wu (__m256i, __m256i);
19021 __m256i __lasx_xvmul_b (__m256i, __m256i);
19022 __m256i __lasx_xvmul_d (__m256i, __m256i);
19023 __m256i __lasx_xvmul_h (__m256i, __m256i);
19024 __m256i __lasx_xvmul_w (__m256i, __m256i);
19025 __m256i __lasx_xvmulwev_d_w (__m256i, __m256i);
19026 __m256i __lasx_xvmulwev_d_wu (__m256i, __m256i);
19027 __m256i __lasx_xvmulwev_d_wu_w (__m256i, __m256i);
19028 __m256i __lasx_xvmulwev_h_b (__m256i, __m256i);
19029 __m256i __lasx_xvmulwev_h_bu (__m256i, __m256i);
19030 __m256i __lasx_xvmulwev_h_bu_b (__m256i, __m256i);
19031 __m256i __lasx_xvmulwev_q_d (__m256i, __m256i);
19032 __m256i __lasx_xvmulwev_q_du (__m256i, __m256i);
19033 __m256i __lasx_xvmulwev_q_du_d (__m256i, __m256i);
19034 __m256i __lasx_xvmulwev_w_h (__m256i, __m256i);
19035 __m256i __lasx_xvmulwev_w_hu (__m256i, __m256i);
19036 __m256i __lasx_xvmulwev_w_hu_h (__m256i, __m256i);
19037 __m256i __lasx_xvmulwod_d_w (__m256i, __m256i);
19038 __m256i __lasx_xvmulwod_d_wu (__m256i, __m256i);
19039 __m256i __lasx_xvmulwod_d_wu_w (__m256i, __m256i);
19040 __m256i __lasx_xvmulwod_h_b (__m256i, __m256i);
19041 __m256i __lasx_xvmulwod_h_bu (__m256i, __m256i);
19042 __m256i __lasx_xvmulwod_h_bu_b (__m256i, __m256i);
19043 __m256i __lasx_xvmulwod_q_d (__m256i, __m256i);
19044 __m256i __lasx_xvmulwod_q_du (__m256i, __m256i);
19045 __m256i __lasx_xvmulwod_q_du_d (__m256i, __m256i);
19046 __m256i __lasx_xvmulwod_w_h (__m256i, __m256i);
19047 __m256i __lasx_xvmulwod_w_hu (__m256i, __m256i);
19048 __m256i __lasx_xvmulwod_w_hu_h (__m256i, __m256i);
19049 __m256i __lasx_xvneg_b (__m256i);
19050 __m256i __lasx_xvneg_d (__m256i);
19051 __m256i __lasx_xvneg_h (__m256i);
19052 __m256i __lasx_xvneg_w (__m256i);
19053 __m256i __lasx_xvnori_b (__m256i, imm0_255);
19054 __m256i __lasx_xvnor_v (__m256i, __m256i);
19055 __m256i __lasx_xvori_b (__m256i, imm0_255);
19056 __m256i __lasx_xvorn_v (__m256i, __m256i);
19057 __m256i __lasx_xvor_v (__m256i, __m256i);
19058 __m256i __lasx_xvpackev_b (__m256i, __m256i);
19059 __m256i __lasx_xvpackev_d (__m256i, __m256i);
19060 __m256i __lasx_xvpackev_h (__m256i, __m256i);
19061 __m256i __lasx_xvpackev_w (__m256i, __m256i);
19062 __m256i __lasx_xvpackod_b (__m256i, __m256i);
19063 __m256i __lasx_xvpackod_d (__m256i, __m256i);
19064 __m256i __lasx_xvpackod_h (__m256i, __m256i);
19065 __m256i __lasx_xvpackod_w (__m256i, __m256i);
19066 __m256i __lasx_xvpcnt_b (__m256i);
19067 __m256i __lasx_xvpcnt_d (__m256i);
19068 __m256i __lasx_xvpcnt_h (__m256i);
19069 __m256i __lasx_xvpcnt_w (__m256i);
19070 __m256i __lasx_xvpermi_d (__m256i, imm0_255);
19071 __m256i __lasx_xvpermi_q (__m256i, __m256i, imm0_255);
19072 __m256i __lasx_xvpermi_w (__m256i, __m256i, imm0_255);
19073 __m256i __lasx_xvperm_w (__m256i, __m256i);
19074 __m256i __lasx_xvpickev_b (__m256i, __m256i);
19075 __m256i __lasx_xvpickev_d (__m256i, __m256i);
19076 __m256i __lasx_xvpickev_h (__m256i, __m256i);
19077 __m256i __lasx_xvpickev_w (__m256i, __m256i);
19078 __m256i __lasx_xvpickod_b (__m256i, __m256i);
19079 __m256i __lasx_xvpickod_d (__m256i, __m256i);
19080 __m256i __lasx_xvpickod_h (__m256i, __m256i);
19081 __m256i __lasx_xvpickod_w (__m256i, __m256i);
19082 long int __lasx_xvpickve2gr_d (__m256i, imm0_3);
19083 unsigned long int __lasx_xvpickve2gr_du (__m256i, imm0_3);
19084 int __lasx_xvpickve2gr_w (__m256i, imm0_7);
19085 unsigned int __lasx_xvpickve2gr_wu (__m256i, imm0_7);
19086 __m256i __lasx_xvpickve_d (__m256i, imm0_3);
19087 __m256d __lasx_xvpickve_d_f (__m256d, imm0_3);
19088 __m256i __lasx_xvpickve_w (__m256i, imm0_7);
19089 __m256 __lasx_xvpickve_w_f (__m256, imm0_7);
19090 __m256i __lasx_xvrepl128vei_b (__m256i, imm0_15);
19091 __m256i __lasx_xvrepl128vei_d (__m256i, imm0_1);
19092 __m256i __lasx_xvrepl128vei_h (__m256i, imm0_7);
19093 __m256i __lasx_xvrepl128vei_w (__m256i, imm0_3);
19094 __m256i __lasx_xvreplgr2vr_b (int);
19095 __m256i __lasx_xvreplgr2vr_d (long int);
19096 __m256i __lasx_xvreplgr2vr_h (int);
19097 __m256i __lasx_xvreplgr2vr_w (int);
19098 __m256i __lasx_xvrepli_b (imm_n512_511);
19099 __m256i __lasx_xvrepli_d (imm_n512_511);
19100 __m256i __lasx_xvrepli_h (imm_n512_511);
19101 __m256i __lasx_xvrepli_w (imm_n512_511);
19102 __m256i __lasx_xvreplve0_b (__m256i);
19103 __m256i __lasx_xvreplve0_d (__m256i);
19104 __m256i __lasx_xvreplve0_h (__m256i);
19105 __m256i __lasx_xvreplve0_q (__m256i);
19106 __m256i __lasx_xvreplve0_w (__m256i);
19107 __m256i __lasx_xvreplve_b (__m256i, int);
19108 __m256i __lasx_xvreplve_d (__m256i, int);
19109 __m256i __lasx_xvreplve_h (__m256i, int);
19110 __m256i __lasx_xvreplve_w (__m256i, int);
19111 __m256i __lasx_xvrotr_b (__m256i, __m256i);
19112 __m256i __lasx_xvrotr_d (__m256i, __m256i);
19113 __m256i __lasx_xvrotr_h (__m256i, __m256i);
19114 __m256i __lasx_xvrotri_b (__m256i, imm0_7);
19115 __m256i __lasx_xvrotri_d (__m256i, imm0_63);
19116 __m256i __lasx_xvrotri_h (__m256i, imm0_15);
19117 __m256i __lasx_xvrotri_w (__m256i, imm0_31);
19118 __m256i __lasx_xvrotr_w (__m256i, __m256i);
19119 __m256i __lasx_xvsadd_b (__m256i, __m256i);
19120 __m256i __lasx_xvsadd_bu (__m256i, __m256i);
19121 __m256i __lasx_xvsadd_d (__m256i, __m256i);
19122 __m256i __lasx_xvsadd_du (__m256i, __m256i);
19123 __m256i __lasx_xvsadd_h (__m256i, __m256i);
19124 __m256i __lasx_xvsadd_hu (__m256i, __m256i);
19125 __m256i __lasx_xvsadd_w (__m256i, __m256i);
19126 __m256i __lasx_xvsadd_wu (__m256i, __m256i);
19127 __m256i __lasx_xvsat_b (__m256i, imm0_7);
19128 __m256i __lasx_xvsat_bu (__m256i, imm0_7);
19129 __m256i __lasx_xvsat_d (__m256i, imm0_63);
19130 __m256i __lasx_xvsat_du (__m256i, imm0_63);
19131 __m256i __lasx_xvsat_h (__m256i, imm0_15);
19132 __m256i __lasx_xvsat_hu (__m256i, imm0_15);
19133 __m256i __lasx_xvsat_w (__m256i, imm0_31);
19134 __m256i __lasx_xvsat_wu (__m256i, imm0_31);
19135 __m256i __lasx_xvseq_b (__m256i, __m256i);
19136 __m256i __lasx_xvseq_d (__m256i, __m256i);
19137 __m256i __lasx_xvseq_h (__m256i, __m256i);
19138 __m256i __lasx_xvseqi_b (__m256i, imm_n16_15);
19139 __m256i __lasx_xvseqi_d (__m256i, imm_n16_15);
19140 __m256i __lasx_xvseqi_h (__m256i, imm_n16_15);
19141 __m256i __lasx_xvseqi_w (__m256i, imm_n16_15);
19142 __m256i __lasx_xvseq_w (__m256i, __m256i);
19143 __m256i __lasx_xvshuf4i_b (__m256i, imm0_255);
19144 __m256i __lasx_xvshuf4i_d (__m256i, __m256i, imm0_255);
19145 __m256i __lasx_xvshuf4i_h (__m256i, imm0_255);
19146 __m256i __lasx_xvshuf4i_w (__m256i, imm0_255);
19147 __m256i __lasx_xvshuf_b (__m256i, __m256i, __m256i);
19148 __m256i __lasx_xvshuf_d (__m256i, __m256i, __m256i);
19149 __m256i __lasx_xvshuf_h (__m256i, __m256i, __m256i);
19150 __m256i __lasx_xvshuf_w (__m256i, __m256i, __m256i);
19151 __m256i __lasx_xvsigncov_b (__m256i, __m256i);
19152 __m256i __lasx_xvsigncov_d (__m256i, __m256i);
19153 __m256i __lasx_xvsigncov_h (__m256i, __m256i);
19154 __m256i __lasx_xvsigncov_w (__m256i, __m256i);
19155 __m256i __lasx_xvsle_b (__m256i, __m256i);
19156 __m256i __lasx_xvsle_bu (__m256i, __m256i);
19157 __m256i __lasx_xvsle_d (__m256i, __m256i);
19158 __m256i __lasx_xvsle_du (__m256i, __m256i);
19159 __m256i __lasx_xvsle_h (__m256i, __m256i);
19160 __m256i __lasx_xvsle_hu (__m256i, __m256i);
19161 __m256i __lasx_xvslei_b (__m256i, imm_n16_15);
19162 __m256i __lasx_xvslei_bu (__m256i, imm0_31);
19163 __m256i __lasx_xvslei_d (__m256i, imm_n16_15);
19164 __m256i __lasx_xvslei_du (__m256i, imm0_31);
19165 __m256i __lasx_xvslei_h (__m256i, imm_n16_15);
19166 __m256i __lasx_xvslei_hu (__m256i, imm0_31);
19167 __m256i __lasx_xvslei_w (__m256i, imm_n16_15);
19168 __m256i __lasx_xvslei_wu (__m256i, imm0_31);
19169 __m256i __lasx_xvsle_w (__m256i, __m256i);
19170 __m256i __lasx_xvsle_wu (__m256i, __m256i);
19171 __m256i __lasx_xvsll_b (__m256i, __m256i);
19172 __m256i __lasx_xvsll_d (__m256i, __m256i);
19173 __m256i __lasx_xvsll_h (__m256i, __m256i);
19174 __m256i __lasx_xvslli_b (__m256i, imm0_7);
19175 __m256i __lasx_xvslli_d (__m256i, imm0_63);
19176 __m256i __lasx_xvslli_h (__m256i, imm0_15);
19177 __m256i __lasx_xvslli_w (__m256i, imm0_31);
19178 __m256i __lasx_xvsll_w (__m256i, __m256i);
19179 __m256i __lasx_xvsllwil_du_wu (__m256i, imm0_31);
19180 __m256i __lasx_xvsllwil_d_w (__m256i, imm0_31);
19181 __m256i __lasx_xvsllwil_h_b (__m256i, imm0_7);
19182 __m256i __lasx_xvsllwil_hu_bu (__m256i, imm0_7);
19183 __m256i __lasx_xvsllwil_w_h (__m256i, imm0_15);
19184 __m256i __lasx_xvsllwil_wu_hu (__m256i, imm0_15);
19185 __m256i __lasx_xvslt_b (__m256i, __m256i);
19186 __m256i __lasx_xvslt_bu (__m256i, __m256i);
19187 __m256i __lasx_xvslt_d (__m256i, __m256i);
19188 __m256i __lasx_xvslt_du (__m256i, __m256i);
19189 __m256i __lasx_xvslt_h (__m256i, __m256i);
19190 __m256i __lasx_xvslt_hu (__m256i, __m256i);
19191 __m256i __lasx_xvslti_b (__m256i, imm_n16_15);
19192 __m256i __lasx_xvslti_bu (__m256i, imm0_31);
19193 __m256i __lasx_xvslti_d (__m256i, imm_n16_15);
19194 __m256i __lasx_xvslti_du (__m256i, imm0_31);
19195 __m256i __lasx_xvslti_h (__m256i, imm_n16_15);
19196 __m256i __lasx_xvslti_hu (__m256i, imm0_31);
19197 __m256i __lasx_xvslti_w (__m256i, imm_n16_15);
19198 __m256i __lasx_xvslti_wu (__m256i, imm0_31);
19199 __m256i __lasx_xvslt_w (__m256i, __m256i);
19200 __m256i __lasx_xvslt_wu (__m256i, __m256i);
19201 __m256i __lasx_xvsra_b (__m256i, __m256i);
19202 __m256i __lasx_xvsra_d (__m256i, __m256i);
19203 __m256i __lasx_xvsra_h (__m256i, __m256i);
19204 __m256i __lasx_xvsrai_b (__m256i, imm0_7);
19205 __m256i __lasx_xvsrai_d (__m256i, imm0_63);
19206 __m256i __lasx_xvsrai_h (__m256i, imm0_15);
19207 __m256i __lasx_xvsrai_w (__m256i, imm0_31);
19208 __m256i __lasx_xvsran_b_h (__m256i, __m256i);
19209 __m256i __lasx_xvsran_h_w (__m256i, __m256i);
19210 __m256i __lasx_xvsrani_b_h (__m256i, __m256i, imm0_15);
19211 __m256i __lasx_xvsrani_d_q (__m256i, __m256i, imm0_127);
19212 __m256i __lasx_xvsrani_h_w (__m256i, __m256i, imm0_31);
19213 __m256i __lasx_xvsrani_w_d (__m256i, __m256i, imm0_63);
19214 __m256i __lasx_xvsran_w_d (__m256i, __m256i);
19215 __m256i __lasx_xvsrar_b (__m256i, __m256i);
19216 __m256i __lasx_xvsrar_d (__m256i, __m256i);
19217 __m256i __lasx_xvsrar_h (__m256i, __m256i);
19218 __m256i __lasx_xvsrari_b (__m256i, imm0_7);
19219 __m256i __lasx_xvsrari_d (__m256i, imm0_63);
19220 __m256i __lasx_xvsrari_h (__m256i, imm0_15);
19221 __m256i __lasx_xvsrari_w (__m256i, imm0_31);
19222 __m256i __lasx_xvsrarn_b_h (__m256i, __m256i);
19223 __m256i __lasx_xvsrarn_h_w (__m256i, __m256i);
19224 __m256i __lasx_xvsrarni_b_h (__m256i, __m256i, imm0_15);
19225 __m256i __lasx_xvsrarni_d_q (__m256i, __m256i, imm0_127);
19226 __m256i __lasx_xvsrarni_h_w (__m256i, __m256i, imm0_31);
19227 __m256i __lasx_xvsrarni_w_d (__m256i, __m256i, imm0_63);
19228 __m256i __lasx_xvsrarn_w_d (__m256i, __m256i);
19229 __m256i __lasx_xvsrar_w (__m256i, __m256i);
19230 __m256i __lasx_xvsra_w (__m256i, __m256i);
19231 __m256i __lasx_xvsrl_b (__m256i, __m256i);
19232 __m256i __lasx_xvsrl_d (__m256i, __m256i);
19233 __m256i __lasx_xvsrl_h (__m256i, __m256i);
19234 __m256i __lasx_xvsrli_b (__m256i, imm0_7);
19235 __m256i __lasx_xvsrli_d (__m256i, imm0_63);
19236 __m256i __lasx_xvsrli_h (__m256i, imm0_15);
19237 __m256i __lasx_xvsrli_w (__m256i, imm0_31);
19238 __m256i __lasx_xvsrln_b_h (__m256i, __m256i);
19239 __m256i __lasx_xvsrln_h_w (__m256i, __m256i);
19240 __m256i __lasx_xvsrlni_b_h (__m256i, __m256i, imm0_15);
19241 __m256i __lasx_xvsrlni_d_q (__m256i, __m256i, imm0_127);
19242 __m256i __lasx_xvsrlni_h_w (__m256i, __m256i, imm0_31);
19243 __m256i __lasx_xvsrlni_w_d (__m256i, __m256i, imm0_63);
19244 __m256i __lasx_xvsrln_w_d (__m256i, __m256i);
19245 __m256i __lasx_xvsrlr_b (__m256i, __m256i);
19246 __m256i __lasx_xvsrlr_d (__m256i, __m256i);
19247 __m256i __lasx_xvsrlr_h (__m256i, __m256i);
19248 __m256i __lasx_xvsrlri_b (__m256i, imm0_7);
19249 __m256i __lasx_xvsrlri_d (__m256i, imm0_63);
19250 __m256i __lasx_xvsrlri_h (__m256i, imm0_15);
19251 __m256i __lasx_xvsrlri_w (__m256i, imm0_31);
19252 __m256i __lasx_xvsrlrn_b_h (__m256i, __m256i);
19253 __m256i __lasx_xvsrlrn_h_w (__m256i, __m256i);
19254 __m256i __lasx_xvsrlrni_b_h (__m256i, __m256i, imm0_15);
19255 __m256i __lasx_xvsrlrni_d_q (__m256i, __m256i, imm0_127);
19256 __m256i __lasx_xvsrlrni_h_w (__m256i, __m256i, imm0_31);
19257 __m256i __lasx_xvsrlrni_w_d (__m256i, __m256i, imm0_63);
19258 __m256i __lasx_xvsrlrn_w_d (__m256i, __m256i);
19259 __m256i __lasx_xvsrlr_w (__m256i, __m256i);
19260 __m256i __lasx_xvsrl_w (__m256i, __m256i);
19261 __m256i __lasx_xvssran_b_h (__m256i, __m256i);
19262 __m256i __lasx_xvssran_bu_h (__m256i, __m256i);
19263 __m256i __lasx_xvssran_hu_w (__m256i, __m256i);
19264 __m256i __lasx_xvssran_h_w (__m256i, __m256i);
19265 __m256i __lasx_xvssrani_b_h (__m256i, __m256i, imm0_15);
19266 __m256i __lasx_xvssrani_bu_h (__m256i, __m256i, imm0_15);
19267 __m256i __lasx_xvssrani_d_q (__m256i, __m256i, imm0_127);
19268 __m256i __lasx_xvssrani_du_q (__m256i, __m256i, imm0_127);
19269 __m256i __lasx_xvssrani_hu_w (__m256i, __m256i, imm0_31);
19270 __m256i __lasx_xvssrani_h_w (__m256i, __m256i, imm0_31);
19271 __m256i __lasx_xvssrani_w_d (__m256i, __m256i, imm0_63);
19272 __m256i __lasx_xvssrani_wu_d (__m256i, __m256i, imm0_63);
19273 __m256i __lasx_xvssran_w_d (__m256i, __m256i);
19274 __m256i __lasx_xvssran_wu_d (__m256i, __m256i);
19275 __m256i __lasx_xvssrarn_b_h (__m256i, __m256i);
19276 __m256i __lasx_xvssrarn_bu_h (__m256i, __m256i);
19277 __m256i __lasx_xvssrarn_hu_w (__m256i, __m256i);
19278 __m256i __lasx_xvssrarn_h_w (__m256i, __m256i);
19279 __m256i __lasx_xvssrarni_b_h (__m256i, __m256i, imm0_15);
19280 __m256i __lasx_xvssrarni_bu_h (__m256i, __m256i, imm0_15);
19281 __m256i __lasx_xvssrarni_d_q (__m256i, __m256i, imm0_127);
19282 __m256i __lasx_xvssrarni_du_q (__m256i, __m256i, imm0_127);
19283 __m256i __lasx_xvssrarni_hu_w (__m256i, __m256i, imm0_31);
19284 __m256i __lasx_xvssrarni_h_w (__m256i, __m256i, imm0_31);
19285 __m256i __lasx_xvssrarni_w_d (__m256i, __m256i, imm0_63);
19286 __m256i __lasx_xvssrarni_wu_d (__m256i, __m256i, imm0_63);
19287 __m256i __lasx_xvssrarn_w_d (__m256i, __m256i);
19288 __m256i __lasx_xvssrarn_wu_d (__m256i, __m256i);
19289 __m256i __lasx_xvssrln_b_h (__m256i, __m256i);
19290 __m256i __lasx_xvssrln_bu_h (__m256i, __m256i);
19291 __m256i __lasx_xvssrln_hu_w (__m256i, __m256i);
19292 __m256i __lasx_xvssrln_h_w (__m256i, __m256i);
19293 __m256i __lasx_xvssrlni_b_h (__m256i, __m256i, imm0_15);
19294 __m256i __lasx_xvssrlni_bu_h (__m256i, __m256i, imm0_15);
19295 __m256i __lasx_xvssrlni_d_q (__m256i, __m256i, imm0_127);
19296 __m256i __lasx_xvssrlni_du_q (__m256i, __m256i, imm0_127);
19297 __m256i __lasx_xvssrlni_hu_w (__m256i, __m256i, imm0_31);
19298 __m256i __lasx_xvssrlni_h_w (__m256i, __m256i, imm0_31);
19299 __m256i __lasx_xvssrlni_w_d (__m256i, __m256i, imm0_63);
19300 __m256i __lasx_xvssrlni_wu_d (__m256i, __m256i, imm0_63);
19301 __m256i __lasx_xvssrln_w_d (__m256i, __m256i);
19302 __m256i __lasx_xvssrln_wu_d (__m256i, __m256i);
19303 __m256i __lasx_xvssrlrn_b_h (__m256i, __m256i);
19304 __m256i __lasx_xvssrlrn_bu_h (__m256i, __m256i);
19305 __m256i __lasx_xvssrlrn_hu_w (__m256i, __m256i);
19306 __m256i __lasx_xvssrlrn_h_w (__m256i, __m256i);
19307 __m256i __lasx_xvssrlrni_b_h (__m256i, __m256i, imm0_15);
19308 __m256i __lasx_xvssrlrni_bu_h (__m256i, __m256i, imm0_15);
19309 __m256i __lasx_xvssrlrni_d_q (__m256i, __m256i, imm0_127);
19310 __m256i __lasx_xvssrlrni_du_q (__m256i, __m256i, imm0_127);
19311 __m256i __lasx_xvssrlrni_hu_w (__m256i, __m256i, imm0_31);
19312 __m256i __lasx_xvssrlrni_h_w (__m256i, __m256i, imm0_31);
19313 __m256i __lasx_xvssrlrni_w_d (__m256i, __m256i, imm0_63);
19314 __m256i __lasx_xvssrlrni_wu_d (__m256i, __m256i, imm0_63);
19315 __m256i __lasx_xvssrlrn_w_d (__m256i, __m256i);
19316 __m256i __lasx_xvssrlrn_wu_d (__m256i, __m256i);
19317 __m256i __lasx_xvssub_b (__m256i, __m256i);
19318 __m256i __lasx_xvssub_bu (__m256i, __m256i);
19319 __m256i __lasx_xvssub_d (__m256i, __m256i);
19320 __m256i __lasx_xvssub_du (__m256i, __m256i);
19321 __m256i __lasx_xvssub_h (__m256i, __m256i);
19322 __m256i __lasx_xvssub_hu (__m256i, __m256i);
19323 __m256i __lasx_xvssub_w (__m256i, __m256i);
19324 __m256i __lasx_xvssub_wu (__m256i, __m256i);
19325 void __lasx_xvst (__m256i, void *, imm_n2048_2047);
19326 void __lasx_xvstelm_b (__m256i, void *, imm_n128_127, imm0_31);
19327 void __lasx_xvstelm_d (__m256i, void *, imm_n128_127, imm0_3);
19328 void __lasx_xvstelm_h (__m256i, void *, imm_n128_127, imm0_15);
19329 void __lasx_xvstelm_w (__m256i, void *, imm_n128_127, imm0_7);
19330 void __lasx_xvstx (__m256i, void *, long int);
19331 __m256i __lasx_xvsub_b (__m256i, __m256i);
19332 __m256i __lasx_xvsub_d (__m256i, __m256i);
19333 __m256i __lasx_xvsub_h (__m256i, __m256i);
19334 __m256i __lasx_xvsubi_bu (__m256i, imm0_31);
19335 __m256i __lasx_xvsubi_du (__m256i, imm0_31);
19336 __m256i __lasx_xvsubi_hu (__m256i, imm0_31);
19337 __m256i __lasx_xvsubi_wu (__m256i, imm0_31);
19338 __m256i __lasx_xvsub_q (__m256i, __m256i);
19339 __m256i __lasx_xvsub_w (__m256i, __m256i);
19340 __m256i __lasx_xvsubwev_d_w (__m256i, __m256i);
19341 __m256i __lasx_xvsubwev_d_wu (__m256i, __m256i);
19342 __m256i __lasx_xvsubwev_h_b (__m256i, __m256i);
19343 __m256i __lasx_xvsubwev_h_bu (__m256i, __m256i);
19344 __m256i __lasx_xvsubwev_q_d (__m256i, __m256i);
19345 __m256i __lasx_xvsubwev_q_du (__m256i, __m256i);
19346 __m256i __lasx_xvsubwev_w_h (__m256i, __m256i);
19347 __m256i __lasx_xvsubwev_w_hu (__m256i, __m256i);
19348 __m256i __lasx_xvsubwod_d_w (__m256i, __m256i);
19349 __m256i __lasx_xvsubwod_d_wu (__m256i, __m256i);
19350 __m256i __lasx_xvsubwod_h_b (__m256i, __m256i);
19351 __m256i __lasx_xvsubwod_h_bu (__m256i, __m256i);
19352 __m256i __lasx_xvsubwod_q_d (__m256i, __m256i);
19353 __m256i __lasx_xvsubwod_q_du (__m256i, __m256i);
19354 __m256i __lasx_xvsubwod_w_h (__m256i, __m256i);
19355 __m256i __lasx_xvsubwod_w_hu (__m256i, __m256i);
19356 __m256i __lasx_xvxori_b (__m256i, imm0_255);
19357 __m256i __lasx_xvxor_v (__m256i, __m256i);
19358 @end smallexample
19360 These instrisic functions are available by including @code{lasxintrin.h} and
19361 using @option{-mfrecipe} and @option{-mlasx}.
19362 @smallexample
19363 __m256d __lasx_xvfrecipe_d (__m256d);
19364 __m256 __lasx_xvfrecipe_s (__m256);
19365 __m256d __lasx_xvfrsqrte_d (__m256d);
19366 __m256 __lasx_xvfrsqrte_s (__m256);
19367 @end smallexample
19369 @node MIPS DSP Built-in Functions
19370 @subsection MIPS DSP Built-in Functions
19372 The MIPS DSP Application-Specific Extension (ASE) includes new
19373 instructions that are designed to improve the performance of DSP and
19374 media applications.  It provides instructions that operate on packed
19375 8-bit/16-bit integer data, Q7, Q15 and Q31 fractional data.
19377 GCC supports MIPS DSP operations using both the generic
19378 vector extensions (@pxref{Vector Extensions}) and a collection of
19379 MIPS-specific built-in functions.  Both kinds of support are
19380 enabled by the @option{-mdsp} command-line option.
19382 Revision 2 of the ASE was introduced in the second half of 2006.
19383 This revision adds extra instructions to the original ASE, but is
19384 otherwise backwards-compatible with it.  You can select revision 2
19385 using the command-line option @option{-mdspr2}; this option implies
19386 @option{-mdsp}.
19388 The SCOUNT and POS bits of the DSP control register are global.  The
19389 WRDSP, EXTPDP, EXTPDPV and MTHLIP instructions modify the SCOUNT and
19390 POS bits.  During optimization, the compiler does not delete these
19391 instructions and it does not delete calls to functions containing
19392 these instructions.
19394 At present, GCC only provides support for operations on 32-bit
19395 vectors.  The vector type associated with 8-bit integer data is
19396 usually called @code{v4i8}, the vector type associated with Q7
19397 is usually called @code{v4q7}, the vector type associated with 16-bit
19398 integer data is usually called @code{v2i16}, and the vector type
19399 associated with Q15 is usually called @code{v2q15}.  They can be
19400 defined in C as follows:
19402 @smallexample
19403 typedef signed char v4i8 __attribute__ ((vector_size(4)));
19404 typedef signed char v4q7 __attribute__ ((vector_size(4)));
19405 typedef short v2i16 __attribute__ ((vector_size(4)));
19406 typedef short v2q15 __attribute__ ((vector_size(4)));
19407 @end smallexample
19409 @code{v4i8}, @code{v4q7}, @code{v2i16} and @code{v2q15} values are
19410 initialized in the same way as aggregates.  For example:
19412 @smallexample
19413 v4i8 a = @{1, 2, 3, 4@};
19414 v4i8 b;
19415 b = (v4i8) @{5, 6, 7, 8@};
19417 v2q15 c = @{0x0fcb, 0x3a75@};
19418 v2q15 d;
19419 d = (v2q15) @{0.1234 * 0x1.0p15, 0.4567 * 0x1.0p15@};
19420 @end smallexample
19422 @emph{Note:} The CPU's endianness determines the order in which values
19423 are packed.  On little-endian targets, the first value is the least
19424 significant and the last value is the most significant.  The opposite
19425 order applies to big-endian targets.  For example, the code above
19426 sets the lowest byte of @code{a} to @code{1} on little-endian targets
19427 and @code{4} on big-endian targets.
19429 @emph{Note:} Q7, Q15 and Q31 values must be initialized with their integer
19430 representation.  As shown in this example, the integer representation
19431 of a Q7 value can be obtained by multiplying the fractional value by
19432 @code{0x1.0p7}.  The equivalent for Q15 values is to multiply by
19433 @code{0x1.0p15}.  The equivalent for Q31 values is to multiply by
19434 @code{0x1.0p31}.
19436 The table below lists the @code{v4i8} and @code{v2q15} operations for which
19437 hardware support exists.  @code{a} and @code{b} are @code{v4i8} values,
19438 and @code{c} and @code{d} are @code{v2q15} values.
19440 @multitable @columnfractions .50 .50
19441 @headitem C code @tab MIPS instruction
19442 @item @code{a + b} @tab @code{addu.qb}
19443 @item @code{c + d} @tab @code{addq.ph}
19444 @item @code{a - b} @tab @code{subu.qb}
19445 @item @code{c - d} @tab @code{subq.ph}
19446 @end multitable
19448 The table below lists the @code{v2i16} operation for which
19449 hardware support exists for the DSP ASE REV 2.  @code{e} and @code{f} are
19450 @code{v2i16} values.
19452 @multitable @columnfractions .50 .50
19453 @headitem C code @tab MIPS instruction
19454 @item @code{e * f} @tab @code{mul.ph}
19455 @end multitable
19457 It is easier to describe the DSP built-in functions if we first define
19458 the following types:
19460 @smallexample
19461 typedef int q31;
19462 typedef int i32;
19463 typedef unsigned int ui32;
19464 typedef long long a64;
19465 @end smallexample
19467 @code{q31} and @code{i32} are actually the same as @code{int}, but we
19468 use @code{q31} to indicate a Q31 fractional value and @code{i32} to
19469 indicate a 32-bit integer value.  Similarly, @code{a64} is the same as
19470 @code{long long}, but we use @code{a64} to indicate values that are
19471 placed in one of the four DSP accumulators (@code{$ac0},
19472 @code{$ac1}, @code{$ac2} or @code{$ac3}).
19474 Also, some built-in functions prefer or require immediate numbers as
19475 parameters, because the corresponding DSP instructions accept both immediate
19476 numbers and register operands, or accept immediate numbers only.  The
19477 immediate parameters are listed as follows.
19479 @smallexample
19480 imm0_3: 0 to 3.
19481 imm0_7: 0 to 7.
19482 imm0_15: 0 to 15.
19483 imm0_31: 0 to 31.
19484 imm0_63: 0 to 63.
19485 imm0_255: 0 to 255.
19486 imm_n32_31: -32 to 31.
19487 imm_n512_511: -512 to 511.
19488 @end smallexample
19490 The following built-in functions map directly to a particular MIPS DSP
19491 instruction.  Please refer to the architecture specification
19492 for details on what each instruction does.
19494 @smallexample
19495 v2q15 __builtin_mips_addq_ph (v2q15, v2q15);
19496 v2q15 __builtin_mips_addq_s_ph (v2q15, v2q15);
19497 q31 __builtin_mips_addq_s_w (q31, q31);
19498 v4i8 __builtin_mips_addu_qb (v4i8, v4i8);
19499 v4i8 __builtin_mips_addu_s_qb (v4i8, v4i8);
19500 v2q15 __builtin_mips_subq_ph (v2q15, v2q15);
19501 v2q15 __builtin_mips_subq_s_ph (v2q15, v2q15);
19502 q31 __builtin_mips_subq_s_w (q31, q31);
19503 v4i8 __builtin_mips_subu_qb (v4i8, v4i8);
19504 v4i8 __builtin_mips_subu_s_qb (v4i8, v4i8);
19505 i32 __builtin_mips_addsc (i32, i32);
19506 i32 __builtin_mips_addwc (i32, i32);
19507 i32 __builtin_mips_modsub (i32, i32);
19508 i32 __builtin_mips_raddu_w_qb (v4i8);
19509 v2q15 __builtin_mips_absq_s_ph (v2q15);
19510 q31 __builtin_mips_absq_s_w (q31);
19511 v4i8 __builtin_mips_precrq_qb_ph (v2q15, v2q15);
19512 v2q15 __builtin_mips_precrq_ph_w (q31, q31);
19513 v2q15 __builtin_mips_precrq_rs_ph_w (q31, q31);
19514 v4i8 __builtin_mips_precrqu_s_qb_ph (v2q15, v2q15);
19515 q31 __builtin_mips_preceq_w_phl (v2q15);
19516 q31 __builtin_mips_preceq_w_phr (v2q15);
19517 v2q15 __builtin_mips_precequ_ph_qbl (v4i8);
19518 v2q15 __builtin_mips_precequ_ph_qbr (v4i8);
19519 v2q15 __builtin_mips_precequ_ph_qbla (v4i8);
19520 v2q15 __builtin_mips_precequ_ph_qbra (v4i8);
19521 v2q15 __builtin_mips_preceu_ph_qbl (v4i8);
19522 v2q15 __builtin_mips_preceu_ph_qbr (v4i8);
19523 v2q15 __builtin_mips_preceu_ph_qbla (v4i8);
19524 v2q15 __builtin_mips_preceu_ph_qbra (v4i8);
19525 v4i8 __builtin_mips_shll_qb (v4i8, imm0_7);
19526 v4i8 __builtin_mips_shll_qb (v4i8, i32);
19527 v2q15 __builtin_mips_shll_ph (v2q15, imm0_15);
19528 v2q15 __builtin_mips_shll_ph (v2q15, i32);
19529 v2q15 __builtin_mips_shll_s_ph (v2q15, imm0_15);
19530 v2q15 __builtin_mips_shll_s_ph (v2q15, i32);
19531 q31 __builtin_mips_shll_s_w (q31, imm0_31);
19532 q31 __builtin_mips_shll_s_w (q31, i32);
19533 v4i8 __builtin_mips_shrl_qb (v4i8, imm0_7);
19534 v4i8 __builtin_mips_shrl_qb (v4i8, i32);
19535 v2q15 __builtin_mips_shra_ph (v2q15, imm0_15);
19536 v2q15 __builtin_mips_shra_ph (v2q15, i32);
19537 v2q15 __builtin_mips_shra_r_ph (v2q15, imm0_15);
19538 v2q15 __builtin_mips_shra_r_ph (v2q15, i32);
19539 q31 __builtin_mips_shra_r_w (q31, imm0_31);
19540 q31 __builtin_mips_shra_r_w (q31, i32);
19541 v2q15 __builtin_mips_muleu_s_ph_qbl (v4i8, v2q15);
19542 v2q15 __builtin_mips_muleu_s_ph_qbr (v4i8, v2q15);
19543 v2q15 __builtin_mips_mulq_rs_ph (v2q15, v2q15);
19544 q31 __builtin_mips_muleq_s_w_phl (v2q15, v2q15);
19545 q31 __builtin_mips_muleq_s_w_phr (v2q15, v2q15);
19546 a64 __builtin_mips_dpau_h_qbl (a64, v4i8, v4i8);
19547 a64 __builtin_mips_dpau_h_qbr (a64, v4i8, v4i8);
19548 a64 __builtin_mips_dpsu_h_qbl (a64, v4i8, v4i8);
19549 a64 __builtin_mips_dpsu_h_qbr (a64, v4i8, v4i8);
19550 a64 __builtin_mips_dpaq_s_w_ph (a64, v2q15, v2q15);
19551 a64 __builtin_mips_dpaq_sa_l_w (a64, q31, q31);
19552 a64 __builtin_mips_dpsq_s_w_ph (a64, v2q15, v2q15);
19553 a64 __builtin_mips_dpsq_sa_l_w (a64, q31, q31);
19554 a64 __builtin_mips_mulsaq_s_w_ph (a64, v2q15, v2q15);
19555 a64 __builtin_mips_maq_s_w_phl (a64, v2q15, v2q15);
19556 a64 __builtin_mips_maq_s_w_phr (a64, v2q15, v2q15);
19557 a64 __builtin_mips_maq_sa_w_phl (a64, v2q15, v2q15);
19558 a64 __builtin_mips_maq_sa_w_phr (a64, v2q15, v2q15);
19559 i32 __builtin_mips_bitrev (i32);
19560 i32 __builtin_mips_insv (i32, i32);
19561 v4i8 __builtin_mips_repl_qb (imm0_255);
19562 v4i8 __builtin_mips_repl_qb (i32);
19563 v2q15 __builtin_mips_repl_ph (imm_n512_511);
19564 v2q15 __builtin_mips_repl_ph (i32);
19565 void __builtin_mips_cmpu_eq_qb (v4i8, v4i8);
19566 void __builtin_mips_cmpu_lt_qb (v4i8, v4i8);
19567 void __builtin_mips_cmpu_le_qb (v4i8, v4i8);
19568 i32 __builtin_mips_cmpgu_eq_qb (v4i8, v4i8);
19569 i32 __builtin_mips_cmpgu_lt_qb (v4i8, v4i8);
19570 i32 __builtin_mips_cmpgu_le_qb (v4i8, v4i8);
19571 void __builtin_mips_cmp_eq_ph (v2q15, v2q15);
19572 void __builtin_mips_cmp_lt_ph (v2q15, v2q15);
19573 void __builtin_mips_cmp_le_ph (v2q15, v2q15);
19574 v4i8 __builtin_mips_pick_qb (v4i8, v4i8);
19575 v2q15 __builtin_mips_pick_ph (v2q15, v2q15);
19576 v2q15 __builtin_mips_packrl_ph (v2q15, v2q15);
19577 i32 __builtin_mips_extr_w (a64, imm0_31);
19578 i32 __builtin_mips_extr_w (a64, i32);
19579 i32 __builtin_mips_extr_r_w (a64, imm0_31);
19580 i32 __builtin_mips_extr_s_h (a64, i32);
19581 i32 __builtin_mips_extr_rs_w (a64, imm0_31);
19582 i32 __builtin_mips_extr_rs_w (a64, i32);
19583 i32 __builtin_mips_extr_s_h (a64, imm0_31);
19584 i32 __builtin_mips_extr_r_w (a64, i32);
19585 i32 __builtin_mips_extp (a64, imm0_31);
19586 i32 __builtin_mips_extp (a64, i32);
19587 i32 __builtin_mips_extpdp (a64, imm0_31);
19588 i32 __builtin_mips_extpdp (a64, i32);
19589 a64 __builtin_mips_shilo (a64, imm_n32_31);
19590 a64 __builtin_mips_shilo (a64, i32);
19591 a64 __builtin_mips_mthlip (a64, i32);
19592 void __builtin_mips_wrdsp (i32, imm0_63);
19593 i32 __builtin_mips_rddsp (imm0_63);
19594 i32 __builtin_mips_lbux (void *, i32);
19595 i32 __builtin_mips_lhx (void *, i32);
19596 i32 __builtin_mips_lwx (void *, i32);
19597 a64 __builtin_mips_ldx (void *, i32); /* MIPS64 only */
19598 i32 __builtin_mips_bposge32 (void);
19599 a64 __builtin_mips_madd (a64, i32, i32);
19600 a64 __builtin_mips_maddu (a64, ui32, ui32);
19601 a64 __builtin_mips_msub (a64, i32, i32);
19602 a64 __builtin_mips_msubu (a64, ui32, ui32);
19603 a64 __builtin_mips_mult (i32, i32);
19604 a64 __builtin_mips_multu (ui32, ui32);
19605 @end smallexample
19607 The following built-in functions map directly to a particular MIPS DSP REV 2
19608 instruction.  Please refer to the architecture specification
19609 for details on what each instruction does.
19611 @smallexample
19612 v4q7 __builtin_mips_absq_s_qb (v4q7);
19613 v2i16 __builtin_mips_addu_ph (v2i16, v2i16);
19614 v2i16 __builtin_mips_addu_s_ph (v2i16, v2i16);
19615 v4i8 __builtin_mips_adduh_qb (v4i8, v4i8);
19616 v4i8 __builtin_mips_adduh_r_qb (v4i8, v4i8);
19617 i32 __builtin_mips_append (i32, i32, imm0_31);
19618 i32 __builtin_mips_balign (i32, i32, imm0_3);
19619 i32 __builtin_mips_cmpgdu_eq_qb (v4i8, v4i8);
19620 i32 __builtin_mips_cmpgdu_lt_qb (v4i8, v4i8);
19621 i32 __builtin_mips_cmpgdu_le_qb (v4i8, v4i8);
19622 a64 __builtin_mips_dpa_w_ph (a64, v2i16, v2i16);
19623 a64 __builtin_mips_dps_w_ph (a64, v2i16, v2i16);
19624 v2i16 __builtin_mips_mul_ph (v2i16, v2i16);
19625 v2i16 __builtin_mips_mul_s_ph (v2i16, v2i16);
19626 q31 __builtin_mips_mulq_rs_w (q31, q31);
19627 v2q15 __builtin_mips_mulq_s_ph (v2q15, v2q15);
19628 q31 __builtin_mips_mulq_s_w (q31, q31);
19629 a64 __builtin_mips_mulsa_w_ph (a64, v2i16, v2i16);
19630 v4i8 __builtin_mips_precr_qb_ph (v2i16, v2i16);
19631 v2i16 __builtin_mips_precr_sra_ph_w (i32, i32, imm0_31);
19632 v2i16 __builtin_mips_precr_sra_r_ph_w (i32, i32, imm0_31);
19633 i32 __builtin_mips_prepend (i32, i32, imm0_31);
19634 v4i8 __builtin_mips_shra_qb (v4i8, imm0_7);
19635 v4i8 __builtin_mips_shra_r_qb (v4i8, imm0_7);
19636 v4i8 __builtin_mips_shra_qb (v4i8, i32);
19637 v4i8 __builtin_mips_shra_r_qb (v4i8, i32);
19638 v2i16 __builtin_mips_shrl_ph (v2i16, imm0_15);
19639 v2i16 __builtin_mips_shrl_ph (v2i16, i32);
19640 v2i16 __builtin_mips_subu_ph (v2i16, v2i16);
19641 v2i16 __builtin_mips_subu_s_ph (v2i16, v2i16);
19642 v4i8 __builtin_mips_subuh_qb (v4i8, v4i8);
19643 v4i8 __builtin_mips_subuh_r_qb (v4i8, v4i8);
19644 v2q15 __builtin_mips_addqh_ph (v2q15, v2q15);
19645 v2q15 __builtin_mips_addqh_r_ph (v2q15, v2q15);
19646 q31 __builtin_mips_addqh_w (q31, q31);
19647 q31 __builtin_mips_addqh_r_w (q31, q31);
19648 v2q15 __builtin_mips_subqh_ph (v2q15, v2q15);
19649 v2q15 __builtin_mips_subqh_r_ph (v2q15, v2q15);
19650 q31 __builtin_mips_subqh_w (q31, q31);
19651 q31 __builtin_mips_subqh_r_w (q31, q31);
19652 a64 __builtin_mips_dpax_w_ph (a64, v2i16, v2i16);
19653 a64 __builtin_mips_dpsx_w_ph (a64, v2i16, v2i16);
19654 a64 __builtin_mips_dpaqx_s_w_ph (a64, v2q15, v2q15);
19655 a64 __builtin_mips_dpaqx_sa_w_ph (a64, v2q15, v2q15);
19656 a64 __builtin_mips_dpsqx_s_w_ph (a64, v2q15, v2q15);
19657 a64 __builtin_mips_dpsqx_sa_w_ph (a64, v2q15, v2q15);
19658 @end smallexample
19661 @node MIPS Paired-Single Support
19662 @subsection MIPS Paired-Single Support
19664 The MIPS64 architecture includes a number of instructions that
19665 operate on pairs of single-precision floating-point values.
19666 Each pair is packed into a 64-bit floating-point register,
19667 with one element being designated the ``upper half'' and
19668 the other being designated the ``lower half''.
19670 GCC supports paired-single operations using both the generic
19671 vector extensions (@pxref{Vector Extensions}) and a collection of
19672 MIPS-specific built-in functions.  Both kinds of support are
19673 enabled by the @option{-mpaired-single} command-line option.
19675 The vector type associated with paired-single values is usually
19676 called @code{v2sf}.  It can be defined in C as follows:
19678 @smallexample
19679 typedef float v2sf __attribute__ ((vector_size (8)));
19680 @end smallexample
19682 @code{v2sf} values are initialized in the same way as aggregates.
19683 For example:
19685 @smallexample
19686 v2sf a = @{1.5, 9.1@};
19687 v2sf b;
19688 float e, f;
19689 b = (v2sf) @{e, f@};
19690 @end smallexample
19692 @emph{Note:} The CPU's endianness determines which value is stored in
19693 the upper half of a register and which value is stored in the lower half.
19694 On little-endian targets, the first value is the lower one and the second
19695 value is the upper one.  The opposite order applies to big-endian targets.
19696 For example, the code above sets the lower half of @code{a} to
19697 @code{1.5} on little-endian targets and @code{9.1} on big-endian targets.
19699 @node MIPS Loongson Built-in Functions
19700 @subsection MIPS Loongson Built-in Functions
19702 GCC provides intrinsics to access the SIMD instructions provided by the
19703 ST Microelectronics Loongson-2E and -2F processors.  These intrinsics,
19704 available after inclusion of the @code{loongson.h} header file,
19705 operate on the following 64-bit vector types:
19707 @itemize
19708 @item @code{uint8x8_t}, a vector of eight unsigned 8-bit integers;
19709 @item @code{uint16x4_t}, a vector of four unsigned 16-bit integers;
19710 @item @code{uint32x2_t}, a vector of two unsigned 32-bit integers;
19711 @item @code{int8x8_t}, a vector of eight signed 8-bit integers;
19712 @item @code{int16x4_t}, a vector of four signed 16-bit integers;
19713 @item @code{int32x2_t}, a vector of two signed 32-bit integers.
19714 @end itemize
19716 The intrinsics provided are listed below; each is named after the
19717 machine instruction to which it corresponds, with suffixes added as
19718 appropriate to distinguish intrinsics that expand to the same machine
19719 instruction yet have different argument types.  Refer to the architecture
19720 documentation for a description of the functionality of each
19721 instruction.
19723 @smallexample
19724 int16x4_t packsswh (int32x2_t s, int32x2_t t);
19725 int8x8_t packsshb (int16x4_t s, int16x4_t t);
19726 uint8x8_t packushb (uint16x4_t s, uint16x4_t t);
19727 uint32x2_t paddw_u (uint32x2_t s, uint32x2_t t);
19728 uint16x4_t paddh_u (uint16x4_t s, uint16x4_t t);
19729 uint8x8_t paddb_u (uint8x8_t s, uint8x8_t t);
19730 int32x2_t paddw_s (int32x2_t s, int32x2_t t);
19731 int16x4_t paddh_s (int16x4_t s, int16x4_t t);
19732 int8x8_t paddb_s (int8x8_t s, int8x8_t t);
19733 uint64_t paddd_u (uint64_t s, uint64_t t);
19734 int64_t paddd_s (int64_t s, int64_t t);
19735 int16x4_t paddsh (int16x4_t s, int16x4_t t);
19736 int8x8_t paddsb (int8x8_t s, int8x8_t t);
19737 uint16x4_t paddush (uint16x4_t s, uint16x4_t t);
19738 uint8x8_t paddusb (uint8x8_t s, uint8x8_t t);
19739 uint64_t pandn_ud (uint64_t s, uint64_t t);
19740 uint32x2_t pandn_uw (uint32x2_t s, uint32x2_t t);
19741 uint16x4_t pandn_uh (uint16x4_t s, uint16x4_t t);
19742 uint8x8_t pandn_ub (uint8x8_t s, uint8x8_t t);
19743 int64_t pandn_sd (int64_t s, int64_t t);
19744 int32x2_t pandn_sw (int32x2_t s, int32x2_t t);
19745 int16x4_t pandn_sh (int16x4_t s, int16x4_t t);
19746 int8x8_t pandn_sb (int8x8_t s, int8x8_t t);
19747 uint16x4_t pavgh (uint16x4_t s, uint16x4_t t);
19748 uint8x8_t pavgb (uint8x8_t s, uint8x8_t t);
19749 uint32x2_t pcmpeqw_u (uint32x2_t s, uint32x2_t t);
19750 uint16x4_t pcmpeqh_u (uint16x4_t s, uint16x4_t t);
19751 uint8x8_t pcmpeqb_u (uint8x8_t s, uint8x8_t t);
19752 int32x2_t pcmpeqw_s (int32x2_t s, int32x2_t t);
19753 int16x4_t pcmpeqh_s (int16x4_t s, int16x4_t t);
19754 int8x8_t pcmpeqb_s (int8x8_t s, int8x8_t t);
19755 uint32x2_t pcmpgtw_u (uint32x2_t s, uint32x2_t t);
19756 uint16x4_t pcmpgth_u (uint16x4_t s, uint16x4_t t);
19757 uint8x8_t pcmpgtb_u (uint8x8_t s, uint8x8_t t);
19758 int32x2_t pcmpgtw_s (int32x2_t s, int32x2_t t);
19759 int16x4_t pcmpgth_s (int16x4_t s, int16x4_t t);
19760 int8x8_t pcmpgtb_s (int8x8_t s, int8x8_t t);
19761 uint16x4_t pextrh_u (uint16x4_t s, int field);
19762 int16x4_t pextrh_s (int16x4_t s, int field);
19763 uint16x4_t pinsrh_0_u (uint16x4_t s, uint16x4_t t);
19764 uint16x4_t pinsrh_1_u (uint16x4_t s, uint16x4_t t);
19765 uint16x4_t pinsrh_2_u (uint16x4_t s, uint16x4_t t);
19766 uint16x4_t pinsrh_3_u (uint16x4_t s, uint16x4_t t);
19767 int16x4_t pinsrh_0_s (int16x4_t s, int16x4_t t);
19768 int16x4_t pinsrh_1_s (int16x4_t s, int16x4_t t);
19769 int16x4_t pinsrh_2_s (int16x4_t s, int16x4_t t);
19770 int16x4_t pinsrh_3_s (int16x4_t s, int16x4_t t);
19771 int32x2_t pmaddhw (int16x4_t s, int16x4_t t);
19772 int16x4_t pmaxsh (int16x4_t s, int16x4_t t);
19773 uint8x8_t pmaxub (uint8x8_t s, uint8x8_t t);
19774 int16x4_t pminsh (int16x4_t s, int16x4_t t);
19775 uint8x8_t pminub (uint8x8_t s, uint8x8_t t);
19776 uint8x8_t pmovmskb_u (uint8x8_t s);
19777 int8x8_t pmovmskb_s (int8x8_t s);
19778 uint16x4_t pmulhuh (uint16x4_t s, uint16x4_t t);
19779 int16x4_t pmulhh (int16x4_t s, int16x4_t t);
19780 int16x4_t pmullh (int16x4_t s, int16x4_t t);
19781 int64_t pmuluw (uint32x2_t s, uint32x2_t t);
19782 uint8x8_t pasubub (uint8x8_t s, uint8x8_t t);
19783 uint16x4_t biadd (uint8x8_t s);
19784 uint16x4_t psadbh (uint8x8_t s, uint8x8_t t);
19785 uint16x4_t pshufh_u (uint16x4_t dest, uint16x4_t s, uint8_t order);
19786 int16x4_t pshufh_s (int16x4_t dest, int16x4_t s, uint8_t order);
19787 uint16x4_t psllh_u (uint16x4_t s, uint8_t amount);
19788 int16x4_t psllh_s (int16x4_t s, uint8_t amount);
19789 uint32x2_t psllw_u (uint32x2_t s, uint8_t amount);
19790 int32x2_t psllw_s (int32x2_t s, uint8_t amount);
19791 uint16x4_t psrlh_u (uint16x4_t s, uint8_t amount);
19792 int16x4_t psrlh_s (int16x4_t s, uint8_t amount);
19793 uint32x2_t psrlw_u (uint32x2_t s, uint8_t amount);
19794 int32x2_t psrlw_s (int32x2_t s, uint8_t amount);
19795 uint16x4_t psrah_u (uint16x4_t s, uint8_t amount);
19796 int16x4_t psrah_s (int16x4_t s, uint8_t amount);
19797 uint32x2_t psraw_u (uint32x2_t s, uint8_t amount);
19798 int32x2_t psraw_s (int32x2_t s, uint8_t amount);
19799 uint32x2_t psubw_u (uint32x2_t s, uint32x2_t t);
19800 uint16x4_t psubh_u (uint16x4_t s, uint16x4_t t);
19801 uint8x8_t psubb_u (uint8x8_t s, uint8x8_t t);
19802 int32x2_t psubw_s (int32x2_t s, int32x2_t t);
19803 int16x4_t psubh_s (int16x4_t s, int16x4_t t);
19804 int8x8_t psubb_s (int8x8_t s, int8x8_t t);
19805 uint64_t psubd_u (uint64_t s, uint64_t t);
19806 int64_t psubd_s (int64_t s, int64_t t);
19807 int16x4_t psubsh (int16x4_t s, int16x4_t t);
19808 int8x8_t psubsb (int8x8_t s, int8x8_t t);
19809 uint16x4_t psubush (uint16x4_t s, uint16x4_t t);
19810 uint8x8_t psubusb (uint8x8_t s, uint8x8_t t);
19811 uint32x2_t punpckhwd_u (uint32x2_t s, uint32x2_t t);
19812 uint16x4_t punpckhhw_u (uint16x4_t s, uint16x4_t t);
19813 uint8x8_t punpckhbh_u (uint8x8_t s, uint8x8_t t);
19814 int32x2_t punpckhwd_s (int32x2_t s, int32x2_t t);
19815 int16x4_t punpckhhw_s (int16x4_t s, int16x4_t t);
19816 int8x8_t punpckhbh_s (int8x8_t s, int8x8_t t);
19817 uint32x2_t punpcklwd_u (uint32x2_t s, uint32x2_t t);
19818 uint16x4_t punpcklhw_u (uint16x4_t s, uint16x4_t t);
19819 uint8x8_t punpcklbh_u (uint8x8_t s, uint8x8_t t);
19820 int32x2_t punpcklwd_s (int32x2_t s, int32x2_t t);
19821 int16x4_t punpcklhw_s (int16x4_t s, int16x4_t t);
19822 int8x8_t punpcklbh_s (int8x8_t s, int8x8_t t);
19823 @end smallexample
19825 @menu
19826 * Paired-Single Arithmetic::
19827 * Paired-Single Built-in Functions::
19828 * MIPS-3D Built-in Functions::
19829 @end menu
19831 @node Paired-Single Arithmetic
19832 @subsubsection Paired-Single Arithmetic
19834 The table below lists the @code{v2sf} operations for which hardware
19835 support exists.  @code{a}, @code{b} and @code{c} are @code{v2sf}
19836 values and @code{x} is an integral value.
19838 @multitable @columnfractions .50 .50
19839 @headitem C code @tab MIPS instruction
19840 @item @code{a + b} @tab @code{add.ps}
19841 @item @code{a - b} @tab @code{sub.ps}
19842 @item @code{-a} @tab @code{neg.ps}
19843 @item @code{a * b} @tab @code{mul.ps}
19844 @item @code{a * b + c} @tab @code{madd.ps}
19845 @item @code{a * b - c} @tab @code{msub.ps}
19846 @item @code{-(a * b + c)} @tab @code{nmadd.ps}
19847 @item @code{-(a * b - c)} @tab @code{nmsub.ps}
19848 @item @code{x ? a : b} @tab @code{movn.ps}/@code{movz.ps}
19849 @end multitable
19851 Note that the multiply-accumulate instructions can be disabled
19852 using the command-line option @code{-mno-fused-madd}.
19854 @node Paired-Single Built-in Functions
19855 @subsubsection Paired-Single Built-in Functions
19857 The following paired-single functions map directly to a particular
19858 MIPS instruction.  Please refer to the architecture specification
19859 for details on what each instruction does.
19861 @table @code
19862 @item v2sf __builtin_mips_pll_ps (v2sf, v2sf)
19863 Pair lower lower (@code{pll.ps}).
19865 @item v2sf __builtin_mips_pul_ps (v2sf, v2sf)
19866 Pair upper lower (@code{pul.ps}).
19868 @item v2sf __builtin_mips_plu_ps (v2sf, v2sf)
19869 Pair lower upper (@code{plu.ps}).
19871 @item v2sf __builtin_mips_puu_ps (v2sf, v2sf)
19872 Pair upper upper (@code{puu.ps}).
19874 @item v2sf __builtin_mips_cvt_ps_s (float, float)
19875 Convert pair to paired single (@code{cvt.ps.s}).
19877 @item float __builtin_mips_cvt_s_pl (v2sf)
19878 Convert pair lower to single (@code{cvt.s.pl}).
19880 @item float __builtin_mips_cvt_s_pu (v2sf)
19881 Convert pair upper to single (@code{cvt.s.pu}).
19883 @item v2sf __builtin_mips_abs_ps (v2sf)
19884 Absolute value (@code{abs.ps}).
19886 @item v2sf __builtin_mips_alnv_ps (v2sf, v2sf, int)
19887 Align variable (@code{alnv.ps}).
19889 @emph{Note:} The value of the third parameter must be 0 or 4
19890 modulo 8, otherwise the result is unpredictable.  Please read the
19891 instruction description for details.
19892 @end table
19894 The following multi-instruction functions are also available.
19895 In each case, @var{cond} can be any of the 16 floating-point conditions:
19896 @code{f}, @code{un}, @code{eq}, @code{ueq}, @code{olt}, @code{ult},
19897 @code{ole}, @code{ule}, @code{sf}, @code{ngle}, @code{seq}, @code{ngl},
19898 @code{lt}, @code{nge}, @code{le} or @code{ngt}.
19900 @table @code
19901 @item v2sf __builtin_mips_movt_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
19902 @itemx v2sf __builtin_mips_movf_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
19903 Conditional move based on floating-point comparison (@code{c.@var{cond}.ps},
19904 @code{movt.ps}/@code{movf.ps}).
19906 The @code{movt} functions return the value @var{x} computed by:
19908 @smallexample
19909 c.@var{cond}.ps @var{cc},@var{a},@var{b}
19910 mov.ps @var{x},@var{c}
19911 movt.ps @var{x},@var{d},@var{cc}
19912 @end smallexample
19914 The @code{movf} functions are similar but use @code{movf.ps} instead
19915 of @code{movt.ps}.
19917 @item int __builtin_mips_upper_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
19918 @itemx int __builtin_mips_lower_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
19919 Comparison of two paired-single values (@code{c.@var{cond}.ps},
19920 @code{bc1t}/@code{bc1f}).
19922 These functions compare @var{a} and @var{b} using @code{c.@var{cond}.ps}
19923 and return either the upper or lower half of the result.  For example:
19925 @smallexample
19926 v2sf a, b;
19927 if (__builtin_mips_upper_c_eq_ps (a, b))
19928   upper_halves_are_equal ();
19929 else
19930   upper_halves_are_unequal ();
19932 if (__builtin_mips_lower_c_eq_ps (a, b))
19933   lower_halves_are_equal ();
19934 else
19935   lower_halves_are_unequal ();
19936 @end smallexample
19937 @end table
19939 @node MIPS-3D Built-in Functions
19940 @subsubsection MIPS-3D Built-in Functions
19942 The MIPS-3D Application-Specific Extension (ASE) includes additional
19943 paired-single instructions that are designed to improve the performance
19944 of 3D graphics operations.  Support for these instructions is controlled
19945 by the @option{-mips3d} command-line option.
19947 The functions listed below map directly to a particular MIPS-3D
19948 instruction.  Please refer to the architecture specification for
19949 more details on what each instruction does.
19951 @table @code
19952 @item v2sf __builtin_mips_addr_ps (v2sf, v2sf)
19953 Reduction add (@code{addr.ps}).
19955 @item v2sf __builtin_mips_mulr_ps (v2sf, v2sf)
19956 Reduction multiply (@code{mulr.ps}).
19958 @item v2sf __builtin_mips_cvt_pw_ps (v2sf)
19959 Convert paired single to paired word (@code{cvt.pw.ps}).
19961 @item v2sf __builtin_mips_cvt_ps_pw (v2sf)
19962 Convert paired word to paired single (@code{cvt.ps.pw}).
19964 @item float __builtin_mips_recip1_s (float)
19965 @itemx double __builtin_mips_recip1_d (double)
19966 @itemx v2sf __builtin_mips_recip1_ps (v2sf)
19967 Reduced-precision reciprocal (sequence step 1) (@code{recip1.@var{fmt}}).
19969 @item float __builtin_mips_recip2_s (float, float)
19970 @itemx double __builtin_mips_recip2_d (double, double)
19971 @itemx v2sf __builtin_mips_recip2_ps (v2sf, v2sf)
19972 Reduced-precision reciprocal (sequence step 2) (@code{recip2.@var{fmt}}).
19974 @item float __builtin_mips_rsqrt1_s (float)
19975 @itemx double __builtin_mips_rsqrt1_d (double)
19976 @itemx v2sf __builtin_mips_rsqrt1_ps (v2sf)
19977 Reduced-precision reciprocal square root (sequence step 1)
19978 (@code{rsqrt1.@var{fmt}}).
19980 @item float __builtin_mips_rsqrt2_s (float, float)
19981 @itemx double __builtin_mips_rsqrt2_d (double, double)
19982 @itemx v2sf __builtin_mips_rsqrt2_ps (v2sf, v2sf)
19983 Reduced-precision reciprocal square root (sequence step 2)
19984 (@code{rsqrt2.@var{fmt}}).
19985 @end table
19987 The following multi-instruction functions are also available.
19988 In each case, @var{cond} can be any of the 16 floating-point conditions:
19989 @code{f}, @code{un}, @code{eq}, @code{ueq}, @code{olt}, @code{ult},
19990 @code{ole}, @code{ule}, @code{sf}, @code{ngle}, @code{seq},
19991 @code{ngl}, @code{lt}, @code{nge}, @code{le} or @code{ngt}.
19993 @table @code
19994 @item int __builtin_mips_cabs_@var{cond}_s (float @var{a}, float @var{b})
19995 @itemx int __builtin_mips_cabs_@var{cond}_d (double @var{a}, double @var{b})
19996 Absolute comparison of two scalar values (@code{cabs.@var{cond}.@var{fmt}},
19997 @code{bc1t}/@code{bc1f}).
19999 These functions compare @var{a} and @var{b} using @code{cabs.@var{cond}.s}
20000 or @code{cabs.@var{cond}.d} and return the result as a boolean value.
20001 For example:
20003 @smallexample
20004 float a, b;
20005 if (__builtin_mips_cabs_eq_s (a, b))
20006   true ();
20007 else
20008   false ();
20009 @end smallexample
20011 @item int __builtin_mips_upper_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
20012 @itemx int __builtin_mips_lower_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
20013 Absolute comparison of two paired-single values (@code{cabs.@var{cond}.ps},
20014 @code{bc1t}/@code{bc1f}).
20016 These functions compare @var{a} and @var{b} using @code{cabs.@var{cond}.ps}
20017 and return either the upper or lower half of the result.  For example:
20019 @smallexample
20020 v2sf a, b;
20021 if (__builtin_mips_upper_cabs_eq_ps (a, b))
20022   upper_halves_are_equal ();
20023 else
20024   upper_halves_are_unequal ();
20026 if (__builtin_mips_lower_cabs_eq_ps (a, b))
20027   lower_halves_are_equal ();
20028 else
20029   lower_halves_are_unequal ();
20030 @end smallexample
20032 @item v2sf __builtin_mips_movt_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
20033 @itemx v2sf __builtin_mips_movf_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
20034 Conditional move based on absolute comparison (@code{cabs.@var{cond}.ps},
20035 @code{movt.ps}/@code{movf.ps}).
20037 The @code{movt} functions return the value @var{x} computed by:
20039 @smallexample
20040 cabs.@var{cond}.ps @var{cc},@var{a},@var{b}
20041 mov.ps @var{x},@var{c}
20042 movt.ps @var{x},@var{d},@var{cc}
20043 @end smallexample
20045 The @code{movf} functions are similar but use @code{movf.ps} instead
20046 of @code{movt.ps}.
20048 @item int __builtin_mips_any_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
20049 @itemx int __builtin_mips_all_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
20050 @itemx int __builtin_mips_any_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
20051 @itemx int __builtin_mips_all_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
20052 Comparison of two paired-single values
20053 (@code{c.@var{cond}.ps}/@code{cabs.@var{cond}.ps},
20054 @code{bc1any2t}/@code{bc1any2f}).
20056 These functions compare @var{a} and @var{b} using @code{c.@var{cond}.ps}
20057 or @code{cabs.@var{cond}.ps}.  The @code{any} forms return @code{true} if either
20058 result is @code{true} and the @code{all} forms return @code{true} if both results are @code{true}.
20059 For example:
20061 @smallexample
20062 v2sf a, b;
20063 if (__builtin_mips_any_c_eq_ps (a, b))
20064   one_is_true ();
20065 else
20066   both_are_false ();
20068 if (__builtin_mips_all_c_eq_ps (a, b))
20069   both_are_true ();
20070 else
20071   one_is_false ();
20072 @end smallexample
20074 @item int __builtin_mips_any_c_@var{cond}_4s (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
20075 @itemx int __builtin_mips_all_c_@var{cond}_4s (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
20076 @itemx int __builtin_mips_any_cabs_@var{cond}_4s (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
20077 @itemx int __builtin_mips_all_cabs_@var{cond}_4s (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
20078 Comparison of four paired-single values
20079 (@code{c.@var{cond}.ps}/@code{cabs.@var{cond}.ps},
20080 @code{bc1any4t}/@code{bc1any4f}).
20082 These functions use @code{c.@var{cond}.ps} or @code{cabs.@var{cond}.ps}
20083 to compare @var{a} with @var{b} and to compare @var{c} with @var{d}.
20084 The @code{any} forms return @code{true} if any of the four results are @code{true}
20085 and the @code{all} forms return @code{true} if all four results are @code{true}.
20086 For example:
20088 @smallexample
20089 v2sf a, b, c, d;
20090 if (__builtin_mips_any_c_eq_4s (a, b, c, d))
20091   some_are_true ();
20092 else
20093   all_are_false ();
20095 if (__builtin_mips_all_c_eq_4s (a, b, c, d))
20096   all_are_true ();
20097 else
20098   some_are_false ();
20099 @end smallexample
20100 @end table
20102 @node MIPS SIMD Architecture (MSA) Support
20103 @subsection MIPS SIMD Architecture (MSA) Support
20105 @menu
20106 * MIPS SIMD Architecture Built-in Functions::
20107 @end menu
20109 GCC provides intrinsics to access the SIMD instructions provided by the
20110 MSA MIPS SIMD Architecture.  The interface is made available by including
20111 @code{<msa.h>} and using @option{-mmsa -mhard-float -mfp64 -mnan=2008}.
20112 For each @code{__builtin_msa_*}, there is a shortened name of the intrinsic,
20113 @code{__msa_*}.
20115 MSA implements 128-bit wide vector registers, operating on 8-, 16-, 32- and
20116 64-bit integer, 16- and 32-bit fixed-point, or 32- and 64-bit floating point
20117 data elements.  The following vectors typedefs are included in @code{msa.h}:
20118 @itemize
20119 @item @code{v16i8}, a vector of sixteen signed 8-bit integers;
20120 @item @code{v16u8}, a vector of sixteen unsigned 8-bit integers;
20121 @item @code{v8i16}, a vector of eight signed 16-bit integers;
20122 @item @code{v8u16}, a vector of eight unsigned 16-bit integers;
20123 @item @code{v4i32}, a vector of four signed 32-bit integers;
20124 @item @code{v4u32}, a vector of four unsigned 32-bit integers;
20125 @item @code{v2i64}, a vector of two signed 64-bit integers;
20126 @item @code{v2u64}, a vector of two unsigned 64-bit integers;
20127 @item @code{v4f32}, a vector of four 32-bit floats;
20128 @item @code{v2f64}, a vector of two 64-bit doubles.
20129 @end itemize
20131 Instructions and corresponding built-ins may have additional restrictions and/or
20132 input/output values manipulated:
20133 @itemize
20134 @item @code{imm0_1}, an integer literal in range 0 to 1;
20135 @item @code{imm0_3}, an integer literal in range 0 to 3;
20136 @item @code{imm0_7}, an integer literal in range 0 to 7;
20137 @item @code{imm0_15}, an integer literal in range 0 to 15;
20138 @item @code{imm0_31}, an integer literal in range 0 to 31;
20139 @item @code{imm0_63}, an integer literal in range 0 to 63;
20140 @item @code{imm0_255}, an integer literal in range 0 to 255;
20141 @item @code{imm_n16_15}, an integer literal in range -16 to 15;
20142 @item @code{imm_n512_511}, an integer literal in range -512 to 511;
20143 @item @code{imm_n1024_1022}, an integer literal in range -512 to 511 left
20144 shifted by 1 bit, i.e., -1024, -1022, @dots{}, 1020, 1022;
20145 @item @code{imm_n2048_2044}, an integer literal in range -512 to 511 left
20146 shifted by 2 bits, i.e., -2048, -2044, @dots{}, 2040, 2044;
20147 @item @code{imm_n4096_4088}, an integer literal in range -512 to 511 left
20148 shifted by 3 bits, i.e., -4096, -4088, @dots{}, 4080, 4088;
20149 @item @code{imm1_4}, an integer literal in range 1 to 4;
20150 @item @code{i32, i64, u32, u64, f32, f64}, defined as follows:
20151 @end itemize
20153 @smallexample
20155 typedef int i32;
20156 #if __LONG_MAX__ == __LONG_LONG_MAX__
20157 typedef long i64;
20158 #else
20159 typedef long long i64;
20160 #endif
20162 typedef unsigned int u32;
20163 #if __LONG_MAX__ == __LONG_LONG_MAX__
20164 typedef unsigned long u64;
20165 #else
20166 typedef unsigned long long u64;
20167 #endif
20169 typedef double f64;
20170 typedef float f32;
20172 @end smallexample
20174 @node MIPS SIMD Architecture Built-in Functions
20175 @subsubsection MIPS SIMD Architecture Built-in Functions
20177 The intrinsics provided are listed below; each is named after the
20178 machine instruction.
20180 @smallexample
20181 v16i8 __builtin_msa_add_a_b (v16i8, v16i8);
20182 v8i16 __builtin_msa_add_a_h (v8i16, v8i16);
20183 v4i32 __builtin_msa_add_a_w (v4i32, v4i32);
20184 v2i64 __builtin_msa_add_a_d (v2i64, v2i64);
20186 v16i8 __builtin_msa_adds_a_b (v16i8, v16i8);
20187 v8i16 __builtin_msa_adds_a_h (v8i16, v8i16);
20188 v4i32 __builtin_msa_adds_a_w (v4i32, v4i32);
20189 v2i64 __builtin_msa_adds_a_d (v2i64, v2i64);
20191 v16i8 __builtin_msa_adds_s_b (v16i8, v16i8);
20192 v8i16 __builtin_msa_adds_s_h (v8i16, v8i16);
20193 v4i32 __builtin_msa_adds_s_w (v4i32, v4i32);
20194 v2i64 __builtin_msa_adds_s_d (v2i64, v2i64);
20196 v16u8 __builtin_msa_adds_u_b (v16u8, v16u8);
20197 v8u16 __builtin_msa_adds_u_h (v8u16, v8u16);
20198 v4u32 __builtin_msa_adds_u_w (v4u32, v4u32);
20199 v2u64 __builtin_msa_adds_u_d (v2u64, v2u64);
20201 v16i8 __builtin_msa_addv_b (v16i8, v16i8);
20202 v8i16 __builtin_msa_addv_h (v8i16, v8i16);
20203 v4i32 __builtin_msa_addv_w (v4i32, v4i32);
20204 v2i64 __builtin_msa_addv_d (v2i64, v2i64);
20206 v16i8 __builtin_msa_addvi_b (v16i8, imm0_31);
20207 v8i16 __builtin_msa_addvi_h (v8i16, imm0_31);
20208 v4i32 __builtin_msa_addvi_w (v4i32, imm0_31);
20209 v2i64 __builtin_msa_addvi_d (v2i64, imm0_31);
20211 v16u8 __builtin_msa_and_v (v16u8, v16u8);
20213 v16u8 __builtin_msa_andi_b (v16u8, imm0_255);
20215 v16i8 __builtin_msa_asub_s_b (v16i8, v16i8);
20216 v8i16 __builtin_msa_asub_s_h (v8i16, v8i16);
20217 v4i32 __builtin_msa_asub_s_w (v4i32, v4i32);
20218 v2i64 __builtin_msa_asub_s_d (v2i64, v2i64);
20220 v16u8 __builtin_msa_asub_u_b (v16u8, v16u8);
20221 v8u16 __builtin_msa_asub_u_h (v8u16, v8u16);
20222 v4u32 __builtin_msa_asub_u_w (v4u32, v4u32);
20223 v2u64 __builtin_msa_asub_u_d (v2u64, v2u64);
20225 v16i8 __builtin_msa_ave_s_b (v16i8, v16i8);
20226 v8i16 __builtin_msa_ave_s_h (v8i16, v8i16);
20227 v4i32 __builtin_msa_ave_s_w (v4i32, v4i32);
20228 v2i64 __builtin_msa_ave_s_d (v2i64, v2i64);
20230 v16u8 __builtin_msa_ave_u_b (v16u8, v16u8);
20231 v8u16 __builtin_msa_ave_u_h (v8u16, v8u16);
20232 v4u32 __builtin_msa_ave_u_w (v4u32, v4u32);
20233 v2u64 __builtin_msa_ave_u_d (v2u64, v2u64);
20235 v16i8 __builtin_msa_aver_s_b (v16i8, v16i8);
20236 v8i16 __builtin_msa_aver_s_h (v8i16, v8i16);
20237 v4i32 __builtin_msa_aver_s_w (v4i32, v4i32);
20238 v2i64 __builtin_msa_aver_s_d (v2i64, v2i64);
20240 v16u8 __builtin_msa_aver_u_b (v16u8, v16u8);
20241 v8u16 __builtin_msa_aver_u_h (v8u16, v8u16);
20242 v4u32 __builtin_msa_aver_u_w (v4u32, v4u32);
20243 v2u64 __builtin_msa_aver_u_d (v2u64, v2u64);
20245 v16u8 __builtin_msa_bclr_b (v16u8, v16u8);
20246 v8u16 __builtin_msa_bclr_h (v8u16, v8u16);
20247 v4u32 __builtin_msa_bclr_w (v4u32, v4u32);
20248 v2u64 __builtin_msa_bclr_d (v2u64, v2u64);
20250 v16u8 __builtin_msa_bclri_b (v16u8, imm0_7);
20251 v8u16 __builtin_msa_bclri_h (v8u16, imm0_15);
20252 v4u32 __builtin_msa_bclri_w (v4u32, imm0_31);
20253 v2u64 __builtin_msa_bclri_d (v2u64, imm0_63);
20255 v16u8 __builtin_msa_binsl_b (v16u8, v16u8, v16u8);
20256 v8u16 __builtin_msa_binsl_h (v8u16, v8u16, v8u16);
20257 v4u32 __builtin_msa_binsl_w (v4u32, v4u32, v4u32);
20258 v2u64 __builtin_msa_binsl_d (v2u64, v2u64, v2u64);
20260 v16u8 __builtin_msa_binsli_b (v16u8, v16u8, imm0_7);
20261 v8u16 __builtin_msa_binsli_h (v8u16, v8u16, imm0_15);
20262 v4u32 __builtin_msa_binsli_w (v4u32, v4u32, imm0_31);
20263 v2u64 __builtin_msa_binsli_d (v2u64, v2u64, imm0_63);
20265 v16u8 __builtin_msa_binsr_b (v16u8, v16u8, v16u8);
20266 v8u16 __builtin_msa_binsr_h (v8u16, v8u16, v8u16);
20267 v4u32 __builtin_msa_binsr_w (v4u32, v4u32, v4u32);
20268 v2u64 __builtin_msa_binsr_d (v2u64, v2u64, v2u64);
20270 v16u8 __builtin_msa_binsri_b (v16u8, v16u8, imm0_7);
20271 v8u16 __builtin_msa_binsri_h (v8u16, v8u16, imm0_15);
20272 v4u32 __builtin_msa_binsri_w (v4u32, v4u32, imm0_31);
20273 v2u64 __builtin_msa_binsri_d (v2u64, v2u64, imm0_63);
20275 v16u8 __builtin_msa_bmnz_v (v16u8, v16u8, v16u8);
20277 v16u8 __builtin_msa_bmnzi_b (v16u8, v16u8, imm0_255);
20279 v16u8 __builtin_msa_bmz_v (v16u8, v16u8, v16u8);
20281 v16u8 __builtin_msa_bmzi_b (v16u8, v16u8, imm0_255);
20283 v16u8 __builtin_msa_bneg_b (v16u8, v16u8);
20284 v8u16 __builtin_msa_bneg_h (v8u16, v8u16);
20285 v4u32 __builtin_msa_bneg_w (v4u32, v4u32);
20286 v2u64 __builtin_msa_bneg_d (v2u64, v2u64);
20288 v16u8 __builtin_msa_bnegi_b (v16u8, imm0_7);
20289 v8u16 __builtin_msa_bnegi_h (v8u16, imm0_15);
20290 v4u32 __builtin_msa_bnegi_w (v4u32, imm0_31);
20291 v2u64 __builtin_msa_bnegi_d (v2u64, imm0_63);
20293 i32 __builtin_msa_bnz_b (v16u8);
20294 i32 __builtin_msa_bnz_h (v8u16);
20295 i32 __builtin_msa_bnz_w (v4u32);
20296 i32 __builtin_msa_bnz_d (v2u64);
20298 i32 __builtin_msa_bnz_v (v16u8);
20300 v16u8 __builtin_msa_bsel_v (v16u8, v16u8, v16u8);
20302 v16u8 __builtin_msa_bseli_b (v16u8, v16u8, imm0_255);
20304 v16u8 __builtin_msa_bset_b (v16u8, v16u8);
20305 v8u16 __builtin_msa_bset_h (v8u16, v8u16);
20306 v4u32 __builtin_msa_bset_w (v4u32, v4u32);
20307 v2u64 __builtin_msa_bset_d (v2u64, v2u64);
20309 v16u8 __builtin_msa_bseti_b (v16u8, imm0_7);
20310 v8u16 __builtin_msa_bseti_h (v8u16, imm0_15);
20311 v4u32 __builtin_msa_bseti_w (v4u32, imm0_31);
20312 v2u64 __builtin_msa_bseti_d (v2u64, imm0_63);
20314 i32 __builtin_msa_bz_b (v16u8);
20315 i32 __builtin_msa_bz_h (v8u16);
20316 i32 __builtin_msa_bz_w (v4u32);
20317 i32 __builtin_msa_bz_d (v2u64);
20319 i32 __builtin_msa_bz_v (v16u8);
20321 v16i8 __builtin_msa_ceq_b (v16i8, v16i8);
20322 v8i16 __builtin_msa_ceq_h (v8i16, v8i16);
20323 v4i32 __builtin_msa_ceq_w (v4i32, v4i32);
20324 v2i64 __builtin_msa_ceq_d (v2i64, v2i64);
20326 v16i8 __builtin_msa_ceqi_b (v16i8, imm_n16_15);
20327 v8i16 __builtin_msa_ceqi_h (v8i16, imm_n16_15);
20328 v4i32 __builtin_msa_ceqi_w (v4i32, imm_n16_15);
20329 v2i64 __builtin_msa_ceqi_d (v2i64, imm_n16_15);
20331 i32 __builtin_msa_cfcmsa (imm0_31);
20333 v16i8 __builtin_msa_cle_s_b (v16i8, v16i8);
20334 v8i16 __builtin_msa_cle_s_h (v8i16, v8i16);
20335 v4i32 __builtin_msa_cle_s_w (v4i32, v4i32);
20336 v2i64 __builtin_msa_cle_s_d (v2i64, v2i64);
20338 v16i8 __builtin_msa_cle_u_b (v16u8, v16u8);
20339 v8i16 __builtin_msa_cle_u_h (v8u16, v8u16);
20340 v4i32 __builtin_msa_cle_u_w (v4u32, v4u32);
20341 v2i64 __builtin_msa_cle_u_d (v2u64, v2u64);
20343 v16i8 __builtin_msa_clei_s_b (v16i8, imm_n16_15);
20344 v8i16 __builtin_msa_clei_s_h (v8i16, imm_n16_15);
20345 v4i32 __builtin_msa_clei_s_w (v4i32, imm_n16_15);
20346 v2i64 __builtin_msa_clei_s_d (v2i64, imm_n16_15);
20348 v16i8 __builtin_msa_clei_u_b (v16u8, imm0_31);
20349 v8i16 __builtin_msa_clei_u_h (v8u16, imm0_31);
20350 v4i32 __builtin_msa_clei_u_w (v4u32, imm0_31);
20351 v2i64 __builtin_msa_clei_u_d (v2u64, imm0_31);
20353 v16i8 __builtin_msa_clt_s_b (v16i8, v16i8);
20354 v8i16 __builtin_msa_clt_s_h (v8i16, v8i16);
20355 v4i32 __builtin_msa_clt_s_w (v4i32, v4i32);
20356 v2i64 __builtin_msa_clt_s_d (v2i64, v2i64);
20358 v16i8 __builtin_msa_clt_u_b (v16u8, v16u8);
20359 v8i16 __builtin_msa_clt_u_h (v8u16, v8u16);
20360 v4i32 __builtin_msa_clt_u_w (v4u32, v4u32);
20361 v2i64 __builtin_msa_clt_u_d (v2u64, v2u64);
20363 v16i8 __builtin_msa_clti_s_b (v16i8, imm_n16_15);
20364 v8i16 __builtin_msa_clti_s_h (v8i16, imm_n16_15);
20365 v4i32 __builtin_msa_clti_s_w (v4i32, imm_n16_15);
20366 v2i64 __builtin_msa_clti_s_d (v2i64, imm_n16_15);
20368 v16i8 __builtin_msa_clti_u_b (v16u8, imm0_31);
20369 v8i16 __builtin_msa_clti_u_h (v8u16, imm0_31);
20370 v4i32 __builtin_msa_clti_u_w (v4u32, imm0_31);
20371 v2i64 __builtin_msa_clti_u_d (v2u64, imm0_31);
20373 i32 __builtin_msa_copy_s_b (v16i8, imm0_15);
20374 i32 __builtin_msa_copy_s_h (v8i16, imm0_7);
20375 i32 __builtin_msa_copy_s_w (v4i32, imm0_3);
20376 i64 __builtin_msa_copy_s_d (v2i64, imm0_1);
20378 u32 __builtin_msa_copy_u_b (v16i8, imm0_15);
20379 u32 __builtin_msa_copy_u_h (v8i16, imm0_7);
20380 u32 __builtin_msa_copy_u_w (v4i32, imm0_3);
20381 u64 __builtin_msa_copy_u_d (v2i64, imm0_1);
20383 void __builtin_msa_ctcmsa (imm0_31, i32);
20385 v16i8 __builtin_msa_div_s_b (v16i8, v16i8);
20386 v8i16 __builtin_msa_div_s_h (v8i16, v8i16);
20387 v4i32 __builtin_msa_div_s_w (v4i32, v4i32);
20388 v2i64 __builtin_msa_div_s_d (v2i64, v2i64);
20390 v16u8 __builtin_msa_div_u_b (v16u8, v16u8);
20391 v8u16 __builtin_msa_div_u_h (v8u16, v8u16);
20392 v4u32 __builtin_msa_div_u_w (v4u32, v4u32);
20393 v2u64 __builtin_msa_div_u_d (v2u64, v2u64);
20395 v8i16 __builtin_msa_dotp_s_h (v16i8, v16i8);
20396 v4i32 __builtin_msa_dotp_s_w (v8i16, v8i16);
20397 v2i64 __builtin_msa_dotp_s_d (v4i32, v4i32);
20399 v8u16 __builtin_msa_dotp_u_h (v16u8, v16u8);
20400 v4u32 __builtin_msa_dotp_u_w (v8u16, v8u16);
20401 v2u64 __builtin_msa_dotp_u_d (v4u32, v4u32);
20403 v8i16 __builtin_msa_dpadd_s_h (v8i16, v16i8, v16i8);
20404 v4i32 __builtin_msa_dpadd_s_w (v4i32, v8i16, v8i16);
20405 v2i64 __builtin_msa_dpadd_s_d (v2i64, v4i32, v4i32);
20407 v8u16 __builtin_msa_dpadd_u_h (v8u16, v16u8, v16u8);
20408 v4u32 __builtin_msa_dpadd_u_w (v4u32, v8u16, v8u16);
20409 v2u64 __builtin_msa_dpadd_u_d (v2u64, v4u32, v4u32);
20411 v8i16 __builtin_msa_dpsub_s_h (v8i16, v16i8, v16i8);
20412 v4i32 __builtin_msa_dpsub_s_w (v4i32, v8i16, v8i16);
20413 v2i64 __builtin_msa_dpsub_s_d (v2i64, v4i32, v4i32);
20415 v8i16 __builtin_msa_dpsub_u_h (v8i16, v16u8, v16u8);
20416 v4i32 __builtin_msa_dpsub_u_w (v4i32, v8u16, v8u16);
20417 v2i64 __builtin_msa_dpsub_u_d (v2i64, v4u32, v4u32);
20419 v4f32 __builtin_msa_fadd_w (v4f32, v4f32);
20420 v2f64 __builtin_msa_fadd_d (v2f64, v2f64);
20422 v4i32 __builtin_msa_fcaf_w (v4f32, v4f32);
20423 v2i64 __builtin_msa_fcaf_d (v2f64, v2f64);
20425 v4i32 __builtin_msa_fceq_w (v4f32, v4f32);
20426 v2i64 __builtin_msa_fceq_d (v2f64, v2f64);
20428 v4i32 __builtin_msa_fclass_w (v4f32);
20429 v2i64 __builtin_msa_fclass_d (v2f64);
20431 v4i32 __builtin_msa_fcle_w (v4f32, v4f32);
20432 v2i64 __builtin_msa_fcle_d (v2f64, v2f64);
20434 v4i32 __builtin_msa_fclt_w (v4f32, v4f32);
20435 v2i64 __builtin_msa_fclt_d (v2f64, v2f64);
20437 v4i32 __builtin_msa_fcne_w (v4f32, v4f32);
20438 v2i64 __builtin_msa_fcne_d (v2f64, v2f64);
20440 v4i32 __builtin_msa_fcor_w (v4f32, v4f32);
20441 v2i64 __builtin_msa_fcor_d (v2f64, v2f64);
20443 v4i32 __builtin_msa_fcueq_w (v4f32, v4f32);
20444 v2i64 __builtin_msa_fcueq_d (v2f64, v2f64);
20446 v4i32 __builtin_msa_fcule_w (v4f32, v4f32);
20447 v2i64 __builtin_msa_fcule_d (v2f64, v2f64);
20449 v4i32 __builtin_msa_fcult_w (v4f32, v4f32);
20450 v2i64 __builtin_msa_fcult_d (v2f64, v2f64);
20452 v4i32 __builtin_msa_fcun_w (v4f32, v4f32);
20453 v2i64 __builtin_msa_fcun_d (v2f64, v2f64);
20455 v4i32 __builtin_msa_fcune_w (v4f32, v4f32);
20456 v2i64 __builtin_msa_fcune_d (v2f64, v2f64);
20458 v4f32 __builtin_msa_fdiv_w (v4f32, v4f32);
20459 v2f64 __builtin_msa_fdiv_d (v2f64, v2f64);
20461 v8i16 __builtin_msa_fexdo_h (v4f32, v4f32);
20462 v4f32 __builtin_msa_fexdo_w (v2f64, v2f64);
20464 v4f32 __builtin_msa_fexp2_w (v4f32, v4i32);
20465 v2f64 __builtin_msa_fexp2_d (v2f64, v2i64);
20467 v4f32 __builtin_msa_fexupl_w (v8i16);
20468 v2f64 __builtin_msa_fexupl_d (v4f32);
20470 v4f32 __builtin_msa_fexupr_w (v8i16);
20471 v2f64 __builtin_msa_fexupr_d (v4f32);
20473 v4f32 __builtin_msa_ffint_s_w (v4i32);
20474 v2f64 __builtin_msa_ffint_s_d (v2i64);
20476 v4f32 __builtin_msa_ffint_u_w (v4u32);
20477 v2f64 __builtin_msa_ffint_u_d (v2u64);
20479 v4f32 __builtin_msa_ffql_w (v8i16);
20480 v2f64 __builtin_msa_ffql_d (v4i32);
20482 v4f32 __builtin_msa_ffqr_w (v8i16);
20483 v2f64 __builtin_msa_ffqr_d (v4i32);
20485 v16i8 __builtin_msa_fill_b (i32);
20486 v8i16 __builtin_msa_fill_h (i32);
20487 v4i32 __builtin_msa_fill_w (i32);
20488 v2i64 __builtin_msa_fill_d (i64);
20490 v4f32 __builtin_msa_flog2_w (v4f32);
20491 v2f64 __builtin_msa_flog2_d (v2f64);
20493 v4f32 __builtin_msa_fmadd_w (v4f32, v4f32, v4f32);
20494 v2f64 __builtin_msa_fmadd_d (v2f64, v2f64, v2f64);
20496 v4f32 __builtin_msa_fmax_w (v4f32, v4f32);
20497 v2f64 __builtin_msa_fmax_d (v2f64, v2f64);
20499 v4f32 __builtin_msa_fmax_a_w (v4f32, v4f32);
20500 v2f64 __builtin_msa_fmax_a_d (v2f64, v2f64);
20502 v4f32 __builtin_msa_fmin_w (v4f32, v4f32);
20503 v2f64 __builtin_msa_fmin_d (v2f64, v2f64);
20505 v4f32 __builtin_msa_fmin_a_w (v4f32, v4f32);
20506 v2f64 __builtin_msa_fmin_a_d (v2f64, v2f64);
20508 v4f32 __builtin_msa_fmsub_w (v4f32, v4f32, v4f32);
20509 v2f64 __builtin_msa_fmsub_d (v2f64, v2f64, v2f64);
20511 v4f32 __builtin_msa_fmul_w (v4f32, v4f32);
20512 v2f64 __builtin_msa_fmul_d (v2f64, v2f64);
20514 v4f32 __builtin_msa_frint_w (v4f32);
20515 v2f64 __builtin_msa_frint_d (v2f64);
20517 v4f32 __builtin_msa_frcp_w (v4f32);
20518 v2f64 __builtin_msa_frcp_d (v2f64);
20520 v4f32 __builtin_msa_frsqrt_w (v4f32);
20521 v2f64 __builtin_msa_frsqrt_d (v2f64);
20523 v4i32 __builtin_msa_fsaf_w (v4f32, v4f32);
20524 v2i64 __builtin_msa_fsaf_d (v2f64, v2f64);
20526 v4i32 __builtin_msa_fseq_w (v4f32, v4f32);
20527 v2i64 __builtin_msa_fseq_d (v2f64, v2f64);
20529 v4i32 __builtin_msa_fsle_w (v4f32, v4f32);
20530 v2i64 __builtin_msa_fsle_d (v2f64, v2f64);
20532 v4i32 __builtin_msa_fslt_w (v4f32, v4f32);
20533 v2i64 __builtin_msa_fslt_d (v2f64, v2f64);
20535 v4i32 __builtin_msa_fsne_w (v4f32, v4f32);
20536 v2i64 __builtin_msa_fsne_d (v2f64, v2f64);
20538 v4i32 __builtin_msa_fsor_w (v4f32, v4f32);
20539 v2i64 __builtin_msa_fsor_d (v2f64, v2f64);
20541 v4f32 __builtin_msa_fsqrt_w (v4f32);
20542 v2f64 __builtin_msa_fsqrt_d (v2f64);
20544 v4f32 __builtin_msa_fsub_w (v4f32, v4f32);
20545 v2f64 __builtin_msa_fsub_d (v2f64, v2f64);
20547 v4i32 __builtin_msa_fsueq_w (v4f32, v4f32);
20548 v2i64 __builtin_msa_fsueq_d (v2f64, v2f64);
20550 v4i32 __builtin_msa_fsule_w (v4f32, v4f32);
20551 v2i64 __builtin_msa_fsule_d (v2f64, v2f64);
20553 v4i32 __builtin_msa_fsult_w (v4f32, v4f32);
20554 v2i64 __builtin_msa_fsult_d (v2f64, v2f64);
20556 v4i32 __builtin_msa_fsun_w (v4f32, v4f32);
20557 v2i64 __builtin_msa_fsun_d (v2f64, v2f64);
20559 v4i32 __builtin_msa_fsune_w (v4f32, v4f32);
20560 v2i64 __builtin_msa_fsune_d (v2f64, v2f64);
20562 v4i32 __builtin_msa_ftint_s_w (v4f32);
20563 v2i64 __builtin_msa_ftint_s_d (v2f64);
20565 v4u32 __builtin_msa_ftint_u_w (v4f32);
20566 v2u64 __builtin_msa_ftint_u_d (v2f64);
20568 v8i16 __builtin_msa_ftq_h (v4f32, v4f32);
20569 v4i32 __builtin_msa_ftq_w (v2f64, v2f64);
20571 v4i32 __builtin_msa_ftrunc_s_w (v4f32);
20572 v2i64 __builtin_msa_ftrunc_s_d (v2f64);
20574 v4u32 __builtin_msa_ftrunc_u_w (v4f32);
20575 v2u64 __builtin_msa_ftrunc_u_d (v2f64);
20577 v8i16 __builtin_msa_hadd_s_h (v16i8, v16i8);
20578 v4i32 __builtin_msa_hadd_s_w (v8i16, v8i16);
20579 v2i64 __builtin_msa_hadd_s_d (v4i32, v4i32);
20581 v8u16 __builtin_msa_hadd_u_h (v16u8, v16u8);
20582 v4u32 __builtin_msa_hadd_u_w (v8u16, v8u16);
20583 v2u64 __builtin_msa_hadd_u_d (v4u32, v4u32);
20585 v8i16 __builtin_msa_hsub_s_h (v16i8, v16i8);
20586 v4i32 __builtin_msa_hsub_s_w (v8i16, v8i16);
20587 v2i64 __builtin_msa_hsub_s_d (v4i32, v4i32);
20589 v8i16 __builtin_msa_hsub_u_h (v16u8, v16u8);
20590 v4i32 __builtin_msa_hsub_u_w (v8u16, v8u16);
20591 v2i64 __builtin_msa_hsub_u_d (v4u32, v4u32);
20593 v16i8 __builtin_msa_ilvev_b (v16i8, v16i8);
20594 v8i16 __builtin_msa_ilvev_h (v8i16, v8i16);
20595 v4i32 __builtin_msa_ilvev_w (v4i32, v4i32);
20596 v2i64 __builtin_msa_ilvev_d (v2i64, v2i64);
20598 v16i8 __builtin_msa_ilvl_b (v16i8, v16i8);
20599 v8i16 __builtin_msa_ilvl_h (v8i16, v8i16);
20600 v4i32 __builtin_msa_ilvl_w (v4i32, v4i32);
20601 v2i64 __builtin_msa_ilvl_d (v2i64, v2i64);
20603 v16i8 __builtin_msa_ilvod_b (v16i8, v16i8);
20604 v8i16 __builtin_msa_ilvod_h (v8i16, v8i16);
20605 v4i32 __builtin_msa_ilvod_w (v4i32, v4i32);
20606 v2i64 __builtin_msa_ilvod_d (v2i64, v2i64);
20608 v16i8 __builtin_msa_ilvr_b (v16i8, v16i8);
20609 v8i16 __builtin_msa_ilvr_h (v8i16, v8i16);
20610 v4i32 __builtin_msa_ilvr_w (v4i32, v4i32);
20611 v2i64 __builtin_msa_ilvr_d (v2i64, v2i64);
20613 v16i8 __builtin_msa_insert_b (v16i8, imm0_15, i32);
20614 v8i16 __builtin_msa_insert_h (v8i16, imm0_7, i32);
20615 v4i32 __builtin_msa_insert_w (v4i32, imm0_3, i32);
20616 v2i64 __builtin_msa_insert_d (v2i64, imm0_1, i64);
20618 v16i8 __builtin_msa_insve_b (v16i8, imm0_15, v16i8);
20619 v8i16 __builtin_msa_insve_h (v8i16, imm0_7, v8i16);
20620 v4i32 __builtin_msa_insve_w (v4i32, imm0_3, v4i32);
20621 v2i64 __builtin_msa_insve_d (v2i64, imm0_1, v2i64);
20623 v16i8 __builtin_msa_ld_b (const void *, imm_n512_511);
20624 v8i16 __builtin_msa_ld_h (const void *, imm_n1024_1022);
20625 v4i32 __builtin_msa_ld_w (const void *, imm_n2048_2044);
20626 v2i64 __builtin_msa_ld_d (const void *, imm_n4096_4088);
20628 v16i8 __builtin_msa_ldi_b (imm_n512_511);
20629 v8i16 __builtin_msa_ldi_h (imm_n512_511);
20630 v4i32 __builtin_msa_ldi_w (imm_n512_511);
20631 v2i64 __builtin_msa_ldi_d (imm_n512_511);
20633 v8i16 __builtin_msa_madd_q_h (v8i16, v8i16, v8i16);
20634 v4i32 __builtin_msa_madd_q_w (v4i32, v4i32, v4i32);
20636 v8i16 __builtin_msa_maddr_q_h (v8i16, v8i16, v8i16);
20637 v4i32 __builtin_msa_maddr_q_w (v4i32, v4i32, v4i32);
20639 v16i8 __builtin_msa_maddv_b (v16i8, v16i8, v16i8);
20640 v8i16 __builtin_msa_maddv_h (v8i16, v8i16, v8i16);
20641 v4i32 __builtin_msa_maddv_w (v4i32, v4i32, v4i32);
20642 v2i64 __builtin_msa_maddv_d (v2i64, v2i64, v2i64);
20644 v16i8 __builtin_msa_max_a_b (v16i8, v16i8);
20645 v8i16 __builtin_msa_max_a_h (v8i16, v8i16);
20646 v4i32 __builtin_msa_max_a_w (v4i32, v4i32);
20647 v2i64 __builtin_msa_max_a_d (v2i64, v2i64);
20649 v16i8 __builtin_msa_max_s_b (v16i8, v16i8);
20650 v8i16 __builtin_msa_max_s_h (v8i16, v8i16);
20651 v4i32 __builtin_msa_max_s_w (v4i32, v4i32);
20652 v2i64 __builtin_msa_max_s_d (v2i64, v2i64);
20654 v16u8 __builtin_msa_max_u_b (v16u8, v16u8);
20655 v8u16 __builtin_msa_max_u_h (v8u16, v8u16);
20656 v4u32 __builtin_msa_max_u_w (v4u32, v4u32);
20657 v2u64 __builtin_msa_max_u_d (v2u64, v2u64);
20659 v16i8 __builtin_msa_maxi_s_b (v16i8, imm_n16_15);
20660 v8i16 __builtin_msa_maxi_s_h (v8i16, imm_n16_15);
20661 v4i32 __builtin_msa_maxi_s_w (v4i32, imm_n16_15);
20662 v2i64 __builtin_msa_maxi_s_d (v2i64, imm_n16_15);
20664 v16u8 __builtin_msa_maxi_u_b (v16u8, imm0_31);
20665 v8u16 __builtin_msa_maxi_u_h (v8u16, imm0_31);
20666 v4u32 __builtin_msa_maxi_u_w (v4u32, imm0_31);
20667 v2u64 __builtin_msa_maxi_u_d (v2u64, imm0_31);
20669 v16i8 __builtin_msa_min_a_b (v16i8, v16i8);
20670 v8i16 __builtin_msa_min_a_h (v8i16, v8i16);
20671 v4i32 __builtin_msa_min_a_w (v4i32, v4i32);
20672 v2i64 __builtin_msa_min_a_d (v2i64, v2i64);
20674 v16i8 __builtin_msa_min_s_b (v16i8, v16i8);
20675 v8i16 __builtin_msa_min_s_h (v8i16, v8i16);
20676 v4i32 __builtin_msa_min_s_w (v4i32, v4i32);
20677 v2i64 __builtin_msa_min_s_d (v2i64, v2i64);
20679 v16u8 __builtin_msa_min_u_b (v16u8, v16u8);
20680 v8u16 __builtin_msa_min_u_h (v8u16, v8u16);
20681 v4u32 __builtin_msa_min_u_w (v4u32, v4u32);
20682 v2u64 __builtin_msa_min_u_d (v2u64, v2u64);
20684 v16i8 __builtin_msa_mini_s_b (v16i8, imm_n16_15);
20685 v8i16 __builtin_msa_mini_s_h (v8i16, imm_n16_15);
20686 v4i32 __builtin_msa_mini_s_w (v4i32, imm_n16_15);
20687 v2i64 __builtin_msa_mini_s_d (v2i64, imm_n16_15);
20689 v16u8 __builtin_msa_mini_u_b (v16u8, imm0_31);
20690 v8u16 __builtin_msa_mini_u_h (v8u16, imm0_31);
20691 v4u32 __builtin_msa_mini_u_w (v4u32, imm0_31);
20692 v2u64 __builtin_msa_mini_u_d (v2u64, imm0_31);
20694 v16i8 __builtin_msa_mod_s_b (v16i8, v16i8);
20695 v8i16 __builtin_msa_mod_s_h (v8i16, v8i16);
20696 v4i32 __builtin_msa_mod_s_w (v4i32, v4i32);
20697 v2i64 __builtin_msa_mod_s_d (v2i64, v2i64);
20699 v16u8 __builtin_msa_mod_u_b (v16u8, v16u8);
20700 v8u16 __builtin_msa_mod_u_h (v8u16, v8u16);
20701 v4u32 __builtin_msa_mod_u_w (v4u32, v4u32);
20702 v2u64 __builtin_msa_mod_u_d (v2u64, v2u64);
20704 v16i8 __builtin_msa_move_v (v16i8);
20706 v8i16 __builtin_msa_msub_q_h (v8i16, v8i16, v8i16);
20707 v4i32 __builtin_msa_msub_q_w (v4i32, v4i32, v4i32);
20709 v8i16 __builtin_msa_msubr_q_h (v8i16, v8i16, v8i16);
20710 v4i32 __builtin_msa_msubr_q_w (v4i32, v4i32, v4i32);
20712 v16i8 __builtin_msa_msubv_b (v16i8, v16i8, v16i8);
20713 v8i16 __builtin_msa_msubv_h (v8i16, v8i16, v8i16);
20714 v4i32 __builtin_msa_msubv_w (v4i32, v4i32, v4i32);
20715 v2i64 __builtin_msa_msubv_d (v2i64, v2i64, v2i64);
20717 v8i16 __builtin_msa_mul_q_h (v8i16, v8i16);
20718 v4i32 __builtin_msa_mul_q_w (v4i32, v4i32);
20720 v8i16 __builtin_msa_mulr_q_h (v8i16, v8i16);
20721 v4i32 __builtin_msa_mulr_q_w (v4i32, v4i32);
20723 v16i8 __builtin_msa_mulv_b (v16i8, v16i8);
20724 v8i16 __builtin_msa_mulv_h (v8i16, v8i16);
20725 v4i32 __builtin_msa_mulv_w (v4i32, v4i32);
20726 v2i64 __builtin_msa_mulv_d (v2i64, v2i64);
20728 v16i8 __builtin_msa_nloc_b (v16i8);
20729 v8i16 __builtin_msa_nloc_h (v8i16);
20730 v4i32 __builtin_msa_nloc_w (v4i32);
20731 v2i64 __builtin_msa_nloc_d (v2i64);
20733 v16i8 __builtin_msa_nlzc_b (v16i8);
20734 v8i16 __builtin_msa_nlzc_h (v8i16);
20735 v4i32 __builtin_msa_nlzc_w (v4i32);
20736 v2i64 __builtin_msa_nlzc_d (v2i64);
20738 v16u8 __builtin_msa_nor_v (v16u8, v16u8);
20740 v16u8 __builtin_msa_nori_b (v16u8, imm0_255);
20742 v16u8 __builtin_msa_or_v (v16u8, v16u8);
20744 v16u8 __builtin_msa_ori_b (v16u8, imm0_255);
20746 v16i8 __builtin_msa_pckev_b (v16i8, v16i8);
20747 v8i16 __builtin_msa_pckev_h (v8i16, v8i16);
20748 v4i32 __builtin_msa_pckev_w (v4i32, v4i32);
20749 v2i64 __builtin_msa_pckev_d (v2i64, v2i64);
20751 v16i8 __builtin_msa_pckod_b (v16i8, v16i8);
20752 v8i16 __builtin_msa_pckod_h (v8i16, v8i16);
20753 v4i32 __builtin_msa_pckod_w (v4i32, v4i32);
20754 v2i64 __builtin_msa_pckod_d (v2i64, v2i64);
20756 v16i8 __builtin_msa_pcnt_b (v16i8);
20757 v8i16 __builtin_msa_pcnt_h (v8i16);
20758 v4i32 __builtin_msa_pcnt_w (v4i32);
20759 v2i64 __builtin_msa_pcnt_d (v2i64);
20761 v16i8 __builtin_msa_sat_s_b (v16i8, imm0_7);
20762 v8i16 __builtin_msa_sat_s_h (v8i16, imm0_15);
20763 v4i32 __builtin_msa_sat_s_w (v4i32, imm0_31);
20764 v2i64 __builtin_msa_sat_s_d (v2i64, imm0_63);
20766 v16u8 __builtin_msa_sat_u_b (v16u8, imm0_7);
20767 v8u16 __builtin_msa_sat_u_h (v8u16, imm0_15);
20768 v4u32 __builtin_msa_sat_u_w (v4u32, imm0_31);
20769 v2u64 __builtin_msa_sat_u_d (v2u64, imm0_63);
20771 v16i8 __builtin_msa_shf_b (v16i8, imm0_255);
20772 v8i16 __builtin_msa_shf_h (v8i16, imm0_255);
20773 v4i32 __builtin_msa_shf_w (v4i32, imm0_255);
20775 v16i8 __builtin_msa_sld_b (v16i8, v16i8, i32);
20776 v8i16 __builtin_msa_sld_h (v8i16, v8i16, i32);
20777 v4i32 __builtin_msa_sld_w (v4i32, v4i32, i32);
20778 v2i64 __builtin_msa_sld_d (v2i64, v2i64, i32);
20780 v16i8 __builtin_msa_sldi_b (v16i8, v16i8, imm0_15);
20781 v8i16 __builtin_msa_sldi_h (v8i16, v8i16, imm0_7);
20782 v4i32 __builtin_msa_sldi_w (v4i32, v4i32, imm0_3);
20783 v2i64 __builtin_msa_sldi_d (v2i64, v2i64, imm0_1);
20785 v16i8 __builtin_msa_sll_b (v16i8, v16i8);
20786 v8i16 __builtin_msa_sll_h (v8i16, v8i16);
20787 v4i32 __builtin_msa_sll_w (v4i32, v4i32);
20788 v2i64 __builtin_msa_sll_d (v2i64, v2i64);
20790 v16i8 __builtin_msa_slli_b (v16i8, imm0_7);
20791 v8i16 __builtin_msa_slli_h (v8i16, imm0_15);
20792 v4i32 __builtin_msa_slli_w (v4i32, imm0_31);
20793 v2i64 __builtin_msa_slli_d (v2i64, imm0_63);
20795 v16i8 __builtin_msa_splat_b (v16i8, i32);
20796 v8i16 __builtin_msa_splat_h (v8i16, i32);
20797 v4i32 __builtin_msa_splat_w (v4i32, i32);
20798 v2i64 __builtin_msa_splat_d (v2i64, i32);
20800 v16i8 __builtin_msa_splati_b (v16i8, imm0_15);
20801 v8i16 __builtin_msa_splati_h (v8i16, imm0_7);
20802 v4i32 __builtin_msa_splati_w (v4i32, imm0_3);
20803 v2i64 __builtin_msa_splati_d (v2i64, imm0_1);
20805 v16i8 __builtin_msa_sra_b (v16i8, v16i8);
20806 v8i16 __builtin_msa_sra_h (v8i16, v8i16);
20807 v4i32 __builtin_msa_sra_w (v4i32, v4i32);
20808 v2i64 __builtin_msa_sra_d (v2i64, v2i64);
20810 v16i8 __builtin_msa_srai_b (v16i8, imm0_7);
20811 v8i16 __builtin_msa_srai_h (v8i16, imm0_15);
20812 v4i32 __builtin_msa_srai_w (v4i32, imm0_31);
20813 v2i64 __builtin_msa_srai_d (v2i64, imm0_63);
20815 v16i8 __builtin_msa_srar_b (v16i8, v16i8);
20816 v8i16 __builtin_msa_srar_h (v8i16, v8i16);
20817 v4i32 __builtin_msa_srar_w (v4i32, v4i32);
20818 v2i64 __builtin_msa_srar_d (v2i64, v2i64);
20820 v16i8 __builtin_msa_srari_b (v16i8, imm0_7);
20821 v8i16 __builtin_msa_srari_h (v8i16, imm0_15);
20822 v4i32 __builtin_msa_srari_w (v4i32, imm0_31);
20823 v2i64 __builtin_msa_srari_d (v2i64, imm0_63);
20825 v16i8 __builtin_msa_srl_b (v16i8, v16i8);
20826 v8i16 __builtin_msa_srl_h (v8i16, v8i16);
20827 v4i32 __builtin_msa_srl_w (v4i32, v4i32);
20828 v2i64 __builtin_msa_srl_d (v2i64, v2i64);
20830 v16i8 __builtin_msa_srli_b (v16i8, imm0_7);
20831 v8i16 __builtin_msa_srli_h (v8i16, imm0_15);
20832 v4i32 __builtin_msa_srli_w (v4i32, imm0_31);
20833 v2i64 __builtin_msa_srli_d (v2i64, imm0_63);
20835 v16i8 __builtin_msa_srlr_b (v16i8, v16i8);
20836 v8i16 __builtin_msa_srlr_h (v8i16, v8i16);
20837 v4i32 __builtin_msa_srlr_w (v4i32, v4i32);
20838 v2i64 __builtin_msa_srlr_d (v2i64, v2i64);
20840 v16i8 __builtin_msa_srlri_b (v16i8, imm0_7);
20841 v8i16 __builtin_msa_srlri_h (v8i16, imm0_15);
20842 v4i32 __builtin_msa_srlri_w (v4i32, imm0_31);
20843 v2i64 __builtin_msa_srlri_d (v2i64, imm0_63);
20845 void __builtin_msa_st_b (v16i8, void *, imm_n512_511);
20846 void __builtin_msa_st_h (v8i16, void *, imm_n1024_1022);
20847 void __builtin_msa_st_w (v4i32, void *, imm_n2048_2044);
20848 void __builtin_msa_st_d (v2i64, void *, imm_n4096_4088);
20850 v16i8 __builtin_msa_subs_s_b (v16i8, v16i8);
20851 v8i16 __builtin_msa_subs_s_h (v8i16, v8i16);
20852 v4i32 __builtin_msa_subs_s_w (v4i32, v4i32);
20853 v2i64 __builtin_msa_subs_s_d (v2i64, v2i64);
20855 v16u8 __builtin_msa_subs_u_b (v16u8, v16u8);
20856 v8u16 __builtin_msa_subs_u_h (v8u16, v8u16);
20857 v4u32 __builtin_msa_subs_u_w (v4u32, v4u32);
20858 v2u64 __builtin_msa_subs_u_d (v2u64, v2u64);
20860 v16u8 __builtin_msa_subsus_u_b (v16u8, v16i8);
20861 v8u16 __builtin_msa_subsus_u_h (v8u16, v8i16);
20862 v4u32 __builtin_msa_subsus_u_w (v4u32, v4i32);
20863 v2u64 __builtin_msa_subsus_u_d (v2u64, v2i64);
20865 v16i8 __builtin_msa_subsuu_s_b (v16u8, v16u8);
20866 v8i16 __builtin_msa_subsuu_s_h (v8u16, v8u16);
20867 v4i32 __builtin_msa_subsuu_s_w (v4u32, v4u32);
20868 v2i64 __builtin_msa_subsuu_s_d (v2u64, v2u64);
20870 v16i8 __builtin_msa_subv_b (v16i8, v16i8);
20871 v8i16 __builtin_msa_subv_h (v8i16, v8i16);
20872 v4i32 __builtin_msa_subv_w (v4i32, v4i32);
20873 v2i64 __builtin_msa_subv_d (v2i64, v2i64);
20875 v16i8 __builtin_msa_subvi_b (v16i8, imm0_31);
20876 v8i16 __builtin_msa_subvi_h (v8i16, imm0_31);
20877 v4i32 __builtin_msa_subvi_w (v4i32, imm0_31);
20878 v2i64 __builtin_msa_subvi_d (v2i64, imm0_31);
20880 v16i8 __builtin_msa_vshf_b (v16i8, v16i8, v16i8);
20881 v8i16 __builtin_msa_vshf_h (v8i16, v8i16, v8i16);
20882 v4i32 __builtin_msa_vshf_w (v4i32, v4i32, v4i32);
20883 v2i64 __builtin_msa_vshf_d (v2i64, v2i64, v2i64);
20885 v16u8 __builtin_msa_xor_v (v16u8, v16u8);
20887 v16u8 __builtin_msa_xori_b (v16u8, imm0_255);
20888 @end smallexample
20890 @node Other MIPS Built-in Functions
20891 @subsection Other MIPS Built-in Functions
20893 GCC provides other MIPS-specific built-in functions:
20895 @table @code
20896 @item void __builtin_mips_cache (int @var{op}, const volatile void *@var{addr})
20897 Insert a @samp{cache} instruction with operands @var{op} and @var{addr}.
20898 GCC defines the preprocessor macro @code{___GCC_HAVE_BUILTIN_MIPS_CACHE}
20899 when this function is available.
20901 @item unsigned int __builtin_mips_get_fcsr (void)
20902 @itemx void __builtin_mips_set_fcsr (unsigned int @var{value})
20903 Get and set the contents of the floating-point control and status register
20904 (FPU control register 31).  These functions are only available in hard-float
20905 code but can be called in both MIPS16 and non-MIPS16 contexts.
20907 @code{__builtin_mips_set_fcsr} can be used to change any bit of the
20908 register except the condition codes, which GCC assumes are preserved.
20909 @end table
20911 @node MSP430 Built-in Functions
20912 @subsection MSP430 Built-in Functions
20914 GCC provides a couple of special builtin functions to aid in the
20915 writing of interrupt handlers in C.
20917 @table @code
20918 @item __bic_SR_register_on_exit (int @var{mask})
20919 This clears the indicated bits in the saved copy of the status register
20920 currently residing on the stack.  This only works inside interrupt
20921 handlers and the changes to the status register will only take affect
20922 once the handler returns.
20924 @item __bis_SR_register_on_exit (int @var{mask})
20925 This sets the indicated bits in the saved copy of the status register
20926 currently residing on the stack.  This only works inside interrupt
20927 handlers and the changes to the status register will only take affect
20928 once the handler returns.
20930 @item __delay_cycles (long long @var{cycles})
20931 This inserts an instruction sequence that takes exactly @var{cycles}
20932 cycles (between 0 and about 17E9) to complete.  The inserted sequence
20933 may use jumps, loops, or no-ops, and does not interfere with any other
20934 instructions.  Note that @var{cycles} must be a compile-time constant
20935 integer - that is, you must pass a number, not a variable that may be
20936 optimized to a constant later.  The number of cycles delayed by this
20937 builtin is exact.
20938 @end table
20940 @node NDS32 Built-in Functions
20941 @subsection NDS32 Built-in Functions
20943 These built-in functions are available for the NDS32 target:
20945 @defbuiltin{void __builtin_nds32_isync (int *@var{addr})}
20946 Insert an ISYNC instruction into the instruction stream where
20947 @var{addr} is an instruction address for serialization.
20948 @enddefbuiltin
20950 @defbuiltin{void __builtin_nds32_isb (void)}
20951 Insert an ISB instruction into the instruction stream.
20952 @enddefbuiltin
20954 @defbuiltin{int __builtin_nds32_mfsr (int @var{sr})}
20955 Return the content of a system register which is mapped by @var{sr}.
20956 @enddefbuiltin
20958 @defbuiltin{int __builtin_nds32_mfusr (int @var{usr})}
20959 Return the content of a user space register which is mapped by @var{usr}.
20960 @enddefbuiltin
20962 @defbuiltin{void __builtin_nds32_mtsr (int @var{value}, int @var{sr})}
20963 Move the @var{value} to a system register which is mapped by @var{sr}.
20964 @enddefbuiltin
20966 @defbuiltin{void __builtin_nds32_mtusr (int @var{value}, int @var{usr})}
20967 Move the @var{value} to a user space register which is mapped by @var{usr}.
20968 @enddefbuiltin
20970 @defbuiltin{void __builtin_nds32_setgie_en (void)}
20971 Enable global interrupt.
20972 @enddefbuiltin
20974 @defbuiltin{void __builtin_nds32_setgie_dis (void)}
20975 Disable global interrupt.
20976 @enddefbuiltin
20978 @node Nvidia PTX Built-in Functions
20979 @subsection Nvidia PTX Built-in Functions
20981 These built-in functions are available for the Nvidia PTX target:
20983 @defbuiltin{{unsigned int} __builtin_nvptx_brev (unsigned int @var{x})}
20984 Reverse the bit order of a 32-bit unsigned integer.
20985 @enddefbuiltin
20987 @defbuiltin{{unsigned long long} __builtin_nvptx_brevll (unsigned long long @var{x})}
20988 Reverse the bit order of a 64-bit unsigned integer.
20989 @enddefbuiltin
20991 @node Basic PowerPC Built-in Functions
20992 @subsection Basic PowerPC Built-in Functions
20994 @menu
20995 * Basic PowerPC Built-in Functions Available on all Configurations::
20996 * Basic PowerPC Built-in Functions Available on ISA 2.05::
20997 * Basic PowerPC Built-in Functions Available on ISA 2.06::
20998 * Basic PowerPC Built-in Functions Available on ISA 2.07::
20999 * Basic PowerPC Built-in Functions Available on ISA 3.0::
21000 * Basic PowerPC Built-in Functions Available on ISA 3.1::
21001 @end menu
21003 This section describes PowerPC built-in functions that do not require
21004 the inclusion of any special header files to declare prototypes or
21005 provide macro definitions.  The sections that follow describe
21006 additional PowerPC built-in functions.
21008 @node Basic PowerPC Built-in Functions Available on all Configurations
21009 @subsubsection Basic PowerPC Built-in Functions Available on all Configurations
21011 @defbuiltin{void __builtin_cpu_init (void)}
21012 This function is a @code{nop} on the PowerPC platform and is included solely
21013 to maintain API compatibility with the x86 builtins.
21014 @enddefbuiltin
21016 @defbuiltin{int __builtin_cpu_is (const char *@var{cpuname})}
21017 This function returns a value of @code{1} if the run-time CPU is of type
21018 @var{cpuname} and returns @code{0} otherwise
21020 The @code{__builtin_cpu_is} function requires GLIBC 2.23 or newer
21021 which exports the hardware capability bits.  GCC defines the macro
21022 @code{__BUILTIN_CPU_SUPPORTS__} if the @code{__builtin_cpu_supports}
21023 built-in function is fully supported.
21025 If GCC was configured to use a GLIBC before 2.23, the built-in
21026 function @code{__builtin_cpu_is} always returns a 0 and the compiler
21027 issues a warning.
21029 The following CPU names can be detected:
21031 @table @samp
21032 @item power10
21033 IBM POWER10 Server CPU.
21034 @item power9
21035 IBM POWER9 Server CPU.
21036 @item power8
21037 IBM POWER8 Server CPU.
21038 @item power7
21039 IBM POWER7 Server CPU.
21040 @item power6x
21041 IBM POWER6 Server CPU (RAW mode).
21042 @item power6
21043 IBM POWER6 Server CPU (Architected mode).
21044 @item power5+
21045 IBM POWER5+ Server CPU.
21046 @item power5
21047 IBM POWER5 Server CPU.
21048 @item ppc970
21049 IBM 970 Server CPU (ie, Apple G5).
21050 @item power4
21051 IBM POWER4 Server CPU.
21052 @item ppca2
21053 IBM A2 64-bit Embedded CPU
21054 @item ppc476
21055 IBM PowerPC 476FP 32-bit Embedded CPU.
21056 @item ppc464
21057 IBM PowerPC 464 32-bit Embedded CPU.
21058 @item ppc440
21059 PowerPC 440 32-bit Embedded CPU.
21060 @item ppc405
21061 PowerPC 405 32-bit Embedded CPU.
21062 @item ppc-cell-be
21063 IBM PowerPC Cell Broadband Engine Architecture CPU.
21064 @end table
21066 Here is an example:
21067 @smallexample
21068 #ifdef __BUILTIN_CPU_SUPPORTS__
21069   if (__builtin_cpu_is ("power8"))
21070     @{
21071        do_power8 (); // POWER8 specific implementation.
21072     @}
21073   else
21074 #endif
21075     @{
21076        do_generic (); // Generic implementation.
21077     @}
21078 @end smallexample
21079 @enddefbuiltin
21081 @defbuiltin{int __builtin_cpu_supports (const char *@var{feature})}
21082 This function returns a value of @code{1} if the run-time CPU supports the HWCAP
21083 feature @var{feature} and returns @code{0} otherwise.
21085 The @code{__builtin_cpu_supports} function requires GLIBC 2.23 or
21086 newer which exports the hardware capability bits.  GCC defines the
21087 macro @code{__BUILTIN_CPU_SUPPORTS__} if the
21088 @code{__builtin_cpu_supports} built-in function is fully supported.
21090 If GCC was configured to use a GLIBC before 2.23, the built-in
21091 function @code{__builtin_cpu_supports} always returns a 0 and the
21092 compiler issues a warning.
21094 The following features can be
21095 detected:
21097 @table @samp
21098 @item 4xxmac
21099 4xx CPU has a Multiply Accumulator.
21100 @item altivec
21101 CPU has a SIMD/Vector Unit.
21102 @item arch_2_05
21103 CPU supports ISA 2.05 (eg, POWER6)
21104 @item arch_2_06
21105 CPU supports ISA 2.06 (eg, POWER7)
21106 @item arch_2_07
21107 CPU supports ISA 2.07 (eg, POWER8)
21108 @item arch_3_00
21109 CPU supports ISA 3.0 (eg, POWER9)
21110 @item arch_3_1
21111 CPU supports ISA 3.1 (eg, POWER10)
21112 @item archpmu
21113 CPU supports the set of compatible performance monitoring events.
21114 @item booke
21115 CPU supports the Embedded ISA category.
21116 @item cellbe
21117 CPU has a CELL broadband engine.
21118 @item darn
21119 CPU supports the @code{darn} (deliver a random number) instruction.
21120 @item dfp
21121 CPU has a decimal floating point unit.
21122 @item dscr
21123 CPU supports the data stream control register.
21124 @item ebb
21125 CPU supports event base branching.
21126 @item efpdouble
21127 CPU has a SPE double precision floating point unit.
21128 @item efpsingle
21129 CPU has a SPE single precision floating point unit.
21130 @item fpu
21131 CPU has a floating point unit.
21132 @item htm
21133 CPU has hardware transaction memory instructions.
21134 @item htm-nosc
21135 Kernel aborts hardware transactions when a syscall is made.
21136 @item htm-no-suspend
21137 CPU supports hardware transaction memory but does not support the
21138 @code{tsuspend.} instruction.
21139 @item ic_snoop
21140 CPU supports icache snooping capabilities.
21141 @item ieee128
21142 CPU supports 128-bit IEEE binary floating point instructions.
21143 @item isel
21144 CPU supports the integer select instruction.
21145 @item mma
21146 CPU supports the matrix-multiply assist instructions.
21147 @item mmu
21148 CPU has a memory management unit.
21149 @item notb
21150 CPU does not have a timebase (eg, 601 and 403gx).
21151 @item pa6t
21152 CPU supports the PA Semi 6T CORE ISA.
21153 @item power4
21154 CPU supports ISA 2.00 (eg, POWER4)
21155 @item power5
21156 CPU supports ISA 2.02 (eg, POWER5)
21157 @item power5+
21158 CPU supports ISA 2.03 (eg, POWER5+)
21159 @item power6x
21160 CPU supports ISA 2.05 (eg, POWER6) extended opcodes mffgpr and mftgpr.
21161 @item ppc32
21162 CPU supports 32-bit mode execution.
21163 @item ppc601
21164 CPU supports the old POWER ISA (eg, 601)
21165 @item ppc64
21166 CPU supports 64-bit mode execution.
21167 @item ppcle
21168 CPU supports a little-endian mode that uses address swizzling.
21169 @item scv
21170 Kernel supports system call vectored.
21171 @item smt
21172 CPU support simultaneous multi-threading.
21173 @item spe
21174 CPU has a signal processing extension unit.
21175 @item tar
21176 CPU supports the target address register.
21177 @item true_le
21178 CPU supports true little-endian mode.
21179 @item ucache
21180 CPU has unified I/D cache.
21181 @item vcrypto
21182 CPU supports the vector cryptography instructions.
21183 @item vsx
21184 CPU supports the vector-scalar extension.
21185 @end table
21187 Here is an example:
21188 @smallexample
21189 #ifdef __BUILTIN_CPU_SUPPORTS__
21190   if (__builtin_cpu_supports ("fpu"))
21191     @{
21192        asm("fadd %0,%1,%2" : "=d"(dst) : "d"(src1), "d"(src2));
21193     @}
21194   else
21195 #endif
21196     @{
21197        dst = __fadd (src1, src2); // Software FP addition function.
21198     @}
21199 @end smallexample
21200 @enddefbuiltin
21202 The following built-in functions are also available on all PowerPC
21203 processors:
21204 @smallexample
21205 uint64_t __builtin_ppc_get_timebase ();
21206 unsigned long __builtin_ppc_mftb ();
21207 double __builtin_unpack_ibm128 (__ibm128, int);
21208 __ibm128 __builtin_pack_ibm128 (double, double);
21209 double __builtin_mffs (void);
21210 void __builtin_mtfsf (const int, double);
21211 void __builtin_mtfsb0 (const int);
21212 void __builtin_mtfsb1 (const int);
21213 double __builtin_set_fpscr_rn (int);
21214 @end smallexample
21216 The @code{__builtin_ppc_get_timebase} and @code{__builtin_ppc_mftb}
21217 functions generate instructions to read the Time Base Register.  The
21218 @code{__builtin_ppc_get_timebase} function may generate multiple
21219 instructions and always returns the 64 bits of the Time Base Register.
21220 The @code{__builtin_ppc_mftb} function always generates one instruction and
21221 returns the Time Base Register value as an unsigned long, throwing away
21222 the most significant word on 32-bit environments.  The @code{__builtin_mffs}
21223 return the value of the FPSCR register.  Note, ISA 3.0 supports the
21224 @code{__builtin_mffsl()} which permits software to read the control and
21225 non-sticky status bits in the FSPCR without the higher latency associated with
21226 accessing the sticky status bits.  The @code{__builtin_mtfsf} takes a constant
21227 8-bit integer field mask and a double precision floating point argument
21228 and generates the @code{mtfsf} (extended mnemonic) instruction to write new
21229 values to selected fields of the FPSCR.  The
21230 @code{__builtin_mtfsb0} and @code{__builtin_mtfsb1} take the bit to change
21231 as an argument.  The valid bit range is between 0 and 31.  The builtins map to
21232 the @code{mtfsb0} and @code{mtfsb1} instructions which take the argument and
21233 add 32.  Hence these instructions only modify the FPSCR[32:63] bits by
21234 changing the specified bit to a zero or one respectively.
21236 The @code{__builtin_set_fpscr_rn} built-in allows changing both of the floating
21237 point rounding mode bits and returning the various FPSCR fields before the RN
21238 field is updated.  The built-in returns a double consisting of the initial
21239 value of the FPSCR fields DRN, VE, OE, UE, ZE, XE, NI, and RN bit positions
21240 with all other bits set to zero.  The built-in argument is a 2-bit value for the
21241 new RN field value.  The argument can either be an @code{const int} or stored
21242 in a variable.  Earlier versions of @code{__builtin_set_fpscr_rn} returned
21243 void.  A @code{__SET_FPSCR_RN_RETURNS_FPSCR__} macro has been added.  If
21244 defined, then the @code{__builtin_set_fpscr_rn} built-in returns the FPSCR
21245 fields.  If not defined, the @code{__builtin_set_fpscr_rn} does not return a
21246 value.  If the @option{-msoft-float} option is used, the
21247 @code{__builtin_set_fpscr_rn} built-in will not return a value.
21249 @node Basic PowerPC Built-in Functions Available on ISA 2.05
21250 @subsubsection Basic PowerPC Built-in Functions Available on ISA 2.05
21252 The basic built-in functions described in this section are
21253 available on the PowerPC family of processors starting with ISA 2.05
21254 or later.  Unless specific options are explicitly disabled on the
21255 command line, specifying option @option{-mcpu=power6} has the effect of
21256 enabling the @option{-mpowerpc64}, @option{-mpowerpc-gpopt},
21257 @option{-mpowerpc-gfxopt}, @option{-mmfcrf}, @option{-mpopcntb},
21258 @option{-mfprnd}, @option{-mcmpb}, @option{-mhard-dfp}, and
21259 @option{-mrecip-precision} options.  Specify the
21260 @option{-maltivec} option explicitly in
21261 combination with the above options if desired.
21263 The following functions require option @option{-mcmpb}.
21264 @smallexample
21265 unsigned long long __builtin_cmpb (unsigned long long int, unsigned long long int);
21266 unsigned int __builtin_cmpb (unsigned int, unsigned int);
21267 @end smallexample
21269 The @code{__builtin_cmpb} function
21270 performs a byte-wise compare on the contents of its two arguments,
21271 returning the result of the byte-wise comparison as the returned
21272 value.  For each byte comparison, the corresponding byte of the return
21273 value holds 0xff if the input bytes are equal and 0 if the input bytes
21274 are not equal.  If either of the arguments to this built-in function
21275 is wider than 32 bits, the function call expands into the form that
21276 expects @code{unsigned long long int} arguments
21277 which is only available on 64-bit targets.
21279 The following built-in functions are available
21280 when hardware decimal floating point
21281 (@option{-mhard-dfp}) is available:
21282 @smallexample
21283 void __builtin_set_fpscr_drn(int);
21284 _Decimal64 __builtin_ddedpd (int, _Decimal64);
21285 _Decimal128 __builtin_ddedpdq (int, _Decimal128);
21286 _Decimal64 __builtin_denbcd (int, _Decimal64);
21287 _Decimal128 __builtin_denbcdq (int, _Decimal128);
21288 _Decimal64 __builtin_diex (long long, _Decimal64);
21289 _Decimal128 _builtin_diexq (long long, _Decimal128);
21290 _Decimal64 __builtin_dscli (_Decimal64, int);
21291 _Decimal128 __builtin_dscliq (_Decimal128, int);
21292 _Decimal64 __builtin_dscri (_Decimal64, int);
21293 _Decimal128 __builtin_dscriq (_Decimal128, int);
21294 long long __builtin_dxex (_Decimal64);
21295 long long __builtin_dxexq (_Decimal128);
21296 _Decimal128 __builtin_pack_dec128 (unsigned long long, unsigned long long);
21297 unsigned long long __builtin_unpack_dec128 (_Decimal128, int);
21299 The @code{__builtin_set_fpscr_drn} builtin allows changing the three decimal
21300 floating point rounding mode bits.  The argument is a 3-bit value.  The
21301 argument can either be a @code{const int} or the value can be stored in
21302 a variable.
21303 The builtin uses the ISA 3.0 instruction @code{mffscdrn} if available.
21304 Otherwise the builtin reads the FPSCR, masks the current decimal rounding
21305 mode bits out and OR's in the new value.
21307 _Decimal64 __builtin_dfp_quantize (_Decimal64, _Decimal64, const int);
21308 _Decimal64 __builtin_dfp_quantize (const int, _Decimal64, const int);
21309 _Decimal128 __builtin_dfp_quantize (_Decimal128, _Decimal128, const int);
21310 _Decimal128 __builtin_dfp_quantize (const int, _Decimal128, const int);
21312 The @code{__builtin_dfp_quantize} built-in, converts and rounds the second
21313 argument to the form with the exponent as specified by the first
21314 argument based on the rounding mode specified by the third argument.
21315 If the first argument is a decimal floating point value, its exponent is used
21316 for converting and rounding of the second argument.  If the first argument is a
21317 5-bit constant integer value, then the value specifies the exponent to be used
21318 when rounding and converting the second argument.  The third argument is a
21319 two bit constant integer that specifies the rounding mode.  The possible modes
21320 are: 00 Round to nearest, ties to even; 01 Round toward 0; 10 Round to nearest,
21321 ties away from 0; 11 Round according to DRN where DRN is the Decimal Floating
21322 point field of the FPSCR.
21324 @end smallexample
21326 The following functions require @option{-mhard-float},
21327 @option{-mpowerpc-gfxopt}, and @option{-mpopcntb} options.
21329 @smallexample
21330 double __builtin_recipdiv (double, double);
21331 float __builtin_recipdivf (float, float);
21332 double __builtin_rsqrt (double);
21333 float __builtin_rsqrtf (float);
21334 @end smallexample
21336 The @code{vec_rsqrt}, @code{__builtin_rsqrt}, and
21337 @code{__builtin_rsqrtf} functions generate multiple instructions to
21338 implement the reciprocal sqrt functionality using reciprocal sqrt
21339 estimate instructions.
21341 The @code{__builtin_recipdiv}, and @code{__builtin_recipdivf}
21342 functions generate multiple instructions to implement division using
21343 the reciprocal estimate instructions.
21345 The following functions require @option{-mhard-float} and
21346 @option{-mmultiple} options.
21348 The @code{__builtin_unpack_longdouble} function takes a
21349 @code{long double} argument and a compile time constant of 0 or 1.  If
21350 the constant is 0, the first @code{double} within the
21351 @code{long double} is returned, otherwise the second @code{double}
21352 is returned.  The @code{__builtin_unpack_longdouble} function is only
21353 available if @code{long double} uses the IBM extended double
21354 representation.
21356 The @code{__builtin_pack_longdouble} function takes two @code{double}
21357 arguments and returns a @code{long double} value that combines the two
21358 arguments.  The @code{__builtin_pack_longdouble} function is only
21359 available if @code{long double} uses the IBM extended double
21360 representation.
21362 The @code{__builtin_unpack_ibm128} function takes a @code{__ibm128}
21363 argument and a compile time constant of 0 or 1.  If the constant is 0,
21364 the first @code{double} within the @code{__ibm128} is returned,
21365 otherwise the second @code{double} is returned.
21367 The @code{__builtin_pack_ibm128} function takes two @code{double}
21368 arguments and returns a @code{__ibm128} value that combines the two
21369 arguments.
21371 Additional built-in functions are available for the 64-bit PowerPC
21372 family of processors, for efficient use of 128-bit floating point
21373 (@code{__float128}) values.
21375 @node Basic PowerPC Built-in Functions Available on ISA 2.06
21376 @subsubsection Basic PowerPC Built-in Functions Available on ISA 2.06
21378 The basic built-in functions described in this section are
21379 available on the PowerPC family of processors starting with ISA 2.05
21380 or later.  Unless specific options are explicitly disabled on the
21381 command line, specifying option @option{-mcpu=power7} has the effect of
21382 enabling all the same options as for @option{-mcpu=power6} in
21383 addition to the @option{-maltivec}, @option{-mpopcntd}, and
21384 @option{-mvsx} options.
21386 The following basic built-in functions require @option{-mpopcntd}:
21387 @smallexample
21388 unsigned int __builtin_addg6s (unsigned int, unsigned int);
21389 long long __builtin_bpermd (long long, long long);
21390 unsigned int __builtin_cbcdtd (unsigned int);
21391 unsigned int __builtin_cdtbcd (unsigned int);
21392 long long __builtin_divde (long long, long long);
21393 unsigned long long __builtin_divdeu (unsigned long long, unsigned long long);
21394 int __builtin_divwe (int, int);
21395 unsigned int __builtin_divweu (unsigned int, unsigned int);
21396 vector __int128 __builtin_pack_vector_int128 (long long, long long);
21397 void __builtin_rs6000_speculation_barrier (void);
21398 long long __builtin_unpack_vector_int128 (vector __int128, signed char);
21399 @end smallexample
21401 Of these, the @code{__builtin_divde} and @code{__builtin_divdeu} functions
21402 require a 64-bit environment.
21404 The following basic built-in functions, which are also supported on
21405 x86 targets, require @option{-mfloat128}.
21406 @smallexample
21407 __float128 __builtin_fabsq (__float128);
21408 __float128 __builtin_copysignq (__float128, __float128);
21409 __float128 __builtin_infq (void);
21410 __float128 __builtin_huge_valq (void);
21411 __float128 __builtin_nanq (void);
21412 __float128 __builtin_nansq (void);
21414 __float128 __builtin_sqrtf128 (__float128);
21415 __float128 __builtin_fmaf128 (__float128, __float128, __float128);
21416 @end smallexample
21418 @node Basic PowerPC Built-in Functions Available on ISA 2.07
21419 @subsubsection Basic PowerPC Built-in Functions Available on ISA 2.07
21421 The basic built-in functions described in this section are
21422 available on the PowerPC family of processors starting with ISA 2.07
21423 or later.  Unless specific options are explicitly disabled on the
21424 command line, specifying option @option{-mcpu=power8} has the effect of
21425 enabling all the same options as for @option{-mcpu=power7} in
21426 addition to the @option{-mpower8-fusion}, @option{-mcrypto},
21427 @option{-mhtm}, @option{-mquad-memory}, and
21428 @option{-mquad-memory-atomic} options.
21430 This section intentionally empty.
21432 @node Basic PowerPC Built-in Functions Available on ISA 3.0
21433 @subsubsection Basic PowerPC Built-in Functions Available on ISA 3.0
21435 The basic built-in functions described in this section are
21436 available on the PowerPC family of processors starting with ISA 3.0
21437 or later.  Unless specific options are explicitly disabled on the
21438 command line, specifying option @option{-mcpu=power9} has the effect of
21439 enabling all the same options as for @option{-mcpu=power8} in
21440 addition to the @option{-misel} option.
21442 The following built-in functions are available on Linux 64-bit systems
21443 that use the ISA 3.0 instruction set (@option{-mcpu=power9}):
21445 @defbuiltin{__float128 __builtin_addf128_round_to_odd (__float128, __float128)}
21446 Perform a 128-bit IEEE floating point add using round to odd as the
21447 rounding mode.
21448 @enddefbuiltin
21450 @defbuiltin{__float128 __builtin_subf128_round_to_odd (__float128, __float128)}
21451 Perform a 128-bit IEEE floating point subtract using round to odd as
21452 the rounding mode.
21453 @enddefbuiltin
21455 @defbuiltin{__float128 __builtin_mulf128_round_to_odd (__float128, __float128)}
21456 Perform a 128-bit IEEE floating point multiply using round to odd as
21457 the rounding mode.
21458 @enddefbuiltin
21460 @defbuiltin{__float128 __builtin_divf128_round_to_odd (__float128, __float128)}
21461 Perform a 128-bit IEEE floating point divide using round to odd as
21462 the rounding mode.
21463 @enddefbuiltin
21465 @defbuiltin{__float128 __builtin_sqrtf128_round_to_odd (__float128)}
21466 Perform a 128-bit IEEE floating point square root using round to odd
21467 as the rounding mode.
21468 @enddefbuiltin
21470 @defbuiltin{__float128 __builtin_fmaf128_round_to_odd (__float128, __float128, __float128)}
21471 Perform a 128-bit IEEE floating point fused multiply and add operation
21472 using round to odd as the rounding mode.
21473 @enddefbuiltin
21475 @defbuiltin{double __builtin_truncf128_round_to_odd (__float128)}
21476 Convert a 128-bit IEEE floating point value to @code{double} using
21477 round to odd as the rounding mode.
21478 @enddefbuiltin
21481 The following additional built-in functions are also available for the
21482 PowerPC family of processors, starting with ISA 3.0 or later:
21484 @defbuiltin{{long long} __builtin_darn (void)}
21485 @defbuiltinx{{long long} __builtin_darn_raw (void)}
21486 @defbuiltinx{int __builtin_darn_32 (void)}
21487 The @code{__builtin_darn} and @code{__builtin_darn_raw}
21488 functions require a
21489 64-bit environment supporting ISA 3.0 or later.
21490 The @code{__builtin_darn} function provides a 64-bit conditioned
21491 random number.  The @code{__builtin_darn_raw} function provides a
21492 64-bit raw random number.  The @code{__builtin_darn_32} function
21493 provides a 32-bit conditioned random number.
21494 @enddefbuiltin
21496 The following additional built-in functions are also available for the
21497 PowerPC family of processors, starting with ISA 3.0 or later:
21499 @smallexample
21500 int __builtin_byte_in_set (unsigned char u, unsigned long long set);
21501 int __builtin_byte_in_range (unsigned char u, unsigned int range);
21502 int __builtin_byte_in_either_range (unsigned char u, unsigned int ranges);
21504 int __builtin_dfp_dtstsfi_lt (unsigned int comparison, _Decimal64 value);
21505 int __builtin_dfp_dtstsfi_lt (unsigned int comparison, _Decimal128 value);
21506 int __builtin_dfp_dtstsfi_lt_dd (unsigned int comparison, _Decimal64 value);
21507 int __builtin_dfp_dtstsfi_lt_td (unsigned int comparison, _Decimal128 value);
21509 int __builtin_dfp_dtstsfi_gt (unsigned int comparison, _Decimal64 value);
21510 int __builtin_dfp_dtstsfi_gt (unsigned int comparison, _Decimal128 value);
21511 int __builtin_dfp_dtstsfi_gt_dd (unsigned int comparison, _Decimal64 value);
21512 int __builtin_dfp_dtstsfi_gt_td (unsigned int comparison, _Decimal128 value);
21514 int __builtin_dfp_dtstsfi_eq (unsigned int comparison, _Decimal64 value);
21515 int __builtin_dfp_dtstsfi_eq (unsigned int comparison, _Decimal128 value);
21516 int __builtin_dfp_dtstsfi_eq_dd (unsigned int comparison, _Decimal64 value);
21517 int __builtin_dfp_dtstsfi_eq_td (unsigned int comparison, _Decimal128 value);
21519 int __builtin_dfp_dtstsfi_ov (unsigned int comparison, _Decimal64 value);
21520 int __builtin_dfp_dtstsfi_ov (unsigned int comparison, _Decimal128 value);
21521 int __builtin_dfp_dtstsfi_ov_dd (unsigned int comparison, _Decimal64 value);
21522 int __builtin_dfp_dtstsfi_ov_td (unsigned int comparison, _Decimal128 value);
21524 double __builtin_mffsl(void);
21526 @end smallexample
21527 The @code{__builtin_byte_in_set} function requires a
21528 64-bit environment supporting ISA 3.0 or later.  This function returns
21529 a non-zero value if and only if its @code{u} argument exactly equals one of
21530 the eight bytes contained within its 64-bit @code{set} argument.
21532 The @code{__builtin_byte_in_range} and
21533 @code{__builtin_byte_in_either_range} require an environment
21534 supporting ISA 3.0 or later.  For these two functions, the
21535 @code{range} argument is encoded as 4 bytes, organized as
21536 @code{hi_1:lo_1:hi_2:lo_2}.
21537 The @code{__builtin_byte_in_range} function returns a
21538 non-zero value if and only if its @code{u} argument is within the
21539 range bounded between @code{lo_2} and @code{hi_2} inclusive.
21540 The @code{__builtin_byte_in_either_range} function returns non-zero if
21541 and only if its @code{u} argument is within either the range bounded
21542 between @code{lo_1} and @code{hi_1} inclusive or the range bounded
21543 between @code{lo_2} and @code{hi_2} inclusive.
21545 The @code{__builtin_dfp_dtstsfi_lt} function returns a non-zero value
21546 if and only if the number of signficant digits of its @code{value} argument
21547 is less than its @code{comparison} argument.  The
21548 @code{__builtin_dfp_dtstsfi_lt_dd} and
21549 @code{__builtin_dfp_dtstsfi_lt_td} functions behave similarly, but
21550 require that the type of the @code{value} argument be
21551 @code{__Decimal64} and @code{__Decimal128} respectively.
21553 The @code{__builtin_dfp_dtstsfi_gt} function returns a non-zero value
21554 if and only if the number of signficant digits of its @code{value} argument
21555 is greater than its @code{comparison} argument.  The
21556 @code{__builtin_dfp_dtstsfi_gt_dd} and
21557 @code{__builtin_dfp_dtstsfi_gt_td} functions behave similarly, but
21558 require that the type of the @code{value} argument be
21559 @code{__Decimal64} and @code{__Decimal128} respectively.
21561 The @code{__builtin_dfp_dtstsfi_eq} function returns a non-zero value
21562 if and only if the number of signficant digits of its @code{value} argument
21563 equals its @code{comparison} argument.  The
21564 @code{__builtin_dfp_dtstsfi_eq_dd} and
21565 @code{__builtin_dfp_dtstsfi_eq_td} functions behave similarly, but
21566 require that the type of the @code{value} argument be
21567 @code{__Decimal64} and @code{__Decimal128} respectively.
21569 The @code{__builtin_dfp_dtstsfi_ov} function returns a non-zero value
21570 if and only if its @code{value} argument has an undefined number of
21571 significant digits, such as when @code{value} is an encoding of @code{NaN}.
21572 The @code{__builtin_dfp_dtstsfi_ov_dd} and
21573 @code{__builtin_dfp_dtstsfi_ov_td} functions behave similarly, but
21574 require that the type of the @code{value} argument be
21575 @code{__Decimal64} and @code{__Decimal128} respectively.
21577 The @code{__builtin_mffsl} uses the ISA 3.0 @code{mffsl} instruction to read
21578 the FPSCR.  The instruction is a lower latency version of the @code{mffs}
21579 instruction.  If the @code{mffsl} instruction is not available, then the
21580 builtin uses the older @code{mffs} instruction to read the FPSCR.
21582 @node Basic PowerPC Built-in Functions Available on ISA 3.1
21583 @subsubsection Basic PowerPC Built-in Functions Available on ISA 3.1
21585 The basic built-in functions described in this section are
21586 available on the PowerPC family of processors starting with ISA 3.1.
21587 Unless specific options are explicitly disabled on the
21588 command line, specifying option @option{-mcpu=power10} has the effect of
21589 enabling all the same options as for @option{-mcpu=power9}.
21591 The following built-in functions are available on Linux 64-bit systems
21592 that use a future architecture instruction set (@option{-mcpu=power10}):
21594 @defbuiltin{{unsigned long long} @
21595             __builtin_cfuged (unsigned long long, unsigned long long)}
21596 Perform a 64-bit centrifuge operation, as if implemented by the
21597 @code{cfuged} instruction.
21598 @enddefbuiltin
21600 @defbuiltin{{unsigned long long} @
21601             __builtin_cntlzdm (unsigned long long, unsigned long long)}
21602 Perform a 64-bit count leading zeros operation under mask, as if
21603 implemented by the @code{cntlzdm} instruction.
21604 @enddefbuiltin
21606 @defbuiltin{{unsigned long long} @
21607             __builtin_cnttzdm (unsigned long long, unsigned long long)}
21608 Perform a 64-bit count trailing zeros operation under mask, as if
21609 implemented by the @code{cnttzdm} instruction.
21610 @enddefbuiltin
21612 @defbuiltin{{unsigned long long} @
21613             __builtin_pdepd (unsigned long long, unsigned long long)}
21614 Perform a 64-bit parallel bits deposit operation, as if implemented by the
21615 @code{pdepd} instruction.
21616 @enddefbuiltin
21618 @defbuiltin{{unsigned long long} @
21619             __builtin_pextd (unsigned long long, unsigned long long)}
21620 Perform a 64-bit parallel bits extract operation, as if implemented by the
21621 @code{pextd} instruction.
21622 @enddefbuiltin
21624 @defbuiltin{{vector signed __int128} vsx_xl_sext (signed long long, signed char *)}
21625 @defbuiltinx{{vector signed __int128} vsx_xl_sext (signed long long, signed short *)}
21626 @defbuiltinx{{vector signed __int128} vsx_xl_sext (signed long long, signed int *)}
21627 @defbuiltinx{{vector signed __int128} vsx_xl_sext (signed long long, signed long long *)}
21628 @defbuiltinx{{vector unsigned __int128} vsx_xl_zext (signed long long, unsigned char *)}
21629 @defbuiltinx{{vector unsigned __int128} vsx_xl_zext (signed long long, unsigned short *)}
21630 @defbuiltinx{{vector unsigned __int128} vsx_xl_zext (signed long long, unsigned int *)}
21631 @defbuiltinx{{vector unsigned __int128} vsx_xl_zext (signed long long, unsigned long long *)}
21633 Load (and sign extend) to an __int128 vector, as if implemented by the ISA 3.1
21634 @code{lxvrbx}, @code{lxvrhx}, @code{lxvrwx}, and  @code{lxvrdx}
21635 instructions.
21636 @enddefbuiltin
21638 @defbuiltin{{void} vec_xst_trunc (vector signed __int128, signed long long, signed char *)}
21639 @defbuiltinx{{void} vec_xst_trunc (vector signed __int128, signed long long, signed short *)}
21640 @defbuiltinx{{void} vec_xst_trunc (vector signed __int128, signed long long, signed int *)}
21641 @defbuiltinx{{void} vec_xst_trunc (vector signed __int128, signed long long, signed long long *)}
21642 @defbuiltinx{{void} vec_xst_trunc (vector unsigned __int128, signed long long, unsigned char *)}
21643 @defbuiltinx{{void} vec_xst_trunc (vector unsigned __int128, signed long long, unsigned short *)}
21644 @defbuiltinx{{void} vec_xst_trunc (vector unsigned __int128, signed long long, unsigned int *)}
21645 @defbuiltinx{{void} vec_xst_trunc (vector unsigned __int128, signed long long, unsigned long long *)}
21647 Truncate and store the rightmost element of a vector, as if implemented by the
21648 ISA 3.1 @code{stxvrbx}, @code{stxvrhx}, @code{stxvrwx}, and @code{stxvrdx}
21649 instructions.
21650 @enddefbuiltin
21652 @node PowerPC AltiVec/VSX Built-in Functions
21653 @subsection PowerPC AltiVec/VSX Built-in Functions
21655 GCC provides an interface for the PowerPC family of processors to access
21656 the AltiVec operations described in Motorola's AltiVec Programming
21657 Interface Manual.  The interface is made available by including
21658 @code{<altivec.h>} and using @option{-maltivec} and
21659 @option{-mabi=altivec}.  The interface supports the following vector
21660 types.
21662 @smallexample
21663 vector unsigned char
21664 vector signed char
21665 vector bool char
21667 vector unsigned short
21668 vector signed short
21669 vector bool short
21670 vector pixel
21672 vector unsigned int
21673 vector signed int
21674 vector bool int
21675 vector float
21676 @end smallexample
21678 GCC's implementation of the high-level language interface available from
21679 C and C++ code differs from Motorola's documentation in several ways.
21681 @itemize @bullet
21683 @item
21684 A vector constant is a list of constant expressions within curly braces.
21686 @item
21687 A vector initializer requires no cast if the vector constant is of the
21688 same type as the variable it is initializing.
21690 @item
21691 If @code{signed} or @code{unsigned} is omitted, the signedness of the
21692 vector type is the default signedness of the base type.  The default
21693 varies depending on the operating system, so a portable program should
21694 always specify the signedness.
21696 @item
21697 Compiling with @option{-maltivec} adds keywords @code{__vector},
21698 @code{vector}, @code{__pixel}, @code{pixel}, @code{__bool} and
21699 @code{bool}.  When compiling ISO C, the context-sensitive substitution
21700 of the keywords @code{vector}, @code{pixel} and @code{bool} is
21701 disabled.  To use them, you must include @code{<altivec.h>} instead.
21703 @item
21704 GCC allows using a @code{typedef} name as the type specifier for a
21705 vector type, but only under the following circumstances:
21707 @itemize @bullet
21709 @item
21710 When using @code{__vector} instead of @code{vector}; for example,
21712 @smallexample
21713 typedef signed short int16;
21714 __vector int16 data;
21715 @end smallexample
21717 @item
21718 When using @code{vector} in keyword-and-predefine mode; for example,
21720 @smallexample
21721 typedef signed short int16;
21722 vector int16 data;
21723 @end smallexample
21725 Note that keyword-and-predefine mode is enabled by disabling GNU
21726 extensions (e.g., by using @code{-std=c11}) and including
21727 @code{<altivec.h>}.
21728 @end itemize
21730 @item
21731 For C, overloaded functions are implemented with macros so the following
21732 does not work:
21734 @smallexample
21735   vec_add ((vector signed int)@{1, 2, 3, 4@}, foo);
21736 @end smallexample
21738 @noindent
21739 Since @code{vec_add} is a macro, the vector constant in the example
21740 is treated as four separate arguments.  Wrap the entire argument in
21741 parentheses for this to work.
21742 @end itemize
21744 @emph{Note:} Only the @code{<altivec.h>} interface is supported.
21745 Internally, GCC uses built-in functions to achieve the functionality in
21746 the aforementioned header file, but they are not supported and are
21747 subject to change without notice.
21749 GCC complies with the Power Vector Intrinsic Programming Reference (PVIPR),
21750 which may be found at
21751 @uref{https://openpowerfoundation.org/?resource_lib=power-vector-intrinsic-programming-reference}.
21752 Chapter 4 of this document fully documents the vector API interfaces
21753 that must be
21754 provided by compliant compilers.  Programmers should preferentially use
21755 the interfaces described therein.  However, historically GCC has provided
21756 additional interfaces for access to vector instructions.  These are
21757 briefly described below.  Where the PVIPR provides a portable interface,
21758 other functions in GCC that provide the same capabilities should be
21759 considered deprecated.
21761 The PVIPR documents the following overloaded functions:
21763 @multitable @columnfractions 0.33 0.33 0.33
21765 @item @code{vec_abs}
21766 @tab @code{vec_absd}
21767 @tab @code{vec_abss}
21768 @item @code{vec_add}
21769 @tab @code{vec_addc}
21770 @tab @code{vec_adde}
21771 @item @code{vec_addec}
21772 @tab @code{vec_adds}
21773 @tab @code{vec_all_eq}
21774 @item @code{vec_all_ge}
21775 @tab @code{vec_all_gt}
21776 @tab @code{vec_all_in}
21777 @item @code{vec_all_le}
21778 @tab @code{vec_all_lt}
21779 @tab @code{vec_all_nan}
21780 @item @code{vec_all_ne}
21781 @tab @code{vec_all_nge}
21782 @tab @code{vec_all_ngt}
21783 @item @code{vec_all_nle}
21784 @tab @code{vec_all_nlt}
21785 @tab @code{vec_all_numeric}
21786 @item @code{vec_and}
21787 @tab @code{vec_andc}
21788 @tab @code{vec_any_eq}
21789 @item @code{vec_any_ge}
21790 @tab @code{vec_any_gt}
21791 @tab @code{vec_any_le}
21792 @item @code{vec_any_lt}
21793 @tab @code{vec_any_nan}
21794 @tab @code{vec_any_ne}
21795 @item @code{vec_any_nge}
21796 @tab @code{vec_any_ngt}
21797 @tab @code{vec_any_nle}
21798 @item @code{vec_any_nlt}
21799 @tab @code{vec_any_numeric}
21800 @tab @code{vec_any_out}
21801 @item @code{vec_avg}
21802 @tab @code{vec_bperm}
21803 @tab @code{vec_ceil}
21804 @item @code{vec_cipher_be}
21805 @tab @code{vec_cipherlast_be}
21806 @tab @code{vec_cmpb}
21807 @item @code{vec_cmpeq}
21808 @tab @code{vec_cmpge}
21809 @tab @code{vec_cmpgt}
21810 @item @code{vec_cmple}
21811 @tab @code{vec_cmplt}
21812 @tab @code{vec_cmpne}
21813 @item @code{vec_cmpnez}
21814 @tab @code{vec_cntlz}
21815 @tab @code{vec_cntlz_lsbb}
21816 @item @code{vec_cnttz}
21817 @tab @code{vec_cnttz_lsbb}
21818 @tab @code{vec_cpsgn}
21819 @item @code{vec_ctf}
21820 @tab @code{vec_cts}
21821 @tab @code{vec_ctu}
21822 @item @code{vec_div}
21823 @tab @code{vec_double}
21824 @tab @code{vec_doublee}
21825 @item @code{vec_doubleh}
21826 @tab @code{vec_doublel}
21827 @tab @code{vec_doubleo}
21828 @item @code{vec_eqv}
21829 @tab @code{vec_expte}
21830 @tab @code{vec_extract}
21831 @item @code{vec_extract_exp}
21832 @tab @code{vec_extract_fp32_from_shorth}
21833 @tab @code{vec_extract_fp32_from_shortl}
21834 @item @code{vec_extract_sig}
21835 @tab @code{vec_extract_4b}
21836 @tab @code{vec_first_match_index}
21837 @item @code{vec_first_match_or_eos_index}
21838 @tab @code{vec_first_mismatch_index}
21839 @tab @code{vec_first_mismatch_or_eos_index}
21840 @item @code{vec_float}
21841 @tab @code{vec_float2}
21842 @tab @code{vec_floate}
21843 @item @code{vec_floato}
21844 @tab @code{vec_floor}
21845 @tab @code{vec_gb}
21846 @item @code{vec_insert}
21847 @tab @code{vec_insert_exp}
21848 @tab @code{vec_insert4b}
21849 @item @code{vec_ld}
21850 @tab @code{vec_lde}
21851 @tab @code{vec_ldl}
21852 @item @code{vec_loge}
21853 @tab @code{vec_madd}
21854 @tab @code{vec_madds}
21855 @item @code{vec_max}
21856 @tab @code{vec_mergee}
21857 @tab @code{vec_mergeh}
21858 @item @code{vec_mergel}
21859 @tab @code{vec_mergeo}
21860 @tab @code{vec_mfvscr}
21861 @item @code{vec_min}
21862 @tab @code{vec_mradds}
21863 @tab @code{vec_msub}
21864 @item @code{vec_msum}
21865 @tab @code{vec_msums}
21866 @tab @code{vec_mtvscr}
21867 @item @code{vec_mul}
21868 @tab @code{vec_mule}
21869 @tab @code{vec_mulo}
21870 @item @code{vec_nabs}
21871 @tab @code{vec_nand}
21872 @tab @code{vec_ncipher_be}
21873 @item @code{vec_ncipherlast_be}
21874 @tab @code{vec_nearbyint}
21875 @tab @code{vec_neg}
21876 @item @code{vec_nmadd}
21877 @tab @code{vec_nmsub}
21878 @tab @code{vec_nor}
21879 @item @code{vec_or}
21880 @tab @code{vec_orc}
21881 @tab @code{vec_pack}
21882 @item @code{vec_pack_to_short_fp32}
21883 @tab @code{vec_packpx}
21884 @tab @code{vec_packs}
21885 @item @code{vec_packsu}
21886 @tab @code{vec_parity_lsbb}
21887 @tab @code{vec_perm}
21888 @item @code{vec_permxor}
21889 @tab @code{vec_pmsum_be}
21890 @tab @code{vec_popcnt}
21891 @item @code{vec_re}
21892 @tab @code{vec_recipdiv}
21893 @tab @code{vec_revb}
21894 @item @code{vec_reve}
21895 @tab @code{vec_rint}
21896 @tab @code{vec_rl}
21897 @item @code{vec_rlmi}
21898 @tab @code{vec_rlnm}
21899 @tab @code{vec_round}
21900 @item @code{vec_rsqrt}
21901 @tab @code{vec_rsqrte}
21902 @tab @code{vec_sbox_be}
21903 @item @code{vec_sel}
21904 @tab @code{vec_shasigma_be}
21905 @tab @code{vec_signed}
21906 @item @code{vec_signed2}
21907 @tab @code{vec_signede}
21908 @tab @code{vec_signedo}
21909 @item @code{vec_sl}
21910 @tab @code{vec_sld}
21911 @tab @code{vec_sldw}
21912 @item @code{vec_sll}
21913 @tab @code{vec_slo}
21914 @tab @code{vec_slv}
21915 @item @code{vec_splat}
21916 @tab @code{vec_splat_s8}
21917 @tab @code{vec_splat_s16}
21918 @item @code{vec_splat_s32}
21919 @tab @code{vec_splat_u8}
21920 @tab @code{vec_splat_u16}
21921 @item @code{vec_splat_u32}
21922 @tab @code{vec_splats}
21923 @tab @code{vec_sqrt}
21924 @item @code{vec_sr}
21925 @tab @code{vec_sra}
21926 @tab @code{vec_srl}
21927 @item @code{vec_sro}
21928 @tab @code{vec_srv}
21929 @tab @code{vec_st}
21930 @item @code{vec_ste}
21931 @tab @code{vec_stl}
21932 @tab @code{vec_sub}
21933 @item @code{vec_subc}
21934 @tab @code{vec_sube}
21935 @tab @code{vec_subec}
21936 @item @code{vec_subs}
21937 @tab @code{vec_sum2s}
21938 @tab @code{vec_sum4s}
21939 @item @code{vec_sums}
21940 @tab @code{vec_test_data_class}
21941 @tab @code{vec_trunc}
21942 @item @code{vec_unpackh}
21943 @tab @code{vec_unpackl}
21944 @tab @code{vec_unsigned}
21945 @item @code{vec_unsigned2}
21946 @tab @code{vec_unsignede}
21947 @tab @code{vec_unsignedo}
21948 @item @code{vec_xl}
21949 @tab @code{vec_xl_be}
21950 @tab @code{vec_xl_len}
21951 @item @code{vec_xl_len_r}
21952 @tab @code{vec_xor}
21953 @tab @code{vec_xst}
21954 @item @code{vec_xst_be}
21955 @tab @code{vec_xst_len}
21956 @tab @code{vec_xst_len_r}
21958 @end multitable
21960 @menu
21961 * PowerPC AltiVec Built-in Functions on ISA 2.05::
21962 * PowerPC AltiVec Built-in Functions Available on ISA 2.06::
21963 * PowerPC AltiVec Built-in Functions Available on ISA 2.07::
21964 * PowerPC AltiVec Built-in Functions Available on ISA 3.0::
21965 * PowerPC AltiVec Built-in Functions Available on ISA 3.1::
21966 @end menu
21968 @node PowerPC AltiVec Built-in Functions on ISA 2.05
21969 @subsubsection PowerPC AltiVec Built-in Functions on ISA 2.05
21971 The following interfaces are supported for the generic and specific
21972 AltiVec operations and the AltiVec predicates.  In cases where there
21973 is a direct mapping between generic and specific operations, only the
21974 generic names are shown here, although the specific operations can also
21975 be used.
21977 Arguments that are documented as @code{const int} require literal
21978 integral values within the range required for that operation.
21980 Only functions excluded from the PVIPR are listed here.
21982 @smallexample
21983 void vec_dss (const int);
21985 void vec_dssall (void);
21987 void vec_dst (const vector unsigned char *, int, const int);
21988 void vec_dst (const vector signed char *, int, const int);
21989 void vec_dst (const vector bool char *, int, const int);
21990 void vec_dst (const vector unsigned short *, int, const int);
21991 void vec_dst (const vector signed short *, int, const int);
21992 void vec_dst (const vector bool short *, int, const int);
21993 void vec_dst (const vector pixel *, int, const int);
21994 void vec_dst (const vector unsigned int *, int, const int);
21995 void vec_dst (const vector signed int *, int, const int);
21996 void vec_dst (const vector bool int *, int, const int);
21997 void vec_dst (const vector float *, int, const int);
21998 void vec_dst (const unsigned char *, int, const int);
21999 void vec_dst (const signed char *, int, const int);
22000 void vec_dst (const unsigned short *, int, const int);
22001 void vec_dst (const short *, int, const int);
22002 void vec_dst (const unsigned int *, int, const int);
22003 void vec_dst (const int *, int, const int);
22004 void vec_dst (const float *, int, const int);
22006 void vec_dstst (const vector unsigned char *, int, const int);
22007 void vec_dstst (const vector signed char *, int, const int);
22008 void vec_dstst (const vector bool char *, int, const int);
22009 void vec_dstst (const vector unsigned short *, int, const int);
22010 void vec_dstst (const vector signed short *, int, const int);
22011 void vec_dstst (const vector bool short *, int, const int);
22012 void vec_dstst (const vector pixel *, int, const int);
22013 void vec_dstst (const vector unsigned int *, int, const int);
22014 void vec_dstst (const vector signed int *, int, const int);
22015 void vec_dstst (const vector bool int *, int, const int);
22016 void vec_dstst (const vector float *, int, const int);
22017 void vec_dstst (const unsigned char *, int, const int);
22018 void vec_dstst (const signed char *, int, const int);
22019 void vec_dstst (const unsigned short *, int, const int);
22020 void vec_dstst (const short *, int, const int);
22021 void vec_dstst (const unsigned int *, int, const int);
22022 void vec_dstst (const int *, int, const int);
22023 void vec_dstst (const unsigned long *, int, const int);
22024 void vec_dstst (const long *, int, const int);
22025 void vec_dstst (const float *, int, const int);
22027 void vec_dststt (const vector unsigned char *, int, const int);
22028 void vec_dststt (const vector signed char *, int, const int);
22029 void vec_dststt (const vector bool char *, int, const int);
22030 void vec_dststt (const vector unsigned short *, int, const int);
22031 void vec_dststt (const vector signed short *, int, const int);
22032 void vec_dststt (const vector bool short *, int, const int);
22033 void vec_dststt (const vector pixel *, int, const int);
22034 void vec_dststt (const vector unsigned int *, int, const int);
22035 void vec_dststt (const vector signed int *, int, const int);
22036 void vec_dststt (const vector bool int *, int, const int);
22037 void vec_dststt (const vector float *, int, const int);
22038 void vec_dststt (const unsigned char *, int, const int);
22039 void vec_dststt (const signed char *, int, const int);
22040 void vec_dststt (const unsigned short *, int, const int);
22041 void vec_dststt (const short *, int, const int);
22042 void vec_dststt (const unsigned int *, int, const int);
22043 void vec_dststt (const int *, int, const int);
22044 void vec_dststt (const float *, int, const int);
22046 void vec_dstt (const vector unsigned char *, int, const int);
22047 void vec_dstt (const vector signed char *, int, const int);
22048 void vec_dstt (const vector bool char *, int, const int);
22049 void vec_dstt (const vector unsigned short *, int, const int);
22050 void vec_dstt (const vector signed short *, int, const int);
22051 void vec_dstt (const vector bool short *, int, const int);
22052 void vec_dstt (const vector pixel *, int, const int);
22053 void vec_dstt (const vector unsigned int *, int, const int);
22054 void vec_dstt (const vector signed int *, int, const int);
22055 void vec_dstt (const vector bool int *, int, const int);
22056 void vec_dstt (const vector float *, int, const int);
22057 void vec_dstt (const unsigned char *, int, const int);
22058 void vec_dstt (const signed char *, int, const int);
22059 void vec_dstt (const unsigned short *, int, const int);
22060 void vec_dstt (const short *, int, const int);
22061 void vec_dstt (const unsigned int *, int, const int);
22062 void vec_dstt (const int *, int, const int);
22063 void vec_dstt (const float *, int, const int);
22065 vector signed char vec_lvebx (int, char *);
22066 vector unsigned char vec_lvebx (int, unsigned char *);
22068 vector signed short vec_lvehx (int, short *);
22069 vector unsigned short vec_lvehx (int, unsigned short *);
22071 vector float vec_lvewx (int, float *);
22072 vector signed int vec_lvewx (int, int *);
22073 vector unsigned int vec_lvewx (int, unsigned int *);
22075 vector unsigned char vec_lvsl (int, const unsigned char *);
22076 vector unsigned char vec_lvsl (int, const signed char *);
22077 vector unsigned char vec_lvsl (int, const unsigned short *);
22078 vector unsigned char vec_lvsl (int, const short *);
22079 vector unsigned char vec_lvsl (int, const unsigned int *);
22080 vector unsigned char vec_lvsl (int, const int *);
22081 vector unsigned char vec_lvsl (int, const float *);
22083 vector unsigned char vec_lvsr (int, const unsigned char *);
22084 vector unsigned char vec_lvsr (int, const signed char *);
22085 vector unsigned char vec_lvsr (int, const unsigned short *);
22086 vector unsigned char vec_lvsr (int, const short *);
22087 vector unsigned char vec_lvsr (int, const unsigned int *);
22088 vector unsigned char vec_lvsr (int, const int *);
22089 vector unsigned char vec_lvsr (int, const float *);
22091 void vec_stvebx (vector signed char, int, signed char *);
22092 void vec_stvebx (vector unsigned char, int, unsigned char *);
22093 void vec_stvebx (vector bool char, int, signed char *);
22094 void vec_stvebx (vector bool char, int, unsigned char *);
22096 void vec_stvehx (vector signed short, int, short *);
22097 void vec_stvehx (vector unsigned short, int, unsigned short *);
22098 void vec_stvehx (vector bool short, int, short *);
22099 void vec_stvehx (vector bool short, int, unsigned short *);
22101 void vec_stvewx (vector float, int, float *);
22102 void vec_stvewx (vector signed int, int, int *);
22103 void vec_stvewx (vector unsigned int, int, unsigned int *);
22104 void vec_stvewx (vector bool int, int, int *);
22105 void vec_stvewx (vector bool int, int, unsigned int *);
22107 vector float vec_vaddfp (vector float, vector float);
22109 vector signed char vec_vaddsbs (vector bool char, vector signed char);
22110 vector signed char vec_vaddsbs (vector signed char, vector bool char);
22111 vector signed char vec_vaddsbs (vector signed char, vector signed char);
22113 vector signed short vec_vaddshs (vector bool short, vector signed short);
22114 vector signed short vec_vaddshs (vector signed short, vector bool short);
22115 vector signed short vec_vaddshs (vector signed short, vector signed short);
22117 vector signed int vec_vaddsws (vector bool int, vector signed int);
22118 vector signed int vec_vaddsws (vector signed int, vector bool int);
22119 vector signed int vec_vaddsws (vector signed int, vector signed int);
22121 vector signed char vec_vaddubm (vector bool char, vector signed char);
22122 vector signed char vec_vaddubm (vector signed char, vector bool char);
22123 vector signed char vec_vaddubm (vector signed char, vector signed char);
22124 vector unsigned char vec_vaddubm (vector bool char, vector unsigned char);
22125 vector unsigned char vec_vaddubm (vector unsigned char, vector bool char);
22126 vector unsigned char vec_vaddubm (vector unsigned char, vector unsigned char);
22128 vector unsigned char vec_vaddubs (vector bool char, vector unsigned char);
22129 vector unsigned char vec_vaddubs (vector unsigned char, vector bool char);
22130 vector unsigned char vec_vaddubs (vector unsigned char, vector unsigned char);
22132 vector signed short vec_vadduhm (vector bool short, vector signed short);
22133 vector signed short vec_vadduhm (vector signed short, vector bool short);
22134 vector signed short vec_vadduhm (vector signed short, vector signed short);
22135 vector unsigned short vec_vadduhm (vector bool short, vector unsigned short);
22136 vector unsigned short vec_vadduhm (vector unsigned short, vector bool short);
22137 vector unsigned short vec_vadduhm (vector unsigned short, vector unsigned short);
22139 vector unsigned short vec_vadduhs (vector bool short, vector unsigned short);
22140 vector unsigned short vec_vadduhs (vector unsigned short, vector bool short);
22141 vector unsigned short vec_vadduhs (vector unsigned short, vector unsigned short);
22143 vector signed int vec_vadduwm (vector bool int, vector signed int);
22144 vector signed int vec_vadduwm (vector signed int, vector bool int);
22145 vector signed int vec_vadduwm (vector signed int, vector signed int);
22146 vector unsigned int vec_vadduwm (vector bool int, vector unsigned int);
22147 vector unsigned int vec_vadduwm (vector unsigned int, vector bool int);
22148 vector unsigned int vec_vadduwm (vector unsigned int, vector unsigned int);
22150 vector unsigned int vec_vadduws (vector bool int, vector unsigned int);
22151 vector unsigned int vec_vadduws (vector unsigned int, vector bool int);
22152 vector unsigned int vec_vadduws (vector unsigned int, vector unsigned int);
22154 vector signed char vec_vavgsb (vector signed char, vector signed char);
22156 vector signed short vec_vavgsh (vector signed short, vector signed short);
22158 vector signed int vec_vavgsw (vector signed int, vector signed int);
22160 vector unsigned char vec_vavgub (vector unsigned char, vector unsigned char);
22162 vector unsigned short vec_vavguh (vector unsigned short, vector unsigned short);
22164 vector unsigned int vec_vavguw (vector unsigned int, vector unsigned int);
22166 vector float vec_vcfsx (vector signed int, const int);
22168 vector float vec_vcfux (vector unsigned int, const int);
22170 vector bool int vec_vcmpeqfp (vector float, vector float);
22172 vector bool char vec_vcmpequb (vector signed char, vector signed char);
22173 vector bool char vec_vcmpequb (vector unsigned char, vector unsigned char);
22175 vector bool short vec_vcmpequh (vector signed short, vector signed short);
22176 vector bool short vec_vcmpequh (vector unsigned short, vector unsigned short);
22178 vector bool int vec_vcmpequw (vector signed int, vector signed int);
22179 vector bool int vec_vcmpequw (vector unsigned int, vector unsigned int);
22181 vector bool int vec_vcmpgtfp (vector float, vector float);
22183 vector bool char vec_vcmpgtsb (vector signed char, vector signed char);
22185 vector bool short vec_vcmpgtsh (vector signed short, vector signed short);
22187 vector bool int vec_vcmpgtsw (vector signed int, vector signed int);
22189 vector bool char vec_vcmpgtub (vector unsigned char, vector unsigned char);
22191 vector bool short vec_vcmpgtuh (vector unsigned short, vector unsigned short);
22193 vector bool int vec_vcmpgtuw (vector unsigned int, vector unsigned int);
22195 vector float vec_vmaxfp (vector float, vector float);
22197 vector signed char vec_vmaxsb (vector bool char, vector signed char);
22198 vector signed char vec_vmaxsb (vector signed char, vector bool char);
22199 vector signed char vec_vmaxsb (vector signed char, vector signed char);
22201 vector signed short vec_vmaxsh (vector bool short, vector signed short);
22202 vector signed short vec_vmaxsh (vector signed short, vector bool short);
22203 vector signed short vec_vmaxsh (vector signed short, vector signed short);
22205 vector signed int vec_vmaxsw (vector bool int, vector signed int);
22206 vector signed int vec_vmaxsw (vector signed int, vector bool int);
22207 vector signed int vec_vmaxsw (vector signed int, vector signed int);
22209 vector unsigned char vec_vmaxub (vector bool char, vector unsigned char);
22210 vector unsigned char vec_vmaxub (vector unsigned char, vector bool char);
22211 vector unsigned char vec_vmaxub (vector unsigned char, vector unsigned char);
22213 vector unsigned short vec_vmaxuh (vector bool short, vector unsigned short);
22214 vector unsigned short vec_vmaxuh (vector unsigned short, vector bool short);
22215 vector unsigned short vec_vmaxuh (vector unsigned short, vector unsigned short);
22217 vector unsigned int vec_vmaxuw (vector bool int, vector unsigned int);
22218 vector unsigned int vec_vmaxuw (vector unsigned int, vector bool int);
22219 vector unsigned int vec_vmaxuw (vector unsigned int, vector unsigned int);
22221 vector float vec_vminfp (vector float, vector float);
22223 vector signed char vec_vminsb (vector bool char, vector signed char);
22224 vector signed char vec_vminsb (vector signed char, vector bool char);
22225 vector signed char vec_vminsb (vector signed char, vector signed char);
22227 vector signed short vec_vminsh (vector bool short, vector signed short);
22228 vector signed short vec_vminsh (vector signed short, vector bool short);
22229 vector signed short vec_vminsh (vector signed short, vector signed short);
22231 vector signed int vec_vminsw (vector bool int, vector signed int);
22232 vector signed int vec_vminsw (vector signed int, vector bool int);
22233 vector signed int vec_vminsw (vector signed int, vector signed int);
22235 vector unsigned char vec_vminub (vector bool char, vector unsigned char);
22236 vector unsigned char vec_vminub (vector unsigned char, vector bool char);
22237 vector unsigned char vec_vminub (vector unsigned char, vector unsigned char);
22239 vector unsigned short vec_vminuh (vector bool short, vector unsigned short);
22240 vector unsigned short vec_vminuh (vector unsigned short, vector bool short);
22241 vector unsigned short vec_vminuh (vector unsigned short, vector unsigned short);
22243 vector unsigned int vec_vminuw (vector bool int, vector unsigned int);
22244 vector unsigned int vec_vminuw (vector unsigned int, vector bool int);
22245 vector unsigned int vec_vminuw (vector unsigned int, vector unsigned int);
22247 vector bool char vec_vmrghb (vector bool char, vector bool char);
22248 vector signed char vec_vmrghb (vector signed char, vector signed char);
22249 vector unsigned char vec_vmrghb (vector unsigned char, vector unsigned char);
22251 vector bool short vec_vmrghh (vector bool short, vector bool short);
22252 vector signed short vec_vmrghh (vector signed short, vector signed short);
22253 vector unsigned short vec_vmrghh (vector unsigned short, vector unsigned short);
22254 vector pixel vec_vmrghh (vector pixel, vector pixel);
22256 vector float vec_vmrghw (vector float, vector float);
22257 vector bool int vec_vmrghw (vector bool int, vector bool int);
22258 vector signed int vec_vmrghw (vector signed int, vector signed int);
22259 vector unsigned int vec_vmrghw (vector unsigned int, vector unsigned int);
22261 vector bool char vec_vmrglb (vector bool char, vector bool char);
22262 vector signed char vec_vmrglb (vector signed char, vector signed char);
22263 vector unsigned char vec_vmrglb (vector unsigned char, vector unsigned char);
22265 vector bool short vec_vmrglh (vector bool short, vector bool short);
22266 vector signed short vec_vmrglh (vector signed short, vector signed short);
22267 vector unsigned short vec_vmrglh (vector unsigned short, vector unsigned short);
22268 vector pixel vec_vmrglh (vector pixel, vector pixel);
22270 vector float vec_vmrglw (vector float, vector float);
22271 vector signed int vec_vmrglw (vector signed int, vector signed int);
22272 vector unsigned int vec_vmrglw (vector unsigned int, vector unsigned int);
22273 vector bool int vec_vmrglw (vector bool int, vector bool int);
22275 vector signed int vec_vmsummbm (vector signed char, vector unsigned char,
22276                                 vector signed int);
22278 vector signed int vec_vmsumshm (vector signed short, vector signed short,
22279                                 vector signed int);
22281 vector signed int vec_vmsumshs (vector signed short, vector signed short,
22282                                 vector signed int);
22284 vector unsigned int vec_vmsumubm (vector unsigned char, vector unsigned char,
22285                                   vector unsigned int);
22287 vector unsigned int vec_vmsumuhm (vector unsigned short, vector unsigned short,
22288                                   vector unsigned int);
22290 vector unsigned int vec_vmsumuhs (vector unsigned short, vector unsigned short,
22291                                   vector unsigned int);
22293 vector signed short vec_vmulesb (vector signed char, vector signed char);
22295 vector signed int vec_vmulesh (vector signed short, vector signed short);
22297 vector unsigned short vec_vmuleub (vector unsigned char, vector unsigned char);
22299 vector unsigned int vec_vmuleuh (vector unsigned short, vector unsigned short);
22301 vector signed short vec_vmulosb (vector signed char, vector signed char);
22303 vector signed int vec_vmulosh (vector signed short, vector signed short);
22305 vector unsigned short vec_vmuloub (vector unsigned char, vector unsigned char);
22307 vector unsigned int vec_vmulouh (vector unsigned short, vector unsigned short);
22309 vector signed char vec_vpkshss (vector signed short, vector signed short);
22311 vector unsigned char vec_vpkshus (vector signed short, vector signed short);
22313 vector signed short vec_vpkswss (vector signed int, vector signed int);
22315 vector unsigned short vec_vpkswus (vector signed int, vector signed int);
22317 vector bool char vec_vpkuhum (vector bool short, vector bool short);
22318 vector signed char vec_vpkuhum (vector signed short, vector signed short);
22319 vector unsigned char vec_vpkuhum (vector unsigned short, vector unsigned short);
22321 vector unsigned char vec_vpkuhus (vector unsigned short, vector unsigned short);
22323 vector bool short vec_vpkuwum (vector bool int, vector bool int);
22324 vector signed short vec_vpkuwum (vector signed int, vector signed int);
22325 vector unsigned short vec_vpkuwum (vector unsigned int, vector unsigned int);
22327 vector unsigned short vec_vpkuwus (vector unsigned int, vector unsigned int);
22329 vector signed char vec_vrlb (vector signed char, vector unsigned char);
22330 vector unsigned char vec_vrlb (vector unsigned char, vector unsigned char);
22332 vector signed short vec_vrlh (vector signed short, vector unsigned short);
22333 vector unsigned short vec_vrlh (vector unsigned short, vector unsigned short);
22335 vector signed int vec_vrlw (vector signed int, vector unsigned int);
22336 vector unsigned int vec_vrlw (vector unsigned int, vector unsigned int);
22338 vector signed char vec_vslb (vector signed char, vector unsigned char);
22339 vector unsigned char vec_vslb (vector unsigned char, vector unsigned char);
22341 vector signed short vec_vslh (vector signed short, vector unsigned short);
22342 vector unsigned short vec_vslh (vector unsigned short, vector unsigned short);
22344 vector signed int vec_vslw (vector signed int, vector unsigned int);
22345 vector unsigned int vec_vslw (vector unsigned int, vector unsigned int);
22347 vector signed char vec_vspltb (vector signed char, const int);
22348 vector unsigned char vec_vspltb (vector unsigned char, const int);
22349 vector bool char vec_vspltb (vector bool char, const int);
22351 vector bool short vec_vsplth (vector bool short, const int);
22352 vector signed short vec_vsplth (vector signed short, const int);
22353 vector unsigned short vec_vsplth (vector unsigned short, const int);
22354 vector pixel vec_vsplth (vector pixel, const int);
22356 vector float vec_vspltw (vector float, const int);
22357 vector signed int vec_vspltw (vector signed int, const int);
22358 vector unsigned int vec_vspltw (vector unsigned int, const int);
22359 vector bool int vec_vspltw (vector bool int, const int);
22361 vector signed char vec_vsrab (vector signed char, vector unsigned char);
22362 vector unsigned char vec_vsrab (vector unsigned char, vector unsigned char);
22364 vector signed short vec_vsrah (vector signed short, vector unsigned short);
22365 vector unsigned short vec_vsrah (vector unsigned short, vector unsigned short);
22367 vector signed int vec_vsraw (vector signed int, vector unsigned int);
22368 vector unsigned int vec_vsraw (vector unsigned int, vector unsigned int);
22370 vector signed char vec_vsrb (vector signed char, vector unsigned char);
22371 vector unsigned char vec_vsrb (vector unsigned char, vector unsigned char);
22373 vector signed short vec_vsrh (vector signed short, vector unsigned short);
22374 vector unsigned short vec_vsrh (vector unsigned short, vector unsigned short);
22376 vector signed int vec_vsrw (vector signed int, vector unsigned int);
22377 vector unsigned int vec_vsrw (vector unsigned int, vector unsigned int);
22379 vector float vec_vsubfp (vector float, vector float);
22381 vector signed char vec_vsubsbs (vector bool char, vector signed char);
22382 vector signed char vec_vsubsbs (vector signed char, vector bool char);
22383 vector signed char vec_vsubsbs (vector signed char, vector signed char);
22385 vector signed short vec_vsubshs (vector bool short, vector signed short);
22386 vector signed short vec_vsubshs (vector signed short, vector bool short);
22387 vector signed short vec_vsubshs (vector signed short, vector signed short);
22389 vector signed int vec_vsubsws (vector bool int, vector signed int);
22390 vector signed int vec_vsubsws (vector signed int, vector bool int);
22391 vector signed int vec_vsubsws (vector signed int, vector signed int);
22393 vector signed char vec_vsububm (vector bool char, vector signed char);
22394 vector signed char vec_vsububm (vector signed char, vector bool char);
22395 vector signed char vec_vsububm (vector signed char, vector signed char);
22396 vector unsigned char vec_vsububm (vector bool char, vector unsigned char);
22397 vector unsigned char vec_vsububm (vector unsigned char, vector bool char);
22398 vector unsigned char vec_vsububm (vector unsigned char, vector unsigned char);
22400 vector unsigned char vec_vsububs (vector bool char, vector unsigned char);
22401 vector unsigned char vec_vsububs (vector unsigned char, vector bool char);
22402 vector unsigned char vec_vsububs (vector unsigned char, vector unsigned char);
22404 vector signed short vec_vsubuhm (vector bool short, vector signed short);
22405 vector signed short vec_vsubuhm (vector signed short, vector bool short);
22406 vector signed short vec_vsubuhm (vector signed short, vector signed short);
22407 vector unsigned short vec_vsubuhm (vector bool short, vector unsigned short);
22408 vector unsigned short vec_vsubuhm (vector unsigned short, vector bool short);
22409 vector unsigned short vec_vsubuhm (vector unsigned short, vector unsigned short);
22411 vector unsigned short vec_vsubuhs (vector bool short, vector unsigned short);
22412 vector unsigned short vec_vsubuhs (vector unsigned short, vector bool short);
22413 vector unsigned short vec_vsubuhs (vector unsigned short, vector unsigned short);
22415 vector signed int vec_vsubuwm (vector bool int, vector signed int);
22416 vector signed int vec_vsubuwm (vector signed int, vector bool int);
22417 vector signed int vec_vsubuwm (vector signed int, vector signed int);
22418 vector unsigned int vec_vsubuwm (vector bool int, vector unsigned int);
22419 vector unsigned int vec_vsubuwm (vector unsigned int, vector bool int);
22420 vector unsigned int vec_vsubuwm (vector unsigned int, vector unsigned int);
22422 vector unsigned int vec_vsubuws (vector bool int, vector unsigned int);
22423 vector unsigned int vec_vsubuws (vector unsigned int, vector bool int);
22424 vector unsigned int vec_vsubuws (vector unsigned int, vector unsigned int);
22426 vector signed int vec_vsum4sbs (vector signed char, vector signed int);
22428 vector signed int vec_vsum4shs (vector signed short, vector signed int);
22430 vector unsigned int vec_vsum4ubs (vector unsigned char, vector unsigned int);
22432 vector unsigned int vec_vupkhpx (vector pixel);
22434 vector bool short vec_vupkhsb (vector bool char);
22435 vector signed short vec_vupkhsb (vector signed char);
22437 vector bool int vec_vupkhsh (vector bool short);
22438 vector signed int vec_vupkhsh (vector signed short);
22440 vector unsigned int vec_vupklpx (vector pixel);
22442 vector bool short vec_vupklsb (vector bool char);
22443 vector signed short vec_vupklsb (vector signed char);
22445 vector bool int vec_vupklsh (vector bool short);
22446 vector signed int vec_vupklsh (vector signed short);
22447 @end smallexample
22449 @node PowerPC AltiVec Built-in Functions Available on ISA 2.06
22450 @subsubsection PowerPC AltiVec Built-in Functions Available on ISA 2.06
22452 The AltiVec built-in functions described in this section are
22453 available on the PowerPC family of processors starting with ISA 2.06
22454 or later.  These are normally enabled by adding @option{-mvsx} to the
22455 command line.
22457 When @option{-mvsx} is used, the following additional vector types are
22458 implemented.
22460 @smallexample
22461 vector unsigned __int128
22462 vector signed __int128
22463 vector unsigned long long int
22464 vector signed long long int
22465 vector double
22466 @end smallexample
22468 The long long types are only implemented for 64-bit code generation.
22470 Only functions excluded from the PVIPR are listed here.
22472 @smallexample
22473 void vec_dst (const unsigned long *, int, const int);
22474 void vec_dst (const long *, int, const int);
22476 void vec_dststt (const unsigned long *, int, const int);
22477 void vec_dststt (const long *, int, const int);
22479 void vec_dstt (const unsigned long *, int, const int);
22480 void vec_dstt (const long *, int, const int);
22482 vector unsigned char vec_lvsl (int, const unsigned long *);
22483 vector unsigned char vec_lvsl (int, const long *);
22485 vector unsigned char vec_lvsr (int, const unsigned long *);
22486 vector unsigned char vec_lvsr (int, const long *);
22488 vector unsigned char vec_lvsl (int, const double *);
22489 vector unsigned char vec_lvsr (int, const double *);
22491 vector double vec_vsx_ld (int, const vector double *);
22492 vector double vec_vsx_ld (int, const double *);
22493 vector float vec_vsx_ld (int, const vector float *);
22494 vector float vec_vsx_ld (int, const float *);
22495 vector bool int vec_vsx_ld (int, const vector bool int *);
22496 vector signed int vec_vsx_ld (int, const vector signed int *);
22497 vector signed int vec_vsx_ld (int, const int *);
22498 vector signed int vec_vsx_ld (int, const long *);
22499 vector unsigned int vec_vsx_ld (int, const vector unsigned int *);
22500 vector unsigned int vec_vsx_ld (int, const unsigned int *);
22501 vector unsigned int vec_vsx_ld (int, const unsigned long *);
22502 vector bool short vec_vsx_ld (int, const vector bool short *);
22503 vector pixel vec_vsx_ld (int, const vector pixel *);
22504 vector signed short vec_vsx_ld (int, const vector signed short *);
22505 vector signed short vec_vsx_ld (int, const short *);
22506 vector unsigned short vec_vsx_ld (int, const vector unsigned short *);
22507 vector unsigned short vec_vsx_ld (int, const unsigned short *);
22508 vector bool char vec_vsx_ld (int, const vector bool char *);
22509 vector signed char vec_vsx_ld (int, const vector signed char *);
22510 vector signed char vec_vsx_ld (int, const signed char *);
22511 vector unsigned char vec_vsx_ld (int, const vector unsigned char *);
22512 vector unsigned char vec_vsx_ld (int, const unsigned char *);
22514 void vec_vsx_st (vector double, int, vector double *);
22515 void vec_vsx_st (vector double, int, double *);
22516 void vec_vsx_st (vector float, int, vector float *);
22517 void vec_vsx_st (vector float, int, float *);
22518 void vec_vsx_st (vector signed int, int, vector signed int *);
22519 void vec_vsx_st (vector signed int, int, int *);
22520 void vec_vsx_st (vector unsigned int, int, vector unsigned int *);
22521 void vec_vsx_st (vector unsigned int, int, unsigned int *);
22522 void vec_vsx_st (vector bool int, int, vector bool int *);
22523 void vec_vsx_st (vector bool int, int, unsigned int *);
22524 void vec_vsx_st (vector bool int, int, int *);
22525 void vec_vsx_st (vector signed short, int, vector signed short *);
22526 void vec_vsx_st (vector signed short, int, short *);
22527 void vec_vsx_st (vector unsigned short, int, vector unsigned short *);
22528 void vec_vsx_st (vector unsigned short, int, unsigned short *);
22529 void vec_vsx_st (vector bool short, int, vector bool short *);
22530 void vec_vsx_st (vector bool short, int, unsigned short *);
22531 void vec_vsx_st (vector pixel, int, vector pixel *);
22532 void vec_vsx_st (vector pixel, int, unsigned short *);
22533 void vec_vsx_st (vector pixel, int, short *);
22534 void vec_vsx_st (vector bool short, int, short *);
22535 void vec_vsx_st (vector signed char, int, vector signed char *);
22536 void vec_vsx_st (vector signed char, int, signed char *);
22537 void vec_vsx_st (vector unsigned char, int, vector unsigned char *);
22538 void vec_vsx_st (vector unsigned char, int, unsigned char *);
22539 void vec_vsx_st (vector bool char, int, vector bool char *);
22540 void vec_vsx_st (vector bool char, int, unsigned char *);
22541 void vec_vsx_st (vector bool char, int, signed char *);
22543 vector double vec_xxpermdi (vector double, vector double, const int);
22544 vector float vec_xxpermdi (vector float, vector float, const int);
22545 vector long long vec_xxpermdi (vector long long, vector long long, const int);
22546 vector unsigned long long vec_xxpermdi (vector unsigned long long,
22547                                         vector unsigned long long, const int);
22548 vector int vec_xxpermdi (vector int, vector int, const int);
22549 vector unsigned int vec_xxpermdi (vector unsigned int,
22550                                   vector unsigned int, const int);
22551 vector short vec_xxpermdi (vector short, vector short, const int);
22552 vector unsigned short vec_xxpermdi (vector unsigned short,
22553                                     vector unsigned short, const int);
22554 vector signed char vec_xxpermdi (vector signed char, vector signed char,
22555                                  const int);
22556 vector unsigned char vec_xxpermdi (vector unsigned char,
22557                                    vector unsigned char, const int);
22559 vector double vec_xxsldi (vector double, vector double, int);
22560 vector float vec_xxsldi (vector float, vector float, int);
22561 vector long long vec_xxsldi (vector long long, vector long long, int);
22562 vector unsigned long long vec_xxsldi (vector unsigned long long,
22563                                       vector unsigned long long, int);
22564 vector int vec_xxsldi (vector int, vector int, int);
22565 vector unsigned int vec_xxsldi (vector unsigned int, vector unsigned int, int);
22566 vector short vec_xxsldi (vector short, vector short, int);
22567 vector unsigned short vec_xxsldi (vector unsigned short,
22568                                   vector unsigned short, int);
22569 vector signed char vec_xxsldi (vector signed char, vector signed char, int);
22570 vector unsigned char vec_xxsldi (vector unsigned char,
22571                                  vector unsigned char, int);
22572 @end smallexample
22574 Note that the @samp{vec_ld} and @samp{vec_st} built-in functions always
22575 generate the AltiVec @samp{LVX} and @samp{STVX} instructions even
22576 if the VSX instruction set is available.  The @samp{vec_vsx_ld} and
22577 @samp{vec_vsx_st} built-in functions always generate the VSX @samp{LXVD2X},
22578 @samp{LXVW4X}, @samp{STXVD2X}, and @samp{STXVW4X} instructions.
22580 @node PowerPC AltiVec Built-in Functions Available on ISA 2.07
22581 @subsubsection PowerPC AltiVec Built-in Functions Available on ISA 2.07
22583 If the ISA 2.07 additions to the vector/scalar (power8-vector)
22584 instruction set are available, the following additional functions are
22585 available for both 32-bit and 64-bit targets.  For 64-bit targets, you
22586 can use @var{vector long} instead of @var{vector long long},
22587 @var{vector bool long} instead of @var{vector bool long long}, and
22588 @var{vector unsigned long} instead of @var{vector unsigned long long}.
22590 Only functions excluded from the PVIPR are listed here.
22592 @smallexample
22593 vector long long vec_vaddudm (vector long long, vector long long);
22594 vector long long vec_vaddudm (vector bool long long, vector long long);
22595 vector long long vec_vaddudm (vector long long, vector bool long long);
22596 vector unsigned long long vec_vaddudm (vector unsigned long long,
22597                                        vector unsigned long long);
22598 vector unsigned long long vec_vaddudm (vector bool unsigned long long,
22599                                        vector unsigned long long);
22600 vector unsigned long long vec_vaddudm (vector unsigned long long,
22601                                        vector bool unsigned long long);
22603 vector long long vec_vclz (vector long long);
22604 vector unsigned long long vec_vclz (vector unsigned long long);
22605 vector int vec_vclz (vector int);
22606 vector unsigned int vec_vclz (vector int);
22607 vector short vec_vclz (vector short);
22608 vector unsigned short vec_vclz (vector unsigned short);
22609 vector signed char vec_vclz (vector signed char);
22610 vector unsigned char vec_vclz (vector unsigned char);
22612 vector signed char vec_vclzb (vector signed char);
22613 vector unsigned char vec_vclzb (vector unsigned char);
22615 vector long long vec_vclzd (vector long long);
22616 vector unsigned long long vec_vclzd (vector unsigned long long);
22618 vector short vec_vclzh (vector short);
22619 vector unsigned short vec_vclzh (vector unsigned short);
22621 vector int vec_vclzw (vector int);
22622 vector unsigned int vec_vclzw (vector int);
22624 vector signed char vec_vgbbd (vector signed char);
22625 vector unsigned char vec_vgbbd (vector unsigned char);
22627 vector long long vec_vmaxsd (vector long long, vector long long);
22629 vector unsigned long long vec_vmaxud (vector unsigned long long,
22630                                       unsigned vector long long);
22632 vector long long vec_vminsd (vector long long, vector long long);
22634 vector unsigned long long vec_vminud (vector long long, vector long long);
22636 vector int vec_vpksdss (vector long long, vector long long);
22637 vector unsigned int vec_vpksdss (vector long long, vector long long);
22639 vector unsigned int vec_vpkudus (vector unsigned long long,
22640                                  vector unsigned long long);
22642 vector int vec_vpkudum (vector long long, vector long long);
22643 vector unsigned int vec_vpkudum (vector unsigned long long,
22644                                  vector unsigned long long);
22645 vector bool int vec_vpkudum (vector bool long long, vector bool long long);
22647 vector long long vec_vpopcnt (vector long long);
22648 vector unsigned long long vec_vpopcnt (vector unsigned long long);
22649 vector int vec_vpopcnt (vector int);
22650 vector unsigned int vec_vpopcnt (vector int);
22651 vector short vec_vpopcnt (vector short);
22652 vector unsigned short vec_vpopcnt (vector unsigned short);
22653 vector signed char vec_vpopcnt (vector signed char);
22654 vector unsigned char vec_vpopcnt (vector unsigned char);
22656 vector signed char vec_vpopcntb (vector signed char);
22657 vector unsigned char vec_vpopcntb (vector unsigned char);
22659 vector long long vec_vpopcntd (vector long long);
22660 vector unsigned long long vec_vpopcntd (vector unsigned long long);
22662 vector short vec_vpopcnth (vector short);
22663 vector unsigned short vec_vpopcnth (vector unsigned short);
22665 vector int vec_vpopcntw (vector int);
22666 vector unsigned int vec_vpopcntw (vector int);
22668 vector long long vec_vrld (vector long long, vector unsigned long long);
22669 vector unsigned long long vec_vrld (vector unsigned long long,
22670                                     vector unsigned long long);
22672 vector long long vec_vsld (vector long long, vector unsigned long long);
22673 vector long long vec_vsld (vector unsigned long long,
22674                            vector unsigned long long);
22676 vector long long vec_vsrad (vector long long, vector unsigned long long);
22677 vector unsigned long long vec_vsrad (vector unsigned long long,
22678                                      vector unsigned long long);
22680 vector long long vec_vsrd (vector long long, vector unsigned long long);
22681 vector unsigned long long char vec_vsrd (vector unsigned long long,
22682                                          vector unsigned long long);
22684 vector long long vec_vsubudm (vector long long, vector long long);
22685 vector long long vec_vsubudm (vector bool long long, vector long long);
22686 vector long long vec_vsubudm (vector long long, vector bool long long);
22687 vector unsigned long long vec_vsubudm (vector unsigned long long,
22688                                        vector unsigned long long);
22689 vector unsigned long long vec_vsubudm (vector bool long long,
22690                                        vector unsigned long long);
22691 vector unsigned long long vec_vsubudm (vector unsigned long long,
22692                                        vector bool long long);
22694 vector long long vec_vupkhsw (vector int);
22695 vector unsigned long long vec_vupkhsw (vector unsigned int);
22697 vector long long vec_vupklsw (vector int);
22698 vector unsigned long long vec_vupklsw (vector int);
22699 @end smallexample
22701 If the ISA 2.07 additions to the vector/scalar (power8-vector)
22702 instruction set are available, the following additional functions are
22703 available for 64-bit targets.  New vector types
22704 (@var{vector __int128} and @var{vector __uint128}) are available
22705 to hold the @var{__int128} and @var{__uint128} types to use these
22706 builtins.
22708 The normal vector extract, and set operations work on
22709 @var{vector __int128} and @var{vector __uint128} types,
22710 but the index value must be 0.
22712 Only functions excluded from the PVIPR are listed here.
22714 @smallexample
22715 vector __int128 vec_vaddcuq (vector __int128, vector __int128);
22716 vector __uint128 vec_vaddcuq (vector __uint128, vector __uint128);
22718 vector __int128 vec_vadduqm (vector __int128, vector __int128);
22719 vector __uint128 vec_vadduqm (vector __uint128, vector __uint128);
22721 vector __int128 vec_vaddecuq (vector __int128, vector __int128,
22722                                 vector __int128);
22723 vector __uint128 vec_vaddecuq (vector __uint128, vector __uint128,
22724                                  vector __uint128);
22726 vector __int128 vec_vaddeuqm (vector __int128, vector __int128,
22727                                 vector __int128);
22728 vector __uint128 vec_vaddeuqm (vector __uint128, vector __uint128,
22729                                  vector __uint128);
22731 vector __int128 vec_vsubecuq (vector __int128, vector __int128,
22732                                 vector __int128);
22733 vector __uint128 vec_vsubecuq (vector __uint128, vector __uint128,
22734                                  vector __uint128);
22736 vector __int128 vec_vsubeuqm (vector __int128, vector __int128,
22737                                 vector __int128);
22738 vector __uint128 vec_vsubeuqm (vector __uint128, vector __uint128,
22739                                  vector __uint128);
22741 vector __int128 vec_vsubcuq (vector __int128, vector __int128);
22742 vector __uint128 vec_vsubcuq (vector __uint128, vector __uint128);
22744 __int128 vec_vsubuqm (__int128, __int128);
22745 __uint128 vec_vsubuqm (__uint128, __uint128);
22747 vector __int128 __builtin_bcdadd (vector __int128, vector __int128, const int);
22748 vector unsigned char __builtin_bcdadd (vector unsigned char, vector unsigned char,
22749                                        const int);
22750 int __builtin_bcdadd_lt (vector __int128, vector __int128, const int);
22751 int __builtin_bcdadd_lt (vector unsigned char, vector unsigned char, const int);
22752 int __builtin_bcdadd_eq (vector __int128, vector __int128, const int);
22753 int __builtin_bcdadd_eq (vector unsigned char, vector unsigned char, const int);
22754 int __builtin_bcdadd_gt (vector __int128, vector __int128, const int);
22755 int __builtin_bcdadd_gt (vector unsigned char, vector unsigned char, const int);
22756 int __builtin_bcdadd_ov (vector __int128, vector __int128, const int);
22757 int __builtin_bcdadd_ov (vector unsigned char, vector unsigned char, const int);
22759 vector __int128 __builtin_bcdsub (vector __int128, vector __int128, const int);
22760 vector unsigned char __builtin_bcdsub (vector unsigned char, vector unsigned char,
22761                                        const int);
22762 int __builtin_bcdsub_le (vector __int128, vector __int128, const int);
22763 int __builtin_bcdsub_le (vector unsigned char, vector unsigned char, const int);
22764 int __builtin_bcdsub_lt (vector __int128, vector __int128, const int);
22765 int __builtin_bcdsub_lt (vector unsigned char, vector unsigned char, const int);
22766 int __builtin_bcdsub_eq (vector __int128, vector __int128, const int);
22767 int __builtin_bcdsub_eq (vector unsigned char, vector unsigned char, const int);
22768 int __builtin_bcdsub_gt (vector __int128, vector __int128, const int);
22769 int __builtin_bcdsub_gt (vector unsigned char, vector unsigned char, const int);
22770 int __builtin_bcdsub_ge (vector __int128, vector __int128, const int);
22771 int __builtin_bcdsub_ge (vector unsigned char, vector unsigned char, const int);
22772 int __builtin_bcdsub_ov (vector __int128, vector __int128, const int);
22773 int __builtin_bcdsub_ov (vector unsigned char, vector unsigned char, const int);
22774 @end smallexample
22776 @node PowerPC AltiVec Built-in Functions Available on ISA 3.0
22777 @subsubsection PowerPC AltiVec Built-in Functions Available on ISA 3.0
22779 The following additional built-in functions are also available for the
22780 PowerPC family of processors, starting with ISA 3.0
22781 (@option{-mcpu=power9}) or later.
22783 Only instructions excluded from the PVIPR are listed here.
22785 @smallexample
22786 unsigned int scalar_extract_exp (double source);
22787 unsigned long long int scalar_extract_exp (__ieee128 source);
22789 unsigned long long int scalar_extract_sig (double source);
22790 unsigned __int128 scalar_extract_sig (__ieee128 source);
22792 double scalar_insert_exp (unsigned long long int significand,
22793                           unsigned long long int exponent);
22794 double scalar_insert_exp (double significand, unsigned long long int exponent);
22796 ieee_128 scalar_insert_exp (unsigned __int128 significand,
22797                             unsigned long long int exponent);
22798 ieee_128 scalar_insert_exp (ieee_128 significand, unsigned long long int exponent);
22799 vector ieee_128 scalar_insert_exp (vector unsigned __int128 significand,
22800                                    vector unsigned long long exponent);
22801 vector unsigned long long scalar_extract_exp_to_vec (ieee_128);
22802 vector unsigned __int128  scalar_extract_sig_to_vec (ieee_128);
22804 int scalar_cmp_exp_gt (double arg1, double arg2);
22805 int scalar_cmp_exp_lt (double arg1, double arg2);
22806 int scalar_cmp_exp_eq (double arg1, double arg2);
22807 int scalar_cmp_exp_unordered (double arg1, double arg2);
22809 bool scalar_test_data_class (float source, const int condition);
22810 bool scalar_test_data_class (double source, const int condition);
22811 bool scalar_test_data_class (__ieee128 source, const int condition);
22813 bool scalar_test_neg (float source);
22814 bool scalar_test_neg (double source);
22815 bool scalar_test_neg (__ieee128 source);
22816 @end smallexample
22818 The @code{scalar_extract_exp} with a 64-bit source argument
22819 function requires an environment supporting ISA 3.0 or later.
22820 The @code{scalar_extract_exp} with a 128-bit source argument
22821 and @code{scalar_extract_sig}
22822 functions require a 64-bit environment supporting ISA 3.0 or later.
22823 The @code{scalar_extract_exp} and @code{scalar_extract_sig} built-in
22824 functions return the significand and the biased exponent value
22825 respectively of their @code{source} arguments.
22826 When supplied with a 64-bit @code{source} argument, the
22827 result returned by @code{scalar_extract_sig} has
22828 the @code{0x0010000000000000} bit set if the
22829 function's @code{source} argument is in normalized form.
22830 Otherwise, this bit is set to 0.
22831 When supplied with a 128-bit @code{source} argument, the
22832 @code{0x00010000000000000000000000000000} bit of the result is
22833 treated similarly.
22834 Note that the sign of the significand is not represented in the result
22835 returned from the @code{scalar_extract_sig} function.  Use the
22836 @code{scalar_test_neg} function to test the sign of its @code{double}
22837 argument.
22839 The @code{scalar_insert_exp}
22840 functions require a 64-bit environment supporting ISA 3.0 or later.
22841 When supplied with a 64-bit first argument, the
22842 @code{scalar_insert_exp} built-in function returns a double-precision
22843 floating point value that is constructed by assembling the values of its
22844 @code{significand} and @code{exponent} arguments.  The sign of the
22845 result is copied from the most significant bit of the
22846 @code{significand} argument.  The significand and exponent components
22847 of the result are composed of the least significant 11 bits of the
22848 @code{exponent} argument and the least significant 52 bits of the
22849 @code{significand} argument respectively.
22851 When supplied with a 128-bit first argument, the
22852 @code{scalar_insert_exp} built-in function returns a quad-precision
22853 IEEE floating point value if the two arguments were scalar.  If the two
22854 arguments are vectors, the return value is a vector IEEE floating point value.
22855 The sign bit of the result is copied from the most significant bit of the
22856 @code{significand} argument.  The significand and exponent components of the
22857 result are composed of the least significant 15 bits of the @code{exponent}
22858 argument (element 0 on big-endian and element 1 on little-endian) and the
22859 least significant 112 bits of the @code{significand} argument
22860 respectively.  Note, the @code{significand} is the scalar argument or in the
22861 case of vector arguments, @code{significand} is element 0 for big-endian and
22862 element 1 for little-endian.
22864 The @code{scalar_extract_exp_to_vec},
22865 and @code{scalar_extract_sig_to_vec} are similar to
22866 @code{scalar_extract_exp}, @code{scalar_extract_sig} except they return
22867 a vector result of type unsigned long long and unsigned __int128 respectively.
22869 The @code{scalar_cmp_exp_gt}, @code{scalar_cmp_exp_lt},
22870 @code{scalar_cmp_exp_eq}, and @code{scalar_cmp_exp_unordered} built-in
22871 functions return a non-zero value if @code{arg1} is greater than, less
22872 than, equal to, or not comparable to @code{arg2} respectively.  The
22873 arguments are not comparable if one or the other equals NaN (not a
22874 number). 
22876 The @code{scalar_test_data_class} built-in function returns 1
22877 if any of the condition tests enabled by the value of the
22878 @code{condition} variable are true, and 0 otherwise.  The
22879 @code{condition} argument must be a compile-time constant integer with
22880 value not exceeding 127.  The
22881 @code{condition} argument is encoded as a bitmask with each bit
22882 enabling the testing of a different condition, as characterized by the
22883 following:
22884 @smallexample
22885 0x40    Test for NaN
22886 0x20    Test for +Infinity
22887 0x10    Test for -Infinity
22888 0x08    Test for +Zero
22889 0x04    Test for -Zero
22890 0x02    Test for +Denormal
22891 0x01    Test for -Denormal
22892 @end smallexample
22894 The @code{scalar_test_neg} built-in function returns 1 if its
22895 @code{source} argument holds a negative value, 0 otherwise.
22897 The following built-in functions are also available for the PowerPC family
22898 of processors, starting with ISA 3.0 or later
22899 (@option{-mcpu=power9}).  These string functions are described
22900 separately in order to group the descriptions closer to the function
22901 prototypes.
22903 Only functions excluded from the PVIPR are listed here.
22905 @smallexample
22906 int vec_all_nez (vector signed char, vector signed char);
22907 int vec_all_nez (vector unsigned char, vector unsigned char);
22908 int vec_all_nez (vector signed short, vector signed short);
22909 int vec_all_nez (vector unsigned short, vector unsigned short);
22910 int vec_all_nez (vector signed int, vector signed int);
22911 int vec_all_nez (vector unsigned int, vector unsigned int);
22913 int vec_any_eqz (vector signed char, vector signed char);
22914 int vec_any_eqz (vector unsigned char, vector unsigned char);
22915 int vec_any_eqz (vector signed short, vector signed short);
22916 int vec_any_eqz (vector unsigned short, vector unsigned short);
22917 int vec_any_eqz (vector signed int, vector signed int);
22918 int vec_any_eqz (vector unsigned int, vector unsigned int);
22920 signed char vec_xlx (unsigned int index, vector signed char data);
22921 unsigned char vec_xlx (unsigned int index, vector unsigned char data);
22922 signed short vec_xlx (unsigned int index, vector signed short data);
22923 unsigned short vec_xlx (unsigned int index, vector unsigned short data);
22924 signed int vec_xlx (unsigned int index, vector signed int data);
22925 unsigned int vec_xlx (unsigned int index, vector unsigned int data);
22926 float vec_xlx (unsigned int index, vector float data);
22928 signed char vec_xrx (unsigned int index, vector signed char data);
22929 unsigned char vec_xrx (unsigned int index, vector unsigned char data);
22930 signed short vec_xrx (unsigned int index, vector signed short data);
22931 unsigned short vec_xrx (unsigned int index, vector unsigned short data);
22932 signed int vec_xrx (unsigned int index, vector signed int data);
22933 unsigned int vec_xrx (unsigned int index, vector unsigned int data);
22934 float vec_xrx (unsigned int index, vector float data);
22935 @end smallexample
22937 The @code{vec_all_nez}, @code{vec_any_eqz}, and @code{vec_cmpnez}
22938 perform pairwise comparisons between the elements at the same
22939 positions within their two vector arguments.
22940 The @code{vec_all_nez} function returns a
22941 non-zero value if and only if all pairwise comparisons are not
22942 equal and no element of either vector argument contains a zero.
22943 The @code{vec_any_eqz} function returns a
22944 non-zero value if and only if at least one pairwise comparison is equal
22945 or if at least one element of either vector argument contains a zero.
22946 The @code{vec_cmpnez} function returns a vector of the same type as
22947 its two arguments, within which each element consists of all ones to
22948 denote that either the corresponding elements of the incoming arguments are
22949 not equal or that at least one of the corresponding elements contains
22950 zero.  Otherwise, the element of the returned vector contains all zeros.
22952 The @code{vec_xlx} and @code{vec_xrx} functions extract the single
22953 element selected by the @code{index} argument from the vector
22954 represented by the @code{data} argument.  The @code{index} argument
22955 always specifies a byte offset, regardless of the size of the vector
22956 element.  With @code{vec_xlx}, @code{index} is the offset of the first
22957 byte of the element to be extracted.  With @code{vec_xrx}, @code{index}
22958 represents the last byte of the element to be extracted, measured
22959 from the right end of the vector.  In other words, the last byte of
22960 the element to be extracted is found at position @code{(15 - index)}.
22961 There is no requirement that @code{index} be a multiple of the vector
22962 element size.  However, if the size of the vector element added to
22963 @code{index} is greater than 15, the content of the returned value is
22964 undefined.
22966 The following functions are also available if the ISA 3.0 instruction
22967 set additions (@option{-mcpu=power9}) are available.
22969 Only functions excluded from the PVIPR are listed here.
22971 @smallexample
22972 vector long long vec_vctz (vector long long);
22973 vector unsigned long long vec_vctz (vector unsigned long long);
22974 vector int vec_vctz (vector int);
22975 vector unsigned int vec_vctz (vector int);
22976 vector short vec_vctz (vector short);
22977 vector unsigned short vec_vctz (vector unsigned short);
22978 vector signed char vec_vctz (vector signed char);
22979 vector unsigned char vec_vctz (vector unsigned char);
22981 vector signed char vec_vctzb (vector signed char);
22982 vector unsigned char vec_vctzb (vector unsigned char);
22984 vector long long vec_vctzd (vector long long);
22985 vector unsigned long long vec_vctzd (vector unsigned long long);
22987 vector short vec_vctzh (vector short);
22988 vector unsigned short vec_vctzh (vector unsigned short);
22990 vector int vec_vctzw (vector int);
22991 vector unsigned int vec_vctzw (vector int);
22993 vector int vec_vprtyb (vector int);
22994 vector unsigned int vec_vprtyb (vector unsigned int);
22995 vector long long vec_vprtyb (vector long long);
22996 vector unsigned long long vec_vprtyb (vector unsigned long long);
22998 vector int vec_vprtybw (vector int);
22999 vector unsigned int vec_vprtybw (vector unsigned int);
23001 vector long long vec_vprtybd (vector long long);
23002 vector unsigned long long vec_vprtybd (vector unsigned long long);
23003 @end smallexample
23005 On 64-bit targets, if the ISA 3.0 additions (@option{-mcpu=power9})
23006 are available:
23008 @smallexample
23009 vector long vec_vprtyb (vector long);
23010 vector unsigned long vec_vprtyb (vector unsigned long);
23011 vector __int128 vec_vprtyb (vector __int128);
23012 vector __uint128 vec_vprtyb (vector __uint128);
23014 vector long vec_vprtybd (vector long);
23015 vector unsigned long vec_vprtybd (vector unsigned long);
23017 vector __int128 vec_vprtybq (vector __int128);
23018 vector __uint128 vec_vprtybd (vector __uint128);
23019 @end smallexample
23021 The following built-in functions are available for the PowerPC family
23022 of processors, starting with ISA 3.0 or later (@option{-mcpu=power9}).
23024 Only functions excluded from the PVIPR are listed here.
23026 @smallexample
23027 __vector unsigned char
23028 vec_absdb (__vector unsigned char arg1, __vector unsigned char arg2);
23029 __vector unsigned short
23030 vec_absdh (__vector unsigned short arg1, __vector unsigned short arg2);
23031 __vector unsigned int
23032 vec_absdw (__vector unsigned int arg1, __vector unsigned int arg2);
23033 @end smallexample
23035 The @code{vec_absd}, @code{vec_absdb}, @code{vec_absdh}, and
23036 @code{vec_absdw} built-in functions each computes the absolute
23037 differences of the pairs of vector elements supplied in its two vector
23038 arguments, placing the absolute differences into the corresponding
23039 elements of the vector result.
23041 The following built-in functions are available for the PowerPC family
23042 of processors, starting with ISA 3.0 or later (@option{-mcpu=power9}):
23043 @smallexample
23044 vector unsigned int vec_vrlnm (vector unsigned int, vector unsigned int);
23045 vector unsigned long long vec_vrlnm (vector unsigned long long,
23046                                      vector unsigned long long);
23047 @end smallexample
23049 The result of @code{vec_vrlnm} is obtained by rotating each element
23050 of the first argument vector left and ANDing it with a mask.  The
23051 second argument vector contains the mask  beginning in bits 11:15,
23052 the mask end in bits 19:23, and the shift count in bits 27:31,
23053 of each element.
23055 If the cryptographic instructions are enabled (@option{-mcrypto} or
23056 @option{-mcpu=power8}), the following builtins are enabled.
23058 Only functions excluded from the PVIPR are listed here.
23060 @smallexample
23061 vector unsigned long long __builtin_crypto_vsbox (vector unsigned long long);
23063 vector unsigned long long __builtin_crypto_vcipher (vector unsigned long long,
23064                                                     vector unsigned long long);
23066 vector unsigned long long __builtin_crypto_vcipherlast
23067                                      (vector unsigned long long,
23068                                       vector unsigned long long);
23070 vector unsigned long long __builtin_crypto_vncipher (vector unsigned long long,
23071                                                      vector unsigned long long);
23073 vector unsigned long long __builtin_crypto_vncipherlast (vector unsigned long long,
23074                                                          vector unsigned long long);
23076 vector unsigned char __builtin_crypto_vpermxor (vector unsigned char,
23077                                                 vector unsigned char,
23078                                                 vector unsigned char);
23080 vector unsigned short __builtin_crypto_vpermxor (vector unsigned short,
23081                                                  vector unsigned short,
23082                                                  vector unsigned short);
23084 vector unsigned int __builtin_crypto_vpermxor (vector unsigned int,
23085                                                vector unsigned int,
23086                                                vector unsigned int);
23088 vector unsigned long long __builtin_crypto_vpermxor (vector unsigned long long,
23089                                                      vector unsigned long long,
23090                                                      vector unsigned long long);
23092 vector unsigned char __builtin_crypto_vpmsumb (vector unsigned char,
23093                                                vector unsigned char);
23095 vector unsigned short __builtin_crypto_vpmsumh (vector unsigned short,
23096                                                 vector unsigned short);
23098 vector unsigned int __builtin_crypto_vpmsumw (vector unsigned int,
23099                                               vector unsigned int);
23101 vector unsigned long long __builtin_crypto_vpmsumd (vector unsigned long long,
23102                                                     vector unsigned long long);
23104 vector unsigned long long __builtin_crypto_vshasigmad (vector unsigned long long,
23105                                                        int, int);
23107 vector unsigned int __builtin_crypto_vshasigmaw (vector unsigned int, int, int);
23108 @end smallexample
23110 The second argument to @var{__builtin_crypto_vshasigmad} and
23111 @var{__builtin_crypto_vshasigmaw} must be a constant
23112 integer that is 0 or 1.  The third argument to these built-in functions
23113 must be a constant integer in the range of 0 to 15.
23115 The following sign extension builtins are provided:
23117 @smallexample
23118 vector signed int vec_signexti (vector signed char a);
23119 vector signed long long vec_signextll (vector signed char a);
23120 vector signed int vec_signexti (vector signed short a);
23121 vector signed long long vec_signextll (vector signed short a);
23122 vector signed long long vec_signextll (vector signed int a);
23123 vector signed long long vec_signextq (vector signed long long a);
23124 @end smallexample
23126 Each element of the result is produced by sign-extending the element of the
23127 input vector that would fall in the least significant portion of the result
23128 element. For example, a sign-extension of a vector signed char to a vector
23129 signed long long will sign extend the rightmost byte of each doubleword.
23131 @node PowerPC AltiVec Built-in Functions Available on ISA 3.1
23132 @subsubsection PowerPC AltiVec Built-in Functions Available on ISA 3.1
23134 The following additional built-in functions are also available for the
23135 PowerPC family of processors, starting with ISA 3.1 (@option{-mcpu=power10}):
23138 @smallexample
23139 @exdent vector unsigned long long int
23140 @exdent vec_cfuge (vector unsigned long long int, vector unsigned long long int);
23141 @end smallexample
23142 Perform a vector centrifuge operation, as if implemented by the
23143 @code{vcfuged} instruction.
23144 @findex vec_cfuge
23146 @smallexample
23147 @exdent vector unsigned long long int
23148 @exdent vec_cntlzm (vector unsigned long long int, vector unsigned long long int);
23149 @end smallexample
23150 Perform a vector count leading zeros under bit mask operation, as if
23151 implemented by the @code{vclzdm} instruction.
23152 @findex vec_cntlzm
23154 @smallexample
23155 @exdent vector unsigned long long int
23156 @exdent vec_cnttzm (vector unsigned long long int, vector unsigned long long int);
23157 @end smallexample
23158 Perform a vector count trailing zeros under bit mask operation, as if
23159 implemented by the @code{vctzdm} instruction.
23160 @findex vec_cnttzm
23162 @smallexample
23163 @exdent vector signed char
23164 @exdent vec_clrl (vector signed char @var{a}, unsigned int @var{n});
23165 @exdent vector unsigned char
23166 @exdent vec_clrl (vector unsigned char @var{a}, unsigned int @var{n});
23167 @end smallexample
23168 Clear the left-most @code{(16 - n)} bytes of vector argument @code{a}, as if
23169 implemented by the @code{vclrlb} instruction on a big-endian target
23170 and by the @code{vclrrb} instruction on a little-endian target.  A
23171 value of @code{n} that is greater than 16 is treated as if it equaled 16.
23172 @findex vec_clrl
23174 @smallexample
23175 @exdent vector signed char
23176 @exdent vec_clrr (vector signed char @var{a}, unsigned int @var{n});
23177 @exdent vector unsigned char
23178 @exdent vec_clrr (vector unsigned char @var{a}, unsigned int @var{n});
23179 @end smallexample
23180 Clear the right-most @code{(16 - n)} bytes of vector argument @code{a}, as if
23181 implemented by the @code{vclrrb} instruction on a big-endian target
23182 and by the @code{vclrlb} instruction on a little-endian target.  A
23183 value of @code{n} that is greater than 16 is treated as if it equaled 16.
23184 @findex vec_clrr
23186 @smallexample
23187 @exdent vector unsigned long long int
23188 @exdent vec_gnb (vector unsigned __int128, const unsigned char);
23189 @end smallexample
23190 Perform a 128-bit vector gather  operation, as if implemented by the
23191 @code{vgnb} instruction.  The second argument must be a literal
23192 integer value between 2 and 7 inclusive.
23193 @findex vec_gnb
23196 Vector Extract
23198 @smallexample
23199 @exdent vector unsigned long long int
23200 @exdent vec_extractl (vector unsigned char, vector unsigned char, unsigned int);
23201 @exdent vector unsigned long long int
23202 @exdent vec_extractl (vector unsigned short, vector unsigned short, unsigned int);
23203 @exdent vector unsigned long long int
23204 @exdent vec_extractl (vector unsigned int, vector unsigned int, unsigned int);
23205 @exdent vector unsigned long long int
23206 @exdent vec_extractl (vector unsigned long long, vector unsigned long long, unsigned int);
23207 @end smallexample
23208 Extract an element from two concatenated vectors starting at the given byte index
23209 in natural-endian order, and place it zero-extended in doubleword 1 of the result
23210 according to natural element order.  If the byte index is out of range for the
23211 data type, the intrinsic will be rejected.
23212 For little-endian, this output will match the placement by the hardware
23213 instruction, i.e., dword[0] in RTL notation.  For big-endian, an additional
23214 instruction is needed to move it from the "left" doubleword to the  "right" one.
23215 For little-endian, semantics matching the @code{vextdubvrx},
23216 @code{vextduhvrx}, @code{vextduwvrx} instruction will be generated, while for
23217 big-endian, semantics matching the @code{vextdubvlx}, @code{vextduhvlx},
23218 @code{vextduwvlx} instructions
23219 will be generated.  Note that some fairly anomalous results can be generated if
23220 the byte index is not aligned on an element boundary for the element being
23221 extracted.  This is a limitation of the bi-endian vector programming model is
23222 consistent with the limitation on @code{vec_perm}.
23223 @findex vec_extractl
23225 @smallexample
23226 @exdent vector unsigned long long int
23227 @exdent vec_extracth (vector unsigned char, vector unsigned char, unsigned int);
23228 @exdent vector unsigned long long int
23229 @exdent vec_extracth (vector unsigned short, vector unsigned short,
23230 unsigned int);
23231 @exdent vector unsigned long long int
23232 @exdent vec_extracth (vector unsigned int, vector unsigned int, unsigned int);
23233 @exdent vector unsigned long long int
23234 @exdent vec_extracth (vector unsigned long long, vector unsigned long long,
23235 unsigned int);
23236 @end smallexample
23237 Extract an element from two concatenated vectors starting at the given byte
23238 index.  The index is based on big endian order for a little endian system.
23239 Similarly, the index is based on little endian order for a big endian system.
23240 The extraced elements are zero-extended and put in doubleword 1
23241 according to natural element order.  If the byte index is out of range for the
23242 data type, the intrinsic will be rejected.  For little-endian, this output
23243 will match the placement by the hardware instruction (vextdubvrx, vextduhvrx,
23244 vextduwvrx, vextddvrx) i.e., dword[0] in RTL
23245 notation.  For big-endian, an additional instruction is needed to move it
23246 from the "left" doubleword to the "right" one.  For little-endian, semantics
23247 matching the @code{vextdubvlx}, @code{vextduhvlx}, @code{vextduwvlx}
23248 instructions will be generated, while for big-endian, semantics matching the
23249 @code{vextdubvrx}, @code{vextduhvrx}, @code{vextduwvrx} instructions will
23250 be generated.  Note that some fairly anomalous
23251 results can be generated if the byte index is not aligned on the
23252 element boundary for the element being extracted.  This is a
23253 limitation of the bi-endian vector programming model consistent with the
23254 limitation on @code{vec_perm}.
23255 @findex vec_extracth
23256 @smallexample
23257 @exdent vector unsigned long long int
23258 @exdent vec_pdep (vector unsigned long long int, vector unsigned long long int);
23259 @end smallexample
23260 Perform a vector parallel bits deposit operation, as if implemented by
23261 the @code{vpdepd} instruction.
23262 @findex vec_pdep
23264 Vector Insert
23266 @smallexample
23267 @exdent vector unsigned char
23268 @exdent vec_insertl (unsigned char, vector unsigned char, unsigned int);
23269 @exdent vector unsigned short
23270 @exdent vec_insertl (unsigned short, vector unsigned short, unsigned int);
23271 @exdent vector unsigned int
23272 @exdent vec_insertl (unsigned int, vector unsigned int, unsigned int);
23273 @exdent vector unsigned long long
23274 @exdent vec_insertl (unsigned long long, vector unsigned long long,
23275 unsigned int);
23276 @exdent vector unsigned char
23277 @exdent vec_insertl (vector unsigned char, vector unsigned char, unsigned int;
23278 @exdent vector unsigned short
23279 @exdent vec_insertl (vector unsigned short, vector unsigned short,
23280 unsigned int);
23281 @exdent vector unsigned int
23282 @exdent vec_insertl (vector unsigned int, vector unsigned int, unsigned int);
23283 @end smallexample
23285 Let src be the first argument, when the first argument is a scalar, or the
23286 rightmost element of the left doubleword of the first argument, when the first
23287 argument is a vector.  Insert the source into the destination at the position
23288 given by the third argument, using natural element order in the second
23289 argument.  The rest of the second argument is unchanged.  If the byte
23290 index is greater than 14 for halfwords, greater than 12 for words, or
23291 greater than 8 for doublewords the result is undefined.   For little-endian,
23292 the generated code will be semantically equivalent to @code{vins[bhwd]rx}
23293 instructions.  Similarly for big-endian it will be semantically equivalent
23294 to @code{vins[bhwd]lx}.  Note that some fairly anomalous results can be
23295 generated if the byte index is not aligned on an element boundary for the
23296 type of element being inserted.
23297 @findex vec_insertl
23299 @smallexample
23300 @exdent vector unsigned char
23301 @exdent vec_inserth (unsigned char, vector unsigned char, unsigned int);
23302 @exdent vector unsigned short
23303 @exdent vec_inserth (unsigned short, vector unsigned short, unsigned int);
23304 @exdent vector unsigned int
23305 @exdent vec_inserth (unsigned int, vector unsigned int, unsigned int);
23306 @exdent vector unsigned long long
23307 @exdent vec_inserth (unsigned long long, vector unsigned long long,
23308 unsigned int);
23309 @exdent vector unsigned char
23310 @exdent vec_inserth (vector unsigned char, vector unsigned char, unsigned int);
23311 @exdent vector unsigned short
23312 @exdent vec_inserth (vector unsigned short, vector unsigned short,
23313 unsigned int);
23314 @exdent vector unsigned int
23315 @exdent vec_inserth (vector unsigned int, vector unsigned int, unsigned int);
23316 @end smallexample
23318 Let src be the first argument, when the first argument is a scalar, or the
23319 rightmost element of the first argument, when the first argument is a vector.
23320 Insert src into the second argument at the position identified by the third
23321 argument, using opposite element order in the second argument, and leaving the
23322 rest of the second argument unchanged.  If the byte index is greater than 14
23323 for halfwords, 12 for words, or 8 for doublewords, the intrinsic will be
23324 rejected. Note that the underlying hardware instruction uses the same register
23325 for the second argument and the result.
23326 For little-endian, the code generation will be semantically equivalent to
23327 @code{vins[bhwd]lx}, while for big-endian it will be semantically equivalent to
23328 @code{vins[bhwd]rx}.
23329 Note that some fairly anomalous results can be generated if the byte index is
23330 not aligned on an element boundary for the sort of element being inserted.
23331 @findex vec_inserth
23333 Vector Replace Element
23334 @smallexample
23335 @exdent vector signed int vec_replace_elt (vector signed int, signed int,
23336 const int);
23337 @exdent vector unsigned int vec_replace_elt (vector unsigned int,
23338 unsigned int, const int);
23339 @exdent vector float vec_replace_elt (vector float, float, const int);
23340 @exdent vector signed long long vec_replace_elt (vector signed long long,
23341 signed long long, const int);
23342 @exdent vector unsigned long long vec_replace_elt (vector unsigned long long,
23343 unsigned long long, const int);
23344 @exdent vector double rec_replace_elt (vector double, double, const int);
23345 @end smallexample
23346 The third argument (constrained to [0,3]) identifies the natural-endian
23347 element number of the first argument that will be replaced by the second
23348 argument to produce the result.  The other elements of the first argument will
23349 remain unchanged in the result.
23351 If it's desirable to insert a word at an unaligned position, use
23352 vec_replace_unaligned instead.
23354 @findex vec_replace_element
23356 Vector Replace Unaligned
23357 @smallexample
23358 @exdent vector unsigned char vec_replace_unaligned (vector unsigned char,
23359 signed int, const int);
23360 @exdent vector unsigned char vec_replace_unaligned (vector unsigned char,
23361 unsigned int, const int);
23362 @exdent vector unsigned char vec_replace_unaligned (vector unsigned char,
23363 float, const int);
23364 @exdent vector unsigned char vec_replace_unaligned (vector unsigned char,
23365 signed long long, const int);
23366 @exdent vector unsigned char vec_replace_unaligned (vector unsigned char,
23367 unsigned long long, const int);
23368 @exdent vector unsigned char vec_replace_unaligned (vector unsigned char,
23369 double, const int);
23370 @end smallexample
23372 The second argument replaces a portion of the first argument to produce the
23373 result, with the rest of the first argument unchanged in the result.  The
23374 third argument identifies the byte index (using left-to-right, or big-endian
23375 order) where the high-order byte of the second argument will be placed, with
23376 the remaining bytes of the second argument placed naturally "to the right"
23377 of the high-order byte.
23379 The programmer is responsible for understanding the endianness issues involved
23380 with the first argument and the result.
23381 @findex vec_replace_unaligned
23383 Vector Shift Left Double Bit Immediate
23384 @smallexample
23385 @exdent vector signed char vec_sldb (vector signed char, vector signed char,
23386 const unsigned int);
23387 @exdent vector unsigned char vec_sldb (vector unsigned char,
23388 vector unsigned char, const unsigned int);
23389 @exdent vector signed short vec_sldb (vector signed short, vector signed short,
23390 const unsigned int);
23391 @exdent vector unsigned short vec_sldb (vector unsigned short,
23392 vector unsigned short, const unsigned int);
23393 @exdent vector signed int vec_sldb (vector signed int, vector signed int,
23394 const unsigned int);
23395 @exdent vector unsigned int vec_sldb (vector unsigned int, vector unsigned int,
23396 const unsigned int);
23397 @exdent vector signed long long vec_sldb (vector signed long long,
23398 vector signed long long, const unsigned int);
23399 @exdent vector unsigned long long vec_sldb (vector unsigned long long,
23400 vector unsigned long long, const unsigned int);
23401 @end smallexample
23403 Shift the combined input vectors left by the amount specified by the low-order
23404 three bits of the third argument, and return the leftmost remaining 128 bits.
23405 Code using this instruction must be endian-aware.
23407 @findex vec_sldb
23409 Vector Shift Right Double Bit Immediate
23411 @smallexample
23412 @exdent vector signed char vec_srdb (vector signed char, vector signed char,
23413 const unsigned int);
23414 @exdent vector unsigned char vec_srdb (vector unsigned char, vector unsigned char,
23415 const unsigned int);
23416 @exdent vector signed short vec_srdb (vector signed short, vector signed short,
23417 const unsigned int);
23418 @exdent vector unsigned short vec_srdb (vector unsigned short, vector unsigned short,
23419 const unsigned int);
23420 @exdent vector signed int vec_srdb (vector signed int, vector signed int,
23421 const unsigned int);
23422 @exdent vector unsigned int vec_srdb (vector unsigned int, vector unsigned int,
23423 const unsigned int);
23424 @exdent vector signed long long vec_srdb (vector signed long long,
23425 vector signed long long, const unsigned int);
23426 @exdent vector unsigned long long vec_srdb (vector unsigned long long,
23427 vector unsigned long long, const unsigned int);
23428 @end smallexample
23430 Shift the combined input vectors right by the amount specified by the low-order
23431 three bits of the third argument, and return the remaining 128 bits.  Code
23432 using this built-in must be endian-aware.
23434 @findex vec_srdb
23436 Vector Splat
23438 @smallexample
23439 @exdent vector signed int vec_splati (const signed int);
23440 @exdent vector float vec_splati (const float);
23441 @end smallexample
23443 Splat a 32-bit immediate into a vector of words.
23445 @findex vec_splati
23447 @smallexample
23448 @exdent vector double vec_splatid (const float);
23449 @end smallexample
23451 Convert a single precision floating-point value to double-precision and splat
23452 the result to a vector of double-precision floats.
23454 @findex vec_splatid
23456 @smallexample
23457 @exdent vector signed int vec_splati_ins (vector signed int,
23458 const unsigned int, const signed int);
23459 @exdent vector unsigned int vec_splati_ins (vector unsigned int,
23460 const unsigned int, const unsigned int);
23461 @exdent vector float vec_splati_ins (vector float, const unsigned int,
23462 const float);
23463 @end smallexample
23465 Argument 2 must be either 0 or 1.  Splat the value of argument 3 into the word
23466 identified by argument 2 of each doubleword of argument 1 and return the
23467 result.  The other words of argument 1 are unchanged.
23469 @findex vec_splati_ins
23471 Vector Blend Variable
23473 @smallexample
23474 @exdent vector signed char vec_blendv (vector signed char, vector signed char,
23475 vector unsigned char);
23476 @exdent vector unsigned char vec_blendv (vector unsigned char,
23477 vector unsigned char, vector unsigned char);
23478 @exdent vector signed short vec_blendv (vector signed short,
23479 vector signed short, vector unsigned short);
23480 @exdent vector unsigned short vec_blendv (vector unsigned short,
23481 vector unsigned short, vector unsigned short);
23482 @exdent vector signed int vec_blendv (vector signed int, vector signed int,
23483 vector unsigned int);
23484 @exdent vector unsigned int vec_blendv (vector unsigned int,
23485 vector unsigned int, vector unsigned int);
23486 @exdent vector signed long long vec_blendv (vector signed long long,
23487 vector signed long long, vector unsigned long long);
23488 @exdent vector unsigned long long vec_blendv (vector unsigned long long,
23489 vector unsigned long long, vector unsigned long long);
23490 @exdent vector float vec_blendv (vector float, vector float,
23491 vector unsigned int);
23492 @exdent vector double vec_blendv (vector double, vector double,
23493 vector unsigned long long);
23494 @end smallexample
23496 Blend the first and second argument vectors according to the sign bits of the
23497 corresponding elements of the third argument vector.  This is similar to the
23498 @code{vsel} and @code{xxsel} instructions but for bigger elements.
23500 @findex vec_blendv
23502 Vector Permute Extended
23504 @smallexample
23505 @exdent vector signed char vec_permx (vector signed char, vector signed char,
23506 vector unsigned char, const int);
23507 @exdent vector unsigned char vec_permx (vector unsigned char,
23508 vector unsigned char, vector unsigned char, const int);
23509 @exdent vector signed short vec_permx (vector signed short,
23510 vector signed short, vector unsigned char, const int);
23511 @exdent vector unsigned short vec_permx (vector unsigned short,
23512 vector unsigned short, vector unsigned char, const int);
23513 @exdent vector signed int vec_permx (vector signed int, vector signed int,
23514 vector unsigned char, const int);
23515 @exdent vector unsigned int vec_permx (vector unsigned int,
23516 vector unsigned int, vector unsigned char, const int);
23517 @exdent vector signed long long vec_permx (vector signed long long,
23518 vector signed long long, vector unsigned char, const int);
23519 @exdent vector unsigned long long vec_permx (vector unsigned long long,
23520 vector unsigned long long, vector unsigned char, const int);
23521 @exdent vector float (vector float, vector float, vector unsigned char,
23522 const int);
23523 @exdent vector double (vector double, vector double, vector unsigned char,
23524 const int);
23525 @end smallexample
23527 Perform a partial permute of the first two arguments, which form a 32-byte
23528 section of an emulated vector up to 256 bytes wide, using the partial permute
23529 control vector in the third argument.  The fourth argument (constrained to
23530 values of 0-7) identifies which 32-byte section of the emulated vector is
23531 contained in the first two arguments.
23532 @findex vec_permx
23534 @smallexample
23535 @exdent vector unsigned long long int
23536 @exdent vec_pext (vector unsigned long long int, vector unsigned long long int);
23537 @end smallexample
23538 Perform a vector parallel bit extract operation, as if implemented by
23539 the @code{vpextd} instruction.
23540 @findex vec_pext
23542 @smallexample
23543 @exdent vector unsigned char vec_stril (vector unsigned char);
23544 @exdent vector signed char vec_stril (vector signed char);
23545 @exdent vector unsigned short vec_stril (vector unsigned short);
23546 @exdent vector signed short vec_stril (vector signed short);
23547 @end smallexample
23548 Isolate the left-most non-zero elements of the incoming vector argument,
23549 replacing all elements to the right of the left-most zero element
23550 found within the argument with zero.  The typical implementation uses
23551 the @code{vstribl} or @code{vstrihl} instruction on big-endian targets
23552 and uses the @code{vstribr} or @code{vstrihr} instruction on
23553 little-endian targets.
23554 @findex vec_stril
23556 @smallexample
23557 @exdent int vec_stril_p (vector unsigned char);
23558 @exdent int vec_stril_p (vector signed char);
23559 @exdent int short vec_stril_p (vector unsigned short);
23560 @exdent int vec_stril_p (vector signed short);
23561 @end smallexample
23562 Return a non-zero value if and only if the argument contains a zero
23563 element.  The typical implementation uses
23564 the @code{vstribl.} or @code{vstrihl.} instruction on big-endian targets
23565 and uses the @code{vstribr.} or @code{vstrihr.} instruction on
23566 little-endian targets.  Choose this built-in to check for presence of
23567 zero element if the same argument is also passed to @code{vec_stril}.
23568 @findex vec_stril_p
23570 @smallexample
23571 @exdent vector unsigned char vec_strir (vector unsigned char);
23572 @exdent vector signed char vec_strir (vector signed char);
23573 @exdent vector unsigned short vec_strir (vector unsigned short);
23574 @exdent vector signed short vec_strir (vector signed short);
23575 @end smallexample
23576 Isolate the right-most non-zero elements of the incoming vector argument,
23577 replacing all elements to the left of the right-most zero element
23578 found within the argument with zero.  The typical implementation uses
23579 the @code{vstribr} or @code{vstrihr} instruction on big-endian targets
23580 and uses the @code{vstribl} or @code{vstrihl} instruction on
23581 little-endian targets.
23582 @findex vec_strir
23584 @smallexample
23585 @exdent int vec_strir_p (vector unsigned char);
23586 @exdent int vec_strir_p (vector signed char);
23587 @exdent int short vec_strir_p (vector unsigned short);
23588 @exdent int vec_strir_p (vector signed short);
23589 @end smallexample
23590 Return a non-zero value if and only if the argument contains a zero
23591 element.  The typical implementation uses
23592 the @code{vstribr.} or @code{vstrihr.} instruction on big-endian targets
23593 and uses the @code{vstribl.} or @code{vstrihl.} instruction on
23594 little-endian targets.  Choose this built-in to check for presence of
23595 zero element if the same argument is also passed to @code{vec_strir}.
23596 @findex vec_strir_p
23598 @smallexample
23599 @exdent vector unsigned char
23600 @exdent vec_ternarylogic (vector unsigned char, vector unsigned char,
23601             vector unsigned char, const unsigned int);
23602 @exdent vector unsigned short
23603 @exdent vec_ternarylogic (vector unsigned short, vector unsigned short,
23604             vector unsigned short, const unsigned int);
23605 @exdent vector unsigned int
23606 @exdent vec_ternarylogic (vector unsigned int, vector unsigned int,
23607             vector unsigned int, const unsigned int);
23608 @exdent vector unsigned long long int
23609 @exdent vec_ternarylogic (vector unsigned long long int, vector unsigned long long int,
23610             vector unsigned long long int, const unsigned int);
23611 @exdent vector unsigned __int128
23612 @exdent vec_ternarylogic (vector unsigned __int128, vector unsigned __int128,
23613             vector unsigned __int128, const unsigned int);
23614 @end smallexample
23615 Perform a 128-bit vector evaluate operation, as if implemented by the
23616 @code{xxeval} instruction.  The fourth argument must be a literal
23617 integer value between 0 and 255 inclusive.
23618 @findex vec_ternarylogic
23620 @smallexample
23621 @exdent vector unsigned char vec_genpcvm (vector unsigned char, const int);
23622 @exdent vector unsigned short vec_genpcvm (vector unsigned short, const int);
23623 @exdent vector unsigned int vec_genpcvm (vector unsigned int, const int);
23624 @exdent vector unsigned int vec_genpcvm (vector unsigned long long int,
23625                                          const int);
23626 @end smallexample
23628 Vector Integer Multiply/Divide/Modulo
23630 @smallexample
23631 @exdent vector signed int
23632 @exdent vec_mulh (vector signed int @var{a}, vector signed int @var{b});
23633 @exdent vector unsigned int
23634 @exdent vec_mulh (vector unsigned int @var{a}, vector unsigned int @var{b});
23635 @end smallexample
23637 For each integer value @code{i} from 0 to 3, do the following. The integer
23638 value in word element @code{i} of a is multiplied by the integer value in word
23639 element @code{i} of b. The high-order 32 bits of the 64-bit product are placed
23640 into word element @code{i} of the vector returned.
23642 @smallexample
23643 @exdent vector signed long long
23644 @exdent vec_mulh (vector signed long long @var{a}, vector signed long long @var{b});
23645 @exdent vector unsigned long long
23646 @exdent vec_mulh (vector unsigned long long @var{a}, vector unsigned long long @var{b});
23647 @end smallexample
23649 For each integer value @code{i} from 0 to 1, do the following. The integer
23650 value in doubleword element @code{i} of a is multiplied by the integer value in
23651 doubleword element @code{i} of b. The high-order 64 bits of the 128-bit product
23652 are placed into doubleword element @code{i} of the vector returned.
23654 @smallexample
23655 @exdent vector unsigned long long
23656 @exdent vec_mul (vector unsigned long long @var{a}, vector unsigned long long @var{b});
23657 @exdent vector signed long long
23658 @exdent vec_mul (vector signed long long @var{a}, vector signed long long @var{b});
23659 @end smallexample
23661 For each integer value @code{i} from 0 to 1, do the following. The integer
23662 value in doubleword element @code{i} of a is multiplied by the integer value in
23663 doubleword element @code{i} of b. The low-order 64 bits of the 128-bit product
23664 are placed into doubleword element @code{i} of the vector returned.
23666 @smallexample
23667 @exdent vector signed int
23668 @exdent vec_div (vector signed int @var{a}, vector signed int @var{b});
23669 @exdent vector unsigned int
23670 @exdent vec_div (vector unsigned int @var{a}, vector unsigned int @var{b});
23671 @end smallexample
23673 For each integer value @code{i} from 0 to 3, do the following. The integer in
23674 word element @code{i} of a is divided by the integer in word element @code{i}
23675 of b. The unique integer quotient is placed into the word element @code{i} of
23676 the vector returned. If an attempt is made to perform any of the divisions
23677 <anything> Ã· 0 then the quotient is undefined.
23679 @smallexample
23680 @exdent vector signed long long
23681 @exdent vec_div (vector signed long long @var{a}, vector signed long long @var{b});
23682 @exdent vector unsigned long long
23683 @exdent vec_div (vector unsigned long long @var{a}, vector unsigned long long @var{b});
23684 @end smallexample
23686 For each integer value @code{i} from 0 to 1, do the following. The integer in
23687 doubleword element @code{i} of a is divided by the integer in doubleword
23688 element @code{i} of b. The unique integer quotient is placed into the
23689 doubleword element @code{i} of the vector returned. If an attempt is made to
23690 perform any of the divisions 0x8000_0000_0000_0000 Ã· -1 or <anything> Ã· 0 then
23691 the quotient is undefined.
23693 @smallexample
23694 @exdent vector signed int
23695 @exdent vec_dive (vector signed int @var{a}, vector signed int @var{b});
23696 @exdent vector unsigned int
23697 @exdent vec_dive (vector unsigned int @var{a}, vector unsigned int @var{b});
23698 @end smallexample
23700 For each integer value @code{i} from 0 to 3, do the following. The integer in
23701 word element @code{i} of a is shifted left by 32 bits, then divided by the
23702 integer in word element @code{i} of b. The unique integer quotient is placed
23703 into the word element @code{i} of the vector returned. If the quotient cannot
23704 be represented in 32 bits, or if an attempt is made to perform any of the
23705 divisions <anything> Ã· 0 then the quotient is undefined.
23707 @smallexample
23708 @exdent vector signed long long
23709 @exdent vec_dive (vector signed long long @var{a}, vector signed long long @var{b});
23710 @exdent vector unsigned long long
23711 @exdent vec_dive (vector unsigned long long @var{a}, vector unsigned long long @var{b});
23712 @end smallexample
23714 For each integer value @code{i} from 0 to 1, do the following. The integer in
23715 doubleword element @code{i} of a is shifted left by 64 bits, then divided by
23716 the integer in doubleword element @code{i} of b. The unique integer quotient is
23717 placed into the doubleword element @code{i} of the vector returned. If the
23718 quotient cannot be represented in 64 bits, or if an attempt is made to perform
23719 <anything> Ã· 0 then the quotient is undefined.
23721 @smallexample
23722 @exdent vector signed int
23723 @exdent vec_mod (vector signed int @var{a}, vector signed int @var{b});
23724 @exdent vector unsigned int
23725 @exdent vec_mod (vector unsigned int @var{a}, vector unsigned int @var{b});
23726 @end smallexample
23728 For each integer value @code{i} from 0 to 3, do the following. The integer in
23729 word element @code{i} of a is divided by the integer in word element @code{i}
23730 of b. The unique integer remainder is placed into the word element @code{i} of
23731 the vector returned.  If an attempt is made to perform any of the divisions
23732 0x8000_0000 Ã· -1 or <anything> Ã· 0 then the remainder is undefined.
23734 @smallexample
23735 @exdent vector signed long long
23736 @exdent vec_mod (vector signed long long @var{a}, vector signed long long @var{b});
23737 @exdent vector unsigned long long
23738 @exdent vec_mod (vector unsigned long long @var{a}, vector unsigned long long @var{b});
23739 @end smallexample
23741 For each integer value @code{i} from 0 to 1, do the following. The integer in
23742 doubleword element @code{i} of a is divided by the integer in doubleword
23743 element @code{i} of b. The unique integer remainder is placed into the
23744 doubleword element @code{i} of the vector returned. If an attempt is made to
23745 perform <anything> Ã· 0 then the remainder is undefined.
23747 Generate PCV from specified Mask size, as if implemented by the
23748 @code{xxgenpcvbm}, @code{xxgenpcvhm}, @code{xxgenpcvwm} instructions, where
23749 immediate value is either 0, 1, 2 or 3.
23750 @findex vec_genpcvm
23752 @smallexample
23753 @exdent vector unsigned __int128 vec_rl (vector unsigned __int128 @var{A},
23754                                          vector unsigned __int128 @var{B});
23755 @exdent vector signed __int128 vec_rl (vector signed __int128 @var{A},
23756                                        vector unsigned __int128 @var{B});
23757 @end smallexample
23759 Result value: Each element of @var{R} is obtained by rotating the corresponding element
23760 of @var{A} left by the number of bits specified by the corresponding element of @var{B}.
23763 @smallexample
23764 @exdent vector unsigned __int128 vec_rlmi (vector unsigned __int128,
23765                                            vector unsigned __int128,
23766                                            vector unsigned __int128);
23767 @exdent vector signed __int128 vec_rlmi (vector signed __int128,
23768                                          vector signed __int128,
23769                                          vector unsigned __int128);
23770 @end smallexample
23772 Returns the result of rotating the first input and inserting it under mask
23773 into the second input.  The first bit in the mask, the last bit in the mask are
23774 obtained from the two 7-bit fields bits [108:115] and bits [117:123]
23775 respectively of the second input.  The shift is obtained from the third input
23776 in the 7-bit field [125:131] where all bits counted from zero at the left.
23778 @smallexample
23779 @exdent vector unsigned __int128 vec_rlnm (vector unsigned __int128,
23780                                            vector unsigned __int128,
23781                                            vector unsigned __int128);
23782 @exdent vector signed __int128 vec_rlnm (vector signed __int128,
23783                                          vector unsigned __int128,
23784                                          vector unsigned __int128);
23785 @end smallexample
23787 Returns the result of rotating the first input and ANDing it with a mask.  The
23788 first bit in the mask and the last bit in the mask are obtained from the two
23789 7-bit fields bits [117:123] and bits [125:131] respectively of the second
23790 input.  The shift is obtained from the third input in the 7-bit field bits
23791 [125:131] where all bits counted from zero at the left.
23793 @smallexample
23794 @exdent vector unsigned __int128 vec_sl(vector unsigned __int128 @var{A}, vector unsigned __int128 @var{B});
23795 @exdent vector signed __int128 vec_sl(vector signed __int128 @var{A}, vector unsigned __int128 @var{B});
23796 @end smallexample
23798 Result value: Each element of @var{R} is obtained by shifting the corresponding element of
23799 @var{A} left by the number of bits specified by the corresponding element of @var{B}.
23801 @smallexample
23802 @exdent vector unsigned __int128 vec_sr(vector unsigned __int128 @var{A}, vector unsigned __int128 @var{B});
23803 @exdent vector signed __int128 vec_sr(vector signed __int128 @var{A}, vector unsigned __int128 @var{B});
23804 @end smallexample
23806 Result value: Each element of @var{R} is obtained by shifting the corresponding element of
23807 @var{A} right by the number of bits specified by the corresponding element of @var{B}.
23809 @smallexample
23810 @exdent vector unsigned __int128 vec_sra(vector unsigned __int128 @var{A}, vector unsigned __int128 @var{B});
23811 @exdent vector signed __int128 vec_sra(vector signed __int128 @var{A}, vector unsigned __int128 @var{B});
23812 @end smallexample
23814 Result value: Each element of @var{R} is obtained by arithmetic shifting the corresponding
23815 element of @var{A} right by the number of bits specified by the corresponding element of @var{B}.
23817 @smallexample
23818 @exdent vector unsigned __int128 vec_mule (vector unsigned long long,
23819                                            vector unsigned long long);
23820 @exdent vector signed __int128 vec_mule (vector signed long long,
23821                                          vector signed long long);
23822 @end smallexample
23824 Returns a vector containing a 128-bit integer result of multiplying the even
23825 doubleword elements of the two inputs.
23827 @smallexample
23828 @exdent vector unsigned __int128 vec_mulo (vector unsigned long long,
23829                                            vector unsigned long long);
23830 @exdent vector signed __int128 vec_mulo (vector signed long long,
23831                                          vector signed long long);
23832 @end smallexample
23834 Returns a vector containing a 128-bit integer result of multiplying the odd
23835 doubleword elements of the two inputs.
23837 @smallexample
23838 @exdent vector unsigned __int128 vec_div (vector unsigned __int128,
23839                                           vector unsigned __int128);
23840 @exdent vector signed __int128 vec_div (vector signed __int128,
23841                                         vector signed __int128);
23842 @end smallexample
23844 Returns the result of dividing the first operand by the second operand. An
23845 attempt to divide any value by zero or to divide the most negative signed
23846 128-bit integer by negative one results in an undefined value.
23848 @smallexample
23849 @exdent vector unsigned __int128 vec_dive (vector unsigned __int128,
23850                                            vector unsigned __int128);
23851 @exdent vector signed __int128 vec_dive (vector signed __int128,
23852                                          vector signed __int128);
23853 @end smallexample
23855 The result is produced by shifting the first input left by 128 bits and
23856 dividing by the second.  If an attempt is made to divide by zero or the result
23857 is larger than 128 bits, the result is undefined.
23859 @smallexample
23860 @exdent vector unsigned __int128 vec_mod (vector unsigned __int128,
23861                                           vector unsigned __int128);
23862 @exdent vector signed __int128 vec_mod (vector signed __int128,
23863                                         vector signed __int128);
23864 @end smallexample
23866 The result is the modulo result of dividing the first input  by the second
23867 input.
23869 The following builtins perform 128-bit vector comparisons.  The
23870 @code{vec_all_xx}, @code{vec_any_xx}, and @code{vec_cmpxx}, where @code{xx} is
23871 one of the operations @code{eq, ne, gt, lt, ge, le} perform pairwise
23872 comparisons between the elements at the same positions within their two vector
23873 arguments.  The @code{vec_all_xx}function returns a non-zero value if and only
23874 if all pairwise comparisons are true.  The @code{vec_any_xx} function returns
23875 a non-zero value if and only if at least one pairwise comparison is true.  The
23876 @code{vec_cmpxx}function returns a vector of the same type as its two
23877 arguments, within which each element consists of all ones to denote that
23878 specified logical comparison of the corresponding elements was true.
23879 Otherwise, the element of the returned vector contains all zeros.
23881 @smallexample
23882 vector bool __int128 vec_cmpeq (vector signed __int128, vector signed __int128);
23883 vector bool __int128 vec_cmpeq (vector unsigned __int128, vector unsigned __int128);
23884 vector bool __int128 vec_cmpne (vector signed __int128, vector signed __int128);
23885 vector bool __int128 vec_cmpne (vector unsigned __int128, vector unsigned __int128);
23886 vector bool __int128 vec_cmpgt (vector signed __int128, vector signed __int128);
23887 vector bool __int128 vec_cmpgt (vector unsigned __int128, vector unsigned __int128);
23888 vector bool __int128 vec_cmplt (vector signed __int128, vector signed __int128);
23889 vector bool __int128 vec_cmplt (vector unsigned __int128, vector unsigned __int128);
23890 vector bool __int128 vec_cmpge (vector signed __int128, vector signed __int128);
23891 vector bool __int128 vec_cmpge (vector unsigned __int128, vector unsigned __int128);
23892 vector bool __int128 vec_cmple (vector signed __int128, vector signed __int128);
23893 vector bool __int128 vec_cmple (vector unsigned __int128, vector unsigned __int128);
23895 int vec_all_eq (vector signed __int128, vector signed __int128);
23896 int vec_all_eq (vector unsigned __int128, vector unsigned __int128);
23897 int vec_all_ne (vector signed __int128, vector signed __int128);
23898 int vec_all_ne (vector unsigned __int128, vector unsigned __int128);
23899 int vec_all_gt (vector signed __int128, vector signed __int128);
23900 int vec_all_gt (vector unsigned __int128, vector unsigned __int128);
23901 int vec_all_lt (vector signed __int128, vector signed __int128);
23902 int vec_all_lt (vector unsigned __int128, vector unsigned __int128);
23903 int vec_all_ge (vector signed __int128, vector signed __int128);
23904 int vec_all_ge (vector unsigned __int128, vector unsigned __int128);
23905 int vec_all_le (vector signed __int128, vector signed __int128);
23906 int vec_all_le (vector unsigned __int128, vector unsigned __int128);
23908 int vec_any_eq (vector signed __int128, vector signed __int128);
23909 int vec_any_eq (vector unsigned __int128, vector unsigned __int128);
23910 int vec_any_ne (vector signed __int128, vector signed __int128);
23911 int vec_any_ne (vector unsigned __int128, vector unsigned __int128);
23912 int vec_any_gt (vector signed __int128, vector signed __int128);
23913 int vec_any_gt (vector unsigned __int128, vector unsigned __int128);
23914 int vec_any_lt (vector signed __int128, vector signed __int128);
23915 int vec_any_lt (vector unsigned __int128, vector unsigned __int128);
23916 int vec_any_ge (vector signed __int128, vector signed __int128);
23917 int vec_any_ge (vector unsigned __int128, vector unsigned __int128);
23918 int vec_any_le (vector signed __int128, vector signed __int128);
23919 int vec_any_le (vector unsigned __int128, vector unsigned __int128);
23920 @end smallexample
23923 @node PowerPC Hardware Transactional Memory Built-in Functions
23924 @subsection PowerPC Hardware Transactional Memory Built-in Functions
23925 GCC provides two interfaces for accessing the Hardware Transactional
23926 Memory (HTM) instructions available on some of the PowerPC family
23927 of processors (eg, POWER8).  The two interfaces come in a low level
23928 interface, consisting of built-in functions specific to PowerPC and a
23929 higher level interface consisting of inline functions that are common
23930 between PowerPC and S/390.
23932 @subsubsection PowerPC HTM Low Level Built-in Functions
23934 The following low level built-in functions are available with
23935 @option{-mhtm} or @option{-mcpu=CPU} where CPU is `power8' or later.
23936 They all generate the machine instruction that is part of the name.
23938 The HTM builtins (with the exception of @code{__builtin_tbegin}) return
23939 the full 4-bit condition register value set by their associated hardware
23940 instruction.  The header file @code{htmintrin.h} defines some macros that can
23941 be used to decipher the return value.  The @code{__builtin_tbegin} builtin
23942 returns a simple @code{true} or @code{false} value depending on whether a transaction was
23943 successfully started or not.  The arguments of the builtins match exactly the
23944 type and order of the associated hardware instruction's operands, except for
23945 the @code{__builtin_tcheck} builtin, which does not take any input arguments.
23946 Refer to the ISA manual for a description of each instruction's operands.
23948 @smallexample
23949 unsigned int __builtin_tbegin (unsigned int);
23950 unsigned int __builtin_tend (unsigned int);
23952 unsigned int __builtin_tabort (unsigned int);
23953 unsigned int __builtin_tabortdc (unsigned int, unsigned int, unsigned int);
23954 unsigned int __builtin_tabortdci (unsigned int, unsigned int, int);
23955 unsigned int __builtin_tabortwc (unsigned int, unsigned int, unsigned int);
23956 unsigned int __builtin_tabortwci (unsigned int, unsigned int, int);
23958 unsigned int __builtin_tcheck (void);
23959 unsigned int __builtin_treclaim (unsigned int);
23960 unsigned int __builtin_trechkpt (void);
23961 unsigned int __builtin_tsr (unsigned int);
23962 @end smallexample
23964 In addition to the above HTM built-ins, we have added built-ins for
23965 some common extended mnemonics of the HTM instructions:
23967 @smallexample
23968 unsigned int __builtin_tendall (void);
23969 unsigned int __builtin_tresume (void);
23970 unsigned int __builtin_tsuspend (void);
23971 @end smallexample
23973 Note that the semantics of the above HTM builtins are required to mimic
23974 the locking semantics used for critical sections.  Builtins that are used
23975 to create a new transaction or restart a suspended transaction must have
23976 lock acquisition like semantics while those builtins that end or suspend a
23977 transaction must have lock release like semantics.  Specifically, this must
23978 mimic lock semantics as specified by C++11, for example: Lock acquisition is
23979 as-if an execution of __atomic_exchange_n(&globallock,1,__ATOMIC_ACQUIRE)
23980 that returns 0, and lock release is as-if an execution of
23981 __atomic_store(&globallock,0,__ATOMIC_RELEASE), with globallock being an
23982 implicit implementation-defined lock used for all transactions.  The HTM
23983 instructions associated with with the builtins inherently provide the
23984 correct acquisition and release hardware barriers required.  However,
23985 the compiler must also be prohibited from moving loads and stores across
23986 the builtins in a way that would violate their semantics.  This has been
23987 accomplished by adding memory barriers to the associated HTM instructions
23988 (which is a conservative approach to provide acquire and release semantics).
23989 Earlier versions of the compiler did not treat the HTM instructions as
23990 memory barriers.  A @code{__TM_FENCE__} macro has been added, which can
23991 be used to determine whether the current compiler treats HTM instructions
23992 as memory barriers or not.  This allows the user to explicitly add memory
23993 barriers to their code when using an older version of the compiler.
23995 The following set of built-in functions are available to gain access
23996 to the HTM specific special purpose registers.
23998 @smallexample
23999 unsigned long __builtin_get_texasr (void);
24000 unsigned long __builtin_get_texasru (void);
24001 unsigned long __builtin_get_tfhar (void);
24002 unsigned long __builtin_get_tfiar (void);
24004 void __builtin_set_texasr (unsigned long);
24005 void __builtin_set_texasru (unsigned long);
24006 void __builtin_set_tfhar (unsigned long);
24007 void __builtin_set_tfiar (unsigned long);
24008 @end smallexample
24010 Example usage of these low level built-in functions may look like:
24012 @smallexample
24013 #include <htmintrin.h>
24015 int num_retries = 10;
24017 while (1)
24018   @{
24019     if (__builtin_tbegin (0))
24020       @{
24021         /* Transaction State Initiated.  */
24022         if (is_locked (lock))
24023           __builtin_tabort (0);
24024         ... transaction code...
24025         __builtin_tend (0);
24026         break;
24027       @}
24028     else
24029       @{
24030         /* Transaction State Failed.  Use locks if the transaction
24031            failure is "persistent" or we've tried too many times.  */
24032         if (num_retries-- <= 0
24033             || _TEXASRU_FAILURE_PERSISTENT (__builtin_get_texasru ()))
24034           @{
24035             acquire_lock (lock);
24036             ... non transactional fallback path...
24037             release_lock (lock);
24038             break;
24039           @}
24040       @}
24041   @}
24042 @end smallexample
24044 One final built-in function has been added that returns the value of
24045 the 2-bit Transaction State field of the Machine Status Register (MSR)
24046 as stored in @code{CR0}.
24048 @smallexample
24049 unsigned long __builtin_ttest (void)
24050 @end smallexample
24052 This built-in can be used to determine the current transaction state
24053 using the following code example:
24055 @smallexample
24056 #include <htmintrin.h>
24058 unsigned char tx_state = _HTM_STATE (__builtin_ttest ());
24060 if (tx_state == _HTM_TRANSACTIONAL)
24061   @{
24062     /* Code to use in transactional state.  */
24063   @}
24064 else if (tx_state == _HTM_NONTRANSACTIONAL)
24065   @{
24066     /* Code to use in non-transactional state.  */
24067   @}
24068 else if (tx_state == _HTM_SUSPENDED)
24069   @{
24070     /* Code to use in transaction suspended state.  */
24071   @}
24072 @end smallexample
24074 @subsubsection PowerPC HTM High Level Inline Functions
24076 The following high level HTM interface is made available by including
24077 @code{<htmxlintrin.h>} and using @option{-mhtm} or @option{-mcpu=CPU}
24078 where CPU is `power8' or later.  This interface is common between PowerPC
24079 and S/390, allowing users to write one HTM source implementation that
24080 can be compiled and executed on either system.
24082 @smallexample
24083 long __TM_simple_begin (void);
24084 long __TM_begin (void* const TM_buff);
24085 long __TM_end (void);
24086 void __TM_abort (void);
24087 void __TM_named_abort (unsigned char const code);
24088 void __TM_resume (void);
24089 void __TM_suspend (void);
24091 long __TM_is_user_abort (void* const TM_buff);
24092 long __TM_is_named_user_abort (void* const TM_buff, unsigned char *code);
24093 long __TM_is_illegal (void* const TM_buff);
24094 long __TM_is_footprint_exceeded (void* const TM_buff);
24095 long __TM_nesting_depth (void* const TM_buff);
24096 long __TM_is_nested_too_deep(void* const TM_buff);
24097 long __TM_is_conflict(void* const TM_buff);
24098 long __TM_is_failure_persistent(void* const TM_buff);
24099 long __TM_failure_address(void* const TM_buff);
24100 long long __TM_failure_code(void* const TM_buff);
24101 @end smallexample
24103 Using these common set of HTM inline functions, we can create
24104 a more portable version of the HTM example in the previous
24105 section that will work on either PowerPC or S/390:
24107 @smallexample
24108 #include <htmxlintrin.h>
24110 int num_retries = 10;
24111 TM_buff_type TM_buff;
24113 while (1)
24114   @{
24115     if (__TM_begin (TM_buff) == _HTM_TBEGIN_STARTED)
24116       @{
24117         /* Transaction State Initiated.  */
24118         if (is_locked (lock))
24119           __TM_abort ();
24120         ... transaction code...
24121         __TM_end ();
24122         break;
24123       @}
24124     else
24125       @{
24126         /* Transaction State Failed.  Use locks if the transaction
24127            failure is "persistent" or we've tried too many times.  */
24128         if (num_retries-- <= 0
24129             || __TM_is_failure_persistent (TM_buff))
24130           @{
24131             acquire_lock (lock);
24132             ... non transactional fallback path...
24133             release_lock (lock);
24134             break;
24135           @}
24136       @}
24137   @}
24138 @end smallexample
24140 @node PowerPC Atomic Memory Operation Functions
24141 @subsection PowerPC Atomic Memory Operation Functions
24142 ISA 3.0 of the PowerPC added new atomic memory operation (amo)
24143 instructions.  GCC provides support for these instructions in 64-bit
24144 environments.  All of the functions are declared in the include file
24145 @code{amo.h}.
24147 The functions supported are:
24149 @smallexample
24150 #include <amo.h>
24152 uint32_t amo_lwat_add (uint32_t *, uint32_t);
24153 uint32_t amo_lwat_xor (uint32_t *, uint32_t);
24154 uint32_t amo_lwat_ior (uint32_t *, uint32_t);
24155 uint32_t amo_lwat_and (uint32_t *, uint32_t);
24156 uint32_t amo_lwat_umax (uint32_t *, uint32_t);
24157 uint32_t amo_lwat_umin (uint32_t *, uint32_t);
24158 uint32_t amo_lwat_swap (uint32_t *, uint32_t);
24160 int32_t amo_lwat_sadd (int32_t *, int32_t);
24161 int32_t amo_lwat_smax (int32_t *, int32_t);
24162 int32_t amo_lwat_smin (int32_t *, int32_t);
24163 int32_t amo_lwat_sswap (int32_t *, int32_t);
24165 uint64_t amo_ldat_add (uint64_t *, uint64_t);
24166 uint64_t amo_ldat_xor (uint64_t *, uint64_t);
24167 uint64_t amo_ldat_ior (uint64_t *, uint64_t);
24168 uint64_t amo_ldat_and (uint64_t *, uint64_t);
24169 uint64_t amo_ldat_umax (uint64_t *, uint64_t);
24170 uint64_t amo_ldat_umin (uint64_t *, uint64_t);
24171 uint64_t amo_ldat_swap (uint64_t *, uint64_t);
24173 int64_t amo_ldat_sadd (int64_t *, int64_t);
24174 int64_t amo_ldat_smax (int64_t *, int64_t);
24175 int64_t amo_ldat_smin (int64_t *, int64_t);
24176 int64_t amo_ldat_sswap (int64_t *, int64_t);
24178 void amo_stwat_add (uint32_t *, uint32_t);
24179 void amo_stwat_xor (uint32_t *, uint32_t);
24180 void amo_stwat_ior (uint32_t *, uint32_t);
24181 void amo_stwat_and (uint32_t *, uint32_t);
24182 void amo_stwat_umax (uint32_t *, uint32_t);
24183 void amo_stwat_umin (uint32_t *, uint32_t);
24185 void amo_stwat_sadd (int32_t *, int32_t);
24186 void amo_stwat_smax (int32_t *, int32_t);
24187 void amo_stwat_smin (int32_t *, int32_t);
24189 void amo_stdat_add (uint64_t *, uint64_t);
24190 void amo_stdat_xor (uint64_t *, uint64_t);
24191 void amo_stdat_ior (uint64_t *, uint64_t);
24192 void amo_stdat_and (uint64_t *, uint64_t);
24193 void amo_stdat_umax (uint64_t *, uint64_t);
24194 void amo_stdat_umin (uint64_t *, uint64_t);
24196 void amo_stdat_sadd (int64_t *, int64_t);
24197 void amo_stdat_smax (int64_t *, int64_t);
24198 void amo_stdat_smin (int64_t *, int64_t);
24199 @end smallexample
24201 @node PowerPC Matrix-Multiply Assist Built-in Functions
24202 @subsection PowerPC Matrix-Multiply Assist Built-in Functions
24203 ISA 3.1 of the PowerPC added new Matrix-Multiply Assist (MMA) instructions.
24204 GCC provides support for these instructions through the following built-in
24205 functions which are enabled with the @code{-mmma} option.  The vec_t type
24206 below is defined to be a normal vector unsigned char type.  The uint2, uint4
24207 and uint8 parameters are 2-bit, 4-bit and 8-bit unsigned integer constants
24208 respectively.  The compiler will verify that they are constants and that
24209 their values are within range.
24211 The built-in functions supported are:
24213 @smallexample
24214 void __builtin_mma_xvi4ger8 (__vector_quad *, vec_t, vec_t);
24215 void __builtin_mma_xvi8ger4 (__vector_quad *, vec_t, vec_t);
24216 void __builtin_mma_xvi16ger2 (__vector_quad *, vec_t, vec_t);
24217 void __builtin_mma_xvi16ger2s (__vector_quad *, vec_t, vec_t);
24218 void __builtin_mma_xvf16ger2 (__vector_quad *, vec_t, vec_t);
24219 void __builtin_mma_xvbf16ger2 (__vector_quad *, vec_t, vec_t);
24220 void __builtin_mma_xvf32ger (__vector_quad *, vec_t, vec_t);
24222 void __builtin_mma_xvi4ger8pp (__vector_quad *, vec_t, vec_t);
24223 void __builtin_mma_xvi8ger4pp (__vector_quad *, vec_t, vec_t);
24224 void __builtin_mma_xvi8ger4spp(__vector_quad *, vec_t, vec_t);
24225 void __builtin_mma_xvi16ger2pp (__vector_quad *, vec_t, vec_t);
24226 void __builtin_mma_xvi16ger2spp (__vector_quad *, vec_t, vec_t);
24227 void __builtin_mma_xvf16ger2pp (__vector_quad *, vec_t, vec_t);
24228 void __builtin_mma_xvf16ger2pn (__vector_quad *, vec_t, vec_t);
24229 void __builtin_mma_xvf16ger2np (__vector_quad *, vec_t, vec_t);
24230 void __builtin_mma_xvf16ger2nn (__vector_quad *, vec_t, vec_t);
24231 void __builtin_mma_xvbf16ger2pp (__vector_quad *, vec_t, vec_t);
24232 void __builtin_mma_xvbf16ger2pn (__vector_quad *, vec_t, vec_t);
24233 void __builtin_mma_xvbf16ger2np (__vector_quad *, vec_t, vec_t);
24234 void __builtin_mma_xvbf16ger2nn (__vector_quad *, vec_t, vec_t);
24235 void __builtin_mma_xvf32gerpp (__vector_quad *, vec_t, vec_t);
24236 void __builtin_mma_xvf32gerpn (__vector_quad *, vec_t, vec_t);
24237 void __builtin_mma_xvf32gernp (__vector_quad *, vec_t, vec_t);
24238 void __builtin_mma_xvf32gernn (__vector_quad *, vec_t, vec_t);
24240 void __builtin_mma_pmxvi4ger8 (__vector_quad *, vec_t, vec_t, uint4, uint4, uint8);
24241 void __builtin_mma_pmxvi4ger8pp (__vector_quad *, vec_t, vec_t, uint4, uint4, uint8);
24243 void __builtin_mma_pmxvi8ger4 (__vector_quad *, vec_t, vec_t, uint4, uint4, uint4);
24244 void __builtin_mma_pmxvi8ger4pp (__vector_quad *, vec_t, vec_t, uint4, uint4, uint4);
24245 void __builtin_mma_pmxvi8ger4spp(__vector_quad *, vec_t, vec_t, uint4, uint4, uint4);
24247 void __builtin_mma_pmxvi16ger2 (__vector_quad *, vec_t, vec_t, uint4, uint4, uint2);
24248 void __builtin_mma_pmxvi16ger2s (__vector_quad *, vec_t, vec_t, uint4, uint4, uint2);
24249 void __builtin_mma_pmxvf16ger2 (__vector_quad *, vec_t, vec_t, uint4, uint4, uint2);
24250 void __builtin_mma_pmxvbf16ger2 (__vector_quad *, vec_t, vec_t, uint4, uint4, uint2);
24252 void __builtin_mma_pmxvi16ger2pp (__vector_quad *, vec_t, vec_t, uint4, uint4, uint2);
24253 void __builtin_mma_pmxvi16ger2spp (__vector_quad *, vec_t, vec_t, uint4, uint4, uint2);
24254 void __builtin_mma_pmxvf16ger2pp (__vector_quad *, vec_t, vec_t, uint4, uint4, uint2);
24255 void __builtin_mma_pmxvf16ger2pn (__vector_quad *, vec_t, vec_t, uint4, uint4, uint2);
24256 void __builtin_mma_pmxvf16ger2np (__vector_quad *, vec_t, vec_t, uint4, uint4, uint2);
24257 void __builtin_mma_pmxvf16ger2nn (__vector_quad *, vec_t, vec_t, uint4, uint4, uint2);
24258 void __builtin_mma_pmxvbf16ger2pp (__vector_quad *, vec_t, vec_t, uint4, uint4, uint2);
24259 void __builtin_mma_pmxvbf16ger2pn (__vector_quad *, vec_t, vec_t, uint4, uint4, uint2);
24260 void __builtin_mma_pmxvbf16ger2np (__vector_quad *, vec_t, vec_t, uint4, uint4, uint2);
24261 void __builtin_mma_pmxvbf16ger2nn (__vector_quad *, vec_t, vec_t, uint4, uint4, uint2);
24263 void __builtin_mma_pmxvf32ger (__vector_quad *, vec_t, vec_t, uint4, uint4);
24264 void __builtin_mma_pmxvf32gerpp (__vector_quad *, vec_t, vec_t, uint4, uint4);
24265 void __builtin_mma_pmxvf32gerpn (__vector_quad *, vec_t, vec_t, uint4, uint4);
24266 void __builtin_mma_pmxvf32gernp (__vector_quad *, vec_t, vec_t, uint4, uint4);
24267 void __builtin_mma_pmxvf32gernn (__vector_quad *, vec_t, vec_t, uint4, uint4);
24269 void __builtin_mma_xvf64ger (__vector_quad *, __vector_pair, vec_t);
24270 void __builtin_mma_xvf64gerpp (__vector_quad *, __vector_pair, vec_t);
24271 void __builtin_mma_xvf64gerpn (__vector_quad *, __vector_pair, vec_t);
24272 void __builtin_mma_xvf64gernp (__vector_quad *, __vector_pair, vec_t);
24273 void __builtin_mma_xvf64gernn (__vector_quad *, __vector_pair, vec_t);
24275 void __builtin_mma_pmxvf64ger (__vector_quad *, __vector_pair, vec_t, uint4, uint2);
24276 void __builtin_mma_pmxvf64gerpp (__vector_quad *, __vector_pair, vec_t, uint4, uint2);
24277 void __builtin_mma_pmxvf64gerpn (__vector_quad *, __vector_pair, vec_t, uint4, uint2);
24278 void __builtin_mma_pmxvf64gernp (__vector_quad *, __vector_pair, vec_t, uint4, uint2);
24279 void __builtin_mma_pmxvf64gernn (__vector_quad *, __vector_pair, vec_t, uint4, uint2);
24281 void __builtin_mma_xxmtacc (__vector_quad *);
24282 void __builtin_mma_xxmfacc (__vector_quad *);
24283 void __builtin_mma_xxsetaccz (__vector_quad *);
24285 void __builtin_mma_build_acc (__vector_quad *, vec_t, vec_t, vec_t, vec_t);
24286 void __builtin_mma_disassemble_acc (void *, __vector_quad *);
24288 void __builtin_vsx_build_pair (__vector_pair *, vec_t, vec_t);
24289 void __builtin_vsx_disassemble_pair (void *, __vector_pair *);
24291 vec_t __builtin_vsx_xvcvspbf16 (vec_t);
24292 vec_t __builtin_vsx_xvcvbf16spn (vec_t);
24294 __vector_pair __builtin_vsx_lxvp (size_t, __vector_pair *);
24295 void __builtin_vsx_stxvp (__vector_pair, size_t, __vector_pair *);
24296 @end smallexample
24298 @node PRU Built-in Functions
24299 @subsection PRU Built-in Functions
24301 GCC provides a couple of special builtin functions to aid in utilizing
24302 special PRU instructions.
24304 The built-in functions supported are:
24306 @defbuiltin{void __delay_cycles (constant long long @var{cycles})}
24307 This inserts an instruction sequence that takes exactly @var{cycles}
24308 cycles (between 0 and 0xffffffff) to complete.  The inserted sequence
24309 may use jumps, loops, or no-ops, and does not interfere with any other
24310 instructions.  Note that @var{cycles} must be a compile-time constant
24311 integer - that is, you must pass a number, not a variable that may be
24312 optimized to a constant later.  The number of cycles delayed by this
24313 builtin is exact.
24314 @enddefbuiltin
24316 @defbuiltin{void __halt (void)}
24317 This inserts a HALT instruction to stop processor execution.
24318 @enddefbuiltin
24320 @defbuiltin{{unsigned int} @
24321             __lmbd (unsigned int @var{wordval}, @
24322                     unsigned int @var{bitval})}
24323 This inserts LMBD instruction to calculate the left-most bit with value
24324 @var{bitval} in value @var{wordval}.  Only the least significant bit
24325 of @var{bitval} is taken into account.
24326 @enddefbuiltin
24328 @node RISC-V Built-in Functions
24329 @subsection RISC-V Built-in Functions
24331 These built-in functions are available for the RISC-V family of
24332 processors.
24334 @defbuiltin{{void *} __builtin_thread_pointer (void)}
24335 Returns the value that is currently set in the @samp{tp} register.
24336 @enddefbuiltin
24338 @defbuiltin{void __builtin_riscv_pause (void)}
24339 Generates the @code{pause} (hint) machine instruction.  If the target implements
24340 the Zihintpause extension, it indicates that the current hart should be
24341 temporarily paused or slowed down.
24342 @enddefbuiltin
24344 @node RISC-V Vector Intrinsics
24345 @subsection RISC-V Vector Intrinsics
24347 GCC supports vector intrinsics as specified in version 0.11 of the RISC-V
24348 vector intrinsic specification, which is available at the following link:
24349 @uref{https://github.com/riscv-non-isa/rvv-intrinsic-doc/tree/v0.11.x}.
24350 All of these functions are declared in the include file @file{riscv_vector.h}.
24352 @node CORE-V Built-in Functions
24353 @subsection CORE-V Built-in Functions
24354 For more information on all CORE-V built-ins, please see
24355 @uref{https://github.com/openhwgroup/core-v-sw/blob/master/specifications/corev-builtin-spec.md}
24357 These built-in functions are available for the CORE-V MAC machine
24358 architecture. For more information on CORE-V built-ins, please see
24359 @uref{https://github.com/openhwgroup/core-v-sw/blob/master/specifications/corev-builtin-spec.md#listing-of-multiply-accumulate-builtins-xcvmac}.
24361 @deftypefn {Built-in Function} {int32_t} __builtin_riscv_cv_mac_mac (int32_t, int32_t, int32_t)
24362 Generated assembler @code{cv.mac}
24363 @end deftypefn
24365 @deftypefn {Built-in Function} {int32_t} __builtin_riscv_cv_mac_msu (int32_t, int32_t, int32_t)
24366 Generates the @code{cv.msu} machine instruction.
24367 @end deftypefn
24369 @deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_mac_muluN (uint32_t, uint32_t, uint8_t)
24370 Generates the @code{cv.muluN} machine instruction.
24371 @end deftypefn
24373 @deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_mac_mulhhuN (uint32_t, uint32_t, uint8_t)
24374 Generates the @code{cv.mulhhuN} machine instruction.
24375 @end deftypefn
24377 @deftypefn {Built-in Function} {int32_t} __builtin_riscv_cv_mac_mulsN (int32_t, int32_t, uint8_t)
24378 Generates the @code{cv.mulsN} machine instruction.
24379 @end deftypefn
24381 @deftypefn {Built-in Function} {int32_t} __builtin_riscv_cv_mac_mulhhsN (int32_t, int32_t, uint8_t)
24382 Generates the @code{cv.mulhhsN} machine instruction.
24383 @end deftypefn
24385 @deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_mac_muluRN (uint32_t, uint32_t, uint8_t)
24386 Generates the @code{cv.muluRN} machine instruction.
24387 @end deftypefn
24389 @deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_mac_mulhhuRN (uint32_t, uint32_t, uint8_t)
24390 Generates the @code{cv.mulhhuRN} machine instruction.
24391 @end deftypefn
24393 @deftypefn {Built-in Function} {int32_t} __builtin_riscv_cv_mac_mulsRN (int32_t, int32_t, uint8_t)
24394 Generates the @code{cv.mulsRN} machine instruction.
24395 @end deftypefn
24397 @deftypefn {Built-in Function} {int32_t} __builtin_riscv_cv_mac_mulhhsRN (int32_t, int32_t, uint8_t)
24398 Generates the @code{cv.mulhhsRN} machine instruction.
24399 @end deftypefn
24401 @deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_mac_macuN (uint32_t, uint32_t, uint8_t)
24402 Generates the @code{cv.macuN} machine instruction.
24403 @end deftypefn
24405 @deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_mac_machhuN (uint32_t, uint32_t, uint8_t)
24406 Generates the @code{cv.machhuN} machine instruction.
24407 @end deftypefn
24409 @deftypefn {Built-in Function} {int32_t} __builtin_riscv_cv_mac_macsN (int32_t, int32_t, uint8_t)
24410 Generates the @code{cv.macsN} machine instruction.
24411 @end deftypefn
24413 @deftypefn {Built-in Function} {int32_t} __builtin_riscv_cv_mac_machhsN (int32_t, int32_t, uint8_t)
24414 Generates the @code{cv.machhsN} machine instruction.
24415 @end deftypefn
24417 @deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_mac_macuRN (uint32_t, uint32_t, uint8_t)
24418 Generates the @code{cv.macuRN} machine instruction.
24419 @end deftypefn
24421 @deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_mac_machhuRN (uint32_t, uint32_t, uint8_t)
24422 Generates the @code{cv.machhuRN} machine instruction.
24423 @end deftypefn
24425 @deftypefn {Built-in Function} {int32_t} __builtin_riscv_cv_mac_macsRN (int32_t, int32_t, uint8_t)
24426 Generates the @code{cv.macsRN} machine instruction.
24427 @end deftypefn
24429 @deftypefn {Built-in Function} {int32_t} __builtin_riscv_cv_mac_machhsRN (int32_t, int32_t, uint8_t)
24430 Generates the @code{cv.machhsRN} machine instruction.
24431 @end deftypefn
24433 These built-in functions are available for the CORE-V ALU machine
24434 architecture. For more information on CORE-V built-ins, please see
24435 @uref{https://github.com/openhwgroup/core-v-sw/blob/master/specifications/corev-builtin-spec.md#listing-of-miscellaneous-alu-builtins-xcvalu}
24437 @deftypefn {Built-in Function} {int} __builtin_riscv_cv_alu_slet (int32_t, int32_t)
24438 Generated assembler @code{cv.slet}
24439 @end deftypefn
24441 @deftypefn {Built-in Function} {int} __builtin_riscv_cv_alu_sletu (uint32_t, uint32_t)
24442 Generated assembler @code{cv.sletu}
24443 @end deftypefn
24445 @deftypefn {Built-in Function} {int32_t} __builtin_riscv_cv_alu_min (int32_t, int32_t)
24446 Generated assembler @code{cv.min}
24447 @end deftypefn
24449 @deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_alu_minu (uint32_t, uint32_t)
24450 Generated assembler @code{cv.minu}
24451 @end deftypefn
24453 @deftypefn {Built-in Function} {int32_t} __builtin_riscv_cv_alu_max (int32_t, int32_t)
24454 Generated assembler @code{cv.max}
24455 @end deftypefn
24457 @deftypefn {Built-in Function} {uint32_tnt} __builtin_riscv_cv_alu_maxu (uint32_t, uint32_t)
24458 Generated assembler @code{cv.maxu}
24459 @end deftypefn
24461 @deftypefn {Built-in Function} {int32_t} __builtin_riscv_cv_alu_exths (int16_t)
24462 Generated assembler @code{cv.exths}
24463 @end deftypefn
24465 @deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_alu_exthz (uint16_t)
24466 Generated assembler @code{cv.exthz}
24467 @end deftypefn
24469 @deftypefn {Built-in Function} {int32_t} __builtin_riscv_cv_alu_extbs (int8_t)
24470 Generated assembler @code{cv.extbs}
24471 @end deftypefn
24473 @deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_alu_extbz (uint8_t)
24474 Generated assembler @code{cv.extbz}
24475 @end deftypefn
24477 @deftypefn {Built-in Function} {int32_t} __builtin_riscv_cv_alu_clip (int32_t, uint32_t)
24478 Generated assembler @code{cv.clip} if the uint32_t operand is a constant and an exact power of 2.
24479 Generated assembler @code{cv.clipr} if  the it is a register.
24480 @end deftypefn
24482 @deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_alu_clipu (uint32_t, uint32_t)
24483 Generated assembler @code{cv.clipu} if the uint32_t operand is a constant and an exact power of 2.
24484 Generated assembler @code{cv.clipur} if  the it is a register.
24485 @end deftypefn
24487 @deftypefn {Built-in Function} {int32_t} __builtin_riscv_cv_alu_addN (int32_t, int32_t, uint8_t)
24488 Generated assembler @code{cv.addN} if the uint8_t operand is a constant and in the range 0 <= shft <= 31.
24489 Generated assembler @code{cv.addNr} if  the it is a register.
24490 @end deftypefn
24492 @deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_alu_adduN (uint32_t, uint32_t, uint8_t)
24493 Generated assembler @code{cv.adduN} if the uint8_t operand is a constant and in the range 0 <= shft <= 31.
24494 Generated assembler @code{cv.adduNr} if  the it is a register.
24495 @end deftypefn
24497 @deftypefn {Built-in Function} {int32_t} __builtin_riscv_cv_alu_addRN (int32_t, int32_t, uint8_t)
24498 Generated assembler @code{cv.addRN} if the uint8_t operand is a constant and in the range 0 <= shft <= 31.
24499 Generated assembler @code{cv.addRNr} if  the it is a register.
24500 @end deftypefn
24502 @deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_alu_adduRN (uint32_t, uint32_t, uint8_t)
24503 Generated assembler @code{cv.adduRN} if the uint8_t operand is a constant and in the range 0 <= shft <= 31.
24504 Generated assembler @code{cv.adduRNr} if  the it is a register.
24505 @end deftypefn
24507 @deftypefn {Built-in Function} {int32_t} __builtin_riscv_cv_alu_subN (int32_t, int32_t, uint8_t)
24508 Generated assembler @code{cv.subN} if the uint8_t operand is a constant and in the range 0 <= shft <= 31.
24509 Generated assembler @code{cv.subNr} if  the it is a register.
24510 @end deftypefn
24512 @deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_alu_subuN (uint32_t, uint32_t, uint8_t)
24513 Generated assembler @code{cv.subuN} if the uint8_t operand is a constant and in the range 0 <= shft <= 31.
24514 Generated assembler @code{cv.subuNr} if  the it is a register.
24515 @end deftypefn
24517 @deftypefn {Built-in Function} {int32_t} __builtin_riscv_cv_alu_subRN (int32_t, int32_t, uint8_t)
24518 Generated assembler @code{cv.subRN} if the uint8_t operand is a constant and in the range 0 <= shft <= 31.
24519 Generated assembler @code{cv.subRNr} if  the it is a register.
24520 @end deftypefn
24522 @deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_alu_subuRN (uint32_t, uint32_t, uint8_t)
24523 Generated assembler @code{cv.subuRN} if the uint8_t operand is a constant and in the range 0 <= shft <= 31.
24524 Generated assembler @code{cv.subuRNr} if  the it is a register.
24525 @end deftypefn
24527 These built-in functions are available for the CORE-V Event Load machine
24528 architecture. For more information on CORE-V ELW builtins, please see
24529 @uref{https://github.com/openhwgroup/core-v-sw/blob/master/specifications/corev-builtin-spec.md#listing-of-event-load-word-builtins-xcvelw}
24531 @deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_elw_elw (uint32_t *)
24532 Generated assembler @code{cv.elw}
24533 @end deftypefn
24535 These built-in functions are available for the CORE-V SIMD machine
24536 architecture. For more information on CORE-V SIMD built-ins, please see
24537 @uref{https://github.com/openhwgroup/core-v-sw/blob/master/specifications/corev-builtin-spec.md#listing-of-pulp-816-bit-simd-builtins-xcvsimd}
24539 @deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_simd_add_h (uint32_t, uint32_t, uint4_t)
24540 Generated assembler @code{cv.add.h}
24541 @end deftypefn
24543 @deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_simd_add_b (uint32_t, uint32_t)
24544 Generated assembler @code{cv.add.b}
24545 @end deftypefn
24547 @deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_simd_add_sc_h (uint32_t, int16_t)
24548 Generated assembler @code{cv.add.sc.h}
24549 @end deftypefn
24551 @deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_simd_add_sc_h (uint32_t, int6_t)
24552 Generated assembler @code{cv.add.sci.h}
24553 @end deftypefn
24555 @deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_simd_add_sc_b (uint32_t, int8_t)
24556 Generated assembler @code{cv.add.sc.b}
24557 @end deftypefn
24559 @deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_simd_add_sc_b (uint32_t, int6_t)
24560 Generated assembler @code{cv.add.sci.b}
24561 @end deftypefn
24563 @deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_simd_sub_h (uint32_t, uint32_t, uint4_t)
24564 Generated assembler @code{cv.sub.h}
24565 @end deftypefn
24567 @deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_simd_sub_b (uint32_t, uint32_t)
24568 Generated assembler @code{cv.sub.b}
24569 @end deftypefn
24571 @deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_simd_sub_sc_h (uint32_t, int16_t)
24572 Generated assembler @code{cv.sub.sc.h}
24573 @end deftypefn
24575 @deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_simd_sub_sc_h (uint32_t, int6_t)
24576 Generated assembler @code{cv.sub.sci.h}
24577 @end deftypefn
24579 @deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_simd_sub_sc_b (uint32_t, int8_t)
24580 Generated assembler @code{cv.sub.sc.b}
24581 @end deftypefn
24583 @deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_simd_sub_sc_b (uint32_t, int6_t)
24584 Generated assembler @code{cv.sub.sci.b}
24585 @end deftypefn
24587 @deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_simd_avg_h (uint32_t, uint32_t)
24588 Generated assembler @code{cv.avg.h}
24589 @end deftypefn
24591 @deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_simd_avg_b (uint32_t, uint32_t)
24592 Generated assembler @code{cv.avg.b}
24593 @end deftypefn
24595 @deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_simd_avg_sc_h (uint32_t, int16_t)
24596 Generated assembler @code{cv.avg.sc.h}
24597 @end deftypefn
24599 @deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_simd_avg_sc_h (uint32_t, int6_t)
24600 Generated assembler @code{cv.avg.sci.h}
24601 @end deftypefn
24603 @deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_simd_avg_sc_b (uint32_t, int8_t)
24604 Generated assembler @code{cv.avg.sc.b}
24605 @end deftypefn
24607 @deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_simd_avg_sc_b (uint32_t, int6_t)
24608 Generated assembler @code{cv.avg.sci.b}
24609 @end deftypefn
24611 @deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_simd_avgu_h (uint32_t, uint32_t)
24612 Generated assembler @code{cv.avgu.h}
24613 @end deftypefn
24615 @deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_simd_avgu_b (uint32_t, uint32_t)
24616 Generated assembler @code{cv.avgu.b}
24617 @end deftypefn
24619 @deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_simd_avgu_sc_h (uint32_t, uint16_t)
24620 Generated assembler @code{cv.avgu.sc.h}
24621 @end deftypefn
24623 @deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_simd_avgu_sc_h (uint32_t, uint6_t)
24624 Generated assembler @code{cv.avgu.sci.h}
24625 @end deftypefn
24627 @deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_simd_avgu_sc_b (uint32_t, uint8_t)
24628 Generated assembler @code{cv.avgu.sc.b}
24629 @end deftypefn
24631 @deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_simd_avgu_sc_b (uint32_t, uint6_t)
24632 Generated assembler @code{cv.avgu.sci.b}
24633 @end deftypefn
24635 @deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_simd_min_h (uint32_t, uint32_t)
24636 Generated assembler @code{cv.min.h}
24637 @end deftypefn
24639 @deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_simd_min_b (uint32_t, uint32_t)
24640 Generated assembler @code{cv.min.b}
24641 @end deftypefn
24643 @deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_simd_min_sc_h (uint32_t, int16_t)
24644 Generated assembler @code{cv.min.sc.h}
24645 @end deftypefn
24647 @deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_simd_min_sc_h (uint32_t, int6_t)
24648 Generated assembler @code{cv.min.sci.h}
24649 @end deftypefn
24651 @deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_simd_min_sc_b (uint32_t, int8_t)
24652 Generated assembler @code{cv.min.sc.b}
24653 @end deftypefn
24655 @deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_simd_min_sc_b (uint32_t, int6_t)
24656 Generated assembler @code{cv.min.sci.b}
24657 @end deftypefn
24659 @deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_simd_minu_h (uint32_t, uint32_t)
24660 Generated assembler @code{cv.minu.h}
24661 @end deftypefn
24663 @deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_simd_minu_b (uint32_t, uint32_t)
24664 Generated assembler @code{cv.minu.b}
24665 @end deftypefn
24667 @deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_simd_minu_sc_h (uint32_t, uint16_t)
24668 Generated assembler @code{cv.minu.sc.h}
24669 @end deftypefn
24671 @deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_simd_minu_sc_h (uint32_t, uint6_t)
24672 Generated assembler @code{cv.minu.sci.h}
24673 @end deftypefn
24675 @deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_simd_minu_sc_b (uint32_t, uint8_t)
24676 Generated assembler @code{cv.minu.sc.b}
24677 @end deftypefn
24679 @deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_simd_minu_sc_b (uint32_t, uint6_t)
24680 Generated assembler @code{cv.minu.sci.b}
24681 @end deftypefn
24683 @deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_simd_max_h (uint32_t, uint32_t)
24684 Generated assembler @code{cv.max.h}
24685 @end deftypefn
24687 @deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_simd_max_b (uint32_t, uint32_t)
24688 Generated assembler @code{cv.max.b}
24689 @end deftypefn
24691 @deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_simd_max_sc_h (uint32_t, int16_t)
24692 Generated assembler @code{cv.max.sc.h}
24693 @end deftypefn
24695 @deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_simd_max_sc_h (uint32_t, int6_t)
24696 Generated assembler @code{cv.max.sci.h}
24697 @end deftypefn
24699 @deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_simd_max_sc_b (uint32_t, int8_t)
24700 Generated assembler @code{cv.max.sc.b}
24701 @end deftypefn
24703 @deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_simd_max_sc_b (uint32_t, int6_t)
24704 Generated assembler @code{cv.max.sci.b}
24705 @end deftypefn
24707 @deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_simd_maxu_h (uint32_t, uint32_t)
24708 Generated assembler @code{cv.maxu.h}
24709 @end deftypefn
24711 @deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_simd_maxu_b (uint32_t, uint32_t)
24712 Generated assembler @code{cv.maxu.b}
24713 @end deftypefn
24715 @deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_simd_maxu_sc_h (uint32_t, uint16_t)
24716 Generated assembler @code{cv.maxu.sc.h}
24717 @end deftypefn
24719 @deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_simd_maxu_sc_h (uint32_t, uint6_t)
24720 Generated assembler @code{cv.maxu.sci.h}
24721 @end deftypefn
24723 @deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_simd_maxu_sc_b (uint32_t, uint8_t)
24724 Generated assembler @code{cv.maxu.sc.b}
24725 @end deftypefn
24727 @deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_simd_maxu_sc_b (uint32_t, uint6_t)
24728 Generated assembler @code{cv.maxu.sci.b}
24729 @end deftypefn
24731 @deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_simd_srl_h (uint32_t, uint32_t)
24732 Generated assembler @code{cv.srl.h}
24733 @end deftypefn
24735 @deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_simd_srl_b (uint32_t, uint32_t)
24736 Generated assembler @code{cv.srl.b}
24737 @end deftypefn
24739 @deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_simd_srl_sc_h (uint32_t, int16_t)
24740 Generated assembler @code{cv.srl.sc.h}
24741 @end deftypefn
24743 @deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_simd_srl_sc_h (uint32_t, int6_t)
24744 Generated assembler @code{cv.srl.sci.h}
24745 @end deftypefn
24747 @deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_simd_srl_sc_b (uint32_t, int8_t)
24748 Generated assembler @code{cv.srl.sc.b}
24749 @end deftypefn
24751 @deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_simd_srl_sc_b (uint32_t, int6_t)
24752 Generated assembler @code{cv.srl.sci.b}
24753 @end deftypefn
24755 @deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_simd_sra_h (uint32_t, uint32_t)
24756 Generated assembler @code{cv.sra.h}
24757 @end deftypefn
24759 @deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_simd_sra_b (uint32_t, uint32_t)
24760 Generated assembler @code{cv.sra.b}
24761 @end deftypefn
24763 @deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_simd_sra_sc_h (uint32_t, int16_t)
24764 Generated assembler @code{cv.sra.sc.h}
24765 @end deftypefn
24767 @deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_simd_sra_sc_h (uint32_t, int6_t)
24768 Generated assembler @code{cv.sra.sci.h}
24769 @end deftypefn
24771 @deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_simd_sra_sc_b (uint32_t, int8_t)
24772 Generated assembler @code{cv.sra.sc.b}
24773 @end deftypefn
24775 @deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_simd_sra_sc_b (uint32_t, int6_t)
24776 Generated assembler @code{cv.sra.sci.b}
24777 @end deftypefn
24779 @deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_simd_sll_h (uint32_t, uint32_t)
24780 Generated assembler @code{cv.sll.h}
24781 @end deftypefn
24783 @deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_simd_sll_b (uint32_t, uint32_t)
24784 Generated assembler @code{cv.sll.b}
24785 @end deftypefn
24787 @deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_simd_sll_sc_h (uint32_t, int16_t)
24788 Generated assembler @code{cv.sll.sc.h}
24789 @end deftypefn
24791 @deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_simd_sll_sc_h (uint32_t, int6_t)
24792 Generated assembler @code{cv.sll.sci.h}
24793 @end deftypefn
24795 @deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_simd_sll_sc_b (uint32_t, int8_t)
24796 Generated assembler @code{cv.sll.sc.b}
24797 @end deftypefn
24799 @deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_simd_sll_sc_b (uint32_t, int6_t)
24800 Generated assembler @code{cv.sll.sci.b}
24801 @end deftypefn
24803 @deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_simd_or_h (uint32_t, uint32_t)
24804 Generated assembler @code{cv.or.h}
24805 @end deftypefn
24807 @deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_simd_or_b (uint32_t, uint32_t)
24808 Generated assembler @code{cv.or.b}
24809 @end deftypefn
24811 @deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_simd_or_sc_h (uint32_t, int16_t)
24812 Generated assembler @code{cv.or.sc.h}
24813 @end deftypefn
24815 @deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_simd_or_sc_h (uint32_t, int6_t)
24816 Generated assembler @code{cv.or.sci.h}
24817 @end deftypefn
24819 @deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_simd_or_sc_b (uint32_t, int8_t)
24820 Generated assembler @code{cv.or.sc.b}
24821 @end deftypefn
24823 @deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_simd_or_sc_b (uint32_t, int6_t)
24824 Generated assembler @code{cv.or.sci.b}
24825 @end deftypefn
24827 @deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_simd_xor_h (uint32_t, uint32_t)
24828 Generated assembler @code{cv.xor.h}
24829 @end deftypefn
24831 @deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_simd_xor_b (uint32_t, uint32_t)
24832 Generated assembler @code{cv.xor.b}
24833 @end deftypefn
24835 @deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_simd_xor_sc_h (uint32_t, int16_t)
24836 Generated assembler @code{cv.xor.sc.h}
24837 @end deftypefn
24839 @deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_simd_xor_sc_h (uint32_t, int6_t)
24840 Generated assembler @code{cv.xor.sci.h}
24841 @end deftypefn
24843 @deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_simd_xor_sc_b (uint32_t, int8_t)
24844 Generated assembler @code{cv.xor.sc.b}
24845 @end deftypefn
24847 @deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_simd_xor_sc_b (uint32_t, int6_t)
24848 Generated assembler @code{cv.xor.sci.b}
24849 @end deftypefn
24851 @deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_simd_and_h (uint32_t, uint32_t)
24852 Generated assembler @code{cv.and.h}
24853 @end deftypefn
24855 @deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_simd_and_b (uint32_t, uint32_t)
24856 Generated assembler @code{cv.and.b}
24857 @end deftypefn
24859 @deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_simd_and_sc_h (uint32_t, int16_t)
24860 Generated assembler @code{cv.and.sc.h}
24861 @end deftypefn
24863 @deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_simd_and_sc_h (uint32_t, int6_t)
24864 Generated assembler @code{cv.and.sci.h}
24865 @end deftypefn
24867 @deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_simd_and_sc_b (uint32_t, int8_t)
24868 Generated assembler @code{cv.and.sc.b}
24869 @end deftypefn
24871 @deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_simd_and_sc_b (uint32_t, int6_t)
24872 Generated assembler @code{cv.and.sci.b}
24873 @end deftypefn
24875 @deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_simd_abs_h (uint32_t)
24876 Generated assembler @code{cv.abs.h}
24877 @end deftypefn
24879 @deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_simd_abs_b (uint32_t)
24880 Generated assembler @code{cv.abs.b}
24881 @end deftypefn
24883 @deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_simd_dotup_h (uint32_t, uint32_t)
24884 Generated assembler @code{cv.dotup.h}
24885 @end deftypefn
24887 @deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_simd_dotup_b (uint32_t, uint32_t)
24888 Generated assembler @code{cv.dotup.b}
24889 @end deftypefn
24891 @deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_simd_dotup_sc_h (uint32_t, uint16_t)
24892 Generated assembler @code{cv.dotup.sc.h}
24893 @end deftypefn
24895 @deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_simd_dotup_sc_h (uint32_t, uint6_t)
24896 Generated assembler @code{cv.dotup.sci.h}
24897 @end deftypefn
24899 @deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_simd_dotup_sc_b (uint32_t, uint8_t)
24900 Generated assembler @code{cv.dotup.sc.b}
24901 @end deftypefn
24903 @deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_simd_dotup_sc_b (uint32_t, uint6_t)
24904 Generated assembler @code{cv.dotup.sci.b}
24905 @end deftypefn
24907 @deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_simd_dotusp_h (uint32_t, uint32_t)
24908 Generated assembler @code{cv.dotusp.h}
24909 @end deftypefn
24911 @deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_simd_dotusp_b (uint32_t, uint32_t)
24912 Generated assembler @code{cv.dotusp.b}
24913 @end deftypefn
24915 @deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_simd_dotusp_sc_h (uint32_t, int16_t)
24916 Generated assembler @code{cv.dotusp.sc.h}
24917 @end deftypefn
24919 @deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_simd_dotusp_sc_h (uint32_t, int6_t)
24920 Generated assembler @code{cv.dotusp.sci.h}
24921 @end deftypefn
24923 @deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_simd_dotusp_sc_b (uint32_t, int8_t)
24924 Generated assembler @code{cv.dotusp.sc.b}
24925 @end deftypefn
24927 @deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_simd_dotusp_sc_b (uint32_t, int6_t)
24928 Generated assembler @code{cv.dotusp.sci.b}
24929 @end deftypefn
24931 @deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_simd_dotsp_h (uint32_t, uint32_t)
24932 Generated assembler @code{cv.dotsp.h}
24933 @end deftypefn
24935 @deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_simd_dotsp_b (uint32_t, uint32_t)
24936 Generated assembler @code{cv.dotsp.b}
24937 @end deftypefn
24939 @deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_simd_dotsp_sc_h (uint32_t, int16_t)
24940 Generated assembler @code{cv.dotsp.sc.h}
24941 @end deftypefn
24943 @deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_simd_dotsp_sc_h (uint32_t, int6_t)
24944 Generated assembler @code{cv.dotsp.sci.h}
24945 @end deftypefn
24947 @deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_simd_dotsp_sc_b (uint32_t, int8_t)
24948 Generated assembler @code{cv.dotsp.sc.b}
24949 @end deftypefn
24951 @deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_simd_dotsp_sc_b (uint32_t, int6_t)
24952 Generated assembler @code{cv.dotsp.sci.b}
24953 @end deftypefn
24955 @deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_simd_sdotup_h (uint32_t, uint32_t, uint32_t)
24956 Generated assembler @code{cv.sdotup.h}
24957 @end deftypefn
24959 @deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_simd_sdotup_b (uint32_t, uint32_t, uint32_t)
24960 Generated assembler @code{cv.sdotup.b}
24961 @end deftypefn
24963 @deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_simd_sdotup_sc_h (uint32_t, uint16_t, uint32_t)
24964 Generated assembler @code{cv.sdotup.sc.h}
24965 @end deftypefn
24967 @deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_simd_sdotup_sc_h (uint32_t, uint6_t, uint32_t)
24968 Generated assembler @code{cv.sdotup.sci.h}
24969 @end deftypefn
24971 @deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_simd_sdotup_sc_b (uint32_t, uint8_t, uint32_t)
24972 Generated assembler @code{cv.sdotup.sc.b}
24973 @end deftypefn
24975 @deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_simd_sdotup_sc_b (uint32_t, uint6_t, uint32_t)
24976 Generated assembler @code{cv.sdotup.sci.b}
24977 @end deftypefn
24979 @deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_simd_sdotusp_h (uint32_t, uint32_t, uint32_t)
24980 Generated assembler @code{cv.sdotusp.h}
24981 @end deftypefn
24983 @deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_simd_sdotusp_b (uint32_t, uint32_t, uint32_t)
24984 Generated assembler @code{cv.sdotusp.b}
24985 @end deftypefn
24987 @deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_simd_sdotusp_sc_h (uint32_t, int16_t, uint32_t)
24988 Generated assembler @code{cv.sdotusp.sc.h}
24989 @end deftypefn
24991 @deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_simd_sdotusp_sc_h (uint32_t, int6_t, uint32_t)
24992 Generated assembler @code{cv.sdotusp.sci.h}
24993 @end deftypefn
24995 @deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_simd_sdotusp_sc_b (uint32_t, int8_t, uint32_t)
24996 Generated assembler @code{cv.sdotusp.sc.b}
24997 @end deftypefn
24999 @deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_simd_sdotusp_sc_b (uint32_t, int6_t, uint32_t)
25000 Generated assembler @code{cv.sdotusp.sci.b}
25001 @end deftypefn
25003 @deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_simd_sdotsp_h (uint32_t, uint32_t, uint32_t)
25004 Generated assembler @code{cv.sdotsp.h}
25005 @end deftypefn
25007 @deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_simd_sdotsp_b (uint32_t, uint32_t, uint32_t)
25008 Generated assembler @code{cv.sdotsp.b}
25009 @end deftypefn
25011 @deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_simd_sdotsp_sc_h (uint32_t, int16_t, uint32_t)
25012 Generated assembler @code{cv.sdotsp.sc.h}
25013 @end deftypefn
25015 @deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_simd_sdotsp_sc_h (uint32_t, int6_t, uint32_t)
25016 Generated assembler @code{cv.sdotsp.sci.h}
25017 @end deftypefn
25019 @deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_simd_sdotsp_sc_b (uint32_t, int8_t, uint32_t)
25020 Generated assembler @code{cv.sdotsp.sc.b}
25021 @end deftypefn
25023 @deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_simd_sdotsp_sc_b (uint32_t, int6_t, uint32_t)
25024 Generated assembler @code{cv.sdotsp.sci.b}
25025 @end deftypefn
25027 @deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_simd_extract_h (uint32_t, uint6_t)
25028 Generated assembler @code{cv.extract.h}
25029 @end deftypefn
25031 @deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_simd_extract_b (uint32_t, uint6_t)
25032 Generated assembler @code{cv.extract.b}
25033 @end deftypefn
25035 @deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_simd_extractu_h (uint32_t, uint6_t)
25036 Generated assembler @code{cv.extractu.h}
25037 @end deftypefn
25039 @deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_simd_extractu_b (uint32_t, uint6_t)
25040 Generated assembler @code{cv.extractu.b}
25041 @end deftypefn
25043 @deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_simd_insert_h (uint32_t, uint32_t)
25044 Generated assembler @code{cv.insert.h}
25045 @end deftypefn
25047 @deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_simd_insert_b (uint32_t, uint32_t)
25048 Generated assembler @code{cv.insert.b}
25049 @end deftypefn
25051 @deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_simd_shuffle_h (uint32_t, uint32_t)
25052 Generated assembler @code{cv.shuffle.h}
25053 @end deftypefn
25055 @deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_simd_shuffle_b (uint32_t, uint32_t)
25056 Generated assembler @code{cv.shuffle.b}
25057 @end deftypefn
25059 @deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_simd_shuffle_sci_h (uint32_t, uint4_t)
25060 Generated assembler @code{cv.shuffle.sci.h}
25061 @end deftypefn
25063 @deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_simd_shufflei0_sci_b (uint32_t, uint4_t)
25064 Generated assembler @code{cv.shufflei0.sci.b}
25065 @end deftypefn
25067 @deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_simd_shufflei1_sci_b (uint32_t, uint4_t)
25068 Generated assembler @code{cv.shufflei1.sci.b}
25069 @end deftypefn
25071 @deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_simd_shufflei2_sci_b (uint32_t, uint4_t)
25072 Generated assembler @code{cv.shufflei2.sci.b}
25073 @end deftypefn
25075 @deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_simd_shufflei3_sci_b (uint32_t, uint4_t)
25076 Generated assembler @code{cv.shufflei3.sci.b}
25077 @end deftypefn
25079 @deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_simd_shuffle2_h (uint32_t, uint32_t, uint32_t)
25080 Generated assembler @code{cv.shuffle2.h}
25081 @end deftypefn
25083 @deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_simd_shuffle2_b (uint32_t, uint32_t, uint32_t)
25084 Generated assembler @code{cv.shuffle2.b}
25085 @end deftypefn
25087 @deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_simd_packlo_h (uint32_t, uint32_t)
25088 Generated assembler @code{cv.pack}
25089 @end deftypefn
25091 @deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_simd_packhi_h (uint32_t, uint32_t)
25092 Generated assembler @code{cv.pack.h}
25093 @end deftypefn
25095 @deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_simd_packhi_b (uint32_t, uint32_t, uint32_t)
25096 Generated assembler @code{cv.packhi.b}
25097 @end deftypefn
25099 @deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_simd_packlo_b (uint32_t, uint32_t, uint32_t)
25100 Generated assembler @code{cv.packlo.b}
25101 @end deftypefn
25103 @deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_simd_cmpeq_h (uint32_t, uint32_t)
25104 Generated assembler @code{cv.cmpeq.h}
25105 @end deftypefn
25107 @deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_simd_cmpeq_b (uint32_t, uint32_t)
25108 Generated assembler @code{cv.cmpeq.b}
25109 @end deftypefn
25111 @deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_simd_cmpeq_sc_h (uint32_t, int16_t)
25112 Generated assembler @code{cv.cmpeq.sc.h}
25113 @end deftypefn
25115 @deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_simd_cmpeq_sc_h (uint32_t, int6_t)
25116 Generated assembler @code{cv.cmpeq.sci.h}
25117 @end deftypefn
25119 @deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_simd_cmpeq_sc_b (uint32_t, int8_t)
25120 Generated assembler @code{cv.cmpeq.sc.b}
25121 @end deftypefn
25123 @deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_simd_cmpeq_sc_b (uint32_t, int6_t)
25124 Generated assembler @code{cv.cmpeq.sci.b}
25125 @end deftypefn
25127 @deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_simd_cmpne_h (uint32_t, uint32_t)
25128 Generated assembler @code{cv.cmpne.h}
25129 @end deftypefn
25131 @deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_simd_cmpne_b (uint32_t, uint32_t)
25132 Generated assembler @code{cv.cmpne.b}
25133 @end deftypefn
25135 @deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_simd_cmpne_sc_h (uint32_t, int16_t)
25136 Generated assembler @code{cv.cmpne.sc.h}
25137 @end deftypefn
25139 @deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_simd_cmpne_sc_h (uint32_t, int6_t)
25140 Generated assembler @code{cv.cmpne.sci.h}
25141 @end deftypefn
25143 @deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_simd_cmpne_sc_b (uint32_t, int8_t)
25144 Generated assembler @code{cv.cmpne.sc.b}
25145 @end deftypefn
25147 @deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_simd_cmpne_sc_b (uint32_t, int6_t)
25148 Generated assembler @code{cv.cmpne.sci.b}
25149 @end deftypefn
25151 @deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_simd_cmpgt_h (uint32_t, uint32_t)
25152 Generated assembler @code{cv.cmpgt.h}
25153 @end deftypefn
25155 @deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_simd_cmpgt_b (uint32_t, uint32_t)
25156 Generated assembler @code{cv.cmpgt.b}
25157 @end deftypefn
25159 @deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_simd_cmpgt_sc_h (uint32_t, int16_t)
25160 Generated assembler @code{cv.cmpgt.sc.h}
25161 @end deftypefn
25163 @deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_simd_cmpgt_sc_h (uint32_t, int6_t)
25164 Generated assembler @code{cv.cmpgt.sci.h}
25165 @end deftypefn
25167 @deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_simd_cmpgt_sc_b (uint32_t, int8_t)
25168 Generated assembler @code{cv.cmpgt.sc.b}
25169 @end deftypefn
25171 @deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_simd_cmpgt_sc_b (uint32_t, int6_t)
25172 Generated assembler @code{cv.cmpgt.sci.b}
25173 @end deftypefn
25175 @deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_simd_cmpge_h (uint32_t, uint32_t)
25176 Generated assembler @code{cv.cmpge.h}
25177 @end deftypefn
25179 @deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_simd_cmpge_b (uint32_t, uint32_t)
25180 Generated assembler @code{cv.cmpge.b}
25181 @end deftypefn
25183 @deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_simd_cmpge_sc_h (uint32_t, int16_t)
25184 Generated assembler @code{cv.cmpge.sc.h}
25185 @end deftypefn
25187 @deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_simd_cmpge_sc_h (uint32_t, int6_t)
25188 Generated assembler @code{cv.cmpge.sci.h}
25189 @end deftypefn
25191 @deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_simd_cmpge_sc_b (uint32_t, int8_t)
25192 Generated assembler @code{cv.cmpge.sc.b}
25193 @end deftypefn
25195 @deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_simd_cmpge_sc_b (uint32_t, int6_t)
25196 Generated assembler @code{cv.cmpge.sci.b}
25197 @end deftypefn
25199 @deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_simd_cmplt_h (uint32_t, uint32_t)
25200 Generated assembler @code{cv.cmplt.h}
25201 @end deftypefn
25203 @deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_simd_cmplt_b (uint32_t, uint32_t)
25204 Generated assembler @code{cv.cmplt.b}
25205 @end deftypefn
25207 @deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_simd_cmplt_sc_h (uint32_t, int16_t)
25208 Generated assembler @code{cv.cmplt.sc.h}
25209 @end deftypefn
25211 @deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_simd_cmplt_sc_h (uint32_t, int6_t)
25212 Generated assembler @code{cv.cmplt.sci.h}
25213 @end deftypefn
25215 @deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_simd_cmplt_sc_b (uint32_t, int8_t)
25216 Generated assembler @code{cv.cmplt.sc.b}
25217 @end deftypefn
25219 @deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_simd_cmplt_sc_b (uint32_t, int6_t)
25220 Generated assembler @code{cv.cmplt.sci.b}
25221 @end deftypefn
25223 @deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_simd_cmple_h (uint32_t, uint32_t)
25224 Generated assembler @code{cv.cmple.h}
25225 @end deftypefn
25227 @deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_simd_cmple_b (uint32_t, uint32_t)
25228 Generated assembler @code{cv.cmple.b}
25229 @end deftypefn
25231 @deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_simd_cmple_sc_h (uint32_t, int16_t)
25232 Generated assembler @code{cv.cmple.sc.h}
25233 @end deftypefn
25235 @deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_simd_cmple_sc_h (uint32_t, int6_t)
25236 Generated assembler @code{cv.cmple.sci.h}
25237 @end deftypefn
25239 @deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_simd_cmple_sc_b (uint32_t, int8_t)
25240 Generated assembler @code{cv.cmple.sc.b}
25241 @end deftypefn
25243 @deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_simd_cmple_sc_b (uint32_t, int6_t)
25244 Generated assembler @code{cv.cmple.sci.b}
25245 @end deftypefn
25247 @deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_simd_cmpgtu_h (uint32_t, uint32_t)
25248 Generated assembler @code{cv.cmpgtu.h}
25249 @end deftypefn
25251 @deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_simd_cmpgtu_b (uint32_t, uint32_t)
25252 Generated assembler @code{cv.cmpgtu.b}
25253 @end deftypefn
25255 @deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_simd_cmpgtu_sc_h (uint32_t, uint16_t)
25256 Generated assembler @code{cv.cmpgtu.sc.h}
25257 @end deftypefn
25259 @deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_simd_cmpgtu_sc_h (uint32_t, uint6_t)
25260 Generated assembler @code{cv.cmpgtu.sci.h}
25261 @end deftypefn
25263 @deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_simd_cmpgtu_sc_b (uint32_t, uint8_t)
25264 Generated assembler @code{cv.cmpgtu.sc.b}
25265 @end deftypefn
25267 @deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_simd_cmpgtu_sc_b (uint32_t, uint6_t)
25268 Generated assembler @code{cv.cmpgtu.sci.b}
25269 @end deftypefn
25271 @deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_simd_cmpgeu_h (uint32_t, uint32_t)
25272 Generated assembler @code{cv.cmpgeu.h}
25273 @end deftypefn
25275 @deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_simd_cmpgeu_b (uint32_t, uint32_t)
25276 Generated assembler @code{cv.cmpgeu.b}
25277 @end deftypefn
25279 @deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_simd_cmpgeu_sc_h (uint32_t, uint16_t)
25280 Generated assembler @code{cv.cmpgeu.sc.h}
25281 @end deftypefn
25283 @deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_simd_cmpgeu_sc_h (uint32_t, uint6_t)
25284 Generated assembler @code{cv.cmpgeu.sci.h}
25285 @end deftypefn
25287 @deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_simd_cmpgeu_sc_b (uint32_t, uint8_t)
25288 Generated assembler @code{cv.cmpgeu.sc.b}
25289 @end deftypefn
25291 @deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_simd_cmpgeu_sc_b (uint32_t, uint6_t)
25292 Generated assembler @code{cv.cmpgeu.sci.b}
25293 @end deftypefn
25295 @deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_simd_cmpltu_h (uint32_t, uint32_t)
25296 Generated assembler @code{cv.cmpltu.h}
25297 @end deftypefn
25299 @deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_simd_cmpltu_b (uint32_t, uint32_t)
25300 Generated assembler @code{cv.cmpltu.b}
25301 @end deftypefn
25303 @deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_simd_cmpltu_sc_h (uint32_t, uint16_t)
25304 Generated assembler @code{cv.cmpltu.sc.h}
25305 @end deftypefn
25307 @deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_simd_cmpltu_sc_h (uint32_t, uint6_t)
25308 Generated assembler @code{cv.cmpltu.sci.h}
25309 @end deftypefn
25311 @deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_simd_cmpltu_sc_b (uint32_t, uint8_t)
25312 Generated assembler @code{cv.cmpltu.sc.b}
25313 @end deftypefn
25315 @deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_simd_cmpltu_sc_b (uint32_t, uint6_t)
25316 Generated assembler @code{cv.cmpltu.sci.b}
25317 @end deftypefn
25319 @deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_simd_cmpleu_h (uint32_t, uint32_t)
25320 Generated assembler @code{cv.cmpleu.h}
25321 @end deftypefn
25323 @deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_simd_cmpleu_b (uint32_t, uint32_t)
25324 Generated assembler @code{cv.cmpleu.b}
25325 @end deftypefn
25327 @deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_simd_cmpleu_sc_h (uint32_t, uint16_t)
25328 Generated assembler @code{cv.cmpleu.sc.h}
25329 @end deftypefn
25331 @deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_simd_cmpleu_sc_h (uint32_t, uint6_t)
25332 Generated assembler @code{cv.cmpleu.sci.h}
25333 @end deftypefn
25335 @deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_simd_cmpleu_sc_b (uint32_t, uint8_t)
25336 Generated assembler @code{cv.cmpleu.sc.b}
25337 @end deftypefn
25339 @deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_simd_cmpleu_sc_b (uint32_t, uint6_t)
25340 Generated assembler @code{cv.cmpleu.sci.b}
25341 @end deftypefn
25343 @deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_simd_cplxmul_r (uint32_t, uint32_t, uint32_t, uint4_t)
25344 Generated assembler @code{cv.cplxmul.r}
25345 @end deftypefn
25347 @deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_simd_cplxmul_i (uint32_t, uint32_t, uint32_t, uint4_t)
25348 Generated assembler @code{cv.cplxmul.i}
25349 @end deftypefn
25351 @deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_simd_cplxmul_r (uint32_t, uint32_t, uint32_t, uint4_t)
25352 Generated assembler @code{cv.cplxmul.r.div2}
25353 @end deftypefn
25355 @deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_simd_cplxmul_i (uint32_t, uint32_t, uint32_t, uint4_t)
25356 Generated assembler @code{cv.cplxmul.i.div2}
25357 @end deftypefn
25359 @deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_simd_cplxmul_r (uint32_t, uint32_t, uint32_t, uint4_t)
25360 Generated assembler @code{cv.cplxmul.r.div4}
25361 @end deftypefn
25363 @deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_simd_cplxmul_i (uint32_t, uint32_t, uint32_t, uint4_t)
25364 Generated assembler @code{cv.cplxmul.i.div4}
25365 @end deftypefn
25367 @deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_simd_cplxmul_r (uint32_t, uint32_t, uint32_t, uint4_t)
25368 Generated assembler @code{cv.cplxmul.r.div8}
25369 @end deftypefn
25371 @deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_simd_cplxmul_i (uint32_t, uint32_t, uint32_t, uint4_t)
25372 Generated assembler @code{cv.cplxmul.i.div8}
25373 @end deftypefn
25375 @deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_simd_cplxconj (uint32_t)
25376 Generated assembler @code{cv.cplxconj}
25377 @end deftypefn
25379 @deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_simd_subrotmj (uint32_t, uint32_t, uint4_t)
25380 Generated assembler @code{cv.subrotmj}
25381 @end deftypefn
25383 @deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_simd_subrotmj (uint32_t, uint32_t, uint32_t, uint4_t)
25384 Generated assembler @code{cv.subrotmj.div2}
25385 @end deftypefn
25387 @deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_simd_subrotmj (uint32_t, uint32_t, uint32_t, uint4_t)
25388 Generated assembler @code{cv.subrotmj.div4}
25389 @end deftypefn
25391 @deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_simd_subrotmj (uint32_t, uint32_t, uint32_t, uint4_t)
25392 Generated assembler @code{cv.subrotmj.div8}
25393 @end deftypefn
25395 @deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_simd_add_h (uint32_t, uint32_t, uint32_t, uint4_t)
25396 Generated assembler @code{cv.add.div2}
25397 @end deftypefn
25399 @deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_simd_add_h (uint32_t, uint32_t, uint32_t, uint4_t)
25400 Generated assembler @code{cv.add.div4}
25401 @end deftypefn
25403 @deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_simd_add_h (uint32_t, uint32_t, uint32_t, uint4_t)
25404 Generated assembler @code{cv.add.div8}
25405 @end deftypefn
25407 @deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_simd_sub_h (uint32_t, uint32_t, uint32_t, uint4_t)
25408 Generated assembler @code{cv.sub.div2}
25409 @end deftypefn
25411 @deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_simd_sub_h (uint32_t, uint32_t, uint32_t, uint4_t)
25412 Generated assembler @code{cv.sub.div4}
25413 @end deftypefn
25415 @deftypefn {Built-in Function} {uint32_t} __builtin_riscv_cv_simd_sub_h (uint32_t, uint32_t, uint32_t, uint4_t)
25416 Generated assembler @code{cv.sub.div8}
25417 @end deftypefn
25419 @node RX Built-in Functions
25420 @subsection RX Built-in Functions
25421 GCC supports some of the RX instructions which cannot be expressed in
25422 the C programming language via the use of built-in functions.  The
25423 following functions are supported:
25425 @defbuiltin{void __builtin_rx_brk (void)}
25426 Generates the @code{brk} machine instruction.
25427 @enddefbuiltin
25429 @defbuiltin{void __builtin_rx_clrpsw (int)}
25430 Generates the @code{clrpsw} machine instruction to clear the specified
25431 bit in the processor status word.
25432 @enddefbuiltin
25434 @defbuiltin{void __builtin_rx_int (int)}
25435 Generates the @code{int} machine instruction to generate an interrupt
25436 with the specified value.
25437 @enddefbuiltin
25439 @defbuiltin{void __builtin_rx_machi (int, int)}
25440 Generates the @code{machi} machine instruction to add the result of
25441 multiplying the top 16 bits of the two arguments into the
25442 accumulator.
25443 @enddefbuiltin
25445 @defbuiltin{void __builtin_rx_maclo (int, int)}
25446 Generates the @code{maclo} machine instruction to add the result of
25447 multiplying the bottom 16 bits of the two arguments into the
25448 accumulator.
25449 @enddefbuiltin
25451 @defbuiltin{void __builtin_rx_mulhi (int, int)}
25452 Generates the @code{mulhi} machine instruction to place the result of
25453 multiplying the top 16 bits of the two arguments into the
25454 accumulator.
25455 @enddefbuiltin
25457 @defbuiltin{void __builtin_rx_mullo (int, int)}
25458 Generates the @code{mullo} machine instruction to place the result of
25459 multiplying the bottom 16 bits of the two arguments into the
25460 accumulator.
25461 @enddefbuiltin
25463 @defbuiltin{int __builtin_rx_mvfachi (void)}
25464 Generates the @code{mvfachi} machine instruction to read the top
25465 32 bits of the accumulator.
25466 @enddefbuiltin
25468 @defbuiltin{int __builtin_rx_mvfacmi (void)}
25469 Generates the @code{mvfacmi} machine instruction to read the middle
25470 32 bits of the accumulator.
25471 @enddefbuiltin
25473 @defbuiltin{int __builtin_rx_mvfc (int)}
25474 Generates the @code{mvfc} machine instruction which reads the control
25475 register specified in its argument and returns its value.
25476 @enddefbuiltin
25478 @defbuiltin{void __builtin_rx_mvtachi (int)}
25479 Generates the @code{mvtachi} machine instruction to set the top
25480 32 bits of the accumulator.
25481 @enddefbuiltin
25483 @defbuiltin{void __builtin_rx_mvtaclo (int)}
25484 Generates the @code{mvtaclo} machine instruction to set the bottom
25485 32 bits of the accumulator.
25486 @enddefbuiltin
25488 @defbuiltin{void __builtin_rx_mvtc (int @var{reg}, int @var{val})}
25489 Generates the @code{mvtc} machine instruction which sets control
25490 register number @code{reg} to @code{val}.
25491 @enddefbuiltin
25493 @defbuiltin{void __builtin_rx_mvtipl (int)}
25494 Generates the @code{mvtipl} machine instruction set the interrupt
25495 priority level.
25496 @enddefbuiltin
25498 @defbuiltin{void __builtin_rx_racw (int)}
25499 Generates the @code{racw} machine instruction to round the accumulator
25500 according to the specified mode.
25501 @enddefbuiltin
25503 @defbuiltin{int __builtin_rx_revw (int)}
25504 Generates the @code{revw} machine instruction which swaps the bytes in
25505 the argument so that bits 0--7 now occupy bits 8--15 and vice versa,
25506 and also bits 16--23 occupy bits 24--31 and vice versa.
25507 @enddefbuiltin
25509 @defbuiltin{void __builtin_rx_rmpa (void)}
25510 Generates the @code{rmpa} machine instruction which initiates a
25511 repeated multiply and accumulate sequence.
25512 @enddefbuiltin
25514 @defbuiltin{void __builtin_rx_round (float)}
25515 Generates the @code{round} machine instruction which returns the
25516 floating-point argument rounded according to the current rounding mode
25517 set in the floating-point status word register.
25518 @enddefbuiltin
25520 @defbuiltin{int __builtin_rx_sat (int)}
25521 Generates the @code{sat} machine instruction which returns the
25522 saturated value of the argument.
25523 @enddefbuiltin
25525 @defbuiltin{void __builtin_rx_setpsw (int)}
25526 Generates the @code{setpsw} machine instruction to set the specified
25527 bit in the processor status word.
25528 @enddefbuiltin
25530 @defbuiltin{void __builtin_rx_wait (void)}
25531 Generates the @code{wait} machine instruction.
25532 @enddefbuiltin
25534 @node S/390 System z Built-in Functions
25535 @subsection S/390 System z Built-in Functions
25536 @defbuiltin{int __builtin_tbegin (void*)}
25537 Generates the @code{tbegin} machine instruction starting a
25538 non-constrained hardware transaction.  If the parameter is non-NULL the
25539 memory area is used to store the transaction diagnostic buffer and
25540 will be passed as first operand to @code{tbegin}.  This buffer can be
25541 defined using the @code{struct __htm_tdb} C struct defined in
25542 @code{htmintrin.h} and must reside on a double-word boundary.  The
25543 second tbegin operand is set to @code{0xff0c}. This enables
25544 save/restore of all GPRs and disables aborts for FPR and AR
25545 manipulations inside the transaction body.  The condition code set by
25546 the tbegin instruction is returned as integer value.  The tbegin
25547 instruction by definition overwrites the content of all FPRs.  The
25548 compiler will generate code which saves and restores the FPRs.  For
25549 soft-float code it is recommended to used the @code{*_nofloat}
25550 variant.  In order to prevent a TDB from being written it is required
25551 to pass a constant zero value as parameter.  Passing a zero value
25552 through a variable is not sufficient.  Although modifications of
25553 access registers inside the transaction will not trigger an
25554 transaction abort it is not supported to actually modify them.  Access
25555 registers do not get saved when entering a transaction. They will have
25556 undefined state when reaching the abort code.
25557 @enddefbuiltin
25559 Macros for the possible return codes of tbegin are defined in the
25560 @code{htmintrin.h} header file:
25562 @defmac _HTM_TBEGIN_STARTED
25563 @code{tbegin} has been executed as part of normal processing.  The
25564 transaction body is supposed to be executed.
25565 @end defmac
25567 @defmac _HTM_TBEGIN_INDETERMINATE
25568 The transaction was aborted due to an indeterminate condition which
25569 might be persistent.
25570 @end defmac
25572 @defmac _HTM_TBEGIN_TRANSIENT
25573 The transaction aborted due to a transient failure.  The transaction
25574 should be re-executed in that case.
25575 @end defmac
25577 @defmac _HTM_TBEGIN_PERSISTENT
25578 The transaction aborted due to a persistent failure.  Re-execution
25579 under same circumstances will not be productive.
25580 @end defmac
25582 @defmac _HTM_FIRST_USER_ABORT_CODE
25583 The @code{_HTM_FIRST_USER_ABORT_CODE} defined in @code{htmintrin.h}
25584 specifies the first abort code which can be used for
25585 @code{__builtin_tabort}.  Values below this threshold are reserved for
25586 machine use.
25587 @end defmac
25589 @deftp {Data type} {struct __htm_tdb}
25590 The @code{struct __htm_tdb} defined in @code{htmintrin.h} describes
25591 the structure of the transaction diagnostic block as specified in the
25592 Principles of Operation manual chapter 5-91.
25593 @end deftp
25595 @defbuiltin{int __builtin_tbegin_nofloat (void*)}
25596 Same as @code{__builtin_tbegin} but without FPR saves and restores.
25597 Using this variant in code making use of FPRs will leave the FPRs in
25598 undefined state when entering the transaction abort handler code.
25599 @enddefbuiltin
25601 @defbuiltin{int __builtin_tbegin_retry (void*, int)}
25602 In addition to @code{__builtin_tbegin} a loop for transient failures
25603 is generated.  If tbegin returns a condition code of 2 the transaction
25604 will be retried as often as specified in the second argument.  The
25605 perform processor assist instruction is used to tell the CPU about the
25606 number of fails so far.
25607 @enddefbuiltin
25609 @defbuiltin{int __builtin_tbegin_retry_nofloat (void*, int)}
25610 Same as @code{__builtin_tbegin_retry} but without FPR saves and
25611 restores.  Using this variant in code making use of FPRs will leave
25612 the FPRs in undefined state when entering the transaction abort
25613 handler code.
25614 @enddefbuiltin
25616 @defbuiltin{void __builtin_tbeginc (void)}
25617 Generates the @code{tbeginc} machine instruction starting a constrained
25618 hardware transaction.  The second operand is set to @code{0xff08}.
25619 @enddefbuiltin
25621 @defbuiltin{int __builtin_tend (void)}
25622 Generates the @code{tend} machine instruction finishing a transaction
25623 and making the changes visible to other threads.  The condition code
25624 generated by tend is returned as integer value.
25625 @enddefbuiltin
25627 @defbuiltin{void __builtin_tabort (int)}
25628 Generates the @code{tabort} machine instruction with the specified
25629 abort code.  Abort codes from 0 through 255 are reserved and will
25630 result in an error message.
25631 @enddefbuiltin
25633 @defbuiltin{void __builtin_tx_assist (int)}
25634 Generates the @code{ppa rX,rY,1} machine instruction.  Where the
25635 integer parameter is loaded into rX and a value of zero is loaded into
25636 rY.  The integer parameter specifies the number of times the
25637 transaction repeatedly aborted.
25638 @enddefbuiltin
25640 @defbuiltin{int __builtin_tx_nesting_depth (void)}
25641 Generates the @code{etnd} machine instruction.  The current nesting
25642 depth is returned as integer value.  For a nesting depth of 0 the code
25643 is not executed as part of an transaction.
25644 @enddefbuiltin
25646 @defbuiltin{void __builtin_non_tx_store (uint64_t *, uint64_t)}
25648 Generates the @code{ntstg} machine instruction.  The second argument
25649 is written to the first arguments location.  The store operation will
25650 not be rolled-back in case of an transaction abort.
25651 @enddefbuiltin
25653 @node SH Built-in Functions
25654 @subsection SH Built-in Functions
25655 The following built-in functions are supported on the SH1, SH2, SH3 and SH4
25656 families of processors:
25658 @defbuiltin{{void} __builtin_set_thread_pointer (void *@var{ptr})}
25659 Sets the @samp{GBR} register to the specified value @var{ptr}.  This is usually
25660 used by system code that manages threads and execution contexts.  The compiler
25661 normally does not generate code that modifies the contents of @samp{GBR} and
25662 thus the value is preserved across function calls.  Changing the @samp{GBR}
25663 value in user code must be done with caution, since the compiler might use
25664 @samp{GBR} in order to access thread local variables.
25666 @enddefbuiltin
25668 @defbuiltin{{void *} __builtin_thread_pointer (void)}
25669 Returns the value that is currently set in the @samp{GBR} register.
25670 Memory loads and stores that use the thread pointer as a base address are
25671 turned into @samp{GBR} based displacement loads and stores, if possible.
25672 For example:
25673 @smallexample
25674 struct my_tcb
25676    int a, b, c, d, e;
25679 int get_tcb_value (void)
25681   // Generate @samp{mov.l @@(8,gbr),r0} instruction
25682   return ((my_tcb*)__builtin_thread_pointer ())->c;
25685 @end smallexample
25686 @enddefbuiltin
25688 @defbuiltin{{unsigned int} __builtin_sh_get_fpscr (void)}
25689 Returns the value that is currently set in the @samp{FPSCR} register.
25690 @enddefbuiltin
25692 @defbuiltin{{void} __builtin_sh_set_fpscr (unsigned int @var{val})}
25693 Sets the @samp{FPSCR} register to the specified value @var{val}, while
25694 preserving the current values of the FR, SZ and PR bits.
25695 @enddefbuiltin
25697 @node SPARC VIS Built-in Functions
25698 @subsection SPARC VIS Built-in Functions
25700 GCC supports SIMD operations on the SPARC using both the generic vector
25701 extensions (@pxref{Vector Extensions}) as well as built-in functions for
25702 the SPARC Visual Instruction Set (VIS).  When you use the @option{-mvis}
25703 switch, the VIS extension is exposed as the following built-in functions:
25705 @smallexample
25706 typedef int v1si __attribute__ ((vector_size (4)));
25707 typedef int v2si __attribute__ ((vector_size (8)));
25708 typedef short v4hi __attribute__ ((vector_size (8)));
25709 typedef short v2hi __attribute__ ((vector_size (4)));
25710 typedef unsigned char v8qi __attribute__ ((vector_size (8)));
25711 typedef unsigned char v4qi __attribute__ ((vector_size (4)));
25713 void __builtin_vis_write_gsr (int64_t);
25714 int64_t __builtin_vis_read_gsr (void);
25716 void * __builtin_vis_alignaddr (void *, long);
25717 void * __builtin_vis_alignaddrl (void *, long);
25718 int64_t __builtin_vis_faligndatadi (int64_t, int64_t);
25719 v2si __builtin_vis_faligndatav2si (v2si, v2si);
25720 v4hi __builtin_vis_faligndatav4hi (v4si, v4si);
25721 v8qi __builtin_vis_faligndatav8qi (v8qi, v8qi);
25723 v4hi __builtin_vis_fexpand (v4qi);
25725 v4hi __builtin_vis_fmul8x16 (v4qi, v4hi);
25726 v4hi __builtin_vis_fmul8x16au (v4qi, v2hi);
25727 v4hi __builtin_vis_fmul8x16al (v4qi, v2hi);
25728 v4hi __builtin_vis_fmul8sux16 (v8qi, v4hi);
25729 v4hi __builtin_vis_fmul8ulx16 (v8qi, v4hi);
25730 v2si __builtin_vis_fmuld8sux16 (v4qi, v2hi);
25731 v2si __builtin_vis_fmuld8ulx16 (v4qi, v2hi);
25733 v4qi __builtin_vis_fpack16 (v4hi);
25734 v8qi __builtin_vis_fpack32 (v2si, v8qi);
25735 v2hi __builtin_vis_fpackfix (v2si);
25736 v8qi __builtin_vis_fpmerge (v4qi, v4qi);
25738 int64_t __builtin_vis_pdist (v8qi, v8qi, int64_t);
25740 long __builtin_vis_edge8 (void *, void *);
25741 long __builtin_vis_edge8l (void *, void *);
25742 long __builtin_vis_edge16 (void *, void *);
25743 long __builtin_vis_edge16l (void *, void *);
25744 long __builtin_vis_edge32 (void *, void *);
25745 long __builtin_vis_edge32l (void *, void *);
25747 long __builtin_vis_fcmple16 (v4hi, v4hi);
25748 long __builtin_vis_fcmple32 (v2si, v2si);
25749 long __builtin_vis_fcmpne16 (v4hi, v4hi);
25750 long __builtin_vis_fcmpne32 (v2si, v2si);
25751 long __builtin_vis_fcmpgt16 (v4hi, v4hi);
25752 long __builtin_vis_fcmpgt32 (v2si, v2si);
25753 long __builtin_vis_fcmpeq16 (v4hi, v4hi);
25754 long __builtin_vis_fcmpeq32 (v2si, v2si);
25756 v4hi __builtin_vis_fpadd16 (v4hi, v4hi);
25757 v2hi __builtin_vis_fpadd16s (v2hi, v2hi);
25758 v2si __builtin_vis_fpadd32 (v2si, v2si);
25759 v1si __builtin_vis_fpadd32s (v1si, v1si);
25760 v4hi __builtin_vis_fpsub16 (v4hi, v4hi);
25761 v2hi __builtin_vis_fpsub16s (v2hi, v2hi);
25762 v2si __builtin_vis_fpsub32 (v2si, v2si);
25763 v1si __builtin_vis_fpsub32s (v1si, v1si);
25765 long __builtin_vis_array8 (long, long);
25766 long __builtin_vis_array16 (long, long);
25767 long __builtin_vis_array32 (long, long);
25768 @end smallexample
25770 When you use the @option{-mvis2} switch, the VIS version 2.0 built-in
25771 functions also become available:
25773 @smallexample
25774 long __builtin_vis_bmask (long, long);
25775 int64_t __builtin_vis_bshuffledi (int64_t, int64_t);
25776 v2si __builtin_vis_bshufflev2si (v2si, v2si);
25777 v4hi __builtin_vis_bshufflev2si (v4hi, v4hi);
25778 v8qi __builtin_vis_bshufflev2si (v8qi, v8qi);
25780 long __builtin_vis_edge8n (void *, void *);
25781 long __builtin_vis_edge8ln (void *, void *);
25782 long __builtin_vis_edge16n (void *, void *);
25783 long __builtin_vis_edge16ln (void *, void *);
25784 long __builtin_vis_edge32n (void *, void *);
25785 long __builtin_vis_edge32ln (void *, void *);
25786 @end smallexample
25788 When you use the @option{-mvis3} switch, the VIS version 3.0 built-in
25789 functions also become available:
25791 @smallexample
25792 void __builtin_vis_cmask8 (long);
25793 void __builtin_vis_cmask16 (long);
25794 void __builtin_vis_cmask32 (long);
25796 v4hi __builtin_vis_fchksm16 (v4hi, v4hi);
25798 v4hi __builtin_vis_fsll16 (v4hi, v4hi);
25799 v4hi __builtin_vis_fslas16 (v4hi, v4hi);
25800 v4hi __builtin_vis_fsrl16 (v4hi, v4hi);
25801 v4hi __builtin_vis_fsra16 (v4hi, v4hi);
25802 v2si __builtin_vis_fsll16 (v2si, v2si);
25803 v2si __builtin_vis_fslas16 (v2si, v2si);
25804 v2si __builtin_vis_fsrl16 (v2si, v2si);
25805 v2si __builtin_vis_fsra16 (v2si, v2si);
25807 long __builtin_vis_pdistn (v8qi, v8qi);
25809 v4hi __builtin_vis_fmean16 (v4hi, v4hi);
25811 int64_t __builtin_vis_fpadd64 (int64_t, int64_t);
25812 int64_t __builtin_vis_fpsub64 (int64_t, int64_t);
25814 v4hi __builtin_vis_fpadds16 (v4hi, v4hi);
25815 v2hi __builtin_vis_fpadds16s (v2hi, v2hi);
25816 v4hi __builtin_vis_fpsubs16 (v4hi, v4hi);
25817 v2hi __builtin_vis_fpsubs16s (v2hi, v2hi);
25818 v2si __builtin_vis_fpadds32 (v2si, v2si);
25819 v1si __builtin_vis_fpadds32s (v1si, v1si);
25820 v2si __builtin_vis_fpsubs32 (v2si, v2si);
25821 v1si __builtin_vis_fpsubs32s (v1si, v1si);
25823 long __builtin_vis_fucmple8 (v8qi, v8qi);
25824 long __builtin_vis_fucmpne8 (v8qi, v8qi);
25825 long __builtin_vis_fucmpgt8 (v8qi, v8qi);
25826 long __builtin_vis_fucmpeq8 (v8qi, v8qi);
25828 float __builtin_vis_fhadds (float, float);
25829 double __builtin_vis_fhaddd (double, double);
25830 float __builtin_vis_fhsubs (float, float);
25831 double __builtin_vis_fhsubd (double, double);
25832 float __builtin_vis_fnhadds (float, float);
25833 double __builtin_vis_fnhaddd (double, double);
25835 int64_t __builtin_vis_umulxhi (int64_t, int64_t);
25836 int64_t __builtin_vis_xmulx (int64_t, int64_t);
25837 int64_t __builtin_vis_xmulxhi (int64_t, int64_t);
25838 @end smallexample
25840 When you use the @option{-mvis4} switch, the VIS version 4.0 built-in
25841 functions also become available:
25843 @smallexample
25844 v8qi __builtin_vis_fpadd8 (v8qi, v8qi);
25845 v8qi __builtin_vis_fpadds8 (v8qi, v8qi);
25846 v8qi __builtin_vis_fpaddus8 (v8qi, v8qi);
25847 v4hi __builtin_vis_fpaddus16 (v4hi, v4hi);
25849 v8qi __builtin_vis_fpsub8 (v8qi, v8qi);
25850 v8qi __builtin_vis_fpsubs8 (v8qi, v8qi);
25851 v8qi __builtin_vis_fpsubus8 (v8qi, v8qi);
25852 v4hi __builtin_vis_fpsubus16 (v4hi, v4hi);
25854 long __builtin_vis_fpcmple8 (v8qi, v8qi);
25855 long __builtin_vis_fpcmpgt8 (v8qi, v8qi);
25856 long __builtin_vis_fpcmpule16 (v4hi, v4hi);
25857 long __builtin_vis_fpcmpugt16 (v4hi, v4hi);
25858 long __builtin_vis_fpcmpule32 (v2si, v2si);
25859 long __builtin_vis_fpcmpugt32 (v2si, v2si);
25861 v8qi __builtin_vis_fpmax8 (v8qi, v8qi);
25862 v4hi __builtin_vis_fpmax16 (v4hi, v4hi);
25863 v2si __builtin_vis_fpmax32 (v2si, v2si);
25865 v8qi __builtin_vis_fpmaxu8 (v8qi, v8qi);
25866 v4hi __builtin_vis_fpmaxu16 (v4hi, v4hi);
25867 v2si __builtin_vis_fpmaxu32 (v2si, v2si);
25869 v8qi __builtin_vis_fpmin8 (v8qi, v8qi);
25870 v4hi __builtin_vis_fpmin16 (v4hi, v4hi);
25871 v2si __builtin_vis_fpmin32 (v2si, v2si);
25873 v8qi __builtin_vis_fpminu8 (v8qi, v8qi);
25874 v4hi __builtin_vis_fpminu16 (v4hi, v4hi);
25875 v2si __builtin_vis_fpminu32 (v2si, v2si);
25876 @end smallexample
25878 When you use the @option{-mvis4b} switch, the VIS version 4.0B
25879 built-in functions also become available:
25881 @smallexample
25882 v8qi __builtin_vis_dictunpack8 (double, int);
25883 v4hi __builtin_vis_dictunpack16 (double, int);
25884 v2si __builtin_vis_dictunpack32 (double, int);
25886 long __builtin_vis_fpcmple8shl (v8qi, v8qi, int);
25887 long __builtin_vis_fpcmpgt8shl (v8qi, v8qi, int);
25888 long __builtin_vis_fpcmpeq8shl (v8qi, v8qi, int);
25889 long __builtin_vis_fpcmpne8shl (v8qi, v8qi, int);
25891 long __builtin_vis_fpcmple16shl (v4hi, v4hi, int);
25892 long __builtin_vis_fpcmpgt16shl (v4hi, v4hi, int);
25893 long __builtin_vis_fpcmpeq16shl (v4hi, v4hi, int);
25894 long __builtin_vis_fpcmpne16shl (v4hi, v4hi, int);
25896 long __builtin_vis_fpcmple32shl (v2si, v2si, int);
25897 long __builtin_vis_fpcmpgt32shl (v2si, v2si, int);
25898 long __builtin_vis_fpcmpeq32shl (v2si, v2si, int);
25899 long __builtin_vis_fpcmpne32shl (v2si, v2si, int);
25901 long __builtin_vis_fpcmpule8shl (v8qi, v8qi, int);
25902 long __builtin_vis_fpcmpugt8shl (v8qi, v8qi, int);
25903 long __builtin_vis_fpcmpule16shl (v4hi, v4hi, int);
25904 long __builtin_vis_fpcmpugt16shl (v4hi, v4hi, int);
25905 long __builtin_vis_fpcmpule32shl (v2si, v2si, int);
25906 long __builtin_vis_fpcmpugt32shl (v2si, v2si, int);
25908 long __builtin_vis_fpcmpde8shl (v8qi, v8qi, int);
25909 long __builtin_vis_fpcmpde16shl (v4hi, v4hi, int);
25910 long __builtin_vis_fpcmpde32shl (v2si, v2si, int);
25912 long __builtin_vis_fpcmpur8shl (v8qi, v8qi, int);
25913 long __builtin_vis_fpcmpur16shl (v4hi, v4hi, int);
25914 long __builtin_vis_fpcmpur32shl (v2si, v2si, int);
25915 @end smallexample
25917 @node TI C6X Built-in Functions
25918 @subsection TI C6X Built-in Functions
25920 GCC provides intrinsics to access certain instructions of the TI C6X
25921 processors.  These intrinsics, listed below, are available after
25922 inclusion of the @code{c6x_intrinsics.h} header file.  They map directly
25923 to C6X instructions.
25925 @smallexample
25926 int _sadd (int, int);
25927 int _ssub (int, int);
25928 int _sadd2 (int, int);
25929 int _ssub2 (int, int);
25930 long long _mpy2 (int, int);
25931 long long _smpy2 (int, int);
25932 int _add4 (int, int);
25933 int _sub4 (int, int);
25934 int _saddu4 (int, int);
25936 int _smpy (int, int);
25937 int _smpyh (int, int);
25938 int _smpyhl (int, int);
25939 int _smpylh (int, int);
25941 int _sshl (int, int);
25942 int _subc (int, int);
25944 int _avg2 (int, int);
25945 int _avgu4 (int, int);
25947 int _clrr (int, int);
25948 int _extr (int, int);
25949 int _extru (int, int);
25950 int _abs (int);
25951 int _abs2 (int);
25952 @end smallexample
25954 @node x86 Built-in Functions
25955 @subsection x86 Built-in Functions
25957 These built-in functions are available for the x86-32 and x86-64 family
25958 of computers, depending on the command-line switches used.
25960 If you specify command-line switches such as @option{-msse},
25961 the compiler could use the extended instruction sets even if the built-ins
25962 are not used explicitly in the program.  For this reason, applications
25963 that perform run-time CPU detection must compile separate files for each
25964 supported architecture, using the appropriate flags.  In particular,
25965 the file containing the CPU detection code should be compiled without
25966 these options.
25968 The following machine modes are available for use with MMX built-in functions
25969 (@pxref{Vector Extensions}): @code{V2SI} for a vector of two 32-bit integers,
25970 @code{V4HI} for a vector of four 16-bit integers, and @code{V8QI} for a
25971 vector of eight 8-bit integers.  Some of the built-in functions operate on
25972 MMX registers as a whole 64-bit entity, these use @code{V1DI} as their mode.
25974 If 3DNow!@: extensions are enabled, @code{V2SF} is used as a mode for a vector
25975 of two 32-bit floating-point values.
25977 If SSE extensions are enabled, @code{V4SF} is used for a vector of four 32-bit
25978 floating-point values.  Some instructions use a vector of four 32-bit
25979 integers, these use @code{V4SI}.  Finally, some instructions operate on an
25980 entire vector register, interpreting it as a 128-bit integer, these use mode
25981 @code{TI}.
25983 The x86-32 and x86-64 family of processors use additional built-in
25984 functions for efficient use of @code{TF} (@code{__float128}) 128-bit
25985 floating point and @code{TC} 128-bit complex floating-point values.
25987 The following floating-point built-in functions are always available:
25989 @defbuiltin{__float128 __builtin_fabsq (__float128 @var{x}))}
25990 Computes the absolute value of @var{x}.
25991 @enddefbuiltin
25993 @defbuiltin{__float128 __builtin_copysignq (__float128 @var{x}, @
25994                                             __float128 @var{y})}
25995 Copies the sign of @var{y} into @var{x} and returns the new value of
25996 @var{x}.
25997 @enddefbuiltin
25999 @defbuiltin{__float128 __builtin_infq (void)}
26000 Similar to @code{__builtin_inf}, except the return type is @code{__float128}.
26001 @enddefbuiltin
26003 @defbuiltin{__float128 __builtin_huge_valq (void)}
26004 Similar to @code{__builtin_huge_val}, except the return type is @code{__float128}.
26005 @enddefbuiltin
26007 @defbuiltin{__float128 __builtin_nanq (void)}
26008 Similar to @code{__builtin_nan}, except the return type is @code{__float128}.
26009 @enddefbuiltin
26011 @defbuiltin{__float128 __builtin_nansq (void)}
26012 Similar to @code{__builtin_nans}, except the return type is @code{__float128}.
26013 @enddefbuiltin
26015 The following built-in function is always available.
26017 @defbuiltin{void __builtin_ia32_pause (void)}
26018 Generates the @code{pause} machine instruction with a compiler memory
26019 barrier.
26020 @enddefbuiltin
26022 The following built-in functions are always available and can be used to
26023 check the target platform type.
26025 @defbuiltin{void __builtin_cpu_init (void)}
26026 This function runs the CPU detection code to check the type of CPU and the
26027 features supported.  This built-in function needs to be invoked along with the built-in functions
26028 to check CPU type and features, @code{__builtin_cpu_is} and
26029 @code{__builtin_cpu_supports}, only when used in a function that is
26030 executed before any constructors are called.  The CPU detection code is
26031 automatically executed in a very high priority constructor.
26033 For example, this function has to be used in @code{ifunc} resolvers that
26034 check for CPU type using the built-in functions @code{__builtin_cpu_is}
26035 and @code{__builtin_cpu_supports}, or in constructors on targets that
26036 don't support constructor priority.
26037 @smallexample
26039 static void (*resolve_memcpy (void)) (void)
26041   // ifunc resolvers fire before constructors, explicitly call the init
26042   // function.
26043   __builtin_cpu_init ();
26044   if (__builtin_cpu_supports ("ssse3"))
26045     return ssse3_memcpy; // super fast memcpy with ssse3 instructions.
26046   else
26047     return default_memcpy;
26050 void *memcpy (void *, const void *, size_t)
26051      __attribute__ ((ifunc ("resolve_memcpy")));
26052 @end smallexample
26054 @enddefbuiltin
26056 @defbuiltin{int __builtin_cpu_is (const char *@var{cpuname})}
26057 This function returns a positive integer if the run-time CPU
26058 is of type @var{cpuname}
26059 and returns @code{0} otherwise. The following CPU names can be detected:
26061 @table @samp
26062 @item amd
26063 AMD CPU.
26065 @item intel
26066 Intel CPU.
26068 @item atom
26069 Intel Atom CPU.
26071 @item slm
26072 Intel Silvermont CPU.
26074 @item core2
26075 Intel Core 2 CPU.
26077 @item corei7
26078 Intel Core i7 CPU.
26080 @item nehalem
26081 Intel Core i7 Nehalem CPU.
26083 @item westmere
26084 Intel Core i7 Westmere CPU.
26086 @item sandybridge
26087 Intel Core i7 Sandy Bridge CPU.
26089 @item ivybridge
26090 Intel Core i7 Ivy Bridge CPU.
26092 @item haswell
26093 Intel Core i7 Haswell CPU.
26095 @item broadwell
26096 Intel Core i7 Broadwell CPU.
26098 @item skylake
26099 Intel Core i7 Skylake CPU.
26101 @item skylake-avx512
26102 Intel Core i7 Skylake AVX512 CPU.
26104 @item cannonlake
26105 Intel Core i7 Cannon Lake CPU.
26107 @item icelake-client
26108 Intel Core i7 Ice Lake Client CPU.
26110 @item icelake-server
26111 Intel Core i7 Ice Lake Server CPU.
26113 @item cascadelake
26114 Intel Core i7 Cascadelake CPU.
26116 @item tigerlake
26117 Intel Core i7 Tigerlake CPU.
26119 @item cooperlake
26120 Intel Core i7 Cooperlake CPU.
26122 @item sapphirerapids
26123 Intel Core i7 sapphirerapids CPU.
26125 @item alderlake
26126 Intel Core i7 Alderlake CPU.
26128 @item rocketlake
26129 Intel Core i7 Rocketlake CPU.
26131 @item graniterapids
26132 Intel Core i7 graniterapids CPU.
26134 @item graniterapids-d
26135 Intel Core i7 graniterapids D CPU.
26137 @item arrowlake
26138 Intel Core i7 Arrow Lake CPU.
26140 @item arrowlake-s
26141 Intel Core i7 Arrow Lake S CPU.
26143 @item pantherlake
26144 Intel Core i7 Panther Lake CPU.
26146 @item bonnell
26147 Intel Atom Bonnell CPU.
26149 @item silvermont
26150 Intel Atom Silvermont CPU.
26152 @item goldmont
26153 Intel Atom Goldmont CPU.
26155 @item goldmont-plus
26156 Intel Atom Goldmont Plus CPU.
26158 @item tremont
26159 Intel Atom Tremont CPU.
26161 @item sierraforest
26162 Intel Atom Sierra Forest CPU.
26164 @item grandridge
26165 Intel Atom Grand Ridge CPU.
26167 @item clearwaterforest
26168 Intel Atom Clearwater Forest CPU.
26170 @item knl
26171 Intel Knights Landing CPU.
26173 @item knm
26174 Intel Knights Mill CPU.
26176 @item lujiazui
26177 ZHAOXIN lujiazui CPU.
26179 @item yongfeng
26180 ZHAOXIN yongfeng CPU.
26182 @item amdfam10h
26183 AMD Family 10h CPU.
26185 @item barcelona
26186 AMD Family 10h Barcelona CPU.
26188 @item shanghai
26189 AMD Family 10h Shanghai CPU.
26191 @item istanbul
26192 AMD Family 10h Istanbul CPU.
26194 @item btver1
26195 AMD Family 14h CPU.
26197 @item amdfam15h
26198 AMD Family 15h CPU.
26200 @item bdver1
26201 AMD Family 15h Bulldozer version 1.
26203 @item bdver2
26204 AMD Family 15h Bulldozer version 2.
26206 @item bdver3
26207 AMD Family 15h Bulldozer version 3.
26209 @item bdver4
26210 AMD Family 15h Bulldozer version 4.
26212 @item btver2
26213 AMD Family 16h CPU.
26215 @item amdfam17h
26216 AMD Family 17h CPU.
26218 @item znver1
26219 AMD Family 17h Zen version 1.
26221 @item znver2
26222 AMD Family 17h Zen version 2.
26224 @item amdfam19h
26225 AMD Family 19h CPU.
26227 @item znver3
26228 AMD Family 19h Zen version 3.
26230 @item znver4
26231 AMD Family 19h Zen version 4.
26233 @item znver5
26234 AMD Family 1ah Zen version 5.
26235 @end table
26237 Here is an example:
26238 @smallexample
26239 if (__builtin_cpu_is ("corei7"))
26240   @{
26241      do_corei7 (); // Core i7 specific implementation.
26242   @}
26243 else
26244   @{
26245      do_generic (); // Generic implementation.
26246   @}
26247 @end smallexample
26248 @enddefbuiltin
26250 @defbuiltin{int __builtin_cpu_supports (const char *@var{feature})}
26251 This function returns a positive integer if the run-time CPU
26252 supports @var{feature}
26253 and returns @code{0} otherwise. The following features can be detected:
26255 @table @samp
26256 @item cmov
26257 CMOV instruction.
26258 @item mmx
26259 MMX instructions.
26260 @item popcnt
26261 POPCNT instruction.
26262 @item sse
26263 SSE instructions.
26264 @item sse2
26265 SSE2 instructions.
26266 @item sse3
26267 SSE3 instructions.
26268 @item ssse3
26269 SSSE3 instructions.
26270 @item sse4.1
26271 SSE4.1 instructions.
26272 @item sse4.2
26273 SSE4.2 instructions.
26274 @item avx
26275 AVX instructions.
26276 @item avx2
26277 AVX2 instructions.
26278 @item sse4a
26279 SSE4A instructions.
26280 @item fma4
26281 FMA4 instructions.
26282 @item xop
26283 XOP instructions.
26284 @item fma
26285 FMA instructions.
26286 @item avx512f
26287 AVX512F instructions.
26288 @item bmi
26289 BMI instructions.
26290 @item bmi2
26291 BMI2 instructions.
26292 @item aes
26293 AES instructions.
26294 @item pclmul
26295 PCLMUL instructions.
26296 @item avx512vl
26297 AVX512VL instructions.
26298 @item avx512bw
26299 AVX512BW instructions.
26300 @item avx512dq
26301 AVX512DQ instructions.
26302 @item avx512cd
26303 AVX512CD instructions.
26304 @item avx512er
26305 AVX512ER instructions.
26306 @item avx512pf
26307 AVX512PF instructions.
26308 @item avx512vbmi
26309 AVX512VBMI instructions.
26310 @item avx512ifma
26311 AVX512IFMA instructions.
26312 @item avx5124vnniw
26313 AVX5124VNNIW instructions.
26314 @item avx5124fmaps
26315 AVX5124FMAPS instructions.
26316 @item avx512vpopcntdq
26317 AVX512VPOPCNTDQ instructions.
26318 @item avx512vbmi2
26319 AVX512VBMI2 instructions.
26320 @item gfni
26321 GFNI instructions.
26322 @item vpclmulqdq
26323 VPCLMULQDQ instructions.
26324 @item avx512vnni
26325 AVX512VNNI instructions.
26326 @item avx512bitalg
26327 AVX512BITALG instructions.
26328 @item x86-64
26329 Baseline x86-64 microarchitecture level (as defined in x86-64 psABI).
26330 @item x86-64-v2
26331 x86-64-v2 microarchitecture level.
26332 @item x86-64-v3
26333 x86-64-v3 microarchitecture level.
26334 @item x86-64-v4
26335 x86-64-v4 microarchitecture level.
26338 @end table
26340 Here is an example:
26341 @smallexample
26342 if (__builtin_cpu_supports ("popcnt"))
26343   @{
26344      asm("popcnt %1,%0" : "=r"(count) : "rm"(n) : "cc");
26345   @}
26346 else
26347   @{
26348      count = generic_countbits (n); //generic implementation.
26349   @}
26350 @end smallexample
26351 @enddefbuiltin
26353 The following built-in functions are made available by @option{-mmmx}.
26354 All of them generate the machine instruction that is part of the name.
26356 @smallexample
26357 v8qi __builtin_ia32_paddb (v8qi, v8qi);
26358 v4hi __builtin_ia32_paddw (v4hi, v4hi);
26359 v2si __builtin_ia32_paddd (v2si, v2si);
26360 v8qi __builtin_ia32_psubb (v8qi, v8qi);
26361 v4hi __builtin_ia32_psubw (v4hi, v4hi);
26362 v2si __builtin_ia32_psubd (v2si, v2si);
26363 v8qi __builtin_ia32_paddsb (v8qi, v8qi);
26364 v4hi __builtin_ia32_paddsw (v4hi, v4hi);
26365 v8qi __builtin_ia32_psubsb (v8qi, v8qi);
26366 v4hi __builtin_ia32_psubsw (v4hi, v4hi);
26367 v8qi __builtin_ia32_paddusb (v8qi, v8qi);
26368 v4hi __builtin_ia32_paddusw (v4hi, v4hi);
26369 v8qi __builtin_ia32_psubusb (v8qi, v8qi);
26370 v4hi __builtin_ia32_psubusw (v4hi, v4hi);
26371 v4hi __builtin_ia32_pmullw (v4hi, v4hi);
26372 v4hi __builtin_ia32_pmulhw (v4hi, v4hi);
26373 di __builtin_ia32_pand (di, di);
26374 di __builtin_ia32_pandn (di,di);
26375 di __builtin_ia32_por (di, di);
26376 di __builtin_ia32_pxor (di, di);
26377 v8qi __builtin_ia32_pcmpeqb (v8qi, v8qi);
26378 v4hi __builtin_ia32_pcmpeqw (v4hi, v4hi);
26379 v2si __builtin_ia32_pcmpeqd (v2si, v2si);
26380 v8qi __builtin_ia32_pcmpgtb (v8qi, v8qi);
26381 v4hi __builtin_ia32_pcmpgtw (v4hi, v4hi);
26382 v2si __builtin_ia32_pcmpgtd (v2si, v2si);
26383 v8qi __builtin_ia32_punpckhbw (v8qi, v8qi);
26384 v4hi __builtin_ia32_punpckhwd (v4hi, v4hi);
26385 v2si __builtin_ia32_punpckhdq (v2si, v2si);
26386 v8qi __builtin_ia32_punpcklbw (v8qi, v8qi);
26387 v4hi __builtin_ia32_punpcklwd (v4hi, v4hi);
26388 v2si __builtin_ia32_punpckldq (v2si, v2si);
26389 v8qi __builtin_ia32_packsswb (v4hi, v4hi);
26390 v4hi __builtin_ia32_packssdw (v2si, v2si);
26391 v8qi __builtin_ia32_packuswb (v4hi, v4hi);
26393 v4hi __builtin_ia32_psllw (v4hi, v4hi);
26394 v2si __builtin_ia32_pslld (v2si, v2si);
26395 v1di __builtin_ia32_psllq (v1di, v1di);
26396 v4hi __builtin_ia32_psrlw (v4hi, v4hi);
26397 v2si __builtin_ia32_psrld (v2si, v2si);
26398 v1di __builtin_ia32_psrlq (v1di, v1di);
26399 v4hi __builtin_ia32_psraw (v4hi, v4hi);
26400 v2si __builtin_ia32_psrad (v2si, v2si);
26401 v4hi __builtin_ia32_psllwi (v4hi, int);
26402 v2si __builtin_ia32_pslldi (v2si, int);
26403 v1di __builtin_ia32_psllqi (v1di, int);
26404 v4hi __builtin_ia32_psrlwi (v4hi, int);
26405 v2si __builtin_ia32_psrldi (v2si, int);
26406 v1di __builtin_ia32_psrlqi (v1di, int);
26407 v4hi __builtin_ia32_psrawi (v4hi, int);
26408 v2si __builtin_ia32_psradi (v2si, int);
26409 @end smallexample
26411 The following built-in functions are made available either with
26412 @option{-msse}, or with @option{-m3dnowa}.  All of them generate
26413 the machine instruction that is part of the name.
26415 @smallexample
26416 v4hi __builtin_ia32_pmulhuw (v4hi, v4hi);
26417 v8qi __builtin_ia32_pavgb (v8qi, v8qi);
26418 v4hi __builtin_ia32_pavgw (v4hi, v4hi);
26419 v1di __builtin_ia32_psadbw (v8qi, v8qi);
26420 v8qi __builtin_ia32_pmaxub (v8qi, v8qi);
26421 v4hi __builtin_ia32_pmaxsw (v4hi, v4hi);
26422 v8qi __builtin_ia32_pminub (v8qi, v8qi);
26423 v4hi __builtin_ia32_pminsw (v4hi, v4hi);
26424 int __builtin_ia32_pmovmskb (v8qi);
26425 void __builtin_ia32_maskmovq (v8qi, v8qi, char *);
26426 void __builtin_ia32_movntq (di *, di);
26427 void __builtin_ia32_sfence (void);
26428 @end smallexample
26430 The following built-in functions are available when @option{-msse} is used.
26431 All of them generate the machine instruction that is part of the name.
26433 @smallexample
26434 int __builtin_ia32_comieq (v4sf, v4sf);
26435 int __builtin_ia32_comineq (v4sf, v4sf);
26436 int __builtin_ia32_comilt (v4sf, v4sf);
26437 int __builtin_ia32_comile (v4sf, v4sf);
26438 int __builtin_ia32_comigt (v4sf, v4sf);
26439 int __builtin_ia32_comige (v4sf, v4sf);
26440 int __builtin_ia32_ucomieq (v4sf, v4sf);
26441 int __builtin_ia32_ucomineq (v4sf, v4sf);
26442 int __builtin_ia32_ucomilt (v4sf, v4sf);
26443 int __builtin_ia32_ucomile (v4sf, v4sf);
26444 int __builtin_ia32_ucomigt (v4sf, v4sf);
26445 int __builtin_ia32_ucomige (v4sf, v4sf);
26446 v4sf __builtin_ia32_addps (v4sf, v4sf);
26447 v4sf __builtin_ia32_subps (v4sf, v4sf);
26448 v4sf __builtin_ia32_mulps (v4sf, v4sf);
26449 v4sf __builtin_ia32_divps (v4sf, v4sf);
26450 v4sf __builtin_ia32_addss (v4sf, v4sf);
26451 v4sf __builtin_ia32_subss (v4sf, v4sf);
26452 v4sf __builtin_ia32_mulss (v4sf, v4sf);
26453 v4sf __builtin_ia32_divss (v4sf, v4sf);
26454 v4sf __builtin_ia32_cmpeqps (v4sf, v4sf);
26455 v4sf __builtin_ia32_cmpltps (v4sf, v4sf);
26456 v4sf __builtin_ia32_cmpleps (v4sf, v4sf);
26457 v4sf __builtin_ia32_cmpgtps (v4sf, v4sf);
26458 v4sf __builtin_ia32_cmpgeps (v4sf, v4sf);
26459 v4sf __builtin_ia32_cmpunordps (v4sf, v4sf);
26460 v4sf __builtin_ia32_cmpneqps (v4sf, v4sf);
26461 v4sf __builtin_ia32_cmpnltps (v4sf, v4sf);
26462 v4sf __builtin_ia32_cmpnleps (v4sf, v4sf);
26463 v4sf __builtin_ia32_cmpngtps (v4sf, v4sf);
26464 v4sf __builtin_ia32_cmpngeps (v4sf, v4sf);
26465 v4sf __builtin_ia32_cmpordps (v4sf, v4sf);
26466 v4sf __builtin_ia32_cmpeqss (v4sf, v4sf);
26467 v4sf __builtin_ia32_cmpltss (v4sf, v4sf);
26468 v4sf __builtin_ia32_cmpless (v4sf, v4sf);
26469 v4sf __builtin_ia32_cmpunordss (v4sf, v4sf);
26470 v4sf __builtin_ia32_cmpneqss (v4sf, v4sf);
26471 v4sf __builtin_ia32_cmpnltss (v4sf, v4sf);
26472 v4sf __builtin_ia32_cmpnless (v4sf, v4sf);
26473 v4sf __builtin_ia32_cmpordss (v4sf, v4sf);
26474 v4sf __builtin_ia32_maxps (v4sf, v4sf);
26475 v4sf __builtin_ia32_maxss (v4sf, v4sf);
26476 v4sf __builtin_ia32_minps (v4sf, v4sf);
26477 v4sf __builtin_ia32_minss (v4sf, v4sf);
26478 v4sf __builtin_ia32_andps (v4sf, v4sf);
26479 v4sf __builtin_ia32_andnps (v4sf, v4sf);
26480 v4sf __builtin_ia32_orps (v4sf, v4sf);
26481 v4sf __builtin_ia32_xorps (v4sf, v4sf);
26482 v4sf __builtin_ia32_movss (v4sf, v4sf);
26483 v4sf __builtin_ia32_movhlps (v4sf, v4sf);
26484 v4sf __builtin_ia32_movlhps (v4sf, v4sf);
26485 v4sf __builtin_ia32_unpckhps (v4sf, v4sf);
26486 v4sf __builtin_ia32_unpcklps (v4sf, v4sf);
26487 v4sf __builtin_ia32_cvtpi2ps (v4sf, v2si);
26488 v4sf __builtin_ia32_cvtsi2ss (v4sf, int);
26489 v2si __builtin_ia32_cvtps2pi (v4sf);
26490 int __builtin_ia32_cvtss2si (v4sf);
26491 v2si __builtin_ia32_cvttps2pi (v4sf);
26492 int __builtin_ia32_cvttss2si (v4sf);
26493 v4sf __builtin_ia32_rcpps (v4sf);
26494 v4sf __builtin_ia32_rsqrtps (v4sf);
26495 v4sf __builtin_ia32_sqrtps (v4sf);
26496 v4sf __builtin_ia32_rcpss (v4sf);
26497 v4sf __builtin_ia32_rsqrtss (v4sf);
26498 v4sf __builtin_ia32_sqrtss (v4sf);
26499 v4sf __builtin_ia32_shufps (v4sf, v4sf, int);
26500 void __builtin_ia32_movntps (float *, v4sf);
26501 int __builtin_ia32_movmskps (v4sf);
26502 @end smallexample
26504 The following built-in functions are available when @option{-msse} is used.
26506 @defbuiltin{v4sf __builtin_ia32_loadups (float *)}
26507 Generates the @code{movups} machine instruction as a load from memory.
26508 @enddefbuiltin
26510 @defbuiltin{void __builtin_ia32_storeups (float *, v4sf)}
26511 Generates the @code{movups} machine instruction as a store to memory.
26512 @enddefbuiltin
26514 @defbuiltin{v4sf __builtin_ia32_loadss (float *)}
26515 Generates the @code{movss} machine instruction as a load from memory.
26516 @enddefbuiltin
26518 @defbuiltin{v4sf __builtin_ia32_loadhps (v4sf, const v2sf *)}
26519 Generates the @code{movhps} machine instruction as a load from memory.
26520 @enddefbuiltin
26522 @defbuiltin{v4sf __builtin_ia32_loadlps (v4sf, const v2sf *)}
26523 Generates the @code{movlps} machine instruction as a load from memory
26524 @enddefbuiltin
26526 @defbuiltin{void __builtin_ia32_storehps (v2sf *, v4sf)}
26527 Generates the @code{movhps} machine instruction as a store to memory.
26528 @enddefbuiltin
26530 @defbuiltin{void __builtin_ia32_storelps (v2sf *, v4sf)}
26531 Generates the @code{movlps} machine instruction as a store to memory.
26532 @enddefbuiltin
26534 The following built-in functions are available when @option{-msse2} is used.
26535 All of them generate the machine instruction that is part of the name.
26537 @smallexample
26538 int __builtin_ia32_comisdeq (v2df, v2df);
26539 int __builtin_ia32_comisdlt (v2df, v2df);
26540 int __builtin_ia32_comisdle (v2df, v2df);
26541 int __builtin_ia32_comisdgt (v2df, v2df);
26542 int __builtin_ia32_comisdge (v2df, v2df);
26543 int __builtin_ia32_comisdneq (v2df, v2df);
26544 int __builtin_ia32_ucomisdeq (v2df, v2df);
26545 int __builtin_ia32_ucomisdlt (v2df, v2df);
26546 int __builtin_ia32_ucomisdle (v2df, v2df);
26547 int __builtin_ia32_ucomisdgt (v2df, v2df);
26548 int __builtin_ia32_ucomisdge (v2df, v2df);
26549 int __builtin_ia32_ucomisdneq (v2df, v2df);
26550 v2df __builtin_ia32_cmpeqpd (v2df, v2df);
26551 v2df __builtin_ia32_cmpltpd (v2df, v2df);
26552 v2df __builtin_ia32_cmplepd (v2df, v2df);
26553 v2df __builtin_ia32_cmpgtpd (v2df, v2df);
26554 v2df __builtin_ia32_cmpgepd (v2df, v2df);
26555 v2df __builtin_ia32_cmpunordpd (v2df, v2df);
26556 v2df __builtin_ia32_cmpneqpd (v2df, v2df);
26557 v2df __builtin_ia32_cmpnltpd (v2df, v2df);
26558 v2df __builtin_ia32_cmpnlepd (v2df, v2df);
26559 v2df __builtin_ia32_cmpngtpd (v2df, v2df);
26560 v2df __builtin_ia32_cmpngepd (v2df, v2df);
26561 v2df __builtin_ia32_cmpordpd (v2df, v2df);
26562 v2df __builtin_ia32_cmpeqsd (v2df, v2df);
26563 v2df __builtin_ia32_cmpltsd (v2df, v2df);
26564 v2df __builtin_ia32_cmplesd (v2df, v2df);
26565 v2df __builtin_ia32_cmpunordsd (v2df, v2df);
26566 v2df __builtin_ia32_cmpneqsd (v2df, v2df);
26567 v2df __builtin_ia32_cmpnltsd (v2df, v2df);
26568 v2df __builtin_ia32_cmpnlesd (v2df, v2df);
26569 v2df __builtin_ia32_cmpordsd (v2df, v2df);
26570 v2di __builtin_ia32_paddq (v2di, v2di);
26571 v2di __builtin_ia32_psubq (v2di, v2di);
26572 v2df __builtin_ia32_addpd (v2df, v2df);
26573 v2df __builtin_ia32_subpd (v2df, v2df);
26574 v2df __builtin_ia32_mulpd (v2df, v2df);
26575 v2df __builtin_ia32_divpd (v2df, v2df);
26576 v2df __builtin_ia32_addsd (v2df, v2df);
26577 v2df __builtin_ia32_subsd (v2df, v2df);
26578 v2df __builtin_ia32_mulsd (v2df, v2df);
26579 v2df __builtin_ia32_divsd (v2df, v2df);
26580 v2df __builtin_ia32_minpd (v2df, v2df);
26581 v2df __builtin_ia32_maxpd (v2df, v2df);
26582 v2df __builtin_ia32_minsd (v2df, v2df);
26583 v2df __builtin_ia32_maxsd (v2df, v2df);
26584 v2df __builtin_ia32_andpd (v2df, v2df);
26585 v2df __builtin_ia32_andnpd (v2df, v2df);
26586 v2df __builtin_ia32_orpd (v2df, v2df);
26587 v2df __builtin_ia32_xorpd (v2df, v2df);
26588 v2df __builtin_ia32_movsd (v2df, v2df);
26589 v2df __builtin_ia32_unpckhpd (v2df, v2df);
26590 v2df __builtin_ia32_unpcklpd (v2df, v2df);
26591 v16qi __builtin_ia32_paddb128 (v16qi, v16qi);
26592 v8hi __builtin_ia32_paddw128 (v8hi, v8hi);
26593 v4si __builtin_ia32_paddd128 (v4si, v4si);
26594 v2di __builtin_ia32_paddq128 (v2di, v2di);
26595 v16qi __builtin_ia32_psubb128 (v16qi, v16qi);
26596 v8hi __builtin_ia32_psubw128 (v8hi, v8hi);
26597 v4si __builtin_ia32_psubd128 (v4si, v4si);
26598 v2di __builtin_ia32_psubq128 (v2di, v2di);
26599 v8hi __builtin_ia32_pmullw128 (v8hi, v8hi);
26600 v8hi __builtin_ia32_pmulhw128 (v8hi, v8hi);
26601 v2di __builtin_ia32_pand128 (v2di, v2di);
26602 v2di __builtin_ia32_pandn128 (v2di, v2di);
26603 v2di __builtin_ia32_por128 (v2di, v2di);
26604 v2di __builtin_ia32_pxor128 (v2di, v2di);
26605 v16qi __builtin_ia32_pavgb128 (v16qi, v16qi);
26606 v8hi __builtin_ia32_pavgw128 (v8hi, v8hi);
26607 v16qi __builtin_ia32_pcmpeqb128 (v16qi, v16qi);
26608 v8hi __builtin_ia32_pcmpeqw128 (v8hi, v8hi);
26609 v4si __builtin_ia32_pcmpeqd128 (v4si, v4si);
26610 v16qi __builtin_ia32_pcmpgtb128 (v16qi, v16qi);
26611 v8hi __builtin_ia32_pcmpgtw128 (v8hi, v8hi);
26612 v4si __builtin_ia32_pcmpgtd128 (v4si, v4si);
26613 v16qi __builtin_ia32_pmaxub128 (v16qi, v16qi);
26614 v8hi __builtin_ia32_pmaxsw128 (v8hi, v8hi);
26615 v16qi __builtin_ia32_pminub128 (v16qi, v16qi);
26616 v8hi __builtin_ia32_pminsw128 (v8hi, v8hi);
26617 v16qi __builtin_ia32_punpckhbw128 (v16qi, v16qi);
26618 v8hi __builtin_ia32_punpckhwd128 (v8hi, v8hi);
26619 v4si __builtin_ia32_punpckhdq128 (v4si, v4si);
26620 v2di __builtin_ia32_punpckhqdq128 (v2di, v2di);
26621 v16qi __builtin_ia32_punpcklbw128 (v16qi, v16qi);
26622 v8hi __builtin_ia32_punpcklwd128 (v8hi, v8hi);
26623 v4si __builtin_ia32_punpckldq128 (v4si, v4si);
26624 v2di __builtin_ia32_punpcklqdq128 (v2di, v2di);
26625 v16qi __builtin_ia32_packsswb128 (v8hi, v8hi);
26626 v8hi __builtin_ia32_packssdw128 (v4si, v4si);
26627 v16qi __builtin_ia32_packuswb128 (v8hi, v8hi);
26628 v8hi __builtin_ia32_pmulhuw128 (v8hi, v8hi);
26629 void __builtin_ia32_maskmovdqu (v16qi, v16qi);
26630 v2df __builtin_ia32_loadupd (double *);
26631 void __builtin_ia32_storeupd (double *, v2df);
26632 v2df __builtin_ia32_loadhpd (v2df, double const *);
26633 v2df __builtin_ia32_loadlpd (v2df, double const *);
26634 int __builtin_ia32_movmskpd (v2df);
26635 int __builtin_ia32_pmovmskb128 (v16qi);
26636 void __builtin_ia32_movnti (int *, int);
26637 void __builtin_ia32_movnti64 (long long int *, long long int);
26638 void __builtin_ia32_movntpd (double *, v2df);
26639 void __builtin_ia32_movntdq (v2df *, v2df);
26640 v4si __builtin_ia32_pshufd (v4si, int);
26641 v8hi __builtin_ia32_pshuflw (v8hi, int);
26642 v8hi __builtin_ia32_pshufhw (v8hi, int);
26643 v2di __builtin_ia32_psadbw128 (v16qi, v16qi);
26644 v2df __builtin_ia32_sqrtpd (v2df);
26645 v2df __builtin_ia32_sqrtsd (v2df);
26646 v2df __builtin_ia32_shufpd (v2df, v2df, int);
26647 v2df __builtin_ia32_cvtdq2pd (v4si);
26648 v4sf __builtin_ia32_cvtdq2ps (v4si);
26649 v4si __builtin_ia32_cvtpd2dq (v2df);
26650 v2si __builtin_ia32_cvtpd2pi (v2df);
26651 v4sf __builtin_ia32_cvtpd2ps (v2df);
26652 v4si __builtin_ia32_cvttpd2dq (v2df);
26653 v2si __builtin_ia32_cvttpd2pi (v2df);
26654 v2df __builtin_ia32_cvtpi2pd (v2si);
26655 int __builtin_ia32_cvtsd2si (v2df);
26656 int __builtin_ia32_cvttsd2si (v2df);
26657 long long __builtin_ia32_cvtsd2si64 (v2df);
26658 long long __builtin_ia32_cvttsd2si64 (v2df);
26659 v4si __builtin_ia32_cvtps2dq (v4sf);
26660 v2df __builtin_ia32_cvtps2pd (v4sf);
26661 v4si __builtin_ia32_cvttps2dq (v4sf);
26662 v2df __builtin_ia32_cvtsi2sd (v2df, int);
26663 v2df __builtin_ia32_cvtsi642sd (v2df, long long);
26664 v4sf __builtin_ia32_cvtsd2ss (v4sf, v2df);
26665 v2df __builtin_ia32_cvtss2sd (v2df, v4sf);
26666 void __builtin_ia32_clflush (const void *);
26667 void __builtin_ia32_lfence (void);
26668 void __builtin_ia32_mfence (void);
26669 v16qi __builtin_ia32_loaddqu (const char *);
26670 void __builtin_ia32_storedqu (char *, v16qi);
26671 v1di __builtin_ia32_pmuludq (v2si, v2si);
26672 v2di __builtin_ia32_pmuludq128 (v4si, v4si);
26673 v8hi __builtin_ia32_psllw128 (v8hi, v8hi);
26674 v4si __builtin_ia32_pslld128 (v4si, v4si);
26675 v2di __builtin_ia32_psllq128 (v2di, v2di);
26676 v8hi __builtin_ia32_psrlw128 (v8hi, v8hi);
26677 v4si __builtin_ia32_psrld128 (v4si, v4si);
26678 v2di __builtin_ia32_psrlq128 (v2di, v2di);
26679 v8hi __builtin_ia32_psraw128 (v8hi, v8hi);
26680 v4si __builtin_ia32_psrad128 (v4si, v4si);
26681 v2di __builtin_ia32_pslldqi128 (v2di, int);
26682 v8hi __builtin_ia32_psllwi128 (v8hi, int);
26683 v4si __builtin_ia32_pslldi128 (v4si, int);
26684 v2di __builtin_ia32_psllqi128 (v2di, int);
26685 v2di __builtin_ia32_psrldqi128 (v2di, int);
26686 v8hi __builtin_ia32_psrlwi128 (v8hi, int);
26687 v4si __builtin_ia32_psrldi128 (v4si, int);
26688 v2di __builtin_ia32_psrlqi128 (v2di, int);
26689 v8hi __builtin_ia32_psrawi128 (v8hi, int);
26690 v4si __builtin_ia32_psradi128 (v4si, int);
26691 v4si __builtin_ia32_pmaddwd128 (v8hi, v8hi);
26692 v2di __builtin_ia32_movq128 (v2di);
26693 @end smallexample
26695 The following built-in functions are available when @option{-msse3} is used.
26696 All of them generate the machine instruction that is part of the name.
26698 @smallexample
26699 v2df __builtin_ia32_addsubpd (v2df, v2df);
26700 v4sf __builtin_ia32_addsubps (v4sf, v4sf);
26701 v2df __builtin_ia32_haddpd (v2df, v2df);
26702 v4sf __builtin_ia32_haddps (v4sf, v4sf);
26703 v2df __builtin_ia32_hsubpd (v2df, v2df);
26704 v4sf __builtin_ia32_hsubps (v4sf, v4sf);
26705 v16qi __builtin_ia32_lddqu (char const *);
26706 void __builtin_ia32_monitor (void *, unsigned int, unsigned int);
26707 v4sf __builtin_ia32_movshdup (v4sf);
26708 v4sf __builtin_ia32_movsldup (v4sf);
26709 void __builtin_ia32_mwait (unsigned int, unsigned int);
26710 @end smallexample
26712 The following built-in functions are available when @option{-mssse3} is used.
26713 All of them generate the machine instruction that is part of the name.
26715 @smallexample
26716 v2si __builtin_ia32_phaddd (v2si, v2si);
26717 v4hi __builtin_ia32_phaddw (v4hi, v4hi);
26718 v4hi __builtin_ia32_phaddsw (v4hi, v4hi);
26719 v2si __builtin_ia32_phsubd (v2si, v2si);
26720 v4hi __builtin_ia32_phsubw (v4hi, v4hi);
26721 v4hi __builtin_ia32_phsubsw (v4hi, v4hi);
26722 v4hi __builtin_ia32_pmaddubsw (v8qi, v8qi);
26723 v4hi __builtin_ia32_pmulhrsw (v4hi, v4hi);
26724 v8qi __builtin_ia32_pshufb (v8qi, v8qi);
26725 v8qi __builtin_ia32_psignb (v8qi, v8qi);
26726 v2si __builtin_ia32_psignd (v2si, v2si);
26727 v4hi __builtin_ia32_psignw (v4hi, v4hi);
26728 v1di __builtin_ia32_palignr (v1di, v1di, int);
26729 v8qi __builtin_ia32_pabsb (v8qi);
26730 v2si __builtin_ia32_pabsd (v2si);
26731 v4hi __builtin_ia32_pabsw (v4hi);
26732 @end smallexample
26734 The following built-in functions are available when @option{-mssse3} is used.
26735 All of them generate the machine instruction that is part of the name.
26737 @smallexample
26738 v4si __builtin_ia32_phaddd128 (v4si, v4si);
26739 v8hi __builtin_ia32_phaddw128 (v8hi, v8hi);
26740 v8hi __builtin_ia32_phaddsw128 (v8hi, v8hi);
26741 v4si __builtin_ia32_phsubd128 (v4si, v4si);
26742 v8hi __builtin_ia32_phsubw128 (v8hi, v8hi);
26743 v8hi __builtin_ia32_phsubsw128 (v8hi, v8hi);
26744 v8hi __builtin_ia32_pmaddubsw128 (v16qi, v16qi);
26745 v8hi __builtin_ia32_pmulhrsw128 (v8hi, v8hi);
26746 v16qi __builtin_ia32_pshufb128 (v16qi, v16qi);
26747 v16qi __builtin_ia32_psignb128 (v16qi, v16qi);
26748 v4si __builtin_ia32_psignd128 (v4si, v4si);
26749 v8hi __builtin_ia32_psignw128 (v8hi, v8hi);
26750 v2di __builtin_ia32_palignr128 (v2di, v2di, int);
26751 v16qi __builtin_ia32_pabsb128 (v16qi);
26752 v4si __builtin_ia32_pabsd128 (v4si);
26753 v8hi __builtin_ia32_pabsw128 (v8hi);
26754 @end smallexample
26756 The following built-in functions are available when @option{-msse4.1} is
26757 used.  All of them generate the machine instruction that is part of the
26758 name.
26760 @smallexample
26761 v2df __builtin_ia32_blendpd (v2df, v2df, const int);
26762 v4sf __builtin_ia32_blendps (v4sf, v4sf, const int);
26763 v2df __builtin_ia32_blendvpd (v2df, v2df, v2df);
26764 v4sf __builtin_ia32_blendvps (v4sf, v4sf, v4sf);
26765 v2df __builtin_ia32_dppd (v2df, v2df, const int);
26766 v4sf __builtin_ia32_dpps (v4sf, v4sf, const int);
26767 v4sf __builtin_ia32_insertps128 (v4sf, v4sf, const int);
26768 v2di __builtin_ia32_movntdqa (v2di *);
26769 v16qi __builtin_ia32_mpsadbw128 (v16qi, v16qi, const int);
26770 v8hi __builtin_ia32_packusdw128 (v4si, v4si);
26771 v16qi __builtin_ia32_pblendvb128 (v16qi, v16qi, v16qi);
26772 v8hi __builtin_ia32_pblendw128 (v8hi, v8hi, const int);
26773 v2di __builtin_ia32_pcmpeqq (v2di, v2di);
26774 v8hi __builtin_ia32_phminposuw128 (v8hi);
26775 v16qi __builtin_ia32_pmaxsb128 (v16qi, v16qi);
26776 v4si __builtin_ia32_pmaxsd128 (v4si, v4si);
26777 v4si __builtin_ia32_pmaxud128 (v4si, v4si);
26778 v8hi __builtin_ia32_pmaxuw128 (v8hi, v8hi);
26779 v16qi __builtin_ia32_pminsb128 (v16qi, v16qi);
26780 v4si __builtin_ia32_pminsd128 (v4si, v4si);
26781 v4si __builtin_ia32_pminud128 (v4si, v4si);
26782 v8hi __builtin_ia32_pminuw128 (v8hi, v8hi);
26783 v4si __builtin_ia32_pmovsxbd128 (v16qi);
26784 v2di __builtin_ia32_pmovsxbq128 (v16qi);
26785 v8hi __builtin_ia32_pmovsxbw128 (v16qi);
26786 v2di __builtin_ia32_pmovsxdq128 (v4si);
26787 v4si __builtin_ia32_pmovsxwd128 (v8hi);
26788 v2di __builtin_ia32_pmovsxwq128 (v8hi);
26789 v4si __builtin_ia32_pmovzxbd128 (v16qi);
26790 v2di __builtin_ia32_pmovzxbq128 (v16qi);
26791 v8hi __builtin_ia32_pmovzxbw128 (v16qi);
26792 v2di __builtin_ia32_pmovzxdq128 (v4si);
26793 v4si __builtin_ia32_pmovzxwd128 (v8hi);
26794 v2di __builtin_ia32_pmovzxwq128 (v8hi);
26795 v2di __builtin_ia32_pmuldq128 (v4si, v4si);
26796 v4si __builtin_ia32_pmulld128 (v4si, v4si);
26797 int __builtin_ia32_ptestc128 (v2di, v2di);
26798 int __builtin_ia32_ptestnzc128 (v2di, v2di);
26799 int __builtin_ia32_ptestz128 (v2di, v2di);
26800 v2df __builtin_ia32_roundpd (v2df, const int);
26801 v4sf __builtin_ia32_roundps (v4sf, const int);
26802 v2df __builtin_ia32_roundsd (v2df, v2df, const int);
26803 v4sf __builtin_ia32_roundss (v4sf, v4sf, const int);
26804 @end smallexample
26806 The following built-in functions are available when @option{-msse4.1} is
26807 used.
26809 @defbuiltin{v4sf __builtin_ia32_vec_set_v4sf (v4sf, float, const int)}
26810 Generates the @code{insertps} machine instruction.
26811 @enddefbuiltin
26813 @defbuiltin{int __builtin_ia32_vec_ext_v16qi (v16qi, const int)}
26814 Generates the @code{pextrb} machine instruction.
26815 @enddefbuiltin
26817 @defbuiltin{v16qi __builtin_ia32_vec_set_v16qi (v16qi, int, const int)}
26818 Generates the @code{pinsrb} machine instruction.
26819 @enddefbuiltin
26821 @defbuiltin{v4si __builtin_ia32_vec_set_v4si (v4si, int, const int)}
26822 Generates the @code{pinsrd} machine instruction.
26823 @enddefbuiltin
26825 @defbuiltin{v2di __builtin_ia32_vec_set_v2di (v2di, long long, const int)}
26826 Generates the @code{pinsrq} machine instruction in 64bit mode.
26827 @enddefbuiltin
26829 The following built-in functions are changed to generate new SSE4.1
26830 instructions when @option{-msse4.1} is used.
26832 @defbuiltin{float __builtin_ia32_vec_ext_v4sf (v4sf, const int)}
26833 Generates the @code{extractps} machine instruction.
26834 @enddefbuiltin
26836 @defbuiltin{int __builtin_ia32_vec_ext_v4si (v4si, const int)}
26837 Generates the @code{pextrd} machine instruction.
26838 @enddefbuiltin
26840 @defbuiltin{{long long} __builtin_ia32_vec_ext_v2di (v2di, const int)}
26841 Generates the @code{pextrq} machine instruction in 64bit mode.
26842 @enddefbuiltin
26844 The following built-in functions are available when @option{-msse4.2} is
26845 used.  All of them generate the machine instruction that is part of the
26846 name.
26848 @smallexample
26849 v16qi __builtin_ia32_pcmpestrm128 (v16qi, int, v16qi, int, const int);
26850 int __builtin_ia32_pcmpestri128 (v16qi, int, v16qi, int, const int);
26851 int __builtin_ia32_pcmpestria128 (v16qi, int, v16qi, int, const int);
26852 int __builtin_ia32_pcmpestric128 (v16qi, int, v16qi, int, const int);
26853 int __builtin_ia32_pcmpestrio128 (v16qi, int, v16qi, int, const int);
26854 int __builtin_ia32_pcmpestris128 (v16qi, int, v16qi, int, const int);
26855 int __builtin_ia32_pcmpestriz128 (v16qi, int, v16qi, int, const int);
26856 v16qi __builtin_ia32_pcmpistrm128 (v16qi, v16qi, const int);
26857 int __builtin_ia32_pcmpistri128 (v16qi, v16qi, const int);
26858 int __builtin_ia32_pcmpistria128 (v16qi, v16qi, const int);
26859 int __builtin_ia32_pcmpistric128 (v16qi, v16qi, const int);
26860 int __builtin_ia32_pcmpistrio128 (v16qi, v16qi, const int);
26861 int __builtin_ia32_pcmpistris128 (v16qi, v16qi, const int);
26862 int __builtin_ia32_pcmpistriz128 (v16qi, v16qi, const int);
26863 v2di __builtin_ia32_pcmpgtq (v2di, v2di);
26864 @end smallexample
26866 The following built-in functions are available when @option{-msse4.2} is
26867 used.
26869 @defbuiltin{{unsigned int} __builtin_ia32_crc32qi (unsigned int, unsigned char)}
26870 Generates the @code{crc32b} machine instruction.
26871 @enddefbuiltin
26873 @defbuiltin{{unsigned int} __builtin_ia32_crc32hi (unsigned int, unsigned short)}
26874 Generates the @code{crc32w} machine instruction.
26875 @enddefbuiltin
26877 @defbuiltin{{unsigned int} __builtin_ia32_crc32si (unsigned int, unsigned int)}
26878 Generates the @code{crc32l} machine instruction.
26879 @enddefbuiltin
26881 @defbuiltin{{unsigned long long} __builtin_ia32_crc32di (unsigned long long, unsigned long long)}
26882 Generates the @code{crc32q} machine instruction.
26883 @enddefbuiltin
26885 The following built-in functions are changed to generate new SSE4.2
26886 instructions when @option{-msse4.2} is used.
26888 @defbuiltin{int __builtin_popcount (unsigned int)}
26889 Generates the @code{popcntl} machine instruction.
26890 @enddefbuiltin
26892 @defbuiltin{int __builtin_popcountl (unsigned long)}
26893 Generates the @code{popcntl} or @code{popcntq} machine instruction,
26894 depending on the size of @code{unsigned long}.
26895 @enddefbuiltin
26897 @defbuiltin{int __builtin_popcountll (unsigned long long)}
26898 Generates the @code{popcntq} machine instruction.
26899 @enddefbuiltin
26901 The following built-in functions are available when @option{-mavx} is
26902 used. All of them generate the machine instruction that is part of the
26903 name.
26905 @smallexample
26906 v4df __builtin_ia32_addpd256 (v4df,v4df);
26907 v8sf __builtin_ia32_addps256 (v8sf,v8sf);
26908 v4df __builtin_ia32_addsubpd256 (v4df,v4df);
26909 v8sf __builtin_ia32_addsubps256 (v8sf,v8sf);
26910 v4df __builtin_ia32_andnpd256 (v4df,v4df);
26911 v8sf __builtin_ia32_andnps256 (v8sf,v8sf);
26912 v4df __builtin_ia32_andpd256 (v4df,v4df);
26913 v8sf __builtin_ia32_andps256 (v8sf,v8sf);
26914 v4df __builtin_ia32_blendpd256 (v4df,v4df,int);
26915 v8sf __builtin_ia32_blendps256 (v8sf,v8sf,int);
26916 v4df __builtin_ia32_blendvpd256 (v4df,v4df,v4df);
26917 v8sf __builtin_ia32_blendvps256 (v8sf,v8sf,v8sf);
26918 v2df __builtin_ia32_cmppd (v2df,v2df,int);
26919 v4df __builtin_ia32_cmppd256 (v4df,v4df,int);
26920 v4sf __builtin_ia32_cmpps (v4sf,v4sf,int);
26921 v8sf __builtin_ia32_cmpps256 (v8sf,v8sf,int);
26922 v2df __builtin_ia32_cmpsd (v2df,v2df,int);
26923 v4sf __builtin_ia32_cmpss (v4sf,v4sf,int);
26924 v4df __builtin_ia32_cvtdq2pd256 (v4si);
26925 v8sf __builtin_ia32_cvtdq2ps256 (v8si);
26926 v4si __builtin_ia32_cvtpd2dq256 (v4df);
26927 v4sf __builtin_ia32_cvtpd2ps256 (v4df);
26928 v8si __builtin_ia32_cvtps2dq256 (v8sf);
26929 v4df __builtin_ia32_cvtps2pd256 (v4sf);
26930 v4si __builtin_ia32_cvttpd2dq256 (v4df);
26931 v8si __builtin_ia32_cvttps2dq256 (v8sf);
26932 v4df __builtin_ia32_divpd256 (v4df,v4df);
26933 v8sf __builtin_ia32_divps256 (v8sf,v8sf);
26934 v8sf __builtin_ia32_dpps256 (v8sf,v8sf,int);
26935 v4df __builtin_ia32_haddpd256 (v4df,v4df);
26936 v8sf __builtin_ia32_haddps256 (v8sf,v8sf);
26937 v4df __builtin_ia32_hsubpd256 (v4df,v4df);
26938 v8sf __builtin_ia32_hsubps256 (v8sf,v8sf);
26939 v32qi __builtin_ia32_lddqu256 (pcchar);
26940 v32qi __builtin_ia32_loaddqu256 (pcchar);
26941 v4df __builtin_ia32_loadupd256 (pcdouble);
26942 v8sf __builtin_ia32_loadups256 (pcfloat);
26943 v2df __builtin_ia32_maskloadpd (pcv2df,v2df);
26944 v4df __builtin_ia32_maskloadpd256 (pcv4df,v4df);
26945 v4sf __builtin_ia32_maskloadps (pcv4sf,v4sf);
26946 v8sf __builtin_ia32_maskloadps256 (pcv8sf,v8sf);
26947 void __builtin_ia32_maskstorepd (pv2df,v2df,v2df);
26948 void __builtin_ia32_maskstorepd256 (pv4df,v4df,v4df);
26949 void __builtin_ia32_maskstoreps (pv4sf,v4sf,v4sf);
26950 void __builtin_ia32_maskstoreps256 (pv8sf,v8sf,v8sf);
26951 v4df __builtin_ia32_maxpd256 (v4df,v4df);
26952 v8sf __builtin_ia32_maxps256 (v8sf,v8sf);
26953 v4df __builtin_ia32_minpd256 (v4df,v4df);
26954 v8sf __builtin_ia32_minps256 (v8sf,v8sf);
26955 v4df __builtin_ia32_movddup256 (v4df);
26956 int __builtin_ia32_movmskpd256 (v4df);
26957 int __builtin_ia32_movmskps256 (v8sf);
26958 v8sf __builtin_ia32_movshdup256 (v8sf);
26959 v8sf __builtin_ia32_movsldup256 (v8sf);
26960 v4df __builtin_ia32_mulpd256 (v4df,v4df);
26961 v8sf __builtin_ia32_mulps256 (v8sf,v8sf);
26962 v4df __builtin_ia32_orpd256 (v4df,v4df);
26963 v8sf __builtin_ia32_orps256 (v8sf,v8sf);
26964 v2df __builtin_ia32_pd_pd256 (v4df);
26965 v4df __builtin_ia32_pd256_pd (v2df);
26966 v4sf __builtin_ia32_ps_ps256 (v8sf);
26967 v8sf __builtin_ia32_ps256_ps (v4sf);
26968 int __builtin_ia32_ptestc256 (v4di,v4di,ptest);
26969 int __builtin_ia32_ptestnzc256 (v4di,v4di,ptest);
26970 int __builtin_ia32_ptestz256 (v4di,v4di,ptest);
26971 v8sf __builtin_ia32_rcpps256 (v8sf);
26972 v4df __builtin_ia32_roundpd256 (v4df,int);
26973 v8sf __builtin_ia32_roundps256 (v8sf,int);
26974 v8sf __builtin_ia32_rsqrtps_nr256 (v8sf);
26975 v8sf __builtin_ia32_rsqrtps256 (v8sf);
26976 v4df __builtin_ia32_shufpd256 (v4df,v4df,int);
26977 v8sf __builtin_ia32_shufps256 (v8sf,v8sf,int);
26978 v4si __builtin_ia32_si_si256 (v8si);
26979 v8si __builtin_ia32_si256_si (v4si);
26980 v4df __builtin_ia32_sqrtpd256 (v4df);
26981 v8sf __builtin_ia32_sqrtps_nr256 (v8sf);
26982 v8sf __builtin_ia32_sqrtps256 (v8sf);
26983 void __builtin_ia32_storedqu256 (pchar,v32qi);
26984 void __builtin_ia32_storeupd256 (pdouble,v4df);
26985 void __builtin_ia32_storeups256 (pfloat,v8sf);
26986 v4df __builtin_ia32_subpd256 (v4df,v4df);
26987 v8sf __builtin_ia32_subps256 (v8sf,v8sf);
26988 v4df __builtin_ia32_unpckhpd256 (v4df,v4df);
26989 v8sf __builtin_ia32_unpckhps256 (v8sf,v8sf);
26990 v4df __builtin_ia32_unpcklpd256 (v4df,v4df);
26991 v8sf __builtin_ia32_unpcklps256 (v8sf,v8sf);
26992 v4df __builtin_ia32_vbroadcastf128_pd256 (pcv2df);
26993 v8sf __builtin_ia32_vbroadcastf128_ps256 (pcv4sf);
26994 v4df __builtin_ia32_vbroadcastsd256 (pcdouble);
26995 v4sf __builtin_ia32_vbroadcastss (pcfloat);
26996 v8sf __builtin_ia32_vbroadcastss256 (pcfloat);
26997 v2df __builtin_ia32_vextractf128_pd256 (v4df,int);
26998 v4sf __builtin_ia32_vextractf128_ps256 (v8sf,int);
26999 v4si __builtin_ia32_vextractf128_si256 (v8si,int);
27000 v4df __builtin_ia32_vinsertf128_pd256 (v4df,v2df,int);
27001 v8sf __builtin_ia32_vinsertf128_ps256 (v8sf,v4sf,int);
27002 v8si __builtin_ia32_vinsertf128_si256 (v8si,v4si,int);
27003 v4df __builtin_ia32_vperm2f128_pd256 (v4df,v4df,int);
27004 v8sf __builtin_ia32_vperm2f128_ps256 (v8sf,v8sf,int);
27005 v8si __builtin_ia32_vperm2f128_si256 (v8si,v8si,int);
27006 v2df __builtin_ia32_vpermil2pd (v2df,v2df,v2di,int);
27007 v4df __builtin_ia32_vpermil2pd256 (v4df,v4df,v4di,int);
27008 v4sf __builtin_ia32_vpermil2ps (v4sf,v4sf,v4si,int);
27009 v8sf __builtin_ia32_vpermil2ps256 (v8sf,v8sf,v8si,int);
27010 v2df __builtin_ia32_vpermilpd (v2df,int);
27011 v4df __builtin_ia32_vpermilpd256 (v4df,int);
27012 v4sf __builtin_ia32_vpermilps (v4sf,int);
27013 v8sf __builtin_ia32_vpermilps256 (v8sf,int);
27014 v2df __builtin_ia32_vpermilvarpd (v2df,v2di);
27015 v4df __builtin_ia32_vpermilvarpd256 (v4df,v4di);
27016 v4sf __builtin_ia32_vpermilvarps (v4sf,v4si);
27017 v8sf __builtin_ia32_vpermilvarps256 (v8sf,v8si);
27018 int __builtin_ia32_vtestcpd (v2df,v2df,ptest);
27019 int __builtin_ia32_vtestcpd256 (v4df,v4df,ptest);
27020 int __builtin_ia32_vtestcps (v4sf,v4sf,ptest);
27021 int __builtin_ia32_vtestcps256 (v8sf,v8sf,ptest);
27022 int __builtin_ia32_vtestnzcpd (v2df,v2df,ptest);
27023 int __builtin_ia32_vtestnzcpd256 (v4df,v4df,ptest);
27024 int __builtin_ia32_vtestnzcps (v4sf,v4sf,ptest);
27025 int __builtin_ia32_vtestnzcps256 (v8sf,v8sf,ptest);
27026 int __builtin_ia32_vtestzpd (v2df,v2df,ptest);
27027 int __builtin_ia32_vtestzpd256 (v4df,v4df,ptest);
27028 int __builtin_ia32_vtestzps (v4sf,v4sf,ptest);
27029 int __builtin_ia32_vtestzps256 (v8sf,v8sf,ptest);
27030 void __builtin_ia32_vzeroall (void);
27031 void __builtin_ia32_vzeroupper (void);
27032 v4df __builtin_ia32_xorpd256 (v4df,v4df);
27033 v8sf __builtin_ia32_xorps256 (v8sf,v8sf);
27034 @end smallexample
27036 The following built-in functions are available when @option{-mavx2} is
27037 used. All of them generate the machine instruction that is part of the
27038 name.
27040 @smallexample
27041 v32qi __builtin_ia32_mpsadbw256 (v32qi,v32qi,int);
27042 v32qi __builtin_ia32_pabsb256 (v32qi);
27043 v16hi __builtin_ia32_pabsw256 (v16hi);
27044 v8si __builtin_ia32_pabsd256 (v8si);
27045 v16hi __builtin_ia32_packssdw256 (v8si,v8si);
27046 v32qi __builtin_ia32_packsswb256 (v16hi,v16hi);
27047 v16hi __builtin_ia32_packusdw256 (v8si,v8si);
27048 v32qi __builtin_ia32_packuswb256 (v16hi,v16hi);
27049 v32qi __builtin_ia32_paddb256 (v32qi,v32qi);
27050 v16hi __builtin_ia32_paddw256 (v16hi,v16hi);
27051 v8si __builtin_ia32_paddd256 (v8si,v8si);
27052 v4di __builtin_ia32_paddq256 (v4di,v4di);
27053 v32qi __builtin_ia32_paddsb256 (v32qi,v32qi);
27054 v16hi __builtin_ia32_paddsw256 (v16hi,v16hi);
27055 v32qi __builtin_ia32_paddusb256 (v32qi,v32qi);
27056 v16hi __builtin_ia32_paddusw256 (v16hi,v16hi);
27057 v4di __builtin_ia32_palignr256 (v4di,v4di,int);
27058 v4di __builtin_ia32_andsi256 (v4di,v4di);
27059 v4di __builtin_ia32_andnotsi256 (v4di,v4di);
27060 v32qi __builtin_ia32_pavgb256 (v32qi,v32qi);
27061 v16hi __builtin_ia32_pavgw256 (v16hi,v16hi);
27062 v32qi __builtin_ia32_pblendvb256 (v32qi,v32qi,v32qi);
27063 v16hi __builtin_ia32_pblendw256 (v16hi,v16hi,int);
27064 v32qi __builtin_ia32_pcmpeqb256 (v32qi,v32qi);
27065 v16hi __builtin_ia32_pcmpeqw256 (v16hi,v16hi);
27066 v8si __builtin_ia32_pcmpeqd256 (c8si,v8si);
27067 v4di __builtin_ia32_pcmpeqq256 (v4di,v4di);
27068 v32qi __builtin_ia32_pcmpgtb256 (v32qi,v32qi);
27069 v16hi __builtin_ia32_pcmpgtw256 (16hi,v16hi);
27070 v8si __builtin_ia32_pcmpgtd256 (v8si,v8si);
27071 v4di __builtin_ia32_pcmpgtq256 (v4di,v4di);
27072 v16hi __builtin_ia32_phaddw256 (v16hi,v16hi);
27073 v8si __builtin_ia32_phaddd256 (v8si,v8si);
27074 v16hi __builtin_ia32_phaddsw256 (v16hi,v16hi);
27075 v16hi __builtin_ia32_phsubw256 (v16hi,v16hi);
27076 v8si __builtin_ia32_phsubd256 (v8si,v8si);
27077 v16hi __builtin_ia32_phsubsw256 (v16hi,v16hi);
27078 v32qi __builtin_ia32_pmaddubsw256 (v32qi,v32qi);
27079 v16hi __builtin_ia32_pmaddwd256 (v16hi,v16hi);
27080 v32qi __builtin_ia32_pmaxsb256 (v32qi,v32qi);
27081 v16hi __builtin_ia32_pmaxsw256 (v16hi,v16hi);
27082 v8si __builtin_ia32_pmaxsd256 (v8si,v8si);
27083 v32qi __builtin_ia32_pmaxub256 (v32qi,v32qi);
27084 v16hi __builtin_ia32_pmaxuw256 (v16hi,v16hi);
27085 v8si __builtin_ia32_pmaxud256 (v8si,v8si);
27086 v32qi __builtin_ia32_pminsb256 (v32qi,v32qi);
27087 v16hi __builtin_ia32_pminsw256 (v16hi,v16hi);
27088 v8si __builtin_ia32_pminsd256 (v8si,v8si);
27089 v32qi __builtin_ia32_pminub256 (v32qi,v32qi);
27090 v16hi __builtin_ia32_pminuw256 (v16hi,v16hi);
27091 v8si __builtin_ia32_pminud256 (v8si,v8si);
27092 int __builtin_ia32_pmovmskb256 (v32qi);
27093 v16hi __builtin_ia32_pmovsxbw256 (v16qi);
27094 v8si __builtin_ia32_pmovsxbd256 (v16qi);
27095 v4di __builtin_ia32_pmovsxbq256 (v16qi);
27096 v8si __builtin_ia32_pmovsxwd256 (v8hi);
27097 v4di __builtin_ia32_pmovsxwq256 (v8hi);
27098 v4di __builtin_ia32_pmovsxdq256 (v4si);
27099 v16hi __builtin_ia32_pmovzxbw256 (v16qi);
27100 v8si __builtin_ia32_pmovzxbd256 (v16qi);
27101 v4di __builtin_ia32_pmovzxbq256 (v16qi);
27102 v8si __builtin_ia32_pmovzxwd256 (v8hi);
27103 v4di __builtin_ia32_pmovzxwq256 (v8hi);
27104 v4di __builtin_ia32_pmovzxdq256 (v4si);
27105 v4di __builtin_ia32_pmuldq256 (v8si,v8si);
27106 v16hi __builtin_ia32_pmulhrsw256 (v16hi, v16hi);
27107 v16hi __builtin_ia32_pmulhuw256 (v16hi,v16hi);
27108 v16hi __builtin_ia32_pmulhw256 (v16hi,v16hi);
27109 v16hi __builtin_ia32_pmullw256 (v16hi,v16hi);
27110 v8si __builtin_ia32_pmulld256 (v8si,v8si);
27111 v4di __builtin_ia32_pmuludq256 (v8si,v8si);
27112 v4di __builtin_ia32_por256 (v4di,v4di);
27113 v16hi __builtin_ia32_psadbw256 (v32qi,v32qi);
27114 v32qi __builtin_ia32_pshufb256 (v32qi,v32qi);
27115 v8si __builtin_ia32_pshufd256 (v8si,int);
27116 v16hi __builtin_ia32_pshufhw256 (v16hi,int);
27117 v16hi __builtin_ia32_pshuflw256 (v16hi,int);
27118 v32qi __builtin_ia32_psignb256 (v32qi,v32qi);
27119 v16hi __builtin_ia32_psignw256 (v16hi,v16hi);
27120 v8si __builtin_ia32_psignd256 (v8si,v8si);
27121 v4di __builtin_ia32_pslldqi256 (v4di,int);
27122 v16hi __builtin_ia32_psllwi256 (16hi,int);
27123 v16hi __builtin_ia32_psllw256(v16hi,v8hi);
27124 v8si __builtin_ia32_pslldi256 (v8si,int);
27125 v8si __builtin_ia32_pslld256(v8si,v4si);
27126 v4di __builtin_ia32_psllqi256 (v4di,int);
27127 v4di __builtin_ia32_psllq256(v4di,v2di);
27128 v16hi __builtin_ia32_psrawi256 (v16hi,int);
27129 v16hi __builtin_ia32_psraw256 (v16hi,v8hi);
27130 v8si __builtin_ia32_psradi256 (v8si,int);
27131 v8si __builtin_ia32_psrad256 (v8si,v4si);
27132 v4di __builtin_ia32_psrldqi256 (v4di, int);
27133 v16hi __builtin_ia32_psrlwi256 (v16hi,int);
27134 v16hi __builtin_ia32_psrlw256 (v16hi,v8hi);
27135 v8si __builtin_ia32_psrldi256 (v8si,int);
27136 v8si __builtin_ia32_psrld256 (v8si,v4si);
27137 v4di __builtin_ia32_psrlqi256 (v4di,int);
27138 v4di __builtin_ia32_psrlq256(v4di,v2di);
27139 v32qi __builtin_ia32_psubb256 (v32qi,v32qi);
27140 v32hi __builtin_ia32_psubw256 (v16hi,v16hi);
27141 v8si __builtin_ia32_psubd256 (v8si,v8si);
27142 v4di __builtin_ia32_psubq256 (v4di,v4di);
27143 v32qi __builtin_ia32_psubsb256 (v32qi,v32qi);
27144 v16hi __builtin_ia32_psubsw256 (v16hi,v16hi);
27145 v32qi __builtin_ia32_psubusb256 (v32qi,v32qi);
27146 v16hi __builtin_ia32_psubusw256 (v16hi,v16hi);
27147 v32qi __builtin_ia32_punpckhbw256 (v32qi,v32qi);
27148 v16hi __builtin_ia32_punpckhwd256 (v16hi,v16hi);
27149 v8si __builtin_ia32_punpckhdq256 (v8si,v8si);
27150 v4di __builtin_ia32_punpckhqdq256 (v4di,v4di);
27151 v32qi __builtin_ia32_punpcklbw256 (v32qi,v32qi);
27152 v16hi __builtin_ia32_punpcklwd256 (v16hi,v16hi);
27153 v8si __builtin_ia32_punpckldq256 (v8si,v8si);
27154 v4di __builtin_ia32_punpcklqdq256 (v4di,v4di);
27155 v4di __builtin_ia32_pxor256 (v4di,v4di);
27156 v4di __builtin_ia32_movntdqa256 (pv4di);
27157 v4sf __builtin_ia32_vbroadcastss_ps (v4sf);
27158 v8sf __builtin_ia32_vbroadcastss_ps256 (v4sf);
27159 v4df __builtin_ia32_vbroadcastsd_pd256 (v2df);
27160 v4di __builtin_ia32_vbroadcastsi256 (v2di);
27161 v4si __builtin_ia32_pblendd128 (v4si,v4si);
27162 v8si __builtin_ia32_pblendd256 (v8si,v8si);
27163 v32qi __builtin_ia32_pbroadcastb256 (v16qi);
27164 v16hi __builtin_ia32_pbroadcastw256 (v8hi);
27165 v8si __builtin_ia32_pbroadcastd256 (v4si);
27166 v4di __builtin_ia32_pbroadcastq256 (v2di);
27167 v16qi __builtin_ia32_pbroadcastb128 (v16qi);
27168 v8hi __builtin_ia32_pbroadcastw128 (v8hi);
27169 v4si __builtin_ia32_pbroadcastd128 (v4si);
27170 v2di __builtin_ia32_pbroadcastq128 (v2di);
27171 v8si __builtin_ia32_permvarsi256 (v8si,v8si);
27172 v4df __builtin_ia32_permdf256 (v4df,int);
27173 v8sf __builtin_ia32_permvarsf256 (v8sf,v8sf);
27174 v4di __builtin_ia32_permdi256 (v4di,int);
27175 v4di __builtin_ia32_permti256 (v4di,v4di,int);
27176 v4di __builtin_ia32_extract128i256 (v4di,int);
27177 v4di __builtin_ia32_insert128i256 (v4di,v2di,int);
27178 v8si __builtin_ia32_maskloadd256 (pcv8si,v8si);
27179 v4di __builtin_ia32_maskloadq256 (pcv4di,v4di);
27180 v4si __builtin_ia32_maskloadd (pcv4si,v4si);
27181 v2di __builtin_ia32_maskloadq (pcv2di,v2di);
27182 void __builtin_ia32_maskstored256 (pv8si,v8si,v8si);
27183 void __builtin_ia32_maskstoreq256 (pv4di,v4di,v4di);
27184 void __builtin_ia32_maskstored (pv4si,v4si,v4si);
27185 void __builtin_ia32_maskstoreq (pv2di,v2di,v2di);
27186 v8si __builtin_ia32_psllv8si (v8si,v8si);
27187 v4si __builtin_ia32_psllv4si (v4si,v4si);
27188 v4di __builtin_ia32_psllv4di (v4di,v4di);
27189 v2di __builtin_ia32_psllv2di (v2di,v2di);
27190 v8si __builtin_ia32_psrav8si (v8si,v8si);
27191 v4si __builtin_ia32_psrav4si (v4si,v4si);
27192 v8si __builtin_ia32_psrlv8si (v8si,v8si);
27193 v4si __builtin_ia32_psrlv4si (v4si,v4si);
27194 v4di __builtin_ia32_psrlv4di (v4di,v4di);
27195 v2di __builtin_ia32_psrlv2di (v2di,v2di);
27196 v2df __builtin_ia32_gathersiv2df (v2df, pcdouble,v4si,v2df,int);
27197 v4df __builtin_ia32_gathersiv4df (v4df, pcdouble,v4si,v4df,int);
27198 v2df __builtin_ia32_gatherdiv2df (v2df, pcdouble,v2di,v2df,int);
27199 v4df __builtin_ia32_gatherdiv4df (v4df, pcdouble,v4di,v4df,int);
27200 v4sf __builtin_ia32_gathersiv4sf (v4sf, pcfloat,v4si,v4sf,int);
27201 v8sf __builtin_ia32_gathersiv8sf (v8sf, pcfloat,v8si,v8sf,int);
27202 v4sf __builtin_ia32_gatherdiv4sf (v4sf, pcfloat,v2di,v4sf,int);
27203 v4sf __builtin_ia32_gatherdiv4sf256 (v4sf, pcfloat,v4di,v4sf,int);
27204 v2di __builtin_ia32_gathersiv2di (v2di, pcint64,v4si,v2di,int);
27205 v4di __builtin_ia32_gathersiv4di (v4di, pcint64,v4si,v4di,int);
27206 v2di __builtin_ia32_gatherdiv2di (v2di, pcint64,v2di,v2di,int);
27207 v4di __builtin_ia32_gatherdiv4di (v4di, pcint64,v4di,v4di,int);
27208 v4si __builtin_ia32_gathersiv4si (v4si, pcint,v4si,v4si,int);
27209 v8si __builtin_ia32_gathersiv8si (v8si, pcint,v8si,v8si,int);
27210 v4si __builtin_ia32_gatherdiv4si (v4si, pcint,v2di,v4si,int);
27211 v4si __builtin_ia32_gatherdiv4si256 (v4si, pcint,v4di,v4si,int);
27212 @end smallexample
27214 The following built-in functions are available when @option{-maes} is
27215 used.  All of them generate the machine instruction that is part of the
27216 name.
27218 @smallexample
27219 v2di __builtin_ia32_aesenc128 (v2di, v2di);
27220 v2di __builtin_ia32_aesenclast128 (v2di, v2di);
27221 v2di __builtin_ia32_aesdec128 (v2di, v2di);
27222 v2di __builtin_ia32_aesdeclast128 (v2di, v2di);
27223 v2di __builtin_ia32_aeskeygenassist128 (v2di, const int);
27224 v2di __builtin_ia32_aesimc128 (v2di);
27225 @end smallexample
27227 The following built-in function is available when @option{-mpclmul} is
27228 used.
27230 @defbuiltin{v2di __builtin_ia32_pclmulqdq128 (v2di, v2di, const int)}
27231 Generates the @code{pclmulqdq} machine instruction.
27232 @enddefbuiltin
27234 The following built-in function is available when @option{-mfsgsbase} is
27235 used.  All of them generate the machine instruction that is part of the
27236 name.
27238 @smallexample
27239 unsigned int __builtin_ia32_rdfsbase32 (void);
27240 unsigned long long __builtin_ia32_rdfsbase64 (void);
27241 unsigned int __builtin_ia32_rdgsbase32 (void);
27242 unsigned long long __builtin_ia32_rdgsbase64 (void);
27243 void _writefsbase_u32 (unsigned int);
27244 void _writefsbase_u64 (unsigned long long);
27245 void _writegsbase_u32 (unsigned int);
27246 void _writegsbase_u64 (unsigned long long);
27247 @end smallexample
27249 The following built-in function is available when @option{-mrdrnd} is
27250 used.  All of them generate the machine instruction that is part of the
27251 name.
27253 @smallexample
27254 unsigned int __builtin_ia32_rdrand16_step (unsigned short *);
27255 unsigned int __builtin_ia32_rdrand32_step (unsigned int *);
27256 unsigned int __builtin_ia32_rdrand64_step (unsigned long long *);
27257 @end smallexample
27259 The following built-in function is available when @option{-mptwrite} is
27260 used.  All of them generate the machine instruction that is part of the
27261 name.
27263 @smallexample
27264 void __builtin_ia32_ptwrite32 (unsigned);
27265 void __builtin_ia32_ptwrite64 (unsigned long long);
27266 @end smallexample
27268 The following built-in functions are available when @option{-msse4a} is used.
27269 All of them generate the machine instruction that is part of the name.
27271 @smallexample
27272 void __builtin_ia32_movntsd (double *, v2df);
27273 void __builtin_ia32_movntss (float *, v4sf);
27274 v2di __builtin_ia32_extrq  (v2di, v16qi);
27275 v2di __builtin_ia32_extrqi (v2di, const unsigned int, const unsigned int);
27276 v2di __builtin_ia32_insertq (v2di, v2di);
27277 v2di __builtin_ia32_insertqi (v2di, v2di, const unsigned int, const unsigned int);
27278 @end smallexample
27280 The following built-in functions are available when @option{-mxop} is used.
27281 @smallexample
27282 v2df __builtin_ia32_vfrczpd (v2df);
27283 v4sf __builtin_ia32_vfrczps (v4sf);
27284 v2df __builtin_ia32_vfrczsd (v2df);
27285 v4sf __builtin_ia32_vfrczss (v4sf);
27286 v4df __builtin_ia32_vfrczpd256 (v4df);
27287 v8sf __builtin_ia32_vfrczps256 (v8sf);
27288 v2di __builtin_ia32_vpcmov (v2di, v2di, v2di);
27289 v2di __builtin_ia32_vpcmov_v2di (v2di, v2di, v2di);
27290 v4si __builtin_ia32_vpcmov_v4si (v4si, v4si, v4si);
27291 v8hi __builtin_ia32_vpcmov_v8hi (v8hi, v8hi, v8hi);
27292 v16qi __builtin_ia32_vpcmov_v16qi (v16qi, v16qi, v16qi);
27293 v2df __builtin_ia32_vpcmov_v2df (v2df, v2df, v2df);
27294 v4sf __builtin_ia32_vpcmov_v4sf (v4sf, v4sf, v4sf);
27295 v4di __builtin_ia32_vpcmov_v4di256 (v4di, v4di, v4di);
27296 v8si __builtin_ia32_vpcmov_v8si256 (v8si, v8si, v8si);
27297 v16hi __builtin_ia32_vpcmov_v16hi256 (v16hi, v16hi, v16hi);
27298 v32qi __builtin_ia32_vpcmov_v32qi256 (v32qi, v32qi, v32qi);
27299 v4df __builtin_ia32_vpcmov_v4df256 (v4df, v4df, v4df);
27300 v8sf __builtin_ia32_vpcmov_v8sf256 (v8sf, v8sf, v8sf);
27301 v16qi __builtin_ia32_vpcomeqb (v16qi, v16qi);
27302 v8hi __builtin_ia32_vpcomeqw (v8hi, v8hi);
27303 v4si __builtin_ia32_vpcomeqd (v4si, v4si);
27304 v2di __builtin_ia32_vpcomeqq (v2di, v2di);
27305 v16qi __builtin_ia32_vpcomequb (v16qi, v16qi);
27306 v4si __builtin_ia32_vpcomequd (v4si, v4si);
27307 v2di __builtin_ia32_vpcomequq (v2di, v2di);
27308 v8hi __builtin_ia32_vpcomequw (v8hi, v8hi);
27309 v8hi __builtin_ia32_vpcomeqw (v8hi, v8hi);
27310 v16qi __builtin_ia32_vpcomfalseb (v16qi, v16qi);
27311 v4si __builtin_ia32_vpcomfalsed (v4si, v4si);
27312 v2di __builtin_ia32_vpcomfalseq (v2di, v2di);
27313 v16qi __builtin_ia32_vpcomfalseub (v16qi, v16qi);
27314 v4si __builtin_ia32_vpcomfalseud (v4si, v4si);
27315 v2di __builtin_ia32_vpcomfalseuq (v2di, v2di);
27316 v8hi __builtin_ia32_vpcomfalseuw (v8hi, v8hi);
27317 v8hi __builtin_ia32_vpcomfalsew (v8hi, v8hi);
27318 v16qi __builtin_ia32_vpcomgeb (v16qi, v16qi);
27319 v4si __builtin_ia32_vpcomged (v4si, v4si);
27320 v2di __builtin_ia32_vpcomgeq (v2di, v2di);
27321 v16qi __builtin_ia32_vpcomgeub (v16qi, v16qi);
27322 v4si __builtin_ia32_vpcomgeud (v4si, v4si);
27323 v2di __builtin_ia32_vpcomgeuq (v2di, v2di);
27324 v8hi __builtin_ia32_vpcomgeuw (v8hi, v8hi);
27325 v8hi __builtin_ia32_vpcomgew (v8hi, v8hi);
27326 v16qi __builtin_ia32_vpcomgtb (v16qi, v16qi);
27327 v4si __builtin_ia32_vpcomgtd (v4si, v4si);
27328 v2di __builtin_ia32_vpcomgtq (v2di, v2di);
27329 v16qi __builtin_ia32_vpcomgtub (v16qi, v16qi);
27330 v4si __builtin_ia32_vpcomgtud (v4si, v4si);
27331 v2di __builtin_ia32_vpcomgtuq (v2di, v2di);
27332 v8hi __builtin_ia32_vpcomgtuw (v8hi, v8hi);
27333 v8hi __builtin_ia32_vpcomgtw (v8hi, v8hi);
27334 v16qi __builtin_ia32_vpcomleb (v16qi, v16qi);
27335 v4si __builtin_ia32_vpcomled (v4si, v4si);
27336 v2di __builtin_ia32_vpcomleq (v2di, v2di);
27337 v16qi __builtin_ia32_vpcomleub (v16qi, v16qi);
27338 v4si __builtin_ia32_vpcomleud (v4si, v4si);
27339 v2di __builtin_ia32_vpcomleuq (v2di, v2di);
27340 v8hi __builtin_ia32_vpcomleuw (v8hi, v8hi);
27341 v8hi __builtin_ia32_vpcomlew (v8hi, v8hi);
27342 v16qi __builtin_ia32_vpcomltb (v16qi, v16qi);
27343 v4si __builtin_ia32_vpcomltd (v4si, v4si);
27344 v2di __builtin_ia32_vpcomltq (v2di, v2di);
27345 v16qi __builtin_ia32_vpcomltub (v16qi, v16qi);
27346 v4si __builtin_ia32_vpcomltud (v4si, v4si);
27347 v2di __builtin_ia32_vpcomltuq (v2di, v2di);
27348 v8hi __builtin_ia32_vpcomltuw (v8hi, v8hi);
27349 v8hi __builtin_ia32_vpcomltw (v8hi, v8hi);
27350 v16qi __builtin_ia32_vpcomneb (v16qi, v16qi);
27351 v4si __builtin_ia32_vpcomned (v4si, v4si);
27352 v2di __builtin_ia32_vpcomneq (v2di, v2di);
27353 v16qi __builtin_ia32_vpcomneub (v16qi, v16qi);
27354 v4si __builtin_ia32_vpcomneud (v4si, v4si);
27355 v2di __builtin_ia32_vpcomneuq (v2di, v2di);
27356 v8hi __builtin_ia32_vpcomneuw (v8hi, v8hi);
27357 v8hi __builtin_ia32_vpcomnew (v8hi, v8hi);
27358 v16qi __builtin_ia32_vpcomtrueb (v16qi, v16qi);
27359 v4si __builtin_ia32_vpcomtrued (v4si, v4si);
27360 v2di __builtin_ia32_vpcomtrueq (v2di, v2di);
27361 v16qi __builtin_ia32_vpcomtrueub (v16qi, v16qi);
27362 v4si __builtin_ia32_vpcomtrueud (v4si, v4si);
27363 v2di __builtin_ia32_vpcomtrueuq (v2di, v2di);
27364 v8hi __builtin_ia32_vpcomtrueuw (v8hi, v8hi);
27365 v8hi __builtin_ia32_vpcomtruew (v8hi, v8hi);
27366 v4si __builtin_ia32_vphaddbd (v16qi);
27367 v2di __builtin_ia32_vphaddbq (v16qi);
27368 v8hi __builtin_ia32_vphaddbw (v16qi);
27369 v2di __builtin_ia32_vphadddq (v4si);
27370 v4si __builtin_ia32_vphaddubd (v16qi);
27371 v2di __builtin_ia32_vphaddubq (v16qi);
27372 v8hi __builtin_ia32_vphaddubw (v16qi);
27373 v2di __builtin_ia32_vphaddudq (v4si);
27374 v4si __builtin_ia32_vphadduwd (v8hi);
27375 v2di __builtin_ia32_vphadduwq (v8hi);
27376 v4si __builtin_ia32_vphaddwd (v8hi);
27377 v2di __builtin_ia32_vphaddwq (v8hi);
27378 v8hi __builtin_ia32_vphsubbw (v16qi);
27379 v2di __builtin_ia32_vphsubdq (v4si);
27380 v4si __builtin_ia32_vphsubwd (v8hi);
27381 v4si __builtin_ia32_vpmacsdd (v4si, v4si, v4si);
27382 v2di __builtin_ia32_vpmacsdqh (v4si, v4si, v2di);
27383 v2di __builtin_ia32_vpmacsdql (v4si, v4si, v2di);
27384 v4si __builtin_ia32_vpmacssdd (v4si, v4si, v4si);
27385 v2di __builtin_ia32_vpmacssdqh (v4si, v4si, v2di);
27386 v2di __builtin_ia32_vpmacssdql (v4si, v4si, v2di);
27387 v4si __builtin_ia32_vpmacsswd (v8hi, v8hi, v4si);
27388 v8hi __builtin_ia32_vpmacssww (v8hi, v8hi, v8hi);
27389 v4si __builtin_ia32_vpmacswd (v8hi, v8hi, v4si);
27390 v8hi __builtin_ia32_vpmacsww (v8hi, v8hi, v8hi);
27391 v4si __builtin_ia32_vpmadcsswd (v8hi, v8hi, v4si);
27392 v4si __builtin_ia32_vpmadcswd (v8hi, v8hi, v4si);
27393 v16qi __builtin_ia32_vpperm (v16qi, v16qi, v16qi);
27394 v16qi __builtin_ia32_vprotb (v16qi, v16qi);
27395 v4si __builtin_ia32_vprotd (v4si, v4si);
27396 v2di __builtin_ia32_vprotq (v2di, v2di);
27397 v8hi __builtin_ia32_vprotw (v8hi, v8hi);
27398 v16qi __builtin_ia32_vpshab (v16qi, v16qi);
27399 v4si __builtin_ia32_vpshad (v4si, v4si);
27400 v2di __builtin_ia32_vpshaq (v2di, v2di);
27401 v8hi __builtin_ia32_vpshaw (v8hi, v8hi);
27402 v16qi __builtin_ia32_vpshlb (v16qi, v16qi);
27403 v4si __builtin_ia32_vpshld (v4si, v4si);
27404 v2di __builtin_ia32_vpshlq (v2di, v2di);
27405 v8hi __builtin_ia32_vpshlw (v8hi, v8hi);
27406 @end smallexample
27408 The following built-in functions are available when @option{-mfma4} is used.
27409 All of them generate the machine instruction that is part of the name.
27411 @smallexample
27412 v2df __builtin_ia32_vfmaddpd (v2df, v2df, v2df);
27413 v4sf __builtin_ia32_vfmaddps (v4sf, v4sf, v4sf);
27414 v2df __builtin_ia32_vfmaddsd (v2df, v2df, v2df);
27415 v4sf __builtin_ia32_vfmaddss (v4sf, v4sf, v4sf);
27416 v2df __builtin_ia32_vfmsubpd (v2df, v2df, v2df);
27417 v4sf __builtin_ia32_vfmsubps (v4sf, v4sf, v4sf);
27418 v2df __builtin_ia32_vfmsubsd (v2df, v2df, v2df);
27419 v4sf __builtin_ia32_vfmsubss (v4sf, v4sf, v4sf);
27420 v2df __builtin_ia32_vfnmaddpd (v2df, v2df, v2df);
27421 v4sf __builtin_ia32_vfnmaddps (v4sf, v4sf, v4sf);
27422 v2df __builtin_ia32_vfnmaddsd (v2df, v2df, v2df);
27423 v4sf __builtin_ia32_vfnmaddss (v4sf, v4sf, v4sf);
27424 v2df __builtin_ia32_vfnmsubpd (v2df, v2df, v2df);
27425 v4sf __builtin_ia32_vfnmsubps (v4sf, v4sf, v4sf);
27426 v2df __builtin_ia32_vfnmsubsd (v2df, v2df, v2df);
27427 v4sf __builtin_ia32_vfnmsubss (v4sf, v4sf, v4sf);
27428 v2df __builtin_ia32_vfmaddsubpd  (v2df, v2df, v2df);
27429 v4sf __builtin_ia32_vfmaddsubps  (v4sf, v4sf, v4sf);
27430 v2df __builtin_ia32_vfmsubaddpd  (v2df, v2df, v2df);
27431 v4sf __builtin_ia32_vfmsubaddps  (v4sf, v4sf, v4sf);
27432 v4df __builtin_ia32_vfmaddpd256 (v4df, v4df, v4df);
27433 v8sf __builtin_ia32_vfmaddps256 (v8sf, v8sf, v8sf);
27434 v4df __builtin_ia32_vfmsubpd256 (v4df, v4df, v4df);
27435 v8sf __builtin_ia32_vfmsubps256 (v8sf, v8sf, v8sf);
27436 v4df __builtin_ia32_vfnmaddpd256 (v4df, v4df, v4df);
27437 v8sf __builtin_ia32_vfnmaddps256 (v8sf, v8sf, v8sf);
27438 v4df __builtin_ia32_vfnmsubpd256 (v4df, v4df, v4df);
27439 v8sf __builtin_ia32_vfnmsubps256 (v8sf, v8sf, v8sf);
27440 v4df __builtin_ia32_vfmaddsubpd256 (v4df, v4df, v4df);
27441 v8sf __builtin_ia32_vfmaddsubps256 (v8sf, v8sf, v8sf);
27442 v4df __builtin_ia32_vfmsubaddpd256 (v4df, v4df, v4df);
27443 v8sf __builtin_ia32_vfmsubaddps256 (v8sf, v8sf, v8sf);
27445 @end smallexample
27447 The following built-in functions are available when @option{-mlwp} is used.
27449 @smallexample
27450 void __builtin_ia32_llwpcb16 (void *);
27451 void __builtin_ia32_llwpcb32 (void *);
27452 void __builtin_ia32_llwpcb64 (void *);
27453 void * __builtin_ia32_llwpcb16 (void);
27454 void * __builtin_ia32_llwpcb32 (void);
27455 void * __builtin_ia32_llwpcb64 (void);
27456 void __builtin_ia32_lwpval16 (unsigned short, unsigned int, unsigned short);
27457 void __builtin_ia32_lwpval32 (unsigned int, unsigned int, unsigned int);
27458 void __builtin_ia32_lwpval64 (unsigned __int64, unsigned int, unsigned int);
27459 unsigned char __builtin_ia32_lwpins16 (unsigned short, unsigned int, unsigned short);
27460 unsigned char __builtin_ia32_lwpins32 (unsigned int, unsigned int, unsigned int);
27461 unsigned char __builtin_ia32_lwpins64 (unsigned __int64, unsigned int, unsigned int);
27462 @end smallexample
27464 The following built-in functions are available when @option{-mbmi} is used.
27465 All of them generate the machine instruction that is part of the name.
27466 @smallexample
27467 unsigned int __builtin_ia32_bextr_u32(unsigned int, unsigned int);
27468 unsigned long long __builtin_ia32_bextr_u64 (unsigned long long, unsigned long long);
27469 @end smallexample
27471 The following built-in functions are available when @option{-mbmi2} is used.
27472 All of them generate the machine instruction that is part of the name.
27473 @smallexample
27474 unsigned int _bzhi_u32 (unsigned int, unsigned int);
27475 unsigned int _pdep_u32 (unsigned int, unsigned int);
27476 unsigned int _pext_u32 (unsigned int, unsigned int);
27477 unsigned long long _bzhi_u64 (unsigned long long, unsigned long long);
27478 unsigned long long _pdep_u64 (unsigned long long, unsigned long long);
27479 unsigned long long _pext_u64 (unsigned long long, unsigned long long);
27480 @end smallexample
27482 The following built-in functions are available when @option{-mlzcnt} is used.
27483 All of them generate the machine instruction that is part of the name.
27484 @smallexample
27485 unsigned short __builtin_ia32_lzcnt_u16(unsigned short);
27486 unsigned int __builtin_ia32_lzcnt_u32(unsigned int);
27487 unsigned long long __builtin_ia32_lzcnt_u64 (unsigned long long);
27488 @end smallexample
27490 The following built-in functions are available when @option{-mfxsr} is used.
27491 All of them generate the machine instruction that is part of the name.
27492 @smallexample
27493 void __builtin_ia32_fxsave (void *);
27494 void __builtin_ia32_fxrstor (void *);
27495 void __builtin_ia32_fxsave64 (void *);
27496 void __builtin_ia32_fxrstor64 (void *);
27497 @end smallexample
27499 The following built-in functions are available when @option{-mxsave} is used.
27500 All of them generate the machine instruction that is part of the name.
27501 @smallexample
27502 void __builtin_ia32_xsave (void *, long long);
27503 void __builtin_ia32_xrstor (void *, long long);
27504 void __builtin_ia32_xsave64 (void *, long long);
27505 void __builtin_ia32_xrstor64 (void *, long long);
27506 @end smallexample
27508 The following built-in functions are available when @option{-mxsaveopt} is used.
27509 All of them generate the machine instruction that is part of the name.
27510 @smallexample
27511 void __builtin_ia32_xsaveopt (void *, long long);
27512 void __builtin_ia32_xsaveopt64 (void *, long long);
27513 @end smallexample
27515 The following built-in functions are available when @option{-mtbm} is used.
27516 Both of them generate the immediate form of the bextr machine instruction.
27517 @smallexample
27518 unsigned int __builtin_ia32_bextri_u32 (unsigned int,
27519                                         const unsigned int);
27520 unsigned long long __builtin_ia32_bextri_u64 (unsigned long long,
27521                                               const unsigned long long);
27522 @end smallexample
27525 The following built-in functions are available when @option{-m3dnow} is used.
27526 All of them generate the machine instruction that is part of the name.
27528 @smallexample
27529 void __builtin_ia32_femms (void);
27530 v8qi __builtin_ia32_pavgusb (v8qi, v8qi);
27531 v2si __builtin_ia32_pf2id (v2sf);
27532 v2sf __builtin_ia32_pfacc (v2sf, v2sf);
27533 v2sf __builtin_ia32_pfadd (v2sf, v2sf);
27534 v2si __builtin_ia32_pfcmpeq (v2sf, v2sf);
27535 v2si __builtin_ia32_pfcmpge (v2sf, v2sf);
27536 v2si __builtin_ia32_pfcmpgt (v2sf, v2sf);
27537 v2sf __builtin_ia32_pfmax (v2sf, v2sf);
27538 v2sf __builtin_ia32_pfmin (v2sf, v2sf);
27539 v2sf __builtin_ia32_pfmul (v2sf, v2sf);
27540 v2sf __builtin_ia32_pfrcp (v2sf);
27541 v2sf __builtin_ia32_pfrcpit1 (v2sf, v2sf);
27542 v2sf __builtin_ia32_pfrcpit2 (v2sf, v2sf);
27543 v2sf __builtin_ia32_pfrsqrt (v2sf);
27544 v2sf __builtin_ia32_pfsub (v2sf, v2sf);
27545 v2sf __builtin_ia32_pfsubr (v2sf, v2sf);
27546 v2sf __builtin_ia32_pi2fd (v2si);
27547 v4hi __builtin_ia32_pmulhrw (v4hi, v4hi);
27548 @end smallexample
27550 The following built-in functions are available when @option{-m3dnowa} is used.
27551 All of them generate the machine instruction that is part of the name.
27553 @smallexample
27554 v2si __builtin_ia32_pf2iw (v2sf);
27555 v2sf __builtin_ia32_pfnacc (v2sf, v2sf);
27556 v2sf __builtin_ia32_pfpnacc (v2sf, v2sf);
27557 v2sf __builtin_ia32_pi2fw (v2si);
27558 v2sf __builtin_ia32_pswapdsf (v2sf);
27559 v2si __builtin_ia32_pswapdsi (v2si);
27560 @end smallexample
27562 The following built-in functions are available when @option{-mrtm} is used
27563 They are used for restricted transactional memory. These are the internal
27564 low level functions. Normally the functions in 
27565 @ref{x86 transactional memory intrinsics} should be used instead.
27567 @smallexample
27568 int __builtin_ia32_xbegin ();
27569 void __builtin_ia32_xend ();
27570 void __builtin_ia32_xabort (status);
27571 int __builtin_ia32_xtest ();
27572 @end smallexample
27574 The following built-in functions are available when @option{-mmwaitx} is used.
27575 All of them generate the machine instruction that is part of the name.
27576 @smallexample
27577 void __builtin_ia32_monitorx (void *, unsigned int, unsigned int);
27578 void __builtin_ia32_mwaitx (unsigned int, unsigned int, unsigned int);
27579 @end smallexample
27581 The following built-in functions are available when @option{-mclzero} is used.
27582 All of them generate the machine instruction that is part of the name.
27583 @smallexample
27584 void __builtin_i32_clzero (void *);
27585 @end smallexample
27587 The following built-in functions are available when @option{-mpku} is used.
27588 They generate reads and writes to PKRU.
27589 @smallexample
27590 void __builtin_ia32_wrpkru (unsigned int);
27591 unsigned int __builtin_ia32_rdpkru ();
27592 @end smallexample
27594 The following built-in functions are available when
27595 @option{-mshstk} option is used.  They support shadow stack
27596 machine instructions from Intel Control-flow Enforcement Technology (CET).
27597 Each built-in function generates the  machine instruction that is part
27598 of the function's name.  These are the internal low-level functions.
27599 Normally the functions in @ref{x86 control-flow protection intrinsics}
27600 should be used instead.
27602 @smallexample
27603 unsigned int __builtin_ia32_rdsspd (void);
27604 unsigned long long __builtin_ia32_rdsspq (void);
27605 void __builtin_ia32_incsspd (unsigned int);
27606 void __builtin_ia32_incsspq (unsigned long long);
27607 void __builtin_ia32_saveprevssp(void);
27608 void __builtin_ia32_rstorssp(void *);
27609 void __builtin_ia32_wrssd(unsigned int, void *);
27610 void __builtin_ia32_wrssq(unsigned long long, void *);
27611 void __builtin_ia32_wrussd(unsigned int, void *);
27612 void __builtin_ia32_wrussq(unsigned long long, void *);
27613 void __builtin_ia32_setssbsy(void);
27614 void __builtin_ia32_clrssbsy(void *);
27615 @end smallexample
27617 @node x86 transactional memory intrinsics
27618 @subsection x86 Transactional Memory Intrinsics
27620 These hardware transactional memory intrinsics for x86 allow you to use
27621 memory transactions with RTM (Restricted Transactional Memory).
27622 This support is enabled with the @option{-mrtm} option.
27623 For using HLE (Hardware Lock Elision) see 
27624 @ref{x86 specific memory model extensions for transactional memory} instead.
27626 A memory transaction commits all changes to memory in an atomic way,
27627 as visible to other threads. If the transaction fails it is rolled back
27628 and all side effects discarded.
27630 Generally there is no guarantee that a memory transaction ever succeeds
27631 and suitable fallback code always needs to be supplied.
27633 @deftypefn {RTM Function} {unsigned} _xbegin ()
27634 Start a RTM (Restricted Transactional Memory) transaction. 
27635 Returns @code{_XBEGIN_STARTED} when the transaction
27636 started successfully (note this is not 0, so the constant has to be 
27637 explicitly tested).  
27639 If the transaction aborts, all side effects
27640 are undone and an abort code encoded as a bit mask is returned.
27641 The following macros are defined:
27643 @defmac{_XABORT_EXPLICIT}
27644 Transaction was explicitly aborted with @code{_xabort}.  The parameter passed
27645 to @code{_xabort} is available with @code{_XABORT_CODE(status)}.
27646 @end defmac
27648 @defmac{_XABORT_RETRY}
27649 Transaction retry is possible.
27650 @end defmac
27652 @defmac{_XABORT_CONFLICT}
27653 Transaction abort due to a memory conflict with another thread.
27654 @end defmac
27656 @defmac{_XABORT_CAPACITY}
27657 Transaction abort due to the transaction using too much memory.
27658 @end defmac
27660 @defmac{_XABORT_DEBUG}
27661 Transaction abort due to a debug trap.
27662 @end defmac
27664 @defmac{_XABORT_NESTED}
27665 Transaction abort in an inner nested transaction.
27666 @end defmac
27668 There is no guarantee
27669 any transaction ever succeeds, so there always needs to be a valid
27670 fallback path.
27671 @end deftypefn
27673 @deftypefn {RTM Function} {void} _xend ()
27674 Commit the current transaction. When no transaction is active this faults.
27675 All memory side effects of the transaction become visible
27676 to other threads in an atomic manner.
27677 @end deftypefn
27679 @deftypefn {RTM Function} {int} _xtest ()
27680 Return a nonzero value if a transaction is currently active, otherwise 0.
27681 @end deftypefn
27683 @deftypefn {RTM Function} {void} _xabort (status)
27684 Abort the current transaction. When no transaction is active this is a no-op.
27685 The @var{status} is an 8-bit constant; its value is encoded in the return 
27686 value from @code{_xbegin}.
27687 @end deftypefn
27689 Here is an example showing handling for @code{_XABORT_RETRY}
27690 and a fallback path for other failures:
27692 @smallexample
27693 #include <immintrin.h>
27695 int n_tries, max_tries;
27696 unsigned status = _XABORT_EXPLICIT;
27699 for (n_tries = 0; n_tries < max_tries; n_tries++) 
27700   @{
27701     status = _xbegin ();
27702     if (status == _XBEGIN_STARTED || !(status & _XABORT_RETRY))
27703       break;
27704   @}
27705 if (status == _XBEGIN_STARTED) 
27706   @{
27707     ... transaction code...
27708     _xend ();
27709   @} 
27710 else 
27711   @{
27712     ... non-transactional fallback path...
27713   @}
27714 @end smallexample
27716 @noindent
27717 Note that, in most cases, the transactional and non-transactional code
27718 must synchronize together to ensure consistency.
27720 @node x86 control-flow protection intrinsics
27721 @subsection x86 Control-Flow Protection Intrinsics
27723 @deftypefn {CET Function} {ret_type} _get_ssp (void)
27724 Get the current value of shadow stack pointer if shadow stack support
27725 from Intel CET is enabled in the hardware or @code{0} otherwise.
27726 The @code{ret_type} is @code{unsigned long long} for 64-bit targets 
27727 and @code{unsigned int} for 32-bit targets.
27728 @end deftypefn
27730 @deftypefn {CET Function} void _inc_ssp (unsigned int)
27731 Increment the current shadow stack pointer by the size specified by the
27732 function argument.  The argument is masked to a byte value for security
27733 reasons, so to increment by more than 255 bytes you must call the function
27734 multiple times.
27735 @end deftypefn
27737 The shadow stack unwind code looks like:
27739 @smallexample
27740 #include <immintrin.h>
27742 /* Unwind the shadow stack for EH.  */
27743 #define _Unwind_Frames_Extra(x)       \
27744   do                                  \
27745     @{                                \
27746       _Unwind_Word ssp = _get_ssp (); \
27747       if (ssp != 0)                   \
27748         @{                            \
27749           _Unwind_Word tmp = (x);     \
27750           while (tmp > 255)           \
27751             @{                        \
27752               _inc_ssp (tmp);         \
27753               tmp -= 255;             \
27754             @}                        \
27755           _inc_ssp (tmp);             \
27756         @}                            \
27757     @}                                \
27758     while (0)
27759 @end smallexample
27761 @noindent
27762 This code runs unconditionally on all 64-bit processors.  For 32-bit
27763 processors the code runs on those that support multi-byte NOP instructions.
27765 @node Target Format Checks
27766 @section Format Checks Specific to Particular Target Machines
27768 For some target machines, GCC supports additional options to the
27769 format attribute
27770 (@pxref{Function Attributes,,Declaring Attributes of Functions}).
27772 @menu
27773 * Solaris Format Checks::
27774 * Darwin Format Checks::
27775 @end menu
27777 @node Solaris Format Checks
27778 @subsection Solaris Format Checks
27780 Solaris targets support the @code{cmn_err} (or @code{__cmn_err__}) format
27781 check.  @code{cmn_err} accepts a subset of the standard @code{printf}
27782 conversions, and the two-argument @code{%b} conversion for displaying
27783 bit-fields.  See the Solaris man page for @code{cmn_err} for more information.
27785 @node Darwin Format Checks
27786 @subsection Darwin Format Checks
27788 In addition to the full set of format archetypes (attribute format style
27789 arguments such as @code{printf}, @code{scanf}, @code{strftime}, and
27790 @code{strfmon}), Darwin targets also support the @code{CFString} (or
27791 @code{__CFString__}) archetype in the @code{format} attribute.
27792 Declarations with this archetype are parsed for correct syntax
27793 and argument types.  However, parsing of the format string itself and
27794 validating arguments against it in calls to such functions is currently
27795 not performed.
27797 Additionally, @code{CFStringRefs} (defined by the @code{CoreFoundation} headers) may
27798 also be used as format arguments.  Note that the relevant headers are only likely to be
27799 available on Darwin (OSX) installations.  On such installations, the XCode and system
27800 documentation provide descriptions of @code{CFString}, @code{CFStringRefs} and
27801 associated functions.
27803 @node Pragmas
27804 @section Pragmas Accepted by GCC
27805 @cindex pragmas
27806 @cindex @code{#pragma}
27808 GCC supports several types of pragmas, primarily in order to compile
27809 code originally written for other compilers.  Note that in general
27810 we do not recommend the use of pragmas; @xref{Function Attributes},
27811 for further explanation.
27813 The GNU C preprocessor recognizes several pragmas in addition to the
27814 compiler pragmas documented here.  Refer to the CPP manual for more
27815 information.
27817 @menu
27818 * AArch64 Pragmas::
27819 * ARM Pragmas::
27820 * M32C Pragmas::
27821 * PRU Pragmas::
27822 * RS/6000 and PowerPC Pragmas::
27823 * S/390 Pragmas::
27824 * Darwin Pragmas::
27825 * Solaris Pragmas::
27826 * Symbol-Renaming Pragmas::
27827 * Structure-Layout Pragmas::
27828 * Weak Pragmas::
27829 * Diagnostic Pragmas::
27830 * Visibility Pragmas::
27831 * Push/Pop Macro Pragmas::
27832 * Function Specific Option Pragmas::
27833 * Loop-Specific Pragmas::
27834 @end menu
27836 @node AArch64 Pragmas
27837 @subsection AArch64 Pragmas
27839 The pragmas defined by the AArch64 target correspond to the AArch64
27840 target function attributes.  They can be specified as below:
27841 @smallexample
27842 #pragma GCC target("string")
27843 @end smallexample
27845 where @code{@var{string}} can be any string accepted as an AArch64 target
27846 attribute.  @xref{AArch64 Function Attributes}, for more details
27847 on the permissible values of @code{string}.
27849 @node ARM Pragmas
27850 @subsection ARM Pragmas
27852 The ARM target defines pragmas for controlling the default addition of
27853 @code{long_call} and @code{short_call} attributes to functions.
27854 @xref{Function Attributes}, for information about the effects of these
27855 attributes.
27857 @table @code
27858 @cindex pragma, long_calls
27859 @item long_calls
27860 Set all subsequent functions to have the @code{long_call} attribute.
27862 @cindex pragma, no_long_calls
27863 @item no_long_calls
27864 Set all subsequent functions to have the @code{short_call} attribute.
27866 @cindex pragma, long_calls_off
27867 @item long_calls_off
27868 Do not affect the @code{long_call} or @code{short_call} attributes of
27869 subsequent functions.
27870 @end table
27872 @node M32C Pragmas
27873 @subsection M32C Pragmas
27875 @table @code
27876 @cindex pragma, memregs
27877 @item GCC memregs @var{number}
27878 Overrides the command-line option @code{-memregs=} for the current
27879 file.  Use with care!  This pragma must be before any function in the
27880 file, and mixing different memregs values in different objects may
27881 make them incompatible.  This pragma is useful when a
27882 performance-critical function uses a memreg for temporary values,
27883 as it may allow you to reduce the number of memregs used.
27885 @cindex pragma, address
27886 @item ADDRESS @var{name} @var{address}
27887 For any declared symbols matching @var{name}, this does three things
27888 to that symbol: it forces the symbol to be located at the given
27889 address (a number), it forces the symbol to be volatile, and it
27890 changes the symbol's scope to be static.  This pragma exists for
27891 compatibility with other compilers, but note that the common
27892 @code{1234H} numeric syntax is not supported (use @code{0x1234}
27893 instead).  Example:
27895 @smallexample
27896 #pragma ADDRESS port3 0x103
27897 char port3;
27898 @end smallexample
27900 @end table
27902 @node PRU Pragmas
27903 @subsection PRU Pragmas
27905 @table @code
27907 @cindex pragma, ctable_entry
27908 @item ctable_entry @var{index} @var{constant_address}
27909 Specifies that the PRU CTABLE entry given by @var{index} has the value
27910 @var{constant_address}.  This enables GCC to emit LBCO/SBCO instructions
27911 when the load/store address is known and can be addressed with some CTABLE
27912 entry.  For example:
27914 @smallexample
27915 /* will compile to "sbco Rx, 2, 0x10, 4" */
27916 #pragma ctable_entry 2 0x4802a000
27917 *(unsigned int *)0x4802a010 = val;
27918 @end smallexample
27920 @end table
27922 @node RS/6000 and PowerPC Pragmas
27923 @subsection RS/6000 and PowerPC Pragmas
27925 The RS/6000 and PowerPC targets define one pragma for controlling
27926 whether or not the @code{longcall} attribute is added to function
27927 declarations by default.  This pragma overrides the @option{-mlongcall}
27928 option, but not the @code{longcall} and @code{shortcall} attributes.
27929 @xref{RS/6000 and PowerPC Options}, for more information about when long
27930 calls are and are not necessary.
27932 @table @code
27933 @cindex pragma, longcall
27934 @item longcall (1)
27935 Apply the @code{longcall} attribute to all subsequent function
27936 declarations.
27938 @item longcall (0)
27939 Do not apply the @code{longcall} attribute to subsequent function
27940 declarations.
27941 @end table
27943 @c Describe h8300 pragmas here.
27944 @c Describe sh pragmas here.
27945 @c Describe v850 pragmas here.
27947 @node S/390 Pragmas
27948 @subsection S/390 Pragmas
27950 The pragmas defined by the S/390 target correspond to the S/390
27951 target function attributes and some the additional options:
27953 @table @samp
27954 @item zvector
27955 @itemx no-zvector
27956 @end table
27958 Note that options of the pragma, unlike options of the target
27959 attribute, do change the value of preprocessor macros like
27960 @code{__VEC__}.  They can be specified as below:
27962 @smallexample
27963 #pragma GCC target("string[,string]...")
27964 #pragma GCC target("string"[,"string"]...)
27965 @end smallexample
27967 @node Darwin Pragmas
27968 @subsection Darwin Pragmas
27970 The following pragmas are available for all architectures running the
27971 Darwin operating system.  These are useful for compatibility with other
27972 macOS compilers.
27974 @table @code
27975 @cindex pragma, mark
27976 @item mark @var{tokens}@dots{}
27977 This pragma is accepted, but has no effect.
27979 @cindex pragma, options align
27980 @item options align=@var{alignment}
27981 This pragma sets the alignment of fields in structures.  The values of
27982 @var{alignment} may be @code{mac68k}, to emulate m68k alignment, or
27983 @code{power}, to emulate PowerPC alignment.  Uses of this pragma nest
27984 properly; to restore the previous setting, use @code{reset} for the
27985 @var{alignment}.
27987 @cindex pragma, segment
27988 @item segment @var{tokens}@dots{}
27989 This pragma is accepted, but has no effect.
27991 @cindex pragma, unused
27992 @item unused (@var{var} [, @var{var}]@dots{})
27993 This pragma declares variables to be possibly unused.  GCC does not
27994 produce warnings for the listed variables.  The effect is similar to
27995 that of the @code{unused} attribute, except that this pragma may appear
27996 anywhere within the variables' scopes.
27997 @end table
27999 @node Solaris Pragmas
28000 @subsection Solaris Pragmas
28002 The Solaris target supports @code{#pragma redefine_extname}
28003 (@pxref{Symbol-Renaming Pragmas}).  It also supports additional
28004 @code{#pragma} directives for compatibility with the system compiler.
28006 @table @code
28007 @cindex pragma, align
28008 @item align @var{alignment} (@var{variable} [, @var{variable}]...)
28010 Increase the minimum alignment of each @var{variable} to @var{alignment}.
28011 This is the same as GCC's @code{aligned} attribute @pxref{Variable
28012 Attributes}).  Macro expansion occurs on the arguments to this pragma
28013 when compiling C and Objective-C@.  It does not currently occur when
28014 compiling C++, but this is a bug which may be fixed in a future
28015 release.
28017 @cindex pragma, fini
28018 @item fini (@var{function} [, @var{function}]...)
28020 This pragma causes each listed @var{function} to be called after
28021 main, or during shared module unloading, by adding a call to the
28022 @code{.fini} section.
28024 @cindex pragma, init
28025 @item init (@var{function} [, @var{function}]...)
28027 This pragma causes each listed @var{function} to be called during
28028 initialization (before @code{main}) or during shared module loading, by
28029 adding a call to the @code{.init} section.
28031 @end table
28033 @node Symbol-Renaming Pragmas
28034 @subsection Symbol-Renaming Pragmas
28036 GCC supports a @code{#pragma} directive that changes the name used in
28037 assembly for a given declaration. While this pragma is supported on all
28038 platforms, it is intended primarily to provide compatibility with the
28039 Solaris system headers. This effect can also be achieved using the asm
28040 labels extension (@pxref{Asm Labels}).
28042 @table @code
28043 @cindex pragma, redefine_extname
28044 @item redefine_extname @var{oldname} @var{newname}
28046 This pragma gives the C function @var{oldname} the assembly symbol
28047 @var{newname}.  The preprocessor macro @code{__PRAGMA_REDEFINE_EXTNAME}
28048 is defined if this pragma is available (currently on all platforms).
28049 @end table
28051 This pragma and the @code{asm} labels extension interact in a complicated
28052 manner.  Here are some corner cases you may want to be aware of:
28054 @enumerate
28055 @item This pragma silently applies only to declarations with external
28056 linkage.  The @code{asm} label feature does not have this restriction.
28058 @item In C++, this pragma silently applies only to declarations with
28059 ``C'' linkage.  Again, @code{asm} labels do not have this restriction.
28061 @item If either of the ways of changing the assembly name of a
28062 declaration are applied to a declaration whose assembly name has
28063 already been determined (either by a previous use of one of these
28064 features, or because the compiler needed the assembly name in order to
28065 generate code), and the new name is different, a warning issues and
28066 the name does not change.
28068 @item The @var{oldname} used by @code{#pragma redefine_extname} is
28069 always the C-language name.
28070 @end enumerate
28072 @node Structure-Layout Pragmas
28073 @subsection Structure-Layout Pragmas
28075 For compatibility with Microsoft Windows compilers, GCC supports a
28076 set of @code{#pragma} directives that change the maximum alignment of
28077 members of structures (other than zero-width bit-fields), unions, and
28078 classes subsequently defined. The @var{n} value below always is required
28079 to be a small power of two and specifies the new alignment in bytes.
28081 @enumerate
28082 @item @code{#pragma pack(@var{n})} simply sets the new alignment.
28083 @item @code{#pragma pack()} sets the alignment to the one that was in
28084 effect when compilation started (see also command-line option
28085 @option{-fpack-struct[=@var{n}]} @pxref{Code Gen Options}).
28086 @item @code{#pragma pack(push[,@var{n}])} pushes the current alignment
28087 setting on an internal stack and then optionally sets the new alignment.
28088 @item @code{#pragma pack(pop)} restores the alignment setting to the one
28089 saved at the top of the internal stack (and removes that stack entry).
28090 Note that @code{#pragma pack([@var{n}])} does not influence this internal
28091 stack; thus it is possible to have @code{#pragma pack(push)} followed by
28092 multiple @code{#pragma pack(@var{n})} instances and finalized by a single
28093 @code{#pragma pack(pop)}.
28094 @end enumerate
28096 Some targets, e.g.@: x86 and PowerPC, support the @code{#pragma ms_struct}
28097 directive which lays out structures and unions subsequently defined as the
28098 documented @code{__attribute__ ((ms_struct))}.
28100 @enumerate
28101 @item @code{#pragma ms_struct on} turns on the Microsoft layout.
28102 @item @code{#pragma ms_struct off} turns off the Microsoft layout.
28103 @item @code{#pragma ms_struct reset} goes back to the default layout.
28104 @end enumerate
28106 Most targets also support the @code{#pragma scalar_storage_order} directive
28107 which lays out structures and unions subsequently defined as the documented
28108 @code{__attribute__ ((scalar_storage_order))}.
28110 @enumerate
28111 @item @code{#pragma scalar_storage_order big-endian} sets the storage order
28112 of the scalar fields to big-endian.
28113 @item @code{#pragma scalar_storage_order little-endian} sets the storage order
28114 of the scalar fields to little-endian.
28115 @item @code{#pragma scalar_storage_order default} goes back to the endianness
28116 that was in effect when compilation started (see also command-line option
28117 @option{-fsso-struct=@var{endianness}} @pxref{C Dialect Options}).
28118 @end enumerate
28120 @node Weak Pragmas
28121 @subsection Weak Pragmas
28123 For compatibility with SVR4, GCC supports a set of @code{#pragma}
28124 directives for declaring symbols to be weak, and defining weak
28125 aliases.
28127 @table @code
28128 @cindex pragma, weak
28129 @item #pragma weak @var{symbol}
28130 This pragma declares @var{symbol} to be weak, as if the declaration
28131 had the attribute of the same name.  The pragma may appear before
28132 or after the declaration of @var{symbol}.  It is not an error for
28133 @var{symbol} to never be defined at all.
28135 @item #pragma weak @var{symbol1} = @var{symbol2}
28136 This pragma declares @var{symbol1} to be a weak alias of @var{symbol2}.
28137 It is an error if @var{symbol2} is not defined in the current
28138 translation unit.
28139 @end table
28141 @node Diagnostic Pragmas
28142 @subsection Diagnostic Pragmas
28144 GCC allows the user to selectively enable or disable certain types of
28145 diagnostics, and change the kind of the diagnostic.  For example, a
28146 project's policy might require that all sources compile with
28147 @option{-Werror} but certain files might have exceptions allowing
28148 specific types of warnings.  Or, a project might selectively enable
28149 diagnostics and treat them as errors depending on which preprocessor
28150 macros are defined.
28152 @table @code
28153 @cindex pragma, diagnostic
28154 @item #pragma GCC diagnostic @var{kind} @var{option}
28156 Modifies the disposition of a diagnostic.  Note that not all
28157 diagnostics are modifiable; at the moment only warnings (normally
28158 controlled by @samp{-W@dots{}}) can be controlled, and not all of them.
28159 Use @option{-fdiagnostics-show-option} to determine which diagnostics
28160 are controllable and which option controls them.
28162 @var{kind} is @samp{error} to treat this diagnostic as an error,
28163 @samp{warning} to treat it like a warning (even if @option{-Werror} is
28164 in effect), or @samp{ignored} if the diagnostic is to be ignored.
28165 @var{option} is a double quoted string that matches the command-line
28166 option.
28168 @smallexample
28169 #pragma GCC diagnostic warning "-Wformat"
28170 #pragma GCC diagnostic error "-Wformat"
28171 #pragma GCC diagnostic ignored "-Wformat"
28172 @end smallexample
28174 Note that these pragmas override any command-line options.  GCC keeps
28175 track of the location of each pragma, and issues diagnostics according
28176 to the state as of that point in the source file.  Thus, pragmas occurring
28177 after a line do not affect diagnostics caused by that line.
28179 @item #pragma GCC diagnostic push
28180 @itemx #pragma GCC diagnostic pop
28182 Causes GCC to remember the state of the diagnostics as of each
28183 @code{push}, and restore to that point at each @code{pop}.  If a
28184 @code{pop} has no matching @code{push}, the command-line options are
28185 restored.
28187 @smallexample
28188 #pragma GCC diagnostic error "-Wuninitialized"
28189   foo(a);                       /* error is given for this one */
28190 #pragma GCC diagnostic push
28191 #pragma GCC diagnostic ignored "-Wuninitialized"
28192   foo(b);                       /* no diagnostic for this one */
28193 #pragma GCC diagnostic pop
28194   foo(c);                       /* error is given for this one */
28195 #pragma GCC diagnostic pop
28196   foo(d);                       /* depends on command-line options */
28197 @end smallexample
28199 @item #pragma GCC diagnostic ignored_attributes
28201 Similarly to @option{-Wno-attributes=}, this pragma allows users to suppress
28202 warnings about unknown scoped attributes (in C++11 and C23).  For example,
28203 @code{#pragma GCC diagnostic ignored_attributes "vendor::attr"} disables
28204 warning about the following declaration:
28206 @smallexample
28207 [[vendor::attr]] void f();
28208 @end smallexample
28210 whereas @code{#pragma GCC diagnostic ignored_attributes "vendor::"} prevents
28211 warning about both of these declarations:
28213 @smallexample
28214 [[vendor::safe]] void f();
28215 [[vendor::unsafe]] void f2();
28216 @end smallexample
28218 @end table
28220 GCC also offers a simple mechanism for printing messages during
28221 compilation.
28223 @table @code
28224 @cindex pragma, diagnostic
28225 @item #pragma message @var{string}
28227 Prints @var{string} as a compiler message on compilation.  The message
28228 is informational only, and is neither a compilation warning nor an
28229 error.  Newlines can be included in the string by using the @samp{\n}
28230 escape sequence.
28232 @smallexample
28233 #pragma message "Compiling " __FILE__ "..."
28234 @end smallexample
28236 @var{string} may be parenthesized, and is printed with location
28237 information.  For example,
28239 @smallexample
28240 #define DO_PRAGMA(x) _Pragma (#x)
28241 #define TODO(x) DO_PRAGMA(message ("TODO - " #x))
28243 TODO(Remember to fix this)
28244 @end smallexample
28246 @noindent
28247 prints @samp{/tmp/file.c:4: note: #pragma message:
28248 TODO - Remember to fix this}.
28250 @cindex pragma, diagnostic
28251 @item #pragma GCC error @var{message}
28252 Generates an error message.  This pragma @emph{is} considered to
28253 indicate an error in the compilation, and it will be treated as such.
28255 Newlines can be included in the string by using the @samp{\n}
28256 escape sequence.  They will be displayed as newlines even if the
28257 @option{-fmessage-length} option is set to zero.
28259 The error is only generated if the pragma is present in the code after
28260 pre-processing has been completed.  It does not matter however if the
28261 code containing the pragma is unreachable:
28263 @smallexample
28264 #if 0
28265 #pragma GCC error "this error is not seen"
28266 #endif
28267 void foo (void)
28269   return;
28270 #pragma GCC error "this error is seen"
28272 @end smallexample
28274 @cindex pragma, diagnostic
28275 @item #pragma GCC warning @var{message}
28276 This is just like @samp{pragma GCC error} except that a warning
28277 message is issued instead of an error message.  Unless
28278 @option{-Werror} is in effect, in which case this pragma will generate
28279 an error as well.
28281 @end table
28283 @node Visibility Pragmas
28284 @subsection Visibility Pragmas
28286 @table @code
28287 @cindex pragma, visibility
28288 @item #pragma GCC visibility push(@var{visibility})
28289 @itemx #pragma GCC visibility pop
28291 This pragma allows the user to set the visibility for multiple
28292 declarations without having to give each a visibility attribute
28293 (@pxref{Function Attributes}).
28295 In C++, @samp{#pragma GCC visibility} affects only namespace-scope
28296 declarations.  Class members and template specializations are not
28297 affected; if you want to override the visibility for a particular
28298 member or instantiation, you must use an attribute.
28300 @end table
28303 @node Push/Pop Macro Pragmas
28304 @subsection Push/Pop Macro Pragmas
28306 For compatibility with Microsoft Windows compilers, GCC supports
28307 @samp{#pragma push_macro(@var{"macro_name"})}
28308 and @samp{#pragma pop_macro(@var{"macro_name"})}.
28310 @table @code
28311 @cindex pragma, push_macro
28312 @item #pragma push_macro(@var{"macro_name"})
28313 This pragma saves the value of the macro named as @var{macro_name} to
28314 the top of the stack for this macro.
28316 @cindex pragma, pop_macro
28317 @item #pragma pop_macro(@var{"macro_name"})
28318 This pragma sets the value of the macro named as @var{macro_name} to
28319 the value on top of the stack for this macro. If the stack for
28320 @var{macro_name} is empty, the value of the macro remains unchanged.
28321 @end table
28323 For example:
28325 @smallexample
28326 #define X  1
28327 #pragma push_macro("X")
28328 #undef X
28329 #define X -1
28330 #pragma pop_macro("X")
28331 int x [X];
28332 @end smallexample
28334 @noindent
28335 In this example, the definition of X as 1 is saved by @code{#pragma
28336 push_macro} and restored by @code{#pragma pop_macro}.
28338 @node Function Specific Option Pragmas
28339 @subsection Function Specific Option Pragmas
28341 @table @code
28342 @cindex pragma GCC target
28343 @item #pragma GCC target (@var{string}, @dots{})
28345 This pragma allows you to set target-specific options for functions
28346 defined later in the source file.  One or more strings can be
28347 specified.  Each function that is defined after this point is treated
28348 as if it had been declared with one @code{target(}@var{string}@code{)}
28349 attribute for each @var{string} argument.  The parentheses around
28350 the strings in the pragma are optional.  @xref{Function Attributes},
28351 for more information about the @code{target} attribute and the attribute
28352 syntax.
28354 The @code{#pragma GCC target} pragma is presently implemented for
28355 x86, ARM, AArch64, PowerPC, S/390, and Nios II targets only.
28357 @cindex pragma GCC optimize
28358 @item #pragma GCC optimize (@var{string}, @dots{})
28360 This pragma allows you to set global optimization options for functions
28361 defined later in the source file.  One or more strings can be
28362 specified.  Each function that is defined after this point is treated
28363 as if it had been declared with one @code{optimize(}@var{string}@code{)}
28364 attribute for each @var{string} argument.  The parentheses around
28365 the strings in the pragma are optional.  @xref{Function Attributes},
28366 for more information about the @code{optimize} attribute and the attribute
28367 syntax.
28369 @cindex pragma GCC push_options
28370 @cindex pragma GCC pop_options
28371 @item #pragma GCC push_options
28372 @itemx #pragma GCC pop_options
28374 These pragmas maintain a stack of the current target and optimization
28375 options.  It is intended for include files where you temporarily want
28376 to switch to using a different @samp{#pragma GCC target} or
28377 @samp{#pragma GCC optimize} and then to pop back to the previous
28378 options.
28380 @cindex pragma GCC reset_options
28381 @item #pragma GCC reset_options
28383 This pragma clears the current @code{#pragma GCC target} and
28384 @code{#pragma GCC optimize} to use the default switches as specified
28385 on the command line.
28387 @end table
28389 @node Loop-Specific Pragmas
28390 @subsection Loop-Specific Pragmas
28392 @table @code
28393 @cindex pragma GCC ivdep
28394 @item #pragma GCC ivdep
28396 With this pragma, the programmer asserts that there are no loop-carried
28397 dependencies which would prevent consecutive iterations of
28398 the following loop from executing concurrently with SIMD
28399 (single instruction multiple data) instructions.
28401 For example, the compiler can only unconditionally vectorize the following
28402 loop with the pragma:
28404 @smallexample
28405 void foo (int n, int *a, int *b, int *c)
28407   int i, j;
28408 #pragma GCC ivdep
28409   for (i = 0; i < n; ++i)
28410     a[i] = b[i] + c[i];
28412 @end smallexample
28414 @noindent
28415 In this example, using the @code{restrict} qualifier had the same
28416 effect. In the following example, that would not be possible. Assume
28417 @math{k < -m} or @math{k >= m}. Only with the pragma, the compiler knows
28418 that it can unconditionally vectorize the following loop:
28420 @smallexample
28421 void ignore_vec_dep (int *a, int k, int c, int m)
28423 #pragma GCC ivdep
28424   for (int i = 0; i < m; i++)
28425     a[i] = a[i + k] * c;
28427 @end smallexample
28429 @cindex pragma GCC novector
28430 @item #pragma GCC novector
28432 With this pragma, the programmer asserts that the following loop should be
28433 prevented from executing concurrently with SIMD (single instruction multiple
28434 data) instructions.
28436 For example, the compiler cannot vectorize the following loop with the pragma:
28438 @smallexample
28439 void foo (int n, int *a, int *b, int *c)
28441   int i, j;
28442 #pragma GCC novector
28443   for (i = 0; i < n; ++i)
28444     a[i] = b[i] + c[i];
28446 @end smallexample
28448 @cindex pragma GCC unroll @var{n}
28449 @item #pragma GCC unroll @var{n}
28451 You can use this pragma to control how many times a loop should be unrolled.
28452 It must be placed immediately before a @code{for}, @code{while} or @code{do}
28453 loop or a @code{#pragma GCC ivdep}, and applies only to the loop that follows.
28454 @var{n} is an integer constant expression specifying the unrolling factor.
28455 The values of @math{0} and @math{1} block any unrolling of the loop.
28457 @end table
28459 @node Unnamed Fields
28460 @section Unnamed Structure and Union Fields
28461 @cindex @code{struct}
28462 @cindex @code{union}
28464 As permitted by ISO C11 and for compatibility with other compilers,
28465 GCC allows you to define
28466 a structure or union that contains, as fields, structures and unions
28467 without names.  For example:
28469 @smallexample
28470 struct @{
28471   int a;
28472   union @{
28473     int b;
28474     float c;
28475   @};
28476   int d;
28477 @} foo;
28478 @end smallexample
28480 @noindent
28481 In this example, you are able to access members of the unnamed
28482 union with code like @samp{foo.b}.  Note that only unnamed structs and
28483 unions are allowed, you may not have, for example, an unnamed
28484 @code{int}.
28486 You must never create such structures that cause ambiguous field definitions.
28487 For example, in this structure:
28489 @smallexample
28490 struct @{
28491   int a;
28492   struct @{
28493     int a;
28494   @};
28495 @} foo;
28496 @end smallexample
28498 @noindent
28499 it is ambiguous which @code{a} is being referred to with @samp{foo.a}.
28500 The compiler gives errors for such constructs.
28502 @opindex fms-extensions
28503 Unless @option{-fms-extensions} is used, the unnamed field must be a
28504 structure or union definition without a tag (for example, @samp{struct
28505 @{ int a; @};}).  If @option{-fms-extensions} is used, the field may
28506 also be a definition with a tag such as @samp{struct foo @{ int a;
28507 @};}, a reference to a previously defined structure or union such as
28508 @samp{struct foo;}, or a reference to a @code{typedef} name for a
28509 previously defined structure or union type.
28511 @opindex fplan9-extensions
28512 The option @option{-fplan9-extensions} enables
28513 @option{-fms-extensions} as well as two other extensions.  First, a
28514 pointer to a structure is automatically converted to a pointer to an
28515 anonymous field for assignments and function calls.  For example:
28517 @smallexample
28518 struct s1 @{ int a; @};
28519 struct s2 @{ struct s1; @};
28520 extern void f1 (struct s1 *);
28521 void f2 (struct s2 *p) @{ f1 (p); @}
28522 @end smallexample
28524 @noindent
28525 In the call to @code{f1} inside @code{f2}, the pointer @code{p} is
28526 converted into a pointer to the anonymous field.
28528 Second, when the type of an anonymous field is a @code{typedef} for a
28529 @code{struct} or @code{union}, code may refer to the field using the
28530 name of the @code{typedef}.
28532 @smallexample
28533 typedef struct @{ int a; @} s1;
28534 struct s2 @{ s1; @};
28535 s1 f1 (struct s2 *p) @{ return p->s1; @}
28536 @end smallexample
28538 These usages are only permitted when they are not ambiguous.
28540 @node Thread-Local
28541 @section Thread-Local Storage
28542 @cindex Thread-Local Storage
28543 @cindex @acronym{TLS}
28544 @cindex @code{__thread}
28546 Thread-local storage (@acronym{TLS}) is a mechanism by which variables
28547 are allocated such that there is one instance of the variable per extant
28548 thread.  The runtime model GCC uses to implement this originates
28549 in the IA-64 processor-specific ABI, but has since been migrated
28550 to other processors as well.  It requires significant support from
28551 the linker (@command{ld}), dynamic linker (@command{ld.so}), and
28552 system libraries (@file{libc.so} and @file{libpthread.so}), so it
28553 is not available everywhere.
28555 At the user level, the extension is visible with a new storage
28556 class keyword: @code{__thread}.  For example:
28558 @smallexample
28559 __thread int i;
28560 extern __thread struct state s;
28561 static __thread char *p;
28562 @end smallexample
28564 The @code{__thread} specifier may be used alone, with the @code{extern}
28565 or @code{static} specifiers, but with no other storage class specifier.
28566 When used with @code{extern} or @code{static}, @code{__thread} must appear
28567 immediately after the other storage class specifier.
28569 The @code{__thread} specifier may be applied to any global, file-scoped
28570 static, function-scoped static, or static data member of a class.  It may
28571 not be applied to block-scoped automatic or non-static data member.
28573 When the address-of operator is applied to a thread-local variable, it is
28574 evaluated at run time and returns the address of the current thread's
28575 instance of that variable.  An address so obtained may be used by any
28576 thread.  When a thread terminates, any pointers to thread-local variables
28577 in that thread become invalid.
28579 No static initialization may refer to the address of a thread-local variable.
28581 In C++, if an initializer is present for a thread-local variable, it must
28582 be a @var{constant-expression}, as defined in 5.19.2 of the ANSI/ISO C++
28583 standard.
28585 See @uref{https://www.akkadia.org/drepper/tls.pdf,
28586 ELF Handling For Thread-Local Storage} for a detailed explanation of
28587 the four thread-local storage addressing models, and how the runtime
28588 is expected to function.
28590 @menu
28591 * C99 Thread-Local Edits::
28592 * C++98 Thread-Local Edits::
28593 @end menu
28595 @node C99 Thread-Local Edits
28596 @subsection ISO/IEC 9899:1999 Edits for Thread-Local Storage
28598 The following are a set of changes to ISO/IEC 9899:1999 (aka C99)
28599 that document the exact semantics of the language extension.
28601 @itemize @bullet
28602 @item
28603 @cite{5.1.2  Execution environments}
28605 Add new text after paragraph 1
28607 @quotation
28608 Within either execution environment, a @dfn{thread} is a flow of
28609 control within a program.  It is implementation defined whether
28610 or not there may be more than one thread associated with a program.
28611 It is implementation defined how threads beyond the first are
28612 created, the name and type of the function called at thread
28613 startup, and how threads may be terminated.  However, objects
28614 with thread storage duration shall be initialized before thread
28615 startup.
28616 @end quotation
28618 @item
28619 @cite{6.2.4  Storage durations of objects}
28621 Add new text before paragraph 3
28623 @quotation
28624 An object whose identifier is declared with the storage-class
28625 specifier @w{@code{__thread}} has @dfn{thread storage duration}.
28626 Its lifetime is the entire execution of the thread, and its
28627 stored value is initialized only once, prior to thread startup.
28628 @end quotation
28630 @item
28631 @cite{6.4.1  Keywords}
28633 Add @code{__thread}.
28635 @item
28636 @cite{6.7.1  Storage-class specifiers}
28638 Add @code{__thread} to the list of storage class specifiers in
28639 paragraph 1.
28641 Change paragraph 2 to
28643 @quotation
28644 With the exception of @code{__thread}, at most one storage-class
28645 specifier may be given [@dots{}].  The @code{__thread} specifier may
28646 be used alone, or immediately following @code{extern} or
28647 @code{static}.
28648 @end quotation
28650 Add new text after paragraph 6
28652 @quotation
28653 The declaration of an identifier for a variable that has
28654 block scope that specifies @code{__thread} shall also
28655 specify either @code{extern} or @code{static}.
28657 The @code{__thread} specifier shall be used only with
28658 variables.
28659 @end quotation
28660 @end itemize
28662 @node C++98 Thread-Local Edits
28663 @subsection ISO/IEC 14882:1998 Edits for Thread-Local Storage
28665 The following are a set of changes to ISO/IEC 14882:1998 (aka C++98)
28666 that document the exact semantics of the language extension.
28668 @itemize @bullet
28669 @item
28670 @b{[intro.execution]}
28672 New text after paragraph 4
28674 @quotation
28675 A @dfn{thread} is a flow of control within the abstract machine.
28676 It is implementation defined whether or not there may be more than
28677 one thread.
28678 @end quotation
28680 New text after paragraph 7
28682 @quotation
28683 It is unspecified whether additional action must be taken to
28684 ensure when and whether side effects are visible to other threads.
28685 @end quotation
28687 @item
28688 @b{[lex.key]}
28690 Add @code{__thread}.
28692 @item
28693 @b{[basic.start.main]}
28695 Add after paragraph 5
28697 @quotation
28698 The thread that begins execution at the @code{main} function is called
28699 the @dfn{main thread}.  It is implementation defined how functions
28700 beginning threads other than the main thread are designated or typed.
28701 A function so designated, as well as the @code{main} function, is called
28702 a @dfn{thread startup function}.  It is implementation defined what
28703 happens if a thread startup function returns.  It is implementation
28704 defined what happens to other threads when any thread calls @code{exit}.
28705 @end quotation
28707 @item
28708 @b{[basic.start.init]}
28710 Add after paragraph 4
28712 @quotation
28713 The storage for an object of thread storage duration shall be
28714 statically initialized before the first statement of the thread startup
28715 function.  An object of thread storage duration shall not require
28716 dynamic initialization.
28717 @end quotation
28719 @item
28720 @b{[basic.start.term]}
28722 Add after paragraph 3
28724 @quotation
28725 The type of an object with thread storage duration shall not have a
28726 non-trivial destructor, nor shall it be an array type whose elements
28727 (directly or indirectly) have non-trivial destructors.
28728 @end quotation
28730 @item
28731 @b{[basic.stc]}
28733 Add ``thread storage duration'' to the list in paragraph 1.
28735 Change paragraph 2
28737 @quotation
28738 Thread, static, and automatic storage durations are associated with
28739 objects introduced by declarations [@dots{}].
28740 @end quotation
28742 Add @code{__thread} to the list of specifiers in paragraph 3.
28744 @item
28745 @b{[basic.stc.thread]}
28747 New section before @b{[basic.stc.static]}
28749 @quotation
28750 The keyword @code{__thread} applied to a non-local object gives the
28751 object thread storage duration.
28753 A local variable or class data member declared both @code{static}
28754 and @code{__thread} gives the variable or member thread storage
28755 duration.
28756 @end quotation
28758 @item
28759 @b{[basic.stc.static]}
28761 Change paragraph 1
28763 @quotation
28764 All objects that have neither thread storage duration, dynamic
28765 storage duration nor are local [@dots{}].
28766 @end quotation
28768 @item
28769 @b{[dcl.stc]}
28771 Add @code{__thread} to the list in paragraph 1.
28773 Change paragraph 1
28775 @quotation
28776 With the exception of @code{__thread}, at most one
28777 @var{storage-class-specifier} shall appear in a given
28778 @var{decl-specifier-seq}.  The @code{__thread} specifier may
28779 be used alone, or immediately following the @code{extern} or
28780 @code{static} specifiers.  [@dots{}]
28781 @end quotation
28783 Add after paragraph 5
28785 @quotation
28786 The @code{__thread} specifier can be applied only to the names of objects
28787 and to anonymous unions.
28788 @end quotation
28790 @item
28791 @b{[class.mem]}
28793 Add after paragraph 6
28795 @quotation
28796 Non-@code{static} members shall not be @code{__thread}.
28797 @end quotation
28798 @end itemize
28800 @node Binary constants
28801 @section Binary Constants using the @samp{0b} Prefix
28802 @cindex Binary constants using the @samp{0b} prefix
28804 Integer constants can be written as binary constants, consisting of a
28805 sequence of @samp{0} and @samp{1} digits, prefixed by @samp{0b} or
28806 @samp{0B}.  This is particularly useful in environments that operate a
28807 lot on the bit level (like microcontrollers).
28809 The following statements are identical:
28811 @smallexample
28812 i =       42;
28813 i =     0x2a;
28814 i =      052;
28815 i = 0b101010;
28816 @end smallexample
28818 The type of these constants follows the same rules as for octal or
28819 hexadecimal integer constants, so suffixes like @samp{L} or @samp{UL}
28820 can be applied.
28822 @node C++ Extensions
28823 @chapter Extensions to the C++ Language
28824 @cindex extensions, C++ language
28825 @cindex C++ language extensions
28827 The GNU compiler provides these extensions to the C++ language (and you
28828 can also use most of the C language extensions in your C++ programs).  If you
28829 want to write code that checks whether these features are available, you can
28830 test for the GNU compiler the same way as for C programs: check for a
28831 predefined macro @code{__GNUC__}.  You can also use @code{__GNUG__} to
28832 test specifically for GNU C++ (@pxref{Common Predefined Macros,,
28833 Predefined Macros,cpp,The GNU C Preprocessor}).
28835 @menu
28836 * C++ Volatiles::       What constitutes an access to a volatile object.
28837 * Restricted Pointers:: C99 restricted pointers and references.
28838 * Vague Linkage::       Where G++ puts inlines, vtables and such.
28839 * C++ Interface::       You can use a single C++ header file for both
28840                         declarations and definitions.
28841 * Template Instantiation:: Methods for ensuring that exactly one copy of
28842                         each needed template instantiation is emitted.
28843 * Bound member functions:: You can extract a function pointer to the
28844                         method denoted by a @samp{->*} or @samp{.*} expression.
28845 * C++ Attributes::      Variable, function, and type attributes for C++ only.
28846 * Function Multiversioning::   Declaring multiple function versions.
28847 * Type Traits::         Compiler support for type traits.
28848 * C++ Concepts::        Improved support for generic programming.
28849 * Deprecated Features:: Things will disappear from G++.
28850 * Backwards Compatibility:: Compatibilities with earlier definitions of C++.
28851 @end menu
28853 @node C++ Volatiles
28854 @section When is a Volatile C++ Object Accessed?
28855 @cindex accessing volatiles
28856 @cindex volatile read
28857 @cindex volatile write
28858 @cindex volatile access
28860 The C++ standard differs from the C standard in its treatment of
28861 volatile objects.  It fails to specify what constitutes a volatile
28862 access, except to say that C++ should behave in a similar manner to C
28863 with respect to volatiles, where possible.  However, the different
28864 lvalueness of expressions between C and C++ complicate the behavior.
28865 G++ behaves the same as GCC for volatile access, @xref{C
28866 Extensions,,Volatiles}, for a description of GCC's behavior.
28868 The C and C++ language specifications differ when an object is
28869 accessed in a void context:
28871 @smallexample
28872 volatile int *src = @var{somevalue};
28873 *src;
28874 @end smallexample
28876 The C++ standard specifies that such expressions do not undergo lvalue
28877 to rvalue conversion, and that the type of the dereferenced object may
28878 be incomplete.  The C++ standard does not specify explicitly that it
28879 is lvalue to rvalue conversion that is responsible for causing an
28880 access.  There is reason to believe that it is, because otherwise
28881 certain simple expressions become undefined.  However, because it
28882 would surprise most programmers, G++ treats dereferencing a pointer to
28883 volatile object of complete type as GCC would do for an equivalent
28884 type in C@.  When the object has incomplete type, G++ issues a
28885 warning; if you wish to force an error, you must force a conversion to
28886 rvalue with, for instance, a static cast.
28888 When using a reference to volatile, G++ does not treat equivalent
28889 expressions as accesses to volatiles, but instead issues a warning that
28890 no volatile is accessed.  The rationale for this is that otherwise it
28891 becomes difficult to determine where volatile access occur, and not
28892 possible to ignore the return value from functions returning volatile
28893 references.  Again, if you wish to force a read, cast the reference to
28894 an rvalue.
28896 G++ implements the same behavior as GCC does when assigning to a
28897 volatile object---there is no reread of the assigned-to object, the
28898 assigned rvalue is reused.  Note that in C++ assignment expressions
28899 are lvalues, and if used as an lvalue, the volatile object is
28900 referred to.  For instance, @var{vref} refers to @var{vobj}, as
28901 expected, in the following example:
28903 @smallexample
28904 volatile int vobj;
28905 volatile int &vref = vobj = @var{something};
28906 @end smallexample
28908 @node Restricted Pointers
28909 @section Restricting Pointer Aliasing
28910 @cindex restricted pointers
28911 @cindex restricted references
28912 @cindex restricted this pointer
28914 As with the C front end, G++ understands the C99 feature of restricted pointers,
28915 specified with the @code{__restrict__}, or @code{__restrict} type
28916 qualifier.  Because you cannot compile C++ by specifying the @option{-std=c99}
28917 language flag, @code{restrict} is not a keyword in C++.
28919 In addition to allowing restricted pointers, you can specify restricted
28920 references, which indicate that the reference is not aliased in the local
28921 context.
28923 @smallexample
28924 void fn (int *__restrict__ rptr, int &__restrict__ rref)
28926   /* @r{@dots{}} */
28928 @end smallexample
28930 @noindent
28931 In the body of @code{fn}, @var{rptr} points to an unaliased integer and
28932 @var{rref} refers to a (different) unaliased integer.
28934 You may also specify whether a member function's @var{this} pointer is
28935 unaliased by using @code{__restrict__} as a member function qualifier.
28937 @smallexample
28938 void T::fn () __restrict__
28940   /* @r{@dots{}} */
28942 @end smallexample
28944 @noindent
28945 Within the body of @code{T::fn}, @var{this} has the effective
28946 definition @code{T *__restrict__ const this}.  Notice that the
28947 interpretation of a @code{__restrict__} member function qualifier is
28948 different to that of @code{const} or @code{volatile} qualifier, in that it
28949 is applied to the pointer rather than the object.  This is consistent with
28950 other compilers that implement restricted pointers.
28952 As with all outermost parameter qualifiers, @code{__restrict__} is
28953 ignored in function definition matching.  This means you only need to
28954 specify @code{__restrict__} in a function definition, rather than
28955 in a function prototype as well.
28957 @node Vague Linkage
28958 @section Vague Linkage
28959 @cindex vague linkage
28961 There are several constructs in C++ that require space in the object
28962 file but are not clearly tied to a single translation unit.  We say that
28963 these constructs have ``vague linkage''.  Typically such constructs are
28964 emitted wherever they are needed, though sometimes we can be more
28965 clever.
28967 @table @asis
28968 @item Inline Functions
28969 Inline functions are typically defined in a header file which can be
28970 included in many different compilations.  Hopefully they can usually be
28971 inlined, but sometimes an out-of-line copy is necessary, if the address
28972 of the function is taken or if inlining fails.  In general, we emit an
28973 out-of-line copy in all translation units where one is needed.  As an
28974 exception, we only emit inline virtual functions with the vtable, since
28975 it always requires a copy.
28977 Local static variables and string constants used in an inline function
28978 are also considered to have vague linkage, since they must be shared
28979 between all inlined and out-of-line instances of the function.
28981 @cindex vtable
28982 @item VTables
28983 C++ virtual functions are implemented in most compilers using a lookup
28984 table, known as a vtable.  The vtable contains pointers to the virtual
28985 functions provided by a class, and each object of the class contains a
28986 pointer to its vtable (or vtables, in some multiple-inheritance
28987 situations).  If the class declares any non-inline, non-pure virtual
28988 functions, the first one is chosen as the ``key method'' for the class,
28989 and the vtable is only emitted in the translation unit where the key
28990 method is defined.
28992 @emph{Note:} If the chosen key method is later defined as inline, the
28993 vtable is still emitted in every translation unit that defines it.
28994 Make sure that any inline virtuals are declared inline in the class
28995 body, even if they are not defined there.
28997 @cindex @code{type_info}
28998 @cindex RTTI
28999 @item @code{type_info} objects
29000 C++ requires information about types to be written out in order to
29001 implement @samp{dynamic_cast}, @samp{typeid} and exception handling.
29002 For polymorphic classes (classes with virtual functions), the @samp{type_info}
29003 object is written out along with the vtable so that @samp{dynamic_cast}
29004 can determine the dynamic type of a class object at run time.  For all
29005 other types, we write out the @samp{type_info} object when it is used: when
29006 applying @samp{typeid} to an expression, throwing an object, or
29007 referring to a type in a catch clause or exception specification.
29009 @item Template Instantiations
29010 Most everything in this section also applies to template instantiations,
29011 but there are other options as well.
29012 @xref{Template Instantiation,,Where's the Template?}.
29014 @end table
29016 When used with GNU ld version 2.8 or later on an ELF system such as
29017 GNU/Linux or Solaris 2, or on Microsoft Windows, duplicate copies of
29018 these constructs will be discarded at link time.  This is known as
29019 COMDAT support.
29021 On targets that don't support COMDAT, but do support weak symbols, GCC
29022 uses them.  This way one copy overrides all the others, but
29023 the unused copies still take up space in the executable.
29025 For targets that do not support either COMDAT or weak symbols,
29026 most entities with vague linkage are emitted as local symbols to
29027 avoid duplicate definition errors from the linker.  This does not happen
29028 for local statics in inlines, however, as having multiple copies
29029 almost certainly breaks things.
29031 @xref{C++ Interface,,Declarations and Definitions in One Header}, for
29032 another way to control placement of these constructs.
29034 @node C++ Interface
29035 @section C++ Interface and Implementation Pragmas
29037 @cindex interface and implementation headers, C++
29038 @cindex C++ interface and implementation headers
29039 @cindex pragmas, interface and implementation
29041 @code{#pragma interface} and @code{#pragma implementation} provide the
29042 user with a way of explicitly directing the compiler to emit entities
29043 with vague linkage (and debugging information) in a particular
29044 translation unit.
29046 @emph{Note:} These @code{#pragma}s have been superceded as of GCC 2.7.2
29047 by COMDAT support and the ``key method'' heuristic
29048 mentioned in @ref{Vague Linkage}.  Using them can actually cause your
29049 program to grow due to unnecessary out-of-line copies of inline
29050 functions.
29052 @table @code
29053 @kindex #pragma interface
29054 @item #pragma interface
29055 @itemx #pragma interface "@var{subdir}/@var{objects}.h"
29056 Use this directive in @emph{header files} that define object classes, to save
29057 space in most of the object files that use those classes.  Normally,
29058 local copies of certain information (backup copies of inline member
29059 functions, debugging information, and the internal tables that implement
29060 virtual functions) must be kept in each object file that includes class
29061 definitions.  You can use this pragma to avoid such duplication.  When a
29062 header file containing @samp{#pragma interface} is included in a
29063 compilation, this auxiliary information is not generated (unless
29064 the main input source file itself uses @samp{#pragma implementation}).
29065 Instead, the object files contain references to be resolved at link
29066 time.
29068 The second form of this directive is useful for the case where you have
29069 multiple headers with the same name in different directories.  If you
29070 use this form, you must specify the same string to @samp{#pragma
29071 implementation}.
29073 @kindex #pragma implementation
29074 @item #pragma implementation
29075 @itemx #pragma implementation "@var{objects}.h"
29076 Use this pragma in a @emph{main input file}, when you want full output from
29077 included header files to be generated (and made globally visible).  The
29078 included header file, in turn, should use @samp{#pragma interface}.
29079 Backup copies of inline member functions, debugging information, and the
29080 internal tables used to implement virtual functions are all generated in
29081 implementation files.
29083 @cindex implied @code{#pragma implementation}
29084 @cindex @code{#pragma implementation}, implied
29085 @cindex naming convention, implementation headers
29086 If you use @samp{#pragma implementation} with no argument, it applies to
29087 an include file with the same basename@footnote{A file's @dfn{basename}
29088 is the name stripped of all leading path information and of trailing
29089 suffixes, such as @samp{.h} or @samp{.C} or @samp{.cc}.} as your source
29090 file.  For example, in @file{allclass.cc}, giving just
29091 @samp{#pragma implementation}
29092 by itself is equivalent to @samp{#pragma implementation "allclass.h"}.
29094 Use the string argument if you want a single implementation file to
29095 include code from multiple header files.  (You must also use
29096 @samp{#include} to include the header file; @samp{#pragma
29097 implementation} only specifies how to use the file---it doesn't actually
29098 include it.)
29100 There is no way to split up the contents of a single header file into
29101 multiple implementation files.
29102 @end table
29104 @cindex inlining and C++ pragmas
29105 @cindex C++ pragmas, effect on inlining
29106 @cindex pragmas in C++, effect on inlining
29107 @samp{#pragma implementation} and @samp{#pragma interface} also have an
29108 effect on function inlining.
29110 If you define a class in a header file marked with @samp{#pragma
29111 interface}, the effect on an inline function defined in that class is
29112 similar to an explicit @code{extern} declaration---the compiler emits
29113 no code at all to define an independent version of the function.  Its
29114 definition is used only for inlining with its callers.
29116 @opindex fno-implement-inlines
29117 Conversely, when you include the same header file in a main source file
29118 that declares it as @samp{#pragma implementation}, the compiler emits
29119 code for the function itself; this defines a version of the function
29120 that can be found via pointers (or by callers compiled without
29121 inlining).  If all calls to the function can be inlined, you can avoid
29122 emitting the function by compiling with @option{-fno-implement-inlines}.
29123 If any calls are not inlined, you will get linker errors.
29125 @node Template Instantiation
29126 @section Where's the Template?
29127 @cindex template instantiation
29129 C++ templates were the first language feature to require more
29130 intelligence from the environment than was traditionally found on a UNIX
29131 system.  Somehow the compiler and linker have to make sure that each
29132 template instance occurs exactly once in the executable if it is needed,
29133 and not at all otherwise.  There are two basic approaches to this
29134 problem, which are referred to as the Borland model and the Cfront model.
29136 @table @asis
29137 @item Borland model
29138 Borland C++ solved the template instantiation problem by adding the code
29139 equivalent of common blocks to their linker; the compiler emits template
29140 instances in each translation unit that uses them, and the linker
29141 collapses them together.  The advantage of this model is that the linker
29142 only has to consider the object files themselves; there is no external
29143 complexity to worry about.  The disadvantage is that compilation time
29144 is increased because the template code is being compiled repeatedly.
29145 Code written for this model tends to include definitions of all
29146 templates in the header file, since they must be seen to be
29147 instantiated.
29149 @item Cfront model
29150 The AT&T C++ translator, Cfront, solved the template instantiation
29151 problem by creating the notion of a template repository, an
29152 automatically maintained place where template instances are stored.  A
29153 more modern version of the repository works as follows: As individual
29154 object files are built, the compiler places any template definitions and
29155 instantiations encountered in the repository.  At link time, the link
29156 wrapper adds in the objects in the repository and compiles any needed
29157 instances that were not previously emitted.  The advantages of this
29158 model are more optimal compilation speed and the ability to use the
29159 system linker; to implement the Borland model a compiler vendor also
29160 needs to replace the linker.  The disadvantages are vastly increased
29161 complexity, and thus potential for error; for some code this can be
29162 just as transparent, but in practice it can been very difficult to build
29163 multiple programs in one directory and one program in multiple
29164 directories.  Code written for this model tends to separate definitions
29165 of non-inline member templates into a separate file, which should be
29166 compiled separately.
29167 @end table
29169 G++ implements the Borland model on targets where the linker supports it,
29170 including ELF targets (such as GNU/Linux), macOS and Microsoft Windows.
29171 Otherwise G++ implements neither automatic model.
29173 You have the following options for dealing with template instantiations:
29175 @enumerate
29176 @item
29177 Do nothing.  Code written for the Borland model works fine, but
29178 each translation unit contains instances of each of the templates it
29179 uses.  The duplicate instances will be discarded by the linker, but in
29180 a large program, this can lead to an unacceptable amount of code
29181 duplication in object files or shared libraries.
29183 Duplicate instances of a template can be avoided by defining an explicit
29184 instantiation in one object file, and preventing the compiler from doing
29185 implicit instantiations in any other object files by using an explicit
29186 instantiation declaration, using the @code{extern template} syntax:
29188 @smallexample
29189 extern template int max (int, int);
29190 @end smallexample
29192 This syntax is defined in the C++ 2011 standard, but has been supported by
29193 G++ and other compilers since well before 2011.
29195 Explicit instantiations can be used for the largest or most frequently
29196 duplicated instances, without having to know exactly which other instances
29197 are used in the rest of the program.  You can scatter the explicit
29198 instantiations throughout your program, perhaps putting them in the
29199 translation units where the instances are used or the translation units
29200 that define the templates themselves; you can put all of the explicit
29201 instantiations you need into one big file; or you can create small files
29202 like
29204 @smallexample
29205 #include "Foo.h"
29206 #include "Foo.cc"
29208 template class Foo<int>;
29209 template ostream& operator <<
29210                 (ostream&, const Foo<int>&);
29211 @end smallexample
29213 @noindent
29214 for each of the instances you need, and create a template instantiation
29215 library from those.
29217 This is the simplest option, but also offers flexibility and
29218 fine-grained control when necessary. It is also the most portable
29219 alternative and programs using this approach will work with most modern
29220 compilers.
29222 @opindex fno-implicit-templates
29223 @item
29224 Compile your code with @option{-fno-implicit-templates} to disable the
29225 implicit generation of template instances, and explicitly instantiate
29226 all the ones you use.  This approach requires more knowledge of exactly
29227 which instances you need than do the others, but it's less
29228 mysterious and allows greater control if you want to ensure that only
29229 the intended instances are used.
29231 If you are using Cfront-model code, you can probably get away with not
29232 using @option{-fno-implicit-templates} when compiling files that don't
29233 @samp{#include} the member template definitions.
29235 If you use one big file to do the instantiations, you may want to
29236 compile it without @option{-fno-implicit-templates} so you get all of the
29237 instances required by your explicit instantiations (but not by any
29238 other files) without having to specify them as well.
29240 In addition to forward declaration of explicit instantiations
29241 (with @code{extern}), G++ has extended the template instantiation
29242 syntax to support instantiation of the compiler support data for a
29243 template class (i.e.@: the vtable) without instantiating any of its
29244 members (with @code{inline}), and instantiation of only the static data
29245 members of a template class, without the support data or member
29246 functions (with @code{static}):
29248 @smallexample
29249 inline template class Foo<int>;
29250 static template class Foo<int>;
29251 @end smallexample
29252 @end enumerate
29254 @node Bound member functions
29255 @section Extracting the Function Pointer from a Bound Pointer to Member Function
29256 @cindex pmf
29257 @cindex pointer to member function
29258 @cindex bound pointer to member function
29260 In C++, pointer to member functions (PMFs) are implemented using a wide
29261 pointer of sorts to handle all the possible call mechanisms; the PMF
29262 needs to store information about how to adjust the @samp{this} pointer,
29263 and if the function pointed to is virtual, where to find the vtable, and
29264 where in the vtable to look for the member function.  If you are using
29265 PMFs in an inner loop, you should really reconsider that decision.  If
29266 that is not an option, you can extract the pointer to the function that
29267 would be called for a given object/PMF pair and call it directly inside
29268 the inner loop, to save a bit of time.
29270 Note that you still pay the penalty for the call through a
29271 function pointer; on most modern architectures, such a call defeats the
29272 branch prediction features of the CPU@.  This is also true of normal
29273 virtual function calls.
29275 The syntax for this extension is
29277 @smallexample
29278 extern A a;
29279 extern int (A::*fp)();
29280 typedef int (*fptr)(A *);
29282 fptr p = (fptr)(a.*fp);
29283 @end smallexample
29285 For PMF constants (i.e.@: expressions of the form @samp{&Klasse::Member}),
29286 no object is needed to obtain the address of the function.  They can be
29287 converted to function pointers directly:
29289 @smallexample
29290 fptr p1 = (fptr)(&A::foo);
29291 @end smallexample
29293 @opindex Wno-pmf-conversions
29294 You must specify @option{-Wno-pmf-conversions} to use this extension.
29296 @node C++ Attributes
29297 @section C++-Specific Variable, Function, and Type Attributes
29299 Some attributes only make sense for C++ programs.
29301 @table @code
29302 @cindex @code{abi_tag} function attribute
29303 @cindex @code{abi_tag} variable attribute
29304 @cindex @code{abi_tag} type attribute
29305 @item abi_tag ("@var{tag}", ...)
29306 The @code{abi_tag} attribute can be applied to a function, variable, or class
29307 declaration.  It modifies the mangled name of the entity to
29308 incorporate the tag name, in order to distinguish the function or
29309 class from an earlier version with a different ABI; perhaps the class
29310 has changed size, or the function has a different return type that is
29311 not encoded in the mangled name.
29313 The attribute can also be applied to an inline namespace, but does not
29314 affect the mangled name of the namespace; in this case it is only used
29315 for @option{-Wabi-tag} warnings and automatic tagging of functions and
29316 variables.  Tagging inline namespaces is generally preferable to
29317 tagging individual declarations, but the latter is sometimes
29318 necessary, such as when only certain members of a class need to be
29319 tagged.
29321 The argument can be a list of strings of arbitrary length.  The
29322 strings are sorted on output, so the order of the list is
29323 unimportant.
29325 A redeclaration of an entity must not add new ABI tags,
29326 since doing so would change the mangled name.
29328 The ABI tags apply to a name, so all instantiations and
29329 specializations of a template have the same tags.  The attribute will
29330 be ignored if applied to an explicit specialization or instantiation.
29332 The @option{-Wabi-tag} flag enables a warning about a class which does
29333 not have all the ABI tags used by its subobjects and virtual functions; for users with code
29334 that needs to coexist with an earlier ABI, using this option can help
29335 to find all affected types that need to be tagged.
29337 When a type involving an ABI tag is used as the type of a variable or
29338 return type of a function where that tag is not already present in the
29339 signature of the function, the tag is automatically applied to the
29340 variable or function.  @option{-Wabi-tag} also warns about this
29341 situation; this warning can be avoided by explicitly tagging the
29342 variable or function or moving it into a tagged inline namespace.
29344 @cindex @code{init_priority} variable attribute
29345 @item init_priority (@var{priority})
29347 In Standard C++, objects defined at namespace scope are guaranteed to be
29348 initialized in an order in strict accordance with that of their definitions
29349 @emph{in a given translation unit}.  No guarantee is made for initializations
29350 across translation units.  However, GNU C++ allows users to control the
29351 order of initialization of objects defined at namespace scope with the
29352 @code{init_priority} attribute by specifying a relative @var{priority},
29353 a constant integral expression currently bounded between 101 and 65535
29354 inclusive.  Lower numbers indicate a higher priority.
29356 In the following example, @code{A} would normally be created before
29357 @code{B}, but the @code{init_priority} attribute reverses that order:
29359 @smallexample
29360 Some_Class  A  __attribute__ ((init_priority (2000)));
29361 Some_Class  B  __attribute__ ((init_priority (543)));
29362 @end smallexample
29364 @noindent
29365 Note that the particular values of @var{priority} do not matter; only their
29366 relative ordering.
29368 @cindex @code{no_dangling} type attribute
29369 @cindex @code{no_dangling} function attribute
29370 @item no_dangling
29372 This attribute can be applied on a class type, function, or member
29373 function.  Dangling references to classes marked with this attribute
29374 will have the @option{-Wdangling-reference} diagnostic suppressed; so
29375 will references returned from the @code{gnu::no_dangling}-marked
29376 functions.  For example:
29378 @smallexample
29379 class [[gnu::no_dangling]] S @{ @dots{} @};
29380 @end smallexample
29384 @smallexample
29385 class A @{
29386   int *p;
29387   [[gnu::no_dangling]] int &foo() @{ return *p; @}
29390 [[gnu::no_dangling]] const int &
29391 foo (const int &i)
29393   @dots{}
29395 @end smallexample
29397 This attribute takes an optional argument, which must be an expression that
29398 evaluates to true or false:
29400 @smallexample
29401 template <typename T>
29402 struct [[gnu::no_dangling(std::is_reference_v<T>)]] S @{
29403   @dots{}
29405 @end smallexample
29409 @smallexample
29410 template <typename T>
29411 [[gnu::no_dangling(std::is_lvalue_reference_v<T>)]]
29412 decltype(auto) foo(T&& t) @{
29413   @dots{}
29415 @end smallexample
29417 @cindex @code{warn_unused} type attribute
29418 @item warn_unused
29420 For C++ types with non-trivial constructors and/or destructors it is
29421 impossible for the compiler to determine whether a variable of this
29422 type is truly unused if it is not referenced. This type attribute
29423 informs the compiler that variables of this type should be warned
29424 about if they appear to be unused, just like variables of fundamental
29425 types.
29427 This attribute is appropriate for types which just represent a value,
29428 such as @code{std::string}; it is not appropriate for types which
29429 control a resource, such as @code{std::lock_guard}.
29431 This attribute is also accepted in C, but it is unnecessary because C
29432 does not have constructors or destructors.
29434 @cindex @code{cold} type attribute
29435 @item cold
29437 In addition to functions and labels, GNU C++ allows the @code{cold}
29438 attribute to be used on C++ classes, structs, or unions.  Applying
29439 the @code{cold} attribute on a type has the effect of treating every
29440 member function of the type, including implicit special member
29441 functions, as cold.  If a member function is marked with the
29442 @code{hot} function attribute, the @code{hot} attribute takes
29443 precedence and the @code{cold} attribute is not propagated.
29445 For the effects of the @code{cold} attribute on functions, see
29446 @ref{Common Function Attributes}.
29448 @cindex @code{hot} type attribute
29449 @item hot
29451 In addition to functions and labels, GNU C++ allows the @code{hot}
29452 attribute to be used on C++ classes, structs, or unions.  Applying
29453 the @code{hot} attribute on a type has the effect of treating every
29454 member function of the type, including implicit special member
29455 functions, as hot.  If a member function is marked with the
29456 @code{cold} function attribute, the @code{cold} attribute takes
29457 precedence and the @code{hot} attribute is not propagated.
29459 For the effects of the @code{hot} attribute on functions, see
29460 @ref{Common Function Attributes}.
29462 @end table
29464 @node Function Multiversioning
29465 @section Function Multiversioning
29466 @cindex function versions
29468 With the GNU C++ front end, for x86 targets, you may specify multiple
29469 versions of a function, where each function is specialized for a
29470 specific target feature.  At runtime, the appropriate version of the
29471 function is automatically executed depending on the characteristics of
29472 the execution platform.  Here is an example.
29474 @smallexample
29475 __attribute__ ((target ("default")))
29476 int foo ()
29478   // The default version of foo.
29479   return 0;
29482 __attribute__ ((target ("sse4.2")))
29483 int foo ()
29485   // foo version for SSE4.2
29486   return 1;
29489 __attribute__ ((target ("arch=atom")))
29490 int foo ()
29492   // foo version for the Intel ATOM processor
29493   return 2;
29496 __attribute__ ((target ("arch=amdfam10")))
29497 int foo ()
29499   // foo version for the AMD Family 0x10 processors.
29500   return 3;
29503 int main ()
29505   int (*p)() = &foo;
29506   assert ((*p) () == foo ());
29507   return 0;
29509 @end smallexample
29511 In the above example, four versions of function foo are created. The
29512 first version of foo with the target attribute "default" is the default
29513 version.  This version gets executed when no other target specific
29514 version qualifies for execution on a particular platform. A new version
29515 of foo is created by using the same function signature but with a
29516 different target string.  Function foo is called or a pointer to it is
29517 taken just like a regular function.  GCC takes care of doing the
29518 dispatching to call the right version at runtime.  Refer to the
29519 @uref{https://gcc.gnu.org/wiki/FunctionMultiVersioning, GCC wiki on
29520 Function Multiversioning} for more details.
29522 @node Type Traits
29523 @section Type Traits
29525 The C++ front end implements syntactic extensions that allow
29526 compile-time determination of 
29527 various characteristics of a type (or of a
29528 pair of types).
29530 @defbuiltin{bool __has_nothrow_assign (@var{type})}
29531 If @var{type} is @code{const}-qualified or is a reference type then
29532 the trait is @code{false}.  Otherwise if @code{__has_trivial_assign (type)}
29533 is @code{true} then the trait is @code{true}, else if @var{type} is
29534 a cv-qualified class or union type with copy assignment operators that are
29535 known not to throw an exception then the trait is @code{true}, else it is
29536 @code{false}.
29537 Requires: @var{type} shall be a complete type, (possibly cv-qualified)
29538 @code{void}, or an array of unknown bound.
29539 @enddefbuiltin
29541 @defbuiltin{bool __has_nothrow_copy (@var{type})}
29542 If @code{__has_trivial_copy (type)} is @code{true} then the trait is
29543 @code{true}, else if @var{type} is a cv-qualified class or union type
29544 with copy constructors that are known not to throw an exception then
29545 the trait is @code{true}, else it is @code{false}.
29546 Requires: @var{type} shall be a complete type, (possibly cv-qualified)
29547 @code{void}, or an array of unknown bound.
29548 @enddefbuiltin
29550 @defbuiltin{bool __has_nothrow_constructor (@var{type})}
29551 If @code{__has_trivial_constructor (type)} is @code{true} then the trait
29552 is @code{true}, else if @var{type} is a cv class or union type (or array
29553 thereof) with a default constructor that is known not to throw an
29554 exception then the trait is @code{true}, else it is @code{false}.
29555 Requires: @var{type} shall be a complete type, (possibly cv-qualified)
29556 @code{void}, or an array of unknown bound.
29557 @enddefbuiltin
29559 @defbuiltin{bool __has_trivial_assign (@var{type})}
29560 If @var{type} is @code{const}- qualified or is a reference type then
29561 the trait is @code{false}.  Otherwise if @code{__is_trivial (type)} is
29562 @code{true} then the trait is @code{true}, else if @var{type} is
29563 a cv-qualified class or union type with a trivial copy assignment
29564 ([class.copy]) then the trait is @code{true}, else it is @code{false}.
29565 Requires: @var{type} shall be a complete type, (possibly cv-qualified)
29566 @code{void}, or an array of unknown bound.
29567 @enddefbuiltin
29569 @defbuiltin{bool __has_trivial_copy (@var{type})}
29570 If @code{__is_trivial (type)} is @code{true} or @var{type} is a reference
29571 type then the trait is @code{true}, else if @var{type} is a cv class
29572 or union type with a trivial copy constructor ([class.copy]) then the trait
29573 is @code{true}, else it is @code{false}.  Requires: @var{type} shall be
29574 a complete type, (possibly cv-qualified) @code{void}, or an array of unknown
29575 bound.
29576 @enddefbuiltin
29578 @defbuiltin{bool __has_trivial_constructor (@var{type})}
29579 If @code{__is_trivial (type)} is @code{true} then the trait is @code{true},
29580 else if @var{type} is a cv-qualified class or union type (or array thereof)
29581 with a trivial default constructor ([class.ctor]) then the trait is @code{true},
29582 else it is @code{false}.
29583 Requires: @var{type} shall be a complete type, (possibly cv-qualified)
29584 @code{void}, or an array of unknown bound.
29585 @enddefbuiltin
29587 @defbuiltin{bool __has_trivial_destructor (@var{type})}
29588 If @code{__is_trivial (type)} is @code{true} or @var{type} is a reference type
29589 then the trait is @code{true}, else if @var{type} is a cv class or union
29590 type (or array thereof) with a trivial destructor ([class.dtor]) then
29591 the trait is @code{true}, else it is @code{false}.
29592 Requires: @var{type} shall be a complete type, (possibly cv-qualified)
29593 @code{void}, or an array of unknown bound.
29594 @enddefbuiltin
29596 @defbuiltin{bool __has_virtual_destructor (@var{type})}
29597 If @var{type} is a class type with a virtual destructor
29598 ([class.dtor]) then the trait is @code{true}, else it is @code{false}.
29599 Requires: If @var{type} is a non-union class type, it shall be a complete type.
29600 @enddefbuiltin
29602 @defbuiltin{bool __is_abstract (@var{type})}
29603 If @var{type} is an abstract class ([class.abstract]) then the trait
29604 is @code{true}, else it is @code{false}.
29605 Requires: If @var{type} is a non-union class type, it shall be a complete type.
29606 @enddefbuiltin
29608 @defbuiltin{bool __is_aggregate (@var{type})}
29609 If @var{type} is an aggregate type ([dcl.init.aggr]) the trait is
29610 @code{true}, else it is @code{false}.
29611 Requires: If @var{type} is a class type, it shall be a complete type.
29612 @enddefbuiltin
29614 @defbuiltin{bool __is_base_of (@var{base_type}, @var{derived_type})}
29615 If @var{base_type} is a base class of @var{derived_type}
29616 ([class.derived]) then the trait is @code{true}, otherwise it is @code{false}.
29617 Top-level cv-qualifications of @var{base_type} and
29618 @var{derived_type} are ignored.  For the purposes of this trait, a
29619 class type is considered is own base.
29620 Requires: if @code{__is_class (base_type)} and @code{__is_class (derived_type)}
29621 are @code{true} and @var{base_type} and @var{derived_type} are not the same
29622 type (disregarding cv-qualifiers), @var{derived_type} shall be a complete
29623 type.  A diagnostic is produced if this requirement is not met.
29624 @enddefbuiltin
29626 @defbuiltin{bool __is_class (@var{type})}
29627 If @var{type} is a cv-qualified class type, and not a union type
29628 ([basic.compound]) the trait is @code{true}, else it is @code{false}.
29629 @enddefbuiltin
29631 @c FIXME Commented out for GCC 13, discuss user interface for GCC 14.
29632 @c @defbuiltin{bool __is_deducible (@var{template}, @var{type})}
29633 @c If template arguments for @code{template} can be deduced from
29634 @c @code{type} or obtained from default template arguments.
29635 @c @enddefbuiltin
29637 @defbuiltin{bool __is_empty (@var{type})}
29638 If @code{__is_class (type)} is @code{false} then the trait is @code{false}.
29639 Otherwise @var{type} is considered empty if and only if: @var{type}
29640 has no non-static data members, or all non-static data members, if
29641 any, are bit-fields of length 0, and @var{type} has no virtual
29642 members, and @var{type} has no virtual base classes, and @var{type}
29643 has no base classes @var{base_type} for which
29644 @code{__is_empty (base_type)} is @code{false}.
29645 Requires: If @var{type} is a non-union class type, it shall be a complete type.
29646 @enddefbuiltin
29648 @defbuiltin{bool __is_enum (@var{type})}
29649 If @var{type} is a cv enumeration type ([basic.compound]) the trait is
29650 @code{true}, else it is @code{false}.
29651 @enddefbuiltin
29653 @defbuiltin{bool __is_final (@var{type})}
29654 If @var{type} is a class or union type marked @code{final}, then the trait
29655 is @code{true}, else it is @code{false}.
29656 Requires: If @var{type} is a class type, it shall be a complete type.
29657 @enddefbuiltin
29659 @defbuiltin{bool __is_literal_type (@var{type})}
29660 If @var{type} is a literal type ([basic.types]) the trait is
29661 @code{true}, else it is @code{false}.
29662 Requires: @var{type} shall be a complete type, (possibly cv-qualified)
29663 @code{void}, or an array of unknown bound.
29664 @enddefbuiltin
29666 @defbuiltin{bool __is_pod (@var{type})}
29667 If @var{type} is a cv POD type ([basic.types]) then the trait is @code{true},
29668 else it is @code{false}.
29669 Requires: @var{type} shall be a complete type, (possibly cv-qualified)
29670 @code{void}, or an array of unknown bound.
29671 @enddefbuiltin
29673 @defbuiltin{bool __is_polymorphic (@var{type})}
29674 If @var{type} is a polymorphic class ([class.virtual]) then the trait
29675 is @code{true}, else it is @code{false}.
29676 Requires: If @var{type} is a non-union class type, it shall be a complete type.
29677 @enddefbuiltin
29679 @defbuiltin{bool __is_standard_layout (@var{type})}
29680 If @var{type} is a standard-layout type ([basic.types]) the trait is
29681 @code{true}, else it is @code{false}.
29682 Requires: @var{type} shall be a complete type, an array of complete types,
29683 or (possibly cv-qualified) @code{void}.
29684 @enddefbuiltin
29686 @defbuiltin{bool __is_trivial (@var{type})}
29687 If @var{type} is a trivial type ([basic.types]) the trait is
29688 @code{true}, else it is @code{false}.
29689 Requires: @var{type} shall be a complete type, an array of complete types,
29690 or (possibly cv-qualified) @code{void}.
29691 @enddefbuiltin
29693 @defbuiltin{bool __is_union (@var{type})}
29694 If @var{type} is a cv union type ([basic.compound]) the trait is
29695 @code{true}, else it is @code{false}.
29696 @enddefbuiltin
29698 @defbuiltin{bool __underlying_type (@var{type})}
29699 The underlying type of @var{type}.
29700 Requires: @var{type} shall be an enumeration type ([dcl.enum]).
29701 @enddefbuiltin
29703 @defbuiltin{bool __integer_pack (@var{length})}
29704 When used as the pattern of a pack expansion within a template
29705 definition, expands to a template argument pack containing integers
29706 from @code{0} to @code{@var{length}-1}.  This is provided for
29707 efficient implementation of @code{std::make_integer_sequence}.
29708 @enddefbuiltin
29711 @node C++ Concepts
29712 @section C++ Concepts
29714 C++ concepts provide much-improved support for generic programming. In
29715 particular, they allow the specification of constraints on template arguments.
29716 The constraints are used to extend the usual overloading and partial
29717 specialization capabilities of the language, allowing generic data structures
29718 and algorithms to be ``refined'' based on their properties rather than their
29719 type names.
29721 The following keywords are reserved for concepts.
29723 @table @code
29724 @kindex assumes
29725 @item assumes
29726 States an expression as an assumption, and if possible, verifies that the
29727 assumption is valid. For example, @code{assume(n > 0)}.
29729 @kindex axiom
29730 @item axiom
29731 Introduces an axiom definition. Axioms introduce requirements on values.
29733 @kindex forall
29734 @item forall
29735 Introduces a universally quantified object in an axiom. For example,
29736 @code{forall (int n) n + 0 == n}.
29738 @kindex concept
29739 @item concept
29740 Introduces a concept definition. Concepts are sets of syntactic and semantic
29741 requirements on types and their values.
29743 @kindex requires
29744 @item requires
29745 Introduces constraints on template arguments or requirements for a member
29746 function of a class template.
29747 @end table
29749 The front end also exposes a number of internal mechanism that can be used
29750 to simplify the writing of type traits. Note that some of these traits are
29751 likely to be removed in the future.
29753 @defbuiltin{bool __is_same (@var{type1}, @var{type2})}
29754 A binary type trait: @code{true} whenever the @var{type1} and
29755 @var{type2} refer to the same type.
29756 @enddefbuiltin
29759 @node Deprecated Features
29760 @section Deprecated Features
29762 In the past, the GNU C++ compiler was extended to experiment with new
29763 features, at a time when the C++ language was still evolving.  Now that
29764 the C++ standard is complete, some of those features are superseded by
29765 superior alternatives.  Using the old features might cause a warning in
29766 some cases that the feature will be dropped in the future.  In other
29767 cases, the feature might be gone already.
29769 G++ allows a virtual function returning @samp{void *} to be overridden
29770 by one returning a different pointer type.  This extension to the
29771 covariant return type rules is now deprecated and will be removed from a
29772 future version.
29774 The use of default arguments in function pointers, function typedefs
29775 and other places where they are not permitted by the standard is
29776 deprecated and will be removed from a future version of G++.
29778 G++ allows floating-point literals to appear in integral constant expressions,
29779 e.g.@: @samp{ enum E @{ e = int(2.2 * 3.7) @} }
29780 This extension is deprecated and will be removed from a future version.
29782 G++ allows static data members of const floating-point type to be declared
29783 with an initializer in a class definition. The standard only allows
29784 initializers for static members of const integral types and const
29785 enumeration types so this extension has been deprecated and will be removed
29786 from a future version.
29788 G++ allows attributes to follow a parenthesized direct initializer,
29789 e.g.@: @samp{ int f (0) __attribute__ ((something)); } This extension
29790 has been ignored since G++ 3.3 and is deprecated.
29792 G++ allows anonymous structs and unions to have members that are not
29793 public non-static data members (i.e.@: fields).  These extensions are
29794 deprecated.
29796 @node Backwards Compatibility
29797 @section Backwards Compatibility
29798 @cindex Backwards Compatibility
29799 @cindex ARM [Annotated C++ Reference Manual]
29801 Now that there is a definitive ISO standard C++, G++ has a specification
29802 to adhere to.  The C++ language evolved over time, and features that
29803 used to be acceptable in previous drafts of the standard, such as the ARM
29804 [Annotated C++ Reference Manual], are no longer accepted.  In order to allow
29805 compilation of C++ written to such drafts, G++ contains some backwards
29806 compatibilities.  @emph{All such backwards compatibility features are
29807 liable to disappear in future versions of G++.} They should be considered
29808 deprecated.   @xref{Deprecated Features}.
29810 @table @code
29812 @item Implicit C language
29813 Old C system header files did not contain an @code{extern "C" @{@dots{}@}}
29814 scope to set the language.  On such systems, all system header files are
29815 implicitly scoped inside a C language scope.  Such headers must
29816 correctly prototype function argument types, there is no leeway for
29817 @code{()} to indicate an unspecified set of arguments.
29819 @end table
29821 @c  LocalWords:  emph deftypefn builtin ARCv2EM SIMD builtins msimd
29822 @c  LocalWords:  typedef v4si v8hi DMA dma vdiwr vdowr