gcc/ChangeLog:
[official-gcc.git] / gcc / doc / extend.texi
blob3889ecb543191650296884a2ae693091fa3312bf
1 c Copyright (C) 1988-2018 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 * Variable Length::     Arrays whose length is computed at run time.
46 * Variadic Macros::     Macros with a variable number of arguments.
47 * Escaped Newlines::    Slightly looser rules for escaped newlines.
48 * Subscripting::        Any array can be subscripted, even if not an lvalue.
49 * Pointer Arith::       Arithmetic on @code{void}-pointers and function pointers.
50 * Pointers to Arrays::  Pointers to arrays with qualifiers work as expected.
51 * Initializers::        Non-constant initializers.
52 * Compound Literals::   Compound literals give structures, unions
53                         or arrays as values.
54 * Designated Inits::    Labeling elements of initializers.
55 * Case Ranges::         `case 1 ... 9' and such.
56 * Cast to Union::       Casting to union type from any member of the union.
57 * Mixed Declarations::  Mixing declarations and code.
58 * Function Attributes:: Declaring that functions have no side effects,
59                         or that they can never return.
60 * Variable Attributes:: Specifying attributes of variables.
61 * Type Attributes::     Specifying attributes of types.
62 * Label Attributes::    Specifying attributes on labels.
63 * Enumerator Attributes:: Specifying attributes on enumerators.
64 * Statement Attributes:: Specifying attributes on statements.
65 * Attribute Syntax::    Formal syntax for attributes.
66 * Function Prototypes:: Prototype declarations and old-style definitions.
67 * C++ Comments::        C++ comments are recognized.
68 * Dollar Signs::        Dollar sign is allowed in identifiers.
69 * Character Escapes::   @samp{\e} stands for the character @key{ESC}.
70 * Alignment::           Determining the alignment of a function, type or variable.
71 * Inline::              Defining inline functions (as fast as macros).
72 * Volatiles::           What constitutes an access to a volatile object.
73 * Using Assembly Language with C:: Instructions and extensions for interfacing C with assembler.
74 * Alternate Keywords::  @code{__const__}, @code{__asm__}, etc., for header files.
75 * Incomplete Enums::    @code{enum foo;}, with details to follow.
76 * Function Names::      Printable strings which are the name of the current
77                         function.
78 * Return Address::      Getting the return or frame address of a function.
79 * Vector Extensions::   Using vector instructions through built-in functions.
80 * Offsetof::            Special syntax for implementing @code{offsetof}.
81 * __sync Builtins::     Legacy built-in functions for atomic memory access.
82 * __atomic Builtins::   Atomic built-in functions with memory model.
83 * Integer Overflow Builtins:: Built-in functions to perform arithmetics and
84                         arithmetic overflow checking.
85 * x86 specific memory model extensions for transactional memory:: x86 memory models.
86 * Object Size Checking:: Built-in functions for limited buffer overflow
87                         checking.
88 * Other Builtins::      Other built-in functions.
89 * Target Builtins::     Built-in functions specific to particular targets.
90 * Target Format Checks:: Format checks specific to particular targets.
91 * Pragmas::             Pragmas accepted by GCC.
92 * Unnamed Fields::      Unnamed struct/union fields within structs/unions.
93 * Thread-Local::        Per-thread variables.
94 * Binary constants::    Binary constants using the @samp{0b} prefix.
95 @end menu
97 @node Statement Exprs
98 @section Statements and Declarations in Expressions
99 @cindex statements inside expressions
100 @cindex declarations inside expressions
101 @cindex expressions containing statements
102 @cindex macros, statements in expressions
104 @c the above section title wrapped and causes an underfull hbox.. i
105 @c changed it from "within" to "in". --mew 4feb93
106 A compound statement enclosed in parentheses may appear as an expression
107 in GNU C@.  This allows you to use loops, switches, and local variables
108 within an expression.
110 Recall that a compound statement is a sequence of statements surrounded
111 by braces; in this construct, parentheses go around the braces.  For
112 example:
114 @smallexample
115 (@{ int y = foo (); int z;
116    if (y > 0) z = y;
117    else z = - y;
118    z; @})
119 @end smallexample
121 @noindent
122 is a valid (though slightly more complex than necessary) expression
123 for the absolute value of @code{foo ()}.
125 The last thing in the compound statement should be an expression
126 followed by a semicolon; the value of this subexpression serves as the
127 value of the entire construct.  (If you use some other kind of statement
128 last within the braces, the construct has type @code{void}, and thus
129 effectively no value.)
131 This feature is especially useful in making macro definitions ``safe'' (so
132 that they evaluate each operand exactly once).  For example, the
133 ``maximum'' function is commonly defined as a macro in standard C as
134 follows:
136 @smallexample
137 #define max(a,b) ((a) > (b) ? (a) : (b))
138 @end smallexample
140 @noindent
141 @cindex side effects, macro argument
142 But this definition computes either @var{a} or @var{b} twice, with bad
143 results if the operand has side effects.  In GNU C, if you know the
144 type of the operands (here taken as @code{int}), you can define
145 the macro safely as follows:
147 @smallexample
148 #define maxint(a,b) \
149   (@{int _a = (a), _b = (b); _a > _b ? _a : _b; @})
150 @end smallexample
152 Embedded statements are not allowed in constant expressions, such as
153 the value of an enumeration constant, the width of a bit-field, or
154 the initial value of a static variable.
156 If you don't know the type of the operand, you can still do this, but you
157 must use @code{typeof} or @code{__auto_type} (@pxref{Typeof}).
159 In G++, the result value of a statement expression undergoes array and
160 function pointer decay, and is returned by value to the enclosing
161 expression.  For instance, if @code{A} is a class, then
163 @smallexample
164         A a;
166         (@{a;@}).Foo ()
167 @end smallexample
169 @noindent
170 constructs a temporary @code{A} object to hold the result of the
171 statement expression, and that is used to invoke @code{Foo}.
172 Therefore the @code{this} pointer observed by @code{Foo} is not the
173 address of @code{a}.
175 In a statement expression, any temporaries created within a statement
176 are destroyed at that statement's end.  This makes statement
177 expressions inside macros slightly different from function calls.  In
178 the latter case temporaries introduced during argument evaluation are
179 destroyed at the end of the statement that includes the function
180 call.  In the statement expression case they are destroyed during
181 the statement expression.  For instance,
183 @smallexample
184 #define macro(a)  (@{__typeof__(a) b = (a); b + 3; @})
185 template<typename T> T function(T a) @{ T b = a; return b + 3; @}
187 void foo ()
189   macro (X ());
190   function (X ());
192 @end smallexample
194 @noindent
195 has different places where temporaries are destroyed.  For the
196 @code{macro} case, the temporary @code{X} is destroyed just after
197 the initialization of @code{b}.  In the @code{function} case that
198 temporary is destroyed when the function returns.
200 These considerations mean that it is probably a bad idea to use
201 statement expressions of this form in header files that are designed to
202 work with C++.  (Note that some versions of the GNU C Library contained
203 header files using statement expressions that lead to precisely this
204 bug.)
206 Jumping into a statement expression with @code{goto} or using a
207 @code{switch} statement outside the statement expression with a
208 @code{case} or @code{default} label inside the statement expression is
209 not permitted.  Jumping into a statement expression with a computed
210 @code{goto} (@pxref{Labels as Values}) has undefined behavior.
211 Jumping out of a statement expression is permitted, but if the
212 statement expression is part of a larger expression then it is
213 unspecified which other subexpressions of that expression have been
214 evaluated except where the language definition requires certain
215 subexpressions to be evaluated before or after the statement
216 expression.  In any case, as with a function call, the evaluation of a
217 statement expression is not interleaved with the evaluation of other
218 parts of the containing expression.  For example,
220 @smallexample
221   foo (), ((@{ bar1 (); goto a; 0; @}) + bar2 ()), baz();
222 @end smallexample
224 @noindent
225 calls @code{foo} and @code{bar1} and does not call @code{baz} but
226 may or may not call @code{bar2}.  If @code{bar2} is called, it is
227 called after @code{foo} and before @code{bar1}.
229 @node Local Labels
230 @section Locally Declared Labels
231 @cindex local labels
232 @cindex macros, local labels
234 GCC allows you to declare @dfn{local labels} in any nested block
235 scope.  A local label is just like an ordinary label, but you can
236 only reference it (with a @code{goto} statement, or by taking its
237 address) within the block in which it is declared.
239 A local label declaration looks like this:
241 @smallexample
242 __label__ @var{label};
243 @end smallexample
245 @noindent
248 @smallexample
249 __label__ @var{label1}, @var{label2}, /* @r{@dots{}} */;
250 @end smallexample
252 Local label declarations must come at the beginning of the block,
253 before any ordinary declarations or statements.
255 The label declaration defines the label @emph{name}, but does not define
256 the label itself.  You must do this in the usual way, with
257 @code{@var{label}:}, within the statements of the statement expression.
259 The local label feature is useful for complex macros.  If a macro
260 contains nested loops, a @code{goto} can be useful for breaking out of
261 them.  However, an ordinary label whose scope is the whole function
262 cannot be used: if the macro can be expanded several times in one
263 function, the label is multiply defined in that function.  A
264 local label avoids this problem.  For example:
266 @smallexample
267 #define SEARCH(value, array, target)              \
268 do @{                                              \
269   __label__ found;                                \
270   typeof (target) _SEARCH_target = (target);      \
271   typeof (*(array)) *_SEARCH_array = (array);     \
272   int i, j;                                       \
273   int value;                                      \
274   for (i = 0; i < max; i++)                       \
275     for (j = 0; j < max; j++)                     \
276       if (_SEARCH_array[i][j] == _SEARCH_target)  \
277         @{ (value) = i; goto found; @}              \
278   (value) = -1;                                   \
279  found:;                                          \
280 @} while (0)
281 @end smallexample
283 This could also be written using a statement expression:
285 @smallexample
286 #define SEARCH(array, target)                     \
287 (@{                                                \
288   __label__ found;                                \
289   typeof (target) _SEARCH_target = (target);      \
290   typeof (*(array)) *_SEARCH_array = (array);     \
291   int i, j;                                       \
292   int value;                                      \
293   for (i = 0; i < max; i++)                       \
294     for (j = 0; j < max; j++)                     \
295       if (_SEARCH_array[i][j] == _SEARCH_target)  \
296         @{ value = i; goto found; @}                \
297   value = -1;                                     \
298  found:                                           \
299   value;                                          \
301 @end smallexample
303 Local label declarations also make the labels they declare visible to
304 nested functions, if there are any.  @xref{Nested Functions}, for details.
306 @node Labels as Values
307 @section Labels as Values
308 @cindex labels as values
309 @cindex computed gotos
310 @cindex goto with computed label
311 @cindex address of a label
313 You can get the address of a label defined in the current function
314 (or a containing function) with the unary operator @samp{&&}.  The
315 value has type @code{void *}.  This value is a constant and can be used
316 wherever a constant of that type is valid.  For example:
318 @smallexample
319 void *ptr;
320 /* @r{@dots{}} */
321 ptr = &&foo;
322 @end smallexample
324 To use these values, you need to be able to jump to one.  This is done
325 with the computed goto statement@footnote{The analogous feature in
326 Fortran is called an assigned goto, but that name seems inappropriate in
327 C, where one can do more than simply store label addresses in label
328 variables.}, @code{goto *@var{exp};}.  For example,
330 @smallexample
331 goto *ptr;
332 @end smallexample
334 @noindent
335 Any expression of type @code{void *} is allowed.
337 One way of using these constants is in initializing a static array that
338 serves as a jump table:
340 @smallexample
341 static void *array[] = @{ &&foo, &&bar, &&hack @};
342 @end smallexample
344 @noindent
345 Then you can select a label with indexing, like this:
347 @smallexample
348 goto *array[i];
349 @end smallexample
351 @noindent
352 Note that this does not check whether the subscript is in bounds---array
353 indexing in C never does that.
355 Such an array of label values serves a purpose much like that of the
356 @code{switch} statement.  The @code{switch} statement is cleaner, so
357 use that rather than an array unless the problem does not fit a
358 @code{switch} statement very well.
360 Another use of label values is in an interpreter for threaded code.
361 The labels within the interpreter function can be stored in the
362 threaded code for super-fast dispatching.
364 You may not use this mechanism to jump to code in a different function.
365 If you do that, totally unpredictable things happen.  The best way to
366 avoid this is to store the label address only in automatic variables and
367 never pass it as an argument.
369 An alternate way to write the above example is
371 @smallexample
372 static const int array[] = @{ &&foo - &&foo, &&bar - &&foo,
373                              &&hack - &&foo @};
374 goto *(&&foo + array[i]);
375 @end smallexample
377 @noindent
378 This is more friendly to code living in shared libraries, as it reduces
379 the number of dynamic relocations that are needed, and by consequence,
380 allows the data to be read-only.
381 This alternative with label differences is not supported for the AVR target,
382 please use the first approach for AVR programs.
384 The @code{&&foo} expressions for the same label might have different
385 values if the containing function is inlined or cloned.  If a program
386 relies on them being always the same,
387 @code{__attribute__((__noinline__,__noclone__))} should be used to
388 prevent inlining and cloning.  If @code{&&foo} is used in a static
389 variable initializer, inlining and cloning is forbidden.
391 @node Nested Functions
392 @section Nested Functions
393 @cindex nested functions
394 @cindex downward funargs
395 @cindex thunks
397 A @dfn{nested function} is a function defined inside another function.
398 Nested functions are supported as an extension in GNU C, but are not
399 supported by GNU C++.
401 The nested function's name is local to the block where it is defined.
402 For example, here we define a nested function named @code{square}, and
403 call it twice:
405 @smallexample
406 @group
407 foo (double a, double b)
409   double square (double z) @{ return z * z; @}
411   return square (a) + square (b);
413 @end group
414 @end smallexample
416 The nested function can access all the variables of the containing
417 function that are visible at the point of its definition.  This is
418 called @dfn{lexical scoping}.  For example, here we show a nested
419 function which uses an inherited variable named @code{offset}:
421 @smallexample
422 @group
423 bar (int *array, int offset, int size)
425   int access (int *array, int index)
426     @{ return array[index + offset]; @}
427   int i;
428   /* @r{@dots{}} */
429   for (i = 0; i < size; i++)
430     /* @r{@dots{}} */ access (array, i) /* @r{@dots{}} */
432 @end group
433 @end smallexample
435 Nested function definitions are permitted within functions in the places
436 where variable definitions are allowed; that is, in any block, mixed
437 with the other declarations and statements in the block.
439 It is possible to call the nested function from outside the scope of its
440 name by storing its address or passing the address to another function:
442 @smallexample
443 hack (int *array, int size)
445   void store (int index, int value)
446     @{ array[index] = value; @}
448   intermediate (store, size);
450 @end smallexample
452 Here, the function @code{intermediate} receives the address of
453 @code{store} as an argument.  If @code{intermediate} calls @code{store},
454 the arguments given to @code{store} are used to store into @code{array}.
455 But this technique works only so long as the containing function
456 (@code{hack}, in this example) does not exit.
458 If you try to call the nested function through its address after the
459 containing function exits, all hell breaks loose.  If you try
460 to call it after a containing scope level exits, and if it refers
461 to some of the variables that are no longer in scope, you may be lucky,
462 but it's not wise to take the risk.  If, however, the nested function
463 does not refer to anything that has gone out of scope, you should be
464 safe.
466 GCC implements taking the address of a nested function using a technique
467 called @dfn{trampolines}.  This technique was described in
468 @cite{Lexical Closures for C++} (Thomas M. Breuel, USENIX
469 C++ Conference Proceedings, October 17-21, 1988).
471 A nested function can jump to a label inherited from a containing
472 function, provided the label is explicitly declared in the containing
473 function (@pxref{Local Labels}).  Such a jump returns instantly to the
474 containing function, exiting the nested function that did the
475 @code{goto} and any intermediate functions as well.  Here is an example:
477 @smallexample
478 @group
479 bar (int *array, int offset, int size)
481   __label__ failure;
482   int access (int *array, int index)
483     @{
484       if (index > size)
485         goto failure;
486       return array[index + offset];
487     @}
488   int i;
489   /* @r{@dots{}} */
490   for (i = 0; i < size; i++)
491     /* @r{@dots{}} */ access (array, i) /* @r{@dots{}} */
492   /* @r{@dots{}} */
493   return 0;
495  /* @r{Control comes here from @code{access}
496     if it detects an error.}  */
497  failure:
498   return -1;
500 @end group
501 @end smallexample
503 A nested function always has no linkage.  Declaring one with
504 @code{extern} or @code{static} is erroneous.  If you need to declare the nested function
505 before its definition, use @code{auto} (which is otherwise meaningless
506 for function declarations).
508 @smallexample
509 bar (int *array, int offset, int size)
511   __label__ failure;
512   auto int access (int *, int);
513   /* @r{@dots{}} */
514   int access (int *array, int index)
515     @{
516       if (index > size)
517         goto failure;
518       return array[index + offset];
519     @}
520   /* @r{@dots{}} */
522 @end smallexample
524 @node Nonlocal Gotos
525 @section Nonlocal Gotos
526 @cindex nonlocal gotos
528 GCC provides the built-in functions @code{__builtin_setjmp} and
529 @code{__builtin_longjmp} which are similar to, but not interchangeable
530 with, the C library functions @code{setjmp} and @code{longjmp}.  
531 The built-in versions are used internally by GCC's libraries
532 to implement exception handling on some targets.  You should use the 
533 standard C library functions declared in @code{<setjmp.h>} in user code
534 instead of the builtins.
536 The built-in versions of these functions use GCC's normal
537 mechanisms to save and restore registers using the stack on function
538 entry and exit.  The jump buffer argument @var{buf} holds only the
539 information needed to restore the stack frame, rather than the entire 
540 set of saved register values.  
542 An important caveat is that GCC arranges to save and restore only
543 those registers known to the specific architecture variant being
544 compiled for.  This can make @code{__builtin_setjmp} and
545 @code{__builtin_longjmp} more efficient than their library
546 counterparts in some cases, but it can also cause incorrect and
547 mysterious behavior when mixing with code that uses the full register
548 set.
550 You should declare the jump buffer argument @var{buf} to the
551 built-in functions as:
553 @smallexample
554 #include <stdint.h>
555 intptr_t @var{buf}[5];
556 @end smallexample
558 @deftypefn {Built-in Function} {int} __builtin_setjmp (intptr_t *@var{buf})
559 This function saves the current stack context in @var{buf}.  
560 @code{__builtin_setjmp} returns 0 when returning directly,
561 and 1 when returning from @code{__builtin_longjmp} using the same
562 @var{buf}.
563 @end deftypefn
565 @deftypefn {Built-in Function} {void} __builtin_longjmp (intptr_t *@var{buf}, int @var{val})
566 This function restores the stack context in @var{buf}, 
567 saved by a previous call to @code{__builtin_setjmp}.  After
568 @code{__builtin_longjmp} is finished, the program resumes execution as
569 if the matching @code{__builtin_setjmp} returns the value @var{val},
570 which must be 1.
572 Because @code{__builtin_longjmp} depends on the function return
573 mechanism to restore the stack context, it cannot be called
574 from the same function calling @code{__builtin_setjmp} to
575 initialize @var{buf}.  It can only be called from a function called
576 (directly or indirectly) from the function calling @code{__builtin_setjmp}.
577 @end deftypefn
579 @node Constructing Calls
580 @section Constructing Function Calls
581 @cindex constructing calls
582 @cindex forwarding calls
584 Using the built-in functions described below, you can record
585 the arguments a function received, and call another function
586 with the same arguments, without knowing the number or types
587 of the arguments.
589 You can also record the return value of that function call,
590 and later return that value, without knowing what data type
591 the function tried to return (as long as your caller expects
592 that data type).
594 However, these built-in functions may interact badly with some
595 sophisticated features or other extensions of the language.  It
596 is, therefore, not recommended to use them outside very simple
597 functions acting as mere forwarders for their arguments.
599 @deftypefn {Built-in Function} {void *} __builtin_apply_args ()
600 This built-in function returns a pointer to data
601 describing how to perform a call with the same arguments as are passed
602 to the current function.
604 The function saves the arg pointer register, structure value address,
605 and all registers that might be used to pass arguments to a function
606 into a block of memory allocated on the stack.  Then it returns the
607 address of that block.
608 @end deftypefn
610 @deftypefn {Built-in Function} {void *} __builtin_apply (void (*@var{function})(), void *@var{arguments}, size_t @var{size})
611 This built-in function invokes @var{function}
612 with a copy of the parameters described by @var{arguments}
613 and @var{size}.
615 The value of @var{arguments} should be the value returned by
616 @code{__builtin_apply_args}.  The argument @var{size} specifies the size
617 of the stack argument data, in bytes.
619 This function returns a pointer to data describing
620 how to return whatever value is returned by @var{function}.  The data
621 is saved in a block of memory allocated on the stack.
623 It is not always simple to compute the proper value for @var{size}.  The
624 value is used by @code{__builtin_apply} to compute the amount of data
625 that should be pushed on the stack and copied from the incoming argument
626 area.
627 @end deftypefn
629 @deftypefn {Built-in Function} {void} __builtin_return (void *@var{result})
630 This built-in function returns the value described by @var{result} from
631 the containing function.  You should specify, for @var{result}, a value
632 returned by @code{__builtin_apply}.
633 @end deftypefn
635 @deftypefn {Built-in Function} {} __builtin_va_arg_pack ()
636 This built-in function represents all anonymous arguments of an inline
637 function.  It can be used only in inline functions that are always
638 inlined, never compiled as a separate function, such as those using
639 @code{__attribute__ ((__always_inline__))} or
640 @code{__attribute__ ((__gnu_inline__))} extern inline functions.
641 It must be only passed as last argument to some other function
642 with variable arguments.  This is useful for writing small wrapper
643 inlines for variable argument functions, when using preprocessor
644 macros is undesirable.  For example:
645 @smallexample
646 extern int myprintf (FILE *f, const char *format, ...);
647 extern inline __attribute__ ((__gnu_inline__)) int
648 myprintf (FILE *f, const char *format, ...)
650   int r = fprintf (f, "myprintf: ");
651   if (r < 0)
652     return r;
653   int s = fprintf (f, format, __builtin_va_arg_pack ());
654   if (s < 0)
655     return s;
656   return r + s;
658 @end smallexample
659 @end deftypefn
661 @deftypefn {Built-in Function} {size_t} __builtin_va_arg_pack_len ()
662 This built-in function returns the number of anonymous arguments of
663 an inline function.  It can be used only in inline functions that
664 are always inlined, never compiled as a separate function, such
665 as those using @code{__attribute__ ((__always_inline__))} or
666 @code{__attribute__ ((__gnu_inline__))} extern inline functions.
667 For example following does link- or run-time checking of open
668 arguments for optimized code:
669 @smallexample
670 #ifdef __OPTIMIZE__
671 extern inline __attribute__((__gnu_inline__)) int
672 myopen (const char *path, int oflag, ...)
674   if (__builtin_va_arg_pack_len () > 1)
675     warn_open_too_many_arguments ();
677   if (__builtin_constant_p (oflag))
678     @{
679       if ((oflag & O_CREAT) != 0 && __builtin_va_arg_pack_len () < 1)
680         @{
681           warn_open_missing_mode ();
682           return __open_2 (path, oflag);
683         @}
684       return open (path, oflag, __builtin_va_arg_pack ());
685     @}
687   if (__builtin_va_arg_pack_len () < 1)
688     return __open_2 (path, oflag);
690   return open (path, oflag, __builtin_va_arg_pack ());
692 #endif
693 @end smallexample
694 @end deftypefn
696 @node Typeof
697 @section Referring to a Type with @code{typeof}
698 @findex typeof
699 @findex sizeof
700 @cindex macros, types of arguments
702 Another way to refer to the type of an expression is with @code{typeof}.
703 The syntax of using of this keyword looks like @code{sizeof}, but the
704 construct acts semantically like a type name defined with @code{typedef}.
706 There are two ways of writing the argument to @code{typeof}: with an
707 expression or with a type.  Here is an example with an expression:
709 @smallexample
710 typeof (x[0](1))
711 @end smallexample
713 @noindent
714 This assumes that @code{x} is an array of pointers to functions;
715 the type described is that of the values of the functions.
717 Here is an example with a typename as the argument:
719 @smallexample
720 typeof (int *)
721 @end smallexample
723 @noindent
724 Here the type described is that of pointers to @code{int}.
726 If you are writing a header file that must work when included in ISO C
727 programs, write @code{__typeof__} instead of @code{typeof}.
728 @xref{Alternate Keywords}.
730 A @code{typeof} construct can be used anywhere a typedef name can be
731 used.  For example, you can use it in a declaration, in a cast, or inside
732 of @code{sizeof} or @code{typeof}.
734 The operand of @code{typeof} is evaluated for its side effects if and
735 only if it is an expression of variably modified type or the name of
736 such a type.
738 @code{typeof} is often useful in conjunction with
739 statement expressions (@pxref{Statement Exprs}).
740 Here is how the two together can
741 be used to define a safe ``maximum'' macro which operates on any
742 arithmetic type and evaluates each of its arguments exactly once:
744 @smallexample
745 #define max(a,b) \
746   (@{ typeof (a) _a = (a); \
747       typeof (b) _b = (b); \
748     _a > _b ? _a : _b; @})
749 @end smallexample
751 @cindex underscores in variables in macros
752 @cindex @samp{_} in variables in macros
753 @cindex local variables in macros
754 @cindex variables, local, in macros
755 @cindex macros, local variables in
757 The reason for using names that start with underscores for the local
758 variables is to avoid conflicts with variable names that occur within the
759 expressions that are substituted for @code{a} and @code{b}.  Eventually we
760 hope to design a new form of declaration syntax that allows you to declare
761 variables whose scopes start only after their initializers; this will be a
762 more reliable way to prevent such conflicts.
764 @noindent
765 Some more examples of the use of @code{typeof}:
767 @itemize @bullet
768 @item
769 This declares @code{y} with the type of what @code{x} points to.
771 @smallexample
772 typeof (*x) y;
773 @end smallexample
775 @item
776 This declares @code{y} as an array of such values.
778 @smallexample
779 typeof (*x) y[4];
780 @end smallexample
782 @item
783 This declares @code{y} as an array of pointers to characters:
785 @smallexample
786 typeof (typeof (char *)[4]) y;
787 @end smallexample
789 @noindent
790 It is equivalent to the following traditional C declaration:
792 @smallexample
793 char *y[4];
794 @end smallexample
796 To see the meaning of the declaration using @code{typeof}, and why it
797 might be a useful way to write, rewrite it with these macros:
799 @smallexample
800 #define pointer(T)  typeof(T *)
801 #define array(T, N) typeof(T [N])
802 @end smallexample
804 @noindent
805 Now the declaration can be rewritten this way:
807 @smallexample
808 array (pointer (char), 4) y;
809 @end smallexample
811 @noindent
812 Thus, @code{array (pointer (char), 4)} is the type of arrays of 4
813 pointers to @code{char}.
814 @end itemize
816 In GNU C, but not GNU C++, you may also declare the type of a variable
817 as @code{__auto_type}.  In that case, the declaration must declare
818 only one variable, whose declarator must just be an identifier, the
819 declaration must be initialized, and the type of the variable is
820 determined by the initializer; the name of the variable is not in
821 scope until after the initializer.  (In C++, you should use C++11
822 @code{auto} for this purpose.)  Using @code{__auto_type}, the
823 ``maximum'' macro above could be written as:
825 @smallexample
826 #define max(a,b) \
827   (@{ __auto_type _a = (a); \
828       __auto_type _b = (b); \
829     _a > _b ? _a : _b; @})
830 @end smallexample
832 Using @code{__auto_type} instead of @code{typeof} has two advantages:
834 @itemize @bullet
835 @item Each argument to the macro appears only once in the expansion of
836 the macro.  This prevents the size of the macro expansion growing
837 exponentially when calls to such macros are nested inside arguments of
838 such macros.
840 @item If the argument to the macro has variably modified type, it is
841 evaluated only once when using @code{__auto_type}, but twice if
842 @code{typeof} is used.
843 @end itemize
845 @node Conditionals
846 @section Conditionals with Omitted Operands
847 @cindex conditional expressions, extensions
848 @cindex omitted middle-operands
849 @cindex middle-operands, omitted
850 @cindex extensions, @code{?:}
851 @cindex @code{?:} extensions
853 The middle operand in a conditional expression may be omitted.  Then
854 if the first operand is nonzero, its value is the value of the conditional
855 expression.
857 Therefore, the expression
859 @smallexample
860 x ? : y
861 @end smallexample
863 @noindent
864 has the value of @code{x} if that is nonzero; otherwise, the value of
865 @code{y}.
867 This example is perfectly equivalent to
869 @smallexample
870 x ? x : y
871 @end smallexample
873 @cindex side effect in @code{?:}
874 @cindex @code{?:} side effect
875 @noindent
876 In this simple case, the ability to omit the middle operand is not
877 especially useful.  When it becomes useful is when the first operand does,
878 or may (if it is a macro argument), contain a side effect.  Then repeating
879 the operand in the middle would perform the side effect twice.  Omitting
880 the middle operand uses the value already computed without the undesirable
881 effects of recomputing it.
883 @node __int128
884 @section 128-bit Integers
885 @cindex @code{__int128} data types
887 As an extension the integer scalar type @code{__int128} is supported for
888 targets which have an integer mode wide enough to hold 128 bits.
889 Simply write @code{__int128} for a signed 128-bit integer, or
890 @code{unsigned __int128} for an unsigned 128-bit integer.  There is no
891 support in GCC for expressing an integer constant of type @code{__int128}
892 for targets with @code{long long} integer less than 128 bits wide.
894 @node Long Long
895 @section Double-Word Integers
896 @cindex @code{long long} data types
897 @cindex double-word arithmetic
898 @cindex multiprecision arithmetic
899 @cindex @code{LL} integer suffix
900 @cindex @code{ULL} integer suffix
902 ISO C99 and ISO C++11 support data types for integers that are at least
903 64 bits wide, and as an extension GCC supports them in C90 and C++98 modes.
904 Simply write @code{long long int} for a signed integer, or
905 @code{unsigned long long int} for an unsigned integer.  To make an
906 integer constant of type @code{long long int}, add the suffix @samp{LL}
907 to the integer.  To make an integer constant of type @code{unsigned long
908 long int}, add the suffix @samp{ULL} to the integer.
910 You can use these types in arithmetic like any other integer types.
911 Addition, subtraction, and bitwise boolean operations on these types
912 are open-coded on all types of machines.  Multiplication is open-coded
913 if the machine supports a fullword-to-doubleword widening multiply
914 instruction.  Division and shifts are open-coded only on machines that
915 provide special support.  The operations that are not open-coded use
916 special library routines that come with GCC@.
918 There may be pitfalls when you use @code{long long} types for function
919 arguments without function prototypes.  If a function
920 expects type @code{int} for its argument, and you pass a value of type
921 @code{long long int}, confusion results because the caller and the
922 subroutine disagree about the number of bytes for the argument.
923 Likewise, if the function expects @code{long long int} and you pass
924 @code{int}.  The best way to avoid such problems is to use prototypes.
926 @node Complex
927 @section Complex Numbers
928 @cindex complex numbers
929 @cindex @code{_Complex} keyword
930 @cindex @code{__complex__} keyword
932 ISO C99 supports complex floating data types, and as an extension GCC
933 supports them in C90 mode and in C++.  GCC also supports complex integer data
934 types which are not part of ISO C99.  You can declare complex types
935 using the keyword @code{_Complex}.  As an extension, the older GNU
936 keyword @code{__complex__} is also supported.
938 For example, @samp{_Complex double x;} declares @code{x} as a
939 variable whose real part and imaginary part are both of type
940 @code{double}.  @samp{_Complex short int y;} declares @code{y} to
941 have real and imaginary parts of type @code{short int}; this is not
942 likely to be useful, but it shows that the set of complex types is
943 complete.
945 To write a constant with a complex data type, use the suffix @samp{i} or
946 @samp{j} (either one; they are equivalent).  For example, @code{2.5fi}
947 has type @code{_Complex float} and @code{3i} has type
948 @code{_Complex int}.  Such a constant always has a pure imaginary
949 value, but you can form any complex value you like by adding one to a
950 real constant.  This is a GNU extension; if you have an ISO C99
951 conforming C library (such as the GNU C Library), and want to construct complex
952 constants of floating type, you should include @code{<complex.h>} and
953 use the macros @code{I} or @code{_Complex_I} instead.
955 The ISO C++14 library also defines the @samp{i} suffix, so C++14 code
956 that includes the @samp{<complex>} header cannot use @samp{i} for the
957 GNU extension.  The @samp{j} suffix still has the GNU meaning.
959 @cindex @code{__real__} keyword
960 @cindex @code{__imag__} keyword
961 To extract the real part of a complex-valued expression @var{exp}, write
962 @code{__real__ @var{exp}}.  Likewise, use @code{__imag__} to
963 extract the imaginary part.  This is a GNU extension; for values of
964 floating type, you should use the ISO C99 functions @code{crealf},
965 @code{creal}, @code{creall}, @code{cimagf}, @code{cimag} and
966 @code{cimagl}, declared in @code{<complex.h>} and also provided as
967 built-in functions by GCC@.
969 @cindex complex conjugation
970 The operator @samp{~} performs complex conjugation when used on a value
971 with a complex type.  This is a GNU extension; for values of
972 floating type, you should use the ISO C99 functions @code{conjf},
973 @code{conj} and @code{conjl}, declared in @code{<complex.h>} and also
974 provided as built-in functions by GCC@.
976 GCC can allocate complex automatic variables in a noncontiguous
977 fashion; it's even possible for the real part to be in a register while
978 the imaginary part is on the stack (or vice versa).  Only the DWARF
979 debug info format can represent this, so use of DWARF is recommended.
980 If you are using the stabs debug info format, GCC describes a noncontiguous
981 complex variable as if it were two separate variables of noncomplex type.
982 If the variable's actual name is @code{foo}, the two fictitious
983 variables are named @code{foo$real} and @code{foo$imag}.  You can
984 examine and set these two fictitious variables with your debugger.
986 @node Floating Types
987 @section Additional Floating Types
988 @cindex additional floating types
989 @cindex @code{_Float@var{n}} data types
990 @cindex @code{_Float@var{n}x} data types
991 @cindex @code{__float80} data type
992 @cindex @code{__float128} data type
993 @cindex @code{__ibm128} data type
994 @cindex @code{w} floating point suffix
995 @cindex @code{q} floating point suffix
996 @cindex @code{W} floating point suffix
997 @cindex @code{Q} floating point suffix
999 ISO/IEC TS 18661-3:2015 defines C support for additional floating
1000 types @code{_Float@var{n}} and @code{_Float@var{n}x}, and GCC supports
1001 these type names; the set of types supported depends on the target
1002 architecture.  These types are not supported when compiling C++.
1003 Constants with these types use suffixes @code{f@var{n}} or
1004 @code{F@var{n}} and @code{f@var{n}x} or @code{F@var{n}x}.  These type
1005 names can be used together with @code{_Complex} to declare complex
1006 types.
1008 As an extension, GNU C and GNU C++ support additional floating
1009 types, which are not supported by all targets.
1010 @itemize @bullet
1011 @item @code{__float128} is available on i386, x86_64, IA-64, and
1012 hppa HP-UX, as well as on PowerPC GNU/Linux targets that enable
1013 the vector scalar (VSX) instruction set.  @code{__float128} supports
1014 the 128-bit floating type.  On i386, x86_64, PowerPC, and IA-64
1015 other than HP-UX, @code{__float128} is an alias for @code{_Float128}.
1016 On hppa and IA-64 HP-UX, @code{__float128} is an alias for @code{long
1017 double}.
1019 @item @code{__float80} is available on the i386, x86_64, and IA-64
1020 targets, and supports the 80-bit (@code{XFmode}) floating type.  It is
1021 an alias for the type name @code{_Float64x} on these targets.
1023 @item @code{__ibm128} is available on PowerPC targets, and provides
1024 access to the IBM extended double format which is the current format
1025 used for @code{long double}.  When @code{long double} transitions to
1026 @code{__float128} on PowerPC in the future, @code{__ibm128} will remain
1027 for use in conversions between the two types.
1028 @end itemize
1030 Support for these additional types includes the arithmetic operators:
1031 add, subtract, multiply, divide; unary arithmetic operators;
1032 relational operators; equality operators; and conversions to and from
1033 integer and other floating types.  Use a suffix @samp{w} or @samp{W}
1034 in a literal constant of type @code{__float80} or type
1035 @code{__ibm128}.  Use a suffix @samp{q} or @samp{Q} for @code{_float128}.
1037 In order to use @code{_Float128}, @code{__float128}, and @code{__ibm128}
1038 on PowerPC Linux systems, you must use the @option{-mfloat128} option. It is
1039 expected in future versions of GCC that @code{_Float128} and @code{__float128}
1040 will be enabled automatically.
1042 The @code{_Float128} type is supported on all systems where
1043 @code{__float128} is supported or where @code{long double} has the
1044 IEEE binary128 format.  The @code{_Float64x} type is supported on all
1045 systems where @code{__float128} is supported.  The @code{_Float32}
1046 type is supported on all systems supporting IEEE binary32; the
1047 @code{_Float64} and @code{_Float32x} types are supported on all systems
1048 supporting IEEE binary64.  The @code{_Float16} type is supported on AArch64
1049 systems by default, and on ARM systems when the IEEE format for 16-bit
1050 floating-point types is selected with @option{-mfp16-format=ieee}.
1051 GCC does not currently support @code{_Float128x} on any systems.
1053 On the i386, x86_64, IA-64, and HP-UX targets, you can declare complex
1054 types using the corresponding internal complex type, @code{XCmode} for
1055 @code{__float80} type and @code{TCmode} for @code{__float128} type:
1057 @smallexample
1058 typedef _Complex float __attribute__((mode(TC))) _Complex128;
1059 typedef _Complex float __attribute__((mode(XC))) _Complex80;
1060 @end smallexample
1062 On the PowerPC Linux VSX targets, you can declare complex types using
1063 the corresponding internal complex type, @code{KCmode} for
1064 @code{__float128} type and @code{ICmode} for @code{__ibm128} type:
1066 @smallexample
1067 typedef _Complex float __attribute__((mode(KC))) _Complex_float128;
1068 typedef _Complex float __attribute__((mode(IC))) _Complex_ibm128;
1069 @end smallexample
1071 @node Half-Precision
1072 @section Half-Precision Floating Point
1073 @cindex half-precision floating point
1074 @cindex @code{__fp16} data type
1076 On ARM and AArch64 targets, GCC supports half-precision (16-bit) floating
1077 point via the @code{__fp16} type defined in the ARM C Language Extensions.
1078 On ARM systems, you must enable this type explicitly with the
1079 @option{-mfp16-format} command-line option in order to use it.
1081 ARM targets support two incompatible representations for half-precision
1082 floating-point values.  You must choose one of the representations and
1083 use it consistently in your program.
1085 Specifying @option{-mfp16-format=ieee} selects the IEEE 754-2008 format.
1086 This format can represent normalized values in the range of @math{2^{-14}} to 65504.
1087 There are 11 bits of significand precision, approximately 3
1088 decimal digits.
1090 Specifying @option{-mfp16-format=alternative} selects the ARM
1091 alternative format.  This representation is similar to the IEEE
1092 format, but does not support infinities or NaNs.  Instead, the range
1093 of exponents is extended, so that this format can represent normalized
1094 values in the range of @math{2^{-14}} to 131008.
1096 The GCC port for AArch64 only supports the IEEE 754-2008 format, and does
1097 not require use of the @option{-mfp16-format} command-line option.
1099 The @code{__fp16} type may only be used as an argument to intrinsics defined
1100 in @code{<arm_fp16.h>}, or as a storage format.  For purposes of
1101 arithmetic and other operations, @code{__fp16} values in C or C++
1102 expressions are automatically promoted to @code{float}.
1104 The ARM target provides hardware support for conversions between
1105 @code{__fp16} and @code{float} values
1106 as an extension to VFP and NEON (Advanced SIMD), and from ARMv8-A provides
1107 hardware support for conversions between @code{__fp16} and @code{double}
1108 values.  GCC generates code using these hardware instructions if you
1109 compile with options to select an FPU that provides them;
1110 for example, @option{-mfpu=neon-fp16 -mfloat-abi=softfp},
1111 in addition to the @option{-mfp16-format} option to select
1112 a half-precision format.
1114 Language-level support for the @code{__fp16} data type is
1115 independent of whether GCC generates code using hardware floating-point
1116 instructions.  In cases where hardware support is not specified, GCC
1117 implements conversions between @code{__fp16} and other types as library
1118 calls.
1120 It is recommended that portable code use the @code{_Float16} type defined
1121 by ISO/IEC TS 18661-3:2015.  @xref{Floating Types}.
1123 @node Decimal Float
1124 @section Decimal Floating Types
1125 @cindex decimal floating types
1126 @cindex @code{_Decimal32} data type
1127 @cindex @code{_Decimal64} data type
1128 @cindex @code{_Decimal128} data type
1129 @cindex @code{df} integer suffix
1130 @cindex @code{dd} integer suffix
1131 @cindex @code{dl} integer suffix
1132 @cindex @code{DF} integer suffix
1133 @cindex @code{DD} integer suffix
1134 @cindex @code{DL} integer suffix
1136 As an extension, GNU C supports decimal floating types as
1137 defined in the N1312 draft of ISO/IEC WDTR24732.  Support for decimal
1138 floating types in GCC will evolve as the draft technical report changes.
1139 Calling conventions for any target might also change.  Not all targets
1140 support decimal floating types.
1142 The decimal floating types are @code{_Decimal32}, @code{_Decimal64}, and
1143 @code{_Decimal128}.  They use a radix of ten, unlike the floating types
1144 @code{float}, @code{double}, and @code{long double} whose radix is not
1145 specified by the C standard but is usually two.
1147 Support for decimal floating types includes the arithmetic operators
1148 add, subtract, multiply, divide; unary arithmetic operators;
1149 relational operators; equality operators; and conversions to and from
1150 integer and other floating types.  Use a suffix @samp{df} or
1151 @samp{DF} in a literal constant of type @code{_Decimal32}, @samp{dd}
1152 or @samp{DD} for @code{_Decimal64}, and @samp{dl} or @samp{DL} for
1153 @code{_Decimal128}.
1155 GCC support of decimal float as specified by the draft technical report
1156 is incomplete:
1158 @itemize @bullet
1159 @item
1160 When the value of a decimal floating type cannot be represented in the
1161 integer type to which it is being converted, the result is undefined
1162 rather than the result value specified by the draft technical report.
1164 @item
1165 GCC does not provide the C library functionality associated with
1166 @file{math.h}, @file{fenv.h}, @file{stdio.h}, @file{stdlib.h}, and
1167 @file{wchar.h}, which must come from a separate C library implementation.
1168 Because of this the GNU C compiler does not define macro
1169 @code{__STDC_DEC_FP__} to indicate that the implementation conforms to
1170 the technical report.
1171 @end itemize
1173 Types @code{_Decimal32}, @code{_Decimal64}, and @code{_Decimal128}
1174 are supported by the DWARF debug information format.
1176 @node Hex Floats
1177 @section Hex Floats
1178 @cindex hex floats
1180 ISO C99 and ISO C++17 support floating-point numbers written not only in
1181 the usual decimal notation, such as @code{1.55e1}, but also numbers such as
1182 @code{0x1.fp3} written in hexadecimal format.  As a GNU extension, GCC
1183 supports this in C90 mode (except in some cases when strictly
1184 conforming) and in C++98, C++11 and C++14 modes.  In that format the
1185 @samp{0x} hex introducer and the @samp{p} or @samp{P} exponent field are
1186 mandatory.  The exponent is a decimal number that indicates the power of
1187 2 by which the significant part is multiplied.  Thus @samp{0x1.f} is
1188 @tex
1189 $1 {15\over16}$,
1190 @end tex
1191 @ifnottex
1192 1 15/16,
1193 @end ifnottex
1194 @samp{p3} multiplies it by 8, and the value of @code{0x1.fp3}
1195 is the same as @code{1.55e1}.
1197 Unlike for floating-point numbers in the decimal notation the exponent
1198 is always required in the hexadecimal notation.  Otherwise the compiler
1199 would not be able to resolve the ambiguity of, e.g., @code{0x1.f}.  This
1200 could mean @code{1.0f} or @code{1.9375} since @samp{f} is also the
1201 extension for floating-point constants of type @code{float}.
1203 @node Fixed-Point
1204 @section Fixed-Point Types
1205 @cindex fixed-point types
1206 @cindex @code{_Fract} data type
1207 @cindex @code{_Accum} data type
1208 @cindex @code{_Sat} data type
1209 @cindex @code{hr} fixed-suffix
1210 @cindex @code{r} fixed-suffix
1211 @cindex @code{lr} fixed-suffix
1212 @cindex @code{llr} fixed-suffix
1213 @cindex @code{uhr} fixed-suffix
1214 @cindex @code{ur} fixed-suffix
1215 @cindex @code{ulr} fixed-suffix
1216 @cindex @code{ullr} fixed-suffix
1217 @cindex @code{hk} fixed-suffix
1218 @cindex @code{k} fixed-suffix
1219 @cindex @code{lk} fixed-suffix
1220 @cindex @code{llk} fixed-suffix
1221 @cindex @code{uhk} fixed-suffix
1222 @cindex @code{uk} fixed-suffix
1223 @cindex @code{ulk} fixed-suffix
1224 @cindex @code{ullk} fixed-suffix
1225 @cindex @code{HR} fixed-suffix
1226 @cindex @code{R} fixed-suffix
1227 @cindex @code{LR} fixed-suffix
1228 @cindex @code{LLR} fixed-suffix
1229 @cindex @code{UHR} fixed-suffix
1230 @cindex @code{UR} fixed-suffix
1231 @cindex @code{ULR} fixed-suffix
1232 @cindex @code{ULLR} fixed-suffix
1233 @cindex @code{HK} fixed-suffix
1234 @cindex @code{K} fixed-suffix
1235 @cindex @code{LK} fixed-suffix
1236 @cindex @code{LLK} fixed-suffix
1237 @cindex @code{UHK} fixed-suffix
1238 @cindex @code{UK} fixed-suffix
1239 @cindex @code{ULK} fixed-suffix
1240 @cindex @code{ULLK} fixed-suffix
1242 As an extension, GNU C supports fixed-point types as
1243 defined in the N1169 draft of ISO/IEC DTR 18037.  Support for fixed-point
1244 types in GCC will evolve as the draft technical report changes.
1245 Calling conventions for any target might also change.  Not all targets
1246 support fixed-point types.
1248 The fixed-point types are
1249 @code{short _Fract},
1250 @code{_Fract},
1251 @code{long _Fract},
1252 @code{long long _Fract},
1253 @code{unsigned short _Fract},
1254 @code{unsigned _Fract},
1255 @code{unsigned long _Fract},
1256 @code{unsigned long long _Fract},
1257 @code{_Sat short _Fract},
1258 @code{_Sat _Fract},
1259 @code{_Sat long _Fract},
1260 @code{_Sat long long _Fract},
1261 @code{_Sat unsigned short _Fract},
1262 @code{_Sat unsigned _Fract},
1263 @code{_Sat unsigned long _Fract},
1264 @code{_Sat unsigned long long _Fract},
1265 @code{short _Accum},
1266 @code{_Accum},
1267 @code{long _Accum},
1268 @code{long long _Accum},
1269 @code{unsigned short _Accum},
1270 @code{unsigned _Accum},
1271 @code{unsigned long _Accum},
1272 @code{unsigned long long _Accum},
1273 @code{_Sat short _Accum},
1274 @code{_Sat _Accum},
1275 @code{_Sat long _Accum},
1276 @code{_Sat long long _Accum},
1277 @code{_Sat unsigned short _Accum},
1278 @code{_Sat unsigned _Accum},
1279 @code{_Sat unsigned long _Accum},
1280 @code{_Sat unsigned long long _Accum}.
1282 Fixed-point data values contain fractional and optional integral parts.
1283 The format of fixed-point data varies and depends on the target machine.
1285 Support for fixed-point types includes:
1286 @itemize @bullet
1287 @item
1288 prefix and postfix increment and decrement operators (@code{++}, @code{--})
1289 @item
1290 unary arithmetic operators (@code{+}, @code{-}, @code{!})
1291 @item
1292 binary arithmetic operators (@code{+}, @code{-}, @code{*}, @code{/})
1293 @item
1294 binary shift operators (@code{<<}, @code{>>})
1295 @item
1296 relational operators (@code{<}, @code{<=}, @code{>=}, @code{>})
1297 @item
1298 equality operators (@code{==}, @code{!=})
1299 @item
1300 assignment operators (@code{+=}, @code{-=}, @code{*=}, @code{/=},
1301 @code{<<=}, @code{>>=})
1302 @item
1303 conversions to and from integer, floating-point, or fixed-point types
1304 @end itemize
1306 Use a suffix in a fixed-point literal constant:
1307 @itemize
1308 @item @samp{hr} or @samp{HR} for @code{short _Fract} and
1309 @code{_Sat short _Fract}
1310 @item @samp{r} or @samp{R} for @code{_Fract} and @code{_Sat _Fract}
1311 @item @samp{lr} or @samp{LR} for @code{long _Fract} and
1312 @code{_Sat long _Fract}
1313 @item @samp{llr} or @samp{LLR} for @code{long long _Fract} and
1314 @code{_Sat long long _Fract}
1315 @item @samp{uhr} or @samp{UHR} for @code{unsigned short _Fract} and
1316 @code{_Sat unsigned short _Fract}
1317 @item @samp{ur} or @samp{UR} for @code{unsigned _Fract} and
1318 @code{_Sat unsigned _Fract}
1319 @item @samp{ulr} or @samp{ULR} for @code{unsigned long _Fract} and
1320 @code{_Sat unsigned long _Fract}
1321 @item @samp{ullr} or @samp{ULLR} for @code{unsigned long long _Fract}
1322 and @code{_Sat unsigned long long _Fract}
1323 @item @samp{hk} or @samp{HK} for @code{short _Accum} and
1324 @code{_Sat short _Accum}
1325 @item @samp{k} or @samp{K} for @code{_Accum} and @code{_Sat _Accum}
1326 @item @samp{lk} or @samp{LK} for @code{long _Accum} and
1327 @code{_Sat long _Accum}
1328 @item @samp{llk} or @samp{LLK} for @code{long long _Accum} and
1329 @code{_Sat long long _Accum}
1330 @item @samp{uhk} or @samp{UHK} for @code{unsigned short _Accum} and
1331 @code{_Sat unsigned short _Accum}
1332 @item @samp{uk} or @samp{UK} for @code{unsigned _Accum} and
1333 @code{_Sat unsigned _Accum}
1334 @item @samp{ulk} or @samp{ULK} for @code{unsigned long _Accum} and
1335 @code{_Sat unsigned long _Accum}
1336 @item @samp{ullk} or @samp{ULLK} for @code{unsigned long long _Accum}
1337 and @code{_Sat unsigned long long _Accum}
1338 @end itemize
1340 GCC support of fixed-point types as specified by the draft technical report
1341 is incomplete:
1343 @itemize @bullet
1344 @item
1345 Pragmas to control overflow and rounding behaviors are not implemented.
1346 @end itemize
1348 Fixed-point types are supported by the DWARF debug information format.
1350 @node Named Address Spaces
1351 @section Named Address Spaces
1352 @cindex Named Address Spaces
1354 As an extension, GNU C supports named address spaces as
1355 defined in the N1275 draft of ISO/IEC DTR 18037.  Support for named
1356 address spaces in GCC will evolve as the draft technical report
1357 changes.  Calling conventions for any target might also change.  At
1358 present, only the AVR, SPU, M32C, RL78, and x86 targets support
1359 address spaces other than the generic address space.
1361 Address space identifiers may be used exactly like any other C type
1362 qualifier (e.g., @code{const} or @code{volatile}).  See the N1275
1363 document for more details.
1365 @anchor{AVR Named Address Spaces}
1366 @subsection AVR Named Address Spaces
1368 On the AVR target, there are several address spaces that can be used
1369 in order to put read-only data into the flash memory and access that
1370 data by means of the special instructions @code{LPM} or @code{ELPM}
1371 needed to read from flash.
1373 Devices belonging to @code{avrtiny} and @code{avrxmega3} can access
1374 flash memory by means of @code{LD*} instructions because the flash
1375 memory is mapped into the RAM address space.  There is @emph{no need}
1376 for language extensions like @code{__flash} or attribute
1377 @ref{AVR Variable Attributes,,@code{progmem}}.
1378 The default linker description files for these devices cater for that
1379 feature and @code{.rodata} stays in flash: The compiler just generates
1380 @code{LD*} instructions, and the linker script adds core specific
1381 offsets to all @code{.rodata} symbols: @code{0x4000} in the case of
1382 @code{avrtiny} and @code{0x8000} in the case of @code{avrxmega3}.
1383 See @ref{AVR Options} for a list of respective devices.
1385 For devices not in @code{avrtiny} or @code{avrxmega3},
1386 any data including read-only data is located in RAM (the generic
1387 address space) because flash memory is not visible in the RAM address
1388 space.  In order to locate read-only data in flash memory @emph{and}
1389 to generate the right instructions to access this data without
1390 using (inline) assembler code, special address spaces are needed.
1392 @table @code
1393 @item __flash
1394 @cindex @code{__flash} AVR Named Address Spaces
1395 The @code{__flash} qualifier locates data in the
1396 @code{.progmem.data} section. Data is read using the @code{LPM}
1397 instruction. Pointers to this address space are 16 bits wide.
1399 @item __flash1
1400 @itemx __flash2
1401 @itemx __flash3
1402 @itemx __flash4
1403 @itemx __flash5
1404 @cindex @code{__flash1} AVR Named Address Spaces
1405 @cindex @code{__flash2} AVR Named Address Spaces
1406 @cindex @code{__flash3} AVR Named Address Spaces
1407 @cindex @code{__flash4} AVR Named Address Spaces
1408 @cindex @code{__flash5} AVR Named Address Spaces
1409 These are 16-bit address spaces locating data in section
1410 @code{.progmem@var{N}.data} where @var{N} refers to
1411 address space @code{__flash@var{N}}.
1412 The compiler sets the @code{RAMPZ} segment register appropriately 
1413 before reading data by means of the @code{ELPM} instruction.
1415 @item __memx
1416 @cindex @code{__memx} AVR Named Address Spaces
1417 This is a 24-bit address space that linearizes flash and RAM:
1418 If the high bit of the address is set, data is read from
1419 RAM using the lower two bytes as RAM address.
1420 If the high bit of the address is clear, data is read from flash
1421 with @code{RAMPZ} set according to the high byte of the address.
1422 @xref{AVR Built-in Functions,,@code{__builtin_avr_flash_segment}}.
1424 Objects in this address space are located in @code{.progmemx.data}.
1425 @end table
1427 @b{Example}
1429 @smallexample
1430 char my_read (const __flash char ** p)
1432     /* p is a pointer to RAM that points to a pointer to flash.
1433        The first indirection of p reads that flash pointer
1434        from RAM and the second indirection reads a char from this
1435        flash address.  */
1437     return **p;
1440 /* Locate array[] in flash memory */
1441 const __flash int array[] = @{ 3, 5, 7, 11, 13, 17, 19 @};
1443 int i = 1;
1445 int main (void)
1447    /* Return 17 by reading from flash memory */
1448    return array[array[i]];
1450 @end smallexample
1452 @noindent
1453 For each named address space supported by avr-gcc there is an equally
1454 named but uppercase built-in macro defined. 
1455 The purpose is to facilitate testing if respective address space
1456 support is available or not:
1458 @smallexample
1459 #ifdef __FLASH
1460 const __flash int var = 1;
1462 int read_var (void)
1464     return var;
1466 #else
1467 #include <avr/pgmspace.h> /* From AVR-LibC */
1469 const int var PROGMEM = 1;
1471 int read_var (void)
1473     return (int) pgm_read_word (&var);
1475 #endif /* __FLASH */
1476 @end smallexample
1478 @noindent
1479 Notice that attribute @ref{AVR Variable Attributes,,@code{progmem}}
1480 locates data in flash but
1481 accesses to these data read from generic address space, i.e.@:
1482 from RAM,
1483 so that you need special accessors like @code{pgm_read_byte}
1484 from @w{@uref{http://nongnu.org/avr-libc/user-manual/,AVR-LibC}}
1485 together with attribute @code{progmem}.
1487 @noindent
1488 @b{Limitations and caveats}
1490 @itemize
1491 @item
1492 Reading across the 64@tie{}KiB section boundary of
1493 the @code{__flash} or @code{__flash@var{N}} address spaces
1494 shows undefined behavior. The only address space that
1495 supports reading across the 64@tie{}KiB flash segment boundaries is
1496 @code{__memx}.
1498 @item
1499 If you use one of the @code{__flash@var{N}} address spaces
1500 you must arrange your linker script to locate the
1501 @code{.progmem@var{N}.data} sections according to your needs.
1503 @item
1504 Any data or pointers to the non-generic address spaces must
1505 be qualified as @code{const}, i.e.@: as read-only data.
1506 This still applies if the data in one of these address
1507 spaces like software version number or calibration lookup table are intended to
1508 be changed after load time by, say, a boot loader. In this case
1509 the right qualification is @code{const} @code{volatile} so that the compiler
1510 must not optimize away known values or insert them
1511 as immediates into operands of instructions.
1513 @item
1514 The following code initializes a variable @code{pfoo}
1515 located in static storage with a 24-bit address:
1516 @smallexample
1517 extern const __memx char foo;
1518 const __memx void *pfoo = &foo;
1519 @end smallexample
1521 @item
1522 On the reduced Tiny devices like ATtiny40, no address spaces are supported.
1523 Just use vanilla C / C++ code without overhead as outlined above.
1524 Attribute @code{progmem} is supported but works differently,
1525 see @ref{AVR Variable Attributes}.
1527 @end itemize
1529 @subsection M32C Named Address Spaces
1530 @cindex @code{__far} M32C Named Address Spaces
1532 On the M32C target, with the R8C and M16C CPU variants, variables
1533 qualified with @code{__far} are accessed using 32-bit addresses in
1534 order to access memory beyond the first 64@tie{}Ki bytes.  If
1535 @code{__far} is used with the M32CM or M32C CPU variants, it has no
1536 effect.
1538 @subsection RL78 Named Address Spaces
1539 @cindex @code{__far} RL78 Named Address Spaces
1541 On the RL78 target, variables qualified with @code{__far} are accessed
1542 with 32-bit pointers (20-bit addresses) rather than the default 16-bit
1543 addresses.  Non-far variables are assumed to appear in the topmost
1544 64@tie{}KiB of the address space.
1546 @subsection SPU Named Address Spaces
1547 @cindex @code{__ea} SPU Named Address Spaces
1549 On the SPU target variables may be declared as
1550 belonging to another address space by qualifying the type with the
1551 @code{__ea} address space identifier:
1553 @smallexample
1554 extern int __ea i;
1555 @end smallexample
1557 @noindent 
1558 The compiler generates special code to access the variable @code{i}.
1559 It may use runtime library
1560 support, or generate special machine instructions to access that address
1561 space.
1563 @subsection x86 Named Address Spaces
1564 @cindex x86 named address spaces
1566 On the x86 target, variables may be declared as being relative
1567 to the @code{%fs} or @code{%gs} segments.
1569 @table @code
1570 @item __seg_fs
1571 @itemx __seg_gs
1572 @cindex @code{__seg_fs} x86 named address space
1573 @cindex @code{__seg_gs} x86 named address space
1574 The object is accessed with the respective segment override prefix.
1576 The respective segment base must be set via some method specific to
1577 the operating system.  Rather than require an expensive system call
1578 to retrieve the segment base, these address spaces are not considered
1579 to be subspaces of the generic (flat) address space.  This means that
1580 explicit casts are required to convert pointers between these address
1581 spaces and the generic address space.  In practice the application
1582 should cast to @code{uintptr_t} and apply the segment base offset
1583 that it installed previously.
1585 The preprocessor symbols @code{__SEG_FS} and @code{__SEG_GS} are
1586 defined when these address spaces are supported.
1587 @end table
1589 @node Zero Length
1590 @section Arrays of Length Zero
1591 @cindex arrays of length zero
1592 @cindex zero-length arrays
1593 @cindex length-zero arrays
1594 @cindex flexible array members
1596 Declaring zero-length arrays is allowed in GNU C as an extension.
1597 A zero-length array can be useful as the last element of a structure
1598 that is really a header for a variable-length object:
1600 @smallexample
1601 struct line @{
1602   int length;
1603   char contents[0];
1606 struct line *thisline = (struct line *)
1607   malloc (sizeof (struct line) + this_length);
1608 thisline->length = this_length;
1609 @end smallexample
1611 Although the size of a zero-length array is zero, an array member of
1612 this kind may increase the size of the enclosing type as a result of tail
1613 padding.  The offset of a zero-length array member from the beginning
1614 of the enclosing structure is the same as the offset of an array with
1615 one or more elements of the same type.  The alignment of a zero-length
1616 array is the same as the alignment of its elements.
1618 Declaring zero-length arrays in other contexts, including as interior
1619 members of structure objects or as non-member objects, is discouraged.
1620 Accessing elements of zero-length arrays declared in such contexts is
1621 undefined and may be diagnosed.
1623 In the absence of the zero-length array extension, in ISO C90
1624 the @code{contents} array in the example above would typically be declared
1625 to have a single element.  Unlike a zero-length array which only contributes
1626 to the size of the enclosing structure for the purposes of alignment,
1627 a one-element array always occupies at least as much space as a single
1628 object of the type.  Although using one-element arrays this way is
1629 discouraged, GCC handles accesses to trailing one-element array members
1630 analogously to zero-length arrays.
1632 The preferred mechanism to declare variable-length types like
1633 @code{struct line} above is the ISO C99 @dfn{flexible array member},
1634 with slightly different syntax and semantics:
1636 @itemize @bullet
1637 @item
1638 Flexible array members are written as @code{contents[]} without
1639 the @code{0}.
1641 @item
1642 Flexible array members have incomplete type, and so the @code{sizeof}
1643 operator may not be applied.  As a quirk of the original implementation
1644 of zero-length arrays, @code{sizeof} evaluates to zero.
1646 @item
1647 Flexible array members may only appear as the last member of a
1648 @code{struct} that is otherwise non-empty.
1650 @item
1651 A structure containing a flexible array member, or a union containing
1652 such a structure (possibly recursively), may not be a member of a
1653 structure or an element of an array.  (However, these uses are
1654 permitted by GCC as extensions.)
1655 @end itemize
1657 Non-empty initialization of zero-length
1658 arrays is treated like any case where there are more initializer
1659 elements than the array holds, in that a suitable warning about ``excess
1660 elements in array'' is given, and the excess elements (all of them, in
1661 this case) are ignored.
1663 GCC allows static initialization of flexible array members.
1664 This is equivalent to defining a new structure containing the original
1665 structure followed by an array of sufficient size to contain the data.
1666 E.g.@: in the following, @code{f1} is constructed as if it were declared
1667 like @code{f2}.
1669 @smallexample
1670 struct f1 @{
1671   int x; int y[];
1672 @} f1 = @{ 1, @{ 2, 3, 4 @} @};
1674 struct f2 @{
1675   struct f1 f1; int data[3];
1676 @} f2 = @{ @{ 1 @}, @{ 2, 3, 4 @} @};
1677 @end smallexample
1679 @noindent
1680 The convenience of this extension is that @code{f1} has the desired
1681 type, eliminating the need to consistently refer to @code{f2.f1}.
1683 This has symmetry with normal static arrays, in that an array of
1684 unknown size is also written with @code{[]}.
1686 Of course, this extension only makes sense if the extra data comes at
1687 the end of a top-level object, as otherwise we would be overwriting
1688 data at subsequent offsets.  To avoid undue complication and confusion
1689 with initialization of deeply nested arrays, we simply disallow any
1690 non-empty initialization except when the structure is the top-level
1691 object.  For example:
1693 @smallexample
1694 struct foo @{ int x; int y[]; @};
1695 struct bar @{ struct foo z; @};
1697 struct foo a = @{ 1, @{ 2, 3, 4 @} @};        // @r{Valid.}
1698 struct bar b = @{ @{ 1, @{ 2, 3, 4 @} @} @};    // @r{Invalid.}
1699 struct bar c = @{ @{ 1, @{ @} @} @};            // @r{Valid.}
1700 struct foo d[1] = @{ @{ 1, @{ 2, 3, 4 @} @} @};  // @r{Invalid.}
1701 @end smallexample
1703 @node Empty Structures
1704 @section Structures with No Members
1705 @cindex empty structures
1706 @cindex zero-size structures
1708 GCC permits a C structure to have no members:
1710 @smallexample
1711 struct empty @{
1713 @end smallexample
1715 The structure has size zero.  In C++, empty structures are part
1716 of the language.  G++ treats empty structures as if they had a single
1717 member of type @code{char}.
1719 @node Variable Length
1720 @section Arrays of Variable Length
1721 @cindex variable-length arrays
1722 @cindex arrays of variable length
1723 @cindex VLAs
1725 Variable-length automatic arrays are allowed in ISO C99, and as an
1726 extension GCC accepts them in C90 mode and in C++.  These arrays are
1727 declared like any other automatic arrays, but with a length that is not
1728 a constant expression.  The storage is allocated at the point of
1729 declaration and deallocated when the block scope containing the declaration
1730 exits.  For
1731 example:
1733 @smallexample
1734 FILE *
1735 concat_fopen (char *s1, char *s2, char *mode)
1737   char str[strlen (s1) + strlen (s2) + 1];
1738   strcpy (str, s1);
1739   strcat (str, s2);
1740   return fopen (str, mode);
1742 @end smallexample
1744 @cindex scope of a variable length array
1745 @cindex variable-length array scope
1746 @cindex deallocating variable length arrays
1747 Jumping or breaking out of the scope of the array name deallocates the
1748 storage.  Jumping into the scope is not allowed; you get an error
1749 message for it.
1751 @cindex variable-length array in a structure
1752 As an extension, GCC accepts variable-length arrays as a member of
1753 a structure or a union.  For example:
1755 @smallexample
1756 void
1757 foo (int n)
1759   struct S @{ int x[n]; @};
1761 @end smallexample
1763 @cindex @code{alloca} vs variable-length arrays
1764 You can use the function @code{alloca} to get an effect much like
1765 variable-length arrays.  The function @code{alloca} is available in
1766 many other C implementations (but not in all).  On the other hand,
1767 variable-length arrays are more elegant.
1769 There are other differences between these two methods.  Space allocated
1770 with @code{alloca} exists until the containing @emph{function} returns.
1771 The space for a variable-length array is deallocated as soon as the array
1772 name's scope ends, unless you also use @code{alloca} in this scope.
1774 You can also use variable-length arrays as arguments to functions:
1776 @smallexample
1777 struct entry
1778 tester (int len, char data[len][len])
1780   /* @r{@dots{}} */
1782 @end smallexample
1784 The length of an array is computed once when the storage is allocated
1785 and is remembered for the scope of the array in case you access it with
1786 @code{sizeof}.
1788 If you want to pass the array first and the length afterward, you can
1789 use a forward declaration in the parameter list---another GNU extension.
1791 @smallexample
1792 struct entry
1793 tester (int len; char data[len][len], int len)
1795   /* @r{@dots{}} */
1797 @end smallexample
1799 @cindex parameter forward declaration
1800 The @samp{int len} before the semicolon is a @dfn{parameter forward
1801 declaration}, and it serves the purpose of making the name @code{len}
1802 known when the declaration of @code{data} is parsed.
1804 You can write any number of such parameter forward declarations in the
1805 parameter list.  They can be separated by commas or semicolons, but the
1806 last one must end with a semicolon, which is followed by the ``real''
1807 parameter declarations.  Each forward declaration must match a ``real''
1808 declaration in parameter name and data type.  ISO C99 does not support
1809 parameter forward declarations.
1811 @node Variadic Macros
1812 @section Macros with a Variable Number of Arguments.
1813 @cindex variable number of arguments
1814 @cindex macro with variable arguments
1815 @cindex rest argument (in macro)
1816 @cindex variadic macros
1818 In the ISO C standard of 1999, a macro can be declared to accept a
1819 variable number of arguments much as a function can.  The syntax for
1820 defining the macro is similar to that of a function.  Here is an
1821 example:
1823 @smallexample
1824 #define debug(format, ...) fprintf (stderr, format, __VA_ARGS__)
1825 @end smallexample
1827 @noindent
1828 Here @samp{@dots{}} is a @dfn{variable argument}.  In the invocation of
1829 such a macro, it represents the zero or more tokens until the closing
1830 parenthesis that ends the invocation, including any commas.  This set of
1831 tokens replaces the identifier @code{__VA_ARGS__} in the macro body
1832 wherever it appears.  See the CPP manual for more information.
1834 GCC has long supported variadic macros, and used a different syntax that
1835 allowed you to give a name to the variable arguments just like any other
1836 argument.  Here is an example:
1838 @smallexample
1839 #define debug(format, args...) fprintf (stderr, format, args)
1840 @end smallexample
1842 @noindent
1843 This is in all ways equivalent to the ISO C example above, but arguably
1844 more readable and descriptive.
1846 GNU CPP has two further variadic macro extensions, and permits them to
1847 be used with either of the above forms of macro definition.
1849 In standard C, you are not allowed to leave the variable argument out
1850 entirely; but you are allowed to pass an empty argument.  For example,
1851 this invocation is invalid in ISO C, because there is no comma after
1852 the string:
1854 @smallexample
1855 debug ("A message")
1856 @end smallexample
1858 GNU CPP permits you to completely omit the variable arguments in this
1859 way.  In the above examples, the compiler would complain, though since
1860 the expansion of the macro still has the extra comma after the format
1861 string.
1863 To help solve this problem, CPP behaves specially for variable arguments
1864 used with the token paste operator, @samp{##}.  If instead you write
1866 @smallexample
1867 #define debug(format, ...) fprintf (stderr, format, ## __VA_ARGS__)
1868 @end smallexample
1870 @noindent
1871 and if the variable arguments are omitted or empty, the @samp{##}
1872 operator causes the preprocessor to remove the comma before it.  If you
1873 do provide some variable arguments in your macro invocation, GNU CPP
1874 does not complain about the paste operation and instead places the
1875 variable arguments after the comma.  Just like any other pasted macro
1876 argument, these arguments are not macro expanded.
1878 @node Escaped Newlines
1879 @section Slightly Looser Rules for Escaped Newlines
1880 @cindex escaped newlines
1881 @cindex newlines (escaped)
1883 The preprocessor treatment of escaped newlines is more relaxed 
1884 than that specified by the C90 standard, which requires the newline
1885 to immediately follow a backslash.  
1886 GCC's implementation allows whitespace in the form
1887 of spaces, horizontal and vertical tabs, and form feeds between the
1888 backslash and the subsequent newline.  The preprocessor issues a
1889 warning, but treats it as a valid escaped newline and combines the two
1890 lines to form a single logical line.  This works within comments and
1891 tokens, as well as between tokens.  Comments are @emph{not} treated as
1892 whitespace for the purposes of this relaxation, since they have not
1893 yet been replaced with spaces.
1895 @node Subscripting
1896 @section Non-Lvalue Arrays May Have Subscripts
1897 @cindex subscripting
1898 @cindex arrays, non-lvalue
1900 @cindex subscripting and function values
1901 In ISO C99, arrays that are not lvalues still decay to pointers, and
1902 may be subscripted, although they may not be modified or used after
1903 the next sequence point and the unary @samp{&} operator may not be
1904 applied to them.  As an extension, GNU C allows such arrays to be
1905 subscripted in C90 mode, though otherwise they do not decay to
1906 pointers outside C99 mode.  For example,
1907 this is valid in GNU C though not valid in C90:
1909 @smallexample
1910 @group
1911 struct foo @{int a[4];@};
1913 struct foo f();
1915 bar (int index)
1917   return f().a[index];
1919 @end group
1920 @end smallexample
1922 @node Pointer Arith
1923 @section Arithmetic on @code{void}- and Function-Pointers
1924 @cindex void pointers, arithmetic
1925 @cindex void, size of pointer to
1926 @cindex function pointers, arithmetic
1927 @cindex function, size of pointer to
1929 In GNU C, addition and subtraction operations are supported on pointers to
1930 @code{void} and on pointers to functions.  This is done by treating the
1931 size of a @code{void} or of a function as 1.
1933 A consequence of this is that @code{sizeof} is also allowed on @code{void}
1934 and on function types, and returns 1.
1936 @opindex Wpointer-arith
1937 The option @option{-Wpointer-arith} requests a warning if these extensions
1938 are used.
1940 @node Pointers to Arrays
1941 @section Pointers to Arrays with Qualifiers Work as Expected
1942 @cindex pointers to arrays
1943 @cindex const qualifier
1945 In GNU C, pointers to arrays with qualifiers work similar to pointers
1946 to other qualified types. For example, a value of type @code{int (*)[5]}
1947 can be used to initialize a variable of type @code{const int (*)[5]}.
1948 These types are incompatible in ISO C because the @code{const} qualifier
1949 is formally attached to the element type of the array and not the
1950 array itself.
1952 @smallexample
1953 extern void
1954 transpose (int N, int M, double out[M][N], const double in[N][M]);
1955 double x[3][2];
1956 double y[2][3];
1957 @r{@dots{}}
1958 transpose(3, 2, y, x);
1959 @end smallexample
1961 @node Initializers
1962 @section Non-Constant Initializers
1963 @cindex initializers, non-constant
1964 @cindex non-constant initializers
1966 As in standard C++ and ISO C99, the elements of an aggregate initializer for an
1967 automatic variable are not required to be constant expressions in GNU C@.
1968 Here is an example of an initializer with run-time varying elements:
1970 @smallexample
1971 foo (float f, float g)
1973   float beat_freqs[2] = @{ f-g, f+g @};
1974   /* @r{@dots{}} */
1976 @end smallexample
1978 @node Compound Literals
1979 @section Compound Literals
1980 @cindex constructor expressions
1981 @cindex initializations in expressions
1982 @cindex structures, constructor expression
1983 @cindex expressions, constructor
1984 @cindex compound literals
1985 @c The GNU C name for what C99 calls compound literals was "constructor expressions".
1987 A compound literal looks like a cast of a brace-enclosed aggregate
1988 initializer list.  Its value is an object of the type specified in
1989 the cast, containing the elements specified in the initializer.
1990 Unlike the result of a cast, a compound literal is an lvalue.  ISO
1991 C99 and later support compound literals.  As an extension, GCC
1992 supports compound literals also in C90 mode and in C++, although
1993 as explained below, the C++ semantics are somewhat different.
1995 Usually, the specified type of a compound literal is a structure.  Assume
1996 that @code{struct foo} and @code{structure} are declared as shown:
1998 @smallexample
1999 struct foo @{int a; char b[2];@} structure;
2000 @end smallexample
2002 @noindent
2003 Here is an example of constructing a @code{struct foo} with a compound literal:
2005 @smallexample
2006 structure = ((struct foo) @{x + y, 'a', 0@});
2007 @end smallexample
2009 @noindent
2010 This is equivalent to writing the following:
2012 @smallexample
2014   struct foo temp = @{x + y, 'a', 0@};
2015   structure = temp;
2017 @end smallexample
2019 You can also construct an array, though this is dangerous in C++, as
2020 explained below.  If all the elements of the compound literal are
2021 (made up of) simple constant expressions suitable for use in
2022 initializers of objects of static storage duration, then the compound
2023 literal can be coerced to a pointer to its first element and used in
2024 such an initializer, as shown here:
2026 @smallexample
2027 char **foo = (char *[]) @{ "x", "y", "z" @};
2028 @end smallexample
2030 Compound literals for scalar types and union types are also allowed.  In
2031 the following example the variable @code{i} is initialized to the value
2032 @code{2}, the result of incrementing the unnamed object created by
2033 the compound literal.
2035 @smallexample
2036 int i = ++(int) @{ 1 @};
2037 @end smallexample
2039 As a GNU extension, GCC allows initialization of objects with static storage
2040 duration by compound literals (which is not possible in ISO C99 because
2041 the initializer is not a constant).
2042 It is handled as if the object were initialized only with the brace-enclosed
2043 list if the types of the compound literal and the object match.
2044 The elements of the compound literal must be constant.
2045 If the object being initialized has array type of unknown size, the size is
2046 determined by the size of the compound literal.
2048 @smallexample
2049 static struct foo x = (struct foo) @{1, 'a', 'b'@};
2050 static int y[] = (int []) @{1, 2, 3@};
2051 static int z[] = (int [3]) @{1@};
2052 @end smallexample
2054 @noindent
2055 The above lines are equivalent to the following:
2056 @smallexample
2057 static struct foo x = @{1, 'a', 'b'@};
2058 static int y[] = @{1, 2, 3@};
2059 static int z[] = @{1, 0, 0@};
2060 @end smallexample
2062 In C, a compound literal designates an unnamed object with static or
2063 automatic storage duration.  In C++, a compound literal designates a
2064 temporary object that only lives until the end of its full-expression.
2065 As a result, well-defined C code that takes the address of a subobject
2066 of a compound literal can be undefined in C++, so G++ rejects
2067 the conversion of a temporary array to a pointer.  For instance, if
2068 the array compound literal example above appeared inside a function,
2069 any subsequent use of @code{foo} in C++ would have undefined behavior
2070 because the lifetime of the array ends after the declaration of @code{foo}.
2072 As an optimization, G++ sometimes gives array compound literals longer
2073 lifetimes: when the array either appears outside a function or has
2074 a @code{const}-qualified type.  If @code{foo} and its initializer had
2075 elements of type @code{char *const} rather than @code{char *}, or if
2076 @code{foo} were a global variable, the array would have static storage
2077 duration.  But it is probably safest just to avoid the use of array
2078 compound literals in C++ code.
2080 @node Designated Inits
2081 @section Designated Initializers
2082 @cindex initializers with labeled elements
2083 @cindex labeled elements in initializers
2084 @cindex case labels in initializers
2085 @cindex designated initializers
2087 Standard C90 requires the elements of an initializer to appear in a fixed
2088 order, the same as the order of the elements in the array or structure
2089 being initialized.
2091 In ISO C99 you can give the elements in any order, specifying the array
2092 indices or structure field names they apply to, and GNU C allows this as
2093 an extension in C90 mode as well.  This extension is not
2094 implemented in GNU C++.
2096 To specify an array index, write
2097 @samp{[@var{index}] =} before the element value.  For example,
2099 @smallexample
2100 int a[6] = @{ [4] = 29, [2] = 15 @};
2101 @end smallexample
2103 @noindent
2104 is equivalent to
2106 @smallexample
2107 int a[6] = @{ 0, 0, 15, 0, 29, 0 @};
2108 @end smallexample
2110 @noindent
2111 The index values must be constant expressions, even if the array being
2112 initialized is automatic.
2114 An alternative syntax for this that has been obsolete since GCC 2.5 but
2115 GCC still accepts is to write @samp{[@var{index}]} before the element
2116 value, with no @samp{=}.
2118 To initialize a range of elements to the same value, write
2119 @samp{[@var{first} ... @var{last}] = @var{value}}.  This is a GNU
2120 extension.  For example,
2122 @smallexample
2123 int widths[] = @{ [0 ... 9] = 1, [10 ... 99] = 2, [100] = 3 @};
2124 @end smallexample
2126 @noindent
2127 If the value in it has side effects, the side effects happen only once,
2128 not for each initialized field by the range initializer.
2130 @noindent
2131 Note that the length of the array is the highest value specified
2132 plus one.
2134 In a structure initializer, specify the name of a field to initialize
2135 with @samp{.@var{fieldname} =} before the element value.  For example,
2136 given the following structure,
2138 @smallexample
2139 struct point @{ int x, y; @};
2140 @end smallexample
2142 @noindent
2143 the following initialization
2145 @smallexample
2146 struct point p = @{ .y = yvalue, .x = xvalue @};
2147 @end smallexample
2149 @noindent
2150 is equivalent to
2152 @smallexample
2153 struct point p = @{ xvalue, yvalue @};
2154 @end smallexample
2156 Another syntax that has the same meaning, obsolete since GCC 2.5, is
2157 @samp{@var{fieldname}:}, as shown here:
2159 @smallexample
2160 struct point p = @{ y: yvalue, x: xvalue @};
2161 @end smallexample
2163 Omitted fields are implicitly initialized the same as for objects
2164 that have static storage duration.
2166 @cindex designators
2167 The @samp{[@var{index}]} or @samp{.@var{fieldname}} is known as a
2168 @dfn{designator}.  You can also use a designator (or the obsolete colon
2169 syntax) when initializing a union, to specify which element of the union
2170 should be used.  For example,
2172 @smallexample
2173 union foo @{ int i; double d; @};
2175 union foo f = @{ .d = 4 @};
2176 @end smallexample
2178 @noindent
2179 converts 4 to a @code{double} to store it in the union using
2180 the second element.  By contrast, casting 4 to type @code{union foo}
2181 stores it into the union as the integer @code{i}, since it is
2182 an integer.  @xref{Cast to Union}.
2184 You can combine this technique of naming elements with ordinary C
2185 initialization of successive elements.  Each initializer element that
2186 does not have a designator applies to the next consecutive element of the
2187 array or structure.  For example,
2189 @smallexample
2190 int a[6] = @{ [1] = v1, v2, [4] = v4 @};
2191 @end smallexample
2193 @noindent
2194 is equivalent to
2196 @smallexample
2197 int a[6] = @{ 0, v1, v2, 0, v4, 0 @};
2198 @end smallexample
2200 Labeling the elements of an array initializer is especially useful
2201 when the indices are characters or belong to an @code{enum} type.
2202 For example:
2204 @smallexample
2205 int whitespace[256]
2206   = @{ [' '] = 1, ['\t'] = 1, ['\h'] = 1,
2207       ['\f'] = 1, ['\n'] = 1, ['\r'] = 1 @};
2208 @end smallexample
2210 @cindex designator lists
2211 You can also write a series of @samp{.@var{fieldname}} and
2212 @samp{[@var{index}]} designators before an @samp{=} to specify a
2213 nested subobject to initialize; the list is taken relative to the
2214 subobject corresponding to the closest surrounding brace pair.  For
2215 example, with the @samp{struct point} declaration above:
2217 @smallexample
2218 struct point ptarray[10] = @{ [2].y = yv2, [2].x = xv2, [0].x = xv0 @};
2219 @end smallexample
2221 If the same field is initialized multiple times, or overlapping
2222 fields of a union are initialized, the value from the last
2223 initialization is used.  When a field of a union is itself a structure, 
2224 the entire structure from the last field initialized is used.  If any previous
2225 initializer has side effect, it is unspecified whether the side effect
2226 happens or not.  Currently, GCC discards the side-effecting
2227 initializer expressions and issues a warning.
2229 @node Case Ranges
2230 @section Case Ranges
2231 @cindex case ranges
2232 @cindex ranges in case statements
2234 You can specify a range of consecutive values in a single @code{case} label,
2235 like this:
2237 @smallexample
2238 case @var{low} ... @var{high}:
2239 @end smallexample
2241 @noindent
2242 This has the same effect as the proper number of individual @code{case}
2243 labels, one for each integer value from @var{low} to @var{high}, inclusive.
2245 This feature is especially useful for ranges of ASCII character codes:
2247 @smallexample
2248 case 'A' ... 'Z':
2249 @end smallexample
2251 @strong{Be careful:} Write spaces around the @code{...}, for otherwise
2252 it may be parsed wrong when you use it with integer values.  For example,
2253 write this:
2255 @smallexample
2256 case 1 ... 5:
2257 @end smallexample
2259 @noindent
2260 rather than this:
2262 @smallexample
2263 case 1...5:
2264 @end smallexample
2266 @node Cast to Union
2267 @section Cast to a Union Type
2268 @cindex cast to a union
2269 @cindex union, casting to a
2271 A cast to union type looks similar to other casts, except that the type
2272 specified is a union type.  You can specify the type either with the
2273 @code{union} keyword or with a @code{typedef} name that refers to
2274 a union.  A cast to a union actually creates a compound literal and
2275 yields an lvalue, not an rvalue like true casts do.
2276 @xref{Compound Literals}.
2278 The types that may be cast to the union type are those of the members
2279 of the union.  Thus, given the following union and variables:
2281 @smallexample
2282 union foo @{ int i; double d; @};
2283 int x;
2284 double y;
2285 @end smallexample
2287 @noindent
2288 both @code{x} and @code{y} can be cast to type @code{union foo}.
2290 Using the cast as the right-hand side of an assignment to a variable of
2291 union type is equivalent to storing in a member of the union:
2293 @smallexample
2294 union foo u;
2295 /* @r{@dots{}} */
2296 u = (union foo) x  @equiv{}  u.i = x
2297 u = (union foo) y  @equiv{}  u.d = y
2298 @end smallexample
2300 You can also use the union cast as a function argument:
2302 @smallexample
2303 void hack (union foo);
2304 /* @r{@dots{}} */
2305 hack ((union foo) x);
2306 @end smallexample
2308 @node Mixed Declarations
2309 @section Mixed Declarations and Code
2310 @cindex mixed declarations and code
2311 @cindex declarations, mixed with code
2312 @cindex code, mixed with declarations
2314 ISO C99 and ISO C++ allow declarations and code to be freely mixed
2315 within compound statements.  As an extension, GNU C also allows this in
2316 C90 mode.  For example, you could do:
2318 @smallexample
2319 int i;
2320 /* @r{@dots{}} */
2321 i++;
2322 int j = i + 2;
2323 @end smallexample
2325 Each identifier is visible from where it is declared until the end of
2326 the enclosing block.
2328 @node Function Attributes
2329 @section Declaring Attributes of Functions
2330 @cindex function attributes
2331 @cindex declaring attributes of functions
2332 @cindex @code{volatile} applied to function
2333 @cindex @code{const} applied to function
2335 In GNU C and C++, you can use function attributes to specify certain
2336 function properties that may help the compiler optimize calls or
2337 check code more carefully for correctness.  For example, you
2338 can use attributes to specify that a function never returns
2339 (@code{noreturn}), returns a value depending only on the values of
2340 its arguments (@code{const}), or has @code{printf}-style arguments
2341 (@code{format}).
2343 You can also use attributes to control memory placement, code
2344 generation options or call/return conventions within the function
2345 being annotated.  Many of these attributes are target-specific.  For
2346 example, many targets support attributes for defining interrupt
2347 handler functions, which typically must follow special register usage
2348 and return conventions.  Such attributes are described in the subsection
2349 for each target.  However, a considerable number of attributes are
2350 supported by most, if not all targets.  Those are described in
2351 the @ref{Common Function Attributes} section.
2353 Function attributes are introduced by the @code{__attribute__} keyword
2354 in the declaration of a function, followed by an attribute specification
2355 enclosed in double parentheses.  You can specify multiple attributes in
2356 a declaration by separating them by commas within the double parentheses
2357 or by immediately following one attribute specification with another.
2358 @xref{Attribute Syntax}, for the exact rules on attribute syntax and
2359 placement.  Compatible attribute specifications on distinct declarations
2360 of the same function are merged.  An attribute specification that is not
2361 compatible with attributes already applied to a declaration of the same
2362 function is ignored with a warning.
2364 Some function attributes take one or more arguments that refer to
2365 the function's parameters by their positions within the function parameter
2366 list.  Such attribute arguments are referred to as @dfn{positional arguments}.
2367 Unless specified otherwise, positional arguments that specify properties
2368 of parameters with pointer types can also specify the same properties of
2369 the implicit C++ @code{this} argument in non-static member functions, and
2370 of parameters of reference to a pointer type.  For ordinary functions,
2371 position one refers to the first parameter on the list.  In C++ non-static
2372 member functions, position one refers to the implicit @code{this} pointer.
2373 The same restrictions and effects apply to function attributes used with
2374 ordinary functions or C++ member functions.
2376 GCC also supports attributes on
2377 variable declarations (@pxref{Variable Attributes}),
2378 labels (@pxref{Label Attributes}),
2379 enumerators (@pxref{Enumerator Attributes}),
2380 statements (@pxref{Statement Attributes}),
2381 and types (@pxref{Type Attributes}).
2383 There is some overlap between the purposes of attributes and pragmas
2384 (@pxref{Pragmas,,Pragmas Accepted by GCC}).  It has been
2385 found convenient to use @code{__attribute__} to achieve a natural
2386 attachment of attributes to their corresponding declarations, whereas
2387 @code{#pragma} is of use for compatibility with other compilers
2388 or constructs that do not naturally form part of the grammar.
2390 In addition to the attributes documented here,
2391 GCC plugins may provide their own attributes.
2393 @menu
2394 * Common Function Attributes::
2395 * AArch64 Function Attributes::
2396 * ARC Function Attributes::
2397 * ARM Function Attributes::
2398 * AVR Function Attributes::
2399 * Blackfin Function Attributes::
2400 * CR16 Function Attributes::
2401 * C-SKY Function Attributes::
2402 * Epiphany Function Attributes::
2403 * H8/300 Function Attributes::
2404 * IA-64 Function Attributes::
2405 * M32C Function Attributes::
2406 * M32R/D Function Attributes::
2407 * m68k Function Attributes::
2408 * MCORE Function Attributes::
2409 * MeP Function Attributes::
2410 * MicroBlaze Function Attributes::
2411 * Microsoft Windows Function Attributes::
2412 * MIPS Function Attributes::
2413 * MSP430 Function Attributes::
2414 * NDS32 Function Attributes::
2415 * Nios II Function Attributes::
2416 * Nvidia PTX Function Attributes::
2417 * PowerPC Function Attributes::
2418 * RISC-V Function Attributes::
2419 * RL78 Function Attributes::
2420 * RX Function Attributes::
2421 * S/390 Function Attributes::
2422 * SH Function Attributes::
2423 * SPU Function Attributes::
2424 * Symbian OS Function Attributes::
2425 * V850 Function Attributes::
2426 * Visium Function Attributes::
2427 * x86 Function Attributes::
2428 * Xstormy16 Function Attributes::
2429 @end menu
2431 @node Common Function Attributes
2432 @subsection Common Function Attributes
2434 The following attributes are supported on most targets.
2436 @table @code
2437 @c Keep this table alphabetized by attribute name.  Treat _ as space.
2439 @item alias ("@var{target}")
2440 @cindex @code{alias} function attribute
2441 The @code{alias} attribute causes the declaration to be emitted as an
2442 alias for another symbol, which must be specified.  For instance,
2444 @smallexample
2445 void __f () @{ /* @r{Do something.} */; @}
2446 void f () __attribute__ ((weak, alias ("__f")));
2447 @end smallexample
2449 @noindent
2450 defines @samp{f} to be a weak alias for @samp{__f}.  In C++, the
2451 mangled name for the target must be used.  It is an error if @samp{__f}
2452 is not defined in the same translation unit.
2454 This attribute requires assembler and object file support,
2455 and may not be available on all targets.
2457 @item aligned
2458 @itemx aligned (@var{alignment})
2459 @cindex @code{aligned} function attribute
2460 The @code{aligned} attribute specifies a minimum alignment for
2461 the first instruction of the function, measured in bytes.  When specified,
2462 @var{alignment} must be an integer constant power of 2.  Specifying no
2463 @var{alignment} argument implies the ideal alignment for the target.
2464 The @code{__alignof__} operator can be used to determine what that is
2465 (@pxref{Alignment}).  The attribute has no effect when a definition for
2466 the function is not provided in the same translation unit.
2468 The attribute cannot be used to decrease the alignment of a function
2469 previously declared with a more restrictive alignment; only to increase
2470 it.  Attempts to do otherwise are diagnosed.  Some targets specify
2471 a minimum default alignment for functions that is greater than 1.  On
2472 such targets, specifying a less restrictive alignment is silently ignored.
2473 Using the attribute overrides the effect of the @option{-falign-functions}
2474 (@pxref{Optimize Options}) option for this function.
2476 Note that the effectiveness of @code{aligned} attributes may be
2477 limited by inherent limitations in the system linker 
2478 and/or object file format.  On some systems, the
2479 linker is only able to arrange for functions to be aligned up to a
2480 certain maximum alignment.  (For some linkers, the maximum supported
2481 alignment may be very very small.)  See your linker documentation for
2482 further information.
2484 The @code{aligned} attribute can also be used for variables and fields
2485 (@pxref{Variable Attributes}.)
2487 @item alloc_align (@var{position})
2488 @cindex @code{alloc_align} function attribute
2489 The @code{alloc_align} attribute may be applied to a function that
2490 returns a pointer and takes at least one argument of an integer type.
2491 It indicates that the returned pointer is aligned on a boundary given
2492 by the function argument at @var{position}.  Meaningful alignments are
2493 powers of 2 greater than one.  GCC uses this information to improve
2494 pointer alignment analysis.
2496 The function parameter denoting the allocated alignment is specified by
2497 one constant integer argument whose number is the argument of the attribute.
2498 Argument numbering starts at one.
2500 For instance,
2502 @smallexample
2503 void* my_memalign (size_t, size_t) __attribute__ ((alloc_align (1)));
2504 @end smallexample
2506 @noindent
2507 declares that @code{my_memalign} returns memory with minimum alignment
2508 given by parameter 1.
2510 @item alloc_size (@var{position})
2511 @itemx alloc_size (@var{position-1}, @var{position-2})
2512 @cindex @code{alloc_size} function attribute
2513 The @code{alloc_size} attribute may be applied to a function that
2514 returns a pointer and takes at least one argument of an integer type.
2515 It indicates that the returned pointer points to memory whose size is
2516 given by the function argument at @var{position-1}, or by the product
2517 of the arguments at @var{position-1} and @var{position-2}.  Meaningful
2518 sizes are positive values less than @code{PTRDIFF_MAX}.  GCC uses this
2519 information to improve the results of @code{__builtin_object_size}.
2521 The function parameter(s) denoting the allocated size are specified by
2522 one or two integer arguments supplied to the attribute.  The allocated size
2523 is either the value of the single function argument specified or the product
2524 of the two function arguments specified.  Argument numbering starts at
2525 one.
2527 For instance,
2529 @smallexample
2530 void* my_calloc (size_t, size_t) __attribute__ ((alloc_size (1, 2)));
2531 void* my_realloc (void*, size_t) __attribute__ ((alloc_size (2)));
2532 @end smallexample
2534 @noindent
2535 declares that @code{my_calloc} returns memory of the size given by
2536 the product of parameter 1 and 2 and that @code{my_realloc} returns memory
2537 of the size given by parameter 2.
2539 @item always_inline
2540 @cindex @code{always_inline} function attribute
2541 Generally, functions are not inlined unless optimization is specified.
2542 For functions declared inline, this attribute inlines the function
2543 independent of any restrictions that otherwise apply to inlining.
2544 Failure to inline such a function is diagnosed as an error.
2545 Note that if such a function is called indirectly the compiler may
2546 or may not inline it depending on optimization level and a failure
2547 to inline an indirect call may or may not be diagnosed.
2549 @item artificial
2550 @cindex @code{artificial} function attribute
2551 This attribute is useful for small inline wrappers that if possible
2552 should appear during debugging as a unit.  Depending on the debug
2553 info format it either means marking the function as artificial
2554 or using the caller location for all instructions within the inlined
2555 body.
2557 @item assume_aligned (@var{alignment})
2558 @itemx assume_aligned (@var{alignment}, @var{offset})
2559 @cindex @code{assume_aligned} function attribute
2560 The @code{assume_aligned} attribute may be applied to a function that
2561 returns a pointer.  It indicates that the returned pointer is aligned
2562 on a boundary given by @var{alignment}.  If the attribute has two
2563 arguments, the second argument is misalignment @var{offset}.  Meaningful
2564 values of @var{alignment} are powers of 2 greater than one.  Meaningful
2565 values of @var{offset} are greater than zero and less than @var{alignment}.
2567 For instance
2569 @smallexample
2570 void* my_alloc1 (size_t) __attribute__((assume_aligned (16)));
2571 void* my_alloc2 (size_t) __attribute__((assume_aligned (32, 8)));
2572 @end smallexample
2574 @noindent
2575 declares that @code{my_alloc1} returns 16-byte aligned pointers and
2576 that @code{my_alloc2} returns a pointer whose value modulo 32 is equal
2577 to 8.
2579 @item cold
2580 @cindex @code{cold} function attribute
2581 The @code{cold} attribute on functions is used to inform the compiler that
2582 the function is unlikely to be executed.  The function is optimized for
2583 size rather than speed and on many targets it is placed into a special
2584 subsection of the text section so all cold functions appear close together,
2585 improving code locality of non-cold parts of program.  The paths leading
2586 to calls of cold functions within code are marked as unlikely by the branch
2587 prediction mechanism.  It is thus useful to mark functions used to handle
2588 unlikely conditions, such as @code{perror}, as cold to improve optimization
2589 of hot functions that do call marked functions in rare occasions.
2591 When profile feedback is available, via @option{-fprofile-use}, cold functions
2592 are automatically detected and this attribute is ignored.
2594 @item const
2595 @cindex @code{const} function attribute
2596 @cindex functions that have no side effects
2597 Many functions do not examine any values except their arguments, and
2598 have no effects except to return a value.  Calls to such functions lend
2599 themselves to optimization such as common subexpression elimination.
2600 The presence of the @code{const} attribute on a function declaration 
2601 allows GCC to emit more efficient code for some calls to the function.  
2603 The @code{const} attribute imposes greater restrictions on a function's
2604 definition than the similar @code{pure} attribute below because it
2605 additionally prohibits the function from reading memory except for
2606 constant global variables.  Decorating the same function with
2607 both the @code{const} and the @code{pure} attribute is diagnosed.
2609 @cindex pointer arguments
2610 Note that a function that has pointer arguments and examines the data
2611 pointed to must @emph{not} be declared @code{const}.  Likewise, a
2612 function that calls a non-@code{const} function usually must not be
2613 @code{const}.  Because a @code{const} function cannot have any side
2614 effects it does not make sense for such a function to return @code{void}.
2615 Declaring such a function is diagnosed.
2617 @item constructor
2618 @itemx destructor
2619 @itemx constructor (@var{priority})
2620 @itemx destructor (@var{priority})
2621 @cindex @code{constructor} function attribute
2622 @cindex @code{destructor} function attribute
2623 The @code{constructor} attribute causes the function to be called
2624 automatically before execution enters @code{main ()}.  Similarly, the
2625 @code{destructor} attribute causes the function to be called
2626 automatically after @code{main ()} completes or @code{exit ()} is
2627 called.  Functions with these attributes are useful for
2628 initializing data that is used implicitly during the execution of
2629 the program.
2631 On some targets the attributes also accept an integer argument to
2632 specify a priority to control the order in which constructor and
2633 destructor functions are run.  A constructor
2634 with a smaller priority number runs before a constructor with a larger
2635 priority number; the opposite relationship holds for destructors.  So,
2636 if you have a constructor that allocates a resource and a destructor
2637 that deallocates the same resource, both functions typically have the
2638 same priority.  The priorities for constructor and destructor
2639 functions are the same as those specified for namespace-scope C++
2640 objects (@pxref{C++ Attributes}).  However, at present, the order in which
2641 constructors for C++ objects with static storage duration and functions
2642 decorated with attribute @code{constructor} are invoked is unspecified.
2643 In mixed declarations, attribute @code{init_priority} can be used to
2644 impose a specific ordering.
2646 Using the argument forms of the @code{constructor} and @code{destructor}
2647 attributes on targets where the feature is not supported is rejected with
2648 an error.
2650 @item copy
2651 @itemx copy (@var{function})
2652 @cindex @code{copy} function attribute
2653 The @code{copy} attribute applies the set of attributes with which
2654 @var{function} has been declared to the declaration of the function
2655 to which the attribute is applied.  The attribute is designed for
2656 libraries that define aliases or function resolvers that are expected
2657 to specify the same set of attributes as their targets.  The @code{copy}
2658 attribute can be used with functions, variables, or types.  However,
2659 the kind of symbol to which the attribute is applied (either function
2660 or variable) must match the kind of symbol to which the argument refers.
2661 The @code{copy} attribute copies only syntactic and semantic attributes
2662 but not attributes that affect a symbol's linkage or visibility such as
2663 @code{alias}, @code{visibility}, or @code{weak}.  The @code{deprecated}
2664 attribute is also not copied.  @xref{Common Type Attributes}.
2665 @xref{Common Variable Attributes}.
2667 For example, the @var{StrongAlias} macro below makes use of the @code{alias}
2668 and @code{copy} attributes to define an alias named @var{alloc} for function
2669 @var{allocate} declared with attributes @var{alloc_size}, @var{malloc}, and
2670 @var{nothrow}.  Thanks to the @code{__typeof__} operator the alias has
2671 the same type as the target function.  As a result of the @code{copy}
2672 attribute the alias also shares the same attributes as the target.
2674 @smallexample
2675 #define StrongAlias(TagetFunc, AliasDecl)   \
2676   extern __typeof__ (TargetFunc) AliasDecl  \
2677     __attribute__ ((alias (#TargetFunc), copy (TargetFunc)));
2679 extern __attribute__ ((alloc_size (1), malloc, nothrow))
2680   void* allocate (size_t);
2681 StrongAlias (allocate, alloc);
2682 @end smallexample
2684 @item deprecated
2685 @itemx deprecated (@var{msg})
2686 @cindex @code{deprecated} function attribute
2687 The @code{deprecated} attribute results in a warning if the function
2688 is used anywhere in the source file.  This is useful when identifying
2689 functions that are expected to be removed in a future version of a
2690 program.  The warning also includes the location of the declaration
2691 of the deprecated function, to enable users to easily find further
2692 information about why the function is deprecated, or what they should
2693 do instead.  Note that the warnings only occurs for uses:
2695 @smallexample
2696 int old_fn () __attribute__ ((deprecated));
2697 int old_fn ();
2698 int (*fn_ptr)() = old_fn;
2699 @end smallexample
2701 @noindent
2702 results in a warning on line 3 but not line 2.  The optional @var{msg}
2703 argument, which must be a string, is printed in the warning if
2704 present.
2706 The @code{deprecated} attribute can also be used for variables and
2707 types (@pxref{Variable Attributes}, @pxref{Type Attributes}.)
2709 The message attached to the attribute is affected by the setting of
2710 the @option{-fmessage-length} option.
2712 @item error ("@var{message}")
2713 @itemx warning ("@var{message}")
2714 @cindex @code{error} function attribute
2715 @cindex @code{warning} function attribute
2716 If the @code{error} or @code{warning} attribute 
2717 is used on a function declaration and a call to such a function
2718 is not eliminated through dead code elimination or other optimizations, 
2719 an error or warning (respectively) that includes @var{message} is diagnosed.  
2720 This is useful
2721 for compile-time checking, especially together with @code{__builtin_constant_p}
2722 and inline functions where checking the inline function arguments is not
2723 possible through @code{extern char [(condition) ? 1 : -1];} tricks.
2725 While it is possible to leave the function undefined and thus invoke
2726 a link failure (to define the function with
2727 a message in @code{.gnu.warning*} section),
2728 when using these attributes the problem is diagnosed
2729 earlier and with exact location of the call even in presence of inline
2730 functions or when not emitting debugging information.
2732 @item externally_visible
2733 @cindex @code{externally_visible} function attribute
2734 This attribute, attached to a global variable or function, nullifies
2735 the effect of the @option{-fwhole-program} command-line option, so the
2736 object remains visible outside the current compilation unit.
2738 If @option{-fwhole-program} is used together with @option{-flto} and 
2739 @command{gold} is used as the linker plugin, 
2740 @code{externally_visible} attributes are automatically added to functions 
2741 (not variable yet due to a current @command{gold} issue) 
2742 that are accessed outside of LTO objects according to resolution file
2743 produced by @command{gold}.
2744 For other linkers that cannot generate resolution file,
2745 explicit @code{externally_visible} attributes are still necessary.
2747 @item flatten
2748 @cindex @code{flatten} function attribute
2749 Generally, inlining into a function is limited.  For a function marked with
2750 this attribute, every call inside this function is inlined, if possible.
2751 Functions declared with attribute @code{noinline} and similar are not
2752 inlined.  Whether the function itself is considered for inlining depends
2753 on its size and the current inlining parameters.
2755 @item format (@var{archetype}, @var{string-index}, @var{first-to-check})
2756 @cindex @code{format} function attribute
2757 @cindex functions with @code{printf}, @code{scanf}, @code{strftime} or @code{strfmon} style arguments
2758 @opindex Wformat
2759 The @code{format} attribute specifies that a function takes @code{printf},
2760 @code{scanf}, @code{strftime} or @code{strfmon} style arguments that
2761 should be type-checked against a format string.  For example, the
2762 declaration:
2764 @smallexample
2765 extern int
2766 my_printf (void *my_object, const char *my_format, ...)
2767       __attribute__ ((format (printf, 2, 3)));
2768 @end smallexample
2770 @noindent
2771 causes the compiler to check the arguments in calls to @code{my_printf}
2772 for consistency with the @code{printf} style format string argument
2773 @code{my_format}.
2775 The parameter @var{archetype} determines how the format string is
2776 interpreted, and should be @code{printf}, @code{scanf}, @code{strftime},
2777 @code{gnu_printf}, @code{gnu_scanf}, @code{gnu_strftime} or
2778 @code{strfmon}.  (You can also use @code{__printf__},
2779 @code{__scanf__}, @code{__strftime__} or @code{__strfmon__}.)  On
2780 MinGW targets, @code{ms_printf}, @code{ms_scanf}, and
2781 @code{ms_strftime} are also present.
2782 @var{archetype} values such as @code{printf} refer to the formats accepted
2783 by the system's C runtime library,
2784 while values prefixed with @samp{gnu_} always refer
2785 to the formats accepted by the GNU C Library.  On Microsoft Windows
2786 targets, values prefixed with @samp{ms_} refer to the formats accepted by the
2787 @file{msvcrt.dll} library.
2788 The parameter @var{string-index}
2789 specifies which argument is the format string argument (starting
2790 from 1), while @var{first-to-check} is the number of the first
2791 argument to check against the format string.  For functions
2792 where the arguments are not available to be checked (such as
2793 @code{vprintf}), specify the third parameter as zero.  In this case the
2794 compiler only checks the format string for consistency.  For
2795 @code{strftime} formats, the third parameter is required to be zero.
2796 Since non-static C++ methods have an implicit @code{this} argument, the
2797 arguments of such methods should be counted from two, not one, when
2798 giving values for @var{string-index} and @var{first-to-check}.
2800 In the example above, the format string (@code{my_format}) is the second
2801 argument of the function @code{my_print}, and the arguments to check
2802 start with the third argument, so the correct parameters for the format
2803 attribute are 2 and 3.
2805 @opindex ffreestanding
2806 @opindex fno-builtin
2807 The @code{format} attribute allows you to identify your own functions
2808 that take format strings as arguments, so that GCC can check the
2809 calls to these functions for errors.  The compiler always (unless
2810 @option{-ffreestanding} or @option{-fno-builtin} is used) checks formats
2811 for the standard library functions @code{printf}, @code{fprintf},
2812 @code{sprintf}, @code{scanf}, @code{fscanf}, @code{sscanf}, @code{strftime},
2813 @code{vprintf}, @code{vfprintf} and @code{vsprintf} whenever such
2814 warnings are requested (using @option{-Wformat}), so there is no need to
2815 modify the header file @file{stdio.h}.  In C99 mode, the functions
2816 @code{snprintf}, @code{vsnprintf}, @code{vscanf}, @code{vfscanf} and
2817 @code{vsscanf} are also checked.  Except in strictly conforming C
2818 standard modes, the X/Open function @code{strfmon} is also checked as
2819 are @code{printf_unlocked} and @code{fprintf_unlocked}.
2820 @xref{C Dialect Options,,Options Controlling C Dialect}.
2822 For Objective-C dialects, @code{NSString} (or @code{__NSString__}) is
2823 recognized in the same context.  Declarations including these format attributes
2824 are parsed for correct syntax, however the result of checking of such format
2825 strings is not yet defined, and is not carried out by this version of the
2826 compiler.
2828 The target may also provide additional types of format checks.
2829 @xref{Target Format Checks,,Format Checks Specific to Particular
2830 Target Machines}.
2832 @item format_arg (@var{string-index})
2833 @cindex @code{format_arg} function attribute
2834 @opindex Wformat-nonliteral
2835 The @code{format_arg} attribute specifies that a function takes one or
2836 more format strings for a @code{printf}, @code{scanf}, @code{strftime} or
2837 @code{strfmon} style function and modifies it (for example, to translate
2838 it into another language), so the result can be passed to a
2839 @code{printf}, @code{scanf}, @code{strftime} or @code{strfmon} style
2840 function (with the remaining arguments to the format function the same
2841 as they would have been for the unmodified string).  Multiple
2842 @code{format_arg} attributes may be applied to the same function, each
2843 designating a distinct parameter as a format string.  For example, the
2844 declaration:
2846 @smallexample
2847 extern char *
2848 my_dgettext (char *my_domain, const char *my_format)
2849       __attribute__ ((format_arg (2)));
2850 @end smallexample
2852 @noindent
2853 causes the compiler to check the arguments in calls to a @code{printf},
2854 @code{scanf}, @code{strftime} or @code{strfmon} type function, whose
2855 format string argument is a call to the @code{my_dgettext} function, for
2856 consistency with the format string argument @code{my_format}.  If the
2857 @code{format_arg} attribute had not been specified, all the compiler
2858 could tell in such calls to format functions would be that the format
2859 string argument is not constant; this would generate a warning when
2860 @option{-Wformat-nonliteral} is used, but the calls could not be checked
2861 without the attribute.
2863 In calls to a function declared with more than one @code{format_arg}
2864 attribute, each with a distinct argument value, the corresponding
2865 actual function arguments are checked against all format strings
2866 designated by the attributes.  This capability is designed to support
2867 the GNU @code{ngettext} family of functions.
2869 The parameter @var{string-index} specifies which argument is the format
2870 string argument (starting from one).  Since non-static C++ methods have
2871 an implicit @code{this} argument, the arguments of such methods should
2872 be counted from two.
2874 The @code{format_arg} attribute allows you to identify your own
2875 functions that modify format strings, so that GCC can check the
2876 calls to @code{printf}, @code{scanf}, @code{strftime} or @code{strfmon}
2877 type function whose operands are a call to one of your own function.
2878 The compiler always treats @code{gettext}, @code{dgettext}, and
2879 @code{dcgettext} in this manner except when strict ISO C support is
2880 requested by @option{-ansi} or an appropriate @option{-std} option, or
2881 @option{-ffreestanding} or @option{-fno-builtin}
2882 is used.  @xref{C Dialect Options,,Options
2883 Controlling C Dialect}.
2885 For Objective-C dialects, the @code{format-arg} attribute may refer to an
2886 @code{NSString} reference for compatibility with the @code{format} attribute
2887 above.
2889 The target may also allow additional types in @code{format-arg} attributes.
2890 @xref{Target Format Checks,,Format Checks Specific to Particular
2891 Target Machines}.
2893 @item gnu_inline
2894 @cindex @code{gnu_inline} function attribute
2895 This attribute should be used with a function that is also declared
2896 with the @code{inline} keyword.  It directs GCC to treat the function
2897 as if it were defined in gnu90 mode even when compiling in C99 or
2898 gnu99 mode.
2900 If the function is declared @code{extern}, then this definition of the
2901 function is used only for inlining.  In no case is the function
2902 compiled as a standalone function, not even if you take its address
2903 explicitly.  Such an address becomes an external reference, as if you
2904 had only declared the function, and had not defined it.  This has
2905 almost the effect of a macro.  The way to use this is to put a
2906 function definition in a header file with this attribute, and put
2907 another copy of the function, without @code{extern}, in a library
2908 file.  The definition in the header file causes most calls to the
2909 function to be inlined.  If any uses of the function remain, they
2910 refer to the single copy in the library.  Note that the two
2911 definitions of the functions need not be precisely the same, although
2912 if they do not have the same effect your program may behave oddly.
2914 In C, if the function is neither @code{extern} nor @code{static}, then
2915 the function is compiled as a standalone function, as well as being
2916 inlined where possible.
2918 This is how GCC traditionally handled functions declared
2919 @code{inline}.  Since ISO C99 specifies a different semantics for
2920 @code{inline}, this function attribute is provided as a transition
2921 measure and as a useful feature in its own right.  This attribute is
2922 available in GCC 4.1.3 and later.  It is available if either of the
2923 preprocessor macros @code{__GNUC_GNU_INLINE__} or
2924 @code{__GNUC_STDC_INLINE__} are defined.  @xref{Inline,,An Inline
2925 Function is As Fast As a Macro}.
2927 In C++, this attribute does not depend on @code{extern} in any way,
2928 but it still requires the @code{inline} keyword to enable its special
2929 behavior.
2931 @item hot
2932 @cindex @code{hot} function attribute
2933 The @code{hot} attribute on a function is used to inform the compiler that
2934 the function is a hot spot of the compiled program.  The function is
2935 optimized more aggressively and on many targets it is placed into a special
2936 subsection of the text section so all hot functions appear close together,
2937 improving locality.
2939 When profile feedback is available, via @option{-fprofile-use}, hot functions
2940 are automatically detected and this attribute is ignored.
2942 @item ifunc ("@var{resolver}")
2943 @cindex @code{ifunc} function attribute
2944 @cindex indirect functions
2945 @cindex functions that are dynamically resolved
2946 The @code{ifunc} attribute is used to mark a function as an indirect
2947 function using the STT_GNU_IFUNC symbol type extension to the ELF
2948 standard.  This allows the resolution of the symbol value to be
2949 determined dynamically at load time, and an optimized version of the
2950 routine to be selected for the particular processor or other system
2951 characteristics determined then.  To use this attribute, first define
2952 the implementation functions available, and a resolver function that
2953 returns a pointer to the selected implementation function.  The
2954 implementation functions' declarations must match the API of the
2955 function being implemented.  The resolver should be declared to
2956 be a function taking no arguments and returning a pointer to
2957 a function of the same type as the implementation.  For example:
2959 @smallexample
2960 void *my_memcpy (void *dst, const void *src, size_t len)
2962   @dots{}
2963   return dst;
2966 static void * (*resolve_memcpy (void))(void *, const void *, size_t)
2968   return my_memcpy; // we will just always select this routine
2970 @end smallexample
2972 @noindent
2973 The exported header file declaring the function the user calls would
2974 contain:
2976 @smallexample
2977 extern void *memcpy (void *, const void *, size_t);
2978 @end smallexample
2980 @noindent
2981 allowing the user to call @code{memcpy} as a regular function, unaware of
2982 the actual implementation.  Finally, the indirect function needs to be
2983 defined in the same translation unit as the resolver function:
2985 @smallexample
2986 void *memcpy (void *, const void *, size_t)
2987      __attribute__ ((ifunc ("resolve_memcpy")));
2988 @end smallexample
2990 In C++, the @code{ifunc} attribute takes a string that is the mangled name
2991 of the resolver function.  A C++ resolver for a non-static member function
2992 of class @code{C} should be declared to return a pointer to a non-member
2993 function taking pointer to @code{C} as the first argument, followed by
2994 the same arguments as of the implementation function.  G++ checks
2995 the signatures of the two functions and issues
2996 a @option{-Wattribute-alias} warning for mismatches.  To suppress a warning
2997 for the necessary cast from a pointer to the implementation member function
2998 to the type of the corresponding non-member function use
2999 the @option{-Wno-pmf-conversions} option.  For example:
3001 @smallexample
3002 class S
3004 private:
3005   int debug_impl (int);
3006   int optimized_impl (int);
3008   typedef int Func (S*, int);
3010   static Func* resolver ();
3011 public:
3013   int interface (int);
3016 int S::debug_impl (int) @{ /* @r{@dots{}} */ @}
3017 int S::optimized_impl (int) @{ /* @r{@dots{}} */ @}
3019 S::Func* S::resolver ()
3021   int (S::*pimpl) (int)
3022     = getenv ("DEBUG") ? &S::debug_impl : &S::optimized_impl;
3024   // Cast triggers -Wno-pmf-conversions.
3025   return reinterpret_cast<Func*>(pimpl);
3028 int S::interface (int) __attribute__ ((ifunc ("_ZN1S8resolverEv")));
3029 @end smallexample
3031 Indirect functions cannot be weak.  Binutils version 2.20.1 or higher
3032 and GNU C Library version 2.11.1 are required to use this feature.
3034 @item interrupt
3035 @itemx interrupt_handler
3036 Many GCC back ends support attributes to indicate that a function is
3037 an interrupt handler, which tells the compiler to generate function
3038 entry and exit sequences that differ from those from regular
3039 functions.  The exact syntax and behavior are target-specific;
3040 refer to the following subsections for details.
3042 @item leaf
3043 @cindex @code{leaf} function attribute
3044 Calls to external functions with this attribute must return to the
3045 current compilation unit only by return or by exception handling.  In
3046 particular, a leaf function is not allowed to invoke callback functions
3047 passed to it from the current compilation unit, directly call functions
3048 exported by the unit, or @code{longjmp} into the unit.  Leaf functions
3049 might still call functions from other compilation units and thus they
3050 are not necessarily leaf in the sense that they contain no function
3051 calls at all.
3053 The attribute is intended for library functions to improve dataflow
3054 analysis.  The compiler takes the hint that any data not escaping the
3055 current compilation unit cannot be used or modified by the leaf
3056 function.  For example, the @code{sin} function is a leaf function, but
3057 @code{qsort} is not.
3059 Note that leaf functions might indirectly run a signal handler defined
3060 in the current compilation unit that uses static variables.  Similarly,
3061 when lazy symbol resolution is in effect, leaf functions might invoke
3062 indirect functions whose resolver function or implementation function is
3063 defined in the current compilation unit and uses static variables.  There
3064 is no standard-compliant way to write such a signal handler, resolver
3065 function, or implementation function, and the best that you can do is to
3066 remove the @code{leaf} attribute or mark all such static variables
3067 @code{volatile}.  Lastly, for ELF-based systems that support symbol
3068 interposition, care should be taken that functions defined in the
3069 current compilation unit do not unexpectedly interpose other symbols
3070 based on the defined standards mode and defined feature test macros;
3071 otherwise an inadvertent callback would be added.
3073 The attribute has no effect on functions defined within the current
3074 compilation unit.  This is to allow easy merging of multiple compilation
3075 units into one, for example, by using the link-time optimization.  For
3076 this reason the attribute is not allowed on types to annotate indirect
3077 calls.
3079 @item malloc
3080 @cindex @code{malloc} function attribute
3081 @cindex functions that behave like malloc
3082 This tells the compiler that a function is @code{malloc}-like, i.e.,
3083 that the pointer @var{P} returned by the function cannot alias any
3084 other pointer valid when the function returns, and moreover no
3085 pointers to valid objects occur in any storage addressed by @var{P}.
3087 Using this attribute can improve optimization.  Compiler predicts
3088 that a function with the attribute returns non-null in most cases.
3089 Functions like
3090 @code{malloc} and @code{calloc} have this property because they return
3091 a pointer to uninitialized or zeroed-out storage.  However, functions
3092 like @code{realloc} do not have this property, as they can return a
3093 pointer to storage containing pointers.
3095 @item no_icf
3096 @cindex @code{no_icf} function attribute
3097 This function attribute prevents a functions from being merged with another
3098 semantically equivalent function.
3100 @item no_instrument_function
3101 @cindex @code{no_instrument_function} function attribute
3102 @opindex finstrument-functions
3103 @opindex p
3104 @opindex pg
3105 If any of @option{-finstrument-functions}, @option{-p}, or @option{-pg} are 
3106 given, profiling function calls are
3107 generated at entry and exit of most user-compiled functions.
3108 Functions with this attribute are not so instrumented.
3110 @item no_profile_instrument_function
3111 @cindex @code{no_profile_instrument_function} function attribute
3112 The @code{no_profile_instrument_function} attribute on functions is used
3113 to inform the compiler that it should not process any profile feedback based
3114 optimization code instrumentation.
3116 @item no_reorder
3117 @cindex @code{no_reorder} function attribute
3118 Do not reorder functions or variables marked @code{no_reorder}
3119 against each other or top level assembler statements the executable.
3120 The actual order in the program will depend on the linker command
3121 line. Static variables marked like this are also not removed.
3122 This has a similar effect
3123 as the @option{-fno-toplevel-reorder} option, but only applies to the
3124 marked symbols.
3126 @item no_sanitize ("@var{sanitize_option}")
3127 @cindex @code{no_sanitize} function attribute
3128 The @code{no_sanitize} attribute on functions is used
3129 to inform the compiler that it should not do sanitization of all options
3130 mentioned in @var{sanitize_option}.  A list of values acceptable by
3131 @option{-fsanitize} option can be provided.
3133 @smallexample
3134 void __attribute__ ((no_sanitize ("alignment", "object-size")))
3135 f () @{ /* @r{Do something.} */; @}
3136 void __attribute__ ((no_sanitize ("alignment,object-size")))
3137 g () @{ /* @r{Do something.} */; @}
3138 @end smallexample
3140 @item no_sanitize_address
3141 @itemx no_address_safety_analysis
3142 @cindex @code{no_sanitize_address} function attribute
3143 The @code{no_sanitize_address} attribute on functions is used
3144 to inform the compiler that it should not instrument memory accesses
3145 in the function when compiling with the @option{-fsanitize=address} option.
3146 The @code{no_address_safety_analysis} is a deprecated alias of the
3147 @code{no_sanitize_address} attribute, new code should use
3148 @code{no_sanitize_address}.
3150 @item no_sanitize_thread
3151 @cindex @code{no_sanitize_thread} function attribute
3152 The @code{no_sanitize_thread} attribute on functions is used
3153 to inform the compiler that it should not instrument memory accesses
3154 in the function when compiling with the @option{-fsanitize=thread} option.
3156 @item no_sanitize_undefined
3157 @cindex @code{no_sanitize_undefined} function attribute
3158 The @code{no_sanitize_undefined} attribute on functions is used
3159 to inform the compiler that it should not check for undefined behavior
3160 in the function when compiling with the @option{-fsanitize=undefined} option.
3162 @item no_split_stack
3163 @cindex @code{no_split_stack} function attribute
3164 @opindex fsplit-stack
3165 If @option{-fsplit-stack} is given, functions have a small
3166 prologue which decides whether to split the stack.  Functions with the
3167 @code{no_split_stack} attribute do not have that prologue, and thus
3168 may run with only a small amount of stack space available.
3170 @item no_stack_limit
3171 @cindex @code{no_stack_limit} function attribute
3172 This attribute locally overrides the @option{-fstack-limit-register}
3173 and @option{-fstack-limit-symbol} command-line options; it has the effect
3174 of disabling stack limit checking in the function it applies to.
3176 @item noclone
3177 @cindex @code{noclone} function attribute
3178 This function attribute prevents a function from being considered for
3179 cloning---a mechanism that produces specialized copies of functions
3180 and which is (currently) performed by interprocedural constant
3181 propagation.
3183 @item noinline
3184 @cindex @code{noinline} function attribute
3185 This function attribute prevents a function from being considered for
3186 inlining.
3187 @c Don't enumerate the optimizations by name here; we try to be
3188 @c future-compatible with this mechanism.
3189 If the function does not have side effects, there are optimizations
3190 other than inlining that cause function calls to be optimized away,
3191 although the function call is live.  To keep such calls from being
3192 optimized away, put
3193 @smallexample
3194 asm ("");
3195 @end smallexample
3197 @noindent
3198 (@pxref{Extended Asm}) in the called function, to serve as a special
3199 side effect.
3201 @item noipa
3202 @cindex @code{noipa} function attribute
3203 Disable interprocedural optimizations between the function with this
3204 attribute and its callers, as if the body of the function is not available
3205 when optimizing callers and the callers are unavailable when optimizing
3206 the body.  This attribute implies @code{noinline}, @code{noclone} and
3207 @code{no_icf} attributes.    However, this attribute is not equivalent
3208 to a combination of other attributes, because its purpose is to suppress
3209 existing and future optimizations employing interprocedural analysis,
3210 including those that do not have an attribute suitable for disabling
3211 them individually.  This attribute is supported mainly for the purpose
3212 of testing the compiler.
3214 @item nonnull
3215 @itemx nonnull (@var{arg-index}, @dots{})
3216 @cindex @code{nonnull} function attribute
3217 @cindex functions with non-null pointer arguments
3218 The @code{nonnull} attribute may be applied to a function that takes at
3219 least one argument of a pointer type.  It indicates that the referenced
3220 arguments must be non-null pointers.  For instance, the declaration:
3222 @smallexample
3223 extern void *
3224 my_memcpy (void *dest, const void *src, size_t len)
3225         __attribute__((nonnull (1, 2)));
3226 @end smallexample
3228 @noindent
3229 causes the compiler to check that, in calls to @code{my_memcpy},
3230 arguments @var{dest} and @var{src} are non-null.  If the compiler
3231 determines that a null pointer is passed in an argument slot marked
3232 as non-null, and the @option{-Wnonnull} option is enabled, a warning
3233 is issued.  @xref{Warning Options}.  Unless disabled by
3234 the @option{-fno-delete-null-pointer-checks} option the compiler may
3235 also perform optimizations based on the knowledge that certain function
3236 arguments cannot be null. In addition,
3237 the @option{-fisolate-erroneous-paths-attribute} option can be specified
3238 to have GCC transform calls with null arguments to non-null functions
3239 into traps. @xref{Optimize Options}.
3241 If no @var{arg-index} is given to the @code{nonnull} attribute,
3242 all pointer arguments are marked as non-null.  To illustrate, the
3243 following declaration is equivalent to the previous example:
3245 @smallexample
3246 extern void *
3247 my_memcpy (void *dest, const void *src, size_t len)
3248         __attribute__((nonnull));
3249 @end smallexample
3251 @item noplt
3252 @cindex @code{noplt} function attribute
3253 The @code{noplt} attribute is the counterpart to option @option{-fno-plt}.
3254 Calls to functions marked with this attribute in position-independent code
3255 do not use the PLT.
3257 @smallexample
3258 @group
3259 /* Externally defined function foo.  */
3260 int foo () __attribute__ ((noplt));
3263 main (/* @r{@dots{}} */)
3265   /* @r{@dots{}} */
3266   foo ();
3267   /* @r{@dots{}} */
3269 @end group
3270 @end smallexample
3272 The @code{noplt} attribute on function @code{foo}
3273 tells the compiler to assume that
3274 the function @code{foo} is externally defined and that the call to
3275 @code{foo} must avoid the PLT
3276 in position-independent code.
3278 In position-dependent code, a few targets also convert calls to
3279 functions that are marked to not use the PLT to use the GOT instead.
3281 @item noreturn
3282 @cindex @code{noreturn} function attribute
3283 @cindex functions that never return
3284 A few standard library functions, such as @code{abort} and @code{exit},
3285 cannot return.  GCC knows this automatically.  Some programs define
3286 their own functions that never return.  You can declare them
3287 @code{noreturn} to tell the compiler this fact.  For example,
3289 @smallexample
3290 @group
3291 void fatal () __attribute__ ((noreturn));
3293 void
3294 fatal (/* @r{@dots{}} */)
3296   /* @r{@dots{}} */ /* @r{Print error message.} */ /* @r{@dots{}} */
3297   exit (1);
3299 @end group
3300 @end smallexample
3302 The @code{noreturn} keyword tells the compiler to assume that
3303 @code{fatal} cannot return.  It can then optimize without regard to what
3304 would happen if @code{fatal} ever did return.  This makes slightly
3305 better code.  More importantly, it helps avoid spurious warnings of
3306 uninitialized variables.
3308 The @code{noreturn} keyword does not affect the exceptional path when that
3309 applies: a @code{noreturn}-marked function may still return to the caller
3310 by throwing an exception or calling @code{longjmp}.
3312 In order to preserve backtraces, GCC will never turn calls to
3313 @code{noreturn} functions into tail calls.
3315 Do not assume that registers saved by the calling function are
3316 restored before calling the @code{noreturn} function.
3318 It does not make sense for a @code{noreturn} function to have a return
3319 type other than @code{void}.
3321 @item nothrow
3322 @cindex @code{nothrow} function attribute
3323 The @code{nothrow} attribute is used to inform the compiler that a
3324 function cannot throw an exception.  For example, most functions in
3325 the standard C library can be guaranteed not to throw an exception
3326 with the notable exceptions of @code{qsort} and @code{bsearch} that
3327 take function pointer arguments.
3329 @item optimize (@var{level}, @dots{})
3330 @item optimize (@var{string}, @dots{})
3331 @cindex @code{optimize} function attribute
3332 The @code{optimize} attribute is used to specify that a function is to
3333 be compiled with different optimization options than specified on the
3334 command line.  Valid arguments are constant non-negative integers and
3335 strings.  Each numeric argument specifies an optimization @var{level}.
3336 Each @var{string} argument consists of one or more comma-separated
3337 substrings.  Each substring that begins with the letter @code{O} refers
3338 to an optimization option such as @option{-O0} or @option{-Os}.  Other
3339 substrings are taken as suffixes to the @code{-f} prefix jointly
3340 forming the name of an optimization option.  @xref{Optimize Options}.
3342 @samp{#pragma GCC optimize} can be used to set optimization options
3343 for more than one function.  @xref{Function Specific Option Pragmas},
3344 for details about the pragma.
3346 Providing multiple strings as arguments separated by commas to specify
3347 multiple options is equivalent to separating the option suffixes with
3348 a comma (@samp{,}) within a single string.  Spaces are not permitted
3349 within the strings.
3351 Not every optimization option that starts with the @var{-f} prefix
3352 specified by the attribute necessarily has an effect on the function.
3353 The @code{optimize} attribute should be used for debugging purposes only.
3354 It is not suitable in production code.
3356 @item patchable_function_entry
3357 @cindex @code{patchable_function_entry} function attribute
3358 @cindex extra NOP instructions at the function entry point
3359 In case the target's text segment can be made writable at run time by
3360 any means, padding the function entry with a number of NOPs can be
3361 used to provide a universal tool for instrumentation.
3363 The @code{patchable_function_entry} function attribute can be used to
3364 change the number of NOPs to any desired value.  The two-value syntax
3365 is the same as for the command-line switch
3366 @option{-fpatchable-function-entry=N,M}, generating @var{N} NOPs, with
3367 the function entry point before the @var{M}th NOP instruction.
3368 @var{M} defaults to 0 if omitted e.g.@: function entry point is before
3369 the first NOP.
3371 If patchable function entries are enabled globally using the command-line
3372 option @option{-fpatchable-function-entry=N,M}, then you must disable
3373 instrumentation on all functions that are part of the instrumentation
3374 framework with the attribute @code{patchable_function_entry (0)}
3375 to prevent recursion.
3377 @item pure
3378 @cindex @code{pure} function attribute
3379 @cindex functions that have no side effects
3380 Many functions have no effects except the return value and their
3381 return value depends only on the parameters and/or global variables.
3382 Calls to such functions can be subject
3383 to common subexpression elimination and loop optimization just as an
3384 arithmetic operator would be.  These functions should be declared
3385 with the attribute @code{pure}.  For example,
3387 @smallexample
3388 int square (int) __attribute__ ((pure));
3389 @end smallexample
3391 @noindent
3392 says that the hypothetical function @code{square} is safe to call
3393 fewer times than the program says.
3395 Some common examples of pure functions are @code{strlen} or @code{memcmp}.
3396 Interesting non-pure functions are functions with infinite loops or those
3397 depending on volatile memory or other system resource, that may change between
3398 two consecutive calls (such as @code{feof} in a multithreading environment).
3400 The @code{pure} attribute imposes similar but looser restrictions on
3401 a function's definition than the @code{const} attribute: @code{pure}
3402 allows the function to read any non-volatile memory, not just
3403 constant global variables.  Decorating the same function with
3404 both the @code{pure} and the @code{const} attribute is diagnosed.
3405 Because a @code{pure} function cannot have any side effects it does not
3406 make sense for such a function to return @code{void}.  Declaring such
3407 a function is diagnosed.
3409 @item returns_nonnull
3410 @cindex @code{returns_nonnull} function attribute
3411 The @code{returns_nonnull} attribute specifies that the function
3412 return value should be a non-null pointer.  For instance, the declaration:
3414 @smallexample
3415 extern void *
3416 mymalloc (size_t len) __attribute__((returns_nonnull));
3417 @end smallexample
3419 @noindent
3420 lets the compiler optimize callers based on the knowledge
3421 that the return value will never be null.
3423 @item returns_twice
3424 @cindex @code{returns_twice} function attribute
3425 @cindex functions that return more than once
3426 The @code{returns_twice} attribute tells the compiler that a function may
3427 return more than one time.  The compiler ensures that all registers
3428 are dead before calling such a function and emits a warning about
3429 the variables that may be clobbered after the second return from the
3430 function.  Examples of such functions are @code{setjmp} and @code{vfork}.
3431 The @code{longjmp}-like counterpart of such function, if any, might need
3432 to be marked with the @code{noreturn} attribute.
3434 @item section ("@var{section-name}")
3435 @cindex @code{section} function attribute
3436 @cindex functions in arbitrary sections
3437 Normally, the compiler places the code it generates in the @code{text} section.
3438 Sometimes, however, you need additional sections, or you need certain
3439 particular functions to appear in special sections.  The @code{section}
3440 attribute specifies that a function lives in a particular section.
3441 For example, the declaration:
3443 @smallexample
3444 extern void foobar (void) __attribute__ ((section ("bar")));
3445 @end smallexample
3447 @noindent
3448 puts the function @code{foobar} in the @code{bar} section.
3450 Some file formats do not support arbitrary sections so the @code{section}
3451 attribute is not available on all platforms.
3452 If you need to map the entire contents of a module to a particular
3453 section, consider using the facilities of the linker instead.
3455 @item sentinel
3456 @itemx sentinel (@var{position})
3457 @cindex @code{sentinel} function attribute
3458 This function attribute indicates that an argument in a call to the function
3459 is expected to be an explicit @code{NULL}.  The attribute is only valid on
3460 variadic functions.  By default, the sentinel is expected to be the last
3461 argument of the function call.  If the optional @var{position} argument
3462 is specified to the attribute, the sentinel must be located at
3463 @var{position} counting backwards from the end of the argument list.
3465 @smallexample
3466 __attribute__ ((sentinel))
3467 is equivalent to
3468 __attribute__ ((sentinel(0)))
3469 @end smallexample
3471 The attribute is automatically set with a position of 0 for the built-in
3472 functions @code{execl} and @code{execlp}.  The built-in function
3473 @code{execle} has the attribute set with a position of 1.
3475 A valid @code{NULL} in this context is defined as zero with any object
3476 pointer type.  If your system defines the @code{NULL} macro with
3477 an integer type then you need to add an explicit cast.  During
3478 installation GCC replaces the system @code{<stddef.h>} header with
3479 a copy that redefines NULL appropriately.
3481 The warnings for missing or incorrect sentinels are enabled with
3482 @option{-Wformat}.
3484 @item simd
3485 @itemx simd("@var{mask}")
3486 @cindex @code{simd} function attribute
3487 This attribute enables creation of one or more function versions that
3488 can process multiple arguments using SIMD instructions from a
3489 single invocation.  Specifying this attribute allows compiler to
3490 assume that such versions are available at link time (provided
3491 in the same or another translation unit).  Generated versions are
3492 target-dependent and described in the corresponding Vector ABI document.  For
3493 x86_64 target this document can be found
3494 @w{@uref{https://sourceware.org/glibc/wiki/libmvec?action=AttachFile&do=view&target=VectorABI.txt,here}}.
3496 The optional argument @var{mask} may have the value
3497 @code{notinbranch} or @code{inbranch},
3498 and instructs the compiler to generate non-masked or masked
3499 clones correspondingly. By default, all clones are generated.
3501 If the attribute is specified and @code{#pragma omp declare simd} is
3502 present on a declaration and the @option{-fopenmp} or @option{-fopenmp-simd}
3503 switch is specified, then the attribute is ignored.
3505 @item stack_protect
3506 @cindex @code{stack_protect} function attribute
3507 This attribute adds stack protection code to the function if 
3508 flags @option{-fstack-protector}, @option{-fstack-protector-strong}
3509 or @option{-fstack-protector-explicit} are set.
3511 @item target (@var{string}, @dots{})
3512 @cindex @code{target} function attribute
3513 Multiple target back ends implement the @code{target} attribute
3514 to specify that a function is to
3515 be compiled with different target options than specified on the
3516 command line.  One or more strings can be provided as arguments.
3517 Each string consists of one or more comma-separated suffixes to
3518 the @code{-m} prefix jointly forming the name of a machine-dependent
3519 option.  @xref{Submodel Options,,Machine-Dependent Options}.
3521 The @code{target} attribute can be used for instance to have a function
3522 compiled with a different ISA (instruction set architecture) than the
3523 default.  @samp{#pragma GCC target} can be used to specify target-specific
3524 options for more than one function.  @xref{Function Specific Option Pragmas},
3525 for details about the pragma.
3527 For instance, on an x86, you could declare one function with the
3528 @code{target("sse4.1,arch=core2")} attribute and another with
3529 @code{target("sse4a,arch=amdfam10")}.  This is equivalent to
3530 compiling the first function with @option{-msse4.1} and
3531 @option{-march=core2} options, and the second function with
3532 @option{-msse4a} and @option{-march=amdfam10} options.  It is up to you
3533 to make sure that a function is only invoked on a machine that
3534 supports the particular ISA it is compiled for (for example by using
3535 @code{cpuid} on x86 to determine what feature bits and architecture
3536 family are used).
3538 @smallexample
3539 int core2_func (void) __attribute__ ((__target__ ("arch=core2")));
3540 int sse3_func (void) __attribute__ ((__target__ ("sse3")));
3541 @end smallexample
3543 Providing multiple strings as arguments separated by commas to specify
3544 multiple options is equivalent to separating the option suffixes with
3545 a comma (@samp{,}) within a single string.  Spaces are not permitted
3546 within the strings.
3548 The options supported are specific to each target; refer to @ref{x86
3549 Function Attributes}, @ref{PowerPC Function Attributes},
3550 @ref{ARM Function Attributes}, @ref{AArch64 Function Attributes},
3551 @ref{Nios II Function Attributes}, and @ref{S/390 Function Attributes}
3552 for details.
3554 @item target_clones (@var{options})
3555 @cindex @code{target_clones} function attribute
3556 The @code{target_clones} attribute is used to specify that a function
3557 be cloned into multiple versions compiled with different target options
3558 than specified on the command line.  The supported options and restrictions
3559 are the same as for @code{target} attribute.
3561 For instance, on an x86, you could compile a function with
3562 @code{target_clones("sse4.1,avx")}.  GCC creates two function clones,
3563 one compiled with @option{-msse4.1} and another with @option{-mavx}.
3565 On a PowerPC, you can compile a function with
3566 @code{target_clones("cpu=power9,default")}.  GCC will create two
3567 function clones, one compiled with @option{-mcpu=power9} and another
3568 with the default options.  GCC must be configured to use GLIBC 2.23 or
3569 newer in order to use the @code{target_clones} attribute.
3571 It also creates a resolver function (see
3572 the @code{ifunc} attribute above) that dynamically selects a clone
3573 suitable for current architecture.  The resolver is created only if there
3574 is a usage of a function with @code{target_clones} attribute.
3576 @item unused
3577 @cindex @code{unused} function attribute
3578 This attribute, attached to a function, means that the function is meant
3579 to be possibly unused.  GCC does not produce a warning for this
3580 function.
3582 @item used
3583 @cindex @code{used} function attribute
3584 This attribute, attached to a function, means that code must be emitted
3585 for the function even if it appears that the function is not referenced.
3586 This is useful, for example, when the function is referenced only in
3587 inline assembly.
3589 When applied to a member function of a C++ class template, the
3590 attribute also means that the function is instantiated if the
3591 class itself is instantiated.
3593 @item visibility ("@var{visibility_type}")
3594 @cindex @code{visibility} function attribute
3595 This attribute affects the linkage of the declaration to which it is attached.
3596 It can be applied to variables (@pxref{Common Variable Attributes}) and types
3597 (@pxref{Common Type Attributes}) as well as functions.
3599 There are four supported @var{visibility_type} values: default,
3600 hidden, protected or internal visibility.
3602 @smallexample
3603 void __attribute__ ((visibility ("protected")))
3604 f () @{ /* @r{Do something.} */; @}
3605 int i __attribute__ ((visibility ("hidden")));
3606 @end smallexample
3608 The possible values of @var{visibility_type} correspond to the
3609 visibility settings in the ELF gABI.
3611 @table @code
3612 @c keep this list of visibilities in alphabetical order.
3614 @item default
3615 Default visibility is the normal case for the object file format.
3616 This value is available for the visibility attribute to override other
3617 options that may change the assumed visibility of entities.
3619 On ELF, default visibility means that the declaration is visible to other
3620 modules and, in shared libraries, means that the declared entity may be
3621 overridden.
3623 On Darwin, default visibility means that the declaration is visible to
3624 other modules.
3626 Default visibility corresponds to ``external linkage'' in the language.
3628 @item hidden
3629 Hidden visibility indicates that the entity declared has a new
3630 form of linkage, which we call ``hidden linkage''.  Two
3631 declarations of an object with hidden linkage refer to the same object
3632 if they are in the same shared object.
3634 @item internal
3635 Internal visibility is like hidden visibility, but with additional
3636 processor specific semantics.  Unless otherwise specified by the
3637 psABI, GCC defines internal visibility to mean that a function is
3638 @emph{never} called from another module.  Compare this with hidden
3639 functions which, while they cannot be referenced directly by other
3640 modules, can be referenced indirectly via function pointers.  By
3641 indicating that a function cannot be called from outside the module,
3642 GCC may for instance omit the load of a PIC register since it is known
3643 that the calling function loaded the correct value.
3645 @item protected
3646 Protected visibility is like default visibility except that it
3647 indicates that references within the defining module bind to the
3648 definition in that module.  That is, the declared entity cannot be
3649 overridden by another module.
3651 @end table
3653 All visibilities are supported on many, but not all, ELF targets
3654 (supported when the assembler supports the @samp{.visibility}
3655 pseudo-op).  Default visibility is supported everywhere.  Hidden
3656 visibility is supported on Darwin targets.
3658 The visibility attribute should be applied only to declarations that
3659 would otherwise have external linkage.  The attribute should be applied
3660 consistently, so that the same entity should not be declared with
3661 different settings of the attribute.
3663 In C++, the visibility attribute applies to types as well as functions
3664 and objects, because in C++ types have linkage.  A class must not have
3665 greater visibility than its non-static data member types and bases,
3666 and class members default to the visibility of their class.  Also, a
3667 declaration without explicit visibility is limited to the visibility
3668 of its type.
3670 In C++, you can mark member functions and static member variables of a
3671 class with the visibility attribute.  This is useful if you know a
3672 particular method or static member variable should only be used from
3673 one shared object; then you can mark it hidden while the rest of the
3674 class has default visibility.  Care must be taken to avoid breaking
3675 the One Definition Rule; for example, it is usually not useful to mark
3676 an inline method as hidden without marking the whole class as hidden.
3678 A C++ namespace declaration can also have the visibility attribute.
3680 @smallexample
3681 namespace nspace1 __attribute__ ((visibility ("protected")))
3682 @{ /* @r{Do something.} */; @}
3683 @end smallexample
3685 This attribute applies only to the particular namespace body, not to
3686 other definitions of the same namespace; it is equivalent to using
3687 @samp{#pragma GCC visibility} before and after the namespace
3688 definition (@pxref{Visibility Pragmas}).
3690 In C++, if a template argument has limited visibility, this
3691 restriction is implicitly propagated to the template instantiation.
3692 Otherwise, template instantiations and specializations default to the
3693 visibility of their template.
3695 If both the template and enclosing class have explicit visibility, the
3696 visibility from the template is used.
3698 @item warn_unused_result
3699 @cindex @code{warn_unused_result} function attribute
3700 The @code{warn_unused_result} attribute causes a warning to be emitted
3701 if a caller of the function with this attribute does not use its
3702 return value.  This is useful for functions where not checking
3703 the result is either a security problem or always a bug, such as
3704 @code{realloc}.
3706 @smallexample
3707 int fn () __attribute__ ((warn_unused_result));
3708 int foo ()
3710   if (fn () < 0) return -1;
3711   fn ();
3712   return 0;
3714 @end smallexample
3716 @noindent
3717 results in warning on line 5.
3719 @item weak
3720 @cindex @code{weak} function attribute
3721 The @code{weak} attribute causes the declaration to be emitted as a weak
3722 symbol rather than a global.  This is primarily useful in defining
3723 library functions that can be overridden in user code, though it can
3724 also be used with non-function declarations.  Weak symbols are supported
3725 for ELF targets, and also for a.out targets when using the GNU assembler
3726 and linker.
3728 @item weakref
3729 @itemx weakref ("@var{target}")
3730 @cindex @code{weakref} function attribute
3731 The @code{weakref} attribute marks a declaration as a weak reference.
3732 Without arguments, it should be accompanied by an @code{alias} attribute
3733 naming the target symbol.  Optionally, the @var{target} may be given as
3734 an argument to @code{weakref} itself.  In either case, @code{weakref}
3735 implicitly marks the declaration as @code{weak}.  Without a
3736 @var{target}, given as an argument to @code{weakref} or to @code{alias},
3737 @code{weakref} is equivalent to @code{weak}.
3739 @smallexample
3740 static int x() __attribute__ ((weakref ("y")));
3741 /* is equivalent to... */
3742 static int x() __attribute__ ((weak, weakref, alias ("y")));
3743 /* and to... */
3744 static int x() __attribute__ ((weakref));
3745 static int x() __attribute__ ((alias ("y")));
3746 @end smallexample
3748 A weak reference is an alias that does not by itself require a
3749 definition to be given for the target symbol.  If the target symbol is
3750 only referenced through weak references, then it becomes a @code{weak}
3751 undefined symbol.  If it is directly referenced, however, then such
3752 strong references prevail, and a definition is required for the
3753 symbol, not necessarily in the same translation unit.
3755 The effect is equivalent to moving all references to the alias to a
3756 separate translation unit, renaming the alias to the aliased symbol,
3757 declaring it as weak, compiling the two separate translation units and
3758 performing a link with relocatable output (ie: @code{ld -r}) on them.
3760 At present, a declaration to which @code{weakref} is attached can
3761 only be @code{static}.
3764 @end table
3766 @c This is the end of the target-independent attribute table
3768 @node AArch64 Function Attributes
3769 @subsection AArch64 Function Attributes
3771 The following target-specific function attributes are available for the
3772 AArch64 target.  For the most part, these options mirror the behavior of
3773 similar command-line options (@pxref{AArch64 Options}), but on a
3774 per-function basis.
3776 @table @code
3777 @item general-regs-only
3778 @cindex @code{general-regs-only} function attribute, AArch64
3779 Indicates that no floating-point or Advanced SIMD registers should be
3780 used when generating code for this function.  If the function explicitly
3781 uses floating-point code, then the compiler gives an error.  This is
3782 the same behavior as that of the command-line option
3783 @option{-mgeneral-regs-only}.
3785 @item fix-cortex-a53-835769
3786 @cindex @code{fix-cortex-a53-835769} function attribute, AArch64
3787 Indicates that the workaround for the Cortex-A53 erratum 835769 should be
3788 applied to this function.  To explicitly disable the workaround for this
3789 function specify the negated form: @code{no-fix-cortex-a53-835769}.
3790 This corresponds to the behavior of the command line options
3791 @option{-mfix-cortex-a53-835769} and @option{-mno-fix-cortex-a53-835769}.
3793 @item cmodel=
3794 @cindex @code{cmodel=} function attribute, AArch64
3795 Indicates that code should be generated for a particular code model for
3796 this function.  The behavior and permissible arguments are the same as
3797 for the command line option @option{-mcmodel=}.
3799 @item strict-align
3800 @itemx no-strict-align
3801 @cindex @code{strict-align} function attribute, AArch64
3802 @code{strict-align} indicates that the compiler should not assume that unaligned
3803 memory references are handled by the system.  To allow the compiler to assume
3804 that aligned memory references are handled by the system, the inverse attribute
3805 @code{no-strict-align} can be specified.  The behavior is same as for the
3806 command-line option @option{-mstrict-align} and @option{-mno-strict-align}.
3808 @item omit-leaf-frame-pointer
3809 @cindex @code{omit-leaf-frame-pointer} function attribute, AArch64
3810 Indicates that the frame pointer should be omitted for a leaf function call.
3811 To keep the frame pointer, the inverse attribute
3812 @code{no-omit-leaf-frame-pointer} can be specified.  These attributes have
3813 the same behavior as the command-line options @option{-momit-leaf-frame-pointer}
3814 and @option{-mno-omit-leaf-frame-pointer}.
3816 @item tls-dialect=
3817 @cindex @code{tls-dialect=} function attribute, AArch64
3818 Specifies the TLS dialect to use for this function.  The behavior and
3819 permissible arguments are the same as for the command-line option
3820 @option{-mtls-dialect=}.
3822 @item arch=
3823 @cindex @code{arch=} function attribute, AArch64
3824 Specifies the architecture version and architectural extensions to use
3825 for this function.  The behavior and permissible arguments are the same as
3826 for the @option{-march=} command-line option.
3828 @item tune=
3829 @cindex @code{tune=} function attribute, AArch64
3830 Specifies the core for which to tune the performance of this function.
3831 The behavior and permissible arguments are the same as for the @option{-mtune=}
3832 command-line option.
3834 @item cpu=
3835 @cindex @code{cpu=} function attribute, AArch64
3836 Specifies the core for which to tune the performance of this function and also
3837 whose architectural features to use.  The behavior and valid arguments are the
3838 same as for the @option{-mcpu=} command-line option.
3840 @item sign-return-address
3841 @cindex @code{sign-return-address} function attribute, AArch64
3842 Select the function scope on which return address signing will be applied.  The
3843 behavior and permissible arguments are the same as for the command-line option
3844 @option{-msign-return-address=}.  The default value is @code{none}.
3846 @end table
3848 The above target attributes can be specified as follows:
3850 @smallexample
3851 __attribute__((target("@var{attr-string}")))
3853 f (int a)
3855   return a + 5;
3857 @end smallexample
3859 where @code{@var{attr-string}} is one of the attribute strings specified above.
3861 Additionally, the architectural extension string may be specified on its
3862 own.  This can be used to turn on and off particular architectural extensions
3863 without having to specify a particular architecture version or core.  Example:
3865 @smallexample
3866 __attribute__((target("+crc+nocrypto")))
3868 foo (int a)
3870   return a + 5;
3872 @end smallexample
3874 In this example @code{target("+crc+nocrypto")} enables the @code{crc}
3875 extension and disables the @code{crypto} extension for the function @code{foo}
3876 without modifying an existing @option{-march=} or @option{-mcpu} option.
3878 Multiple target function attributes can be specified by separating them with
3879 a comma.  For example:
3880 @smallexample
3881 __attribute__((target("arch=armv8-a+crc+crypto,tune=cortex-a53")))
3883 foo (int a)
3885   return a + 5;
3887 @end smallexample
3889 is valid and compiles function @code{foo} for ARMv8-A with @code{crc}
3890 and @code{crypto} extensions and tunes it for @code{cortex-a53}.
3892 @subsubsection Inlining rules
3893 Specifying target attributes on individual functions or performing link-time
3894 optimization across translation units compiled with different target options
3895 can affect function inlining rules:
3897 In particular, a caller function can inline a callee function only if the
3898 architectural features available to the callee are a subset of the features
3899 available to the caller.
3900 For example: A function @code{foo} compiled with @option{-march=armv8-a+crc},
3901 or tagged with the equivalent @code{arch=armv8-a+crc} attribute,
3902 can inline a function @code{bar} compiled with @option{-march=armv8-a+nocrc}
3903 because the all the architectural features that function @code{bar} requires
3904 are available to function @code{foo}.  Conversely, function @code{bar} cannot
3905 inline function @code{foo}.
3907 Additionally inlining a function compiled with @option{-mstrict-align} into a
3908 function compiled without @code{-mstrict-align} is not allowed.
3909 However, inlining a function compiled without @option{-mstrict-align} into a
3910 function compiled with @option{-mstrict-align} is allowed.
3912 Note that CPU tuning options and attributes such as the @option{-mcpu=},
3913 @option{-mtune=} do not inhibit inlining unless the CPU specified by the
3914 @option{-mcpu=} option or the @code{cpu=} attribute conflicts with the
3915 architectural feature rules specified above.
3917 @node ARC Function Attributes
3918 @subsection ARC Function Attributes
3920 These function attributes are supported by the ARC back end:
3922 @table @code
3923 @item interrupt
3924 @cindex @code{interrupt} function attribute, ARC
3925 Use this attribute to indicate
3926 that the specified function is an interrupt handler.  The compiler generates
3927 function entry and exit sequences suitable for use in an interrupt handler
3928 when this attribute is present.
3930 On the ARC, you must specify the kind of interrupt to be handled
3931 in a parameter to the interrupt attribute like this:
3933 @smallexample
3934 void f () __attribute__ ((interrupt ("ilink1")));
3935 @end smallexample
3937 Permissible values for this parameter are: @w{@code{ilink1}} and
3938 @w{@code{ilink2}}.
3940 @item long_call
3941 @itemx medium_call
3942 @itemx short_call
3943 @cindex @code{long_call} function attribute, ARC
3944 @cindex @code{medium_call} function attribute, ARC
3945 @cindex @code{short_call} function attribute, ARC
3946 @cindex indirect calls, ARC
3947 These attributes specify how a particular function is called.
3948 These attributes override the
3949 @option{-mlong-calls} and @option{-mmedium-calls} (@pxref{ARC Options})
3950 command-line switches and @code{#pragma long_calls} settings.
3952 For ARC, a function marked with the @code{long_call} attribute is
3953 always called using register-indirect jump-and-link instructions,
3954 thereby enabling the called function to be placed anywhere within the
3955 32-bit address space.  A function marked with the @code{medium_call}
3956 attribute will always be close enough to be called with an unconditional
3957 branch-and-link instruction, which has a 25-bit offset from
3958 the call site.  A function marked with the @code{short_call}
3959 attribute will always be close enough to be called with a conditional
3960 branch-and-link instruction, which has a 21-bit offset from
3961 the call site.
3963 @item jli_always
3964 @cindex @code{jli_always} function attribute, ARC
3965 Forces a particular function to be called using @code{jli}
3966 instruction.  The @code{jli} instruction makes use of a table stored
3967 into @code{.jlitab} section, which holds the location of the functions
3968 which are addressed using this instruction.
3970 @item jli_fixed
3971 @cindex @code{jli_fixed} function attribute, ARC
3972 Identical like the above one, but the location of the function in the
3973 @code{jli} table is known and given as an attribute parameter.
3975 @item secure_call
3976 @cindex @code{secure_call} function attribute, ARC
3977 This attribute allows one to mark secure-code functions that are
3978 callable from normal mode.  The location of the secure call function
3979 into the @code{sjli} table needs to be passed as argument.
3981 @end table
3983 @node ARM Function Attributes
3984 @subsection ARM Function Attributes
3986 These function attributes are supported for ARM targets:
3988 @table @code
3989 @item interrupt
3990 @cindex @code{interrupt} function attribute, ARM
3991 Use this attribute to indicate
3992 that the specified function is an interrupt handler.  The compiler generates
3993 function entry and exit sequences suitable for use in an interrupt handler
3994 when this attribute is present.
3996 You can specify the kind of interrupt to be handled by
3997 adding an optional parameter to the interrupt attribute like this:
3999 @smallexample
4000 void f () __attribute__ ((interrupt ("IRQ")));
4001 @end smallexample
4003 @noindent
4004 Permissible values for this parameter are: @code{IRQ}, @code{FIQ},
4005 @code{SWI}, @code{ABORT} and @code{UNDEF}.
4007 On ARMv7-M the interrupt type is ignored, and the attribute means the function
4008 may be called with a word-aligned stack pointer.
4010 @item isr
4011 @cindex @code{isr} function attribute, ARM
4012 Use this attribute on ARM to write Interrupt Service Routines. This is an
4013 alias to the @code{interrupt} attribute above.
4015 @item long_call
4016 @itemx short_call
4017 @cindex @code{long_call} function attribute, ARM
4018 @cindex @code{short_call} function attribute, ARM
4019 @cindex indirect calls, ARM
4020 These attributes specify how a particular function is called.
4021 These attributes override the
4022 @option{-mlong-calls} (@pxref{ARM Options})
4023 command-line switch and @code{#pragma long_calls} settings.  For ARM, the
4024 @code{long_call} attribute indicates that the function might be far
4025 away from the call site and require a different (more expensive)
4026 calling sequence.   The @code{short_call} attribute always places
4027 the offset to the function from the call site into the @samp{BL}
4028 instruction directly.
4030 @item naked
4031 @cindex @code{naked} function attribute, ARM
4032 This attribute allows the compiler to construct the
4033 requisite function declaration, while allowing the body of the
4034 function to be assembly code. The specified function will not have
4035 prologue/epilogue sequences generated by the compiler. Only basic
4036 @code{asm} statements can safely be included in naked functions
4037 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
4038 basic @code{asm} and C code may appear to work, they cannot be
4039 depended upon to work reliably and are not supported.
4041 @item pcs
4042 @cindex @code{pcs} function attribute, ARM
4044 The @code{pcs} attribute can be used to control the calling convention
4045 used for a function on ARM.  The attribute takes an argument that specifies
4046 the calling convention to use.
4048 When compiling using the AAPCS ABI (or a variant of it) then valid
4049 values for the argument are @code{"aapcs"} and @code{"aapcs-vfp"}.  In
4050 order to use a variant other than @code{"aapcs"} then the compiler must
4051 be permitted to use the appropriate co-processor registers (i.e., the
4052 VFP registers must be available in order to use @code{"aapcs-vfp"}).
4053 For example,
4055 @smallexample
4056 /* Argument passed in r0, and result returned in r0+r1.  */
4057 double f2d (float) __attribute__((pcs("aapcs")));
4058 @end smallexample
4060 Variadic functions always use the @code{"aapcs"} calling convention and
4061 the compiler rejects attempts to specify an alternative.
4063 @item target (@var{options})
4064 @cindex @code{target} function attribute
4065 As discussed in @ref{Common Function Attributes}, this attribute 
4066 allows specification of target-specific compilation options.
4068 On ARM, the following options are allowed:
4070 @table @samp
4071 @item thumb
4072 @cindex @code{target("thumb")} function attribute, ARM
4073 Force code generation in the Thumb (T16/T32) ISA, depending on the
4074 architecture level.
4076 @item arm
4077 @cindex @code{target("arm")} function attribute, ARM
4078 Force code generation in the ARM (A32) ISA.
4080 Functions from different modes can be inlined in the caller's mode.
4082 @item fpu=
4083 @cindex @code{target("fpu=")} function attribute, ARM
4084 Specifies the fpu for which to tune the performance of this function.
4085 The behavior and permissible arguments are the same as for the @option{-mfpu=}
4086 command-line option.
4088 @item arch=
4089 @cindex @code{arch=} function attribute, ARM
4090 Specifies the architecture version and architectural extensions to use
4091 for this function.  The behavior and permissible arguments are the same as
4092 for the @option{-march=} command-line option.
4094 The above target attributes can be specified as follows:
4096 @smallexample
4097 __attribute__((target("arch=armv8-a+crc")))
4099 f (int a)
4101   return a + 5;
4103 @end smallexample
4105 Additionally, the architectural extension string may be specified on its
4106 own.  This can be used to turn on and off particular architectural extensions
4107 without having to specify a particular architecture version or core.  Example:
4109 @smallexample
4110 __attribute__((target("+crc+nocrypto")))
4112 foo (int a)
4114   return a + 5;
4116 @end smallexample
4118 In this example @code{target("+crc+nocrypto")} enables the @code{crc}
4119 extension and disables the @code{crypto} extension for the function @code{foo}
4120 without modifying an existing @option{-march=} or @option{-mcpu} option.
4122 @end table
4124 @end table
4126 @node AVR Function Attributes
4127 @subsection AVR Function Attributes
4129 These function attributes are supported by the AVR back end:
4131 @table @code
4132 @item interrupt
4133 @cindex @code{interrupt} function attribute, AVR
4134 Use this attribute to indicate
4135 that the specified function is an interrupt handler.  The compiler generates
4136 function entry and exit sequences suitable for use in an interrupt handler
4137 when this attribute is present.
4139 On the AVR, the hardware globally disables interrupts when an
4140 interrupt is executed.  The first instruction of an interrupt handler
4141 declared with this attribute is a @code{SEI} instruction to
4142 re-enable interrupts.  See also the @code{signal} function attribute
4143 that does not insert a @code{SEI} instruction.  If both @code{signal} and
4144 @code{interrupt} are specified for the same function, @code{signal}
4145 is silently ignored.
4147 @item naked
4148 @cindex @code{naked} function attribute, AVR
4149 This attribute allows the compiler to construct the
4150 requisite function declaration, while allowing the body of the
4151 function to be assembly code. The specified function will not have
4152 prologue/epilogue sequences generated by the compiler. Only basic
4153 @code{asm} statements can safely be included in naked functions
4154 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
4155 basic @code{asm} and C code may appear to work, they cannot be
4156 depended upon to work reliably and are not supported.
4158 @item no_gccisr
4159 @cindex @code{no_gccisr} function attribute, AVR
4160 Do not use @code{__gcc_isr} pseudo instructions in a function with
4161 the @code{interrupt} or @code{signal} attribute aka. interrupt
4162 service routine (ISR).
4163 Use this attribute if the preamble of the ISR prologue should always read
4164 @example
4165 push  __zero_reg__
4166 push  __tmp_reg__
4167 in    __tmp_reg__, __SREG__
4168 push  __tmp_reg__
4169 clr   __zero_reg__
4170 @end example
4171 and accordingly for the postamble of the epilogue --- no matter whether
4172 the mentioned registers are actually used in the ISR or not.
4173 Situations where you might want to use this attribute include:
4174 @itemize @bullet
4175 @item
4176 Code that (effectively) clobbers bits of @code{SREG} other than the
4177 @code{I}-flag by writing to the memory location of @code{SREG}.
4178 @item
4179 Code that uses inline assembler to jump to a different function which
4180 expects (parts of) the prologue code as outlined above to be present.
4181 @end itemize
4182 To disable @code{__gcc_isr} generation for the whole compilation unit,
4183 there is option @option{-mno-gas-isr-prologues}, @pxref{AVR Options}.
4185 @item OS_main
4186 @itemx OS_task
4187 @cindex @code{OS_main} function attribute, AVR
4188 @cindex @code{OS_task} function attribute, AVR
4189 On AVR, functions with the @code{OS_main} or @code{OS_task} attribute
4190 do not save/restore any call-saved register in their prologue/epilogue.
4192 The @code{OS_main} attribute can be used when there @emph{is
4193 guarantee} that interrupts are disabled at the time when the function
4194 is entered.  This saves resources when the stack pointer has to be
4195 changed to set up a frame for local variables.
4197 The @code{OS_task} attribute can be used when there is @emph{no
4198 guarantee} that interrupts are disabled at that time when the function
4199 is entered like for, e@.g@. task functions in a multi-threading operating
4200 system. In that case, changing the stack pointer register is
4201 guarded by save/clear/restore of the global interrupt enable flag.
4203 The differences to the @code{naked} function attribute are:
4204 @itemize @bullet
4205 @item @code{naked} functions do not have a return instruction whereas 
4206 @code{OS_main} and @code{OS_task} functions have a @code{RET} or
4207 @code{RETI} return instruction.
4208 @item @code{naked} functions do not set up a frame for local variables
4209 or a frame pointer whereas @code{OS_main} and @code{OS_task} do this
4210 as needed.
4211 @end itemize
4213 @item signal
4214 @cindex @code{signal} function attribute, AVR
4215 Use this attribute on the AVR to indicate that the specified
4216 function is an interrupt handler.  The compiler generates function
4217 entry and exit sequences suitable for use in an interrupt handler when this
4218 attribute is present.
4220 See also the @code{interrupt} function attribute. 
4222 The AVR hardware globally disables interrupts when an interrupt is executed.
4223 Interrupt handler functions defined with the @code{signal} attribute
4224 do not re-enable interrupts.  It is save to enable interrupts in a
4225 @code{signal} handler.  This ``save'' only applies to the code
4226 generated by the compiler and not to the IRQ layout of the
4227 application which is responsibility of the application.
4229 If both @code{signal} and @code{interrupt} are specified for the same
4230 function, @code{signal} is silently ignored.
4231 @end table
4233 @node Blackfin Function Attributes
4234 @subsection Blackfin Function Attributes
4236 These function attributes are supported by the Blackfin back end:
4238 @table @code
4240 @item exception_handler
4241 @cindex @code{exception_handler} function attribute
4242 @cindex exception handler functions, Blackfin
4243 Use this attribute on the Blackfin to indicate that the specified function
4244 is an exception handler.  The compiler generates function entry and
4245 exit sequences suitable for use in an exception handler when this
4246 attribute is present.
4248 @item interrupt_handler
4249 @cindex @code{interrupt_handler} function attribute, Blackfin
4250 Use this attribute to
4251 indicate that the specified function is an interrupt handler.  The compiler
4252 generates function entry and exit sequences suitable for use in an
4253 interrupt handler when this attribute is present.
4255 @item kspisusp
4256 @cindex @code{kspisusp} function attribute, Blackfin
4257 @cindex User stack pointer in interrupts on the Blackfin
4258 When used together with @code{interrupt_handler}, @code{exception_handler}
4259 or @code{nmi_handler}, code is generated to load the stack pointer
4260 from the USP register in the function prologue.
4262 @item l1_text
4263 @cindex @code{l1_text} function attribute, Blackfin
4264 This attribute specifies a function to be placed into L1 Instruction
4265 SRAM@. The function is put into a specific section named @code{.l1.text}.
4266 With @option{-mfdpic}, function calls with a such function as the callee
4267 or caller uses inlined PLT.
4269 @item l2
4270 @cindex @code{l2} function attribute, Blackfin
4271 This attribute specifies a function to be placed into L2
4272 SRAM. The function is put into a specific section named
4273 @code{.l2.text}. With @option{-mfdpic}, callers of such functions use
4274 an inlined PLT.
4276 @item longcall
4277 @itemx shortcall
4278 @cindex indirect calls, Blackfin
4279 @cindex @code{longcall} function attribute, Blackfin
4280 @cindex @code{shortcall} function attribute, Blackfin
4281 The @code{longcall} attribute
4282 indicates that the function might be far away from the call site and
4283 require a different (more expensive) calling sequence.  The
4284 @code{shortcall} attribute indicates that the function is always close
4285 enough for the shorter calling sequence to be used.  These attributes
4286 override the @option{-mlongcall} switch.
4288 @item nesting
4289 @cindex @code{nesting} function attribute, Blackfin
4290 @cindex Allow nesting in an interrupt handler on the Blackfin processor
4291 Use this attribute together with @code{interrupt_handler},
4292 @code{exception_handler} or @code{nmi_handler} to indicate that the function
4293 entry code should enable nested interrupts or exceptions.
4295 @item nmi_handler
4296 @cindex @code{nmi_handler} function attribute, Blackfin
4297 @cindex NMI handler functions on the Blackfin processor
4298 Use this attribute on the Blackfin to indicate that the specified function
4299 is an NMI handler.  The compiler generates function entry and
4300 exit sequences suitable for use in an NMI handler when this
4301 attribute is present.
4303 @item saveall
4304 @cindex @code{saveall} function attribute, Blackfin
4305 @cindex save all registers on the Blackfin
4306 Use this attribute to indicate that
4307 all registers except the stack pointer should be saved in the prologue
4308 regardless of whether they are used or not.
4309 @end table
4311 @node CR16 Function Attributes
4312 @subsection CR16 Function Attributes
4314 These function attributes are supported by the CR16 back end:
4316 @table @code
4317 @item interrupt
4318 @cindex @code{interrupt} function attribute, CR16
4319 Use this attribute to indicate
4320 that the specified function is an interrupt handler.  The compiler generates
4321 function entry and exit sequences suitable for use in an interrupt handler
4322 when this attribute is present.
4323 @end table
4325 @node C-SKY Function Attributes
4326 @subsection C-SKY Function Attributes
4328 These function attributes are supported by the C-SKY back end:
4330 @table @code
4331 @item interrupt
4332 @itemx isr
4333 @cindex @code{interrupt} function attribute, C-SKY
4334 @cindex @code{isr} function attribute, C-SKY
4335 Use these attributes to indicate that the specified function
4336 is an interrupt handler.
4337 The compiler generates function entry and exit sequences suitable for
4338 use in an interrupt handler when either of these attributes are present.
4340 Use of these options requires the @option{-mistack} command-line option
4341 to enable support for the necessary interrupt stack instructions.  They
4342 are ignored with a warning otherwise.  @xref{C-SKY Options}.
4344 @item naked
4345 @cindex @code{naked} function attribute, C-SKY
4346 This attribute allows the compiler to construct the
4347 requisite function declaration, while allowing the body of the
4348 function to be assembly code. The specified function will not have
4349 prologue/epilogue sequences generated by the compiler. Only basic
4350 @code{asm} statements can safely be included in naked functions
4351 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
4352 basic @code{asm} and C code may appear to work, they cannot be
4353 depended upon to work reliably and are not supported.
4354 @end table
4357 @node Epiphany Function Attributes
4358 @subsection Epiphany Function Attributes
4360 These function attributes are supported by the Epiphany back end:
4362 @table @code
4363 @item disinterrupt
4364 @cindex @code{disinterrupt} function attribute, Epiphany
4365 This attribute causes the compiler to emit
4366 instructions to disable interrupts for the duration of the given
4367 function.
4369 @item forwarder_section
4370 @cindex @code{forwarder_section} function attribute, Epiphany
4371 This attribute modifies the behavior of an interrupt handler.
4372 The interrupt handler may be in external memory which cannot be
4373 reached by a branch instruction, so generate a local memory trampoline
4374 to transfer control.  The single parameter identifies the section where
4375 the trampoline is placed.
4377 @item interrupt
4378 @cindex @code{interrupt} function attribute, Epiphany
4379 Use this attribute to indicate
4380 that the specified function is an interrupt handler.  The compiler generates
4381 function entry and exit sequences suitable for use in an interrupt handler
4382 when this attribute is present.  It may also generate
4383 a special section with code to initialize the interrupt vector table.
4385 On Epiphany targets one or more optional parameters can be added like this:
4387 @smallexample
4388 void __attribute__ ((interrupt ("dma0, dma1"))) universal_dma_handler ();
4389 @end smallexample
4391 Permissible values for these parameters are: @w{@code{reset}},
4392 @w{@code{software_exception}}, @w{@code{page_miss}},
4393 @w{@code{timer0}}, @w{@code{timer1}}, @w{@code{message}},
4394 @w{@code{dma0}}, @w{@code{dma1}}, @w{@code{wand}} and @w{@code{swi}}.
4395 Multiple parameters indicate that multiple entries in the interrupt
4396 vector table should be initialized for this function, i.e.@: for each
4397 parameter @w{@var{name}}, a jump to the function is emitted in
4398 the section @w{ivt_entry_@var{name}}.  The parameter(s) may be omitted
4399 entirely, in which case no interrupt vector table entry is provided.
4401 Note that interrupts are enabled inside the function
4402 unless the @code{disinterrupt} attribute is also specified.
4404 The following examples are all valid uses of these attributes on
4405 Epiphany targets:
4406 @smallexample
4407 void __attribute__ ((interrupt)) universal_handler ();
4408 void __attribute__ ((interrupt ("dma1"))) dma1_handler ();
4409 void __attribute__ ((interrupt ("dma0, dma1"))) 
4410   universal_dma_handler ();
4411 void __attribute__ ((interrupt ("timer0"), disinterrupt))
4412   fast_timer_handler ();
4413 void __attribute__ ((interrupt ("dma0, dma1"), 
4414                      forwarder_section ("tramp")))
4415   external_dma_handler ();
4416 @end smallexample
4418 @item long_call
4419 @itemx short_call
4420 @cindex @code{long_call} function attribute, Epiphany
4421 @cindex @code{short_call} function attribute, Epiphany
4422 @cindex indirect calls, Epiphany
4423 These attributes specify how a particular function is called.
4424 These attributes override the
4425 @option{-mlong-calls} (@pxref{Adapteva Epiphany Options})
4426 command-line switch and @code{#pragma long_calls} settings.
4427 @end table
4430 @node H8/300 Function Attributes
4431 @subsection H8/300 Function Attributes
4433 These function attributes are available for H8/300 targets:
4435 @table @code
4436 @item function_vector
4437 @cindex @code{function_vector} function attribute, H8/300
4438 Use this attribute on the H8/300, H8/300H, and H8S to indicate 
4439 that the specified function should be called through the function vector.
4440 Calling a function through the function vector reduces code size; however,
4441 the function vector has a limited size (maximum 128 entries on the H8/300
4442 and 64 entries on the H8/300H and H8S)
4443 and shares space with the interrupt vector.
4445 @item interrupt_handler
4446 @cindex @code{interrupt_handler} function attribute, H8/300
4447 Use this attribute on the H8/300, H8/300H, and H8S to
4448 indicate that the specified function is an interrupt handler.  The compiler
4449 generates function entry and exit sequences suitable for use in an
4450 interrupt handler when this attribute is present.
4452 @item saveall
4453 @cindex @code{saveall} function attribute, H8/300
4454 @cindex save all registers on the H8/300, H8/300H, and H8S
4455 Use this attribute on the H8/300, H8/300H, and H8S to indicate that
4456 all registers except the stack pointer should be saved in the prologue
4457 regardless of whether they are used or not.
4458 @end table
4460 @node IA-64 Function Attributes
4461 @subsection IA-64 Function Attributes
4463 These function attributes are supported on IA-64 targets:
4465 @table @code
4466 @item syscall_linkage
4467 @cindex @code{syscall_linkage} function attribute, IA-64
4468 This attribute is used to modify the IA-64 calling convention by marking
4469 all input registers as live at all function exits.  This makes it possible
4470 to restart a system call after an interrupt without having to save/restore
4471 the input registers.  This also prevents kernel data from leaking into
4472 application code.
4474 @item version_id
4475 @cindex @code{version_id} function attribute, IA-64
4476 This IA-64 HP-UX attribute, attached to a global variable or function, renames a
4477 symbol to contain a version string, thus allowing for function level
4478 versioning.  HP-UX system header files may use function level versioning
4479 for some system calls.
4481 @smallexample
4482 extern int foo () __attribute__((version_id ("20040821")));
4483 @end smallexample
4485 @noindent
4486 Calls to @code{foo} are mapped to calls to @code{foo@{20040821@}}.
4487 @end table
4489 @node M32C Function Attributes
4490 @subsection M32C Function Attributes
4492 These function attributes are supported by the M32C back end:
4494 @table @code
4495 @item bank_switch
4496 @cindex @code{bank_switch} function attribute, M32C
4497 When added to an interrupt handler with the M32C port, causes the
4498 prologue and epilogue to use bank switching to preserve the registers
4499 rather than saving them on the stack.
4501 @item fast_interrupt
4502 @cindex @code{fast_interrupt} function attribute, M32C
4503 Use this attribute on the M32C port to indicate that the specified
4504 function is a fast interrupt handler.  This is just like the
4505 @code{interrupt} attribute, except that @code{freit} is used to return
4506 instead of @code{reit}.
4508 @item function_vector
4509 @cindex @code{function_vector} function attribute, M16C/M32C
4510 On M16C/M32C targets, the @code{function_vector} attribute declares a
4511 special page subroutine call function. Use of this attribute reduces
4512 the code size by 2 bytes for each call generated to the
4513 subroutine. The argument to the attribute is the vector number entry
4514 from the special page vector table which contains the 16 low-order
4515 bits of the subroutine's entry address. Each vector table has special
4516 page number (18 to 255) that is used in @code{jsrs} instructions.
4517 Jump addresses of the routines are generated by adding 0x0F0000 (in
4518 case of M16C targets) or 0xFF0000 (in case of M32C targets), to the
4519 2-byte addresses set in the vector table. Therefore you need to ensure
4520 that all the special page vector routines should get mapped within the
4521 address range 0x0F0000 to 0x0FFFFF (for M16C) and 0xFF0000 to 0xFFFFFF
4522 (for M32C).
4524 In the following example 2 bytes are saved for each call to
4525 function @code{foo}.
4527 @smallexample
4528 void foo (void) __attribute__((function_vector(0x18)));
4529 void foo (void)
4533 void bar (void)
4535     foo();
4537 @end smallexample
4539 If functions are defined in one file and are called in another file,
4540 then be sure to write this declaration in both files.
4542 This attribute is ignored for R8C target.
4544 @item interrupt
4545 @cindex @code{interrupt} function attribute, M32C
4546 Use this attribute to indicate
4547 that the specified function is an interrupt handler.  The compiler generates
4548 function entry and exit sequences suitable for use in an interrupt handler
4549 when this attribute is present.
4550 @end table
4552 @node M32R/D Function Attributes
4553 @subsection M32R/D Function Attributes
4555 These function attributes are supported by the M32R/D back end:
4557 @table @code
4558 @item interrupt
4559 @cindex @code{interrupt} function attribute, M32R/D
4560 Use this attribute to indicate
4561 that the specified function is an interrupt handler.  The compiler generates
4562 function entry and exit sequences suitable for use in an interrupt handler
4563 when this attribute is present.
4565 @item model (@var{model-name})
4566 @cindex @code{model} function attribute, M32R/D
4567 @cindex function addressability on the M32R/D
4569 On the M32R/D, use this attribute to set the addressability of an
4570 object, and of the code generated for a function.  The identifier
4571 @var{model-name} is one of @code{small}, @code{medium}, or
4572 @code{large}, representing each of the code models.
4574 Small model objects live in the lower 16MB of memory (so that their
4575 addresses can be loaded with the @code{ld24} instruction), and are
4576 callable with the @code{bl} instruction.
4578 Medium model objects may live anywhere in the 32-bit address space (the
4579 compiler generates @code{seth/add3} instructions to load their addresses),
4580 and are callable with the @code{bl} instruction.
4582 Large model objects may live anywhere in the 32-bit address space (the
4583 compiler generates @code{seth/add3} instructions to load their addresses),
4584 and may not be reachable with the @code{bl} instruction (the compiler
4585 generates the much slower @code{seth/add3/jl} instruction sequence).
4586 @end table
4588 @node m68k Function Attributes
4589 @subsection m68k Function Attributes
4591 These function attributes are supported by the m68k back end:
4593 @table @code
4594 @item interrupt
4595 @itemx interrupt_handler
4596 @cindex @code{interrupt} function attribute, m68k
4597 @cindex @code{interrupt_handler} function attribute, m68k
4598 Use this attribute to
4599 indicate that the specified function is an interrupt handler.  The compiler
4600 generates function entry and exit sequences suitable for use in an
4601 interrupt handler when this attribute is present.  Either name may be used.
4603 @item interrupt_thread
4604 @cindex @code{interrupt_thread} function attribute, fido
4605 Use this attribute on fido, a subarchitecture of the m68k, to indicate
4606 that the specified function is an interrupt handler that is designed
4607 to run as a thread.  The compiler omits generate prologue/epilogue
4608 sequences and replaces the return instruction with a @code{sleep}
4609 instruction.  This attribute is available only on fido.
4610 @end table
4612 @node MCORE Function Attributes
4613 @subsection MCORE Function Attributes
4615 These function attributes are supported by the MCORE back end:
4617 @table @code
4618 @item naked
4619 @cindex @code{naked} function attribute, MCORE
4620 This attribute allows the compiler to construct the
4621 requisite function declaration, while allowing the body of the
4622 function to be assembly code. The specified function will not have
4623 prologue/epilogue sequences generated by the compiler. Only basic
4624 @code{asm} statements can safely be included in naked functions
4625 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
4626 basic @code{asm} and C code may appear to work, they cannot be
4627 depended upon to work reliably and are not supported.
4628 @end table
4630 @node MeP Function Attributes
4631 @subsection MeP Function Attributes
4633 These function attributes are supported by the MeP back end:
4635 @table @code
4636 @item disinterrupt
4637 @cindex @code{disinterrupt} function attribute, MeP
4638 On MeP targets, this attribute causes the compiler to emit
4639 instructions to disable interrupts for the duration of the given
4640 function.
4642 @item interrupt
4643 @cindex @code{interrupt} function attribute, MeP
4644 Use this attribute to indicate
4645 that the specified function is an interrupt handler.  The compiler generates
4646 function entry and exit sequences suitable for use in an interrupt handler
4647 when this attribute is present.
4649 @item near
4650 @cindex @code{near} function attribute, MeP
4651 This attribute causes the compiler to assume the called
4652 function is close enough to use the normal calling convention,
4653 overriding the @option{-mtf} command-line option.
4655 @item far
4656 @cindex @code{far} function attribute, MeP
4657 On MeP targets this causes the compiler to use a calling convention
4658 that assumes the called function is too far away for the built-in
4659 addressing modes.
4661 @item vliw
4662 @cindex @code{vliw} function attribute, MeP
4663 The @code{vliw} attribute tells the compiler to emit
4664 instructions in VLIW mode instead of core mode.  Note that this
4665 attribute is not allowed unless a VLIW coprocessor has been configured
4666 and enabled through command-line options.
4667 @end table
4669 @node MicroBlaze Function Attributes
4670 @subsection MicroBlaze Function Attributes
4672 These function attributes are supported on MicroBlaze targets:
4674 @table @code
4675 @item save_volatiles
4676 @cindex @code{save_volatiles} function attribute, MicroBlaze
4677 Use this attribute to indicate that the function is
4678 an interrupt handler.  All volatile registers (in addition to non-volatile
4679 registers) are saved in the function prologue.  If the function is a leaf
4680 function, only volatiles used by the function are saved.  A normal function
4681 return is generated instead of a return from interrupt.
4683 @item break_handler
4684 @cindex @code{break_handler} function attribute, MicroBlaze
4685 @cindex break handler functions
4686 Use this attribute to indicate that
4687 the specified function is a break handler.  The compiler generates function
4688 entry and exit sequences suitable for use in an break handler when this
4689 attribute is present. The return from @code{break_handler} is done through
4690 the @code{rtbd} instead of @code{rtsd}.
4692 @smallexample
4693 void f () __attribute__ ((break_handler));
4694 @end smallexample
4696 @item interrupt_handler
4697 @itemx fast_interrupt 
4698 @cindex @code{interrupt_handler} function attribute, MicroBlaze
4699 @cindex @code{fast_interrupt} function attribute, MicroBlaze
4700 These attributes indicate that the specified function is an interrupt
4701 handler.  Use the @code{fast_interrupt} attribute to indicate handlers
4702 used in low-latency interrupt mode, and @code{interrupt_handler} for
4703 interrupts that do not use low-latency handlers.  In both cases, GCC
4704 emits appropriate prologue code and generates a return from the handler
4705 using @code{rtid} instead of @code{rtsd}.
4706 @end table
4708 @node Microsoft Windows Function Attributes
4709 @subsection Microsoft Windows Function Attributes
4711 The following attributes are available on Microsoft Windows and Symbian OS
4712 targets.
4714 @table @code
4715 @item dllexport
4716 @cindex @code{dllexport} function attribute
4717 @cindex @code{__declspec(dllexport)}
4718 On Microsoft Windows targets and Symbian OS targets the
4719 @code{dllexport} attribute causes the compiler to provide a global
4720 pointer to a pointer in a DLL, so that it can be referenced with the
4721 @code{dllimport} attribute.  On Microsoft Windows targets, the pointer
4722 name is formed by combining @code{_imp__} and the function or variable
4723 name.
4725 You can use @code{__declspec(dllexport)} as a synonym for
4726 @code{__attribute__ ((dllexport))} for compatibility with other
4727 compilers.
4729 On systems that support the @code{visibility} attribute, this
4730 attribute also implies ``default'' visibility.  It is an error to
4731 explicitly specify any other visibility.
4733 GCC's default behavior is to emit all inline functions with the
4734 @code{dllexport} attribute.  Since this can cause object file-size bloat,
4735 you can use @option{-fno-keep-inline-dllexport}, which tells GCC to
4736 ignore the attribute for inlined functions unless the 
4737 @option{-fkeep-inline-functions} flag is used instead.
4739 The attribute is ignored for undefined symbols.
4741 When applied to C++ classes, the attribute marks defined non-inlined
4742 member functions and static data members as exports.  Static consts
4743 initialized in-class are not marked unless they are also defined
4744 out-of-class.
4746 For Microsoft Windows targets there are alternative methods for
4747 including the symbol in the DLL's export table such as using a
4748 @file{.def} file with an @code{EXPORTS} section or, with GNU ld, using
4749 the @option{--export-all} linker flag.
4751 @item dllimport
4752 @cindex @code{dllimport} function attribute
4753 @cindex @code{__declspec(dllimport)}
4754 On Microsoft Windows and Symbian OS targets, the @code{dllimport}
4755 attribute causes the compiler to reference a function or variable via
4756 a global pointer to a pointer that is set up by the DLL exporting the
4757 symbol.  The attribute implies @code{extern}.  On Microsoft Windows
4758 targets, the pointer name is formed by combining @code{_imp__} and the
4759 function or variable name.
4761 You can use @code{__declspec(dllimport)} as a synonym for
4762 @code{__attribute__ ((dllimport))} for compatibility with other
4763 compilers.
4765 On systems that support the @code{visibility} attribute, this
4766 attribute also implies ``default'' visibility.  It is an error to
4767 explicitly specify any other visibility.
4769 Currently, the attribute is ignored for inlined functions.  If the
4770 attribute is applied to a symbol @emph{definition}, an error is reported.
4771 If a symbol previously declared @code{dllimport} is later defined, the
4772 attribute is ignored in subsequent references, and a warning is emitted.
4773 The attribute is also overridden by a subsequent declaration as
4774 @code{dllexport}.
4776 When applied to C++ classes, the attribute marks non-inlined
4777 member functions and static data members as imports.  However, the
4778 attribute is ignored for virtual methods to allow creation of vtables
4779 using thunks.
4781 On the SH Symbian OS target the @code{dllimport} attribute also has
4782 another affect---it can cause the vtable and run-time type information
4783 for a class to be exported.  This happens when the class has a
4784 dllimported constructor or a non-inline, non-pure virtual function
4785 and, for either of those two conditions, the class also has an inline
4786 constructor or destructor and has a key function that is defined in
4787 the current translation unit.
4789 For Microsoft Windows targets the use of the @code{dllimport}
4790 attribute on functions is not necessary, but provides a small
4791 performance benefit by eliminating a thunk in the DLL@.  The use of the
4792 @code{dllimport} attribute on imported variables can be avoided by passing the
4793 @option{--enable-auto-import} switch to the GNU linker.  As with
4794 functions, using the attribute for a variable eliminates a thunk in
4795 the DLL@.
4797 One drawback to using this attribute is that a pointer to a
4798 @emph{variable} marked as @code{dllimport} cannot be used as a constant
4799 address. However, a pointer to a @emph{function} with the
4800 @code{dllimport} attribute can be used as a constant initializer; in
4801 this case, the address of a stub function in the import lib is
4802 referenced.  On Microsoft Windows targets, the attribute can be disabled
4803 for functions by setting the @option{-mnop-fun-dllimport} flag.
4804 @end table
4806 @node MIPS Function Attributes
4807 @subsection MIPS Function Attributes
4809 These function attributes are supported by the MIPS back end:
4811 @table @code
4812 @item interrupt
4813 @cindex @code{interrupt} function attribute, MIPS
4814 Use this attribute to indicate that the specified function is an interrupt
4815 handler.  The compiler generates function entry and exit sequences suitable
4816 for use in an interrupt handler when this attribute is present.
4817 An optional argument is supported for the interrupt attribute which allows
4818 the interrupt mode to be described.  By default GCC assumes the external
4819 interrupt controller (EIC) mode is in use, this can be explicitly set using
4820 @code{eic}.  When interrupts are non-masked then the requested Interrupt
4821 Priority Level (IPL) is copied to the current IPL which has the effect of only
4822 enabling higher priority interrupts.  To use vectored interrupt mode use
4823 the argument @code{vector=[sw0|sw1|hw0|hw1|hw2|hw3|hw4|hw5]}, this will change
4824 the behavior of the non-masked interrupt support and GCC will arrange to mask
4825 all interrupts from sw0 up to and including the specified interrupt vector.
4827 You can use the following attributes to modify the behavior
4828 of an interrupt handler:
4829 @table @code
4830 @item use_shadow_register_set
4831 @cindex @code{use_shadow_register_set} function attribute, MIPS
4832 Assume that the handler uses a shadow register set, instead of
4833 the main general-purpose registers.  An optional argument @code{intstack} is
4834 supported to indicate that the shadow register set contains a valid stack
4835 pointer.
4837 @item keep_interrupts_masked
4838 @cindex @code{keep_interrupts_masked} function attribute, MIPS
4839 Keep interrupts masked for the whole function.  Without this attribute,
4840 GCC tries to reenable interrupts for as much of the function as it can.
4842 @item use_debug_exception_return
4843 @cindex @code{use_debug_exception_return} function attribute, MIPS
4844 Return using the @code{deret} instruction.  Interrupt handlers that don't
4845 have this attribute return using @code{eret} instead.
4846 @end table
4848 You can use any combination of these attributes, as shown below:
4849 @smallexample
4850 void __attribute__ ((interrupt)) v0 ();
4851 void __attribute__ ((interrupt, use_shadow_register_set)) v1 ();
4852 void __attribute__ ((interrupt, keep_interrupts_masked)) v2 ();
4853 void __attribute__ ((interrupt, use_debug_exception_return)) v3 ();
4854 void __attribute__ ((interrupt, use_shadow_register_set,
4855                      keep_interrupts_masked)) v4 ();
4856 void __attribute__ ((interrupt, use_shadow_register_set,
4857                      use_debug_exception_return)) v5 ();
4858 void __attribute__ ((interrupt, keep_interrupts_masked,
4859                      use_debug_exception_return)) v6 ();
4860 void __attribute__ ((interrupt, use_shadow_register_set,
4861                      keep_interrupts_masked,
4862                      use_debug_exception_return)) v7 ();
4863 void __attribute__ ((interrupt("eic"))) v8 ();
4864 void __attribute__ ((interrupt("vector=hw3"))) v9 ();
4865 @end smallexample
4867 @item long_call
4868 @itemx short_call
4869 @itemx near
4870 @itemx far
4871 @cindex indirect calls, MIPS
4872 @cindex @code{long_call} function attribute, MIPS
4873 @cindex @code{short_call} function attribute, MIPS
4874 @cindex @code{near} function attribute, MIPS
4875 @cindex @code{far} function attribute, MIPS
4876 These attributes specify how a particular function is called on MIPS@.
4877 The attributes override the @option{-mlong-calls} (@pxref{MIPS Options})
4878 command-line switch.  The @code{long_call} and @code{far} attributes are
4879 synonyms, and cause the compiler to always call
4880 the function by first loading its address into a register, and then using
4881 the contents of that register.  The @code{short_call} and @code{near}
4882 attributes are synonyms, and have the opposite
4883 effect; they specify that non-PIC calls should be made using the more
4884 efficient @code{jal} instruction.
4886 @item mips16
4887 @itemx nomips16
4888 @cindex @code{mips16} function attribute, MIPS
4889 @cindex @code{nomips16} function attribute, MIPS
4891 On MIPS targets, you can use the @code{mips16} and @code{nomips16}
4892 function attributes to locally select or turn off MIPS16 code generation.
4893 A function with the @code{mips16} attribute is emitted as MIPS16 code,
4894 while MIPS16 code generation is disabled for functions with the
4895 @code{nomips16} attribute.  These attributes override the
4896 @option{-mips16} and @option{-mno-mips16} options on the command line
4897 (@pxref{MIPS Options}).
4899 When compiling files containing mixed MIPS16 and non-MIPS16 code, the
4900 preprocessor symbol @code{__mips16} reflects the setting on the command line,
4901 not that within individual functions.  Mixed MIPS16 and non-MIPS16 code
4902 may interact badly with some GCC extensions such as @code{__builtin_apply}
4903 (@pxref{Constructing Calls}).
4905 @item micromips, MIPS
4906 @itemx nomicromips, MIPS
4907 @cindex @code{micromips} function attribute
4908 @cindex @code{nomicromips} function attribute
4910 On MIPS targets, you can use the @code{micromips} and @code{nomicromips}
4911 function attributes to locally select or turn off microMIPS code generation.
4912 A function with the @code{micromips} attribute is emitted as microMIPS code,
4913 while microMIPS code generation is disabled for functions with the
4914 @code{nomicromips} attribute.  These attributes override the
4915 @option{-mmicromips} and @option{-mno-micromips} options on the command line
4916 (@pxref{MIPS Options}).
4918 When compiling files containing mixed microMIPS and non-microMIPS code, the
4919 preprocessor symbol @code{__mips_micromips} reflects the setting on the
4920 command line,
4921 not that within individual functions.  Mixed microMIPS and non-microMIPS code
4922 may interact badly with some GCC extensions such as @code{__builtin_apply}
4923 (@pxref{Constructing Calls}).
4925 @item nocompression
4926 @cindex @code{nocompression} function attribute, MIPS
4927 On MIPS targets, you can use the @code{nocompression} function attribute
4928 to locally turn off MIPS16 and microMIPS code generation.  This attribute
4929 overrides the @option{-mips16} and @option{-mmicromips} options on the
4930 command line (@pxref{MIPS Options}).
4931 @end table
4933 @node MSP430 Function Attributes
4934 @subsection MSP430 Function Attributes
4936 These function attributes are supported by the MSP430 back end:
4938 @table @code
4939 @item critical
4940 @cindex @code{critical} function attribute, MSP430
4941 Critical functions disable interrupts upon entry and restore the
4942 previous interrupt state upon exit.  Critical functions cannot also
4943 have the @code{naked} or @code{reentrant} attributes.  They can have
4944 the @code{interrupt} attribute.
4946 @item interrupt
4947 @cindex @code{interrupt} function attribute, MSP430
4948 Use this attribute to indicate
4949 that the specified function is an interrupt handler.  The compiler generates
4950 function entry and exit sequences suitable for use in an interrupt handler
4951 when this attribute is present.
4953 You can provide an argument to the interrupt
4954 attribute which specifies a name or number.  If the argument is a
4955 number it indicates the slot in the interrupt vector table (0 - 31) to
4956 which this handler should be assigned.  If the argument is a name it
4957 is treated as a symbolic name for the vector slot.  These names should
4958 match up with appropriate entries in the linker script.  By default
4959 the names @code{watchdog} for vector 26, @code{nmi} for vector 30 and
4960 @code{reset} for vector 31 are recognized.
4962 @item naked
4963 @cindex @code{naked} function attribute, MSP430
4964 This attribute allows the compiler to construct the
4965 requisite function declaration, while allowing the body of the
4966 function to be assembly code. The specified function will not have
4967 prologue/epilogue sequences generated by the compiler. Only basic
4968 @code{asm} statements can safely be included in naked functions
4969 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
4970 basic @code{asm} and C code may appear to work, they cannot be
4971 depended upon to work reliably and are not supported.
4973 @item reentrant
4974 @cindex @code{reentrant} function attribute, MSP430
4975 Reentrant functions disable interrupts upon entry and enable them
4976 upon exit.  Reentrant functions cannot also have the @code{naked}
4977 or @code{critical} attributes.  They can have the @code{interrupt}
4978 attribute.
4980 @item wakeup
4981 @cindex @code{wakeup} function attribute, MSP430
4982 This attribute only applies to interrupt functions.  It is silently
4983 ignored if applied to a non-interrupt function.  A wakeup interrupt
4984 function will rouse the processor from any low-power state that it
4985 might be in when the function exits.
4987 @item lower
4988 @itemx upper
4989 @itemx either
4990 @cindex @code{lower} function attribute, MSP430
4991 @cindex @code{upper} function attribute, MSP430
4992 @cindex @code{either} function attribute, MSP430
4993 On the MSP430 target these attributes can be used to specify whether
4994 the function or variable should be placed into low memory, high
4995 memory, or the placement should be left to the linker to decide.  The
4996 attributes are only significant if compiling for the MSP430X
4997 architecture.
4999 The attributes work in conjunction with a linker script that has been
5000 augmented to specify where to place sections with a @code{.lower} and
5001 a @code{.upper} prefix.  So, for example, as well as placing the
5002 @code{.data} section, the script also specifies the placement of a
5003 @code{.lower.data} and a @code{.upper.data} section.  The intention
5004 is that @code{lower} sections are placed into a small but easier to
5005 access memory region and the upper sections are placed into a larger, but
5006 slower to access, region.
5008 The @code{either} attribute is special.  It tells the linker to place
5009 the object into the corresponding @code{lower} section if there is
5010 room for it.  If there is insufficient room then the object is placed
5011 into the corresponding @code{upper} section instead.  Note that the
5012 placement algorithm is not very sophisticated.  It does not attempt to
5013 find an optimal packing of the @code{lower} sections.  It just makes
5014 one pass over the objects and does the best that it can.  Using the
5015 @option{-ffunction-sections} and @option{-fdata-sections} command-line
5016 options can help the packing, however, since they produce smaller,
5017 easier to pack regions.
5018 @end table
5020 @node NDS32 Function Attributes
5021 @subsection NDS32 Function Attributes
5023 These function attributes are supported by the NDS32 back end:
5025 @table @code
5026 @item exception
5027 @cindex @code{exception} function attribute
5028 @cindex exception handler functions, NDS32
5029 Use this attribute on the NDS32 target to indicate that the specified function
5030 is an exception handler.  The compiler will generate corresponding sections
5031 for use in an exception handler.
5033 @item interrupt
5034 @cindex @code{interrupt} function attribute, NDS32
5035 On NDS32 target, this attribute indicates that the specified function
5036 is an interrupt handler.  The compiler generates corresponding sections
5037 for use in an interrupt handler.  You can use the following attributes
5038 to modify the behavior:
5039 @table @code
5040 @item nested
5041 @cindex @code{nested} function attribute, NDS32
5042 This interrupt service routine is interruptible.
5043 @item not_nested
5044 @cindex @code{not_nested} function attribute, NDS32
5045 This interrupt service routine is not interruptible.
5046 @item nested_ready
5047 @cindex @code{nested_ready} function attribute, NDS32
5048 This interrupt service routine is interruptible after @code{PSW.GIE}
5049 (global interrupt enable) is set.  This allows interrupt service routine to
5050 finish some short critical code before enabling interrupts.
5051 @item save_all
5052 @cindex @code{save_all} function attribute, NDS32
5053 The system will help save all registers into stack before entering
5054 interrupt handler.
5055 @item partial_save
5056 @cindex @code{partial_save} function attribute, NDS32
5057 The system will help save caller registers into stack before entering
5058 interrupt handler.
5059 @end table
5061 @item naked
5062 @cindex @code{naked} function attribute, NDS32
5063 This attribute allows the compiler to construct the
5064 requisite function declaration, while allowing the body of the
5065 function to be assembly code. The specified function will not have
5066 prologue/epilogue sequences generated by the compiler. Only basic
5067 @code{asm} statements can safely be included in naked functions
5068 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
5069 basic @code{asm} and C code may appear to work, they cannot be
5070 depended upon to work reliably and are not supported.
5072 @item reset
5073 @cindex @code{reset} function attribute, NDS32
5074 @cindex reset handler functions
5075 Use this attribute on the NDS32 target to indicate that the specified function
5076 is a reset handler.  The compiler will generate corresponding sections
5077 for use in a reset handler.  You can use the following attributes
5078 to provide extra exception handling:
5079 @table @code
5080 @item nmi
5081 @cindex @code{nmi} function attribute, NDS32
5082 Provide a user-defined function to handle NMI exception.
5083 @item warm
5084 @cindex @code{warm} function attribute, NDS32
5085 Provide a user-defined function to handle warm reset exception.
5086 @end table
5087 @end table
5089 @node Nios II Function Attributes
5090 @subsection Nios II Function Attributes
5092 These function attributes are supported by the Nios II back end:
5094 @table @code
5095 @item target (@var{options})
5096 @cindex @code{target} function attribute
5097 As discussed in @ref{Common Function Attributes}, this attribute 
5098 allows specification of target-specific compilation options.
5100 When compiling for Nios II, the following options are allowed:
5102 @table @samp
5103 @item custom-@var{insn}=@var{N}
5104 @itemx no-custom-@var{insn}
5105 @cindex @code{target("custom-@var{insn}=@var{N}")} function attribute, Nios II
5106 @cindex @code{target("no-custom-@var{insn}")} function attribute, Nios II
5107 Each @samp{custom-@var{insn}=@var{N}} attribute locally enables use of a
5108 custom instruction with encoding @var{N} when generating code that uses 
5109 @var{insn}.  Similarly, @samp{no-custom-@var{insn}} locally inhibits use of
5110 the custom instruction @var{insn}.
5111 These target attributes correspond to the
5112 @option{-mcustom-@var{insn}=@var{N}} and @option{-mno-custom-@var{insn}}
5113 command-line options, and support the same set of @var{insn} keywords.
5114 @xref{Nios II Options}, for more information.
5116 @item custom-fpu-cfg=@var{name}
5117 @cindex @code{target("custom-fpu-cfg=@var{name}")} function attribute, Nios II
5118 This attribute corresponds to the @option{-mcustom-fpu-cfg=@var{name}}
5119 command-line option, to select a predefined set of custom instructions
5120 named @var{name}.
5121 @xref{Nios II Options}, for more information.
5122 @end table
5123 @end table
5125 @node Nvidia PTX Function Attributes
5126 @subsection Nvidia PTX Function Attributes
5128 These function attributes are supported by the Nvidia PTX back end:
5130 @table @code
5131 @item kernel
5132 @cindex @code{kernel} attribute, Nvidia PTX
5133 This attribute indicates that the corresponding function should be compiled
5134 as a kernel function, which can be invoked from the host via the CUDA RT 
5135 library.
5136 By default functions are only callable only from other PTX functions.
5138 Kernel functions must have @code{void} return type.
5139 @end table
5141 @node PowerPC Function Attributes
5142 @subsection PowerPC Function Attributes
5144 These function attributes are supported by the PowerPC back end:
5146 @table @code
5147 @item longcall
5148 @itemx shortcall
5149 @cindex indirect calls, PowerPC
5150 @cindex @code{longcall} function attribute, PowerPC
5151 @cindex @code{shortcall} function attribute, PowerPC
5152 The @code{longcall} attribute
5153 indicates that the function might be far away from the call site and
5154 require a different (more expensive) calling sequence.  The
5155 @code{shortcall} attribute indicates that the function is always close
5156 enough for the shorter calling sequence to be used.  These attributes
5157 override both the @option{-mlongcall} switch and
5158 the @code{#pragma longcall} setting.
5160 @xref{RS/6000 and PowerPC Options}, for more information on whether long
5161 calls are necessary.
5163 @item target (@var{options})
5164 @cindex @code{target} function attribute
5165 As discussed in @ref{Common Function Attributes}, this attribute 
5166 allows specification of target-specific compilation options.
5168 On the PowerPC, the following options are allowed:
5170 @table @samp
5171 @item altivec
5172 @itemx no-altivec
5173 @cindex @code{target("altivec")} function attribute, PowerPC
5174 Generate code that uses (does not use) AltiVec instructions.  In
5175 32-bit code, you cannot enable AltiVec instructions unless
5176 @option{-mabi=altivec} is used on the command line.
5178 @item cmpb
5179 @itemx no-cmpb
5180 @cindex @code{target("cmpb")} function attribute, PowerPC
5181 Generate code that uses (does not use) the compare bytes instruction
5182 implemented on the POWER6 processor and other processors that support
5183 the PowerPC V2.05 architecture.
5185 @item dlmzb
5186 @itemx no-dlmzb
5187 @cindex @code{target("dlmzb")} function attribute, PowerPC
5188 Generate code that uses (does not use) the string-search @samp{dlmzb}
5189 instruction on the IBM 405, 440, 464 and 476 processors.  This instruction is
5190 generated by default when targeting those processors.
5192 @item fprnd
5193 @itemx no-fprnd
5194 @cindex @code{target("fprnd")} function attribute, PowerPC
5195 Generate code that uses (does not use) the FP round to integer
5196 instructions implemented on the POWER5+ processor and other processors
5197 that support the PowerPC V2.03 architecture.
5199 @item hard-dfp
5200 @itemx no-hard-dfp
5201 @cindex @code{target("hard-dfp")} function attribute, PowerPC
5202 Generate code that uses (does not use) the decimal floating-point
5203 instructions implemented on some POWER processors.
5205 @item isel
5206 @itemx no-isel
5207 @cindex @code{target("isel")} function attribute, PowerPC
5208 Generate code that uses (does not use) ISEL instruction.
5210 @item mfcrf
5211 @itemx no-mfcrf
5212 @cindex @code{target("mfcrf")} function attribute, PowerPC
5213 Generate code that uses (does not use) the move from condition
5214 register field instruction implemented on the POWER4 processor and
5215 other processors that support the PowerPC V2.01 architecture.
5217 @item mfpgpr
5218 @itemx no-mfpgpr
5219 @cindex @code{target("mfpgpr")} function attribute, PowerPC
5220 Generate code that uses (does not use) the FP move to/from general
5221 purpose register instructions implemented on the POWER6X processor and
5222 other processors that support the extended PowerPC V2.05 architecture.
5224 @item mulhw
5225 @itemx no-mulhw
5226 @cindex @code{target("mulhw")} function attribute, PowerPC
5227 Generate code that uses (does not use) the half-word multiply and
5228 multiply-accumulate instructions on the IBM 405, 440, 464 and 476 processors.
5229 These instructions are generated by default when targeting those
5230 processors.
5232 @item multiple
5233 @itemx no-multiple
5234 @cindex @code{target("multiple")} function attribute, PowerPC
5235 Generate code that uses (does not use) the load multiple word
5236 instructions and the store multiple word instructions.
5238 @item update
5239 @itemx no-update
5240 @cindex @code{target("update")} function attribute, PowerPC
5241 Generate code that uses (does not use) the load or store instructions
5242 that update the base register to the address of the calculated memory
5243 location.
5245 @item popcntb
5246 @itemx no-popcntb
5247 @cindex @code{target("popcntb")} function attribute, PowerPC
5248 Generate code that uses (does not use) the popcount and double-precision
5249 FP reciprocal estimate instruction implemented on the POWER5
5250 processor and other processors that support the PowerPC V2.02
5251 architecture.
5253 @item popcntd
5254 @itemx no-popcntd
5255 @cindex @code{target("popcntd")} function attribute, PowerPC
5256 Generate code that uses (does not use) the popcount instruction
5257 implemented on the POWER7 processor and other processors that support
5258 the PowerPC V2.06 architecture.
5260 @item powerpc-gfxopt
5261 @itemx no-powerpc-gfxopt
5262 @cindex @code{target("powerpc-gfxopt")} function attribute, PowerPC
5263 Generate code that uses (does not use) the optional PowerPC
5264 architecture instructions in the Graphics group, including
5265 floating-point select.
5267 @item powerpc-gpopt
5268 @itemx no-powerpc-gpopt
5269 @cindex @code{target("powerpc-gpopt")} function attribute, PowerPC
5270 Generate code that uses (does not use) the optional PowerPC
5271 architecture instructions in the General Purpose group, including
5272 floating-point square root.
5274 @item recip-precision
5275 @itemx no-recip-precision
5276 @cindex @code{target("recip-precision")} function attribute, PowerPC
5277 Assume (do not assume) that the reciprocal estimate instructions
5278 provide higher-precision estimates than is mandated by the PowerPC
5279 ABI.
5281 @item string
5282 @itemx no-string
5283 @cindex @code{target("string")} function attribute, PowerPC
5284 Generate code that uses (does not use) the load string instructions
5285 and the store string word instructions to save multiple registers and
5286 do small block moves.
5288 @item vsx
5289 @itemx no-vsx
5290 @cindex @code{target("vsx")} function attribute, PowerPC
5291 Generate code that uses (does not use) vector/scalar (VSX)
5292 instructions, and also enable the use of built-in functions that allow
5293 more direct access to the VSX instruction set.  In 32-bit code, you
5294 cannot enable VSX or AltiVec instructions unless
5295 @option{-mabi=altivec} is used on the command line.
5297 @item friz
5298 @itemx no-friz
5299 @cindex @code{target("friz")} function attribute, PowerPC
5300 Generate (do not generate) the @code{friz} instruction when the
5301 @option{-funsafe-math-optimizations} option is used to optimize
5302 rounding a floating-point value to 64-bit integer and back to floating
5303 point.  The @code{friz} instruction does not return the same value if
5304 the floating-point number is too large to fit in an integer.
5306 @item avoid-indexed-addresses
5307 @itemx no-avoid-indexed-addresses
5308 @cindex @code{target("avoid-indexed-addresses")} function attribute, PowerPC
5309 Generate code that tries to avoid (not avoid) the use of indexed load
5310 or store instructions.
5312 @item paired
5313 @itemx no-paired
5314 @cindex @code{target("paired")} function attribute, PowerPC
5315 Generate code that uses (does not use) the generation of PAIRED simd
5316 instructions.
5318 @item longcall
5319 @itemx no-longcall
5320 @cindex @code{target("longcall")} function attribute, PowerPC
5321 Generate code that assumes (does not assume) that all calls are far
5322 away so that a longer more expensive calling sequence is required.
5324 @item cpu=@var{CPU}
5325 @cindex @code{target("cpu=@var{CPU}")} function attribute, PowerPC
5326 Specify the architecture to generate code for when compiling the
5327 function.  If you select the @code{target("cpu=power7")} attribute when
5328 generating 32-bit code, VSX and AltiVec instructions are not generated
5329 unless you use the @option{-mabi=altivec} option on the command line.
5331 @item tune=@var{TUNE}
5332 @cindex @code{target("tune=@var{TUNE}")} function attribute, PowerPC
5333 Specify the architecture to tune for when compiling the function.  If
5334 you do not specify the @code{target("tune=@var{TUNE}")} attribute and
5335 you do specify the @code{target("cpu=@var{CPU}")} attribute,
5336 compilation tunes for the @var{CPU} architecture, and not the
5337 default tuning specified on the command line.
5338 @end table
5340 On the PowerPC, the inliner does not inline a
5341 function that has different target options than the caller, unless the
5342 callee has a subset of the target options of the caller.
5343 @end table
5345 @node RISC-V Function Attributes
5346 @subsection RISC-V Function Attributes
5348 These function attributes are supported by the RISC-V back end:
5350 @table @code
5351 @item naked
5352 @cindex @code{naked} function attribute, RISC-V
5353 This attribute allows the compiler to construct the
5354 requisite function declaration, while allowing the body of the
5355 function to be assembly code. The specified function will not have
5356 prologue/epilogue sequences generated by the compiler. Only basic
5357 @code{asm} statements can safely be included in naked functions
5358 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
5359 basic @code{asm} and C code may appear to work, they cannot be
5360 depended upon to work reliably and are not supported.
5362 @item interrupt
5363 @cindex @code{interrupt} function attribute, RISC-V
5364 Use this attribute to indicate that the specified function is an interrupt
5365 handler.  The compiler generates function entry and exit sequences suitable
5366 for use in an interrupt handler when this attribute is present.
5368 You can specify the kind of interrupt to be handled by adding an optional
5369 parameter to the interrupt attribute like this:
5371 @smallexample
5372 void f (void) __attribute__ ((interrupt ("user")));
5373 @end smallexample
5375 Permissible values for this parameter are @code{user}, @code{supervisor},
5376 and @code{machine}.  If there is no parameter, then it defaults to
5377 @code{machine}.
5378 @end table
5380 @node RL78 Function Attributes
5381 @subsection RL78 Function Attributes
5383 These function attributes are supported by the RL78 back end:
5385 @table @code
5386 @item interrupt
5387 @itemx brk_interrupt
5388 @cindex @code{interrupt} function attribute, RL78
5389 @cindex @code{brk_interrupt} function attribute, RL78
5390 These attributes indicate
5391 that the specified function is an interrupt handler.  The compiler generates
5392 function entry and exit sequences suitable for use in an interrupt handler
5393 when this attribute is present.
5395 Use @code{brk_interrupt} instead of @code{interrupt} for
5396 handlers intended to be used with the @code{BRK} opcode (i.e.@: those
5397 that must end with @code{RETB} instead of @code{RETI}).
5399 @item naked
5400 @cindex @code{naked} function attribute, RL78
5401 This attribute allows the compiler to construct the
5402 requisite function declaration, while allowing the body of the
5403 function to be assembly code. The specified function will not have
5404 prologue/epilogue sequences generated by the compiler. Only basic
5405 @code{asm} statements can safely be included in naked functions
5406 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
5407 basic @code{asm} and C code may appear to work, they cannot be
5408 depended upon to work reliably and are not supported.
5409 @end table
5411 @node RX Function Attributes
5412 @subsection RX Function Attributes
5414 These function attributes are supported by the RX back end:
5416 @table @code
5417 @item fast_interrupt
5418 @cindex @code{fast_interrupt} function attribute, RX
5419 Use this attribute on the RX port to indicate that the specified
5420 function is a fast interrupt handler.  This is just like the
5421 @code{interrupt} attribute, except that @code{freit} is used to return
5422 instead of @code{reit}.
5424 @item interrupt
5425 @cindex @code{interrupt} function attribute, RX
5426 Use this attribute to indicate
5427 that the specified function is an interrupt handler.  The compiler generates
5428 function entry and exit sequences suitable for use in an interrupt handler
5429 when this attribute is present.
5431 On RX and RL78 targets, you may specify one or more vector numbers as arguments
5432 to the attribute, as well as naming an alternate table name.
5433 Parameters are handled sequentially, so one handler can be assigned to
5434 multiple entries in multiple tables.  One may also pass the magic
5435 string @code{"$default"} which causes the function to be used for any
5436 unfilled slots in the current table.
5438 This example shows a simple assignment of a function to one vector in
5439 the default table (note that preprocessor macros may be used for
5440 chip-specific symbolic vector names):
5441 @smallexample
5442 void __attribute__ ((interrupt (5))) txd1_handler ();
5443 @end smallexample
5445 This example assigns a function to two slots in the default table
5446 (using preprocessor macros defined elsewhere) and makes it the default
5447 for the @code{dct} table:
5448 @smallexample
5449 void __attribute__ ((interrupt (RXD1_VECT,RXD2_VECT,"dct","$default")))
5450         txd1_handler ();
5451 @end smallexample
5453 @item naked
5454 @cindex @code{naked} function attribute, RX
5455 This attribute allows the compiler to construct the
5456 requisite function declaration, while allowing the body of the
5457 function to be assembly code. The specified function will not have
5458 prologue/epilogue sequences generated by the compiler. Only basic
5459 @code{asm} statements can safely be included in naked functions
5460 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
5461 basic @code{asm} and C code may appear to work, they cannot be
5462 depended upon to work reliably and are not supported.
5464 @item vector
5465 @cindex @code{vector} function attribute, RX
5466 This RX attribute is similar to the @code{interrupt} attribute, including its
5467 parameters, but does not make the function an interrupt-handler type
5468 function (i.e.@: it retains the normal C function calling ABI).  See the
5469 @code{interrupt} attribute for a description of its arguments.
5470 @end table
5472 @node S/390 Function Attributes
5473 @subsection S/390 Function Attributes
5475 These function attributes are supported on the S/390:
5477 @table @code
5478 @item hotpatch (@var{halfwords-before-function-label},@var{halfwords-after-function-label})
5479 @cindex @code{hotpatch} function attribute, S/390
5481 On S/390 System z targets, you can use this function attribute to
5482 make GCC generate a ``hot-patching'' function prologue.  If the
5483 @option{-mhotpatch=} command-line option is used at the same time,
5484 the @code{hotpatch} attribute takes precedence.  The first of the
5485 two arguments specifies the number of halfwords to be added before
5486 the function label.  A second argument can be used to specify the
5487 number of halfwords to be added after the function label.  For
5488 both arguments the maximum allowed value is 1000000.
5490 If both arguments are zero, hotpatching is disabled.
5492 @item target (@var{options})
5493 @cindex @code{target} function attribute
5494 As discussed in @ref{Common Function Attributes}, this attribute
5495 allows specification of target-specific compilation options.
5497 On S/390, the following options are supported:
5499 @table @samp
5500 @item arch=
5501 @item tune=
5502 @item stack-guard=
5503 @item stack-size=
5504 @item branch-cost=
5505 @item warn-framesize=
5506 @item backchain
5507 @itemx no-backchain
5508 @item hard-dfp
5509 @itemx no-hard-dfp
5510 @item hard-float
5511 @itemx soft-float
5512 @item htm
5513 @itemx no-htm
5514 @item vx
5515 @itemx no-vx
5516 @item packed-stack
5517 @itemx no-packed-stack
5518 @item small-exec
5519 @itemx no-small-exec
5520 @item mvcle
5521 @itemx no-mvcle
5522 @item warn-dynamicstack
5523 @itemx no-warn-dynamicstack
5524 @end table
5526 The options work exactly like the S/390 specific command line
5527 options (without the prefix @option{-m}) except that they do not
5528 change any feature macros.  For example,
5530 @smallexample
5531 @code{target("no-vx")}
5532 @end smallexample
5534 does not undefine the @code{__VEC__} macro.
5535 @end table
5537 @node SH Function Attributes
5538 @subsection SH Function Attributes
5540 These function attributes are supported on the SH family of processors:
5542 @table @code
5543 @item function_vector
5544 @cindex @code{function_vector} function attribute, SH
5545 @cindex calling functions through the function vector on SH2A
5546 On SH2A targets, this attribute declares a function to be called using the
5547 TBR relative addressing mode.  The argument to this attribute is the entry
5548 number of the same function in a vector table containing all the TBR
5549 relative addressable functions.  For correct operation the TBR must be setup
5550 accordingly to point to the start of the vector table before any functions with
5551 this attribute are invoked.  Usually a good place to do the initialization is
5552 the startup routine.  The TBR relative vector table can have at max 256 function
5553 entries.  The jumps to these functions are generated using a SH2A specific,
5554 non delayed branch instruction JSR/N @@(disp8,TBR).  You must use GAS and GLD
5555 from GNU binutils version 2.7 or later for this attribute to work correctly.
5557 In an application, for a function being called once, this attribute
5558 saves at least 8 bytes of code; and if other successive calls are being
5559 made to the same function, it saves 2 bytes of code per each of these
5560 calls.
5562 @item interrupt_handler
5563 @cindex @code{interrupt_handler} function attribute, SH
5564 Use this attribute to
5565 indicate that the specified function is an interrupt handler.  The compiler
5566 generates function entry and exit sequences suitable for use in an
5567 interrupt handler when this attribute is present.
5569 @item nosave_low_regs
5570 @cindex @code{nosave_low_regs} function attribute, SH
5571 Use this attribute on SH targets to indicate that an @code{interrupt_handler}
5572 function should not save and restore registers R0..R7.  This can be used on SH3*
5573 and SH4* targets that have a second R0..R7 register bank for non-reentrant
5574 interrupt handlers.
5576 @item renesas
5577 @cindex @code{renesas} function attribute, SH
5578 On SH targets this attribute specifies that the function or struct follows the
5579 Renesas ABI.
5581 @item resbank
5582 @cindex @code{resbank} function attribute, SH
5583 On the SH2A target, this attribute enables the high-speed register
5584 saving and restoration using a register bank for @code{interrupt_handler}
5585 routines.  Saving to the bank is performed automatically after the CPU
5586 accepts an interrupt that uses a register bank.
5588 The nineteen 32-bit registers comprising general register R0 to R14,
5589 control register GBR, and system registers MACH, MACL, and PR and the
5590 vector table address offset are saved into a register bank.  Register
5591 banks are stacked in first-in last-out (FILO) sequence.  Restoration
5592 from the bank is executed by issuing a RESBANK instruction.
5594 @item sp_switch
5595 @cindex @code{sp_switch} function attribute, SH
5596 Use this attribute on the SH to indicate an @code{interrupt_handler}
5597 function should switch to an alternate stack.  It expects a string
5598 argument that names a global variable holding the address of the
5599 alternate stack.
5601 @smallexample
5602 void *alt_stack;
5603 void f () __attribute__ ((interrupt_handler,
5604                           sp_switch ("alt_stack")));
5605 @end smallexample
5607 @item trap_exit
5608 @cindex @code{trap_exit} function attribute, SH
5609 Use this attribute on the SH for an @code{interrupt_handler} to return using
5610 @code{trapa} instead of @code{rte}.  This attribute expects an integer
5611 argument specifying the trap number to be used.
5613 @item trapa_handler
5614 @cindex @code{trapa_handler} function attribute, SH
5615 On SH targets this function attribute is similar to @code{interrupt_handler}
5616 but it does not save and restore all registers.
5617 @end table
5619 @node SPU Function Attributes
5620 @subsection SPU Function Attributes
5622 These function attributes are supported by the SPU back end:
5624 @table @code
5625 @item naked
5626 @cindex @code{naked} function attribute, SPU
5627 This attribute allows the compiler to construct the
5628 requisite function declaration, while allowing the body of the
5629 function to be assembly code. The specified function will not have
5630 prologue/epilogue sequences generated by the compiler. Only basic
5631 @code{asm} statements can safely be included in naked functions
5632 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
5633 basic @code{asm} and C code may appear to work, they cannot be
5634 depended upon to work reliably and are not supported.
5635 @end table
5637 @node Symbian OS Function Attributes
5638 @subsection Symbian OS Function Attributes
5640 @xref{Microsoft Windows Function Attributes}, for discussion of the
5641 @code{dllexport} and @code{dllimport} attributes.
5643 @node V850 Function Attributes
5644 @subsection V850 Function Attributes
5646 The V850 back end supports these function attributes:
5648 @table @code
5649 @item interrupt
5650 @itemx interrupt_handler
5651 @cindex @code{interrupt} function attribute, V850
5652 @cindex @code{interrupt_handler} function attribute, V850
5653 Use these attributes to indicate
5654 that the specified function is an interrupt handler.  The compiler generates
5655 function entry and exit sequences suitable for use in an interrupt handler
5656 when either attribute is present.
5657 @end table
5659 @node Visium Function Attributes
5660 @subsection Visium Function Attributes
5662 These function attributes are supported by the Visium back end:
5664 @table @code
5665 @item interrupt
5666 @cindex @code{interrupt} function attribute, Visium
5667 Use this attribute to indicate
5668 that the specified function is an interrupt handler.  The compiler generates
5669 function entry and exit sequences suitable for use in an interrupt handler
5670 when this attribute is present.
5671 @end table
5673 @node x86 Function Attributes
5674 @subsection x86 Function Attributes
5676 These function attributes are supported by the x86 back end:
5678 @table @code
5679 @item cdecl
5680 @cindex @code{cdecl} function attribute, x86-32
5681 @cindex functions that pop the argument stack on x86-32
5682 @opindex mrtd
5683 On the x86-32 targets, the @code{cdecl} attribute causes the compiler to
5684 assume that the calling function pops off the stack space used to
5685 pass arguments.  This is
5686 useful to override the effects of the @option{-mrtd} switch.
5688 @item fastcall
5689 @cindex @code{fastcall} function attribute, x86-32
5690 @cindex functions that pop the argument stack on x86-32
5691 On x86-32 targets, the @code{fastcall} attribute causes the compiler to
5692 pass the first argument (if of integral type) in the register ECX and
5693 the second argument (if of integral type) in the register EDX@.  Subsequent
5694 and other typed arguments are passed on the stack.  The called function
5695 pops the arguments off the stack.  If the number of arguments is variable all
5696 arguments are pushed on the stack.
5698 @item thiscall
5699 @cindex @code{thiscall} function attribute, x86-32
5700 @cindex functions that pop the argument stack on x86-32
5701 On x86-32 targets, the @code{thiscall} attribute causes the compiler to
5702 pass the first argument (if of integral type) in the register ECX.
5703 Subsequent and other typed arguments are passed on the stack. The called
5704 function pops the arguments off the stack.
5705 If the number of arguments is variable all arguments are pushed on the
5706 stack.
5707 The @code{thiscall} attribute is intended for C++ non-static member functions.
5708 As a GCC extension, this calling convention can be used for C functions
5709 and for static member methods.
5711 @item ms_abi
5712 @itemx sysv_abi
5713 @cindex @code{ms_abi} function attribute, x86
5714 @cindex @code{sysv_abi} function attribute, x86
5716 On 32-bit and 64-bit x86 targets, you can use an ABI attribute
5717 to indicate which calling convention should be used for a function.  The
5718 @code{ms_abi} attribute tells the compiler to use the Microsoft ABI,
5719 while the @code{sysv_abi} attribute tells the compiler to use the ABI
5720 used on GNU/Linux and other systems.  The default is to use the Microsoft ABI
5721 when targeting Windows.  On all other systems, the default is the x86/AMD ABI.
5723 Note, the @code{ms_abi} attribute for Microsoft Windows 64-bit targets currently
5724 requires the @option{-maccumulate-outgoing-args} option.
5726 @item callee_pop_aggregate_return (@var{number})
5727 @cindex @code{callee_pop_aggregate_return} function attribute, x86
5729 On x86-32 targets, you can use this attribute to control how
5730 aggregates are returned in memory.  If the caller is responsible for
5731 popping the hidden pointer together with the rest of the arguments, specify
5732 @var{number} equal to zero.  If callee is responsible for popping the
5733 hidden pointer, specify @var{number} equal to one.  
5735 The default x86-32 ABI assumes that the callee pops the
5736 stack for hidden pointer.  However, on x86-32 Microsoft Windows targets,
5737 the compiler assumes that the
5738 caller pops the stack for hidden pointer.
5740 @item ms_hook_prologue
5741 @cindex @code{ms_hook_prologue} function attribute, x86
5743 On 32-bit and 64-bit x86 targets, you can use
5744 this function attribute to make GCC generate the ``hot-patching'' function
5745 prologue used in Win32 API functions in Microsoft Windows XP Service Pack 2
5746 and newer.
5748 @item naked
5749 @cindex @code{naked} function attribute, x86
5750 This attribute allows the compiler to construct the
5751 requisite function declaration, while allowing the body of the
5752 function to be assembly code. The specified function will not have
5753 prologue/epilogue sequences generated by the compiler. Only basic
5754 @code{asm} statements can safely be included in naked functions
5755 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
5756 basic @code{asm} and C code may appear to work, they cannot be
5757 depended upon to work reliably and are not supported.
5759 @item regparm (@var{number})
5760 @cindex @code{regparm} function attribute, x86
5761 @cindex functions that are passed arguments in registers on x86-32
5762 On x86-32 targets, the @code{regparm} attribute causes the compiler to
5763 pass arguments number one to @var{number} if they are of integral type
5764 in registers EAX, EDX, and ECX instead of on the stack.  Functions that
5765 take a variable number of arguments continue to be passed all of their
5766 arguments on the stack.
5768 Beware that on some ELF systems this attribute is unsuitable for
5769 global functions in shared libraries with lazy binding (which is the
5770 default).  Lazy binding sends the first call via resolving code in
5771 the loader, which might assume EAX, EDX and ECX can be clobbered, as
5772 per the standard calling conventions.  Solaris 8 is affected by this.
5773 Systems with the GNU C Library version 2.1 or higher
5774 and FreeBSD are believed to be
5775 safe since the loaders there save EAX, EDX and ECX.  (Lazy binding can be
5776 disabled with the linker or the loader if desired, to avoid the
5777 problem.)
5779 @item sseregparm
5780 @cindex @code{sseregparm} function attribute, x86
5781 On x86-32 targets with SSE support, the @code{sseregparm} attribute
5782 causes the compiler to pass up to 3 floating-point arguments in
5783 SSE registers instead of on the stack.  Functions that take a
5784 variable number of arguments continue to pass all of their
5785 floating-point arguments on the stack.
5787 @item force_align_arg_pointer
5788 @cindex @code{force_align_arg_pointer} function attribute, x86
5789 On x86 targets, the @code{force_align_arg_pointer} attribute may be
5790 applied to individual function definitions, generating an alternate
5791 prologue and epilogue that realigns the run-time stack if necessary.
5792 This supports mixing legacy codes that run with a 4-byte aligned stack
5793 with modern codes that keep a 16-byte stack for SSE compatibility.
5795 @item stdcall
5796 @cindex @code{stdcall} function attribute, x86-32
5797 @cindex functions that pop the argument stack on x86-32
5798 On x86-32 targets, the @code{stdcall} attribute causes the compiler to
5799 assume that the called function pops off the stack space used to
5800 pass arguments, unless it takes a variable number of arguments.
5802 @item no_caller_saved_registers
5803 @cindex @code{no_caller_saved_registers} function attribute, x86
5804 Use this attribute to indicate that the specified function has no
5805 caller-saved registers. That is, all registers are callee-saved. For
5806 example, this attribute can be used for a function called from an
5807 interrupt handler. The compiler generates proper function entry and
5808 exit sequences to save and restore any modified registers, except for
5809 the EFLAGS register.  Since GCC doesn't preserve SSE, MMX nor x87
5810 states, the GCC option @option{-mgeneral-regs-only} should be used to
5811 compile functions with @code{no_caller_saved_registers} attribute.
5813 @item interrupt
5814 @cindex @code{interrupt} function attribute, x86
5815 Use this attribute to indicate that the specified function is an
5816 interrupt handler or an exception handler (depending on parameters passed
5817 to the function, explained further).  The compiler generates function
5818 entry and exit sequences suitable for use in an interrupt handler when
5819 this attribute is present.  The @code{IRET} instruction, instead of the
5820 @code{RET} instruction, is used to return from interrupt handlers.  All
5821 registers, except for the EFLAGS register which is restored by the
5822 @code{IRET} instruction, are preserved by the compiler.  Since GCC
5823 doesn't preserve SSE, MMX nor x87 states, the GCC option
5824 @option{-mgeneral-regs-only} should be used to compile interrupt and
5825 exception handlers.
5827 Any interruptible-without-stack-switch code must be compiled with
5828 @option{-mno-red-zone} since interrupt handlers can and will, because
5829 of the hardware design, touch the red zone.
5831 An interrupt handler must be declared with a mandatory pointer
5832 argument:
5834 @smallexample
5835 struct interrupt_frame;
5837 __attribute__ ((interrupt))
5838 void
5839 f (struct interrupt_frame *frame)
5842 @end smallexample
5844 @noindent
5845 and you must define @code{struct interrupt_frame} as described in the
5846 processor's manual.
5848 Exception handlers differ from interrupt handlers because the system
5849 pushes an error code on the stack.  An exception handler declaration is
5850 similar to that for an interrupt handler, but with a different mandatory
5851 function signature.  The compiler arranges to pop the error code off the
5852 stack before the @code{IRET} instruction.
5854 @smallexample
5855 #ifdef __x86_64__
5856 typedef unsigned long long int uword_t;
5857 #else
5858 typedef unsigned int uword_t;
5859 #endif
5861 struct interrupt_frame;
5863 __attribute__ ((interrupt))
5864 void
5865 f (struct interrupt_frame *frame, uword_t error_code)
5867   ...
5869 @end smallexample
5871 Exception handlers should only be used for exceptions that push an error
5872 code; you should use an interrupt handler in other cases.  The system
5873 will crash if the wrong kind of handler is used.
5875 @item target (@var{options})
5876 @cindex @code{target} function attribute
5877 As discussed in @ref{Common Function Attributes}, this attribute 
5878 allows specification of target-specific compilation options.
5880 On the x86, the following options are allowed:
5881 @table @samp
5882 @item abm
5883 @itemx no-abm
5884 @cindex @code{target("abm")} function attribute, x86
5885 Enable/disable the generation of the advanced bit instructions.
5887 @item aes
5888 @itemx no-aes
5889 @cindex @code{target("aes")} function attribute, x86
5890 Enable/disable the generation of the AES instructions.
5892 @item default
5893 @cindex @code{target("default")} function attribute, x86
5894 @xref{Function Multiversioning}, where it is used to specify the
5895 default function version.
5897 @item mmx
5898 @itemx no-mmx
5899 @cindex @code{target("mmx")} function attribute, x86
5900 Enable/disable the generation of the MMX instructions.
5902 @item pclmul
5903 @itemx no-pclmul
5904 @cindex @code{target("pclmul")} function attribute, x86
5905 Enable/disable the generation of the PCLMUL instructions.
5907 @item popcnt
5908 @itemx no-popcnt
5909 @cindex @code{target("popcnt")} function attribute, x86
5910 Enable/disable the generation of the POPCNT instruction.
5912 @item sse
5913 @itemx no-sse
5914 @cindex @code{target("sse")} function attribute, x86
5915 Enable/disable the generation of the SSE instructions.
5917 @item sse2
5918 @itemx no-sse2
5919 @cindex @code{target("sse2")} function attribute, x86
5920 Enable/disable the generation of the SSE2 instructions.
5922 @item sse3
5923 @itemx no-sse3
5924 @cindex @code{target("sse3")} function attribute, x86
5925 Enable/disable the generation of the SSE3 instructions.
5927 @item sse4
5928 @itemx no-sse4
5929 @cindex @code{target("sse4")} function attribute, x86
5930 Enable/disable the generation of the SSE4 instructions (both SSE4.1
5931 and SSE4.2).
5933 @item sse4.1
5934 @itemx no-sse4.1
5935 @cindex @code{target("sse4.1")} function attribute, x86
5936 Enable/disable the generation of the sse4.1 instructions.
5938 @item sse4.2
5939 @itemx no-sse4.2
5940 @cindex @code{target("sse4.2")} function attribute, x86
5941 Enable/disable the generation of the sse4.2 instructions.
5943 @item sse4a
5944 @itemx no-sse4a
5945 @cindex @code{target("sse4a")} function attribute, x86
5946 Enable/disable the generation of the SSE4A instructions.
5948 @item fma4
5949 @itemx no-fma4
5950 @cindex @code{target("fma4")} function attribute, x86
5951 Enable/disable the generation of the FMA4 instructions.
5953 @item xop
5954 @itemx no-xop
5955 @cindex @code{target("xop")} function attribute, x86
5956 Enable/disable the generation of the XOP instructions.
5958 @item lwp
5959 @itemx no-lwp
5960 @cindex @code{target("lwp")} function attribute, x86
5961 Enable/disable the generation of the LWP instructions.
5963 @item ssse3
5964 @itemx no-ssse3
5965 @cindex @code{target("ssse3")} function attribute, x86
5966 Enable/disable the generation of the SSSE3 instructions.
5968 @item cld
5969 @itemx no-cld
5970 @cindex @code{target("cld")} function attribute, x86
5971 Enable/disable the generation of the CLD before string moves.
5973 @item fancy-math-387
5974 @itemx no-fancy-math-387
5975 @cindex @code{target("fancy-math-387")} function attribute, x86
5976 Enable/disable the generation of the @code{sin}, @code{cos}, and
5977 @code{sqrt} instructions on the 387 floating-point unit.
5979 @item ieee-fp
5980 @itemx no-ieee-fp
5981 @cindex @code{target("ieee-fp")} function attribute, x86
5982 Enable/disable the generation of floating point that depends on IEEE arithmetic.
5984 @item inline-all-stringops
5985 @itemx no-inline-all-stringops
5986 @cindex @code{target("inline-all-stringops")} function attribute, x86
5987 Enable/disable inlining of string operations.
5989 @item inline-stringops-dynamically
5990 @itemx no-inline-stringops-dynamically
5991 @cindex @code{target("inline-stringops-dynamically")} function attribute, x86
5992 Enable/disable the generation of the inline code to do small string
5993 operations and calling the library routines for large operations.
5995 @item align-stringops
5996 @itemx no-align-stringops
5997 @cindex @code{target("align-stringops")} function attribute, x86
5998 Do/do not align destination of inlined string operations.
6000 @item recip
6001 @itemx no-recip
6002 @cindex @code{target("recip")} function attribute, x86
6003 Enable/disable the generation of RCPSS, RCPPS, RSQRTSS and RSQRTPS
6004 instructions followed an additional Newton-Raphson step instead of
6005 doing a floating-point division.
6007 @item arch=@var{ARCH}
6008 @cindex @code{target("arch=@var{ARCH}")} function attribute, x86
6009 Specify the architecture to generate code for in compiling the function.
6011 @item tune=@var{TUNE}
6012 @cindex @code{target("tune=@var{TUNE}")} function attribute, x86
6013 Specify the architecture to tune for in compiling the function.
6015 @item fpmath=@var{FPMATH}
6016 @cindex @code{target("fpmath=@var{FPMATH}")} function attribute, x86
6017 Specify which floating-point unit to use.  You must specify the
6018 @code{target("fpmath=sse,387")} option as
6019 @code{target("fpmath=sse+387")} because the comma would separate
6020 different options.
6022 @item indirect_branch("@var{choice}")
6023 @cindex @code{indirect_branch} function attribute, x86
6024 On x86 targets, the @code{indirect_branch} attribute causes the compiler
6025 to convert indirect call and jump with @var{choice}.  @samp{keep}
6026 keeps indirect call and jump unmodified.  @samp{thunk} converts indirect
6027 call and jump to call and return thunk.  @samp{thunk-inline} converts
6028 indirect call and jump to inlined call and return thunk.
6029 @samp{thunk-extern} converts indirect call and jump to external call
6030 and return thunk provided in a separate object file.
6032 @item function_return("@var{choice}")
6033 @cindex @code{function_return} function attribute, x86
6034 On x86 targets, the @code{function_return} attribute causes the compiler
6035 to convert function return with @var{choice}.  @samp{keep} keeps function
6036 return unmodified.  @samp{thunk} converts function return to call and
6037 return thunk.  @samp{thunk-inline} converts function return to inlined
6038 call and return thunk.  @samp{thunk-extern} converts function return to
6039 external call and return thunk provided in a separate object file.
6041 @item nocf_check
6042 @cindex @code{nocf_check} function attribute
6043 The @code{nocf_check} attribute on a function is used to inform the
6044 compiler that the function's prologue should not be instrumented when
6045 compiled with the @option{-fcf-protection=branch} option.  The
6046 compiler assumes that the function's address is a valid target for a
6047 control-flow transfer.
6049 The @code{nocf_check} attribute on a type of pointer to function is
6050 used to inform the compiler that a call through the pointer should
6051 not be instrumented when compiled with the
6052 @option{-fcf-protection=branch} option.  The compiler assumes
6053 that the function's address from the pointer is a valid target for
6054 a control-flow transfer.  A direct function call through a function
6055 name is assumed to be a safe call thus direct calls are not
6056 instrumented by the compiler.
6058 The @code{nocf_check} attribute is applied to an object's type.
6059 In case of assignment of a function address or a function pointer to
6060 another pointer, the attribute is not carried over from the right-hand
6061 object's type; the type of left-hand object stays unchanged.  The
6062 compiler checks for @code{nocf_check} attribute mismatch and reports
6063 a warning in case of mismatch.
6065 @smallexample
6067 int foo (void) __attribute__(nocf_check);
6068 void (*foo1)(void) __attribute__(nocf_check);
6069 void (*foo2)(void);
6071 /* foo's address is assumed to be valid.  */
6073 foo (void) 
6075   /* This call site is not checked for control-flow 
6076      validity.  */
6077   (*foo1)();
6079   /* A warning is issued about attribute mismatch.  */
6080   foo1 = foo2; 
6082   /* This call site is still not checked.  */
6083   (*foo1)();
6085   /* This call site is checked.  */
6086   (*foo2)();
6088   /* A warning is issued about attribute mismatch.  */
6089   foo2 = foo1; 
6091   /* This call site is still checked.  */
6092   (*foo2)();
6094   return 0;
6096 @end smallexample
6098 @item indirect_return
6099 @cindex @code{indirect_return} function attribute, x86
6101 The @code{indirect_return} attribute can be applied to a function,
6102 as well as variable or type of function pointer to inform the
6103 compiler that the function may return via indirect branch.
6105 @item fentry_name("@var{name}")
6106 @cindex @code{fentry_name} function attribute, x86
6107 On x86 targets, the @code{fentry_name} attribute sets the function to
6108 call on function entry when function instrumentation is enabled
6109 with @option{-pg -mfentry}. When @var{name} is nop then a 5 byte
6110 nop sequence is generated.
6112 @item fentry_section("@var{name}")
6113 @cindex @code{fentry_section} function attribute, x86
6114 On x86 targets, the @code{fentry_section} attribute sets the name
6115 of the section to record function entry instrumentation calls in when
6116 enabled with @option{-pg -mrecord-mcount}
6118 @end table
6120 On the x86, the inliner does not inline a
6121 function that has different target options than the caller, unless the
6122 callee has a subset of the target options of the caller.  For example
6123 a function declared with @code{target("sse3")} can inline a function
6124 with @code{target("sse2")}, since @code{-msse3} implies @code{-msse2}.
6125 @end table
6127 @node Xstormy16 Function Attributes
6128 @subsection Xstormy16 Function Attributes
6130 These function attributes are supported by the Xstormy16 back end:
6132 @table @code
6133 @item interrupt
6134 @cindex @code{interrupt} function attribute, Xstormy16
6135 Use this attribute to indicate
6136 that the specified function is an interrupt handler.  The compiler generates
6137 function entry and exit sequences suitable for use in an interrupt handler
6138 when this attribute is present.
6139 @end table
6141 @node Variable Attributes
6142 @section Specifying Attributes of Variables
6143 @cindex attribute of variables
6144 @cindex variable attributes
6146 The keyword @code{__attribute__} allows you to specify special properties
6147 of variables, function parameters, or structure, union, and, in C++, class
6148 members.  This @code{__attribute__} keyword is followed by an attribute
6149 specification enclosed in double parentheses.  Some attributes are currently
6150 defined generically for variables.  Other attributes are defined for
6151 variables on particular target systems.  Other attributes are available
6152 for functions (@pxref{Function Attributes}), labels (@pxref{Label Attributes}),
6153 enumerators (@pxref{Enumerator Attributes}), statements
6154 (@pxref{Statement Attributes}), and for types (@pxref{Type Attributes}).
6155 Other front ends might define more attributes
6156 (@pxref{C++ Extensions,,Extensions to the C++ Language}).
6158 @xref{Attribute Syntax}, for details of the exact syntax for using
6159 attributes.
6161 @menu
6162 * Common Variable Attributes::
6163 * ARC Variable Attributes::
6164 * AVR Variable Attributes::
6165 * Blackfin Variable Attributes::
6166 * H8/300 Variable Attributes::
6167 * IA-64 Variable Attributes::
6168 * M32R/D Variable Attributes::
6169 * MeP Variable Attributes::
6170 * Microsoft Windows Variable Attributes::
6171 * MSP430 Variable Attributes::
6172 * Nvidia PTX Variable Attributes::
6173 * PowerPC Variable Attributes::
6174 * RL78 Variable Attributes::
6175 * SPU Variable Attributes::
6176 * V850 Variable Attributes::
6177 * x86 Variable Attributes::
6178 * Xstormy16 Variable Attributes::
6179 @end menu
6181 @node Common Variable Attributes
6182 @subsection Common Variable Attributes
6184 The following attributes are supported on most targets.
6186 @table @code
6187 @cindex @code{aligned} variable attribute
6188 @item aligned
6189 @itemx aligned (@var{alignment})
6190 The @code{aligned} attribute specifies a minimum alignment for the variable
6191 or structure field, measured in bytes.  When specified, @var{alignment} must
6192 be an integer constant power of 2.  Specifying no @var{alignment} argument
6193 implies the maximum alignment for the target, which is often, but by no
6194 means always, 8 or 16 bytes.
6196 For example, the declaration:
6198 @smallexample
6199 int x __attribute__ ((aligned (16))) = 0;
6200 @end smallexample
6202 @noindent
6203 causes the compiler to allocate the global variable @code{x} on a
6204 16-byte boundary.  On a 68040, this could be used in conjunction with
6205 an @code{asm} expression to access the @code{move16} instruction which
6206 requires 16-byte aligned operands.
6208 You can also specify the alignment of structure fields.  For example, to
6209 create a double-word aligned @code{int} pair, you could write:
6211 @smallexample
6212 struct foo @{ int x[2] __attribute__ ((aligned (8))); @};
6213 @end smallexample
6215 @noindent
6216 This is an alternative to creating a union with a @code{double} member,
6217 which forces the union to be double-word aligned.
6219 As in the preceding examples, you can explicitly specify the alignment
6220 (in bytes) that you wish the compiler to use for a given variable or
6221 structure field.  Alternatively, you can leave out the alignment factor
6222 and just ask the compiler to align a variable or field to the
6223 default alignment for the target architecture you are compiling for.
6224 The default alignment is sufficient for all scalar types, but may not be
6225 enough for all vector types on a target that supports vector operations.
6226 The default alignment is fixed for a particular target ABI.
6228 GCC also provides a target specific macro @code{__BIGGEST_ALIGNMENT__},
6229 which is the largest alignment ever used for any data type on the
6230 target machine you are compiling for.  For example, you could write:
6232 @smallexample
6233 short array[3] __attribute__ ((aligned (__BIGGEST_ALIGNMENT__)));
6234 @end smallexample
6236 The compiler automatically sets the alignment for the declared
6237 variable or field to @code{__BIGGEST_ALIGNMENT__}.  Doing this can
6238 often make copy operations more efficient, because the compiler can
6239 use whatever instructions copy the biggest chunks of memory when
6240 performing copies to or from the variables or fields that you have
6241 aligned this way.  Note that the value of @code{__BIGGEST_ALIGNMENT__}
6242 may change depending on command-line options.
6244 When used on a struct, or struct member, the @code{aligned} attribute can
6245 only increase the alignment; in order to decrease it, the @code{packed}
6246 attribute must be specified as well.  When used as part of a typedef, the
6247 @code{aligned} attribute can both increase and decrease alignment, and
6248 specifying the @code{packed} attribute generates a warning.
6250 Note that the effectiveness of @code{aligned} attributes for static
6251 variables may be limited by inherent limitations in the system linker
6252 and/or object file format.  On some systems, the linker is
6253 only able to arrange for variables to be aligned up to a certain maximum
6254 alignment.  (For some linkers, the maximum supported alignment may
6255 be very very small.)  If your linker is only able to align variables
6256 up to a maximum of 8-byte alignment, then specifying @code{aligned(16)}
6257 in an @code{__attribute__} still only provides you with 8-byte
6258 alignment.  See your linker documentation for further information.
6260 Stack variables are not affected by linker restrictions; GCC can properly
6261 align them on any target.
6263 The @code{aligned} attribute can also be used for functions
6264 (@pxref{Common Function Attributes}.)
6266 @cindex @code{warn_if_not_aligned} variable attribute
6267 @item warn_if_not_aligned (@var{alignment})
6268 This attribute specifies a threshold for the structure field, measured
6269 in bytes.  If the structure field is aligned below the threshold, a
6270 warning will be issued.  For example, the declaration:
6272 @smallexample
6273 struct foo
6275   int i1;
6276   int i2;
6277   unsigned long long x __attribute__ ((warn_if_not_aligned (16)));
6279 @end smallexample
6281 @noindent
6282 causes the compiler to issue an warning on @code{struct foo}, like
6283 @samp{warning: alignment 8 of 'struct foo' is less than 16}.
6284 The compiler also issues a warning, like @samp{warning: 'x' offset
6285 8 in 'struct foo' isn't aligned to 16}, when the structure field has
6286 the misaligned offset:
6288 @smallexample
6289 struct __attribute__ ((aligned (16))) foo
6291   int i1;
6292   int i2;
6293   unsigned long long x __attribute__ ((warn_if_not_aligned (16)));
6295 @end smallexample
6297 This warning can be disabled by @option{-Wno-if-not-aligned}.
6298 The @code{warn_if_not_aligned} attribute can also be used for types
6299 (@pxref{Common Type Attributes}.)
6301 @item cleanup (@var{cleanup_function})
6302 @cindex @code{cleanup} variable attribute
6303 The @code{cleanup} attribute runs a function when the variable goes
6304 out of scope.  This attribute can only be applied to auto function
6305 scope variables; it may not be applied to parameters or variables
6306 with static storage duration.  The function must take one parameter,
6307 a pointer to a type compatible with the variable.  The return value
6308 of the function (if any) is ignored.
6310 If @option{-fexceptions} is enabled, then @var{cleanup_function}
6311 is run during the stack unwinding that happens during the
6312 processing of the exception.  Note that the @code{cleanup} attribute
6313 does not allow the exception to be caught, only to perform an action.
6314 It is undefined what happens if @var{cleanup_function} does not
6315 return normally.
6317 @item common
6318 @itemx nocommon
6319 @cindex @code{common} variable attribute
6320 @cindex @code{nocommon} variable attribute
6321 @opindex fcommon
6322 @opindex fno-common
6323 The @code{common} attribute requests GCC to place a variable in
6324 ``common'' storage.  The @code{nocommon} attribute requests the
6325 opposite---to allocate space for it directly.
6327 These attributes override the default chosen by the
6328 @option{-fno-common} and @option{-fcommon} flags respectively.
6330 @item copy
6331 @itemx copy (@var{variable})
6332 @cindex @code{copy} variable attribute
6333 The @code{copy} attribute applies the set of attributes with which
6334 @var{variable} has been declared to the declaration of the variable
6335 to which the attribute is applied.  The attribute is designed for
6336 libraries that define aliases that are expected to specify the same
6337 set of attributes as the aliased symbols.  The @code{copy} attribute
6338 can be used with variables, functions or types.  However, the kind
6339 of symbol to which the attribute is applied (either varible or
6340 function) must match the kind of symbol to which the argument refers.
6341 The @code{copy} attribute copies only syntactic and semantic attributes
6342 but not attributes that affect a symbol's linkage or visibility such as
6343 @code{alias}, @code{visibility}, or @code{weak}.  The @code{deprecated}
6344 attribute is also not copied.  @xref{Common Function Attributes}.
6345 @xref{Common Type Attributes}.
6347 @item deprecated
6348 @itemx deprecated (@var{msg})
6349 @cindex @code{deprecated} variable attribute
6350 The @code{deprecated} attribute results in a warning if the variable
6351 is used anywhere in the source file.  This is useful when identifying
6352 variables that are expected to be removed in a future version of a
6353 program.  The warning also includes the location of the declaration
6354 of the deprecated variable, to enable users to easily find further
6355 information about why the variable is deprecated, or what they should
6356 do instead.  Note that the warning only occurs for uses:
6358 @smallexample
6359 extern int old_var __attribute__ ((deprecated));
6360 extern int old_var;
6361 int new_fn () @{ return old_var; @}
6362 @end smallexample
6364 @noindent
6365 results in a warning on line 3 but not line 2.  The optional @var{msg}
6366 argument, which must be a string, is printed in the warning if
6367 present.
6369 The @code{deprecated} attribute can also be used for functions and
6370 types (@pxref{Common Function Attributes},
6371 @pxref{Common Type Attributes}).
6373 The message attached to the attribute is affected by the setting of
6374 the @option{-fmessage-length} option.
6376 @item mode (@var{mode})
6377 @cindex @code{mode} variable attribute
6378 This attribute specifies the data type for the declaration---whichever
6379 type corresponds to the mode @var{mode}.  This in effect lets you
6380 request an integer or floating-point type according to its width.
6382 @xref{Machine Modes,,, gccint, GNU Compiler Collection (GCC) Internals},
6383 for a list of the possible keywords for @var{mode}.
6384 You may also specify a mode of @code{byte} or @code{__byte__} to
6385 indicate the mode corresponding to a one-byte integer, @code{word} or
6386 @code{__word__} for the mode of a one-word integer, and @code{pointer}
6387 or @code{__pointer__} for the mode used to represent pointers.
6389 @item nonstring
6390 @cindex @code{nonstring} variable attribute
6391 The @code{nonstring} variable attribute specifies that an object or member
6392 declaration with type array of @code{char}, @code{signed char}, or
6393 @code{unsigned char}, or pointer to such a type is intended to store
6394 character arrays that do not necessarily contain a terminating @code{NUL}.
6395 This is useful in detecting uses of such arrays or pointers with functions
6396 that expect @code{NUL}-terminated strings, and to avoid warnings when such
6397 an array or pointer is used as an argument to a bounded string manipulation
6398 function such as @code{strncpy}.  For example, without the attribute, GCC
6399 will issue a warning for the @code{strncpy} call below because it may
6400 truncate the copy without appending the terminating @code{NUL} character.
6401 Using the attribute makes it possible to suppress the warning.  However,
6402 when the array is declared with the attribute the call to @code{strlen} is
6403 diagnosed because when the array doesn't contain a @code{NUL}-terminated
6404 string the call is undefined.  To copy, compare, of search non-string
6405 character arrays use the @code{memcpy}, @code{memcmp}, @code{memchr},
6406 and other functions that operate on arrays of bytes.  In addition,
6407 calling @code{strnlen} and @code{strndup} with such arrays is safe
6408 provided a suitable bound is specified, and not diagnosed.
6410 @smallexample
6411 struct Data
6413   char name [32] __attribute__ ((nonstring));
6416 int f (struct Data *pd, const char *s)
6418   strncpy (pd->name, s, sizeof pd->name);
6419   @dots{}
6420   return strlen (pd->name);   // unsafe, gets a warning
6422 @end smallexample
6424 @item packed
6425 @cindex @code{packed} variable attribute
6426 The @code{packed} attribute specifies that a structure member should have
6427 the smallest possible alignment---one bit for a bit-field and one byte
6428 otherwise, unless a larger value is specified with the @code{aligned}
6429 attribute.  The attribute does not apply to non-member objects.
6431 For example in the structure below, the member array @code{x} is packed
6432 so that it immediately follows @code{a} with no intervening padding:
6434 @smallexample
6435 struct foo
6437   char a;
6438   int x[2] __attribute__ ((packed));
6440 @end smallexample
6442 @emph{Note:} The 4.1, 4.2 and 4.3 series of GCC ignore the
6443 @code{packed} attribute on bit-fields of type @code{char}.  This has
6444 been fixed in GCC 4.4 but the change can lead to differences in the
6445 structure layout.  See the documentation of
6446 @option{-Wpacked-bitfield-compat} for more information.
6448 @item section ("@var{section-name}")
6449 @cindex @code{section} variable attribute
6450 Normally, the compiler places the objects it generates in sections like
6451 @code{data} and @code{bss}.  Sometimes, however, you need additional sections,
6452 or you need certain particular variables to appear in special sections,
6453 for example to map to special hardware.  The @code{section}
6454 attribute specifies that a variable (or function) lives in a particular
6455 section.  For example, this small program uses several specific section names:
6457 @smallexample
6458 struct duart a __attribute__ ((section ("DUART_A"))) = @{ 0 @};
6459 struct duart b __attribute__ ((section ("DUART_B"))) = @{ 0 @};
6460 char stack[10000] __attribute__ ((section ("STACK"))) = @{ 0 @};
6461 int init_data __attribute__ ((section ("INITDATA")));
6463 main()
6465   /* @r{Initialize stack pointer} */
6466   init_sp (stack + sizeof (stack));
6468   /* @r{Initialize initialized data} */
6469   memcpy (&init_data, &data, &edata - &data);
6471   /* @r{Turn on the serial ports} */
6472   init_duart (&a);
6473   init_duart (&b);
6475 @end smallexample
6477 @noindent
6478 Use the @code{section} attribute with
6479 @emph{global} variables and not @emph{local} variables,
6480 as shown in the example.
6482 You may use the @code{section} attribute with initialized or
6483 uninitialized global variables but the linker requires
6484 each object be defined once, with the exception that uninitialized
6485 variables tentatively go in the @code{common} (or @code{bss}) section
6486 and can be multiply ``defined''.  Using the @code{section} attribute
6487 changes what section the variable goes into and may cause the
6488 linker to issue an error if an uninitialized variable has multiple
6489 definitions.  You can force a variable to be initialized with the
6490 @option{-fno-common} flag or the @code{nocommon} attribute.
6492 Some file formats do not support arbitrary sections so the @code{section}
6493 attribute is not available on all platforms.
6494 If you need to map the entire contents of a module to a particular
6495 section, consider using the facilities of the linker instead.
6497 @item tls_model ("@var{tls_model}")
6498 @cindex @code{tls_model} variable attribute
6499 The @code{tls_model} attribute sets thread-local storage model
6500 (@pxref{Thread-Local}) of a particular @code{__thread} variable,
6501 overriding @option{-ftls-model=} command-line switch on a per-variable
6502 basis.
6503 The @var{tls_model} argument should be one of @code{global-dynamic},
6504 @code{local-dynamic}, @code{initial-exec} or @code{local-exec}.
6506 Not all targets support this attribute.
6508 @item unused
6509 @cindex @code{unused} variable attribute
6510 This attribute, attached to a variable, means that the variable is meant
6511 to be possibly unused.  GCC does not produce a warning for this
6512 variable.
6514 @item used
6515 @cindex @code{used} variable attribute
6516 This attribute, attached to a variable with static storage, means that
6517 the variable must be emitted even if it appears that the variable is not
6518 referenced.
6520 When applied to a static data member of a C++ class template, the
6521 attribute also means that the member is instantiated if the
6522 class itself is instantiated.
6524 @item vector_size (@var{bytes})
6525 @cindex @code{vector_size} variable attribute
6526 This attribute specifies the vector size for the variable, measured in
6527 bytes.  For example, the declaration:
6529 @smallexample
6530 int foo __attribute__ ((vector_size (16)));
6531 @end smallexample
6533 @noindent
6534 causes the compiler to set the mode for @code{foo}, to be 16 bytes,
6535 divided into @code{int} sized units.  Assuming a 32-bit int (a vector of
6536 4 units of 4 bytes), the corresponding mode of @code{foo} is V4SI@.
6538 This attribute is only applicable to integral and float scalars,
6539 although arrays, pointers, and function return values are allowed in
6540 conjunction with this construct.
6542 Aggregates with this attribute are invalid, even if they are of the same
6543 size as a corresponding scalar.  For example, the declaration:
6545 @smallexample
6546 struct S @{ int a; @};
6547 struct S  __attribute__ ((vector_size (16))) foo;
6548 @end smallexample
6550 @noindent
6551 is invalid even if the size of the structure is the same as the size of
6552 the @code{int}.
6554 @item visibility ("@var{visibility_type}")
6555 @cindex @code{visibility} variable attribute
6556 This attribute affects the linkage of the declaration to which it is attached.
6557 The @code{visibility} attribute is described in
6558 @ref{Common Function Attributes}.
6560 @item weak
6561 @cindex @code{weak} variable attribute
6562 The @code{weak} attribute is described in
6563 @ref{Common Function Attributes}.
6565 @end table
6567 @node ARC Variable Attributes
6568 @subsection ARC Variable Attributes
6570 @table @code
6571 @item aux
6572 @cindex @code{aux} variable attribute, ARC
6573 The @code{aux} attribute is used to directly access the ARC's
6574 auxiliary register space from C.  The auxilirary register number is
6575 given via attribute argument.
6577 @end table
6579 @node AVR Variable Attributes
6580 @subsection AVR Variable Attributes
6582 @table @code
6583 @item progmem
6584 @cindex @code{progmem} variable attribute, AVR
6585 The @code{progmem} attribute is used on the AVR to place read-only
6586 data in the non-volatile program memory (flash). The @code{progmem}
6587 attribute accomplishes this by putting respective variables into a
6588 section whose name starts with @code{.progmem}.
6590 This attribute works similar to the @code{section} attribute
6591 but adds additional checking.
6593 @table @asis
6594 @item @bullet{}@tie{} Ordinary AVR cores with 32 general purpose registers:
6595 @code{progmem} affects the location
6596 of the data but not how this data is accessed.
6597 In order to read data located with the @code{progmem} attribute
6598 (inline) assembler must be used.
6599 @smallexample
6600 /* Use custom macros from @w{@uref{http://nongnu.org/avr-libc/user-manual/,AVR-LibC}} */
6601 #include <avr/pgmspace.h> 
6603 /* Locate var in flash memory */
6604 const int var[2] PROGMEM = @{ 1, 2 @};
6606 int read_var (int i)
6608     /* Access var[] by accessor macro from avr/pgmspace.h */
6609     return (int) pgm_read_word (& var[i]);
6611 @end smallexample
6613 AVR is a Harvard architecture processor and data and read-only data
6614 normally resides in the data memory (RAM).
6616 See also the @ref{AVR Named Address Spaces} section for
6617 an alternate way to locate and access data in flash memory.
6619 @item @bullet{}@tie{} AVR cores with flash memory visible in the RAM address range:
6620 On such devices, there is no need for attribute @code{progmem} or
6621 @ref{AVR Named Address Spaces,,@code{__flash}} qualifier at all.
6622 Just use standard C / C++.  The compiler will generate @code{LD*}
6623 instructions.  As flash memory is visible in the RAM address range,
6624 and the default linker script does @emph{not} locate @code{.rodata} in
6625 RAM, no special features are needed in order not to waste RAM for
6626 read-only data or to read from flash.  You might even get slightly better
6627 performance by
6628 avoiding @code{progmem} and @code{__flash}.  This applies to devices from
6629 families @code{avrtiny} and @code{avrxmega3}, see @ref{AVR Options} for
6630 an overview.
6632 @item @bullet{}@tie{}Reduced AVR Tiny cores like ATtiny40:
6633 The compiler adds @code{0x4000}
6634 to the addresses of objects and declarations in @code{progmem} and locates
6635 the objects in flash memory, namely in section @code{.progmem.data}.
6636 The offset is needed because the flash memory is visible in the RAM
6637 address space starting at address @code{0x4000}.
6639 Data in @code{progmem} can be accessed by means of ordinary C@tie{}code,
6640 no special functions or macros are needed.
6642 @smallexample
6643 /* var is located in flash memory */
6644 extern const int var[2] __attribute__((progmem));
6646 int read_var (int i)
6648     return var[i];
6650 @end smallexample
6652 Please notice that on these devices, there is no need for @code{progmem}
6653 at all.
6655 @end table
6657 @item io
6658 @itemx io (@var{addr})
6659 @cindex @code{io} variable attribute, AVR
6660 Variables with the @code{io} attribute are used to address
6661 memory-mapped peripherals in the io address range.
6662 If an address is specified, the variable
6663 is assigned that address, and the value is interpreted as an
6664 address in the data address space.
6665 Example:
6667 @smallexample
6668 volatile int porta __attribute__((io (0x22)));
6669 @end smallexample
6671 The address specified in the address in the data address range.
6673 Otherwise, the variable it is not assigned an address, but the
6674 compiler will still use in/out instructions where applicable,
6675 assuming some other module assigns an address in the io address range.
6676 Example:
6678 @smallexample
6679 extern volatile int porta __attribute__((io));
6680 @end smallexample
6682 @item io_low
6683 @itemx io_low (@var{addr})
6684 @cindex @code{io_low} variable attribute, AVR
6685 This is like the @code{io} attribute, but additionally it informs the
6686 compiler that the object lies in the lower half of the I/O area,
6687 allowing the use of @code{cbi}, @code{sbi}, @code{sbic} and @code{sbis}
6688 instructions.
6690 @item address
6691 @itemx address (@var{addr})
6692 @cindex @code{address} variable attribute, AVR
6693 Variables with the @code{address} attribute are used to address
6694 memory-mapped peripherals that may lie outside the io address range.
6696 @smallexample
6697 volatile int porta __attribute__((address (0x600)));
6698 @end smallexample
6700 @item absdata
6701 @cindex @code{absdata} variable attribute, AVR
6702 Variables in static storage and with the @code{absdata} attribute can
6703 be accessed by the @code{LDS} and @code{STS} instructions which take
6704 absolute addresses.
6706 @itemize @bullet
6707 @item
6708 This attribute is only supported for the reduced AVR Tiny core
6709 like ATtiny40.
6711 @item
6712 You must make sure that respective data is located in the
6713 address range @code{0x40}@dots{}@code{0xbf} accessible by
6714 @code{LDS} and @code{STS}.  One way to achieve this as an
6715 appropriate linker description file.
6717 @item
6718 If the location does not fit the address range of @code{LDS}
6719 and @code{STS}, there is currently (Binutils 2.26) just an unspecific
6720 warning like
6721 @quotation
6722 @code{module.c:(.text+0x1c): warning: internal error: out of range error}
6723 @end quotation
6725 @end itemize
6727 See also the @option{-mabsdata} @ref{AVR Options,command-line option}.
6729 @end table
6731 @node Blackfin Variable Attributes
6732 @subsection Blackfin Variable Attributes
6734 Three attributes are currently defined for the Blackfin.
6736 @table @code
6737 @item l1_data
6738 @itemx l1_data_A
6739 @itemx l1_data_B
6740 @cindex @code{l1_data} variable attribute, Blackfin
6741 @cindex @code{l1_data_A} variable attribute, Blackfin
6742 @cindex @code{l1_data_B} variable attribute, Blackfin
6743 Use these attributes on the Blackfin to place the variable into L1 Data SRAM.
6744 Variables with @code{l1_data} attribute are put into the specific section
6745 named @code{.l1.data}. Those with @code{l1_data_A} attribute are put into
6746 the specific section named @code{.l1.data.A}. Those with @code{l1_data_B}
6747 attribute are put into the specific section named @code{.l1.data.B}.
6749 @item l2
6750 @cindex @code{l2} variable attribute, Blackfin
6751 Use this attribute on the Blackfin to place the variable into L2 SRAM.
6752 Variables with @code{l2} attribute are put into the specific section
6753 named @code{.l2.data}.
6754 @end table
6756 @node H8/300 Variable Attributes
6757 @subsection H8/300 Variable Attributes
6759 These variable attributes are available for H8/300 targets:
6761 @table @code
6762 @item eightbit_data
6763 @cindex @code{eightbit_data} variable attribute, H8/300
6764 @cindex eight-bit data on the H8/300, H8/300H, and H8S
6765 Use this attribute on the H8/300, H8/300H, and H8S to indicate that the specified
6766 variable should be placed into the eight-bit data section.
6767 The compiler generates more efficient code for certain operations
6768 on data in the eight-bit data area.  Note the eight-bit data area is limited to
6769 256 bytes of data.
6771 You must use GAS and GLD from GNU binutils version 2.7 or later for
6772 this attribute to work correctly.
6774 @item tiny_data
6775 @cindex @code{tiny_data} variable attribute, H8/300
6776 @cindex tiny data section on the H8/300H and H8S
6777 Use this attribute on the H8/300H and H8S to indicate that the specified
6778 variable should be placed into the tiny data section.
6779 The compiler generates more efficient code for loads and stores
6780 on data in the tiny data section.  Note the tiny data area is limited to
6781 slightly under 32KB of data.
6783 @end table
6785 @node IA-64 Variable Attributes
6786 @subsection IA-64 Variable Attributes
6788 The IA-64 back end supports the following variable attribute:
6790 @table @code
6791 @item model (@var{model-name})
6792 @cindex @code{model} variable attribute, IA-64
6794 On IA-64, use this attribute to set the addressability of an object.
6795 At present, the only supported identifier for @var{model-name} is
6796 @code{small}, indicating addressability via ``small'' (22-bit)
6797 addresses (so that their addresses can be loaded with the @code{addl}
6798 instruction).  Caveat: such addressing is by definition not position
6799 independent and hence this attribute must not be used for objects
6800 defined by shared libraries.
6802 @end table
6804 @node M32R/D Variable Attributes
6805 @subsection M32R/D Variable Attributes
6807 One attribute is currently defined for the M32R/D@.
6809 @table @code
6810 @item model (@var{model-name})
6811 @cindex @code{model-name} variable attribute, M32R/D
6812 @cindex variable addressability on the M32R/D
6813 Use this attribute on the M32R/D to set the addressability of an object.
6814 The identifier @var{model-name} is one of @code{small}, @code{medium},
6815 or @code{large}, representing each of the code models.
6817 Small model objects live in the lower 16MB of memory (so that their
6818 addresses can be loaded with the @code{ld24} instruction).
6820 Medium and large model objects may live anywhere in the 32-bit address space
6821 (the compiler generates @code{seth/add3} instructions to load their
6822 addresses).
6823 @end table
6825 @node MeP Variable Attributes
6826 @subsection MeP Variable Attributes
6828 The MeP target has a number of addressing modes and busses.  The
6829 @code{near} space spans the standard memory space's first 16 megabytes
6830 (24 bits).  The @code{far} space spans the entire 32-bit memory space.
6831 The @code{based} space is a 128-byte region in the memory space that
6832 is addressed relative to the @code{$tp} register.  The @code{tiny}
6833 space is a 65536-byte region relative to the @code{$gp} register.  In
6834 addition to these memory regions, the MeP target has a separate 16-bit
6835 control bus which is specified with @code{cb} attributes.
6837 @table @code
6839 @item based
6840 @cindex @code{based} variable attribute, MeP
6841 Any variable with the @code{based} attribute is assigned to the
6842 @code{.based} section, and is accessed with relative to the
6843 @code{$tp} register.
6845 @item tiny
6846 @cindex @code{tiny} variable attribute, MeP
6847 Likewise, the @code{tiny} attribute assigned variables to the
6848 @code{.tiny} section, relative to the @code{$gp} register.
6850 @item near
6851 @cindex @code{near} variable attribute, MeP
6852 Variables with the @code{near} attribute are assumed to have addresses
6853 that fit in a 24-bit addressing mode.  This is the default for large
6854 variables (@code{-mtiny=4} is the default) but this attribute can
6855 override @code{-mtiny=} for small variables, or override @code{-ml}.
6857 @item far
6858 @cindex @code{far} variable attribute, MeP
6859 Variables with the @code{far} attribute are addressed using a full
6860 32-bit address.  Since this covers the entire memory space, this
6861 allows modules to make no assumptions about where variables might be
6862 stored.
6864 @item io
6865 @cindex @code{io} variable attribute, MeP
6866 @itemx io (@var{addr})
6867 Variables with the @code{io} attribute are used to address
6868 memory-mapped peripherals.  If an address is specified, the variable
6869 is assigned that address, else it is not assigned an address (it is
6870 assumed some other module assigns an address).  Example:
6872 @smallexample
6873 int timer_count __attribute__((io(0x123)));
6874 @end smallexample
6876 @item cb
6877 @itemx cb (@var{addr})
6878 @cindex @code{cb} variable attribute, MeP
6879 Variables with the @code{cb} attribute are used to access the control
6880 bus, using special instructions.  @code{addr} indicates the control bus
6881 address.  Example:
6883 @smallexample
6884 int cpu_clock __attribute__((cb(0x123)));
6885 @end smallexample
6887 @end table
6889 @node Microsoft Windows Variable Attributes
6890 @subsection Microsoft Windows Variable Attributes
6892 You can use these attributes on Microsoft Windows targets.
6893 @ref{x86 Variable Attributes} for additional Windows compatibility
6894 attributes available on all x86 targets.
6896 @table @code
6897 @item dllimport
6898 @itemx dllexport
6899 @cindex @code{dllimport} variable attribute
6900 @cindex @code{dllexport} variable attribute
6901 The @code{dllimport} and @code{dllexport} attributes are described in
6902 @ref{Microsoft Windows Function Attributes}.
6904 @item selectany
6905 @cindex @code{selectany} variable attribute
6906 The @code{selectany} attribute causes an initialized global variable to
6907 have link-once semantics.  When multiple definitions of the variable are
6908 encountered by the linker, the first is selected and the remainder are
6909 discarded.  Following usage by the Microsoft compiler, the linker is told
6910 @emph{not} to warn about size or content differences of the multiple
6911 definitions.
6913 Although the primary usage of this attribute is for POD types, the
6914 attribute can also be applied to global C++ objects that are initialized
6915 by a constructor.  In this case, the static initialization and destruction
6916 code for the object is emitted in each translation defining the object,
6917 but the calls to the constructor and destructor are protected by a
6918 link-once guard variable.
6920 The @code{selectany} attribute is only available on Microsoft Windows
6921 targets.  You can use @code{__declspec (selectany)} as a synonym for
6922 @code{__attribute__ ((selectany))} for compatibility with other
6923 compilers.
6925 @item shared
6926 @cindex @code{shared} variable attribute
6927 On Microsoft Windows, in addition to putting variable definitions in a named
6928 section, the section can also be shared among all running copies of an
6929 executable or DLL@.  For example, this small program defines shared data
6930 by putting it in a named section @code{shared} and marking the section
6931 shareable:
6933 @smallexample
6934 int foo __attribute__((section ("shared"), shared)) = 0;
6937 main()
6939   /* @r{Read and write foo.  All running
6940      copies see the same value.}  */
6941   return 0;
6943 @end smallexample
6945 @noindent
6946 You may only use the @code{shared} attribute along with @code{section}
6947 attribute with a fully-initialized global definition because of the way
6948 linkers work.  See @code{section} attribute for more information.
6950 The @code{shared} attribute is only available on Microsoft Windows@.
6952 @end table
6954 @node MSP430 Variable Attributes
6955 @subsection MSP430 Variable Attributes
6957 @table @code
6958 @item noinit
6959 @cindex @code{noinit} variable attribute, MSP430 
6960 Any data with the @code{noinit} attribute will not be initialised by
6961 the C runtime startup code, or the program loader.  Not initialising
6962 data in this way can reduce program startup times.
6964 @item persistent
6965 @cindex @code{persistent} variable attribute, MSP430 
6966 Any variable with the @code{persistent} attribute will not be
6967 initialised by the C runtime startup code.  Instead its value will be
6968 set once, when the application is loaded, and then never initialised
6969 again, even if the processor is reset or the program restarts.
6970 Persistent data is intended to be placed into FLASH RAM, where its
6971 value will be retained across resets.  The linker script being used to
6972 create the application should ensure that persistent data is correctly
6973 placed.
6975 @item lower
6976 @itemx upper
6977 @itemx either
6978 @cindex @code{lower} variable attribute, MSP430 
6979 @cindex @code{upper} variable attribute, MSP430 
6980 @cindex @code{either} variable attribute, MSP430 
6981 These attributes are the same as the MSP430 function attributes of the
6982 same name (@pxref{MSP430 Function Attributes}).  
6983 These attributes can be applied to both functions and variables.
6984 @end table
6986 @node Nvidia PTX Variable Attributes
6987 @subsection Nvidia PTX Variable Attributes
6989 These variable attributes are supported by the Nvidia PTX back end:
6991 @table @code
6992 @item shared
6993 @cindex @code{shared} attribute, Nvidia PTX
6994 Use this attribute to place a variable in the @code{.shared} memory space.
6995 This memory space is private to each cooperative thread array; only threads
6996 within one thread block refer to the same instance of the variable.
6997 The runtime does not initialize variables in this memory space.
6998 @end table
7000 @node PowerPC Variable Attributes
7001 @subsection PowerPC Variable Attributes
7003 Three attributes currently are defined for PowerPC configurations:
7004 @code{altivec}, @code{ms_struct} and @code{gcc_struct}.
7006 @cindex @code{ms_struct} variable attribute, PowerPC
7007 @cindex @code{gcc_struct} variable attribute, PowerPC
7008 For full documentation of the struct attributes please see the
7009 documentation in @ref{x86 Variable Attributes}.
7011 @cindex @code{altivec} variable attribute, PowerPC
7012 For documentation of @code{altivec} attribute please see the
7013 documentation in @ref{PowerPC Type Attributes}.
7015 @node RL78 Variable Attributes
7016 @subsection RL78 Variable Attributes
7018 @cindex @code{saddr} variable attribute, RL78
7019 The RL78 back end supports the @code{saddr} variable attribute.  This
7020 specifies placement of the corresponding variable in the SADDR area,
7021 which can be accessed more efficiently than the default memory region.
7023 @node SPU Variable Attributes
7024 @subsection SPU Variable Attributes
7026 @cindex @code{spu_vector} variable attribute, SPU
7027 The SPU supports the @code{spu_vector} attribute for variables.  For
7028 documentation of this attribute please see the documentation in
7029 @ref{SPU Type Attributes}.
7031 @node V850 Variable Attributes
7032 @subsection V850 Variable Attributes
7034 These variable attributes are supported by the V850 back end:
7036 @table @code
7038 @item sda
7039 @cindex @code{sda} variable attribute, V850
7040 Use this attribute to explicitly place a variable in the small data area,
7041 which can hold up to 64 kilobytes.
7043 @item tda
7044 @cindex @code{tda} variable attribute, V850
7045 Use this attribute to explicitly place a variable in the tiny data area,
7046 which can hold up to 256 bytes in total.
7048 @item zda
7049 @cindex @code{zda} variable attribute, V850
7050 Use this attribute to explicitly place a variable in the first 32 kilobytes
7051 of memory.
7052 @end table
7054 @node x86 Variable Attributes
7055 @subsection x86 Variable Attributes
7057 Two attributes are currently defined for x86 configurations:
7058 @code{ms_struct} and @code{gcc_struct}.
7060 @table @code
7061 @item ms_struct
7062 @itemx gcc_struct
7063 @cindex @code{ms_struct} variable attribute, x86
7064 @cindex @code{gcc_struct} variable attribute, x86
7066 If @code{packed} is used on a structure, or if bit-fields are used,
7067 it may be that the Microsoft ABI lays out the structure differently
7068 than the way GCC normally does.  Particularly when moving packed
7069 data between functions compiled with GCC and the native Microsoft compiler
7070 (either via function call or as data in a file), it may be necessary to access
7071 either format.
7073 The @code{ms_struct} and @code{gcc_struct} attributes correspond
7074 to the @option{-mms-bitfields} and @option{-mno-ms-bitfields}
7075 command-line options, respectively;
7076 see @ref{x86 Options}, for details of how structure layout is affected.
7077 @xref{x86 Type Attributes}, for information about the corresponding
7078 attributes on types.
7080 @end table
7082 @node Xstormy16 Variable Attributes
7083 @subsection Xstormy16 Variable Attributes
7085 One attribute is currently defined for xstormy16 configurations:
7086 @code{below100}.
7088 @table @code
7089 @item below100
7090 @cindex @code{below100} variable attribute, Xstormy16
7092 If a variable has the @code{below100} attribute (@code{BELOW100} is
7093 allowed also), GCC places the variable in the first 0x100 bytes of
7094 memory and use special opcodes to access it.  Such variables are
7095 placed in either the @code{.bss_below100} section or the
7096 @code{.data_below100} section.
7098 @end table
7100 @node Type Attributes
7101 @section Specifying Attributes of Types
7102 @cindex attribute of types
7103 @cindex type attributes
7105 The keyword @code{__attribute__} allows you to specify various special
7106 properties of types.  Some type attributes apply only to structure and
7107 union types, and in C++, also class types, while others can apply to
7108 any type defined via a @code{typedef} declaration.  Unless otherwise
7109 specified, the same restrictions and effects apply to attributes regardless
7110 of whether a type is a trivial structure or a C++ class with user-defined
7111 constructors, destructors, or a copy assignment.
7113 Other attributes are defined for functions (@pxref{Function Attributes}),
7114 labels (@pxref{Label  Attributes}), enumerators (@pxref{Enumerator
7115 Attributes}), statements (@pxref{Statement Attributes}), and for variables
7116 (@pxref{Variable Attributes}).
7118 The @code{__attribute__} keyword is followed by an attribute specification
7119 enclosed in double parentheses.
7121 You may specify type attributes in an enum, struct or union type
7122 declaration or definition by placing them immediately after the
7123 @code{struct}, @code{union} or @code{enum} keyword.  You can also place
7124 them just past the closing curly brace of the definition, but this is less
7125 preferred because logically the type should be fully defined at 
7126 the closing brace.
7128 You can also include type attributes in a @code{typedef} declaration.
7129 @xref{Attribute Syntax}, for details of the exact syntax for using
7130 attributes.
7132 @menu
7133 * Common Type Attributes::
7134 * ARC Type Attributes::
7135 * ARM Type Attributes::
7136 * MeP Type Attributes::
7137 * PowerPC Type Attributes::
7138 * SPU Type Attributes::
7139 * x86 Type Attributes::
7140 @end menu
7142 @node Common Type Attributes
7143 @subsection Common Type Attributes
7145 The following type attributes are supported on most targets.
7147 @table @code
7148 @cindex @code{aligned} type attribute
7149 @item aligned
7150 @itemx aligned (@var{alignment})
7151 The @code{aligned} attribute specifies a minimum alignment (in bytes) for
7152 variables of the specified type.  When specified, @var{alignment} must be
7153 a power of 2.  Specifying no @var{alignment} argument implies the maximum
7154 alignment for the target, which is often, but by no means always, 8 or 16
7155 bytes.  For example, the declarations:
7157 @smallexample
7158 struct __attribute__ ((aligned (8))) S @{ short f[3]; @};
7159 typedef int more_aligned_int __attribute__ ((aligned (8)));
7160 @end smallexample
7162 @noindent
7163 force the compiler to ensure (as far as it can) that each variable whose
7164 type is @code{struct S} or @code{more_aligned_int} is allocated and
7165 aligned @emph{at least} on a 8-byte boundary.  On a SPARC, having all
7166 variables of type @code{struct S} aligned to 8-byte boundaries allows
7167 the compiler to use the @code{ldd} and @code{std} (doubleword load and
7168 store) instructions when copying one variable of type @code{struct S} to
7169 another, thus improving run-time efficiency.
7171 Note that the alignment of any given @code{struct} or @code{union} type
7172 is required by the ISO C standard to be at least a perfect multiple of
7173 the lowest common multiple of the alignments of all of the members of
7174 the @code{struct} or @code{union} in question.  This means that you @emph{can}
7175 effectively adjust the alignment of a @code{struct} or @code{union}
7176 type by attaching an @code{aligned} attribute to any one of the members
7177 of such a type, but the notation illustrated in the example above is a
7178 more obvious, intuitive, and readable way to request the compiler to
7179 adjust the alignment of an entire @code{struct} or @code{union} type.
7181 As in the preceding example, you can explicitly specify the alignment
7182 (in bytes) that you wish the compiler to use for a given @code{struct}
7183 or @code{union} type.  Alternatively, you can leave out the alignment factor
7184 and just ask the compiler to align a type to the maximum
7185 useful alignment for the target machine you are compiling for.  For
7186 example, you could write:
7188 @smallexample
7189 struct __attribute__ ((aligned)) S @{ short f[3]; @};
7190 @end smallexample
7192 Whenever you leave out the alignment factor in an @code{aligned}
7193 attribute specification, the compiler automatically sets the alignment
7194 for the type to the largest alignment that is ever used for any data
7195 type on the target machine you are compiling for.  Doing this can often
7196 make copy operations more efficient, because the compiler can use
7197 whatever instructions copy the biggest chunks of memory when performing
7198 copies to or from the variables that have types that you have aligned
7199 this way.
7201 In the example above, if the size of each @code{short} is 2 bytes, then
7202 the size of the entire @code{struct S} type is 6 bytes.  The smallest
7203 power of two that is greater than or equal to that is 8, so the
7204 compiler sets the alignment for the entire @code{struct S} type to 8
7205 bytes.
7207 Note that although you can ask the compiler to select a time-efficient
7208 alignment for a given type and then declare only individual stand-alone
7209 objects of that type, the compiler's ability to select a time-efficient
7210 alignment is primarily useful only when you plan to create arrays of
7211 variables having the relevant (efficiently aligned) type.  If you
7212 declare or use arrays of variables of an efficiently-aligned type, then
7213 it is likely that your program also does pointer arithmetic (or
7214 subscripting, which amounts to the same thing) on pointers to the
7215 relevant type, and the code that the compiler generates for these
7216 pointer arithmetic operations is often more efficient for
7217 efficiently-aligned types than for other types.
7219 Note that the effectiveness of @code{aligned} attributes may be limited
7220 by inherent limitations in your linker.  On many systems, the linker is
7221 only able to arrange for variables to be aligned up to a certain maximum
7222 alignment.  (For some linkers, the maximum supported alignment may
7223 be very very small.)  If your linker is only able to align variables
7224 up to a maximum of 8-byte alignment, then specifying @code{aligned (16)}
7225 in an @code{__attribute__} still only provides you with 8-byte
7226 alignment.  See your linker documentation for further information.
7228 When used on a struct, or struct member, the @code{aligned} attribute can
7229 only increase the alignment; in order to decrease it, the @code{packed}
7230 attribute must be specified as well.  When used as part of a typedef, the
7231 @code{aligned} attribute can both increase and decrease alignment, and
7232 specifying the @code{packed} attribute generates a warning.
7234 @cindex @code{warn_if_not_aligned} type attribute
7235 @item warn_if_not_aligned (@var{alignment})
7236 This attribute specifies a threshold for the structure field, measured
7237 in bytes.  If the structure field is aligned below the threshold, a
7238 warning will be issued.  For example, the declaration:
7240 @smallexample
7241 typedef unsigned long long __u64
7242    __attribute__((aligned (4), warn_if_not_aligned (8)));
7244 struct foo
7246   int i1;
7247   int i2;
7248   __u64 x;
7250 @end smallexample
7252 @noindent
7253 causes the compiler to issue an warning on @code{struct foo}, like
7254 @samp{warning: alignment 4 of 'struct foo' is less than 8}.
7255 It is used to define @code{struct foo} in such a way that
7256 @code{struct foo} has the same layout and the structure field @code{x}
7257 has the same alignment when @code{__u64} is aligned at either 4 or
7258 8 bytes.  Align @code{struct foo} to 8 bytes:
7260 @smallexample
7261 struct __attribute__ ((aligned (8))) foo
7263   int i1;
7264   int i2;
7265   __u64 x;
7267 @end smallexample
7269 @noindent
7270 silences the warning.  The compiler also issues a warning, like
7271 @samp{warning: 'x' offset 12 in 'struct foo' isn't aligned to 8},
7272 when the structure field has the misaligned offset:
7274 @smallexample
7275 struct __attribute__ ((aligned (8))) foo
7277   int i1;
7278   int i2;
7279   int i3;
7280   __u64 x;
7282 @end smallexample
7284 This warning can be disabled by @option{-Wno-if-not-aligned}.
7286 @item copy
7287 @itemx copy (@var{expression})
7288 @cindex @code{copy} type attribute
7289 The @code{copy} attribute applies the set of attributes with which
7290 the type of the @var{expression} has been declared to the declaration
7291 of the type to which the attribute is applied.  The attribute is
7292 designed for libraries that define aliases that are expected to
7293 specify the same set of attributes as the aliased symbols.
7294 The @code{copy} attribute can be used with types, variables, or
7295 functions.  However, the kind of symbol to which the attribute is
7296 applied (either varible or function) must match the kind of symbol
7297 to which the argument refers.
7298 The @code{copy} attribute copies only syntactic and semantic attributes
7299 but not attributes that affect a symbol's linkage or visibility such as
7300 @code{alias}, @code{visibility}, or @code{weak}.  The @code{deprecated}
7301 attribute is also not copied.  @xref{Common Function Attributes}.
7302 @xref{Common Variable Attributes}.
7304 For example, suppose @code{struct A} below is defined in some third
7305 party library header to have the alignment requirement @code{N} and
7306 to force a warning whenever a variable of the type is not so aligned
7307 due to attribute @code{packed}.  Specifying the @code{copy} attribute
7308 on the definition on the unrelated @code{struct B} has the effect of
7309 copying all relevant attributes from the type referenced by the pointer
7310 expression to @code{struct B}.
7312 @smallexample
7313 struct __attribute__ ((aligned (N), warn_if_not_aligned (N)))
7314 A @{ /* @r{@dots{}} */ @};
7315 struct __attribute__ ((copy ( (struct A *)0)) B @{ /* @r{@dots{}} */ @};
7316 @end smallexample
7318 @item deprecated
7319 @itemx deprecated (@var{msg})
7320 @cindex @code{deprecated} type attribute
7321 The @code{deprecated} attribute results in a warning if the type
7322 is used anywhere in the source file.  This is useful when identifying
7323 types that are expected to be removed in a future version of a program.
7324 If possible, the warning also includes the location of the declaration
7325 of the deprecated type, to enable users to easily find further
7326 information about why the type is deprecated, or what they should do
7327 instead.  Note that the warnings only occur for uses and then only
7328 if the type is being applied to an identifier that itself is not being
7329 declared as deprecated.
7331 @smallexample
7332 typedef int T1 __attribute__ ((deprecated));
7333 T1 x;
7334 typedef T1 T2;
7335 T2 y;
7336 typedef T1 T3 __attribute__ ((deprecated));
7337 T3 z __attribute__ ((deprecated));
7338 @end smallexample
7340 @noindent
7341 results in a warning on line 2 and 3 but not lines 4, 5, or 6.  No
7342 warning is issued for line 4 because T2 is not explicitly
7343 deprecated.  Line 5 has no warning because T3 is explicitly
7344 deprecated.  Similarly for line 6.  The optional @var{msg}
7345 argument, which must be a string, is printed in the warning if
7346 present.  Control characters in the string will be replaced with
7347 escape sequences, and if the @option{-fmessage-length} option is set
7348 to 0 (its default value) then any newline characters will be ignored.
7350 The @code{deprecated} attribute can also be used for functions and
7351 variables (@pxref{Function Attributes}, @pxref{Variable Attributes}.)
7353 The message attached to the attribute is affected by the setting of
7354 the @option{-fmessage-length} option.
7356 @item designated_init
7357 @cindex @code{designated_init} type attribute
7358 This attribute may only be applied to structure types.  It indicates
7359 that any initialization of an object of this type must use designated
7360 initializers rather than positional initializers.  The intent of this
7361 attribute is to allow the programmer to indicate that a structure's
7362 layout may change, and that therefore relying on positional
7363 initialization will result in future breakage.
7365 GCC emits warnings based on this attribute by default; use
7366 @option{-Wno-designated-init} to suppress them.
7368 @item may_alias
7369 @cindex @code{may_alias} type attribute
7370 Accesses through pointers to types with this attribute are not subject
7371 to type-based alias analysis, but are instead assumed to be able to alias
7372 any other type of objects.
7373 In the context of section 6.5 paragraph 7 of the C99 standard,
7374 an lvalue expression
7375 dereferencing such a pointer is treated like having a character type.
7376 See @option{-fstrict-aliasing} for more information on aliasing issues.
7377 This extension exists to support some vector APIs, in which pointers to
7378 one vector type are permitted to alias pointers to a different vector type.
7380 Note that an object of a type with this attribute does not have any
7381 special semantics.
7383 Example of use:
7385 @smallexample
7386 typedef short __attribute__ ((__may_alias__)) short_a;
7389 main (void)
7391   int a = 0x12345678;
7392   short_a *b = (short_a *) &a;
7394   b[1] = 0;
7396   if (a == 0x12345678)
7397     abort();
7399   exit(0);
7401 @end smallexample
7403 @noindent
7404 If you replaced @code{short_a} with @code{short} in the variable
7405 declaration, the above program would abort when compiled with
7406 @option{-fstrict-aliasing}, which is on by default at @option{-O2} or
7407 above.
7409 @item mode (@var{mode})
7410 @cindex @code{mode} type attribute
7411 This attribute specifies the data type for the declaration---whichever
7412 type corresponds to the mode @var{mode}.  This in effect lets you
7413 request an integer or floating-point type according to its width.
7415 @xref{Machine Modes,,, gccint, GNU Compiler Collection (GCC) Internals},
7416 for a list of the possible keywords for @var{mode}.
7417 You may also specify a mode of @code{byte} or @code{__byte__} to
7418 indicate the mode corresponding to a one-byte integer, @code{word} or
7419 @code{__word__} for the mode of a one-word integer, and @code{pointer}
7420 or @code{__pointer__} for the mode used to represent pointers.
7422 @item packed
7423 @cindex @code{packed} type attribute
7424 This attribute, attached to a @code{struct}, @code{union}, or C++ @code{class}
7425 type definition, specifies that each of its members (other than zero-width
7426 bit-fields) is placed to minimize the memory required.  This is equivalent
7427 to specifying the @code{packed} attribute on each of the members.
7429 @opindex fshort-enums
7430 When attached to an @code{enum} definition, the @code{packed} attribute
7431 indicates that the smallest integral type should be used.
7432 Specifying the @option{-fshort-enums} flag on the command line
7433 is equivalent to specifying the @code{packed}
7434 attribute on all @code{enum} definitions.
7436 In the following example @code{struct my_packed_struct}'s members are
7437 packed closely together, but the internal layout of its @code{s} member
7438 is not packed---to do that, @code{struct my_unpacked_struct} needs to
7439 be packed too.
7441 @smallexample
7442 struct my_unpacked_struct
7443  @{
7444     char c;
7445     int i;
7446  @};
7448 struct __attribute__ ((__packed__)) my_packed_struct
7449   @{
7450      char c;
7451      int  i;
7452      struct my_unpacked_struct s;
7453   @};
7454 @end smallexample
7456 You may only specify the @code{packed} attribute on the definition
7457 of an @code{enum}, @code{struct}, @code{union}, or @code{class}, 
7458 not on a @code{typedef} that does not also define the enumerated type,
7459 structure, union, or class.
7461 @item scalar_storage_order ("@var{endianness}")
7462 @cindex @code{scalar_storage_order} type attribute
7463 When attached to a @code{union} or a @code{struct}, this attribute sets
7464 the storage order, aka endianness, of the scalar fields of the type, as
7465 well as the array fields whose component is scalar.  The supported
7466 endiannesses are @code{big-endian} and @code{little-endian}.  The attribute
7467 has no effects on fields which are themselves a @code{union}, a @code{struct}
7468 or an array whose component is a @code{union} or a @code{struct}, and it is
7469 possible for these fields to have a different scalar storage order than the
7470 enclosing type.
7472 This attribute is supported only for targets that use a uniform default
7473 scalar storage order (fortunately, most of them), i.e.@: targets that store
7474 the scalars either all in big-endian or all in little-endian.
7476 Additional restrictions are enforced for types with the reverse scalar
7477 storage order with regard to the scalar storage order of the target:
7479 @itemize
7480 @item Taking the address of a scalar field of a @code{union} or a
7481 @code{struct} with reverse scalar storage order is not permitted and yields
7482 an error.
7483 @item Taking the address of an array field, whose component is scalar, of
7484 a @code{union} or a @code{struct} with reverse scalar storage order is
7485 permitted but yields a warning, unless @option{-Wno-scalar-storage-order}
7486 is specified.
7487 @item Taking the address of a @code{union} or a @code{struct} with reverse
7488 scalar storage order is permitted.
7489 @end itemize
7491 These restrictions exist because the storage order attribute is lost when
7492 the address of a scalar or the address of an array with scalar component is
7493 taken, so storing indirectly through this address generally does not work.
7494 The second case is nevertheless allowed to be able to perform a block copy
7495 from or to the array.
7497 Moreover, the use of type punning or aliasing to toggle the storage order
7498 is not supported; that is to say, a given scalar object cannot be accessed
7499 through distinct types that assign a different storage order to it.
7501 @item transparent_union
7502 @cindex @code{transparent_union} type attribute
7504 This attribute, attached to a @code{union} type definition, indicates
7505 that any function parameter having that union type causes calls to that
7506 function to be treated in a special way.
7508 First, the argument corresponding to a transparent union type can be of
7509 any type in the union; no cast is required.  Also, if the union contains
7510 a pointer type, the corresponding argument can be a null pointer
7511 constant or a void pointer expression; and if the union contains a void
7512 pointer type, the corresponding argument can be any pointer expression.
7513 If the union member type is a pointer, qualifiers like @code{const} on
7514 the referenced type must be respected, just as with normal pointer
7515 conversions.
7517 Second, the argument is passed to the function using the calling
7518 conventions of the first member of the transparent union, not the calling
7519 conventions of the union itself.  All members of the union must have the
7520 same machine representation; this is necessary for this argument passing
7521 to work properly.
7523 Transparent unions are designed for library functions that have multiple
7524 interfaces for compatibility reasons.  For example, suppose the
7525 @code{wait} function must accept either a value of type @code{int *} to
7526 comply with POSIX, or a value of type @code{union wait *} to comply with
7527 the 4.1BSD interface.  If @code{wait}'s parameter were @code{void *},
7528 @code{wait} would accept both kinds of arguments, but it would also
7529 accept any other pointer type and this would make argument type checking
7530 less useful.  Instead, @code{<sys/wait.h>} might define the interface
7531 as follows:
7533 @smallexample
7534 typedef union __attribute__ ((__transparent_union__))
7535   @{
7536     int *__ip;
7537     union wait *__up;
7538   @} wait_status_ptr_t;
7540 pid_t wait (wait_status_ptr_t);
7541 @end smallexample
7543 @noindent
7544 This interface allows either @code{int *} or @code{union wait *}
7545 arguments to be passed, using the @code{int *} calling convention.
7546 The program can call @code{wait} with arguments of either type:
7548 @smallexample
7549 int w1 () @{ int w; return wait (&w); @}
7550 int w2 () @{ union wait w; return wait (&w); @}
7551 @end smallexample
7553 @noindent
7554 With this interface, @code{wait}'s implementation might look like this:
7556 @smallexample
7557 pid_t wait (wait_status_ptr_t p)
7559   return waitpid (-1, p.__ip, 0);
7561 @end smallexample
7563 @item unused
7564 @cindex @code{unused} type attribute
7565 When attached to a type (including a @code{union} or a @code{struct}),
7566 this attribute means that variables of that type are meant to appear
7567 possibly unused.  GCC does not produce a warning for any variables of
7568 that type, even if the variable appears to do nothing.  This is often
7569 the case with lock or thread classes, which are usually defined and then
7570 not referenced, but contain constructors and destructors that have
7571 nontrivial bookkeeping functions.
7573 @item visibility
7574 @cindex @code{visibility} type attribute
7575 In C++, attribute visibility (@pxref{Function Attributes}) can also be
7576 applied to class, struct, union and enum types.  Unlike other type
7577 attributes, the attribute must appear between the initial keyword and
7578 the name of the type; it cannot appear after the body of the type.
7580 Note that the type visibility is applied to vague linkage entities
7581 associated with the class (vtable, typeinfo node, etc.).  In
7582 particular, if a class is thrown as an exception in one shared object
7583 and caught in another, the class must have default visibility.
7584 Otherwise the two shared objects are unable to use the same
7585 typeinfo node and exception handling will break.
7587 @end table
7589 To specify multiple attributes, separate them by commas within the
7590 double parentheses: for example, @samp{__attribute__ ((aligned (16),
7591 packed))}.
7593 @node ARC Type Attributes
7594 @subsection ARC Type Attributes
7596 @cindex @code{uncached} type attribute, ARC
7597 Declaring objects with @code{uncached} allows you to exclude
7598 data-cache participation in load and store operations on those objects
7599 without involving the additional semantic implications of
7600 @code{volatile}.  The @code{.di} instruction suffix is used for all
7601 loads and stores of data declared @code{uncached}.
7603 @node ARM Type Attributes
7604 @subsection ARM Type Attributes
7606 @cindex @code{notshared} type attribute, ARM
7607 On those ARM targets that support @code{dllimport} (such as Symbian
7608 OS), you can use the @code{notshared} attribute to indicate that the
7609 virtual table and other similar data for a class should not be
7610 exported from a DLL@.  For example:
7612 @smallexample
7613 class __declspec(notshared) C @{
7614 public:
7615   __declspec(dllimport) C();
7616   virtual void f();
7619 __declspec(dllexport)
7620 C::C() @{@}
7621 @end smallexample
7623 @noindent
7624 In this code, @code{C::C} is exported from the current DLL, but the
7625 virtual table for @code{C} is not exported.  (You can use
7626 @code{__attribute__} instead of @code{__declspec} if you prefer, but
7627 most Symbian OS code uses @code{__declspec}.)
7629 @node MeP Type Attributes
7630 @subsection MeP Type Attributes
7632 @cindex @code{based} type attribute, MeP
7633 @cindex @code{tiny} type attribute, MeP
7634 @cindex @code{near} type attribute, MeP
7635 @cindex @code{far} type attribute, MeP
7636 Many of the MeP variable attributes may be applied to types as well.
7637 Specifically, the @code{based}, @code{tiny}, @code{near}, and
7638 @code{far} attributes may be applied to either.  The @code{io} and
7639 @code{cb} attributes may not be applied to types.
7641 @node PowerPC Type Attributes
7642 @subsection PowerPC Type Attributes
7644 Three attributes currently are defined for PowerPC configurations:
7645 @code{altivec}, @code{ms_struct} and @code{gcc_struct}.
7647 @cindex @code{ms_struct} type attribute, PowerPC
7648 @cindex @code{gcc_struct} type attribute, PowerPC
7649 For full documentation of the @code{ms_struct} and @code{gcc_struct}
7650 attributes please see the documentation in @ref{x86 Type Attributes}.
7652 @cindex @code{altivec} type attribute, PowerPC
7653 The @code{altivec} attribute allows one to declare AltiVec vector data
7654 types supported by the AltiVec Programming Interface Manual.  The
7655 attribute requires an argument to specify one of three vector types:
7656 @code{vector__}, @code{pixel__} (always followed by unsigned short),
7657 and @code{bool__} (always followed by unsigned).
7659 @smallexample
7660 __attribute__((altivec(vector__)))
7661 __attribute__((altivec(pixel__))) unsigned short
7662 __attribute__((altivec(bool__))) unsigned
7663 @end smallexample
7665 These attributes mainly are intended to support the @code{__vector},
7666 @code{__pixel}, and @code{__bool} AltiVec keywords.
7668 @node SPU Type Attributes
7669 @subsection SPU Type Attributes
7671 @cindex @code{spu_vector} type attribute, SPU
7672 The SPU supports the @code{spu_vector} attribute for types.  This attribute
7673 allows one to declare vector data types supported by the Sony/Toshiba/IBM SPU
7674 Language Extensions Specification.  It is intended to support the
7675 @code{__vector} keyword.
7677 @node x86 Type Attributes
7678 @subsection x86 Type Attributes
7680 Two attributes are currently defined for x86 configurations:
7681 @code{ms_struct} and @code{gcc_struct}.
7683 @table @code
7685 @item ms_struct
7686 @itemx gcc_struct
7687 @cindex @code{ms_struct} type attribute, x86
7688 @cindex @code{gcc_struct} type attribute, x86
7690 If @code{packed} is used on a structure, or if bit-fields are used
7691 it may be that the Microsoft ABI packs them differently
7692 than GCC normally packs them.  Particularly when moving packed
7693 data between functions compiled with GCC and the native Microsoft compiler
7694 (either via function call or as data in a file), it may be necessary to access
7695 either format.
7697 The @code{ms_struct} and @code{gcc_struct} attributes correspond
7698 to the @option{-mms-bitfields} and @option{-mno-ms-bitfields}
7699 command-line options, respectively;
7700 see @ref{x86 Options}, for details of how structure layout is affected.
7701 @xref{x86 Variable Attributes}, for information about the corresponding
7702 attributes on variables.
7704 @end table
7706 @node Label Attributes
7707 @section Label Attributes
7708 @cindex Label Attributes
7710 GCC allows attributes to be set on C labels.  @xref{Attribute Syntax}, for 
7711 details of the exact syntax for using attributes.  Other attributes are 
7712 available for functions (@pxref{Function Attributes}), variables 
7713 (@pxref{Variable Attributes}), enumerators (@pxref{Enumerator Attributes}),
7714 statements (@pxref{Statement Attributes}), and for types
7715 (@pxref{Type Attributes}).
7717 This example uses the @code{cold} label attribute to indicate the 
7718 @code{ErrorHandling} branch is unlikely to be taken and that the
7719 @code{ErrorHandling} label is unused:
7721 @smallexample
7723    asm goto ("some asm" : : : : NoError);
7725 /* This branch (the fall-through from the asm) is less commonly used */
7726 ErrorHandling: 
7727    __attribute__((cold, unused)); /* Semi-colon is required here */
7728    printf("error\n");
7729    return 0;
7731 NoError:
7732    printf("no error\n");
7733    return 1;
7734 @end smallexample
7736 @table @code
7737 @item unused
7738 @cindex @code{unused} label attribute
7739 This feature is intended for program-generated code that may contain 
7740 unused labels, but which is compiled with @option{-Wall}.  It is
7741 not normally appropriate to use in it human-written code, though it
7742 could be useful in cases where the code that jumps to the label is
7743 contained within an @code{#ifdef} conditional.
7745 @item hot
7746 @cindex @code{hot} label attribute
7747 The @code{hot} attribute on a label is used to inform the compiler that
7748 the path following the label is more likely than paths that are not so
7749 annotated.  This attribute is used in cases where @code{__builtin_expect}
7750 cannot be used, for instance with computed goto or @code{asm goto}.
7752 @item cold
7753 @cindex @code{cold} label attribute
7754 The @code{cold} attribute on labels is used to inform the compiler that
7755 the path following the label is unlikely to be executed.  This attribute
7756 is used in cases where @code{__builtin_expect} cannot be used, for instance
7757 with computed goto or @code{asm goto}.
7759 @end table
7761 @node Enumerator Attributes
7762 @section Enumerator Attributes
7763 @cindex Enumerator Attributes
7765 GCC allows attributes to be set on enumerators.  @xref{Attribute Syntax}, for
7766 details of the exact syntax for using attributes.  Other attributes are
7767 available for functions (@pxref{Function Attributes}), variables
7768 (@pxref{Variable Attributes}), labels (@pxref{Label Attributes}), statements
7769 (@pxref{Statement Attributes}), and for types (@pxref{Type Attributes}).
7771 This example uses the @code{deprecated} enumerator attribute to indicate the
7772 @code{oldval} enumerator is deprecated:
7774 @smallexample
7775 enum E @{
7776   oldval __attribute__((deprecated)),
7777   newval
7781 fn (void)
7783   return oldval;
7785 @end smallexample
7787 @table @code
7788 @item deprecated
7789 @cindex @code{deprecated} enumerator attribute
7790 The @code{deprecated} attribute results in a warning if the enumerator
7791 is used anywhere in the source file.  This is useful when identifying
7792 enumerators that are expected to be removed in a future version of a
7793 program.  The warning also includes the location of the declaration
7794 of the deprecated enumerator, to enable users to easily find further
7795 information about why the enumerator is deprecated, or what they should
7796 do instead.  Note that the warnings only occurs for uses.
7798 @end table
7800 @node Statement Attributes
7801 @section Statement Attributes
7802 @cindex Statement Attributes
7804 GCC allows attributes to be set on null statements.  @xref{Attribute Syntax},
7805 for details of the exact syntax for using attributes.  Other attributes are
7806 available for functions (@pxref{Function Attributes}), variables
7807 (@pxref{Variable Attributes}), labels (@pxref{Label Attributes}), enumerators
7808 (@pxref{Enumerator Attributes}), and for types (@pxref{Type Attributes}).
7810 This example uses the @code{fallthrough} statement attribute to indicate that
7811 the @option{-Wimplicit-fallthrough} warning should not be emitted:
7813 @smallexample
7814 switch (cond)
7815   @{
7816   case 1:
7817     bar (1);
7818     __attribute__((fallthrough));
7819   case 2:
7820     @dots{}
7821   @}
7822 @end smallexample
7824 @table @code
7825 @item fallthrough
7826 @cindex @code{fallthrough} statement attribute
7827 The @code{fallthrough} attribute with a null statement serves as a
7828 fallthrough statement.  It hints to the compiler that a statement
7829 that falls through to another case label, or user-defined label
7830 in a switch statement is intentional and thus the
7831 @option{-Wimplicit-fallthrough} warning must not trigger.  The
7832 fallthrough attribute may appear at most once in each attribute
7833 list, and may not be mixed with other attributes.  It can only
7834 be used in a switch statement (the compiler will issue an error
7835 otherwise), after a preceding statement and before a logically
7836 succeeding case label, or user-defined label.
7838 @end table
7840 @node Attribute Syntax
7841 @section Attribute Syntax
7842 @cindex attribute syntax
7844 This section describes the syntax with which @code{__attribute__} may be
7845 used, and the constructs to which attribute specifiers bind, for the C
7846 language.  Some details may vary for C++ and Objective-C@.  Because of
7847 infelicities in the grammar for attributes, some forms described here
7848 may not be successfully parsed in all cases.
7850 There are some problems with the semantics of attributes in C++.  For
7851 example, there are no manglings for attributes, although they may affect
7852 code generation, so problems may arise when attributed types are used in
7853 conjunction with templates or overloading.  Similarly, @code{typeid}
7854 does not distinguish between types with different attributes.  Support
7855 for attributes in C++ may be restricted in future to attributes on
7856 declarations only, but not on nested declarators.
7858 @xref{Function Attributes}, for details of the semantics of attributes
7859 applying to functions.  @xref{Variable Attributes}, for details of the
7860 semantics of attributes applying to variables.  @xref{Type Attributes},
7861 for details of the semantics of attributes applying to structure, union
7862 and enumerated types.
7863 @xref{Label Attributes}, for details of the semantics of attributes 
7864 applying to labels.
7865 @xref{Enumerator Attributes}, for details of the semantics of attributes
7866 applying to enumerators.
7867 @xref{Statement Attributes}, for details of the semantics of attributes
7868 applying to statements.
7870 An @dfn{attribute specifier} is of the form
7871 @code{__attribute__ ((@var{attribute-list}))}.  An @dfn{attribute list}
7872 is a possibly empty comma-separated sequence of @dfn{attributes}, where
7873 each attribute is one of the following:
7875 @itemize @bullet
7876 @item
7877 Empty.  Empty attributes are ignored.
7879 @item
7880 An attribute name
7881 (which may be an identifier such as @code{unused}, or a reserved
7882 word such as @code{const}).
7884 @item
7885 An attribute name followed by a parenthesized list of
7886 parameters for the attribute.
7887 These parameters take one of the following forms:
7889 @itemize @bullet
7890 @item
7891 An identifier.  For example, @code{mode} attributes use this form.
7893 @item
7894 An identifier followed by a comma and a non-empty comma-separated list
7895 of expressions.  For example, @code{format} attributes use this form.
7897 @item
7898 A possibly empty comma-separated list of expressions.  For example,
7899 @code{format_arg} attributes use this form with the list being a single
7900 integer constant expression, and @code{alias} attributes use this form
7901 with the list being a single string constant.
7902 @end itemize
7903 @end itemize
7905 An @dfn{attribute specifier list} is a sequence of one or more attribute
7906 specifiers, not separated by any other tokens.
7908 You may optionally specify attribute names with @samp{__}
7909 preceding and following the name.
7910 This allows you to use them in header files without
7911 being concerned about a possible macro of the same name.  For example,
7912 you may use the attribute name @code{__noreturn__} instead of @code{noreturn}.
7915 @subsubheading Label Attributes
7917 In GNU C, an attribute specifier list may appear after the colon following a
7918 label, other than a @code{case} or @code{default} label.  GNU C++ only permits
7919 attributes on labels if the attribute specifier is immediately
7920 followed by a semicolon (i.e., the label applies to an empty
7921 statement).  If the semicolon is missing, C++ label attributes are
7922 ambiguous, as it is permissible for a declaration, which could begin
7923 with an attribute list, to be labelled in C++.  Declarations cannot be
7924 labelled in C90 or C99, so the ambiguity does not arise there.
7926 @subsubheading Enumerator Attributes
7928 In GNU C, an attribute specifier list may appear as part of an enumerator.
7929 The attribute goes after the enumeration constant, before @code{=}, if
7930 present.  The optional attribute in the enumerator appertains to the
7931 enumeration constant.  It is not possible to place the attribute after
7932 the constant expression, if present.
7934 @subsubheading Statement Attributes
7935 In GNU C, an attribute specifier list may appear as part of a null
7936 statement.  The attribute goes before the semicolon.
7938 @subsubheading Type Attributes
7940 An attribute specifier list may appear as part of a @code{struct},
7941 @code{union} or @code{enum} specifier.  It may go either immediately
7942 after the @code{struct}, @code{union} or @code{enum} keyword, or after
7943 the closing brace.  The former syntax is preferred.
7944 Where attribute specifiers follow the closing brace, they are considered
7945 to relate to the structure, union or enumerated type defined, not to any
7946 enclosing declaration the type specifier appears in, and the type
7947 defined is not complete until after the attribute specifiers.
7948 @c Otherwise, there would be the following problems: a shift/reduce
7949 @c conflict between attributes binding the struct/union/enum and
7950 @c binding to the list of specifiers/qualifiers; and "aligned"
7951 @c attributes could use sizeof for the structure, but the size could be
7952 @c changed later by "packed" attributes.
7955 @subsubheading All other attributes
7957 Otherwise, an attribute specifier appears as part of a declaration,
7958 counting declarations of unnamed parameters and type names, and relates
7959 to that declaration (which may be nested in another declaration, for
7960 example in the case of a parameter declaration), or to a particular declarator
7961 within a declaration.  Where an
7962 attribute specifier is applied to a parameter declared as a function or
7963 an array, it should apply to the function or array rather than the
7964 pointer to which the parameter is implicitly converted, but this is not
7965 yet correctly implemented.
7967 Any list of specifiers and qualifiers at the start of a declaration may
7968 contain attribute specifiers, whether or not such a list may in that
7969 context contain storage class specifiers.  (Some attributes, however,
7970 are essentially in the nature of storage class specifiers, and only make
7971 sense where storage class specifiers may be used; for example,
7972 @code{section}.)  There is one necessary limitation to this syntax: the
7973 first old-style parameter declaration in a function definition cannot
7974 begin with an attribute specifier, because such an attribute applies to
7975 the function instead by syntax described below (which, however, is not
7976 yet implemented in this case).  In some other cases, attribute
7977 specifiers are permitted by this grammar but not yet supported by the
7978 compiler.  All attribute specifiers in this place relate to the
7979 declaration as a whole.  In the obsolescent usage where a type of
7980 @code{int} is implied by the absence of type specifiers, such a list of
7981 specifiers and qualifiers may be an attribute specifier list with no
7982 other specifiers or qualifiers.
7984 At present, the first parameter in a function prototype must have some
7985 type specifier that is not an attribute specifier; this resolves an
7986 ambiguity in the interpretation of @code{void f(int
7987 (__attribute__((foo)) x))}, but is subject to change.  At present, if
7988 the parentheses of a function declarator contain only attributes then
7989 those attributes are ignored, rather than yielding an error or warning
7990 or implying a single parameter of type int, but this is subject to
7991 change.
7993 An attribute specifier list may appear immediately before a declarator
7994 (other than the first) in a comma-separated list of declarators in a
7995 declaration of more than one identifier using a single list of
7996 specifiers and qualifiers.  Such attribute specifiers apply
7997 only to the identifier before whose declarator they appear.  For
7998 example, in
8000 @smallexample
8001 __attribute__((noreturn)) void d0 (void),
8002     __attribute__((format(printf, 1, 2))) d1 (const char *, ...),
8003      d2 (void);
8004 @end smallexample
8006 @noindent
8007 the @code{noreturn} attribute applies to all the functions
8008 declared; the @code{format} attribute only applies to @code{d1}.
8010 An attribute specifier list may appear immediately before the comma,
8011 @code{=} or semicolon terminating the declaration of an identifier other
8012 than a function definition.  Such attribute specifiers apply
8013 to the declared object or function.  Where an
8014 assembler name for an object or function is specified (@pxref{Asm
8015 Labels}), the attribute must follow the @code{asm}
8016 specification.
8018 An attribute specifier list may, in future, be permitted to appear after
8019 the declarator in a function definition (before any old-style parameter
8020 declarations or the function body).
8022 Attribute specifiers may be mixed with type qualifiers appearing inside
8023 the @code{[]} of a parameter array declarator, in the C99 construct by
8024 which such qualifiers are applied to the pointer to which the array is
8025 implicitly converted.  Such attribute specifiers apply to the pointer,
8026 not to the array, but at present this is not implemented and they are
8027 ignored.
8029 An attribute specifier list may appear at the start of a nested
8030 declarator.  At present, there are some limitations in this usage: the
8031 attributes correctly apply to the declarator, but for most individual
8032 attributes the semantics this implies are not implemented.
8033 When attribute specifiers follow the @code{*} of a pointer
8034 declarator, they may be mixed with any type qualifiers present.
8035 The following describes the formal semantics of this syntax.  It makes the
8036 most sense if you are familiar with the formal specification of
8037 declarators in the ISO C standard.
8039 Consider (as in C99 subclause 6.7.5 paragraph 4) a declaration @code{T
8040 D1}, where @code{T} contains declaration specifiers that specify a type
8041 @var{Type} (such as @code{int}) and @code{D1} is a declarator that
8042 contains an identifier @var{ident}.  The type specified for @var{ident}
8043 for derived declarators whose type does not include an attribute
8044 specifier is as in the ISO C standard.
8046 If @code{D1} has the form @code{( @var{attribute-specifier-list} D )},
8047 and the declaration @code{T D} specifies the type
8048 ``@var{derived-declarator-type-list} @var{Type}'' for @var{ident}, then
8049 @code{T D1} specifies the type ``@var{derived-declarator-type-list}
8050 @var{attribute-specifier-list} @var{Type}'' for @var{ident}.
8052 If @code{D1} has the form @code{*
8053 @var{type-qualifier-and-attribute-specifier-list} D}, and the
8054 declaration @code{T D} specifies the type
8055 ``@var{derived-declarator-type-list} @var{Type}'' for @var{ident}, then
8056 @code{T D1} specifies the type ``@var{derived-declarator-type-list}
8057 @var{type-qualifier-and-attribute-specifier-list} pointer to @var{Type}'' for
8058 @var{ident}.
8060 For example,
8062 @smallexample
8063 void (__attribute__((noreturn)) ****f) (void);
8064 @end smallexample
8066 @noindent
8067 specifies the type ``pointer to pointer to pointer to pointer to
8068 non-returning function returning @code{void}''.  As another example,
8070 @smallexample
8071 char *__attribute__((aligned(8))) *f;
8072 @end smallexample
8074 @noindent
8075 specifies the type ``pointer to 8-byte-aligned pointer to @code{char}''.
8076 Note again that this does not work with most attributes; for example,
8077 the usage of @samp{aligned} and @samp{noreturn} attributes given above
8078 is not yet supported.
8080 For compatibility with existing code written for compiler versions that
8081 did not implement attributes on nested declarators, some laxity is
8082 allowed in the placing of attributes.  If an attribute that only applies
8083 to types is applied to a declaration, it is treated as applying to
8084 the type of that declaration.  If an attribute that only applies to
8085 declarations is applied to the type of a declaration, it is treated
8086 as applying to that declaration; and, for compatibility with code
8087 placing the attributes immediately before the identifier declared, such
8088 an attribute applied to a function return type is treated as
8089 applying to the function type, and such an attribute applied to an array
8090 element type is treated as applying to the array type.  If an
8091 attribute that only applies to function types is applied to a
8092 pointer-to-function type, it is treated as applying to the pointer
8093 target type; if such an attribute is applied to a function return type
8094 that is not a pointer-to-function type, it is treated as applying
8095 to the function type.
8097 @node Function Prototypes
8098 @section Prototypes and Old-Style Function Definitions
8099 @cindex function prototype declarations
8100 @cindex old-style function definitions
8101 @cindex promotion of formal parameters
8103 GNU C extends ISO C to allow a function prototype to override a later
8104 old-style non-prototype definition.  Consider the following example:
8106 @smallexample
8107 /* @r{Use prototypes unless the compiler is old-fashioned.}  */
8108 #ifdef __STDC__
8109 #define P(x) x
8110 #else
8111 #define P(x) ()
8112 #endif
8114 /* @r{Prototype function declaration.}  */
8115 int isroot P((uid_t));
8117 /* @r{Old-style function definition.}  */
8119 isroot (x)   /* @r{??? lossage here ???} */
8120      uid_t x;
8122   return x == 0;
8124 @end smallexample
8126 Suppose the type @code{uid_t} happens to be @code{short}.  ISO C does
8127 not allow this example, because subword arguments in old-style
8128 non-prototype definitions are promoted.  Therefore in this example the
8129 function definition's argument is really an @code{int}, which does not
8130 match the prototype argument type of @code{short}.
8132 This restriction of ISO C makes it hard to write code that is portable
8133 to traditional C compilers, because the programmer does not know
8134 whether the @code{uid_t} type is @code{short}, @code{int}, or
8135 @code{long}.  Therefore, in cases like these GNU C allows a prototype
8136 to override a later old-style definition.  More precisely, in GNU C, a
8137 function prototype argument type overrides the argument type specified
8138 by a later old-style definition if the former type is the same as the
8139 latter type before promotion.  Thus in GNU C the above example is
8140 equivalent to the following:
8142 @smallexample
8143 int isroot (uid_t);
8146 isroot (uid_t x)
8148   return x == 0;
8150 @end smallexample
8152 @noindent
8153 GNU C++ does not support old-style function definitions, so this
8154 extension is irrelevant.
8156 @node C++ Comments
8157 @section C++ Style Comments
8158 @cindex @code{//}
8159 @cindex C++ comments
8160 @cindex comments, C++ style
8162 In GNU C, you may use C++ style comments, which start with @samp{//} and
8163 continue until the end of the line.  Many other C implementations allow
8164 such comments, and they are included in the 1999 C standard.  However,
8165 C++ style comments are not recognized if you specify an @option{-std}
8166 option specifying a version of ISO C before C99, or @option{-ansi}
8167 (equivalent to @option{-std=c90}).
8169 @node Dollar Signs
8170 @section Dollar Signs in Identifier Names
8171 @cindex $
8172 @cindex dollar signs in identifier names
8173 @cindex identifier names, dollar signs in
8175 In GNU C, you may normally use dollar signs in identifier names.
8176 This is because many traditional C implementations allow such identifiers.
8177 However, dollar signs in identifiers are not supported on a few target
8178 machines, typically because the target assembler does not allow them.
8180 @node Character Escapes
8181 @section The Character @key{ESC} in Constants
8183 You can use the sequence @samp{\e} in a string or character constant to
8184 stand for the ASCII character @key{ESC}.
8186 @node Alignment
8187 @section Determining the Alignment of Functions, Types or Variables
8188 @cindex alignment
8189 @cindex type alignment
8190 @cindex variable alignment
8192 The keyword @code{__alignof__} determines the alignment requirement of
8193 a function, object, or a type, or the minimum alignment usually required
8194 by a type.  Its syntax is just like @code{sizeof} and C11 @code{_Alignof}.
8196 For example, if the target machine requires a @code{double} value to be
8197 aligned on an 8-byte boundary, then @code{__alignof__ (double)} is 8.
8198 This is true on many RISC machines.  On more traditional machine
8199 designs, @code{__alignof__ (double)} is 4 or even 2.
8201 Some machines never actually require alignment; they allow references to any
8202 data type even at an odd address.  For these machines, @code{__alignof__}
8203 reports the smallest alignment that GCC gives the data type, usually as
8204 mandated by the target ABI.
8206 If the operand of @code{__alignof__} is an lvalue rather than a type,
8207 its value is the required alignment for its type, taking into account
8208 any minimum alignment specified by attribute @code{aligned}
8209 (@pxref{Common Variable Attributes}).  For example, after this
8210 declaration:
8212 @smallexample
8213 struct foo @{ int x; char y; @} foo1;
8214 @end smallexample
8216 @noindent
8217 the value of @code{__alignof__ (foo1.y)} is 1, even though its actual
8218 alignment is probably 2 or 4, the same as @code{__alignof__ (int)}.
8219 It is an error to ask for the alignment of an incomplete type other
8220 than @code{void}.
8222 If the operand of the @code{__alignof__} expression is a function,
8223 the expression evaluates to the alignment of the function which may
8224 be specified by attribute @code{aligned} (@pxref{Common Function Attributes}).
8226 @node Inline
8227 @section An Inline Function is As Fast As a Macro
8228 @cindex inline functions
8229 @cindex integrating function code
8230 @cindex open coding
8231 @cindex macros, inline alternative
8233 By declaring a function inline, you can direct GCC to make
8234 calls to that function faster.  One way GCC can achieve this is to
8235 integrate that function's code into the code for its callers.  This
8236 makes execution faster by eliminating the function-call overhead; in
8237 addition, if any of the actual argument values are constant, their
8238 known values may permit simplifications at compile time so that not
8239 all of the inline function's code needs to be included.  The effect on
8240 code size is less predictable; object code may be larger or smaller
8241 with function inlining, depending on the particular case.  You can
8242 also direct GCC to try to integrate all ``simple enough'' functions
8243 into their callers with the option @option{-finline-functions}.
8245 GCC implements three different semantics of declaring a function
8246 inline.  One is available with @option{-std=gnu89} or
8247 @option{-fgnu89-inline} or when @code{gnu_inline} attribute is present
8248 on all inline declarations, another when
8249 @option{-std=c99},
8250 @option{-std=gnu99} or an option for a later C version is used
8251 (without @option{-fgnu89-inline}), and the third
8252 is used when compiling C++.
8254 To declare a function inline, use the @code{inline} keyword in its
8255 declaration, like this:
8257 @smallexample
8258 static inline int
8259 inc (int *a)
8261   return (*a)++;
8263 @end smallexample
8265 If you are writing a header file to be included in ISO C90 programs, write
8266 @code{__inline__} instead of @code{inline}.  @xref{Alternate Keywords}.
8268 The three types of inlining behave similarly in two important cases:
8269 when the @code{inline} keyword is used on a @code{static} function,
8270 like the example above, and when a function is first declared without
8271 using the @code{inline} keyword and then is defined with
8272 @code{inline}, like this:
8274 @smallexample
8275 extern int inc (int *a);
8276 inline int
8277 inc (int *a)
8279   return (*a)++;
8281 @end smallexample
8283 In both of these common cases, the program behaves the same as if you
8284 had not used the @code{inline} keyword, except for its speed.
8286 @cindex inline functions, omission of
8287 @opindex fkeep-inline-functions
8288 When a function is both inline and @code{static}, if all calls to the
8289 function are integrated into the caller, and the function's address is
8290 never used, then the function's own assembler code is never referenced.
8291 In this case, GCC does not actually output assembler code for the
8292 function, unless you specify the option @option{-fkeep-inline-functions}.
8293 If there is a nonintegrated call, then the function is compiled to
8294 assembler code as usual.  The function must also be compiled as usual if
8295 the program refers to its address, because that cannot be inlined.
8297 @opindex Winline
8298 Note that certain usages in a function definition can make it unsuitable
8299 for inline substitution.  Among these usages are: variadic functions,
8300 use of @code{alloca}, use of computed goto (@pxref{Labels as Values}),
8301 use of nonlocal goto, use of nested functions, use of @code{setjmp}, use
8302 of @code{__builtin_longjmp} and use of @code{__builtin_return} or
8303 @code{__builtin_apply_args}.  Using @option{-Winline} warns when a
8304 function marked @code{inline} could not be substituted, and gives the
8305 reason for the failure.
8307 @cindex automatic @code{inline} for C++ member fns
8308 @cindex @code{inline} automatic for C++ member fns
8309 @cindex member fns, automatically @code{inline}
8310 @cindex C++ member fns, automatically @code{inline}
8311 @opindex fno-default-inline
8312 As required by ISO C++, GCC considers member functions defined within
8313 the body of a class to be marked inline even if they are
8314 not explicitly declared with the @code{inline} keyword.  You can
8315 override this with @option{-fno-default-inline}; @pxref{C++ Dialect
8316 Options,,Options Controlling C++ Dialect}.
8318 GCC does not inline any functions when not optimizing unless you specify
8319 the @samp{always_inline} attribute for the function, like this:
8321 @smallexample
8322 /* @r{Prototype.}  */
8323 inline void foo (const char) __attribute__((always_inline));
8324 @end smallexample
8326 The remainder of this section is specific to GNU C90 inlining.
8328 @cindex non-static inline function
8329 When an inline function is not @code{static}, then the compiler must assume
8330 that there may be calls from other source files; since a global symbol can
8331 be defined only once in any program, the function must not be defined in
8332 the other source files, so the calls therein cannot be integrated.
8333 Therefore, a non-@code{static} inline function is always compiled on its
8334 own in the usual fashion.
8336 If you specify both @code{inline} and @code{extern} in the function
8337 definition, then the definition is used only for inlining.  In no case
8338 is the function compiled on its own, not even if you refer to its
8339 address explicitly.  Such an address becomes an external reference, as
8340 if you had only declared the function, and had not defined it.
8342 This combination of @code{inline} and @code{extern} has almost the
8343 effect of a macro.  The way to use it is to put a function definition in
8344 a header file with these keywords, and put another copy of the
8345 definition (lacking @code{inline} and @code{extern}) in a library file.
8346 The definition in the header file causes most calls to the function
8347 to be inlined.  If any uses of the function remain, they refer to
8348 the single copy in the library.
8350 @node Volatiles
8351 @section When is a Volatile Object Accessed?
8352 @cindex accessing volatiles
8353 @cindex volatile read
8354 @cindex volatile write
8355 @cindex volatile access
8357 C has the concept of volatile objects.  These are normally accessed by
8358 pointers and used for accessing hardware or inter-thread
8359 communication.  The standard encourages compilers to refrain from
8360 optimizations concerning accesses to volatile objects, but leaves it
8361 implementation defined as to what constitutes a volatile access.  The
8362 minimum requirement is that at a sequence point all previous accesses
8363 to volatile objects have stabilized and no subsequent accesses have
8364 occurred.  Thus an implementation is free to reorder and combine
8365 volatile accesses that occur between sequence points, but cannot do
8366 so for accesses across a sequence point.  The use of volatile does
8367 not allow you to violate the restriction on updating objects multiple
8368 times between two sequence points.
8370 Accesses to non-volatile objects are not ordered with respect to
8371 volatile accesses.  You cannot use a volatile object as a memory
8372 barrier to order a sequence of writes to non-volatile memory.  For
8373 instance:
8375 @smallexample
8376 int *ptr = @var{something};
8377 volatile int vobj;
8378 *ptr = @var{something};
8379 vobj = 1;
8380 @end smallexample
8382 @noindent
8383 Unless @var{*ptr} and @var{vobj} can be aliased, it is not guaranteed
8384 that the write to @var{*ptr} occurs by the time the update
8385 of @var{vobj} happens.  If you need this guarantee, you must use
8386 a stronger memory barrier such as:
8388 @smallexample
8389 int *ptr = @var{something};
8390 volatile int vobj;
8391 *ptr = @var{something};
8392 asm volatile ("" : : : "memory");
8393 vobj = 1;
8394 @end smallexample
8396 A scalar volatile object is read when it is accessed in a void context:
8398 @smallexample
8399 volatile int *src = @var{somevalue};
8400 *src;
8401 @end smallexample
8403 Such expressions are rvalues, and GCC implements this as a
8404 read of the volatile object being pointed to.
8406 Assignments are also expressions and have an rvalue.  However when
8407 assigning to a scalar volatile, the volatile object is not reread,
8408 regardless of whether the assignment expression's rvalue is used or
8409 not.  If the assignment's rvalue is used, the value is that assigned
8410 to the volatile object.  For instance, there is no read of @var{vobj}
8411 in all the following cases:
8413 @smallexample
8414 int obj;
8415 volatile int vobj;
8416 vobj = @var{something};
8417 obj = vobj = @var{something};
8418 obj ? vobj = @var{onething} : vobj = @var{anotherthing};
8419 obj = (@var{something}, vobj = @var{anotherthing});
8420 @end smallexample
8422 If you need to read the volatile object after an assignment has
8423 occurred, you must use a separate expression with an intervening
8424 sequence point.
8426 As bit-fields are not individually addressable, volatile bit-fields may
8427 be implicitly read when written to, or when adjacent bit-fields are
8428 accessed.  Bit-field operations may be optimized such that adjacent
8429 bit-fields are only partially accessed, if they straddle a storage unit
8430 boundary.  For these reasons it is unwise to use volatile bit-fields to
8431 access hardware.
8433 @node Using Assembly Language with C
8434 @section How to Use Inline Assembly Language in C Code
8435 @cindex @code{asm} keyword
8436 @cindex assembly language in C
8437 @cindex inline assembly language
8438 @cindex mixing assembly language and C
8440 The @code{asm} keyword allows you to embed assembler instructions
8441 within C code.  GCC provides two forms of inline @code{asm}
8442 statements.  A @dfn{basic @code{asm}} statement is one with no
8443 operands (@pxref{Basic Asm}), while an @dfn{extended @code{asm}}
8444 statement (@pxref{Extended Asm}) includes one or more operands.  
8445 The extended form is preferred for mixing C and assembly language
8446 within a function, but to include assembly language at
8447 top level you must use basic @code{asm}.
8449 You can also use the @code{asm} keyword to override the assembler name
8450 for a C symbol, or to place a C variable in a specific register.
8452 @menu
8453 * Basic Asm::          Inline assembler without operands.
8454 * Extended Asm::       Inline assembler with operands.
8455 * Constraints::        Constraints for @code{asm} operands
8456 * Asm Labels::         Specifying the assembler name to use for a C symbol.
8457 * Explicit Register Variables::  Defining variables residing in specified 
8458                        registers.
8459 * Size of an asm::     How GCC calculates the size of an @code{asm} block.
8460 @end menu
8462 @node Basic Asm
8463 @subsection Basic Asm --- Assembler Instructions Without Operands
8464 @cindex basic @code{asm}
8465 @cindex assembly language in C, basic
8467 A basic @code{asm} statement has the following syntax:
8469 @example
8470 asm @var{asm-qualifiers} ( @var{AssemblerInstructions} )
8471 @end example
8473 The @code{asm} keyword is a GNU extension.
8474 When writing code that can be compiled with @option{-ansi} and the
8475 various @option{-std} options, use @code{__asm__} instead of 
8476 @code{asm} (@pxref{Alternate Keywords}).
8478 @subsubheading Qualifiers
8479 @table @code
8480 @item volatile
8481 The optional @code{volatile} qualifier has no effect. 
8482 All basic @code{asm} blocks are implicitly volatile.
8484 @item inline
8485 If you use the @code{inline} qualifier, then for inlining purposes the size
8486 of the @code{asm} statement is taken as the smallest size possible (@pxref{Size
8487 of an asm}).
8488 @end table
8490 @subsubheading Parameters
8491 @table @var
8493 @item AssemblerInstructions
8494 This is a literal string that specifies the assembler code. The string can 
8495 contain any instructions recognized by the assembler, including directives. 
8496 GCC does not parse the assembler instructions themselves and 
8497 does not know what they mean or even whether they are valid assembler input. 
8499 You may place multiple assembler instructions together in a single @code{asm} 
8500 string, separated by the characters normally used in assembly code for the 
8501 system. A combination that works in most places is a newline to break the 
8502 line, plus a tab character (written as @samp{\n\t}).
8503 Some assemblers allow semicolons as a line separator. However, 
8504 note that some assembler dialects use semicolons to start a comment. 
8505 @end table
8507 @subsubheading Remarks
8508 Using extended @code{asm} (@pxref{Extended Asm}) typically produces
8509 smaller, safer, and more efficient code, and in most cases it is a
8510 better solution than basic @code{asm}.  However, there are two
8511 situations where only basic @code{asm} can be used:
8513 @itemize @bullet
8514 @item
8515 Extended @code{asm} statements have to be inside a C
8516 function, so to write inline assembly language at file scope (``top-level''),
8517 outside of C functions, you must use basic @code{asm}.
8518 You can use this technique to emit assembler directives,
8519 define assembly language macros that can be invoked elsewhere in the file,
8520 or write entire functions in assembly language.
8522 @item
8523 Functions declared
8524 with the @code{naked} attribute also require basic @code{asm}
8525 (@pxref{Function Attributes}).
8526 @end itemize
8528 Safely accessing C data and calling functions from basic @code{asm} is more 
8529 complex than it may appear. To access C data, it is better to use extended 
8530 @code{asm}.
8532 Do not expect a sequence of @code{asm} statements to remain perfectly 
8533 consecutive after compilation. If certain instructions need to remain 
8534 consecutive in the output, put them in a single multi-instruction @code{asm}
8535 statement. Note that GCC's optimizers can move @code{asm} statements 
8536 relative to other code, including across jumps.
8538 @code{asm} statements may not perform jumps into other @code{asm} statements. 
8539 GCC does not know about these jumps, and therefore cannot take 
8540 account of them when deciding how to optimize. Jumps from @code{asm} to C 
8541 labels are only supported in extended @code{asm}.
8543 Under certain circumstances, GCC may duplicate (or remove duplicates of) your 
8544 assembly code when optimizing. This can lead to unexpected duplicate 
8545 symbol errors during compilation if your assembly code defines symbols or 
8546 labels.
8548 @strong{Warning:} The C standards do not specify semantics for @code{asm},
8549 making it a potential source of incompatibilities between compilers.  These
8550 incompatibilities may not produce compiler warnings/errors.
8552 GCC does not parse basic @code{asm}'s @var{AssemblerInstructions}, which
8553 means there is no way to communicate to the compiler what is happening
8554 inside them.  GCC has no visibility of symbols in the @code{asm} and may
8555 discard them as unreferenced.  It also does not know about side effects of
8556 the assembler code, such as modifications to memory or registers.  Unlike
8557 some compilers, GCC assumes that no changes to general purpose registers
8558 occur.  This assumption may change in a future release.
8560 To avoid complications from future changes to the semantics and the
8561 compatibility issues between compilers, consider replacing basic @code{asm}
8562 with extended @code{asm}.  See
8563 @uref{https://gcc.gnu.org/wiki/ConvertBasicAsmToExtended, How to convert
8564 from basic asm to extended asm} for information about how to perform this
8565 conversion.
8567 The compiler copies the assembler instructions in a basic @code{asm} 
8568 verbatim to the assembly language output file, without 
8569 processing dialects or any of the @samp{%} operators that are available with
8570 extended @code{asm}. This results in minor differences between basic 
8571 @code{asm} strings and extended @code{asm} templates. For example, to refer to 
8572 registers you might use @samp{%eax} in basic @code{asm} and
8573 @samp{%%eax} in extended @code{asm}.
8575 On targets such as x86 that support multiple assembler dialects,
8576 all basic @code{asm} blocks use the assembler dialect specified by the 
8577 @option{-masm} command-line option (@pxref{x86 Options}).  
8578 Basic @code{asm} provides no
8579 mechanism to provide different assembler strings for different dialects.
8581 For basic @code{asm} with non-empty assembler string GCC assumes
8582 the assembler block does not change any general purpose registers,
8583 but it may read or write any globally accessible variable.
8585 Here is an example of basic @code{asm} for i386:
8587 @example
8588 /* Note that this code will not compile with -masm=intel */
8589 #define DebugBreak() asm("int $3")
8590 @end example
8592 @node Extended Asm
8593 @subsection Extended Asm - Assembler Instructions with C Expression Operands
8594 @cindex extended @code{asm}
8595 @cindex assembly language in C, extended
8597 With extended @code{asm} you can read and write C variables from 
8598 assembler and perform jumps from assembler code to C labels.  
8599 Extended @code{asm} syntax uses colons (@samp{:}) to delimit
8600 the operand parameters after the assembler template:
8602 @example
8603 asm @var{asm-qualifiers} ( @var{AssemblerTemplate} 
8604                  : @var{OutputOperands} 
8605                  @r{[} : @var{InputOperands}
8606                  @r{[} : @var{Clobbers} @r{]} @r{]})
8608 asm @var{asm-qualifiers} ( @var{AssemblerTemplate} 
8609                       : 
8610                       : @var{InputOperands}
8611                       : @var{Clobbers}
8612                       : @var{GotoLabels})
8613 @end example
8614 where in the last form, @var{asm-qualifiers} contains @code{goto} (and in the
8615 first form, not).
8617 The @code{asm} keyword is a GNU extension.
8618 When writing code that can be compiled with @option{-ansi} and the
8619 various @option{-std} options, use @code{__asm__} instead of 
8620 @code{asm} (@pxref{Alternate Keywords}).
8622 @subsubheading Qualifiers
8623 @table @code
8625 @item volatile
8626 The typical use of extended @code{asm} statements is to manipulate input 
8627 values to produce output values. However, your @code{asm} statements may 
8628 also produce side effects. If so, you may need to use the @code{volatile} 
8629 qualifier to disable certain optimizations. @xref{Volatile}.
8631 @item inline
8632 If you use the @code{inline} qualifier, then for inlining purposes the size
8633 of the @code{asm} statement is taken as the smallest size possible
8634 (@pxref{Size of an asm}).
8636 @item goto
8637 This qualifier informs the compiler that the @code{asm} statement may 
8638 perform a jump to one of the labels listed in the @var{GotoLabels}.
8639 @xref{GotoLabels}.
8640 @end table
8642 @subsubheading Parameters
8643 @table @var
8644 @item AssemblerTemplate
8645 This is a literal string that is the template for the assembler code. It is a 
8646 combination of fixed text and tokens that refer to the input, output, 
8647 and goto parameters. @xref{AssemblerTemplate}.
8649 @item OutputOperands
8650 A comma-separated list of the C variables modified by the instructions in the 
8651 @var{AssemblerTemplate}.  An empty list is permitted.  @xref{OutputOperands}.
8653 @item InputOperands
8654 A comma-separated list of C expressions read by the instructions in the 
8655 @var{AssemblerTemplate}.  An empty list is permitted.  @xref{InputOperands}.
8657 @item Clobbers
8658 A comma-separated list of registers or other values changed by the 
8659 @var{AssemblerTemplate}, beyond those listed as outputs.
8660 An empty list is permitted.  @xref{Clobbers and Scratch Registers}.
8662 @item GotoLabels
8663 When you are using the @code{goto} form of @code{asm}, this section contains 
8664 the list of all C labels to which the code in the 
8665 @var{AssemblerTemplate} may jump. 
8666 @xref{GotoLabels}.
8668 @code{asm} statements may not perform jumps into other @code{asm} statements,
8669 only to the listed @var{GotoLabels}.
8670 GCC's optimizers do not know about other jumps; therefore they cannot take 
8671 account of them when deciding how to optimize.
8672 @end table
8674 The total number of input + output + goto operands is limited to 30.
8676 @subsubheading Remarks
8677 The @code{asm} statement allows you to include assembly instructions directly 
8678 within C code. This may help you to maximize performance in time-sensitive 
8679 code or to access assembly instructions that are not readily available to C 
8680 programs.
8682 Note that extended @code{asm} statements must be inside a function. Only 
8683 basic @code{asm} may be outside functions (@pxref{Basic Asm}).
8684 Functions declared with the @code{naked} attribute also require basic 
8685 @code{asm} (@pxref{Function Attributes}).
8687 While the uses of @code{asm} are many and varied, it may help to think of an 
8688 @code{asm} statement as a series of low-level instructions that convert input 
8689 parameters to output parameters. So a simple (if not particularly useful) 
8690 example for i386 using @code{asm} might look like this:
8692 @example
8693 int src = 1;
8694 int dst;   
8696 asm ("mov %1, %0\n\t"
8697     "add $1, %0"
8698     : "=r" (dst) 
8699     : "r" (src));
8701 printf("%d\n", dst);
8702 @end example
8704 This code copies @code{src} to @code{dst} and add 1 to @code{dst}.
8706 @anchor{Volatile}
8707 @subsubsection Volatile
8708 @cindex volatile @code{asm}
8709 @cindex @code{asm} volatile
8711 GCC's optimizers sometimes discard @code{asm} statements if they determine 
8712 there is no need for the output variables. Also, the optimizers may move 
8713 code out of loops if they believe that the code will always return the same 
8714 result (i.e.@: none of its input values change between calls). Using the 
8715 @code{volatile} qualifier disables these optimizations. @code{asm} statements 
8716 that have no output operands, including @code{asm goto} statements, 
8717 are implicitly volatile.
8719 This i386 code demonstrates a case that does not use (or require) the 
8720 @code{volatile} qualifier. If it is performing assertion checking, this code 
8721 uses @code{asm} to perform the validation. Otherwise, @code{dwRes} is 
8722 unreferenced by any code. As a result, the optimizers can discard the 
8723 @code{asm} statement, which in turn removes the need for the entire 
8724 @code{DoCheck} routine. By omitting the @code{volatile} qualifier when it 
8725 isn't needed you allow the optimizers to produce the most efficient code 
8726 possible.
8728 @example
8729 void DoCheck(uint32_t dwSomeValue)
8731    uint32_t dwRes;
8733    // Assumes dwSomeValue is not zero.
8734    asm ("bsfl %1,%0"
8735      : "=r" (dwRes)
8736      : "r" (dwSomeValue)
8737      : "cc");
8739    assert(dwRes > 3);
8741 @end example
8743 The next example shows a case where the optimizers can recognize that the input 
8744 (@code{dwSomeValue}) never changes during the execution of the function and can 
8745 therefore move the @code{asm} outside the loop to produce more efficient code. 
8746 Again, using the @code{volatile} qualifier disables this type of optimization.
8748 @example
8749 void do_print(uint32_t dwSomeValue)
8751    uint32_t dwRes;
8753    for (uint32_t x=0; x < 5; x++)
8754    @{
8755       // Assumes dwSomeValue is not zero.
8756       asm ("bsfl %1,%0"
8757         : "=r" (dwRes)
8758         : "r" (dwSomeValue)
8759         : "cc");
8761       printf("%u: %u %u\n", x, dwSomeValue, dwRes);
8762    @}
8764 @end example
8766 The following example demonstrates a case where you need to use the 
8767 @code{volatile} qualifier. 
8768 It uses the x86 @code{rdtsc} instruction, which reads 
8769 the computer's time-stamp counter. Without the @code{volatile} qualifier, 
8770 the optimizers might assume that the @code{asm} block will always return the 
8771 same value and therefore optimize away the second call.
8773 @example
8774 uint64_t msr;
8776 asm volatile ( "rdtsc\n\t"    // Returns the time in EDX:EAX.
8777         "shl $32, %%rdx\n\t"  // Shift the upper bits left.
8778         "or %%rdx, %0"        // 'Or' in the lower bits.
8779         : "=a" (msr)
8780         : 
8781         : "rdx");
8783 printf("msr: %llx\n", msr);
8785 // Do other work...
8787 // Reprint the timestamp
8788 asm volatile ( "rdtsc\n\t"    // Returns the time in EDX:EAX.
8789         "shl $32, %%rdx\n\t"  // Shift the upper bits left.
8790         "or %%rdx, %0"        // 'Or' in the lower bits.
8791         : "=a" (msr)
8792         : 
8793         : "rdx");
8795 printf("msr: %llx\n", msr);
8796 @end example
8798 GCC's optimizers do not treat this code like the non-volatile code in the 
8799 earlier examples. They do not move it out of loops or omit it on the 
8800 assumption that the result from a previous call is still valid.
8802 Note that the compiler can move even @code{volatile asm} instructions relative
8803 to other code, including across jump instructions. For example, on many 
8804 targets there is a system register that controls the rounding mode of 
8805 floating-point operations. Setting it with a @code{volatile asm} statement,
8806 as in the following PowerPC example, does not work reliably.
8808 @example
8809 asm volatile("mtfsf 255, %0" : : "f" (fpenv));
8810 sum = x + y;
8811 @end example
8813 The compiler may move the addition back before the @code{volatile asm}
8814 statement. To make it work as expected, add an artificial dependency to
8815 the @code{asm} by referencing a variable in the subsequent code, for
8816 example:
8818 @example
8819 asm volatile ("mtfsf 255,%1" : "=X" (sum) : "f" (fpenv));
8820 sum = x + y;
8821 @end example
8823 Under certain circumstances, GCC may duplicate (or remove duplicates of) your 
8824 assembly code when optimizing. This can lead to unexpected duplicate symbol 
8825 errors during compilation if your @code{asm} code defines symbols or labels. 
8826 Using @samp{%=} 
8827 (@pxref{AssemblerTemplate}) may help resolve this problem.
8829 @anchor{AssemblerTemplate}
8830 @subsubsection Assembler Template
8831 @cindex @code{asm} assembler template
8833 An assembler template is a literal string containing assembler instructions.
8834 The compiler replaces tokens in the template that refer 
8835 to inputs, outputs, and goto labels,
8836 and then outputs the resulting string to the assembler. The 
8837 string can contain any instructions recognized by the assembler, including 
8838 directives. GCC does not parse the assembler instructions 
8839 themselves and does not know what they mean or even whether they are valid 
8840 assembler input. However, it does count the statements 
8841 (@pxref{Size of an asm}).
8843 You may place multiple assembler instructions together in a single @code{asm} 
8844 string, separated by the characters normally used in assembly code for the 
8845 system. A combination that works in most places is a newline to break the 
8846 line, plus a tab character to move to the instruction field (written as 
8847 @samp{\n\t}). 
8848 Some assemblers allow semicolons as a line separator. However, note 
8849 that some assembler dialects use semicolons to start a comment. 
8851 Do not expect a sequence of @code{asm} statements to remain perfectly 
8852 consecutive after compilation, even when you are using the @code{volatile} 
8853 qualifier. If certain instructions need to remain consecutive in the output, 
8854 put them in a single multi-instruction @code{asm} statement.
8856 Accessing data from C programs without using input/output operands (such as 
8857 by using global symbols directly from the assembler template) may not work as 
8858 expected. Similarly, calling functions directly from an assembler template 
8859 requires a detailed understanding of the target assembler and ABI.
8861 Since GCC does not parse the assembler template,
8862 it has no visibility of any 
8863 symbols it references. This may result in GCC discarding those symbols as 
8864 unreferenced unless they are also listed as input, output, or goto operands.
8866 @subsubheading Special format strings
8868 In addition to the tokens described by the input, output, and goto operands, 
8869 these tokens have special meanings in the assembler template:
8871 @table @samp
8872 @item %% 
8873 Outputs a single @samp{%} into the assembler code.
8875 @item %= 
8876 Outputs a number that is unique to each instance of the @code{asm} 
8877 statement in the entire compilation. This option is useful when creating local 
8878 labels and referring to them multiple times in a single template that 
8879 generates multiple assembler instructions. 
8881 @item %@{
8882 @itemx %|
8883 @itemx %@}
8884 Outputs @samp{@{}, @samp{|}, and @samp{@}} characters (respectively)
8885 into the assembler code.  When unescaped, these characters have special
8886 meaning to indicate multiple assembler dialects, as described below.
8887 @end table
8889 @subsubheading Multiple assembler dialects in @code{asm} templates
8891 On targets such as x86, GCC supports multiple assembler dialects.
8892 The @option{-masm} option controls which dialect GCC uses as its 
8893 default for inline assembler. The target-specific documentation for the 
8894 @option{-masm} option contains the list of supported dialects, as well as the 
8895 default dialect if the option is not specified. This information may be 
8896 important to understand, since assembler code that works correctly when 
8897 compiled using one dialect will likely fail if compiled using another.
8898 @xref{x86 Options}.
8900 If your code needs to support multiple assembler dialects (for example, if 
8901 you are writing public headers that need to support a variety of compilation 
8902 options), use constructs of this form:
8904 @example
8905 @{ dialect0 | dialect1 | dialect2... @}
8906 @end example
8908 This construct outputs @code{dialect0} 
8909 when using dialect #0 to compile the code, 
8910 @code{dialect1} for dialect #1, etc. If there are fewer alternatives within the 
8911 braces than the number of dialects the compiler supports, the construct 
8912 outputs nothing.
8914 For example, if an x86 compiler supports two dialects
8915 (@samp{att}, @samp{intel}), an 
8916 assembler template such as this:
8918 @example
8919 "bt@{l %[Offset],%[Base] | %[Base],%[Offset]@}; jc %l2"
8920 @end example
8922 @noindent
8923 is equivalent to one of
8925 @example
8926 "btl %[Offset],%[Base] ; jc %l2"   @r{/* att dialect */}
8927 "bt %[Base],%[Offset]; jc %l2"     @r{/* intel dialect */}
8928 @end example
8930 Using that same compiler, this code:
8932 @example
8933 "xchg@{l@}\t@{%%@}ebx, %1"
8934 @end example
8936 @noindent
8937 corresponds to either
8939 @example
8940 "xchgl\t%%ebx, %1"                 @r{/* att dialect */}
8941 "xchg\tebx, %1"                    @r{/* intel dialect */}
8942 @end example
8944 There is no support for nesting dialect alternatives.
8946 @anchor{OutputOperands}
8947 @subsubsection Output Operands
8948 @cindex @code{asm} output operands
8950 An @code{asm} statement has zero or more output operands indicating the names
8951 of C variables modified by the assembler code.
8953 In this i386 example, @code{old} (referred to in the template string as 
8954 @code{%0}) and @code{*Base} (as @code{%1}) are outputs and @code{Offset} 
8955 (@code{%2}) is an input:
8957 @example
8958 bool old;
8960 __asm__ ("btsl %2,%1\n\t" // Turn on zero-based bit #Offset in Base.
8961          "sbb %0,%0"      // Use the CF to calculate old.
8962    : "=r" (old), "+rm" (*Base)
8963    : "Ir" (Offset)
8964    : "cc");
8966 return old;
8967 @end example
8969 Operands are separated by commas.  Each operand has this format:
8971 @example
8972 @r{[} [@var{asmSymbolicName}] @r{]} @var{constraint} (@var{cvariablename})
8973 @end example
8975 @table @var
8976 @item asmSymbolicName
8977 Specifies a symbolic name for the operand.
8978 Reference the name in the assembler template 
8979 by enclosing it in square brackets 
8980 (i.e.@: @samp{%[Value]}). The scope of the name is the @code{asm} statement 
8981 that contains the definition. Any valid C variable name is acceptable, 
8982 including names already defined in the surrounding code. No two operands 
8983 within the same @code{asm} statement can use the same symbolic name.
8985 When not using an @var{asmSymbolicName}, use the (zero-based) position
8986 of the operand 
8987 in the list of operands in the assembler template. For example if there are 
8988 three output operands, use @samp{%0} in the template to refer to the first, 
8989 @samp{%1} for the second, and @samp{%2} for the third. 
8991 @item constraint
8992 A string constant specifying constraints on the placement of the operand; 
8993 @xref{Constraints}, for details.
8995 Output constraints must begin with either @samp{=} (a variable overwriting an 
8996 existing value) or @samp{+} (when reading and writing). When using 
8997 @samp{=}, do not assume the location contains the existing value
8998 on entry to the @code{asm}, except 
8999 when the operand is tied to an input; @pxref{InputOperands,,Input Operands}.
9001 After the prefix, there must be one or more additional constraints 
9002 (@pxref{Constraints}) that describe where the value resides. Common 
9003 constraints include @samp{r} for register and @samp{m} for memory. 
9004 When you list more than one possible location (for example, @code{"=rm"}),
9005 the compiler chooses the most efficient one based on the current context. 
9006 If you list as many alternates as the @code{asm} statement allows, you permit 
9007 the optimizers to produce the best possible code. 
9008 If you must use a specific register, but your Machine Constraints do not
9009 provide sufficient control to select the specific register you want, 
9010 local register variables may provide a solution (@pxref{Local Register 
9011 Variables}).
9013 @item cvariablename
9014 Specifies a C lvalue expression to hold the output, typically a variable name.
9015 The enclosing parentheses are a required part of the syntax.
9017 @end table
9019 When the compiler selects the registers to use to 
9020 represent the output operands, it does not use any of the clobbered registers 
9021 (@pxref{Clobbers and Scratch Registers}).
9023 Output operand expressions must be lvalues. The compiler cannot check whether 
9024 the operands have data types that are reasonable for the instruction being 
9025 executed. For output expressions that are not directly addressable (for 
9026 example a bit-field), the constraint must allow a register. In that case, GCC 
9027 uses the register as the output of the @code{asm}, and then stores that 
9028 register into the output. 
9030 Operands using the @samp{+} constraint modifier count as two operands 
9031 (that is, both as input and output) towards the total maximum of 30 operands
9032 per @code{asm} statement.
9034 Use the @samp{&} constraint modifier (@pxref{Modifiers}) on all output
9035 operands that must not overlap an input.  Otherwise, 
9036 GCC may allocate the output operand in the same register as an unrelated 
9037 input operand, on the assumption that the assembler code consumes its 
9038 inputs before producing outputs. This assumption may be false if the assembler 
9039 code actually consists of more than one instruction.
9041 The same problem can occur if one output parameter (@var{a}) allows a register 
9042 constraint and another output parameter (@var{b}) allows a memory constraint.
9043 The code generated by GCC to access the memory address in @var{b} can contain
9044 registers which @emph{might} be shared by @var{a}, and GCC considers those 
9045 registers to be inputs to the asm. As above, GCC assumes that such input
9046 registers are consumed before any outputs are written. This assumption may 
9047 result in incorrect behavior if the @code{asm} statement writes to @var{a}
9048 before using
9049 @var{b}. Combining the @samp{&} modifier with the register constraint on @var{a}
9050 ensures that modifying @var{a} does not affect the address referenced by 
9051 @var{b}. Otherwise, the location of @var{b} 
9052 is undefined if @var{a} is modified before using @var{b}.
9054 @code{asm} supports operand modifiers on operands (for example @samp{%k2} 
9055 instead of simply @samp{%2}). Typically these qualifiers are hardware 
9056 dependent. The list of supported modifiers for x86 is found at 
9057 @ref{x86Operandmodifiers,x86 Operand modifiers}.
9059 If the C code that follows the @code{asm} makes no use of any of the output 
9060 operands, use @code{volatile} for the @code{asm} statement to prevent the 
9061 optimizers from discarding the @code{asm} statement as unneeded 
9062 (see @ref{Volatile}).
9064 This code makes no use of the optional @var{asmSymbolicName}. Therefore it 
9065 references the first output operand as @code{%0} (were there a second, it 
9066 would be @code{%1}, etc). The number of the first input operand is one greater 
9067 than that of the last output operand. In this i386 example, that makes 
9068 @code{Mask} referenced as @code{%1}:
9070 @example
9071 uint32_t Mask = 1234;
9072 uint32_t Index;
9074   asm ("bsfl %1, %0"
9075      : "=r" (Index)
9076      : "r" (Mask)
9077      : "cc");
9078 @end example
9080 That code overwrites the variable @code{Index} (@samp{=}),
9081 placing the value in a register (@samp{r}).
9082 Using the generic @samp{r} constraint instead of a constraint for a specific 
9083 register allows the compiler to pick the register to use, which can result 
9084 in more efficient code. This may not be possible if an assembler instruction 
9085 requires a specific register.
9087 The following i386 example uses the @var{asmSymbolicName} syntax.
9088 It produces the 
9089 same result as the code above, but some may consider it more readable or more 
9090 maintainable since reordering index numbers is not necessary when adding or 
9091 removing operands. The names @code{aIndex} and @code{aMask}
9092 are only used in this example to emphasize which 
9093 names get used where.
9094 It is acceptable to reuse the names @code{Index} and @code{Mask}.
9096 @example
9097 uint32_t Mask = 1234;
9098 uint32_t Index;
9100   asm ("bsfl %[aMask], %[aIndex]"
9101      : [aIndex] "=r" (Index)
9102      : [aMask] "r" (Mask)
9103      : "cc");
9104 @end example
9106 Here are some more examples of output operands.
9108 @example
9109 uint32_t c = 1;
9110 uint32_t d;
9111 uint32_t *e = &c;
9113 asm ("mov %[e], %[d]"
9114    : [d] "=rm" (d)
9115    : [e] "rm" (*e));
9116 @end example
9118 Here, @code{d} may either be in a register or in memory. Since the compiler 
9119 might already have the current value of the @code{uint32_t} location
9120 pointed to by @code{e}
9121 in a register, you can enable it to choose the best location
9122 for @code{d} by specifying both constraints.
9124 @anchor{FlagOutputOperands}
9125 @subsubsection Flag Output Operands
9126 @cindex @code{asm} flag output operands
9128 Some targets have a special register that holds the ``flags'' for the
9129 result of an operation or comparison.  Normally, the contents of that
9130 register are either unmodifed by the asm, or the @code{asm} statement is
9131 considered to clobber the contents.
9133 On some targets, a special form of output operand exists by which
9134 conditions in the flags register may be outputs of the asm.  The set of
9135 conditions supported are target specific, but the general rule is that
9136 the output variable must be a scalar integer, and the value is boolean.
9137 When supported, the target defines the preprocessor symbol
9138 @code{__GCC_ASM_FLAG_OUTPUTS__}.
9140 Because of the special nature of the flag output operands, the constraint
9141 may not include alternatives.
9143 Most often, the target has only one flags register, and thus is an implied
9144 operand of many instructions.  In this case, the operand should not be
9145 referenced within the assembler template via @code{%0} etc, as there's
9146 no corresponding text in the assembly language.
9148 @table @asis
9149 @item x86 family
9150 The flag output constraints for the x86 family are of the form
9151 @samp{=@@cc@var{cond}} where @var{cond} is one of the standard
9152 conditions defined in the ISA manual for @code{j@var{cc}} or
9153 @code{set@var{cc}}.
9155 @table @code
9156 @item a
9157 ``above'' or unsigned greater than
9158 @item ae
9159 ``above or equal'' or unsigned greater than or equal
9160 @item b
9161 ``below'' or unsigned less than
9162 @item be
9163 ``below or equal'' or unsigned less than or equal
9164 @item c
9165 carry flag set
9166 @item e
9167 @itemx z
9168 ``equal'' or zero flag set
9169 @item g
9170 signed greater than
9171 @item ge
9172 signed greater than or equal
9173 @item l
9174 signed less than
9175 @item le
9176 signed less than or equal
9177 @item o
9178 overflow flag set
9179 @item p
9180 parity flag set
9181 @item s
9182 sign flag set
9183 @item na
9184 @itemx nae
9185 @itemx nb
9186 @itemx nbe
9187 @itemx nc
9188 @itemx ne
9189 @itemx ng
9190 @itemx nge
9191 @itemx nl
9192 @itemx nle
9193 @itemx no
9194 @itemx np
9195 @itemx ns
9196 @itemx nz
9197 ``not'' @var{flag}, or inverted versions of those above
9198 @end table
9200 @end table
9202 @anchor{InputOperands}
9203 @subsubsection Input Operands
9204 @cindex @code{asm} input operands
9205 @cindex @code{asm} expressions
9207 Input operands make values from C variables and expressions available to the 
9208 assembly code.
9210 Operands are separated by commas.  Each operand has this format:
9212 @example
9213 @r{[} [@var{asmSymbolicName}] @r{]} @var{constraint} (@var{cexpression})
9214 @end example
9216 @table @var
9217 @item asmSymbolicName
9218 Specifies a symbolic name for the operand.
9219 Reference the name in the assembler template 
9220 by enclosing it in square brackets 
9221 (i.e.@: @samp{%[Value]}). The scope of the name is the @code{asm} statement 
9222 that contains the definition. Any valid C variable name is acceptable, 
9223 including names already defined in the surrounding code. No two operands 
9224 within the same @code{asm} statement can use the same symbolic name.
9226 When not using an @var{asmSymbolicName}, use the (zero-based) position
9227 of the operand 
9228 in the list of operands in the assembler template. For example if there are
9229 two output operands and three inputs,
9230 use @samp{%2} in the template to refer to the first input operand,
9231 @samp{%3} for the second, and @samp{%4} for the third. 
9233 @item constraint
9234 A string constant specifying constraints on the placement of the operand; 
9235 @xref{Constraints}, for details.
9237 Input constraint strings may not begin with either @samp{=} or @samp{+}.
9238 When you list more than one possible location (for example, @samp{"irm"}), 
9239 the compiler chooses the most efficient one based on the current context.
9240 If you must use a specific register, but your Machine Constraints do not
9241 provide sufficient control to select the specific register you want, 
9242 local register variables may provide a solution (@pxref{Local Register 
9243 Variables}).
9245 Input constraints can also be digits (for example, @code{"0"}). This indicates 
9246 that the specified input must be in the same place as the output constraint 
9247 at the (zero-based) index in the output constraint list. 
9248 When using @var{asmSymbolicName} syntax for the output operands,
9249 you may use these names (enclosed in brackets @samp{[]}) instead of digits.
9251 @item cexpression
9252 This is the C variable or expression being passed to the @code{asm} statement 
9253 as input.  The enclosing parentheses are a required part of the syntax.
9255 @end table
9257 When the compiler selects the registers to use to represent the input 
9258 operands, it does not use any of the clobbered registers
9259 (@pxref{Clobbers and Scratch Registers}).
9261 If there are no output operands but there are input operands, place two 
9262 consecutive colons where the output operands would go:
9264 @example
9265 __asm__ ("some instructions"
9266    : /* No outputs. */
9267    : "r" (Offset / 8));
9268 @end example
9270 @strong{Warning:} Do @emph{not} modify the contents of input-only operands 
9271 (except for inputs tied to outputs). The compiler assumes that on exit from 
9272 the @code{asm} statement these operands contain the same values as they 
9273 had before executing the statement. 
9274 It is @emph{not} possible to use clobbers
9275 to inform the compiler that the values in these inputs are changing. One 
9276 common work-around is to tie the changing input variable to an output variable 
9277 that never gets used. Note, however, that if the code that follows the 
9278 @code{asm} statement makes no use of any of the output operands, the GCC 
9279 optimizers may discard the @code{asm} statement as unneeded 
9280 (see @ref{Volatile}).
9282 @code{asm} supports operand modifiers on operands (for example @samp{%k2} 
9283 instead of simply @samp{%2}). Typically these qualifiers are hardware 
9284 dependent. The list of supported modifiers for x86 is found at 
9285 @ref{x86Operandmodifiers,x86 Operand modifiers}.
9287 In this example using the fictitious @code{combine} instruction, the 
9288 constraint @code{"0"} for input operand 1 says that it must occupy the same 
9289 location as output operand 0. Only input operands may use numbers in 
9290 constraints, and they must each refer to an output operand. Only a number (or 
9291 the symbolic assembler name) in the constraint can guarantee that one operand 
9292 is in the same place as another. The mere fact that @code{foo} is the value of 
9293 both operands is not enough to guarantee that they are in the same place in 
9294 the generated assembler code.
9296 @example
9297 asm ("combine %2, %0" 
9298    : "=r" (foo) 
9299    : "0" (foo), "g" (bar));
9300 @end example
9302 Here is an example using symbolic names.
9304 @example
9305 asm ("cmoveq %1, %2, %[result]" 
9306    : [result] "=r"(result) 
9307    : "r" (test), "r" (new), "[result]" (old));
9308 @end example
9310 @anchor{Clobbers and Scratch Registers}
9311 @subsubsection Clobbers and Scratch Registers
9312 @cindex @code{asm} clobbers
9313 @cindex @code{asm} scratch registers
9315 While the compiler is aware of changes to entries listed in the output 
9316 operands, the inline @code{asm} code may modify more than just the outputs. For 
9317 example, calculations may require additional registers, or the processor may 
9318 overwrite a register as a side effect of a particular assembler instruction. 
9319 In order to inform the compiler of these changes, list them in the clobber 
9320 list. Clobber list items are either register names or the special clobbers 
9321 (listed below). Each clobber list item is a string constant 
9322 enclosed in double quotes and separated by commas.
9324 Clobber descriptions may not in any way overlap with an input or output 
9325 operand. For example, you may not have an operand describing a register class 
9326 with one member when listing that register in the clobber list. Variables 
9327 declared to live in specific registers (@pxref{Explicit Register 
9328 Variables}) and used 
9329 as @code{asm} input or output operands must have no part mentioned in the 
9330 clobber description. In particular, there is no way to specify that input 
9331 operands get modified without also specifying them as output operands.
9333 When the compiler selects which registers to use to represent input and output 
9334 operands, it does not use any of the clobbered registers. As a result, 
9335 clobbered registers are available for any use in the assembler code.
9337 Here is a realistic example for the VAX showing the use of clobbered 
9338 registers: 
9340 @example
9341 asm volatile ("movc3 %0, %1, %2"
9342                    : /* No outputs. */
9343                    : "g" (from), "g" (to), "g" (count)
9344                    : "r0", "r1", "r2", "r3", "r4", "r5", "memory");
9345 @end example
9347 Also, there are two special clobber arguments:
9349 @table @code
9350 @item "cc"
9351 The @code{"cc"} clobber indicates that the assembler code modifies the flags 
9352 register. On some machines, GCC represents the condition codes as a specific 
9353 hardware register; @code{"cc"} serves to name this register.
9354 On other machines, condition code handling is different, 
9355 and specifying @code{"cc"} has no effect. But 
9356 it is valid no matter what the target.
9358 @item "memory"
9359 The @code{"memory"} clobber tells the compiler that the assembly code
9360 performs memory 
9361 reads or writes to items other than those listed in the input and output 
9362 operands (for example, accessing the memory pointed to by one of the input 
9363 parameters). To ensure memory contains correct values, GCC may need to flush 
9364 specific register values to memory before executing the @code{asm}. Further, 
9365 the compiler does not assume that any values read from memory before an 
9366 @code{asm} remain unchanged after that @code{asm}; it reloads them as 
9367 needed.  
9368 Using the @code{"memory"} clobber effectively forms a read/write
9369 memory barrier for the compiler.
9371 Note that this clobber does not prevent the @emph{processor} from doing 
9372 speculative reads past the @code{asm} statement. To prevent that, you need 
9373 processor-specific fence instructions.
9375 @end table
9377 Flushing registers to memory has performance implications and may be
9378 an issue for time-sensitive code.  You can provide better information
9379 to GCC to avoid this, as shown in the following examples.  At a
9380 minimum, aliasing rules allow GCC to know what memory @emph{doesn't}
9381 need to be flushed.
9383 Here is a fictitious sum of squares instruction, that takes two
9384 pointers to floating point values in memory and produces a floating
9385 point register output.
9386 Notice that @code{x}, and @code{y} both appear twice in the @code{asm}
9387 parameters, once to specify memory accessed, and once to specify a
9388 base register used by the @code{asm}.  You won't normally be wasting a
9389 register by doing this as GCC can use the same register for both
9390 purposes.  However, it would be foolish to use both @code{%1} and
9391 @code{%3} for @code{x} in this @code{asm} and expect them to be the
9392 same.  In fact, @code{%3} may well not be a register.  It might be a
9393 symbolic memory reference to the object pointed to by @code{x}.
9395 @smallexample
9396 asm ("sumsq %0, %1, %2"
9397      : "+f" (result)
9398      : "r" (x), "r" (y), "m" (*x), "m" (*y));
9399 @end smallexample
9401 Here is a fictitious @code{*z++ = *x++ * *y++} instruction.
9402 Notice that the @code{x}, @code{y} and @code{z} pointer registers
9403 must be specified as input/output because the @code{asm} modifies
9404 them.
9406 @smallexample
9407 asm ("vecmul %0, %1, %2"
9408      : "+r" (z), "+r" (x), "+r" (y), "=m" (*z)
9409      : "m" (*x), "m" (*y));
9410 @end smallexample
9412 An x86 example where the string memory argument is of unknown length.
9414 @smallexample
9415 asm("repne scasb"
9416     : "=c" (count), "+D" (p)
9417     : "m" (*(const char (*)[]) p), "0" (-1), "a" (0));
9418 @end smallexample
9420 If you know the above will only be reading a ten byte array then you
9421 could instead use a memory input like:
9422 @code{"m" (*(const char (*)[10]) p)}.
9424 Here is an example of a PowerPC vector scale implemented in assembly,
9425 complete with vector and condition code clobbers, and some initialized
9426 offset registers that are unchanged by the @code{asm}.
9428 @smallexample
9429 void
9430 dscal (size_t n, double *x, double alpha)
9432   asm ("/* lots of asm here */"
9433        : "+m" (*(double (*)[n]) x), "+&r" (n), "+b" (x)
9434        : "d" (alpha), "b" (32), "b" (48), "b" (64),
9435          "b" (80), "b" (96), "b" (112)
9436        : "cr0",
9437          "vs32","vs33","vs34","vs35","vs36","vs37","vs38","vs39",
9438          "vs40","vs41","vs42","vs43","vs44","vs45","vs46","vs47");
9440 @end smallexample
9442 Rather than allocating fixed registers via clobbers to provide scratch
9443 registers for an @code{asm} statement, an alternative is to define a
9444 variable and make it an early-clobber output as with @code{a2} and
9445 @code{a3} in the example below.  This gives the compiler register
9446 allocator more freedom.  You can also define a variable and make it an
9447 output tied to an input as with @code{a0} and @code{a1}, tied
9448 respectively to @code{ap} and @code{lda}.  Of course, with tied
9449 outputs your @code{asm} can't use the input value after modifying the
9450 output register since they are one and the same register.  What's
9451 more, if you omit the early-clobber on the output, it is possible that
9452 GCC might allocate the same register to another of the inputs if GCC
9453 could prove they had the same value on entry to the @code{asm}.  This
9454 is why @code{a1} has an early-clobber.  Its tied input, @code{lda}
9455 might conceivably be known to have the value 16 and without an
9456 early-clobber share the same register as @code{%11}.  On the other
9457 hand, @code{ap} can't be the same as any of the other inputs, so an
9458 early-clobber on @code{a0} is not needed.  It is also not desirable in
9459 this case.  An early-clobber on @code{a0} would cause GCC to allocate
9460 a separate register for the @code{"m" (*(const double (*)[]) ap)}
9461 input.  Note that tying an input to an output is the way to set up an
9462 initialized temporary register modified by an @code{asm} statement.
9463 An input not tied to an output is assumed by GCC to be unchanged, for
9464 example @code{"b" (16)} below sets up @code{%11} to 16, and GCC might
9465 use that register in following code if the value 16 happened to be
9466 needed.  You can even use a normal @code{asm} output for a scratch if
9467 all inputs that might share the same register are consumed before the
9468 scratch is used.  The VSX registers clobbered by the @code{asm}
9469 statement could have used this technique except for GCC's limit on the
9470 number of @code{asm} parameters.
9472 @smallexample
9473 static void
9474 dgemv_kernel_4x4 (long n, const double *ap, long lda,
9475                   const double *x, double *y, double alpha)
9477   double *a0;
9478   double *a1;
9479   double *a2;
9480   double *a3;
9482   __asm__
9483     (
9484      /* lots of asm here */
9485      "#n=%1 ap=%8=%12 lda=%13 x=%7=%10 y=%0=%2 alpha=%9 o16=%11\n"
9486      "#a0=%3 a1=%4 a2=%5 a3=%6"
9487      :
9488        "+m" (*(double (*)[n]) y),
9489        "+&r" (n),       // 1
9490        "+b" (y),        // 2
9491        "=b" (a0),       // 3
9492        "=&b" (a1),      // 4
9493        "=&b" (a2),      // 5
9494        "=&b" (a3)       // 6
9495      :
9496        "m" (*(const double (*)[n]) x),
9497        "m" (*(const double (*)[]) ap),
9498        "d" (alpha),     // 9
9499        "r" (x),         // 10
9500        "b" (16),        // 11
9501        "3" (ap),        // 12
9502        "4" (lda)        // 13
9503      :
9504        "cr0",
9505        "vs32","vs33","vs34","vs35","vs36","vs37",
9506        "vs40","vs41","vs42","vs43","vs44","vs45","vs46","vs47"
9507      );
9509 @end smallexample
9511 @anchor{GotoLabels}
9512 @subsubsection Goto Labels
9513 @cindex @code{asm} goto labels
9515 @code{asm goto} allows assembly code to jump to one or more C labels.  The
9516 @var{GotoLabels} section in an @code{asm goto} statement contains 
9517 a comma-separated 
9518 list of all C labels to which the assembler code may jump. GCC assumes that 
9519 @code{asm} execution falls through to the next statement (if this is not the 
9520 case, consider using the @code{__builtin_unreachable} intrinsic after the 
9521 @code{asm} statement). Optimization of @code{asm goto} may be improved by 
9522 using the @code{hot} and @code{cold} label attributes (@pxref{Label 
9523 Attributes}).
9525 An @code{asm goto} statement cannot have outputs.
9526 This is due to an internal restriction of 
9527 the compiler: control transfer instructions cannot have outputs. 
9528 If the assembler code does modify anything, use the @code{"memory"} clobber 
9529 to force the 
9530 optimizers to flush all register values to memory and reload them if 
9531 necessary after the @code{asm} statement.
9533 Also note that an @code{asm goto} statement is always implicitly
9534 considered volatile.
9536 To reference a label in the assembler template,
9537 prefix it with @samp{%l} (lowercase @samp{L}) followed 
9538 by its (zero-based) position in @var{GotoLabels} plus the number of input 
9539 operands.  For example, if the @code{asm} has three inputs and references two 
9540 labels, refer to the first label as @samp{%l3} and the second as @samp{%l4}).
9542 Alternately, you can reference labels using the actual C label name enclosed
9543 in brackets.  For example, to reference a label named @code{carry}, you can
9544 use @samp{%l[carry]}.  The label must still be listed in the @var{GotoLabels}
9545 section when using this approach.
9547 Here is an example of @code{asm goto} for i386:
9549 @example
9550 asm goto (
9551     "btl %1, %0\n\t"
9552     "jc %l2"
9553     : /* No outputs. */
9554     : "r" (p1), "r" (p2) 
9555     : "cc" 
9556     : carry);
9558 return 0;
9560 carry:
9561 return 1;
9562 @end example
9564 The following example shows an @code{asm goto} that uses a memory clobber.
9566 @example
9567 int frob(int x)
9569   int y;
9570   asm goto ("frob %%r5, %1; jc %l[error]; mov (%2), %%r5"
9571             : /* No outputs. */
9572             : "r"(x), "r"(&y)
9573             : "r5", "memory" 
9574             : error);
9575   return y;
9576 error:
9577   return -1;
9579 @end example
9581 @anchor{x86Operandmodifiers}
9582 @subsubsection x86 Operand Modifiers
9584 References to input, output, and goto operands in the assembler template
9585 of extended @code{asm} statements can use 
9586 modifiers to affect the way the operands are formatted in 
9587 the code output to the assembler. For example, the 
9588 following code uses the @samp{h} and @samp{b} modifiers for x86:
9590 @example
9591 uint16_t  num;
9592 asm volatile ("xchg %h0, %b0" : "+a" (num) );
9593 @end example
9595 @noindent
9596 These modifiers generate this assembler code:
9598 @example
9599 xchg %ah, %al
9600 @end example
9602 The rest of this discussion uses the following code for illustrative purposes.
9604 @example
9605 int main()
9607    int iInt = 1;
9609 top:
9611    asm volatile goto ("some assembler instructions here"
9612    : /* No outputs. */
9613    : "q" (iInt), "X" (sizeof(unsigned char) + 1), "i" (42)
9614    : /* No clobbers. */
9615    : top);
9617 @end example
9619 With no modifiers, this is what the output from the operands would be
9620 for the @samp{att} and @samp{intel} dialects of assembler:
9622 @multitable {Operand} {$.L2} {OFFSET FLAT:.L2}
9623 @headitem Operand @tab @samp{att} @tab @samp{intel}
9624 @item @code{%0}
9625 @tab @code{%eax}
9626 @tab @code{eax}
9627 @item @code{%1}
9628 @tab @code{$2}
9629 @tab @code{2}
9630 @item @code{%3}
9631 @tab @code{$.L3}
9632 @tab @code{OFFSET FLAT:.L3}
9633 @end multitable
9635 The table below shows the list of supported modifiers and their effects.
9637 @multitable {Modifier} {Print the opcode suffix for the size of th} {Operand} {@samp{att}} {@samp{intel}}
9638 @headitem Modifier @tab Description @tab Operand @tab @samp{att} @tab @samp{intel}
9639 @item @code{a}
9640 @tab Print an absolute memory reference.
9641 @tab @code{%A0}
9642 @tab @code{*%rax}
9643 @tab @code{rax}
9644 @item @code{b}
9645 @tab Print the QImode name of the register.
9646 @tab @code{%b0}
9647 @tab @code{%al}
9648 @tab @code{al}
9649 @item @code{c}
9650 @tab Require a constant operand and print the constant expression with no punctuation.
9651 @tab @code{%c1}
9652 @tab @code{2}
9653 @tab @code{2}
9654 @item @code{E}
9655 @tab Print the address in Double Integer (DImode) mode (8 bytes) when the target is 64-bit.
9656 Otherwise mode is unspecified (VOIDmode).
9657 @tab @code{%E1}
9658 @tab @code{%(rax)}
9659 @tab @code{[rax]}
9660 @item @code{h}
9661 @tab Print the QImode name for a ``high'' register.
9662 @tab @code{%h0}
9663 @tab @code{%ah}
9664 @tab @code{ah}
9665 @item @code{H}
9666 @tab Add 8 bytes to an offsettable memory reference. Useful when accessing the
9667 high 8 bytes of SSE values. For a memref in (%rax), it generates
9668 @tab @code{%H0}
9669 @tab @code{8(%rax)}
9670 @tab @code{8[rax]}
9671 @item @code{k}
9672 @tab Print the SImode name of the register.
9673 @tab @code{%k0}
9674 @tab @code{%eax}
9675 @tab @code{eax}
9676 @item @code{l}
9677 @tab Print the label name with no punctuation.
9678 @tab @code{%l3}
9679 @tab @code{.L3}
9680 @tab @code{.L3}
9681 @item @code{p}
9682 @tab Print raw symbol name (without syntax-specific prefixes).
9683 @tab @code{%p2}
9684 @tab @code{42}
9685 @tab @code{42}
9686 @item @code{P}
9687 @tab If used for a function, print the PLT suffix and generate PIC code.
9688 For example, emit @code{foo@@PLT} instead of 'foo' for the function
9689 foo(). If used for a constant, drop all syntax-specific prefixes and
9690 issue the bare constant. See @code{p} above.
9691 @item @code{q}
9692 @tab Print the DImode name of the register.
9693 @tab @code{%q0}
9694 @tab @code{%rax}
9695 @tab @code{rax}
9696 @item @code{w}
9697 @tab Print the HImode name of the register.
9698 @tab @code{%w0}
9699 @tab @code{%ax}
9700 @tab @code{ax}
9701 @item @code{z}
9702 @tab Print the opcode suffix for the size of the current integer operand (one of @code{b}/@code{w}/@code{l}/@code{q}).
9703 @tab @code{%z0}
9704 @tab @code{l}
9705 @tab 
9706 @end multitable
9708 @code{V} is a special modifier which prints the name of the full integer
9709 register without @code{%}.
9711 @anchor{x86floatingpointasmoperands}
9712 @subsubsection x86 Floating-Point @code{asm} Operands
9714 On x86 targets, there are several rules on the usage of stack-like registers
9715 in the operands of an @code{asm}.  These rules apply only to the operands
9716 that are stack-like registers:
9718 @enumerate
9719 @item
9720 Given a set of input registers that die in an @code{asm}, it is
9721 necessary to know which are implicitly popped by the @code{asm}, and
9722 which must be explicitly popped by GCC@.
9724 An input register that is implicitly popped by the @code{asm} must be
9725 explicitly clobbered, unless it is constrained to match an
9726 output operand.
9728 @item
9729 For any input register that is implicitly popped by an @code{asm}, it is
9730 necessary to know how to adjust the stack to compensate for the pop.
9731 If any non-popped input is closer to the top of the reg-stack than
9732 the implicitly popped register, it would not be possible to know what the
9733 stack looked like---it's not clear how the rest of the stack ``slides
9734 up''.
9736 All implicitly popped input registers must be closer to the top of
9737 the reg-stack than any input that is not implicitly popped.
9739 It is possible that if an input dies in an @code{asm}, the compiler might
9740 use the input register for an output reload.  Consider this example:
9742 @smallexample
9743 asm ("foo" : "=t" (a) : "f" (b));
9744 @end smallexample
9746 @noindent
9747 This code says that input @code{b} is not popped by the @code{asm}, and that
9748 the @code{asm} pushes a result onto the reg-stack, i.e., the stack is one
9749 deeper after the @code{asm} than it was before.  But, it is possible that
9750 reload may think that it can use the same register for both the input and
9751 the output.
9753 To prevent this from happening,
9754 if any input operand uses the @samp{f} constraint, all output register
9755 constraints must use the @samp{&} early-clobber modifier.
9757 The example above is correctly written as:
9759 @smallexample
9760 asm ("foo" : "=&t" (a) : "f" (b));
9761 @end smallexample
9763 @item
9764 Some operands need to be in particular places on the stack.  All
9765 output operands fall in this category---GCC has no other way to
9766 know which registers the outputs appear in unless you indicate
9767 this in the constraints.
9769 Output operands must specifically indicate which register an output
9770 appears in after an @code{asm}.  @samp{=f} is not allowed: the operand
9771 constraints must select a class with a single register.
9773 @item
9774 Output operands may not be ``inserted'' between existing stack registers.
9775 Since no 387 opcode uses a read/write operand, all output operands
9776 are dead before the @code{asm}, and are pushed by the @code{asm}.
9777 It makes no sense to push anywhere but the top of the reg-stack.
9779 Output operands must start at the top of the reg-stack: output
9780 operands may not ``skip'' a register.
9782 @item
9783 Some @code{asm} statements may need extra stack space for internal
9784 calculations.  This can be guaranteed by clobbering stack registers
9785 unrelated to the inputs and outputs.
9787 @end enumerate
9789 This @code{asm}
9790 takes one input, which is internally popped, and produces two outputs.
9792 @smallexample
9793 asm ("fsincos" : "=t" (cos), "=u" (sin) : "0" (inp));
9794 @end smallexample
9796 @noindent
9797 This @code{asm} takes two inputs, which are popped by the @code{fyl2xp1} opcode,
9798 and replaces them with one output.  The @code{st(1)} clobber is necessary 
9799 for the compiler to know that @code{fyl2xp1} pops both inputs.
9801 @smallexample
9802 asm ("fyl2xp1" : "=t" (result) : "0" (x), "u" (y) : "st(1)");
9803 @end smallexample
9805 @lowersections
9806 @include md.texi
9807 @raisesections
9809 @node Asm Labels
9810 @subsection Controlling Names Used in Assembler Code
9811 @cindex assembler names for identifiers
9812 @cindex names used in assembler code
9813 @cindex identifiers, names in assembler code
9815 You can specify the name to be used in the assembler code for a C
9816 function or variable by writing the @code{asm} (or @code{__asm__})
9817 keyword after the declarator.
9818 It is up to you to make sure that the assembler names you choose do not
9819 conflict with any other assembler symbols, or reference registers.
9821 @subsubheading Assembler names for data:
9823 This sample shows how to specify the assembler name for data:
9825 @smallexample
9826 int foo asm ("myfoo") = 2;
9827 @end smallexample
9829 @noindent
9830 This specifies that the name to be used for the variable @code{foo} in
9831 the assembler code should be @samp{myfoo} rather than the usual
9832 @samp{_foo}.
9834 On systems where an underscore is normally prepended to the name of a C
9835 variable, this feature allows you to define names for the
9836 linker that do not start with an underscore.
9838 GCC does not support using this feature with a non-static local variable 
9839 since such variables do not have assembler names.  If you are
9840 trying to put the variable in a particular register, see 
9841 @ref{Explicit Register Variables}.
9843 @subsubheading Assembler names for functions:
9845 To specify the assembler name for functions, write a declaration for the 
9846 function before its definition and put @code{asm} there, like this:
9848 @smallexample
9849 int func (int x, int y) asm ("MYFUNC");
9850      
9851 int func (int x, int y)
9853    /* @r{@dots{}} */
9854 @end smallexample
9856 @noindent
9857 This specifies that the name to be used for the function @code{func} in
9858 the assembler code should be @code{MYFUNC}.
9860 @node Explicit Register Variables
9861 @subsection Variables in Specified Registers
9862 @anchor{Explicit Reg Vars}
9863 @cindex explicit register variables
9864 @cindex variables in specified registers
9865 @cindex specified registers
9867 GNU C allows you to associate specific hardware registers with C 
9868 variables.  In almost all cases, allowing the compiler to assign
9869 registers produces the best code.  However under certain unusual
9870 circumstances, more precise control over the variable storage is 
9871 required.
9873 Both global and local variables can be associated with a register.  The
9874 consequences of performing this association are very different between
9875 the two, as explained in the sections below.
9877 @menu
9878 * Global Register Variables::   Variables declared at global scope.
9879 * Local Register Variables::    Variables declared within a function.
9880 @end menu
9882 @node Global Register Variables
9883 @subsubsection Defining Global Register Variables
9884 @anchor{Global Reg Vars}
9885 @cindex global register variables
9886 @cindex registers, global variables in
9887 @cindex registers, global allocation
9889 You can define a global register variable and associate it with a specified 
9890 register like this:
9892 @smallexample
9893 register int *foo asm ("r12");
9894 @end smallexample
9896 @noindent
9897 Here @code{r12} is the name of the register that should be used. Note that 
9898 this is the same syntax used for defining local register variables, but for 
9899 a global variable the declaration appears outside a function. The 
9900 @code{register} keyword is required, and cannot be combined with 
9901 @code{static}. The register name must be a valid register name for the
9902 target platform.
9904 Do not use type qualifiers such as @code{const} and @code{volatile}, as
9905 the outcome may be contrary to expectations.  In  particular, using the
9906 @code{volatile} qualifier does not fully prevent the compiler from
9907 optimizing accesses to the register.
9909 Registers are a scarce resource on most systems and allowing the 
9910 compiler to manage their usage usually results in the best code. However, 
9911 under special circumstances it can make sense to reserve some globally.
9912 For example this may be useful in programs such as programming language 
9913 interpreters that have a couple of global variables that are accessed 
9914 very often.
9916 After defining a global register variable, for the current compilation
9917 unit:
9919 @itemize @bullet
9920 @item If the register is a call-saved register, call ABI is affected:
9921 the register will not be restored in function epilogue sequences after
9922 the variable has been assigned.  Therefore, functions cannot safely
9923 return to callers that assume standard ABI.
9924 @item Conversely, if the register is a call-clobbered register, making
9925 calls to functions that use standard ABI may lose contents of the variable.
9926 Such calls may be created by the compiler even if none are evident in
9927 the original program, for example when libgcc functions are used to
9928 make up for unavailable instructions.
9929 @item Accesses to the variable may be optimized as usual and the register
9930 remains available for allocation and use in any computations, provided that
9931 observable values of the variable are not affected.
9932 @item If the variable is referenced in inline assembly, the type of access
9933 must be provided to the compiler via constraints (@pxref{Constraints}).
9934 Accesses from basic asms are not supported.
9935 @end itemize
9937 Note that these points @emph{only} apply to code that is compiled with the
9938 definition. The behavior of code that is merely linked in (for example 
9939 code from libraries) is not affected.
9941 If you want to recompile source files that do not actually use your global 
9942 register variable so they do not use the specified register for any other 
9943 purpose, you need not actually add the global register declaration to 
9944 their source code. It suffices to specify the compiler option 
9945 @option{-ffixed-@var{reg}} (@pxref{Code Gen Options}) to reserve the 
9946 register.
9948 @subsubheading Declaring the variable
9950 Global register variables can not have initial values, because an
9951 executable file has no means to supply initial contents for a register.
9953 When selecting a register, choose one that is normally saved and 
9954 restored by function calls on your machine. This ensures that code
9955 which is unaware of this reservation (such as library routines) will 
9956 restore it before returning.
9958 On machines with register windows, be sure to choose a global
9959 register that is not affected magically by the function call mechanism.
9961 @subsubheading Using the variable
9963 @cindex @code{qsort}, and global register variables
9964 When calling routines that are not aware of the reservation, be 
9965 cautious if those routines call back into code which uses them. As an 
9966 example, if you call the system library version of @code{qsort}, it may 
9967 clobber your registers during execution, but (if you have selected 
9968 appropriate registers) it will restore them before returning. However 
9969 it will @emph{not} restore them before calling @code{qsort}'s comparison 
9970 function. As a result, global values will not reliably be available to 
9971 the comparison function unless the @code{qsort} function itself is rebuilt.
9973 Similarly, it is not safe to access the global register variables from signal
9974 handlers or from more than one thread of control. Unless you recompile 
9975 them specially for the task at hand, the system library routines may 
9976 temporarily use the register for other things.  Furthermore, since the register
9977 is not reserved exclusively for the variable, accessing it from handlers of
9978 asynchronous signals may observe unrelated temporary values residing in the
9979 register.
9981 @cindex register variable after @code{longjmp}
9982 @cindex global register after @code{longjmp}
9983 @cindex value after @code{longjmp}
9984 @findex longjmp
9985 @findex setjmp
9986 On most machines, @code{longjmp} restores to each global register
9987 variable the value it had at the time of the @code{setjmp}. On some
9988 machines, however, @code{longjmp} does not change the value of global
9989 register variables. To be portable, the function that called @code{setjmp}
9990 should make other arrangements to save the values of the global register
9991 variables, and to restore them in a @code{longjmp}. This way, the same
9992 thing happens regardless of what @code{longjmp} does.
9994 @node Local Register Variables
9995 @subsubsection Specifying Registers for Local Variables
9996 @anchor{Local Reg Vars}
9997 @cindex local variables, specifying registers
9998 @cindex specifying registers for local variables
9999 @cindex registers for local variables
10001 You can define a local register variable and associate it with a specified 
10002 register like this:
10004 @smallexample
10005 register int *foo asm ("r12");
10006 @end smallexample
10008 @noindent
10009 Here @code{r12} is the name of the register that should be used.  Note
10010 that this is the same syntax used for defining global register variables, 
10011 but for a local variable the declaration appears within a function.  The 
10012 @code{register} keyword is required, and cannot be combined with 
10013 @code{static}.  The register name must be a valid register name for the
10014 target platform.
10016 Do not use type qualifiers such as @code{const} and @code{volatile}, as
10017 the outcome may be contrary to expectations. In particular, when the
10018 @code{const} qualifier is used, the compiler may substitute the
10019 variable with its initializer in @code{asm} statements, which may cause
10020 the corresponding operand to appear in a different register.
10022 As with global register variables, it is recommended that you choose 
10023 a register that is normally saved and restored by function calls on your 
10024 machine, so that calls to library routines will not clobber it.
10026 The only supported use for this feature is to specify registers
10027 for input and output operands when calling Extended @code{asm} 
10028 (@pxref{Extended Asm}).  This may be necessary if the constraints for a 
10029 particular machine don't provide sufficient control to select the desired 
10030 register.  To force an operand into a register, create a local variable 
10031 and specify the register name after the variable's declaration.  Then use 
10032 the local variable for the @code{asm} operand and specify any constraint 
10033 letter that matches the register:
10035 @smallexample
10036 register int *p1 asm ("r0") = @dots{};
10037 register int *p2 asm ("r1") = @dots{};
10038 register int *result asm ("r0");
10039 asm ("sysint" : "=r" (result) : "0" (p1), "r" (p2));
10040 @end smallexample
10042 @emph{Warning:} In the above example, be aware that a register (for example 
10043 @code{r0}) can be call-clobbered by subsequent code, including function 
10044 calls and library calls for arithmetic operators on other variables (for 
10045 example the initialization of @code{p2}).  In this case, use temporary 
10046 variables for expressions between the register assignments:
10048 @smallexample
10049 int t1 = @dots{};
10050 register int *p1 asm ("r0") = @dots{};
10051 register int *p2 asm ("r1") = t1;
10052 register int *result asm ("r0");
10053 asm ("sysint" : "=r" (result) : "0" (p1), "r" (p2));
10054 @end smallexample
10056 Defining a register variable does not reserve the register.  Other than
10057 when invoking the Extended @code{asm}, the contents of the specified 
10058 register are not guaranteed.  For this reason, the following uses 
10059 are explicitly @emph{not} supported.  If they appear to work, it is only 
10060 happenstance, and may stop working as intended due to (seemingly) 
10061 unrelated changes in surrounding code, or even minor changes in the 
10062 optimization of a future version of gcc:
10064 @itemize @bullet
10065 @item Passing parameters to or from Basic @code{asm}
10066 @item Passing parameters to or from Extended @code{asm} without using input 
10067 or output operands.
10068 @item Passing parameters to or from routines written in assembler (or
10069 other languages) using non-standard calling conventions.
10070 @end itemize
10072 Some developers use Local Register Variables in an attempt to improve 
10073 gcc's allocation of registers, especially in large functions.  In this 
10074 case the register name is essentially a hint to the register allocator.
10075 While in some instances this can generate better code, improvements are
10076 subject to the whims of the allocator/optimizers.  Since there are no
10077 guarantees that your improvements won't be lost, this usage of Local
10078 Register Variables is discouraged.
10080 On the MIPS platform, there is related use for local register variables 
10081 with slightly different characteristics (@pxref{MIPS Coprocessors,, 
10082 Defining coprocessor specifics for MIPS targets, gccint, 
10083 GNU Compiler Collection (GCC) Internals}).
10085 @node Size of an asm
10086 @subsection Size of an @code{asm}
10088 Some targets require that GCC track the size of each instruction used
10089 in order to generate correct code.  Because the final length of the
10090 code produced by an @code{asm} statement is only known by the
10091 assembler, GCC must make an estimate as to how big it will be.  It
10092 does this by counting the number of instructions in the pattern of the
10093 @code{asm} and multiplying that by the length of the longest
10094 instruction supported by that processor.  (When working out the number
10095 of instructions, it assumes that any occurrence of a newline or of
10096 whatever statement separator character is supported by the assembler ---
10097 typically @samp{;} --- indicates the end of an instruction.)
10099 Normally, GCC's estimate is adequate to ensure that correct
10100 code is generated, but it is possible to confuse the compiler if you use
10101 pseudo instructions or assembler macros that expand into multiple real
10102 instructions, or if you use assembler directives that expand to more
10103 space in the object file than is needed for a single instruction.
10104 If this happens then the assembler may produce a diagnostic saying that
10105 a label is unreachable.
10107 @cindex @code{asm inline}
10108 This size is also used for inlining decisions.  If you use @code{asm inline}
10109 instead of just @code{asm}, then for inlining purposes the size of the asm
10110 is taken as the minimum size, ignoring how many instructions GCC thinks it is.
10112 @node Alternate Keywords
10113 @section Alternate Keywords
10114 @cindex alternate keywords
10115 @cindex keywords, alternate
10117 @option{-ansi} and the various @option{-std} options disable certain
10118 keywords.  This causes trouble when you want to use GNU C extensions, or
10119 a general-purpose header file that should be usable by all programs,
10120 including ISO C programs.  The keywords @code{asm}, @code{typeof} and
10121 @code{inline} are not available in programs compiled with
10122 @option{-ansi} or @option{-std} (although @code{inline} can be used in a
10123 program compiled with @option{-std=c99} or @option{-std=c11}).  The
10124 ISO C99 keyword
10125 @code{restrict} is only available when @option{-std=gnu99} (which will
10126 eventually be the default) or @option{-std=c99} (or the equivalent
10127 @option{-std=iso9899:1999}), or an option for a later standard
10128 version, is used.
10130 The way to solve these problems is to put @samp{__} at the beginning and
10131 end of each problematical keyword.  For example, use @code{__asm__}
10132 instead of @code{asm}, and @code{__inline__} instead of @code{inline}.
10134 Other C compilers won't accept these alternative keywords; if you want to
10135 compile with another compiler, you can define the alternate keywords as
10136 macros to replace them with the customary keywords.  It looks like this:
10138 @smallexample
10139 #ifndef __GNUC__
10140 #define __asm__ asm
10141 #endif
10142 @end smallexample
10144 @findex __extension__
10145 @opindex pedantic
10146 @option{-pedantic} and other options cause warnings for many GNU C extensions.
10147 You can
10148 prevent such warnings within one expression by writing
10149 @code{__extension__} before the expression.  @code{__extension__} has no
10150 effect aside from this.
10152 @node Incomplete Enums
10153 @section Incomplete @code{enum} Types
10155 You can define an @code{enum} tag without specifying its possible values.
10156 This results in an incomplete type, much like what you get if you write
10157 @code{struct foo} without describing the elements.  A later declaration
10158 that does specify the possible values completes the type.
10160 You cannot allocate variables or storage using the type while it is
10161 incomplete.  However, you can work with pointers to that type.
10163 This extension may not be very useful, but it makes the handling of
10164 @code{enum} more consistent with the way @code{struct} and @code{union}
10165 are handled.
10167 This extension is not supported by GNU C++.
10169 @node Function Names
10170 @section Function Names as Strings
10171 @cindex @code{__func__} identifier
10172 @cindex @code{__FUNCTION__} identifier
10173 @cindex @code{__PRETTY_FUNCTION__} identifier
10175 GCC provides three magic constants that hold the name of the current
10176 function as a string.  In C++11 and later modes, all three are treated
10177 as constant expressions and can be used in @code{constexpr} constexts.
10178 The first of these constants is @code{__func__}, which is part of
10179 the C99 standard:
10181 The identifier @code{__func__} is implicitly declared by the translator
10182 as if, immediately following the opening brace of each function
10183 definition, the declaration
10185 @smallexample
10186 static const char __func__[] = "function-name";
10187 @end smallexample
10189 @noindent
10190 appeared, where function-name is the name of the lexically-enclosing
10191 function.  This name is the unadorned name of the function.  As an
10192 extension, at file (or, in C++, namespace scope), @code{__func__}
10193 evaluates to the empty string.
10195 @code{__FUNCTION__} is another name for @code{__func__}, provided for
10196 backward compatibility with old versions of GCC.
10198 In C, @code{__PRETTY_FUNCTION__} is yet another name for
10199 @code{__func__}, except that at file (or, in C++, namespace scope),
10200 it evaluates to the string @code{"top level"}.  In addition, in C++,
10201 @code{__PRETTY_FUNCTION__} contains the signature of the function as
10202 well as its bare name.  For example, this program:
10204 @smallexample
10205 extern "C" int printf (const char *, ...);
10207 class a @{
10208  public:
10209   void sub (int i)
10210     @{
10211       printf ("__FUNCTION__ = %s\n", __FUNCTION__);
10212       printf ("__PRETTY_FUNCTION__ = %s\n", __PRETTY_FUNCTION__);
10213     @}
10217 main (void)
10219   a ax;
10220   ax.sub (0);
10221   return 0;
10223 @end smallexample
10225 @noindent
10226 gives this output:
10228 @smallexample
10229 __FUNCTION__ = sub
10230 __PRETTY_FUNCTION__ = void a::sub(int)
10231 @end smallexample
10233 These identifiers are variables, not preprocessor macros, and may not
10234 be used to initialize @code{char} arrays or be concatenated with string
10235 literals.
10237 @node Return Address
10238 @section Getting the Return or Frame Address of a Function
10240 These functions may be used to get information about the callers of a
10241 function.
10243 @deftypefn {Built-in Function} {void *} __builtin_return_address (unsigned int @var{level})
10244 This function returns the return address of the current function, or of
10245 one of its callers.  The @var{level} argument is number of frames to
10246 scan up the call stack.  A value of @code{0} yields the return address
10247 of the current function, a value of @code{1} yields the return address
10248 of the caller of the current function, and so forth.  When inlining
10249 the expected behavior is that the function returns the address of
10250 the function that is returned to.  To work around this behavior use
10251 the @code{noinline} function attribute.
10253 The @var{level} argument must be a constant integer.
10255 On some machines it may be impossible to determine the return address of
10256 any function other than the current one; in such cases, or when the top
10257 of the stack has been reached, this function returns @code{0} or a
10258 random value.  In addition, @code{__builtin_frame_address} may be used
10259 to determine if the top of the stack has been reached.
10261 Additional post-processing of the returned value may be needed, see
10262 @code{__builtin_extract_return_addr}.
10264 Calling this function with a nonzero argument can have unpredictable
10265 effects, including crashing the calling program.  As a result, calls
10266 that are considered unsafe are diagnosed when the @option{-Wframe-address}
10267 option is in effect.  Such calls should only be made in debugging
10268 situations.
10269 @end deftypefn
10271 @deftypefn {Built-in Function} {void *} __builtin_extract_return_addr (void *@var{addr})
10272 The address as returned by @code{__builtin_return_address} may have to be fed
10273 through this function to get the actual encoded address.  For example, on the
10274 31-bit S/390 platform the highest bit has to be masked out, or on SPARC
10275 platforms an offset has to be added for the true next instruction to be
10276 executed.
10278 If no fixup is needed, this function simply passes through @var{addr}.
10279 @end deftypefn
10281 @deftypefn {Built-in Function} {void *} __builtin_frob_return_address (void *@var{addr})
10282 This function does the reverse of @code{__builtin_extract_return_addr}.
10283 @end deftypefn
10285 @deftypefn {Built-in Function} {void *} __builtin_frame_address (unsigned int @var{level})
10286 This function is similar to @code{__builtin_return_address}, but it
10287 returns the address of the function frame rather than the return address
10288 of the function.  Calling @code{__builtin_frame_address} with a value of
10289 @code{0} yields the frame address of the current function, a value of
10290 @code{1} yields the frame address of the caller of the current function,
10291 and so forth.
10293 The frame is the area on the stack that holds local variables and saved
10294 registers.  The frame address is normally the address of the first word
10295 pushed on to the stack by the function.  However, the exact definition
10296 depends upon the processor and the calling convention.  If the processor
10297 has a dedicated frame pointer register, and the function has a frame,
10298 then @code{__builtin_frame_address} returns the value of the frame
10299 pointer register.
10301 On some machines it may be impossible to determine the frame address of
10302 any function other than the current one; in such cases, or when the top
10303 of the stack has been reached, this function returns @code{0} if
10304 the first frame pointer is properly initialized by the startup code.
10306 Calling this function with a nonzero argument can have unpredictable
10307 effects, including crashing the calling program.  As a result, calls
10308 that are considered unsafe are diagnosed when the @option{-Wframe-address}
10309 option is in effect.  Such calls should only be made in debugging
10310 situations.
10311 @end deftypefn
10313 @node Vector Extensions
10314 @section Using Vector Instructions through Built-in Functions
10316 On some targets, the instruction set contains SIMD vector instructions which
10317 operate on multiple values contained in one large register at the same time.
10318 For example, on the x86 the MMX, 3DNow!@: and SSE extensions can be used
10319 this way.
10321 The first step in using these extensions is to provide the necessary data
10322 types.  This should be done using an appropriate @code{typedef}:
10324 @smallexample
10325 typedef int v4si __attribute__ ((vector_size (16)));
10326 @end smallexample
10328 @noindent
10329 The @code{int} type specifies the base type, while the attribute specifies
10330 the vector size for the variable, measured in bytes.  For example, the
10331 declaration above causes the compiler to set the mode for the @code{v4si}
10332 type to be 16 bytes wide and divided into @code{int} sized units.  For
10333 a 32-bit @code{int} this means a vector of 4 units of 4 bytes, and the
10334 corresponding mode of @code{foo} is @acronym{V4SI}.
10336 The @code{vector_size} attribute is only applicable to integral and
10337 float scalars, although arrays, pointers, and function return values
10338 are allowed in conjunction with this construct. Only sizes that are
10339 a power of two are currently allowed.
10341 All the basic integer types can be used as base types, both as signed
10342 and as unsigned: @code{char}, @code{short}, @code{int}, @code{long},
10343 @code{long long}.  In addition, @code{float} and @code{double} can be
10344 used to build floating-point vector types.
10346 Specifying a combination that is not valid for the current architecture
10347 causes GCC to synthesize the instructions using a narrower mode.
10348 For example, if you specify a variable of type @code{V4SI} and your
10349 architecture does not allow for this specific SIMD type, GCC
10350 produces code that uses 4 @code{SIs}.
10352 The types defined in this manner can be used with a subset of normal C
10353 operations.  Currently, GCC allows using the following operators
10354 on these types: @code{+, -, *, /, unary minus, ^, |, &, ~, %}@.
10356 The operations behave like C++ @code{valarrays}.  Addition is defined as
10357 the addition of the corresponding elements of the operands.  For
10358 example, in the code below, each of the 4 elements in @var{a} is
10359 added to the corresponding 4 elements in @var{b} and the resulting
10360 vector is stored in @var{c}.
10362 @smallexample
10363 typedef int v4si __attribute__ ((vector_size (16)));
10365 v4si a, b, c;
10367 c = a + b;
10368 @end smallexample
10370 Subtraction, multiplication, division, and the logical operations
10371 operate in a similar manner.  Likewise, the result of using the unary
10372 minus or complement operators on a vector type is a vector whose
10373 elements are the negative or complemented values of the corresponding
10374 elements in the operand.
10376 It is possible to use shifting operators @code{<<}, @code{>>} on
10377 integer-type vectors. The operation is defined as following: @code{@{a0,
10378 a1, @dots{}, an@} >> @{b0, b1, @dots{}, bn@} == @{a0 >> b0, a1 >> b1,
10379 @dots{}, an >> bn@}}@. Vector operands must have the same number of
10380 elements. 
10382 For convenience, it is allowed to use a binary vector operation
10383 where one operand is a scalar. In that case the compiler transforms
10384 the scalar operand into a vector where each element is the scalar from
10385 the operation. The transformation happens only if the scalar could be
10386 safely converted to the vector-element type.
10387 Consider the following code.
10389 @smallexample
10390 typedef int v4si __attribute__ ((vector_size (16)));
10392 v4si a, b, c;
10393 long l;
10395 a = b + 1;    /* a = b + @{1,1,1,1@}; */
10396 a = 2 * b;    /* a = @{2,2,2,2@} * b; */
10398 a = l + a;    /* Error, cannot convert long to int. */
10399 @end smallexample
10401 Vectors can be subscripted as if the vector were an array with
10402 the same number of elements and base type.  Out of bound accesses
10403 invoke undefined behavior at run time.  Warnings for out of bound
10404 accesses for vector subscription can be enabled with
10405 @option{-Warray-bounds}.
10407 Vector comparison is supported with standard comparison
10408 operators: @code{==, !=, <, <=, >, >=}. Comparison operands can be
10409 vector expressions of integer-type or real-type. Comparison between
10410 integer-type vectors and real-type vectors are not supported.  The
10411 result of the comparison is a vector of the same width and number of
10412 elements as the comparison operands with a signed integral element
10413 type.
10415 Vectors are compared element-wise producing 0 when comparison is false
10416 and -1 (constant of the appropriate type where all bits are set)
10417 otherwise. Consider the following example.
10419 @smallexample
10420 typedef int v4si __attribute__ ((vector_size (16)));
10422 v4si a = @{1,2,3,4@};
10423 v4si b = @{3,2,1,4@};
10424 v4si c;
10426 c = a >  b;     /* The result would be @{0, 0,-1, 0@}  */
10427 c = a == b;     /* The result would be @{0,-1, 0,-1@}  */
10428 @end smallexample
10430 In C++, the ternary operator @code{?:} is available. @code{a?b:c}, where
10431 @code{b} and @code{c} are vectors of the same type and @code{a} is an
10432 integer vector with the same number of elements of the same size as @code{b}
10433 and @code{c}, computes all three arguments and creates a vector
10434 @code{@{a[0]?b[0]:c[0], a[1]?b[1]:c[1], @dots{}@}}.  Note that unlike in
10435 OpenCL, @code{a} is thus interpreted as @code{a != 0} and not @code{a < 0}.
10436 As in the case of binary operations, this syntax is also accepted when
10437 one of @code{b} or @code{c} is a scalar that is then transformed into a
10438 vector. If both @code{b} and @code{c} are scalars and the type of
10439 @code{true?b:c} has the same size as the element type of @code{a}, then
10440 @code{b} and @code{c} are converted to a vector type whose elements have
10441 this type and with the same number of elements as @code{a}.
10443 In C++, the logic operators @code{!, &&, ||} are available for vectors.
10444 @code{!v} is equivalent to @code{v == 0}, @code{a && b} is equivalent to
10445 @code{a!=0 & b!=0} and @code{a || b} is equivalent to @code{a!=0 | b!=0}.
10446 For mixed operations between a scalar @code{s} and a vector @code{v},
10447 @code{s && v} is equivalent to @code{s?v!=0:0} (the evaluation is
10448 short-circuit) and @code{v && s} is equivalent to @code{v!=0 & (s?-1:0)}.
10450 @findex __builtin_shuffle
10451 Vector shuffling is available using functions
10452 @code{__builtin_shuffle (vec, mask)} and
10453 @code{__builtin_shuffle (vec0, vec1, mask)}.
10454 Both functions construct a permutation of elements from one or two
10455 vectors and return a vector of the same type as the input vector(s).
10456 The @var{mask} is an integral vector with the same width (@var{W})
10457 and element count (@var{N}) as the output vector.
10459 The elements of the input vectors are numbered in memory ordering of
10460 @var{vec0} beginning at 0 and @var{vec1} beginning at @var{N}.  The
10461 elements of @var{mask} are considered modulo @var{N} in the single-operand
10462 case and modulo @math{2*@var{N}} in the two-operand case.
10464 Consider the following example,
10466 @smallexample
10467 typedef int v4si __attribute__ ((vector_size (16)));
10469 v4si a = @{1,2,3,4@};
10470 v4si b = @{5,6,7,8@};
10471 v4si mask1 = @{0,1,1,3@};
10472 v4si mask2 = @{0,4,2,5@};
10473 v4si res;
10475 res = __builtin_shuffle (a, mask1);       /* res is @{1,2,2,4@}  */
10476 res = __builtin_shuffle (a, b, mask2);    /* res is @{1,5,3,6@}  */
10477 @end smallexample
10479 Note that @code{__builtin_shuffle} is intentionally semantically
10480 compatible with the OpenCL @code{shuffle} and @code{shuffle2} functions.
10482 You can declare variables and use them in function calls and returns, as
10483 well as in assignments and some casts.  You can specify a vector type as
10484 a return type for a function.  Vector types can also be used as function
10485 arguments.  It is possible to cast from one vector type to another,
10486 provided they are of the same size (in fact, you can also cast vectors
10487 to and from other datatypes of the same size).
10489 You cannot operate between vectors of different lengths or different
10490 signedness without a cast.
10492 @node Offsetof
10493 @section Support for @code{offsetof}
10494 @findex __builtin_offsetof
10496 GCC implements for both C and C++ a syntactic extension to implement
10497 the @code{offsetof} macro.
10499 @smallexample
10500 primary:
10501         "__builtin_offsetof" "(" @code{typename} "," offsetof_member_designator ")"
10503 offsetof_member_designator:
10504           @code{identifier}
10505         | offsetof_member_designator "." @code{identifier}
10506         | offsetof_member_designator "[" @code{expr} "]"
10507 @end smallexample
10509 This extension is sufficient such that
10511 @smallexample
10512 #define offsetof(@var{type}, @var{member})  __builtin_offsetof (@var{type}, @var{member})
10513 @end smallexample
10515 @noindent
10516 is a suitable definition of the @code{offsetof} macro.  In C++, @var{type}
10517 may be dependent.  In either case, @var{member} may consist of a single
10518 identifier, or a sequence of member accesses and array references.
10520 @node __sync Builtins
10521 @section Legacy @code{__sync} Built-in Functions for Atomic Memory Access
10523 The following built-in functions
10524 are intended to be compatible with those described
10525 in the @cite{Intel Itanium Processor-specific Application Binary Interface},
10526 section 7.4.  As such, they depart from normal GCC practice by not using
10527 the @samp{__builtin_} prefix and also by being overloaded so that they
10528 work on multiple types.
10530 The definition given in the Intel documentation allows only for the use of
10531 the types @code{int}, @code{long}, @code{long long} or their unsigned
10532 counterparts.  GCC allows any scalar type that is 1, 2, 4 or 8 bytes in
10533 size other than the C type @code{_Bool} or the C++ type @code{bool}.
10534 Operations on pointer arguments are performed as if the operands were
10535 of the @code{uintptr_t} type.  That is, they are not scaled by the size
10536 of the type to which the pointer points.
10538 These functions are implemented in terms of the @samp{__atomic}
10539 builtins (@pxref{__atomic Builtins}).  They should not be used for new
10540 code which should use the @samp{__atomic} builtins instead.
10542 Not all operations are supported by all target processors.  If a particular
10543 operation cannot be implemented on the target processor, a warning is
10544 generated and a call to an external function is generated.  The external
10545 function carries the same name as the built-in version,
10546 with an additional suffix
10547 @samp{_@var{n}} where @var{n} is the size of the data type.
10549 @c ??? Should we have a mechanism to suppress this warning?  This is almost
10550 @c useful for implementing the operation under the control of an external
10551 @c mutex.
10553 In most cases, these built-in functions are considered a @dfn{full barrier}.
10554 That is,
10555 no memory operand is moved across the operation, either forward or
10556 backward.  Further, instructions are issued as necessary to prevent the
10557 processor from speculating loads across the operation and from queuing stores
10558 after the operation.
10560 All of the routines are described in the Intel documentation to take
10561 ``an optional list of variables protected by the memory barrier''.  It's
10562 not clear what is meant by that; it could mean that @emph{only} the
10563 listed variables are protected, or it could mean a list of additional
10564 variables to be protected.  The list is ignored by GCC which treats it as
10565 empty.  GCC interprets an empty list as meaning that all globally
10566 accessible variables should be protected.
10568 @table @code
10569 @item @var{type} __sync_fetch_and_add (@var{type} *ptr, @var{type} value, ...)
10570 @itemx @var{type} __sync_fetch_and_sub (@var{type} *ptr, @var{type} value, ...)
10571 @itemx @var{type} __sync_fetch_and_or (@var{type} *ptr, @var{type} value, ...)
10572 @itemx @var{type} __sync_fetch_and_and (@var{type} *ptr, @var{type} value, ...)
10573 @itemx @var{type} __sync_fetch_and_xor (@var{type} *ptr, @var{type} value, ...)
10574 @itemx @var{type} __sync_fetch_and_nand (@var{type} *ptr, @var{type} value, ...)
10575 @findex __sync_fetch_and_add
10576 @findex __sync_fetch_and_sub
10577 @findex __sync_fetch_and_or
10578 @findex __sync_fetch_and_and
10579 @findex __sync_fetch_and_xor
10580 @findex __sync_fetch_and_nand
10581 These built-in functions perform the operation suggested by the name, and
10582 returns the value that had previously been in memory.  That is, operations
10583 on integer operands have the following semantics.  Operations on pointer
10584 arguments are performed as if the operands were of the @code{uintptr_t}
10585 type.  That is, they are not scaled by the size of the type to which
10586 the pointer points.
10588 @smallexample
10589 @{ tmp = *ptr; *ptr @var{op}= value; return tmp; @}
10590 @{ tmp = *ptr; *ptr = ~(tmp & value); return tmp; @}   // nand
10591 @end smallexample
10593 The object pointed to by the first argument must be of integer or pointer
10594 type.  It must not be a boolean type.
10596 @emph{Note:} GCC 4.4 and later implement @code{__sync_fetch_and_nand}
10597 as @code{*ptr = ~(tmp & value)} instead of @code{*ptr = ~tmp & value}.
10599 @item @var{type} __sync_add_and_fetch (@var{type} *ptr, @var{type} value, ...)
10600 @itemx @var{type} __sync_sub_and_fetch (@var{type} *ptr, @var{type} value, ...)
10601 @itemx @var{type} __sync_or_and_fetch (@var{type} *ptr, @var{type} value, ...)
10602 @itemx @var{type} __sync_and_and_fetch (@var{type} *ptr, @var{type} value, ...)
10603 @itemx @var{type} __sync_xor_and_fetch (@var{type} *ptr, @var{type} value, ...)
10604 @itemx @var{type} __sync_nand_and_fetch (@var{type} *ptr, @var{type} value, ...)
10605 @findex __sync_add_and_fetch
10606 @findex __sync_sub_and_fetch
10607 @findex __sync_or_and_fetch
10608 @findex __sync_and_and_fetch
10609 @findex __sync_xor_and_fetch
10610 @findex __sync_nand_and_fetch
10611 These built-in functions perform the operation suggested by the name, and
10612 return the new value.  That is, operations on integer operands have
10613 the following semantics.  Operations on pointer operands are performed as
10614 if the operand's type were @code{uintptr_t}.
10616 @smallexample
10617 @{ *ptr @var{op}= value; return *ptr; @}
10618 @{ *ptr = ~(*ptr & value); return *ptr; @}   // nand
10619 @end smallexample
10621 The same constraints on arguments apply as for the corresponding
10622 @code{__sync_op_and_fetch} built-in functions.
10624 @emph{Note:} GCC 4.4 and later implement @code{__sync_nand_and_fetch}
10625 as @code{*ptr = ~(*ptr & value)} instead of
10626 @code{*ptr = ~*ptr & value}.
10628 @item bool __sync_bool_compare_and_swap (@var{type} *ptr, @var{type} oldval, @var{type} newval, ...)
10629 @itemx @var{type} __sync_val_compare_and_swap (@var{type} *ptr, @var{type} oldval, @var{type} newval, ...)
10630 @findex __sync_bool_compare_and_swap
10631 @findex __sync_val_compare_and_swap
10632 These built-in functions perform an atomic compare and swap.
10633 That is, if the current
10634 value of @code{*@var{ptr}} is @var{oldval}, then write @var{newval} into
10635 @code{*@var{ptr}}.
10637 The ``bool'' version returns @code{true} if the comparison is successful and
10638 @var{newval} is written.  The ``val'' version returns the contents
10639 of @code{*@var{ptr}} before the operation.
10641 @item __sync_synchronize (...)
10642 @findex __sync_synchronize
10643 This built-in function issues a full memory barrier.
10645 @item @var{type} __sync_lock_test_and_set (@var{type} *ptr, @var{type} value, ...)
10646 @findex __sync_lock_test_and_set
10647 This built-in function, as described by Intel, is not a traditional test-and-set
10648 operation, but rather an atomic exchange operation.  It writes @var{value}
10649 into @code{*@var{ptr}}, and returns the previous contents of
10650 @code{*@var{ptr}}.
10652 Many targets have only minimal support for such locks, and do not support
10653 a full exchange operation.  In this case, a target may support reduced
10654 functionality here by which the @emph{only} valid value to store is the
10655 immediate constant 1.  The exact value actually stored in @code{*@var{ptr}}
10656 is implementation defined.
10658 This built-in function is not a full barrier,
10659 but rather an @dfn{acquire barrier}.
10660 This means that references after the operation cannot move to (or be
10661 speculated to) before the operation, but previous memory stores may not
10662 be globally visible yet, and previous memory loads may not yet be
10663 satisfied.
10665 @item void __sync_lock_release (@var{type} *ptr, ...)
10666 @findex __sync_lock_release
10667 This built-in function releases the lock acquired by
10668 @code{__sync_lock_test_and_set}.
10669 Normally this means writing the constant 0 to @code{*@var{ptr}}.
10671 This built-in function is not a full barrier,
10672 but rather a @dfn{release barrier}.
10673 This means that all previous memory stores are globally visible, and all
10674 previous memory loads have been satisfied, but following memory reads
10675 are not prevented from being speculated to before the barrier.
10676 @end table
10678 @node __atomic Builtins
10679 @section Built-in Functions for Memory Model Aware Atomic Operations
10681 The following built-in functions approximately match the requirements
10682 for the C++11 memory model.  They are all
10683 identified by being prefixed with @samp{__atomic} and most are
10684 overloaded so that they work with multiple types.
10686 These functions are intended to replace the legacy @samp{__sync}
10687 builtins.  The main difference is that the memory order that is requested
10688 is a parameter to the functions.  New code should always use the
10689 @samp{__atomic} builtins rather than the @samp{__sync} builtins.
10691 Note that the @samp{__atomic} builtins assume that programs will
10692 conform to the C++11 memory model.  In particular, they assume
10693 that programs are free of data races.  See the C++11 standard for
10694 detailed requirements.
10696 The @samp{__atomic} builtins can be used with any integral scalar or
10697 pointer type that is 1, 2, 4, or 8 bytes in length.  16-byte integral
10698 types are also allowed if @samp{__int128} (@pxref{__int128}) is
10699 supported by the architecture.
10701 The four non-arithmetic functions (load, store, exchange, and 
10702 compare_exchange) all have a generic version as well.  This generic
10703 version works on any data type.  It uses the lock-free built-in function
10704 if the specific data type size makes that possible; otherwise, an
10705 external call is left to be resolved at run time.  This external call is
10706 the same format with the addition of a @samp{size_t} parameter inserted
10707 as the first parameter indicating the size of the object being pointed to.
10708 All objects must be the same size.
10710 There are 6 different memory orders that can be specified.  These map
10711 to the C++11 memory orders with the same names, see the C++11 standard
10712 or the @uref{http://gcc.gnu.org/wiki/Atomic/GCCMM/AtomicSync,GCC wiki
10713 on atomic synchronization} for detailed definitions.  Individual
10714 targets may also support additional memory orders for use on specific
10715 architectures.  Refer to the target documentation for details of
10716 these.
10718 An atomic operation can both constrain code motion and
10719 be mapped to hardware instructions for synchronization between threads
10720 (e.g., a fence).  To which extent this happens is controlled by the
10721 memory orders, which are listed here in approximately ascending order of
10722 strength.  The description of each memory order is only meant to roughly
10723 illustrate the effects and is not a specification; see the C++11
10724 memory model for precise semantics.
10726 @table  @code
10727 @item __ATOMIC_RELAXED
10728 Implies no inter-thread ordering constraints.
10729 @item __ATOMIC_CONSUME
10730 This is currently implemented using the stronger @code{__ATOMIC_ACQUIRE}
10731 memory order because of a deficiency in C++11's semantics for
10732 @code{memory_order_consume}.
10733 @item __ATOMIC_ACQUIRE
10734 Creates an inter-thread happens-before constraint from the release (or
10735 stronger) semantic store to this acquire load.  Can prevent hoisting
10736 of code to before the operation.
10737 @item __ATOMIC_RELEASE
10738 Creates an inter-thread happens-before constraint to acquire (or stronger)
10739 semantic loads that read from this release store.  Can prevent sinking
10740 of code to after the operation.
10741 @item __ATOMIC_ACQ_REL
10742 Combines the effects of both @code{__ATOMIC_ACQUIRE} and
10743 @code{__ATOMIC_RELEASE}.
10744 @item __ATOMIC_SEQ_CST
10745 Enforces total ordering with all other @code{__ATOMIC_SEQ_CST} operations.
10746 @end table
10748 Note that in the C++11 memory model, @emph{fences} (e.g.,
10749 @samp{__atomic_thread_fence}) take effect in combination with other
10750 atomic operations on specific memory locations (e.g., atomic loads);
10751 operations on specific memory locations do not necessarily affect other
10752 operations in the same way.
10754 Target architectures are encouraged to provide their own patterns for
10755 each of the atomic built-in functions.  If no target is provided, the original
10756 non-memory model set of @samp{__sync} atomic built-in functions are
10757 used, along with any required synchronization fences surrounding it in
10758 order to achieve the proper behavior.  Execution in this case is subject
10759 to the same restrictions as those built-in functions.
10761 If there is no pattern or mechanism to provide a lock-free instruction
10762 sequence, a call is made to an external routine with the same parameters
10763 to be resolved at run time.
10765 When implementing patterns for these built-in functions, the memory order
10766 parameter can be ignored as long as the pattern implements the most
10767 restrictive @code{__ATOMIC_SEQ_CST} memory order.  Any of the other memory
10768 orders execute correctly with this memory order but they may not execute as
10769 efficiently as they could with a more appropriate implementation of the
10770 relaxed requirements.
10772 Note that the C++11 standard allows for the memory order parameter to be
10773 determined at run time rather than at compile time.  These built-in
10774 functions map any run-time value to @code{__ATOMIC_SEQ_CST} rather
10775 than invoke a runtime library call or inline a switch statement.  This is
10776 standard compliant, safe, and the simplest approach for now.
10778 The memory order parameter is a signed int, but only the lower 16 bits are
10779 reserved for the memory order.  The remainder of the signed int is reserved
10780 for target use and should be 0.  Use of the predefined atomic values
10781 ensures proper usage.
10783 @deftypefn {Built-in Function} @var{type} __atomic_load_n (@var{type} *ptr, int memorder)
10784 This built-in function implements an atomic load operation.  It returns the
10785 contents of @code{*@var{ptr}}.
10787 The valid memory order variants are
10788 @code{__ATOMIC_RELAXED}, @code{__ATOMIC_SEQ_CST}, @code{__ATOMIC_ACQUIRE},
10789 and @code{__ATOMIC_CONSUME}.
10791 @end deftypefn
10793 @deftypefn {Built-in Function} void __atomic_load (@var{type} *ptr, @var{type} *ret, int memorder)
10794 This is the generic version of an atomic load.  It returns the
10795 contents of @code{*@var{ptr}} in @code{*@var{ret}}.
10797 @end deftypefn
10799 @deftypefn {Built-in Function} void __atomic_store_n (@var{type} *ptr, @var{type} val, int memorder)
10800 This built-in function implements an atomic store operation.  It writes 
10801 @code{@var{val}} into @code{*@var{ptr}}.  
10803 The valid memory order variants are
10804 @code{__ATOMIC_RELAXED}, @code{__ATOMIC_SEQ_CST}, and @code{__ATOMIC_RELEASE}.
10806 @end deftypefn
10808 @deftypefn {Built-in Function} void __atomic_store (@var{type} *ptr, @var{type} *val, int memorder)
10809 This is the generic version of an atomic store.  It stores the value
10810 of @code{*@var{val}} into @code{*@var{ptr}}.
10812 @end deftypefn
10814 @deftypefn {Built-in Function} @var{type} __atomic_exchange_n (@var{type} *ptr, @var{type} val, int memorder)
10815 This built-in function implements an atomic exchange operation.  It writes
10816 @var{val} into @code{*@var{ptr}}, and returns the previous contents of
10817 @code{*@var{ptr}}.
10819 The valid memory order variants are
10820 @code{__ATOMIC_RELAXED}, @code{__ATOMIC_SEQ_CST}, @code{__ATOMIC_ACQUIRE},
10821 @code{__ATOMIC_RELEASE}, and @code{__ATOMIC_ACQ_REL}.
10823 @end deftypefn
10825 @deftypefn {Built-in Function} void __atomic_exchange (@var{type} *ptr, @var{type} *val, @var{type} *ret, int memorder)
10826 This is the generic version of an atomic exchange.  It stores the
10827 contents of @code{*@var{val}} into @code{*@var{ptr}}. The original value
10828 of @code{*@var{ptr}} is copied into @code{*@var{ret}}.
10830 @end deftypefn
10832 @deftypefn {Built-in Function} bool __atomic_compare_exchange_n (@var{type} *ptr, @var{type} *expected, @var{type} desired, bool weak, int success_memorder, int failure_memorder)
10833 This built-in function implements an atomic compare and exchange operation.
10834 This compares the contents of @code{*@var{ptr}} with the contents of
10835 @code{*@var{expected}}. If equal, the operation is a @emph{read-modify-write}
10836 operation that writes @var{desired} into @code{*@var{ptr}}.  If they are not
10837 equal, the operation is a @emph{read} and the current contents of
10838 @code{*@var{ptr}} are written into @code{*@var{expected}}.  @var{weak} is @code{true}
10839 for weak compare_exchange, which may fail spuriously, and @code{false} for
10840 the strong variation, which never fails spuriously.  Many targets
10841 only offer the strong variation and ignore the parameter.  When in doubt, use
10842 the strong variation.
10844 If @var{desired} is written into @code{*@var{ptr}} then @code{true} is returned
10845 and memory is affected according to the
10846 memory order specified by @var{success_memorder}.  There are no
10847 restrictions on what memory order can be used here.
10849 Otherwise, @code{false} is returned and memory is affected according
10850 to @var{failure_memorder}. This memory order cannot be
10851 @code{__ATOMIC_RELEASE} nor @code{__ATOMIC_ACQ_REL}.  It also cannot be a
10852 stronger order than that specified by @var{success_memorder}.
10854 @end deftypefn
10856 @deftypefn {Built-in Function} bool __atomic_compare_exchange (@var{type} *ptr, @var{type} *expected, @var{type} *desired, bool weak, int success_memorder, int failure_memorder)
10857 This built-in function implements the generic version of
10858 @code{__atomic_compare_exchange}.  The function is virtually identical to
10859 @code{__atomic_compare_exchange_n}, except the desired value is also a
10860 pointer.
10862 @end deftypefn
10864 @deftypefn {Built-in Function} @var{type} __atomic_add_fetch (@var{type} *ptr, @var{type} val, int memorder)
10865 @deftypefnx {Built-in Function} @var{type} __atomic_sub_fetch (@var{type} *ptr, @var{type} val, int memorder)
10866 @deftypefnx {Built-in Function} @var{type} __atomic_and_fetch (@var{type} *ptr, @var{type} val, int memorder)
10867 @deftypefnx {Built-in Function} @var{type} __atomic_xor_fetch (@var{type} *ptr, @var{type} val, int memorder)
10868 @deftypefnx {Built-in Function} @var{type} __atomic_or_fetch (@var{type} *ptr, @var{type} val, int memorder)
10869 @deftypefnx {Built-in Function} @var{type} __atomic_nand_fetch (@var{type} *ptr, @var{type} val, int memorder)
10870 These built-in functions perform the operation suggested by the name, and
10871 return the result of the operation.  Operations on pointer arguments are
10872 performed as if the operands were of the @code{uintptr_t} type.  That is,
10873 they are not scaled by the size of the type to which the pointer points.
10875 @smallexample
10876 @{ *ptr @var{op}= val; return *ptr; @}
10877 @end smallexample
10879 The object pointed to by the first argument must be of integer or pointer
10880 type.  It must not be a boolean type.  All memory orders are valid.
10882 @end deftypefn
10884 @deftypefn {Built-in Function} @var{type} __atomic_fetch_add (@var{type} *ptr, @var{type} val, int memorder)
10885 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_sub (@var{type} *ptr, @var{type} val, int memorder)
10886 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_and (@var{type} *ptr, @var{type} val, int memorder)
10887 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_xor (@var{type} *ptr, @var{type} val, int memorder)
10888 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_or (@var{type} *ptr, @var{type} val, int memorder)
10889 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_nand (@var{type} *ptr, @var{type} val, int memorder)
10890 These built-in functions perform the operation suggested by the name, and
10891 return the value that had previously been in @code{*@var{ptr}}.  Operations
10892 on pointer arguments are performed as if the operands were of
10893 the @code{uintptr_t} type.  That is, they are not scaled by the size of
10894 the type to which the pointer points.
10896 @smallexample
10897 @{ tmp = *ptr; *ptr @var{op}= val; return tmp; @}
10898 @end smallexample
10900 The same constraints on arguments apply as for the corresponding
10901 @code{__atomic_op_fetch} built-in functions.  All memory orders are valid.
10903 @end deftypefn
10905 @deftypefn {Built-in Function} bool __atomic_test_and_set (void *ptr, int memorder)
10907 This built-in function performs an atomic test-and-set operation on
10908 the byte at @code{*@var{ptr}}.  The byte is set to some implementation
10909 defined nonzero ``set'' value and the return value is @code{true} if and only
10910 if the previous contents were ``set''.
10911 It should be only used for operands of type @code{bool} or @code{char}. For 
10912 other types only part of the value may be set.
10914 All memory orders are valid.
10916 @end deftypefn
10918 @deftypefn {Built-in Function} void __atomic_clear (bool *ptr, int memorder)
10920 This built-in function performs an atomic clear operation on
10921 @code{*@var{ptr}}.  After the operation, @code{*@var{ptr}} contains 0.
10922 It should be only used for operands of type @code{bool} or @code{char} and 
10923 in conjunction with @code{__atomic_test_and_set}.
10924 For other types it may only clear partially. If the type is not @code{bool}
10925 prefer using @code{__atomic_store}.
10927 The valid memory order variants are
10928 @code{__ATOMIC_RELAXED}, @code{__ATOMIC_SEQ_CST}, and
10929 @code{__ATOMIC_RELEASE}.
10931 @end deftypefn
10933 @deftypefn {Built-in Function} void __atomic_thread_fence (int memorder)
10935 This built-in function acts as a synchronization fence between threads
10936 based on the specified memory order.
10938 All memory orders are valid.
10940 @end deftypefn
10942 @deftypefn {Built-in Function} void __atomic_signal_fence (int memorder)
10944 This built-in function acts as a synchronization fence between a thread
10945 and signal handlers based in the same thread.
10947 All memory orders are valid.
10949 @end deftypefn
10951 @deftypefn {Built-in Function} bool __atomic_always_lock_free (size_t size,  void *ptr)
10953 This built-in function returns @code{true} if objects of @var{size} bytes always
10954 generate lock-free atomic instructions for the target architecture.
10955 @var{size} must resolve to a compile-time constant and the result also
10956 resolves to a compile-time constant.
10958 @var{ptr} is an optional pointer to the object that may be used to determine
10959 alignment.  A value of 0 indicates typical alignment should be used.  The 
10960 compiler may also ignore this parameter.
10962 @smallexample
10963 if (__atomic_always_lock_free (sizeof (long long), 0))
10964 @end smallexample
10966 @end deftypefn
10968 @deftypefn {Built-in Function} bool __atomic_is_lock_free (size_t size, void *ptr)
10970 This built-in function returns @code{true} if objects of @var{size} bytes always
10971 generate lock-free atomic instructions for the target architecture.  If
10972 the built-in function is not known to be lock-free, a call is made to a
10973 runtime routine named @code{__atomic_is_lock_free}.
10975 @var{ptr} is an optional pointer to the object that may be used to determine
10976 alignment.  A value of 0 indicates typical alignment should be used.  The 
10977 compiler may also ignore this parameter.
10978 @end deftypefn
10980 @node Integer Overflow Builtins
10981 @section Built-in Functions to Perform Arithmetic with Overflow Checking
10983 The following built-in functions allow performing simple arithmetic operations
10984 together with checking whether the operations overflowed.
10986 @deftypefn {Built-in Function} bool __builtin_add_overflow (@var{type1} a, @var{type2} b, @var{type3} *res)
10987 @deftypefnx {Built-in Function} bool __builtin_sadd_overflow (int a, int b, int *res)
10988 @deftypefnx {Built-in Function} bool __builtin_saddl_overflow (long int a, long int b, long int *res)
10989 @deftypefnx {Built-in Function} bool __builtin_saddll_overflow (long long int a, long long int b, long long int *res)
10990 @deftypefnx {Built-in Function} bool __builtin_uadd_overflow (unsigned int a, unsigned int b, unsigned int *res)
10991 @deftypefnx {Built-in Function} bool __builtin_uaddl_overflow (unsigned long int a, unsigned long int b, unsigned long int *res)
10992 @deftypefnx {Built-in Function} bool __builtin_uaddll_overflow (unsigned long long int a, unsigned long long int b, unsigned long long int *res)
10994 These built-in functions promote the first two operands into infinite precision signed
10995 type and perform addition on those promoted operands.  The result is then
10996 cast to the type the third pointer argument points to and stored there.
10997 If the stored result is equal to the infinite precision result, the built-in
10998 functions return @code{false}, otherwise they return @code{true}.  As the addition is
10999 performed in infinite signed precision, these built-in functions have fully defined
11000 behavior for all argument values.
11002 The first built-in function allows arbitrary integral types for operands and
11003 the result type must be pointer to some integral type other than enumerated or
11004 boolean type, the rest of the built-in functions have explicit integer types.
11006 The compiler will attempt to use hardware instructions to implement
11007 these built-in functions where possible, like conditional jump on overflow
11008 after addition, conditional jump on carry etc.
11010 @end deftypefn
11012 @deftypefn {Built-in Function} bool __builtin_sub_overflow (@var{type1} a, @var{type2} b, @var{type3} *res)
11013 @deftypefnx {Built-in Function} bool __builtin_ssub_overflow (int a, int b, int *res)
11014 @deftypefnx {Built-in Function} bool __builtin_ssubl_overflow (long int a, long int b, long int *res)
11015 @deftypefnx {Built-in Function} bool __builtin_ssubll_overflow (long long int a, long long int b, long long int *res)
11016 @deftypefnx {Built-in Function} bool __builtin_usub_overflow (unsigned int a, unsigned int b, unsigned int *res)
11017 @deftypefnx {Built-in Function} bool __builtin_usubl_overflow (unsigned long int a, unsigned long int b, unsigned long int *res)
11018 @deftypefnx {Built-in Function} bool __builtin_usubll_overflow (unsigned long long int a, unsigned long long int b, unsigned long long int *res)
11020 These built-in functions are similar to the add overflow checking built-in
11021 functions above, except they perform subtraction, subtract the second argument
11022 from the first one, instead of addition.
11024 @end deftypefn
11026 @deftypefn {Built-in Function} bool __builtin_mul_overflow (@var{type1} a, @var{type2} b, @var{type3} *res)
11027 @deftypefnx {Built-in Function} bool __builtin_smul_overflow (int a, int b, int *res)
11028 @deftypefnx {Built-in Function} bool __builtin_smull_overflow (long int a, long int b, long int *res)
11029 @deftypefnx {Built-in Function} bool __builtin_smulll_overflow (long long int a, long long int b, long long int *res)
11030 @deftypefnx {Built-in Function} bool __builtin_umul_overflow (unsigned int a, unsigned int b, unsigned int *res)
11031 @deftypefnx {Built-in Function} bool __builtin_umull_overflow (unsigned long int a, unsigned long int b, unsigned long int *res)
11032 @deftypefnx {Built-in Function} bool __builtin_umulll_overflow (unsigned long long int a, unsigned long long int b, unsigned long long int *res)
11034 These built-in functions are similar to the add overflow checking built-in
11035 functions above, except they perform multiplication, instead of addition.
11037 @end deftypefn
11039 The following built-in functions allow checking if simple arithmetic operation
11040 would overflow.
11042 @deftypefn {Built-in Function} bool __builtin_add_overflow_p (@var{type1} a, @var{type2} b, @var{type3} c)
11043 @deftypefnx {Built-in Function} bool __builtin_sub_overflow_p (@var{type1} a, @var{type2} b, @var{type3} c)
11044 @deftypefnx {Built-in Function} bool __builtin_mul_overflow_p (@var{type1} a, @var{type2} b, @var{type3} c)
11046 These built-in functions are similar to @code{__builtin_add_overflow},
11047 @code{__builtin_sub_overflow}, or @code{__builtin_mul_overflow}, except that
11048 they don't store the result of the arithmetic operation anywhere and the
11049 last argument is not a pointer, but some expression with integral type other
11050 than enumerated or boolean type.
11052 The built-in functions promote the first two operands into infinite precision signed type
11053 and perform addition on those promoted operands. The result is then
11054 cast to the type of the third argument.  If the cast result is equal to the infinite
11055 precision result, the built-in functions return @code{false}, otherwise they return @code{true}.
11056 The value of the third argument is ignored, just the side effects in the third argument
11057 are evaluated, and no integral argument promotions are performed on the last argument.
11058 If the third argument is a bit-field, the type used for the result cast has the
11059 precision and signedness of the given bit-field, rather than precision and signedness
11060 of the underlying type.
11062 For example, the following macro can be used to portably check, at
11063 compile-time, whether or not adding two constant integers will overflow,
11064 and perform the addition only when it is known to be safe and not to trigger
11065 a @option{-Woverflow} warning.
11067 @smallexample
11068 #define INT_ADD_OVERFLOW_P(a, b) \
11069    __builtin_add_overflow_p (a, b, (__typeof__ ((a) + (b))) 0)
11071 enum @{
11072     A = INT_MAX, B = 3,
11073     C = INT_ADD_OVERFLOW_P (A, B) ? 0 : A + B,
11074     D = __builtin_add_overflow_p (1, SCHAR_MAX, (signed char) 0)
11076 @end smallexample
11078 The compiler will attempt to use hardware instructions to implement
11079 these built-in functions where possible, like conditional jump on overflow
11080 after addition, conditional jump on carry etc.
11082 @end deftypefn
11084 @node x86 specific memory model extensions for transactional memory
11085 @section x86-Specific Memory Model Extensions for Transactional Memory
11087 The x86 architecture supports additional memory ordering flags
11088 to mark critical sections for hardware lock elision. 
11089 These must be specified in addition to an existing memory order to
11090 atomic intrinsics.
11092 @table @code
11093 @item __ATOMIC_HLE_ACQUIRE
11094 Start lock elision on a lock variable.
11095 Memory order must be @code{__ATOMIC_ACQUIRE} or stronger.
11096 @item __ATOMIC_HLE_RELEASE
11097 End lock elision on a lock variable.
11098 Memory order must be @code{__ATOMIC_RELEASE} or stronger.
11099 @end table
11101 When a lock acquire fails, it is required for good performance to abort
11102 the transaction quickly. This can be done with a @code{_mm_pause}.
11104 @smallexample
11105 #include <immintrin.h> // For _mm_pause
11107 int lockvar;
11109 /* Acquire lock with lock elision */
11110 while (__atomic_exchange_n(&lockvar, 1, __ATOMIC_ACQUIRE|__ATOMIC_HLE_ACQUIRE))
11111     _mm_pause(); /* Abort failed transaction */
11113 /* Free lock with lock elision */
11114 __atomic_store_n(&lockvar, 0, __ATOMIC_RELEASE|__ATOMIC_HLE_RELEASE);
11115 @end smallexample
11117 @node Object Size Checking
11118 @section Object Size Checking Built-in Functions
11119 @findex __builtin_object_size
11120 @findex __builtin___memcpy_chk
11121 @findex __builtin___mempcpy_chk
11122 @findex __builtin___memmove_chk
11123 @findex __builtin___memset_chk
11124 @findex __builtin___strcpy_chk
11125 @findex __builtin___stpcpy_chk
11126 @findex __builtin___strncpy_chk
11127 @findex __builtin___strcat_chk
11128 @findex __builtin___strncat_chk
11129 @findex __builtin___sprintf_chk
11130 @findex __builtin___snprintf_chk
11131 @findex __builtin___vsprintf_chk
11132 @findex __builtin___vsnprintf_chk
11133 @findex __builtin___printf_chk
11134 @findex __builtin___vprintf_chk
11135 @findex __builtin___fprintf_chk
11136 @findex __builtin___vfprintf_chk
11138 GCC implements a limited buffer overflow protection mechanism that can
11139 prevent some buffer overflow attacks by determining the sizes of objects
11140 into which data is about to be written and preventing the writes when
11141 the size isn't sufficient.  The built-in functions described below yield
11142 the best results when used together and when optimization is enabled.
11143 For example, to detect object sizes across function boundaries or to
11144 follow pointer assignments through non-trivial control flow they rely
11145 on various optimization passes enabled with @option{-O2}.  However, to
11146 a limited extent, they can be used without optimization as well.
11148 @deftypefn {Built-in Function} {size_t} __builtin_object_size (const void * @var{ptr}, int @var{type})
11149 is a built-in construct that returns a constant number of bytes from
11150 @var{ptr} to the end of the object @var{ptr} pointer points to
11151 (if known at compile time).  @code{__builtin_object_size} never evaluates
11152 its arguments for side effects.  If there are any side effects in them, it
11153 returns @code{(size_t) -1} for @var{type} 0 or 1 and @code{(size_t) 0}
11154 for @var{type} 2 or 3.  If there are multiple objects @var{ptr} can
11155 point to and all of them are known at compile time, the returned number
11156 is the maximum of remaining byte counts in those objects if @var{type} & 2 is
11157 0 and minimum if nonzero.  If it is not possible to determine which objects
11158 @var{ptr} points to at compile time, @code{__builtin_object_size} should
11159 return @code{(size_t) -1} for @var{type} 0 or 1 and @code{(size_t) 0}
11160 for @var{type} 2 or 3.
11162 @var{type} is an integer constant from 0 to 3.  If the least significant
11163 bit is clear, objects are whole variables, if it is set, a closest
11164 surrounding subobject is considered the object a pointer points to.
11165 The second bit determines if maximum or minimum of remaining bytes
11166 is computed.
11168 @smallexample
11169 struct V @{ char buf1[10]; int b; char buf2[10]; @} var;
11170 char *p = &var.buf1[1], *q = &var.b;
11172 /* Here the object p points to is var.  */
11173 assert (__builtin_object_size (p, 0) == sizeof (var) - 1);
11174 /* The subobject p points to is var.buf1.  */
11175 assert (__builtin_object_size (p, 1) == sizeof (var.buf1) - 1);
11176 /* The object q points to is var.  */
11177 assert (__builtin_object_size (q, 0)
11178         == (char *) (&var + 1) - (char *) &var.b);
11179 /* The subobject q points to is var.b.  */
11180 assert (__builtin_object_size (q, 1) == sizeof (var.b));
11181 @end smallexample
11182 @end deftypefn
11184 There are built-in functions added for many common string operation
11185 functions, e.g., for @code{memcpy} @code{__builtin___memcpy_chk}
11186 built-in is provided.  This built-in has an additional last argument,
11187 which is the number of bytes remaining in the object the @var{dest}
11188 argument points to or @code{(size_t) -1} if the size is not known.
11190 The built-in functions are optimized into the normal string functions
11191 like @code{memcpy} if the last argument is @code{(size_t) -1} or if
11192 it is known at compile time that the destination object will not
11193 be overflowed.  If the compiler can determine at compile time that the
11194 object will always be overflowed, it issues a warning.
11196 The intended use can be e.g.@:
11198 @smallexample
11199 #undef memcpy
11200 #define bos0(dest) __builtin_object_size (dest, 0)
11201 #define memcpy(dest, src, n) \
11202   __builtin___memcpy_chk (dest, src, n, bos0 (dest))
11204 char *volatile p;
11205 char buf[10];
11206 /* It is unknown what object p points to, so this is optimized
11207    into plain memcpy - no checking is possible.  */
11208 memcpy (p, "abcde", n);
11209 /* Destination is known and length too.  It is known at compile
11210    time there will be no overflow.  */
11211 memcpy (&buf[5], "abcde", 5);
11212 /* Destination is known, but the length is not known at compile time.
11213    This will result in __memcpy_chk call that can check for overflow
11214    at run time.  */
11215 memcpy (&buf[5], "abcde", n);
11216 /* Destination is known and it is known at compile time there will
11217    be overflow.  There will be a warning and __memcpy_chk call that
11218    will abort the program at run time.  */
11219 memcpy (&buf[6], "abcde", 5);
11220 @end smallexample
11222 Such built-in functions are provided for @code{memcpy}, @code{mempcpy},
11223 @code{memmove}, @code{memset}, @code{strcpy}, @code{stpcpy}, @code{strncpy},
11224 @code{strcat} and @code{strncat}.
11226 There are also checking built-in functions for formatted output functions.
11227 @smallexample
11228 int __builtin___sprintf_chk (char *s, int flag, size_t os, const char *fmt, ...);
11229 int __builtin___snprintf_chk (char *s, size_t maxlen, int flag, size_t os,
11230                               const char *fmt, ...);
11231 int __builtin___vsprintf_chk (char *s, int flag, size_t os, const char *fmt,
11232                               va_list ap);
11233 int __builtin___vsnprintf_chk (char *s, size_t maxlen, int flag, size_t os,
11234                                const char *fmt, va_list ap);
11235 @end smallexample
11237 The added @var{flag} argument is passed unchanged to @code{__sprintf_chk}
11238 etc.@: functions and can contain implementation specific flags on what
11239 additional security measures the checking function might take, such as
11240 handling @code{%n} differently.
11242 The @var{os} argument is the object size @var{s} points to, like in the
11243 other built-in functions.  There is a small difference in the behavior
11244 though, if @var{os} is @code{(size_t) -1}, the built-in functions are
11245 optimized into the non-checking functions only if @var{flag} is 0, otherwise
11246 the checking function is called with @var{os} argument set to
11247 @code{(size_t) -1}.
11249 In addition to this, there are checking built-in functions
11250 @code{__builtin___printf_chk}, @code{__builtin___vprintf_chk},
11251 @code{__builtin___fprintf_chk} and @code{__builtin___vfprintf_chk}.
11252 These have just one additional argument, @var{flag}, right before
11253 format string @var{fmt}.  If the compiler is able to optimize them to
11254 @code{fputc} etc.@: functions, it does, otherwise the checking function
11255 is called and the @var{flag} argument passed to it.
11257 @node Other Builtins
11258 @section Other Built-in Functions Provided by GCC
11259 @cindex built-in functions
11260 @findex __builtin_alloca
11261 @findex __builtin_alloca_with_align
11262 @findex __builtin_alloca_with_align_and_max
11263 @findex __builtin_call_with_static_chain
11264 @findex __builtin_extend_pointer
11265 @findex __builtin_fpclassify
11266 @findex __builtin_has_attribute
11267 @findex __builtin_isfinite
11268 @findex __builtin_isnormal
11269 @findex __builtin_isgreater
11270 @findex __builtin_isgreaterequal
11271 @findex __builtin_isinf_sign
11272 @findex __builtin_isless
11273 @findex __builtin_islessequal
11274 @findex __builtin_islessgreater
11275 @findex __builtin_isunordered
11276 @findex __builtin_powi
11277 @findex __builtin_powif
11278 @findex __builtin_powil
11279 @findex __builtin_speculation_safe_value
11280 @findex _Exit
11281 @findex _exit
11282 @findex abort
11283 @findex abs
11284 @findex acos
11285 @findex acosf
11286 @findex acosh
11287 @findex acoshf
11288 @findex acoshl
11289 @findex acosl
11290 @findex alloca
11291 @findex asin
11292 @findex asinf
11293 @findex asinh
11294 @findex asinhf
11295 @findex asinhl
11296 @findex asinl
11297 @findex atan
11298 @findex atan2
11299 @findex atan2f
11300 @findex atan2l
11301 @findex atanf
11302 @findex atanh
11303 @findex atanhf
11304 @findex atanhl
11305 @findex atanl
11306 @findex bcmp
11307 @findex bzero
11308 @findex cabs
11309 @findex cabsf
11310 @findex cabsl
11311 @findex cacos
11312 @findex cacosf
11313 @findex cacosh
11314 @findex cacoshf
11315 @findex cacoshl
11316 @findex cacosl
11317 @findex calloc
11318 @findex carg
11319 @findex cargf
11320 @findex cargl
11321 @findex casin
11322 @findex casinf
11323 @findex casinh
11324 @findex casinhf
11325 @findex casinhl
11326 @findex casinl
11327 @findex catan
11328 @findex catanf
11329 @findex catanh
11330 @findex catanhf
11331 @findex catanhl
11332 @findex catanl
11333 @findex cbrt
11334 @findex cbrtf
11335 @findex cbrtl
11336 @findex ccos
11337 @findex ccosf
11338 @findex ccosh
11339 @findex ccoshf
11340 @findex ccoshl
11341 @findex ccosl
11342 @findex ceil
11343 @findex ceilf
11344 @findex ceill
11345 @findex cexp
11346 @findex cexpf
11347 @findex cexpl
11348 @findex cimag
11349 @findex cimagf
11350 @findex cimagl
11351 @findex clog
11352 @findex clogf
11353 @findex clogl
11354 @findex clog10
11355 @findex clog10f
11356 @findex clog10l
11357 @findex conj
11358 @findex conjf
11359 @findex conjl
11360 @findex copysign
11361 @findex copysignf
11362 @findex copysignl
11363 @findex cos
11364 @findex cosf
11365 @findex cosh
11366 @findex coshf
11367 @findex coshl
11368 @findex cosl
11369 @findex cpow
11370 @findex cpowf
11371 @findex cpowl
11372 @findex cproj
11373 @findex cprojf
11374 @findex cprojl
11375 @findex creal
11376 @findex crealf
11377 @findex creall
11378 @findex csin
11379 @findex csinf
11380 @findex csinh
11381 @findex csinhf
11382 @findex csinhl
11383 @findex csinl
11384 @findex csqrt
11385 @findex csqrtf
11386 @findex csqrtl
11387 @findex ctan
11388 @findex ctanf
11389 @findex ctanh
11390 @findex ctanhf
11391 @findex ctanhl
11392 @findex ctanl
11393 @findex dcgettext
11394 @findex dgettext
11395 @findex drem
11396 @findex dremf
11397 @findex dreml
11398 @findex erf
11399 @findex erfc
11400 @findex erfcf
11401 @findex erfcl
11402 @findex erff
11403 @findex erfl
11404 @findex exit
11405 @findex exp
11406 @findex exp10
11407 @findex exp10f
11408 @findex exp10l
11409 @findex exp2
11410 @findex exp2f
11411 @findex exp2l
11412 @findex expf
11413 @findex expl
11414 @findex expm1
11415 @findex expm1f
11416 @findex expm1l
11417 @findex fabs
11418 @findex fabsf
11419 @findex fabsl
11420 @findex fdim
11421 @findex fdimf
11422 @findex fdiml
11423 @findex ffs
11424 @findex floor
11425 @findex floorf
11426 @findex floorl
11427 @findex fma
11428 @findex fmaf
11429 @findex fmal
11430 @findex fmax
11431 @findex fmaxf
11432 @findex fmaxl
11433 @findex fmin
11434 @findex fminf
11435 @findex fminl
11436 @findex fmod
11437 @findex fmodf
11438 @findex fmodl
11439 @findex fprintf
11440 @findex fprintf_unlocked
11441 @findex fputs
11442 @findex fputs_unlocked
11443 @findex frexp
11444 @findex frexpf
11445 @findex frexpl
11446 @findex fscanf
11447 @findex gamma
11448 @findex gammaf
11449 @findex gammal
11450 @findex gamma_r
11451 @findex gammaf_r
11452 @findex gammal_r
11453 @findex gettext
11454 @findex hypot
11455 @findex hypotf
11456 @findex hypotl
11457 @findex ilogb
11458 @findex ilogbf
11459 @findex ilogbl
11460 @findex imaxabs
11461 @findex index
11462 @findex isalnum
11463 @findex isalpha
11464 @findex isascii
11465 @findex isblank
11466 @findex iscntrl
11467 @findex isdigit
11468 @findex isgraph
11469 @findex islower
11470 @findex isprint
11471 @findex ispunct
11472 @findex isspace
11473 @findex isupper
11474 @findex iswalnum
11475 @findex iswalpha
11476 @findex iswblank
11477 @findex iswcntrl
11478 @findex iswdigit
11479 @findex iswgraph
11480 @findex iswlower
11481 @findex iswprint
11482 @findex iswpunct
11483 @findex iswspace
11484 @findex iswupper
11485 @findex iswxdigit
11486 @findex isxdigit
11487 @findex j0
11488 @findex j0f
11489 @findex j0l
11490 @findex j1
11491 @findex j1f
11492 @findex j1l
11493 @findex jn
11494 @findex jnf
11495 @findex jnl
11496 @findex labs
11497 @findex ldexp
11498 @findex ldexpf
11499 @findex ldexpl
11500 @findex lgamma
11501 @findex lgammaf
11502 @findex lgammal
11503 @findex lgamma_r
11504 @findex lgammaf_r
11505 @findex lgammal_r
11506 @findex llabs
11507 @findex llrint
11508 @findex llrintf
11509 @findex llrintl
11510 @findex llround
11511 @findex llroundf
11512 @findex llroundl
11513 @findex log
11514 @findex log10
11515 @findex log10f
11516 @findex log10l
11517 @findex log1p
11518 @findex log1pf
11519 @findex log1pl
11520 @findex log2
11521 @findex log2f
11522 @findex log2l
11523 @findex logb
11524 @findex logbf
11525 @findex logbl
11526 @findex logf
11527 @findex logl
11528 @findex lrint
11529 @findex lrintf
11530 @findex lrintl
11531 @findex lround
11532 @findex lroundf
11533 @findex lroundl
11534 @findex malloc
11535 @findex memchr
11536 @findex memcmp
11537 @findex memcpy
11538 @findex mempcpy
11539 @findex memset
11540 @findex modf
11541 @findex modff
11542 @findex modfl
11543 @findex nearbyint
11544 @findex nearbyintf
11545 @findex nearbyintl
11546 @findex nextafter
11547 @findex nextafterf
11548 @findex nextafterl
11549 @findex nexttoward
11550 @findex nexttowardf
11551 @findex nexttowardl
11552 @findex pow
11553 @findex pow10
11554 @findex pow10f
11555 @findex pow10l
11556 @findex powf
11557 @findex powl
11558 @findex printf
11559 @findex printf_unlocked
11560 @findex putchar
11561 @findex puts
11562 @findex remainder
11563 @findex remainderf
11564 @findex remainderl
11565 @findex remquo
11566 @findex remquof
11567 @findex remquol
11568 @findex rindex
11569 @findex rint
11570 @findex rintf
11571 @findex rintl
11572 @findex round
11573 @findex roundf
11574 @findex roundl
11575 @findex scalb
11576 @findex scalbf
11577 @findex scalbl
11578 @findex scalbln
11579 @findex scalblnf
11580 @findex scalblnf
11581 @findex scalbn
11582 @findex scalbnf
11583 @findex scanfnl
11584 @findex signbit
11585 @findex signbitf
11586 @findex signbitl
11587 @findex signbitd32
11588 @findex signbitd64
11589 @findex signbitd128
11590 @findex significand
11591 @findex significandf
11592 @findex significandl
11593 @findex sin
11594 @findex sincos
11595 @findex sincosf
11596 @findex sincosl
11597 @findex sinf
11598 @findex sinh
11599 @findex sinhf
11600 @findex sinhl
11601 @findex sinl
11602 @findex snprintf
11603 @findex sprintf
11604 @findex sqrt
11605 @findex sqrtf
11606 @findex sqrtl
11607 @findex sscanf
11608 @findex stpcpy
11609 @findex stpncpy
11610 @findex strcasecmp
11611 @findex strcat
11612 @findex strchr
11613 @findex strcmp
11614 @findex strcpy
11615 @findex strcspn
11616 @findex strdup
11617 @findex strfmon
11618 @findex strftime
11619 @findex strlen
11620 @findex strncasecmp
11621 @findex strncat
11622 @findex strncmp
11623 @findex strncpy
11624 @findex strndup
11625 @findex strnlen
11626 @findex strpbrk
11627 @findex strrchr
11628 @findex strspn
11629 @findex strstr
11630 @findex tan
11631 @findex tanf
11632 @findex tanh
11633 @findex tanhf
11634 @findex tanhl
11635 @findex tanl
11636 @findex tgamma
11637 @findex tgammaf
11638 @findex tgammal
11639 @findex toascii
11640 @findex tolower
11641 @findex toupper
11642 @findex towlower
11643 @findex towupper
11644 @findex trunc
11645 @findex truncf
11646 @findex truncl
11647 @findex vfprintf
11648 @findex vfscanf
11649 @findex vprintf
11650 @findex vscanf
11651 @findex vsnprintf
11652 @findex vsprintf
11653 @findex vsscanf
11654 @findex y0
11655 @findex y0f
11656 @findex y0l
11657 @findex y1
11658 @findex y1f
11659 @findex y1l
11660 @findex yn
11661 @findex ynf
11662 @findex ynl
11664 GCC provides a large number of built-in functions other than the ones
11665 mentioned above.  Some of these are for internal use in the processing
11666 of exceptions or variable-length argument lists and are not
11667 documented here because they may change from time to time; we do not
11668 recommend general use of these functions.
11670 The remaining functions are provided for optimization purposes.
11672 With the exception of built-ins that have library equivalents such as
11673 the standard C library functions discussed below, or that expand to
11674 library calls, GCC built-in functions are always expanded inline and
11675 thus do not have corresponding entry points and their address cannot
11676 be obtained.  Attempting to use them in an expression other than
11677 a function call results in a compile-time error.
11679 @opindex fno-builtin
11680 GCC includes built-in versions of many of the functions in the standard
11681 C library.  These functions come in two forms: one whose names start with
11682 the @code{__builtin_} prefix, and the other without.  Both forms have the
11683 same type (including prototype), the same address (when their address is
11684 taken), and the same meaning as the C library functions even if you specify
11685 the @option{-fno-builtin} option @pxref{C Dialect Options}).  Many of these
11686 functions are only optimized in certain cases; if they are not optimized in
11687 a particular case, a call to the library function is emitted.
11689 @opindex ansi
11690 @opindex std
11691 Outside strict ISO C mode (@option{-ansi}, @option{-std=c90},
11692 @option{-std=c99} or @option{-std=c11}), the functions
11693 @code{_exit}, @code{alloca}, @code{bcmp}, @code{bzero},
11694 @code{dcgettext}, @code{dgettext}, @code{dremf}, @code{dreml},
11695 @code{drem}, @code{exp10f}, @code{exp10l}, @code{exp10}, @code{ffsll},
11696 @code{ffsl}, @code{ffs}, @code{fprintf_unlocked},
11697 @code{fputs_unlocked}, @code{gammaf}, @code{gammal}, @code{gamma},
11698 @code{gammaf_r}, @code{gammal_r}, @code{gamma_r}, @code{gettext},
11699 @code{index}, @code{isascii}, @code{j0f}, @code{j0l}, @code{j0},
11700 @code{j1f}, @code{j1l}, @code{j1}, @code{jnf}, @code{jnl}, @code{jn},
11701 @code{lgammaf_r}, @code{lgammal_r}, @code{lgamma_r}, @code{mempcpy},
11702 @code{pow10f}, @code{pow10l}, @code{pow10}, @code{printf_unlocked},
11703 @code{rindex}, @code{scalbf}, @code{scalbl}, @code{scalb},
11704 @code{signbit}, @code{signbitf}, @code{signbitl}, @code{signbitd32},
11705 @code{signbitd64}, @code{signbitd128}, @code{significandf},
11706 @code{significandl}, @code{significand}, @code{sincosf},
11707 @code{sincosl}, @code{sincos}, @code{stpcpy}, @code{stpncpy},
11708 @code{strcasecmp}, @code{strdup}, @code{strfmon}, @code{strncasecmp},
11709 @code{strndup}, @code{strnlen}, @code{toascii}, @code{y0f}, @code{y0l},
11710 @code{y0}, @code{y1f}, @code{y1l}, @code{y1}, @code{ynf}, @code{ynl} and
11711 @code{yn}
11712 may be handled as built-in functions.
11713 All these functions have corresponding versions
11714 prefixed with @code{__builtin_}, which may be used even in strict C90
11715 mode.
11717 The ISO C99 functions
11718 @code{_Exit}, @code{acoshf}, @code{acoshl}, @code{acosh}, @code{asinhf},
11719 @code{asinhl}, @code{asinh}, @code{atanhf}, @code{atanhl}, @code{atanh},
11720 @code{cabsf}, @code{cabsl}, @code{cabs}, @code{cacosf}, @code{cacoshf},
11721 @code{cacoshl}, @code{cacosh}, @code{cacosl}, @code{cacos},
11722 @code{cargf}, @code{cargl}, @code{carg}, @code{casinf}, @code{casinhf},
11723 @code{casinhl}, @code{casinh}, @code{casinl}, @code{casin},
11724 @code{catanf}, @code{catanhf}, @code{catanhl}, @code{catanh},
11725 @code{catanl}, @code{catan}, @code{cbrtf}, @code{cbrtl}, @code{cbrt},
11726 @code{ccosf}, @code{ccoshf}, @code{ccoshl}, @code{ccosh}, @code{ccosl},
11727 @code{ccos}, @code{cexpf}, @code{cexpl}, @code{cexp}, @code{cimagf},
11728 @code{cimagl}, @code{cimag}, @code{clogf}, @code{clogl}, @code{clog},
11729 @code{conjf}, @code{conjl}, @code{conj}, @code{copysignf}, @code{copysignl},
11730 @code{copysign}, @code{cpowf}, @code{cpowl}, @code{cpow}, @code{cprojf},
11731 @code{cprojl}, @code{cproj}, @code{crealf}, @code{creall}, @code{creal},
11732 @code{csinf}, @code{csinhf}, @code{csinhl}, @code{csinh}, @code{csinl},
11733 @code{csin}, @code{csqrtf}, @code{csqrtl}, @code{csqrt}, @code{ctanf},
11734 @code{ctanhf}, @code{ctanhl}, @code{ctanh}, @code{ctanl}, @code{ctan},
11735 @code{erfcf}, @code{erfcl}, @code{erfc}, @code{erff}, @code{erfl},
11736 @code{erf}, @code{exp2f}, @code{exp2l}, @code{exp2}, @code{expm1f},
11737 @code{expm1l}, @code{expm1}, @code{fdimf}, @code{fdiml}, @code{fdim},
11738 @code{fmaf}, @code{fmal}, @code{fmaxf}, @code{fmaxl}, @code{fmax},
11739 @code{fma}, @code{fminf}, @code{fminl}, @code{fmin}, @code{hypotf},
11740 @code{hypotl}, @code{hypot}, @code{ilogbf}, @code{ilogbl}, @code{ilogb},
11741 @code{imaxabs}, @code{isblank}, @code{iswblank}, @code{lgammaf},
11742 @code{lgammal}, @code{lgamma}, @code{llabs}, @code{llrintf}, @code{llrintl},
11743 @code{llrint}, @code{llroundf}, @code{llroundl}, @code{llround},
11744 @code{log1pf}, @code{log1pl}, @code{log1p}, @code{log2f}, @code{log2l},
11745 @code{log2}, @code{logbf}, @code{logbl}, @code{logb}, @code{lrintf},
11746 @code{lrintl}, @code{lrint}, @code{lroundf}, @code{lroundl},
11747 @code{lround}, @code{nearbyintf}, @code{nearbyintl}, @code{nearbyint},
11748 @code{nextafterf}, @code{nextafterl}, @code{nextafter},
11749 @code{nexttowardf}, @code{nexttowardl}, @code{nexttoward},
11750 @code{remainderf}, @code{remainderl}, @code{remainder}, @code{remquof},
11751 @code{remquol}, @code{remquo}, @code{rintf}, @code{rintl}, @code{rint},
11752 @code{roundf}, @code{roundl}, @code{round}, @code{scalblnf},
11753 @code{scalblnl}, @code{scalbln}, @code{scalbnf}, @code{scalbnl},
11754 @code{scalbn}, @code{snprintf}, @code{tgammaf}, @code{tgammal},
11755 @code{tgamma}, @code{truncf}, @code{truncl}, @code{trunc},
11756 @code{vfscanf}, @code{vscanf}, @code{vsnprintf} and @code{vsscanf}
11757 are handled as built-in functions
11758 except in strict ISO C90 mode (@option{-ansi} or @option{-std=c90}).
11760 There are also built-in versions of the ISO C99 functions
11761 @code{acosf}, @code{acosl}, @code{asinf}, @code{asinl}, @code{atan2f},
11762 @code{atan2l}, @code{atanf}, @code{atanl}, @code{ceilf}, @code{ceill},
11763 @code{cosf}, @code{coshf}, @code{coshl}, @code{cosl}, @code{expf},
11764 @code{expl}, @code{fabsf}, @code{fabsl}, @code{floorf}, @code{floorl},
11765 @code{fmodf}, @code{fmodl}, @code{frexpf}, @code{frexpl}, @code{ldexpf},
11766 @code{ldexpl}, @code{log10f}, @code{log10l}, @code{logf}, @code{logl},
11767 @code{modfl}, @code{modf}, @code{powf}, @code{powl}, @code{sinf},
11768 @code{sinhf}, @code{sinhl}, @code{sinl}, @code{sqrtf}, @code{sqrtl},
11769 @code{tanf}, @code{tanhf}, @code{tanhl} and @code{tanl}
11770 that are recognized in any mode since ISO C90 reserves these names for
11771 the purpose to which ISO C99 puts them.  All these functions have
11772 corresponding versions prefixed with @code{__builtin_}.
11774 There are also built-in functions @code{__builtin_fabsf@var{n}},
11775 @code{__builtin_fabsf@var{n}x}, @code{__builtin_copysignf@var{n}} and
11776 @code{__builtin_copysignf@var{n}x}, corresponding to the TS 18661-3
11777 functions @code{fabsf@var{n}}, @code{fabsf@var{n}x},
11778 @code{copysignf@var{n}} and @code{copysignf@var{n}x}, for supported
11779 types @code{_Float@var{n}} and @code{_Float@var{n}x}.
11781 There are also GNU extension functions @code{clog10}, @code{clog10f} and
11782 @code{clog10l} which names are reserved by ISO C99 for future use.
11783 All these functions have versions prefixed with @code{__builtin_}.
11785 The ISO C94 functions
11786 @code{iswalnum}, @code{iswalpha}, @code{iswcntrl}, @code{iswdigit},
11787 @code{iswgraph}, @code{iswlower}, @code{iswprint}, @code{iswpunct},
11788 @code{iswspace}, @code{iswupper}, @code{iswxdigit}, @code{towlower} and
11789 @code{towupper}
11790 are handled as built-in functions
11791 except in strict ISO C90 mode (@option{-ansi} or @option{-std=c90}).
11793 The ISO C90 functions
11794 @code{abort}, @code{abs}, @code{acos}, @code{asin}, @code{atan2},
11795 @code{atan}, @code{calloc}, @code{ceil}, @code{cosh}, @code{cos},
11796 @code{exit}, @code{exp}, @code{fabs}, @code{floor}, @code{fmod},
11797 @code{fprintf}, @code{fputs}, @code{frexp}, @code{fscanf},
11798 @code{isalnum}, @code{isalpha}, @code{iscntrl}, @code{isdigit},
11799 @code{isgraph}, @code{islower}, @code{isprint}, @code{ispunct},
11800 @code{isspace}, @code{isupper}, @code{isxdigit}, @code{tolower},
11801 @code{toupper}, @code{labs}, @code{ldexp}, @code{log10}, @code{log},
11802 @code{malloc}, @code{memchr}, @code{memcmp}, @code{memcpy},
11803 @code{memset}, @code{modf}, @code{pow}, @code{printf}, @code{putchar},
11804 @code{puts}, @code{scanf}, @code{sinh}, @code{sin}, @code{snprintf},
11805 @code{sprintf}, @code{sqrt}, @code{sscanf}, @code{strcat},
11806 @code{strchr}, @code{strcmp}, @code{strcpy}, @code{strcspn},
11807 @code{strlen}, @code{strncat}, @code{strncmp}, @code{strncpy},
11808 @code{strpbrk}, @code{strrchr}, @code{strspn}, @code{strstr},
11809 @code{tanh}, @code{tan}, @code{vfprintf}, @code{vprintf} and @code{vsprintf}
11810 are all recognized as built-in functions unless
11811 @option{-fno-builtin} is specified (or @option{-fno-builtin-@var{function}}
11812 is specified for an individual function).  All of these functions have
11813 corresponding versions prefixed with @code{__builtin_}.
11815 GCC provides built-in versions of the ISO C99 floating-point comparison
11816 macros that avoid raising exceptions for unordered operands.  They have
11817 the same names as the standard macros ( @code{isgreater},
11818 @code{isgreaterequal}, @code{isless}, @code{islessequal},
11819 @code{islessgreater}, and @code{isunordered}) , with @code{__builtin_}
11820 prefixed.  We intend for a library implementor to be able to simply
11821 @code{#define} each standard macro to its built-in equivalent.
11822 In the same fashion, GCC provides @code{fpclassify}, @code{isfinite},
11823 @code{isinf_sign}, @code{isnormal} and @code{signbit} built-ins used with
11824 @code{__builtin_} prefixed.  The @code{isinf} and @code{isnan}
11825 built-in functions appear both with and without the @code{__builtin_} prefix.
11827 @deftypefn {Built-in Function} void *__builtin_alloca (size_t size)
11828 The @code{__builtin_alloca} function must be called at block scope.
11829 The function allocates an object @var{size} bytes large on the stack
11830 of the calling function.  The object is aligned on the default stack
11831 alignment boundary for the target determined by the
11832 @code{__BIGGEST_ALIGNMENT__} macro.  The @code{__builtin_alloca}
11833 function returns a pointer to the first byte of the allocated object.
11834 The lifetime of the allocated object ends just before the calling
11835 function returns to its caller.   This is so even when
11836 @code{__builtin_alloca} is called within a nested block.
11838 For example, the following function allocates eight objects of @code{n}
11839 bytes each on the stack, storing a pointer to each in consecutive elements
11840 of the array @code{a}.  It then passes the array to function @code{g}
11841 which can safely use the storage pointed to by each of the array elements.
11843 @smallexample
11844 void f (unsigned n)
11846   void *a [8];
11847   for (int i = 0; i != 8; ++i)
11848     a [i] = __builtin_alloca (n);
11850   g (a, n);   // @r{safe}
11852 @end smallexample
11854 Since the @code{__builtin_alloca} function doesn't validate its argument
11855 it is the responsibility of its caller to make sure the argument doesn't
11856 cause it to exceed the stack size limit.
11857 The @code{__builtin_alloca} function is provided to make it possible to
11858 allocate on the stack arrays of bytes with an upper bound that may be
11859 computed at run time.  Since C99 Variable Length Arrays offer
11860 similar functionality under a portable, more convenient, and safer
11861 interface they are recommended instead, in both C99 and C++ programs
11862 where GCC provides them as an extension.
11863 @xref{Variable Length}, for details.
11865 @end deftypefn
11867 @deftypefn {Built-in Function} void *__builtin_alloca_with_align (size_t size, size_t alignment)
11868 The @code{__builtin_alloca_with_align} function must be called at block
11869 scope.  The function allocates an object @var{size} bytes large on
11870 the stack of the calling function.  The allocated object is aligned on
11871 the boundary specified by the argument @var{alignment} whose unit is given
11872 in bits (not bytes).  The @var{size} argument must be positive and not
11873 exceed the stack size limit.  The @var{alignment} argument must be a constant
11874 integer expression that evaluates to a power of 2 greater than or equal to
11875 @code{CHAR_BIT} and less than some unspecified maximum.  Invocations
11876 with other values are rejected with an error indicating the valid bounds.
11877 The function returns a pointer to the first byte of the allocated object.
11878 The lifetime of the allocated object ends at the end of the block in which
11879 the function was called.  The allocated storage is released no later than
11880 just before the calling function returns to its caller, but may be released
11881 at the end of the block in which the function was called.
11883 For example, in the following function the call to @code{g} is unsafe
11884 because when @code{overalign} is non-zero, the space allocated by
11885 @code{__builtin_alloca_with_align} may have been released at the end
11886 of the @code{if} statement in which it was called.
11888 @smallexample
11889 void f (unsigned n, bool overalign)
11891   void *p;
11892   if (overalign)
11893     p = __builtin_alloca_with_align (n, 64 /* bits */);
11894   else
11895     p = __builtin_alloc (n);
11897   g (p, n);   // @r{unsafe}
11899 @end smallexample
11901 Since the @code{__builtin_alloca_with_align} function doesn't validate its
11902 @var{size} argument it is the responsibility of its caller to make sure
11903 the argument doesn't cause it to exceed the stack size limit.
11904 The @code{__builtin_alloca_with_align} function is provided to make
11905 it possible to allocate on the stack overaligned arrays of bytes with
11906 an upper bound that may be computed at run time.  Since C99
11907 Variable Length Arrays offer the same functionality under
11908 a portable, more convenient, and safer interface they are recommended
11909 instead, in both C99 and C++ programs where GCC provides them as
11910 an extension.  @xref{Variable Length}, for details.
11912 @end deftypefn
11914 @deftypefn {Built-in Function} void *__builtin_alloca_with_align_and_max (size_t size, size_t alignment, size_t max_size)
11915 Similar to @code{__builtin_alloca_with_align} but takes an extra argument
11916 specifying an upper bound for @var{size} in case its value cannot be computed
11917 at compile time, for use by @option{-fstack-usage}, @option{-Wstack-usage}
11918 and @option{-Walloca-larger-than}.  @var{max_size} must be a constant integer
11919 expression, it has no effect on code generation and no attempt is made to
11920 check its compatibility with @var{size}.
11922 @end deftypefn
11924 @deftypefn {Built-in Function} bool __builtin_has_attribute (@var{type-or-expression}, @var{attribute})
11925 The @code{__builtin_has_attribute} function evaluates to an integer constant
11926 expression equal to @code{true} if the symbol or type referenced by
11927 the @var{type-or-expression} argument has been declared with
11928 the @var{attribute} referenced by the second argument.  Neither argument
11929 is evaluated.  The @var{type-or-expression} argument is subject to the same
11930 restrictions as the argument to @code{typeof} (@pxref{Typeof}).  The
11931 @var{attribute} argument is an attribute name optionally followed by
11932 a comma-separated list of arguments enclosed in parentheses.  Both forms
11933 of attribute names---with and without double leading and trailing
11934 underscores---are recognized.  @xref{Attribute Syntax} for details.
11935 When no attribute arguments are specified for an attribute that expects
11936 one or more arguments the function returns @code{true} if
11937 @var{type-or-expression} has been declared with the attribute regardless
11938 of the attribute argument values.  Arguments provided for an attribute
11939 that expects some are validated and matched up to the provided number.
11940 The function returns @code{true} if all provided arguments match.  For
11941 example, the first call to the function below evaluates to @code{true}
11942 because @code{x} is declared with the @code{aligned} attribute but
11943 the second call evaluates to @code{false} because @code{x} is declared
11944 @code{aligned (8)} and not @code{aligned (4)}.
11946 @smallexample
11947 __attribute__ ((aligned (8))) int x;
11948 _Static_assert (__builtin_has_attribute (x, aligned), "aligned");
11949 _Static_assert (!__builtin_has_attribute (x, aligned (4)), "aligned (4)");
11950 @end smallexample
11952 Due to a limitation the @code{__builtin_has_attribute} function returns
11953 @code{false} for the @code{mode} attribute even if the type or variable
11954 referenced by the @var{type-or-expression} argument was declared with one.
11955 The function is also not supported with labels, and in C with enumerators.
11957 Note that unlike the @code{__has_attribute} preprocessor operator which
11958 is suitable for use in @code{#if} preprocessing directives
11959 @code{__builtin_has_attribute} is an intrinsic function that is not
11960 recognized in such contexts.
11962 @end deftypefn
11964 @deftypefn {Built-in Function} @var{type} __builtin_speculation_safe_value (@var{type} val, @var{type} failval)
11966 This built-in function can be used to help mitigate against unsafe
11967 speculative execution.  @var{type} may be any integral type or any
11968 pointer type.
11970 @enumerate
11971 @item
11972 If the CPU is not speculatively executing the code, then @var{val}
11973 is returned.
11974 @item
11975 If the CPU is executing speculatively then either:
11976 @itemize
11977 @item
11978 The function may cause execution to pause until it is known that the
11979 code is no-longer being executed speculatively (in which case
11980 @var{val} can be returned, as above); or
11981 @item
11982 The function may use target-dependent speculation tracking state to cause
11983 @var{failval} to be returned when it is known that speculative
11984 execution has incorrectly predicted a conditional branch operation.
11985 @end itemize
11986 @end enumerate
11988 The second argument, @var{failval}, is optional and defaults to zero
11989 if omitted.
11991 GCC defines the preprocessor macro
11992 @code{__HAVE_BUILTIN_SPECULATION_SAFE_VALUE} for targets that have been
11993 updated to support this builtin.
11995 The built-in function can be used where a variable appears to be used in a
11996 safe way, but the CPU, due to speculative execution may temporarily ignore
11997 the bounds checks.  Consider, for example, the following function:
11999 @smallexample
12000 int array[500];
12001 int f (unsigned untrusted_index)
12003   if (untrusted_index < 500)
12004     return array[untrusted_index];
12005   return 0;
12007 @end smallexample
12009 If the function is called repeatedly with @code{untrusted_index} less
12010 than the limit of 500, then a branch predictor will learn that the
12011 block of code that returns a value stored in @code{array} will be
12012 executed.  If the function is subsequently called with an
12013 out-of-range value it will still try to execute that block of code
12014 first until the CPU determines that the prediction was incorrect
12015 (the CPU will unwind any incorrect operations at that point).
12016 However, depending on how the result of the function is used, it might be
12017 possible to leave traces in the cache that can reveal what was stored
12018 at the out-of-bounds location.  The built-in function can be used to
12019 provide some protection against leaking data in this way by changing
12020 the code to:
12022 @smallexample
12023 int array[500];
12024 int f (unsigned untrusted_index)
12026   if (untrusted_index < 500)
12027     return array[__builtin_speculation_safe_value (untrusted_index)];
12028   return 0;
12030 @end smallexample
12032 The built-in function will either cause execution to stall until the
12033 conditional branch has been fully resolved, or it may permit
12034 speculative execution to continue, but using 0 instead of
12035 @code{untrusted_value} if that exceeds the limit.
12037 If accessing any memory location is potentially unsafe when speculative
12038 execution is incorrect, then the code can be rewritten as
12040 @smallexample
12041 int array[500];
12042 int f (unsigned untrusted_index)
12044   if (untrusted_index < 500)
12045     return *__builtin_speculation_safe_value (&array[untrusted_index], NULL);
12046   return 0;
12048 @end smallexample
12050 which will cause a @code{NULL} pointer to be used for the unsafe case.
12052 @end deftypefn
12054 @deftypefn {Built-in Function} int __builtin_types_compatible_p (@var{type1}, @var{type2})
12056 You can use the built-in function @code{__builtin_types_compatible_p} to
12057 determine whether two types are the same.
12059 This built-in function returns 1 if the unqualified versions of the
12060 types @var{type1} and @var{type2} (which are types, not expressions) are
12061 compatible, 0 otherwise.  The result of this built-in function can be
12062 used in integer constant expressions.
12064 This built-in function ignores top level qualifiers (e.g., @code{const},
12065 @code{volatile}).  For example, @code{int} is equivalent to @code{const
12066 int}.
12068 The type @code{int[]} and @code{int[5]} are compatible.  On the other
12069 hand, @code{int} and @code{char *} are not compatible, even if the size
12070 of their types, on the particular architecture are the same.  Also, the
12071 amount of pointer indirection is taken into account when determining
12072 similarity.  Consequently, @code{short *} is not similar to
12073 @code{short **}.  Furthermore, two types that are typedefed are
12074 considered compatible if their underlying types are compatible.
12076 An @code{enum} type is not considered to be compatible with another
12077 @code{enum} type even if both are compatible with the same integer
12078 type; this is what the C standard specifies.
12079 For example, @code{enum @{foo, bar@}} is not similar to
12080 @code{enum @{hot, dog@}}.
12082 You typically use this function in code whose execution varies
12083 depending on the arguments' types.  For example:
12085 @smallexample
12086 #define foo(x)                                                  \
12087   (@{                                                           \
12088     typeof (x) tmp = (x);                                       \
12089     if (__builtin_types_compatible_p (typeof (x), long double)) \
12090       tmp = foo_long_double (tmp);                              \
12091     else if (__builtin_types_compatible_p (typeof (x), double)) \
12092       tmp = foo_double (tmp);                                   \
12093     else if (__builtin_types_compatible_p (typeof (x), float))  \
12094       tmp = foo_float (tmp);                                    \
12095     else                                                        \
12096       abort ();                                                 \
12097     tmp;                                                        \
12098   @})
12099 @end smallexample
12101 @emph{Note:} This construct is only available for C@.
12103 @end deftypefn
12105 @deftypefn {Built-in Function} @var{type} __builtin_call_with_static_chain (@var{call_exp}, @var{pointer_exp})
12107 The @var{call_exp} expression must be a function call, and the
12108 @var{pointer_exp} expression must be a pointer.  The @var{pointer_exp}
12109 is passed to the function call in the target's static chain location.
12110 The result of builtin is the result of the function call.
12112 @emph{Note:} This builtin is only available for C@.
12113 This builtin can be used to call Go closures from C.
12115 @end deftypefn
12117 @deftypefn {Built-in Function} @var{type} __builtin_choose_expr (@var{const_exp}, @var{exp1}, @var{exp2})
12119 You can use the built-in function @code{__builtin_choose_expr} to
12120 evaluate code depending on the value of a constant expression.  This
12121 built-in function returns @var{exp1} if @var{const_exp}, which is an
12122 integer constant expression, is nonzero.  Otherwise it returns @var{exp2}.
12124 This built-in function is analogous to the @samp{? :} operator in C,
12125 except that the expression returned has its type unaltered by promotion
12126 rules.  Also, the built-in function does not evaluate the expression
12127 that is not chosen.  For example, if @var{const_exp} evaluates to @code{true},
12128 @var{exp2} is not evaluated even if it has side effects.
12130 This built-in function can return an lvalue if the chosen argument is an
12131 lvalue.
12133 If @var{exp1} is returned, the return type is the same as @var{exp1}'s
12134 type.  Similarly, if @var{exp2} is returned, its return type is the same
12135 as @var{exp2}.
12137 Example:
12139 @smallexample
12140 #define foo(x)                                                    \
12141   __builtin_choose_expr (                                         \
12142     __builtin_types_compatible_p (typeof (x), double),            \
12143     foo_double (x),                                               \
12144     __builtin_choose_expr (                                       \
12145       __builtin_types_compatible_p (typeof (x), float),           \
12146       foo_float (x),                                              \
12147       /* @r{The void expression results in a compile-time error}  \
12148          @r{when assigning the result to something.}  */          \
12149       (void)0))
12150 @end smallexample
12152 @emph{Note:} This construct is only available for C@.  Furthermore, the
12153 unused expression (@var{exp1} or @var{exp2} depending on the value of
12154 @var{const_exp}) may still generate syntax errors.  This may change in
12155 future revisions.
12157 @end deftypefn
12159 @deftypefn {Built-in Function} @var{type} __builtin_tgmath (@var{functions}, @var{arguments})
12161 The built-in function @code{__builtin_tgmath}, available only for C
12162 and Objective-C, calls a function determined according to the rules of
12163 @code{<tgmath.h>} macros.  It is intended to be used in
12164 implementations of that header, so that expansions of macros from that
12165 header only expand each of their arguments once, to avoid problems
12166 when calls to such macros are nested inside the arguments of other
12167 calls to such macros; in addition, it results in better diagnostics
12168 for invalid calls to @code{<tgmath.h>} macros than implementations
12169 using other GNU C language features.  For example, the @code{pow}
12170 type-generic macro might be defined as:
12172 @smallexample
12173 #define pow(a, b) __builtin_tgmath (powf, pow, powl, \
12174                                     cpowf, cpow, cpowl, a, b)
12175 @end smallexample
12177 The arguments to @code{__builtin_tgmath} are at least two pointers to
12178 functions, followed by the arguments to the type-generic macro (which
12179 will be passed as arguments to the selected function).  All the
12180 pointers to functions must be pointers to prototyped functions, none
12181 of which may have variable arguments, and all of which must have the
12182 same number of parameters; the number of parameters of the first
12183 function determines how many arguments to @code{__builtin_tgmath} are
12184 interpreted as function pointers, and how many as the arguments to the
12185 called function.
12187 The types of the specified functions must all be different, but
12188 related to each other in the same way as a set of functions that may
12189 be selected between by a macro in @code{<tgmath.h>}.  This means that
12190 the functions are parameterized by a floating-point type @var{t},
12191 different for each such function.  The function return types may all
12192 be the same type, or they may be @var{t} for each function, or they
12193 may be the real type corresponding to @var{t} for each function (if
12194 some of the types @var{t} are complex).  Likewise, for each parameter
12195 position, the type of the parameter in that position may always be the
12196 same type, or may be @var{t} for each function (this case must apply
12197 for at least one parameter position), or may be the real type
12198 corresponding to @var{t} for each function.
12200 The standard rules for @code{<tgmath.h>} macros are used to find a
12201 common type @var{u} from the types of the arguments for parameters
12202 whose types vary between the functions; complex integer types (a GNU
12203 extension) are treated like @code{_Complex double} for this purpose
12204 (or @code{_Complex _Float64} if all the function return types are the
12205 same @code{_Float@var{n}} or @code{_Float@var{n}x} type).
12206 If the function return types vary, or are all the same integer type,
12207 the function called is the one for which @var{t} is @var{u}, and it is
12208 an error if there is no such function.  If the function return types
12209 are all the same floating-point type, the type-generic macro is taken
12210 to be one of those from TS 18661 that rounds the result to a narrower
12211 type; if there is a function for which @var{t} is @var{u}, it is
12212 called, and otherwise the first function, if any, for which @var{t}
12213 has at least the range and precision of @var{u} is called, and it is
12214 an error if there is no such function.
12216 @end deftypefn
12218 @deftypefn {Built-in Function} @var{type} __builtin_complex (@var{real}, @var{imag})
12220 The built-in function @code{__builtin_complex} is provided for use in
12221 implementing the ISO C11 macros @code{CMPLXF}, @code{CMPLX} and
12222 @code{CMPLXL}.  @var{real} and @var{imag} must have the same type, a
12223 real binary floating-point type, and the result has the corresponding
12224 complex type with real and imaginary parts @var{real} and @var{imag}.
12225 Unlike @samp{@var{real} + I * @var{imag}}, this works even when
12226 infinities, NaNs and negative zeros are involved.
12228 @end deftypefn
12230 @deftypefn {Built-in Function} int __builtin_constant_p (@var{exp})
12231 You can use the built-in function @code{__builtin_constant_p} to
12232 determine if a value is known to be constant at compile time and hence
12233 that GCC can perform constant-folding on expressions involving that
12234 value.  The argument of the function is the value to test.  The function
12235 returns the integer 1 if the argument is known to be a compile-time
12236 constant and 0 if it is not known to be a compile-time constant.  A
12237 return of 0 does not indicate that the value is @emph{not} a constant,
12238 but merely that GCC cannot prove it is a constant with the specified
12239 value of the @option{-O} option.
12241 You typically use this function in an embedded application where
12242 memory is a critical resource.  If you have some complex calculation,
12243 you may want it to be folded if it involves constants, but need to call
12244 a function if it does not.  For example:
12246 @smallexample
12247 #define Scale_Value(X)      \
12248   (__builtin_constant_p (X) \
12249   ? ((X) * SCALE + OFFSET) : Scale (X))
12250 @end smallexample
12252 You may use this built-in function in either a macro or an inline
12253 function.  However, if you use it in an inlined function and pass an
12254 argument of the function as the argument to the built-in, GCC 
12255 never returns 1 when you call the inline function with a string constant
12256 or compound literal (@pxref{Compound Literals}) and does not return 1
12257 when you pass a constant numeric value to the inline function unless you
12258 specify the @option{-O} option.
12260 You may also use @code{__builtin_constant_p} in initializers for static
12261 data.  For instance, you can write
12263 @smallexample
12264 static const int table[] = @{
12265    __builtin_constant_p (EXPRESSION) ? (EXPRESSION) : -1,
12266    /* @r{@dots{}} */
12268 @end smallexample
12270 @noindent
12271 This is an acceptable initializer even if @var{EXPRESSION} is not a
12272 constant expression, including the case where
12273 @code{__builtin_constant_p} returns 1 because @var{EXPRESSION} can be
12274 folded to a constant but @var{EXPRESSION} contains operands that are
12275 not otherwise permitted in a static initializer (for example,
12276 @code{0 && foo ()}).  GCC must be more conservative about evaluating the
12277 built-in in this case, because it has no opportunity to perform
12278 optimization.
12279 @end deftypefn
12281 @deftypefn {Built-in Function} long __builtin_expect (long @var{exp}, long @var{c})
12282 @opindex fprofile-arcs
12283 You may use @code{__builtin_expect} to provide the compiler with
12284 branch prediction information.  In general, you should prefer to
12285 use actual profile feedback for this (@option{-fprofile-arcs}), as
12286 programmers are notoriously bad at predicting how their programs
12287 actually perform.  However, there are applications in which this
12288 data is hard to collect.
12290 The return value is the value of @var{exp}, which should be an integral
12291 expression.  The semantics of the built-in are that it is expected that
12292 @var{exp} == @var{c}.  For example:
12294 @smallexample
12295 if (__builtin_expect (x, 0))
12296   foo ();
12297 @end smallexample
12299 @noindent
12300 indicates that we do not expect to call @code{foo}, since
12301 we expect @code{x} to be zero.  Since you are limited to integral
12302 expressions for @var{exp}, you should use constructions such as
12304 @smallexample
12305 if (__builtin_expect (ptr != NULL, 1))
12306   foo (*ptr);
12307 @end smallexample
12309 @noindent
12310 when testing pointer or floating-point values.
12312 For the purposes of branch prediction optimizations, the probability that
12313 a @code{__builtin_expect} expression is @code{true} is controlled by GCC's
12314 @code{builtin-expect-probability} parameter, which defaults to 90%.  
12315 You can also use @code{__builtin_expect_with_probability} to explicitly 
12316 assign a probability value to individual expressions.
12317 @end deftypefn
12319 @deftypefn {Built-in Function} long __builtin_expect_with_probability
12320 (long @var{exp}, long @var{c}, double @var{probability})
12322 This function has the same semantics as @code{__builtin_expect},
12323 but the caller provides the expected probability that @var{exp} == @var{c}.
12324 The last argument, @var{probability}, is a floating-point value in the
12325 range 0.0 to 1.0, inclusive.  The @var{probability} argument must be
12326 constant floating-point expression.
12327 @end deftypefn
12329 @deftypefn {Built-in Function} void __builtin_trap (void)
12330 This function causes the program to exit abnormally.  GCC implements
12331 this function by using a target-dependent mechanism (such as
12332 intentionally executing an illegal instruction) or by calling
12333 @code{abort}.  The mechanism used may vary from release to release so
12334 you should not rely on any particular implementation.
12335 @end deftypefn
12337 @deftypefn {Built-in Function} void __builtin_unreachable (void)
12338 If control flow reaches the point of the @code{__builtin_unreachable},
12339 the program is undefined.  It is useful in situations where the
12340 compiler cannot deduce the unreachability of the code.
12342 One such case is immediately following an @code{asm} statement that
12343 either never terminates, or one that transfers control elsewhere
12344 and never returns.  In this example, without the
12345 @code{__builtin_unreachable}, GCC issues a warning that control
12346 reaches the end of a non-void function.  It also generates code
12347 to return after the @code{asm}.
12349 @smallexample
12350 int f (int c, int v)
12352   if (c)
12353     @{
12354       return v;
12355     @}
12356   else
12357     @{
12358       asm("jmp error_handler");
12359       __builtin_unreachable ();
12360     @}
12362 @end smallexample
12364 @noindent
12365 Because the @code{asm} statement unconditionally transfers control out
12366 of the function, control never reaches the end of the function
12367 body.  The @code{__builtin_unreachable} is in fact unreachable and
12368 communicates this fact to the compiler.
12370 Another use for @code{__builtin_unreachable} is following a call a
12371 function that never returns but that is not declared
12372 @code{__attribute__((noreturn))}, as in this example:
12374 @smallexample
12375 void function_that_never_returns (void);
12377 int g (int c)
12379   if (c)
12380     @{
12381       return 1;
12382     @}
12383   else
12384     @{
12385       function_that_never_returns ();
12386       __builtin_unreachable ();
12387     @}
12389 @end smallexample
12391 @end deftypefn
12393 @deftypefn {Built-in Function} {void *} __builtin_assume_aligned (const void *@var{exp}, size_t @var{align}, ...)
12394 This function returns its first argument, and allows the compiler
12395 to assume that the returned pointer is at least @var{align} bytes
12396 aligned.  This built-in can have either two or three arguments,
12397 if it has three, the third argument should have integer type, and
12398 if it is nonzero means misalignment offset.  For example:
12400 @smallexample
12401 void *x = __builtin_assume_aligned (arg, 16);
12402 @end smallexample
12404 @noindent
12405 means that the compiler can assume @code{x}, set to @code{arg}, is at least
12406 16-byte aligned, while:
12408 @smallexample
12409 void *x = __builtin_assume_aligned (arg, 32, 8);
12410 @end smallexample
12412 @noindent
12413 means that the compiler can assume for @code{x}, set to @code{arg}, that
12414 @code{(char *) x - 8} is 32-byte aligned.
12415 @end deftypefn
12417 @deftypefn {Built-in Function} int __builtin_LINE ()
12418 This function is the equivalent of the preprocessor @code{__LINE__}
12419 macro and returns a constant integer expression that evaluates to
12420 the line number of the invocation of the built-in.  When used as a C++
12421 default argument for a function @var{F}, it returns the line number
12422 of the call to @var{F}.
12423 @end deftypefn
12425 @deftypefn {Built-in Function} {const char *} __builtin_FUNCTION ()
12426 This function is the equivalent of the @code{__FUNCTION__} symbol
12427 and returns an address constant pointing to the name of the function
12428 from which the built-in was invoked, or the empty string if
12429 the invocation is not at function scope.  When used as a C++ default
12430 argument for a function @var{F}, it returns the name of @var{F}'s
12431 caller or the empty string if the call was not made at function
12432 scope.
12433 @end deftypefn
12435 @deftypefn {Built-in Function} {const char *} __builtin_FILE ()
12436 This function is the equivalent of the preprocessor @code{__FILE__}
12437 macro and returns an address constant pointing to the file name
12438 containing the invocation of the built-in, or the empty string if
12439 the invocation is not at function scope.  When used as a C++ default
12440 argument for a function @var{F}, it returns the file name of the call
12441 to @var{F} or the empty string if the call was not made at function
12442 scope.
12444 For example, in the following, each call to function @code{foo} will
12445 print a line similar to @code{"file.c:123: foo: message"} with the name
12446 of the file and the line number of the @code{printf} call, the name of
12447 the function @code{foo}, followed by the word @code{message}.
12449 @smallexample
12450 const char*
12451 function (const char *func = __builtin_FUNCTION ())
12453   return func;
12456 void foo (void)
12458   printf ("%s:%i: %s: message\n", file (), line (), function ());
12460 @end smallexample
12462 @end deftypefn
12464 @deftypefn {Built-in Function} void __builtin___clear_cache (char *@var{begin}, char *@var{end})
12465 This function is used to flush the processor's instruction cache for
12466 the region of memory between @var{begin} inclusive and @var{end}
12467 exclusive.  Some targets require that the instruction cache be
12468 flushed, after modifying memory containing code, in order to obtain
12469 deterministic behavior.
12471 If the target does not require instruction cache flushes,
12472 @code{__builtin___clear_cache} has no effect.  Otherwise either
12473 instructions are emitted in-line to clear the instruction cache or a
12474 call to the @code{__clear_cache} function in libgcc is made.
12475 @end deftypefn
12477 @deftypefn {Built-in Function} void __builtin_prefetch (const void *@var{addr}, ...)
12478 This function is used to minimize cache-miss latency by moving data into
12479 a cache before it is accessed.
12480 You can insert calls to @code{__builtin_prefetch} into code for which
12481 you know addresses of data in memory that is likely to be accessed soon.
12482 If the target supports them, data prefetch instructions are generated.
12483 If the prefetch is done early enough before the access then the data will
12484 be in the cache by the time it is accessed.
12486 The value of @var{addr} is the address of the memory to prefetch.
12487 There are two optional arguments, @var{rw} and @var{locality}.
12488 The value of @var{rw} is a compile-time constant one or zero; one
12489 means that the prefetch is preparing for a write to the memory address
12490 and zero, the default, means that the prefetch is preparing for a read.
12491 The value @var{locality} must be a compile-time constant integer between
12492 zero and three.  A value of zero means that the data has no temporal
12493 locality, so it need not be left in the cache after the access.  A value
12494 of three means that the data has a high degree of temporal locality and
12495 should be left in all levels of cache possible.  Values of one and two
12496 mean, respectively, a low or moderate degree of temporal locality.  The
12497 default is three.
12499 @smallexample
12500 for (i = 0; i < n; i++)
12501   @{
12502     a[i] = a[i] + b[i];
12503     __builtin_prefetch (&a[i+j], 1, 1);
12504     __builtin_prefetch (&b[i+j], 0, 1);
12505     /* @r{@dots{}} */
12506   @}
12507 @end smallexample
12509 Data prefetch does not generate faults if @var{addr} is invalid, but
12510 the address expression itself must be valid.  For example, a prefetch
12511 of @code{p->next} does not fault if @code{p->next} is not a valid
12512 address, but evaluation faults if @code{p} is not a valid address.
12514 If the target does not support data prefetch, the address expression
12515 is evaluated if it includes side effects but no other code is generated
12516 and GCC does not issue a warning.
12517 @end deftypefn
12519 @deftypefn {Built-in Function} double __builtin_huge_val (void)
12520 Returns a positive infinity, if supported by the floating-point format,
12521 else @code{DBL_MAX}.  This function is suitable for implementing the
12522 ISO C macro @code{HUGE_VAL}.
12523 @end deftypefn
12525 @deftypefn {Built-in Function} float __builtin_huge_valf (void)
12526 Similar to @code{__builtin_huge_val}, except the return type is @code{float}.
12527 @end deftypefn
12529 @deftypefn {Built-in Function} {long double} __builtin_huge_vall (void)
12530 Similar to @code{__builtin_huge_val}, except the return
12531 type is @code{long double}.
12532 @end deftypefn
12534 @deftypefn {Built-in Function} _Float@var{n} __builtin_huge_valf@var{n} (void)
12535 Similar to @code{__builtin_huge_val}, except the return type is
12536 @code{_Float@var{n}}.
12537 @end deftypefn
12539 @deftypefn {Built-in Function} _Float@var{n}x __builtin_huge_valf@var{n}x (void)
12540 Similar to @code{__builtin_huge_val}, except the return type is
12541 @code{_Float@var{n}x}.
12542 @end deftypefn
12544 @deftypefn {Built-in Function} int __builtin_fpclassify (int, int, int, int, int, ...)
12545 This built-in implements the C99 fpclassify functionality.  The first
12546 five int arguments should be the target library's notion of the
12547 possible FP classes and are used for return values.  They must be
12548 constant values and they must appear in this order: @code{FP_NAN},
12549 @code{FP_INFINITE}, @code{FP_NORMAL}, @code{FP_SUBNORMAL} and
12550 @code{FP_ZERO}.  The ellipsis is for exactly one floating-point value
12551 to classify.  GCC treats the last argument as type-generic, which
12552 means it does not do default promotion from float to double.
12553 @end deftypefn
12555 @deftypefn {Built-in Function} double __builtin_inf (void)
12556 Similar to @code{__builtin_huge_val}, except a warning is generated
12557 if the target floating-point format does not support infinities.
12558 @end deftypefn
12560 @deftypefn {Built-in Function} _Decimal32 __builtin_infd32 (void)
12561 Similar to @code{__builtin_inf}, except the return type is @code{_Decimal32}.
12562 @end deftypefn
12564 @deftypefn {Built-in Function} _Decimal64 __builtin_infd64 (void)
12565 Similar to @code{__builtin_inf}, except the return type is @code{_Decimal64}.
12566 @end deftypefn
12568 @deftypefn {Built-in Function} _Decimal128 __builtin_infd128 (void)
12569 Similar to @code{__builtin_inf}, except the return type is @code{_Decimal128}.
12570 @end deftypefn
12572 @deftypefn {Built-in Function} float __builtin_inff (void)
12573 Similar to @code{__builtin_inf}, except the return type is @code{float}.
12574 This function is suitable for implementing the ISO C99 macro @code{INFINITY}.
12575 @end deftypefn
12577 @deftypefn {Built-in Function} {long double} __builtin_infl (void)
12578 Similar to @code{__builtin_inf}, except the return
12579 type is @code{long double}.
12580 @end deftypefn
12582 @deftypefn {Built-in Function} _Float@var{n} __builtin_inff@var{n} (void)
12583 Similar to @code{__builtin_inf}, except the return
12584 type is @code{_Float@var{n}}.
12585 @end deftypefn
12587 @deftypefn {Built-in Function} _Float@var{n} __builtin_inff@var{n}x (void)
12588 Similar to @code{__builtin_inf}, except the return
12589 type is @code{_Float@var{n}x}.
12590 @end deftypefn
12592 @deftypefn {Built-in Function} int __builtin_isinf_sign (...)
12593 Similar to @code{isinf}, except the return value is -1 for
12594 an argument of @code{-Inf} and 1 for an argument of @code{+Inf}.
12595 Note while the parameter list is an
12596 ellipsis, this function only accepts exactly one floating-point
12597 argument.  GCC treats this parameter as type-generic, which means it
12598 does not do default promotion from float to double.
12599 @end deftypefn
12601 @deftypefn {Built-in Function} double __builtin_nan (const char *str)
12602 This is an implementation of the ISO C99 function @code{nan}.
12604 Since ISO C99 defines this function in terms of @code{strtod}, which we
12605 do not implement, a description of the parsing is in order.  The string
12606 is parsed as by @code{strtol}; that is, the base is recognized by
12607 leading @samp{0} or @samp{0x} prefixes.  The number parsed is placed
12608 in the significand such that the least significant bit of the number
12609 is at the least significant bit of the significand.  The number is
12610 truncated to fit the significand field provided.  The significand is
12611 forced to be a quiet NaN@.
12613 This function, if given a string literal all of which would have been
12614 consumed by @code{strtol}, is evaluated early enough that it is considered a
12615 compile-time constant.
12616 @end deftypefn
12618 @deftypefn {Built-in Function} _Decimal32 __builtin_nand32 (const char *str)
12619 Similar to @code{__builtin_nan}, except the return type is @code{_Decimal32}.
12620 @end deftypefn
12622 @deftypefn {Built-in Function} _Decimal64 __builtin_nand64 (const char *str)
12623 Similar to @code{__builtin_nan}, except the return type is @code{_Decimal64}.
12624 @end deftypefn
12626 @deftypefn {Built-in Function} _Decimal128 __builtin_nand128 (const char *str)
12627 Similar to @code{__builtin_nan}, except the return type is @code{_Decimal128}.
12628 @end deftypefn
12630 @deftypefn {Built-in Function} float __builtin_nanf (const char *str)
12631 Similar to @code{__builtin_nan}, except the return type is @code{float}.
12632 @end deftypefn
12634 @deftypefn {Built-in Function} {long double} __builtin_nanl (const char *str)
12635 Similar to @code{__builtin_nan}, except the return type is @code{long double}.
12636 @end deftypefn
12638 @deftypefn {Built-in Function} _Float@var{n} __builtin_nanf@var{n} (const char *str)
12639 Similar to @code{__builtin_nan}, except the return type is
12640 @code{_Float@var{n}}.
12641 @end deftypefn
12643 @deftypefn {Built-in Function} _Float@var{n}x __builtin_nanf@var{n}x (const char *str)
12644 Similar to @code{__builtin_nan}, except the return type is
12645 @code{_Float@var{n}x}.
12646 @end deftypefn
12648 @deftypefn {Built-in Function} double __builtin_nans (const char *str)
12649 Similar to @code{__builtin_nan}, except the significand is forced
12650 to be a signaling NaN@.  The @code{nans} function is proposed by
12651 @uref{http://www.open-std.org/jtc1/sc22/wg14/www/docs/n965.htm,,WG14 N965}.
12652 @end deftypefn
12654 @deftypefn {Built-in Function} float __builtin_nansf (const char *str)
12655 Similar to @code{__builtin_nans}, except the return type is @code{float}.
12656 @end deftypefn
12658 @deftypefn {Built-in Function} {long double} __builtin_nansl (const char *str)
12659 Similar to @code{__builtin_nans}, except the return type is @code{long double}.
12660 @end deftypefn
12662 @deftypefn {Built-in Function} _Float@var{n} __builtin_nansf@var{n} (const char *str)
12663 Similar to @code{__builtin_nans}, except the return type is
12664 @code{_Float@var{n}}.
12665 @end deftypefn
12667 @deftypefn {Built-in Function} _Float@var{n}x __builtin_nansf@var{n}x (const char *str)
12668 Similar to @code{__builtin_nans}, except the return type is
12669 @code{_Float@var{n}x}.
12670 @end deftypefn
12672 @deftypefn {Built-in Function} int __builtin_ffs (int x)
12673 Returns one plus the index of the least significant 1-bit of @var{x}, or
12674 if @var{x} is zero, returns zero.
12675 @end deftypefn
12677 @deftypefn {Built-in Function} int __builtin_clz (unsigned int x)
12678 Returns the number of leading 0-bits in @var{x}, starting at the most
12679 significant bit position.  If @var{x} is 0, the result is undefined.
12680 @end deftypefn
12682 @deftypefn {Built-in Function} int __builtin_ctz (unsigned int x)
12683 Returns the number of trailing 0-bits in @var{x}, starting at the least
12684 significant bit position.  If @var{x} is 0, the result is undefined.
12685 @end deftypefn
12687 @deftypefn {Built-in Function} int __builtin_clrsb (int x)
12688 Returns the number of leading redundant sign bits in @var{x}, i.e.@: the
12689 number of bits following the most significant bit that are identical
12690 to it.  There are no special cases for 0 or other values. 
12691 @end deftypefn
12693 @deftypefn {Built-in Function} int __builtin_popcount (unsigned int x)
12694 Returns the number of 1-bits in @var{x}.
12695 @end deftypefn
12697 @deftypefn {Built-in Function} int __builtin_parity (unsigned int x)
12698 Returns the parity of @var{x}, i.e.@: the number of 1-bits in @var{x}
12699 modulo 2.
12700 @end deftypefn
12702 @deftypefn {Built-in Function} int __builtin_ffsl (long)
12703 Similar to @code{__builtin_ffs}, except the argument type is
12704 @code{long}.
12705 @end deftypefn
12707 @deftypefn {Built-in Function} int __builtin_clzl (unsigned long)
12708 Similar to @code{__builtin_clz}, except the argument type is
12709 @code{unsigned long}.
12710 @end deftypefn
12712 @deftypefn {Built-in Function} int __builtin_ctzl (unsigned long)
12713 Similar to @code{__builtin_ctz}, except the argument type is
12714 @code{unsigned long}.
12715 @end deftypefn
12717 @deftypefn {Built-in Function} int __builtin_clrsbl (long)
12718 Similar to @code{__builtin_clrsb}, except the argument type is
12719 @code{long}.
12720 @end deftypefn
12722 @deftypefn {Built-in Function} int __builtin_popcountl (unsigned long)
12723 Similar to @code{__builtin_popcount}, except the argument type is
12724 @code{unsigned long}.
12725 @end deftypefn
12727 @deftypefn {Built-in Function} int __builtin_parityl (unsigned long)
12728 Similar to @code{__builtin_parity}, except the argument type is
12729 @code{unsigned long}.
12730 @end deftypefn
12732 @deftypefn {Built-in Function} int __builtin_ffsll (long long)
12733 Similar to @code{__builtin_ffs}, except the argument type is
12734 @code{long long}.
12735 @end deftypefn
12737 @deftypefn {Built-in Function} int __builtin_clzll (unsigned long long)
12738 Similar to @code{__builtin_clz}, except the argument type is
12739 @code{unsigned long long}.
12740 @end deftypefn
12742 @deftypefn {Built-in Function} int __builtin_ctzll (unsigned long long)
12743 Similar to @code{__builtin_ctz}, except the argument type is
12744 @code{unsigned long long}.
12745 @end deftypefn
12747 @deftypefn {Built-in Function} int __builtin_clrsbll (long long)
12748 Similar to @code{__builtin_clrsb}, except the argument type is
12749 @code{long long}.
12750 @end deftypefn
12752 @deftypefn {Built-in Function} int __builtin_popcountll (unsigned long long)
12753 Similar to @code{__builtin_popcount}, except the argument type is
12754 @code{unsigned long long}.
12755 @end deftypefn
12757 @deftypefn {Built-in Function} int __builtin_parityll (unsigned long long)
12758 Similar to @code{__builtin_parity}, except the argument type is
12759 @code{unsigned long long}.
12760 @end deftypefn
12762 @deftypefn {Built-in Function} double __builtin_powi (double, int)
12763 Returns the first argument raised to the power of the second.  Unlike the
12764 @code{pow} function no guarantees about precision and rounding are made.
12765 @end deftypefn
12767 @deftypefn {Built-in Function} float __builtin_powif (float, int)
12768 Similar to @code{__builtin_powi}, except the argument and return types
12769 are @code{float}.
12770 @end deftypefn
12772 @deftypefn {Built-in Function} {long double} __builtin_powil (long double, int)
12773 Similar to @code{__builtin_powi}, except the argument and return types
12774 are @code{long double}.
12775 @end deftypefn
12777 @deftypefn {Built-in Function} uint16_t __builtin_bswap16 (uint16_t x)
12778 Returns @var{x} with the order of the bytes reversed; for example,
12779 @code{0xaabb} becomes @code{0xbbaa}.  Byte here always means
12780 exactly 8 bits.
12781 @end deftypefn
12783 @deftypefn {Built-in Function} uint32_t __builtin_bswap32 (uint32_t x)
12784 Similar to @code{__builtin_bswap16}, except the argument and return types
12785 are 32 bit.
12786 @end deftypefn
12788 @deftypefn {Built-in Function} uint64_t __builtin_bswap64 (uint64_t x)
12789 Similar to @code{__builtin_bswap32}, except the argument and return types
12790 are 64 bit.
12791 @end deftypefn
12793 @deftypefn {Built-in Function} Pmode __builtin_extend_pointer (void * x)
12794 On targets where the user visible pointer size is smaller than the size
12795 of an actual hardware address this function returns the extended user
12796 pointer.  Targets where this is true included ILP32 mode on x86_64 or
12797 Aarch64.  This function is mainly useful when writing inline assembly
12798 code.
12799 @end deftypefn
12801 @deftypefn {Built-in Function} int __builtin_goacc_parlevel_id (int x)
12802 Returns the openacc gang, worker or vector id depending on whether @var{x} is
12803 0, 1 or 2.
12804 @end deftypefn
12806 @deftypefn {Built-in Function} int __builtin_goacc_parlevel_size (int x)
12807 Returns the openacc gang, worker or vector size depending on whether @var{x} is
12808 0, 1 or 2.
12809 @end deftypefn
12811 @node Target Builtins
12812 @section Built-in Functions Specific to Particular Target Machines
12814 On some target machines, GCC supports many built-in functions specific
12815 to those machines.  Generally these generate calls to specific machine
12816 instructions, but allow the compiler to schedule those calls.
12818 @menu
12819 * AArch64 Built-in Functions::
12820 * Alpha Built-in Functions::
12821 * Altera Nios II Built-in Functions::
12822 * ARC Built-in Functions::
12823 * ARC SIMD Built-in Functions::
12824 * ARM iWMMXt Built-in Functions::
12825 * ARM C Language Extensions (ACLE)::
12826 * ARM Floating Point Status and Control Intrinsics::
12827 * ARM ARMv8-M Security Extensions::
12828 * AVR Built-in Functions::
12829 * Blackfin Built-in Functions::
12830 * FR-V Built-in Functions::
12831 * MIPS DSP Built-in Functions::
12832 * MIPS Paired-Single Support::
12833 * MIPS Loongson Built-in Functions::
12834 * MIPS SIMD Architecture (MSA) Support::
12835 * Other MIPS Built-in Functions::
12836 * MSP430 Built-in Functions::
12837 * NDS32 Built-in Functions::
12838 * picoChip Built-in Functions::
12839 * Basic PowerPC Built-in Functions::
12840 * PowerPC AltiVec/VSX Built-in Functions::
12841 * PowerPC Hardware Transactional Memory Built-in Functions::
12842 * PowerPC Atomic Memory Operation Functions::
12843 * RX Built-in Functions::
12844 * S/390 System z Built-in Functions::
12845 * SH Built-in Functions::
12846 * SPARC VIS Built-in Functions::
12847 * SPU Built-in Functions::
12848 * TI C6X Built-in Functions::
12849 * TILE-Gx Built-in Functions::
12850 * TILEPro Built-in Functions::
12851 * x86 Built-in Functions::
12852 * x86 transactional memory intrinsics::
12853 * x86 control-flow protection intrinsics::
12854 @end menu
12856 @node AArch64 Built-in Functions
12857 @subsection AArch64 Built-in Functions
12859 These built-in functions are available for the AArch64 family of
12860 processors.
12861 @smallexample
12862 unsigned int __builtin_aarch64_get_fpcr ()
12863 void __builtin_aarch64_set_fpcr (unsigned int)
12864 unsigned int __builtin_aarch64_get_fpsr ()
12865 void __builtin_aarch64_set_fpsr (unsigned int)
12866 @end smallexample
12868 @node Alpha Built-in Functions
12869 @subsection Alpha Built-in Functions
12871 These built-in functions are available for the Alpha family of
12872 processors, depending on the command-line switches used.
12874 The following built-in functions are always available.  They
12875 all generate the machine instruction that is part of the name.
12877 @smallexample
12878 long __builtin_alpha_implver (void)
12879 long __builtin_alpha_rpcc (void)
12880 long __builtin_alpha_amask (long)
12881 long __builtin_alpha_cmpbge (long, long)
12882 long __builtin_alpha_extbl (long, long)
12883 long __builtin_alpha_extwl (long, long)
12884 long __builtin_alpha_extll (long, long)
12885 long __builtin_alpha_extql (long, long)
12886 long __builtin_alpha_extwh (long, long)
12887 long __builtin_alpha_extlh (long, long)
12888 long __builtin_alpha_extqh (long, long)
12889 long __builtin_alpha_insbl (long, long)
12890 long __builtin_alpha_inswl (long, long)
12891 long __builtin_alpha_insll (long, long)
12892 long __builtin_alpha_insql (long, long)
12893 long __builtin_alpha_inswh (long, long)
12894 long __builtin_alpha_inslh (long, long)
12895 long __builtin_alpha_insqh (long, long)
12896 long __builtin_alpha_mskbl (long, long)
12897 long __builtin_alpha_mskwl (long, long)
12898 long __builtin_alpha_mskll (long, long)
12899 long __builtin_alpha_mskql (long, long)
12900 long __builtin_alpha_mskwh (long, long)
12901 long __builtin_alpha_msklh (long, long)
12902 long __builtin_alpha_mskqh (long, long)
12903 long __builtin_alpha_umulh (long, long)
12904 long __builtin_alpha_zap (long, long)
12905 long __builtin_alpha_zapnot (long, long)
12906 @end smallexample
12908 The following built-in functions are always with @option{-mmax}
12909 or @option{-mcpu=@var{cpu}} where @var{cpu} is @code{pca56} or
12910 later.  They all generate the machine instruction that is part
12911 of the name.
12913 @smallexample
12914 long __builtin_alpha_pklb (long)
12915 long __builtin_alpha_pkwb (long)
12916 long __builtin_alpha_unpkbl (long)
12917 long __builtin_alpha_unpkbw (long)
12918 long __builtin_alpha_minub8 (long, long)
12919 long __builtin_alpha_minsb8 (long, long)
12920 long __builtin_alpha_minuw4 (long, long)
12921 long __builtin_alpha_minsw4 (long, long)
12922 long __builtin_alpha_maxub8 (long, long)
12923 long __builtin_alpha_maxsb8 (long, long)
12924 long __builtin_alpha_maxuw4 (long, long)
12925 long __builtin_alpha_maxsw4 (long, long)
12926 long __builtin_alpha_perr (long, long)
12927 @end smallexample
12929 The following built-in functions are always with @option{-mcix}
12930 or @option{-mcpu=@var{cpu}} where @var{cpu} is @code{ev67} or
12931 later.  They all generate the machine instruction that is part
12932 of the name.
12934 @smallexample
12935 long __builtin_alpha_cttz (long)
12936 long __builtin_alpha_ctlz (long)
12937 long __builtin_alpha_ctpop (long)
12938 @end smallexample
12940 The following built-in functions are available on systems that use the OSF/1
12941 PALcode.  Normally they invoke the @code{rduniq} and @code{wruniq}
12942 PAL calls, but when invoked with @option{-mtls-kernel}, they invoke
12943 @code{rdval} and @code{wrval}.
12945 @smallexample
12946 void *__builtin_thread_pointer (void)
12947 void __builtin_set_thread_pointer (void *)
12948 @end smallexample
12950 @node Altera Nios II Built-in Functions
12951 @subsection Altera Nios II Built-in Functions
12953 These built-in functions are available for the Altera Nios II
12954 family of processors.
12956 The following built-in functions are always available.  They
12957 all generate the machine instruction that is part of the name.
12959 @example
12960 int __builtin_ldbio (volatile const void *)
12961 int __builtin_ldbuio (volatile const void *)
12962 int __builtin_ldhio (volatile const void *)
12963 int __builtin_ldhuio (volatile const void *)
12964 int __builtin_ldwio (volatile const void *)
12965 void __builtin_stbio (volatile void *, int)
12966 void __builtin_sthio (volatile void *, int)
12967 void __builtin_stwio (volatile void *, int)
12968 void __builtin_sync (void)
12969 int __builtin_rdctl (int) 
12970 int __builtin_rdprs (int, int)
12971 void __builtin_wrctl (int, int)
12972 void __builtin_flushd (volatile void *)
12973 void __builtin_flushda (volatile void *)
12974 int __builtin_wrpie (int);
12975 void __builtin_eni (int);
12976 int __builtin_ldex (volatile const void *)
12977 int __builtin_stex (volatile void *, int)
12978 int __builtin_ldsex (volatile const void *)
12979 int __builtin_stsex (volatile void *, int)
12980 @end example
12982 The following built-in functions are always available.  They
12983 all generate a Nios II Custom Instruction. The name of the
12984 function represents the types that the function takes and
12985 returns. The letter before the @code{n} is the return type
12986 or void if absent. The @code{n} represents the first parameter
12987 to all the custom instructions, the custom instruction number.
12988 The two letters after the @code{n} represent the up to two
12989 parameters to the function.
12991 The letters represent the following data types:
12992 @table @code
12993 @item <no letter>
12994 @code{void} for return type and no parameter for parameter types.
12996 @item i
12997 @code{int} for return type and parameter type
12999 @item f
13000 @code{float} for return type and parameter type
13002 @item p
13003 @code{void *} for return type and parameter type
13005 @end table
13007 And the function names are:
13008 @example
13009 void __builtin_custom_n (void)
13010 void __builtin_custom_ni (int)
13011 void __builtin_custom_nf (float)
13012 void __builtin_custom_np (void *)
13013 void __builtin_custom_nii (int, int)
13014 void __builtin_custom_nif (int, float)
13015 void __builtin_custom_nip (int, void *)
13016 void __builtin_custom_nfi (float, int)
13017 void __builtin_custom_nff (float, float)
13018 void __builtin_custom_nfp (float, void *)
13019 void __builtin_custom_npi (void *, int)
13020 void __builtin_custom_npf (void *, float)
13021 void __builtin_custom_npp (void *, void *)
13022 int __builtin_custom_in (void)
13023 int __builtin_custom_ini (int)
13024 int __builtin_custom_inf (float)
13025 int __builtin_custom_inp (void *)
13026 int __builtin_custom_inii (int, int)
13027 int __builtin_custom_inif (int, float)
13028 int __builtin_custom_inip (int, void *)
13029 int __builtin_custom_infi (float, int)
13030 int __builtin_custom_inff (float, float)
13031 int __builtin_custom_infp (float, void *)
13032 int __builtin_custom_inpi (void *, int)
13033 int __builtin_custom_inpf (void *, float)
13034 int __builtin_custom_inpp (void *, void *)
13035 float __builtin_custom_fn (void)
13036 float __builtin_custom_fni (int)
13037 float __builtin_custom_fnf (float)
13038 float __builtin_custom_fnp (void *)
13039 float __builtin_custom_fnii (int, int)
13040 float __builtin_custom_fnif (int, float)
13041 float __builtin_custom_fnip (int, void *)
13042 float __builtin_custom_fnfi (float, int)
13043 float __builtin_custom_fnff (float, float)
13044 float __builtin_custom_fnfp (float, void *)
13045 float __builtin_custom_fnpi (void *, int)
13046 float __builtin_custom_fnpf (void *, float)
13047 float __builtin_custom_fnpp (void *, void *)
13048 void * __builtin_custom_pn (void)
13049 void * __builtin_custom_pni (int)
13050 void * __builtin_custom_pnf (float)
13051 void * __builtin_custom_pnp (void *)
13052 void * __builtin_custom_pnii (int, int)
13053 void * __builtin_custom_pnif (int, float)
13054 void * __builtin_custom_pnip (int, void *)
13055 void * __builtin_custom_pnfi (float, int)
13056 void * __builtin_custom_pnff (float, float)
13057 void * __builtin_custom_pnfp (float, void *)
13058 void * __builtin_custom_pnpi (void *, int)
13059 void * __builtin_custom_pnpf (void *, float)
13060 void * __builtin_custom_pnpp (void *, void *)
13061 @end example
13063 @node ARC Built-in Functions
13064 @subsection ARC Built-in Functions
13066 The following built-in functions are provided for ARC targets.  The
13067 built-ins generate the corresponding assembly instructions.  In the
13068 examples given below, the generated code often requires an operand or
13069 result to be in a register.  Where necessary further code will be
13070 generated to ensure this is true, but for brevity this is not
13071 described in each case.
13073 @emph{Note:} Using a built-in to generate an instruction not supported
13074 by a target may cause problems. At present the compiler is not
13075 guaranteed to detect such misuse, and as a result an internal compiler
13076 error may be generated.
13078 @deftypefn {Built-in Function} int __builtin_arc_aligned (void *@var{val}, int @var{alignval})
13079 Return 1 if @var{val} is known to have the byte alignment given
13080 by @var{alignval}, otherwise return 0.
13081 Note that this is different from
13082 @smallexample
13083 __alignof__(*(char *)@var{val}) >= alignval
13084 @end smallexample
13085 because __alignof__ sees only the type of the dereference, whereas
13086 __builtin_arc_align uses alignment information from the pointer
13087 as well as from the pointed-to type.
13088 The information available will depend on optimization level.
13089 @end deftypefn
13091 @deftypefn {Built-in Function} void __builtin_arc_brk (void)
13092 Generates
13093 @example
13095 @end example
13096 @end deftypefn
13098 @deftypefn {Built-in Function} {unsigned int} __builtin_arc_core_read (unsigned int @var{regno})
13099 The operand is the number of a register to be read.  Generates:
13100 @example
13101 mov  @var{dest}, r@var{regno}
13102 @end example
13103 where the value in @var{dest} will be the result returned from the
13104 built-in.
13105 @end deftypefn
13107 @deftypefn {Built-in Function} void __builtin_arc_core_write (unsigned int @var{regno}, unsigned int @var{val})
13108 The first operand is the number of a register to be written, the
13109 second operand is a compile time constant to write into that
13110 register.  Generates:
13111 @example
13112 mov  r@var{regno}, @var{val}
13113 @end example
13114 @end deftypefn
13116 @deftypefn {Built-in Function} int __builtin_arc_divaw (int @var{a}, int @var{b})
13117 Only available if either @option{-mcpu=ARC700} or @option{-meA} is set.
13118 Generates:
13119 @example
13120 divaw  @var{dest}, @var{a}, @var{b}
13121 @end example
13122 where the value in @var{dest} will be the result returned from the
13123 built-in.
13124 @end deftypefn
13126 @deftypefn {Built-in Function} void __builtin_arc_flag (unsigned int @var{a})
13127 Generates
13128 @example
13129 flag  @var{a}
13130 @end example
13131 @end deftypefn
13133 @deftypefn {Built-in Function} {unsigned int} __builtin_arc_lr (unsigned int @var{auxr})
13134 The operand, @var{auxv}, is the address of an auxiliary register and
13135 must be a compile time constant.  Generates:
13136 @example
13137 lr  @var{dest}, [@var{auxr}]
13138 @end example
13139 Where the value in @var{dest} will be the result returned from the
13140 built-in.
13141 @end deftypefn
13143 @deftypefn {Built-in Function} void __builtin_arc_mul64 (int @var{a}, int @var{b})
13144 Only available with @option{-mmul64}.  Generates:
13145 @example
13146 mul64  @var{a}, @var{b}
13147 @end example
13148 @end deftypefn
13150 @deftypefn {Built-in Function} void __builtin_arc_mulu64 (unsigned int @var{a}, unsigned int @var{b})
13151 Only available with @option{-mmul64}.  Generates:
13152 @example
13153 mulu64  @var{a}, @var{b}
13154 @end example
13155 @end deftypefn
13157 @deftypefn {Built-in Function} void __builtin_arc_nop (void)
13158 Generates:
13159 @example
13161 @end example
13162 @end deftypefn
13164 @deftypefn {Built-in Function} int __builtin_arc_norm (int @var{src})
13165 Only valid if the @samp{norm} instruction is available through the
13166 @option{-mnorm} option or by default with @option{-mcpu=ARC700}.
13167 Generates:
13168 @example
13169 norm  @var{dest}, @var{src}
13170 @end example
13171 Where the value in @var{dest} will be the result returned from the
13172 built-in.
13173 @end deftypefn
13175 @deftypefn {Built-in Function}  {short int} __builtin_arc_normw (short int @var{src})
13176 Only valid if the @samp{normw} instruction is available through the
13177 @option{-mnorm} option or by default with @option{-mcpu=ARC700}.
13178 Generates:
13179 @example
13180 normw  @var{dest}, @var{src}
13181 @end example
13182 Where the value in @var{dest} will be the result returned from the
13183 built-in.
13184 @end deftypefn
13186 @deftypefn {Built-in Function}  void __builtin_arc_rtie (void)
13187 Generates:
13188 @example
13189 rtie
13190 @end example
13191 @end deftypefn
13193 @deftypefn {Built-in Function}  void __builtin_arc_sleep (int @var{a}
13194 Generates:
13195 @example
13196 sleep  @var{a}
13197 @end example
13198 @end deftypefn
13200 @deftypefn {Built-in Function}  void __builtin_arc_sr (unsigned int @var{auxr}, unsigned int @var{val})
13201 The first argument, @var{auxv}, is the address of an auxiliary
13202 register, the second argument, @var{val}, is a compile time constant
13203 to be written to the register.  Generates:
13204 @example
13205 sr  @var{auxr}, [@var{val}]
13206 @end example
13207 @end deftypefn
13209 @deftypefn {Built-in Function}  int __builtin_arc_swap (int @var{src})
13210 Only valid with @option{-mswap}.  Generates:
13211 @example
13212 swap  @var{dest}, @var{src}
13213 @end example
13214 Where the value in @var{dest} will be the result returned from the
13215 built-in.
13216 @end deftypefn
13218 @deftypefn {Built-in Function}  void __builtin_arc_swi (void)
13219 Generates:
13220 @example
13222 @end example
13223 @end deftypefn
13225 @deftypefn {Built-in Function}  void __builtin_arc_sync (void)
13226 Only available with @option{-mcpu=ARC700}.  Generates:
13227 @example
13228 sync
13229 @end example
13230 @end deftypefn
13232 @deftypefn {Built-in Function}  void __builtin_arc_trap_s (unsigned int @var{c})
13233 Only available with @option{-mcpu=ARC700}.  Generates:
13234 @example
13235 trap_s  @var{c}
13236 @end example
13237 @end deftypefn
13239 @deftypefn {Built-in Function}  void __builtin_arc_unimp_s (void)
13240 Only available with @option{-mcpu=ARC700}.  Generates:
13241 @example
13242 unimp_s
13243 @end example
13244 @end deftypefn
13246 The instructions generated by the following builtins are not
13247 considered as candidates for scheduling.  They are not moved around by
13248 the compiler during scheduling, and thus can be expected to appear
13249 where they are put in the C code:
13250 @example
13251 __builtin_arc_brk()
13252 __builtin_arc_core_read()
13253 __builtin_arc_core_write()
13254 __builtin_arc_flag()
13255 __builtin_arc_lr()
13256 __builtin_arc_sleep()
13257 __builtin_arc_sr()
13258 __builtin_arc_swi()
13259 @end example
13261 @node ARC SIMD Built-in Functions
13262 @subsection ARC SIMD Built-in Functions
13264 SIMD builtins provided by the compiler can be used to generate the
13265 vector instructions.  This section describes the available builtins
13266 and their usage in programs.  With the @option{-msimd} option, the
13267 compiler provides 128-bit vector types, which can be specified using
13268 the @code{vector_size} attribute.  The header file @file{arc-simd.h}
13269 can be included to use the following predefined types:
13270 @example
13271 typedef int __v4si   __attribute__((vector_size(16)));
13272 typedef short __v8hi __attribute__((vector_size(16)));
13273 @end example
13275 These types can be used to define 128-bit variables.  The built-in
13276 functions listed in the following section can be used on these
13277 variables to generate the vector operations.
13279 For all builtins, @code{__builtin_arc_@var{someinsn}}, the header file
13280 @file{arc-simd.h} also provides equivalent macros called
13281 @code{_@var{someinsn}} that can be used for programming ease and
13282 improved readability.  The following macros for DMA control are also
13283 provided:
13284 @example
13285 #define _setup_dma_in_channel_reg _vdiwr
13286 #define _setup_dma_out_channel_reg _vdowr
13287 @end example
13289 The following is a complete list of all the SIMD built-ins provided
13290 for ARC, grouped by calling signature.
13292 The following take two @code{__v8hi} arguments and return a
13293 @code{__v8hi} result:
13294 @example
13295 __v8hi __builtin_arc_vaddaw (__v8hi, __v8hi)
13296 __v8hi __builtin_arc_vaddw (__v8hi, __v8hi)
13297 __v8hi __builtin_arc_vand (__v8hi, __v8hi)
13298 __v8hi __builtin_arc_vandaw (__v8hi, __v8hi)
13299 __v8hi __builtin_arc_vavb (__v8hi, __v8hi)
13300 __v8hi __builtin_arc_vavrb (__v8hi, __v8hi)
13301 __v8hi __builtin_arc_vbic (__v8hi, __v8hi)
13302 __v8hi __builtin_arc_vbicaw (__v8hi, __v8hi)
13303 __v8hi __builtin_arc_vdifaw (__v8hi, __v8hi)
13304 __v8hi __builtin_arc_vdifw (__v8hi, __v8hi)
13305 __v8hi __builtin_arc_veqw (__v8hi, __v8hi)
13306 __v8hi __builtin_arc_vh264f (__v8hi, __v8hi)
13307 __v8hi __builtin_arc_vh264ft (__v8hi, __v8hi)
13308 __v8hi __builtin_arc_vh264fw (__v8hi, __v8hi)
13309 __v8hi __builtin_arc_vlew (__v8hi, __v8hi)
13310 __v8hi __builtin_arc_vltw (__v8hi, __v8hi)
13311 __v8hi __builtin_arc_vmaxaw (__v8hi, __v8hi)
13312 __v8hi __builtin_arc_vmaxw (__v8hi, __v8hi)
13313 __v8hi __builtin_arc_vminaw (__v8hi, __v8hi)
13314 __v8hi __builtin_arc_vminw (__v8hi, __v8hi)
13315 __v8hi __builtin_arc_vmr1aw (__v8hi, __v8hi)
13316 __v8hi __builtin_arc_vmr1w (__v8hi, __v8hi)
13317 __v8hi __builtin_arc_vmr2aw (__v8hi, __v8hi)
13318 __v8hi __builtin_arc_vmr2w (__v8hi, __v8hi)
13319 __v8hi __builtin_arc_vmr3aw (__v8hi, __v8hi)
13320 __v8hi __builtin_arc_vmr3w (__v8hi, __v8hi)
13321 __v8hi __builtin_arc_vmr4aw (__v8hi, __v8hi)
13322 __v8hi __builtin_arc_vmr4w (__v8hi, __v8hi)
13323 __v8hi __builtin_arc_vmr5aw (__v8hi, __v8hi)
13324 __v8hi __builtin_arc_vmr5w (__v8hi, __v8hi)
13325 __v8hi __builtin_arc_vmr6aw (__v8hi, __v8hi)
13326 __v8hi __builtin_arc_vmr6w (__v8hi, __v8hi)
13327 __v8hi __builtin_arc_vmr7aw (__v8hi, __v8hi)
13328 __v8hi __builtin_arc_vmr7w (__v8hi, __v8hi)
13329 __v8hi __builtin_arc_vmrb (__v8hi, __v8hi)
13330 __v8hi __builtin_arc_vmulaw (__v8hi, __v8hi)
13331 __v8hi __builtin_arc_vmulfaw (__v8hi, __v8hi)
13332 __v8hi __builtin_arc_vmulfw (__v8hi, __v8hi)
13333 __v8hi __builtin_arc_vmulw (__v8hi, __v8hi)
13334 __v8hi __builtin_arc_vnew (__v8hi, __v8hi)
13335 __v8hi __builtin_arc_vor (__v8hi, __v8hi)
13336 __v8hi __builtin_arc_vsubaw (__v8hi, __v8hi)
13337 __v8hi __builtin_arc_vsubw (__v8hi, __v8hi)
13338 __v8hi __builtin_arc_vsummw (__v8hi, __v8hi)
13339 __v8hi __builtin_arc_vvc1f (__v8hi, __v8hi)
13340 __v8hi __builtin_arc_vvc1ft (__v8hi, __v8hi)
13341 __v8hi __builtin_arc_vxor (__v8hi, __v8hi)
13342 __v8hi __builtin_arc_vxoraw (__v8hi, __v8hi)
13343 @end example
13345 The following take one @code{__v8hi} and one @code{int} argument and return a
13346 @code{__v8hi} result:
13348 @example
13349 __v8hi __builtin_arc_vbaddw (__v8hi, int)
13350 __v8hi __builtin_arc_vbmaxw (__v8hi, int)
13351 __v8hi __builtin_arc_vbminw (__v8hi, int)
13352 __v8hi __builtin_arc_vbmulaw (__v8hi, int)
13353 __v8hi __builtin_arc_vbmulfw (__v8hi, int)
13354 __v8hi __builtin_arc_vbmulw (__v8hi, int)
13355 __v8hi __builtin_arc_vbrsubw (__v8hi, int)
13356 __v8hi __builtin_arc_vbsubw (__v8hi, int)
13357 @end example
13359 The following take one @code{__v8hi} argument and one @code{int} argument which
13360 must be a 3-bit compile time constant indicating a register number
13361 I0-I7.  They return a @code{__v8hi} result.
13362 @example
13363 __v8hi __builtin_arc_vasrw (__v8hi, const int)
13364 __v8hi __builtin_arc_vsr8 (__v8hi, const int)
13365 __v8hi __builtin_arc_vsr8aw (__v8hi, const int)
13366 @end example
13368 The following take one @code{__v8hi} argument and one @code{int}
13369 argument which must be a 6-bit compile time constant.  They return a
13370 @code{__v8hi} result.
13371 @example
13372 __v8hi __builtin_arc_vasrpwbi (__v8hi, const int)
13373 __v8hi __builtin_arc_vasrrpwbi (__v8hi, const int)
13374 __v8hi __builtin_arc_vasrrwi (__v8hi, const int)
13375 __v8hi __builtin_arc_vasrsrwi (__v8hi, const int)
13376 __v8hi __builtin_arc_vasrwi (__v8hi, const int)
13377 __v8hi __builtin_arc_vsr8awi (__v8hi, const int)
13378 __v8hi __builtin_arc_vsr8i (__v8hi, const int)
13379 @end example
13381 The following take one @code{__v8hi} argument and one @code{int} argument which
13382 must be a 8-bit compile time constant.  They return a @code{__v8hi}
13383 result.
13384 @example
13385 __v8hi __builtin_arc_vd6tapf (__v8hi, const int)
13386 __v8hi __builtin_arc_vmvaw (__v8hi, const int)
13387 __v8hi __builtin_arc_vmvw (__v8hi, const int)
13388 __v8hi __builtin_arc_vmvzw (__v8hi, const int)
13389 @end example
13391 The following take two @code{int} arguments, the second of which which
13392 must be a 8-bit compile time constant.  They return a @code{__v8hi}
13393 result:
13394 @example
13395 __v8hi __builtin_arc_vmovaw (int, const int)
13396 __v8hi __builtin_arc_vmovw (int, const int)
13397 __v8hi __builtin_arc_vmovzw (int, const int)
13398 @end example
13400 The following take a single @code{__v8hi} argument and return a
13401 @code{__v8hi} result:
13402 @example
13403 __v8hi __builtin_arc_vabsaw (__v8hi)
13404 __v8hi __builtin_arc_vabsw (__v8hi)
13405 __v8hi __builtin_arc_vaddsuw (__v8hi)
13406 __v8hi __builtin_arc_vexch1 (__v8hi)
13407 __v8hi __builtin_arc_vexch2 (__v8hi)
13408 __v8hi __builtin_arc_vexch4 (__v8hi)
13409 __v8hi __builtin_arc_vsignw (__v8hi)
13410 __v8hi __builtin_arc_vupbaw (__v8hi)
13411 __v8hi __builtin_arc_vupbw (__v8hi)
13412 __v8hi __builtin_arc_vupsbaw (__v8hi)
13413 __v8hi __builtin_arc_vupsbw (__v8hi)
13414 @end example
13416 The following take two @code{int} arguments and return no result:
13417 @example
13418 void __builtin_arc_vdirun (int, int)
13419 void __builtin_arc_vdorun (int, int)
13420 @end example
13422 The following take two @code{int} arguments and return no result.  The
13423 first argument must a 3-bit compile time constant indicating one of
13424 the DR0-DR7 DMA setup channels:
13425 @example
13426 void __builtin_arc_vdiwr (const int, int)
13427 void __builtin_arc_vdowr (const int, int)
13428 @end example
13430 The following take an @code{int} argument and return no result:
13431 @example
13432 void __builtin_arc_vendrec (int)
13433 void __builtin_arc_vrec (int)
13434 void __builtin_arc_vrecrun (int)
13435 void __builtin_arc_vrun (int)
13436 @end example
13438 The following take a @code{__v8hi} argument and two @code{int}
13439 arguments and return a @code{__v8hi} result.  The second argument must
13440 be a 3-bit compile time constants, indicating one the registers I0-I7,
13441 and the third argument must be an 8-bit compile time constant.
13443 @emph{Note:} Although the equivalent hardware instructions do not take
13444 an SIMD register as an operand, these builtins overwrite the relevant
13445 bits of the @code{__v8hi} register provided as the first argument with
13446 the value loaded from the @code{[Ib, u8]} location in the SDM.
13448 @example
13449 __v8hi __builtin_arc_vld32 (__v8hi, const int, const int)
13450 __v8hi __builtin_arc_vld32wh (__v8hi, const int, const int)
13451 __v8hi __builtin_arc_vld32wl (__v8hi, const int, const int)
13452 __v8hi __builtin_arc_vld64 (__v8hi, const int, const int)
13453 @end example
13455 The following take two @code{int} arguments and return a @code{__v8hi}
13456 result.  The first argument must be a 3-bit compile time constants,
13457 indicating one the registers I0-I7, and the second argument must be an
13458 8-bit compile time constant.
13460 @example
13461 __v8hi __builtin_arc_vld128 (const int, const int)
13462 __v8hi __builtin_arc_vld64w (const int, const int)
13463 @end example
13465 The following take a @code{__v8hi} argument and two @code{int}
13466 arguments and return no result.  The second argument must be a 3-bit
13467 compile time constants, indicating one the registers I0-I7, and the
13468 third argument must be an 8-bit compile time constant.
13470 @example
13471 void __builtin_arc_vst128 (__v8hi, const int, const int)
13472 void __builtin_arc_vst64 (__v8hi, const int, const int)
13473 @end example
13475 The following take a @code{__v8hi} argument and three @code{int}
13476 arguments and return no result.  The second argument must be a 3-bit
13477 compile-time constant, identifying the 16-bit sub-register to be
13478 stored, the third argument must be a 3-bit compile time constants,
13479 indicating one the registers I0-I7, and the fourth argument must be an
13480 8-bit compile time constant.
13482 @example
13483 void __builtin_arc_vst16_n (__v8hi, const int, const int, const int)
13484 void __builtin_arc_vst32_n (__v8hi, const int, const int, const int)
13485 @end example
13487 @node ARM iWMMXt Built-in Functions
13488 @subsection ARM iWMMXt Built-in Functions
13490 These built-in functions are available for the ARM family of
13491 processors when the @option{-mcpu=iwmmxt} switch is used:
13493 @smallexample
13494 typedef int v2si __attribute__ ((vector_size (8)));
13495 typedef short v4hi __attribute__ ((vector_size (8)));
13496 typedef char v8qi __attribute__ ((vector_size (8)));
13498 int __builtin_arm_getwcgr0 (void)
13499 void __builtin_arm_setwcgr0 (int)
13500 int __builtin_arm_getwcgr1 (void)
13501 void __builtin_arm_setwcgr1 (int)
13502 int __builtin_arm_getwcgr2 (void)
13503 void __builtin_arm_setwcgr2 (int)
13504 int __builtin_arm_getwcgr3 (void)
13505 void __builtin_arm_setwcgr3 (int)
13506 int __builtin_arm_textrmsb (v8qi, int)
13507 int __builtin_arm_textrmsh (v4hi, int)
13508 int __builtin_arm_textrmsw (v2si, int)
13509 int __builtin_arm_textrmub (v8qi, int)
13510 int __builtin_arm_textrmuh (v4hi, int)
13511 int __builtin_arm_textrmuw (v2si, int)
13512 v8qi __builtin_arm_tinsrb (v8qi, int, int)
13513 v4hi __builtin_arm_tinsrh (v4hi, int, int)
13514 v2si __builtin_arm_tinsrw (v2si, int, int)
13515 long long __builtin_arm_tmia (long long, int, int)
13516 long long __builtin_arm_tmiabb (long long, int, int)
13517 long long __builtin_arm_tmiabt (long long, int, int)
13518 long long __builtin_arm_tmiaph (long long, int, int)
13519 long long __builtin_arm_tmiatb (long long, int, int)
13520 long long __builtin_arm_tmiatt (long long, int, int)
13521 int __builtin_arm_tmovmskb (v8qi)
13522 int __builtin_arm_tmovmskh (v4hi)
13523 int __builtin_arm_tmovmskw (v2si)
13524 long long __builtin_arm_waccb (v8qi)
13525 long long __builtin_arm_wacch (v4hi)
13526 long long __builtin_arm_waccw (v2si)
13527 v8qi __builtin_arm_waddb (v8qi, v8qi)
13528 v8qi __builtin_arm_waddbss (v8qi, v8qi)
13529 v8qi __builtin_arm_waddbus (v8qi, v8qi)
13530 v4hi __builtin_arm_waddh (v4hi, v4hi)
13531 v4hi __builtin_arm_waddhss (v4hi, v4hi)
13532 v4hi __builtin_arm_waddhus (v4hi, v4hi)
13533 v2si __builtin_arm_waddw (v2si, v2si)
13534 v2si __builtin_arm_waddwss (v2si, v2si)
13535 v2si __builtin_arm_waddwus (v2si, v2si)
13536 v8qi __builtin_arm_walign (v8qi, v8qi, int)
13537 long long __builtin_arm_wand(long long, long long)
13538 long long __builtin_arm_wandn (long long, long long)
13539 v8qi __builtin_arm_wavg2b (v8qi, v8qi)
13540 v8qi __builtin_arm_wavg2br (v8qi, v8qi)
13541 v4hi __builtin_arm_wavg2h (v4hi, v4hi)
13542 v4hi __builtin_arm_wavg2hr (v4hi, v4hi)
13543 v8qi __builtin_arm_wcmpeqb (v8qi, v8qi)
13544 v4hi __builtin_arm_wcmpeqh (v4hi, v4hi)
13545 v2si __builtin_arm_wcmpeqw (v2si, v2si)
13546 v8qi __builtin_arm_wcmpgtsb (v8qi, v8qi)
13547 v4hi __builtin_arm_wcmpgtsh (v4hi, v4hi)
13548 v2si __builtin_arm_wcmpgtsw (v2si, v2si)
13549 v8qi __builtin_arm_wcmpgtub (v8qi, v8qi)
13550 v4hi __builtin_arm_wcmpgtuh (v4hi, v4hi)
13551 v2si __builtin_arm_wcmpgtuw (v2si, v2si)
13552 long long __builtin_arm_wmacs (long long, v4hi, v4hi)
13553 long long __builtin_arm_wmacsz (v4hi, v4hi)
13554 long long __builtin_arm_wmacu (long long, v4hi, v4hi)
13555 long long __builtin_arm_wmacuz (v4hi, v4hi)
13556 v4hi __builtin_arm_wmadds (v4hi, v4hi)
13557 v4hi __builtin_arm_wmaddu (v4hi, v4hi)
13558 v8qi __builtin_arm_wmaxsb (v8qi, v8qi)
13559 v4hi __builtin_arm_wmaxsh (v4hi, v4hi)
13560 v2si __builtin_arm_wmaxsw (v2si, v2si)
13561 v8qi __builtin_arm_wmaxub (v8qi, v8qi)
13562 v4hi __builtin_arm_wmaxuh (v4hi, v4hi)
13563 v2si __builtin_arm_wmaxuw (v2si, v2si)
13564 v8qi __builtin_arm_wminsb (v8qi, v8qi)
13565 v4hi __builtin_arm_wminsh (v4hi, v4hi)
13566 v2si __builtin_arm_wminsw (v2si, v2si)
13567 v8qi __builtin_arm_wminub (v8qi, v8qi)
13568 v4hi __builtin_arm_wminuh (v4hi, v4hi)
13569 v2si __builtin_arm_wminuw (v2si, v2si)
13570 v4hi __builtin_arm_wmulsm (v4hi, v4hi)
13571 v4hi __builtin_arm_wmulul (v4hi, v4hi)
13572 v4hi __builtin_arm_wmulum (v4hi, v4hi)
13573 long long __builtin_arm_wor (long long, long long)
13574 v2si __builtin_arm_wpackdss (long long, long long)
13575 v2si __builtin_arm_wpackdus (long long, long long)
13576 v8qi __builtin_arm_wpackhss (v4hi, v4hi)
13577 v8qi __builtin_arm_wpackhus (v4hi, v4hi)
13578 v4hi __builtin_arm_wpackwss (v2si, v2si)
13579 v4hi __builtin_arm_wpackwus (v2si, v2si)
13580 long long __builtin_arm_wrord (long long, long long)
13581 long long __builtin_arm_wrordi (long long, int)
13582 v4hi __builtin_arm_wrorh (v4hi, long long)
13583 v4hi __builtin_arm_wrorhi (v4hi, int)
13584 v2si __builtin_arm_wrorw (v2si, long long)
13585 v2si __builtin_arm_wrorwi (v2si, int)
13586 v2si __builtin_arm_wsadb (v2si, v8qi, v8qi)
13587 v2si __builtin_arm_wsadbz (v8qi, v8qi)
13588 v2si __builtin_arm_wsadh (v2si, v4hi, v4hi)
13589 v2si __builtin_arm_wsadhz (v4hi, v4hi)
13590 v4hi __builtin_arm_wshufh (v4hi, int)
13591 long long __builtin_arm_wslld (long long, long long)
13592 long long __builtin_arm_wslldi (long long, int)
13593 v4hi __builtin_arm_wsllh (v4hi, long long)
13594 v4hi __builtin_arm_wsllhi (v4hi, int)
13595 v2si __builtin_arm_wsllw (v2si, long long)
13596 v2si __builtin_arm_wsllwi (v2si, int)
13597 long long __builtin_arm_wsrad (long long, long long)
13598 long long __builtin_arm_wsradi (long long, int)
13599 v4hi __builtin_arm_wsrah (v4hi, long long)
13600 v4hi __builtin_arm_wsrahi (v4hi, int)
13601 v2si __builtin_arm_wsraw (v2si, long long)
13602 v2si __builtin_arm_wsrawi (v2si, int)
13603 long long __builtin_arm_wsrld (long long, long long)
13604 long long __builtin_arm_wsrldi (long long, int)
13605 v4hi __builtin_arm_wsrlh (v4hi, long long)
13606 v4hi __builtin_arm_wsrlhi (v4hi, int)
13607 v2si __builtin_arm_wsrlw (v2si, long long)
13608 v2si __builtin_arm_wsrlwi (v2si, int)
13609 v8qi __builtin_arm_wsubb (v8qi, v8qi)
13610 v8qi __builtin_arm_wsubbss (v8qi, v8qi)
13611 v8qi __builtin_arm_wsubbus (v8qi, v8qi)
13612 v4hi __builtin_arm_wsubh (v4hi, v4hi)
13613 v4hi __builtin_arm_wsubhss (v4hi, v4hi)
13614 v4hi __builtin_arm_wsubhus (v4hi, v4hi)
13615 v2si __builtin_arm_wsubw (v2si, v2si)
13616 v2si __builtin_arm_wsubwss (v2si, v2si)
13617 v2si __builtin_arm_wsubwus (v2si, v2si)
13618 v4hi __builtin_arm_wunpckehsb (v8qi)
13619 v2si __builtin_arm_wunpckehsh (v4hi)
13620 long long __builtin_arm_wunpckehsw (v2si)
13621 v4hi __builtin_arm_wunpckehub (v8qi)
13622 v2si __builtin_arm_wunpckehuh (v4hi)
13623 long long __builtin_arm_wunpckehuw (v2si)
13624 v4hi __builtin_arm_wunpckelsb (v8qi)
13625 v2si __builtin_arm_wunpckelsh (v4hi)
13626 long long __builtin_arm_wunpckelsw (v2si)
13627 v4hi __builtin_arm_wunpckelub (v8qi)
13628 v2si __builtin_arm_wunpckeluh (v4hi)
13629 long long __builtin_arm_wunpckeluw (v2si)
13630 v8qi __builtin_arm_wunpckihb (v8qi, v8qi)
13631 v4hi __builtin_arm_wunpckihh (v4hi, v4hi)
13632 v2si __builtin_arm_wunpckihw (v2si, v2si)
13633 v8qi __builtin_arm_wunpckilb (v8qi, v8qi)
13634 v4hi __builtin_arm_wunpckilh (v4hi, v4hi)
13635 v2si __builtin_arm_wunpckilw (v2si, v2si)
13636 long long __builtin_arm_wxor (long long, long long)
13637 long long __builtin_arm_wzero ()
13638 @end smallexample
13641 @node ARM C Language Extensions (ACLE)
13642 @subsection ARM C Language Extensions (ACLE)
13644 GCC implements extensions for C as described in the ARM C Language
13645 Extensions (ACLE) specification, which can be found at
13646 @uref{http://infocenter.arm.com/help/topic/com.arm.doc.ihi0053c/IHI0053C_acle_2_0.pdf}.
13648 As a part of ACLE, GCC implements extensions for Advanced SIMD as described in
13649 the ARM C Language Extensions Specification.  The complete list of Advanced SIMD
13650 intrinsics can be found at
13651 @uref{http://infocenter.arm.com/help/topic/com.arm.doc.ihi0073a/IHI0073A_arm_neon_intrinsics_ref.pdf}.
13652 The built-in intrinsics for the Advanced SIMD extension are available when
13653 NEON is enabled.
13655 Currently, ARM and AArch64 back ends do not support ACLE 2.0 fully.  Both
13656 back ends support CRC32 intrinsics and the ARM back end supports the
13657 Coprocessor intrinsics, all from @file{arm_acle.h}.  The ARM back end's 16-bit
13658 floating-point Advanced SIMD intrinsics currently comply to ACLE v1.1.
13659 AArch64's back end does not have support for 16-bit floating point Advanced SIMD
13660 intrinsics yet.
13662 See @ref{ARM Options} and @ref{AArch64 Options} for more information on the
13663 availability of extensions.
13665 @node ARM Floating Point Status and Control Intrinsics
13666 @subsection ARM Floating Point Status and Control Intrinsics
13668 These built-in functions are available for the ARM family of
13669 processors with floating-point unit.
13671 @smallexample
13672 unsigned int __builtin_arm_get_fpscr ()
13673 void __builtin_arm_set_fpscr (unsigned int)
13674 @end smallexample
13676 @node ARM ARMv8-M Security Extensions
13677 @subsection ARM ARMv8-M Security Extensions
13679 GCC implements the ARMv8-M Security Extensions as described in the ARMv8-M
13680 Security Extensions: Requirements on Development Tools Engineering
13681 Specification, which can be found at
13682 @uref{http://infocenter.arm.com/help/topic/com.arm.doc.ecm0359818/ECM0359818_armv8m_security_extensions_reqs_on_dev_tools_1_0.pdf}.
13684 As part of the Security Extensions GCC implements two new function attributes:
13685 @code{cmse_nonsecure_entry} and @code{cmse_nonsecure_call}.
13687 As part of the Security Extensions GCC implements the intrinsics below.  FPTR
13688 is used here to mean any function pointer type.
13690 @smallexample
13691 cmse_address_info_t cmse_TT (void *)
13692 cmse_address_info_t cmse_TT_fptr (FPTR)
13693 cmse_address_info_t cmse_TTT (void *)
13694 cmse_address_info_t cmse_TTT_fptr (FPTR)
13695 cmse_address_info_t cmse_TTA (void *)
13696 cmse_address_info_t cmse_TTA_fptr (FPTR)
13697 cmse_address_info_t cmse_TTAT (void *)
13698 cmse_address_info_t cmse_TTAT_fptr (FPTR)
13699 void * cmse_check_address_range (void *, size_t, int)
13700 typeof(p) cmse_nsfptr_create (FPTR p)
13701 intptr_t cmse_is_nsfptr (FPTR)
13702 int cmse_nonsecure_caller (void)
13703 @end smallexample
13705 @node AVR Built-in Functions
13706 @subsection AVR Built-in Functions
13708 For each built-in function for AVR, there is an equally named,
13709 uppercase built-in macro defined. That way users can easily query if
13710 or if not a specific built-in is implemented or not. For example, if
13711 @code{__builtin_avr_nop} is available the macro
13712 @code{__BUILTIN_AVR_NOP} is defined to @code{1} and undefined otherwise.
13714 @table @code
13716 @item void __builtin_avr_nop (void)
13717 @itemx void __builtin_avr_sei (void)
13718 @itemx void __builtin_avr_cli (void)
13719 @itemx void __builtin_avr_sleep (void)
13720 @itemx void __builtin_avr_wdr (void)
13721 @itemx unsigned char __builtin_avr_swap (unsigned char)
13722 @itemx unsigned int __builtin_avr_fmul (unsigned char, unsigned char)
13723 @itemx int __builtin_avr_fmuls (char, char)
13724 @itemx int __builtin_avr_fmulsu (char, unsigned char)
13725 These built-in functions map to the respective machine
13726 instruction, i.e.@: @code{nop}, @code{sei}, @code{cli}, @code{sleep},
13727 @code{wdr}, @code{swap}, @code{fmul}, @code{fmuls}
13728 resp. @code{fmulsu}. The three @code{fmul*} built-ins are implemented
13729 as library call if no hardware multiplier is available.
13731 @item void __builtin_avr_delay_cycles (unsigned long ticks)
13732 Delay execution for @var{ticks} cycles. Note that this
13733 built-in does not take into account the effect of interrupts that
13734 might increase delay time. @var{ticks} must be a compile-time
13735 integer constant; delays with a variable number of cycles are not supported.
13737 @item char __builtin_avr_flash_segment (const __memx void*)
13738 This built-in takes a byte address to the 24-bit
13739 @ref{AVR Named Address Spaces,address space} @code{__memx} and returns
13740 the number of the flash segment (the 64 KiB chunk) where the address
13741 points to.  Counting starts at @code{0}.
13742 If the address does not point to flash memory, return @code{-1}.
13744 @item uint8_t __builtin_avr_insert_bits (uint32_t map, uint8_t bits, uint8_t val)
13745 Insert bits from @var{bits} into @var{val} and return the resulting
13746 value. The nibbles of @var{map} determine how the insertion is
13747 performed: Let @var{X} be the @var{n}-th nibble of @var{map}
13748 @enumerate
13749 @item If @var{X} is @code{0xf},
13750 then the @var{n}-th bit of @var{val} is returned unaltered.
13752 @item If X is in the range 0@dots{}7,
13753 then the @var{n}-th result bit is set to the @var{X}-th bit of @var{bits}
13755 @item If X is in the range 8@dots{}@code{0xe},
13756 then the @var{n}-th result bit is undefined.
13757 @end enumerate
13759 @noindent
13760 One typical use case for this built-in is adjusting input and
13761 output values to non-contiguous port layouts. Some examples:
13763 @smallexample
13764 // same as val, bits is unused
13765 __builtin_avr_insert_bits (0xffffffff, bits, val)
13766 @end smallexample
13768 @smallexample
13769 // same as bits, val is unused
13770 __builtin_avr_insert_bits (0x76543210, bits, val)
13771 @end smallexample
13773 @smallexample
13774 // same as rotating bits by 4
13775 __builtin_avr_insert_bits (0x32107654, bits, 0)
13776 @end smallexample
13778 @smallexample
13779 // high nibble of result is the high nibble of val
13780 // low nibble of result is the low nibble of bits
13781 __builtin_avr_insert_bits (0xffff3210, bits, val)
13782 @end smallexample
13784 @smallexample
13785 // reverse the bit order of bits
13786 __builtin_avr_insert_bits (0x01234567, bits, 0)
13787 @end smallexample
13789 @item void __builtin_avr_nops (unsigned count)
13790 Insert @var{count} @code{NOP} instructions.
13791 The number of instructions must be a compile-time integer constant.
13793 @end table
13795 @noindent
13796 There are many more AVR-specific built-in functions that are used to
13797 implement the ISO/IEC TR 18037 ``Embedded C'' fixed-point functions of
13798 section 7.18a.6.  You don't need to use these built-ins directly.
13799 Instead, use the declarations as supplied by the @code{stdfix.h} header
13800 with GNU-C99:
13802 @smallexample
13803 #include <stdfix.h>
13805 // Re-interpret the bit representation of unsigned 16-bit
13806 // integer @var{uval} as Q-format 0.16 value.
13807 unsigned fract get_bits (uint_ur_t uval)
13809     return urbits (uval);
13811 @end smallexample
13813 @node Blackfin Built-in Functions
13814 @subsection Blackfin Built-in Functions
13816 Currently, there are two Blackfin-specific built-in functions.  These are
13817 used for generating @code{CSYNC} and @code{SSYNC} machine insns without
13818 using inline assembly; by using these built-in functions the compiler can
13819 automatically add workarounds for hardware errata involving these
13820 instructions.  These functions are named as follows:
13822 @smallexample
13823 void __builtin_bfin_csync (void)
13824 void __builtin_bfin_ssync (void)
13825 @end smallexample
13827 @node FR-V Built-in Functions
13828 @subsection FR-V Built-in Functions
13830 GCC provides many FR-V-specific built-in functions.  In general,
13831 these functions are intended to be compatible with those described
13832 by @cite{FR-V Family, Softune C/C++ Compiler Manual (V6), Fujitsu
13833 Semiconductor}.  The two exceptions are @code{__MDUNPACKH} and
13834 @code{__MBTOHE}, the GCC forms of which pass 128-bit values by
13835 pointer rather than by value.
13837 Most of the functions are named after specific FR-V instructions.
13838 Such functions are said to be ``directly mapped'' and are summarized
13839 here in tabular form.
13841 @menu
13842 * Argument Types::
13843 * Directly-mapped Integer Functions::
13844 * Directly-mapped Media Functions::
13845 * Raw read/write Functions::
13846 * Other Built-in Functions::
13847 @end menu
13849 @node Argument Types
13850 @subsubsection Argument Types
13852 The arguments to the built-in functions can be divided into three groups:
13853 register numbers, compile-time constants and run-time values.  In order
13854 to make this classification clear at a glance, the arguments and return
13855 values are given the following pseudo types:
13857 @multitable @columnfractions .20 .30 .15 .35
13858 @item Pseudo type @tab Real C type @tab Constant? @tab Description
13859 @item @code{uh} @tab @code{unsigned short} @tab No @tab an unsigned halfword
13860 @item @code{uw1} @tab @code{unsigned int} @tab No @tab an unsigned word
13861 @item @code{sw1} @tab @code{int} @tab No @tab a signed word
13862 @item @code{uw2} @tab @code{unsigned long long} @tab No
13863 @tab an unsigned doubleword
13864 @item @code{sw2} @tab @code{long long} @tab No @tab a signed doubleword
13865 @item @code{const} @tab @code{int} @tab Yes @tab an integer constant
13866 @item @code{acc} @tab @code{int} @tab Yes @tab an ACC register number
13867 @item @code{iacc} @tab @code{int} @tab Yes @tab an IACC register number
13868 @end multitable
13870 These pseudo types are not defined by GCC, they are simply a notational
13871 convenience used in this manual.
13873 Arguments of type @code{uh}, @code{uw1}, @code{sw1}, @code{uw2}
13874 and @code{sw2} are evaluated at run time.  They correspond to
13875 register operands in the underlying FR-V instructions.
13877 @code{const} arguments represent immediate operands in the underlying
13878 FR-V instructions.  They must be compile-time constants.
13880 @code{acc} arguments are evaluated at compile time and specify the number
13881 of an accumulator register.  For example, an @code{acc} argument of 2
13882 selects the ACC2 register.
13884 @code{iacc} arguments are similar to @code{acc} arguments but specify the
13885 number of an IACC register.  See @pxref{Other Built-in Functions}
13886 for more details.
13888 @node Directly-mapped Integer Functions
13889 @subsubsection Directly-Mapped Integer Functions
13891 The functions listed below map directly to FR-V I-type instructions.
13893 @multitable @columnfractions .45 .32 .23
13894 @item Function prototype @tab Example usage @tab Assembly output
13895 @item @code{sw1 __ADDSS (sw1, sw1)}
13896 @tab @code{@var{c} = __ADDSS (@var{a}, @var{b})}
13897 @tab @code{ADDSS @var{a},@var{b},@var{c}}
13898 @item @code{sw1 __SCAN (sw1, sw1)}
13899 @tab @code{@var{c} = __SCAN (@var{a}, @var{b})}
13900 @tab @code{SCAN @var{a},@var{b},@var{c}}
13901 @item @code{sw1 __SCUTSS (sw1)}
13902 @tab @code{@var{b} = __SCUTSS (@var{a})}
13903 @tab @code{SCUTSS @var{a},@var{b}}
13904 @item @code{sw1 __SLASS (sw1, sw1)}
13905 @tab @code{@var{c} = __SLASS (@var{a}, @var{b})}
13906 @tab @code{SLASS @var{a},@var{b},@var{c}}
13907 @item @code{void __SMASS (sw1, sw1)}
13908 @tab @code{__SMASS (@var{a}, @var{b})}
13909 @tab @code{SMASS @var{a},@var{b}}
13910 @item @code{void __SMSSS (sw1, sw1)}
13911 @tab @code{__SMSSS (@var{a}, @var{b})}
13912 @tab @code{SMSSS @var{a},@var{b}}
13913 @item @code{void __SMU (sw1, sw1)}
13914 @tab @code{__SMU (@var{a}, @var{b})}
13915 @tab @code{SMU @var{a},@var{b}}
13916 @item @code{sw2 __SMUL (sw1, sw1)}
13917 @tab @code{@var{c} = __SMUL (@var{a}, @var{b})}
13918 @tab @code{SMUL @var{a},@var{b},@var{c}}
13919 @item @code{sw1 __SUBSS (sw1, sw1)}
13920 @tab @code{@var{c} = __SUBSS (@var{a}, @var{b})}
13921 @tab @code{SUBSS @var{a},@var{b},@var{c}}
13922 @item @code{uw2 __UMUL (uw1, uw1)}
13923 @tab @code{@var{c} = __UMUL (@var{a}, @var{b})}
13924 @tab @code{UMUL @var{a},@var{b},@var{c}}
13925 @end multitable
13927 @node Directly-mapped Media Functions
13928 @subsubsection Directly-Mapped Media Functions
13930 The functions listed below map directly to FR-V M-type instructions.
13932 @multitable @columnfractions .45 .32 .23
13933 @item Function prototype @tab Example usage @tab Assembly output
13934 @item @code{uw1 __MABSHS (sw1)}
13935 @tab @code{@var{b} = __MABSHS (@var{a})}
13936 @tab @code{MABSHS @var{a},@var{b}}
13937 @item @code{void __MADDACCS (acc, acc)}
13938 @tab @code{__MADDACCS (@var{b}, @var{a})}
13939 @tab @code{MADDACCS @var{a},@var{b}}
13940 @item @code{sw1 __MADDHSS (sw1, sw1)}
13941 @tab @code{@var{c} = __MADDHSS (@var{a}, @var{b})}
13942 @tab @code{MADDHSS @var{a},@var{b},@var{c}}
13943 @item @code{uw1 __MADDHUS (uw1, uw1)}
13944 @tab @code{@var{c} = __MADDHUS (@var{a}, @var{b})}
13945 @tab @code{MADDHUS @var{a},@var{b},@var{c}}
13946 @item @code{uw1 __MAND (uw1, uw1)}
13947 @tab @code{@var{c} = __MAND (@var{a}, @var{b})}
13948 @tab @code{MAND @var{a},@var{b},@var{c}}
13949 @item @code{void __MASACCS (acc, acc)}
13950 @tab @code{__MASACCS (@var{b}, @var{a})}
13951 @tab @code{MASACCS @var{a},@var{b}}
13952 @item @code{uw1 __MAVEH (uw1, uw1)}
13953 @tab @code{@var{c} = __MAVEH (@var{a}, @var{b})}
13954 @tab @code{MAVEH @var{a},@var{b},@var{c}}
13955 @item @code{uw2 __MBTOH (uw1)}
13956 @tab @code{@var{b} = __MBTOH (@var{a})}
13957 @tab @code{MBTOH @var{a},@var{b}}
13958 @item @code{void __MBTOHE (uw1 *, uw1)}
13959 @tab @code{__MBTOHE (&@var{b}, @var{a})}
13960 @tab @code{MBTOHE @var{a},@var{b}}
13961 @item @code{void __MCLRACC (acc)}
13962 @tab @code{__MCLRACC (@var{a})}
13963 @tab @code{MCLRACC @var{a}}
13964 @item @code{void __MCLRACCA (void)}
13965 @tab @code{__MCLRACCA ()}
13966 @tab @code{MCLRACCA}
13967 @item @code{uw1 __Mcop1 (uw1, uw1)}
13968 @tab @code{@var{c} = __Mcop1 (@var{a}, @var{b})}
13969 @tab @code{Mcop1 @var{a},@var{b},@var{c}}
13970 @item @code{uw1 __Mcop2 (uw1, uw1)}
13971 @tab @code{@var{c} = __Mcop2 (@var{a}, @var{b})}
13972 @tab @code{Mcop2 @var{a},@var{b},@var{c}}
13973 @item @code{uw1 __MCPLHI (uw2, const)}
13974 @tab @code{@var{c} = __MCPLHI (@var{a}, @var{b})}
13975 @tab @code{MCPLHI @var{a},#@var{b},@var{c}}
13976 @item @code{uw1 __MCPLI (uw2, const)}
13977 @tab @code{@var{c} = __MCPLI (@var{a}, @var{b})}
13978 @tab @code{MCPLI @var{a},#@var{b},@var{c}}
13979 @item @code{void __MCPXIS (acc, sw1, sw1)}
13980 @tab @code{__MCPXIS (@var{c}, @var{a}, @var{b})}
13981 @tab @code{MCPXIS @var{a},@var{b},@var{c}}
13982 @item @code{void __MCPXIU (acc, uw1, uw1)}
13983 @tab @code{__MCPXIU (@var{c}, @var{a}, @var{b})}
13984 @tab @code{MCPXIU @var{a},@var{b},@var{c}}
13985 @item @code{void __MCPXRS (acc, sw1, sw1)}
13986 @tab @code{__MCPXRS (@var{c}, @var{a}, @var{b})}
13987 @tab @code{MCPXRS @var{a},@var{b},@var{c}}
13988 @item @code{void __MCPXRU (acc, uw1, uw1)}
13989 @tab @code{__MCPXRU (@var{c}, @var{a}, @var{b})}
13990 @tab @code{MCPXRU @var{a},@var{b},@var{c}}
13991 @item @code{uw1 __MCUT (acc, uw1)}
13992 @tab @code{@var{c} = __MCUT (@var{a}, @var{b})}
13993 @tab @code{MCUT @var{a},@var{b},@var{c}}
13994 @item @code{uw1 __MCUTSS (acc, sw1)}
13995 @tab @code{@var{c} = __MCUTSS (@var{a}, @var{b})}
13996 @tab @code{MCUTSS @var{a},@var{b},@var{c}}
13997 @item @code{void __MDADDACCS (acc, acc)}
13998 @tab @code{__MDADDACCS (@var{b}, @var{a})}
13999 @tab @code{MDADDACCS @var{a},@var{b}}
14000 @item @code{void __MDASACCS (acc, acc)}
14001 @tab @code{__MDASACCS (@var{b}, @var{a})}
14002 @tab @code{MDASACCS @var{a},@var{b}}
14003 @item @code{uw2 __MDCUTSSI (acc, const)}
14004 @tab @code{@var{c} = __MDCUTSSI (@var{a}, @var{b})}
14005 @tab @code{MDCUTSSI @var{a},#@var{b},@var{c}}
14006 @item @code{uw2 __MDPACKH (uw2, uw2)}
14007 @tab @code{@var{c} = __MDPACKH (@var{a}, @var{b})}
14008 @tab @code{MDPACKH @var{a},@var{b},@var{c}}
14009 @item @code{uw2 __MDROTLI (uw2, const)}
14010 @tab @code{@var{c} = __MDROTLI (@var{a}, @var{b})}
14011 @tab @code{MDROTLI @var{a},#@var{b},@var{c}}
14012 @item @code{void __MDSUBACCS (acc, acc)}
14013 @tab @code{__MDSUBACCS (@var{b}, @var{a})}
14014 @tab @code{MDSUBACCS @var{a},@var{b}}
14015 @item @code{void __MDUNPACKH (uw1 *, uw2)}
14016 @tab @code{__MDUNPACKH (&@var{b}, @var{a})}
14017 @tab @code{MDUNPACKH @var{a},@var{b}}
14018 @item @code{uw2 __MEXPDHD (uw1, const)}
14019 @tab @code{@var{c} = __MEXPDHD (@var{a}, @var{b})}
14020 @tab @code{MEXPDHD @var{a},#@var{b},@var{c}}
14021 @item @code{uw1 __MEXPDHW (uw1, const)}
14022 @tab @code{@var{c} = __MEXPDHW (@var{a}, @var{b})}
14023 @tab @code{MEXPDHW @var{a},#@var{b},@var{c}}
14024 @item @code{uw1 __MHDSETH (uw1, const)}
14025 @tab @code{@var{c} = __MHDSETH (@var{a}, @var{b})}
14026 @tab @code{MHDSETH @var{a},#@var{b},@var{c}}
14027 @item @code{sw1 __MHDSETS (const)}
14028 @tab @code{@var{b} = __MHDSETS (@var{a})}
14029 @tab @code{MHDSETS #@var{a},@var{b}}
14030 @item @code{uw1 __MHSETHIH (uw1, const)}
14031 @tab @code{@var{b} = __MHSETHIH (@var{b}, @var{a})}
14032 @tab @code{MHSETHIH #@var{a},@var{b}}
14033 @item @code{sw1 __MHSETHIS (sw1, const)}
14034 @tab @code{@var{b} = __MHSETHIS (@var{b}, @var{a})}
14035 @tab @code{MHSETHIS #@var{a},@var{b}}
14036 @item @code{uw1 __MHSETLOH (uw1, const)}
14037 @tab @code{@var{b} = __MHSETLOH (@var{b}, @var{a})}
14038 @tab @code{MHSETLOH #@var{a},@var{b}}
14039 @item @code{sw1 __MHSETLOS (sw1, const)}
14040 @tab @code{@var{b} = __MHSETLOS (@var{b}, @var{a})}
14041 @tab @code{MHSETLOS #@var{a},@var{b}}
14042 @item @code{uw1 __MHTOB (uw2)}
14043 @tab @code{@var{b} = __MHTOB (@var{a})}
14044 @tab @code{MHTOB @var{a},@var{b}}
14045 @item @code{void __MMACHS (acc, sw1, sw1)}
14046 @tab @code{__MMACHS (@var{c}, @var{a}, @var{b})}
14047 @tab @code{MMACHS @var{a},@var{b},@var{c}}
14048 @item @code{void __MMACHU (acc, uw1, uw1)}
14049 @tab @code{__MMACHU (@var{c}, @var{a}, @var{b})}
14050 @tab @code{MMACHU @var{a},@var{b},@var{c}}
14051 @item @code{void __MMRDHS (acc, sw1, sw1)}
14052 @tab @code{__MMRDHS (@var{c}, @var{a}, @var{b})}
14053 @tab @code{MMRDHS @var{a},@var{b},@var{c}}
14054 @item @code{void __MMRDHU (acc, uw1, uw1)}
14055 @tab @code{__MMRDHU (@var{c}, @var{a}, @var{b})}
14056 @tab @code{MMRDHU @var{a},@var{b},@var{c}}
14057 @item @code{void __MMULHS (acc, sw1, sw1)}
14058 @tab @code{__MMULHS (@var{c}, @var{a}, @var{b})}
14059 @tab @code{MMULHS @var{a},@var{b},@var{c}}
14060 @item @code{void __MMULHU (acc, uw1, uw1)}
14061 @tab @code{__MMULHU (@var{c}, @var{a}, @var{b})}
14062 @tab @code{MMULHU @var{a},@var{b},@var{c}}
14063 @item @code{void __MMULXHS (acc, sw1, sw1)}
14064 @tab @code{__MMULXHS (@var{c}, @var{a}, @var{b})}
14065 @tab @code{MMULXHS @var{a},@var{b},@var{c}}
14066 @item @code{void __MMULXHU (acc, uw1, uw1)}
14067 @tab @code{__MMULXHU (@var{c}, @var{a}, @var{b})}
14068 @tab @code{MMULXHU @var{a},@var{b},@var{c}}
14069 @item @code{uw1 __MNOT (uw1)}
14070 @tab @code{@var{b} = __MNOT (@var{a})}
14071 @tab @code{MNOT @var{a},@var{b}}
14072 @item @code{uw1 __MOR (uw1, uw1)}
14073 @tab @code{@var{c} = __MOR (@var{a}, @var{b})}
14074 @tab @code{MOR @var{a},@var{b},@var{c}}
14075 @item @code{uw1 __MPACKH (uh, uh)}
14076 @tab @code{@var{c} = __MPACKH (@var{a}, @var{b})}
14077 @tab @code{MPACKH @var{a},@var{b},@var{c}}
14078 @item @code{sw2 __MQADDHSS (sw2, sw2)}
14079 @tab @code{@var{c} = __MQADDHSS (@var{a}, @var{b})}
14080 @tab @code{MQADDHSS @var{a},@var{b},@var{c}}
14081 @item @code{uw2 __MQADDHUS (uw2, uw2)}
14082 @tab @code{@var{c} = __MQADDHUS (@var{a}, @var{b})}
14083 @tab @code{MQADDHUS @var{a},@var{b},@var{c}}
14084 @item @code{void __MQCPXIS (acc, sw2, sw2)}
14085 @tab @code{__MQCPXIS (@var{c}, @var{a}, @var{b})}
14086 @tab @code{MQCPXIS @var{a},@var{b},@var{c}}
14087 @item @code{void __MQCPXIU (acc, uw2, uw2)}
14088 @tab @code{__MQCPXIU (@var{c}, @var{a}, @var{b})}
14089 @tab @code{MQCPXIU @var{a},@var{b},@var{c}}
14090 @item @code{void __MQCPXRS (acc, sw2, sw2)}
14091 @tab @code{__MQCPXRS (@var{c}, @var{a}, @var{b})}
14092 @tab @code{MQCPXRS @var{a},@var{b},@var{c}}
14093 @item @code{void __MQCPXRU (acc, uw2, uw2)}
14094 @tab @code{__MQCPXRU (@var{c}, @var{a}, @var{b})}
14095 @tab @code{MQCPXRU @var{a},@var{b},@var{c}}
14096 @item @code{sw2 __MQLCLRHS (sw2, sw2)}
14097 @tab @code{@var{c} = __MQLCLRHS (@var{a}, @var{b})}
14098 @tab @code{MQLCLRHS @var{a},@var{b},@var{c}}
14099 @item @code{sw2 __MQLMTHS (sw2, sw2)}
14100 @tab @code{@var{c} = __MQLMTHS (@var{a}, @var{b})}
14101 @tab @code{MQLMTHS @var{a},@var{b},@var{c}}
14102 @item @code{void __MQMACHS (acc, sw2, sw2)}
14103 @tab @code{__MQMACHS (@var{c}, @var{a}, @var{b})}
14104 @tab @code{MQMACHS @var{a},@var{b},@var{c}}
14105 @item @code{void __MQMACHU (acc, uw2, uw2)}
14106 @tab @code{__MQMACHU (@var{c}, @var{a}, @var{b})}
14107 @tab @code{MQMACHU @var{a},@var{b},@var{c}}
14108 @item @code{void __MQMACXHS (acc, sw2, sw2)}
14109 @tab @code{__MQMACXHS (@var{c}, @var{a}, @var{b})}
14110 @tab @code{MQMACXHS @var{a},@var{b},@var{c}}
14111 @item @code{void __MQMULHS (acc, sw2, sw2)}
14112 @tab @code{__MQMULHS (@var{c}, @var{a}, @var{b})}
14113 @tab @code{MQMULHS @var{a},@var{b},@var{c}}
14114 @item @code{void __MQMULHU (acc, uw2, uw2)}
14115 @tab @code{__MQMULHU (@var{c}, @var{a}, @var{b})}
14116 @tab @code{MQMULHU @var{a},@var{b},@var{c}}
14117 @item @code{void __MQMULXHS (acc, sw2, sw2)}
14118 @tab @code{__MQMULXHS (@var{c}, @var{a}, @var{b})}
14119 @tab @code{MQMULXHS @var{a},@var{b},@var{c}}
14120 @item @code{void __MQMULXHU (acc, uw2, uw2)}
14121 @tab @code{__MQMULXHU (@var{c}, @var{a}, @var{b})}
14122 @tab @code{MQMULXHU @var{a},@var{b},@var{c}}
14123 @item @code{sw2 __MQSATHS (sw2, sw2)}
14124 @tab @code{@var{c} = __MQSATHS (@var{a}, @var{b})}
14125 @tab @code{MQSATHS @var{a},@var{b},@var{c}}
14126 @item @code{uw2 __MQSLLHI (uw2, int)}
14127 @tab @code{@var{c} = __MQSLLHI (@var{a}, @var{b})}
14128 @tab @code{MQSLLHI @var{a},@var{b},@var{c}}
14129 @item @code{sw2 __MQSRAHI (sw2, int)}
14130 @tab @code{@var{c} = __MQSRAHI (@var{a}, @var{b})}
14131 @tab @code{MQSRAHI @var{a},@var{b},@var{c}}
14132 @item @code{sw2 __MQSUBHSS (sw2, sw2)}
14133 @tab @code{@var{c} = __MQSUBHSS (@var{a}, @var{b})}
14134 @tab @code{MQSUBHSS @var{a},@var{b},@var{c}}
14135 @item @code{uw2 __MQSUBHUS (uw2, uw2)}
14136 @tab @code{@var{c} = __MQSUBHUS (@var{a}, @var{b})}
14137 @tab @code{MQSUBHUS @var{a},@var{b},@var{c}}
14138 @item @code{void __MQXMACHS (acc, sw2, sw2)}
14139 @tab @code{__MQXMACHS (@var{c}, @var{a}, @var{b})}
14140 @tab @code{MQXMACHS @var{a},@var{b},@var{c}}
14141 @item @code{void __MQXMACXHS (acc, sw2, sw2)}
14142 @tab @code{__MQXMACXHS (@var{c}, @var{a}, @var{b})}
14143 @tab @code{MQXMACXHS @var{a},@var{b},@var{c}}
14144 @item @code{uw1 __MRDACC (acc)}
14145 @tab @code{@var{b} = __MRDACC (@var{a})}
14146 @tab @code{MRDACC @var{a},@var{b}}
14147 @item @code{uw1 __MRDACCG (acc)}
14148 @tab @code{@var{b} = __MRDACCG (@var{a})}
14149 @tab @code{MRDACCG @var{a},@var{b}}
14150 @item @code{uw1 __MROTLI (uw1, const)}
14151 @tab @code{@var{c} = __MROTLI (@var{a}, @var{b})}
14152 @tab @code{MROTLI @var{a},#@var{b},@var{c}}
14153 @item @code{uw1 __MROTRI (uw1, const)}
14154 @tab @code{@var{c} = __MROTRI (@var{a}, @var{b})}
14155 @tab @code{MROTRI @var{a},#@var{b},@var{c}}
14156 @item @code{sw1 __MSATHS (sw1, sw1)}
14157 @tab @code{@var{c} = __MSATHS (@var{a}, @var{b})}
14158 @tab @code{MSATHS @var{a},@var{b},@var{c}}
14159 @item @code{uw1 __MSATHU (uw1, uw1)}
14160 @tab @code{@var{c} = __MSATHU (@var{a}, @var{b})}
14161 @tab @code{MSATHU @var{a},@var{b},@var{c}}
14162 @item @code{uw1 __MSLLHI (uw1, const)}
14163 @tab @code{@var{c} = __MSLLHI (@var{a}, @var{b})}
14164 @tab @code{MSLLHI @var{a},#@var{b},@var{c}}
14165 @item @code{sw1 __MSRAHI (sw1, const)}
14166 @tab @code{@var{c} = __MSRAHI (@var{a}, @var{b})}
14167 @tab @code{MSRAHI @var{a},#@var{b},@var{c}}
14168 @item @code{uw1 __MSRLHI (uw1, const)}
14169 @tab @code{@var{c} = __MSRLHI (@var{a}, @var{b})}
14170 @tab @code{MSRLHI @var{a},#@var{b},@var{c}}
14171 @item @code{void __MSUBACCS (acc, acc)}
14172 @tab @code{__MSUBACCS (@var{b}, @var{a})}
14173 @tab @code{MSUBACCS @var{a},@var{b}}
14174 @item @code{sw1 __MSUBHSS (sw1, sw1)}
14175 @tab @code{@var{c} = __MSUBHSS (@var{a}, @var{b})}
14176 @tab @code{MSUBHSS @var{a},@var{b},@var{c}}
14177 @item @code{uw1 __MSUBHUS (uw1, uw1)}
14178 @tab @code{@var{c} = __MSUBHUS (@var{a}, @var{b})}
14179 @tab @code{MSUBHUS @var{a},@var{b},@var{c}}
14180 @item @code{void __MTRAP (void)}
14181 @tab @code{__MTRAP ()}
14182 @tab @code{MTRAP}
14183 @item @code{uw2 __MUNPACKH (uw1)}
14184 @tab @code{@var{b} = __MUNPACKH (@var{a})}
14185 @tab @code{MUNPACKH @var{a},@var{b}}
14186 @item @code{uw1 __MWCUT (uw2, uw1)}
14187 @tab @code{@var{c} = __MWCUT (@var{a}, @var{b})}
14188 @tab @code{MWCUT @var{a},@var{b},@var{c}}
14189 @item @code{void __MWTACC (acc, uw1)}
14190 @tab @code{__MWTACC (@var{b}, @var{a})}
14191 @tab @code{MWTACC @var{a},@var{b}}
14192 @item @code{void __MWTACCG (acc, uw1)}
14193 @tab @code{__MWTACCG (@var{b}, @var{a})}
14194 @tab @code{MWTACCG @var{a},@var{b}}
14195 @item @code{uw1 __MXOR (uw1, uw1)}
14196 @tab @code{@var{c} = __MXOR (@var{a}, @var{b})}
14197 @tab @code{MXOR @var{a},@var{b},@var{c}}
14198 @end multitable
14200 @node Raw read/write Functions
14201 @subsubsection Raw Read/Write Functions
14203 This sections describes built-in functions related to read and write
14204 instructions to access memory.  These functions generate
14205 @code{membar} instructions to flush the I/O load and stores where
14206 appropriate, as described in Fujitsu's manual described above.
14208 @table @code
14210 @item unsigned char __builtin_read8 (void *@var{data})
14211 @item unsigned short __builtin_read16 (void *@var{data})
14212 @item unsigned long __builtin_read32 (void *@var{data})
14213 @item unsigned long long __builtin_read64 (void *@var{data})
14215 @item void __builtin_write8 (void *@var{data}, unsigned char @var{datum})
14216 @item void __builtin_write16 (void *@var{data}, unsigned short @var{datum})
14217 @item void __builtin_write32 (void *@var{data}, unsigned long @var{datum})
14218 @item void __builtin_write64 (void *@var{data}, unsigned long long @var{datum})
14219 @end table
14221 @node Other Built-in Functions
14222 @subsubsection Other Built-in Functions
14224 This section describes built-in functions that are not named after
14225 a specific FR-V instruction.
14227 @table @code
14228 @item sw2 __IACCreadll (iacc @var{reg})
14229 Return the full 64-bit value of IACC0@.  The @var{reg} argument is reserved
14230 for future expansion and must be 0.
14232 @item sw1 __IACCreadl (iacc @var{reg})
14233 Return the value of IACC0H if @var{reg} is 0 and IACC0L if @var{reg} is 1.
14234 Other values of @var{reg} are rejected as invalid.
14236 @item void __IACCsetll (iacc @var{reg}, sw2 @var{x})
14237 Set the full 64-bit value of IACC0 to @var{x}.  The @var{reg} argument
14238 is reserved for future expansion and must be 0.
14240 @item void __IACCsetl (iacc @var{reg}, sw1 @var{x})
14241 Set IACC0H to @var{x} if @var{reg} is 0 and IACC0L to @var{x} if @var{reg}
14242 is 1.  Other values of @var{reg} are rejected as invalid.
14244 @item void __data_prefetch0 (const void *@var{x})
14245 Use the @code{dcpl} instruction to load the contents of address @var{x}
14246 into the data cache.
14248 @item void __data_prefetch (const void *@var{x})
14249 Use the @code{nldub} instruction to load the contents of address @var{x}
14250 into the data cache.  The instruction is issued in slot I1@.
14251 @end table
14253 @node MIPS DSP Built-in Functions
14254 @subsection MIPS DSP Built-in Functions
14256 The MIPS DSP Application-Specific Extension (ASE) includes new
14257 instructions that are designed to improve the performance of DSP and
14258 media applications.  It provides instructions that operate on packed
14259 8-bit/16-bit integer data, Q7, Q15 and Q31 fractional data.
14261 GCC supports MIPS DSP operations using both the generic
14262 vector extensions (@pxref{Vector Extensions}) and a collection of
14263 MIPS-specific built-in functions.  Both kinds of support are
14264 enabled by the @option{-mdsp} command-line option.
14266 Revision 2 of the ASE was introduced in the second half of 2006.
14267 This revision adds extra instructions to the original ASE, but is
14268 otherwise backwards-compatible with it.  You can select revision 2
14269 using the command-line option @option{-mdspr2}; this option implies
14270 @option{-mdsp}.
14272 The SCOUNT and POS bits of the DSP control register are global.  The
14273 WRDSP, EXTPDP, EXTPDPV and MTHLIP instructions modify the SCOUNT and
14274 POS bits.  During optimization, the compiler does not delete these
14275 instructions and it does not delete calls to functions containing
14276 these instructions.
14278 At present, GCC only provides support for operations on 32-bit
14279 vectors.  The vector type associated with 8-bit integer data is
14280 usually called @code{v4i8}, the vector type associated with Q7
14281 is usually called @code{v4q7}, the vector type associated with 16-bit
14282 integer data is usually called @code{v2i16}, and the vector type
14283 associated with Q15 is usually called @code{v2q15}.  They can be
14284 defined in C as follows:
14286 @smallexample
14287 typedef signed char v4i8 __attribute__ ((vector_size(4)));
14288 typedef signed char v4q7 __attribute__ ((vector_size(4)));
14289 typedef short v2i16 __attribute__ ((vector_size(4)));
14290 typedef short v2q15 __attribute__ ((vector_size(4)));
14291 @end smallexample
14293 @code{v4i8}, @code{v4q7}, @code{v2i16} and @code{v2q15} values are
14294 initialized in the same way as aggregates.  For example:
14296 @smallexample
14297 v4i8 a = @{1, 2, 3, 4@};
14298 v4i8 b;
14299 b = (v4i8) @{5, 6, 7, 8@};
14301 v2q15 c = @{0x0fcb, 0x3a75@};
14302 v2q15 d;
14303 d = (v2q15) @{0.1234 * 0x1.0p15, 0.4567 * 0x1.0p15@};
14304 @end smallexample
14306 @emph{Note:} The CPU's endianness determines the order in which values
14307 are packed.  On little-endian targets, the first value is the least
14308 significant and the last value is the most significant.  The opposite
14309 order applies to big-endian targets.  For example, the code above
14310 sets the lowest byte of @code{a} to @code{1} on little-endian targets
14311 and @code{4} on big-endian targets.
14313 @emph{Note:} Q7, Q15 and Q31 values must be initialized with their integer
14314 representation.  As shown in this example, the integer representation
14315 of a Q7 value can be obtained by multiplying the fractional value by
14316 @code{0x1.0p7}.  The equivalent for Q15 values is to multiply by
14317 @code{0x1.0p15}.  The equivalent for Q31 values is to multiply by
14318 @code{0x1.0p31}.
14320 The table below lists the @code{v4i8} and @code{v2q15} operations for which
14321 hardware support exists.  @code{a} and @code{b} are @code{v4i8} values,
14322 and @code{c} and @code{d} are @code{v2q15} values.
14324 @multitable @columnfractions .50 .50
14325 @item C code @tab MIPS instruction
14326 @item @code{a + b} @tab @code{addu.qb}
14327 @item @code{c + d} @tab @code{addq.ph}
14328 @item @code{a - b} @tab @code{subu.qb}
14329 @item @code{c - d} @tab @code{subq.ph}
14330 @end multitable
14332 The table below lists the @code{v2i16} operation for which
14333 hardware support exists for the DSP ASE REV 2.  @code{e} and @code{f} are
14334 @code{v2i16} values.
14336 @multitable @columnfractions .50 .50
14337 @item C code @tab MIPS instruction
14338 @item @code{e * f} @tab @code{mul.ph}
14339 @end multitable
14341 It is easier to describe the DSP built-in functions if we first define
14342 the following types:
14344 @smallexample
14345 typedef int q31;
14346 typedef int i32;
14347 typedef unsigned int ui32;
14348 typedef long long a64;
14349 @end smallexample
14351 @code{q31} and @code{i32} are actually the same as @code{int}, but we
14352 use @code{q31} to indicate a Q31 fractional value and @code{i32} to
14353 indicate a 32-bit integer value.  Similarly, @code{a64} is the same as
14354 @code{long long}, but we use @code{a64} to indicate values that are
14355 placed in one of the four DSP accumulators (@code{$ac0},
14356 @code{$ac1}, @code{$ac2} or @code{$ac3}).
14358 Also, some built-in functions prefer or require immediate numbers as
14359 parameters, because the corresponding DSP instructions accept both immediate
14360 numbers and register operands, or accept immediate numbers only.  The
14361 immediate parameters are listed as follows.
14363 @smallexample
14364 imm0_3: 0 to 3.
14365 imm0_7: 0 to 7.
14366 imm0_15: 0 to 15.
14367 imm0_31: 0 to 31.
14368 imm0_63: 0 to 63.
14369 imm0_255: 0 to 255.
14370 imm_n32_31: -32 to 31.
14371 imm_n512_511: -512 to 511.
14372 @end smallexample
14374 The following built-in functions map directly to a particular MIPS DSP
14375 instruction.  Please refer to the architecture specification
14376 for details on what each instruction does.
14378 @smallexample
14379 v2q15 __builtin_mips_addq_ph (v2q15, v2q15)
14380 v2q15 __builtin_mips_addq_s_ph (v2q15, v2q15)
14381 q31 __builtin_mips_addq_s_w (q31, q31)
14382 v4i8 __builtin_mips_addu_qb (v4i8, v4i8)
14383 v4i8 __builtin_mips_addu_s_qb (v4i8, v4i8)
14384 v2q15 __builtin_mips_subq_ph (v2q15, v2q15)
14385 v2q15 __builtin_mips_subq_s_ph (v2q15, v2q15)
14386 q31 __builtin_mips_subq_s_w (q31, q31)
14387 v4i8 __builtin_mips_subu_qb (v4i8, v4i8)
14388 v4i8 __builtin_mips_subu_s_qb (v4i8, v4i8)
14389 i32 __builtin_mips_addsc (i32, i32)
14390 i32 __builtin_mips_addwc (i32, i32)
14391 i32 __builtin_mips_modsub (i32, i32)
14392 i32 __builtin_mips_raddu_w_qb (v4i8)
14393 v2q15 __builtin_mips_absq_s_ph (v2q15)
14394 q31 __builtin_mips_absq_s_w (q31)
14395 v4i8 __builtin_mips_precrq_qb_ph (v2q15, v2q15)
14396 v2q15 __builtin_mips_precrq_ph_w (q31, q31)
14397 v2q15 __builtin_mips_precrq_rs_ph_w (q31, q31)
14398 v4i8 __builtin_mips_precrqu_s_qb_ph (v2q15, v2q15)
14399 q31 __builtin_mips_preceq_w_phl (v2q15)
14400 q31 __builtin_mips_preceq_w_phr (v2q15)
14401 v2q15 __builtin_mips_precequ_ph_qbl (v4i8)
14402 v2q15 __builtin_mips_precequ_ph_qbr (v4i8)
14403 v2q15 __builtin_mips_precequ_ph_qbla (v4i8)
14404 v2q15 __builtin_mips_precequ_ph_qbra (v4i8)
14405 v2q15 __builtin_mips_preceu_ph_qbl (v4i8)
14406 v2q15 __builtin_mips_preceu_ph_qbr (v4i8)
14407 v2q15 __builtin_mips_preceu_ph_qbla (v4i8)
14408 v2q15 __builtin_mips_preceu_ph_qbra (v4i8)
14409 v4i8 __builtin_mips_shll_qb (v4i8, imm0_7)
14410 v4i8 __builtin_mips_shll_qb (v4i8, i32)
14411 v2q15 __builtin_mips_shll_ph (v2q15, imm0_15)
14412 v2q15 __builtin_mips_shll_ph (v2q15, i32)
14413 v2q15 __builtin_mips_shll_s_ph (v2q15, imm0_15)
14414 v2q15 __builtin_mips_shll_s_ph (v2q15, i32)
14415 q31 __builtin_mips_shll_s_w (q31, imm0_31)
14416 q31 __builtin_mips_shll_s_w (q31, i32)
14417 v4i8 __builtin_mips_shrl_qb (v4i8, imm0_7)
14418 v4i8 __builtin_mips_shrl_qb (v4i8, i32)
14419 v2q15 __builtin_mips_shra_ph (v2q15, imm0_15)
14420 v2q15 __builtin_mips_shra_ph (v2q15, i32)
14421 v2q15 __builtin_mips_shra_r_ph (v2q15, imm0_15)
14422 v2q15 __builtin_mips_shra_r_ph (v2q15, i32)
14423 q31 __builtin_mips_shra_r_w (q31, imm0_31)
14424 q31 __builtin_mips_shra_r_w (q31, i32)
14425 v2q15 __builtin_mips_muleu_s_ph_qbl (v4i8, v2q15)
14426 v2q15 __builtin_mips_muleu_s_ph_qbr (v4i8, v2q15)
14427 v2q15 __builtin_mips_mulq_rs_ph (v2q15, v2q15)
14428 q31 __builtin_mips_muleq_s_w_phl (v2q15, v2q15)
14429 q31 __builtin_mips_muleq_s_w_phr (v2q15, v2q15)
14430 a64 __builtin_mips_dpau_h_qbl (a64, v4i8, v4i8)
14431 a64 __builtin_mips_dpau_h_qbr (a64, v4i8, v4i8)
14432 a64 __builtin_mips_dpsu_h_qbl (a64, v4i8, v4i8)
14433 a64 __builtin_mips_dpsu_h_qbr (a64, v4i8, v4i8)
14434 a64 __builtin_mips_dpaq_s_w_ph (a64, v2q15, v2q15)
14435 a64 __builtin_mips_dpaq_sa_l_w (a64, q31, q31)
14436 a64 __builtin_mips_dpsq_s_w_ph (a64, v2q15, v2q15)
14437 a64 __builtin_mips_dpsq_sa_l_w (a64, q31, q31)
14438 a64 __builtin_mips_mulsaq_s_w_ph (a64, v2q15, v2q15)
14439 a64 __builtin_mips_maq_s_w_phl (a64, v2q15, v2q15)
14440 a64 __builtin_mips_maq_s_w_phr (a64, v2q15, v2q15)
14441 a64 __builtin_mips_maq_sa_w_phl (a64, v2q15, v2q15)
14442 a64 __builtin_mips_maq_sa_w_phr (a64, v2q15, v2q15)
14443 i32 __builtin_mips_bitrev (i32)
14444 i32 __builtin_mips_insv (i32, i32)
14445 v4i8 __builtin_mips_repl_qb (imm0_255)
14446 v4i8 __builtin_mips_repl_qb (i32)
14447 v2q15 __builtin_mips_repl_ph (imm_n512_511)
14448 v2q15 __builtin_mips_repl_ph (i32)
14449 void __builtin_mips_cmpu_eq_qb (v4i8, v4i8)
14450 void __builtin_mips_cmpu_lt_qb (v4i8, v4i8)
14451 void __builtin_mips_cmpu_le_qb (v4i8, v4i8)
14452 i32 __builtin_mips_cmpgu_eq_qb (v4i8, v4i8)
14453 i32 __builtin_mips_cmpgu_lt_qb (v4i8, v4i8)
14454 i32 __builtin_mips_cmpgu_le_qb (v4i8, v4i8)
14455 void __builtin_mips_cmp_eq_ph (v2q15, v2q15)
14456 void __builtin_mips_cmp_lt_ph (v2q15, v2q15)
14457 void __builtin_mips_cmp_le_ph (v2q15, v2q15)
14458 v4i8 __builtin_mips_pick_qb (v4i8, v4i8)
14459 v2q15 __builtin_mips_pick_ph (v2q15, v2q15)
14460 v2q15 __builtin_mips_packrl_ph (v2q15, v2q15)
14461 i32 __builtin_mips_extr_w (a64, imm0_31)
14462 i32 __builtin_mips_extr_w (a64, i32)
14463 i32 __builtin_mips_extr_r_w (a64, imm0_31)
14464 i32 __builtin_mips_extr_s_h (a64, i32)
14465 i32 __builtin_mips_extr_rs_w (a64, imm0_31)
14466 i32 __builtin_mips_extr_rs_w (a64, i32)
14467 i32 __builtin_mips_extr_s_h (a64, imm0_31)
14468 i32 __builtin_mips_extr_r_w (a64, i32)
14469 i32 __builtin_mips_extp (a64, imm0_31)
14470 i32 __builtin_mips_extp (a64, i32)
14471 i32 __builtin_mips_extpdp (a64, imm0_31)
14472 i32 __builtin_mips_extpdp (a64, i32)
14473 a64 __builtin_mips_shilo (a64, imm_n32_31)
14474 a64 __builtin_mips_shilo (a64, i32)
14475 a64 __builtin_mips_mthlip (a64, i32)
14476 void __builtin_mips_wrdsp (i32, imm0_63)
14477 i32 __builtin_mips_rddsp (imm0_63)
14478 i32 __builtin_mips_lbux (void *, i32)
14479 i32 __builtin_mips_lhx (void *, i32)
14480 i32 __builtin_mips_lwx (void *, i32)
14481 a64 __builtin_mips_ldx (void *, i32) [MIPS64 only]
14482 i32 __builtin_mips_bposge32 (void)
14483 a64 __builtin_mips_madd (a64, i32, i32);
14484 a64 __builtin_mips_maddu (a64, ui32, ui32);
14485 a64 __builtin_mips_msub (a64, i32, i32);
14486 a64 __builtin_mips_msubu (a64, ui32, ui32);
14487 a64 __builtin_mips_mult (i32, i32);
14488 a64 __builtin_mips_multu (ui32, ui32);
14489 @end smallexample
14491 The following built-in functions map directly to a particular MIPS DSP REV 2
14492 instruction.  Please refer to the architecture specification
14493 for details on what each instruction does.
14495 @smallexample
14496 v4q7 __builtin_mips_absq_s_qb (v4q7);
14497 v2i16 __builtin_mips_addu_ph (v2i16, v2i16);
14498 v2i16 __builtin_mips_addu_s_ph (v2i16, v2i16);
14499 v4i8 __builtin_mips_adduh_qb (v4i8, v4i8);
14500 v4i8 __builtin_mips_adduh_r_qb (v4i8, v4i8);
14501 i32 __builtin_mips_append (i32, i32, imm0_31);
14502 i32 __builtin_mips_balign (i32, i32, imm0_3);
14503 i32 __builtin_mips_cmpgdu_eq_qb (v4i8, v4i8);
14504 i32 __builtin_mips_cmpgdu_lt_qb (v4i8, v4i8);
14505 i32 __builtin_mips_cmpgdu_le_qb (v4i8, v4i8);
14506 a64 __builtin_mips_dpa_w_ph (a64, v2i16, v2i16);
14507 a64 __builtin_mips_dps_w_ph (a64, v2i16, v2i16);
14508 v2i16 __builtin_mips_mul_ph (v2i16, v2i16);
14509 v2i16 __builtin_mips_mul_s_ph (v2i16, v2i16);
14510 q31 __builtin_mips_mulq_rs_w (q31, q31);
14511 v2q15 __builtin_mips_mulq_s_ph (v2q15, v2q15);
14512 q31 __builtin_mips_mulq_s_w (q31, q31);
14513 a64 __builtin_mips_mulsa_w_ph (a64, v2i16, v2i16);
14514 v4i8 __builtin_mips_precr_qb_ph (v2i16, v2i16);
14515 v2i16 __builtin_mips_precr_sra_ph_w (i32, i32, imm0_31);
14516 v2i16 __builtin_mips_precr_sra_r_ph_w (i32, i32, imm0_31);
14517 i32 __builtin_mips_prepend (i32, i32, imm0_31);
14518 v4i8 __builtin_mips_shra_qb (v4i8, imm0_7);
14519 v4i8 __builtin_mips_shra_r_qb (v4i8, imm0_7);
14520 v4i8 __builtin_mips_shra_qb (v4i8, i32);
14521 v4i8 __builtin_mips_shra_r_qb (v4i8, i32);
14522 v2i16 __builtin_mips_shrl_ph (v2i16, imm0_15);
14523 v2i16 __builtin_mips_shrl_ph (v2i16, i32);
14524 v2i16 __builtin_mips_subu_ph (v2i16, v2i16);
14525 v2i16 __builtin_mips_subu_s_ph (v2i16, v2i16);
14526 v4i8 __builtin_mips_subuh_qb (v4i8, v4i8);
14527 v4i8 __builtin_mips_subuh_r_qb (v4i8, v4i8);
14528 v2q15 __builtin_mips_addqh_ph (v2q15, v2q15);
14529 v2q15 __builtin_mips_addqh_r_ph (v2q15, v2q15);
14530 q31 __builtin_mips_addqh_w (q31, q31);
14531 q31 __builtin_mips_addqh_r_w (q31, q31);
14532 v2q15 __builtin_mips_subqh_ph (v2q15, v2q15);
14533 v2q15 __builtin_mips_subqh_r_ph (v2q15, v2q15);
14534 q31 __builtin_mips_subqh_w (q31, q31);
14535 q31 __builtin_mips_subqh_r_w (q31, q31);
14536 a64 __builtin_mips_dpax_w_ph (a64, v2i16, v2i16);
14537 a64 __builtin_mips_dpsx_w_ph (a64, v2i16, v2i16);
14538 a64 __builtin_mips_dpaqx_s_w_ph (a64, v2q15, v2q15);
14539 a64 __builtin_mips_dpaqx_sa_w_ph (a64, v2q15, v2q15);
14540 a64 __builtin_mips_dpsqx_s_w_ph (a64, v2q15, v2q15);
14541 a64 __builtin_mips_dpsqx_sa_w_ph (a64, v2q15, v2q15);
14542 @end smallexample
14545 @node MIPS Paired-Single Support
14546 @subsection MIPS Paired-Single Support
14548 The MIPS64 architecture includes a number of instructions that
14549 operate on pairs of single-precision floating-point values.
14550 Each pair is packed into a 64-bit floating-point register,
14551 with one element being designated the ``upper half'' and
14552 the other being designated the ``lower half''.
14554 GCC supports paired-single operations using both the generic
14555 vector extensions (@pxref{Vector Extensions}) and a collection of
14556 MIPS-specific built-in functions.  Both kinds of support are
14557 enabled by the @option{-mpaired-single} command-line option.
14559 The vector type associated with paired-single values is usually
14560 called @code{v2sf}.  It can be defined in C as follows:
14562 @smallexample
14563 typedef float v2sf __attribute__ ((vector_size (8)));
14564 @end smallexample
14566 @code{v2sf} values are initialized in the same way as aggregates.
14567 For example:
14569 @smallexample
14570 v2sf a = @{1.5, 9.1@};
14571 v2sf b;
14572 float e, f;
14573 b = (v2sf) @{e, f@};
14574 @end smallexample
14576 @emph{Note:} The CPU's endianness determines which value is stored in
14577 the upper half of a register and which value is stored in the lower half.
14578 On little-endian targets, the first value is the lower one and the second
14579 value is the upper one.  The opposite order applies to big-endian targets.
14580 For example, the code above sets the lower half of @code{a} to
14581 @code{1.5} on little-endian targets and @code{9.1} on big-endian targets.
14583 @node MIPS Loongson Built-in Functions
14584 @subsection MIPS Loongson Built-in Functions
14586 GCC provides intrinsics to access the SIMD instructions provided by the
14587 ST Microelectronics Loongson-2E and -2F processors.  These intrinsics,
14588 available after inclusion of the @code{loongson.h} header file,
14589 operate on the following 64-bit vector types:
14591 @itemize
14592 @item @code{uint8x8_t}, a vector of eight unsigned 8-bit integers;
14593 @item @code{uint16x4_t}, a vector of four unsigned 16-bit integers;
14594 @item @code{uint32x2_t}, a vector of two unsigned 32-bit integers;
14595 @item @code{int8x8_t}, a vector of eight signed 8-bit integers;
14596 @item @code{int16x4_t}, a vector of four signed 16-bit integers;
14597 @item @code{int32x2_t}, a vector of two signed 32-bit integers.
14598 @end itemize
14600 The intrinsics provided are listed below; each is named after the
14601 machine instruction to which it corresponds, with suffixes added as
14602 appropriate to distinguish intrinsics that expand to the same machine
14603 instruction yet have different argument types.  Refer to the architecture
14604 documentation for a description of the functionality of each
14605 instruction.
14607 @smallexample
14608 int16x4_t packsswh (int32x2_t s, int32x2_t t);
14609 int8x8_t packsshb (int16x4_t s, int16x4_t t);
14610 uint8x8_t packushb (uint16x4_t s, uint16x4_t t);
14611 uint32x2_t paddw_u (uint32x2_t s, uint32x2_t t);
14612 uint16x4_t paddh_u (uint16x4_t s, uint16x4_t t);
14613 uint8x8_t paddb_u (uint8x8_t s, uint8x8_t t);
14614 int32x2_t paddw_s (int32x2_t s, int32x2_t t);
14615 int16x4_t paddh_s (int16x4_t s, int16x4_t t);
14616 int8x8_t paddb_s (int8x8_t s, int8x8_t t);
14617 uint64_t paddd_u (uint64_t s, uint64_t t);
14618 int64_t paddd_s (int64_t s, int64_t t);
14619 int16x4_t paddsh (int16x4_t s, int16x4_t t);
14620 int8x8_t paddsb (int8x8_t s, int8x8_t t);
14621 uint16x4_t paddush (uint16x4_t s, uint16x4_t t);
14622 uint8x8_t paddusb (uint8x8_t s, uint8x8_t t);
14623 uint64_t pandn_ud (uint64_t s, uint64_t t);
14624 uint32x2_t pandn_uw (uint32x2_t s, uint32x2_t t);
14625 uint16x4_t pandn_uh (uint16x4_t s, uint16x4_t t);
14626 uint8x8_t pandn_ub (uint8x8_t s, uint8x8_t t);
14627 int64_t pandn_sd (int64_t s, int64_t t);
14628 int32x2_t pandn_sw (int32x2_t s, int32x2_t t);
14629 int16x4_t pandn_sh (int16x4_t s, int16x4_t t);
14630 int8x8_t pandn_sb (int8x8_t s, int8x8_t t);
14631 uint16x4_t pavgh (uint16x4_t s, uint16x4_t t);
14632 uint8x8_t pavgb (uint8x8_t s, uint8x8_t t);
14633 uint32x2_t pcmpeqw_u (uint32x2_t s, uint32x2_t t);
14634 uint16x4_t pcmpeqh_u (uint16x4_t s, uint16x4_t t);
14635 uint8x8_t pcmpeqb_u (uint8x8_t s, uint8x8_t t);
14636 int32x2_t pcmpeqw_s (int32x2_t s, int32x2_t t);
14637 int16x4_t pcmpeqh_s (int16x4_t s, int16x4_t t);
14638 int8x8_t pcmpeqb_s (int8x8_t s, int8x8_t t);
14639 uint32x2_t pcmpgtw_u (uint32x2_t s, uint32x2_t t);
14640 uint16x4_t pcmpgth_u (uint16x4_t s, uint16x4_t t);
14641 uint8x8_t pcmpgtb_u (uint8x8_t s, uint8x8_t t);
14642 int32x2_t pcmpgtw_s (int32x2_t s, int32x2_t t);
14643 int16x4_t pcmpgth_s (int16x4_t s, int16x4_t t);
14644 int8x8_t pcmpgtb_s (int8x8_t s, int8x8_t t);
14645 uint16x4_t pextrh_u (uint16x4_t s, int field);
14646 int16x4_t pextrh_s (int16x4_t s, int field);
14647 uint16x4_t pinsrh_0_u (uint16x4_t s, uint16x4_t t);
14648 uint16x4_t pinsrh_1_u (uint16x4_t s, uint16x4_t t);
14649 uint16x4_t pinsrh_2_u (uint16x4_t s, uint16x4_t t);
14650 uint16x4_t pinsrh_3_u (uint16x4_t s, uint16x4_t t);
14651 int16x4_t pinsrh_0_s (int16x4_t s, int16x4_t t);
14652 int16x4_t pinsrh_1_s (int16x4_t s, int16x4_t t);
14653 int16x4_t pinsrh_2_s (int16x4_t s, int16x4_t t);
14654 int16x4_t pinsrh_3_s (int16x4_t s, int16x4_t t);
14655 int32x2_t pmaddhw (int16x4_t s, int16x4_t t);
14656 int16x4_t pmaxsh (int16x4_t s, int16x4_t t);
14657 uint8x8_t pmaxub (uint8x8_t s, uint8x8_t t);
14658 int16x4_t pminsh (int16x4_t s, int16x4_t t);
14659 uint8x8_t pminub (uint8x8_t s, uint8x8_t t);
14660 uint8x8_t pmovmskb_u (uint8x8_t s);
14661 int8x8_t pmovmskb_s (int8x8_t s);
14662 uint16x4_t pmulhuh (uint16x4_t s, uint16x4_t t);
14663 int16x4_t pmulhh (int16x4_t s, int16x4_t t);
14664 int16x4_t pmullh (int16x4_t s, int16x4_t t);
14665 int64_t pmuluw (uint32x2_t s, uint32x2_t t);
14666 uint8x8_t pasubub (uint8x8_t s, uint8x8_t t);
14667 uint16x4_t biadd (uint8x8_t s);
14668 uint16x4_t psadbh (uint8x8_t s, uint8x8_t t);
14669 uint16x4_t pshufh_u (uint16x4_t dest, uint16x4_t s, uint8_t order);
14670 int16x4_t pshufh_s (int16x4_t dest, int16x4_t s, uint8_t order);
14671 uint16x4_t psllh_u (uint16x4_t s, uint8_t amount);
14672 int16x4_t psllh_s (int16x4_t s, uint8_t amount);
14673 uint32x2_t psllw_u (uint32x2_t s, uint8_t amount);
14674 int32x2_t psllw_s (int32x2_t s, uint8_t amount);
14675 uint16x4_t psrlh_u (uint16x4_t s, uint8_t amount);
14676 int16x4_t psrlh_s (int16x4_t s, uint8_t amount);
14677 uint32x2_t psrlw_u (uint32x2_t s, uint8_t amount);
14678 int32x2_t psrlw_s (int32x2_t s, uint8_t amount);
14679 uint16x4_t psrah_u (uint16x4_t s, uint8_t amount);
14680 int16x4_t psrah_s (int16x4_t s, uint8_t amount);
14681 uint32x2_t psraw_u (uint32x2_t s, uint8_t amount);
14682 int32x2_t psraw_s (int32x2_t s, uint8_t amount);
14683 uint32x2_t psubw_u (uint32x2_t s, uint32x2_t t);
14684 uint16x4_t psubh_u (uint16x4_t s, uint16x4_t t);
14685 uint8x8_t psubb_u (uint8x8_t s, uint8x8_t t);
14686 int32x2_t psubw_s (int32x2_t s, int32x2_t t);
14687 int16x4_t psubh_s (int16x4_t s, int16x4_t t);
14688 int8x8_t psubb_s (int8x8_t s, int8x8_t t);
14689 uint64_t psubd_u (uint64_t s, uint64_t t);
14690 int64_t psubd_s (int64_t s, int64_t t);
14691 int16x4_t psubsh (int16x4_t s, int16x4_t t);
14692 int8x8_t psubsb (int8x8_t s, int8x8_t t);
14693 uint16x4_t psubush (uint16x4_t s, uint16x4_t t);
14694 uint8x8_t psubusb (uint8x8_t s, uint8x8_t t);
14695 uint32x2_t punpckhwd_u (uint32x2_t s, uint32x2_t t);
14696 uint16x4_t punpckhhw_u (uint16x4_t s, uint16x4_t t);
14697 uint8x8_t punpckhbh_u (uint8x8_t s, uint8x8_t t);
14698 int32x2_t punpckhwd_s (int32x2_t s, int32x2_t t);
14699 int16x4_t punpckhhw_s (int16x4_t s, int16x4_t t);
14700 int8x8_t punpckhbh_s (int8x8_t s, int8x8_t t);
14701 uint32x2_t punpcklwd_u (uint32x2_t s, uint32x2_t t);
14702 uint16x4_t punpcklhw_u (uint16x4_t s, uint16x4_t t);
14703 uint8x8_t punpcklbh_u (uint8x8_t s, uint8x8_t t);
14704 int32x2_t punpcklwd_s (int32x2_t s, int32x2_t t);
14705 int16x4_t punpcklhw_s (int16x4_t s, int16x4_t t);
14706 int8x8_t punpcklbh_s (int8x8_t s, int8x8_t t);
14707 @end smallexample
14709 @menu
14710 * Paired-Single Arithmetic::
14711 * Paired-Single Built-in Functions::
14712 * MIPS-3D Built-in Functions::
14713 @end menu
14715 @node Paired-Single Arithmetic
14716 @subsubsection Paired-Single Arithmetic
14718 The table below lists the @code{v2sf} operations for which hardware
14719 support exists.  @code{a}, @code{b} and @code{c} are @code{v2sf}
14720 values and @code{x} is an integral value.
14722 @multitable @columnfractions .50 .50
14723 @item C code @tab MIPS instruction
14724 @item @code{a + b} @tab @code{add.ps}
14725 @item @code{a - b} @tab @code{sub.ps}
14726 @item @code{-a} @tab @code{neg.ps}
14727 @item @code{a * b} @tab @code{mul.ps}
14728 @item @code{a * b + c} @tab @code{madd.ps}
14729 @item @code{a * b - c} @tab @code{msub.ps}
14730 @item @code{-(a * b + c)} @tab @code{nmadd.ps}
14731 @item @code{-(a * b - c)} @tab @code{nmsub.ps}
14732 @item @code{x ? a : b} @tab @code{movn.ps}/@code{movz.ps}
14733 @end multitable
14735 Note that the multiply-accumulate instructions can be disabled
14736 using the command-line option @code{-mno-fused-madd}.
14738 @node Paired-Single Built-in Functions
14739 @subsubsection Paired-Single Built-in Functions
14741 The following paired-single functions map directly to a particular
14742 MIPS instruction.  Please refer to the architecture specification
14743 for details on what each instruction does.
14745 @table @code
14746 @item v2sf __builtin_mips_pll_ps (v2sf, v2sf)
14747 Pair lower lower (@code{pll.ps}).
14749 @item v2sf __builtin_mips_pul_ps (v2sf, v2sf)
14750 Pair upper lower (@code{pul.ps}).
14752 @item v2sf __builtin_mips_plu_ps (v2sf, v2sf)
14753 Pair lower upper (@code{plu.ps}).
14755 @item v2sf __builtin_mips_puu_ps (v2sf, v2sf)
14756 Pair upper upper (@code{puu.ps}).
14758 @item v2sf __builtin_mips_cvt_ps_s (float, float)
14759 Convert pair to paired single (@code{cvt.ps.s}).
14761 @item float __builtin_mips_cvt_s_pl (v2sf)
14762 Convert pair lower to single (@code{cvt.s.pl}).
14764 @item float __builtin_mips_cvt_s_pu (v2sf)
14765 Convert pair upper to single (@code{cvt.s.pu}).
14767 @item v2sf __builtin_mips_abs_ps (v2sf)
14768 Absolute value (@code{abs.ps}).
14770 @item v2sf __builtin_mips_alnv_ps (v2sf, v2sf, int)
14771 Align variable (@code{alnv.ps}).
14773 @emph{Note:} The value of the third parameter must be 0 or 4
14774 modulo 8, otherwise the result is unpredictable.  Please read the
14775 instruction description for details.
14776 @end table
14778 The following multi-instruction functions are also available.
14779 In each case, @var{cond} can be any of the 16 floating-point conditions:
14780 @code{f}, @code{un}, @code{eq}, @code{ueq}, @code{olt}, @code{ult},
14781 @code{ole}, @code{ule}, @code{sf}, @code{ngle}, @code{seq}, @code{ngl},
14782 @code{lt}, @code{nge}, @code{le} or @code{ngt}.
14784 @table @code
14785 @item v2sf __builtin_mips_movt_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
14786 @itemx v2sf __builtin_mips_movf_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
14787 Conditional move based on floating-point comparison (@code{c.@var{cond}.ps},
14788 @code{movt.ps}/@code{movf.ps}).
14790 The @code{movt} functions return the value @var{x} computed by:
14792 @smallexample
14793 c.@var{cond}.ps @var{cc},@var{a},@var{b}
14794 mov.ps @var{x},@var{c}
14795 movt.ps @var{x},@var{d},@var{cc}
14796 @end smallexample
14798 The @code{movf} functions are similar but use @code{movf.ps} instead
14799 of @code{movt.ps}.
14801 @item int __builtin_mips_upper_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
14802 @itemx int __builtin_mips_lower_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
14803 Comparison of two paired-single values (@code{c.@var{cond}.ps},
14804 @code{bc1t}/@code{bc1f}).
14806 These functions compare @var{a} and @var{b} using @code{c.@var{cond}.ps}
14807 and return either the upper or lower half of the result.  For example:
14809 @smallexample
14810 v2sf a, b;
14811 if (__builtin_mips_upper_c_eq_ps (a, b))
14812   upper_halves_are_equal ();
14813 else
14814   upper_halves_are_unequal ();
14816 if (__builtin_mips_lower_c_eq_ps (a, b))
14817   lower_halves_are_equal ();
14818 else
14819   lower_halves_are_unequal ();
14820 @end smallexample
14821 @end table
14823 @node MIPS-3D Built-in Functions
14824 @subsubsection MIPS-3D Built-in Functions
14826 The MIPS-3D Application-Specific Extension (ASE) includes additional
14827 paired-single instructions that are designed to improve the performance
14828 of 3D graphics operations.  Support for these instructions is controlled
14829 by the @option{-mips3d} command-line option.
14831 The functions listed below map directly to a particular MIPS-3D
14832 instruction.  Please refer to the architecture specification for
14833 more details on what each instruction does.
14835 @table @code
14836 @item v2sf __builtin_mips_addr_ps (v2sf, v2sf)
14837 Reduction add (@code{addr.ps}).
14839 @item v2sf __builtin_mips_mulr_ps (v2sf, v2sf)
14840 Reduction multiply (@code{mulr.ps}).
14842 @item v2sf __builtin_mips_cvt_pw_ps (v2sf)
14843 Convert paired single to paired word (@code{cvt.pw.ps}).
14845 @item v2sf __builtin_mips_cvt_ps_pw (v2sf)
14846 Convert paired word to paired single (@code{cvt.ps.pw}).
14848 @item float __builtin_mips_recip1_s (float)
14849 @itemx double __builtin_mips_recip1_d (double)
14850 @itemx v2sf __builtin_mips_recip1_ps (v2sf)
14851 Reduced-precision reciprocal (sequence step 1) (@code{recip1.@var{fmt}}).
14853 @item float __builtin_mips_recip2_s (float, float)
14854 @itemx double __builtin_mips_recip2_d (double, double)
14855 @itemx v2sf __builtin_mips_recip2_ps (v2sf, v2sf)
14856 Reduced-precision reciprocal (sequence step 2) (@code{recip2.@var{fmt}}).
14858 @item float __builtin_mips_rsqrt1_s (float)
14859 @itemx double __builtin_mips_rsqrt1_d (double)
14860 @itemx v2sf __builtin_mips_rsqrt1_ps (v2sf)
14861 Reduced-precision reciprocal square root (sequence step 1)
14862 (@code{rsqrt1.@var{fmt}}).
14864 @item float __builtin_mips_rsqrt2_s (float, float)
14865 @itemx double __builtin_mips_rsqrt2_d (double, double)
14866 @itemx v2sf __builtin_mips_rsqrt2_ps (v2sf, v2sf)
14867 Reduced-precision reciprocal square root (sequence step 2)
14868 (@code{rsqrt2.@var{fmt}}).
14869 @end table
14871 The following multi-instruction functions are also available.
14872 In each case, @var{cond} can be any of the 16 floating-point conditions:
14873 @code{f}, @code{un}, @code{eq}, @code{ueq}, @code{olt}, @code{ult},
14874 @code{ole}, @code{ule}, @code{sf}, @code{ngle}, @code{seq},
14875 @code{ngl}, @code{lt}, @code{nge}, @code{le} or @code{ngt}.
14877 @table @code
14878 @item int __builtin_mips_cabs_@var{cond}_s (float @var{a}, float @var{b})
14879 @itemx int __builtin_mips_cabs_@var{cond}_d (double @var{a}, double @var{b})
14880 Absolute comparison of two scalar values (@code{cabs.@var{cond}.@var{fmt}},
14881 @code{bc1t}/@code{bc1f}).
14883 These functions compare @var{a} and @var{b} using @code{cabs.@var{cond}.s}
14884 or @code{cabs.@var{cond}.d} and return the result as a boolean value.
14885 For example:
14887 @smallexample
14888 float a, b;
14889 if (__builtin_mips_cabs_eq_s (a, b))
14890   true ();
14891 else
14892   false ();
14893 @end smallexample
14895 @item int __builtin_mips_upper_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
14896 @itemx int __builtin_mips_lower_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
14897 Absolute comparison of two paired-single values (@code{cabs.@var{cond}.ps},
14898 @code{bc1t}/@code{bc1f}).
14900 These functions compare @var{a} and @var{b} using @code{cabs.@var{cond}.ps}
14901 and return either the upper or lower half of the result.  For example:
14903 @smallexample
14904 v2sf a, b;
14905 if (__builtin_mips_upper_cabs_eq_ps (a, b))
14906   upper_halves_are_equal ();
14907 else
14908   upper_halves_are_unequal ();
14910 if (__builtin_mips_lower_cabs_eq_ps (a, b))
14911   lower_halves_are_equal ();
14912 else
14913   lower_halves_are_unequal ();
14914 @end smallexample
14916 @item v2sf __builtin_mips_movt_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
14917 @itemx v2sf __builtin_mips_movf_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
14918 Conditional move based on absolute comparison (@code{cabs.@var{cond}.ps},
14919 @code{movt.ps}/@code{movf.ps}).
14921 The @code{movt} functions return the value @var{x} computed by:
14923 @smallexample
14924 cabs.@var{cond}.ps @var{cc},@var{a},@var{b}
14925 mov.ps @var{x},@var{c}
14926 movt.ps @var{x},@var{d},@var{cc}
14927 @end smallexample
14929 The @code{movf} functions are similar but use @code{movf.ps} instead
14930 of @code{movt.ps}.
14932 @item int __builtin_mips_any_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
14933 @itemx int __builtin_mips_all_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
14934 @itemx int __builtin_mips_any_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
14935 @itemx int __builtin_mips_all_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
14936 Comparison of two paired-single values
14937 (@code{c.@var{cond}.ps}/@code{cabs.@var{cond}.ps},
14938 @code{bc1any2t}/@code{bc1any2f}).
14940 These functions compare @var{a} and @var{b} using @code{c.@var{cond}.ps}
14941 or @code{cabs.@var{cond}.ps}.  The @code{any} forms return @code{true} if either
14942 result is @code{true} and the @code{all} forms return @code{true} if both results are @code{true}.
14943 For example:
14945 @smallexample
14946 v2sf a, b;
14947 if (__builtin_mips_any_c_eq_ps (a, b))
14948   one_is_true ();
14949 else
14950   both_are_false ();
14952 if (__builtin_mips_all_c_eq_ps (a, b))
14953   both_are_true ();
14954 else
14955   one_is_false ();
14956 @end smallexample
14958 @item int __builtin_mips_any_c_@var{cond}_4s (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
14959 @itemx int __builtin_mips_all_c_@var{cond}_4s (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
14960 @itemx int __builtin_mips_any_cabs_@var{cond}_4s (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
14961 @itemx int __builtin_mips_all_cabs_@var{cond}_4s (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
14962 Comparison of four paired-single values
14963 (@code{c.@var{cond}.ps}/@code{cabs.@var{cond}.ps},
14964 @code{bc1any4t}/@code{bc1any4f}).
14966 These functions use @code{c.@var{cond}.ps} or @code{cabs.@var{cond}.ps}
14967 to compare @var{a} with @var{b} and to compare @var{c} with @var{d}.
14968 The @code{any} forms return @code{true} if any of the four results are @code{true}
14969 and the @code{all} forms return @code{true} if all four results are @code{true}.
14970 For example:
14972 @smallexample
14973 v2sf a, b, c, d;
14974 if (__builtin_mips_any_c_eq_4s (a, b, c, d))
14975   some_are_true ();
14976 else
14977   all_are_false ();
14979 if (__builtin_mips_all_c_eq_4s (a, b, c, d))
14980   all_are_true ();
14981 else
14982   some_are_false ();
14983 @end smallexample
14984 @end table
14986 @node MIPS SIMD Architecture (MSA) Support
14987 @subsection MIPS SIMD Architecture (MSA) Support
14989 @menu
14990 * MIPS SIMD Architecture Built-in Functions::
14991 @end menu
14993 GCC provides intrinsics to access the SIMD instructions provided by the
14994 MSA MIPS SIMD Architecture.  The interface is made available by including
14995 @code{<msa.h>} and using @option{-mmsa -mhard-float -mfp64 -mnan=2008}.
14996 For each @code{__builtin_msa_*}, there is a shortened name of the intrinsic,
14997 @code{__msa_*}.
14999 MSA implements 128-bit wide vector registers, operating on 8-, 16-, 32- and
15000 64-bit integer, 16- and 32-bit fixed-point, or 32- and 64-bit floating point
15001 data elements.  The following vectors typedefs are included in @code{msa.h}:
15002 @itemize
15003 @item @code{v16i8}, a vector of sixteen signed 8-bit integers;
15004 @item @code{v16u8}, a vector of sixteen unsigned 8-bit integers;
15005 @item @code{v8i16}, a vector of eight signed 16-bit integers;
15006 @item @code{v8u16}, a vector of eight unsigned 16-bit integers;
15007 @item @code{v4i32}, a vector of four signed 32-bit integers;
15008 @item @code{v4u32}, a vector of four unsigned 32-bit integers;
15009 @item @code{v2i64}, a vector of two signed 64-bit integers;
15010 @item @code{v2u64}, a vector of two unsigned 64-bit integers;
15011 @item @code{v4f32}, a vector of four 32-bit floats;
15012 @item @code{v2f64}, a vector of two 64-bit doubles.
15013 @end itemize
15015 Instructions and corresponding built-ins may have additional restrictions and/or
15016 input/output values manipulated:
15017 @itemize
15018 @item @code{imm0_1}, an integer literal in range 0 to 1;
15019 @item @code{imm0_3}, an integer literal in range 0 to 3;
15020 @item @code{imm0_7}, an integer literal in range 0 to 7;
15021 @item @code{imm0_15}, an integer literal in range 0 to 15;
15022 @item @code{imm0_31}, an integer literal in range 0 to 31;
15023 @item @code{imm0_63}, an integer literal in range 0 to 63;
15024 @item @code{imm0_255}, an integer literal in range 0 to 255;
15025 @item @code{imm_n16_15}, an integer literal in range -16 to 15;
15026 @item @code{imm_n512_511}, an integer literal in range -512 to 511;
15027 @item @code{imm_n1024_1022}, an integer literal in range -512 to 511 left
15028 shifted by 1 bit, i.e., -1024, -1022, @dots{}, 1020, 1022;
15029 @item @code{imm_n2048_2044}, an integer literal in range -512 to 511 left
15030 shifted by 2 bits, i.e., -2048, -2044, @dots{}, 2040, 2044;
15031 @item @code{imm_n4096_4088}, an integer literal in range -512 to 511 left
15032 shifted by 3 bits, i.e., -4096, -4088, @dots{}, 4080, 4088;
15033 @item @code{imm1_4}, an integer literal in range 1 to 4;
15034 @item @code{i32, i64, u32, u64, f32, f64}, defined as follows:
15035 @end itemize
15037 @smallexample
15039 typedef int i32;
15040 #if __LONG_MAX__ == __LONG_LONG_MAX__
15041 typedef long i64;
15042 #else
15043 typedef long long i64;
15044 #endif
15046 typedef unsigned int u32;
15047 #if __LONG_MAX__ == __LONG_LONG_MAX__
15048 typedef unsigned long u64;
15049 #else
15050 typedef unsigned long long u64;
15051 #endif
15053 typedef double f64;
15054 typedef float f32;
15056 @end smallexample
15058 @node MIPS SIMD Architecture Built-in Functions
15059 @subsubsection MIPS SIMD Architecture Built-in Functions
15061 The intrinsics provided are listed below; each is named after the
15062 machine instruction.
15064 @smallexample
15065 v16i8 __builtin_msa_add_a_b (v16i8, v16i8);
15066 v8i16 __builtin_msa_add_a_h (v8i16, v8i16);
15067 v4i32 __builtin_msa_add_a_w (v4i32, v4i32);
15068 v2i64 __builtin_msa_add_a_d (v2i64, v2i64);
15070 v16i8 __builtin_msa_adds_a_b (v16i8, v16i8);
15071 v8i16 __builtin_msa_adds_a_h (v8i16, v8i16);
15072 v4i32 __builtin_msa_adds_a_w (v4i32, v4i32);
15073 v2i64 __builtin_msa_adds_a_d (v2i64, v2i64);
15075 v16i8 __builtin_msa_adds_s_b (v16i8, v16i8);
15076 v8i16 __builtin_msa_adds_s_h (v8i16, v8i16);
15077 v4i32 __builtin_msa_adds_s_w (v4i32, v4i32);
15078 v2i64 __builtin_msa_adds_s_d (v2i64, v2i64);
15080 v16u8 __builtin_msa_adds_u_b (v16u8, v16u8);
15081 v8u16 __builtin_msa_adds_u_h (v8u16, v8u16);
15082 v4u32 __builtin_msa_adds_u_w (v4u32, v4u32);
15083 v2u64 __builtin_msa_adds_u_d (v2u64, v2u64);
15085 v16i8 __builtin_msa_addv_b (v16i8, v16i8);
15086 v8i16 __builtin_msa_addv_h (v8i16, v8i16);
15087 v4i32 __builtin_msa_addv_w (v4i32, v4i32);
15088 v2i64 __builtin_msa_addv_d (v2i64, v2i64);
15090 v16i8 __builtin_msa_addvi_b (v16i8, imm0_31);
15091 v8i16 __builtin_msa_addvi_h (v8i16, imm0_31);
15092 v4i32 __builtin_msa_addvi_w (v4i32, imm0_31);
15093 v2i64 __builtin_msa_addvi_d (v2i64, imm0_31);
15095 v16u8 __builtin_msa_and_v (v16u8, v16u8);
15097 v16u8 __builtin_msa_andi_b (v16u8, imm0_255);
15099 v16i8 __builtin_msa_asub_s_b (v16i8, v16i8);
15100 v8i16 __builtin_msa_asub_s_h (v8i16, v8i16);
15101 v4i32 __builtin_msa_asub_s_w (v4i32, v4i32);
15102 v2i64 __builtin_msa_asub_s_d (v2i64, v2i64);
15104 v16u8 __builtin_msa_asub_u_b (v16u8, v16u8);
15105 v8u16 __builtin_msa_asub_u_h (v8u16, v8u16);
15106 v4u32 __builtin_msa_asub_u_w (v4u32, v4u32);
15107 v2u64 __builtin_msa_asub_u_d (v2u64, v2u64);
15109 v16i8 __builtin_msa_ave_s_b (v16i8, v16i8);
15110 v8i16 __builtin_msa_ave_s_h (v8i16, v8i16);
15111 v4i32 __builtin_msa_ave_s_w (v4i32, v4i32);
15112 v2i64 __builtin_msa_ave_s_d (v2i64, v2i64);
15114 v16u8 __builtin_msa_ave_u_b (v16u8, v16u8);
15115 v8u16 __builtin_msa_ave_u_h (v8u16, v8u16);
15116 v4u32 __builtin_msa_ave_u_w (v4u32, v4u32);
15117 v2u64 __builtin_msa_ave_u_d (v2u64, v2u64);
15119 v16i8 __builtin_msa_aver_s_b (v16i8, v16i8);
15120 v8i16 __builtin_msa_aver_s_h (v8i16, v8i16);
15121 v4i32 __builtin_msa_aver_s_w (v4i32, v4i32);
15122 v2i64 __builtin_msa_aver_s_d (v2i64, v2i64);
15124 v16u8 __builtin_msa_aver_u_b (v16u8, v16u8);
15125 v8u16 __builtin_msa_aver_u_h (v8u16, v8u16);
15126 v4u32 __builtin_msa_aver_u_w (v4u32, v4u32);
15127 v2u64 __builtin_msa_aver_u_d (v2u64, v2u64);
15129 v16u8 __builtin_msa_bclr_b (v16u8, v16u8);
15130 v8u16 __builtin_msa_bclr_h (v8u16, v8u16);
15131 v4u32 __builtin_msa_bclr_w (v4u32, v4u32);
15132 v2u64 __builtin_msa_bclr_d (v2u64, v2u64);
15134 v16u8 __builtin_msa_bclri_b (v16u8, imm0_7);
15135 v8u16 __builtin_msa_bclri_h (v8u16, imm0_15);
15136 v4u32 __builtin_msa_bclri_w (v4u32, imm0_31);
15137 v2u64 __builtin_msa_bclri_d (v2u64, imm0_63);
15139 v16u8 __builtin_msa_binsl_b (v16u8, v16u8, v16u8);
15140 v8u16 __builtin_msa_binsl_h (v8u16, v8u16, v8u16);
15141 v4u32 __builtin_msa_binsl_w (v4u32, v4u32, v4u32);
15142 v2u64 __builtin_msa_binsl_d (v2u64, v2u64, v2u64);
15144 v16u8 __builtin_msa_binsli_b (v16u8, v16u8, imm0_7);
15145 v8u16 __builtin_msa_binsli_h (v8u16, v8u16, imm0_15);
15146 v4u32 __builtin_msa_binsli_w (v4u32, v4u32, imm0_31);
15147 v2u64 __builtin_msa_binsli_d (v2u64, v2u64, imm0_63);
15149 v16u8 __builtin_msa_binsr_b (v16u8, v16u8, v16u8);
15150 v8u16 __builtin_msa_binsr_h (v8u16, v8u16, v8u16);
15151 v4u32 __builtin_msa_binsr_w (v4u32, v4u32, v4u32);
15152 v2u64 __builtin_msa_binsr_d (v2u64, v2u64, v2u64);
15154 v16u8 __builtin_msa_binsri_b (v16u8, v16u8, imm0_7);
15155 v8u16 __builtin_msa_binsri_h (v8u16, v8u16, imm0_15);
15156 v4u32 __builtin_msa_binsri_w (v4u32, v4u32, imm0_31);
15157 v2u64 __builtin_msa_binsri_d (v2u64, v2u64, imm0_63);
15159 v16u8 __builtin_msa_bmnz_v (v16u8, v16u8, v16u8);
15161 v16u8 __builtin_msa_bmnzi_b (v16u8, v16u8, imm0_255);
15163 v16u8 __builtin_msa_bmz_v (v16u8, v16u8, v16u8);
15165 v16u8 __builtin_msa_bmzi_b (v16u8, v16u8, imm0_255);
15167 v16u8 __builtin_msa_bneg_b (v16u8, v16u8);
15168 v8u16 __builtin_msa_bneg_h (v8u16, v8u16);
15169 v4u32 __builtin_msa_bneg_w (v4u32, v4u32);
15170 v2u64 __builtin_msa_bneg_d (v2u64, v2u64);
15172 v16u8 __builtin_msa_bnegi_b (v16u8, imm0_7);
15173 v8u16 __builtin_msa_bnegi_h (v8u16, imm0_15);
15174 v4u32 __builtin_msa_bnegi_w (v4u32, imm0_31);
15175 v2u64 __builtin_msa_bnegi_d (v2u64, imm0_63);
15177 i32 __builtin_msa_bnz_b (v16u8);
15178 i32 __builtin_msa_bnz_h (v8u16);
15179 i32 __builtin_msa_bnz_w (v4u32);
15180 i32 __builtin_msa_bnz_d (v2u64);
15182 i32 __builtin_msa_bnz_v (v16u8);
15184 v16u8 __builtin_msa_bsel_v (v16u8, v16u8, v16u8);
15186 v16u8 __builtin_msa_bseli_b (v16u8, v16u8, imm0_255);
15188 v16u8 __builtin_msa_bset_b (v16u8, v16u8);
15189 v8u16 __builtin_msa_bset_h (v8u16, v8u16);
15190 v4u32 __builtin_msa_bset_w (v4u32, v4u32);
15191 v2u64 __builtin_msa_bset_d (v2u64, v2u64);
15193 v16u8 __builtin_msa_bseti_b (v16u8, imm0_7);
15194 v8u16 __builtin_msa_bseti_h (v8u16, imm0_15);
15195 v4u32 __builtin_msa_bseti_w (v4u32, imm0_31);
15196 v2u64 __builtin_msa_bseti_d (v2u64, imm0_63);
15198 i32 __builtin_msa_bz_b (v16u8);
15199 i32 __builtin_msa_bz_h (v8u16);
15200 i32 __builtin_msa_bz_w (v4u32);
15201 i32 __builtin_msa_bz_d (v2u64);
15203 i32 __builtin_msa_bz_v (v16u8);
15205 v16i8 __builtin_msa_ceq_b (v16i8, v16i8);
15206 v8i16 __builtin_msa_ceq_h (v8i16, v8i16);
15207 v4i32 __builtin_msa_ceq_w (v4i32, v4i32);
15208 v2i64 __builtin_msa_ceq_d (v2i64, v2i64);
15210 v16i8 __builtin_msa_ceqi_b (v16i8, imm_n16_15);
15211 v8i16 __builtin_msa_ceqi_h (v8i16, imm_n16_15);
15212 v4i32 __builtin_msa_ceqi_w (v4i32, imm_n16_15);
15213 v2i64 __builtin_msa_ceqi_d (v2i64, imm_n16_15);
15215 i32 __builtin_msa_cfcmsa (imm0_31);
15217 v16i8 __builtin_msa_cle_s_b (v16i8, v16i8);
15218 v8i16 __builtin_msa_cle_s_h (v8i16, v8i16);
15219 v4i32 __builtin_msa_cle_s_w (v4i32, v4i32);
15220 v2i64 __builtin_msa_cle_s_d (v2i64, v2i64);
15222 v16i8 __builtin_msa_cle_u_b (v16u8, v16u8);
15223 v8i16 __builtin_msa_cle_u_h (v8u16, v8u16);
15224 v4i32 __builtin_msa_cle_u_w (v4u32, v4u32);
15225 v2i64 __builtin_msa_cle_u_d (v2u64, v2u64);
15227 v16i8 __builtin_msa_clei_s_b (v16i8, imm_n16_15);
15228 v8i16 __builtin_msa_clei_s_h (v8i16, imm_n16_15);
15229 v4i32 __builtin_msa_clei_s_w (v4i32, imm_n16_15);
15230 v2i64 __builtin_msa_clei_s_d (v2i64, imm_n16_15);
15232 v16i8 __builtin_msa_clei_u_b (v16u8, imm0_31);
15233 v8i16 __builtin_msa_clei_u_h (v8u16, imm0_31);
15234 v4i32 __builtin_msa_clei_u_w (v4u32, imm0_31);
15235 v2i64 __builtin_msa_clei_u_d (v2u64, imm0_31);
15237 v16i8 __builtin_msa_clt_s_b (v16i8, v16i8);
15238 v8i16 __builtin_msa_clt_s_h (v8i16, v8i16);
15239 v4i32 __builtin_msa_clt_s_w (v4i32, v4i32);
15240 v2i64 __builtin_msa_clt_s_d (v2i64, v2i64);
15242 v16i8 __builtin_msa_clt_u_b (v16u8, v16u8);
15243 v8i16 __builtin_msa_clt_u_h (v8u16, v8u16);
15244 v4i32 __builtin_msa_clt_u_w (v4u32, v4u32);
15245 v2i64 __builtin_msa_clt_u_d (v2u64, v2u64);
15247 v16i8 __builtin_msa_clti_s_b (v16i8, imm_n16_15);
15248 v8i16 __builtin_msa_clti_s_h (v8i16, imm_n16_15);
15249 v4i32 __builtin_msa_clti_s_w (v4i32, imm_n16_15);
15250 v2i64 __builtin_msa_clti_s_d (v2i64, imm_n16_15);
15252 v16i8 __builtin_msa_clti_u_b (v16u8, imm0_31);
15253 v8i16 __builtin_msa_clti_u_h (v8u16, imm0_31);
15254 v4i32 __builtin_msa_clti_u_w (v4u32, imm0_31);
15255 v2i64 __builtin_msa_clti_u_d (v2u64, imm0_31);
15257 i32 __builtin_msa_copy_s_b (v16i8, imm0_15);
15258 i32 __builtin_msa_copy_s_h (v8i16, imm0_7);
15259 i32 __builtin_msa_copy_s_w (v4i32, imm0_3);
15260 i64 __builtin_msa_copy_s_d (v2i64, imm0_1);
15262 u32 __builtin_msa_copy_u_b (v16i8, imm0_15);
15263 u32 __builtin_msa_copy_u_h (v8i16, imm0_7);
15264 u32 __builtin_msa_copy_u_w (v4i32, imm0_3);
15265 u64 __builtin_msa_copy_u_d (v2i64, imm0_1);
15267 void __builtin_msa_ctcmsa (imm0_31, i32);
15269 v16i8 __builtin_msa_div_s_b (v16i8, v16i8);
15270 v8i16 __builtin_msa_div_s_h (v8i16, v8i16);
15271 v4i32 __builtin_msa_div_s_w (v4i32, v4i32);
15272 v2i64 __builtin_msa_div_s_d (v2i64, v2i64);
15274 v16u8 __builtin_msa_div_u_b (v16u8, v16u8);
15275 v8u16 __builtin_msa_div_u_h (v8u16, v8u16);
15276 v4u32 __builtin_msa_div_u_w (v4u32, v4u32);
15277 v2u64 __builtin_msa_div_u_d (v2u64, v2u64);
15279 v8i16 __builtin_msa_dotp_s_h (v16i8, v16i8);
15280 v4i32 __builtin_msa_dotp_s_w (v8i16, v8i16);
15281 v2i64 __builtin_msa_dotp_s_d (v4i32, v4i32);
15283 v8u16 __builtin_msa_dotp_u_h (v16u8, v16u8);
15284 v4u32 __builtin_msa_dotp_u_w (v8u16, v8u16);
15285 v2u64 __builtin_msa_dotp_u_d (v4u32, v4u32);
15287 v8i16 __builtin_msa_dpadd_s_h (v8i16, v16i8, v16i8);
15288 v4i32 __builtin_msa_dpadd_s_w (v4i32, v8i16, v8i16);
15289 v2i64 __builtin_msa_dpadd_s_d (v2i64, v4i32, v4i32);
15291 v8u16 __builtin_msa_dpadd_u_h (v8u16, v16u8, v16u8);
15292 v4u32 __builtin_msa_dpadd_u_w (v4u32, v8u16, v8u16);
15293 v2u64 __builtin_msa_dpadd_u_d (v2u64, v4u32, v4u32);
15295 v8i16 __builtin_msa_dpsub_s_h (v8i16, v16i8, v16i8);
15296 v4i32 __builtin_msa_dpsub_s_w (v4i32, v8i16, v8i16);
15297 v2i64 __builtin_msa_dpsub_s_d (v2i64, v4i32, v4i32);
15299 v8i16 __builtin_msa_dpsub_u_h (v8i16, v16u8, v16u8);
15300 v4i32 __builtin_msa_dpsub_u_w (v4i32, v8u16, v8u16);
15301 v2i64 __builtin_msa_dpsub_u_d (v2i64, v4u32, v4u32);
15303 v4f32 __builtin_msa_fadd_w (v4f32, v4f32);
15304 v2f64 __builtin_msa_fadd_d (v2f64, v2f64);
15306 v4i32 __builtin_msa_fcaf_w (v4f32, v4f32);
15307 v2i64 __builtin_msa_fcaf_d (v2f64, v2f64);
15309 v4i32 __builtin_msa_fceq_w (v4f32, v4f32);
15310 v2i64 __builtin_msa_fceq_d (v2f64, v2f64);
15312 v4i32 __builtin_msa_fclass_w (v4f32);
15313 v2i64 __builtin_msa_fclass_d (v2f64);
15315 v4i32 __builtin_msa_fcle_w (v4f32, v4f32);
15316 v2i64 __builtin_msa_fcle_d (v2f64, v2f64);
15318 v4i32 __builtin_msa_fclt_w (v4f32, v4f32);
15319 v2i64 __builtin_msa_fclt_d (v2f64, v2f64);
15321 v4i32 __builtin_msa_fcne_w (v4f32, v4f32);
15322 v2i64 __builtin_msa_fcne_d (v2f64, v2f64);
15324 v4i32 __builtin_msa_fcor_w (v4f32, v4f32);
15325 v2i64 __builtin_msa_fcor_d (v2f64, v2f64);
15327 v4i32 __builtin_msa_fcueq_w (v4f32, v4f32);
15328 v2i64 __builtin_msa_fcueq_d (v2f64, v2f64);
15330 v4i32 __builtin_msa_fcule_w (v4f32, v4f32);
15331 v2i64 __builtin_msa_fcule_d (v2f64, v2f64);
15333 v4i32 __builtin_msa_fcult_w (v4f32, v4f32);
15334 v2i64 __builtin_msa_fcult_d (v2f64, v2f64);
15336 v4i32 __builtin_msa_fcun_w (v4f32, v4f32);
15337 v2i64 __builtin_msa_fcun_d (v2f64, v2f64);
15339 v4i32 __builtin_msa_fcune_w (v4f32, v4f32);
15340 v2i64 __builtin_msa_fcune_d (v2f64, v2f64);
15342 v4f32 __builtin_msa_fdiv_w (v4f32, v4f32);
15343 v2f64 __builtin_msa_fdiv_d (v2f64, v2f64);
15345 v8i16 __builtin_msa_fexdo_h (v4f32, v4f32);
15346 v4f32 __builtin_msa_fexdo_w (v2f64, v2f64);
15348 v4f32 __builtin_msa_fexp2_w (v4f32, v4i32);
15349 v2f64 __builtin_msa_fexp2_d (v2f64, v2i64);
15351 v4f32 __builtin_msa_fexupl_w (v8i16);
15352 v2f64 __builtin_msa_fexupl_d (v4f32);
15354 v4f32 __builtin_msa_fexupr_w (v8i16);
15355 v2f64 __builtin_msa_fexupr_d (v4f32);
15357 v4f32 __builtin_msa_ffint_s_w (v4i32);
15358 v2f64 __builtin_msa_ffint_s_d (v2i64);
15360 v4f32 __builtin_msa_ffint_u_w (v4u32);
15361 v2f64 __builtin_msa_ffint_u_d (v2u64);
15363 v4f32 __builtin_msa_ffql_w (v8i16);
15364 v2f64 __builtin_msa_ffql_d (v4i32);
15366 v4f32 __builtin_msa_ffqr_w (v8i16);
15367 v2f64 __builtin_msa_ffqr_d (v4i32);
15369 v16i8 __builtin_msa_fill_b (i32);
15370 v8i16 __builtin_msa_fill_h (i32);
15371 v4i32 __builtin_msa_fill_w (i32);
15372 v2i64 __builtin_msa_fill_d (i64);
15374 v4f32 __builtin_msa_flog2_w (v4f32);
15375 v2f64 __builtin_msa_flog2_d (v2f64);
15377 v4f32 __builtin_msa_fmadd_w (v4f32, v4f32, v4f32);
15378 v2f64 __builtin_msa_fmadd_d (v2f64, v2f64, v2f64);
15380 v4f32 __builtin_msa_fmax_w (v4f32, v4f32);
15381 v2f64 __builtin_msa_fmax_d (v2f64, v2f64);
15383 v4f32 __builtin_msa_fmax_a_w (v4f32, v4f32);
15384 v2f64 __builtin_msa_fmax_a_d (v2f64, v2f64);
15386 v4f32 __builtin_msa_fmin_w (v4f32, v4f32);
15387 v2f64 __builtin_msa_fmin_d (v2f64, v2f64);
15389 v4f32 __builtin_msa_fmin_a_w (v4f32, v4f32);
15390 v2f64 __builtin_msa_fmin_a_d (v2f64, v2f64);
15392 v4f32 __builtin_msa_fmsub_w (v4f32, v4f32, v4f32);
15393 v2f64 __builtin_msa_fmsub_d (v2f64, v2f64, v2f64);
15395 v4f32 __builtin_msa_fmul_w (v4f32, v4f32);
15396 v2f64 __builtin_msa_fmul_d (v2f64, v2f64);
15398 v4f32 __builtin_msa_frint_w (v4f32);
15399 v2f64 __builtin_msa_frint_d (v2f64);
15401 v4f32 __builtin_msa_frcp_w (v4f32);
15402 v2f64 __builtin_msa_frcp_d (v2f64);
15404 v4f32 __builtin_msa_frsqrt_w (v4f32);
15405 v2f64 __builtin_msa_frsqrt_d (v2f64);
15407 v4i32 __builtin_msa_fsaf_w (v4f32, v4f32);
15408 v2i64 __builtin_msa_fsaf_d (v2f64, v2f64);
15410 v4i32 __builtin_msa_fseq_w (v4f32, v4f32);
15411 v2i64 __builtin_msa_fseq_d (v2f64, v2f64);
15413 v4i32 __builtin_msa_fsle_w (v4f32, v4f32);
15414 v2i64 __builtin_msa_fsle_d (v2f64, v2f64);
15416 v4i32 __builtin_msa_fslt_w (v4f32, v4f32);
15417 v2i64 __builtin_msa_fslt_d (v2f64, v2f64);
15419 v4i32 __builtin_msa_fsne_w (v4f32, v4f32);
15420 v2i64 __builtin_msa_fsne_d (v2f64, v2f64);
15422 v4i32 __builtin_msa_fsor_w (v4f32, v4f32);
15423 v2i64 __builtin_msa_fsor_d (v2f64, v2f64);
15425 v4f32 __builtin_msa_fsqrt_w (v4f32);
15426 v2f64 __builtin_msa_fsqrt_d (v2f64);
15428 v4f32 __builtin_msa_fsub_w (v4f32, v4f32);
15429 v2f64 __builtin_msa_fsub_d (v2f64, v2f64);
15431 v4i32 __builtin_msa_fsueq_w (v4f32, v4f32);
15432 v2i64 __builtin_msa_fsueq_d (v2f64, v2f64);
15434 v4i32 __builtin_msa_fsule_w (v4f32, v4f32);
15435 v2i64 __builtin_msa_fsule_d (v2f64, v2f64);
15437 v4i32 __builtin_msa_fsult_w (v4f32, v4f32);
15438 v2i64 __builtin_msa_fsult_d (v2f64, v2f64);
15440 v4i32 __builtin_msa_fsun_w (v4f32, v4f32);
15441 v2i64 __builtin_msa_fsun_d (v2f64, v2f64);
15443 v4i32 __builtin_msa_fsune_w (v4f32, v4f32);
15444 v2i64 __builtin_msa_fsune_d (v2f64, v2f64);
15446 v4i32 __builtin_msa_ftint_s_w (v4f32);
15447 v2i64 __builtin_msa_ftint_s_d (v2f64);
15449 v4u32 __builtin_msa_ftint_u_w (v4f32);
15450 v2u64 __builtin_msa_ftint_u_d (v2f64);
15452 v8i16 __builtin_msa_ftq_h (v4f32, v4f32);
15453 v4i32 __builtin_msa_ftq_w (v2f64, v2f64);
15455 v4i32 __builtin_msa_ftrunc_s_w (v4f32);
15456 v2i64 __builtin_msa_ftrunc_s_d (v2f64);
15458 v4u32 __builtin_msa_ftrunc_u_w (v4f32);
15459 v2u64 __builtin_msa_ftrunc_u_d (v2f64);
15461 v8i16 __builtin_msa_hadd_s_h (v16i8, v16i8);
15462 v4i32 __builtin_msa_hadd_s_w (v8i16, v8i16);
15463 v2i64 __builtin_msa_hadd_s_d (v4i32, v4i32);
15465 v8u16 __builtin_msa_hadd_u_h (v16u8, v16u8);
15466 v4u32 __builtin_msa_hadd_u_w (v8u16, v8u16);
15467 v2u64 __builtin_msa_hadd_u_d (v4u32, v4u32);
15469 v8i16 __builtin_msa_hsub_s_h (v16i8, v16i8);
15470 v4i32 __builtin_msa_hsub_s_w (v8i16, v8i16);
15471 v2i64 __builtin_msa_hsub_s_d (v4i32, v4i32);
15473 v8i16 __builtin_msa_hsub_u_h (v16u8, v16u8);
15474 v4i32 __builtin_msa_hsub_u_w (v8u16, v8u16);
15475 v2i64 __builtin_msa_hsub_u_d (v4u32, v4u32);
15477 v16i8 __builtin_msa_ilvev_b (v16i8, v16i8);
15478 v8i16 __builtin_msa_ilvev_h (v8i16, v8i16);
15479 v4i32 __builtin_msa_ilvev_w (v4i32, v4i32);
15480 v2i64 __builtin_msa_ilvev_d (v2i64, v2i64);
15482 v16i8 __builtin_msa_ilvl_b (v16i8, v16i8);
15483 v8i16 __builtin_msa_ilvl_h (v8i16, v8i16);
15484 v4i32 __builtin_msa_ilvl_w (v4i32, v4i32);
15485 v2i64 __builtin_msa_ilvl_d (v2i64, v2i64);
15487 v16i8 __builtin_msa_ilvod_b (v16i8, v16i8);
15488 v8i16 __builtin_msa_ilvod_h (v8i16, v8i16);
15489 v4i32 __builtin_msa_ilvod_w (v4i32, v4i32);
15490 v2i64 __builtin_msa_ilvod_d (v2i64, v2i64);
15492 v16i8 __builtin_msa_ilvr_b (v16i8, v16i8);
15493 v8i16 __builtin_msa_ilvr_h (v8i16, v8i16);
15494 v4i32 __builtin_msa_ilvr_w (v4i32, v4i32);
15495 v2i64 __builtin_msa_ilvr_d (v2i64, v2i64);
15497 v16i8 __builtin_msa_insert_b (v16i8, imm0_15, i32);
15498 v8i16 __builtin_msa_insert_h (v8i16, imm0_7, i32);
15499 v4i32 __builtin_msa_insert_w (v4i32, imm0_3, i32);
15500 v2i64 __builtin_msa_insert_d (v2i64, imm0_1, i64);
15502 v16i8 __builtin_msa_insve_b (v16i8, imm0_15, v16i8);
15503 v8i16 __builtin_msa_insve_h (v8i16, imm0_7, v8i16);
15504 v4i32 __builtin_msa_insve_w (v4i32, imm0_3, v4i32);
15505 v2i64 __builtin_msa_insve_d (v2i64, imm0_1, v2i64);
15507 v16i8 __builtin_msa_ld_b (void *, imm_n512_511);
15508 v8i16 __builtin_msa_ld_h (void *, imm_n1024_1022);
15509 v4i32 __builtin_msa_ld_w (void *, imm_n2048_2044);
15510 v2i64 __builtin_msa_ld_d (void *, imm_n4096_4088);
15512 v16i8 __builtin_msa_ldi_b (imm_n512_511);
15513 v8i16 __builtin_msa_ldi_h (imm_n512_511);
15514 v4i32 __builtin_msa_ldi_w (imm_n512_511);
15515 v2i64 __builtin_msa_ldi_d (imm_n512_511);
15517 v8i16 __builtin_msa_madd_q_h (v8i16, v8i16, v8i16);
15518 v4i32 __builtin_msa_madd_q_w (v4i32, v4i32, v4i32);
15520 v8i16 __builtin_msa_maddr_q_h (v8i16, v8i16, v8i16);
15521 v4i32 __builtin_msa_maddr_q_w (v4i32, v4i32, v4i32);
15523 v16i8 __builtin_msa_maddv_b (v16i8, v16i8, v16i8);
15524 v8i16 __builtin_msa_maddv_h (v8i16, v8i16, v8i16);
15525 v4i32 __builtin_msa_maddv_w (v4i32, v4i32, v4i32);
15526 v2i64 __builtin_msa_maddv_d (v2i64, v2i64, v2i64);
15528 v16i8 __builtin_msa_max_a_b (v16i8, v16i8);
15529 v8i16 __builtin_msa_max_a_h (v8i16, v8i16);
15530 v4i32 __builtin_msa_max_a_w (v4i32, v4i32);
15531 v2i64 __builtin_msa_max_a_d (v2i64, v2i64);
15533 v16i8 __builtin_msa_max_s_b (v16i8, v16i8);
15534 v8i16 __builtin_msa_max_s_h (v8i16, v8i16);
15535 v4i32 __builtin_msa_max_s_w (v4i32, v4i32);
15536 v2i64 __builtin_msa_max_s_d (v2i64, v2i64);
15538 v16u8 __builtin_msa_max_u_b (v16u8, v16u8);
15539 v8u16 __builtin_msa_max_u_h (v8u16, v8u16);
15540 v4u32 __builtin_msa_max_u_w (v4u32, v4u32);
15541 v2u64 __builtin_msa_max_u_d (v2u64, v2u64);
15543 v16i8 __builtin_msa_maxi_s_b (v16i8, imm_n16_15);
15544 v8i16 __builtin_msa_maxi_s_h (v8i16, imm_n16_15);
15545 v4i32 __builtin_msa_maxi_s_w (v4i32, imm_n16_15);
15546 v2i64 __builtin_msa_maxi_s_d (v2i64, imm_n16_15);
15548 v16u8 __builtin_msa_maxi_u_b (v16u8, imm0_31);
15549 v8u16 __builtin_msa_maxi_u_h (v8u16, imm0_31);
15550 v4u32 __builtin_msa_maxi_u_w (v4u32, imm0_31);
15551 v2u64 __builtin_msa_maxi_u_d (v2u64, imm0_31);
15553 v16i8 __builtin_msa_min_a_b (v16i8, v16i8);
15554 v8i16 __builtin_msa_min_a_h (v8i16, v8i16);
15555 v4i32 __builtin_msa_min_a_w (v4i32, v4i32);
15556 v2i64 __builtin_msa_min_a_d (v2i64, v2i64);
15558 v16i8 __builtin_msa_min_s_b (v16i8, v16i8);
15559 v8i16 __builtin_msa_min_s_h (v8i16, v8i16);
15560 v4i32 __builtin_msa_min_s_w (v4i32, v4i32);
15561 v2i64 __builtin_msa_min_s_d (v2i64, v2i64);
15563 v16u8 __builtin_msa_min_u_b (v16u8, v16u8);
15564 v8u16 __builtin_msa_min_u_h (v8u16, v8u16);
15565 v4u32 __builtin_msa_min_u_w (v4u32, v4u32);
15566 v2u64 __builtin_msa_min_u_d (v2u64, v2u64);
15568 v16i8 __builtin_msa_mini_s_b (v16i8, imm_n16_15);
15569 v8i16 __builtin_msa_mini_s_h (v8i16, imm_n16_15);
15570 v4i32 __builtin_msa_mini_s_w (v4i32, imm_n16_15);
15571 v2i64 __builtin_msa_mini_s_d (v2i64, imm_n16_15);
15573 v16u8 __builtin_msa_mini_u_b (v16u8, imm0_31);
15574 v8u16 __builtin_msa_mini_u_h (v8u16, imm0_31);
15575 v4u32 __builtin_msa_mini_u_w (v4u32, imm0_31);
15576 v2u64 __builtin_msa_mini_u_d (v2u64, imm0_31);
15578 v16i8 __builtin_msa_mod_s_b (v16i8, v16i8);
15579 v8i16 __builtin_msa_mod_s_h (v8i16, v8i16);
15580 v4i32 __builtin_msa_mod_s_w (v4i32, v4i32);
15581 v2i64 __builtin_msa_mod_s_d (v2i64, v2i64);
15583 v16u8 __builtin_msa_mod_u_b (v16u8, v16u8);
15584 v8u16 __builtin_msa_mod_u_h (v8u16, v8u16);
15585 v4u32 __builtin_msa_mod_u_w (v4u32, v4u32);
15586 v2u64 __builtin_msa_mod_u_d (v2u64, v2u64);
15588 v16i8 __builtin_msa_move_v (v16i8);
15590 v8i16 __builtin_msa_msub_q_h (v8i16, v8i16, v8i16);
15591 v4i32 __builtin_msa_msub_q_w (v4i32, v4i32, v4i32);
15593 v8i16 __builtin_msa_msubr_q_h (v8i16, v8i16, v8i16);
15594 v4i32 __builtin_msa_msubr_q_w (v4i32, v4i32, v4i32);
15596 v16i8 __builtin_msa_msubv_b (v16i8, v16i8, v16i8);
15597 v8i16 __builtin_msa_msubv_h (v8i16, v8i16, v8i16);
15598 v4i32 __builtin_msa_msubv_w (v4i32, v4i32, v4i32);
15599 v2i64 __builtin_msa_msubv_d (v2i64, v2i64, v2i64);
15601 v8i16 __builtin_msa_mul_q_h (v8i16, v8i16);
15602 v4i32 __builtin_msa_mul_q_w (v4i32, v4i32);
15604 v8i16 __builtin_msa_mulr_q_h (v8i16, v8i16);
15605 v4i32 __builtin_msa_mulr_q_w (v4i32, v4i32);
15607 v16i8 __builtin_msa_mulv_b (v16i8, v16i8);
15608 v8i16 __builtin_msa_mulv_h (v8i16, v8i16);
15609 v4i32 __builtin_msa_mulv_w (v4i32, v4i32);
15610 v2i64 __builtin_msa_mulv_d (v2i64, v2i64);
15612 v16i8 __builtin_msa_nloc_b (v16i8);
15613 v8i16 __builtin_msa_nloc_h (v8i16);
15614 v4i32 __builtin_msa_nloc_w (v4i32);
15615 v2i64 __builtin_msa_nloc_d (v2i64);
15617 v16i8 __builtin_msa_nlzc_b (v16i8);
15618 v8i16 __builtin_msa_nlzc_h (v8i16);
15619 v4i32 __builtin_msa_nlzc_w (v4i32);
15620 v2i64 __builtin_msa_nlzc_d (v2i64);
15622 v16u8 __builtin_msa_nor_v (v16u8, v16u8);
15624 v16u8 __builtin_msa_nori_b (v16u8, imm0_255);
15626 v16u8 __builtin_msa_or_v (v16u8, v16u8);
15628 v16u8 __builtin_msa_ori_b (v16u8, imm0_255);
15630 v16i8 __builtin_msa_pckev_b (v16i8, v16i8);
15631 v8i16 __builtin_msa_pckev_h (v8i16, v8i16);
15632 v4i32 __builtin_msa_pckev_w (v4i32, v4i32);
15633 v2i64 __builtin_msa_pckev_d (v2i64, v2i64);
15635 v16i8 __builtin_msa_pckod_b (v16i8, v16i8);
15636 v8i16 __builtin_msa_pckod_h (v8i16, v8i16);
15637 v4i32 __builtin_msa_pckod_w (v4i32, v4i32);
15638 v2i64 __builtin_msa_pckod_d (v2i64, v2i64);
15640 v16i8 __builtin_msa_pcnt_b (v16i8);
15641 v8i16 __builtin_msa_pcnt_h (v8i16);
15642 v4i32 __builtin_msa_pcnt_w (v4i32);
15643 v2i64 __builtin_msa_pcnt_d (v2i64);
15645 v16i8 __builtin_msa_sat_s_b (v16i8, imm0_7);
15646 v8i16 __builtin_msa_sat_s_h (v8i16, imm0_15);
15647 v4i32 __builtin_msa_sat_s_w (v4i32, imm0_31);
15648 v2i64 __builtin_msa_sat_s_d (v2i64, imm0_63);
15650 v16u8 __builtin_msa_sat_u_b (v16u8, imm0_7);
15651 v8u16 __builtin_msa_sat_u_h (v8u16, imm0_15);
15652 v4u32 __builtin_msa_sat_u_w (v4u32, imm0_31);
15653 v2u64 __builtin_msa_sat_u_d (v2u64, imm0_63);
15655 v16i8 __builtin_msa_shf_b (v16i8, imm0_255);
15656 v8i16 __builtin_msa_shf_h (v8i16, imm0_255);
15657 v4i32 __builtin_msa_shf_w (v4i32, imm0_255);
15659 v16i8 __builtin_msa_sld_b (v16i8, v16i8, i32);
15660 v8i16 __builtin_msa_sld_h (v8i16, v8i16, i32);
15661 v4i32 __builtin_msa_sld_w (v4i32, v4i32, i32);
15662 v2i64 __builtin_msa_sld_d (v2i64, v2i64, i32);
15664 v16i8 __builtin_msa_sldi_b (v16i8, v16i8, imm0_15);
15665 v8i16 __builtin_msa_sldi_h (v8i16, v8i16, imm0_7);
15666 v4i32 __builtin_msa_sldi_w (v4i32, v4i32, imm0_3);
15667 v2i64 __builtin_msa_sldi_d (v2i64, v2i64, imm0_1);
15669 v16i8 __builtin_msa_sll_b (v16i8, v16i8);
15670 v8i16 __builtin_msa_sll_h (v8i16, v8i16);
15671 v4i32 __builtin_msa_sll_w (v4i32, v4i32);
15672 v2i64 __builtin_msa_sll_d (v2i64, v2i64);
15674 v16i8 __builtin_msa_slli_b (v16i8, imm0_7);
15675 v8i16 __builtin_msa_slli_h (v8i16, imm0_15);
15676 v4i32 __builtin_msa_slli_w (v4i32, imm0_31);
15677 v2i64 __builtin_msa_slli_d (v2i64, imm0_63);
15679 v16i8 __builtin_msa_splat_b (v16i8, i32);
15680 v8i16 __builtin_msa_splat_h (v8i16, i32);
15681 v4i32 __builtin_msa_splat_w (v4i32, i32);
15682 v2i64 __builtin_msa_splat_d (v2i64, i32);
15684 v16i8 __builtin_msa_splati_b (v16i8, imm0_15);
15685 v8i16 __builtin_msa_splati_h (v8i16, imm0_7);
15686 v4i32 __builtin_msa_splati_w (v4i32, imm0_3);
15687 v2i64 __builtin_msa_splati_d (v2i64, imm0_1);
15689 v16i8 __builtin_msa_sra_b (v16i8, v16i8);
15690 v8i16 __builtin_msa_sra_h (v8i16, v8i16);
15691 v4i32 __builtin_msa_sra_w (v4i32, v4i32);
15692 v2i64 __builtin_msa_sra_d (v2i64, v2i64);
15694 v16i8 __builtin_msa_srai_b (v16i8, imm0_7);
15695 v8i16 __builtin_msa_srai_h (v8i16, imm0_15);
15696 v4i32 __builtin_msa_srai_w (v4i32, imm0_31);
15697 v2i64 __builtin_msa_srai_d (v2i64, imm0_63);
15699 v16i8 __builtin_msa_srar_b (v16i8, v16i8);
15700 v8i16 __builtin_msa_srar_h (v8i16, v8i16);
15701 v4i32 __builtin_msa_srar_w (v4i32, v4i32);
15702 v2i64 __builtin_msa_srar_d (v2i64, v2i64);
15704 v16i8 __builtin_msa_srari_b (v16i8, imm0_7);
15705 v8i16 __builtin_msa_srari_h (v8i16, imm0_15);
15706 v4i32 __builtin_msa_srari_w (v4i32, imm0_31);
15707 v2i64 __builtin_msa_srari_d (v2i64, imm0_63);
15709 v16i8 __builtin_msa_srl_b (v16i8, v16i8);
15710 v8i16 __builtin_msa_srl_h (v8i16, v8i16);
15711 v4i32 __builtin_msa_srl_w (v4i32, v4i32);
15712 v2i64 __builtin_msa_srl_d (v2i64, v2i64);
15714 v16i8 __builtin_msa_srli_b (v16i8, imm0_7);
15715 v8i16 __builtin_msa_srli_h (v8i16, imm0_15);
15716 v4i32 __builtin_msa_srli_w (v4i32, imm0_31);
15717 v2i64 __builtin_msa_srli_d (v2i64, imm0_63);
15719 v16i8 __builtin_msa_srlr_b (v16i8, v16i8);
15720 v8i16 __builtin_msa_srlr_h (v8i16, v8i16);
15721 v4i32 __builtin_msa_srlr_w (v4i32, v4i32);
15722 v2i64 __builtin_msa_srlr_d (v2i64, v2i64);
15724 v16i8 __builtin_msa_srlri_b (v16i8, imm0_7);
15725 v8i16 __builtin_msa_srlri_h (v8i16, imm0_15);
15726 v4i32 __builtin_msa_srlri_w (v4i32, imm0_31);
15727 v2i64 __builtin_msa_srlri_d (v2i64, imm0_63);
15729 void __builtin_msa_st_b (v16i8, void *, imm_n512_511);
15730 void __builtin_msa_st_h (v8i16, void *, imm_n1024_1022);
15731 void __builtin_msa_st_w (v4i32, void *, imm_n2048_2044);
15732 void __builtin_msa_st_d (v2i64, void *, imm_n4096_4088);
15734 v16i8 __builtin_msa_subs_s_b (v16i8, v16i8);
15735 v8i16 __builtin_msa_subs_s_h (v8i16, v8i16);
15736 v4i32 __builtin_msa_subs_s_w (v4i32, v4i32);
15737 v2i64 __builtin_msa_subs_s_d (v2i64, v2i64);
15739 v16u8 __builtin_msa_subs_u_b (v16u8, v16u8);
15740 v8u16 __builtin_msa_subs_u_h (v8u16, v8u16);
15741 v4u32 __builtin_msa_subs_u_w (v4u32, v4u32);
15742 v2u64 __builtin_msa_subs_u_d (v2u64, v2u64);
15744 v16u8 __builtin_msa_subsus_u_b (v16u8, v16i8);
15745 v8u16 __builtin_msa_subsus_u_h (v8u16, v8i16);
15746 v4u32 __builtin_msa_subsus_u_w (v4u32, v4i32);
15747 v2u64 __builtin_msa_subsus_u_d (v2u64, v2i64);
15749 v16i8 __builtin_msa_subsuu_s_b (v16u8, v16u8);
15750 v8i16 __builtin_msa_subsuu_s_h (v8u16, v8u16);
15751 v4i32 __builtin_msa_subsuu_s_w (v4u32, v4u32);
15752 v2i64 __builtin_msa_subsuu_s_d (v2u64, v2u64);
15754 v16i8 __builtin_msa_subv_b (v16i8, v16i8);
15755 v8i16 __builtin_msa_subv_h (v8i16, v8i16);
15756 v4i32 __builtin_msa_subv_w (v4i32, v4i32);
15757 v2i64 __builtin_msa_subv_d (v2i64, v2i64);
15759 v16i8 __builtin_msa_subvi_b (v16i8, imm0_31);
15760 v8i16 __builtin_msa_subvi_h (v8i16, imm0_31);
15761 v4i32 __builtin_msa_subvi_w (v4i32, imm0_31);
15762 v2i64 __builtin_msa_subvi_d (v2i64, imm0_31);
15764 v16i8 __builtin_msa_vshf_b (v16i8, v16i8, v16i8);
15765 v8i16 __builtin_msa_vshf_h (v8i16, v8i16, v8i16);
15766 v4i32 __builtin_msa_vshf_w (v4i32, v4i32, v4i32);
15767 v2i64 __builtin_msa_vshf_d (v2i64, v2i64, v2i64);
15769 v16u8 __builtin_msa_xor_v (v16u8, v16u8);
15771 v16u8 __builtin_msa_xori_b (v16u8, imm0_255);
15772 @end smallexample
15774 @node Other MIPS Built-in Functions
15775 @subsection Other MIPS Built-in Functions
15777 GCC provides other MIPS-specific built-in functions:
15779 @table @code
15780 @item void __builtin_mips_cache (int @var{op}, const volatile void *@var{addr})
15781 Insert a @samp{cache} instruction with operands @var{op} and @var{addr}.
15782 GCC defines the preprocessor macro @code{___GCC_HAVE_BUILTIN_MIPS_CACHE}
15783 when this function is available.
15785 @item unsigned int __builtin_mips_get_fcsr (void)
15786 @itemx void __builtin_mips_set_fcsr (unsigned int @var{value})
15787 Get and set the contents of the floating-point control and status register
15788 (FPU control register 31).  These functions are only available in hard-float
15789 code but can be called in both MIPS16 and non-MIPS16 contexts.
15791 @code{__builtin_mips_set_fcsr} can be used to change any bit of the
15792 register except the condition codes, which GCC assumes are preserved.
15793 @end table
15795 @node MSP430 Built-in Functions
15796 @subsection MSP430 Built-in Functions
15798 GCC provides a couple of special builtin functions to aid in the
15799 writing of interrupt handlers in C.
15801 @table @code
15802 @item __bic_SR_register_on_exit (int @var{mask})
15803 This clears the indicated bits in the saved copy of the status register
15804 currently residing on the stack.  This only works inside interrupt
15805 handlers and the changes to the status register will only take affect
15806 once the handler returns.
15808 @item __bis_SR_register_on_exit (int @var{mask})
15809 This sets the indicated bits in the saved copy of the status register
15810 currently residing on the stack.  This only works inside interrupt
15811 handlers and the changes to the status register will only take affect
15812 once the handler returns.
15814 @item __delay_cycles (long long @var{cycles})
15815 This inserts an instruction sequence that takes exactly @var{cycles}
15816 cycles (between 0 and about 17E9) to complete.  The inserted sequence
15817 may use jumps, loops, or no-ops, and does not interfere with any other
15818 instructions.  Note that @var{cycles} must be a compile-time constant
15819 integer - that is, you must pass a number, not a variable that may be
15820 optimized to a constant later.  The number of cycles delayed by this
15821 builtin is exact.
15822 @end table
15824 @node NDS32 Built-in Functions
15825 @subsection NDS32 Built-in Functions
15827 These built-in functions are available for the NDS32 target:
15829 @deftypefn {Built-in Function} void __builtin_nds32_isync (int *@var{addr})
15830 Insert an ISYNC instruction into the instruction stream where
15831 @var{addr} is an instruction address for serialization.
15832 @end deftypefn
15834 @deftypefn {Built-in Function} void __builtin_nds32_isb (void)
15835 Insert an ISB instruction into the instruction stream.
15836 @end deftypefn
15838 @deftypefn {Built-in Function} int __builtin_nds32_mfsr (int @var{sr})
15839 Return the content of a system register which is mapped by @var{sr}.
15840 @end deftypefn
15842 @deftypefn {Built-in Function} int __builtin_nds32_mfusr (int @var{usr})
15843 Return the content of a user space register which is mapped by @var{usr}.
15844 @end deftypefn
15846 @deftypefn {Built-in Function} void __builtin_nds32_mtsr (int @var{value}, int @var{sr})
15847 Move the @var{value} to a system register which is mapped by @var{sr}.
15848 @end deftypefn
15850 @deftypefn {Built-in Function} void __builtin_nds32_mtusr (int @var{value}, int @var{usr})
15851 Move the @var{value} to a user space register which is mapped by @var{usr}.
15852 @end deftypefn
15854 @deftypefn {Built-in Function} void __builtin_nds32_setgie_en (void)
15855 Enable global interrupt.
15856 @end deftypefn
15858 @deftypefn {Built-in Function} void __builtin_nds32_setgie_dis (void)
15859 Disable global interrupt.
15860 @end deftypefn
15862 @node picoChip Built-in Functions
15863 @subsection picoChip Built-in Functions
15865 GCC provides an interface to selected machine instructions from the
15866 picoChip instruction set.
15868 @table @code
15869 @item int __builtin_sbc (int @var{value})
15870 Sign bit count.  Return the number of consecutive bits in @var{value}
15871 that have the same value as the sign bit.  The result is the number of
15872 leading sign bits minus one, giving the number of redundant sign bits in
15873 @var{value}.
15875 @item int __builtin_byteswap (int @var{value})
15876 Byte swap.  Return the result of swapping the upper and lower bytes of
15877 @var{value}.
15879 @item int __builtin_brev (int @var{value})
15880 Bit reversal.  Return the result of reversing the bits in
15881 @var{value}.  Bit 15 is swapped with bit 0, bit 14 is swapped with bit 1,
15882 and so on.
15884 @item int __builtin_adds (int @var{x}, int @var{y})
15885 Saturating addition.  Return the result of adding @var{x} and @var{y},
15886 storing the value 32767 if the result overflows.
15888 @item int __builtin_subs (int @var{x}, int @var{y})
15889 Saturating subtraction.  Return the result of subtracting @var{y} from
15890 @var{x}, storing the value @minus{}32768 if the result overflows.
15892 @item void __builtin_halt (void)
15893 Halt.  The processor stops execution.  This built-in is useful for
15894 implementing assertions.
15896 @end table
15898 @node Basic PowerPC Built-in Functions
15899 @subsection Basic PowerPC Built-in Functions
15901 @menu
15902 * Basic PowerPC Built-in Functions Available on all Configurations::
15903 * Basic PowerPC Built-in Functions Available on ISA 2.05::
15904 * Basic PowerPC Built-in Functions Available on ISA 2.06::
15905 * Basic PowerPC Built-in Functions Available on ISA 2.07::
15906 * Basic PowerPC Built-in Functions Available on ISA 3.0::
15907 @end menu
15909 This section describes PowerPC built-in functions that do not require
15910 the inclusion of any special header files to declare prototypes or
15911 provide macro definitions.  The sections that follow describe
15912 additional PowerPC built-in functions.
15914 @node Basic PowerPC Built-in Functions Available on all Configurations
15915 @subsubsection Basic PowerPC Built-in Functions Available on all Configurations
15917 @deftypefn {Built-in Function} void __builtin_cpu_init (void)
15918 This function is a @code{nop} on the PowerPC platform and is included solely
15919 to maintain API compatibility with the x86 builtins.
15920 @end deftypefn
15922 @deftypefn {Built-in Function} int __builtin_cpu_is (const char *@var{cpuname})
15923 This function returns a value of @code{1} if the run-time CPU is of type
15924 @var{cpuname} and returns @code{0} otherwise
15926 The @code{__builtin_cpu_is} function requires GLIBC 2.23 or newer
15927 which exports the hardware capability bits.  GCC defines the macro
15928 @code{__BUILTIN_CPU_SUPPORTS__} if the @code{__builtin_cpu_supports}
15929 built-in function is fully supported.
15931 If GCC was configured to use a GLIBC before 2.23, the built-in
15932 function @code{__builtin_cpu_is} always returns a 0 and the compiler
15933 issues a warning.
15935 The following CPU names can be detected:
15937 @table @samp
15938 @item power9
15939 IBM POWER9 Server CPU.
15940 @item power8
15941 IBM POWER8 Server CPU.
15942 @item power7
15943 IBM POWER7 Server CPU.
15944 @item power6x
15945 IBM POWER6 Server CPU (RAW mode).
15946 @item power6
15947 IBM POWER6 Server CPU (Architected mode).
15948 @item power5+
15949 IBM POWER5+ Server CPU.
15950 @item power5
15951 IBM POWER5 Server CPU.
15952 @item ppc970
15953 IBM 970 Server CPU (ie, Apple G5).
15954 @item power4
15955 IBM POWER4 Server CPU.
15956 @item ppca2
15957 IBM A2 64-bit Embedded CPU
15958 @item ppc476
15959 IBM PowerPC 476FP 32-bit Embedded CPU.
15960 @item ppc464
15961 IBM PowerPC 464 32-bit Embedded CPU.
15962 @item ppc440
15963 PowerPC 440 32-bit Embedded CPU.
15964 @item ppc405
15965 PowerPC 405 32-bit Embedded CPU.
15966 @item ppc-cell-be
15967 IBM PowerPC Cell Broadband Engine Architecture CPU.
15968 @end table
15970 Here is an example:
15971 @smallexample
15972 #ifdef __BUILTIN_CPU_SUPPORTS__
15973   if (__builtin_cpu_is ("power8"))
15974     @{
15975        do_power8 (); // POWER8 specific implementation.
15976     @}
15977   else
15978 #endif
15979     @{
15980        do_generic (); // Generic implementation.
15981     @}
15982 @end smallexample
15983 @end deftypefn
15985 @deftypefn {Built-in Function} int __builtin_cpu_supports (const char *@var{feature})
15986 This function returns a value of @code{1} if the run-time CPU supports the HWCAP
15987 feature @var{feature} and returns @code{0} otherwise.
15989 The @code{__builtin_cpu_supports} function requires GLIBC 2.23 or
15990 newer which exports the hardware capability bits.  GCC defines the
15991 macro @code{__BUILTIN_CPU_SUPPORTS__} if the
15992 @code{__builtin_cpu_supports} built-in function is fully supported.
15994 If GCC was configured to use a GLIBC before 2.23, the built-in
15995 function @code{__builtin_cpu_suports} always returns a 0 and the
15996 compiler issues a warning.
15998 The following features can be
15999 detected:
16001 @table @samp
16002 @item 4xxmac
16003 4xx CPU has a Multiply Accumulator.
16004 @item altivec
16005 CPU has a SIMD/Vector Unit.
16006 @item arch_2_05
16007 CPU supports ISA 2.05 (eg, POWER6)
16008 @item arch_2_06
16009 CPU supports ISA 2.06 (eg, POWER7)
16010 @item arch_2_07
16011 CPU supports ISA 2.07 (eg, POWER8)
16012 @item arch_3_00
16013 CPU supports ISA 3.0 (eg, POWER9)
16014 @item archpmu
16015 CPU supports the set of compatible performance monitoring events.
16016 @item booke
16017 CPU supports the Embedded ISA category.
16018 @item cellbe
16019 CPU has a CELL broadband engine.
16020 @item darn
16021 CPU supports the @code{darn} (deliver a random number) instruction.
16022 @item dfp
16023 CPU has a decimal floating point unit.
16024 @item dscr
16025 CPU supports the data stream control register.
16026 @item ebb
16027 CPU supports event base branching.
16028 @item efpdouble
16029 CPU has a SPE double precision floating point unit.
16030 @item efpsingle
16031 CPU has a SPE single precision floating point unit.
16032 @item fpu
16033 CPU has a floating point unit.
16034 @item htm
16035 CPU has hardware transaction memory instructions.
16036 @item htm-nosc
16037 Kernel aborts hardware transactions when a syscall is made.
16038 @item htm-no-suspend
16039 CPU supports hardware transaction memory but does not support the
16040 @code{tsuspend.} instruction.
16041 @item ic_snoop
16042 CPU supports icache snooping capabilities.
16043 @item ieee128
16044 CPU supports 128-bit IEEE binary floating point instructions.
16045 @item isel
16046 CPU supports the integer select instruction.
16047 @item mmu
16048 CPU has a memory management unit.
16049 @item notb
16050 CPU does not have a timebase (eg, 601 and 403gx).
16051 @item pa6t
16052 CPU supports the PA Semi 6T CORE ISA.
16053 @item power4
16054 CPU supports ISA 2.00 (eg, POWER4)
16055 @item power5
16056 CPU supports ISA 2.02 (eg, POWER5)
16057 @item power5+
16058 CPU supports ISA 2.03 (eg, POWER5+)
16059 @item power6x
16060 CPU supports ISA 2.05 (eg, POWER6) extended opcodes mffgpr and mftgpr.
16061 @item ppc32
16062 CPU supports 32-bit mode execution.
16063 @item ppc601
16064 CPU supports the old POWER ISA (eg, 601)
16065 @item ppc64
16066 CPU supports 64-bit mode execution.
16067 @item ppcle
16068 CPU supports a little-endian mode that uses address swizzling.
16069 @item scv
16070 Kernel supports system call vectored.
16071 @item smt
16072 CPU support simultaneous multi-threading.
16073 @item spe
16074 CPU has a signal processing extension unit.
16075 @item tar
16076 CPU supports the target address register.
16077 @item true_le
16078 CPU supports true little-endian mode.
16079 @item ucache
16080 CPU has unified I/D cache.
16081 @item vcrypto
16082 CPU supports the vector cryptography instructions.
16083 @item vsx
16084 CPU supports the vector-scalar extension.
16085 @end table
16087 Here is an example:
16088 @smallexample
16089 #ifdef __BUILTIN_CPU_SUPPORTS__
16090   if (__builtin_cpu_supports ("fpu"))
16091     @{
16092        asm("fadd %0,%1,%2" : "=d"(dst) : "d"(src1), "d"(src2));
16093     @}
16094   else
16095 #endif
16096     @{
16097        dst = __fadd (src1, src2); // Software FP addition function.
16098     @}
16099 @end smallexample
16100 @end deftypefn
16102 The following built-in functions are also available on all PowerPC
16103 processors:
16104 @smallexample
16105 uint64_t __builtin_ppc_get_timebase ();
16106 unsigned long __builtin_ppc_mftb ();
16107 double __builtin_unpack_ibm128 (__ibm128, int);
16108 __ibm128 __builtin_pack_ibm128 (double, double);
16109 double __builtin_mffs (void);
16110 void __builtin_mtfsb0 (const int);
16111 void __builtin_mtfsb1 (const int);
16112 void __builtin_set_fpscr_rn (int);
16113 @end smallexample
16115 The @code{__builtin_ppc_get_timebase} and @code{__builtin_ppc_mftb}
16116 functions generate instructions to read the Time Base Register.  The
16117 @code{__builtin_ppc_get_timebase} function may generate multiple
16118 instructions and always returns the 64 bits of the Time Base Register.
16119 The @code{__builtin_ppc_mftb} function always generates one instruction and
16120 returns the Time Base Register value as an unsigned long, throwing away
16121 the most significant word on 32-bit environments.  The @code{__builtin_mffs}
16122 return the value of the FPSCR register.  Note, ISA 3.0 supports the
16123 @code{__builtin_mffsl()} which permits software to read the control and
16124 non-sticky status bits in the FSPCR without the higher latency associated with
16125 accessing the sticky status bits.  The
16126 @code{__builtin_mtfsb0} and @code{__builtin_mtfsb1} take the bit to change
16127 as an argument.  The valid bit range is between 0 and 31.  The builtins map to
16128 the @code{mtfsb0} and @code{mtfsb1} instructions which take the argument and
16129 add 32.  Hence these instructions only modify the FPSCR[32:63] bits by
16130 changing the specified bit to a zero or one respectively.  The
16131 @code{__builtin_set_fpscr_rn} builtin allows changing both of the floating
16132 point rounding mode bits.  The argument is a 2-bit value.  The argument can
16133 either be a @code{const int} or stored in a variable. The builtin uses
16134 the ISA 3.0
16135 instruction @code{mffscrn} if available, otherwise it reads the FPSCR, masks
16136 the current rounding mode bits out and OR's in the new value.
16138 @node Basic PowerPC Built-in Functions Available on ISA 2.05
16139 @subsubsection Basic PowerPC Built-in Functions Available on ISA 2.05
16141 The basic built-in functions described in this section are
16142 available on the PowerPC family of processors starting with ISA 2.05
16143 or later.  Unless specific options are explicitly disabled on the
16144 command line, specifying option @option{-mcpu=power6} has the effect of
16145 enabling the @option{-mpowerpc64}, @option{-mpowerpc-gpopt},
16146 @option{-mpowerpc-gfxopt}, @option{-mmfcrf}, @option{-mpopcntb},
16147 @option{-mfprnd}, @option{-mcmpb}, @option{-mhard-dfp}, and
16148 @option{-mrecip-precision} options.  Specify the
16149 @option{-maltivec} and @option{-mfpgpr} options explicitly in
16150 combination with the above options if they are desired.
16152 The following functions require option @option{-mcmpb}.
16153 @smallexample
16154 unsigned long long __builtin_cmpb (unsigned long long int, unsigned long long int);
16155 unsigned int __builtin_cmpb (unsigned int, unsigned int);
16156 @end smallexample
16158 The @code{__builtin_cmpb} function
16159 performs a byte-wise compare on the contents of its two arguments,
16160 returning the result of the byte-wise comparison as the returned
16161 value.  For each byte comparison, the corresponding byte of the return
16162 value holds 0xff if the input bytes are equal and 0 if the input bytes
16163 are not equal.  If either of the arguments to this built-in function
16164 is wider than 32 bits, the function call expands into the form that
16165 expects @code{unsigned long long int} arguments
16166 which is only available on 64-bit targets.
16168 The following built-in functions are available
16169 when hardware decimal floating point
16170 (@option{-mhard-dfp}) is available:
16171 @smallexample
16172 void __builtin_set_fpscr_drn(int);
16173 _Decimal64 __builtin_ddedpd (int, _Decimal64);
16174 _Decimal128 __builtin_ddedpdq (int, _Decimal128);
16175 _Decimal64 __builtin_denbcd (int, _Decimal64);
16176 _Decimal128 __builtin_denbcdq (int, _Decimal128);
16177 _Decimal64 __builtin_diex (long long, _Decimal64);
16178 _Decimal128 _builtin_diexq (long long, _Decimal128);
16179 _Decimal64 __builtin_dscli (_Decimal64, int);
16180 _Decimal128 __builtin_dscliq (_Decimal128, int);
16181 _Decimal64 __builtin_dscri (_Decimal64, int);
16182 _Decimal128 __builtin_dscriq (_Decimal128, int);
16183 long long __builtin_dxex (_Decimal64);
16184 long long __builtin_dxexq (_Decimal128);
16185 _Decimal128 __builtin_pack_dec128 (unsigned long long, unsigned long long);
16186 unsigned long long __builtin_unpack_dec128 (_Decimal128, int);
16188 The @code{__builtin_set_fpscr_drn} builtin allows changing the three decimal
16189 floating point rounding mode bits.  The argument is a 3-bit value.  The
16190 argument can either be a @code{const int} or the value can be stored in
16191 a variable.
16192 The builtin uses the ISA 3.0 instruction @code{mffscdrn} if available.
16193 Otherwise the builtin reads the FPSCR, masks the current decimal rounding
16194 mode bits out and OR's in the new value.
16196 @end smallexample
16198 The following functions require @option{-mhard-float},
16199 @option{-mpowerpc-gfxopt}, and @option{-mpopcntb} options.
16201 @smallexample
16202 double __builtin_recipdiv (double, double);
16203 float __builtin_recipdivf (float, float);
16204 double __builtin_rsqrt (double);
16205 float __builtin_rsqrtf (float);
16206 @end smallexample
16208 The @code{vec_rsqrt}, @code{__builtin_rsqrt}, and
16209 @code{__builtin_rsqrtf} functions generate multiple instructions to
16210 implement the reciprocal sqrt functionality using reciprocal sqrt
16211 estimate instructions.
16213 The @code{__builtin_recipdiv}, and @code{__builtin_recipdivf}
16214 functions generate multiple instructions to implement division using
16215 the reciprocal estimate instructions.
16217 The following functions require @option{-mhard-float} and
16218 @option{-mmultiple} options.
16220 The @code{__builtin_unpack_longdouble} function takes a
16221 @code{long double} argument and a compile time constant of 0 or 1.  If
16222 the constant is 0, the first @code{double} within the
16223 @code{long double} is returned, otherwise the second @code{double}
16224 is returned.  The @code{__builtin_unpack_longdouble} function is only
16225 available if @code{long double} uses the IBM extended double
16226 representation.
16228 The @code{__builtin_pack_longdouble} function takes two @code{double}
16229 arguments and returns a @code{long double} value that combines the two
16230 arguments.  The @code{__builtin_pack_longdouble} function is only
16231 available if @code{long double} uses the IBM extended double
16232 representation.
16234 The @code{__builtin_unpack_ibm128} function takes a @code{__ibm128}
16235 argument and a compile time constant of 0 or 1.  If the constant is 0,
16236 the first @code{double} within the @code{__ibm128} is returned,
16237 otherwise the second @code{double} is returned.
16239 The @code{__builtin_pack_ibm128} function takes two @code{double}
16240 arguments and returns a @code{__ibm128} value that combines the two
16241 arguments.
16243 Additional built-in functions are available for the 64-bit PowerPC
16244 family of processors, for efficient use of 128-bit floating point
16245 (@code{__float128}) values.
16247 @node Basic PowerPC Built-in Functions Available on ISA 2.06
16248 @subsubsection Basic PowerPC Built-in Functions Available on ISA 2.06
16250 The basic built-in functions described in this section are
16251 available on the PowerPC family of processors starting with ISA 2.05
16252 or later.  Unless specific options are explicitly disabled on the
16253 command line, specifying option @option{-mcpu=power7} has the effect of
16254 enabling all the same options as for @option{-mcpu=power6} in
16255 addition to the @option{-maltivec}, @option{-mpopcntd}, and
16256 @option{-mvsx} options.
16258 The following basic built-in functions require @option{-mpopcntd}:
16259 @smallexample
16260 unsigned int __builtin_addg6s (unsigned int, unsigned int);
16261 long long __builtin_bpermd (long long, long long);
16262 unsigned int __builtin_cbcdtd (unsigned int);
16263 unsigned int __builtin_cdtbcd (unsigned int);
16264 long long __builtin_divde (long long, long long);
16265 unsigned long long __builtin_divdeu (unsigned long long, unsigned long long);
16266 int __builtin_divwe (int, int);
16267 unsigned int __builtin_divweu (unsigned int, unsigned int);
16268 vector __int128 __builtin_pack_vector_int128 (long long, long long);
16269 void __builtin_rs6000_speculation_barrier (void);
16270 long long __builtin_unpack_vector_int128 (vector __int128, signed char);
16271 @end smallexample
16273 Of these, the @code{__builtin_divde} and @code{__builtin_divdeu} functions
16274 require a 64-bit environment.
16276 The following basic built-in functions, which are also supported on
16277 x86 targets, require @option{-mfloat128}.
16278 @smallexample
16279 __float128 __builtin_fabsq (__float128);
16280 __float128 __builtin_copysignq (__float128, __float128);
16281 __float128 __builtin_infq (void);
16282 __float128 __builtin_huge_valq (void);
16283 __float128 __builtin_nanq (void);
16284 __float128 __builtin_nansq (void);
16286 __float128 __builtin_sqrtf128 (__float128);
16287 __float128 __builtin_fmaf128 (__float128, __float128, __float128);
16288 @end smallexample
16290 @node Basic PowerPC Built-in Functions Available on ISA 2.07
16291 @subsubsection Basic PowerPC Built-in Functions Available on ISA 2.07
16293 The basic built-in functions described in this section are
16294 available on the PowerPC family of processors starting with ISA 2.07
16295 or later.  Unless specific options are explicitly disabled on the
16296 command line, specifying option @option{-mcpu=power8} has the effect of
16297 enabling all the same options as for @option{-mcpu=power7} in
16298 addition to the @option{-mpower8-fusion}, @option{-mpower8-vector},
16299 @option{-mcrypto}, @option{-mhtm}, @option{-mquad-memory}, and
16300 @option{-mquad-memory-atomic} options.
16302 This section intentionally empty.
16304 @node Basic PowerPC Built-in Functions Available on ISA 3.0
16305 @subsubsection Basic PowerPC Built-in Functions Available on ISA 3.0
16307 The basic built-in functions described in this section are
16308 available on the PowerPC family of processors starting with ISA 3.0
16309 or later.  Unless specific options are explicitly disabled on the
16310 command line, specifying option @option{-mcpu=power9} has the effect of
16311 enabling all the same options as for @option{-mcpu=power8} in
16312 addition to the @option{-misel} option.
16314 The following built-in functions are available on Linux 64-bit systems
16315 that use the ISA 3.0 instruction set (@option{-mcpu=power9}):
16317 @table @code
16318 @item __float128 __builtin_addf128_round_to_odd (__float128, __float128)
16319 Perform a 128-bit IEEE floating point add using round to odd as the
16320 rounding mode.
16321 @findex __builtin_addf128_round_to_odd
16323 @item __float128 __builtin_subf128_round_to_odd (__float128, __float128)
16324 Perform a 128-bit IEEE floating point subtract using round to odd as
16325 the rounding mode.
16326 @findex __builtin_subf128_round_to_odd
16328 @item __float128 __builtin_mulf128_round_to_odd (__float128, __float128)
16329 Perform a 128-bit IEEE floating point multiply using round to odd as
16330 the rounding mode.
16331 @findex __builtin_mulf128_round_to_odd
16333 @item __float128 __builtin_divf128_round_to_odd (__float128, __float128)
16334 Perform a 128-bit IEEE floating point divide using round to odd as
16335 the rounding mode.
16336 @findex __builtin_divf128_round_to_odd
16338 @item __float128 __builtin_sqrtf128_round_to_odd (__float128)
16339 Perform a 128-bit IEEE floating point square root using round to odd
16340 as the rounding mode.
16341 @findex __builtin_sqrtf128_round_to_odd
16343 @item __float128 __builtin_fmaf128_round_to_odd (__float128, __float128, __float128)
16344 Perform a 128-bit IEEE floating point fused multiply and add operation
16345 using round to odd as the rounding mode.
16346 @findex __builtin_fmaf128_round_to_odd
16348 @item double __builtin_truncf128_round_to_odd (__float128)
16349 Convert a 128-bit IEEE floating point value to @code{double} using
16350 round to odd as the rounding mode.
16351 @findex __builtin_truncf128_round_to_odd
16352 @end table
16354 The following additional built-in functions are also available for the
16355 PowerPC family of processors, starting with ISA 3.0 or later:
16356 @smallexample
16357 long long __builtin_darn (void);
16358 long long __builtin_darn_raw (void);
16359 int __builtin_darn_32 (void);
16360 @end smallexample
16362 The @code{__builtin_darn} and @code{__builtin_darn_raw}
16363 functions require a
16364 64-bit environment supporting ISA 3.0 or later.
16365 The @code{__builtin_darn} function provides a 64-bit conditioned
16366 random number.  The @code{__builtin_darn_raw} function provides a
16367 64-bit raw random number.  The @code{__builtin_darn_32} function
16368 provides a 32-bit conditioned random number.
16370 The following additional built-in functions are also available for the
16371 PowerPC family of processors, starting with ISA 3.0 or later:
16373 @smallexample
16374 int __builtin_byte_in_set (unsigned char u, unsigned long long set);
16375 int __builtin_byte_in_range (unsigned char u, unsigned int range);
16376 int __builtin_byte_in_either_range (unsigned char u, unsigned int ranges);
16378 int __builtin_dfp_dtstsfi_lt (unsigned int comparison, _Decimal64 value);
16379 int __builtin_dfp_dtstsfi_lt (unsigned int comparison, _Decimal128 value);
16380 int __builtin_dfp_dtstsfi_lt_dd (unsigned int comparison, _Decimal64 value);
16381 int __builtin_dfp_dtstsfi_lt_td (unsigned int comparison, _Decimal128 value);
16383 int __builtin_dfp_dtstsfi_gt (unsigned int comparison, _Decimal64 value);
16384 int __builtin_dfp_dtstsfi_gt (unsigned int comparison, _Decimal128 value);
16385 int __builtin_dfp_dtstsfi_gt_dd (unsigned int comparison, _Decimal64 value);
16386 int __builtin_dfp_dtstsfi_gt_td (unsigned int comparison, _Decimal128 value);
16388 int __builtin_dfp_dtstsfi_eq (unsigned int comparison, _Decimal64 value);
16389 int __builtin_dfp_dtstsfi_eq (unsigned int comparison, _Decimal128 value);
16390 int __builtin_dfp_dtstsfi_eq_dd (unsigned int comparison, _Decimal64 value);
16391 int __builtin_dfp_dtstsfi_eq_td (unsigned int comparison, _Decimal128 value);
16393 int __builtin_dfp_dtstsfi_ov (unsigned int comparison, _Decimal64 value);
16394 int __builtin_dfp_dtstsfi_ov (unsigned int comparison, _Decimal128 value);
16395 int __builtin_dfp_dtstsfi_ov_dd (unsigned int comparison, _Decimal64 value);
16396 int __builtin_dfp_dtstsfi_ov_td (unsigned int comparison, _Decimal128 value);
16398 double __builtin_mffsl(void);
16400 @end smallexample
16401 The @code{__builtin_byte_in_set} function requires a
16402 64-bit environment supporting ISA 3.0 or later.  This function returns
16403 a non-zero value if and only if its @code{u} argument exactly equals one of
16404 the eight bytes contained within its 64-bit @code{set} argument.
16406 The @code{__builtin_byte_in_range} and
16407 @code{__builtin_byte_in_either_range} require an environment
16408 supporting ISA 3.0 or later.  For these two functions, the
16409 @code{range} argument is encoded as 4 bytes, organized as
16410 @code{hi_1:lo_1:hi_2:lo_2}.
16411 The @code{__builtin_byte_in_range} function returns a
16412 non-zero value if and only if its @code{u} argument is within the
16413 range bounded between @code{lo_2} and @code{hi_2} inclusive.
16414 The @code{__builtin_byte_in_either_range} function returns non-zero if
16415 and only if its @code{u} argument is within either the range bounded
16416 between @code{lo_1} and @code{hi_1} inclusive or the range bounded
16417 between @code{lo_2} and @code{hi_2} inclusive.
16419 The @code{__builtin_dfp_dtstsfi_lt} function returns a non-zero value
16420 if and only if the number of signficant digits of its @code{value} argument
16421 is less than its @code{comparison} argument.  The
16422 @code{__builtin_dfp_dtstsfi_lt_dd} and
16423 @code{__builtin_dfp_dtstsfi_lt_td} functions behave similarly, but
16424 require that the type of the @code{value} argument be
16425 @code{__Decimal64} and @code{__Decimal128} respectively.
16427 The @code{__builtin_dfp_dtstsfi_gt} function returns a non-zero value
16428 if and only if the number of signficant digits of its @code{value} argument
16429 is greater than its @code{comparison} argument.  The
16430 @code{__builtin_dfp_dtstsfi_gt_dd} and
16431 @code{__builtin_dfp_dtstsfi_gt_td} functions behave similarly, but
16432 require that the type of the @code{value} argument be
16433 @code{__Decimal64} and @code{__Decimal128} respectively.
16435 The @code{__builtin_dfp_dtstsfi_eq} function returns a non-zero value
16436 if and only if the number of signficant digits of its @code{value} argument
16437 equals its @code{comparison} argument.  The
16438 @code{__builtin_dfp_dtstsfi_eq_dd} and
16439 @code{__builtin_dfp_dtstsfi_eq_td} functions behave similarly, but
16440 require that the type of the @code{value} argument be
16441 @code{__Decimal64} and @code{__Decimal128} respectively.
16443 The @code{__builtin_dfp_dtstsfi_ov} function returns a non-zero value
16444 if and only if its @code{value} argument has an undefined number of
16445 significant digits, such as when @code{value} is an encoding of @code{NaN}.
16446 The @code{__builtin_dfp_dtstsfi_ov_dd} and
16447 @code{__builtin_dfp_dtstsfi_ov_td} functions behave similarly, but
16448 require that the type of the @code{value} argument be
16449 @code{__Decimal64} and @code{__Decimal128} respectively.
16451 The @code{__builtin_mffsl} uses the ISA 3.0 @code{mffsl} instruction to read
16452 the FPSCR.  The instruction is a lower latency version of the @code{mffs}
16453 instruction.  If the @code{mffsl} instruction is not available, then the
16454 builtin uses the older @code{mffs} instruction to read the FPSCR.
16457 @node PowerPC AltiVec/VSX Built-in Functions
16458 @subsection PowerPC AltiVec/VSX Built-in Functions
16460 GCC provides an interface for the PowerPC family of processors to access
16461 the AltiVec operations described in Motorola's AltiVec Programming
16462 Interface Manual.  The interface is made available by including
16463 @code{<altivec.h>} and using @option{-maltivec} and
16464 @option{-mabi=altivec}.  The interface supports the following vector
16465 types.
16467 @smallexample
16468 vector unsigned char
16469 vector signed char
16470 vector bool char
16472 vector unsigned short
16473 vector signed short
16474 vector bool short
16475 vector pixel
16477 vector unsigned int
16478 vector signed int
16479 vector bool int
16480 vector float
16481 @end smallexample
16483 GCC's implementation of the high-level language interface available from
16484 C and C++ code differs from Motorola's documentation in several ways.
16486 @itemize @bullet
16488 @item
16489 A vector constant is a list of constant expressions within curly braces.
16491 @item
16492 A vector initializer requires no cast if the vector constant is of the
16493 same type as the variable it is initializing.
16495 @item
16496 If @code{signed} or @code{unsigned} is omitted, the signedness of the
16497 vector type is the default signedness of the base type.  The default
16498 varies depending on the operating system, so a portable program should
16499 always specify the signedness.
16501 @item
16502 Compiling with @option{-maltivec} adds keywords @code{__vector},
16503 @code{vector}, @code{__pixel}, @code{pixel}, @code{__bool} and
16504 @code{bool}.  When compiling ISO C, the context-sensitive substitution
16505 of the keywords @code{vector}, @code{pixel} and @code{bool} is
16506 disabled.  To use them, you must include @code{<altivec.h>} instead.
16508 @item
16509 GCC allows using a @code{typedef} name as the type specifier for a
16510 vector type.
16512 @item
16513 For C, overloaded functions are implemented with macros so the following
16514 does not work:
16516 @smallexample
16517   vec_add ((vector signed int)@{1, 2, 3, 4@}, foo);
16518 @end smallexample
16520 @noindent
16521 Since @code{vec_add} is a macro, the vector constant in the example
16522 is treated as four separate arguments.  Wrap the entire argument in
16523 parentheses for this to work.
16524 @end itemize
16526 @emph{Note:} Only the @code{<altivec.h>} interface is supported.
16527 Internally, GCC uses built-in functions to achieve the functionality in
16528 the aforementioned header file, but they are not supported and are
16529 subject to change without notice.
16531 GCC complies with the OpenPOWER 64-Bit ELF V2 ABI Specification,
16532 which may be found at
16533 @uref{http://openpowerfoundation.org/wp-content/uploads/resources/leabi-prd/content/index.html}.
16534 Appendix A of this document lists the vector API interfaces that must be
16535 provided by compliant compilers.  Programmers should preferentially use
16536 the interfaces described therein.  However, historically GCC has provided
16537 additional interfaces for access to vector instructions.  These are
16538 briefly described below.
16540 @menu
16541 * PowerPC AltiVec Built-in Functions on ISA 2.05::
16542 * PowerPC AltiVec Built-in Functions Available on ISA 2.06::
16543 * PowerPC AltiVec Built-in Functions Available on ISA 2.07::
16544 * PowerPC AltiVec Built-in Functions Available on ISA 3.0::
16545 @end menu
16547 @node PowerPC AltiVec Built-in Functions on ISA 2.05
16548 @subsubsection PowerPC AltiVec Built-in Functions on ISA 2.05
16550 The following interfaces are supported for the generic and specific
16551 AltiVec operations and the AltiVec predicates.  In cases where there
16552 is a direct mapping between generic and specific operations, only the
16553 generic names are shown here, although the specific operations can also
16554 be used.
16556 Arguments that are documented as @code{const int} require literal
16557 integral values within the range required for that operation.
16559 @smallexample
16560 vector signed char vec_abs (vector signed char);
16561 vector signed short vec_abs (vector signed short);
16562 vector signed int vec_abs (vector signed int);
16563 vector float vec_abs (vector float);
16565 vector signed char vec_abss (vector signed char);
16566 vector signed short vec_abss (vector signed short);
16567 vector signed int vec_abss (vector signed int);
16569 vector signed char vec_add (vector bool char, vector signed char);
16570 vector signed char vec_add (vector signed char, vector bool char);
16571 vector signed char vec_add (vector signed char, vector signed char);
16572 vector unsigned char vec_add (vector bool char, vector unsigned char);
16573 vector unsigned char vec_add (vector unsigned char, vector bool char);
16574 vector unsigned char vec_add (vector unsigned char, vector unsigned char);
16575 vector signed short vec_add (vector bool short, vector signed short);
16576 vector signed short vec_add (vector signed short, vector bool short);
16577 vector signed short vec_add (vector signed short, vector signed short);
16578 vector unsigned short vec_add (vector bool short, vector unsigned short);
16579 vector unsigned short vec_add (vector unsigned short, vector bool short);
16580 vector unsigned short vec_add (vector unsigned short, vector unsigned short);
16581 vector signed int vec_add (vector bool int, vector signed int);
16582 vector signed int vec_add (vector signed int, vector bool int);
16583 vector signed int vec_add (vector signed int, vector signed int);
16584 vector unsigned int vec_add (vector bool int, vector unsigned int);
16585 vector unsigned int vec_add (vector unsigned int, vector bool int);
16586 vector unsigned int vec_add (vector unsigned int, vector unsigned int);
16587 vector float vec_add (vector float, vector float);
16589 vector unsigned int vec_addc (vector unsigned int, vector unsigned int);
16591 vector unsigned char vec_adds (vector bool char, vector unsigned char);
16592 vector unsigned char vec_adds (vector unsigned char, vector bool char);
16593 vector unsigned char vec_adds (vector unsigned char, vector unsigned char);
16594 vector signed char vec_adds (vector bool char, vector signed char);
16595 vector signed char vec_adds (vector signed char, vector bool char);
16596 vector signed char vec_adds (vector signed char, vector signed char);
16597 vector unsigned short vec_adds (vector bool short, vector unsigned short);
16598 vector unsigned short vec_adds (vector unsigned short, vector bool short);
16599 vector unsigned short vec_adds (vector unsigned short, vector unsigned short);
16600 vector signed short vec_adds (vector bool short, vector signed short);
16601 vector signed short vec_adds (vector signed short, vector bool short);
16602 vector signed short vec_adds (vector signed short, vector signed short);
16603 vector unsigned int vec_adds (vector bool int, vector unsigned int);
16604 vector unsigned int vec_adds (vector unsigned int, vector bool int);
16605 vector unsigned int vec_adds (vector unsigned int, vector unsigned int);
16606 vector signed int vec_adds (vector bool int, vector signed int);
16607 vector signed int vec_adds (vector signed int, vector bool int);
16608 vector signed int vec_adds (vector signed int, vector signed int);
16610 int vec_all_eq (vector signed char, vector bool char);
16611 int vec_all_eq (vector signed char, vector signed char);
16612 int vec_all_eq (vector unsigned char, vector bool char);
16613 int vec_all_eq (vector unsigned char, vector unsigned char);
16614 int vec_all_eq (vector bool char, vector bool char);
16615 int vec_all_eq (vector bool char, vector unsigned char);
16616 int vec_all_eq (vector bool char, vector signed char);
16617 int vec_all_eq (vector signed short, vector bool short);
16618 int vec_all_eq (vector signed short, vector signed short);
16619 int vec_all_eq (vector unsigned short, vector bool short);
16620 int vec_all_eq (vector unsigned short, vector unsigned short);
16621 int vec_all_eq (vector bool short, vector bool short);
16622 int vec_all_eq (vector bool short, vector unsigned short);
16623 int vec_all_eq (vector bool short, vector signed short);
16624 int vec_all_eq (vector pixel, vector pixel);
16625 int vec_all_eq (vector signed int, vector bool int);
16626 int vec_all_eq (vector signed int, vector signed int);
16627 int vec_all_eq (vector unsigned int, vector bool int);
16628 int vec_all_eq (vector unsigned int, vector unsigned int);
16629 int vec_all_eq (vector bool int, vector bool int);
16630 int vec_all_eq (vector bool int, vector unsigned int);
16631 int vec_all_eq (vector bool int, vector signed int);
16632 int vec_all_eq (vector float, vector float);
16634 int vec_all_ge (vector bool char, vector unsigned char);
16635 int vec_all_ge (vector unsigned char, vector bool char);
16636 int vec_all_ge (vector unsigned char, vector unsigned char);
16637 int vec_all_ge (vector bool char, vector signed char);
16638 int vec_all_ge (vector signed char, vector bool char);
16639 int vec_all_ge (vector signed char, vector signed char);
16640 int vec_all_ge (vector bool short, vector unsigned short);
16641 int vec_all_ge (vector unsigned short, vector bool short);
16642 int vec_all_ge (vector unsigned short, vector unsigned short);
16643 int vec_all_ge (vector signed short, vector signed short);
16644 int vec_all_ge (vector bool short, vector signed short);
16645 int vec_all_ge (vector signed short, vector bool short);
16646 int vec_all_ge (vector bool int, vector unsigned int);
16647 int vec_all_ge (vector unsigned int, vector bool int);
16648 int vec_all_ge (vector unsigned int, vector unsigned int);
16649 int vec_all_ge (vector bool int, vector signed int);
16650 int vec_all_ge (vector signed int, vector bool int);
16651 int vec_all_ge (vector signed int, vector signed int);
16652 int vec_all_ge (vector float, vector float);
16654 int vec_all_gt (vector bool char, vector unsigned char);
16655 int vec_all_gt (vector unsigned char, vector bool char);
16656 int vec_all_gt (vector unsigned char, vector unsigned char);
16657 int vec_all_gt (vector bool char, vector signed char);
16658 int vec_all_gt (vector signed char, vector bool char);
16659 int vec_all_gt (vector signed char, vector signed char);
16660 int vec_all_gt (vector bool short, vector unsigned short);
16661 int vec_all_gt (vector unsigned short, vector bool short);
16662 int vec_all_gt (vector unsigned short, vector unsigned short);
16663 int vec_all_gt (vector bool short, vector signed short);
16664 int vec_all_gt (vector signed short, vector bool short);
16665 int vec_all_gt (vector signed short, vector signed short);
16666 int vec_all_gt (vector bool int, vector unsigned int);
16667 int vec_all_gt (vector unsigned int, vector bool int);
16668 int vec_all_gt (vector unsigned int, vector unsigned int);
16669 int vec_all_gt (vector bool int, vector signed int);
16670 int vec_all_gt (vector signed int, vector bool int);
16671 int vec_all_gt (vector signed int, vector signed int);
16672 int vec_all_gt (vector float, vector float);
16674 int vec_all_in (vector float, vector float);
16676 int vec_all_le (vector bool char, vector unsigned char);
16677 int vec_all_le (vector unsigned char, vector bool char);
16678 int vec_all_le (vector unsigned char, vector unsigned char);
16679 int vec_all_le (vector bool char, vector signed char);
16680 int vec_all_le (vector signed char, vector bool char);
16681 int vec_all_le (vector signed char, vector signed char);
16682 int vec_all_le (vector bool short, vector unsigned short);
16683 int vec_all_le (vector unsigned short, vector bool short);
16684 int vec_all_le (vector unsigned short, vector unsigned short);
16685 int vec_all_le (vector bool short, vector signed short);
16686 int vec_all_le (vector signed short, vector bool short);
16687 int vec_all_le (vector signed short, vector signed short);
16688 int vec_all_le (vector bool int, vector unsigned int);
16689 int vec_all_le (vector unsigned int, vector bool int);
16690 int vec_all_le (vector unsigned int, vector unsigned int);
16691 int vec_all_le (vector bool int, vector signed int);
16692 int vec_all_le (vector signed int, vector bool int);
16693 int vec_all_le (vector signed int, vector signed int);
16694 int vec_all_le (vector float, vector float);
16696 int vec_all_lt (vector bool char, vector unsigned char);
16697 int vec_all_lt (vector unsigned char, vector bool char);
16698 int vec_all_lt (vector unsigned char, vector unsigned char);
16699 int vec_all_lt (vector bool char, vector signed char);
16700 int vec_all_lt (vector signed char, vector bool char);
16701 int vec_all_lt (vector signed char, vector signed char);
16702 int vec_all_lt (vector bool short, vector unsigned short);
16703 int vec_all_lt (vector unsigned short, vector bool short);
16704 int vec_all_lt (vector unsigned short, vector unsigned short);
16705 int vec_all_lt (vector bool short, vector signed short);
16706 int vec_all_lt (vector signed short, vector bool short);
16707 int vec_all_lt (vector signed short, vector signed short);
16708 int vec_all_lt (vector bool int, vector unsigned int);
16709 int vec_all_lt (vector unsigned int, vector bool int);
16710 int vec_all_lt (vector unsigned int, vector unsigned int);
16711 int vec_all_lt (vector bool int, vector signed int);
16712 int vec_all_lt (vector signed int, vector bool int);
16713 int vec_all_lt (vector signed int, vector signed int);
16714 int vec_all_lt (vector float, vector float);
16716 int vec_all_nan (vector float);
16718 int vec_all_ne (vector signed char, vector bool char);
16719 int vec_all_ne (vector signed char, vector signed char);
16720 int vec_all_ne (vector unsigned char, vector bool char);
16721 int vec_all_ne (vector unsigned char, vector unsigned char);
16722 int vec_all_ne (vector bool char, vector bool char);
16723 int vec_all_ne (vector bool char, vector unsigned char);
16724 int vec_all_ne (vector bool char, vector signed char);
16725 int vec_all_ne (vector signed short, vector bool short);
16726 int vec_all_ne (vector signed short, vector signed short);
16727 int vec_all_ne (vector unsigned short, vector bool short);
16728 int vec_all_ne (vector unsigned short, vector unsigned short);
16729 int vec_all_ne (vector bool short, vector bool short);
16730 int vec_all_ne (vector bool short, vector unsigned short);
16731 int vec_all_ne (vector bool short, vector signed short);
16732 int vec_all_ne (vector pixel, vector pixel);
16733 int vec_all_ne (vector signed int, vector bool int);
16734 int vec_all_ne (vector signed int, vector signed int);
16735 int vec_all_ne (vector unsigned int, vector bool int);
16736 int vec_all_ne (vector unsigned int, vector unsigned int);
16737 int vec_all_ne (vector bool int, vector bool int);
16738 int vec_all_ne (vector bool int, vector unsigned int);
16739 int vec_all_ne (vector bool int, vector signed int);
16740 int vec_all_ne (vector float, vector float);
16742 int vec_all_nge (vector float, vector float);
16744 int vec_all_ngt (vector float, vector float);
16746 int vec_all_nle (vector float, vector float);
16748 int vec_all_nlt (vector float, vector float);
16750 int vec_all_numeric (vector float);
16752 vector float vec_and (vector float, vector float);
16753 vector float vec_and (vector float, vector bool int);
16754 vector float vec_and (vector bool int, vector float);
16755 vector bool int vec_and (vector bool int, vector bool int);
16756 vector signed int vec_and (vector bool int, vector signed int);
16757 vector signed int vec_and (vector signed int, vector bool int);
16758 vector signed int vec_and (vector signed int, vector signed int);
16759 vector unsigned int vec_and (vector bool int, vector unsigned int);
16760 vector unsigned int vec_and (vector unsigned int, vector bool int);
16761 vector unsigned int vec_and (vector unsigned int, vector unsigned int);
16762 vector bool short vec_and (vector bool short, vector bool short);
16763 vector signed short vec_and (vector bool short, vector signed short);
16764 vector signed short vec_and (vector signed short, vector bool short);
16765 vector signed short vec_and (vector signed short, vector signed short);
16766 vector unsigned short vec_and (vector bool short, vector unsigned short);
16767 vector unsigned short vec_and (vector unsigned short, vector bool short);
16768 vector unsigned short vec_and (vector unsigned short, vector unsigned short);
16769 vector signed char vec_and (vector bool char, vector signed char);
16770 vector bool char vec_and (vector bool char, vector bool char);
16771 vector signed char vec_and (vector signed char, vector bool char);
16772 vector signed char vec_and (vector signed char, vector signed char);
16773 vector unsigned char vec_and (vector bool char, vector unsigned char);
16774 vector unsigned char vec_and (vector unsigned char, vector bool char);
16775 vector unsigned char vec_and (vector unsigned char, vector unsigned char);
16777 vector float vec_andc (vector float, vector float);
16778 vector float vec_andc (vector float, vector bool int);
16779 vector float vec_andc (vector bool int, vector float);
16780 vector bool int vec_andc (vector bool int, vector bool int);
16781 vector signed int vec_andc (vector bool int, vector signed int);
16782 vector signed int vec_andc (vector signed int, vector bool int);
16783 vector signed int vec_andc (vector signed int, vector signed int);
16784 vector unsigned int vec_andc (vector bool int, vector unsigned int);
16785 vector unsigned int vec_andc (vector unsigned int, vector bool int);
16786 vector unsigned int vec_andc (vector unsigned int, vector unsigned int);
16787 vector bool short vec_andc (vector bool short, vector bool short);
16788 vector signed short vec_andc (vector bool short, vector signed short);
16789 vector signed short vec_andc (vector signed short, vector bool short);
16790 vector signed short vec_andc (vector signed short, vector signed short);
16791 vector unsigned short vec_andc (vector bool short, vector unsigned short);
16792 vector unsigned short vec_andc (vector unsigned short, vector bool short);
16793 vector unsigned short vec_andc (vector unsigned short, vector unsigned short);
16794 vector signed char vec_andc (vector bool char, vector signed char);
16795 vector bool char vec_andc (vector bool char, vector bool char);
16796 vector signed char vec_andc (vector signed char, vector bool char);
16797 vector signed char vec_andc (vector signed char, vector signed char);
16798 vector unsigned char vec_andc (vector bool char, vector unsigned char);
16799 vector unsigned char vec_andc (vector unsigned char, vector bool char);
16800 vector unsigned char vec_andc (vector unsigned char, vector unsigned char);
16802 int vec_any_eq (vector signed char, vector bool char);
16803 int vec_any_eq (vector signed char, vector signed char);
16804 int vec_any_eq (vector unsigned char, vector bool char);
16805 int vec_any_eq (vector unsigned char, vector unsigned char);
16806 int vec_any_eq (vector bool char, vector bool char);
16807 int vec_any_eq (vector bool char, vector unsigned char);
16808 int vec_any_eq (vector bool char, vector signed char);
16809 int vec_any_eq (vector signed short, vector bool short);
16810 int vec_any_eq (vector signed short, vector signed short);
16811 int vec_any_eq (vector unsigned short, vector bool short);
16812 int vec_any_eq (vector unsigned short, vector unsigned short);
16813 int vec_any_eq (vector bool short, vector bool short);
16814 int vec_any_eq (vector bool short, vector unsigned short);
16815 int vec_any_eq (vector bool short, vector signed short);
16816 int vec_any_eq (vector pixel, vector pixel);
16817 int vec_any_eq (vector signed int, vector bool int);
16818 int vec_any_eq (vector signed int, vector signed int);
16819 int vec_any_eq (vector unsigned int, vector bool int);
16820 int vec_any_eq (vector unsigned int, vector unsigned int);
16821 int vec_any_eq (vector bool int, vector bool int);
16822 int vec_any_eq (vector bool int, vector unsigned int);
16823 int vec_any_eq (vector bool int, vector signed int);
16824 int vec_any_eq (vector float, vector float);
16826 int vec_any_ge (vector signed char, vector bool char);
16827 int vec_any_ge (vector unsigned char, vector bool char);
16828 int vec_any_ge (vector unsigned char, vector unsigned char);
16829 int vec_any_ge (vector signed char, vector signed char);
16830 int vec_any_ge (vector bool char, vector unsigned char);
16831 int vec_any_ge (vector bool char, vector signed char);
16832 int vec_any_ge (vector unsigned short, vector bool short);
16833 int vec_any_ge (vector unsigned short, vector unsigned short);
16834 int vec_any_ge (vector signed short, vector signed short);
16835 int vec_any_ge (vector signed short, vector bool short);
16836 int vec_any_ge (vector bool short, vector unsigned short);
16837 int vec_any_ge (vector bool short, vector signed short);
16838 int vec_any_ge (vector signed int, vector bool int);
16839 int vec_any_ge (vector unsigned int, vector bool int);
16840 int vec_any_ge (vector unsigned int, vector unsigned int);
16841 int vec_any_ge (vector signed int, vector signed int);
16842 int vec_any_ge (vector bool int, vector unsigned int);
16843 int vec_any_ge (vector bool int, vector signed int);
16844 int vec_any_ge (vector float, vector float);
16846 int vec_any_gt (vector bool char, vector unsigned char);
16847 int vec_any_gt (vector unsigned char, vector bool char);
16848 int vec_any_gt (vector unsigned char, vector unsigned char);
16849 int vec_any_gt (vector bool char, vector signed char);
16850 int vec_any_gt (vector signed char, vector bool char);
16851 int vec_any_gt (vector signed char, vector signed char);
16852 int vec_any_gt (vector bool short, vector unsigned short);
16853 int vec_any_gt (vector unsigned short, vector bool short);
16854 int vec_any_gt (vector unsigned short, vector unsigned short);
16855 int vec_any_gt (vector bool short, vector signed short);
16856 int vec_any_gt (vector signed short, vector bool short);
16857 int vec_any_gt (vector signed short, vector signed short);
16858 int vec_any_gt (vector bool int, vector unsigned int);
16859 int vec_any_gt (vector unsigned int, vector bool int);
16860 int vec_any_gt (vector unsigned int, vector unsigned int);
16861 int vec_any_gt (vector bool int, vector signed int);
16862 int vec_any_gt (vector signed int, vector bool int);
16863 int vec_any_gt (vector signed int, vector signed int);
16864 int vec_any_gt (vector float, vector float);
16866 int vec_any_le (vector bool char, vector unsigned char);
16867 int vec_any_le (vector unsigned char, vector bool char);
16868 int vec_any_le (vector unsigned char, vector unsigned char);
16869 int vec_any_le (vector bool char, vector signed char);
16870 int vec_any_le (vector signed char, vector bool char);
16871 int vec_any_le (vector signed char, vector signed char);
16872 int vec_any_le (vector bool short, vector unsigned short);
16873 int vec_any_le (vector unsigned short, vector bool short);
16874 int vec_any_le (vector unsigned short, vector unsigned short);
16875 int vec_any_le (vector bool short, vector signed short);
16876 int vec_any_le (vector signed short, vector bool short);
16877 int vec_any_le (vector signed short, vector signed short);
16878 int vec_any_le (vector bool int, vector unsigned int);
16879 int vec_any_le (vector unsigned int, vector bool int);
16880 int vec_any_le (vector unsigned int, vector unsigned int);
16881 int vec_any_le (vector bool int, vector signed int);
16882 int vec_any_le (vector signed int, vector bool int);
16883 int vec_any_le (vector signed int, vector signed int);
16884 int vec_any_le (vector float, vector float);
16886 int vec_any_lt (vector bool char, vector unsigned char);
16887 int vec_any_lt (vector unsigned char, vector bool char);
16888 int vec_any_lt (vector unsigned char, vector unsigned char);
16889 int vec_any_lt (vector bool char, vector signed char);
16890 int vec_any_lt (vector signed char, vector bool char);
16891 int vec_any_lt (vector signed char, vector signed char);
16892 int vec_any_lt (vector bool short, vector unsigned short);
16893 int vec_any_lt (vector unsigned short, vector bool short);
16894 int vec_any_lt (vector unsigned short, vector unsigned short);
16895 int vec_any_lt (vector bool short, vector signed short);
16896 int vec_any_lt (vector signed short, vector bool short);
16897 int vec_any_lt (vector signed short, vector signed short);
16898 int vec_any_lt (vector bool int, vector unsigned int);
16899 int vec_any_lt (vector unsigned int, vector bool int);
16900 int vec_any_lt (vector unsigned int, vector unsigned int);
16901 int vec_any_lt (vector bool int, vector signed int);
16902 int vec_any_lt (vector signed int, vector bool int);
16903 int vec_any_lt (vector signed int, vector signed int);
16904 int vec_any_lt (vector float, vector float);
16906 int vec_any_nan (vector float);
16908 int vec_any_ne (vector signed char, vector bool char);
16909 int vec_any_ne (vector signed char, vector signed char);
16910 int vec_any_ne (vector unsigned char, vector bool char);
16911 int vec_any_ne (vector unsigned char, vector unsigned char);
16912 int vec_any_ne (vector bool char, vector bool char);
16913 int vec_any_ne (vector bool char, vector unsigned char);
16914 int vec_any_ne (vector bool char, vector signed char);
16915 int vec_any_ne (vector signed short, vector bool short);
16916 int vec_any_ne (vector signed short, vector signed short);
16917 int vec_any_ne (vector unsigned short, vector bool short);
16918 int vec_any_ne (vector unsigned short, vector unsigned short);
16919 int vec_any_ne (vector bool short, vector bool short);
16920 int vec_any_ne (vector bool short, vector unsigned short);
16921 int vec_any_ne (vector bool short, vector signed short);
16922 int vec_any_ne (vector pixel, vector pixel);
16923 int vec_any_ne (vector signed int, vector bool int);
16924 int vec_any_ne (vector signed int, vector signed int);
16925 int vec_any_ne (vector unsigned int, vector bool int);
16926 int vec_any_ne (vector unsigned int, vector unsigned int);
16927 int vec_any_ne (vector bool int, vector bool int);
16928 int vec_any_ne (vector bool int, vector unsigned int);
16929 int vec_any_ne (vector bool int, vector signed int);
16930 int vec_any_ne (vector float, vector float);
16932 int vec_any_nge (vector float, vector float);
16934 int vec_any_ngt (vector float, vector float);
16936 int vec_any_nle (vector float, vector float);
16938 int vec_any_nlt (vector float, vector float);
16940 int vec_any_numeric (vector float);
16942 int vec_any_out (vector float, vector float);
16944 vector unsigned char vec_avg (vector unsigned char, vector unsigned char);
16945 vector signed char vec_avg (vector signed char, vector signed char);
16946 vector unsigned short vec_avg (vector unsigned short, vector unsigned short);
16947 vector signed short vec_avg (vector signed short, vector signed short);
16948 vector unsigned int vec_avg (vector unsigned int, vector unsigned int);
16949 vector signed int vec_avg (vector signed int, vector signed int);
16951 vector float vec_ceil (vector float);
16953 vector signed int vec_cmpb (vector float, vector float);
16955 vector bool char vec_cmpeq (vector bool char, vector bool char);
16956 vector bool short vec_cmpeq (vector bool short, vector bool short);
16957 vector bool int vec_cmpeq (vector bool int, vector bool int);
16958 vector bool char vec_cmpeq (vector signed char, vector signed char);
16959 vector bool char vec_cmpeq (vector unsigned char, vector unsigned char);
16960 vector bool short vec_cmpeq (vector signed short, vector signed short);
16961 vector bool short vec_cmpeq (vector unsigned short, vector unsigned short);
16962 vector bool int vec_cmpeq (vector signed int, vector signed int);
16963 vector bool int vec_cmpeq (vector unsigned int, vector unsigned int);
16964 vector bool int vec_cmpeq (vector float, vector float);
16966 vector bool int vec_cmpge (vector float, vector float);
16968 vector bool char vec_cmpgt (vector unsigned char, vector unsigned char);
16969 vector bool char vec_cmpgt (vector signed char, vector signed char);
16970 vector bool short vec_cmpgt (vector unsigned short, vector unsigned short);
16971 vector bool short vec_cmpgt (vector signed short, vector signed short);
16972 vector bool int vec_cmpgt (vector unsigned int, vector unsigned int);
16973 vector bool int vec_cmpgt (vector signed int, vector signed int);
16974 vector bool int vec_cmpgt (vector float, vector float);
16976 vector bool int vec_cmple (vector float, vector float);
16978 vector bool char vec_cmplt (vector unsigned char, vector unsigned char);
16979 vector bool char vec_cmplt (vector signed char, vector signed char);
16980 vector bool short vec_cmplt (vector unsigned short, vector unsigned short);
16981 vector bool short vec_cmplt (vector signed short, vector signed short);
16982 vector bool int vec_cmplt (vector unsigned int, vector unsigned int);
16983 vector bool int vec_cmplt (vector signed int, vector signed int);
16984 vector bool int vec_cmplt (vector float, vector float);
16986 vector float vec_cpsgn (vector float, vector float);
16988 vector float vec_ctf (vector unsigned int, const int);
16989 vector float vec_ctf (vector signed int, const int);
16991 vector signed int vec_cts (vector float, const int);
16993 vector unsigned int vec_ctu (vector float, const int);
16995 void vec_dss (const int);
16997 void vec_dssall (void);
16999 void vec_dst (const vector unsigned char *, int, const int);
17000 void vec_dst (const vector signed char *, int, const int);
17001 void vec_dst (const vector bool char *, int, const int);
17002 void vec_dst (const vector unsigned short *, int, const int);
17003 void vec_dst (const vector signed short *, int, const int);
17004 void vec_dst (const vector bool short *, int, const int);
17005 void vec_dst (const vector pixel *, int, const int);
17006 void vec_dst (const vector unsigned int *, int, const int);
17007 void vec_dst (const vector signed int *, int, const int);
17008 void vec_dst (const vector bool int *, int, const int);
17009 void vec_dst (const vector float *, int, const int);
17010 void vec_dst (const unsigned char *, int, const int);
17011 void vec_dst (const signed char *, int, const int);
17012 void vec_dst (const unsigned short *, int, const int);
17013 void vec_dst (const short *, int, const int);
17014 void vec_dst (const unsigned int *, int, const int);
17015 void vec_dst (const int *, int, const int);
17016 void vec_dst (const float *, int, const int);
17018 void vec_dstst (const vector unsigned char *, int, const int);
17019 void vec_dstst (const vector signed char *, int, const int);
17020 void vec_dstst (const vector bool char *, int, const int);
17021 void vec_dstst (const vector unsigned short *, int, const int);
17022 void vec_dstst (const vector signed short *, int, const int);
17023 void vec_dstst (const vector bool short *, int, const int);
17024 void vec_dstst (const vector pixel *, int, const int);
17025 void vec_dstst (const vector unsigned int *, int, const int);
17026 void vec_dstst (const vector signed int *, int, const int);
17027 void vec_dstst (const vector bool int *, int, const int);
17028 void vec_dstst (const vector float *, int, const int);
17029 void vec_dstst (const unsigned char *, int, const int);
17030 void vec_dstst (const signed char *, int, const int);
17031 void vec_dstst (const unsigned short *, int, const int);
17032 void vec_dstst (const short *, int, const int);
17033 void vec_dstst (const unsigned int *, int, const int);
17034 void vec_dstst (const int *, int, const int);
17035 void vec_dstst (const unsigned long *, int, const int);
17036 void vec_dstst (const long *, int, const int);
17037 void vec_dstst (const float *, int, const int);
17039 void vec_dststt (const vector unsigned char *, int, const int);
17040 void vec_dststt (const vector signed char *, int, const int);
17041 void vec_dststt (const vector bool char *, int, const int);
17042 void vec_dststt (const vector unsigned short *, int, const int);
17043 void vec_dststt (const vector signed short *, int, const int);
17044 void vec_dststt (const vector bool short *, int, const int);
17045 void vec_dststt (const vector pixel *, int, const int);
17046 void vec_dststt (const vector unsigned int *, int, const int);
17047 void vec_dststt (const vector signed int *, int, const int);
17048 void vec_dststt (const vector bool int *, int, const int);
17049 void vec_dststt (const vector float *, int, const int);
17050 void vec_dststt (const unsigned char *, int, const int);
17051 void vec_dststt (const signed char *, int, const int);
17052 void vec_dststt (const unsigned short *, int, const int);
17053 void vec_dststt (const short *, int, const int);
17054 void vec_dststt (const unsigned int *, int, const int);
17055 void vec_dststt (const int *, int, const int);
17056 void vec_dststt (const float *, int, const int);
17058 void vec_dstt (const vector unsigned char *, int, const int);
17059 void vec_dstt (const vector signed char *, int, const int);
17060 void vec_dstt (const vector bool char *, int, const int);
17061 void vec_dstt (const vector unsigned short *, int, const int);
17062 void vec_dstt (const vector signed short *, int, const int);
17063 void vec_dstt (const vector bool short *, int, const int);
17064 void vec_dstt (const vector pixel *, int, const int);
17065 void vec_dstt (const vector unsigned int *, int, const int);
17066 void vec_dstt (const vector signed int *, int, const int);
17067 void vec_dstt (const vector bool int *, int, const int);
17068 void vec_dstt (const vector float *, int, const int);
17069 void vec_dstt (const unsigned char *, int, const int);
17070 void vec_dstt (const signed char *, int, const int);
17071 void vec_dstt (const unsigned short *, int, const int);
17072 void vec_dstt (const short *, int, const int);
17073 void vec_dstt (const unsigned int *, int, const int);
17074 void vec_dstt (const int *, int, const int);
17075 void vec_dstt (const float *, int, const int);
17077 vector float vec_expte (vector float);
17079 vector float vec_floor (vector float);
17081 vector float vec_ld (int, const vector float *);
17082 vector float vec_ld (int, const float *);
17083 vector bool int vec_ld (int, const vector bool int *);
17084 vector signed int vec_ld (int, const vector signed int *);
17085 vector signed int vec_ld (int, const int *);
17086 vector unsigned int vec_ld (int, const vector unsigned int *);
17087 vector unsigned int vec_ld (int, const unsigned int *);
17088 vector bool short vec_ld (int, const vector bool short *);
17089 vector pixel vec_ld (int, const vector pixel *);
17090 vector signed short vec_ld (int, const vector signed short *);
17091 vector signed short vec_ld (int, const short *);
17092 vector unsigned short vec_ld (int, const vector unsigned short *);
17093 vector unsigned short vec_ld (int, const unsigned short *);
17094 vector bool char vec_ld (int, const vector bool char *);
17095 vector signed char vec_ld (int, const vector signed char *);
17096 vector signed char vec_ld (int, const signed char *);
17097 vector unsigned char vec_ld (int, const vector unsigned char *);
17098 vector unsigned char vec_ld (int, const unsigned char *);
17100 vector signed char vec_lde (int, const signed char *);
17101 vector unsigned char vec_lde (int, const unsigned char *);
17102 vector signed short vec_lde (int, const short *);
17103 vector unsigned short vec_lde (int, const unsigned short *);
17104 vector float vec_lde (int, const float *);
17105 vector signed int vec_lde (int, const int *);
17106 vector unsigned int vec_lde (int, const unsigned int *);
17108 vector float vec_ldl (int, const vector float *);
17109 vector float vec_ldl (int, const float *);
17110 vector bool int vec_ldl (int, const vector bool int *);
17111 vector signed int vec_ldl (int, const vector signed int *);
17112 vector signed int vec_ldl (int, const int *);
17113 vector unsigned int vec_ldl (int, const vector unsigned int *);
17114 vector unsigned int vec_ldl (int, const unsigned int *);
17115 vector bool short vec_ldl (int, const vector bool short *);
17116 vector pixel vec_ldl (int, const vector pixel *);
17117 vector signed short vec_ldl (int, const vector signed short *);
17118 vector signed short vec_ldl (int, const short *);
17119 vector unsigned short vec_ldl (int, const vector unsigned short *);
17120 vector unsigned short vec_ldl (int, const unsigned short *);
17121 vector bool char vec_ldl (int, const vector bool char *);
17122 vector signed char vec_ldl (int, const vector signed char *);
17123 vector signed char vec_ldl (int, const signed char *);
17124 vector unsigned char vec_ldl (int, const vector unsigned char *);
17125 vector unsigned char vec_ldl (int, const unsigned char *);
17127 vector float vec_loge (vector float);
17129 vector signed char vec_lvebx (int, char *);
17130 vector unsigned char vec_lvebx (int, unsigned char *);
17132 vector signed short vec_lvehx (int, short *);
17133 vector unsigned short vec_lvehx (int, unsigned short *);
17135 vector float vec_lvewx (int, float *);
17136 vector signed int vec_lvewx (int, int *);
17137 vector unsigned int vec_lvewx (int, unsigned int *);
17139 vector unsigned char vec_lvsl (int, const unsigned char *);
17140 vector unsigned char vec_lvsl (int, const signed char *);
17141 vector unsigned char vec_lvsl (int, const unsigned short *);
17142 vector unsigned char vec_lvsl (int, const short *);
17143 vector unsigned char vec_lvsl (int, const unsigned int *);
17144 vector unsigned char vec_lvsl (int, const int *);
17145 vector unsigned char vec_lvsl (int, const float *);
17147 vector unsigned char vec_lvsr (int, const unsigned char *);
17148 vector unsigned char vec_lvsr (int, const signed char *);
17149 vector unsigned char vec_lvsr (int, const unsigned short *);
17150 vector unsigned char vec_lvsr (int, const short *);
17151 vector unsigned char vec_lvsr (int, const unsigned int *);
17152 vector unsigned char vec_lvsr (int, const int *);
17153 vector unsigned char vec_lvsr (int, const float *);
17155 vector float vec_madd (vector float, vector float, vector float);
17157 vector signed short vec_madds (vector signed short, vector signed short,
17158                                vector signed short);
17160 vector unsigned char vec_max (vector bool char, vector unsigned char);
17161 vector unsigned char vec_max (vector unsigned char, vector bool char);
17162 vector unsigned char vec_max (vector unsigned char, vector unsigned char);
17163 vector signed char vec_max (vector bool char, vector signed char);
17164 vector signed char vec_max (vector signed char, vector bool char);
17165 vector signed char vec_max (vector signed char, vector signed char);
17166 vector unsigned short vec_max (vector bool short, vector unsigned short);
17167 vector unsigned short vec_max (vector unsigned short, vector bool short);
17168 vector unsigned short vec_max (vector unsigned short, vector unsigned short);
17169 vector signed short vec_max (vector bool short, vector signed short);
17170 vector signed short vec_max (vector signed short, vector bool short);
17171 vector signed short vec_max (vector signed short, vector signed short);
17172 vector unsigned int vec_max (vector bool int, vector unsigned int);
17173 vector unsigned int vec_max (vector unsigned int, vector bool int);
17174 vector unsigned int vec_max (vector unsigned int, vector unsigned int);
17175 vector signed int vec_max (vector bool int, vector signed int);
17176 vector signed int vec_max (vector signed int, vector bool int);
17177 vector signed int vec_max (vector signed int, vector signed int);
17178 vector float vec_max (vector float, vector float);
17180 vector bool char vec_mergeh (vector bool char, vector bool char);
17181 vector signed char vec_mergeh (vector signed char, vector signed char);
17182 vector unsigned char vec_mergeh (vector unsigned char, vector unsigned char);
17183 vector bool short vec_mergeh (vector bool short, vector bool short);
17184 vector pixel vec_mergeh (vector pixel, vector pixel);
17185 vector signed short vec_mergeh (vector signed short, vector signed short);
17186 vector unsigned short vec_mergeh (vector unsigned short, vector unsigned short);
17187 vector float vec_mergeh (vector float, vector float);
17188 vector bool int vec_mergeh (vector bool int, vector bool int);
17189 vector signed int vec_mergeh (vector signed int, vector signed int);
17190 vector unsigned int vec_mergeh (vector unsigned int, vector unsigned int);
17192 vector bool char vec_mergel (vector bool char, vector bool char);
17193 vector signed char vec_mergel (vector signed char, vector signed char);
17194 vector unsigned char vec_mergel (vector unsigned char, vector unsigned char);
17195 vector bool short vec_mergel (vector bool short, vector bool short);
17196 vector pixel vec_mergel (vector pixel, vector pixel);
17197 vector signed short vec_mergel (vector signed short, vector signed short);
17198 vector unsigned short vec_mergel (vector unsigned short, vector unsigned short);
17199 vector float vec_mergel (vector float, vector float);
17200 vector bool int vec_mergel (vector bool int, vector bool int);
17201 vector signed int vec_mergel (vector signed int, vector signed int);
17202 vector unsigned int vec_mergel (vector unsigned int, vector unsigned int);
17204 vector unsigned short vec_mfvscr (void);
17206 vector unsigned char vec_min (vector bool char, vector unsigned char);
17207 vector unsigned char vec_min (vector unsigned char, vector bool char);
17208 vector unsigned char vec_min (vector unsigned char, vector unsigned char);
17209 vector signed char vec_min (vector bool char, vector signed char);
17210 vector signed char vec_min (vector signed char, vector bool char);
17211 vector signed char vec_min (vector signed char, vector signed char);
17212 vector unsigned short vec_min (vector bool short, vector unsigned short);
17213 vector unsigned short vec_min (vector unsigned short, vector bool short);
17214 vector unsigned short vec_min (vector unsigned short, vector unsigned short);
17215 vector signed short vec_min (vector bool short, vector signed short);
17216 vector signed short vec_min (vector signed short, vector bool short);
17217 vector signed short vec_min (vector signed short, vector signed short);
17218 vector unsigned int vec_min (vector bool int, vector unsigned int);
17219 vector unsigned int vec_min (vector unsigned int, vector bool int);
17220 vector unsigned int vec_min (vector unsigned int, vector unsigned int);
17221 vector signed int vec_min (vector bool int, vector signed int);
17222 vector signed int vec_min (vector signed int, vector bool int);
17223 vector signed int vec_min (vector signed int, vector signed int);
17224 vector float vec_min (vector float, vector float);
17226 vector signed short vec_mladd (vector signed short, vector signed short,
17227                                vector signed short);
17228 vector signed short vec_mladd (vector signed short, vector unsigned short,
17229                                vector unsigned short);
17230 vector signed short vec_mladd (vector unsigned short, vector signed short,
17231                                vector signed short);
17232 vector unsigned short vec_mladd (vector unsigned short, vector unsigned short,
17233                                  vector unsigned short);
17235 vector signed short vec_mradds (vector signed short, vector signed short,
17236                                 vector signed short);
17238 vector unsigned int vec_msum (vector unsigned char, vector unsigned char,
17239                               vector unsigned int);
17240 vector signed int vec_msum (vector signed char, vector unsigned char,
17241                             vector signed int);
17242 vector unsigned int vec_msum (vector unsigned short, vector unsigned short,
17243                               vector unsigned int);
17244 vector signed int vec_msum (vector signed short, vector signed short,
17245                             vector signed int);
17247 vector unsigned int vec_msums (vector unsigned short, vector unsigned short,
17248                                vector unsigned int);
17249 vector signed int vec_msums (vector signed short, vector signed short,
17250                              vector signed int);
17252 void vec_mtvscr (vector signed int);
17253 void vec_mtvscr (vector unsigned int);
17254 void vec_mtvscr (vector bool int);
17255 void vec_mtvscr (vector signed short);
17256 void vec_mtvscr (vector unsigned short);
17257 void vec_mtvscr (vector bool short);
17258 void vec_mtvscr (vector pixel);
17259 void vec_mtvscr (vector signed char);
17260 void vec_mtvscr (vector unsigned char);
17261 void vec_mtvscr (vector bool char);
17263 vector float vec_mul (vector float, vector float);
17265 vector unsigned short vec_mule (vector unsigned char, vector unsigned char);
17266 vector signed short vec_mule (vector signed char, vector signed char);
17267 vector unsigned int vec_mule (vector unsigned short, vector unsigned short);
17268 vector signed int vec_mule (vector signed short, vector signed short);
17270 vector unsigned short vec_mulo (vector unsigned char, vector unsigned char);
17271 vector signed short vec_mulo (vector signed char, vector signed char);
17272 vector unsigned int vec_mulo (vector unsigned short, vector unsigned short);
17273 vector signed int vec_mulo (vector signed short, vector signed short);
17275 vector signed char vec_nabs (vector signed char);
17276 vector signed short vec_nabs (vector signed short);
17277 vector signed int vec_nabs (vector signed int);
17278 vector float vec_nabs (vector float);
17280 vector float vec_nmsub (vector float, vector float, vector float);
17282 vector float vec_nor (vector float, vector float);
17283 vector signed int vec_nor (vector signed int, vector signed int);
17284 vector unsigned int vec_nor (vector unsigned int, vector unsigned int);
17285 vector bool int vec_nor (vector bool int, vector bool int);
17286 vector signed short vec_nor (vector signed short, vector signed short);
17287 vector unsigned short vec_nor (vector unsigned short, vector unsigned short);
17288 vector bool short vec_nor (vector bool short, vector bool short);
17289 vector signed char vec_nor (vector signed char, vector signed char);
17290 vector unsigned char vec_nor (vector unsigned char, vector unsigned char);
17291 vector bool char vec_nor (vector bool char, vector bool char);
17293 vector float vec_or (vector float, vector float);
17294 vector float vec_or (vector float, vector bool int);
17295 vector float vec_or (vector bool int, vector float);
17296 vector bool int vec_or (vector bool int, vector bool int);
17297 vector signed int vec_or (vector bool int, vector signed int);
17298 vector signed int vec_or (vector signed int, vector bool int);
17299 vector signed int vec_or (vector signed int, vector signed int);
17300 vector unsigned int vec_or (vector bool int, vector unsigned int);
17301 vector unsigned int vec_or (vector unsigned int, vector bool int);
17302 vector unsigned int vec_or (vector unsigned int, vector unsigned int);
17303 vector bool short vec_or (vector bool short, vector bool short);
17304 vector signed short vec_or (vector bool short, vector signed short);
17305 vector signed short vec_or (vector signed short, vector bool short);
17306 vector signed short vec_or (vector signed short, vector signed short);
17307 vector unsigned short vec_or (vector bool short, vector unsigned short);
17308 vector unsigned short vec_or (vector unsigned short, vector bool short);
17309 vector unsigned short vec_or (vector unsigned short, vector unsigned short);
17310 vector signed char vec_or (vector bool char, vector signed char);
17311 vector bool char vec_or (vector bool char, vector bool char);
17312 vector signed char vec_or (vector signed char, vector bool char);
17313 vector signed char vec_or (vector signed char, vector signed char);
17314 vector unsigned char vec_or (vector bool char, vector unsigned char);
17315 vector unsigned char vec_or (vector unsigned char, vector bool char);
17316 vector unsigned char vec_or (vector unsigned char, vector unsigned char);
17318 vector signed char vec_pack (vector signed short, vector signed short);
17319 vector unsigned char vec_pack (vector unsigned short, vector unsigned short);
17320 vector bool char vec_pack (vector bool short, vector bool short);
17321 vector signed short vec_pack (vector signed int, vector signed int);
17322 vector unsigned short vec_pack (vector unsigned int, vector unsigned int);
17323 vector bool short vec_pack (vector bool int, vector bool int);
17325 vector pixel vec_packpx (vector unsigned int, vector unsigned int);
17327 vector unsigned char vec_packs (vector unsigned short, vector unsigned short);
17328 vector signed char vec_packs (vector signed short, vector signed short);
17329 vector unsigned short vec_packs (vector unsigned int, vector unsigned int);
17330 vector signed short vec_packs (vector signed int, vector signed int);
17332 vector unsigned char vec_packsu (vector unsigned short, vector unsigned short);
17333 vector unsigned char vec_packsu (vector signed short, vector signed short);
17334 vector unsigned short vec_packsu (vector unsigned int, vector unsigned int);
17335 vector unsigned short vec_packsu (vector signed int, vector signed int);
17337 vector float vec_perm (vector float, vector float, vector unsigned char);
17338 vector signed int vec_perm (vector signed int, vector signed int, vector unsigned char);
17339 vector unsigned int vec_perm (vector unsigned int, vector unsigned int,
17340                               vector unsigned char);
17341 vector bool int vec_perm (vector bool int, vector bool int, vector unsigned char);
17342 vector signed short vec_perm (vector signed short, vector signed short,
17343                               vector unsigned char);
17344 vector unsigned short vec_perm (vector unsigned short, vector unsigned short,
17345                                 vector unsigned char);
17346 vector bool short vec_perm (vector bool short, vector bool short, vector unsigned char);
17347 vector pixel vec_perm (vector pixel, vector pixel, vector unsigned char);
17348 vector signed char vec_perm (vector signed char, vector signed char,
17349                              vector unsigned char);
17350 vector unsigned char vec_perm (vector unsigned char, vector unsigned char,
17351                                vector unsigned char);
17352 vector bool char vec_perm (vector bool char, vector bool char, vector unsigned char);
17354 vector float vec_re (vector float);
17356 vector bool char vec_reve (vector bool char);
17357 vector signed char vec_reve (vector signed char);
17358 vector unsigned char vec_reve (vector unsigned char);
17359 vector bool int vec_reve (vector bool int);
17360 vector signed int vec_reve (vector signed int);
17361 vector unsigned int vec_reve (vector unsigned int);
17362 vector bool short vec_reve (vector bool short);
17363 vector signed short vec_reve (vector signed short);
17364 vector unsigned short vec_reve (vector unsigned short);
17366 vector signed char vec_rl (vector signed char, vector unsigned char);
17367 vector unsigned char vec_rl (vector unsigned char, vector unsigned char);
17368 vector signed short vec_rl (vector signed short, vector unsigned short);
17369 vector unsigned short vec_rl (vector unsigned short, vector unsigned short);
17370 vector signed int vec_rl (vector signed int, vector unsigned int);
17371 vector unsigned int vec_rl (vector unsigned int, vector unsigned int);
17373 vector float vec_round (vector float);
17375 vector float vec_rsqrt (vector float);
17377 vector float vec_rsqrte (vector float);
17379 vector float vec_sel (vector float, vector float, vector bool int);
17380 vector float vec_sel (vector float, vector float, vector unsigned int);
17381 vector signed int vec_sel (vector signed int, vector signed int, vector bool int);
17382 vector signed int vec_sel (vector signed int, vector signed int, vector unsigned int);
17383 vector unsigned int vec_sel (vector unsigned int, vector unsigned int, vector bool int);
17384 vector unsigned int vec_sel (vector unsigned int, vector unsigned int,
17385                              vector unsigned int);
17386 vector bool int vec_sel (vector bool int, vector bool int, vector bool int);
17387 vector bool int vec_sel (vector bool int, vector bool int, vector unsigned int);
17388 vector signed short vec_sel (vector signed short, vector signed short,
17389                              vector bool short);
17390 vector signed short vec_sel (vector signed short, vector signed short,
17391                              vector unsigned short);
17392 vector unsigned short vec_sel (vector unsigned short, vector unsigned short,
17393                                vector bool short);
17394 vector unsigned short vec_sel (vector unsigned short, vector unsigned short,
17395                                vector unsigned short);
17396 vector bool short vec_sel (vector bool short, vector bool short, vector bool short);
17397 vector bool short vec_sel (vector bool short, vector bool short, vector unsigned short);
17398 vector signed char vec_sel (vector signed char, vector signed char, vector bool char);
17399 vector signed char vec_sel (vector signed char, vector signed char,
17400                             vector unsigned char);
17401 vector unsigned char vec_sel (vector unsigned char, vector unsigned char,
17402                               vector bool char);
17403 vector unsigned char vec_sel (vector unsigned char, vector unsigned char,
17404                               vector unsigned char);
17405 vector bool char vec_sel (vector bool char, vector bool char, vector bool char);
17406 vector bool char vec_sel (vector bool char, vector bool char, vector unsigned char);
17408 vector signed char vec_sl (vector signed char, vector unsigned char);
17409 vector unsigned char vec_sl (vector unsigned char, vector unsigned char);
17410 vector signed short vec_sl (vector signed short, vector unsigned short);
17411 vector unsigned short vec_sl (vector unsigned short, vector unsigned short);
17412 vector signed int vec_sl (vector signed int, vector unsigned int);
17413 vector unsigned int vec_sl (vector unsigned int, vector unsigned int);
17415 vector float vec_sld (vector float, vector float, const int);
17416 vector signed int vec_sld (vector signed int, vector signed int, const int);
17417 vector unsigned int vec_sld (vector unsigned int, vector unsigned int, const int);
17418 vector bool int vec_sld (vector bool int, vector bool int, const int);
17419 vector signed short vec_sld (vector signed short, vector signed short, const int);
17420 vector unsigned short vec_sld (vector unsigned short, vector unsigned short, const int);
17421 vector bool short vec_sld (vector bool short, vector bool short, const int);
17422 vector pixel vec_sld (vector pixel, vector pixel, const int);
17423 vector signed char vec_sld (vector signed char, vector signed char, const int);
17424 vector unsigned char vec_sld (vector unsigned char, vector unsigned char, const int);
17425 vector bool char vec_sld (vector bool char, vector bool char, const int);
17427 vector signed int vec_sll (vector signed int, vector unsigned int);
17428 vector signed int vec_sll (vector signed int, vector unsigned short);
17429 vector signed int vec_sll (vector signed int, vector unsigned char);
17430 vector unsigned int vec_sll (vector unsigned int, vector unsigned int);
17431 vector unsigned int vec_sll (vector unsigned int, vector unsigned short);
17432 vector unsigned int vec_sll (vector unsigned int, vector unsigned char);
17433 vector bool int vec_sll (vector bool int, vector unsigned int);
17434 vector bool int vec_sll (vector bool int, vector unsigned short);
17435 vector bool int vec_sll (vector bool int, vector unsigned char);
17436 vector signed short vec_sll (vector signed short, vector unsigned int);
17437 vector signed short vec_sll (vector signed short, vector unsigned short);
17438 vector signed short vec_sll (vector signed short, vector unsigned char);
17439 vector unsigned short vec_sll (vector unsigned short, vector unsigned int);
17440 vector unsigned short vec_sll (vector unsigned short, vector unsigned short);
17441 vector unsigned short vec_sll (vector unsigned short, vector unsigned char);
17442 vector bool short vec_sll (vector bool short, vector unsigned int);
17443 vector bool short vec_sll (vector bool short, vector unsigned short);
17444 vector bool short vec_sll (vector bool short, vector unsigned char);
17445 vector pixel vec_sll (vector pixel, vector unsigned int);
17446 vector pixel vec_sll (vector pixel, vector unsigned short);
17447 vector pixel vec_sll (vector pixel, vector unsigned char);
17448 vector signed char vec_sll (vector signed char, vector unsigned int);
17449 vector signed char vec_sll (vector signed char, vector unsigned short);
17450 vector signed char vec_sll (vector signed char, vector unsigned char);
17451 vector unsigned char vec_sll (vector unsigned char, vector unsigned int);
17452 vector unsigned char vec_sll (vector unsigned char, vector unsigned short);
17453 vector unsigned char vec_sll (vector unsigned char, vector unsigned char);
17454 vector bool char vec_sll (vector bool char, vector unsigned int);
17455 vector bool char vec_sll (vector bool char, vector unsigned short);
17456 vector bool char vec_sll (vector bool char, vector unsigned char);
17458 vector float vec_slo (vector float, vector signed char);
17459 vector float vec_slo (vector float, vector unsigned char);
17460 vector signed int vec_slo (vector signed int, vector signed char);
17461 vector signed int vec_slo (vector signed int, vector unsigned char);
17462 vector unsigned int vec_slo (vector unsigned int, vector signed char);
17463 vector unsigned int vec_slo (vector unsigned int, vector unsigned char);
17464 vector signed short vec_slo (vector signed short, vector signed char);
17465 vector signed short vec_slo (vector signed short, vector unsigned char);
17466 vector unsigned short vec_slo (vector unsigned short, vector signed char);
17467 vector unsigned short vec_slo (vector unsigned short, vector unsigned char);
17468 vector pixel vec_slo (vector pixel, vector signed char);
17469 vector pixel vec_slo (vector pixel, vector unsigned char);
17470 vector signed char vec_slo (vector signed char, vector signed char);
17471 vector signed char vec_slo (vector signed char, vector unsigned char);
17472 vector unsigned char vec_slo (vector unsigned char, vector signed char);
17473 vector unsigned char vec_slo (vector unsigned char, vector unsigned char);
17475 vector signed char vec_splat (vector signed char, const int);
17476 vector unsigned char vec_splat (vector unsigned char, const int);
17477 vector bool char vec_splat (vector bool char, const int);
17478 vector signed short vec_splat (vector signed short, const int);
17479 vector unsigned short vec_splat (vector unsigned short, const int);
17480 vector bool short vec_splat (vector bool short, const int);
17481 vector pixel vec_splat (vector pixel, const int);
17482 vector float vec_splat (vector float, const int);
17483 vector signed int vec_splat (vector signed int, const int);
17484 vector unsigned int vec_splat (vector unsigned int, const int);
17485 vector bool int vec_splat (vector bool int, const int);
17487 vector signed short vec_splat_s16 (const int);
17489 vector signed int vec_splat_s32 (const int);
17491 vector signed char vec_splat_s8 (const int);
17493 vector unsigned short vec_splat_u16 (const int);
17495 vector unsigned int vec_splat_u32 (const int);
17497 vector unsigned char vec_splat_u8 (const int);
17499 vector signed char vec_splats (signed char);
17500 vector unsigned char vec_splats (unsigned char);
17501 vector signed short vec_splats (signed short);
17502 vector unsigned short vec_splats (unsigned short);
17503 vector signed int vec_splats (signed int);
17504 vector unsigned int vec_splats (unsigned int);
17505 vector float vec_splats (float);
17507 vector signed char vec_sr (vector signed char, vector unsigned char);
17508 vector unsigned char vec_sr (vector unsigned char, vector unsigned char);
17509 vector signed short vec_sr (vector signed short, vector unsigned short);
17510 vector unsigned short vec_sr (vector unsigned short, vector unsigned short);
17511 vector signed int vec_sr (vector signed int, vector unsigned int);
17512 vector unsigned int vec_sr (vector unsigned int, vector unsigned int);
17514 vector signed char vec_sra (vector signed char, vector unsigned char);
17515 vector unsigned char vec_sra (vector unsigned char, vector unsigned char);
17516 vector signed short vec_sra (vector signed short, vector unsigned short);
17517 vector unsigned short vec_sra (vector unsigned short, vector unsigned short);
17518 vector signed int vec_sra (vector signed int, vector unsigned int);
17519 vector unsigned int vec_sra (vector unsigned int, vector unsigned int);
17521 vector signed int vec_srl (vector signed int, vector unsigned int);
17522 vector signed int vec_srl (vector signed int, vector unsigned short);
17523 vector signed int vec_srl (vector signed int, vector unsigned char);
17524 vector unsigned int vec_srl (vector unsigned int, vector unsigned int);
17525 vector unsigned int vec_srl (vector unsigned int, vector unsigned short);
17526 vector unsigned int vec_srl (vector unsigned int, vector unsigned char);
17527 vector bool int vec_srl (vector bool int, vector unsigned int);
17528 vector bool int vec_srl (vector bool int, vector unsigned short);
17529 vector bool int vec_srl (vector bool int, vector unsigned char);
17530 vector signed short vec_srl (vector signed short, vector unsigned int);
17531 vector signed short vec_srl (vector signed short, vector unsigned short);
17532 vector signed short vec_srl (vector signed short, vector unsigned char);
17533 vector unsigned short vec_srl (vector unsigned short, vector unsigned int);
17534 vector unsigned short vec_srl (vector unsigned short, vector unsigned short);
17535 vector unsigned short vec_srl (vector unsigned short, vector unsigned char);
17536 vector bool short vec_srl (vector bool short, vector unsigned int);
17537 vector bool short vec_srl (vector bool short, vector unsigned short);
17538 vector bool short vec_srl (vector bool short, vector unsigned char);
17539 vector pixel vec_srl (vector pixel, vector unsigned int);
17540 vector pixel vec_srl (vector pixel, vector unsigned short);
17541 vector pixel vec_srl (vector pixel, vector unsigned char);
17542 vector signed char vec_srl (vector signed char, vector unsigned int);
17543 vector signed char vec_srl (vector signed char, vector unsigned short);
17544 vector signed char vec_srl (vector signed char, vector unsigned char);
17545 vector unsigned char vec_srl (vector unsigned char, vector unsigned int);
17546 vector unsigned char vec_srl (vector unsigned char, vector unsigned short);
17547 vector unsigned char vec_srl (vector unsigned char, vector unsigned char);
17548 vector bool char vec_srl (vector bool char, vector unsigned int);
17549 vector bool char vec_srl (vector bool char, vector unsigned short);
17550 vector bool char vec_srl (vector bool char, vector unsigned char);
17552 vector float vec_sro (vector float, vector signed char);
17553 vector float vec_sro (vector float, vector unsigned char);
17554 vector signed int vec_sro (vector signed int, vector signed char);
17555 vector signed int vec_sro (vector signed int, vector unsigned char);
17556 vector unsigned int vec_sro (vector unsigned int, vector signed char);
17557 vector unsigned int vec_sro (vector unsigned int, vector unsigned char);
17558 vector signed short vec_sro (vector signed short, vector signed char);
17559 vector signed short vec_sro (vector signed short, vector unsigned char);
17560 vector unsigned short vec_sro (vector unsigned short, vector signed char);
17561 vector unsigned short vec_sro (vector unsigned short, vector unsigned char);
17562 vector pixel vec_sro (vector pixel, vector signed char);
17563 vector pixel vec_sro (vector pixel, vector unsigned char);
17564 vector signed char vec_sro (vector signed char, vector signed char);
17565 vector signed char vec_sro (vector signed char, vector unsigned char);
17566 vector unsigned char vec_sro (vector unsigned char, vector signed char);
17567 vector unsigned char vec_sro (vector unsigned char, vector unsigned char);
17569 void vec_st (vector float, int, vector float *);
17570 void vec_st (vector float, int, float *);
17571 void vec_st (vector signed int, int, vector signed int *);
17572 void vec_st (vector signed int, int, int *);
17573 void vec_st (vector unsigned int, int, vector unsigned int *);
17574 void vec_st (vector unsigned int, int, unsigned int *);
17575 void vec_st (vector bool int, int, vector bool int *);
17576 void vec_st (vector bool int, int, unsigned int *);
17577 void vec_st (vector bool int, int, int *);
17578 void vec_st (vector signed short, int, vector signed short *);
17579 void vec_st (vector signed short, int, short *);
17580 void vec_st (vector unsigned short, int, vector unsigned short *);
17581 void vec_st (vector unsigned short, int, unsigned short *);
17582 void vec_st (vector bool short, int, vector bool short *);
17583 void vec_st (vector bool short, int, unsigned short *);
17584 void vec_st (vector pixel, int, vector pixel *);
17585 void vec_st (vector bool short, int, short *);
17586 void vec_st (vector signed char, int, vector signed char *);
17587 void vec_st (vector signed char, int, signed char *);
17588 void vec_st (vector unsigned char, int, vector unsigned char *);
17589 void vec_st (vector unsigned char, int, unsigned char *);
17590 void vec_st (vector bool char, int, vector bool char *);
17591 void vec_st (vector bool char, int, unsigned char *);
17592 void vec_st (vector bool char, int, signed char *);
17594 void vec_ste (vector signed char, int, signed char *);
17595 void vec_ste (vector unsigned char, int, unsigned char *);
17596 void vec_ste (vector bool char, int, signed char *);
17597 void vec_ste (vector bool char, int, unsigned char *);
17598 void vec_ste (vector signed short, int, short *);
17599 void vec_ste (vector unsigned short, int, unsigned short *);
17600 void vec_ste (vector bool short, int, short *);
17601 void vec_ste (vector bool short, int, unsigned short *);
17602 void vec_ste (vector pixel, int, short *);
17603 void vec_ste (vector pixel, int, unsigned short *);
17604 void vec_ste (vector float, int, float *);
17605 void vec_ste (vector signed int, int, int *);
17606 void vec_ste (vector unsigned int, int, unsigned int *);
17607 void vec_ste (vector bool int, int, int *);
17608 void vec_ste (vector bool int, int, unsigned int *);
17610 void vec_stl (vector float, int, vector float *);
17611 void vec_stl (vector float, int, float *);
17612 void vec_stl (vector signed int, int, vector signed int *);
17613 void vec_stl (vector signed int, int, int *);
17614 void vec_stl (vector unsigned int, int, vector unsigned int *);
17615 void vec_stl (vector unsigned int, int, unsigned int *);
17616 void vec_stl (vector bool int, int, vector bool int *);
17617 void vec_stl (vector bool int, int, unsigned int *);
17618 void vec_stl (vector bool int, int, int *);
17619 void vec_stl (vector signed short, int, vector signed short *);
17620 void vec_stl (vector signed short, int, short *);
17621 void vec_stl (vector unsigned short, int, vector unsigned short *);
17622 void vec_stl (vector unsigned short, int, unsigned short *);
17623 void vec_stl (vector bool short, int, vector bool short *);
17624 void vec_stl (vector bool short, int, unsigned short *);
17625 void vec_stl (vector bool short, int, short *);
17626 void vec_stl (vector pixel, int, vector pixel *);
17627 void vec_stl (vector signed char, int, vector signed char *);
17628 void vec_stl (vector signed char, int, signed char *);
17629 void vec_stl (vector unsigned char, int, vector unsigned char *);
17630 void vec_stl (vector unsigned char, int, unsigned char *);
17631 void vec_stl (vector bool char, int, vector bool char *);
17632 void vec_stl (vector bool char, int, unsigned char *);
17633 void vec_stl (vector bool char, int, signed char *);
17635 void vec_stvebx (vector signed char, int, signed char *);
17636 void vec_stvebx (vector unsigned char, int, unsigned char *);
17637 void vec_stvebx (vector bool char, int, signed char *);
17638 void vec_stvebx (vector bool char, int, unsigned char *);
17640 void vec_stvehx (vector signed short, int, short *);
17641 void vec_stvehx (vector unsigned short, int, unsigned short *);
17642 void vec_stvehx (vector bool short, int, short *);
17643 void vec_stvehx (vector bool short, int, unsigned short *);
17645 void vec_stvewx (vector float, int, float *);
17646 void vec_stvewx (vector signed int, int, int *);
17647 void vec_stvewx (vector unsigned int, int, unsigned int *);
17648 void vec_stvewx (vector bool int, int, int *);
17649 void vec_stvewx (vector bool int, int, unsigned int *);
17651 vector signed char vec_sub (vector bool char, vector signed char);
17652 vector signed char vec_sub (vector signed char, vector bool char);
17653 vector signed char vec_sub (vector signed char, vector signed char);
17654 vector unsigned char vec_sub (vector bool char, vector unsigned char);
17655 vector unsigned char vec_sub (vector unsigned char, vector bool char);
17656 vector unsigned char vec_sub (vector unsigned char, vector unsigned char);
17657 vector signed short vec_sub (vector bool short, vector signed short);
17658 vector signed short vec_sub (vector signed short, vector bool short);
17659 vector signed short vec_sub (vector signed short, vector signed short);
17660 vector unsigned short vec_sub (vector bool short, vector unsigned short);
17661 vector unsigned short vec_sub (vector unsigned short, vector bool short);
17662 vector unsigned short vec_sub (vector unsigned short, vector unsigned short);
17663 vector signed int vec_sub (vector bool int, vector signed int);
17664 vector signed int vec_sub (vector signed int, vector bool int);
17665 vector signed int vec_sub (vector signed int, vector signed int);
17666 vector unsigned int vec_sub (vector bool int, vector unsigned int);
17667 vector unsigned int vec_sub (vector unsigned int, vector bool int);
17668 vector unsigned int vec_sub (vector unsigned int, vector unsigned int);
17669 vector float vec_sub (vector float, vector float);
17671 vector signed int vec_subc (vector signed int, vector signed int);
17672 vector unsigned int vec_subc (vector unsigned int, vector unsigned int);
17674 vector signed int vec_sube (vector signed int, vector signed int,
17675                             vector signed int);
17676 vector unsigned int vec_sube (vector unsigned int, vector unsigned int,
17677                               vector unsigned int);
17679 vector signed int vec_subec (vector signed int, vector signed int,
17680                              vector signed int);
17681 vector unsigned int vec_subec (vector unsigned int, vector unsigned int,
17682                                vector unsigned int);
17684 vector unsigned char vec_subs (vector bool char, vector unsigned char);
17685 vector unsigned char vec_subs (vector unsigned char, vector bool char);
17686 vector unsigned char vec_subs (vector unsigned char, vector unsigned char);
17687 vector signed char vec_subs (vector bool char, vector signed char);
17688 vector signed char vec_subs (vector signed char, vector bool char);
17689 vector signed char vec_subs (vector signed char, vector signed char);
17690 vector unsigned short vec_subs (vector bool short, vector unsigned short);
17691 vector unsigned short vec_subs (vector unsigned short, vector bool short);
17692 vector unsigned short vec_subs (vector unsigned short, vector unsigned short);
17693 vector signed short vec_subs (vector bool short, vector signed short);
17694 vector signed short vec_subs (vector signed short, vector bool short);
17695 vector signed short vec_subs (vector signed short, vector signed short);
17696 vector unsigned int vec_subs (vector bool int, vector unsigned int);
17697 vector unsigned int vec_subs (vector unsigned int, vector bool int);
17698 vector unsigned int vec_subs (vector unsigned int, vector unsigned int);
17699 vector signed int vec_subs (vector bool int, vector signed int);
17700 vector signed int vec_subs (vector signed int, vector bool int);
17701 vector signed int vec_subs (vector signed int, vector signed int);
17703 vector signed int vec_sum2s (vector signed int, vector signed int);
17705 vector unsigned int vec_sum4s (vector unsigned char, vector unsigned int);
17706 vector signed int vec_sum4s (vector signed char, vector signed int);
17707 vector signed int vec_sum4s (vector signed short, vector signed int);
17709 vector signed int vec_sums (vector signed int, vector signed int);
17711 vector float vec_trunc (vector float);
17713 vector signed short vec_unpackh (vector signed char);
17714 vector bool short vec_unpackh (vector bool char);
17715 vector signed int vec_unpackh (vector signed short);
17716 vector bool int vec_unpackh (vector bool short);
17717 vector unsigned int vec_unpackh (vector pixel);
17719 vector signed short vec_unpackl (vector signed char);
17720 vector bool short vec_unpackl (vector bool char);
17721 vector unsigned int vec_unpackl (vector pixel);
17722 vector signed int vec_unpackl (vector signed short);
17723 vector bool int vec_unpackl (vector bool short);
17725 vector float vec_vaddfp (vector float, vector float);
17727 vector signed char vec_vaddsbs (vector bool char, vector signed char);
17728 vector signed char vec_vaddsbs (vector signed char, vector bool char);
17729 vector signed char vec_vaddsbs (vector signed char, vector signed char);
17731 vector signed short vec_vaddshs (vector bool short, vector signed short);
17732 vector signed short vec_vaddshs (vector signed short, vector bool short);
17733 vector signed short vec_vaddshs (vector signed short, vector signed short);
17735 vector signed int vec_vaddsws (vector bool int, vector signed int);
17736 vector signed int vec_vaddsws (vector signed int, vector bool int);
17737 vector signed int vec_vaddsws (vector signed int, vector signed int);
17739 vector signed char vec_vaddubm (vector bool char, vector signed char);
17740 vector signed char vec_vaddubm (vector signed char, vector bool char);
17741 vector signed char vec_vaddubm (vector signed char, vector signed char);
17742 vector unsigned char vec_vaddubm (vector bool char, vector unsigned char);
17743 vector unsigned char vec_vaddubm (vector unsigned char, vector bool char);
17744 vector unsigned char vec_vaddubm (vector unsigned char, vector unsigned char);
17746 vector unsigned char vec_vaddubs (vector bool char, vector unsigned char);
17747 vector unsigned char vec_vaddubs (vector unsigned char, vector bool char);
17748 vector unsigned char vec_vaddubs (vector unsigned char, vector unsigned char);
17750 vector signed short vec_vadduhm (vector bool short, vector signed short);
17751 vector signed short vec_vadduhm (vector signed short, vector bool short);
17752 vector signed short vec_vadduhm (vector signed short, vector signed short);
17753 vector unsigned short vec_vadduhm (vector bool short, vector unsigned short);
17754 vector unsigned short vec_vadduhm (vector unsigned short, vector bool short);
17755 vector unsigned short vec_vadduhm (vector unsigned short, vector unsigned short);
17757 vector unsigned short vec_vadduhs (vector bool short, vector unsigned short);
17758 vector unsigned short vec_vadduhs (vector unsigned short, vector bool short);
17759 vector unsigned short vec_vadduhs (vector unsigned short, vector unsigned short);
17761 vector signed int vec_vadduwm (vector bool int, vector signed int);
17762 vector signed int vec_vadduwm (vector signed int, vector bool int);
17763 vector signed int vec_vadduwm (vector signed int, vector signed int);
17764 vector unsigned int vec_vadduwm (vector bool int, vector unsigned int);
17765 vector unsigned int vec_vadduwm (vector unsigned int, vector bool int);
17766 vector unsigned int vec_vadduwm (vector unsigned int, vector unsigned int);
17768 vector unsigned int vec_vadduws (vector bool int, vector unsigned int);
17769 vector unsigned int vec_vadduws (vector unsigned int, vector bool int);
17770 vector unsigned int vec_vadduws (vector unsigned int, vector unsigned int);
17772 vector signed char vec_vavgsb (vector signed char, vector signed char);
17774 vector signed short vec_vavgsh (vector signed short, vector signed short);
17776 vector signed int vec_vavgsw (vector signed int, vector signed int);
17778 vector unsigned char vec_vavgub (vector unsigned char, vector unsigned char);
17780 vector unsigned short vec_vavguh (vector unsigned short, vector unsigned short);
17782 vector unsigned int vec_vavguw (vector unsigned int, vector unsigned int);
17784 vector float vec_vcfsx (vector signed int, const int);
17786 vector float vec_vcfux (vector unsigned int, const int);
17788 vector bool int vec_vcmpeqfp (vector float, vector float);
17790 vector bool char vec_vcmpequb (vector signed char, vector signed char);
17791 vector bool char vec_vcmpequb (vector unsigned char, vector unsigned char);
17793 vector bool short vec_vcmpequh (vector signed short, vector signed short);
17794 vector bool short vec_vcmpequh (vector unsigned short, vector unsigned short);
17796 vector bool int vec_vcmpequw (vector signed int, vector signed int);
17797 vector bool int vec_vcmpequw (vector unsigned int, vector unsigned int);
17799 vector bool int vec_vcmpgtfp (vector float, vector float);
17801 vector bool char vec_vcmpgtsb (vector signed char, vector signed char);
17803 vector bool short vec_vcmpgtsh (vector signed short, vector signed short);
17805 vector bool int vec_vcmpgtsw (vector signed int, vector signed int);
17807 vector bool char vec_vcmpgtub (vector unsigned char, vector unsigned char);
17809 vector bool short vec_vcmpgtuh (vector unsigned short, vector unsigned short);
17811 vector bool int vec_vcmpgtuw (vector unsigned int, vector unsigned int);
17813 vector float vec_vmaxfp (vector float, vector float);
17815 vector signed char vec_vmaxsb (vector bool char, vector signed char);
17816 vector signed char vec_vmaxsb (vector signed char, vector bool char);
17817 vector signed char vec_vmaxsb (vector signed char, vector signed char);
17819 vector signed short vec_vmaxsh (vector bool short, vector signed short);
17820 vector signed short vec_vmaxsh (vector signed short, vector bool short);
17821 vector signed short vec_vmaxsh (vector signed short, vector signed short);
17823 vector signed int vec_vmaxsw (vector bool int, vector signed int);
17824 vector signed int vec_vmaxsw (vector signed int, vector bool int);
17825 vector signed int vec_vmaxsw (vector signed int, vector signed int);
17827 vector unsigned char vec_vmaxub (vector bool char, vector unsigned char);
17828 vector unsigned char vec_vmaxub (vector unsigned char, vector bool char);
17829 vector unsigned char vec_vmaxub (vector unsigned char, vector unsigned char);
17831 vector unsigned short vec_vmaxuh (vector bool short, vector unsigned short);
17832 vector unsigned short vec_vmaxuh (vector unsigned short, vector bool short);
17833 vector unsigned short vec_vmaxuh (vector unsigned short, vector unsigned short);
17835 vector unsigned int vec_vmaxuw (vector bool int, vector unsigned int);
17836 vector unsigned int vec_vmaxuw (vector unsigned int, vector bool int);
17837 vector unsigned int vec_vmaxuw (vector unsigned int, vector unsigned int);
17839 vector float vec_vminfp (vector float, vector float);
17841 vector signed char vec_vminsb (vector bool char, vector signed char);
17842 vector signed char vec_vminsb (vector signed char, vector bool char);
17843 vector signed char vec_vminsb (vector signed char, vector signed char);
17845 vector signed short vec_vminsh (vector bool short, vector signed short);
17846 vector signed short vec_vminsh (vector signed short, vector bool short);
17847 vector signed short vec_vminsh (vector signed short, vector signed short);
17849 vector signed int vec_vminsw (vector bool int, vector signed int);
17850 vector signed int vec_vminsw (vector signed int, vector bool int);
17851 vector signed int vec_vminsw (vector signed int, vector signed int);
17853 vector unsigned char vec_vminub (vector bool char, vector unsigned char);
17854 vector unsigned char vec_vminub (vector unsigned char, vector bool char);
17855 vector unsigned char vec_vminub (vector unsigned char, vector unsigned char);
17857 vector unsigned short vec_vminuh (vector bool short, vector unsigned short);
17858 vector unsigned short vec_vminuh (vector unsigned short, vector bool short);
17859 vector unsigned short vec_vminuh (vector unsigned short, vector unsigned short);
17861 vector unsigned int vec_vminuw (vector bool int, vector unsigned int);
17862 vector unsigned int vec_vminuw (vector unsigned int, vector bool int);
17863 vector unsigned int vec_vminuw (vector unsigned int, vector unsigned int);
17865 vector bool char vec_vmrghb (vector bool char, vector bool char);
17866 vector signed char vec_vmrghb (vector signed char, vector signed char);
17867 vector unsigned char vec_vmrghb (vector unsigned char, vector unsigned char);
17869 vector bool short vec_vmrghh (vector bool short, vector bool short);
17870 vector signed short vec_vmrghh (vector signed short, vector signed short);
17871 vector unsigned short vec_vmrghh (vector unsigned short, vector unsigned short);
17872 vector pixel vec_vmrghh (vector pixel, vector pixel);
17874 vector float vec_vmrghw (vector float, vector float);
17875 vector bool int vec_vmrghw (vector bool int, vector bool int);
17876 vector signed int vec_vmrghw (vector signed int, vector signed int);
17877 vector unsigned int vec_vmrghw (vector unsigned int, vector unsigned int);
17879 vector bool char vec_vmrglb (vector bool char, vector bool char);
17880 vector signed char vec_vmrglb (vector signed char, vector signed char);
17881 vector unsigned char vec_vmrglb (vector unsigned char, vector unsigned char);
17883 vector bool short vec_vmrglh (vector bool short, vector bool short);
17884 vector signed short vec_vmrglh (vector signed short, vector signed short);
17885 vector unsigned short vec_vmrglh (vector unsigned short, vector unsigned short);
17886 vector pixel vec_vmrglh (vector pixel, vector pixel);
17888 vector float vec_vmrglw (vector float, vector float);
17889 vector signed int vec_vmrglw (vector signed int, vector signed int);
17890 vector unsigned int vec_vmrglw (vector unsigned int, vector unsigned int);
17891 vector bool int vec_vmrglw (vector bool int, vector bool int);
17893 vector signed int vec_vmsummbm (vector signed char, vector unsigned char,
17894                                 vector signed int);
17896 vector signed int vec_vmsumshm (vector signed short, vector signed short,
17897                                 vector signed int);
17899 vector signed int vec_vmsumshs (vector signed short, vector signed short,
17900                                 vector signed int);
17902 vector unsigned int vec_vmsumubm (vector unsigned char, vector unsigned char,
17903                                   vector unsigned int);
17905 vector unsigned int vec_vmsumuhm (vector unsigned short, vector unsigned short,
17906                                   vector unsigned int);
17908 vector unsigned int vec_vmsumuhs (vector unsigned short, vector unsigned short,
17909                                   vector unsigned int);
17911 vector signed short vec_vmulesb (vector signed char, vector signed char);
17913 vector signed int vec_vmulesh (vector signed short, vector signed short);
17915 vector unsigned short vec_vmuleub (vector unsigned char, vector unsigned char);
17917 vector unsigned int vec_vmuleuh (vector unsigned short, vector unsigned short);
17919 vector signed short vec_vmulosb (vector signed char, vector signed char);
17921 vector signed int vec_vmulosh (vector signed short, vector signed short);
17923 vector unsigned short vec_vmuloub (vector unsigned char, vector unsigned char);
17925 vector unsigned int vec_vmulouh (vector unsigned short, vector unsigned short);
17927 vector signed char vec_vpkshss (vector signed short, vector signed short);
17929 vector unsigned char vec_vpkshus (vector signed short, vector signed short);
17931 vector signed short vec_vpkswss (vector signed int, vector signed int);
17933 vector unsigned short vec_vpkswus (vector signed int, vector signed int);
17935 vector bool char vec_vpkuhum (vector bool short, vector bool short);
17936 vector signed char vec_vpkuhum (vector signed short, vector signed short);
17937 vector unsigned char vec_vpkuhum (vector unsigned short, vector unsigned short);
17939 vector unsigned char vec_vpkuhus (vector unsigned short, vector unsigned short);
17941 vector bool short vec_vpkuwum (vector bool int, vector bool int);
17942 vector signed short vec_vpkuwum (vector signed int, vector signed int);
17943 vector unsigned short vec_vpkuwum (vector unsigned int, vector unsigned int);
17945 vector unsigned short vec_vpkuwus (vector unsigned int, vector unsigned int);
17947 vector signed char vec_vrlb (vector signed char, vector unsigned char);
17948 vector unsigned char vec_vrlb (vector unsigned char, vector unsigned char);
17950 vector signed short vec_vrlh (vector signed short, vector unsigned short);
17951 vector unsigned short vec_vrlh (vector unsigned short, vector unsigned short);
17953 vector signed int vec_vrlw (vector signed int, vector unsigned int);
17954 vector unsigned int vec_vrlw (vector unsigned int, vector unsigned int);
17956 vector signed char vec_vslb (vector signed char, vector unsigned char);
17957 vector unsigned char vec_vslb (vector unsigned char, vector unsigned char);
17959 vector signed short vec_vslh (vector signed short, vector unsigned short);
17960 vector unsigned short vec_vslh (vector unsigned short, vector unsigned short);
17962 vector signed int vec_vslw (vector signed int, vector unsigned int);
17963 vector unsigned int vec_vslw (vector unsigned int, vector unsigned int);
17965 vector signed char vec_vspltb (vector signed char, const int);
17966 vector unsigned char vec_vspltb (vector unsigned char, const int);
17967 vector bool char vec_vspltb (vector bool char, const int);
17969 vector bool short vec_vsplth (vector bool short, const int);
17970 vector signed short vec_vsplth (vector signed short, const int);
17971 vector unsigned short vec_vsplth (vector unsigned short, const int);
17972 vector pixel vec_vsplth (vector pixel, const int);
17974 vector float vec_vspltw (vector float, const int);
17975 vector signed int vec_vspltw (vector signed int, const int);
17976 vector unsigned int vec_vspltw (vector unsigned int, const int);
17977 vector bool int vec_vspltw (vector bool int, const int);
17979 vector signed char vec_vsrab (vector signed char, vector unsigned char);
17980 vector unsigned char vec_vsrab (vector unsigned char, vector unsigned char);
17982 vector signed short vec_vsrah (vector signed short, vector unsigned short);
17983 vector unsigned short vec_vsrah (vector unsigned short, vector unsigned short);
17985 vector signed int vec_vsraw (vector signed int, vector unsigned int);
17986 vector unsigned int vec_vsraw (vector unsigned int, vector unsigned int);
17988 vector signed char vec_vsrb (vector signed char, vector unsigned char);
17989 vector unsigned char vec_vsrb (vector unsigned char, vector unsigned char);
17991 vector signed short vec_vsrh (vector signed short, vector unsigned short);
17992 vector unsigned short vec_vsrh (vector unsigned short, vector unsigned short);
17994 vector signed int vec_vsrw (vector signed int, vector unsigned int);
17995 vector unsigned int vec_vsrw (vector unsigned int, vector unsigned int);
17997 vector float vec_vsubfp (vector float, vector float);
17999 vector signed char vec_vsubsbs (vector bool char, vector signed char);
18000 vector signed char vec_vsubsbs (vector signed char, vector bool char);
18001 vector signed char vec_vsubsbs (vector signed char, vector signed char);
18003 vector signed short vec_vsubshs (vector bool short, vector signed short);
18004 vector signed short vec_vsubshs (vector signed short, vector bool short);
18005 vector signed short vec_vsubshs (vector signed short, vector signed short);
18007 vector signed int vec_vsubsws (vector bool int, vector signed int);
18008 vector signed int vec_vsubsws (vector signed int, vector bool int);
18009 vector signed int vec_vsubsws (vector signed int, vector signed int);
18011 vector signed char vec_vsububm (vector bool char, vector signed char);
18012 vector signed char vec_vsububm (vector signed char, vector bool char);
18013 vector signed char vec_vsububm (vector signed char, vector signed char);
18014 vector unsigned char vec_vsububm (vector bool char, vector unsigned char);
18015 vector unsigned char vec_vsububm (vector unsigned char, vector bool char);
18016 vector unsigned char vec_vsububm (vector unsigned char, vector unsigned char);
18018 vector unsigned char vec_vsububs (vector bool char, vector unsigned char);
18019 vector unsigned char vec_vsububs (vector unsigned char, vector bool char);
18020 vector unsigned char vec_vsububs (vector unsigned char, vector unsigned char);
18022 vector signed short vec_vsubuhm (vector bool short, vector signed short);
18023 vector signed short vec_vsubuhm (vector signed short, vector bool short);
18024 vector signed short vec_vsubuhm (vector signed short, vector signed short);
18025 vector unsigned short vec_vsubuhm (vector bool short, vector unsigned short);
18026 vector unsigned short vec_vsubuhm (vector unsigned short, vector bool short);
18027 vector unsigned short vec_vsubuhm (vector unsigned short, vector unsigned short);
18029 vector unsigned short vec_vsubuhs (vector bool short, vector unsigned short);
18030 vector unsigned short vec_vsubuhs (vector unsigned short, vector bool short);
18031 vector unsigned short vec_vsubuhs (vector unsigned short, vector unsigned short);
18033 vector signed int vec_vsubuwm (vector bool int, vector signed int);
18034 vector signed int vec_vsubuwm (vector signed int, vector bool int);
18035 vector signed int vec_vsubuwm (vector signed int, vector signed int);
18036 vector unsigned int vec_vsubuwm (vector bool int, vector unsigned int);
18037 vector unsigned int vec_vsubuwm (vector unsigned int, vector bool int);
18038 vector unsigned int vec_vsubuwm (vector unsigned int, vector unsigned int);
18040 vector unsigned int vec_vsubuws (vector bool int, vector unsigned int);
18041 vector unsigned int vec_vsubuws (vector unsigned int, vector bool int);
18042 vector unsigned int vec_vsubuws (vector unsigned int, vector unsigned int);
18044 vector signed int vec_vsum4sbs (vector signed char, vector signed int);
18046 vector signed int vec_vsum4shs (vector signed short, vector signed int);
18048 vector unsigned int vec_vsum4ubs (vector unsigned char, vector unsigned int);
18050 vector unsigned int vec_vupkhpx (vector pixel);
18052 vector bool short vec_vupkhsb (vector bool char);
18053 vector signed short vec_vupkhsb (vector signed char);
18055 vector bool int vec_vupkhsh (vector bool short);
18056 vector signed int vec_vupkhsh (vector signed short);
18058 vector unsigned int vec_vupklpx (vector pixel);
18060 vector bool short vec_vupklsb (vector bool char);
18061 vector signed short vec_vupklsb (vector signed char);
18063 vector bool int vec_vupklsh (vector bool short);
18064 vector signed int vec_vupklsh (vector signed short);
18066 vector float vec_xor (vector float, vector float);
18067 vector float vec_xor (vector float, vector bool int);
18068 vector float vec_xor (vector bool int, vector float);
18069 vector bool int vec_xor (vector bool int, vector bool int);
18070 vector signed int vec_xor (vector bool int, vector signed int);
18071 vector signed int vec_xor (vector signed int, vector bool int);
18072 vector signed int vec_xor (vector signed int, vector signed int);
18073 vector unsigned int vec_xor (vector bool int, vector unsigned int);
18074 vector unsigned int vec_xor (vector unsigned int, vector bool int);
18075 vector unsigned int vec_xor (vector unsigned int, vector unsigned int);
18076 vector bool short vec_xor (vector bool short, vector bool short);
18077 vector signed short vec_xor (vector bool short, vector signed short);
18078 vector signed short vec_xor (vector signed short, vector bool short);
18079 vector signed short vec_xor (vector signed short, vector signed short);
18080 vector unsigned short vec_xor (vector bool short, vector unsigned short);
18081 vector unsigned short vec_xor (vector unsigned short, vector bool short);
18082 vector unsigned short vec_xor (vector unsigned short, vector unsigned short);
18083 vector signed char vec_xor (vector bool char, vector signed char);
18084 vector bool char vec_xor (vector bool char, vector bool char);
18085 vector signed char vec_xor (vector signed char, vector bool char);
18086 vector signed char vec_xor (vector signed char, vector signed char);
18087 vector unsigned char vec_xor (vector bool char, vector unsigned char);
18088 vector unsigned char vec_xor (vector unsigned char, vector bool char);
18089 vector unsigned char vec_xor (vector unsigned char, vector unsigned char);
18090 @end smallexample
18092 @node PowerPC AltiVec Built-in Functions Available on ISA 2.06
18093 @subsubsection PowerPC AltiVec Built-in Functions Available on ISA 2.06
18095 The AltiVec built-in functions described in this section are
18096 available on the PowerPC family of processors starting with ISA 2.06
18097 or later.  These are normally enabled by adding @option{-mvsx} to the
18098 command line.
18100 When @option{-mvsx} is used, the following additional vector types are
18101 implemented.
18103 @smallexample
18104 vector unsigned __int128
18105 vector signed __int128
18106 vector unsigned long long int
18107 vector signed long long int
18108 vector double
18109 @end smallexample
18111 The long long types are only implemented for 64-bit code generation.
18113 @smallexample
18115 vector bool long long vec_and (vector bool long long int, vector bool long long);
18117 vector double vec_ctf (vector unsigned long, const int);
18118 vector double vec_ctf (vector signed long, const int);
18120 vector signed long vec_cts (vector double, const int);
18122 vector unsigned long vec_ctu (vector double, const int);
18124 void vec_dst (const unsigned long *, int, const int);
18125 void vec_dst (const long *, int, const int);
18127 void vec_dststt (const unsigned long *, int, const int);
18128 void vec_dststt (const long *, int, const int);
18130 void vec_dstt (const unsigned long *, int, const int);
18131 void vec_dstt (const long *, int, const int);
18133 vector unsigned char vec_lvsl (int, const unsigned long *);
18134 vector unsigned char vec_lvsl (int, const long *);
18136 vector unsigned char vec_lvsr (int, const unsigned long *);
18137 vector unsigned char vec_lvsr (int, const long *);
18139 vector double vec_mul (vector double, vector double);
18140 vector long vec_mul (vector long, vector long);
18141 vector unsigned long vec_mul (vector unsigned long, vector unsigned long);
18143 vector unsigned long long vec_mule (vector unsigned int, vector unsigned int);
18144 vector signed long long vec_mule (vector signed int, vector signed int);
18146 vector unsigned long long vec_mulo (vector unsigned int, vector unsigned int);
18147 vector signed long long vec_mulo (vector signed int, vector signed int);
18149 vector double vec_nabs (vector double);
18151 vector bool long long vec_reve (vector bool long long);
18152 vector signed long long vec_reve (vector signed long long);
18153 vector unsigned long long vec_reve (vector unsigned long long);
18154 vector double vec_sld (vector double, vector double, const int);
18156 vector bool long long int vec_sld (vector bool long long int,
18157                                    vector bool long long int, const int);
18158 vector long long int vec_sld (vector long long int, vector  long long int, const int);
18159 vector unsigned long long int vec_sld (vector unsigned long long int,
18160                                        vector unsigned long long int, const int);
18162 vector long long int vec_sll (vector long long int, vector unsigned char);
18163 vector unsigned long long int vec_sll (vector unsigned long long int,
18164                                        vector unsigned char);
18166 vector signed long long vec_slo (vector signed long long, vector signed char);
18167 vector signed long long vec_slo (vector signed long long, vector unsigned char);
18168 vector unsigned long long vec_slo (vector unsigned long long, vector signed char);
18169 vector unsigned long long vec_slo (vector unsigned long long, vector unsigned char);
18171 vector signed long vec_splat (vector signed long, const int);
18172 vector unsigned long vec_splat (vector unsigned long, const int);
18174 vector long long int vec_srl (vector long long int, vector unsigned char);
18175 vector unsigned long long int vec_srl (vector unsigned long long int,
18176                                        vector unsigned char);
18178 vector long long int vec_sro (vector long long int, vector char);
18179 vector long long int vec_sro (vector long long int, vector unsigned char);
18180 vector unsigned long long int vec_sro (vector unsigned long long int, vector char);
18181 vector unsigned long long int vec_sro (vector unsigned long long int,
18182                                        vector unsigned char);
18184 vector signed __int128 vec_subc (vector signed __int128, vector signed __int128);
18185 vector unsigned __int128 vec_subc (vector unsigned __int128, vector unsigned __int128);
18187 vector signed __int128 vec_sube (vector signed __int128, vector signed __int128,
18188                                  vector signed __int128);
18189 vector unsigned __int128 vec_sube (vector unsigned __int128, vector unsigned __int128,
18190                                    vector unsigned __int128);
18192 vector signed __int128 vec_subec (vector signed __int128, vector signed __int128,
18193                                   vector signed __int128);
18194 vector unsigned __int128 vec_subec (vector unsigned __int128, vector unsigned __int128,
18195                                     vector unsigned __int128);
18197 vector double vec_unpackh (vector float);
18199 vector double vec_unpackl (vector float);
18201 vector double vec_doublee (vector float);
18202 vector double vec_doublee (vector signed int);
18203 vector double vec_doublee (vector unsigned int);
18205 vector double vec_doubleo (vector float);
18206 vector double vec_doubleo (vector signed int);
18207 vector double vec_doubleo (vector unsigned int);
18209 vector double vec_doubleh (vector float);
18210 vector double vec_doubleh (vector signed int);
18211 vector double vec_doubleh (vector unsigned int);
18213 vector double vec_doublel (vector float);
18214 vector double vec_doublel (vector signed int);
18215 vector double vec_doublel (vector unsigned int);
18217 vector float vec_float (vector signed int);
18218 vector float vec_float (vector unsigned int);
18220 vector float vec_float2 (vector signed long long, vector signed long long);
18221 vector float vec_float2 (vector unsigned long long, vector signed long long);
18223 vector float vec_floate (vector double);
18224 vector float vec_floate (vector signed long long);
18225 vector float vec_floate (vector unsigned long long);
18227 vector float vec_floato (vector double);
18228 vector float vec_floato (vector signed long long);
18229 vector float vec_floato (vector unsigned long long);
18231 vector signed long long vec_signed (vector double);
18232 vector signed int vec_signed (vector float);
18234 vector signed int vec_signede (vector double);
18236 vector signed int vec_signedo (vector double);
18238 vector signed char vec_sldw (vector signed char, vector signed char, const int);
18239 vector unsigned char vec_sldw (vector unsigned char, vector unsigned char, const int);
18240 vector signed short vec_sldw (vector signed short, vector signed short, const int);
18241 vector unsigned short vec_sldw (vector unsigned short,
18242                                 vector unsigned short, const int);
18243 vector signed int vec_sldw (vector signed int, vector signed int, const int);
18244 vector unsigned int vec_sldw (vector unsigned int, vector unsigned int, const int);
18245 vector signed long long vec_sldw (vector signed long long,
18246                                   vector signed long long, const int);
18247 vector unsigned long long vec_sldw (vector unsigned long long,
18248                                     vector unsigned long long, const int);
18250 vector signed long long vec_unsigned (vector double);
18251 vector signed int vec_unsigned (vector float);
18253 vector signed int vec_unsignede (vector double);
18255 vector signed int vec_unsignedo (vector double);
18257 vector double vec_abs (vector double);
18258 vector double vec_add (vector double, vector double);
18259 vector double vec_and (vector double, vector double);
18260 vector double vec_and (vector double, vector bool long);
18261 vector double vec_and (vector bool long, vector double);
18262 vector long vec_and (vector long, vector long);
18263 vector long vec_and (vector long, vector bool long);
18264 vector long vec_and (vector bool long, vector long);
18265 vector unsigned long vec_and (vector unsigned long, vector unsigned long);
18266 vector unsigned long vec_and (vector unsigned long, vector bool long);
18267 vector unsigned long vec_and (vector bool long, vector unsigned long);
18268 vector double vec_andc (vector double, vector double);
18269 vector double vec_andc (vector double, vector bool long);
18270 vector double vec_andc (vector bool long, vector double);
18271 vector long vec_andc (vector long, vector long);
18272 vector long vec_andc (vector long, vector bool long);
18273 vector long vec_andc (vector bool long, vector long);
18274 vector unsigned long vec_andc (vector unsigned long, vector unsigned long);
18275 vector unsigned long vec_andc (vector unsigned long, vector bool long);
18276 vector unsigned long vec_andc (vector bool long, vector unsigned long);
18277 vector double vec_ceil (vector double);
18278 vector bool long vec_cmpeq (vector double, vector double);
18279 vector bool long vec_cmpge (vector double, vector double);
18280 vector bool long vec_cmpgt (vector double, vector double);
18281 vector bool long vec_cmple (vector double, vector double);
18282 vector bool long vec_cmplt (vector double, vector double);
18283 vector double vec_cpsgn (vector double, vector double);
18284 vector float vec_div (vector float, vector float);
18285 vector double vec_div (vector double, vector double);
18286 vector long vec_div (vector long, vector long);
18287 vector unsigned long vec_div (vector unsigned long, vector unsigned long);
18288 vector double vec_floor (vector double);
18289 vector __int128 vec_ld (int, const vector __int128 *);
18290 vector unsigned __int128 vec_ld (int, const vector unsigned __int128 *);
18291 vector __int128 vec_ld (int, const __int128 *);
18292 vector unsigned __int128 vec_ld (int, const unsigned __int128 *);
18293 vector double vec_ld (int, const vector double *);
18294 vector double vec_ld (int, const double *);
18295 vector double vec_ldl (int, const vector double *);
18296 vector double vec_ldl (int, const double *);
18297 vector unsigned char vec_lvsl (int, const double *);
18298 vector unsigned char vec_lvsr (int, const double *);
18299 vector double vec_madd (vector double, vector double, vector double);
18300 vector double vec_max (vector double, vector double);
18301 vector signed long vec_mergeh (vector signed long, vector signed long);
18302 vector signed long vec_mergeh (vector signed long, vector bool long);
18303 vector signed long vec_mergeh (vector bool long, vector signed long);
18304 vector unsigned long vec_mergeh (vector unsigned long, vector unsigned long);
18305 vector unsigned long vec_mergeh (vector unsigned long, vector bool long);
18306 vector unsigned long vec_mergeh (vector bool long, vector unsigned long);
18307 vector signed long vec_mergel (vector signed long, vector signed long);
18308 vector signed long vec_mergel (vector signed long, vector bool long);
18309 vector signed long vec_mergel (vector bool long, vector signed long);
18310 vector unsigned long vec_mergel (vector unsigned long, vector unsigned long);
18311 vector unsigned long vec_mergel (vector unsigned long, vector bool long);
18312 vector unsigned long vec_mergel (vector bool long, vector unsigned long);
18313 vector double vec_min (vector double, vector double);
18314 vector float vec_msub (vector float, vector float, vector float);
18315 vector double vec_msub (vector double, vector double, vector double);
18316 vector float vec_nearbyint (vector float);
18317 vector double vec_nearbyint (vector double);
18318 vector float vec_nmadd (vector float, vector float, vector float);
18319 vector double vec_nmadd (vector double, vector double, vector double);
18320 vector double vec_nmsub (vector double, vector double, vector double);
18321 vector double vec_nor (vector double, vector double);
18322 vector long vec_nor (vector long, vector long);
18323 vector long vec_nor (vector long, vector bool long);
18324 vector long vec_nor (vector bool long, vector long);
18325 vector unsigned long vec_nor (vector unsigned long, vector unsigned long);
18326 vector unsigned long vec_nor (vector unsigned long, vector bool long);
18327 vector unsigned long vec_nor (vector bool long, vector unsigned long);
18328 vector double vec_or (vector double, vector double);
18329 vector double vec_or (vector double, vector bool long);
18330 vector double vec_or (vector bool long, vector double);
18331 vector long vec_or (vector long, vector long);
18332 vector long vec_or (vector long, vector bool long);
18333 vector long vec_or (vector bool long, vector long);
18334 vector unsigned long vec_or (vector unsigned long, vector unsigned long);
18335 vector unsigned long vec_or (vector unsigned long, vector bool long);
18336 vector unsigned long vec_or (vector bool long, vector unsigned long);
18337 vector double vec_perm (vector double, vector double, vector unsigned char);
18338 vector long vec_perm (vector long, vector long, vector unsigned char);
18339 vector unsigned long vec_perm (vector unsigned long, vector unsigned long,
18340                                vector unsigned char);
18341 vector bool char vec_permxor (vector bool char, vector bool char,
18342                               vector bool char);
18343 vector unsigned char vec_permxor (vector signed char, vector signed char,
18344                                   vector signed char);
18345 vector unsigned char vec_permxor (vector unsigned char, vector unsigned char,
18346                                   vector unsigned char);
18347 vector double vec_rint (vector double);
18348 vector double vec_recip (vector double, vector double);
18349 vector double vec_rsqrt (vector double);
18350 vector double vec_rsqrte (vector double);
18351 vector double vec_sel (vector double, vector double, vector bool long);
18352 vector double vec_sel (vector double, vector double, vector unsigned long);
18353 vector long vec_sel (vector long, vector long, vector long);
18354 vector long vec_sel (vector long, vector long, vector unsigned long);
18355 vector long vec_sel (vector long, vector long, vector bool long);
18356 vector unsigned long vec_sel (vector unsigned long, vector unsigned long,
18357                               vector long);
18358 vector unsigned long vec_sel (vector unsigned long, vector unsigned long,
18359                               vector unsigned long);
18360 vector unsigned long vec_sel (vector unsigned long, vector unsigned long,
18361                               vector bool long);
18362 vector double vec_splats (double);
18363 vector signed long vec_splats (signed long);
18364 vector unsigned long vec_splats (unsigned long);
18365 vector float vec_sqrt (vector float);
18366 vector double vec_sqrt (vector double);
18367 void vec_st (vector double, int, vector double *);
18368 void vec_st (vector double, int, double *);
18369 vector double vec_sub (vector double, vector double);
18370 vector double vec_trunc (vector double);
18371 vector double vec_xl (int, vector double *);
18372 vector double vec_xl (int, double *);
18373 vector long long vec_xl (int, vector long long *);
18374 vector long long vec_xl (int, long long *);
18375 vector unsigned long long vec_xl (int, vector unsigned long long *);
18376 vector unsigned long long vec_xl (int, unsigned long long *);
18377 vector float vec_xl (int, vector float *);
18378 vector float vec_xl (int, float *);
18379 vector int vec_xl (int, vector int *);
18380 vector int vec_xl (int, int *);
18381 vector unsigned int vec_xl (int, vector unsigned int *);
18382 vector unsigned int vec_xl (int, unsigned int *);
18383 vector double vec_xor (vector double, vector double);
18384 vector double vec_xor (vector double, vector bool long);
18385 vector double vec_xor (vector bool long, vector double);
18386 vector long vec_xor (vector long, vector long);
18387 vector long vec_xor (vector long, vector bool long);
18388 vector long vec_xor (vector bool long, vector long);
18389 vector unsigned long vec_xor (vector unsigned long, vector unsigned long);
18390 vector unsigned long vec_xor (vector unsigned long, vector bool long);
18391 vector unsigned long vec_xor (vector bool long, vector unsigned long);
18392 void vec_xst (vector double, int, vector double *);
18393 void vec_xst (vector double, int, double *);
18394 void vec_xst (vector long long, int, vector long long *);
18395 void vec_xst (vector long long, int, long long *);
18396 void vec_xst (vector unsigned long long, int, vector unsigned long long *);
18397 void vec_xst (vector unsigned long long, int, unsigned long long *);
18398 void vec_xst (vector float, int, vector float *);
18399 void vec_xst (vector float, int, float *);
18400 void vec_xst (vector int, int, vector int *);
18401 void vec_xst (vector int, int, int *);
18402 void vec_xst (vector unsigned int, int, vector unsigned int *);
18403 void vec_xst (vector unsigned int, int, unsigned int *);
18404 int vec_all_eq (vector double, vector double);
18405 int vec_all_ge (vector double, vector double);
18406 int vec_all_gt (vector double, vector double);
18407 int vec_all_le (vector double, vector double);
18408 int vec_all_lt (vector double, vector double);
18409 int vec_all_nan (vector double);
18410 int vec_all_ne (vector double, vector double);
18411 int vec_all_nge (vector double, vector double);
18412 int vec_all_ngt (vector double, vector double);
18413 int vec_all_nle (vector double, vector double);
18414 int vec_all_nlt (vector double, vector double);
18415 int vec_all_numeric (vector double);
18416 int vec_any_eq (vector double, vector double);
18417 int vec_any_ge (vector double, vector double);
18418 int vec_any_gt (vector double, vector double);
18419 int vec_any_le (vector double, vector double);
18420 int vec_any_lt (vector double, vector double);
18421 int vec_any_nan (vector double);
18422 int vec_any_ne (vector double, vector double);
18423 int vec_any_nge (vector double, vector double);
18424 int vec_any_ngt (vector double, vector double);
18425 int vec_any_nle (vector double, vector double);
18426 int vec_any_nlt (vector double, vector double);
18427 int vec_any_numeric (vector double);
18429 vector double vec_vsx_ld (int, const vector double *);
18430 vector double vec_vsx_ld (int, const double *);
18431 vector float vec_vsx_ld (int, const vector float *);
18432 vector float vec_vsx_ld (int, const float *);
18433 vector bool int vec_vsx_ld (int, const vector bool int *);
18434 vector signed int vec_vsx_ld (int, const vector signed int *);
18435 vector signed int vec_vsx_ld (int, const int *);
18436 vector signed int vec_vsx_ld (int, const long *);
18437 vector unsigned int vec_vsx_ld (int, const vector unsigned int *);
18438 vector unsigned int vec_vsx_ld (int, const unsigned int *);
18439 vector unsigned int vec_vsx_ld (int, const unsigned long *);
18440 vector bool short vec_vsx_ld (int, const vector bool short *);
18441 vector pixel vec_vsx_ld (int, const vector pixel *);
18442 vector signed short vec_vsx_ld (int, const vector signed short *);
18443 vector signed short vec_vsx_ld (int, const short *);
18444 vector unsigned short vec_vsx_ld (int, const vector unsigned short *);
18445 vector unsigned short vec_vsx_ld (int, const unsigned short *);
18446 vector bool char vec_vsx_ld (int, const vector bool char *);
18447 vector signed char vec_vsx_ld (int, const vector signed char *);
18448 vector signed char vec_vsx_ld (int, const signed char *);
18449 vector unsigned char vec_vsx_ld (int, const vector unsigned char *);
18450 vector unsigned char vec_vsx_ld (int, const unsigned char *);
18452 void vec_vsx_st (vector double, int, vector double *);
18453 void vec_vsx_st (vector double, int, double *);
18454 void vec_vsx_st (vector float, int, vector float *);
18455 void vec_vsx_st (vector float, int, float *);
18456 void vec_vsx_st (vector signed int, int, vector signed int *);
18457 void vec_vsx_st (vector signed int, int, int *);
18458 void vec_vsx_st (vector unsigned int, int, vector unsigned int *);
18459 void vec_vsx_st (vector unsigned int, int, unsigned int *);
18460 void vec_vsx_st (vector bool int, int, vector bool int *);
18461 void vec_vsx_st (vector bool int, int, unsigned int *);
18462 void vec_vsx_st (vector bool int, int, int *);
18463 void vec_vsx_st (vector signed short, int, vector signed short *);
18464 void vec_vsx_st (vector signed short, int, short *);
18465 void vec_vsx_st (vector unsigned short, int, vector unsigned short *);
18466 void vec_vsx_st (vector unsigned short, int, unsigned short *);
18467 void vec_vsx_st (vector bool short, int, vector bool short *);
18468 void vec_vsx_st (vector bool short, int, unsigned short *);
18469 void vec_vsx_st (vector pixel, int, vector pixel *);
18470 void vec_vsx_st (vector pixel, int, unsigned short *);
18471 void vec_vsx_st (vector pixel, int, short *);
18472 void vec_vsx_st (vector bool short, int, short *);
18473 void vec_vsx_st (vector signed char, int, vector signed char *);
18474 void vec_vsx_st (vector signed char, int, signed char *);
18475 void vec_vsx_st (vector unsigned char, int, vector unsigned char *);
18476 void vec_vsx_st (vector unsigned char, int, unsigned char *);
18477 void vec_vsx_st (vector bool char, int, vector bool char *);
18478 void vec_vsx_st (vector bool char, int, unsigned char *);
18479 void vec_vsx_st (vector bool char, int, signed char *);
18481 vector double vec_xxpermdi (vector double, vector double, const int);
18482 vector float vec_xxpermdi (vector float, vector float, const int);
18483 vector long long vec_xxpermdi (vector long long, vector long long, const int);
18484 vector unsigned long long vec_xxpermdi (vector unsigned long long,
18485                                         vector unsigned long long, const int);
18486 vector int vec_xxpermdi (vector int, vector int, const int);
18487 vector unsigned int vec_xxpermdi (vector unsigned int,
18488                                   vector unsigned int, const int);
18489 vector short vec_xxpermdi (vector short, vector short, const int);
18490 vector unsigned short vec_xxpermdi (vector unsigned short,
18491                                     vector unsigned short, const int);
18492 vector signed char vec_xxpermdi (vector signed char, vector signed char,
18493                                  const int);
18494 vector unsigned char vec_xxpermdi (vector unsigned char,
18495                                    vector unsigned char, const int);
18497 vector double vec_xxsldi (vector double, vector double, int);
18498 vector float vec_xxsldi (vector float, vector float, int);
18499 vector long long vec_xxsldi (vector long long, vector long long, int);
18500 vector unsigned long long vec_xxsldi (vector unsigned long long,
18501                                       vector unsigned long long, int);
18502 vector int vec_xxsldi (vector int, vector int, int);
18503 vector unsigned int vec_xxsldi (vector unsigned int, vector unsigned int, int);
18504 vector short vec_xxsldi (vector short, vector short, int);
18505 vector unsigned short vec_xxsldi (vector unsigned short,
18506                                   vector unsigned short, int);
18507 vector signed char vec_xxsldi (vector signed char, vector signed char, int);
18508 vector unsigned char vec_xxsldi (vector unsigned char,
18509                                  vector unsigned char, int);
18510 @end smallexample
18512 Note that the @samp{vec_ld} and @samp{vec_st} built-in functions always
18513 generate the AltiVec @samp{LVX} and @samp{STVX} instructions even
18514 if the VSX instruction set is available.  The @samp{vec_vsx_ld} and
18515 @samp{vec_vsx_st} built-in functions always generate the VSX @samp{LXVD2X},
18516 @samp{LXVW4X}, @samp{STXVD2X}, and @samp{STXVW4X} instructions.
18518 @node PowerPC AltiVec Built-in Functions Available on ISA 2.07
18519 @subsubsection PowerPC AltiVec Built-in Functions Available on ISA 2.07
18521 If the ISA 2.07 additions to the vector/scalar (power8-vector)
18522 instruction set are available, the following additional functions are
18523 available for both 32-bit and 64-bit targets.  For 64-bit targets, you
18524 can use @var{vector long} instead of @var{vector long long},
18525 @var{vector bool long} instead of @var{vector bool long long}, and
18526 @var{vector unsigned long} instead of @var{vector unsigned long long}.
18528 @smallexample
18529 vector signed char vec_neg (vector signed char);
18530 vector signed short vec_neg (vector signed short);
18531 vector signed int vec_neg (vector signed int);
18532 vector signed long long vec_neg (vector signed long long);
18533 vector float  char vec_neg (vector float);
18534 vector double vec_neg (vector double);
18536 vector signed int vec_signed2 (vector double, vector double);
18538 vector signed int vec_unsigned2 (vector double, vector double);
18540 vector long long vec_abs (vector long long);
18542 vector long long vec_add (vector long long, vector long long);
18543 vector unsigned long long vec_add (vector unsigned long long,
18544                                    vector unsigned long long);
18546 int vec_all_eq (vector long long, vector long long);
18547 int vec_all_eq (vector unsigned long long, vector unsigned long long);
18548 int vec_all_ge (vector long long, vector long long);
18549 int vec_all_ge (vector unsigned long long, vector unsigned long long);
18550 int vec_all_gt (vector long long, vector long long);
18551 int vec_all_gt (vector unsigned long long, vector unsigned long long);
18552 int vec_all_le (vector long long, vector long long);
18553 int vec_all_le (vector unsigned long long, vector unsigned long long);
18554 int vec_all_lt (vector long long, vector long long);
18555 int vec_all_lt (vector unsigned long long, vector unsigned long long);
18556 int vec_all_ne (vector long long, vector long long);
18557 int vec_all_ne (vector unsigned long long, vector unsigned long long);
18559 int vec_any_eq (vector long long, vector long long);
18560 int vec_any_eq (vector unsigned long long, vector unsigned long long);
18561 int vec_any_ge (vector long long, vector long long);
18562 int vec_any_ge (vector unsigned long long, vector unsigned long long);
18563 int vec_any_gt (vector long long, vector long long);
18564 int vec_any_gt (vector unsigned long long, vector unsigned long long);
18565 int vec_any_le (vector long long, vector long long);
18566 int vec_any_le (vector unsigned long long, vector unsigned long long);
18567 int vec_any_lt (vector long long, vector long long);
18568 int vec_any_lt (vector unsigned long long, vector unsigned long long);
18569 int vec_any_ne (vector long long, vector long long);
18570 int vec_any_ne (vector unsigned long long, vector unsigned long long);
18572 vector bool long long vec_cmpeq (vector bool long long, vector bool long long);
18574 vector long long vec_eqv (vector long long, vector long long);
18575 vector long long vec_eqv (vector bool long long, vector long long);
18576 vector long long vec_eqv (vector long long, vector bool long long);
18577 vector unsigned long long vec_eqv (vector unsigned long long, vector unsigned long long);
18578 vector unsigned long long vec_eqv (vector bool long long, vector unsigned long long);
18579 vector unsigned long long vec_eqv (vector unsigned long long,
18580                                    vector bool long long);
18581 vector int vec_eqv (vector int, vector int);
18582 vector int vec_eqv (vector bool int, vector int);
18583 vector int vec_eqv (vector int, vector bool int);
18584 vector unsigned int vec_eqv (vector unsigned int, vector unsigned int);
18585 vector unsigned int vec_eqv (vector bool unsigned int, vector unsigned int);
18586 vector unsigned int vec_eqv (vector unsigned int, vector bool unsigned int);
18587 vector short vec_eqv (vector short, vector short);
18588 vector short vec_eqv (vector bool short, vector short);
18589 vector short vec_eqv (vector short, vector bool short);
18590 vector unsigned short vec_eqv (vector unsigned short, vector unsigned short);
18591 vector unsigned short vec_eqv (vector bool unsigned short, vector unsigned short);
18592 vector unsigned short vec_eqv (vector unsigned short, vector bool unsigned short);
18593 vector signed char vec_eqv (vector signed char, vector signed char);
18594 vector signed char vec_eqv (vector bool signed char, vector signed char);
18595 vector signed char vec_eqv (vector signed char, vector bool signed char);
18596 vector unsigned char vec_eqv (vector unsigned char, vector unsigned char);
18597 vector unsigned char vec_eqv (vector bool unsigned char, vector unsigned char);
18598 vector unsigned char vec_eqv (vector unsigned char, vector bool unsigned char);
18600 vector long long vec_max (vector long long, vector long long);
18601 vector unsigned long long vec_max (vector unsigned long long,
18602                                    vector unsigned long long);
18604 vector signed int vec_mergee (vector signed int, vector signed int);
18605 vector unsigned int vec_mergee (vector unsigned int, vector unsigned int);
18606 vector bool int vec_mergee (vector bool int, vector bool int);
18608 vector signed int vec_mergeo (vector signed int, vector signed int);
18609 vector unsigned int vec_mergeo (vector unsigned int, vector unsigned int);
18610 vector bool int vec_mergeo (vector bool int, vector bool int);
18612 vector long long vec_min (vector long long, vector long long);
18613 vector unsigned long long vec_min (vector unsigned long long,
18614                                    vector unsigned long long);
18616 vector signed long long vec_nabs (vector signed long long);
18618 vector long long vec_nand (vector long long, vector long long);
18619 vector long long vec_nand (vector bool long long, vector long long);
18620 vector long long vec_nand (vector long long, vector bool long long);
18621 vector unsigned long long vec_nand (vector unsigned long long,
18622                                     vector unsigned long long);
18623 vector unsigned long long vec_nand (vector bool long long, vector unsigned long long);
18624 vector unsigned long long vec_nand (vector unsigned long long, vector bool long long);
18625 vector int vec_nand (vector int, vector int);
18626 vector int vec_nand (vector bool int, vector int);
18627 vector int vec_nand (vector int, vector bool int);
18628 vector unsigned int vec_nand (vector unsigned int, vector unsigned int);
18629 vector unsigned int vec_nand (vector bool unsigned int, vector unsigned int);
18630 vector unsigned int vec_nand (vector unsigned int, vector bool unsigned int);
18631 vector short vec_nand (vector short, vector short);
18632 vector short vec_nand (vector bool short, vector short);
18633 vector short vec_nand (vector short, vector bool short);
18634 vector unsigned short vec_nand (vector unsigned short, vector unsigned short);
18635 vector unsigned short vec_nand (vector bool unsigned short, vector unsigned short);
18636 vector unsigned short vec_nand (vector unsigned short, vector bool unsigned short);
18637 vector signed char vec_nand (vector signed char, vector signed char);
18638 vector signed char vec_nand (vector bool signed char, vector signed char);
18639 vector signed char vec_nand (vector signed char, vector bool signed char);
18640 vector unsigned char vec_nand (vector unsigned char, vector unsigned char);
18641 vector unsigned char vec_nand (vector bool unsigned char, vector unsigned char);
18642 vector unsigned char vec_nand (vector unsigned char, vector bool unsigned char);
18644 vector long long vec_orc (vector long long, vector long long);
18645 vector long long vec_orc (vector bool long long, vector long long);
18646 vector long long vec_orc (vector long long, vector bool long long);
18647 vector unsigned long long vec_orc (vector unsigned long long,
18648                                    vector unsigned long long);
18649 vector unsigned long long vec_orc (vector bool long long, vector unsigned long long);
18650 vector unsigned long long vec_orc (vector unsigned long long, vector bool long long);
18651 vector int vec_orc (vector int, vector int);
18652 vector int vec_orc (vector bool int, vector int);
18653 vector int vec_orc (vector int, vector bool int);
18654 vector unsigned int vec_orc (vector unsigned int, vector unsigned int);
18655 vector unsigned int vec_orc (vector bool unsigned int, vector unsigned int);
18656 vector unsigned int vec_orc (vector unsigned int, vector bool unsigned int);
18657 vector short vec_orc (vector short, vector short);
18658 vector short vec_orc (vector bool short, vector short);
18659 vector short vec_orc (vector short, vector bool short);
18660 vector unsigned short vec_orc (vector unsigned short, vector unsigned short);
18661 vector unsigned short vec_orc (vector bool unsigned short, vector unsigned short);
18662 vector unsigned short vec_orc (vector unsigned short, vector bool unsigned short);
18663 vector signed char vec_orc (vector signed char, vector signed char);
18664 vector signed char vec_orc (vector bool signed char, vector signed char);
18665 vector signed char vec_orc (vector signed char, vector bool signed char);
18666 vector unsigned char vec_orc (vector unsigned char, vector unsigned char);
18667 vector unsigned char vec_orc (vector bool unsigned char, vector unsigned char);
18668 vector unsigned char vec_orc (vector unsigned char, vector bool unsigned char);
18670 vector int vec_pack (vector long long, vector long long);
18671 vector unsigned int vec_pack (vector unsigned long long, vector unsigned long long);
18672 vector bool int vec_pack (vector bool long long, vector bool long long);
18673 vector float vec_pack (vector double, vector double);
18675 vector int vec_packs (vector long long, vector long long);
18676 vector unsigned int vec_packs (vector unsigned long long, vector unsigned long long);
18678 vector unsigned char vec_packsu (vector signed short, vector signed short)
18679 vector unsigned char vec_packsu (vector unsigned short, vector unsigned short)
18680 vector unsigned short int vec_packsu (vector signed int, vector signed int);
18681 vector unsigned short int vec_packsu (vector unsigned int, vector unsigned int);
18682 vector unsigned int vec_packsu (vector long long, vector long long);
18683 vector unsigned int vec_packsu (vector unsigned long long, vector unsigned long long);
18684 vector unsigned int vec_packsu (vector signed long long, vector signed long long);
18686 vector unsigned char vec_popcnt (vector signed char);
18687 vector unsigned char vec_popcnt (vector unsigned char);
18688 vector unsigned short vec_popcnt (vector signed short);
18689 vector unsigned short vec_popcnt (vector unsigned short);
18690 vector unsigned int vec_popcnt (vector signed int);
18691 vector unsigned int vec_popcnt (vector unsigned int);
18692 vector unsigned long long vec_popcnt (vector signed long long);
18693 vector unsigned long long vec_popcnt (vector unsigned long long);
18695 vector long long vec_rl (vector long long, vector unsigned long long);
18696 vector long long vec_rl (vector unsigned long long, vector unsigned long long);
18698 vector long long vec_sl (vector long long, vector unsigned long long);
18699 vector long long vec_sl (vector unsigned long long, vector unsigned long long);
18701 vector long long vec_sr (vector long long, vector unsigned long long);
18702 vector unsigned long long char vec_sr (vector unsigned long long,
18703                                        vector unsigned long long);
18705 vector long long vec_sra (vector long long, vector unsigned long long);
18706 vector unsigned long long vec_sra (vector unsigned long long,
18707                                    vector unsigned long long);
18709 vector long long vec_sub (vector long long, vector long long);
18710 vector unsigned long long vec_sub (vector unsigned long long,
18711                                    vector unsigned long long);
18713 vector long long vec_unpackh (vector int);
18714 vector unsigned long long vec_unpackh (vector unsigned int);
18716 vector long long vec_unpackl (vector int);
18717 vector unsigned long long vec_unpackl (vector unsigned int);
18719 vector long long vec_vaddudm (vector long long, vector long long);
18720 vector long long vec_vaddudm (vector bool long long, vector long long);
18721 vector long long vec_vaddudm (vector long long, vector bool long long);
18722 vector unsigned long long vec_vaddudm (vector unsigned long long,
18723                                        vector unsigned long long);
18724 vector unsigned long long vec_vaddudm (vector bool unsigned long long,
18725                                        vector unsigned long long);
18726 vector unsigned long long vec_vaddudm (vector unsigned long long,
18727                                        vector bool unsigned long long);
18729 vector long long vec_vbpermq (vector signed char, vector signed char);
18730 vector long long vec_vbpermq (vector unsigned char, vector unsigned char);
18732 vector unsigned char vec_bperm (vector unsigned char, vector unsigned char);
18733 vector unsigned char vec_bperm (vector unsigned long long, vector unsigned char);
18734 vector unsigned long long vec_bperm (vector unsigned __int128, vector unsigned char);
18736 vector long long vec_cntlz (vector long long);
18737 vector unsigned long long vec_cntlz (vector unsigned long long);
18738 vector int vec_cntlz (vector int);
18739 vector unsigned int vec_cntlz (vector int);
18740 vector short vec_cntlz (vector short);
18741 vector unsigned short vec_cntlz (vector unsigned short);
18742 vector signed char vec_cntlz (vector signed char);
18743 vector unsigned char vec_cntlz (vector unsigned char);
18745 vector long long vec_vclz (vector long long);
18746 vector unsigned long long vec_vclz (vector unsigned long long);
18747 vector int vec_vclz (vector int);
18748 vector unsigned int vec_vclz (vector int);
18749 vector short vec_vclz (vector short);
18750 vector unsigned short vec_vclz (vector unsigned short);
18751 vector signed char vec_vclz (vector signed char);
18752 vector unsigned char vec_vclz (vector unsigned char);
18754 vector signed char vec_vclzb (vector signed char);
18755 vector unsigned char vec_vclzb (vector unsigned char);
18757 vector long long vec_vclzd (vector long long);
18758 vector unsigned long long vec_vclzd (vector unsigned long long);
18760 vector short vec_vclzh (vector short);
18761 vector unsigned short vec_vclzh (vector unsigned short);
18763 vector int vec_vclzw (vector int);
18764 vector unsigned int vec_vclzw (vector int);
18766 vector signed char vec_vgbbd (vector signed char);
18767 vector unsigned char vec_vgbbd (vector unsigned char);
18769 vector long long vec_vmaxsd (vector long long, vector long long);
18771 vector unsigned long long vec_vmaxud (vector unsigned long long,
18772                                       unsigned vector long long);
18774 vector long long vec_vminsd (vector long long, vector long long);
18776 vector unsigned long long vec_vminud (vector long long, vector long long);
18778 vector int vec_vpksdss (vector long long, vector long long);
18779 vector unsigned int vec_vpksdss (vector long long, vector long long);
18781 vector unsigned int vec_vpkudus (vector unsigned long long,
18782                                  vector unsigned long long);
18784 vector int vec_vpkudum (vector long long, vector long long);
18785 vector unsigned int vec_vpkudum (vector unsigned long long,
18786                                  vector unsigned long long);
18787 vector bool int vec_vpkudum (vector bool long long, vector bool long long);
18789 vector long long vec_vpopcnt (vector long long);
18790 vector unsigned long long vec_vpopcnt (vector unsigned long long);
18791 vector int vec_vpopcnt (vector int);
18792 vector unsigned int vec_vpopcnt (vector int);
18793 vector short vec_vpopcnt (vector short);
18794 vector unsigned short vec_vpopcnt (vector unsigned short);
18795 vector signed char vec_vpopcnt (vector signed char);
18796 vector unsigned char vec_vpopcnt (vector unsigned char);
18798 vector signed char vec_vpopcntb (vector signed char);
18799 vector unsigned char vec_vpopcntb (vector unsigned char);
18801 vector long long vec_vpopcntd (vector long long);
18802 vector unsigned long long vec_vpopcntd (vector unsigned long long);
18804 vector short vec_vpopcnth (vector short);
18805 vector unsigned short vec_vpopcnth (vector unsigned short);
18807 vector int vec_vpopcntw (vector int);
18808 vector unsigned int vec_vpopcntw (vector int);
18810 vector long long vec_vrld (vector long long, vector unsigned long long);
18811 vector unsigned long long vec_vrld (vector unsigned long long,
18812                                     vector unsigned long long);
18814 vector long long vec_vsld (vector long long, vector unsigned long long);
18815 vector long long vec_vsld (vector unsigned long long,
18816                            vector unsigned long long);
18818 vector long long vec_vsrad (vector long long, vector unsigned long long);
18819 vector unsigned long long vec_vsrad (vector unsigned long long,
18820                                      vector unsigned long long);
18822 vector long long vec_vsrd (vector long long, vector unsigned long long);
18823 vector unsigned long long char vec_vsrd (vector unsigned long long,
18824                                          vector unsigned long long);
18826 vector long long vec_vsubudm (vector long long, vector long long);
18827 vector long long vec_vsubudm (vector bool long long, vector long long);
18828 vector long long vec_vsubudm (vector long long, vector bool long long);
18829 vector unsigned long long vec_vsubudm (vector unsigned long long,
18830                                        vector unsigned long long);
18831 vector unsigned long long vec_vsubudm (vector bool long long,
18832                                        vector unsigned long long);
18833 vector unsigned long long vec_vsubudm (vector unsigned long long,
18834                                        vector bool long long);
18836 vector long long vec_vupkhsw (vector int);
18837 vector unsigned long long vec_vupkhsw (vector unsigned int);
18839 vector long long vec_vupklsw (vector int);
18840 vector unsigned long long vec_vupklsw (vector int);
18841 @end smallexample
18843 If the ISA 2.07 additions to the vector/scalar (power8-vector)
18844 instruction set are available, the following additional functions are
18845 available for 64-bit targets.  New vector types
18846 (@var{vector __int128} and @var{vector __uint128}) are available
18847 to hold the @var{__int128} and @var{__uint128} types to use these
18848 builtins.
18850 The normal vector extract, and set operations work on
18851 @var{vector __int128} and @var{vector __uint128} types,
18852 but the index value must be 0.
18854 @smallexample
18855 vector __int128 vec_vaddcuq (vector __int128, vector __int128);
18856 vector __uint128 vec_vaddcuq (vector __uint128, vector __uint128);
18858 vector __int128 vec_vadduqm (vector __int128, vector __int128);
18859 vector __uint128 vec_vadduqm (vector __uint128, vector __uint128);
18861 vector __int128 vec_vaddecuq (vector __int128, vector __int128,
18862                                 vector __int128);
18863 vector __uint128 vec_vaddecuq (vector __uint128, vector __uint128,
18864                                  vector __uint128);
18866 vector __int128 vec_vaddeuqm (vector __int128, vector __int128,
18867                                 vector __int128);
18868 vector __uint128 vec_vaddeuqm (vector __uint128, vector __uint128,
18869                                  vector __uint128);
18871 vector __int128 vec_vsubecuq (vector __int128, vector __int128,
18872                                 vector __int128);
18873 vector __uint128 vec_vsubecuq (vector __uint128, vector __uint128,
18874                                  vector __uint128);
18876 vector __int128 vec_vsubeuqm (vector __int128, vector __int128,
18877                                 vector __int128);
18878 vector __uint128 vec_vsubeuqm (vector __uint128, vector __uint128,
18879                                  vector __uint128);
18881 vector __int128 vec_vsubcuq (vector __int128, vector __int128);
18882 vector __uint128 vec_vsubcuq (vector __uint128, vector __uint128);
18884 __int128 vec_vsubuqm (__int128, __int128);
18885 __uint128 vec_vsubuqm (__uint128, __uint128);
18887 vector __int128 __builtin_bcdadd (vector __int128, vector __int128, const int);
18888 int __builtin_bcdadd_lt (vector __int128, vector __int128, const int);
18889 int __builtin_bcdadd_eq (vector __int128, vector __int128, const int);
18890 int __builtin_bcdadd_gt (vector __int128, vector __int128, const int);
18891 int __builtin_bcdadd_ov (vector __int128, vector __int128, const int);
18892 vector __int128 __builtin_bcdsub (vector __int128, vector __int128, const int);
18893 int __builtin_bcdsub_lt (vector __int128, vector __int128, const int);
18894 int __builtin_bcdsub_eq (vector __int128, vector __int128, const int);
18895 int __builtin_bcdsub_gt (vector __int128, vector __int128, const int);
18896 int __builtin_bcdsub_ov (vector __int128, vector __int128, const int);
18897 @end smallexample
18899 @node PowerPC AltiVec Built-in Functions Available on ISA 3.0
18900 @subsubsection PowerPC AltiVec Built-in Functions Available on ISA 3.0
18902 The following additional built-in functions are also available for the
18903 PowerPC family of processors, starting with ISA 3.0
18904 (@option{-mcpu=power9}) or later:
18905 @smallexample
18906 unsigned int scalar_extract_exp (double source);
18907 unsigned long long int scalar_extract_exp (__ieee128 source);
18909 unsigned long long int scalar_extract_sig (double source);
18910 unsigned __int128 scalar_extract_sig (__ieee128 source);
18912 double scalar_insert_exp (unsigned long long int significand,
18913                           unsigned long long int exponent);
18914 double scalar_insert_exp (double significand, unsigned long long int exponent);
18916 ieee_128 scalar_insert_exp (unsigned __int128 significand,
18917                             unsigned long long int exponent);
18918 ieee_128 scalar_insert_exp (ieee_128 significand, unsigned long long int exponent);
18920 int scalar_cmp_exp_gt (double arg1, double arg2);
18921 int scalar_cmp_exp_lt (double arg1, double arg2);
18922 int scalar_cmp_exp_eq (double arg1, double arg2);
18923 int scalar_cmp_exp_unordered (double arg1, double arg2);
18925 bool scalar_test_data_class (float source, const int condition);
18926 bool scalar_test_data_class (double source, const int condition);
18927 bool scalar_test_data_class (__ieee128 source, const int condition);
18929 bool scalar_test_neg (float source);
18930 bool scalar_test_neg (double source);
18931 bool scalar_test_neg (__ieee128 source);
18932 @end smallexample
18934 The @code{scalar_extract_exp} and @code{scalar_extract_sig}
18935 functions require a 64-bit environment supporting ISA 3.0 or later.
18936 The @code{scalar_extract_exp} and @code{scalar_extract_sig} built-in
18937 functions return the significand and the biased exponent value
18938 respectively of their @code{source} arguments.
18939 When supplied with a 64-bit @code{source} argument, the
18940 result returned by @code{scalar_extract_sig} has
18941 the @code{0x0010000000000000} bit set if the
18942 function's @code{source} argument is in normalized form.
18943 Otherwise, this bit is set to 0.
18944 When supplied with a 128-bit @code{source} argument, the
18945 @code{0x00010000000000000000000000000000} bit of the result is
18946 treated similarly.
18947 Note that the sign of the significand is not represented in the result
18948 returned from the @code{scalar_extract_sig} function.  Use the
18949 @code{scalar_test_neg} function to test the sign of its @code{double}
18950 argument.
18952 The @code{scalar_insert_exp}
18953 functions require a 64-bit environment supporting ISA 3.0 or later.
18954 When supplied with a 64-bit first argument, the
18955 @code{scalar_insert_exp} built-in function returns a double-precision
18956 floating point value that is constructed by assembling the values of its
18957 @code{significand} and @code{exponent} arguments.  The sign of the
18958 result is copied from the most significant bit of the
18959 @code{significand} argument.  The significand and exponent components
18960 of the result are composed of the least significant 11 bits of the
18961 @code{exponent} argument and the least significant 52 bits of the
18962 @code{significand} argument respectively.
18964 When supplied with a 128-bit first argument, the
18965 @code{scalar_insert_exp} built-in function returns a quad-precision
18966 ieee floating point value.  The sign bit of the result is copied from
18967 the most significant bit of the @code{significand} argument.
18968 The significand and exponent components of the result are composed of
18969 the least significant 15 bits of the @code{exponent} argument and the
18970 least significant 112 bits of the @code{significand} argument respectively.
18972 The @code{scalar_cmp_exp_gt}, @code{scalar_cmp_exp_lt},
18973 @code{scalar_cmp_exp_eq}, and @code{scalar_cmp_exp_unordered} built-in
18974 functions return a non-zero value if @code{arg1} is greater than, less
18975 than, equal to, or not comparable to @code{arg2} respectively.  The
18976 arguments are not comparable if one or the other equals NaN (not a
18977 number). 
18979 The @code{scalar_test_data_class} built-in function returns 1
18980 if any of the condition tests enabled by the value of the
18981 @code{condition} variable are true, and 0 otherwise.  The
18982 @code{condition} argument must be a compile-time constant integer with
18983 value not exceeding 127.  The
18984 @code{condition} argument is encoded as a bitmask with each bit
18985 enabling the testing of a different condition, as characterized by the
18986 following:
18987 @smallexample
18988 0x40    Test for NaN
18989 0x20    Test for +Infinity
18990 0x10    Test for -Infinity
18991 0x08    Test for +Zero
18992 0x04    Test for -Zero
18993 0x02    Test for +Denormal
18994 0x01    Test for -Denormal
18995 @end smallexample
18997 The @code{scalar_test_neg} built-in function returns 1 if its
18998 @code{source} argument holds a negative value, 0 otherwise.
19000 The following built-in functions are also available for the PowerPC family
19001 of processors, starting with ISA 3.0 or later
19002 (@option{-mcpu=power9}).  These string functions are described
19003 separately in order to group the descriptions closer to the function
19004 prototypes:
19005 @smallexample
19006 int vec_all_nez (vector signed char, vector signed char);
19007 int vec_all_nez (vector unsigned char, vector unsigned char);
19008 int vec_all_nez (vector signed short, vector signed short);
19009 int vec_all_nez (vector unsigned short, vector unsigned short);
19010 int vec_all_nez (vector signed int, vector signed int);
19011 int vec_all_nez (vector unsigned int, vector unsigned int);
19013 int vec_any_eqz (vector signed char, vector signed char);
19014 int vec_any_eqz (vector unsigned char, vector unsigned char);
19015 int vec_any_eqz (vector signed short, vector signed short);
19016 int vec_any_eqz (vector unsigned short, vector unsigned short);
19017 int vec_any_eqz (vector signed int, vector signed int);
19018 int vec_any_eqz (vector unsigned int, vector unsigned int);
19020 vector bool char vec_cmpnez (vector signed char arg1, vector signed char arg2);
19021 vector bool char vec_cmpnez (vector unsigned char arg1, vector unsigned char arg2);
19022 vector bool short vec_cmpnez (vector signed short arg1, vector signed short arg2);
19023 vector bool short vec_cmpnez (vector unsigned short arg1, vector unsigned short arg2);
19024 vector bool int vec_cmpnez (vector signed int arg1, vector signed int arg2);
19025 vector bool int vec_cmpnez (vector unsigned int, vector unsigned int);
19027 vector signed char vec_cnttz (vector signed char);
19028 vector unsigned char vec_cnttz (vector unsigned char);
19029 vector signed short vec_cnttz (vector signed short);
19030 vector unsigned short vec_cnttz (vector unsigned short);
19031 vector signed int vec_cnttz (vector signed int);
19032 vector unsigned int vec_cnttz (vector unsigned int);
19033 vector signed long long vec_cnttz (vector signed long long);
19034 vector unsigned long long vec_cnttz (vector unsigned long long);
19036 signed int vec_cntlz_lsbb (vector signed char);
19037 signed int vec_cntlz_lsbb (vector unsigned char);
19039 signed int vec_cnttz_lsbb (vector signed char);
19040 signed int vec_cnttz_lsbb (vector unsigned char);
19042 unsigned int vec_first_match_index (vector signed char, vector signed char);
19043 unsigned int vec_first_match_index (vector unsigned char, vector unsigned char);
19044 unsigned int vec_first_match_index (vector signed int, vector signed int);
19045 unsigned int vec_first_match_index (vector unsigned int, vector unsigned int);
19046 unsigned int vec_first_match_index (vector signed short, vector signed short);
19047 unsigned int vec_first_match_index (vector unsigned short, vector unsigned short);
19048 unsigned int vec_first_match_or_eos_index (vector signed char, vector signed char);
19049 unsigned int vec_first_match_or_eos_index (vector unsigned char, vector unsigned char);
19050 unsigned int vec_first_match_or_eos_index (vector signed int, vector signed int);
19051 unsigned int vec_first_match_or_eos_index (vector unsigned int, vector unsigned int);
19052 unsigned int vec_first_match_or_eos_index (vector signed short, vector signed short);
19053 unsigned int vec_first_match_or_eos_index (vector unsigned short,
19054                                            vector unsigned short);
19055 unsigned int vec_first_mismatch_index (vector signed char, vector signed char);
19056 unsigned int vec_first_mismatch_index (vector unsigned char, vector unsigned char);
19057 unsigned int vec_first_mismatch_index (vector signed int, vector signed int);
19058 unsigned int vec_first_mismatch_index (vector unsigned int, vector unsigned int);
19059 unsigned int vec_first_mismatch_index (vector signed short, vector signed short);
19060 unsigned int vec_first_mismatch_index (vector unsigned short, vector unsigned short);
19061 unsigned int vec_first_mismatch_or_eos_index (vector signed char, vector signed char);
19062 unsigned int vec_first_mismatch_or_eos_index (vector unsigned char,
19063                                               vector unsigned char);
19064 unsigned int vec_first_mismatch_or_eos_index (vector signed int, vector signed int);
19065 unsigned int vec_first_mismatch_or_eos_index (vector unsigned int, vector unsigned int);
19066 unsigned int vec_first_mismatch_or_eos_index (vector signed short, vector signed short);
19067 unsigned int vec_first_mismatch_or_eos_index (vector unsigned short,
19068                                               vector unsigned short);
19070 vector unsigned short vec_pack_to_short_fp32 (vector float, vector float);
19072 vector signed char vec_xl_be (signed long long, signed char *);
19073 vector unsigned char vec_xl_be (signed long long, unsigned char *);
19074 vector signed int vec_xl_be (signed long long, signed int *);
19075 vector unsigned int vec_xl_be (signed long long, unsigned int *);
19076 vector signed __int128 vec_xl_be (signed long long, signed __int128 *);
19077 vector unsigned __int128 vec_xl_be (signed long long, unsigned __int128 *);
19078 vector signed long long vec_xl_be (signed long long, signed long long *);
19079 vector unsigned long long vec_xl_be (signed long long, unsigned long long *);
19080 vector signed short vec_xl_be (signed long long, signed short *);
19081 vector unsigned short vec_xl_be (signed long long, unsigned short *);
19082 vector double vec_xl_be (signed long long, double *);
19083 vector float vec_xl_be (signed long long, float *);
19085 vector signed char vec_xl_len (signed char *addr, size_t len);
19086 vector unsigned char vec_xl_len (unsigned char *addr, size_t len);
19087 vector signed int vec_xl_len (signed int *addr, size_t len);
19088 vector unsigned int vec_xl_len (unsigned int *addr, size_t len);
19089 vector signed __int128 vec_xl_len (signed __int128 *addr, size_t len);
19090 vector unsigned __int128 vec_xl_len (unsigned __int128 *addr, size_t len);
19091 vector signed long long vec_xl_len (signed long long *addr, size_t len);
19092 vector unsigned long long vec_xl_len (unsigned long long *addr, size_t len);
19093 vector signed short vec_xl_len (signed short *addr, size_t len);
19094 vector unsigned short vec_xl_len (unsigned short *addr, size_t len);
19095 vector double vec_xl_len (double *addr, size_t len);
19096 vector float vec_xl_len (float *addr, size_t len);
19098 vector unsigned char vec_xl_len_r (unsigned char *addr, size_t len);
19100 void vec_xst_len (vector signed char data, signed char *addr, size_t len);
19101 void vec_xst_len (vector unsigned char data, unsigned char *addr, size_t len);
19102 void vec_xst_len (vector signed int data, signed int *addr, size_t len);
19103 void vec_xst_len (vector unsigned int data, unsigned int *addr, size_t len);
19104 void vec_xst_len (vector unsigned __int128 data, unsigned __int128 *addr, size_t len);
19105 void vec_xst_len (vector signed long long data, signed long long *addr, size_t len);
19106 void vec_xst_len (vector unsigned long long data, unsigned long long *addr, size_t len);
19107 void vec_xst_len (vector signed short data, signed short *addr, size_t len);
19108 void vec_xst_len (vector unsigned short data, unsigned short *addr, size_t len);
19109 void vec_xst_len (vector signed __int128 data, signed __int128 *addr, size_t len);
19110 void vec_xst_len (vector double data, double *addr, size_t len);
19111 void vec_xst_len (vector float data, float *addr, size_t len);
19113 void vec_xst_len_r (vector unsigned char data, unsigned char *addr, size_t len);
19115 signed char vec_xlx (unsigned int index, vector signed char data);
19116 unsigned char vec_xlx (unsigned int index, vector unsigned char data);
19117 signed short vec_xlx (unsigned int index, vector signed short data);
19118 unsigned short vec_xlx (unsigned int index, vector unsigned short data);
19119 signed int vec_xlx (unsigned int index, vector signed int data);
19120 unsigned int vec_xlx (unsigned int index, vector unsigned int data);
19121 float vec_xlx (unsigned int index, vector float data);
19123 signed char vec_xrx (unsigned int index, vector signed char data);
19124 unsigned char vec_xrx (unsigned int index, vector unsigned char data);
19125 signed short vec_xrx (unsigned int index, vector signed short data);
19126 unsigned short vec_xrx (unsigned int index, vector unsigned short data);
19127 signed int vec_xrx (unsigned int index, vector signed int data);
19128 unsigned int vec_xrx (unsigned int index, vector unsigned int data);
19129 float vec_xrx (unsigned int index, vector float data);
19130 @end smallexample
19132 The @code{vec_all_nez}, @code{vec_any_eqz}, and @code{vec_cmpnez}
19133 perform pairwise comparisons between the elements at the same
19134 positions within their two vector arguments.
19135 The @code{vec_all_nez} function returns a
19136 non-zero value if and only if all pairwise comparisons are not
19137 equal and no element of either vector argument contains a zero.
19138 The @code{vec_any_eqz} function returns a
19139 non-zero value if and only if at least one pairwise comparison is equal
19140 or if at least one element of either vector argument contains a zero.
19141 The @code{vec_cmpnez} function returns a vector of the same type as
19142 its two arguments, within which each element consists of all ones to
19143 denote that either the corresponding elements of the incoming arguments are
19144 not equal or that at least one of the corresponding elements contains
19145 zero.  Otherwise, the element of the returned vector contains all zeros.
19147 The @code{vec_cntlz_lsbb} function returns the count of the number of
19148 consecutive leading byte elements (starting from position 0 within the
19149 supplied vector argument) for which the least-significant bit
19150 equals zero.  The @code{vec_cnttz_lsbb} function returns the count of
19151 the number of consecutive trailing byte elements (starting from
19152 position 15 and counting backwards within the supplied vector
19153 argument) for which the least-significant bit equals zero.
19155 The @code{vec_xl_len} and @code{vec_xst_len} functions require a
19156 64-bit environment supporting ISA 3.0 or later.  The @code{vec_xl_len}
19157 function loads a variable length vector from memory.  The
19158 @code{vec_xst_len} function stores a variable length vector to memory.
19159 With both the @code{vec_xl_len} and @code{vec_xst_len} functions, the
19160 @code{addr} argument represents the memory address to or from which
19161 data will be transferred, and the
19162 @code{len} argument represents the number of bytes to be
19163 transferred, as computed by the C expression @code{min((len & 0xff), 16)}.
19164 If this expression's value is not a multiple of the vector element's
19165 size, the behavior of this function is undefined.
19166 In the case that the underlying computer is configured to run in
19167 big-endian mode, the data transfer moves bytes 0 to @code{(len - 1)} of
19168 the corresponding vector.  In little-endian mode, the data transfer
19169 moves bytes @code{(16 - len)} to @code{15} of the corresponding
19170 vector.  For the load function, any bytes of the result vector that
19171 are not loaded from memory are set to zero.
19172 The value of the @code{addr} argument need not be aligned on a
19173 multiple of the vector's element size.
19175 The @code{vec_xlx} and @code{vec_xrx} functions extract the single
19176 element selected by the @code{index} argument from the vector
19177 represented by the @code{data} argument.  The @code{index} argument
19178 always specifies a byte offset, regardless of the size of the vector
19179 element.  With @code{vec_xlx}, @code{index} is the offset of the first
19180 byte of the element to be extracted.  With @code{vec_xrx}, @code{index}
19181 represents the last byte of the element to be extracted, measured
19182 from the right end of the vector.  In other words, the last byte of
19183 the element to be extracted is found at position @code{(15 - index)}.
19184 There is no requirement that @code{index} be a multiple of the vector
19185 element size.  However, if the size of the vector element added to
19186 @code{index} is greater than 15, the content of the returned value is
19187 undefined.
19189 If the ISA 3.0 instruction set additions (@option{-mcpu=power9})
19190 are available:
19192 @smallexample
19193 vector unsigned long long vec_bperm (vector unsigned long long, vector unsigned char);
19195 vector bool char vec_cmpne (vector bool char, vector bool char);
19196 vector bool char vec_cmpne (vector signed char, vector signed char);
19197 vector bool char vec_cmpne (vector unsigned char, vector unsigned char);
19198 vector bool int vec_cmpne (vector bool int, vector bool int);
19199 vector bool int vec_cmpne (vector signed int, vector signed int);
19200 vector bool int vec_cmpne (vector unsigned int, vector unsigned int);
19201 vector bool long long vec_cmpne (vector bool long long, vector bool long long);
19202 vector bool long long vec_cmpne (vector signed long long, vector signed long long);
19203 vector bool long long vec_cmpne (vector unsigned long long, vector unsigned long long);
19204 vector bool short vec_cmpne (vector bool short, vector bool short);
19205 vector bool short vec_cmpne (vector signed short, vector signed short);
19206 vector bool short vec_cmpne (vector unsigned short, vector unsigned short);
19207 vector bool long long vec_cmpne (vector double, vector double);
19208 vector bool int vec_cmpne (vector float, vector float);
19210 vector float vec_extract_fp32_from_shorth (vector unsigned short);
19211 vector float vec_extract_fp32_from_shortl (vector unsigned short);
19213 vector long long vec_vctz (vector long long);
19214 vector unsigned long long vec_vctz (vector unsigned long long);
19215 vector int vec_vctz (vector int);
19216 vector unsigned int vec_vctz (vector int);
19217 vector short vec_vctz (vector short);
19218 vector unsigned short vec_vctz (vector unsigned short);
19219 vector signed char vec_vctz (vector signed char);
19220 vector unsigned char vec_vctz (vector unsigned char);
19222 vector signed char vec_vctzb (vector signed char);
19223 vector unsigned char vec_vctzb (vector unsigned char);
19225 vector long long vec_vctzd (vector long long);
19226 vector unsigned long long vec_vctzd (vector unsigned long long);
19228 vector short vec_vctzh (vector short);
19229 vector unsigned short vec_vctzh (vector unsigned short);
19231 vector int vec_vctzw (vector int);
19232 vector unsigned int vec_vctzw (vector int);
19234 vector unsigned long long vec_extract4b (vector unsigned char, const int);
19236 vector unsigned char vec_insert4b (vector signed int, vector unsigned char,
19237                                    const int);
19238 vector unsigned char vec_insert4b (vector unsigned int, vector unsigned char,
19239                                    const int);
19241 vector unsigned int vec_parity_lsbb (vector signed int);
19242 vector unsigned int vec_parity_lsbb (vector unsigned int);
19243 vector unsigned __int128 vec_parity_lsbb (vector signed __int128);
19244 vector unsigned __int128 vec_parity_lsbb (vector unsigned __int128);
19245 vector unsigned long long vec_parity_lsbb (vector signed long long);
19246 vector unsigned long long vec_parity_lsbb (vector unsigned long long);
19248 vector int vec_vprtyb (vector int);
19249 vector unsigned int vec_vprtyb (vector unsigned int);
19250 vector long long vec_vprtyb (vector long long);
19251 vector unsigned long long vec_vprtyb (vector unsigned long long);
19253 vector int vec_vprtybw (vector int);
19254 vector unsigned int vec_vprtybw (vector unsigned int);
19256 vector long long vec_vprtybd (vector long long);
19257 vector unsigned long long vec_vprtybd (vector unsigned long long);
19258 @end smallexample
19260 On 64-bit targets, if the ISA 3.0 additions (@option{-mcpu=power9})
19261 are available:
19263 @smallexample
19264 vector long vec_vprtyb (vector long);
19265 vector unsigned long vec_vprtyb (vector unsigned long);
19266 vector __int128 vec_vprtyb (vector __int128);
19267 vector __uint128 vec_vprtyb (vector __uint128);
19269 vector long vec_vprtybd (vector long);
19270 vector unsigned long vec_vprtybd (vector unsigned long);
19272 vector __int128 vec_vprtybq (vector __int128);
19273 vector __uint128 vec_vprtybd (vector __uint128);
19274 @end smallexample
19276 The following built-in vector functions are available for the PowerPC family
19277 of processors, starting with ISA 3.0 or later (@option{-mcpu=power9}):
19278 @smallexample
19279 __vector unsigned char
19280 vec_slv (__vector unsigned char src, __vector unsigned char shift_distance);
19281 __vector unsigned char
19282 vec_srv (__vector unsigned char src, __vector unsigned char shift_distance);
19283 @end smallexample
19285 The @code{vec_slv} and @code{vec_srv} functions operate on
19286 all of the bytes of their @code{src} and @code{shift_distance}
19287 arguments in parallel.  The behavior of the @code{vec_slv} is as if
19288 there existed a temporary array of 17 unsigned characters
19289 @code{slv_array} within which elements 0 through 15 are the same as
19290 the entries in the @code{src} array and element 16 equals 0.  The
19291 result returned from the @code{vec_slv} function is a
19292 @code{__vector} of 16 unsigned characters within which element
19293 @code{i} is computed using the C expression
19294 @code{0xff & (*((unsigned short *)(slv_array + i)) << (0x07 &
19295 shift_distance[i]))},
19296 with this resulting value coerced to the @code{unsigned char} type.
19297 The behavior of the @code{vec_srv} is as if
19298 there existed a temporary array of 17 unsigned characters
19299 @code{srv_array} within which element 0 equals zero and
19300 elements 1 through 16 equal the elements 0 through 15 of
19301 the @code{src} array.  The
19302 result returned from the @code{vec_srv} function is a
19303 @code{__vector} of 16 unsigned characters within which element
19304 @code{i} is computed using the C expression
19305 @code{0xff & (*((unsigned short *)(srv_array + i)) >>
19306 (0x07 & shift_distance[i]))},
19307 with this resulting value coerced to the @code{unsigned char} type.
19309 The following built-in functions are available for the PowerPC family
19310 of processors, starting with ISA 3.0 or later (@option{-mcpu=power9}):
19311 @smallexample
19312 __vector unsigned char
19313 vec_absd (__vector unsigned char arg1, __vector unsigned char arg2);
19314 __vector unsigned short
19315 vec_absd (__vector unsigned short arg1, __vector unsigned short arg2);
19316 __vector unsigned int
19317 vec_absd (__vector unsigned int arg1, __vector unsigned int arg2);
19319 __vector unsigned char
19320 vec_absdb (__vector unsigned char arg1, __vector unsigned char arg2);
19321 __vector unsigned short
19322 vec_absdh (__vector unsigned short arg1, __vector unsigned short arg2);
19323 __vector unsigned int
19324 vec_absdw (__vector unsigned int arg1, __vector unsigned int arg2);
19325 @end smallexample
19327 The @code{vec_absd}, @code{vec_absdb}, @code{vec_absdh}, and
19328 @code{vec_absdw} built-in functions each computes the absolute
19329 differences of the pairs of vector elements supplied in its two vector
19330 arguments, placing the absolute differences into the corresponding
19331 elements of the vector result.
19333 The following built-in functions are available for the PowerPC family
19334 of processors, starting with ISA 3.0 or later (@option{-mcpu=power9}):
19335 @smallexample
19336 __vector unsigned int vec_extract_exp (__vector float source);
19337 __vector unsigned long long int vec_extract_exp (__vector double source);
19339 __vector unsigned int vec_extract_sig (__vector float source);
19340 __vector unsigned long long int vec_extract_sig (__vector double source);
19342 __vector float vec_insert_exp (__vector unsigned int significands,
19343                                __vector unsigned int exponents);
19344 __vector float vec_insert_exp (__vector unsigned float significands,
19345                                __vector unsigned int exponents);
19346 __vector double vec_insert_exp (__vector unsigned long long int significands,
19347                                 __vector unsigned long long int exponents);
19348 __vector double vec_insert_exp (__vector unsigned double significands,
19349                                 __vector unsigned long long int exponents);
19351 __vector bool int vec_test_data_class (__vector float source, const int condition);
19352 __vector bool long long int vec_test_data_class (__vector double source,
19353                                                  const int condition);
19354 @end smallexample
19356 The @code{vec_extract_sig} and @code{vec_extract_exp} built-in
19357 functions return vectors representing the significands and biased
19358 exponent values of their @code{source} arguments respectively.
19359 Within the result vector returned by @code{vec_extract_sig}, the
19360 @code{0x800000} bit of each vector element returned when the
19361 function's @code{source} argument is of type @code{float} is set to 1
19362 if the corresponding floating point value is in normalized form.
19363 Otherwise, this bit is set to 0.  When the @code{source} argument is
19364 of type @code{double}, the @code{0x10000000000000} bit within each of
19365 the result vector's elements is set according to the same rules.
19366 Note that the sign of the significand is not represented in the result
19367 returned from the @code{vec_extract_sig} function.  To extract the
19368 sign bits, use the
19369 @code{vec_cpsgn} function, which returns a new vector within which all
19370 of the sign bits of its second argument vector are overwritten with the
19371 sign bits copied from the coresponding elements of its first argument
19372 vector, and all other (non-sign) bits of the second argument vector
19373 are copied unchanged into the result vector.
19375 The @code{vec_insert_exp} built-in functions return a vector of
19376 single- or double-precision floating
19377 point values constructed by assembling the values of their
19378 @code{significands} and @code{exponents} arguments into the
19379 corresponding elements of the returned vector.
19380 The sign of each
19381 element of the result is copied from the most significant bit of the
19382 corresponding entry within the @code{significands} argument.
19383 Note that the relevant
19384 bits of the @code{significands} argument are the same, for both integer
19385 and floating point types.
19387 significand and exponent components of each element of the result are
19388 composed of the least significant bits of the corresponding
19389 @code{significands} element and the least significant bits of the
19390 corresponding @code{exponents} element.
19392 The @code{vec_test_data_class} built-in function returns a vector
19393 representing the results of testing the @code{source} vector for the
19394 condition selected by the @code{condition} argument.  The
19395 @code{condition} argument must be a compile-time constant integer with
19396 value not exceeding 127.  The
19397 @code{condition} argument is encoded as a bitmask with each bit
19398 enabling the testing of a different condition, as characterized by the
19399 following:
19400 @smallexample
19401 0x40    Test for NaN
19402 0x20    Test for +Infinity
19403 0x10    Test for -Infinity
19404 0x08    Test for +Zero
19405 0x04    Test for -Zero
19406 0x02    Test for +Denormal
19407 0x01    Test for -Denormal
19408 @end smallexample
19410 If any of the enabled test conditions is true, the corresponding entry
19411 in the result vector is -1.  Otherwise (all of the enabled test
19412 conditions are false), the corresponding entry of the result vector is 0.
19414 The following built-in functions are available for the PowerPC family
19415 of processors, starting with ISA 3.0 or later (@option{-mcpu=power9}):
19416 @smallexample
19417 vector unsigned int vec_rlmi (vector unsigned int, vector unsigned int,
19418                               vector unsigned int);
19419 vector unsigned long long vec_rlmi (vector unsigned long long,
19420                                     vector unsigned long long,
19421                                     vector unsigned long long);
19422 vector unsigned int vec_rlnm (vector unsigned int, vector unsigned int,
19423                               vector unsigned int);
19424 vector unsigned long long vec_rlnm (vector unsigned long long,
19425                                     vector unsigned long long,
19426                                     vector unsigned long long);
19427 vector unsigned int vec_vrlnm (vector unsigned int, vector unsigned int);
19428 vector unsigned long long vec_vrlnm (vector unsigned long long,
19429                                      vector unsigned long long);
19430 @end smallexample
19432 The result of @code{vec_rlmi} is obtained by rotating each element of
19433 the first argument vector left and inserting it under mask into the
19434 second argument vector.  The third argument vector contains the mask
19435 beginning in bits 11:15, the mask end in bits 19:23, and the shift
19436 count in bits 27:31, of each element.
19438 The result of @code{vec_rlnm} is obtained by rotating each element of
19439 the first argument vector left and ANDing it with a mask specified by
19440 the second and third argument vectors.  The second argument vector
19441 contains the shift count for each element in the low-order byte.  The
19442 third argument vector contains the mask end for each element in the
19443 low-order byte, with the mask begin in the next higher byte.
19445 The result of @code{vec_vrlnm} is obtained by rotating each element
19446 of the first argument vector left and ANDing it with a mask.  The
19447 second argument vector contains the mask  beginning in bits 11:15,
19448 the mask end in bits 19:23, and the shift count in bits 27:31,
19449 of each element.
19451 If the ISA 3.0 instruction set additions (@option{-mcpu=power9})
19452 are available:
19453 @smallexample
19454 vector signed bool char vec_revb (vector signed char);
19455 vector signed char vec_revb (vector signed char);
19456 vector unsigned char vec_revb (vector unsigned char);
19457 vector bool short vec_revb (vector bool short);
19458 vector short vec_revb (vector short);
19459 vector unsigned short vec_revb (vector unsigned short);
19460 vector bool int vec_revb (vector bool int);
19461 vector int vec_revb (vector int);
19462 vector unsigned int vec_revb (vector unsigned int);
19463 vector float vec_revb (vector float);
19464 vector bool long long vec_revb (vector bool long long);
19465 vector long long vec_revb (vector long long);
19466 vector unsigned long long vec_revb (vector unsigned long long);
19467 vector double vec_revb (vector double);
19468 @end smallexample
19470 On 64-bit targets, if the ISA 3.0 additions (@option{-mcpu=power9})
19471 are available:
19472 @smallexample
19473 vector long vec_revb (vector long);
19474 vector unsigned long vec_revb (vector unsigned long);
19475 vector __int128 vec_revb (vector __int128);
19476 vector __uint128 vec_revb (vector __uint128);
19477 @end smallexample
19479 The @code{vec_revb} built-in function reverses the bytes on an element
19480 by element basis.  A vector of @code{vector unsigned char} or
19481 @code{vector signed char} reverses the bytes in the whole word.
19483 If the cryptographic instructions are enabled (@option{-mcrypto} or
19484 @option{-mcpu=power8}), the following builtins are enabled.
19486 @smallexample
19487 vector unsigned long long __builtin_crypto_vsbox (vector unsigned long long);
19489 vector unsigned long long __builtin_crypto_vcipher (vector unsigned long long,
19490                                                     vector unsigned long long);
19492 vector unsigned long long __builtin_crypto_vcipherlast
19493                                      (vector unsigned long long,
19494                                       vector unsigned long long);
19496 vector unsigned long long __builtin_crypto_vncipher (vector unsigned long long,
19497                                                      vector unsigned long long);
19499 vector unsigned long long __builtin_crypto_vncipherlast (vector unsigned long long,
19500                                                          vector unsigned long long);
19502 vector unsigned char __builtin_crypto_vpermxor (vector unsigned char,
19503                                                 vector unsigned char,
19504                                                 vector unsigned char);
19506 vector unsigned short __builtin_crypto_vpermxor (vector unsigned short,
19507                                                  vector unsigned short,
19508                                                  vector unsigned short);
19510 vector unsigned int __builtin_crypto_vpermxor (vector unsigned int,
19511                                                vector unsigned int,
19512                                                vector unsigned int);
19514 vector unsigned long long __builtin_crypto_vpermxor (vector unsigned long long,
19515                                                      vector unsigned long long,
19516                                                      vector unsigned long long);
19518 vector unsigned char __builtin_crypto_vpmsumb (vector unsigned char,
19519                                                vector unsigned char);
19521 vector unsigned short __builtin_crypto_vpmsumb (vector unsigned short,
19522                                                 vector unsigned short);
19524 vector unsigned int __builtin_crypto_vpmsumb (vector unsigned int,
19525                                               vector unsigned int);
19527 vector unsigned long long __builtin_crypto_vpmsumb (vector unsigned long long,
19528                                                     vector unsigned long long);
19530 vector unsigned long long __builtin_crypto_vshasigmad (vector unsigned long long,
19531                                                        int, int);
19533 vector unsigned int __builtin_crypto_vshasigmaw (vector unsigned int, int, int);
19534 @end smallexample
19536 The second argument to @var{__builtin_crypto_vshasigmad} and
19537 @var{__builtin_crypto_vshasigmaw} must be a constant
19538 integer that is 0 or 1.  The third argument to these built-in functions
19539 must be a constant integer in the range of 0 to 15.
19541 If the ISA 3.0 instruction set additions 
19542 are enabled (@option{-mcpu=power9}), the following additional
19543 functions are available for both 32-bit and 64-bit targets.
19544 @smallexample
19545 vector short vec_xl (int, vector short *);
19546 vector short vec_xl (int, short *);
19547 vector unsigned short vec_xl (int, vector unsigned short *);
19548 vector unsigned short vec_xl (int, unsigned short *);
19549 vector char vec_xl (int, vector char *);
19550 vector char vec_xl (int, char *);
19551 vector unsigned char vec_xl (int, vector unsigned char *);
19552 vector unsigned char vec_xl (int, unsigned char *);
19554 void vec_xst (vector short, int, vector short *);
19555 void vec_xst (vector short, int, short *);
19556 void vec_xst (vector unsigned short, int, vector unsigned short *);
19557 void vec_xst (vector unsigned short, int, unsigned short *);
19558 void vec_xst (vector char, int, vector char *);
19559 void vec_xst (vector char, int, char *);
19560 void vec_xst (vector unsigned char, int, vector unsigned char *);
19561 void vec_xst (vector unsigned char, int, unsigned char *);
19562 @end smallexample
19563 @node PowerPC Hardware Transactional Memory Built-in Functions
19564 @subsection PowerPC Hardware Transactional Memory Built-in Functions
19565 GCC provides two interfaces for accessing the Hardware Transactional
19566 Memory (HTM) instructions available on some of the PowerPC family
19567 of processors (eg, POWER8).  The two interfaces come in a low level
19568 interface, consisting of built-in functions specific to PowerPC and a
19569 higher level interface consisting of inline functions that are common
19570 between PowerPC and S/390.
19572 @subsubsection PowerPC HTM Low Level Built-in Functions
19574 The following low level built-in functions are available with
19575 @option{-mhtm} or @option{-mcpu=CPU} where CPU is `power8' or later.
19576 They all generate the machine instruction that is part of the name.
19578 The HTM builtins (with the exception of @code{__builtin_tbegin}) return
19579 the full 4-bit condition register value set by their associated hardware
19580 instruction.  The header file @code{htmintrin.h} defines some macros that can
19581 be used to decipher the return value.  The @code{__builtin_tbegin} builtin
19582 returns a simple @code{true} or @code{false} value depending on whether a transaction was
19583 successfully started or not.  The arguments of the builtins match exactly the
19584 type and order of the associated hardware instruction's operands, except for
19585 the @code{__builtin_tcheck} builtin, which does not take any input arguments.
19586 Refer to the ISA manual for a description of each instruction's operands.
19588 @smallexample
19589 unsigned int __builtin_tbegin (unsigned int)
19590 unsigned int __builtin_tend (unsigned int)
19592 unsigned int __builtin_tabort (unsigned int)
19593 unsigned int __builtin_tabortdc (unsigned int, unsigned int, unsigned int)
19594 unsigned int __builtin_tabortdci (unsigned int, unsigned int, int)
19595 unsigned int __builtin_tabortwc (unsigned int, unsigned int, unsigned int)
19596 unsigned int __builtin_tabortwci (unsigned int, unsigned int, int)
19598 unsigned int __builtin_tcheck (void)
19599 unsigned int __builtin_treclaim (unsigned int)
19600 unsigned int __builtin_trechkpt (void)
19601 unsigned int __builtin_tsr (unsigned int)
19602 @end smallexample
19604 In addition to the above HTM built-ins, we have added built-ins for
19605 some common extended mnemonics of the HTM instructions:
19607 @smallexample
19608 unsigned int __builtin_tendall (void)
19609 unsigned int __builtin_tresume (void)
19610 unsigned int __builtin_tsuspend (void)
19611 @end smallexample
19613 Note that the semantics of the above HTM builtins are required to mimic
19614 the locking semantics used for critical sections.  Builtins that are used
19615 to create a new transaction or restart a suspended transaction must have
19616 lock acquisition like semantics while those builtins that end or suspend a
19617 transaction must have lock release like semantics.  Specifically, this must
19618 mimic lock semantics as specified by C++11, for example: Lock acquisition is
19619 as-if an execution of __atomic_exchange_n(&globallock,1,__ATOMIC_ACQUIRE)
19620 that returns 0, and lock release is as-if an execution of
19621 __atomic_store(&globallock,0,__ATOMIC_RELEASE), with globallock being an
19622 implicit implementation-defined lock used for all transactions.  The HTM
19623 instructions associated with with the builtins inherently provide the
19624 correct acquisition and release hardware barriers required.  However,
19625 the compiler must also be prohibited from moving loads and stores across
19626 the builtins in a way that would violate their semantics.  This has been
19627 accomplished by adding memory barriers to the associated HTM instructions
19628 (which is a conservative approach to provide acquire and release semantics).
19629 Earlier versions of the compiler did not treat the HTM instructions as
19630 memory barriers.  A @code{__TM_FENCE__} macro has been added, which can
19631 be used to determine whether the current compiler treats HTM instructions
19632 as memory barriers or not.  This allows the user to explicitly add memory
19633 barriers to their code when using an older version of the compiler.
19635 The following set of built-in functions are available to gain access
19636 to the HTM specific special purpose registers.
19638 @smallexample
19639 unsigned long __builtin_get_texasr (void)
19640 unsigned long __builtin_get_texasru (void)
19641 unsigned long __builtin_get_tfhar (void)
19642 unsigned long __builtin_get_tfiar (void)
19644 void __builtin_set_texasr (unsigned long);
19645 void __builtin_set_texasru (unsigned long);
19646 void __builtin_set_tfhar (unsigned long);
19647 void __builtin_set_tfiar (unsigned long);
19648 @end smallexample
19650 Example usage of these low level built-in functions may look like:
19652 @smallexample
19653 #include <htmintrin.h>
19655 int num_retries = 10;
19657 while (1)
19658   @{
19659     if (__builtin_tbegin (0))
19660       @{
19661         /* Transaction State Initiated.  */
19662         if (is_locked (lock))
19663           __builtin_tabort (0);
19664         ... transaction code...
19665         __builtin_tend (0);
19666         break;
19667       @}
19668     else
19669       @{
19670         /* Transaction State Failed.  Use locks if the transaction
19671            failure is "persistent" or we've tried too many times.  */
19672         if (num_retries-- <= 0
19673             || _TEXASRU_FAILURE_PERSISTENT (__builtin_get_texasru ()))
19674           @{
19675             acquire_lock (lock);
19676             ... non transactional fallback path...
19677             release_lock (lock);
19678             break;
19679           @}
19680       @}
19681   @}
19682 @end smallexample
19684 One final built-in function has been added that returns the value of
19685 the 2-bit Transaction State field of the Machine Status Register (MSR)
19686 as stored in @code{CR0}.
19688 @smallexample
19689 unsigned long __builtin_ttest (void)
19690 @end smallexample
19692 This built-in can be used to determine the current transaction state
19693 using the following code example:
19695 @smallexample
19696 #include <htmintrin.h>
19698 unsigned char tx_state = _HTM_STATE (__builtin_ttest ());
19700 if (tx_state == _HTM_TRANSACTIONAL)
19701   @{
19702     /* Code to use in transactional state.  */
19703   @}
19704 else if (tx_state == _HTM_NONTRANSACTIONAL)
19705   @{
19706     /* Code to use in non-transactional state.  */
19707   @}
19708 else if (tx_state == _HTM_SUSPENDED)
19709   @{
19710     /* Code to use in transaction suspended state.  */
19711   @}
19712 @end smallexample
19714 @subsubsection PowerPC HTM High Level Inline Functions
19716 The following high level HTM interface is made available by including
19717 @code{<htmxlintrin.h>} and using @option{-mhtm} or @option{-mcpu=CPU}
19718 where CPU is `power8' or later.  This interface is common between PowerPC
19719 and S/390, allowing users to write one HTM source implementation that
19720 can be compiled and executed on either system.
19722 @smallexample
19723 long __TM_simple_begin (void)
19724 long __TM_begin (void* const TM_buff)
19725 long __TM_end (void)
19726 void __TM_abort (void)
19727 void __TM_named_abort (unsigned char const code)
19728 void __TM_resume (void)
19729 void __TM_suspend (void)
19731 long __TM_is_user_abort (void* const TM_buff)
19732 long __TM_is_named_user_abort (void* const TM_buff, unsigned char *code)
19733 long __TM_is_illegal (void* const TM_buff)
19734 long __TM_is_footprint_exceeded (void* const TM_buff)
19735 long __TM_nesting_depth (void* const TM_buff)
19736 long __TM_is_nested_too_deep(void* const TM_buff)
19737 long __TM_is_conflict(void* const TM_buff)
19738 long __TM_is_failure_persistent(void* const TM_buff)
19739 long __TM_failure_address(void* const TM_buff)
19740 long long __TM_failure_code(void* const TM_buff)
19741 @end smallexample
19743 Using these common set of HTM inline functions, we can create
19744 a more portable version of the HTM example in the previous
19745 section that will work on either PowerPC or S/390:
19747 @smallexample
19748 #include <htmxlintrin.h>
19750 int num_retries = 10;
19751 TM_buff_type TM_buff;
19753 while (1)
19754   @{
19755     if (__TM_begin (TM_buff) == _HTM_TBEGIN_STARTED)
19756       @{
19757         /* Transaction State Initiated.  */
19758         if (is_locked (lock))
19759           __TM_abort ();
19760         ... transaction code...
19761         __TM_end ();
19762         break;
19763       @}
19764     else
19765       @{
19766         /* Transaction State Failed.  Use locks if the transaction
19767            failure is "persistent" or we've tried too many times.  */
19768         if (num_retries-- <= 0
19769             || __TM_is_failure_persistent (TM_buff))
19770           @{
19771             acquire_lock (lock);
19772             ... non transactional fallback path...
19773             release_lock (lock);
19774             break;
19775           @}
19776       @}
19777   @}
19778 @end smallexample
19780 @node PowerPC Atomic Memory Operation Functions
19781 @subsection PowerPC Atomic Memory Operation Functions
19782 ISA 3.0 of the PowerPC added new atomic memory operation (amo)
19783 instructions.  GCC provides support for these instructions in 64-bit
19784 environments.  All of the functions are declared in the include file
19785 @code{amo.h}.
19787 The functions supported are:
19789 @smallexample
19790 #include <amo.h>
19792 uint32_t amo_lwat_add (uint32_t *, uint32_t);
19793 uint32_t amo_lwat_xor (uint32_t *, uint32_t);
19794 uint32_t amo_lwat_ior (uint32_t *, uint32_t);
19795 uint32_t amo_lwat_and (uint32_t *, uint32_t);
19796 uint32_t amo_lwat_umax (uint32_t *, uint32_t);
19797 uint32_t amo_lwat_umin (uint32_t *, uint32_t);
19798 uint32_t amo_lwat_swap (uint32_t *, uint32_t);
19800 int32_t amo_lwat_sadd (int32_t *, int32_t);
19801 int32_t amo_lwat_smax (int32_t *, int32_t);
19802 int32_t amo_lwat_smin (int32_t *, int32_t);
19803 int32_t amo_lwat_sswap (int32_t *, int32_t);
19805 uint64_t amo_ldat_add (uint64_t *, uint64_t);
19806 uint64_t amo_ldat_xor (uint64_t *, uint64_t);
19807 uint64_t amo_ldat_ior (uint64_t *, uint64_t);
19808 uint64_t amo_ldat_and (uint64_t *, uint64_t);
19809 uint64_t amo_ldat_umax (uint64_t *, uint64_t);
19810 uint64_t amo_ldat_umin (uint64_t *, uint64_t);
19811 uint64_t amo_ldat_swap (uint64_t *, uint64_t);
19813 int64_t amo_ldat_sadd (int64_t *, int64_t);
19814 int64_t amo_ldat_smax (int64_t *, int64_t);
19815 int64_t amo_ldat_smin (int64_t *, int64_t);
19816 int64_t amo_ldat_sswap (int64_t *, int64_t);
19818 void amo_stwat_add (uint32_t *, uint32_t);
19819 void amo_stwat_xor (uint32_t *, uint32_t);
19820 void amo_stwat_ior (uint32_t *, uint32_t);
19821 void amo_stwat_and (uint32_t *, uint32_t);
19822 void amo_stwat_umax (uint32_t *, uint32_t);
19823 void amo_stwat_umin (uint32_t *, uint32_t);
19825 void amo_stwat_sadd (int32_t *, int32_t);
19826 void amo_stwat_smax (int32_t *, int32_t);
19827 void amo_stwat_smin (int32_t *, int32_t);
19829 void amo_stdat_add (uint64_t *, uint64_t);
19830 void amo_stdat_xor (uint64_t *, uint64_t);
19831 void amo_stdat_ior (uint64_t *, uint64_t);
19832 void amo_stdat_and (uint64_t *, uint64_t);
19833 void amo_stdat_umax (uint64_t *, uint64_t);
19834 void amo_stdat_umin (uint64_t *, uint64_t);
19836 void amo_stdat_sadd (int64_t *, int64_t);
19837 void amo_stdat_smax (int64_t *, int64_t);
19838 void amo_stdat_smin (int64_t *, int64_t);
19839 @end smallexample
19841 @node RX Built-in Functions
19842 @subsection RX Built-in Functions
19843 GCC supports some of the RX instructions which cannot be expressed in
19844 the C programming language via the use of built-in functions.  The
19845 following functions are supported:
19847 @deftypefn {Built-in Function}  void __builtin_rx_brk (void)
19848 Generates the @code{brk} machine instruction.
19849 @end deftypefn
19851 @deftypefn {Built-in Function}  void __builtin_rx_clrpsw (int)
19852 Generates the @code{clrpsw} machine instruction to clear the specified
19853 bit in the processor status word.
19854 @end deftypefn
19856 @deftypefn {Built-in Function}  void __builtin_rx_int (int)
19857 Generates the @code{int} machine instruction to generate an interrupt
19858 with the specified value.
19859 @end deftypefn
19861 @deftypefn {Built-in Function}  void __builtin_rx_machi (int, int)
19862 Generates the @code{machi} machine instruction to add the result of
19863 multiplying the top 16 bits of the two arguments into the
19864 accumulator.
19865 @end deftypefn
19867 @deftypefn {Built-in Function}  void __builtin_rx_maclo (int, int)
19868 Generates the @code{maclo} machine instruction to add the result of
19869 multiplying the bottom 16 bits of the two arguments into the
19870 accumulator.
19871 @end deftypefn
19873 @deftypefn {Built-in Function}  void __builtin_rx_mulhi (int, int)
19874 Generates the @code{mulhi} machine instruction to place the result of
19875 multiplying the top 16 bits of the two arguments into the
19876 accumulator.
19877 @end deftypefn
19879 @deftypefn {Built-in Function}  void __builtin_rx_mullo (int, int)
19880 Generates the @code{mullo} machine instruction to place the result of
19881 multiplying the bottom 16 bits of the two arguments into the
19882 accumulator.
19883 @end deftypefn
19885 @deftypefn {Built-in Function}  int  __builtin_rx_mvfachi (void)
19886 Generates the @code{mvfachi} machine instruction to read the top
19887 32 bits of the accumulator.
19888 @end deftypefn
19890 @deftypefn {Built-in Function}  int  __builtin_rx_mvfacmi (void)
19891 Generates the @code{mvfacmi} machine instruction to read the middle
19892 32 bits of the accumulator.
19893 @end deftypefn
19895 @deftypefn {Built-in Function}  int __builtin_rx_mvfc (int)
19896 Generates the @code{mvfc} machine instruction which reads the control
19897 register specified in its argument and returns its value.
19898 @end deftypefn
19900 @deftypefn {Built-in Function}  void __builtin_rx_mvtachi (int)
19901 Generates the @code{mvtachi} machine instruction to set the top
19902 32 bits of the accumulator.
19903 @end deftypefn
19905 @deftypefn {Built-in Function}  void __builtin_rx_mvtaclo (int)
19906 Generates the @code{mvtaclo} machine instruction to set the bottom
19907 32 bits of the accumulator.
19908 @end deftypefn
19910 @deftypefn {Built-in Function}  void __builtin_rx_mvtc (int reg, int val)
19911 Generates the @code{mvtc} machine instruction which sets control
19912 register number @code{reg} to @code{val}.
19913 @end deftypefn
19915 @deftypefn {Built-in Function}  void __builtin_rx_mvtipl (int)
19916 Generates the @code{mvtipl} machine instruction set the interrupt
19917 priority level.
19918 @end deftypefn
19920 @deftypefn {Built-in Function}  void __builtin_rx_racw (int)
19921 Generates the @code{racw} machine instruction to round the accumulator
19922 according to the specified mode.
19923 @end deftypefn
19925 @deftypefn {Built-in Function}  int __builtin_rx_revw (int)
19926 Generates the @code{revw} machine instruction which swaps the bytes in
19927 the argument so that bits 0--7 now occupy bits 8--15 and vice versa,
19928 and also bits 16--23 occupy bits 24--31 and vice versa.
19929 @end deftypefn
19931 @deftypefn {Built-in Function}  void __builtin_rx_rmpa (void)
19932 Generates the @code{rmpa} machine instruction which initiates a
19933 repeated multiply and accumulate sequence.
19934 @end deftypefn
19936 @deftypefn {Built-in Function}  void __builtin_rx_round (float)
19937 Generates the @code{round} machine instruction which returns the
19938 floating-point argument rounded according to the current rounding mode
19939 set in the floating-point status word register.
19940 @end deftypefn
19942 @deftypefn {Built-in Function}  int __builtin_rx_sat (int)
19943 Generates the @code{sat} machine instruction which returns the
19944 saturated value of the argument.
19945 @end deftypefn
19947 @deftypefn {Built-in Function}  void __builtin_rx_setpsw (int)
19948 Generates the @code{setpsw} machine instruction to set the specified
19949 bit in the processor status word.
19950 @end deftypefn
19952 @deftypefn {Built-in Function}  void __builtin_rx_wait (void)
19953 Generates the @code{wait} machine instruction.
19954 @end deftypefn
19956 @node S/390 System z Built-in Functions
19957 @subsection S/390 System z Built-in Functions
19958 @deftypefn {Built-in Function} int __builtin_tbegin (void*)
19959 Generates the @code{tbegin} machine instruction starting a
19960 non-constrained hardware transaction.  If the parameter is non-NULL the
19961 memory area is used to store the transaction diagnostic buffer and
19962 will be passed as first operand to @code{tbegin}.  This buffer can be
19963 defined using the @code{struct __htm_tdb} C struct defined in
19964 @code{htmintrin.h} and must reside on a double-word boundary.  The
19965 second tbegin operand is set to @code{0xff0c}. This enables
19966 save/restore of all GPRs and disables aborts for FPR and AR
19967 manipulations inside the transaction body.  The condition code set by
19968 the tbegin instruction is returned as integer value.  The tbegin
19969 instruction by definition overwrites the content of all FPRs.  The
19970 compiler will generate code which saves and restores the FPRs.  For
19971 soft-float code it is recommended to used the @code{*_nofloat}
19972 variant.  In order to prevent a TDB from being written it is required
19973 to pass a constant zero value as parameter.  Passing a zero value
19974 through a variable is not sufficient.  Although modifications of
19975 access registers inside the transaction will not trigger an
19976 transaction abort it is not supported to actually modify them.  Access
19977 registers do not get saved when entering a transaction. They will have
19978 undefined state when reaching the abort code.
19979 @end deftypefn
19981 Macros for the possible return codes of tbegin are defined in the
19982 @code{htmintrin.h} header file:
19984 @table @code
19985 @item _HTM_TBEGIN_STARTED
19986 @code{tbegin} has been executed as part of normal processing.  The
19987 transaction body is supposed to be executed.
19988 @item _HTM_TBEGIN_INDETERMINATE
19989 The transaction was aborted due to an indeterminate condition which
19990 might be persistent.
19991 @item _HTM_TBEGIN_TRANSIENT
19992 The transaction aborted due to a transient failure.  The transaction
19993 should be re-executed in that case.
19994 @item _HTM_TBEGIN_PERSISTENT
19995 The transaction aborted due to a persistent failure.  Re-execution
19996 under same circumstances will not be productive.
19997 @end table
19999 @defmac _HTM_FIRST_USER_ABORT_CODE
20000 The @code{_HTM_FIRST_USER_ABORT_CODE} defined in @code{htmintrin.h}
20001 specifies the first abort code which can be used for
20002 @code{__builtin_tabort}.  Values below this threshold are reserved for
20003 machine use.
20004 @end defmac
20006 @deftp {Data type} {struct __htm_tdb}
20007 The @code{struct __htm_tdb} defined in @code{htmintrin.h} describes
20008 the structure of the transaction diagnostic block as specified in the
20009 Principles of Operation manual chapter 5-91.
20010 @end deftp
20012 @deftypefn {Built-in Function} int __builtin_tbegin_nofloat (void*)
20013 Same as @code{__builtin_tbegin} but without FPR saves and restores.
20014 Using this variant in code making use of FPRs will leave the FPRs in
20015 undefined state when entering the transaction abort handler code.
20016 @end deftypefn
20018 @deftypefn {Built-in Function} int __builtin_tbegin_retry (void*, int)
20019 In addition to @code{__builtin_tbegin} a loop for transient failures
20020 is generated.  If tbegin returns a condition code of 2 the transaction
20021 will be retried as often as specified in the second argument.  The
20022 perform processor assist instruction is used to tell the CPU about the
20023 number of fails so far.
20024 @end deftypefn
20026 @deftypefn {Built-in Function} int __builtin_tbegin_retry_nofloat (void*, int)
20027 Same as @code{__builtin_tbegin_retry} but without FPR saves and
20028 restores.  Using this variant in code making use of FPRs will leave
20029 the FPRs in undefined state when entering the transaction abort
20030 handler code.
20031 @end deftypefn
20033 @deftypefn {Built-in Function} void __builtin_tbeginc (void)
20034 Generates the @code{tbeginc} machine instruction starting a constrained
20035 hardware transaction.  The second operand is set to @code{0xff08}.
20036 @end deftypefn
20038 @deftypefn {Built-in Function} int __builtin_tend (void)
20039 Generates the @code{tend} machine instruction finishing a transaction
20040 and making the changes visible to other threads.  The condition code
20041 generated by tend is returned as integer value.
20042 @end deftypefn
20044 @deftypefn {Built-in Function} void __builtin_tabort (int)
20045 Generates the @code{tabort} machine instruction with the specified
20046 abort code.  Abort codes from 0 through 255 are reserved and will
20047 result in an error message.
20048 @end deftypefn
20050 @deftypefn {Built-in Function} void __builtin_tx_assist (int)
20051 Generates the @code{ppa rX,rY,1} machine instruction.  Where the
20052 integer parameter is loaded into rX and a value of zero is loaded into
20053 rY.  The integer parameter specifies the number of times the
20054 transaction repeatedly aborted.
20055 @end deftypefn
20057 @deftypefn {Built-in Function} int __builtin_tx_nesting_depth (void)
20058 Generates the @code{etnd} machine instruction.  The current nesting
20059 depth is returned as integer value.  For a nesting depth of 0 the code
20060 is not executed as part of an transaction.
20061 @end deftypefn
20063 @deftypefn {Built-in Function} void __builtin_non_tx_store (uint64_t *, uint64_t)
20065 Generates the @code{ntstg} machine instruction.  The second argument
20066 is written to the first arguments location.  The store operation will
20067 not be rolled-back in case of an transaction abort.
20068 @end deftypefn
20070 @node SH Built-in Functions
20071 @subsection SH Built-in Functions
20072 The following built-in functions are supported on the SH1, SH2, SH3 and SH4
20073 families of processors:
20075 @deftypefn {Built-in Function} {void} __builtin_set_thread_pointer (void *@var{ptr})
20076 Sets the @samp{GBR} register to the specified value @var{ptr}.  This is usually
20077 used by system code that manages threads and execution contexts.  The compiler
20078 normally does not generate code that modifies the contents of @samp{GBR} and
20079 thus the value is preserved across function calls.  Changing the @samp{GBR}
20080 value in user code must be done with caution, since the compiler might use
20081 @samp{GBR} in order to access thread local variables.
20083 @end deftypefn
20085 @deftypefn {Built-in Function} {void *} __builtin_thread_pointer (void)
20086 Returns the value that is currently set in the @samp{GBR} register.
20087 Memory loads and stores that use the thread pointer as a base address are
20088 turned into @samp{GBR} based displacement loads and stores, if possible.
20089 For example:
20090 @smallexample
20091 struct my_tcb
20093    int a, b, c, d, e;
20096 int get_tcb_value (void)
20098   // Generate @samp{mov.l @@(8,gbr),r0} instruction
20099   return ((my_tcb*)__builtin_thread_pointer ())->c;
20102 @end smallexample
20103 @end deftypefn
20105 @deftypefn {Built-in Function} {unsigned int} __builtin_sh_get_fpscr (void)
20106 Returns the value that is currently set in the @samp{FPSCR} register.
20107 @end deftypefn
20109 @deftypefn {Built-in Function} {void} __builtin_sh_set_fpscr (unsigned int @var{val})
20110 Sets the @samp{FPSCR} register to the specified value @var{val}, while
20111 preserving the current values of the FR, SZ and PR bits.
20112 @end deftypefn
20114 @node SPARC VIS Built-in Functions
20115 @subsection SPARC VIS Built-in Functions
20117 GCC supports SIMD operations on the SPARC using both the generic vector
20118 extensions (@pxref{Vector Extensions}) as well as built-in functions for
20119 the SPARC Visual Instruction Set (VIS).  When you use the @option{-mvis}
20120 switch, the VIS extension is exposed as the following built-in functions:
20122 @smallexample
20123 typedef int v1si __attribute__ ((vector_size (4)));
20124 typedef int v2si __attribute__ ((vector_size (8)));
20125 typedef short v4hi __attribute__ ((vector_size (8)));
20126 typedef short v2hi __attribute__ ((vector_size (4)));
20127 typedef unsigned char v8qi __attribute__ ((vector_size (8)));
20128 typedef unsigned char v4qi __attribute__ ((vector_size (4)));
20130 void __builtin_vis_write_gsr (int64_t);
20131 int64_t __builtin_vis_read_gsr (void);
20133 void * __builtin_vis_alignaddr (void *, long);
20134 void * __builtin_vis_alignaddrl (void *, long);
20135 int64_t __builtin_vis_faligndatadi (int64_t, int64_t);
20136 v2si __builtin_vis_faligndatav2si (v2si, v2si);
20137 v4hi __builtin_vis_faligndatav4hi (v4si, v4si);
20138 v8qi __builtin_vis_faligndatav8qi (v8qi, v8qi);
20140 v4hi __builtin_vis_fexpand (v4qi);
20142 v4hi __builtin_vis_fmul8x16 (v4qi, v4hi);
20143 v4hi __builtin_vis_fmul8x16au (v4qi, v2hi);
20144 v4hi __builtin_vis_fmul8x16al (v4qi, v2hi);
20145 v4hi __builtin_vis_fmul8sux16 (v8qi, v4hi);
20146 v4hi __builtin_vis_fmul8ulx16 (v8qi, v4hi);
20147 v2si __builtin_vis_fmuld8sux16 (v4qi, v2hi);
20148 v2si __builtin_vis_fmuld8ulx16 (v4qi, v2hi);
20150 v4qi __builtin_vis_fpack16 (v4hi);
20151 v8qi __builtin_vis_fpack32 (v2si, v8qi);
20152 v2hi __builtin_vis_fpackfix (v2si);
20153 v8qi __builtin_vis_fpmerge (v4qi, v4qi);
20155 int64_t __builtin_vis_pdist (v8qi, v8qi, int64_t);
20157 long __builtin_vis_edge8 (void *, void *);
20158 long __builtin_vis_edge8l (void *, void *);
20159 long __builtin_vis_edge16 (void *, void *);
20160 long __builtin_vis_edge16l (void *, void *);
20161 long __builtin_vis_edge32 (void *, void *);
20162 long __builtin_vis_edge32l (void *, void *);
20164 long __builtin_vis_fcmple16 (v4hi, v4hi);
20165 long __builtin_vis_fcmple32 (v2si, v2si);
20166 long __builtin_vis_fcmpne16 (v4hi, v4hi);
20167 long __builtin_vis_fcmpne32 (v2si, v2si);
20168 long __builtin_vis_fcmpgt16 (v4hi, v4hi);
20169 long __builtin_vis_fcmpgt32 (v2si, v2si);
20170 long __builtin_vis_fcmpeq16 (v4hi, v4hi);
20171 long __builtin_vis_fcmpeq32 (v2si, v2si);
20173 v4hi __builtin_vis_fpadd16 (v4hi, v4hi);
20174 v2hi __builtin_vis_fpadd16s (v2hi, v2hi);
20175 v2si __builtin_vis_fpadd32 (v2si, v2si);
20176 v1si __builtin_vis_fpadd32s (v1si, v1si);
20177 v4hi __builtin_vis_fpsub16 (v4hi, v4hi);
20178 v2hi __builtin_vis_fpsub16s (v2hi, v2hi);
20179 v2si __builtin_vis_fpsub32 (v2si, v2si);
20180 v1si __builtin_vis_fpsub32s (v1si, v1si);
20182 long __builtin_vis_array8 (long, long);
20183 long __builtin_vis_array16 (long, long);
20184 long __builtin_vis_array32 (long, long);
20185 @end smallexample
20187 When you use the @option{-mvis2} switch, the VIS version 2.0 built-in
20188 functions also become available:
20190 @smallexample
20191 long __builtin_vis_bmask (long, long);
20192 int64_t __builtin_vis_bshuffledi (int64_t, int64_t);
20193 v2si __builtin_vis_bshufflev2si (v2si, v2si);
20194 v4hi __builtin_vis_bshufflev2si (v4hi, v4hi);
20195 v8qi __builtin_vis_bshufflev2si (v8qi, v8qi);
20197 long __builtin_vis_edge8n (void *, void *);
20198 long __builtin_vis_edge8ln (void *, void *);
20199 long __builtin_vis_edge16n (void *, void *);
20200 long __builtin_vis_edge16ln (void *, void *);
20201 long __builtin_vis_edge32n (void *, void *);
20202 long __builtin_vis_edge32ln (void *, void *);
20203 @end smallexample
20205 When you use the @option{-mvis3} switch, the VIS version 3.0 built-in
20206 functions also become available:
20208 @smallexample
20209 void __builtin_vis_cmask8 (long);
20210 void __builtin_vis_cmask16 (long);
20211 void __builtin_vis_cmask32 (long);
20213 v4hi __builtin_vis_fchksm16 (v4hi, v4hi);
20215 v4hi __builtin_vis_fsll16 (v4hi, v4hi);
20216 v4hi __builtin_vis_fslas16 (v4hi, v4hi);
20217 v4hi __builtin_vis_fsrl16 (v4hi, v4hi);
20218 v4hi __builtin_vis_fsra16 (v4hi, v4hi);
20219 v2si __builtin_vis_fsll16 (v2si, v2si);
20220 v2si __builtin_vis_fslas16 (v2si, v2si);
20221 v2si __builtin_vis_fsrl16 (v2si, v2si);
20222 v2si __builtin_vis_fsra16 (v2si, v2si);
20224 long __builtin_vis_pdistn (v8qi, v8qi);
20226 v4hi __builtin_vis_fmean16 (v4hi, v4hi);
20228 int64_t __builtin_vis_fpadd64 (int64_t, int64_t);
20229 int64_t __builtin_vis_fpsub64 (int64_t, int64_t);
20231 v4hi __builtin_vis_fpadds16 (v4hi, v4hi);
20232 v2hi __builtin_vis_fpadds16s (v2hi, v2hi);
20233 v4hi __builtin_vis_fpsubs16 (v4hi, v4hi);
20234 v2hi __builtin_vis_fpsubs16s (v2hi, v2hi);
20235 v2si __builtin_vis_fpadds32 (v2si, v2si);
20236 v1si __builtin_vis_fpadds32s (v1si, v1si);
20237 v2si __builtin_vis_fpsubs32 (v2si, v2si);
20238 v1si __builtin_vis_fpsubs32s (v1si, v1si);
20240 long __builtin_vis_fucmple8 (v8qi, v8qi);
20241 long __builtin_vis_fucmpne8 (v8qi, v8qi);
20242 long __builtin_vis_fucmpgt8 (v8qi, v8qi);
20243 long __builtin_vis_fucmpeq8 (v8qi, v8qi);
20245 float __builtin_vis_fhadds (float, float);
20246 double __builtin_vis_fhaddd (double, double);
20247 float __builtin_vis_fhsubs (float, float);
20248 double __builtin_vis_fhsubd (double, double);
20249 float __builtin_vis_fnhadds (float, float);
20250 double __builtin_vis_fnhaddd (double, double);
20252 int64_t __builtin_vis_umulxhi (int64_t, int64_t);
20253 int64_t __builtin_vis_xmulx (int64_t, int64_t);
20254 int64_t __builtin_vis_xmulxhi (int64_t, int64_t);
20255 @end smallexample
20257 When you use the @option{-mvis4} switch, the VIS version 4.0 built-in
20258 functions also become available:
20260 @smallexample
20261 v8qi __builtin_vis_fpadd8 (v8qi, v8qi);
20262 v8qi __builtin_vis_fpadds8 (v8qi, v8qi);
20263 v8qi __builtin_vis_fpaddus8 (v8qi, v8qi);
20264 v4hi __builtin_vis_fpaddus16 (v4hi, v4hi);
20266 v8qi __builtin_vis_fpsub8 (v8qi, v8qi);
20267 v8qi __builtin_vis_fpsubs8 (v8qi, v8qi);
20268 v8qi __builtin_vis_fpsubus8 (v8qi, v8qi);
20269 v4hi __builtin_vis_fpsubus16 (v4hi, v4hi);
20271 long __builtin_vis_fpcmple8 (v8qi, v8qi);
20272 long __builtin_vis_fpcmpgt8 (v8qi, v8qi);
20273 long __builtin_vis_fpcmpule16 (v4hi, v4hi);
20274 long __builtin_vis_fpcmpugt16 (v4hi, v4hi);
20275 long __builtin_vis_fpcmpule32 (v2si, v2si);
20276 long __builtin_vis_fpcmpugt32 (v2si, v2si);
20278 v8qi __builtin_vis_fpmax8 (v8qi, v8qi);
20279 v4hi __builtin_vis_fpmax16 (v4hi, v4hi);
20280 v2si __builtin_vis_fpmax32 (v2si, v2si);
20282 v8qi __builtin_vis_fpmaxu8 (v8qi, v8qi);
20283 v4hi __builtin_vis_fpmaxu16 (v4hi, v4hi);
20284 v2si __builtin_vis_fpmaxu32 (v2si, v2si);
20287 v8qi __builtin_vis_fpmin8 (v8qi, v8qi);
20288 v4hi __builtin_vis_fpmin16 (v4hi, v4hi);
20289 v2si __builtin_vis_fpmin32 (v2si, v2si);
20291 v8qi __builtin_vis_fpminu8 (v8qi, v8qi);
20292 v4hi __builtin_vis_fpminu16 (v4hi, v4hi);
20293 v2si __builtin_vis_fpminu32 (v2si, v2si);
20294 @end smallexample
20296 When you use the @option{-mvis4b} switch, the VIS version 4.0B
20297 built-in functions also become available:
20299 @smallexample
20300 v8qi __builtin_vis_dictunpack8 (double, int);
20301 v4hi __builtin_vis_dictunpack16 (double, int);
20302 v2si __builtin_vis_dictunpack32 (double, int);
20304 long __builtin_vis_fpcmple8shl (v8qi, v8qi, int);
20305 long __builtin_vis_fpcmpgt8shl (v8qi, v8qi, int);
20306 long __builtin_vis_fpcmpeq8shl (v8qi, v8qi, int);
20307 long __builtin_vis_fpcmpne8shl (v8qi, v8qi, int);
20309 long __builtin_vis_fpcmple16shl (v4hi, v4hi, int);
20310 long __builtin_vis_fpcmpgt16shl (v4hi, v4hi, int);
20311 long __builtin_vis_fpcmpeq16shl (v4hi, v4hi, int);
20312 long __builtin_vis_fpcmpne16shl (v4hi, v4hi, int);
20314 long __builtin_vis_fpcmple32shl (v2si, v2si, int);
20315 long __builtin_vis_fpcmpgt32shl (v2si, v2si, int);
20316 long __builtin_vis_fpcmpeq32shl (v2si, v2si, int);
20317 long __builtin_vis_fpcmpne32shl (v2si, v2si, int);
20319 long __builtin_vis_fpcmpule8shl (v8qi, v8qi, int);
20320 long __builtin_vis_fpcmpugt8shl (v8qi, v8qi, int);
20321 long __builtin_vis_fpcmpule16shl (v4hi, v4hi, int);
20322 long __builtin_vis_fpcmpugt16shl (v4hi, v4hi, int);
20323 long __builtin_vis_fpcmpule32shl (v2si, v2si, int);
20324 long __builtin_vis_fpcmpugt32shl (v2si, v2si, int);
20326 long __builtin_vis_fpcmpde8shl (v8qi, v8qi, int);
20327 long __builtin_vis_fpcmpde16shl (v4hi, v4hi, int);
20328 long __builtin_vis_fpcmpde32shl (v2si, v2si, int);
20330 long __builtin_vis_fpcmpur8shl (v8qi, v8qi, int);
20331 long __builtin_vis_fpcmpur16shl (v4hi, v4hi, int);
20332 long __builtin_vis_fpcmpur32shl (v2si, v2si, int);
20333 @end smallexample
20335 @node SPU Built-in Functions
20336 @subsection SPU Built-in Functions
20338 GCC provides extensions for the SPU processor as described in the
20339 Sony/Toshiba/IBM SPU Language Extensions Specification.  GCC's
20340 implementation differs in several ways.
20342 @itemize @bullet
20344 @item
20345 The optional extension of specifying vector constants in parentheses is
20346 not supported.
20348 @item
20349 A vector initializer requires no cast if the vector constant is of the
20350 same type as the variable it is initializing.
20352 @item
20353 If @code{signed} or @code{unsigned} is omitted, the signedness of the
20354 vector type is the default signedness of the base type.  The default
20355 varies depending on the operating system, so a portable program should
20356 always specify the signedness.
20358 @item
20359 By default, the keyword @code{__vector} is added. The macro
20360 @code{vector} is defined in @code{<spu_intrinsics.h>} and can be
20361 undefined.
20363 @item
20364 GCC allows using a @code{typedef} name as the type specifier for a
20365 vector type.
20367 @item
20368 For C, overloaded functions are implemented with macros so the following
20369 does not work:
20371 @smallexample
20372   spu_add ((vector signed int)@{1, 2, 3, 4@}, foo);
20373 @end smallexample
20375 @noindent
20376 Since @code{spu_add} is a macro, the vector constant in the example
20377 is treated as four separate arguments.  Wrap the entire argument in
20378 parentheses for this to work.
20380 @item
20381 The extended version of @code{__builtin_expect} is not supported.
20383 @end itemize
20385 @emph{Note:} Only the interface described in the aforementioned
20386 specification is supported. Internally, GCC uses built-in functions to
20387 implement the required functionality, but these are not supported and
20388 are subject to change without notice.
20390 @node TI C6X Built-in Functions
20391 @subsection TI C6X Built-in Functions
20393 GCC provides intrinsics to access certain instructions of the TI C6X
20394 processors.  These intrinsics, listed below, are available after
20395 inclusion of the @code{c6x_intrinsics.h} header file.  They map directly
20396 to C6X instructions.
20398 @smallexample
20400 int _sadd (int, int)
20401 int _ssub (int, int)
20402 int _sadd2 (int, int)
20403 int _ssub2 (int, int)
20404 long long _mpy2 (int, int)
20405 long long _smpy2 (int, int)
20406 int _add4 (int, int)
20407 int _sub4 (int, int)
20408 int _saddu4 (int, int)
20410 int _smpy (int, int)
20411 int _smpyh (int, int)
20412 int _smpyhl (int, int)
20413 int _smpylh (int, int)
20415 int _sshl (int, int)
20416 int _subc (int, int)
20418 int _avg2 (int, int)
20419 int _avgu4 (int, int)
20421 int _clrr (int, int)
20422 int _extr (int, int)
20423 int _extru (int, int)
20424 int _abs (int)
20425 int _abs2 (int)
20427 @end smallexample
20429 @node TILE-Gx Built-in Functions
20430 @subsection TILE-Gx Built-in Functions
20432 GCC provides intrinsics to access every instruction of the TILE-Gx
20433 processor.  The intrinsics are of the form:
20435 @smallexample
20437 unsigned long long __insn_@var{op} (...)
20439 @end smallexample
20441 Where @var{op} is the name of the instruction.  Refer to the ISA manual
20442 for the complete list of instructions.
20444 GCC also provides intrinsics to directly access the network registers.
20445 The intrinsics are:
20447 @smallexample
20449 unsigned long long __tile_idn0_receive (void)
20450 unsigned long long __tile_idn1_receive (void)
20451 unsigned long long __tile_udn0_receive (void)
20452 unsigned long long __tile_udn1_receive (void)
20453 unsigned long long __tile_udn2_receive (void)
20454 unsigned long long __tile_udn3_receive (void)
20455 void __tile_idn_send (unsigned long long)
20456 void __tile_udn_send (unsigned long long)
20458 @end smallexample
20460 The intrinsic @code{void __tile_network_barrier (void)} is used to
20461 guarantee that no network operations before it are reordered with
20462 those after it.
20464 @node TILEPro Built-in Functions
20465 @subsection TILEPro Built-in Functions
20467 GCC provides intrinsics to access every instruction of the TILEPro
20468 processor.  The intrinsics are of the form:
20470 @smallexample
20472 unsigned __insn_@var{op} (...)
20474 @end smallexample
20476 @noindent
20477 where @var{op} is the name of the instruction.  Refer to the ISA manual
20478 for the complete list of instructions.
20480 GCC also provides intrinsics to directly access the network registers.
20481 The intrinsics are:
20483 @smallexample
20485 unsigned __tile_idn0_receive (void)
20486 unsigned __tile_idn1_receive (void)
20487 unsigned __tile_sn_receive (void)
20488 unsigned __tile_udn0_receive (void)
20489 unsigned __tile_udn1_receive (void)
20490 unsigned __tile_udn2_receive (void)
20491 unsigned __tile_udn3_receive (void)
20492 void __tile_idn_send (unsigned)
20493 void __tile_sn_send (unsigned)
20494 void __tile_udn_send (unsigned)
20496 @end smallexample
20498 The intrinsic @code{void __tile_network_barrier (void)} is used to
20499 guarantee that no network operations before it are reordered with
20500 those after it.
20502 @node x86 Built-in Functions
20503 @subsection x86 Built-in Functions
20505 These built-in functions are available for the x86-32 and x86-64 family
20506 of computers, depending on the command-line switches used.
20508 If you specify command-line switches such as @option{-msse},
20509 the compiler could use the extended instruction sets even if the built-ins
20510 are not used explicitly in the program.  For this reason, applications
20511 that perform run-time CPU detection must compile separate files for each
20512 supported architecture, using the appropriate flags.  In particular,
20513 the file containing the CPU detection code should be compiled without
20514 these options.
20516 The following machine modes are available for use with MMX built-in functions
20517 (@pxref{Vector Extensions}): @code{V2SI} for a vector of two 32-bit integers,
20518 @code{V4HI} for a vector of four 16-bit integers, and @code{V8QI} for a
20519 vector of eight 8-bit integers.  Some of the built-in functions operate on
20520 MMX registers as a whole 64-bit entity, these use @code{V1DI} as their mode.
20522 If 3DNow!@: extensions are enabled, @code{V2SF} is used as a mode for a vector
20523 of two 32-bit floating-point values.
20525 If SSE extensions are enabled, @code{V4SF} is used for a vector of four 32-bit
20526 floating-point values.  Some instructions use a vector of four 32-bit
20527 integers, these use @code{V4SI}.  Finally, some instructions operate on an
20528 entire vector register, interpreting it as a 128-bit integer, these use mode
20529 @code{TI}.
20531 The x86-32 and x86-64 family of processors use additional built-in
20532 functions for efficient use of @code{TF} (@code{__float128}) 128-bit
20533 floating point and @code{TC} 128-bit complex floating-point values.
20535 The following floating-point built-in functions are always available.  All
20536 of them implement the function that is part of the name.
20538 @smallexample
20539 __float128 __builtin_fabsq (__float128)
20540 __float128 __builtin_copysignq (__float128, __float128)
20541 @end smallexample
20543 The following built-in functions are always available.
20545 @table @code
20546 @item __float128 __builtin_infq (void)
20547 Similar to @code{__builtin_inf}, except the return type is @code{__float128}.
20548 @findex __builtin_infq
20550 @item __float128 __builtin_huge_valq (void)
20551 Similar to @code{__builtin_huge_val}, except the return type is @code{__float128}.
20552 @findex __builtin_huge_valq
20554 @item __float128 __builtin_nanq (void)
20555 Similar to @code{__builtin_nan}, except the return type is @code{__float128}.
20556 @findex __builtin_nanq
20558 @item __float128 __builtin_nansq (void)
20559 Similar to @code{__builtin_nans}, except the return type is @code{__float128}.
20560 @findex __builtin_nansq
20561 @end table
20563 The following built-in function is always available.
20565 @table @code
20566 @item void __builtin_ia32_pause (void)
20567 Generates the @code{pause} machine instruction with a compiler memory
20568 barrier.
20569 @end table
20571 The following built-in functions are always available and can be used to
20572 check the target platform type.
20574 @deftypefn {Built-in Function} void __builtin_cpu_init (void)
20575 This function runs the CPU detection code to check the type of CPU and the
20576 features supported.  This built-in function needs to be invoked along with the built-in functions
20577 to check CPU type and features, @code{__builtin_cpu_is} and
20578 @code{__builtin_cpu_supports}, only when used in a function that is
20579 executed before any constructors are called.  The CPU detection code is
20580 automatically executed in a very high priority constructor.
20582 For example, this function has to be used in @code{ifunc} resolvers that
20583 check for CPU type using the built-in functions @code{__builtin_cpu_is}
20584 and @code{__builtin_cpu_supports}, or in constructors on targets that
20585 don't support constructor priority.
20586 @smallexample
20588 static void (*resolve_memcpy (void)) (void)
20590   // ifunc resolvers fire before constructors, explicitly call the init
20591   // function.
20592   __builtin_cpu_init ();
20593   if (__builtin_cpu_supports ("ssse3"))
20594     return ssse3_memcpy; // super fast memcpy with ssse3 instructions.
20595   else
20596     return default_memcpy;
20599 void *memcpy (void *, const void *, size_t)
20600      __attribute__ ((ifunc ("resolve_memcpy")));
20601 @end smallexample
20603 @end deftypefn
20605 @deftypefn {Built-in Function} int __builtin_cpu_is (const char *@var{cpuname})
20606 This function returns a positive integer if the run-time CPU
20607 is of type @var{cpuname}
20608 and returns @code{0} otherwise. The following CPU names can be detected:
20610 @table @samp
20611 @item amd
20612 AMD CPU.
20614 @item intel
20615 Intel CPU.
20617 @item atom
20618 Intel Atom CPU.
20620 @item slm
20621 Intel Silvermont CPU.
20623 @item core2
20624 Intel Core 2 CPU.
20626 @item corei7
20627 Intel Core i7 CPU.
20629 @item nehalem
20630 Intel Core i7 Nehalem CPU.
20632 @item westmere
20633 Intel Core i7 Westmere CPU.
20635 @item sandybridge
20636 Intel Core i7 Sandy Bridge CPU.
20638 @item ivybridge
20639 Intel Core i7 Ivy Bridge CPU.
20641 @item haswell
20642 Intel Core i7 Haswell CPU.
20644 @item broadwell
20645 Intel Core i7 Broadwell CPU.
20647 @item skylake
20648 Intel Core i7 Skylake CPU.
20650 @item skylake-avx512
20651 Intel Core i7 Skylake AVX512 CPU.
20653 @item cannonlake
20654 Intel Core i7 Cannon Lake CPU.
20656 @item icelake-client
20657 Intel Core i7 Ice Lake Client CPU.
20659 @item icelake-server
20660 Intel Core i7 Ice Lake Server CPU.
20662 @item bonnell
20663 Intel Atom Bonnell CPU.
20665 @item silvermont
20666 Intel Atom Silvermont CPU.
20668 @item goldmont
20669 Intel Atom Goldmont CPU.
20671 @item goldmont-plus
20672 Intel Atom Goldmont Plus CPU.
20674 @item tremont
20675 Intel Atom Tremont CPU.
20677 @item knl
20678 Intel Knights Landing CPU.
20680 @item knm
20681 Intel Knights Mill CPU.
20683 @item amdfam10h
20684 AMD Family 10h CPU.
20686 @item barcelona
20687 AMD Family 10h Barcelona CPU.
20689 @item shanghai
20690 AMD Family 10h Shanghai CPU.
20692 @item istanbul
20693 AMD Family 10h Istanbul CPU.
20695 @item btver1
20696 AMD Family 14h CPU.
20698 @item amdfam15h
20699 AMD Family 15h CPU.
20701 @item bdver1
20702 AMD Family 15h Bulldozer version 1.
20704 @item bdver2
20705 AMD Family 15h Bulldozer version 2.
20707 @item bdver3
20708 AMD Family 15h Bulldozer version 3.
20710 @item bdver4
20711 AMD Family 15h Bulldozer version 4.
20713 @item btver2
20714 AMD Family 16h CPU.
20716 @item amdfam17h
20717 AMD Family 17h CPU.
20719 @item znver1
20720 AMD Family 17h Zen version 1.
20722 @item znver2
20723 AMD Family 17h Zen version 2.
20724 @end table
20726 Here is an example:
20727 @smallexample
20728 if (__builtin_cpu_is ("corei7"))
20729   @{
20730      do_corei7 (); // Core i7 specific implementation.
20731   @}
20732 else
20733   @{
20734      do_generic (); // Generic implementation.
20735   @}
20736 @end smallexample
20737 @end deftypefn
20739 @deftypefn {Built-in Function} int __builtin_cpu_supports (const char *@var{feature})
20740 This function returns a positive integer if the run-time CPU
20741 supports @var{feature}
20742 and returns @code{0} otherwise. The following features can be detected:
20744 @table @samp
20745 @item cmov
20746 CMOV instruction.
20747 @item mmx
20748 MMX instructions.
20749 @item popcnt
20750 POPCNT instruction.
20751 @item sse
20752 SSE instructions.
20753 @item sse2
20754 SSE2 instructions.
20755 @item sse3
20756 SSE3 instructions.
20757 @item ssse3
20758 SSSE3 instructions.
20759 @item sse4.1
20760 SSE4.1 instructions.
20761 @item sse4.2
20762 SSE4.2 instructions.
20763 @item avx
20764 AVX instructions.
20765 @item avx2
20766 AVX2 instructions.
20767 @item sse4a
20768 SSE4A instructions.
20769 @item fma4
20770 FMA4 instructions.
20771 @item xop
20772 XOP instructions.
20773 @item fma
20774 FMA instructions.
20775 @item avx512f
20776 AVX512F instructions.
20777 @item bmi
20778 BMI instructions.
20779 @item bmi2
20780 BMI2 instructions.
20781 @item aes
20782 AES instructions.
20783 @item pclmul
20784 PCLMUL instructions.
20785 @item avx512vl
20786 AVX512VL instructions.
20787 @item avx512bw
20788 AVX512BW instructions.
20789 @item avx512dq
20790 AVX512DQ instructions.
20791 @item avx512cd
20792 AVX512CD instructions.
20793 @item avx512er
20794 AVX512ER instructions.
20795 @item avx512pf
20796 AVX512PF instructions.
20797 @item avx512vbmi
20798 AVX512VBMI instructions.
20799 @item avx512ifma
20800 AVX512IFMA instructions.
20801 @item avx5124vnniw
20802 AVX5124VNNIW instructions.
20803 @item avx5124fmaps
20804 AVX5124FMAPS instructions.
20805 @item avx512vpopcntdq
20806 AVX512VPOPCNTDQ instructions.
20807 @item avx512vbmi2
20808 AVX512VBMI2 instructions.
20809 @item gfni
20810 GFNI instructions.
20811 @item vpclmulqdq
20812 VPCLMULQDQ instructions.
20813 @item avx512vnni
20814 AVX512VNNI instructions.
20815 @item avx512bitalg
20816 AVX512BITALG instructions.
20817 @end table
20819 Here is an example:
20820 @smallexample
20821 if (__builtin_cpu_supports ("popcnt"))
20822   @{
20823      asm("popcnt %1,%0" : "=r"(count) : "rm"(n) : "cc");
20824   @}
20825 else
20826   @{
20827      count = generic_countbits (n); //generic implementation.
20828   @}
20829 @end smallexample
20830 @end deftypefn
20833 The following built-in functions are made available by @option{-mmmx}.
20834 All of them generate the machine instruction that is part of the name.
20836 @smallexample
20837 v8qi __builtin_ia32_paddb (v8qi, v8qi)
20838 v4hi __builtin_ia32_paddw (v4hi, v4hi)
20839 v2si __builtin_ia32_paddd (v2si, v2si)
20840 v8qi __builtin_ia32_psubb (v8qi, v8qi)
20841 v4hi __builtin_ia32_psubw (v4hi, v4hi)
20842 v2si __builtin_ia32_psubd (v2si, v2si)
20843 v8qi __builtin_ia32_paddsb (v8qi, v8qi)
20844 v4hi __builtin_ia32_paddsw (v4hi, v4hi)
20845 v8qi __builtin_ia32_psubsb (v8qi, v8qi)
20846 v4hi __builtin_ia32_psubsw (v4hi, v4hi)
20847 v8qi __builtin_ia32_paddusb (v8qi, v8qi)
20848 v4hi __builtin_ia32_paddusw (v4hi, v4hi)
20849 v8qi __builtin_ia32_psubusb (v8qi, v8qi)
20850 v4hi __builtin_ia32_psubusw (v4hi, v4hi)
20851 v4hi __builtin_ia32_pmullw (v4hi, v4hi)
20852 v4hi __builtin_ia32_pmulhw (v4hi, v4hi)
20853 di __builtin_ia32_pand (di, di)
20854 di __builtin_ia32_pandn (di,di)
20855 di __builtin_ia32_por (di, di)
20856 di __builtin_ia32_pxor (di, di)
20857 v8qi __builtin_ia32_pcmpeqb (v8qi, v8qi)
20858 v4hi __builtin_ia32_pcmpeqw (v4hi, v4hi)
20859 v2si __builtin_ia32_pcmpeqd (v2si, v2si)
20860 v8qi __builtin_ia32_pcmpgtb (v8qi, v8qi)
20861 v4hi __builtin_ia32_pcmpgtw (v4hi, v4hi)
20862 v2si __builtin_ia32_pcmpgtd (v2si, v2si)
20863 v8qi __builtin_ia32_punpckhbw (v8qi, v8qi)
20864 v4hi __builtin_ia32_punpckhwd (v4hi, v4hi)
20865 v2si __builtin_ia32_punpckhdq (v2si, v2si)
20866 v8qi __builtin_ia32_punpcklbw (v8qi, v8qi)
20867 v4hi __builtin_ia32_punpcklwd (v4hi, v4hi)
20868 v2si __builtin_ia32_punpckldq (v2si, v2si)
20869 v8qi __builtin_ia32_packsswb (v4hi, v4hi)
20870 v4hi __builtin_ia32_packssdw (v2si, v2si)
20871 v8qi __builtin_ia32_packuswb (v4hi, v4hi)
20873 v4hi __builtin_ia32_psllw (v4hi, v4hi)
20874 v2si __builtin_ia32_pslld (v2si, v2si)
20875 v1di __builtin_ia32_psllq (v1di, v1di)
20876 v4hi __builtin_ia32_psrlw (v4hi, v4hi)
20877 v2si __builtin_ia32_psrld (v2si, v2si)
20878 v1di __builtin_ia32_psrlq (v1di, v1di)
20879 v4hi __builtin_ia32_psraw (v4hi, v4hi)
20880 v2si __builtin_ia32_psrad (v2si, v2si)
20881 v4hi __builtin_ia32_psllwi (v4hi, int)
20882 v2si __builtin_ia32_pslldi (v2si, int)
20883 v1di __builtin_ia32_psllqi (v1di, int)
20884 v4hi __builtin_ia32_psrlwi (v4hi, int)
20885 v2si __builtin_ia32_psrldi (v2si, int)
20886 v1di __builtin_ia32_psrlqi (v1di, int)
20887 v4hi __builtin_ia32_psrawi (v4hi, int)
20888 v2si __builtin_ia32_psradi (v2si, int)
20890 @end smallexample
20892 The following built-in functions are made available either with
20893 @option{-msse}, or with @option{-m3dnowa}.  All of them generate
20894 the machine instruction that is part of the name.
20896 @smallexample
20897 v4hi __builtin_ia32_pmulhuw (v4hi, v4hi)
20898 v8qi __builtin_ia32_pavgb (v8qi, v8qi)
20899 v4hi __builtin_ia32_pavgw (v4hi, v4hi)
20900 v1di __builtin_ia32_psadbw (v8qi, v8qi)
20901 v8qi __builtin_ia32_pmaxub (v8qi, v8qi)
20902 v4hi __builtin_ia32_pmaxsw (v4hi, v4hi)
20903 v8qi __builtin_ia32_pminub (v8qi, v8qi)
20904 v4hi __builtin_ia32_pminsw (v4hi, v4hi)
20905 int __builtin_ia32_pmovmskb (v8qi)
20906 void __builtin_ia32_maskmovq (v8qi, v8qi, char *)
20907 void __builtin_ia32_movntq (di *, di)
20908 void __builtin_ia32_sfence (void)
20909 @end smallexample
20911 The following built-in functions are available when @option{-msse} is used.
20912 All of them generate the machine instruction that is part of the name.
20914 @smallexample
20915 int __builtin_ia32_comieq (v4sf, v4sf)
20916 int __builtin_ia32_comineq (v4sf, v4sf)
20917 int __builtin_ia32_comilt (v4sf, v4sf)
20918 int __builtin_ia32_comile (v4sf, v4sf)
20919 int __builtin_ia32_comigt (v4sf, v4sf)
20920 int __builtin_ia32_comige (v4sf, v4sf)
20921 int __builtin_ia32_ucomieq (v4sf, v4sf)
20922 int __builtin_ia32_ucomineq (v4sf, v4sf)
20923 int __builtin_ia32_ucomilt (v4sf, v4sf)
20924 int __builtin_ia32_ucomile (v4sf, v4sf)
20925 int __builtin_ia32_ucomigt (v4sf, v4sf)
20926 int __builtin_ia32_ucomige (v4sf, v4sf)
20927 v4sf __builtin_ia32_addps (v4sf, v4sf)
20928 v4sf __builtin_ia32_subps (v4sf, v4sf)
20929 v4sf __builtin_ia32_mulps (v4sf, v4sf)
20930 v4sf __builtin_ia32_divps (v4sf, v4sf)
20931 v4sf __builtin_ia32_addss (v4sf, v4sf)
20932 v4sf __builtin_ia32_subss (v4sf, v4sf)
20933 v4sf __builtin_ia32_mulss (v4sf, v4sf)
20934 v4sf __builtin_ia32_divss (v4sf, v4sf)
20935 v4sf __builtin_ia32_cmpeqps (v4sf, v4sf)
20936 v4sf __builtin_ia32_cmpltps (v4sf, v4sf)
20937 v4sf __builtin_ia32_cmpleps (v4sf, v4sf)
20938 v4sf __builtin_ia32_cmpgtps (v4sf, v4sf)
20939 v4sf __builtin_ia32_cmpgeps (v4sf, v4sf)
20940 v4sf __builtin_ia32_cmpunordps (v4sf, v4sf)
20941 v4sf __builtin_ia32_cmpneqps (v4sf, v4sf)
20942 v4sf __builtin_ia32_cmpnltps (v4sf, v4sf)
20943 v4sf __builtin_ia32_cmpnleps (v4sf, v4sf)
20944 v4sf __builtin_ia32_cmpngtps (v4sf, v4sf)
20945 v4sf __builtin_ia32_cmpngeps (v4sf, v4sf)
20946 v4sf __builtin_ia32_cmpordps (v4sf, v4sf)
20947 v4sf __builtin_ia32_cmpeqss (v4sf, v4sf)
20948 v4sf __builtin_ia32_cmpltss (v4sf, v4sf)
20949 v4sf __builtin_ia32_cmpless (v4sf, v4sf)
20950 v4sf __builtin_ia32_cmpunordss (v4sf, v4sf)
20951 v4sf __builtin_ia32_cmpneqss (v4sf, v4sf)
20952 v4sf __builtin_ia32_cmpnltss (v4sf, v4sf)
20953 v4sf __builtin_ia32_cmpnless (v4sf, v4sf)
20954 v4sf __builtin_ia32_cmpordss (v4sf, v4sf)
20955 v4sf __builtin_ia32_maxps (v4sf, v4sf)
20956 v4sf __builtin_ia32_maxss (v4sf, v4sf)
20957 v4sf __builtin_ia32_minps (v4sf, v4sf)
20958 v4sf __builtin_ia32_minss (v4sf, v4sf)
20959 v4sf __builtin_ia32_andps (v4sf, v4sf)
20960 v4sf __builtin_ia32_andnps (v4sf, v4sf)
20961 v4sf __builtin_ia32_orps (v4sf, v4sf)
20962 v4sf __builtin_ia32_xorps (v4sf, v4sf)
20963 v4sf __builtin_ia32_movss (v4sf, v4sf)
20964 v4sf __builtin_ia32_movhlps (v4sf, v4sf)
20965 v4sf __builtin_ia32_movlhps (v4sf, v4sf)
20966 v4sf __builtin_ia32_unpckhps (v4sf, v4sf)
20967 v4sf __builtin_ia32_unpcklps (v4sf, v4sf)
20968 v4sf __builtin_ia32_cvtpi2ps (v4sf, v2si)
20969 v4sf __builtin_ia32_cvtsi2ss (v4sf, int)
20970 v2si __builtin_ia32_cvtps2pi (v4sf)
20971 int __builtin_ia32_cvtss2si (v4sf)
20972 v2si __builtin_ia32_cvttps2pi (v4sf)
20973 int __builtin_ia32_cvttss2si (v4sf)
20974 v4sf __builtin_ia32_rcpps (v4sf)
20975 v4sf __builtin_ia32_rsqrtps (v4sf)
20976 v4sf __builtin_ia32_sqrtps (v4sf)
20977 v4sf __builtin_ia32_rcpss (v4sf)
20978 v4sf __builtin_ia32_rsqrtss (v4sf)
20979 v4sf __builtin_ia32_sqrtss (v4sf)
20980 v4sf __builtin_ia32_shufps (v4sf, v4sf, int)
20981 void __builtin_ia32_movntps (float *, v4sf)
20982 int __builtin_ia32_movmskps (v4sf)
20983 @end smallexample
20985 The following built-in functions are available when @option{-msse} is used.
20987 @table @code
20988 @item v4sf __builtin_ia32_loadups (float *)
20989 Generates the @code{movups} machine instruction as a load from memory.
20990 @item void __builtin_ia32_storeups (float *, v4sf)
20991 Generates the @code{movups} machine instruction as a store to memory.
20992 @item v4sf __builtin_ia32_loadss (float *)
20993 Generates the @code{movss} machine instruction as a load from memory.
20994 @item v4sf __builtin_ia32_loadhps (v4sf, const v2sf *)
20995 Generates the @code{movhps} machine instruction as a load from memory.
20996 @item v4sf __builtin_ia32_loadlps (v4sf, const v2sf *)
20997 Generates the @code{movlps} machine instruction as a load from memory
20998 @item void __builtin_ia32_storehps (v2sf *, v4sf)
20999 Generates the @code{movhps} machine instruction as a store to memory.
21000 @item void __builtin_ia32_storelps (v2sf *, v4sf)
21001 Generates the @code{movlps} machine instruction as a store to memory.
21002 @end table
21004 The following built-in functions are available when @option{-msse2} is used.
21005 All of them generate the machine instruction that is part of the name.
21007 @smallexample
21008 int __builtin_ia32_comisdeq (v2df, v2df)
21009 int __builtin_ia32_comisdlt (v2df, v2df)
21010 int __builtin_ia32_comisdle (v2df, v2df)
21011 int __builtin_ia32_comisdgt (v2df, v2df)
21012 int __builtin_ia32_comisdge (v2df, v2df)
21013 int __builtin_ia32_comisdneq (v2df, v2df)
21014 int __builtin_ia32_ucomisdeq (v2df, v2df)
21015 int __builtin_ia32_ucomisdlt (v2df, v2df)
21016 int __builtin_ia32_ucomisdle (v2df, v2df)
21017 int __builtin_ia32_ucomisdgt (v2df, v2df)
21018 int __builtin_ia32_ucomisdge (v2df, v2df)
21019 int __builtin_ia32_ucomisdneq (v2df, v2df)
21020 v2df __builtin_ia32_cmpeqpd (v2df, v2df)
21021 v2df __builtin_ia32_cmpltpd (v2df, v2df)
21022 v2df __builtin_ia32_cmplepd (v2df, v2df)
21023 v2df __builtin_ia32_cmpgtpd (v2df, v2df)
21024 v2df __builtin_ia32_cmpgepd (v2df, v2df)
21025 v2df __builtin_ia32_cmpunordpd (v2df, v2df)
21026 v2df __builtin_ia32_cmpneqpd (v2df, v2df)
21027 v2df __builtin_ia32_cmpnltpd (v2df, v2df)
21028 v2df __builtin_ia32_cmpnlepd (v2df, v2df)
21029 v2df __builtin_ia32_cmpngtpd (v2df, v2df)
21030 v2df __builtin_ia32_cmpngepd (v2df, v2df)
21031 v2df __builtin_ia32_cmpordpd (v2df, v2df)
21032 v2df __builtin_ia32_cmpeqsd (v2df, v2df)
21033 v2df __builtin_ia32_cmpltsd (v2df, v2df)
21034 v2df __builtin_ia32_cmplesd (v2df, v2df)
21035 v2df __builtin_ia32_cmpunordsd (v2df, v2df)
21036 v2df __builtin_ia32_cmpneqsd (v2df, v2df)
21037 v2df __builtin_ia32_cmpnltsd (v2df, v2df)
21038 v2df __builtin_ia32_cmpnlesd (v2df, v2df)
21039 v2df __builtin_ia32_cmpordsd (v2df, v2df)
21040 v2di __builtin_ia32_paddq (v2di, v2di)
21041 v2di __builtin_ia32_psubq (v2di, v2di)
21042 v2df __builtin_ia32_addpd (v2df, v2df)
21043 v2df __builtin_ia32_subpd (v2df, v2df)
21044 v2df __builtin_ia32_mulpd (v2df, v2df)
21045 v2df __builtin_ia32_divpd (v2df, v2df)
21046 v2df __builtin_ia32_addsd (v2df, v2df)
21047 v2df __builtin_ia32_subsd (v2df, v2df)
21048 v2df __builtin_ia32_mulsd (v2df, v2df)
21049 v2df __builtin_ia32_divsd (v2df, v2df)
21050 v2df __builtin_ia32_minpd (v2df, v2df)
21051 v2df __builtin_ia32_maxpd (v2df, v2df)
21052 v2df __builtin_ia32_minsd (v2df, v2df)
21053 v2df __builtin_ia32_maxsd (v2df, v2df)
21054 v2df __builtin_ia32_andpd (v2df, v2df)
21055 v2df __builtin_ia32_andnpd (v2df, v2df)
21056 v2df __builtin_ia32_orpd (v2df, v2df)
21057 v2df __builtin_ia32_xorpd (v2df, v2df)
21058 v2df __builtin_ia32_movsd (v2df, v2df)
21059 v2df __builtin_ia32_unpckhpd (v2df, v2df)
21060 v2df __builtin_ia32_unpcklpd (v2df, v2df)
21061 v16qi __builtin_ia32_paddb128 (v16qi, v16qi)
21062 v8hi __builtin_ia32_paddw128 (v8hi, v8hi)
21063 v4si __builtin_ia32_paddd128 (v4si, v4si)
21064 v2di __builtin_ia32_paddq128 (v2di, v2di)
21065 v16qi __builtin_ia32_psubb128 (v16qi, v16qi)
21066 v8hi __builtin_ia32_psubw128 (v8hi, v8hi)
21067 v4si __builtin_ia32_psubd128 (v4si, v4si)
21068 v2di __builtin_ia32_psubq128 (v2di, v2di)
21069 v8hi __builtin_ia32_pmullw128 (v8hi, v8hi)
21070 v8hi __builtin_ia32_pmulhw128 (v8hi, v8hi)
21071 v2di __builtin_ia32_pand128 (v2di, v2di)
21072 v2di __builtin_ia32_pandn128 (v2di, v2di)
21073 v2di __builtin_ia32_por128 (v2di, v2di)
21074 v2di __builtin_ia32_pxor128 (v2di, v2di)
21075 v16qi __builtin_ia32_pavgb128 (v16qi, v16qi)
21076 v8hi __builtin_ia32_pavgw128 (v8hi, v8hi)
21077 v16qi __builtin_ia32_pcmpeqb128 (v16qi, v16qi)
21078 v8hi __builtin_ia32_pcmpeqw128 (v8hi, v8hi)
21079 v4si __builtin_ia32_pcmpeqd128 (v4si, v4si)
21080 v16qi __builtin_ia32_pcmpgtb128 (v16qi, v16qi)
21081 v8hi __builtin_ia32_pcmpgtw128 (v8hi, v8hi)
21082 v4si __builtin_ia32_pcmpgtd128 (v4si, v4si)
21083 v16qi __builtin_ia32_pmaxub128 (v16qi, v16qi)
21084 v8hi __builtin_ia32_pmaxsw128 (v8hi, v8hi)
21085 v16qi __builtin_ia32_pminub128 (v16qi, v16qi)
21086 v8hi __builtin_ia32_pminsw128 (v8hi, v8hi)
21087 v16qi __builtin_ia32_punpckhbw128 (v16qi, v16qi)
21088 v8hi __builtin_ia32_punpckhwd128 (v8hi, v8hi)
21089 v4si __builtin_ia32_punpckhdq128 (v4si, v4si)
21090 v2di __builtin_ia32_punpckhqdq128 (v2di, v2di)
21091 v16qi __builtin_ia32_punpcklbw128 (v16qi, v16qi)
21092 v8hi __builtin_ia32_punpcklwd128 (v8hi, v8hi)
21093 v4si __builtin_ia32_punpckldq128 (v4si, v4si)
21094 v2di __builtin_ia32_punpcklqdq128 (v2di, v2di)
21095 v16qi __builtin_ia32_packsswb128 (v8hi, v8hi)
21096 v8hi __builtin_ia32_packssdw128 (v4si, v4si)
21097 v16qi __builtin_ia32_packuswb128 (v8hi, v8hi)
21098 v8hi __builtin_ia32_pmulhuw128 (v8hi, v8hi)
21099 void __builtin_ia32_maskmovdqu (v16qi, v16qi)
21100 v2df __builtin_ia32_loadupd (double *)
21101 void __builtin_ia32_storeupd (double *, v2df)
21102 v2df __builtin_ia32_loadhpd (v2df, double const *)
21103 v2df __builtin_ia32_loadlpd (v2df, double const *)
21104 int __builtin_ia32_movmskpd (v2df)
21105 int __builtin_ia32_pmovmskb128 (v16qi)
21106 void __builtin_ia32_movnti (int *, int)
21107 void __builtin_ia32_movnti64 (long long int *, long long int)
21108 void __builtin_ia32_movntpd (double *, v2df)
21109 void __builtin_ia32_movntdq (v2df *, v2df)
21110 v4si __builtin_ia32_pshufd (v4si, int)
21111 v8hi __builtin_ia32_pshuflw (v8hi, int)
21112 v8hi __builtin_ia32_pshufhw (v8hi, int)
21113 v2di __builtin_ia32_psadbw128 (v16qi, v16qi)
21114 v2df __builtin_ia32_sqrtpd (v2df)
21115 v2df __builtin_ia32_sqrtsd (v2df)
21116 v2df __builtin_ia32_shufpd (v2df, v2df, int)
21117 v2df __builtin_ia32_cvtdq2pd (v4si)
21118 v4sf __builtin_ia32_cvtdq2ps (v4si)
21119 v4si __builtin_ia32_cvtpd2dq (v2df)
21120 v2si __builtin_ia32_cvtpd2pi (v2df)
21121 v4sf __builtin_ia32_cvtpd2ps (v2df)
21122 v4si __builtin_ia32_cvttpd2dq (v2df)
21123 v2si __builtin_ia32_cvttpd2pi (v2df)
21124 v2df __builtin_ia32_cvtpi2pd (v2si)
21125 int __builtin_ia32_cvtsd2si (v2df)
21126 int __builtin_ia32_cvttsd2si (v2df)
21127 long long __builtin_ia32_cvtsd2si64 (v2df)
21128 long long __builtin_ia32_cvttsd2si64 (v2df)
21129 v4si __builtin_ia32_cvtps2dq (v4sf)
21130 v2df __builtin_ia32_cvtps2pd (v4sf)
21131 v4si __builtin_ia32_cvttps2dq (v4sf)
21132 v2df __builtin_ia32_cvtsi2sd (v2df, int)
21133 v2df __builtin_ia32_cvtsi642sd (v2df, long long)
21134 v4sf __builtin_ia32_cvtsd2ss (v4sf, v2df)
21135 v2df __builtin_ia32_cvtss2sd (v2df, v4sf)
21136 void __builtin_ia32_clflush (const void *)
21137 void __builtin_ia32_lfence (void)
21138 void __builtin_ia32_mfence (void)
21139 v16qi __builtin_ia32_loaddqu (const char *)
21140 void __builtin_ia32_storedqu (char *, v16qi)
21141 v1di __builtin_ia32_pmuludq (v2si, v2si)
21142 v2di __builtin_ia32_pmuludq128 (v4si, v4si)
21143 v8hi __builtin_ia32_psllw128 (v8hi, v8hi)
21144 v4si __builtin_ia32_pslld128 (v4si, v4si)
21145 v2di __builtin_ia32_psllq128 (v2di, v2di)
21146 v8hi __builtin_ia32_psrlw128 (v8hi, v8hi)
21147 v4si __builtin_ia32_psrld128 (v4si, v4si)
21148 v2di __builtin_ia32_psrlq128 (v2di, v2di)
21149 v8hi __builtin_ia32_psraw128 (v8hi, v8hi)
21150 v4si __builtin_ia32_psrad128 (v4si, v4si)
21151 v2di __builtin_ia32_pslldqi128 (v2di, int)
21152 v8hi __builtin_ia32_psllwi128 (v8hi, int)
21153 v4si __builtin_ia32_pslldi128 (v4si, int)
21154 v2di __builtin_ia32_psllqi128 (v2di, int)
21155 v2di __builtin_ia32_psrldqi128 (v2di, int)
21156 v8hi __builtin_ia32_psrlwi128 (v8hi, int)
21157 v4si __builtin_ia32_psrldi128 (v4si, int)
21158 v2di __builtin_ia32_psrlqi128 (v2di, int)
21159 v8hi __builtin_ia32_psrawi128 (v8hi, int)
21160 v4si __builtin_ia32_psradi128 (v4si, int)
21161 v4si __builtin_ia32_pmaddwd128 (v8hi, v8hi)
21162 v2di __builtin_ia32_movq128 (v2di)
21163 @end smallexample
21165 The following built-in functions are available when @option{-msse3} is used.
21166 All of them generate the machine instruction that is part of the name.
21168 @smallexample
21169 v2df __builtin_ia32_addsubpd (v2df, v2df)
21170 v4sf __builtin_ia32_addsubps (v4sf, v4sf)
21171 v2df __builtin_ia32_haddpd (v2df, v2df)
21172 v4sf __builtin_ia32_haddps (v4sf, v4sf)
21173 v2df __builtin_ia32_hsubpd (v2df, v2df)
21174 v4sf __builtin_ia32_hsubps (v4sf, v4sf)
21175 v16qi __builtin_ia32_lddqu (char const *)
21176 void __builtin_ia32_monitor (void *, unsigned int, unsigned int)
21177 v4sf __builtin_ia32_movshdup (v4sf)
21178 v4sf __builtin_ia32_movsldup (v4sf)
21179 void __builtin_ia32_mwait (unsigned int, unsigned int)
21180 @end smallexample
21182 The following built-in functions are available when @option{-mssse3} is used.
21183 All of them generate the machine instruction that is part of the name.
21185 @smallexample
21186 v2si __builtin_ia32_phaddd (v2si, v2si)
21187 v4hi __builtin_ia32_phaddw (v4hi, v4hi)
21188 v4hi __builtin_ia32_phaddsw (v4hi, v4hi)
21189 v2si __builtin_ia32_phsubd (v2si, v2si)
21190 v4hi __builtin_ia32_phsubw (v4hi, v4hi)
21191 v4hi __builtin_ia32_phsubsw (v4hi, v4hi)
21192 v4hi __builtin_ia32_pmaddubsw (v8qi, v8qi)
21193 v4hi __builtin_ia32_pmulhrsw (v4hi, v4hi)
21194 v8qi __builtin_ia32_pshufb (v8qi, v8qi)
21195 v8qi __builtin_ia32_psignb (v8qi, v8qi)
21196 v2si __builtin_ia32_psignd (v2si, v2si)
21197 v4hi __builtin_ia32_psignw (v4hi, v4hi)
21198 v1di __builtin_ia32_palignr (v1di, v1di, int)
21199 v8qi __builtin_ia32_pabsb (v8qi)
21200 v2si __builtin_ia32_pabsd (v2si)
21201 v4hi __builtin_ia32_pabsw (v4hi)
21202 @end smallexample
21204 The following built-in functions are available when @option{-mssse3} is used.
21205 All of them generate the machine instruction that is part of the name.
21207 @smallexample
21208 v4si __builtin_ia32_phaddd128 (v4si, v4si)
21209 v8hi __builtin_ia32_phaddw128 (v8hi, v8hi)
21210 v8hi __builtin_ia32_phaddsw128 (v8hi, v8hi)
21211 v4si __builtin_ia32_phsubd128 (v4si, v4si)
21212 v8hi __builtin_ia32_phsubw128 (v8hi, v8hi)
21213 v8hi __builtin_ia32_phsubsw128 (v8hi, v8hi)
21214 v8hi __builtin_ia32_pmaddubsw128 (v16qi, v16qi)
21215 v8hi __builtin_ia32_pmulhrsw128 (v8hi, v8hi)
21216 v16qi __builtin_ia32_pshufb128 (v16qi, v16qi)
21217 v16qi __builtin_ia32_psignb128 (v16qi, v16qi)
21218 v4si __builtin_ia32_psignd128 (v4si, v4si)
21219 v8hi __builtin_ia32_psignw128 (v8hi, v8hi)
21220 v2di __builtin_ia32_palignr128 (v2di, v2di, int)
21221 v16qi __builtin_ia32_pabsb128 (v16qi)
21222 v4si __builtin_ia32_pabsd128 (v4si)
21223 v8hi __builtin_ia32_pabsw128 (v8hi)
21224 @end smallexample
21226 The following built-in functions are available when @option{-msse4.1} is
21227 used.  All of them generate the machine instruction that is part of the
21228 name.
21230 @smallexample
21231 v2df __builtin_ia32_blendpd (v2df, v2df, const int)
21232 v4sf __builtin_ia32_blendps (v4sf, v4sf, const int)
21233 v2df __builtin_ia32_blendvpd (v2df, v2df, v2df)
21234 v4sf __builtin_ia32_blendvps (v4sf, v4sf, v4sf)
21235 v2df __builtin_ia32_dppd (v2df, v2df, const int)
21236 v4sf __builtin_ia32_dpps (v4sf, v4sf, const int)
21237 v4sf __builtin_ia32_insertps128 (v4sf, v4sf, const int)
21238 v2di __builtin_ia32_movntdqa (v2di *);
21239 v16qi __builtin_ia32_mpsadbw128 (v16qi, v16qi, const int)
21240 v8hi __builtin_ia32_packusdw128 (v4si, v4si)
21241 v16qi __builtin_ia32_pblendvb128 (v16qi, v16qi, v16qi)
21242 v8hi __builtin_ia32_pblendw128 (v8hi, v8hi, const int)
21243 v2di __builtin_ia32_pcmpeqq (v2di, v2di)
21244 v8hi __builtin_ia32_phminposuw128 (v8hi)
21245 v16qi __builtin_ia32_pmaxsb128 (v16qi, v16qi)
21246 v4si __builtin_ia32_pmaxsd128 (v4si, v4si)
21247 v4si __builtin_ia32_pmaxud128 (v4si, v4si)
21248 v8hi __builtin_ia32_pmaxuw128 (v8hi, v8hi)
21249 v16qi __builtin_ia32_pminsb128 (v16qi, v16qi)
21250 v4si __builtin_ia32_pminsd128 (v4si, v4si)
21251 v4si __builtin_ia32_pminud128 (v4si, v4si)
21252 v8hi __builtin_ia32_pminuw128 (v8hi, v8hi)
21253 v4si __builtin_ia32_pmovsxbd128 (v16qi)
21254 v2di __builtin_ia32_pmovsxbq128 (v16qi)
21255 v8hi __builtin_ia32_pmovsxbw128 (v16qi)
21256 v2di __builtin_ia32_pmovsxdq128 (v4si)
21257 v4si __builtin_ia32_pmovsxwd128 (v8hi)
21258 v2di __builtin_ia32_pmovsxwq128 (v8hi)
21259 v4si __builtin_ia32_pmovzxbd128 (v16qi)
21260 v2di __builtin_ia32_pmovzxbq128 (v16qi)
21261 v8hi __builtin_ia32_pmovzxbw128 (v16qi)
21262 v2di __builtin_ia32_pmovzxdq128 (v4si)
21263 v4si __builtin_ia32_pmovzxwd128 (v8hi)
21264 v2di __builtin_ia32_pmovzxwq128 (v8hi)
21265 v2di __builtin_ia32_pmuldq128 (v4si, v4si)
21266 v4si __builtin_ia32_pmulld128 (v4si, v4si)
21267 int __builtin_ia32_ptestc128 (v2di, v2di)
21268 int __builtin_ia32_ptestnzc128 (v2di, v2di)
21269 int __builtin_ia32_ptestz128 (v2di, v2di)
21270 v2df __builtin_ia32_roundpd (v2df, const int)
21271 v4sf __builtin_ia32_roundps (v4sf, const int)
21272 v2df __builtin_ia32_roundsd (v2df, v2df, const int)
21273 v4sf __builtin_ia32_roundss (v4sf, v4sf, const int)
21274 @end smallexample
21276 The following built-in functions are available when @option{-msse4.1} is
21277 used.
21279 @table @code
21280 @item v4sf __builtin_ia32_vec_set_v4sf (v4sf, float, const int)
21281 Generates the @code{insertps} machine instruction.
21282 @item int __builtin_ia32_vec_ext_v16qi (v16qi, const int)
21283 Generates the @code{pextrb} machine instruction.
21284 @item v16qi __builtin_ia32_vec_set_v16qi (v16qi, int, const int)
21285 Generates the @code{pinsrb} machine instruction.
21286 @item v4si __builtin_ia32_vec_set_v4si (v4si, int, const int)
21287 Generates the @code{pinsrd} machine instruction.
21288 @item v2di __builtin_ia32_vec_set_v2di (v2di, long long, const int)
21289 Generates the @code{pinsrq} machine instruction in 64bit mode.
21290 @end table
21292 The following built-in functions are changed to generate new SSE4.1
21293 instructions when @option{-msse4.1} is used.
21295 @table @code
21296 @item float __builtin_ia32_vec_ext_v4sf (v4sf, const int)
21297 Generates the @code{extractps} machine instruction.
21298 @item int __builtin_ia32_vec_ext_v4si (v4si, const int)
21299 Generates the @code{pextrd} machine instruction.
21300 @item long long __builtin_ia32_vec_ext_v2di (v2di, const int)
21301 Generates the @code{pextrq} machine instruction in 64bit mode.
21302 @end table
21304 The following built-in functions are available when @option{-msse4.2} is
21305 used.  All of them generate the machine instruction that is part of the
21306 name.
21308 @smallexample
21309 v16qi __builtin_ia32_pcmpestrm128 (v16qi, int, v16qi, int, const int)
21310 int __builtin_ia32_pcmpestri128 (v16qi, int, v16qi, int, const int)
21311 int __builtin_ia32_pcmpestria128 (v16qi, int, v16qi, int, const int)
21312 int __builtin_ia32_pcmpestric128 (v16qi, int, v16qi, int, const int)
21313 int __builtin_ia32_pcmpestrio128 (v16qi, int, v16qi, int, const int)
21314 int __builtin_ia32_pcmpestris128 (v16qi, int, v16qi, int, const int)
21315 int __builtin_ia32_pcmpestriz128 (v16qi, int, v16qi, int, const int)
21316 v16qi __builtin_ia32_pcmpistrm128 (v16qi, v16qi, const int)
21317 int __builtin_ia32_pcmpistri128 (v16qi, v16qi, const int)
21318 int __builtin_ia32_pcmpistria128 (v16qi, v16qi, const int)
21319 int __builtin_ia32_pcmpistric128 (v16qi, v16qi, const int)
21320 int __builtin_ia32_pcmpistrio128 (v16qi, v16qi, const int)
21321 int __builtin_ia32_pcmpistris128 (v16qi, v16qi, const int)
21322 int __builtin_ia32_pcmpistriz128 (v16qi, v16qi, const int)
21323 v2di __builtin_ia32_pcmpgtq (v2di, v2di)
21324 @end smallexample
21326 The following built-in functions are available when @option{-msse4.2} is
21327 used.
21329 @table @code
21330 @item unsigned int __builtin_ia32_crc32qi (unsigned int, unsigned char)
21331 Generates the @code{crc32b} machine instruction.
21332 @item unsigned int __builtin_ia32_crc32hi (unsigned int, unsigned short)
21333 Generates the @code{crc32w} machine instruction.
21334 @item unsigned int __builtin_ia32_crc32si (unsigned int, unsigned int)
21335 Generates the @code{crc32l} machine instruction.
21336 @item unsigned long long __builtin_ia32_crc32di (unsigned long long, unsigned long long)
21337 Generates the @code{crc32q} machine instruction.
21338 @end table
21340 The following built-in functions are changed to generate new SSE4.2
21341 instructions when @option{-msse4.2} is used.
21343 @table @code
21344 @item int __builtin_popcount (unsigned int)
21345 Generates the @code{popcntl} machine instruction.
21346 @item int __builtin_popcountl (unsigned long)
21347 Generates the @code{popcntl} or @code{popcntq} machine instruction,
21348 depending on the size of @code{unsigned long}.
21349 @item int __builtin_popcountll (unsigned long long)
21350 Generates the @code{popcntq} machine instruction.
21351 @end table
21353 The following built-in functions are available when @option{-mavx} is
21354 used. All of them generate the machine instruction that is part of the
21355 name.
21357 @smallexample
21358 v4df __builtin_ia32_addpd256 (v4df,v4df)
21359 v8sf __builtin_ia32_addps256 (v8sf,v8sf)
21360 v4df __builtin_ia32_addsubpd256 (v4df,v4df)
21361 v8sf __builtin_ia32_addsubps256 (v8sf,v8sf)
21362 v4df __builtin_ia32_andnpd256 (v4df,v4df)
21363 v8sf __builtin_ia32_andnps256 (v8sf,v8sf)
21364 v4df __builtin_ia32_andpd256 (v4df,v4df)
21365 v8sf __builtin_ia32_andps256 (v8sf,v8sf)
21366 v4df __builtin_ia32_blendpd256 (v4df,v4df,int)
21367 v8sf __builtin_ia32_blendps256 (v8sf,v8sf,int)
21368 v4df __builtin_ia32_blendvpd256 (v4df,v4df,v4df)
21369 v8sf __builtin_ia32_blendvps256 (v8sf,v8sf,v8sf)
21370 v2df __builtin_ia32_cmppd (v2df,v2df,int)
21371 v4df __builtin_ia32_cmppd256 (v4df,v4df,int)
21372 v4sf __builtin_ia32_cmpps (v4sf,v4sf,int)
21373 v8sf __builtin_ia32_cmpps256 (v8sf,v8sf,int)
21374 v2df __builtin_ia32_cmpsd (v2df,v2df,int)
21375 v4sf __builtin_ia32_cmpss (v4sf,v4sf,int)
21376 v4df __builtin_ia32_cvtdq2pd256 (v4si)
21377 v8sf __builtin_ia32_cvtdq2ps256 (v8si)
21378 v4si __builtin_ia32_cvtpd2dq256 (v4df)
21379 v4sf __builtin_ia32_cvtpd2ps256 (v4df)
21380 v8si __builtin_ia32_cvtps2dq256 (v8sf)
21381 v4df __builtin_ia32_cvtps2pd256 (v4sf)
21382 v4si __builtin_ia32_cvttpd2dq256 (v4df)
21383 v8si __builtin_ia32_cvttps2dq256 (v8sf)
21384 v4df __builtin_ia32_divpd256 (v4df,v4df)
21385 v8sf __builtin_ia32_divps256 (v8sf,v8sf)
21386 v8sf __builtin_ia32_dpps256 (v8sf,v8sf,int)
21387 v4df __builtin_ia32_haddpd256 (v4df,v4df)
21388 v8sf __builtin_ia32_haddps256 (v8sf,v8sf)
21389 v4df __builtin_ia32_hsubpd256 (v4df,v4df)
21390 v8sf __builtin_ia32_hsubps256 (v8sf,v8sf)
21391 v32qi __builtin_ia32_lddqu256 (pcchar)
21392 v32qi __builtin_ia32_loaddqu256 (pcchar)
21393 v4df __builtin_ia32_loadupd256 (pcdouble)
21394 v8sf __builtin_ia32_loadups256 (pcfloat)
21395 v2df __builtin_ia32_maskloadpd (pcv2df,v2df)
21396 v4df __builtin_ia32_maskloadpd256 (pcv4df,v4df)
21397 v4sf __builtin_ia32_maskloadps (pcv4sf,v4sf)
21398 v8sf __builtin_ia32_maskloadps256 (pcv8sf,v8sf)
21399 void __builtin_ia32_maskstorepd (pv2df,v2df,v2df)
21400 void __builtin_ia32_maskstorepd256 (pv4df,v4df,v4df)
21401 void __builtin_ia32_maskstoreps (pv4sf,v4sf,v4sf)
21402 void __builtin_ia32_maskstoreps256 (pv8sf,v8sf,v8sf)
21403 v4df __builtin_ia32_maxpd256 (v4df,v4df)
21404 v8sf __builtin_ia32_maxps256 (v8sf,v8sf)
21405 v4df __builtin_ia32_minpd256 (v4df,v4df)
21406 v8sf __builtin_ia32_minps256 (v8sf,v8sf)
21407 v4df __builtin_ia32_movddup256 (v4df)
21408 int __builtin_ia32_movmskpd256 (v4df)
21409 int __builtin_ia32_movmskps256 (v8sf)
21410 v8sf __builtin_ia32_movshdup256 (v8sf)
21411 v8sf __builtin_ia32_movsldup256 (v8sf)
21412 v4df __builtin_ia32_mulpd256 (v4df,v4df)
21413 v8sf __builtin_ia32_mulps256 (v8sf,v8sf)
21414 v4df __builtin_ia32_orpd256 (v4df,v4df)
21415 v8sf __builtin_ia32_orps256 (v8sf,v8sf)
21416 v2df __builtin_ia32_pd_pd256 (v4df)
21417 v4df __builtin_ia32_pd256_pd (v2df)
21418 v4sf __builtin_ia32_ps_ps256 (v8sf)
21419 v8sf __builtin_ia32_ps256_ps (v4sf)
21420 int __builtin_ia32_ptestc256 (v4di,v4di,ptest)
21421 int __builtin_ia32_ptestnzc256 (v4di,v4di,ptest)
21422 int __builtin_ia32_ptestz256 (v4di,v4di,ptest)
21423 v8sf __builtin_ia32_rcpps256 (v8sf)
21424 v4df __builtin_ia32_roundpd256 (v4df,int)
21425 v8sf __builtin_ia32_roundps256 (v8sf,int)
21426 v8sf __builtin_ia32_rsqrtps_nr256 (v8sf)
21427 v8sf __builtin_ia32_rsqrtps256 (v8sf)
21428 v4df __builtin_ia32_shufpd256 (v4df,v4df,int)
21429 v8sf __builtin_ia32_shufps256 (v8sf,v8sf,int)
21430 v4si __builtin_ia32_si_si256 (v8si)
21431 v8si __builtin_ia32_si256_si (v4si)
21432 v4df __builtin_ia32_sqrtpd256 (v4df)
21433 v8sf __builtin_ia32_sqrtps_nr256 (v8sf)
21434 v8sf __builtin_ia32_sqrtps256 (v8sf)
21435 void __builtin_ia32_storedqu256 (pchar,v32qi)
21436 void __builtin_ia32_storeupd256 (pdouble,v4df)
21437 void __builtin_ia32_storeups256 (pfloat,v8sf)
21438 v4df __builtin_ia32_subpd256 (v4df,v4df)
21439 v8sf __builtin_ia32_subps256 (v8sf,v8sf)
21440 v4df __builtin_ia32_unpckhpd256 (v4df,v4df)
21441 v8sf __builtin_ia32_unpckhps256 (v8sf,v8sf)
21442 v4df __builtin_ia32_unpcklpd256 (v4df,v4df)
21443 v8sf __builtin_ia32_unpcklps256 (v8sf,v8sf)
21444 v4df __builtin_ia32_vbroadcastf128_pd256 (pcv2df)
21445 v8sf __builtin_ia32_vbroadcastf128_ps256 (pcv4sf)
21446 v4df __builtin_ia32_vbroadcastsd256 (pcdouble)
21447 v4sf __builtin_ia32_vbroadcastss (pcfloat)
21448 v8sf __builtin_ia32_vbroadcastss256 (pcfloat)
21449 v2df __builtin_ia32_vextractf128_pd256 (v4df,int)
21450 v4sf __builtin_ia32_vextractf128_ps256 (v8sf,int)
21451 v4si __builtin_ia32_vextractf128_si256 (v8si,int)
21452 v4df __builtin_ia32_vinsertf128_pd256 (v4df,v2df,int)
21453 v8sf __builtin_ia32_vinsertf128_ps256 (v8sf,v4sf,int)
21454 v8si __builtin_ia32_vinsertf128_si256 (v8si,v4si,int)
21455 v4df __builtin_ia32_vperm2f128_pd256 (v4df,v4df,int)
21456 v8sf __builtin_ia32_vperm2f128_ps256 (v8sf,v8sf,int)
21457 v8si __builtin_ia32_vperm2f128_si256 (v8si,v8si,int)
21458 v2df __builtin_ia32_vpermil2pd (v2df,v2df,v2di,int)
21459 v4df __builtin_ia32_vpermil2pd256 (v4df,v4df,v4di,int)
21460 v4sf __builtin_ia32_vpermil2ps (v4sf,v4sf,v4si,int)
21461 v8sf __builtin_ia32_vpermil2ps256 (v8sf,v8sf,v8si,int)
21462 v2df __builtin_ia32_vpermilpd (v2df,int)
21463 v4df __builtin_ia32_vpermilpd256 (v4df,int)
21464 v4sf __builtin_ia32_vpermilps (v4sf,int)
21465 v8sf __builtin_ia32_vpermilps256 (v8sf,int)
21466 v2df __builtin_ia32_vpermilvarpd (v2df,v2di)
21467 v4df __builtin_ia32_vpermilvarpd256 (v4df,v4di)
21468 v4sf __builtin_ia32_vpermilvarps (v4sf,v4si)
21469 v8sf __builtin_ia32_vpermilvarps256 (v8sf,v8si)
21470 int __builtin_ia32_vtestcpd (v2df,v2df,ptest)
21471 int __builtin_ia32_vtestcpd256 (v4df,v4df,ptest)
21472 int __builtin_ia32_vtestcps (v4sf,v4sf,ptest)
21473 int __builtin_ia32_vtestcps256 (v8sf,v8sf,ptest)
21474 int __builtin_ia32_vtestnzcpd (v2df,v2df,ptest)
21475 int __builtin_ia32_vtestnzcpd256 (v4df,v4df,ptest)
21476 int __builtin_ia32_vtestnzcps (v4sf,v4sf,ptest)
21477 int __builtin_ia32_vtestnzcps256 (v8sf,v8sf,ptest)
21478 int __builtin_ia32_vtestzpd (v2df,v2df,ptest)
21479 int __builtin_ia32_vtestzpd256 (v4df,v4df,ptest)
21480 int __builtin_ia32_vtestzps (v4sf,v4sf,ptest)
21481 int __builtin_ia32_vtestzps256 (v8sf,v8sf,ptest)
21482 void __builtin_ia32_vzeroall (void)
21483 void __builtin_ia32_vzeroupper (void)
21484 v4df __builtin_ia32_xorpd256 (v4df,v4df)
21485 v8sf __builtin_ia32_xorps256 (v8sf,v8sf)
21486 @end smallexample
21488 The following built-in functions are available when @option{-mavx2} is
21489 used. All of them generate the machine instruction that is part of the
21490 name.
21492 @smallexample
21493 v32qi __builtin_ia32_mpsadbw256 (v32qi,v32qi,int)
21494 v32qi __builtin_ia32_pabsb256 (v32qi)
21495 v16hi __builtin_ia32_pabsw256 (v16hi)
21496 v8si __builtin_ia32_pabsd256 (v8si)
21497 v16hi __builtin_ia32_packssdw256 (v8si,v8si)
21498 v32qi __builtin_ia32_packsswb256 (v16hi,v16hi)
21499 v16hi __builtin_ia32_packusdw256 (v8si,v8si)
21500 v32qi __builtin_ia32_packuswb256 (v16hi,v16hi)
21501 v32qi __builtin_ia32_paddb256 (v32qi,v32qi)
21502 v16hi __builtin_ia32_paddw256 (v16hi,v16hi)
21503 v8si __builtin_ia32_paddd256 (v8si,v8si)
21504 v4di __builtin_ia32_paddq256 (v4di,v4di)
21505 v32qi __builtin_ia32_paddsb256 (v32qi,v32qi)
21506 v16hi __builtin_ia32_paddsw256 (v16hi,v16hi)
21507 v32qi __builtin_ia32_paddusb256 (v32qi,v32qi)
21508 v16hi __builtin_ia32_paddusw256 (v16hi,v16hi)
21509 v4di __builtin_ia32_palignr256 (v4di,v4di,int)
21510 v4di __builtin_ia32_andsi256 (v4di,v4di)
21511 v4di __builtin_ia32_andnotsi256 (v4di,v4di)
21512 v32qi __builtin_ia32_pavgb256 (v32qi,v32qi)
21513 v16hi __builtin_ia32_pavgw256 (v16hi,v16hi)
21514 v32qi __builtin_ia32_pblendvb256 (v32qi,v32qi,v32qi)
21515 v16hi __builtin_ia32_pblendw256 (v16hi,v16hi,int)
21516 v32qi __builtin_ia32_pcmpeqb256 (v32qi,v32qi)
21517 v16hi __builtin_ia32_pcmpeqw256 (v16hi,v16hi)
21518 v8si __builtin_ia32_pcmpeqd256 (c8si,v8si)
21519 v4di __builtin_ia32_pcmpeqq256 (v4di,v4di)
21520 v32qi __builtin_ia32_pcmpgtb256 (v32qi,v32qi)
21521 v16hi __builtin_ia32_pcmpgtw256 (16hi,v16hi)
21522 v8si __builtin_ia32_pcmpgtd256 (v8si,v8si)
21523 v4di __builtin_ia32_pcmpgtq256 (v4di,v4di)
21524 v16hi __builtin_ia32_phaddw256 (v16hi,v16hi)
21525 v8si __builtin_ia32_phaddd256 (v8si,v8si)
21526 v16hi __builtin_ia32_phaddsw256 (v16hi,v16hi)
21527 v16hi __builtin_ia32_phsubw256 (v16hi,v16hi)
21528 v8si __builtin_ia32_phsubd256 (v8si,v8si)
21529 v16hi __builtin_ia32_phsubsw256 (v16hi,v16hi)
21530 v32qi __builtin_ia32_pmaddubsw256 (v32qi,v32qi)
21531 v16hi __builtin_ia32_pmaddwd256 (v16hi,v16hi)
21532 v32qi __builtin_ia32_pmaxsb256 (v32qi,v32qi)
21533 v16hi __builtin_ia32_pmaxsw256 (v16hi,v16hi)
21534 v8si __builtin_ia32_pmaxsd256 (v8si,v8si)
21535 v32qi __builtin_ia32_pmaxub256 (v32qi,v32qi)
21536 v16hi __builtin_ia32_pmaxuw256 (v16hi,v16hi)
21537 v8si __builtin_ia32_pmaxud256 (v8si,v8si)
21538 v32qi __builtin_ia32_pminsb256 (v32qi,v32qi)
21539 v16hi __builtin_ia32_pminsw256 (v16hi,v16hi)
21540 v8si __builtin_ia32_pminsd256 (v8si,v8si)
21541 v32qi __builtin_ia32_pminub256 (v32qi,v32qi)
21542 v16hi __builtin_ia32_pminuw256 (v16hi,v16hi)
21543 v8si __builtin_ia32_pminud256 (v8si,v8si)
21544 int __builtin_ia32_pmovmskb256 (v32qi)
21545 v16hi __builtin_ia32_pmovsxbw256 (v16qi)
21546 v8si __builtin_ia32_pmovsxbd256 (v16qi)
21547 v4di __builtin_ia32_pmovsxbq256 (v16qi)
21548 v8si __builtin_ia32_pmovsxwd256 (v8hi)
21549 v4di __builtin_ia32_pmovsxwq256 (v8hi)
21550 v4di __builtin_ia32_pmovsxdq256 (v4si)
21551 v16hi __builtin_ia32_pmovzxbw256 (v16qi)
21552 v8si __builtin_ia32_pmovzxbd256 (v16qi)
21553 v4di __builtin_ia32_pmovzxbq256 (v16qi)
21554 v8si __builtin_ia32_pmovzxwd256 (v8hi)
21555 v4di __builtin_ia32_pmovzxwq256 (v8hi)
21556 v4di __builtin_ia32_pmovzxdq256 (v4si)
21557 v4di __builtin_ia32_pmuldq256 (v8si,v8si)
21558 v16hi __builtin_ia32_pmulhrsw256 (v16hi, v16hi)
21559 v16hi __builtin_ia32_pmulhuw256 (v16hi,v16hi)
21560 v16hi __builtin_ia32_pmulhw256 (v16hi,v16hi)
21561 v16hi __builtin_ia32_pmullw256 (v16hi,v16hi)
21562 v8si __builtin_ia32_pmulld256 (v8si,v8si)
21563 v4di __builtin_ia32_pmuludq256 (v8si,v8si)
21564 v4di __builtin_ia32_por256 (v4di,v4di)
21565 v16hi __builtin_ia32_psadbw256 (v32qi,v32qi)
21566 v32qi __builtin_ia32_pshufb256 (v32qi,v32qi)
21567 v8si __builtin_ia32_pshufd256 (v8si,int)
21568 v16hi __builtin_ia32_pshufhw256 (v16hi,int)
21569 v16hi __builtin_ia32_pshuflw256 (v16hi,int)
21570 v32qi __builtin_ia32_psignb256 (v32qi,v32qi)
21571 v16hi __builtin_ia32_psignw256 (v16hi,v16hi)
21572 v8si __builtin_ia32_psignd256 (v8si,v8si)
21573 v4di __builtin_ia32_pslldqi256 (v4di,int)
21574 v16hi __builtin_ia32_psllwi256 (16hi,int)
21575 v16hi __builtin_ia32_psllw256(v16hi,v8hi)
21576 v8si __builtin_ia32_pslldi256 (v8si,int)
21577 v8si __builtin_ia32_pslld256(v8si,v4si)
21578 v4di __builtin_ia32_psllqi256 (v4di,int)
21579 v4di __builtin_ia32_psllq256(v4di,v2di)
21580 v16hi __builtin_ia32_psrawi256 (v16hi,int)
21581 v16hi __builtin_ia32_psraw256 (v16hi,v8hi)
21582 v8si __builtin_ia32_psradi256 (v8si,int)
21583 v8si __builtin_ia32_psrad256 (v8si,v4si)
21584 v4di __builtin_ia32_psrldqi256 (v4di, int)
21585 v16hi __builtin_ia32_psrlwi256 (v16hi,int)
21586 v16hi __builtin_ia32_psrlw256 (v16hi,v8hi)
21587 v8si __builtin_ia32_psrldi256 (v8si,int)
21588 v8si __builtin_ia32_psrld256 (v8si,v4si)
21589 v4di __builtin_ia32_psrlqi256 (v4di,int)
21590 v4di __builtin_ia32_psrlq256(v4di,v2di)
21591 v32qi __builtin_ia32_psubb256 (v32qi,v32qi)
21592 v32hi __builtin_ia32_psubw256 (v16hi,v16hi)
21593 v8si __builtin_ia32_psubd256 (v8si,v8si)
21594 v4di __builtin_ia32_psubq256 (v4di,v4di)
21595 v32qi __builtin_ia32_psubsb256 (v32qi,v32qi)
21596 v16hi __builtin_ia32_psubsw256 (v16hi,v16hi)
21597 v32qi __builtin_ia32_psubusb256 (v32qi,v32qi)
21598 v16hi __builtin_ia32_psubusw256 (v16hi,v16hi)
21599 v32qi __builtin_ia32_punpckhbw256 (v32qi,v32qi)
21600 v16hi __builtin_ia32_punpckhwd256 (v16hi,v16hi)
21601 v8si __builtin_ia32_punpckhdq256 (v8si,v8si)
21602 v4di __builtin_ia32_punpckhqdq256 (v4di,v4di)
21603 v32qi __builtin_ia32_punpcklbw256 (v32qi,v32qi)
21604 v16hi __builtin_ia32_punpcklwd256 (v16hi,v16hi)
21605 v8si __builtin_ia32_punpckldq256 (v8si,v8si)
21606 v4di __builtin_ia32_punpcklqdq256 (v4di,v4di)
21607 v4di __builtin_ia32_pxor256 (v4di,v4di)
21608 v4di __builtin_ia32_movntdqa256 (pv4di)
21609 v4sf __builtin_ia32_vbroadcastss_ps (v4sf)
21610 v8sf __builtin_ia32_vbroadcastss_ps256 (v4sf)
21611 v4df __builtin_ia32_vbroadcastsd_pd256 (v2df)
21612 v4di __builtin_ia32_vbroadcastsi256 (v2di)
21613 v4si __builtin_ia32_pblendd128 (v4si,v4si)
21614 v8si __builtin_ia32_pblendd256 (v8si,v8si)
21615 v32qi __builtin_ia32_pbroadcastb256 (v16qi)
21616 v16hi __builtin_ia32_pbroadcastw256 (v8hi)
21617 v8si __builtin_ia32_pbroadcastd256 (v4si)
21618 v4di __builtin_ia32_pbroadcastq256 (v2di)
21619 v16qi __builtin_ia32_pbroadcastb128 (v16qi)
21620 v8hi __builtin_ia32_pbroadcastw128 (v8hi)
21621 v4si __builtin_ia32_pbroadcastd128 (v4si)
21622 v2di __builtin_ia32_pbroadcastq128 (v2di)
21623 v8si __builtin_ia32_permvarsi256 (v8si,v8si)
21624 v4df __builtin_ia32_permdf256 (v4df,int)
21625 v8sf __builtin_ia32_permvarsf256 (v8sf,v8sf)
21626 v4di __builtin_ia32_permdi256 (v4di,int)
21627 v4di __builtin_ia32_permti256 (v4di,v4di,int)
21628 v4di __builtin_ia32_extract128i256 (v4di,int)
21629 v4di __builtin_ia32_insert128i256 (v4di,v2di,int)
21630 v8si __builtin_ia32_maskloadd256 (pcv8si,v8si)
21631 v4di __builtin_ia32_maskloadq256 (pcv4di,v4di)
21632 v4si __builtin_ia32_maskloadd (pcv4si,v4si)
21633 v2di __builtin_ia32_maskloadq (pcv2di,v2di)
21634 void __builtin_ia32_maskstored256 (pv8si,v8si,v8si)
21635 void __builtin_ia32_maskstoreq256 (pv4di,v4di,v4di)
21636 void __builtin_ia32_maskstored (pv4si,v4si,v4si)
21637 void __builtin_ia32_maskstoreq (pv2di,v2di,v2di)
21638 v8si __builtin_ia32_psllv8si (v8si,v8si)
21639 v4si __builtin_ia32_psllv4si (v4si,v4si)
21640 v4di __builtin_ia32_psllv4di (v4di,v4di)
21641 v2di __builtin_ia32_psllv2di (v2di,v2di)
21642 v8si __builtin_ia32_psrav8si (v8si,v8si)
21643 v4si __builtin_ia32_psrav4si (v4si,v4si)
21644 v8si __builtin_ia32_psrlv8si (v8si,v8si)
21645 v4si __builtin_ia32_psrlv4si (v4si,v4si)
21646 v4di __builtin_ia32_psrlv4di (v4di,v4di)
21647 v2di __builtin_ia32_psrlv2di (v2di,v2di)
21648 v2df __builtin_ia32_gathersiv2df (v2df, pcdouble,v4si,v2df,int)
21649 v4df __builtin_ia32_gathersiv4df (v4df, pcdouble,v4si,v4df,int)
21650 v2df __builtin_ia32_gatherdiv2df (v2df, pcdouble,v2di,v2df,int)
21651 v4df __builtin_ia32_gatherdiv4df (v4df, pcdouble,v4di,v4df,int)
21652 v4sf __builtin_ia32_gathersiv4sf (v4sf, pcfloat,v4si,v4sf,int)
21653 v8sf __builtin_ia32_gathersiv8sf (v8sf, pcfloat,v8si,v8sf,int)
21654 v4sf __builtin_ia32_gatherdiv4sf (v4sf, pcfloat,v2di,v4sf,int)
21655 v4sf __builtin_ia32_gatherdiv4sf256 (v4sf, pcfloat,v4di,v4sf,int)
21656 v2di __builtin_ia32_gathersiv2di (v2di, pcint64,v4si,v2di,int)
21657 v4di __builtin_ia32_gathersiv4di (v4di, pcint64,v4si,v4di,int)
21658 v2di __builtin_ia32_gatherdiv2di (v2di, pcint64,v2di,v2di,int)
21659 v4di __builtin_ia32_gatherdiv4di (v4di, pcint64,v4di,v4di,int)
21660 v4si __builtin_ia32_gathersiv4si (v4si, pcint,v4si,v4si,int)
21661 v8si __builtin_ia32_gathersiv8si (v8si, pcint,v8si,v8si,int)
21662 v4si __builtin_ia32_gatherdiv4si (v4si, pcint,v2di,v4si,int)
21663 v4si __builtin_ia32_gatherdiv4si256 (v4si, pcint,v4di,v4si,int)
21664 @end smallexample
21666 The following built-in functions are available when @option{-maes} is
21667 used.  All of them generate the machine instruction that is part of the
21668 name.
21670 @smallexample
21671 v2di __builtin_ia32_aesenc128 (v2di, v2di)
21672 v2di __builtin_ia32_aesenclast128 (v2di, v2di)
21673 v2di __builtin_ia32_aesdec128 (v2di, v2di)
21674 v2di __builtin_ia32_aesdeclast128 (v2di, v2di)
21675 v2di __builtin_ia32_aeskeygenassist128 (v2di, const int)
21676 v2di __builtin_ia32_aesimc128 (v2di)
21677 @end smallexample
21679 The following built-in function is available when @option{-mpclmul} is
21680 used.
21682 @table @code
21683 @item v2di __builtin_ia32_pclmulqdq128 (v2di, v2di, const int)
21684 Generates the @code{pclmulqdq} machine instruction.
21685 @end table
21687 The following built-in function is available when @option{-mfsgsbase} is
21688 used.  All of them generate the machine instruction that is part of the
21689 name.
21691 @smallexample
21692 unsigned int __builtin_ia32_rdfsbase32 (void)
21693 unsigned long long __builtin_ia32_rdfsbase64 (void)
21694 unsigned int __builtin_ia32_rdgsbase32 (void)
21695 unsigned long long __builtin_ia32_rdgsbase64 (void)
21696 void _writefsbase_u32 (unsigned int)
21697 void _writefsbase_u64 (unsigned long long)
21698 void _writegsbase_u32 (unsigned int)
21699 void _writegsbase_u64 (unsigned long long)
21700 @end smallexample
21702 The following built-in function is available when @option{-mrdrnd} is
21703 used.  All of them generate the machine instruction that is part of the
21704 name.
21706 @smallexample
21707 unsigned int __builtin_ia32_rdrand16_step (unsigned short *)
21708 unsigned int __builtin_ia32_rdrand32_step (unsigned int *)
21709 unsigned int __builtin_ia32_rdrand64_step (unsigned long long *)
21710 @end smallexample
21712 The following built-in function is available when @option{-mptwrite} is
21713 used.  All of them generate the machine instruction that is part of the
21714 name.
21716 @smallexample
21717 void __builtin_ia32_ptwrite32 (unsigned)
21718 void __builtin_ia32_ptwrite64 (unsigned long long)
21719 @end smallexample
21721 The following built-in functions are available when @option{-msse4a} is used.
21722 All of them generate the machine instruction that is part of the name.
21724 @smallexample
21725 void __builtin_ia32_movntsd (double *, v2df)
21726 void __builtin_ia32_movntss (float *, v4sf)
21727 v2di __builtin_ia32_extrq  (v2di, v16qi)
21728 v2di __builtin_ia32_extrqi (v2di, const unsigned int, const unsigned int)
21729 v2di __builtin_ia32_insertq (v2di, v2di)
21730 v2di __builtin_ia32_insertqi (v2di, v2di, const unsigned int, const unsigned int)
21731 @end smallexample
21733 The following built-in functions are available when @option{-mxop} is used.
21734 @smallexample
21735 v2df __builtin_ia32_vfrczpd (v2df)
21736 v4sf __builtin_ia32_vfrczps (v4sf)
21737 v2df __builtin_ia32_vfrczsd (v2df)
21738 v4sf __builtin_ia32_vfrczss (v4sf)
21739 v4df __builtin_ia32_vfrczpd256 (v4df)
21740 v8sf __builtin_ia32_vfrczps256 (v8sf)
21741 v2di __builtin_ia32_vpcmov (v2di, v2di, v2di)
21742 v2di __builtin_ia32_vpcmov_v2di (v2di, v2di, v2di)
21743 v4si __builtin_ia32_vpcmov_v4si (v4si, v4si, v4si)
21744 v8hi __builtin_ia32_vpcmov_v8hi (v8hi, v8hi, v8hi)
21745 v16qi __builtin_ia32_vpcmov_v16qi (v16qi, v16qi, v16qi)
21746 v2df __builtin_ia32_vpcmov_v2df (v2df, v2df, v2df)
21747 v4sf __builtin_ia32_vpcmov_v4sf (v4sf, v4sf, v4sf)
21748 v4di __builtin_ia32_vpcmov_v4di256 (v4di, v4di, v4di)
21749 v8si __builtin_ia32_vpcmov_v8si256 (v8si, v8si, v8si)
21750 v16hi __builtin_ia32_vpcmov_v16hi256 (v16hi, v16hi, v16hi)
21751 v32qi __builtin_ia32_vpcmov_v32qi256 (v32qi, v32qi, v32qi)
21752 v4df __builtin_ia32_vpcmov_v4df256 (v4df, v4df, v4df)
21753 v8sf __builtin_ia32_vpcmov_v8sf256 (v8sf, v8sf, v8sf)
21754 v16qi __builtin_ia32_vpcomeqb (v16qi, v16qi)
21755 v8hi __builtin_ia32_vpcomeqw (v8hi, v8hi)
21756 v4si __builtin_ia32_vpcomeqd (v4si, v4si)
21757 v2di __builtin_ia32_vpcomeqq (v2di, v2di)
21758 v16qi __builtin_ia32_vpcomequb (v16qi, v16qi)
21759 v4si __builtin_ia32_vpcomequd (v4si, v4si)
21760 v2di __builtin_ia32_vpcomequq (v2di, v2di)
21761 v8hi __builtin_ia32_vpcomequw (v8hi, v8hi)
21762 v8hi __builtin_ia32_vpcomeqw (v8hi, v8hi)
21763 v16qi __builtin_ia32_vpcomfalseb (v16qi, v16qi)
21764 v4si __builtin_ia32_vpcomfalsed (v4si, v4si)
21765 v2di __builtin_ia32_vpcomfalseq (v2di, v2di)
21766 v16qi __builtin_ia32_vpcomfalseub (v16qi, v16qi)
21767 v4si __builtin_ia32_vpcomfalseud (v4si, v4si)
21768 v2di __builtin_ia32_vpcomfalseuq (v2di, v2di)
21769 v8hi __builtin_ia32_vpcomfalseuw (v8hi, v8hi)
21770 v8hi __builtin_ia32_vpcomfalsew (v8hi, v8hi)
21771 v16qi __builtin_ia32_vpcomgeb (v16qi, v16qi)
21772 v4si __builtin_ia32_vpcomged (v4si, v4si)
21773 v2di __builtin_ia32_vpcomgeq (v2di, v2di)
21774 v16qi __builtin_ia32_vpcomgeub (v16qi, v16qi)
21775 v4si __builtin_ia32_vpcomgeud (v4si, v4si)
21776 v2di __builtin_ia32_vpcomgeuq (v2di, v2di)
21777 v8hi __builtin_ia32_vpcomgeuw (v8hi, v8hi)
21778 v8hi __builtin_ia32_vpcomgew (v8hi, v8hi)
21779 v16qi __builtin_ia32_vpcomgtb (v16qi, v16qi)
21780 v4si __builtin_ia32_vpcomgtd (v4si, v4si)
21781 v2di __builtin_ia32_vpcomgtq (v2di, v2di)
21782 v16qi __builtin_ia32_vpcomgtub (v16qi, v16qi)
21783 v4si __builtin_ia32_vpcomgtud (v4si, v4si)
21784 v2di __builtin_ia32_vpcomgtuq (v2di, v2di)
21785 v8hi __builtin_ia32_vpcomgtuw (v8hi, v8hi)
21786 v8hi __builtin_ia32_vpcomgtw (v8hi, v8hi)
21787 v16qi __builtin_ia32_vpcomleb (v16qi, v16qi)
21788 v4si __builtin_ia32_vpcomled (v4si, v4si)
21789 v2di __builtin_ia32_vpcomleq (v2di, v2di)
21790 v16qi __builtin_ia32_vpcomleub (v16qi, v16qi)
21791 v4si __builtin_ia32_vpcomleud (v4si, v4si)
21792 v2di __builtin_ia32_vpcomleuq (v2di, v2di)
21793 v8hi __builtin_ia32_vpcomleuw (v8hi, v8hi)
21794 v8hi __builtin_ia32_vpcomlew (v8hi, v8hi)
21795 v16qi __builtin_ia32_vpcomltb (v16qi, v16qi)
21796 v4si __builtin_ia32_vpcomltd (v4si, v4si)
21797 v2di __builtin_ia32_vpcomltq (v2di, v2di)
21798 v16qi __builtin_ia32_vpcomltub (v16qi, v16qi)
21799 v4si __builtin_ia32_vpcomltud (v4si, v4si)
21800 v2di __builtin_ia32_vpcomltuq (v2di, v2di)
21801 v8hi __builtin_ia32_vpcomltuw (v8hi, v8hi)
21802 v8hi __builtin_ia32_vpcomltw (v8hi, v8hi)
21803 v16qi __builtin_ia32_vpcomneb (v16qi, v16qi)
21804 v4si __builtin_ia32_vpcomned (v4si, v4si)
21805 v2di __builtin_ia32_vpcomneq (v2di, v2di)
21806 v16qi __builtin_ia32_vpcomneub (v16qi, v16qi)
21807 v4si __builtin_ia32_vpcomneud (v4si, v4si)
21808 v2di __builtin_ia32_vpcomneuq (v2di, v2di)
21809 v8hi __builtin_ia32_vpcomneuw (v8hi, v8hi)
21810 v8hi __builtin_ia32_vpcomnew (v8hi, v8hi)
21811 v16qi __builtin_ia32_vpcomtrueb (v16qi, v16qi)
21812 v4si __builtin_ia32_vpcomtrued (v4si, v4si)
21813 v2di __builtin_ia32_vpcomtrueq (v2di, v2di)
21814 v16qi __builtin_ia32_vpcomtrueub (v16qi, v16qi)
21815 v4si __builtin_ia32_vpcomtrueud (v4si, v4si)
21816 v2di __builtin_ia32_vpcomtrueuq (v2di, v2di)
21817 v8hi __builtin_ia32_vpcomtrueuw (v8hi, v8hi)
21818 v8hi __builtin_ia32_vpcomtruew (v8hi, v8hi)
21819 v4si __builtin_ia32_vphaddbd (v16qi)
21820 v2di __builtin_ia32_vphaddbq (v16qi)
21821 v8hi __builtin_ia32_vphaddbw (v16qi)
21822 v2di __builtin_ia32_vphadddq (v4si)
21823 v4si __builtin_ia32_vphaddubd (v16qi)
21824 v2di __builtin_ia32_vphaddubq (v16qi)
21825 v8hi __builtin_ia32_vphaddubw (v16qi)
21826 v2di __builtin_ia32_vphaddudq (v4si)
21827 v4si __builtin_ia32_vphadduwd (v8hi)
21828 v2di __builtin_ia32_vphadduwq (v8hi)
21829 v4si __builtin_ia32_vphaddwd (v8hi)
21830 v2di __builtin_ia32_vphaddwq (v8hi)
21831 v8hi __builtin_ia32_vphsubbw (v16qi)
21832 v2di __builtin_ia32_vphsubdq (v4si)
21833 v4si __builtin_ia32_vphsubwd (v8hi)
21834 v4si __builtin_ia32_vpmacsdd (v4si, v4si, v4si)
21835 v2di __builtin_ia32_vpmacsdqh (v4si, v4si, v2di)
21836 v2di __builtin_ia32_vpmacsdql (v4si, v4si, v2di)
21837 v4si __builtin_ia32_vpmacssdd (v4si, v4si, v4si)
21838 v2di __builtin_ia32_vpmacssdqh (v4si, v4si, v2di)
21839 v2di __builtin_ia32_vpmacssdql (v4si, v4si, v2di)
21840 v4si __builtin_ia32_vpmacsswd (v8hi, v8hi, v4si)
21841 v8hi __builtin_ia32_vpmacssww (v8hi, v8hi, v8hi)
21842 v4si __builtin_ia32_vpmacswd (v8hi, v8hi, v4si)
21843 v8hi __builtin_ia32_vpmacsww (v8hi, v8hi, v8hi)
21844 v4si __builtin_ia32_vpmadcsswd (v8hi, v8hi, v4si)
21845 v4si __builtin_ia32_vpmadcswd (v8hi, v8hi, v4si)
21846 v16qi __builtin_ia32_vpperm (v16qi, v16qi, v16qi)
21847 v16qi __builtin_ia32_vprotb (v16qi, v16qi)
21848 v4si __builtin_ia32_vprotd (v4si, v4si)
21849 v2di __builtin_ia32_vprotq (v2di, v2di)
21850 v8hi __builtin_ia32_vprotw (v8hi, v8hi)
21851 v16qi __builtin_ia32_vpshab (v16qi, v16qi)
21852 v4si __builtin_ia32_vpshad (v4si, v4si)
21853 v2di __builtin_ia32_vpshaq (v2di, v2di)
21854 v8hi __builtin_ia32_vpshaw (v8hi, v8hi)
21855 v16qi __builtin_ia32_vpshlb (v16qi, v16qi)
21856 v4si __builtin_ia32_vpshld (v4si, v4si)
21857 v2di __builtin_ia32_vpshlq (v2di, v2di)
21858 v8hi __builtin_ia32_vpshlw (v8hi, v8hi)
21859 @end smallexample
21861 The following built-in functions are available when @option{-mfma4} is used.
21862 All of them generate the machine instruction that is part of the name.
21864 @smallexample
21865 v2df __builtin_ia32_vfmaddpd (v2df, v2df, v2df)
21866 v4sf __builtin_ia32_vfmaddps (v4sf, v4sf, v4sf)
21867 v2df __builtin_ia32_vfmaddsd (v2df, v2df, v2df)
21868 v4sf __builtin_ia32_vfmaddss (v4sf, v4sf, v4sf)
21869 v2df __builtin_ia32_vfmsubpd (v2df, v2df, v2df)
21870 v4sf __builtin_ia32_vfmsubps (v4sf, v4sf, v4sf)
21871 v2df __builtin_ia32_vfmsubsd (v2df, v2df, v2df)
21872 v4sf __builtin_ia32_vfmsubss (v4sf, v4sf, v4sf)
21873 v2df __builtin_ia32_vfnmaddpd (v2df, v2df, v2df)
21874 v4sf __builtin_ia32_vfnmaddps (v4sf, v4sf, v4sf)
21875 v2df __builtin_ia32_vfnmaddsd (v2df, v2df, v2df)
21876 v4sf __builtin_ia32_vfnmaddss (v4sf, v4sf, v4sf)
21877 v2df __builtin_ia32_vfnmsubpd (v2df, v2df, v2df)
21878 v4sf __builtin_ia32_vfnmsubps (v4sf, v4sf, v4sf)
21879 v2df __builtin_ia32_vfnmsubsd (v2df, v2df, v2df)
21880 v4sf __builtin_ia32_vfnmsubss (v4sf, v4sf, v4sf)
21881 v2df __builtin_ia32_vfmaddsubpd  (v2df, v2df, v2df)
21882 v4sf __builtin_ia32_vfmaddsubps  (v4sf, v4sf, v4sf)
21883 v2df __builtin_ia32_vfmsubaddpd  (v2df, v2df, v2df)
21884 v4sf __builtin_ia32_vfmsubaddps  (v4sf, v4sf, v4sf)
21885 v4df __builtin_ia32_vfmaddpd256 (v4df, v4df, v4df)
21886 v8sf __builtin_ia32_vfmaddps256 (v8sf, v8sf, v8sf)
21887 v4df __builtin_ia32_vfmsubpd256 (v4df, v4df, v4df)
21888 v8sf __builtin_ia32_vfmsubps256 (v8sf, v8sf, v8sf)
21889 v4df __builtin_ia32_vfnmaddpd256 (v4df, v4df, v4df)
21890 v8sf __builtin_ia32_vfnmaddps256 (v8sf, v8sf, v8sf)
21891 v4df __builtin_ia32_vfnmsubpd256 (v4df, v4df, v4df)
21892 v8sf __builtin_ia32_vfnmsubps256 (v8sf, v8sf, v8sf)
21893 v4df __builtin_ia32_vfmaddsubpd256 (v4df, v4df, v4df)
21894 v8sf __builtin_ia32_vfmaddsubps256 (v8sf, v8sf, v8sf)
21895 v4df __builtin_ia32_vfmsubaddpd256 (v4df, v4df, v4df)
21896 v8sf __builtin_ia32_vfmsubaddps256 (v8sf, v8sf, v8sf)
21898 @end smallexample
21900 The following built-in functions are available when @option{-mlwp} is used.
21902 @smallexample
21903 void __builtin_ia32_llwpcb16 (void *);
21904 void __builtin_ia32_llwpcb32 (void *);
21905 void __builtin_ia32_llwpcb64 (void *);
21906 void * __builtin_ia32_llwpcb16 (void);
21907 void * __builtin_ia32_llwpcb32 (void);
21908 void * __builtin_ia32_llwpcb64 (void);
21909 void __builtin_ia32_lwpval16 (unsigned short, unsigned int, unsigned short)
21910 void __builtin_ia32_lwpval32 (unsigned int, unsigned int, unsigned int)
21911 void __builtin_ia32_lwpval64 (unsigned __int64, unsigned int, unsigned int)
21912 unsigned char __builtin_ia32_lwpins16 (unsigned short, unsigned int, unsigned short)
21913 unsigned char __builtin_ia32_lwpins32 (unsigned int, unsigned int, unsigned int)
21914 unsigned char __builtin_ia32_lwpins64 (unsigned __int64, unsigned int, unsigned int)
21915 @end smallexample
21917 The following built-in functions are available when @option{-mbmi} is used.
21918 All of them generate the machine instruction that is part of the name.
21919 @smallexample
21920 unsigned int __builtin_ia32_bextr_u32(unsigned int, unsigned int);
21921 unsigned long long __builtin_ia32_bextr_u64 (unsigned long long, unsigned long long);
21922 @end smallexample
21924 The following built-in functions are available when @option{-mbmi2} is used.
21925 All of them generate the machine instruction that is part of the name.
21926 @smallexample
21927 unsigned int _bzhi_u32 (unsigned int, unsigned int)
21928 unsigned int _pdep_u32 (unsigned int, unsigned int)
21929 unsigned int _pext_u32 (unsigned int, unsigned int)
21930 unsigned long long _bzhi_u64 (unsigned long long, unsigned long long)
21931 unsigned long long _pdep_u64 (unsigned long long, unsigned long long)
21932 unsigned long long _pext_u64 (unsigned long long, unsigned long long)
21933 @end smallexample
21935 The following built-in functions are available when @option{-mlzcnt} is used.
21936 All of them generate the machine instruction that is part of the name.
21937 @smallexample
21938 unsigned short __builtin_ia32_lzcnt_u16(unsigned short);
21939 unsigned int __builtin_ia32_lzcnt_u32(unsigned int);
21940 unsigned long long __builtin_ia32_lzcnt_u64 (unsigned long long);
21941 @end smallexample
21943 The following built-in functions are available when @option{-mfxsr} is used.
21944 All of them generate the machine instruction that is part of the name.
21945 @smallexample
21946 void __builtin_ia32_fxsave (void *)
21947 void __builtin_ia32_fxrstor (void *)
21948 void __builtin_ia32_fxsave64 (void *)
21949 void __builtin_ia32_fxrstor64 (void *)
21950 @end smallexample
21952 The following built-in functions are available when @option{-mxsave} is used.
21953 All of them generate the machine instruction that is part of the name.
21954 @smallexample
21955 void __builtin_ia32_xsave (void *, long long)
21956 void __builtin_ia32_xrstor (void *, long long)
21957 void __builtin_ia32_xsave64 (void *, long long)
21958 void __builtin_ia32_xrstor64 (void *, long long)
21959 @end smallexample
21961 The following built-in functions are available when @option{-mxsaveopt} is used.
21962 All of them generate the machine instruction that is part of the name.
21963 @smallexample
21964 void __builtin_ia32_xsaveopt (void *, long long)
21965 void __builtin_ia32_xsaveopt64 (void *, long long)
21966 @end smallexample
21968 The following built-in functions are available when @option{-mtbm} is used.
21969 Both of them generate the immediate form of the bextr machine instruction.
21970 @smallexample
21971 unsigned int __builtin_ia32_bextri_u32 (unsigned int,
21972                                         const unsigned int);
21973 unsigned long long __builtin_ia32_bextri_u64 (unsigned long long,
21974                                               const unsigned long long);
21975 @end smallexample
21978 The following built-in functions are available when @option{-m3dnow} is used.
21979 All of them generate the machine instruction that is part of the name.
21981 @smallexample
21982 void __builtin_ia32_femms (void)
21983 v8qi __builtin_ia32_pavgusb (v8qi, v8qi)
21984 v2si __builtin_ia32_pf2id (v2sf)
21985 v2sf __builtin_ia32_pfacc (v2sf, v2sf)
21986 v2sf __builtin_ia32_pfadd (v2sf, v2sf)
21987 v2si __builtin_ia32_pfcmpeq (v2sf, v2sf)
21988 v2si __builtin_ia32_pfcmpge (v2sf, v2sf)
21989 v2si __builtin_ia32_pfcmpgt (v2sf, v2sf)
21990 v2sf __builtin_ia32_pfmax (v2sf, v2sf)
21991 v2sf __builtin_ia32_pfmin (v2sf, v2sf)
21992 v2sf __builtin_ia32_pfmul (v2sf, v2sf)
21993 v2sf __builtin_ia32_pfrcp (v2sf)
21994 v2sf __builtin_ia32_pfrcpit1 (v2sf, v2sf)
21995 v2sf __builtin_ia32_pfrcpit2 (v2sf, v2sf)
21996 v2sf __builtin_ia32_pfrsqrt (v2sf)
21997 v2sf __builtin_ia32_pfsub (v2sf, v2sf)
21998 v2sf __builtin_ia32_pfsubr (v2sf, v2sf)
21999 v2sf __builtin_ia32_pi2fd (v2si)
22000 v4hi __builtin_ia32_pmulhrw (v4hi, v4hi)
22001 @end smallexample
22003 The following built-in functions are available when @option{-m3dnowa} is used.
22004 All of them generate the machine instruction that is part of the name.
22006 @smallexample
22007 v2si __builtin_ia32_pf2iw (v2sf)
22008 v2sf __builtin_ia32_pfnacc (v2sf, v2sf)
22009 v2sf __builtin_ia32_pfpnacc (v2sf, v2sf)
22010 v2sf __builtin_ia32_pi2fw (v2si)
22011 v2sf __builtin_ia32_pswapdsf (v2sf)
22012 v2si __builtin_ia32_pswapdsi (v2si)
22013 @end smallexample
22015 The following built-in functions are available when @option{-mrtm} is used
22016 They are used for restricted transactional memory. These are the internal
22017 low level functions. Normally the functions in 
22018 @ref{x86 transactional memory intrinsics} should be used instead.
22020 @smallexample
22021 int __builtin_ia32_xbegin ()
22022 void __builtin_ia32_xend ()
22023 void __builtin_ia32_xabort (status)
22024 int __builtin_ia32_xtest ()
22025 @end smallexample
22027 The following built-in functions are available when @option{-mmwaitx} is used.
22028 All of them generate the machine instruction that is part of the name.
22029 @smallexample
22030 void __builtin_ia32_monitorx (void *, unsigned int, unsigned int)
22031 void __builtin_ia32_mwaitx (unsigned int, unsigned int, unsigned int)
22032 @end smallexample
22034 The following built-in functions are available when @option{-mclzero} is used.
22035 All of them generate the machine instruction that is part of the name.
22036 @smallexample
22037 void __builtin_i32_clzero (void *)
22038 @end smallexample
22040 The following built-in functions are available when @option{-mpku} is used.
22041 They generate reads and writes to PKRU.
22042 @smallexample
22043 void __builtin_ia32_wrpkru (unsigned int)
22044 unsigned int __builtin_ia32_rdpkru ()
22045 @end smallexample
22047 The following built-in functions are available when @option{-mcet} or
22048 @option{-mshstk} option is used.  They support shadow stack
22049 machine instructions from Intel Control-flow Enforcement Technology (CET).
22050 Each built-in function generates the  machine instruction that is part
22051 of the function's name.  These are the internal low-level functions.
22052 Normally the functions in @ref{x86 control-flow protection intrinsics}
22053 should be used instead.
22055 @smallexample
22056 unsigned int __builtin_ia32_rdsspd (void)
22057 unsigned long long __builtin_ia32_rdsspq (void)
22058 void __builtin_ia32_incsspd (unsigned int)
22059 void __builtin_ia32_incsspq (unsigned long long)
22060 void __builtin_ia32_saveprevssp(void);
22061 void __builtin_ia32_rstorssp(void *);
22062 void __builtin_ia32_wrssd(unsigned int, void *);
22063 void __builtin_ia32_wrssq(unsigned long long, void *);
22064 void __builtin_ia32_wrussd(unsigned int, void *);
22065 void __builtin_ia32_wrussq(unsigned long long, void *);
22066 void __builtin_ia32_setssbsy(void);
22067 void __builtin_ia32_clrssbsy(void *);
22068 @end smallexample
22070 @node x86 transactional memory intrinsics
22071 @subsection x86 Transactional Memory Intrinsics
22073 These hardware transactional memory intrinsics for x86 allow you to use
22074 memory transactions with RTM (Restricted Transactional Memory).
22075 This support is enabled with the @option{-mrtm} option.
22076 For using HLE (Hardware Lock Elision) see 
22077 @ref{x86 specific memory model extensions for transactional memory} instead.
22079 A memory transaction commits all changes to memory in an atomic way,
22080 as visible to other threads. If the transaction fails it is rolled back
22081 and all side effects discarded.
22083 Generally there is no guarantee that a memory transaction ever succeeds
22084 and suitable fallback code always needs to be supplied.
22086 @deftypefn {RTM Function} {unsigned} _xbegin ()
22087 Start a RTM (Restricted Transactional Memory) transaction. 
22088 Returns @code{_XBEGIN_STARTED} when the transaction
22089 started successfully (note this is not 0, so the constant has to be 
22090 explicitly tested).  
22092 If the transaction aborts, all side effects
22093 are undone and an abort code encoded as a bit mask is returned.
22094 The following macros are defined:
22096 @table @code
22097 @item _XABORT_EXPLICIT
22098 Transaction was explicitly aborted with @code{_xabort}.  The parameter passed
22099 to @code{_xabort} is available with @code{_XABORT_CODE(status)}.
22100 @item _XABORT_RETRY
22101 Transaction retry is possible.
22102 @item _XABORT_CONFLICT
22103 Transaction abort due to a memory conflict with another thread.
22104 @item _XABORT_CAPACITY
22105 Transaction abort due to the transaction using too much memory.
22106 @item _XABORT_DEBUG
22107 Transaction abort due to a debug trap.
22108 @item _XABORT_NESTED
22109 Transaction abort in an inner nested transaction.
22110 @end table
22112 There is no guarantee
22113 any transaction ever succeeds, so there always needs to be a valid
22114 fallback path.
22115 @end deftypefn
22117 @deftypefn {RTM Function} {void} _xend ()
22118 Commit the current transaction. When no transaction is active this faults.
22119 All memory side effects of the transaction become visible
22120 to other threads in an atomic manner.
22121 @end deftypefn
22123 @deftypefn {RTM Function} {int} _xtest ()
22124 Return a nonzero value if a transaction is currently active, otherwise 0.
22125 @end deftypefn
22127 @deftypefn {RTM Function} {void} _xabort (status)
22128 Abort the current transaction. When no transaction is active this is a no-op.
22129 The @var{status} is an 8-bit constant; its value is encoded in the return 
22130 value from @code{_xbegin}.
22131 @end deftypefn
22133 Here is an example showing handling for @code{_XABORT_RETRY}
22134 and a fallback path for other failures:
22136 @smallexample
22137 #include <immintrin.h>
22139 int n_tries, max_tries;
22140 unsigned status = _XABORT_EXPLICIT;
22143 for (n_tries = 0; n_tries < max_tries; n_tries++) 
22144   @{
22145     status = _xbegin ();
22146     if (status == _XBEGIN_STARTED || !(status & _XABORT_RETRY))
22147       break;
22148   @}
22149 if (status == _XBEGIN_STARTED) 
22150   @{
22151     ... transaction code...
22152     _xend ();
22153   @} 
22154 else 
22155   @{
22156     ... non-transactional fallback path...
22157   @}
22158 @end smallexample
22160 @noindent
22161 Note that, in most cases, the transactional and non-transactional code
22162 must synchronize together to ensure consistency.
22164 @node x86 control-flow protection intrinsics
22165 @subsection x86 Control-Flow Protection Intrinsics
22167 @deftypefn {CET Function} {ret_type} _get_ssp (void)
22168 Get the current value of shadow stack pointer if shadow stack support
22169 from Intel CET is enabled in the hardware or @code{0} otherwise.
22170 The @code{ret_type} is @code{unsigned long long} for 64-bit targets 
22171 and @code{unsigned int} for 32-bit targets.
22172 @end deftypefn
22174 @deftypefn {CET Function} void _inc_ssp (unsigned int)
22175 Increment the current shadow stack pointer by the size specified by the
22176 function argument.  The argument is masked to a byte value for security
22177 reasons, so to increment by more than 255 bytes you must call the function
22178 multiple times.
22179 @end deftypefn
22181 The shadow stack unwind code looks like:
22183 @smallexample
22184 #include <immintrin.h>
22186 /* Unwind the shadow stack for EH.  */
22187 #define _Unwind_Frames_Extra(x)       \
22188   do                                  \
22189     @{                                \
22190       _Unwind_Word ssp = _get_ssp (); \
22191       if (ssp != 0)                   \
22192         @{                            \
22193           _Unwind_Word tmp = (x);     \
22194           while (tmp > 255)           \
22195             @{                        \
22196               _inc_ssp (tmp);         \
22197               tmp -= 255;             \
22198             @}                        \
22199           _inc_ssp (tmp);             \
22200         @}                            \
22201     @}                                \
22202     while (0)
22203 @end smallexample
22205 @noindent
22206 This code runs unconditionally on all 64-bit processors.  For 32-bit
22207 processors the code runs on those that support multi-byte NOP instructions.
22209 @node Target Format Checks
22210 @section Format Checks Specific to Particular Target Machines
22212 For some target machines, GCC supports additional options to the
22213 format attribute
22214 (@pxref{Function Attributes,,Declaring Attributes of Functions}).
22216 @menu
22217 * Solaris Format Checks::
22218 * Darwin Format Checks::
22219 @end menu
22221 @node Solaris Format Checks
22222 @subsection Solaris Format Checks
22224 Solaris targets support the @code{cmn_err} (or @code{__cmn_err__}) format
22225 check.  @code{cmn_err} accepts a subset of the standard @code{printf}
22226 conversions, and the two-argument @code{%b} conversion for displaying
22227 bit-fields.  See the Solaris man page for @code{cmn_err} for more information.
22229 @node Darwin Format Checks
22230 @subsection Darwin Format Checks
22232 Darwin targets support the @code{CFString} (or @code{__CFString__}) in the format
22233 attribute context.  Declarations made with such attribution are parsed for correct syntax
22234 and format argument types.  However, parsing of the format string itself is currently undefined
22235 and is not carried out by this version of the compiler.
22237 Additionally, @code{CFStringRefs} (defined by the @code{CoreFoundation} headers) may
22238 also be used as format arguments.  Note that the relevant headers are only likely to be
22239 available on Darwin (OSX) installations.  On such installations, the XCode and system
22240 documentation provide descriptions of @code{CFString}, @code{CFStringRefs} and
22241 associated functions.
22243 @node Pragmas
22244 @section Pragmas Accepted by GCC
22245 @cindex pragmas
22246 @cindex @code{#pragma}
22248 GCC supports several types of pragmas, primarily in order to compile
22249 code originally written for other compilers.  Note that in general
22250 we do not recommend the use of pragmas; @xref{Function Attributes},
22251 for further explanation.
22253 The GNU C preprocessor recognizes several pragmas in addition to the
22254 compiler pragmas documented here.  Refer to the CPP manual for more
22255 information.
22257 @menu
22258 * AArch64 Pragmas::
22259 * ARM Pragmas::
22260 * M32C Pragmas::
22261 * MeP Pragmas::
22262 * RS/6000 and PowerPC Pragmas::
22263 * S/390 Pragmas::
22264 * Darwin Pragmas::
22265 * Solaris Pragmas::
22266 * Symbol-Renaming Pragmas::
22267 * Structure-Layout Pragmas::
22268 * Weak Pragmas::
22269 * Diagnostic Pragmas::
22270 * Visibility Pragmas::
22271 * Push/Pop Macro Pragmas::
22272 * Function Specific Option Pragmas::
22273 * Loop-Specific Pragmas::
22274 @end menu
22276 @node AArch64 Pragmas
22277 @subsection AArch64 Pragmas
22279 The pragmas defined by the AArch64 target correspond to the AArch64
22280 target function attributes.  They can be specified as below:
22281 @smallexample
22282 #pragma GCC target("string")
22283 @end smallexample
22285 where @code{@var{string}} can be any string accepted as an AArch64 target
22286 attribute.  @xref{AArch64 Function Attributes}, for more details
22287 on the permissible values of @code{string}.
22289 @node ARM Pragmas
22290 @subsection ARM Pragmas
22292 The ARM target defines pragmas for controlling the default addition of
22293 @code{long_call} and @code{short_call} attributes to functions.
22294 @xref{Function Attributes}, for information about the effects of these
22295 attributes.
22297 @table @code
22298 @item long_calls
22299 @cindex pragma, long_calls
22300 Set all subsequent functions to have the @code{long_call} attribute.
22302 @item no_long_calls
22303 @cindex pragma, no_long_calls
22304 Set all subsequent functions to have the @code{short_call} attribute.
22306 @item long_calls_off
22307 @cindex pragma, long_calls_off
22308 Do not affect the @code{long_call} or @code{short_call} attributes of
22309 subsequent functions.
22310 @end table
22312 @node M32C Pragmas
22313 @subsection M32C Pragmas
22315 @table @code
22316 @item GCC memregs @var{number}
22317 @cindex pragma, memregs
22318 Overrides the command-line option @code{-memregs=} for the current
22319 file.  Use with care!  This pragma must be before any function in the
22320 file, and mixing different memregs values in different objects may
22321 make them incompatible.  This pragma is useful when a
22322 performance-critical function uses a memreg for temporary values,
22323 as it may allow you to reduce the number of memregs used.
22325 @item ADDRESS @var{name} @var{address}
22326 @cindex pragma, address
22327 For any declared symbols matching @var{name}, this does three things
22328 to that symbol: it forces the symbol to be located at the given
22329 address (a number), it forces the symbol to be volatile, and it
22330 changes the symbol's scope to be static.  This pragma exists for
22331 compatibility with other compilers, but note that the common
22332 @code{1234H} numeric syntax is not supported (use @code{0x1234}
22333 instead).  Example:
22335 @smallexample
22336 #pragma ADDRESS port3 0x103
22337 char port3;
22338 @end smallexample
22340 @end table
22342 @node MeP Pragmas
22343 @subsection MeP Pragmas
22345 @table @code
22347 @item custom io_volatile (on|off)
22348 @cindex pragma, custom io_volatile
22349 Overrides the command-line option @code{-mio-volatile} for the current
22350 file.  Note that for compatibility with future GCC releases, this
22351 option should only be used once before any @code{io} variables in each
22352 file.
22354 @item GCC coprocessor available @var{registers}
22355 @cindex pragma, coprocessor available
22356 Specifies which coprocessor registers are available to the register
22357 allocator.  @var{registers} may be a single register, register range
22358 separated by ellipses, or comma-separated list of those.  Example:
22360 @smallexample
22361 #pragma GCC coprocessor available $c0...$c10, $c28
22362 @end smallexample
22364 @item GCC coprocessor call_saved @var{registers}
22365 @cindex pragma, coprocessor call_saved
22366 Specifies which coprocessor registers are to be saved and restored by
22367 any function using them.  @var{registers} may be a single register,
22368 register range separated by ellipses, or comma-separated list of
22369 those.  Example:
22371 @smallexample
22372 #pragma GCC coprocessor call_saved $c4...$c6, $c31
22373 @end smallexample
22375 @item GCC coprocessor subclass '(A|B|C|D)' = @var{registers}
22376 @cindex pragma, coprocessor subclass
22377 Creates and defines a register class.  These register classes can be
22378 used by inline @code{asm} constructs.  @var{registers} may be a single
22379 register, register range separated by ellipses, or comma-separated
22380 list of those.  Example:
22382 @smallexample
22383 #pragma GCC coprocessor subclass 'B' = $c2, $c4, $c6
22385 asm ("cpfoo %0" : "=B" (x));
22386 @end smallexample
22388 @item GCC disinterrupt @var{name} , @var{name} @dots{}
22389 @cindex pragma, disinterrupt
22390 For the named functions, the compiler adds code to disable interrupts
22391 for the duration of those functions.  If any functions so named 
22392 are not encountered in the source, a warning is emitted that the pragma is
22393 not used.  Examples:
22395 @smallexample
22396 #pragma disinterrupt foo
22397 #pragma disinterrupt bar, grill
22398 int foo () @{ @dots{} @}
22399 @end smallexample
22401 @item GCC call @var{name} , @var{name} @dots{}
22402 @cindex pragma, call
22403 For the named functions, the compiler always uses a register-indirect
22404 call model when calling the named functions.  Examples:
22406 @smallexample
22407 extern int foo ();
22408 #pragma call foo
22409 @end smallexample
22411 @end table
22413 @node RS/6000 and PowerPC Pragmas
22414 @subsection RS/6000 and PowerPC Pragmas
22416 The RS/6000 and PowerPC targets define one pragma for controlling
22417 whether or not the @code{longcall} attribute is added to function
22418 declarations by default.  This pragma overrides the @option{-mlongcall}
22419 option, but not the @code{longcall} and @code{shortcall} attributes.
22420 @xref{RS/6000 and PowerPC Options}, for more information about when long
22421 calls are and are not necessary.
22423 @table @code
22424 @item longcall (1)
22425 @cindex pragma, longcall
22426 Apply the @code{longcall} attribute to all subsequent function
22427 declarations.
22429 @item longcall (0)
22430 Do not apply the @code{longcall} attribute to subsequent function
22431 declarations.
22432 @end table
22434 @c Describe h8300 pragmas here.
22435 @c Describe sh pragmas here.
22436 @c Describe v850 pragmas here.
22438 @node S/390 Pragmas
22439 @subsection S/390 Pragmas
22441 The pragmas defined by the S/390 target correspond to the S/390
22442 target function attributes and some the additional options:
22444 @table @samp
22445 @item zvector
22446 @itemx no-zvector
22447 @end table
22449 Note that options of the pragma, unlike options of the target
22450 attribute, do change the value of preprocessor macros like
22451 @code{__VEC__}.  They can be specified as below:
22453 @smallexample
22454 #pragma GCC target("string[,string]...")
22455 #pragma GCC target("string"[,"string"]...)
22456 @end smallexample
22458 @node Darwin Pragmas
22459 @subsection Darwin Pragmas
22461 The following pragmas are available for all architectures running the
22462 Darwin operating system.  These are useful for compatibility with other
22463 Mac OS compilers.
22465 @table @code
22466 @item mark @var{tokens}@dots{}
22467 @cindex pragma, mark
22468 This pragma is accepted, but has no effect.
22470 @item options align=@var{alignment}
22471 @cindex pragma, options align
22472 This pragma sets the alignment of fields in structures.  The values of
22473 @var{alignment} may be @code{mac68k}, to emulate m68k alignment, or
22474 @code{power}, to emulate PowerPC alignment.  Uses of this pragma nest
22475 properly; to restore the previous setting, use @code{reset} for the
22476 @var{alignment}.
22478 @item segment @var{tokens}@dots{}
22479 @cindex pragma, segment
22480 This pragma is accepted, but has no effect.
22482 @item unused (@var{var} [, @var{var}]@dots{})
22483 @cindex pragma, unused
22484 This pragma declares variables to be possibly unused.  GCC does not
22485 produce warnings for the listed variables.  The effect is similar to
22486 that of the @code{unused} attribute, except that this pragma may appear
22487 anywhere within the variables' scopes.
22488 @end table
22490 @node Solaris Pragmas
22491 @subsection Solaris Pragmas
22493 The Solaris target supports @code{#pragma redefine_extname}
22494 (@pxref{Symbol-Renaming Pragmas}).  It also supports additional
22495 @code{#pragma} directives for compatibility with the system compiler.
22497 @table @code
22498 @item align @var{alignment} (@var{variable} [, @var{variable}]...)
22499 @cindex pragma, align
22501 Increase the minimum alignment of each @var{variable} to @var{alignment}.
22502 This is the same as GCC's @code{aligned} attribute @pxref{Variable
22503 Attributes}).  Macro expansion occurs on the arguments to this pragma
22504 when compiling C and Objective-C@.  It does not currently occur when
22505 compiling C++, but this is a bug which may be fixed in a future
22506 release.
22508 @item fini (@var{function} [, @var{function}]...)
22509 @cindex pragma, fini
22511 This pragma causes each listed @var{function} to be called after
22512 main, or during shared module unloading, by adding a call to the
22513 @code{.fini} section.
22515 @item init (@var{function} [, @var{function}]...)
22516 @cindex pragma, init
22518 This pragma causes each listed @var{function} to be called during
22519 initialization (before @code{main}) or during shared module loading, by
22520 adding a call to the @code{.init} section.
22522 @end table
22524 @node Symbol-Renaming Pragmas
22525 @subsection Symbol-Renaming Pragmas
22527 GCC supports a @code{#pragma} directive that changes the name used in
22528 assembly for a given declaration. While this pragma is supported on all
22529 platforms, it is intended primarily to provide compatibility with the
22530 Solaris system headers. This effect can also be achieved using the asm
22531 labels extension (@pxref{Asm Labels}).
22533 @table @code
22534 @item redefine_extname @var{oldname} @var{newname}
22535 @cindex pragma, redefine_extname
22537 This pragma gives the C function @var{oldname} the assembly symbol
22538 @var{newname}.  The preprocessor macro @code{__PRAGMA_REDEFINE_EXTNAME}
22539 is defined if this pragma is available (currently on all platforms).
22540 @end table
22542 This pragma and the @code{asm} labels extension interact in a complicated
22543 manner.  Here are some corner cases you may want to be aware of:
22545 @enumerate
22546 @item This pragma silently applies only to declarations with external
22547 linkage.  The @code{asm} label feature does not have this restriction.
22549 @item In C++, this pragma silently applies only to declarations with
22550 ``C'' linkage.  Again, @code{asm} labels do not have this restriction.
22552 @item If either of the ways of changing the assembly name of a
22553 declaration are applied to a declaration whose assembly name has
22554 already been determined (either by a previous use of one of these
22555 features, or because the compiler needed the assembly name in order to
22556 generate code), and the new name is different, a warning issues and
22557 the name does not change.
22559 @item The @var{oldname} used by @code{#pragma redefine_extname} is
22560 always the C-language name.
22561 @end enumerate
22563 @node Structure-Layout Pragmas
22564 @subsection Structure-Layout Pragmas
22566 For compatibility with Microsoft Windows compilers, GCC supports a
22567 set of @code{#pragma} directives that change the maximum alignment of
22568 members of structures (other than zero-width bit-fields), unions, and
22569 classes subsequently defined. The @var{n} value below always is required
22570 to be a small power of two and specifies the new alignment in bytes.
22572 @enumerate
22573 @item @code{#pragma pack(@var{n})} simply sets the new alignment.
22574 @item @code{#pragma pack()} sets the alignment to the one that was in
22575 effect when compilation started (see also command-line option
22576 @option{-fpack-struct[=@var{n}]} @pxref{Code Gen Options}).
22577 @item @code{#pragma pack(push[,@var{n}])} pushes the current alignment
22578 setting on an internal stack and then optionally sets the new alignment.
22579 @item @code{#pragma pack(pop)} restores the alignment setting to the one
22580 saved at the top of the internal stack (and removes that stack entry).
22581 Note that @code{#pragma pack([@var{n}])} does not influence this internal
22582 stack; thus it is possible to have @code{#pragma pack(push)} followed by
22583 multiple @code{#pragma pack(@var{n})} instances and finalized by a single
22584 @code{#pragma pack(pop)}.
22585 @end enumerate
22587 Some targets, e.g.@: x86 and PowerPC, support the @code{#pragma ms_struct}
22588 directive which lays out structures and unions subsequently defined as the
22589 documented @code{__attribute__ ((ms_struct))}.
22591 @enumerate
22592 @item @code{#pragma ms_struct on} turns on the Microsoft layout.
22593 @item @code{#pragma ms_struct off} turns off the Microsoft layout.
22594 @item @code{#pragma ms_struct reset} goes back to the default layout.
22595 @end enumerate
22597 Most targets also support the @code{#pragma scalar_storage_order} directive
22598 which lays out structures and unions subsequently defined as the documented
22599 @code{__attribute__ ((scalar_storage_order))}.
22601 @enumerate
22602 @item @code{#pragma scalar_storage_order big-endian} sets the storage order
22603 of the scalar fields to big-endian.
22604 @item @code{#pragma scalar_storage_order little-endian} sets the storage order
22605 of the scalar fields to little-endian.
22606 @item @code{#pragma scalar_storage_order default} goes back to the endianness
22607 that was in effect when compilation started (see also command-line option
22608 @option{-fsso-struct=@var{endianness}} @pxref{C Dialect Options}).
22609 @end enumerate
22611 @node Weak Pragmas
22612 @subsection Weak Pragmas
22614 For compatibility with SVR4, GCC supports a set of @code{#pragma}
22615 directives for declaring symbols to be weak, and defining weak
22616 aliases.
22618 @table @code
22619 @item #pragma weak @var{symbol}
22620 @cindex pragma, weak
22621 This pragma declares @var{symbol} to be weak, as if the declaration
22622 had the attribute of the same name.  The pragma may appear before
22623 or after the declaration of @var{symbol}.  It is not an error for
22624 @var{symbol} to never be defined at all.
22626 @item #pragma weak @var{symbol1} = @var{symbol2}
22627 This pragma declares @var{symbol1} to be a weak alias of @var{symbol2}.
22628 It is an error if @var{symbol2} is not defined in the current
22629 translation unit.
22630 @end table
22632 @node Diagnostic Pragmas
22633 @subsection Diagnostic Pragmas
22635 GCC allows the user to selectively enable or disable certain types of
22636 diagnostics, and change the kind of the diagnostic.  For example, a
22637 project's policy might require that all sources compile with
22638 @option{-Werror} but certain files might have exceptions allowing
22639 specific types of warnings.  Or, a project might selectively enable
22640 diagnostics and treat them as errors depending on which preprocessor
22641 macros are defined.
22643 @table @code
22644 @item #pragma GCC diagnostic @var{kind} @var{option}
22645 @cindex pragma, diagnostic
22647 Modifies the disposition of a diagnostic.  Note that not all
22648 diagnostics are modifiable; at the moment only warnings (normally
22649 controlled by @samp{-W@dots{}}) can be controlled, and not all of them.
22650 Use @option{-fdiagnostics-show-option} to determine which diagnostics
22651 are controllable and which option controls them.
22653 @var{kind} is @samp{error} to treat this diagnostic as an error,
22654 @samp{warning} to treat it like a warning (even if @option{-Werror} is
22655 in effect), or @samp{ignored} if the diagnostic is to be ignored.
22656 @var{option} is a double quoted string that matches the command-line
22657 option.
22659 @smallexample
22660 #pragma GCC diagnostic warning "-Wformat"
22661 #pragma GCC diagnostic error "-Wformat"
22662 #pragma GCC diagnostic ignored "-Wformat"
22663 @end smallexample
22665 Note that these pragmas override any command-line options.  GCC keeps
22666 track of the location of each pragma, and issues diagnostics according
22667 to the state as of that point in the source file.  Thus, pragmas occurring
22668 after a line do not affect diagnostics caused by that line.
22670 @item #pragma GCC diagnostic push
22671 @itemx #pragma GCC diagnostic pop
22673 Causes GCC to remember the state of the diagnostics as of each
22674 @code{push}, and restore to that point at each @code{pop}.  If a
22675 @code{pop} has no matching @code{push}, the command-line options are
22676 restored.
22678 @smallexample
22679 #pragma GCC diagnostic error "-Wuninitialized"
22680   foo(a);                       /* error is given for this one */
22681 #pragma GCC diagnostic push
22682 #pragma GCC diagnostic ignored "-Wuninitialized"
22683   foo(b);                       /* no diagnostic for this one */
22684 #pragma GCC diagnostic pop
22685   foo(c);                       /* error is given for this one */
22686 #pragma GCC diagnostic pop
22687   foo(d);                       /* depends on command-line options */
22688 @end smallexample
22690 @end table
22692 GCC also offers a simple mechanism for printing messages during
22693 compilation.
22695 @table @code
22696 @item #pragma message @var{string}
22697 @cindex pragma, diagnostic
22699 Prints @var{string} as a compiler message on compilation.  The message
22700 is informational only, and is neither a compilation warning nor an
22701 error.  Newlines can be included in the string by using the @samp{\n}
22702 escape sequence.
22704 @smallexample
22705 #pragma message "Compiling " __FILE__ "..."
22706 @end smallexample
22708 @var{string} may be parenthesized, and is printed with location
22709 information.  For example,
22711 @smallexample
22712 #define DO_PRAGMA(x) _Pragma (#x)
22713 #define TODO(x) DO_PRAGMA(message ("TODO - " #x))
22715 TODO(Remember to fix this)
22716 @end smallexample
22718 @noindent
22719 prints @samp{/tmp/file.c:4: note: #pragma message:
22720 TODO - Remember to fix this}.
22722 @item #pragma GCC error @var{message}
22723 @cindex pragma, diagnostic
22724 Generates an error message.  This pragma @emph{is} considered to
22725 indicate an error in the compilation, and it will be treated as such.
22727 Newlines can be included in the string by using the @samp{\n}
22728 escape sequence.  They will be displayed as newlines even if the
22729 @option{-fmessage-length} option is set to zero.
22731 The error is only generated if the pragma is present in the code after
22732 pre-processing has been completed.  It does not matter however if the
22733 code containing the pragma is unreachable:
22735 @smallexample
22736 #if 0
22737 #pragma GCC error "this error is not seen"
22738 #endif
22739 void foo (void)
22741   return;
22742 #pragma GCC error "this error is seen"
22744 @end smallexample
22746 @item #pragma GCC warning @var{message}
22747 @cindex pragma, diagnostic
22748 This is just like @samp{pragma GCC error} except that a warning
22749 message is issued instead of an error message.  Unless
22750 @option{-Werror} is in effect, in which case this pragma will generate
22751 an error as well.
22753 @end table
22755 @node Visibility Pragmas
22756 @subsection Visibility Pragmas
22758 @table @code
22759 @item #pragma GCC visibility push(@var{visibility})
22760 @itemx #pragma GCC visibility pop
22761 @cindex pragma, visibility
22763 This pragma allows the user to set the visibility for multiple
22764 declarations without having to give each a visibility attribute
22765 (@pxref{Function Attributes}).
22767 In C++, @samp{#pragma GCC visibility} affects only namespace-scope
22768 declarations.  Class members and template specializations are not
22769 affected; if you want to override the visibility for a particular
22770 member or instantiation, you must use an attribute.
22772 @end table
22775 @node Push/Pop Macro Pragmas
22776 @subsection Push/Pop Macro Pragmas
22778 For compatibility with Microsoft Windows compilers, GCC supports
22779 @samp{#pragma push_macro(@var{"macro_name"})}
22780 and @samp{#pragma pop_macro(@var{"macro_name"})}.
22782 @table @code
22783 @item #pragma push_macro(@var{"macro_name"})
22784 @cindex pragma, push_macro
22785 This pragma saves the value of the macro named as @var{macro_name} to
22786 the top of the stack for this macro.
22788 @item #pragma pop_macro(@var{"macro_name"})
22789 @cindex pragma, pop_macro
22790 This pragma sets the value of the macro named as @var{macro_name} to
22791 the value on top of the stack for this macro. If the stack for
22792 @var{macro_name} is empty, the value of the macro remains unchanged.
22793 @end table
22795 For example:
22797 @smallexample
22798 #define X  1
22799 #pragma push_macro("X")
22800 #undef X
22801 #define X -1
22802 #pragma pop_macro("X")
22803 int x [X];
22804 @end smallexample
22806 @noindent
22807 In this example, the definition of X as 1 is saved by @code{#pragma
22808 push_macro} and restored by @code{#pragma pop_macro}.
22810 @node Function Specific Option Pragmas
22811 @subsection Function Specific Option Pragmas
22813 @table @code
22814 @item #pragma GCC target (@var{string}, @dots{})
22815 @cindex pragma GCC target
22817 This pragma allows you to set target-specific options for functions
22818 defined later in the source file.  One or more strings can be
22819 specified.  Each function that is defined after this point is treated
22820 as if it had been declared with one @code{target(}@var{string}@code{)}
22821 attribute for each @var{string} argument.  The parentheses around
22822 the strings in the pragma are optional.  @xref{Function Attributes},
22823 for more information about the @code{target} attribute and the attribute
22824 syntax.
22826 The @code{#pragma GCC target} pragma is presently implemented for
22827 x86, ARM, AArch64, PowerPC, S/390, and Nios II targets only.
22829 @item #pragma GCC optimize (@var{string}, @dots{})
22830 @cindex pragma GCC optimize
22832 This pragma allows you to set global optimization options for functions
22833 defined later in the source file.  One or more strings can be
22834 specified.  Each function that is defined after this point is treated
22835 as if it had been declared with one @code{optimize(}@var{string}@code{)}
22836 attribute for each @var{string} argument.  The parentheses around
22837 the strings in the pragma are optional.  @xref{Function Attributes},
22838 for more information about the @code{optimize} attribute and the attribute
22839 syntax.
22841 @item #pragma GCC push_options
22842 @itemx #pragma GCC pop_options
22843 @cindex pragma GCC push_options
22844 @cindex pragma GCC pop_options
22846 These pragmas maintain a stack of the current target and optimization
22847 options.  It is intended for include files where you temporarily want
22848 to switch to using a different @samp{#pragma GCC target} or
22849 @samp{#pragma GCC optimize} and then to pop back to the previous
22850 options.
22852 @item #pragma GCC reset_options
22853 @cindex pragma GCC reset_options
22855 This pragma clears the current @code{#pragma GCC target} and
22856 @code{#pragma GCC optimize} to use the default switches as specified
22857 on the command line.
22859 @end table
22861 @node Loop-Specific Pragmas
22862 @subsection Loop-Specific Pragmas
22864 @table @code
22865 @item #pragma GCC ivdep
22866 @cindex pragma GCC ivdep
22868 With this pragma, the programmer asserts that there are no loop-carried
22869 dependencies which would prevent consecutive iterations of
22870 the following loop from executing concurrently with SIMD
22871 (single instruction multiple data) instructions.
22873 For example, the compiler can only unconditionally vectorize the following
22874 loop with the pragma:
22876 @smallexample
22877 void foo (int n, int *a, int *b, int *c)
22879   int i, j;
22880 #pragma GCC ivdep
22881   for (i = 0; i < n; ++i)
22882     a[i] = b[i] + c[i];
22884 @end smallexample
22886 @noindent
22887 In this example, using the @code{restrict} qualifier had the same
22888 effect. In the following example, that would not be possible. Assume
22889 @math{k < -m} or @math{k >= m}. Only with the pragma, the compiler knows
22890 that it can unconditionally vectorize the following loop:
22892 @smallexample
22893 void ignore_vec_dep (int *a, int k, int c, int m)
22895 #pragma GCC ivdep
22896   for (int i = 0; i < m; i++)
22897     a[i] = a[i + k] * c;
22899 @end smallexample
22901 @item #pragma GCC unroll @var{n}
22902 @cindex pragma GCC unroll @var{n}
22904 You can use this pragma to control how many times a loop should be unrolled.
22905 It must be placed immediately before a @code{for}, @code{while} or @code{do}
22906 loop or a @code{#pragma GCC ivdep}, and applies only to the loop that follows.
22907 @var{n} is an integer constant expression specifying the unrolling factor.
22908 The values of @math{0} and @math{1} block any unrolling of the loop.
22910 @end table
22912 @node Unnamed Fields
22913 @section Unnamed Structure and Union Fields
22914 @cindex @code{struct}
22915 @cindex @code{union}
22917 As permitted by ISO C11 and for compatibility with other compilers,
22918 GCC allows you to define
22919 a structure or union that contains, as fields, structures and unions
22920 without names.  For example:
22922 @smallexample
22923 struct @{
22924   int a;
22925   union @{
22926     int b;
22927     float c;
22928   @};
22929   int d;
22930 @} foo;
22931 @end smallexample
22933 @noindent
22934 In this example, you are able to access members of the unnamed
22935 union with code like @samp{foo.b}.  Note that only unnamed structs and
22936 unions are allowed, you may not have, for example, an unnamed
22937 @code{int}.
22939 You must never create such structures that cause ambiguous field definitions.
22940 For example, in this structure:
22942 @smallexample
22943 struct @{
22944   int a;
22945   struct @{
22946     int a;
22947   @};
22948 @} foo;
22949 @end smallexample
22951 @noindent
22952 it is ambiguous which @code{a} is being referred to with @samp{foo.a}.
22953 The compiler gives errors for such constructs.
22955 @opindex fms-extensions
22956 Unless @option{-fms-extensions} is used, the unnamed field must be a
22957 structure or union definition without a tag (for example, @samp{struct
22958 @{ int a; @};}).  If @option{-fms-extensions} is used, the field may
22959 also be a definition with a tag such as @samp{struct foo @{ int a;
22960 @};}, a reference to a previously defined structure or union such as
22961 @samp{struct foo;}, or a reference to a @code{typedef} name for a
22962 previously defined structure or union type.
22964 @opindex fplan9-extensions
22965 The option @option{-fplan9-extensions} enables
22966 @option{-fms-extensions} as well as two other extensions.  First, a
22967 pointer to a structure is automatically converted to a pointer to an
22968 anonymous field for assignments and function calls.  For example:
22970 @smallexample
22971 struct s1 @{ int a; @};
22972 struct s2 @{ struct s1; @};
22973 extern void f1 (struct s1 *);
22974 void f2 (struct s2 *p) @{ f1 (p); @}
22975 @end smallexample
22977 @noindent
22978 In the call to @code{f1} inside @code{f2}, the pointer @code{p} is
22979 converted into a pointer to the anonymous field.
22981 Second, when the type of an anonymous field is a @code{typedef} for a
22982 @code{struct} or @code{union}, code may refer to the field using the
22983 name of the @code{typedef}.
22985 @smallexample
22986 typedef struct @{ int a; @} s1;
22987 struct s2 @{ s1; @};
22988 s1 f1 (struct s2 *p) @{ return p->s1; @}
22989 @end smallexample
22991 These usages are only permitted when they are not ambiguous.
22993 @node Thread-Local
22994 @section Thread-Local Storage
22995 @cindex Thread-Local Storage
22996 @cindex @acronym{TLS}
22997 @cindex @code{__thread}
22999 Thread-local storage (@acronym{TLS}) is a mechanism by which variables
23000 are allocated such that there is one instance of the variable per extant
23001 thread.  The runtime model GCC uses to implement this originates
23002 in the IA-64 processor-specific ABI, but has since been migrated
23003 to other processors as well.  It requires significant support from
23004 the linker (@command{ld}), dynamic linker (@command{ld.so}), and
23005 system libraries (@file{libc.so} and @file{libpthread.so}), so it
23006 is not available everywhere.
23008 At the user level, the extension is visible with a new storage
23009 class keyword: @code{__thread}.  For example:
23011 @smallexample
23012 __thread int i;
23013 extern __thread struct state s;
23014 static __thread char *p;
23015 @end smallexample
23017 The @code{__thread} specifier may be used alone, with the @code{extern}
23018 or @code{static} specifiers, but with no other storage class specifier.
23019 When used with @code{extern} or @code{static}, @code{__thread} must appear
23020 immediately after the other storage class specifier.
23022 The @code{__thread} specifier may be applied to any global, file-scoped
23023 static, function-scoped static, or static data member of a class.  It may
23024 not be applied to block-scoped automatic or non-static data member.
23026 When the address-of operator is applied to a thread-local variable, it is
23027 evaluated at run time and returns the address of the current thread's
23028 instance of that variable.  An address so obtained may be used by any
23029 thread.  When a thread terminates, any pointers to thread-local variables
23030 in that thread become invalid.
23032 No static initialization may refer to the address of a thread-local variable.
23034 In C++, if an initializer is present for a thread-local variable, it must
23035 be a @var{constant-expression}, as defined in 5.19.2 of the ANSI/ISO C++
23036 standard.
23038 See @uref{https://www.akkadia.org/drepper/tls.pdf,
23039 ELF Handling For Thread-Local Storage} for a detailed explanation of
23040 the four thread-local storage addressing models, and how the runtime
23041 is expected to function.
23043 @menu
23044 * C99 Thread-Local Edits::
23045 * C++98 Thread-Local Edits::
23046 @end menu
23048 @node C99 Thread-Local Edits
23049 @subsection ISO/IEC 9899:1999 Edits for Thread-Local Storage
23051 The following are a set of changes to ISO/IEC 9899:1999 (aka C99)
23052 that document the exact semantics of the language extension.
23054 @itemize @bullet
23055 @item
23056 @cite{5.1.2  Execution environments}
23058 Add new text after paragraph 1
23060 @quotation
23061 Within either execution environment, a @dfn{thread} is a flow of
23062 control within a program.  It is implementation defined whether
23063 or not there may be more than one thread associated with a program.
23064 It is implementation defined how threads beyond the first are
23065 created, the name and type of the function called at thread
23066 startup, and how threads may be terminated.  However, objects
23067 with thread storage duration shall be initialized before thread
23068 startup.
23069 @end quotation
23071 @item
23072 @cite{6.2.4  Storage durations of objects}
23074 Add new text before paragraph 3
23076 @quotation
23077 An object whose identifier is declared with the storage-class
23078 specifier @w{@code{__thread}} has @dfn{thread storage duration}.
23079 Its lifetime is the entire execution of the thread, and its
23080 stored value is initialized only once, prior to thread startup.
23081 @end quotation
23083 @item
23084 @cite{6.4.1  Keywords}
23086 Add @code{__thread}.
23088 @item
23089 @cite{6.7.1  Storage-class specifiers}
23091 Add @code{__thread} to the list of storage class specifiers in
23092 paragraph 1.
23094 Change paragraph 2 to
23096 @quotation
23097 With the exception of @code{__thread}, at most one storage-class
23098 specifier may be given [@dots{}].  The @code{__thread} specifier may
23099 be used alone, or immediately following @code{extern} or
23100 @code{static}.
23101 @end quotation
23103 Add new text after paragraph 6
23105 @quotation
23106 The declaration of an identifier for a variable that has
23107 block scope that specifies @code{__thread} shall also
23108 specify either @code{extern} or @code{static}.
23110 The @code{__thread} specifier shall be used only with
23111 variables.
23112 @end quotation
23113 @end itemize
23115 @node C++98 Thread-Local Edits
23116 @subsection ISO/IEC 14882:1998 Edits for Thread-Local Storage
23118 The following are a set of changes to ISO/IEC 14882:1998 (aka C++98)
23119 that document the exact semantics of the language extension.
23121 @itemize @bullet
23122 @item
23123 @b{[intro.execution]}
23125 New text after paragraph 4
23127 @quotation
23128 A @dfn{thread} is a flow of control within the abstract machine.
23129 It is implementation defined whether or not there may be more than
23130 one thread.
23131 @end quotation
23133 New text after paragraph 7
23135 @quotation
23136 It is unspecified whether additional action must be taken to
23137 ensure when and whether side effects are visible to other threads.
23138 @end quotation
23140 @item
23141 @b{[lex.key]}
23143 Add @code{__thread}.
23145 @item
23146 @b{[basic.start.main]}
23148 Add after paragraph 5
23150 @quotation
23151 The thread that begins execution at the @code{main} function is called
23152 the @dfn{main thread}.  It is implementation defined how functions
23153 beginning threads other than the main thread are designated or typed.
23154 A function so designated, as well as the @code{main} function, is called
23155 a @dfn{thread startup function}.  It is implementation defined what
23156 happens if a thread startup function returns.  It is implementation
23157 defined what happens to other threads when any thread calls @code{exit}.
23158 @end quotation
23160 @item
23161 @b{[basic.start.init]}
23163 Add after paragraph 4
23165 @quotation
23166 The storage for an object of thread storage duration shall be
23167 statically initialized before the first statement of the thread startup
23168 function.  An object of thread storage duration shall not require
23169 dynamic initialization.
23170 @end quotation
23172 @item
23173 @b{[basic.start.term]}
23175 Add after paragraph 3
23177 @quotation
23178 The type of an object with thread storage duration shall not have a
23179 non-trivial destructor, nor shall it be an array type whose elements
23180 (directly or indirectly) have non-trivial destructors.
23181 @end quotation
23183 @item
23184 @b{[basic.stc]}
23186 Add ``thread storage duration'' to the list in paragraph 1.
23188 Change paragraph 2
23190 @quotation
23191 Thread, static, and automatic storage durations are associated with
23192 objects introduced by declarations [@dots{}].
23193 @end quotation
23195 Add @code{__thread} to the list of specifiers in paragraph 3.
23197 @item
23198 @b{[basic.stc.thread]}
23200 New section before @b{[basic.stc.static]}
23202 @quotation
23203 The keyword @code{__thread} applied to a non-local object gives the
23204 object thread storage duration.
23206 A local variable or class data member declared both @code{static}
23207 and @code{__thread} gives the variable or member thread storage
23208 duration.
23209 @end quotation
23211 @item
23212 @b{[basic.stc.static]}
23214 Change paragraph 1
23216 @quotation
23217 All objects that have neither thread storage duration, dynamic
23218 storage duration nor are local [@dots{}].
23219 @end quotation
23221 @item
23222 @b{[dcl.stc]}
23224 Add @code{__thread} to the list in paragraph 1.
23226 Change paragraph 1
23228 @quotation
23229 With the exception of @code{__thread}, at most one
23230 @var{storage-class-specifier} shall appear in a given
23231 @var{decl-specifier-seq}.  The @code{__thread} specifier may
23232 be used alone, or immediately following the @code{extern} or
23233 @code{static} specifiers.  [@dots{}]
23234 @end quotation
23236 Add after paragraph 5
23238 @quotation
23239 The @code{__thread} specifier can be applied only to the names of objects
23240 and to anonymous unions.
23241 @end quotation
23243 @item
23244 @b{[class.mem]}
23246 Add after paragraph 6
23248 @quotation
23249 Non-@code{static} members shall not be @code{__thread}.
23250 @end quotation
23251 @end itemize
23253 @node Binary constants
23254 @section Binary Constants using the @samp{0b} Prefix
23255 @cindex Binary constants using the @samp{0b} prefix
23257 Integer constants can be written as binary constants, consisting of a
23258 sequence of @samp{0} and @samp{1} digits, prefixed by @samp{0b} or
23259 @samp{0B}.  This is particularly useful in environments that operate a
23260 lot on the bit level (like microcontrollers).
23262 The following statements are identical:
23264 @smallexample
23265 i =       42;
23266 i =     0x2a;
23267 i =      052;
23268 i = 0b101010;
23269 @end smallexample
23271 The type of these constants follows the same rules as for octal or
23272 hexadecimal integer constants, so suffixes like @samp{L} or @samp{UL}
23273 can be applied.
23275 @node C++ Extensions
23276 @chapter Extensions to the C++ Language
23277 @cindex extensions, C++ language
23278 @cindex C++ language extensions
23280 The GNU compiler provides these extensions to the C++ language (and you
23281 can also use most of the C language extensions in your C++ programs).  If you
23282 want to write code that checks whether these features are available, you can
23283 test for the GNU compiler the same way as for C programs: check for a
23284 predefined macro @code{__GNUC__}.  You can also use @code{__GNUG__} to
23285 test specifically for GNU C++ (@pxref{Common Predefined Macros,,
23286 Predefined Macros,cpp,The GNU C Preprocessor}).
23288 @menu
23289 * C++ Volatiles::       What constitutes an access to a volatile object.
23290 * Restricted Pointers:: C99 restricted pointers and references.
23291 * Vague Linkage::       Where G++ puts inlines, vtables and such.
23292 * C++ Interface::       You can use a single C++ header file for both
23293                         declarations and definitions.
23294 * Template Instantiation:: Methods for ensuring that exactly one copy of
23295                         each needed template instantiation is emitted.
23296 * Bound member functions:: You can extract a function pointer to the
23297                         method denoted by a @samp{->*} or @samp{.*} expression.
23298 * C++ Attributes::      Variable, function, and type attributes for C++ only.
23299 * Function Multiversioning::   Declaring multiple function versions.
23300 * Type Traits::         Compiler support for type traits.
23301 * C++ Concepts::        Improved support for generic programming.
23302 * Deprecated Features:: Things will disappear from G++.
23303 * Backwards Compatibility:: Compatibilities with earlier definitions of C++.
23304 @end menu
23306 @node C++ Volatiles
23307 @section When is a Volatile C++ Object Accessed?
23308 @cindex accessing volatiles
23309 @cindex volatile read
23310 @cindex volatile write
23311 @cindex volatile access
23313 The C++ standard differs from the C standard in its treatment of
23314 volatile objects.  It fails to specify what constitutes a volatile
23315 access, except to say that C++ should behave in a similar manner to C
23316 with respect to volatiles, where possible.  However, the different
23317 lvalueness of expressions between C and C++ complicate the behavior.
23318 G++ behaves the same as GCC for volatile access, @xref{C
23319 Extensions,,Volatiles}, for a description of GCC's behavior.
23321 The C and C++ language specifications differ when an object is
23322 accessed in a void context:
23324 @smallexample
23325 volatile int *src = @var{somevalue};
23326 *src;
23327 @end smallexample
23329 The C++ standard specifies that such expressions do not undergo lvalue
23330 to rvalue conversion, and that the type of the dereferenced object may
23331 be incomplete.  The C++ standard does not specify explicitly that it
23332 is lvalue to rvalue conversion that is responsible for causing an
23333 access.  There is reason to believe that it is, because otherwise
23334 certain simple expressions become undefined.  However, because it
23335 would surprise most programmers, G++ treats dereferencing a pointer to
23336 volatile object of complete type as GCC would do for an equivalent
23337 type in C@.  When the object has incomplete type, G++ issues a
23338 warning; if you wish to force an error, you must force a conversion to
23339 rvalue with, for instance, a static cast.
23341 When using a reference to volatile, G++ does not treat equivalent
23342 expressions as accesses to volatiles, but instead issues a warning that
23343 no volatile is accessed.  The rationale for this is that otherwise it
23344 becomes difficult to determine where volatile access occur, and not
23345 possible to ignore the return value from functions returning volatile
23346 references.  Again, if you wish to force a read, cast the reference to
23347 an rvalue.
23349 G++ implements the same behavior as GCC does when assigning to a
23350 volatile object---there is no reread of the assigned-to object, the
23351 assigned rvalue is reused.  Note that in C++ assignment expressions
23352 are lvalues, and if used as an lvalue, the volatile object is
23353 referred to.  For instance, @var{vref} refers to @var{vobj}, as
23354 expected, in the following example:
23356 @smallexample
23357 volatile int vobj;
23358 volatile int &vref = vobj = @var{something};
23359 @end smallexample
23361 @node Restricted Pointers
23362 @section Restricting Pointer Aliasing
23363 @cindex restricted pointers
23364 @cindex restricted references
23365 @cindex restricted this pointer
23367 As with the C front end, G++ understands the C99 feature of restricted pointers,
23368 specified with the @code{__restrict__}, or @code{__restrict} type
23369 qualifier.  Because you cannot compile C++ by specifying the @option{-std=c99}
23370 language flag, @code{restrict} is not a keyword in C++.
23372 In addition to allowing restricted pointers, you can specify restricted
23373 references, which indicate that the reference is not aliased in the local
23374 context.
23376 @smallexample
23377 void fn (int *__restrict__ rptr, int &__restrict__ rref)
23379   /* @r{@dots{}} */
23381 @end smallexample
23383 @noindent
23384 In the body of @code{fn}, @var{rptr} points to an unaliased integer and
23385 @var{rref} refers to a (different) unaliased integer.
23387 You may also specify whether a member function's @var{this} pointer is
23388 unaliased by using @code{__restrict__} as a member function qualifier.
23390 @smallexample
23391 void T::fn () __restrict__
23393   /* @r{@dots{}} */
23395 @end smallexample
23397 @noindent
23398 Within the body of @code{T::fn}, @var{this} has the effective
23399 definition @code{T *__restrict__ const this}.  Notice that the
23400 interpretation of a @code{__restrict__} member function qualifier is
23401 different to that of @code{const} or @code{volatile} qualifier, in that it
23402 is applied to the pointer rather than the object.  This is consistent with
23403 other compilers that implement restricted pointers.
23405 As with all outermost parameter qualifiers, @code{__restrict__} is
23406 ignored in function definition matching.  This means you only need to
23407 specify @code{__restrict__} in a function definition, rather than
23408 in a function prototype as well.
23410 @node Vague Linkage
23411 @section Vague Linkage
23412 @cindex vague linkage
23414 There are several constructs in C++ that require space in the object
23415 file but are not clearly tied to a single translation unit.  We say that
23416 these constructs have ``vague linkage''.  Typically such constructs are
23417 emitted wherever they are needed, though sometimes we can be more
23418 clever.
23420 @table @asis
23421 @item Inline Functions
23422 Inline functions are typically defined in a header file which can be
23423 included in many different compilations.  Hopefully they can usually be
23424 inlined, but sometimes an out-of-line copy is necessary, if the address
23425 of the function is taken or if inlining fails.  In general, we emit an
23426 out-of-line copy in all translation units where one is needed.  As an
23427 exception, we only emit inline virtual functions with the vtable, since
23428 it always requires a copy.
23430 Local static variables and string constants used in an inline function
23431 are also considered to have vague linkage, since they must be shared
23432 between all inlined and out-of-line instances of the function.
23434 @item VTables
23435 @cindex vtable
23436 C++ virtual functions are implemented in most compilers using a lookup
23437 table, known as a vtable.  The vtable contains pointers to the virtual
23438 functions provided by a class, and each object of the class contains a
23439 pointer to its vtable (or vtables, in some multiple-inheritance
23440 situations).  If the class declares any non-inline, non-pure virtual
23441 functions, the first one is chosen as the ``key method'' for the class,
23442 and the vtable is only emitted in the translation unit where the key
23443 method is defined.
23445 @emph{Note:} If the chosen key method is later defined as inline, the
23446 vtable is still emitted in every translation unit that defines it.
23447 Make sure that any inline virtuals are declared inline in the class
23448 body, even if they are not defined there.
23450 @item @code{type_info} objects
23451 @cindex @code{type_info}
23452 @cindex RTTI
23453 C++ requires information about types to be written out in order to
23454 implement @samp{dynamic_cast}, @samp{typeid} and exception handling.
23455 For polymorphic classes (classes with virtual functions), the @samp{type_info}
23456 object is written out along with the vtable so that @samp{dynamic_cast}
23457 can determine the dynamic type of a class object at run time.  For all
23458 other types, we write out the @samp{type_info} object when it is used: when
23459 applying @samp{typeid} to an expression, throwing an object, or
23460 referring to a type in a catch clause or exception specification.
23462 @item Template Instantiations
23463 Most everything in this section also applies to template instantiations,
23464 but there are other options as well.
23465 @xref{Template Instantiation,,Where's the Template?}.
23467 @end table
23469 When used with GNU ld version 2.8 or later on an ELF system such as
23470 GNU/Linux or Solaris 2, or on Microsoft Windows, duplicate copies of
23471 these constructs will be discarded at link time.  This is known as
23472 COMDAT support.
23474 On targets that don't support COMDAT, but do support weak symbols, GCC
23475 uses them.  This way one copy overrides all the others, but
23476 the unused copies still take up space in the executable.
23478 For targets that do not support either COMDAT or weak symbols,
23479 most entities with vague linkage are emitted as local symbols to
23480 avoid duplicate definition errors from the linker.  This does not happen
23481 for local statics in inlines, however, as having multiple copies
23482 almost certainly breaks things.
23484 @xref{C++ Interface,,Declarations and Definitions in One Header}, for
23485 another way to control placement of these constructs.
23487 @node C++ Interface
23488 @section C++ Interface and Implementation Pragmas
23490 @cindex interface and implementation headers, C++
23491 @cindex C++ interface and implementation headers
23492 @cindex pragmas, interface and implementation
23494 @code{#pragma interface} and @code{#pragma implementation} provide the
23495 user with a way of explicitly directing the compiler to emit entities
23496 with vague linkage (and debugging information) in a particular
23497 translation unit.
23499 @emph{Note:} These @code{#pragma}s have been superceded as of GCC 2.7.2
23500 by COMDAT support and the ``key method'' heuristic
23501 mentioned in @ref{Vague Linkage}.  Using them can actually cause your
23502 program to grow due to unnecessary out-of-line copies of inline
23503 functions.
23505 @table @code
23506 @item #pragma interface
23507 @itemx #pragma interface "@var{subdir}/@var{objects}.h"
23508 @kindex #pragma interface
23509 Use this directive in @emph{header files} that define object classes, to save
23510 space in most of the object files that use those classes.  Normally,
23511 local copies of certain information (backup copies of inline member
23512 functions, debugging information, and the internal tables that implement
23513 virtual functions) must be kept in each object file that includes class
23514 definitions.  You can use this pragma to avoid such duplication.  When a
23515 header file containing @samp{#pragma interface} is included in a
23516 compilation, this auxiliary information is not generated (unless
23517 the main input source file itself uses @samp{#pragma implementation}).
23518 Instead, the object files contain references to be resolved at link
23519 time.
23521 The second form of this directive is useful for the case where you have
23522 multiple headers with the same name in different directories.  If you
23523 use this form, you must specify the same string to @samp{#pragma
23524 implementation}.
23526 @item #pragma implementation
23527 @itemx #pragma implementation "@var{objects}.h"
23528 @kindex #pragma implementation
23529 Use this pragma in a @emph{main input file}, when you want full output from
23530 included header files to be generated (and made globally visible).  The
23531 included header file, in turn, should use @samp{#pragma interface}.
23532 Backup copies of inline member functions, debugging information, and the
23533 internal tables used to implement virtual functions are all generated in
23534 implementation files.
23536 @cindex implied @code{#pragma implementation}
23537 @cindex @code{#pragma implementation}, implied
23538 @cindex naming convention, implementation headers
23539 If you use @samp{#pragma implementation} with no argument, it applies to
23540 an include file with the same basename@footnote{A file's @dfn{basename}
23541 is the name stripped of all leading path information and of trailing
23542 suffixes, such as @samp{.h} or @samp{.C} or @samp{.cc}.} as your source
23543 file.  For example, in @file{allclass.cc}, giving just
23544 @samp{#pragma implementation}
23545 by itself is equivalent to @samp{#pragma implementation "allclass.h"}.
23547 Use the string argument if you want a single implementation file to
23548 include code from multiple header files.  (You must also use
23549 @samp{#include} to include the header file; @samp{#pragma
23550 implementation} only specifies how to use the file---it doesn't actually
23551 include it.)
23553 There is no way to split up the contents of a single header file into
23554 multiple implementation files.
23555 @end table
23557 @cindex inlining and C++ pragmas
23558 @cindex C++ pragmas, effect on inlining
23559 @cindex pragmas in C++, effect on inlining
23560 @samp{#pragma implementation} and @samp{#pragma interface} also have an
23561 effect on function inlining.
23563 If you define a class in a header file marked with @samp{#pragma
23564 interface}, the effect on an inline function defined in that class is
23565 similar to an explicit @code{extern} declaration---the compiler emits
23566 no code at all to define an independent version of the function.  Its
23567 definition is used only for inlining with its callers.
23569 @opindex fno-implement-inlines
23570 Conversely, when you include the same header file in a main source file
23571 that declares it as @samp{#pragma implementation}, the compiler emits
23572 code for the function itself; this defines a version of the function
23573 that can be found via pointers (or by callers compiled without
23574 inlining).  If all calls to the function can be inlined, you can avoid
23575 emitting the function by compiling with @option{-fno-implement-inlines}.
23576 If any calls are not inlined, you will get linker errors.
23578 @node Template Instantiation
23579 @section Where's the Template?
23580 @cindex template instantiation
23582 C++ templates were the first language feature to require more
23583 intelligence from the environment than was traditionally found on a UNIX
23584 system.  Somehow the compiler and linker have to make sure that each
23585 template instance occurs exactly once in the executable if it is needed,
23586 and not at all otherwise.  There are two basic approaches to this
23587 problem, which are referred to as the Borland model and the Cfront model.
23589 @table @asis
23590 @item Borland model
23591 Borland C++ solved the template instantiation problem by adding the code
23592 equivalent of common blocks to their linker; the compiler emits template
23593 instances in each translation unit that uses them, and the linker
23594 collapses them together.  The advantage of this model is that the linker
23595 only has to consider the object files themselves; there is no external
23596 complexity to worry about.  The disadvantage is that compilation time
23597 is increased because the template code is being compiled repeatedly.
23598 Code written for this model tends to include definitions of all
23599 templates in the header file, since they must be seen to be
23600 instantiated.
23602 @item Cfront model
23603 The AT&T C++ translator, Cfront, solved the template instantiation
23604 problem by creating the notion of a template repository, an
23605 automatically maintained place where template instances are stored.  A
23606 more modern version of the repository works as follows: As individual
23607 object files are built, the compiler places any template definitions and
23608 instantiations encountered in the repository.  At link time, the link
23609 wrapper adds in the objects in the repository and compiles any needed
23610 instances that were not previously emitted.  The advantages of this
23611 model are more optimal compilation speed and the ability to use the
23612 system linker; to implement the Borland model a compiler vendor also
23613 needs to replace the linker.  The disadvantages are vastly increased
23614 complexity, and thus potential for error; for some code this can be
23615 just as transparent, but in practice it can been very difficult to build
23616 multiple programs in one directory and one program in multiple
23617 directories.  Code written for this model tends to separate definitions
23618 of non-inline member templates into a separate file, which should be
23619 compiled separately.
23620 @end table
23622 G++ implements the Borland model on targets where the linker supports it,
23623 including ELF targets (such as GNU/Linux), Mac OS X and Microsoft Windows.
23624 Otherwise G++ implements neither automatic model.
23626 You have the following options for dealing with template instantiations:
23628 @enumerate
23629 @item
23630 Do nothing.  Code written for the Borland model works fine, but
23631 each translation unit contains instances of each of the templates it
23632 uses.  The duplicate instances will be discarded by the linker, but in
23633 a large program, this can lead to an unacceptable amount of code
23634 duplication in object files or shared libraries.
23636 Duplicate instances of a template can be avoided by defining an explicit
23637 instantiation in one object file, and preventing the compiler from doing
23638 implicit instantiations in any other object files by using an explicit
23639 instantiation declaration, using the @code{extern template} syntax:
23641 @smallexample
23642 extern template int max (int, int);
23643 @end smallexample
23645 This syntax is defined in the C++ 2011 standard, but has been supported by
23646 G++ and other compilers since well before 2011.
23648 Explicit instantiations can be used for the largest or most frequently
23649 duplicated instances, without having to know exactly which other instances
23650 are used in the rest of the program.  You can scatter the explicit
23651 instantiations throughout your program, perhaps putting them in the
23652 translation units where the instances are used or the translation units
23653 that define the templates themselves; you can put all of the explicit
23654 instantiations you need into one big file; or you can create small files
23655 like
23657 @smallexample
23658 #include "Foo.h"
23659 #include "Foo.cc"
23661 template class Foo<int>;
23662 template ostream& operator <<
23663                 (ostream&, const Foo<int>&);
23664 @end smallexample
23666 @noindent
23667 for each of the instances you need, and create a template instantiation
23668 library from those.
23670 This is the simplest option, but also offers flexibility and
23671 fine-grained control when necessary. It is also the most portable
23672 alternative and programs using this approach will work with most modern
23673 compilers.
23675 @item
23676 @opindex frepo
23677 Compile your template-using code with @option{-frepo}.  The compiler
23678 generates files with the extension @samp{.rpo} listing all of the
23679 template instantiations used in the corresponding object files that
23680 could be instantiated there; the link wrapper, @samp{collect2},
23681 then updates the @samp{.rpo} files to tell the compiler where to place
23682 those instantiations and rebuild any affected object files.  The
23683 link-time overhead is negligible after the first pass, as the compiler
23684 continues to place the instantiations in the same files.
23686 This can be a suitable option for application code written for the Borland
23687 model, as it usually just works.  Code written for the Cfront model 
23688 needs to be modified so that the template definitions are available at
23689 one or more points of instantiation; usually this is as simple as adding
23690 @code{#include <tmethods.cc>} to the end of each template header.
23692 For library code, if you want the library to provide all of the template
23693 instantiations it needs, just try to link all of its object files
23694 together; the link will fail, but cause the instantiations to be
23695 generated as a side effect.  Be warned, however, that this may cause
23696 conflicts if multiple libraries try to provide the same instantiations.
23697 For greater control, use explicit instantiation as described in the next
23698 option.
23700 @item
23701 @opindex fno-implicit-templates
23702 Compile your code with @option{-fno-implicit-templates} to disable the
23703 implicit generation of template instances, and explicitly instantiate
23704 all the ones you use.  This approach requires more knowledge of exactly
23705 which instances you need than do the others, but it's less
23706 mysterious and allows greater control if you want to ensure that only
23707 the intended instances are used.
23709 If you are using Cfront-model code, you can probably get away with not
23710 using @option{-fno-implicit-templates} when compiling files that don't
23711 @samp{#include} the member template definitions.
23713 If you use one big file to do the instantiations, you may want to
23714 compile it without @option{-fno-implicit-templates} so you get all of the
23715 instances required by your explicit instantiations (but not by any
23716 other files) without having to specify them as well.
23718 In addition to forward declaration of explicit instantiations
23719 (with @code{extern}), G++ has extended the template instantiation
23720 syntax to support instantiation of the compiler support data for a
23721 template class (i.e.@: the vtable) without instantiating any of its
23722 members (with @code{inline}), and instantiation of only the static data
23723 members of a template class, without the support data or member
23724 functions (with @code{static}):
23726 @smallexample
23727 inline template class Foo<int>;
23728 static template class Foo<int>;
23729 @end smallexample
23730 @end enumerate
23732 @node Bound member functions
23733 @section Extracting the Function Pointer from a Bound Pointer to Member Function
23734 @cindex pmf
23735 @cindex pointer to member function
23736 @cindex bound pointer to member function
23738 In C++, pointer to member functions (PMFs) are implemented using a wide
23739 pointer of sorts to handle all the possible call mechanisms; the PMF
23740 needs to store information about how to adjust the @samp{this} pointer,
23741 and if the function pointed to is virtual, where to find the vtable, and
23742 where in the vtable to look for the member function.  If you are using
23743 PMFs in an inner loop, you should really reconsider that decision.  If
23744 that is not an option, you can extract the pointer to the function that
23745 would be called for a given object/PMF pair and call it directly inside
23746 the inner loop, to save a bit of time.
23748 Note that you still pay the penalty for the call through a
23749 function pointer; on most modern architectures, such a call defeats the
23750 branch prediction features of the CPU@.  This is also true of normal
23751 virtual function calls.
23753 The syntax for this extension is
23755 @smallexample
23756 extern A a;
23757 extern int (A::*fp)();
23758 typedef int (*fptr)(A *);
23760 fptr p = (fptr)(a.*fp);
23761 @end smallexample
23763 For PMF constants (i.e.@: expressions of the form @samp{&Klasse::Member}),
23764 no object is needed to obtain the address of the function.  They can be
23765 converted to function pointers directly:
23767 @smallexample
23768 fptr p1 = (fptr)(&A::foo);
23769 @end smallexample
23771 @opindex Wno-pmf-conversions
23772 You must specify @option{-Wno-pmf-conversions} to use this extension.
23774 @node C++ Attributes
23775 @section C++-Specific Variable, Function, and Type Attributes
23777 Some attributes only make sense for C++ programs.
23779 @table @code
23780 @item abi_tag ("@var{tag}", ...)
23781 @cindex @code{abi_tag} function attribute
23782 @cindex @code{abi_tag} variable attribute
23783 @cindex @code{abi_tag} type attribute
23784 The @code{abi_tag} attribute can be applied to a function, variable, or class
23785 declaration.  It modifies the mangled name of the entity to
23786 incorporate the tag name, in order to distinguish the function or
23787 class from an earlier version with a different ABI; perhaps the class
23788 has changed size, or the function has a different return type that is
23789 not encoded in the mangled name.
23791 The attribute can also be applied to an inline namespace, but does not
23792 affect the mangled name of the namespace; in this case it is only used
23793 for @option{-Wabi-tag} warnings and automatic tagging of functions and
23794 variables.  Tagging inline namespaces is generally preferable to
23795 tagging individual declarations, but the latter is sometimes
23796 necessary, such as when only certain members of a class need to be
23797 tagged.
23799 The argument can be a list of strings of arbitrary length.  The
23800 strings are sorted on output, so the order of the list is
23801 unimportant.
23803 A redeclaration of an entity must not add new ABI tags,
23804 since doing so would change the mangled name.
23806 The ABI tags apply to a name, so all instantiations and
23807 specializations of a template have the same tags.  The attribute will
23808 be ignored if applied to an explicit specialization or instantiation.
23810 The @option{-Wabi-tag} flag enables a warning about a class which does
23811 not have all the ABI tags used by its subobjects and virtual functions; for users with code
23812 that needs to coexist with an earlier ABI, using this option can help
23813 to find all affected types that need to be tagged.
23815 When a type involving an ABI tag is used as the type of a variable or
23816 return type of a function where that tag is not already present in the
23817 signature of the function, the tag is automatically applied to the
23818 variable or function.  @option{-Wabi-tag} also warns about this
23819 situation; this warning can be avoided by explicitly tagging the
23820 variable or function or moving it into a tagged inline namespace.
23822 @item init_priority (@var{priority})
23823 @cindex @code{init_priority} variable attribute
23825 In Standard C++, objects defined at namespace scope are guaranteed to be
23826 initialized in an order in strict accordance with that of their definitions
23827 @emph{in a given translation unit}.  No guarantee is made for initializations
23828 across translation units.  However, GNU C++ allows users to control the
23829 order of initialization of objects defined at namespace scope with the
23830 @code{init_priority} attribute by specifying a relative @var{priority},
23831 a constant integral expression currently bounded between 101 and 65535
23832 inclusive.  Lower numbers indicate a higher priority.
23834 In the following example, @code{A} would normally be created before
23835 @code{B}, but the @code{init_priority} attribute reverses that order:
23837 @smallexample
23838 Some_Class  A  __attribute__ ((init_priority (2000)));
23839 Some_Class  B  __attribute__ ((init_priority (543)));
23840 @end smallexample
23842 @noindent
23843 Note that the particular values of @var{priority} do not matter; only their
23844 relative ordering.
23846 @item warn_unused
23847 @cindex @code{warn_unused} type attribute
23849 For C++ types with non-trivial constructors and/or destructors it is
23850 impossible for the compiler to determine whether a variable of this
23851 type is truly unused if it is not referenced. This type attribute
23852 informs the compiler that variables of this type should be warned
23853 about if they appear to be unused, just like variables of fundamental
23854 types.
23856 This attribute is appropriate for types which just represent a value,
23857 such as @code{std::string}; it is not appropriate for types which
23858 control a resource, such as @code{std::lock_guard}.
23860 This attribute is also accepted in C, but it is unnecessary because C
23861 does not have constructors or destructors.
23863 @end table
23865 @node Function Multiversioning
23866 @section Function Multiversioning
23867 @cindex function versions
23869 With the GNU C++ front end, for x86 targets, you may specify multiple
23870 versions of a function, where each function is specialized for a
23871 specific target feature.  At runtime, the appropriate version of the
23872 function is automatically executed depending on the characteristics of
23873 the execution platform.  Here is an example.
23875 @smallexample
23876 __attribute__ ((target ("default")))
23877 int foo ()
23879   // The default version of foo.
23880   return 0;
23883 __attribute__ ((target ("sse4.2")))
23884 int foo ()
23886   // foo version for SSE4.2
23887   return 1;
23890 __attribute__ ((target ("arch=atom")))
23891 int foo ()
23893   // foo version for the Intel ATOM processor
23894   return 2;
23897 __attribute__ ((target ("arch=amdfam10")))
23898 int foo ()
23900   // foo version for the AMD Family 0x10 processors.
23901   return 3;
23904 int main ()
23906   int (*p)() = &foo;
23907   assert ((*p) () == foo ());
23908   return 0;
23910 @end smallexample
23912 In the above example, four versions of function foo are created. The
23913 first version of foo with the target attribute "default" is the default
23914 version.  This version gets executed when no other target specific
23915 version qualifies for execution on a particular platform. A new version
23916 of foo is created by using the same function signature but with a
23917 different target string.  Function foo is called or a pointer to it is
23918 taken just like a regular function.  GCC takes care of doing the
23919 dispatching to call the right version at runtime.  Refer to the
23920 @uref{http://gcc.gnu.org/wiki/FunctionMultiVersioning, GCC wiki on
23921 Function Multiversioning} for more details.
23923 @node Type Traits
23924 @section Type Traits
23926 The C++ front end implements syntactic extensions that allow
23927 compile-time determination of 
23928 various characteristics of a type (or of a
23929 pair of types).
23931 @table @code
23932 @item __has_nothrow_assign (type)
23933 If @code{type} is @code{const}-qualified or is a reference type then
23934 the trait is @code{false}.  Otherwise if @code{__has_trivial_assign (type)}
23935 is @code{true} then the trait is @code{true}, else if @code{type} is
23936 a cv-qualified class or union type with copy assignment operators that are
23937 known not to throw an exception then the trait is @code{true}, else it is
23938 @code{false}.
23939 Requires: @code{type} shall be a complete type, (possibly cv-qualified)
23940 @code{void}, or an array of unknown bound.
23942 @item __has_nothrow_copy (type)
23943 If @code{__has_trivial_copy (type)} is @code{true} then the trait is
23944 @code{true}, else if @code{type} is a cv-qualified class or union type
23945 with copy constructors that are known not to throw an exception then
23946 the trait is @code{true}, else it is @code{false}.
23947 Requires: @code{type} shall be a complete type, (possibly cv-qualified)
23948 @code{void}, or an array of unknown bound.
23950 @item __has_nothrow_constructor (type)
23951 If @code{__has_trivial_constructor (type)} is @code{true} then the trait
23952 is @code{true}, else if @code{type} is a cv class or union type (or array
23953 thereof) with a default constructor that is known not to throw an
23954 exception then the trait is @code{true}, else it is @code{false}.
23955 Requires: @code{type} shall be a complete type, (possibly cv-qualified)
23956 @code{void}, or an array of unknown bound.
23958 @item __has_trivial_assign (type)
23959 If @code{type} is @code{const}- qualified or is a reference type then
23960 the trait is @code{false}.  Otherwise if @code{__is_pod (type)} is
23961 @code{true} then the trait is @code{true}, else if @code{type} is
23962 a cv-qualified class or union type with a trivial copy assignment
23963 ([class.copy]) then the trait is @code{true}, else it is @code{false}.
23964 Requires: @code{type} shall be a complete type, (possibly cv-qualified)
23965 @code{void}, or an array of unknown bound.
23967 @item __has_trivial_copy (type)
23968 If @code{__is_pod (type)} is @code{true} or @code{type} is a reference
23969 type then the trait is @code{true}, else if @code{type} is a cv class
23970 or union type with a trivial copy constructor ([class.copy]) then the trait
23971 is @code{true}, else it is @code{false}.  Requires: @code{type} shall be
23972 a complete type, (possibly cv-qualified) @code{void}, or an array of unknown
23973 bound.
23975 @item __has_trivial_constructor (type)
23976 If @code{__is_pod (type)} is @code{true} then the trait is @code{true},
23977 else if @code{type} is a cv-qualified class or union type (or array thereof)
23978 with a trivial default constructor ([class.ctor]) then the trait is @code{true},
23979 else it is @code{false}.
23980 Requires: @code{type} shall be a complete type, (possibly cv-qualified)
23981 @code{void}, or an array of unknown bound.
23983 @item __has_trivial_destructor (type)
23984 If @code{__is_pod (type)} is @code{true} or @code{type} is a reference type
23985 then the trait is @code{true}, else if @code{type} is a cv class or union
23986 type (or array thereof) with a trivial destructor ([class.dtor]) then
23987 the trait is @code{true}, else it is @code{false}.
23988 Requires: @code{type} shall be a complete type, (possibly cv-qualified)
23989 @code{void}, or an array of unknown bound.
23991 @item __has_virtual_destructor (type)
23992 If @code{type} is a class type with a virtual destructor
23993 ([class.dtor]) then the trait is @code{true}, else it is @code{false}.
23994 Requires: @code{type} shall be a complete type, (possibly cv-qualified)
23995 @code{void}, or an array of unknown bound.
23997 @item __is_abstract (type)
23998 If @code{type} is an abstract class ([class.abstract]) then the trait
23999 is @code{true}, else it is @code{false}.
24000 Requires: @code{type} shall be a complete type, (possibly cv-qualified)
24001 @code{void}, or an array of unknown bound.
24003 @item __is_base_of (base_type, derived_type)
24004 If @code{base_type} is a base class of @code{derived_type}
24005 ([class.derived]) then the trait is @code{true}, otherwise it is @code{false}.
24006 Top-level cv-qualifications of @code{base_type} and
24007 @code{derived_type} are ignored.  For the purposes of this trait, a
24008 class type is considered is own base.
24009 Requires: if @code{__is_class (base_type)} and @code{__is_class (derived_type)}
24010 are @code{true} and @code{base_type} and @code{derived_type} are not the same
24011 type (disregarding cv-qualifiers), @code{derived_type} shall be a complete
24012 type.  A diagnostic is produced if this requirement is not met.
24014 @item __is_class (type)
24015 If @code{type} is a cv-qualified class type, and not a union type
24016 ([basic.compound]) the trait is @code{true}, else it is @code{false}.
24018 @item __is_empty (type)
24019 If @code{__is_class (type)} is @code{false} then the trait is @code{false}.
24020 Otherwise @code{type} is considered empty if and only if: @code{type}
24021 has no non-static data members, or all non-static data members, if
24022 any, are bit-fields of length 0, and @code{type} has no virtual
24023 members, and @code{type} has no virtual base classes, and @code{type}
24024 has no base classes @code{base_type} for which
24025 @code{__is_empty (base_type)} is @code{false}.
24026 Requires: @code{type} shall be a complete type, (possibly cv-qualified)
24027 @code{void}, or an array of unknown bound.
24029 @item __is_enum (type)
24030 If @code{type} is a cv enumeration type ([basic.compound]) the trait is
24031 @code{true}, else it is @code{false}.
24033 @item __is_literal_type (type)
24034 If @code{type} is a literal type ([basic.types]) the trait is
24035 @code{true}, else it is @code{false}.
24036 Requires: @code{type} shall be a complete type, (possibly cv-qualified)
24037 @code{void}, or an array of unknown bound.
24039 @item __is_pod (type)
24040 If @code{type} is a cv POD type ([basic.types]) then the trait is @code{true},
24041 else it is @code{false}.
24042 Requires: @code{type} shall be a complete type, (possibly cv-qualified)
24043 @code{void}, or an array of unknown bound.
24045 @item __is_polymorphic (type)
24046 If @code{type} is a polymorphic class ([class.virtual]) then the trait
24047 is @code{true}, else it is @code{false}.
24048 Requires: @code{type} shall be a complete type, (possibly cv-qualified)
24049 @code{void}, or an array of unknown bound.
24051 @item __is_standard_layout (type)
24052 If @code{type} is a standard-layout type ([basic.types]) the trait is
24053 @code{true}, else it is @code{false}.
24054 Requires: @code{type} shall be a complete type, (possibly cv-qualified)
24055 @code{void}, or an array of unknown bound.
24057 @item __is_trivial (type)
24058 If @code{type} is a trivial type ([basic.types]) the trait is
24059 @code{true}, else it is @code{false}.
24060 Requires: @code{type} shall be a complete type, (possibly cv-qualified)
24061 @code{void}, or an array of unknown bound.
24063 @item __is_union (type)
24064 If @code{type} is a cv union type ([basic.compound]) the trait is
24065 @code{true}, else it is @code{false}.
24067 @item __underlying_type (type)
24068 The underlying type of @code{type}.
24069 Requires: @code{type} shall be an enumeration type ([dcl.enum]).
24071 @item __integer_pack (length)
24072 When used as the pattern of a pack expansion within a template
24073 definition, expands to a template argument pack containing integers
24074 from @code{0} to @code{length-1}.  This is provided for efficient
24075 implementation of @code{std::make_integer_sequence}.
24077 @end table
24080 @node C++ Concepts
24081 @section C++ Concepts
24083 C++ concepts provide much-improved support for generic programming. In
24084 particular, they allow the specification of constraints on template arguments.
24085 The constraints are used to extend the usual overloading and partial
24086 specialization capabilities of the language, allowing generic data structures
24087 and algorithms to be ``refined'' based on their properties rather than their
24088 type names.
24090 The following keywords are reserved for concepts.
24092 @table @code
24093 @item assumes
24094 States an expression as an assumption, and if possible, verifies that the
24095 assumption is valid. For example, @code{assume(n > 0)}.
24097 @item axiom
24098 Introduces an axiom definition. Axioms introduce requirements on values.
24100 @item forall
24101 Introduces a universally quantified object in an axiom. For example,
24102 @code{forall (int n) n + 0 == n}).
24104 @item concept
24105 Introduces a concept definition. Concepts are sets of syntactic and semantic
24106 requirements on types and their values.
24108 @item requires
24109 Introduces constraints on template arguments or requirements for a member
24110 function of a class template.
24112 @end table
24114 The front end also exposes a number of internal mechanism that can be used
24115 to simplify the writing of type traits. Note that some of these traits are
24116 likely to be removed in the future.
24118 @table @code
24119 @item __is_same (type1, type2)
24120 A binary type trait: @code{true} whenever the type arguments are the same.
24122 @end table
24125 @node Deprecated Features
24126 @section Deprecated Features
24128 In the past, the GNU C++ compiler was extended to experiment with new
24129 features, at a time when the C++ language was still evolving.  Now that
24130 the C++ standard is complete, some of those features are superseded by
24131 superior alternatives.  Using the old features might cause a warning in
24132 some cases that the feature will be dropped in the future.  In other
24133 cases, the feature might be gone already.
24135 G++ allows a virtual function returning @samp{void *} to be overridden
24136 by one returning a different pointer type.  This extension to the
24137 covariant return type rules is now deprecated and will be removed from a
24138 future version.
24140 The use of default arguments in function pointers, function typedefs
24141 and other places where they are not permitted by the standard is
24142 deprecated and will be removed from a future version of G++.
24144 G++ allows floating-point literals to appear in integral constant expressions,
24145 e.g.@: @samp{ enum E @{ e = int(2.2 * 3.7) @} }
24146 This extension is deprecated and will be removed from a future version.
24148 G++ allows static data members of const floating-point type to be declared
24149 with an initializer in a class definition. The standard only allows
24150 initializers for static members of const integral types and const
24151 enumeration types so this extension has been deprecated and will be removed
24152 from a future version.
24154 G++ allows attributes to follow a parenthesized direct initializer,
24155 e.g.@: @samp{ int f (0) __attribute__ ((something)); } This extension
24156 has been ignored since G++ 3.3 and is deprecated.
24158 G++ allows anonymous structs and unions to have members that are not
24159 public non-static data members (i.e.@: fields).  These extensions are
24160 deprecated.
24162 @node Backwards Compatibility
24163 @section Backwards Compatibility
24164 @cindex Backwards Compatibility
24165 @cindex ARM [Annotated C++ Reference Manual]
24167 Now that there is a definitive ISO standard C++, G++ has a specification
24168 to adhere to.  The C++ language evolved over time, and features that
24169 used to be acceptable in previous drafts of the standard, such as the ARM
24170 [Annotated C++ Reference Manual], are no longer accepted.  In order to allow
24171 compilation of C++ written to such drafts, G++ contains some backwards
24172 compatibilities.  @emph{All such backwards compatibility features are
24173 liable to disappear in future versions of G++.} They should be considered
24174 deprecated.   @xref{Deprecated Features}.
24176 @table @code
24178 @item Implicit C language
24179 Old C system header files did not contain an @code{extern "C" @{@dots{}@}}
24180 scope to set the language.  On such systems, all system header files are
24181 implicitly scoped inside a C language scope.  Such headers must
24182 correctly prototype function argument types, there is no leeway for
24183 @code{()} to indicate an unspecified set of arguments.
24185 @end table
24187 @c  LocalWords:  emph deftypefn builtin ARCv2EM SIMD builtins msimd
24188 @c  LocalWords:  typedef v4si v8hi DMA dma vdiwr vdowr