target-supports.exp (check_effective_target_weak_undefined): Return 0 on hppa*-*...
[official-gcc.git] / gcc / doc / extend.texi
blob0a84083c5f30fcff2822f6e4db6b64088f7f2f9e
1 c Copyright (C) 1988-2019 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 * Variadic Pointer Args::  Pointer arguments to variadic functions.
51 * Pointers to Arrays::  Pointers to arrays with qualifiers work as expected.
52 * Initializers::        Non-constant initializers.
53 * Compound Literals::   Compound literals give structures, unions
54                         or arrays as values.
55 * Designated Inits::    Labeling elements of initializers.
56 * Case Ranges::         `case 1 ... 9' and such.
57 * Cast to Union::       Casting to union type from any member of the union.
58 * Mixed Declarations::  Mixing declarations and code.
59 * Function Attributes:: Declaring that functions have no side effects,
60                         or that they can never return.
61 * Variable Attributes:: Specifying attributes of variables.
62 * Type Attributes::     Specifying attributes of types.
63 * Label Attributes::    Specifying attributes on labels.
64 * Enumerator Attributes:: Specifying attributes on enumerators.
65 * Statement Attributes:: Specifying attributes on statements.
66 * Attribute Syntax::    Formal syntax for attributes.
67 * Function Prototypes:: Prototype declarations and old-style definitions.
68 * C++ Comments::        C++ comments are recognized.
69 * Dollar Signs::        Dollar sign is allowed in identifiers.
70 * Character Escapes::   @samp{\e} stands for the character @key{ESC}.
71 * Alignment::           Determining the alignment of a function, type or variable.
72 * Inline::              Defining inline functions (as fast as macros).
73 * Volatiles::           What constitutes an access to a volatile object.
74 * Using Assembly Language with C:: Instructions and extensions for interfacing C with assembler.
75 * Alternate Keywords::  @code{__const__}, @code{__asm__}, etc., for header files.
76 * Incomplete Enums::    @code{enum foo;}, with details to follow.
77 * Function Names::      Printable strings which are the name of the current
78                         function.
79 * Return Address::      Getting the return or frame address of a function.
80 * Vector Extensions::   Using vector instructions through built-in functions.
81 * Offsetof::            Special syntax for implementing @code{offsetof}.
82 * __sync Builtins::     Legacy built-in functions for atomic memory access.
83 * __atomic Builtins::   Atomic built-in functions with memory model.
84 * Integer Overflow Builtins:: Built-in functions to perform arithmetics and
85                         arithmetic overflow checking.
86 * x86 specific memory model extensions for transactional memory:: x86 memory models.
87 * Object Size Checking:: Built-in functions for limited buffer overflow
88                         checking.
89 * Other Builtins::      Other built-in functions.
90 * Target Builtins::     Built-in functions specific to particular targets.
91 * Target Format Checks:: Format checks specific to particular targets.
92 * Pragmas::             Pragmas accepted by GCC.
93 * Unnamed Fields::      Unnamed struct/union fields within structs/unions.
94 * Thread-Local::        Per-thread variables.
95 * Binary constants::    Binary constants using the @samp{0b} prefix.
96 @end menu
98 @node Statement Exprs
99 @section Statements and Declarations in Expressions
100 @cindex statements inside expressions
101 @cindex declarations inside expressions
102 @cindex expressions containing statements
103 @cindex macros, statements in expressions
105 @c the above section title wrapped and causes an underfull hbox.. i
106 @c changed it from "within" to "in". --mew 4feb93
107 A compound statement enclosed in parentheses may appear as an expression
108 in GNU C@.  This allows you to use loops, switches, and local variables
109 within an expression.
111 Recall that a compound statement is a sequence of statements surrounded
112 by braces; in this construct, parentheses go around the braces.  For
113 example:
115 @smallexample
116 (@{ int y = foo (); int z;
117    if (y > 0) z = y;
118    else z = - y;
119    z; @})
120 @end smallexample
122 @noindent
123 is a valid (though slightly more complex than necessary) expression
124 for the absolute value of @code{foo ()}.
126 The last thing in the compound statement should be an expression
127 followed by a semicolon; the value of this subexpression serves as the
128 value of the entire construct.  (If you use some other kind of statement
129 last within the braces, the construct has type @code{void}, and thus
130 effectively no value.)
132 This feature is especially useful in making macro definitions ``safe'' (so
133 that they evaluate each operand exactly once).  For example, the
134 ``maximum'' function is commonly defined as a macro in standard C as
135 follows:
137 @smallexample
138 #define max(a,b) ((a) > (b) ? (a) : (b))
139 @end smallexample
141 @noindent
142 @cindex side effects, macro argument
143 But this definition computes either @var{a} or @var{b} twice, with bad
144 results if the operand has side effects.  In GNU C, if you know the
145 type of the operands (here taken as @code{int}), you can define
146 the macro safely as follows:
148 @smallexample
149 #define maxint(a,b) \
150   (@{int _a = (a), _b = (b); _a > _b ? _a : _b; @})
151 @end smallexample
153 Embedded statements are not allowed in constant expressions, such as
154 the value of an enumeration constant, the width of a bit-field, or
155 the initial value of a static variable.
157 If you don't know the type of the operand, you can still do this, but you
158 must use @code{typeof} or @code{__auto_type} (@pxref{Typeof}).
160 In G++, the result value of a statement expression undergoes array and
161 function pointer decay, and is returned by value to the enclosing
162 expression.  For instance, if @code{A} is a class, then
164 @smallexample
165         A a;
167         (@{a;@}).Foo ()
168 @end smallexample
170 @noindent
171 constructs a temporary @code{A} object to hold the result of the
172 statement expression, and that is used to invoke @code{Foo}.
173 Therefore the @code{this} pointer observed by @code{Foo} is not the
174 address of @code{a}.
176 In a statement expression, any temporaries created within a statement
177 are destroyed at that statement's end.  This makes statement
178 expressions inside macros slightly different from function calls.  In
179 the latter case temporaries introduced during argument evaluation are
180 destroyed at the end of the statement that includes the function
181 call.  In the statement expression case they are destroyed during
182 the statement expression.  For instance,
184 @smallexample
185 #define macro(a)  (@{__typeof__(a) b = (a); b + 3; @})
186 template<typename T> T function(T a) @{ T b = a; return b + 3; @}
188 void foo ()
190   macro (X ());
191   function (X ());
193 @end smallexample
195 @noindent
196 has different places where temporaries are destroyed.  For the
197 @code{macro} case, the temporary @code{X} is destroyed just after
198 the initialization of @code{b}.  In the @code{function} case that
199 temporary is destroyed when the function returns.
201 These considerations mean that it is probably a bad idea to use
202 statement expressions of this form in header files that are designed to
203 work with C++.  (Note that some versions of the GNU C Library contained
204 header files using statement expressions that lead to precisely this
205 bug.)
207 Jumping into a statement expression with @code{goto} or using a
208 @code{switch} statement outside the statement expression with a
209 @code{case} or @code{default} label inside the statement expression is
210 not permitted.  Jumping into a statement expression with a computed
211 @code{goto} (@pxref{Labels as Values}) has undefined behavior.
212 Jumping out of a statement expression is permitted, but if the
213 statement expression is part of a larger expression then it is
214 unspecified which other subexpressions of that expression have been
215 evaluated except where the language definition requires certain
216 subexpressions to be evaluated before or after the statement
217 expression.  A @code{break} or @code{continue} statement inside of
218 a statement expression used in @code{while}, @code{do} or @code{for}
219 loop or @code{switch} statement condition
220 or @code{for} statement init or increment expressions jumps to an
221 outer loop or @code{switch} statement if any (otherwise it is an error),
222 rather than to the loop or @code{switch} statement in whose condition
223 or init or increment expression it appears.
224 In any case, as with a function call, the evaluation of a
225 statement expression is not interleaved with the evaluation of other
226 parts of the containing expression.  For example,
228 @smallexample
229   foo (), ((@{ bar1 (); goto a; 0; @}) + bar2 ()), baz();
230 @end smallexample
232 @noindent
233 calls @code{foo} and @code{bar1} and does not call @code{baz} but
234 may or may not call @code{bar2}.  If @code{bar2} is called, it is
235 called after @code{foo} and before @code{bar1}.
237 @node Local Labels
238 @section Locally Declared Labels
239 @cindex local labels
240 @cindex macros, local labels
242 GCC allows you to declare @dfn{local labels} in any nested block
243 scope.  A local label is just like an ordinary label, but you can
244 only reference it (with a @code{goto} statement, or by taking its
245 address) within the block in which it is declared.
247 A local label declaration looks like this:
249 @smallexample
250 __label__ @var{label};
251 @end smallexample
253 @noindent
256 @smallexample
257 __label__ @var{label1}, @var{label2}, /* @r{@dots{}} */;
258 @end smallexample
260 Local label declarations must come at the beginning of the block,
261 before any ordinary declarations or statements.
263 The label declaration defines the label @emph{name}, but does not define
264 the label itself.  You must do this in the usual way, with
265 @code{@var{label}:}, within the statements of the statement expression.
267 The local label feature is useful for complex macros.  If a macro
268 contains nested loops, a @code{goto} can be useful for breaking out of
269 them.  However, an ordinary label whose scope is the whole function
270 cannot be used: if the macro can be expanded several times in one
271 function, the label is multiply defined in that function.  A
272 local label avoids this problem.  For example:
274 @smallexample
275 #define SEARCH(value, array, target)              \
276 do @{                                              \
277   __label__ found;                                \
278   typeof (target) _SEARCH_target = (target);      \
279   typeof (*(array)) *_SEARCH_array = (array);     \
280   int i, j;                                       \
281   int value;                                      \
282   for (i = 0; i < max; i++)                       \
283     for (j = 0; j < max; j++)                     \
284       if (_SEARCH_array[i][j] == _SEARCH_target)  \
285         @{ (value) = i; goto found; @}              \
286   (value) = -1;                                   \
287  found:;                                          \
288 @} while (0)
289 @end smallexample
291 This could also be written using a statement expression:
293 @smallexample
294 #define SEARCH(array, target)                     \
295 (@{                                                \
296   __label__ found;                                \
297   typeof (target) _SEARCH_target = (target);      \
298   typeof (*(array)) *_SEARCH_array = (array);     \
299   int i, j;                                       \
300   int value;                                      \
301   for (i = 0; i < max; i++)                       \
302     for (j = 0; j < max; j++)                     \
303       if (_SEARCH_array[i][j] == _SEARCH_target)  \
304         @{ value = i; goto found; @}                \
305   value = -1;                                     \
306  found:                                           \
307   value;                                          \
309 @end smallexample
311 Local label declarations also make the labels they declare visible to
312 nested functions, if there are any.  @xref{Nested Functions}, for details.
314 @node Labels as Values
315 @section Labels as Values
316 @cindex labels as values
317 @cindex computed gotos
318 @cindex goto with computed label
319 @cindex address of a label
321 You can get the address of a label defined in the current function
322 (or a containing function) with the unary operator @samp{&&}.  The
323 value has type @code{void *}.  This value is a constant and can be used
324 wherever a constant of that type is valid.  For example:
326 @smallexample
327 void *ptr;
328 /* @r{@dots{}} */
329 ptr = &&foo;
330 @end smallexample
332 To use these values, you need to be able to jump to one.  This is done
333 with the computed goto statement@footnote{The analogous feature in
334 Fortran is called an assigned goto, but that name seems inappropriate in
335 C, where one can do more than simply store label addresses in label
336 variables.}, @code{goto *@var{exp};}.  For example,
338 @smallexample
339 goto *ptr;
340 @end smallexample
342 @noindent
343 Any expression of type @code{void *} is allowed.
345 One way of using these constants is in initializing a static array that
346 serves as a jump table:
348 @smallexample
349 static void *array[] = @{ &&foo, &&bar, &&hack @};
350 @end smallexample
352 @noindent
353 Then you can select a label with indexing, like this:
355 @smallexample
356 goto *array[i];
357 @end smallexample
359 @noindent
360 Note that this does not check whether the subscript is in bounds---array
361 indexing in C never does that.
363 Such an array of label values serves a purpose much like that of the
364 @code{switch} statement.  The @code{switch} statement is cleaner, so
365 use that rather than an array unless the problem does not fit a
366 @code{switch} statement very well.
368 Another use of label values is in an interpreter for threaded code.
369 The labels within the interpreter function can be stored in the
370 threaded code for super-fast dispatching.
372 You may not use this mechanism to jump to code in a different function.
373 If you do that, totally unpredictable things happen.  The best way to
374 avoid this is to store the label address only in automatic variables and
375 never pass it as an argument.
377 An alternate way to write the above example is
379 @smallexample
380 static const int array[] = @{ &&foo - &&foo, &&bar - &&foo,
381                              &&hack - &&foo @};
382 goto *(&&foo + array[i]);
383 @end smallexample
385 @noindent
386 This is more friendly to code living in shared libraries, as it reduces
387 the number of dynamic relocations that are needed, and by consequence,
388 allows the data to be read-only.
389 This alternative with label differences is not supported for the AVR target,
390 please use the first approach for AVR programs.
392 The @code{&&foo} expressions for the same label might have different
393 values if the containing function is inlined or cloned.  If a program
394 relies on them being always the same,
395 @code{__attribute__((__noinline__,__noclone__))} should be used to
396 prevent inlining and cloning.  If @code{&&foo} is used in a static
397 variable initializer, inlining and cloning is forbidden.
399 @node Nested Functions
400 @section Nested Functions
401 @cindex nested functions
402 @cindex downward funargs
403 @cindex thunks
405 A @dfn{nested function} is a function defined inside another function.
406 Nested functions are supported as an extension in GNU C, but are not
407 supported by GNU C++.
409 The nested function's name is local to the block where it is defined.
410 For example, here we define a nested function named @code{square}, and
411 call it twice:
413 @smallexample
414 @group
415 foo (double a, double b)
417   double square (double z) @{ return z * z; @}
419   return square (a) + square (b);
421 @end group
422 @end smallexample
424 The nested function can access all the variables of the containing
425 function that are visible at the point of its definition.  This is
426 called @dfn{lexical scoping}.  For example, here we show a nested
427 function which uses an inherited variable named @code{offset}:
429 @smallexample
430 @group
431 bar (int *array, int offset, int size)
433   int access (int *array, int index)
434     @{ return array[index + offset]; @}
435   int i;
436   /* @r{@dots{}} */
437   for (i = 0; i < size; i++)
438     /* @r{@dots{}} */ access (array, i) /* @r{@dots{}} */
440 @end group
441 @end smallexample
443 Nested function definitions are permitted within functions in the places
444 where variable definitions are allowed; that is, in any block, mixed
445 with the other declarations and statements in the block.
447 It is possible to call the nested function from outside the scope of its
448 name by storing its address or passing the address to another function:
450 @smallexample
451 hack (int *array, int size)
453   void store (int index, int value)
454     @{ array[index] = value; @}
456   intermediate (store, size);
458 @end smallexample
460 Here, the function @code{intermediate} receives the address of
461 @code{store} as an argument.  If @code{intermediate} calls @code{store},
462 the arguments given to @code{store} are used to store into @code{array}.
463 But this technique works only so long as the containing function
464 (@code{hack}, in this example) does not exit.
466 If you try to call the nested function through its address after the
467 containing function exits, all hell breaks loose.  If you try
468 to call it after a containing scope level exits, and if it refers
469 to some of the variables that are no longer in scope, you may be lucky,
470 but it's not wise to take the risk.  If, however, the nested function
471 does not refer to anything that has gone out of scope, you should be
472 safe.
474 GCC implements taking the address of a nested function using a technique
475 called @dfn{trampolines}.  This technique was described in
476 @cite{Lexical Closures for C++} (Thomas M. Breuel, USENIX
477 C++ Conference Proceedings, October 17-21, 1988).
479 A nested function can jump to a label inherited from a containing
480 function, provided the label is explicitly declared in the containing
481 function (@pxref{Local Labels}).  Such a jump returns instantly to the
482 containing function, exiting the nested function that did the
483 @code{goto} and any intermediate functions as well.  Here is an example:
485 @smallexample
486 @group
487 bar (int *array, int offset, int size)
489   __label__ failure;
490   int access (int *array, int index)
491     @{
492       if (index > size)
493         goto failure;
494       return array[index + offset];
495     @}
496   int i;
497   /* @r{@dots{}} */
498   for (i = 0; i < size; i++)
499     /* @r{@dots{}} */ access (array, i) /* @r{@dots{}} */
500   /* @r{@dots{}} */
501   return 0;
503  /* @r{Control comes here from @code{access}
504     if it detects an error.}  */
505  failure:
506   return -1;
508 @end group
509 @end smallexample
511 A nested function always has no linkage.  Declaring one with
512 @code{extern} or @code{static} is erroneous.  If you need to declare the nested function
513 before its definition, use @code{auto} (which is otherwise meaningless
514 for function declarations).
516 @smallexample
517 bar (int *array, int offset, int size)
519   __label__ failure;
520   auto int access (int *, int);
521   /* @r{@dots{}} */
522   int access (int *array, int index)
523     @{
524       if (index > size)
525         goto failure;
526       return array[index + offset];
527     @}
528   /* @r{@dots{}} */
530 @end smallexample
532 @node Nonlocal Gotos
533 @section Nonlocal Gotos
534 @cindex nonlocal gotos
536 GCC provides the built-in functions @code{__builtin_setjmp} and
537 @code{__builtin_longjmp} which are similar to, but not interchangeable
538 with, the C library functions @code{setjmp} and @code{longjmp}.  
539 The built-in versions are used internally by GCC's libraries
540 to implement exception handling on some targets.  You should use the 
541 standard C library functions declared in @code{<setjmp.h>} in user code
542 instead of the builtins.
544 The built-in versions of these functions use GCC's normal
545 mechanisms to save and restore registers using the stack on function
546 entry and exit.  The jump buffer argument @var{buf} holds only the
547 information needed to restore the stack frame, rather than the entire 
548 set of saved register values.  
550 An important caveat is that GCC arranges to save and restore only
551 those registers known to the specific architecture variant being
552 compiled for.  This can make @code{__builtin_setjmp} and
553 @code{__builtin_longjmp} more efficient than their library
554 counterparts in some cases, but it can also cause incorrect and
555 mysterious behavior when mixing with code that uses the full register
556 set.
558 You should declare the jump buffer argument @var{buf} to the
559 built-in functions as:
561 @smallexample
562 #include <stdint.h>
563 intptr_t @var{buf}[5];
564 @end smallexample
566 @deftypefn {Built-in Function} {int} __builtin_setjmp (intptr_t *@var{buf})
567 This function saves the current stack context in @var{buf}.  
568 @code{__builtin_setjmp} returns 0 when returning directly,
569 and 1 when returning from @code{__builtin_longjmp} using the same
570 @var{buf}.
571 @end deftypefn
573 @deftypefn {Built-in Function} {void} __builtin_longjmp (intptr_t *@var{buf}, int @var{val})
574 This function restores the stack context in @var{buf}, 
575 saved by a previous call to @code{__builtin_setjmp}.  After
576 @code{__builtin_longjmp} is finished, the program resumes execution as
577 if the matching @code{__builtin_setjmp} returns the value @var{val},
578 which must be 1.
580 Because @code{__builtin_longjmp} depends on the function return
581 mechanism to restore the stack context, it cannot be called
582 from the same function calling @code{__builtin_setjmp} to
583 initialize @var{buf}.  It can only be called from a function called
584 (directly or indirectly) from the function calling @code{__builtin_setjmp}.
585 @end deftypefn
587 @node Constructing Calls
588 @section Constructing Function Calls
589 @cindex constructing calls
590 @cindex forwarding calls
592 Using the built-in functions described below, you can record
593 the arguments a function received, and call another function
594 with the same arguments, without knowing the number or types
595 of the arguments.
597 You can also record the return value of that function call,
598 and later return that value, without knowing what data type
599 the function tried to return (as long as your caller expects
600 that data type).
602 However, these built-in functions may interact badly with some
603 sophisticated features or other extensions of the language.  It
604 is, therefore, not recommended to use them outside very simple
605 functions acting as mere forwarders for their arguments.
607 @deftypefn {Built-in Function} {void *} __builtin_apply_args ()
608 This built-in function returns a pointer to data
609 describing how to perform a call with the same arguments as are passed
610 to the current function.
612 The function saves the arg pointer register, structure value address,
613 and all registers that might be used to pass arguments to a function
614 into a block of memory allocated on the stack.  Then it returns the
615 address of that block.
616 @end deftypefn
618 @deftypefn {Built-in Function} {void *} __builtin_apply (void (*@var{function})(), void *@var{arguments}, size_t @var{size})
619 This built-in function invokes @var{function}
620 with a copy of the parameters described by @var{arguments}
621 and @var{size}.
623 The value of @var{arguments} should be the value returned by
624 @code{__builtin_apply_args}.  The argument @var{size} specifies the size
625 of the stack argument data, in bytes.
627 This function returns a pointer to data describing
628 how to return whatever value is returned by @var{function}.  The data
629 is saved in a block of memory allocated on the stack.
631 It is not always simple to compute the proper value for @var{size}.  The
632 value is used by @code{__builtin_apply} to compute the amount of data
633 that should be pushed on the stack and copied from the incoming argument
634 area.
635 @end deftypefn
637 @deftypefn {Built-in Function} {void} __builtin_return (void *@var{result})
638 This built-in function returns the value described by @var{result} from
639 the containing function.  You should specify, for @var{result}, a value
640 returned by @code{__builtin_apply}.
641 @end deftypefn
643 @deftypefn {Built-in Function} {} __builtin_va_arg_pack ()
644 This built-in function represents all anonymous arguments of an inline
645 function.  It can be used only in inline functions that are always
646 inlined, never compiled as a separate function, such as those using
647 @code{__attribute__ ((__always_inline__))} or
648 @code{__attribute__ ((__gnu_inline__))} extern inline functions.
649 It must be only passed as last argument to some other function
650 with variable arguments.  This is useful for writing small wrapper
651 inlines for variable argument functions, when using preprocessor
652 macros is undesirable.  For example:
653 @smallexample
654 extern int myprintf (FILE *f, const char *format, ...);
655 extern inline __attribute__ ((__gnu_inline__)) int
656 myprintf (FILE *f, const char *format, ...)
658   int r = fprintf (f, "myprintf: ");
659   if (r < 0)
660     return r;
661   int s = fprintf (f, format, __builtin_va_arg_pack ());
662   if (s < 0)
663     return s;
664   return r + s;
666 @end smallexample
667 @end deftypefn
669 @deftypefn {Built-in Function} {size_t} __builtin_va_arg_pack_len ()
670 This built-in function returns the number of anonymous arguments of
671 an inline function.  It can be used only in inline functions that
672 are always inlined, never compiled as a separate function, such
673 as those using @code{__attribute__ ((__always_inline__))} or
674 @code{__attribute__ ((__gnu_inline__))} extern inline functions.
675 For example following does link- or run-time checking of open
676 arguments for optimized code:
677 @smallexample
678 #ifdef __OPTIMIZE__
679 extern inline __attribute__((__gnu_inline__)) int
680 myopen (const char *path, int oflag, ...)
682   if (__builtin_va_arg_pack_len () > 1)
683     warn_open_too_many_arguments ();
685   if (__builtin_constant_p (oflag))
686     @{
687       if ((oflag & O_CREAT) != 0 && __builtin_va_arg_pack_len () < 1)
688         @{
689           warn_open_missing_mode ();
690           return __open_2 (path, oflag);
691         @}
692       return open (path, oflag, __builtin_va_arg_pack ());
693     @}
695   if (__builtin_va_arg_pack_len () < 1)
696     return __open_2 (path, oflag);
698   return open (path, oflag, __builtin_va_arg_pack ());
700 #endif
701 @end smallexample
702 @end deftypefn
704 @node Typeof
705 @section Referring to a Type with @code{typeof}
706 @findex typeof
707 @findex sizeof
708 @cindex macros, types of arguments
710 Another way to refer to the type of an expression is with @code{typeof}.
711 The syntax of using of this keyword looks like @code{sizeof}, but the
712 construct acts semantically like a type name defined with @code{typedef}.
714 There are two ways of writing the argument to @code{typeof}: with an
715 expression or with a type.  Here is an example with an expression:
717 @smallexample
718 typeof (x[0](1))
719 @end smallexample
721 @noindent
722 This assumes that @code{x} is an array of pointers to functions;
723 the type described is that of the values of the functions.
725 Here is an example with a typename as the argument:
727 @smallexample
728 typeof (int *)
729 @end smallexample
731 @noindent
732 Here the type described is that of pointers to @code{int}.
734 If you are writing a header file that must work when included in ISO C
735 programs, write @code{__typeof__} instead of @code{typeof}.
736 @xref{Alternate Keywords}.
738 A @code{typeof} construct can be used anywhere a typedef name can be
739 used.  For example, you can use it in a declaration, in a cast, or inside
740 of @code{sizeof} or @code{typeof}.
742 The operand of @code{typeof} is evaluated for its side effects if and
743 only if it is an expression of variably modified type or the name of
744 such a type.
746 @code{typeof} is often useful in conjunction with
747 statement expressions (@pxref{Statement Exprs}).
748 Here is how the two together can
749 be used to define a safe ``maximum'' macro which operates on any
750 arithmetic type and evaluates each of its arguments exactly once:
752 @smallexample
753 #define max(a,b) \
754   (@{ typeof (a) _a = (a); \
755       typeof (b) _b = (b); \
756     _a > _b ? _a : _b; @})
757 @end smallexample
759 @cindex underscores in variables in macros
760 @cindex @samp{_} in variables in macros
761 @cindex local variables in macros
762 @cindex variables, local, in macros
763 @cindex macros, local variables in
765 The reason for using names that start with underscores for the local
766 variables is to avoid conflicts with variable names that occur within the
767 expressions that are substituted for @code{a} and @code{b}.  Eventually we
768 hope to design a new form of declaration syntax that allows you to declare
769 variables whose scopes start only after their initializers; this will be a
770 more reliable way to prevent such conflicts.
772 @noindent
773 Some more examples of the use of @code{typeof}:
775 @itemize @bullet
776 @item
777 This declares @code{y} with the type of what @code{x} points to.
779 @smallexample
780 typeof (*x) y;
781 @end smallexample
783 @item
784 This declares @code{y} as an array of such values.
786 @smallexample
787 typeof (*x) y[4];
788 @end smallexample
790 @item
791 This declares @code{y} as an array of pointers to characters:
793 @smallexample
794 typeof (typeof (char *)[4]) y;
795 @end smallexample
797 @noindent
798 It is equivalent to the following traditional C declaration:
800 @smallexample
801 char *y[4];
802 @end smallexample
804 To see the meaning of the declaration using @code{typeof}, and why it
805 might be a useful way to write, rewrite it with these macros:
807 @smallexample
808 #define pointer(T)  typeof(T *)
809 #define array(T, N) typeof(T [N])
810 @end smallexample
812 @noindent
813 Now the declaration can be rewritten this way:
815 @smallexample
816 array (pointer (char), 4) y;
817 @end smallexample
819 @noindent
820 Thus, @code{array (pointer (char), 4)} is the type of arrays of 4
821 pointers to @code{char}.
822 @end itemize
824 In GNU C, but not GNU C++, you may also declare the type of a variable
825 as @code{__auto_type}.  In that case, the declaration must declare
826 only one variable, whose declarator must just be an identifier, the
827 declaration must be initialized, and the type of the variable is
828 determined by the initializer; the name of the variable is not in
829 scope until after the initializer.  (In C++, you should use C++11
830 @code{auto} for this purpose.)  Using @code{__auto_type}, the
831 ``maximum'' macro above could be written as:
833 @smallexample
834 #define max(a,b) \
835   (@{ __auto_type _a = (a); \
836       __auto_type _b = (b); \
837     _a > _b ? _a : _b; @})
838 @end smallexample
840 Using @code{__auto_type} instead of @code{typeof} has two advantages:
842 @itemize @bullet
843 @item Each argument to the macro appears only once in the expansion of
844 the macro.  This prevents the size of the macro expansion growing
845 exponentially when calls to such macros are nested inside arguments of
846 such macros.
848 @item If the argument to the macro has variably modified type, it is
849 evaluated only once when using @code{__auto_type}, but twice if
850 @code{typeof} is used.
851 @end itemize
853 @node Conditionals
854 @section Conditionals with Omitted Operands
855 @cindex conditional expressions, extensions
856 @cindex omitted middle-operands
857 @cindex middle-operands, omitted
858 @cindex extensions, @code{?:}
859 @cindex @code{?:} extensions
861 The middle operand in a conditional expression may be omitted.  Then
862 if the first operand is nonzero, its value is the value of the conditional
863 expression.
865 Therefore, the expression
867 @smallexample
868 x ? : y
869 @end smallexample
871 @noindent
872 has the value of @code{x} if that is nonzero; otherwise, the value of
873 @code{y}.
875 This example is perfectly equivalent to
877 @smallexample
878 x ? x : y
879 @end smallexample
881 @cindex side effect in @code{?:}
882 @cindex @code{?:} side effect
883 @noindent
884 In this simple case, the ability to omit the middle operand is not
885 especially useful.  When it becomes useful is when the first operand does,
886 or may (if it is a macro argument), contain a side effect.  Then repeating
887 the operand in the middle would perform the side effect twice.  Omitting
888 the middle operand uses the value already computed without the undesirable
889 effects of recomputing it.
891 @node __int128
892 @section 128-bit Integers
893 @cindex @code{__int128} data types
895 As an extension the integer scalar type @code{__int128} is supported for
896 targets which have an integer mode wide enough to hold 128 bits.
897 Simply write @code{__int128} for a signed 128-bit integer, or
898 @code{unsigned __int128} for an unsigned 128-bit integer.  There is no
899 support in GCC for expressing an integer constant of type @code{__int128}
900 for targets with @code{long long} integer less than 128 bits wide.
902 @node Long Long
903 @section Double-Word Integers
904 @cindex @code{long long} data types
905 @cindex double-word arithmetic
906 @cindex multiprecision arithmetic
907 @cindex @code{LL} integer suffix
908 @cindex @code{ULL} integer suffix
910 ISO C99 and ISO C++11 support data types for integers that are at least
911 64 bits wide, and as an extension GCC supports them in C90 and C++98 modes.
912 Simply write @code{long long int} for a signed integer, or
913 @code{unsigned long long int} for an unsigned integer.  To make an
914 integer constant of type @code{long long int}, add the suffix @samp{LL}
915 to the integer.  To make an integer constant of type @code{unsigned long
916 long int}, add the suffix @samp{ULL} to the integer.
918 You can use these types in arithmetic like any other integer types.
919 Addition, subtraction, and bitwise boolean operations on these types
920 are open-coded on all types of machines.  Multiplication is open-coded
921 if the machine supports a fullword-to-doubleword widening multiply
922 instruction.  Division and shifts are open-coded only on machines that
923 provide special support.  The operations that are not open-coded use
924 special library routines that come with GCC@.
926 There may be pitfalls when you use @code{long long} types for function
927 arguments without function prototypes.  If a function
928 expects type @code{int} for its argument, and you pass a value of type
929 @code{long long int}, confusion results because the caller and the
930 subroutine disagree about the number of bytes for the argument.
931 Likewise, if the function expects @code{long long int} and you pass
932 @code{int}.  The best way to avoid such problems is to use prototypes.
934 @node Complex
935 @section Complex Numbers
936 @cindex complex numbers
937 @cindex @code{_Complex} keyword
938 @cindex @code{__complex__} keyword
940 ISO C99 supports complex floating data types, and as an extension GCC
941 supports them in C90 mode and in C++.  GCC also supports complex integer data
942 types which are not part of ISO C99.  You can declare complex types
943 using the keyword @code{_Complex}.  As an extension, the older GNU
944 keyword @code{__complex__} is also supported.
946 For example, @samp{_Complex double x;} declares @code{x} as a
947 variable whose real part and imaginary part are both of type
948 @code{double}.  @samp{_Complex short int y;} declares @code{y} to
949 have real and imaginary parts of type @code{short int}; this is not
950 likely to be useful, but it shows that the set of complex types is
951 complete.
953 To write a constant with a complex data type, use the suffix @samp{i} or
954 @samp{j} (either one; they are equivalent).  For example, @code{2.5fi}
955 has type @code{_Complex float} and @code{3i} has type
956 @code{_Complex int}.  Such a constant always has a pure imaginary
957 value, but you can form any complex value you like by adding one to a
958 real constant.  This is a GNU extension; if you have an ISO C99
959 conforming C library (such as the GNU C Library), and want to construct complex
960 constants of floating type, you should include @code{<complex.h>} and
961 use the macros @code{I} or @code{_Complex_I} instead.
963 The ISO C++14 library also defines the @samp{i} suffix, so C++14 code
964 that includes the @samp{<complex>} header cannot use @samp{i} for the
965 GNU extension.  The @samp{j} suffix still has the GNU meaning.
967 @cindex @code{__real__} keyword
968 @cindex @code{__imag__} keyword
969 To extract the real part of a complex-valued expression @var{exp}, write
970 @code{__real__ @var{exp}}.  Likewise, use @code{__imag__} to
971 extract the imaginary part.  This is a GNU extension; for values of
972 floating type, you should use the ISO C99 functions @code{crealf},
973 @code{creal}, @code{creall}, @code{cimagf}, @code{cimag} and
974 @code{cimagl}, declared in @code{<complex.h>} and also provided as
975 built-in functions by GCC@.
977 @cindex complex conjugation
978 The operator @samp{~} performs complex conjugation when used on a value
979 with a complex type.  This is a GNU extension; for values of
980 floating type, you should use the ISO C99 functions @code{conjf},
981 @code{conj} and @code{conjl}, declared in @code{<complex.h>} and also
982 provided as built-in functions by GCC@.
984 GCC can allocate complex automatic variables in a noncontiguous
985 fashion; it's even possible for the real part to be in a register while
986 the imaginary part is on the stack (or vice versa).  Only the DWARF
987 debug info format can represent this, so use of DWARF is recommended.
988 If you are using the stabs debug info format, GCC describes a noncontiguous
989 complex variable as if it were two separate variables of noncomplex type.
990 If the variable's actual name is @code{foo}, the two fictitious
991 variables are named @code{foo$real} and @code{foo$imag}.  You can
992 examine and set these two fictitious variables with your debugger.
994 @node Floating Types
995 @section Additional Floating Types
996 @cindex additional floating types
997 @cindex @code{_Float@var{n}} data types
998 @cindex @code{_Float@var{n}x} data types
999 @cindex @code{__float80} data type
1000 @cindex @code{__float128} data type
1001 @cindex @code{__ibm128} data type
1002 @cindex @code{w} floating point suffix
1003 @cindex @code{q} floating point suffix
1004 @cindex @code{W} floating point suffix
1005 @cindex @code{Q} floating point suffix
1007 ISO/IEC TS 18661-3:2015 defines C support for additional floating
1008 types @code{_Float@var{n}} and @code{_Float@var{n}x}, and GCC supports
1009 these type names; the set of types supported depends on the target
1010 architecture.  These types are not supported when compiling C++.
1011 Constants with these types use suffixes @code{f@var{n}} or
1012 @code{F@var{n}} and @code{f@var{n}x} or @code{F@var{n}x}.  These type
1013 names can be used together with @code{_Complex} to declare complex
1014 types.
1016 As an extension, GNU C and GNU C++ support additional floating
1017 types, which are not supported by all targets.
1018 @itemize @bullet
1019 @item @code{__float128} is available on i386, x86_64, IA-64, and
1020 hppa HP-UX, as well as on PowerPC GNU/Linux targets that enable
1021 the vector scalar (VSX) instruction set.  @code{__float128} supports
1022 the 128-bit floating type.  On i386, x86_64, PowerPC, and IA-64
1023 other than HP-UX, @code{__float128} is an alias for @code{_Float128}.
1024 On hppa and IA-64 HP-UX, @code{__float128} is an alias for @code{long
1025 double}.
1027 @item @code{__float80} is available on the i386, x86_64, and IA-64
1028 targets, and supports the 80-bit (@code{XFmode}) floating type.  It is
1029 an alias for the type name @code{_Float64x} on these targets.
1031 @item @code{__ibm128} is available on PowerPC targets, and provides
1032 access to the IBM extended double format which is the current format
1033 used for @code{long double}.  When @code{long double} transitions to
1034 @code{__float128} on PowerPC in the future, @code{__ibm128} will remain
1035 for use in conversions between the two types.
1036 @end itemize
1038 Support for these additional types includes the arithmetic operators:
1039 add, subtract, multiply, divide; unary arithmetic operators;
1040 relational operators; equality operators; and conversions to and from
1041 integer and other floating types.  Use a suffix @samp{w} or @samp{W}
1042 in a literal constant of type @code{__float80} or type
1043 @code{__ibm128}.  Use a suffix @samp{q} or @samp{Q} for @code{_float128}.
1045 In order to use @code{_Float128}, @code{__float128}, and @code{__ibm128}
1046 on PowerPC Linux systems, you must use the @option{-mfloat128} option. It is
1047 expected in future versions of GCC that @code{_Float128} and @code{__float128}
1048 will be enabled automatically.
1050 The @code{_Float128} type is supported on all systems where
1051 @code{__float128} is supported or where @code{long double} has the
1052 IEEE binary128 format.  The @code{_Float64x} type is supported on all
1053 systems where @code{__float128} is supported.  The @code{_Float32}
1054 type is supported on all systems supporting IEEE binary32; the
1055 @code{_Float64} and @code{_Float32x} types are supported on all systems
1056 supporting IEEE binary64.  The @code{_Float16} type is supported on AArch64
1057 systems by default, and on ARM systems when the IEEE format for 16-bit
1058 floating-point types is selected with @option{-mfp16-format=ieee}.
1059 GCC does not currently support @code{_Float128x} on any systems.
1061 On the i386, x86_64, IA-64, and HP-UX targets, you can declare complex
1062 types using the corresponding internal complex type, @code{XCmode} for
1063 @code{__float80} type and @code{TCmode} for @code{__float128} type:
1065 @smallexample
1066 typedef _Complex float __attribute__((mode(TC))) _Complex128;
1067 typedef _Complex float __attribute__((mode(XC))) _Complex80;
1068 @end smallexample
1070 On the PowerPC Linux VSX targets, you can declare complex types using
1071 the corresponding internal complex type, @code{KCmode} for
1072 @code{__float128} type and @code{ICmode} for @code{__ibm128} type:
1074 @smallexample
1075 typedef _Complex float __attribute__((mode(KC))) _Complex_float128;
1076 typedef _Complex float __attribute__((mode(IC))) _Complex_ibm128;
1077 @end smallexample
1079 @node Half-Precision
1080 @section Half-Precision Floating Point
1081 @cindex half-precision floating point
1082 @cindex @code{__fp16} data type
1084 On ARM and AArch64 targets, GCC supports half-precision (16-bit) floating
1085 point via the @code{__fp16} type defined in the ARM C Language Extensions.
1086 On ARM systems, you must enable this type explicitly with the
1087 @option{-mfp16-format} command-line option in order to use it.
1089 ARM targets support two incompatible representations for half-precision
1090 floating-point values.  You must choose one of the representations and
1091 use it consistently in your program.
1093 Specifying @option{-mfp16-format=ieee} selects the IEEE 754-2008 format.
1094 This format can represent normalized values in the range of @math{2^{-14}} to 65504.
1095 There are 11 bits of significand precision, approximately 3
1096 decimal digits.
1098 Specifying @option{-mfp16-format=alternative} selects the ARM
1099 alternative format.  This representation is similar to the IEEE
1100 format, but does not support infinities or NaNs.  Instead, the range
1101 of exponents is extended, so that this format can represent normalized
1102 values in the range of @math{2^{-14}} to 131008.
1104 The GCC port for AArch64 only supports the IEEE 754-2008 format, and does
1105 not require use of the @option{-mfp16-format} command-line option.
1107 The @code{__fp16} type may only be used as an argument to intrinsics defined
1108 in @code{<arm_fp16.h>}, or as a storage format.  For purposes of
1109 arithmetic and other operations, @code{__fp16} values in C or C++
1110 expressions are automatically promoted to @code{float}.
1112 The ARM target provides hardware support for conversions between
1113 @code{__fp16} and @code{float} values
1114 as an extension to VFP and NEON (Advanced SIMD), and from ARMv8-A provides
1115 hardware support for conversions between @code{__fp16} and @code{double}
1116 values.  GCC generates code using these hardware instructions if you
1117 compile with options to select an FPU that provides them;
1118 for example, @option{-mfpu=neon-fp16 -mfloat-abi=softfp},
1119 in addition to the @option{-mfp16-format} option to select
1120 a half-precision format.
1122 Language-level support for the @code{__fp16} data type is
1123 independent of whether GCC generates code using hardware floating-point
1124 instructions.  In cases where hardware support is not specified, GCC
1125 implements conversions between @code{__fp16} and other types as library
1126 calls.
1128 It is recommended that portable code use the @code{_Float16} type defined
1129 by ISO/IEC TS 18661-3:2015.  @xref{Floating Types}.
1131 @node Decimal Float
1132 @section Decimal Floating Types
1133 @cindex decimal floating types
1134 @cindex @code{_Decimal32} data type
1135 @cindex @code{_Decimal64} data type
1136 @cindex @code{_Decimal128} data type
1137 @cindex @code{df} integer suffix
1138 @cindex @code{dd} integer suffix
1139 @cindex @code{dl} integer suffix
1140 @cindex @code{DF} integer suffix
1141 @cindex @code{DD} integer suffix
1142 @cindex @code{DL} integer suffix
1144 As an extension, GNU C supports decimal floating types as
1145 defined in the N1312 draft of ISO/IEC WDTR24732.  Support for decimal
1146 floating types in GCC will evolve as the draft technical report changes.
1147 Calling conventions for any target might also change.  Not all targets
1148 support decimal floating types.
1150 The decimal floating types are @code{_Decimal32}, @code{_Decimal64}, and
1151 @code{_Decimal128}.  They use a radix of ten, unlike the floating types
1152 @code{float}, @code{double}, and @code{long double} whose radix is not
1153 specified by the C standard but is usually two.
1155 Support for decimal floating types includes the arithmetic operators
1156 add, subtract, multiply, divide; unary arithmetic operators;
1157 relational operators; equality operators; and conversions to and from
1158 integer and other floating types.  Use a suffix @samp{df} or
1159 @samp{DF} in a literal constant of type @code{_Decimal32}, @samp{dd}
1160 or @samp{DD} for @code{_Decimal64}, and @samp{dl} or @samp{DL} for
1161 @code{_Decimal128}.
1163 GCC support of decimal float as specified by the draft technical report
1164 is incomplete:
1166 @itemize @bullet
1167 @item
1168 When the value of a decimal floating type cannot be represented in the
1169 integer type to which it is being converted, the result is undefined
1170 rather than the result value specified by the draft technical report.
1172 @item
1173 GCC does not provide the C library functionality associated with
1174 @file{math.h}, @file{fenv.h}, @file{stdio.h}, @file{stdlib.h}, and
1175 @file{wchar.h}, which must come from a separate C library implementation.
1176 Because of this the GNU C compiler does not define macro
1177 @code{__STDC_DEC_FP__} to indicate that the implementation conforms to
1178 the technical report.
1179 @end itemize
1181 Types @code{_Decimal32}, @code{_Decimal64}, and @code{_Decimal128}
1182 are supported by the DWARF debug information format.
1184 @node Hex Floats
1185 @section Hex Floats
1186 @cindex hex floats
1188 ISO C99 and ISO C++17 support floating-point numbers written not only in
1189 the usual decimal notation, such as @code{1.55e1}, but also numbers such as
1190 @code{0x1.fp3} written in hexadecimal format.  As a GNU extension, GCC
1191 supports this in C90 mode (except in some cases when strictly
1192 conforming) and in C++98, C++11 and C++14 modes.  In that format the
1193 @samp{0x} hex introducer and the @samp{p} or @samp{P} exponent field are
1194 mandatory.  The exponent is a decimal number that indicates the power of
1195 2 by which the significant part is multiplied.  Thus @samp{0x1.f} is
1196 @tex
1197 $1 {15\over16}$,
1198 @end tex
1199 @ifnottex
1200 1 15/16,
1201 @end ifnottex
1202 @samp{p3} multiplies it by 8, and the value of @code{0x1.fp3}
1203 is the same as @code{1.55e1}.
1205 Unlike for floating-point numbers in the decimal notation the exponent
1206 is always required in the hexadecimal notation.  Otherwise the compiler
1207 would not be able to resolve the ambiguity of, e.g., @code{0x1.f}.  This
1208 could mean @code{1.0f} or @code{1.9375} since @samp{f} is also the
1209 extension for floating-point constants of type @code{float}.
1211 @node Fixed-Point
1212 @section Fixed-Point Types
1213 @cindex fixed-point types
1214 @cindex @code{_Fract} data type
1215 @cindex @code{_Accum} data type
1216 @cindex @code{_Sat} data type
1217 @cindex @code{hr} fixed-suffix
1218 @cindex @code{r} fixed-suffix
1219 @cindex @code{lr} fixed-suffix
1220 @cindex @code{llr} fixed-suffix
1221 @cindex @code{uhr} fixed-suffix
1222 @cindex @code{ur} fixed-suffix
1223 @cindex @code{ulr} fixed-suffix
1224 @cindex @code{ullr} fixed-suffix
1225 @cindex @code{hk} fixed-suffix
1226 @cindex @code{k} fixed-suffix
1227 @cindex @code{lk} fixed-suffix
1228 @cindex @code{llk} fixed-suffix
1229 @cindex @code{uhk} fixed-suffix
1230 @cindex @code{uk} fixed-suffix
1231 @cindex @code{ulk} fixed-suffix
1232 @cindex @code{ullk} fixed-suffix
1233 @cindex @code{HR} fixed-suffix
1234 @cindex @code{R} fixed-suffix
1235 @cindex @code{LR} fixed-suffix
1236 @cindex @code{LLR} fixed-suffix
1237 @cindex @code{UHR} fixed-suffix
1238 @cindex @code{UR} fixed-suffix
1239 @cindex @code{ULR} fixed-suffix
1240 @cindex @code{ULLR} fixed-suffix
1241 @cindex @code{HK} fixed-suffix
1242 @cindex @code{K} fixed-suffix
1243 @cindex @code{LK} fixed-suffix
1244 @cindex @code{LLK} fixed-suffix
1245 @cindex @code{UHK} fixed-suffix
1246 @cindex @code{UK} fixed-suffix
1247 @cindex @code{ULK} fixed-suffix
1248 @cindex @code{ULLK} fixed-suffix
1250 As an extension, GNU C supports fixed-point types as
1251 defined in the N1169 draft of ISO/IEC DTR 18037.  Support for fixed-point
1252 types in GCC will evolve as the draft technical report changes.
1253 Calling conventions for any target might also change.  Not all targets
1254 support fixed-point types.
1256 The fixed-point types are
1257 @code{short _Fract},
1258 @code{_Fract},
1259 @code{long _Fract},
1260 @code{long long _Fract},
1261 @code{unsigned short _Fract},
1262 @code{unsigned _Fract},
1263 @code{unsigned long _Fract},
1264 @code{unsigned long long _Fract},
1265 @code{_Sat short _Fract},
1266 @code{_Sat _Fract},
1267 @code{_Sat long _Fract},
1268 @code{_Sat long long _Fract},
1269 @code{_Sat unsigned short _Fract},
1270 @code{_Sat unsigned _Fract},
1271 @code{_Sat unsigned long _Fract},
1272 @code{_Sat unsigned long long _Fract},
1273 @code{short _Accum},
1274 @code{_Accum},
1275 @code{long _Accum},
1276 @code{long long _Accum},
1277 @code{unsigned short _Accum},
1278 @code{unsigned _Accum},
1279 @code{unsigned long _Accum},
1280 @code{unsigned long long _Accum},
1281 @code{_Sat short _Accum},
1282 @code{_Sat _Accum},
1283 @code{_Sat long _Accum},
1284 @code{_Sat long long _Accum},
1285 @code{_Sat unsigned short _Accum},
1286 @code{_Sat unsigned _Accum},
1287 @code{_Sat unsigned long _Accum},
1288 @code{_Sat unsigned long long _Accum}.
1290 Fixed-point data values contain fractional and optional integral parts.
1291 The format of fixed-point data varies and depends on the target machine.
1293 Support for fixed-point types includes:
1294 @itemize @bullet
1295 @item
1296 prefix and postfix increment and decrement operators (@code{++}, @code{--})
1297 @item
1298 unary arithmetic operators (@code{+}, @code{-}, @code{!})
1299 @item
1300 binary arithmetic operators (@code{+}, @code{-}, @code{*}, @code{/})
1301 @item
1302 binary shift operators (@code{<<}, @code{>>})
1303 @item
1304 relational operators (@code{<}, @code{<=}, @code{>=}, @code{>})
1305 @item
1306 equality operators (@code{==}, @code{!=})
1307 @item
1308 assignment operators (@code{+=}, @code{-=}, @code{*=}, @code{/=},
1309 @code{<<=}, @code{>>=})
1310 @item
1311 conversions to and from integer, floating-point, or fixed-point types
1312 @end itemize
1314 Use a suffix in a fixed-point literal constant:
1315 @itemize
1316 @item @samp{hr} or @samp{HR} for @code{short _Fract} and
1317 @code{_Sat short _Fract}
1318 @item @samp{r} or @samp{R} for @code{_Fract} and @code{_Sat _Fract}
1319 @item @samp{lr} or @samp{LR} for @code{long _Fract} and
1320 @code{_Sat long _Fract}
1321 @item @samp{llr} or @samp{LLR} for @code{long long _Fract} and
1322 @code{_Sat long long _Fract}
1323 @item @samp{uhr} or @samp{UHR} for @code{unsigned short _Fract} and
1324 @code{_Sat unsigned short _Fract}
1325 @item @samp{ur} or @samp{UR} for @code{unsigned _Fract} and
1326 @code{_Sat unsigned _Fract}
1327 @item @samp{ulr} or @samp{ULR} for @code{unsigned long _Fract} and
1328 @code{_Sat unsigned long _Fract}
1329 @item @samp{ullr} or @samp{ULLR} for @code{unsigned long long _Fract}
1330 and @code{_Sat unsigned long long _Fract}
1331 @item @samp{hk} or @samp{HK} for @code{short _Accum} and
1332 @code{_Sat short _Accum}
1333 @item @samp{k} or @samp{K} for @code{_Accum} and @code{_Sat _Accum}
1334 @item @samp{lk} or @samp{LK} for @code{long _Accum} and
1335 @code{_Sat long _Accum}
1336 @item @samp{llk} or @samp{LLK} for @code{long long _Accum} and
1337 @code{_Sat long long _Accum}
1338 @item @samp{uhk} or @samp{UHK} for @code{unsigned short _Accum} and
1339 @code{_Sat unsigned short _Accum}
1340 @item @samp{uk} or @samp{UK} for @code{unsigned _Accum} and
1341 @code{_Sat unsigned _Accum}
1342 @item @samp{ulk} or @samp{ULK} for @code{unsigned long _Accum} and
1343 @code{_Sat unsigned long _Accum}
1344 @item @samp{ullk} or @samp{ULLK} for @code{unsigned long long _Accum}
1345 and @code{_Sat unsigned long long _Accum}
1346 @end itemize
1348 GCC support of fixed-point types as specified by the draft technical report
1349 is incomplete:
1351 @itemize @bullet
1352 @item
1353 Pragmas to control overflow and rounding behaviors are not implemented.
1354 @end itemize
1356 Fixed-point types are supported by the DWARF debug information format.
1358 @node Named Address Spaces
1359 @section Named Address Spaces
1360 @cindex Named Address Spaces
1362 As an extension, GNU C supports named address spaces as
1363 defined in the N1275 draft of ISO/IEC DTR 18037.  Support for named
1364 address spaces in GCC will evolve as the draft technical report
1365 changes.  Calling conventions for any target might also change.  At
1366 present, only the AVR, SPU, M32C, RL78, and x86 targets support
1367 address spaces other than the generic address space.
1369 Address space identifiers may be used exactly like any other C type
1370 qualifier (e.g., @code{const} or @code{volatile}).  See the N1275
1371 document for more details.
1373 @anchor{AVR Named Address Spaces}
1374 @subsection AVR Named Address Spaces
1376 On the AVR target, there are several address spaces that can be used
1377 in order to put read-only data into the flash memory and access that
1378 data by means of the special instructions @code{LPM} or @code{ELPM}
1379 needed to read from flash.
1381 Devices belonging to @code{avrtiny} and @code{avrxmega3} can access
1382 flash memory by means of @code{LD*} instructions because the flash
1383 memory is mapped into the RAM address space.  There is @emph{no need}
1384 for language extensions like @code{__flash} or attribute
1385 @ref{AVR Variable Attributes,,@code{progmem}}.
1386 The default linker description files for these devices cater for that
1387 feature and @code{.rodata} stays in flash: The compiler just generates
1388 @code{LD*} instructions, and the linker script adds core specific
1389 offsets to all @code{.rodata} symbols: @code{0x4000} in the case of
1390 @code{avrtiny} and @code{0x8000} in the case of @code{avrxmega3}.
1391 See @ref{AVR Options} for a list of respective devices.
1393 For devices not in @code{avrtiny} or @code{avrxmega3},
1394 any data including read-only data is located in RAM (the generic
1395 address space) because flash memory is not visible in the RAM address
1396 space.  In order to locate read-only data in flash memory @emph{and}
1397 to generate the right instructions to access this data without
1398 using (inline) assembler code, special address spaces are needed.
1400 @table @code
1401 @item __flash
1402 @cindex @code{__flash} AVR Named Address Spaces
1403 The @code{__flash} qualifier locates data in the
1404 @code{.progmem.data} section. Data is read using the @code{LPM}
1405 instruction. Pointers to this address space are 16 bits wide.
1407 @item __flash1
1408 @itemx __flash2
1409 @itemx __flash3
1410 @itemx __flash4
1411 @itemx __flash5
1412 @cindex @code{__flash1} AVR Named Address Spaces
1413 @cindex @code{__flash2} AVR Named Address Spaces
1414 @cindex @code{__flash3} AVR Named Address Spaces
1415 @cindex @code{__flash4} AVR Named Address Spaces
1416 @cindex @code{__flash5} AVR Named Address Spaces
1417 These are 16-bit address spaces locating data in section
1418 @code{.progmem@var{N}.data} where @var{N} refers to
1419 address space @code{__flash@var{N}}.
1420 The compiler sets the @code{RAMPZ} segment register appropriately 
1421 before reading data by means of the @code{ELPM} instruction.
1423 @item __memx
1424 @cindex @code{__memx} AVR Named Address Spaces
1425 This is a 24-bit address space that linearizes flash and RAM:
1426 If the high bit of the address is set, data is read from
1427 RAM using the lower two bytes as RAM address.
1428 If the high bit of the address is clear, data is read from flash
1429 with @code{RAMPZ} set according to the high byte of the address.
1430 @xref{AVR Built-in Functions,,@code{__builtin_avr_flash_segment}}.
1432 Objects in this address space are located in @code{.progmemx.data}.
1433 @end table
1435 @b{Example}
1437 @smallexample
1438 char my_read (const __flash char ** p)
1440     /* p is a pointer to RAM that points to a pointer to flash.
1441        The first indirection of p reads that flash pointer
1442        from RAM and the second indirection reads a char from this
1443        flash address.  */
1445     return **p;
1448 /* Locate array[] in flash memory */
1449 const __flash int array[] = @{ 3, 5, 7, 11, 13, 17, 19 @};
1451 int i = 1;
1453 int main (void)
1455    /* Return 17 by reading from flash memory */
1456    return array[array[i]];
1458 @end smallexample
1460 @noindent
1461 For each named address space supported by avr-gcc there is an equally
1462 named but uppercase built-in macro defined. 
1463 The purpose is to facilitate testing if respective address space
1464 support is available or not:
1466 @smallexample
1467 #ifdef __FLASH
1468 const __flash int var = 1;
1470 int read_var (void)
1472     return var;
1474 #else
1475 #include <avr/pgmspace.h> /* From AVR-LibC */
1477 const int var PROGMEM = 1;
1479 int read_var (void)
1481     return (int) pgm_read_word (&var);
1483 #endif /* __FLASH */
1484 @end smallexample
1486 @noindent
1487 Notice that attribute @ref{AVR Variable Attributes,,@code{progmem}}
1488 locates data in flash but
1489 accesses to these data read from generic address space, i.e.@:
1490 from RAM,
1491 so that you need special accessors like @code{pgm_read_byte}
1492 from @w{@uref{http://nongnu.org/avr-libc/user-manual/,AVR-LibC}}
1493 together with attribute @code{progmem}.
1495 @noindent
1496 @b{Limitations and caveats}
1498 @itemize
1499 @item
1500 Reading across the 64@tie{}KiB section boundary of
1501 the @code{__flash} or @code{__flash@var{N}} address spaces
1502 shows undefined behavior. The only address space that
1503 supports reading across the 64@tie{}KiB flash segment boundaries is
1504 @code{__memx}.
1506 @item
1507 If you use one of the @code{__flash@var{N}} address spaces
1508 you must arrange your linker script to locate the
1509 @code{.progmem@var{N}.data} sections according to your needs.
1511 @item
1512 Any data or pointers to the non-generic address spaces must
1513 be qualified as @code{const}, i.e.@: as read-only data.
1514 This still applies if the data in one of these address
1515 spaces like software version number or calibration lookup table are intended to
1516 be changed after load time by, say, a boot loader. In this case
1517 the right qualification is @code{const} @code{volatile} so that the compiler
1518 must not optimize away known values or insert them
1519 as immediates into operands of instructions.
1521 @item
1522 The following code initializes a variable @code{pfoo}
1523 located in static storage with a 24-bit address:
1524 @smallexample
1525 extern const __memx char foo;
1526 const __memx void *pfoo = &foo;
1527 @end smallexample
1529 @item
1530 On the reduced Tiny devices like ATtiny40, no address spaces are supported.
1531 Just use vanilla C / C++ code without overhead as outlined above.
1532 Attribute @code{progmem} is supported but works differently,
1533 see @ref{AVR Variable Attributes}.
1535 @end itemize
1537 @subsection M32C Named Address Spaces
1538 @cindex @code{__far} M32C Named Address Spaces
1540 On the M32C target, with the R8C and M16C CPU variants, variables
1541 qualified with @code{__far} are accessed using 32-bit addresses in
1542 order to access memory beyond the first 64@tie{}Ki bytes.  If
1543 @code{__far} is used with the M32CM or M32C CPU variants, it has no
1544 effect.
1546 @subsection RL78 Named Address Spaces
1547 @cindex @code{__far} RL78 Named Address Spaces
1549 On the RL78 target, variables qualified with @code{__far} are accessed
1550 with 32-bit pointers (20-bit addresses) rather than the default 16-bit
1551 addresses.  Non-far variables are assumed to appear in the topmost
1552 64@tie{}KiB of the address space.
1554 @subsection SPU Named Address Spaces
1555 @cindex @code{__ea} SPU Named Address Spaces
1557 On the SPU target variables may be declared as
1558 belonging to another address space by qualifying the type with the
1559 @code{__ea} address space identifier:
1561 @smallexample
1562 extern int __ea i;
1563 @end smallexample
1565 @noindent 
1566 The compiler generates special code to access the variable @code{i}.
1567 It may use runtime library
1568 support, or generate special machine instructions to access that address
1569 space.
1571 @subsection x86 Named Address Spaces
1572 @cindex x86 named address spaces
1574 On the x86 target, variables may be declared as being relative
1575 to the @code{%fs} or @code{%gs} segments.
1577 @table @code
1578 @item __seg_fs
1579 @itemx __seg_gs
1580 @cindex @code{__seg_fs} x86 named address space
1581 @cindex @code{__seg_gs} x86 named address space
1582 The object is accessed with the respective segment override prefix.
1584 The respective segment base must be set via some method specific to
1585 the operating system.  Rather than require an expensive system call
1586 to retrieve the segment base, these address spaces are not considered
1587 to be subspaces of the generic (flat) address space.  This means that
1588 explicit casts are required to convert pointers between these address
1589 spaces and the generic address space.  In practice the application
1590 should cast to @code{uintptr_t} and apply the segment base offset
1591 that it installed previously.
1593 The preprocessor symbols @code{__SEG_FS} and @code{__SEG_GS} are
1594 defined when these address spaces are supported.
1595 @end table
1597 @node Zero Length
1598 @section Arrays of Length Zero
1599 @cindex arrays of length zero
1600 @cindex zero-length arrays
1601 @cindex length-zero arrays
1602 @cindex flexible array members
1604 Declaring zero-length arrays is allowed in GNU C as an extension.
1605 A zero-length array can be useful as the last element of a structure
1606 that is really a header for a variable-length object:
1608 @smallexample
1609 struct line @{
1610   int length;
1611   char contents[0];
1614 struct line *thisline = (struct line *)
1615   malloc (sizeof (struct line) + this_length);
1616 thisline->length = this_length;
1617 @end smallexample
1619 Although the size of a zero-length array is zero, an array member of
1620 this kind may increase the size of the enclosing type as a result of tail
1621 padding.  The offset of a zero-length array member from the beginning
1622 of the enclosing structure is the same as the offset of an array with
1623 one or more elements of the same type.  The alignment of a zero-length
1624 array is the same as the alignment of its elements.
1626 Declaring zero-length arrays in other contexts, including as interior
1627 members of structure objects or as non-member objects, is discouraged.
1628 Accessing elements of zero-length arrays declared in such contexts is
1629 undefined and may be diagnosed.
1631 In the absence of the zero-length array extension, in ISO C90
1632 the @code{contents} array in the example above would typically be declared
1633 to have a single element.  Unlike a zero-length array which only contributes
1634 to the size of the enclosing structure for the purposes of alignment,
1635 a one-element array always occupies at least as much space as a single
1636 object of the type.  Although using one-element arrays this way is
1637 discouraged, GCC handles accesses to trailing one-element array members
1638 analogously to zero-length arrays.
1640 The preferred mechanism to declare variable-length types like
1641 @code{struct line} above is the ISO C99 @dfn{flexible array member},
1642 with slightly different syntax and semantics:
1644 @itemize @bullet
1645 @item
1646 Flexible array members are written as @code{contents[]} without
1647 the @code{0}.
1649 @item
1650 Flexible array members have incomplete type, and so the @code{sizeof}
1651 operator may not be applied.  As a quirk of the original implementation
1652 of zero-length arrays, @code{sizeof} evaluates to zero.
1654 @item
1655 Flexible array members may only appear as the last member of a
1656 @code{struct} that is otherwise non-empty.
1658 @item
1659 A structure containing a flexible array member, or a union containing
1660 such a structure (possibly recursively), may not be a member of a
1661 structure or an element of an array.  (However, these uses are
1662 permitted by GCC as extensions.)
1663 @end itemize
1665 Non-empty initialization of zero-length
1666 arrays is treated like any case where there are more initializer
1667 elements than the array holds, in that a suitable warning about ``excess
1668 elements in array'' is given, and the excess elements (all of them, in
1669 this case) are ignored.
1671 GCC allows static initialization of flexible array members.
1672 This is equivalent to defining a new structure containing the original
1673 structure followed by an array of sufficient size to contain the data.
1674 E.g.@: in the following, @code{f1} is constructed as if it were declared
1675 like @code{f2}.
1677 @smallexample
1678 struct f1 @{
1679   int x; int y[];
1680 @} f1 = @{ 1, @{ 2, 3, 4 @} @};
1682 struct f2 @{
1683   struct f1 f1; int data[3];
1684 @} f2 = @{ @{ 1 @}, @{ 2, 3, 4 @} @};
1685 @end smallexample
1687 @noindent
1688 The convenience of this extension is that @code{f1} has the desired
1689 type, eliminating the need to consistently refer to @code{f2.f1}.
1691 This has symmetry with normal static arrays, in that an array of
1692 unknown size is also written with @code{[]}.
1694 Of course, this extension only makes sense if the extra data comes at
1695 the end of a top-level object, as otherwise we would be overwriting
1696 data at subsequent offsets.  To avoid undue complication and confusion
1697 with initialization of deeply nested arrays, we simply disallow any
1698 non-empty initialization except when the structure is the top-level
1699 object.  For example:
1701 @smallexample
1702 struct foo @{ int x; int y[]; @};
1703 struct bar @{ struct foo z; @};
1705 struct foo a = @{ 1, @{ 2, 3, 4 @} @};        // @r{Valid.}
1706 struct bar b = @{ @{ 1, @{ 2, 3, 4 @} @} @};    // @r{Invalid.}
1707 struct bar c = @{ @{ 1, @{ @} @} @};            // @r{Valid.}
1708 struct foo d[1] = @{ @{ 1, @{ 2, 3, 4 @} @} @};  // @r{Invalid.}
1709 @end smallexample
1711 @node Empty Structures
1712 @section Structures with No Members
1713 @cindex empty structures
1714 @cindex zero-size structures
1716 GCC permits a C structure to have no members:
1718 @smallexample
1719 struct empty @{
1721 @end smallexample
1723 The structure has size zero.  In C++, empty structures are part
1724 of the language.  G++ treats empty structures as if they had a single
1725 member of type @code{char}.
1727 @node Variable Length
1728 @section Arrays of Variable Length
1729 @cindex variable-length arrays
1730 @cindex arrays of variable length
1731 @cindex VLAs
1733 Variable-length automatic arrays are allowed in ISO C99, and as an
1734 extension GCC accepts them in C90 mode and in C++.  These arrays are
1735 declared like any other automatic arrays, but with a length that is not
1736 a constant expression.  The storage is allocated at the point of
1737 declaration and deallocated when the block scope containing the declaration
1738 exits.  For
1739 example:
1741 @smallexample
1742 FILE *
1743 concat_fopen (char *s1, char *s2, char *mode)
1745   char str[strlen (s1) + strlen (s2) + 1];
1746   strcpy (str, s1);
1747   strcat (str, s2);
1748   return fopen (str, mode);
1750 @end smallexample
1752 @cindex scope of a variable length array
1753 @cindex variable-length array scope
1754 @cindex deallocating variable length arrays
1755 Jumping or breaking out of the scope of the array name deallocates the
1756 storage.  Jumping into the scope is not allowed; you get an error
1757 message for it.
1759 @cindex variable-length array in a structure
1760 As an extension, GCC accepts variable-length arrays as a member of
1761 a structure or a union.  For example:
1763 @smallexample
1764 void
1765 foo (int n)
1767   struct S @{ int x[n]; @};
1769 @end smallexample
1771 @cindex @code{alloca} vs variable-length arrays
1772 You can use the function @code{alloca} to get an effect much like
1773 variable-length arrays.  The function @code{alloca} is available in
1774 many other C implementations (but not in all).  On the other hand,
1775 variable-length arrays are more elegant.
1777 There are other differences between these two methods.  Space allocated
1778 with @code{alloca} exists until the containing @emph{function} returns.
1779 The space for a variable-length array is deallocated as soon as the array
1780 name's scope ends, unless you also use @code{alloca} in this scope.
1782 You can also use variable-length arrays as arguments to functions:
1784 @smallexample
1785 struct entry
1786 tester (int len, char data[len][len])
1788   /* @r{@dots{}} */
1790 @end smallexample
1792 The length of an array is computed once when the storage is allocated
1793 and is remembered for the scope of the array in case you access it with
1794 @code{sizeof}.
1796 If you want to pass the array first and the length afterward, you can
1797 use a forward declaration in the parameter list---another GNU extension.
1799 @smallexample
1800 struct entry
1801 tester (int len; char data[len][len], int len)
1803   /* @r{@dots{}} */
1805 @end smallexample
1807 @cindex parameter forward declaration
1808 The @samp{int len} before the semicolon is a @dfn{parameter forward
1809 declaration}, and it serves the purpose of making the name @code{len}
1810 known when the declaration of @code{data} is parsed.
1812 You can write any number of such parameter forward declarations in the
1813 parameter list.  They can be separated by commas or semicolons, but the
1814 last one must end with a semicolon, which is followed by the ``real''
1815 parameter declarations.  Each forward declaration must match a ``real''
1816 declaration in parameter name and data type.  ISO C99 does not support
1817 parameter forward declarations.
1819 @node Variadic Macros
1820 @section Macros with a Variable Number of Arguments.
1821 @cindex variable number of arguments
1822 @cindex macro with variable arguments
1823 @cindex rest argument (in macro)
1824 @cindex variadic macros
1826 In the ISO C standard of 1999, a macro can be declared to accept a
1827 variable number of arguments much as a function can.  The syntax for
1828 defining the macro is similar to that of a function.  Here is an
1829 example:
1831 @smallexample
1832 #define debug(format, ...) fprintf (stderr, format, __VA_ARGS__)
1833 @end smallexample
1835 @noindent
1836 Here @samp{@dots{}} is a @dfn{variable argument}.  In the invocation of
1837 such a macro, it represents the zero or more tokens until the closing
1838 parenthesis that ends the invocation, including any commas.  This set of
1839 tokens replaces the identifier @code{__VA_ARGS__} in the macro body
1840 wherever it appears.  See the CPP manual for more information.
1842 GCC has long supported variadic macros, and used a different syntax that
1843 allowed you to give a name to the variable arguments just like any other
1844 argument.  Here is an example:
1846 @smallexample
1847 #define debug(format, args...) fprintf (stderr, format, args)
1848 @end smallexample
1850 @noindent
1851 This is in all ways equivalent to the ISO C example above, but arguably
1852 more readable and descriptive.
1854 GNU CPP has two further variadic macro extensions, and permits them to
1855 be used with either of the above forms of macro definition.
1857 In standard C, you are not allowed to leave the variable argument out
1858 entirely; but you are allowed to pass an empty argument.  For example,
1859 this invocation is invalid in ISO C, because there is no comma after
1860 the string:
1862 @smallexample
1863 debug ("A message")
1864 @end smallexample
1866 GNU CPP permits you to completely omit the variable arguments in this
1867 way.  In the above examples, the compiler would complain, though since
1868 the expansion of the macro still has the extra comma after the format
1869 string.
1871 To help solve this problem, CPP behaves specially for variable arguments
1872 used with the token paste operator, @samp{##}.  If instead you write
1874 @smallexample
1875 #define debug(format, ...) fprintf (stderr, format, ## __VA_ARGS__)
1876 @end smallexample
1878 @noindent
1879 and if the variable arguments are omitted or empty, the @samp{##}
1880 operator causes the preprocessor to remove the comma before it.  If you
1881 do provide some variable arguments in your macro invocation, GNU CPP
1882 does not complain about the paste operation and instead places the
1883 variable arguments after the comma.  Just like any other pasted macro
1884 argument, these arguments are not macro expanded.
1886 @node Escaped Newlines
1887 @section Slightly Looser Rules for Escaped Newlines
1888 @cindex escaped newlines
1889 @cindex newlines (escaped)
1891 The preprocessor treatment of escaped newlines is more relaxed 
1892 than that specified by the C90 standard, which requires the newline
1893 to immediately follow a backslash.  
1894 GCC's implementation allows whitespace in the form
1895 of spaces, horizontal and vertical tabs, and form feeds between the
1896 backslash and the subsequent newline.  The preprocessor issues a
1897 warning, but treats it as a valid escaped newline and combines the two
1898 lines to form a single logical line.  This works within comments and
1899 tokens, as well as between tokens.  Comments are @emph{not} treated as
1900 whitespace for the purposes of this relaxation, since they have not
1901 yet been replaced with spaces.
1903 @node Subscripting
1904 @section Non-Lvalue Arrays May Have Subscripts
1905 @cindex subscripting
1906 @cindex arrays, non-lvalue
1908 @cindex subscripting and function values
1909 In ISO C99, arrays that are not lvalues still decay to pointers, and
1910 may be subscripted, although they may not be modified or used after
1911 the next sequence point and the unary @samp{&} operator may not be
1912 applied to them.  As an extension, GNU C allows such arrays to be
1913 subscripted in C90 mode, though otherwise they do not decay to
1914 pointers outside C99 mode.  For example,
1915 this is valid in GNU C though not valid in C90:
1917 @smallexample
1918 @group
1919 struct foo @{int a[4];@};
1921 struct foo f();
1923 bar (int index)
1925   return f().a[index];
1927 @end group
1928 @end smallexample
1930 @node Pointer Arith
1931 @section Arithmetic on @code{void}- and Function-Pointers
1932 @cindex void pointers, arithmetic
1933 @cindex void, size of pointer to
1934 @cindex function pointers, arithmetic
1935 @cindex function, size of pointer to
1937 In GNU C, addition and subtraction operations are supported on pointers to
1938 @code{void} and on pointers to functions.  This is done by treating the
1939 size of a @code{void} or of a function as 1.
1941 A consequence of this is that @code{sizeof} is also allowed on @code{void}
1942 and on function types, and returns 1.
1944 @opindex Wpointer-arith
1945 The option @option{-Wpointer-arith} requests a warning if these extensions
1946 are used.
1948 @node Variadic Pointer Args
1949 @section Pointer Arguments in Variadic Functions
1950 @cindex pointer arguments in variadic functions
1951 @cindex variadic functions, pointer arguments
1953 Standard C requires that pointer types used with @code{va_arg} in
1954 functions with variable argument lists either must be compatible with
1955 that of the actual argument, or that one type must be a pointer to
1956 @code{void} and the other a pointer to a character type.  GNU C
1957 implements the POSIX XSI extension that additionally permits the use
1958 of @code{va_arg} with a pointer type to receive arguments of any other
1959 pointer type.
1961 In particular, in GNU C @samp{va_arg (ap, void *)} can safely be used
1962 to consume an argument of any pointer type.
1964 @node Pointers to Arrays
1965 @section Pointers to Arrays with Qualifiers Work as Expected
1966 @cindex pointers to arrays
1967 @cindex const qualifier
1969 In GNU C, pointers to arrays with qualifiers work similar to pointers
1970 to other qualified types. For example, a value of type @code{int (*)[5]}
1971 can be used to initialize a variable of type @code{const int (*)[5]}.
1972 These types are incompatible in ISO C because the @code{const} qualifier
1973 is formally attached to the element type of the array and not the
1974 array itself.
1976 @smallexample
1977 extern void
1978 transpose (int N, int M, double out[M][N], const double in[N][M]);
1979 double x[3][2];
1980 double y[2][3];
1981 @r{@dots{}}
1982 transpose(3, 2, y, x);
1983 @end smallexample
1985 @node Initializers
1986 @section Non-Constant Initializers
1987 @cindex initializers, non-constant
1988 @cindex non-constant initializers
1990 As in standard C++ and ISO C99, the elements of an aggregate initializer for an
1991 automatic variable are not required to be constant expressions in GNU C@.
1992 Here is an example of an initializer with run-time varying elements:
1994 @smallexample
1995 foo (float f, float g)
1997   float beat_freqs[2] = @{ f-g, f+g @};
1998   /* @r{@dots{}} */
2000 @end smallexample
2002 @node Compound Literals
2003 @section Compound Literals
2004 @cindex constructor expressions
2005 @cindex initializations in expressions
2006 @cindex structures, constructor expression
2007 @cindex expressions, constructor
2008 @cindex compound literals
2009 @c The GNU C name for what C99 calls compound literals was "constructor expressions".
2011 A compound literal looks like a cast of a brace-enclosed aggregate
2012 initializer list.  Its value is an object of the type specified in
2013 the cast, containing the elements specified in the initializer.
2014 Unlike the result of a cast, a compound literal is an lvalue.  ISO
2015 C99 and later support compound literals.  As an extension, GCC
2016 supports compound literals also in C90 mode and in C++, although
2017 as explained below, the C++ semantics are somewhat different.
2019 Usually, the specified type of a compound literal is a structure.  Assume
2020 that @code{struct foo} and @code{structure} are declared as shown:
2022 @smallexample
2023 struct foo @{int a; char b[2];@} structure;
2024 @end smallexample
2026 @noindent
2027 Here is an example of constructing a @code{struct foo} with a compound literal:
2029 @smallexample
2030 structure = ((struct foo) @{x + y, 'a', 0@});
2031 @end smallexample
2033 @noindent
2034 This is equivalent to writing the following:
2036 @smallexample
2038   struct foo temp = @{x + y, 'a', 0@};
2039   structure = temp;
2041 @end smallexample
2043 You can also construct an array, though this is dangerous in C++, as
2044 explained below.  If all the elements of the compound literal are
2045 (made up of) simple constant expressions suitable for use in
2046 initializers of objects of static storage duration, then the compound
2047 literal can be coerced to a pointer to its first element and used in
2048 such an initializer, as shown here:
2050 @smallexample
2051 char **foo = (char *[]) @{ "x", "y", "z" @};
2052 @end smallexample
2054 Compound literals for scalar types and union types are also allowed.  In
2055 the following example the variable @code{i} is initialized to the value
2056 @code{2}, the result of incrementing the unnamed object created by
2057 the compound literal.
2059 @smallexample
2060 int i = ++(int) @{ 1 @};
2061 @end smallexample
2063 As a GNU extension, GCC allows initialization of objects with static storage
2064 duration by compound literals (which is not possible in ISO C99 because
2065 the initializer is not a constant).
2066 It is handled as if the object were initialized only with the brace-enclosed
2067 list if the types of the compound literal and the object match.
2068 The elements of the compound literal must be constant.
2069 If the object being initialized has array type of unknown size, the size is
2070 determined by the size of the compound literal.
2072 @smallexample
2073 static struct foo x = (struct foo) @{1, 'a', 'b'@};
2074 static int y[] = (int []) @{1, 2, 3@};
2075 static int z[] = (int [3]) @{1@};
2076 @end smallexample
2078 @noindent
2079 The above lines are equivalent to the following:
2080 @smallexample
2081 static struct foo x = @{1, 'a', 'b'@};
2082 static int y[] = @{1, 2, 3@};
2083 static int z[] = @{1, 0, 0@};
2084 @end smallexample
2086 In C, a compound literal designates an unnamed object with static or
2087 automatic storage duration.  In C++, a compound literal designates a
2088 temporary object that only lives until the end of its full-expression.
2089 As a result, well-defined C code that takes the address of a subobject
2090 of a compound literal can be undefined in C++, so G++ rejects
2091 the conversion of a temporary array to a pointer.  For instance, if
2092 the array compound literal example above appeared inside a function,
2093 any subsequent use of @code{foo} in C++ would have undefined behavior
2094 because the lifetime of the array ends after the declaration of @code{foo}.
2096 As an optimization, G++ sometimes gives array compound literals longer
2097 lifetimes: when the array either appears outside a function or has
2098 a @code{const}-qualified type.  If @code{foo} and its initializer had
2099 elements of type @code{char *const} rather than @code{char *}, or if
2100 @code{foo} were a global variable, the array would have static storage
2101 duration.  But it is probably safest just to avoid the use of array
2102 compound literals in C++ code.
2104 @node Designated Inits
2105 @section Designated Initializers
2106 @cindex initializers with labeled elements
2107 @cindex labeled elements in initializers
2108 @cindex case labels in initializers
2109 @cindex designated initializers
2111 Standard C90 requires the elements of an initializer to appear in a fixed
2112 order, the same as the order of the elements in the array or structure
2113 being initialized.
2115 In ISO C99 you can give the elements in any order, specifying the array
2116 indices or structure field names they apply to, and GNU C allows this as
2117 an extension in C90 mode as well.  This extension is not
2118 implemented in GNU C++.
2120 To specify an array index, write
2121 @samp{[@var{index}] =} before the element value.  For example,
2123 @smallexample
2124 int a[6] = @{ [4] = 29, [2] = 15 @};
2125 @end smallexample
2127 @noindent
2128 is equivalent to
2130 @smallexample
2131 int a[6] = @{ 0, 0, 15, 0, 29, 0 @};
2132 @end smallexample
2134 @noindent
2135 The index values must be constant expressions, even if the array being
2136 initialized is automatic.
2138 An alternative syntax for this that has been obsolete since GCC 2.5 but
2139 GCC still accepts is to write @samp{[@var{index}]} before the element
2140 value, with no @samp{=}.
2142 To initialize a range of elements to the same value, write
2143 @samp{[@var{first} ... @var{last}] = @var{value}}.  This is a GNU
2144 extension.  For example,
2146 @smallexample
2147 int widths[] = @{ [0 ... 9] = 1, [10 ... 99] = 2, [100] = 3 @};
2148 @end smallexample
2150 @noindent
2151 If the value in it has side effects, the side effects happen only once,
2152 not for each initialized field by the range initializer.
2154 @noindent
2155 Note that the length of the array is the highest value specified
2156 plus one.
2158 In a structure initializer, specify the name of a field to initialize
2159 with @samp{.@var{fieldname} =} before the element value.  For example,
2160 given the following structure,
2162 @smallexample
2163 struct point @{ int x, y; @};
2164 @end smallexample
2166 @noindent
2167 the following initialization
2169 @smallexample
2170 struct point p = @{ .y = yvalue, .x = xvalue @};
2171 @end smallexample
2173 @noindent
2174 is equivalent to
2176 @smallexample
2177 struct point p = @{ xvalue, yvalue @};
2178 @end smallexample
2180 Another syntax that has the same meaning, obsolete since GCC 2.5, is
2181 @samp{@var{fieldname}:}, as shown here:
2183 @smallexample
2184 struct point p = @{ y: yvalue, x: xvalue @};
2185 @end smallexample
2187 Omitted fields are implicitly initialized the same as for objects
2188 that have static storage duration.
2190 @cindex designators
2191 The @samp{[@var{index}]} or @samp{.@var{fieldname}} is known as a
2192 @dfn{designator}.  You can also use a designator (or the obsolete colon
2193 syntax) when initializing a union, to specify which element of the union
2194 should be used.  For example,
2196 @smallexample
2197 union foo @{ int i; double d; @};
2199 union foo f = @{ .d = 4 @};
2200 @end smallexample
2202 @noindent
2203 converts 4 to a @code{double} to store it in the union using
2204 the second element.  By contrast, casting 4 to type @code{union foo}
2205 stores it into the union as the integer @code{i}, since it is
2206 an integer.  @xref{Cast to Union}.
2208 You can combine this technique of naming elements with ordinary C
2209 initialization of successive elements.  Each initializer element that
2210 does not have a designator applies to the next consecutive element of the
2211 array or structure.  For example,
2213 @smallexample
2214 int a[6] = @{ [1] = v1, v2, [4] = v4 @};
2215 @end smallexample
2217 @noindent
2218 is equivalent to
2220 @smallexample
2221 int a[6] = @{ 0, v1, v2, 0, v4, 0 @};
2222 @end smallexample
2224 Labeling the elements of an array initializer is especially useful
2225 when the indices are characters or belong to an @code{enum} type.
2226 For example:
2228 @smallexample
2229 int whitespace[256]
2230   = @{ [' '] = 1, ['\t'] = 1, ['\h'] = 1,
2231       ['\f'] = 1, ['\n'] = 1, ['\r'] = 1 @};
2232 @end smallexample
2234 @cindex designator lists
2235 You can also write a series of @samp{.@var{fieldname}} and
2236 @samp{[@var{index}]} designators before an @samp{=} to specify a
2237 nested subobject to initialize; the list is taken relative to the
2238 subobject corresponding to the closest surrounding brace pair.  For
2239 example, with the @samp{struct point} declaration above:
2241 @smallexample
2242 struct point ptarray[10] = @{ [2].y = yv2, [2].x = xv2, [0].x = xv0 @};
2243 @end smallexample
2245 If the same field is initialized multiple times, or overlapping
2246 fields of a union are initialized, the value from the last
2247 initialization is used.  When a field of a union is itself a structure, 
2248 the entire structure from the last field initialized is used.  If any previous
2249 initializer has side effect, it is unspecified whether the side effect
2250 happens or not.  Currently, GCC discards the side-effecting
2251 initializer expressions and issues a warning.
2253 @node Case Ranges
2254 @section Case Ranges
2255 @cindex case ranges
2256 @cindex ranges in case statements
2258 You can specify a range of consecutive values in a single @code{case} label,
2259 like this:
2261 @smallexample
2262 case @var{low} ... @var{high}:
2263 @end smallexample
2265 @noindent
2266 This has the same effect as the proper number of individual @code{case}
2267 labels, one for each integer value from @var{low} to @var{high}, inclusive.
2269 This feature is especially useful for ranges of ASCII character codes:
2271 @smallexample
2272 case 'A' ... 'Z':
2273 @end smallexample
2275 @strong{Be careful:} Write spaces around the @code{...}, for otherwise
2276 it may be parsed wrong when you use it with integer values.  For example,
2277 write this:
2279 @smallexample
2280 case 1 ... 5:
2281 @end smallexample
2283 @noindent
2284 rather than this:
2286 @smallexample
2287 case 1...5:
2288 @end smallexample
2290 @node Cast to Union
2291 @section Cast to a Union Type
2292 @cindex cast to a union
2293 @cindex union, casting to a
2295 A cast to a union type is a C extension not available in C++.  It looks
2296 just like ordinary casts with the constraint that the type specified is
2297 a union type.  You can specify the type either with the @code{union}
2298 keyword or with a @code{typedef} name that refers to a union.  The result
2299 of a cast to a union is a temporary rvalue of the union type with a member
2300 whose type matches that of the operand initialized to the value of
2301 the operand.  The effect of a cast to a union is similar to a compound
2302 literal except that it yields an rvalue like standard casts do.
2303 @xref{Compound Literals}.
2305 Expressions that may be cast to the union type are those whose type matches
2306 at least one of the members of the union.  Thus, given the following union
2307 and variables:
2309 @smallexample
2310 union foo @{ int i; double d; @};
2311 int x;
2312 double y;
2313 union foo z;
2314 @end smallexample
2316 @noindent
2317 both @code{x} and @code{y} can be cast to type @code{union foo} and
2318 the following assignments
2319 @smallexample
2320   z = (union foo) x;
2321   z = (union foo) y;
2322 @end smallexample
2323 are shorthand equivalents of these
2324 @smallexample
2325   z = (union foo) @{ .i = x @};
2326   z = (union foo) @{ .d = y @};
2327 @end smallexample
2329 However, @code{(union foo) FLT_MAX;} is not a valid cast because the union
2330 has no member of type @code{float}.
2332 Using the cast as the right-hand side of an assignment to a variable of
2333 union type is equivalent to storing in a member of the union with
2334 the same type
2336 @smallexample
2337 union foo u;
2338 /* @r{@dots{}} */
2339 u = (union foo) x  @equiv{}  u.i = x
2340 u = (union foo) y  @equiv{}  u.d = y
2341 @end smallexample
2343 You can also use the union cast as a function argument:
2345 @smallexample
2346 void hack (union foo);
2347 /* @r{@dots{}} */
2348 hack ((union foo) x);
2349 @end smallexample
2351 @node Mixed Declarations
2352 @section Mixed Declarations and Code
2353 @cindex mixed declarations and code
2354 @cindex declarations, mixed with code
2355 @cindex code, mixed with declarations
2357 ISO C99 and ISO C++ allow declarations and code to be freely mixed
2358 within compound statements.  As an extension, GNU C also allows this in
2359 C90 mode.  For example, you could do:
2361 @smallexample
2362 int i;
2363 /* @r{@dots{}} */
2364 i++;
2365 int j = i + 2;
2366 @end smallexample
2368 Each identifier is visible from where it is declared until the end of
2369 the enclosing block.
2371 @node Function Attributes
2372 @section Declaring Attributes of Functions
2373 @cindex function attributes
2374 @cindex declaring attributes of functions
2375 @cindex @code{volatile} applied to function
2376 @cindex @code{const} applied to function
2378 In GNU C and C++, you can use function attributes to specify certain
2379 function properties that may help the compiler optimize calls or
2380 check code more carefully for correctness.  For example, you
2381 can use attributes to specify that a function never returns
2382 (@code{noreturn}), returns a value depending only on the values of
2383 its arguments (@code{const}), or has @code{printf}-style arguments
2384 (@code{format}).
2386 You can also use attributes to control memory placement, code
2387 generation options or call/return conventions within the function
2388 being annotated.  Many of these attributes are target-specific.  For
2389 example, many targets support attributes for defining interrupt
2390 handler functions, which typically must follow special register usage
2391 and return conventions.  Such attributes are described in the subsection
2392 for each target.  However, a considerable number of attributes are
2393 supported by most, if not all targets.  Those are described in
2394 the @ref{Common Function Attributes} section.
2396 Function attributes are introduced by the @code{__attribute__} keyword
2397 in the declaration of a function, followed by an attribute specification
2398 enclosed in double parentheses.  You can specify multiple attributes in
2399 a declaration by separating them by commas within the double parentheses
2400 or by immediately following one attribute specification with another.
2401 @xref{Attribute Syntax}, for the exact rules on attribute syntax and
2402 placement.  Compatible attribute specifications on distinct declarations
2403 of the same function are merged.  An attribute specification that is not
2404 compatible with attributes already applied to a declaration of the same
2405 function is ignored with a warning.
2407 Some function attributes take one or more arguments that refer to
2408 the function's parameters by their positions within the function parameter
2409 list.  Such attribute arguments are referred to as @dfn{positional arguments}.
2410 Unless specified otherwise, positional arguments that specify properties
2411 of parameters with pointer types can also specify the same properties of
2412 the implicit C++ @code{this} argument in non-static member functions, and
2413 of parameters of reference to a pointer type.  For ordinary functions,
2414 position one refers to the first parameter on the list.  In C++ non-static
2415 member functions, position one refers to the implicit @code{this} pointer.
2416 The same restrictions and effects apply to function attributes used with
2417 ordinary functions or C++ member functions.
2419 GCC also supports attributes on
2420 variable declarations (@pxref{Variable Attributes}),
2421 labels (@pxref{Label Attributes}),
2422 enumerators (@pxref{Enumerator Attributes}),
2423 statements (@pxref{Statement Attributes}),
2424 and types (@pxref{Type Attributes}).
2426 There is some overlap between the purposes of attributes and pragmas
2427 (@pxref{Pragmas,,Pragmas Accepted by GCC}).  It has been
2428 found convenient to use @code{__attribute__} to achieve a natural
2429 attachment of attributes to their corresponding declarations, whereas
2430 @code{#pragma} is of use for compatibility with other compilers
2431 or constructs that do not naturally form part of the grammar.
2433 In addition to the attributes documented here,
2434 GCC plugins may provide their own attributes.
2436 @menu
2437 * Common Function Attributes::
2438 * AArch64 Function Attributes::
2439 * AMD GCN Function Attributes::
2440 * ARC Function Attributes::
2441 * ARM Function Attributes::
2442 * AVR Function Attributes::
2443 * Blackfin Function Attributes::
2444 * CR16 Function Attributes::
2445 * C-SKY Function Attributes::
2446 * Epiphany Function Attributes::
2447 * H8/300 Function Attributes::
2448 * IA-64 Function Attributes::
2449 * M32C Function Attributes::
2450 * M32R/D Function Attributes::
2451 * m68k Function Attributes::
2452 * MCORE Function Attributes::
2453 * MeP Function Attributes::
2454 * MicroBlaze Function Attributes::
2455 * Microsoft Windows Function Attributes::
2456 * MIPS Function Attributes::
2457 * MSP430 Function Attributes::
2458 * NDS32 Function Attributes::
2459 * Nios II Function Attributes::
2460 * Nvidia PTX Function Attributes::
2461 * PowerPC Function Attributes::
2462 * RISC-V Function Attributes::
2463 * RL78 Function Attributes::
2464 * RX Function Attributes::
2465 * S/390 Function Attributes::
2466 * SH Function Attributes::
2467 * SPU Function Attributes::
2468 * Symbian OS Function Attributes::
2469 * V850 Function Attributes::
2470 * Visium Function Attributes::
2471 * x86 Function Attributes::
2472 * Xstormy16 Function Attributes::
2473 @end menu
2475 @node Common Function Attributes
2476 @subsection Common Function Attributes
2478 The following attributes are supported on most targets.
2480 @table @code
2481 @c Keep this table alphabetized by attribute name.  Treat _ as space.
2483 @item alias ("@var{target}")
2484 @cindex @code{alias} function attribute
2485 The @code{alias} attribute causes the declaration to be emitted as an
2486 alias for another symbol, which must be specified.  For instance,
2488 @smallexample
2489 void __f () @{ /* @r{Do something.} */; @}
2490 void f () __attribute__ ((weak, alias ("__f")));
2491 @end smallexample
2493 @noindent
2494 defines @samp{f} to be a weak alias for @samp{__f}.  In C++, the
2495 mangled name for the target must be used.  It is an error if @samp{__f}
2496 is not defined in the same translation unit.
2498 This attribute requires assembler and object file support,
2499 and may not be available on all targets.
2501 @item aligned
2502 @itemx aligned (@var{alignment})
2503 @cindex @code{aligned} function attribute
2504 The @code{aligned} attribute specifies a minimum alignment for
2505 the first instruction of the function, measured in bytes.  When specified,
2506 @var{alignment} must be an integer constant power of 2.  Specifying no
2507 @var{alignment} argument implies the ideal alignment for the target.
2508 The @code{__alignof__} operator can be used to determine what that is
2509 (@pxref{Alignment}).  The attribute has no effect when a definition for
2510 the function is not provided in the same translation unit.
2512 The attribute cannot be used to decrease the alignment of a function
2513 previously declared with a more restrictive alignment; only to increase
2514 it.  Attempts to do otherwise are diagnosed.  Some targets specify
2515 a minimum default alignment for functions that is greater than 1.  On
2516 such targets, specifying a less restrictive alignment is silently ignored.
2517 Using the attribute overrides the effect of the @option{-falign-functions}
2518 (@pxref{Optimize Options}) option for this function.
2520 Note that the effectiveness of @code{aligned} attributes may be
2521 limited by inherent limitations in the system linker 
2522 and/or object file format.  On some systems, the
2523 linker is only able to arrange for functions to be aligned up to a
2524 certain maximum alignment.  (For some linkers, the maximum supported
2525 alignment may be very very small.)  See your linker documentation for
2526 further information.
2528 The @code{aligned} attribute can also be used for variables and fields
2529 (@pxref{Variable Attributes}.)
2531 @item alloc_align (@var{position})
2532 @cindex @code{alloc_align} function attribute
2533 The @code{alloc_align} attribute may be applied to a function that
2534 returns a pointer and takes at least one argument of an integer or
2535 enumerated type.
2536 It indicates that the returned pointer is aligned on a boundary given
2537 by the function argument at @var{position}.  Meaningful alignments are
2538 powers of 2 greater than one.  GCC uses this information to improve
2539 pointer alignment analysis.
2541 The function parameter denoting the allocated alignment is specified by
2542 one constant integer argument whose number is the argument of the attribute.
2543 Argument numbering starts at one.
2545 For instance,
2547 @smallexample
2548 void* my_memalign (size_t, size_t) __attribute__ ((alloc_align (1)));
2549 @end smallexample
2551 @noindent
2552 declares that @code{my_memalign} returns memory with minimum alignment
2553 given by parameter 1.
2555 @item alloc_size (@var{position})
2556 @itemx alloc_size (@var{position-1}, @var{position-2})
2557 @cindex @code{alloc_size} function attribute
2558 The @code{alloc_size} attribute may be applied to a function that
2559 returns a pointer and takes at least one argument of an integer or
2560 enumerated type.
2561 It indicates that the returned pointer points to memory whose size is
2562 given by the function argument at @var{position-1}, or by the product
2563 of the arguments at @var{position-1} and @var{position-2}.  Meaningful
2564 sizes are positive values less than @code{PTRDIFF_MAX}.  GCC uses this
2565 information to improve the results of @code{__builtin_object_size}.
2567 The function parameter(s) denoting the allocated size are specified by
2568 one or two integer arguments supplied to the attribute.  The allocated size
2569 is either the value of the single function argument specified or the product
2570 of the two function arguments specified.  Argument numbering starts at
2571 one for ordinary functions, and at two for C++ non-static member functions.
2573 For instance,
2575 @smallexample
2576 void* my_calloc (size_t, size_t) __attribute__ ((alloc_size (1, 2)));
2577 void* my_realloc (void*, size_t) __attribute__ ((alloc_size (2)));
2578 @end smallexample
2580 @noindent
2581 declares that @code{my_calloc} returns memory of the size given by
2582 the product of parameter 1 and 2 and that @code{my_realloc} returns memory
2583 of the size given by parameter 2.
2585 @item always_inline
2586 @cindex @code{always_inline} function attribute
2587 Generally, functions are not inlined unless optimization is specified.
2588 For functions declared inline, this attribute inlines the function
2589 independent of any restrictions that otherwise apply to inlining.
2590 Failure to inline such a function is diagnosed as an error.
2591 Note that if such a function is called indirectly the compiler may
2592 or may not inline it depending on optimization level and a failure
2593 to inline an indirect call may or may not be diagnosed.
2595 @item artificial
2596 @cindex @code{artificial} function attribute
2597 This attribute is useful for small inline wrappers that if possible
2598 should appear during debugging as a unit.  Depending on the debug
2599 info format it either means marking the function as artificial
2600 or using the caller location for all instructions within the inlined
2601 body.
2603 @item assume_aligned (@var{alignment})
2604 @itemx assume_aligned (@var{alignment}, @var{offset})
2605 @cindex @code{assume_aligned} function attribute
2606 The @code{assume_aligned} attribute may be applied to a function that
2607 returns a pointer.  It indicates that the returned pointer is aligned
2608 on a boundary given by @var{alignment}.  If the attribute has two
2609 arguments, the second argument is misalignment @var{offset}.  Meaningful
2610 values of @var{alignment} are powers of 2 greater than one.  Meaningful
2611 values of @var{offset} are greater than zero and less than @var{alignment}.
2613 For instance
2615 @smallexample
2616 void* my_alloc1 (size_t) __attribute__((assume_aligned (16)));
2617 void* my_alloc2 (size_t) __attribute__((assume_aligned (32, 8)));
2618 @end smallexample
2620 @noindent
2621 declares that @code{my_alloc1} returns 16-byte aligned pointers and
2622 that @code{my_alloc2} returns a pointer whose value modulo 32 is equal
2623 to 8.
2625 @item cold
2626 @cindex @code{cold} function attribute
2627 The @code{cold} attribute on functions is used to inform the compiler that
2628 the function is unlikely to be executed.  The function is optimized for
2629 size rather than speed and on many targets it is placed into a special
2630 subsection of the text section so all cold functions appear close together,
2631 improving code locality of non-cold parts of program.  The paths leading
2632 to calls of cold functions within code are marked as unlikely by the branch
2633 prediction mechanism.  It is thus useful to mark functions used to handle
2634 unlikely conditions, such as @code{perror}, as cold to improve optimization
2635 of hot functions that do call marked functions in rare occasions.
2637 When profile feedback is available, via @option{-fprofile-use}, cold functions
2638 are automatically detected and this attribute is ignored.
2640 @item const
2641 @cindex @code{const} function attribute
2642 @cindex functions that have no side effects
2643 Calls to functions whose return value is not affected by changes to
2644 the observable state of the program and that have no observable effects
2645 on such state other than to return a value may lend themselves to
2646 optimizations such as common subexpression elimination.  Declaring such
2647 functions with the @code{const} attribute allows GCC to avoid emitting
2648 some calls in repeated invocations of the function with the same argument
2649 values.
2651 For example,
2653 @smallexample
2654 int square (int) __attribute__ ((const));
2655 @end smallexample
2657 @noindent
2658 tells GCC that subsequent calls to function @code{square} with the same
2659 argument value can be replaced by the result of the first call regardless
2660 of the statements in between.
2662 The @code{const} attribute prohibits a function from reading objects
2663 that affect its return value between successive invocations.  However,
2664 functions declared with the attribute can safely read objects that do
2665 not change their return value, such as non-volatile constants.
2667 The @code{const} attribute imposes greater restrictions on a function's
2668 definition than the similar @code{pure} attribute.  Declaring the same
2669 function with both the @code{const} and the @code{pure} attribute is
2670 diagnosed.  Because a const function cannot have any observable side
2671 effects it does not make sense for it to return @code{void}.  Declaring
2672 such a function is diagnosed.
2674 @cindex pointer arguments
2675 Note that a function that has pointer arguments and examines the data
2676 pointed to must @emph{not} be declared @code{const} if the pointed-to
2677 data might change between successive invocations of the function.  In
2678 general, since a function cannot distinguish data that might change
2679 from data that cannot, const functions should never take pointer or,
2680 in C++, reference arguments. Likewise, a function that calls a non-const
2681 function usually must not be const itself.
2683 @item constructor
2684 @itemx destructor
2685 @itemx constructor (@var{priority})
2686 @itemx destructor (@var{priority})
2687 @cindex @code{constructor} function attribute
2688 @cindex @code{destructor} function attribute
2689 The @code{constructor} attribute causes the function to be called
2690 automatically before execution enters @code{main ()}.  Similarly, the
2691 @code{destructor} attribute causes the function to be called
2692 automatically after @code{main ()} completes or @code{exit ()} is
2693 called.  Functions with these attributes are useful for
2694 initializing data that is used implicitly during the execution of
2695 the program.
2697 On some targets the attributes also accept an integer argument to
2698 specify a priority to control the order in which constructor and
2699 destructor functions are run.  A constructor
2700 with a smaller priority number runs before a constructor with a larger
2701 priority number; the opposite relationship holds for destructors.  So,
2702 if you have a constructor that allocates a resource and a destructor
2703 that deallocates the same resource, both functions typically have the
2704 same priority.  The priorities for constructor and destructor
2705 functions are the same as those specified for namespace-scope C++
2706 objects (@pxref{C++ Attributes}).  However, at present, the order in which
2707 constructors for C++ objects with static storage duration and functions
2708 decorated with attribute @code{constructor} are invoked is unspecified.
2709 In mixed declarations, attribute @code{init_priority} can be used to
2710 impose a specific ordering.
2712 Using the argument forms of the @code{constructor} and @code{destructor}
2713 attributes on targets where the feature is not supported is rejected with
2714 an error.
2716 @item copy
2717 @itemx copy (@var{function})
2718 @cindex @code{copy} function attribute
2719 The @code{copy} attribute applies the set of attributes with which
2720 @var{function} has been declared to the declaration of the function
2721 to which the attribute is applied.  The attribute is designed for
2722 libraries that define aliases or function resolvers that are expected
2723 to specify the same set of attributes as their targets.  The @code{copy}
2724 attribute can be used with functions, variables, or types.  However,
2725 the kind of symbol to which the attribute is applied (either function
2726 or variable) must match the kind of symbol to which the argument refers.
2727 The @code{copy} attribute copies only syntactic and semantic attributes
2728 but not attributes that affect a symbol's linkage or visibility such as
2729 @code{alias}, @code{visibility}, or @code{weak}.  The @code{deprecated}
2730 attribute is also not copied.  @xref{Common Type Attributes}.
2731 @xref{Common Variable Attributes}.
2733 For example, the @var{StrongAlias} macro below makes use of the @code{alias}
2734 and @code{copy} attributes to define an alias named @var{alloc} for function
2735 @var{allocate} declared with attributes @var{alloc_size}, @var{malloc}, and
2736 @var{nothrow}.  Thanks to the @code{__typeof__} operator the alias has
2737 the same type as the target function.  As a result of the @code{copy}
2738 attribute the alias also shares the same attributes as the target.
2740 @smallexample
2741 #define StrongAlias(TagetFunc, AliasDecl)   \
2742   extern __typeof__ (TargetFunc) AliasDecl  \
2743     __attribute__ ((alias (#TargetFunc), copy (TargetFunc)));
2745 extern __attribute__ ((alloc_size (1), malloc, nothrow))
2746   void* allocate (size_t);
2747 StrongAlias (allocate, alloc);
2748 @end smallexample
2750 @item deprecated
2751 @itemx deprecated (@var{msg})
2752 @cindex @code{deprecated} function attribute
2753 The @code{deprecated} attribute results in a warning if the function
2754 is used anywhere in the source file.  This is useful when identifying
2755 functions that are expected to be removed in a future version of a
2756 program.  The warning also includes the location of the declaration
2757 of the deprecated function, to enable users to easily find further
2758 information about why the function is deprecated, or what they should
2759 do instead.  Note that the warnings only occurs for uses:
2761 @smallexample
2762 int old_fn () __attribute__ ((deprecated));
2763 int old_fn ();
2764 int (*fn_ptr)() = old_fn;
2765 @end smallexample
2767 @noindent
2768 results in a warning on line 3 but not line 2.  The optional @var{msg}
2769 argument, which must be a string, is printed in the warning if
2770 present.
2772 The @code{deprecated} attribute can also be used for variables and
2773 types (@pxref{Variable Attributes}, @pxref{Type Attributes}.)
2775 The message attached to the attribute is affected by the setting of
2776 the @option{-fmessage-length} option.
2778 @item error ("@var{message}")
2779 @itemx warning ("@var{message}")
2780 @cindex @code{error} function attribute
2781 @cindex @code{warning} function attribute
2782 If the @code{error} or @code{warning} attribute 
2783 is used on a function declaration and a call to such a function
2784 is not eliminated through dead code elimination or other optimizations, 
2785 an error or warning (respectively) that includes @var{message} is diagnosed.  
2786 This is useful
2787 for compile-time checking, especially together with @code{__builtin_constant_p}
2788 and inline functions where checking the inline function arguments is not
2789 possible through @code{extern char [(condition) ? 1 : -1];} tricks.
2791 While it is possible to leave the function undefined and thus invoke
2792 a link failure (to define the function with
2793 a message in @code{.gnu.warning*} section),
2794 when using these attributes the problem is diagnosed
2795 earlier and with exact location of the call even in presence of inline
2796 functions or when not emitting debugging information.
2798 @item externally_visible
2799 @cindex @code{externally_visible} function attribute
2800 This attribute, attached to a global variable or function, nullifies
2801 the effect of the @option{-fwhole-program} command-line option, so the
2802 object remains visible outside the current compilation unit.
2804 If @option{-fwhole-program} is used together with @option{-flto} and 
2805 @command{gold} is used as the linker plugin, 
2806 @code{externally_visible} attributes are automatically added to functions 
2807 (not variable yet due to a current @command{gold} issue) 
2808 that are accessed outside of LTO objects according to resolution file
2809 produced by @command{gold}.
2810 For other linkers that cannot generate resolution file,
2811 explicit @code{externally_visible} attributes are still necessary.
2813 @item flatten
2814 @cindex @code{flatten} function attribute
2815 Generally, inlining into a function is limited.  For a function marked with
2816 this attribute, every call inside this function is inlined, if possible.
2817 Functions declared with attribute @code{noinline} and similar are not
2818 inlined.  Whether the function itself is considered for inlining depends
2819 on its size and the current inlining parameters.
2821 @item format (@var{archetype}, @var{string-index}, @var{first-to-check})
2822 @cindex @code{format} function attribute
2823 @cindex functions with @code{printf}, @code{scanf}, @code{strftime} or @code{strfmon} style arguments
2824 @opindex Wformat
2825 The @code{format} attribute specifies that a function takes @code{printf},
2826 @code{scanf}, @code{strftime} or @code{strfmon} style arguments that
2827 should be type-checked against a format string.  For example, the
2828 declaration:
2830 @smallexample
2831 extern int
2832 my_printf (void *my_object, const char *my_format, ...)
2833       __attribute__ ((format (printf, 2, 3)));
2834 @end smallexample
2836 @noindent
2837 causes the compiler to check the arguments in calls to @code{my_printf}
2838 for consistency with the @code{printf} style format string argument
2839 @code{my_format}.
2841 The parameter @var{archetype} determines how the format string is
2842 interpreted, and should be @code{printf}, @code{scanf}, @code{strftime},
2843 @code{gnu_printf}, @code{gnu_scanf}, @code{gnu_strftime} or
2844 @code{strfmon}.  (You can also use @code{__printf__},
2845 @code{__scanf__}, @code{__strftime__} or @code{__strfmon__}.)  On
2846 MinGW targets, @code{ms_printf}, @code{ms_scanf}, and
2847 @code{ms_strftime} are also present.
2848 @var{archetype} values such as @code{printf} refer to the formats accepted
2849 by the system's C runtime library,
2850 while values prefixed with @samp{gnu_} always refer
2851 to the formats accepted by the GNU C Library.  On Microsoft Windows
2852 targets, values prefixed with @samp{ms_} refer to the formats accepted by the
2853 @file{msvcrt.dll} library.
2854 The parameter @var{string-index}
2855 specifies which argument is the format string argument (starting
2856 from 1), while @var{first-to-check} is the number of the first
2857 argument to check against the format string.  For functions
2858 where the arguments are not available to be checked (such as
2859 @code{vprintf}), specify the third parameter as zero.  In this case the
2860 compiler only checks the format string for consistency.  For
2861 @code{strftime} formats, the third parameter is required to be zero.
2862 Since non-static C++ methods have an implicit @code{this} argument, the
2863 arguments of such methods should be counted from two, not one, when
2864 giving values for @var{string-index} and @var{first-to-check}.
2866 In the example above, the format string (@code{my_format}) is the second
2867 argument of the function @code{my_print}, and the arguments to check
2868 start with the third argument, so the correct parameters for the format
2869 attribute are 2 and 3.
2871 @opindex ffreestanding
2872 @opindex fno-builtin
2873 The @code{format} attribute allows you to identify your own functions
2874 that take format strings as arguments, so that GCC can check the
2875 calls to these functions for errors.  The compiler always (unless
2876 @option{-ffreestanding} or @option{-fno-builtin} is used) checks formats
2877 for the standard library functions @code{printf}, @code{fprintf},
2878 @code{sprintf}, @code{scanf}, @code{fscanf}, @code{sscanf}, @code{strftime},
2879 @code{vprintf}, @code{vfprintf} and @code{vsprintf} whenever such
2880 warnings are requested (using @option{-Wformat}), so there is no need to
2881 modify the header file @file{stdio.h}.  In C99 mode, the functions
2882 @code{snprintf}, @code{vsnprintf}, @code{vscanf}, @code{vfscanf} and
2883 @code{vsscanf} are also checked.  Except in strictly conforming C
2884 standard modes, the X/Open function @code{strfmon} is also checked as
2885 are @code{printf_unlocked} and @code{fprintf_unlocked}.
2886 @xref{C Dialect Options,,Options Controlling C Dialect}.
2888 For Objective-C dialects, @code{NSString} (or @code{__NSString__}) is
2889 recognized in the same context.  Declarations including these format attributes
2890 are parsed for correct syntax, however the result of checking of such format
2891 strings is not yet defined, and is not carried out by this version of the
2892 compiler.
2894 The target may also provide additional types of format checks.
2895 @xref{Target Format Checks,,Format Checks Specific to Particular
2896 Target Machines}.
2898 @item format_arg (@var{string-index})
2899 @cindex @code{format_arg} function attribute
2900 @opindex Wformat-nonliteral
2901 The @code{format_arg} attribute specifies that a function takes one or
2902 more format strings for a @code{printf}, @code{scanf}, @code{strftime} or
2903 @code{strfmon} style function and modifies it (for example, to translate
2904 it into another language), so the result can be passed to a
2905 @code{printf}, @code{scanf}, @code{strftime} or @code{strfmon} style
2906 function (with the remaining arguments to the format function the same
2907 as they would have been for the unmodified string).  Multiple
2908 @code{format_arg} attributes may be applied to the same function, each
2909 designating a distinct parameter as a format string.  For example, the
2910 declaration:
2912 @smallexample
2913 extern char *
2914 my_dgettext (char *my_domain, const char *my_format)
2915       __attribute__ ((format_arg (2)));
2916 @end smallexample
2918 @noindent
2919 causes the compiler to check the arguments in calls to a @code{printf},
2920 @code{scanf}, @code{strftime} or @code{strfmon} type function, whose
2921 format string argument is a call to the @code{my_dgettext} function, for
2922 consistency with the format string argument @code{my_format}.  If the
2923 @code{format_arg} attribute had not been specified, all the compiler
2924 could tell in such calls to format functions would be that the format
2925 string argument is not constant; this would generate a warning when
2926 @option{-Wformat-nonliteral} is used, but the calls could not be checked
2927 without the attribute.
2929 In calls to a function declared with more than one @code{format_arg}
2930 attribute, each with a distinct argument value, the corresponding
2931 actual function arguments are checked against all format strings
2932 designated by the attributes.  This capability is designed to support
2933 the GNU @code{ngettext} family of functions.
2935 The parameter @var{string-index} specifies which argument is the format
2936 string argument (starting from one).  Since non-static C++ methods have
2937 an implicit @code{this} argument, the arguments of such methods should
2938 be counted from two.
2940 The @code{format_arg} attribute allows you to identify your own
2941 functions that modify format strings, so that GCC can check the
2942 calls to @code{printf}, @code{scanf}, @code{strftime} or @code{strfmon}
2943 type function whose operands are a call to one of your own function.
2944 The compiler always treats @code{gettext}, @code{dgettext}, and
2945 @code{dcgettext} in this manner except when strict ISO C support is
2946 requested by @option{-ansi} or an appropriate @option{-std} option, or
2947 @option{-ffreestanding} or @option{-fno-builtin}
2948 is used.  @xref{C Dialect Options,,Options
2949 Controlling C Dialect}.
2951 For Objective-C dialects, the @code{format-arg} attribute may refer to an
2952 @code{NSString} reference for compatibility with the @code{format} attribute
2953 above.
2955 The target may also allow additional types in @code{format-arg} attributes.
2956 @xref{Target Format Checks,,Format Checks Specific to Particular
2957 Target Machines}.
2959 @item gnu_inline
2960 @cindex @code{gnu_inline} function attribute
2961 This attribute should be used with a function that is also declared
2962 with the @code{inline} keyword.  It directs GCC to treat the function
2963 as if it were defined in gnu90 mode even when compiling in C99 or
2964 gnu99 mode.
2966 If the function is declared @code{extern}, then this definition of the
2967 function is used only for inlining.  In no case is the function
2968 compiled as a standalone function, not even if you take its address
2969 explicitly.  Such an address becomes an external reference, as if you
2970 had only declared the function, and had not defined it.  This has
2971 almost the effect of a macro.  The way to use this is to put a
2972 function definition in a header file with this attribute, and put
2973 another copy of the function, without @code{extern}, in a library
2974 file.  The definition in the header file causes most calls to the
2975 function to be inlined.  If any uses of the function remain, they
2976 refer to the single copy in the library.  Note that the two
2977 definitions of the functions need not be precisely the same, although
2978 if they do not have the same effect your program may behave oddly.
2980 In C, if the function is neither @code{extern} nor @code{static}, then
2981 the function is compiled as a standalone function, as well as being
2982 inlined where possible.
2984 This is how GCC traditionally handled functions declared
2985 @code{inline}.  Since ISO C99 specifies a different semantics for
2986 @code{inline}, this function attribute is provided as a transition
2987 measure and as a useful feature in its own right.  This attribute is
2988 available in GCC 4.1.3 and later.  It is available if either of the
2989 preprocessor macros @code{__GNUC_GNU_INLINE__} or
2990 @code{__GNUC_STDC_INLINE__} are defined.  @xref{Inline,,An Inline
2991 Function is As Fast As a Macro}.
2993 In C++, this attribute does not depend on @code{extern} in any way,
2994 but it still requires the @code{inline} keyword to enable its special
2995 behavior.
2997 @item hot
2998 @cindex @code{hot} function attribute
2999 The @code{hot} attribute on a function is used to inform the compiler that
3000 the function is a hot spot of the compiled program.  The function is
3001 optimized more aggressively and on many targets it is placed into a special
3002 subsection of the text section so all hot functions appear close together,
3003 improving locality.
3005 When profile feedback is available, via @option{-fprofile-use}, hot functions
3006 are automatically detected and this attribute is ignored.
3008 @item ifunc ("@var{resolver}")
3009 @cindex @code{ifunc} function attribute
3010 @cindex indirect functions
3011 @cindex functions that are dynamically resolved
3012 The @code{ifunc} attribute is used to mark a function as an indirect
3013 function using the STT_GNU_IFUNC symbol type extension to the ELF
3014 standard.  This allows the resolution of the symbol value to be
3015 determined dynamically at load time, and an optimized version of the
3016 routine to be selected for the particular processor or other system
3017 characteristics determined then.  To use this attribute, first define
3018 the implementation functions available, and a resolver function that
3019 returns a pointer to the selected implementation function.  The
3020 implementation functions' declarations must match the API of the
3021 function being implemented.  The resolver should be declared to
3022 be a function taking no arguments and returning a pointer to
3023 a function of the same type as the implementation.  For example:
3025 @smallexample
3026 void *my_memcpy (void *dst, const void *src, size_t len)
3028   @dots{}
3029   return dst;
3032 static void * (*resolve_memcpy (void))(void *, const void *, size_t)
3034   return my_memcpy; // we will just always select this routine
3036 @end smallexample
3038 @noindent
3039 The exported header file declaring the function the user calls would
3040 contain:
3042 @smallexample
3043 extern void *memcpy (void *, const void *, size_t);
3044 @end smallexample
3046 @noindent
3047 allowing the user to call @code{memcpy} as a regular function, unaware of
3048 the actual implementation.  Finally, the indirect function needs to be
3049 defined in the same translation unit as the resolver function:
3051 @smallexample
3052 void *memcpy (void *, const void *, size_t)
3053      __attribute__ ((ifunc ("resolve_memcpy")));
3054 @end smallexample
3056 In C++, the @code{ifunc} attribute takes a string that is the mangled name
3057 of the resolver function.  A C++ resolver for a non-static member function
3058 of class @code{C} should be declared to return a pointer to a non-member
3059 function taking pointer to @code{C} as the first argument, followed by
3060 the same arguments as of the implementation function.  G++ checks
3061 the signatures of the two functions and issues
3062 a @option{-Wattribute-alias} warning for mismatches.  To suppress a warning
3063 for the necessary cast from a pointer to the implementation member function
3064 to the type of the corresponding non-member function use
3065 the @option{-Wno-pmf-conversions} option.  For example:
3067 @smallexample
3068 class S
3070 private:
3071   int debug_impl (int);
3072   int optimized_impl (int);
3074   typedef int Func (S*, int);
3076   static Func* resolver ();
3077 public:
3079   int interface (int);
3082 int S::debug_impl (int) @{ /* @r{@dots{}} */ @}
3083 int S::optimized_impl (int) @{ /* @r{@dots{}} */ @}
3085 S::Func* S::resolver ()
3087   int (S::*pimpl) (int)
3088     = getenv ("DEBUG") ? &S::debug_impl : &S::optimized_impl;
3090   // Cast triggers -Wno-pmf-conversions.
3091   return reinterpret_cast<Func*>(pimpl);
3094 int S::interface (int) __attribute__ ((ifunc ("_ZN1S8resolverEv")));
3095 @end smallexample
3097 Indirect functions cannot be weak.  Binutils version 2.20.1 or higher
3098 and GNU C Library version 2.11.1 are required to use this feature.
3100 @item interrupt
3101 @itemx interrupt_handler
3102 Many GCC back ends support attributes to indicate that a function is
3103 an interrupt handler, which tells the compiler to generate function
3104 entry and exit sequences that differ from those from regular
3105 functions.  The exact syntax and behavior are target-specific;
3106 refer to the following subsections for details.
3108 @item leaf
3109 @cindex @code{leaf} function attribute
3110 Calls to external functions with this attribute must return to the
3111 current compilation unit only by return or by exception handling.  In
3112 particular, a leaf function is not allowed to invoke callback functions
3113 passed to it from the current compilation unit, directly call functions
3114 exported by the unit, or @code{longjmp} into the unit.  Leaf functions
3115 might still call functions from other compilation units and thus they
3116 are not necessarily leaf in the sense that they contain no function
3117 calls at all.
3119 The attribute is intended for library functions to improve dataflow
3120 analysis.  The compiler takes the hint that any data not escaping the
3121 current compilation unit cannot be used or modified by the leaf
3122 function.  For example, the @code{sin} function is a leaf function, but
3123 @code{qsort} is not.
3125 Note that leaf functions might indirectly run a signal handler defined
3126 in the current compilation unit that uses static variables.  Similarly,
3127 when lazy symbol resolution is in effect, leaf functions might invoke
3128 indirect functions whose resolver function or implementation function is
3129 defined in the current compilation unit and uses static variables.  There
3130 is no standard-compliant way to write such a signal handler, resolver
3131 function, or implementation function, and the best that you can do is to
3132 remove the @code{leaf} attribute or mark all such static variables
3133 @code{volatile}.  Lastly, for ELF-based systems that support symbol
3134 interposition, care should be taken that functions defined in the
3135 current compilation unit do not unexpectedly interpose other symbols
3136 based on the defined standards mode and defined feature test macros;
3137 otherwise an inadvertent callback would be added.
3139 The attribute has no effect on functions defined within the current
3140 compilation unit.  This is to allow easy merging of multiple compilation
3141 units into one, for example, by using the link-time optimization.  For
3142 this reason the attribute is not allowed on types to annotate indirect
3143 calls.
3145 @item malloc
3146 @cindex @code{malloc} function attribute
3147 @cindex functions that behave like malloc
3148 This tells the compiler that a function is @code{malloc}-like, i.e.,
3149 that the pointer @var{P} returned by the function cannot alias any
3150 other pointer valid when the function returns, and moreover no
3151 pointers to valid objects occur in any storage addressed by @var{P}.
3153 Using this attribute can improve optimization.  Compiler predicts
3154 that a function with the attribute returns non-null in most cases.
3155 Functions like
3156 @code{malloc} and @code{calloc} have this property because they return
3157 a pointer to uninitialized or zeroed-out storage.  However, functions
3158 like @code{realloc} do not have this property, as they can return a
3159 pointer to storage containing pointers.
3161 @item no_icf
3162 @cindex @code{no_icf} function attribute
3163 This function attribute prevents a functions from being merged with another
3164 semantically equivalent function.
3166 @item no_instrument_function
3167 @cindex @code{no_instrument_function} function attribute
3168 @opindex finstrument-functions
3169 @opindex p
3170 @opindex pg
3171 If any of @option{-finstrument-functions}, @option{-p}, or @option{-pg} are 
3172 given, profiling function calls are
3173 generated at entry and exit of most user-compiled functions.
3174 Functions with this attribute are not so instrumented.
3176 @item no_profile_instrument_function
3177 @cindex @code{no_profile_instrument_function} function attribute
3178 The @code{no_profile_instrument_function} attribute on functions is used
3179 to inform the compiler that it should not process any profile feedback based
3180 optimization code instrumentation.
3182 @item no_reorder
3183 @cindex @code{no_reorder} function attribute
3184 Do not reorder functions or variables marked @code{no_reorder}
3185 against each other or top level assembler statements the executable.
3186 The actual order in the program will depend on the linker command
3187 line. Static variables marked like this are also not removed.
3188 This has a similar effect
3189 as the @option{-fno-toplevel-reorder} option, but only applies to the
3190 marked symbols.
3192 @item no_sanitize ("@var{sanitize_option}")
3193 @cindex @code{no_sanitize} function attribute
3194 The @code{no_sanitize} attribute on functions is used
3195 to inform the compiler that it should not do sanitization of all options
3196 mentioned in @var{sanitize_option}.  A list of values acceptable by
3197 @option{-fsanitize} option can be provided.
3199 @smallexample
3200 void __attribute__ ((no_sanitize ("alignment", "object-size")))
3201 f () @{ /* @r{Do something.} */; @}
3202 void __attribute__ ((no_sanitize ("alignment,object-size")))
3203 g () @{ /* @r{Do something.} */; @}
3204 @end smallexample
3206 @item no_sanitize_address
3207 @itemx no_address_safety_analysis
3208 @cindex @code{no_sanitize_address} function attribute
3209 The @code{no_sanitize_address} attribute on functions is used
3210 to inform the compiler that it should not instrument memory accesses
3211 in the function when compiling with the @option{-fsanitize=address} option.
3212 The @code{no_address_safety_analysis} is a deprecated alias of the
3213 @code{no_sanitize_address} attribute, new code should use
3214 @code{no_sanitize_address}.
3216 @item no_sanitize_thread
3217 @cindex @code{no_sanitize_thread} function attribute
3218 The @code{no_sanitize_thread} attribute on functions is used
3219 to inform the compiler that it should not instrument memory accesses
3220 in the function when compiling with the @option{-fsanitize=thread} option.
3222 @item no_sanitize_undefined
3223 @cindex @code{no_sanitize_undefined} function attribute
3224 The @code{no_sanitize_undefined} attribute on functions is used
3225 to inform the compiler that it should not check for undefined behavior
3226 in the function when compiling with the @option{-fsanitize=undefined} option.
3228 @item no_split_stack
3229 @cindex @code{no_split_stack} function attribute
3230 @opindex fsplit-stack
3231 If @option{-fsplit-stack} is given, functions have a small
3232 prologue which decides whether to split the stack.  Functions with the
3233 @code{no_split_stack} attribute do not have that prologue, and thus
3234 may run with only a small amount of stack space available.
3236 @item no_stack_limit
3237 @cindex @code{no_stack_limit} function attribute
3238 This attribute locally overrides the @option{-fstack-limit-register}
3239 and @option{-fstack-limit-symbol} command-line options; it has the effect
3240 of disabling stack limit checking in the function it applies to.
3242 @item noclone
3243 @cindex @code{noclone} function attribute
3244 This function attribute prevents a function from being considered for
3245 cloning---a mechanism that produces specialized copies of functions
3246 and which is (currently) performed by interprocedural constant
3247 propagation.
3249 @item noinline
3250 @cindex @code{noinline} function attribute
3251 This function attribute prevents a function from being considered for
3252 inlining.
3253 @c Don't enumerate the optimizations by name here; we try to be
3254 @c future-compatible with this mechanism.
3255 If the function does not have side effects, there are optimizations
3256 other than inlining that cause function calls to be optimized away,
3257 although the function call is live.  To keep such calls from being
3258 optimized away, put
3259 @smallexample
3260 asm ("");
3261 @end smallexample
3263 @noindent
3264 (@pxref{Extended Asm}) in the called function, to serve as a special
3265 side effect.
3267 @item noipa
3268 @cindex @code{noipa} function attribute
3269 Disable interprocedural optimizations between the function with this
3270 attribute and its callers, as if the body of the function is not available
3271 when optimizing callers and the callers are unavailable when optimizing
3272 the body.  This attribute implies @code{noinline}, @code{noclone} and
3273 @code{no_icf} attributes.    However, this attribute is not equivalent
3274 to a combination of other attributes, because its purpose is to suppress
3275 existing and future optimizations employing interprocedural analysis,
3276 including those that do not have an attribute suitable for disabling
3277 them individually.  This attribute is supported mainly for the purpose
3278 of testing the compiler.
3280 @item nonnull
3281 @itemx nonnull (@var{arg-index}, @dots{})
3282 @cindex @code{nonnull} function attribute
3283 @cindex functions with non-null pointer arguments
3284 The @code{nonnull} attribute may be applied to a function that takes at
3285 least one argument of a pointer type.  It indicates that the referenced
3286 arguments must be non-null pointers.  For instance, the declaration:
3288 @smallexample
3289 extern void *
3290 my_memcpy (void *dest, const void *src, size_t len)
3291         __attribute__((nonnull (1, 2)));
3292 @end smallexample
3294 @noindent
3295 causes the compiler to check that, in calls to @code{my_memcpy},
3296 arguments @var{dest} and @var{src} are non-null.  If the compiler
3297 determines that a null pointer is passed in an argument slot marked
3298 as non-null, and the @option{-Wnonnull} option is enabled, a warning
3299 is issued.  @xref{Warning Options}.  Unless disabled by
3300 the @option{-fno-delete-null-pointer-checks} option the compiler may
3301 also perform optimizations based on the knowledge that certain function
3302 arguments cannot be null. In addition,
3303 the @option{-fisolate-erroneous-paths-attribute} option can be specified
3304 to have GCC transform calls with null arguments to non-null functions
3305 into traps. @xref{Optimize Options}.
3307 If no @var{arg-index} is given to the @code{nonnull} attribute,
3308 all pointer arguments are marked as non-null.  To illustrate, the
3309 following declaration is equivalent to the previous example:
3311 @smallexample
3312 extern void *
3313 my_memcpy (void *dest, const void *src, size_t len)
3314         __attribute__((nonnull));
3315 @end smallexample
3317 @item noplt
3318 @cindex @code{noplt} function attribute
3319 The @code{noplt} attribute is the counterpart to option @option{-fno-plt}.
3320 Calls to functions marked with this attribute in position-independent code
3321 do not use the PLT.
3323 @smallexample
3324 @group
3325 /* Externally defined function foo.  */
3326 int foo () __attribute__ ((noplt));
3329 main (/* @r{@dots{}} */)
3331   /* @r{@dots{}} */
3332   foo ();
3333   /* @r{@dots{}} */
3335 @end group
3336 @end smallexample
3338 The @code{noplt} attribute on function @code{foo}
3339 tells the compiler to assume that
3340 the function @code{foo} is externally defined and that the call to
3341 @code{foo} must avoid the PLT
3342 in position-independent code.
3344 In position-dependent code, a few targets also convert calls to
3345 functions that are marked to not use the PLT to use the GOT instead.
3347 @item noreturn
3348 @cindex @code{noreturn} function attribute
3349 @cindex functions that never return
3350 A few standard library functions, such as @code{abort} and @code{exit},
3351 cannot return.  GCC knows this automatically.  Some programs define
3352 their own functions that never return.  You can declare them
3353 @code{noreturn} to tell the compiler this fact.  For example,
3355 @smallexample
3356 @group
3357 void fatal () __attribute__ ((noreturn));
3359 void
3360 fatal (/* @r{@dots{}} */)
3362   /* @r{@dots{}} */ /* @r{Print error message.} */ /* @r{@dots{}} */
3363   exit (1);
3365 @end group
3366 @end smallexample
3368 The @code{noreturn} keyword tells the compiler to assume that
3369 @code{fatal} cannot return.  It can then optimize without regard to what
3370 would happen if @code{fatal} ever did return.  This makes slightly
3371 better code.  More importantly, it helps avoid spurious warnings of
3372 uninitialized variables.
3374 The @code{noreturn} keyword does not affect the exceptional path when that
3375 applies: a @code{noreturn}-marked function may still return to the caller
3376 by throwing an exception or calling @code{longjmp}.
3378 In order to preserve backtraces, GCC will never turn calls to
3379 @code{noreturn} functions into tail calls.
3381 Do not assume that registers saved by the calling function are
3382 restored before calling the @code{noreturn} function.
3384 It does not make sense for a @code{noreturn} function to have a return
3385 type other than @code{void}.
3387 @item nothrow
3388 @cindex @code{nothrow} function attribute
3389 The @code{nothrow} attribute is used to inform the compiler that a
3390 function cannot throw an exception.  For example, most functions in
3391 the standard C library can be guaranteed not to throw an exception
3392 with the notable exceptions of @code{qsort} and @code{bsearch} that
3393 take function pointer arguments.
3395 @item optimize (@var{level}, @dots{})
3396 @item optimize (@var{string}, @dots{})
3397 @cindex @code{optimize} function attribute
3398 The @code{optimize} attribute is used to specify that a function is to
3399 be compiled with different optimization options than specified on the
3400 command line.  Valid arguments are constant non-negative integers and
3401 strings.  Each numeric argument specifies an optimization @var{level}.
3402 Each @var{string} argument consists of one or more comma-separated
3403 substrings.  Each substring that begins with the letter @code{O} refers
3404 to an optimization option such as @option{-O0} or @option{-Os}.  Other
3405 substrings are taken as suffixes to the @code{-f} prefix jointly
3406 forming the name of an optimization option.  @xref{Optimize Options}.
3408 @samp{#pragma GCC optimize} can be used to set optimization options
3409 for more than one function.  @xref{Function Specific Option Pragmas},
3410 for details about the pragma.
3412 Providing multiple strings as arguments separated by commas to specify
3413 multiple options is equivalent to separating the option suffixes with
3414 a comma (@samp{,}) within a single string.  Spaces are not permitted
3415 within the strings.
3417 Not every optimization option that starts with the @var{-f} prefix
3418 specified by the attribute necessarily has an effect on the function.
3419 The @code{optimize} attribute should be used for debugging purposes only.
3420 It is not suitable in production code.
3422 @item patchable_function_entry
3423 @cindex @code{patchable_function_entry} function attribute
3424 @cindex extra NOP instructions at the function entry point
3425 In case the target's text segment can be made writable at run time by
3426 any means, padding the function entry with a number of NOPs can be
3427 used to provide a universal tool for instrumentation.
3429 The @code{patchable_function_entry} function attribute can be used to
3430 change the number of NOPs to any desired value.  The two-value syntax
3431 is the same as for the command-line switch
3432 @option{-fpatchable-function-entry=N,M}, generating @var{N} NOPs, with
3433 the function entry point before the @var{M}th NOP instruction.
3434 @var{M} defaults to 0 if omitted e.g.@: function entry point is before
3435 the first NOP.
3437 If patchable function entries are enabled globally using the command-line
3438 option @option{-fpatchable-function-entry=N,M}, then you must disable
3439 instrumentation on all functions that are part of the instrumentation
3440 framework with the attribute @code{patchable_function_entry (0)}
3441 to prevent recursion.
3443 @item pure
3444 @cindex @code{pure} function attribute
3445 @cindex functions that have no side effects
3447 Calls to functions that have no observable effects on the state of
3448 the program other than to return a value may lend themselves to optimizations
3449 such as common subexpression elimination.  Declaring such functions with
3450 the @code{pure} attribute allows GCC to avoid emitting some calls in repeated
3451 invocations of the function with the same argument values.
3453 The @code{pure} attribute prohibits a function from modifying the state
3454 of the program that is observable by means other than inspecting
3455 the function's return value.  However, functions declared with the @code{pure}
3456 attribute can safely read any non-volatile objects, and modify the value of
3457 objects in a way that does not affect their return value or the observable
3458 state of the program.
3460 For example,
3462 @smallexample
3463 int hash (char *) __attribute__ ((pure));
3464 @end smallexample
3466 @noindent
3467 tells GCC that subsequent calls to the function @code{hash} with the same
3468 string can be replaced by the result of the first call provided the state
3469 of the program observable by @code{hash}, including the contents of the array
3470 itself, does not change in between.  Even though @code{hash} takes a non-const
3471 pointer argument it must not modify the array it points to, or any other object
3472 whose value the rest of the program may depend on.  However, the caller may
3473 safely change the contents of the array between successive calls to
3474 the function (doing so disables the optimization).  The restriction also
3475 applies to member objects referenced by the @code{this} pointer in C++
3476 non-static member functions.
3478 Some common examples of pure functions are @code{strlen} or @code{memcmp}.
3479 Interesting non-pure functions are functions with infinite loops or those
3480 depending on volatile memory or other system resource, that may change between
3481 consecutive calls (such as the standard C @code{feof} function in
3482 a multithreading environment).
3484 The @code{pure} attribute imposes similar but looser restrictions on
3485 a function's definition than the @code{const} attribute: @code{pure}
3486 allows the function to read any non-volatile memory, even if it changes
3487 in between successive invocations of the function.  Declaring the same
3488 function with both the @code{pure} and the @code{const} attribute is
3489 diagnosed.  Because a pure function cannot have any observable side
3490 effects it does not make sense for such a function to return @code{void}.
3491 Declaring such a function is diagnosed.
3493 @item returns_nonnull
3494 @cindex @code{returns_nonnull} function attribute
3495 The @code{returns_nonnull} attribute specifies that the function
3496 return value should be a non-null pointer.  For instance, the declaration:
3498 @smallexample
3499 extern void *
3500 mymalloc (size_t len) __attribute__((returns_nonnull));
3501 @end smallexample
3503 @noindent
3504 lets the compiler optimize callers based on the knowledge
3505 that the return value will never be null.
3507 @item returns_twice
3508 @cindex @code{returns_twice} function attribute
3509 @cindex functions that return more than once
3510 The @code{returns_twice} attribute tells the compiler that a function may
3511 return more than one time.  The compiler ensures that all registers
3512 are dead before calling such a function and emits a warning about
3513 the variables that may be clobbered after the second return from the
3514 function.  Examples of such functions are @code{setjmp} and @code{vfork}.
3515 The @code{longjmp}-like counterpart of such function, if any, might need
3516 to be marked with the @code{noreturn} attribute.
3518 @item section ("@var{section-name}")
3519 @cindex @code{section} function attribute
3520 @cindex functions in arbitrary sections
3521 Normally, the compiler places the code it generates in the @code{text} section.
3522 Sometimes, however, you need additional sections, or you need certain
3523 particular functions to appear in special sections.  The @code{section}
3524 attribute specifies that a function lives in a particular section.
3525 For example, the declaration:
3527 @smallexample
3528 extern void foobar (void) __attribute__ ((section ("bar")));
3529 @end smallexample
3531 @noindent
3532 puts the function @code{foobar} in the @code{bar} section.
3534 Some file formats do not support arbitrary sections so the @code{section}
3535 attribute is not available on all platforms.
3536 If you need to map the entire contents of a module to a particular
3537 section, consider using the facilities of the linker instead.
3539 @item sentinel
3540 @itemx sentinel (@var{position})
3541 @cindex @code{sentinel} function attribute
3542 This function attribute indicates that an argument in a call to the function
3543 is expected to be an explicit @code{NULL}.  The attribute is only valid on
3544 variadic functions.  By default, the sentinel is expected to be the last
3545 argument of the function call.  If the optional @var{position} argument
3546 is specified to the attribute, the sentinel must be located at
3547 @var{position} counting backwards from the end of the argument list.
3549 @smallexample
3550 __attribute__ ((sentinel))
3551 is equivalent to
3552 __attribute__ ((sentinel(0)))
3553 @end smallexample
3555 The attribute is automatically set with a position of 0 for the built-in
3556 functions @code{execl} and @code{execlp}.  The built-in function
3557 @code{execle} has the attribute set with a position of 1.
3559 A valid @code{NULL} in this context is defined as zero with any object
3560 pointer type.  If your system defines the @code{NULL} macro with
3561 an integer type then you need to add an explicit cast.  During
3562 installation GCC replaces the system @code{<stddef.h>} header with
3563 a copy that redefines NULL appropriately.
3565 The warnings for missing or incorrect sentinels are enabled with
3566 @option{-Wformat}.
3568 @item simd
3569 @itemx simd("@var{mask}")
3570 @cindex @code{simd} function attribute
3571 This attribute enables creation of one or more function versions that
3572 can process multiple arguments using SIMD instructions from a
3573 single invocation.  Specifying this attribute allows compiler to
3574 assume that such versions are available at link time (provided
3575 in the same or another translation unit).  Generated versions are
3576 target-dependent and described in the corresponding Vector ABI document.  For
3577 x86_64 target this document can be found
3578 @w{@uref{https://sourceware.org/glibc/wiki/libmvec?action=AttachFile&do=view&target=VectorABI.txt,here}}.
3580 The optional argument @var{mask} may have the value
3581 @code{notinbranch} or @code{inbranch},
3582 and instructs the compiler to generate non-masked or masked
3583 clones correspondingly. By default, all clones are generated.
3585 If the attribute is specified and @code{#pragma omp declare simd} is
3586 present on a declaration and the @option{-fopenmp} or @option{-fopenmp-simd}
3587 switch is specified, then the attribute is ignored.
3589 @item stack_protect
3590 @cindex @code{stack_protect} function attribute
3591 This attribute adds stack protection code to the function if 
3592 flags @option{-fstack-protector}, @option{-fstack-protector-strong}
3593 or @option{-fstack-protector-explicit} are set.
3595 @item target (@var{string}, @dots{})
3596 @cindex @code{target} function attribute
3597 Multiple target back ends implement the @code{target} attribute
3598 to specify that a function is to
3599 be compiled with different target options than specified on the
3600 command line.  One or more strings can be provided as arguments.
3601 Each string consists of one or more comma-separated suffixes to
3602 the @code{-m} prefix jointly forming the name of a machine-dependent
3603 option.  @xref{Submodel Options,,Machine-Dependent Options}.
3605 The @code{target} attribute can be used for instance to have a function
3606 compiled with a different ISA (instruction set architecture) than the
3607 default.  @samp{#pragma GCC target} can be used to specify target-specific
3608 options for more than one function.  @xref{Function Specific Option Pragmas},
3609 for details about the pragma.
3611 For instance, on an x86, you could declare one function with the
3612 @code{target("sse4.1,arch=core2")} attribute and another with
3613 @code{target("sse4a,arch=amdfam10")}.  This is equivalent to
3614 compiling the first function with @option{-msse4.1} and
3615 @option{-march=core2} options, and the second function with
3616 @option{-msse4a} and @option{-march=amdfam10} options.  It is up to you
3617 to make sure that a function is only invoked on a machine that
3618 supports the particular ISA it is compiled for (for example by using
3619 @code{cpuid} on x86 to determine what feature bits and architecture
3620 family are used).
3622 @smallexample
3623 int core2_func (void) __attribute__ ((__target__ ("arch=core2")));
3624 int sse3_func (void) __attribute__ ((__target__ ("sse3")));
3625 @end smallexample
3627 Providing multiple strings as arguments separated by commas to specify
3628 multiple options is equivalent to separating the option suffixes with
3629 a comma (@samp{,}) within a single string.  Spaces are not permitted
3630 within the strings.
3632 The options supported are specific to each target; refer to @ref{x86
3633 Function Attributes}, @ref{PowerPC Function Attributes},
3634 @ref{ARM Function Attributes}, @ref{AArch64 Function Attributes},
3635 @ref{Nios II Function Attributes}, and @ref{S/390 Function Attributes}
3636 for details.
3638 @item target_clones (@var{options})
3639 @cindex @code{target_clones} function attribute
3640 The @code{target_clones} attribute is used to specify that a function
3641 be cloned into multiple versions compiled with different target options
3642 than specified on the command line.  The supported options and restrictions
3643 are the same as for @code{target} attribute.
3645 For instance, on an x86, you could compile a function with
3646 @code{target_clones("sse4.1,avx")}.  GCC creates two function clones,
3647 one compiled with @option{-msse4.1} and another with @option{-mavx}.
3649 On a PowerPC, you can compile a function with
3650 @code{target_clones("cpu=power9,default")}.  GCC will create two
3651 function clones, one compiled with @option{-mcpu=power9} and another
3652 with the default options.  GCC must be configured to use GLIBC 2.23 or
3653 newer in order to use the @code{target_clones} attribute.
3655 It also creates a resolver function (see
3656 the @code{ifunc} attribute above) that dynamically selects a clone
3657 suitable for current architecture.  The resolver is created only if there
3658 is a usage of a function with @code{target_clones} attribute.
3660 @item unused
3661 @cindex @code{unused} function attribute
3662 This attribute, attached to a function, means that the function is meant
3663 to be possibly unused.  GCC does not produce a warning for this
3664 function.
3666 @item used
3667 @cindex @code{used} function attribute
3668 This attribute, attached to a function, means that code must be emitted
3669 for the function even if it appears that the function is not referenced.
3670 This is useful, for example, when the function is referenced only in
3671 inline assembly.
3673 When applied to a member function of a C++ class template, the
3674 attribute also means that the function is instantiated if the
3675 class itself is instantiated.
3677 @item visibility ("@var{visibility_type}")
3678 @cindex @code{visibility} function attribute
3679 This attribute affects the linkage of the declaration to which it is attached.
3680 It can be applied to variables (@pxref{Common Variable Attributes}) and types
3681 (@pxref{Common Type Attributes}) as well as functions.
3683 There are four supported @var{visibility_type} values: default,
3684 hidden, protected or internal visibility.
3686 @smallexample
3687 void __attribute__ ((visibility ("protected")))
3688 f () @{ /* @r{Do something.} */; @}
3689 int i __attribute__ ((visibility ("hidden")));
3690 @end smallexample
3692 The possible values of @var{visibility_type} correspond to the
3693 visibility settings in the ELF gABI.
3695 @table @code
3696 @c keep this list of visibilities in alphabetical order.
3698 @item default
3699 Default visibility is the normal case for the object file format.
3700 This value is available for the visibility attribute to override other
3701 options that may change the assumed visibility of entities.
3703 On ELF, default visibility means that the declaration is visible to other
3704 modules and, in shared libraries, means that the declared entity may be
3705 overridden.
3707 On Darwin, default visibility means that the declaration is visible to
3708 other modules.
3710 Default visibility corresponds to ``external linkage'' in the language.
3712 @item hidden
3713 Hidden visibility indicates that the entity declared has a new
3714 form of linkage, which we call ``hidden linkage''.  Two
3715 declarations of an object with hidden linkage refer to the same object
3716 if they are in the same shared object.
3718 @item internal
3719 Internal visibility is like hidden visibility, but with additional
3720 processor specific semantics.  Unless otherwise specified by the
3721 psABI, GCC defines internal visibility to mean that a function is
3722 @emph{never} called from another module.  Compare this with hidden
3723 functions which, while they cannot be referenced directly by other
3724 modules, can be referenced indirectly via function pointers.  By
3725 indicating that a function cannot be called from outside the module,
3726 GCC may for instance omit the load of a PIC register since it is known
3727 that the calling function loaded the correct value.
3729 @item protected
3730 Protected visibility is like default visibility except that it
3731 indicates that references within the defining module bind to the
3732 definition in that module.  That is, the declared entity cannot be
3733 overridden by another module.
3735 @end table
3737 All visibilities are supported on many, but not all, ELF targets
3738 (supported when the assembler supports the @samp{.visibility}
3739 pseudo-op).  Default visibility is supported everywhere.  Hidden
3740 visibility is supported on Darwin targets.
3742 The visibility attribute should be applied only to declarations that
3743 would otherwise have external linkage.  The attribute should be applied
3744 consistently, so that the same entity should not be declared with
3745 different settings of the attribute.
3747 In C++, the visibility attribute applies to types as well as functions
3748 and objects, because in C++ types have linkage.  A class must not have
3749 greater visibility than its non-static data member types and bases,
3750 and class members default to the visibility of their class.  Also, a
3751 declaration without explicit visibility is limited to the visibility
3752 of its type.
3754 In C++, you can mark member functions and static member variables of a
3755 class with the visibility attribute.  This is useful if you know a
3756 particular method or static member variable should only be used from
3757 one shared object; then you can mark it hidden while the rest of the
3758 class has default visibility.  Care must be taken to avoid breaking
3759 the One Definition Rule; for example, it is usually not useful to mark
3760 an inline method as hidden without marking the whole class as hidden.
3762 A C++ namespace declaration can also have the visibility attribute.
3764 @smallexample
3765 namespace nspace1 __attribute__ ((visibility ("protected")))
3766 @{ /* @r{Do something.} */; @}
3767 @end smallexample
3769 This attribute applies only to the particular namespace body, not to
3770 other definitions of the same namespace; it is equivalent to using
3771 @samp{#pragma GCC visibility} before and after the namespace
3772 definition (@pxref{Visibility Pragmas}).
3774 In C++, if a template argument has limited visibility, this
3775 restriction is implicitly propagated to the template instantiation.
3776 Otherwise, template instantiations and specializations default to the
3777 visibility of their template.
3779 If both the template and enclosing class have explicit visibility, the
3780 visibility from the template is used.
3782 @item warn_unused_result
3783 @cindex @code{warn_unused_result} function attribute
3784 The @code{warn_unused_result} attribute causes a warning to be emitted
3785 if a caller of the function with this attribute does not use its
3786 return value.  This is useful for functions where not checking
3787 the result is either a security problem or always a bug, such as
3788 @code{realloc}.
3790 @smallexample
3791 int fn () __attribute__ ((warn_unused_result));
3792 int foo ()
3794   if (fn () < 0) return -1;
3795   fn ();
3796   return 0;
3798 @end smallexample
3800 @noindent
3801 results in warning on line 5.
3803 @item weak
3804 @cindex @code{weak} function attribute
3805 The @code{weak} attribute causes the declaration to be emitted as a weak
3806 symbol rather than a global.  This is primarily useful in defining
3807 library functions that can be overridden in user code, though it can
3808 also be used with non-function declarations.  Weak symbols are supported
3809 for ELF targets, and also for a.out targets when using the GNU assembler
3810 and linker.
3812 @item weakref
3813 @itemx weakref ("@var{target}")
3814 @cindex @code{weakref} function attribute
3815 The @code{weakref} attribute marks a declaration as a weak reference.
3816 Without arguments, it should be accompanied by an @code{alias} attribute
3817 naming the target symbol.  Optionally, the @var{target} may be given as
3818 an argument to @code{weakref} itself.  In either case, @code{weakref}
3819 implicitly marks the declaration as @code{weak}.  Without a
3820 @var{target}, given as an argument to @code{weakref} or to @code{alias},
3821 @code{weakref} is equivalent to @code{weak}.
3823 @smallexample
3824 static int x() __attribute__ ((weakref ("y")));
3825 /* is equivalent to... */
3826 static int x() __attribute__ ((weak, weakref, alias ("y")));
3827 /* and to... */
3828 static int x() __attribute__ ((weakref));
3829 static int x() __attribute__ ((alias ("y")));
3830 @end smallexample
3832 A weak reference is an alias that does not by itself require a
3833 definition to be given for the target symbol.  If the target symbol is
3834 only referenced through weak references, then it becomes a @code{weak}
3835 undefined symbol.  If it is directly referenced, however, then such
3836 strong references prevail, and a definition is required for the
3837 symbol, not necessarily in the same translation unit.
3839 The effect is equivalent to moving all references to the alias to a
3840 separate translation unit, renaming the alias to the aliased symbol,
3841 declaring it as weak, compiling the two separate translation units and
3842 performing a link with relocatable output (ie: @code{ld -r}) on them.
3844 At present, a declaration to which @code{weakref} is attached can
3845 only be @code{static}.
3848 @end table
3850 @c This is the end of the target-independent attribute table
3852 @node AArch64 Function Attributes
3853 @subsection AArch64 Function Attributes
3855 The following target-specific function attributes are available for the
3856 AArch64 target.  For the most part, these options mirror the behavior of
3857 similar command-line options (@pxref{AArch64 Options}), but on a
3858 per-function basis.
3860 @table @code
3861 @item general-regs-only
3862 @cindex @code{general-regs-only} function attribute, AArch64
3863 Indicates that no floating-point or Advanced SIMD registers should be
3864 used when generating code for this function.  If the function explicitly
3865 uses floating-point code, then the compiler gives an error.  This is
3866 the same behavior as that of the command-line option
3867 @option{-mgeneral-regs-only}.
3869 @item fix-cortex-a53-835769
3870 @cindex @code{fix-cortex-a53-835769} function attribute, AArch64
3871 Indicates that the workaround for the Cortex-A53 erratum 835769 should be
3872 applied to this function.  To explicitly disable the workaround for this
3873 function specify the negated form: @code{no-fix-cortex-a53-835769}.
3874 This corresponds to the behavior of the command line options
3875 @option{-mfix-cortex-a53-835769} and @option{-mno-fix-cortex-a53-835769}.
3877 @item cmodel=
3878 @cindex @code{cmodel=} function attribute, AArch64
3879 Indicates that code should be generated for a particular code model for
3880 this function.  The behavior and permissible arguments are the same as
3881 for the command line option @option{-mcmodel=}.
3883 @item strict-align
3884 @itemx no-strict-align
3885 @cindex @code{strict-align} function attribute, AArch64
3886 @code{strict-align} indicates that the compiler should not assume that unaligned
3887 memory references are handled by the system.  To allow the compiler to assume
3888 that aligned memory references are handled by the system, the inverse attribute
3889 @code{no-strict-align} can be specified.  The behavior is same as for the
3890 command-line option @option{-mstrict-align} and @option{-mno-strict-align}.
3892 @item omit-leaf-frame-pointer
3893 @cindex @code{omit-leaf-frame-pointer} function attribute, AArch64
3894 Indicates that the frame pointer should be omitted for a leaf function call.
3895 To keep the frame pointer, the inverse attribute
3896 @code{no-omit-leaf-frame-pointer} can be specified.  These attributes have
3897 the same behavior as the command-line options @option{-momit-leaf-frame-pointer}
3898 and @option{-mno-omit-leaf-frame-pointer}.
3900 @item tls-dialect=
3901 @cindex @code{tls-dialect=} function attribute, AArch64
3902 Specifies the TLS dialect to use for this function.  The behavior and
3903 permissible arguments are the same as for the command-line option
3904 @option{-mtls-dialect=}.
3906 @item arch=
3907 @cindex @code{arch=} function attribute, AArch64
3908 Specifies the architecture version and architectural extensions to use
3909 for this function.  The behavior and permissible arguments are the same as
3910 for the @option{-march=} command-line option.
3912 @item tune=
3913 @cindex @code{tune=} function attribute, AArch64
3914 Specifies the core for which to tune the performance of this function.
3915 The behavior and permissible arguments are the same as for the @option{-mtune=}
3916 command-line option.
3918 @item cpu=
3919 @cindex @code{cpu=} function attribute, AArch64
3920 Specifies the core for which to tune the performance of this function and also
3921 whose architectural features to use.  The behavior and valid arguments are the
3922 same as for the @option{-mcpu=} command-line option.
3924 @item sign-return-address
3925 @cindex @code{sign-return-address} function attribute, AArch64
3926 Select the function scope on which return address signing will be applied.  The
3927 behavior and permissible arguments are the same as for the command-line option
3928 @option{-msign-return-address=}.  The default value is @code{none}.
3930 @end table
3932 The above target attributes can be specified as follows:
3934 @smallexample
3935 __attribute__((target("@var{attr-string}")))
3937 f (int a)
3939   return a + 5;
3941 @end smallexample
3943 where @code{@var{attr-string}} is one of the attribute strings specified above.
3945 Additionally, the architectural extension string may be specified on its
3946 own.  This can be used to turn on and off particular architectural extensions
3947 without having to specify a particular architecture version or core.  Example:
3949 @smallexample
3950 __attribute__((target("+crc+nocrypto")))
3952 foo (int a)
3954   return a + 5;
3956 @end smallexample
3958 In this example @code{target("+crc+nocrypto")} enables the @code{crc}
3959 extension and disables the @code{crypto} extension for the function @code{foo}
3960 without modifying an existing @option{-march=} or @option{-mcpu} option.
3962 Multiple target function attributes can be specified by separating them with
3963 a comma.  For example:
3964 @smallexample
3965 __attribute__((target("arch=armv8-a+crc+crypto,tune=cortex-a53")))
3967 foo (int a)
3969   return a + 5;
3971 @end smallexample
3973 is valid and compiles function @code{foo} for ARMv8-A with @code{crc}
3974 and @code{crypto} extensions and tunes it for @code{cortex-a53}.
3976 @subsubsection Inlining rules
3977 Specifying target attributes on individual functions or performing link-time
3978 optimization across translation units compiled with different target options
3979 can affect function inlining rules:
3981 In particular, a caller function can inline a callee function only if the
3982 architectural features available to the callee are a subset of the features
3983 available to the caller.
3984 For example: A function @code{foo} compiled with @option{-march=armv8-a+crc},
3985 or tagged with the equivalent @code{arch=armv8-a+crc} attribute,
3986 can inline a function @code{bar} compiled with @option{-march=armv8-a+nocrc}
3987 because the all the architectural features that function @code{bar} requires
3988 are available to function @code{foo}.  Conversely, function @code{bar} cannot
3989 inline function @code{foo}.
3991 Additionally inlining a function compiled with @option{-mstrict-align} into a
3992 function compiled without @code{-mstrict-align} is not allowed.
3993 However, inlining a function compiled without @option{-mstrict-align} into a
3994 function compiled with @option{-mstrict-align} is allowed.
3996 Note that CPU tuning options and attributes such as the @option{-mcpu=},
3997 @option{-mtune=} do not inhibit inlining unless the CPU specified by the
3998 @option{-mcpu=} option or the @code{cpu=} attribute conflicts with the
3999 architectural feature rules specified above.
4001 @node AMD GCN Function Attributes
4002 @subsection AMD GCN Function Attributes
4004 These function attributes are supported by the AMD GCN back end:
4006 @table @code
4007 @item amdgpu_hsa_kernel
4008 @cindex @code{amdgpu_hsa_kernel} function attribute, AMD GCN
4009 This attribute indicates that the corresponding function should be compiled as
4010 a kernel function, that is an entry point that can be invoked from the host
4011 via the HSA runtime library.  By default functions are only callable only from
4012 other GCN functions.
4014 This attribute is implicitly applied to any function named @code{main}, using
4015 default parameters.
4017 Kernel functions may return an integer value, which will be written to a
4018 conventional place within the HSA "kernargs" region.
4020 The attribute parameters configure what values are passed into the kernel
4021 function by the GPU drivers, via the initial register state.  Some values are
4022 used by the compiler, and therefore forced on.  Enabling other options may
4023 break assumptions in the compiler and/or run-time libraries.
4025 @table @code
4026 @item private_segment_buffer
4027 Set @code{enable_sgpr_private_segment_buffer} flag.  Always on (required to
4028 locate the stack).
4030 @item dispatch_ptr
4031 Set @code{enable_sgpr_dispatch_ptr} flag.  Always on (required to locate the
4032 launch dimensions).
4034 @item queue_ptr
4035 Set @code{enable_sgpr_queue_ptr} flag.  Always on (required to convert address
4036 spaces).
4038 @item kernarg_segment_ptr
4039 Set @code{enable_sgpr_kernarg_segment_ptr} flag.  Always on (required to
4040 locate the kernel arguments, "kernargs").
4042 @item dispatch_id
4043 Set @code{enable_sgpr_dispatch_id} flag.
4045 @item flat_scratch_init
4046 Set @code{enable_sgpr_flat_scratch_init} flag.
4048 @item private_segment_size
4049 Set @code{enable_sgpr_private_segment_size} flag.
4051 @item grid_workgroup_count_X
4052 Set @code{enable_sgpr_grid_workgroup_count_x} flag.  Always on (required to
4053 use OpenACC/OpenMP).
4055 @item grid_workgroup_count_Y
4056 Set @code{enable_sgpr_grid_workgroup_count_y} flag.
4058 @item grid_workgroup_count_Z
4059 Set @code{enable_sgpr_grid_workgroup_count_z} flag.
4061 @item workgroup_id_X
4062 Set @code{enable_sgpr_workgroup_id_x} flag.
4064 @item workgroup_id_Y
4065 Set @code{enable_sgpr_workgroup_id_y} flag.
4067 @item workgroup_id_Z
4068 Set @code{enable_sgpr_workgroup_id_z} flag.
4070 @item workgroup_info
4071 Set @code{enable_sgpr_workgroup_info} flag.
4073 @item private_segment_wave_offset
4074 Set @code{enable_sgpr_private_segment_wave_byte_offset} flag.  Always on
4075 (required to locate the stack).
4077 @item work_item_id_X
4078 Set @code{enable_vgpr_workitem_id} parameter.  Always on (can't be disabled).
4080 @item work_item_id_Y
4081 Set @code{enable_vgpr_workitem_id} parameter.  Always on (required to enable
4082 vectorization.)
4084 @item work_item_id_Z
4085 Set @code{enable_vgpr_workitem_id} parameter.  Always on (required to use
4086 OpenACC/OpenMP).
4088 @end table
4089 @end table
4091 @node ARC Function Attributes
4092 @subsection ARC Function Attributes
4094 These function attributes are supported by the ARC back end:
4096 @table @code
4097 @item interrupt
4098 @cindex @code{interrupt} function attribute, ARC
4099 Use this attribute to indicate
4100 that the specified function is an interrupt handler.  The compiler generates
4101 function entry and exit sequences suitable for use in an interrupt handler
4102 when this attribute is present.
4104 On the ARC, you must specify the kind of interrupt to be handled
4105 in a parameter to the interrupt attribute like this:
4107 @smallexample
4108 void f () __attribute__ ((interrupt ("ilink1")));
4109 @end smallexample
4111 Permissible values for this parameter are: @w{@code{ilink1}} and
4112 @w{@code{ilink2}}.
4114 @item long_call
4115 @itemx medium_call
4116 @itemx short_call
4117 @cindex @code{long_call} function attribute, ARC
4118 @cindex @code{medium_call} function attribute, ARC
4119 @cindex @code{short_call} function attribute, ARC
4120 @cindex indirect calls, ARC
4121 These attributes specify how a particular function is called.
4122 These attributes override the
4123 @option{-mlong-calls} and @option{-mmedium-calls} (@pxref{ARC Options})
4124 command-line switches and @code{#pragma long_calls} settings.
4126 For ARC, a function marked with the @code{long_call} attribute is
4127 always called using register-indirect jump-and-link instructions,
4128 thereby enabling the called function to be placed anywhere within the
4129 32-bit address space.  A function marked with the @code{medium_call}
4130 attribute will always be close enough to be called with an unconditional
4131 branch-and-link instruction, which has a 25-bit offset from
4132 the call site.  A function marked with the @code{short_call}
4133 attribute will always be close enough to be called with a conditional
4134 branch-and-link instruction, which has a 21-bit offset from
4135 the call site.
4137 @item jli_always
4138 @cindex @code{jli_always} function attribute, ARC
4139 Forces a particular function to be called using @code{jli}
4140 instruction.  The @code{jli} instruction makes use of a table stored
4141 into @code{.jlitab} section, which holds the location of the functions
4142 which are addressed using this instruction.
4144 @item jli_fixed
4145 @cindex @code{jli_fixed} function attribute, ARC
4146 Identical like the above one, but the location of the function in the
4147 @code{jli} table is known and given as an attribute parameter.
4149 @item secure_call
4150 @cindex @code{secure_call} function attribute, ARC
4151 This attribute allows one to mark secure-code functions that are
4152 callable from normal mode.  The location of the secure call function
4153 into the @code{sjli} table needs to be passed as argument.
4155 @end table
4157 @node ARM Function Attributes
4158 @subsection ARM Function Attributes
4160 These function attributes are supported for ARM targets:
4162 @table @code
4163 @item interrupt
4164 @cindex @code{interrupt} function attribute, ARM
4165 Use this attribute to indicate
4166 that the specified function is an interrupt handler.  The compiler generates
4167 function entry and exit sequences suitable for use in an interrupt handler
4168 when this attribute is present.
4170 You can specify the kind of interrupt to be handled by
4171 adding an optional parameter to the interrupt attribute like this:
4173 @smallexample
4174 void f () __attribute__ ((interrupt ("IRQ")));
4175 @end smallexample
4177 @noindent
4178 Permissible values for this parameter are: @code{IRQ}, @code{FIQ},
4179 @code{SWI}, @code{ABORT} and @code{UNDEF}.
4181 On ARMv7-M the interrupt type is ignored, and the attribute means the function
4182 may be called with a word-aligned stack pointer.
4184 @item isr
4185 @cindex @code{isr} function attribute, ARM
4186 Use this attribute on ARM to write Interrupt Service Routines. This is an
4187 alias to the @code{interrupt} attribute above.
4189 @item long_call
4190 @itemx short_call
4191 @cindex @code{long_call} function attribute, ARM
4192 @cindex @code{short_call} function attribute, ARM
4193 @cindex indirect calls, ARM
4194 These attributes specify how a particular function is called.
4195 These attributes override the
4196 @option{-mlong-calls} (@pxref{ARM Options})
4197 command-line switch and @code{#pragma long_calls} settings.  For ARM, the
4198 @code{long_call} attribute indicates that the function might be far
4199 away from the call site and require a different (more expensive)
4200 calling sequence.   The @code{short_call} attribute always places
4201 the offset to the function from the call site into the @samp{BL}
4202 instruction directly.
4204 @item naked
4205 @cindex @code{naked} function attribute, ARM
4206 This attribute allows the compiler to construct the
4207 requisite function declaration, while allowing the body of the
4208 function to be assembly code. The specified function will not have
4209 prologue/epilogue sequences generated by the compiler. Only basic
4210 @code{asm} statements can safely be included in naked functions
4211 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
4212 basic @code{asm} and C code may appear to work, they cannot be
4213 depended upon to work reliably and are not supported.
4215 @item pcs
4216 @cindex @code{pcs} function attribute, ARM
4218 The @code{pcs} attribute can be used to control the calling convention
4219 used for a function on ARM.  The attribute takes an argument that specifies
4220 the calling convention to use.
4222 When compiling using the AAPCS ABI (or a variant of it) then valid
4223 values for the argument are @code{"aapcs"} and @code{"aapcs-vfp"}.  In
4224 order to use a variant other than @code{"aapcs"} then the compiler must
4225 be permitted to use the appropriate co-processor registers (i.e., the
4226 VFP registers must be available in order to use @code{"aapcs-vfp"}).
4227 For example,
4229 @smallexample
4230 /* Argument passed in r0, and result returned in r0+r1.  */
4231 double f2d (float) __attribute__((pcs("aapcs")));
4232 @end smallexample
4234 Variadic functions always use the @code{"aapcs"} calling convention and
4235 the compiler rejects attempts to specify an alternative.
4237 @item target (@var{options})
4238 @cindex @code{target} function attribute
4239 As discussed in @ref{Common Function Attributes}, this attribute 
4240 allows specification of target-specific compilation options.
4242 On ARM, the following options are allowed:
4244 @table @samp
4245 @item thumb
4246 @cindex @code{target("thumb")} function attribute, ARM
4247 Force code generation in the Thumb (T16/T32) ISA, depending on the
4248 architecture level.
4250 @item arm
4251 @cindex @code{target("arm")} function attribute, ARM
4252 Force code generation in the ARM (A32) ISA.
4254 Functions from different modes can be inlined in the caller's mode.
4256 @item fpu=
4257 @cindex @code{target("fpu=")} function attribute, ARM
4258 Specifies the fpu for which to tune the performance of this function.
4259 The behavior and permissible arguments are the same as for the @option{-mfpu=}
4260 command-line option.
4262 @item arch=
4263 @cindex @code{arch=} function attribute, ARM
4264 Specifies the architecture version and architectural extensions to use
4265 for this function.  The behavior and permissible arguments are the same as
4266 for the @option{-march=} command-line option.
4268 The above target attributes can be specified as follows:
4270 @smallexample
4271 __attribute__((target("arch=armv8-a+crc")))
4273 f (int a)
4275   return a + 5;
4277 @end smallexample
4279 Additionally, the architectural extension string may be specified on its
4280 own.  This can be used to turn on and off particular architectural extensions
4281 without having to specify a particular architecture version or core.  Example:
4283 @smallexample
4284 __attribute__((target("+crc+nocrypto")))
4286 foo (int a)
4288   return a + 5;
4290 @end smallexample
4292 In this example @code{target("+crc+nocrypto")} enables the @code{crc}
4293 extension and disables the @code{crypto} extension for the function @code{foo}
4294 without modifying an existing @option{-march=} or @option{-mcpu} option.
4296 @end table
4298 @end table
4300 @node AVR Function Attributes
4301 @subsection AVR Function Attributes
4303 These function attributes are supported by the AVR back end:
4305 @table @code
4306 @item interrupt
4307 @cindex @code{interrupt} function attribute, AVR
4308 Use this attribute to indicate
4309 that the specified function is an interrupt handler.  The compiler generates
4310 function entry and exit sequences suitable for use in an interrupt handler
4311 when this attribute is present.
4313 On the AVR, the hardware globally disables interrupts when an
4314 interrupt is executed.  The first instruction of an interrupt handler
4315 declared with this attribute is a @code{SEI} instruction to
4316 re-enable interrupts.  See also the @code{signal} function attribute
4317 that does not insert a @code{SEI} instruction.  If both @code{signal} and
4318 @code{interrupt} are specified for the same function, @code{signal}
4319 is silently ignored.
4321 @item naked
4322 @cindex @code{naked} function attribute, AVR
4323 This attribute allows the compiler to construct the
4324 requisite function declaration, while allowing the body of the
4325 function to be assembly code. The specified function will not have
4326 prologue/epilogue sequences generated by the compiler. Only basic
4327 @code{asm} statements can safely be included in naked functions
4328 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
4329 basic @code{asm} and C code may appear to work, they cannot be
4330 depended upon to work reliably and are not supported.
4332 @item no_gccisr
4333 @cindex @code{no_gccisr} function attribute, AVR
4334 Do not use @code{__gcc_isr} pseudo instructions in a function with
4335 the @code{interrupt} or @code{signal} attribute aka. interrupt
4336 service routine (ISR).
4337 Use this attribute if the preamble of the ISR prologue should always read
4338 @example
4339 push  __zero_reg__
4340 push  __tmp_reg__
4341 in    __tmp_reg__, __SREG__
4342 push  __tmp_reg__
4343 clr   __zero_reg__
4344 @end example
4345 and accordingly for the postamble of the epilogue --- no matter whether
4346 the mentioned registers are actually used in the ISR or not.
4347 Situations where you might want to use this attribute include:
4348 @itemize @bullet
4349 @item
4350 Code that (effectively) clobbers bits of @code{SREG} other than the
4351 @code{I}-flag by writing to the memory location of @code{SREG}.
4352 @item
4353 Code that uses inline assembler to jump to a different function which
4354 expects (parts of) the prologue code as outlined above to be present.
4355 @end itemize
4356 To disable @code{__gcc_isr} generation for the whole compilation unit,
4357 there is option @option{-mno-gas-isr-prologues}, @pxref{AVR Options}.
4359 @item OS_main
4360 @itemx OS_task
4361 @cindex @code{OS_main} function attribute, AVR
4362 @cindex @code{OS_task} function attribute, AVR
4363 On AVR, functions with the @code{OS_main} or @code{OS_task} attribute
4364 do not save/restore any call-saved register in their prologue/epilogue.
4366 The @code{OS_main} attribute can be used when there @emph{is
4367 guarantee} that interrupts are disabled at the time when the function
4368 is entered.  This saves resources when the stack pointer has to be
4369 changed to set up a frame for local variables.
4371 The @code{OS_task} attribute can be used when there is @emph{no
4372 guarantee} that interrupts are disabled at that time when the function
4373 is entered like for, e@.g@. task functions in a multi-threading operating
4374 system. In that case, changing the stack pointer register is
4375 guarded by save/clear/restore of the global interrupt enable flag.
4377 The differences to the @code{naked} function attribute are:
4378 @itemize @bullet
4379 @item @code{naked} functions do not have a return instruction whereas 
4380 @code{OS_main} and @code{OS_task} functions have a @code{RET} or
4381 @code{RETI} return instruction.
4382 @item @code{naked} functions do not set up a frame for local variables
4383 or a frame pointer whereas @code{OS_main} and @code{OS_task} do this
4384 as needed.
4385 @end itemize
4387 @item signal
4388 @cindex @code{signal} function attribute, AVR
4389 Use this attribute on the AVR to indicate that the specified
4390 function is an interrupt handler.  The compiler generates function
4391 entry and exit sequences suitable for use in an interrupt handler when this
4392 attribute is present.
4394 See also the @code{interrupt} function attribute. 
4396 The AVR hardware globally disables interrupts when an interrupt is executed.
4397 Interrupt handler functions defined with the @code{signal} attribute
4398 do not re-enable interrupts.  It is save to enable interrupts in a
4399 @code{signal} handler.  This ``save'' only applies to the code
4400 generated by the compiler and not to the IRQ layout of the
4401 application which is responsibility of the application.
4403 If both @code{signal} and @code{interrupt} are specified for the same
4404 function, @code{signal} is silently ignored.
4405 @end table
4407 @node Blackfin Function Attributes
4408 @subsection Blackfin Function Attributes
4410 These function attributes are supported by the Blackfin back end:
4412 @table @code
4414 @item exception_handler
4415 @cindex @code{exception_handler} function attribute
4416 @cindex exception handler functions, Blackfin
4417 Use this attribute on the Blackfin to indicate that the specified function
4418 is an exception handler.  The compiler generates function entry and
4419 exit sequences suitable for use in an exception handler when this
4420 attribute is present.
4422 @item interrupt_handler
4423 @cindex @code{interrupt_handler} function attribute, Blackfin
4424 Use this attribute to
4425 indicate that the specified function is an interrupt handler.  The compiler
4426 generates function entry and exit sequences suitable for use in an
4427 interrupt handler when this attribute is present.
4429 @item kspisusp
4430 @cindex @code{kspisusp} function attribute, Blackfin
4431 @cindex User stack pointer in interrupts on the Blackfin
4432 When used together with @code{interrupt_handler}, @code{exception_handler}
4433 or @code{nmi_handler}, code is generated to load the stack pointer
4434 from the USP register in the function prologue.
4436 @item l1_text
4437 @cindex @code{l1_text} function attribute, Blackfin
4438 This attribute specifies a function to be placed into L1 Instruction
4439 SRAM@. The function is put into a specific section named @code{.l1.text}.
4440 With @option{-mfdpic}, function calls with a such function as the callee
4441 or caller uses inlined PLT.
4443 @item l2
4444 @cindex @code{l2} function attribute, Blackfin
4445 This attribute specifies a function to be placed into L2
4446 SRAM. The function is put into a specific section named
4447 @code{.l2.text}. With @option{-mfdpic}, callers of such functions use
4448 an inlined PLT.
4450 @item longcall
4451 @itemx shortcall
4452 @cindex indirect calls, Blackfin
4453 @cindex @code{longcall} function attribute, Blackfin
4454 @cindex @code{shortcall} function attribute, Blackfin
4455 The @code{longcall} attribute
4456 indicates that the function might be far away from the call site and
4457 require a different (more expensive) calling sequence.  The
4458 @code{shortcall} attribute indicates that the function is always close
4459 enough for the shorter calling sequence to be used.  These attributes
4460 override the @option{-mlongcall} switch.
4462 @item nesting
4463 @cindex @code{nesting} function attribute, Blackfin
4464 @cindex Allow nesting in an interrupt handler on the Blackfin processor
4465 Use this attribute together with @code{interrupt_handler},
4466 @code{exception_handler} or @code{nmi_handler} to indicate that the function
4467 entry code should enable nested interrupts or exceptions.
4469 @item nmi_handler
4470 @cindex @code{nmi_handler} function attribute, Blackfin
4471 @cindex NMI handler functions on the Blackfin processor
4472 Use this attribute on the Blackfin to indicate that the specified function
4473 is an NMI handler.  The compiler generates function entry and
4474 exit sequences suitable for use in an NMI handler when this
4475 attribute is present.
4477 @item saveall
4478 @cindex @code{saveall} function attribute, Blackfin
4479 @cindex save all registers on the Blackfin
4480 Use this attribute to indicate that
4481 all registers except the stack pointer should be saved in the prologue
4482 regardless of whether they are used or not.
4483 @end table
4485 @node CR16 Function Attributes
4486 @subsection CR16 Function Attributes
4488 These function attributes are supported by the CR16 back end:
4490 @table @code
4491 @item interrupt
4492 @cindex @code{interrupt} function attribute, CR16
4493 Use this attribute to indicate
4494 that the specified function is an interrupt handler.  The compiler generates
4495 function entry and exit sequences suitable for use in an interrupt handler
4496 when this attribute is present.
4497 @end table
4499 @node C-SKY Function Attributes
4500 @subsection C-SKY Function Attributes
4502 These function attributes are supported by the C-SKY back end:
4504 @table @code
4505 @item interrupt
4506 @itemx isr
4507 @cindex @code{interrupt} function attribute, C-SKY
4508 @cindex @code{isr} function attribute, C-SKY
4509 Use these attributes to indicate that the specified function
4510 is an interrupt handler.
4511 The compiler generates function entry and exit sequences suitable for
4512 use in an interrupt handler when either of these attributes are present.
4514 Use of these options requires the @option{-mistack} command-line option
4515 to enable support for the necessary interrupt stack instructions.  They
4516 are ignored with a warning otherwise.  @xref{C-SKY Options}.
4518 @item naked
4519 @cindex @code{naked} function attribute, C-SKY
4520 This attribute allows the compiler to construct the
4521 requisite function declaration, while allowing the body of the
4522 function to be assembly code. The specified function will not have
4523 prologue/epilogue sequences generated by the compiler. Only basic
4524 @code{asm} statements can safely be included in naked functions
4525 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
4526 basic @code{asm} and C code may appear to work, they cannot be
4527 depended upon to work reliably and are not supported.
4528 @end table
4531 @node Epiphany Function Attributes
4532 @subsection Epiphany Function Attributes
4534 These function attributes are supported by the Epiphany back end:
4536 @table @code
4537 @item disinterrupt
4538 @cindex @code{disinterrupt} function attribute, Epiphany
4539 This attribute causes the compiler to emit
4540 instructions to disable interrupts for the duration of the given
4541 function.
4543 @item forwarder_section
4544 @cindex @code{forwarder_section} function attribute, Epiphany
4545 This attribute modifies the behavior of an interrupt handler.
4546 The interrupt handler may be in external memory which cannot be
4547 reached by a branch instruction, so generate a local memory trampoline
4548 to transfer control.  The single parameter identifies the section where
4549 the trampoline is placed.
4551 @item interrupt
4552 @cindex @code{interrupt} function attribute, Epiphany
4553 Use this attribute to indicate
4554 that the specified function is an interrupt handler.  The compiler generates
4555 function entry and exit sequences suitable for use in an interrupt handler
4556 when this attribute is present.  It may also generate
4557 a special section with code to initialize the interrupt vector table.
4559 On Epiphany targets one or more optional parameters can be added like this:
4561 @smallexample
4562 void __attribute__ ((interrupt ("dma0, dma1"))) universal_dma_handler ();
4563 @end smallexample
4565 Permissible values for these parameters are: @w{@code{reset}},
4566 @w{@code{software_exception}}, @w{@code{page_miss}},
4567 @w{@code{timer0}}, @w{@code{timer1}}, @w{@code{message}},
4568 @w{@code{dma0}}, @w{@code{dma1}}, @w{@code{wand}} and @w{@code{swi}}.
4569 Multiple parameters indicate that multiple entries in the interrupt
4570 vector table should be initialized for this function, i.e.@: for each
4571 parameter @w{@var{name}}, a jump to the function is emitted in
4572 the section @w{ivt_entry_@var{name}}.  The parameter(s) may be omitted
4573 entirely, in which case no interrupt vector table entry is provided.
4575 Note that interrupts are enabled inside the function
4576 unless the @code{disinterrupt} attribute is also specified.
4578 The following examples are all valid uses of these attributes on
4579 Epiphany targets:
4580 @smallexample
4581 void __attribute__ ((interrupt)) universal_handler ();
4582 void __attribute__ ((interrupt ("dma1"))) dma1_handler ();
4583 void __attribute__ ((interrupt ("dma0, dma1"))) 
4584   universal_dma_handler ();
4585 void __attribute__ ((interrupt ("timer0"), disinterrupt))
4586   fast_timer_handler ();
4587 void __attribute__ ((interrupt ("dma0, dma1"), 
4588                      forwarder_section ("tramp")))
4589   external_dma_handler ();
4590 @end smallexample
4592 @item long_call
4593 @itemx short_call
4594 @cindex @code{long_call} function attribute, Epiphany
4595 @cindex @code{short_call} function attribute, Epiphany
4596 @cindex indirect calls, Epiphany
4597 These attributes specify how a particular function is called.
4598 These attributes override the
4599 @option{-mlong-calls} (@pxref{Adapteva Epiphany Options})
4600 command-line switch and @code{#pragma long_calls} settings.
4601 @end table
4604 @node H8/300 Function Attributes
4605 @subsection H8/300 Function Attributes
4607 These function attributes are available for H8/300 targets:
4609 @table @code
4610 @item function_vector
4611 @cindex @code{function_vector} function attribute, H8/300
4612 Use this attribute on the H8/300, H8/300H, and H8S to indicate 
4613 that the specified function should be called through the function vector.
4614 Calling a function through the function vector reduces code size; however,
4615 the function vector has a limited size (maximum 128 entries on the H8/300
4616 and 64 entries on the H8/300H and H8S)
4617 and shares space with the interrupt vector.
4619 @item interrupt_handler
4620 @cindex @code{interrupt_handler} function attribute, H8/300
4621 Use this attribute on the H8/300, H8/300H, and H8S to
4622 indicate that the specified function is an interrupt handler.  The compiler
4623 generates function entry and exit sequences suitable for use in an
4624 interrupt handler when this attribute is present.
4626 @item saveall
4627 @cindex @code{saveall} function attribute, H8/300
4628 @cindex save all registers on the H8/300, H8/300H, and H8S
4629 Use this attribute on the H8/300, H8/300H, and H8S to indicate that
4630 all registers except the stack pointer should be saved in the prologue
4631 regardless of whether they are used or not.
4632 @end table
4634 @node IA-64 Function Attributes
4635 @subsection IA-64 Function Attributes
4637 These function attributes are supported on IA-64 targets:
4639 @table @code
4640 @item syscall_linkage
4641 @cindex @code{syscall_linkage} function attribute, IA-64
4642 This attribute is used to modify the IA-64 calling convention by marking
4643 all input registers as live at all function exits.  This makes it possible
4644 to restart a system call after an interrupt without having to save/restore
4645 the input registers.  This also prevents kernel data from leaking into
4646 application code.
4648 @item version_id
4649 @cindex @code{version_id} function attribute, IA-64
4650 This IA-64 HP-UX attribute, attached to a global variable or function, renames a
4651 symbol to contain a version string, thus allowing for function level
4652 versioning.  HP-UX system header files may use function level versioning
4653 for some system calls.
4655 @smallexample
4656 extern int foo () __attribute__((version_id ("20040821")));
4657 @end smallexample
4659 @noindent
4660 Calls to @code{foo} are mapped to calls to @code{foo@{20040821@}}.
4661 @end table
4663 @node M32C Function Attributes
4664 @subsection M32C Function Attributes
4666 These function attributes are supported by the M32C back end:
4668 @table @code
4669 @item bank_switch
4670 @cindex @code{bank_switch} function attribute, M32C
4671 When added to an interrupt handler with the M32C port, causes the
4672 prologue and epilogue to use bank switching to preserve the registers
4673 rather than saving them on the stack.
4675 @item fast_interrupt
4676 @cindex @code{fast_interrupt} function attribute, M32C
4677 Use this attribute on the M32C port to indicate that the specified
4678 function is a fast interrupt handler.  This is just like the
4679 @code{interrupt} attribute, except that @code{freit} is used to return
4680 instead of @code{reit}.
4682 @item function_vector
4683 @cindex @code{function_vector} function attribute, M16C/M32C
4684 On M16C/M32C targets, the @code{function_vector} attribute declares a
4685 special page subroutine call function. Use of this attribute reduces
4686 the code size by 2 bytes for each call generated to the
4687 subroutine. The argument to the attribute is the vector number entry
4688 from the special page vector table which contains the 16 low-order
4689 bits of the subroutine's entry address. Each vector table has special
4690 page number (18 to 255) that is used in @code{jsrs} instructions.
4691 Jump addresses of the routines are generated by adding 0x0F0000 (in
4692 case of M16C targets) or 0xFF0000 (in case of M32C targets), to the
4693 2-byte addresses set in the vector table. Therefore you need to ensure
4694 that all the special page vector routines should get mapped within the
4695 address range 0x0F0000 to 0x0FFFFF (for M16C) and 0xFF0000 to 0xFFFFFF
4696 (for M32C).
4698 In the following example 2 bytes are saved for each call to
4699 function @code{foo}.
4701 @smallexample
4702 void foo (void) __attribute__((function_vector(0x18)));
4703 void foo (void)
4707 void bar (void)
4709     foo();
4711 @end smallexample
4713 If functions are defined in one file and are called in another file,
4714 then be sure to write this declaration in both files.
4716 This attribute is ignored for R8C target.
4718 @item interrupt
4719 @cindex @code{interrupt} function attribute, M32C
4720 Use this attribute to indicate
4721 that the specified function is an interrupt handler.  The compiler generates
4722 function entry and exit sequences suitable for use in an interrupt handler
4723 when this attribute is present.
4724 @end table
4726 @node M32R/D Function Attributes
4727 @subsection M32R/D Function Attributes
4729 These function attributes are supported by the M32R/D back end:
4731 @table @code
4732 @item interrupt
4733 @cindex @code{interrupt} function attribute, M32R/D
4734 Use this attribute to indicate
4735 that the specified function is an interrupt handler.  The compiler generates
4736 function entry and exit sequences suitable for use in an interrupt handler
4737 when this attribute is present.
4739 @item model (@var{model-name})
4740 @cindex @code{model} function attribute, M32R/D
4741 @cindex function addressability on the M32R/D
4743 On the M32R/D, use this attribute to set the addressability of an
4744 object, and of the code generated for a function.  The identifier
4745 @var{model-name} is one of @code{small}, @code{medium}, or
4746 @code{large}, representing each of the code models.
4748 Small model objects live in the lower 16MB of memory (so that their
4749 addresses can be loaded with the @code{ld24} instruction), and are
4750 callable with the @code{bl} instruction.
4752 Medium model objects may live anywhere in the 32-bit address space (the
4753 compiler generates @code{seth/add3} instructions to load their addresses),
4754 and are callable with the @code{bl} instruction.
4756 Large model objects may live anywhere in the 32-bit address space (the
4757 compiler generates @code{seth/add3} instructions to load their addresses),
4758 and may not be reachable with the @code{bl} instruction (the compiler
4759 generates the much slower @code{seth/add3/jl} instruction sequence).
4760 @end table
4762 @node m68k Function Attributes
4763 @subsection m68k Function Attributes
4765 These function attributes are supported by the m68k back end:
4767 @table @code
4768 @item interrupt
4769 @itemx interrupt_handler
4770 @cindex @code{interrupt} function attribute, m68k
4771 @cindex @code{interrupt_handler} function attribute, m68k
4772 Use this attribute to
4773 indicate that the specified function is an interrupt handler.  The compiler
4774 generates function entry and exit sequences suitable for use in an
4775 interrupt handler when this attribute is present.  Either name may be used.
4777 @item interrupt_thread
4778 @cindex @code{interrupt_thread} function attribute, fido
4779 Use this attribute on fido, a subarchitecture of the m68k, to indicate
4780 that the specified function is an interrupt handler that is designed
4781 to run as a thread.  The compiler omits generate prologue/epilogue
4782 sequences and replaces the return instruction with a @code{sleep}
4783 instruction.  This attribute is available only on fido.
4784 @end table
4786 @node MCORE Function Attributes
4787 @subsection MCORE Function Attributes
4789 These function attributes are supported by the MCORE back end:
4791 @table @code
4792 @item naked
4793 @cindex @code{naked} function attribute, MCORE
4794 This attribute allows the compiler to construct the
4795 requisite function declaration, while allowing the body of the
4796 function to be assembly code. The specified function will not have
4797 prologue/epilogue sequences generated by the compiler. Only basic
4798 @code{asm} statements can safely be included in naked functions
4799 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
4800 basic @code{asm} and C code may appear to work, they cannot be
4801 depended upon to work reliably and are not supported.
4802 @end table
4804 @node MeP Function Attributes
4805 @subsection MeP Function Attributes
4807 These function attributes are supported by the MeP back end:
4809 @table @code
4810 @item disinterrupt
4811 @cindex @code{disinterrupt} function attribute, MeP
4812 On MeP targets, this attribute causes the compiler to emit
4813 instructions to disable interrupts for the duration of the given
4814 function.
4816 @item interrupt
4817 @cindex @code{interrupt} function attribute, MeP
4818 Use this attribute to indicate
4819 that the specified function is an interrupt handler.  The compiler generates
4820 function entry and exit sequences suitable for use in an interrupt handler
4821 when this attribute is present.
4823 @item near
4824 @cindex @code{near} function attribute, MeP
4825 This attribute causes the compiler to assume the called
4826 function is close enough to use the normal calling convention,
4827 overriding the @option{-mtf} command-line option.
4829 @item far
4830 @cindex @code{far} function attribute, MeP
4831 On MeP targets this causes the compiler to use a calling convention
4832 that assumes the called function is too far away for the built-in
4833 addressing modes.
4835 @item vliw
4836 @cindex @code{vliw} function attribute, MeP
4837 The @code{vliw} attribute tells the compiler to emit
4838 instructions in VLIW mode instead of core mode.  Note that this
4839 attribute is not allowed unless a VLIW coprocessor has been configured
4840 and enabled through command-line options.
4841 @end table
4843 @node MicroBlaze Function Attributes
4844 @subsection MicroBlaze Function Attributes
4846 These function attributes are supported on MicroBlaze targets:
4848 @table @code
4849 @item save_volatiles
4850 @cindex @code{save_volatiles} function attribute, MicroBlaze
4851 Use this attribute to indicate that the function is
4852 an interrupt handler.  All volatile registers (in addition to non-volatile
4853 registers) are saved in the function prologue.  If the function is a leaf
4854 function, only volatiles used by the function are saved.  A normal function
4855 return is generated instead of a return from interrupt.
4857 @item break_handler
4858 @cindex @code{break_handler} function attribute, MicroBlaze
4859 @cindex break handler functions
4860 Use this attribute to indicate that
4861 the specified function is a break handler.  The compiler generates function
4862 entry and exit sequences suitable for use in an break handler when this
4863 attribute is present. The return from @code{break_handler} is done through
4864 the @code{rtbd} instead of @code{rtsd}.
4866 @smallexample
4867 void f () __attribute__ ((break_handler));
4868 @end smallexample
4870 @item interrupt_handler
4871 @itemx fast_interrupt 
4872 @cindex @code{interrupt_handler} function attribute, MicroBlaze
4873 @cindex @code{fast_interrupt} function attribute, MicroBlaze
4874 These attributes indicate that the specified function is an interrupt
4875 handler.  Use the @code{fast_interrupt} attribute to indicate handlers
4876 used in low-latency interrupt mode, and @code{interrupt_handler} for
4877 interrupts that do not use low-latency handlers.  In both cases, GCC
4878 emits appropriate prologue code and generates a return from the handler
4879 using @code{rtid} instead of @code{rtsd}.
4880 @end table
4882 @node Microsoft Windows Function Attributes
4883 @subsection Microsoft Windows Function Attributes
4885 The following attributes are available on Microsoft Windows and Symbian OS
4886 targets.
4888 @table @code
4889 @item dllexport
4890 @cindex @code{dllexport} function attribute
4891 @cindex @code{__declspec(dllexport)}
4892 On Microsoft Windows targets and Symbian OS targets the
4893 @code{dllexport} attribute causes the compiler to provide a global
4894 pointer to a pointer in a DLL, so that it can be referenced with the
4895 @code{dllimport} attribute.  On Microsoft Windows targets, the pointer
4896 name is formed by combining @code{_imp__} and the function or variable
4897 name.
4899 You can use @code{__declspec(dllexport)} as a synonym for
4900 @code{__attribute__ ((dllexport))} for compatibility with other
4901 compilers.
4903 On systems that support the @code{visibility} attribute, this
4904 attribute also implies ``default'' visibility.  It is an error to
4905 explicitly specify any other visibility.
4907 GCC's default behavior is to emit all inline functions with the
4908 @code{dllexport} attribute.  Since this can cause object file-size bloat,
4909 you can use @option{-fno-keep-inline-dllexport}, which tells GCC to
4910 ignore the attribute for inlined functions unless the 
4911 @option{-fkeep-inline-functions} flag is used instead.
4913 The attribute is ignored for undefined symbols.
4915 When applied to C++ classes, the attribute marks defined non-inlined
4916 member functions and static data members as exports.  Static consts
4917 initialized in-class are not marked unless they are also defined
4918 out-of-class.
4920 For Microsoft Windows targets there are alternative methods for
4921 including the symbol in the DLL's export table such as using a
4922 @file{.def} file with an @code{EXPORTS} section or, with GNU ld, using
4923 the @option{--export-all} linker flag.
4925 @item dllimport
4926 @cindex @code{dllimport} function attribute
4927 @cindex @code{__declspec(dllimport)}
4928 On Microsoft Windows and Symbian OS targets, the @code{dllimport}
4929 attribute causes the compiler to reference a function or variable via
4930 a global pointer to a pointer that is set up by the DLL exporting the
4931 symbol.  The attribute implies @code{extern}.  On Microsoft Windows
4932 targets, the pointer name is formed by combining @code{_imp__} and the
4933 function or variable name.
4935 You can use @code{__declspec(dllimport)} as a synonym for
4936 @code{__attribute__ ((dllimport))} for compatibility with other
4937 compilers.
4939 On systems that support the @code{visibility} attribute, this
4940 attribute also implies ``default'' visibility.  It is an error to
4941 explicitly specify any other visibility.
4943 Currently, the attribute is ignored for inlined functions.  If the
4944 attribute is applied to a symbol @emph{definition}, an error is reported.
4945 If a symbol previously declared @code{dllimport} is later defined, the
4946 attribute is ignored in subsequent references, and a warning is emitted.
4947 The attribute is also overridden by a subsequent declaration as
4948 @code{dllexport}.
4950 When applied to C++ classes, the attribute marks non-inlined
4951 member functions and static data members as imports.  However, the
4952 attribute is ignored for virtual methods to allow creation of vtables
4953 using thunks.
4955 On the SH Symbian OS target the @code{dllimport} attribute also has
4956 another affect---it can cause the vtable and run-time type information
4957 for a class to be exported.  This happens when the class has a
4958 dllimported constructor or a non-inline, non-pure virtual function
4959 and, for either of those two conditions, the class also has an inline
4960 constructor or destructor and has a key function that is defined in
4961 the current translation unit.
4963 For Microsoft Windows targets the use of the @code{dllimport}
4964 attribute on functions is not necessary, but provides a small
4965 performance benefit by eliminating a thunk in the DLL@.  The use of the
4966 @code{dllimport} attribute on imported variables can be avoided by passing the
4967 @option{--enable-auto-import} switch to the GNU linker.  As with
4968 functions, using the attribute for a variable eliminates a thunk in
4969 the DLL@.
4971 One drawback to using this attribute is that a pointer to a
4972 @emph{variable} marked as @code{dllimport} cannot be used as a constant
4973 address. However, a pointer to a @emph{function} with the
4974 @code{dllimport} attribute can be used as a constant initializer; in
4975 this case, the address of a stub function in the import lib is
4976 referenced.  On Microsoft Windows targets, the attribute can be disabled
4977 for functions by setting the @option{-mnop-fun-dllimport} flag.
4978 @end table
4980 @node MIPS Function Attributes
4981 @subsection MIPS Function Attributes
4983 These function attributes are supported by the MIPS back end:
4985 @table @code
4986 @item interrupt
4987 @cindex @code{interrupt} function attribute, MIPS
4988 Use this attribute to indicate that the specified function is an interrupt
4989 handler.  The compiler generates function entry and exit sequences suitable
4990 for use in an interrupt handler when this attribute is present.
4991 An optional argument is supported for the interrupt attribute which allows
4992 the interrupt mode to be described.  By default GCC assumes the external
4993 interrupt controller (EIC) mode is in use, this can be explicitly set using
4994 @code{eic}.  When interrupts are non-masked then the requested Interrupt
4995 Priority Level (IPL) is copied to the current IPL which has the effect of only
4996 enabling higher priority interrupts.  To use vectored interrupt mode use
4997 the argument @code{vector=[sw0|sw1|hw0|hw1|hw2|hw3|hw4|hw5]}, this will change
4998 the behavior of the non-masked interrupt support and GCC will arrange to mask
4999 all interrupts from sw0 up to and including the specified interrupt vector.
5001 You can use the following attributes to modify the behavior
5002 of an interrupt handler:
5003 @table @code
5004 @item use_shadow_register_set
5005 @cindex @code{use_shadow_register_set} function attribute, MIPS
5006 Assume that the handler uses a shadow register set, instead of
5007 the main general-purpose registers.  An optional argument @code{intstack} is
5008 supported to indicate that the shadow register set contains a valid stack
5009 pointer.
5011 @item keep_interrupts_masked
5012 @cindex @code{keep_interrupts_masked} function attribute, MIPS
5013 Keep interrupts masked for the whole function.  Without this attribute,
5014 GCC tries to reenable interrupts for as much of the function as it can.
5016 @item use_debug_exception_return
5017 @cindex @code{use_debug_exception_return} function attribute, MIPS
5018 Return using the @code{deret} instruction.  Interrupt handlers that don't
5019 have this attribute return using @code{eret} instead.
5020 @end table
5022 You can use any combination of these attributes, as shown below:
5023 @smallexample
5024 void __attribute__ ((interrupt)) v0 ();
5025 void __attribute__ ((interrupt, use_shadow_register_set)) v1 ();
5026 void __attribute__ ((interrupt, keep_interrupts_masked)) v2 ();
5027 void __attribute__ ((interrupt, use_debug_exception_return)) v3 ();
5028 void __attribute__ ((interrupt, use_shadow_register_set,
5029                      keep_interrupts_masked)) v4 ();
5030 void __attribute__ ((interrupt, use_shadow_register_set,
5031                      use_debug_exception_return)) v5 ();
5032 void __attribute__ ((interrupt, keep_interrupts_masked,
5033                      use_debug_exception_return)) v6 ();
5034 void __attribute__ ((interrupt, use_shadow_register_set,
5035                      keep_interrupts_masked,
5036                      use_debug_exception_return)) v7 ();
5037 void __attribute__ ((interrupt("eic"))) v8 ();
5038 void __attribute__ ((interrupt("vector=hw3"))) v9 ();
5039 @end smallexample
5041 @item long_call
5042 @itemx short_call
5043 @itemx near
5044 @itemx far
5045 @cindex indirect calls, MIPS
5046 @cindex @code{long_call} function attribute, MIPS
5047 @cindex @code{short_call} function attribute, MIPS
5048 @cindex @code{near} function attribute, MIPS
5049 @cindex @code{far} function attribute, MIPS
5050 These attributes specify how a particular function is called on MIPS@.
5051 The attributes override the @option{-mlong-calls} (@pxref{MIPS Options})
5052 command-line switch.  The @code{long_call} and @code{far} attributes are
5053 synonyms, and cause the compiler to always call
5054 the function by first loading its address into a register, and then using
5055 the contents of that register.  The @code{short_call} and @code{near}
5056 attributes are synonyms, and have the opposite
5057 effect; they specify that non-PIC calls should be made using the more
5058 efficient @code{jal} instruction.
5060 @item mips16
5061 @itemx nomips16
5062 @cindex @code{mips16} function attribute, MIPS
5063 @cindex @code{nomips16} function attribute, MIPS
5065 On MIPS targets, you can use the @code{mips16} and @code{nomips16}
5066 function attributes to locally select or turn off MIPS16 code generation.
5067 A function with the @code{mips16} attribute is emitted as MIPS16 code,
5068 while MIPS16 code generation is disabled for functions with the
5069 @code{nomips16} attribute.  These attributes override the
5070 @option{-mips16} and @option{-mno-mips16} options on the command line
5071 (@pxref{MIPS Options}).
5073 When compiling files containing mixed MIPS16 and non-MIPS16 code, the
5074 preprocessor symbol @code{__mips16} reflects the setting on the command line,
5075 not that within individual functions.  Mixed MIPS16 and non-MIPS16 code
5076 may interact badly with some GCC extensions such as @code{__builtin_apply}
5077 (@pxref{Constructing Calls}).
5079 @item micromips, MIPS
5080 @itemx nomicromips, MIPS
5081 @cindex @code{micromips} function attribute
5082 @cindex @code{nomicromips} function attribute
5084 On MIPS targets, you can use the @code{micromips} and @code{nomicromips}
5085 function attributes to locally select or turn off microMIPS code generation.
5086 A function with the @code{micromips} attribute is emitted as microMIPS code,
5087 while microMIPS code generation is disabled for functions with the
5088 @code{nomicromips} attribute.  These attributes override the
5089 @option{-mmicromips} and @option{-mno-micromips} options on the command line
5090 (@pxref{MIPS Options}).
5092 When compiling files containing mixed microMIPS and non-microMIPS code, the
5093 preprocessor symbol @code{__mips_micromips} reflects the setting on the
5094 command line,
5095 not that within individual functions.  Mixed microMIPS and non-microMIPS code
5096 may interact badly with some GCC extensions such as @code{__builtin_apply}
5097 (@pxref{Constructing Calls}).
5099 @item nocompression
5100 @cindex @code{nocompression} function attribute, MIPS
5101 On MIPS targets, you can use the @code{nocompression} function attribute
5102 to locally turn off MIPS16 and microMIPS code generation.  This attribute
5103 overrides the @option{-mips16} and @option{-mmicromips} options on the
5104 command line (@pxref{MIPS Options}).
5105 @end table
5107 @node MSP430 Function Attributes
5108 @subsection MSP430 Function Attributes
5110 These function attributes are supported by the MSP430 back end:
5112 @table @code
5113 @item critical
5114 @cindex @code{critical} function attribute, MSP430
5115 Critical functions disable interrupts upon entry and restore the
5116 previous interrupt state upon exit.  Critical functions cannot also
5117 have the @code{naked}, @code{reentrant} or @code{interrupt} attributes.
5119 The MSP430 hardware ensures that interrupts are disabled on entry to
5120 @code{interrupt} functions, and restores the previous interrupt state
5121 on exit. The @code{critical} attribute is therefore redundant on
5122 @code{interrupt} functions.
5124 @item interrupt
5125 @cindex @code{interrupt} function attribute, MSP430
5126 Use this attribute to indicate
5127 that the specified function is an interrupt handler.  The compiler generates
5128 function entry and exit sequences suitable for use in an interrupt handler
5129 when this attribute is present.
5131 You can provide an argument to the interrupt
5132 attribute which specifies a name or number.  If the argument is a
5133 number it indicates the slot in the interrupt vector table (0 - 31) to
5134 which this handler should be assigned.  If the argument is a name it
5135 is treated as a symbolic name for the vector slot.  These names should
5136 match up with appropriate entries in the linker script.  By default
5137 the names @code{watchdog} for vector 26, @code{nmi} for vector 30 and
5138 @code{reset} for vector 31 are recognized.
5140 @item naked
5141 @cindex @code{naked} function attribute, MSP430
5142 This attribute allows the compiler to construct the
5143 requisite function declaration, while allowing the body of the
5144 function to be assembly code. The specified function will not have
5145 prologue/epilogue sequences generated by the compiler. Only basic
5146 @code{asm} statements can safely be included in naked functions
5147 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
5148 basic @code{asm} and C code may appear to work, they cannot be
5149 depended upon to work reliably and are not supported.
5151 @item reentrant
5152 @cindex @code{reentrant} function attribute, MSP430
5153 Reentrant functions disable interrupts upon entry and enable them
5154 upon exit.  Reentrant functions cannot also have the @code{naked}
5155 or @code{critical} attributes.  They can have the @code{interrupt}
5156 attribute.
5158 @item wakeup
5159 @cindex @code{wakeup} function attribute, MSP430
5160 This attribute only applies to interrupt functions.  It is silently
5161 ignored if applied to a non-interrupt function.  A wakeup interrupt
5162 function will rouse the processor from any low-power state that it
5163 might be in when the function exits.
5165 @item lower
5166 @itemx upper
5167 @itemx either
5168 @cindex @code{lower} function attribute, MSP430
5169 @cindex @code{upper} function attribute, MSP430
5170 @cindex @code{either} function attribute, MSP430
5171 On the MSP430 target these attributes can be used to specify whether
5172 the function or variable should be placed into low memory, high
5173 memory, or the placement should be left to the linker to decide.  The
5174 attributes are only significant if compiling for the MSP430X
5175 architecture.
5177 The attributes work in conjunction with a linker script that has been
5178 augmented to specify where to place sections with a @code{.lower} and
5179 a @code{.upper} prefix.  So, for example, as well as placing the
5180 @code{.data} section, the script also specifies the placement of a
5181 @code{.lower.data} and a @code{.upper.data} section.  The intention
5182 is that @code{lower} sections are placed into a small but easier to
5183 access memory region and the upper sections are placed into a larger, but
5184 slower to access, region.
5186 The @code{either} attribute is special.  It tells the linker to place
5187 the object into the corresponding @code{lower} section if there is
5188 room for it.  If there is insufficient room then the object is placed
5189 into the corresponding @code{upper} section instead.  Note that the
5190 placement algorithm is not very sophisticated.  It does not attempt to
5191 find an optimal packing of the @code{lower} sections.  It just makes
5192 one pass over the objects and does the best that it can.  Using the
5193 @option{-ffunction-sections} and @option{-fdata-sections} command-line
5194 options can help the packing, however, since they produce smaller,
5195 easier to pack regions.
5196 @end table
5198 @node NDS32 Function Attributes
5199 @subsection NDS32 Function Attributes
5201 These function attributes are supported by the NDS32 back end:
5203 @table @code
5204 @item exception
5205 @cindex @code{exception} function attribute
5206 @cindex exception handler functions, NDS32
5207 Use this attribute on the NDS32 target to indicate that the specified function
5208 is an exception handler.  The compiler will generate corresponding sections
5209 for use in an exception handler.
5211 @item interrupt
5212 @cindex @code{interrupt} function attribute, NDS32
5213 On NDS32 target, this attribute indicates that the specified function
5214 is an interrupt handler.  The compiler generates corresponding sections
5215 for use in an interrupt handler.  You can use the following attributes
5216 to modify the behavior:
5217 @table @code
5218 @item nested
5219 @cindex @code{nested} function attribute, NDS32
5220 This interrupt service routine is interruptible.
5221 @item not_nested
5222 @cindex @code{not_nested} function attribute, NDS32
5223 This interrupt service routine is not interruptible.
5224 @item nested_ready
5225 @cindex @code{nested_ready} function attribute, NDS32
5226 This interrupt service routine is interruptible after @code{PSW.GIE}
5227 (global interrupt enable) is set.  This allows interrupt service routine to
5228 finish some short critical code before enabling interrupts.
5229 @item save_all
5230 @cindex @code{save_all} function attribute, NDS32
5231 The system will help save all registers into stack before entering
5232 interrupt handler.
5233 @item partial_save
5234 @cindex @code{partial_save} function attribute, NDS32
5235 The system will help save caller registers into stack before entering
5236 interrupt handler.
5237 @end table
5239 @item naked
5240 @cindex @code{naked} function attribute, NDS32
5241 This attribute allows the compiler to construct the
5242 requisite function declaration, while allowing the body of the
5243 function to be assembly code. The specified function will not have
5244 prologue/epilogue sequences generated by the compiler. Only basic
5245 @code{asm} statements can safely be included in naked functions
5246 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
5247 basic @code{asm} and C code may appear to work, they cannot be
5248 depended upon to work reliably and are not supported.
5250 @item reset
5251 @cindex @code{reset} function attribute, NDS32
5252 @cindex reset handler functions
5253 Use this attribute on the NDS32 target to indicate that the specified function
5254 is a reset handler.  The compiler will generate corresponding sections
5255 for use in a reset handler.  You can use the following attributes
5256 to provide extra exception handling:
5257 @table @code
5258 @item nmi
5259 @cindex @code{nmi} function attribute, NDS32
5260 Provide a user-defined function to handle NMI exception.
5261 @item warm
5262 @cindex @code{warm} function attribute, NDS32
5263 Provide a user-defined function to handle warm reset exception.
5264 @end table
5265 @end table
5267 @node Nios II Function Attributes
5268 @subsection Nios II Function Attributes
5270 These function attributes are supported by the Nios II back end:
5272 @table @code
5273 @item target (@var{options})
5274 @cindex @code{target} function attribute
5275 As discussed in @ref{Common Function Attributes}, this attribute 
5276 allows specification of target-specific compilation options.
5278 When compiling for Nios II, the following options are allowed:
5280 @table @samp
5281 @item custom-@var{insn}=@var{N}
5282 @itemx no-custom-@var{insn}
5283 @cindex @code{target("custom-@var{insn}=@var{N}")} function attribute, Nios II
5284 @cindex @code{target("no-custom-@var{insn}")} function attribute, Nios II
5285 Each @samp{custom-@var{insn}=@var{N}} attribute locally enables use of a
5286 custom instruction with encoding @var{N} when generating code that uses 
5287 @var{insn}.  Similarly, @samp{no-custom-@var{insn}} locally inhibits use of
5288 the custom instruction @var{insn}.
5289 These target attributes correspond to the
5290 @option{-mcustom-@var{insn}=@var{N}} and @option{-mno-custom-@var{insn}}
5291 command-line options, and support the same set of @var{insn} keywords.
5292 @xref{Nios II Options}, for more information.
5294 @item custom-fpu-cfg=@var{name}
5295 @cindex @code{target("custom-fpu-cfg=@var{name}")} function attribute, Nios II
5296 This attribute corresponds to the @option{-mcustom-fpu-cfg=@var{name}}
5297 command-line option, to select a predefined set of custom instructions
5298 named @var{name}.
5299 @xref{Nios II Options}, for more information.
5300 @end table
5301 @end table
5303 @node Nvidia PTX Function Attributes
5304 @subsection Nvidia PTX Function Attributes
5306 These function attributes are supported by the Nvidia PTX back end:
5308 @table @code
5309 @item kernel
5310 @cindex @code{kernel} attribute, Nvidia PTX
5311 This attribute indicates that the corresponding function should be compiled
5312 as a kernel function, which can be invoked from the host via the CUDA RT 
5313 library.
5314 By default functions are only callable only from other PTX functions.
5316 Kernel functions must have @code{void} return type.
5317 @end table
5319 @node PowerPC Function Attributes
5320 @subsection PowerPC Function Attributes
5322 These function attributes are supported by the PowerPC back end:
5324 @table @code
5325 @item longcall
5326 @itemx shortcall
5327 @cindex indirect calls, PowerPC
5328 @cindex @code{longcall} function attribute, PowerPC
5329 @cindex @code{shortcall} function attribute, PowerPC
5330 The @code{longcall} attribute
5331 indicates that the function might be far away from the call site and
5332 require a different (more expensive) calling sequence.  The
5333 @code{shortcall} attribute indicates that the function is always close
5334 enough for the shorter calling sequence to be used.  These attributes
5335 override both the @option{-mlongcall} switch and
5336 the @code{#pragma longcall} setting.
5338 @xref{RS/6000 and PowerPC Options}, for more information on whether long
5339 calls are necessary.
5341 @item target (@var{options})
5342 @cindex @code{target} function attribute
5343 As discussed in @ref{Common Function Attributes}, this attribute 
5344 allows specification of target-specific compilation options.
5346 On the PowerPC, the following options are allowed:
5348 @table @samp
5349 @item altivec
5350 @itemx no-altivec
5351 @cindex @code{target("altivec")} function attribute, PowerPC
5352 Generate code that uses (does not use) AltiVec instructions.  In
5353 32-bit code, you cannot enable AltiVec instructions unless
5354 @option{-mabi=altivec} is used on the command line.
5356 @item cmpb
5357 @itemx no-cmpb
5358 @cindex @code{target("cmpb")} function attribute, PowerPC
5359 Generate code that uses (does not use) the compare bytes instruction
5360 implemented on the POWER6 processor and other processors that support
5361 the PowerPC V2.05 architecture.
5363 @item dlmzb
5364 @itemx no-dlmzb
5365 @cindex @code{target("dlmzb")} function attribute, PowerPC
5366 Generate code that uses (does not use) the string-search @samp{dlmzb}
5367 instruction on the IBM 405, 440, 464 and 476 processors.  This instruction is
5368 generated by default when targeting those processors.
5370 @item fprnd
5371 @itemx no-fprnd
5372 @cindex @code{target("fprnd")} function attribute, PowerPC
5373 Generate code that uses (does not use) the FP round to integer
5374 instructions implemented on the POWER5+ processor and other processors
5375 that support the PowerPC V2.03 architecture.
5377 @item hard-dfp
5378 @itemx no-hard-dfp
5379 @cindex @code{target("hard-dfp")} function attribute, PowerPC
5380 Generate code that uses (does not use) the decimal floating-point
5381 instructions implemented on some POWER processors.
5383 @item isel
5384 @itemx no-isel
5385 @cindex @code{target("isel")} function attribute, PowerPC
5386 Generate code that uses (does not use) ISEL instruction.
5388 @item mfcrf
5389 @itemx no-mfcrf
5390 @cindex @code{target("mfcrf")} function attribute, PowerPC
5391 Generate code that uses (does not use) the move from condition
5392 register field instruction implemented on the POWER4 processor and
5393 other processors that support the PowerPC V2.01 architecture.
5395 @item mfpgpr
5396 @itemx no-mfpgpr
5397 @cindex @code{target("mfpgpr")} function attribute, PowerPC
5398 Generate code that uses (does not use) the FP move to/from general
5399 purpose register instructions implemented on the POWER6X processor and
5400 other processors that support the extended PowerPC V2.05 architecture.
5402 @item mulhw
5403 @itemx no-mulhw
5404 @cindex @code{target("mulhw")} function attribute, PowerPC
5405 Generate code that uses (does not use) the half-word multiply and
5406 multiply-accumulate instructions on the IBM 405, 440, 464 and 476 processors.
5407 These instructions are generated by default when targeting those
5408 processors.
5410 @item multiple
5411 @itemx no-multiple
5412 @cindex @code{target("multiple")} function attribute, PowerPC
5413 Generate code that uses (does not use) the load multiple word
5414 instructions and the store multiple word instructions.
5416 @item update
5417 @itemx no-update
5418 @cindex @code{target("update")} function attribute, PowerPC
5419 Generate code that uses (does not use) the load or store instructions
5420 that update the base register to the address of the calculated memory
5421 location.
5423 @item popcntb
5424 @itemx no-popcntb
5425 @cindex @code{target("popcntb")} function attribute, PowerPC
5426 Generate code that uses (does not use) the popcount and double-precision
5427 FP reciprocal estimate instruction implemented on the POWER5
5428 processor and other processors that support the PowerPC V2.02
5429 architecture.
5431 @item popcntd
5432 @itemx no-popcntd
5433 @cindex @code{target("popcntd")} function attribute, PowerPC
5434 Generate code that uses (does not use) the popcount instruction
5435 implemented on the POWER7 processor and other processors that support
5436 the PowerPC V2.06 architecture.
5438 @item powerpc-gfxopt
5439 @itemx no-powerpc-gfxopt
5440 @cindex @code{target("powerpc-gfxopt")} function attribute, PowerPC
5441 Generate code that uses (does not use) the optional PowerPC
5442 architecture instructions in the Graphics group, including
5443 floating-point select.
5445 @item powerpc-gpopt
5446 @itemx no-powerpc-gpopt
5447 @cindex @code{target("powerpc-gpopt")} function attribute, PowerPC
5448 Generate code that uses (does not use) the optional PowerPC
5449 architecture instructions in the General Purpose group, including
5450 floating-point square root.
5452 @item recip-precision
5453 @itemx no-recip-precision
5454 @cindex @code{target("recip-precision")} function attribute, PowerPC
5455 Assume (do not assume) that the reciprocal estimate instructions
5456 provide higher-precision estimates than is mandated by the PowerPC
5457 ABI.
5459 @item string
5460 @itemx no-string
5461 @cindex @code{target("string")} function attribute, PowerPC
5462 Generate code that uses (does not use) the load string instructions
5463 and the store string word instructions to save multiple registers and
5464 do small block moves.
5466 @item vsx
5467 @itemx no-vsx
5468 @cindex @code{target("vsx")} function attribute, PowerPC
5469 Generate code that uses (does not use) vector/scalar (VSX)
5470 instructions, and also enable the use of built-in functions that allow
5471 more direct access to the VSX instruction set.  In 32-bit code, you
5472 cannot enable VSX or AltiVec instructions unless
5473 @option{-mabi=altivec} is used on the command line.
5475 @item friz
5476 @itemx no-friz
5477 @cindex @code{target("friz")} function attribute, PowerPC
5478 Generate (do not generate) the @code{friz} instruction when the
5479 @option{-funsafe-math-optimizations} option is used to optimize
5480 rounding a floating-point value to 64-bit integer and back to floating
5481 point.  The @code{friz} instruction does not return the same value if
5482 the floating-point number is too large to fit in an integer.
5484 @item avoid-indexed-addresses
5485 @itemx no-avoid-indexed-addresses
5486 @cindex @code{target("avoid-indexed-addresses")} function attribute, PowerPC
5487 Generate code that tries to avoid (not avoid) the use of indexed load
5488 or store instructions.
5490 @item paired
5491 @itemx no-paired
5492 @cindex @code{target("paired")} function attribute, PowerPC
5493 Generate code that uses (does not use) the generation of PAIRED simd
5494 instructions.
5496 @item longcall
5497 @itemx no-longcall
5498 @cindex @code{target("longcall")} function attribute, PowerPC
5499 Generate code that assumes (does not assume) that all calls are far
5500 away so that a longer more expensive calling sequence is required.
5502 @item cpu=@var{CPU}
5503 @cindex @code{target("cpu=@var{CPU}")} function attribute, PowerPC
5504 Specify the architecture to generate code for when compiling the
5505 function.  If you select the @code{target("cpu=power7")} attribute when
5506 generating 32-bit code, VSX and AltiVec instructions are not generated
5507 unless you use the @option{-mabi=altivec} option on the command line.
5509 @item tune=@var{TUNE}
5510 @cindex @code{target("tune=@var{TUNE}")} function attribute, PowerPC
5511 Specify the architecture to tune for when compiling the function.  If
5512 you do not specify the @code{target("tune=@var{TUNE}")} attribute and
5513 you do specify the @code{target("cpu=@var{CPU}")} attribute,
5514 compilation tunes for the @var{CPU} architecture, and not the
5515 default tuning specified on the command line.
5516 @end table
5518 On the PowerPC, the inliner does not inline a
5519 function that has different target options than the caller, unless the
5520 callee has a subset of the target options of the caller.
5521 @end table
5523 @node RISC-V Function Attributes
5524 @subsection RISC-V Function Attributes
5526 These function attributes are supported by the RISC-V back end:
5528 @table @code
5529 @item naked
5530 @cindex @code{naked} function attribute, RISC-V
5531 This attribute allows the compiler to construct the
5532 requisite function declaration, while allowing the body of the
5533 function to be assembly code. The specified function will not have
5534 prologue/epilogue sequences generated by the compiler. Only basic
5535 @code{asm} statements can safely be included in naked functions
5536 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
5537 basic @code{asm} and C code may appear to work, they cannot be
5538 depended upon to work reliably and are not supported.
5540 @item interrupt
5541 @cindex @code{interrupt} function attribute, RISC-V
5542 Use this attribute to indicate that the specified function is an interrupt
5543 handler.  The compiler generates function entry and exit sequences suitable
5544 for use in an interrupt handler when this attribute is present.
5546 You can specify the kind of interrupt to be handled by adding an optional
5547 parameter to the interrupt attribute like this:
5549 @smallexample
5550 void f (void) __attribute__ ((interrupt ("user")));
5551 @end smallexample
5553 Permissible values for this parameter are @code{user}, @code{supervisor},
5554 and @code{machine}.  If there is no parameter, then it defaults to
5555 @code{machine}.
5556 @end table
5558 @node RL78 Function Attributes
5559 @subsection RL78 Function Attributes
5561 These function attributes are supported by the RL78 back end:
5563 @table @code
5564 @item interrupt
5565 @itemx brk_interrupt
5566 @cindex @code{interrupt} function attribute, RL78
5567 @cindex @code{brk_interrupt} function attribute, RL78
5568 These attributes indicate
5569 that the specified function is an interrupt handler.  The compiler generates
5570 function entry and exit sequences suitable for use in an interrupt handler
5571 when this attribute is present.
5573 Use @code{brk_interrupt} instead of @code{interrupt} for
5574 handlers intended to be used with the @code{BRK} opcode (i.e.@: those
5575 that must end with @code{RETB} instead of @code{RETI}).
5577 @item naked
5578 @cindex @code{naked} function attribute, RL78
5579 This attribute allows the compiler to construct the
5580 requisite function declaration, while allowing the body of the
5581 function to be assembly code. The specified function will not have
5582 prologue/epilogue sequences generated by the compiler. Only basic
5583 @code{asm} statements can safely be included in naked functions
5584 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
5585 basic @code{asm} and C code may appear to work, they cannot be
5586 depended upon to work reliably and are not supported.
5587 @end table
5589 @node RX Function Attributes
5590 @subsection RX Function Attributes
5592 These function attributes are supported by the RX back end:
5594 @table @code
5595 @item fast_interrupt
5596 @cindex @code{fast_interrupt} function attribute, RX
5597 Use this attribute on the RX port to indicate that the specified
5598 function is a fast interrupt handler.  This is just like the
5599 @code{interrupt} attribute, except that @code{freit} is used to return
5600 instead of @code{reit}.
5602 @item interrupt
5603 @cindex @code{interrupt} function attribute, RX
5604 Use this attribute to indicate
5605 that the specified function is an interrupt handler.  The compiler generates
5606 function entry and exit sequences suitable for use in an interrupt handler
5607 when this attribute is present.
5609 On RX and RL78 targets, you may specify one or more vector numbers as arguments
5610 to the attribute, as well as naming an alternate table name.
5611 Parameters are handled sequentially, so one handler can be assigned to
5612 multiple entries in multiple tables.  One may also pass the magic
5613 string @code{"$default"} which causes the function to be used for any
5614 unfilled slots in the current table.
5616 This example shows a simple assignment of a function to one vector in
5617 the default table (note that preprocessor macros may be used for
5618 chip-specific symbolic vector names):
5619 @smallexample
5620 void __attribute__ ((interrupt (5))) txd1_handler ();
5621 @end smallexample
5623 This example assigns a function to two slots in the default table
5624 (using preprocessor macros defined elsewhere) and makes it the default
5625 for the @code{dct} table:
5626 @smallexample
5627 void __attribute__ ((interrupt (RXD1_VECT,RXD2_VECT,"dct","$default")))
5628         txd1_handler ();
5629 @end smallexample
5631 @item naked
5632 @cindex @code{naked} function attribute, RX
5633 This attribute allows the compiler to construct the
5634 requisite function declaration, while allowing the body of the
5635 function to be assembly code. The specified function will not have
5636 prologue/epilogue sequences generated by the compiler. Only basic
5637 @code{asm} statements can safely be included in naked functions
5638 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
5639 basic @code{asm} and C code may appear to work, they cannot be
5640 depended upon to work reliably and are not supported.
5642 @item vector
5643 @cindex @code{vector} function attribute, RX
5644 This RX attribute is similar to the @code{interrupt} attribute, including its
5645 parameters, but does not make the function an interrupt-handler type
5646 function (i.e.@: it retains the normal C function calling ABI).  See the
5647 @code{interrupt} attribute for a description of its arguments.
5648 @end table
5650 @node S/390 Function Attributes
5651 @subsection S/390 Function Attributes
5653 These function attributes are supported on the S/390:
5655 @table @code
5656 @item hotpatch (@var{halfwords-before-function-label},@var{halfwords-after-function-label})
5657 @cindex @code{hotpatch} function attribute, S/390
5659 On S/390 System z targets, you can use this function attribute to
5660 make GCC generate a ``hot-patching'' function prologue.  If the
5661 @option{-mhotpatch=} command-line option is used at the same time,
5662 the @code{hotpatch} attribute takes precedence.  The first of the
5663 two arguments specifies the number of halfwords to be added before
5664 the function label.  A second argument can be used to specify the
5665 number of halfwords to be added after the function label.  For
5666 both arguments the maximum allowed value is 1000000.
5668 If both arguments are zero, hotpatching is disabled.
5670 @item target (@var{options})
5671 @cindex @code{target} function attribute
5672 As discussed in @ref{Common Function Attributes}, this attribute
5673 allows specification of target-specific compilation options.
5675 On S/390, the following options are supported:
5677 @table @samp
5678 @item arch=
5679 @item tune=
5680 @item stack-guard=
5681 @item stack-size=
5682 @item branch-cost=
5683 @item warn-framesize=
5684 @item backchain
5685 @itemx no-backchain
5686 @item hard-dfp
5687 @itemx no-hard-dfp
5688 @item hard-float
5689 @itemx soft-float
5690 @item htm
5691 @itemx no-htm
5692 @item vx
5693 @itemx no-vx
5694 @item packed-stack
5695 @itemx no-packed-stack
5696 @item small-exec
5697 @itemx no-small-exec
5698 @item mvcle
5699 @itemx no-mvcle
5700 @item warn-dynamicstack
5701 @itemx no-warn-dynamicstack
5702 @end table
5704 The options work exactly like the S/390 specific command line
5705 options (without the prefix @option{-m}) except that they do not
5706 change any feature macros.  For example,
5708 @smallexample
5709 @code{target("no-vx")}
5710 @end smallexample
5712 does not undefine the @code{__VEC__} macro.
5713 @end table
5715 @node SH Function Attributes
5716 @subsection SH Function Attributes
5718 These function attributes are supported on the SH family of processors:
5720 @table @code
5721 @item function_vector
5722 @cindex @code{function_vector} function attribute, SH
5723 @cindex calling functions through the function vector on SH2A
5724 On SH2A targets, this attribute declares a function to be called using the
5725 TBR relative addressing mode.  The argument to this attribute is the entry
5726 number of the same function in a vector table containing all the TBR
5727 relative addressable functions.  For correct operation the TBR must be setup
5728 accordingly to point to the start of the vector table before any functions with
5729 this attribute are invoked.  Usually a good place to do the initialization is
5730 the startup routine.  The TBR relative vector table can have at max 256 function
5731 entries.  The jumps to these functions are generated using a SH2A specific,
5732 non delayed branch instruction JSR/N @@(disp8,TBR).  You must use GAS and GLD
5733 from GNU binutils version 2.7 or later for this attribute to work correctly.
5735 In an application, for a function being called once, this attribute
5736 saves at least 8 bytes of code; and if other successive calls are being
5737 made to the same function, it saves 2 bytes of code per each of these
5738 calls.
5740 @item interrupt_handler
5741 @cindex @code{interrupt_handler} function attribute, SH
5742 Use this attribute to
5743 indicate that the specified function is an interrupt handler.  The compiler
5744 generates function entry and exit sequences suitable for use in an
5745 interrupt handler when this attribute is present.
5747 @item nosave_low_regs
5748 @cindex @code{nosave_low_regs} function attribute, SH
5749 Use this attribute on SH targets to indicate that an @code{interrupt_handler}
5750 function should not save and restore registers R0..R7.  This can be used on SH3*
5751 and SH4* targets that have a second R0..R7 register bank for non-reentrant
5752 interrupt handlers.
5754 @item renesas
5755 @cindex @code{renesas} function attribute, SH
5756 On SH targets this attribute specifies that the function or struct follows the
5757 Renesas ABI.
5759 @item resbank
5760 @cindex @code{resbank} function attribute, SH
5761 On the SH2A target, this attribute enables the high-speed register
5762 saving and restoration using a register bank for @code{interrupt_handler}
5763 routines.  Saving to the bank is performed automatically after the CPU
5764 accepts an interrupt that uses a register bank.
5766 The nineteen 32-bit registers comprising general register R0 to R14,
5767 control register GBR, and system registers MACH, MACL, and PR and the
5768 vector table address offset are saved into a register bank.  Register
5769 banks are stacked in first-in last-out (FILO) sequence.  Restoration
5770 from the bank is executed by issuing a RESBANK instruction.
5772 @item sp_switch
5773 @cindex @code{sp_switch} function attribute, SH
5774 Use this attribute on the SH to indicate an @code{interrupt_handler}
5775 function should switch to an alternate stack.  It expects a string
5776 argument that names a global variable holding the address of the
5777 alternate stack.
5779 @smallexample
5780 void *alt_stack;
5781 void f () __attribute__ ((interrupt_handler,
5782                           sp_switch ("alt_stack")));
5783 @end smallexample
5785 @item trap_exit
5786 @cindex @code{trap_exit} function attribute, SH
5787 Use this attribute on the SH for an @code{interrupt_handler} to return using
5788 @code{trapa} instead of @code{rte}.  This attribute expects an integer
5789 argument specifying the trap number to be used.
5791 @item trapa_handler
5792 @cindex @code{trapa_handler} function attribute, SH
5793 On SH targets this function attribute is similar to @code{interrupt_handler}
5794 but it does not save and restore all registers.
5795 @end table
5797 @node SPU Function Attributes
5798 @subsection SPU Function Attributes
5800 These function attributes are supported by the SPU back end:
5802 @table @code
5803 @item naked
5804 @cindex @code{naked} function attribute, SPU
5805 This attribute allows the compiler to construct the
5806 requisite function declaration, while allowing the body of the
5807 function to be assembly code. The specified function will not have
5808 prologue/epilogue sequences generated by the compiler. Only basic
5809 @code{asm} statements can safely be included in naked functions
5810 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
5811 basic @code{asm} and C code may appear to work, they cannot be
5812 depended upon to work reliably and are not supported.
5813 @end table
5815 @node Symbian OS Function Attributes
5816 @subsection Symbian OS Function Attributes
5818 @xref{Microsoft Windows Function Attributes}, for discussion of the
5819 @code{dllexport} and @code{dllimport} attributes.
5821 @node V850 Function Attributes
5822 @subsection V850 Function Attributes
5824 The V850 back end supports these function attributes:
5826 @table @code
5827 @item interrupt
5828 @itemx interrupt_handler
5829 @cindex @code{interrupt} function attribute, V850
5830 @cindex @code{interrupt_handler} function attribute, V850
5831 Use these attributes to indicate
5832 that the specified function is an interrupt handler.  The compiler generates
5833 function entry and exit sequences suitable for use in an interrupt handler
5834 when either attribute is present.
5835 @end table
5837 @node Visium Function Attributes
5838 @subsection Visium Function Attributes
5840 These function attributes are supported by the Visium back end:
5842 @table @code
5843 @item interrupt
5844 @cindex @code{interrupt} function attribute, Visium
5845 Use this attribute to indicate
5846 that the specified function is an interrupt handler.  The compiler generates
5847 function entry and exit sequences suitable for use in an interrupt handler
5848 when this attribute is present.
5849 @end table
5851 @node x86 Function Attributes
5852 @subsection x86 Function Attributes
5854 These function attributes are supported by the x86 back end:
5856 @table @code
5857 @item cdecl
5858 @cindex @code{cdecl} function attribute, x86-32
5859 @cindex functions that pop the argument stack on x86-32
5860 @opindex mrtd
5861 On the x86-32 targets, the @code{cdecl} attribute causes the compiler to
5862 assume that the calling function pops off the stack space used to
5863 pass arguments.  This is
5864 useful to override the effects of the @option{-mrtd} switch.
5866 @item fastcall
5867 @cindex @code{fastcall} function attribute, x86-32
5868 @cindex functions that pop the argument stack on x86-32
5869 On x86-32 targets, the @code{fastcall} attribute causes the compiler to
5870 pass the first argument (if of integral type) in the register ECX and
5871 the second argument (if of integral type) in the register EDX@.  Subsequent
5872 and other typed arguments are passed on the stack.  The called function
5873 pops the arguments off the stack.  If the number of arguments is variable all
5874 arguments are pushed on the stack.
5876 @item thiscall
5877 @cindex @code{thiscall} function attribute, x86-32
5878 @cindex functions that pop the argument stack on x86-32
5879 On x86-32 targets, the @code{thiscall} attribute causes the compiler to
5880 pass the first argument (if of integral type) in the register ECX.
5881 Subsequent and other typed arguments are passed on the stack. The called
5882 function pops the arguments off the stack.
5883 If the number of arguments is variable all arguments are pushed on the
5884 stack.
5885 The @code{thiscall} attribute is intended for C++ non-static member functions.
5886 As a GCC extension, this calling convention can be used for C functions
5887 and for static member methods.
5889 @item ms_abi
5890 @itemx sysv_abi
5891 @cindex @code{ms_abi} function attribute, x86
5892 @cindex @code{sysv_abi} function attribute, x86
5894 On 32-bit and 64-bit x86 targets, you can use an ABI attribute
5895 to indicate which calling convention should be used for a function.  The
5896 @code{ms_abi} attribute tells the compiler to use the Microsoft ABI,
5897 while the @code{sysv_abi} attribute tells the compiler to use the ABI
5898 used on GNU/Linux and other systems.  The default is to use the Microsoft ABI
5899 when targeting Windows.  On all other systems, the default is the x86/AMD ABI.
5901 Note, the @code{ms_abi} attribute for Microsoft Windows 64-bit targets currently
5902 requires the @option{-maccumulate-outgoing-args} option.
5904 @item callee_pop_aggregate_return (@var{number})
5905 @cindex @code{callee_pop_aggregate_return} function attribute, x86
5907 On x86-32 targets, you can use this attribute to control how
5908 aggregates are returned in memory.  If the caller is responsible for
5909 popping the hidden pointer together with the rest of the arguments, specify
5910 @var{number} equal to zero.  If callee is responsible for popping the
5911 hidden pointer, specify @var{number} equal to one.  
5913 The default x86-32 ABI assumes that the callee pops the
5914 stack for hidden pointer.  However, on x86-32 Microsoft Windows targets,
5915 the compiler assumes that the
5916 caller pops the stack for hidden pointer.
5918 @item ms_hook_prologue
5919 @cindex @code{ms_hook_prologue} function attribute, x86
5921 On 32-bit and 64-bit x86 targets, you can use
5922 this function attribute to make GCC generate the ``hot-patching'' function
5923 prologue used in Win32 API functions in Microsoft Windows XP Service Pack 2
5924 and newer.
5926 @item naked
5927 @cindex @code{naked} function attribute, x86
5928 This attribute allows the compiler to construct the
5929 requisite function declaration, while allowing the body of the
5930 function to be assembly code. The specified function will not have
5931 prologue/epilogue sequences generated by the compiler. Only basic
5932 @code{asm} statements can safely be included in naked functions
5933 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
5934 basic @code{asm} and C code may appear to work, they cannot be
5935 depended upon to work reliably and are not supported.
5937 @item regparm (@var{number})
5938 @cindex @code{regparm} function attribute, x86
5939 @cindex functions that are passed arguments in registers on x86-32
5940 On x86-32 targets, the @code{regparm} attribute causes the compiler to
5941 pass arguments number one to @var{number} if they are of integral type
5942 in registers EAX, EDX, and ECX instead of on the stack.  Functions that
5943 take a variable number of arguments continue to be passed all of their
5944 arguments on the stack.
5946 Beware that on some ELF systems this attribute is unsuitable for
5947 global functions in shared libraries with lazy binding (which is the
5948 default).  Lazy binding sends the first call via resolving code in
5949 the loader, which might assume EAX, EDX and ECX can be clobbered, as
5950 per the standard calling conventions.  Solaris 8 is affected by this.
5951 Systems with the GNU C Library version 2.1 or higher
5952 and FreeBSD are believed to be
5953 safe since the loaders there save EAX, EDX and ECX.  (Lazy binding can be
5954 disabled with the linker or the loader if desired, to avoid the
5955 problem.)
5957 @item sseregparm
5958 @cindex @code{sseregparm} function attribute, x86
5959 On x86-32 targets with SSE support, the @code{sseregparm} attribute
5960 causes the compiler to pass up to 3 floating-point arguments in
5961 SSE registers instead of on the stack.  Functions that take a
5962 variable number of arguments continue to pass all of their
5963 floating-point arguments on the stack.
5965 @item force_align_arg_pointer
5966 @cindex @code{force_align_arg_pointer} function attribute, x86
5967 On x86 targets, the @code{force_align_arg_pointer} attribute may be
5968 applied to individual function definitions, generating an alternate
5969 prologue and epilogue that realigns the run-time stack if necessary.
5970 This supports mixing legacy codes that run with a 4-byte aligned stack
5971 with modern codes that keep a 16-byte stack for SSE compatibility.
5973 @item stdcall
5974 @cindex @code{stdcall} function attribute, x86-32
5975 @cindex functions that pop the argument stack on x86-32
5976 On x86-32 targets, the @code{stdcall} attribute causes the compiler to
5977 assume that the called function pops off the stack space used to
5978 pass arguments, unless it takes a variable number of arguments.
5980 @item no_caller_saved_registers
5981 @cindex @code{no_caller_saved_registers} function attribute, x86
5982 Use this attribute to indicate that the specified function has no
5983 caller-saved registers. That is, all registers are callee-saved. For
5984 example, this attribute can be used for a function called from an
5985 interrupt handler. The compiler generates proper function entry and
5986 exit sequences to save and restore any modified registers, except for
5987 the EFLAGS register.  Since GCC doesn't preserve SSE, MMX nor x87
5988 states, the GCC option @option{-mgeneral-regs-only} should be used to
5989 compile functions with @code{no_caller_saved_registers} attribute.
5991 @item interrupt
5992 @cindex @code{interrupt} function attribute, x86
5993 Use this attribute to indicate that the specified function is an
5994 interrupt handler or an exception handler (depending on parameters passed
5995 to the function, explained further).  The compiler generates function
5996 entry and exit sequences suitable for use in an interrupt handler when
5997 this attribute is present.  The @code{IRET} instruction, instead of the
5998 @code{RET} instruction, is used to return from interrupt handlers.  All
5999 registers, except for the EFLAGS register which is restored by the
6000 @code{IRET} instruction, are preserved by the compiler.  Since GCC
6001 doesn't preserve SSE, MMX nor x87 states, the GCC option
6002 @option{-mgeneral-regs-only} should be used to compile interrupt and
6003 exception handlers.
6005 Any interruptible-without-stack-switch code must be compiled with
6006 @option{-mno-red-zone} since interrupt handlers can and will, because
6007 of the hardware design, touch the red zone.
6009 An interrupt handler must be declared with a mandatory pointer
6010 argument:
6012 @smallexample
6013 struct interrupt_frame;
6015 __attribute__ ((interrupt))
6016 void
6017 f (struct interrupt_frame *frame)
6020 @end smallexample
6022 @noindent
6023 and you must define @code{struct interrupt_frame} as described in the
6024 processor's manual.
6026 Exception handlers differ from interrupt handlers because the system
6027 pushes an error code on the stack.  An exception handler declaration is
6028 similar to that for an interrupt handler, but with a different mandatory
6029 function signature.  The compiler arranges to pop the error code off the
6030 stack before the @code{IRET} instruction.
6032 @smallexample
6033 #ifdef __x86_64__
6034 typedef unsigned long long int uword_t;
6035 #else
6036 typedef unsigned int uword_t;
6037 #endif
6039 struct interrupt_frame;
6041 __attribute__ ((interrupt))
6042 void
6043 f (struct interrupt_frame *frame, uword_t error_code)
6045   ...
6047 @end smallexample
6049 Exception handlers should only be used for exceptions that push an error
6050 code; you should use an interrupt handler in other cases.  The system
6051 will crash if the wrong kind of handler is used.
6053 @item target (@var{options})
6054 @cindex @code{target} function attribute
6055 As discussed in @ref{Common Function Attributes}, this attribute 
6056 allows specification of target-specific compilation options.
6058 On the x86, the following options are allowed:
6059 @table @samp
6060 @item 3dnow
6061 @itemx no-3dnow
6062 @cindex @code{target("3dnow")} function attribute, x86
6063 Enable/disable the generation of the 3DNow!@: instructions.
6065 @item 3dnowa
6066 @itemx no-3dnowa
6067 @cindex @code{target("3dnowa")} function attribute, x86
6068 Enable/disable the generation of the enhanced 3DNow!@: instructions.
6070 @item abm
6071 @itemx no-abm
6072 @cindex @code{target("abm")} function attribute, x86
6073 Enable/disable the generation of the advanced bit instructions.
6075 @item adx
6076 @itemx no-adx
6077 @cindex @code{target("adx")} function attribute, x86
6078 Enable/disable the generation of the ADX instructions.
6080 @item aes
6081 @itemx no-aes
6082 @cindex @code{target("aes")} function attribute, x86
6083 Enable/disable the generation of the AES instructions.
6085 @item avx
6086 @itemx no-avx
6087 @cindex @code{target("avx")} function attribute, x86
6088 Enable/disable the generation of the AVX instructions.
6090 @item avx2
6091 @itemx no-avx2
6092 @cindex @code{target("avx2")} function attribute, x86
6093 Enable/disable the generation of the AVX2 instructions.
6095 @item avx5124fmaps
6096 @itemx no-avx5124fmaps
6097 @cindex @code{target("avx5124fmaps")} function attribute, x86
6098 Enable/disable the generation of the AVX5124FMAPS instructions.
6100 @item avx5124vnniw
6101 @itemx no-avx5124vnniw
6102 @cindex @code{target("avx5124vnniw")} function attribute, x86
6103 Enable/disable the generation of the AVX5124VNNIW instructions.
6105 @item avx512bitalg
6106 @itemx no-avx512bitalg
6107 @cindex @code{target("avx512bitalg")} function attribute, x86
6108 Enable/disable the generation of the AVX512BITALG instructions.
6110 @item avx512bw
6111 @itemx no-avx512bw
6112 @cindex @code{target("avx512bw")} function attribute, x86
6113 Enable/disable the generation of the AVX512BW instructions.
6115 @item avx512cd
6116 @itemx no-avx512cd
6117 @cindex @code{target("avx512cd")} function attribute, x86
6118 Enable/disable the generation of the AVX512CD instructions.
6120 @item avx512dq
6121 @itemx no-avx512dq
6122 @cindex @code{target("avx512dq")} function attribute, x86
6123 Enable/disable the generation of the AVX512DQ instructions.
6125 @item avx512er
6126 @itemx no-avx512er
6127 @cindex @code{target("avx512er")} function attribute, x86
6128 Enable/disable the generation of the AVX512ER instructions.
6130 @item avx512f
6131 @itemx no-avx512f
6132 @cindex @code{target("avx512f")} function attribute, x86
6133 Enable/disable the generation of the AVX512F instructions.
6135 @item avx512ifma
6136 @itemx no-avx512ifma
6137 @cindex @code{target("avx512ifma")} function attribute, x86
6138 Enable/disable the generation of the AVX512IFMA instructions.
6140 @item avx512pf
6141 @itemx no-avx512pf
6142 @cindex @code{target("avx512pf")} function attribute, x86
6143 Enable/disable the generation of the AVX512PF instructions.
6145 @item avx512vbmi
6146 @itemx no-avx512vbmi
6147 @cindex @code{target("avx512vbmi")} function attribute, x86
6148 Enable/disable the generation of the AVX512VBMI instructions.
6150 @item avx512vbmi2
6151 @itemx no-avx512vbmi2
6152 @cindex @code{target("avx512vbmi2")} function attribute, x86
6153 Enable/disable the generation of the AVX512VBMI2 instructions.
6155 @item avx512vl
6156 @itemx no-avx512vl
6157 @cindex @code{target("avx512vl")} function attribute, x86
6158 Enable/disable the generation of the AVX512VL instructions.
6160 @item avx512vnni
6161 @itemx no-avx512vnni
6162 @cindex @code{target("avx512vnni")} function attribute, x86
6163 Enable/disable the generation of the AVX512VNNI instructions.
6165 @item avx512vpopcntdq
6166 @itemx no-avx512vpopcntdq
6167 @cindex @code{target("avx512vpopcntdq")} function attribute, x86
6168 Enable/disable the generation of the AVX512VPOPCNTDQ instructions.
6170 @item bmi
6171 @itemx no-bmi
6172 @cindex @code{target("bmi")} function attribute, x86
6173 Enable/disable the generation of the BMI instructions.
6175 @item bmi2
6176 @itemx no-bmi2
6177 @cindex @code{target("bmi2")} function attribute, x86
6178 Enable/disable the generation of the BMI2 instructions.
6180 @item cldemote
6181 @itemx no-cldemote
6182 @cindex @code{target("cldemote")} function attribute, x86
6183 Enable/disable the generation of the CLDEMOTE instructions.
6185 @item clflushopt
6186 @itemx no-clflushopt
6187 @cindex @code{target("clflushopt")} function attribute, x86
6188 Enable/disable the generation of the CLFLUSHOPT instructions.
6190 @item clwb
6191 @itemx no-clwb
6192 @cindex @code{target("clwb")} function attribute, x86
6193 Enable/disable the generation of the CLWB instructions.
6195 @item clzero
6196 @itemx no-clzero
6197 @cindex @code{target("clzero")} function attribute, x86
6198 Enable/disable the generation of the CLZERO instructions.
6200 @item crc32
6201 @itemx no-crc32
6202 @cindex @code{target("crc32")} function attribute, x86
6203 Enable/disable the generation of the CRC32 instructions.
6205 @item cx16
6206 @itemx no-cx16
6207 @cindex @code{target("cx16")} function attribute, x86
6208 Enable/disable the generation of the CMPXCHG16B instructions.
6210 @item default
6211 @cindex @code{target("default")} function attribute, x86
6212 @xref{Function Multiversioning}, where it is used to specify the
6213 default function version.
6215 @item f16c
6216 @itemx no-f16c
6217 @cindex @code{target("f16c")} function attribute, x86
6218 Enable/disable the generation of the F16C instructions.
6220 @item fma
6221 @itemx no-fma
6222 @cindex @code{target("fma")} function attribute, x86
6223 Enable/disable the generation of the FMA instructions.
6225 @item fma4
6226 @itemx no-fma4
6227 @cindex @code{target("fma4")} function attribute, x86
6228 Enable/disable the generation of the FMA4 instructions.
6230 @item fsgsbase
6231 @itemx no-fsgsbase
6232 @cindex @code{target("fsgsbase")} function attribute, x86
6233 Enable/disable the generation of the FSGSBASE instructions.
6235 @item fxsr
6236 @itemx no-fxsr
6237 @cindex @code{target("fxsr")} function attribute, x86
6238 Enable/disable the generation of the FXSR instructions.
6240 @item gfni
6241 @itemx no-gfni
6242 @cindex @code{target("gfni")} function attribute, x86
6243 Enable/disable the generation of the GFNI instructions.
6245 @item hle
6246 @itemx no-hle
6247 @cindex @code{target("hle")} function attribute, x86
6248 Enable/disable the generation of the HLE instruction prefixes.
6250 @item lwp
6251 @itemx no-lwp
6252 @cindex @code{target("lwp")} function attribute, x86
6253 Enable/disable the generation of the LWP instructions.
6255 @item lzcnt
6256 @itemx no-lzcnt
6257 @cindex @code{target("lzcnt")} function attribute, x86
6258 Enable/disable the generation of the LZCNT instructions.
6260 @item mmx
6261 @itemx no-mmx
6262 @cindex @code{target("mmx")} function attribute, x86
6263 Enable/disable the generation of the MMX instructions.
6265 @item movbe
6266 @itemx no-movbe
6267 @cindex @code{target("movbe")} function attribute, x86
6268 Enable/disable the generation of the MOVBE instructions.
6270 @item movdir64b
6271 @itemx no-movdir64b
6272 @cindex @code{target("movdir64b")} function attribute, x86
6273 Enable/disable the generation of the MOVDIR64B instructions.
6275 @item movdiri
6276 @itemx no-movdiri
6277 @cindex @code{target("movdiri")} function attribute, x86
6278 Enable/disable the generation of the MOVDIRI instructions.
6280 @item mwaitx
6281 @itemx no-mwaitx
6282 @cindex @code{target("mwaitx")} function attribute, x86
6283 Enable/disable the generation of the MWAITX instructions.
6285 @item pclmul
6286 @itemx no-pclmul
6287 @cindex @code{target("pclmul")} function attribute, x86
6288 Enable/disable the generation of the PCLMUL instructions.
6290 @item pconfig
6291 @itemx no-pconfig
6292 @cindex @code{target("pconfig")} function attribute, x86
6293 Enable/disable the generation of the PCONFIG instructions.
6295 @item pku
6296 @itemx no-pku
6297 @cindex @code{target("pku")} function attribute, x86
6298 Enable/disable the generation of the PKU instructions.
6300 @item popcnt
6301 @itemx no-popcnt
6302 @cindex @code{target("popcnt")} function attribute, x86
6303 Enable/disable the generation of the POPCNT instruction.
6305 @item prefetchwt1
6306 @itemx no-prefetchwt1
6307 @cindex @code{target("prefetchwt1")} function attribute, x86
6308 Enable/disable the generation of the PREFETCHWT1 instructions.
6310 @item prfchw
6311 @itemx no-prfchw
6312 @cindex @code{target("prfchw")} function attribute, x86
6313 Enable/disable the generation of the PREFETCHW instruction.
6315 @item ptwrite
6316 @itemx no-ptwrite
6317 @cindex @code{target("ptwrite")} function attribute, x86
6318 Enable/disable the generation of the PTWRITE instructions.
6320 @item rdpid
6321 @itemx no-rdpid
6322 @cindex @code{target("rdpid")} function attribute, x86
6323 Enable/disable the generation of the RDPID instructions.
6325 @item rdrnd
6326 @itemx no-rdrnd
6327 @cindex @code{target("rdrnd")} function attribute, x86
6328 Enable/disable the generation of the RDRND instructions.
6330 @item rdseed
6331 @itemx no-rdseed
6332 @cindex @code{target("rdseed")} function attribute, x86
6333 Enable/disable the generation of the RDSEED instructions.
6335 @item rtm
6336 @itemx no-rtm
6337 @cindex @code{target("rtm")} function attribute, x86
6338 Enable/disable the generation of the RTM instructions.
6340 @item sahf
6341 @itemx no-sahf
6342 @cindex @code{target("sahf")} function attribute, x86
6343 Enable/disable the generation of the SAHF instructions.
6345 @item sgx
6346 @itemx no-sgx
6347 @cindex @code{target("sgx")} function attribute, x86
6348 Enable/disable the generation of the SGX instructions.
6350 @item sha
6351 @itemx no-sha
6352 @cindex @code{target("sha")} function attribute, x86
6353 Enable/disable the generation of the SHA instructions.
6355 @item shstk
6356 @itemx no-shstk
6357 @cindex @code{target("shstk")} function attribute, x86
6358 Enable/disable the shadow stack built-in functions from CET.
6360 @item sse
6361 @itemx no-sse
6362 @cindex @code{target("sse")} function attribute, x86
6363 Enable/disable the generation of the SSE instructions.
6365 @item sse2
6366 @itemx no-sse2
6367 @cindex @code{target("sse2")} function attribute, x86
6368 Enable/disable the generation of the SSE2 instructions.
6370 @item sse3
6371 @itemx no-sse3
6372 @cindex @code{target("sse3")} function attribute, x86
6373 Enable/disable the generation of the SSE3 instructions.
6375 @item sse4
6376 @itemx no-sse4
6377 @cindex @code{target("sse4")} function attribute, x86
6378 Enable/disable the generation of the SSE4 instructions (both SSE4.1
6379 and SSE4.2).
6381 @item sse4.1
6382 @itemx no-sse4.1
6383 @cindex @code{target("sse4.1")} function attribute, x86
6384 Enable/disable the generation of the sse4.1 instructions.
6386 @item sse4.2
6387 @itemx no-sse4.2
6388 @cindex @code{target("sse4.2")} function attribute, x86
6389 Enable/disable the generation of the sse4.2 instructions.
6391 @item sse4a
6392 @itemx no-sse4a
6393 @cindex @code{target("sse4a")} function attribute, x86
6394 Enable/disable the generation of the SSE4A instructions.
6396 @item ssse3
6397 @itemx no-ssse3
6398 @cindex @code{target("ssse3")} function attribute, x86
6399 Enable/disable the generation of the SSSE3 instructions.
6401 @item tbm
6402 @itemx no-tbm
6403 @cindex @code{target("tbm")} function attribute, x86
6404 Enable/disable the generation of the TBM instructions.
6406 @item vaes
6407 @itemx no-vaes
6408 @cindex @code{target("vaes")} function attribute, x86
6409 Enable/disable the generation of the VAES instructions.
6411 @item vpclmulqdq
6412 @itemx no-vpclmulqdq
6413 @cindex @code{target("vpclmulqdq")} function attribute, x86
6414 Enable/disable the generation of the VPCLMULQDQ instructions.
6416 @item waitpkg
6417 @itemx no-waitpkg
6418 @cindex @code{target("waitpkg")} function attribute, x86
6419 Enable/disable the generation of the WAITPKG instructions.
6421 @item wbnoinvd
6422 @itemx no-wbnoinvd
6423 @cindex @code{target("wbnoinvd")} function attribute, x86
6424 Enable/disable the generation of the WBNOINVD instructions.
6426 @item xop
6427 @itemx no-xop
6428 @cindex @code{target("xop")} function attribute, x86
6429 Enable/disable the generation of the XOP instructions.
6431 @item xsave
6432 @itemx no-xsave
6433 @cindex @code{target("xsave")} function attribute, x86
6434 Enable/disable the generation of the XSAVE instructions.
6436 @item xsavec
6437 @itemx no-xsavec
6438 @cindex @code{target("xsavec")} function attribute, x86
6439 Enable/disable the generation of the XSAVEC instructions.
6441 @item xsaveopt
6442 @itemx no-xsaveopt
6443 @cindex @code{target("xsaveopt")} function attribute, x86
6444 Enable/disable the generation of the XSAVEOPT instructions.
6446 @item xsaves
6447 @itemx no-xsaves
6448 @cindex @code{target("xsaves")} function attribute, x86
6449 Enable/disable the generation of the XSAVES instructions.
6451 @item cld
6452 @itemx no-cld
6453 @cindex @code{target("cld")} function attribute, x86
6454 Enable/disable the generation of the CLD before string moves.
6456 @item fancy-math-387
6457 @itemx no-fancy-math-387
6458 @cindex @code{target("fancy-math-387")} function attribute, x86
6459 Enable/disable the generation of the @code{sin}, @code{cos}, and
6460 @code{sqrt} instructions on the 387 floating-point unit.
6462 @item ieee-fp
6463 @itemx no-ieee-fp
6464 @cindex @code{target("ieee-fp")} function attribute, x86
6465 Enable/disable the generation of floating point that depends on IEEE arithmetic.
6467 @item inline-all-stringops
6468 @itemx no-inline-all-stringops
6469 @cindex @code{target("inline-all-stringops")} function attribute, x86
6470 Enable/disable inlining of string operations.
6472 @item inline-stringops-dynamically
6473 @itemx no-inline-stringops-dynamically
6474 @cindex @code{target("inline-stringops-dynamically")} function attribute, x86
6475 Enable/disable the generation of the inline code to do small string
6476 operations and calling the library routines for large operations.
6478 @item align-stringops
6479 @itemx no-align-stringops
6480 @cindex @code{target("align-stringops")} function attribute, x86
6481 Do/do not align destination of inlined string operations.
6483 @item recip
6484 @itemx no-recip
6485 @cindex @code{target("recip")} function attribute, x86
6486 Enable/disable the generation of RCPSS, RCPPS, RSQRTSS and RSQRTPS
6487 instructions followed an additional Newton-Raphson step instead of
6488 doing a floating-point division.
6490 @item arch=@var{ARCH}
6491 @cindex @code{target("arch=@var{ARCH}")} function attribute, x86
6492 Specify the architecture to generate code for in compiling the function.
6494 @item tune=@var{TUNE}
6495 @cindex @code{target("tune=@var{TUNE}")} function attribute, x86
6496 Specify the architecture to tune for in compiling the function.
6498 @item fpmath=@var{FPMATH}
6499 @cindex @code{target("fpmath=@var{FPMATH}")} function attribute, x86
6500 Specify which floating-point unit to use.  You must specify the
6501 @code{target("fpmath=sse,387")} option as
6502 @code{target("fpmath=sse+387")} because the comma would separate
6503 different options.
6505 @item indirect_branch("@var{choice}")
6506 @cindex @code{indirect_branch} function attribute, x86
6507 On x86 targets, the @code{indirect_branch} attribute causes the compiler
6508 to convert indirect call and jump with @var{choice}.  @samp{keep}
6509 keeps indirect call and jump unmodified.  @samp{thunk} converts indirect
6510 call and jump to call and return thunk.  @samp{thunk-inline} converts
6511 indirect call and jump to inlined call and return thunk.
6512 @samp{thunk-extern} converts indirect call and jump to external call
6513 and return thunk provided in a separate object file.
6515 @item function_return("@var{choice}")
6516 @cindex @code{function_return} function attribute, x86
6517 On x86 targets, the @code{function_return} attribute causes the compiler
6518 to convert function return with @var{choice}.  @samp{keep} keeps function
6519 return unmodified.  @samp{thunk} converts function return to call and
6520 return thunk.  @samp{thunk-inline} converts function return to inlined
6521 call and return thunk.  @samp{thunk-extern} converts function return to
6522 external call and return thunk provided in a separate object file.
6524 @item nocf_check
6525 @cindex @code{nocf_check} function attribute
6526 The @code{nocf_check} attribute on a function is used to inform the
6527 compiler that the function's prologue should not be instrumented when
6528 compiled with the @option{-fcf-protection=branch} option.  The
6529 compiler assumes that the function's address is a valid target for a
6530 control-flow transfer.
6532 The @code{nocf_check} attribute on a type of pointer to function is
6533 used to inform the compiler that a call through the pointer should
6534 not be instrumented when compiled with the
6535 @option{-fcf-protection=branch} option.  The compiler assumes
6536 that the function's address from the pointer is a valid target for
6537 a control-flow transfer.  A direct function call through a function
6538 name is assumed to be a safe call thus direct calls are not
6539 instrumented by the compiler.
6541 The @code{nocf_check} attribute is applied to an object's type.
6542 In case of assignment of a function address or a function pointer to
6543 another pointer, the attribute is not carried over from the right-hand
6544 object's type; the type of left-hand object stays unchanged.  The
6545 compiler checks for @code{nocf_check} attribute mismatch and reports
6546 a warning in case of mismatch.
6548 @smallexample
6550 int foo (void) __attribute__(nocf_check);
6551 void (*foo1)(void) __attribute__(nocf_check);
6552 void (*foo2)(void);
6554 /* foo's address is assumed to be valid.  */
6556 foo (void) 
6558   /* This call site is not checked for control-flow 
6559      validity.  */
6560   (*foo1)();
6562   /* A warning is issued about attribute mismatch.  */
6563   foo1 = foo2; 
6565   /* This call site is still not checked.  */
6566   (*foo1)();
6568   /* This call site is checked.  */
6569   (*foo2)();
6571   /* A warning is issued about attribute mismatch.  */
6572   foo2 = foo1; 
6574   /* This call site is still checked.  */
6575   (*foo2)();
6577   return 0;
6579 @end smallexample
6581 @item cf_check
6582 @cindex @code{cf_check} function attribute, x86
6584 The @code{cf_check} attribute on a function is used to inform the
6585 compiler that ENDBR instruction should be placed at the function
6586 entry when @option{-fcf-protection=branch} is enabled.
6588 @item indirect_return
6589 @cindex @code{indirect_return} function attribute, x86
6591 The @code{indirect_return} attribute can be applied to a function,
6592 as well as variable or type of function pointer to inform the
6593 compiler that the function may return via indirect branch.
6595 @item fentry_name("@var{name}")
6596 @cindex @code{fentry_name} function attribute, x86
6597 On x86 targets, the @code{fentry_name} attribute sets the function to
6598 call on function entry when function instrumentation is enabled
6599 with @option{-pg -mfentry}. When @var{name} is nop then a 5 byte
6600 nop sequence is generated.
6602 @item fentry_section("@var{name}")
6603 @cindex @code{fentry_section} function attribute, x86
6604 On x86 targets, the @code{fentry_section} attribute sets the name
6605 of the section to record function entry instrumentation calls in when
6606 enabled with @option{-pg -mrecord-mcount}
6608 @end table
6610 On the x86, the inliner does not inline a
6611 function that has different target options than the caller, unless the
6612 callee has a subset of the target options of the caller.  For example
6613 a function declared with @code{target("sse3")} can inline a function
6614 with @code{target("sse2")}, since @code{-msse3} implies @code{-msse2}.
6615 @end table
6617 @node Xstormy16 Function Attributes
6618 @subsection Xstormy16 Function Attributes
6620 These function attributes are supported by the Xstormy16 back end:
6622 @table @code
6623 @item interrupt
6624 @cindex @code{interrupt} function attribute, Xstormy16
6625 Use this attribute to indicate
6626 that the specified function is an interrupt handler.  The compiler generates
6627 function entry and exit sequences suitable for use in an interrupt handler
6628 when this attribute is present.
6629 @end table
6631 @node Variable Attributes
6632 @section Specifying Attributes of Variables
6633 @cindex attribute of variables
6634 @cindex variable attributes
6636 The keyword @code{__attribute__} allows you to specify special properties
6637 of variables, function parameters, or structure, union, and, in C++, class
6638 members.  This @code{__attribute__} keyword is followed by an attribute
6639 specification enclosed in double parentheses.  Some attributes are currently
6640 defined generically for variables.  Other attributes are defined for
6641 variables on particular target systems.  Other attributes are available
6642 for functions (@pxref{Function Attributes}), labels (@pxref{Label Attributes}),
6643 enumerators (@pxref{Enumerator Attributes}), statements
6644 (@pxref{Statement Attributes}), and for types (@pxref{Type Attributes}).
6645 Other front ends might define more attributes
6646 (@pxref{C++ Extensions,,Extensions to the C++ Language}).
6648 @xref{Attribute Syntax}, for details of the exact syntax for using
6649 attributes.
6651 @menu
6652 * Common Variable Attributes::
6653 * ARC Variable Attributes::
6654 * AVR Variable Attributes::
6655 * Blackfin Variable Attributes::
6656 * H8/300 Variable Attributes::
6657 * IA-64 Variable Attributes::
6658 * M32R/D Variable Attributes::
6659 * MeP Variable Attributes::
6660 * Microsoft Windows Variable Attributes::
6661 * MSP430 Variable Attributes::
6662 * Nvidia PTX Variable Attributes::
6663 * PowerPC Variable Attributes::
6664 * RL78 Variable Attributes::
6665 * SPU Variable Attributes::
6666 * V850 Variable Attributes::
6667 * x86 Variable Attributes::
6668 * Xstormy16 Variable Attributes::
6669 @end menu
6671 @node Common Variable Attributes
6672 @subsection Common Variable Attributes
6674 The following attributes are supported on most targets.
6676 @table @code
6677 @cindex @code{aligned} variable attribute
6678 @item aligned
6679 @itemx aligned (@var{alignment})
6680 The @code{aligned} attribute specifies a minimum alignment for the variable
6681 or structure field, measured in bytes.  When specified, @var{alignment} must
6682 be an integer constant power of 2.  Specifying no @var{alignment} argument
6683 implies the maximum alignment for the target, which is often, but by no
6684 means always, 8 or 16 bytes.
6686 For example, the declaration:
6688 @smallexample
6689 int x __attribute__ ((aligned (16))) = 0;
6690 @end smallexample
6692 @noindent
6693 causes the compiler to allocate the global variable @code{x} on a
6694 16-byte boundary.  On a 68040, this could be used in conjunction with
6695 an @code{asm} expression to access the @code{move16} instruction which
6696 requires 16-byte aligned operands.
6698 You can also specify the alignment of structure fields.  For example, to
6699 create a double-word aligned @code{int} pair, you could write:
6701 @smallexample
6702 struct foo @{ int x[2] __attribute__ ((aligned (8))); @};
6703 @end smallexample
6705 @noindent
6706 This is an alternative to creating a union with a @code{double} member,
6707 which forces the union to be double-word aligned.
6709 As in the preceding examples, you can explicitly specify the alignment
6710 (in bytes) that you wish the compiler to use for a given variable or
6711 structure field.  Alternatively, you can leave out the alignment factor
6712 and just ask the compiler to align a variable or field to the
6713 default alignment for the target architecture you are compiling for.
6714 The default alignment is sufficient for all scalar types, but may not be
6715 enough for all vector types on a target that supports vector operations.
6716 The default alignment is fixed for a particular target ABI.
6718 GCC also provides a target specific macro @code{__BIGGEST_ALIGNMENT__},
6719 which is the largest alignment ever used for any data type on the
6720 target machine you are compiling for.  For example, you could write:
6722 @smallexample
6723 short array[3] __attribute__ ((aligned (__BIGGEST_ALIGNMENT__)));
6724 @end smallexample
6726 The compiler automatically sets the alignment for the declared
6727 variable or field to @code{__BIGGEST_ALIGNMENT__}.  Doing this can
6728 often make copy operations more efficient, because the compiler can
6729 use whatever instructions copy the biggest chunks of memory when
6730 performing copies to or from the variables or fields that you have
6731 aligned this way.  Note that the value of @code{__BIGGEST_ALIGNMENT__}
6732 may change depending on command-line options.
6734 When used on a struct, or struct member, the @code{aligned} attribute can
6735 only increase the alignment; in order to decrease it, the @code{packed}
6736 attribute must be specified as well.  When used as part of a typedef, the
6737 @code{aligned} attribute can both increase and decrease alignment, and
6738 specifying the @code{packed} attribute generates a warning.
6740 Note that the effectiveness of @code{aligned} attributes for static
6741 variables may be limited by inherent limitations in the system linker
6742 and/or object file format.  On some systems, the linker is
6743 only able to arrange for variables to be aligned up to a certain maximum
6744 alignment.  (For some linkers, the maximum supported alignment may
6745 be very very small.)  If your linker is only able to align variables
6746 up to a maximum of 8-byte alignment, then specifying @code{aligned(16)}
6747 in an @code{__attribute__} still only provides you with 8-byte
6748 alignment.  See your linker documentation for further information.
6750 Stack variables are not affected by linker restrictions; GCC can properly
6751 align them on any target.
6753 The @code{aligned} attribute can also be used for functions
6754 (@pxref{Common Function Attributes}.)
6756 @cindex @code{warn_if_not_aligned} variable attribute
6757 @item warn_if_not_aligned (@var{alignment})
6758 This attribute specifies a threshold for the structure field, measured
6759 in bytes.  If the structure field is aligned below the threshold, a
6760 warning will be issued.  For example, the declaration:
6762 @smallexample
6763 struct foo
6765   int i1;
6766   int i2;
6767   unsigned long long x __attribute__ ((warn_if_not_aligned (16)));
6769 @end smallexample
6771 @noindent
6772 causes the compiler to issue an warning on @code{struct foo}, like
6773 @samp{warning: alignment 8 of 'struct foo' is less than 16}.
6774 The compiler also issues a warning, like @samp{warning: 'x' offset
6775 8 in 'struct foo' isn't aligned to 16}, when the structure field has
6776 the misaligned offset:
6778 @smallexample
6779 struct __attribute__ ((aligned (16))) foo
6781   int i1;
6782   int i2;
6783   unsigned long long x __attribute__ ((warn_if_not_aligned (16)));
6785 @end smallexample
6787 This warning can be disabled by @option{-Wno-if-not-aligned}.
6788 The @code{warn_if_not_aligned} attribute can also be used for types
6789 (@pxref{Common Type Attributes}.)
6791 @item alloc_size (@var{position})
6792 @itemx alloc_size (@var{position-1}, @var{position-2})
6793 @cindex @code{alloc_size} variable attribute
6794 The @code{alloc_size} variable attribute may be applied to the declaration
6795 of a pointer to a function that returns a pointer and takes at least one
6796 argument of an integer type.  It indicates that the returned pointer points
6797 to an object whose size is given by the function argument at @var{position-1},
6798 or by the product of the arguments at @var{position-1} and @var{position-2}.
6799 Meaningful sizes are positive values less than @code{PTRDIFF_MAX}.  Other
6800 sizes are disagnosed when detected.  GCC uses this information to improve
6801 the results of @code{__builtin_object_size}.
6803 For instance, the following declarations
6805 @smallexample
6806 typedef __attribute__ ((alloc_size (1, 2))) void*
6807   (*calloc_ptr) (size_t, size_t);
6808 typedef __attribute__ ((alloc_size (1))) void*
6809   (*malloc_ptr) (size_t);
6810 @end smallexample
6812 @noindent
6813 specify that @code{calloc_ptr} is a pointer of a function that, like
6814 the standard C function @code{calloc}, returns an object whose size
6815 is given by the product of arguments 1 and 2, and similarly, that
6816 @code{malloc_ptr}, like the standard C function @code{malloc},
6817 returns an object whose size is given by argument 1 to the function.
6819 @item cleanup (@var{cleanup_function})
6820 @cindex @code{cleanup} variable attribute
6821 The @code{cleanup} attribute runs a function when the variable goes
6822 out of scope.  This attribute can only be applied to auto function
6823 scope variables; it may not be applied to parameters or variables
6824 with static storage duration.  The function must take one parameter,
6825 a pointer to a type compatible with the variable.  The return value
6826 of the function (if any) is ignored.
6828 If @option{-fexceptions} is enabled, then @var{cleanup_function}
6829 is run during the stack unwinding that happens during the
6830 processing of the exception.  Note that the @code{cleanup} attribute
6831 does not allow the exception to be caught, only to perform an action.
6832 It is undefined what happens if @var{cleanup_function} does not
6833 return normally.
6835 @item common
6836 @itemx nocommon
6837 @cindex @code{common} variable attribute
6838 @cindex @code{nocommon} variable attribute
6839 @opindex fcommon
6840 @opindex fno-common
6841 The @code{common} attribute requests GCC to place a variable in
6842 ``common'' storage.  The @code{nocommon} attribute requests the
6843 opposite---to allocate space for it directly.
6845 These attributes override the default chosen by the
6846 @option{-fno-common} and @option{-fcommon} flags respectively.
6848 @item copy
6849 @itemx copy (@var{variable})
6850 @cindex @code{copy} variable attribute
6851 The @code{copy} attribute applies the set of attributes with which
6852 @var{variable} has been declared to the declaration of the variable
6853 to which the attribute is applied.  The attribute is designed for
6854 libraries that define aliases that are expected to specify the same
6855 set of attributes as the aliased symbols.  The @code{copy} attribute
6856 can be used with variables, functions or types.  However, the kind
6857 of symbol to which the attribute is applied (either varible or
6858 function) must match the kind of symbol to which the argument refers.
6859 The @code{copy} attribute copies only syntactic and semantic attributes
6860 but not attributes that affect a symbol's linkage or visibility such as
6861 @code{alias}, @code{visibility}, or @code{weak}.  The @code{deprecated}
6862 attribute is also not copied.  @xref{Common Function Attributes}.
6863 @xref{Common Type Attributes}.
6865 @item deprecated
6866 @itemx deprecated (@var{msg})
6867 @cindex @code{deprecated} variable attribute
6868 The @code{deprecated} attribute results in a warning if the variable
6869 is used anywhere in the source file.  This is useful when identifying
6870 variables that are expected to be removed in a future version of a
6871 program.  The warning also includes the location of the declaration
6872 of the deprecated variable, to enable users to easily find further
6873 information about why the variable is deprecated, or what they should
6874 do instead.  Note that the warning only occurs for uses:
6876 @smallexample
6877 extern int old_var __attribute__ ((deprecated));
6878 extern int old_var;
6879 int new_fn () @{ return old_var; @}
6880 @end smallexample
6882 @noindent
6883 results in a warning on line 3 but not line 2.  The optional @var{msg}
6884 argument, which must be a string, is printed in the warning if
6885 present.
6887 The @code{deprecated} attribute can also be used for functions and
6888 types (@pxref{Common Function Attributes},
6889 @pxref{Common Type Attributes}).
6891 The message attached to the attribute is affected by the setting of
6892 the @option{-fmessage-length} option.
6894 @item mode (@var{mode})
6895 @cindex @code{mode} variable attribute
6896 This attribute specifies the data type for the declaration---whichever
6897 type corresponds to the mode @var{mode}.  This in effect lets you
6898 request an integer or floating-point type according to its width.
6900 @xref{Machine Modes,,, gccint, GNU Compiler Collection (GCC) Internals},
6901 for a list of the possible keywords for @var{mode}.
6902 You may also specify a mode of @code{byte} or @code{__byte__} to
6903 indicate the mode corresponding to a one-byte integer, @code{word} or
6904 @code{__word__} for the mode of a one-word integer, and @code{pointer}
6905 or @code{__pointer__} for the mode used to represent pointers.
6907 @item nonstring
6908 @cindex @code{nonstring} variable attribute
6909 The @code{nonstring} variable attribute specifies that an object or member
6910 declaration with type array of @code{char}, @code{signed char}, or
6911 @code{unsigned char}, or pointer to such a type is intended to store
6912 character arrays that do not necessarily contain a terminating @code{NUL}.
6913 This is useful in detecting uses of such arrays or pointers with functions
6914 that expect @code{NUL}-terminated strings, and to avoid warnings when such
6915 an array or pointer is used as an argument to a bounded string manipulation
6916 function such as @code{strncpy}.  For example, without the attribute, GCC
6917 will issue a warning for the @code{strncpy} call below because it may
6918 truncate the copy without appending the terminating @code{NUL} character.
6919 Using the attribute makes it possible to suppress the warning.  However,
6920 when the array is declared with the attribute the call to @code{strlen} is
6921 diagnosed because when the array doesn't contain a @code{NUL}-terminated
6922 string the call is undefined.  To copy, compare, of search non-string
6923 character arrays use the @code{memcpy}, @code{memcmp}, @code{memchr},
6924 and other functions that operate on arrays of bytes.  In addition,
6925 calling @code{strnlen} and @code{strndup} with such arrays is safe
6926 provided a suitable bound is specified, and not diagnosed.
6928 @smallexample
6929 struct Data
6931   char name [32] __attribute__ ((nonstring));
6934 int f (struct Data *pd, const char *s)
6936   strncpy (pd->name, s, sizeof pd->name);
6937   @dots{}
6938   return strlen (pd->name);   // unsafe, gets a warning
6940 @end smallexample
6942 @item packed
6943 @cindex @code{packed} variable attribute
6944 The @code{packed} attribute specifies that a structure member should have
6945 the smallest possible alignment---one bit for a bit-field and one byte
6946 otherwise, unless a larger value is specified with the @code{aligned}
6947 attribute.  The attribute does not apply to non-member objects.
6949 For example in the structure below, the member array @code{x} is packed
6950 so that it immediately follows @code{a} with no intervening padding:
6952 @smallexample
6953 struct foo
6955   char a;
6956   int x[2] __attribute__ ((packed));
6958 @end smallexample
6960 @emph{Note:} The 4.1, 4.2 and 4.3 series of GCC ignore the
6961 @code{packed} attribute on bit-fields of type @code{char}.  This has
6962 been fixed in GCC 4.4 but the change can lead to differences in the
6963 structure layout.  See the documentation of
6964 @option{-Wpacked-bitfield-compat} for more information.
6966 @item section ("@var{section-name}")
6967 @cindex @code{section} variable attribute
6968 Normally, the compiler places the objects it generates in sections like
6969 @code{data} and @code{bss}.  Sometimes, however, you need additional sections,
6970 or you need certain particular variables to appear in special sections,
6971 for example to map to special hardware.  The @code{section}
6972 attribute specifies that a variable (or function) lives in a particular
6973 section.  For example, this small program uses several specific section names:
6975 @smallexample
6976 struct duart a __attribute__ ((section ("DUART_A"))) = @{ 0 @};
6977 struct duart b __attribute__ ((section ("DUART_B"))) = @{ 0 @};
6978 char stack[10000] __attribute__ ((section ("STACK"))) = @{ 0 @};
6979 int init_data __attribute__ ((section ("INITDATA")));
6981 main()
6983   /* @r{Initialize stack pointer} */
6984   init_sp (stack + sizeof (stack));
6986   /* @r{Initialize initialized data} */
6987   memcpy (&init_data, &data, &edata - &data);
6989   /* @r{Turn on the serial ports} */
6990   init_duart (&a);
6991   init_duart (&b);
6993 @end smallexample
6995 @noindent
6996 Use the @code{section} attribute with
6997 @emph{global} variables and not @emph{local} variables,
6998 as shown in the example.
7000 You may use the @code{section} attribute with initialized or
7001 uninitialized global variables but the linker requires
7002 each object be defined once, with the exception that uninitialized
7003 variables tentatively go in the @code{common} (or @code{bss}) section
7004 and can be multiply ``defined''.  Using the @code{section} attribute
7005 changes what section the variable goes into and may cause the
7006 linker to issue an error if an uninitialized variable has multiple
7007 definitions.  You can force a variable to be initialized with the
7008 @option{-fno-common} flag or the @code{nocommon} attribute.
7010 Some file formats do not support arbitrary sections so the @code{section}
7011 attribute is not available on all platforms.
7012 If you need to map the entire contents of a module to a particular
7013 section, consider using the facilities of the linker instead.
7015 @item tls_model ("@var{tls_model}")
7016 @cindex @code{tls_model} variable attribute
7017 The @code{tls_model} attribute sets thread-local storage model
7018 (@pxref{Thread-Local}) of a particular @code{__thread} variable,
7019 overriding @option{-ftls-model=} command-line switch on a per-variable
7020 basis.
7021 The @var{tls_model} argument should be one of @code{global-dynamic},
7022 @code{local-dynamic}, @code{initial-exec} or @code{local-exec}.
7024 Not all targets support this attribute.
7026 @item unused
7027 @cindex @code{unused} variable attribute
7028 This attribute, attached to a variable, means that the variable is meant
7029 to be possibly unused.  GCC does not produce a warning for this
7030 variable.
7032 @item used
7033 @cindex @code{used} variable attribute
7034 This attribute, attached to a variable with static storage, means that
7035 the variable must be emitted even if it appears that the variable is not
7036 referenced.
7038 When applied to a static data member of a C++ class template, the
7039 attribute also means that the member is instantiated if the
7040 class itself is instantiated.
7042 @item vector_size (@var{bytes})
7043 @cindex @code{vector_size} variable attribute
7044 This attribute specifies the vector size for the variable, measured in
7045 bytes.  For example, the declaration:
7047 @smallexample
7048 int foo __attribute__ ((vector_size (16)));
7049 @end smallexample
7051 @noindent
7052 causes the compiler to set the mode for @code{foo}, to be 16 bytes,
7053 divided into @code{int} sized units.  Assuming a 32-bit int (a vector of
7054 4 units of 4 bytes), the corresponding mode of @code{foo} is V4SI@.
7056 This attribute is only applicable to integral and float scalars,
7057 although arrays, pointers, and function return values are allowed in
7058 conjunction with this construct.
7060 Aggregates with this attribute are invalid, even if they are of the same
7061 size as a corresponding scalar.  For example, the declaration:
7063 @smallexample
7064 struct S @{ int a; @};
7065 struct S  __attribute__ ((vector_size (16))) foo;
7066 @end smallexample
7068 @noindent
7069 is invalid even if the size of the structure is the same as the size of
7070 the @code{int}.
7072 @item visibility ("@var{visibility_type}")
7073 @cindex @code{visibility} variable attribute
7074 This attribute affects the linkage of the declaration to which it is attached.
7075 The @code{visibility} attribute is described in
7076 @ref{Common Function Attributes}.
7078 @item weak
7079 @cindex @code{weak} variable attribute
7080 The @code{weak} attribute is described in
7081 @ref{Common Function Attributes}.
7083 @end table
7085 @node ARC Variable Attributes
7086 @subsection ARC Variable Attributes
7088 @table @code
7089 @item aux
7090 @cindex @code{aux} variable attribute, ARC
7091 The @code{aux} attribute is used to directly access the ARC's
7092 auxiliary register space from C.  The auxilirary register number is
7093 given via attribute argument.
7095 @end table
7097 @node AVR Variable Attributes
7098 @subsection AVR Variable Attributes
7100 @table @code
7101 @item progmem
7102 @cindex @code{progmem} variable attribute, AVR
7103 The @code{progmem} attribute is used on the AVR to place read-only
7104 data in the non-volatile program memory (flash). The @code{progmem}
7105 attribute accomplishes this by putting respective variables into a
7106 section whose name starts with @code{.progmem}.
7108 This attribute works similar to the @code{section} attribute
7109 but adds additional checking.
7111 @table @asis
7112 @item @bullet{}@tie{} Ordinary AVR cores with 32 general purpose registers:
7113 @code{progmem} affects the location
7114 of the data but not how this data is accessed.
7115 In order to read data located with the @code{progmem} attribute
7116 (inline) assembler must be used.
7117 @smallexample
7118 /* Use custom macros from @w{@uref{http://nongnu.org/avr-libc/user-manual/,AVR-LibC}} */
7119 #include <avr/pgmspace.h> 
7121 /* Locate var in flash memory */
7122 const int var[2] PROGMEM = @{ 1, 2 @};
7124 int read_var (int i)
7126     /* Access var[] by accessor macro from avr/pgmspace.h */
7127     return (int) pgm_read_word (& var[i]);
7129 @end smallexample
7131 AVR is a Harvard architecture processor and data and read-only data
7132 normally resides in the data memory (RAM).
7134 See also the @ref{AVR Named Address Spaces} section for
7135 an alternate way to locate and access data in flash memory.
7137 @item @bullet{}@tie{} AVR cores with flash memory visible in the RAM address range:
7138 On such devices, there is no need for attribute @code{progmem} or
7139 @ref{AVR Named Address Spaces,,@code{__flash}} qualifier at all.
7140 Just use standard C / C++.  The compiler will generate @code{LD*}
7141 instructions.  As flash memory is visible in the RAM address range,
7142 and the default linker script does @emph{not} locate @code{.rodata} in
7143 RAM, no special features are needed in order not to waste RAM for
7144 read-only data or to read from flash.  You might even get slightly better
7145 performance by
7146 avoiding @code{progmem} and @code{__flash}.  This applies to devices from
7147 families @code{avrtiny} and @code{avrxmega3}, see @ref{AVR Options} for
7148 an overview.
7150 @item @bullet{}@tie{}Reduced AVR Tiny cores like ATtiny40:
7151 The compiler adds @code{0x4000}
7152 to the addresses of objects and declarations in @code{progmem} and locates
7153 the objects in flash memory, namely in section @code{.progmem.data}.
7154 The offset is needed because the flash memory is visible in the RAM
7155 address space starting at address @code{0x4000}.
7157 Data in @code{progmem} can be accessed by means of ordinary C@tie{}code,
7158 no special functions or macros are needed.
7160 @smallexample
7161 /* var is located in flash memory */
7162 extern const int var[2] __attribute__((progmem));
7164 int read_var (int i)
7166     return var[i];
7168 @end smallexample
7170 Please notice that on these devices, there is no need for @code{progmem}
7171 at all.
7173 @end table
7175 @item io
7176 @itemx io (@var{addr})
7177 @cindex @code{io} variable attribute, AVR
7178 Variables with the @code{io} attribute are used to address
7179 memory-mapped peripherals in the io address range.
7180 If an address is specified, the variable
7181 is assigned that address, and the value is interpreted as an
7182 address in the data address space.
7183 Example:
7185 @smallexample
7186 volatile int porta __attribute__((io (0x22)));
7187 @end smallexample
7189 The address specified in the address in the data address range.
7191 Otherwise, the variable it is not assigned an address, but the
7192 compiler will still use in/out instructions where applicable,
7193 assuming some other module assigns an address in the io address range.
7194 Example:
7196 @smallexample
7197 extern volatile int porta __attribute__((io));
7198 @end smallexample
7200 @item io_low
7201 @itemx io_low (@var{addr})
7202 @cindex @code{io_low} variable attribute, AVR
7203 This is like the @code{io} attribute, but additionally it informs the
7204 compiler that the object lies in the lower half of the I/O area,
7205 allowing the use of @code{cbi}, @code{sbi}, @code{sbic} and @code{sbis}
7206 instructions.
7208 @item address
7209 @itemx address (@var{addr})
7210 @cindex @code{address} variable attribute, AVR
7211 Variables with the @code{address} attribute are used to address
7212 memory-mapped peripherals that may lie outside the io address range.
7214 @smallexample
7215 volatile int porta __attribute__((address (0x600)));
7216 @end smallexample
7218 @item absdata
7219 @cindex @code{absdata} variable attribute, AVR
7220 Variables in static storage and with the @code{absdata} attribute can
7221 be accessed by the @code{LDS} and @code{STS} instructions which take
7222 absolute addresses.
7224 @itemize @bullet
7225 @item
7226 This attribute is only supported for the reduced AVR Tiny core
7227 like ATtiny40.
7229 @item
7230 You must make sure that respective data is located in the
7231 address range @code{0x40}@dots{}@code{0xbf} accessible by
7232 @code{LDS} and @code{STS}.  One way to achieve this as an
7233 appropriate linker description file.
7235 @item
7236 If the location does not fit the address range of @code{LDS}
7237 and @code{STS}, there is currently (Binutils 2.26) just an unspecific
7238 warning like
7239 @quotation
7240 @code{module.c:(.text+0x1c): warning: internal error: out of range error}
7241 @end quotation
7243 @end itemize
7245 See also the @option{-mabsdata} @ref{AVR Options,command-line option}.
7247 @end table
7249 @node Blackfin Variable Attributes
7250 @subsection Blackfin Variable Attributes
7252 Three attributes are currently defined for the Blackfin.
7254 @table @code
7255 @item l1_data
7256 @itemx l1_data_A
7257 @itemx l1_data_B
7258 @cindex @code{l1_data} variable attribute, Blackfin
7259 @cindex @code{l1_data_A} variable attribute, Blackfin
7260 @cindex @code{l1_data_B} variable attribute, Blackfin
7261 Use these attributes on the Blackfin to place the variable into L1 Data SRAM.
7262 Variables with @code{l1_data} attribute are put into the specific section
7263 named @code{.l1.data}. Those with @code{l1_data_A} attribute are put into
7264 the specific section named @code{.l1.data.A}. Those with @code{l1_data_B}
7265 attribute are put into the specific section named @code{.l1.data.B}.
7267 @item l2
7268 @cindex @code{l2} variable attribute, Blackfin
7269 Use this attribute on the Blackfin to place the variable into L2 SRAM.
7270 Variables with @code{l2} attribute are put into the specific section
7271 named @code{.l2.data}.
7272 @end table
7274 @node H8/300 Variable Attributes
7275 @subsection H8/300 Variable Attributes
7277 These variable attributes are available for H8/300 targets:
7279 @table @code
7280 @item eightbit_data
7281 @cindex @code{eightbit_data} variable attribute, H8/300
7282 @cindex eight-bit data on the H8/300, H8/300H, and H8S
7283 Use this attribute on the H8/300, H8/300H, and H8S to indicate that the specified
7284 variable should be placed into the eight-bit data section.
7285 The compiler generates more efficient code for certain operations
7286 on data in the eight-bit data area.  Note the eight-bit data area is limited to
7287 256 bytes of data.
7289 You must use GAS and GLD from GNU binutils version 2.7 or later for
7290 this attribute to work correctly.
7292 @item tiny_data
7293 @cindex @code{tiny_data} variable attribute, H8/300
7294 @cindex tiny data section on the H8/300H and H8S
7295 Use this attribute on the H8/300H and H8S to indicate that the specified
7296 variable should be placed into the tiny data section.
7297 The compiler generates more efficient code for loads and stores
7298 on data in the tiny data section.  Note the tiny data area is limited to
7299 slightly under 32KB of data.
7301 @end table
7303 @node IA-64 Variable Attributes
7304 @subsection IA-64 Variable Attributes
7306 The IA-64 back end supports the following variable attribute:
7308 @table @code
7309 @item model (@var{model-name})
7310 @cindex @code{model} variable attribute, IA-64
7312 On IA-64, use this attribute to set the addressability of an object.
7313 At present, the only supported identifier for @var{model-name} is
7314 @code{small}, indicating addressability via ``small'' (22-bit)
7315 addresses (so that their addresses can be loaded with the @code{addl}
7316 instruction).  Caveat: such addressing is by definition not position
7317 independent and hence this attribute must not be used for objects
7318 defined by shared libraries.
7320 @end table
7322 @node M32R/D Variable Attributes
7323 @subsection M32R/D Variable Attributes
7325 One attribute is currently defined for the M32R/D@.
7327 @table @code
7328 @item model (@var{model-name})
7329 @cindex @code{model-name} variable attribute, M32R/D
7330 @cindex variable addressability on the M32R/D
7331 Use this attribute on the M32R/D to set the addressability of an object.
7332 The identifier @var{model-name} is one of @code{small}, @code{medium},
7333 or @code{large}, representing each of the code models.
7335 Small model objects live in the lower 16MB of memory (so that their
7336 addresses can be loaded with the @code{ld24} instruction).
7338 Medium and large model objects may live anywhere in the 32-bit address space
7339 (the compiler generates @code{seth/add3} instructions to load their
7340 addresses).
7341 @end table
7343 @node MeP Variable Attributes
7344 @subsection MeP Variable Attributes
7346 The MeP target has a number of addressing modes and busses.  The
7347 @code{near} space spans the standard memory space's first 16 megabytes
7348 (24 bits).  The @code{far} space spans the entire 32-bit memory space.
7349 The @code{based} space is a 128-byte region in the memory space that
7350 is addressed relative to the @code{$tp} register.  The @code{tiny}
7351 space is a 65536-byte region relative to the @code{$gp} register.  In
7352 addition to these memory regions, the MeP target has a separate 16-bit
7353 control bus which is specified with @code{cb} attributes.
7355 @table @code
7357 @item based
7358 @cindex @code{based} variable attribute, MeP
7359 Any variable with the @code{based} attribute is assigned to the
7360 @code{.based} section, and is accessed with relative to the
7361 @code{$tp} register.
7363 @item tiny
7364 @cindex @code{tiny} variable attribute, MeP
7365 Likewise, the @code{tiny} attribute assigned variables to the
7366 @code{.tiny} section, relative to the @code{$gp} register.
7368 @item near
7369 @cindex @code{near} variable attribute, MeP
7370 Variables with the @code{near} attribute are assumed to have addresses
7371 that fit in a 24-bit addressing mode.  This is the default for large
7372 variables (@code{-mtiny=4} is the default) but this attribute can
7373 override @code{-mtiny=} for small variables, or override @code{-ml}.
7375 @item far
7376 @cindex @code{far} variable attribute, MeP
7377 Variables with the @code{far} attribute are addressed using a full
7378 32-bit address.  Since this covers the entire memory space, this
7379 allows modules to make no assumptions about where variables might be
7380 stored.
7382 @item io
7383 @cindex @code{io} variable attribute, MeP
7384 @itemx io (@var{addr})
7385 Variables with the @code{io} attribute are used to address
7386 memory-mapped peripherals.  If an address is specified, the variable
7387 is assigned that address, else it is not assigned an address (it is
7388 assumed some other module assigns an address).  Example:
7390 @smallexample
7391 int timer_count __attribute__((io(0x123)));
7392 @end smallexample
7394 @item cb
7395 @itemx cb (@var{addr})
7396 @cindex @code{cb} variable attribute, MeP
7397 Variables with the @code{cb} attribute are used to access the control
7398 bus, using special instructions.  @code{addr} indicates the control bus
7399 address.  Example:
7401 @smallexample
7402 int cpu_clock __attribute__((cb(0x123)));
7403 @end smallexample
7405 @end table
7407 @node Microsoft Windows Variable Attributes
7408 @subsection Microsoft Windows Variable Attributes
7410 You can use these attributes on Microsoft Windows targets.
7411 @ref{x86 Variable Attributes} for additional Windows compatibility
7412 attributes available on all x86 targets.
7414 @table @code
7415 @item dllimport
7416 @itemx dllexport
7417 @cindex @code{dllimport} variable attribute
7418 @cindex @code{dllexport} variable attribute
7419 The @code{dllimport} and @code{dllexport} attributes are described in
7420 @ref{Microsoft Windows Function Attributes}.
7422 @item selectany
7423 @cindex @code{selectany} variable attribute
7424 The @code{selectany} attribute causes an initialized global variable to
7425 have link-once semantics.  When multiple definitions of the variable are
7426 encountered by the linker, the first is selected and the remainder are
7427 discarded.  Following usage by the Microsoft compiler, the linker is told
7428 @emph{not} to warn about size or content differences of the multiple
7429 definitions.
7431 Although the primary usage of this attribute is for POD types, the
7432 attribute can also be applied to global C++ objects that are initialized
7433 by a constructor.  In this case, the static initialization and destruction
7434 code for the object is emitted in each translation defining the object,
7435 but the calls to the constructor and destructor are protected by a
7436 link-once guard variable.
7438 The @code{selectany} attribute is only available on Microsoft Windows
7439 targets.  You can use @code{__declspec (selectany)} as a synonym for
7440 @code{__attribute__ ((selectany))} for compatibility with other
7441 compilers.
7443 @item shared
7444 @cindex @code{shared} variable attribute
7445 On Microsoft Windows, in addition to putting variable definitions in a named
7446 section, the section can also be shared among all running copies of an
7447 executable or DLL@.  For example, this small program defines shared data
7448 by putting it in a named section @code{shared} and marking the section
7449 shareable:
7451 @smallexample
7452 int foo __attribute__((section ("shared"), shared)) = 0;
7455 main()
7457   /* @r{Read and write foo.  All running
7458      copies see the same value.}  */
7459   return 0;
7461 @end smallexample
7463 @noindent
7464 You may only use the @code{shared} attribute along with @code{section}
7465 attribute with a fully-initialized global definition because of the way
7466 linkers work.  See @code{section} attribute for more information.
7468 The @code{shared} attribute is only available on Microsoft Windows@.
7470 @end table
7472 @node MSP430 Variable Attributes
7473 @subsection MSP430 Variable Attributes
7475 @table @code
7476 @item noinit
7477 @cindex @code{noinit} variable attribute, MSP430 
7478 Any data with the @code{noinit} attribute will not be initialised by
7479 the C runtime startup code, or the program loader.  Not initialising
7480 data in this way can reduce program startup times.
7482 @item persistent
7483 @cindex @code{persistent} variable attribute, MSP430 
7484 Any variable with the @code{persistent} attribute will not be
7485 initialised by the C runtime startup code.  Instead its value will be
7486 set once, when the application is loaded, and then never initialised
7487 again, even if the processor is reset or the program restarts.
7488 Persistent data is intended to be placed into FLASH RAM, where its
7489 value will be retained across resets.  The linker script being used to
7490 create the application should ensure that persistent data is correctly
7491 placed.
7493 @item lower
7494 @itemx upper
7495 @itemx either
7496 @cindex @code{lower} variable attribute, MSP430 
7497 @cindex @code{upper} variable attribute, MSP430 
7498 @cindex @code{either} variable attribute, MSP430 
7499 These attributes are the same as the MSP430 function attributes of the
7500 same name (@pxref{MSP430 Function Attributes}).  
7501 These attributes can be applied to both functions and variables.
7502 @end table
7504 @node Nvidia PTX Variable Attributes
7505 @subsection Nvidia PTX Variable Attributes
7507 These variable attributes are supported by the Nvidia PTX back end:
7509 @table @code
7510 @item shared
7511 @cindex @code{shared} attribute, Nvidia PTX
7512 Use this attribute to place a variable in the @code{.shared} memory space.
7513 This memory space is private to each cooperative thread array; only threads
7514 within one thread block refer to the same instance of the variable.
7515 The runtime does not initialize variables in this memory space.
7516 @end table
7518 @node PowerPC Variable Attributes
7519 @subsection PowerPC Variable Attributes
7521 Three attributes currently are defined for PowerPC configurations:
7522 @code{altivec}, @code{ms_struct} and @code{gcc_struct}.
7524 @cindex @code{ms_struct} variable attribute, PowerPC
7525 @cindex @code{gcc_struct} variable attribute, PowerPC
7526 For full documentation of the struct attributes please see the
7527 documentation in @ref{x86 Variable Attributes}.
7529 @cindex @code{altivec} variable attribute, PowerPC
7530 For documentation of @code{altivec} attribute please see the
7531 documentation in @ref{PowerPC Type Attributes}.
7533 @node RL78 Variable Attributes
7534 @subsection RL78 Variable Attributes
7536 @cindex @code{saddr} variable attribute, RL78
7537 The RL78 back end supports the @code{saddr} variable attribute.  This
7538 specifies placement of the corresponding variable in the SADDR area,
7539 which can be accessed more efficiently than the default memory region.
7541 @node SPU Variable Attributes
7542 @subsection SPU Variable Attributes
7544 @cindex @code{spu_vector} variable attribute, SPU
7545 The SPU supports the @code{spu_vector} attribute for variables.  For
7546 documentation of this attribute please see the documentation in
7547 @ref{SPU Type Attributes}.
7549 @node V850 Variable Attributes
7550 @subsection V850 Variable Attributes
7552 These variable attributes are supported by the V850 back end:
7554 @table @code
7556 @item sda
7557 @cindex @code{sda} variable attribute, V850
7558 Use this attribute to explicitly place a variable in the small data area,
7559 which can hold up to 64 kilobytes.
7561 @item tda
7562 @cindex @code{tda} variable attribute, V850
7563 Use this attribute to explicitly place a variable in the tiny data area,
7564 which can hold up to 256 bytes in total.
7566 @item zda
7567 @cindex @code{zda} variable attribute, V850
7568 Use this attribute to explicitly place a variable in the first 32 kilobytes
7569 of memory.
7570 @end table
7572 @node x86 Variable Attributes
7573 @subsection x86 Variable Attributes
7575 Two attributes are currently defined for x86 configurations:
7576 @code{ms_struct} and @code{gcc_struct}.
7578 @table @code
7579 @item ms_struct
7580 @itemx gcc_struct
7581 @cindex @code{ms_struct} variable attribute, x86
7582 @cindex @code{gcc_struct} variable attribute, x86
7584 If @code{packed} is used on a structure, or if bit-fields are used,
7585 it may be that the Microsoft ABI lays out the structure differently
7586 than the way GCC normally does.  Particularly when moving packed
7587 data between functions compiled with GCC and the native Microsoft compiler
7588 (either via function call or as data in a file), it may be necessary to access
7589 either format.
7591 The @code{ms_struct} and @code{gcc_struct} attributes correspond
7592 to the @option{-mms-bitfields} and @option{-mno-ms-bitfields}
7593 command-line options, respectively;
7594 see @ref{x86 Options}, for details of how structure layout is affected.
7595 @xref{x86 Type Attributes}, for information about the corresponding
7596 attributes on types.
7598 @end table
7600 @node Xstormy16 Variable Attributes
7601 @subsection Xstormy16 Variable Attributes
7603 One attribute is currently defined for xstormy16 configurations:
7604 @code{below100}.
7606 @table @code
7607 @item below100
7608 @cindex @code{below100} variable attribute, Xstormy16
7610 If a variable has the @code{below100} attribute (@code{BELOW100} is
7611 allowed also), GCC places the variable in the first 0x100 bytes of
7612 memory and use special opcodes to access it.  Such variables are
7613 placed in either the @code{.bss_below100} section or the
7614 @code{.data_below100} section.
7616 @end table
7618 @node Type Attributes
7619 @section Specifying Attributes of Types
7620 @cindex attribute of types
7621 @cindex type attributes
7623 The keyword @code{__attribute__} allows you to specify various special
7624 properties of types.  Some type attributes apply only to structure and
7625 union types, and in C++, also class types, while others can apply to
7626 any type defined via a @code{typedef} declaration.  Unless otherwise
7627 specified, the same restrictions and effects apply to attributes regardless
7628 of whether a type is a trivial structure or a C++ class with user-defined
7629 constructors, destructors, or a copy assignment.
7631 Other attributes are defined for functions (@pxref{Function Attributes}),
7632 labels (@pxref{Label  Attributes}), enumerators (@pxref{Enumerator
7633 Attributes}), statements (@pxref{Statement Attributes}), and for variables
7634 (@pxref{Variable Attributes}).
7636 The @code{__attribute__} keyword is followed by an attribute specification
7637 enclosed in double parentheses.
7639 You may specify type attributes in an enum, struct or union type
7640 declaration or definition by placing them immediately after the
7641 @code{struct}, @code{union} or @code{enum} keyword.  You can also place
7642 them just past the closing curly brace of the definition, but this is less
7643 preferred because logically the type should be fully defined at 
7644 the closing brace.
7646 You can also include type attributes in a @code{typedef} declaration.
7647 @xref{Attribute Syntax}, for details of the exact syntax for using
7648 attributes.
7650 @menu
7651 * Common Type Attributes::
7652 * ARC Type Attributes::
7653 * ARM Type Attributes::
7654 * MeP Type Attributes::
7655 * PowerPC Type Attributes::
7656 * SPU Type Attributes::
7657 * x86 Type Attributes::
7658 @end menu
7660 @node Common Type Attributes
7661 @subsection Common Type Attributes
7663 The following type attributes are supported on most targets.
7665 @table @code
7666 @cindex @code{aligned} type attribute
7667 @item aligned
7668 @itemx aligned (@var{alignment})
7669 The @code{aligned} attribute specifies a minimum alignment (in bytes) for
7670 variables of the specified type.  When specified, @var{alignment} must be
7671 a power of 2.  Specifying no @var{alignment} argument implies the maximum
7672 alignment for the target, which is often, but by no means always, 8 or 16
7673 bytes.  For example, the declarations:
7675 @smallexample
7676 struct __attribute__ ((aligned (8))) S @{ short f[3]; @};
7677 typedef int more_aligned_int __attribute__ ((aligned (8)));
7678 @end smallexample
7680 @noindent
7681 force the compiler to ensure (as far as it can) that each variable whose
7682 type is @code{struct S} or @code{more_aligned_int} is allocated and
7683 aligned @emph{at least} on a 8-byte boundary.  On a SPARC, having all
7684 variables of type @code{struct S} aligned to 8-byte boundaries allows
7685 the compiler to use the @code{ldd} and @code{std} (doubleword load and
7686 store) instructions when copying one variable of type @code{struct S} to
7687 another, thus improving run-time efficiency.
7689 Note that the alignment of any given @code{struct} or @code{union} type
7690 is required by the ISO C standard to be at least a perfect multiple of
7691 the lowest common multiple of the alignments of all of the members of
7692 the @code{struct} or @code{union} in question.  This means that you @emph{can}
7693 effectively adjust the alignment of a @code{struct} or @code{union}
7694 type by attaching an @code{aligned} attribute to any one of the members
7695 of such a type, but the notation illustrated in the example above is a
7696 more obvious, intuitive, and readable way to request the compiler to
7697 adjust the alignment of an entire @code{struct} or @code{union} type.
7699 As in the preceding example, you can explicitly specify the alignment
7700 (in bytes) that you wish the compiler to use for a given @code{struct}
7701 or @code{union} type.  Alternatively, you can leave out the alignment factor
7702 and just ask the compiler to align a type to the maximum
7703 useful alignment for the target machine you are compiling for.  For
7704 example, you could write:
7706 @smallexample
7707 struct __attribute__ ((aligned)) S @{ short f[3]; @};
7708 @end smallexample
7710 Whenever you leave out the alignment factor in an @code{aligned}
7711 attribute specification, the compiler automatically sets the alignment
7712 for the type to the largest alignment that is ever used for any data
7713 type on the target machine you are compiling for.  Doing this can often
7714 make copy operations more efficient, because the compiler can use
7715 whatever instructions copy the biggest chunks of memory when performing
7716 copies to or from the variables that have types that you have aligned
7717 this way.
7719 In the example above, if the size of each @code{short} is 2 bytes, then
7720 the size of the entire @code{struct S} type is 6 bytes.  The smallest
7721 power of two that is greater than or equal to that is 8, so the
7722 compiler sets the alignment for the entire @code{struct S} type to 8
7723 bytes.
7725 Note that although you can ask the compiler to select a time-efficient
7726 alignment for a given type and then declare only individual stand-alone
7727 objects of that type, the compiler's ability to select a time-efficient
7728 alignment is primarily useful only when you plan to create arrays of
7729 variables having the relevant (efficiently aligned) type.  If you
7730 declare or use arrays of variables of an efficiently-aligned type, then
7731 it is likely that your program also does pointer arithmetic (or
7732 subscripting, which amounts to the same thing) on pointers to the
7733 relevant type, and the code that the compiler generates for these
7734 pointer arithmetic operations is often more efficient for
7735 efficiently-aligned types than for other types.
7737 Note that the effectiveness of @code{aligned} attributes may be limited
7738 by inherent limitations in your linker.  On many systems, the linker is
7739 only able to arrange for variables to be aligned up to a certain maximum
7740 alignment.  (For some linkers, the maximum supported alignment may
7741 be very very small.)  If your linker is only able to align variables
7742 up to a maximum of 8-byte alignment, then specifying @code{aligned (16)}
7743 in an @code{__attribute__} still only provides you with 8-byte
7744 alignment.  See your linker documentation for further information.
7746 When used on a struct, or struct member, the @code{aligned} attribute can
7747 only increase the alignment; in order to decrease it, the @code{packed}
7748 attribute must be specified as well.  When used as part of a typedef, the
7749 @code{aligned} attribute can both increase and decrease alignment, and
7750 specifying the @code{packed} attribute generates a warning.
7752 @cindex @code{warn_if_not_aligned} type attribute
7753 @item warn_if_not_aligned (@var{alignment})
7754 This attribute specifies a threshold for the structure field, measured
7755 in bytes.  If the structure field is aligned below the threshold, a
7756 warning will be issued.  For example, the declaration:
7758 @smallexample
7759 typedef unsigned long long __u64
7760    __attribute__((aligned (4), warn_if_not_aligned (8)));
7762 struct foo
7764   int i1;
7765   int i2;
7766   __u64 x;
7768 @end smallexample
7770 @noindent
7771 causes the compiler to issue an warning on @code{struct foo}, like
7772 @samp{warning: alignment 4 of 'struct foo' is less than 8}.
7773 It is used to define @code{struct foo} in such a way that
7774 @code{struct foo} has the same layout and the structure field @code{x}
7775 has the same alignment when @code{__u64} is aligned at either 4 or
7776 8 bytes.  Align @code{struct foo} to 8 bytes:
7778 @smallexample
7779 struct __attribute__ ((aligned (8))) foo
7781   int i1;
7782   int i2;
7783   __u64 x;
7785 @end smallexample
7787 @noindent
7788 silences the warning.  The compiler also issues a warning, like
7789 @samp{warning: 'x' offset 12 in 'struct foo' isn't aligned to 8},
7790 when the structure field has the misaligned offset:
7792 @smallexample
7793 struct __attribute__ ((aligned (8))) foo
7795   int i1;
7796   int i2;
7797   int i3;
7798   __u64 x;
7800 @end smallexample
7802 This warning can be disabled by @option{-Wno-if-not-aligned}.
7804 @item alloc_size (@var{position})
7805 @itemx alloc_size (@var{position-1}, @var{position-2})
7806 @cindex @code{alloc_size} type attribute
7807 The @code{alloc_size} type attribute may be applied to the definition
7808 of a type of a function that returns a pointer and takes at least one
7809 argument of an integer type.  It indicates that the returned pointer
7810 points to an object whose size is given by the function argument at
7811 @var{position-1}, or by the product of the arguments at @var{position-1}
7812 and @var{position-2}.  Meaningful sizes are positive values less than
7813 @code{PTRDIFF_MAX}.  Other sizes are disagnosed when detected.  GCC uses
7814 this information to improve the results of @code{__builtin_object_size}.
7816 For instance, the following declarations
7818 @smallexample
7819 typedef __attribute__ ((alloc_size (1, 2))) void*
7820   calloc_type (size_t, size_t);
7821 typedef __attribute__ ((alloc_size (1))) void*
7822   malloc_type (size_t);
7823 @end smallexample
7825 @noindent
7826 specify that @code{calloc_type} is a type of a function that, like
7827 the standard C function @code{calloc}, returns an object whose size
7828 is given by the product of arguments 1 and 2, and that
7829 @code{malloc_type}, like the standard C function @code{malloc},
7830 returns an object whose size is given by argument 1 to the function.
7832 @item copy
7833 @itemx copy (@var{expression})
7834 @cindex @code{copy} type attribute
7835 The @code{copy} attribute applies the set of attributes with which
7836 the type of the @var{expression} has been declared to the declaration
7837 of the type to which the attribute is applied.  The attribute is
7838 designed for libraries that define aliases that are expected to
7839 specify the same set of attributes as the aliased symbols.
7840 The @code{copy} attribute can be used with types, variables, or
7841 functions.  However, the kind of symbol to which the attribute is
7842 applied (either varible or function) must match the kind of symbol
7843 to which the argument refers.
7844 The @code{copy} attribute copies only syntactic and semantic attributes
7845 but not attributes that affect a symbol's linkage or visibility such as
7846 @code{alias}, @code{visibility}, or @code{weak}.  The @code{deprecated}
7847 attribute is also not copied.  @xref{Common Function Attributes}.
7848 @xref{Common Variable Attributes}.
7850 For example, suppose @code{struct A} below is defined in some third
7851 party library header to have the alignment requirement @code{N} and
7852 to force a warning whenever a variable of the type is not so aligned
7853 due to attribute @code{packed}.  Specifying the @code{copy} attribute
7854 on the definition on the unrelated @code{struct B} has the effect of
7855 copying all relevant attributes from the type referenced by the pointer
7856 expression to @code{struct B}.
7858 @smallexample
7859 struct __attribute__ ((aligned (N), warn_if_not_aligned (N)))
7860 A @{ /* @r{@dots{}} */ @};
7861 struct __attribute__ ((copy ( (struct A *)0)) B @{ /* @r{@dots{}} */ @};
7862 @end smallexample
7864 @item deprecated
7865 @itemx deprecated (@var{msg})
7866 @cindex @code{deprecated} type attribute
7867 The @code{deprecated} attribute results in a warning if the type
7868 is used anywhere in the source file.  This is useful when identifying
7869 types that are expected to be removed in a future version of a program.
7870 If possible, the warning also includes the location of the declaration
7871 of the deprecated type, to enable users to easily find further
7872 information about why the type is deprecated, or what they should do
7873 instead.  Note that the warnings only occur for uses and then only
7874 if the type is being applied to an identifier that itself is not being
7875 declared as deprecated.
7877 @smallexample
7878 typedef int T1 __attribute__ ((deprecated));
7879 T1 x;
7880 typedef T1 T2;
7881 T2 y;
7882 typedef T1 T3 __attribute__ ((deprecated));
7883 T3 z __attribute__ ((deprecated));
7884 @end smallexample
7886 @noindent
7887 results in a warning on line 2 and 3 but not lines 4, 5, or 6.  No
7888 warning is issued for line 4 because T2 is not explicitly
7889 deprecated.  Line 5 has no warning because T3 is explicitly
7890 deprecated.  Similarly for line 6.  The optional @var{msg}
7891 argument, which must be a string, is printed in the warning if
7892 present.  Control characters in the string will be replaced with
7893 escape sequences, and if the @option{-fmessage-length} option is set
7894 to 0 (its default value) then any newline characters will be ignored.
7896 The @code{deprecated} attribute can also be used for functions and
7897 variables (@pxref{Function Attributes}, @pxref{Variable Attributes}.)
7899 The message attached to the attribute is affected by the setting of
7900 the @option{-fmessage-length} option.
7902 @item designated_init
7903 @cindex @code{designated_init} type attribute
7904 This attribute may only be applied to structure types.  It indicates
7905 that any initialization of an object of this type must use designated
7906 initializers rather than positional initializers.  The intent of this
7907 attribute is to allow the programmer to indicate that a structure's
7908 layout may change, and that therefore relying on positional
7909 initialization will result in future breakage.
7911 GCC emits warnings based on this attribute by default; use
7912 @option{-Wno-designated-init} to suppress them.
7914 @item may_alias
7915 @cindex @code{may_alias} type attribute
7916 Accesses through pointers to types with this attribute are not subject
7917 to type-based alias analysis, but are instead assumed to be able to alias
7918 any other type of objects.
7919 In the context of section 6.5 paragraph 7 of the C99 standard,
7920 an lvalue expression
7921 dereferencing such a pointer is treated like having a character type.
7922 See @option{-fstrict-aliasing} for more information on aliasing issues.
7923 This extension exists to support some vector APIs, in which pointers to
7924 one vector type are permitted to alias pointers to a different vector type.
7926 Note that an object of a type with this attribute does not have any
7927 special semantics.
7929 Example of use:
7931 @smallexample
7932 typedef short __attribute__ ((__may_alias__)) short_a;
7935 main (void)
7937   int a = 0x12345678;
7938   short_a *b = (short_a *) &a;
7940   b[1] = 0;
7942   if (a == 0x12345678)
7943     abort();
7945   exit(0);
7947 @end smallexample
7949 @noindent
7950 If you replaced @code{short_a} with @code{short} in the variable
7951 declaration, the above program would abort when compiled with
7952 @option{-fstrict-aliasing}, which is on by default at @option{-O2} or
7953 above.
7955 @item mode (@var{mode})
7956 @cindex @code{mode} type attribute
7957 This attribute specifies the data type for the declaration---whichever
7958 type corresponds to the mode @var{mode}.  This in effect lets you
7959 request an integer or floating-point type according to its width.
7961 @xref{Machine Modes,,, gccint, GNU Compiler Collection (GCC) Internals},
7962 for a list of the possible keywords for @var{mode}.
7963 You may also specify a mode of @code{byte} or @code{__byte__} to
7964 indicate the mode corresponding to a one-byte integer, @code{word} or
7965 @code{__word__} for the mode of a one-word integer, and @code{pointer}
7966 or @code{__pointer__} for the mode used to represent pointers.
7968 @item packed
7969 @cindex @code{packed} type attribute
7970 This attribute, attached to a @code{struct}, @code{union}, or C++ @code{class}
7971 type definition, specifies that each of its members (other than zero-width
7972 bit-fields) is placed to minimize the memory required.  This is equivalent
7973 to specifying the @code{packed} attribute on each of the members.
7975 @opindex fshort-enums
7976 When attached to an @code{enum} definition, the @code{packed} attribute
7977 indicates that the smallest integral type should be used.
7978 Specifying the @option{-fshort-enums} flag on the command line
7979 is equivalent to specifying the @code{packed}
7980 attribute on all @code{enum} definitions.
7982 In the following example @code{struct my_packed_struct}'s members are
7983 packed closely together, but the internal layout of its @code{s} member
7984 is not packed---to do that, @code{struct my_unpacked_struct} needs to
7985 be packed too.
7987 @smallexample
7988 struct my_unpacked_struct
7989  @{
7990     char c;
7991     int i;
7992  @};
7994 struct __attribute__ ((__packed__)) my_packed_struct
7995   @{
7996      char c;
7997      int  i;
7998      struct my_unpacked_struct s;
7999   @};
8000 @end smallexample
8002 You may only specify the @code{packed} attribute on the definition
8003 of an @code{enum}, @code{struct}, @code{union}, or @code{class}, 
8004 not on a @code{typedef} that does not also define the enumerated type,
8005 structure, union, or class.
8007 @item scalar_storage_order ("@var{endianness}")
8008 @cindex @code{scalar_storage_order} type attribute
8009 When attached to a @code{union} or a @code{struct}, this attribute sets
8010 the storage order, aka endianness, of the scalar fields of the type, as
8011 well as the array fields whose component is scalar.  The supported
8012 endiannesses are @code{big-endian} and @code{little-endian}.  The attribute
8013 has no effects on fields which are themselves a @code{union}, a @code{struct}
8014 or an array whose component is a @code{union} or a @code{struct}, and it is
8015 possible for these fields to have a different scalar storage order than the
8016 enclosing type.
8018 This attribute is supported only for targets that use a uniform default
8019 scalar storage order (fortunately, most of them), i.e.@: targets that store
8020 the scalars either all in big-endian or all in little-endian.
8022 Additional restrictions are enforced for types with the reverse scalar
8023 storage order with regard to the scalar storage order of the target:
8025 @itemize
8026 @item Taking the address of a scalar field of a @code{union} or a
8027 @code{struct} with reverse scalar storage order is not permitted and yields
8028 an error.
8029 @item Taking the address of an array field, whose component is scalar, of
8030 a @code{union} or a @code{struct} with reverse scalar storage order is
8031 permitted but yields a warning, unless @option{-Wno-scalar-storage-order}
8032 is specified.
8033 @item Taking the address of a @code{union} or a @code{struct} with reverse
8034 scalar storage order is permitted.
8035 @end itemize
8037 These restrictions exist because the storage order attribute is lost when
8038 the address of a scalar or the address of an array with scalar component is
8039 taken, so storing indirectly through this address generally does not work.
8040 The second case is nevertheless allowed to be able to perform a block copy
8041 from or to the array.
8043 Moreover, the use of type punning or aliasing to toggle the storage order
8044 is not supported; that is to say, a given scalar object cannot be accessed
8045 through distinct types that assign a different storage order to it.
8047 @item transparent_union
8048 @cindex @code{transparent_union} type attribute
8050 This attribute, attached to a @code{union} type definition, indicates
8051 that any function parameter having that union type causes calls to that
8052 function to be treated in a special way.
8054 First, the argument corresponding to a transparent union type can be of
8055 any type in the union; no cast is required.  Also, if the union contains
8056 a pointer type, the corresponding argument can be a null pointer
8057 constant or a void pointer expression; and if the union contains a void
8058 pointer type, the corresponding argument can be any pointer expression.
8059 If the union member type is a pointer, qualifiers like @code{const} on
8060 the referenced type must be respected, just as with normal pointer
8061 conversions.
8063 Second, the argument is passed to the function using the calling
8064 conventions of the first member of the transparent union, not the calling
8065 conventions of the union itself.  All members of the union must have the
8066 same machine representation; this is necessary for this argument passing
8067 to work properly.
8069 Transparent unions are designed for library functions that have multiple
8070 interfaces for compatibility reasons.  For example, suppose the
8071 @code{wait} function must accept either a value of type @code{int *} to
8072 comply with POSIX, or a value of type @code{union wait *} to comply with
8073 the 4.1BSD interface.  If @code{wait}'s parameter were @code{void *},
8074 @code{wait} would accept both kinds of arguments, but it would also
8075 accept any other pointer type and this would make argument type checking
8076 less useful.  Instead, @code{<sys/wait.h>} might define the interface
8077 as follows:
8079 @smallexample
8080 typedef union __attribute__ ((__transparent_union__))
8081   @{
8082     int *__ip;
8083     union wait *__up;
8084   @} wait_status_ptr_t;
8086 pid_t wait (wait_status_ptr_t);
8087 @end smallexample
8089 @noindent
8090 This interface allows either @code{int *} or @code{union wait *}
8091 arguments to be passed, using the @code{int *} calling convention.
8092 The program can call @code{wait} with arguments of either type:
8094 @smallexample
8095 int w1 () @{ int w; return wait (&w); @}
8096 int w2 () @{ union wait w; return wait (&w); @}
8097 @end smallexample
8099 @noindent
8100 With this interface, @code{wait}'s implementation might look like this:
8102 @smallexample
8103 pid_t wait (wait_status_ptr_t p)
8105   return waitpid (-1, p.__ip, 0);
8107 @end smallexample
8109 @item unused
8110 @cindex @code{unused} type attribute
8111 When attached to a type (including a @code{union} or a @code{struct}),
8112 this attribute means that variables of that type are meant to appear
8113 possibly unused.  GCC does not produce a warning for any variables of
8114 that type, even if the variable appears to do nothing.  This is often
8115 the case with lock or thread classes, which are usually defined and then
8116 not referenced, but contain constructors and destructors that have
8117 nontrivial bookkeeping functions.
8119 @item visibility
8120 @cindex @code{visibility} type attribute
8121 In C++, attribute visibility (@pxref{Function Attributes}) can also be
8122 applied to class, struct, union and enum types.  Unlike other type
8123 attributes, the attribute must appear between the initial keyword and
8124 the name of the type; it cannot appear after the body of the type.
8126 Note that the type visibility is applied to vague linkage entities
8127 associated with the class (vtable, typeinfo node, etc.).  In
8128 particular, if a class is thrown as an exception in one shared object
8129 and caught in another, the class must have default visibility.
8130 Otherwise the two shared objects are unable to use the same
8131 typeinfo node and exception handling will break.
8133 @end table
8135 To specify multiple attributes, separate them by commas within the
8136 double parentheses: for example, @samp{__attribute__ ((aligned (16),
8137 packed))}.
8139 @node ARC Type Attributes
8140 @subsection ARC Type Attributes
8142 @cindex @code{uncached} type attribute, ARC
8143 Declaring objects with @code{uncached} allows you to exclude
8144 data-cache participation in load and store operations on those objects
8145 without involving the additional semantic implications of
8146 @code{volatile}.  The @code{.di} instruction suffix is used for all
8147 loads and stores of data declared @code{uncached}.
8149 @node ARM Type Attributes
8150 @subsection ARM Type Attributes
8152 @cindex @code{notshared} type attribute, ARM
8153 On those ARM targets that support @code{dllimport} (such as Symbian
8154 OS), you can use the @code{notshared} attribute to indicate that the
8155 virtual table and other similar data for a class should not be
8156 exported from a DLL@.  For example:
8158 @smallexample
8159 class __declspec(notshared) C @{
8160 public:
8161   __declspec(dllimport) C();
8162   virtual void f();
8165 __declspec(dllexport)
8166 C::C() @{@}
8167 @end smallexample
8169 @noindent
8170 In this code, @code{C::C} is exported from the current DLL, but the
8171 virtual table for @code{C} is not exported.  (You can use
8172 @code{__attribute__} instead of @code{__declspec} if you prefer, but
8173 most Symbian OS code uses @code{__declspec}.)
8175 @node MeP Type Attributes
8176 @subsection MeP Type Attributes
8178 @cindex @code{based} type attribute, MeP
8179 @cindex @code{tiny} type attribute, MeP
8180 @cindex @code{near} type attribute, MeP
8181 @cindex @code{far} type attribute, MeP
8182 Many of the MeP variable attributes may be applied to types as well.
8183 Specifically, the @code{based}, @code{tiny}, @code{near}, and
8184 @code{far} attributes may be applied to either.  The @code{io} and
8185 @code{cb} attributes may not be applied to types.
8187 @node PowerPC Type Attributes
8188 @subsection PowerPC Type Attributes
8190 Three attributes currently are defined for PowerPC configurations:
8191 @code{altivec}, @code{ms_struct} and @code{gcc_struct}.
8193 @cindex @code{ms_struct} type attribute, PowerPC
8194 @cindex @code{gcc_struct} type attribute, PowerPC
8195 For full documentation of the @code{ms_struct} and @code{gcc_struct}
8196 attributes please see the documentation in @ref{x86 Type Attributes}.
8198 @cindex @code{altivec} type attribute, PowerPC
8199 The @code{altivec} attribute allows one to declare AltiVec vector data
8200 types supported by the AltiVec Programming Interface Manual.  The
8201 attribute requires an argument to specify one of three vector types:
8202 @code{vector__}, @code{pixel__} (always followed by unsigned short),
8203 and @code{bool__} (always followed by unsigned).
8205 @smallexample
8206 __attribute__((altivec(vector__)))
8207 __attribute__((altivec(pixel__))) unsigned short
8208 __attribute__((altivec(bool__))) unsigned
8209 @end smallexample
8211 These attributes mainly are intended to support the @code{__vector},
8212 @code{__pixel}, and @code{__bool} AltiVec keywords.
8214 @node SPU Type Attributes
8215 @subsection SPU Type Attributes
8217 @cindex @code{spu_vector} type attribute, SPU
8218 The SPU supports the @code{spu_vector} attribute for types.  This attribute
8219 allows one to declare vector data types supported by the Sony/Toshiba/IBM SPU
8220 Language Extensions Specification.  It is intended to support the
8221 @code{__vector} keyword.
8223 @node x86 Type Attributes
8224 @subsection x86 Type Attributes
8226 Two attributes are currently defined for x86 configurations:
8227 @code{ms_struct} and @code{gcc_struct}.
8229 @table @code
8231 @item ms_struct
8232 @itemx gcc_struct
8233 @cindex @code{ms_struct} type attribute, x86
8234 @cindex @code{gcc_struct} type attribute, x86
8236 If @code{packed} is used on a structure, or if bit-fields are used
8237 it may be that the Microsoft ABI packs them differently
8238 than GCC normally packs them.  Particularly when moving packed
8239 data between functions compiled with GCC and the native Microsoft compiler
8240 (either via function call or as data in a file), it may be necessary to access
8241 either format.
8243 The @code{ms_struct} and @code{gcc_struct} attributes correspond
8244 to the @option{-mms-bitfields} and @option{-mno-ms-bitfields}
8245 command-line options, respectively;
8246 see @ref{x86 Options}, for details of how structure layout is affected.
8247 @xref{x86 Variable Attributes}, for information about the corresponding
8248 attributes on variables.
8250 @end table
8252 @node Label Attributes
8253 @section Label Attributes
8254 @cindex Label Attributes
8256 GCC allows attributes to be set on C labels.  @xref{Attribute Syntax}, for 
8257 details of the exact syntax for using attributes.  Other attributes are 
8258 available for functions (@pxref{Function Attributes}), variables 
8259 (@pxref{Variable Attributes}), enumerators (@pxref{Enumerator Attributes}),
8260 statements (@pxref{Statement Attributes}), and for types
8261 (@pxref{Type Attributes}).
8263 This example uses the @code{cold} label attribute to indicate the 
8264 @code{ErrorHandling} branch is unlikely to be taken and that the
8265 @code{ErrorHandling} label is unused:
8267 @smallexample
8269    asm goto ("some asm" : : : : NoError);
8271 /* This branch (the fall-through from the asm) is less commonly used */
8272 ErrorHandling: 
8273    __attribute__((cold, unused)); /* Semi-colon is required here */
8274    printf("error\n");
8275    return 0;
8277 NoError:
8278    printf("no error\n");
8279    return 1;
8280 @end smallexample
8282 @table @code
8283 @item unused
8284 @cindex @code{unused} label attribute
8285 This feature is intended for program-generated code that may contain 
8286 unused labels, but which is compiled with @option{-Wall}.  It is
8287 not normally appropriate to use in it human-written code, though it
8288 could be useful in cases where the code that jumps to the label is
8289 contained within an @code{#ifdef} conditional.
8291 @item hot
8292 @cindex @code{hot} label attribute
8293 The @code{hot} attribute on a label is used to inform the compiler that
8294 the path following the label is more likely than paths that are not so
8295 annotated.  This attribute is used in cases where @code{__builtin_expect}
8296 cannot be used, for instance with computed goto or @code{asm goto}.
8298 @item cold
8299 @cindex @code{cold} label attribute
8300 The @code{cold} attribute on labels is used to inform the compiler that
8301 the path following the label is unlikely to be executed.  This attribute
8302 is used in cases where @code{__builtin_expect} cannot be used, for instance
8303 with computed goto or @code{asm goto}.
8305 @end table
8307 @node Enumerator Attributes
8308 @section Enumerator Attributes
8309 @cindex Enumerator Attributes
8311 GCC allows attributes to be set on enumerators.  @xref{Attribute Syntax}, for
8312 details of the exact syntax for using attributes.  Other attributes are
8313 available for functions (@pxref{Function Attributes}), variables
8314 (@pxref{Variable Attributes}), labels (@pxref{Label Attributes}), statements
8315 (@pxref{Statement Attributes}), and for types (@pxref{Type Attributes}).
8317 This example uses the @code{deprecated} enumerator attribute to indicate the
8318 @code{oldval} enumerator is deprecated:
8320 @smallexample
8321 enum E @{
8322   oldval __attribute__((deprecated)),
8323   newval
8327 fn (void)
8329   return oldval;
8331 @end smallexample
8333 @table @code
8334 @item deprecated
8335 @cindex @code{deprecated} enumerator attribute
8336 The @code{deprecated} attribute results in a warning if the enumerator
8337 is used anywhere in the source file.  This is useful when identifying
8338 enumerators that are expected to be removed in a future version of a
8339 program.  The warning also includes the location of the declaration
8340 of the deprecated enumerator, to enable users to easily find further
8341 information about why the enumerator is deprecated, or what they should
8342 do instead.  Note that the warnings only occurs for uses.
8344 @end table
8346 @node Statement Attributes
8347 @section Statement Attributes
8348 @cindex Statement Attributes
8350 GCC allows attributes to be set on null statements.  @xref{Attribute Syntax},
8351 for details of the exact syntax for using attributes.  Other attributes are
8352 available for functions (@pxref{Function Attributes}), variables
8353 (@pxref{Variable Attributes}), labels (@pxref{Label Attributes}), enumerators
8354 (@pxref{Enumerator Attributes}), and for types (@pxref{Type Attributes}).
8356 This example uses the @code{fallthrough} statement attribute to indicate that
8357 the @option{-Wimplicit-fallthrough} warning should not be emitted:
8359 @smallexample
8360 switch (cond)
8361   @{
8362   case 1:
8363     bar (1);
8364     __attribute__((fallthrough));
8365   case 2:
8366     @dots{}
8367   @}
8368 @end smallexample
8370 @table @code
8371 @item fallthrough
8372 @cindex @code{fallthrough} statement attribute
8373 The @code{fallthrough} attribute with a null statement serves as a
8374 fallthrough statement.  It hints to the compiler that a statement
8375 that falls through to another case label, or user-defined label
8376 in a switch statement is intentional and thus the
8377 @option{-Wimplicit-fallthrough} warning must not trigger.  The
8378 fallthrough attribute may appear at most once in each attribute
8379 list, and may not be mixed with other attributes.  It can only
8380 be used in a switch statement (the compiler will issue an error
8381 otherwise), after a preceding statement and before a logically
8382 succeeding case label, or user-defined label.
8384 @end table
8386 @node Attribute Syntax
8387 @section Attribute Syntax
8388 @cindex attribute syntax
8390 This section describes the syntax with which @code{__attribute__} may be
8391 used, and the constructs to which attribute specifiers bind, for the C
8392 language.  Some details may vary for C++ and Objective-C@.  Because of
8393 infelicities in the grammar for attributes, some forms described here
8394 may not be successfully parsed in all cases.
8396 There are some problems with the semantics of attributes in C++.  For
8397 example, there are no manglings for attributes, although they may affect
8398 code generation, so problems may arise when attributed types are used in
8399 conjunction with templates or overloading.  Similarly, @code{typeid}
8400 does not distinguish between types with different attributes.  Support
8401 for attributes in C++ may be restricted in future to attributes on
8402 declarations only, but not on nested declarators.
8404 @xref{Function Attributes}, for details of the semantics of attributes
8405 applying to functions.  @xref{Variable Attributes}, for details of the
8406 semantics of attributes applying to variables.  @xref{Type Attributes},
8407 for details of the semantics of attributes applying to structure, union
8408 and enumerated types.
8409 @xref{Label Attributes}, for details of the semantics of attributes 
8410 applying to labels.
8411 @xref{Enumerator Attributes}, for details of the semantics of attributes
8412 applying to enumerators.
8413 @xref{Statement Attributes}, for details of the semantics of attributes
8414 applying to statements.
8416 An @dfn{attribute specifier} is of the form
8417 @code{__attribute__ ((@var{attribute-list}))}.  An @dfn{attribute list}
8418 is a possibly empty comma-separated sequence of @dfn{attributes}, where
8419 each attribute is one of the following:
8421 @itemize @bullet
8422 @item
8423 Empty.  Empty attributes are ignored.
8425 @item
8426 An attribute name
8427 (which may be an identifier such as @code{unused}, or a reserved
8428 word such as @code{const}).
8430 @item
8431 An attribute name followed by a parenthesized list of
8432 parameters for the attribute.
8433 These parameters take one of the following forms:
8435 @itemize @bullet
8436 @item
8437 An identifier.  For example, @code{mode} attributes use this form.
8439 @item
8440 An identifier followed by a comma and a non-empty comma-separated list
8441 of expressions.  For example, @code{format} attributes use this form.
8443 @item
8444 A possibly empty comma-separated list of expressions.  For example,
8445 @code{format_arg} attributes use this form with the list being a single
8446 integer constant expression, and @code{alias} attributes use this form
8447 with the list being a single string constant.
8448 @end itemize
8449 @end itemize
8451 An @dfn{attribute specifier list} is a sequence of one or more attribute
8452 specifiers, not separated by any other tokens.
8454 You may optionally specify attribute names with @samp{__}
8455 preceding and following the name.
8456 This allows you to use them in header files without
8457 being concerned about a possible macro of the same name.  For example,
8458 you may use the attribute name @code{__noreturn__} instead of @code{noreturn}.
8461 @subsubheading Label Attributes
8463 In GNU C, an attribute specifier list may appear after the colon following a
8464 label, other than a @code{case} or @code{default} label.  GNU C++ only permits
8465 attributes on labels if the attribute specifier is immediately
8466 followed by a semicolon (i.e., the label applies to an empty
8467 statement).  If the semicolon is missing, C++ label attributes are
8468 ambiguous, as it is permissible for a declaration, which could begin
8469 with an attribute list, to be labelled in C++.  Declarations cannot be
8470 labelled in C90 or C99, so the ambiguity does not arise there.
8472 @subsubheading Enumerator Attributes
8474 In GNU C, an attribute specifier list may appear as part of an enumerator.
8475 The attribute goes after the enumeration constant, before @code{=}, if
8476 present.  The optional attribute in the enumerator appertains to the
8477 enumeration constant.  It is not possible to place the attribute after
8478 the constant expression, if present.
8480 @subsubheading Statement Attributes
8481 In GNU C, an attribute specifier list may appear as part of a null
8482 statement.  The attribute goes before the semicolon.
8484 @subsubheading Type Attributes
8486 An attribute specifier list may appear as part of a @code{struct},
8487 @code{union} or @code{enum} specifier.  It may go either immediately
8488 after the @code{struct}, @code{union} or @code{enum} keyword, or after
8489 the closing brace.  The former syntax is preferred.
8490 Where attribute specifiers follow the closing brace, they are considered
8491 to relate to the structure, union or enumerated type defined, not to any
8492 enclosing declaration the type specifier appears in, and the type
8493 defined is not complete until after the attribute specifiers.
8494 @c Otherwise, there would be the following problems: a shift/reduce
8495 @c conflict between attributes binding the struct/union/enum and
8496 @c binding to the list of specifiers/qualifiers; and "aligned"
8497 @c attributes could use sizeof for the structure, but the size could be
8498 @c changed later by "packed" attributes.
8501 @subsubheading All other attributes
8503 Otherwise, an attribute specifier appears as part of a declaration,
8504 counting declarations of unnamed parameters and type names, and relates
8505 to that declaration (which may be nested in another declaration, for
8506 example in the case of a parameter declaration), or to a particular declarator
8507 within a declaration.  Where an
8508 attribute specifier is applied to a parameter declared as a function or
8509 an array, it should apply to the function or array rather than the
8510 pointer to which the parameter is implicitly converted, but this is not
8511 yet correctly implemented.
8513 Any list of specifiers and qualifiers at the start of a declaration may
8514 contain attribute specifiers, whether or not such a list may in that
8515 context contain storage class specifiers.  (Some attributes, however,
8516 are essentially in the nature of storage class specifiers, and only make
8517 sense where storage class specifiers may be used; for example,
8518 @code{section}.)  There is one necessary limitation to this syntax: the
8519 first old-style parameter declaration in a function definition cannot
8520 begin with an attribute specifier, because such an attribute applies to
8521 the function instead by syntax described below (which, however, is not
8522 yet implemented in this case).  In some other cases, attribute
8523 specifiers are permitted by this grammar but not yet supported by the
8524 compiler.  All attribute specifiers in this place relate to the
8525 declaration as a whole.  In the obsolescent usage where a type of
8526 @code{int} is implied by the absence of type specifiers, such a list of
8527 specifiers and qualifiers may be an attribute specifier list with no
8528 other specifiers or qualifiers.
8530 At present, the first parameter in a function prototype must have some
8531 type specifier that is not an attribute specifier; this resolves an
8532 ambiguity in the interpretation of @code{void f(int
8533 (__attribute__((foo)) x))}, but is subject to change.  At present, if
8534 the parentheses of a function declarator contain only attributes then
8535 those attributes are ignored, rather than yielding an error or warning
8536 or implying a single parameter of type int, but this is subject to
8537 change.
8539 An attribute specifier list may appear immediately before a declarator
8540 (other than the first) in a comma-separated list of declarators in a
8541 declaration of more than one identifier using a single list of
8542 specifiers and qualifiers.  Such attribute specifiers apply
8543 only to the identifier before whose declarator they appear.  For
8544 example, in
8546 @smallexample
8547 __attribute__((noreturn)) void d0 (void),
8548     __attribute__((format(printf, 1, 2))) d1 (const char *, ...),
8549      d2 (void);
8550 @end smallexample
8552 @noindent
8553 the @code{noreturn} attribute applies to all the functions
8554 declared; the @code{format} attribute only applies to @code{d1}.
8556 An attribute specifier list may appear immediately before the comma,
8557 @code{=} or semicolon terminating the declaration of an identifier other
8558 than a function definition.  Such attribute specifiers apply
8559 to the declared object or function.  Where an
8560 assembler name for an object or function is specified (@pxref{Asm
8561 Labels}), the attribute must follow the @code{asm}
8562 specification.
8564 An attribute specifier list may, in future, be permitted to appear after
8565 the declarator in a function definition (before any old-style parameter
8566 declarations or the function body).
8568 Attribute specifiers may be mixed with type qualifiers appearing inside
8569 the @code{[]} of a parameter array declarator, in the C99 construct by
8570 which such qualifiers are applied to the pointer to which the array is
8571 implicitly converted.  Such attribute specifiers apply to the pointer,
8572 not to the array, but at present this is not implemented and they are
8573 ignored.
8575 An attribute specifier list may appear at the start of a nested
8576 declarator.  At present, there are some limitations in this usage: the
8577 attributes correctly apply to the declarator, but for most individual
8578 attributes the semantics this implies are not implemented.
8579 When attribute specifiers follow the @code{*} of a pointer
8580 declarator, they may be mixed with any type qualifiers present.
8581 The following describes the formal semantics of this syntax.  It makes the
8582 most sense if you are familiar with the formal specification of
8583 declarators in the ISO C standard.
8585 Consider (as in C99 subclause 6.7.5 paragraph 4) a declaration @code{T
8586 D1}, where @code{T} contains declaration specifiers that specify a type
8587 @var{Type} (such as @code{int}) and @code{D1} is a declarator that
8588 contains an identifier @var{ident}.  The type specified for @var{ident}
8589 for derived declarators whose type does not include an attribute
8590 specifier is as in the ISO C standard.
8592 If @code{D1} has the form @code{( @var{attribute-specifier-list} D )},
8593 and the declaration @code{T D} specifies the type
8594 ``@var{derived-declarator-type-list} @var{Type}'' for @var{ident}, then
8595 @code{T D1} specifies the type ``@var{derived-declarator-type-list}
8596 @var{attribute-specifier-list} @var{Type}'' for @var{ident}.
8598 If @code{D1} has the form @code{*
8599 @var{type-qualifier-and-attribute-specifier-list} D}, and the
8600 declaration @code{T D} specifies the type
8601 ``@var{derived-declarator-type-list} @var{Type}'' for @var{ident}, then
8602 @code{T D1} specifies the type ``@var{derived-declarator-type-list}
8603 @var{type-qualifier-and-attribute-specifier-list} pointer to @var{Type}'' for
8604 @var{ident}.
8606 For example,
8608 @smallexample
8609 void (__attribute__((noreturn)) ****f) (void);
8610 @end smallexample
8612 @noindent
8613 specifies the type ``pointer to pointer to pointer to pointer to
8614 non-returning function returning @code{void}''.  As another example,
8616 @smallexample
8617 char *__attribute__((aligned(8))) *f;
8618 @end smallexample
8620 @noindent
8621 specifies the type ``pointer to 8-byte-aligned pointer to @code{char}''.
8622 Note again that this does not work with most attributes; for example,
8623 the usage of @samp{aligned} and @samp{noreturn} attributes given above
8624 is not yet supported.
8626 For compatibility with existing code written for compiler versions that
8627 did not implement attributes on nested declarators, some laxity is
8628 allowed in the placing of attributes.  If an attribute that only applies
8629 to types is applied to a declaration, it is treated as applying to
8630 the type of that declaration.  If an attribute that only applies to
8631 declarations is applied to the type of a declaration, it is treated
8632 as applying to that declaration; and, for compatibility with code
8633 placing the attributes immediately before the identifier declared, such
8634 an attribute applied to a function return type is treated as
8635 applying to the function type, and such an attribute applied to an array
8636 element type is treated as applying to the array type.  If an
8637 attribute that only applies to function types is applied to a
8638 pointer-to-function type, it is treated as applying to the pointer
8639 target type; if such an attribute is applied to a function return type
8640 that is not a pointer-to-function type, it is treated as applying
8641 to the function type.
8643 @node Function Prototypes
8644 @section Prototypes and Old-Style Function Definitions
8645 @cindex function prototype declarations
8646 @cindex old-style function definitions
8647 @cindex promotion of formal parameters
8649 GNU C extends ISO C to allow a function prototype to override a later
8650 old-style non-prototype definition.  Consider the following example:
8652 @smallexample
8653 /* @r{Use prototypes unless the compiler is old-fashioned.}  */
8654 #ifdef __STDC__
8655 #define P(x) x
8656 #else
8657 #define P(x) ()
8658 #endif
8660 /* @r{Prototype function declaration.}  */
8661 int isroot P((uid_t));
8663 /* @r{Old-style function definition.}  */
8665 isroot (x)   /* @r{??? lossage here ???} */
8666      uid_t x;
8668   return x == 0;
8670 @end smallexample
8672 Suppose the type @code{uid_t} happens to be @code{short}.  ISO C does
8673 not allow this example, because subword arguments in old-style
8674 non-prototype definitions are promoted.  Therefore in this example the
8675 function definition's argument is really an @code{int}, which does not
8676 match the prototype argument type of @code{short}.
8678 This restriction of ISO C makes it hard to write code that is portable
8679 to traditional C compilers, because the programmer does not know
8680 whether the @code{uid_t} type is @code{short}, @code{int}, or
8681 @code{long}.  Therefore, in cases like these GNU C allows a prototype
8682 to override a later old-style definition.  More precisely, in GNU C, a
8683 function prototype argument type overrides the argument type specified
8684 by a later old-style definition if the former type is the same as the
8685 latter type before promotion.  Thus in GNU C the above example is
8686 equivalent to the following:
8688 @smallexample
8689 int isroot (uid_t);
8692 isroot (uid_t x)
8694   return x == 0;
8696 @end smallexample
8698 @noindent
8699 GNU C++ does not support old-style function definitions, so this
8700 extension is irrelevant.
8702 @node C++ Comments
8703 @section C++ Style Comments
8704 @cindex @code{//}
8705 @cindex C++ comments
8706 @cindex comments, C++ style
8708 In GNU C, you may use C++ style comments, which start with @samp{//} and
8709 continue until the end of the line.  Many other C implementations allow
8710 such comments, and they are included in the 1999 C standard.  However,
8711 C++ style comments are not recognized if you specify an @option{-std}
8712 option specifying a version of ISO C before C99, or @option{-ansi}
8713 (equivalent to @option{-std=c90}).
8715 @node Dollar Signs
8716 @section Dollar Signs in Identifier Names
8717 @cindex $
8718 @cindex dollar signs in identifier names
8719 @cindex identifier names, dollar signs in
8721 In GNU C, you may normally use dollar signs in identifier names.
8722 This is because many traditional C implementations allow such identifiers.
8723 However, dollar signs in identifiers are not supported on a few target
8724 machines, typically because the target assembler does not allow them.
8726 @node Character Escapes
8727 @section The Character @key{ESC} in Constants
8729 You can use the sequence @samp{\e} in a string or character constant to
8730 stand for the ASCII character @key{ESC}.
8732 @node Alignment
8733 @section Determining the Alignment of Functions, Types or Variables
8734 @cindex alignment
8735 @cindex type alignment
8736 @cindex variable alignment
8738 The keyword @code{__alignof__} determines the alignment requirement of
8739 a function, object, or a type, or the minimum alignment usually required
8740 by a type.  Its syntax is just like @code{sizeof} and C11 @code{_Alignof}.
8742 For example, if the target machine requires a @code{double} value to be
8743 aligned on an 8-byte boundary, then @code{__alignof__ (double)} is 8.
8744 This is true on many RISC machines.  On more traditional machine
8745 designs, @code{__alignof__ (double)} is 4 or even 2.
8747 Some machines never actually require alignment; they allow references to any
8748 data type even at an odd address.  For these machines, @code{__alignof__}
8749 reports the smallest alignment that GCC gives the data type, usually as
8750 mandated by the target ABI.
8752 If the operand of @code{__alignof__} is an lvalue rather than a type,
8753 its value is the required alignment for its type, taking into account
8754 any minimum alignment specified by attribute @code{aligned}
8755 (@pxref{Common Variable Attributes}).  For example, after this
8756 declaration:
8758 @smallexample
8759 struct foo @{ int x; char y; @} foo1;
8760 @end smallexample
8762 @noindent
8763 the value of @code{__alignof__ (foo1.y)} is 1, even though its actual
8764 alignment is probably 2 or 4, the same as @code{__alignof__ (int)}.
8765 It is an error to ask for the alignment of an incomplete type other
8766 than @code{void}.
8768 If the operand of the @code{__alignof__} expression is a function,
8769 the expression evaluates to the alignment of the function which may
8770 be specified by attribute @code{aligned} (@pxref{Common Function Attributes}).
8772 @node Inline
8773 @section An Inline Function is As Fast As a Macro
8774 @cindex inline functions
8775 @cindex integrating function code
8776 @cindex open coding
8777 @cindex macros, inline alternative
8779 By declaring a function inline, you can direct GCC to make
8780 calls to that function faster.  One way GCC can achieve this is to
8781 integrate that function's code into the code for its callers.  This
8782 makes execution faster by eliminating the function-call overhead; in
8783 addition, if any of the actual argument values are constant, their
8784 known values may permit simplifications at compile time so that not
8785 all of the inline function's code needs to be included.  The effect on
8786 code size is less predictable; object code may be larger or smaller
8787 with function inlining, depending on the particular case.  You can
8788 also direct GCC to try to integrate all ``simple enough'' functions
8789 into their callers with the option @option{-finline-functions}.
8791 GCC implements three different semantics of declaring a function
8792 inline.  One is available with @option{-std=gnu89} or
8793 @option{-fgnu89-inline} or when @code{gnu_inline} attribute is present
8794 on all inline declarations, another when
8795 @option{-std=c99},
8796 @option{-std=gnu99} or an option for a later C version is used
8797 (without @option{-fgnu89-inline}), and the third
8798 is used when compiling C++.
8800 To declare a function inline, use the @code{inline} keyword in its
8801 declaration, like this:
8803 @smallexample
8804 static inline int
8805 inc (int *a)
8807   return (*a)++;
8809 @end smallexample
8811 If you are writing a header file to be included in ISO C90 programs, write
8812 @code{__inline__} instead of @code{inline}.  @xref{Alternate Keywords}.
8814 The three types of inlining behave similarly in two important cases:
8815 when the @code{inline} keyword is used on a @code{static} function,
8816 like the example above, and when a function is first declared without
8817 using the @code{inline} keyword and then is defined with
8818 @code{inline}, like this:
8820 @smallexample
8821 extern int inc (int *a);
8822 inline int
8823 inc (int *a)
8825   return (*a)++;
8827 @end smallexample
8829 In both of these common cases, the program behaves the same as if you
8830 had not used the @code{inline} keyword, except for its speed.
8832 @cindex inline functions, omission of
8833 @opindex fkeep-inline-functions
8834 When a function is both inline and @code{static}, if all calls to the
8835 function are integrated into the caller, and the function's address is
8836 never used, then the function's own assembler code is never referenced.
8837 In this case, GCC does not actually output assembler code for the
8838 function, unless you specify the option @option{-fkeep-inline-functions}.
8839 If there is a nonintegrated call, then the function is compiled to
8840 assembler code as usual.  The function must also be compiled as usual if
8841 the program refers to its address, because that cannot be inlined.
8843 @opindex Winline
8844 Note that certain usages in a function definition can make it unsuitable
8845 for inline substitution.  Among these usages are: variadic functions,
8846 use of @code{alloca}, use of computed goto (@pxref{Labels as Values}),
8847 use of nonlocal goto, use of nested functions, use of @code{setjmp}, use
8848 of @code{__builtin_longjmp} and use of @code{__builtin_return} or
8849 @code{__builtin_apply_args}.  Using @option{-Winline} warns when a
8850 function marked @code{inline} could not be substituted, and gives the
8851 reason for the failure.
8853 @cindex automatic @code{inline} for C++ member fns
8854 @cindex @code{inline} automatic for C++ member fns
8855 @cindex member fns, automatically @code{inline}
8856 @cindex C++ member fns, automatically @code{inline}
8857 @opindex fno-default-inline
8858 As required by ISO C++, GCC considers member functions defined within
8859 the body of a class to be marked inline even if they are
8860 not explicitly declared with the @code{inline} keyword.  You can
8861 override this with @option{-fno-default-inline}; @pxref{C++ Dialect
8862 Options,,Options Controlling C++ Dialect}.
8864 GCC does not inline any functions when not optimizing unless you specify
8865 the @samp{always_inline} attribute for the function, like this:
8867 @smallexample
8868 /* @r{Prototype.}  */
8869 inline void foo (const char) __attribute__((always_inline));
8870 @end smallexample
8872 The remainder of this section is specific to GNU C90 inlining.
8874 @cindex non-static inline function
8875 When an inline function is not @code{static}, then the compiler must assume
8876 that there may be calls from other source files; since a global symbol can
8877 be defined only once in any program, the function must not be defined in
8878 the other source files, so the calls therein cannot be integrated.
8879 Therefore, a non-@code{static} inline function is always compiled on its
8880 own in the usual fashion.
8882 If you specify both @code{inline} and @code{extern} in the function
8883 definition, then the definition is used only for inlining.  In no case
8884 is the function compiled on its own, not even if you refer to its
8885 address explicitly.  Such an address becomes an external reference, as
8886 if you had only declared the function, and had not defined it.
8888 This combination of @code{inline} and @code{extern} has almost the
8889 effect of a macro.  The way to use it is to put a function definition in
8890 a header file with these keywords, and put another copy of the
8891 definition (lacking @code{inline} and @code{extern}) in a library file.
8892 The definition in the header file causes most calls to the function
8893 to be inlined.  If any uses of the function remain, they refer to
8894 the single copy in the library.
8896 @node Volatiles
8897 @section When is a Volatile Object Accessed?
8898 @cindex accessing volatiles
8899 @cindex volatile read
8900 @cindex volatile write
8901 @cindex volatile access
8903 C has the concept of volatile objects.  These are normally accessed by
8904 pointers and used for accessing hardware or inter-thread
8905 communication.  The standard encourages compilers to refrain from
8906 optimizations concerning accesses to volatile objects, but leaves it
8907 implementation defined as to what constitutes a volatile access.  The
8908 minimum requirement is that at a sequence point all previous accesses
8909 to volatile objects have stabilized and no subsequent accesses have
8910 occurred.  Thus an implementation is free to reorder and combine
8911 volatile accesses that occur between sequence points, but cannot do
8912 so for accesses across a sequence point.  The use of volatile does
8913 not allow you to violate the restriction on updating objects multiple
8914 times between two sequence points.
8916 Accesses to non-volatile objects are not ordered with respect to
8917 volatile accesses.  You cannot use a volatile object as a memory
8918 barrier to order a sequence of writes to non-volatile memory.  For
8919 instance:
8921 @smallexample
8922 int *ptr = @var{something};
8923 volatile int vobj;
8924 *ptr = @var{something};
8925 vobj = 1;
8926 @end smallexample
8928 @noindent
8929 Unless @var{*ptr} and @var{vobj} can be aliased, it is not guaranteed
8930 that the write to @var{*ptr} occurs by the time the update
8931 of @var{vobj} happens.  If you need this guarantee, you must use
8932 a stronger memory barrier such as:
8934 @smallexample
8935 int *ptr = @var{something};
8936 volatile int vobj;
8937 *ptr = @var{something};
8938 asm volatile ("" : : : "memory");
8939 vobj = 1;
8940 @end smallexample
8942 A scalar volatile object is read when it is accessed in a void context:
8944 @smallexample
8945 volatile int *src = @var{somevalue};
8946 *src;
8947 @end smallexample
8949 Such expressions are rvalues, and GCC implements this as a
8950 read of the volatile object being pointed to.
8952 Assignments are also expressions and have an rvalue.  However when
8953 assigning to a scalar volatile, the volatile object is not reread,
8954 regardless of whether the assignment expression's rvalue is used or
8955 not.  If the assignment's rvalue is used, the value is that assigned
8956 to the volatile object.  For instance, there is no read of @var{vobj}
8957 in all the following cases:
8959 @smallexample
8960 int obj;
8961 volatile int vobj;
8962 vobj = @var{something};
8963 obj = vobj = @var{something};
8964 obj ? vobj = @var{onething} : vobj = @var{anotherthing};
8965 obj = (@var{something}, vobj = @var{anotherthing});
8966 @end smallexample
8968 If you need to read the volatile object after an assignment has
8969 occurred, you must use a separate expression with an intervening
8970 sequence point.
8972 As bit-fields are not individually addressable, volatile bit-fields may
8973 be implicitly read when written to, or when adjacent bit-fields are
8974 accessed.  Bit-field operations may be optimized such that adjacent
8975 bit-fields are only partially accessed, if they straddle a storage unit
8976 boundary.  For these reasons it is unwise to use volatile bit-fields to
8977 access hardware.
8979 @node Using Assembly Language with C
8980 @section How to Use Inline Assembly Language in C Code
8981 @cindex @code{asm} keyword
8982 @cindex assembly language in C
8983 @cindex inline assembly language
8984 @cindex mixing assembly language and C
8986 The @code{asm} keyword allows you to embed assembler instructions
8987 within C code.  GCC provides two forms of inline @code{asm}
8988 statements.  A @dfn{basic @code{asm}} statement is one with no
8989 operands (@pxref{Basic Asm}), while an @dfn{extended @code{asm}}
8990 statement (@pxref{Extended Asm}) includes one or more operands.  
8991 The extended form is preferred for mixing C and assembly language
8992 within a function, but to include assembly language at
8993 top level you must use basic @code{asm}.
8995 You can also use the @code{asm} keyword to override the assembler name
8996 for a C symbol, or to place a C variable in a specific register.
8998 @menu
8999 * Basic Asm::          Inline assembler without operands.
9000 * Extended Asm::       Inline assembler with operands.
9001 * Constraints::        Constraints for @code{asm} operands
9002 * Asm Labels::         Specifying the assembler name to use for a C symbol.
9003 * Explicit Register Variables::  Defining variables residing in specified 
9004                        registers.
9005 * Size of an asm::     How GCC calculates the size of an @code{asm} block.
9006 @end menu
9008 @node Basic Asm
9009 @subsection Basic Asm --- Assembler Instructions Without Operands
9010 @cindex basic @code{asm}
9011 @cindex assembly language in C, basic
9013 A basic @code{asm} statement has the following syntax:
9015 @example
9016 asm @var{asm-qualifiers} ( @var{AssemblerInstructions} )
9017 @end example
9019 The @code{asm} keyword is a GNU extension.
9020 When writing code that can be compiled with @option{-ansi} and the
9021 various @option{-std} options, use @code{__asm__} instead of 
9022 @code{asm} (@pxref{Alternate Keywords}).
9024 @subsubheading Qualifiers
9025 @table @code
9026 @item volatile
9027 The optional @code{volatile} qualifier has no effect. 
9028 All basic @code{asm} blocks are implicitly volatile.
9030 @item inline
9031 If you use the @code{inline} qualifier, then for inlining purposes the size
9032 of the @code{asm} statement is taken as the smallest size possible (@pxref{Size
9033 of an asm}).
9034 @end table
9036 @subsubheading Parameters
9037 @table @var
9039 @item AssemblerInstructions
9040 This is a literal string that specifies the assembler code. The string can 
9041 contain any instructions recognized by the assembler, including directives. 
9042 GCC does not parse the assembler instructions themselves and 
9043 does not know what they mean or even whether they are valid assembler input. 
9045 You may place multiple assembler instructions together in a single @code{asm} 
9046 string, separated by the characters normally used in assembly code for the 
9047 system. A combination that works in most places is a newline to break the 
9048 line, plus a tab character (written as @samp{\n\t}).
9049 Some assemblers allow semicolons as a line separator. However, 
9050 note that some assembler dialects use semicolons to start a comment. 
9051 @end table
9053 @subsubheading Remarks
9054 Using extended @code{asm} (@pxref{Extended Asm}) typically produces
9055 smaller, safer, and more efficient code, and in most cases it is a
9056 better solution than basic @code{asm}.  However, there are two
9057 situations where only basic @code{asm} can be used:
9059 @itemize @bullet
9060 @item
9061 Extended @code{asm} statements have to be inside a C
9062 function, so to write inline assembly language at file scope (``top-level''),
9063 outside of C functions, you must use basic @code{asm}.
9064 You can use this technique to emit assembler directives,
9065 define assembly language macros that can be invoked elsewhere in the file,
9066 or write entire functions in assembly language.
9067 Basic @code{asm} statements outside of functions may not use any
9068 qualifiers.
9070 @item
9071 Functions declared
9072 with the @code{naked} attribute also require basic @code{asm}
9073 (@pxref{Function Attributes}).
9074 @end itemize
9076 Safely accessing C data and calling functions from basic @code{asm} is more 
9077 complex than it may appear. To access C data, it is better to use extended 
9078 @code{asm}.
9080 Do not expect a sequence of @code{asm} statements to remain perfectly 
9081 consecutive after compilation. If certain instructions need to remain 
9082 consecutive in the output, put them in a single multi-instruction @code{asm}
9083 statement. Note that GCC's optimizers can move @code{asm} statements 
9084 relative to other code, including across jumps.
9086 @code{asm} statements may not perform jumps into other @code{asm} statements. 
9087 GCC does not know about these jumps, and therefore cannot take 
9088 account of them when deciding how to optimize. Jumps from @code{asm} to C 
9089 labels are only supported in extended @code{asm}.
9091 Under certain circumstances, GCC may duplicate (or remove duplicates of) your 
9092 assembly code when optimizing. This can lead to unexpected duplicate 
9093 symbol errors during compilation if your assembly code defines symbols or 
9094 labels.
9096 @strong{Warning:} The C standards do not specify semantics for @code{asm},
9097 making it a potential source of incompatibilities between compilers.  These
9098 incompatibilities may not produce compiler warnings/errors.
9100 GCC does not parse basic @code{asm}'s @var{AssemblerInstructions}, which
9101 means there is no way to communicate to the compiler what is happening
9102 inside them.  GCC has no visibility of symbols in the @code{asm} and may
9103 discard them as unreferenced.  It also does not know about side effects of
9104 the assembler code, such as modifications to memory or registers.  Unlike
9105 some compilers, GCC assumes that no changes to general purpose registers
9106 occur.  This assumption may change in a future release.
9108 To avoid complications from future changes to the semantics and the
9109 compatibility issues between compilers, consider replacing basic @code{asm}
9110 with extended @code{asm}.  See
9111 @uref{https://gcc.gnu.org/wiki/ConvertBasicAsmToExtended, How to convert
9112 from basic asm to extended asm} for information about how to perform this
9113 conversion.
9115 The compiler copies the assembler instructions in a basic @code{asm} 
9116 verbatim to the assembly language output file, without 
9117 processing dialects or any of the @samp{%} operators that are available with
9118 extended @code{asm}. This results in minor differences between basic 
9119 @code{asm} strings and extended @code{asm} templates. For example, to refer to 
9120 registers you might use @samp{%eax} in basic @code{asm} and
9121 @samp{%%eax} in extended @code{asm}.
9123 On targets such as x86 that support multiple assembler dialects,
9124 all basic @code{asm} blocks use the assembler dialect specified by the 
9125 @option{-masm} command-line option (@pxref{x86 Options}).  
9126 Basic @code{asm} provides no
9127 mechanism to provide different assembler strings for different dialects.
9129 For basic @code{asm} with non-empty assembler string GCC assumes
9130 the assembler block does not change any general purpose registers,
9131 but it may read or write any globally accessible variable.
9133 Here is an example of basic @code{asm} for i386:
9135 @example
9136 /* Note that this code will not compile with -masm=intel */
9137 #define DebugBreak() asm("int $3")
9138 @end example
9140 @node Extended Asm
9141 @subsection Extended Asm - Assembler Instructions with C Expression Operands
9142 @cindex extended @code{asm}
9143 @cindex assembly language in C, extended
9145 With extended @code{asm} you can read and write C variables from 
9146 assembler and perform jumps from assembler code to C labels.  
9147 Extended @code{asm} syntax uses colons (@samp{:}) to delimit
9148 the operand parameters after the assembler template:
9150 @example
9151 asm @var{asm-qualifiers} ( @var{AssemblerTemplate} 
9152                  : @var{OutputOperands} 
9153                  @r{[} : @var{InputOperands}
9154                  @r{[} : @var{Clobbers} @r{]} @r{]})
9156 asm @var{asm-qualifiers} ( @var{AssemblerTemplate} 
9157                       : 
9158                       : @var{InputOperands}
9159                       : @var{Clobbers}
9160                       : @var{GotoLabels})
9161 @end example
9162 where in the last form, @var{asm-qualifiers} contains @code{goto} (and in the
9163 first form, not).
9165 The @code{asm} keyword is a GNU extension.
9166 When writing code that can be compiled with @option{-ansi} and the
9167 various @option{-std} options, use @code{__asm__} instead of 
9168 @code{asm} (@pxref{Alternate Keywords}).
9170 @subsubheading Qualifiers
9171 @table @code
9173 @item volatile
9174 The typical use of extended @code{asm} statements is to manipulate input 
9175 values to produce output values. However, your @code{asm} statements may 
9176 also produce side effects. If so, you may need to use the @code{volatile} 
9177 qualifier to disable certain optimizations. @xref{Volatile}.
9179 @item inline
9180 If you use the @code{inline} qualifier, then for inlining purposes the size
9181 of the @code{asm} statement is taken as the smallest size possible
9182 (@pxref{Size of an asm}).
9184 @item goto
9185 This qualifier informs the compiler that the @code{asm} statement may 
9186 perform a jump to one of the labels listed in the @var{GotoLabels}.
9187 @xref{GotoLabels}.
9188 @end table
9190 @subsubheading Parameters
9191 @table @var
9192 @item AssemblerTemplate
9193 This is a literal string that is the template for the assembler code. It is a 
9194 combination of fixed text and tokens that refer to the input, output, 
9195 and goto parameters. @xref{AssemblerTemplate}.
9197 @item OutputOperands
9198 A comma-separated list of the C variables modified by the instructions in the 
9199 @var{AssemblerTemplate}.  An empty list is permitted.  @xref{OutputOperands}.
9201 @item InputOperands
9202 A comma-separated list of C expressions read by the instructions in the 
9203 @var{AssemblerTemplate}.  An empty list is permitted.  @xref{InputOperands}.
9205 @item Clobbers
9206 A comma-separated list of registers or other values changed by the 
9207 @var{AssemblerTemplate}, beyond those listed as outputs.
9208 An empty list is permitted.  @xref{Clobbers and Scratch Registers}.
9210 @item GotoLabels
9211 When you are using the @code{goto} form of @code{asm}, this section contains 
9212 the list of all C labels to which the code in the 
9213 @var{AssemblerTemplate} may jump. 
9214 @xref{GotoLabels}.
9216 @code{asm} statements may not perform jumps into other @code{asm} statements,
9217 only to the listed @var{GotoLabels}.
9218 GCC's optimizers do not know about other jumps; therefore they cannot take 
9219 account of them when deciding how to optimize.
9220 @end table
9222 The total number of input + output + goto operands is limited to 30.
9224 @subsubheading Remarks
9225 The @code{asm} statement allows you to include assembly instructions directly 
9226 within C code. This may help you to maximize performance in time-sensitive 
9227 code or to access assembly instructions that are not readily available to C 
9228 programs.
9230 Note that extended @code{asm} statements must be inside a function. Only 
9231 basic @code{asm} may be outside functions (@pxref{Basic Asm}).
9232 Functions declared with the @code{naked} attribute also require basic 
9233 @code{asm} (@pxref{Function Attributes}).
9235 While the uses of @code{asm} are many and varied, it may help to think of an 
9236 @code{asm} statement as a series of low-level instructions that convert input 
9237 parameters to output parameters. So a simple (if not particularly useful) 
9238 example for i386 using @code{asm} might look like this:
9240 @example
9241 int src = 1;
9242 int dst;   
9244 asm ("mov %1, %0\n\t"
9245     "add $1, %0"
9246     : "=r" (dst) 
9247     : "r" (src));
9249 printf("%d\n", dst);
9250 @end example
9252 This code copies @code{src} to @code{dst} and add 1 to @code{dst}.
9254 @anchor{Volatile}
9255 @subsubsection Volatile
9256 @cindex volatile @code{asm}
9257 @cindex @code{asm} volatile
9259 GCC's optimizers sometimes discard @code{asm} statements if they determine 
9260 there is no need for the output variables. Also, the optimizers may move 
9261 code out of loops if they believe that the code will always return the same 
9262 result (i.e.@: none of its input values change between calls). Using the 
9263 @code{volatile} qualifier disables these optimizations. @code{asm} statements 
9264 that have no output operands, including @code{asm goto} statements, 
9265 are implicitly volatile.
9267 This i386 code demonstrates a case that does not use (or require) the 
9268 @code{volatile} qualifier. If it is performing assertion checking, this code 
9269 uses @code{asm} to perform the validation. Otherwise, @code{dwRes} is 
9270 unreferenced by any code. As a result, the optimizers can discard the 
9271 @code{asm} statement, which in turn removes the need for the entire 
9272 @code{DoCheck} routine. By omitting the @code{volatile} qualifier when it 
9273 isn't needed you allow the optimizers to produce the most efficient code 
9274 possible.
9276 @example
9277 void DoCheck(uint32_t dwSomeValue)
9279    uint32_t dwRes;
9281    // Assumes dwSomeValue is not zero.
9282    asm ("bsfl %1,%0"
9283      : "=r" (dwRes)
9284      : "r" (dwSomeValue)
9285      : "cc");
9287    assert(dwRes > 3);
9289 @end example
9291 The next example shows a case where the optimizers can recognize that the input 
9292 (@code{dwSomeValue}) never changes during the execution of the function and can 
9293 therefore move the @code{asm} outside the loop to produce more efficient code. 
9294 Again, using the @code{volatile} qualifier disables this type of optimization.
9296 @example
9297 void do_print(uint32_t dwSomeValue)
9299    uint32_t dwRes;
9301    for (uint32_t x=0; x < 5; x++)
9302    @{
9303       // Assumes dwSomeValue is not zero.
9304       asm ("bsfl %1,%0"
9305         : "=r" (dwRes)
9306         : "r" (dwSomeValue)
9307         : "cc");
9309       printf("%u: %u %u\n", x, dwSomeValue, dwRes);
9310    @}
9312 @end example
9314 The following example demonstrates a case where you need to use the 
9315 @code{volatile} qualifier. 
9316 It uses the x86 @code{rdtsc} instruction, which reads 
9317 the computer's time-stamp counter. Without the @code{volatile} qualifier, 
9318 the optimizers might assume that the @code{asm} block will always return the 
9319 same value and therefore optimize away the second call.
9321 @example
9322 uint64_t msr;
9324 asm volatile ( "rdtsc\n\t"    // Returns the time in EDX:EAX.
9325         "shl $32, %%rdx\n\t"  // Shift the upper bits left.
9326         "or %%rdx, %0"        // 'Or' in the lower bits.
9327         : "=a" (msr)
9328         : 
9329         : "rdx");
9331 printf("msr: %llx\n", msr);
9333 // Do other work...
9335 // Reprint the timestamp
9336 asm volatile ( "rdtsc\n\t"    // Returns the time in EDX:EAX.
9337         "shl $32, %%rdx\n\t"  // Shift the upper bits left.
9338         "or %%rdx, %0"        // 'Or' in the lower bits.
9339         : "=a" (msr)
9340         : 
9341         : "rdx");
9343 printf("msr: %llx\n", msr);
9344 @end example
9346 GCC's optimizers do not treat this code like the non-volatile code in the 
9347 earlier examples. They do not move it out of loops or omit it on the 
9348 assumption that the result from a previous call is still valid.
9350 Note that the compiler can move even @code{volatile asm} instructions relative
9351 to other code, including across jump instructions. For example, on many 
9352 targets there is a system register that controls the rounding mode of 
9353 floating-point operations. Setting it with a @code{volatile asm} statement,
9354 as in the following PowerPC example, does not work reliably.
9356 @example
9357 asm volatile("mtfsf 255, %0" : : "f" (fpenv));
9358 sum = x + y;
9359 @end example
9361 The compiler may move the addition back before the @code{volatile asm}
9362 statement. To make it work as expected, add an artificial dependency to
9363 the @code{asm} by referencing a variable in the subsequent code, for
9364 example:
9366 @example
9367 asm volatile ("mtfsf 255,%1" : "=X" (sum) : "f" (fpenv));
9368 sum = x + y;
9369 @end example
9371 Under certain circumstances, GCC may duplicate (or remove duplicates of) your 
9372 assembly code when optimizing. This can lead to unexpected duplicate symbol 
9373 errors during compilation if your @code{asm} code defines symbols or labels. 
9374 Using @samp{%=} 
9375 (@pxref{AssemblerTemplate}) may help resolve this problem.
9377 @anchor{AssemblerTemplate}
9378 @subsubsection Assembler Template
9379 @cindex @code{asm} assembler template
9381 An assembler template is a literal string containing assembler instructions.
9382 The compiler replaces tokens in the template that refer 
9383 to inputs, outputs, and goto labels,
9384 and then outputs the resulting string to the assembler. The 
9385 string can contain any instructions recognized by the assembler, including 
9386 directives. GCC does not parse the assembler instructions 
9387 themselves and does not know what they mean or even whether they are valid 
9388 assembler input. However, it does count the statements 
9389 (@pxref{Size of an asm}).
9391 You may place multiple assembler instructions together in a single @code{asm} 
9392 string, separated by the characters normally used in assembly code for the 
9393 system. A combination that works in most places is a newline to break the 
9394 line, plus a tab character to move to the instruction field (written as 
9395 @samp{\n\t}). 
9396 Some assemblers allow semicolons as a line separator. However, note 
9397 that some assembler dialects use semicolons to start a comment. 
9399 Do not expect a sequence of @code{asm} statements to remain perfectly 
9400 consecutive after compilation, even when you are using the @code{volatile} 
9401 qualifier. If certain instructions need to remain consecutive in the output, 
9402 put them in a single multi-instruction @code{asm} statement.
9404 Accessing data from C programs without using input/output operands (such as 
9405 by using global symbols directly from the assembler template) may not work as 
9406 expected. Similarly, calling functions directly from an assembler template 
9407 requires a detailed understanding of the target assembler and ABI.
9409 Since GCC does not parse the assembler template,
9410 it has no visibility of any 
9411 symbols it references. This may result in GCC discarding those symbols as 
9412 unreferenced unless they are also listed as input, output, or goto operands.
9414 @subsubheading Special format strings
9416 In addition to the tokens described by the input, output, and goto operands, 
9417 these tokens have special meanings in the assembler template:
9419 @table @samp
9420 @item %% 
9421 Outputs a single @samp{%} into the assembler code.
9423 @item %= 
9424 Outputs a number that is unique to each instance of the @code{asm} 
9425 statement in the entire compilation. This option is useful when creating local 
9426 labels and referring to them multiple times in a single template that 
9427 generates multiple assembler instructions. 
9429 @item %@{
9430 @itemx %|
9431 @itemx %@}
9432 Outputs @samp{@{}, @samp{|}, and @samp{@}} characters (respectively)
9433 into the assembler code.  When unescaped, these characters have special
9434 meaning to indicate multiple assembler dialects, as described below.
9435 @end table
9437 @subsubheading Multiple assembler dialects in @code{asm} templates
9439 On targets such as x86, GCC supports multiple assembler dialects.
9440 The @option{-masm} option controls which dialect GCC uses as its 
9441 default for inline assembler. The target-specific documentation for the 
9442 @option{-masm} option contains the list of supported dialects, as well as the 
9443 default dialect if the option is not specified. This information may be 
9444 important to understand, since assembler code that works correctly when 
9445 compiled using one dialect will likely fail if compiled using another.
9446 @xref{x86 Options}.
9448 If your code needs to support multiple assembler dialects (for example, if 
9449 you are writing public headers that need to support a variety of compilation 
9450 options), use constructs of this form:
9452 @example
9453 @{ dialect0 | dialect1 | dialect2... @}
9454 @end example
9456 This construct outputs @code{dialect0} 
9457 when using dialect #0 to compile the code, 
9458 @code{dialect1} for dialect #1, etc. If there are fewer alternatives within the 
9459 braces than the number of dialects the compiler supports, the construct 
9460 outputs nothing.
9462 For example, if an x86 compiler supports two dialects
9463 (@samp{att}, @samp{intel}), an 
9464 assembler template such as this:
9466 @example
9467 "bt@{l %[Offset],%[Base] | %[Base],%[Offset]@}; jc %l2"
9468 @end example
9470 @noindent
9471 is equivalent to one of
9473 @example
9474 "btl %[Offset],%[Base] ; jc %l2"   @r{/* att dialect */}
9475 "bt %[Base],%[Offset]; jc %l2"     @r{/* intel dialect */}
9476 @end example
9478 Using that same compiler, this code:
9480 @example
9481 "xchg@{l@}\t@{%%@}ebx, %1"
9482 @end example
9484 @noindent
9485 corresponds to either
9487 @example
9488 "xchgl\t%%ebx, %1"                 @r{/* att dialect */}
9489 "xchg\tebx, %1"                    @r{/* intel dialect */}
9490 @end example
9492 There is no support for nesting dialect alternatives.
9494 @anchor{OutputOperands}
9495 @subsubsection Output Operands
9496 @cindex @code{asm} output operands
9498 An @code{asm} statement has zero or more output operands indicating the names
9499 of C variables modified by the assembler code.
9501 In this i386 example, @code{old} (referred to in the template string as 
9502 @code{%0}) and @code{*Base} (as @code{%1}) are outputs and @code{Offset} 
9503 (@code{%2}) is an input:
9505 @example
9506 bool old;
9508 __asm__ ("btsl %2,%1\n\t" // Turn on zero-based bit #Offset in Base.
9509          "sbb %0,%0"      // Use the CF to calculate old.
9510    : "=r" (old), "+rm" (*Base)
9511    : "Ir" (Offset)
9512    : "cc");
9514 return old;
9515 @end example
9517 Operands are separated by commas.  Each operand has this format:
9519 @example
9520 @r{[} [@var{asmSymbolicName}] @r{]} @var{constraint} (@var{cvariablename})
9521 @end example
9523 @table @var
9524 @item asmSymbolicName
9525 Specifies a symbolic name for the operand.
9526 Reference the name in the assembler template 
9527 by enclosing it in square brackets 
9528 (i.e.@: @samp{%[Value]}). The scope of the name is the @code{asm} statement 
9529 that contains the definition. Any valid C variable name is acceptable, 
9530 including names already defined in the surrounding code. No two operands 
9531 within the same @code{asm} statement can use the same symbolic name.
9533 When not using an @var{asmSymbolicName}, use the (zero-based) position
9534 of the operand 
9535 in the list of operands in the assembler template. For example if there are 
9536 three output operands, use @samp{%0} in the template to refer to the first, 
9537 @samp{%1} for the second, and @samp{%2} for the third. 
9539 @item constraint
9540 A string constant specifying constraints on the placement of the operand; 
9541 @xref{Constraints}, for details.
9543 Output constraints must begin with either @samp{=} (a variable overwriting an 
9544 existing value) or @samp{+} (when reading and writing). When using 
9545 @samp{=}, do not assume the location contains the existing value
9546 on entry to the @code{asm}, except 
9547 when the operand is tied to an input; @pxref{InputOperands,,Input Operands}.
9549 After the prefix, there must be one or more additional constraints 
9550 (@pxref{Constraints}) that describe where the value resides. Common 
9551 constraints include @samp{r} for register and @samp{m} for memory. 
9552 When you list more than one possible location (for example, @code{"=rm"}),
9553 the compiler chooses the most efficient one based on the current context. 
9554 If you list as many alternates as the @code{asm} statement allows, you permit 
9555 the optimizers to produce the best possible code. 
9556 If you must use a specific register, but your Machine Constraints do not
9557 provide sufficient control to select the specific register you want, 
9558 local register variables may provide a solution (@pxref{Local Register 
9559 Variables}).
9561 @item cvariablename
9562 Specifies a C lvalue expression to hold the output, typically a variable name.
9563 The enclosing parentheses are a required part of the syntax.
9565 @end table
9567 When the compiler selects the registers to use to 
9568 represent the output operands, it does not use any of the clobbered registers 
9569 (@pxref{Clobbers and Scratch Registers}).
9571 Output operand expressions must be lvalues. The compiler cannot check whether 
9572 the operands have data types that are reasonable for the instruction being 
9573 executed. For output expressions that are not directly addressable (for 
9574 example a bit-field), the constraint must allow a register. In that case, GCC 
9575 uses the register as the output of the @code{asm}, and then stores that 
9576 register into the output. 
9578 Operands using the @samp{+} constraint modifier count as two operands 
9579 (that is, both as input and output) towards the total maximum of 30 operands
9580 per @code{asm} statement.
9582 Use the @samp{&} constraint modifier (@pxref{Modifiers}) on all output
9583 operands that must not overlap an input.  Otherwise, 
9584 GCC may allocate the output operand in the same register as an unrelated 
9585 input operand, on the assumption that the assembler code consumes its 
9586 inputs before producing outputs. This assumption may be false if the assembler 
9587 code actually consists of more than one instruction.
9589 The same problem can occur if one output parameter (@var{a}) allows a register 
9590 constraint and another output parameter (@var{b}) allows a memory constraint.
9591 The code generated by GCC to access the memory address in @var{b} can contain
9592 registers which @emph{might} be shared by @var{a}, and GCC considers those 
9593 registers to be inputs to the asm. As above, GCC assumes that such input
9594 registers are consumed before any outputs are written. This assumption may 
9595 result in incorrect behavior if the @code{asm} statement writes to @var{a}
9596 before using
9597 @var{b}. Combining the @samp{&} modifier with the register constraint on @var{a}
9598 ensures that modifying @var{a} does not affect the address referenced by 
9599 @var{b}. Otherwise, the location of @var{b} 
9600 is undefined if @var{a} is modified before using @var{b}.
9602 @code{asm} supports operand modifiers on operands (for example @samp{%k2} 
9603 instead of simply @samp{%2}). Typically these qualifiers are hardware 
9604 dependent. The list of supported modifiers for x86 is found at 
9605 @ref{x86Operandmodifiers,x86 Operand modifiers}.
9607 If the C code that follows the @code{asm} makes no use of any of the output 
9608 operands, use @code{volatile} for the @code{asm} statement to prevent the 
9609 optimizers from discarding the @code{asm} statement as unneeded 
9610 (see @ref{Volatile}).
9612 This code makes no use of the optional @var{asmSymbolicName}. Therefore it 
9613 references the first output operand as @code{%0} (were there a second, it 
9614 would be @code{%1}, etc). The number of the first input operand is one greater 
9615 than that of the last output operand. In this i386 example, that makes 
9616 @code{Mask} referenced as @code{%1}:
9618 @example
9619 uint32_t Mask = 1234;
9620 uint32_t Index;
9622   asm ("bsfl %1, %0"
9623      : "=r" (Index)
9624      : "r" (Mask)
9625      : "cc");
9626 @end example
9628 That code overwrites the variable @code{Index} (@samp{=}),
9629 placing the value in a register (@samp{r}).
9630 Using the generic @samp{r} constraint instead of a constraint for a specific 
9631 register allows the compiler to pick the register to use, which can result 
9632 in more efficient code. This may not be possible if an assembler instruction 
9633 requires a specific register.
9635 The following i386 example uses the @var{asmSymbolicName} syntax.
9636 It produces the 
9637 same result as the code above, but some may consider it more readable or more 
9638 maintainable since reordering index numbers is not necessary when adding or 
9639 removing operands. The names @code{aIndex} and @code{aMask}
9640 are only used in this example to emphasize which 
9641 names get used where.
9642 It is acceptable to reuse the names @code{Index} and @code{Mask}.
9644 @example
9645 uint32_t Mask = 1234;
9646 uint32_t Index;
9648   asm ("bsfl %[aMask], %[aIndex]"
9649      : [aIndex] "=r" (Index)
9650      : [aMask] "r" (Mask)
9651      : "cc");
9652 @end example
9654 Here are some more examples of output operands.
9656 @example
9657 uint32_t c = 1;
9658 uint32_t d;
9659 uint32_t *e = &c;
9661 asm ("mov %[e], %[d]"
9662    : [d] "=rm" (d)
9663    : [e] "rm" (*e));
9664 @end example
9666 Here, @code{d} may either be in a register or in memory. Since the compiler 
9667 might already have the current value of the @code{uint32_t} location
9668 pointed to by @code{e}
9669 in a register, you can enable it to choose the best location
9670 for @code{d} by specifying both constraints.
9672 @anchor{FlagOutputOperands}
9673 @subsubsection Flag Output Operands
9674 @cindex @code{asm} flag output operands
9676 Some targets have a special register that holds the ``flags'' for the
9677 result of an operation or comparison.  Normally, the contents of that
9678 register are either unmodifed by the asm, or the @code{asm} statement is
9679 considered to clobber the contents.
9681 On some targets, a special form of output operand exists by which
9682 conditions in the flags register may be outputs of the asm.  The set of
9683 conditions supported are target specific, but the general rule is that
9684 the output variable must be a scalar integer, and the value is boolean.
9685 When supported, the target defines the preprocessor symbol
9686 @code{__GCC_ASM_FLAG_OUTPUTS__}.
9688 Because of the special nature of the flag output operands, the constraint
9689 may not include alternatives.
9691 Most often, the target has only one flags register, and thus is an implied
9692 operand of many instructions.  In this case, the operand should not be
9693 referenced within the assembler template via @code{%0} etc, as there's
9694 no corresponding text in the assembly language.
9696 @table @asis
9697 @item x86 family
9698 The flag output constraints for the x86 family are of the form
9699 @samp{=@@cc@var{cond}} where @var{cond} is one of the standard
9700 conditions defined in the ISA manual for @code{j@var{cc}} or
9701 @code{set@var{cc}}.
9703 @table @code
9704 @item a
9705 ``above'' or unsigned greater than
9706 @item ae
9707 ``above or equal'' or unsigned greater than or equal
9708 @item b
9709 ``below'' or unsigned less than
9710 @item be
9711 ``below or equal'' or unsigned less than or equal
9712 @item c
9713 carry flag set
9714 @item e
9715 @itemx z
9716 ``equal'' or zero flag set
9717 @item g
9718 signed greater than
9719 @item ge
9720 signed greater than or equal
9721 @item l
9722 signed less than
9723 @item le
9724 signed less than or equal
9725 @item o
9726 overflow flag set
9727 @item p
9728 parity flag set
9729 @item s
9730 sign flag set
9731 @item na
9732 @itemx nae
9733 @itemx nb
9734 @itemx nbe
9735 @itemx nc
9736 @itemx ne
9737 @itemx ng
9738 @itemx nge
9739 @itemx nl
9740 @itemx nle
9741 @itemx no
9742 @itemx np
9743 @itemx ns
9744 @itemx nz
9745 ``not'' @var{flag}, or inverted versions of those above
9746 @end table
9748 @end table
9750 @anchor{InputOperands}
9751 @subsubsection Input Operands
9752 @cindex @code{asm} input operands
9753 @cindex @code{asm} expressions
9755 Input operands make values from C variables and expressions available to the 
9756 assembly code.
9758 Operands are separated by commas.  Each operand has this format:
9760 @example
9761 @r{[} [@var{asmSymbolicName}] @r{]} @var{constraint} (@var{cexpression})
9762 @end example
9764 @table @var
9765 @item asmSymbolicName
9766 Specifies a symbolic name for the operand.
9767 Reference the name in the assembler template 
9768 by enclosing it in square brackets 
9769 (i.e.@: @samp{%[Value]}). The scope of the name is the @code{asm} statement 
9770 that contains the definition. Any valid C variable name is acceptable, 
9771 including names already defined in the surrounding code. No two operands 
9772 within the same @code{asm} statement can use the same symbolic name.
9774 When not using an @var{asmSymbolicName}, use the (zero-based) position
9775 of the operand 
9776 in the list of operands in the assembler template. For example if there are
9777 two output operands and three inputs,
9778 use @samp{%2} in the template to refer to the first input operand,
9779 @samp{%3} for the second, and @samp{%4} for the third. 
9781 @item constraint
9782 A string constant specifying constraints on the placement of the operand; 
9783 @xref{Constraints}, for details.
9785 Input constraint strings may not begin with either @samp{=} or @samp{+}.
9786 When you list more than one possible location (for example, @samp{"irm"}), 
9787 the compiler chooses the most efficient one based on the current context.
9788 If you must use a specific register, but your Machine Constraints do not
9789 provide sufficient control to select the specific register you want, 
9790 local register variables may provide a solution (@pxref{Local Register 
9791 Variables}).
9793 Input constraints can also be digits (for example, @code{"0"}). This indicates 
9794 that the specified input must be in the same place as the output constraint 
9795 at the (zero-based) index in the output constraint list. 
9796 When using @var{asmSymbolicName} syntax for the output operands,
9797 you may use these names (enclosed in brackets @samp{[]}) instead of digits.
9799 @item cexpression
9800 This is the C variable or expression being passed to the @code{asm} statement 
9801 as input.  The enclosing parentheses are a required part of the syntax.
9803 @end table
9805 When the compiler selects the registers to use to represent the input 
9806 operands, it does not use any of the clobbered registers
9807 (@pxref{Clobbers and Scratch Registers}).
9809 If there are no output operands but there are input operands, place two 
9810 consecutive colons where the output operands would go:
9812 @example
9813 __asm__ ("some instructions"
9814    : /* No outputs. */
9815    : "r" (Offset / 8));
9816 @end example
9818 @strong{Warning:} Do @emph{not} modify the contents of input-only operands 
9819 (except for inputs tied to outputs). The compiler assumes that on exit from 
9820 the @code{asm} statement these operands contain the same values as they 
9821 had before executing the statement. 
9822 It is @emph{not} possible to use clobbers
9823 to inform the compiler that the values in these inputs are changing. One 
9824 common work-around is to tie the changing input variable to an output variable 
9825 that never gets used. Note, however, that if the code that follows the 
9826 @code{asm} statement makes no use of any of the output operands, the GCC 
9827 optimizers may discard the @code{asm} statement as unneeded 
9828 (see @ref{Volatile}).
9830 @code{asm} supports operand modifiers on operands (for example @samp{%k2} 
9831 instead of simply @samp{%2}). Typically these qualifiers are hardware 
9832 dependent. The list of supported modifiers for x86 is found at 
9833 @ref{x86Operandmodifiers,x86 Operand modifiers}.
9835 In this example using the fictitious @code{combine} instruction, the 
9836 constraint @code{"0"} for input operand 1 says that it must occupy the same 
9837 location as output operand 0. Only input operands may use numbers in 
9838 constraints, and they must each refer to an output operand. Only a number (or 
9839 the symbolic assembler name) in the constraint can guarantee that one operand 
9840 is in the same place as another. The mere fact that @code{foo} is the value of 
9841 both operands is not enough to guarantee that they are in the same place in 
9842 the generated assembler code.
9844 @example
9845 asm ("combine %2, %0" 
9846    : "=r" (foo) 
9847    : "0" (foo), "g" (bar));
9848 @end example
9850 Here is an example using symbolic names.
9852 @example
9853 asm ("cmoveq %1, %2, %[result]" 
9854    : [result] "=r"(result) 
9855    : "r" (test), "r" (new), "[result]" (old));
9856 @end example
9858 @anchor{Clobbers and Scratch Registers}
9859 @subsubsection Clobbers and Scratch Registers
9860 @cindex @code{asm} clobbers
9861 @cindex @code{asm} scratch registers
9863 While the compiler is aware of changes to entries listed in the output 
9864 operands, the inline @code{asm} code may modify more than just the outputs. For 
9865 example, calculations may require additional registers, or the processor may 
9866 overwrite a register as a side effect of a particular assembler instruction. 
9867 In order to inform the compiler of these changes, list them in the clobber 
9868 list. Clobber list items are either register names or the special clobbers 
9869 (listed below). Each clobber list item is a string constant 
9870 enclosed in double quotes and separated by commas.
9872 Clobber descriptions may not in any way overlap with an input or output 
9873 operand. For example, you may not have an operand describing a register class 
9874 with one member when listing that register in the clobber list. Variables 
9875 declared to live in specific registers (@pxref{Explicit Register 
9876 Variables}) and used 
9877 as @code{asm} input or output operands must have no part mentioned in the 
9878 clobber description. In particular, there is no way to specify that input 
9879 operands get modified without also specifying them as output operands.
9881 When the compiler selects which registers to use to represent input and output 
9882 operands, it does not use any of the clobbered registers. As a result, 
9883 clobbered registers are available for any use in the assembler code.
9885 Another restriction is that the clobber list should not contain the
9886 stack pointer register.  This is because the compiler requires the
9887 value of the stack pointer to be the same after an @code{asm}
9888 statement as it was on entry to the statement.  However, previous
9889 versions of GCC did not enforce this rule and allowed the stack
9890 pointer to appear in the list, with unclear semantics.  This behavior
9891 is deprecated and listing the stack pointer may become an error in
9892 future versions of GCC@.
9894 Here is a realistic example for the VAX showing the use of clobbered 
9895 registers: 
9897 @example
9898 asm volatile ("movc3 %0, %1, %2"
9899                    : /* No outputs. */
9900                    : "g" (from), "g" (to), "g" (count)
9901                    : "r0", "r1", "r2", "r3", "r4", "r5", "memory");
9902 @end example
9904 Also, there are two special clobber arguments:
9906 @table @code
9907 @item "cc"
9908 The @code{"cc"} clobber indicates that the assembler code modifies the flags 
9909 register. On some machines, GCC represents the condition codes as a specific 
9910 hardware register; @code{"cc"} serves to name this register.
9911 On other machines, condition code handling is different, 
9912 and specifying @code{"cc"} has no effect. But 
9913 it is valid no matter what the target.
9915 @item "memory"
9916 The @code{"memory"} clobber tells the compiler that the assembly code
9917 performs memory 
9918 reads or writes to items other than those listed in the input and output 
9919 operands (for example, accessing the memory pointed to by one of the input 
9920 parameters). To ensure memory contains correct values, GCC may need to flush 
9921 specific register values to memory before executing the @code{asm}. Further, 
9922 the compiler does not assume that any values read from memory before an 
9923 @code{asm} remain unchanged after that @code{asm}; it reloads them as 
9924 needed.  
9925 Using the @code{"memory"} clobber effectively forms a read/write
9926 memory barrier for the compiler.
9928 Note that this clobber does not prevent the @emph{processor} from doing 
9929 speculative reads past the @code{asm} statement. To prevent that, you need 
9930 processor-specific fence instructions.
9932 @end table
9934 Flushing registers to memory has performance implications and may be
9935 an issue for time-sensitive code.  You can provide better information
9936 to GCC to avoid this, as shown in the following examples.  At a
9937 minimum, aliasing rules allow GCC to know what memory @emph{doesn't}
9938 need to be flushed.
9940 Here is a fictitious sum of squares instruction, that takes two
9941 pointers to floating point values in memory and produces a floating
9942 point register output.
9943 Notice that @code{x}, and @code{y} both appear twice in the @code{asm}
9944 parameters, once to specify memory accessed, and once to specify a
9945 base register used by the @code{asm}.  You won't normally be wasting a
9946 register by doing this as GCC can use the same register for both
9947 purposes.  However, it would be foolish to use both @code{%1} and
9948 @code{%3} for @code{x} in this @code{asm} and expect them to be the
9949 same.  In fact, @code{%3} may well not be a register.  It might be a
9950 symbolic memory reference to the object pointed to by @code{x}.
9952 @smallexample
9953 asm ("sumsq %0, %1, %2"
9954      : "+f" (result)
9955      : "r" (x), "r" (y), "m" (*x), "m" (*y));
9956 @end smallexample
9958 Here is a fictitious @code{*z++ = *x++ * *y++} instruction.
9959 Notice that the @code{x}, @code{y} and @code{z} pointer registers
9960 must be specified as input/output because the @code{asm} modifies
9961 them.
9963 @smallexample
9964 asm ("vecmul %0, %1, %2"
9965      : "+r" (z), "+r" (x), "+r" (y), "=m" (*z)
9966      : "m" (*x), "m" (*y));
9967 @end smallexample
9969 An x86 example where the string memory argument is of unknown length.
9971 @smallexample
9972 asm("repne scasb"
9973     : "=c" (count), "+D" (p)
9974     : "m" (*(const char (*)[]) p), "0" (-1), "a" (0));
9975 @end smallexample
9977 If you know the above will only be reading a ten byte array then you
9978 could instead use a memory input like:
9979 @code{"m" (*(const char (*)[10]) p)}.
9981 Here is an example of a PowerPC vector scale implemented in assembly,
9982 complete with vector and condition code clobbers, and some initialized
9983 offset registers that are unchanged by the @code{asm}.
9985 @smallexample
9986 void
9987 dscal (size_t n, double *x, double alpha)
9989   asm ("/* lots of asm here */"
9990        : "+m" (*(double (*)[n]) x), "+&r" (n), "+b" (x)
9991        : "d" (alpha), "b" (32), "b" (48), "b" (64),
9992          "b" (80), "b" (96), "b" (112)
9993        : "cr0",
9994          "vs32","vs33","vs34","vs35","vs36","vs37","vs38","vs39",
9995          "vs40","vs41","vs42","vs43","vs44","vs45","vs46","vs47");
9997 @end smallexample
9999 Rather than allocating fixed registers via clobbers to provide scratch
10000 registers for an @code{asm} statement, an alternative is to define a
10001 variable and make it an early-clobber output as with @code{a2} and
10002 @code{a3} in the example below.  This gives the compiler register
10003 allocator more freedom.  You can also define a variable and make it an
10004 output tied to an input as with @code{a0} and @code{a1}, tied
10005 respectively to @code{ap} and @code{lda}.  Of course, with tied
10006 outputs your @code{asm} can't use the input value after modifying the
10007 output register since they are one and the same register.  What's
10008 more, if you omit the early-clobber on the output, it is possible that
10009 GCC might allocate the same register to another of the inputs if GCC
10010 could prove they had the same value on entry to the @code{asm}.  This
10011 is why @code{a1} has an early-clobber.  Its tied input, @code{lda}
10012 might conceivably be known to have the value 16 and without an
10013 early-clobber share the same register as @code{%11}.  On the other
10014 hand, @code{ap} can't be the same as any of the other inputs, so an
10015 early-clobber on @code{a0} is not needed.  It is also not desirable in
10016 this case.  An early-clobber on @code{a0} would cause GCC to allocate
10017 a separate register for the @code{"m" (*(const double (*)[]) ap)}
10018 input.  Note that tying an input to an output is the way to set up an
10019 initialized temporary register modified by an @code{asm} statement.
10020 An input not tied to an output is assumed by GCC to be unchanged, for
10021 example @code{"b" (16)} below sets up @code{%11} to 16, and GCC might
10022 use that register in following code if the value 16 happened to be
10023 needed.  You can even use a normal @code{asm} output for a scratch if
10024 all inputs that might share the same register are consumed before the
10025 scratch is used.  The VSX registers clobbered by the @code{asm}
10026 statement could have used this technique except for GCC's limit on the
10027 number of @code{asm} parameters.
10029 @smallexample
10030 static void
10031 dgemv_kernel_4x4 (long n, const double *ap, long lda,
10032                   const double *x, double *y, double alpha)
10034   double *a0;
10035   double *a1;
10036   double *a2;
10037   double *a3;
10039   __asm__
10040     (
10041      /* lots of asm here */
10042      "#n=%1 ap=%8=%12 lda=%13 x=%7=%10 y=%0=%2 alpha=%9 o16=%11\n"
10043      "#a0=%3 a1=%4 a2=%5 a3=%6"
10044      :
10045        "+m" (*(double (*)[n]) y),
10046        "+&r" (n),       // 1
10047        "+b" (y),        // 2
10048        "=b" (a0),       // 3
10049        "=&b" (a1),      // 4
10050        "=&b" (a2),      // 5
10051        "=&b" (a3)       // 6
10052      :
10053        "m" (*(const double (*)[n]) x),
10054        "m" (*(const double (*)[]) ap),
10055        "d" (alpha),     // 9
10056        "r" (x),         // 10
10057        "b" (16),        // 11
10058        "3" (ap),        // 12
10059        "4" (lda)        // 13
10060      :
10061        "cr0",
10062        "vs32","vs33","vs34","vs35","vs36","vs37",
10063        "vs40","vs41","vs42","vs43","vs44","vs45","vs46","vs47"
10064      );
10066 @end smallexample
10068 @anchor{GotoLabels}
10069 @subsubsection Goto Labels
10070 @cindex @code{asm} goto labels
10072 @code{asm goto} allows assembly code to jump to one or more C labels.  The
10073 @var{GotoLabels} section in an @code{asm goto} statement contains 
10074 a comma-separated 
10075 list of all C labels to which the assembler code may jump. GCC assumes that 
10076 @code{asm} execution falls through to the next statement (if this is not the 
10077 case, consider using the @code{__builtin_unreachable} intrinsic after the 
10078 @code{asm} statement). Optimization of @code{asm goto} may be improved by 
10079 using the @code{hot} and @code{cold} label attributes (@pxref{Label 
10080 Attributes}).
10082 An @code{asm goto} statement cannot have outputs.
10083 This is due to an internal restriction of 
10084 the compiler: control transfer instructions cannot have outputs. 
10085 If the assembler code does modify anything, use the @code{"memory"} clobber 
10086 to force the 
10087 optimizers to flush all register values to memory and reload them if 
10088 necessary after the @code{asm} statement.
10090 Also note that an @code{asm goto} statement is always implicitly
10091 considered volatile.
10093 To reference a label in the assembler template,
10094 prefix it with @samp{%l} (lowercase @samp{L}) followed 
10095 by its (zero-based) position in @var{GotoLabels} plus the number of input 
10096 operands.  For example, if the @code{asm} has three inputs and references two 
10097 labels, refer to the first label as @samp{%l3} and the second as @samp{%l4}).
10099 Alternately, you can reference labels using the actual C label name enclosed
10100 in brackets.  For example, to reference a label named @code{carry}, you can
10101 use @samp{%l[carry]}.  The label must still be listed in the @var{GotoLabels}
10102 section when using this approach.
10104 Here is an example of @code{asm goto} for i386:
10106 @example
10107 asm goto (
10108     "btl %1, %0\n\t"
10109     "jc %l2"
10110     : /* No outputs. */
10111     : "r" (p1), "r" (p2) 
10112     : "cc" 
10113     : carry);
10115 return 0;
10117 carry:
10118 return 1;
10119 @end example
10121 The following example shows an @code{asm goto} that uses a memory clobber.
10123 @example
10124 int frob(int x)
10126   int y;
10127   asm goto ("frob %%r5, %1; jc %l[error]; mov (%2), %%r5"
10128             : /* No outputs. */
10129             : "r"(x), "r"(&y)
10130             : "r5", "memory" 
10131             : error);
10132   return y;
10133 error:
10134   return -1;
10136 @end example
10138 @anchor{x86Operandmodifiers}
10139 @subsubsection x86 Operand Modifiers
10141 References to input, output, and goto operands in the assembler template
10142 of extended @code{asm} statements can use 
10143 modifiers to affect the way the operands are formatted in 
10144 the code output to the assembler. For example, the 
10145 following code uses the @samp{h} and @samp{b} modifiers for x86:
10147 @example
10148 uint16_t  num;
10149 asm volatile ("xchg %h0, %b0" : "+a" (num) );
10150 @end example
10152 @noindent
10153 These modifiers generate this assembler code:
10155 @example
10156 xchg %ah, %al
10157 @end example
10159 The rest of this discussion uses the following code for illustrative purposes.
10161 @example
10162 int main()
10164    int iInt = 1;
10166 top:
10168    asm volatile goto ("some assembler instructions here"
10169    : /* No outputs. */
10170    : "q" (iInt), "X" (sizeof(unsigned char) + 1), "i" (42)
10171    : /* No clobbers. */
10172    : top);
10174 @end example
10176 With no modifiers, this is what the output from the operands would be
10177 for the @samp{att} and @samp{intel} dialects of assembler:
10179 @multitable {Operand} {$.L2} {OFFSET FLAT:.L2}
10180 @headitem Operand @tab @samp{att} @tab @samp{intel}
10181 @item @code{%0}
10182 @tab @code{%eax}
10183 @tab @code{eax}
10184 @item @code{%1}
10185 @tab @code{$2}
10186 @tab @code{2}
10187 @item @code{%3}
10188 @tab @code{$.L3}
10189 @tab @code{OFFSET FLAT:.L3}
10190 @end multitable
10192 The table below shows the list of supported modifiers and their effects.
10194 @multitable {Modifier} {Print the opcode suffix for the size of th} {Operand} {@samp{att}} {@samp{intel}}
10195 @headitem Modifier @tab Description @tab Operand @tab @samp{att} @tab @samp{intel}
10196 @item @code{a}
10197 @tab Print an absolute memory reference.
10198 @tab @code{%A0}
10199 @tab @code{*%rax}
10200 @tab @code{rax}
10201 @item @code{b}
10202 @tab Print the QImode name of the register.
10203 @tab @code{%b0}
10204 @tab @code{%al}
10205 @tab @code{al}
10206 @item @code{c}
10207 @tab Require a constant operand and print the constant expression with no punctuation.
10208 @tab @code{%c1}
10209 @tab @code{2}
10210 @tab @code{2}
10211 @item @code{E}
10212 @tab Print the address in Double Integer (DImode) mode (8 bytes) when the target is 64-bit.
10213 Otherwise mode is unspecified (VOIDmode).
10214 @tab @code{%E1}
10215 @tab @code{%(rax)}
10216 @tab @code{[rax]}
10217 @item @code{h}
10218 @tab Print the QImode name for a ``high'' register.
10219 @tab @code{%h0}
10220 @tab @code{%ah}
10221 @tab @code{ah}
10222 @item @code{H}
10223 @tab Add 8 bytes to an offsettable memory reference. Useful when accessing the
10224 high 8 bytes of SSE values. For a memref in (%rax), it generates
10225 @tab @code{%H0}
10226 @tab @code{8(%rax)}
10227 @tab @code{8[rax]}
10228 @item @code{k}
10229 @tab Print the SImode name of the register.
10230 @tab @code{%k0}
10231 @tab @code{%eax}
10232 @tab @code{eax}
10233 @item @code{l}
10234 @tab Print the label name with no punctuation.
10235 @tab @code{%l3}
10236 @tab @code{.L3}
10237 @tab @code{.L3}
10238 @item @code{p}
10239 @tab Print raw symbol name (without syntax-specific prefixes).
10240 @tab @code{%p2}
10241 @tab @code{42}
10242 @tab @code{42}
10243 @item @code{P}
10244 @tab If used for a function, print the PLT suffix and generate PIC code.
10245 For example, emit @code{foo@@PLT} instead of 'foo' for the function
10246 foo(). If used for a constant, drop all syntax-specific prefixes and
10247 issue the bare constant. See @code{p} above.
10248 @item @code{q}
10249 @tab Print the DImode name of the register.
10250 @tab @code{%q0}
10251 @tab @code{%rax}
10252 @tab @code{rax}
10253 @item @code{w}
10254 @tab Print the HImode name of the register.
10255 @tab @code{%w0}
10256 @tab @code{%ax}
10257 @tab @code{ax}
10258 @item @code{z}
10259 @tab Print the opcode suffix for the size of the current integer operand (one of @code{b}/@code{w}/@code{l}/@code{q}).
10260 @tab @code{%z0}
10261 @tab @code{l}
10262 @tab 
10263 @end multitable
10265 @code{V} is a special modifier which prints the name of the full integer
10266 register without @code{%}.
10268 @anchor{x86floatingpointasmoperands}
10269 @subsubsection x86 Floating-Point @code{asm} Operands
10271 On x86 targets, there are several rules on the usage of stack-like registers
10272 in the operands of an @code{asm}.  These rules apply only to the operands
10273 that are stack-like registers:
10275 @enumerate
10276 @item
10277 Given a set of input registers that die in an @code{asm}, it is
10278 necessary to know which are implicitly popped by the @code{asm}, and
10279 which must be explicitly popped by GCC@.
10281 An input register that is implicitly popped by the @code{asm} must be
10282 explicitly clobbered, unless it is constrained to match an
10283 output operand.
10285 @item
10286 For any input register that is implicitly popped by an @code{asm}, it is
10287 necessary to know how to adjust the stack to compensate for the pop.
10288 If any non-popped input is closer to the top of the reg-stack than
10289 the implicitly popped register, it would not be possible to know what the
10290 stack looked like---it's not clear how the rest of the stack ``slides
10291 up''.
10293 All implicitly popped input registers must be closer to the top of
10294 the reg-stack than any input that is not implicitly popped.
10296 It is possible that if an input dies in an @code{asm}, the compiler might
10297 use the input register for an output reload.  Consider this example:
10299 @smallexample
10300 asm ("foo" : "=t" (a) : "f" (b));
10301 @end smallexample
10303 @noindent
10304 This code says that input @code{b} is not popped by the @code{asm}, and that
10305 the @code{asm} pushes a result onto the reg-stack, i.e., the stack is one
10306 deeper after the @code{asm} than it was before.  But, it is possible that
10307 reload may think that it can use the same register for both the input and
10308 the output.
10310 To prevent this from happening,
10311 if any input operand uses the @samp{f} constraint, all output register
10312 constraints must use the @samp{&} early-clobber modifier.
10314 The example above is correctly written as:
10316 @smallexample
10317 asm ("foo" : "=&t" (a) : "f" (b));
10318 @end smallexample
10320 @item
10321 Some operands need to be in particular places on the stack.  All
10322 output operands fall in this category---GCC has no other way to
10323 know which registers the outputs appear in unless you indicate
10324 this in the constraints.
10326 Output operands must specifically indicate which register an output
10327 appears in after an @code{asm}.  @samp{=f} is not allowed: the operand
10328 constraints must select a class with a single register.
10330 @item
10331 Output operands may not be ``inserted'' between existing stack registers.
10332 Since no 387 opcode uses a read/write operand, all output operands
10333 are dead before the @code{asm}, and are pushed by the @code{asm}.
10334 It makes no sense to push anywhere but the top of the reg-stack.
10336 Output operands must start at the top of the reg-stack: output
10337 operands may not ``skip'' a register.
10339 @item
10340 Some @code{asm} statements may need extra stack space for internal
10341 calculations.  This can be guaranteed by clobbering stack registers
10342 unrelated to the inputs and outputs.
10344 @end enumerate
10346 This @code{asm}
10347 takes one input, which is internally popped, and produces two outputs.
10349 @smallexample
10350 asm ("fsincos" : "=t" (cos), "=u" (sin) : "0" (inp));
10351 @end smallexample
10353 @noindent
10354 This @code{asm} takes two inputs, which are popped by the @code{fyl2xp1} opcode,
10355 and replaces them with one output.  The @code{st(1)} clobber is necessary 
10356 for the compiler to know that @code{fyl2xp1} pops both inputs.
10358 @smallexample
10359 asm ("fyl2xp1" : "=t" (result) : "0" (x), "u" (y) : "st(1)");
10360 @end smallexample
10362 @lowersections
10363 @include md.texi
10364 @raisesections
10366 @node Asm Labels
10367 @subsection Controlling Names Used in Assembler Code
10368 @cindex assembler names for identifiers
10369 @cindex names used in assembler code
10370 @cindex identifiers, names in assembler code
10372 You can specify the name to be used in the assembler code for a C
10373 function or variable by writing the @code{asm} (or @code{__asm__})
10374 keyword after the declarator.
10375 It is up to you to make sure that the assembler names you choose do not
10376 conflict with any other assembler symbols, or reference registers.
10378 @subsubheading Assembler names for data:
10380 This sample shows how to specify the assembler name for data:
10382 @smallexample
10383 int foo asm ("myfoo") = 2;
10384 @end smallexample
10386 @noindent
10387 This specifies that the name to be used for the variable @code{foo} in
10388 the assembler code should be @samp{myfoo} rather than the usual
10389 @samp{_foo}.
10391 On systems where an underscore is normally prepended to the name of a C
10392 variable, this feature allows you to define names for the
10393 linker that do not start with an underscore.
10395 GCC does not support using this feature with a non-static local variable 
10396 since such variables do not have assembler names.  If you are
10397 trying to put the variable in a particular register, see 
10398 @ref{Explicit Register Variables}.
10400 @subsubheading Assembler names for functions:
10402 To specify the assembler name for functions, write a declaration for the 
10403 function before its definition and put @code{asm} there, like this:
10405 @smallexample
10406 int func (int x, int y) asm ("MYFUNC");
10407      
10408 int func (int x, int y)
10410    /* @r{@dots{}} */
10411 @end smallexample
10413 @noindent
10414 This specifies that the name to be used for the function @code{func} in
10415 the assembler code should be @code{MYFUNC}.
10417 @node Explicit Register Variables
10418 @subsection Variables in Specified Registers
10419 @anchor{Explicit Reg Vars}
10420 @cindex explicit register variables
10421 @cindex variables in specified registers
10422 @cindex specified registers
10424 GNU C allows you to associate specific hardware registers with C 
10425 variables.  In almost all cases, allowing the compiler to assign
10426 registers produces the best code.  However under certain unusual
10427 circumstances, more precise control over the variable storage is 
10428 required.
10430 Both global and local variables can be associated with a register.  The
10431 consequences of performing this association are very different between
10432 the two, as explained in the sections below.
10434 @menu
10435 * Global Register Variables::   Variables declared at global scope.
10436 * Local Register Variables::    Variables declared within a function.
10437 @end menu
10439 @node Global Register Variables
10440 @subsubsection Defining Global Register Variables
10441 @anchor{Global Reg Vars}
10442 @cindex global register variables
10443 @cindex registers, global variables in
10444 @cindex registers, global allocation
10446 You can define a global register variable and associate it with a specified 
10447 register like this:
10449 @smallexample
10450 register int *foo asm ("r12");
10451 @end smallexample
10453 @noindent
10454 Here @code{r12} is the name of the register that should be used. Note that 
10455 this is the same syntax used for defining local register variables, but for 
10456 a global variable the declaration appears outside a function. The 
10457 @code{register} keyword is required, and cannot be combined with 
10458 @code{static}. The register name must be a valid register name for the
10459 target platform.
10461 Do not use type qualifiers such as @code{const} and @code{volatile}, as
10462 the outcome may be contrary to expectations.  In  particular, using the
10463 @code{volatile} qualifier does not fully prevent the compiler from
10464 optimizing accesses to the register.
10466 Registers are a scarce resource on most systems and allowing the 
10467 compiler to manage their usage usually results in the best code. However, 
10468 under special circumstances it can make sense to reserve some globally.
10469 For example this may be useful in programs such as programming language 
10470 interpreters that have a couple of global variables that are accessed 
10471 very often.
10473 After defining a global register variable, for the current compilation
10474 unit:
10476 @itemize @bullet
10477 @item If the register is a call-saved register, call ABI is affected:
10478 the register will not be restored in function epilogue sequences after
10479 the variable has been assigned.  Therefore, functions cannot safely
10480 return to callers that assume standard ABI.
10481 @item Conversely, if the register is a call-clobbered register, making
10482 calls to functions that use standard ABI may lose contents of the variable.
10483 Such calls may be created by the compiler even if none are evident in
10484 the original program, for example when libgcc functions are used to
10485 make up for unavailable instructions.
10486 @item Accesses to the variable may be optimized as usual and the register
10487 remains available for allocation and use in any computations, provided that
10488 observable values of the variable are not affected.
10489 @item If the variable is referenced in inline assembly, the type of access
10490 must be provided to the compiler via constraints (@pxref{Constraints}).
10491 Accesses from basic asms are not supported.
10492 @end itemize
10494 Note that these points @emph{only} apply to code that is compiled with the
10495 definition. The behavior of code that is merely linked in (for example 
10496 code from libraries) is not affected.
10498 If you want to recompile source files that do not actually use your global 
10499 register variable so they do not use the specified register for any other 
10500 purpose, you need not actually add the global register declaration to 
10501 their source code. It suffices to specify the compiler option 
10502 @option{-ffixed-@var{reg}} (@pxref{Code Gen Options}) to reserve the 
10503 register.
10505 @subsubheading Declaring the variable
10507 Global register variables cannot have initial values, because an
10508 executable file has no means to supply initial contents for a register.
10510 When selecting a register, choose one that is normally saved and 
10511 restored by function calls on your machine. This ensures that code
10512 which is unaware of this reservation (such as library routines) will 
10513 restore it before returning.
10515 On machines with register windows, be sure to choose a global
10516 register that is not affected magically by the function call mechanism.
10518 @subsubheading Using the variable
10520 @cindex @code{qsort}, and global register variables
10521 When calling routines that are not aware of the reservation, be 
10522 cautious if those routines call back into code which uses them. As an 
10523 example, if you call the system library version of @code{qsort}, it may 
10524 clobber your registers during execution, but (if you have selected 
10525 appropriate registers) it will restore them before returning. However 
10526 it will @emph{not} restore them before calling @code{qsort}'s comparison 
10527 function. As a result, global values will not reliably be available to 
10528 the comparison function unless the @code{qsort} function itself is rebuilt.
10530 Similarly, it is not safe to access the global register variables from signal
10531 handlers or from more than one thread of control. Unless you recompile 
10532 them specially for the task at hand, the system library routines may 
10533 temporarily use the register for other things.  Furthermore, since the register
10534 is not reserved exclusively for the variable, accessing it from handlers of
10535 asynchronous signals may observe unrelated temporary values residing in the
10536 register.
10538 @cindex register variable after @code{longjmp}
10539 @cindex global register after @code{longjmp}
10540 @cindex value after @code{longjmp}
10541 @findex longjmp
10542 @findex setjmp
10543 On most machines, @code{longjmp} restores to each global register
10544 variable the value it had at the time of the @code{setjmp}. On some
10545 machines, however, @code{longjmp} does not change the value of global
10546 register variables. To be portable, the function that called @code{setjmp}
10547 should make other arrangements to save the values of the global register
10548 variables, and to restore them in a @code{longjmp}. This way, the same
10549 thing happens regardless of what @code{longjmp} does.
10551 @node Local Register Variables
10552 @subsubsection Specifying Registers for Local Variables
10553 @anchor{Local Reg Vars}
10554 @cindex local variables, specifying registers
10555 @cindex specifying registers for local variables
10556 @cindex registers for local variables
10558 You can define a local register variable and associate it with a specified 
10559 register like this:
10561 @smallexample
10562 register int *foo asm ("r12");
10563 @end smallexample
10565 @noindent
10566 Here @code{r12} is the name of the register that should be used.  Note
10567 that this is the same syntax used for defining global register variables, 
10568 but for a local variable the declaration appears within a function.  The 
10569 @code{register} keyword is required, and cannot be combined with 
10570 @code{static}.  The register name must be a valid register name for the
10571 target platform.
10573 Do not use type qualifiers such as @code{const} and @code{volatile}, as
10574 the outcome may be contrary to expectations. In particular, when the
10575 @code{const} qualifier is used, the compiler may substitute the
10576 variable with its initializer in @code{asm} statements, which may cause
10577 the corresponding operand to appear in a different register.
10579 As with global register variables, it is recommended that you choose 
10580 a register that is normally saved and restored by function calls on your 
10581 machine, so that calls to library routines will not clobber it.
10583 The only supported use for this feature is to specify registers
10584 for input and output operands when calling Extended @code{asm} 
10585 (@pxref{Extended Asm}).  This may be necessary if the constraints for a 
10586 particular machine don't provide sufficient control to select the desired 
10587 register.  To force an operand into a register, create a local variable 
10588 and specify the register name after the variable's declaration.  Then use 
10589 the local variable for the @code{asm} operand and specify any constraint 
10590 letter that matches the register:
10592 @smallexample
10593 register int *p1 asm ("r0") = @dots{};
10594 register int *p2 asm ("r1") = @dots{};
10595 register int *result asm ("r0");
10596 asm ("sysint" : "=r" (result) : "0" (p1), "r" (p2));
10597 @end smallexample
10599 @emph{Warning:} In the above example, be aware that a register (for example 
10600 @code{r0}) can be call-clobbered by subsequent code, including function 
10601 calls and library calls for arithmetic operators on other variables (for 
10602 example the initialization of @code{p2}).  In this case, use temporary 
10603 variables for expressions between the register assignments:
10605 @smallexample
10606 int t1 = @dots{};
10607 register int *p1 asm ("r0") = @dots{};
10608 register int *p2 asm ("r1") = t1;
10609 register int *result asm ("r0");
10610 asm ("sysint" : "=r" (result) : "0" (p1), "r" (p2));
10611 @end smallexample
10613 Defining a register variable does not reserve the register.  Other than
10614 when invoking the Extended @code{asm}, the contents of the specified 
10615 register are not guaranteed.  For this reason, the following uses 
10616 are explicitly @emph{not} supported.  If they appear to work, it is only 
10617 happenstance, and may stop working as intended due to (seemingly) 
10618 unrelated changes in surrounding code, or even minor changes in the 
10619 optimization of a future version of gcc:
10621 @itemize @bullet
10622 @item Passing parameters to or from Basic @code{asm}
10623 @item Passing parameters to or from Extended @code{asm} without using input 
10624 or output operands.
10625 @item Passing parameters to or from routines written in assembler (or
10626 other languages) using non-standard calling conventions.
10627 @end itemize
10629 Some developers use Local Register Variables in an attempt to improve 
10630 gcc's allocation of registers, especially in large functions.  In this 
10631 case the register name is essentially a hint to the register allocator.
10632 While in some instances this can generate better code, improvements are
10633 subject to the whims of the allocator/optimizers.  Since there are no
10634 guarantees that your improvements won't be lost, this usage of Local
10635 Register Variables is discouraged.
10637 On the MIPS platform, there is related use for local register variables 
10638 with slightly different characteristics (@pxref{MIPS Coprocessors,, 
10639 Defining coprocessor specifics for MIPS targets, gccint, 
10640 GNU Compiler Collection (GCC) Internals}).
10642 @node Size of an asm
10643 @subsection Size of an @code{asm}
10645 Some targets require that GCC track the size of each instruction used
10646 in order to generate correct code.  Because the final length of the
10647 code produced by an @code{asm} statement is only known by the
10648 assembler, GCC must make an estimate as to how big it will be.  It
10649 does this by counting the number of instructions in the pattern of the
10650 @code{asm} and multiplying that by the length of the longest
10651 instruction supported by that processor.  (When working out the number
10652 of instructions, it assumes that any occurrence of a newline or of
10653 whatever statement separator character is supported by the assembler ---
10654 typically @samp{;} --- indicates the end of an instruction.)
10656 Normally, GCC's estimate is adequate to ensure that correct
10657 code is generated, but it is possible to confuse the compiler if you use
10658 pseudo instructions or assembler macros that expand into multiple real
10659 instructions, or if you use assembler directives that expand to more
10660 space in the object file than is needed for a single instruction.
10661 If this happens then the assembler may produce a diagnostic saying that
10662 a label is unreachable.
10664 @cindex @code{asm inline}
10665 This size is also used for inlining decisions.  If you use @code{asm inline}
10666 instead of just @code{asm}, then for inlining purposes the size of the asm
10667 is taken as the minimum size, ignoring how many instructions GCC thinks it is.
10669 @node Alternate Keywords
10670 @section Alternate Keywords
10671 @cindex alternate keywords
10672 @cindex keywords, alternate
10674 @option{-ansi} and the various @option{-std} options disable certain
10675 keywords.  This causes trouble when you want to use GNU C extensions, or
10676 a general-purpose header file that should be usable by all programs,
10677 including ISO C programs.  The keywords @code{asm}, @code{typeof} and
10678 @code{inline} are not available in programs compiled with
10679 @option{-ansi} or @option{-std} (although @code{inline} can be used in a
10680 program compiled with @option{-std=c99} or @option{-std=c11}).  The
10681 ISO C99 keyword
10682 @code{restrict} is only available when @option{-std=gnu99} (which will
10683 eventually be the default) or @option{-std=c99} (or the equivalent
10684 @option{-std=iso9899:1999}), or an option for a later standard
10685 version, is used.
10687 The way to solve these problems is to put @samp{__} at the beginning and
10688 end of each problematical keyword.  For example, use @code{__asm__}
10689 instead of @code{asm}, and @code{__inline__} instead of @code{inline}.
10691 Other C compilers won't accept these alternative keywords; if you want to
10692 compile with another compiler, you can define the alternate keywords as
10693 macros to replace them with the customary keywords.  It looks like this:
10695 @smallexample
10696 #ifndef __GNUC__
10697 #define __asm__ asm
10698 #endif
10699 @end smallexample
10701 @findex __extension__
10702 @opindex pedantic
10703 @option{-pedantic} and other options cause warnings for many GNU C extensions.
10704 You can
10705 prevent such warnings within one expression by writing
10706 @code{__extension__} before the expression.  @code{__extension__} has no
10707 effect aside from this.
10709 @node Incomplete Enums
10710 @section Incomplete @code{enum} Types
10712 You can define an @code{enum} tag without specifying its possible values.
10713 This results in an incomplete type, much like what you get if you write
10714 @code{struct foo} without describing the elements.  A later declaration
10715 that does specify the possible values completes the type.
10717 You cannot allocate variables or storage using the type while it is
10718 incomplete.  However, you can work with pointers to that type.
10720 This extension may not be very useful, but it makes the handling of
10721 @code{enum} more consistent with the way @code{struct} and @code{union}
10722 are handled.
10724 This extension is not supported by GNU C++.
10726 @node Function Names
10727 @section Function Names as Strings
10728 @cindex @code{__func__} identifier
10729 @cindex @code{__FUNCTION__} identifier
10730 @cindex @code{__PRETTY_FUNCTION__} identifier
10732 GCC provides three magic constants that hold the name of the current
10733 function as a string.  In C++11 and later modes, all three are treated
10734 as constant expressions and can be used in @code{constexpr} constexts.
10735 The first of these constants is @code{__func__}, which is part of
10736 the C99 standard:
10738 The identifier @code{__func__} is implicitly declared by the translator
10739 as if, immediately following the opening brace of each function
10740 definition, the declaration
10742 @smallexample
10743 static const char __func__[] = "function-name";
10744 @end smallexample
10746 @noindent
10747 appeared, where function-name is the name of the lexically-enclosing
10748 function.  This name is the unadorned name of the function.  As an
10749 extension, at file (or, in C++, namespace scope), @code{__func__}
10750 evaluates to the empty string.
10752 @code{__FUNCTION__} is another name for @code{__func__}, provided for
10753 backward compatibility with old versions of GCC.
10755 In C, @code{__PRETTY_FUNCTION__} is yet another name for
10756 @code{__func__}, except that at file (or, in C++, namespace scope),
10757 it evaluates to the string @code{"top level"}.  In addition, in C++,
10758 @code{__PRETTY_FUNCTION__} contains the signature of the function as
10759 well as its bare name.  For example, this program:
10761 @smallexample
10762 extern "C" int printf (const char *, ...);
10764 class a @{
10765  public:
10766   void sub (int i)
10767     @{
10768       printf ("__FUNCTION__ = %s\n", __FUNCTION__);
10769       printf ("__PRETTY_FUNCTION__ = %s\n", __PRETTY_FUNCTION__);
10770     @}
10774 main (void)
10776   a ax;
10777   ax.sub (0);
10778   return 0;
10780 @end smallexample
10782 @noindent
10783 gives this output:
10785 @smallexample
10786 __FUNCTION__ = sub
10787 __PRETTY_FUNCTION__ = void a::sub(int)
10788 @end smallexample
10790 These identifiers are variables, not preprocessor macros, and may not
10791 be used to initialize @code{char} arrays or be concatenated with string
10792 literals.
10794 @node Return Address
10795 @section Getting the Return or Frame Address of a Function
10797 These functions may be used to get information about the callers of a
10798 function.
10800 @deftypefn {Built-in Function} {void *} __builtin_return_address (unsigned int @var{level})
10801 This function returns the return address of the current function, or of
10802 one of its callers.  The @var{level} argument is number of frames to
10803 scan up the call stack.  A value of @code{0} yields the return address
10804 of the current function, a value of @code{1} yields the return address
10805 of the caller of the current function, and so forth.  When inlining
10806 the expected behavior is that the function returns the address of
10807 the function that is returned to.  To work around this behavior use
10808 the @code{noinline} function attribute.
10810 The @var{level} argument must be a constant integer.
10812 On some machines it may be impossible to determine the return address of
10813 any function other than the current one; in such cases, or when the top
10814 of the stack has been reached, this function returns @code{0} or a
10815 random value.  In addition, @code{__builtin_frame_address} may be used
10816 to determine if the top of the stack has been reached.
10818 Additional post-processing of the returned value may be needed, see
10819 @code{__builtin_extract_return_addr}.
10821 Calling this function with a nonzero argument can have unpredictable
10822 effects, including crashing the calling program.  As a result, calls
10823 that are considered unsafe are diagnosed when the @option{-Wframe-address}
10824 option is in effect.  Such calls should only be made in debugging
10825 situations.
10826 @end deftypefn
10828 @deftypefn {Built-in Function} {void *} __builtin_extract_return_addr (void *@var{addr})
10829 The address as returned by @code{__builtin_return_address} may have to be fed
10830 through this function to get the actual encoded address.  For example, on the
10831 31-bit S/390 platform the highest bit has to be masked out, or on SPARC
10832 platforms an offset has to be added for the true next instruction to be
10833 executed.
10835 If no fixup is needed, this function simply passes through @var{addr}.
10836 @end deftypefn
10838 @deftypefn {Built-in Function} {void *} __builtin_frob_return_address (void *@var{addr})
10839 This function does the reverse of @code{__builtin_extract_return_addr}.
10840 @end deftypefn
10842 @deftypefn {Built-in Function} {void *} __builtin_frame_address (unsigned int @var{level})
10843 This function is similar to @code{__builtin_return_address}, but it
10844 returns the address of the function frame rather than the return address
10845 of the function.  Calling @code{__builtin_frame_address} with a value of
10846 @code{0} yields the frame address of the current function, a value of
10847 @code{1} yields the frame address of the caller of the current function,
10848 and so forth.
10850 The frame is the area on the stack that holds local variables and saved
10851 registers.  The frame address is normally the address of the first word
10852 pushed on to the stack by the function.  However, the exact definition
10853 depends upon the processor and the calling convention.  If the processor
10854 has a dedicated frame pointer register, and the function has a frame,
10855 then @code{__builtin_frame_address} returns the value of the frame
10856 pointer register.
10858 On some machines it may be impossible to determine the frame address of
10859 any function other than the current one; in such cases, or when the top
10860 of the stack has been reached, this function returns @code{0} if
10861 the first frame pointer is properly initialized by the startup code.
10863 Calling this function with a nonzero argument can have unpredictable
10864 effects, including crashing the calling program.  As a result, calls
10865 that are considered unsafe are diagnosed when the @option{-Wframe-address}
10866 option is in effect.  Such calls should only be made in debugging
10867 situations.
10868 @end deftypefn
10870 @node Vector Extensions
10871 @section Using Vector Instructions through Built-in Functions
10873 On some targets, the instruction set contains SIMD vector instructions which
10874 operate on multiple values contained in one large register at the same time.
10875 For example, on the x86 the MMX, 3DNow!@: and SSE extensions can be used
10876 this way.
10878 The first step in using these extensions is to provide the necessary data
10879 types.  This should be done using an appropriate @code{typedef}:
10881 @smallexample
10882 typedef int v4si __attribute__ ((vector_size (16)));
10883 @end smallexample
10885 @noindent
10886 The @code{int} type specifies the base type, while the attribute specifies
10887 the vector size for the variable, measured in bytes.  For example, the
10888 declaration above causes the compiler to set the mode for the @code{v4si}
10889 type to be 16 bytes wide and divided into @code{int} sized units.  For
10890 a 32-bit @code{int} this means a vector of 4 units of 4 bytes, and the
10891 corresponding mode of @code{foo} is @acronym{V4SI}.
10893 The @code{vector_size} attribute is only applicable to integral and
10894 float scalars, although arrays, pointers, and function return values
10895 are allowed in conjunction with this construct. Only sizes that are
10896 a power of two are currently allowed.
10898 All the basic integer types can be used as base types, both as signed
10899 and as unsigned: @code{char}, @code{short}, @code{int}, @code{long},
10900 @code{long long}.  In addition, @code{float} and @code{double} can be
10901 used to build floating-point vector types.
10903 Specifying a combination that is not valid for the current architecture
10904 causes GCC to synthesize the instructions using a narrower mode.
10905 For example, if you specify a variable of type @code{V4SI} and your
10906 architecture does not allow for this specific SIMD type, GCC
10907 produces code that uses 4 @code{SIs}.
10909 The types defined in this manner can be used with a subset of normal C
10910 operations.  Currently, GCC allows using the following operators
10911 on these types: @code{+, -, *, /, unary minus, ^, |, &, ~, %}@.
10913 The operations behave like C++ @code{valarrays}.  Addition is defined as
10914 the addition of the corresponding elements of the operands.  For
10915 example, in the code below, each of the 4 elements in @var{a} is
10916 added to the corresponding 4 elements in @var{b} and the resulting
10917 vector is stored in @var{c}.
10919 @smallexample
10920 typedef int v4si __attribute__ ((vector_size (16)));
10922 v4si a, b, c;
10924 c = a + b;
10925 @end smallexample
10927 Subtraction, multiplication, division, and the logical operations
10928 operate in a similar manner.  Likewise, the result of using the unary
10929 minus or complement operators on a vector type is a vector whose
10930 elements are the negative or complemented values of the corresponding
10931 elements in the operand.
10933 It is possible to use shifting operators @code{<<}, @code{>>} on
10934 integer-type vectors. The operation is defined as following: @code{@{a0,
10935 a1, @dots{}, an@} >> @{b0, b1, @dots{}, bn@} == @{a0 >> b0, a1 >> b1,
10936 @dots{}, an >> bn@}}@. Vector operands must have the same number of
10937 elements. 
10939 For convenience, it is allowed to use a binary vector operation
10940 where one operand is a scalar. In that case the compiler transforms
10941 the scalar operand into a vector where each element is the scalar from
10942 the operation. The transformation happens only if the scalar could be
10943 safely converted to the vector-element type.
10944 Consider the following code.
10946 @smallexample
10947 typedef int v4si __attribute__ ((vector_size (16)));
10949 v4si a, b, c;
10950 long l;
10952 a = b + 1;    /* a = b + @{1,1,1,1@}; */
10953 a = 2 * b;    /* a = @{2,2,2,2@} * b; */
10955 a = l + a;    /* Error, cannot convert long to int. */
10956 @end smallexample
10958 Vectors can be subscripted as if the vector were an array with
10959 the same number of elements and base type.  Out of bound accesses
10960 invoke undefined behavior at run time.  Warnings for out of bound
10961 accesses for vector subscription can be enabled with
10962 @option{-Warray-bounds}.
10964 Vector comparison is supported with standard comparison
10965 operators: @code{==, !=, <, <=, >, >=}. Comparison operands can be
10966 vector expressions of integer-type or real-type. Comparison between
10967 integer-type vectors and real-type vectors are not supported.  The
10968 result of the comparison is a vector of the same width and number of
10969 elements as the comparison operands with a signed integral element
10970 type.
10972 Vectors are compared element-wise producing 0 when comparison is false
10973 and -1 (constant of the appropriate type where all bits are set)
10974 otherwise. Consider the following example.
10976 @smallexample
10977 typedef int v4si __attribute__ ((vector_size (16)));
10979 v4si a = @{1,2,3,4@};
10980 v4si b = @{3,2,1,4@};
10981 v4si c;
10983 c = a >  b;     /* The result would be @{0, 0,-1, 0@}  */
10984 c = a == b;     /* The result would be @{0,-1, 0,-1@}  */
10985 @end smallexample
10987 In C++, the ternary operator @code{?:} is available. @code{a?b:c}, where
10988 @code{b} and @code{c} are vectors of the same type and @code{a} is an
10989 integer vector with the same number of elements of the same size as @code{b}
10990 and @code{c}, computes all three arguments and creates a vector
10991 @code{@{a[0]?b[0]:c[0], a[1]?b[1]:c[1], @dots{}@}}.  Note that unlike in
10992 OpenCL, @code{a} is thus interpreted as @code{a != 0} and not @code{a < 0}.
10993 As in the case of binary operations, this syntax is also accepted when
10994 one of @code{b} or @code{c} is a scalar that is then transformed into a
10995 vector. If both @code{b} and @code{c} are scalars and the type of
10996 @code{true?b:c} has the same size as the element type of @code{a}, then
10997 @code{b} and @code{c} are converted to a vector type whose elements have
10998 this type and with the same number of elements as @code{a}.
11000 In C++, the logic operators @code{!, &&, ||} are available for vectors.
11001 @code{!v} is equivalent to @code{v == 0}, @code{a && b} is equivalent to
11002 @code{a!=0 & b!=0} and @code{a || b} is equivalent to @code{a!=0 | b!=0}.
11003 For mixed operations between a scalar @code{s} and a vector @code{v},
11004 @code{s && v} is equivalent to @code{s?v!=0:0} (the evaluation is
11005 short-circuit) and @code{v && s} is equivalent to @code{v!=0 & (s?-1:0)}.
11007 @findex __builtin_shuffle
11008 Vector shuffling is available using functions
11009 @code{__builtin_shuffle (vec, mask)} and
11010 @code{__builtin_shuffle (vec0, vec1, mask)}.
11011 Both functions construct a permutation of elements from one or two
11012 vectors and return a vector of the same type as the input vector(s).
11013 The @var{mask} is an integral vector with the same width (@var{W})
11014 and element count (@var{N}) as the output vector.
11016 The elements of the input vectors are numbered in memory ordering of
11017 @var{vec0} beginning at 0 and @var{vec1} beginning at @var{N}.  The
11018 elements of @var{mask} are considered modulo @var{N} in the single-operand
11019 case and modulo @math{2*@var{N}} in the two-operand case.
11021 Consider the following example,
11023 @smallexample
11024 typedef int v4si __attribute__ ((vector_size (16)));
11026 v4si a = @{1,2,3,4@};
11027 v4si b = @{5,6,7,8@};
11028 v4si mask1 = @{0,1,1,3@};
11029 v4si mask2 = @{0,4,2,5@};
11030 v4si res;
11032 res = __builtin_shuffle (a, mask1);       /* res is @{1,2,2,4@}  */
11033 res = __builtin_shuffle (a, b, mask2);    /* res is @{1,5,3,6@}  */
11034 @end smallexample
11036 Note that @code{__builtin_shuffle} is intentionally semantically
11037 compatible with the OpenCL @code{shuffle} and @code{shuffle2} functions.
11039 You can declare variables and use them in function calls and returns, as
11040 well as in assignments and some casts.  You can specify a vector type as
11041 a return type for a function.  Vector types can also be used as function
11042 arguments.  It is possible to cast from one vector type to another,
11043 provided they are of the same size (in fact, you can also cast vectors
11044 to and from other datatypes of the same size).
11046 You cannot operate between vectors of different lengths or different
11047 signedness without a cast.
11049 @findex __builtin_convertvector
11050 Vector conversion is available using the
11051 @code{__builtin_convertvector (vec, vectype)}
11052 function.  @var{vec} must be an expression with integral or floating
11053 vector type and @var{vectype} an integral or floating vector type with the
11054 same number of elements.  The result has @var{vectype} type and value of
11055 a C cast of every element of @var{vec} to the element type of @var{vectype}.
11057 Consider the following example,
11058 @smallexample
11059 typedef int v4si __attribute__ ((vector_size (16)));
11060 typedef float v4sf __attribute__ ((vector_size (16)));
11061 typedef double v4df __attribute__ ((vector_size (32)));
11062 typedef unsigned long long v4di __attribute__ ((vector_size (32)));
11064 v4si a = @{1,-2,3,-4@};
11065 v4sf b = @{1.5f,-2.5f,3.f,7.f@};
11066 v4di c = @{1ULL,5ULL,0ULL,10ULL@};
11067 v4sf d = __builtin_convertvector (a, v4sf); /* d is @{1.f,-2.f,3.f,-4.f@} */
11068 /* Equivalent of:
11069    v4sf d = @{ (float)a[0], (float)a[1], (float)a[2], (float)a[3] @}; */
11070 v4df e = __builtin_convertvector (a, v4df); /* e is @{1.,-2.,3.,-4.@} */
11071 v4df f = __builtin_convertvector (b, v4df); /* f is @{1.5,-2.5,3.,7.@} */
11072 v4si g = __builtin_convertvector (f, v4si); /* g is @{1,-2,3,7@} */
11073 v4si h = __builtin_convertvector (c, v4si); /* h is @{1,5,0,10@} */
11074 @end smallexample
11076 @cindex vector types, using with x86 intrinsics
11077 Sometimes it is desirable to write code using a mix of generic vector
11078 operations (for clarity) and machine-specific vector intrinsics (to
11079 access vector instructions that are not exposed via generic built-ins).
11080 On x86, intrinsic functions for integer vectors typically use the same
11081 vector type @code{__m128i} irrespective of how they interpret the vector,
11082 making it necessary to cast their arguments and return values from/to
11083 other vector types.  In C, you can make use of a @code{union} type:
11084 @c In C++ such type punning via a union is not allowed by the language
11085 @smallexample
11086 #include <immintrin.h>
11088 typedef unsigned char u8x16 __attribute__ ((vector_size (16)));
11089 typedef unsigned int  u32x4 __attribute__ ((vector_size (16)));
11091 typedef union @{
11092         __m128i mm;
11093         u8x16   u8;
11094         u32x4   u32;
11095 @} v128;
11096 @end smallexample
11098 @noindent
11099 for variables that can be used with both built-in operators and x86
11100 intrinsics:
11102 @smallexample
11103 v128 x, y = @{ 0 @};
11104 memcpy (&x, ptr, sizeof x);
11105 y.u8  += 0x80;
11106 x.mm  = _mm_adds_epu8 (x.mm, y.mm);
11107 x.u32 &= 0xffffff;
11109 /* Instead of a variable, a compound literal may be used to pass the
11110    return value of an intrinsic call to a function expecting the union: */
11111 v128 foo (v128);
11112 x = foo ((v128) @{_mm_adds_epu8 (x.mm, y.mm)@});
11113 @c This could be done implicitly with __attribute__((transparent_union)),
11114 @c but GCC does not accept it for unions of vector types (PR 88955).
11115 @end smallexample
11117 @node Offsetof
11118 @section Support for @code{offsetof}
11119 @findex __builtin_offsetof
11121 GCC implements for both C and C++ a syntactic extension to implement
11122 the @code{offsetof} macro.
11124 @smallexample
11125 primary:
11126         "__builtin_offsetof" "(" @code{typename} "," offsetof_member_designator ")"
11128 offsetof_member_designator:
11129           @code{identifier}
11130         | offsetof_member_designator "." @code{identifier}
11131         | offsetof_member_designator "[" @code{expr} "]"
11132 @end smallexample
11134 This extension is sufficient such that
11136 @smallexample
11137 #define offsetof(@var{type}, @var{member})  __builtin_offsetof (@var{type}, @var{member})
11138 @end smallexample
11140 @noindent
11141 is a suitable definition of the @code{offsetof} macro.  In C++, @var{type}
11142 may be dependent.  In either case, @var{member} may consist of a single
11143 identifier, or a sequence of member accesses and array references.
11145 @node __sync Builtins
11146 @section Legacy @code{__sync} Built-in Functions for Atomic Memory Access
11148 The following built-in functions
11149 are intended to be compatible with those described
11150 in the @cite{Intel Itanium Processor-specific Application Binary Interface},
11151 section 7.4.  As such, they depart from normal GCC practice by not using
11152 the @samp{__builtin_} prefix and also by being overloaded so that they
11153 work on multiple types.
11155 The definition given in the Intel documentation allows only for the use of
11156 the types @code{int}, @code{long}, @code{long long} or their unsigned
11157 counterparts.  GCC allows any scalar type that is 1, 2, 4 or 8 bytes in
11158 size other than the C type @code{_Bool} or the C++ type @code{bool}.
11159 Operations on pointer arguments are performed as if the operands were
11160 of the @code{uintptr_t} type.  That is, they are not scaled by the size
11161 of the type to which the pointer points.
11163 These functions are implemented in terms of the @samp{__atomic}
11164 builtins (@pxref{__atomic Builtins}).  They should not be used for new
11165 code which should use the @samp{__atomic} builtins instead.
11167 Not all operations are supported by all target processors.  If a particular
11168 operation cannot be implemented on the target processor, a warning is
11169 generated and a call to an external function is generated.  The external
11170 function carries the same name as the built-in version,
11171 with an additional suffix
11172 @samp{_@var{n}} where @var{n} is the size of the data type.
11174 @c ??? Should we have a mechanism to suppress this warning?  This is almost
11175 @c useful for implementing the operation under the control of an external
11176 @c mutex.
11178 In most cases, these built-in functions are considered a @dfn{full barrier}.
11179 That is,
11180 no memory operand is moved across the operation, either forward or
11181 backward.  Further, instructions are issued as necessary to prevent the
11182 processor from speculating loads across the operation and from queuing stores
11183 after the operation.
11185 All of the routines are described in the Intel documentation to take
11186 ``an optional list of variables protected by the memory barrier''.  It's
11187 not clear what is meant by that; it could mean that @emph{only} the
11188 listed variables are protected, or it could mean a list of additional
11189 variables to be protected.  The list is ignored by GCC which treats it as
11190 empty.  GCC interprets an empty list as meaning that all globally
11191 accessible variables should be protected.
11193 @table @code
11194 @item @var{type} __sync_fetch_and_add (@var{type} *ptr, @var{type} value, ...)
11195 @itemx @var{type} __sync_fetch_and_sub (@var{type} *ptr, @var{type} value, ...)
11196 @itemx @var{type} __sync_fetch_and_or (@var{type} *ptr, @var{type} value, ...)
11197 @itemx @var{type} __sync_fetch_and_and (@var{type} *ptr, @var{type} value, ...)
11198 @itemx @var{type} __sync_fetch_and_xor (@var{type} *ptr, @var{type} value, ...)
11199 @itemx @var{type} __sync_fetch_and_nand (@var{type} *ptr, @var{type} value, ...)
11200 @findex __sync_fetch_and_add
11201 @findex __sync_fetch_and_sub
11202 @findex __sync_fetch_and_or
11203 @findex __sync_fetch_and_and
11204 @findex __sync_fetch_and_xor
11205 @findex __sync_fetch_and_nand
11206 These built-in functions perform the operation suggested by the name, and
11207 returns the value that had previously been in memory.  That is, operations
11208 on integer operands have the following semantics.  Operations on pointer
11209 arguments are performed as if the operands were of the @code{uintptr_t}
11210 type.  That is, they are not scaled by the size of the type to which
11211 the pointer points.
11213 @smallexample
11214 @{ tmp = *ptr; *ptr @var{op}= value; return tmp; @}
11215 @{ tmp = *ptr; *ptr = ~(tmp & value); return tmp; @}   // nand
11216 @end smallexample
11218 The object pointed to by the first argument must be of integer or pointer
11219 type.  It must not be a boolean type.
11221 @emph{Note:} GCC 4.4 and later implement @code{__sync_fetch_and_nand}
11222 as @code{*ptr = ~(tmp & value)} instead of @code{*ptr = ~tmp & value}.
11224 @item @var{type} __sync_add_and_fetch (@var{type} *ptr, @var{type} value, ...)
11225 @itemx @var{type} __sync_sub_and_fetch (@var{type} *ptr, @var{type} value, ...)
11226 @itemx @var{type} __sync_or_and_fetch (@var{type} *ptr, @var{type} value, ...)
11227 @itemx @var{type} __sync_and_and_fetch (@var{type} *ptr, @var{type} value, ...)
11228 @itemx @var{type} __sync_xor_and_fetch (@var{type} *ptr, @var{type} value, ...)
11229 @itemx @var{type} __sync_nand_and_fetch (@var{type} *ptr, @var{type} value, ...)
11230 @findex __sync_add_and_fetch
11231 @findex __sync_sub_and_fetch
11232 @findex __sync_or_and_fetch
11233 @findex __sync_and_and_fetch
11234 @findex __sync_xor_and_fetch
11235 @findex __sync_nand_and_fetch
11236 These built-in functions perform the operation suggested by the name, and
11237 return the new value.  That is, operations on integer operands have
11238 the following semantics.  Operations on pointer operands are performed as
11239 if the operand's type were @code{uintptr_t}.
11241 @smallexample
11242 @{ *ptr @var{op}= value; return *ptr; @}
11243 @{ *ptr = ~(*ptr & value); return *ptr; @}   // nand
11244 @end smallexample
11246 The same constraints on arguments apply as for the corresponding
11247 @code{__sync_op_and_fetch} built-in functions.
11249 @emph{Note:} GCC 4.4 and later implement @code{__sync_nand_and_fetch}
11250 as @code{*ptr = ~(*ptr & value)} instead of
11251 @code{*ptr = ~*ptr & value}.
11253 @item bool __sync_bool_compare_and_swap (@var{type} *ptr, @var{type} oldval, @var{type} newval, ...)
11254 @itemx @var{type} __sync_val_compare_and_swap (@var{type} *ptr, @var{type} oldval, @var{type} newval, ...)
11255 @findex __sync_bool_compare_and_swap
11256 @findex __sync_val_compare_and_swap
11257 These built-in functions perform an atomic compare and swap.
11258 That is, if the current
11259 value of @code{*@var{ptr}} is @var{oldval}, then write @var{newval} into
11260 @code{*@var{ptr}}.
11262 The ``bool'' version returns @code{true} if the comparison is successful and
11263 @var{newval} is written.  The ``val'' version returns the contents
11264 of @code{*@var{ptr}} before the operation.
11266 @item __sync_synchronize (...)
11267 @findex __sync_synchronize
11268 This built-in function issues a full memory barrier.
11270 @item @var{type} __sync_lock_test_and_set (@var{type} *ptr, @var{type} value, ...)
11271 @findex __sync_lock_test_and_set
11272 This built-in function, as described by Intel, is not a traditional test-and-set
11273 operation, but rather an atomic exchange operation.  It writes @var{value}
11274 into @code{*@var{ptr}}, and returns the previous contents of
11275 @code{*@var{ptr}}.
11277 Many targets have only minimal support for such locks, and do not support
11278 a full exchange operation.  In this case, a target may support reduced
11279 functionality here by which the @emph{only} valid value to store is the
11280 immediate constant 1.  The exact value actually stored in @code{*@var{ptr}}
11281 is implementation defined.
11283 This built-in function is not a full barrier,
11284 but rather an @dfn{acquire barrier}.
11285 This means that references after the operation cannot move to (or be
11286 speculated to) before the operation, but previous memory stores may not
11287 be globally visible yet, and previous memory loads may not yet be
11288 satisfied.
11290 @item void __sync_lock_release (@var{type} *ptr, ...)
11291 @findex __sync_lock_release
11292 This built-in function releases the lock acquired by
11293 @code{__sync_lock_test_and_set}.
11294 Normally this means writing the constant 0 to @code{*@var{ptr}}.
11296 This built-in function is not a full barrier,
11297 but rather a @dfn{release barrier}.
11298 This means that all previous memory stores are globally visible, and all
11299 previous memory loads have been satisfied, but following memory reads
11300 are not prevented from being speculated to before the barrier.
11301 @end table
11303 @node __atomic Builtins
11304 @section Built-in Functions for Memory Model Aware Atomic Operations
11306 The following built-in functions approximately match the requirements
11307 for the C++11 memory model.  They are all
11308 identified by being prefixed with @samp{__atomic} and most are
11309 overloaded so that they work with multiple types.
11311 These functions are intended to replace the legacy @samp{__sync}
11312 builtins.  The main difference is that the memory order that is requested
11313 is a parameter to the functions.  New code should always use the
11314 @samp{__atomic} builtins rather than the @samp{__sync} builtins.
11316 Note that the @samp{__atomic} builtins assume that programs will
11317 conform to the C++11 memory model.  In particular, they assume
11318 that programs are free of data races.  See the C++11 standard for
11319 detailed requirements.
11321 The @samp{__atomic} builtins can be used with any integral scalar or
11322 pointer type that is 1, 2, 4, or 8 bytes in length.  16-byte integral
11323 types are also allowed if @samp{__int128} (@pxref{__int128}) is
11324 supported by the architecture.
11326 The four non-arithmetic functions (load, store, exchange, and 
11327 compare_exchange) all have a generic version as well.  This generic
11328 version works on any data type.  It uses the lock-free built-in function
11329 if the specific data type size makes that possible; otherwise, an
11330 external call is left to be resolved at run time.  This external call is
11331 the same format with the addition of a @samp{size_t} parameter inserted
11332 as the first parameter indicating the size of the object being pointed to.
11333 All objects must be the same size.
11335 There are 6 different memory orders that can be specified.  These map
11336 to the C++11 memory orders with the same names, see the C++11 standard
11337 or the @uref{http://gcc.gnu.org/wiki/Atomic/GCCMM/AtomicSync,GCC wiki
11338 on atomic synchronization} for detailed definitions.  Individual
11339 targets may also support additional memory orders for use on specific
11340 architectures.  Refer to the target documentation for details of
11341 these.
11343 An atomic operation can both constrain code motion and
11344 be mapped to hardware instructions for synchronization between threads
11345 (e.g., a fence).  To which extent this happens is controlled by the
11346 memory orders, which are listed here in approximately ascending order of
11347 strength.  The description of each memory order is only meant to roughly
11348 illustrate the effects and is not a specification; see the C++11
11349 memory model for precise semantics.
11351 @table  @code
11352 @item __ATOMIC_RELAXED
11353 Implies no inter-thread ordering constraints.
11354 @item __ATOMIC_CONSUME
11355 This is currently implemented using the stronger @code{__ATOMIC_ACQUIRE}
11356 memory order because of a deficiency in C++11's semantics for
11357 @code{memory_order_consume}.
11358 @item __ATOMIC_ACQUIRE
11359 Creates an inter-thread happens-before constraint from the release (or
11360 stronger) semantic store to this acquire load.  Can prevent hoisting
11361 of code to before the operation.
11362 @item __ATOMIC_RELEASE
11363 Creates an inter-thread happens-before constraint to acquire (or stronger)
11364 semantic loads that read from this release store.  Can prevent sinking
11365 of code to after the operation.
11366 @item __ATOMIC_ACQ_REL
11367 Combines the effects of both @code{__ATOMIC_ACQUIRE} and
11368 @code{__ATOMIC_RELEASE}.
11369 @item __ATOMIC_SEQ_CST
11370 Enforces total ordering with all other @code{__ATOMIC_SEQ_CST} operations.
11371 @end table
11373 Note that in the C++11 memory model, @emph{fences} (e.g.,
11374 @samp{__atomic_thread_fence}) take effect in combination with other
11375 atomic operations on specific memory locations (e.g., atomic loads);
11376 operations on specific memory locations do not necessarily affect other
11377 operations in the same way.
11379 Target architectures are encouraged to provide their own patterns for
11380 each of the atomic built-in functions.  If no target is provided, the original
11381 non-memory model set of @samp{__sync} atomic built-in functions are
11382 used, along with any required synchronization fences surrounding it in
11383 order to achieve the proper behavior.  Execution in this case is subject
11384 to the same restrictions as those built-in functions.
11386 If there is no pattern or mechanism to provide a lock-free instruction
11387 sequence, a call is made to an external routine with the same parameters
11388 to be resolved at run time.
11390 When implementing patterns for these built-in functions, the memory order
11391 parameter can be ignored as long as the pattern implements the most
11392 restrictive @code{__ATOMIC_SEQ_CST} memory order.  Any of the other memory
11393 orders execute correctly with this memory order but they may not execute as
11394 efficiently as they could with a more appropriate implementation of the
11395 relaxed requirements.
11397 Note that the C++11 standard allows for the memory order parameter to be
11398 determined at run time rather than at compile time.  These built-in
11399 functions map any run-time value to @code{__ATOMIC_SEQ_CST} rather
11400 than invoke a runtime library call or inline a switch statement.  This is
11401 standard compliant, safe, and the simplest approach for now.
11403 The memory order parameter is a signed int, but only the lower 16 bits are
11404 reserved for the memory order.  The remainder of the signed int is reserved
11405 for target use and should be 0.  Use of the predefined atomic values
11406 ensures proper usage.
11408 @deftypefn {Built-in Function} @var{type} __atomic_load_n (@var{type} *ptr, int memorder)
11409 This built-in function implements an atomic load operation.  It returns the
11410 contents of @code{*@var{ptr}}.
11412 The valid memory order variants are
11413 @code{__ATOMIC_RELAXED}, @code{__ATOMIC_SEQ_CST}, @code{__ATOMIC_ACQUIRE},
11414 and @code{__ATOMIC_CONSUME}.
11416 @end deftypefn
11418 @deftypefn {Built-in Function} void __atomic_load (@var{type} *ptr, @var{type} *ret, int memorder)
11419 This is the generic version of an atomic load.  It returns the
11420 contents of @code{*@var{ptr}} in @code{*@var{ret}}.
11422 @end deftypefn
11424 @deftypefn {Built-in Function} void __atomic_store_n (@var{type} *ptr, @var{type} val, int memorder)
11425 This built-in function implements an atomic store operation.  It writes 
11426 @code{@var{val}} into @code{*@var{ptr}}.  
11428 The valid memory order variants are
11429 @code{__ATOMIC_RELAXED}, @code{__ATOMIC_SEQ_CST}, and @code{__ATOMIC_RELEASE}.
11431 @end deftypefn
11433 @deftypefn {Built-in Function} void __atomic_store (@var{type} *ptr, @var{type} *val, int memorder)
11434 This is the generic version of an atomic store.  It stores the value
11435 of @code{*@var{val}} into @code{*@var{ptr}}.
11437 @end deftypefn
11439 @deftypefn {Built-in Function} @var{type} __atomic_exchange_n (@var{type} *ptr, @var{type} val, int memorder)
11440 This built-in function implements an atomic exchange operation.  It writes
11441 @var{val} into @code{*@var{ptr}}, and returns the previous contents of
11442 @code{*@var{ptr}}.
11444 The valid memory order variants are
11445 @code{__ATOMIC_RELAXED}, @code{__ATOMIC_SEQ_CST}, @code{__ATOMIC_ACQUIRE},
11446 @code{__ATOMIC_RELEASE}, and @code{__ATOMIC_ACQ_REL}.
11448 @end deftypefn
11450 @deftypefn {Built-in Function} void __atomic_exchange (@var{type} *ptr, @var{type} *val, @var{type} *ret, int memorder)
11451 This is the generic version of an atomic exchange.  It stores the
11452 contents of @code{*@var{val}} into @code{*@var{ptr}}. The original value
11453 of @code{*@var{ptr}} is copied into @code{*@var{ret}}.
11455 @end deftypefn
11457 @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)
11458 This built-in function implements an atomic compare and exchange operation.
11459 This compares the contents of @code{*@var{ptr}} with the contents of
11460 @code{*@var{expected}}. If equal, the operation is a @emph{read-modify-write}
11461 operation that writes @var{desired} into @code{*@var{ptr}}.  If they are not
11462 equal, the operation is a @emph{read} and the current contents of
11463 @code{*@var{ptr}} are written into @code{*@var{expected}}.  @var{weak} is @code{true}
11464 for weak compare_exchange, which may fail spuriously, and @code{false} for
11465 the strong variation, which never fails spuriously.  Many targets
11466 only offer the strong variation and ignore the parameter.  When in doubt, use
11467 the strong variation.
11469 If @var{desired} is written into @code{*@var{ptr}} then @code{true} is returned
11470 and memory is affected according to the
11471 memory order specified by @var{success_memorder}.  There are no
11472 restrictions on what memory order can be used here.
11474 Otherwise, @code{false} is returned and memory is affected according
11475 to @var{failure_memorder}. This memory order cannot be
11476 @code{__ATOMIC_RELEASE} nor @code{__ATOMIC_ACQ_REL}.  It also cannot be a
11477 stronger order than that specified by @var{success_memorder}.
11479 @end deftypefn
11481 @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)
11482 This built-in function implements the generic version of
11483 @code{__atomic_compare_exchange}.  The function is virtually identical to
11484 @code{__atomic_compare_exchange_n}, except the desired value is also a
11485 pointer.
11487 @end deftypefn
11489 @deftypefn {Built-in Function} @var{type} __atomic_add_fetch (@var{type} *ptr, @var{type} val, int memorder)
11490 @deftypefnx {Built-in Function} @var{type} __atomic_sub_fetch (@var{type} *ptr, @var{type} val, int memorder)
11491 @deftypefnx {Built-in Function} @var{type} __atomic_and_fetch (@var{type} *ptr, @var{type} val, int memorder)
11492 @deftypefnx {Built-in Function} @var{type} __atomic_xor_fetch (@var{type} *ptr, @var{type} val, int memorder)
11493 @deftypefnx {Built-in Function} @var{type} __atomic_or_fetch (@var{type} *ptr, @var{type} val, int memorder)
11494 @deftypefnx {Built-in Function} @var{type} __atomic_nand_fetch (@var{type} *ptr, @var{type} val, int memorder)
11495 These built-in functions perform the operation suggested by the name, and
11496 return the result of the operation.  Operations on pointer arguments are
11497 performed as if the operands were of the @code{uintptr_t} type.  That is,
11498 they are not scaled by the size of the type to which the pointer points.
11500 @smallexample
11501 @{ *ptr @var{op}= val; return *ptr; @}
11502 @{ *ptr = ~(*ptr & val); return *ptr; @} // nand
11503 @end smallexample
11505 The object pointed to by the first argument must be of integer or pointer
11506 type.  It must not be a boolean type.  All memory orders are valid.
11508 @end deftypefn
11510 @deftypefn {Built-in Function} @var{type} __atomic_fetch_add (@var{type} *ptr, @var{type} val, int memorder)
11511 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_sub (@var{type} *ptr, @var{type} val, int memorder)
11512 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_and (@var{type} *ptr, @var{type} val, int memorder)
11513 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_xor (@var{type} *ptr, @var{type} val, int memorder)
11514 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_or (@var{type} *ptr, @var{type} val, int memorder)
11515 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_nand (@var{type} *ptr, @var{type} val, int memorder)
11516 These built-in functions perform the operation suggested by the name, and
11517 return the value that had previously been in @code{*@var{ptr}}.  Operations
11518 on pointer arguments are performed as if the operands were of
11519 the @code{uintptr_t} type.  That is, they are not scaled by the size of
11520 the type to which the pointer points.
11522 @smallexample
11523 @{ tmp = *ptr; *ptr @var{op}= val; return tmp; @}
11524 @{ tmp = *ptr; *ptr = ~(*ptr & val); return tmp; @} // nand
11525 @end smallexample
11527 The same constraints on arguments apply as for the corresponding
11528 @code{__atomic_op_fetch} built-in functions.  All memory orders are valid.
11530 @end deftypefn
11532 @deftypefn {Built-in Function} bool __atomic_test_and_set (void *ptr, int memorder)
11534 This built-in function performs an atomic test-and-set operation on
11535 the byte at @code{*@var{ptr}}.  The byte is set to some implementation
11536 defined nonzero ``set'' value and the return value is @code{true} if and only
11537 if the previous contents were ``set''.
11538 It should be only used for operands of type @code{bool} or @code{char}. For 
11539 other types only part of the value may be set.
11541 All memory orders are valid.
11543 @end deftypefn
11545 @deftypefn {Built-in Function} void __atomic_clear (bool *ptr, int memorder)
11547 This built-in function performs an atomic clear operation on
11548 @code{*@var{ptr}}.  After the operation, @code{*@var{ptr}} contains 0.
11549 It should be only used for operands of type @code{bool} or @code{char} and 
11550 in conjunction with @code{__atomic_test_and_set}.
11551 For other types it may only clear partially. If the type is not @code{bool}
11552 prefer using @code{__atomic_store}.
11554 The valid memory order variants are
11555 @code{__ATOMIC_RELAXED}, @code{__ATOMIC_SEQ_CST}, and
11556 @code{__ATOMIC_RELEASE}.
11558 @end deftypefn
11560 @deftypefn {Built-in Function} void __atomic_thread_fence (int memorder)
11562 This built-in function acts as a synchronization fence between threads
11563 based on the specified memory order.
11565 All memory orders are valid.
11567 @end deftypefn
11569 @deftypefn {Built-in Function} void __atomic_signal_fence (int memorder)
11571 This built-in function acts as a synchronization fence between a thread
11572 and signal handlers based in the same thread.
11574 All memory orders are valid.
11576 @end deftypefn
11578 @deftypefn {Built-in Function} bool __atomic_always_lock_free (size_t size,  void *ptr)
11580 This built-in function returns @code{true} if objects of @var{size} bytes always
11581 generate lock-free atomic instructions for the target architecture.
11582 @var{size} must resolve to a compile-time constant and the result also
11583 resolves to a compile-time constant.
11585 @var{ptr} is an optional pointer to the object that may be used to determine
11586 alignment.  A value of 0 indicates typical alignment should be used.  The 
11587 compiler may also ignore this parameter.
11589 @smallexample
11590 if (__atomic_always_lock_free (sizeof (long long), 0))
11591 @end smallexample
11593 @end deftypefn
11595 @deftypefn {Built-in Function} bool __atomic_is_lock_free (size_t size, void *ptr)
11597 This built-in function returns @code{true} if objects of @var{size} bytes always
11598 generate lock-free atomic instructions for the target architecture.  If
11599 the built-in function is not known to be lock-free, a call is made to a
11600 runtime routine named @code{__atomic_is_lock_free}.
11602 @var{ptr} is an optional pointer to the object that may be used to determine
11603 alignment.  A value of 0 indicates typical alignment should be used.  The 
11604 compiler may also ignore this parameter.
11605 @end deftypefn
11607 @node Integer Overflow Builtins
11608 @section Built-in Functions to Perform Arithmetic with Overflow Checking
11610 The following built-in functions allow performing simple arithmetic operations
11611 together with checking whether the operations overflowed.
11613 @deftypefn {Built-in Function} bool __builtin_add_overflow (@var{type1} a, @var{type2} b, @var{type3} *res)
11614 @deftypefnx {Built-in Function} bool __builtin_sadd_overflow (int a, int b, int *res)
11615 @deftypefnx {Built-in Function} bool __builtin_saddl_overflow (long int a, long int b, long int *res)
11616 @deftypefnx {Built-in Function} bool __builtin_saddll_overflow (long long int a, long long int b, long long int *res)
11617 @deftypefnx {Built-in Function} bool __builtin_uadd_overflow (unsigned int a, unsigned int b, unsigned int *res)
11618 @deftypefnx {Built-in Function} bool __builtin_uaddl_overflow (unsigned long int a, unsigned long int b, unsigned long int *res)
11619 @deftypefnx {Built-in Function} bool __builtin_uaddll_overflow (unsigned long long int a, unsigned long long int b, unsigned long long int *res)
11621 These built-in functions promote the first two operands into infinite precision signed
11622 type and perform addition on those promoted operands.  The result is then
11623 cast to the type the third pointer argument points to and stored there.
11624 If the stored result is equal to the infinite precision result, the built-in
11625 functions return @code{false}, otherwise they return @code{true}.  As the addition is
11626 performed in infinite signed precision, these built-in functions have fully defined
11627 behavior for all argument values.
11629 The first built-in function allows arbitrary integral types for operands and
11630 the result type must be pointer to some integral type other than enumerated or
11631 boolean type, the rest of the built-in functions have explicit integer types.
11633 The compiler will attempt to use hardware instructions to implement
11634 these built-in functions where possible, like conditional jump on overflow
11635 after addition, conditional jump on carry etc.
11637 @end deftypefn
11639 @deftypefn {Built-in Function} bool __builtin_sub_overflow (@var{type1} a, @var{type2} b, @var{type3} *res)
11640 @deftypefnx {Built-in Function} bool __builtin_ssub_overflow (int a, int b, int *res)
11641 @deftypefnx {Built-in Function} bool __builtin_ssubl_overflow (long int a, long int b, long int *res)
11642 @deftypefnx {Built-in Function} bool __builtin_ssubll_overflow (long long int a, long long int b, long long int *res)
11643 @deftypefnx {Built-in Function} bool __builtin_usub_overflow (unsigned int a, unsigned int b, unsigned int *res)
11644 @deftypefnx {Built-in Function} bool __builtin_usubl_overflow (unsigned long int a, unsigned long int b, unsigned long int *res)
11645 @deftypefnx {Built-in Function} bool __builtin_usubll_overflow (unsigned long long int a, unsigned long long int b, unsigned long long int *res)
11647 These built-in functions are similar to the add overflow checking built-in
11648 functions above, except they perform subtraction, subtract the second argument
11649 from the first one, instead of addition.
11651 @end deftypefn
11653 @deftypefn {Built-in Function} bool __builtin_mul_overflow (@var{type1} a, @var{type2} b, @var{type3} *res)
11654 @deftypefnx {Built-in Function} bool __builtin_smul_overflow (int a, int b, int *res)
11655 @deftypefnx {Built-in Function} bool __builtin_smull_overflow (long int a, long int b, long int *res)
11656 @deftypefnx {Built-in Function} bool __builtin_smulll_overflow (long long int a, long long int b, long long int *res)
11657 @deftypefnx {Built-in Function} bool __builtin_umul_overflow (unsigned int a, unsigned int b, unsigned int *res)
11658 @deftypefnx {Built-in Function} bool __builtin_umull_overflow (unsigned long int a, unsigned long int b, unsigned long int *res)
11659 @deftypefnx {Built-in Function} bool __builtin_umulll_overflow (unsigned long long int a, unsigned long long int b, unsigned long long int *res)
11661 These built-in functions are similar to the add overflow checking built-in
11662 functions above, except they perform multiplication, instead of addition.
11664 @end deftypefn
11666 The following built-in functions allow checking if simple arithmetic operation
11667 would overflow.
11669 @deftypefn {Built-in Function} bool __builtin_add_overflow_p (@var{type1} a, @var{type2} b, @var{type3} c)
11670 @deftypefnx {Built-in Function} bool __builtin_sub_overflow_p (@var{type1} a, @var{type2} b, @var{type3} c)
11671 @deftypefnx {Built-in Function} bool __builtin_mul_overflow_p (@var{type1} a, @var{type2} b, @var{type3} c)
11673 These built-in functions are similar to @code{__builtin_add_overflow},
11674 @code{__builtin_sub_overflow}, or @code{__builtin_mul_overflow}, except that
11675 they don't store the result of the arithmetic operation anywhere and the
11676 last argument is not a pointer, but some expression with integral type other
11677 than enumerated or boolean type.
11679 The built-in functions promote the first two operands into infinite precision signed type
11680 and perform addition on those promoted operands. The result is then
11681 cast to the type of the third argument.  If the cast result is equal to the infinite
11682 precision result, the built-in functions return @code{false}, otherwise they return @code{true}.
11683 The value of the third argument is ignored, just the side effects in the third argument
11684 are evaluated, and no integral argument promotions are performed on the last argument.
11685 If the third argument is a bit-field, the type used for the result cast has the
11686 precision and signedness of the given bit-field, rather than precision and signedness
11687 of the underlying type.
11689 For example, the following macro can be used to portably check, at
11690 compile-time, whether or not adding two constant integers will overflow,
11691 and perform the addition only when it is known to be safe and not to trigger
11692 a @option{-Woverflow} warning.
11694 @smallexample
11695 #define INT_ADD_OVERFLOW_P(a, b) \
11696    __builtin_add_overflow_p (a, b, (__typeof__ ((a) + (b))) 0)
11698 enum @{
11699     A = INT_MAX, B = 3,
11700     C = INT_ADD_OVERFLOW_P (A, B) ? 0 : A + B,
11701     D = __builtin_add_overflow_p (1, SCHAR_MAX, (signed char) 0)
11703 @end smallexample
11705 The compiler will attempt to use hardware instructions to implement
11706 these built-in functions where possible, like conditional jump on overflow
11707 after addition, conditional jump on carry etc.
11709 @end deftypefn
11711 @node x86 specific memory model extensions for transactional memory
11712 @section x86-Specific Memory Model Extensions for Transactional Memory
11714 The x86 architecture supports additional memory ordering flags
11715 to mark critical sections for hardware lock elision. 
11716 These must be specified in addition to an existing memory order to
11717 atomic intrinsics.
11719 @table @code
11720 @item __ATOMIC_HLE_ACQUIRE
11721 Start lock elision on a lock variable.
11722 Memory order must be @code{__ATOMIC_ACQUIRE} or stronger.
11723 @item __ATOMIC_HLE_RELEASE
11724 End lock elision on a lock variable.
11725 Memory order must be @code{__ATOMIC_RELEASE} or stronger.
11726 @end table
11728 When a lock acquire fails, it is required for good performance to abort
11729 the transaction quickly. This can be done with a @code{_mm_pause}.
11731 @smallexample
11732 #include <immintrin.h> // For _mm_pause
11734 int lockvar;
11736 /* Acquire lock with lock elision */
11737 while (__atomic_exchange_n(&lockvar, 1, __ATOMIC_ACQUIRE|__ATOMIC_HLE_ACQUIRE))
11738     _mm_pause(); /* Abort failed transaction */
11740 /* Free lock with lock elision */
11741 __atomic_store_n(&lockvar, 0, __ATOMIC_RELEASE|__ATOMIC_HLE_RELEASE);
11742 @end smallexample
11744 @node Object Size Checking
11745 @section Object Size Checking Built-in Functions
11746 @findex __builtin_object_size
11747 @findex __builtin___memcpy_chk
11748 @findex __builtin___mempcpy_chk
11749 @findex __builtin___memmove_chk
11750 @findex __builtin___memset_chk
11751 @findex __builtin___strcpy_chk
11752 @findex __builtin___stpcpy_chk
11753 @findex __builtin___strncpy_chk
11754 @findex __builtin___strcat_chk
11755 @findex __builtin___strncat_chk
11756 @findex __builtin___sprintf_chk
11757 @findex __builtin___snprintf_chk
11758 @findex __builtin___vsprintf_chk
11759 @findex __builtin___vsnprintf_chk
11760 @findex __builtin___printf_chk
11761 @findex __builtin___vprintf_chk
11762 @findex __builtin___fprintf_chk
11763 @findex __builtin___vfprintf_chk
11765 GCC implements a limited buffer overflow protection mechanism that can
11766 prevent some buffer overflow attacks by determining the sizes of objects
11767 into which data is about to be written and preventing the writes when
11768 the size isn't sufficient.  The built-in functions described below yield
11769 the best results when used together and when optimization is enabled.
11770 For example, to detect object sizes across function boundaries or to
11771 follow pointer assignments through non-trivial control flow they rely
11772 on various optimization passes enabled with @option{-O2}.  However, to
11773 a limited extent, they can be used without optimization as well.
11775 @deftypefn {Built-in Function} {size_t} __builtin_object_size (const void * @var{ptr}, int @var{type})
11776 is a built-in construct that returns a constant number of bytes from
11777 @var{ptr} to the end of the object @var{ptr} pointer points to
11778 (if known at compile time).  To determine the sizes of dynamically allocated
11779 objects the function relies on the allocation functions called to obtain
11780 the storage to be declared with the @code{alloc_size} attribute (@pxref{Common
11781 Function Attributes}).  @code{__builtin_object_size} never evaluates
11782 its arguments for side effects.  If there are any side effects in them, it
11783 returns @code{(size_t) -1} for @var{type} 0 or 1 and @code{(size_t) 0}
11784 for @var{type} 2 or 3.  If there are multiple objects @var{ptr} can
11785 point to and all of them are known at compile time, the returned number
11786 is the maximum of remaining byte counts in those objects if @var{type} & 2 is
11787 0 and minimum if nonzero.  If it is not possible to determine which objects
11788 @var{ptr} points to at compile time, @code{__builtin_object_size} should
11789 return @code{(size_t) -1} for @var{type} 0 or 1 and @code{(size_t) 0}
11790 for @var{type} 2 or 3.
11792 @var{type} is an integer constant from 0 to 3.  If the least significant
11793 bit is clear, objects are whole variables, if it is set, a closest
11794 surrounding subobject is considered the object a pointer points to.
11795 The second bit determines if maximum or minimum of remaining bytes
11796 is computed.
11798 @smallexample
11799 struct V @{ char buf1[10]; int b; char buf2[10]; @} var;
11800 char *p = &var.buf1[1], *q = &var.b;
11802 /* Here the object p points to is var.  */
11803 assert (__builtin_object_size (p, 0) == sizeof (var) - 1);
11804 /* The subobject p points to is var.buf1.  */
11805 assert (__builtin_object_size (p, 1) == sizeof (var.buf1) - 1);
11806 /* The object q points to is var.  */
11807 assert (__builtin_object_size (q, 0)
11808         == (char *) (&var + 1) - (char *) &var.b);
11809 /* The subobject q points to is var.b.  */
11810 assert (__builtin_object_size (q, 1) == sizeof (var.b));
11811 @end smallexample
11812 @end deftypefn
11814 There are built-in functions added for many common string operation
11815 functions, e.g., for @code{memcpy} @code{__builtin___memcpy_chk}
11816 built-in is provided.  This built-in has an additional last argument,
11817 which is the number of bytes remaining in the object the @var{dest}
11818 argument points to or @code{(size_t) -1} if the size is not known.
11820 The built-in functions are optimized into the normal string functions
11821 like @code{memcpy} if the last argument is @code{(size_t) -1} or if
11822 it is known at compile time that the destination object will not
11823 be overflowed.  If the compiler can determine at compile time that the
11824 object will always be overflowed, it issues a warning.
11826 The intended use can be e.g.@:
11828 @smallexample
11829 #undef memcpy
11830 #define bos0(dest) __builtin_object_size (dest, 0)
11831 #define memcpy(dest, src, n) \
11832   __builtin___memcpy_chk (dest, src, n, bos0 (dest))
11834 char *volatile p;
11835 char buf[10];
11836 /* It is unknown what object p points to, so this is optimized
11837    into plain memcpy - no checking is possible.  */
11838 memcpy (p, "abcde", n);
11839 /* Destination is known and length too.  It is known at compile
11840    time there will be no overflow.  */
11841 memcpy (&buf[5], "abcde", 5);
11842 /* Destination is known, but the length is not known at compile time.
11843    This will result in __memcpy_chk call that can check for overflow
11844    at run time.  */
11845 memcpy (&buf[5], "abcde", n);
11846 /* Destination is known and it is known at compile time there will
11847    be overflow.  There will be a warning and __memcpy_chk call that
11848    will abort the program at run time.  */
11849 memcpy (&buf[6], "abcde", 5);
11850 @end smallexample
11852 Such built-in functions are provided for @code{memcpy}, @code{mempcpy},
11853 @code{memmove}, @code{memset}, @code{strcpy}, @code{stpcpy}, @code{strncpy},
11854 @code{strcat} and @code{strncat}.
11856 There are also checking built-in functions for formatted output functions.
11857 @smallexample
11858 int __builtin___sprintf_chk (char *s, int flag, size_t os, const char *fmt, ...);
11859 int __builtin___snprintf_chk (char *s, size_t maxlen, int flag, size_t os,
11860                               const char *fmt, ...);
11861 int __builtin___vsprintf_chk (char *s, int flag, size_t os, const char *fmt,
11862                               va_list ap);
11863 int __builtin___vsnprintf_chk (char *s, size_t maxlen, int flag, size_t os,
11864                                const char *fmt, va_list ap);
11865 @end smallexample
11867 The added @var{flag} argument is passed unchanged to @code{__sprintf_chk}
11868 etc.@: functions and can contain implementation specific flags on what
11869 additional security measures the checking function might take, such as
11870 handling @code{%n} differently.
11872 The @var{os} argument is the object size @var{s} points to, like in the
11873 other built-in functions.  There is a small difference in the behavior
11874 though, if @var{os} is @code{(size_t) -1}, the built-in functions are
11875 optimized into the non-checking functions only if @var{flag} is 0, otherwise
11876 the checking function is called with @var{os} argument set to
11877 @code{(size_t) -1}.
11879 In addition to this, there are checking built-in functions
11880 @code{__builtin___printf_chk}, @code{__builtin___vprintf_chk},
11881 @code{__builtin___fprintf_chk} and @code{__builtin___vfprintf_chk}.
11882 These have just one additional argument, @var{flag}, right before
11883 format string @var{fmt}.  If the compiler is able to optimize them to
11884 @code{fputc} etc.@: functions, it does, otherwise the checking function
11885 is called and the @var{flag} argument passed to it.
11887 @node Other Builtins
11888 @section Other Built-in Functions Provided by GCC
11889 @cindex built-in functions
11890 @findex __builtin_alloca
11891 @findex __builtin_alloca_with_align
11892 @findex __builtin_alloca_with_align_and_max
11893 @findex __builtin_call_with_static_chain
11894 @findex __builtin_extend_pointer
11895 @findex __builtin_fpclassify
11896 @findex __builtin_has_attribute
11897 @findex __builtin_isfinite
11898 @findex __builtin_isnormal
11899 @findex __builtin_isgreater
11900 @findex __builtin_isgreaterequal
11901 @findex __builtin_isinf_sign
11902 @findex __builtin_isless
11903 @findex __builtin_islessequal
11904 @findex __builtin_islessgreater
11905 @findex __builtin_isunordered
11906 @findex __builtin_object_size
11907 @findex __builtin_powi
11908 @findex __builtin_powif
11909 @findex __builtin_powil
11910 @findex __builtin_speculation_safe_value
11911 @findex _Exit
11912 @findex _exit
11913 @findex abort
11914 @findex abs
11915 @findex acos
11916 @findex acosf
11917 @findex acosh
11918 @findex acoshf
11919 @findex acoshl
11920 @findex acosl
11921 @findex alloca
11922 @findex asin
11923 @findex asinf
11924 @findex asinh
11925 @findex asinhf
11926 @findex asinhl
11927 @findex asinl
11928 @findex atan
11929 @findex atan2
11930 @findex atan2f
11931 @findex atan2l
11932 @findex atanf
11933 @findex atanh
11934 @findex atanhf
11935 @findex atanhl
11936 @findex atanl
11937 @findex bcmp
11938 @findex bzero
11939 @findex cabs
11940 @findex cabsf
11941 @findex cabsl
11942 @findex cacos
11943 @findex cacosf
11944 @findex cacosh
11945 @findex cacoshf
11946 @findex cacoshl
11947 @findex cacosl
11948 @findex calloc
11949 @findex carg
11950 @findex cargf
11951 @findex cargl
11952 @findex casin
11953 @findex casinf
11954 @findex casinh
11955 @findex casinhf
11956 @findex casinhl
11957 @findex casinl
11958 @findex catan
11959 @findex catanf
11960 @findex catanh
11961 @findex catanhf
11962 @findex catanhl
11963 @findex catanl
11964 @findex cbrt
11965 @findex cbrtf
11966 @findex cbrtl
11967 @findex ccos
11968 @findex ccosf
11969 @findex ccosh
11970 @findex ccoshf
11971 @findex ccoshl
11972 @findex ccosl
11973 @findex ceil
11974 @findex ceilf
11975 @findex ceill
11976 @findex cexp
11977 @findex cexpf
11978 @findex cexpl
11979 @findex cimag
11980 @findex cimagf
11981 @findex cimagl
11982 @findex clog
11983 @findex clogf
11984 @findex clogl
11985 @findex clog10
11986 @findex clog10f
11987 @findex clog10l
11988 @findex conj
11989 @findex conjf
11990 @findex conjl
11991 @findex copysign
11992 @findex copysignf
11993 @findex copysignl
11994 @findex cos
11995 @findex cosf
11996 @findex cosh
11997 @findex coshf
11998 @findex coshl
11999 @findex cosl
12000 @findex cpow
12001 @findex cpowf
12002 @findex cpowl
12003 @findex cproj
12004 @findex cprojf
12005 @findex cprojl
12006 @findex creal
12007 @findex crealf
12008 @findex creall
12009 @findex csin
12010 @findex csinf
12011 @findex csinh
12012 @findex csinhf
12013 @findex csinhl
12014 @findex csinl
12015 @findex csqrt
12016 @findex csqrtf
12017 @findex csqrtl
12018 @findex ctan
12019 @findex ctanf
12020 @findex ctanh
12021 @findex ctanhf
12022 @findex ctanhl
12023 @findex ctanl
12024 @findex dcgettext
12025 @findex dgettext
12026 @findex drem
12027 @findex dremf
12028 @findex dreml
12029 @findex erf
12030 @findex erfc
12031 @findex erfcf
12032 @findex erfcl
12033 @findex erff
12034 @findex erfl
12035 @findex exit
12036 @findex exp
12037 @findex exp10
12038 @findex exp10f
12039 @findex exp10l
12040 @findex exp2
12041 @findex exp2f
12042 @findex exp2l
12043 @findex expf
12044 @findex expl
12045 @findex expm1
12046 @findex expm1f
12047 @findex expm1l
12048 @findex fabs
12049 @findex fabsf
12050 @findex fabsl
12051 @findex fdim
12052 @findex fdimf
12053 @findex fdiml
12054 @findex ffs
12055 @findex floor
12056 @findex floorf
12057 @findex floorl
12058 @findex fma
12059 @findex fmaf
12060 @findex fmal
12061 @findex fmax
12062 @findex fmaxf
12063 @findex fmaxl
12064 @findex fmin
12065 @findex fminf
12066 @findex fminl
12067 @findex fmod
12068 @findex fmodf
12069 @findex fmodl
12070 @findex fprintf
12071 @findex fprintf_unlocked
12072 @findex fputs
12073 @findex fputs_unlocked
12074 @findex frexp
12075 @findex frexpf
12076 @findex frexpl
12077 @findex fscanf
12078 @findex gamma
12079 @findex gammaf
12080 @findex gammal
12081 @findex gamma_r
12082 @findex gammaf_r
12083 @findex gammal_r
12084 @findex gettext
12085 @findex hypot
12086 @findex hypotf
12087 @findex hypotl
12088 @findex ilogb
12089 @findex ilogbf
12090 @findex ilogbl
12091 @findex imaxabs
12092 @findex index
12093 @findex isalnum
12094 @findex isalpha
12095 @findex isascii
12096 @findex isblank
12097 @findex iscntrl
12098 @findex isdigit
12099 @findex isgraph
12100 @findex islower
12101 @findex isprint
12102 @findex ispunct
12103 @findex isspace
12104 @findex isupper
12105 @findex iswalnum
12106 @findex iswalpha
12107 @findex iswblank
12108 @findex iswcntrl
12109 @findex iswdigit
12110 @findex iswgraph
12111 @findex iswlower
12112 @findex iswprint
12113 @findex iswpunct
12114 @findex iswspace
12115 @findex iswupper
12116 @findex iswxdigit
12117 @findex isxdigit
12118 @findex j0
12119 @findex j0f
12120 @findex j0l
12121 @findex j1
12122 @findex j1f
12123 @findex j1l
12124 @findex jn
12125 @findex jnf
12126 @findex jnl
12127 @findex labs
12128 @findex ldexp
12129 @findex ldexpf
12130 @findex ldexpl
12131 @findex lgamma
12132 @findex lgammaf
12133 @findex lgammal
12134 @findex lgamma_r
12135 @findex lgammaf_r
12136 @findex lgammal_r
12137 @findex llabs
12138 @findex llrint
12139 @findex llrintf
12140 @findex llrintl
12141 @findex llround
12142 @findex llroundf
12143 @findex llroundl
12144 @findex log
12145 @findex log10
12146 @findex log10f
12147 @findex log10l
12148 @findex log1p
12149 @findex log1pf
12150 @findex log1pl
12151 @findex log2
12152 @findex log2f
12153 @findex log2l
12154 @findex logb
12155 @findex logbf
12156 @findex logbl
12157 @findex logf
12158 @findex logl
12159 @findex lrint
12160 @findex lrintf
12161 @findex lrintl
12162 @findex lround
12163 @findex lroundf
12164 @findex lroundl
12165 @findex malloc
12166 @findex memchr
12167 @findex memcmp
12168 @findex memcpy
12169 @findex mempcpy
12170 @findex memset
12171 @findex modf
12172 @findex modff
12173 @findex modfl
12174 @findex nearbyint
12175 @findex nearbyintf
12176 @findex nearbyintl
12177 @findex nextafter
12178 @findex nextafterf
12179 @findex nextafterl
12180 @findex nexttoward
12181 @findex nexttowardf
12182 @findex nexttowardl
12183 @findex pow
12184 @findex pow10
12185 @findex pow10f
12186 @findex pow10l
12187 @findex powf
12188 @findex powl
12189 @findex printf
12190 @findex printf_unlocked
12191 @findex putchar
12192 @findex puts
12193 @findex remainder
12194 @findex remainderf
12195 @findex remainderl
12196 @findex remquo
12197 @findex remquof
12198 @findex remquol
12199 @findex rindex
12200 @findex rint
12201 @findex rintf
12202 @findex rintl
12203 @findex round
12204 @findex roundf
12205 @findex roundl
12206 @findex scalb
12207 @findex scalbf
12208 @findex scalbl
12209 @findex scalbln
12210 @findex scalblnf
12211 @findex scalblnf
12212 @findex scalbn
12213 @findex scalbnf
12214 @findex scanfnl
12215 @findex signbit
12216 @findex signbitf
12217 @findex signbitl
12218 @findex signbitd32
12219 @findex signbitd64
12220 @findex signbitd128
12221 @findex significand
12222 @findex significandf
12223 @findex significandl
12224 @findex sin
12225 @findex sincos
12226 @findex sincosf
12227 @findex sincosl
12228 @findex sinf
12229 @findex sinh
12230 @findex sinhf
12231 @findex sinhl
12232 @findex sinl
12233 @findex snprintf
12234 @findex sprintf
12235 @findex sqrt
12236 @findex sqrtf
12237 @findex sqrtl
12238 @findex sscanf
12239 @findex stpcpy
12240 @findex stpncpy
12241 @findex strcasecmp
12242 @findex strcat
12243 @findex strchr
12244 @findex strcmp
12245 @findex strcpy
12246 @findex strcspn
12247 @findex strdup
12248 @findex strfmon
12249 @findex strftime
12250 @findex strlen
12251 @findex strncasecmp
12252 @findex strncat
12253 @findex strncmp
12254 @findex strncpy
12255 @findex strndup
12256 @findex strnlen
12257 @findex strpbrk
12258 @findex strrchr
12259 @findex strspn
12260 @findex strstr
12261 @findex tan
12262 @findex tanf
12263 @findex tanh
12264 @findex tanhf
12265 @findex tanhl
12266 @findex tanl
12267 @findex tgamma
12268 @findex tgammaf
12269 @findex tgammal
12270 @findex toascii
12271 @findex tolower
12272 @findex toupper
12273 @findex towlower
12274 @findex towupper
12275 @findex trunc
12276 @findex truncf
12277 @findex truncl
12278 @findex vfprintf
12279 @findex vfscanf
12280 @findex vprintf
12281 @findex vscanf
12282 @findex vsnprintf
12283 @findex vsprintf
12284 @findex vsscanf
12285 @findex y0
12286 @findex y0f
12287 @findex y0l
12288 @findex y1
12289 @findex y1f
12290 @findex y1l
12291 @findex yn
12292 @findex ynf
12293 @findex ynl
12295 GCC provides a large number of built-in functions other than the ones
12296 mentioned above.  Some of these are for internal use in the processing
12297 of exceptions or variable-length argument lists and are not
12298 documented here because they may change from time to time; we do not
12299 recommend general use of these functions.
12301 The remaining functions are provided for optimization purposes.
12303 With the exception of built-ins that have library equivalents such as
12304 the standard C library functions discussed below, or that expand to
12305 library calls, GCC built-in functions are always expanded inline and
12306 thus do not have corresponding entry points and their address cannot
12307 be obtained.  Attempting to use them in an expression other than
12308 a function call results in a compile-time error.
12310 @opindex fno-builtin
12311 GCC includes built-in versions of many of the functions in the standard
12312 C library.  These functions come in two forms: one whose names start with
12313 the @code{__builtin_} prefix, and the other without.  Both forms have the
12314 same type (including prototype), the same address (when their address is
12315 taken), and the same meaning as the C library functions even if you specify
12316 the @option{-fno-builtin} option @pxref{C Dialect Options}).  Many of these
12317 functions are only optimized in certain cases; if they are not optimized in
12318 a particular case, a call to the library function is emitted.
12320 @opindex ansi
12321 @opindex std
12322 Outside strict ISO C mode (@option{-ansi}, @option{-std=c90},
12323 @option{-std=c99} or @option{-std=c11}), the functions
12324 @code{_exit}, @code{alloca}, @code{bcmp}, @code{bzero},
12325 @code{dcgettext}, @code{dgettext}, @code{dremf}, @code{dreml},
12326 @code{drem}, @code{exp10f}, @code{exp10l}, @code{exp10}, @code{ffsll},
12327 @code{ffsl}, @code{ffs}, @code{fprintf_unlocked},
12328 @code{fputs_unlocked}, @code{gammaf}, @code{gammal}, @code{gamma},
12329 @code{gammaf_r}, @code{gammal_r}, @code{gamma_r}, @code{gettext},
12330 @code{index}, @code{isascii}, @code{j0f}, @code{j0l}, @code{j0},
12331 @code{j1f}, @code{j1l}, @code{j1}, @code{jnf}, @code{jnl}, @code{jn},
12332 @code{lgammaf_r}, @code{lgammal_r}, @code{lgamma_r}, @code{mempcpy},
12333 @code{pow10f}, @code{pow10l}, @code{pow10}, @code{printf_unlocked},
12334 @code{rindex}, @code{scalbf}, @code{scalbl}, @code{scalb},
12335 @code{signbit}, @code{signbitf}, @code{signbitl}, @code{signbitd32},
12336 @code{signbitd64}, @code{signbitd128}, @code{significandf},
12337 @code{significandl}, @code{significand}, @code{sincosf},
12338 @code{sincosl}, @code{sincos}, @code{stpcpy}, @code{stpncpy},
12339 @code{strcasecmp}, @code{strdup}, @code{strfmon}, @code{strncasecmp},
12340 @code{strndup}, @code{strnlen}, @code{toascii}, @code{y0f}, @code{y0l},
12341 @code{y0}, @code{y1f}, @code{y1l}, @code{y1}, @code{ynf}, @code{ynl} and
12342 @code{yn}
12343 may be handled as built-in functions.
12344 All these functions have corresponding versions
12345 prefixed with @code{__builtin_}, which may be used even in strict C90
12346 mode.
12348 The ISO C99 functions
12349 @code{_Exit}, @code{acoshf}, @code{acoshl}, @code{acosh}, @code{asinhf},
12350 @code{asinhl}, @code{asinh}, @code{atanhf}, @code{atanhl}, @code{atanh},
12351 @code{cabsf}, @code{cabsl}, @code{cabs}, @code{cacosf}, @code{cacoshf},
12352 @code{cacoshl}, @code{cacosh}, @code{cacosl}, @code{cacos},
12353 @code{cargf}, @code{cargl}, @code{carg}, @code{casinf}, @code{casinhf},
12354 @code{casinhl}, @code{casinh}, @code{casinl}, @code{casin},
12355 @code{catanf}, @code{catanhf}, @code{catanhl}, @code{catanh},
12356 @code{catanl}, @code{catan}, @code{cbrtf}, @code{cbrtl}, @code{cbrt},
12357 @code{ccosf}, @code{ccoshf}, @code{ccoshl}, @code{ccosh}, @code{ccosl},
12358 @code{ccos}, @code{cexpf}, @code{cexpl}, @code{cexp}, @code{cimagf},
12359 @code{cimagl}, @code{cimag}, @code{clogf}, @code{clogl}, @code{clog},
12360 @code{conjf}, @code{conjl}, @code{conj}, @code{copysignf}, @code{copysignl},
12361 @code{copysign}, @code{cpowf}, @code{cpowl}, @code{cpow}, @code{cprojf},
12362 @code{cprojl}, @code{cproj}, @code{crealf}, @code{creall}, @code{creal},
12363 @code{csinf}, @code{csinhf}, @code{csinhl}, @code{csinh}, @code{csinl},
12364 @code{csin}, @code{csqrtf}, @code{csqrtl}, @code{csqrt}, @code{ctanf},
12365 @code{ctanhf}, @code{ctanhl}, @code{ctanh}, @code{ctanl}, @code{ctan},
12366 @code{erfcf}, @code{erfcl}, @code{erfc}, @code{erff}, @code{erfl},
12367 @code{erf}, @code{exp2f}, @code{exp2l}, @code{exp2}, @code{expm1f},
12368 @code{expm1l}, @code{expm1}, @code{fdimf}, @code{fdiml}, @code{fdim},
12369 @code{fmaf}, @code{fmal}, @code{fmaxf}, @code{fmaxl}, @code{fmax},
12370 @code{fma}, @code{fminf}, @code{fminl}, @code{fmin}, @code{hypotf},
12371 @code{hypotl}, @code{hypot}, @code{ilogbf}, @code{ilogbl}, @code{ilogb},
12372 @code{imaxabs}, @code{isblank}, @code{iswblank}, @code{lgammaf},
12373 @code{lgammal}, @code{lgamma}, @code{llabs}, @code{llrintf}, @code{llrintl},
12374 @code{llrint}, @code{llroundf}, @code{llroundl}, @code{llround},
12375 @code{log1pf}, @code{log1pl}, @code{log1p}, @code{log2f}, @code{log2l},
12376 @code{log2}, @code{logbf}, @code{logbl}, @code{logb}, @code{lrintf},
12377 @code{lrintl}, @code{lrint}, @code{lroundf}, @code{lroundl},
12378 @code{lround}, @code{nearbyintf}, @code{nearbyintl}, @code{nearbyint},
12379 @code{nextafterf}, @code{nextafterl}, @code{nextafter},
12380 @code{nexttowardf}, @code{nexttowardl}, @code{nexttoward},
12381 @code{remainderf}, @code{remainderl}, @code{remainder}, @code{remquof},
12382 @code{remquol}, @code{remquo}, @code{rintf}, @code{rintl}, @code{rint},
12383 @code{roundf}, @code{roundl}, @code{round}, @code{scalblnf},
12384 @code{scalblnl}, @code{scalbln}, @code{scalbnf}, @code{scalbnl},
12385 @code{scalbn}, @code{snprintf}, @code{tgammaf}, @code{tgammal},
12386 @code{tgamma}, @code{truncf}, @code{truncl}, @code{trunc},
12387 @code{vfscanf}, @code{vscanf}, @code{vsnprintf} and @code{vsscanf}
12388 are handled as built-in functions
12389 except in strict ISO C90 mode (@option{-ansi} or @option{-std=c90}).
12391 There are also built-in versions of the ISO C99 functions
12392 @code{acosf}, @code{acosl}, @code{asinf}, @code{asinl}, @code{atan2f},
12393 @code{atan2l}, @code{atanf}, @code{atanl}, @code{ceilf}, @code{ceill},
12394 @code{cosf}, @code{coshf}, @code{coshl}, @code{cosl}, @code{expf},
12395 @code{expl}, @code{fabsf}, @code{fabsl}, @code{floorf}, @code{floorl},
12396 @code{fmodf}, @code{fmodl}, @code{frexpf}, @code{frexpl}, @code{ldexpf},
12397 @code{ldexpl}, @code{log10f}, @code{log10l}, @code{logf}, @code{logl},
12398 @code{modfl}, @code{modf}, @code{powf}, @code{powl}, @code{sinf},
12399 @code{sinhf}, @code{sinhl}, @code{sinl}, @code{sqrtf}, @code{sqrtl},
12400 @code{tanf}, @code{tanhf}, @code{tanhl} and @code{tanl}
12401 that are recognized in any mode since ISO C90 reserves these names for
12402 the purpose to which ISO C99 puts them.  All these functions have
12403 corresponding versions prefixed with @code{__builtin_}.
12405 There are also built-in functions @code{__builtin_fabsf@var{n}},
12406 @code{__builtin_fabsf@var{n}x}, @code{__builtin_copysignf@var{n}} and
12407 @code{__builtin_copysignf@var{n}x}, corresponding to the TS 18661-3
12408 functions @code{fabsf@var{n}}, @code{fabsf@var{n}x},
12409 @code{copysignf@var{n}} and @code{copysignf@var{n}x}, for supported
12410 types @code{_Float@var{n}} and @code{_Float@var{n}x}.
12412 There are also GNU extension functions @code{clog10}, @code{clog10f} and
12413 @code{clog10l} which names are reserved by ISO C99 for future use.
12414 All these functions have versions prefixed with @code{__builtin_}.
12416 The ISO C94 functions
12417 @code{iswalnum}, @code{iswalpha}, @code{iswcntrl}, @code{iswdigit},
12418 @code{iswgraph}, @code{iswlower}, @code{iswprint}, @code{iswpunct},
12419 @code{iswspace}, @code{iswupper}, @code{iswxdigit}, @code{towlower} and
12420 @code{towupper}
12421 are handled as built-in functions
12422 except in strict ISO C90 mode (@option{-ansi} or @option{-std=c90}).
12424 The ISO C90 functions
12425 @code{abort}, @code{abs}, @code{acos}, @code{asin}, @code{atan2},
12426 @code{atan}, @code{calloc}, @code{ceil}, @code{cosh}, @code{cos},
12427 @code{exit}, @code{exp}, @code{fabs}, @code{floor}, @code{fmod},
12428 @code{fprintf}, @code{fputs}, @code{frexp}, @code{fscanf},
12429 @code{isalnum}, @code{isalpha}, @code{iscntrl}, @code{isdigit},
12430 @code{isgraph}, @code{islower}, @code{isprint}, @code{ispunct},
12431 @code{isspace}, @code{isupper}, @code{isxdigit}, @code{tolower},
12432 @code{toupper}, @code{labs}, @code{ldexp}, @code{log10}, @code{log},
12433 @code{malloc}, @code{memchr}, @code{memcmp}, @code{memcpy},
12434 @code{memset}, @code{modf}, @code{pow}, @code{printf}, @code{putchar},
12435 @code{puts}, @code{scanf}, @code{sinh}, @code{sin}, @code{snprintf},
12436 @code{sprintf}, @code{sqrt}, @code{sscanf}, @code{strcat},
12437 @code{strchr}, @code{strcmp}, @code{strcpy}, @code{strcspn},
12438 @code{strlen}, @code{strncat}, @code{strncmp}, @code{strncpy},
12439 @code{strpbrk}, @code{strrchr}, @code{strspn}, @code{strstr},
12440 @code{tanh}, @code{tan}, @code{vfprintf}, @code{vprintf} and @code{vsprintf}
12441 are all recognized as built-in functions unless
12442 @option{-fno-builtin} is specified (or @option{-fno-builtin-@var{function}}
12443 is specified for an individual function).  All of these functions have
12444 corresponding versions prefixed with @code{__builtin_}.
12446 GCC provides built-in versions of the ISO C99 floating-point comparison
12447 macros that avoid raising exceptions for unordered operands.  They have
12448 the same names as the standard macros ( @code{isgreater},
12449 @code{isgreaterequal}, @code{isless}, @code{islessequal},
12450 @code{islessgreater}, and @code{isunordered}) , with @code{__builtin_}
12451 prefixed.  We intend for a library implementor to be able to simply
12452 @code{#define} each standard macro to its built-in equivalent.
12453 In the same fashion, GCC provides @code{fpclassify}, @code{isfinite},
12454 @code{isinf_sign}, @code{isnormal} and @code{signbit} built-ins used with
12455 @code{__builtin_} prefixed.  The @code{isinf} and @code{isnan}
12456 built-in functions appear both with and without the @code{__builtin_} prefix.
12458 @deftypefn {Built-in Function} void *__builtin_alloca (size_t size)
12459 The @code{__builtin_alloca} function must be called at block scope.
12460 The function allocates an object @var{size} bytes large on the stack
12461 of the calling function.  The object is aligned on the default stack
12462 alignment boundary for the target determined by the
12463 @code{__BIGGEST_ALIGNMENT__} macro.  The @code{__builtin_alloca}
12464 function returns a pointer to the first byte of the allocated object.
12465 The lifetime of the allocated object ends just before the calling
12466 function returns to its caller.   This is so even when
12467 @code{__builtin_alloca} is called within a nested block.
12469 For example, the following function allocates eight objects of @code{n}
12470 bytes each on the stack, storing a pointer to each in consecutive elements
12471 of the array @code{a}.  It then passes the array to function @code{g}
12472 which can safely use the storage pointed to by each of the array elements.
12474 @smallexample
12475 void f (unsigned n)
12477   void *a [8];
12478   for (int i = 0; i != 8; ++i)
12479     a [i] = __builtin_alloca (n);
12481   g (a, n);   // @r{safe}
12483 @end smallexample
12485 Since the @code{__builtin_alloca} function doesn't validate its argument
12486 it is the responsibility of its caller to make sure the argument doesn't
12487 cause it to exceed the stack size limit.
12488 The @code{__builtin_alloca} function is provided to make it possible to
12489 allocate on the stack arrays of bytes with an upper bound that may be
12490 computed at run time.  Since C99 Variable Length Arrays offer
12491 similar functionality under a portable, more convenient, and safer
12492 interface they are recommended instead, in both C99 and C++ programs
12493 where GCC provides them as an extension.
12494 @xref{Variable Length}, for details.
12496 @end deftypefn
12498 @deftypefn {Built-in Function} void *__builtin_alloca_with_align (size_t size, size_t alignment)
12499 The @code{__builtin_alloca_with_align} function must be called at block
12500 scope.  The function allocates an object @var{size} bytes large on
12501 the stack of the calling function.  The allocated object is aligned on
12502 the boundary specified by the argument @var{alignment} whose unit is given
12503 in bits (not bytes).  The @var{size} argument must be positive and not
12504 exceed the stack size limit.  The @var{alignment} argument must be a constant
12505 integer expression that evaluates to a power of 2 greater than or equal to
12506 @code{CHAR_BIT} and less than some unspecified maximum.  Invocations
12507 with other values are rejected with an error indicating the valid bounds.
12508 The function returns a pointer to the first byte of the allocated object.
12509 The lifetime of the allocated object ends at the end of the block in which
12510 the function was called.  The allocated storage is released no later than
12511 just before the calling function returns to its caller, but may be released
12512 at the end of the block in which the function was called.
12514 For example, in the following function the call to @code{g} is unsafe
12515 because when @code{overalign} is non-zero, the space allocated by
12516 @code{__builtin_alloca_with_align} may have been released at the end
12517 of the @code{if} statement in which it was called.
12519 @smallexample
12520 void f (unsigned n, bool overalign)
12522   void *p;
12523   if (overalign)
12524     p = __builtin_alloca_with_align (n, 64 /* bits */);
12525   else
12526     p = __builtin_alloc (n);
12528   g (p, n);   // @r{unsafe}
12530 @end smallexample
12532 Since the @code{__builtin_alloca_with_align} function doesn't validate its
12533 @var{size} argument it is the responsibility of its caller to make sure
12534 the argument doesn't cause it to exceed the stack size limit.
12535 The @code{__builtin_alloca_with_align} function is provided to make
12536 it possible to allocate on the stack overaligned arrays of bytes with
12537 an upper bound that may be computed at run time.  Since C99
12538 Variable Length Arrays offer the same functionality under
12539 a portable, more convenient, and safer interface they are recommended
12540 instead, in both C99 and C++ programs where GCC provides them as
12541 an extension.  @xref{Variable Length}, for details.
12543 @end deftypefn
12545 @deftypefn {Built-in Function} void *__builtin_alloca_with_align_and_max (size_t size, size_t alignment, size_t max_size)
12546 Similar to @code{__builtin_alloca_with_align} but takes an extra argument
12547 specifying an upper bound for @var{size} in case its value cannot be computed
12548 at compile time, for use by @option{-fstack-usage}, @option{-Wstack-usage}
12549 and @option{-Walloca-larger-than}.  @var{max_size} must be a constant integer
12550 expression, it has no effect on code generation and no attempt is made to
12551 check its compatibility with @var{size}.
12553 @end deftypefn
12555 @deftypefn {Built-in Function} bool __builtin_has_attribute (@var{type-or-expression}, @var{attribute})
12556 The @code{__builtin_has_attribute} function evaluates to an integer constant
12557 expression equal to @code{true} if the symbol or type referenced by
12558 the @var{type-or-expression} argument has been declared with
12559 the @var{attribute} referenced by the second argument.  Neither argument
12560 is evaluated.  The @var{type-or-expression} argument is subject to the same
12561 restrictions as the argument to @code{typeof} (@pxref{Typeof}).  The
12562 @var{attribute} argument is an attribute name optionally followed by
12563 a comma-separated list of arguments enclosed in parentheses.  Both forms
12564 of attribute names---with and without double leading and trailing
12565 underscores---are recognized.  @xref{Attribute Syntax}, for details.
12566 When no attribute arguments are specified for an attribute that expects
12567 one or more arguments the function returns @code{true} if
12568 @var{type-or-expression} has been declared with the attribute regardless
12569 of the attribute argument values.  Arguments provided for an attribute
12570 that expects some are validated and matched up to the provided number.
12571 The function returns @code{true} if all provided arguments match.  For
12572 example, the first call to the function below evaluates to @code{true}
12573 because @code{x} is declared with the @code{aligned} attribute but
12574 the second call evaluates to @code{false} because @code{x} is declared
12575 @code{aligned (8)} and not @code{aligned (4)}.
12577 @smallexample
12578 __attribute__ ((aligned (8))) int x;
12579 _Static_assert (__builtin_has_attribute (x, aligned), "aligned");
12580 _Static_assert (!__builtin_has_attribute (x, aligned (4)), "aligned (4)");
12581 @end smallexample
12583 Due to a limitation the @code{__builtin_has_attribute} function returns
12584 @code{false} for the @code{mode} attribute even if the type or variable
12585 referenced by the @var{type-or-expression} argument was declared with one.
12586 The function is also not supported with labels, and in C with enumerators.
12588 Note that unlike the @code{__has_attribute} preprocessor operator which
12589 is suitable for use in @code{#if} preprocessing directives
12590 @code{__builtin_has_attribute} is an intrinsic function that is not
12591 recognized in such contexts.
12593 @end deftypefn
12595 @deftypefn {Built-in Function} @var{type} __builtin_speculation_safe_value (@var{type} val, @var{type} failval)
12597 This built-in function can be used to help mitigate against unsafe
12598 speculative execution.  @var{type} may be any integral type or any
12599 pointer type.
12601 @enumerate
12602 @item
12603 If the CPU is not speculatively executing the code, then @var{val}
12604 is returned.
12605 @item
12606 If the CPU is executing speculatively then either:
12607 @itemize
12608 @item
12609 The function may cause execution to pause until it is known that the
12610 code is no-longer being executed speculatively (in which case
12611 @var{val} can be returned, as above); or
12612 @item
12613 The function may use target-dependent speculation tracking state to cause
12614 @var{failval} to be returned when it is known that speculative
12615 execution has incorrectly predicted a conditional branch operation.
12616 @end itemize
12617 @end enumerate
12619 The second argument, @var{failval}, is optional and defaults to zero
12620 if omitted.
12622 GCC defines the preprocessor macro
12623 @code{__HAVE_BUILTIN_SPECULATION_SAFE_VALUE} for targets that have been
12624 updated to support this builtin.
12626 The built-in function can be used where a variable appears to be used in a
12627 safe way, but the CPU, due to speculative execution may temporarily ignore
12628 the bounds checks.  Consider, for example, the following function:
12630 @smallexample
12631 int array[500];
12632 int f (unsigned untrusted_index)
12634   if (untrusted_index < 500)
12635     return array[untrusted_index];
12636   return 0;
12638 @end smallexample
12640 If the function is called repeatedly with @code{untrusted_index} less
12641 than the limit of 500, then a branch predictor will learn that the
12642 block of code that returns a value stored in @code{array} will be
12643 executed.  If the function is subsequently called with an
12644 out-of-range value it will still try to execute that block of code
12645 first until the CPU determines that the prediction was incorrect
12646 (the CPU will unwind any incorrect operations at that point).
12647 However, depending on how the result of the function is used, it might be
12648 possible to leave traces in the cache that can reveal what was stored
12649 at the out-of-bounds location.  The built-in function can be used to
12650 provide some protection against leaking data in this way by changing
12651 the code to:
12653 @smallexample
12654 int array[500];
12655 int f (unsigned untrusted_index)
12657   if (untrusted_index < 500)
12658     return array[__builtin_speculation_safe_value (untrusted_index)];
12659   return 0;
12661 @end smallexample
12663 The built-in function will either cause execution to stall until the
12664 conditional branch has been fully resolved, or it may permit
12665 speculative execution to continue, but using 0 instead of
12666 @code{untrusted_value} if that exceeds the limit.
12668 If accessing any memory location is potentially unsafe when speculative
12669 execution is incorrect, then the code can be rewritten as
12671 @smallexample
12672 int array[500];
12673 int f (unsigned untrusted_index)
12675   if (untrusted_index < 500)
12676     return *__builtin_speculation_safe_value (&array[untrusted_index], NULL);
12677   return 0;
12679 @end smallexample
12681 which will cause a @code{NULL} pointer to be used for the unsafe case.
12683 @end deftypefn
12685 @deftypefn {Built-in Function} int __builtin_types_compatible_p (@var{type1}, @var{type2})
12687 You can use the built-in function @code{__builtin_types_compatible_p} to
12688 determine whether two types are the same.
12690 This built-in function returns 1 if the unqualified versions of the
12691 types @var{type1} and @var{type2} (which are types, not expressions) are
12692 compatible, 0 otherwise.  The result of this built-in function can be
12693 used in integer constant expressions.
12695 This built-in function ignores top level qualifiers (e.g., @code{const},
12696 @code{volatile}).  For example, @code{int} is equivalent to @code{const
12697 int}.
12699 The type @code{int[]} and @code{int[5]} are compatible.  On the other
12700 hand, @code{int} and @code{char *} are not compatible, even if the size
12701 of their types, on the particular architecture are the same.  Also, the
12702 amount of pointer indirection is taken into account when determining
12703 similarity.  Consequently, @code{short *} is not similar to
12704 @code{short **}.  Furthermore, two types that are typedefed are
12705 considered compatible if their underlying types are compatible.
12707 An @code{enum} type is not considered to be compatible with another
12708 @code{enum} type even if both are compatible with the same integer
12709 type; this is what the C standard specifies.
12710 For example, @code{enum @{foo, bar@}} is not similar to
12711 @code{enum @{hot, dog@}}.
12713 You typically use this function in code whose execution varies
12714 depending on the arguments' types.  For example:
12716 @smallexample
12717 #define foo(x)                                                  \
12718   (@{                                                           \
12719     typeof (x) tmp = (x);                                       \
12720     if (__builtin_types_compatible_p (typeof (x), long double)) \
12721       tmp = foo_long_double (tmp);                              \
12722     else if (__builtin_types_compatible_p (typeof (x), double)) \
12723       tmp = foo_double (tmp);                                   \
12724     else if (__builtin_types_compatible_p (typeof (x), float))  \
12725       tmp = foo_float (tmp);                                    \
12726     else                                                        \
12727       abort ();                                                 \
12728     tmp;                                                        \
12729   @})
12730 @end smallexample
12732 @emph{Note:} This construct is only available for C@.
12734 @end deftypefn
12736 @deftypefn {Built-in Function} @var{type} __builtin_call_with_static_chain (@var{call_exp}, @var{pointer_exp})
12738 The @var{call_exp} expression must be a function call, and the
12739 @var{pointer_exp} expression must be a pointer.  The @var{pointer_exp}
12740 is passed to the function call in the target's static chain location.
12741 The result of builtin is the result of the function call.
12743 @emph{Note:} This builtin is only available for C@.
12744 This builtin can be used to call Go closures from C.
12746 @end deftypefn
12748 @deftypefn {Built-in Function} @var{type} __builtin_choose_expr (@var{const_exp}, @var{exp1}, @var{exp2})
12750 You can use the built-in function @code{__builtin_choose_expr} to
12751 evaluate code depending on the value of a constant expression.  This
12752 built-in function returns @var{exp1} if @var{const_exp}, which is an
12753 integer constant expression, is nonzero.  Otherwise it returns @var{exp2}.
12755 This built-in function is analogous to the @samp{? :} operator in C,
12756 except that the expression returned has its type unaltered by promotion
12757 rules.  Also, the built-in function does not evaluate the expression
12758 that is not chosen.  For example, if @var{const_exp} evaluates to @code{true},
12759 @var{exp2} is not evaluated even if it has side effects.
12761 This built-in function can return an lvalue if the chosen argument is an
12762 lvalue.
12764 If @var{exp1} is returned, the return type is the same as @var{exp1}'s
12765 type.  Similarly, if @var{exp2} is returned, its return type is the same
12766 as @var{exp2}.
12768 Example:
12770 @smallexample
12771 #define foo(x)                                                    \
12772   __builtin_choose_expr (                                         \
12773     __builtin_types_compatible_p (typeof (x), double),            \
12774     foo_double (x),                                               \
12775     __builtin_choose_expr (                                       \
12776       __builtin_types_compatible_p (typeof (x), float),           \
12777       foo_float (x),                                              \
12778       /* @r{The void expression results in a compile-time error}  \
12779          @r{when assigning the result to something.}  */          \
12780       (void)0))
12781 @end smallexample
12783 @emph{Note:} This construct is only available for C@.  Furthermore, the
12784 unused expression (@var{exp1} or @var{exp2} depending on the value of
12785 @var{const_exp}) may still generate syntax errors.  This may change in
12786 future revisions.
12788 @end deftypefn
12790 @deftypefn {Built-in Function} @var{type} __builtin_tgmath (@var{functions}, @var{arguments})
12792 The built-in function @code{__builtin_tgmath}, available only for C
12793 and Objective-C, calls a function determined according to the rules of
12794 @code{<tgmath.h>} macros.  It is intended to be used in
12795 implementations of that header, so that expansions of macros from that
12796 header only expand each of their arguments once, to avoid problems
12797 when calls to such macros are nested inside the arguments of other
12798 calls to such macros; in addition, it results in better diagnostics
12799 for invalid calls to @code{<tgmath.h>} macros than implementations
12800 using other GNU C language features.  For example, the @code{pow}
12801 type-generic macro might be defined as:
12803 @smallexample
12804 #define pow(a, b) __builtin_tgmath (powf, pow, powl, \
12805                                     cpowf, cpow, cpowl, a, b)
12806 @end smallexample
12808 The arguments to @code{__builtin_tgmath} are at least two pointers to
12809 functions, followed by the arguments to the type-generic macro (which
12810 will be passed as arguments to the selected function).  All the
12811 pointers to functions must be pointers to prototyped functions, none
12812 of which may have variable arguments, and all of which must have the
12813 same number of parameters; the number of parameters of the first
12814 function determines how many arguments to @code{__builtin_tgmath} are
12815 interpreted as function pointers, and how many as the arguments to the
12816 called function.
12818 The types of the specified functions must all be different, but
12819 related to each other in the same way as a set of functions that may
12820 be selected between by a macro in @code{<tgmath.h>}.  This means that
12821 the functions are parameterized by a floating-point type @var{t},
12822 different for each such function.  The function return types may all
12823 be the same type, or they may be @var{t} for each function, or they
12824 may be the real type corresponding to @var{t} for each function (if
12825 some of the types @var{t} are complex).  Likewise, for each parameter
12826 position, the type of the parameter in that position may always be the
12827 same type, or may be @var{t} for each function (this case must apply
12828 for at least one parameter position), or may be the real type
12829 corresponding to @var{t} for each function.
12831 The standard rules for @code{<tgmath.h>} macros are used to find a
12832 common type @var{u} from the types of the arguments for parameters
12833 whose types vary between the functions; complex integer types (a GNU
12834 extension) are treated like @code{_Complex double} for this purpose
12835 (or @code{_Complex _Float64} if all the function return types are the
12836 same @code{_Float@var{n}} or @code{_Float@var{n}x} type).
12837 If the function return types vary, or are all the same integer type,
12838 the function called is the one for which @var{t} is @var{u}, and it is
12839 an error if there is no such function.  If the function return types
12840 are all the same floating-point type, the type-generic macro is taken
12841 to be one of those from TS 18661 that rounds the result to a narrower
12842 type; if there is a function for which @var{t} is @var{u}, it is
12843 called, and otherwise the first function, if any, for which @var{t}
12844 has at least the range and precision of @var{u} is called, and it is
12845 an error if there is no such function.
12847 @end deftypefn
12849 @deftypefn {Built-in Function} @var{type} __builtin_complex (@var{real}, @var{imag})
12851 The built-in function @code{__builtin_complex} is provided for use in
12852 implementing the ISO C11 macros @code{CMPLXF}, @code{CMPLX} and
12853 @code{CMPLXL}.  @var{real} and @var{imag} must have the same type, a
12854 real binary floating-point type, and the result has the corresponding
12855 complex type with real and imaginary parts @var{real} and @var{imag}.
12856 Unlike @samp{@var{real} + I * @var{imag}}, this works even when
12857 infinities, NaNs and negative zeros are involved.
12859 @end deftypefn
12861 @deftypefn {Built-in Function} int __builtin_constant_p (@var{exp})
12862 You can use the built-in function @code{__builtin_constant_p} to
12863 determine if a value is known to be constant at compile time and hence
12864 that GCC can perform constant-folding on expressions involving that
12865 value.  The argument of the function is the value to test.  The function
12866 returns the integer 1 if the argument is known to be a compile-time
12867 constant and 0 if it is not known to be a compile-time constant.  A
12868 return of 0 does not indicate that the value is @emph{not} a constant,
12869 but merely that GCC cannot prove it is a constant with the specified
12870 value of the @option{-O} option.
12872 You typically use this function in an embedded application where
12873 memory is a critical resource.  If you have some complex calculation,
12874 you may want it to be folded if it involves constants, but need to call
12875 a function if it does not.  For example:
12877 @smallexample
12878 #define Scale_Value(X)      \
12879   (__builtin_constant_p (X) \
12880   ? ((X) * SCALE + OFFSET) : Scale (X))
12881 @end smallexample
12883 You may use this built-in function in either a macro or an inline
12884 function.  However, if you use it in an inlined function and pass an
12885 argument of the function as the argument to the built-in, GCC 
12886 never returns 1 when you call the inline function with a string constant
12887 or compound literal (@pxref{Compound Literals}) and does not return 1
12888 when you pass a constant numeric value to the inline function unless you
12889 specify the @option{-O} option.
12891 You may also use @code{__builtin_constant_p} in initializers for static
12892 data.  For instance, you can write
12894 @smallexample
12895 static const int table[] = @{
12896    __builtin_constant_p (EXPRESSION) ? (EXPRESSION) : -1,
12897    /* @r{@dots{}} */
12899 @end smallexample
12901 @noindent
12902 This is an acceptable initializer even if @var{EXPRESSION} is not a
12903 constant expression, including the case where
12904 @code{__builtin_constant_p} returns 1 because @var{EXPRESSION} can be
12905 folded to a constant but @var{EXPRESSION} contains operands that are
12906 not otherwise permitted in a static initializer (for example,
12907 @code{0 && foo ()}).  GCC must be more conservative about evaluating the
12908 built-in in this case, because it has no opportunity to perform
12909 optimization.
12910 @end deftypefn
12912 @deftypefn {Built-in Function} bool __builtin_is_constant_evaluated (void)
12913 The @code{__builtin_is_constant_evaluated} function is available only
12914 in C++.  The built-in is intended to be used by implementations of
12915 the @code{std::is_constant_evaluated} C++ function.  Programs should make
12916 use of the latter function rather than invoking the built-in directly.
12918 The main use case of the built-in is to determine whether a @code{constexpr}
12919 function is being called in a @code{constexpr} context.  A call to
12920 the function evaluates to a core constant expression with the value
12921 @code{true} if and only if it occurs within the evaluation of an expression
12922 or conversion that is manifestly constant-evaluated as defined in the C++
12923 standard.  Manifestly constant-evaluated contexts include constant-expressions,
12924 the conditions of @code{constexpr if} statements, constraint-expressions, and
12925 initializers of variables usable in constant expressions.   For more details
12926 refer to the latest revision of the C++ standard.
12927 @end deftypefn
12929 @deftypefn {Built-in Function} long __builtin_expect (long @var{exp}, long @var{c})
12930 @opindex fprofile-arcs
12931 You may use @code{__builtin_expect} to provide the compiler with
12932 branch prediction information.  In general, you should prefer to
12933 use actual profile feedback for this (@option{-fprofile-arcs}), as
12934 programmers are notoriously bad at predicting how their programs
12935 actually perform.  However, there are applications in which this
12936 data is hard to collect.
12938 The return value is the value of @var{exp}, which should be an integral
12939 expression.  The semantics of the built-in are that it is expected that
12940 @var{exp} == @var{c}.  For example:
12942 @smallexample
12943 if (__builtin_expect (x, 0))
12944   foo ();
12945 @end smallexample
12947 @noindent
12948 indicates that we do not expect to call @code{foo}, since
12949 we expect @code{x} to be zero.  Since you are limited to integral
12950 expressions for @var{exp}, you should use constructions such as
12952 @smallexample
12953 if (__builtin_expect (ptr != NULL, 1))
12954   foo (*ptr);
12955 @end smallexample
12957 @noindent
12958 when testing pointer or floating-point values.
12960 For the purposes of branch prediction optimizations, the probability that
12961 a @code{__builtin_expect} expression is @code{true} is controlled by GCC's
12962 @code{builtin-expect-probability} parameter, which defaults to 90%.  
12963 You can also use @code{__builtin_expect_with_probability} to explicitly 
12964 assign a probability value to individual expressions.
12965 @end deftypefn
12967 @deftypefn {Built-in Function} long __builtin_expect_with_probability
12968 (long @var{exp}, long @var{c}, double @var{probability})
12970 This function has the same semantics as @code{__builtin_expect},
12971 but the caller provides the expected probability that @var{exp} == @var{c}.
12972 The last argument, @var{probability}, is a floating-point value in the
12973 range 0.0 to 1.0, inclusive.  The @var{probability} argument must be
12974 constant floating-point expression.
12975 @end deftypefn
12977 @deftypefn {Built-in Function} void __builtin_trap (void)
12978 This function causes the program to exit abnormally.  GCC implements
12979 this function by using a target-dependent mechanism (such as
12980 intentionally executing an illegal instruction) or by calling
12981 @code{abort}.  The mechanism used may vary from release to release so
12982 you should not rely on any particular implementation.
12983 @end deftypefn
12985 @deftypefn {Built-in Function} void __builtin_unreachable (void)
12986 If control flow reaches the point of the @code{__builtin_unreachable},
12987 the program is undefined.  It is useful in situations where the
12988 compiler cannot deduce the unreachability of the code.
12990 One such case is immediately following an @code{asm} statement that
12991 either never terminates, or one that transfers control elsewhere
12992 and never returns.  In this example, without the
12993 @code{__builtin_unreachable}, GCC issues a warning that control
12994 reaches the end of a non-void function.  It also generates code
12995 to return after the @code{asm}.
12997 @smallexample
12998 int f (int c, int v)
13000   if (c)
13001     @{
13002       return v;
13003     @}
13004   else
13005     @{
13006       asm("jmp error_handler");
13007       __builtin_unreachable ();
13008     @}
13010 @end smallexample
13012 @noindent
13013 Because the @code{asm} statement unconditionally transfers control out
13014 of the function, control never reaches the end of the function
13015 body.  The @code{__builtin_unreachable} is in fact unreachable and
13016 communicates this fact to the compiler.
13018 Another use for @code{__builtin_unreachable} is following a call a
13019 function that never returns but that is not declared
13020 @code{__attribute__((noreturn))}, as in this example:
13022 @smallexample
13023 void function_that_never_returns (void);
13025 int g (int c)
13027   if (c)
13028     @{
13029       return 1;
13030     @}
13031   else
13032     @{
13033       function_that_never_returns ();
13034       __builtin_unreachable ();
13035     @}
13037 @end smallexample
13039 @end deftypefn
13041 @deftypefn {Built-in Function} {void *} __builtin_assume_aligned (const void *@var{exp}, size_t @var{align}, ...)
13042 This function returns its first argument, and allows the compiler
13043 to assume that the returned pointer is at least @var{align} bytes
13044 aligned.  This built-in can have either two or three arguments,
13045 if it has three, the third argument should have integer type, and
13046 if it is nonzero means misalignment offset.  For example:
13048 @smallexample
13049 void *x = __builtin_assume_aligned (arg, 16);
13050 @end smallexample
13052 @noindent
13053 means that the compiler can assume @code{x}, set to @code{arg}, is at least
13054 16-byte aligned, while:
13056 @smallexample
13057 void *x = __builtin_assume_aligned (arg, 32, 8);
13058 @end smallexample
13060 @noindent
13061 means that the compiler can assume for @code{x}, set to @code{arg}, that
13062 @code{(char *) x - 8} is 32-byte aligned.
13063 @end deftypefn
13065 @deftypefn {Built-in Function} int __builtin_LINE ()
13066 This function is the equivalent of the preprocessor @code{__LINE__}
13067 macro and returns a constant integer expression that evaluates to
13068 the line number of the invocation of the built-in.  When used as a C++
13069 default argument for a function @var{F}, it returns the line number
13070 of the call to @var{F}.
13071 @end deftypefn
13073 @deftypefn {Built-in Function} {const char *} __builtin_FUNCTION ()
13074 This function is the equivalent of the @code{__FUNCTION__} symbol
13075 and returns an address constant pointing to the name of the function
13076 from which the built-in was invoked, or the empty string if
13077 the invocation is not at function scope.  When used as a C++ default
13078 argument for a function @var{F}, it returns the name of @var{F}'s
13079 caller or the empty string if the call was not made at function
13080 scope.
13081 @end deftypefn
13083 @deftypefn {Built-in Function} {const char *} __builtin_FILE ()
13084 This function is the equivalent of the preprocessor @code{__FILE__}
13085 macro and returns an address constant pointing to the file name
13086 containing the invocation of the built-in, or the empty string if
13087 the invocation is not at function scope.  When used as a C++ default
13088 argument for a function @var{F}, it returns the file name of the call
13089 to @var{F} or the empty string if the call was not made at function
13090 scope.
13092 For example, in the following, each call to function @code{foo} will
13093 print a line similar to @code{"file.c:123: foo: message"} with the name
13094 of the file and the line number of the @code{printf} call, the name of
13095 the function @code{foo}, followed by the word @code{message}.
13097 @smallexample
13098 const char*
13099 function (const char *func = __builtin_FUNCTION ())
13101   return func;
13104 void foo (void)
13106   printf ("%s:%i: %s: message\n", file (), line (), function ());
13108 @end smallexample
13110 @end deftypefn
13112 @deftypefn {Built-in Function} void __builtin___clear_cache (void *@var{begin}, void *@var{end})
13113 This function is used to flush the processor's instruction cache for
13114 the region of memory between @var{begin} inclusive and @var{end}
13115 exclusive.  Some targets require that the instruction cache be
13116 flushed, after modifying memory containing code, in order to obtain
13117 deterministic behavior.
13119 If the target does not require instruction cache flushes,
13120 @code{__builtin___clear_cache} has no effect.  Otherwise either
13121 instructions are emitted in-line to clear the instruction cache or a
13122 call to the @code{__clear_cache} function in libgcc is made.
13123 @end deftypefn
13125 @deftypefn {Built-in Function} void __builtin_prefetch (const void *@var{addr}, ...)
13126 This function is used to minimize cache-miss latency by moving data into
13127 a cache before it is accessed.
13128 You can insert calls to @code{__builtin_prefetch} into code for which
13129 you know addresses of data in memory that is likely to be accessed soon.
13130 If the target supports them, data prefetch instructions are generated.
13131 If the prefetch is done early enough before the access then the data will
13132 be in the cache by the time it is accessed.
13134 The value of @var{addr} is the address of the memory to prefetch.
13135 There are two optional arguments, @var{rw} and @var{locality}.
13136 The value of @var{rw} is a compile-time constant one or zero; one
13137 means that the prefetch is preparing for a write to the memory address
13138 and zero, the default, means that the prefetch is preparing for a read.
13139 The value @var{locality} must be a compile-time constant integer between
13140 zero and three.  A value of zero means that the data has no temporal
13141 locality, so it need not be left in the cache after the access.  A value
13142 of three means that the data has a high degree of temporal locality and
13143 should be left in all levels of cache possible.  Values of one and two
13144 mean, respectively, a low or moderate degree of temporal locality.  The
13145 default is three.
13147 @smallexample
13148 for (i = 0; i < n; i++)
13149   @{
13150     a[i] = a[i] + b[i];
13151     __builtin_prefetch (&a[i+j], 1, 1);
13152     __builtin_prefetch (&b[i+j], 0, 1);
13153     /* @r{@dots{}} */
13154   @}
13155 @end smallexample
13157 Data prefetch does not generate faults if @var{addr} is invalid, but
13158 the address expression itself must be valid.  For example, a prefetch
13159 of @code{p->next} does not fault if @code{p->next} is not a valid
13160 address, but evaluation faults if @code{p} is not a valid address.
13162 If the target does not support data prefetch, the address expression
13163 is evaluated if it includes side effects but no other code is generated
13164 and GCC does not issue a warning.
13165 @end deftypefn
13167 @deftypefn {Built-in Function}{size_t} __builtin_object_size (const void * @var{ptr}, int @var{type})
13168 Returns the size of an object pointed to by @var{ptr}.  @xref{Object Size
13169 Checking}, for a detailed description of the function.
13170 @end deftypefn
13172 @deftypefn {Built-in Function} double __builtin_huge_val (void)
13173 Returns a positive infinity, if supported by the floating-point format,
13174 else @code{DBL_MAX}.  This function is suitable for implementing the
13175 ISO C macro @code{HUGE_VAL}.
13176 @end deftypefn
13178 @deftypefn {Built-in Function} float __builtin_huge_valf (void)
13179 Similar to @code{__builtin_huge_val}, except the return type is @code{float}.
13180 @end deftypefn
13182 @deftypefn {Built-in Function} {long double} __builtin_huge_vall (void)
13183 Similar to @code{__builtin_huge_val}, except the return
13184 type is @code{long double}.
13185 @end deftypefn
13187 @deftypefn {Built-in Function} _Float@var{n} __builtin_huge_valf@var{n} (void)
13188 Similar to @code{__builtin_huge_val}, except the return type is
13189 @code{_Float@var{n}}.
13190 @end deftypefn
13192 @deftypefn {Built-in Function} _Float@var{n}x __builtin_huge_valf@var{n}x (void)
13193 Similar to @code{__builtin_huge_val}, except the return type is
13194 @code{_Float@var{n}x}.
13195 @end deftypefn
13197 @deftypefn {Built-in Function} int __builtin_fpclassify (int, int, int, int, int, ...)
13198 This built-in implements the C99 fpclassify functionality.  The first
13199 five int arguments should be the target library's notion of the
13200 possible FP classes and are used for return values.  They must be
13201 constant values and they must appear in this order: @code{FP_NAN},
13202 @code{FP_INFINITE}, @code{FP_NORMAL}, @code{FP_SUBNORMAL} and
13203 @code{FP_ZERO}.  The ellipsis is for exactly one floating-point value
13204 to classify.  GCC treats the last argument as type-generic, which
13205 means it does not do default promotion from float to double.
13206 @end deftypefn
13208 @deftypefn {Built-in Function} double __builtin_inf (void)
13209 Similar to @code{__builtin_huge_val}, except a warning is generated
13210 if the target floating-point format does not support infinities.
13211 @end deftypefn
13213 @deftypefn {Built-in Function} _Decimal32 __builtin_infd32 (void)
13214 Similar to @code{__builtin_inf}, except the return type is @code{_Decimal32}.
13215 @end deftypefn
13217 @deftypefn {Built-in Function} _Decimal64 __builtin_infd64 (void)
13218 Similar to @code{__builtin_inf}, except the return type is @code{_Decimal64}.
13219 @end deftypefn
13221 @deftypefn {Built-in Function} _Decimal128 __builtin_infd128 (void)
13222 Similar to @code{__builtin_inf}, except the return type is @code{_Decimal128}.
13223 @end deftypefn
13225 @deftypefn {Built-in Function} float __builtin_inff (void)
13226 Similar to @code{__builtin_inf}, except the return type is @code{float}.
13227 This function is suitable for implementing the ISO C99 macro @code{INFINITY}.
13228 @end deftypefn
13230 @deftypefn {Built-in Function} {long double} __builtin_infl (void)
13231 Similar to @code{__builtin_inf}, except the return
13232 type is @code{long double}.
13233 @end deftypefn
13235 @deftypefn {Built-in Function} _Float@var{n} __builtin_inff@var{n} (void)
13236 Similar to @code{__builtin_inf}, except the return
13237 type is @code{_Float@var{n}}.
13238 @end deftypefn
13240 @deftypefn {Built-in Function} _Float@var{n} __builtin_inff@var{n}x (void)
13241 Similar to @code{__builtin_inf}, except the return
13242 type is @code{_Float@var{n}x}.
13243 @end deftypefn
13245 @deftypefn {Built-in Function} int __builtin_isinf_sign (...)
13246 Similar to @code{isinf}, except the return value is -1 for
13247 an argument of @code{-Inf} and 1 for an argument of @code{+Inf}.
13248 Note while the parameter list is an
13249 ellipsis, this function only accepts exactly one floating-point
13250 argument.  GCC treats this parameter as type-generic, which means it
13251 does not do default promotion from float to double.
13252 @end deftypefn
13254 @deftypefn {Built-in Function} double __builtin_nan (const char *str)
13255 This is an implementation of the ISO C99 function @code{nan}.
13257 Since ISO C99 defines this function in terms of @code{strtod}, which we
13258 do not implement, a description of the parsing is in order.  The string
13259 is parsed as by @code{strtol}; that is, the base is recognized by
13260 leading @samp{0} or @samp{0x} prefixes.  The number parsed is placed
13261 in the significand such that the least significant bit of the number
13262 is at the least significant bit of the significand.  The number is
13263 truncated to fit the significand field provided.  The significand is
13264 forced to be a quiet NaN@.
13266 This function, if given a string literal all of which would have been
13267 consumed by @code{strtol}, is evaluated early enough that it is considered a
13268 compile-time constant.
13269 @end deftypefn
13271 @deftypefn {Built-in Function} _Decimal32 __builtin_nand32 (const char *str)
13272 Similar to @code{__builtin_nan}, except the return type is @code{_Decimal32}.
13273 @end deftypefn
13275 @deftypefn {Built-in Function} _Decimal64 __builtin_nand64 (const char *str)
13276 Similar to @code{__builtin_nan}, except the return type is @code{_Decimal64}.
13277 @end deftypefn
13279 @deftypefn {Built-in Function} _Decimal128 __builtin_nand128 (const char *str)
13280 Similar to @code{__builtin_nan}, except the return type is @code{_Decimal128}.
13281 @end deftypefn
13283 @deftypefn {Built-in Function} float __builtin_nanf (const char *str)
13284 Similar to @code{__builtin_nan}, except the return type is @code{float}.
13285 @end deftypefn
13287 @deftypefn {Built-in Function} {long double} __builtin_nanl (const char *str)
13288 Similar to @code{__builtin_nan}, except the return type is @code{long double}.
13289 @end deftypefn
13291 @deftypefn {Built-in Function} _Float@var{n} __builtin_nanf@var{n} (const char *str)
13292 Similar to @code{__builtin_nan}, except the return type is
13293 @code{_Float@var{n}}.
13294 @end deftypefn
13296 @deftypefn {Built-in Function} _Float@var{n}x __builtin_nanf@var{n}x (const char *str)
13297 Similar to @code{__builtin_nan}, except the return type is
13298 @code{_Float@var{n}x}.
13299 @end deftypefn
13301 @deftypefn {Built-in Function} double __builtin_nans (const char *str)
13302 Similar to @code{__builtin_nan}, except the significand is forced
13303 to be a signaling NaN@.  The @code{nans} function is proposed by
13304 @uref{http://www.open-std.org/jtc1/sc22/wg14/www/docs/n965.htm,,WG14 N965}.
13305 @end deftypefn
13307 @deftypefn {Built-in Function} float __builtin_nansf (const char *str)
13308 Similar to @code{__builtin_nans}, except the return type is @code{float}.
13309 @end deftypefn
13311 @deftypefn {Built-in Function} {long double} __builtin_nansl (const char *str)
13312 Similar to @code{__builtin_nans}, except the return type is @code{long double}.
13313 @end deftypefn
13315 @deftypefn {Built-in Function} _Float@var{n} __builtin_nansf@var{n} (const char *str)
13316 Similar to @code{__builtin_nans}, except the return type is
13317 @code{_Float@var{n}}.
13318 @end deftypefn
13320 @deftypefn {Built-in Function} _Float@var{n}x __builtin_nansf@var{n}x (const char *str)
13321 Similar to @code{__builtin_nans}, except the return type is
13322 @code{_Float@var{n}x}.
13323 @end deftypefn
13325 @deftypefn {Built-in Function} int __builtin_ffs (int x)
13326 Returns one plus the index of the least significant 1-bit of @var{x}, or
13327 if @var{x} is zero, returns zero.
13328 @end deftypefn
13330 @deftypefn {Built-in Function} int __builtin_clz (unsigned int x)
13331 Returns the number of leading 0-bits in @var{x}, starting at the most
13332 significant bit position.  If @var{x} is 0, the result is undefined.
13333 @end deftypefn
13335 @deftypefn {Built-in Function} int __builtin_ctz (unsigned int x)
13336 Returns the number of trailing 0-bits in @var{x}, starting at the least
13337 significant bit position.  If @var{x} is 0, the result is undefined.
13338 @end deftypefn
13340 @deftypefn {Built-in Function} int __builtin_clrsb (int x)
13341 Returns the number of leading redundant sign bits in @var{x}, i.e.@: the
13342 number of bits following the most significant bit that are identical
13343 to it.  There are no special cases for 0 or other values. 
13344 @end deftypefn
13346 @deftypefn {Built-in Function} int __builtin_popcount (unsigned int x)
13347 Returns the number of 1-bits in @var{x}.
13348 @end deftypefn
13350 @deftypefn {Built-in Function} int __builtin_parity (unsigned int x)
13351 Returns the parity of @var{x}, i.e.@: the number of 1-bits in @var{x}
13352 modulo 2.
13353 @end deftypefn
13355 @deftypefn {Built-in Function} int __builtin_ffsl (long)
13356 Similar to @code{__builtin_ffs}, except the argument type is
13357 @code{long}.
13358 @end deftypefn
13360 @deftypefn {Built-in Function} int __builtin_clzl (unsigned long)
13361 Similar to @code{__builtin_clz}, except the argument type is
13362 @code{unsigned long}.
13363 @end deftypefn
13365 @deftypefn {Built-in Function} int __builtin_ctzl (unsigned long)
13366 Similar to @code{__builtin_ctz}, except the argument type is
13367 @code{unsigned long}.
13368 @end deftypefn
13370 @deftypefn {Built-in Function} int __builtin_clrsbl (long)
13371 Similar to @code{__builtin_clrsb}, except the argument type is
13372 @code{long}.
13373 @end deftypefn
13375 @deftypefn {Built-in Function} int __builtin_popcountl (unsigned long)
13376 Similar to @code{__builtin_popcount}, except the argument type is
13377 @code{unsigned long}.
13378 @end deftypefn
13380 @deftypefn {Built-in Function} int __builtin_parityl (unsigned long)
13381 Similar to @code{__builtin_parity}, except the argument type is
13382 @code{unsigned long}.
13383 @end deftypefn
13385 @deftypefn {Built-in Function} int __builtin_ffsll (long long)
13386 Similar to @code{__builtin_ffs}, except the argument type is
13387 @code{long long}.
13388 @end deftypefn
13390 @deftypefn {Built-in Function} int __builtin_clzll (unsigned long long)
13391 Similar to @code{__builtin_clz}, except the argument type is
13392 @code{unsigned long long}.
13393 @end deftypefn
13395 @deftypefn {Built-in Function} int __builtin_ctzll (unsigned long long)
13396 Similar to @code{__builtin_ctz}, except the argument type is
13397 @code{unsigned long long}.
13398 @end deftypefn
13400 @deftypefn {Built-in Function} int __builtin_clrsbll (long long)
13401 Similar to @code{__builtin_clrsb}, except the argument type is
13402 @code{long long}.
13403 @end deftypefn
13405 @deftypefn {Built-in Function} int __builtin_popcountll (unsigned long long)
13406 Similar to @code{__builtin_popcount}, except the argument type is
13407 @code{unsigned long long}.
13408 @end deftypefn
13410 @deftypefn {Built-in Function} int __builtin_parityll (unsigned long long)
13411 Similar to @code{__builtin_parity}, except the argument type is
13412 @code{unsigned long long}.
13413 @end deftypefn
13415 @deftypefn {Built-in Function} double __builtin_powi (double, int)
13416 Returns the first argument raised to the power of the second.  Unlike the
13417 @code{pow} function no guarantees about precision and rounding are made.
13418 @end deftypefn
13420 @deftypefn {Built-in Function} float __builtin_powif (float, int)
13421 Similar to @code{__builtin_powi}, except the argument and return types
13422 are @code{float}.
13423 @end deftypefn
13425 @deftypefn {Built-in Function} {long double} __builtin_powil (long double, int)
13426 Similar to @code{__builtin_powi}, except the argument and return types
13427 are @code{long double}.
13428 @end deftypefn
13430 @deftypefn {Built-in Function} uint16_t __builtin_bswap16 (uint16_t x)
13431 Returns @var{x} with the order of the bytes reversed; for example,
13432 @code{0xaabb} becomes @code{0xbbaa}.  Byte here always means
13433 exactly 8 bits.
13434 @end deftypefn
13436 @deftypefn {Built-in Function} uint32_t __builtin_bswap32 (uint32_t x)
13437 Similar to @code{__builtin_bswap16}, except the argument and return types
13438 are 32 bit.
13439 @end deftypefn
13441 @deftypefn {Built-in Function} uint64_t __builtin_bswap64 (uint64_t x)
13442 Similar to @code{__builtin_bswap32}, except the argument and return types
13443 are 64 bit.
13444 @end deftypefn
13446 @deftypefn {Built-in Function} Pmode __builtin_extend_pointer (void * x)
13447 On targets where the user visible pointer size is smaller than the size
13448 of an actual hardware address this function returns the extended user
13449 pointer.  Targets where this is true included ILP32 mode on x86_64 or
13450 Aarch64.  This function is mainly useful when writing inline assembly
13451 code.
13452 @end deftypefn
13454 @deftypefn {Built-in Function} int __builtin_goacc_parlevel_id (int x)
13455 Returns the openacc gang, worker or vector id depending on whether @var{x} is
13456 0, 1 or 2.
13457 @end deftypefn
13459 @deftypefn {Built-in Function} int __builtin_goacc_parlevel_size (int x)
13460 Returns the openacc gang, worker or vector size depending on whether @var{x} is
13461 0, 1 or 2.
13462 @end deftypefn
13464 @node Target Builtins
13465 @section Built-in Functions Specific to Particular Target Machines
13467 On some target machines, GCC supports many built-in functions specific
13468 to those machines.  Generally these generate calls to specific machine
13469 instructions, but allow the compiler to schedule those calls.
13471 @menu
13472 * AArch64 Built-in Functions::
13473 * Alpha Built-in Functions::
13474 * Altera Nios II Built-in Functions::
13475 * ARC Built-in Functions::
13476 * ARC SIMD Built-in Functions::
13477 * ARM iWMMXt Built-in Functions::
13478 * ARM C Language Extensions (ACLE)::
13479 * ARM Floating Point Status and Control Intrinsics::
13480 * ARM ARMv8-M Security Extensions::
13481 * AVR Built-in Functions::
13482 * Blackfin Built-in Functions::
13483 * FR-V Built-in Functions::
13484 * MIPS DSP Built-in Functions::
13485 * MIPS Paired-Single Support::
13486 * MIPS Loongson Built-in Functions::
13487 * MIPS SIMD Architecture (MSA) Support::
13488 * Other MIPS Built-in Functions::
13489 * MSP430 Built-in Functions::
13490 * NDS32 Built-in Functions::
13491 * picoChip Built-in Functions::
13492 * Basic PowerPC Built-in Functions::
13493 * PowerPC AltiVec/VSX Built-in Functions::
13494 * PowerPC Hardware Transactional Memory Built-in Functions::
13495 * PowerPC Atomic Memory Operation Functions::
13496 * RX Built-in Functions::
13497 * S/390 System z Built-in Functions::
13498 * SH Built-in Functions::
13499 * SPARC VIS Built-in Functions::
13500 * SPU Built-in Functions::
13501 * TI C6X Built-in Functions::
13502 * TILE-Gx Built-in Functions::
13503 * TILEPro Built-in Functions::
13504 * x86 Built-in Functions::
13505 * x86 transactional memory intrinsics::
13506 * x86 control-flow protection intrinsics::
13507 @end menu
13509 @node AArch64 Built-in Functions
13510 @subsection AArch64 Built-in Functions
13512 These built-in functions are available for the AArch64 family of
13513 processors.
13514 @smallexample
13515 unsigned int __builtin_aarch64_get_fpcr ()
13516 void __builtin_aarch64_set_fpcr (unsigned int)
13517 unsigned int __builtin_aarch64_get_fpsr ()
13518 void __builtin_aarch64_set_fpsr (unsigned int)
13519 @end smallexample
13521 @node Alpha Built-in Functions
13522 @subsection Alpha Built-in Functions
13524 These built-in functions are available for the Alpha family of
13525 processors, depending on the command-line switches used.
13527 The following built-in functions are always available.  They
13528 all generate the machine instruction that is part of the name.
13530 @smallexample
13531 long __builtin_alpha_implver (void)
13532 long __builtin_alpha_rpcc (void)
13533 long __builtin_alpha_amask (long)
13534 long __builtin_alpha_cmpbge (long, long)
13535 long __builtin_alpha_extbl (long, long)
13536 long __builtin_alpha_extwl (long, long)
13537 long __builtin_alpha_extll (long, long)
13538 long __builtin_alpha_extql (long, long)
13539 long __builtin_alpha_extwh (long, long)
13540 long __builtin_alpha_extlh (long, long)
13541 long __builtin_alpha_extqh (long, long)
13542 long __builtin_alpha_insbl (long, long)
13543 long __builtin_alpha_inswl (long, long)
13544 long __builtin_alpha_insll (long, long)
13545 long __builtin_alpha_insql (long, long)
13546 long __builtin_alpha_inswh (long, long)
13547 long __builtin_alpha_inslh (long, long)
13548 long __builtin_alpha_insqh (long, long)
13549 long __builtin_alpha_mskbl (long, long)
13550 long __builtin_alpha_mskwl (long, long)
13551 long __builtin_alpha_mskll (long, long)
13552 long __builtin_alpha_mskql (long, long)
13553 long __builtin_alpha_mskwh (long, long)
13554 long __builtin_alpha_msklh (long, long)
13555 long __builtin_alpha_mskqh (long, long)
13556 long __builtin_alpha_umulh (long, long)
13557 long __builtin_alpha_zap (long, long)
13558 long __builtin_alpha_zapnot (long, long)
13559 @end smallexample
13561 The following built-in functions are always with @option{-mmax}
13562 or @option{-mcpu=@var{cpu}} where @var{cpu} is @code{pca56} or
13563 later.  They all generate the machine instruction that is part
13564 of the name.
13566 @smallexample
13567 long __builtin_alpha_pklb (long)
13568 long __builtin_alpha_pkwb (long)
13569 long __builtin_alpha_unpkbl (long)
13570 long __builtin_alpha_unpkbw (long)
13571 long __builtin_alpha_minub8 (long, long)
13572 long __builtin_alpha_minsb8 (long, long)
13573 long __builtin_alpha_minuw4 (long, long)
13574 long __builtin_alpha_minsw4 (long, long)
13575 long __builtin_alpha_maxub8 (long, long)
13576 long __builtin_alpha_maxsb8 (long, long)
13577 long __builtin_alpha_maxuw4 (long, long)
13578 long __builtin_alpha_maxsw4 (long, long)
13579 long __builtin_alpha_perr (long, long)
13580 @end smallexample
13582 The following built-in functions are always with @option{-mcix}
13583 or @option{-mcpu=@var{cpu}} where @var{cpu} is @code{ev67} or
13584 later.  They all generate the machine instruction that is part
13585 of the name.
13587 @smallexample
13588 long __builtin_alpha_cttz (long)
13589 long __builtin_alpha_ctlz (long)
13590 long __builtin_alpha_ctpop (long)
13591 @end smallexample
13593 The following built-in functions are available on systems that use the OSF/1
13594 PALcode.  Normally they invoke the @code{rduniq} and @code{wruniq}
13595 PAL calls, but when invoked with @option{-mtls-kernel}, they invoke
13596 @code{rdval} and @code{wrval}.
13598 @smallexample
13599 void *__builtin_thread_pointer (void)
13600 void __builtin_set_thread_pointer (void *)
13601 @end smallexample
13603 @node Altera Nios II Built-in Functions
13604 @subsection Altera Nios II Built-in Functions
13606 These built-in functions are available for the Altera Nios II
13607 family of processors.
13609 The following built-in functions are always available.  They
13610 all generate the machine instruction that is part of the name.
13612 @example
13613 int __builtin_ldbio (volatile const void *)
13614 int __builtin_ldbuio (volatile const void *)
13615 int __builtin_ldhio (volatile const void *)
13616 int __builtin_ldhuio (volatile const void *)
13617 int __builtin_ldwio (volatile const void *)
13618 void __builtin_stbio (volatile void *, int)
13619 void __builtin_sthio (volatile void *, int)
13620 void __builtin_stwio (volatile void *, int)
13621 void __builtin_sync (void)
13622 int __builtin_rdctl (int) 
13623 int __builtin_rdprs (int, int)
13624 void __builtin_wrctl (int, int)
13625 void __builtin_flushd (volatile void *)
13626 void __builtin_flushda (volatile void *)
13627 int __builtin_wrpie (int);
13628 void __builtin_eni (int);
13629 int __builtin_ldex (volatile const void *)
13630 int __builtin_stex (volatile void *, int)
13631 int __builtin_ldsex (volatile const void *)
13632 int __builtin_stsex (volatile void *, int)
13633 @end example
13635 The following built-in functions are always available.  They
13636 all generate a Nios II Custom Instruction. The name of the
13637 function represents the types that the function takes and
13638 returns. The letter before the @code{n} is the return type
13639 or void if absent. The @code{n} represents the first parameter
13640 to all the custom instructions, the custom instruction number.
13641 The two letters after the @code{n} represent the up to two
13642 parameters to the function.
13644 The letters represent the following data types:
13645 @table @code
13646 @item <no letter>
13647 @code{void} for return type and no parameter for parameter types.
13649 @item i
13650 @code{int} for return type and parameter type
13652 @item f
13653 @code{float} for return type and parameter type
13655 @item p
13656 @code{void *} for return type and parameter type
13658 @end table
13660 And the function names are:
13661 @example
13662 void __builtin_custom_n (void)
13663 void __builtin_custom_ni (int)
13664 void __builtin_custom_nf (float)
13665 void __builtin_custom_np (void *)
13666 void __builtin_custom_nii (int, int)
13667 void __builtin_custom_nif (int, float)
13668 void __builtin_custom_nip (int, void *)
13669 void __builtin_custom_nfi (float, int)
13670 void __builtin_custom_nff (float, float)
13671 void __builtin_custom_nfp (float, void *)
13672 void __builtin_custom_npi (void *, int)
13673 void __builtin_custom_npf (void *, float)
13674 void __builtin_custom_npp (void *, void *)
13675 int __builtin_custom_in (void)
13676 int __builtin_custom_ini (int)
13677 int __builtin_custom_inf (float)
13678 int __builtin_custom_inp (void *)
13679 int __builtin_custom_inii (int, int)
13680 int __builtin_custom_inif (int, float)
13681 int __builtin_custom_inip (int, void *)
13682 int __builtin_custom_infi (float, int)
13683 int __builtin_custom_inff (float, float)
13684 int __builtin_custom_infp (float, void *)
13685 int __builtin_custom_inpi (void *, int)
13686 int __builtin_custom_inpf (void *, float)
13687 int __builtin_custom_inpp (void *, void *)
13688 float __builtin_custom_fn (void)
13689 float __builtin_custom_fni (int)
13690 float __builtin_custom_fnf (float)
13691 float __builtin_custom_fnp (void *)
13692 float __builtin_custom_fnii (int, int)
13693 float __builtin_custom_fnif (int, float)
13694 float __builtin_custom_fnip (int, void *)
13695 float __builtin_custom_fnfi (float, int)
13696 float __builtin_custom_fnff (float, float)
13697 float __builtin_custom_fnfp (float, void *)
13698 float __builtin_custom_fnpi (void *, int)
13699 float __builtin_custom_fnpf (void *, float)
13700 float __builtin_custom_fnpp (void *, void *)
13701 void * __builtin_custom_pn (void)
13702 void * __builtin_custom_pni (int)
13703 void * __builtin_custom_pnf (float)
13704 void * __builtin_custom_pnp (void *)
13705 void * __builtin_custom_pnii (int, int)
13706 void * __builtin_custom_pnif (int, float)
13707 void * __builtin_custom_pnip (int, void *)
13708 void * __builtin_custom_pnfi (float, int)
13709 void * __builtin_custom_pnff (float, float)
13710 void * __builtin_custom_pnfp (float, void *)
13711 void * __builtin_custom_pnpi (void *, int)
13712 void * __builtin_custom_pnpf (void *, float)
13713 void * __builtin_custom_pnpp (void *, void *)
13714 @end example
13716 @node ARC Built-in Functions
13717 @subsection ARC Built-in Functions
13719 The following built-in functions are provided for ARC targets.  The
13720 built-ins generate the corresponding assembly instructions.  In the
13721 examples given below, the generated code often requires an operand or
13722 result to be in a register.  Where necessary further code will be
13723 generated to ensure this is true, but for brevity this is not
13724 described in each case.
13726 @emph{Note:} Using a built-in to generate an instruction not supported
13727 by a target may cause problems. At present the compiler is not
13728 guaranteed to detect such misuse, and as a result an internal compiler
13729 error may be generated.
13731 @deftypefn {Built-in Function} int __builtin_arc_aligned (void *@var{val}, int @var{alignval})
13732 Return 1 if @var{val} is known to have the byte alignment given
13733 by @var{alignval}, otherwise return 0.
13734 Note that this is different from
13735 @smallexample
13736 __alignof__(*(char *)@var{val}) >= alignval
13737 @end smallexample
13738 because __alignof__ sees only the type of the dereference, whereas
13739 __builtin_arc_align uses alignment information from the pointer
13740 as well as from the pointed-to type.
13741 The information available will depend on optimization level.
13742 @end deftypefn
13744 @deftypefn {Built-in Function} void __builtin_arc_brk (void)
13745 Generates
13746 @example
13748 @end example
13749 @end deftypefn
13751 @deftypefn {Built-in Function} {unsigned int} __builtin_arc_core_read (unsigned int @var{regno})
13752 The operand is the number of a register to be read.  Generates:
13753 @example
13754 mov  @var{dest}, r@var{regno}
13755 @end example
13756 where the value in @var{dest} will be the result returned from the
13757 built-in.
13758 @end deftypefn
13760 @deftypefn {Built-in Function} void __builtin_arc_core_write (unsigned int @var{regno}, unsigned int @var{val})
13761 The first operand is the number of a register to be written, the
13762 second operand is a compile time constant to write into that
13763 register.  Generates:
13764 @example
13765 mov  r@var{regno}, @var{val}
13766 @end example
13767 @end deftypefn
13769 @deftypefn {Built-in Function} int __builtin_arc_divaw (int @var{a}, int @var{b})
13770 Only available if either @option{-mcpu=ARC700} or @option{-meA} is set.
13771 Generates:
13772 @example
13773 divaw  @var{dest}, @var{a}, @var{b}
13774 @end example
13775 where the value in @var{dest} will be the result returned from the
13776 built-in.
13777 @end deftypefn
13779 @deftypefn {Built-in Function} void __builtin_arc_flag (unsigned int @var{a})
13780 Generates
13781 @example
13782 flag  @var{a}
13783 @end example
13784 @end deftypefn
13786 @deftypefn {Built-in Function} {unsigned int} __builtin_arc_lr (unsigned int @var{auxr})
13787 The operand, @var{auxv}, is the address of an auxiliary register and
13788 must be a compile time constant.  Generates:
13789 @example
13790 lr  @var{dest}, [@var{auxr}]
13791 @end example
13792 Where the value in @var{dest} will be the result returned from the
13793 built-in.
13794 @end deftypefn
13796 @deftypefn {Built-in Function} void __builtin_arc_mul64 (int @var{a}, int @var{b})
13797 Only available with @option{-mmul64}.  Generates:
13798 @example
13799 mul64  @var{a}, @var{b}
13800 @end example
13801 @end deftypefn
13803 @deftypefn {Built-in Function} void __builtin_arc_mulu64 (unsigned int @var{a}, unsigned int @var{b})
13804 Only available with @option{-mmul64}.  Generates:
13805 @example
13806 mulu64  @var{a}, @var{b}
13807 @end example
13808 @end deftypefn
13810 @deftypefn {Built-in Function} void __builtin_arc_nop (void)
13811 Generates:
13812 @example
13814 @end example
13815 @end deftypefn
13817 @deftypefn {Built-in Function} int __builtin_arc_norm (int @var{src})
13818 Only valid if the @samp{norm} instruction is available through the
13819 @option{-mnorm} option or by default with @option{-mcpu=ARC700}.
13820 Generates:
13821 @example
13822 norm  @var{dest}, @var{src}
13823 @end example
13824 Where the value in @var{dest} will be the result returned from the
13825 built-in.
13826 @end deftypefn
13828 @deftypefn {Built-in Function}  {short int} __builtin_arc_normw (short int @var{src})
13829 Only valid if the @samp{normw} instruction is available through the
13830 @option{-mnorm} option or by default with @option{-mcpu=ARC700}.
13831 Generates:
13832 @example
13833 normw  @var{dest}, @var{src}
13834 @end example
13835 Where the value in @var{dest} will be the result returned from the
13836 built-in.
13837 @end deftypefn
13839 @deftypefn {Built-in Function}  void __builtin_arc_rtie (void)
13840 Generates:
13841 @example
13842 rtie
13843 @end example
13844 @end deftypefn
13846 @deftypefn {Built-in Function}  void __builtin_arc_sleep (int @var{a}
13847 Generates:
13848 @example
13849 sleep  @var{a}
13850 @end example
13851 @end deftypefn
13853 @deftypefn {Built-in Function}  void __builtin_arc_sr (unsigned int @var{auxr}, unsigned int @var{val})
13854 The first argument, @var{auxv}, is the address of an auxiliary
13855 register, the second argument, @var{val}, is a compile time constant
13856 to be written to the register.  Generates:
13857 @example
13858 sr  @var{auxr}, [@var{val}]
13859 @end example
13860 @end deftypefn
13862 @deftypefn {Built-in Function}  int __builtin_arc_swap (int @var{src})
13863 Only valid with @option{-mswap}.  Generates:
13864 @example
13865 swap  @var{dest}, @var{src}
13866 @end example
13867 Where the value in @var{dest} will be the result returned from the
13868 built-in.
13869 @end deftypefn
13871 @deftypefn {Built-in Function}  void __builtin_arc_swi (void)
13872 Generates:
13873 @example
13875 @end example
13876 @end deftypefn
13878 @deftypefn {Built-in Function}  void __builtin_arc_sync (void)
13879 Only available with @option{-mcpu=ARC700}.  Generates:
13880 @example
13881 sync
13882 @end example
13883 @end deftypefn
13885 @deftypefn {Built-in Function}  void __builtin_arc_trap_s (unsigned int @var{c})
13886 Only available with @option{-mcpu=ARC700}.  Generates:
13887 @example
13888 trap_s  @var{c}
13889 @end example
13890 @end deftypefn
13892 @deftypefn {Built-in Function}  void __builtin_arc_unimp_s (void)
13893 Only available with @option{-mcpu=ARC700}.  Generates:
13894 @example
13895 unimp_s
13896 @end example
13897 @end deftypefn
13899 The instructions generated by the following builtins are not
13900 considered as candidates for scheduling.  They are not moved around by
13901 the compiler during scheduling, and thus can be expected to appear
13902 where they are put in the C code:
13903 @example
13904 __builtin_arc_brk()
13905 __builtin_arc_core_read()
13906 __builtin_arc_core_write()
13907 __builtin_arc_flag()
13908 __builtin_arc_lr()
13909 __builtin_arc_sleep()
13910 __builtin_arc_sr()
13911 __builtin_arc_swi()
13912 @end example
13914 @node ARC SIMD Built-in Functions
13915 @subsection ARC SIMD Built-in Functions
13917 SIMD builtins provided by the compiler can be used to generate the
13918 vector instructions.  This section describes the available builtins
13919 and their usage in programs.  With the @option{-msimd} option, the
13920 compiler provides 128-bit vector types, which can be specified using
13921 the @code{vector_size} attribute.  The header file @file{arc-simd.h}
13922 can be included to use the following predefined types:
13923 @example
13924 typedef int __v4si   __attribute__((vector_size(16)));
13925 typedef short __v8hi __attribute__((vector_size(16)));
13926 @end example
13928 These types can be used to define 128-bit variables.  The built-in
13929 functions listed in the following section can be used on these
13930 variables to generate the vector operations.
13932 For all builtins, @code{__builtin_arc_@var{someinsn}}, the header file
13933 @file{arc-simd.h} also provides equivalent macros called
13934 @code{_@var{someinsn}} that can be used for programming ease and
13935 improved readability.  The following macros for DMA control are also
13936 provided:
13937 @example
13938 #define _setup_dma_in_channel_reg _vdiwr
13939 #define _setup_dma_out_channel_reg _vdowr
13940 @end example
13942 The following is a complete list of all the SIMD built-ins provided
13943 for ARC, grouped by calling signature.
13945 The following take two @code{__v8hi} arguments and return a
13946 @code{__v8hi} result:
13947 @example
13948 __v8hi __builtin_arc_vaddaw (__v8hi, __v8hi)
13949 __v8hi __builtin_arc_vaddw (__v8hi, __v8hi)
13950 __v8hi __builtin_arc_vand (__v8hi, __v8hi)
13951 __v8hi __builtin_arc_vandaw (__v8hi, __v8hi)
13952 __v8hi __builtin_arc_vavb (__v8hi, __v8hi)
13953 __v8hi __builtin_arc_vavrb (__v8hi, __v8hi)
13954 __v8hi __builtin_arc_vbic (__v8hi, __v8hi)
13955 __v8hi __builtin_arc_vbicaw (__v8hi, __v8hi)
13956 __v8hi __builtin_arc_vdifaw (__v8hi, __v8hi)
13957 __v8hi __builtin_arc_vdifw (__v8hi, __v8hi)
13958 __v8hi __builtin_arc_veqw (__v8hi, __v8hi)
13959 __v8hi __builtin_arc_vh264f (__v8hi, __v8hi)
13960 __v8hi __builtin_arc_vh264ft (__v8hi, __v8hi)
13961 __v8hi __builtin_arc_vh264fw (__v8hi, __v8hi)
13962 __v8hi __builtin_arc_vlew (__v8hi, __v8hi)
13963 __v8hi __builtin_arc_vltw (__v8hi, __v8hi)
13964 __v8hi __builtin_arc_vmaxaw (__v8hi, __v8hi)
13965 __v8hi __builtin_arc_vmaxw (__v8hi, __v8hi)
13966 __v8hi __builtin_arc_vminaw (__v8hi, __v8hi)
13967 __v8hi __builtin_arc_vminw (__v8hi, __v8hi)
13968 __v8hi __builtin_arc_vmr1aw (__v8hi, __v8hi)
13969 __v8hi __builtin_arc_vmr1w (__v8hi, __v8hi)
13970 __v8hi __builtin_arc_vmr2aw (__v8hi, __v8hi)
13971 __v8hi __builtin_arc_vmr2w (__v8hi, __v8hi)
13972 __v8hi __builtin_arc_vmr3aw (__v8hi, __v8hi)
13973 __v8hi __builtin_arc_vmr3w (__v8hi, __v8hi)
13974 __v8hi __builtin_arc_vmr4aw (__v8hi, __v8hi)
13975 __v8hi __builtin_arc_vmr4w (__v8hi, __v8hi)
13976 __v8hi __builtin_arc_vmr5aw (__v8hi, __v8hi)
13977 __v8hi __builtin_arc_vmr5w (__v8hi, __v8hi)
13978 __v8hi __builtin_arc_vmr6aw (__v8hi, __v8hi)
13979 __v8hi __builtin_arc_vmr6w (__v8hi, __v8hi)
13980 __v8hi __builtin_arc_vmr7aw (__v8hi, __v8hi)
13981 __v8hi __builtin_arc_vmr7w (__v8hi, __v8hi)
13982 __v8hi __builtin_arc_vmrb (__v8hi, __v8hi)
13983 __v8hi __builtin_arc_vmulaw (__v8hi, __v8hi)
13984 __v8hi __builtin_arc_vmulfaw (__v8hi, __v8hi)
13985 __v8hi __builtin_arc_vmulfw (__v8hi, __v8hi)
13986 __v8hi __builtin_arc_vmulw (__v8hi, __v8hi)
13987 __v8hi __builtin_arc_vnew (__v8hi, __v8hi)
13988 __v8hi __builtin_arc_vor (__v8hi, __v8hi)
13989 __v8hi __builtin_arc_vsubaw (__v8hi, __v8hi)
13990 __v8hi __builtin_arc_vsubw (__v8hi, __v8hi)
13991 __v8hi __builtin_arc_vsummw (__v8hi, __v8hi)
13992 __v8hi __builtin_arc_vvc1f (__v8hi, __v8hi)
13993 __v8hi __builtin_arc_vvc1ft (__v8hi, __v8hi)
13994 __v8hi __builtin_arc_vxor (__v8hi, __v8hi)
13995 __v8hi __builtin_arc_vxoraw (__v8hi, __v8hi)
13996 @end example
13998 The following take one @code{__v8hi} and one @code{int} argument and return a
13999 @code{__v8hi} result:
14001 @example
14002 __v8hi __builtin_arc_vbaddw (__v8hi, int)
14003 __v8hi __builtin_arc_vbmaxw (__v8hi, int)
14004 __v8hi __builtin_arc_vbminw (__v8hi, int)
14005 __v8hi __builtin_arc_vbmulaw (__v8hi, int)
14006 __v8hi __builtin_arc_vbmulfw (__v8hi, int)
14007 __v8hi __builtin_arc_vbmulw (__v8hi, int)
14008 __v8hi __builtin_arc_vbrsubw (__v8hi, int)
14009 __v8hi __builtin_arc_vbsubw (__v8hi, int)
14010 @end example
14012 The following take one @code{__v8hi} argument and one @code{int} argument which
14013 must be a 3-bit compile time constant indicating a register number
14014 I0-I7.  They return a @code{__v8hi} result.
14015 @example
14016 __v8hi __builtin_arc_vasrw (__v8hi, const int)
14017 __v8hi __builtin_arc_vsr8 (__v8hi, const int)
14018 __v8hi __builtin_arc_vsr8aw (__v8hi, const int)
14019 @end example
14021 The following take one @code{__v8hi} argument and one @code{int}
14022 argument which must be a 6-bit compile time constant.  They return a
14023 @code{__v8hi} result.
14024 @example
14025 __v8hi __builtin_arc_vasrpwbi (__v8hi, const int)
14026 __v8hi __builtin_arc_vasrrpwbi (__v8hi, const int)
14027 __v8hi __builtin_arc_vasrrwi (__v8hi, const int)
14028 __v8hi __builtin_arc_vasrsrwi (__v8hi, const int)
14029 __v8hi __builtin_arc_vasrwi (__v8hi, const int)
14030 __v8hi __builtin_arc_vsr8awi (__v8hi, const int)
14031 __v8hi __builtin_arc_vsr8i (__v8hi, const int)
14032 @end example
14034 The following take one @code{__v8hi} argument and one @code{int} argument which
14035 must be a 8-bit compile time constant.  They return a @code{__v8hi}
14036 result.
14037 @example
14038 __v8hi __builtin_arc_vd6tapf (__v8hi, const int)
14039 __v8hi __builtin_arc_vmvaw (__v8hi, const int)
14040 __v8hi __builtin_arc_vmvw (__v8hi, const int)
14041 __v8hi __builtin_arc_vmvzw (__v8hi, const int)
14042 @end example
14044 The following take two @code{int} arguments, the second of which which
14045 must be a 8-bit compile time constant.  They return a @code{__v8hi}
14046 result:
14047 @example
14048 __v8hi __builtin_arc_vmovaw (int, const int)
14049 __v8hi __builtin_arc_vmovw (int, const int)
14050 __v8hi __builtin_arc_vmovzw (int, const int)
14051 @end example
14053 The following take a single @code{__v8hi} argument and return a
14054 @code{__v8hi} result:
14055 @example
14056 __v8hi __builtin_arc_vabsaw (__v8hi)
14057 __v8hi __builtin_arc_vabsw (__v8hi)
14058 __v8hi __builtin_arc_vaddsuw (__v8hi)
14059 __v8hi __builtin_arc_vexch1 (__v8hi)
14060 __v8hi __builtin_arc_vexch2 (__v8hi)
14061 __v8hi __builtin_arc_vexch4 (__v8hi)
14062 __v8hi __builtin_arc_vsignw (__v8hi)
14063 __v8hi __builtin_arc_vupbaw (__v8hi)
14064 __v8hi __builtin_arc_vupbw (__v8hi)
14065 __v8hi __builtin_arc_vupsbaw (__v8hi)
14066 __v8hi __builtin_arc_vupsbw (__v8hi)
14067 @end example
14069 The following take two @code{int} arguments and return no result:
14070 @example
14071 void __builtin_arc_vdirun (int, int)
14072 void __builtin_arc_vdorun (int, int)
14073 @end example
14075 The following take two @code{int} arguments and return no result.  The
14076 first argument must a 3-bit compile time constant indicating one of
14077 the DR0-DR7 DMA setup channels:
14078 @example
14079 void __builtin_arc_vdiwr (const int, int)
14080 void __builtin_arc_vdowr (const int, int)
14081 @end example
14083 The following take an @code{int} argument and return no result:
14084 @example
14085 void __builtin_arc_vendrec (int)
14086 void __builtin_arc_vrec (int)
14087 void __builtin_arc_vrecrun (int)
14088 void __builtin_arc_vrun (int)
14089 @end example
14091 The following take a @code{__v8hi} argument and two @code{int}
14092 arguments and return a @code{__v8hi} result.  The second argument must
14093 be a 3-bit compile time constants, indicating one the registers I0-I7,
14094 and the third argument must be an 8-bit compile time constant.
14096 @emph{Note:} Although the equivalent hardware instructions do not take
14097 an SIMD register as an operand, these builtins overwrite the relevant
14098 bits of the @code{__v8hi} register provided as the first argument with
14099 the value loaded from the @code{[Ib, u8]} location in the SDM.
14101 @example
14102 __v8hi __builtin_arc_vld32 (__v8hi, const int, const int)
14103 __v8hi __builtin_arc_vld32wh (__v8hi, const int, const int)
14104 __v8hi __builtin_arc_vld32wl (__v8hi, const int, const int)
14105 __v8hi __builtin_arc_vld64 (__v8hi, const int, const int)
14106 @end example
14108 The following take two @code{int} arguments and return a @code{__v8hi}
14109 result.  The first argument must be a 3-bit compile time constants,
14110 indicating one the registers I0-I7, and the second argument must be an
14111 8-bit compile time constant.
14113 @example
14114 __v8hi __builtin_arc_vld128 (const int, const int)
14115 __v8hi __builtin_arc_vld64w (const int, const int)
14116 @end example
14118 The following take a @code{__v8hi} argument and two @code{int}
14119 arguments and return no result.  The second argument must be a 3-bit
14120 compile time constants, indicating one the registers I0-I7, and the
14121 third argument must be an 8-bit compile time constant.
14123 @example
14124 void __builtin_arc_vst128 (__v8hi, const int, const int)
14125 void __builtin_arc_vst64 (__v8hi, const int, const int)
14126 @end example
14128 The following take a @code{__v8hi} argument and three @code{int}
14129 arguments and return no result.  The second argument must be a 3-bit
14130 compile-time constant, identifying the 16-bit sub-register to be
14131 stored, the third argument must be a 3-bit compile time constants,
14132 indicating one the registers I0-I7, and the fourth argument must be an
14133 8-bit compile time constant.
14135 @example
14136 void __builtin_arc_vst16_n (__v8hi, const int, const int, const int)
14137 void __builtin_arc_vst32_n (__v8hi, const int, const int, const int)
14138 @end example
14140 @node ARM iWMMXt Built-in Functions
14141 @subsection ARM iWMMXt Built-in Functions
14143 These built-in functions are available for the ARM family of
14144 processors when the @option{-mcpu=iwmmxt} switch is used:
14146 @smallexample
14147 typedef int v2si __attribute__ ((vector_size (8)));
14148 typedef short v4hi __attribute__ ((vector_size (8)));
14149 typedef char v8qi __attribute__ ((vector_size (8)));
14151 int __builtin_arm_getwcgr0 (void)
14152 void __builtin_arm_setwcgr0 (int)
14153 int __builtin_arm_getwcgr1 (void)
14154 void __builtin_arm_setwcgr1 (int)
14155 int __builtin_arm_getwcgr2 (void)
14156 void __builtin_arm_setwcgr2 (int)
14157 int __builtin_arm_getwcgr3 (void)
14158 void __builtin_arm_setwcgr3 (int)
14159 int __builtin_arm_textrmsb (v8qi, int)
14160 int __builtin_arm_textrmsh (v4hi, int)
14161 int __builtin_arm_textrmsw (v2si, int)
14162 int __builtin_arm_textrmub (v8qi, int)
14163 int __builtin_arm_textrmuh (v4hi, int)
14164 int __builtin_arm_textrmuw (v2si, int)
14165 v8qi __builtin_arm_tinsrb (v8qi, int, int)
14166 v4hi __builtin_arm_tinsrh (v4hi, int, int)
14167 v2si __builtin_arm_tinsrw (v2si, int, int)
14168 long long __builtin_arm_tmia (long long, int, int)
14169 long long __builtin_arm_tmiabb (long long, int, int)
14170 long long __builtin_arm_tmiabt (long long, int, int)
14171 long long __builtin_arm_tmiaph (long long, int, int)
14172 long long __builtin_arm_tmiatb (long long, int, int)
14173 long long __builtin_arm_tmiatt (long long, int, int)
14174 int __builtin_arm_tmovmskb (v8qi)
14175 int __builtin_arm_tmovmskh (v4hi)
14176 int __builtin_arm_tmovmskw (v2si)
14177 long long __builtin_arm_waccb (v8qi)
14178 long long __builtin_arm_wacch (v4hi)
14179 long long __builtin_arm_waccw (v2si)
14180 v8qi __builtin_arm_waddb (v8qi, v8qi)
14181 v8qi __builtin_arm_waddbss (v8qi, v8qi)
14182 v8qi __builtin_arm_waddbus (v8qi, v8qi)
14183 v4hi __builtin_arm_waddh (v4hi, v4hi)
14184 v4hi __builtin_arm_waddhss (v4hi, v4hi)
14185 v4hi __builtin_arm_waddhus (v4hi, v4hi)
14186 v2si __builtin_arm_waddw (v2si, v2si)
14187 v2si __builtin_arm_waddwss (v2si, v2si)
14188 v2si __builtin_arm_waddwus (v2si, v2si)
14189 v8qi __builtin_arm_walign (v8qi, v8qi, int)
14190 long long __builtin_arm_wand(long long, long long)
14191 long long __builtin_arm_wandn (long long, long long)
14192 v8qi __builtin_arm_wavg2b (v8qi, v8qi)
14193 v8qi __builtin_arm_wavg2br (v8qi, v8qi)
14194 v4hi __builtin_arm_wavg2h (v4hi, v4hi)
14195 v4hi __builtin_arm_wavg2hr (v4hi, v4hi)
14196 v8qi __builtin_arm_wcmpeqb (v8qi, v8qi)
14197 v4hi __builtin_arm_wcmpeqh (v4hi, v4hi)
14198 v2si __builtin_arm_wcmpeqw (v2si, v2si)
14199 v8qi __builtin_arm_wcmpgtsb (v8qi, v8qi)
14200 v4hi __builtin_arm_wcmpgtsh (v4hi, v4hi)
14201 v2si __builtin_arm_wcmpgtsw (v2si, v2si)
14202 v8qi __builtin_arm_wcmpgtub (v8qi, v8qi)
14203 v4hi __builtin_arm_wcmpgtuh (v4hi, v4hi)
14204 v2si __builtin_arm_wcmpgtuw (v2si, v2si)
14205 long long __builtin_arm_wmacs (long long, v4hi, v4hi)
14206 long long __builtin_arm_wmacsz (v4hi, v4hi)
14207 long long __builtin_arm_wmacu (long long, v4hi, v4hi)
14208 long long __builtin_arm_wmacuz (v4hi, v4hi)
14209 v4hi __builtin_arm_wmadds (v4hi, v4hi)
14210 v4hi __builtin_arm_wmaddu (v4hi, v4hi)
14211 v8qi __builtin_arm_wmaxsb (v8qi, v8qi)
14212 v4hi __builtin_arm_wmaxsh (v4hi, v4hi)
14213 v2si __builtin_arm_wmaxsw (v2si, v2si)
14214 v8qi __builtin_arm_wmaxub (v8qi, v8qi)
14215 v4hi __builtin_arm_wmaxuh (v4hi, v4hi)
14216 v2si __builtin_arm_wmaxuw (v2si, v2si)
14217 v8qi __builtin_arm_wminsb (v8qi, v8qi)
14218 v4hi __builtin_arm_wminsh (v4hi, v4hi)
14219 v2si __builtin_arm_wminsw (v2si, v2si)
14220 v8qi __builtin_arm_wminub (v8qi, v8qi)
14221 v4hi __builtin_arm_wminuh (v4hi, v4hi)
14222 v2si __builtin_arm_wminuw (v2si, v2si)
14223 v4hi __builtin_arm_wmulsm (v4hi, v4hi)
14224 v4hi __builtin_arm_wmulul (v4hi, v4hi)
14225 v4hi __builtin_arm_wmulum (v4hi, v4hi)
14226 long long __builtin_arm_wor (long long, long long)
14227 v2si __builtin_arm_wpackdss (long long, long long)
14228 v2si __builtin_arm_wpackdus (long long, long long)
14229 v8qi __builtin_arm_wpackhss (v4hi, v4hi)
14230 v8qi __builtin_arm_wpackhus (v4hi, v4hi)
14231 v4hi __builtin_arm_wpackwss (v2si, v2si)
14232 v4hi __builtin_arm_wpackwus (v2si, v2si)
14233 long long __builtin_arm_wrord (long long, long long)
14234 long long __builtin_arm_wrordi (long long, int)
14235 v4hi __builtin_arm_wrorh (v4hi, long long)
14236 v4hi __builtin_arm_wrorhi (v4hi, int)
14237 v2si __builtin_arm_wrorw (v2si, long long)
14238 v2si __builtin_arm_wrorwi (v2si, int)
14239 v2si __builtin_arm_wsadb (v2si, v8qi, v8qi)
14240 v2si __builtin_arm_wsadbz (v8qi, v8qi)
14241 v2si __builtin_arm_wsadh (v2si, v4hi, v4hi)
14242 v2si __builtin_arm_wsadhz (v4hi, v4hi)
14243 v4hi __builtin_arm_wshufh (v4hi, int)
14244 long long __builtin_arm_wslld (long long, long long)
14245 long long __builtin_arm_wslldi (long long, int)
14246 v4hi __builtin_arm_wsllh (v4hi, long long)
14247 v4hi __builtin_arm_wsllhi (v4hi, int)
14248 v2si __builtin_arm_wsllw (v2si, long long)
14249 v2si __builtin_arm_wsllwi (v2si, int)
14250 long long __builtin_arm_wsrad (long long, long long)
14251 long long __builtin_arm_wsradi (long long, int)
14252 v4hi __builtin_arm_wsrah (v4hi, long long)
14253 v4hi __builtin_arm_wsrahi (v4hi, int)
14254 v2si __builtin_arm_wsraw (v2si, long long)
14255 v2si __builtin_arm_wsrawi (v2si, int)
14256 long long __builtin_arm_wsrld (long long, long long)
14257 long long __builtin_arm_wsrldi (long long, int)
14258 v4hi __builtin_arm_wsrlh (v4hi, long long)
14259 v4hi __builtin_arm_wsrlhi (v4hi, int)
14260 v2si __builtin_arm_wsrlw (v2si, long long)
14261 v2si __builtin_arm_wsrlwi (v2si, int)
14262 v8qi __builtin_arm_wsubb (v8qi, v8qi)
14263 v8qi __builtin_arm_wsubbss (v8qi, v8qi)
14264 v8qi __builtin_arm_wsubbus (v8qi, v8qi)
14265 v4hi __builtin_arm_wsubh (v4hi, v4hi)
14266 v4hi __builtin_arm_wsubhss (v4hi, v4hi)
14267 v4hi __builtin_arm_wsubhus (v4hi, v4hi)
14268 v2si __builtin_arm_wsubw (v2si, v2si)
14269 v2si __builtin_arm_wsubwss (v2si, v2si)
14270 v2si __builtin_arm_wsubwus (v2si, v2si)
14271 v4hi __builtin_arm_wunpckehsb (v8qi)
14272 v2si __builtin_arm_wunpckehsh (v4hi)
14273 long long __builtin_arm_wunpckehsw (v2si)
14274 v4hi __builtin_arm_wunpckehub (v8qi)
14275 v2si __builtin_arm_wunpckehuh (v4hi)
14276 long long __builtin_arm_wunpckehuw (v2si)
14277 v4hi __builtin_arm_wunpckelsb (v8qi)
14278 v2si __builtin_arm_wunpckelsh (v4hi)
14279 long long __builtin_arm_wunpckelsw (v2si)
14280 v4hi __builtin_arm_wunpckelub (v8qi)
14281 v2si __builtin_arm_wunpckeluh (v4hi)
14282 long long __builtin_arm_wunpckeluw (v2si)
14283 v8qi __builtin_arm_wunpckihb (v8qi, v8qi)
14284 v4hi __builtin_arm_wunpckihh (v4hi, v4hi)
14285 v2si __builtin_arm_wunpckihw (v2si, v2si)
14286 v8qi __builtin_arm_wunpckilb (v8qi, v8qi)
14287 v4hi __builtin_arm_wunpckilh (v4hi, v4hi)
14288 v2si __builtin_arm_wunpckilw (v2si, v2si)
14289 long long __builtin_arm_wxor (long long, long long)
14290 long long __builtin_arm_wzero ()
14291 @end smallexample
14294 @node ARM C Language Extensions (ACLE)
14295 @subsection ARM C Language Extensions (ACLE)
14297 GCC implements extensions for C as described in the ARM C Language
14298 Extensions (ACLE) specification, which can be found at
14299 @uref{http://infocenter.arm.com/help/topic/com.arm.doc.ihi0053c/IHI0053C_acle_2_0.pdf}.
14301 As a part of ACLE, GCC implements extensions for Advanced SIMD as described in
14302 the ARM C Language Extensions Specification.  The complete list of Advanced SIMD
14303 intrinsics can be found at
14304 @uref{http://infocenter.arm.com/help/topic/com.arm.doc.ihi0073a/IHI0073A_arm_neon_intrinsics_ref.pdf}.
14305 The built-in intrinsics for the Advanced SIMD extension are available when
14306 NEON is enabled.
14308 Currently, ARM and AArch64 back ends do not support ACLE 2.0 fully.  Both
14309 back ends support CRC32 intrinsics and the ARM back end supports the
14310 Coprocessor intrinsics, all from @file{arm_acle.h}.  The ARM back end's 16-bit
14311 floating-point Advanced SIMD intrinsics currently comply to ACLE v1.1.
14312 AArch64's back end does not have support for 16-bit floating point Advanced SIMD
14313 intrinsics yet.
14315 See @ref{ARM Options} and @ref{AArch64 Options} for more information on the
14316 availability of extensions.
14318 @node ARM Floating Point Status and Control Intrinsics
14319 @subsection ARM Floating Point Status and Control Intrinsics
14321 These built-in functions are available for the ARM family of
14322 processors with floating-point unit.
14324 @smallexample
14325 unsigned int __builtin_arm_get_fpscr ()
14326 void __builtin_arm_set_fpscr (unsigned int)
14327 @end smallexample
14329 @node ARM ARMv8-M Security Extensions
14330 @subsection ARM ARMv8-M Security Extensions
14332 GCC implements the ARMv8-M Security Extensions as described in the ARMv8-M
14333 Security Extensions: Requirements on Development Tools Engineering
14334 Specification, which can be found at
14335 @uref{http://infocenter.arm.com/help/topic/com.arm.doc.ecm0359818/ECM0359818_armv8m_security_extensions_reqs_on_dev_tools_1_0.pdf}.
14337 As part of the Security Extensions GCC implements two new function attributes:
14338 @code{cmse_nonsecure_entry} and @code{cmse_nonsecure_call}.
14340 As part of the Security Extensions GCC implements the intrinsics below.  FPTR
14341 is used here to mean any function pointer type.
14343 @smallexample
14344 cmse_address_info_t cmse_TT (void *)
14345 cmse_address_info_t cmse_TT_fptr (FPTR)
14346 cmse_address_info_t cmse_TTT (void *)
14347 cmse_address_info_t cmse_TTT_fptr (FPTR)
14348 cmse_address_info_t cmse_TTA (void *)
14349 cmse_address_info_t cmse_TTA_fptr (FPTR)
14350 cmse_address_info_t cmse_TTAT (void *)
14351 cmse_address_info_t cmse_TTAT_fptr (FPTR)
14352 void * cmse_check_address_range (void *, size_t, int)
14353 typeof(p) cmse_nsfptr_create (FPTR p)
14354 intptr_t cmse_is_nsfptr (FPTR)
14355 int cmse_nonsecure_caller (void)
14356 @end smallexample
14358 @node AVR Built-in Functions
14359 @subsection AVR Built-in Functions
14361 For each built-in function for AVR, there is an equally named,
14362 uppercase built-in macro defined. That way users can easily query if
14363 or if not a specific built-in is implemented or not. For example, if
14364 @code{__builtin_avr_nop} is available the macro
14365 @code{__BUILTIN_AVR_NOP} is defined to @code{1} and undefined otherwise.
14367 @table @code
14369 @item void __builtin_avr_nop (void)
14370 @itemx void __builtin_avr_sei (void)
14371 @itemx void __builtin_avr_cli (void)
14372 @itemx void __builtin_avr_sleep (void)
14373 @itemx void __builtin_avr_wdr (void)
14374 @itemx unsigned char __builtin_avr_swap (unsigned char)
14375 @itemx unsigned int __builtin_avr_fmul (unsigned char, unsigned char)
14376 @itemx int __builtin_avr_fmuls (char, char)
14377 @itemx int __builtin_avr_fmulsu (char, unsigned char)
14378 These built-in functions map to the respective machine
14379 instruction, i.e.@: @code{nop}, @code{sei}, @code{cli}, @code{sleep},
14380 @code{wdr}, @code{swap}, @code{fmul}, @code{fmuls}
14381 resp. @code{fmulsu}. The three @code{fmul*} built-ins are implemented
14382 as library call if no hardware multiplier is available.
14384 @item void __builtin_avr_delay_cycles (unsigned long ticks)
14385 Delay execution for @var{ticks} cycles. Note that this
14386 built-in does not take into account the effect of interrupts that
14387 might increase delay time. @var{ticks} must be a compile-time
14388 integer constant; delays with a variable number of cycles are not supported.
14390 @item char __builtin_avr_flash_segment (const __memx void*)
14391 This built-in takes a byte address to the 24-bit
14392 @ref{AVR Named Address Spaces,address space} @code{__memx} and returns
14393 the number of the flash segment (the 64 KiB chunk) where the address
14394 points to.  Counting starts at @code{0}.
14395 If the address does not point to flash memory, return @code{-1}.
14397 @item uint8_t __builtin_avr_insert_bits (uint32_t map, uint8_t bits, uint8_t val)
14398 Insert bits from @var{bits} into @var{val} and return the resulting
14399 value. The nibbles of @var{map} determine how the insertion is
14400 performed: Let @var{X} be the @var{n}-th nibble of @var{map}
14401 @enumerate
14402 @item If @var{X} is @code{0xf},
14403 then the @var{n}-th bit of @var{val} is returned unaltered.
14405 @item If X is in the range 0@dots{}7,
14406 then the @var{n}-th result bit is set to the @var{X}-th bit of @var{bits}
14408 @item If X is in the range 8@dots{}@code{0xe},
14409 then the @var{n}-th result bit is undefined.
14410 @end enumerate
14412 @noindent
14413 One typical use case for this built-in is adjusting input and
14414 output values to non-contiguous port layouts. Some examples:
14416 @smallexample
14417 // same as val, bits is unused
14418 __builtin_avr_insert_bits (0xffffffff, bits, val)
14419 @end smallexample
14421 @smallexample
14422 // same as bits, val is unused
14423 __builtin_avr_insert_bits (0x76543210, bits, val)
14424 @end smallexample
14426 @smallexample
14427 // same as rotating bits by 4
14428 __builtin_avr_insert_bits (0x32107654, bits, 0)
14429 @end smallexample
14431 @smallexample
14432 // high nibble of result is the high nibble of val
14433 // low nibble of result is the low nibble of bits
14434 __builtin_avr_insert_bits (0xffff3210, bits, val)
14435 @end smallexample
14437 @smallexample
14438 // reverse the bit order of bits
14439 __builtin_avr_insert_bits (0x01234567, bits, 0)
14440 @end smallexample
14442 @item void __builtin_avr_nops (unsigned count)
14443 Insert @var{count} @code{NOP} instructions.
14444 The number of instructions must be a compile-time integer constant.
14446 @end table
14448 @noindent
14449 There are many more AVR-specific built-in functions that are used to
14450 implement the ISO/IEC TR 18037 ``Embedded C'' fixed-point functions of
14451 section 7.18a.6.  You don't need to use these built-ins directly.
14452 Instead, use the declarations as supplied by the @code{stdfix.h} header
14453 with GNU-C99:
14455 @smallexample
14456 #include <stdfix.h>
14458 // Re-interpret the bit representation of unsigned 16-bit
14459 // integer @var{uval} as Q-format 0.16 value.
14460 unsigned fract get_bits (uint_ur_t uval)
14462     return urbits (uval);
14464 @end smallexample
14466 @node Blackfin Built-in Functions
14467 @subsection Blackfin Built-in Functions
14469 Currently, there are two Blackfin-specific built-in functions.  These are
14470 used for generating @code{CSYNC} and @code{SSYNC} machine insns without
14471 using inline assembly; by using these built-in functions the compiler can
14472 automatically add workarounds for hardware errata involving these
14473 instructions.  These functions are named as follows:
14475 @smallexample
14476 void __builtin_bfin_csync (void)
14477 void __builtin_bfin_ssync (void)
14478 @end smallexample
14480 @node FR-V Built-in Functions
14481 @subsection FR-V Built-in Functions
14483 GCC provides many FR-V-specific built-in functions.  In general,
14484 these functions are intended to be compatible with those described
14485 by @cite{FR-V Family, Softune C/C++ Compiler Manual (V6), Fujitsu
14486 Semiconductor}.  The two exceptions are @code{__MDUNPACKH} and
14487 @code{__MBTOHE}, the GCC forms of which pass 128-bit values by
14488 pointer rather than by value.
14490 Most of the functions are named after specific FR-V instructions.
14491 Such functions are said to be ``directly mapped'' and are summarized
14492 here in tabular form.
14494 @menu
14495 * Argument Types::
14496 * Directly-mapped Integer Functions::
14497 * Directly-mapped Media Functions::
14498 * Raw read/write Functions::
14499 * Other Built-in Functions::
14500 @end menu
14502 @node Argument Types
14503 @subsubsection Argument Types
14505 The arguments to the built-in functions can be divided into three groups:
14506 register numbers, compile-time constants and run-time values.  In order
14507 to make this classification clear at a glance, the arguments and return
14508 values are given the following pseudo types:
14510 @multitable @columnfractions .20 .30 .15 .35
14511 @item Pseudo type @tab Real C type @tab Constant? @tab Description
14512 @item @code{uh} @tab @code{unsigned short} @tab No @tab an unsigned halfword
14513 @item @code{uw1} @tab @code{unsigned int} @tab No @tab an unsigned word
14514 @item @code{sw1} @tab @code{int} @tab No @tab a signed word
14515 @item @code{uw2} @tab @code{unsigned long long} @tab No
14516 @tab an unsigned doubleword
14517 @item @code{sw2} @tab @code{long long} @tab No @tab a signed doubleword
14518 @item @code{const} @tab @code{int} @tab Yes @tab an integer constant
14519 @item @code{acc} @tab @code{int} @tab Yes @tab an ACC register number
14520 @item @code{iacc} @tab @code{int} @tab Yes @tab an IACC register number
14521 @end multitable
14523 These pseudo types are not defined by GCC, they are simply a notational
14524 convenience used in this manual.
14526 Arguments of type @code{uh}, @code{uw1}, @code{sw1}, @code{uw2}
14527 and @code{sw2} are evaluated at run time.  They correspond to
14528 register operands in the underlying FR-V instructions.
14530 @code{const} arguments represent immediate operands in the underlying
14531 FR-V instructions.  They must be compile-time constants.
14533 @code{acc} arguments are evaluated at compile time and specify the number
14534 of an accumulator register.  For example, an @code{acc} argument of 2
14535 selects the ACC2 register.
14537 @code{iacc} arguments are similar to @code{acc} arguments but specify the
14538 number of an IACC register.  See @pxref{Other Built-in Functions}
14539 for more details.
14541 @node Directly-mapped Integer Functions
14542 @subsubsection Directly-Mapped Integer Functions
14544 The functions listed below map directly to FR-V I-type instructions.
14546 @multitable @columnfractions .45 .32 .23
14547 @item Function prototype @tab Example usage @tab Assembly output
14548 @item @code{sw1 __ADDSS (sw1, sw1)}
14549 @tab @code{@var{c} = __ADDSS (@var{a}, @var{b})}
14550 @tab @code{ADDSS @var{a},@var{b},@var{c}}
14551 @item @code{sw1 __SCAN (sw1, sw1)}
14552 @tab @code{@var{c} = __SCAN (@var{a}, @var{b})}
14553 @tab @code{SCAN @var{a},@var{b},@var{c}}
14554 @item @code{sw1 __SCUTSS (sw1)}
14555 @tab @code{@var{b} = __SCUTSS (@var{a})}
14556 @tab @code{SCUTSS @var{a},@var{b}}
14557 @item @code{sw1 __SLASS (sw1, sw1)}
14558 @tab @code{@var{c} = __SLASS (@var{a}, @var{b})}
14559 @tab @code{SLASS @var{a},@var{b},@var{c}}
14560 @item @code{void __SMASS (sw1, sw1)}
14561 @tab @code{__SMASS (@var{a}, @var{b})}
14562 @tab @code{SMASS @var{a},@var{b}}
14563 @item @code{void __SMSSS (sw1, sw1)}
14564 @tab @code{__SMSSS (@var{a}, @var{b})}
14565 @tab @code{SMSSS @var{a},@var{b}}
14566 @item @code{void __SMU (sw1, sw1)}
14567 @tab @code{__SMU (@var{a}, @var{b})}
14568 @tab @code{SMU @var{a},@var{b}}
14569 @item @code{sw2 __SMUL (sw1, sw1)}
14570 @tab @code{@var{c} = __SMUL (@var{a}, @var{b})}
14571 @tab @code{SMUL @var{a},@var{b},@var{c}}
14572 @item @code{sw1 __SUBSS (sw1, sw1)}
14573 @tab @code{@var{c} = __SUBSS (@var{a}, @var{b})}
14574 @tab @code{SUBSS @var{a},@var{b},@var{c}}
14575 @item @code{uw2 __UMUL (uw1, uw1)}
14576 @tab @code{@var{c} = __UMUL (@var{a}, @var{b})}
14577 @tab @code{UMUL @var{a},@var{b},@var{c}}
14578 @end multitable
14580 @node Directly-mapped Media Functions
14581 @subsubsection Directly-Mapped Media Functions
14583 The functions listed below map directly to FR-V M-type instructions.
14585 @multitable @columnfractions .45 .32 .23
14586 @item Function prototype @tab Example usage @tab Assembly output
14587 @item @code{uw1 __MABSHS (sw1)}
14588 @tab @code{@var{b} = __MABSHS (@var{a})}
14589 @tab @code{MABSHS @var{a},@var{b}}
14590 @item @code{void __MADDACCS (acc, acc)}
14591 @tab @code{__MADDACCS (@var{b}, @var{a})}
14592 @tab @code{MADDACCS @var{a},@var{b}}
14593 @item @code{sw1 __MADDHSS (sw1, sw1)}
14594 @tab @code{@var{c} = __MADDHSS (@var{a}, @var{b})}
14595 @tab @code{MADDHSS @var{a},@var{b},@var{c}}
14596 @item @code{uw1 __MADDHUS (uw1, uw1)}
14597 @tab @code{@var{c} = __MADDHUS (@var{a}, @var{b})}
14598 @tab @code{MADDHUS @var{a},@var{b},@var{c}}
14599 @item @code{uw1 __MAND (uw1, uw1)}
14600 @tab @code{@var{c} = __MAND (@var{a}, @var{b})}
14601 @tab @code{MAND @var{a},@var{b},@var{c}}
14602 @item @code{void __MASACCS (acc, acc)}
14603 @tab @code{__MASACCS (@var{b}, @var{a})}
14604 @tab @code{MASACCS @var{a},@var{b}}
14605 @item @code{uw1 __MAVEH (uw1, uw1)}
14606 @tab @code{@var{c} = __MAVEH (@var{a}, @var{b})}
14607 @tab @code{MAVEH @var{a},@var{b},@var{c}}
14608 @item @code{uw2 __MBTOH (uw1)}
14609 @tab @code{@var{b} = __MBTOH (@var{a})}
14610 @tab @code{MBTOH @var{a},@var{b}}
14611 @item @code{void __MBTOHE (uw1 *, uw1)}
14612 @tab @code{__MBTOHE (&@var{b}, @var{a})}
14613 @tab @code{MBTOHE @var{a},@var{b}}
14614 @item @code{void __MCLRACC (acc)}
14615 @tab @code{__MCLRACC (@var{a})}
14616 @tab @code{MCLRACC @var{a}}
14617 @item @code{void __MCLRACCA (void)}
14618 @tab @code{__MCLRACCA ()}
14619 @tab @code{MCLRACCA}
14620 @item @code{uw1 __Mcop1 (uw1, uw1)}
14621 @tab @code{@var{c} = __Mcop1 (@var{a}, @var{b})}
14622 @tab @code{Mcop1 @var{a},@var{b},@var{c}}
14623 @item @code{uw1 __Mcop2 (uw1, uw1)}
14624 @tab @code{@var{c} = __Mcop2 (@var{a}, @var{b})}
14625 @tab @code{Mcop2 @var{a},@var{b},@var{c}}
14626 @item @code{uw1 __MCPLHI (uw2, const)}
14627 @tab @code{@var{c} = __MCPLHI (@var{a}, @var{b})}
14628 @tab @code{MCPLHI @var{a},#@var{b},@var{c}}
14629 @item @code{uw1 __MCPLI (uw2, const)}
14630 @tab @code{@var{c} = __MCPLI (@var{a}, @var{b})}
14631 @tab @code{MCPLI @var{a},#@var{b},@var{c}}
14632 @item @code{void __MCPXIS (acc, sw1, sw1)}
14633 @tab @code{__MCPXIS (@var{c}, @var{a}, @var{b})}
14634 @tab @code{MCPXIS @var{a},@var{b},@var{c}}
14635 @item @code{void __MCPXIU (acc, uw1, uw1)}
14636 @tab @code{__MCPXIU (@var{c}, @var{a}, @var{b})}
14637 @tab @code{MCPXIU @var{a},@var{b},@var{c}}
14638 @item @code{void __MCPXRS (acc, sw1, sw1)}
14639 @tab @code{__MCPXRS (@var{c}, @var{a}, @var{b})}
14640 @tab @code{MCPXRS @var{a},@var{b},@var{c}}
14641 @item @code{void __MCPXRU (acc, uw1, uw1)}
14642 @tab @code{__MCPXRU (@var{c}, @var{a}, @var{b})}
14643 @tab @code{MCPXRU @var{a},@var{b},@var{c}}
14644 @item @code{uw1 __MCUT (acc, uw1)}
14645 @tab @code{@var{c} = __MCUT (@var{a}, @var{b})}
14646 @tab @code{MCUT @var{a},@var{b},@var{c}}
14647 @item @code{uw1 __MCUTSS (acc, sw1)}
14648 @tab @code{@var{c} = __MCUTSS (@var{a}, @var{b})}
14649 @tab @code{MCUTSS @var{a},@var{b},@var{c}}
14650 @item @code{void __MDADDACCS (acc, acc)}
14651 @tab @code{__MDADDACCS (@var{b}, @var{a})}
14652 @tab @code{MDADDACCS @var{a},@var{b}}
14653 @item @code{void __MDASACCS (acc, acc)}
14654 @tab @code{__MDASACCS (@var{b}, @var{a})}
14655 @tab @code{MDASACCS @var{a},@var{b}}
14656 @item @code{uw2 __MDCUTSSI (acc, const)}
14657 @tab @code{@var{c} = __MDCUTSSI (@var{a}, @var{b})}
14658 @tab @code{MDCUTSSI @var{a},#@var{b},@var{c}}
14659 @item @code{uw2 __MDPACKH (uw2, uw2)}
14660 @tab @code{@var{c} = __MDPACKH (@var{a}, @var{b})}
14661 @tab @code{MDPACKH @var{a},@var{b},@var{c}}
14662 @item @code{uw2 __MDROTLI (uw2, const)}
14663 @tab @code{@var{c} = __MDROTLI (@var{a}, @var{b})}
14664 @tab @code{MDROTLI @var{a},#@var{b},@var{c}}
14665 @item @code{void __MDSUBACCS (acc, acc)}
14666 @tab @code{__MDSUBACCS (@var{b}, @var{a})}
14667 @tab @code{MDSUBACCS @var{a},@var{b}}
14668 @item @code{void __MDUNPACKH (uw1 *, uw2)}
14669 @tab @code{__MDUNPACKH (&@var{b}, @var{a})}
14670 @tab @code{MDUNPACKH @var{a},@var{b}}
14671 @item @code{uw2 __MEXPDHD (uw1, const)}
14672 @tab @code{@var{c} = __MEXPDHD (@var{a}, @var{b})}
14673 @tab @code{MEXPDHD @var{a},#@var{b},@var{c}}
14674 @item @code{uw1 __MEXPDHW (uw1, const)}
14675 @tab @code{@var{c} = __MEXPDHW (@var{a}, @var{b})}
14676 @tab @code{MEXPDHW @var{a},#@var{b},@var{c}}
14677 @item @code{uw1 __MHDSETH (uw1, const)}
14678 @tab @code{@var{c} = __MHDSETH (@var{a}, @var{b})}
14679 @tab @code{MHDSETH @var{a},#@var{b},@var{c}}
14680 @item @code{sw1 __MHDSETS (const)}
14681 @tab @code{@var{b} = __MHDSETS (@var{a})}
14682 @tab @code{MHDSETS #@var{a},@var{b}}
14683 @item @code{uw1 __MHSETHIH (uw1, const)}
14684 @tab @code{@var{b} = __MHSETHIH (@var{b}, @var{a})}
14685 @tab @code{MHSETHIH #@var{a},@var{b}}
14686 @item @code{sw1 __MHSETHIS (sw1, const)}
14687 @tab @code{@var{b} = __MHSETHIS (@var{b}, @var{a})}
14688 @tab @code{MHSETHIS #@var{a},@var{b}}
14689 @item @code{uw1 __MHSETLOH (uw1, const)}
14690 @tab @code{@var{b} = __MHSETLOH (@var{b}, @var{a})}
14691 @tab @code{MHSETLOH #@var{a},@var{b}}
14692 @item @code{sw1 __MHSETLOS (sw1, const)}
14693 @tab @code{@var{b} = __MHSETLOS (@var{b}, @var{a})}
14694 @tab @code{MHSETLOS #@var{a},@var{b}}
14695 @item @code{uw1 __MHTOB (uw2)}
14696 @tab @code{@var{b} = __MHTOB (@var{a})}
14697 @tab @code{MHTOB @var{a},@var{b}}
14698 @item @code{void __MMACHS (acc, sw1, sw1)}
14699 @tab @code{__MMACHS (@var{c}, @var{a}, @var{b})}
14700 @tab @code{MMACHS @var{a},@var{b},@var{c}}
14701 @item @code{void __MMACHU (acc, uw1, uw1)}
14702 @tab @code{__MMACHU (@var{c}, @var{a}, @var{b})}
14703 @tab @code{MMACHU @var{a},@var{b},@var{c}}
14704 @item @code{void __MMRDHS (acc, sw1, sw1)}
14705 @tab @code{__MMRDHS (@var{c}, @var{a}, @var{b})}
14706 @tab @code{MMRDHS @var{a},@var{b},@var{c}}
14707 @item @code{void __MMRDHU (acc, uw1, uw1)}
14708 @tab @code{__MMRDHU (@var{c}, @var{a}, @var{b})}
14709 @tab @code{MMRDHU @var{a},@var{b},@var{c}}
14710 @item @code{void __MMULHS (acc, sw1, sw1)}
14711 @tab @code{__MMULHS (@var{c}, @var{a}, @var{b})}
14712 @tab @code{MMULHS @var{a},@var{b},@var{c}}
14713 @item @code{void __MMULHU (acc, uw1, uw1)}
14714 @tab @code{__MMULHU (@var{c}, @var{a}, @var{b})}
14715 @tab @code{MMULHU @var{a},@var{b},@var{c}}
14716 @item @code{void __MMULXHS (acc, sw1, sw1)}
14717 @tab @code{__MMULXHS (@var{c}, @var{a}, @var{b})}
14718 @tab @code{MMULXHS @var{a},@var{b},@var{c}}
14719 @item @code{void __MMULXHU (acc, uw1, uw1)}
14720 @tab @code{__MMULXHU (@var{c}, @var{a}, @var{b})}
14721 @tab @code{MMULXHU @var{a},@var{b},@var{c}}
14722 @item @code{uw1 __MNOT (uw1)}
14723 @tab @code{@var{b} = __MNOT (@var{a})}
14724 @tab @code{MNOT @var{a},@var{b}}
14725 @item @code{uw1 __MOR (uw1, uw1)}
14726 @tab @code{@var{c} = __MOR (@var{a}, @var{b})}
14727 @tab @code{MOR @var{a},@var{b},@var{c}}
14728 @item @code{uw1 __MPACKH (uh, uh)}
14729 @tab @code{@var{c} = __MPACKH (@var{a}, @var{b})}
14730 @tab @code{MPACKH @var{a},@var{b},@var{c}}
14731 @item @code{sw2 __MQADDHSS (sw2, sw2)}
14732 @tab @code{@var{c} = __MQADDHSS (@var{a}, @var{b})}
14733 @tab @code{MQADDHSS @var{a},@var{b},@var{c}}
14734 @item @code{uw2 __MQADDHUS (uw2, uw2)}
14735 @tab @code{@var{c} = __MQADDHUS (@var{a}, @var{b})}
14736 @tab @code{MQADDHUS @var{a},@var{b},@var{c}}
14737 @item @code{void __MQCPXIS (acc, sw2, sw2)}
14738 @tab @code{__MQCPXIS (@var{c}, @var{a}, @var{b})}
14739 @tab @code{MQCPXIS @var{a},@var{b},@var{c}}
14740 @item @code{void __MQCPXIU (acc, uw2, uw2)}
14741 @tab @code{__MQCPXIU (@var{c}, @var{a}, @var{b})}
14742 @tab @code{MQCPXIU @var{a},@var{b},@var{c}}
14743 @item @code{void __MQCPXRS (acc, sw2, sw2)}
14744 @tab @code{__MQCPXRS (@var{c}, @var{a}, @var{b})}
14745 @tab @code{MQCPXRS @var{a},@var{b},@var{c}}
14746 @item @code{void __MQCPXRU (acc, uw2, uw2)}
14747 @tab @code{__MQCPXRU (@var{c}, @var{a}, @var{b})}
14748 @tab @code{MQCPXRU @var{a},@var{b},@var{c}}
14749 @item @code{sw2 __MQLCLRHS (sw2, sw2)}
14750 @tab @code{@var{c} = __MQLCLRHS (@var{a}, @var{b})}
14751 @tab @code{MQLCLRHS @var{a},@var{b},@var{c}}
14752 @item @code{sw2 __MQLMTHS (sw2, sw2)}
14753 @tab @code{@var{c} = __MQLMTHS (@var{a}, @var{b})}
14754 @tab @code{MQLMTHS @var{a},@var{b},@var{c}}
14755 @item @code{void __MQMACHS (acc, sw2, sw2)}
14756 @tab @code{__MQMACHS (@var{c}, @var{a}, @var{b})}
14757 @tab @code{MQMACHS @var{a},@var{b},@var{c}}
14758 @item @code{void __MQMACHU (acc, uw2, uw2)}
14759 @tab @code{__MQMACHU (@var{c}, @var{a}, @var{b})}
14760 @tab @code{MQMACHU @var{a},@var{b},@var{c}}
14761 @item @code{void __MQMACXHS (acc, sw2, sw2)}
14762 @tab @code{__MQMACXHS (@var{c}, @var{a}, @var{b})}
14763 @tab @code{MQMACXHS @var{a},@var{b},@var{c}}
14764 @item @code{void __MQMULHS (acc, sw2, sw2)}
14765 @tab @code{__MQMULHS (@var{c}, @var{a}, @var{b})}
14766 @tab @code{MQMULHS @var{a},@var{b},@var{c}}
14767 @item @code{void __MQMULHU (acc, uw2, uw2)}
14768 @tab @code{__MQMULHU (@var{c}, @var{a}, @var{b})}
14769 @tab @code{MQMULHU @var{a},@var{b},@var{c}}
14770 @item @code{void __MQMULXHS (acc, sw2, sw2)}
14771 @tab @code{__MQMULXHS (@var{c}, @var{a}, @var{b})}
14772 @tab @code{MQMULXHS @var{a},@var{b},@var{c}}
14773 @item @code{void __MQMULXHU (acc, uw2, uw2)}
14774 @tab @code{__MQMULXHU (@var{c}, @var{a}, @var{b})}
14775 @tab @code{MQMULXHU @var{a},@var{b},@var{c}}
14776 @item @code{sw2 __MQSATHS (sw2, sw2)}
14777 @tab @code{@var{c} = __MQSATHS (@var{a}, @var{b})}
14778 @tab @code{MQSATHS @var{a},@var{b},@var{c}}
14779 @item @code{uw2 __MQSLLHI (uw2, int)}
14780 @tab @code{@var{c} = __MQSLLHI (@var{a}, @var{b})}
14781 @tab @code{MQSLLHI @var{a},@var{b},@var{c}}
14782 @item @code{sw2 __MQSRAHI (sw2, int)}
14783 @tab @code{@var{c} = __MQSRAHI (@var{a}, @var{b})}
14784 @tab @code{MQSRAHI @var{a},@var{b},@var{c}}
14785 @item @code{sw2 __MQSUBHSS (sw2, sw2)}
14786 @tab @code{@var{c} = __MQSUBHSS (@var{a}, @var{b})}
14787 @tab @code{MQSUBHSS @var{a},@var{b},@var{c}}
14788 @item @code{uw2 __MQSUBHUS (uw2, uw2)}
14789 @tab @code{@var{c} = __MQSUBHUS (@var{a}, @var{b})}
14790 @tab @code{MQSUBHUS @var{a},@var{b},@var{c}}
14791 @item @code{void __MQXMACHS (acc, sw2, sw2)}
14792 @tab @code{__MQXMACHS (@var{c}, @var{a}, @var{b})}
14793 @tab @code{MQXMACHS @var{a},@var{b},@var{c}}
14794 @item @code{void __MQXMACXHS (acc, sw2, sw2)}
14795 @tab @code{__MQXMACXHS (@var{c}, @var{a}, @var{b})}
14796 @tab @code{MQXMACXHS @var{a},@var{b},@var{c}}
14797 @item @code{uw1 __MRDACC (acc)}
14798 @tab @code{@var{b} = __MRDACC (@var{a})}
14799 @tab @code{MRDACC @var{a},@var{b}}
14800 @item @code{uw1 __MRDACCG (acc)}
14801 @tab @code{@var{b} = __MRDACCG (@var{a})}
14802 @tab @code{MRDACCG @var{a},@var{b}}
14803 @item @code{uw1 __MROTLI (uw1, const)}
14804 @tab @code{@var{c} = __MROTLI (@var{a}, @var{b})}
14805 @tab @code{MROTLI @var{a},#@var{b},@var{c}}
14806 @item @code{uw1 __MROTRI (uw1, const)}
14807 @tab @code{@var{c} = __MROTRI (@var{a}, @var{b})}
14808 @tab @code{MROTRI @var{a},#@var{b},@var{c}}
14809 @item @code{sw1 __MSATHS (sw1, sw1)}
14810 @tab @code{@var{c} = __MSATHS (@var{a}, @var{b})}
14811 @tab @code{MSATHS @var{a},@var{b},@var{c}}
14812 @item @code{uw1 __MSATHU (uw1, uw1)}
14813 @tab @code{@var{c} = __MSATHU (@var{a}, @var{b})}
14814 @tab @code{MSATHU @var{a},@var{b},@var{c}}
14815 @item @code{uw1 __MSLLHI (uw1, const)}
14816 @tab @code{@var{c} = __MSLLHI (@var{a}, @var{b})}
14817 @tab @code{MSLLHI @var{a},#@var{b},@var{c}}
14818 @item @code{sw1 __MSRAHI (sw1, const)}
14819 @tab @code{@var{c} = __MSRAHI (@var{a}, @var{b})}
14820 @tab @code{MSRAHI @var{a},#@var{b},@var{c}}
14821 @item @code{uw1 __MSRLHI (uw1, const)}
14822 @tab @code{@var{c} = __MSRLHI (@var{a}, @var{b})}
14823 @tab @code{MSRLHI @var{a},#@var{b},@var{c}}
14824 @item @code{void __MSUBACCS (acc, acc)}
14825 @tab @code{__MSUBACCS (@var{b}, @var{a})}
14826 @tab @code{MSUBACCS @var{a},@var{b}}
14827 @item @code{sw1 __MSUBHSS (sw1, sw1)}
14828 @tab @code{@var{c} = __MSUBHSS (@var{a}, @var{b})}
14829 @tab @code{MSUBHSS @var{a},@var{b},@var{c}}
14830 @item @code{uw1 __MSUBHUS (uw1, uw1)}
14831 @tab @code{@var{c} = __MSUBHUS (@var{a}, @var{b})}
14832 @tab @code{MSUBHUS @var{a},@var{b},@var{c}}
14833 @item @code{void __MTRAP (void)}
14834 @tab @code{__MTRAP ()}
14835 @tab @code{MTRAP}
14836 @item @code{uw2 __MUNPACKH (uw1)}
14837 @tab @code{@var{b} = __MUNPACKH (@var{a})}
14838 @tab @code{MUNPACKH @var{a},@var{b}}
14839 @item @code{uw1 __MWCUT (uw2, uw1)}
14840 @tab @code{@var{c} = __MWCUT (@var{a}, @var{b})}
14841 @tab @code{MWCUT @var{a},@var{b},@var{c}}
14842 @item @code{void __MWTACC (acc, uw1)}
14843 @tab @code{__MWTACC (@var{b}, @var{a})}
14844 @tab @code{MWTACC @var{a},@var{b}}
14845 @item @code{void __MWTACCG (acc, uw1)}
14846 @tab @code{__MWTACCG (@var{b}, @var{a})}
14847 @tab @code{MWTACCG @var{a},@var{b}}
14848 @item @code{uw1 __MXOR (uw1, uw1)}
14849 @tab @code{@var{c} = __MXOR (@var{a}, @var{b})}
14850 @tab @code{MXOR @var{a},@var{b},@var{c}}
14851 @end multitable
14853 @node Raw read/write Functions
14854 @subsubsection Raw Read/Write Functions
14856 This sections describes built-in functions related to read and write
14857 instructions to access memory.  These functions generate
14858 @code{membar} instructions to flush the I/O load and stores where
14859 appropriate, as described in Fujitsu's manual described above.
14861 @table @code
14863 @item unsigned char __builtin_read8 (void *@var{data})
14864 @item unsigned short __builtin_read16 (void *@var{data})
14865 @item unsigned long __builtin_read32 (void *@var{data})
14866 @item unsigned long long __builtin_read64 (void *@var{data})
14868 @item void __builtin_write8 (void *@var{data}, unsigned char @var{datum})
14869 @item void __builtin_write16 (void *@var{data}, unsigned short @var{datum})
14870 @item void __builtin_write32 (void *@var{data}, unsigned long @var{datum})
14871 @item void __builtin_write64 (void *@var{data}, unsigned long long @var{datum})
14872 @end table
14874 @node Other Built-in Functions
14875 @subsubsection Other Built-in Functions
14877 This section describes built-in functions that are not named after
14878 a specific FR-V instruction.
14880 @table @code
14881 @item sw2 __IACCreadll (iacc @var{reg})
14882 Return the full 64-bit value of IACC0@.  The @var{reg} argument is reserved
14883 for future expansion and must be 0.
14885 @item sw1 __IACCreadl (iacc @var{reg})
14886 Return the value of IACC0H if @var{reg} is 0 and IACC0L if @var{reg} is 1.
14887 Other values of @var{reg} are rejected as invalid.
14889 @item void __IACCsetll (iacc @var{reg}, sw2 @var{x})
14890 Set the full 64-bit value of IACC0 to @var{x}.  The @var{reg} argument
14891 is reserved for future expansion and must be 0.
14893 @item void __IACCsetl (iacc @var{reg}, sw1 @var{x})
14894 Set IACC0H to @var{x} if @var{reg} is 0 and IACC0L to @var{x} if @var{reg}
14895 is 1.  Other values of @var{reg} are rejected as invalid.
14897 @item void __data_prefetch0 (const void *@var{x})
14898 Use the @code{dcpl} instruction to load the contents of address @var{x}
14899 into the data cache.
14901 @item void __data_prefetch (const void *@var{x})
14902 Use the @code{nldub} instruction to load the contents of address @var{x}
14903 into the data cache.  The instruction is issued in slot I1@.
14904 @end table
14906 @node MIPS DSP Built-in Functions
14907 @subsection MIPS DSP Built-in Functions
14909 The MIPS DSP Application-Specific Extension (ASE) includes new
14910 instructions that are designed to improve the performance of DSP and
14911 media applications.  It provides instructions that operate on packed
14912 8-bit/16-bit integer data, Q7, Q15 and Q31 fractional data.
14914 GCC supports MIPS DSP operations using both the generic
14915 vector extensions (@pxref{Vector Extensions}) and a collection of
14916 MIPS-specific built-in functions.  Both kinds of support are
14917 enabled by the @option{-mdsp} command-line option.
14919 Revision 2 of the ASE was introduced in the second half of 2006.
14920 This revision adds extra instructions to the original ASE, but is
14921 otherwise backwards-compatible with it.  You can select revision 2
14922 using the command-line option @option{-mdspr2}; this option implies
14923 @option{-mdsp}.
14925 The SCOUNT and POS bits of the DSP control register are global.  The
14926 WRDSP, EXTPDP, EXTPDPV and MTHLIP instructions modify the SCOUNT and
14927 POS bits.  During optimization, the compiler does not delete these
14928 instructions and it does not delete calls to functions containing
14929 these instructions.
14931 At present, GCC only provides support for operations on 32-bit
14932 vectors.  The vector type associated with 8-bit integer data is
14933 usually called @code{v4i8}, the vector type associated with Q7
14934 is usually called @code{v4q7}, the vector type associated with 16-bit
14935 integer data is usually called @code{v2i16}, and the vector type
14936 associated with Q15 is usually called @code{v2q15}.  They can be
14937 defined in C as follows:
14939 @smallexample
14940 typedef signed char v4i8 __attribute__ ((vector_size(4)));
14941 typedef signed char v4q7 __attribute__ ((vector_size(4)));
14942 typedef short v2i16 __attribute__ ((vector_size(4)));
14943 typedef short v2q15 __attribute__ ((vector_size(4)));
14944 @end smallexample
14946 @code{v4i8}, @code{v4q7}, @code{v2i16} and @code{v2q15} values are
14947 initialized in the same way as aggregates.  For example:
14949 @smallexample
14950 v4i8 a = @{1, 2, 3, 4@};
14951 v4i8 b;
14952 b = (v4i8) @{5, 6, 7, 8@};
14954 v2q15 c = @{0x0fcb, 0x3a75@};
14955 v2q15 d;
14956 d = (v2q15) @{0.1234 * 0x1.0p15, 0.4567 * 0x1.0p15@};
14957 @end smallexample
14959 @emph{Note:} The CPU's endianness determines the order in which values
14960 are packed.  On little-endian targets, the first value is the least
14961 significant and the last value is the most significant.  The opposite
14962 order applies to big-endian targets.  For example, the code above
14963 sets the lowest byte of @code{a} to @code{1} on little-endian targets
14964 and @code{4} on big-endian targets.
14966 @emph{Note:} Q7, Q15 and Q31 values must be initialized with their integer
14967 representation.  As shown in this example, the integer representation
14968 of a Q7 value can be obtained by multiplying the fractional value by
14969 @code{0x1.0p7}.  The equivalent for Q15 values is to multiply by
14970 @code{0x1.0p15}.  The equivalent for Q31 values is to multiply by
14971 @code{0x1.0p31}.
14973 The table below lists the @code{v4i8} and @code{v2q15} operations for which
14974 hardware support exists.  @code{a} and @code{b} are @code{v4i8} values,
14975 and @code{c} and @code{d} are @code{v2q15} values.
14977 @multitable @columnfractions .50 .50
14978 @item C code @tab MIPS instruction
14979 @item @code{a + b} @tab @code{addu.qb}
14980 @item @code{c + d} @tab @code{addq.ph}
14981 @item @code{a - b} @tab @code{subu.qb}
14982 @item @code{c - d} @tab @code{subq.ph}
14983 @end multitable
14985 The table below lists the @code{v2i16} operation for which
14986 hardware support exists for the DSP ASE REV 2.  @code{e} and @code{f} are
14987 @code{v2i16} values.
14989 @multitable @columnfractions .50 .50
14990 @item C code @tab MIPS instruction
14991 @item @code{e * f} @tab @code{mul.ph}
14992 @end multitable
14994 It is easier to describe the DSP built-in functions if we first define
14995 the following types:
14997 @smallexample
14998 typedef int q31;
14999 typedef int i32;
15000 typedef unsigned int ui32;
15001 typedef long long a64;
15002 @end smallexample
15004 @code{q31} and @code{i32} are actually the same as @code{int}, but we
15005 use @code{q31} to indicate a Q31 fractional value and @code{i32} to
15006 indicate a 32-bit integer value.  Similarly, @code{a64} is the same as
15007 @code{long long}, but we use @code{a64} to indicate values that are
15008 placed in one of the four DSP accumulators (@code{$ac0},
15009 @code{$ac1}, @code{$ac2} or @code{$ac3}).
15011 Also, some built-in functions prefer or require immediate numbers as
15012 parameters, because the corresponding DSP instructions accept both immediate
15013 numbers and register operands, or accept immediate numbers only.  The
15014 immediate parameters are listed as follows.
15016 @smallexample
15017 imm0_3: 0 to 3.
15018 imm0_7: 0 to 7.
15019 imm0_15: 0 to 15.
15020 imm0_31: 0 to 31.
15021 imm0_63: 0 to 63.
15022 imm0_255: 0 to 255.
15023 imm_n32_31: -32 to 31.
15024 imm_n512_511: -512 to 511.
15025 @end smallexample
15027 The following built-in functions map directly to a particular MIPS DSP
15028 instruction.  Please refer to the architecture specification
15029 for details on what each instruction does.
15031 @smallexample
15032 v2q15 __builtin_mips_addq_ph (v2q15, v2q15)
15033 v2q15 __builtin_mips_addq_s_ph (v2q15, v2q15)
15034 q31 __builtin_mips_addq_s_w (q31, q31)
15035 v4i8 __builtin_mips_addu_qb (v4i8, v4i8)
15036 v4i8 __builtin_mips_addu_s_qb (v4i8, v4i8)
15037 v2q15 __builtin_mips_subq_ph (v2q15, v2q15)
15038 v2q15 __builtin_mips_subq_s_ph (v2q15, v2q15)
15039 q31 __builtin_mips_subq_s_w (q31, q31)
15040 v4i8 __builtin_mips_subu_qb (v4i8, v4i8)
15041 v4i8 __builtin_mips_subu_s_qb (v4i8, v4i8)
15042 i32 __builtin_mips_addsc (i32, i32)
15043 i32 __builtin_mips_addwc (i32, i32)
15044 i32 __builtin_mips_modsub (i32, i32)
15045 i32 __builtin_mips_raddu_w_qb (v4i8)
15046 v2q15 __builtin_mips_absq_s_ph (v2q15)
15047 q31 __builtin_mips_absq_s_w (q31)
15048 v4i8 __builtin_mips_precrq_qb_ph (v2q15, v2q15)
15049 v2q15 __builtin_mips_precrq_ph_w (q31, q31)
15050 v2q15 __builtin_mips_precrq_rs_ph_w (q31, q31)
15051 v4i8 __builtin_mips_precrqu_s_qb_ph (v2q15, v2q15)
15052 q31 __builtin_mips_preceq_w_phl (v2q15)
15053 q31 __builtin_mips_preceq_w_phr (v2q15)
15054 v2q15 __builtin_mips_precequ_ph_qbl (v4i8)
15055 v2q15 __builtin_mips_precequ_ph_qbr (v4i8)
15056 v2q15 __builtin_mips_precequ_ph_qbla (v4i8)
15057 v2q15 __builtin_mips_precequ_ph_qbra (v4i8)
15058 v2q15 __builtin_mips_preceu_ph_qbl (v4i8)
15059 v2q15 __builtin_mips_preceu_ph_qbr (v4i8)
15060 v2q15 __builtin_mips_preceu_ph_qbla (v4i8)
15061 v2q15 __builtin_mips_preceu_ph_qbra (v4i8)
15062 v4i8 __builtin_mips_shll_qb (v4i8, imm0_7)
15063 v4i8 __builtin_mips_shll_qb (v4i8, i32)
15064 v2q15 __builtin_mips_shll_ph (v2q15, imm0_15)
15065 v2q15 __builtin_mips_shll_ph (v2q15, i32)
15066 v2q15 __builtin_mips_shll_s_ph (v2q15, imm0_15)
15067 v2q15 __builtin_mips_shll_s_ph (v2q15, i32)
15068 q31 __builtin_mips_shll_s_w (q31, imm0_31)
15069 q31 __builtin_mips_shll_s_w (q31, i32)
15070 v4i8 __builtin_mips_shrl_qb (v4i8, imm0_7)
15071 v4i8 __builtin_mips_shrl_qb (v4i8, i32)
15072 v2q15 __builtin_mips_shra_ph (v2q15, imm0_15)
15073 v2q15 __builtin_mips_shra_ph (v2q15, i32)
15074 v2q15 __builtin_mips_shra_r_ph (v2q15, imm0_15)
15075 v2q15 __builtin_mips_shra_r_ph (v2q15, i32)
15076 q31 __builtin_mips_shra_r_w (q31, imm0_31)
15077 q31 __builtin_mips_shra_r_w (q31, i32)
15078 v2q15 __builtin_mips_muleu_s_ph_qbl (v4i8, v2q15)
15079 v2q15 __builtin_mips_muleu_s_ph_qbr (v4i8, v2q15)
15080 v2q15 __builtin_mips_mulq_rs_ph (v2q15, v2q15)
15081 q31 __builtin_mips_muleq_s_w_phl (v2q15, v2q15)
15082 q31 __builtin_mips_muleq_s_w_phr (v2q15, v2q15)
15083 a64 __builtin_mips_dpau_h_qbl (a64, v4i8, v4i8)
15084 a64 __builtin_mips_dpau_h_qbr (a64, v4i8, v4i8)
15085 a64 __builtin_mips_dpsu_h_qbl (a64, v4i8, v4i8)
15086 a64 __builtin_mips_dpsu_h_qbr (a64, v4i8, v4i8)
15087 a64 __builtin_mips_dpaq_s_w_ph (a64, v2q15, v2q15)
15088 a64 __builtin_mips_dpaq_sa_l_w (a64, q31, q31)
15089 a64 __builtin_mips_dpsq_s_w_ph (a64, v2q15, v2q15)
15090 a64 __builtin_mips_dpsq_sa_l_w (a64, q31, q31)
15091 a64 __builtin_mips_mulsaq_s_w_ph (a64, v2q15, v2q15)
15092 a64 __builtin_mips_maq_s_w_phl (a64, v2q15, v2q15)
15093 a64 __builtin_mips_maq_s_w_phr (a64, v2q15, v2q15)
15094 a64 __builtin_mips_maq_sa_w_phl (a64, v2q15, v2q15)
15095 a64 __builtin_mips_maq_sa_w_phr (a64, v2q15, v2q15)
15096 i32 __builtin_mips_bitrev (i32)
15097 i32 __builtin_mips_insv (i32, i32)
15098 v4i8 __builtin_mips_repl_qb (imm0_255)
15099 v4i8 __builtin_mips_repl_qb (i32)
15100 v2q15 __builtin_mips_repl_ph (imm_n512_511)
15101 v2q15 __builtin_mips_repl_ph (i32)
15102 void __builtin_mips_cmpu_eq_qb (v4i8, v4i8)
15103 void __builtin_mips_cmpu_lt_qb (v4i8, v4i8)
15104 void __builtin_mips_cmpu_le_qb (v4i8, v4i8)
15105 i32 __builtin_mips_cmpgu_eq_qb (v4i8, v4i8)
15106 i32 __builtin_mips_cmpgu_lt_qb (v4i8, v4i8)
15107 i32 __builtin_mips_cmpgu_le_qb (v4i8, v4i8)
15108 void __builtin_mips_cmp_eq_ph (v2q15, v2q15)
15109 void __builtin_mips_cmp_lt_ph (v2q15, v2q15)
15110 void __builtin_mips_cmp_le_ph (v2q15, v2q15)
15111 v4i8 __builtin_mips_pick_qb (v4i8, v4i8)
15112 v2q15 __builtin_mips_pick_ph (v2q15, v2q15)
15113 v2q15 __builtin_mips_packrl_ph (v2q15, v2q15)
15114 i32 __builtin_mips_extr_w (a64, imm0_31)
15115 i32 __builtin_mips_extr_w (a64, i32)
15116 i32 __builtin_mips_extr_r_w (a64, imm0_31)
15117 i32 __builtin_mips_extr_s_h (a64, i32)
15118 i32 __builtin_mips_extr_rs_w (a64, imm0_31)
15119 i32 __builtin_mips_extr_rs_w (a64, i32)
15120 i32 __builtin_mips_extr_s_h (a64, imm0_31)
15121 i32 __builtin_mips_extr_r_w (a64, i32)
15122 i32 __builtin_mips_extp (a64, imm0_31)
15123 i32 __builtin_mips_extp (a64, i32)
15124 i32 __builtin_mips_extpdp (a64, imm0_31)
15125 i32 __builtin_mips_extpdp (a64, i32)
15126 a64 __builtin_mips_shilo (a64, imm_n32_31)
15127 a64 __builtin_mips_shilo (a64, i32)
15128 a64 __builtin_mips_mthlip (a64, i32)
15129 void __builtin_mips_wrdsp (i32, imm0_63)
15130 i32 __builtin_mips_rddsp (imm0_63)
15131 i32 __builtin_mips_lbux (void *, i32)
15132 i32 __builtin_mips_lhx (void *, i32)
15133 i32 __builtin_mips_lwx (void *, i32)
15134 a64 __builtin_mips_ldx (void *, i32) [MIPS64 only]
15135 i32 __builtin_mips_bposge32 (void)
15136 a64 __builtin_mips_madd (a64, i32, i32);
15137 a64 __builtin_mips_maddu (a64, ui32, ui32);
15138 a64 __builtin_mips_msub (a64, i32, i32);
15139 a64 __builtin_mips_msubu (a64, ui32, ui32);
15140 a64 __builtin_mips_mult (i32, i32);
15141 a64 __builtin_mips_multu (ui32, ui32);
15142 @end smallexample
15144 The following built-in functions map directly to a particular MIPS DSP REV 2
15145 instruction.  Please refer to the architecture specification
15146 for details on what each instruction does.
15148 @smallexample
15149 v4q7 __builtin_mips_absq_s_qb (v4q7);
15150 v2i16 __builtin_mips_addu_ph (v2i16, v2i16);
15151 v2i16 __builtin_mips_addu_s_ph (v2i16, v2i16);
15152 v4i8 __builtin_mips_adduh_qb (v4i8, v4i8);
15153 v4i8 __builtin_mips_adduh_r_qb (v4i8, v4i8);
15154 i32 __builtin_mips_append (i32, i32, imm0_31);
15155 i32 __builtin_mips_balign (i32, i32, imm0_3);
15156 i32 __builtin_mips_cmpgdu_eq_qb (v4i8, v4i8);
15157 i32 __builtin_mips_cmpgdu_lt_qb (v4i8, v4i8);
15158 i32 __builtin_mips_cmpgdu_le_qb (v4i8, v4i8);
15159 a64 __builtin_mips_dpa_w_ph (a64, v2i16, v2i16);
15160 a64 __builtin_mips_dps_w_ph (a64, v2i16, v2i16);
15161 v2i16 __builtin_mips_mul_ph (v2i16, v2i16);
15162 v2i16 __builtin_mips_mul_s_ph (v2i16, v2i16);
15163 q31 __builtin_mips_mulq_rs_w (q31, q31);
15164 v2q15 __builtin_mips_mulq_s_ph (v2q15, v2q15);
15165 q31 __builtin_mips_mulq_s_w (q31, q31);
15166 a64 __builtin_mips_mulsa_w_ph (a64, v2i16, v2i16);
15167 v4i8 __builtin_mips_precr_qb_ph (v2i16, v2i16);
15168 v2i16 __builtin_mips_precr_sra_ph_w (i32, i32, imm0_31);
15169 v2i16 __builtin_mips_precr_sra_r_ph_w (i32, i32, imm0_31);
15170 i32 __builtin_mips_prepend (i32, i32, imm0_31);
15171 v4i8 __builtin_mips_shra_qb (v4i8, imm0_7);
15172 v4i8 __builtin_mips_shra_r_qb (v4i8, imm0_7);
15173 v4i8 __builtin_mips_shra_qb (v4i8, i32);
15174 v4i8 __builtin_mips_shra_r_qb (v4i8, i32);
15175 v2i16 __builtin_mips_shrl_ph (v2i16, imm0_15);
15176 v2i16 __builtin_mips_shrl_ph (v2i16, i32);
15177 v2i16 __builtin_mips_subu_ph (v2i16, v2i16);
15178 v2i16 __builtin_mips_subu_s_ph (v2i16, v2i16);
15179 v4i8 __builtin_mips_subuh_qb (v4i8, v4i8);
15180 v4i8 __builtin_mips_subuh_r_qb (v4i8, v4i8);
15181 v2q15 __builtin_mips_addqh_ph (v2q15, v2q15);
15182 v2q15 __builtin_mips_addqh_r_ph (v2q15, v2q15);
15183 q31 __builtin_mips_addqh_w (q31, q31);
15184 q31 __builtin_mips_addqh_r_w (q31, q31);
15185 v2q15 __builtin_mips_subqh_ph (v2q15, v2q15);
15186 v2q15 __builtin_mips_subqh_r_ph (v2q15, v2q15);
15187 q31 __builtin_mips_subqh_w (q31, q31);
15188 q31 __builtin_mips_subqh_r_w (q31, q31);
15189 a64 __builtin_mips_dpax_w_ph (a64, v2i16, v2i16);
15190 a64 __builtin_mips_dpsx_w_ph (a64, v2i16, v2i16);
15191 a64 __builtin_mips_dpaqx_s_w_ph (a64, v2q15, v2q15);
15192 a64 __builtin_mips_dpaqx_sa_w_ph (a64, v2q15, v2q15);
15193 a64 __builtin_mips_dpsqx_s_w_ph (a64, v2q15, v2q15);
15194 a64 __builtin_mips_dpsqx_sa_w_ph (a64, v2q15, v2q15);
15195 @end smallexample
15198 @node MIPS Paired-Single Support
15199 @subsection MIPS Paired-Single Support
15201 The MIPS64 architecture includes a number of instructions that
15202 operate on pairs of single-precision floating-point values.
15203 Each pair is packed into a 64-bit floating-point register,
15204 with one element being designated the ``upper half'' and
15205 the other being designated the ``lower half''.
15207 GCC supports paired-single operations using both the generic
15208 vector extensions (@pxref{Vector Extensions}) and a collection of
15209 MIPS-specific built-in functions.  Both kinds of support are
15210 enabled by the @option{-mpaired-single} command-line option.
15212 The vector type associated with paired-single values is usually
15213 called @code{v2sf}.  It can be defined in C as follows:
15215 @smallexample
15216 typedef float v2sf __attribute__ ((vector_size (8)));
15217 @end smallexample
15219 @code{v2sf} values are initialized in the same way as aggregates.
15220 For example:
15222 @smallexample
15223 v2sf a = @{1.5, 9.1@};
15224 v2sf b;
15225 float e, f;
15226 b = (v2sf) @{e, f@};
15227 @end smallexample
15229 @emph{Note:} The CPU's endianness determines which value is stored in
15230 the upper half of a register and which value is stored in the lower half.
15231 On little-endian targets, the first value is the lower one and the second
15232 value is the upper one.  The opposite order applies to big-endian targets.
15233 For example, the code above sets the lower half of @code{a} to
15234 @code{1.5} on little-endian targets and @code{9.1} on big-endian targets.
15236 @node MIPS Loongson Built-in Functions
15237 @subsection MIPS Loongson Built-in Functions
15239 GCC provides intrinsics to access the SIMD instructions provided by the
15240 ST Microelectronics Loongson-2E and -2F processors.  These intrinsics,
15241 available after inclusion of the @code{loongson.h} header file,
15242 operate on the following 64-bit vector types:
15244 @itemize
15245 @item @code{uint8x8_t}, a vector of eight unsigned 8-bit integers;
15246 @item @code{uint16x4_t}, a vector of four unsigned 16-bit integers;
15247 @item @code{uint32x2_t}, a vector of two unsigned 32-bit integers;
15248 @item @code{int8x8_t}, a vector of eight signed 8-bit integers;
15249 @item @code{int16x4_t}, a vector of four signed 16-bit integers;
15250 @item @code{int32x2_t}, a vector of two signed 32-bit integers.
15251 @end itemize
15253 The intrinsics provided are listed below; each is named after the
15254 machine instruction to which it corresponds, with suffixes added as
15255 appropriate to distinguish intrinsics that expand to the same machine
15256 instruction yet have different argument types.  Refer to the architecture
15257 documentation for a description of the functionality of each
15258 instruction.
15260 @smallexample
15261 int16x4_t packsswh (int32x2_t s, int32x2_t t);
15262 int8x8_t packsshb (int16x4_t s, int16x4_t t);
15263 uint8x8_t packushb (uint16x4_t s, uint16x4_t t);
15264 uint32x2_t paddw_u (uint32x2_t s, uint32x2_t t);
15265 uint16x4_t paddh_u (uint16x4_t s, uint16x4_t t);
15266 uint8x8_t paddb_u (uint8x8_t s, uint8x8_t t);
15267 int32x2_t paddw_s (int32x2_t s, int32x2_t t);
15268 int16x4_t paddh_s (int16x4_t s, int16x4_t t);
15269 int8x8_t paddb_s (int8x8_t s, int8x8_t t);
15270 uint64_t paddd_u (uint64_t s, uint64_t t);
15271 int64_t paddd_s (int64_t s, int64_t t);
15272 int16x4_t paddsh (int16x4_t s, int16x4_t t);
15273 int8x8_t paddsb (int8x8_t s, int8x8_t t);
15274 uint16x4_t paddush (uint16x4_t s, uint16x4_t t);
15275 uint8x8_t paddusb (uint8x8_t s, uint8x8_t t);
15276 uint64_t pandn_ud (uint64_t s, uint64_t t);
15277 uint32x2_t pandn_uw (uint32x2_t s, uint32x2_t t);
15278 uint16x4_t pandn_uh (uint16x4_t s, uint16x4_t t);
15279 uint8x8_t pandn_ub (uint8x8_t s, uint8x8_t t);
15280 int64_t pandn_sd (int64_t s, int64_t t);
15281 int32x2_t pandn_sw (int32x2_t s, int32x2_t t);
15282 int16x4_t pandn_sh (int16x4_t s, int16x4_t t);
15283 int8x8_t pandn_sb (int8x8_t s, int8x8_t t);
15284 uint16x4_t pavgh (uint16x4_t s, uint16x4_t t);
15285 uint8x8_t pavgb (uint8x8_t s, uint8x8_t t);
15286 uint32x2_t pcmpeqw_u (uint32x2_t s, uint32x2_t t);
15287 uint16x4_t pcmpeqh_u (uint16x4_t s, uint16x4_t t);
15288 uint8x8_t pcmpeqb_u (uint8x8_t s, uint8x8_t t);
15289 int32x2_t pcmpeqw_s (int32x2_t s, int32x2_t t);
15290 int16x4_t pcmpeqh_s (int16x4_t s, int16x4_t t);
15291 int8x8_t pcmpeqb_s (int8x8_t s, int8x8_t t);
15292 uint32x2_t pcmpgtw_u (uint32x2_t s, uint32x2_t t);
15293 uint16x4_t pcmpgth_u (uint16x4_t s, uint16x4_t t);
15294 uint8x8_t pcmpgtb_u (uint8x8_t s, uint8x8_t t);
15295 int32x2_t pcmpgtw_s (int32x2_t s, int32x2_t t);
15296 int16x4_t pcmpgth_s (int16x4_t s, int16x4_t t);
15297 int8x8_t pcmpgtb_s (int8x8_t s, int8x8_t t);
15298 uint16x4_t pextrh_u (uint16x4_t s, int field);
15299 int16x4_t pextrh_s (int16x4_t s, int field);
15300 uint16x4_t pinsrh_0_u (uint16x4_t s, uint16x4_t t);
15301 uint16x4_t pinsrh_1_u (uint16x4_t s, uint16x4_t t);
15302 uint16x4_t pinsrh_2_u (uint16x4_t s, uint16x4_t t);
15303 uint16x4_t pinsrh_3_u (uint16x4_t s, uint16x4_t t);
15304 int16x4_t pinsrh_0_s (int16x4_t s, int16x4_t t);
15305 int16x4_t pinsrh_1_s (int16x4_t s, int16x4_t t);
15306 int16x4_t pinsrh_2_s (int16x4_t s, int16x4_t t);
15307 int16x4_t pinsrh_3_s (int16x4_t s, int16x4_t t);
15308 int32x2_t pmaddhw (int16x4_t s, int16x4_t t);
15309 int16x4_t pmaxsh (int16x4_t s, int16x4_t t);
15310 uint8x8_t pmaxub (uint8x8_t s, uint8x8_t t);
15311 int16x4_t pminsh (int16x4_t s, int16x4_t t);
15312 uint8x8_t pminub (uint8x8_t s, uint8x8_t t);
15313 uint8x8_t pmovmskb_u (uint8x8_t s);
15314 int8x8_t pmovmskb_s (int8x8_t s);
15315 uint16x4_t pmulhuh (uint16x4_t s, uint16x4_t t);
15316 int16x4_t pmulhh (int16x4_t s, int16x4_t t);
15317 int16x4_t pmullh (int16x4_t s, int16x4_t t);
15318 int64_t pmuluw (uint32x2_t s, uint32x2_t t);
15319 uint8x8_t pasubub (uint8x8_t s, uint8x8_t t);
15320 uint16x4_t biadd (uint8x8_t s);
15321 uint16x4_t psadbh (uint8x8_t s, uint8x8_t t);
15322 uint16x4_t pshufh_u (uint16x4_t dest, uint16x4_t s, uint8_t order);
15323 int16x4_t pshufh_s (int16x4_t dest, int16x4_t s, uint8_t order);
15324 uint16x4_t psllh_u (uint16x4_t s, uint8_t amount);
15325 int16x4_t psllh_s (int16x4_t s, uint8_t amount);
15326 uint32x2_t psllw_u (uint32x2_t s, uint8_t amount);
15327 int32x2_t psllw_s (int32x2_t s, uint8_t amount);
15328 uint16x4_t psrlh_u (uint16x4_t s, uint8_t amount);
15329 int16x4_t psrlh_s (int16x4_t s, uint8_t amount);
15330 uint32x2_t psrlw_u (uint32x2_t s, uint8_t amount);
15331 int32x2_t psrlw_s (int32x2_t s, uint8_t amount);
15332 uint16x4_t psrah_u (uint16x4_t s, uint8_t amount);
15333 int16x4_t psrah_s (int16x4_t s, uint8_t amount);
15334 uint32x2_t psraw_u (uint32x2_t s, uint8_t amount);
15335 int32x2_t psraw_s (int32x2_t s, uint8_t amount);
15336 uint32x2_t psubw_u (uint32x2_t s, uint32x2_t t);
15337 uint16x4_t psubh_u (uint16x4_t s, uint16x4_t t);
15338 uint8x8_t psubb_u (uint8x8_t s, uint8x8_t t);
15339 int32x2_t psubw_s (int32x2_t s, int32x2_t t);
15340 int16x4_t psubh_s (int16x4_t s, int16x4_t t);
15341 int8x8_t psubb_s (int8x8_t s, int8x8_t t);
15342 uint64_t psubd_u (uint64_t s, uint64_t t);
15343 int64_t psubd_s (int64_t s, int64_t t);
15344 int16x4_t psubsh (int16x4_t s, int16x4_t t);
15345 int8x8_t psubsb (int8x8_t s, int8x8_t t);
15346 uint16x4_t psubush (uint16x4_t s, uint16x4_t t);
15347 uint8x8_t psubusb (uint8x8_t s, uint8x8_t t);
15348 uint32x2_t punpckhwd_u (uint32x2_t s, uint32x2_t t);
15349 uint16x4_t punpckhhw_u (uint16x4_t s, uint16x4_t t);
15350 uint8x8_t punpckhbh_u (uint8x8_t s, uint8x8_t t);
15351 int32x2_t punpckhwd_s (int32x2_t s, int32x2_t t);
15352 int16x4_t punpckhhw_s (int16x4_t s, int16x4_t t);
15353 int8x8_t punpckhbh_s (int8x8_t s, int8x8_t t);
15354 uint32x2_t punpcklwd_u (uint32x2_t s, uint32x2_t t);
15355 uint16x4_t punpcklhw_u (uint16x4_t s, uint16x4_t t);
15356 uint8x8_t punpcklbh_u (uint8x8_t s, uint8x8_t t);
15357 int32x2_t punpcklwd_s (int32x2_t s, int32x2_t t);
15358 int16x4_t punpcklhw_s (int16x4_t s, int16x4_t t);
15359 int8x8_t punpcklbh_s (int8x8_t s, int8x8_t t);
15360 @end smallexample
15362 @menu
15363 * Paired-Single Arithmetic::
15364 * Paired-Single Built-in Functions::
15365 * MIPS-3D Built-in Functions::
15366 @end menu
15368 @node Paired-Single Arithmetic
15369 @subsubsection Paired-Single Arithmetic
15371 The table below lists the @code{v2sf} operations for which hardware
15372 support exists.  @code{a}, @code{b} and @code{c} are @code{v2sf}
15373 values and @code{x} is an integral value.
15375 @multitable @columnfractions .50 .50
15376 @item C code @tab MIPS instruction
15377 @item @code{a + b} @tab @code{add.ps}
15378 @item @code{a - b} @tab @code{sub.ps}
15379 @item @code{-a} @tab @code{neg.ps}
15380 @item @code{a * b} @tab @code{mul.ps}
15381 @item @code{a * b + c} @tab @code{madd.ps}
15382 @item @code{a * b - c} @tab @code{msub.ps}
15383 @item @code{-(a * b + c)} @tab @code{nmadd.ps}
15384 @item @code{-(a * b - c)} @tab @code{nmsub.ps}
15385 @item @code{x ? a : b} @tab @code{movn.ps}/@code{movz.ps}
15386 @end multitable
15388 Note that the multiply-accumulate instructions can be disabled
15389 using the command-line option @code{-mno-fused-madd}.
15391 @node Paired-Single Built-in Functions
15392 @subsubsection Paired-Single Built-in Functions
15394 The following paired-single functions map directly to a particular
15395 MIPS instruction.  Please refer to the architecture specification
15396 for details on what each instruction does.
15398 @table @code
15399 @item v2sf __builtin_mips_pll_ps (v2sf, v2sf)
15400 Pair lower lower (@code{pll.ps}).
15402 @item v2sf __builtin_mips_pul_ps (v2sf, v2sf)
15403 Pair upper lower (@code{pul.ps}).
15405 @item v2sf __builtin_mips_plu_ps (v2sf, v2sf)
15406 Pair lower upper (@code{plu.ps}).
15408 @item v2sf __builtin_mips_puu_ps (v2sf, v2sf)
15409 Pair upper upper (@code{puu.ps}).
15411 @item v2sf __builtin_mips_cvt_ps_s (float, float)
15412 Convert pair to paired single (@code{cvt.ps.s}).
15414 @item float __builtin_mips_cvt_s_pl (v2sf)
15415 Convert pair lower to single (@code{cvt.s.pl}).
15417 @item float __builtin_mips_cvt_s_pu (v2sf)
15418 Convert pair upper to single (@code{cvt.s.pu}).
15420 @item v2sf __builtin_mips_abs_ps (v2sf)
15421 Absolute value (@code{abs.ps}).
15423 @item v2sf __builtin_mips_alnv_ps (v2sf, v2sf, int)
15424 Align variable (@code{alnv.ps}).
15426 @emph{Note:} The value of the third parameter must be 0 or 4
15427 modulo 8, otherwise the result is unpredictable.  Please read the
15428 instruction description for details.
15429 @end table
15431 The following multi-instruction functions are also available.
15432 In each case, @var{cond} can be any of the 16 floating-point conditions:
15433 @code{f}, @code{un}, @code{eq}, @code{ueq}, @code{olt}, @code{ult},
15434 @code{ole}, @code{ule}, @code{sf}, @code{ngle}, @code{seq}, @code{ngl},
15435 @code{lt}, @code{nge}, @code{le} or @code{ngt}.
15437 @table @code
15438 @item v2sf __builtin_mips_movt_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
15439 @itemx v2sf __builtin_mips_movf_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
15440 Conditional move based on floating-point comparison (@code{c.@var{cond}.ps},
15441 @code{movt.ps}/@code{movf.ps}).
15443 The @code{movt} functions return the value @var{x} computed by:
15445 @smallexample
15446 c.@var{cond}.ps @var{cc},@var{a},@var{b}
15447 mov.ps @var{x},@var{c}
15448 movt.ps @var{x},@var{d},@var{cc}
15449 @end smallexample
15451 The @code{movf} functions are similar but use @code{movf.ps} instead
15452 of @code{movt.ps}.
15454 @item int __builtin_mips_upper_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
15455 @itemx int __builtin_mips_lower_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
15456 Comparison of two paired-single values (@code{c.@var{cond}.ps},
15457 @code{bc1t}/@code{bc1f}).
15459 These functions compare @var{a} and @var{b} using @code{c.@var{cond}.ps}
15460 and return either the upper or lower half of the result.  For example:
15462 @smallexample
15463 v2sf a, b;
15464 if (__builtin_mips_upper_c_eq_ps (a, b))
15465   upper_halves_are_equal ();
15466 else
15467   upper_halves_are_unequal ();
15469 if (__builtin_mips_lower_c_eq_ps (a, b))
15470   lower_halves_are_equal ();
15471 else
15472   lower_halves_are_unequal ();
15473 @end smallexample
15474 @end table
15476 @node MIPS-3D Built-in Functions
15477 @subsubsection MIPS-3D Built-in Functions
15479 The MIPS-3D Application-Specific Extension (ASE) includes additional
15480 paired-single instructions that are designed to improve the performance
15481 of 3D graphics operations.  Support for these instructions is controlled
15482 by the @option{-mips3d} command-line option.
15484 The functions listed below map directly to a particular MIPS-3D
15485 instruction.  Please refer to the architecture specification for
15486 more details on what each instruction does.
15488 @table @code
15489 @item v2sf __builtin_mips_addr_ps (v2sf, v2sf)
15490 Reduction add (@code{addr.ps}).
15492 @item v2sf __builtin_mips_mulr_ps (v2sf, v2sf)
15493 Reduction multiply (@code{mulr.ps}).
15495 @item v2sf __builtin_mips_cvt_pw_ps (v2sf)
15496 Convert paired single to paired word (@code{cvt.pw.ps}).
15498 @item v2sf __builtin_mips_cvt_ps_pw (v2sf)
15499 Convert paired word to paired single (@code{cvt.ps.pw}).
15501 @item float __builtin_mips_recip1_s (float)
15502 @itemx double __builtin_mips_recip1_d (double)
15503 @itemx v2sf __builtin_mips_recip1_ps (v2sf)
15504 Reduced-precision reciprocal (sequence step 1) (@code{recip1.@var{fmt}}).
15506 @item float __builtin_mips_recip2_s (float, float)
15507 @itemx double __builtin_mips_recip2_d (double, double)
15508 @itemx v2sf __builtin_mips_recip2_ps (v2sf, v2sf)
15509 Reduced-precision reciprocal (sequence step 2) (@code{recip2.@var{fmt}}).
15511 @item float __builtin_mips_rsqrt1_s (float)
15512 @itemx double __builtin_mips_rsqrt1_d (double)
15513 @itemx v2sf __builtin_mips_rsqrt1_ps (v2sf)
15514 Reduced-precision reciprocal square root (sequence step 1)
15515 (@code{rsqrt1.@var{fmt}}).
15517 @item float __builtin_mips_rsqrt2_s (float, float)
15518 @itemx double __builtin_mips_rsqrt2_d (double, double)
15519 @itemx v2sf __builtin_mips_rsqrt2_ps (v2sf, v2sf)
15520 Reduced-precision reciprocal square root (sequence step 2)
15521 (@code{rsqrt2.@var{fmt}}).
15522 @end table
15524 The following multi-instruction functions are also available.
15525 In each case, @var{cond} can be any of the 16 floating-point conditions:
15526 @code{f}, @code{un}, @code{eq}, @code{ueq}, @code{olt}, @code{ult},
15527 @code{ole}, @code{ule}, @code{sf}, @code{ngle}, @code{seq},
15528 @code{ngl}, @code{lt}, @code{nge}, @code{le} or @code{ngt}.
15530 @table @code
15531 @item int __builtin_mips_cabs_@var{cond}_s (float @var{a}, float @var{b})
15532 @itemx int __builtin_mips_cabs_@var{cond}_d (double @var{a}, double @var{b})
15533 Absolute comparison of two scalar values (@code{cabs.@var{cond}.@var{fmt}},
15534 @code{bc1t}/@code{bc1f}).
15536 These functions compare @var{a} and @var{b} using @code{cabs.@var{cond}.s}
15537 or @code{cabs.@var{cond}.d} and return the result as a boolean value.
15538 For example:
15540 @smallexample
15541 float a, b;
15542 if (__builtin_mips_cabs_eq_s (a, b))
15543   true ();
15544 else
15545   false ();
15546 @end smallexample
15548 @item int __builtin_mips_upper_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
15549 @itemx int __builtin_mips_lower_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
15550 Absolute comparison of two paired-single values (@code{cabs.@var{cond}.ps},
15551 @code{bc1t}/@code{bc1f}).
15553 These functions compare @var{a} and @var{b} using @code{cabs.@var{cond}.ps}
15554 and return either the upper or lower half of the result.  For example:
15556 @smallexample
15557 v2sf a, b;
15558 if (__builtin_mips_upper_cabs_eq_ps (a, b))
15559   upper_halves_are_equal ();
15560 else
15561   upper_halves_are_unequal ();
15563 if (__builtin_mips_lower_cabs_eq_ps (a, b))
15564   lower_halves_are_equal ();
15565 else
15566   lower_halves_are_unequal ();
15567 @end smallexample
15569 @item v2sf __builtin_mips_movt_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
15570 @itemx v2sf __builtin_mips_movf_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
15571 Conditional move based on absolute comparison (@code{cabs.@var{cond}.ps},
15572 @code{movt.ps}/@code{movf.ps}).
15574 The @code{movt} functions return the value @var{x} computed by:
15576 @smallexample
15577 cabs.@var{cond}.ps @var{cc},@var{a},@var{b}
15578 mov.ps @var{x},@var{c}
15579 movt.ps @var{x},@var{d},@var{cc}
15580 @end smallexample
15582 The @code{movf} functions are similar but use @code{movf.ps} instead
15583 of @code{movt.ps}.
15585 @item int __builtin_mips_any_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
15586 @itemx int __builtin_mips_all_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
15587 @itemx int __builtin_mips_any_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
15588 @itemx int __builtin_mips_all_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
15589 Comparison of two paired-single values
15590 (@code{c.@var{cond}.ps}/@code{cabs.@var{cond}.ps},
15591 @code{bc1any2t}/@code{bc1any2f}).
15593 These functions compare @var{a} and @var{b} using @code{c.@var{cond}.ps}
15594 or @code{cabs.@var{cond}.ps}.  The @code{any} forms return @code{true} if either
15595 result is @code{true} and the @code{all} forms return @code{true} if both results are @code{true}.
15596 For example:
15598 @smallexample
15599 v2sf a, b;
15600 if (__builtin_mips_any_c_eq_ps (a, b))
15601   one_is_true ();
15602 else
15603   both_are_false ();
15605 if (__builtin_mips_all_c_eq_ps (a, b))
15606   both_are_true ();
15607 else
15608   one_is_false ();
15609 @end smallexample
15611 @item int __builtin_mips_any_c_@var{cond}_4s (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
15612 @itemx int __builtin_mips_all_c_@var{cond}_4s (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
15613 @itemx int __builtin_mips_any_cabs_@var{cond}_4s (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
15614 @itemx int __builtin_mips_all_cabs_@var{cond}_4s (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
15615 Comparison of four paired-single values
15616 (@code{c.@var{cond}.ps}/@code{cabs.@var{cond}.ps},
15617 @code{bc1any4t}/@code{bc1any4f}).
15619 These functions use @code{c.@var{cond}.ps} or @code{cabs.@var{cond}.ps}
15620 to compare @var{a} with @var{b} and to compare @var{c} with @var{d}.
15621 The @code{any} forms return @code{true} if any of the four results are @code{true}
15622 and the @code{all} forms return @code{true} if all four results are @code{true}.
15623 For example:
15625 @smallexample
15626 v2sf a, b, c, d;
15627 if (__builtin_mips_any_c_eq_4s (a, b, c, d))
15628   some_are_true ();
15629 else
15630   all_are_false ();
15632 if (__builtin_mips_all_c_eq_4s (a, b, c, d))
15633   all_are_true ();
15634 else
15635   some_are_false ();
15636 @end smallexample
15637 @end table
15639 @node MIPS SIMD Architecture (MSA) Support
15640 @subsection MIPS SIMD Architecture (MSA) Support
15642 @menu
15643 * MIPS SIMD Architecture Built-in Functions::
15644 @end menu
15646 GCC provides intrinsics to access the SIMD instructions provided by the
15647 MSA MIPS SIMD Architecture.  The interface is made available by including
15648 @code{<msa.h>} and using @option{-mmsa -mhard-float -mfp64 -mnan=2008}.
15649 For each @code{__builtin_msa_*}, there is a shortened name of the intrinsic,
15650 @code{__msa_*}.
15652 MSA implements 128-bit wide vector registers, operating on 8-, 16-, 32- and
15653 64-bit integer, 16- and 32-bit fixed-point, or 32- and 64-bit floating point
15654 data elements.  The following vectors typedefs are included in @code{msa.h}:
15655 @itemize
15656 @item @code{v16i8}, a vector of sixteen signed 8-bit integers;
15657 @item @code{v16u8}, a vector of sixteen unsigned 8-bit integers;
15658 @item @code{v8i16}, a vector of eight signed 16-bit integers;
15659 @item @code{v8u16}, a vector of eight unsigned 16-bit integers;
15660 @item @code{v4i32}, a vector of four signed 32-bit integers;
15661 @item @code{v4u32}, a vector of four unsigned 32-bit integers;
15662 @item @code{v2i64}, a vector of two signed 64-bit integers;
15663 @item @code{v2u64}, a vector of two unsigned 64-bit integers;
15664 @item @code{v4f32}, a vector of four 32-bit floats;
15665 @item @code{v2f64}, a vector of two 64-bit doubles.
15666 @end itemize
15668 Instructions and corresponding built-ins may have additional restrictions and/or
15669 input/output values manipulated:
15670 @itemize
15671 @item @code{imm0_1}, an integer literal in range 0 to 1;
15672 @item @code{imm0_3}, an integer literal in range 0 to 3;
15673 @item @code{imm0_7}, an integer literal in range 0 to 7;
15674 @item @code{imm0_15}, an integer literal in range 0 to 15;
15675 @item @code{imm0_31}, an integer literal in range 0 to 31;
15676 @item @code{imm0_63}, an integer literal in range 0 to 63;
15677 @item @code{imm0_255}, an integer literal in range 0 to 255;
15678 @item @code{imm_n16_15}, an integer literal in range -16 to 15;
15679 @item @code{imm_n512_511}, an integer literal in range -512 to 511;
15680 @item @code{imm_n1024_1022}, an integer literal in range -512 to 511 left
15681 shifted by 1 bit, i.e., -1024, -1022, @dots{}, 1020, 1022;
15682 @item @code{imm_n2048_2044}, an integer literal in range -512 to 511 left
15683 shifted by 2 bits, i.e., -2048, -2044, @dots{}, 2040, 2044;
15684 @item @code{imm_n4096_4088}, an integer literal in range -512 to 511 left
15685 shifted by 3 bits, i.e., -4096, -4088, @dots{}, 4080, 4088;
15686 @item @code{imm1_4}, an integer literal in range 1 to 4;
15687 @item @code{i32, i64, u32, u64, f32, f64}, defined as follows:
15688 @end itemize
15690 @smallexample
15692 typedef int i32;
15693 #if __LONG_MAX__ == __LONG_LONG_MAX__
15694 typedef long i64;
15695 #else
15696 typedef long long i64;
15697 #endif
15699 typedef unsigned int u32;
15700 #if __LONG_MAX__ == __LONG_LONG_MAX__
15701 typedef unsigned long u64;
15702 #else
15703 typedef unsigned long long u64;
15704 #endif
15706 typedef double f64;
15707 typedef float f32;
15709 @end smallexample
15711 @node MIPS SIMD Architecture Built-in Functions
15712 @subsubsection MIPS SIMD Architecture Built-in Functions
15714 The intrinsics provided are listed below; each is named after the
15715 machine instruction.
15717 @smallexample
15718 v16i8 __builtin_msa_add_a_b (v16i8, v16i8);
15719 v8i16 __builtin_msa_add_a_h (v8i16, v8i16);
15720 v4i32 __builtin_msa_add_a_w (v4i32, v4i32);
15721 v2i64 __builtin_msa_add_a_d (v2i64, v2i64);
15723 v16i8 __builtin_msa_adds_a_b (v16i8, v16i8);
15724 v8i16 __builtin_msa_adds_a_h (v8i16, v8i16);
15725 v4i32 __builtin_msa_adds_a_w (v4i32, v4i32);
15726 v2i64 __builtin_msa_adds_a_d (v2i64, v2i64);
15728 v16i8 __builtin_msa_adds_s_b (v16i8, v16i8);
15729 v8i16 __builtin_msa_adds_s_h (v8i16, v8i16);
15730 v4i32 __builtin_msa_adds_s_w (v4i32, v4i32);
15731 v2i64 __builtin_msa_adds_s_d (v2i64, v2i64);
15733 v16u8 __builtin_msa_adds_u_b (v16u8, v16u8);
15734 v8u16 __builtin_msa_adds_u_h (v8u16, v8u16);
15735 v4u32 __builtin_msa_adds_u_w (v4u32, v4u32);
15736 v2u64 __builtin_msa_adds_u_d (v2u64, v2u64);
15738 v16i8 __builtin_msa_addv_b (v16i8, v16i8);
15739 v8i16 __builtin_msa_addv_h (v8i16, v8i16);
15740 v4i32 __builtin_msa_addv_w (v4i32, v4i32);
15741 v2i64 __builtin_msa_addv_d (v2i64, v2i64);
15743 v16i8 __builtin_msa_addvi_b (v16i8, imm0_31);
15744 v8i16 __builtin_msa_addvi_h (v8i16, imm0_31);
15745 v4i32 __builtin_msa_addvi_w (v4i32, imm0_31);
15746 v2i64 __builtin_msa_addvi_d (v2i64, imm0_31);
15748 v16u8 __builtin_msa_and_v (v16u8, v16u8);
15750 v16u8 __builtin_msa_andi_b (v16u8, imm0_255);
15752 v16i8 __builtin_msa_asub_s_b (v16i8, v16i8);
15753 v8i16 __builtin_msa_asub_s_h (v8i16, v8i16);
15754 v4i32 __builtin_msa_asub_s_w (v4i32, v4i32);
15755 v2i64 __builtin_msa_asub_s_d (v2i64, v2i64);
15757 v16u8 __builtin_msa_asub_u_b (v16u8, v16u8);
15758 v8u16 __builtin_msa_asub_u_h (v8u16, v8u16);
15759 v4u32 __builtin_msa_asub_u_w (v4u32, v4u32);
15760 v2u64 __builtin_msa_asub_u_d (v2u64, v2u64);
15762 v16i8 __builtin_msa_ave_s_b (v16i8, v16i8);
15763 v8i16 __builtin_msa_ave_s_h (v8i16, v8i16);
15764 v4i32 __builtin_msa_ave_s_w (v4i32, v4i32);
15765 v2i64 __builtin_msa_ave_s_d (v2i64, v2i64);
15767 v16u8 __builtin_msa_ave_u_b (v16u8, v16u8);
15768 v8u16 __builtin_msa_ave_u_h (v8u16, v8u16);
15769 v4u32 __builtin_msa_ave_u_w (v4u32, v4u32);
15770 v2u64 __builtin_msa_ave_u_d (v2u64, v2u64);
15772 v16i8 __builtin_msa_aver_s_b (v16i8, v16i8);
15773 v8i16 __builtin_msa_aver_s_h (v8i16, v8i16);
15774 v4i32 __builtin_msa_aver_s_w (v4i32, v4i32);
15775 v2i64 __builtin_msa_aver_s_d (v2i64, v2i64);
15777 v16u8 __builtin_msa_aver_u_b (v16u8, v16u8);
15778 v8u16 __builtin_msa_aver_u_h (v8u16, v8u16);
15779 v4u32 __builtin_msa_aver_u_w (v4u32, v4u32);
15780 v2u64 __builtin_msa_aver_u_d (v2u64, v2u64);
15782 v16u8 __builtin_msa_bclr_b (v16u8, v16u8);
15783 v8u16 __builtin_msa_bclr_h (v8u16, v8u16);
15784 v4u32 __builtin_msa_bclr_w (v4u32, v4u32);
15785 v2u64 __builtin_msa_bclr_d (v2u64, v2u64);
15787 v16u8 __builtin_msa_bclri_b (v16u8, imm0_7);
15788 v8u16 __builtin_msa_bclri_h (v8u16, imm0_15);
15789 v4u32 __builtin_msa_bclri_w (v4u32, imm0_31);
15790 v2u64 __builtin_msa_bclri_d (v2u64, imm0_63);
15792 v16u8 __builtin_msa_binsl_b (v16u8, v16u8, v16u8);
15793 v8u16 __builtin_msa_binsl_h (v8u16, v8u16, v8u16);
15794 v4u32 __builtin_msa_binsl_w (v4u32, v4u32, v4u32);
15795 v2u64 __builtin_msa_binsl_d (v2u64, v2u64, v2u64);
15797 v16u8 __builtin_msa_binsli_b (v16u8, v16u8, imm0_7);
15798 v8u16 __builtin_msa_binsli_h (v8u16, v8u16, imm0_15);
15799 v4u32 __builtin_msa_binsli_w (v4u32, v4u32, imm0_31);
15800 v2u64 __builtin_msa_binsli_d (v2u64, v2u64, imm0_63);
15802 v16u8 __builtin_msa_binsr_b (v16u8, v16u8, v16u8);
15803 v8u16 __builtin_msa_binsr_h (v8u16, v8u16, v8u16);
15804 v4u32 __builtin_msa_binsr_w (v4u32, v4u32, v4u32);
15805 v2u64 __builtin_msa_binsr_d (v2u64, v2u64, v2u64);
15807 v16u8 __builtin_msa_binsri_b (v16u8, v16u8, imm0_7);
15808 v8u16 __builtin_msa_binsri_h (v8u16, v8u16, imm0_15);
15809 v4u32 __builtin_msa_binsri_w (v4u32, v4u32, imm0_31);
15810 v2u64 __builtin_msa_binsri_d (v2u64, v2u64, imm0_63);
15812 v16u8 __builtin_msa_bmnz_v (v16u8, v16u8, v16u8);
15814 v16u8 __builtin_msa_bmnzi_b (v16u8, v16u8, imm0_255);
15816 v16u8 __builtin_msa_bmz_v (v16u8, v16u8, v16u8);
15818 v16u8 __builtin_msa_bmzi_b (v16u8, v16u8, imm0_255);
15820 v16u8 __builtin_msa_bneg_b (v16u8, v16u8);
15821 v8u16 __builtin_msa_bneg_h (v8u16, v8u16);
15822 v4u32 __builtin_msa_bneg_w (v4u32, v4u32);
15823 v2u64 __builtin_msa_bneg_d (v2u64, v2u64);
15825 v16u8 __builtin_msa_bnegi_b (v16u8, imm0_7);
15826 v8u16 __builtin_msa_bnegi_h (v8u16, imm0_15);
15827 v4u32 __builtin_msa_bnegi_w (v4u32, imm0_31);
15828 v2u64 __builtin_msa_bnegi_d (v2u64, imm0_63);
15830 i32 __builtin_msa_bnz_b (v16u8);
15831 i32 __builtin_msa_bnz_h (v8u16);
15832 i32 __builtin_msa_bnz_w (v4u32);
15833 i32 __builtin_msa_bnz_d (v2u64);
15835 i32 __builtin_msa_bnz_v (v16u8);
15837 v16u8 __builtin_msa_bsel_v (v16u8, v16u8, v16u8);
15839 v16u8 __builtin_msa_bseli_b (v16u8, v16u8, imm0_255);
15841 v16u8 __builtin_msa_bset_b (v16u8, v16u8);
15842 v8u16 __builtin_msa_bset_h (v8u16, v8u16);
15843 v4u32 __builtin_msa_bset_w (v4u32, v4u32);
15844 v2u64 __builtin_msa_bset_d (v2u64, v2u64);
15846 v16u8 __builtin_msa_bseti_b (v16u8, imm0_7);
15847 v8u16 __builtin_msa_bseti_h (v8u16, imm0_15);
15848 v4u32 __builtin_msa_bseti_w (v4u32, imm0_31);
15849 v2u64 __builtin_msa_bseti_d (v2u64, imm0_63);
15851 i32 __builtin_msa_bz_b (v16u8);
15852 i32 __builtin_msa_bz_h (v8u16);
15853 i32 __builtin_msa_bz_w (v4u32);
15854 i32 __builtin_msa_bz_d (v2u64);
15856 i32 __builtin_msa_bz_v (v16u8);
15858 v16i8 __builtin_msa_ceq_b (v16i8, v16i8);
15859 v8i16 __builtin_msa_ceq_h (v8i16, v8i16);
15860 v4i32 __builtin_msa_ceq_w (v4i32, v4i32);
15861 v2i64 __builtin_msa_ceq_d (v2i64, v2i64);
15863 v16i8 __builtin_msa_ceqi_b (v16i8, imm_n16_15);
15864 v8i16 __builtin_msa_ceqi_h (v8i16, imm_n16_15);
15865 v4i32 __builtin_msa_ceqi_w (v4i32, imm_n16_15);
15866 v2i64 __builtin_msa_ceqi_d (v2i64, imm_n16_15);
15868 i32 __builtin_msa_cfcmsa (imm0_31);
15870 v16i8 __builtin_msa_cle_s_b (v16i8, v16i8);
15871 v8i16 __builtin_msa_cle_s_h (v8i16, v8i16);
15872 v4i32 __builtin_msa_cle_s_w (v4i32, v4i32);
15873 v2i64 __builtin_msa_cle_s_d (v2i64, v2i64);
15875 v16i8 __builtin_msa_cle_u_b (v16u8, v16u8);
15876 v8i16 __builtin_msa_cle_u_h (v8u16, v8u16);
15877 v4i32 __builtin_msa_cle_u_w (v4u32, v4u32);
15878 v2i64 __builtin_msa_cle_u_d (v2u64, v2u64);
15880 v16i8 __builtin_msa_clei_s_b (v16i8, imm_n16_15);
15881 v8i16 __builtin_msa_clei_s_h (v8i16, imm_n16_15);
15882 v4i32 __builtin_msa_clei_s_w (v4i32, imm_n16_15);
15883 v2i64 __builtin_msa_clei_s_d (v2i64, imm_n16_15);
15885 v16i8 __builtin_msa_clei_u_b (v16u8, imm0_31);
15886 v8i16 __builtin_msa_clei_u_h (v8u16, imm0_31);
15887 v4i32 __builtin_msa_clei_u_w (v4u32, imm0_31);
15888 v2i64 __builtin_msa_clei_u_d (v2u64, imm0_31);
15890 v16i8 __builtin_msa_clt_s_b (v16i8, v16i8);
15891 v8i16 __builtin_msa_clt_s_h (v8i16, v8i16);
15892 v4i32 __builtin_msa_clt_s_w (v4i32, v4i32);
15893 v2i64 __builtin_msa_clt_s_d (v2i64, v2i64);
15895 v16i8 __builtin_msa_clt_u_b (v16u8, v16u8);
15896 v8i16 __builtin_msa_clt_u_h (v8u16, v8u16);
15897 v4i32 __builtin_msa_clt_u_w (v4u32, v4u32);
15898 v2i64 __builtin_msa_clt_u_d (v2u64, v2u64);
15900 v16i8 __builtin_msa_clti_s_b (v16i8, imm_n16_15);
15901 v8i16 __builtin_msa_clti_s_h (v8i16, imm_n16_15);
15902 v4i32 __builtin_msa_clti_s_w (v4i32, imm_n16_15);
15903 v2i64 __builtin_msa_clti_s_d (v2i64, imm_n16_15);
15905 v16i8 __builtin_msa_clti_u_b (v16u8, imm0_31);
15906 v8i16 __builtin_msa_clti_u_h (v8u16, imm0_31);
15907 v4i32 __builtin_msa_clti_u_w (v4u32, imm0_31);
15908 v2i64 __builtin_msa_clti_u_d (v2u64, imm0_31);
15910 i32 __builtin_msa_copy_s_b (v16i8, imm0_15);
15911 i32 __builtin_msa_copy_s_h (v8i16, imm0_7);
15912 i32 __builtin_msa_copy_s_w (v4i32, imm0_3);
15913 i64 __builtin_msa_copy_s_d (v2i64, imm0_1);
15915 u32 __builtin_msa_copy_u_b (v16i8, imm0_15);
15916 u32 __builtin_msa_copy_u_h (v8i16, imm0_7);
15917 u32 __builtin_msa_copy_u_w (v4i32, imm0_3);
15918 u64 __builtin_msa_copy_u_d (v2i64, imm0_1);
15920 void __builtin_msa_ctcmsa (imm0_31, i32);
15922 v16i8 __builtin_msa_div_s_b (v16i8, v16i8);
15923 v8i16 __builtin_msa_div_s_h (v8i16, v8i16);
15924 v4i32 __builtin_msa_div_s_w (v4i32, v4i32);
15925 v2i64 __builtin_msa_div_s_d (v2i64, v2i64);
15927 v16u8 __builtin_msa_div_u_b (v16u8, v16u8);
15928 v8u16 __builtin_msa_div_u_h (v8u16, v8u16);
15929 v4u32 __builtin_msa_div_u_w (v4u32, v4u32);
15930 v2u64 __builtin_msa_div_u_d (v2u64, v2u64);
15932 v8i16 __builtin_msa_dotp_s_h (v16i8, v16i8);
15933 v4i32 __builtin_msa_dotp_s_w (v8i16, v8i16);
15934 v2i64 __builtin_msa_dotp_s_d (v4i32, v4i32);
15936 v8u16 __builtin_msa_dotp_u_h (v16u8, v16u8);
15937 v4u32 __builtin_msa_dotp_u_w (v8u16, v8u16);
15938 v2u64 __builtin_msa_dotp_u_d (v4u32, v4u32);
15940 v8i16 __builtin_msa_dpadd_s_h (v8i16, v16i8, v16i8);
15941 v4i32 __builtin_msa_dpadd_s_w (v4i32, v8i16, v8i16);
15942 v2i64 __builtin_msa_dpadd_s_d (v2i64, v4i32, v4i32);
15944 v8u16 __builtin_msa_dpadd_u_h (v8u16, v16u8, v16u8);
15945 v4u32 __builtin_msa_dpadd_u_w (v4u32, v8u16, v8u16);
15946 v2u64 __builtin_msa_dpadd_u_d (v2u64, v4u32, v4u32);
15948 v8i16 __builtin_msa_dpsub_s_h (v8i16, v16i8, v16i8);
15949 v4i32 __builtin_msa_dpsub_s_w (v4i32, v8i16, v8i16);
15950 v2i64 __builtin_msa_dpsub_s_d (v2i64, v4i32, v4i32);
15952 v8i16 __builtin_msa_dpsub_u_h (v8i16, v16u8, v16u8);
15953 v4i32 __builtin_msa_dpsub_u_w (v4i32, v8u16, v8u16);
15954 v2i64 __builtin_msa_dpsub_u_d (v2i64, v4u32, v4u32);
15956 v4f32 __builtin_msa_fadd_w (v4f32, v4f32);
15957 v2f64 __builtin_msa_fadd_d (v2f64, v2f64);
15959 v4i32 __builtin_msa_fcaf_w (v4f32, v4f32);
15960 v2i64 __builtin_msa_fcaf_d (v2f64, v2f64);
15962 v4i32 __builtin_msa_fceq_w (v4f32, v4f32);
15963 v2i64 __builtin_msa_fceq_d (v2f64, v2f64);
15965 v4i32 __builtin_msa_fclass_w (v4f32);
15966 v2i64 __builtin_msa_fclass_d (v2f64);
15968 v4i32 __builtin_msa_fcle_w (v4f32, v4f32);
15969 v2i64 __builtin_msa_fcle_d (v2f64, v2f64);
15971 v4i32 __builtin_msa_fclt_w (v4f32, v4f32);
15972 v2i64 __builtin_msa_fclt_d (v2f64, v2f64);
15974 v4i32 __builtin_msa_fcne_w (v4f32, v4f32);
15975 v2i64 __builtin_msa_fcne_d (v2f64, v2f64);
15977 v4i32 __builtin_msa_fcor_w (v4f32, v4f32);
15978 v2i64 __builtin_msa_fcor_d (v2f64, v2f64);
15980 v4i32 __builtin_msa_fcueq_w (v4f32, v4f32);
15981 v2i64 __builtin_msa_fcueq_d (v2f64, v2f64);
15983 v4i32 __builtin_msa_fcule_w (v4f32, v4f32);
15984 v2i64 __builtin_msa_fcule_d (v2f64, v2f64);
15986 v4i32 __builtin_msa_fcult_w (v4f32, v4f32);
15987 v2i64 __builtin_msa_fcult_d (v2f64, v2f64);
15989 v4i32 __builtin_msa_fcun_w (v4f32, v4f32);
15990 v2i64 __builtin_msa_fcun_d (v2f64, v2f64);
15992 v4i32 __builtin_msa_fcune_w (v4f32, v4f32);
15993 v2i64 __builtin_msa_fcune_d (v2f64, v2f64);
15995 v4f32 __builtin_msa_fdiv_w (v4f32, v4f32);
15996 v2f64 __builtin_msa_fdiv_d (v2f64, v2f64);
15998 v8i16 __builtin_msa_fexdo_h (v4f32, v4f32);
15999 v4f32 __builtin_msa_fexdo_w (v2f64, v2f64);
16001 v4f32 __builtin_msa_fexp2_w (v4f32, v4i32);
16002 v2f64 __builtin_msa_fexp2_d (v2f64, v2i64);
16004 v4f32 __builtin_msa_fexupl_w (v8i16);
16005 v2f64 __builtin_msa_fexupl_d (v4f32);
16007 v4f32 __builtin_msa_fexupr_w (v8i16);
16008 v2f64 __builtin_msa_fexupr_d (v4f32);
16010 v4f32 __builtin_msa_ffint_s_w (v4i32);
16011 v2f64 __builtin_msa_ffint_s_d (v2i64);
16013 v4f32 __builtin_msa_ffint_u_w (v4u32);
16014 v2f64 __builtin_msa_ffint_u_d (v2u64);
16016 v4f32 __builtin_msa_ffql_w (v8i16);
16017 v2f64 __builtin_msa_ffql_d (v4i32);
16019 v4f32 __builtin_msa_ffqr_w (v8i16);
16020 v2f64 __builtin_msa_ffqr_d (v4i32);
16022 v16i8 __builtin_msa_fill_b (i32);
16023 v8i16 __builtin_msa_fill_h (i32);
16024 v4i32 __builtin_msa_fill_w (i32);
16025 v2i64 __builtin_msa_fill_d (i64);
16027 v4f32 __builtin_msa_flog2_w (v4f32);
16028 v2f64 __builtin_msa_flog2_d (v2f64);
16030 v4f32 __builtin_msa_fmadd_w (v4f32, v4f32, v4f32);
16031 v2f64 __builtin_msa_fmadd_d (v2f64, v2f64, v2f64);
16033 v4f32 __builtin_msa_fmax_w (v4f32, v4f32);
16034 v2f64 __builtin_msa_fmax_d (v2f64, v2f64);
16036 v4f32 __builtin_msa_fmax_a_w (v4f32, v4f32);
16037 v2f64 __builtin_msa_fmax_a_d (v2f64, v2f64);
16039 v4f32 __builtin_msa_fmin_w (v4f32, v4f32);
16040 v2f64 __builtin_msa_fmin_d (v2f64, v2f64);
16042 v4f32 __builtin_msa_fmin_a_w (v4f32, v4f32);
16043 v2f64 __builtin_msa_fmin_a_d (v2f64, v2f64);
16045 v4f32 __builtin_msa_fmsub_w (v4f32, v4f32, v4f32);
16046 v2f64 __builtin_msa_fmsub_d (v2f64, v2f64, v2f64);
16048 v4f32 __builtin_msa_fmul_w (v4f32, v4f32);
16049 v2f64 __builtin_msa_fmul_d (v2f64, v2f64);
16051 v4f32 __builtin_msa_frint_w (v4f32);
16052 v2f64 __builtin_msa_frint_d (v2f64);
16054 v4f32 __builtin_msa_frcp_w (v4f32);
16055 v2f64 __builtin_msa_frcp_d (v2f64);
16057 v4f32 __builtin_msa_frsqrt_w (v4f32);
16058 v2f64 __builtin_msa_frsqrt_d (v2f64);
16060 v4i32 __builtin_msa_fsaf_w (v4f32, v4f32);
16061 v2i64 __builtin_msa_fsaf_d (v2f64, v2f64);
16063 v4i32 __builtin_msa_fseq_w (v4f32, v4f32);
16064 v2i64 __builtin_msa_fseq_d (v2f64, v2f64);
16066 v4i32 __builtin_msa_fsle_w (v4f32, v4f32);
16067 v2i64 __builtin_msa_fsle_d (v2f64, v2f64);
16069 v4i32 __builtin_msa_fslt_w (v4f32, v4f32);
16070 v2i64 __builtin_msa_fslt_d (v2f64, v2f64);
16072 v4i32 __builtin_msa_fsne_w (v4f32, v4f32);
16073 v2i64 __builtin_msa_fsne_d (v2f64, v2f64);
16075 v4i32 __builtin_msa_fsor_w (v4f32, v4f32);
16076 v2i64 __builtin_msa_fsor_d (v2f64, v2f64);
16078 v4f32 __builtin_msa_fsqrt_w (v4f32);
16079 v2f64 __builtin_msa_fsqrt_d (v2f64);
16081 v4f32 __builtin_msa_fsub_w (v4f32, v4f32);
16082 v2f64 __builtin_msa_fsub_d (v2f64, v2f64);
16084 v4i32 __builtin_msa_fsueq_w (v4f32, v4f32);
16085 v2i64 __builtin_msa_fsueq_d (v2f64, v2f64);
16087 v4i32 __builtin_msa_fsule_w (v4f32, v4f32);
16088 v2i64 __builtin_msa_fsule_d (v2f64, v2f64);
16090 v4i32 __builtin_msa_fsult_w (v4f32, v4f32);
16091 v2i64 __builtin_msa_fsult_d (v2f64, v2f64);
16093 v4i32 __builtin_msa_fsun_w (v4f32, v4f32);
16094 v2i64 __builtin_msa_fsun_d (v2f64, v2f64);
16096 v4i32 __builtin_msa_fsune_w (v4f32, v4f32);
16097 v2i64 __builtin_msa_fsune_d (v2f64, v2f64);
16099 v4i32 __builtin_msa_ftint_s_w (v4f32);
16100 v2i64 __builtin_msa_ftint_s_d (v2f64);
16102 v4u32 __builtin_msa_ftint_u_w (v4f32);
16103 v2u64 __builtin_msa_ftint_u_d (v2f64);
16105 v8i16 __builtin_msa_ftq_h (v4f32, v4f32);
16106 v4i32 __builtin_msa_ftq_w (v2f64, v2f64);
16108 v4i32 __builtin_msa_ftrunc_s_w (v4f32);
16109 v2i64 __builtin_msa_ftrunc_s_d (v2f64);
16111 v4u32 __builtin_msa_ftrunc_u_w (v4f32);
16112 v2u64 __builtin_msa_ftrunc_u_d (v2f64);
16114 v8i16 __builtin_msa_hadd_s_h (v16i8, v16i8);
16115 v4i32 __builtin_msa_hadd_s_w (v8i16, v8i16);
16116 v2i64 __builtin_msa_hadd_s_d (v4i32, v4i32);
16118 v8u16 __builtin_msa_hadd_u_h (v16u8, v16u8);
16119 v4u32 __builtin_msa_hadd_u_w (v8u16, v8u16);
16120 v2u64 __builtin_msa_hadd_u_d (v4u32, v4u32);
16122 v8i16 __builtin_msa_hsub_s_h (v16i8, v16i8);
16123 v4i32 __builtin_msa_hsub_s_w (v8i16, v8i16);
16124 v2i64 __builtin_msa_hsub_s_d (v4i32, v4i32);
16126 v8i16 __builtin_msa_hsub_u_h (v16u8, v16u8);
16127 v4i32 __builtin_msa_hsub_u_w (v8u16, v8u16);
16128 v2i64 __builtin_msa_hsub_u_d (v4u32, v4u32);
16130 v16i8 __builtin_msa_ilvev_b (v16i8, v16i8);
16131 v8i16 __builtin_msa_ilvev_h (v8i16, v8i16);
16132 v4i32 __builtin_msa_ilvev_w (v4i32, v4i32);
16133 v2i64 __builtin_msa_ilvev_d (v2i64, v2i64);
16135 v16i8 __builtin_msa_ilvl_b (v16i8, v16i8);
16136 v8i16 __builtin_msa_ilvl_h (v8i16, v8i16);
16137 v4i32 __builtin_msa_ilvl_w (v4i32, v4i32);
16138 v2i64 __builtin_msa_ilvl_d (v2i64, v2i64);
16140 v16i8 __builtin_msa_ilvod_b (v16i8, v16i8);
16141 v8i16 __builtin_msa_ilvod_h (v8i16, v8i16);
16142 v4i32 __builtin_msa_ilvod_w (v4i32, v4i32);
16143 v2i64 __builtin_msa_ilvod_d (v2i64, v2i64);
16145 v16i8 __builtin_msa_ilvr_b (v16i8, v16i8);
16146 v8i16 __builtin_msa_ilvr_h (v8i16, v8i16);
16147 v4i32 __builtin_msa_ilvr_w (v4i32, v4i32);
16148 v2i64 __builtin_msa_ilvr_d (v2i64, v2i64);
16150 v16i8 __builtin_msa_insert_b (v16i8, imm0_15, i32);
16151 v8i16 __builtin_msa_insert_h (v8i16, imm0_7, i32);
16152 v4i32 __builtin_msa_insert_w (v4i32, imm0_3, i32);
16153 v2i64 __builtin_msa_insert_d (v2i64, imm0_1, i64);
16155 v16i8 __builtin_msa_insve_b (v16i8, imm0_15, v16i8);
16156 v8i16 __builtin_msa_insve_h (v8i16, imm0_7, v8i16);
16157 v4i32 __builtin_msa_insve_w (v4i32, imm0_3, v4i32);
16158 v2i64 __builtin_msa_insve_d (v2i64, imm0_1, v2i64);
16160 v16i8 __builtin_msa_ld_b (void *, imm_n512_511);
16161 v8i16 __builtin_msa_ld_h (void *, imm_n1024_1022);
16162 v4i32 __builtin_msa_ld_w (void *, imm_n2048_2044);
16163 v2i64 __builtin_msa_ld_d (void *, imm_n4096_4088);
16165 v16i8 __builtin_msa_ldi_b (imm_n512_511);
16166 v8i16 __builtin_msa_ldi_h (imm_n512_511);
16167 v4i32 __builtin_msa_ldi_w (imm_n512_511);
16168 v2i64 __builtin_msa_ldi_d (imm_n512_511);
16170 v8i16 __builtin_msa_madd_q_h (v8i16, v8i16, v8i16);
16171 v4i32 __builtin_msa_madd_q_w (v4i32, v4i32, v4i32);
16173 v8i16 __builtin_msa_maddr_q_h (v8i16, v8i16, v8i16);
16174 v4i32 __builtin_msa_maddr_q_w (v4i32, v4i32, v4i32);
16176 v16i8 __builtin_msa_maddv_b (v16i8, v16i8, v16i8);
16177 v8i16 __builtin_msa_maddv_h (v8i16, v8i16, v8i16);
16178 v4i32 __builtin_msa_maddv_w (v4i32, v4i32, v4i32);
16179 v2i64 __builtin_msa_maddv_d (v2i64, v2i64, v2i64);
16181 v16i8 __builtin_msa_max_a_b (v16i8, v16i8);
16182 v8i16 __builtin_msa_max_a_h (v8i16, v8i16);
16183 v4i32 __builtin_msa_max_a_w (v4i32, v4i32);
16184 v2i64 __builtin_msa_max_a_d (v2i64, v2i64);
16186 v16i8 __builtin_msa_max_s_b (v16i8, v16i8);
16187 v8i16 __builtin_msa_max_s_h (v8i16, v8i16);
16188 v4i32 __builtin_msa_max_s_w (v4i32, v4i32);
16189 v2i64 __builtin_msa_max_s_d (v2i64, v2i64);
16191 v16u8 __builtin_msa_max_u_b (v16u8, v16u8);
16192 v8u16 __builtin_msa_max_u_h (v8u16, v8u16);
16193 v4u32 __builtin_msa_max_u_w (v4u32, v4u32);
16194 v2u64 __builtin_msa_max_u_d (v2u64, v2u64);
16196 v16i8 __builtin_msa_maxi_s_b (v16i8, imm_n16_15);
16197 v8i16 __builtin_msa_maxi_s_h (v8i16, imm_n16_15);
16198 v4i32 __builtin_msa_maxi_s_w (v4i32, imm_n16_15);
16199 v2i64 __builtin_msa_maxi_s_d (v2i64, imm_n16_15);
16201 v16u8 __builtin_msa_maxi_u_b (v16u8, imm0_31);
16202 v8u16 __builtin_msa_maxi_u_h (v8u16, imm0_31);
16203 v4u32 __builtin_msa_maxi_u_w (v4u32, imm0_31);
16204 v2u64 __builtin_msa_maxi_u_d (v2u64, imm0_31);
16206 v16i8 __builtin_msa_min_a_b (v16i8, v16i8);
16207 v8i16 __builtin_msa_min_a_h (v8i16, v8i16);
16208 v4i32 __builtin_msa_min_a_w (v4i32, v4i32);
16209 v2i64 __builtin_msa_min_a_d (v2i64, v2i64);
16211 v16i8 __builtin_msa_min_s_b (v16i8, v16i8);
16212 v8i16 __builtin_msa_min_s_h (v8i16, v8i16);
16213 v4i32 __builtin_msa_min_s_w (v4i32, v4i32);
16214 v2i64 __builtin_msa_min_s_d (v2i64, v2i64);
16216 v16u8 __builtin_msa_min_u_b (v16u8, v16u8);
16217 v8u16 __builtin_msa_min_u_h (v8u16, v8u16);
16218 v4u32 __builtin_msa_min_u_w (v4u32, v4u32);
16219 v2u64 __builtin_msa_min_u_d (v2u64, v2u64);
16221 v16i8 __builtin_msa_mini_s_b (v16i8, imm_n16_15);
16222 v8i16 __builtin_msa_mini_s_h (v8i16, imm_n16_15);
16223 v4i32 __builtin_msa_mini_s_w (v4i32, imm_n16_15);
16224 v2i64 __builtin_msa_mini_s_d (v2i64, imm_n16_15);
16226 v16u8 __builtin_msa_mini_u_b (v16u8, imm0_31);
16227 v8u16 __builtin_msa_mini_u_h (v8u16, imm0_31);
16228 v4u32 __builtin_msa_mini_u_w (v4u32, imm0_31);
16229 v2u64 __builtin_msa_mini_u_d (v2u64, imm0_31);
16231 v16i8 __builtin_msa_mod_s_b (v16i8, v16i8);
16232 v8i16 __builtin_msa_mod_s_h (v8i16, v8i16);
16233 v4i32 __builtin_msa_mod_s_w (v4i32, v4i32);
16234 v2i64 __builtin_msa_mod_s_d (v2i64, v2i64);
16236 v16u8 __builtin_msa_mod_u_b (v16u8, v16u8);
16237 v8u16 __builtin_msa_mod_u_h (v8u16, v8u16);
16238 v4u32 __builtin_msa_mod_u_w (v4u32, v4u32);
16239 v2u64 __builtin_msa_mod_u_d (v2u64, v2u64);
16241 v16i8 __builtin_msa_move_v (v16i8);
16243 v8i16 __builtin_msa_msub_q_h (v8i16, v8i16, v8i16);
16244 v4i32 __builtin_msa_msub_q_w (v4i32, v4i32, v4i32);
16246 v8i16 __builtin_msa_msubr_q_h (v8i16, v8i16, v8i16);
16247 v4i32 __builtin_msa_msubr_q_w (v4i32, v4i32, v4i32);
16249 v16i8 __builtin_msa_msubv_b (v16i8, v16i8, v16i8);
16250 v8i16 __builtin_msa_msubv_h (v8i16, v8i16, v8i16);
16251 v4i32 __builtin_msa_msubv_w (v4i32, v4i32, v4i32);
16252 v2i64 __builtin_msa_msubv_d (v2i64, v2i64, v2i64);
16254 v8i16 __builtin_msa_mul_q_h (v8i16, v8i16);
16255 v4i32 __builtin_msa_mul_q_w (v4i32, v4i32);
16257 v8i16 __builtin_msa_mulr_q_h (v8i16, v8i16);
16258 v4i32 __builtin_msa_mulr_q_w (v4i32, v4i32);
16260 v16i8 __builtin_msa_mulv_b (v16i8, v16i8);
16261 v8i16 __builtin_msa_mulv_h (v8i16, v8i16);
16262 v4i32 __builtin_msa_mulv_w (v4i32, v4i32);
16263 v2i64 __builtin_msa_mulv_d (v2i64, v2i64);
16265 v16i8 __builtin_msa_nloc_b (v16i8);
16266 v8i16 __builtin_msa_nloc_h (v8i16);
16267 v4i32 __builtin_msa_nloc_w (v4i32);
16268 v2i64 __builtin_msa_nloc_d (v2i64);
16270 v16i8 __builtin_msa_nlzc_b (v16i8);
16271 v8i16 __builtin_msa_nlzc_h (v8i16);
16272 v4i32 __builtin_msa_nlzc_w (v4i32);
16273 v2i64 __builtin_msa_nlzc_d (v2i64);
16275 v16u8 __builtin_msa_nor_v (v16u8, v16u8);
16277 v16u8 __builtin_msa_nori_b (v16u8, imm0_255);
16279 v16u8 __builtin_msa_or_v (v16u8, v16u8);
16281 v16u8 __builtin_msa_ori_b (v16u8, imm0_255);
16283 v16i8 __builtin_msa_pckev_b (v16i8, v16i8);
16284 v8i16 __builtin_msa_pckev_h (v8i16, v8i16);
16285 v4i32 __builtin_msa_pckev_w (v4i32, v4i32);
16286 v2i64 __builtin_msa_pckev_d (v2i64, v2i64);
16288 v16i8 __builtin_msa_pckod_b (v16i8, v16i8);
16289 v8i16 __builtin_msa_pckod_h (v8i16, v8i16);
16290 v4i32 __builtin_msa_pckod_w (v4i32, v4i32);
16291 v2i64 __builtin_msa_pckod_d (v2i64, v2i64);
16293 v16i8 __builtin_msa_pcnt_b (v16i8);
16294 v8i16 __builtin_msa_pcnt_h (v8i16);
16295 v4i32 __builtin_msa_pcnt_w (v4i32);
16296 v2i64 __builtin_msa_pcnt_d (v2i64);
16298 v16i8 __builtin_msa_sat_s_b (v16i8, imm0_7);
16299 v8i16 __builtin_msa_sat_s_h (v8i16, imm0_15);
16300 v4i32 __builtin_msa_sat_s_w (v4i32, imm0_31);
16301 v2i64 __builtin_msa_sat_s_d (v2i64, imm0_63);
16303 v16u8 __builtin_msa_sat_u_b (v16u8, imm0_7);
16304 v8u16 __builtin_msa_sat_u_h (v8u16, imm0_15);
16305 v4u32 __builtin_msa_sat_u_w (v4u32, imm0_31);
16306 v2u64 __builtin_msa_sat_u_d (v2u64, imm0_63);
16308 v16i8 __builtin_msa_shf_b (v16i8, imm0_255);
16309 v8i16 __builtin_msa_shf_h (v8i16, imm0_255);
16310 v4i32 __builtin_msa_shf_w (v4i32, imm0_255);
16312 v16i8 __builtin_msa_sld_b (v16i8, v16i8, i32);
16313 v8i16 __builtin_msa_sld_h (v8i16, v8i16, i32);
16314 v4i32 __builtin_msa_sld_w (v4i32, v4i32, i32);
16315 v2i64 __builtin_msa_sld_d (v2i64, v2i64, i32);
16317 v16i8 __builtin_msa_sldi_b (v16i8, v16i8, imm0_15);
16318 v8i16 __builtin_msa_sldi_h (v8i16, v8i16, imm0_7);
16319 v4i32 __builtin_msa_sldi_w (v4i32, v4i32, imm0_3);
16320 v2i64 __builtin_msa_sldi_d (v2i64, v2i64, imm0_1);
16322 v16i8 __builtin_msa_sll_b (v16i8, v16i8);
16323 v8i16 __builtin_msa_sll_h (v8i16, v8i16);
16324 v4i32 __builtin_msa_sll_w (v4i32, v4i32);
16325 v2i64 __builtin_msa_sll_d (v2i64, v2i64);
16327 v16i8 __builtin_msa_slli_b (v16i8, imm0_7);
16328 v8i16 __builtin_msa_slli_h (v8i16, imm0_15);
16329 v4i32 __builtin_msa_slli_w (v4i32, imm0_31);
16330 v2i64 __builtin_msa_slli_d (v2i64, imm0_63);
16332 v16i8 __builtin_msa_splat_b (v16i8, i32);
16333 v8i16 __builtin_msa_splat_h (v8i16, i32);
16334 v4i32 __builtin_msa_splat_w (v4i32, i32);
16335 v2i64 __builtin_msa_splat_d (v2i64, i32);
16337 v16i8 __builtin_msa_splati_b (v16i8, imm0_15);
16338 v8i16 __builtin_msa_splati_h (v8i16, imm0_7);
16339 v4i32 __builtin_msa_splati_w (v4i32, imm0_3);
16340 v2i64 __builtin_msa_splati_d (v2i64, imm0_1);
16342 v16i8 __builtin_msa_sra_b (v16i8, v16i8);
16343 v8i16 __builtin_msa_sra_h (v8i16, v8i16);
16344 v4i32 __builtin_msa_sra_w (v4i32, v4i32);
16345 v2i64 __builtin_msa_sra_d (v2i64, v2i64);
16347 v16i8 __builtin_msa_srai_b (v16i8, imm0_7);
16348 v8i16 __builtin_msa_srai_h (v8i16, imm0_15);
16349 v4i32 __builtin_msa_srai_w (v4i32, imm0_31);
16350 v2i64 __builtin_msa_srai_d (v2i64, imm0_63);
16352 v16i8 __builtin_msa_srar_b (v16i8, v16i8);
16353 v8i16 __builtin_msa_srar_h (v8i16, v8i16);
16354 v4i32 __builtin_msa_srar_w (v4i32, v4i32);
16355 v2i64 __builtin_msa_srar_d (v2i64, v2i64);
16357 v16i8 __builtin_msa_srari_b (v16i8, imm0_7);
16358 v8i16 __builtin_msa_srari_h (v8i16, imm0_15);
16359 v4i32 __builtin_msa_srari_w (v4i32, imm0_31);
16360 v2i64 __builtin_msa_srari_d (v2i64, imm0_63);
16362 v16i8 __builtin_msa_srl_b (v16i8, v16i8);
16363 v8i16 __builtin_msa_srl_h (v8i16, v8i16);
16364 v4i32 __builtin_msa_srl_w (v4i32, v4i32);
16365 v2i64 __builtin_msa_srl_d (v2i64, v2i64);
16367 v16i8 __builtin_msa_srli_b (v16i8, imm0_7);
16368 v8i16 __builtin_msa_srli_h (v8i16, imm0_15);
16369 v4i32 __builtin_msa_srli_w (v4i32, imm0_31);
16370 v2i64 __builtin_msa_srli_d (v2i64, imm0_63);
16372 v16i8 __builtin_msa_srlr_b (v16i8, v16i8);
16373 v8i16 __builtin_msa_srlr_h (v8i16, v8i16);
16374 v4i32 __builtin_msa_srlr_w (v4i32, v4i32);
16375 v2i64 __builtin_msa_srlr_d (v2i64, v2i64);
16377 v16i8 __builtin_msa_srlri_b (v16i8, imm0_7);
16378 v8i16 __builtin_msa_srlri_h (v8i16, imm0_15);
16379 v4i32 __builtin_msa_srlri_w (v4i32, imm0_31);
16380 v2i64 __builtin_msa_srlri_d (v2i64, imm0_63);
16382 void __builtin_msa_st_b (v16i8, void *, imm_n512_511);
16383 void __builtin_msa_st_h (v8i16, void *, imm_n1024_1022);
16384 void __builtin_msa_st_w (v4i32, void *, imm_n2048_2044);
16385 void __builtin_msa_st_d (v2i64, void *, imm_n4096_4088);
16387 v16i8 __builtin_msa_subs_s_b (v16i8, v16i8);
16388 v8i16 __builtin_msa_subs_s_h (v8i16, v8i16);
16389 v4i32 __builtin_msa_subs_s_w (v4i32, v4i32);
16390 v2i64 __builtin_msa_subs_s_d (v2i64, v2i64);
16392 v16u8 __builtin_msa_subs_u_b (v16u8, v16u8);
16393 v8u16 __builtin_msa_subs_u_h (v8u16, v8u16);
16394 v4u32 __builtin_msa_subs_u_w (v4u32, v4u32);
16395 v2u64 __builtin_msa_subs_u_d (v2u64, v2u64);
16397 v16u8 __builtin_msa_subsus_u_b (v16u8, v16i8);
16398 v8u16 __builtin_msa_subsus_u_h (v8u16, v8i16);
16399 v4u32 __builtin_msa_subsus_u_w (v4u32, v4i32);
16400 v2u64 __builtin_msa_subsus_u_d (v2u64, v2i64);
16402 v16i8 __builtin_msa_subsuu_s_b (v16u8, v16u8);
16403 v8i16 __builtin_msa_subsuu_s_h (v8u16, v8u16);
16404 v4i32 __builtin_msa_subsuu_s_w (v4u32, v4u32);
16405 v2i64 __builtin_msa_subsuu_s_d (v2u64, v2u64);
16407 v16i8 __builtin_msa_subv_b (v16i8, v16i8);
16408 v8i16 __builtin_msa_subv_h (v8i16, v8i16);
16409 v4i32 __builtin_msa_subv_w (v4i32, v4i32);
16410 v2i64 __builtin_msa_subv_d (v2i64, v2i64);
16412 v16i8 __builtin_msa_subvi_b (v16i8, imm0_31);
16413 v8i16 __builtin_msa_subvi_h (v8i16, imm0_31);
16414 v4i32 __builtin_msa_subvi_w (v4i32, imm0_31);
16415 v2i64 __builtin_msa_subvi_d (v2i64, imm0_31);
16417 v16i8 __builtin_msa_vshf_b (v16i8, v16i8, v16i8);
16418 v8i16 __builtin_msa_vshf_h (v8i16, v8i16, v8i16);
16419 v4i32 __builtin_msa_vshf_w (v4i32, v4i32, v4i32);
16420 v2i64 __builtin_msa_vshf_d (v2i64, v2i64, v2i64);
16422 v16u8 __builtin_msa_xor_v (v16u8, v16u8);
16424 v16u8 __builtin_msa_xori_b (v16u8, imm0_255);
16425 @end smallexample
16427 @node Other MIPS Built-in Functions
16428 @subsection Other MIPS Built-in Functions
16430 GCC provides other MIPS-specific built-in functions:
16432 @table @code
16433 @item void __builtin_mips_cache (int @var{op}, const volatile void *@var{addr})
16434 Insert a @samp{cache} instruction with operands @var{op} and @var{addr}.
16435 GCC defines the preprocessor macro @code{___GCC_HAVE_BUILTIN_MIPS_CACHE}
16436 when this function is available.
16438 @item unsigned int __builtin_mips_get_fcsr (void)
16439 @itemx void __builtin_mips_set_fcsr (unsigned int @var{value})
16440 Get and set the contents of the floating-point control and status register
16441 (FPU control register 31).  These functions are only available in hard-float
16442 code but can be called in both MIPS16 and non-MIPS16 contexts.
16444 @code{__builtin_mips_set_fcsr} can be used to change any bit of the
16445 register except the condition codes, which GCC assumes are preserved.
16446 @end table
16448 @node MSP430 Built-in Functions
16449 @subsection MSP430 Built-in Functions
16451 GCC provides a couple of special builtin functions to aid in the
16452 writing of interrupt handlers in C.
16454 @table @code
16455 @item __bic_SR_register_on_exit (int @var{mask})
16456 This clears the indicated bits in the saved copy of the status register
16457 currently residing on the stack.  This only works inside interrupt
16458 handlers and the changes to the status register will only take affect
16459 once the handler returns.
16461 @item __bis_SR_register_on_exit (int @var{mask})
16462 This sets the indicated bits in the saved copy of the status register
16463 currently residing on the stack.  This only works inside interrupt
16464 handlers and the changes to the status register will only take affect
16465 once the handler returns.
16467 @item __delay_cycles (long long @var{cycles})
16468 This inserts an instruction sequence that takes exactly @var{cycles}
16469 cycles (between 0 and about 17E9) to complete.  The inserted sequence
16470 may use jumps, loops, or no-ops, and does not interfere with any other
16471 instructions.  Note that @var{cycles} must be a compile-time constant
16472 integer - that is, you must pass a number, not a variable that may be
16473 optimized to a constant later.  The number of cycles delayed by this
16474 builtin is exact.
16475 @end table
16477 @node NDS32 Built-in Functions
16478 @subsection NDS32 Built-in Functions
16480 These built-in functions are available for the NDS32 target:
16482 @deftypefn {Built-in Function} void __builtin_nds32_isync (int *@var{addr})
16483 Insert an ISYNC instruction into the instruction stream where
16484 @var{addr} is an instruction address for serialization.
16485 @end deftypefn
16487 @deftypefn {Built-in Function} void __builtin_nds32_isb (void)
16488 Insert an ISB instruction into the instruction stream.
16489 @end deftypefn
16491 @deftypefn {Built-in Function} int __builtin_nds32_mfsr (int @var{sr})
16492 Return the content of a system register which is mapped by @var{sr}.
16493 @end deftypefn
16495 @deftypefn {Built-in Function} int __builtin_nds32_mfusr (int @var{usr})
16496 Return the content of a user space register which is mapped by @var{usr}.
16497 @end deftypefn
16499 @deftypefn {Built-in Function} void __builtin_nds32_mtsr (int @var{value}, int @var{sr})
16500 Move the @var{value} to a system register which is mapped by @var{sr}.
16501 @end deftypefn
16503 @deftypefn {Built-in Function} void __builtin_nds32_mtusr (int @var{value}, int @var{usr})
16504 Move the @var{value} to a user space register which is mapped by @var{usr}.
16505 @end deftypefn
16507 @deftypefn {Built-in Function} void __builtin_nds32_setgie_en (void)
16508 Enable global interrupt.
16509 @end deftypefn
16511 @deftypefn {Built-in Function} void __builtin_nds32_setgie_dis (void)
16512 Disable global interrupt.
16513 @end deftypefn
16515 @node picoChip Built-in Functions
16516 @subsection picoChip Built-in Functions
16518 GCC provides an interface to selected machine instructions from the
16519 picoChip instruction set.
16521 @table @code
16522 @item int __builtin_sbc (int @var{value})
16523 Sign bit count.  Return the number of consecutive bits in @var{value}
16524 that have the same value as the sign bit.  The result is the number of
16525 leading sign bits minus one, giving the number of redundant sign bits in
16526 @var{value}.
16528 @item int __builtin_byteswap (int @var{value})
16529 Byte swap.  Return the result of swapping the upper and lower bytes of
16530 @var{value}.
16532 @item int __builtin_brev (int @var{value})
16533 Bit reversal.  Return the result of reversing the bits in
16534 @var{value}.  Bit 15 is swapped with bit 0, bit 14 is swapped with bit 1,
16535 and so on.
16537 @item int __builtin_adds (int @var{x}, int @var{y})
16538 Saturating addition.  Return the result of adding @var{x} and @var{y},
16539 storing the value 32767 if the result overflows.
16541 @item int __builtin_subs (int @var{x}, int @var{y})
16542 Saturating subtraction.  Return the result of subtracting @var{y} from
16543 @var{x}, storing the value @minus{}32768 if the result overflows.
16545 @item void __builtin_halt (void)
16546 Halt.  The processor stops execution.  This built-in is useful for
16547 implementing assertions.
16549 @end table
16551 @node Basic PowerPC Built-in Functions
16552 @subsection Basic PowerPC Built-in Functions
16554 @menu
16555 * Basic PowerPC Built-in Functions Available on all Configurations::
16556 * Basic PowerPC Built-in Functions Available on ISA 2.05::
16557 * Basic PowerPC Built-in Functions Available on ISA 2.06::
16558 * Basic PowerPC Built-in Functions Available on ISA 2.07::
16559 * Basic PowerPC Built-in Functions Available on ISA 3.0::
16560 @end menu
16562 This section describes PowerPC built-in functions that do not require
16563 the inclusion of any special header files to declare prototypes or
16564 provide macro definitions.  The sections that follow describe
16565 additional PowerPC built-in functions.
16567 @node Basic PowerPC Built-in Functions Available on all Configurations
16568 @subsubsection Basic PowerPC Built-in Functions Available on all Configurations
16570 @deftypefn {Built-in Function} void __builtin_cpu_init (void)
16571 This function is a @code{nop} on the PowerPC platform and is included solely
16572 to maintain API compatibility with the x86 builtins.
16573 @end deftypefn
16575 @deftypefn {Built-in Function} int __builtin_cpu_is (const char *@var{cpuname})
16576 This function returns a value of @code{1} if the run-time CPU is of type
16577 @var{cpuname} and returns @code{0} otherwise
16579 The @code{__builtin_cpu_is} function requires GLIBC 2.23 or newer
16580 which exports the hardware capability bits.  GCC defines the macro
16581 @code{__BUILTIN_CPU_SUPPORTS__} if the @code{__builtin_cpu_supports}
16582 built-in function is fully supported.
16584 If GCC was configured to use a GLIBC before 2.23, the built-in
16585 function @code{__builtin_cpu_is} always returns a 0 and the compiler
16586 issues a warning.
16588 The following CPU names can be detected:
16590 @table @samp
16591 @item power9
16592 IBM POWER9 Server CPU.
16593 @item power8
16594 IBM POWER8 Server CPU.
16595 @item power7
16596 IBM POWER7 Server CPU.
16597 @item power6x
16598 IBM POWER6 Server CPU (RAW mode).
16599 @item power6
16600 IBM POWER6 Server CPU (Architected mode).
16601 @item power5+
16602 IBM POWER5+ Server CPU.
16603 @item power5
16604 IBM POWER5 Server CPU.
16605 @item ppc970
16606 IBM 970 Server CPU (ie, Apple G5).
16607 @item power4
16608 IBM POWER4 Server CPU.
16609 @item ppca2
16610 IBM A2 64-bit Embedded CPU
16611 @item ppc476
16612 IBM PowerPC 476FP 32-bit Embedded CPU.
16613 @item ppc464
16614 IBM PowerPC 464 32-bit Embedded CPU.
16615 @item ppc440
16616 PowerPC 440 32-bit Embedded CPU.
16617 @item ppc405
16618 PowerPC 405 32-bit Embedded CPU.
16619 @item ppc-cell-be
16620 IBM PowerPC Cell Broadband Engine Architecture CPU.
16621 @end table
16623 Here is an example:
16624 @smallexample
16625 #ifdef __BUILTIN_CPU_SUPPORTS__
16626   if (__builtin_cpu_is ("power8"))
16627     @{
16628        do_power8 (); // POWER8 specific implementation.
16629     @}
16630   else
16631 #endif
16632     @{
16633        do_generic (); // Generic implementation.
16634     @}
16635 @end smallexample
16636 @end deftypefn
16638 @deftypefn {Built-in Function} int __builtin_cpu_supports (const char *@var{feature})
16639 This function returns a value of @code{1} if the run-time CPU supports the HWCAP
16640 feature @var{feature} and returns @code{0} otherwise.
16642 The @code{__builtin_cpu_supports} function requires GLIBC 2.23 or
16643 newer which exports the hardware capability bits.  GCC defines the
16644 macro @code{__BUILTIN_CPU_SUPPORTS__} if the
16645 @code{__builtin_cpu_supports} built-in function is fully supported.
16647 If GCC was configured to use a GLIBC before 2.23, the built-in
16648 function @code{__builtin_cpu_suports} always returns a 0 and the
16649 compiler issues a warning.
16651 The following features can be
16652 detected:
16654 @table @samp
16655 @item 4xxmac
16656 4xx CPU has a Multiply Accumulator.
16657 @item altivec
16658 CPU has a SIMD/Vector Unit.
16659 @item arch_2_05
16660 CPU supports ISA 2.05 (eg, POWER6)
16661 @item arch_2_06
16662 CPU supports ISA 2.06 (eg, POWER7)
16663 @item arch_2_07
16664 CPU supports ISA 2.07 (eg, POWER8)
16665 @item arch_3_00
16666 CPU supports ISA 3.0 (eg, POWER9)
16667 @item archpmu
16668 CPU supports the set of compatible performance monitoring events.
16669 @item booke
16670 CPU supports the Embedded ISA category.
16671 @item cellbe
16672 CPU has a CELL broadband engine.
16673 @item darn
16674 CPU supports the @code{darn} (deliver a random number) instruction.
16675 @item dfp
16676 CPU has a decimal floating point unit.
16677 @item dscr
16678 CPU supports the data stream control register.
16679 @item ebb
16680 CPU supports event base branching.
16681 @item efpdouble
16682 CPU has a SPE double precision floating point unit.
16683 @item efpsingle
16684 CPU has a SPE single precision floating point unit.
16685 @item fpu
16686 CPU has a floating point unit.
16687 @item htm
16688 CPU has hardware transaction memory instructions.
16689 @item htm-nosc
16690 Kernel aborts hardware transactions when a syscall is made.
16691 @item htm-no-suspend
16692 CPU supports hardware transaction memory but does not support the
16693 @code{tsuspend.} instruction.
16694 @item ic_snoop
16695 CPU supports icache snooping capabilities.
16696 @item ieee128
16697 CPU supports 128-bit IEEE binary floating point instructions.
16698 @item isel
16699 CPU supports the integer select instruction.
16700 @item mmu
16701 CPU has a memory management unit.
16702 @item notb
16703 CPU does not have a timebase (eg, 601 and 403gx).
16704 @item pa6t
16705 CPU supports the PA Semi 6T CORE ISA.
16706 @item power4
16707 CPU supports ISA 2.00 (eg, POWER4)
16708 @item power5
16709 CPU supports ISA 2.02 (eg, POWER5)
16710 @item power5+
16711 CPU supports ISA 2.03 (eg, POWER5+)
16712 @item power6x
16713 CPU supports ISA 2.05 (eg, POWER6) extended opcodes mffgpr and mftgpr.
16714 @item ppc32
16715 CPU supports 32-bit mode execution.
16716 @item ppc601
16717 CPU supports the old POWER ISA (eg, 601)
16718 @item ppc64
16719 CPU supports 64-bit mode execution.
16720 @item ppcle
16721 CPU supports a little-endian mode that uses address swizzling.
16722 @item scv
16723 Kernel supports system call vectored.
16724 @item smt
16725 CPU support simultaneous multi-threading.
16726 @item spe
16727 CPU has a signal processing extension unit.
16728 @item tar
16729 CPU supports the target address register.
16730 @item true_le
16731 CPU supports true little-endian mode.
16732 @item ucache
16733 CPU has unified I/D cache.
16734 @item vcrypto
16735 CPU supports the vector cryptography instructions.
16736 @item vsx
16737 CPU supports the vector-scalar extension.
16738 @end table
16740 Here is an example:
16741 @smallexample
16742 #ifdef __BUILTIN_CPU_SUPPORTS__
16743   if (__builtin_cpu_supports ("fpu"))
16744     @{
16745        asm("fadd %0,%1,%2" : "=d"(dst) : "d"(src1), "d"(src2));
16746     @}
16747   else
16748 #endif
16749     @{
16750        dst = __fadd (src1, src2); // Software FP addition function.
16751     @}
16752 @end smallexample
16753 @end deftypefn
16755 The following built-in functions are also available on all PowerPC
16756 processors:
16757 @smallexample
16758 uint64_t __builtin_ppc_get_timebase ();
16759 unsigned long __builtin_ppc_mftb ();
16760 double __builtin_unpack_ibm128 (__ibm128, int);
16761 __ibm128 __builtin_pack_ibm128 (double, double);
16762 double __builtin_mffs (void);
16763 void __builtin_mtfsb0 (const int);
16764 void __builtin_mtfsb1 (const int);
16765 void __builtin_set_fpscr_rn (int);
16766 @end smallexample
16768 The @code{__builtin_ppc_get_timebase} and @code{__builtin_ppc_mftb}
16769 functions generate instructions to read the Time Base Register.  The
16770 @code{__builtin_ppc_get_timebase} function may generate multiple
16771 instructions and always returns the 64 bits of the Time Base Register.
16772 The @code{__builtin_ppc_mftb} function always generates one instruction and
16773 returns the Time Base Register value as an unsigned long, throwing away
16774 the most significant word on 32-bit environments.  The @code{__builtin_mffs}
16775 return the value of the FPSCR register.  Note, ISA 3.0 supports the
16776 @code{__builtin_mffsl()} which permits software to read the control and
16777 non-sticky status bits in the FSPCR without the higher latency associated with
16778 accessing the sticky status bits.  The
16779 @code{__builtin_mtfsb0} and @code{__builtin_mtfsb1} take the bit to change
16780 as an argument.  The valid bit range is between 0 and 31.  The builtins map to
16781 the @code{mtfsb0} and @code{mtfsb1} instructions which take the argument and
16782 add 32.  Hence these instructions only modify the FPSCR[32:63] bits by
16783 changing the specified bit to a zero or one respectively.  The
16784 @code{__builtin_set_fpscr_rn} builtin allows changing both of the floating
16785 point rounding mode bits.  The argument is a 2-bit value.  The argument can
16786 either be a @code{const int} or stored in a variable. The builtin uses
16787 the ISA 3.0
16788 instruction @code{mffscrn} if available, otherwise it reads the FPSCR, masks
16789 the current rounding mode bits out and OR's in the new value.
16791 @node Basic PowerPC Built-in Functions Available on ISA 2.05
16792 @subsubsection Basic PowerPC Built-in Functions Available on ISA 2.05
16794 The basic built-in functions described in this section are
16795 available on the PowerPC family of processors starting with ISA 2.05
16796 or later.  Unless specific options are explicitly disabled on the
16797 command line, specifying option @option{-mcpu=power6} has the effect of
16798 enabling the @option{-mpowerpc64}, @option{-mpowerpc-gpopt},
16799 @option{-mpowerpc-gfxopt}, @option{-mmfcrf}, @option{-mpopcntb},
16800 @option{-mfprnd}, @option{-mcmpb}, @option{-mhard-dfp}, and
16801 @option{-mrecip-precision} options.  Specify the
16802 @option{-maltivec} and @option{-mfpgpr} options explicitly in
16803 combination with the above options if they are desired.
16805 The following functions require option @option{-mcmpb}.
16806 @smallexample
16807 unsigned long long __builtin_cmpb (unsigned long long int, unsigned long long int);
16808 unsigned int __builtin_cmpb (unsigned int, unsigned int);
16809 @end smallexample
16811 The @code{__builtin_cmpb} function
16812 performs a byte-wise compare on the contents of its two arguments,
16813 returning the result of the byte-wise comparison as the returned
16814 value.  For each byte comparison, the corresponding byte of the return
16815 value holds 0xff if the input bytes are equal and 0 if the input bytes
16816 are not equal.  If either of the arguments to this built-in function
16817 is wider than 32 bits, the function call expands into the form that
16818 expects @code{unsigned long long int} arguments
16819 which is only available on 64-bit targets.
16821 The following built-in functions are available
16822 when hardware decimal floating point
16823 (@option{-mhard-dfp}) is available:
16824 @smallexample
16825 void __builtin_set_fpscr_drn(int);
16826 _Decimal64 __builtin_ddedpd (int, _Decimal64);
16827 _Decimal128 __builtin_ddedpdq (int, _Decimal128);
16828 _Decimal64 __builtin_denbcd (int, _Decimal64);
16829 _Decimal128 __builtin_denbcdq (int, _Decimal128);
16830 _Decimal64 __builtin_diex (long long, _Decimal64);
16831 _Decimal128 _builtin_diexq (long long, _Decimal128);
16832 _Decimal64 __builtin_dscli (_Decimal64, int);
16833 _Decimal128 __builtin_dscliq (_Decimal128, int);
16834 _Decimal64 __builtin_dscri (_Decimal64, int);
16835 _Decimal128 __builtin_dscriq (_Decimal128, int);
16836 long long __builtin_dxex (_Decimal64);
16837 long long __builtin_dxexq (_Decimal128);
16838 _Decimal128 __builtin_pack_dec128 (unsigned long long, unsigned long long);
16839 unsigned long long __builtin_unpack_dec128 (_Decimal128, int);
16841 The @code{__builtin_set_fpscr_drn} builtin allows changing the three decimal
16842 floating point rounding mode bits.  The argument is a 3-bit value.  The
16843 argument can either be a @code{const int} or the value can be stored in
16844 a variable.
16845 The builtin uses the ISA 3.0 instruction @code{mffscdrn} if available.
16846 Otherwise the builtin reads the FPSCR, masks the current decimal rounding
16847 mode bits out and OR's in the new value.
16849 @end smallexample
16851 The following functions require @option{-mhard-float},
16852 @option{-mpowerpc-gfxopt}, and @option{-mpopcntb} options.
16854 @smallexample
16855 double __builtin_recipdiv (double, double);
16856 float __builtin_recipdivf (float, float);
16857 double __builtin_rsqrt (double);
16858 float __builtin_rsqrtf (float);
16859 @end smallexample
16861 The @code{vec_rsqrt}, @code{__builtin_rsqrt}, and
16862 @code{__builtin_rsqrtf} functions generate multiple instructions to
16863 implement the reciprocal sqrt functionality using reciprocal sqrt
16864 estimate instructions.
16866 The @code{__builtin_recipdiv}, and @code{__builtin_recipdivf}
16867 functions generate multiple instructions to implement division using
16868 the reciprocal estimate instructions.
16870 The following functions require @option{-mhard-float} and
16871 @option{-mmultiple} options.
16873 The @code{__builtin_unpack_longdouble} function takes a
16874 @code{long double} argument and a compile time constant of 0 or 1.  If
16875 the constant is 0, the first @code{double} within the
16876 @code{long double} is returned, otherwise the second @code{double}
16877 is returned.  The @code{__builtin_unpack_longdouble} function is only
16878 available if @code{long double} uses the IBM extended double
16879 representation.
16881 The @code{__builtin_pack_longdouble} function takes two @code{double}
16882 arguments and returns a @code{long double} value that combines the two
16883 arguments.  The @code{__builtin_pack_longdouble} function is only
16884 available if @code{long double} uses the IBM extended double
16885 representation.
16887 The @code{__builtin_unpack_ibm128} function takes a @code{__ibm128}
16888 argument and a compile time constant of 0 or 1.  If the constant is 0,
16889 the first @code{double} within the @code{__ibm128} is returned,
16890 otherwise the second @code{double} is returned.
16892 The @code{__builtin_pack_ibm128} function takes two @code{double}
16893 arguments and returns a @code{__ibm128} value that combines the two
16894 arguments.
16896 Additional built-in functions are available for the 64-bit PowerPC
16897 family of processors, for efficient use of 128-bit floating point
16898 (@code{__float128}) values.
16900 @node Basic PowerPC Built-in Functions Available on ISA 2.06
16901 @subsubsection Basic PowerPC Built-in Functions Available on ISA 2.06
16903 The basic built-in functions described in this section are
16904 available on the PowerPC family of processors starting with ISA 2.05
16905 or later.  Unless specific options are explicitly disabled on the
16906 command line, specifying option @option{-mcpu=power7} has the effect of
16907 enabling all the same options as for @option{-mcpu=power6} in
16908 addition to the @option{-maltivec}, @option{-mpopcntd}, and
16909 @option{-mvsx} options.
16911 The following basic built-in functions require @option{-mpopcntd}:
16912 @smallexample
16913 unsigned int __builtin_addg6s (unsigned int, unsigned int);
16914 long long __builtin_bpermd (long long, long long);
16915 unsigned int __builtin_cbcdtd (unsigned int);
16916 unsigned int __builtin_cdtbcd (unsigned int);
16917 long long __builtin_divde (long long, long long);
16918 unsigned long long __builtin_divdeu (unsigned long long, unsigned long long);
16919 int __builtin_divwe (int, int);
16920 unsigned int __builtin_divweu (unsigned int, unsigned int);
16921 vector __int128 __builtin_pack_vector_int128 (long long, long long);
16922 void __builtin_rs6000_speculation_barrier (void);
16923 long long __builtin_unpack_vector_int128 (vector __int128, signed char);
16924 @end smallexample
16926 Of these, the @code{__builtin_divde} and @code{__builtin_divdeu} functions
16927 require a 64-bit environment.
16929 The following basic built-in functions, which are also supported on
16930 x86 targets, require @option{-mfloat128}.
16931 @smallexample
16932 __float128 __builtin_fabsq (__float128);
16933 __float128 __builtin_copysignq (__float128, __float128);
16934 __float128 __builtin_infq (void);
16935 __float128 __builtin_huge_valq (void);
16936 __float128 __builtin_nanq (void);
16937 __float128 __builtin_nansq (void);
16939 __float128 __builtin_sqrtf128 (__float128);
16940 __float128 __builtin_fmaf128 (__float128, __float128, __float128);
16941 @end smallexample
16943 @node Basic PowerPC Built-in Functions Available on ISA 2.07
16944 @subsubsection Basic PowerPC Built-in Functions Available on ISA 2.07
16946 The basic built-in functions described in this section are
16947 available on the PowerPC family of processors starting with ISA 2.07
16948 or later.  Unless specific options are explicitly disabled on the
16949 command line, specifying option @option{-mcpu=power8} has the effect of
16950 enabling all the same options as for @option{-mcpu=power7} in
16951 addition to the @option{-mpower8-fusion}, @option{-mpower8-vector},
16952 @option{-mcrypto}, @option{-mhtm}, @option{-mquad-memory}, and
16953 @option{-mquad-memory-atomic} options.
16955 This section intentionally empty.
16957 @node Basic PowerPC Built-in Functions Available on ISA 3.0
16958 @subsubsection Basic PowerPC Built-in Functions Available on ISA 3.0
16960 The basic built-in functions described in this section are
16961 available on the PowerPC family of processors starting with ISA 3.0
16962 or later.  Unless specific options are explicitly disabled on the
16963 command line, specifying option @option{-mcpu=power9} has the effect of
16964 enabling all the same options as for @option{-mcpu=power8} in
16965 addition to the @option{-misel} option.
16967 The following built-in functions are available on Linux 64-bit systems
16968 that use the ISA 3.0 instruction set (@option{-mcpu=power9}):
16970 @table @code
16971 @item __float128 __builtin_addf128_round_to_odd (__float128, __float128)
16972 Perform a 128-bit IEEE floating point add using round to odd as the
16973 rounding mode.
16974 @findex __builtin_addf128_round_to_odd
16976 @item __float128 __builtin_subf128_round_to_odd (__float128, __float128)
16977 Perform a 128-bit IEEE floating point subtract using round to odd as
16978 the rounding mode.
16979 @findex __builtin_subf128_round_to_odd
16981 @item __float128 __builtin_mulf128_round_to_odd (__float128, __float128)
16982 Perform a 128-bit IEEE floating point multiply using round to odd as
16983 the rounding mode.
16984 @findex __builtin_mulf128_round_to_odd
16986 @item __float128 __builtin_divf128_round_to_odd (__float128, __float128)
16987 Perform a 128-bit IEEE floating point divide using round to odd as
16988 the rounding mode.
16989 @findex __builtin_divf128_round_to_odd
16991 @item __float128 __builtin_sqrtf128_round_to_odd (__float128)
16992 Perform a 128-bit IEEE floating point square root using round to odd
16993 as the rounding mode.
16994 @findex __builtin_sqrtf128_round_to_odd
16996 @item __float128 __builtin_fmaf128_round_to_odd (__float128, __float128, __float128)
16997 Perform a 128-bit IEEE floating point fused multiply and add operation
16998 using round to odd as the rounding mode.
16999 @findex __builtin_fmaf128_round_to_odd
17001 @item double __builtin_truncf128_round_to_odd (__float128)
17002 Convert a 128-bit IEEE floating point value to @code{double} using
17003 round to odd as the rounding mode.
17004 @findex __builtin_truncf128_round_to_odd
17005 @end table
17007 The following additional built-in functions are also available for the
17008 PowerPC family of processors, starting with ISA 3.0 or later:
17009 @smallexample
17010 long long __builtin_darn (void);
17011 long long __builtin_darn_raw (void);
17012 int __builtin_darn_32 (void);
17013 @end smallexample
17015 The @code{__builtin_darn} and @code{__builtin_darn_raw}
17016 functions require a
17017 64-bit environment supporting ISA 3.0 or later.
17018 The @code{__builtin_darn} function provides a 64-bit conditioned
17019 random number.  The @code{__builtin_darn_raw} function provides a
17020 64-bit raw random number.  The @code{__builtin_darn_32} function
17021 provides a 32-bit conditioned random number.
17023 The following additional built-in functions are also available for the
17024 PowerPC family of processors, starting with ISA 3.0 or later:
17026 @smallexample
17027 int __builtin_byte_in_set (unsigned char u, unsigned long long set);
17028 int __builtin_byte_in_range (unsigned char u, unsigned int range);
17029 int __builtin_byte_in_either_range (unsigned char u, unsigned int ranges);
17031 int __builtin_dfp_dtstsfi_lt (unsigned int comparison, _Decimal64 value);
17032 int __builtin_dfp_dtstsfi_lt (unsigned int comparison, _Decimal128 value);
17033 int __builtin_dfp_dtstsfi_lt_dd (unsigned int comparison, _Decimal64 value);
17034 int __builtin_dfp_dtstsfi_lt_td (unsigned int comparison, _Decimal128 value);
17036 int __builtin_dfp_dtstsfi_gt (unsigned int comparison, _Decimal64 value);
17037 int __builtin_dfp_dtstsfi_gt (unsigned int comparison, _Decimal128 value);
17038 int __builtin_dfp_dtstsfi_gt_dd (unsigned int comparison, _Decimal64 value);
17039 int __builtin_dfp_dtstsfi_gt_td (unsigned int comparison, _Decimal128 value);
17041 int __builtin_dfp_dtstsfi_eq (unsigned int comparison, _Decimal64 value);
17042 int __builtin_dfp_dtstsfi_eq (unsigned int comparison, _Decimal128 value);
17043 int __builtin_dfp_dtstsfi_eq_dd (unsigned int comparison, _Decimal64 value);
17044 int __builtin_dfp_dtstsfi_eq_td (unsigned int comparison, _Decimal128 value);
17046 int __builtin_dfp_dtstsfi_ov (unsigned int comparison, _Decimal64 value);
17047 int __builtin_dfp_dtstsfi_ov (unsigned int comparison, _Decimal128 value);
17048 int __builtin_dfp_dtstsfi_ov_dd (unsigned int comparison, _Decimal64 value);
17049 int __builtin_dfp_dtstsfi_ov_td (unsigned int comparison, _Decimal128 value);
17051 double __builtin_mffsl(void);
17053 @end smallexample
17054 The @code{__builtin_byte_in_set} function requires a
17055 64-bit environment supporting ISA 3.0 or later.  This function returns
17056 a non-zero value if and only if its @code{u} argument exactly equals one of
17057 the eight bytes contained within its 64-bit @code{set} argument.
17059 The @code{__builtin_byte_in_range} and
17060 @code{__builtin_byte_in_either_range} require an environment
17061 supporting ISA 3.0 or later.  For these two functions, the
17062 @code{range} argument is encoded as 4 bytes, organized as
17063 @code{hi_1:lo_1:hi_2:lo_2}.
17064 The @code{__builtin_byte_in_range} function returns a
17065 non-zero value if and only if its @code{u} argument is within the
17066 range bounded between @code{lo_2} and @code{hi_2} inclusive.
17067 The @code{__builtin_byte_in_either_range} function returns non-zero if
17068 and only if its @code{u} argument is within either the range bounded
17069 between @code{lo_1} and @code{hi_1} inclusive or the range bounded
17070 between @code{lo_2} and @code{hi_2} inclusive.
17072 The @code{__builtin_dfp_dtstsfi_lt} function returns a non-zero value
17073 if and only if the number of signficant digits of its @code{value} argument
17074 is less than its @code{comparison} argument.  The
17075 @code{__builtin_dfp_dtstsfi_lt_dd} and
17076 @code{__builtin_dfp_dtstsfi_lt_td} functions behave similarly, but
17077 require that the type of the @code{value} argument be
17078 @code{__Decimal64} and @code{__Decimal128} respectively.
17080 The @code{__builtin_dfp_dtstsfi_gt} function returns a non-zero value
17081 if and only if the number of signficant digits of its @code{value} argument
17082 is greater than its @code{comparison} argument.  The
17083 @code{__builtin_dfp_dtstsfi_gt_dd} and
17084 @code{__builtin_dfp_dtstsfi_gt_td} functions behave similarly, but
17085 require that the type of the @code{value} argument be
17086 @code{__Decimal64} and @code{__Decimal128} respectively.
17088 The @code{__builtin_dfp_dtstsfi_eq} function returns a non-zero value
17089 if and only if the number of signficant digits of its @code{value} argument
17090 equals its @code{comparison} argument.  The
17091 @code{__builtin_dfp_dtstsfi_eq_dd} and
17092 @code{__builtin_dfp_dtstsfi_eq_td} functions behave similarly, but
17093 require that the type of the @code{value} argument be
17094 @code{__Decimal64} and @code{__Decimal128} respectively.
17096 The @code{__builtin_dfp_dtstsfi_ov} function returns a non-zero value
17097 if and only if its @code{value} argument has an undefined number of
17098 significant digits, such as when @code{value} is an encoding of @code{NaN}.
17099 The @code{__builtin_dfp_dtstsfi_ov_dd} and
17100 @code{__builtin_dfp_dtstsfi_ov_td} functions behave similarly, but
17101 require that the type of the @code{value} argument be
17102 @code{__Decimal64} and @code{__Decimal128} respectively.
17104 The @code{__builtin_mffsl} uses the ISA 3.0 @code{mffsl} instruction to read
17105 the FPSCR.  The instruction is a lower latency version of the @code{mffs}
17106 instruction.  If the @code{mffsl} instruction is not available, then the
17107 builtin uses the older @code{mffs} instruction to read the FPSCR.
17110 @node PowerPC AltiVec/VSX Built-in Functions
17111 @subsection PowerPC AltiVec/VSX Built-in Functions
17113 GCC provides an interface for the PowerPC family of processors to access
17114 the AltiVec operations described in Motorola's AltiVec Programming
17115 Interface Manual.  The interface is made available by including
17116 @code{<altivec.h>} and using @option{-maltivec} and
17117 @option{-mabi=altivec}.  The interface supports the following vector
17118 types.
17120 @smallexample
17121 vector unsigned char
17122 vector signed char
17123 vector bool char
17125 vector unsigned short
17126 vector signed short
17127 vector bool short
17128 vector pixel
17130 vector unsigned int
17131 vector signed int
17132 vector bool int
17133 vector float
17134 @end smallexample
17136 GCC's implementation of the high-level language interface available from
17137 C and C++ code differs from Motorola's documentation in several ways.
17139 @itemize @bullet
17141 @item
17142 A vector constant is a list of constant expressions within curly braces.
17144 @item
17145 A vector initializer requires no cast if the vector constant is of the
17146 same type as the variable it is initializing.
17148 @item
17149 If @code{signed} or @code{unsigned} is omitted, the signedness of the
17150 vector type is the default signedness of the base type.  The default
17151 varies depending on the operating system, so a portable program should
17152 always specify the signedness.
17154 @item
17155 Compiling with @option{-maltivec} adds keywords @code{__vector},
17156 @code{vector}, @code{__pixel}, @code{pixel}, @code{__bool} and
17157 @code{bool}.  When compiling ISO C, the context-sensitive substitution
17158 of the keywords @code{vector}, @code{pixel} and @code{bool} is
17159 disabled.  To use them, you must include @code{<altivec.h>} instead.
17161 @item
17162 GCC allows using a @code{typedef} name as the type specifier for a
17163 vector type, but only under the following circumstances:
17165 @itemize @bullet
17167 @item
17168 When using @code{__vector} instead of @code{vector}; for example,
17170 @smallexample
17171 typedef signed short int16;
17172 __vector int16 data;
17173 @end smallexample
17175 @item
17176 When using @code{vector} in keyword-and-predefine mode; for example,
17178 @smallexample
17179 typedef signed short int16;
17180 vector int16 data;
17181 @end smallexample
17183 Note that keyword-and-predefine mode is enabled by disabling GNU
17184 extensions (e.g., by using @code{-std=c11}) and including
17185 @code{<altivec.h>}.
17186 @end itemize
17188 @item
17189 For C, overloaded functions are implemented with macros so the following
17190 does not work:
17192 @smallexample
17193   vec_add ((vector signed int)@{1, 2, 3, 4@}, foo);
17194 @end smallexample
17196 @noindent
17197 Since @code{vec_add} is a macro, the vector constant in the example
17198 is treated as four separate arguments.  Wrap the entire argument in
17199 parentheses for this to work.
17200 @end itemize
17202 @emph{Note:} Only the @code{<altivec.h>} interface is supported.
17203 Internally, GCC uses built-in functions to achieve the functionality in
17204 the aforementioned header file, but they are not supported and are
17205 subject to change without notice.
17207 GCC complies with the OpenPOWER 64-Bit ELF V2 ABI Specification,
17208 which may be found at
17209 @uref{http://openpowerfoundation.org/wp-content/uploads/resources/leabi-prd/content/index.html}.
17210 Appendix A of this document lists the vector API interfaces that must be
17211 provided by compliant compilers.  Programmers should preferentially use
17212 the interfaces described therein.  However, historically GCC has provided
17213 additional interfaces for access to vector instructions.  These are
17214 briefly described below.
17216 @menu
17217 * PowerPC AltiVec Built-in Functions on ISA 2.05::
17218 * PowerPC AltiVec Built-in Functions Available on ISA 2.06::
17219 * PowerPC AltiVec Built-in Functions Available on ISA 2.07::
17220 * PowerPC AltiVec Built-in Functions Available on ISA 3.0::
17221 @end menu
17223 @node PowerPC AltiVec Built-in Functions on ISA 2.05
17224 @subsubsection PowerPC AltiVec Built-in Functions on ISA 2.05
17226 The following interfaces are supported for the generic and specific
17227 AltiVec operations and the AltiVec predicates.  In cases where there
17228 is a direct mapping between generic and specific operations, only the
17229 generic names are shown here, although the specific operations can also
17230 be used.
17232 Arguments that are documented as @code{const int} require literal
17233 integral values within the range required for that operation.
17235 @smallexample
17236 vector signed char vec_abs (vector signed char);
17237 vector signed short vec_abs (vector signed short);
17238 vector signed int vec_abs (vector signed int);
17239 vector float vec_abs (vector float);
17241 vector signed char vec_abss (vector signed char);
17242 vector signed short vec_abss (vector signed short);
17243 vector signed int vec_abss (vector signed int);
17245 vector signed char vec_add (vector bool char, vector signed char);
17246 vector signed char vec_add (vector signed char, vector bool char);
17247 vector signed char vec_add (vector signed char, vector signed char);
17248 vector unsigned char vec_add (vector bool char, vector unsigned char);
17249 vector unsigned char vec_add (vector unsigned char, vector bool char);
17250 vector unsigned char vec_add (vector unsigned char, vector unsigned char);
17251 vector signed short vec_add (vector bool short, vector signed short);
17252 vector signed short vec_add (vector signed short, vector bool short);
17253 vector signed short vec_add (vector signed short, vector signed short);
17254 vector unsigned short vec_add (vector bool short, vector unsigned short);
17255 vector unsigned short vec_add (vector unsigned short, vector bool short);
17256 vector unsigned short vec_add (vector unsigned short, vector unsigned short);
17257 vector signed int vec_add (vector bool int, vector signed int);
17258 vector signed int vec_add (vector signed int, vector bool int);
17259 vector signed int vec_add (vector signed int, vector signed int);
17260 vector unsigned int vec_add (vector bool int, vector unsigned int);
17261 vector unsigned int vec_add (vector unsigned int, vector bool int);
17262 vector unsigned int vec_add (vector unsigned int, vector unsigned int);
17263 vector float vec_add (vector float, vector float);
17265 vector unsigned int vec_addc (vector unsigned int, vector unsigned int);
17267 vector unsigned char vec_adds (vector bool char, vector unsigned char);
17268 vector unsigned char vec_adds (vector unsigned char, vector bool char);
17269 vector unsigned char vec_adds (vector unsigned char, vector unsigned char);
17270 vector signed char vec_adds (vector bool char, vector signed char);
17271 vector signed char vec_adds (vector signed char, vector bool char);
17272 vector signed char vec_adds (vector signed char, vector signed char);
17273 vector unsigned short vec_adds (vector bool short, vector unsigned short);
17274 vector unsigned short vec_adds (vector unsigned short, vector bool short);
17275 vector unsigned short vec_adds (vector unsigned short, vector unsigned short);
17276 vector signed short vec_adds (vector bool short, vector signed short);
17277 vector signed short vec_adds (vector signed short, vector bool short);
17278 vector signed short vec_adds (vector signed short, vector signed short);
17279 vector unsigned int vec_adds (vector bool int, vector unsigned int);
17280 vector unsigned int vec_adds (vector unsigned int, vector bool int);
17281 vector unsigned int vec_adds (vector unsigned int, vector unsigned int);
17282 vector signed int vec_adds (vector bool int, vector signed int);
17283 vector signed int vec_adds (vector signed int, vector bool int);
17284 vector signed int vec_adds (vector signed int, vector signed int);
17286 int vec_all_eq (vector signed char, vector bool char);
17287 int vec_all_eq (vector signed char, vector signed char);
17288 int vec_all_eq (vector unsigned char, vector bool char);
17289 int vec_all_eq (vector unsigned char, vector unsigned char);
17290 int vec_all_eq (vector bool char, vector bool char);
17291 int vec_all_eq (vector bool char, vector unsigned char);
17292 int vec_all_eq (vector bool char, vector signed char);
17293 int vec_all_eq (vector signed short, vector bool short);
17294 int vec_all_eq (vector signed short, vector signed short);
17295 int vec_all_eq (vector unsigned short, vector bool short);
17296 int vec_all_eq (vector unsigned short, vector unsigned short);
17297 int vec_all_eq (vector bool short, vector bool short);
17298 int vec_all_eq (vector bool short, vector unsigned short);
17299 int vec_all_eq (vector bool short, vector signed short);
17300 int vec_all_eq (vector pixel, vector pixel);
17301 int vec_all_eq (vector signed int, vector bool int);
17302 int vec_all_eq (vector signed int, vector signed int);
17303 int vec_all_eq (vector unsigned int, vector bool int);
17304 int vec_all_eq (vector unsigned int, vector unsigned int);
17305 int vec_all_eq (vector bool int, vector bool int);
17306 int vec_all_eq (vector bool int, vector unsigned int);
17307 int vec_all_eq (vector bool int, vector signed int);
17308 int vec_all_eq (vector float, vector float);
17310 int vec_all_ge (vector bool char, vector unsigned char);
17311 int vec_all_ge (vector unsigned char, vector bool char);
17312 int vec_all_ge (vector unsigned char, vector unsigned char);
17313 int vec_all_ge (vector bool char, vector signed char);
17314 int vec_all_ge (vector signed char, vector bool char);
17315 int vec_all_ge (vector signed char, vector signed char);
17316 int vec_all_ge (vector bool short, vector unsigned short);
17317 int vec_all_ge (vector unsigned short, vector bool short);
17318 int vec_all_ge (vector unsigned short, vector unsigned short);
17319 int vec_all_ge (vector signed short, vector signed short);
17320 int vec_all_ge (vector bool short, vector signed short);
17321 int vec_all_ge (vector signed short, vector bool short);
17322 int vec_all_ge (vector bool int, vector unsigned int);
17323 int vec_all_ge (vector unsigned int, vector bool int);
17324 int vec_all_ge (vector unsigned int, vector unsigned int);
17325 int vec_all_ge (vector bool int, vector signed int);
17326 int vec_all_ge (vector signed int, vector bool int);
17327 int vec_all_ge (vector signed int, vector signed int);
17328 int vec_all_ge (vector float, vector float);
17330 int vec_all_gt (vector bool char, vector unsigned char);
17331 int vec_all_gt (vector unsigned char, vector bool char);
17332 int vec_all_gt (vector unsigned char, vector unsigned char);
17333 int vec_all_gt (vector bool char, vector signed char);
17334 int vec_all_gt (vector signed char, vector bool char);
17335 int vec_all_gt (vector signed char, vector signed char);
17336 int vec_all_gt (vector bool short, vector unsigned short);
17337 int vec_all_gt (vector unsigned short, vector bool short);
17338 int vec_all_gt (vector unsigned short, vector unsigned short);
17339 int vec_all_gt (vector bool short, vector signed short);
17340 int vec_all_gt (vector signed short, vector bool short);
17341 int vec_all_gt (vector signed short, vector signed short);
17342 int vec_all_gt (vector bool int, vector unsigned int);
17343 int vec_all_gt (vector unsigned int, vector bool int);
17344 int vec_all_gt (vector unsigned int, vector unsigned int);
17345 int vec_all_gt (vector bool int, vector signed int);
17346 int vec_all_gt (vector signed int, vector bool int);
17347 int vec_all_gt (vector signed int, vector signed int);
17348 int vec_all_gt (vector float, vector float);
17350 int vec_all_in (vector float, vector float);
17352 int vec_all_le (vector bool char, vector unsigned char);
17353 int vec_all_le (vector unsigned char, vector bool char);
17354 int vec_all_le (vector unsigned char, vector unsigned char);
17355 int vec_all_le (vector bool char, vector signed char);
17356 int vec_all_le (vector signed char, vector bool char);
17357 int vec_all_le (vector signed char, vector signed char);
17358 int vec_all_le (vector bool short, vector unsigned short);
17359 int vec_all_le (vector unsigned short, vector bool short);
17360 int vec_all_le (vector unsigned short, vector unsigned short);
17361 int vec_all_le (vector bool short, vector signed short);
17362 int vec_all_le (vector signed short, vector bool short);
17363 int vec_all_le (vector signed short, vector signed short);
17364 int vec_all_le (vector bool int, vector unsigned int);
17365 int vec_all_le (vector unsigned int, vector bool int);
17366 int vec_all_le (vector unsigned int, vector unsigned int);
17367 int vec_all_le (vector bool int, vector signed int);
17368 int vec_all_le (vector signed int, vector bool int);
17369 int vec_all_le (vector signed int, vector signed int);
17370 int vec_all_le (vector float, vector float);
17372 int vec_all_lt (vector bool char, vector unsigned char);
17373 int vec_all_lt (vector unsigned char, vector bool char);
17374 int vec_all_lt (vector unsigned char, vector unsigned char);
17375 int vec_all_lt (vector bool char, vector signed char);
17376 int vec_all_lt (vector signed char, vector bool char);
17377 int vec_all_lt (vector signed char, vector signed char);
17378 int vec_all_lt (vector bool short, vector unsigned short);
17379 int vec_all_lt (vector unsigned short, vector bool short);
17380 int vec_all_lt (vector unsigned short, vector unsigned short);
17381 int vec_all_lt (vector bool short, vector signed short);
17382 int vec_all_lt (vector signed short, vector bool short);
17383 int vec_all_lt (vector signed short, vector signed short);
17384 int vec_all_lt (vector bool int, vector unsigned int);
17385 int vec_all_lt (vector unsigned int, vector bool int);
17386 int vec_all_lt (vector unsigned int, vector unsigned int);
17387 int vec_all_lt (vector bool int, vector signed int);
17388 int vec_all_lt (vector signed int, vector bool int);
17389 int vec_all_lt (vector signed int, vector signed int);
17390 int vec_all_lt (vector float, vector float);
17392 int vec_all_nan (vector float);
17394 int vec_all_ne (vector signed char, vector bool char);
17395 int vec_all_ne (vector signed char, vector signed char);
17396 int vec_all_ne (vector unsigned char, vector bool char);
17397 int vec_all_ne (vector unsigned char, vector unsigned char);
17398 int vec_all_ne (vector bool char, vector bool char);
17399 int vec_all_ne (vector bool char, vector unsigned char);
17400 int vec_all_ne (vector bool char, vector signed char);
17401 int vec_all_ne (vector signed short, vector bool short);
17402 int vec_all_ne (vector signed short, vector signed short);
17403 int vec_all_ne (vector unsigned short, vector bool short);
17404 int vec_all_ne (vector unsigned short, vector unsigned short);
17405 int vec_all_ne (vector bool short, vector bool short);
17406 int vec_all_ne (vector bool short, vector unsigned short);
17407 int vec_all_ne (vector bool short, vector signed short);
17408 int vec_all_ne (vector pixel, vector pixel);
17409 int vec_all_ne (vector signed int, vector bool int);
17410 int vec_all_ne (vector signed int, vector signed int);
17411 int vec_all_ne (vector unsigned int, vector bool int);
17412 int vec_all_ne (vector unsigned int, vector unsigned int);
17413 int vec_all_ne (vector bool int, vector bool int);
17414 int vec_all_ne (vector bool int, vector unsigned int);
17415 int vec_all_ne (vector bool int, vector signed int);
17416 int vec_all_ne (vector float, vector float);
17418 int vec_all_nge (vector float, vector float);
17420 int vec_all_ngt (vector float, vector float);
17422 int vec_all_nle (vector float, vector float);
17424 int vec_all_nlt (vector float, vector float);
17426 int vec_all_numeric (vector float);
17428 vector float vec_and (vector float, vector float);
17429 vector float vec_and (vector float, vector bool int);
17430 vector float vec_and (vector bool int, vector float);
17431 vector bool int vec_and (vector bool int, vector bool int);
17432 vector signed int vec_and (vector bool int, vector signed int);
17433 vector signed int vec_and (vector signed int, vector bool int);
17434 vector signed int vec_and (vector signed int, vector signed int);
17435 vector unsigned int vec_and (vector bool int, vector unsigned int);
17436 vector unsigned int vec_and (vector unsigned int, vector bool int);
17437 vector unsigned int vec_and (vector unsigned int, vector unsigned int);
17438 vector bool short vec_and (vector bool short, vector bool short);
17439 vector signed short vec_and (vector bool short, vector signed short);
17440 vector signed short vec_and (vector signed short, vector bool short);
17441 vector signed short vec_and (vector signed short, vector signed short);
17442 vector unsigned short vec_and (vector bool short, vector unsigned short);
17443 vector unsigned short vec_and (vector unsigned short, vector bool short);
17444 vector unsigned short vec_and (vector unsigned short, vector unsigned short);
17445 vector signed char vec_and (vector bool char, vector signed char);
17446 vector bool char vec_and (vector bool char, vector bool char);
17447 vector signed char vec_and (vector signed char, vector bool char);
17448 vector signed char vec_and (vector signed char, vector signed char);
17449 vector unsigned char vec_and (vector bool char, vector unsigned char);
17450 vector unsigned char vec_and (vector unsigned char, vector bool char);
17451 vector unsigned char vec_and (vector unsigned char, vector unsigned char);
17453 vector float vec_andc (vector float, vector float);
17454 vector float vec_andc (vector float, vector bool int);
17455 vector float vec_andc (vector bool int, vector float);
17456 vector bool int vec_andc (vector bool int, vector bool int);
17457 vector signed int vec_andc (vector bool int, vector signed int);
17458 vector signed int vec_andc (vector signed int, vector bool int);
17459 vector signed int vec_andc (vector signed int, vector signed int);
17460 vector unsigned int vec_andc (vector bool int, vector unsigned int);
17461 vector unsigned int vec_andc (vector unsigned int, vector bool int);
17462 vector unsigned int vec_andc (vector unsigned int, vector unsigned int);
17463 vector bool short vec_andc (vector bool short, vector bool short);
17464 vector signed short vec_andc (vector bool short, vector signed short);
17465 vector signed short vec_andc (vector signed short, vector bool short);
17466 vector signed short vec_andc (vector signed short, vector signed short);
17467 vector unsigned short vec_andc (vector bool short, vector unsigned short);
17468 vector unsigned short vec_andc (vector unsigned short, vector bool short);
17469 vector unsigned short vec_andc (vector unsigned short, vector unsigned short);
17470 vector signed char vec_andc (vector bool char, vector signed char);
17471 vector bool char vec_andc (vector bool char, vector bool char);
17472 vector signed char vec_andc (vector signed char, vector bool char);
17473 vector signed char vec_andc (vector signed char, vector signed char);
17474 vector unsigned char vec_andc (vector bool char, vector unsigned char);
17475 vector unsigned char vec_andc (vector unsigned char, vector bool char);
17476 vector unsigned char vec_andc (vector unsigned char, vector unsigned char);
17478 int vec_any_eq (vector signed char, vector bool char);
17479 int vec_any_eq (vector signed char, vector signed char);
17480 int vec_any_eq (vector unsigned char, vector bool char);
17481 int vec_any_eq (vector unsigned char, vector unsigned char);
17482 int vec_any_eq (vector bool char, vector bool char);
17483 int vec_any_eq (vector bool char, vector unsigned char);
17484 int vec_any_eq (vector bool char, vector signed char);
17485 int vec_any_eq (vector signed short, vector bool short);
17486 int vec_any_eq (vector signed short, vector signed short);
17487 int vec_any_eq (vector unsigned short, vector bool short);
17488 int vec_any_eq (vector unsigned short, vector unsigned short);
17489 int vec_any_eq (vector bool short, vector bool short);
17490 int vec_any_eq (vector bool short, vector unsigned short);
17491 int vec_any_eq (vector bool short, vector signed short);
17492 int vec_any_eq (vector pixel, vector pixel);
17493 int vec_any_eq (vector signed int, vector bool int);
17494 int vec_any_eq (vector signed int, vector signed int);
17495 int vec_any_eq (vector unsigned int, vector bool int);
17496 int vec_any_eq (vector unsigned int, vector unsigned int);
17497 int vec_any_eq (vector bool int, vector bool int);
17498 int vec_any_eq (vector bool int, vector unsigned int);
17499 int vec_any_eq (vector bool int, vector signed int);
17500 int vec_any_eq (vector float, vector float);
17502 int vec_any_ge (vector signed char, vector bool char);
17503 int vec_any_ge (vector unsigned char, vector bool char);
17504 int vec_any_ge (vector unsigned char, vector unsigned char);
17505 int vec_any_ge (vector signed char, vector signed char);
17506 int vec_any_ge (vector bool char, vector unsigned char);
17507 int vec_any_ge (vector bool char, vector signed char);
17508 int vec_any_ge (vector unsigned short, vector bool short);
17509 int vec_any_ge (vector unsigned short, vector unsigned short);
17510 int vec_any_ge (vector signed short, vector signed short);
17511 int vec_any_ge (vector signed short, vector bool short);
17512 int vec_any_ge (vector bool short, vector unsigned short);
17513 int vec_any_ge (vector bool short, vector signed short);
17514 int vec_any_ge (vector signed int, vector bool int);
17515 int vec_any_ge (vector unsigned int, vector bool int);
17516 int vec_any_ge (vector unsigned int, vector unsigned int);
17517 int vec_any_ge (vector signed int, vector signed int);
17518 int vec_any_ge (vector bool int, vector unsigned int);
17519 int vec_any_ge (vector bool int, vector signed int);
17520 int vec_any_ge (vector float, vector float);
17522 int vec_any_gt (vector bool char, vector unsigned char);
17523 int vec_any_gt (vector unsigned char, vector bool char);
17524 int vec_any_gt (vector unsigned char, vector unsigned char);
17525 int vec_any_gt (vector bool char, vector signed char);
17526 int vec_any_gt (vector signed char, vector bool char);
17527 int vec_any_gt (vector signed char, vector signed char);
17528 int vec_any_gt (vector bool short, vector unsigned short);
17529 int vec_any_gt (vector unsigned short, vector bool short);
17530 int vec_any_gt (vector unsigned short, vector unsigned short);
17531 int vec_any_gt (vector bool short, vector signed short);
17532 int vec_any_gt (vector signed short, vector bool short);
17533 int vec_any_gt (vector signed short, vector signed short);
17534 int vec_any_gt (vector bool int, vector unsigned int);
17535 int vec_any_gt (vector unsigned int, vector bool int);
17536 int vec_any_gt (vector unsigned int, vector unsigned int);
17537 int vec_any_gt (vector bool int, vector signed int);
17538 int vec_any_gt (vector signed int, vector bool int);
17539 int vec_any_gt (vector signed int, vector signed int);
17540 int vec_any_gt (vector float, vector float);
17542 int vec_any_le (vector bool char, vector unsigned char);
17543 int vec_any_le (vector unsigned char, vector bool char);
17544 int vec_any_le (vector unsigned char, vector unsigned char);
17545 int vec_any_le (vector bool char, vector signed char);
17546 int vec_any_le (vector signed char, vector bool char);
17547 int vec_any_le (vector signed char, vector signed char);
17548 int vec_any_le (vector bool short, vector unsigned short);
17549 int vec_any_le (vector unsigned short, vector bool short);
17550 int vec_any_le (vector unsigned short, vector unsigned short);
17551 int vec_any_le (vector bool short, vector signed short);
17552 int vec_any_le (vector signed short, vector bool short);
17553 int vec_any_le (vector signed short, vector signed short);
17554 int vec_any_le (vector bool int, vector unsigned int);
17555 int vec_any_le (vector unsigned int, vector bool int);
17556 int vec_any_le (vector unsigned int, vector unsigned int);
17557 int vec_any_le (vector bool int, vector signed int);
17558 int vec_any_le (vector signed int, vector bool int);
17559 int vec_any_le (vector signed int, vector signed int);
17560 int vec_any_le (vector float, vector float);
17562 int vec_any_lt (vector bool char, vector unsigned char);
17563 int vec_any_lt (vector unsigned char, vector bool char);
17564 int vec_any_lt (vector unsigned char, vector unsigned char);
17565 int vec_any_lt (vector bool char, vector signed char);
17566 int vec_any_lt (vector signed char, vector bool char);
17567 int vec_any_lt (vector signed char, vector signed char);
17568 int vec_any_lt (vector bool short, vector unsigned short);
17569 int vec_any_lt (vector unsigned short, vector bool short);
17570 int vec_any_lt (vector unsigned short, vector unsigned short);
17571 int vec_any_lt (vector bool short, vector signed short);
17572 int vec_any_lt (vector signed short, vector bool short);
17573 int vec_any_lt (vector signed short, vector signed short);
17574 int vec_any_lt (vector bool int, vector unsigned int);
17575 int vec_any_lt (vector unsigned int, vector bool int);
17576 int vec_any_lt (vector unsigned int, vector unsigned int);
17577 int vec_any_lt (vector bool int, vector signed int);
17578 int vec_any_lt (vector signed int, vector bool int);
17579 int vec_any_lt (vector signed int, vector signed int);
17580 int vec_any_lt (vector float, vector float);
17582 int vec_any_nan (vector float);
17584 int vec_any_ne (vector signed char, vector bool char);
17585 int vec_any_ne (vector signed char, vector signed char);
17586 int vec_any_ne (vector unsigned char, vector bool char);
17587 int vec_any_ne (vector unsigned char, vector unsigned char);
17588 int vec_any_ne (vector bool char, vector bool char);
17589 int vec_any_ne (vector bool char, vector unsigned char);
17590 int vec_any_ne (vector bool char, vector signed char);
17591 int vec_any_ne (vector signed short, vector bool short);
17592 int vec_any_ne (vector signed short, vector signed short);
17593 int vec_any_ne (vector unsigned short, vector bool short);
17594 int vec_any_ne (vector unsigned short, vector unsigned short);
17595 int vec_any_ne (vector bool short, vector bool short);
17596 int vec_any_ne (vector bool short, vector unsigned short);
17597 int vec_any_ne (vector bool short, vector signed short);
17598 int vec_any_ne (vector pixel, vector pixel);
17599 int vec_any_ne (vector signed int, vector bool int);
17600 int vec_any_ne (vector signed int, vector signed int);
17601 int vec_any_ne (vector unsigned int, vector bool int);
17602 int vec_any_ne (vector unsigned int, vector unsigned int);
17603 int vec_any_ne (vector bool int, vector bool int);
17604 int vec_any_ne (vector bool int, vector unsigned int);
17605 int vec_any_ne (vector bool int, vector signed int);
17606 int vec_any_ne (vector float, vector float);
17608 int vec_any_nge (vector float, vector float);
17610 int vec_any_ngt (vector float, vector float);
17612 int vec_any_nle (vector float, vector float);
17614 int vec_any_nlt (vector float, vector float);
17616 int vec_any_numeric (vector float);
17618 int vec_any_out (vector float, vector float);
17620 vector unsigned char vec_avg (vector unsigned char, vector unsigned char);
17621 vector signed char vec_avg (vector signed char, vector signed char);
17622 vector unsigned short vec_avg (vector unsigned short, vector unsigned short);
17623 vector signed short vec_avg (vector signed short, vector signed short);
17624 vector unsigned int vec_avg (vector unsigned int, vector unsigned int);
17625 vector signed int vec_avg (vector signed int, vector signed int);
17627 vector float vec_ceil (vector float);
17629 vector signed int vec_cmpb (vector float, vector float);
17631 vector bool char vec_cmpeq (vector bool char, vector bool char);
17632 vector bool short vec_cmpeq (vector bool short, vector bool short);
17633 vector bool int vec_cmpeq (vector bool int, vector bool int);
17634 vector bool char vec_cmpeq (vector signed char, vector signed char);
17635 vector bool char vec_cmpeq (vector unsigned char, vector unsigned char);
17636 vector bool short vec_cmpeq (vector signed short, vector signed short);
17637 vector bool short vec_cmpeq (vector unsigned short, vector unsigned short);
17638 vector bool int vec_cmpeq (vector signed int, vector signed int);
17639 vector bool int vec_cmpeq (vector unsigned int, vector unsigned int);
17640 vector bool int vec_cmpeq (vector float, vector float);
17642 vector bool int vec_cmpge (vector float, vector float);
17644 vector bool char vec_cmpgt (vector unsigned char, vector unsigned char);
17645 vector bool char vec_cmpgt (vector signed char, vector signed char);
17646 vector bool short vec_cmpgt (vector unsigned short, vector unsigned short);
17647 vector bool short vec_cmpgt (vector signed short, vector signed short);
17648 vector bool int vec_cmpgt (vector unsigned int, vector unsigned int);
17649 vector bool int vec_cmpgt (vector signed int, vector signed int);
17650 vector bool int vec_cmpgt (vector float, vector float);
17652 vector bool int vec_cmple (vector float, vector float);
17654 vector bool char vec_cmplt (vector unsigned char, vector unsigned char);
17655 vector bool char vec_cmplt (vector signed char, vector signed char);
17656 vector bool short vec_cmplt (vector unsigned short, vector unsigned short);
17657 vector bool short vec_cmplt (vector signed short, vector signed short);
17658 vector bool int vec_cmplt (vector unsigned int, vector unsigned int);
17659 vector bool int vec_cmplt (vector signed int, vector signed int);
17660 vector bool int vec_cmplt (vector float, vector float);
17662 vector float vec_cpsgn (vector float, vector float);
17664 vector float vec_ctf (vector unsigned int, const int);
17665 vector float vec_ctf (vector signed int, const int);
17667 vector signed int vec_cts (vector float, const int);
17669 vector unsigned int vec_ctu (vector float, const int);
17671 void vec_dss (const int);
17673 void vec_dssall (void);
17675 void vec_dst (const vector unsigned char *, int, const int);
17676 void vec_dst (const vector signed char *, int, const int);
17677 void vec_dst (const vector bool char *, int, const int);
17678 void vec_dst (const vector unsigned short *, int, const int);
17679 void vec_dst (const vector signed short *, int, const int);
17680 void vec_dst (const vector bool short *, int, const int);
17681 void vec_dst (const vector pixel *, int, const int);
17682 void vec_dst (const vector unsigned int *, int, const int);
17683 void vec_dst (const vector signed int *, int, const int);
17684 void vec_dst (const vector bool int *, int, const int);
17685 void vec_dst (const vector float *, int, const int);
17686 void vec_dst (const unsigned char *, int, const int);
17687 void vec_dst (const signed char *, int, const int);
17688 void vec_dst (const unsigned short *, int, const int);
17689 void vec_dst (const short *, int, const int);
17690 void vec_dst (const unsigned int *, int, const int);
17691 void vec_dst (const int *, int, const int);
17692 void vec_dst (const float *, int, const int);
17694 void vec_dstst (const vector unsigned char *, int, const int);
17695 void vec_dstst (const vector signed char *, int, const int);
17696 void vec_dstst (const vector bool char *, int, const int);
17697 void vec_dstst (const vector unsigned short *, int, const int);
17698 void vec_dstst (const vector signed short *, int, const int);
17699 void vec_dstst (const vector bool short *, int, const int);
17700 void vec_dstst (const vector pixel *, int, const int);
17701 void vec_dstst (const vector unsigned int *, int, const int);
17702 void vec_dstst (const vector signed int *, int, const int);
17703 void vec_dstst (const vector bool int *, int, const int);
17704 void vec_dstst (const vector float *, int, const int);
17705 void vec_dstst (const unsigned char *, int, const int);
17706 void vec_dstst (const signed char *, int, const int);
17707 void vec_dstst (const unsigned short *, int, const int);
17708 void vec_dstst (const short *, int, const int);
17709 void vec_dstst (const unsigned int *, int, const int);
17710 void vec_dstst (const int *, int, const int);
17711 void vec_dstst (const unsigned long *, int, const int);
17712 void vec_dstst (const long *, int, const int);
17713 void vec_dstst (const float *, int, const int);
17715 void vec_dststt (const vector unsigned char *, int, const int);
17716 void vec_dststt (const vector signed char *, int, const int);
17717 void vec_dststt (const vector bool char *, int, const int);
17718 void vec_dststt (const vector unsigned short *, int, const int);
17719 void vec_dststt (const vector signed short *, int, const int);
17720 void vec_dststt (const vector bool short *, int, const int);
17721 void vec_dststt (const vector pixel *, int, const int);
17722 void vec_dststt (const vector unsigned int *, int, const int);
17723 void vec_dststt (const vector signed int *, int, const int);
17724 void vec_dststt (const vector bool int *, int, const int);
17725 void vec_dststt (const vector float *, int, const int);
17726 void vec_dststt (const unsigned char *, int, const int);
17727 void vec_dststt (const signed char *, int, const int);
17728 void vec_dststt (const unsigned short *, int, const int);
17729 void vec_dststt (const short *, int, const int);
17730 void vec_dststt (const unsigned int *, int, const int);
17731 void vec_dststt (const int *, int, const int);
17732 void vec_dststt (const float *, int, const int);
17734 void vec_dstt (const vector unsigned char *, int, const int);
17735 void vec_dstt (const vector signed char *, int, const int);
17736 void vec_dstt (const vector bool char *, int, const int);
17737 void vec_dstt (const vector unsigned short *, int, const int);
17738 void vec_dstt (const vector signed short *, int, const int);
17739 void vec_dstt (const vector bool short *, int, const int);
17740 void vec_dstt (const vector pixel *, int, const int);
17741 void vec_dstt (const vector unsigned int *, int, const int);
17742 void vec_dstt (const vector signed int *, int, const int);
17743 void vec_dstt (const vector bool int *, int, const int);
17744 void vec_dstt (const vector float *, int, const int);
17745 void vec_dstt (const unsigned char *, int, const int);
17746 void vec_dstt (const signed char *, int, const int);
17747 void vec_dstt (const unsigned short *, int, const int);
17748 void vec_dstt (const short *, int, const int);
17749 void vec_dstt (const unsigned int *, int, const int);
17750 void vec_dstt (const int *, int, const int);
17751 void vec_dstt (const float *, int, const int);
17753 vector float vec_expte (vector float);
17755 vector float vec_floor (vector float);
17757 vector float vec_ld (int, const vector float *);
17758 vector float vec_ld (int, const float *);
17759 vector bool int vec_ld (int, const vector bool int *);
17760 vector signed int vec_ld (int, const vector signed int *);
17761 vector signed int vec_ld (int, const int *);
17762 vector unsigned int vec_ld (int, const vector unsigned int *);
17763 vector unsigned int vec_ld (int, const unsigned int *);
17764 vector bool short vec_ld (int, const vector bool short *);
17765 vector pixel vec_ld (int, const vector pixel *);
17766 vector signed short vec_ld (int, const vector signed short *);
17767 vector signed short vec_ld (int, const short *);
17768 vector unsigned short vec_ld (int, const vector unsigned short *);
17769 vector unsigned short vec_ld (int, const unsigned short *);
17770 vector bool char vec_ld (int, const vector bool char *);
17771 vector signed char vec_ld (int, const vector signed char *);
17772 vector signed char vec_ld (int, const signed char *);
17773 vector unsigned char vec_ld (int, const vector unsigned char *);
17774 vector unsigned char vec_ld (int, const unsigned char *);
17776 vector signed char vec_lde (int, const signed char *);
17777 vector unsigned char vec_lde (int, const unsigned char *);
17778 vector signed short vec_lde (int, const short *);
17779 vector unsigned short vec_lde (int, const unsigned short *);
17780 vector float vec_lde (int, const float *);
17781 vector signed int vec_lde (int, const int *);
17782 vector unsigned int vec_lde (int, const unsigned int *);
17784 vector float vec_ldl (int, const vector float *);
17785 vector float vec_ldl (int, const float *);
17786 vector bool int vec_ldl (int, const vector bool int *);
17787 vector signed int vec_ldl (int, const vector signed int *);
17788 vector signed int vec_ldl (int, const int *);
17789 vector unsigned int vec_ldl (int, const vector unsigned int *);
17790 vector unsigned int vec_ldl (int, const unsigned int *);
17791 vector bool short vec_ldl (int, const vector bool short *);
17792 vector pixel vec_ldl (int, const vector pixel *);
17793 vector signed short vec_ldl (int, const vector signed short *);
17794 vector signed short vec_ldl (int, const short *);
17795 vector unsigned short vec_ldl (int, const vector unsigned short *);
17796 vector unsigned short vec_ldl (int, const unsigned short *);
17797 vector bool char vec_ldl (int, const vector bool char *);
17798 vector signed char vec_ldl (int, const vector signed char *);
17799 vector signed char vec_ldl (int, const signed char *);
17800 vector unsigned char vec_ldl (int, const vector unsigned char *);
17801 vector unsigned char vec_ldl (int, const unsigned char *);
17803 vector float vec_loge (vector float);
17805 vector signed char vec_lvebx (int, char *);
17806 vector unsigned char vec_lvebx (int, unsigned char *);
17808 vector signed short vec_lvehx (int, short *);
17809 vector unsigned short vec_lvehx (int, unsigned short *);
17811 vector float vec_lvewx (int, float *);
17812 vector signed int vec_lvewx (int, int *);
17813 vector unsigned int vec_lvewx (int, unsigned int *);
17815 vector unsigned char vec_lvsl (int, const unsigned char *);
17816 vector unsigned char vec_lvsl (int, const signed char *);
17817 vector unsigned char vec_lvsl (int, const unsigned short *);
17818 vector unsigned char vec_lvsl (int, const short *);
17819 vector unsigned char vec_lvsl (int, const unsigned int *);
17820 vector unsigned char vec_lvsl (int, const int *);
17821 vector unsigned char vec_lvsl (int, const float *);
17823 vector unsigned char vec_lvsr (int, const unsigned char *);
17824 vector unsigned char vec_lvsr (int, const signed char *);
17825 vector unsigned char vec_lvsr (int, const unsigned short *);
17826 vector unsigned char vec_lvsr (int, const short *);
17827 vector unsigned char vec_lvsr (int, const unsigned int *);
17828 vector unsigned char vec_lvsr (int, const int *);
17829 vector unsigned char vec_lvsr (int, const float *);
17831 vector float vec_madd (vector float, vector float, vector float);
17833 vector signed short vec_madds (vector signed short, vector signed short,
17834                                vector signed short);
17836 vector unsigned char vec_max (vector bool char, vector unsigned char);
17837 vector unsigned char vec_max (vector unsigned char, vector bool char);
17838 vector unsigned char vec_max (vector unsigned char, vector unsigned char);
17839 vector signed char vec_max (vector bool char, vector signed char);
17840 vector signed char vec_max (vector signed char, vector bool char);
17841 vector signed char vec_max (vector signed char, vector signed char);
17842 vector unsigned short vec_max (vector bool short, vector unsigned short);
17843 vector unsigned short vec_max (vector unsigned short, vector bool short);
17844 vector unsigned short vec_max (vector unsigned short, vector unsigned short);
17845 vector signed short vec_max (vector bool short, vector signed short);
17846 vector signed short vec_max (vector signed short, vector bool short);
17847 vector signed short vec_max (vector signed short, vector signed short);
17848 vector unsigned int vec_max (vector bool int, vector unsigned int);
17849 vector unsigned int vec_max (vector unsigned int, vector bool int);
17850 vector unsigned int vec_max (vector unsigned int, vector unsigned int);
17851 vector signed int vec_max (vector bool int, vector signed int);
17852 vector signed int vec_max (vector signed int, vector bool int);
17853 vector signed int vec_max (vector signed int, vector signed int);
17854 vector float vec_max (vector float, vector float);
17856 vector bool char vec_mergeh (vector bool char, vector bool char);
17857 vector signed char vec_mergeh (vector signed char, vector signed char);
17858 vector unsigned char vec_mergeh (vector unsigned char, vector unsigned char);
17859 vector bool short vec_mergeh (vector bool short, vector bool short);
17860 vector pixel vec_mergeh (vector pixel, vector pixel);
17861 vector signed short vec_mergeh (vector signed short, vector signed short);
17862 vector unsigned short vec_mergeh (vector unsigned short, vector unsigned short);
17863 vector float vec_mergeh (vector float, vector float);
17864 vector bool int vec_mergeh (vector bool int, vector bool int);
17865 vector signed int vec_mergeh (vector signed int, vector signed int);
17866 vector unsigned int vec_mergeh (vector unsigned int, vector unsigned int);
17868 vector bool char vec_mergel (vector bool char, vector bool char);
17869 vector signed char vec_mergel (vector signed char, vector signed char);
17870 vector unsigned char vec_mergel (vector unsigned char, vector unsigned char);
17871 vector bool short vec_mergel (vector bool short, vector bool short);
17872 vector pixel vec_mergel (vector pixel, vector pixel);
17873 vector signed short vec_mergel (vector signed short, vector signed short);
17874 vector unsigned short vec_mergel (vector unsigned short, vector unsigned short);
17875 vector float vec_mergel (vector float, vector float);
17876 vector bool int vec_mergel (vector bool int, vector bool int);
17877 vector signed int vec_mergel (vector signed int, vector signed int);
17878 vector unsigned int vec_mergel (vector unsigned int, vector unsigned int);
17880 vector unsigned short vec_mfvscr (void);
17882 vector unsigned char vec_min (vector bool char, vector unsigned char);
17883 vector unsigned char vec_min (vector unsigned char, vector bool char);
17884 vector unsigned char vec_min (vector unsigned char, vector unsigned char);
17885 vector signed char vec_min (vector bool char, vector signed char);
17886 vector signed char vec_min (vector signed char, vector bool char);
17887 vector signed char vec_min (vector signed char, vector signed char);
17888 vector unsigned short vec_min (vector bool short, vector unsigned short);
17889 vector unsigned short vec_min (vector unsigned short, vector bool short);
17890 vector unsigned short vec_min (vector unsigned short, vector unsigned short);
17891 vector signed short vec_min (vector bool short, vector signed short);
17892 vector signed short vec_min (vector signed short, vector bool short);
17893 vector signed short vec_min (vector signed short, vector signed short);
17894 vector unsigned int vec_min (vector bool int, vector unsigned int);
17895 vector unsigned int vec_min (vector unsigned int, vector bool int);
17896 vector unsigned int vec_min (vector unsigned int, vector unsigned int);
17897 vector signed int vec_min (vector bool int, vector signed int);
17898 vector signed int vec_min (vector signed int, vector bool int);
17899 vector signed int vec_min (vector signed int, vector signed int);
17900 vector float vec_min (vector float, vector float);
17902 vector signed short vec_mladd (vector signed short, vector signed short,
17903                                vector signed short);
17904 vector signed short vec_mladd (vector signed short, vector unsigned short,
17905                                vector unsigned short);
17906 vector signed short vec_mladd (vector unsigned short, vector signed short,
17907                                vector signed short);
17908 vector unsigned short vec_mladd (vector unsigned short, vector unsigned short,
17909                                  vector unsigned short);
17911 vector signed short vec_mradds (vector signed short, vector signed short,
17912                                 vector signed short);
17914 vector unsigned int vec_msum (vector unsigned char, vector unsigned char,
17915                               vector unsigned int);
17916 vector signed int vec_msum (vector signed char, vector unsigned char,
17917                             vector signed int);
17918 vector unsigned int vec_msum (vector unsigned short, vector unsigned short,
17919                               vector unsigned int);
17920 vector signed int vec_msum (vector signed short, vector signed short,
17921                             vector signed int);
17923 vector unsigned int vec_msums (vector unsigned short, vector unsigned short,
17924                                vector unsigned int);
17925 vector signed int vec_msums (vector signed short, vector signed short,
17926                              vector signed int);
17928 void vec_mtvscr (vector signed int);
17929 void vec_mtvscr (vector unsigned int);
17930 void vec_mtvscr (vector bool int);
17931 void vec_mtvscr (vector signed short);
17932 void vec_mtvscr (vector unsigned short);
17933 void vec_mtvscr (vector bool short);
17934 void vec_mtvscr (vector pixel);
17935 void vec_mtvscr (vector signed char);
17936 void vec_mtvscr (vector unsigned char);
17937 void vec_mtvscr (vector bool char);
17939 vector float vec_mul (vector float, vector float);
17941 vector unsigned short vec_mule (vector unsigned char, vector unsigned char);
17942 vector signed short vec_mule (vector signed char, vector signed char);
17943 vector unsigned int vec_mule (vector unsigned short, vector unsigned short);
17944 vector signed int vec_mule (vector signed short, vector signed short);
17946 vector unsigned short vec_mulo (vector unsigned char, vector unsigned char);
17947 vector signed short vec_mulo (vector signed char, vector signed char);
17948 vector unsigned int vec_mulo (vector unsigned short, vector unsigned short);
17949 vector signed int vec_mulo (vector signed short, vector signed short);
17951 vector signed char vec_nabs (vector signed char);
17952 vector signed short vec_nabs (vector signed short);
17953 vector signed int vec_nabs (vector signed int);
17954 vector float vec_nabs (vector float);
17956 vector float vec_nmsub (vector float, vector float, vector float);
17958 vector float vec_nor (vector float, vector float);
17959 vector signed int vec_nor (vector signed int, vector signed int);
17960 vector unsigned int vec_nor (vector unsigned int, vector unsigned int);
17961 vector bool int vec_nor (vector bool int, vector bool int);
17962 vector signed short vec_nor (vector signed short, vector signed short);
17963 vector unsigned short vec_nor (vector unsigned short, vector unsigned short);
17964 vector bool short vec_nor (vector bool short, vector bool short);
17965 vector signed char vec_nor (vector signed char, vector signed char);
17966 vector unsigned char vec_nor (vector unsigned char, vector unsigned char);
17967 vector bool char vec_nor (vector bool char, vector bool char);
17969 vector float vec_or (vector float, vector float);
17970 vector float vec_or (vector float, vector bool int);
17971 vector float vec_or (vector bool int, vector float);
17972 vector bool int vec_or (vector bool int, vector bool int);
17973 vector signed int vec_or (vector bool int, vector signed int);
17974 vector signed int vec_or (vector signed int, vector bool int);
17975 vector signed int vec_or (vector signed int, vector signed int);
17976 vector unsigned int vec_or (vector bool int, vector unsigned int);
17977 vector unsigned int vec_or (vector unsigned int, vector bool int);
17978 vector unsigned int vec_or (vector unsigned int, vector unsigned int);
17979 vector bool short vec_or (vector bool short, vector bool short);
17980 vector signed short vec_or (vector bool short, vector signed short);
17981 vector signed short vec_or (vector signed short, vector bool short);
17982 vector signed short vec_or (vector signed short, vector signed short);
17983 vector unsigned short vec_or (vector bool short, vector unsigned short);
17984 vector unsigned short vec_or (vector unsigned short, vector bool short);
17985 vector unsigned short vec_or (vector unsigned short, vector unsigned short);
17986 vector signed char vec_or (vector bool char, vector signed char);
17987 vector bool char vec_or (vector bool char, vector bool char);
17988 vector signed char vec_or (vector signed char, vector bool char);
17989 vector signed char vec_or (vector signed char, vector signed char);
17990 vector unsigned char vec_or (vector bool char, vector unsigned char);
17991 vector unsigned char vec_or (vector unsigned char, vector bool char);
17992 vector unsigned char vec_or (vector unsigned char, vector unsigned char);
17994 vector signed char vec_pack (vector signed short, vector signed short);
17995 vector unsigned char vec_pack (vector unsigned short, vector unsigned short);
17996 vector bool char vec_pack (vector bool short, vector bool short);
17997 vector signed short vec_pack (vector signed int, vector signed int);
17998 vector unsigned short vec_pack (vector unsigned int, vector unsigned int);
17999 vector bool short vec_pack (vector bool int, vector bool int);
18001 vector pixel vec_packpx (vector unsigned int, vector unsigned int);
18003 vector unsigned char vec_packs (vector unsigned short, vector unsigned short);
18004 vector signed char vec_packs (vector signed short, vector signed short);
18005 vector unsigned short vec_packs (vector unsigned int, vector unsigned int);
18006 vector signed short vec_packs (vector signed int, vector signed int);
18008 vector unsigned char vec_packsu (vector unsigned short, vector unsigned short);
18009 vector unsigned char vec_packsu (vector signed short, vector signed short);
18010 vector unsigned short vec_packsu (vector unsigned int, vector unsigned int);
18011 vector unsigned short vec_packsu (vector signed int, vector signed int);
18013 vector float vec_perm (vector float, vector float, vector unsigned char);
18014 vector signed int vec_perm (vector signed int, vector signed int, vector unsigned char);
18015 vector unsigned int vec_perm (vector unsigned int, vector unsigned int,
18016                               vector unsigned char);
18017 vector bool int vec_perm (vector bool int, vector bool int, vector unsigned char);
18018 vector signed short vec_perm (vector signed short, vector signed short,
18019                               vector unsigned char);
18020 vector unsigned short vec_perm (vector unsigned short, vector unsigned short,
18021                                 vector unsigned char);
18022 vector bool short vec_perm (vector bool short, vector bool short, vector unsigned char);
18023 vector pixel vec_perm (vector pixel, vector pixel, vector unsigned char);
18024 vector signed char vec_perm (vector signed char, vector signed char,
18025                              vector unsigned char);
18026 vector unsigned char vec_perm (vector unsigned char, vector unsigned char,
18027                                vector unsigned char);
18028 vector bool char vec_perm (vector bool char, vector bool char, vector unsigned char);
18030 vector float vec_re (vector float);
18032 vector bool char vec_reve (vector bool char);
18033 vector signed char vec_reve (vector signed char);
18034 vector unsigned char vec_reve (vector unsigned char);
18035 vector bool int vec_reve (vector bool int);
18036 vector signed int vec_reve (vector signed int);
18037 vector unsigned int vec_reve (vector unsigned int);
18038 vector bool short vec_reve (vector bool short);
18039 vector signed short vec_reve (vector signed short);
18040 vector unsigned short vec_reve (vector unsigned short);
18042 vector signed char vec_rl (vector signed char, vector unsigned char);
18043 vector unsigned char vec_rl (vector unsigned char, vector unsigned char);
18044 vector signed short vec_rl (vector signed short, vector unsigned short);
18045 vector unsigned short vec_rl (vector unsigned short, vector unsigned short);
18046 vector signed int vec_rl (vector signed int, vector unsigned int);
18047 vector unsigned int vec_rl (vector unsigned int, vector unsigned int);
18049 vector float vec_round (vector float);
18051 vector float vec_rsqrt (vector float);
18053 vector float vec_rsqrte (vector float);
18055 vector float vec_sel (vector float, vector float, vector bool int);
18056 vector float vec_sel (vector float, vector float, vector unsigned int);
18057 vector signed int vec_sel (vector signed int, vector signed int, vector bool int);
18058 vector signed int vec_sel (vector signed int, vector signed int, vector unsigned int);
18059 vector unsigned int vec_sel (vector unsigned int, vector unsigned int, vector bool int);
18060 vector unsigned int vec_sel (vector unsigned int, vector unsigned int,
18061                              vector unsigned int);
18062 vector bool int vec_sel (vector bool int, vector bool int, vector bool int);
18063 vector bool int vec_sel (vector bool int, vector bool int, vector unsigned int);
18064 vector signed short vec_sel (vector signed short, vector signed short,
18065                              vector bool short);
18066 vector signed short vec_sel (vector signed short, vector signed short,
18067                              vector unsigned short);
18068 vector unsigned short vec_sel (vector unsigned short, vector unsigned short,
18069                                vector bool short);
18070 vector unsigned short vec_sel (vector unsigned short, vector unsigned short,
18071                                vector unsigned short);
18072 vector bool short vec_sel (vector bool short, vector bool short, vector bool short);
18073 vector bool short vec_sel (vector bool short, vector bool short, vector unsigned short);
18074 vector signed char vec_sel (vector signed char, vector signed char, vector bool char);
18075 vector signed char vec_sel (vector signed char, vector signed char,
18076                             vector unsigned char);
18077 vector unsigned char vec_sel (vector unsigned char, vector unsigned char,
18078                               vector bool char);
18079 vector unsigned char vec_sel (vector unsigned char, vector unsigned char,
18080                               vector unsigned char);
18081 vector bool char vec_sel (vector bool char, vector bool char, vector bool char);
18082 vector bool char vec_sel (vector bool char, vector bool char, vector unsigned char);
18084 vector signed char vec_sl (vector signed char, vector unsigned char);
18085 vector unsigned char vec_sl (vector unsigned char, vector unsigned char);
18086 vector signed short vec_sl (vector signed short, vector unsigned short);
18087 vector unsigned short vec_sl (vector unsigned short, vector unsigned short);
18088 vector signed int vec_sl (vector signed int, vector unsigned int);
18089 vector unsigned int vec_sl (vector unsigned int, vector unsigned int);
18091 vector float vec_sld (vector float, vector float, const int);
18092 vector signed int vec_sld (vector signed int, vector signed int, const int);
18093 vector unsigned int vec_sld (vector unsigned int, vector unsigned int, const int);
18094 vector bool int vec_sld (vector bool int, vector bool int, const int);
18095 vector signed short vec_sld (vector signed short, vector signed short, const int);
18096 vector unsigned short vec_sld (vector unsigned short, vector unsigned short, const int);
18097 vector bool short vec_sld (vector bool short, vector bool short, const int);
18098 vector pixel vec_sld (vector pixel, vector pixel, const int);
18099 vector signed char vec_sld (vector signed char, vector signed char, const int);
18100 vector unsigned char vec_sld (vector unsigned char, vector unsigned char, const int);
18101 vector bool char vec_sld (vector bool char, vector bool char, const int);
18103 vector signed int vec_sll (vector signed int, vector unsigned int);
18104 vector signed int vec_sll (vector signed int, vector unsigned short);
18105 vector signed int vec_sll (vector signed int, vector unsigned char);
18106 vector unsigned int vec_sll (vector unsigned int, vector unsigned int);
18107 vector unsigned int vec_sll (vector unsigned int, vector unsigned short);
18108 vector unsigned int vec_sll (vector unsigned int, vector unsigned char);
18109 vector bool int vec_sll (vector bool int, vector unsigned int);
18110 vector bool int vec_sll (vector bool int, vector unsigned short);
18111 vector bool int vec_sll (vector bool int, vector unsigned char);
18112 vector signed short vec_sll (vector signed short, vector unsigned int);
18113 vector signed short vec_sll (vector signed short, vector unsigned short);
18114 vector signed short vec_sll (vector signed short, vector unsigned char);
18115 vector unsigned short vec_sll (vector unsigned short, vector unsigned int);
18116 vector unsigned short vec_sll (vector unsigned short, vector unsigned short);
18117 vector unsigned short vec_sll (vector unsigned short, vector unsigned char);
18118 vector bool short vec_sll (vector bool short, vector unsigned int);
18119 vector bool short vec_sll (vector bool short, vector unsigned short);
18120 vector bool short vec_sll (vector bool short, vector unsigned char);
18121 vector pixel vec_sll (vector pixel, vector unsigned int);
18122 vector pixel vec_sll (vector pixel, vector unsigned short);
18123 vector pixel vec_sll (vector pixel, vector unsigned char);
18124 vector signed char vec_sll (vector signed char, vector unsigned int);
18125 vector signed char vec_sll (vector signed char, vector unsigned short);
18126 vector signed char vec_sll (vector signed char, vector unsigned char);
18127 vector unsigned char vec_sll (vector unsigned char, vector unsigned int);
18128 vector unsigned char vec_sll (vector unsigned char, vector unsigned short);
18129 vector unsigned char vec_sll (vector unsigned char, vector unsigned char);
18130 vector bool char vec_sll (vector bool char, vector unsigned int);
18131 vector bool char vec_sll (vector bool char, vector unsigned short);
18132 vector bool char vec_sll (vector bool char, vector unsigned char);
18134 vector float vec_slo (vector float, vector signed char);
18135 vector float vec_slo (vector float, vector unsigned char);
18136 vector signed int vec_slo (vector signed int, vector signed char);
18137 vector signed int vec_slo (vector signed int, vector unsigned char);
18138 vector unsigned int vec_slo (vector unsigned int, vector signed char);
18139 vector unsigned int vec_slo (vector unsigned int, vector unsigned char);
18140 vector signed short vec_slo (vector signed short, vector signed char);
18141 vector signed short vec_slo (vector signed short, vector unsigned char);
18142 vector unsigned short vec_slo (vector unsigned short, vector signed char);
18143 vector unsigned short vec_slo (vector unsigned short, vector unsigned char);
18144 vector pixel vec_slo (vector pixel, vector signed char);
18145 vector pixel vec_slo (vector pixel, vector unsigned char);
18146 vector signed char vec_slo (vector signed char, vector signed char);
18147 vector signed char vec_slo (vector signed char, vector unsigned char);
18148 vector unsigned char vec_slo (vector unsigned char, vector signed char);
18149 vector unsigned char vec_slo (vector unsigned char, vector unsigned char);
18151 vector signed char vec_splat (vector signed char, const int);
18152 vector unsigned char vec_splat (vector unsigned char, const int);
18153 vector bool char vec_splat (vector bool char, const int);
18154 vector signed short vec_splat (vector signed short, const int);
18155 vector unsigned short vec_splat (vector unsigned short, const int);
18156 vector bool short vec_splat (vector bool short, const int);
18157 vector pixel vec_splat (vector pixel, const int);
18158 vector float vec_splat (vector float, const int);
18159 vector signed int vec_splat (vector signed int, const int);
18160 vector unsigned int vec_splat (vector unsigned int, const int);
18161 vector bool int vec_splat (vector bool int, const int);
18163 vector signed short vec_splat_s16 (const int);
18165 vector signed int vec_splat_s32 (const int);
18167 vector signed char vec_splat_s8 (const int);
18169 vector unsigned short vec_splat_u16 (const int);
18171 vector unsigned int vec_splat_u32 (const int);
18173 vector unsigned char vec_splat_u8 (const int);
18175 vector signed char vec_splats (signed char);
18176 vector unsigned char vec_splats (unsigned char);
18177 vector signed short vec_splats (signed short);
18178 vector unsigned short vec_splats (unsigned short);
18179 vector signed int vec_splats (signed int);
18180 vector unsigned int vec_splats (unsigned int);
18181 vector float vec_splats (float);
18183 vector signed char vec_sr (vector signed char, vector unsigned char);
18184 vector unsigned char vec_sr (vector unsigned char, vector unsigned char);
18185 vector signed short vec_sr (vector signed short, vector unsigned short);
18186 vector unsigned short vec_sr (vector unsigned short, vector unsigned short);
18187 vector signed int vec_sr (vector signed int, vector unsigned int);
18188 vector unsigned int vec_sr (vector unsigned int, vector unsigned int);
18190 vector signed char vec_sra (vector signed char, vector unsigned char);
18191 vector unsigned char vec_sra (vector unsigned char, vector unsigned char);
18192 vector signed short vec_sra (vector signed short, vector unsigned short);
18193 vector unsigned short vec_sra (vector unsigned short, vector unsigned short);
18194 vector signed int vec_sra (vector signed int, vector unsigned int);
18195 vector unsigned int vec_sra (vector unsigned int, vector unsigned int);
18197 vector signed int vec_srl (vector signed int, vector unsigned int);
18198 vector signed int vec_srl (vector signed int, vector unsigned short);
18199 vector signed int vec_srl (vector signed int, vector unsigned char);
18200 vector unsigned int vec_srl (vector unsigned int, vector unsigned int);
18201 vector unsigned int vec_srl (vector unsigned int, vector unsigned short);
18202 vector unsigned int vec_srl (vector unsigned int, vector unsigned char);
18203 vector bool int vec_srl (vector bool int, vector unsigned int);
18204 vector bool int vec_srl (vector bool int, vector unsigned short);
18205 vector bool int vec_srl (vector bool int, vector unsigned char);
18206 vector signed short vec_srl (vector signed short, vector unsigned int);
18207 vector signed short vec_srl (vector signed short, vector unsigned short);
18208 vector signed short vec_srl (vector signed short, vector unsigned char);
18209 vector unsigned short vec_srl (vector unsigned short, vector unsigned int);
18210 vector unsigned short vec_srl (vector unsigned short, vector unsigned short);
18211 vector unsigned short vec_srl (vector unsigned short, vector unsigned char);
18212 vector bool short vec_srl (vector bool short, vector unsigned int);
18213 vector bool short vec_srl (vector bool short, vector unsigned short);
18214 vector bool short vec_srl (vector bool short, vector unsigned char);
18215 vector pixel vec_srl (vector pixel, vector unsigned int);
18216 vector pixel vec_srl (vector pixel, vector unsigned short);
18217 vector pixel vec_srl (vector pixel, vector unsigned char);
18218 vector signed char vec_srl (vector signed char, vector unsigned int);
18219 vector signed char vec_srl (vector signed char, vector unsigned short);
18220 vector signed char vec_srl (vector signed char, vector unsigned char);
18221 vector unsigned char vec_srl (vector unsigned char, vector unsigned int);
18222 vector unsigned char vec_srl (vector unsigned char, vector unsigned short);
18223 vector unsigned char vec_srl (vector unsigned char, vector unsigned char);
18224 vector bool char vec_srl (vector bool char, vector unsigned int);
18225 vector bool char vec_srl (vector bool char, vector unsigned short);
18226 vector bool char vec_srl (vector bool char, vector unsigned char);
18228 vector float vec_sro (vector float, vector signed char);
18229 vector float vec_sro (vector float, vector unsigned char);
18230 vector signed int vec_sro (vector signed int, vector signed char);
18231 vector signed int vec_sro (vector signed int, vector unsigned char);
18232 vector unsigned int vec_sro (vector unsigned int, vector signed char);
18233 vector unsigned int vec_sro (vector unsigned int, vector unsigned char);
18234 vector signed short vec_sro (vector signed short, vector signed char);
18235 vector signed short vec_sro (vector signed short, vector unsigned char);
18236 vector unsigned short vec_sro (vector unsigned short, vector signed char);
18237 vector unsigned short vec_sro (vector unsigned short, vector unsigned char);
18238 vector pixel vec_sro (vector pixel, vector signed char);
18239 vector pixel vec_sro (vector pixel, vector unsigned char);
18240 vector signed char vec_sro (vector signed char, vector signed char);
18241 vector signed char vec_sro (vector signed char, vector unsigned char);
18242 vector unsigned char vec_sro (vector unsigned char, vector signed char);
18243 vector unsigned char vec_sro (vector unsigned char, vector unsigned char);
18245 void vec_st (vector float, int, vector float *);
18246 void vec_st (vector float, int, float *);
18247 void vec_st (vector signed int, int, vector signed int *);
18248 void vec_st (vector signed int, int, int *);
18249 void vec_st (vector unsigned int, int, vector unsigned int *);
18250 void vec_st (vector unsigned int, int, unsigned int *);
18251 void vec_st (vector bool int, int, vector bool int *);
18252 void vec_st (vector bool int, int, unsigned int *);
18253 void vec_st (vector bool int, int, int *);
18254 void vec_st (vector signed short, int, vector signed short *);
18255 void vec_st (vector signed short, int, short *);
18256 void vec_st (vector unsigned short, int, vector unsigned short *);
18257 void vec_st (vector unsigned short, int, unsigned short *);
18258 void vec_st (vector bool short, int, vector bool short *);
18259 void vec_st (vector bool short, int, unsigned short *);
18260 void vec_st (vector pixel, int, vector pixel *);
18261 void vec_st (vector bool short, int, short *);
18262 void vec_st (vector signed char, int, vector signed char *);
18263 void vec_st (vector signed char, int, signed char *);
18264 void vec_st (vector unsigned char, int, vector unsigned char *);
18265 void vec_st (vector unsigned char, int, unsigned char *);
18266 void vec_st (vector bool char, int, vector bool char *);
18267 void vec_st (vector bool char, int, unsigned char *);
18268 void vec_st (vector bool char, int, signed char *);
18270 void vec_ste (vector signed char, int, signed char *);
18271 void vec_ste (vector unsigned char, int, unsigned char *);
18272 void vec_ste (vector bool char, int, signed char *);
18273 void vec_ste (vector bool char, int, unsigned char *);
18274 void vec_ste (vector signed short, int, short *);
18275 void vec_ste (vector unsigned short, int, unsigned short *);
18276 void vec_ste (vector bool short, int, short *);
18277 void vec_ste (vector bool short, int, unsigned short *);
18278 void vec_ste (vector pixel, int, short *);
18279 void vec_ste (vector pixel, int, unsigned short *);
18280 void vec_ste (vector float, int, float *);
18281 void vec_ste (vector signed int, int, int *);
18282 void vec_ste (vector unsigned int, int, unsigned int *);
18283 void vec_ste (vector bool int, int, int *);
18284 void vec_ste (vector bool int, int, unsigned int *);
18286 void vec_stl (vector float, int, vector float *);
18287 void vec_stl (vector float, int, float *);
18288 void vec_stl (vector signed int, int, vector signed int *);
18289 void vec_stl (vector signed int, int, int *);
18290 void vec_stl (vector unsigned int, int, vector unsigned int *);
18291 void vec_stl (vector unsigned int, int, unsigned int *);
18292 void vec_stl (vector bool int, int, vector bool int *);
18293 void vec_stl (vector bool int, int, unsigned int *);
18294 void vec_stl (vector bool int, int, int *);
18295 void vec_stl (vector signed short, int, vector signed short *);
18296 void vec_stl (vector signed short, int, short *);
18297 void vec_stl (vector unsigned short, int, vector unsigned short *);
18298 void vec_stl (vector unsigned short, int, unsigned short *);
18299 void vec_stl (vector bool short, int, vector bool short *);
18300 void vec_stl (vector bool short, int, unsigned short *);
18301 void vec_stl (vector bool short, int, short *);
18302 void vec_stl (vector pixel, int, vector pixel *);
18303 void vec_stl (vector signed char, int, vector signed char *);
18304 void vec_stl (vector signed char, int, signed char *);
18305 void vec_stl (vector unsigned char, int, vector unsigned char *);
18306 void vec_stl (vector unsigned char, int, unsigned char *);
18307 void vec_stl (vector bool char, int, vector bool char *);
18308 void vec_stl (vector bool char, int, unsigned char *);
18309 void vec_stl (vector bool char, int, signed char *);
18311 void vec_stvebx (vector signed char, int, signed char *);
18312 void vec_stvebx (vector unsigned char, int, unsigned char *);
18313 void vec_stvebx (vector bool char, int, signed char *);
18314 void vec_stvebx (vector bool char, int, unsigned char *);
18316 void vec_stvehx (vector signed short, int, short *);
18317 void vec_stvehx (vector unsigned short, int, unsigned short *);
18318 void vec_stvehx (vector bool short, int, short *);
18319 void vec_stvehx (vector bool short, int, unsigned short *);
18321 void vec_stvewx (vector float, int, float *);
18322 void vec_stvewx (vector signed int, int, int *);
18323 void vec_stvewx (vector unsigned int, int, unsigned int *);
18324 void vec_stvewx (vector bool int, int, int *);
18325 void vec_stvewx (vector bool int, int, unsigned int *);
18327 vector signed char vec_sub (vector bool char, vector signed char);
18328 vector signed char vec_sub (vector signed char, vector bool char);
18329 vector signed char vec_sub (vector signed char, vector signed char);
18330 vector unsigned char vec_sub (vector bool char, vector unsigned char);
18331 vector unsigned char vec_sub (vector unsigned char, vector bool char);
18332 vector unsigned char vec_sub (vector unsigned char, vector unsigned char);
18333 vector signed short vec_sub (vector bool short, vector signed short);
18334 vector signed short vec_sub (vector signed short, vector bool short);
18335 vector signed short vec_sub (vector signed short, vector signed short);
18336 vector unsigned short vec_sub (vector bool short, vector unsigned short);
18337 vector unsigned short vec_sub (vector unsigned short, vector bool short);
18338 vector unsigned short vec_sub (vector unsigned short, vector unsigned short);
18339 vector signed int vec_sub (vector bool int, vector signed int);
18340 vector signed int vec_sub (vector signed int, vector bool int);
18341 vector signed int vec_sub (vector signed int, vector signed int);
18342 vector unsigned int vec_sub (vector bool int, vector unsigned int);
18343 vector unsigned int vec_sub (vector unsigned int, vector bool int);
18344 vector unsigned int vec_sub (vector unsigned int, vector unsigned int);
18345 vector float vec_sub (vector float, vector float);
18347 vector signed int vec_subc (vector signed int, vector signed int);
18348 vector unsigned int vec_subc (vector unsigned int, vector unsigned int);
18350 vector signed int vec_sube (vector signed int, vector signed int,
18351                             vector signed int);
18352 vector unsigned int vec_sube (vector unsigned int, vector unsigned int,
18353                               vector unsigned int);
18355 vector signed int vec_subec (vector signed int, vector signed int,
18356                              vector signed int);
18357 vector unsigned int vec_subec (vector unsigned int, vector unsigned int,
18358                                vector unsigned int);
18360 vector unsigned char vec_subs (vector bool char, vector unsigned char);
18361 vector unsigned char vec_subs (vector unsigned char, vector bool char);
18362 vector unsigned char vec_subs (vector unsigned char, vector unsigned char);
18363 vector signed char vec_subs (vector bool char, vector signed char);
18364 vector signed char vec_subs (vector signed char, vector bool char);
18365 vector signed char vec_subs (vector signed char, vector signed char);
18366 vector unsigned short vec_subs (vector bool short, vector unsigned short);
18367 vector unsigned short vec_subs (vector unsigned short, vector bool short);
18368 vector unsigned short vec_subs (vector unsigned short, vector unsigned short);
18369 vector signed short vec_subs (vector bool short, vector signed short);
18370 vector signed short vec_subs (vector signed short, vector bool short);
18371 vector signed short vec_subs (vector signed short, vector signed short);
18372 vector unsigned int vec_subs (vector bool int, vector unsigned int);
18373 vector unsigned int vec_subs (vector unsigned int, vector bool int);
18374 vector unsigned int vec_subs (vector unsigned int, vector unsigned int);
18375 vector signed int vec_subs (vector bool int, vector signed int);
18376 vector signed int vec_subs (vector signed int, vector bool int);
18377 vector signed int vec_subs (vector signed int, vector signed int);
18379 vector signed int vec_sum2s (vector signed int, vector signed int);
18381 vector unsigned int vec_sum4s (vector unsigned char, vector unsigned int);
18382 vector signed int vec_sum4s (vector signed char, vector signed int);
18383 vector signed int vec_sum4s (vector signed short, vector signed int);
18385 vector signed int vec_sums (vector signed int, vector signed int);
18387 vector float vec_trunc (vector float);
18389 vector signed short vec_unpackh (vector signed char);
18390 vector bool short vec_unpackh (vector bool char);
18391 vector signed int vec_unpackh (vector signed short);
18392 vector bool int vec_unpackh (vector bool short);
18393 vector unsigned int vec_unpackh (vector pixel);
18395 vector signed short vec_unpackl (vector signed char);
18396 vector bool short vec_unpackl (vector bool char);
18397 vector unsigned int vec_unpackl (vector pixel);
18398 vector signed int vec_unpackl (vector signed short);
18399 vector bool int vec_unpackl (vector bool short);
18401 vector float vec_vaddfp (vector float, vector float);
18403 vector signed char vec_vaddsbs (vector bool char, vector signed char);
18404 vector signed char vec_vaddsbs (vector signed char, vector bool char);
18405 vector signed char vec_vaddsbs (vector signed char, vector signed char);
18407 vector signed short vec_vaddshs (vector bool short, vector signed short);
18408 vector signed short vec_vaddshs (vector signed short, vector bool short);
18409 vector signed short vec_vaddshs (vector signed short, vector signed short);
18411 vector signed int vec_vaddsws (vector bool int, vector signed int);
18412 vector signed int vec_vaddsws (vector signed int, vector bool int);
18413 vector signed int vec_vaddsws (vector signed int, vector signed int);
18415 vector signed char vec_vaddubm (vector bool char, vector signed char);
18416 vector signed char vec_vaddubm (vector signed char, vector bool char);
18417 vector signed char vec_vaddubm (vector signed char, vector signed char);
18418 vector unsigned char vec_vaddubm (vector bool char, vector unsigned char);
18419 vector unsigned char vec_vaddubm (vector unsigned char, vector bool char);
18420 vector unsigned char vec_vaddubm (vector unsigned char, vector unsigned char);
18422 vector unsigned char vec_vaddubs (vector bool char, vector unsigned char);
18423 vector unsigned char vec_vaddubs (vector unsigned char, vector bool char);
18424 vector unsigned char vec_vaddubs (vector unsigned char, vector unsigned char);
18426 vector signed short vec_vadduhm (vector bool short, vector signed short);
18427 vector signed short vec_vadduhm (vector signed short, vector bool short);
18428 vector signed short vec_vadduhm (vector signed short, vector signed short);
18429 vector unsigned short vec_vadduhm (vector bool short, vector unsigned short);
18430 vector unsigned short vec_vadduhm (vector unsigned short, vector bool short);
18431 vector unsigned short vec_vadduhm (vector unsigned short, vector unsigned short);
18433 vector unsigned short vec_vadduhs (vector bool short, vector unsigned short);
18434 vector unsigned short vec_vadduhs (vector unsigned short, vector bool short);
18435 vector unsigned short vec_vadduhs (vector unsigned short, vector unsigned short);
18437 vector signed int vec_vadduwm (vector bool int, vector signed int);
18438 vector signed int vec_vadduwm (vector signed int, vector bool int);
18439 vector signed int vec_vadduwm (vector signed int, vector signed int);
18440 vector unsigned int vec_vadduwm (vector bool int, vector unsigned int);
18441 vector unsigned int vec_vadduwm (vector unsigned int, vector bool int);
18442 vector unsigned int vec_vadduwm (vector unsigned int, vector unsigned int);
18444 vector unsigned int vec_vadduws (vector bool int, vector unsigned int);
18445 vector unsigned int vec_vadduws (vector unsigned int, vector bool int);
18446 vector unsigned int vec_vadduws (vector unsigned int, vector unsigned int);
18448 vector signed char vec_vavgsb (vector signed char, vector signed char);
18450 vector signed short vec_vavgsh (vector signed short, vector signed short);
18452 vector signed int vec_vavgsw (vector signed int, vector signed int);
18454 vector unsigned char vec_vavgub (vector unsigned char, vector unsigned char);
18456 vector unsigned short vec_vavguh (vector unsigned short, vector unsigned short);
18458 vector unsigned int vec_vavguw (vector unsigned int, vector unsigned int);
18460 vector float vec_vcfsx (vector signed int, const int);
18462 vector float vec_vcfux (vector unsigned int, const int);
18464 vector bool int vec_vcmpeqfp (vector float, vector float);
18466 vector bool char vec_vcmpequb (vector signed char, vector signed char);
18467 vector bool char vec_vcmpequb (vector unsigned char, vector unsigned char);
18469 vector bool short vec_vcmpequh (vector signed short, vector signed short);
18470 vector bool short vec_vcmpequh (vector unsigned short, vector unsigned short);
18472 vector bool int vec_vcmpequw (vector signed int, vector signed int);
18473 vector bool int vec_vcmpequw (vector unsigned int, vector unsigned int);
18475 vector bool int vec_vcmpgtfp (vector float, vector float);
18477 vector bool char vec_vcmpgtsb (vector signed char, vector signed char);
18479 vector bool short vec_vcmpgtsh (vector signed short, vector signed short);
18481 vector bool int vec_vcmpgtsw (vector signed int, vector signed int);
18483 vector bool char vec_vcmpgtub (vector unsigned char, vector unsigned char);
18485 vector bool short vec_vcmpgtuh (vector unsigned short, vector unsigned short);
18487 vector bool int vec_vcmpgtuw (vector unsigned int, vector unsigned int);
18489 vector float vec_vmaxfp (vector float, vector float);
18491 vector signed char vec_vmaxsb (vector bool char, vector signed char);
18492 vector signed char vec_vmaxsb (vector signed char, vector bool char);
18493 vector signed char vec_vmaxsb (vector signed char, vector signed char);
18495 vector signed short vec_vmaxsh (vector bool short, vector signed short);
18496 vector signed short vec_vmaxsh (vector signed short, vector bool short);
18497 vector signed short vec_vmaxsh (vector signed short, vector signed short);
18499 vector signed int vec_vmaxsw (vector bool int, vector signed int);
18500 vector signed int vec_vmaxsw (vector signed int, vector bool int);
18501 vector signed int vec_vmaxsw (vector signed int, vector signed int);
18503 vector unsigned char vec_vmaxub (vector bool char, vector unsigned char);
18504 vector unsigned char vec_vmaxub (vector unsigned char, vector bool char);
18505 vector unsigned char vec_vmaxub (vector unsigned char, vector unsigned char);
18507 vector unsigned short vec_vmaxuh (vector bool short, vector unsigned short);
18508 vector unsigned short vec_vmaxuh (vector unsigned short, vector bool short);
18509 vector unsigned short vec_vmaxuh (vector unsigned short, vector unsigned short);
18511 vector unsigned int vec_vmaxuw (vector bool int, vector unsigned int);
18512 vector unsigned int vec_vmaxuw (vector unsigned int, vector bool int);
18513 vector unsigned int vec_vmaxuw (vector unsigned int, vector unsigned int);
18515 vector float vec_vminfp (vector float, vector float);
18517 vector signed char vec_vminsb (vector bool char, vector signed char);
18518 vector signed char vec_vminsb (vector signed char, vector bool char);
18519 vector signed char vec_vminsb (vector signed char, vector signed char);
18521 vector signed short vec_vminsh (vector bool short, vector signed short);
18522 vector signed short vec_vminsh (vector signed short, vector bool short);
18523 vector signed short vec_vminsh (vector signed short, vector signed short);
18525 vector signed int vec_vminsw (vector bool int, vector signed int);
18526 vector signed int vec_vminsw (vector signed int, vector bool int);
18527 vector signed int vec_vminsw (vector signed int, vector signed int);
18529 vector unsigned char vec_vminub (vector bool char, vector unsigned char);
18530 vector unsigned char vec_vminub (vector unsigned char, vector bool char);
18531 vector unsigned char vec_vminub (vector unsigned char, vector unsigned char);
18533 vector unsigned short vec_vminuh (vector bool short, vector unsigned short);
18534 vector unsigned short vec_vminuh (vector unsigned short, vector bool short);
18535 vector unsigned short vec_vminuh (vector unsigned short, vector unsigned short);
18537 vector unsigned int vec_vminuw (vector bool int, vector unsigned int);
18538 vector unsigned int vec_vminuw (vector unsigned int, vector bool int);
18539 vector unsigned int vec_vminuw (vector unsigned int, vector unsigned int);
18541 vector bool char vec_vmrghb (vector bool char, vector bool char);
18542 vector signed char vec_vmrghb (vector signed char, vector signed char);
18543 vector unsigned char vec_vmrghb (vector unsigned char, vector unsigned char);
18545 vector bool short vec_vmrghh (vector bool short, vector bool short);
18546 vector signed short vec_vmrghh (vector signed short, vector signed short);
18547 vector unsigned short vec_vmrghh (vector unsigned short, vector unsigned short);
18548 vector pixel vec_vmrghh (vector pixel, vector pixel);
18550 vector float vec_vmrghw (vector float, vector float);
18551 vector bool int vec_vmrghw (vector bool int, vector bool int);
18552 vector signed int vec_vmrghw (vector signed int, vector signed int);
18553 vector unsigned int vec_vmrghw (vector unsigned int, vector unsigned int);
18555 vector bool char vec_vmrglb (vector bool char, vector bool char);
18556 vector signed char vec_vmrglb (vector signed char, vector signed char);
18557 vector unsigned char vec_vmrglb (vector unsigned char, vector unsigned char);
18559 vector bool short vec_vmrglh (vector bool short, vector bool short);
18560 vector signed short vec_vmrglh (vector signed short, vector signed short);
18561 vector unsigned short vec_vmrglh (vector unsigned short, vector unsigned short);
18562 vector pixel vec_vmrglh (vector pixel, vector pixel);
18564 vector float vec_vmrglw (vector float, vector float);
18565 vector signed int vec_vmrglw (vector signed int, vector signed int);
18566 vector unsigned int vec_vmrglw (vector unsigned int, vector unsigned int);
18567 vector bool int vec_vmrglw (vector bool int, vector bool int);
18569 vector signed int vec_vmsummbm (vector signed char, vector unsigned char,
18570                                 vector signed int);
18572 vector signed int vec_vmsumshm (vector signed short, vector signed short,
18573                                 vector signed int);
18575 vector signed int vec_vmsumshs (vector signed short, vector signed short,
18576                                 vector signed int);
18578 vector unsigned int vec_vmsumubm (vector unsigned char, vector unsigned char,
18579                                   vector unsigned int);
18581 vector unsigned int vec_vmsumuhm (vector unsigned short, vector unsigned short,
18582                                   vector unsigned int);
18584 vector unsigned int vec_vmsumuhs (vector unsigned short, vector unsigned short,
18585                                   vector unsigned int);
18587 vector signed short vec_vmulesb (vector signed char, vector signed char);
18589 vector signed int vec_vmulesh (vector signed short, vector signed short);
18591 vector unsigned short vec_vmuleub (vector unsigned char, vector unsigned char);
18593 vector unsigned int vec_vmuleuh (vector unsigned short, vector unsigned short);
18595 vector signed short vec_vmulosb (vector signed char, vector signed char);
18597 vector signed int vec_vmulosh (vector signed short, vector signed short);
18599 vector unsigned short vec_vmuloub (vector unsigned char, vector unsigned char);
18601 vector unsigned int vec_vmulouh (vector unsigned short, vector unsigned short);
18603 vector signed char vec_vpkshss (vector signed short, vector signed short);
18605 vector unsigned char vec_vpkshus (vector signed short, vector signed short);
18607 vector signed short vec_vpkswss (vector signed int, vector signed int);
18609 vector unsigned short vec_vpkswus (vector signed int, vector signed int);
18611 vector bool char vec_vpkuhum (vector bool short, vector bool short);
18612 vector signed char vec_vpkuhum (vector signed short, vector signed short);
18613 vector unsigned char vec_vpkuhum (vector unsigned short, vector unsigned short);
18615 vector unsigned char vec_vpkuhus (vector unsigned short, vector unsigned short);
18617 vector bool short vec_vpkuwum (vector bool int, vector bool int);
18618 vector signed short vec_vpkuwum (vector signed int, vector signed int);
18619 vector unsigned short vec_vpkuwum (vector unsigned int, vector unsigned int);
18621 vector unsigned short vec_vpkuwus (vector unsigned int, vector unsigned int);
18623 vector signed char vec_vrlb (vector signed char, vector unsigned char);
18624 vector unsigned char vec_vrlb (vector unsigned char, vector unsigned char);
18626 vector signed short vec_vrlh (vector signed short, vector unsigned short);
18627 vector unsigned short vec_vrlh (vector unsigned short, vector unsigned short);
18629 vector signed int vec_vrlw (vector signed int, vector unsigned int);
18630 vector unsigned int vec_vrlw (vector unsigned int, vector unsigned int);
18632 vector signed char vec_vslb (vector signed char, vector unsigned char);
18633 vector unsigned char vec_vslb (vector unsigned char, vector unsigned char);
18635 vector signed short vec_vslh (vector signed short, vector unsigned short);
18636 vector unsigned short vec_vslh (vector unsigned short, vector unsigned short);
18638 vector signed int vec_vslw (vector signed int, vector unsigned int);
18639 vector unsigned int vec_vslw (vector unsigned int, vector unsigned int);
18641 vector signed char vec_vspltb (vector signed char, const int);
18642 vector unsigned char vec_vspltb (vector unsigned char, const int);
18643 vector bool char vec_vspltb (vector bool char, const int);
18645 vector bool short vec_vsplth (vector bool short, const int);
18646 vector signed short vec_vsplth (vector signed short, const int);
18647 vector unsigned short vec_vsplth (vector unsigned short, const int);
18648 vector pixel vec_vsplth (vector pixel, const int);
18650 vector float vec_vspltw (vector float, const int);
18651 vector signed int vec_vspltw (vector signed int, const int);
18652 vector unsigned int vec_vspltw (vector unsigned int, const int);
18653 vector bool int vec_vspltw (vector bool int, const int);
18655 vector signed char vec_vsrab (vector signed char, vector unsigned char);
18656 vector unsigned char vec_vsrab (vector unsigned char, vector unsigned char);
18658 vector signed short vec_vsrah (vector signed short, vector unsigned short);
18659 vector unsigned short vec_vsrah (vector unsigned short, vector unsigned short);
18661 vector signed int vec_vsraw (vector signed int, vector unsigned int);
18662 vector unsigned int vec_vsraw (vector unsigned int, vector unsigned int);
18664 vector signed char vec_vsrb (vector signed char, vector unsigned char);
18665 vector unsigned char vec_vsrb (vector unsigned char, vector unsigned char);
18667 vector signed short vec_vsrh (vector signed short, vector unsigned short);
18668 vector unsigned short vec_vsrh (vector unsigned short, vector unsigned short);
18670 vector signed int vec_vsrw (vector signed int, vector unsigned int);
18671 vector unsigned int vec_vsrw (vector unsigned int, vector unsigned int);
18673 vector float vec_vsubfp (vector float, vector float);
18675 vector signed char vec_vsubsbs (vector bool char, vector signed char);
18676 vector signed char vec_vsubsbs (vector signed char, vector bool char);
18677 vector signed char vec_vsubsbs (vector signed char, vector signed char);
18679 vector signed short vec_vsubshs (vector bool short, vector signed short);
18680 vector signed short vec_vsubshs (vector signed short, vector bool short);
18681 vector signed short vec_vsubshs (vector signed short, vector signed short);
18683 vector signed int vec_vsubsws (vector bool int, vector signed int);
18684 vector signed int vec_vsubsws (vector signed int, vector bool int);
18685 vector signed int vec_vsubsws (vector signed int, vector signed int);
18687 vector signed char vec_vsububm (vector bool char, vector signed char);
18688 vector signed char vec_vsububm (vector signed char, vector bool char);
18689 vector signed char vec_vsububm (vector signed char, vector signed char);
18690 vector unsigned char vec_vsububm (vector bool char, vector unsigned char);
18691 vector unsigned char vec_vsububm (vector unsigned char, vector bool char);
18692 vector unsigned char vec_vsububm (vector unsigned char, vector unsigned char);
18694 vector unsigned char vec_vsububs (vector bool char, vector unsigned char);
18695 vector unsigned char vec_vsububs (vector unsigned char, vector bool char);
18696 vector unsigned char vec_vsububs (vector unsigned char, vector unsigned char);
18698 vector signed short vec_vsubuhm (vector bool short, vector signed short);
18699 vector signed short vec_vsubuhm (vector signed short, vector bool short);
18700 vector signed short vec_vsubuhm (vector signed short, vector signed short);
18701 vector unsigned short vec_vsubuhm (vector bool short, vector unsigned short);
18702 vector unsigned short vec_vsubuhm (vector unsigned short, vector bool short);
18703 vector unsigned short vec_vsubuhm (vector unsigned short, vector unsigned short);
18705 vector unsigned short vec_vsubuhs (vector bool short, vector unsigned short);
18706 vector unsigned short vec_vsubuhs (vector unsigned short, vector bool short);
18707 vector unsigned short vec_vsubuhs (vector unsigned short, vector unsigned short);
18709 vector signed int vec_vsubuwm (vector bool int, vector signed int);
18710 vector signed int vec_vsubuwm (vector signed int, vector bool int);
18711 vector signed int vec_vsubuwm (vector signed int, vector signed int);
18712 vector unsigned int vec_vsubuwm (vector bool int, vector unsigned int);
18713 vector unsigned int vec_vsubuwm (vector unsigned int, vector bool int);
18714 vector unsigned int vec_vsubuwm (vector unsigned int, vector unsigned int);
18716 vector unsigned int vec_vsubuws (vector bool int, vector unsigned int);
18717 vector unsigned int vec_vsubuws (vector unsigned int, vector bool int);
18718 vector unsigned int vec_vsubuws (vector unsigned int, vector unsigned int);
18720 vector signed int vec_vsum4sbs (vector signed char, vector signed int);
18722 vector signed int vec_vsum4shs (vector signed short, vector signed int);
18724 vector unsigned int vec_vsum4ubs (vector unsigned char, vector unsigned int);
18726 vector unsigned int vec_vupkhpx (vector pixel);
18728 vector bool short vec_vupkhsb (vector bool char);
18729 vector signed short vec_vupkhsb (vector signed char);
18731 vector bool int vec_vupkhsh (vector bool short);
18732 vector signed int vec_vupkhsh (vector signed short);
18734 vector unsigned int vec_vupklpx (vector pixel);
18736 vector bool short vec_vupklsb (vector bool char);
18737 vector signed short vec_vupklsb (vector signed char);
18739 vector bool int vec_vupklsh (vector bool short);
18740 vector signed int vec_vupklsh (vector signed short);
18742 vector float vec_xor (vector float, vector float);
18743 vector float vec_xor (vector float, vector bool int);
18744 vector float vec_xor (vector bool int, vector float);
18745 vector bool int vec_xor (vector bool int, vector bool int);
18746 vector signed int vec_xor (vector bool int, vector signed int);
18747 vector signed int vec_xor (vector signed int, vector bool int);
18748 vector signed int vec_xor (vector signed int, vector signed int);
18749 vector unsigned int vec_xor (vector bool int, vector unsigned int);
18750 vector unsigned int vec_xor (vector unsigned int, vector bool int);
18751 vector unsigned int vec_xor (vector unsigned int, vector unsigned int);
18752 vector bool short vec_xor (vector bool short, vector bool short);
18753 vector signed short vec_xor (vector bool short, vector signed short);
18754 vector signed short vec_xor (vector signed short, vector bool short);
18755 vector signed short vec_xor (vector signed short, vector signed short);
18756 vector unsigned short vec_xor (vector bool short, vector unsigned short);
18757 vector unsigned short vec_xor (vector unsigned short, vector bool short);
18758 vector unsigned short vec_xor (vector unsigned short, vector unsigned short);
18759 vector signed char vec_xor (vector bool char, vector signed char);
18760 vector bool char vec_xor (vector bool char, vector bool char);
18761 vector signed char vec_xor (vector signed char, vector bool char);
18762 vector signed char vec_xor (vector signed char, vector signed char);
18763 vector unsigned char vec_xor (vector bool char, vector unsigned char);
18764 vector unsigned char vec_xor (vector unsigned char, vector bool char);
18765 vector unsigned char vec_xor (vector unsigned char, vector unsigned char);
18766 @end smallexample
18768 @node PowerPC AltiVec Built-in Functions Available on ISA 2.06
18769 @subsubsection PowerPC AltiVec Built-in Functions Available on ISA 2.06
18771 The AltiVec built-in functions described in this section are
18772 available on the PowerPC family of processors starting with ISA 2.06
18773 or later.  These are normally enabled by adding @option{-mvsx} to the
18774 command line.
18776 When @option{-mvsx} is used, the following additional vector types are
18777 implemented.
18779 @smallexample
18780 vector unsigned __int128
18781 vector signed __int128
18782 vector unsigned long long int
18783 vector signed long long int
18784 vector double
18785 @end smallexample
18787 The long long types are only implemented for 64-bit code generation.
18789 @smallexample
18791 vector bool long long vec_and (vector bool long long int, vector bool long long);
18793 vector double vec_ctf (vector unsigned long, const int);
18794 vector double vec_ctf (vector signed long, const int);
18796 vector signed long vec_cts (vector double, const int);
18798 vector unsigned long vec_ctu (vector double, const int);
18800 void vec_dst (const unsigned long *, int, const int);
18801 void vec_dst (const long *, int, const int);
18803 void vec_dststt (const unsigned long *, int, const int);
18804 void vec_dststt (const long *, int, const int);
18806 void vec_dstt (const unsigned long *, int, const int);
18807 void vec_dstt (const long *, int, const int);
18809 vector unsigned char vec_lvsl (int, const unsigned long *);
18810 vector unsigned char vec_lvsl (int, const long *);
18812 vector unsigned char vec_lvsr (int, const unsigned long *);
18813 vector unsigned char vec_lvsr (int, const long *);
18815 vector double vec_mul (vector double, vector double);
18816 vector long vec_mul (vector long, vector long);
18817 vector unsigned long vec_mul (vector unsigned long, vector unsigned long);
18819 vector unsigned long long vec_mule (vector unsigned int, vector unsigned int);
18820 vector signed long long vec_mule (vector signed int, vector signed int);
18822 vector unsigned long long vec_mulo (vector unsigned int, vector unsigned int);
18823 vector signed long long vec_mulo (vector signed int, vector signed int);
18825 vector double vec_nabs (vector double);
18827 vector bool long long vec_reve (vector bool long long);
18828 vector signed long long vec_reve (vector signed long long);
18829 vector unsigned long long vec_reve (vector unsigned long long);
18830 vector double vec_sld (vector double, vector double, const int);
18832 vector bool long long int vec_sld (vector bool long long int,
18833                                    vector bool long long int, const int);
18834 vector long long int vec_sld (vector long long int, vector  long long int, const int);
18835 vector unsigned long long int vec_sld (vector unsigned long long int,
18836                                        vector unsigned long long int, const int);
18838 vector long long int vec_sll (vector long long int, vector unsigned char);
18839 vector unsigned long long int vec_sll (vector unsigned long long int,
18840                                        vector unsigned char);
18842 vector signed long long vec_slo (vector signed long long, vector signed char);
18843 vector signed long long vec_slo (vector signed long long, vector unsigned char);
18844 vector unsigned long long vec_slo (vector unsigned long long, vector signed char);
18845 vector unsigned long long vec_slo (vector unsigned long long, vector unsigned char);
18847 vector signed long vec_splat (vector signed long, const int);
18848 vector unsigned long vec_splat (vector unsigned long, const int);
18850 vector long long int vec_srl (vector long long int, vector unsigned char);
18851 vector unsigned long long int vec_srl (vector unsigned long long int,
18852                                        vector unsigned char);
18854 vector long long int vec_sro (vector long long int, vector char);
18855 vector long long int vec_sro (vector long long int, vector unsigned char);
18856 vector unsigned long long int vec_sro (vector unsigned long long int, vector char);
18857 vector unsigned long long int vec_sro (vector unsigned long long int,
18858                                        vector unsigned char);
18860 vector signed __int128 vec_subc (vector signed __int128, vector signed __int128);
18861 vector unsigned __int128 vec_subc (vector unsigned __int128, vector unsigned __int128);
18863 vector signed __int128 vec_sube (vector signed __int128, vector signed __int128,
18864                                  vector signed __int128);
18865 vector unsigned __int128 vec_sube (vector unsigned __int128, vector unsigned __int128,
18866                                    vector unsigned __int128);
18868 vector signed __int128 vec_subec (vector signed __int128, vector signed __int128,
18869                                   vector signed __int128);
18870 vector unsigned __int128 vec_subec (vector unsigned __int128, vector unsigned __int128,
18871                                     vector unsigned __int128);
18873 vector double vec_unpackh (vector float);
18875 vector double vec_unpackl (vector float);
18877 vector double vec_doublee (vector float);
18878 vector double vec_doublee (vector signed int);
18879 vector double vec_doublee (vector unsigned int);
18881 vector double vec_doubleo (vector float);
18882 vector double vec_doubleo (vector signed int);
18883 vector double vec_doubleo (vector unsigned int);
18885 vector double vec_doubleh (vector float);
18886 vector double vec_doubleh (vector signed int);
18887 vector double vec_doubleh (vector unsigned int);
18889 vector double vec_doublel (vector float);
18890 vector double vec_doublel (vector signed int);
18891 vector double vec_doublel (vector unsigned int);
18893 vector float vec_float (vector signed int);
18894 vector float vec_float (vector unsigned int);
18896 vector float vec_float2 (vector signed long long, vector signed long long);
18897 vector float vec_float2 (vector unsigned long long, vector signed long long);
18899 vector float vec_floate (vector double);
18900 vector float vec_floate (vector signed long long);
18901 vector float vec_floate (vector unsigned long long);
18903 vector float vec_floato (vector double);
18904 vector float vec_floato (vector signed long long);
18905 vector float vec_floato (vector unsigned long long);
18907 vector signed long long vec_signed (vector double);
18908 vector signed int vec_signed (vector float);
18910 vector signed int vec_signede (vector double);
18912 vector signed int vec_signedo (vector double);
18914 vector signed char vec_sldw (vector signed char, vector signed char, const int);
18915 vector unsigned char vec_sldw (vector unsigned char, vector unsigned char, const int);
18916 vector signed short vec_sldw (vector signed short, vector signed short, const int);
18917 vector unsigned short vec_sldw (vector unsigned short,
18918                                 vector unsigned short, const int);
18919 vector signed int vec_sldw (vector signed int, vector signed int, const int);
18920 vector unsigned int vec_sldw (vector unsigned int, vector unsigned int, const int);
18921 vector signed long long vec_sldw (vector signed long long,
18922                                   vector signed long long, const int);
18923 vector unsigned long long vec_sldw (vector unsigned long long,
18924                                     vector unsigned long long, const int);
18926 vector signed long long vec_unsigned (vector double);
18927 vector signed int vec_unsigned (vector float);
18929 vector signed int vec_unsignede (vector double);
18931 vector signed int vec_unsignedo (vector double);
18933 vector double vec_abs (vector double);
18934 vector double vec_add (vector double, vector double);
18935 vector double vec_and (vector double, vector double);
18936 vector double vec_and (vector double, vector bool long);
18937 vector double vec_and (vector bool long, vector double);
18938 vector long vec_and (vector long, vector long);
18939 vector long vec_and (vector long, vector bool long);
18940 vector long vec_and (vector bool long, vector long);
18941 vector unsigned long vec_and (vector unsigned long, vector unsigned long);
18942 vector unsigned long vec_and (vector unsigned long, vector bool long);
18943 vector unsigned long vec_and (vector bool long, vector unsigned long);
18944 vector double vec_andc (vector double, vector double);
18945 vector double vec_andc (vector double, vector bool long);
18946 vector double vec_andc (vector bool long, vector double);
18947 vector long vec_andc (vector long, vector long);
18948 vector long vec_andc (vector long, vector bool long);
18949 vector long vec_andc (vector bool long, vector long);
18950 vector unsigned long vec_andc (vector unsigned long, vector unsigned long);
18951 vector unsigned long vec_andc (vector unsigned long, vector bool long);
18952 vector unsigned long vec_andc (vector bool long, vector unsigned long);
18953 vector double vec_ceil (vector double);
18954 vector bool long vec_cmpeq (vector double, vector double);
18955 vector bool long vec_cmpge (vector double, vector double);
18956 vector bool long vec_cmpgt (vector double, vector double);
18957 vector bool long vec_cmple (vector double, vector double);
18958 vector bool long vec_cmplt (vector double, vector double);
18959 vector double vec_cpsgn (vector double, vector double);
18960 vector float vec_div (vector float, vector float);
18961 vector double vec_div (vector double, vector double);
18962 vector long vec_div (vector long, vector long);
18963 vector unsigned long vec_div (vector unsigned long, vector unsigned long);
18964 vector double vec_floor (vector double);
18965 vector signed long long vec_ld (int, const vector signed long long *);
18966 vector signed long long vec_ld (int, const signed long long *);
18967 vector unsigned long long vec_ld (int, const vector unsigned long long *);
18968 vector unsigned long long vec_ld (int, const unsigned long long *);
18969 vector __int128 vec_ld (int, const vector __int128 *);
18970 vector unsigned __int128 vec_ld (int, const vector unsigned __int128 *);
18971 vector __int128 vec_ld (int, const __int128 *);
18972 vector unsigned __int128 vec_ld (int, const unsigned __int128 *);
18973 vector double vec_ld (int, const vector double *);
18974 vector double vec_ld (int, const double *);
18975 vector double vec_ldl (int, const vector double *);
18976 vector double vec_ldl (int, const double *);
18977 vector unsigned char vec_lvsl (int, const double *);
18978 vector unsigned char vec_lvsr (int, const double *);
18979 vector double vec_madd (vector double, vector double, vector double);
18980 vector double vec_max (vector double, vector double);
18981 vector signed long vec_mergeh (vector signed long, vector signed long);
18982 vector signed long vec_mergeh (vector signed long, vector bool long);
18983 vector signed long vec_mergeh (vector bool long, vector signed long);
18984 vector unsigned long vec_mergeh (vector unsigned long, vector unsigned long);
18985 vector unsigned long vec_mergeh (vector unsigned long, vector bool long);
18986 vector unsigned long vec_mergeh (vector bool long, vector unsigned long);
18987 vector signed long vec_mergel (vector signed long, vector signed long);
18988 vector signed long vec_mergel (vector signed long, vector bool long);
18989 vector signed long vec_mergel (vector bool long, vector signed long);
18990 vector unsigned long vec_mergel (vector unsigned long, vector unsigned long);
18991 vector unsigned long vec_mergel (vector unsigned long, vector bool long);
18992 vector unsigned long vec_mergel (vector bool long, vector unsigned long);
18993 vector double vec_min (vector double, vector double);
18994 vector float vec_msub (vector float, vector float, vector float);
18995 vector double vec_msub (vector double, vector double, vector double);
18996 vector float vec_nearbyint (vector float);
18997 vector double vec_nearbyint (vector double);
18998 vector float vec_nmadd (vector float, vector float, vector float);
18999 vector double vec_nmadd (vector double, vector double, vector double);
19000 vector double vec_nmsub (vector double, vector double, vector double);
19001 vector double vec_nor (vector double, vector double);
19002 vector long vec_nor (vector long, vector long);
19003 vector long vec_nor (vector long, vector bool long);
19004 vector long vec_nor (vector bool long, vector long);
19005 vector unsigned long vec_nor (vector unsigned long, vector unsigned long);
19006 vector unsigned long vec_nor (vector unsigned long, vector bool long);
19007 vector unsigned long vec_nor (vector bool long, vector unsigned long);
19008 vector double vec_or (vector double, vector double);
19009 vector double vec_or (vector double, vector bool long);
19010 vector double vec_or (vector bool long, vector double);
19011 vector long vec_or (vector long, vector long);
19012 vector long vec_or (vector long, vector bool long);
19013 vector long vec_or (vector bool long, vector long);
19014 vector unsigned long vec_or (vector unsigned long, vector unsigned long);
19015 vector unsigned long vec_or (vector unsigned long, vector bool long);
19016 vector unsigned long vec_or (vector bool long, vector unsigned long);
19017 vector double vec_perm (vector double, vector double, vector unsigned char);
19018 vector long vec_perm (vector long, vector long, vector unsigned char);
19019 vector unsigned long vec_perm (vector unsigned long, vector unsigned long,
19020                                vector unsigned char);
19021 vector bool char vec_permxor (vector bool char, vector bool char,
19022                               vector bool char);
19023 vector unsigned char vec_permxor (vector signed char, vector signed char,
19024                                   vector signed char);
19025 vector unsigned char vec_permxor (vector unsigned char, vector unsigned char,
19026                                   vector unsigned char);
19027 vector double vec_rint (vector double);
19028 vector double vec_recip (vector double, vector double);
19029 vector double vec_rsqrt (vector double);
19030 vector double vec_rsqrte (vector double);
19031 vector double vec_sel (vector double, vector double, vector bool long);
19032 vector double vec_sel (vector double, vector double, vector unsigned long);
19033 vector long vec_sel (vector long, vector long, vector long);
19034 vector long vec_sel (vector long, vector long, vector unsigned long);
19035 vector long vec_sel (vector long, vector long, vector bool long);
19036 vector unsigned long vec_sel (vector unsigned long, vector unsigned long,
19037                               vector long);
19038 vector unsigned long vec_sel (vector unsigned long, vector unsigned long,
19039                               vector unsigned long);
19040 vector unsigned long vec_sel (vector unsigned long, vector unsigned long,
19041                               vector bool long);
19042 vector double vec_splats (double);
19043 vector signed long vec_splats (signed long);
19044 vector unsigned long vec_splats (unsigned long);
19045 vector float vec_sqrt (vector float);
19046 vector double vec_sqrt (vector double);
19047 void vec_st (vector signed long long, int, vector signed long long *);
19048 void vec_st (vector signed long long, int, signed long long *);
19049 void vec_st (vector unsigned long long, int, vector unsigned long long *);
19050 void vec_st (vector unsigned long long, int, unsigned long long *);
19051 void vec_st (vector bool long long, int, vector bool long long *);
19052 void vec_st (vector bool long long, int, signed long long *);
19053 void vec_st (vector bool long long, int, unsigned long long *);
19054 void vec_st (vector double, int, vector double *);
19055 void vec_st (vector double, int, double *);
19056 vector double vec_sub (vector double, vector double);
19057 vector double vec_trunc (vector double);
19058 vector double vec_xl (int, vector double *);
19059 vector double vec_xl (int, double *);
19060 vector long long vec_xl (int, vector long long *);
19061 vector long long vec_xl (int, long long *);
19062 vector unsigned long long vec_xl (int, vector unsigned long long *);
19063 vector unsigned long long vec_xl (int, unsigned long long *);
19064 vector float vec_xl (int, vector float *);
19065 vector float vec_xl (int, float *);
19066 vector int vec_xl (int, vector int *);
19067 vector int vec_xl (int, int *);
19068 vector unsigned int vec_xl (int, vector unsigned int *);
19069 vector unsigned int vec_xl (int, unsigned int *);
19070 vector double vec_xor (vector double, vector double);
19071 vector double vec_xor (vector double, vector bool long);
19072 vector double vec_xor (vector bool long, vector double);
19073 vector long vec_xor (vector long, vector long);
19074 vector long vec_xor (vector long, vector bool long);
19075 vector long vec_xor (vector bool long, vector long);
19076 vector unsigned long vec_xor (vector unsigned long, vector unsigned long);
19077 vector unsigned long vec_xor (vector unsigned long, vector bool long);
19078 vector unsigned long vec_xor (vector bool long, vector unsigned long);
19079 void vec_xst (vector double, int, vector double *);
19080 void vec_xst (vector double, int, double *);
19081 void vec_xst (vector long long, int, vector long long *);
19082 void vec_xst (vector long long, int, long long *);
19083 void vec_xst (vector unsigned long long, int, vector unsigned long long *);
19084 void vec_xst (vector unsigned long long, int, unsigned long long *);
19085 void vec_xst (vector float, int, vector float *);
19086 void vec_xst (vector float, int, float *);
19087 void vec_xst (vector int, int, vector int *);
19088 void vec_xst (vector int, int, int *);
19089 void vec_xst (vector unsigned int, int, vector unsigned int *);
19090 void vec_xst (vector unsigned int, int, unsigned int *);
19091 int vec_all_eq (vector double, vector double);
19092 int vec_all_ge (vector double, vector double);
19093 int vec_all_gt (vector double, vector double);
19094 int vec_all_le (vector double, vector double);
19095 int vec_all_lt (vector double, vector double);
19096 int vec_all_nan (vector double);
19097 int vec_all_ne (vector double, vector double);
19098 int vec_all_nge (vector double, vector double);
19099 int vec_all_ngt (vector double, vector double);
19100 int vec_all_nle (vector double, vector double);
19101 int vec_all_nlt (vector double, vector double);
19102 int vec_all_numeric (vector double);
19103 int vec_any_eq (vector double, vector double);
19104 int vec_any_ge (vector double, vector double);
19105 int vec_any_gt (vector double, vector double);
19106 int vec_any_le (vector double, vector double);
19107 int vec_any_lt (vector double, vector double);
19108 int vec_any_nan (vector double);
19109 int vec_any_ne (vector double, vector double);
19110 int vec_any_nge (vector double, vector double);
19111 int vec_any_ngt (vector double, vector double);
19112 int vec_any_nle (vector double, vector double);
19113 int vec_any_nlt (vector double, vector double);
19114 int vec_any_numeric (vector double);
19116 vector double vec_vsx_ld (int, const vector double *);
19117 vector double vec_vsx_ld (int, const double *);
19118 vector float vec_vsx_ld (int, const vector float *);
19119 vector float vec_vsx_ld (int, const float *);
19120 vector bool int vec_vsx_ld (int, const vector bool int *);
19121 vector signed int vec_vsx_ld (int, const vector signed int *);
19122 vector signed int vec_vsx_ld (int, const int *);
19123 vector signed int vec_vsx_ld (int, const long *);
19124 vector unsigned int vec_vsx_ld (int, const vector unsigned int *);
19125 vector unsigned int vec_vsx_ld (int, const unsigned int *);
19126 vector unsigned int vec_vsx_ld (int, const unsigned long *);
19127 vector bool short vec_vsx_ld (int, const vector bool short *);
19128 vector pixel vec_vsx_ld (int, const vector pixel *);
19129 vector signed short vec_vsx_ld (int, const vector signed short *);
19130 vector signed short vec_vsx_ld (int, const short *);
19131 vector unsigned short vec_vsx_ld (int, const vector unsigned short *);
19132 vector unsigned short vec_vsx_ld (int, const unsigned short *);
19133 vector bool char vec_vsx_ld (int, const vector bool char *);
19134 vector signed char vec_vsx_ld (int, const vector signed char *);
19135 vector signed char vec_vsx_ld (int, const signed char *);
19136 vector unsigned char vec_vsx_ld (int, const vector unsigned char *);
19137 vector unsigned char vec_vsx_ld (int, const unsigned char *);
19139 void vec_vsx_st (vector double, int, vector double *);
19140 void vec_vsx_st (vector double, int, double *);
19141 void vec_vsx_st (vector float, int, vector float *);
19142 void vec_vsx_st (vector float, int, float *);
19143 void vec_vsx_st (vector signed int, int, vector signed int *);
19144 void vec_vsx_st (vector signed int, int, int *);
19145 void vec_vsx_st (vector unsigned int, int, vector unsigned int *);
19146 void vec_vsx_st (vector unsigned int, int, unsigned int *);
19147 void vec_vsx_st (vector bool int, int, vector bool int *);
19148 void vec_vsx_st (vector bool int, int, unsigned int *);
19149 void vec_vsx_st (vector bool int, int, int *);
19150 void vec_vsx_st (vector signed short, int, vector signed short *);
19151 void vec_vsx_st (vector signed short, int, short *);
19152 void vec_vsx_st (vector unsigned short, int, vector unsigned short *);
19153 void vec_vsx_st (vector unsigned short, int, unsigned short *);
19154 void vec_vsx_st (vector bool short, int, vector bool short *);
19155 void vec_vsx_st (vector bool short, int, unsigned short *);
19156 void vec_vsx_st (vector pixel, int, vector pixel *);
19157 void vec_vsx_st (vector pixel, int, unsigned short *);
19158 void vec_vsx_st (vector pixel, int, short *);
19159 void vec_vsx_st (vector bool short, int, short *);
19160 void vec_vsx_st (vector signed char, int, vector signed char *);
19161 void vec_vsx_st (vector signed char, int, signed char *);
19162 void vec_vsx_st (vector unsigned char, int, vector unsigned char *);
19163 void vec_vsx_st (vector unsigned char, int, unsigned char *);
19164 void vec_vsx_st (vector bool char, int, vector bool char *);
19165 void vec_vsx_st (vector bool char, int, unsigned char *);
19166 void vec_vsx_st (vector bool char, int, signed char *);
19168 vector double vec_xxpermdi (vector double, vector double, const int);
19169 vector float vec_xxpermdi (vector float, vector float, const int);
19170 vector long long vec_xxpermdi (vector long long, vector long long, const int);
19171 vector unsigned long long vec_xxpermdi (vector unsigned long long,
19172                                         vector unsigned long long, const int);
19173 vector int vec_xxpermdi (vector int, vector int, const int);
19174 vector unsigned int vec_xxpermdi (vector unsigned int,
19175                                   vector unsigned int, const int);
19176 vector short vec_xxpermdi (vector short, vector short, const int);
19177 vector unsigned short vec_xxpermdi (vector unsigned short,
19178                                     vector unsigned short, const int);
19179 vector signed char vec_xxpermdi (vector signed char, vector signed char,
19180                                  const int);
19181 vector unsigned char vec_xxpermdi (vector unsigned char,
19182                                    vector unsigned char, const int);
19184 vector double vec_xxsldi (vector double, vector double, int);
19185 vector float vec_xxsldi (vector float, vector float, int);
19186 vector long long vec_xxsldi (vector long long, vector long long, int);
19187 vector unsigned long long vec_xxsldi (vector unsigned long long,
19188                                       vector unsigned long long, int);
19189 vector int vec_xxsldi (vector int, vector int, int);
19190 vector unsigned int vec_xxsldi (vector unsigned int, vector unsigned int, int);
19191 vector short vec_xxsldi (vector short, vector short, int);
19192 vector unsigned short vec_xxsldi (vector unsigned short,
19193                                   vector unsigned short, int);
19194 vector signed char vec_xxsldi (vector signed char, vector signed char, int);
19195 vector unsigned char vec_xxsldi (vector unsigned char,
19196                                  vector unsigned char, int);
19197 @end smallexample
19199 Note that the @samp{vec_ld} and @samp{vec_st} built-in functions always
19200 generate the AltiVec @samp{LVX} and @samp{STVX} instructions even
19201 if the VSX instruction set is available.  The @samp{vec_vsx_ld} and
19202 @samp{vec_vsx_st} built-in functions always generate the VSX @samp{LXVD2X},
19203 @samp{LXVW4X}, @samp{STXVD2X}, and @samp{STXVW4X} instructions.
19205 @node PowerPC AltiVec Built-in Functions Available on ISA 2.07
19206 @subsubsection PowerPC AltiVec Built-in Functions Available on ISA 2.07
19208 If the ISA 2.07 additions to the vector/scalar (power8-vector)
19209 instruction set are available, the following additional functions are
19210 available for both 32-bit and 64-bit targets.  For 64-bit targets, you
19211 can use @var{vector long} instead of @var{vector long long},
19212 @var{vector bool long} instead of @var{vector bool long long}, and
19213 @var{vector unsigned long} instead of @var{vector unsigned long long}.
19215 @smallexample
19216 vector signed char vec_neg (vector signed char);
19217 vector signed short vec_neg (vector signed short);
19218 vector signed int vec_neg (vector signed int);
19219 vector signed long long vec_neg (vector signed long long);
19220 vector float  char vec_neg (vector float);
19221 vector double vec_neg (vector double);
19223 vector signed int vec_signed2 (vector double, vector double);
19225 vector signed int vec_unsigned2 (vector double, vector double);
19227 vector long long vec_abs (vector long long);
19229 vector long long vec_add (vector long long, vector long long);
19230 vector unsigned long long vec_add (vector unsigned long long,
19231                                    vector unsigned long long);
19233 int vec_all_eq (vector long long, vector long long);
19234 int vec_all_eq (vector unsigned long long, vector unsigned long long);
19235 int vec_all_ge (vector long long, vector long long);
19236 int vec_all_ge (vector unsigned long long, vector unsigned long long);
19237 int vec_all_gt (vector long long, vector long long);
19238 int vec_all_gt (vector unsigned long long, vector unsigned long long);
19239 int vec_all_le (vector long long, vector long long);
19240 int vec_all_le (vector unsigned long long, vector unsigned long long);
19241 int vec_all_lt (vector long long, vector long long);
19242 int vec_all_lt (vector unsigned long long, vector unsigned long long);
19243 int vec_all_ne (vector long long, vector long long);
19244 int vec_all_ne (vector unsigned long long, vector unsigned long long);
19246 int vec_any_eq (vector long long, vector long long);
19247 int vec_any_eq (vector unsigned long long, vector unsigned long long);
19248 int vec_any_ge (vector long long, vector long long);
19249 int vec_any_ge (vector unsigned long long, vector unsigned long long);
19250 int vec_any_gt (vector long long, vector long long);
19251 int vec_any_gt (vector unsigned long long, vector unsigned long long);
19252 int vec_any_le (vector long long, vector long long);
19253 int vec_any_le (vector unsigned long long, vector unsigned long long);
19254 int vec_any_lt (vector long long, vector long long);
19255 int vec_any_lt (vector unsigned long long, vector unsigned long long);
19256 int vec_any_ne (vector long long, vector long long);
19257 int vec_any_ne (vector unsigned long long, vector unsigned long long);
19259 vector bool long long vec_cmpeq (vector bool long long, vector bool long long);
19261 vector long long vec_eqv (vector long long, vector long long);
19262 vector long long vec_eqv (vector bool long long, vector long long);
19263 vector long long vec_eqv (vector long long, vector bool long long);
19264 vector unsigned long long vec_eqv (vector unsigned long long, vector unsigned long long);
19265 vector unsigned long long vec_eqv (vector bool long long, vector unsigned long long);
19266 vector unsigned long long vec_eqv (vector unsigned long long,
19267                                    vector bool long long);
19268 vector int vec_eqv (vector int, vector int);
19269 vector int vec_eqv (vector bool int, vector int);
19270 vector int vec_eqv (vector int, vector bool int);
19271 vector unsigned int vec_eqv (vector unsigned int, vector unsigned int);
19272 vector unsigned int vec_eqv (vector bool unsigned int, vector unsigned int);
19273 vector unsigned int vec_eqv (vector unsigned int, vector bool unsigned int);
19274 vector short vec_eqv (vector short, vector short);
19275 vector short vec_eqv (vector bool short, vector short);
19276 vector short vec_eqv (vector short, vector bool short);
19277 vector unsigned short vec_eqv (vector unsigned short, vector unsigned short);
19278 vector unsigned short vec_eqv (vector bool unsigned short, vector unsigned short);
19279 vector unsigned short vec_eqv (vector unsigned short, vector bool unsigned short);
19280 vector signed char vec_eqv (vector signed char, vector signed char);
19281 vector signed char vec_eqv (vector bool signed char, vector signed char);
19282 vector signed char vec_eqv (vector signed char, vector bool signed char);
19283 vector unsigned char vec_eqv (vector unsigned char, vector unsigned char);
19284 vector unsigned char vec_eqv (vector bool unsigned char, vector unsigned char);
19285 vector unsigned char vec_eqv (vector unsigned char, vector bool unsigned char);
19287 vector long long vec_max (vector long long, vector long long);
19288 vector unsigned long long vec_max (vector unsigned long long,
19289                                    vector unsigned long long);
19291 vector signed int vec_mergee (vector signed int, vector signed int);
19292 vector unsigned int vec_mergee (vector unsigned int, vector unsigned int);
19293 vector bool int vec_mergee (vector bool int, vector bool int);
19295 vector signed int vec_mergeo (vector signed int, vector signed int);
19296 vector unsigned int vec_mergeo (vector unsigned int, vector unsigned int);
19297 vector bool int vec_mergeo (vector bool int, vector bool int);
19299 vector long long vec_min (vector long long, vector long long);
19300 vector unsigned long long vec_min (vector unsigned long long,
19301                                    vector unsigned long long);
19303 vector signed long long vec_nabs (vector signed long long);
19305 vector long long vec_nand (vector long long, vector long long);
19306 vector long long vec_nand (vector bool long long, vector long long);
19307 vector long long vec_nand (vector long long, vector bool long long);
19308 vector unsigned long long vec_nand (vector unsigned long long,
19309                                     vector unsigned long long);
19310 vector unsigned long long vec_nand (vector bool long long, vector unsigned long long);
19311 vector unsigned long long vec_nand (vector unsigned long long, vector bool long long);
19312 vector int vec_nand (vector int, vector int);
19313 vector int vec_nand (vector bool int, vector int);
19314 vector int vec_nand (vector int, vector bool int);
19315 vector unsigned int vec_nand (vector unsigned int, vector unsigned int);
19316 vector unsigned int vec_nand (vector bool unsigned int, vector unsigned int);
19317 vector unsigned int vec_nand (vector unsigned int, vector bool unsigned int);
19318 vector short vec_nand (vector short, vector short);
19319 vector short vec_nand (vector bool short, vector short);
19320 vector short vec_nand (vector short, vector bool short);
19321 vector unsigned short vec_nand (vector unsigned short, vector unsigned short);
19322 vector unsigned short vec_nand (vector bool unsigned short, vector unsigned short);
19323 vector unsigned short vec_nand (vector unsigned short, vector bool unsigned short);
19324 vector signed char vec_nand (vector signed char, vector signed char);
19325 vector signed char vec_nand (vector bool signed char, vector signed char);
19326 vector signed char vec_nand (vector signed char, vector bool signed char);
19327 vector unsigned char vec_nand (vector unsigned char, vector unsigned char);
19328 vector unsigned char vec_nand (vector bool unsigned char, vector unsigned char);
19329 vector unsigned char vec_nand (vector unsigned char, vector bool unsigned char);
19331 vector long long vec_orc (vector long long, vector long long);
19332 vector long long vec_orc (vector bool long long, vector long long);
19333 vector long long vec_orc (vector long long, vector bool long long);
19334 vector unsigned long long vec_orc (vector unsigned long long,
19335                                    vector unsigned long long);
19336 vector unsigned long long vec_orc (vector bool long long, vector unsigned long long);
19337 vector unsigned long long vec_orc (vector unsigned long long, vector bool long long);
19338 vector int vec_orc (vector int, vector int);
19339 vector int vec_orc (vector bool int, vector int);
19340 vector int vec_orc (vector int, vector bool int);
19341 vector unsigned int vec_orc (vector unsigned int, vector unsigned int);
19342 vector unsigned int vec_orc (vector bool unsigned int, vector unsigned int);
19343 vector unsigned int vec_orc (vector unsigned int, vector bool unsigned int);
19344 vector short vec_orc (vector short, vector short);
19345 vector short vec_orc (vector bool short, vector short);
19346 vector short vec_orc (vector short, vector bool short);
19347 vector unsigned short vec_orc (vector unsigned short, vector unsigned short);
19348 vector unsigned short vec_orc (vector bool unsigned short, vector unsigned short);
19349 vector unsigned short vec_orc (vector unsigned short, vector bool unsigned short);
19350 vector signed char vec_orc (vector signed char, vector signed char);
19351 vector signed char vec_orc (vector bool signed char, vector signed char);
19352 vector signed char vec_orc (vector signed char, vector bool signed char);
19353 vector unsigned char vec_orc (vector unsigned char, vector unsigned char);
19354 vector unsigned char vec_orc (vector bool unsigned char, vector unsigned char);
19355 vector unsigned char vec_orc (vector unsigned char, vector bool unsigned char);
19357 vector int vec_pack (vector long long, vector long long);
19358 vector unsigned int vec_pack (vector unsigned long long, vector unsigned long long);
19359 vector bool int vec_pack (vector bool long long, vector bool long long);
19360 vector float vec_pack (vector double, vector double);
19362 vector int vec_packs (vector long long, vector long long);
19363 vector unsigned int vec_packs (vector unsigned long long, vector unsigned long long);
19365 vector unsigned char vec_packsu (vector signed short, vector signed short)
19366 vector unsigned char vec_packsu (vector unsigned short, vector unsigned short)
19367 vector unsigned short int vec_packsu (vector signed int, vector signed int);
19368 vector unsigned short int vec_packsu (vector unsigned int, vector unsigned int);
19369 vector unsigned int vec_packsu (vector long long, vector long long);
19370 vector unsigned int vec_packsu (vector unsigned long long, vector unsigned long long);
19371 vector unsigned int vec_packsu (vector signed long long, vector signed long long);
19373 vector unsigned char vec_popcnt (vector signed char);
19374 vector unsigned char vec_popcnt (vector unsigned char);
19375 vector unsigned short vec_popcnt (vector signed short);
19376 vector unsigned short vec_popcnt (vector unsigned short);
19377 vector unsigned int vec_popcnt (vector signed int);
19378 vector unsigned int vec_popcnt (vector unsigned int);
19379 vector unsigned long long vec_popcnt (vector signed long long);
19380 vector unsigned long long vec_popcnt (vector unsigned long long);
19382 vector long long vec_rl (vector long long, vector unsigned long long);
19383 vector long long vec_rl (vector unsigned long long, vector unsigned long long);
19385 vector long long vec_sl (vector long long, vector unsigned long long);
19386 vector long long vec_sl (vector unsigned long long, vector unsigned long long);
19388 vector long long vec_sr (vector long long, vector unsigned long long);
19389 vector unsigned long long char vec_sr (vector unsigned long long,
19390                                        vector unsigned long long);
19392 vector long long vec_sra (vector long long, vector unsigned long long);
19393 vector unsigned long long vec_sra (vector unsigned long long,
19394                                    vector unsigned long long);
19396 vector long long vec_sub (vector long long, vector long long);
19397 vector unsigned long long vec_sub (vector unsigned long long,
19398                                    vector unsigned long long);
19400 vector long long vec_unpackh (vector int);
19401 vector unsigned long long vec_unpackh (vector unsigned int);
19403 vector long long vec_unpackl (vector int);
19404 vector unsigned long long vec_unpackl (vector unsigned int);
19406 vector long long vec_vaddudm (vector long long, vector long long);
19407 vector long long vec_vaddudm (vector bool long long, vector long long);
19408 vector long long vec_vaddudm (vector long long, vector bool long long);
19409 vector unsigned long long vec_vaddudm (vector unsigned long long,
19410                                        vector unsigned long long);
19411 vector unsigned long long vec_vaddudm (vector bool unsigned long long,
19412                                        vector unsigned long long);
19413 vector unsigned long long vec_vaddudm (vector unsigned long long,
19414                                        vector bool unsigned long long);
19416 vector long long vec_vbpermq (vector signed char, vector signed char);
19417 vector long long vec_vbpermq (vector unsigned char, vector unsigned char);
19419 vector unsigned char vec_bperm (vector unsigned char, vector unsigned char);
19420 vector unsigned char vec_bperm (vector unsigned long long, vector unsigned char);
19421 vector unsigned long long vec_bperm (vector unsigned __int128, vector unsigned char);
19423 vector long long vec_cntlz (vector long long);
19424 vector unsigned long long vec_cntlz (vector unsigned long long);
19425 vector int vec_cntlz (vector int);
19426 vector unsigned int vec_cntlz (vector int);
19427 vector short vec_cntlz (vector short);
19428 vector unsigned short vec_cntlz (vector unsigned short);
19429 vector signed char vec_cntlz (vector signed char);
19430 vector unsigned char vec_cntlz (vector unsigned char);
19432 vector long long vec_vclz (vector long long);
19433 vector unsigned long long vec_vclz (vector unsigned long long);
19434 vector int vec_vclz (vector int);
19435 vector unsigned int vec_vclz (vector int);
19436 vector short vec_vclz (vector short);
19437 vector unsigned short vec_vclz (vector unsigned short);
19438 vector signed char vec_vclz (vector signed char);
19439 vector unsigned char vec_vclz (vector unsigned char);
19441 vector signed char vec_vclzb (vector signed char);
19442 vector unsigned char vec_vclzb (vector unsigned char);
19444 vector long long vec_vclzd (vector long long);
19445 vector unsigned long long vec_vclzd (vector unsigned long long);
19447 vector short vec_vclzh (vector short);
19448 vector unsigned short vec_vclzh (vector unsigned short);
19450 vector int vec_vclzw (vector int);
19451 vector unsigned int vec_vclzw (vector int);
19453 vector signed char vec_vgbbd (vector signed char);
19454 vector unsigned char vec_vgbbd (vector unsigned char);
19456 vector long long vec_vmaxsd (vector long long, vector long long);
19458 vector unsigned long long vec_vmaxud (vector unsigned long long,
19459                                       unsigned vector long long);
19461 vector long long vec_vminsd (vector long long, vector long long);
19463 vector unsigned long long vec_vminud (vector long long, vector long long);
19465 vector int vec_vpksdss (vector long long, vector long long);
19466 vector unsigned int vec_vpksdss (vector long long, vector long long);
19468 vector unsigned int vec_vpkudus (vector unsigned long long,
19469                                  vector unsigned long long);
19471 vector int vec_vpkudum (vector long long, vector long long);
19472 vector unsigned int vec_vpkudum (vector unsigned long long,
19473                                  vector unsigned long long);
19474 vector bool int vec_vpkudum (vector bool long long, vector bool long long);
19476 vector long long vec_vpopcnt (vector long long);
19477 vector unsigned long long vec_vpopcnt (vector unsigned long long);
19478 vector int vec_vpopcnt (vector int);
19479 vector unsigned int vec_vpopcnt (vector int);
19480 vector short vec_vpopcnt (vector short);
19481 vector unsigned short vec_vpopcnt (vector unsigned short);
19482 vector signed char vec_vpopcnt (vector signed char);
19483 vector unsigned char vec_vpopcnt (vector unsigned char);
19485 vector signed char vec_vpopcntb (vector signed char);
19486 vector unsigned char vec_vpopcntb (vector unsigned char);
19488 vector long long vec_vpopcntd (vector long long);
19489 vector unsigned long long vec_vpopcntd (vector unsigned long long);
19491 vector short vec_vpopcnth (vector short);
19492 vector unsigned short vec_vpopcnth (vector unsigned short);
19494 vector int vec_vpopcntw (vector int);
19495 vector unsigned int vec_vpopcntw (vector int);
19497 vector long long vec_vrld (vector long long, vector unsigned long long);
19498 vector unsigned long long vec_vrld (vector unsigned long long,
19499                                     vector unsigned long long);
19501 vector long long vec_vsld (vector long long, vector unsigned long long);
19502 vector long long vec_vsld (vector unsigned long long,
19503                            vector unsigned long long);
19505 vector long long vec_vsrad (vector long long, vector unsigned long long);
19506 vector unsigned long long vec_vsrad (vector unsigned long long,
19507                                      vector unsigned long long);
19509 vector long long vec_vsrd (vector long long, vector unsigned long long);
19510 vector unsigned long long char vec_vsrd (vector unsigned long long,
19511                                          vector unsigned long long);
19513 vector long long vec_vsubudm (vector long long, vector long long);
19514 vector long long vec_vsubudm (vector bool long long, vector long long);
19515 vector long long vec_vsubudm (vector long long, vector bool long long);
19516 vector unsigned long long vec_vsubudm (vector unsigned long long,
19517                                        vector unsigned long long);
19518 vector unsigned long long vec_vsubudm (vector bool long long,
19519                                        vector unsigned long long);
19520 vector unsigned long long vec_vsubudm (vector unsigned long long,
19521                                        vector bool long long);
19523 vector long long vec_vupkhsw (vector int);
19524 vector unsigned long long vec_vupkhsw (vector unsigned int);
19526 vector long long vec_vupklsw (vector int);
19527 vector unsigned long long vec_vupklsw (vector int);
19528 @end smallexample
19530 If the ISA 2.07 additions to the vector/scalar (power8-vector)
19531 instruction set are available, the following additional functions are
19532 available for 64-bit targets.  New vector types
19533 (@var{vector __int128} and @var{vector __uint128}) are available
19534 to hold the @var{__int128} and @var{__uint128} types to use these
19535 builtins.
19537 The normal vector extract, and set operations work on
19538 @var{vector __int128} and @var{vector __uint128} types,
19539 but the index value must be 0.
19541 @smallexample
19542 vector __int128 vec_vaddcuq (vector __int128, vector __int128);
19543 vector __uint128 vec_vaddcuq (vector __uint128, vector __uint128);
19545 vector __int128 vec_vadduqm (vector __int128, vector __int128);
19546 vector __uint128 vec_vadduqm (vector __uint128, vector __uint128);
19548 vector __int128 vec_vaddecuq (vector __int128, vector __int128,
19549                                 vector __int128);
19550 vector __uint128 vec_vaddecuq (vector __uint128, vector __uint128,
19551                                  vector __uint128);
19553 vector __int128 vec_vaddeuqm (vector __int128, vector __int128,
19554                                 vector __int128);
19555 vector __uint128 vec_vaddeuqm (vector __uint128, vector __uint128,
19556                                  vector __uint128);
19558 vector __int128 vec_vsubecuq (vector __int128, vector __int128,
19559                                 vector __int128);
19560 vector __uint128 vec_vsubecuq (vector __uint128, vector __uint128,
19561                                  vector __uint128);
19563 vector __int128 vec_vsubeuqm (vector __int128, vector __int128,
19564                                 vector __int128);
19565 vector __uint128 vec_vsubeuqm (vector __uint128, vector __uint128,
19566                                  vector __uint128);
19568 vector __int128 vec_vsubcuq (vector __int128, vector __int128);
19569 vector __uint128 vec_vsubcuq (vector __uint128, vector __uint128);
19571 __int128 vec_vsubuqm (__int128, __int128);
19572 __uint128 vec_vsubuqm (__uint128, __uint128);
19574 vector __int128 __builtin_bcdadd (vector __int128, vector __int128, const int);
19575 int __builtin_bcdadd_lt (vector __int128, vector __int128, const int);
19576 int __builtin_bcdadd_eq (vector __int128, vector __int128, const int);
19577 int __builtin_bcdadd_gt (vector __int128, vector __int128, const int);
19578 int __builtin_bcdadd_ov (vector __int128, vector __int128, const int);
19579 vector __int128 __builtin_bcdsub (vector __int128, vector __int128, const int);
19580 int __builtin_bcdsub_lt (vector __int128, vector __int128, const int);
19581 int __builtin_bcdsub_eq (vector __int128, vector __int128, const int);
19582 int __builtin_bcdsub_gt (vector __int128, vector __int128, const int);
19583 int __builtin_bcdsub_ov (vector __int128, vector __int128, const int);
19584 @end smallexample
19586 @node PowerPC AltiVec Built-in Functions Available on ISA 3.0
19587 @subsubsection PowerPC AltiVec Built-in Functions Available on ISA 3.0
19589 The following additional built-in functions are also available for the
19590 PowerPC family of processors, starting with ISA 3.0
19591 (@option{-mcpu=power9}) or later:
19592 @smallexample
19593 unsigned int scalar_extract_exp (double source);
19594 unsigned long long int scalar_extract_exp (__ieee128 source);
19596 unsigned long long int scalar_extract_sig (double source);
19597 unsigned __int128 scalar_extract_sig (__ieee128 source);
19599 double scalar_insert_exp (unsigned long long int significand,
19600                           unsigned long long int exponent);
19601 double scalar_insert_exp (double significand, unsigned long long int exponent);
19603 ieee_128 scalar_insert_exp (unsigned __int128 significand,
19604                             unsigned long long int exponent);
19605 ieee_128 scalar_insert_exp (ieee_128 significand, unsigned long long int exponent);
19607 int scalar_cmp_exp_gt (double arg1, double arg2);
19608 int scalar_cmp_exp_lt (double arg1, double arg2);
19609 int scalar_cmp_exp_eq (double arg1, double arg2);
19610 int scalar_cmp_exp_unordered (double arg1, double arg2);
19612 bool scalar_test_data_class (float source, const int condition);
19613 bool scalar_test_data_class (double source, const int condition);
19614 bool scalar_test_data_class (__ieee128 source, const int condition);
19616 bool scalar_test_neg (float source);
19617 bool scalar_test_neg (double source);
19618 bool scalar_test_neg (__ieee128 source);
19619 @end smallexample
19621 The @code{scalar_extract_exp} and @code{scalar_extract_sig}
19622 functions require a 64-bit environment supporting ISA 3.0 or later.
19623 The @code{scalar_extract_exp} and @code{scalar_extract_sig} built-in
19624 functions return the significand and the biased exponent value
19625 respectively of their @code{source} arguments.
19626 When supplied with a 64-bit @code{source} argument, the
19627 result returned by @code{scalar_extract_sig} has
19628 the @code{0x0010000000000000} bit set if the
19629 function's @code{source} argument is in normalized form.
19630 Otherwise, this bit is set to 0.
19631 When supplied with a 128-bit @code{source} argument, the
19632 @code{0x00010000000000000000000000000000} bit of the result is
19633 treated similarly.
19634 Note that the sign of the significand is not represented in the result
19635 returned from the @code{scalar_extract_sig} function.  Use the
19636 @code{scalar_test_neg} function to test the sign of its @code{double}
19637 argument.
19639 The @code{scalar_insert_exp}
19640 functions require a 64-bit environment supporting ISA 3.0 or later.
19641 When supplied with a 64-bit first argument, the
19642 @code{scalar_insert_exp} built-in function returns a double-precision
19643 floating point value that is constructed by assembling the values of its
19644 @code{significand} and @code{exponent} arguments.  The sign of the
19645 result is copied from the most significant bit of the
19646 @code{significand} argument.  The significand and exponent components
19647 of the result are composed of the least significant 11 bits of the
19648 @code{exponent} argument and the least significant 52 bits of the
19649 @code{significand} argument respectively.
19651 When supplied with a 128-bit first argument, the
19652 @code{scalar_insert_exp} built-in function returns a quad-precision
19653 ieee floating point value.  The sign bit of the result is copied from
19654 the most significant bit of the @code{significand} argument.
19655 The significand and exponent components of the result are composed of
19656 the least significant 15 bits of the @code{exponent} argument and the
19657 least significant 112 bits of the @code{significand} argument respectively.
19659 The @code{scalar_cmp_exp_gt}, @code{scalar_cmp_exp_lt},
19660 @code{scalar_cmp_exp_eq}, and @code{scalar_cmp_exp_unordered} built-in
19661 functions return a non-zero value if @code{arg1} is greater than, less
19662 than, equal to, or not comparable to @code{arg2} respectively.  The
19663 arguments are not comparable if one or the other equals NaN (not a
19664 number). 
19666 The @code{scalar_test_data_class} built-in function returns 1
19667 if any of the condition tests enabled by the value of the
19668 @code{condition} variable are true, and 0 otherwise.  The
19669 @code{condition} argument must be a compile-time constant integer with
19670 value not exceeding 127.  The
19671 @code{condition} argument is encoded as a bitmask with each bit
19672 enabling the testing of a different condition, as characterized by the
19673 following:
19674 @smallexample
19675 0x40    Test for NaN
19676 0x20    Test for +Infinity
19677 0x10    Test for -Infinity
19678 0x08    Test for +Zero
19679 0x04    Test for -Zero
19680 0x02    Test for +Denormal
19681 0x01    Test for -Denormal
19682 @end smallexample
19684 The @code{scalar_test_neg} built-in function returns 1 if its
19685 @code{source} argument holds a negative value, 0 otherwise.
19687 The following built-in functions are also available for the PowerPC family
19688 of processors, starting with ISA 3.0 or later
19689 (@option{-mcpu=power9}).  These string functions are described
19690 separately in order to group the descriptions closer to the function
19691 prototypes:
19692 @smallexample
19693 int vec_all_nez (vector signed char, vector signed char);
19694 int vec_all_nez (vector unsigned char, vector unsigned char);
19695 int vec_all_nez (vector signed short, vector signed short);
19696 int vec_all_nez (vector unsigned short, vector unsigned short);
19697 int vec_all_nez (vector signed int, vector signed int);
19698 int vec_all_nez (vector unsigned int, vector unsigned int);
19700 int vec_any_eqz (vector signed char, vector signed char);
19701 int vec_any_eqz (vector unsigned char, vector unsigned char);
19702 int vec_any_eqz (vector signed short, vector signed short);
19703 int vec_any_eqz (vector unsigned short, vector unsigned short);
19704 int vec_any_eqz (vector signed int, vector signed int);
19705 int vec_any_eqz (vector unsigned int, vector unsigned int);
19707 vector bool char vec_cmpnez (vector signed char arg1, vector signed char arg2);
19708 vector bool char vec_cmpnez (vector unsigned char arg1, vector unsigned char arg2);
19709 vector bool short vec_cmpnez (vector signed short arg1, vector signed short arg2);
19710 vector bool short vec_cmpnez (vector unsigned short arg1, vector unsigned short arg2);
19711 vector bool int vec_cmpnez (vector signed int arg1, vector signed int arg2);
19712 vector bool int vec_cmpnez (vector unsigned int, vector unsigned int);
19714 vector signed char vec_cnttz (vector signed char);
19715 vector unsigned char vec_cnttz (vector unsigned char);
19716 vector signed short vec_cnttz (vector signed short);
19717 vector unsigned short vec_cnttz (vector unsigned short);
19718 vector signed int vec_cnttz (vector signed int);
19719 vector unsigned int vec_cnttz (vector unsigned int);
19720 vector signed long long vec_cnttz (vector signed long long);
19721 vector unsigned long long vec_cnttz (vector unsigned long long);
19723 signed int vec_cntlz_lsbb (vector signed char);
19724 signed int vec_cntlz_lsbb (vector unsigned char);
19726 signed int vec_cnttz_lsbb (vector signed char);
19727 signed int vec_cnttz_lsbb (vector unsigned char);
19729 unsigned int vec_first_match_index (vector signed char, vector signed char);
19730 unsigned int vec_first_match_index (vector unsigned char, vector unsigned char);
19731 unsigned int vec_first_match_index (vector signed int, vector signed int);
19732 unsigned int vec_first_match_index (vector unsigned int, vector unsigned int);
19733 unsigned int vec_first_match_index (vector signed short, vector signed short);
19734 unsigned int vec_first_match_index (vector unsigned short, vector unsigned short);
19735 unsigned int vec_first_match_or_eos_index (vector signed char, vector signed char);
19736 unsigned int vec_first_match_or_eos_index (vector unsigned char, vector unsigned char);
19737 unsigned int vec_first_match_or_eos_index (vector signed int, vector signed int);
19738 unsigned int vec_first_match_or_eos_index (vector unsigned int, vector unsigned int);
19739 unsigned int vec_first_match_or_eos_index (vector signed short, vector signed short);
19740 unsigned int vec_first_match_or_eos_index (vector unsigned short,
19741                                            vector unsigned short);
19742 unsigned int vec_first_mismatch_index (vector signed char, vector signed char);
19743 unsigned int vec_first_mismatch_index (vector unsigned char, vector unsigned char);
19744 unsigned int vec_first_mismatch_index (vector signed int, vector signed int);
19745 unsigned int vec_first_mismatch_index (vector unsigned int, vector unsigned int);
19746 unsigned int vec_first_mismatch_index (vector signed short, vector signed short);
19747 unsigned int vec_first_mismatch_index (vector unsigned short, vector unsigned short);
19748 unsigned int vec_first_mismatch_or_eos_index (vector signed char, vector signed char);
19749 unsigned int vec_first_mismatch_or_eos_index (vector unsigned char,
19750                                               vector unsigned char);
19751 unsigned int vec_first_mismatch_or_eos_index (vector signed int, vector signed int);
19752 unsigned int vec_first_mismatch_or_eos_index (vector unsigned int, vector unsigned int);
19753 unsigned int vec_first_mismatch_or_eos_index (vector signed short, vector signed short);
19754 unsigned int vec_first_mismatch_or_eos_index (vector unsigned short,
19755                                               vector unsigned short);
19757 vector unsigned short vec_pack_to_short_fp32 (vector float, vector float);
19759 vector signed char vec_xl_be (signed long long, signed char *);
19760 vector unsigned char vec_xl_be (signed long long, unsigned char *);
19761 vector signed int vec_xl_be (signed long long, signed int *);
19762 vector unsigned int vec_xl_be (signed long long, unsigned int *);
19763 vector signed __int128 vec_xl_be (signed long long, signed __int128 *);
19764 vector unsigned __int128 vec_xl_be (signed long long, unsigned __int128 *);
19765 vector signed long long vec_xl_be (signed long long, signed long long *);
19766 vector unsigned long long vec_xl_be (signed long long, unsigned long long *);
19767 vector signed short vec_xl_be (signed long long, signed short *);
19768 vector unsigned short vec_xl_be (signed long long, unsigned short *);
19769 vector double vec_xl_be (signed long long, double *);
19770 vector float vec_xl_be (signed long long, float *);
19772 vector signed char vec_xl_len (signed char *addr, size_t len);
19773 vector unsigned char vec_xl_len (unsigned char *addr, size_t len);
19774 vector signed int vec_xl_len (signed int *addr, size_t len);
19775 vector unsigned int vec_xl_len (unsigned int *addr, size_t len);
19776 vector signed __int128 vec_xl_len (signed __int128 *addr, size_t len);
19777 vector unsigned __int128 vec_xl_len (unsigned __int128 *addr, size_t len);
19778 vector signed long long vec_xl_len (signed long long *addr, size_t len);
19779 vector unsigned long long vec_xl_len (unsigned long long *addr, size_t len);
19780 vector signed short vec_xl_len (signed short *addr, size_t len);
19781 vector unsigned short vec_xl_len (unsigned short *addr, size_t len);
19782 vector double vec_xl_len (double *addr, size_t len);
19783 vector float vec_xl_len (float *addr, size_t len);
19785 vector unsigned char vec_xl_len_r (unsigned char *addr, size_t len);
19787 void vec_xst_len (vector signed char data, signed char *addr, size_t len);
19788 void vec_xst_len (vector unsigned char data, unsigned char *addr, size_t len);
19789 void vec_xst_len (vector signed int data, signed int *addr, size_t len);
19790 void vec_xst_len (vector unsigned int data, unsigned int *addr, size_t len);
19791 void vec_xst_len (vector unsigned __int128 data, unsigned __int128 *addr, size_t len);
19792 void vec_xst_len (vector signed long long data, signed long long *addr, size_t len);
19793 void vec_xst_len (vector unsigned long long data, unsigned long long *addr, size_t len);
19794 void vec_xst_len (vector signed short data, signed short *addr, size_t len);
19795 void vec_xst_len (vector unsigned short data, unsigned short *addr, size_t len);
19796 void vec_xst_len (vector signed __int128 data, signed __int128 *addr, size_t len);
19797 void vec_xst_len (vector double data, double *addr, size_t len);
19798 void vec_xst_len (vector float data, float *addr, size_t len);
19800 void vec_xst_len_r (vector unsigned char data, unsigned char *addr, size_t len);
19802 signed char vec_xlx (unsigned int index, vector signed char data);
19803 unsigned char vec_xlx (unsigned int index, vector unsigned char data);
19804 signed short vec_xlx (unsigned int index, vector signed short data);
19805 unsigned short vec_xlx (unsigned int index, vector unsigned short data);
19806 signed int vec_xlx (unsigned int index, vector signed int data);
19807 unsigned int vec_xlx (unsigned int index, vector unsigned int data);
19808 float vec_xlx (unsigned int index, vector float data);
19810 signed char vec_xrx (unsigned int index, vector signed char data);
19811 unsigned char vec_xrx (unsigned int index, vector unsigned char data);
19812 signed short vec_xrx (unsigned int index, vector signed short data);
19813 unsigned short vec_xrx (unsigned int index, vector unsigned short data);
19814 signed int vec_xrx (unsigned int index, vector signed int data);
19815 unsigned int vec_xrx (unsigned int index, vector unsigned int data);
19816 float vec_xrx (unsigned int index, vector float data);
19817 @end smallexample
19819 The @code{vec_all_nez}, @code{vec_any_eqz}, and @code{vec_cmpnez}
19820 perform pairwise comparisons between the elements at the same
19821 positions within their two vector arguments.
19822 The @code{vec_all_nez} function returns a
19823 non-zero value if and only if all pairwise comparisons are not
19824 equal and no element of either vector argument contains a zero.
19825 The @code{vec_any_eqz} function returns a
19826 non-zero value if and only if at least one pairwise comparison is equal
19827 or if at least one element of either vector argument contains a zero.
19828 The @code{vec_cmpnez} function returns a vector of the same type as
19829 its two arguments, within which each element consists of all ones to
19830 denote that either the corresponding elements of the incoming arguments are
19831 not equal or that at least one of the corresponding elements contains
19832 zero.  Otherwise, the element of the returned vector contains all zeros.
19834 The @code{vec_cntlz_lsbb} function returns the count of the number of
19835 consecutive leading byte elements (starting from position 0 within the
19836 supplied vector argument) for which the least-significant bit
19837 equals zero.  The @code{vec_cnttz_lsbb} function returns the count of
19838 the number of consecutive trailing byte elements (starting from
19839 position 15 and counting backwards within the supplied vector
19840 argument) for which the least-significant bit equals zero.
19842 The @code{vec_xl_len} and @code{vec_xst_len} functions require a
19843 64-bit environment supporting ISA 3.0 or later.  The @code{vec_xl_len}
19844 function loads a variable length vector from memory.  The
19845 @code{vec_xst_len} function stores a variable length vector to memory.
19846 With both the @code{vec_xl_len} and @code{vec_xst_len} functions, the
19847 @code{addr} argument represents the memory address to or from which
19848 data will be transferred, and the
19849 @code{len} argument represents the number of bytes to be
19850 transferred, as computed by the C expression @code{min((len & 0xff), 16)}.
19851 If this expression's value is not a multiple of the vector element's
19852 size, the behavior of this function is undefined.
19853 In the case that the underlying computer is configured to run in
19854 big-endian mode, the data transfer moves bytes 0 to @code{(len - 1)} of
19855 the corresponding vector.  In little-endian mode, the data transfer
19856 moves bytes @code{(16 - len)} to @code{15} of the corresponding
19857 vector.  For the load function, any bytes of the result vector that
19858 are not loaded from memory are set to zero.
19859 The value of the @code{addr} argument need not be aligned on a
19860 multiple of the vector's element size.
19862 The @code{vec_xlx} and @code{vec_xrx} functions extract the single
19863 element selected by the @code{index} argument from the vector
19864 represented by the @code{data} argument.  The @code{index} argument
19865 always specifies a byte offset, regardless of the size of the vector
19866 element.  With @code{vec_xlx}, @code{index} is the offset of the first
19867 byte of the element to be extracted.  With @code{vec_xrx}, @code{index}
19868 represents the last byte of the element to be extracted, measured
19869 from the right end of the vector.  In other words, the last byte of
19870 the element to be extracted is found at position @code{(15 - index)}.
19871 There is no requirement that @code{index} be a multiple of the vector
19872 element size.  However, if the size of the vector element added to
19873 @code{index} is greater than 15, the content of the returned value is
19874 undefined.
19876 If the ISA 3.0 instruction set additions (@option{-mcpu=power9})
19877 are available:
19879 @smallexample
19880 vector unsigned long long vec_bperm (vector unsigned long long, vector unsigned char);
19882 vector bool char vec_cmpne (vector bool char, vector bool char);
19883 vector bool char vec_cmpne (vector signed char, vector signed char);
19884 vector bool char vec_cmpne (vector unsigned char, vector unsigned char);
19885 vector bool int vec_cmpne (vector bool int, vector bool int);
19886 vector bool int vec_cmpne (vector signed int, vector signed int);
19887 vector bool int vec_cmpne (vector unsigned int, vector unsigned int);
19888 vector bool long long vec_cmpne (vector bool long long, vector bool long long);
19889 vector bool long long vec_cmpne (vector signed long long, vector signed long long);
19890 vector bool long long vec_cmpne (vector unsigned long long, vector unsigned long long);
19891 vector bool short vec_cmpne (vector bool short, vector bool short);
19892 vector bool short vec_cmpne (vector signed short, vector signed short);
19893 vector bool short vec_cmpne (vector unsigned short, vector unsigned short);
19894 vector bool long long vec_cmpne (vector double, vector double);
19895 vector bool int vec_cmpne (vector float, vector float);
19897 vector float vec_extract_fp32_from_shorth (vector unsigned short);
19898 vector float vec_extract_fp32_from_shortl (vector unsigned short);
19900 vector long long vec_vctz (vector long long);
19901 vector unsigned long long vec_vctz (vector unsigned long long);
19902 vector int vec_vctz (vector int);
19903 vector unsigned int vec_vctz (vector int);
19904 vector short vec_vctz (vector short);
19905 vector unsigned short vec_vctz (vector unsigned short);
19906 vector signed char vec_vctz (vector signed char);
19907 vector unsigned char vec_vctz (vector unsigned char);
19909 vector signed char vec_vctzb (vector signed char);
19910 vector unsigned char vec_vctzb (vector unsigned char);
19912 vector long long vec_vctzd (vector long long);
19913 vector unsigned long long vec_vctzd (vector unsigned long long);
19915 vector short vec_vctzh (vector short);
19916 vector unsigned short vec_vctzh (vector unsigned short);
19918 vector int vec_vctzw (vector int);
19919 vector unsigned int vec_vctzw (vector int);
19921 vector unsigned long long vec_extract4b (vector unsigned char, const int);
19923 vector unsigned char vec_insert4b (vector signed int, vector unsigned char,
19924                                    const int);
19925 vector unsigned char vec_insert4b (vector unsigned int, vector unsigned char,
19926                                    const int);
19928 vector unsigned int vec_parity_lsbb (vector signed int);
19929 vector unsigned int vec_parity_lsbb (vector unsigned int);
19930 vector unsigned __int128 vec_parity_lsbb (vector signed __int128);
19931 vector unsigned __int128 vec_parity_lsbb (vector unsigned __int128);
19932 vector unsigned long long vec_parity_lsbb (vector signed long long);
19933 vector unsigned long long vec_parity_lsbb (vector unsigned long long);
19935 vector int vec_vprtyb (vector int);
19936 vector unsigned int vec_vprtyb (vector unsigned int);
19937 vector long long vec_vprtyb (vector long long);
19938 vector unsigned long long vec_vprtyb (vector unsigned long long);
19940 vector int vec_vprtybw (vector int);
19941 vector unsigned int vec_vprtybw (vector unsigned int);
19943 vector long long vec_vprtybd (vector long long);
19944 vector unsigned long long vec_vprtybd (vector unsigned long long);
19945 @end smallexample
19947 On 64-bit targets, if the ISA 3.0 additions (@option{-mcpu=power9})
19948 are available:
19950 @smallexample
19951 vector long vec_vprtyb (vector long);
19952 vector unsigned long vec_vprtyb (vector unsigned long);
19953 vector __int128 vec_vprtyb (vector __int128);
19954 vector __uint128 vec_vprtyb (vector __uint128);
19956 vector long vec_vprtybd (vector long);
19957 vector unsigned long vec_vprtybd (vector unsigned long);
19959 vector __int128 vec_vprtybq (vector __int128);
19960 vector __uint128 vec_vprtybd (vector __uint128);
19961 @end smallexample
19963 The following built-in vector functions are available for the PowerPC family
19964 of processors, starting with ISA 3.0 or later (@option{-mcpu=power9}):
19965 @smallexample
19966 __vector unsigned char
19967 vec_slv (__vector unsigned char src, __vector unsigned char shift_distance);
19968 __vector unsigned char
19969 vec_srv (__vector unsigned char src, __vector unsigned char shift_distance);
19970 @end smallexample
19972 The @code{vec_slv} and @code{vec_srv} functions operate on
19973 all of the bytes of their @code{src} and @code{shift_distance}
19974 arguments in parallel.  The behavior of the @code{vec_slv} is as if
19975 there existed a temporary array of 17 unsigned characters
19976 @code{slv_array} within which elements 0 through 15 are the same as
19977 the entries in the @code{src} array and element 16 equals 0.  The
19978 result returned from the @code{vec_slv} function is a
19979 @code{__vector} of 16 unsigned characters within which element
19980 @code{i} is computed using the C expression
19981 @code{0xff & (*((unsigned short *)(slv_array + i)) << (0x07 &
19982 shift_distance[i]))},
19983 with this resulting value coerced to the @code{unsigned char} type.
19984 The behavior of the @code{vec_srv} is as if
19985 there existed a temporary array of 17 unsigned characters
19986 @code{srv_array} within which element 0 equals zero and
19987 elements 1 through 16 equal the elements 0 through 15 of
19988 the @code{src} array.  The
19989 result returned from the @code{vec_srv} function is a
19990 @code{__vector} of 16 unsigned characters within which element
19991 @code{i} is computed using the C expression
19992 @code{0xff & (*((unsigned short *)(srv_array + i)) >>
19993 (0x07 & shift_distance[i]))},
19994 with this resulting value coerced to the @code{unsigned char} type.
19996 The following built-in functions are available for the PowerPC family
19997 of processors, starting with ISA 3.0 or later (@option{-mcpu=power9}):
19998 @smallexample
19999 __vector unsigned char
20000 vec_absd (__vector unsigned char arg1, __vector unsigned char arg2);
20001 __vector unsigned short
20002 vec_absd (__vector unsigned short arg1, __vector unsigned short arg2);
20003 __vector unsigned int
20004 vec_absd (__vector unsigned int arg1, __vector unsigned int arg2);
20006 __vector unsigned char
20007 vec_absdb (__vector unsigned char arg1, __vector unsigned char arg2);
20008 __vector unsigned short
20009 vec_absdh (__vector unsigned short arg1, __vector unsigned short arg2);
20010 __vector unsigned int
20011 vec_absdw (__vector unsigned int arg1, __vector unsigned int arg2);
20012 @end smallexample
20014 The @code{vec_absd}, @code{vec_absdb}, @code{vec_absdh}, and
20015 @code{vec_absdw} built-in functions each computes the absolute
20016 differences of the pairs of vector elements supplied in its two vector
20017 arguments, placing the absolute differences into the corresponding
20018 elements of the vector result.
20020 The following built-in functions are available for the PowerPC family
20021 of processors, starting with ISA 3.0 or later (@option{-mcpu=power9}):
20022 @smallexample
20023 __vector unsigned int vec_extract_exp (__vector float source);
20024 __vector unsigned long long int vec_extract_exp (__vector double source);
20026 __vector unsigned int vec_extract_sig (__vector float source);
20027 __vector unsigned long long int vec_extract_sig (__vector double source);
20029 __vector float vec_insert_exp (__vector unsigned int significands,
20030                                __vector unsigned int exponents);
20031 __vector float vec_insert_exp (__vector unsigned float significands,
20032                                __vector unsigned int exponents);
20033 __vector double vec_insert_exp (__vector unsigned long long int significands,
20034                                 __vector unsigned long long int exponents);
20035 __vector double vec_insert_exp (__vector unsigned double significands,
20036                                 __vector unsigned long long int exponents);
20038 __vector bool int vec_test_data_class (__vector float source, const int condition);
20039 __vector bool long long int vec_test_data_class (__vector double source,
20040                                                  const int condition);
20041 @end smallexample
20043 The @code{vec_extract_sig} and @code{vec_extract_exp} built-in
20044 functions return vectors representing the significands and biased
20045 exponent values of their @code{source} arguments respectively.
20046 Within the result vector returned by @code{vec_extract_sig}, the
20047 @code{0x800000} bit of each vector element returned when the
20048 function's @code{source} argument is of type @code{float} is set to 1
20049 if the corresponding floating point value is in normalized form.
20050 Otherwise, this bit is set to 0.  When the @code{source} argument is
20051 of type @code{double}, the @code{0x10000000000000} bit within each of
20052 the result vector's elements is set according to the same rules.
20053 Note that the sign of the significand is not represented in the result
20054 returned from the @code{vec_extract_sig} function.  To extract the
20055 sign bits, use the
20056 @code{vec_cpsgn} function, which returns a new vector within which all
20057 of the sign bits of its second argument vector are overwritten with the
20058 sign bits copied from the coresponding elements of its first argument
20059 vector, and all other (non-sign) bits of the second argument vector
20060 are copied unchanged into the result vector.
20062 The @code{vec_insert_exp} built-in functions return a vector of
20063 single- or double-precision floating
20064 point values constructed by assembling the values of their
20065 @code{significands} and @code{exponents} arguments into the
20066 corresponding elements of the returned vector.
20067 The sign of each
20068 element of the result is copied from the most significant bit of the
20069 corresponding entry within the @code{significands} argument.
20070 Note that the relevant
20071 bits of the @code{significands} argument are the same, for both integer
20072 and floating point types.
20074 significand and exponent components of each element of the result are
20075 composed of the least significant bits of the corresponding
20076 @code{significands} element and the least significant bits of the
20077 corresponding @code{exponents} element.
20079 The @code{vec_test_data_class} built-in function returns a vector
20080 representing the results of testing the @code{source} vector for the
20081 condition selected by the @code{condition} argument.  The
20082 @code{condition} argument must be a compile-time constant integer with
20083 value not exceeding 127.  The
20084 @code{condition} argument is encoded as a bitmask with each bit
20085 enabling the testing of a different condition, as characterized by the
20086 following:
20087 @smallexample
20088 0x40    Test for NaN
20089 0x20    Test for +Infinity
20090 0x10    Test for -Infinity
20091 0x08    Test for +Zero
20092 0x04    Test for -Zero
20093 0x02    Test for +Denormal
20094 0x01    Test for -Denormal
20095 @end smallexample
20097 If any of the enabled test conditions is true, the corresponding entry
20098 in the result vector is -1.  Otherwise (all of the enabled test
20099 conditions are false), the corresponding entry of the result vector is 0.
20101 The following built-in functions are available for the PowerPC family
20102 of processors, starting with ISA 3.0 or later (@option{-mcpu=power9}):
20103 @smallexample
20104 vector unsigned int vec_rlmi (vector unsigned int, vector unsigned int,
20105                               vector unsigned int);
20106 vector unsigned long long vec_rlmi (vector unsigned long long,
20107                                     vector unsigned long long,
20108                                     vector unsigned long long);
20109 vector unsigned int vec_rlnm (vector unsigned int, vector unsigned int,
20110                               vector unsigned int);
20111 vector unsigned long long vec_rlnm (vector unsigned long long,
20112                                     vector unsigned long long,
20113                                     vector unsigned long long);
20114 vector unsigned int vec_vrlnm (vector unsigned int, vector unsigned int);
20115 vector unsigned long long vec_vrlnm (vector unsigned long long,
20116                                      vector unsigned long long);
20117 @end smallexample
20119 The result of @code{vec_rlmi} is obtained by rotating each element of
20120 the first argument vector left and inserting it under mask into the
20121 second argument vector.  The third argument vector contains the mask
20122 beginning in bits 11:15, the mask end in bits 19:23, and the shift
20123 count in bits 27:31, of each element.
20125 The result of @code{vec_rlnm} is obtained by rotating each element of
20126 the first argument vector left and ANDing it with a mask specified by
20127 the second and third argument vectors.  The second argument vector
20128 contains the shift count for each element in the low-order byte.  The
20129 third argument vector contains the mask end for each element in the
20130 low-order byte, with the mask begin in the next higher byte.
20132 The result of @code{vec_vrlnm} is obtained by rotating each element
20133 of the first argument vector left and ANDing it with a mask.  The
20134 second argument vector contains the mask  beginning in bits 11:15,
20135 the mask end in bits 19:23, and the shift count in bits 27:31,
20136 of each element.
20138 If the ISA 3.0 instruction set additions (@option{-mcpu=power9})
20139 are available:
20140 @smallexample
20141 vector signed bool char vec_revb (vector signed char);
20142 vector signed char vec_revb (vector signed char);
20143 vector unsigned char vec_revb (vector unsigned char);
20144 vector bool short vec_revb (vector bool short);
20145 vector short vec_revb (vector short);
20146 vector unsigned short vec_revb (vector unsigned short);
20147 vector bool int vec_revb (vector bool int);
20148 vector int vec_revb (vector int);
20149 vector unsigned int vec_revb (vector unsigned int);
20150 vector float vec_revb (vector float);
20151 vector bool long long vec_revb (vector bool long long);
20152 vector long long vec_revb (vector long long);
20153 vector unsigned long long vec_revb (vector unsigned long long);
20154 vector double vec_revb (vector double);
20155 @end smallexample
20157 On 64-bit targets, if the ISA 3.0 additions (@option{-mcpu=power9})
20158 are available:
20159 @smallexample
20160 vector long vec_revb (vector long);
20161 vector unsigned long vec_revb (vector unsigned long);
20162 vector __int128 vec_revb (vector __int128);
20163 vector __uint128 vec_revb (vector __uint128);
20164 @end smallexample
20166 The @code{vec_revb} built-in function reverses the bytes on an element
20167 by element basis.  A vector of @code{vector unsigned char} or
20168 @code{vector signed char} reverses the bytes in the whole word.
20170 If the cryptographic instructions are enabled (@option{-mcrypto} or
20171 @option{-mcpu=power8}), the following builtins are enabled.
20173 @smallexample
20174 vector unsigned long long __builtin_crypto_vsbox (vector unsigned long long);
20176 vector unsigned char vec_sbox_be (vector unsigned char);
20178 vector unsigned long long __builtin_crypto_vcipher (vector unsigned long long,
20179                                                     vector unsigned long long);
20181 vector unsigned char vec_cipher_be (vector unsigned char, vector unsigned char);
20183 vector unsigned long long __builtin_crypto_vcipherlast
20184                                      (vector unsigned long long,
20185                                       vector unsigned long long);
20187 vector unsigned char vec_cipherlast_be (vector unsigned char,
20188                                         vector unsigned char);
20190 vector unsigned long long __builtin_crypto_vncipher (vector unsigned long long,
20191                                                      vector unsigned long long);
20193 vector unsigned char vec_ncipher_be (vector unsigned char,
20194                                      vector unsigned char);
20196 vector unsigned long long __builtin_crypto_vncipherlast (vector unsigned long long,
20197                                                          vector unsigned long long);
20199 vector unsigned char vec_ncipherlast_be (vector unsigned char,
20200                                          vector unsigned char);
20202 vector unsigned char __builtin_crypto_vpermxor (vector unsigned char,
20203                                                 vector unsigned char,
20204                                                 vector unsigned char);
20206 vector unsigned short __builtin_crypto_vpermxor (vector unsigned short,
20207                                                  vector unsigned short,
20208                                                  vector unsigned short);
20210 vector unsigned int __builtin_crypto_vpermxor (vector unsigned int,
20211                                                vector unsigned int,
20212                                                vector unsigned int);
20214 vector unsigned long long __builtin_crypto_vpermxor (vector unsigned long long,
20215                                                      vector unsigned long long,
20216                                                      vector unsigned long long);
20218 vector unsigned char __builtin_crypto_vpmsumb (vector unsigned char,
20219                                                vector unsigned char);
20221 vector unsigned short __builtin_crypto_vpmsumb (vector unsigned short,
20222                                                 vector unsigned short);
20224 vector unsigned int __builtin_crypto_vpmsumb (vector unsigned int,
20225                                               vector unsigned int);
20227 vector unsigned long long __builtin_crypto_vpmsumb (vector unsigned long long,
20228                                                     vector unsigned long long);
20230 vector unsigned long long __builtin_crypto_vshasigmad (vector unsigned long long,
20231                                                        int, int);
20233 vector unsigned int __builtin_crypto_vshasigmaw (vector unsigned int, int, int);
20234 @end smallexample
20236 The second argument to @var{__builtin_crypto_vshasigmad} and
20237 @var{__builtin_crypto_vshasigmaw} must be a constant
20238 integer that is 0 or 1.  The third argument to these built-in functions
20239 must be a constant integer in the range of 0 to 15.
20241 If the ISA 3.0 instruction set additions 
20242 are enabled (@option{-mcpu=power9}), the following additional
20243 functions are available for both 32-bit and 64-bit targets.
20244 @smallexample
20245 vector short vec_xl (int, vector short *);
20246 vector short vec_xl (int, short *);
20247 vector unsigned short vec_xl (int, vector unsigned short *);
20248 vector unsigned short vec_xl (int, unsigned short *);
20249 vector char vec_xl (int, vector char *);
20250 vector char vec_xl (int, char *);
20251 vector unsigned char vec_xl (int, vector unsigned char *);
20252 vector unsigned char vec_xl (int, unsigned char *);
20254 void vec_xst (vector short, int, vector short *);
20255 void vec_xst (vector short, int, short *);
20256 void vec_xst (vector unsigned short, int, vector unsigned short *);
20257 void vec_xst (vector unsigned short, int, unsigned short *);
20258 void vec_xst (vector char, int, vector char *);
20259 void vec_xst (vector char, int, char *);
20260 void vec_xst (vector unsigned char, int, vector unsigned char *);
20261 void vec_xst (vector unsigned char, int, unsigned char *);
20262 @end smallexample
20263 @node PowerPC Hardware Transactional Memory Built-in Functions
20264 @subsection PowerPC Hardware Transactional Memory Built-in Functions
20265 GCC provides two interfaces for accessing the Hardware Transactional
20266 Memory (HTM) instructions available on some of the PowerPC family
20267 of processors (eg, POWER8).  The two interfaces come in a low level
20268 interface, consisting of built-in functions specific to PowerPC and a
20269 higher level interface consisting of inline functions that are common
20270 between PowerPC and S/390.
20272 @subsubsection PowerPC HTM Low Level Built-in Functions
20274 The following low level built-in functions are available with
20275 @option{-mhtm} or @option{-mcpu=CPU} where CPU is `power8' or later.
20276 They all generate the machine instruction that is part of the name.
20278 The HTM builtins (with the exception of @code{__builtin_tbegin}) return
20279 the full 4-bit condition register value set by their associated hardware
20280 instruction.  The header file @code{htmintrin.h} defines some macros that can
20281 be used to decipher the return value.  The @code{__builtin_tbegin} builtin
20282 returns a simple @code{true} or @code{false} value depending on whether a transaction was
20283 successfully started or not.  The arguments of the builtins match exactly the
20284 type and order of the associated hardware instruction's operands, except for
20285 the @code{__builtin_tcheck} builtin, which does not take any input arguments.
20286 Refer to the ISA manual for a description of each instruction's operands.
20288 @smallexample
20289 unsigned int __builtin_tbegin (unsigned int)
20290 unsigned int __builtin_tend (unsigned int)
20292 unsigned int __builtin_tabort (unsigned int)
20293 unsigned int __builtin_tabortdc (unsigned int, unsigned int, unsigned int)
20294 unsigned int __builtin_tabortdci (unsigned int, unsigned int, int)
20295 unsigned int __builtin_tabortwc (unsigned int, unsigned int, unsigned int)
20296 unsigned int __builtin_tabortwci (unsigned int, unsigned int, int)
20298 unsigned int __builtin_tcheck (void)
20299 unsigned int __builtin_treclaim (unsigned int)
20300 unsigned int __builtin_trechkpt (void)
20301 unsigned int __builtin_tsr (unsigned int)
20302 @end smallexample
20304 In addition to the above HTM built-ins, we have added built-ins for
20305 some common extended mnemonics of the HTM instructions:
20307 @smallexample
20308 unsigned int __builtin_tendall (void)
20309 unsigned int __builtin_tresume (void)
20310 unsigned int __builtin_tsuspend (void)
20311 @end smallexample
20313 Note that the semantics of the above HTM builtins are required to mimic
20314 the locking semantics used for critical sections.  Builtins that are used
20315 to create a new transaction or restart a suspended transaction must have
20316 lock acquisition like semantics while those builtins that end or suspend a
20317 transaction must have lock release like semantics.  Specifically, this must
20318 mimic lock semantics as specified by C++11, for example: Lock acquisition is
20319 as-if an execution of __atomic_exchange_n(&globallock,1,__ATOMIC_ACQUIRE)
20320 that returns 0, and lock release is as-if an execution of
20321 __atomic_store(&globallock,0,__ATOMIC_RELEASE), with globallock being an
20322 implicit implementation-defined lock used for all transactions.  The HTM
20323 instructions associated with with the builtins inherently provide the
20324 correct acquisition and release hardware barriers required.  However,
20325 the compiler must also be prohibited from moving loads and stores across
20326 the builtins in a way that would violate their semantics.  This has been
20327 accomplished by adding memory barriers to the associated HTM instructions
20328 (which is a conservative approach to provide acquire and release semantics).
20329 Earlier versions of the compiler did not treat the HTM instructions as
20330 memory barriers.  A @code{__TM_FENCE__} macro has been added, which can
20331 be used to determine whether the current compiler treats HTM instructions
20332 as memory barriers or not.  This allows the user to explicitly add memory
20333 barriers to their code when using an older version of the compiler.
20335 The following set of built-in functions are available to gain access
20336 to the HTM specific special purpose registers.
20338 @smallexample
20339 unsigned long __builtin_get_texasr (void)
20340 unsigned long __builtin_get_texasru (void)
20341 unsigned long __builtin_get_tfhar (void)
20342 unsigned long __builtin_get_tfiar (void)
20344 void __builtin_set_texasr (unsigned long);
20345 void __builtin_set_texasru (unsigned long);
20346 void __builtin_set_tfhar (unsigned long);
20347 void __builtin_set_tfiar (unsigned long);
20348 @end smallexample
20350 Example usage of these low level built-in functions may look like:
20352 @smallexample
20353 #include <htmintrin.h>
20355 int num_retries = 10;
20357 while (1)
20358   @{
20359     if (__builtin_tbegin (0))
20360       @{
20361         /* Transaction State Initiated.  */
20362         if (is_locked (lock))
20363           __builtin_tabort (0);
20364         ... transaction code...
20365         __builtin_tend (0);
20366         break;
20367       @}
20368     else
20369       @{
20370         /* Transaction State Failed.  Use locks if the transaction
20371            failure is "persistent" or we've tried too many times.  */
20372         if (num_retries-- <= 0
20373             || _TEXASRU_FAILURE_PERSISTENT (__builtin_get_texasru ()))
20374           @{
20375             acquire_lock (lock);
20376             ... non transactional fallback path...
20377             release_lock (lock);
20378             break;
20379           @}
20380       @}
20381   @}
20382 @end smallexample
20384 One final built-in function has been added that returns the value of
20385 the 2-bit Transaction State field of the Machine Status Register (MSR)
20386 as stored in @code{CR0}.
20388 @smallexample
20389 unsigned long __builtin_ttest (void)
20390 @end smallexample
20392 This built-in can be used to determine the current transaction state
20393 using the following code example:
20395 @smallexample
20396 #include <htmintrin.h>
20398 unsigned char tx_state = _HTM_STATE (__builtin_ttest ());
20400 if (tx_state == _HTM_TRANSACTIONAL)
20401   @{
20402     /* Code to use in transactional state.  */
20403   @}
20404 else if (tx_state == _HTM_NONTRANSACTIONAL)
20405   @{
20406     /* Code to use in non-transactional state.  */
20407   @}
20408 else if (tx_state == _HTM_SUSPENDED)
20409   @{
20410     /* Code to use in transaction suspended state.  */
20411   @}
20412 @end smallexample
20414 @subsubsection PowerPC HTM High Level Inline Functions
20416 The following high level HTM interface is made available by including
20417 @code{<htmxlintrin.h>} and using @option{-mhtm} or @option{-mcpu=CPU}
20418 where CPU is `power8' or later.  This interface is common between PowerPC
20419 and S/390, allowing users to write one HTM source implementation that
20420 can be compiled and executed on either system.
20422 @smallexample
20423 long __TM_simple_begin (void)
20424 long __TM_begin (void* const TM_buff)
20425 long __TM_end (void)
20426 void __TM_abort (void)
20427 void __TM_named_abort (unsigned char const code)
20428 void __TM_resume (void)
20429 void __TM_suspend (void)
20431 long __TM_is_user_abort (void* const TM_buff)
20432 long __TM_is_named_user_abort (void* const TM_buff, unsigned char *code)
20433 long __TM_is_illegal (void* const TM_buff)
20434 long __TM_is_footprint_exceeded (void* const TM_buff)
20435 long __TM_nesting_depth (void* const TM_buff)
20436 long __TM_is_nested_too_deep(void* const TM_buff)
20437 long __TM_is_conflict(void* const TM_buff)
20438 long __TM_is_failure_persistent(void* const TM_buff)
20439 long __TM_failure_address(void* const TM_buff)
20440 long long __TM_failure_code(void* const TM_buff)
20441 @end smallexample
20443 Using these common set of HTM inline functions, we can create
20444 a more portable version of the HTM example in the previous
20445 section that will work on either PowerPC or S/390:
20447 @smallexample
20448 #include <htmxlintrin.h>
20450 int num_retries = 10;
20451 TM_buff_type TM_buff;
20453 while (1)
20454   @{
20455     if (__TM_begin (TM_buff) == _HTM_TBEGIN_STARTED)
20456       @{
20457         /* Transaction State Initiated.  */
20458         if (is_locked (lock))
20459           __TM_abort ();
20460         ... transaction code...
20461         __TM_end ();
20462         break;
20463       @}
20464     else
20465       @{
20466         /* Transaction State Failed.  Use locks if the transaction
20467            failure is "persistent" or we've tried too many times.  */
20468         if (num_retries-- <= 0
20469             || __TM_is_failure_persistent (TM_buff))
20470           @{
20471             acquire_lock (lock);
20472             ... non transactional fallback path...
20473             release_lock (lock);
20474             break;
20475           @}
20476       @}
20477   @}
20478 @end smallexample
20480 @node PowerPC Atomic Memory Operation Functions
20481 @subsection PowerPC Atomic Memory Operation Functions
20482 ISA 3.0 of the PowerPC added new atomic memory operation (amo)
20483 instructions.  GCC provides support for these instructions in 64-bit
20484 environments.  All of the functions are declared in the include file
20485 @code{amo.h}.
20487 The functions supported are:
20489 @smallexample
20490 #include <amo.h>
20492 uint32_t amo_lwat_add (uint32_t *, uint32_t);
20493 uint32_t amo_lwat_xor (uint32_t *, uint32_t);
20494 uint32_t amo_lwat_ior (uint32_t *, uint32_t);
20495 uint32_t amo_lwat_and (uint32_t *, uint32_t);
20496 uint32_t amo_lwat_umax (uint32_t *, uint32_t);
20497 uint32_t amo_lwat_umin (uint32_t *, uint32_t);
20498 uint32_t amo_lwat_swap (uint32_t *, uint32_t);
20500 int32_t amo_lwat_sadd (int32_t *, int32_t);
20501 int32_t amo_lwat_smax (int32_t *, int32_t);
20502 int32_t amo_lwat_smin (int32_t *, int32_t);
20503 int32_t amo_lwat_sswap (int32_t *, int32_t);
20505 uint64_t amo_ldat_add (uint64_t *, uint64_t);
20506 uint64_t amo_ldat_xor (uint64_t *, uint64_t);
20507 uint64_t amo_ldat_ior (uint64_t *, uint64_t);
20508 uint64_t amo_ldat_and (uint64_t *, uint64_t);
20509 uint64_t amo_ldat_umax (uint64_t *, uint64_t);
20510 uint64_t amo_ldat_umin (uint64_t *, uint64_t);
20511 uint64_t amo_ldat_swap (uint64_t *, uint64_t);
20513 int64_t amo_ldat_sadd (int64_t *, int64_t);
20514 int64_t amo_ldat_smax (int64_t *, int64_t);
20515 int64_t amo_ldat_smin (int64_t *, int64_t);
20516 int64_t amo_ldat_sswap (int64_t *, int64_t);
20518 void amo_stwat_add (uint32_t *, uint32_t);
20519 void amo_stwat_xor (uint32_t *, uint32_t);
20520 void amo_stwat_ior (uint32_t *, uint32_t);
20521 void amo_stwat_and (uint32_t *, uint32_t);
20522 void amo_stwat_umax (uint32_t *, uint32_t);
20523 void amo_stwat_umin (uint32_t *, uint32_t);
20525 void amo_stwat_sadd (int32_t *, int32_t);
20526 void amo_stwat_smax (int32_t *, int32_t);
20527 void amo_stwat_smin (int32_t *, int32_t);
20529 void amo_stdat_add (uint64_t *, uint64_t);
20530 void amo_stdat_xor (uint64_t *, uint64_t);
20531 void amo_stdat_ior (uint64_t *, uint64_t);
20532 void amo_stdat_and (uint64_t *, uint64_t);
20533 void amo_stdat_umax (uint64_t *, uint64_t);
20534 void amo_stdat_umin (uint64_t *, uint64_t);
20536 void amo_stdat_sadd (int64_t *, int64_t);
20537 void amo_stdat_smax (int64_t *, int64_t);
20538 void amo_stdat_smin (int64_t *, int64_t);
20539 @end smallexample
20541 @node RX Built-in Functions
20542 @subsection RX Built-in Functions
20543 GCC supports some of the RX instructions which cannot be expressed in
20544 the C programming language via the use of built-in functions.  The
20545 following functions are supported:
20547 @deftypefn {Built-in Function}  void __builtin_rx_brk (void)
20548 Generates the @code{brk} machine instruction.
20549 @end deftypefn
20551 @deftypefn {Built-in Function}  void __builtin_rx_clrpsw (int)
20552 Generates the @code{clrpsw} machine instruction to clear the specified
20553 bit in the processor status word.
20554 @end deftypefn
20556 @deftypefn {Built-in Function}  void __builtin_rx_int (int)
20557 Generates the @code{int} machine instruction to generate an interrupt
20558 with the specified value.
20559 @end deftypefn
20561 @deftypefn {Built-in Function}  void __builtin_rx_machi (int, int)
20562 Generates the @code{machi} machine instruction to add the result of
20563 multiplying the top 16 bits of the two arguments into the
20564 accumulator.
20565 @end deftypefn
20567 @deftypefn {Built-in Function}  void __builtin_rx_maclo (int, int)
20568 Generates the @code{maclo} machine instruction to add the result of
20569 multiplying the bottom 16 bits of the two arguments into the
20570 accumulator.
20571 @end deftypefn
20573 @deftypefn {Built-in Function}  void __builtin_rx_mulhi (int, int)
20574 Generates the @code{mulhi} machine instruction to place the result of
20575 multiplying the top 16 bits of the two arguments into the
20576 accumulator.
20577 @end deftypefn
20579 @deftypefn {Built-in Function}  void __builtin_rx_mullo (int, int)
20580 Generates the @code{mullo} machine instruction to place the result of
20581 multiplying the bottom 16 bits of the two arguments into the
20582 accumulator.
20583 @end deftypefn
20585 @deftypefn {Built-in Function}  int  __builtin_rx_mvfachi (void)
20586 Generates the @code{mvfachi} machine instruction to read the top
20587 32 bits of the accumulator.
20588 @end deftypefn
20590 @deftypefn {Built-in Function}  int  __builtin_rx_mvfacmi (void)
20591 Generates the @code{mvfacmi} machine instruction to read the middle
20592 32 bits of the accumulator.
20593 @end deftypefn
20595 @deftypefn {Built-in Function}  int __builtin_rx_mvfc (int)
20596 Generates the @code{mvfc} machine instruction which reads the control
20597 register specified in its argument and returns its value.
20598 @end deftypefn
20600 @deftypefn {Built-in Function}  void __builtin_rx_mvtachi (int)
20601 Generates the @code{mvtachi} machine instruction to set the top
20602 32 bits of the accumulator.
20603 @end deftypefn
20605 @deftypefn {Built-in Function}  void __builtin_rx_mvtaclo (int)
20606 Generates the @code{mvtaclo} machine instruction to set the bottom
20607 32 bits of the accumulator.
20608 @end deftypefn
20610 @deftypefn {Built-in Function}  void __builtin_rx_mvtc (int reg, int val)
20611 Generates the @code{mvtc} machine instruction which sets control
20612 register number @code{reg} to @code{val}.
20613 @end deftypefn
20615 @deftypefn {Built-in Function}  void __builtin_rx_mvtipl (int)
20616 Generates the @code{mvtipl} machine instruction set the interrupt
20617 priority level.
20618 @end deftypefn
20620 @deftypefn {Built-in Function}  void __builtin_rx_racw (int)
20621 Generates the @code{racw} machine instruction to round the accumulator
20622 according to the specified mode.
20623 @end deftypefn
20625 @deftypefn {Built-in Function}  int __builtin_rx_revw (int)
20626 Generates the @code{revw} machine instruction which swaps the bytes in
20627 the argument so that bits 0--7 now occupy bits 8--15 and vice versa,
20628 and also bits 16--23 occupy bits 24--31 and vice versa.
20629 @end deftypefn
20631 @deftypefn {Built-in Function}  void __builtin_rx_rmpa (void)
20632 Generates the @code{rmpa} machine instruction which initiates a
20633 repeated multiply and accumulate sequence.
20634 @end deftypefn
20636 @deftypefn {Built-in Function}  void __builtin_rx_round (float)
20637 Generates the @code{round} machine instruction which returns the
20638 floating-point argument rounded according to the current rounding mode
20639 set in the floating-point status word register.
20640 @end deftypefn
20642 @deftypefn {Built-in Function}  int __builtin_rx_sat (int)
20643 Generates the @code{sat} machine instruction which returns the
20644 saturated value of the argument.
20645 @end deftypefn
20647 @deftypefn {Built-in Function}  void __builtin_rx_setpsw (int)
20648 Generates the @code{setpsw} machine instruction to set the specified
20649 bit in the processor status word.
20650 @end deftypefn
20652 @deftypefn {Built-in Function}  void __builtin_rx_wait (void)
20653 Generates the @code{wait} machine instruction.
20654 @end deftypefn
20656 @node S/390 System z Built-in Functions
20657 @subsection S/390 System z Built-in Functions
20658 @deftypefn {Built-in Function} int __builtin_tbegin (void*)
20659 Generates the @code{tbegin} machine instruction starting a
20660 non-constrained hardware transaction.  If the parameter is non-NULL the
20661 memory area is used to store the transaction diagnostic buffer and
20662 will be passed as first operand to @code{tbegin}.  This buffer can be
20663 defined using the @code{struct __htm_tdb} C struct defined in
20664 @code{htmintrin.h} and must reside on a double-word boundary.  The
20665 second tbegin operand is set to @code{0xff0c}. This enables
20666 save/restore of all GPRs and disables aborts for FPR and AR
20667 manipulations inside the transaction body.  The condition code set by
20668 the tbegin instruction is returned as integer value.  The tbegin
20669 instruction by definition overwrites the content of all FPRs.  The
20670 compiler will generate code which saves and restores the FPRs.  For
20671 soft-float code it is recommended to used the @code{*_nofloat}
20672 variant.  In order to prevent a TDB from being written it is required
20673 to pass a constant zero value as parameter.  Passing a zero value
20674 through a variable is not sufficient.  Although modifications of
20675 access registers inside the transaction will not trigger an
20676 transaction abort it is not supported to actually modify them.  Access
20677 registers do not get saved when entering a transaction. They will have
20678 undefined state when reaching the abort code.
20679 @end deftypefn
20681 Macros for the possible return codes of tbegin are defined in the
20682 @code{htmintrin.h} header file:
20684 @table @code
20685 @item _HTM_TBEGIN_STARTED
20686 @code{tbegin} has been executed as part of normal processing.  The
20687 transaction body is supposed to be executed.
20688 @item _HTM_TBEGIN_INDETERMINATE
20689 The transaction was aborted due to an indeterminate condition which
20690 might be persistent.
20691 @item _HTM_TBEGIN_TRANSIENT
20692 The transaction aborted due to a transient failure.  The transaction
20693 should be re-executed in that case.
20694 @item _HTM_TBEGIN_PERSISTENT
20695 The transaction aborted due to a persistent failure.  Re-execution
20696 under same circumstances will not be productive.
20697 @end table
20699 @defmac _HTM_FIRST_USER_ABORT_CODE
20700 The @code{_HTM_FIRST_USER_ABORT_CODE} defined in @code{htmintrin.h}
20701 specifies the first abort code which can be used for
20702 @code{__builtin_tabort}.  Values below this threshold are reserved for
20703 machine use.
20704 @end defmac
20706 @deftp {Data type} {struct __htm_tdb}
20707 The @code{struct __htm_tdb} defined in @code{htmintrin.h} describes
20708 the structure of the transaction diagnostic block as specified in the
20709 Principles of Operation manual chapter 5-91.
20710 @end deftp
20712 @deftypefn {Built-in Function} int __builtin_tbegin_nofloat (void*)
20713 Same as @code{__builtin_tbegin} but without FPR saves and restores.
20714 Using this variant in code making use of FPRs will leave the FPRs in
20715 undefined state when entering the transaction abort handler code.
20716 @end deftypefn
20718 @deftypefn {Built-in Function} int __builtin_tbegin_retry (void*, int)
20719 In addition to @code{__builtin_tbegin} a loop for transient failures
20720 is generated.  If tbegin returns a condition code of 2 the transaction
20721 will be retried as often as specified in the second argument.  The
20722 perform processor assist instruction is used to tell the CPU about the
20723 number of fails so far.
20724 @end deftypefn
20726 @deftypefn {Built-in Function} int __builtin_tbegin_retry_nofloat (void*, int)
20727 Same as @code{__builtin_tbegin_retry} but without FPR saves and
20728 restores.  Using this variant in code making use of FPRs will leave
20729 the FPRs in undefined state when entering the transaction abort
20730 handler code.
20731 @end deftypefn
20733 @deftypefn {Built-in Function} void __builtin_tbeginc (void)
20734 Generates the @code{tbeginc} machine instruction starting a constrained
20735 hardware transaction.  The second operand is set to @code{0xff08}.
20736 @end deftypefn
20738 @deftypefn {Built-in Function} int __builtin_tend (void)
20739 Generates the @code{tend} machine instruction finishing a transaction
20740 and making the changes visible to other threads.  The condition code
20741 generated by tend is returned as integer value.
20742 @end deftypefn
20744 @deftypefn {Built-in Function} void __builtin_tabort (int)
20745 Generates the @code{tabort} machine instruction with the specified
20746 abort code.  Abort codes from 0 through 255 are reserved and will
20747 result in an error message.
20748 @end deftypefn
20750 @deftypefn {Built-in Function} void __builtin_tx_assist (int)
20751 Generates the @code{ppa rX,rY,1} machine instruction.  Where the
20752 integer parameter is loaded into rX and a value of zero is loaded into
20753 rY.  The integer parameter specifies the number of times the
20754 transaction repeatedly aborted.
20755 @end deftypefn
20757 @deftypefn {Built-in Function} int __builtin_tx_nesting_depth (void)
20758 Generates the @code{etnd} machine instruction.  The current nesting
20759 depth is returned as integer value.  For a nesting depth of 0 the code
20760 is not executed as part of an transaction.
20761 @end deftypefn
20763 @deftypefn {Built-in Function} void __builtin_non_tx_store (uint64_t *, uint64_t)
20765 Generates the @code{ntstg} machine instruction.  The second argument
20766 is written to the first arguments location.  The store operation will
20767 not be rolled-back in case of an transaction abort.
20768 @end deftypefn
20770 @node SH Built-in Functions
20771 @subsection SH Built-in Functions
20772 The following built-in functions are supported on the SH1, SH2, SH3 and SH4
20773 families of processors:
20775 @deftypefn {Built-in Function} {void} __builtin_set_thread_pointer (void *@var{ptr})
20776 Sets the @samp{GBR} register to the specified value @var{ptr}.  This is usually
20777 used by system code that manages threads and execution contexts.  The compiler
20778 normally does not generate code that modifies the contents of @samp{GBR} and
20779 thus the value is preserved across function calls.  Changing the @samp{GBR}
20780 value in user code must be done with caution, since the compiler might use
20781 @samp{GBR} in order to access thread local variables.
20783 @end deftypefn
20785 @deftypefn {Built-in Function} {void *} __builtin_thread_pointer (void)
20786 Returns the value that is currently set in the @samp{GBR} register.
20787 Memory loads and stores that use the thread pointer as a base address are
20788 turned into @samp{GBR} based displacement loads and stores, if possible.
20789 For example:
20790 @smallexample
20791 struct my_tcb
20793    int a, b, c, d, e;
20796 int get_tcb_value (void)
20798   // Generate @samp{mov.l @@(8,gbr),r0} instruction
20799   return ((my_tcb*)__builtin_thread_pointer ())->c;
20802 @end smallexample
20803 @end deftypefn
20805 @deftypefn {Built-in Function} {unsigned int} __builtin_sh_get_fpscr (void)
20806 Returns the value that is currently set in the @samp{FPSCR} register.
20807 @end deftypefn
20809 @deftypefn {Built-in Function} {void} __builtin_sh_set_fpscr (unsigned int @var{val})
20810 Sets the @samp{FPSCR} register to the specified value @var{val}, while
20811 preserving the current values of the FR, SZ and PR bits.
20812 @end deftypefn
20814 @node SPARC VIS Built-in Functions
20815 @subsection SPARC VIS Built-in Functions
20817 GCC supports SIMD operations on the SPARC using both the generic vector
20818 extensions (@pxref{Vector Extensions}) as well as built-in functions for
20819 the SPARC Visual Instruction Set (VIS).  When you use the @option{-mvis}
20820 switch, the VIS extension is exposed as the following built-in functions:
20822 @smallexample
20823 typedef int v1si __attribute__ ((vector_size (4)));
20824 typedef int v2si __attribute__ ((vector_size (8)));
20825 typedef short v4hi __attribute__ ((vector_size (8)));
20826 typedef short v2hi __attribute__ ((vector_size (4)));
20827 typedef unsigned char v8qi __attribute__ ((vector_size (8)));
20828 typedef unsigned char v4qi __attribute__ ((vector_size (4)));
20830 void __builtin_vis_write_gsr (int64_t);
20831 int64_t __builtin_vis_read_gsr (void);
20833 void * __builtin_vis_alignaddr (void *, long);
20834 void * __builtin_vis_alignaddrl (void *, long);
20835 int64_t __builtin_vis_faligndatadi (int64_t, int64_t);
20836 v2si __builtin_vis_faligndatav2si (v2si, v2si);
20837 v4hi __builtin_vis_faligndatav4hi (v4si, v4si);
20838 v8qi __builtin_vis_faligndatav8qi (v8qi, v8qi);
20840 v4hi __builtin_vis_fexpand (v4qi);
20842 v4hi __builtin_vis_fmul8x16 (v4qi, v4hi);
20843 v4hi __builtin_vis_fmul8x16au (v4qi, v2hi);
20844 v4hi __builtin_vis_fmul8x16al (v4qi, v2hi);
20845 v4hi __builtin_vis_fmul8sux16 (v8qi, v4hi);
20846 v4hi __builtin_vis_fmul8ulx16 (v8qi, v4hi);
20847 v2si __builtin_vis_fmuld8sux16 (v4qi, v2hi);
20848 v2si __builtin_vis_fmuld8ulx16 (v4qi, v2hi);
20850 v4qi __builtin_vis_fpack16 (v4hi);
20851 v8qi __builtin_vis_fpack32 (v2si, v8qi);
20852 v2hi __builtin_vis_fpackfix (v2si);
20853 v8qi __builtin_vis_fpmerge (v4qi, v4qi);
20855 int64_t __builtin_vis_pdist (v8qi, v8qi, int64_t);
20857 long __builtin_vis_edge8 (void *, void *);
20858 long __builtin_vis_edge8l (void *, void *);
20859 long __builtin_vis_edge16 (void *, void *);
20860 long __builtin_vis_edge16l (void *, void *);
20861 long __builtin_vis_edge32 (void *, void *);
20862 long __builtin_vis_edge32l (void *, void *);
20864 long __builtin_vis_fcmple16 (v4hi, v4hi);
20865 long __builtin_vis_fcmple32 (v2si, v2si);
20866 long __builtin_vis_fcmpne16 (v4hi, v4hi);
20867 long __builtin_vis_fcmpne32 (v2si, v2si);
20868 long __builtin_vis_fcmpgt16 (v4hi, v4hi);
20869 long __builtin_vis_fcmpgt32 (v2si, v2si);
20870 long __builtin_vis_fcmpeq16 (v4hi, v4hi);
20871 long __builtin_vis_fcmpeq32 (v2si, v2si);
20873 v4hi __builtin_vis_fpadd16 (v4hi, v4hi);
20874 v2hi __builtin_vis_fpadd16s (v2hi, v2hi);
20875 v2si __builtin_vis_fpadd32 (v2si, v2si);
20876 v1si __builtin_vis_fpadd32s (v1si, v1si);
20877 v4hi __builtin_vis_fpsub16 (v4hi, v4hi);
20878 v2hi __builtin_vis_fpsub16s (v2hi, v2hi);
20879 v2si __builtin_vis_fpsub32 (v2si, v2si);
20880 v1si __builtin_vis_fpsub32s (v1si, v1si);
20882 long __builtin_vis_array8 (long, long);
20883 long __builtin_vis_array16 (long, long);
20884 long __builtin_vis_array32 (long, long);
20885 @end smallexample
20887 When you use the @option{-mvis2} switch, the VIS version 2.0 built-in
20888 functions also become available:
20890 @smallexample
20891 long __builtin_vis_bmask (long, long);
20892 int64_t __builtin_vis_bshuffledi (int64_t, int64_t);
20893 v2si __builtin_vis_bshufflev2si (v2si, v2si);
20894 v4hi __builtin_vis_bshufflev2si (v4hi, v4hi);
20895 v8qi __builtin_vis_bshufflev2si (v8qi, v8qi);
20897 long __builtin_vis_edge8n (void *, void *);
20898 long __builtin_vis_edge8ln (void *, void *);
20899 long __builtin_vis_edge16n (void *, void *);
20900 long __builtin_vis_edge16ln (void *, void *);
20901 long __builtin_vis_edge32n (void *, void *);
20902 long __builtin_vis_edge32ln (void *, void *);
20903 @end smallexample
20905 When you use the @option{-mvis3} switch, the VIS version 3.0 built-in
20906 functions also become available:
20908 @smallexample
20909 void __builtin_vis_cmask8 (long);
20910 void __builtin_vis_cmask16 (long);
20911 void __builtin_vis_cmask32 (long);
20913 v4hi __builtin_vis_fchksm16 (v4hi, v4hi);
20915 v4hi __builtin_vis_fsll16 (v4hi, v4hi);
20916 v4hi __builtin_vis_fslas16 (v4hi, v4hi);
20917 v4hi __builtin_vis_fsrl16 (v4hi, v4hi);
20918 v4hi __builtin_vis_fsra16 (v4hi, v4hi);
20919 v2si __builtin_vis_fsll16 (v2si, v2si);
20920 v2si __builtin_vis_fslas16 (v2si, v2si);
20921 v2si __builtin_vis_fsrl16 (v2si, v2si);
20922 v2si __builtin_vis_fsra16 (v2si, v2si);
20924 long __builtin_vis_pdistn (v8qi, v8qi);
20926 v4hi __builtin_vis_fmean16 (v4hi, v4hi);
20928 int64_t __builtin_vis_fpadd64 (int64_t, int64_t);
20929 int64_t __builtin_vis_fpsub64 (int64_t, int64_t);
20931 v4hi __builtin_vis_fpadds16 (v4hi, v4hi);
20932 v2hi __builtin_vis_fpadds16s (v2hi, v2hi);
20933 v4hi __builtin_vis_fpsubs16 (v4hi, v4hi);
20934 v2hi __builtin_vis_fpsubs16s (v2hi, v2hi);
20935 v2si __builtin_vis_fpadds32 (v2si, v2si);
20936 v1si __builtin_vis_fpadds32s (v1si, v1si);
20937 v2si __builtin_vis_fpsubs32 (v2si, v2si);
20938 v1si __builtin_vis_fpsubs32s (v1si, v1si);
20940 long __builtin_vis_fucmple8 (v8qi, v8qi);
20941 long __builtin_vis_fucmpne8 (v8qi, v8qi);
20942 long __builtin_vis_fucmpgt8 (v8qi, v8qi);
20943 long __builtin_vis_fucmpeq8 (v8qi, v8qi);
20945 float __builtin_vis_fhadds (float, float);
20946 double __builtin_vis_fhaddd (double, double);
20947 float __builtin_vis_fhsubs (float, float);
20948 double __builtin_vis_fhsubd (double, double);
20949 float __builtin_vis_fnhadds (float, float);
20950 double __builtin_vis_fnhaddd (double, double);
20952 int64_t __builtin_vis_umulxhi (int64_t, int64_t);
20953 int64_t __builtin_vis_xmulx (int64_t, int64_t);
20954 int64_t __builtin_vis_xmulxhi (int64_t, int64_t);
20955 @end smallexample
20957 When you use the @option{-mvis4} switch, the VIS version 4.0 built-in
20958 functions also become available:
20960 @smallexample
20961 v8qi __builtin_vis_fpadd8 (v8qi, v8qi);
20962 v8qi __builtin_vis_fpadds8 (v8qi, v8qi);
20963 v8qi __builtin_vis_fpaddus8 (v8qi, v8qi);
20964 v4hi __builtin_vis_fpaddus16 (v4hi, v4hi);
20966 v8qi __builtin_vis_fpsub8 (v8qi, v8qi);
20967 v8qi __builtin_vis_fpsubs8 (v8qi, v8qi);
20968 v8qi __builtin_vis_fpsubus8 (v8qi, v8qi);
20969 v4hi __builtin_vis_fpsubus16 (v4hi, v4hi);
20971 long __builtin_vis_fpcmple8 (v8qi, v8qi);
20972 long __builtin_vis_fpcmpgt8 (v8qi, v8qi);
20973 long __builtin_vis_fpcmpule16 (v4hi, v4hi);
20974 long __builtin_vis_fpcmpugt16 (v4hi, v4hi);
20975 long __builtin_vis_fpcmpule32 (v2si, v2si);
20976 long __builtin_vis_fpcmpugt32 (v2si, v2si);
20978 v8qi __builtin_vis_fpmax8 (v8qi, v8qi);
20979 v4hi __builtin_vis_fpmax16 (v4hi, v4hi);
20980 v2si __builtin_vis_fpmax32 (v2si, v2si);
20982 v8qi __builtin_vis_fpmaxu8 (v8qi, v8qi);
20983 v4hi __builtin_vis_fpmaxu16 (v4hi, v4hi);
20984 v2si __builtin_vis_fpmaxu32 (v2si, v2si);
20987 v8qi __builtin_vis_fpmin8 (v8qi, v8qi);
20988 v4hi __builtin_vis_fpmin16 (v4hi, v4hi);
20989 v2si __builtin_vis_fpmin32 (v2si, v2si);
20991 v8qi __builtin_vis_fpminu8 (v8qi, v8qi);
20992 v4hi __builtin_vis_fpminu16 (v4hi, v4hi);
20993 v2si __builtin_vis_fpminu32 (v2si, v2si);
20994 @end smallexample
20996 When you use the @option{-mvis4b} switch, the VIS version 4.0B
20997 built-in functions also become available:
20999 @smallexample
21000 v8qi __builtin_vis_dictunpack8 (double, int);
21001 v4hi __builtin_vis_dictunpack16 (double, int);
21002 v2si __builtin_vis_dictunpack32 (double, int);
21004 long __builtin_vis_fpcmple8shl (v8qi, v8qi, int);
21005 long __builtin_vis_fpcmpgt8shl (v8qi, v8qi, int);
21006 long __builtin_vis_fpcmpeq8shl (v8qi, v8qi, int);
21007 long __builtin_vis_fpcmpne8shl (v8qi, v8qi, int);
21009 long __builtin_vis_fpcmple16shl (v4hi, v4hi, int);
21010 long __builtin_vis_fpcmpgt16shl (v4hi, v4hi, int);
21011 long __builtin_vis_fpcmpeq16shl (v4hi, v4hi, int);
21012 long __builtin_vis_fpcmpne16shl (v4hi, v4hi, int);
21014 long __builtin_vis_fpcmple32shl (v2si, v2si, int);
21015 long __builtin_vis_fpcmpgt32shl (v2si, v2si, int);
21016 long __builtin_vis_fpcmpeq32shl (v2si, v2si, int);
21017 long __builtin_vis_fpcmpne32shl (v2si, v2si, int);
21019 long __builtin_vis_fpcmpule8shl (v8qi, v8qi, int);
21020 long __builtin_vis_fpcmpugt8shl (v8qi, v8qi, int);
21021 long __builtin_vis_fpcmpule16shl (v4hi, v4hi, int);
21022 long __builtin_vis_fpcmpugt16shl (v4hi, v4hi, int);
21023 long __builtin_vis_fpcmpule32shl (v2si, v2si, int);
21024 long __builtin_vis_fpcmpugt32shl (v2si, v2si, int);
21026 long __builtin_vis_fpcmpde8shl (v8qi, v8qi, int);
21027 long __builtin_vis_fpcmpde16shl (v4hi, v4hi, int);
21028 long __builtin_vis_fpcmpde32shl (v2si, v2si, int);
21030 long __builtin_vis_fpcmpur8shl (v8qi, v8qi, int);
21031 long __builtin_vis_fpcmpur16shl (v4hi, v4hi, int);
21032 long __builtin_vis_fpcmpur32shl (v2si, v2si, int);
21033 @end smallexample
21035 @node SPU Built-in Functions
21036 @subsection SPU Built-in Functions
21038 GCC provides extensions for the SPU processor as described in the
21039 Sony/Toshiba/IBM SPU Language Extensions Specification.  GCC's
21040 implementation differs in several ways.
21042 @itemize @bullet
21044 @item
21045 The optional extension of specifying vector constants in parentheses is
21046 not supported.
21048 @item
21049 A vector initializer requires no cast if the vector constant is of the
21050 same type as the variable it is initializing.
21052 @item
21053 If @code{signed} or @code{unsigned} is omitted, the signedness of the
21054 vector type is the default signedness of the base type.  The default
21055 varies depending on the operating system, so a portable program should
21056 always specify the signedness.
21058 @item
21059 By default, the keyword @code{__vector} is added. The macro
21060 @code{vector} is defined in @code{<spu_intrinsics.h>} and can be
21061 undefined.
21063 @item
21064 GCC allows using a @code{typedef} name as the type specifier for a
21065 vector type.
21067 @item
21068 For C, overloaded functions are implemented with macros so the following
21069 does not work:
21071 @smallexample
21072   spu_add ((vector signed int)@{1, 2, 3, 4@}, foo);
21073 @end smallexample
21075 @noindent
21076 Since @code{spu_add} is a macro, the vector constant in the example
21077 is treated as four separate arguments.  Wrap the entire argument in
21078 parentheses for this to work.
21080 @item
21081 The extended version of @code{__builtin_expect} is not supported.
21083 @end itemize
21085 @emph{Note:} Only the interface described in the aforementioned
21086 specification is supported. Internally, GCC uses built-in functions to
21087 implement the required functionality, but these are not supported and
21088 are subject to change without notice.
21090 @node TI C6X Built-in Functions
21091 @subsection TI C6X Built-in Functions
21093 GCC provides intrinsics to access certain instructions of the TI C6X
21094 processors.  These intrinsics, listed below, are available after
21095 inclusion of the @code{c6x_intrinsics.h} header file.  They map directly
21096 to C6X instructions.
21098 @smallexample
21100 int _sadd (int, int)
21101 int _ssub (int, int)
21102 int _sadd2 (int, int)
21103 int _ssub2 (int, int)
21104 long long _mpy2 (int, int)
21105 long long _smpy2 (int, int)
21106 int _add4 (int, int)
21107 int _sub4 (int, int)
21108 int _saddu4 (int, int)
21110 int _smpy (int, int)
21111 int _smpyh (int, int)
21112 int _smpyhl (int, int)
21113 int _smpylh (int, int)
21115 int _sshl (int, int)
21116 int _subc (int, int)
21118 int _avg2 (int, int)
21119 int _avgu4 (int, int)
21121 int _clrr (int, int)
21122 int _extr (int, int)
21123 int _extru (int, int)
21124 int _abs (int)
21125 int _abs2 (int)
21127 @end smallexample
21129 @node TILE-Gx Built-in Functions
21130 @subsection TILE-Gx Built-in Functions
21132 GCC provides intrinsics to access every instruction of the TILE-Gx
21133 processor.  The intrinsics are of the form:
21135 @smallexample
21137 unsigned long long __insn_@var{op} (...)
21139 @end smallexample
21141 Where @var{op} is the name of the instruction.  Refer to the ISA manual
21142 for the complete list of instructions.
21144 GCC also provides intrinsics to directly access the network registers.
21145 The intrinsics are:
21147 @smallexample
21149 unsigned long long __tile_idn0_receive (void)
21150 unsigned long long __tile_idn1_receive (void)
21151 unsigned long long __tile_udn0_receive (void)
21152 unsigned long long __tile_udn1_receive (void)
21153 unsigned long long __tile_udn2_receive (void)
21154 unsigned long long __tile_udn3_receive (void)
21155 void __tile_idn_send (unsigned long long)
21156 void __tile_udn_send (unsigned long long)
21158 @end smallexample
21160 The intrinsic @code{void __tile_network_barrier (void)} is used to
21161 guarantee that no network operations before it are reordered with
21162 those after it.
21164 @node TILEPro Built-in Functions
21165 @subsection TILEPro Built-in Functions
21167 GCC provides intrinsics to access every instruction of the TILEPro
21168 processor.  The intrinsics are of the form:
21170 @smallexample
21172 unsigned __insn_@var{op} (...)
21174 @end smallexample
21176 @noindent
21177 where @var{op} is the name of the instruction.  Refer to the ISA manual
21178 for the complete list of instructions.
21180 GCC also provides intrinsics to directly access the network registers.
21181 The intrinsics are:
21183 @smallexample
21185 unsigned __tile_idn0_receive (void)
21186 unsigned __tile_idn1_receive (void)
21187 unsigned __tile_sn_receive (void)
21188 unsigned __tile_udn0_receive (void)
21189 unsigned __tile_udn1_receive (void)
21190 unsigned __tile_udn2_receive (void)
21191 unsigned __tile_udn3_receive (void)
21192 void __tile_idn_send (unsigned)
21193 void __tile_sn_send (unsigned)
21194 void __tile_udn_send (unsigned)
21196 @end smallexample
21198 The intrinsic @code{void __tile_network_barrier (void)} is used to
21199 guarantee that no network operations before it are reordered with
21200 those after it.
21202 @node x86 Built-in Functions
21203 @subsection x86 Built-in Functions
21205 These built-in functions are available for the x86-32 and x86-64 family
21206 of computers, depending on the command-line switches used.
21208 If you specify command-line switches such as @option{-msse},
21209 the compiler could use the extended instruction sets even if the built-ins
21210 are not used explicitly in the program.  For this reason, applications
21211 that perform run-time CPU detection must compile separate files for each
21212 supported architecture, using the appropriate flags.  In particular,
21213 the file containing the CPU detection code should be compiled without
21214 these options.
21216 The following machine modes are available for use with MMX built-in functions
21217 (@pxref{Vector Extensions}): @code{V2SI} for a vector of two 32-bit integers,
21218 @code{V4HI} for a vector of four 16-bit integers, and @code{V8QI} for a
21219 vector of eight 8-bit integers.  Some of the built-in functions operate on
21220 MMX registers as a whole 64-bit entity, these use @code{V1DI} as their mode.
21222 If 3DNow!@: extensions are enabled, @code{V2SF} is used as a mode for a vector
21223 of two 32-bit floating-point values.
21225 If SSE extensions are enabled, @code{V4SF} is used for a vector of four 32-bit
21226 floating-point values.  Some instructions use a vector of four 32-bit
21227 integers, these use @code{V4SI}.  Finally, some instructions operate on an
21228 entire vector register, interpreting it as a 128-bit integer, these use mode
21229 @code{TI}.
21231 The x86-32 and x86-64 family of processors use additional built-in
21232 functions for efficient use of @code{TF} (@code{__float128}) 128-bit
21233 floating point and @code{TC} 128-bit complex floating-point values.
21235 The following floating-point built-in functions are always available.  All
21236 of them implement the function that is part of the name.
21238 @smallexample
21239 __float128 __builtin_fabsq (__float128)
21240 __float128 __builtin_copysignq (__float128, __float128)
21241 @end smallexample
21243 The following built-in functions are always available.
21245 @table @code
21246 @item __float128 __builtin_infq (void)
21247 Similar to @code{__builtin_inf}, except the return type is @code{__float128}.
21248 @findex __builtin_infq
21250 @item __float128 __builtin_huge_valq (void)
21251 Similar to @code{__builtin_huge_val}, except the return type is @code{__float128}.
21252 @findex __builtin_huge_valq
21254 @item __float128 __builtin_nanq (void)
21255 Similar to @code{__builtin_nan}, except the return type is @code{__float128}.
21256 @findex __builtin_nanq
21258 @item __float128 __builtin_nansq (void)
21259 Similar to @code{__builtin_nans}, except the return type is @code{__float128}.
21260 @findex __builtin_nansq
21261 @end table
21263 The following built-in function is always available.
21265 @table @code
21266 @item void __builtin_ia32_pause (void)
21267 Generates the @code{pause} machine instruction with a compiler memory
21268 barrier.
21269 @end table
21271 The following built-in functions are always available and can be used to
21272 check the target platform type.
21274 @deftypefn {Built-in Function} void __builtin_cpu_init (void)
21275 This function runs the CPU detection code to check the type of CPU and the
21276 features supported.  This built-in function needs to be invoked along with the built-in functions
21277 to check CPU type and features, @code{__builtin_cpu_is} and
21278 @code{__builtin_cpu_supports}, only when used in a function that is
21279 executed before any constructors are called.  The CPU detection code is
21280 automatically executed in a very high priority constructor.
21282 For example, this function has to be used in @code{ifunc} resolvers that
21283 check for CPU type using the built-in functions @code{__builtin_cpu_is}
21284 and @code{__builtin_cpu_supports}, or in constructors on targets that
21285 don't support constructor priority.
21286 @smallexample
21288 static void (*resolve_memcpy (void)) (void)
21290   // ifunc resolvers fire before constructors, explicitly call the init
21291   // function.
21292   __builtin_cpu_init ();
21293   if (__builtin_cpu_supports ("ssse3"))
21294     return ssse3_memcpy; // super fast memcpy with ssse3 instructions.
21295   else
21296     return default_memcpy;
21299 void *memcpy (void *, const void *, size_t)
21300      __attribute__ ((ifunc ("resolve_memcpy")));
21301 @end smallexample
21303 @end deftypefn
21305 @deftypefn {Built-in Function} int __builtin_cpu_is (const char *@var{cpuname})
21306 This function returns a positive integer if the run-time CPU
21307 is of type @var{cpuname}
21308 and returns @code{0} otherwise. The following CPU names can be detected:
21310 @table @samp
21311 @item amd
21312 AMD CPU.
21314 @item intel
21315 Intel CPU.
21317 @item atom
21318 Intel Atom CPU.
21320 @item slm
21321 Intel Silvermont CPU.
21323 @item core2
21324 Intel Core 2 CPU.
21326 @item corei7
21327 Intel Core i7 CPU.
21329 @item nehalem
21330 Intel Core i7 Nehalem CPU.
21332 @item westmere
21333 Intel Core i7 Westmere CPU.
21335 @item sandybridge
21336 Intel Core i7 Sandy Bridge CPU.
21338 @item ivybridge
21339 Intel Core i7 Ivy Bridge CPU.
21341 @item haswell
21342 Intel Core i7 Haswell CPU.
21344 @item broadwell
21345 Intel Core i7 Broadwell CPU.
21347 @item skylake
21348 Intel Core i7 Skylake CPU.
21350 @item skylake-avx512
21351 Intel Core i7 Skylake AVX512 CPU.
21353 @item cannonlake
21354 Intel Core i7 Cannon Lake CPU.
21356 @item icelake-client
21357 Intel Core i7 Ice Lake Client CPU.
21359 @item icelake-server
21360 Intel Core i7 Ice Lake Server CPU.
21362 @item cascadelake
21363 Intel Core i7 Cascadelake CPU.
21365 @item bonnell
21366 Intel Atom Bonnell CPU.
21368 @item silvermont
21369 Intel Atom Silvermont CPU.
21371 @item goldmont
21372 Intel Atom Goldmont CPU.
21374 @item goldmont-plus
21375 Intel Atom Goldmont Plus CPU.
21377 @item tremont
21378 Intel Atom Tremont CPU.
21380 @item knl
21381 Intel Knights Landing CPU.
21383 @item knm
21384 Intel Knights Mill CPU.
21386 @item amdfam10h
21387 AMD Family 10h CPU.
21389 @item barcelona
21390 AMD Family 10h Barcelona CPU.
21392 @item shanghai
21393 AMD Family 10h Shanghai CPU.
21395 @item istanbul
21396 AMD Family 10h Istanbul CPU.
21398 @item btver1
21399 AMD Family 14h CPU.
21401 @item amdfam15h
21402 AMD Family 15h CPU.
21404 @item bdver1
21405 AMD Family 15h Bulldozer version 1.
21407 @item bdver2
21408 AMD Family 15h Bulldozer version 2.
21410 @item bdver3
21411 AMD Family 15h Bulldozer version 3.
21413 @item bdver4
21414 AMD Family 15h Bulldozer version 4.
21416 @item btver2
21417 AMD Family 16h CPU.
21419 @item amdfam17h
21420 AMD Family 17h CPU.
21422 @item znver1
21423 AMD Family 17h Zen version 1.
21425 @item znver2
21426 AMD Family 17h Zen version 2.
21427 @end table
21429 Here is an example:
21430 @smallexample
21431 if (__builtin_cpu_is ("corei7"))
21432   @{
21433      do_corei7 (); // Core i7 specific implementation.
21434   @}
21435 else
21436   @{
21437      do_generic (); // Generic implementation.
21438   @}
21439 @end smallexample
21440 @end deftypefn
21442 @deftypefn {Built-in Function} int __builtin_cpu_supports (const char *@var{feature})
21443 This function returns a positive integer if the run-time CPU
21444 supports @var{feature}
21445 and returns @code{0} otherwise. The following features can be detected:
21447 @table @samp
21448 @item cmov
21449 CMOV instruction.
21450 @item mmx
21451 MMX instructions.
21452 @item popcnt
21453 POPCNT instruction.
21454 @item sse
21455 SSE instructions.
21456 @item sse2
21457 SSE2 instructions.
21458 @item sse3
21459 SSE3 instructions.
21460 @item ssse3
21461 SSSE3 instructions.
21462 @item sse4.1
21463 SSE4.1 instructions.
21464 @item sse4.2
21465 SSE4.2 instructions.
21466 @item avx
21467 AVX instructions.
21468 @item avx2
21469 AVX2 instructions.
21470 @item sse4a
21471 SSE4A instructions.
21472 @item fma4
21473 FMA4 instructions.
21474 @item xop
21475 XOP instructions.
21476 @item fma
21477 FMA instructions.
21478 @item avx512f
21479 AVX512F instructions.
21480 @item bmi
21481 BMI instructions.
21482 @item bmi2
21483 BMI2 instructions.
21484 @item aes
21485 AES instructions.
21486 @item pclmul
21487 PCLMUL instructions.
21488 @item avx512vl
21489 AVX512VL instructions.
21490 @item avx512bw
21491 AVX512BW instructions.
21492 @item avx512dq
21493 AVX512DQ instructions.
21494 @item avx512cd
21495 AVX512CD instructions.
21496 @item avx512er
21497 AVX512ER instructions.
21498 @item avx512pf
21499 AVX512PF instructions.
21500 @item avx512vbmi
21501 AVX512VBMI instructions.
21502 @item avx512ifma
21503 AVX512IFMA instructions.
21504 @item avx5124vnniw
21505 AVX5124VNNIW instructions.
21506 @item avx5124fmaps
21507 AVX5124FMAPS instructions.
21508 @item avx512vpopcntdq
21509 AVX512VPOPCNTDQ instructions.
21510 @item avx512vbmi2
21511 AVX512VBMI2 instructions.
21512 @item gfni
21513 GFNI instructions.
21514 @item vpclmulqdq
21515 VPCLMULQDQ instructions.
21516 @item avx512vnni
21517 AVX512VNNI instructions.
21518 @item avx512bitalg
21519 AVX512BITALG instructions.
21520 @end table
21522 Here is an example:
21523 @smallexample
21524 if (__builtin_cpu_supports ("popcnt"))
21525   @{
21526      asm("popcnt %1,%0" : "=r"(count) : "rm"(n) : "cc");
21527   @}
21528 else
21529   @{
21530      count = generic_countbits (n); //generic implementation.
21531   @}
21532 @end smallexample
21533 @end deftypefn
21536 The following built-in functions are made available by @option{-mmmx}.
21537 All of them generate the machine instruction that is part of the name.
21539 @smallexample
21540 v8qi __builtin_ia32_paddb (v8qi, v8qi)
21541 v4hi __builtin_ia32_paddw (v4hi, v4hi)
21542 v2si __builtin_ia32_paddd (v2si, v2si)
21543 v8qi __builtin_ia32_psubb (v8qi, v8qi)
21544 v4hi __builtin_ia32_psubw (v4hi, v4hi)
21545 v2si __builtin_ia32_psubd (v2si, v2si)
21546 v8qi __builtin_ia32_paddsb (v8qi, v8qi)
21547 v4hi __builtin_ia32_paddsw (v4hi, v4hi)
21548 v8qi __builtin_ia32_psubsb (v8qi, v8qi)
21549 v4hi __builtin_ia32_psubsw (v4hi, v4hi)
21550 v8qi __builtin_ia32_paddusb (v8qi, v8qi)
21551 v4hi __builtin_ia32_paddusw (v4hi, v4hi)
21552 v8qi __builtin_ia32_psubusb (v8qi, v8qi)
21553 v4hi __builtin_ia32_psubusw (v4hi, v4hi)
21554 v4hi __builtin_ia32_pmullw (v4hi, v4hi)
21555 v4hi __builtin_ia32_pmulhw (v4hi, v4hi)
21556 di __builtin_ia32_pand (di, di)
21557 di __builtin_ia32_pandn (di,di)
21558 di __builtin_ia32_por (di, di)
21559 di __builtin_ia32_pxor (di, di)
21560 v8qi __builtin_ia32_pcmpeqb (v8qi, v8qi)
21561 v4hi __builtin_ia32_pcmpeqw (v4hi, v4hi)
21562 v2si __builtin_ia32_pcmpeqd (v2si, v2si)
21563 v8qi __builtin_ia32_pcmpgtb (v8qi, v8qi)
21564 v4hi __builtin_ia32_pcmpgtw (v4hi, v4hi)
21565 v2si __builtin_ia32_pcmpgtd (v2si, v2si)
21566 v8qi __builtin_ia32_punpckhbw (v8qi, v8qi)
21567 v4hi __builtin_ia32_punpckhwd (v4hi, v4hi)
21568 v2si __builtin_ia32_punpckhdq (v2si, v2si)
21569 v8qi __builtin_ia32_punpcklbw (v8qi, v8qi)
21570 v4hi __builtin_ia32_punpcklwd (v4hi, v4hi)
21571 v2si __builtin_ia32_punpckldq (v2si, v2si)
21572 v8qi __builtin_ia32_packsswb (v4hi, v4hi)
21573 v4hi __builtin_ia32_packssdw (v2si, v2si)
21574 v8qi __builtin_ia32_packuswb (v4hi, v4hi)
21576 v4hi __builtin_ia32_psllw (v4hi, v4hi)
21577 v2si __builtin_ia32_pslld (v2si, v2si)
21578 v1di __builtin_ia32_psllq (v1di, v1di)
21579 v4hi __builtin_ia32_psrlw (v4hi, v4hi)
21580 v2si __builtin_ia32_psrld (v2si, v2si)
21581 v1di __builtin_ia32_psrlq (v1di, v1di)
21582 v4hi __builtin_ia32_psraw (v4hi, v4hi)
21583 v2si __builtin_ia32_psrad (v2si, v2si)
21584 v4hi __builtin_ia32_psllwi (v4hi, int)
21585 v2si __builtin_ia32_pslldi (v2si, int)
21586 v1di __builtin_ia32_psllqi (v1di, int)
21587 v4hi __builtin_ia32_psrlwi (v4hi, int)
21588 v2si __builtin_ia32_psrldi (v2si, int)
21589 v1di __builtin_ia32_psrlqi (v1di, int)
21590 v4hi __builtin_ia32_psrawi (v4hi, int)
21591 v2si __builtin_ia32_psradi (v2si, int)
21593 @end smallexample
21595 The following built-in functions are made available either with
21596 @option{-msse}, or with @option{-m3dnowa}.  All of them generate
21597 the machine instruction that is part of the name.
21599 @smallexample
21600 v4hi __builtin_ia32_pmulhuw (v4hi, v4hi)
21601 v8qi __builtin_ia32_pavgb (v8qi, v8qi)
21602 v4hi __builtin_ia32_pavgw (v4hi, v4hi)
21603 v1di __builtin_ia32_psadbw (v8qi, v8qi)
21604 v8qi __builtin_ia32_pmaxub (v8qi, v8qi)
21605 v4hi __builtin_ia32_pmaxsw (v4hi, v4hi)
21606 v8qi __builtin_ia32_pminub (v8qi, v8qi)
21607 v4hi __builtin_ia32_pminsw (v4hi, v4hi)
21608 int __builtin_ia32_pmovmskb (v8qi)
21609 void __builtin_ia32_maskmovq (v8qi, v8qi, char *)
21610 void __builtin_ia32_movntq (di *, di)
21611 void __builtin_ia32_sfence (void)
21612 @end smallexample
21614 The following built-in functions are available when @option{-msse} is used.
21615 All of them generate the machine instruction that is part of the name.
21617 @smallexample
21618 int __builtin_ia32_comieq (v4sf, v4sf)
21619 int __builtin_ia32_comineq (v4sf, v4sf)
21620 int __builtin_ia32_comilt (v4sf, v4sf)
21621 int __builtin_ia32_comile (v4sf, v4sf)
21622 int __builtin_ia32_comigt (v4sf, v4sf)
21623 int __builtin_ia32_comige (v4sf, v4sf)
21624 int __builtin_ia32_ucomieq (v4sf, v4sf)
21625 int __builtin_ia32_ucomineq (v4sf, v4sf)
21626 int __builtin_ia32_ucomilt (v4sf, v4sf)
21627 int __builtin_ia32_ucomile (v4sf, v4sf)
21628 int __builtin_ia32_ucomigt (v4sf, v4sf)
21629 int __builtin_ia32_ucomige (v4sf, v4sf)
21630 v4sf __builtin_ia32_addps (v4sf, v4sf)
21631 v4sf __builtin_ia32_subps (v4sf, v4sf)
21632 v4sf __builtin_ia32_mulps (v4sf, v4sf)
21633 v4sf __builtin_ia32_divps (v4sf, v4sf)
21634 v4sf __builtin_ia32_addss (v4sf, v4sf)
21635 v4sf __builtin_ia32_subss (v4sf, v4sf)
21636 v4sf __builtin_ia32_mulss (v4sf, v4sf)
21637 v4sf __builtin_ia32_divss (v4sf, v4sf)
21638 v4sf __builtin_ia32_cmpeqps (v4sf, v4sf)
21639 v4sf __builtin_ia32_cmpltps (v4sf, v4sf)
21640 v4sf __builtin_ia32_cmpleps (v4sf, v4sf)
21641 v4sf __builtin_ia32_cmpgtps (v4sf, v4sf)
21642 v4sf __builtin_ia32_cmpgeps (v4sf, v4sf)
21643 v4sf __builtin_ia32_cmpunordps (v4sf, v4sf)
21644 v4sf __builtin_ia32_cmpneqps (v4sf, v4sf)
21645 v4sf __builtin_ia32_cmpnltps (v4sf, v4sf)
21646 v4sf __builtin_ia32_cmpnleps (v4sf, v4sf)
21647 v4sf __builtin_ia32_cmpngtps (v4sf, v4sf)
21648 v4sf __builtin_ia32_cmpngeps (v4sf, v4sf)
21649 v4sf __builtin_ia32_cmpordps (v4sf, v4sf)
21650 v4sf __builtin_ia32_cmpeqss (v4sf, v4sf)
21651 v4sf __builtin_ia32_cmpltss (v4sf, v4sf)
21652 v4sf __builtin_ia32_cmpless (v4sf, v4sf)
21653 v4sf __builtin_ia32_cmpunordss (v4sf, v4sf)
21654 v4sf __builtin_ia32_cmpneqss (v4sf, v4sf)
21655 v4sf __builtin_ia32_cmpnltss (v4sf, v4sf)
21656 v4sf __builtin_ia32_cmpnless (v4sf, v4sf)
21657 v4sf __builtin_ia32_cmpordss (v4sf, v4sf)
21658 v4sf __builtin_ia32_maxps (v4sf, v4sf)
21659 v4sf __builtin_ia32_maxss (v4sf, v4sf)
21660 v4sf __builtin_ia32_minps (v4sf, v4sf)
21661 v4sf __builtin_ia32_minss (v4sf, v4sf)
21662 v4sf __builtin_ia32_andps (v4sf, v4sf)
21663 v4sf __builtin_ia32_andnps (v4sf, v4sf)
21664 v4sf __builtin_ia32_orps (v4sf, v4sf)
21665 v4sf __builtin_ia32_xorps (v4sf, v4sf)
21666 v4sf __builtin_ia32_movss (v4sf, v4sf)
21667 v4sf __builtin_ia32_movhlps (v4sf, v4sf)
21668 v4sf __builtin_ia32_movlhps (v4sf, v4sf)
21669 v4sf __builtin_ia32_unpckhps (v4sf, v4sf)
21670 v4sf __builtin_ia32_unpcklps (v4sf, v4sf)
21671 v4sf __builtin_ia32_cvtpi2ps (v4sf, v2si)
21672 v4sf __builtin_ia32_cvtsi2ss (v4sf, int)
21673 v2si __builtin_ia32_cvtps2pi (v4sf)
21674 int __builtin_ia32_cvtss2si (v4sf)
21675 v2si __builtin_ia32_cvttps2pi (v4sf)
21676 int __builtin_ia32_cvttss2si (v4sf)
21677 v4sf __builtin_ia32_rcpps (v4sf)
21678 v4sf __builtin_ia32_rsqrtps (v4sf)
21679 v4sf __builtin_ia32_sqrtps (v4sf)
21680 v4sf __builtin_ia32_rcpss (v4sf)
21681 v4sf __builtin_ia32_rsqrtss (v4sf)
21682 v4sf __builtin_ia32_sqrtss (v4sf)
21683 v4sf __builtin_ia32_shufps (v4sf, v4sf, int)
21684 void __builtin_ia32_movntps (float *, v4sf)
21685 int __builtin_ia32_movmskps (v4sf)
21686 @end smallexample
21688 The following built-in functions are available when @option{-msse} is used.
21690 @table @code
21691 @item v4sf __builtin_ia32_loadups (float *)
21692 Generates the @code{movups} machine instruction as a load from memory.
21693 @item void __builtin_ia32_storeups (float *, v4sf)
21694 Generates the @code{movups} machine instruction as a store to memory.
21695 @item v4sf __builtin_ia32_loadss (float *)
21696 Generates the @code{movss} machine instruction as a load from memory.
21697 @item v4sf __builtin_ia32_loadhps (v4sf, const v2sf *)
21698 Generates the @code{movhps} machine instruction as a load from memory.
21699 @item v4sf __builtin_ia32_loadlps (v4sf, const v2sf *)
21700 Generates the @code{movlps} machine instruction as a load from memory
21701 @item void __builtin_ia32_storehps (v2sf *, v4sf)
21702 Generates the @code{movhps} machine instruction as a store to memory.
21703 @item void __builtin_ia32_storelps (v2sf *, v4sf)
21704 Generates the @code{movlps} machine instruction as a store to memory.
21705 @end table
21707 The following built-in functions are available when @option{-msse2} is used.
21708 All of them generate the machine instruction that is part of the name.
21710 @smallexample
21711 int __builtin_ia32_comisdeq (v2df, v2df)
21712 int __builtin_ia32_comisdlt (v2df, v2df)
21713 int __builtin_ia32_comisdle (v2df, v2df)
21714 int __builtin_ia32_comisdgt (v2df, v2df)
21715 int __builtin_ia32_comisdge (v2df, v2df)
21716 int __builtin_ia32_comisdneq (v2df, v2df)
21717 int __builtin_ia32_ucomisdeq (v2df, v2df)
21718 int __builtin_ia32_ucomisdlt (v2df, v2df)
21719 int __builtin_ia32_ucomisdle (v2df, v2df)
21720 int __builtin_ia32_ucomisdgt (v2df, v2df)
21721 int __builtin_ia32_ucomisdge (v2df, v2df)
21722 int __builtin_ia32_ucomisdneq (v2df, v2df)
21723 v2df __builtin_ia32_cmpeqpd (v2df, v2df)
21724 v2df __builtin_ia32_cmpltpd (v2df, v2df)
21725 v2df __builtin_ia32_cmplepd (v2df, v2df)
21726 v2df __builtin_ia32_cmpgtpd (v2df, v2df)
21727 v2df __builtin_ia32_cmpgepd (v2df, v2df)
21728 v2df __builtin_ia32_cmpunordpd (v2df, v2df)
21729 v2df __builtin_ia32_cmpneqpd (v2df, v2df)
21730 v2df __builtin_ia32_cmpnltpd (v2df, v2df)
21731 v2df __builtin_ia32_cmpnlepd (v2df, v2df)
21732 v2df __builtin_ia32_cmpngtpd (v2df, v2df)
21733 v2df __builtin_ia32_cmpngepd (v2df, v2df)
21734 v2df __builtin_ia32_cmpordpd (v2df, v2df)
21735 v2df __builtin_ia32_cmpeqsd (v2df, v2df)
21736 v2df __builtin_ia32_cmpltsd (v2df, v2df)
21737 v2df __builtin_ia32_cmplesd (v2df, v2df)
21738 v2df __builtin_ia32_cmpunordsd (v2df, v2df)
21739 v2df __builtin_ia32_cmpneqsd (v2df, v2df)
21740 v2df __builtin_ia32_cmpnltsd (v2df, v2df)
21741 v2df __builtin_ia32_cmpnlesd (v2df, v2df)
21742 v2df __builtin_ia32_cmpordsd (v2df, v2df)
21743 v2di __builtin_ia32_paddq (v2di, v2di)
21744 v2di __builtin_ia32_psubq (v2di, v2di)
21745 v2df __builtin_ia32_addpd (v2df, v2df)
21746 v2df __builtin_ia32_subpd (v2df, v2df)
21747 v2df __builtin_ia32_mulpd (v2df, v2df)
21748 v2df __builtin_ia32_divpd (v2df, v2df)
21749 v2df __builtin_ia32_addsd (v2df, v2df)
21750 v2df __builtin_ia32_subsd (v2df, v2df)
21751 v2df __builtin_ia32_mulsd (v2df, v2df)
21752 v2df __builtin_ia32_divsd (v2df, v2df)
21753 v2df __builtin_ia32_minpd (v2df, v2df)
21754 v2df __builtin_ia32_maxpd (v2df, v2df)
21755 v2df __builtin_ia32_minsd (v2df, v2df)
21756 v2df __builtin_ia32_maxsd (v2df, v2df)
21757 v2df __builtin_ia32_andpd (v2df, v2df)
21758 v2df __builtin_ia32_andnpd (v2df, v2df)
21759 v2df __builtin_ia32_orpd (v2df, v2df)
21760 v2df __builtin_ia32_xorpd (v2df, v2df)
21761 v2df __builtin_ia32_movsd (v2df, v2df)
21762 v2df __builtin_ia32_unpckhpd (v2df, v2df)
21763 v2df __builtin_ia32_unpcklpd (v2df, v2df)
21764 v16qi __builtin_ia32_paddb128 (v16qi, v16qi)
21765 v8hi __builtin_ia32_paddw128 (v8hi, v8hi)
21766 v4si __builtin_ia32_paddd128 (v4si, v4si)
21767 v2di __builtin_ia32_paddq128 (v2di, v2di)
21768 v16qi __builtin_ia32_psubb128 (v16qi, v16qi)
21769 v8hi __builtin_ia32_psubw128 (v8hi, v8hi)
21770 v4si __builtin_ia32_psubd128 (v4si, v4si)
21771 v2di __builtin_ia32_psubq128 (v2di, v2di)
21772 v8hi __builtin_ia32_pmullw128 (v8hi, v8hi)
21773 v8hi __builtin_ia32_pmulhw128 (v8hi, v8hi)
21774 v2di __builtin_ia32_pand128 (v2di, v2di)
21775 v2di __builtin_ia32_pandn128 (v2di, v2di)
21776 v2di __builtin_ia32_por128 (v2di, v2di)
21777 v2di __builtin_ia32_pxor128 (v2di, v2di)
21778 v16qi __builtin_ia32_pavgb128 (v16qi, v16qi)
21779 v8hi __builtin_ia32_pavgw128 (v8hi, v8hi)
21780 v16qi __builtin_ia32_pcmpeqb128 (v16qi, v16qi)
21781 v8hi __builtin_ia32_pcmpeqw128 (v8hi, v8hi)
21782 v4si __builtin_ia32_pcmpeqd128 (v4si, v4si)
21783 v16qi __builtin_ia32_pcmpgtb128 (v16qi, v16qi)
21784 v8hi __builtin_ia32_pcmpgtw128 (v8hi, v8hi)
21785 v4si __builtin_ia32_pcmpgtd128 (v4si, v4si)
21786 v16qi __builtin_ia32_pmaxub128 (v16qi, v16qi)
21787 v8hi __builtin_ia32_pmaxsw128 (v8hi, v8hi)
21788 v16qi __builtin_ia32_pminub128 (v16qi, v16qi)
21789 v8hi __builtin_ia32_pminsw128 (v8hi, v8hi)
21790 v16qi __builtin_ia32_punpckhbw128 (v16qi, v16qi)
21791 v8hi __builtin_ia32_punpckhwd128 (v8hi, v8hi)
21792 v4si __builtin_ia32_punpckhdq128 (v4si, v4si)
21793 v2di __builtin_ia32_punpckhqdq128 (v2di, v2di)
21794 v16qi __builtin_ia32_punpcklbw128 (v16qi, v16qi)
21795 v8hi __builtin_ia32_punpcklwd128 (v8hi, v8hi)
21796 v4si __builtin_ia32_punpckldq128 (v4si, v4si)
21797 v2di __builtin_ia32_punpcklqdq128 (v2di, v2di)
21798 v16qi __builtin_ia32_packsswb128 (v8hi, v8hi)
21799 v8hi __builtin_ia32_packssdw128 (v4si, v4si)
21800 v16qi __builtin_ia32_packuswb128 (v8hi, v8hi)
21801 v8hi __builtin_ia32_pmulhuw128 (v8hi, v8hi)
21802 void __builtin_ia32_maskmovdqu (v16qi, v16qi)
21803 v2df __builtin_ia32_loadupd (double *)
21804 void __builtin_ia32_storeupd (double *, v2df)
21805 v2df __builtin_ia32_loadhpd (v2df, double const *)
21806 v2df __builtin_ia32_loadlpd (v2df, double const *)
21807 int __builtin_ia32_movmskpd (v2df)
21808 int __builtin_ia32_pmovmskb128 (v16qi)
21809 void __builtin_ia32_movnti (int *, int)
21810 void __builtin_ia32_movnti64 (long long int *, long long int)
21811 void __builtin_ia32_movntpd (double *, v2df)
21812 void __builtin_ia32_movntdq (v2df *, v2df)
21813 v4si __builtin_ia32_pshufd (v4si, int)
21814 v8hi __builtin_ia32_pshuflw (v8hi, int)
21815 v8hi __builtin_ia32_pshufhw (v8hi, int)
21816 v2di __builtin_ia32_psadbw128 (v16qi, v16qi)
21817 v2df __builtin_ia32_sqrtpd (v2df)
21818 v2df __builtin_ia32_sqrtsd (v2df)
21819 v2df __builtin_ia32_shufpd (v2df, v2df, int)
21820 v2df __builtin_ia32_cvtdq2pd (v4si)
21821 v4sf __builtin_ia32_cvtdq2ps (v4si)
21822 v4si __builtin_ia32_cvtpd2dq (v2df)
21823 v2si __builtin_ia32_cvtpd2pi (v2df)
21824 v4sf __builtin_ia32_cvtpd2ps (v2df)
21825 v4si __builtin_ia32_cvttpd2dq (v2df)
21826 v2si __builtin_ia32_cvttpd2pi (v2df)
21827 v2df __builtin_ia32_cvtpi2pd (v2si)
21828 int __builtin_ia32_cvtsd2si (v2df)
21829 int __builtin_ia32_cvttsd2si (v2df)
21830 long long __builtin_ia32_cvtsd2si64 (v2df)
21831 long long __builtin_ia32_cvttsd2si64 (v2df)
21832 v4si __builtin_ia32_cvtps2dq (v4sf)
21833 v2df __builtin_ia32_cvtps2pd (v4sf)
21834 v4si __builtin_ia32_cvttps2dq (v4sf)
21835 v2df __builtin_ia32_cvtsi2sd (v2df, int)
21836 v2df __builtin_ia32_cvtsi642sd (v2df, long long)
21837 v4sf __builtin_ia32_cvtsd2ss (v4sf, v2df)
21838 v2df __builtin_ia32_cvtss2sd (v2df, v4sf)
21839 void __builtin_ia32_clflush (const void *)
21840 void __builtin_ia32_lfence (void)
21841 void __builtin_ia32_mfence (void)
21842 v16qi __builtin_ia32_loaddqu (const char *)
21843 void __builtin_ia32_storedqu (char *, v16qi)
21844 v1di __builtin_ia32_pmuludq (v2si, v2si)
21845 v2di __builtin_ia32_pmuludq128 (v4si, v4si)
21846 v8hi __builtin_ia32_psllw128 (v8hi, v8hi)
21847 v4si __builtin_ia32_pslld128 (v4si, v4si)
21848 v2di __builtin_ia32_psllq128 (v2di, v2di)
21849 v8hi __builtin_ia32_psrlw128 (v8hi, v8hi)
21850 v4si __builtin_ia32_psrld128 (v4si, v4si)
21851 v2di __builtin_ia32_psrlq128 (v2di, v2di)
21852 v8hi __builtin_ia32_psraw128 (v8hi, v8hi)
21853 v4si __builtin_ia32_psrad128 (v4si, v4si)
21854 v2di __builtin_ia32_pslldqi128 (v2di, int)
21855 v8hi __builtin_ia32_psllwi128 (v8hi, int)
21856 v4si __builtin_ia32_pslldi128 (v4si, int)
21857 v2di __builtin_ia32_psllqi128 (v2di, int)
21858 v2di __builtin_ia32_psrldqi128 (v2di, int)
21859 v8hi __builtin_ia32_psrlwi128 (v8hi, int)
21860 v4si __builtin_ia32_psrldi128 (v4si, int)
21861 v2di __builtin_ia32_psrlqi128 (v2di, int)
21862 v8hi __builtin_ia32_psrawi128 (v8hi, int)
21863 v4si __builtin_ia32_psradi128 (v4si, int)
21864 v4si __builtin_ia32_pmaddwd128 (v8hi, v8hi)
21865 v2di __builtin_ia32_movq128 (v2di)
21866 @end smallexample
21868 The following built-in functions are available when @option{-msse3} is used.
21869 All of them generate the machine instruction that is part of the name.
21871 @smallexample
21872 v2df __builtin_ia32_addsubpd (v2df, v2df)
21873 v4sf __builtin_ia32_addsubps (v4sf, v4sf)
21874 v2df __builtin_ia32_haddpd (v2df, v2df)
21875 v4sf __builtin_ia32_haddps (v4sf, v4sf)
21876 v2df __builtin_ia32_hsubpd (v2df, v2df)
21877 v4sf __builtin_ia32_hsubps (v4sf, v4sf)
21878 v16qi __builtin_ia32_lddqu (char const *)
21879 void __builtin_ia32_monitor (void *, unsigned int, unsigned int)
21880 v4sf __builtin_ia32_movshdup (v4sf)
21881 v4sf __builtin_ia32_movsldup (v4sf)
21882 void __builtin_ia32_mwait (unsigned int, unsigned int)
21883 @end smallexample
21885 The following built-in functions are available when @option{-mssse3} is used.
21886 All of them generate the machine instruction that is part of the name.
21888 @smallexample
21889 v2si __builtin_ia32_phaddd (v2si, v2si)
21890 v4hi __builtin_ia32_phaddw (v4hi, v4hi)
21891 v4hi __builtin_ia32_phaddsw (v4hi, v4hi)
21892 v2si __builtin_ia32_phsubd (v2si, v2si)
21893 v4hi __builtin_ia32_phsubw (v4hi, v4hi)
21894 v4hi __builtin_ia32_phsubsw (v4hi, v4hi)
21895 v4hi __builtin_ia32_pmaddubsw (v8qi, v8qi)
21896 v4hi __builtin_ia32_pmulhrsw (v4hi, v4hi)
21897 v8qi __builtin_ia32_pshufb (v8qi, v8qi)
21898 v8qi __builtin_ia32_psignb (v8qi, v8qi)
21899 v2si __builtin_ia32_psignd (v2si, v2si)
21900 v4hi __builtin_ia32_psignw (v4hi, v4hi)
21901 v1di __builtin_ia32_palignr (v1di, v1di, int)
21902 v8qi __builtin_ia32_pabsb (v8qi)
21903 v2si __builtin_ia32_pabsd (v2si)
21904 v4hi __builtin_ia32_pabsw (v4hi)
21905 @end smallexample
21907 The following built-in functions are available when @option{-mssse3} is used.
21908 All of them generate the machine instruction that is part of the name.
21910 @smallexample
21911 v4si __builtin_ia32_phaddd128 (v4si, v4si)
21912 v8hi __builtin_ia32_phaddw128 (v8hi, v8hi)
21913 v8hi __builtin_ia32_phaddsw128 (v8hi, v8hi)
21914 v4si __builtin_ia32_phsubd128 (v4si, v4si)
21915 v8hi __builtin_ia32_phsubw128 (v8hi, v8hi)
21916 v8hi __builtin_ia32_phsubsw128 (v8hi, v8hi)
21917 v8hi __builtin_ia32_pmaddubsw128 (v16qi, v16qi)
21918 v8hi __builtin_ia32_pmulhrsw128 (v8hi, v8hi)
21919 v16qi __builtin_ia32_pshufb128 (v16qi, v16qi)
21920 v16qi __builtin_ia32_psignb128 (v16qi, v16qi)
21921 v4si __builtin_ia32_psignd128 (v4si, v4si)
21922 v8hi __builtin_ia32_psignw128 (v8hi, v8hi)
21923 v2di __builtin_ia32_palignr128 (v2di, v2di, int)
21924 v16qi __builtin_ia32_pabsb128 (v16qi)
21925 v4si __builtin_ia32_pabsd128 (v4si)
21926 v8hi __builtin_ia32_pabsw128 (v8hi)
21927 @end smallexample
21929 The following built-in functions are available when @option{-msse4.1} is
21930 used.  All of them generate the machine instruction that is part of the
21931 name.
21933 @smallexample
21934 v2df __builtin_ia32_blendpd (v2df, v2df, const int)
21935 v4sf __builtin_ia32_blendps (v4sf, v4sf, const int)
21936 v2df __builtin_ia32_blendvpd (v2df, v2df, v2df)
21937 v4sf __builtin_ia32_blendvps (v4sf, v4sf, v4sf)
21938 v2df __builtin_ia32_dppd (v2df, v2df, const int)
21939 v4sf __builtin_ia32_dpps (v4sf, v4sf, const int)
21940 v4sf __builtin_ia32_insertps128 (v4sf, v4sf, const int)
21941 v2di __builtin_ia32_movntdqa (v2di *);
21942 v16qi __builtin_ia32_mpsadbw128 (v16qi, v16qi, const int)
21943 v8hi __builtin_ia32_packusdw128 (v4si, v4si)
21944 v16qi __builtin_ia32_pblendvb128 (v16qi, v16qi, v16qi)
21945 v8hi __builtin_ia32_pblendw128 (v8hi, v8hi, const int)
21946 v2di __builtin_ia32_pcmpeqq (v2di, v2di)
21947 v8hi __builtin_ia32_phminposuw128 (v8hi)
21948 v16qi __builtin_ia32_pmaxsb128 (v16qi, v16qi)
21949 v4si __builtin_ia32_pmaxsd128 (v4si, v4si)
21950 v4si __builtin_ia32_pmaxud128 (v4si, v4si)
21951 v8hi __builtin_ia32_pmaxuw128 (v8hi, v8hi)
21952 v16qi __builtin_ia32_pminsb128 (v16qi, v16qi)
21953 v4si __builtin_ia32_pminsd128 (v4si, v4si)
21954 v4si __builtin_ia32_pminud128 (v4si, v4si)
21955 v8hi __builtin_ia32_pminuw128 (v8hi, v8hi)
21956 v4si __builtin_ia32_pmovsxbd128 (v16qi)
21957 v2di __builtin_ia32_pmovsxbq128 (v16qi)
21958 v8hi __builtin_ia32_pmovsxbw128 (v16qi)
21959 v2di __builtin_ia32_pmovsxdq128 (v4si)
21960 v4si __builtin_ia32_pmovsxwd128 (v8hi)
21961 v2di __builtin_ia32_pmovsxwq128 (v8hi)
21962 v4si __builtin_ia32_pmovzxbd128 (v16qi)
21963 v2di __builtin_ia32_pmovzxbq128 (v16qi)
21964 v8hi __builtin_ia32_pmovzxbw128 (v16qi)
21965 v2di __builtin_ia32_pmovzxdq128 (v4si)
21966 v4si __builtin_ia32_pmovzxwd128 (v8hi)
21967 v2di __builtin_ia32_pmovzxwq128 (v8hi)
21968 v2di __builtin_ia32_pmuldq128 (v4si, v4si)
21969 v4si __builtin_ia32_pmulld128 (v4si, v4si)
21970 int __builtin_ia32_ptestc128 (v2di, v2di)
21971 int __builtin_ia32_ptestnzc128 (v2di, v2di)
21972 int __builtin_ia32_ptestz128 (v2di, v2di)
21973 v2df __builtin_ia32_roundpd (v2df, const int)
21974 v4sf __builtin_ia32_roundps (v4sf, const int)
21975 v2df __builtin_ia32_roundsd (v2df, v2df, const int)
21976 v4sf __builtin_ia32_roundss (v4sf, v4sf, const int)
21977 @end smallexample
21979 The following built-in functions are available when @option{-msse4.1} is
21980 used.
21982 @table @code
21983 @item v4sf __builtin_ia32_vec_set_v4sf (v4sf, float, const int)
21984 Generates the @code{insertps} machine instruction.
21985 @item int __builtin_ia32_vec_ext_v16qi (v16qi, const int)
21986 Generates the @code{pextrb} machine instruction.
21987 @item v16qi __builtin_ia32_vec_set_v16qi (v16qi, int, const int)
21988 Generates the @code{pinsrb} machine instruction.
21989 @item v4si __builtin_ia32_vec_set_v4si (v4si, int, const int)
21990 Generates the @code{pinsrd} machine instruction.
21991 @item v2di __builtin_ia32_vec_set_v2di (v2di, long long, const int)
21992 Generates the @code{pinsrq} machine instruction in 64bit mode.
21993 @end table
21995 The following built-in functions are changed to generate new SSE4.1
21996 instructions when @option{-msse4.1} is used.
21998 @table @code
21999 @item float __builtin_ia32_vec_ext_v4sf (v4sf, const int)
22000 Generates the @code{extractps} machine instruction.
22001 @item int __builtin_ia32_vec_ext_v4si (v4si, const int)
22002 Generates the @code{pextrd} machine instruction.
22003 @item long long __builtin_ia32_vec_ext_v2di (v2di, const int)
22004 Generates the @code{pextrq} machine instruction in 64bit mode.
22005 @end table
22007 The following built-in functions are available when @option{-msse4.2} is
22008 used.  All of them generate the machine instruction that is part of the
22009 name.
22011 @smallexample
22012 v16qi __builtin_ia32_pcmpestrm128 (v16qi, int, v16qi, int, const int)
22013 int __builtin_ia32_pcmpestri128 (v16qi, int, v16qi, int, const int)
22014 int __builtin_ia32_pcmpestria128 (v16qi, int, v16qi, int, const int)
22015 int __builtin_ia32_pcmpestric128 (v16qi, int, v16qi, int, const int)
22016 int __builtin_ia32_pcmpestrio128 (v16qi, int, v16qi, int, const int)
22017 int __builtin_ia32_pcmpestris128 (v16qi, int, v16qi, int, const int)
22018 int __builtin_ia32_pcmpestriz128 (v16qi, int, v16qi, int, const int)
22019 v16qi __builtin_ia32_pcmpistrm128 (v16qi, v16qi, const int)
22020 int __builtin_ia32_pcmpistri128 (v16qi, v16qi, const int)
22021 int __builtin_ia32_pcmpistria128 (v16qi, v16qi, const int)
22022 int __builtin_ia32_pcmpistric128 (v16qi, v16qi, const int)
22023 int __builtin_ia32_pcmpistrio128 (v16qi, v16qi, const int)
22024 int __builtin_ia32_pcmpistris128 (v16qi, v16qi, const int)
22025 int __builtin_ia32_pcmpistriz128 (v16qi, v16qi, const int)
22026 v2di __builtin_ia32_pcmpgtq (v2di, v2di)
22027 @end smallexample
22029 The following built-in functions are available when @option{-msse4.2} is
22030 used.
22032 @table @code
22033 @item unsigned int __builtin_ia32_crc32qi (unsigned int, unsigned char)
22034 Generates the @code{crc32b} machine instruction.
22035 @item unsigned int __builtin_ia32_crc32hi (unsigned int, unsigned short)
22036 Generates the @code{crc32w} machine instruction.
22037 @item unsigned int __builtin_ia32_crc32si (unsigned int, unsigned int)
22038 Generates the @code{crc32l} machine instruction.
22039 @item unsigned long long __builtin_ia32_crc32di (unsigned long long, unsigned long long)
22040 Generates the @code{crc32q} machine instruction.
22041 @end table
22043 The following built-in functions are changed to generate new SSE4.2
22044 instructions when @option{-msse4.2} is used.
22046 @table @code
22047 @item int __builtin_popcount (unsigned int)
22048 Generates the @code{popcntl} machine instruction.
22049 @item int __builtin_popcountl (unsigned long)
22050 Generates the @code{popcntl} or @code{popcntq} machine instruction,
22051 depending on the size of @code{unsigned long}.
22052 @item int __builtin_popcountll (unsigned long long)
22053 Generates the @code{popcntq} machine instruction.
22054 @end table
22056 The following built-in functions are available when @option{-mavx} is
22057 used. All of them generate the machine instruction that is part of the
22058 name.
22060 @smallexample
22061 v4df __builtin_ia32_addpd256 (v4df,v4df)
22062 v8sf __builtin_ia32_addps256 (v8sf,v8sf)
22063 v4df __builtin_ia32_addsubpd256 (v4df,v4df)
22064 v8sf __builtin_ia32_addsubps256 (v8sf,v8sf)
22065 v4df __builtin_ia32_andnpd256 (v4df,v4df)
22066 v8sf __builtin_ia32_andnps256 (v8sf,v8sf)
22067 v4df __builtin_ia32_andpd256 (v4df,v4df)
22068 v8sf __builtin_ia32_andps256 (v8sf,v8sf)
22069 v4df __builtin_ia32_blendpd256 (v4df,v4df,int)
22070 v8sf __builtin_ia32_blendps256 (v8sf,v8sf,int)
22071 v4df __builtin_ia32_blendvpd256 (v4df,v4df,v4df)
22072 v8sf __builtin_ia32_blendvps256 (v8sf,v8sf,v8sf)
22073 v2df __builtin_ia32_cmppd (v2df,v2df,int)
22074 v4df __builtin_ia32_cmppd256 (v4df,v4df,int)
22075 v4sf __builtin_ia32_cmpps (v4sf,v4sf,int)
22076 v8sf __builtin_ia32_cmpps256 (v8sf,v8sf,int)
22077 v2df __builtin_ia32_cmpsd (v2df,v2df,int)
22078 v4sf __builtin_ia32_cmpss (v4sf,v4sf,int)
22079 v4df __builtin_ia32_cvtdq2pd256 (v4si)
22080 v8sf __builtin_ia32_cvtdq2ps256 (v8si)
22081 v4si __builtin_ia32_cvtpd2dq256 (v4df)
22082 v4sf __builtin_ia32_cvtpd2ps256 (v4df)
22083 v8si __builtin_ia32_cvtps2dq256 (v8sf)
22084 v4df __builtin_ia32_cvtps2pd256 (v4sf)
22085 v4si __builtin_ia32_cvttpd2dq256 (v4df)
22086 v8si __builtin_ia32_cvttps2dq256 (v8sf)
22087 v4df __builtin_ia32_divpd256 (v4df,v4df)
22088 v8sf __builtin_ia32_divps256 (v8sf,v8sf)
22089 v8sf __builtin_ia32_dpps256 (v8sf,v8sf,int)
22090 v4df __builtin_ia32_haddpd256 (v4df,v4df)
22091 v8sf __builtin_ia32_haddps256 (v8sf,v8sf)
22092 v4df __builtin_ia32_hsubpd256 (v4df,v4df)
22093 v8sf __builtin_ia32_hsubps256 (v8sf,v8sf)
22094 v32qi __builtin_ia32_lddqu256 (pcchar)
22095 v32qi __builtin_ia32_loaddqu256 (pcchar)
22096 v4df __builtin_ia32_loadupd256 (pcdouble)
22097 v8sf __builtin_ia32_loadups256 (pcfloat)
22098 v2df __builtin_ia32_maskloadpd (pcv2df,v2df)
22099 v4df __builtin_ia32_maskloadpd256 (pcv4df,v4df)
22100 v4sf __builtin_ia32_maskloadps (pcv4sf,v4sf)
22101 v8sf __builtin_ia32_maskloadps256 (pcv8sf,v8sf)
22102 void __builtin_ia32_maskstorepd (pv2df,v2df,v2df)
22103 void __builtin_ia32_maskstorepd256 (pv4df,v4df,v4df)
22104 void __builtin_ia32_maskstoreps (pv4sf,v4sf,v4sf)
22105 void __builtin_ia32_maskstoreps256 (pv8sf,v8sf,v8sf)
22106 v4df __builtin_ia32_maxpd256 (v4df,v4df)
22107 v8sf __builtin_ia32_maxps256 (v8sf,v8sf)
22108 v4df __builtin_ia32_minpd256 (v4df,v4df)
22109 v8sf __builtin_ia32_minps256 (v8sf,v8sf)
22110 v4df __builtin_ia32_movddup256 (v4df)
22111 int __builtin_ia32_movmskpd256 (v4df)
22112 int __builtin_ia32_movmskps256 (v8sf)
22113 v8sf __builtin_ia32_movshdup256 (v8sf)
22114 v8sf __builtin_ia32_movsldup256 (v8sf)
22115 v4df __builtin_ia32_mulpd256 (v4df,v4df)
22116 v8sf __builtin_ia32_mulps256 (v8sf,v8sf)
22117 v4df __builtin_ia32_orpd256 (v4df,v4df)
22118 v8sf __builtin_ia32_orps256 (v8sf,v8sf)
22119 v2df __builtin_ia32_pd_pd256 (v4df)
22120 v4df __builtin_ia32_pd256_pd (v2df)
22121 v4sf __builtin_ia32_ps_ps256 (v8sf)
22122 v8sf __builtin_ia32_ps256_ps (v4sf)
22123 int __builtin_ia32_ptestc256 (v4di,v4di,ptest)
22124 int __builtin_ia32_ptestnzc256 (v4di,v4di,ptest)
22125 int __builtin_ia32_ptestz256 (v4di,v4di,ptest)
22126 v8sf __builtin_ia32_rcpps256 (v8sf)
22127 v4df __builtin_ia32_roundpd256 (v4df,int)
22128 v8sf __builtin_ia32_roundps256 (v8sf,int)
22129 v8sf __builtin_ia32_rsqrtps_nr256 (v8sf)
22130 v8sf __builtin_ia32_rsqrtps256 (v8sf)
22131 v4df __builtin_ia32_shufpd256 (v4df,v4df,int)
22132 v8sf __builtin_ia32_shufps256 (v8sf,v8sf,int)
22133 v4si __builtin_ia32_si_si256 (v8si)
22134 v8si __builtin_ia32_si256_si (v4si)
22135 v4df __builtin_ia32_sqrtpd256 (v4df)
22136 v8sf __builtin_ia32_sqrtps_nr256 (v8sf)
22137 v8sf __builtin_ia32_sqrtps256 (v8sf)
22138 void __builtin_ia32_storedqu256 (pchar,v32qi)
22139 void __builtin_ia32_storeupd256 (pdouble,v4df)
22140 void __builtin_ia32_storeups256 (pfloat,v8sf)
22141 v4df __builtin_ia32_subpd256 (v4df,v4df)
22142 v8sf __builtin_ia32_subps256 (v8sf,v8sf)
22143 v4df __builtin_ia32_unpckhpd256 (v4df,v4df)
22144 v8sf __builtin_ia32_unpckhps256 (v8sf,v8sf)
22145 v4df __builtin_ia32_unpcklpd256 (v4df,v4df)
22146 v8sf __builtin_ia32_unpcklps256 (v8sf,v8sf)
22147 v4df __builtin_ia32_vbroadcastf128_pd256 (pcv2df)
22148 v8sf __builtin_ia32_vbroadcastf128_ps256 (pcv4sf)
22149 v4df __builtin_ia32_vbroadcastsd256 (pcdouble)
22150 v4sf __builtin_ia32_vbroadcastss (pcfloat)
22151 v8sf __builtin_ia32_vbroadcastss256 (pcfloat)
22152 v2df __builtin_ia32_vextractf128_pd256 (v4df,int)
22153 v4sf __builtin_ia32_vextractf128_ps256 (v8sf,int)
22154 v4si __builtin_ia32_vextractf128_si256 (v8si,int)
22155 v4df __builtin_ia32_vinsertf128_pd256 (v4df,v2df,int)
22156 v8sf __builtin_ia32_vinsertf128_ps256 (v8sf,v4sf,int)
22157 v8si __builtin_ia32_vinsertf128_si256 (v8si,v4si,int)
22158 v4df __builtin_ia32_vperm2f128_pd256 (v4df,v4df,int)
22159 v8sf __builtin_ia32_vperm2f128_ps256 (v8sf,v8sf,int)
22160 v8si __builtin_ia32_vperm2f128_si256 (v8si,v8si,int)
22161 v2df __builtin_ia32_vpermil2pd (v2df,v2df,v2di,int)
22162 v4df __builtin_ia32_vpermil2pd256 (v4df,v4df,v4di,int)
22163 v4sf __builtin_ia32_vpermil2ps (v4sf,v4sf,v4si,int)
22164 v8sf __builtin_ia32_vpermil2ps256 (v8sf,v8sf,v8si,int)
22165 v2df __builtin_ia32_vpermilpd (v2df,int)
22166 v4df __builtin_ia32_vpermilpd256 (v4df,int)
22167 v4sf __builtin_ia32_vpermilps (v4sf,int)
22168 v8sf __builtin_ia32_vpermilps256 (v8sf,int)
22169 v2df __builtin_ia32_vpermilvarpd (v2df,v2di)
22170 v4df __builtin_ia32_vpermilvarpd256 (v4df,v4di)
22171 v4sf __builtin_ia32_vpermilvarps (v4sf,v4si)
22172 v8sf __builtin_ia32_vpermilvarps256 (v8sf,v8si)
22173 int __builtin_ia32_vtestcpd (v2df,v2df,ptest)
22174 int __builtin_ia32_vtestcpd256 (v4df,v4df,ptest)
22175 int __builtin_ia32_vtestcps (v4sf,v4sf,ptest)
22176 int __builtin_ia32_vtestcps256 (v8sf,v8sf,ptest)
22177 int __builtin_ia32_vtestnzcpd (v2df,v2df,ptest)
22178 int __builtin_ia32_vtestnzcpd256 (v4df,v4df,ptest)
22179 int __builtin_ia32_vtestnzcps (v4sf,v4sf,ptest)
22180 int __builtin_ia32_vtestnzcps256 (v8sf,v8sf,ptest)
22181 int __builtin_ia32_vtestzpd (v2df,v2df,ptest)
22182 int __builtin_ia32_vtestzpd256 (v4df,v4df,ptest)
22183 int __builtin_ia32_vtestzps (v4sf,v4sf,ptest)
22184 int __builtin_ia32_vtestzps256 (v8sf,v8sf,ptest)
22185 void __builtin_ia32_vzeroall (void)
22186 void __builtin_ia32_vzeroupper (void)
22187 v4df __builtin_ia32_xorpd256 (v4df,v4df)
22188 v8sf __builtin_ia32_xorps256 (v8sf,v8sf)
22189 @end smallexample
22191 The following built-in functions are available when @option{-mavx2} is
22192 used. All of them generate the machine instruction that is part of the
22193 name.
22195 @smallexample
22196 v32qi __builtin_ia32_mpsadbw256 (v32qi,v32qi,int)
22197 v32qi __builtin_ia32_pabsb256 (v32qi)
22198 v16hi __builtin_ia32_pabsw256 (v16hi)
22199 v8si __builtin_ia32_pabsd256 (v8si)
22200 v16hi __builtin_ia32_packssdw256 (v8si,v8si)
22201 v32qi __builtin_ia32_packsswb256 (v16hi,v16hi)
22202 v16hi __builtin_ia32_packusdw256 (v8si,v8si)
22203 v32qi __builtin_ia32_packuswb256 (v16hi,v16hi)
22204 v32qi __builtin_ia32_paddb256 (v32qi,v32qi)
22205 v16hi __builtin_ia32_paddw256 (v16hi,v16hi)
22206 v8si __builtin_ia32_paddd256 (v8si,v8si)
22207 v4di __builtin_ia32_paddq256 (v4di,v4di)
22208 v32qi __builtin_ia32_paddsb256 (v32qi,v32qi)
22209 v16hi __builtin_ia32_paddsw256 (v16hi,v16hi)
22210 v32qi __builtin_ia32_paddusb256 (v32qi,v32qi)
22211 v16hi __builtin_ia32_paddusw256 (v16hi,v16hi)
22212 v4di __builtin_ia32_palignr256 (v4di,v4di,int)
22213 v4di __builtin_ia32_andsi256 (v4di,v4di)
22214 v4di __builtin_ia32_andnotsi256 (v4di,v4di)
22215 v32qi __builtin_ia32_pavgb256 (v32qi,v32qi)
22216 v16hi __builtin_ia32_pavgw256 (v16hi,v16hi)
22217 v32qi __builtin_ia32_pblendvb256 (v32qi,v32qi,v32qi)
22218 v16hi __builtin_ia32_pblendw256 (v16hi,v16hi,int)
22219 v32qi __builtin_ia32_pcmpeqb256 (v32qi,v32qi)
22220 v16hi __builtin_ia32_pcmpeqw256 (v16hi,v16hi)
22221 v8si __builtin_ia32_pcmpeqd256 (c8si,v8si)
22222 v4di __builtin_ia32_pcmpeqq256 (v4di,v4di)
22223 v32qi __builtin_ia32_pcmpgtb256 (v32qi,v32qi)
22224 v16hi __builtin_ia32_pcmpgtw256 (16hi,v16hi)
22225 v8si __builtin_ia32_pcmpgtd256 (v8si,v8si)
22226 v4di __builtin_ia32_pcmpgtq256 (v4di,v4di)
22227 v16hi __builtin_ia32_phaddw256 (v16hi,v16hi)
22228 v8si __builtin_ia32_phaddd256 (v8si,v8si)
22229 v16hi __builtin_ia32_phaddsw256 (v16hi,v16hi)
22230 v16hi __builtin_ia32_phsubw256 (v16hi,v16hi)
22231 v8si __builtin_ia32_phsubd256 (v8si,v8si)
22232 v16hi __builtin_ia32_phsubsw256 (v16hi,v16hi)
22233 v32qi __builtin_ia32_pmaddubsw256 (v32qi,v32qi)
22234 v16hi __builtin_ia32_pmaddwd256 (v16hi,v16hi)
22235 v32qi __builtin_ia32_pmaxsb256 (v32qi,v32qi)
22236 v16hi __builtin_ia32_pmaxsw256 (v16hi,v16hi)
22237 v8si __builtin_ia32_pmaxsd256 (v8si,v8si)
22238 v32qi __builtin_ia32_pmaxub256 (v32qi,v32qi)
22239 v16hi __builtin_ia32_pmaxuw256 (v16hi,v16hi)
22240 v8si __builtin_ia32_pmaxud256 (v8si,v8si)
22241 v32qi __builtin_ia32_pminsb256 (v32qi,v32qi)
22242 v16hi __builtin_ia32_pminsw256 (v16hi,v16hi)
22243 v8si __builtin_ia32_pminsd256 (v8si,v8si)
22244 v32qi __builtin_ia32_pminub256 (v32qi,v32qi)
22245 v16hi __builtin_ia32_pminuw256 (v16hi,v16hi)
22246 v8si __builtin_ia32_pminud256 (v8si,v8si)
22247 int __builtin_ia32_pmovmskb256 (v32qi)
22248 v16hi __builtin_ia32_pmovsxbw256 (v16qi)
22249 v8si __builtin_ia32_pmovsxbd256 (v16qi)
22250 v4di __builtin_ia32_pmovsxbq256 (v16qi)
22251 v8si __builtin_ia32_pmovsxwd256 (v8hi)
22252 v4di __builtin_ia32_pmovsxwq256 (v8hi)
22253 v4di __builtin_ia32_pmovsxdq256 (v4si)
22254 v16hi __builtin_ia32_pmovzxbw256 (v16qi)
22255 v8si __builtin_ia32_pmovzxbd256 (v16qi)
22256 v4di __builtin_ia32_pmovzxbq256 (v16qi)
22257 v8si __builtin_ia32_pmovzxwd256 (v8hi)
22258 v4di __builtin_ia32_pmovzxwq256 (v8hi)
22259 v4di __builtin_ia32_pmovzxdq256 (v4si)
22260 v4di __builtin_ia32_pmuldq256 (v8si,v8si)
22261 v16hi __builtin_ia32_pmulhrsw256 (v16hi, v16hi)
22262 v16hi __builtin_ia32_pmulhuw256 (v16hi,v16hi)
22263 v16hi __builtin_ia32_pmulhw256 (v16hi,v16hi)
22264 v16hi __builtin_ia32_pmullw256 (v16hi,v16hi)
22265 v8si __builtin_ia32_pmulld256 (v8si,v8si)
22266 v4di __builtin_ia32_pmuludq256 (v8si,v8si)
22267 v4di __builtin_ia32_por256 (v4di,v4di)
22268 v16hi __builtin_ia32_psadbw256 (v32qi,v32qi)
22269 v32qi __builtin_ia32_pshufb256 (v32qi,v32qi)
22270 v8si __builtin_ia32_pshufd256 (v8si,int)
22271 v16hi __builtin_ia32_pshufhw256 (v16hi,int)
22272 v16hi __builtin_ia32_pshuflw256 (v16hi,int)
22273 v32qi __builtin_ia32_psignb256 (v32qi,v32qi)
22274 v16hi __builtin_ia32_psignw256 (v16hi,v16hi)
22275 v8si __builtin_ia32_psignd256 (v8si,v8si)
22276 v4di __builtin_ia32_pslldqi256 (v4di,int)
22277 v16hi __builtin_ia32_psllwi256 (16hi,int)
22278 v16hi __builtin_ia32_psllw256(v16hi,v8hi)
22279 v8si __builtin_ia32_pslldi256 (v8si,int)
22280 v8si __builtin_ia32_pslld256(v8si,v4si)
22281 v4di __builtin_ia32_psllqi256 (v4di,int)
22282 v4di __builtin_ia32_psllq256(v4di,v2di)
22283 v16hi __builtin_ia32_psrawi256 (v16hi,int)
22284 v16hi __builtin_ia32_psraw256 (v16hi,v8hi)
22285 v8si __builtin_ia32_psradi256 (v8si,int)
22286 v8si __builtin_ia32_psrad256 (v8si,v4si)
22287 v4di __builtin_ia32_psrldqi256 (v4di, int)
22288 v16hi __builtin_ia32_psrlwi256 (v16hi,int)
22289 v16hi __builtin_ia32_psrlw256 (v16hi,v8hi)
22290 v8si __builtin_ia32_psrldi256 (v8si,int)
22291 v8si __builtin_ia32_psrld256 (v8si,v4si)
22292 v4di __builtin_ia32_psrlqi256 (v4di,int)
22293 v4di __builtin_ia32_psrlq256(v4di,v2di)
22294 v32qi __builtin_ia32_psubb256 (v32qi,v32qi)
22295 v32hi __builtin_ia32_psubw256 (v16hi,v16hi)
22296 v8si __builtin_ia32_psubd256 (v8si,v8si)
22297 v4di __builtin_ia32_psubq256 (v4di,v4di)
22298 v32qi __builtin_ia32_psubsb256 (v32qi,v32qi)
22299 v16hi __builtin_ia32_psubsw256 (v16hi,v16hi)
22300 v32qi __builtin_ia32_psubusb256 (v32qi,v32qi)
22301 v16hi __builtin_ia32_psubusw256 (v16hi,v16hi)
22302 v32qi __builtin_ia32_punpckhbw256 (v32qi,v32qi)
22303 v16hi __builtin_ia32_punpckhwd256 (v16hi,v16hi)
22304 v8si __builtin_ia32_punpckhdq256 (v8si,v8si)
22305 v4di __builtin_ia32_punpckhqdq256 (v4di,v4di)
22306 v32qi __builtin_ia32_punpcklbw256 (v32qi,v32qi)
22307 v16hi __builtin_ia32_punpcklwd256 (v16hi,v16hi)
22308 v8si __builtin_ia32_punpckldq256 (v8si,v8si)
22309 v4di __builtin_ia32_punpcklqdq256 (v4di,v4di)
22310 v4di __builtin_ia32_pxor256 (v4di,v4di)
22311 v4di __builtin_ia32_movntdqa256 (pv4di)
22312 v4sf __builtin_ia32_vbroadcastss_ps (v4sf)
22313 v8sf __builtin_ia32_vbroadcastss_ps256 (v4sf)
22314 v4df __builtin_ia32_vbroadcastsd_pd256 (v2df)
22315 v4di __builtin_ia32_vbroadcastsi256 (v2di)
22316 v4si __builtin_ia32_pblendd128 (v4si,v4si)
22317 v8si __builtin_ia32_pblendd256 (v8si,v8si)
22318 v32qi __builtin_ia32_pbroadcastb256 (v16qi)
22319 v16hi __builtin_ia32_pbroadcastw256 (v8hi)
22320 v8si __builtin_ia32_pbroadcastd256 (v4si)
22321 v4di __builtin_ia32_pbroadcastq256 (v2di)
22322 v16qi __builtin_ia32_pbroadcastb128 (v16qi)
22323 v8hi __builtin_ia32_pbroadcastw128 (v8hi)
22324 v4si __builtin_ia32_pbroadcastd128 (v4si)
22325 v2di __builtin_ia32_pbroadcastq128 (v2di)
22326 v8si __builtin_ia32_permvarsi256 (v8si,v8si)
22327 v4df __builtin_ia32_permdf256 (v4df,int)
22328 v8sf __builtin_ia32_permvarsf256 (v8sf,v8sf)
22329 v4di __builtin_ia32_permdi256 (v4di,int)
22330 v4di __builtin_ia32_permti256 (v4di,v4di,int)
22331 v4di __builtin_ia32_extract128i256 (v4di,int)
22332 v4di __builtin_ia32_insert128i256 (v4di,v2di,int)
22333 v8si __builtin_ia32_maskloadd256 (pcv8si,v8si)
22334 v4di __builtin_ia32_maskloadq256 (pcv4di,v4di)
22335 v4si __builtin_ia32_maskloadd (pcv4si,v4si)
22336 v2di __builtin_ia32_maskloadq (pcv2di,v2di)
22337 void __builtin_ia32_maskstored256 (pv8si,v8si,v8si)
22338 void __builtin_ia32_maskstoreq256 (pv4di,v4di,v4di)
22339 void __builtin_ia32_maskstored (pv4si,v4si,v4si)
22340 void __builtin_ia32_maskstoreq (pv2di,v2di,v2di)
22341 v8si __builtin_ia32_psllv8si (v8si,v8si)
22342 v4si __builtin_ia32_psllv4si (v4si,v4si)
22343 v4di __builtin_ia32_psllv4di (v4di,v4di)
22344 v2di __builtin_ia32_psllv2di (v2di,v2di)
22345 v8si __builtin_ia32_psrav8si (v8si,v8si)
22346 v4si __builtin_ia32_psrav4si (v4si,v4si)
22347 v8si __builtin_ia32_psrlv8si (v8si,v8si)
22348 v4si __builtin_ia32_psrlv4si (v4si,v4si)
22349 v4di __builtin_ia32_psrlv4di (v4di,v4di)
22350 v2di __builtin_ia32_psrlv2di (v2di,v2di)
22351 v2df __builtin_ia32_gathersiv2df (v2df, pcdouble,v4si,v2df,int)
22352 v4df __builtin_ia32_gathersiv4df (v4df, pcdouble,v4si,v4df,int)
22353 v2df __builtin_ia32_gatherdiv2df (v2df, pcdouble,v2di,v2df,int)
22354 v4df __builtin_ia32_gatherdiv4df (v4df, pcdouble,v4di,v4df,int)
22355 v4sf __builtin_ia32_gathersiv4sf (v4sf, pcfloat,v4si,v4sf,int)
22356 v8sf __builtin_ia32_gathersiv8sf (v8sf, pcfloat,v8si,v8sf,int)
22357 v4sf __builtin_ia32_gatherdiv4sf (v4sf, pcfloat,v2di,v4sf,int)
22358 v4sf __builtin_ia32_gatherdiv4sf256 (v4sf, pcfloat,v4di,v4sf,int)
22359 v2di __builtin_ia32_gathersiv2di (v2di, pcint64,v4si,v2di,int)
22360 v4di __builtin_ia32_gathersiv4di (v4di, pcint64,v4si,v4di,int)
22361 v2di __builtin_ia32_gatherdiv2di (v2di, pcint64,v2di,v2di,int)
22362 v4di __builtin_ia32_gatherdiv4di (v4di, pcint64,v4di,v4di,int)
22363 v4si __builtin_ia32_gathersiv4si (v4si, pcint,v4si,v4si,int)
22364 v8si __builtin_ia32_gathersiv8si (v8si, pcint,v8si,v8si,int)
22365 v4si __builtin_ia32_gatherdiv4si (v4si, pcint,v2di,v4si,int)
22366 v4si __builtin_ia32_gatherdiv4si256 (v4si, pcint,v4di,v4si,int)
22367 @end smallexample
22369 The following built-in functions are available when @option{-maes} is
22370 used.  All of them generate the machine instruction that is part of the
22371 name.
22373 @smallexample
22374 v2di __builtin_ia32_aesenc128 (v2di, v2di)
22375 v2di __builtin_ia32_aesenclast128 (v2di, v2di)
22376 v2di __builtin_ia32_aesdec128 (v2di, v2di)
22377 v2di __builtin_ia32_aesdeclast128 (v2di, v2di)
22378 v2di __builtin_ia32_aeskeygenassist128 (v2di, const int)
22379 v2di __builtin_ia32_aesimc128 (v2di)
22380 @end smallexample
22382 The following built-in function is available when @option{-mpclmul} is
22383 used.
22385 @table @code
22386 @item v2di __builtin_ia32_pclmulqdq128 (v2di, v2di, const int)
22387 Generates the @code{pclmulqdq} machine instruction.
22388 @end table
22390 The following built-in function is available when @option{-mfsgsbase} is
22391 used.  All of them generate the machine instruction that is part of the
22392 name.
22394 @smallexample
22395 unsigned int __builtin_ia32_rdfsbase32 (void)
22396 unsigned long long __builtin_ia32_rdfsbase64 (void)
22397 unsigned int __builtin_ia32_rdgsbase32 (void)
22398 unsigned long long __builtin_ia32_rdgsbase64 (void)
22399 void _writefsbase_u32 (unsigned int)
22400 void _writefsbase_u64 (unsigned long long)
22401 void _writegsbase_u32 (unsigned int)
22402 void _writegsbase_u64 (unsigned long long)
22403 @end smallexample
22405 The following built-in function is available when @option{-mrdrnd} is
22406 used.  All of them generate the machine instruction that is part of the
22407 name.
22409 @smallexample
22410 unsigned int __builtin_ia32_rdrand16_step (unsigned short *)
22411 unsigned int __builtin_ia32_rdrand32_step (unsigned int *)
22412 unsigned int __builtin_ia32_rdrand64_step (unsigned long long *)
22413 @end smallexample
22415 The following built-in function is available when @option{-mptwrite} is
22416 used.  All of them generate the machine instruction that is part of the
22417 name.
22419 @smallexample
22420 void __builtin_ia32_ptwrite32 (unsigned)
22421 void __builtin_ia32_ptwrite64 (unsigned long long)
22422 @end smallexample
22424 The following built-in functions are available when @option{-msse4a} is used.
22425 All of them generate the machine instruction that is part of the name.
22427 @smallexample
22428 void __builtin_ia32_movntsd (double *, v2df)
22429 void __builtin_ia32_movntss (float *, v4sf)
22430 v2di __builtin_ia32_extrq  (v2di, v16qi)
22431 v2di __builtin_ia32_extrqi (v2di, const unsigned int, const unsigned int)
22432 v2di __builtin_ia32_insertq (v2di, v2di)
22433 v2di __builtin_ia32_insertqi (v2di, v2di, const unsigned int, const unsigned int)
22434 @end smallexample
22436 The following built-in functions are available when @option{-mxop} is used.
22437 @smallexample
22438 v2df __builtin_ia32_vfrczpd (v2df)
22439 v4sf __builtin_ia32_vfrczps (v4sf)
22440 v2df __builtin_ia32_vfrczsd (v2df)
22441 v4sf __builtin_ia32_vfrczss (v4sf)
22442 v4df __builtin_ia32_vfrczpd256 (v4df)
22443 v8sf __builtin_ia32_vfrczps256 (v8sf)
22444 v2di __builtin_ia32_vpcmov (v2di, v2di, v2di)
22445 v2di __builtin_ia32_vpcmov_v2di (v2di, v2di, v2di)
22446 v4si __builtin_ia32_vpcmov_v4si (v4si, v4si, v4si)
22447 v8hi __builtin_ia32_vpcmov_v8hi (v8hi, v8hi, v8hi)
22448 v16qi __builtin_ia32_vpcmov_v16qi (v16qi, v16qi, v16qi)
22449 v2df __builtin_ia32_vpcmov_v2df (v2df, v2df, v2df)
22450 v4sf __builtin_ia32_vpcmov_v4sf (v4sf, v4sf, v4sf)
22451 v4di __builtin_ia32_vpcmov_v4di256 (v4di, v4di, v4di)
22452 v8si __builtin_ia32_vpcmov_v8si256 (v8si, v8si, v8si)
22453 v16hi __builtin_ia32_vpcmov_v16hi256 (v16hi, v16hi, v16hi)
22454 v32qi __builtin_ia32_vpcmov_v32qi256 (v32qi, v32qi, v32qi)
22455 v4df __builtin_ia32_vpcmov_v4df256 (v4df, v4df, v4df)
22456 v8sf __builtin_ia32_vpcmov_v8sf256 (v8sf, v8sf, v8sf)
22457 v16qi __builtin_ia32_vpcomeqb (v16qi, v16qi)
22458 v8hi __builtin_ia32_vpcomeqw (v8hi, v8hi)
22459 v4si __builtin_ia32_vpcomeqd (v4si, v4si)
22460 v2di __builtin_ia32_vpcomeqq (v2di, v2di)
22461 v16qi __builtin_ia32_vpcomequb (v16qi, v16qi)
22462 v4si __builtin_ia32_vpcomequd (v4si, v4si)
22463 v2di __builtin_ia32_vpcomequq (v2di, v2di)
22464 v8hi __builtin_ia32_vpcomequw (v8hi, v8hi)
22465 v8hi __builtin_ia32_vpcomeqw (v8hi, v8hi)
22466 v16qi __builtin_ia32_vpcomfalseb (v16qi, v16qi)
22467 v4si __builtin_ia32_vpcomfalsed (v4si, v4si)
22468 v2di __builtin_ia32_vpcomfalseq (v2di, v2di)
22469 v16qi __builtin_ia32_vpcomfalseub (v16qi, v16qi)
22470 v4si __builtin_ia32_vpcomfalseud (v4si, v4si)
22471 v2di __builtin_ia32_vpcomfalseuq (v2di, v2di)
22472 v8hi __builtin_ia32_vpcomfalseuw (v8hi, v8hi)
22473 v8hi __builtin_ia32_vpcomfalsew (v8hi, v8hi)
22474 v16qi __builtin_ia32_vpcomgeb (v16qi, v16qi)
22475 v4si __builtin_ia32_vpcomged (v4si, v4si)
22476 v2di __builtin_ia32_vpcomgeq (v2di, v2di)
22477 v16qi __builtin_ia32_vpcomgeub (v16qi, v16qi)
22478 v4si __builtin_ia32_vpcomgeud (v4si, v4si)
22479 v2di __builtin_ia32_vpcomgeuq (v2di, v2di)
22480 v8hi __builtin_ia32_vpcomgeuw (v8hi, v8hi)
22481 v8hi __builtin_ia32_vpcomgew (v8hi, v8hi)
22482 v16qi __builtin_ia32_vpcomgtb (v16qi, v16qi)
22483 v4si __builtin_ia32_vpcomgtd (v4si, v4si)
22484 v2di __builtin_ia32_vpcomgtq (v2di, v2di)
22485 v16qi __builtin_ia32_vpcomgtub (v16qi, v16qi)
22486 v4si __builtin_ia32_vpcomgtud (v4si, v4si)
22487 v2di __builtin_ia32_vpcomgtuq (v2di, v2di)
22488 v8hi __builtin_ia32_vpcomgtuw (v8hi, v8hi)
22489 v8hi __builtin_ia32_vpcomgtw (v8hi, v8hi)
22490 v16qi __builtin_ia32_vpcomleb (v16qi, v16qi)
22491 v4si __builtin_ia32_vpcomled (v4si, v4si)
22492 v2di __builtin_ia32_vpcomleq (v2di, v2di)
22493 v16qi __builtin_ia32_vpcomleub (v16qi, v16qi)
22494 v4si __builtin_ia32_vpcomleud (v4si, v4si)
22495 v2di __builtin_ia32_vpcomleuq (v2di, v2di)
22496 v8hi __builtin_ia32_vpcomleuw (v8hi, v8hi)
22497 v8hi __builtin_ia32_vpcomlew (v8hi, v8hi)
22498 v16qi __builtin_ia32_vpcomltb (v16qi, v16qi)
22499 v4si __builtin_ia32_vpcomltd (v4si, v4si)
22500 v2di __builtin_ia32_vpcomltq (v2di, v2di)
22501 v16qi __builtin_ia32_vpcomltub (v16qi, v16qi)
22502 v4si __builtin_ia32_vpcomltud (v4si, v4si)
22503 v2di __builtin_ia32_vpcomltuq (v2di, v2di)
22504 v8hi __builtin_ia32_vpcomltuw (v8hi, v8hi)
22505 v8hi __builtin_ia32_vpcomltw (v8hi, v8hi)
22506 v16qi __builtin_ia32_vpcomneb (v16qi, v16qi)
22507 v4si __builtin_ia32_vpcomned (v4si, v4si)
22508 v2di __builtin_ia32_vpcomneq (v2di, v2di)
22509 v16qi __builtin_ia32_vpcomneub (v16qi, v16qi)
22510 v4si __builtin_ia32_vpcomneud (v4si, v4si)
22511 v2di __builtin_ia32_vpcomneuq (v2di, v2di)
22512 v8hi __builtin_ia32_vpcomneuw (v8hi, v8hi)
22513 v8hi __builtin_ia32_vpcomnew (v8hi, v8hi)
22514 v16qi __builtin_ia32_vpcomtrueb (v16qi, v16qi)
22515 v4si __builtin_ia32_vpcomtrued (v4si, v4si)
22516 v2di __builtin_ia32_vpcomtrueq (v2di, v2di)
22517 v16qi __builtin_ia32_vpcomtrueub (v16qi, v16qi)
22518 v4si __builtin_ia32_vpcomtrueud (v4si, v4si)
22519 v2di __builtin_ia32_vpcomtrueuq (v2di, v2di)
22520 v8hi __builtin_ia32_vpcomtrueuw (v8hi, v8hi)
22521 v8hi __builtin_ia32_vpcomtruew (v8hi, v8hi)
22522 v4si __builtin_ia32_vphaddbd (v16qi)
22523 v2di __builtin_ia32_vphaddbq (v16qi)
22524 v8hi __builtin_ia32_vphaddbw (v16qi)
22525 v2di __builtin_ia32_vphadddq (v4si)
22526 v4si __builtin_ia32_vphaddubd (v16qi)
22527 v2di __builtin_ia32_vphaddubq (v16qi)
22528 v8hi __builtin_ia32_vphaddubw (v16qi)
22529 v2di __builtin_ia32_vphaddudq (v4si)
22530 v4si __builtin_ia32_vphadduwd (v8hi)
22531 v2di __builtin_ia32_vphadduwq (v8hi)
22532 v4si __builtin_ia32_vphaddwd (v8hi)
22533 v2di __builtin_ia32_vphaddwq (v8hi)
22534 v8hi __builtin_ia32_vphsubbw (v16qi)
22535 v2di __builtin_ia32_vphsubdq (v4si)
22536 v4si __builtin_ia32_vphsubwd (v8hi)
22537 v4si __builtin_ia32_vpmacsdd (v4si, v4si, v4si)
22538 v2di __builtin_ia32_vpmacsdqh (v4si, v4si, v2di)
22539 v2di __builtin_ia32_vpmacsdql (v4si, v4si, v2di)
22540 v4si __builtin_ia32_vpmacssdd (v4si, v4si, v4si)
22541 v2di __builtin_ia32_vpmacssdqh (v4si, v4si, v2di)
22542 v2di __builtin_ia32_vpmacssdql (v4si, v4si, v2di)
22543 v4si __builtin_ia32_vpmacsswd (v8hi, v8hi, v4si)
22544 v8hi __builtin_ia32_vpmacssww (v8hi, v8hi, v8hi)
22545 v4si __builtin_ia32_vpmacswd (v8hi, v8hi, v4si)
22546 v8hi __builtin_ia32_vpmacsww (v8hi, v8hi, v8hi)
22547 v4si __builtin_ia32_vpmadcsswd (v8hi, v8hi, v4si)
22548 v4si __builtin_ia32_vpmadcswd (v8hi, v8hi, v4si)
22549 v16qi __builtin_ia32_vpperm (v16qi, v16qi, v16qi)
22550 v16qi __builtin_ia32_vprotb (v16qi, v16qi)
22551 v4si __builtin_ia32_vprotd (v4si, v4si)
22552 v2di __builtin_ia32_vprotq (v2di, v2di)
22553 v8hi __builtin_ia32_vprotw (v8hi, v8hi)
22554 v16qi __builtin_ia32_vpshab (v16qi, v16qi)
22555 v4si __builtin_ia32_vpshad (v4si, v4si)
22556 v2di __builtin_ia32_vpshaq (v2di, v2di)
22557 v8hi __builtin_ia32_vpshaw (v8hi, v8hi)
22558 v16qi __builtin_ia32_vpshlb (v16qi, v16qi)
22559 v4si __builtin_ia32_vpshld (v4si, v4si)
22560 v2di __builtin_ia32_vpshlq (v2di, v2di)
22561 v8hi __builtin_ia32_vpshlw (v8hi, v8hi)
22562 @end smallexample
22564 The following built-in functions are available when @option{-mfma4} is used.
22565 All of them generate the machine instruction that is part of the name.
22567 @smallexample
22568 v2df __builtin_ia32_vfmaddpd (v2df, v2df, v2df)
22569 v4sf __builtin_ia32_vfmaddps (v4sf, v4sf, v4sf)
22570 v2df __builtin_ia32_vfmaddsd (v2df, v2df, v2df)
22571 v4sf __builtin_ia32_vfmaddss (v4sf, v4sf, v4sf)
22572 v2df __builtin_ia32_vfmsubpd (v2df, v2df, v2df)
22573 v4sf __builtin_ia32_vfmsubps (v4sf, v4sf, v4sf)
22574 v2df __builtin_ia32_vfmsubsd (v2df, v2df, v2df)
22575 v4sf __builtin_ia32_vfmsubss (v4sf, v4sf, v4sf)
22576 v2df __builtin_ia32_vfnmaddpd (v2df, v2df, v2df)
22577 v4sf __builtin_ia32_vfnmaddps (v4sf, v4sf, v4sf)
22578 v2df __builtin_ia32_vfnmaddsd (v2df, v2df, v2df)
22579 v4sf __builtin_ia32_vfnmaddss (v4sf, v4sf, v4sf)
22580 v2df __builtin_ia32_vfnmsubpd (v2df, v2df, v2df)
22581 v4sf __builtin_ia32_vfnmsubps (v4sf, v4sf, v4sf)
22582 v2df __builtin_ia32_vfnmsubsd (v2df, v2df, v2df)
22583 v4sf __builtin_ia32_vfnmsubss (v4sf, v4sf, v4sf)
22584 v2df __builtin_ia32_vfmaddsubpd  (v2df, v2df, v2df)
22585 v4sf __builtin_ia32_vfmaddsubps  (v4sf, v4sf, v4sf)
22586 v2df __builtin_ia32_vfmsubaddpd  (v2df, v2df, v2df)
22587 v4sf __builtin_ia32_vfmsubaddps  (v4sf, v4sf, v4sf)
22588 v4df __builtin_ia32_vfmaddpd256 (v4df, v4df, v4df)
22589 v8sf __builtin_ia32_vfmaddps256 (v8sf, v8sf, v8sf)
22590 v4df __builtin_ia32_vfmsubpd256 (v4df, v4df, v4df)
22591 v8sf __builtin_ia32_vfmsubps256 (v8sf, v8sf, v8sf)
22592 v4df __builtin_ia32_vfnmaddpd256 (v4df, v4df, v4df)
22593 v8sf __builtin_ia32_vfnmaddps256 (v8sf, v8sf, v8sf)
22594 v4df __builtin_ia32_vfnmsubpd256 (v4df, v4df, v4df)
22595 v8sf __builtin_ia32_vfnmsubps256 (v8sf, v8sf, v8sf)
22596 v4df __builtin_ia32_vfmaddsubpd256 (v4df, v4df, v4df)
22597 v8sf __builtin_ia32_vfmaddsubps256 (v8sf, v8sf, v8sf)
22598 v4df __builtin_ia32_vfmsubaddpd256 (v4df, v4df, v4df)
22599 v8sf __builtin_ia32_vfmsubaddps256 (v8sf, v8sf, v8sf)
22601 @end smallexample
22603 The following built-in functions are available when @option{-mlwp} is used.
22605 @smallexample
22606 void __builtin_ia32_llwpcb16 (void *);
22607 void __builtin_ia32_llwpcb32 (void *);
22608 void __builtin_ia32_llwpcb64 (void *);
22609 void * __builtin_ia32_llwpcb16 (void);
22610 void * __builtin_ia32_llwpcb32 (void);
22611 void * __builtin_ia32_llwpcb64 (void);
22612 void __builtin_ia32_lwpval16 (unsigned short, unsigned int, unsigned short)
22613 void __builtin_ia32_lwpval32 (unsigned int, unsigned int, unsigned int)
22614 void __builtin_ia32_lwpval64 (unsigned __int64, unsigned int, unsigned int)
22615 unsigned char __builtin_ia32_lwpins16 (unsigned short, unsigned int, unsigned short)
22616 unsigned char __builtin_ia32_lwpins32 (unsigned int, unsigned int, unsigned int)
22617 unsigned char __builtin_ia32_lwpins64 (unsigned __int64, unsigned int, unsigned int)
22618 @end smallexample
22620 The following built-in functions are available when @option{-mbmi} is used.
22621 All of them generate the machine instruction that is part of the name.
22622 @smallexample
22623 unsigned int __builtin_ia32_bextr_u32(unsigned int, unsigned int);
22624 unsigned long long __builtin_ia32_bextr_u64 (unsigned long long, unsigned long long);
22625 @end smallexample
22627 The following built-in functions are available when @option{-mbmi2} is used.
22628 All of them generate the machine instruction that is part of the name.
22629 @smallexample
22630 unsigned int _bzhi_u32 (unsigned int, unsigned int)
22631 unsigned int _pdep_u32 (unsigned int, unsigned int)
22632 unsigned int _pext_u32 (unsigned int, unsigned int)
22633 unsigned long long _bzhi_u64 (unsigned long long, unsigned long long)
22634 unsigned long long _pdep_u64 (unsigned long long, unsigned long long)
22635 unsigned long long _pext_u64 (unsigned long long, unsigned long long)
22636 @end smallexample
22638 The following built-in functions are available when @option{-mlzcnt} is used.
22639 All of them generate the machine instruction that is part of the name.
22640 @smallexample
22641 unsigned short __builtin_ia32_lzcnt_u16(unsigned short);
22642 unsigned int __builtin_ia32_lzcnt_u32(unsigned int);
22643 unsigned long long __builtin_ia32_lzcnt_u64 (unsigned long long);
22644 @end smallexample
22646 The following built-in functions are available when @option{-mfxsr} is used.
22647 All of them generate the machine instruction that is part of the name.
22648 @smallexample
22649 void __builtin_ia32_fxsave (void *)
22650 void __builtin_ia32_fxrstor (void *)
22651 void __builtin_ia32_fxsave64 (void *)
22652 void __builtin_ia32_fxrstor64 (void *)
22653 @end smallexample
22655 The following built-in functions are available when @option{-mxsave} is used.
22656 All of them generate the machine instruction that is part of the name.
22657 @smallexample
22658 void __builtin_ia32_xsave (void *, long long)
22659 void __builtin_ia32_xrstor (void *, long long)
22660 void __builtin_ia32_xsave64 (void *, long long)
22661 void __builtin_ia32_xrstor64 (void *, long long)
22662 @end smallexample
22664 The following built-in functions are available when @option{-mxsaveopt} is used.
22665 All of them generate the machine instruction that is part of the name.
22666 @smallexample
22667 void __builtin_ia32_xsaveopt (void *, long long)
22668 void __builtin_ia32_xsaveopt64 (void *, long long)
22669 @end smallexample
22671 The following built-in functions are available when @option{-mtbm} is used.
22672 Both of them generate the immediate form of the bextr machine instruction.
22673 @smallexample
22674 unsigned int __builtin_ia32_bextri_u32 (unsigned int,
22675                                         const unsigned int);
22676 unsigned long long __builtin_ia32_bextri_u64 (unsigned long long,
22677                                               const unsigned long long);
22678 @end smallexample
22681 The following built-in functions are available when @option{-m3dnow} is used.
22682 All of them generate the machine instruction that is part of the name.
22684 @smallexample
22685 void __builtin_ia32_femms (void)
22686 v8qi __builtin_ia32_pavgusb (v8qi, v8qi)
22687 v2si __builtin_ia32_pf2id (v2sf)
22688 v2sf __builtin_ia32_pfacc (v2sf, v2sf)
22689 v2sf __builtin_ia32_pfadd (v2sf, v2sf)
22690 v2si __builtin_ia32_pfcmpeq (v2sf, v2sf)
22691 v2si __builtin_ia32_pfcmpge (v2sf, v2sf)
22692 v2si __builtin_ia32_pfcmpgt (v2sf, v2sf)
22693 v2sf __builtin_ia32_pfmax (v2sf, v2sf)
22694 v2sf __builtin_ia32_pfmin (v2sf, v2sf)
22695 v2sf __builtin_ia32_pfmul (v2sf, v2sf)
22696 v2sf __builtin_ia32_pfrcp (v2sf)
22697 v2sf __builtin_ia32_pfrcpit1 (v2sf, v2sf)
22698 v2sf __builtin_ia32_pfrcpit2 (v2sf, v2sf)
22699 v2sf __builtin_ia32_pfrsqrt (v2sf)
22700 v2sf __builtin_ia32_pfsub (v2sf, v2sf)
22701 v2sf __builtin_ia32_pfsubr (v2sf, v2sf)
22702 v2sf __builtin_ia32_pi2fd (v2si)
22703 v4hi __builtin_ia32_pmulhrw (v4hi, v4hi)
22704 @end smallexample
22706 The following built-in functions are available when @option{-m3dnowa} is used.
22707 All of them generate the machine instruction that is part of the name.
22709 @smallexample
22710 v2si __builtin_ia32_pf2iw (v2sf)
22711 v2sf __builtin_ia32_pfnacc (v2sf, v2sf)
22712 v2sf __builtin_ia32_pfpnacc (v2sf, v2sf)
22713 v2sf __builtin_ia32_pi2fw (v2si)
22714 v2sf __builtin_ia32_pswapdsf (v2sf)
22715 v2si __builtin_ia32_pswapdsi (v2si)
22716 @end smallexample
22718 The following built-in functions are available when @option{-mrtm} is used
22719 They are used for restricted transactional memory. These are the internal
22720 low level functions. Normally the functions in 
22721 @ref{x86 transactional memory intrinsics} should be used instead.
22723 @smallexample
22724 int __builtin_ia32_xbegin ()
22725 void __builtin_ia32_xend ()
22726 void __builtin_ia32_xabort (status)
22727 int __builtin_ia32_xtest ()
22728 @end smallexample
22730 The following built-in functions are available when @option{-mmwaitx} is used.
22731 All of them generate the machine instruction that is part of the name.
22732 @smallexample
22733 void __builtin_ia32_monitorx (void *, unsigned int, unsigned int)
22734 void __builtin_ia32_mwaitx (unsigned int, unsigned int, unsigned int)
22735 @end smallexample
22737 The following built-in functions are available when @option{-mclzero} is used.
22738 All of them generate the machine instruction that is part of the name.
22739 @smallexample
22740 void __builtin_i32_clzero (void *)
22741 @end smallexample
22743 The following built-in functions are available when @option{-mpku} is used.
22744 They generate reads and writes to PKRU.
22745 @smallexample
22746 void __builtin_ia32_wrpkru (unsigned int)
22747 unsigned int __builtin_ia32_rdpkru ()
22748 @end smallexample
22750 The following built-in functions are available when @option{-mcet} or
22751 @option{-mshstk} option is used.  They support shadow stack
22752 machine instructions from Intel Control-flow Enforcement Technology (CET).
22753 Each built-in function generates the  machine instruction that is part
22754 of the function's name.  These are the internal low-level functions.
22755 Normally the functions in @ref{x86 control-flow protection intrinsics}
22756 should be used instead.
22758 @smallexample
22759 unsigned int __builtin_ia32_rdsspd (void)
22760 unsigned long long __builtin_ia32_rdsspq (void)
22761 void __builtin_ia32_incsspd (unsigned int)
22762 void __builtin_ia32_incsspq (unsigned long long)
22763 void __builtin_ia32_saveprevssp(void);
22764 void __builtin_ia32_rstorssp(void *);
22765 void __builtin_ia32_wrssd(unsigned int, void *);
22766 void __builtin_ia32_wrssq(unsigned long long, void *);
22767 void __builtin_ia32_wrussd(unsigned int, void *);
22768 void __builtin_ia32_wrussq(unsigned long long, void *);
22769 void __builtin_ia32_setssbsy(void);
22770 void __builtin_ia32_clrssbsy(void *);
22771 @end smallexample
22773 @node x86 transactional memory intrinsics
22774 @subsection x86 Transactional Memory Intrinsics
22776 These hardware transactional memory intrinsics for x86 allow you to use
22777 memory transactions with RTM (Restricted Transactional Memory).
22778 This support is enabled with the @option{-mrtm} option.
22779 For using HLE (Hardware Lock Elision) see 
22780 @ref{x86 specific memory model extensions for transactional memory} instead.
22782 A memory transaction commits all changes to memory in an atomic way,
22783 as visible to other threads. If the transaction fails it is rolled back
22784 and all side effects discarded.
22786 Generally there is no guarantee that a memory transaction ever succeeds
22787 and suitable fallback code always needs to be supplied.
22789 @deftypefn {RTM Function} {unsigned} _xbegin ()
22790 Start a RTM (Restricted Transactional Memory) transaction. 
22791 Returns @code{_XBEGIN_STARTED} when the transaction
22792 started successfully (note this is not 0, so the constant has to be 
22793 explicitly tested).  
22795 If the transaction aborts, all side effects
22796 are undone and an abort code encoded as a bit mask is returned.
22797 The following macros are defined:
22799 @table @code
22800 @item _XABORT_EXPLICIT
22801 Transaction was explicitly aborted with @code{_xabort}.  The parameter passed
22802 to @code{_xabort} is available with @code{_XABORT_CODE(status)}.
22803 @item _XABORT_RETRY
22804 Transaction retry is possible.
22805 @item _XABORT_CONFLICT
22806 Transaction abort due to a memory conflict with another thread.
22807 @item _XABORT_CAPACITY
22808 Transaction abort due to the transaction using too much memory.
22809 @item _XABORT_DEBUG
22810 Transaction abort due to a debug trap.
22811 @item _XABORT_NESTED
22812 Transaction abort in an inner nested transaction.
22813 @end table
22815 There is no guarantee
22816 any transaction ever succeeds, so there always needs to be a valid
22817 fallback path.
22818 @end deftypefn
22820 @deftypefn {RTM Function} {void} _xend ()
22821 Commit the current transaction. When no transaction is active this faults.
22822 All memory side effects of the transaction become visible
22823 to other threads in an atomic manner.
22824 @end deftypefn
22826 @deftypefn {RTM Function} {int} _xtest ()
22827 Return a nonzero value if a transaction is currently active, otherwise 0.
22828 @end deftypefn
22830 @deftypefn {RTM Function} {void} _xabort (status)
22831 Abort the current transaction. When no transaction is active this is a no-op.
22832 The @var{status} is an 8-bit constant; its value is encoded in the return 
22833 value from @code{_xbegin}.
22834 @end deftypefn
22836 Here is an example showing handling for @code{_XABORT_RETRY}
22837 and a fallback path for other failures:
22839 @smallexample
22840 #include <immintrin.h>
22842 int n_tries, max_tries;
22843 unsigned status = _XABORT_EXPLICIT;
22846 for (n_tries = 0; n_tries < max_tries; n_tries++) 
22847   @{
22848     status = _xbegin ();
22849     if (status == _XBEGIN_STARTED || !(status & _XABORT_RETRY))
22850       break;
22851   @}
22852 if (status == _XBEGIN_STARTED) 
22853   @{
22854     ... transaction code...
22855     _xend ();
22856   @} 
22857 else 
22858   @{
22859     ... non-transactional fallback path...
22860   @}
22861 @end smallexample
22863 @noindent
22864 Note that, in most cases, the transactional and non-transactional code
22865 must synchronize together to ensure consistency.
22867 @node x86 control-flow protection intrinsics
22868 @subsection x86 Control-Flow Protection Intrinsics
22870 @deftypefn {CET Function} {ret_type} _get_ssp (void)
22871 Get the current value of shadow stack pointer if shadow stack support
22872 from Intel CET is enabled in the hardware or @code{0} otherwise.
22873 The @code{ret_type} is @code{unsigned long long} for 64-bit targets 
22874 and @code{unsigned int} for 32-bit targets.
22875 @end deftypefn
22877 @deftypefn {CET Function} void _inc_ssp (unsigned int)
22878 Increment the current shadow stack pointer by the size specified by the
22879 function argument.  The argument is masked to a byte value for security
22880 reasons, so to increment by more than 255 bytes you must call the function
22881 multiple times.
22882 @end deftypefn
22884 The shadow stack unwind code looks like:
22886 @smallexample
22887 #include <immintrin.h>
22889 /* Unwind the shadow stack for EH.  */
22890 #define _Unwind_Frames_Extra(x)       \
22891   do                                  \
22892     @{                                \
22893       _Unwind_Word ssp = _get_ssp (); \
22894       if (ssp != 0)                   \
22895         @{                            \
22896           _Unwind_Word tmp = (x);     \
22897           while (tmp > 255)           \
22898             @{                        \
22899               _inc_ssp (tmp);         \
22900               tmp -= 255;             \
22901             @}                        \
22902           _inc_ssp (tmp);             \
22903         @}                            \
22904     @}                                \
22905     while (0)
22906 @end smallexample
22908 @noindent
22909 This code runs unconditionally on all 64-bit processors.  For 32-bit
22910 processors the code runs on those that support multi-byte NOP instructions.
22912 @node Target Format Checks
22913 @section Format Checks Specific to Particular Target Machines
22915 For some target machines, GCC supports additional options to the
22916 format attribute
22917 (@pxref{Function Attributes,,Declaring Attributes of Functions}).
22919 @menu
22920 * Solaris Format Checks::
22921 * Darwin Format Checks::
22922 @end menu
22924 @node Solaris Format Checks
22925 @subsection Solaris Format Checks
22927 Solaris targets support the @code{cmn_err} (or @code{__cmn_err__}) format
22928 check.  @code{cmn_err} accepts a subset of the standard @code{printf}
22929 conversions, and the two-argument @code{%b} conversion for displaying
22930 bit-fields.  See the Solaris man page for @code{cmn_err} for more information.
22932 @node Darwin Format Checks
22933 @subsection Darwin Format Checks
22935 In addition to the full set of format archetypes (attribute format style
22936 arguments such as @code{printf}, @code{scanf}, @code{strftime}, and
22937 @code{strfmon}), Darwin targets also support the @code{CFString} (or
22938 @code{__CFString__}) archetype in the @code{format} attribute.
22939 Declarations with this archetype are parsed for correct syntax
22940 and argument types.  However, parsing of the format string itself and
22941 validating arguments against it in calls to such functions is currently
22942 not performed.
22944 Additionally, @code{CFStringRefs} (defined by the @code{CoreFoundation} headers) may
22945 also be used as format arguments.  Note that the relevant headers are only likely to be
22946 available on Darwin (OSX) installations.  On such installations, the XCode and system
22947 documentation provide descriptions of @code{CFString}, @code{CFStringRefs} and
22948 associated functions.
22950 @node Pragmas
22951 @section Pragmas Accepted by GCC
22952 @cindex pragmas
22953 @cindex @code{#pragma}
22955 GCC supports several types of pragmas, primarily in order to compile
22956 code originally written for other compilers.  Note that in general
22957 we do not recommend the use of pragmas; @xref{Function Attributes},
22958 for further explanation.
22960 The GNU C preprocessor recognizes several pragmas in addition to the
22961 compiler pragmas documented here.  Refer to the CPP manual for more
22962 information.
22964 @menu
22965 * AArch64 Pragmas::
22966 * ARM Pragmas::
22967 * M32C Pragmas::
22968 * MeP Pragmas::
22969 * RS/6000 and PowerPC Pragmas::
22970 * S/390 Pragmas::
22971 * Darwin Pragmas::
22972 * Solaris Pragmas::
22973 * Symbol-Renaming Pragmas::
22974 * Structure-Layout Pragmas::
22975 * Weak Pragmas::
22976 * Diagnostic Pragmas::
22977 * Visibility Pragmas::
22978 * Push/Pop Macro Pragmas::
22979 * Function Specific Option Pragmas::
22980 * Loop-Specific Pragmas::
22981 @end menu
22983 @node AArch64 Pragmas
22984 @subsection AArch64 Pragmas
22986 The pragmas defined by the AArch64 target correspond to the AArch64
22987 target function attributes.  They can be specified as below:
22988 @smallexample
22989 #pragma GCC target("string")
22990 @end smallexample
22992 where @code{@var{string}} can be any string accepted as an AArch64 target
22993 attribute.  @xref{AArch64 Function Attributes}, for more details
22994 on the permissible values of @code{string}.
22996 @node ARM Pragmas
22997 @subsection ARM Pragmas
22999 The ARM target defines pragmas for controlling the default addition of
23000 @code{long_call} and @code{short_call} attributes to functions.
23001 @xref{Function Attributes}, for information about the effects of these
23002 attributes.
23004 @table @code
23005 @item long_calls
23006 @cindex pragma, long_calls
23007 Set all subsequent functions to have the @code{long_call} attribute.
23009 @item no_long_calls
23010 @cindex pragma, no_long_calls
23011 Set all subsequent functions to have the @code{short_call} attribute.
23013 @item long_calls_off
23014 @cindex pragma, long_calls_off
23015 Do not affect the @code{long_call} or @code{short_call} attributes of
23016 subsequent functions.
23017 @end table
23019 @node M32C Pragmas
23020 @subsection M32C Pragmas
23022 @table @code
23023 @item GCC memregs @var{number}
23024 @cindex pragma, memregs
23025 Overrides the command-line option @code{-memregs=} for the current
23026 file.  Use with care!  This pragma must be before any function in the
23027 file, and mixing different memregs values in different objects may
23028 make them incompatible.  This pragma is useful when a
23029 performance-critical function uses a memreg for temporary values,
23030 as it may allow you to reduce the number of memregs used.
23032 @item ADDRESS @var{name} @var{address}
23033 @cindex pragma, address
23034 For any declared symbols matching @var{name}, this does three things
23035 to that symbol: it forces the symbol to be located at the given
23036 address (a number), it forces the symbol to be volatile, and it
23037 changes the symbol's scope to be static.  This pragma exists for
23038 compatibility with other compilers, but note that the common
23039 @code{1234H} numeric syntax is not supported (use @code{0x1234}
23040 instead).  Example:
23042 @smallexample
23043 #pragma ADDRESS port3 0x103
23044 char port3;
23045 @end smallexample
23047 @end table
23049 @node MeP Pragmas
23050 @subsection MeP Pragmas
23052 @table @code
23054 @item custom io_volatile (on|off)
23055 @cindex pragma, custom io_volatile
23056 Overrides the command-line option @code{-mio-volatile} for the current
23057 file.  Note that for compatibility with future GCC releases, this
23058 option should only be used once before any @code{io} variables in each
23059 file.
23061 @item GCC coprocessor available @var{registers}
23062 @cindex pragma, coprocessor available
23063 Specifies which coprocessor registers are available to the register
23064 allocator.  @var{registers} may be a single register, register range
23065 separated by ellipses, or comma-separated list of those.  Example:
23067 @smallexample
23068 #pragma GCC coprocessor available $c0...$c10, $c28
23069 @end smallexample
23071 @item GCC coprocessor call_saved @var{registers}
23072 @cindex pragma, coprocessor call_saved
23073 Specifies which coprocessor registers are to be saved and restored by
23074 any function using them.  @var{registers} may be a single register,
23075 register range separated by ellipses, or comma-separated list of
23076 those.  Example:
23078 @smallexample
23079 #pragma GCC coprocessor call_saved $c4...$c6, $c31
23080 @end smallexample
23082 @item GCC coprocessor subclass '(A|B|C|D)' = @var{registers}
23083 @cindex pragma, coprocessor subclass
23084 Creates and defines a register class.  These register classes can be
23085 used by inline @code{asm} constructs.  @var{registers} may be a single
23086 register, register range separated by ellipses, or comma-separated
23087 list of those.  Example:
23089 @smallexample
23090 #pragma GCC coprocessor subclass 'B' = $c2, $c4, $c6
23092 asm ("cpfoo %0" : "=B" (x));
23093 @end smallexample
23095 @item GCC disinterrupt @var{name} , @var{name} @dots{}
23096 @cindex pragma, disinterrupt
23097 For the named functions, the compiler adds code to disable interrupts
23098 for the duration of those functions.  If any functions so named 
23099 are not encountered in the source, a warning is emitted that the pragma is
23100 not used.  Examples:
23102 @smallexample
23103 #pragma disinterrupt foo
23104 #pragma disinterrupt bar, grill
23105 int foo () @{ @dots{} @}
23106 @end smallexample
23108 @item GCC call @var{name} , @var{name} @dots{}
23109 @cindex pragma, call
23110 For the named functions, the compiler always uses a register-indirect
23111 call model when calling the named functions.  Examples:
23113 @smallexample
23114 extern int foo ();
23115 #pragma call foo
23116 @end smallexample
23118 @end table
23120 @node RS/6000 and PowerPC Pragmas
23121 @subsection RS/6000 and PowerPC Pragmas
23123 The RS/6000 and PowerPC targets define one pragma for controlling
23124 whether or not the @code{longcall} attribute is added to function
23125 declarations by default.  This pragma overrides the @option{-mlongcall}
23126 option, but not the @code{longcall} and @code{shortcall} attributes.
23127 @xref{RS/6000 and PowerPC Options}, for more information about when long
23128 calls are and are not necessary.
23130 @table @code
23131 @item longcall (1)
23132 @cindex pragma, longcall
23133 Apply the @code{longcall} attribute to all subsequent function
23134 declarations.
23136 @item longcall (0)
23137 Do not apply the @code{longcall} attribute to subsequent function
23138 declarations.
23139 @end table
23141 @c Describe h8300 pragmas here.
23142 @c Describe sh pragmas here.
23143 @c Describe v850 pragmas here.
23145 @node S/390 Pragmas
23146 @subsection S/390 Pragmas
23148 The pragmas defined by the S/390 target correspond to the S/390
23149 target function attributes and some the additional options:
23151 @table @samp
23152 @item zvector
23153 @itemx no-zvector
23154 @end table
23156 Note that options of the pragma, unlike options of the target
23157 attribute, do change the value of preprocessor macros like
23158 @code{__VEC__}.  They can be specified as below:
23160 @smallexample
23161 #pragma GCC target("string[,string]...")
23162 #pragma GCC target("string"[,"string"]...)
23163 @end smallexample
23165 @node Darwin Pragmas
23166 @subsection Darwin Pragmas
23168 The following pragmas are available for all architectures running the
23169 Darwin operating system.  These are useful for compatibility with other
23170 Mac OS compilers.
23172 @table @code
23173 @item mark @var{tokens}@dots{}
23174 @cindex pragma, mark
23175 This pragma is accepted, but has no effect.
23177 @item options align=@var{alignment}
23178 @cindex pragma, options align
23179 This pragma sets the alignment of fields in structures.  The values of
23180 @var{alignment} may be @code{mac68k}, to emulate m68k alignment, or
23181 @code{power}, to emulate PowerPC alignment.  Uses of this pragma nest
23182 properly; to restore the previous setting, use @code{reset} for the
23183 @var{alignment}.
23185 @item segment @var{tokens}@dots{}
23186 @cindex pragma, segment
23187 This pragma is accepted, but has no effect.
23189 @item unused (@var{var} [, @var{var}]@dots{})
23190 @cindex pragma, unused
23191 This pragma declares variables to be possibly unused.  GCC does not
23192 produce warnings for the listed variables.  The effect is similar to
23193 that of the @code{unused} attribute, except that this pragma may appear
23194 anywhere within the variables' scopes.
23195 @end table
23197 @node Solaris Pragmas
23198 @subsection Solaris Pragmas
23200 The Solaris target supports @code{#pragma redefine_extname}
23201 (@pxref{Symbol-Renaming Pragmas}).  It also supports additional
23202 @code{#pragma} directives for compatibility with the system compiler.
23204 @table @code
23205 @item align @var{alignment} (@var{variable} [, @var{variable}]...)
23206 @cindex pragma, align
23208 Increase the minimum alignment of each @var{variable} to @var{alignment}.
23209 This is the same as GCC's @code{aligned} attribute @pxref{Variable
23210 Attributes}).  Macro expansion occurs on the arguments to this pragma
23211 when compiling C and Objective-C@.  It does not currently occur when
23212 compiling C++, but this is a bug which may be fixed in a future
23213 release.
23215 @item fini (@var{function} [, @var{function}]...)
23216 @cindex pragma, fini
23218 This pragma causes each listed @var{function} to be called after
23219 main, or during shared module unloading, by adding a call to the
23220 @code{.fini} section.
23222 @item init (@var{function} [, @var{function}]...)
23223 @cindex pragma, init
23225 This pragma causes each listed @var{function} to be called during
23226 initialization (before @code{main}) or during shared module loading, by
23227 adding a call to the @code{.init} section.
23229 @end table
23231 @node Symbol-Renaming Pragmas
23232 @subsection Symbol-Renaming Pragmas
23234 GCC supports a @code{#pragma} directive that changes the name used in
23235 assembly for a given declaration. While this pragma is supported on all
23236 platforms, it is intended primarily to provide compatibility with the
23237 Solaris system headers. This effect can also be achieved using the asm
23238 labels extension (@pxref{Asm Labels}).
23240 @table @code
23241 @item redefine_extname @var{oldname} @var{newname}
23242 @cindex pragma, redefine_extname
23244 This pragma gives the C function @var{oldname} the assembly symbol
23245 @var{newname}.  The preprocessor macro @code{__PRAGMA_REDEFINE_EXTNAME}
23246 is defined if this pragma is available (currently on all platforms).
23247 @end table
23249 This pragma and the @code{asm} labels extension interact in a complicated
23250 manner.  Here are some corner cases you may want to be aware of:
23252 @enumerate
23253 @item This pragma silently applies only to declarations with external
23254 linkage.  The @code{asm} label feature does not have this restriction.
23256 @item In C++, this pragma silently applies only to declarations with
23257 ``C'' linkage.  Again, @code{asm} labels do not have this restriction.
23259 @item If either of the ways of changing the assembly name of a
23260 declaration are applied to a declaration whose assembly name has
23261 already been determined (either by a previous use of one of these
23262 features, or because the compiler needed the assembly name in order to
23263 generate code), and the new name is different, a warning issues and
23264 the name does not change.
23266 @item The @var{oldname} used by @code{#pragma redefine_extname} is
23267 always the C-language name.
23268 @end enumerate
23270 @node Structure-Layout Pragmas
23271 @subsection Structure-Layout Pragmas
23273 For compatibility with Microsoft Windows compilers, GCC supports a
23274 set of @code{#pragma} directives that change the maximum alignment of
23275 members of structures (other than zero-width bit-fields), unions, and
23276 classes subsequently defined. The @var{n} value below always is required
23277 to be a small power of two and specifies the new alignment in bytes.
23279 @enumerate
23280 @item @code{#pragma pack(@var{n})} simply sets the new alignment.
23281 @item @code{#pragma pack()} sets the alignment to the one that was in
23282 effect when compilation started (see also command-line option
23283 @option{-fpack-struct[=@var{n}]} @pxref{Code Gen Options}).
23284 @item @code{#pragma pack(push[,@var{n}])} pushes the current alignment
23285 setting on an internal stack and then optionally sets the new alignment.
23286 @item @code{#pragma pack(pop)} restores the alignment setting to the one
23287 saved at the top of the internal stack (and removes that stack entry).
23288 Note that @code{#pragma pack([@var{n}])} does not influence this internal
23289 stack; thus it is possible to have @code{#pragma pack(push)} followed by
23290 multiple @code{#pragma pack(@var{n})} instances and finalized by a single
23291 @code{#pragma pack(pop)}.
23292 @end enumerate
23294 Some targets, e.g.@: x86 and PowerPC, support the @code{#pragma ms_struct}
23295 directive which lays out structures and unions subsequently defined as the
23296 documented @code{__attribute__ ((ms_struct))}.
23298 @enumerate
23299 @item @code{#pragma ms_struct on} turns on the Microsoft layout.
23300 @item @code{#pragma ms_struct off} turns off the Microsoft layout.
23301 @item @code{#pragma ms_struct reset} goes back to the default layout.
23302 @end enumerate
23304 Most targets also support the @code{#pragma scalar_storage_order} directive
23305 which lays out structures and unions subsequently defined as the documented
23306 @code{__attribute__ ((scalar_storage_order))}.
23308 @enumerate
23309 @item @code{#pragma scalar_storage_order big-endian} sets the storage order
23310 of the scalar fields to big-endian.
23311 @item @code{#pragma scalar_storage_order little-endian} sets the storage order
23312 of the scalar fields to little-endian.
23313 @item @code{#pragma scalar_storage_order default} goes back to the endianness
23314 that was in effect when compilation started (see also command-line option
23315 @option{-fsso-struct=@var{endianness}} @pxref{C Dialect Options}).
23316 @end enumerate
23318 @node Weak Pragmas
23319 @subsection Weak Pragmas
23321 For compatibility with SVR4, GCC supports a set of @code{#pragma}
23322 directives for declaring symbols to be weak, and defining weak
23323 aliases.
23325 @table @code
23326 @item #pragma weak @var{symbol}
23327 @cindex pragma, weak
23328 This pragma declares @var{symbol} to be weak, as if the declaration
23329 had the attribute of the same name.  The pragma may appear before
23330 or after the declaration of @var{symbol}.  It is not an error for
23331 @var{symbol} to never be defined at all.
23333 @item #pragma weak @var{symbol1} = @var{symbol2}
23334 This pragma declares @var{symbol1} to be a weak alias of @var{symbol2}.
23335 It is an error if @var{symbol2} is not defined in the current
23336 translation unit.
23337 @end table
23339 @node Diagnostic Pragmas
23340 @subsection Diagnostic Pragmas
23342 GCC allows the user to selectively enable or disable certain types of
23343 diagnostics, and change the kind of the diagnostic.  For example, a
23344 project's policy might require that all sources compile with
23345 @option{-Werror} but certain files might have exceptions allowing
23346 specific types of warnings.  Or, a project might selectively enable
23347 diagnostics and treat them as errors depending on which preprocessor
23348 macros are defined.
23350 @table @code
23351 @item #pragma GCC diagnostic @var{kind} @var{option}
23352 @cindex pragma, diagnostic
23354 Modifies the disposition of a diagnostic.  Note that not all
23355 diagnostics are modifiable; at the moment only warnings (normally
23356 controlled by @samp{-W@dots{}}) can be controlled, and not all of them.
23357 Use @option{-fdiagnostics-show-option} to determine which diagnostics
23358 are controllable and which option controls them.
23360 @var{kind} is @samp{error} to treat this diagnostic as an error,
23361 @samp{warning} to treat it like a warning (even if @option{-Werror} is
23362 in effect), or @samp{ignored} if the diagnostic is to be ignored.
23363 @var{option} is a double quoted string that matches the command-line
23364 option.
23366 @smallexample
23367 #pragma GCC diagnostic warning "-Wformat"
23368 #pragma GCC diagnostic error "-Wformat"
23369 #pragma GCC diagnostic ignored "-Wformat"
23370 @end smallexample
23372 Note that these pragmas override any command-line options.  GCC keeps
23373 track of the location of each pragma, and issues diagnostics according
23374 to the state as of that point in the source file.  Thus, pragmas occurring
23375 after a line do not affect diagnostics caused by that line.
23377 @item #pragma GCC diagnostic push
23378 @itemx #pragma GCC diagnostic pop
23380 Causes GCC to remember the state of the diagnostics as of each
23381 @code{push}, and restore to that point at each @code{pop}.  If a
23382 @code{pop} has no matching @code{push}, the command-line options are
23383 restored.
23385 @smallexample
23386 #pragma GCC diagnostic error "-Wuninitialized"
23387   foo(a);                       /* error is given for this one */
23388 #pragma GCC diagnostic push
23389 #pragma GCC diagnostic ignored "-Wuninitialized"
23390   foo(b);                       /* no diagnostic for this one */
23391 #pragma GCC diagnostic pop
23392   foo(c);                       /* error is given for this one */
23393 #pragma GCC diagnostic pop
23394   foo(d);                       /* depends on command-line options */
23395 @end smallexample
23397 @end table
23399 GCC also offers a simple mechanism for printing messages during
23400 compilation.
23402 @table @code
23403 @item #pragma message @var{string}
23404 @cindex pragma, diagnostic
23406 Prints @var{string} as a compiler message on compilation.  The message
23407 is informational only, and is neither a compilation warning nor an
23408 error.  Newlines can be included in the string by using the @samp{\n}
23409 escape sequence.
23411 @smallexample
23412 #pragma message "Compiling " __FILE__ "..."
23413 @end smallexample
23415 @var{string} may be parenthesized, and is printed with location
23416 information.  For example,
23418 @smallexample
23419 #define DO_PRAGMA(x) _Pragma (#x)
23420 #define TODO(x) DO_PRAGMA(message ("TODO - " #x))
23422 TODO(Remember to fix this)
23423 @end smallexample
23425 @noindent
23426 prints @samp{/tmp/file.c:4: note: #pragma message:
23427 TODO - Remember to fix this}.
23429 @item #pragma GCC error @var{message}
23430 @cindex pragma, diagnostic
23431 Generates an error message.  This pragma @emph{is} considered to
23432 indicate an error in the compilation, and it will be treated as such.
23434 Newlines can be included in the string by using the @samp{\n}
23435 escape sequence.  They will be displayed as newlines even if the
23436 @option{-fmessage-length} option is set to zero.
23438 The error is only generated if the pragma is present in the code after
23439 pre-processing has been completed.  It does not matter however if the
23440 code containing the pragma is unreachable:
23442 @smallexample
23443 #if 0
23444 #pragma GCC error "this error is not seen"
23445 #endif
23446 void foo (void)
23448   return;
23449 #pragma GCC error "this error is seen"
23451 @end smallexample
23453 @item #pragma GCC warning @var{message}
23454 @cindex pragma, diagnostic
23455 This is just like @samp{pragma GCC error} except that a warning
23456 message is issued instead of an error message.  Unless
23457 @option{-Werror} is in effect, in which case this pragma will generate
23458 an error as well.
23460 @end table
23462 @node Visibility Pragmas
23463 @subsection Visibility Pragmas
23465 @table @code
23466 @item #pragma GCC visibility push(@var{visibility})
23467 @itemx #pragma GCC visibility pop
23468 @cindex pragma, visibility
23470 This pragma allows the user to set the visibility for multiple
23471 declarations without having to give each a visibility attribute
23472 (@pxref{Function Attributes}).
23474 In C++, @samp{#pragma GCC visibility} affects only namespace-scope
23475 declarations.  Class members and template specializations are not
23476 affected; if you want to override the visibility for a particular
23477 member or instantiation, you must use an attribute.
23479 @end table
23482 @node Push/Pop Macro Pragmas
23483 @subsection Push/Pop Macro Pragmas
23485 For compatibility with Microsoft Windows compilers, GCC supports
23486 @samp{#pragma push_macro(@var{"macro_name"})}
23487 and @samp{#pragma pop_macro(@var{"macro_name"})}.
23489 @table @code
23490 @item #pragma push_macro(@var{"macro_name"})
23491 @cindex pragma, push_macro
23492 This pragma saves the value of the macro named as @var{macro_name} to
23493 the top of the stack for this macro.
23495 @item #pragma pop_macro(@var{"macro_name"})
23496 @cindex pragma, pop_macro
23497 This pragma sets the value of the macro named as @var{macro_name} to
23498 the value on top of the stack for this macro. If the stack for
23499 @var{macro_name} is empty, the value of the macro remains unchanged.
23500 @end table
23502 For example:
23504 @smallexample
23505 #define X  1
23506 #pragma push_macro("X")
23507 #undef X
23508 #define X -1
23509 #pragma pop_macro("X")
23510 int x [X];
23511 @end smallexample
23513 @noindent
23514 In this example, the definition of X as 1 is saved by @code{#pragma
23515 push_macro} and restored by @code{#pragma pop_macro}.
23517 @node Function Specific Option Pragmas
23518 @subsection Function Specific Option Pragmas
23520 @table @code
23521 @item #pragma GCC target (@var{string}, @dots{})
23522 @cindex pragma GCC target
23524 This pragma allows you to set target-specific options for functions
23525 defined later in the source file.  One or more strings can be
23526 specified.  Each function that is defined after this point is treated
23527 as if it had been declared with one @code{target(}@var{string}@code{)}
23528 attribute for each @var{string} argument.  The parentheses around
23529 the strings in the pragma are optional.  @xref{Function Attributes},
23530 for more information about the @code{target} attribute and the attribute
23531 syntax.
23533 The @code{#pragma GCC target} pragma is presently implemented for
23534 x86, ARM, AArch64, PowerPC, S/390, and Nios II targets only.
23536 @item #pragma GCC optimize (@var{string}, @dots{})
23537 @cindex pragma GCC optimize
23539 This pragma allows you to set global optimization options for functions
23540 defined later in the source file.  One or more strings can be
23541 specified.  Each function that is defined after this point is treated
23542 as if it had been declared with one @code{optimize(}@var{string}@code{)}
23543 attribute for each @var{string} argument.  The parentheses around
23544 the strings in the pragma are optional.  @xref{Function Attributes},
23545 for more information about the @code{optimize} attribute and the attribute
23546 syntax.
23548 @item #pragma GCC push_options
23549 @itemx #pragma GCC pop_options
23550 @cindex pragma GCC push_options
23551 @cindex pragma GCC pop_options
23553 These pragmas maintain a stack of the current target and optimization
23554 options.  It is intended for include files where you temporarily want
23555 to switch to using a different @samp{#pragma GCC target} or
23556 @samp{#pragma GCC optimize} and then to pop back to the previous
23557 options.
23559 @item #pragma GCC reset_options
23560 @cindex pragma GCC reset_options
23562 This pragma clears the current @code{#pragma GCC target} and
23563 @code{#pragma GCC optimize} to use the default switches as specified
23564 on the command line.
23566 @end table
23568 @node Loop-Specific Pragmas
23569 @subsection Loop-Specific Pragmas
23571 @table @code
23572 @item #pragma GCC ivdep
23573 @cindex pragma GCC ivdep
23575 With this pragma, the programmer asserts that there are no loop-carried
23576 dependencies which would prevent consecutive iterations of
23577 the following loop from executing concurrently with SIMD
23578 (single instruction multiple data) instructions.
23580 For example, the compiler can only unconditionally vectorize the following
23581 loop with the pragma:
23583 @smallexample
23584 void foo (int n, int *a, int *b, int *c)
23586   int i, j;
23587 #pragma GCC ivdep
23588   for (i = 0; i < n; ++i)
23589     a[i] = b[i] + c[i];
23591 @end smallexample
23593 @noindent
23594 In this example, using the @code{restrict} qualifier had the same
23595 effect. In the following example, that would not be possible. Assume
23596 @math{k < -m} or @math{k >= m}. Only with the pragma, the compiler knows
23597 that it can unconditionally vectorize the following loop:
23599 @smallexample
23600 void ignore_vec_dep (int *a, int k, int c, int m)
23602 #pragma GCC ivdep
23603   for (int i = 0; i < m; i++)
23604     a[i] = a[i + k] * c;
23606 @end smallexample
23608 @item #pragma GCC unroll @var{n}
23609 @cindex pragma GCC unroll @var{n}
23611 You can use this pragma to control how many times a loop should be unrolled.
23612 It must be placed immediately before a @code{for}, @code{while} or @code{do}
23613 loop or a @code{#pragma GCC ivdep}, and applies only to the loop that follows.
23614 @var{n} is an integer constant expression specifying the unrolling factor.
23615 The values of @math{0} and @math{1} block any unrolling of the loop.
23617 @end table
23619 @node Unnamed Fields
23620 @section Unnamed Structure and Union Fields
23621 @cindex @code{struct}
23622 @cindex @code{union}
23624 As permitted by ISO C11 and for compatibility with other compilers,
23625 GCC allows you to define
23626 a structure or union that contains, as fields, structures and unions
23627 without names.  For example:
23629 @smallexample
23630 struct @{
23631   int a;
23632   union @{
23633     int b;
23634     float c;
23635   @};
23636   int d;
23637 @} foo;
23638 @end smallexample
23640 @noindent
23641 In this example, you are able to access members of the unnamed
23642 union with code like @samp{foo.b}.  Note that only unnamed structs and
23643 unions are allowed, you may not have, for example, an unnamed
23644 @code{int}.
23646 You must never create such structures that cause ambiguous field definitions.
23647 For example, in this structure:
23649 @smallexample
23650 struct @{
23651   int a;
23652   struct @{
23653     int a;
23654   @};
23655 @} foo;
23656 @end smallexample
23658 @noindent
23659 it is ambiguous which @code{a} is being referred to with @samp{foo.a}.
23660 The compiler gives errors for such constructs.
23662 @opindex fms-extensions
23663 Unless @option{-fms-extensions} is used, the unnamed field must be a
23664 structure or union definition without a tag (for example, @samp{struct
23665 @{ int a; @};}).  If @option{-fms-extensions} is used, the field may
23666 also be a definition with a tag such as @samp{struct foo @{ int a;
23667 @};}, a reference to a previously defined structure or union such as
23668 @samp{struct foo;}, or a reference to a @code{typedef} name for a
23669 previously defined structure or union type.
23671 @opindex fplan9-extensions
23672 The option @option{-fplan9-extensions} enables
23673 @option{-fms-extensions} as well as two other extensions.  First, a
23674 pointer to a structure is automatically converted to a pointer to an
23675 anonymous field for assignments and function calls.  For example:
23677 @smallexample
23678 struct s1 @{ int a; @};
23679 struct s2 @{ struct s1; @};
23680 extern void f1 (struct s1 *);
23681 void f2 (struct s2 *p) @{ f1 (p); @}
23682 @end smallexample
23684 @noindent
23685 In the call to @code{f1} inside @code{f2}, the pointer @code{p} is
23686 converted into a pointer to the anonymous field.
23688 Second, when the type of an anonymous field is a @code{typedef} for a
23689 @code{struct} or @code{union}, code may refer to the field using the
23690 name of the @code{typedef}.
23692 @smallexample
23693 typedef struct @{ int a; @} s1;
23694 struct s2 @{ s1; @};
23695 s1 f1 (struct s2 *p) @{ return p->s1; @}
23696 @end smallexample
23698 These usages are only permitted when they are not ambiguous.
23700 @node Thread-Local
23701 @section Thread-Local Storage
23702 @cindex Thread-Local Storage
23703 @cindex @acronym{TLS}
23704 @cindex @code{__thread}
23706 Thread-local storage (@acronym{TLS}) is a mechanism by which variables
23707 are allocated such that there is one instance of the variable per extant
23708 thread.  The runtime model GCC uses to implement this originates
23709 in the IA-64 processor-specific ABI, but has since been migrated
23710 to other processors as well.  It requires significant support from
23711 the linker (@command{ld}), dynamic linker (@command{ld.so}), and
23712 system libraries (@file{libc.so} and @file{libpthread.so}), so it
23713 is not available everywhere.
23715 At the user level, the extension is visible with a new storage
23716 class keyword: @code{__thread}.  For example:
23718 @smallexample
23719 __thread int i;
23720 extern __thread struct state s;
23721 static __thread char *p;
23722 @end smallexample
23724 The @code{__thread} specifier may be used alone, with the @code{extern}
23725 or @code{static} specifiers, but with no other storage class specifier.
23726 When used with @code{extern} or @code{static}, @code{__thread} must appear
23727 immediately after the other storage class specifier.
23729 The @code{__thread} specifier may be applied to any global, file-scoped
23730 static, function-scoped static, or static data member of a class.  It may
23731 not be applied to block-scoped automatic or non-static data member.
23733 When the address-of operator is applied to a thread-local variable, it is
23734 evaluated at run time and returns the address of the current thread's
23735 instance of that variable.  An address so obtained may be used by any
23736 thread.  When a thread terminates, any pointers to thread-local variables
23737 in that thread become invalid.
23739 No static initialization may refer to the address of a thread-local variable.
23741 In C++, if an initializer is present for a thread-local variable, it must
23742 be a @var{constant-expression}, as defined in 5.19.2 of the ANSI/ISO C++
23743 standard.
23745 See @uref{https://www.akkadia.org/drepper/tls.pdf,
23746 ELF Handling For Thread-Local Storage} for a detailed explanation of
23747 the four thread-local storage addressing models, and how the runtime
23748 is expected to function.
23750 @menu
23751 * C99 Thread-Local Edits::
23752 * C++98 Thread-Local Edits::
23753 @end menu
23755 @node C99 Thread-Local Edits
23756 @subsection ISO/IEC 9899:1999 Edits for Thread-Local Storage
23758 The following are a set of changes to ISO/IEC 9899:1999 (aka C99)
23759 that document the exact semantics of the language extension.
23761 @itemize @bullet
23762 @item
23763 @cite{5.1.2  Execution environments}
23765 Add new text after paragraph 1
23767 @quotation
23768 Within either execution environment, a @dfn{thread} is a flow of
23769 control within a program.  It is implementation defined whether
23770 or not there may be more than one thread associated with a program.
23771 It is implementation defined how threads beyond the first are
23772 created, the name and type of the function called at thread
23773 startup, and how threads may be terminated.  However, objects
23774 with thread storage duration shall be initialized before thread
23775 startup.
23776 @end quotation
23778 @item
23779 @cite{6.2.4  Storage durations of objects}
23781 Add new text before paragraph 3
23783 @quotation
23784 An object whose identifier is declared with the storage-class
23785 specifier @w{@code{__thread}} has @dfn{thread storage duration}.
23786 Its lifetime is the entire execution of the thread, and its
23787 stored value is initialized only once, prior to thread startup.
23788 @end quotation
23790 @item
23791 @cite{6.4.1  Keywords}
23793 Add @code{__thread}.
23795 @item
23796 @cite{6.7.1  Storage-class specifiers}
23798 Add @code{__thread} to the list of storage class specifiers in
23799 paragraph 1.
23801 Change paragraph 2 to
23803 @quotation
23804 With the exception of @code{__thread}, at most one storage-class
23805 specifier may be given [@dots{}].  The @code{__thread} specifier may
23806 be used alone, or immediately following @code{extern} or
23807 @code{static}.
23808 @end quotation
23810 Add new text after paragraph 6
23812 @quotation
23813 The declaration of an identifier for a variable that has
23814 block scope that specifies @code{__thread} shall also
23815 specify either @code{extern} or @code{static}.
23817 The @code{__thread} specifier shall be used only with
23818 variables.
23819 @end quotation
23820 @end itemize
23822 @node C++98 Thread-Local Edits
23823 @subsection ISO/IEC 14882:1998 Edits for Thread-Local Storage
23825 The following are a set of changes to ISO/IEC 14882:1998 (aka C++98)
23826 that document the exact semantics of the language extension.
23828 @itemize @bullet
23829 @item
23830 @b{[intro.execution]}
23832 New text after paragraph 4
23834 @quotation
23835 A @dfn{thread} is a flow of control within the abstract machine.
23836 It is implementation defined whether or not there may be more than
23837 one thread.
23838 @end quotation
23840 New text after paragraph 7
23842 @quotation
23843 It is unspecified whether additional action must be taken to
23844 ensure when and whether side effects are visible to other threads.
23845 @end quotation
23847 @item
23848 @b{[lex.key]}
23850 Add @code{__thread}.
23852 @item
23853 @b{[basic.start.main]}
23855 Add after paragraph 5
23857 @quotation
23858 The thread that begins execution at the @code{main} function is called
23859 the @dfn{main thread}.  It is implementation defined how functions
23860 beginning threads other than the main thread are designated or typed.
23861 A function so designated, as well as the @code{main} function, is called
23862 a @dfn{thread startup function}.  It is implementation defined what
23863 happens if a thread startup function returns.  It is implementation
23864 defined what happens to other threads when any thread calls @code{exit}.
23865 @end quotation
23867 @item
23868 @b{[basic.start.init]}
23870 Add after paragraph 4
23872 @quotation
23873 The storage for an object of thread storage duration shall be
23874 statically initialized before the first statement of the thread startup
23875 function.  An object of thread storage duration shall not require
23876 dynamic initialization.
23877 @end quotation
23879 @item
23880 @b{[basic.start.term]}
23882 Add after paragraph 3
23884 @quotation
23885 The type of an object with thread storage duration shall not have a
23886 non-trivial destructor, nor shall it be an array type whose elements
23887 (directly or indirectly) have non-trivial destructors.
23888 @end quotation
23890 @item
23891 @b{[basic.stc]}
23893 Add ``thread storage duration'' to the list in paragraph 1.
23895 Change paragraph 2
23897 @quotation
23898 Thread, static, and automatic storage durations are associated with
23899 objects introduced by declarations [@dots{}].
23900 @end quotation
23902 Add @code{__thread} to the list of specifiers in paragraph 3.
23904 @item
23905 @b{[basic.stc.thread]}
23907 New section before @b{[basic.stc.static]}
23909 @quotation
23910 The keyword @code{__thread} applied to a non-local object gives the
23911 object thread storage duration.
23913 A local variable or class data member declared both @code{static}
23914 and @code{__thread} gives the variable or member thread storage
23915 duration.
23916 @end quotation
23918 @item
23919 @b{[basic.stc.static]}
23921 Change paragraph 1
23923 @quotation
23924 All objects that have neither thread storage duration, dynamic
23925 storage duration nor are local [@dots{}].
23926 @end quotation
23928 @item
23929 @b{[dcl.stc]}
23931 Add @code{__thread} to the list in paragraph 1.
23933 Change paragraph 1
23935 @quotation
23936 With the exception of @code{__thread}, at most one
23937 @var{storage-class-specifier} shall appear in a given
23938 @var{decl-specifier-seq}.  The @code{__thread} specifier may
23939 be used alone, or immediately following the @code{extern} or
23940 @code{static} specifiers.  [@dots{}]
23941 @end quotation
23943 Add after paragraph 5
23945 @quotation
23946 The @code{__thread} specifier can be applied only to the names of objects
23947 and to anonymous unions.
23948 @end quotation
23950 @item
23951 @b{[class.mem]}
23953 Add after paragraph 6
23955 @quotation
23956 Non-@code{static} members shall not be @code{__thread}.
23957 @end quotation
23958 @end itemize
23960 @node Binary constants
23961 @section Binary Constants using the @samp{0b} Prefix
23962 @cindex Binary constants using the @samp{0b} prefix
23964 Integer constants can be written as binary constants, consisting of a
23965 sequence of @samp{0} and @samp{1} digits, prefixed by @samp{0b} or
23966 @samp{0B}.  This is particularly useful in environments that operate a
23967 lot on the bit level (like microcontrollers).
23969 The following statements are identical:
23971 @smallexample
23972 i =       42;
23973 i =     0x2a;
23974 i =      052;
23975 i = 0b101010;
23976 @end smallexample
23978 The type of these constants follows the same rules as for octal or
23979 hexadecimal integer constants, so suffixes like @samp{L} or @samp{UL}
23980 can be applied.
23982 @node C++ Extensions
23983 @chapter Extensions to the C++ Language
23984 @cindex extensions, C++ language
23985 @cindex C++ language extensions
23987 The GNU compiler provides these extensions to the C++ language (and you
23988 can also use most of the C language extensions in your C++ programs).  If you
23989 want to write code that checks whether these features are available, you can
23990 test for the GNU compiler the same way as for C programs: check for a
23991 predefined macro @code{__GNUC__}.  You can also use @code{__GNUG__} to
23992 test specifically for GNU C++ (@pxref{Common Predefined Macros,,
23993 Predefined Macros,cpp,The GNU C Preprocessor}).
23995 @menu
23996 * C++ Volatiles::       What constitutes an access to a volatile object.
23997 * Restricted Pointers:: C99 restricted pointers and references.
23998 * Vague Linkage::       Where G++ puts inlines, vtables and such.
23999 * C++ Interface::       You can use a single C++ header file for both
24000                         declarations and definitions.
24001 * Template Instantiation:: Methods for ensuring that exactly one copy of
24002                         each needed template instantiation is emitted.
24003 * Bound member functions:: You can extract a function pointer to the
24004                         method denoted by a @samp{->*} or @samp{.*} expression.
24005 * C++ Attributes::      Variable, function, and type attributes for C++ only.
24006 * Function Multiversioning::   Declaring multiple function versions.
24007 * Type Traits::         Compiler support for type traits.
24008 * C++ Concepts::        Improved support for generic programming.
24009 * Deprecated Features:: Things will disappear from G++.
24010 * Backwards Compatibility:: Compatibilities with earlier definitions of C++.
24011 @end menu
24013 @node C++ Volatiles
24014 @section When is a Volatile C++ Object Accessed?
24015 @cindex accessing volatiles
24016 @cindex volatile read
24017 @cindex volatile write
24018 @cindex volatile access
24020 The C++ standard differs from the C standard in its treatment of
24021 volatile objects.  It fails to specify what constitutes a volatile
24022 access, except to say that C++ should behave in a similar manner to C
24023 with respect to volatiles, where possible.  However, the different
24024 lvalueness of expressions between C and C++ complicate the behavior.
24025 G++ behaves the same as GCC for volatile access, @xref{C
24026 Extensions,,Volatiles}, for a description of GCC's behavior.
24028 The C and C++ language specifications differ when an object is
24029 accessed in a void context:
24031 @smallexample
24032 volatile int *src = @var{somevalue};
24033 *src;
24034 @end smallexample
24036 The C++ standard specifies that such expressions do not undergo lvalue
24037 to rvalue conversion, and that the type of the dereferenced object may
24038 be incomplete.  The C++ standard does not specify explicitly that it
24039 is lvalue to rvalue conversion that is responsible for causing an
24040 access.  There is reason to believe that it is, because otherwise
24041 certain simple expressions become undefined.  However, because it
24042 would surprise most programmers, G++ treats dereferencing a pointer to
24043 volatile object of complete type as GCC would do for an equivalent
24044 type in C@.  When the object has incomplete type, G++ issues a
24045 warning; if you wish to force an error, you must force a conversion to
24046 rvalue with, for instance, a static cast.
24048 When using a reference to volatile, G++ does not treat equivalent
24049 expressions as accesses to volatiles, but instead issues a warning that
24050 no volatile is accessed.  The rationale for this is that otherwise it
24051 becomes difficult to determine where volatile access occur, and not
24052 possible to ignore the return value from functions returning volatile
24053 references.  Again, if you wish to force a read, cast the reference to
24054 an rvalue.
24056 G++ implements the same behavior as GCC does when assigning to a
24057 volatile object---there is no reread of the assigned-to object, the
24058 assigned rvalue is reused.  Note that in C++ assignment expressions
24059 are lvalues, and if used as an lvalue, the volatile object is
24060 referred to.  For instance, @var{vref} refers to @var{vobj}, as
24061 expected, in the following example:
24063 @smallexample
24064 volatile int vobj;
24065 volatile int &vref = vobj = @var{something};
24066 @end smallexample
24068 @node Restricted Pointers
24069 @section Restricting Pointer Aliasing
24070 @cindex restricted pointers
24071 @cindex restricted references
24072 @cindex restricted this pointer
24074 As with the C front end, G++ understands the C99 feature of restricted pointers,
24075 specified with the @code{__restrict__}, or @code{__restrict} type
24076 qualifier.  Because you cannot compile C++ by specifying the @option{-std=c99}
24077 language flag, @code{restrict} is not a keyword in C++.
24079 In addition to allowing restricted pointers, you can specify restricted
24080 references, which indicate that the reference is not aliased in the local
24081 context.
24083 @smallexample
24084 void fn (int *__restrict__ rptr, int &__restrict__ rref)
24086   /* @r{@dots{}} */
24088 @end smallexample
24090 @noindent
24091 In the body of @code{fn}, @var{rptr} points to an unaliased integer and
24092 @var{rref} refers to a (different) unaliased integer.
24094 You may also specify whether a member function's @var{this} pointer is
24095 unaliased by using @code{__restrict__} as a member function qualifier.
24097 @smallexample
24098 void T::fn () __restrict__
24100   /* @r{@dots{}} */
24102 @end smallexample
24104 @noindent
24105 Within the body of @code{T::fn}, @var{this} has the effective
24106 definition @code{T *__restrict__ const this}.  Notice that the
24107 interpretation of a @code{__restrict__} member function qualifier is
24108 different to that of @code{const} or @code{volatile} qualifier, in that it
24109 is applied to the pointer rather than the object.  This is consistent with
24110 other compilers that implement restricted pointers.
24112 As with all outermost parameter qualifiers, @code{__restrict__} is
24113 ignored in function definition matching.  This means you only need to
24114 specify @code{__restrict__} in a function definition, rather than
24115 in a function prototype as well.
24117 @node Vague Linkage
24118 @section Vague Linkage
24119 @cindex vague linkage
24121 There are several constructs in C++ that require space in the object
24122 file but are not clearly tied to a single translation unit.  We say that
24123 these constructs have ``vague linkage''.  Typically such constructs are
24124 emitted wherever they are needed, though sometimes we can be more
24125 clever.
24127 @table @asis
24128 @item Inline Functions
24129 Inline functions are typically defined in a header file which can be
24130 included in many different compilations.  Hopefully they can usually be
24131 inlined, but sometimes an out-of-line copy is necessary, if the address
24132 of the function is taken or if inlining fails.  In general, we emit an
24133 out-of-line copy in all translation units where one is needed.  As an
24134 exception, we only emit inline virtual functions with the vtable, since
24135 it always requires a copy.
24137 Local static variables and string constants used in an inline function
24138 are also considered to have vague linkage, since they must be shared
24139 between all inlined and out-of-line instances of the function.
24141 @item VTables
24142 @cindex vtable
24143 C++ virtual functions are implemented in most compilers using a lookup
24144 table, known as a vtable.  The vtable contains pointers to the virtual
24145 functions provided by a class, and each object of the class contains a
24146 pointer to its vtable (or vtables, in some multiple-inheritance
24147 situations).  If the class declares any non-inline, non-pure virtual
24148 functions, the first one is chosen as the ``key method'' for the class,
24149 and the vtable is only emitted in the translation unit where the key
24150 method is defined.
24152 @emph{Note:} If the chosen key method is later defined as inline, the
24153 vtable is still emitted in every translation unit that defines it.
24154 Make sure that any inline virtuals are declared inline in the class
24155 body, even if they are not defined there.
24157 @item @code{type_info} objects
24158 @cindex @code{type_info}
24159 @cindex RTTI
24160 C++ requires information about types to be written out in order to
24161 implement @samp{dynamic_cast}, @samp{typeid} and exception handling.
24162 For polymorphic classes (classes with virtual functions), the @samp{type_info}
24163 object is written out along with the vtable so that @samp{dynamic_cast}
24164 can determine the dynamic type of a class object at run time.  For all
24165 other types, we write out the @samp{type_info} object when it is used: when
24166 applying @samp{typeid} to an expression, throwing an object, or
24167 referring to a type in a catch clause or exception specification.
24169 @item Template Instantiations
24170 Most everything in this section also applies to template instantiations,
24171 but there are other options as well.
24172 @xref{Template Instantiation,,Where's the Template?}.
24174 @end table
24176 When used with GNU ld version 2.8 or later on an ELF system such as
24177 GNU/Linux or Solaris 2, or on Microsoft Windows, duplicate copies of
24178 these constructs will be discarded at link time.  This is known as
24179 COMDAT support.
24181 On targets that don't support COMDAT, but do support weak symbols, GCC
24182 uses them.  This way one copy overrides all the others, but
24183 the unused copies still take up space in the executable.
24185 For targets that do not support either COMDAT or weak symbols,
24186 most entities with vague linkage are emitted as local symbols to
24187 avoid duplicate definition errors from the linker.  This does not happen
24188 for local statics in inlines, however, as having multiple copies
24189 almost certainly breaks things.
24191 @xref{C++ Interface,,Declarations and Definitions in One Header}, for
24192 another way to control placement of these constructs.
24194 @node C++ Interface
24195 @section C++ Interface and Implementation Pragmas
24197 @cindex interface and implementation headers, C++
24198 @cindex C++ interface and implementation headers
24199 @cindex pragmas, interface and implementation
24201 @code{#pragma interface} and @code{#pragma implementation} provide the
24202 user with a way of explicitly directing the compiler to emit entities
24203 with vague linkage (and debugging information) in a particular
24204 translation unit.
24206 @emph{Note:} These @code{#pragma}s have been superceded as of GCC 2.7.2
24207 by COMDAT support and the ``key method'' heuristic
24208 mentioned in @ref{Vague Linkage}.  Using them can actually cause your
24209 program to grow due to unnecessary out-of-line copies of inline
24210 functions.
24212 @table @code
24213 @item #pragma interface
24214 @itemx #pragma interface "@var{subdir}/@var{objects}.h"
24215 @kindex #pragma interface
24216 Use this directive in @emph{header files} that define object classes, to save
24217 space in most of the object files that use those classes.  Normally,
24218 local copies of certain information (backup copies of inline member
24219 functions, debugging information, and the internal tables that implement
24220 virtual functions) must be kept in each object file that includes class
24221 definitions.  You can use this pragma to avoid such duplication.  When a
24222 header file containing @samp{#pragma interface} is included in a
24223 compilation, this auxiliary information is not generated (unless
24224 the main input source file itself uses @samp{#pragma implementation}).
24225 Instead, the object files contain references to be resolved at link
24226 time.
24228 The second form of this directive is useful for the case where you have
24229 multiple headers with the same name in different directories.  If you
24230 use this form, you must specify the same string to @samp{#pragma
24231 implementation}.
24233 @item #pragma implementation
24234 @itemx #pragma implementation "@var{objects}.h"
24235 @kindex #pragma implementation
24236 Use this pragma in a @emph{main input file}, when you want full output from
24237 included header files to be generated (and made globally visible).  The
24238 included header file, in turn, should use @samp{#pragma interface}.
24239 Backup copies of inline member functions, debugging information, and the
24240 internal tables used to implement virtual functions are all generated in
24241 implementation files.
24243 @cindex implied @code{#pragma implementation}
24244 @cindex @code{#pragma implementation}, implied
24245 @cindex naming convention, implementation headers
24246 If you use @samp{#pragma implementation} with no argument, it applies to
24247 an include file with the same basename@footnote{A file's @dfn{basename}
24248 is the name stripped of all leading path information and of trailing
24249 suffixes, such as @samp{.h} or @samp{.C} or @samp{.cc}.} as your source
24250 file.  For example, in @file{allclass.cc}, giving just
24251 @samp{#pragma implementation}
24252 by itself is equivalent to @samp{#pragma implementation "allclass.h"}.
24254 Use the string argument if you want a single implementation file to
24255 include code from multiple header files.  (You must also use
24256 @samp{#include} to include the header file; @samp{#pragma
24257 implementation} only specifies how to use the file---it doesn't actually
24258 include it.)
24260 There is no way to split up the contents of a single header file into
24261 multiple implementation files.
24262 @end table
24264 @cindex inlining and C++ pragmas
24265 @cindex C++ pragmas, effect on inlining
24266 @cindex pragmas in C++, effect on inlining
24267 @samp{#pragma implementation} and @samp{#pragma interface} also have an
24268 effect on function inlining.
24270 If you define a class in a header file marked with @samp{#pragma
24271 interface}, the effect on an inline function defined in that class is
24272 similar to an explicit @code{extern} declaration---the compiler emits
24273 no code at all to define an independent version of the function.  Its
24274 definition is used only for inlining with its callers.
24276 @opindex fno-implement-inlines
24277 Conversely, when you include the same header file in a main source file
24278 that declares it as @samp{#pragma implementation}, the compiler emits
24279 code for the function itself; this defines a version of the function
24280 that can be found via pointers (or by callers compiled without
24281 inlining).  If all calls to the function can be inlined, you can avoid
24282 emitting the function by compiling with @option{-fno-implement-inlines}.
24283 If any calls are not inlined, you will get linker errors.
24285 @node Template Instantiation
24286 @section Where's the Template?
24287 @cindex template instantiation
24289 C++ templates were the first language feature to require more
24290 intelligence from the environment than was traditionally found on a UNIX
24291 system.  Somehow the compiler and linker have to make sure that each
24292 template instance occurs exactly once in the executable if it is needed,
24293 and not at all otherwise.  There are two basic approaches to this
24294 problem, which are referred to as the Borland model and the Cfront model.
24296 @table @asis
24297 @item Borland model
24298 Borland C++ solved the template instantiation problem by adding the code
24299 equivalent of common blocks to their linker; the compiler emits template
24300 instances in each translation unit that uses them, and the linker
24301 collapses them together.  The advantage of this model is that the linker
24302 only has to consider the object files themselves; there is no external
24303 complexity to worry about.  The disadvantage is that compilation time
24304 is increased because the template code is being compiled repeatedly.
24305 Code written for this model tends to include definitions of all
24306 templates in the header file, since they must be seen to be
24307 instantiated.
24309 @item Cfront model
24310 The AT&T C++ translator, Cfront, solved the template instantiation
24311 problem by creating the notion of a template repository, an
24312 automatically maintained place where template instances are stored.  A
24313 more modern version of the repository works as follows: As individual
24314 object files are built, the compiler places any template definitions and
24315 instantiations encountered in the repository.  At link time, the link
24316 wrapper adds in the objects in the repository and compiles any needed
24317 instances that were not previously emitted.  The advantages of this
24318 model are more optimal compilation speed and the ability to use the
24319 system linker; to implement the Borland model a compiler vendor also
24320 needs to replace the linker.  The disadvantages are vastly increased
24321 complexity, and thus potential for error; for some code this can be
24322 just as transparent, but in practice it can been very difficult to build
24323 multiple programs in one directory and one program in multiple
24324 directories.  Code written for this model tends to separate definitions
24325 of non-inline member templates into a separate file, which should be
24326 compiled separately.
24327 @end table
24329 G++ implements the Borland model on targets where the linker supports it,
24330 including ELF targets (such as GNU/Linux), Mac OS X and Microsoft Windows.
24331 Otherwise G++ implements neither automatic model.
24333 You have the following options for dealing with template instantiations:
24335 @enumerate
24336 @item
24337 Do nothing.  Code written for the Borland model works fine, but
24338 each translation unit contains instances of each of the templates it
24339 uses.  The duplicate instances will be discarded by the linker, but in
24340 a large program, this can lead to an unacceptable amount of code
24341 duplication in object files or shared libraries.
24343 Duplicate instances of a template can be avoided by defining an explicit
24344 instantiation in one object file, and preventing the compiler from doing
24345 implicit instantiations in any other object files by using an explicit
24346 instantiation declaration, using the @code{extern template} syntax:
24348 @smallexample
24349 extern template int max (int, int);
24350 @end smallexample
24352 This syntax is defined in the C++ 2011 standard, but has been supported by
24353 G++ and other compilers since well before 2011.
24355 Explicit instantiations can be used for the largest or most frequently
24356 duplicated instances, without having to know exactly which other instances
24357 are used in the rest of the program.  You can scatter the explicit
24358 instantiations throughout your program, perhaps putting them in the
24359 translation units where the instances are used or the translation units
24360 that define the templates themselves; you can put all of the explicit
24361 instantiations you need into one big file; or you can create small files
24362 like
24364 @smallexample
24365 #include "Foo.h"
24366 #include "Foo.cc"
24368 template class Foo<int>;
24369 template ostream& operator <<
24370                 (ostream&, const Foo<int>&);
24371 @end smallexample
24373 @noindent
24374 for each of the instances you need, and create a template instantiation
24375 library from those.
24377 This is the simplest option, but also offers flexibility and
24378 fine-grained control when necessary. It is also the most portable
24379 alternative and programs using this approach will work with most modern
24380 compilers.
24382 @item
24383 @opindex frepo
24384 Compile your template-using code with @option{-frepo}.  The compiler
24385 generates files with the extension @samp{.rpo} listing all of the
24386 template instantiations used in the corresponding object files that
24387 could be instantiated there; the link wrapper, @samp{collect2},
24388 then updates the @samp{.rpo} files to tell the compiler where to place
24389 those instantiations and rebuild any affected object files.  The
24390 link-time overhead is negligible after the first pass, as the compiler
24391 continues to place the instantiations in the same files.
24393 This can be a suitable option for application code written for the Borland
24394 model, as it usually just works.  Code written for the Cfront model 
24395 needs to be modified so that the template definitions are available at
24396 one or more points of instantiation; usually this is as simple as adding
24397 @code{#include <tmethods.cc>} to the end of each template header.
24399 For library code, if you want the library to provide all of the template
24400 instantiations it needs, just try to link all of its object files
24401 together; the link will fail, but cause the instantiations to be
24402 generated as a side effect.  Be warned, however, that this may cause
24403 conflicts if multiple libraries try to provide the same instantiations.
24404 For greater control, use explicit instantiation as described in the next
24405 option.
24407 @item
24408 @opindex fno-implicit-templates
24409 Compile your code with @option{-fno-implicit-templates} to disable the
24410 implicit generation of template instances, and explicitly instantiate
24411 all the ones you use.  This approach requires more knowledge of exactly
24412 which instances you need than do the others, but it's less
24413 mysterious and allows greater control if you want to ensure that only
24414 the intended instances are used.
24416 If you are using Cfront-model code, you can probably get away with not
24417 using @option{-fno-implicit-templates} when compiling files that don't
24418 @samp{#include} the member template definitions.
24420 If you use one big file to do the instantiations, you may want to
24421 compile it without @option{-fno-implicit-templates} so you get all of the
24422 instances required by your explicit instantiations (but not by any
24423 other files) without having to specify them as well.
24425 In addition to forward declaration of explicit instantiations
24426 (with @code{extern}), G++ has extended the template instantiation
24427 syntax to support instantiation of the compiler support data for a
24428 template class (i.e.@: the vtable) without instantiating any of its
24429 members (with @code{inline}), and instantiation of only the static data
24430 members of a template class, without the support data or member
24431 functions (with @code{static}):
24433 @smallexample
24434 inline template class Foo<int>;
24435 static template class Foo<int>;
24436 @end smallexample
24437 @end enumerate
24439 @node Bound member functions
24440 @section Extracting the Function Pointer from a Bound Pointer to Member Function
24441 @cindex pmf
24442 @cindex pointer to member function
24443 @cindex bound pointer to member function
24445 In C++, pointer to member functions (PMFs) are implemented using a wide
24446 pointer of sorts to handle all the possible call mechanisms; the PMF
24447 needs to store information about how to adjust the @samp{this} pointer,
24448 and if the function pointed to is virtual, where to find the vtable, and
24449 where in the vtable to look for the member function.  If you are using
24450 PMFs in an inner loop, you should really reconsider that decision.  If
24451 that is not an option, you can extract the pointer to the function that
24452 would be called for a given object/PMF pair and call it directly inside
24453 the inner loop, to save a bit of time.
24455 Note that you still pay the penalty for the call through a
24456 function pointer; on most modern architectures, such a call defeats the
24457 branch prediction features of the CPU@.  This is also true of normal
24458 virtual function calls.
24460 The syntax for this extension is
24462 @smallexample
24463 extern A a;
24464 extern int (A::*fp)();
24465 typedef int (*fptr)(A *);
24467 fptr p = (fptr)(a.*fp);
24468 @end smallexample
24470 For PMF constants (i.e.@: expressions of the form @samp{&Klasse::Member}),
24471 no object is needed to obtain the address of the function.  They can be
24472 converted to function pointers directly:
24474 @smallexample
24475 fptr p1 = (fptr)(&A::foo);
24476 @end smallexample
24478 @opindex Wno-pmf-conversions
24479 You must specify @option{-Wno-pmf-conversions} to use this extension.
24481 @node C++ Attributes
24482 @section C++-Specific Variable, Function, and Type Attributes
24484 Some attributes only make sense for C++ programs.
24486 @table @code
24487 @item abi_tag ("@var{tag}", ...)
24488 @cindex @code{abi_tag} function attribute
24489 @cindex @code{abi_tag} variable attribute
24490 @cindex @code{abi_tag} type attribute
24491 The @code{abi_tag} attribute can be applied to a function, variable, or class
24492 declaration.  It modifies the mangled name of the entity to
24493 incorporate the tag name, in order to distinguish the function or
24494 class from an earlier version with a different ABI; perhaps the class
24495 has changed size, or the function has a different return type that is
24496 not encoded in the mangled name.
24498 The attribute can also be applied to an inline namespace, but does not
24499 affect the mangled name of the namespace; in this case it is only used
24500 for @option{-Wabi-tag} warnings and automatic tagging of functions and
24501 variables.  Tagging inline namespaces is generally preferable to
24502 tagging individual declarations, but the latter is sometimes
24503 necessary, such as when only certain members of a class need to be
24504 tagged.
24506 The argument can be a list of strings of arbitrary length.  The
24507 strings are sorted on output, so the order of the list is
24508 unimportant.
24510 A redeclaration of an entity must not add new ABI tags,
24511 since doing so would change the mangled name.
24513 The ABI tags apply to a name, so all instantiations and
24514 specializations of a template have the same tags.  The attribute will
24515 be ignored if applied to an explicit specialization or instantiation.
24517 The @option{-Wabi-tag} flag enables a warning about a class which does
24518 not have all the ABI tags used by its subobjects and virtual functions; for users with code
24519 that needs to coexist with an earlier ABI, using this option can help
24520 to find all affected types that need to be tagged.
24522 When a type involving an ABI tag is used as the type of a variable or
24523 return type of a function where that tag is not already present in the
24524 signature of the function, the tag is automatically applied to the
24525 variable or function.  @option{-Wabi-tag} also warns about this
24526 situation; this warning can be avoided by explicitly tagging the
24527 variable or function or moving it into a tagged inline namespace.
24529 @item init_priority (@var{priority})
24530 @cindex @code{init_priority} variable attribute
24532 In Standard C++, objects defined at namespace scope are guaranteed to be
24533 initialized in an order in strict accordance with that of their definitions
24534 @emph{in a given translation unit}.  No guarantee is made for initializations
24535 across translation units.  However, GNU C++ allows users to control the
24536 order of initialization of objects defined at namespace scope with the
24537 @code{init_priority} attribute by specifying a relative @var{priority},
24538 a constant integral expression currently bounded between 101 and 65535
24539 inclusive.  Lower numbers indicate a higher priority.
24541 In the following example, @code{A} would normally be created before
24542 @code{B}, but the @code{init_priority} attribute reverses that order:
24544 @smallexample
24545 Some_Class  A  __attribute__ ((init_priority (2000)));
24546 Some_Class  B  __attribute__ ((init_priority (543)));
24547 @end smallexample
24549 @noindent
24550 Note that the particular values of @var{priority} do not matter; only their
24551 relative ordering.
24553 @item warn_unused
24554 @cindex @code{warn_unused} type attribute
24556 For C++ types with non-trivial constructors and/or destructors it is
24557 impossible for the compiler to determine whether a variable of this
24558 type is truly unused if it is not referenced. This type attribute
24559 informs the compiler that variables of this type should be warned
24560 about if they appear to be unused, just like variables of fundamental
24561 types.
24563 This attribute is appropriate for types which just represent a value,
24564 such as @code{std::string}; it is not appropriate for types which
24565 control a resource, such as @code{std::lock_guard}.
24567 This attribute is also accepted in C, but it is unnecessary because C
24568 does not have constructors or destructors.
24570 @end table
24572 @node Function Multiversioning
24573 @section Function Multiversioning
24574 @cindex function versions
24576 With the GNU C++ front end, for x86 targets, you may specify multiple
24577 versions of a function, where each function is specialized for a
24578 specific target feature.  At runtime, the appropriate version of the
24579 function is automatically executed depending on the characteristics of
24580 the execution platform.  Here is an example.
24582 @smallexample
24583 __attribute__ ((target ("default")))
24584 int foo ()
24586   // The default version of foo.
24587   return 0;
24590 __attribute__ ((target ("sse4.2")))
24591 int foo ()
24593   // foo version for SSE4.2
24594   return 1;
24597 __attribute__ ((target ("arch=atom")))
24598 int foo ()
24600   // foo version for the Intel ATOM processor
24601   return 2;
24604 __attribute__ ((target ("arch=amdfam10")))
24605 int foo ()
24607   // foo version for the AMD Family 0x10 processors.
24608   return 3;
24611 int main ()
24613   int (*p)() = &foo;
24614   assert ((*p) () == foo ());
24615   return 0;
24617 @end smallexample
24619 In the above example, four versions of function foo are created. The
24620 first version of foo with the target attribute "default" is the default
24621 version.  This version gets executed when no other target specific
24622 version qualifies for execution on a particular platform. A new version
24623 of foo is created by using the same function signature but with a
24624 different target string.  Function foo is called or a pointer to it is
24625 taken just like a regular function.  GCC takes care of doing the
24626 dispatching to call the right version at runtime.  Refer to the
24627 @uref{http://gcc.gnu.org/wiki/FunctionMultiVersioning, GCC wiki on
24628 Function Multiversioning} for more details.
24630 @node Type Traits
24631 @section Type Traits
24633 The C++ front end implements syntactic extensions that allow
24634 compile-time determination of 
24635 various characteristics of a type (or of a
24636 pair of types).
24638 @table @code
24639 @item __has_nothrow_assign (type)
24640 If @code{type} is @code{const}-qualified or is a reference type then
24641 the trait is @code{false}.  Otherwise if @code{__has_trivial_assign (type)}
24642 is @code{true} then the trait is @code{true}, else if @code{type} is
24643 a cv-qualified class or union type with copy assignment operators that are
24644 known not to throw an exception then the trait is @code{true}, else it is
24645 @code{false}.
24646 Requires: @code{type} shall be a complete type, (possibly cv-qualified)
24647 @code{void}, or an array of unknown bound.
24649 @item __has_nothrow_copy (type)
24650 If @code{__has_trivial_copy (type)} is @code{true} then the trait is
24651 @code{true}, else if @code{type} is a cv-qualified class or union type
24652 with copy constructors that are known not to throw an exception then
24653 the trait is @code{true}, else it is @code{false}.
24654 Requires: @code{type} shall be a complete type, (possibly cv-qualified)
24655 @code{void}, or an array of unknown bound.
24657 @item __has_nothrow_constructor (type)
24658 If @code{__has_trivial_constructor (type)} is @code{true} then the trait
24659 is @code{true}, else if @code{type} is a cv class or union type (or array
24660 thereof) with a default constructor that is known not to throw an
24661 exception then the trait is @code{true}, else it is @code{false}.
24662 Requires: @code{type} shall be a complete type, (possibly cv-qualified)
24663 @code{void}, or an array of unknown bound.
24665 @item __has_trivial_assign (type)
24666 If @code{type} is @code{const}- qualified or is a reference type then
24667 the trait is @code{false}.  Otherwise if @code{__is_pod (type)} is
24668 @code{true} then the trait is @code{true}, else if @code{type} is
24669 a cv-qualified class or union type with a trivial copy assignment
24670 ([class.copy]) then the trait is @code{true}, else it is @code{false}.
24671 Requires: @code{type} shall be a complete type, (possibly cv-qualified)
24672 @code{void}, or an array of unknown bound.
24674 @item __has_trivial_copy (type)
24675 If @code{__is_pod (type)} is @code{true} or @code{type} is a reference
24676 type then the trait is @code{true}, else if @code{type} is a cv class
24677 or union type with a trivial copy constructor ([class.copy]) then the trait
24678 is @code{true}, else it is @code{false}.  Requires: @code{type} shall be
24679 a complete type, (possibly cv-qualified) @code{void}, or an array of unknown
24680 bound.
24682 @item __has_trivial_constructor (type)
24683 If @code{__is_pod (type)} is @code{true} then the trait is @code{true},
24684 else if @code{type} is a cv-qualified class or union type (or array thereof)
24685 with a trivial default constructor ([class.ctor]) then the trait is @code{true},
24686 else it is @code{false}.
24687 Requires: @code{type} shall be a complete type, (possibly cv-qualified)
24688 @code{void}, or an array of unknown bound.
24690 @item __has_trivial_destructor (type)
24691 If @code{__is_pod (type)} is @code{true} or @code{type} is a reference type
24692 then the trait is @code{true}, else if @code{type} is a cv class or union
24693 type (or array thereof) with a trivial destructor ([class.dtor]) then
24694 the trait is @code{true}, else it is @code{false}.
24695 Requires: @code{type} shall be a complete type, (possibly cv-qualified)
24696 @code{void}, or an array of unknown bound.
24698 @item __has_virtual_destructor (type)
24699 If @code{type} is a class type with a virtual destructor
24700 ([class.dtor]) then the trait is @code{true}, else it is @code{false}.
24701 Requires: @code{type} shall be a complete type, (possibly cv-qualified)
24702 @code{void}, or an array of unknown bound.
24704 @item __is_abstract (type)
24705 If @code{type} is an abstract class ([class.abstract]) then the trait
24706 is @code{true}, else it is @code{false}.
24707 Requires: @code{type} shall be a complete type, (possibly cv-qualified)
24708 @code{void}, or an array of unknown bound.
24710 @item __is_base_of (base_type, derived_type)
24711 If @code{base_type} is a base class of @code{derived_type}
24712 ([class.derived]) then the trait is @code{true}, otherwise it is @code{false}.
24713 Top-level cv-qualifications of @code{base_type} and
24714 @code{derived_type} are ignored.  For the purposes of this trait, a
24715 class type is considered is own base.
24716 Requires: if @code{__is_class (base_type)} and @code{__is_class (derived_type)}
24717 are @code{true} and @code{base_type} and @code{derived_type} are not the same
24718 type (disregarding cv-qualifiers), @code{derived_type} shall be a complete
24719 type.  A diagnostic is produced if this requirement is not met.
24721 @item __is_class (type)
24722 If @code{type} is a cv-qualified class type, and not a union type
24723 ([basic.compound]) the trait is @code{true}, else it is @code{false}.
24725 @item __is_empty (type)
24726 If @code{__is_class (type)} is @code{false} then the trait is @code{false}.
24727 Otherwise @code{type} is considered empty if and only if: @code{type}
24728 has no non-static data members, or all non-static data members, if
24729 any, are bit-fields of length 0, and @code{type} has no virtual
24730 members, and @code{type} has no virtual base classes, and @code{type}
24731 has no base classes @code{base_type} for which
24732 @code{__is_empty (base_type)} is @code{false}.
24733 Requires: @code{type} shall be a complete type, (possibly cv-qualified)
24734 @code{void}, or an array of unknown bound.
24736 @item __is_enum (type)
24737 If @code{type} is a cv enumeration type ([basic.compound]) the trait is
24738 @code{true}, else it is @code{false}.
24740 @item __is_literal_type (type)
24741 If @code{type} is a literal type ([basic.types]) the trait is
24742 @code{true}, else it is @code{false}.
24743 Requires: @code{type} shall be a complete type, (possibly cv-qualified)
24744 @code{void}, or an array of unknown bound.
24746 @item __is_pod (type)
24747 If @code{type} is a cv POD type ([basic.types]) then the trait is @code{true},
24748 else it is @code{false}.
24749 Requires: @code{type} shall be a complete type, (possibly cv-qualified)
24750 @code{void}, or an array of unknown bound.
24752 @item __is_polymorphic (type)
24753 If @code{type} is a polymorphic class ([class.virtual]) then the trait
24754 is @code{true}, else it is @code{false}.
24755 Requires: @code{type} shall be a complete type, (possibly cv-qualified)
24756 @code{void}, or an array of unknown bound.
24758 @item __is_standard_layout (type)
24759 If @code{type} is a standard-layout type ([basic.types]) the trait is
24760 @code{true}, else it is @code{false}.
24761 Requires: @code{type} shall be a complete type, (possibly cv-qualified)
24762 @code{void}, or an array of unknown bound.
24764 @item __is_trivial (type)
24765 If @code{type} is a trivial type ([basic.types]) the trait is
24766 @code{true}, else it is @code{false}.
24767 Requires: @code{type} shall be a complete type, (possibly cv-qualified)
24768 @code{void}, or an array of unknown bound.
24770 @item __is_union (type)
24771 If @code{type} is a cv union type ([basic.compound]) the trait is
24772 @code{true}, else it is @code{false}.
24774 @item __underlying_type (type)
24775 The underlying type of @code{type}.
24776 Requires: @code{type} shall be an enumeration type ([dcl.enum]).
24778 @item __integer_pack (length)
24779 When used as the pattern of a pack expansion within a template
24780 definition, expands to a template argument pack containing integers
24781 from @code{0} to @code{length-1}.  This is provided for efficient
24782 implementation of @code{std::make_integer_sequence}.
24784 @end table
24787 @node C++ Concepts
24788 @section C++ Concepts
24790 C++ concepts provide much-improved support for generic programming. In
24791 particular, they allow the specification of constraints on template arguments.
24792 The constraints are used to extend the usual overloading and partial
24793 specialization capabilities of the language, allowing generic data structures
24794 and algorithms to be ``refined'' based on their properties rather than their
24795 type names.
24797 The following keywords are reserved for concepts.
24799 @table @code
24800 @item assumes
24801 States an expression as an assumption, and if possible, verifies that the
24802 assumption is valid. For example, @code{assume(n > 0)}.
24804 @item axiom
24805 Introduces an axiom definition. Axioms introduce requirements on values.
24807 @item forall
24808 Introduces a universally quantified object in an axiom. For example,
24809 @code{forall (int n) n + 0 == n}).
24811 @item concept
24812 Introduces a concept definition. Concepts are sets of syntactic and semantic
24813 requirements on types and their values.
24815 @item requires
24816 Introduces constraints on template arguments or requirements for a member
24817 function of a class template.
24819 @end table
24821 The front end also exposes a number of internal mechanism that can be used
24822 to simplify the writing of type traits. Note that some of these traits are
24823 likely to be removed in the future.
24825 @table @code
24826 @item __is_same (type1, type2)
24827 A binary type trait: @code{true} whenever the type arguments are the same.
24829 @end table
24832 @node Deprecated Features
24833 @section Deprecated Features
24835 In the past, the GNU C++ compiler was extended to experiment with new
24836 features, at a time when the C++ language was still evolving.  Now that
24837 the C++ standard is complete, some of those features are superseded by
24838 superior alternatives.  Using the old features might cause a warning in
24839 some cases that the feature will be dropped in the future.  In other
24840 cases, the feature might be gone already.
24842 G++ allows a virtual function returning @samp{void *} to be overridden
24843 by one returning a different pointer type.  This extension to the
24844 covariant return type rules is now deprecated and will be removed from a
24845 future version.
24847 The use of default arguments in function pointers, function typedefs
24848 and other places where they are not permitted by the standard is
24849 deprecated and will be removed from a future version of G++.
24851 G++ allows floating-point literals to appear in integral constant expressions,
24852 e.g.@: @samp{ enum E @{ e = int(2.2 * 3.7) @} }
24853 This extension is deprecated and will be removed from a future version.
24855 G++ allows static data members of const floating-point type to be declared
24856 with an initializer in a class definition. The standard only allows
24857 initializers for static members of const integral types and const
24858 enumeration types so this extension has been deprecated and will be removed
24859 from a future version.
24861 G++ allows attributes to follow a parenthesized direct initializer,
24862 e.g.@: @samp{ int f (0) __attribute__ ((something)); } This extension
24863 has been ignored since G++ 3.3 and is deprecated.
24865 G++ allows anonymous structs and unions to have members that are not
24866 public non-static data members (i.e.@: fields).  These extensions are
24867 deprecated.
24869 @node Backwards Compatibility
24870 @section Backwards Compatibility
24871 @cindex Backwards Compatibility
24872 @cindex ARM [Annotated C++ Reference Manual]
24874 Now that there is a definitive ISO standard C++, G++ has a specification
24875 to adhere to.  The C++ language evolved over time, and features that
24876 used to be acceptable in previous drafts of the standard, such as the ARM
24877 [Annotated C++ Reference Manual], are no longer accepted.  In order to allow
24878 compilation of C++ written to such drafts, G++ contains some backwards
24879 compatibilities.  @emph{All such backwards compatibility features are
24880 liable to disappear in future versions of G++.} They should be considered
24881 deprecated.   @xref{Deprecated Features}.
24883 @table @code
24885 @item Implicit C language
24886 Old C system header files did not contain an @code{extern "C" @{@dots{}@}}
24887 scope to set the language.  On such systems, all system header files are
24888 implicitly scoped inside a C language scope.  Such headers must
24889 correctly prototype function argument types, there is no leeway for
24890 @code{()} to indicate an unspecified set of arguments.
24892 @end table
24894 @c  LocalWords:  emph deftypefn builtin ARCv2EM SIMD builtins msimd
24895 @c  LocalWords:  typedef v4si v8hi DMA dma vdiwr vdowr