Daily bump.
[official-gcc.git] / gcc / doc / extend.texi
blobdce808f1eab1ff734fb5acf97a2d8a6ea270a788
1 c Copyright (C) 1988-2018 Free Software Foundation, Inc.
3 @c This is part of the GCC manual.
4 @c For copying conditions, see the file gcc.texi.
6 @node C Extensions
7 @chapter Extensions to the C Language Family
8 @cindex extensions, C language
9 @cindex C language extensions
11 @opindex pedantic
12 GNU C provides several language features not found in ISO standard C@.
13 (The @option{-pedantic} option directs GCC to print a warning message if
14 any of these features is used.)  To test for the availability of these
15 features in conditional compilation, check for a predefined macro
16 @code{__GNUC__}, which is always defined under GCC@.
18 These extensions are available in C and Objective-C@.  Most of them are
19 also available in C++.  @xref{C++ Extensions,,Extensions to the
20 C++ Language}, for extensions that apply @emph{only} to C++.
22 Some features that are in ISO C99 but not C90 or C++ are also, as
23 extensions, accepted by GCC in C90 mode and in C++.
25 @menu
26 * Statement Exprs::     Putting statements and declarations inside expressions.
27 * Local Labels::        Labels local to a block.
28 * Labels as Values::    Getting pointers to labels, and computed gotos.
29 * Nested Functions::    As in Algol and Pascal, lexical scoping of functions.
30 * Constructing Calls::  Dispatching a call to another function.
31 * Typeof::              @code{typeof}: referring to the type of an expression.
32 * Conditionals::        Omitting the middle operand of a @samp{?:} expression.
33 * __int128::            128-bit integers---@code{__int128}.
34 * Long Long::           Double-word integers---@code{long long int}.
35 * Complex::             Data types for complex numbers.
36 * Floating Types::      Additional Floating Types.
37 * Half-Precision::      Half-Precision Floating Point.
38 * Decimal Float::       Decimal Floating Types.
39 * Hex Floats::          Hexadecimal floating-point constants.
40 * Fixed-Point::         Fixed-Point Types.
41 * Named Address Spaces::Named address spaces.
42 * Zero Length::         Zero-length arrays.
43 * Empty Structures::    Structures with no members.
44 * Variable Length::     Arrays whose length is computed at run time.
45 * Variadic Macros::     Macros with a variable number of arguments.
46 * Escaped Newlines::    Slightly looser rules for escaped newlines.
47 * Subscripting::        Any array can be subscripted, even if not an lvalue.
48 * Pointer Arith::       Arithmetic on @code{void}-pointers and function pointers.
49 * Pointers to Arrays::  Pointers to arrays with qualifiers work as expected.
50 * Initializers::        Non-constant initializers.
51 * Compound Literals::   Compound literals give structures, unions
52                         or arrays as values.
53 * Designated Inits::    Labeling elements of initializers.
54 * Case Ranges::         `case 1 ... 9' and such.
55 * Cast to Union::       Casting to union type from any member of the union.
56 * Mixed Declarations::  Mixing declarations and code.
57 * Function Attributes:: Declaring that functions have no side effects,
58                         or that they can never return.
59 * Variable Attributes:: Specifying attributes of variables.
60 * Type Attributes::     Specifying attributes of types.
61 * Label Attributes::    Specifying attributes on labels.
62 * Enumerator Attributes:: Specifying attributes on enumerators.
63 * Statement Attributes:: Specifying attributes on statements.
64 * Attribute Syntax::    Formal syntax for attributes.
65 * Function Prototypes:: Prototype declarations and old-style definitions.
66 * C++ Comments::        C++ comments are recognized.
67 * Dollar Signs::        Dollar sign is allowed in identifiers.
68 * Character Escapes::   @samp{\e} stands for the character @key{ESC}.
69 * Alignment::           Inquiring about the alignment of a type or variable.
70 * Inline::              Defining inline functions (as fast as macros).
71 * Volatiles::           What constitutes an access to a volatile object.
72 * Using Assembly Language with C:: Instructions and extensions for interfacing C with assembler.
73 * Alternate Keywords::  @code{__const__}, @code{__asm__}, etc., for header files.
74 * Incomplete Enums::    @code{enum foo;}, with details to follow.
75 * Function Names::      Printable strings which are the name of the current
76                         function.
77 * Return Address::      Getting the return or frame address of a function.
78 * Vector Extensions::   Using vector instructions through built-in functions.
79 * Offsetof::            Special syntax for implementing @code{offsetof}.
80 * __sync Builtins::     Legacy built-in functions for atomic memory access.
81 * __atomic Builtins::   Atomic built-in functions with memory model.
82 * Integer Overflow Builtins:: Built-in functions to perform arithmetics and
83                         arithmetic overflow checking.
84 * x86 specific memory model extensions for transactional memory:: x86 memory models.
85 * Object Size Checking:: Built-in functions for limited buffer overflow
86                         checking.
87 * Pointer Bounds Checker builtins:: Built-in functions for Pointer Bounds Checker.
88 * Other Builtins::      Other built-in functions.
89 * Target Builtins::     Built-in functions specific to particular targets.
90 * Target Format Checks:: Format checks specific to particular targets.
91 * Pragmas::             Pragmas accepted by GCC.
92 * Unnamed Fields::      Unnamed struct/union fields within structs/unions.
93 * Thread-Local::        Per-thread variables.
94 * Binary constants::    Binary constants using the @samp{0b} prefix.
95 @end menu
97 @node Statement Exprs
98 @section Statements and Declarations in Expressions
99 @cindex statements inside expressions
100 @cindex declarations inside expressions
101 @cindex expressions containing statements
102 @cindex macros, statements in expressions
104 @c the above section title wrapped and causes an underfull hbox.. i
105 @c changed it from "within" to "in". --mew 4feb93
106 A compound statement enclosed in parentheses may appear as an expression
107 in GNU C@.  This allows you to use loops, switches, and local variables
108 within an expression.
110 Recall that a compound statement is a sequence of statements surrounded
111 by braces; in this construct, parentheses go around the braces.  For
112 example:
114 @smallexample
115 (@{ int y = foo (); int z;
116    if (y > 0) z = y;
117    else z = - y;
118    z; @})
119 @end smallexample
121 @noindent
122 is a valid (though slightly more complex than necessary) expression
123 for the absolute value of @code{foo ()}.
125 The last thing in the compound statement should be an expression
126 followed by a semicolon; the value of this subexpression serves as the
127 value of the entire construct.  (If you use some other kind of statement
128 last within the braces, the construct has type @code{void}, and thus
129 effectively no value.)
131 This feature is especially useful in making macro definitions ``safe'' (so
132 that they evaluate each operand exactly once).  For example, the
133 ``maximum'' function is commonly defined as a macro in standard C as
134 follows:
136 @smallexample
137 #define max(a,b) ((a) > (b) ? (a) : (b))
138 @end smallexample
140 @noindent
141 @cindex side effects, macro argument
142 But this definition computes either @var{a} or @var{b} twice, with bad
143 results if the operand has side effects.  In GNU C, if you know the
144 type of the operands (here taken as @code{int}), you can define
145 the macro safely as follows:
147 @smallexample
148 #define maxint(a,b) \
149   (@{int _a = (a), _b = (b); _a > _b ? _a : _b; @})
150 @end smallexample
152 Embedded statements are not allowed in constant expressions, such as
153 the value of an enumeration constant, the width of a bit-field, or
154 the initial value of a static variable.
156 If you don't know the type of the operand, you can still do this, but you
157 must use @code{typeof} or @code{__auto_type} (@pxref{Typeof}).
159 In G++, the result value of a statement expression undergoes array and
160 function pointer decay, and is returned by value to the enclosing
161 expression.  For instance, if @code{A} is a class, then
163 @smallexample
164         A a;
166         (@{a;@}).Foo ()
167 @end smallexample
169 @noindent
170 constructs a temporary @code{A} object to hold the result of the
171 statement expression, and that is used to invoke @code{Foo}.
172 Therefore the @code{this} pointer observed by @code{Foo} is not the
173 address of @code{a}.
175 In a statement expression, any temporaries created within a statement
176 are destroyed at that statement's end.  This makes statement
177 expressions inside macros slightly different from function calls.  In
178 the latter case temporaries introduced during argument evaluation are
179 destroyed at the end of the statement that includes the function
180 call.  In the statement expression case they are destroyed during
181 the statement expression.  For instance,
183 @smallexample
184 #define macro(a)  (@{__typeof__(a) b = (a); b + 3; @})
185 template<typename T> T function(T a) @{ T b = a; return b + 3; @}
187 void foo ()
189   macro (X ());
190   function (X ());
192 @end smallexample
194 @noindent
195 has different places where temporaries are destroyed.  For the
196 @code{macro} case, the temporary @code{X} is destroyed just after
197 the initialization of @code{b}.  In the @code{function} case that
198 temporary is destroyed when the function returns.
200 These considerations mean that it is probably a bad idea to use
201 statement expressions of this form in header files that are designed to
202 work with C++.  (Note that some versions of the GNU C Library contained
203 header files using statement expressions that lead to precisely this
204 bug.)
206 Jumping into a statement expression with @code{goto} or using a
207 @code{switch} statement outside the statement expression with a
208 @code{case} or @code{default} label inside the statement expression is
209 not permitted.  Jumping into a statement expression with a computed
210 @code{goto} (@pxref{Labels as Values}) has undefined behavior.
211 Jumping out of a statement expression is permitted, but if the
212 statement expression is part of a larger expression then it is
213 unspecified which other subexpressions of that expression have been
214 evaluated except where the language definition requires certain
215 subexpressions to be evaluated before or after the statement
216 expression.  In any case, as with a function call, the evaluation of a
217 statement expression is not interleaved with the evaluation of other
218 parts of the containing expression.  For example,
220 @smallexample
221   foo (), ((@{ bar1 (); goto a; 0; @}) + bar2 ()), baz();
222 @end smallexample
224 @noindent
225 calls @code{foo} and @code{bar1} and does not call @code{baz} but
226 may or may not call @code{bar2}.  If @code{bar2} is called, it is
227 called after @code{foo} and before @code{bar1}.
229 @node Local Labels
230 @section Locally Declared Labels
231 @cindex local labels
232 @cindex macros, local labels
234 GCC allows you to declare @dfn{local labels} in any nested block
235 scope.  A local label is just like an ordinary label, but you can
236 only reference it (with a @code{goto} statement, or by taking its
237 address) within the block in which it is declared.
239 A local label declaration looks like this:
241 @smallexample
242 __label__ @var{label};
243 @end smallexample
245 @noindent
248 @smallexample
249 __label__ @var{label1}, @var{label2}, /* @r{@dots{}} */;
250 @end smallexample
252 Local label declarations must come at the beginning of the block,
253 before any ordinary declarations or statements.
255 The label declaration defines the label @emph{name}, but does not define
256 the label itself.  You must do this in the usual way, with
257 @code{@var{label}:}, within the statements of the statement expression.
259 The local label feature is useful for complex macros.  If a macro
260 contains nested loops, a @code{goto} can be useful for breaking out of
261 them.  However, an ordinary label whose scope is the whole function
262 cannot be used: if the macro can be expanded several times in one
263 function, the label is multiply defined in that function.  A
264 local label avoids this problem.  For example:
266 @smallexample
267 #define SEARCH(value, array, target)              \
268 do @{                                              \
269   __label__ found;                                \
270   typeof (target) _SEARCH_target = (target);      \
271   typeof (*(array)) *_SEARCH_array = (array);     \
272   int i, j;                                       \
273   int value;                                      \
274   for (i = 0; i < max; i++)                       \
275     for (j = 0; j < max; j++)                     \
276       if (_SEARCH_array[i][j] == _SEARCH_target)  \
277         @{ (value) = i; goto found; @}              \
278   (value) = -1;                                   \
279  found:;                                          \
280 @} while (0)
281 @end smallexample
283 This could also be written using a statement expression:
285 @smallexample
286 #define SEARCH(array, target)                     \
287 (@{                                                \
288   __label__ found;                                \
289   typeof (target) _SEARCH_target = (target);      \
290   typeof (*(array)) *_SEARCH_array = (array);     \
291   int i, j;                                       \
292   int value;                                      \
293   for (i = 0; i < max; i++)                       \
294     for (j = 0; j < max; j++)                     \
295       if (_SEARCH_array[i][j] == _SEARCH_target)  \
296         @{ value = i; goto found; @}                \
297   value = -1;                                     \
298  found:                                           \
299   value;                                          \
301 @end smallexample
303 Local label declarations also make the labels they declare visible to
304 nested functions, if there are any.  @xref{Nested Functions}, for details.
306 @node Labels as Values
307 @section Labels as Values
308 @cindex labels as values
309 @cindex computed gotos
310 @cindex goto with computed label
311 @cindex address of a label
313 You can get the address of a label defined in the current function
314 (or a containing function) with the unary operator @samp{&&}.  The
315 value has type @code{void *}.  This value is a constant and can be used
316 wherever a constant of that type is valid.  For example:
318 @smallexample
319 void *ptr;
320 /* @r{@dots{}} */
321 ptr = &&foo;
322 @end smallexample
324 To use these values, you need to be able to jump to one.  This is done
325 with the computed goto statement@footnote{The analogous feature in
326 Fortran is called an assigned goto, but that name seems inappropriate in
327 C, where one can do more than simply store label addresses in label
328 variables.}, @code{goto *@var{exp};}.  For example,
330 @smallexample
331 goto *ptr;
332 @end smallexample
334 @noindent
335 Any expression of type @code{void *} is allowed.
337 One way of using these constants is in initializing a static array that
338 serves as a jump table:
340 @smallexample
341 static void *array[] = @{ &&foo, &&bar, &&hack @};
342 @end smallexample
344 @noindent
345 Then you can select a label with indexing, like this:
347 @smallexample
348 goto *array[i];
349 @end smallexample
351 @noindent
352 Note that this does not check whether the subscript is in bounds---array
353 indexing in C never does that.
355 Such an array of label values serves a purpose much like that of the
356 @code{switch} statement.  The @code{switch} statement is cleaner, so
357 use that rather than an array unless the problem does not fit a
358 @code{switch} statement very well.
360 Another use of label values is in an interpreter for threaded code.
361 The labels within the interpreter function can be stored in the
362 threaded code for super-fast dispatching.
364 You may not use this mechanism to jump to code in a different function.
365 If you do that, totally unpredictable things happen.  The best way to
366 avoid this is to store the label address only in automatic variables and
367 never pass it as an argument.
369 An alternate way to write the above example is
371 @smallexample
372 static const int array[] = @{ &&foo - &&foo, &&bar - &&foo,
373                              &&hack - &&foo @};
374 goto *(&&foo + array[i]);
375 @end smallexample
377 @noindent
378 This is more friendly to code living in shared libraries, as it reduces
379 the number of dynamic relocations that are needed, and by consequence,
380 allows the data to be read-only.
381 This alternative with label differences is not supported for the AVR target,
382 please use the first approach for AVR programs.
384 The @code{&&foo} expressions for the same label might have different
385 values if the containing function is inlined or cloned.  If a program
386 relies on them being always the same,
387 @code{__attribute__((__noinline__,__noclone__))} should be used to
388 prevent inlining and cloning.  If @code{&&foo} is used in a static
389 variable initializer, inlining and cloning is forbidden.
391 @node Nested Functions
392 @section Nested Functions
393 @cindex nested functions
394 @cindex downward funargs
395 @cindex thunks
397 A @dfn{nested function} is a function defined inside another function.
398 Nested functions are supported as an extension in GNU C, but are not
399 supported by GNU C++.
401 The nested function's name is local to the block where it is defined.
402 For example, here we define a nested function named @code{square}, and
403 call it twice:
405 @smallexample
406 @group
407 foo (double a, double b)
409   double square (double z) @{ return z * z; @}
411   return square (a) + square (b);
413 @end group
414 @end smallexample
416 The nested function can access all the variables of the containing
417 function that are visible at the point of its definition.  This is
418 called @dfn{lexical scoping}.  For example, here we show a nested
419 function which uses an inherited variable named @code{offset}:
421 @smallexample
422 @group
423 bar (int *array, int offset, int size)
425   int access (int *array, int index)
426     @{ return array[index + offset]; @}
427   int i;
428   /* @r{@dots{}} */
429   for (i = 0; i < size; i++)
430     /* @r{@dots{}} */ access (array, i) /* @r{@dots{}} */
432 @end group
433 @end smallexample
435 Nested function definitions are permitted within functions in the places
436 where variable definitions are allowed; that is, in any block, mixed
437 with the other declarations and statements in the block.
439 It is possible to call the nested function from outside the scope of its
440 name by storing its address or passing the address to another function:
442 @smallexample
443 hack (int *array, int size)
445   void store (int index, int value)
446     @{ array[index] = value; @}
448   intermediate (store, size);
450 @end smallexample
452 Here, the function @code{intermediate} receives the address of
453 @code{store} as an argument.  If @code{intermediate} calls @code{store},
454 the arguments given to @code{store} are used to store into @code{array}.
455 But this technique works only so long as the containing function
456 (@code{hack}, in this example) does not exit.
458 If you try to call the nested function through its address after the
459 containing function exits, all hell breaks loose.  If you try
460 to call it after a containing scope level exits, and if it refers
461 to some of the variables that are no longer in scope, you may be lucky,
462 but it's not wise to take the risk.  If, however, the nested function
463 does not refer to anything that has gone out of scope, you should be
464 safe.
466 GCC implements taking the address of a nested function using a technique
467 called @dfn{trampolines}.  This technique was described in
468 @cite{Lexical Closures for C++} (Thomas M. Breuel, USENIX
469 C++ Conference Proceedings, October 17-21, 1988).
471 A nested function can jump to a label inherited from a containing
472 function, provided the label is explicitly declared in the containing
473 function (@pxref{Local Labels}).  Such a jump returns instantly to the
474 containing function, exiting the nested function that did the
475 @code{goto} and any intermediate functions as well.  Here is an example:
477 @smallexample
478 @group
479 bar (int *array, int offset, int size)
481   __label__ failure;
482   int access (int *array, int index)
483     @{
484       if (index > size)
485         goto failure;
486       return array[index + offset];
487     @}
488   int i;
489   /* @r{@dots{}} */
490   for (i = 0; i < size; i++)
491     /* @r{@dots{}} */ access (array, i) /* @r{@dots{}} */
492   /* @r{@dots{}} */
493   return 0;
495  /* @r{Control comes here from @code{access}
496     if it detects an error.}  */
497  failure:
498   return -1;
500 @end group
501 @end smallexample
503 A nested function always has no linkage.  Declaring one with
504 @code{extern} or @code{static} is erroneous.  If you need to declare the nested function
505 before its definition, use @code{auto} (which is otherwise meaningless
506 for function declarations).
508 @smallexample
509 bar (int *array, int offset, int size)
511   __label__ failure;
512   auto int access (int *, int);
513   /* @r{@dots{}} */
514   int access (int *array, int index)
515     @{
516       if (index > size)
517         goto failure;
518       return array[index + offset];
519     @}
520   /* @r{@dots{}} */
522 @end smallexample
524 @node Constructing Calls
525 @section Constructing Function Calls
526 @cindex constructing calls
527 @cindex forwarding calls
529 Using the built-in functions described below, you can record
530 the arguments a function received, and call another function
531 with the same arguments, without knowing the number or types
532 of the arguments.
534 You can also record the return value of that function call,
535 and later return that value, without knowing what data type
536 the function tried to return (as long as your caller expects
537 that data type).
539 However, these built-in functions may interact badly with some
540 sophisticated features or other extensions of the language.  It
541 is, therefore, not recommended to use them outside very simple
542 functions acting as mere forwarders for their arguments.
544 @deftypefn {Built-in Function} {void *} __builtin_apply_args ()
545 This built-in function returns a pointer to data
546 describing how to perform a call with the same arguments as are passed
547 to the current function.
549 The function saves the arg pointer register, structure value address,
550 and all registers that might be used to pass arguments to a function
551 into a block of memory allocated on the stack.  Then it returns the
552 address of that block.
553 @end deftypefn
555 @deftypefn {Built-in Function} {void *} __builtin_apply (void (*@var{function})(), void *@var{arguments}, size_t @var{size})
556 This built-in function invokes @var{function}
557 with a copy of the parameters described by @var{arguments}
558 and @var{size}.
560 The value of @var{arguments} should be the value returned by
561 @code{__builtin_apply_args}.  The argument @var{size} specifies the size
562 of the stack argument data, in bytes.
564 This function returns a pointer to data describing
565 how to return whatever value is returned by @var{function}.  The data
566 is saved in a block of memory allocated on the stack.
568 It is not always simple to compute the proper value for @var{size}.  The
569 value is used by @code{__builtin_apply} to compute the amount of data
570 that should be pushed on the stack and copied from the incoming argument
571 area.
572 @end deftypefn
574 @deftypefn {Built-in Function} {void} __builtin_return (void *@var{result})
575 This built-in function returns the value described by @var{result} from
576 the containing function.  You should specify, for @var{result}, a value
577 returned by @code{__builtin_apply}.
578 @end deftypefn
580 @deftypefn {Built-in Function} {} __builtin_va_arg_pack ()
581 This built-in function represents all anonymous arguments of an inline
582 function.  It can be used only in inline functions that are always
583 inlined, never compiled as a separate function, such as those using
584 @code{__attribute__ ((__always_inline__))} or
585 @code{__attribute__ ((__gnu_inline__))} extern inline functions.
586 It must be only passed as last argument to some other function
587 with variable arguments.  This is useful for writing small wrapper
588 inlines for variable argument functions, when using preprocessor
589 macros is undesirable.  For example:
590 @smallexample
591 extern int myprintf (FILE *f, const char *format, ...);
592 extern inline __attribute__ ((__gnu_inline__)) int
593 myprintf (FILE *f, const char *format, ...)
595   int r = fprintf (f, "myprintf: ");
596   if (r < 0)
597     return r;
598   int s = fprintf (f, format, __builtin_va_arg_pack ());
599   if (s < 0)
600     return s;
601   return r + s;
603 @end smallexample
604 @end deftypefn
606 @deftypefn {Built-in Function} {size_t} __builtin_va_arg_pack_len ()
607 This built-in function returns the number of anonymous arguments of
608 an inline function.  It can be used only in inline functions that
609 are always inlined, never compiled as a separate function, such
610 as those using @code{__attribute__ ((__always_inline__))} or
611 @code{__attribute__ ((__gnu_inline__))} extern inline functions.
612 For example following does link- or run-time checking of open
613 arguments for optimized code:
614 @smallexample
615 #ifdef __OPTIMIZE__
616 extern inline __attribute__((__gnu_inline__)) int
617 myopen (const char *path, int oflag, ...)
619   if (__builtin_va_arg_pack_len () > 1)
620     warn_open_too_many_arguments ();
622   if (__builtin_constant_p (oflag))
623     @{
624       if ((oflag & O_CREAT) != 0 && __builtin_va_arg_pack_len () < 1)
625         @{
626           warn_open_missing_mode ();
627           return __open_2 (path, oflag);
628         @}
629       return open (path, oflag, __builtin_va_arg_pack ());
630     @}
632   if (__builtin_va_arg_pack_len () < 1)
633     return __open_2 (path, oflag);
635   return open (path, oflag, __builtin_va_arg_pack ());
637 #endif
638 @end smallexample
639 @end deftypefn
641 @node Typeof
642 @section Referring to a Type with @code{typeof}
643 @findex typeof
644 @findex sizeof
645 @cindex macros, types of arguments
647 Another way to refer to the type of an expression is with @code{typeof}.
648 The syntax of using of this keyword looks like @code{sizeof}, but the
649 construct acts semantically like a type name defined with @code{typedef}.
651 There are two ways of writing the argument to @code{typeof}: with an
652 expression or with a type.  Here is an example with an expression:
654 @smallexample
655 typeof (x[0](1))
656 @end smallexample
658 @noindent
659 This assumes that @code{x} is an array of pointers to functions;
660 the type described is that of the values of the functions.
662 Here is an example with a typename as the argument:
664 @smallexample
665 typeof (int *)
666 @end smallexample
668 @noindent
669 Here the type described is that of pointers to @code{int}.
671 If you are writing a header file that must work when included in ISO C
672 programs, write @code{__typeof__} instead of @code{typeof}.
673 @xref{Alternate Keywords}.
675 A @code{typeof} construct can be used anywhere a typedef name can be
676 used.  For example, you can use it in a declaration, in a cast, or inside
677 of @code{sizeof} or @code{typeof}.
679 The operand of @code{typeof} is evaluated for its side effects if and
680 only if it is an expression of variably modified type or the name of
681 such a type.
683 @code{typeof} is often useful in conjunction with
684 statement expressions (@pxref{Statement Exprs}).
685 Here is how the two together can
686 be used to define a safe ``maximum'' macro which operates on any
687 arithmetic type and evaluates each of its arguments exactly once:
689 @smallexample
690 #define max(a,b) \
691   (@{ typeof (a) _a = (a); \
692       typeof (b) _b = (b); \
693     _a > _b ? _a : _b; @})
694 @end smallexample
696 @cindex underscores in variables in macros
697 @cindex @samp{_} in variables in macros
698 @cindex local variables in macros
699 @cindex variables, local, in macros
700 @cindex macros, local variables in
702 The reason for using names that start with underscores for the local
703 variables is to avoid conflicts with variable names that occur within the
704 expressions that are substituted for @code{a} and @code{b}.  Eventually we
705 hope to design a new form of declaration syntax that allows you to declare
706 variables whose scopes start only after their initializers; this will be a
707 more reliable way to prevent such conflicts.
709 @noindent
710 Some more examples of the use of @code{typeof}:
712 @itemize @bullet
713 @item
714 This declares @code{y} with the type of what @code{x} points to.
716 @smallexample
717 typeof (*x) y;
718 @end smallexample
720 @item
721 This declares @code{y} as an array of such values.
723 @smallexample
724 typeof (*x) y[4];
725 @end smallexample
727 @item
728 This declares @code{y} as an array of pointers to characters:
730 @smallexample
731 typeof (typeof (char *)[4]) y;
732 @end smallexample
734 @noindent
735 It is equivalent to the following traditional C declaration:
737 @smallexample
738 char *y[4];
739 @end smallexample
741 To see the meaning of the declaration using @code{typeof}, and why it
742 might be a useful way to write, rewrite it with these macros:
744 @smallexample
745 #define pointer(T)  typeof(T *)
746 #define array(T, N) typeof(T [N])
747 @end smallexample
749 @noindent
750 Now the declaration can be rewritten this way:
752 @smallexample
753 array (pointer (char), 4) y;
754 @end smallexample
756 @noindent
757 Thus, @code{array (pointer (char), 4)} is the type of arrays of 4
758 pointers to @code{char}.
759 @end itemize
761 In GNU C, but not GNU C++, you may also declare the type of a variable
762 as @code{__auto_type}.  In that case, the declaration must declare
763 only one variable, whose declarator must just be an identifier, the
764 declaration must be initialized, and the type of the variable is
765 determined by the initializer; the name of the variable is not in
766 scope until after the initializer.  (In C++, you should use C++11
767 @code{auto} for this purpose.)  Using @code{__auto_type}, the
768 ``maximum'' macro above could be written as:
770 @smallexample
771 #define max(a,b) \
772   (@{ __auto_type _a = (a); \
773       __auto_type _b = (b); \
774     _a > _b ? _a : _b; @})
775 @end smallexample
777 Using @code{__auto_type} instead of @code{typeof} has two advantages:
779 @itemize @bullet
780 @item Each argument to the macro appears only once in the expansion of
781 the macro.  This prevents the size of the macro expansion growing
782 exponentially when calls to such macros are nested inside arguments of
783 such macros.
785 @item If the argument to the macro has variably modified type, it is
786 evaluated only once when using @code{__auto_type}, but twice if
787 @code{typeof} is used.
788 @end itemize
790 @node Conditionals
791 @section Conditionals with Omitted Operands
792 @cindex conditional expressions, extensions
793 @cindex omitted middle-operands
794 @cindex middle-operands, omitted
795 @cindex extensions, @code{?:}
796 @cindex @code{?:} extensions
798 The middle operand in a conditional expression may be omitted.  Then
799 if the first operand is nonzero, its value is the value of the conditional
800 expression.
802 Therefore, the expression
804 @smallexample
805 x ? : y
806 @end smallexample
808 @noindent
809 has the value of @code{x} if that is nonzero; otherwise, the value of
810 @code{y}.
812 This example is perfectly equivalent to
814 @smallexample
815 x ? x : y
816 @end smallexample
818 @cindex side effect in @code{?:}
819 @cindex @code{?:} side effect
820 @noindent
821 In this simple case, the ability to omit the middle operand is not
822 especially useful.  When it becomes useful is when the first operand does,
823 or may (if it is a macro argument), contain a side effect.  Then repeating
824 the operand in the middle would perform the side effect twice.  Omitting
825 the middle operand uses the value already computed without the undesirable
826 effects of recomputing it.
828 @node __int128
829 @section 128-bit Integers
830 @cindex @code{__int128} data types
832 As an extension the integer scalar type @code{__int128} is supported for
833 targets which have an integer mode wide enough to hold 128 bits.
834 Simply write @code{__int128} for a signed 128-bit integer, or
835 @code{unsigned __int128} for an unsigned 128-bit integer.  There is no
836 support in GCC for expressing an integer constant of type @code{__int128}
837 for targets with @code{long long} integer less than 128 bits wide.
839 @node Long Long
840 @section Double-Word Integers
841 @cindex @code{long long} data types
842 @cindex double-word arithmetic
843 @cindex multiprecision arithmetic
844 @cindex @code{LL} integer suffix
845 @cindex @code{ULL} integer suffix
847 ISO C99 supports data types for integers that are at least 64 bits wide,
848 and as an extension GCC supports them in C90 mode and in C++.
849 Simply write @code{long long int} for a signed integer, or
850 @code{unsigned long long int} for an unsigned integer.  To make an
851 integer constant of type @code{long long int}, add the suffix @samp{LL}
852 to the integer.  To make an integer constant of type @code{unsigned long
853 long int}, add the suffix @samp{ULL} to the integer.
855 You can use these types in arithmetic like any other integer types.
856 Addition, subtraction, and bitwise boolean operations on these types
857 are open-coded on all types of machines.  Multiplication is open-coded
858 if the machine supports a fullword-to-doubleword widening multiply
859 instruction.  Division and shifts are open-coded only on machines that
860 provide special support.  The operations that are not open-coded use
861 special library routines that come with GCC@.
863 There may be pitfalls when you use @code{long long} types for function
864 arguments without function prototypes.  If a function
865 expects type @code{int} for its argument, and you pass a value of type
866 @code{long long int}, confusion results because the caller and the
867 subroutine disagree about the number of bytes for the argument.
868 Likewise, if the function expects @code{long long int} and you pass
869 @code{int}.  The best way to avoid such problems is to use prototypes.
871 @node Complex
872 @section Complex Numbers
873 @cindex complex numbers
874 @cindex @code{_Complex} keyword
875 @cindex @code{__complex__} keyword
877 ISO C99 supports complex floating data types, and as an extension GCC
878 supports them in C90 mode and in C++.  GCC also supports complex integer data
879 types which are not part of ISO C99.  You can declare complex types
880 using the keyword @code{_Complex}.  As an extension, the older GNU
881 keyword @code{__complex__} is also supported.
883 For example, @samp{_Complex double x;} declares @code{x} as a
884 variable whose real part and imaginary part are both of type
885 @code{double}.  @samp{_Complex short int y;} declares @code{y} to
886 have real and imaginary parts of type @code{short int}; this is not
887 likely to be useful, but it shows that the set of complex types is
888 complete.
890 To write a constant with a complex data type, use the suffix @samp{i} or
891 @samp{j} (either one; they are equivalent).  For example, @code{2.5fi}
892 has type @code{_Complex float} and @code{3i} has type
893 @code{_Complex int}.  Such a constant always has a pure imaginary
894 value, but you can form any complex value you like by adding one to a
895 real constant.  This is a GNU extension; if you have an ISO C99
896 conforming C library (such as the GNU C Library), and want to construct complex
897 constants of floating type, you should include @code{<complex.h>} and
898 use the macros @code{I} or @code{_Complex_I} instead.
900 The ISO C++14 library also defines the @samp{i} suffix, so C++14 code
901 that includes the @samp{<complex>} header cannot use @samp{i} for the
902 GNU extension.  The @samp{j} suffix still has the GNU meaning.
904 @cindex @code{__real__} keyword
905 @cindex @code{__imag__} keyword
906 To extract the real part of a complex-valued expression @var{exp}, write
907 @code{__real__ @var{exp}}.  Likewise, use @code{__imag__} to
908 extract the imaginary part.  This is a GNU extension; for values of
909 floating type, you should use the ISO C99 functions @code{crealf},
910 @code{creal}, @code{creall}, @code{cimagf}, @code{cimag} and
911 @code{cimagl}, declared in @code{<complex.h>} and also provided as
912 built-in functions by GCC@.
914 @cindex complex conjugation
915 The operator @samp{~} performs complex conjugation when used on a value
916 with a complex type.  This is a GNU extension; for values of
917 floating type, you should use the ISO C99 functions @code{conjf},
918 @code{conj} and @code{conjl}, declared in @code{<complex.h>} and also
919 provided as built-in functions by GCC@.
921 GCC can allocate complex automatic variables in a noncontiguous
922 fashion; it's even possible for the real part to be in a register while
923 the imaginary part is on the stack (or vice versa).  Only the DWARF
924 debug info format can represent this, so use of DWARF is recommended.
925 If you are using the stabs debug info format, GCC describes a noncontiguous
926 complex variable as if it were two separate variables of noncomplex type.
927 If the variable's actual name is @code{foo}, the two fictitious
928 variables are named @code{foo$real} and @code{foo$imag}.  You can
929 examine and set these two fictitious variables with your debugger.
931 @node Floating Types
932 @section Additional Floating Types
933 @cindex additional floating types
934 @cindex @code{_Float@var{n}} data types
935 @cindex @code{_Float@var{n}x} data types
936 @cindex @code{__float80} data type
937 @cindex @code{__float128} data type
938 @cindex @code{__ibm128} data type
939 @cindex @code{w} floating point suffix
940 @cindex @code{q} floating point suffix
941 @cindex @code{W} floating point suffix
942 @cindex @code{Q} floating point suffix
944 ISO/IEC TS 18661-3:2015 defines C support for additional floating
945 types @code{_Float@var{n}} and @code{_Float@var{n}x}, and GCC supports
946 these type names; the set of types supported depends on the target
947 architecture.  These types are not supported when compiling C++.
948 Constants with these types use suffixes @code{f@var{n}} or
949 @code{F@var{n}} and @code{f@var{n}x} or @code{F@var{n}x}.  These type
950 names can be used together with @code{_Complex} to declare complex
951 types.
953 As an extension, GNU C and GNU C++ support additional floating
954 types, which are not supported by all targets.
955 @itemize @bullet
956 @item @code{__float128} is available on i386, x86_64, IA-64, and
957 hppa HP-UX, as well as on PowerPC GNU/Linux targets that enable
958 the vector scalar (VSX) instruction set.  @code{__float128} supports
959 the 128-bit floating type.  On i386, x86_64, PowerPC, and IA-64
960 other than HP-UX, @code{__float128} is an alias for @code{_Float128}.
961 On hppa and IA-64 HP-UX, @code{__float128} is an alias for @code{long
962 double}.
964 @item @code{__float80} is available on the i386, x86_64, and IA-64
965 targets, and supports the 80-bit (@code{XFmode}) floating type.  It is
966 an alias for the type name @code{_Float64x} on these targets.
968 @item @code{__ibm128} is available on PowerPC targets, and provides
969 access to the IBM extended double format which is the current format
970 used for @code{long double}.  When @code{long double} transitions to
971 @code{__float128} on PowerPC in the future, @code{__ibm128} will remain
972 for use in conversions between the two types.
973 @end itemize
975 Support for these additional types includes the arithmetic operators:
976 add, subtract, multiply, divide; unary arithmetic operators;
977 relational operators; equality operators; and conversions to and from
978 integer and other floating types.  Use a suffix @samp{w} or @samp{W}
979 in a literal constant of type @code{__float80} or type
980 @code{__ibm128}.  Use a suffix @samp{q} or @samp{Q} for @code{_float128}.
982 In order to use @code{_Float128}, @code{__float128}, and @code{__ibm128}
983 on PowerPC Linux systems, you must use the @option{-mfloat128} option. It is
984 expected in future versions of GCC that @code{_Float128} and @code{__float128}
985 will be enabled automatically.
987 The @code{_Float128} type is supported on all systems where
988 @code{__float128} is supported or where @code{long double} has the
989 IEEE binary128 format.  The @code{_Float64x} type is supported on all
990 systems where @code{__float128} is supported.  The @code{_Float32}
991 type is supported on all systems supporting IEEE binary32; the
992 @code{_Float64} and @code{_Float32x} types are supported on all systems
993 supporting IEEE binary64.  The @code{_Float16} type is supported on AArch64
994 systems by default, and on ARM systems when the IEEE format for 16-bit
995 floating-point types is selected with @option{-mfp16-format=ieee}.
996 GCC does not currently support @code{_Float128x} on any systems.
998 On the i386, x86_64, IA-64, and HP-UX targets, you can declare complex
999 types using the corresponding internal complex type, @code{XCmode} for
1000 @code{__float80} type and @code{TCmode} for @code{__float128} type:
1002 @smallexample
1003 typedef _Complex float __attribute__((mode(TC))) _Complex128;
1004 typedef _Complex float __attribute__((mode(XC))) _Complex80;
1005 @end smallexample
1007 On the PowerPC Linux VSX targets, you can declare complex types using
1008 the corresponding internal complex type, @code{KCmode} for
1009 @code{__float128} type and @code{ICmode} for @code{__ibm128} type:
1011 @smallexample
1012 typedef _Complex float __attribute__((mode(KC))) _Complex_float128;
1013 typedef _Complex float __attribute__((mode(IC))) _Complex_ibm128;
1014 @end smallexample
1016 @node Half-Precision
1017 @section Half-Precision Floating Point
1018 @cindex half-precision floating point
1019 @cindex @code{__fp16} data type
1021 On ARM and AArch64 targets, GCC supports half-precision (16-bit) floating
1022 point via the @code{__fp16} type defined in the ARM C Language Extensions.
1023 On ARM systems, you must enable this type explicitly with the
1024 @option{-mfp16-format} command-line option in order to use it.
1026 ARM targets support two incompatible representations for half-precision
1027 floating-point values.  You must choose one of the representations and
1028 use it consistently in your program.
1030 Specifying @option{-mfp16-format=ieee} selects the IEEE 754-2008 format.
1031 This format can represent normalized values in the range of @math{2^{-14}} to 65504.
1032 There are 11 bits of significand precision, approximately 3
1033 decimal digits.
1035 Specifying @option{-mfp16-format=alternative} selects the ARM
1036 alternative format.  This representation is similar to the IEEE
1037 format, but does not support infinities or NaNs.  Instead, the range
1038 of exponents is extended, so that this format can represent normalized
1039 values in the range of @math{2^{-14}} to 131008.
1041 The GCC port for AArch64 only supports the IEEE 754-2008 format, and does
1042 not require use of the @option{-mfp16-format} command-line option.
1044 The @code{__fp16} type may only be used as an argument to intrinsics defined
1045 in @code{<arm_fp16.h>}, or as a storage format.  For purposes of
1046 arithmetic and other operations, @code{__fp16} values in C or C++
1047 expressions are automatically promoted to @code{float}.
1049 The ARM target provides hardware support for conversions between
1050 @code{__fp16} and @code{float} values
1051 as an extension to VFP and NEON (Advanced SIMD), and from ARMv8-A provides
1052 hardware support for conversions between @code{__fp16} and @code{double}
1053 values.  GCC generates code using these hardware instructions if you
1054 compile with options to select an FPU that provides them;
1055 for example, @option{-mfpu=neon-fp16 -mfloat-abi=softfp},
1056 in addition to the @option{-mfp16-format} option to select
1057 a half-precision format.
1059 Language-level support for the @code{__fp16} data type is
1060 independent of whether GCC generates code using hardware floating-point
1061 instructions.  In cases where hardware support is not specified, GCC
1062 implements conversions between @code{__fp16} and other types as library
1063 calls.
1065 It is recommended that portable code use the @code{_Float16} type defined
1066 by ISO/IEC TS 18661-3:2015.  @xref{Floating Types}.
1068 @node Decimal Float
1069 @section Decimal Floating Types
1070 @cindex decimal floating types
1071 @cindex @code{_Decimal32} data type
1072 @cindex @code{_Decimal64} data type
1073 @cindex @code{_Decimal128} data type
1074 @cindex @code{df} integer suffix
1075 @cindex @code{dd} integer suffix
1076 @cindex @code{dl} integer suffix
1077 @cindex @code{DF} integer suffix
1078 @cindex @code{DD} integer suffix
1079 @cindex @code{DL} integer suffix
1081 As an extension, GNU C supports decimal floating types as
1082 defined in the N1312 draft of ISO/IEC WDTR24732.  Support for decimal
1083 floating types in GCC will evolve as the draft technical report changes.
1084 Calling conventions for any target might also change.  Not all targets
1085 support decimal floating types.
1087 The decimal floating types are @code{_Decimal32}, @code{_Decimal64}, and
1088 @code{_Decimal128}.  They use a radix of ten, unlike the floating types
1089 @code{float}, @code{double}, and @code{long double} whose radix is not
1090 specified by the C standard but is usually two.
1092 Support for decimal floating types includes the arithmetic operators
1093 add, subtract, multiply, divide; unary arithmetic operators;
1094 relational operators; equality operators; and conversions to and from
1095 integer and other floating types.  Use a suffix @samp{df} or
1096 @samp{DF} in a literal constant of type @code{_Decimal32}, @samp{dd}
1097 or @samp{DD} for @code{_Decimal64}, and @samp{dl} or @samp{DL} for
1098 @code{_Decimal128}.
1100 GCC support of decimal float as specified by the draft technical report
1101 is incomplete:
1103 @itemize @bullet
1104 @item
1105 When the value of a decimal floating type cannot be represented in the
1106 integer type to which it is being converted, the result is undefined
1107 rather than the result value specified by the draft technical report.
1109 @item
1110 GCC does not provide the C library functionality associated with
1111 @file{math.h}, @file{fenv.h}, @file{stdio.h}, @file{stdlib.h}, and
1112 @file{wchar.h}, which must come from a separate C library implementation.
1113 Because of this the GNU C compiler does not define macro
1114 @code{__STDC_DEC_FP__} to indicate that the implementation conforms to
1115 the technical report.
1116 @end itemize
1118 Types @code{_Decimal32}, @code{_Decimal64}, and @code{_Decimal128}
1119 are supported by the DWARF debug information format.
1121 @node Hex Floats
1122 @section Hex Floats
1123 @cindex hex floats
1125 ISO C99 supports floating-point numbers written not only in the usual
1126 decimal notation, such as @code{1.55e1}, but also numbers such as
1127 @code{0x1.fp3} written in hexadecimal format.  As a GNU extension, GCC
1128 supports this in C90 mode (except in some cases when strictly
1129 conforming) and in C++.  In that format the
1130 @samp{0x} hex introducer and the @samp{p} or @samp{P} exponent field are
1131 mandatory.  The exponent is a decimal number that indicates the power of
1132 2 by which the significant part is multiplied.  Thus @samp{0x1.f} is
1133 @tex
1134 $1 {15\over16}$,
1135 @end tex
1136 @ifnottex
1137 1 15/16,
1138 @end ifnottex
1139 @samp{p3} multiplies it by 8, and the value of @code{0x1.fp3}
1140 is the same as @code{1.55e1}.
1142 Unlike for floating-point numbers in the decimal notation the exponent
1143 is always required in the hexadecimal notation.  Otherwise the compiler
1144 would not be able to resolve the ambiguity of, e.g., @code{0x1.f}.  This
1145 could mean @code{1.0f} or @code{1.9375} since @samp{f} is also the
1146 extension for floating-point constants of type @code{float}.
1148 @node Fixed-Point
1149 @section Fixed-Point Types
1150 @cindex fixed-point types
1151 @cindex @code{_Fract} data type
1152 @cindex @code{_Accum} data type
1153 @cindex @code{_Sat} data type
1154 @cindex @code{hr} fixed-suffix
1155 @cindex @code{r} fixed-suffix
1156 @cindex @code{lr} fixed-suffix
1157 @cindex @code{llr} fixed-suffix
1158 @cindex @code{uhr} fixed-suffix
1159 @cindex @code{ur} fixed-suffix
1160 @cindex @code{ulr} fixed-suffix
1161 @cindex @code{ullr} fixed-suffix
1162 @cindex @code{hk} fixed-suffix
1163 @cindex @code{k} fixed-suffix
1164 @cindex @code{lk} fixed-suffix
1165 @cindex @code{llk} fixed-suffix
1166 @cindex @code{uhk} fixed-suffix
1167 @cindex @code{uk} fixed-suffix
1168 @cindex @code{ulk} fixed-suffix
1169 @cindex @code{ullk} fixed-suffix
1170 @cindex @code{HR} fixed-suffix
1171 @cindex @code{R} fixed-suffix
1172 @cindex @code{LR} fixed-suffix
1173 @cindex @code{LLR} fixed-suffix
1174 @cindex @code{UHR} fixed-suffix
1175 @cindex @code{UR} fixed-suffix
1176 @cindex @code{ULR} fixed-suffix
1177 @cindex @code{ULLR} fixed-suffix
1178 @cindex @code{HK} fixed-suffix
1179 @cindex @code{K} fixed-suffix
1180 @cindex @code{LK} fixed-suffix
1181 @cindex @code{LLK} fixed-suffix
1182 @cindex @code{UHK} fixed-suffix
1183 @cindex @code{UK} fixed-suffix
1184 @cindex @code{ULK} fixed-suffix
1185 @cindex @code{ULLK} fixed-suffix
1187 As an extension, GNU C supports fixed-point types as
1188 defined in the N1169 draft of ISO/IEC DTR 18037.  Support for fixed-point
1189 types in GCC will evolve as the draft technical report changes.
1190 Calling conventions for any target might also change.  Not all targets
1191 support fixed-point types.
1193 The fixed-point types are
1194 @code{short _Fract},
1195 @code{_Fract},
1196 @code{long _Fract},
1197 @code{long long _Fract},
1198 @code{unsigned short _Fract},
1199 @code{unsigned _Fract},
1200 @code{unsigned long _Fract},
1201 @code{unsigned long long _Fract},
1202 @code{_Sat short _Fract},
1203 @code{_Sat _Fract},
1204 @code{_Sat long _Fract},
1205 @code{_Sat long long _Fract},
1206 @code{_Sat unsigned short _Fract},
1207 @code{_Sat unsigned _Fract},
1208 @code{_Sat unsigned long _Fract},
1209 @code{_Sat unsigned long long _Fract},
1210 @code{short _Accum},
1211 @code{_Accum},
1212 @code{long _Accum},
1213 @code{long long _Accum},
1214 @code{unsigned short _Accum},
1215 @code{unsigned _Accum},
1216 @code{unsigned long _Accum},
1217 @code{unsigned long long _Accum},
1218 @code{_Sat short _Accum},
1219 @code{_Sat _Accum},
1220 @code{_Sat long _Accum},
1221 @code{_Sat long long _Accum},
1222 @code{_Sat unsigned short _Accum},
1223 @code{_Sat unsigned _Accum},
1224 @code{_Sat unsigned long _Accum},
1225 @code{_Sat unsigned long long _Accum}.
1227 Fixed-point data values contain fractional and optional integral parts.
1228 The format of fixed-point data varies and depends on the target machine.
1230 Support for fixed-point types includes:
1231 @itemize @bullet
1232 @item
1233 prefix and postfix increment and decrement operators (@code{++}, @code{--})
1234 @item
1235 unary arithmetic operators (@code{+}, @code{-}, @code{!})
1236 @item
1237 binary arithmetic operators (@code{+}, @code{-}, @code{*}, @code{/})
1238 @item
1239 binary shift operators (@code{<<}, @code{>>})
1240 @item
1241 relational operators (@code{<}, @code{<=}, @code{>=}, @code{>})
1242 @item
1243 equality operators (@code{==}, @code{!=})
1244 @item
1245 assignment operators (@code{+=}, @code{-=}, @code{*=}, @code{/=},
1246 @code{<<=}, @code{>>=})
1247 @item
1248 conversions to and from integer, floating-point, or fixed-point types
1249 @end itemize
1251 Use a suffix in a fixed-point literal constant:
1252 @itemize
1253 @item @samp{hr} or @samp{HR} for @code{short _Fract} and
1254 @code{_Sat short _Fract}
1255 @item @samp{r} or @samp{R} for @code{_Fract} and @code{_Sat _Fract}
1256 @item @samp{lr} or @samp{LR} for @code{long _Fract} and
1257 @code{_Sat long _Fract}
1258 @item @samp{llr} or @samp{LLR} for @code{long long _Fract} and
1259 @code{_Sat long long _Fract}
1260 @item @samp{uhr} or @samp{UHR} for @code{unsigned short _Fract} and
1261 @code{_Sat unsigned short _Fract}
1262 @item @samp{ur} or @samp{UR} for @code{unsigned _Fract} and
1263 @code{_Sat unsigned _Fract}
1264 @item @samp{ulr} or @samp{ULR} for @code{unsigned long _Fract} and
1265 @code{_Sat unsigned long _Fract}
1266 @item @samp{ullr} or @samp{ULLR} for @code{unsigned long long _Fract}
1267 and @code{_Sat unsigned long long _Fract}
1268 @item @samp{hk} or @samp{HK} for @code{short _Accum} and
1269 @code{_Sat short _Accum}
1270 @item @samp{k} or @samp{K} for @code{_Accum} and @code{_Sat _Accum}
1271 @item @samp{lk} or @samp{LK} for @code{long _Accum} and
1272 @code{_Sat long _Accum}
1273 @item @samp{llk} or @samp{LLK} for @code{long long _Accum} and
1274 @code{_Sat long long _Accum}
1275 @item @samp{uhk} or @samp{UHK} for @code{unsigned short _Accum} and
1276 @code{_Sat unsigned short _Accum}
1277 @item @samp{uk} or @samp{UK} for @code{unsigned _Accum} and
1278 @code{_Sat unsigned _Accum}
1279 @item @samp{ulk} or @samp{ULK} for @code{unsigned long _Accum} and
1280 @code{_Sat unsigned long _Accum}
1281 @item @samp{ullk} or @samp{ULLK} for @code{unsigned long long _Accum}
1282 and @code{_Sat unsigned long long _Accum}
1283 @end itemize
1285 GCC support of fixed-point types as specified by the draft technical report
1286 is incomplete:
1288 @itemize @bullet
1289 @item
1290 Pragmas to control overflow and rounding behaviors are not implemented.
1291 @end itemize
1293 Fixed-point types are supported by the DWARF debug information format.
1295 @node Named Address Spaces
1296 @section Named Address Spaces
1297 @cindex Named Address Spaces
1299 As an extension, GNU C supports named address spaces as
1300 defined in the N1275 draft of ISO/IEC DTR 18037.  Support for named
1301 address spaces in GCC will evolve as the draft technical report
1302 changes.  Calling conventions for any target might also change.  At
1303 present, only the AVR, SPU, M32C, RL78, and x86 targets support
1304 address spaces other than the generic address space.
1306 Address space identifiers may be used exactly like any other C type
1307 qualifier (e.g., @code{const} or @code{volatile}).  See the N1275
1308 document for more details.
1310 @anchor{AVR Named Address Spaces}
1311 @subsection AVR Named Address Spaces
1313 On the AVR target, there are several address spaces that can be used
1314 in order to put read-only data into the flash memory and access that
1315 data by means of the special instructions @code{LPM} or @code{ELPM}
1316 needed to read from flash.
1318 Devices belonging to @code{avrtiny} and @code{avrxmega3} can access
1319 flash memory by means of @code{LD*} instructions because the flash
1320 memory is mapped into the RAM address space.  There is @emph{no need}
1321 for language extensions like @code{__flash} or attribute
1322 @ref{AVR Variable Attributes,,@code{progmem}}.
1323 The default linker description files for these devices cater for that
1324 feature and @code{.rodata} stays in flash: The compiler just generates
1325 @code{LD*} instructions, and the linker script adds core specific
1326 offsets to all @code{.rodata} symbols: @code{0x4000} in the case of
1327 @code{avrtiny} and @code{0x8000} in the case of @code{avrxmega3}.
1328 See @ref{AVR Options} for a list of respective devices.
1330 For devices not in @code{avrtiny} or @code{avrxmega3},
1331 any data including read-only data is located in RAM (the generic
1332 address space) because flash memory is not visible in the RAM address
1333 space.  In order to locate read-only data in flash memory @emph{and}
1334 to generate the right instructions to access this data without
1335 using (inline) assembler code, special address spaces are needed.
1337 @table @code
1338 @item __flash
1339 @cindex @code{__flash} AVR Named Address Spaces
1340 The @code{__flash} qualifier locates data in the
1341 @code{.progmem.data} section. Data is read using the @code{LPM}
1342 instruction. Pointers to this address space are 16 bits wide.
1344 @item __flash1
1345 @itemx __flash2
1346 @itemx __flash3
1347 @itemx __flash4
1348 @itemx __flash5
1349 @cindex @code{__flash1} AVR Named Address Spaces
1350 @cindex @code{__flash2} AVR Named Address Spaces
1351 @cindex @code{__flash3} AVR Named Address Spaces
1352 @cindex @code{__flash4} AVR Named Address Spaces
1353 @cindex @code{__flash5} AVR Named Address Spaces
1354 These are 16-bit address spaces locating data in section
1355 @code{.progmem@var{N}.data} where @var{N} refers to
1356 address space @code{__flash@var{N}}.
1357 The compiler sets the @code{RAMPZ} segment register appropriately 
1358 before reading data by means of the @code{ELPM} instruction.
1360 @item __memx
1361 @cindex @code{__memx} AVR Named Address Spaces
1362 This is a 24-bit address space that linearizes flash and RAM:
1363 If the high bit of the address is set, data is read from
1364 RAM using the lower two bytes as RAM address.
1365 If the high bit of the address is clear, data is read from flash
1366 with @code{RAMPZ} set according to the high byte of the address.
1367 @xref{AVR Built-in Functions,,@code{__builtin_avr_flash_segment}}.
1369 Objects in this address space are located in @code{.progmemx.data}.
1370 @end table
1372 @b{Example}
1374 @smallexample
1375 char my_read (const __flash char ** p)
1377     /* p is a pointer to RAM that points to a pointer to flash.
1378        The first indirection of p reads that flash pointer
1379        from RAM and the second indirection reads a char from this
1380        flash address.  */
1382     return **p;
1385 /* Locate array[] in flash memory */
1386 const __flash int array[] = @{ 3, 5, 7, 11, 13, 17, 19 @};
1388 int i = 1;
1390 int main (void)
1392    /* Return 17 by reading from flash memory */
1393    return array[array[i]];
1395 @end smallexample
1397 @noindent
1398 For each named address space supported by avr-gcc there is an equally
1399 named but uppercase built-in macro defined. 
1400 The purpose is to facilitate testing if respective address space
1401 support is available or not:
1403 @smallexample
1404 #ifdef __FLASH
1405 const __flash int var = 1;
1407 int read_var (void)
1409     return var;
1411 #else
1412 #include <avr/pgmspace.h> /* From AVR-LibC */
1414 const int var PROGMEM = 1;
1416 int read_var (void)
1418     return (int) pgm_read_word (&var);
1420 #endif /* __FLASH */
1421 @end smallexample
1423 @noindent
1424 Notice that attribute @ref{AVR Variable Attributes,,@code{progmem}}
1425 locates data in flash but
1426 accesses to these data read from generic address space, i.e.@:
1427 from RAM,
1428 so that you need special accessors like @code{pgm_read_byte}
1429 from @w{@uref{http://nongnu.org/avr-libc/user-manual/,AVR-LibC}}
1430 together with attribute @code{progmem}.
1432 @noindent
1433 @b{Limitations and caveats}
1435 @itemize
1436 @item
1437 Reading across the 64@tie{}KiB section boundary of
1438 the @code{__flash} or @code{__flash@var{N}} address spaces
1439 shows undefined behavior. The only address space that
1440 supports reading across the 64@tie{}KiB flash segment boundaries is
1441 @code{__memx}.
1443 @item
1444 If you use one of the @code{__flash@var{N}} address spaces
1445 you must arrange your linker script to locate the
1446 @code{.progmem@var{N}.data} sections according to your needs.
1448 @item
1449 Any data or pointers to the non-generic address spaces must
1450 be qualified as @code{const}, i.e.@: as read-only data.
1451 This still applies if the data in one of these address
1452 spaces like software version number or calibration lookup table are intended to
1453 be changed after load time by, say, a boot loader. In this case
1454 the right qualification is @code{const} @code{volatile} so that the compiler
1455 must not optimize away known values or insert them
1456 as immediates into operands of instructions.
1458 @item
1459 The following code initializes a variable @code{pfoo}
1460 located in static storage with a 24-bit address:
1461 @smallexample
1462 extern const __memx char foo;
1463 const __memx void *pfoo = &foo;
1464 @end smallexample
1466 @item
1467 On the reduced Tiny devices like ATtiny40, no address spaces are supported.
1468 Just use vanilla C / C++ code without overhead as outlined above.
1469 Attribute @code{progmem} is supported but works differently,
1470 see @ref{AVR Variable Attributes}.
1472 @end itemize
1474 @subsection M32C Named Address Spaces
1475 @cindex @code{__far} M32C Named Address Spaces
1477 On the M32C target, with the R8C and M16C CPU variants, variables
1478 qualified with @code{__far} are accessed using 32-bit addresses in
1479 order to access memory beyond the first 64@tie{}Ki bytes.  If
1480 @code{__far} is used with the M32CM or M32C CPU variants, it has no
1481 effect.
1483 @subsection RL78 Named Address Spaces
1484 @cindex @code{__far} RL78 Named Address Spaces
1486 On the RL78 target, variables qualified with @code{__far} are accessed
1487 with 32-bit pointers (20-bit addresses) rather than the default 16-bit
1488 addresses.  Non-far variables are assumed to appear in the topmost
1489 64@tie{}KiB of the address space.
1491 @subsection SPU Named Address Spaces
1492 @cindex @code{__ea} SPU Named Address Spaces
1494 On the SPU target variables may be declared as
1495 belonging to another address space by qualifying the type with the
1496 @code{__ea} address space identifier:
1498 @smallexample
1499 extern int __ea i;
1500 @end smallexample
1502 @noindent 
1503 The compiler generates special code to access the variable @code{i}.
1504 It may use runtime library
1505 support, or generate special machine instructions to access that address
1506 space.
1508 @subsection x86 Named Address Spaces
1509 @cindex x86 named address spaces
1511 On the x86 target, variables may be declared as being relative
1512 to the @code{%fs} or @code{%gs} segments.
1514 @table @code
1515 @item __seg_fs
1516 @itemx __seg_gs
1517 @cindex @code{__seg_fs} x86 named address space
1518 @cindex @code{__seg_gs} x86 named address space
1519 The object is accessed with the respective segment override prefix.
1521 The respective segment base must be set via some method specific to
1522 the operating system.  Rather than require an expensive system call
1523 to retrieve the segment base, these address spaces are not considered
1524 to be subspaces of the generic (flat) address space.  This means that
1525 explicit casts are required to convert pointers between these address
1526 spaces and the generic address space.  In practice the application
1527 should cast to @code{uintptr_t} and apply the segment base offset
1528 that it installed previously.
1530 The preprocessor symbols @code{__SEG_FS} and @code{__SEG_GS} are
1531 defined when these address spaces are supported.
1532 @end table
1534 @node Zero Length
1535 @section Arrays of Length Zero
1536 @cindex arrays of length zero
1537 @cindex zero-length arrays
1538 @cindex length-zero arrays
1539 @cindex flexible array members
1541 Zero-length arrays are allowed in GNU C@.  They are very useful as the
1542 last element of a structure that is really a header for a variable-length
1543 object:
1545 @smallexample
1546 struct line @{
1547   int length;
1548   char contents[0];
1551 struct line *thisline = (struct line *)
1552   malloc (sizeof (struct line) + this_length);
1553 thisline->length = this_length;
1554 @end smallexample
1556 In ISO C90, you would have to give @code{contents} a length of 1, which
1557 means either you waste space or complicate the argument to @code{malloc}.
1559 In ISO C99, you would use a @dfn{flexible array member}, which is
1560 slightly different in syntax and semantics:
1562 @itemize @bullet
1563 @item
1564 Flexible array members are written as @code{contents[]} without
1565 the @code{0}.
1567 @item
1568 Flexible array members have incomplete type, and so the @code{sizeof}
1569 operator may not be applied.  As a quirk of the original implementation
1570 of zero-length arrays, @code{sizeof} evaluates to zero.
1572 @item
1573 Flexible array members may only appear as the last member of a
1574 @code{struct} that is otherwise non-empty.
1576 @item
1577 A structure containing a flexible array member, or a union containing
1578 such a structure (possibly recursively), may not be a member of a
1579 structure or an element of an array.  (However, these uses are
1580 permitted by GCC as extensions.)
1581 @end itemize
1583 Non-empty initialization of zero-length
1584 arrays is treated like any case where there are more initializer
1585 elements than the array holds, in that a suitable warning about ``excess
1586 elements in array'' is given, and the excess elements (all of them, in
1587 this case) are ignored.
1589 GCC allows static initialization of flexible array members.
1590 This is equivalent to defining a new structure containing the original
1591 structure followed by an array of sufficient size to contain the data.
1592 E.g.@: in the following, @code{f1} is constructed as if it were declared
1593 like @code{f2}.
1595 @smallexample
1596 struct f1 @{
1597   int x; int y[];
1598 @} f1 = @{ 1, @{ 2, 3, 4 @} @};
1600 struct f2 @{
1601   struct f1 f1; int data[3];
1602 @} f2 = @{ @{ 1 @}, @{ 2, 3, 4 @} @};
1603 @end smallexample
1605 @noindent
1606 The convenience of this extension is that @code{f1} has the desired
1607 type, eliminating the need to consistently refer to @code{f2.f1}.
1609 This has symmetry with normal static arrays, in that an array of
1610 unknown size is also written with @code{[]}.
1612 Of course, this extension only makes sense if the extra data comes at
1613 the end of a top-level object, as otherwise we would be overwriting
1614 data at subsequent offsets.  To avoid undue complication and confusion
1615 with initialization of deeply nested arrays, we simply disallow any
1616 non-empty initialization except when the structure is the top-level
1617 object.  For example:
1619 @smallexample
1620 struct foo @{ int x; int y[]; @};
1621 struct bar @{ struct foo z; @};
1623 struct foo a = @{ 1, @{ 2, 3, 4 @} @};        // @r{Valid.}
1624 struct bar b = @{ @{ 1, @{ 2, 3, 4 @} @} @};    // @r{Invalid.}
1625 struct bar c = @{ @{ 1, @{ @} @} @};            // @r{Valid.}
1626 struct foo d[1] = @{ @{ 1, @{ 2, 3, 4 @} @} @};  // @r{Invalid.}
1627 @end smallexample
1629 @node Empty Structures
1630 @section Structures with No Members
1631 @cindex empty structures
1632 @cindex zero-size structures
1634 GCC permits a C structure to have no members:
1636 @smallexample
1637 struct empty @{
1639 @end smallexample
1641 The structure has size zero.  In C++, empty structures are part
1642 of the language.  G++ treats empty structures as if they had a single
1643 member of type @code{char}.
1645 @node Variable Length
1646 @section Arrays of Variable Length
1647 @cindex variable-length arrays
1648 @cindex arrays of variable length
1649 @cindex VLAs
1651 Variable-length automatic arrays are allowed in ISO C99, and as an
1652 extension GCC accepts them in C90 mode and in C++.  These arrays are
1653 declared like any other automatic arrays, but with a length that is not
1654 a constant expression.  The storage is allocated at the point of
1655 declaration and deallocated when the block scope containing the declaration
1656 exits.  For
1657 example:
1659 @smallexample
1660 FILE *
1661 concat_fopen (char *s1, char *s2, char *mode)
1663   char str[strlen (s1) + strlen (s2) + 1];
1664   strcpy (str, s1);
1665   strcat (str, s2);
1666   return fopen (str, mode);
1668 @end smallexample
1670 @cindex scope of a variable length array
1671 @cindex variable-length array scope
1672 @cindex deallocating variable length arrays
1673 Jumping or breaking out of the scope of the array name deallocates the
1674 storage.  Jumping into the scope is not allowed; you get an error
1675 message for it.
1677 @cindex variable-length array in a structure
1678 As an extension, GCC accepts variable-length arrays as a member of
1679 a structure or a union.  For example:
1681 @smallexample
1682 void
1683 foo (int n)
1685   struct S @{ int x[n]; @};
1687 @end smallexample
1689 @cindex @code{alloca} vs variable-length arrays
1690 You can use the function @code{alloca} to get an effect much like
1691 variable-length arrays.  The function @code{alloca} is available in
1692 many other C implementations (but not in all).  On the other hand,
1693 variable-length arrays are more elegant.
1695 There are other differences between these two methods.  Space allocated
1696 with @code{alloca} exists until the containing @emph{function} returns.
1697 The space for a variable-length array is deallocated as soon as the array
1698 name's scope ends, unless you also use @code{alloca} in this scope.
1700 You can also use variable-length arrays as arguments to functions:
1702 @smallexample
1703 struct entry
1704 tester (int len, char data[len][len])
1706   /* @r{@dots{}} */
1708 @end smallexample
1710 The length of an array is computed once when the storage is allocated
1711 and is remembered for the scope of the array in case you access it with
1712 @code{sizeof}.
1714 If you want to pass the array first and the length afterward, you can
1715 use a forward declaration in the parameter list---another GNU extension.
1717 @smallexample
1718 struct entry
1719 tester (int len; char data[len][len], int len)
1721   /* @r{@dots{}} */
1723 @end smallexample
1725 @cindex parameter forward declaration
1726 The @samp{int len} before the semicolon is a @dfn{parameter forward
1727 declaration}, and it serves the purpose of making the name @code{len}
1728 known when the declaration of @code{data} is parsed.
1730 You can write any number of such parameter forward declarations in the
1731 parameter list.  They can be separated by commas or semicolons, but the
1732 last one must end with a semicolon, which is followed by the ``real''
1733 parameter declarations.  Each forward declaration must match a ``real''
1734 declaration in parameter name and data type.  ISO C99 does not support
1735 parameter forward declarations.
1737 @node Variadic Macros
1738 @section Macros with a Variable Number of Arguments.
1739 @cindex variable number of arguments
1740 @cindex macro with variable arguments
1741 @cindex rest argument (in macro)
1742 @cindex variadic macros
1744 In the ISO C standard of 1999, a macro can be declared to accept a
1745 variable number of arguments much as a function can.  The syntax for
1746 defining the macro is similar to that of a function.  Here is an
1747 example:
1749 @smallexample
1750 #define debug(format, ...) fprintf (stderr, format, __VA_ARGS__)
1751 @end smallexample
1753 @noindent
1754 Here @samp{@dots{}} is a @dfn{variable argument}.  In the invocation of
1755 such a macro, it represents the zero or more tokens until the closing
1756 parenthesis that ends the invocation, including any commas.  This set of
1757 tokens replaces the identifier @code{__VA_ARGS__} in the macro body
1758 wherever it appears.  See the CPP manual for more information.
1760 GCC has long supported variadic macros, and used a different syntax that
1761 allowed you to give a name to the variable arguments just like any other
1762 argument.  Here is an example:
1764 @smallexample
1765 #define debug(format, args...) fprintf (stderr, format, args)
1766 @end smallexample
1768 @noindent
1769 This is in all ways equivalent to the ISO C example above, but arguably
1770 more readable and descriptive.
1772 GNU CPP has two further variadic macro extensions, and permits them to
1773 be used with either of the above forms of macro definition.
1775 In standard C, you are not allowed to leave the variable argument out
1776 entirely; but you are allowed to pass an empty argument.  For example,
1777 this invocation is invalid in ISO C, because there is no comma after
1778 the string:
1780 @smallexample
1781 debug ("A message")
1782 @end smallexample
1784 GNU CPP permits you to completely omit the variable arguments in this
1785 way.  In the above examples, the compiler would complain, though since
1786 the expansion of the macro still has the extra comma after the format
1787 string.
1789 To help solve this problem, CPP behaves specially for variable arguments
1790 used with the token paste operator, @samp{##}.  If instead you write
1792 @smallexample
1793 #define debug(format, ...) fprintf (stderr, format, ## __VA_ARGS__)
1794 @end smallexample
1796 @noindent
1797 and if the variable arguments are omitted or empty, the @samp{##}
1798 operator causes the preprocessor to remove the comma before it.  If you
1799 do provide some variable arguments in your macro invocation, GNU CPP
1800 does not complain about the paste operation and instead places the
1801 variable arguments after the comma.  Just like any other pasted macro
1802 argument, these arguments are not macro expanded.
1804 @node Escaped Newlines
1805 @section Slightly Looser Rules for Escaped Newlines
1806 @cindex escaped newlines
1807 @cindex newlines (escaped)
1809 The preprocessor treatment of escaped newlines is more relaxed 
1810 than that specified by the C90 standard, which requires the newline
1811 to immediately follow a backslash.  
1812 GCC's implementation allows whitespace in the form
1813 of spaces, horizontal and vertical tabs, and form feeds between the
1814 backslash and the subsequent newline.  The preprocessor issues a
1815 warning, but treats it as a valid escaped newline and combines the two
1816 lines to form a single logical line.  This works within comments and
1817 tokens, as well as between tokens.  Comments are @emph{not} treated as
1818 whitespace for the purposes of this relaxation, since they have not
1819 yet been replaced with spaces.
1821 @node Subscripting
1822 @section Non-Lvalue Arrays May Have Subscripts
1823 @cindex subscripting
1824 @cindex arrays, non-lvalue
1826 @cindex subscripting and function values
1827 In ISO C99, arrays that are not lvalues still decay to pointers, and
1828 may be subscripted, although they may not be modified or used after
1829 the next sequence point and the unary @samp{&} operator may not be
1830 applied to them.  As an extension, GNU C allows such arrays to be
1831 subscripted in C90 mode, though otherwise they do not decay to
1832 pointers outside C99 mode.  For example,
1833 this is valid in GNU C though not valid in C90:
1835 @smallexample
1836 @group
1837 struct foo @{int a[4];@};
1839 struct foo f();
1841 bar (int index)
1843   return f().a[index];
1845 @end group
1846 @end smallexample
1848 @node Pointer Arith
1849 @section Arithmetic on @code{void}- and Function-Pointers
1850 @cindex void pointers, arithmetic
1851 @cindex void, size of pointer to
1852 @cindex function pointers, arithmetic
1853 @cindex function, size of pointer to
1855 In GNU C, addition and subtraction operations are supported on pointers to
1856 @code{void} and on pointers to functions.  This is done by treating the
1857 size of a @code{void} or of a function as 1.
1859 A consequence of this is that @code{sizeof} is also allowed on @code{void}
1860 and on function types, and returns 1.
1862 @opindex Wpointer-arith
1863 The option @option{-Wpointer-arith} requests a warning if these extensions
1864 are used.
1866 @node Pointers to Arrays
1867 @section Pointers to Arrays with Qualifiers Work as Expected
1868 @cindex pointers to arrays
1869 @cindex const qualifier
1871 In GNU C, pointers to arrays with qualifiers work similar to pointers
1872 to other qualified types. For example, a value of type @code{int (*)[5]}
1873 can be used to initialize a variable of type @code{const int (*)[5]}.
1874 These types are incompatible in ISO C because the @code{const} qualifier
1875 is formally attached to the element type of the array and not the
1876 array itself.
1878 @smallexample
1879 extern void
1880 transpose (int N, int M, double out[M][N], const double in[N][M]);
1881 double x[3][2];
1882 double y[2][3];
1883 @r{@dots{}}
1884 transpose(3, 2, y, x);
1885 @end smallexample
1887 @node Initializers
1888 @section Non-Constant Initializers
1889 @cindex initializers, non-constant
1890 @cindex non-constant initializers
1892 As in standard C++ and ISO C99, the elements of an aggregate initializer for an
1893 automatic variable are not required to be constant expressions in GNU C@.
1894 Here is an example of an initializer with run-time varying elements:
1896 @smallexample
1897 foo (float f, float g)
1899   float beat_freqs[2] = @{ f-g, f+g @};
1900   /* @r{@dots{}} */
1902 @end smallexample
1904 @node Compound Literals
1905 @section Compound Literals
1906 @cindex constructor expressions
1907 @cindex initializations in expressions
1908 @cindex structures, constructor expression
1909 @cindex expressions, constructor
1910 @cindex compound literals
1911 @c The GNU C name for what C99 calls compound literals was "constructor expressions".
1913 A compound literal looks like a cast of a brace-enclosed aggregate
1914 initializer list.  Its value is an object of the type specified in
1915 the cast, containing the elements specified in the initializer.
1916 Unlike the result of a cast, a compound literal is an lvalue.  ISO
1917 C99 and later support compound literals.  As an extension, GCC
1918 supports compound literals also in C90 mode and in C++, although
1919 as explained below, the C++ semantics are somewhat different.
1921 Usually, the specified type of a compound literal is a structure.  Assume
1922 that @code{struct foo} and @code{structure} are declared as shown:
1924 @smallexample
1925 struct foo @{int a; char b[2];@} structure;
1926 @end smallexample
1928 @noindent
1929 Here is an example of constructing a @code{struct foo} with a compound literal:
1931 @smallexample
1932 structure = ((struct foo) @{x + y, 'a', 0@});
1933 @end smallexample
1935 @noindent
1936 This is equivalent to writing the following:
1938 @smallexample
1940   struct foo temp = @{x + y, 'a', 0@};
1941   structure = temp;
1943 @end smallexample
1945 You can also construct an array, though this is dangerous in C++, as
1946 explained below.  If all the elements of the compound literal are
1947 (made up of) simple constant expressions suitable for use in
1948 initializers of objects of static storage duration, then the compound
1949 literal can be coerced to a pointer to its first element and used in
1950 such an initializer, as shown here:
1952 @smallexample
1953 char **foo = (char *[]) @{ "x", "y", "z" @};
1954 @end smallexample
1956 Compound literals for scalar types and union types are also allowed.  In
1957 the following example the variable @code{i} is initialized to the value
1958 @code{2}, the result of incrementing the unnamed object created by
1959 the compound literal.
1961 @smallexample
1962 int i = ++(int) @{ 1 @};
1963 @end smallexample
1965 As a GNU extension, GCC allows initialization of objects with static storage
1966 duration by compound literals (which is not possible in ISO C99 because
1967 the initializer is not a constant).
1968 It is handled as if the object were initialized only with the brace-enclosed
1969 list if the types of the compound literal and the object match.
1970 The elements of the compound literal must be constant.
1971 If the object being initialized has array type of unknown size, the size is
1972 determined by the size of the compound literal.
1974 @smallexample
1975 static struct foo x = (struct foo) @{1, 'a', 'b'@};
1976 static int y[] = (int []) @{1, 2, 3@};
1977 static int z[] = (int [3]) @{1@};
1978 @end smallexample
1980 @noindent
1981 The above lines are equivalent to the following:
1982 @smallexample
1983 static struct foo x = @{1, 'a', 'b'@};
1984 static int y[] = @{1, 2, 3@};
1985 static int z[] = @{1, 0, 0@};
1986 @end smallexample
1988 In C, a compound literal designates an unnamed object with static or
1989 automatic storage duration.  In C++, a compound literal designates a
1990 temporary object that only lives until the end of its full-expression.
1991 As a result, well-defined C code that takes the address of a subobject
1992 of a compound literal can be undefined in C++, so G++ rejects
1993 the conversion of a temporary array to a pointer.  For instance, if
1994 the array compound literal example above appeared inside a function,
1995 any subsequent use of @code{foo} in C++ would have undefined behavior
1996 because the lifetime of the array ends after the declaration of @code{foo}.
1998 As an optimization, G++ sometimes gives array compound literals longer
1999 lifetimes: when the array either appears outside a function or has
2000 a @code{const}-qualified type.  If @code{foo} and its initializer had
2001 elements of type @code{char *const} rather than @code{char *}, or if
2002 @code{foo} were a global variable, the array would have static storage
2003 duration.  But it is probably safest just to avoid the use of array
2004 compound literals in C++ code.
2006 @node Designated Inits
2007 @section Designated Initializers
2008 @cindex initializers with labeled elements
2009 @cindex labeled elements in initializers
2010 @cindex case labels in initializers
2011 @cindex designated initializers
2013 Standard C90 requires the elements of an initializer to appear in a fixed
2014 order, the same as the order of the elements in the array or structure
2015 being initialized.
2017 In ISO C99 you can give the elements in any order, specifying the array
2018 indices or structure field names they apply to, and GNU C allows this as
2019 an extension in C90 mode as well.  This extension is not
2020 implemented in GNU C++.
2022 To specify an array index, write
2023 @samp{[@var{index}] =} before the element value.  For example,
2025 @smallexample
2026 int a[6] = @{ [4] = 29, [2] = 15 @};
2027 @end smallexample
2029 @noindent
2030 is equivalent to
2032 @smallexample
2033 int a[6] = @{ 0, 0, 15, 0, 29, 0 @};
2034 @end smallexample
2036 @noindent
2037 The index values must be constant expressions, even if the array being
2038 initialized is automatic.
2040 An alternative syntax for this that has been obsolete since GCC 2.5 but
2041 GCC still accepts is to write @samp{[@var{index}]} before the element
2042 value, with no @samp{=}.
2044 To initialize a range of elements to the same value, write
2045 @samp{[@var{first} ... @var{last}] = @var{value}}.  This is a GNU
2046 extension.  For example,
2048 @smallexample
2049 int widths[] = @{ [0 ... 9] = 1, [10 ... 99] = 2, [100] = 3 @};
2050 @end smallexample
2052 @noindent
2053 If the value in it has side-effects, the side-effects happen only once,
2054 not for each initialized field by the range initializer.
2056 @noindent
2057 Note that the length of the array is the highest value specified
2058 plus one.
2060 In a structure initializer, specify the name of a field to initialize
2061 with @samp{.@var{fieldname} =} before the element value.  For example,
2062 given the following structure,
2064 @smallexample
2065 struct point @{ int x, y; @};
2066 @end smallexample
2068 @noindent
2069 the following initialization
2071 @smallexample
2072 struct point p = @{ .y = yvalue, .x = xvalue @};
2073 @end smallexample
2075 @noindent
2076 is equivalent to
2078 @smallexample
2079 struct point p = @{ xvalue, yvalue @};
2080 @end smallexample
2082 Another syntax that has the same meaning, obsolete since GCC 2.5, is
2083 @samp{@var{fieldname}:}, as shown here:
2085 @smallexample
2086 struct point p = @{ y: yvalue, x: xvalue @};
2087 @end smallexample
2089 Omitted field members are implicitly initialized the same as objects
2090 that have static storage duration.
2092 @cindex designators
2093 The @samp{[@var{index}]} or @samp{.@var{fieldname}} is known as a
2094 @dfn{designator}.  You can also use a designator (or the obsolete colon
2095 syntax) when initializing a union, to specify which element of the union
2096 should be used.  For example,
2098 @smallexample
2099 union foo @{ int i; double d; @};
2101 union foo f = @{ .d = 4 @};
2102 @end smallexample
2104 @noindent
2105 converts 4 to a @code{double} to store it in the union using
2106 the second element.  By contrast, casting 4 to type @code{union foo}
2107 stores it into the union as the integer @code{i}, since it is
2108 an integer.  @xref{Cast to Union}.
2110 You can combine this technique of naming elements with ordinary C
2111 initialization of successive elements.  Each initializer element that
2112 does not have a designator applies to the next consecutive element of the
2113 array or structure.  For example,
2115 @smallexample
2116 int a[6] = @{ [1] = v1, v2, [4] = v4 @};
2117 @end smallexample
2119 @noindent
2120 is equivalent to
2122 @smallexample
2123 int a[6] = @{ 0, v1, v2, 0, v4, 0 @};
2124 @end smallexample
2126 Labeling the elements of an array initializer is especially useful
2127 when the indices are characters or belong to an @code{enum} type.
2128 For example:
2130 @smallexample
2131 int whitespace[256]
2132   = @{ [' '] = 1, ['\t'] = 1, ['\h'] = 1,
2133       ['\f'] = 1, ['\n'] = 1, ['\r'] = 1 @};
2134 @end smallexample
2136 @cindex designator lists
2137 You can also write a series of @samp{.@var{fieldname}} and
2138 @samp{[@var{index}]} designators before an @samp{=} to specify a
2139 nested subobject to initialize; the list is taken relative to the
2140 subobject corresponding to the closest surrounding brace pair.  For
2141 example, with the @samp{struct point} declaration above:
2143 @smallexample
2144 struct point ptarray[10] = @{ [2].y = yv2, [2].x = xv2, [0].x = xv0 @};
2145 @end smallexample
2147 @noindent
2148 If the same field is initialized multiple times, it has the value from
2149 the last initialization.  If any such overridden initialization has
2150 side-effect, it is unspecified whether the side-effect happens or not.
2151 Currently, GCC discards them and issues a warning.
2153 @node Case Ranges
2154 @section Case Ranges
2155 @cindex case ranges
2156 @cindex ranges in case statements
2158 You can specify a range of consecutive values in a single @code{case} label,
2159 like this:
2161 @smallexample
2162 case @var{low} ... @var{high}:
2163 @end smallexample
2165 @noindent
2166 This has the same effect as the proper number of individual @code{case}
2167 labels, one for each integer value from @var{low} to @var{high}, inclusive.
2169 This feature is especially useful for ranges of ASCII character codes:
2171 @smallexample
2172 case 'A' ... 'Z':
2173 @end smallexample
2175 @strong{Be careful:} Write spaces around the @code{...}, for otherwise
2176 it may be parsed wrong when you use it with integer values.  For example,
2177 write this:
2179 @smallexample
2180 case 1 ... 5:
2181 @end smallexample
2183 @noindent
2184 rather than this:
2186 @smallexample
2187 case 1...5:
2188 @end smallexample
2190 @node Cast to Union
2191 @section Cast to a Union Type
2192 @cindex cast to a union
2193 @cindex union, casting to a
2195 A cast to union type looks similar to other casts, except that the type
2196 specified is a union type.  You can specify the type either with the
2197 @code{union} keyword or with a @code{typedef} name that refers to
2198 a union.  A cast to a union actually creates a compound literal and
2199 yields an lvalue, not an rvalue like true casts do.
2200 @xref{Compound Literals}.
2202 The types that may be cast to the union type are those of the members
2203 of the union.  Thus, given the following union and variables:
2205 @smallexample
2206 union foo @{ int i; double d; @};
2207 int x;
2208 double y;
2209 @end smallexample
2211 @noindent
2212 both @code{x} and @code{y} can be cast to type @code{union foo}.
2214 Using the cast as the right-hand side of an assignment to a variable of
2215 union type is equivalent to storing in a member of the union:
2217 @smallexample
2218 union foo u;
2219 /* @r{@dots{}} */
2220 u = (union foo) x  @equiv{}  u.i = x
2221 u = (union foo) y  @equiv{}  u.d = y
2222 @end smallexample
2224 You can also use the union cast as a function argument:
2226 @smallexample
2227 void hack (union foo);
2228 /* @r{@dots{}} */
2229 hack ((union foo) x);
2230 @end smallexample
2232 @node Mixed Declarations
2233 @section Mixed Declarations and Code
2234 @cindex mixed declarations and code
2235 @cindex declarations, mixed with code
2236 @cindex code, mixed with declarations
2238 ISO C99 and ISO C++ allow declarations and code to be freely mixed
2239 within compound statements.  As an extension, GNU C also allows this in
2240 C90 mode.  For example, you could do:
2242 @smallexample
2243 int i;
2244 /* @r{@dots{}} */
2245 i++;
2246 int j = i + 2;
2247 @end smallexample
2249 Each identifier is visible from where it is declared until the end of
2250 the enclosing block.
2252 @node Function Attributes
2253 @section Declaring Attributes of Functions
2254 @cindex function attributes
2255 @cindex declaring attributes of functions
2256 @cindex @code{volatile} applied to function
2257 @cindex @code{const} applied to function
2259 In GNU C, you can use function attributes to declare certain things
2260 about functions called in your program which help the compiler
2261 optimize calls and check your code more carefully.  For example, you
2262 can use attributes to declare that a function never returns
2263 (@code{noreturn}), returns a value depending only on its arguments
2264 (@code{pure}), or has @code{printf}-style arguments (@code{format}).
2266 You can also use attributes to control memory placement, code
2267 generation options or call/return conventions within the function
2268 being annotated.  Many of these attributes are target-specific.  For
2269 example, many targets support attributes for defining interrupt
2270 handler functions, which typically must follow special register usage
2271 and return conventions.
2273 Function attributes are introduced by the @code{__attribute__} keyword
2274 on a declaration, followed by an attribute specification inside double
2275 parentheses.  You can specify multiple attributes in a declaration by
2276 separating them by commas within the double parentheses or by
2277 immediately following an attribute declaration with another attribute
2278 declaration.  @xref{Attribute Syntax}, for the exact rules on
2279 attribute syntax and placement.
2281 GCC also supports attributes on
2282 variable declarations (@pxref{Variable Attributes}),
2283 labels (@pxref{Label Attributes}),
2284 enumerators (@pxref{Enumerator Attributes}),
2285 statements (@pxref{Statement Attributes}),
2286 and types (@pxref{Type Attributes}).
2288 There is some overlap between the purposes of attributes and pragmas
2289 (@pxref{Pragmas,,Pragmas Accepted by GCC}).  It has been
2290 found convenient to use @code{__attribute__} to achieve a natural
2291 attachment of attributes to their corresponding declarations, whereas
2292 @code{#pragma} is of use for compatibility with other compilers
2293 or constructs that do not naturally form part of the grammar.
2295 In addition to the attributes documented here,
2296 GCC plugins may provide their own attributes.
2298 @menu
2299 * Common Function Attributes::
2300 * AArch64 Function Attributes::
2301 * ARC Function Attributes::
2302 * ARM Function Attributes::
2303 * AVR Function Attributes::
2304 * Blackfin Function Attributes::
2305 * CR16 Function Attributes::
2306 * Epiphany Function Attributes::
2307 * H8/300 Function Attributes::
2308 * IA-64 Function Attributes::
2309 * M32C Function Attributes::
2310 * M32R/D Function Attributes::
2311 * m68k Function Attributes::
2312 * MCORE Function Attributes::
2313 * MeP Function Attributes::
2314 * MicroBlaze Function Attributes::
2315 * Microsoft Windows Function Attributes::
2316 * MIPS Function Attributes::
2317 * MSP430 Function Attributes::
2318 * NDS32 Function Attributes::
2319 * Nios II Function Attributes::
2320 * Nvidia PTX Function Attributes::
2321 * PowerPC Function Attributes::
2322 * RISC-V Function Attributes::
2323 * RL78 Function Attributes::
2324 * RX Function Attributes::
2325 * S/390 Function Attributes::
2326 * SH Function Attributes::
2327 * SPU Function Attributes::
2328 * Symbian OS Function Attributes::
2329 * V850 Function Attributes::
2330 * Visium Function Attributes::
2331 * x86 Function Attributes::
2332 * Xstormy16 Function Attributes::
2333 @end menu
2335 @node Common Function Attributes
2336 @subsection Common Function Attributes
2338 The following attributes are supported on most targets.
2340 @table @code
2341 @c Keep this table alphabetized by attribute name.  Treat _ as space.
2343 @item alias ("@var{target}")
2344 @cindex @code{alias} function attribute
2345 The @code{alias} attribute causes the declaration to be emitted as an
2346 alias for another symbol, which must be specified.  For instance,
2348 @smallexample
2349 void __f () @{ /* @r{Do something.} */; @}
2350 void f () __attribute__ ((weak, alias ("__f")));
2351 @end smallexample
2353 @noindent
2354 defines @samp{f} to be a weak alias for @samp{__f}.  In C++, the
2355 mangled name for the target must be used.  It is an error if @samp{__f}
2356 is not defined in the same translation unit.
2358 This attribute requires assembler and object file support,
2359 and may not be available on all targets.
2361 @item aligned (@var{alignment})
2362 @cindex @code{aligned} function attribute
2363 This attribute specifies a minimum alignment for the function,
2364 measured in bytes.
2366 You cannot use this attribute to decrease the alignment of a function,
2367 only to increase it.  However, when you explicitly specify a function
2368 alignment this overrides the effect of the
2369 @option{-falign-functions} (@pxref{Optimize Options}) option for this
2370 function.
2372 Note that the effectiveness of @code{aligned} attributes may be
2373 limited by inherent limitations in your linker.  On many systems, the
2374 linker is only able to arrange for functions to be aligned up to a
2375 certain maximum alignment.  (For some linkers, the maximum supported
2376 alignment may be very very small.)  See your linker documentation for
2377 further information.
2379 The @code{aligned} attribute can also be used for variables and fields
2380 (@pxref{Variable Attributes}.)
2382 @item alloc_align
2383 @cindex @code{alloc_align} function attribute
2384 The @code{alloc_align} attribute is used to tell the compiler that the
2385 function return value points to memory, where the returned pointer minimum
2386 alignment is given by one of the functions parameters.  GCC uses this
2387 information to improve pointer alignment analysis.
2389 The function parameter denoting the allocated alignment is specified by
2390 one integer argument, whose number is the argument of the attribute.
2391 Argument numbering starts at one.
2393 For instance,
2395 @smallexample
2396 void* my_memalign(size_t, size_t) __attribute__((alloc_align(1)))
2397 @end smallexample
2399 @noindent
2400 declares that @code{my_memalign} returns memory with minimum alignment
2401 given by parameter 1.
2403 @item alloc_size
2404 @cindex @code{alloc_size} function attribute
2405 The @code{alloc_size} attribute is used to tell the compiler that the
2406 function return value points to memory, where the size is given by
2407 one or two of the functions parameters.  GCC uses this
2408 information to improve the correctness of @code{__builtin_object_size}.
2410 The function parameter(s) denoting the allocated size are specified by
2411 one or two integer arguments supplied to the attribute.  The allocated size
2412 is either the value of the single function argument specified or the product
2413 of the two function arguments specified.  Argument numbering starts at
2414 one.
2416 For instance,
2418 @smallexample
2419 void* my_calloc(size_t, size_t) __attribute__((alloc_size(1,2)))
2420 void* my_realloc(void*, size_t) __attribute__((alloc_size(2)))
2421 @end smallexample
2423 @noindent
2424 declares that @code{my_calloc} returns memory of the size given by
2425 the product of parameter 1 and 2 and that @code{my_realloc} returns memory
2426 of the size given by parameter 2.
2428 @item always_inline
2429 @cindex @code{always_inline} function attribute
2430 Generally, functions are not inlined unless optimization is specified.
2431 For functions declared inline, this attribute inlines the function
2432 independent of any restrictions that otherwise apply to inlining.
2433 Failure to inline such a function is diagnosed as an error.
2434 Note that if such a function is called indirectly the compiler may
2435 or may not inline it depending on optimization level and a failure
2436 to inline an indirect call may or may not be diagnosed.
2438 @item artificial
2439 @cindex @code{artificial} function attribute
2440 This attribute is useful for small inline wrappers that if possible
2441 should appear during debugging as a unit.  Depending on the debug
2442 info format it either means marking the function as artificial
2443 or using the caller location for all instructions within the inlined
2444 body.
2446 @item assume_aligned
2447 @cindex @code{assume_aligned} function attribute
2448 The @code{assume_aligned} attribute is used to tell the compiler that the
2449 function return value points to memory, where the returned pointer minimum
2450 alignment is given by the first argument.
2451 If the attribute has two arguments, the second argument is misalignment offset.
2453 For instance
2455 @smallexample
2456 void* my_alloc1(size_t) __attribute__((assume_aligned(16)))
2457 void* my_alloc2(size_t) __attribute__((assume_aligned(32, 8)))
2458 @end smallexample
2460 @noindent
2461 declares that @code{my_alloc1} returns 16-byte aligned pointer and
2462 that @code{my_alloc2} returns a pointer whose value modulo 32 is equal
2463 to 8.
2465 @item bnd_instrument
2466 @cindex @code{bnd_instrument} function attribute
2467 The @code{bnd_instrument} attribute on functions is used to inform the
2468 compiler that the function should be instrumented when compiled
2469 with the @option{-fchkp-instrument-marked-only} option.
2471 @item bnd_legacy
2472 @cindex @code{bnd_legacy} function attribute
2473 @cindex Pointer Bounds Checker attributes
2474 The @code{bnd_legacy} attribute on functions is used to inform the
2475 compiler that the function should not be instrumented when compiled
2476 with the @option{-fcheck-pointer-bounds} option.
2478 @item cold
2479 @cindex @code{cold} function attribute
2480 The @code{cold} attribute on functions is used to inform the compiler that
2481 the function is unlikely to be executed.  The function is optimized for
2482 size rather than speed and on many targets it is placed into a special
2483 subsection of the text section so all cold functions appear close together,
2484 improving code locality of non-cold parts of program.  The paths leading
2485 to calls of cold functions within code are marked as unlikely by the branch
2486 prediction mechanism.  It is thus useful to mark functions used to handle
2487 unlikely conditions, such as @code{perror}, as cold to improve optimization
2488 of hot functions that do call marked functions in rare occasions.
2490 When profile feedback is available, via @option{-fprofile-use}, cold functions
2491 are automatically detected and this attribute is ignored.
2493 @item const
2494 @cindex @code{const} function attribute
2495 @cindex functions that have no side effects
2496 Many functions do not examine any values except their arguments, and
2497 have no effects except to return a value.  Calls to such functions lend
2498 themselves to optimization such as common subexpression elimination.
2499 The @code{const} attribute imposes greater restrictions on a function's
2500 definition than the similar @code{pure} attribute below because it prohibits
2501 the function from reading global variables.  Consequently, the presence of
2502 the attribute on a function declarations allows GCC to emit more efficient
2503 code for some calls to the function.  Decorating the same function with
2504 both the @code{const} and the @code{pure} attribute is diagnosed.
2506 @cindex pointer arguments
2507 Note that a function that has pointer arguments and examines the data
2508 pointed to must @emph{not} be declared @code{const}.  Likewise, a
2509 function that calls a non-@code{const} function usually must not be
2510 @code{const}.  It does not make sense for a @code{const} function to
2511 return @code{void}.
2513 @item constructor
2514 @itemx destructor
2515 @itemx constructor (@var{priority})
2516 @itemx destructor (@var{priority})
2517 @cindex @code{constructor} function attribute
2518 @cindex @code{destructor} function attribute
2519 The @code{constructor} attribute causes the function to be called
2520 automatically before execution enters @code{main ()}.  Similarly, the
2521 @code{destructor} attribute causes the function to be called
2522 automatically after @code{main ()} completes or @code{exit ()} is
2523 called.  Functions with these attributes are useful for
2524 initializing data that is used implicitly during the execution of
2525 the program.
2527 You may provide an optional integer priority to control the order in
2528 which constructor and destructor functions are run.  A constructor
2529 with a smaller priority number runs before a constructor with a larger
2530 priority number; the opposite relationship holds for destructors.  So,
2531 if you have a constructor that allocates a resource and a destructor
2532 that deallocates the same resource, both functions typically have the
2533 same priority.  The priorities for constructor and destructor
2534 functions are the same as those specified for namespace-scope C++
2535 objects (@pxref{C++ Attributes}).  However, at present, the order in which
2536 constructors for C++ objects with static storage duration and functions
2537 decorated with attribute @code{constructor} are invoked is unspecified.
2538 In mixed declarations, attribute @code{init_priority} can be used to
2539 impose a specific ordering.
2541 @item deprecated
2542 @itemx deprecated (@var{msg})
2543 @cindex @code{deprecated} function attribute
2544 The @code{deprecated} attribute results in a warning if the function
2545 is used anywhere in the source file.  This is useful when identifying
2546 functions that are expected to be removed in a future version of a
2547 program.  The warning also includes the location of the declaration
2548 of the deprecated function, to enable users to easily find further
2549 information about why the function is deprecated, or what they should
2550 do instead.  Note that the warnings only occurs for uses:
2552 @smallexample
2553 int old_fn () __attribute__ ((deprecated));
2554 int old_fn ();
2555 int (*fn_ptr)() = old_fn;
2556 @end smallexample
2558 @noindent
2559 results in a warning on line 3 but not line 2.  The optional @var{msg}
2560 argument, which must be a string, is printed in the warning if
2561 present.
2563 The @code{deprecated} attribute can also be used for variables and
2564 types (@pxref{Variable Attributes}, @pxref{Type Attributes}.)
2566 @item error ("@var{message}")
2567 @itemx warning ("@var{message}")
2568 @cindex @code{error} function attribute
2569 @cindex @code{warning} function attribute
2570 If the @code{error} or @code{warning} attribute 
2571 is used on a function declaration and a call to such a function
2572 is not eliminated through dead code elimination or other optimizations, 
2573 an error or warning (respectively) that includes @var{message} is diagnosed.  
2574 This is useful
2575 for compile-time checking, especially together with @code{__builtin_constant_p}
2576 and inline functions where checking the inline function arguments is not
2577 possible through @code{extern char [(condition) ? 1 : -1];} tricks.
2579 While it is possible to leave the function undefined and thus invoke
2580 a link failure (to define the function with
2581 a message in @code{.gnu.warning*} section),
2582 when using these attributes the problem is diagnosed
2583 earlier and with exact location of the call even in presence of inline
2584 functions or when not emitting debugging information.
2586 @item externally_visible
2587 @cindex @code{externally_visible} function attribute
2588 This attribute, attached to a global variable or function, nullifies
2589 the effect of the @option{-fwhole-program} command-line option, so the
2590 object remains visible outside the current compilation unit.
2592 If @option{-fwhole-program} is used together with @option{-flto} and 
2593 @command{gold} is used as the linker plugin, 
2594 @code{externally_visible} attributes are automatically added to functions 
2595 (not variable yet due to a current @command{gold} issue) 
2596 that are accessed outside of LTO objects according to resolution file
2597 produced by @command{gold}.
2598 For other linkers that cannot generate resolution file,
2599 explicit @code{externally_visible} attributes are still necessary.
2601 @item flatten
2602 @cindex @code{flatten} function attribute
2603 Generally, inlining into a function is limited.  For a function marked with
2604 this attribute, every call inside this function is inlined, if possible.
2605 Whether the function itself is considered for inlining depends on its size and
2606 the current inlining parameters.
2608 @item format (@var{archetype}, @var{string-index}, @var{first-to-check})
2609 @cindex @code{format} function attribute
2610 @cindex functions with @code{printf}, @code{scanf}, @code{strftime} or @code{strfmon} style arguments
2611 @opindex Wformat
2612 The @code{format} attribute specifies that a function takes @code{printf},
2613 @code{scanf}, @code{strftime} or @code{strfmon} style arguments that
2614 should be type-checked against a format string.  For example, the
2615 declaration:
2617 @smallexample
2618 extern int
2619 my_printf (void *my_object, const char *my_format, ...)
2620       __attribute__ ((format (printf, 2, 3)));
2621 @end smallexample
2623 @noindent
2624 causes the compiler to check the arguments in calls to @code{my_printf}
2625 for consistency with the @code{printf} style format string argument
2626 @code{my_format}.
2628 The parameter @var{archetype} determines how the format string is
2629 interpreted, and should be @code{printf}, @code{scanf}, @code{strftime},
2630 @code{gnu_printf}, @code{gnu_scanf}, @code{gnu_strftime} or
2631 @code{strfmon}.  (You can also use @code{__printf__},
2632 @code{__scanf__}, @code{__strftime__} or @code{__strfmon__}.)  On
2633 MinGW targets, @code{ms_printf}, @code{ms_scanf}, and
2634 @code{ms_strftime} are also present.
2635 @var{archetype} values such as @code{printf} refer to the formats accepted
2636 by the system's C runtime library,
2637 while values prefixed with @samp{gnu_} always refer
2638 to the formats accepted by the GNU C Library.  On Microsoft Windows
2639 targets, values prefixed with @samp{ms_} refer to the formats accepted by the
2640 @file{msvcrt.dll} library.
2641 The parameter @var{string-index}
2642 specifies which argument is the format string argument (starting
2643 from 1), while @var{first-to-check} is the number of the first
2644 argument to check against the format string.  For functions
2645 where the arguments are not available to be checked (such as
2646 @code{vprintf}), specify the third parameter as zero.  In this case the
2647 compiler only checks the format string for consistency.  For
2648 @code{strftime} formats, the third parameter is required to be zero.
2649 Since non-static C++ methods have an implicit @code{this} argument, the
2650 arguments of such methods should be counted from two, not one, when
2651 giving values for @var{string-index} and @var{first-to-check}.
2653 In the example above, the format string (@code{my_format}) is the second
2654 argument of the function @code{my_print}, and the arguments to check
2655 start with the third argument, so the correct parameters for the format
2656 attribute are 2 and 3.
2658 @opindex ffreestanding
2659 @opindex fno-builtin
2660 The @code{format} attribute allows you to identify your own functions
2661 that take format strings as arguments, so that GCC can check the
2662 calls to these functions for errors.  The compiler always (unless
2663 @option{-ffreestanding} or @option{-fno-builtin} is used) checks formats
2664 for the standard library functions @code{printf}, @code{fprintf},
2665 @code{sprintf}, @code{scanf}, @code{fscanf}, @code{sscanf}, @code{strftime},
2666 @code{vprintf}, @code{vfprintf} and @code{vsprintf} whenever such
2667 warnings are requested (using @option{-Wformat}), so there is no need to
2668 modify the header file @file{stdio.h}.  In C99 mode, the functions
2669 @code{snprintf}, @code{vsnprintf}, @code{vscanf}, @code{vfscanf} and
2670 @code{vsscanf} are also checked.  Except in strictly conforming C
2671 standard modes, the X/Open function @code{strfmon} is also checked as
2672 are @code{printf_unlocked} and @code{fprintf_unlocked}.
2673 @xref{C Dialect Options,,Options Controlling C Dialect}.
2675 For Objective-C dialects, @code{NSString} (or @code{__NSString__}) is
2676 recognized in the same context.  Declarations including these format attributes
2677 are parsed for correct syntax, however the result of checking of such format
2678 strings is not yet defined, and is not carried out by this version of the
2679 compiler.
2681 The target may also provide additional types of format checks.
2682 @xref{Target Format Checks,,Format Checks Specific to Particular
2683 Target Machines}.
2685 @item format_arg (@var{string-index})
2686 @cindex @code{format_arg} function attribute
2687 @opindex Wformat-nonliteral
2688 The @code{format_arg} attribute specifies that a function takes a format
2689 string for a @code{printf}, @code{scanf}, @code{strftime} or
2690 @code{strfmon} style function and modifies it (for example, to translate
2691 it into another language), so the result can be passed to a
2692 @code{printf}, @code{scanf}, @code{strftime} or @code{strfmon} style
2693 function (with the remaining arguments to the format function the same
2694 as they would have been for the unmodified string).  For example, the
2695 declaration:
2697 @smallexample
2698 extern char *
2699 my_dgettext (char *my_domain, const char *my_format)
2700       __attribute__ ((format_arg (2)));
2701 @end smallexample
2703 @noindent
2704 causes the compiler to check the arguments in calls to a @code{printf},
2705 @code{scanf}, @code{strftime} or @code{strfmon} type function, whose
2706 format string argument is a call to the @code{my_dgettext} function, for
2707 consistency with the format string argument @code{my_format}.  If the
2708 @code{format_arg} attribute had not been specified, all the compiler
2709 could tell in such calls to format functions would be that the format
2710 string argument is not constant; this would generate a warning when
2711 @option{-Wformat-nonliteral} is used, but the calls could not be checked
2712 without the attribute.
2714 The parameter @var{string-index} specifies which argument is the format
2715 string argument (starting from one).  Since non-static C++ methods have
2716 an implicit @code{this} argument, the arguments of such methods should
2717 be counted from two.
2719 The @code{format_arg} attribute allows you to identify your own
2720 functions that modify format strings, so that GCC can check the
2721 calls to @code{printf}, @code{scanf}, @code{strftime} or @code{strfmon}
2722 type function whose operands are a call to one of your own function.
2723 The compiler always treats @code{gettext}, @code{dgettext}, and
2724 @code{dcgettext} in this manner except when strict ISO C support is
2725 requested by @option{-ansi} or an appropriate @option{-std} option, or
2726 @option{-ffreestanding} or @option{-fno-builtin}
2727 is used.  @xref{C Dialect Options,,Options
2728 Controlling C Dialect}.
2730 For Objective-C dialects, the @code{format-arg} attribute may refer to an
2731 @code{NSString} reference for compatibility with the @code{format} attribute
2732 above.
2734 The target may also allow additional types in @code{format-arg} attributes.
2735 @xref{Target Format Checks,,Format Checks Specific to Particular
2736 Target Machines}.
2738 @item gnu_inline
2739 @cindex @code{gnu_inline} function attribute
2740 This attribute should be used with a function that is also declared
2741 with the @code{inline} keyword.  It directs GCC to treat the function
2742 as if it were defined in gnu90 mode even when compiling in C99 or
2743 gnu99 mode.
2745 If the function is declared @code{extern}, then this definition of the
2746 function is used only for inlining.  In no case is the function
2747 compiled as a standalone function, not even if you take its address
2748 explicitly.  Such an address becomes an external reference, as if you
2749 had only declared the function, and had not defined it.  This has
2750 almost the effect of a macro.  The way to use this is to put a
2751 function definition in a header file with this attribute, and put
2752 another copy of the function, without @code{extern}, in a library
2753 file.  The definition in the header file causes most calls to the
2754 function to be inlined.  If any uses of the function remain, they
2755 refer to the single copy in the library.  Note that the two
2756 definitions of the functions need not be precisely the same, although
2757 if they do not have the same effect your program may behave oddly.
2759 In C, if the function is neither @code{extern} nor @code{static}, then
2760 the function is compiled as a standalone function, as well as being
2761 inlined where possible.
2763 This is how GCC traditionally handled functions declared
2764 @code{inline}.  Since ISO C99 specifies a different semantics for
2765 @code{inline}, this function attribute is provided as a transition
2766 measure and as a useful feature in its own right.  This attribute is
2767 available in GCC 4.1.3 and later.  It is available if either of the
2768 preprocessor macros @code{__GNUC_GNU_INLINE__} or
2769 @code{__GNUC_STDC_INLINE__} are defined.  @xref{Inline,,An Inline
2770 Function is As Fast As a Macro}.
2772 In C++, this attribute does not depend on @code{extern} in any way,
2773 but it still requires the @code{inline} keyword to enable its special
2774 behavior.
2776 @item hot
2777 @cindex @code{hot} function attribute
2778 The @code{hot} attribute on a function is used to inform the compiler that
2779 the function is a hot spot of the compiled program.  The function is
2780 optimized more aggressively and on many targets it is placed into a special
2781 subsection of the text section so all hot functions appear close together,
2782 improving locality.
2784 When profile feedback is available, via @option{-fprofile-use}, hot functions
2785 are automatically detected and this attribute is ignored.
2787 @item ifunc ("@var{resolver}")
2788 @cindex @code{ifunc} function attribute
2789 @cindex indirect functions
2790 @cindex functions that are dynamically resolved
2791 The @code{ifunc} attribute is used to mark a function as an indirect
2792 function using the STT_GNU_IFUNC symbol type extension to the ELF
2793 standard.  This allows the resolution of the symbol value to be
2794 determined dynamically at load time, and an optimized version of the
2795 routine to be selected for the particular processor or other system
2796 characteristics determined then.  To use this attribute, first define
2797 the implementation functions available, and a resolver function that
2798 returns a pointer to the selected implementation function.  The
2799 implementation functions' declarations must match the API of the
2800 function being implemented.  The resolver should be declared to
2801 be a function taking no arguments and returning a pointer to
2802 a function of the same type as the implementation.  For example:
2804 @smallexample
2805 void *my_memcpy (void *dst, const void *src, size_t len)
2807   @dots{}
2808   return dst;
2811 static void * (*resolve_memcpy (void))(void *, const void *, size_t)
2813   return my_memcpy; // we will just always select this routine
2815 @end smallexample
2817 @noindent
2818 The exported header file declaring the function the user calls would
2819 contain:
2821 @smallexample
2822 extern void *memcpy (void *, const void *, size_t);
2823 @end smallexample
2825 @noindent
2826 allowing the user to call @code{memcpy} as a regular function, unaware of
2827 the actual implementation.  Finally, the indirect function needs to be
2828 defined in the same translation unit as the resolver function:
2830 @smallexample
2831 void *memcpy (void *, const void *, size_t)
2832      __attribute__ ((ifunc ("resolve_memcpy")));
2833 @end smallexample
2835 In C++, the @code{ifunc} attribute takes a string that is the mangled name
2836 of the resolver function.  A C++ resolver for a non-static member function
2837 of class @code{C} should be declared to return a pointer to a non-member
2838 function taking pointer to @code{C} as the first argument, followed by
2839 the same arguments as of the implementation function.  G++ checks
2840 the signatures of the two functions and issues
2841 a @option{-Wattribute-alias} warning for mismatches.  To suppress a warning
2842 for the necessary cast from a pointer to the implementation member function
2843 to the type of the corresponding non-member function use
2844 the @option{-Wno-pmf-conversions} option.  For example:
2846 @smallexample
2847 class S
2849 private:
2850   int debug_impl (int);
2851   int optimized_impl (int);
2853   typedef int Func (S*, int);
2855   static Func* resolver ();
2856 public:
2858   int interface (int);
2861 int S::debug_impl (int) @{ /* @r{@dots{}} */ @}
2862 int S::optimized_impl (int) @{ /* @r{@dots{}} */ @}
2864 S::Func* S::resolver ()
2866   int (S::*pimpl) (int)
2867     = getenv ("DEBUG") ? &S::debug_impl : &S::optimized_impl;
2869   // Cast triggers -Wno-pmf-conversions.
2870   return reinterpret_cast<Func*>(pimpl);
2873 int S::interface (int) __attribute__ ((ifunc ("_ZN1S8resolverEv")));
2874 @end smallexample
2876 Indirect functions cannot be weak.  Binutils version 2.20.1 or higher
2877 and GNU C Library version 2.11.1 are required to use this feature.
2879 @item interrupt
2880 @itemx interrupt_handler
2881 Many GCC back ends support attributes to indicate that a function is
2882 an interrupt handler, which tells the compiler to generate function
2883 entry and exit sequences that differ from those from regular
2884 functions.  The exact syntax and behavior are target-specific;
2885 refer to the following subsections for details.
2887 @item leaf
2888 @cindex @code{leaf} function attribute
2889 Calls to external functions with this attribute must return to the
2890 current compilation unit only by return or by exception handling.  In
2891 particular, a leaf function is not allowed to invoke callback functions
2892 passed to it from the current compilation unit, directly call functions
2893 exported by the unit, or @code{longjmp} into the unit.  Leaf functions
2894 might still call functions from other compilation units and thus they
2895 are not necessarily leaf in the sense that they contain no function
2896 calls at all.
2898 The attribute is intended for library functions to improve dataflow
2899 analysis.  The compiler takes the hint that any data not escaping the
2900 current compilation unit cannot be used or modified by the leaf
2901 function.  For example, the @code{sin} function is a leaf function, but
2902 @code{qsort} is not.
2904 Note that leaf functions might indirectly run a signal handler defined
2905 in the current compilation unit that uses static variables.  Similarly,
2906 when lazy symbol resolution is in effect, leaf functions might invoke
2907 indirect functions whose resolver function or implementation function is
2908 defined in the current compilation unit and uses static variables.  There
2909 is no standard-compliant way to write such a signal handler, resolver
2910 function, or implementation function, and the best that you can do is to
2911 remove the @code{leaf} attribute or mark all such static variables
2912 @code{volatile}.  Lastly, for ELF-based systems that support symbol
2913 interposition, care should be taken that functions defined in the
2914 current compilation unit do not unexpectedly interpose other symbols
2915 based on the defined standards mode and defined feature test macros;
2916 otherwise an inadvertent callback would be added.
2918 The attribute has no effect on functions defined within the current
2919 compilation unit.  This is to allow easy merging of multiple compilation
2920 units into one, for example, by using the link-time optimization.  For
2921 this reason the attribute is not allowed on types to annotate indirect
2922 calls.
2924 @item malloc
2925 @cindex @code{malloc} function attribute
2926 @cindex functions that behave like malloc
2927 This tells the compiler that a function is @code{malloc}-like, i.e.,
2928 that the pointer @var{P} returned by the function cannot alias any
2929 other pointer valid when the function returns, and moreover no
2930 pointers to valid objects occur in any storage addressed by @var{P}.
2932 Using this attribute can improve optimization.  Functions like
2933 @code{malloc} and @code{calloc} have this property because they return
2934 a pointer to uninitialized or zeroed-out storage.  However, functions
2935 like @code{realloc} do not have this property, as they can return a
2936 pointer to storage containing pointers.
2938 @item no_icf
2939 @cindex @code{no_icf} function attribute
2940 This function attribute prevents a functions from being merged with another
2941 semantically equivalent function.
2943 @item no_instrument_function
2944 @cindex @code{no_instrument_function} function attribute
2945 @opindex finstrument-functions
2946 If @option{-finstrument-functions} is given, profiling function calls are
2947 generated at entry and exit of most user-compiled functions.
2948 Functions with this attribute are not so instrumented.
2950 @item no_profile_instrument_function
2951 @cindex @code{no_profile_instrument_function} function attribute
2952 The @code{no_profile_instrument_function} attribute on functions is used
2953 to inform the compiler that it should not process any profile feedback based
2954 optimization code instrumentation.
2956 @item no_reorder
2957 @cindex @code{no_reorder} function attribute
2958 Do not reorder functions or variables marked @code{no_reorder}
2959 against each other or top level assembler statements the executable.
2960 The actual order in the program will depend on the linker command
2961 line. Static variables marked like this are also not removed.
2962 This has a similar effect
2963 as the @option{-fno-toplevel-reorder} option, but only applies to the
2964 marked symbols.
2966 @item no_sanitize ("@var{sanitize_option}")
2967 @cindex @code{no_sanitize} function attribute
2968 The @code{no_sanitize} attribute on functions is used
2969 to inform the compiler that it should not do sanitization of all options
2970 mentioned in @var{sanitize_option}.  A list of values acceptable by
2971 @option{-fsanitize} option can be provided.
2973 @smallexample
2974 void __attribute__ ((no_sanitize ("alignment", "object-size")))
2975 f () @{ /* @r{Do something.} */; @}
2976 @end smallexample
2978 @item no_sanitize_address
2979 @itemx no_address_safety_analysis
2980 @cindex @code{no_sanitize_address} function attribute
2981 The @code{no_sanitize_address} attribute on functions is used
2982 to inform the compiler that it should not instrument memory accesses
2983 in the function when compiling with the @option{-fsanitize=address} option.
2984 The @code{no_address_safety_analysis} is a deprecated alias of the
2985 @code{no_sanitize_address} attribute, new code should use
2986 @code{no_sanitize_address}.
2988 @item no_sanitize_thread
2989 @cindex @code{no_sanitize_thread} function attribute
2990 The @code{no_sanitize_thread} attribute on functions is used
2991 to inform the compiler that it should not instrument memory accesses
2992 in the function when compiling with the @option{-fsanitize=thread} option.
2994 @item no_sanitize_undefined
2995 @cindex @code{no_sanitize_undefined} function attribute
2996 The @code{no_sanitize_undefined} attribute on functions is used
2997 to inform the compiler that it should not check for undefined behavior
2998 in the function when compiling with the @option{-fsanitize=undefined} option.
3000 @item no_split_stack
3001 @cindex @code{no_split_stack} function attribute
3002 @opindex fsplit-stack
3003 If @option{-fsplit-stack} is given, functions have a small
3004 prologue which decides whether to split the stack.  Functions with the
3005 @code{no_split_stack} attribute do not have that prologue, and thus
3006 may run with only a small amount of stack space available.
3008 @item no_stack_limit
3009 @cindex @code{no_stack_limit} function attribute
3010 This attribute locally overrides the @option{-fstack-limit-register}
3011 and @option{-fstack-limit-symbol} command-line options; it has the effect
3012 of disabling stack limit checking in the function it applies to.
3014 @item noclone
3015 @cindex @code{noclone} function attribute
3016 This function attribute prevents a function from being considered for
3017 cloning---a mechanism that produces specialized copies of functions
3018 and which is (currently) performed by interprocedural constant
3019 propagation.
3021 @item noinline
3022 @cindex @code{noinline} function attribute
3023 This function attribute prevents a function from being considered for
3024 inlining.
3025 @c Don't enumerate the optimizations by name here; we try to be
3026 @c future-compatible with this mechanism.
3027 If the function does not have side-effects, there are optimizations
3028 other than inlining that cause function calls to be optimized away,
3029 although the function call is live.  To keep such calls from being
3030 optimized away, put
3031 @smallexample
3032 asm ("");
3033 @end smallexample
3035 @noindent
3036 (@pxref{Extended Asm}) in the called function, to serve as a special
3037 side-effect.
3039 @item noipa
3040 @cindex @code{noipa} function attribute
3041 Disable interprocedural optimizations between the function with this
3042 attribute and its callers, as if the body of the function is not available
3043 when optimizing callers and the callers are unavailable when optimizing
3044 the body.  This attribute implies @code{noinline}, @code{noclone} and
3045 @code{no_icf} attributes.    However, this attribute is not equivalent
3046 to a combination of other attributes, because its purpose is to suppress
3047 existing and future optimizations employing interprocedural analysis,
3048 including those that do not have an attribute suitable for disabling
3049 them individually.  This attribute is supported mainly for the purpose
3050 of testing the compiler.
3052 @item nonnull (@var{arg-index}, @dots{})
3053 @cindex @code{nonnull} function attribute
3054 @cindex functions with non-null pointer arguments
3055 The @code{nonnull} attribute specifies that some function parameters should
3056 be non-null pointers.  For instance, the declaration:
3058 @smallexample
3059 extern void *
3060 my_memcpy (void *dest, const void *src, size_t len)
3061         __attribute__((nonnull (1, 2)));
3062 @end smallexample
3064 @noindent
3065 causes the compiler to check that, in calls to @code{my_memcpy},
3066 arguments @var{dest} and @var{src} are non-null.  If the compiler
3067 determines that a null pointer is passed in an argument slot marked
3068 as non-null, and the @option{-Wnonnull} option is enabled, a warning
3069 is issued.  The compiler may also choose to make optimizations based
3070 on the knowledge that certain function arguments will never be null.
3072 If no argument index list is given to the @code{nonnull} attribute,
3073 all pointer arguments are marked as non-null.  To illustrate, the
3074 following declaration is equivalent to the previous example:
3076 @smallexample
3077 extern void *
3078 my_memcpy (void *dest, const void *src, size_t len)
3079         __attribute__((nonnull));
3080 @end smallexample
3082 @item noplt
3083 @cindex @code{noplt} function attribute
3084 The @code{noplt} attribute is the counterpart to option @option{-fno-plt}.
3085 Calls to functions marked with this attribute in position-independent code
3086 do not use the PLT.
3088 @smallexample
3089 @group
3090 /* Externally defined function foo.  */
3091 int foo () __attribute__ ((noplt));
3094 main (/* @r{@dots{}} */)
3096   /* @r{@dots{}} */
3097   foo ();
3098   /* @r{@dots{}} */
3100 @end group
3101 @end smallexample
3103 The @code{noplt} attribute on function @code{foo}
3104 tells the compiler to assume that
3105 the function @code{foo} is externally defined and that the call to
3106 @code{foo} must avoid the PLT
3107 in position-independent code.
3109 In position-dependent code, a few targets also convert calls to
3110 functions that are marked to not use the PLT to use the GOT instead.
3112 @item noreturn
3113 @cindex @code{noreturn} function attribute
3114 @cindex functions that never return
3115 A few standard library functions, such as @code{abort} and @code{exit},
3116 cannot return.  GCC knows this automatically.  Some programs define
3117 their own functions that never return.  You can declare them
3118 @code{noreturn} to tell the compiler this fact.  For example,
3120 @smallexample
3121 @group
3122 void fatal () __attribute__ ((noreturn));
3124 void
3125 fatal (/* @r{@dots{}} */)
3127   /* @r{@dots{}} */ /* @r{Print error message.} */ /* @r{@dots{}} */
3128   exit (1);
3130 @end group
3131 @end smallexample
3133 The @code{noreturn} keyword tells the compiler to assume that
3134 @code{fatal} cannot return.  It can then optimize without regard to what
3135 would happen if @code{fatal} ever did return.  This makes slightly
3136 better code.  More importantly, it helps avoid spurious warnings of
3137 uninitialized variables.
3139 The @code{noreturn} keyword does not affect the exceptional path when that
3140 applies: a @code{noreturn}-marked function may still return to the caller
3141 by throwing an exception or calling @code{longjmp}.
3143 Do not assume that registers saved by the calling function are
3144 restored before calling the @code{noreturn} function.
3146 It does not make sense for a @code{noreturn} function to have a return
3147 type other than @code{void}.
3149 @item nothrow
3150 @cindex @code{nothrow} function attribute
3151 The @code{nothrow} attribute is used to inform the compiler that a
3152 function cannot throw an exception.  For example, most functions in
3153 the standard C library can be guaranteed not to throw an exception
3154 with the notable exceptions of @code{qsort} and @code{bsearch} that
3155 take function pointer arguments.
3157 @item optimize
3158 @cindex @code{optimize} function attribute
3159 The @code{optimize} attribute is used to specify that a function is to
3160 be compiled with different optimization options than specified on the
3161 command line.  Arguments can either be numbers or strings.  Numbers
3162 are assumed to be an optimization level.  Strings that begin with
3163 @code{O} are assumed to be an optimization option, while other options
3164 are assumed to be used with a @code{-f} prefix.  You can also use the
3165 @samp{#pragma GCC optimize} pragma to set the optimization options
3166 that affect more than one function.
3167 @xref{Function Specific Option Pragmas}, for details about the
3168 @samp{#pragma GCC optimize} pragma.
3170 This attribute should be used for debugging purposes only.  It is not
3171 suitable in production code.
3173 @item patchable_function_entry
3174 @cindex @code{patchable_function_entry} function attribute
3175 @cindex extra NOP instructions at the function entry point
3176 In case the target's text segment can be made writable at run time by
3177 any means, padding the function entry with a number of NOPs can be
3178 used to provide a universal tool for instrumentation.
3180 The @code{patchable_function_entry} function attribute can be used to
3181 change the number of NOPs to any desired value.  The two-value syntax
3182 is the same as for the command-line switch
3183 @option{-fpatchable-function-entry=N,M}, generating @var{N} NOPs, with
3184 the function entry point before the @var{M}th NOP instruction.
3185 @var{M} defaults to 0 if omitted e.g. function entry point is before
3186 the first NOP.
3188 If patchable function entries are enabled globally using the command-line
3189 option @option{-fpatchable-function-entry=N,M}, then you must disable
3190 instrumentation on all functions that are part of the instrumentation
3191 framework with the attribute @code{patchable_function_entry (0)}
3192 to prevent recursion.
3194 @item pure
3195 @cindex @code{pure} function attribute
3196 @cindex functions that have no side effects
3197 Many functions have no effects except the return value and their
3198 return value depends only on the parameters and/or global variables.
3199 Calls to such functions can be subject
3200 to common subexpression elimination and loop optimization just as an
3201 arithmetic operator would be.  These functions should be declared
3202 with the attribute @code{pure}.  For example,
3204 @smallexample
3205 int square (int) __attribute__ ((pure));
3206 @end smallexample
3208 @noindent
3209 says that the hypothetical function @code{square} is safe to call
3210 fewer times than the program says.
3212 Some common examples of pure functions are @code{strlen} or @code{memcmp}.
3213 Interesting non-pure functions are functions with infinite loops or those
3214 depending on volatile memory or other system resource, that may change between
3215 two consecutive calls (such as @code{feof} in a multithreading environment).
3217 The @code{pure} attribute imposes similar but looser restrictions on
3218 a function's defintion than the @code{const} attribute: it allows the
3219 function to read global variables.  Decorating the same function with
3220 both the @code{pure} and the @code{const} attribute is diagnosed.
3222 @item returns_nonnull
3223 @cindex @code{returns_nonnull} function attribute
3224 The @code{returns_nonnull} attribute specifies that the function
3225 return value should be a non-null pointer.  For instance, the declaration:
3227 @smallexample
3228 extern void *
3229 mymalloc (size_t len) __attribute__((returns_nonnull));
3230 @end smallexample
3232 @noindent
3233 lets the compiler optimize callers based on the knowledge
3234 that the return value will never be null.
3236 @item returns_twice
3237 @cindex @code{returns_twice} function attribute
3238 @cindex functions that return more than once
3239 The @code{returns_twice} attribute tells the compiler that a function may
3240 return more than one time.  The compiler ensures that all registers
3241 are dead before calling such a function and emits a warning about
3242 the variables that may be clobbered after the second return from the
3243 function.  Examples of such functions are @code{setjmp} and @code{vfork}.
3244 The @code{longjmp}-like counterpart of such function, if any, might need
3245 to be marked with the @code{noreturn} attribute.
3247 @item section ("@var{section-name}")
3248 @cindex @code{section} function attribute
3249 @cindex functions in arbitrary sections
3250 Normally, the compiler places the code it generates in the @code{text} section.
3251 Sometimes, however, you need additional sections, or you need certain
3252 particular functions to appear in special sections.  The @code{section}
3253 attribute specifies that a function lives in a particular section.
3254 For example, the declaration:
3256 @smallexample
3257 extern void foobar (void) __attribute__ ((section ("bar")));
3258 @end smallexample
3260 @noindent
3261 puts the function @code{foobar} in the @code{bar} section.
3263 Some file formats do not support arbitrary sections so the @code{section}
3264 attribute is not available on all platforms.
3265 If you need to map the entire contents of a module to a particular
3266 section, consider using the facilities of the linker instead.
3268 @item sentinel
3269 @cindex @code{sentinel} function attribute
3270 This function attribute ensures that a parameter in a function call is
3271 an explicit @code{NULL}.  The attribute is only valid on variadic
3272 functions.  By default, the sentinel is located at position zero, the
3273 last parameter of the function call.  If an optional integer position
3274 argument P is supplied to the attribute, the sentinel must be located at
3275 position P counting backwards from the end of the argument list.
3277 @smallexample
3278 __attribute__ ((sentinel))
3279 is equivalent to
3280 __attribute__ ((sentinel(0)))
3281 @end smallexample
3283 The attribute is automatically set with a position of 0 for the built-in
3284 functions @code{execl} and @code{execlp}.  The built-in function
3285 @code{execle} has the attribute set with a position of 1.
3287 A valid @code{NULL} in this context is defined as zero with any pointer
3288 type.  If your system defines the @code{NULL} macro with an integer type
3289 then you need to add an explicit cast.  GCC replaces @code{stddef.h}
3290 with a copy that redefines NULL appropriately.
3292 The warnings for missing or incorrect sentinels are enabled with
3293 @option{-Wformat}.
3295 @item simd
3296 @itemx simd("@var{mask}")
3297 @cindex @code{simd} function attribute
3298 This attribute enables creation of one or more function versions that
3299 can process multiple arguments using SIMD instructions from a
3300 single invocation.  Specifying this attribute allows compiler to
3301 assume that such versions are available at link time (provided
3302 in the same or another translation unit).  Generated versions are
3303 target-dependent and described in the corresponding Vector ABI document.  For
3304 x86_64 target this document can be found
3305 @w{@uref{https://sourceware.org/glibc/wiki/libmvec?action=AttachFile&do=view&target=VectorABI.txt,here}}.
3307 The optional argument @var{mask} may have the value
3308 @code{notinbranch} or @code{inbranch},
3309 and instructs the compiler to generate non-masked or masked
3310 clones correspondingly. By default, all clones are generated.
3312 If the attribute is specified and @code{#pragma omp declare simd} is
3313 present on a declaration and the @option{-fopenmp} or @option{-fopenmp-simd}
3314 switch is specified, then the attribute is ignored.
3316 @item stack_protect
3317 @cindex @code{stack_protect} function attribute
3318 This attribute adds stack protection code to the function if 
3319 flags @option{-fstack-protector}, @option{-fstack-protector-strong}
3320 or @option{-fstack-protector-explicit} are set.
3322 @item target (@var{options})
3323 @cindex @code{target} function attribute
3324 Multiple target back ends implement the @code{target} attribute
3325 to specify that a function is to
3326 be compiled with different target options than specified on the
3327 command line.  This can be used for instance to have functions
3328 compiled with a different ISA (instruction set architecture) than the
3329 default.  You can also use the @samp{#pragma GCC target} pragma to set
3330 more than one function to be compiled with specific target options.
3331 @xref{Function Specific Option Pragmas}, for details about the
3332 @samp{#pragma GCC target} pragma.
3334 For instance, on an x86, you could declare one function with the
3335 @code{target("sse4.1,arch=core2")} attribute and another with
3336 @code{target("sse4a,arch=amdfam10")}.  This is equivalent to
3337 compiling the first function with @option{-msse4.1} and
3338 @option{-march=core2} options, and the second function with
3339 @option{-msse4a} and @option{-march=amdfam10} options.  It is up to you
3340 to make sure that a function is only invoked on a machine that
3341 supports the particular ISA it is compiled for (for example by using
3342 @code{cpuid} on x86 to determine what feature bits and architecture
3343 family are used).
3345 @smallexample
3346 int core2_func (void) __attribute__ ((__target__ ("arch=core2")));
3347 int sse3_func (void) __attribute__ ((__target__ ("sse3")));
3348 @end smallexample
3350 You can either use multiple
3351 strings separated by commas to specify multiple options,
3352 or separate the options with a comma (@samp{,}) within a single string.
3354 The options supported are specific to each target; refer to @ref{x86
3355 Function Attributes}, @ref{PowerPC Function Attributes},
3356 @ref{ARM Function Attributes}, @ref{AArch64 Function Attributes},
3357 @ref{Nios II Function Attributes}, and @ref{S/390 Function Attributes}
3358 for details.
3360 @item target_clones (@var{options})
3361 @cindex @code{target_clones} function attribute
3362 The @code{target_clones} attribute is used to specify that a function
3363 be cloned into multiple versions compiled with different target options
3364 than specified on the command line.  The supported options and restrictions
3365 are the same as for @code{target} attribute.
3367 For instance, on an x86, you could compile a function with
3368 @code{target_clones("sse4.1,avx")}.  GCC creates two function clones,
3369 one compiled with @option{-msse4.1} and another with @option{-mavx}.
3371 On a PowerPC, you can compile a function with
3372 @code{target_clones("cpu=power9,default")}.  GCC will create two
3373 function clones, one compiled with @option{-mcpu=power9} and another
3374 with the default options.  GCC must be configured to use GLIBC 2.23 or
3375 newer in order to use the @code{target_clones} attribute.
3377 It also creates a resolver function (see
3378 the @code{ifunc} attribute above) that dynamically selects a clone
3379 suitable for current architecture.  The resolver is created only if there
3380 is a usage of a function with @code{target_clones} attribute.
3382 @item unused
3383 @cindex @code{unused} function attribute
3384 This attribute, attached to a function, means that the function is meant
3385 to be possibly unused.  GCC does not produce a warning for this
3386 function.
3388 @item used
3389 @cindex @code{used} function attribute
3390 This attribute, attached to a function, means that code must be emitted
3391 for the function even if it appears that the function is not referenced.
3392 This is useful, for example, when the function is referenced only in
3393 inline assembly.
3395 When applied to a member function of a C++ class template, the
3396 attribute also means that the function is instantiated if the
3397 class itself is instantiated.
3399 @item visibility ("@var{visibility_type}")
3400 @cindex @code{visibility} function attribute
3401 This attribute affects the linkage of the declaration to which it is attached.
3402 It can be applied to variables (@pxref{Common Variable Attributes}) and types
3403 (@pxref{Common Type Attributes}) as well as functions.
3405 There are four supported @var{visibility_type} values: default,
3406 hidden, protected or internal visibility.
3408 @smallexample
3409 void __attribute__ ((visibility ("protected")))
3410 f () @{ /* @r{Do something.} */; @}
3411 int i __attribute__ ((visibility ("hidden")));
3412 @end smallexample
3414 The possible values of @var{visibility_type} correspond to the
3415 visibility settings in the ELF gABI.
3417 @table @code
3418 @c keep this list of visibilities in alphabetical order.
3420 @item default
3421 Default visibility is the normal case for the object file format.
3422 This value is available for the visibility attribute to override other
3423 options that may change the assumed visibility of entities.
3425 On ELF, default visibility means that the declaration is visible to other
3426 modules and, in shared libraries, means that the declared entity may be
3427 overridden.
3429 On Darwin, default visibility means that the declaration is visible to
3430 other modules.
3432 Default visibility corresponds to ``external linkage'' in the language.
3434 @item hidden
3435 Hidden visibility indicates that the entity declared has a new
3436 form of linkage, which we call ``hidden linkage''.  Two
3437 declarations of an object with hidden linkage refer to the same object
3438 if they are in the same shared object.
3440 @item internal
3441 Internal visibility is like hidden visibility, but with additional
3442 processor specific semantics.  Unless otherwise specified by the
3443 psABI, GCC defines internal visibility to mean that a function is
3444 @emph{never} called from another module.  Compare this with hidden
3445 functions which, while they cannot be referenced directly by other
3446 modules, can be referenced indirectly via function pointers.  By
3447 indicating that a function cannot be called from outside the module,
3448 GCC may for instance omit the load of a PIC register since it is known
3449 that the calling function loaded the correct value.
3451 @item protected
3452 Protected visibility is like default visibility except that it
3453 indicates that references within the defining module bind to the
3454 definition in that module.  That is, the declared entity cannot be
3455 overridden by another module.
3457 @end table
3459 All visibilities are supported on many, but not all, ELF targets
3460 (supported when the assembler supports the @samp{.visibility}
3461 pseudo-op).  Default visibility is supported everywhere.  Hidden
3462 visibility is supported on Darwin targets.
3464 The visibility attribute should be applied only to declarations that
3465 would otherwise have external linkage.  The attribute should be applied
3466 consistently, so that the same entity should not be declared with
3467 different settings of the attribute.
3469 In C++, the visibility attribute applies to types as well as functions
3470 and objects, because in C++ types have linkage.  A class must not have
3471 greater visibility than its non-static data member types and bases,
3472 and class members default to the visibility of their class.  Also, a
3473 declaration without explicit visibility is limited to the visibility
3474 of its type.
3476 In C++, you can mark member functions and static member variables of a
3477 class with the visibility attribute.  This is useful if you know a
3478 particular method or static member variable should only be used from
3479 one shared object; then you can mark it hidden while the rest of the
3480 class has default visibility.  Care must be taken to avoid breaking
3481 the One Definition Rule; for example, it is usually not useful to mark
3482 an inline method as hidden without marking the whole class as hidden.
3484 A C++ namespace declaration can also have the visibility attribute.
3486 @smallexample
3487 namespace nspace1 __attribute__ ((visibility ("protected")))
3488 @{ /* @r{Do something.} */; @}
3489 @end smallexample
3491 This attribute applies only to the particular namespace body, not to
3492 other definitions of the same namespace; it is equivalent to using
3493 @samp{#pragma GCC visibility} before and after the namespace
3494 definition (@pxref{Visibility Pragmas}).
3496 In C++, if a template argument has limited visibility, this
3497 restriction is implicitly propagated to the template instantiation.
3498 Otherwise, template instantiations and specializations default to the
3499 visibility of their template.
3501 If both the template and enclosing class have explicit visibility, the
3502 visibility from the template is used.
3504 @item warn_unused_result
3505 @cindex @code{warn_unused_result} function attribute
3506 The @code{warn_unused_result} attribute causes a warning to be emitted
3507 if a caller of the function with this attribute does not use its
3508 return value.  This is useful for functions where not checking
3509 the result is either a security problem or always a bug, such as
3510 @code{realloc}.
3512 @smallexample
3513 int fn () __attribute__ ((warn_unused_result));
3514 int foo ()
3516   if (fn () < 0) return -1;
3517   fn ();
3518   return 0;
3520 @end smallexample
3522 @noindent
3523 results in warning on line 5.
3525 @item weak
3526 @cindex @code{weak} function attribute
3527 The @code{weak} attribute causes the declaration to be emitted as a weak
3528 symbol rather than a global.  This is primarily useful in defining
3529 library functions that can be overridden in user code, though it can
3530 also be used with non-function declarations.  Weak symbols are supported
3531 for ELF targets, and also for a.out targets when using the GNU assembler
3532 and linker.
3534 @item weakref
3535 @itemx weakref ("@var{target}")
3536 @cindex @code{weakref} function attribute
3537 The @code{weakref} attribute marks a declaration as a weak reference.
3538 Without arguments, it should be accompanied by an @code{alias} attribute
3539 naming the target symbol.  Optionally, the @var{target} may be given as
3540 an argument to @code{weakref} itself.  In either case, @code{weakref}
3541 implicitly marks the declaration as @code{weak}.  Without a
3542 @var{target}, given as an argument to @code{weakref} or to @code{alias},
3543 @code{weakref} is equivalent to @code{weak}.
3545 @smallexample
3546 static int x() __attribute__ ((weakref ("y")));
3547 /* is equivalent to... */
3548 static int x() __attribute__ ((weak, weakref, alias ("y")));
3549 /* and to... */
3550 static int x() __attribute__ ((weakref));
3551 static int x() __attribute__ ((alias ("y")));
3552 @end smallexample
3554 A weak reference is an alias that does not by itself require a
3555 definition to be given for the target symbol.  If the target symbol is
3556 only referenced through weak references, then it becomes a @code{weak}
3557 undefined symbol.  If it is directly referenced, however, then such
3558 strong references prevail, and a definition is required for the
3559 symbol, not necessarily in the same translation unit.
3561 The effect is equivalent to moving all references to the alias to a
3562 separate translation unit, renaming the alias to the aliased symbol,
3563 declaring it as weak, compiling the two separate translation units and
3564 performing a reloadable link on them.
3566 At present, a declaration to which @code{weakref} is attached can
3567 only be @code{static}.
3570 @end table
3572 @c This is the end of the target-independent attribute table
3574 @node AArch64 Function Attributes
3575 @subsection AArch64 Function Attributes
3577 The following target-specific function attributes are available for the
3578 AArch64 target.  For the most part, these options mirror the behavior of
3579 similar command-line options (@pxref{AArch64 Options}), but on a
3580 per-function basis.
3582 @table @code
3583 @item general-regs-only
3584 @cindex @code{general-regs-only} function attribute, AArch64
3585 Indicates that no floating-point or Advanced SIMD registers should be
3586 used when generating code for this function.  If the function explicitly
3587 uses floating-point code, then the compiler gives an error.  This is
3588 the same behavior as that of the command-line option
3589 @option{-mgeneral-regs-only}.
3591 @item fix-cortex-a53-835769
3592 @cindex @code{fix-cortex-a53-835769} function attribute, AArch64
3593 Indicates that the workaround for the Cortex-A53 erratum 835769 should be
3594 applied to this function.  To explicitly disable the workaround for this
3595 function specify the negated form: @code{no-fix-cortex-a53-835769}.
3596 This corresponds to the behavior of the command line options
3597 @option{-mfix-cortex-a53-835769} and @option{-mno-fix-cortex-a53-835769}.
3599 @item cmodel=
3600 @cindex @code{cmodel=} function attribute, AArch64
3601 Indicates that code should be generated for a particular code model for
3602 this function.  The behavior and permissible arguments are the same as
3603 for the command line option @option{-mcmodel=}.
3605 @item strict-align
3606 @cindex @code{strict-align} function attribute, AArch64
3607 Indicates that the compiler should not assume that unaligned memory references
3608 are handled by the system.  The behavior is the same as for the command-line
3609 option @option{-mstrict-align}.
3611 @item omit-leaf-frame-pointer
3612 @cindex @code{omit-leaf-frame-pointer} function attribute, AArch64
3613 Indicates that the frame pointer should be omitted for a leaf function call.
3614 To keep the frame pointer, the inverse attribute
3615 @code{no-omit-leaf-frame-pointer} can be specified.  These attributes have
3616 the same behavior as the command-line options @option{-momit-leaf-frame-pointer}
3617 and @option{-mno-omit-leaf-frame-pointer}.
3619 @item tls-dialect=
3620 @cindex @code{tls-dialect=} function attribute, AArch64
3621 Specifies the TLS dialect to use for this function.  The behavior and
3622 permissible arguments are the same as for the command-line option
3623 @option{-mtls-dialect=}.
3625 @item arch=
3626 @cindex @code{arch=} function attribute, AArch64
3627 Specifies the architecture version and architectural extensions to use
3628 for this function.  The behavior and permissible arguments are the same as
3629 for the @option{-march=} command-line option.
3631 @item tune=
3632 @cindex @code{tune=} function attribute, AArch64
3633 Specifies the core for which to tune the performance of this function.
3634 The behavior and permissible arguments are the same as for the @option{-mtune=}
3635 command-line option.
3637 @item cpu=
3638 @cindex @code{cpu=} function attribute, AArch64
3639 Specifies the core for which to tune the performance of this function and also
3640 whose architectural features to use.  The behavior and valid arguments are the
3641 same as for the @option{-mcpu=} command-line option.
3643 @item sign-return-address
3644 @cindex @code{sign-return-address} function attribute, AArch64
3645 Select the function scope on which return address signing will be applied.  The
3646 behavior and permissible arguments are the same as for the command-line option
3647 @option{-msign-return-address=}.  The default value is @code{none}.
3649 @end table
3651 The above target attributes can be specified as follows:
3653 @smallexample
3654 __attribute__((target("@var{attr-string}")))
3656 f (int a)
3658   return a + 5;
3660 @end smallexample
3662 where @code{@var{attr-string}} is one of the attribute strings specified above.
3664 Additionally, the architectural extension string may be specified on its
3665 own.  This can be used to turn on and off particular architectural extensions
3666 without having to specify a particular architecture version or core.  Example:
3668 @smallexample
3669 __attribute__((target("+crc+nocrypto")))
3671 foo (int a)
3673   return a + 5;
3675 @end smallexample
3677 In this example @code{target("+crc+nocrypto")} enables the @code{crc}
3678 extension and disables the @code{crypto} extension for the function @code{foo}
3679 without modifying an existing @option{-march=} or @option{-mcpu} option.
3681 Multiple target function attributes can be specified by separating them with
3682 a comma.  For example:
3683 @smallexample
3684 __attribute__((target("arch=armv8-a+crc+crypto,tune=cortex-a53")))
3686 foo (int a)
3688   return a + 5;
3690 @end smallexample
3692 is valid and compiles function @code{foo} for ARMv8-A with @code{crc}
3693 and @code{crypto} extensions and tunes it for @code{cortex-a53}.
3695 @subsubsection Inlining rules
3696 Specifying target attributes on individual functions or performing link-time
3697 optimization across translation units compiled with different target options
3698 can affect function inlining rules:
3700 In particular, a caller function can inline a callee function only if the
3701 architectural features available to the callee are a subset of the features
3702 available to the caller.
3703 For example: A function @code{foo} compiled with @option{-march=armv8-a+crc},
3704 or tagged with the equivalent @code{arch=armv8-a+crc} attribute,
3705 can inline a function @code{bar} compiled with @option{-march=armv8-a+nocrc}
3706 because the all the architectural features that function @code{bar} requires
3707 are available to function @code{foo}.  Conversely, function @code{bar} cannot
3708 inline function @code{foo}.
3710 Additionally inlining a function compiled with @option{-mstrict-align} into a
3711 function compiled without @code{-mstrict-align} is not allowed.
3712 However, inlining a function compiled without @option{-mstrict-align} into a
3713 function compiled with @option{-mstrict-align} is allowed.
3715 Note that CPU tuning options and attributes such as the @option{-mcpu=},
3716 @option{-mtune=} do not inhibit inlining unless the CPU specified by the
3717 @option{-mcpu=} option or the @code{cpu=} attribute conflicts with the
3718 architectural feature rules specified above.
3720 @node ARC Function Attributes
3721 @subsection ARC Function Attributes
3723 These function attributes are supported by the ARC back end:
3725 @table @code
3726 @item interrupt
3727 @cindex @code{interrupt} function attribute, ARC
3728 Use this attribute to indicate
3729 that the specified function is an interrupt handler.  The compiler generates
3730 function entry and exit sequences suitable for use in an interrupt handler
3731 when this attribute is present.
3733 On the ARC, you must specify the kind of interrupt to be handled
3734 in a parameter to the interrupt attribute like this:
3736 @smallexample
3737 void f () __attribute__ ((interrupt ("ilink1")));
3738 @end smallexample
3740 Permissible values for this parameter are: @w{@code{ilink1}} and
3741 @w{@code{ilink2}}.
3743 @item long_call
3744 @itemx medium_call
3745 @itemx short_call
3746 @cindex @code{long_call} function attribute, ARC
3747 @cindex @code{medium_call} function attribute, ARC
3748 @cindex @code{short_call} function attribute, ARC
3749 @cindex indirect calls, ARC
3750 These attributes specify how a particular function is called.
3751 These attributes override the
3752 @option{-mlong-calls} and @option{-mmedium-calls} (@pxref{ARC Options})
3753 command-line switches and @code{#pragma long_calls} settings.
3755 For ARC, a function marked with the @code{long_call} attribute is
3756 always called using register-indirect jump-and-link instructions,
3757 thereby enabling the called function to be placed anywhere within the
3758 32-bit address space.  A function marked with the @code{medium_call}
3759 attribute will always be close enough to be called with an unconditional
3760 branch-and-link instruction, which has a 25-bit offset from
3761 the call site.  A function marked with the @code{short_call}
3762 attribute will always be close enough to be called with a conditional
3763 branch-and-link instruction, which has a 21-bit offset from
3764 the call site.
3765 @end table
3767 @node ARM Function Attributes
3768 @subsection ARM Function Attributes
3770 These function attributes are supported for ARM targets:
3772 @table @code
3773 @item interrupt
3774 @cindex @code{interrupt} function attribute, ARM
3775 Use this attribute to indicate
3776 that the specified function is an interrupt handler.  The compiler generates
3777 function entry and exit sequences suitable for use in an interrupt handler
3778 when this attribute is present.
3780 You can specify the kind of interrupt to be handled by
3781 adding an optional parameter to the interrupt attribute like this:
3783 @smallexample
3784 void f () __attribute__ ((interrupt ("IRQ")));
3785 @end smallexample
3787 @noindent
3788 Permissible values for this parameter are: @code{IRQ}, @code{FIQ},
3789 @code{SWI}, @code{ABORT} and @code{UNDEF}.
3791 On ARMv7-M the interrupt type is ignored, and the attribute means the function
3792 may be called with a word-aligned stack pointer.
3794 @item isr
3795 @cindex @code{isr} function attribute, ARM
3796 Use this attribute on ARM to write Interrupt Service Routines. This is an
3797 alias to the @code{interrupt} attribute above.
3799 @item long_call
3800 @itemx short_call
3801 @cindex @code{long_call} function attribute, ARM
3802 @cindex @code{short_call} function attribute, ARM
3803 @cindex indirect calls, ARM
3804 These attributes specify how a particular function is called.
3805 These attributes override the
3806 @option{-mlong-calls} (@pxref{ARM Options})
3807 command-line switch and @code{#pragma long_calls} settings.  For ARM, the
3808 @code{long_call} attribute indicates that the function might be far
3809 away from the call site and require a different (more expensive)
3810 calling sequence.   The @code{short_call} attribute always places
3811 the offset to the function from the call site into the @samp{BL}
3812 instruction directly.
3814 @item naked
3815 @cindex @code{naked} function attribute, ARM
3816 This attribute allows the compiler to construct the
3817 requisite function declaration, while allowing the body of the
3818 function to be assembly code. The specified function will not have
3819 prologue/epilogue sequences generated by the compiler. Only basic
3820 @code{asm} statements can safely be included in naked functions
3821 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
3822 basic @code{asm} and C code may appear to work, they cannot be
3823 depended upon to work reliably and are not supported.
3825 @item pcs
3826 @cindex @code{pcs} function attribute, ARM
3828 The @code{pcs} attribute can be used to control the calling convention
3829 used for a function on ARM.  The attribute takes an argument that specifies
3830 the calling convention to use.
3832 When compiling using the AAPCS ABI (or a variant of it) then valid
3833 values for the argument are @code{"aapcs"} and @code{"aapcs-vfp"}.  In
3834 order to use a variant other than @code{"aapcs"} then the compiler must
3835 be permitted to use the appropriate co-processor registers (i.e., the
3836 VFP registers must be available in order to use @code{"aapcs-vfp"}).
3837 For example,
3839 @smallexample
3840 /* Argument passed in r0, and result returned in r0+r1.  */
3841 double f2d (float) __attribute__((pcs("aapcs")));
3842 @end smallexample
3844 Variadic functions always use the @code{"aapcs"} calling convention and
3845 the compiler rejects attempts to specify an alternative.
3847 @item target (@var{options})
3848 @cindex @code{target} function attribute
3849 As discussed in @ref{Common Function Attributes}, this attribute 
3850 allows specification of target-specific compilation options.
3852 On ARM, the following options are allowed:
3854 @table @samp
3855 @item thumb
3856 @cindex @code{target("thumb")} function attribute, ARM
3857 Force code generation in the Thumb (T16/T32) ISA, depending on the
3858 architecture level.
3860 @item arm
3861 @cindex @code{target("arm")} function attribute, ARM
3862 Force code generation in the ARM (A32) ISA.
3864 Functions from different modes can be inlined in the caller's mode.
3866 @item fpu=
3867 @cindex @code{target("fpu=")} function attribute, ARM
3868 Specifies the fpu for which to tune the performance of this function.
3869 The behavior and permissible arguments are the same as for the @option{-mfpu=}
3870 command-line option.
3872 @item arch=
3873 @cindex @code{arch=} function attribute, ARM
3874 Specifies the architecture version and architectural extensions to use
3875 for this function.  The behavior and permissible arguments are the same as
3876 for the @option{-march=} command-line option.
3878 The above target attributes can be specified as follows:
3880 @smallexample
3881 __attribute__((target("arch=armv8-a+crc")))
3883 f (int a)
3885   return a + 5;
3887 @end smallexample
3889 Additionally, the architectural extension string may be specified on its
3890 own.  This can be used to turn on and off particular architectural extensions
3891 without having to specify a particular architecture version or core.  Example:
3893 @smallexample
3894 __attribute__((target("+crc+nocrypto")))
3896 foo (int a)
3898   return a + 5;
3900 @end smallexample
3902 In this example @code{target("+crc+nocrypto")} enables the @code{crc}
3903 extension and disables the @code{crypto} extension for the function @code{foo}
3904 without modifying an existing @option{-march=} or @option{-mcpu} option.
3906 @end table
3908 @end table
3910 @node AVR Function Attributes
3911 @subsection AVR Function Attributes
3913 These function attributes are supported by the AVR back end:
3915 @table @code
3916 @item interrupt
3917 @cindex @code{interrupt} function attribute, AVR
3918 Use this attribute to indicate
3919 that the specified function is an interrupt handler.  The compiler generates
3920 function entry and exit sequences suitable for use in an interrupt handler
3921 when this attribute is present.
3923 On the AVR, the hardware globally disables interrupts when an
3924 interrupt is executed.  The first instruction of an interrupt handler
3925 declared with this attribute is a @code{SEI} instruction to
3926 re-enable interrupts.  See also the @code{signal} function attribute
3927 that does not insert a @code{SEI} instruction.  If both @code{signal} and
3928 @code{interrupt} are specified for the same function, @code{signal}
3929 is silently ignored.
3931 @item naked
3932 @cindex @code{naked} function attribute, AVR
3933 This attribute allows the compiler to construct the
3934 requisite function declaration, while allowing the body of the
3935 function to be assembly code. The specified function will not have
3936 prologue/epilogue sequences generated by the compiler. Only basic
3937 @code{asm} statements can safely be included in naked functions
3938 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
3939 basic @code{asm} and C code may appear to work, they cannot be
3940 depended upon to work reliably and are not supported.
3942 @item no_gccisr
3943 @cindex @code{no_gccisr} function attribute, AVR
3944 Do not use @code{__gcc_isr} pseudo instructions in a function with
3945 the @code{interrupt} or @code{signal} attribute aka. interrupt
3946 service routine (ISR).
3947 Use this attribute if the preamble of the ISR prologue should always read
3948 @example
3949 push  __zero_reg__
3950 push  __tmp_reg__
3951 in    __tmp_reg__, __SREG__
3952 push  __tmp_reg__
3953 clr   __zero_reg__
3954 @end example
3955 and accordingly for the postamble of the epilogue --- no matter whether
3956 the mentioned registers are actually used in the ISR or not.
3957 Situations where you might want to use this attribute include:
3958 @itemize @bullet
3959 @item
3960 Code that (effectively) clobbers bits of @code{SREG} other than the
3961 @code{I}-flag by writing to the memory location of @code{SREG}.
3962 @item
3963 Code that uses inline assembler to jump to a different function which
3964 expects (parts of) the prologue code as outlined above to be present.
3965 @end itemize
3966 To disable @code{__gcc_isr} generation for the whole compilation unit,
3967 there is option @option{-mno-gas-isr-prologues}, @pxref{AVR Options}.
3969 @item OS_main
3970 @itemx OS_task
3971 @cindex @code{OS_main} function attribute, AVR
3972 @cindex @code{OS_task} function attribute, AVR
3973 On AVR, functions with the @code{OS_main} or @code{OS_task} attribute
3974 do not save/restore any call-saved register in their prologue/epilogue.
3976 The @code{OS_main} attribute can be used when there @emph{is
3977 guarantee} that interrupts are disabled at the time when the function
3978 is entered.  This saves resources when the stack pointer has to be
3979 changed to set up a frame for local variables.
3981 The @code{OS_task} attribute can be used when there is @emph{no
3982 guarantee} that interrupts are disabled at that time when the function
3983 is entered like for, e@.g@. task functions in a multi-threading operating
3984 system. In that case, changing the stack pointer register is
3985 guarded by save/clear/restore of the global interrupt enable flag.
3987 The differences to the @code{naked} function attribute are:
3988 @itemize @bullet
3989 @item @code{naked} functions do not have a return instruction whereas 
3990 @code{OS_main} and @code{OS_task} functions have a @code{RET} or
3991 @code{RETI} return instruction.
3992 @item @code{naked} functions do not set up a frame for local variables
3993 or a frame pointer whereas @code{OS_main} and @code{OS_task} do this
3994 as needed.
3995 @end itemize
3997 @item signal
3998 @cindex @code{signal} function attribute, AVR
3999 Use this attribute on the AVR to indicate that the specified
4000 function is an interrupt handler.  The compiler generates function
4001 entry and exit sequences suitable for use in an interrupt handler when this
4002 attribute is present.
4004 See also the @code{interrupt} function attribute. 
4006 The AVR hardware globally disables interrupts when an interrupt is executed.
4007 Interrupt handler functions defined with the @code{signal} attribute
4008 do not re-enable interrupts.  It is save to enable interrupts in a
4009 @code{signal} handler.  This ``save'' only applies to the code
4010 generated by the compiler and not to the IRQ layout of the
4011 application which is responsibility of the application.
4013 If both @code{signal} and @code{interrupt} are specified for the same
4014 function, @code{signal} is silently ignored.
4015 @end table
4017 @node Blackfin Function Attributes
4018 @subsection Blackfin Function Attributes
4020 These function attributes are supported by the Blackfin back end:
4022 @table @code
4024 @item exception_handler
4025 @cindex @code{exception_handler} function attribute
4026 @cindex exception handler functions, Blackfin
4027 Use this attribute on the Blackfin to indicate that the specified function
4028 is an exception handler.  The compiler generates function entry and
4029 exit sequences suitable for use in an exception handler when this
4030 attribute is present.
4032 @item interrupt_handler
4033 @cindex @code{interrupt_handler} function attribute, Blackfin
4034 Use this attribute to
4035 indicate that the specified function is an interrupt handler.  The compiler
4036 generates function entry and exit sequences suitable for use in an
4037 interrupt handler when this attribute is present.
4039 @item kspisusp
4040 @cindex @code{kspisusp} function attribute, Blackfin
4041 @cindex User stack pointer in interrupts on the Blackfin
4042 When used together with @code{interrupt_handler}, @code{exception_handler}
4043 or @code{nmi_handler}, code is generated to load the stack pointer
4044 from the USP register in the function prologue.
4046 @item l1_text
4047 @cindex @code{l1_text} function attribute, Blackfin
4048 This attribute specifies a function to be placed into L1 Instruction
4049 SRAM@. The function is put into a specific section named @code{.l1.text}.
4050 With @option{-mfdpic}, function calls with a such function as the callee
4051 or caller uses inlined PLT.
4053 @item l2
4054 @cindex @code{l2} function attribute, Blackfin
4055 This attribute specifies a function to be placed into L2
4056 SRAM. The function is put into a specific section named
4057 @code{.l2.text}. With @option{-mfdpic}, callers of such functions use
4058 an inlined PLT.
4060 @item longcall
4061 @itemx shortcall
4062 @cindex indirect calls, Blackfin
4063 @cindex @code{longcall} function attribute, Blackfin
4064 @cindex @code{shortcall} function attribute, Blackfin
4065 The @code{longcall} attribute
4066 indicates that the function might be far away from the call site and
4067 require a different (more expensive) calling sequence.  The
4068 @code{shortcall} attribute indicates that the function is always close
4069 enough for the shorter calling sequence to be used.  These attributes
4070 override the @option{-mlongcall} switch.
4072 @item nesting
4073 @cindex @code{nesting} function attribute, Blackfin
4074 @cindex Allow nesting in an interrupt handler on the Blackfin processor
4075 Use this attribute together with @code{interrupt_handler},
4076 @code{exception_handler} or @code{nmi_handler} to indicate that the function
4077 entry code should enable nested interrupts or exceptions.
4079 @item nmi_handler
4080 @cindex @code{nmi_handler} function attribute, Blackfin
4081 @cindex NMI handler functions on the Blackfin processor
4082 Use this attribute on the Blackfin to indicate that the specified function
4083 is an NMI handler.  The compiler generates function entry and
4084 exit sequences suitable for use in an NMI handler when this
4085 attribute is present.
4087 @item saveall
4088 @cindex @code{saveall} function attribute, Blackfin
4089 @cindex save all registers on the Blackfin
4090 Use this attribute to indicate that
4091 all registers except the stack pointer should be saved in the prologue
4092 regardless of whether they are used or not.
4093 @end table
4095 @node CR16 Function Attributes
4096 @subsection CR16 Function Attributes
4098 These function attributes are supported by the CR16 back end:
4100 @table @code
4101 @item interrupt
4102 @cindex @code{interrupt} function attribute, CR16
4103 Use this attribute to indicate
4104 that the specified function is an interrupt handler.  The compiler generates
4105 function entry and exit sequences suitable for use in an interrupt handler
4106 when this attribute is present.
4107 @end table
4109 @node Epiphany Function Attributes
4110 @subsection Epiphany Function Attributes
4112 These function attributes are supported by the Epiphany back end:
4114 @table @code
4115 @item disinterrupt
4116 @cindex @code{disinterrupt} function attribute, Epiphany
4117 This attribute causes the compiler to emit
4118 instructions to disable interrupts for the duration of the given
4119 function.
4121 @item forwarder_section
4122 @cindex @code{forwarder_section} function attribute, Epiphany
4123 This attribute modifies the behavior of an interrupt handler.
4124 The interrupt handler may be in external memory which cannot be
4125 reached by a branch instruction, so generate a local memory trampoline
4126 to transfer control.  The single parameter identifies the section where
4127 the trampoline is placed.
4129 @item interrupt
4130 @cindex @code{interrupt} function attribute, Epiphany
4131 Use this attribute to indicate
4132 that the specified function is an interrupt handler.  The compiler generates
4133 function entry and exit sequences suitable for use in an interrupt handler
4134 when this attribute is present.  It may also generate
4135 a special section with code to initialize the interrupt vector table.
4137 On Epiphany targets one or more optional parameters can be added like this:
4139 @smallexample
4140 void __attribute__ ((interrupt ("dma0, dma1"))) universal_dma_handler ();
4141 @end smallexample
4143 Permissible values for these parameters are: @w{@code{reset}},
4144 @w{@code{software_exception}}, @w{@code{page_miss}},
4145 @w{@code{timer0}}, @w{@code{timer1}}, @w{@code{message}},
4146 @w{@code{dma0}}, @w{@code{dma1}}, @w{@code{wand}} and @w{@code{swi}}.
4147 Multiple parameters indicate that multiple entries in the interrupt
4148 vector table should be initialized for this function, i.e.@: for each
4149 parameter @w{@var{name}}, a jump to the function is emitted in
4150 the section @w{ivt_entry_@var{name}}.  The parameter(s) may be omitted
4151 entirely, in which case no interrupt vector table entry is provided.
4153 Note that interrupts are enabled inside the function
4154 unless the @code{disinterrupt} attribute is also specified.
4156 The following examples are all valid uses of these attributes on
4157 Epiphany targets:
4158 @smallexample
4159 void __attribute__ ((interrupt)) universal_handler ();
4160 void __attribute__ ((interrupt ("dma1"))) dma1_handler ();
4161 void __attribute__ ((interrupt ("dma0, dma1"))) 
4162   universal_dma_handler ();
4163 void __attribute__ ((interrupt ("timer0"), disinterrupt))
4164   fast_timer_handler ();
4165 void __attribute__ ((interrupt ("dma0, dma1"), 
4166                      forwarder_section ("tramp")))
4167   external_dma_handler ();
4168 @end smallexample
4170 @item long_call
4171 @itemx short_call
4172 @cindex @code{long_call} function attribute, Epiphany
4173 @cindex @code{short_call} function attribute, Epiphany
4174 @cindex indirect calls, Epiphany
4175 These attributes specify how a particular function is called.
4176 These attributes override the
4177 @option{-mlong-calls} (@pxref{Adapteva Epiphany Options})
4178 command-line switch and @code{#pragma long_calls} settings.
4179 @end table
4182 @node H8/300 Function Attributes
4183 @subsection H8/300 Function Attributes
4185 These function attributes are available for H8/300 targets:
4187 @table @code
4188 @item function_vector
4189 @cindex @code{function_vector} function attribute, H8/300
4190 Use this attribute on the H8/300, H8/300H, and H8S to indicate 
4191 that the specified function should be called through the function vector.
4192 Calling a function through the function vector reduces code size; however,
4193 the function vector has a limited size (maximum 128 entries on the H8/300
4194 and 64 entries on the H8/300H and H8S)
4195 and shares space with the interrupt vector.
4197 @item interrupt_handler
4198 @cindex @code{interrupt_handler} function attribute, H8/300
4199 Use this attribute on the H8/300, H8/300H, and H8S to
4200 indicate that the specified function is an interrupt handler.  The compiler
4201 generates function entry and exit sequences suitable for use in an
4202 interrupt handler when this attribute is present.
4204 @item saveall
4205 @cindex @code{saveall} function attribute, H8/300
4206 @cindex save all registers on the H8/300, H8/300H, and H8S
4207 Use this attribute on the H8/300, H8/300H, and H8S to indicate that
4208 all registers except the stack pointer should be saved in the prologue
4209 regardless of whether they are used or not.
4210 @end table
4212 @node IA-64 Function Attributes
4213 @subsection IA-64 Function Attributes
4215 These function attributes are supported on IA-64 targets:
4217 @table @code
4218 @item syscall_linkage
4219 @cindex @code{syscall_linkage} function attribute, IA-64
4220 This attribute is used to modify the IA-64 calling convention by marking
4221 all input registers as live at all function exits.  This makes it possible
4222 to restart a system call after an interrupt without having to save/restore
4223 the input registers.  This also prevents kernel data from leaking into
4224 application code.
4226 @item version_id
4227 @cindex @code{version_id} function attribute, IA-64
4228 This IA-64 HP-UX attribute, attached to a global variable or function, renames a
4229 symbol to contain a version string, thus allowing for function level
4230 versioning.  HP-UX system header files may use function level versioning
4231 for some system calls.
4233 @smallexample
4234 extern int foo () __attribute__((version_id ("20040821")));
4235 @end smallexample
4237 @noindent
4238 Calls to @code{foo} are mapped to calls to @code{foo@{20040821@}}.
4239 @end table
4241 @node M32C Function Attributes
4242 @subsection M32C Function Attributes
4244 These function attributes are supported by the M32C back end:
4246 @table @code
4247 @item bank_switch
4248 @cindex @code{bank_switch} function attribute, M32C
4249 When added to an interrupt handler with the M32C port, causes the
4250 prologue and epilogue to use bank switching to preserve the registers
4251 rather than saving them on the stack.
4253 @item fast_interrupt
4254 @cindex @code{fast_interrupt} function attribute, M32C
4255 Use this attribute on the M32C port to indicate that the specified
4256 function is a fast interrupt handler.  This is just like the
4257 @code{interrupt} attribute, except that @code{freit} is used to return
4258 instead of @code{reit}.
4260 @item function_vector
4261 @cindex @code{function_vector} function attribute, M16C/M32C
4262 On M16C/M32C targets, the @code{function_vector} attribute declares a
4263 special page subroutine call function. Use of this attribute reduces
4264 the code size by 2 bytes for each call generated to the
4265 subroutine. The argument to the attribute is the vector number entry
4266 from the special page vector table which contains the 16 low-order
4267 bits of the subroutine's entry address. Each vector table has special
4268 page number (18 to 255) that is used in @code{jsrs} instructions.
4269 Jump addresses of the routines are generated by adding 0x0F0000 (in
4270 case of M16C targets) or 0xFF0000 (in case of M32C targets), to the
4271 2-byte addresses set in the vector table. Therefore you need to ensure
4272 that all the special page vector routines should get mapped within the
4273 address range 0x0F0000 to 0x0FFFFF (for M16C) and 0xFF0000 to 0xFFFFFF
4274 (for M32C).
4276 In the following example 2 bytes are saved for each call to
4277 function @code{foo}.
4279 @smallexample
4280 void foo (void) __attribute__((function_vector(0x18)));
4281 void foo (void)
4285 void bar (void)
4287     foo();
4289 @end smallexample
4291 If functions are defined in one file and are called in another file,
4292 then be sure to write this declaration in both files.
4294 This attribute is ignored for R8C target.
4296 @item interrupt
4297 @cindex @code{interrupt} function attribute, M32C
4298 Use this attribute to indicate
4299 that the specified function is an interrupt handler.  The compiler generates
4300 function entry and exit sequences suitable for use in an interrupt handler
4301 when this attribute is present.
4302 @end table
4304 @node M32R/D Function Attributes
4305 @subsection M32R/D Function Attributes
4307 These function attributes are supported by the M32R/D back end:
4309 @table @code
4310 @item interrupt
4311 @cindex @code{interrupt} function attribute, M32R/D
4312 Use this attribute to indicate
4313 that the specified function is an interrupt handler.  The compiler generates
4314 function entry and exit sequences suitable for use in an interrupt handler
4315 when this attribute is present.
4317 @item model (@var{model-name})
4318 @cindex @code{model} function attribute, M32R/D
4319 @cindex function addressability on the M32R/D
4321 On the M32R/D, use this attribute to set the addressability of an
4322 object, and of the code generated for a function.  The identifier
4323 @var{model-name} is one of @code{small}, @code{medium}, or
4324 @code{large}, representing each of the code models.
4326 Small model objects live in the lower 16MB of memory (so that their
4327 addresses can be loaded with the @code{ld24} instruction), and are
4328 callable with the @code{bl} instruction.
4330 Medium model objects may live anywhere in the 32-bit address space (the
4331 compiler generates @code{seth/add3} instructions to load their addresses),
4332 and are callable with the @code{bl} instruction.
4334 Large model objects may live anywhere in the 32-bit address space (the
4335 compiler generates @code{seth/add3} instructions to load their addresses),
4336 and may not be reachable with the @code{bl} instruction (the compiler
4337 generates the much slower @code{seth/add3/jl} instruction sequence).
4338 @end table
4340 @node m68k Function Attributes
4341 @subsection m68k Function Attributes
4343 These function attributes are supported by the m68k back end:
4345 @table @code
4346 @item interrupt
4347 @itemx interrupt_handler
4348 @cindex @code{interrupt} function attribute, m68k
4349 @cindex @code{interrupt_handler} function attribute, m68k
4350 Use this attribute to
4351 indicate that the specified function is an interrupt handler.  The compiler
4352 generates function entry and exit sequences suitable for use in an
4353 interrupt handler when this attribute is present.  Either name may be used.
4355 @item interrupt_thread
4356 @cindex @code{interrupt_thread} function attribute, fido
4357 Use this attribute on fido, a subarchitecture of the m68k, to indicate
4358 that the specified function is an interrupt handler that is designed
4359 to run as a thread.  The compiler omits generate prologue/epilogue
4360 sequences and replaces the return instruction with a @code{sleep}
4361 instruction.  This attribute is available only on fido.
4362 @end table
4364 @node MCORE Function Attributes
4365 @subsection MCORE Function Attributes
4367 These function attributes are supported by the MCORE back end:
4369 @table @code
4370 @item naked
4371 @cindex @code{naked} function attribute, MCORE
4372 This attribute allows the compiler to construct the
4373 requisite function declaration, while allowing the body of the
4374 function to be assembly code. The specified function will not have
4375 prologue/epilogue sequences generated by the compiler. Only basic
4376 @code{asm} statements can safely be included in naked functions
4377 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
4378 basic @code{asm} and C code may appear to work, they cannot be
4379 depended upon to work reliably and are not supported.
4380 @end table
4382 @node MeP Function Attributes
4383 @subsection MeP Function Attributes
4385 These function attributes are supported by the MeP back end:
4387 @table @code
4388 @item disinterrupt
4389 @cindex @code{disinterrupt} function attribute, MeP
4390 On MeP targets, this attribute causes the compiler to emit
4391 instructions to disable interrupts for the duration of the given
4392 function.
4394 @item interrupt
4395 @cindex @code{interrupt} function attribute, MeP
4396 Use this attribute to indicate
4397 that the specified function is an interrupt handler.  The compiler generates
4398 function entry and exit sequences suitable for use in an interrupt handler
4399 when this attribute is present.
4401 @item near
4402 @cindex @code{near} function attribute, MeP
4403 This attribute causes the compiler to assume the called
4404 function is close enough to use the normal calling convention,
4405 overriding the @option{-mtf} command-line option.
4407 @item far
4408 @cindex @code{far} function attribute, MeP
4409 On MeP targets this causes the compiler to use a calling convention
4410 that assumes the called function is too far away for the built-in
4411 addressing modes.
4413 @item vliw
4414 @cindex @code{vliw} function attribute, MeP
4415 The @code{vliw} attribute tells the compiler to emit
4416 instructions in VLIW mode instead of core mode.  Note that this
4417 attribute is not allowed unless a VLIW coprocessor has been configured
4418 and enabled through command-line options.
4419 @end table
4421 @node MicroBlaze Function Attributes
4422 @subsection MicroBlaze Function Attributes
4424 These function attributes are supported on MicroBlaze targets:
4426 @table @code
4427 @item save_volatiles
4428 @cindex @code{save_volatiles} function attribute, MicroBlaze
4429 Use this attribute to indicate that the function is
4430 an interrupt handler.  All volatile registers (in addition to non-volatile
4431 registers) are saved in the function prologue.  If the function is a leaf
4432 function, only volatiles used by the function are saved.  A normal function
4433 return is generated instead of a return from interrupt.
4435 @item break_handler
4436 @cindex @code{break_handler} function attribute, MicroBlaze
4437 @cindex break handler functions
4438 Use this attribute to indicate that
4439 the specified function is a break handler.  The compiler generates function
4440 entry and exit sequences suitable for use in an break handler when this
4441 attribute is present. The return from @code{break_handler} is done through
4442 the @code{rtbd} instead of @code{rtsd}.
4444 @smallexample
4445 void f () __attribute__ ((break_handler));
4446 @end smallexample
4448 @item interrupt_handler
4449 @itemx fast_interrupt 
4450 @cindex @code{interrupt_handler} function attribute, MicroBlaze
4451 @cindex @code{fast_interrupt} function attribute, MicroBlaze
4452 These attributes indicate that the specified function is an interrupt
4453 handler.  Use the @code{fast_interrupt} attribute to indicate handlers
4454 used in low-latency interrupt mode, and @code{interrupt_handler} for
4455 interrupts that do not use low-latency handlers.  In both cases, GCC
4456 emits appropriate prologue code and generates a return from the handler
4457 using @code{rtid} instead of @code{rtsd}.
4458 @end table
4460 @node Microsoft Windows Function Attributes
4461 @subsection Microsoft Windows Function Attributes
4463 The following attributes are available on Microsoft Windows and Symbian OS
4464 targets.
4466 @table @code
4467 @item dllexport
4468 @cindex @code{dllexport} function attribute
4469 @cindex @code{__declspec(dllexport)}
4470 On Microsoft Windows targets and Symbian OS targets the
4471 @code{dllexport} attribute causes the compiler to provide a global
4472 pointer to a pointer in a DLL, so that it can be referenced with the
4473 @code{dllimport} attribute.  On Microsoft Windows targets, the pointer
4474 name is formed by combining @code{_imp__} and the function or variable
4475 name.
4477 You can use @code{__declspec(dllexport)} as a synonym for
4478 @code{__attribute__ ((dllexport))} for compatibility with other
4479 compilers.
4481 On systems that support the @code{visibility} attribute, this
4482 attribute also implies ``default'' visibility.  It is an error to
4483 explicitly specify any other visibility.
4485 GCC's default behavior is to emit all inline functions with the
4486 @code{dllexport} attribute.  Since this can cause object file-size bloat,
4487 you can use @option{-fno-keep-inline-dllexport}, which tells GCC to
4488 ignore the attribute for inlined functions unless the 
4489 @option{-fkeep-inline-functions} flag is used instead.
4491 The attribute is ignored for undefined symbols.
4493 When applied to C++ classes, the attribute marks defined non-inlined
4494 member functions and static data members as exports.  Static consts
4495 initialized in-class are not marked unless they are also defined
4496 out-of-class.
4498 For Microsoft Windows targets there are alternative methods for
4499 including the symbol in the DLL's export table such as using a
4500 @file{.def} file with an @code{EXPORTS} section or, with GNU ld, using
4501 the @option{--export-all} linker flag.
4503 @item dllimport
4504 @cindex @code{dllimport} function attribute
4505 @cindex @code{__declspec(dllimport)}
4506 On Microsoft Windows and Symbian OS targets, the @code{dllimport}
4507 attribute causes the compiler to reference a function or variable via
4508 a global pointer to a pointer that is set up by the DLL exporting the
4509 symbol.  The attribute implies @code{extern}.  On Microsoft Windows
4510 targets, the pointer name is formed by combining @code{_imp__} and the
4511 function or variable name.
4513 You can use @code{__declspec(dllimport)} as a synonym for
4514 @code{__attribute__ ((dllimport))} for compatibility with other
4515 compilers.
4517 On systems that support the @code{visibility} attribute, this
4518 attribute also implies ``default'' visibility.  It is an error to
4519 explicitly specify any other visibility.
4521 Currently, the attribute is ignored for inlined functions.  If the
4522 attribute is applied to a symbol @emph{definition}, an error is reported.
4523 If a symbol previously declared @code{dllimport} is later defined, the
4524 attribute is ignored in subsequent references, and a warning is emitted.
4525 The attribute is also overridden by a subsequent declaration as
4526 @code{dllexport}.
4528 When applied to C++ classes, the attribute marks non-inlined
4529 member functions and static data members as imports.  However, the
4530 attribute is ignored for virtual methods to allow creation of vtables
4531 using thunks.
4533 On the SH Symbian OS target the @code{dllimport} attribute also has
4534 another affect---it can cause the vtable and run-time type information
4535 for a class to be exported.  This happens when the class has a
4536 dllimported constructor or a non-inline, non-pure virtual function
4537 and, for either of those two conditions, the class also has an inline
4538 constructor or destructor and has a key function that is defined in
4539 the current translation unit.
4541 For Microsoft Windows targets the use of the @code{dllimport}
4542 attribute on functions is not necessary, but provides a small
4543 performance benefit by eliminating a thunk in the DLL@.  The use of the
4544 @code{dllimport} attribute on imported variables can be avoided by passing the
4545 @option{--enable-auto-import} switch to the GNU linker.  As with
4546 functions, using the attribute for a variable eliminates a thunk in
4547 the DLL@.
4549 One drawback to using this attribute is that a pointer to a
4550 @emph{variable} marked as @code{dllimport} cannot be used as a constant
4551 address. However, a pointer to a @emph{function} with the
4552 @code{dllimport} attribute can be used as a constant initializer; in
4553 this case, the address of a stub function in the import lib is
4554 referenced.  On Microsoft Windows targets, the attribute can be disabled
4555 for functions by setting the @option{-mnop-fun-dllimport} flag.
4556 @end table
4558 @node MIPS Function Attributes
4559 @subsection MIPS Function Attributes
4561 These function attributes are supported by the MIPS back end:
4563 @table @code
4564 @item interrupt
4565 @cindex @code{interrupt} function attribute, MIPS
4566 Use this attribute to indicate that the specified function is an interrupt
4567 handler.  The compiler generates function entry and exit sequences suitable
4568 for use in an interrupt handler when this attribute is present.
4569 An optional argument is supported for the interrupt attribute which allows
4570 the interrupt mode to be described.  By default GCC assumes the external
4571 interrupt controller (EIC) mode is in use, this can be explicitly set using
4572 @code{eic}.  When interrupts are non-masked then the requested Interrupt
4573 Priority Level (IPL) is copied to the current IPL which has the effect of only
4574 enabling higher priority interrupts.  To use vectored interrupt mode use
4575 the argument @code{vector=[sw0|sw1|hw0|hw1|hw2|hw3|hw4|hw5]}, this will change
4576 the behavior of the non-masked interrupt support and GCC will arrange to mask
4577 all interrupts from sw0 up to and including the specified interrupt vector.
4579 You can use the following attributes to modify the behavior
4580 of an interrupt handler:
4581 @table @code
4582 @item use_shadow_register_set
4583 @cindex @code{use_shadow_register_set} function attribute, MIPS
4584 Assume that the handler uses a shadow register set, instead of
4585 the main general-purpose registers.  An optional argument @code{intstack} is
4586 supported to indicate that the shadow register set contains a valid stack
4587 pointer.
4589 @item keep_interrupts_masked
4590 @cindex @code{keep_interrupts_masked} function attribute, MIPS
4591 Keep interrupts masked for the whole function.  Without this attribute,
4592 GCC tries to reenable interrupts for as much of the function as it can.
4594 @item use_debug_exception_return
4595 @cindex @code{use_debug_exception_return} function attribute, MIPS
4596 Return using the @code{deret} instruction.  Interrupt handlers that don't
4597 have this attribute return using @code{eret} instead.
4598 @end table
4600 You can use any combination of these attributes, as shown below:
4601 @smallexample
4602 void __attribute__ ((interrupt)) v0 ();
4603 void __attribute__ ((interrupt, use_shadow_register_set)) v1 ();
4604 void __attribute__ ((interrupt, keep_interrupts_masked)) v2 ();
4605 void __attribute__ ((interrupt, use_debug_exception_return)) v3 ();
4606 void __attribute__ ((interrupt, use_shadow_register_set,
4607                      keep_interrupts_masked)) v4 ();
4608 void __attribute__ ((interrupt, use_shadow_register_set,
4609                      use_debug_exception_return)) v5 ();
4610 void __attribute__ ((interrupt, keep_interrupts_masked,
4611                      use_debug_exception_return)) v6 ();
4612 void __attribute__ ((interrupt, use_shadow_register_set,
4613                      keep_interrupts_masked,
4614                      use_debug_exception_return)) v7 ();
4615 void __attribute__ ((interrupt("eic"))) v8 ();
4616 void __attribute__ ((interrupt("vector=hw3"))) v9 ();
4617 @end smallexample
4619 @item long_call
4620 @itemx short_call
4621 @itemx near
4622 @itemx far
4623 @cindex indirect calls, MIPS
4624 @cindex @code{long_call} function attribute, MIPS
4625 @cindex @code{short_call} function attribute, MIPS
4626 @cindex @code{near} function attribute, MIPS
4627 @cindex @code{far} function attribute, MIPS
4628 These attributes specify how a particular function is called on MIPS@.
4629 The attributes override the @option{-mlong-calls} (@pxref{MIPS Options})
4630 command-line switch.  The @code{long_call} and @code{far} attributes are
4631 synonyms, and cause the compiler to always call
4632 the function by first loading its address into a register, and then using
4633 the contents of that register.  The @code{short_call} and @code{near}
4634 attributes are synonyms, and have the opposite
4635 effect; they specify that non-PIC calls should be made using the more
4636 efficient @code{jal} instruction.
4638 @item mips16
4639 @itemx nomips16
4640 @cindex @code{mips16} function attribute, MIPS
4641 @cindex @code{nomips16} function attribute, MIPS
4643 On MIPS targets, you can use the @code{mips16} and @code{nomips16}
4644 function attributes to locally select or turn off MIPS16 code generation.
4645 A function with the @code{mips16} attribute is emitted as MIPS16 code,
4646 while MIPS16 code generation is disabled for functions with the
4647 @code{nomips16} attribute.  These attributes override the
4648 @option{-mips16} and @option{-mno-mips16} options on the command line
4649 (@pxref{MIPS Options}).
4651 When compiling files containing mixed MIPS16 and non-MIPS16 code, the
4652 preprocessor symbol @code{__mips16} reflects the setting on the command line,
4653 not that within individual functions.  Mixed MIPS16 and non-MIPS16 code
4654 may interact badly with some GCC extensions such as @code{__builtin_apply}
4655 (@pxref{Constructing Calls}).
4657 @item micromips, MIPS
4658 @itemx nomicromips, MIPS
4659 @cindex @code{micromips} function attribute
4660 @cindex @code{nomicromips} function attribute
4662 On MIPS targets, you can use the @code{micromips} and @code{nomicromips}
4663 function attributes to locally select or turn off microMIPS code generation.
4664 A function with the @code{micromips} attribute is emitted as microMIPS code,
4665 while microMIPS code generation is disabled for functions with the
4666 @code{nomicromips} attribute.  These attributes override the
4667 @option{-mmicromips} and @option{-mno-micromips} options on the command line
4668 (@pxref{MIPS Options}).
4670 When compiling files containing mixed microMIPS and non-microMIPS code, the
4671 preprocessor symbol @code{__mips_micromips} reflects the setting on the
4672 command line,
4673 not that within individual functions.  Mixed microMIPS and non-microMIPS code
4674 may interact badly with some GCC extensions such as @code{__builtin_apply}
4675 (@pxref{Constructing Calls}).
4677 @item nocompression
4678 @cindex @code{nocompression} function attribute, MIPS
4679 On MIPS targets, you can use the @code{nocompression} function attribute
4680 to locally turn off MIPS16 and microMIPS code generation.  This attribute
4681 overrides the @option{-mips16} and @option{-mmicromips} options on the
4682 command line (@pxref{MIPS Options}).
4683 @end table
4685 @node MSP430 Function Attributes
4686 @subsection MSP430 Function Attributes
4688 These function attributes are supported by the MSP430 back end:
4690 @table @code
4691 @item critical
4692 @cindex @code{critical} function attribute, MSP430
4693 Critical functions disable interrupts upon entry and restore the
4694 previous interrupt state upon exit.  Critical functions cannot also
4695 have the @code{naked} or @code{reentrant} attributes.  They can have
4696 the @code{interrupt} attribute.
4698 @item interrupt
4699 @cindex @code{interrupt} function attribute, MSP430
4700 Use this attribute to indicate
4701 that the specified function is an interrupt handler.  The compiler generates
4702 function entry and exit sequences suitable for use in an interrupt handler
4703 when this attribute is present.
4705 You can provide an argument to the interrupt
4706 attribute which specifies a name or number.  If the argument is a
4707 number it indicates the slot in the interrupt vector table (0 - 31) to
4708 which this handler should be assigned.  If the argument is a name it
4709 is treated as a symbolic name for the vector slot.  These names should
4710 match up with appropriate entries in the linker script.  By default
4711 the names @code{watchdog} for vector 26, @code{nmi} for vector 30 and
4712 @code{reset} for vector 31 are recognized.
4714 @item naked
4715 @cindex @code{naked} function attribute, MSP430
4716 This attribute allows the compiler to construct the
4717 requisite function declaration, while allowing the body of the
4718 function to be assembly code. The specified function will not have
4719 prologue/epilogue sequences generated by the compiler. Only basic
4720 @code{asm} statements can safely be included in naked functions
4721 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
4722 basic @code{asm} and C code may appear to work, they cannot be
4723 depended upon to work reliably and are not supported.
4725 @item reentrant
4726 @cindex @code{reentrant} function attribute, MSP430
4727 Reentrant functions disable interrupts upon entry and enable them
4728 upon exit.  Reentrant functions cannot also have the @code{naked}
4729 or @code{critical} attributes.  They can have the @code{interrupt}
4730 attribute.
4732 @item wakeup
4733 @cindex @code{wakeup} function attribute, MSP430
4734 This attribute only applies to interrupt functions.  It is silently
4735 ignored if applied to a non-interrupt function.  A wakeup interrupt
4736 function will rouse the processor from any low-power state that it
4737 might be in when the function exits.
4739 @item lower
4740 @itemx upper
4741 @itemx either
4742 @cindex @code{lower} function attribute, MSP430
4743 @cindex @code{upper} function attribute, MSP430
4744 @cindex @code{either} function attribute, MSP430
4745 On the MSP430 target these attributes can be used to specify whether
4746 the function or variable should be placed into low memory, high
4747 memory, or the placement should be left to the linker to decide.  The
4748 attributes are only significant if compiling for the MSP430X
4749 architecture.
4751 The attributes work in conjunction with a linker script that has been
4752 augmented to specify where to place sections with a @code{.lower} and
4753 a @code{.upper} prefix.  So, for example, as well as placing the
4754 @code{.data} section, the script also specifies the placement of a
4755 @code{.lower.data} and a @code{.upper.data} section.  The intention
4756 is that @code{lower} sections are placed into a small but easier to
4757 access memory region and the upper sections are placed into a larger, but
4758 slower to access, region.
4760 The @code{either} attribute is special.  It tells the linker to place
4761 the object into the corresponding @code{lower} section if there is
4762 room for it.  If there is insufficient room then the object is placed
4763 into the corresponding @code{upper} section instead.  Note that the
4764 placement algorithm is not very sophisticated.  It does not attempt to
4765 find an optimal packing of the @code{lower} sections.  It just makes
4766 one pass over the objects and does the best that it can.  Using the
4767 @option{-ffunction-sections} and @option{-fdata-sections} command-line
4768 options can help the packing, however, since they produce smaller,
4769 easier to pack regions.
4770 @end table
4772 @node NDS32 Function Attributes
4773 @subsection NDS32 Function Attributes
4775 These function attributes are supported by the NDS32 back end:
4777 @table @code
4778 @item exception
4779 @cindex @code{exception} function attribute
4780 @cindex exception handler functions, NDS32
4781 Use this attribute on the NDS32 target to indicate that the specified function
4782 is an exception handler.  The compiler will generate corresponding sections
4783 for use in an exception handler.
4785 @item interrupt
4786 @cindex @code{interrupt} function attribute, NDS32
4787 On NDS32 target, this attribute indicates that the specified function
4788 is an interrupt handler.  The compiler generates corresponding sections
4789 for use in an interrupt handler.  You can use the following attributes
4790 to modify the behavior:
4791 @table @code
4792 @item nested
4793 @cindex @code{nested} function attribute, NDS32
4794 This interrupt service routine is interruptible.
4795 @item not_nested
4796 @cindex @code{not_nested} function attribute, NDS32
4797 This interrupt service routine is not interruptible.
4798 @item nested_ready
4799 @cindex @code{nested_ready} function attribute, NDS32
4800 This interrupt service routine is interruptible after @code{PSW.GIE}
4801 (global interrupt enable) is set.  This allows interrupt service routine to
4802 finish some short critical code before enabling interrupts.
4803 @item save_all
4804 @cindex @code{save_all} function attribute, NDS32
4805 The system will help save all registers into stack before entering
4806 interrupt handler.
4807 @item partial_save
4808 @cindex @code{partial_save} function attribute, NDS32
4809 The system will help save caller registers into stack before entering
4810 interrupt handler.
4811 @end table
4813 @item naked
4814 @cindex @code{naked} function attribute, NDS32
4815 This attribute allows the compiler to construct the
4816 requisite function declaration, while allowing the body of the
4817 function to be assembly code. The specified function will not have
4818 prologue/epilogue sequences generated by the compiler. Only basic
4819 @code{asm} statements can safely be included in naked functions
4820 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
4821 basic @code{asm} and C code may appear to work, they cannot be
4822 depended upon to work reliably and are not supported.
4824 @item reset
4825 @cindex @code{reset} function attribute, NDS32
4826 @cindex reset handler functions
4827 Use this attribute on the NDS32 target to indicate that the specified function
4828 is a reset handler.  The compiler will generate corresponding sections
4829 for use in a reset handler.  You can use the following attributes
4830 to provide extra exception handling:
4831 @table @code
4832 @item nmi
4833 @cindex @code{nmi} function attribute, NDS32
4834 Provide a user-defined function to handle NMI exception.
4835 @item warm
4836 @cindex @code{warm} function attribute, NDS32
4837 Provide a user-defined function to handle warm reset exception.
4838 @end table
4839 @end table
4841 @node Nios II Function Attributes
4842 @subsection Nios II Function Attributes
4844 These function attributes are supported by the Nios II back end:
4846 @table @code
4847 @item target (@var{options})
4848 @cindex @code{target} function attribute
4849 As discussed in @ref{Common Function Attributes}, this attribute 
4850 allows specification of target-specific compilation options.
4852 When compiling for Nios II, the following options are allowed:
4854 @table @samp
4855 @item custom-@var{insn}=@var{N}
4856 @itemx no-custom-@var{insn}
4857 @cindex @code{target("custom-@var{insn}=@var{N}")} function attribute, Nios II
4858 @cindex @code{target("no-custom-@var{insn}")} function attribute, Nios II
4859 Each @samp{custom-@var{insn}=@var{N}} attribute locally enables use of a
4860 custom instruction with encoding @var{N} when generating code that uses 
4861 @var{insn}.  Similarly, @samp{no-custom-@var{insn}} locally inhibits use of
4862 the custom instruction @var{insn}.
4863 These target attributes correspond to the
4864 @option{-mcustom-@var{insn}=@var{N}} and @option{-mno-custom-@var{insn}}
4865 command-line options, and support the same set of @var{insn} keywords.
4866 @xref{Nios II Options}, for more information.
4868 @item custom-fpu-cfg=@var{name}
4869 @cindex @code{target("custom-fpu-cfg=@var{name}")} function attribute, Nios II
4870 This attribute corresponds to the @option{-mcustom-fpu-cfg=@var{name}}
4871 command-line option, to select a predefined set of custom instructions
4872 named @var{name}.
4873 @xref{Nios II Options}, for more information.
4874 @end table
4875 @end table
4877 @node Nvidia PTX Function Attributes
4878 @subsection Nvidia PTX Function Attributes
4880 These function attributes are supported by the Nvidia PTX back end:
4882 @table @code
4883 @item kernel
4884 @cindex @code{kernel} attribute, Nvidia PTX
4885 This attribute indicates that the corresponding function should be compiled
4886 as a kernel function, which can be invoked from the host via the CUDA RT 
4887 library.
4888 By default functions are only callable only from other PTX functions.
4890 Kernel functions must have @code{void} return type.
4891 @end table
4893 @node PowerPC Function Attributes
4894 @subsection PowerPC Function Attributes
4896 These function attributes are supported by the PowerPC back end:
4898 @table @code
4899 @item longcall
4900 @itemx shortcall
4901 @cindex indirect calls, PowerPC
4902 @cindex @code{longcall} function attribute, PowerPC
4903 @cindex @code{shortcall} function attribute, PowerPC
4904 The @code{longcall} attribute
4905 indicates that the function might be far away from the call site and
4906 require a different (more expensive) calling sequence.  The
4907 @code{shortcall} attribute indicates that the function is always close
4908 enough for the shorter calling sequence to be used.  These attributes
4909 override both the @option{-mlongcall} switch and
4910 the @code{#pragma longcall} setting.
4912 @xref{RS/6000 and PowerPC Options}, for more information on whether long
4913 calls are necessary.
4915 @item target (@var{options})
4916 @cindex @code{target} function attribute
4917 As discussed in @ref{Common Function Attributes}, this attribute 
4918 allows specification of target-specific compilation options.
4920 On the PowerPC, the following options are allowed:
4922 @table @samp
4923 @item altivec
4924 @itemx no-altivec
4925 @cindex @code{target("altivec")} function attribute, PowerPC
4926 Generate code that uses (does not use) AltiVec instructions.  In
4927 32-bit code, you cannot enable AltiVec instructions unless
4928 @option{-mabi=altivec} is used on the command line.
4930 @item cmpb
4931 @itemx no-cmpb
4932 @cindex @code{target("cmpb")} function attribute, PowerPC
4933 Generate code that uses (does not use) the compare bytes instruction
4934 implemented on the POWER6 processor and other processors that support
4935 the PowerPC V2.05 architecture.
4937 @item dlmzb
4938 @itemx no-dlmzb
4939 @cindex @code{target("dlmzb")} function attribute, PowerPC
4940 Generate code that uses (does not use) the string-search @samp{dlmzb}
4941 instruction on the IBM 405, 440, 464 and 476 processors.  This instruction is
4942 generated by default when targeting those processors.
4944 @item fprnd
4945 @itemx no-fprnd
4946 @cindex @code{target("fprnd")} function attribute, PowerPC
4947 Generate code that uses (does not use) the FP round to integer
4948 instructions implemented on the POWER5+ processor and other processors
4949 that support the PowerPC V2.03 architecture.
4951 @item hard-dfp
4952 @itemx no-hard-dfp
4953 @cindex @code{target("hard-dfp")} function attribute, PowerPC
4954 Generate code that uses (does not use) the decimal floating-point
4955 instructions implemented on some POWER processors.
4957 @item isel
4958 @itemx no-isel
4959 @cindex @code{target("isel")} function attribute, PowerPC
4960 Generate code that uses (does not use) ISEL instruction.
4962 @item mfcrf
4963 @itemx no-mfcrf
4964 @cindex @code{target("mfcrf")} function attribute, PowerPC
4965 Generate code that uses (does not use) the move from condition
4966 register field instruction implemented on the POWER4 processor and
4967 other processors that support the PowerPC V2.01 architecture.
4969 @item mfpgpr
4970 @itemx no-mfpgpr
4971 @cindex @code{target("mfpgpr")} function attribute, PowerPC
4972 Generate code that uses (does not use) the FP move to/from general
4973 purpose register instructions implemented on the POWER6X processor and
4974 other processors that support the extended PowerPC V2.05 architecture.
4976 @item mulhw
4977 @itemx no-mulhw
4978 @cindex @code{target("mulhw")} function attribute, PowerPC
4979 Generate code that uses (does not use) the half-word multiply and
4980 multiply-accumulate instructions on the IBM 405, 440, 464 and 476 processors.
4981 These instructions are generated by default when targeting those
4982 processors.
4984 @item multiple
4985 @itemx no-multiple
4986 @cindex @code{target("multiple")} function attribute, PowerPC
4987 Generate code that uses (does not use) the load multiple word
4988 instructions and the store multiple word instructions.
4990 @item update
4991 @itemx no-update
4992 @cindex @code{target("update")} function attribute, PowerPC
4993 Generate code that uses (does not use) the load or store instructions
4994 that update the base register to the address of the calculated memory
4995 location.
4997 @item popcntb
4998 @itemx no-popcntb
4999 @cindex @code{target("popcntb")} function attribute, PowerPC
5000 Generate code that uses (does not use) the popcount and double-precision
5001 FP reciprocal estimate instruction implemented on the POWER5
5002 processor and other processors that support the PowerPC V2.02
5003 architecture.
5005 @item popcntd
5006 @itemx no-popcntd
5007 @cindex @code{target("popcntd")} function attribute, PowerPC
5008 Generate code that uses (does not use) the popcount instruction
5009 implemented on the POWER7 processor and other processors that support
5010 the PowerPC V2.06 architecture.
5012 @item powerpc-gfxopt
5013 @itemx no-powerpc-gfxopt
5014 @cindex @code{target("powerpc-gfxopt")} function attribute, PowerPC
5015 Generate code that uses (does not use) the optional PowerPC
5016 architecture instructions in the Graphics group, including
5017 floating-point select.
5019 @item powerpc-gpopt
5020 @itemx no-powerpc-gpopt
5021 @cindex @code{target("powerpc-gpopt")} function attribute, PowerPC
5022 Generate code that uses (does not use) the optional PowerPC
5023 architecture instructions in the General Purpose group, including
5024 floating-point square root.
5026 @item recip-precision
5027 @itemx no-recip-precision
5028 @cindex @code{target("recip-precision")} function attribute, PowerPC
5029 Assume (do not assume) that the reciprocal estimate instructions
5030 provide higher-precision estimates than is mandated by the PowerPC
5031 ABI.
5033 @item string
5034 @itemx no-string
5035 @cindex @code{target("string")} function attribute, PowerPC
5036 Generate code that uses (does not use) the load string instructions
5037 and the store string word instructions to save multiple registers and
5038 do small block moves.
5040 @item vsx
5041 @itemx no-vsx
5042 @cindex @code{target("vsx")} function attribute, PowerPC
5043 Generate code that uses (does not use) vector/scalar (VSX)
5044 instructions, and also enable the use of built-in functions that allow
5045 more direct access to the VSX instruction set.  In 32-bit code, you
5046 cannot enable VSX or AltiVec instructions unless
5047 @option{-mabi=altivec} is used on the command line.
5049 @item friz
5050 @itemx no-friz
5051 @cindex @code{target("friz")} function attribute, PowerPC
5052 Generate (do not generate) the @code{friz} instruction when the
5053 @option{-funsafe-math-optimizations} option is used to optimize
5054 rounding a floating-point value to 64-bit integer and back to floating
5055 point.  The @code{friz} instruction does not return the same value if
5056 the floating-point number is too large to fit in an integer.
5058 @item avoid-indexed-addresses
5059 @itemx no-avoid-indexed-addresses
5060 @cindex @code{target("avoid-indexed-addresses")} function attribute, PowerPC
5061 Generate code that tries to avoid (not avoid) the use of indexed load
5062 or store instructions.
5064 @item paired
5065 @itemx no-paired
5066 @cindex @code{target("paired")} function attribute, PowerPC
5067 Generate code that uses (does not use) the generation of PAIRED simd
5068 instructions.
5070 @item longcall
5071 @itemx no-longcall
5072 @cindex @code{target("longcall")} function attribute, PowerPC
5073 Generate code that assumes (does not assume) that all calls are far
5074 away so that a longer more expensive calling sequence is required.
5076 @item cpu=@var{CPU}
5077 @cindex @code{target("cpu=@var{CPU}")} function attribute, PowerPC
5078 Specify the architecture to generate code for when compiling the
5079 function.  If you select the @code{target("cpu=power7")} attribute when
5080 generating 32-bit code, VSX and AltiVec instructions are not generated
5081 unless you use the @option{-mabi=altivec} option on the command line.
5083 @item tune=@var{TUNE}
5084 @cindex @code{target("tune=@var{TUNE}")} function attribute, PowerPC
5085 Specify the architecture to tune for when compiling the function.  If
5086 you do not specify the @code{target("tune=@var{TUNE}")} attribute and
5087 you do specify the @code{target("cpu=@var{CPU}")} attribute,
5088 compilation tunes for the @var{CPU} architecture, and not the
5089 default tuning specified on the command line.
5090 @end table
5092 On the PowerPC, the inliner does not inline a
5093 function that has different target options than the caller, unless the
5094 callee has a subset of the target options of the caller.
5095 @end table
5097 @node RISC-V Function Attributes
5098 @subsection RISC-V Function Attributes
5100 These function attributes are supported by the RISC-V back end:
5102 @table @code
5103 @item naked
5104 @cindex @code{naked} function attribute, RISC-V
5105 This attribute allows the compiler to construct the
5106 requisite function declaration, while allowing the body of the
5107 function to be assembly code. The specified function will not have
5108 prologue/epilogue sequences generated by the compiler. Only basic
5109 @code{asm} statements can safely be included in naked functions
5110 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
5111 basic @code{asm} and C code may appear to work, they cannot be
5112 depended upon to work reliably and are not supported.
5113 @end table
5115 @node RL78 Function Attributes
5116 @subsection RL78 Function Attributes
5118 These function attributes are supported by the RL78 back end:
5120 @table @code
5121 @item interrupt
5122 @itemx brk_interrupt
5123 @cindex @code{interrupt} function attribute, RL78
5124 @cindex @code{brk_interrupt} function attribute, RL78
5125 These attributes indicate
5126 that the specified function is an interrupt handler.  The compiler generates
5127 function entry and exit sequences suitable for use in an interrupt handler
5128 when this attribute is present.
5130 Use @code{brk_interrupt} instead of @code{interrupt} for
5131 handlers intended to be used with the @code{BRK} opcode (i.e.@: those
5132 that must end with @code{RETB} instead of @code{RETI}).
5134 @item naked
5135 @cindex @code{naked} function attribute, RL78
5136 This attribute allows the compiler to construct the
5137 requisite function declaration, while allowing the body of the
5138 function to be assembly code. The specified function will not have
5139 prologue/epilogue sequences generated by the compiler. Only basic
5140 @code{asm} statements can safely be included in naked functions
5141 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
5142 basic @code{asm} and C code may appear to work, they cannot be
5143 depended upon to work reliably and are not supported.
5144 @end table
5146 @node RX Function Attributes
5147 @subsection RX Function Attributes
5149 These function attributes are supported by the RX back end:
5151 @table @code
5152 @item fast_interrupt
5153 @cindex @code{fast_interrupt} function attribute, RX
5154 Use this attribute on the RX port to indicate that the specified
5155 function is a fast interrupt handler.  This is just like the
5156 @code{interrupt} attribute, except that @code{freit} is used to return
5157 instead of @code{reit}.
5159 @item interrupt
5160 @cindex @code{interrupt} function attribute, RX
5161 Use this attribute to indicate
5162 that the specified function is an interrupt handler.  The compiler generates
5163 function entry and exit sequences suitable for use in an interrupt handler
5164 when this attribute is present.
5166 On RX targets, you may specify one or more vector numbers as arguments
5167 to the attribute, as well as naming an alternate table name.
5168 Parameters are handled sequentially, so one handler can be assigned to
5169 multiple entries in multiple tables.  One may also pass the magic
5170 string @code{"$default"} which causes the function to be used for any
5171 unfilled slots in the current table.
5173 This example shows a simple assignment of a function to one vector in
5174 the default table (note that preprocessor macros may be used for
5175 chip-specific symbolic vector names):
5176 @smallexample
5177 void __attribute__ ((interrupt (5))) txd1_handler ();
5178 @end smallexample
5180 This example assigns a function to two slots in the default table
5181 (using preprocessor macros defined elsewhere) and makes it the default
5182 for the @code{dct} table:
5183 @smallexample
5184 void __attribute__ ((interrupt (RXD1_VECT,RXD2_VECT,"dct","$default")))
5185         txd1_handler ();
5186 @end smallexample
5188 @item naked
5189 @cindex @code{naked} function attribute, RX
5190 This attribute allows the compiler to construct the
5191 requisite function declaration, while allowing the body of the
5192 function to be assembly code. The specified function will not have
5193 prologue/epilogue sequences generated by the compiler. Only basic
5194 @code{asm} statements can safely be included in naked functions
5195 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
5196 basic @code{asm} and C code may appear to work, they cannot be
5197 depended upon to work reliably and are not supported.
5199 @item vector
5200 @cindex @code{vector} function attribute, RX
5201 This RX attribute is similar to the @code{interrupt} attribute, including its
5202 parameters, but does not make the function an interrupt-handler type
5203 function (i.e. it retains the normal C function calling ABI).  See the
5204 @code{interrupt} attribute for a description of its arguments.
5205 @end table
5207 @node S/390 Function Attributes
5208 @subsection S/390 Function Attributes
5210 These function attributes are supported on the S/390:
5212 @table @code
5213 @item hotpatch (@var{halfwords-before-function-label},@var{halfwords-after-function-label})
5214 @cindex @code{hotpatch} function attribute, S/390
5216 On S/390 System z targets, you can use this function attribute to
5217 make GCC generate a ``hot-patching'' function prologue.  If the
5218 @option{-mhotpatch=} command-line option is used at the same time,
5219 the @code{hotpatch} attribute takes precedence.  The first of the
5220 two arguments specifies the number of halfwords to be added before
5221 the function label.  A second argument can be used to specify the
5222 number of halfwords to be added after the function label.  For
5223 both arguments the maximum allowed value is 1000000.
5225 If both arguments are zero, hotpatching is disabled.
5227 @item target (@var{options})
5228 @cindex @code{target} function attribute
5229 As discussed in @ref{Common Function Attributes}, this attribute
5230 allows specification of target-specific compilation options.
5232 On S/390, the following options are supported:
5234 @table @samp
5235 @item arch=
5236 @item tune=
5237 @item stack-guard=
5238 @item stack-size=
5239 @item branch-cost=
5240 @item warn-framesize=
5241 @item backchain
5242 @itemx no-backchain
5243 @item hard-dfp
5244 @itemx no-hard-dfp
5245 @item hard-float
5246 @itemx soft-float
5247 @item htm
5248 @itemx no-htm
5249 @item vx
5250 @itemx no-vx
5251 @item packed-stack
5252 @itemx no-packed-stack
5253 @item small-exec
5254 @itemx no-small-exec
5255 @item mvcle
5256 @itemx no-mvcle
5257 @item warn-dynamicstack
5258 @itemx no-warn-dynamicstack
5259 @end table
5261 The options work exactly like the S/390 specific command line
5262 options (without the prefix @option{-m}) except that they do not
5263 change any feature macros.  For example,
5265 @smallexample
5266 @code{target("no-vx")}
5267 @end smallexample
5269 does not undefine the @code{__VEC__} macro.
5270 @end table
5272 @node SH Function Attributes
5273 @subsection SH Function Attributes
5275 These function attributes are supported on the SH family of processors:
5277 @table @code
5278 @item function_vector
5279 @cindex @code{function_vector} function attribute, SH
5280 @cindex calling functions through the function vector on SH2A
5281 On SH2A targets, this attribute declares a function to be called using the
5282 TBR relative addressing mode.  The argument to this attribute is the entry
5283 number of the same function in a vector table containing all the TBR
5284 relative addressable functions.  For correct operation the TBR must be setup
5285 accordingly to point to the start of the vector table before any functions with
5286 this attribute are invoked.  Usually a good place to do the initialization is
5287 the startup routine.  The TBR relative vector table can have at max 256 function
5288 entries.  The jumps to these functions are generated using a SH2A specific,
5289 non delayed branch instruction JSR/N @@(disp8,TBR).  You must use GAS and GLD
5290 from GNU binutils version 2.7 or later for this attribute to work correctly.
5292 In an application, for a function being called once, this attribute
5293 saves at least 8 bytes of code; and if other successive calls are being
5294 made to the same function, it saves 2 bytes of code per each of these
5295 calls.
5297 @item interrupt_handler
5298 @cindex @code{interrupt_handler} function attribute, SH
5299 Use this attribute to
5300 indicate that the specified function is an interrupt handler.  The compiler
5301 generates function entry and exit sequences suitable for use in an
5302 interrupt handler when this attribute is present.
5304 @item nosave_low_regs
5305 @cindex @code{nosave_low_regs} function attribute, SH
5306 Use this attribute on SH targets to indicate that an @code{interrupt_handler}
5307 function should not save and restore registers R0..R7.  This can be used on SH3*
5308 and SH4* targets that have a second R0..R7 register bank for non-reentrant
5309 interrupt handlers.
5311 @item renesas
5312 @cindex @code{renesas} function attribute, SH
5313 On SH targets this attribute specifies that the function or struct follows the
5314 Renesas ABI.
5316 @item resbank
5317 @cindex @code{resbank} function attribute, SH
5318 On the SH2A target, this attribute enables the high-speed register
5319 saving and restoration using a register bank for @code{interrupt_handler}
5320 routines.  Saving to the bank is performed automatically after the CPU
5321 accepts an interrupt that uses a register bank.
5323 The nineteen 32-bit registers comprising general register R0 to R14,
5324 control register GBR, and system registers MACH, MACL, and PR and the
5325 vector table address offset are saved into a register bank.  Register
5326 banks are stacked in first-in last-out (FILO) sequence.  Restoration
5327 from the bank is executed by issuing a RESBANK instruction.
5329 @item sp_switch
5330 @cindex @code{sp_switch} function attribute, SH
5331 Use this attribute on the SH to indicate an @code{interrupt_handler}
5332 function should switch to an alternate stack.  It expects a string
5333 argument that names a global variable holding the address of the
5334 alternate stack.
5336 @smallexample
5337 void *alt_stack;
5338 void f () __attribute__ ((interrupt_handler,
5339                           sp_switch ("alt_stack")));
5340 @end smallexample
5342 @item trap_exit
5343 @cindex @code{trap_exit} function attribute, SH
5344 Use this attribute on the SH for an @code{interrupt_handler} to return using
5345 @code{trapa} instead of @code{rte}.  This attribute expects an integer
5346 argument specifying the trap number to be used.
5348 @item trapa_handler
5349 @cindex @code{trapa_handler} function attribute, SH
5350 On SH targets this function attribute is similar to @code{interrupt_handler}
5351 but it does not save and restore all registers.
5352 @end table
5354 @node SPU Function Attributes
5355 @subsection SPU Function Attributes
5357 These function attributes are supported by the SPU back end:
5359 @table @code
5360 @item naked
5361 @cindex @code{naked} function attribute, SPU
5362 This attribute allows the compiler to construct the
5363 requisite function declaration, while allowing the body of the
5364 function to be assembly code. The specified function will not have
5365 prologue/epilogue sequences generated by the compiler. Only basic
5366 @code{asm} statements can safely be included in naked functions
5367 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
5368 basic @code{asm} and C code may appear to work, they cannot be
5369 depended upon to work reliably and are not supported.
5370 @end table
5372 @node Symbian OS Function Attributes
5373 @subsection Symbian OS Function Attributes
5375 @xref{Microsoft Windows Function Attributes}, for discussion of the
5376 @code{dllexport} and @code{dllimport} attributes.
5378 @node V850 Function Attributes
5379 @subsection V850 Function Attributes
5381 The V850 back end supports these function attributes:
5383 @table @code
5384 @item interrupt
5385 @itemx interrupt_handler
5386 @cindex @code{interrupt} function attribute, V850
5387 @cindex @code{interrupt_handler} function attribute, V850
5388 Use these attributes to indicate
5389 that the specified function is an interrupt handler.  The compiler generates
5390 function entry and exit sequences suitable for use in an interrupt handler
5391 when either attribute is present.
5392 @end table
5394 @node Visium Function Attributes
5395 @subsection Visium Function Attributes
5397 These function attributes are supported by the Visium back end:
5399 @table @code
5400 @item interrupt
5401 @cindex @code{interrupt} function attribute, Visium
5402 Use this attribute to indicate
5403 that the specified function is an interrupt handler.  The compiler generates
5404 function entry and exit sequences suitable for use in an interrupt handler
5405 when this attribute is present.
5406 @end table
5408 @node x86 Function Attributes
5409 @subsection x86 Function Attributes
5411 These function attributes are supported by the x86 back end:
5413 @table @code
5414 @item cdecl
5415 @cindex @code{cdecl} function attribute, x86-32
5416 @cindex functions that pop the argument stack on x86-32
5417 @opindex mrtd
5418 On the x86-32 targets, the @code{cdecl} attribute causes the compiler to
5419 assume that the calling function pops off the stack space used to
5420 pass arguments.  This is
5421 useful to override the effects of the @option{-mrtd} switch.
5423 @item fastcall
5424 @cindex @code{fastcall} function attribute, x86-32
5425 @cindex functions that pop the argument stack on x86-32
5426 On x86-32 targets, the @code{fastcall} attribute causes the compiler to
5427 pass the first argument (if of integral type) in the register ECX and
5428 the second argument (if of integral type) in the register EDX@.  Subsequent
5429 and other typed arguments are passed on the stack.  The called function
5430 pops the arguments off the stack.  If the number of arguments is variable all
5431 arguments are pushed on the stack.
5433 @item thiscall
5434 @cindex @code{thiscall} function attribute, x86-32
5435 @cindex functions that pop the argument stack on x86-32
5436 On x86-32 targets, the @code{thiscall} attribute causes the compiler to
5437 pass the first argument (if of integral type) in the register ECX.
5438 Subsequent and other typed arguments are passed on the stack. The called
5439 function pops the arguments off the stack.
5440 If the number of arguments is variable all arguments are pushed on the
5441 stack.
5442 The @code{thiscall} attribute is intended for C++ non-static member functions.
5443 As a GCC extension, this calling convention can be used for C functions
5444 and for static member methods.
5446 @item ms_abi
5447 @itemx sysv_abi
5448 @cindex @code{ms_abi} function attribute, x86
5449 @cindex @code{sysv_abi} function attribute, x86
5451 On 32-bit and 64-bit x86 targets, you can use an ABI attribute
5452 to indicate which calling convention should be used for a function.  The
5453 @code{ms_abi} attribute tells the compiler to use the Microsoft ABI,
5454 while the @code{sysv_abi} attribute tells the compiler to use the ABI
5455 used on GNU/Linux and other systems.  The default is to use the Microsoft ABI
5456 when targeting Windows.  On all other systems, the default is the x86/AMD ABI.
5458 Note, the @code{ms_abi} attribute for Microsoft Windows 64-bit targets currently
5459 requires the @option{-maccumulate-outgoing-args} option.
5461 @item callee_pop_aggregate_return (@var{number})
5462 @cindex @code{callee_pop_aggregate_return} function attribute, x86
5464 On x86-32 targets, you can use this attribute to control how
5465 aggregates are returned in memory.  If the caller is responsible for
5466 popping the hidden pointer together with the rest of the arguments, specify
5467 @var{number} equal to zero.  If callee is responsible for popping the
5468 hidden pointer, specify @var{number} equal to one.  
5470 The default x86-32 ABI assumes that the callee pops the
5471 stack for hidden pointer.  However, on x86-32 Microsoft Windows targets,
5472 the compiler assumes that the
5473 caller pops the stack for hidden pointer.
5475 @item ms_hook_prologue
5476 @cindex @code{ms_hook_prologue} function attribute, x86
5478 On 32-bit and 64-bit x86 targets, you can use
5479 this function attribute to make GCC generate the ``hot-patching'' function
5480 prologue used in Win32 API functions in Microsoft Windows XP Service Pack 2
5481 and newer.
5483 @item naked
5484 @cindex @code{naked} function attribute, x86
5485 This attribute allows the compiler to construct the
5486 requisite function declaration, while allowing the body of the
5487 function to be assembly code. The specified function will not have
5488 prologue/epilogue sequences generated by the compiler. Only basic
5489 @code{asm} statements can safely be included in naked functions
5490 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
5491 basic @code{asm} and C code may appear to work, they cannot be
5492 depended upon to work reliably and are not supported.
5494 @item regparm (@var{number})
5495 @cindex @code{regparm} function attribute, x86
5496 @cindex functions that are passed arguments in registers on x86-32
5497 On x86-32 targets, the @code{regparm} attribute causes the compiler to
5498 pass arguments number one to @var{number} if they are of integral type
5499 in registers EAX, EDX, and ECX instead of on the stack.  Functions that
5500 take a variable number of arguments continue to be passed all of their
5501 arguments on the stack.
5503 Beware that on some ELF systems this attribute is unsuitable for
5504 global functions in shared libraries with lazy binding (which is the
5505 default).  Lazy binding sends the first call via resolving code in
5506 the loader, which might assume EAX, EDX and ECX can be clobbered, as
5507 per the standard calling conventions.  Solaris 8 is affected by this.
5508 Systems with the GNU C Library version 2.1 or higher
5509 and FreeBSD are believed to be
5510 safe since the loaders there save EAX, EDX and ECX.  (Lazy binding can be
5511 disabled with the linker or the loader if desired, to avoid the
5512 problem.)
5514 @item sseregparm
5515 @cindex @code{sseregparm} function attribute, x86
5516 On x86-32 targets with SSE support, the @code{sseregparm} attribute
5517 causes the compiler to pass up to 3 floating-point arguments in
5518 SSE registers instead of on the stack.  Functions that take a
5519 variable number of arguments continue to pass all of their
5520 floating-point arguments on the stack.
5522 @item force_align_arg_pointer
5523 @cindex @code{force_align_arg_pointer} function attribute, x86
5524 On x86 targets, the @code{force_align_arg_pointer} attribute may be
5525 applied to individual function definitions, generating an alternate
5526 prologue and epilogue that realigns the run-time stack if necessary.
5527 This supports mixing legacy codes that run with a 4-byte aligned stack
5528 with modern codes that keep a 16-byte stack for SSE compatibility.
5530 @item stdcall
5531 @cindex @code{stdcall} function attribute, x86-32
5532 @cindex functions that pop the argument stack on x86-32
5533 On x86-32 targets, the @code{stdcall} attribute causes the compiler to
5534 assume that the called function pops off the stack space used to
5535 pass arguments, unless it takes a variable number of arguments.
5537 @item no_caller_saved_registers
5538 @cindex @code{no_caller_saved_registers} function attribute, x86
5539 Use this attribute to indicate that the specified function has no
5540 caller-saved registers. That is, all registers are callee-saved. For
5541 example, this attribute can be used for a function called from an
5542 interrupt handler. The compiler generates proper function entry and
5543 exit sequences to save and restore any modified registers, except for
5544 the EFLAGS register.  Since GCC doesn't preserve MPX, SSE, MMX nor x87
5545 states, the GCC option @option{-mgeneral-regs-only} should be used to
5546 compile functions with @code{no_caller_saved_registers} attribute.
5548 @item interrupt
5549 @cindex @code{interrupt} function attribute, x86
5550 Use this attribute to indicate that the specified function is an
5551 interrupt handler or an exception handler (depending on parameters passed
5552 to the function, explained further).  The compiler generates function
5553 entry and exit sequences suitable for use in an interrupt handler when
5554 this attribute is present.  The @code{IRET} instruction, instead of the
5555 @code{RET} instruction, is used to return from interrupt handlers.  All
5556 registers, except for the EFLAGS register which is restored by the
5557 @code{IRET} instruction, are preserved by the compiler.  Since GCC
5558 doesn't preserve MPX, SSE, MMX nor x87 states, the GCC option
5559 @option{-mgeneral-regs-only} should be used to compile interrupt and
5560 exception handlers.
5562 Any interruptible-without-stack-switch code must be compiled with
5563 @option{-mno-red-zone} since interrupt handlers can and will, because
5564 of the hardware design, touch the red zone.
5566 An interrupt handler must be declared with a mandatory pointer
5567 argument:
5569 @smallexample
5570 struct interrupt_frame;
5572 __attribute__ ((interrupt))
5573 void
5574 f (struct interrupt_frame *frame)
5577 @end smallexample
5579 @noindent
5580 and you must define @code{struct interrupt_frame} as described in the
5581 processor's manual.
5583 Exception handlers differ from interrupt handlers because the system
5584 pushes an error code on the stack.  An exception handler declaration is
5585 similar to that for an interrupt handler, but with a different mandatory
5586 function signature.  The compiler arranges to pop the error code off the
5587 stack before the @code{IRET} instruction.
5589 @smallexample
5590 #ifdef __x86_64__
5591 typedef unsigned long long int uword_t;
5592 #else
5593 typedef unsigned int uword_t;
5594 #endif
5596 struct interrupt_frame;
5598 __attribute__ ((interrupt))
5599 void
5600 f (struct interrupt_frame *frame, uword_t error_code)
5602   ...
5604 @end smallexample
5606 Exception handlers should only be used for exceptions that push an error
5607 code; you should use an interrupt handler in other cases.  The system
5608 will crash if the wrong kind of handler is used.
5610 @item target (@var{options})
5611 @cindex @code{target} function attribute
5612 As discussed in @ref{Common Function Attributes}, this attribute 
5613 allows specification of target-specific compilation options.
5615 On the x86, the following options are allowed:
5616 @table @samp
5617 @item abm
5618 @itemx no-abm
5619 @cindex @code{target("abm")} function attribute, x86
5620 Enable/disable the generation of the advanced bit instructions.
5622 @item aes
5623 @itemx no-aes
5624 @cindex @code{target("aes")} function attribute, x86
5625 Enable/disable the generation of the AES instructions.
5627 @item default
5628 @cindex @code{target("default")} function attribute, x86
5629 @xref{Function Multiversioning}, where it is used to specify the
5630 default function version.
5632 @item mmx
5633 @itemx no-mmx
5634 @cindex @code{target("mmx")} function attribute, x86
5635 Enable/disable the generation of the MMX instructions.
5637 @item pclmul
5638 @itemx no-pclmul
5639 @cindex @code{target("pclmul")} function attribute, x86
5640 Enable/disable the generation of the PCLMUL instructions.
5642 @item popcnt
5643 @itemx no-popcnt
5644 @cindex @code{target("popcnt")} function attribute, x86
5645 Enable/disable the generation of the POPCNT instruction.
5647 @item sse
5648 @itemx no-sse
5649 @cindex @code{target("sse")} function attribute, x86
5650 Enable/disable the generation of the SSE instructions.
5652 @item sse2
5653 @itemx no-sse2
5654 @cindex @code{target("sse2")} function attribute, x86
5655 Enable/disable the generation of the SSE2 instructions.
5657 @item sse3
5658 @itemx no-sse3
5659 @cindex @code{target("sse3")} function attribute, x86
5660 Enable/disable the generation of the SSE3 instructions.
5662 @item sse4
5663 @itemx no-sse4
5664 @cindex @code{target("sse4")} function attribute, x86
5665 Enable/disable the generation of the SSE4 instructions (both SSE4.1
5666 and SSE4.2).
5668 @item sse4.1
5669 @itemx no-sse4.1
5670 @cindex @code{target("sse4.1")} function attribute, x86
5671 Enable/disable the generation of the sse4.1 instructions.
5673 @item sse4.2
5674 @itemx no-sse4.2
5675 @cindex @code{target("sse4.2")} function attribute, x86
5676 Enable/disable the generation of the sse4.2 instructions.
5678 @item sse4a
5679 @itemx no-sse4a
5680 @cindex @code{target("sse4a")} function attribute, x86
5681 Enable/disable the generation of the SSE4A instructions.
5683 @item fma4
5684 @itemx no-fma4
5685 @cindex @code{target("fma4")} function attribute, x86
5686 Enable/disable the generation of the FMA4 instructions.
5688 @item xop
5689 @itemx no-xop
5690 @cindex @code{target("xop")} function attribute, x86
5691 Enable/disable the generation of the XOP instructions.
5693 @item lwp
5694 @itemx no-lwp
5695 @cindex @code{target("lwp")} function attribute, x86
5696 Enable/disable the generation of the LWP instructions.
5698 @item ssse3
5699 @itemx no-ssse3
5700 @cindex @code{target("ssse3")} function attribute, x86
5701 Enable/disable the generation of the SSSE3 instructions.
5703 @item cld
5704 @itemx no-cld
5705 @cindex @code{target("cld")} function attribute, x86
5706 Enable/disable the generation of the CLD before string moves.
5708 @item fancy-math-387
5709 @itemx no-fancy-math-387
5710 @cindex @code{target("fancy-math-387")} function attribute, x86
5711 Enable/disable the generation of the @code{sin}, @code{cos}, and
5712 @code{sqrt} instructions on the 387 floating-point unit.
5714 @item ieee-fp
5715 @itemx no-ieee-fp
5716 @cindex @code{target("ieee-fp")} function attribute, x86
5717 Enable/disable the generation of floating point that depends on IEEE arithmetic.
5719 @item inline-all-stringops
5720 @itemx no-inline-all-stringops
5721 @cindex @code{target("inline-all-stringops")} function attribute, x86
5722 Enable/disable inlining of string operations.
5724 @item inline-stringops-dynamically
5725 @itemx no-inline-stringops-dynamically
5726 @cindex @code{target("inline-stringops-dynamically")} function attribute, x86
5727 Enable/disable the generation of the inline code to do small string
5728 operations and calling the library routines for large operations.
5730 @item align-stringops
5731 @itemx no-align-stringops
5732 @cindex @code{target("align-stringops")} function attribute, x86
5733 Do/do not align destination of inlined string operations.
5735 @item recip
5736 @itemx no-recip
5737 @cindex @code{target("recip")} function attribute, x86
5738 Enable/disable the generation of RCPSS, RCPPS, RSQRTSS and RSQRTPS
5739 instructions followed an additional Newton-Raphson step instead of
5740 doing a floating-point division.
5742 @item arch=@var{ARCH}
5743 @cindex @code{target("arch=@var{ARCH}")} function attribute, x86
5744 Specify the architecture to generate code for in compiling the function.
5746 @item tune=@var{TUNE}
5747 @cindex @code{target("tune=@var{TUNE}")} function attribute, x86
5748 Specify the architecture to tune for in compiling the function.
5750 @item fpmath=@var{FPMATH}
5751 @cindex @code{target("fpmath=@var{FPMATH}")} function attribute, x86
5752 Specify which floating-point unit to use.  You must specify the
5753 @code{target("fpmath=sse,387")} option as
5754 @code{target("fpmath=sse+387")} because the comma would separate
5755 different options.
5757 @item indirect_branch("@var{choice}")
5758 @cindex @code{indirect_branch} function attribute, x86
5759 On x86 targets, the @code{indirect_branch} attribute causes the compiler
5760 to convert indirect call and jump with @var{choice}.  @samp{keep}
5761 keeps indirect call and jump unmodified.  @samp{thunk} converts indirect
5762 call and jump to call and return thunk.  @samp{thunk-inline} converts
5763 indirect call and jump to inlined call and return thunk.
5764 @samp{thunk-extern} converts indirect call and jump to external call
5765 and return thunk provided in a separate object file.
5767 @item function_return("@var{choice}")
5768 @cindex @code{function_return} function attribute, x86
5769 On x86 targets, the @code{function_return} attribute causes the compiler
5770 to convert function return with @var{choice}.  @samp{keep} keeps function
5771 return unmodified.  @samp{thunk} converts function return to call and
5772 return thunk.  @samp{thunk-inline} converts function return to inlined
5773 call and return thunk.  @samp{thunk-extern} converts function return to
5774 external call and return thunk provided in a separate object file.
5776 @item nocf_check
5777 @cindex @code{nocf_check} function attribute
5778 The @code{nocf_check} attribute on a function is used to inform the
5779 compiler that the function's prologue should not be instrumented when
5780 compiled with the @option{-fcf-protection=branch} option.  The
5781 compiler assumes that the function's address is a valid target for a
5782 control-flow transfer.
5784 The @code{nocf_check} attribute on a type of pointer to function is
5785 used to inform the compiler that a call through the pointer should
5786 not be instrumented when compiled with the
5787 @option{-fcf-protection=branch} option.  The compiler assumes
5788 that the function's address from the pointer is a valid target for
5789 a control-flow transfer.  A direct function call through a function
5790 name is assumed to be a safe call thus direct calls are not
5791 instrumented by the compiler.
5793 The @code{nocf_check} attribute is applied to an object's type.
5794 In case of assignment of a function address or a function pointer to
5795 another pointer, the attribute is not carried over from the right-hand
5796 object's type; the type of left-hand object stays unchanged.  The
5797 compiler checks for @code{nocf_check} attribute mismatch and reports
5798 a warning in case of mismatch.
5800 @smallexample
5802 int foo (void) __attribute__(nocf_check);
5803 void (*foo1)(void) __attribute__(nocf_check);
5804 void (*foo2)(void);
5806 /* foo's address is assumed to be valid.  */
5808 foo (void) 
5810   /* This call site is not checked for control-flow 
5811      validity.  */
5812   (*foo1)();
5814   /* A warning is issued about attribute mismatch.  */
5815   foo1 = foo2; 
5817   /* This call site is still not checked.  */
5818   (*foo1)();
5820   /* This call site is checked.  */
5821   (*foo2)();
5823   /* A warning is issued about attribute mismatch.  */
5824   foo2 = foo1; 
5826   /* This call site is still checked.  */
5827   (*foo2)();
5829   return 0;
5831 @end smallexample
5833 @end table
5835 On the x86, the inliner does not inline a
5836 function that has different target options than the caller, unless the
5837 callee has a subset of the target options of the caller.  For example
5838 a function declared with @code{target("sse3")} can inline a function
5839 with @code{target("sse2")}, since @code{-msse3} implies @code{-msse2}.
5840 @end table
5842 @node Xstormy16 Function Attributes
5843 @subsection Xstormy16 Function Attributes
5845 These function attributes are supported by the Xstormy16 back end:
5847 @table @code
5848 @item interrupt
5849 @cindex @code{interrupt} function attribute, Xstormy16
5850 Use this attribute to indicate
5851 that the specified function is an interrupt handler.  The compiler generates
5852 function entry and exit sequences suitable for use in an interrupt handler
5853 when this attribute is present.
5854 @end table
5856 @node Variable Attributes
5857 @section Specifying Attributes of Variables
5858 @cindex attribute of variables
5859 @cindex variable attributes
5861 The keyword @code{__attribute__} allows you to specify special
5862 attributes of variables or structure fields.  This keyword is followed
5863 by an attribute specification inside double parentheses.  Some
5864 attributes are currently defined generically for variables.
5865 Other attributes are defined for variables on particular target
5866 systems.  Other attributes are available for functions
5867 (@pxref{Function Attributes}), labels (@pxref{Label Attributes}),
5868 enumerators (@pxref{Enumerator Attributes}), statements
5869 (@pxref{Statement Attributes}), and for types (@pxref{Type Attributes}).
5870 Other front ends might define more attributes
5871 (@pxref{C++ Extensions,,Extensions to the C++ Language}).
5873 @xref{Attribute Syntax}, for details of the exact syntax for using
5874 attributes.
5876 @menu
5877 * Common Variable Attributes::
5878 * AVR Variable Attributes::
5879 * Blackfin Variable Attributes::
5880 * H8/300 Variable Attributes::
5881 * IA-64 Variable Attributes::
5882 * M32R/D Variable Attributes::
5883 * MeP Variable Attributes::
5884 * Microsoft Windows Variable Attributes::
5885 * MSP430 Variable Attributes::
5886 * Nvidia PTX Variable Attributes::
5887 * PowerPC Variable Attributes::
5888 * RL78 Variable Attributes::
5889 * SPU Variable Attributes::
5890 * V850 Variable Attributes::
5891 * x86 Variable Attributes::
5892 * Xstormy16 Variable Attributes::
5893 @end menu
5895 @node Common Variable Attributes
5896 @subsection Common Variable Attributes
5898 The following attributes are supported on most targets.
5900 @table @code
5901 @cindex @code{aligned} variable attribute
5902 @item aligned (@var{alignment})
5903 This attribute specifies a minimum alignment for the variable or
5904 structure field, measured in bytes.  For example, the declaration:
5906 @smallexample
5907 int x __attribute__ ((aligned (16))) = 0;
5908 @end smallexample
5910 @noindent
5911 causes the compiler to allocate the global variable @code{x} on a
5912 16-byte boundary.  On a 68040, this could be used in conjunction with
5913 an @code{asm} expression to access the @code{move16} instruction which
5914 requires 16-byte aligned operands.
5916 You can also specify the alignment of structure fields.  For example, to
5917 create a double-word aligned @code{int} pair, you could write:
5919 @smallexample
5920 struct foo @{ int x[2] __attribute__ ((aligned (8))); @};
5921 @end smallexample
5923 @noindent
5924 This is an alternative to creating a union with a @code{double} member,
5925 which forces the union to be double-word aligned.
5927 As in the preceding examples, you can explicitly specify the alignment
5928 (in bytes) that you wish the compiler to use for a given variable or
5929 structure field.  Alternatively, you can leave out the alignment factor
5930 and just ask the compiler to align a variable or field to the
5931 default alignment for the target architecture you are compiling for.
5932 The default alignment is sufficient for all scalar types, but may not be
5933 enough for all vector types on a target that supports vector operations.
5934 The default alignment is fixed for a particular target ABI.
5936 GCC also provides a target specific macro @code{__BIGGEST_ALIGNMENT__},
5937 which is the largest alignment ever used for any data type on the
5938 target machine you are compiling for.  For example, you could write:
5940 @smallexample
5941 short array[3] __attribute__ ((aligned (__BIGGEST_ALIGNMENT__)));
5942 @end smallexample
5944 The compiler automatically sets the alignment for the declared
5945 variable or field to @code{__BIGGEST_ALIGNMENT__}.  Doing this can
5946 often make copy operations more efficient, because the compiler can
5947 use whatever instructions copy the biggest chunks of memory when
5948 performing copies to or from the variables or fields that you have
5949 aligned this way.  Note that the value of @code{__BIGGEST_ALIGNMENT__}
5950 may change depending on command-line options.
5952 When used on a struct, or struct member, the @code{aligned} attribute can
5953 only increase the alignment; in order to decrease it, the @code{packed}
5954 attribute must be specified as well.  When used as part of a typedef, the
5955 @code{aligned} attribute can both increase and decrease alignment, and
5956 specifying the @code{packed} attribute generates a warning.
5958 Note that the effectiveness of @code{aligned} attributes may be limited
5959 by inherent limitations in your linker.  On many systems, the linker is
5960 only able to arrange for variables to be aligned up to a certain maximum
5961 alignment.  (For some linkers, the maximum supported alignment may
5962 be very very small.)  If your linker is only able to align variables
5963 up to a maximum of 8-byte alignment, then specifying @code{aligned(16)}
5964 in an @code{__attribute__} still only provides you with 8-byte
5965 alignment.  See your linker documentation for further information.
5967 The @code{aligned} attribute can also be used for functions
5968 (@pxref{Common Function Attributes}.)
5970 @cindex @code{warn_if_not_aligned} variable attribute
5971 @item warn_if_not_aligned (@var{alignment})
5972 This attribute specifies a threshold for the structure field, measured
5973 in bytes.  If the structure field is aligned below the threshold, a
5974 warning will be issued.  For example, the declaration:
5976 @smallexample
5977 struct foo
5979   int i1;
5980   int i2;
5981   unsigned long long x __attribute__((warn_if_not_aligned(16)));
5983 @end smallexample
5985 @noindent
5986 causes the compiler to issue an warning on @code{struct foo}, like
5987 @samp{warning: alignment 8 of 'struct foo' is less than 16}.
5988 The compiler also issues a warning, like @samp{warning: 'x' offset
5989 8 in 'struct foo' isn't aligned to 16}, when the structure field has
5990 the misaligned offset:
5992 @smallexample
5993 struct foo
5995   int i1;
5996   int i2;
5997   unsigned long long x __attribute__((warn_if_not_aligned(16)));
5998 @} __attribute__((aligned(16)));
5999 @end smallexample
6001 This warning can be disabled by @option{-Wno-if-not-aligned}.
6002 The @code{warn_if_not_aligned} attribute can also be used for types
6003 (@pxref{Common Type Attributes}.)
6005 @item cleanup (@var{cleanup_function})
6006 @cindex @code{cleanup} variable attribute
6007 The @code{cleanup} attribute runs a function when the variable goes
6008 out of scope.  This attribute can only be applied to auto function
6009 scope variables; it may not be applied to parameters or variables
6010 with static storage duration.  The function must take one parameter,
6011 a pointer to a type compatible with the variable.  The return value
6012 of the function (if any) is ignored.
6014 If @option{-fexceptions} is enabled, then @var{cleanup_function}
6015 is run during the stack unwinding that happens during the
6016 processing of the exception.  Note that the @code{cleanup} attribute
6017 does not allow the exception to be caught, only to perform an action.
6018 It is undefined what happens if @var{cleanup_function} does not
6019 return normally.
6021 @item common
6022 @itemx nocommon
6023 @cindex @code{common} variable attribute
6024 @cindex @code{nocommon} variable attribute
6025 @opindex fcommon
6026 @opindex fno-common
6027 The @code{common} attribute requests GCC to place a variable in
6028 ``common'' storage.  The @code{nocommon} attribute requests the
6029 opposite---to allocate space for it directly.
6031 These attributes override the default chosen by the
6032 @option{-fno-common} and @option{-fcommon} flags respectively.
6034 @item deprecated
6035 @itemx deprecated (@var{msg})
6036 @cindex @code{deprecated} variable attribute
6037 The @code{deprecated} attribute results in a warning if the variable
6038 is used anywhere in the source file.  This is useful when identifying
6039 variables that are expected to be removed in a future version of a
6040 program.  The warning also includes the location of the declaration
6041 of the deprecated variable, to enable users to easily find further
6042 information about why the variable is deprecated, or what they should
6043 do instead.  Note that the warning only occurs for uses:
6045 @smallexample
6046 extern int old_var __attribute__ ((deprecated));
6047 extern int old_var;
6048 int new_fn () @{ return old_var; @}
6049 @end smallexample
6051 @noindent
6052 results in a warning on line 3 but not line 2.  The optional @var{msg}
6053 argument, which must be a string, is printed in the warning if
6054 present.
6056 The @code{deprecated} attribute can also be used for functions and
6057 types (@pxref{Common Function Attributes},
6058 @pxref{Common Type Attributes}).
6060 @item nonstring
6061 @cindex @code{nonstring} variable attribute
6062 The @code{nonstring} variable attribute specifies that an object or member
6063 declaration with type array of @code{char} or pointer to @code{char} is
6064 intended to store character arrays that do not necessarily contain
6065 a terminating @code{NUL} character.  This is useful in detecting uses
6066 of such arrays or pointers with functions that expect NUL-terminated
6067 strings, and to avoid warnings when such an array or pointer is used
6068 as an argument to a bounded string manipulation function such as
6069 @code{strncpy}.  For example, without the attribute, GCC will issue
6070 a warning for the @code{strncpy} call below because it may truncate
6071 the copy without appending the terminating @code{NUL} character.  Using
6072 the attribute makes it possible to suppress the warning.  However, when
6073 the array is declared with the attribute the call to @code{strlen} is
6074 diagnosed because when the array doesn't contain a @code{NUL}-terminated
6075 string the call is undefined.  To copy, compare, of search non-string
6076 character arrays use the @code{memcpy}, @code{memcmp}, @code{memchr},
6077 and other functions that operate on arrays of bytes.  In addition,
6078 calling @code{strnlen} and @code{strndup} with such arrays is safe
6079 provided a suitable bound is specified, and not diagnosed.
6081 @smallexample
6082 struct Data
6084   char name [32] __attribute__ ((nonstring));
6087 int f (struct Data *pd, const char *s)
6089   strncpy (pd->name, s, sizeof pd->name);
6090   @dots{}
6091   return strlen (pd->name);   // unsafe, gets a warning
6093 @end smallexample
6095 @item mode (@var{mode})
6096 @cindex @code{mode} variable attribute
6097 This attribute specifies the data type for the declaration---whichever
6098 type corresponds to the mode @var{mode}.  This in effect lets you
6099 request an integer or floating-point type according to its width.
6101 @xref{Machine Modes,,, gccint, GNU Compiler Collection (GCC) Internals},
6102 for a list of the possible keywords for @var{mode}.
6103 You may also specify a mode of @code{byte} or @code{__byte__} to
6104 indicate the mode corresponding to a one-byte integer, @code{word} or
6105 @code{__word__} for the mode of a one-word integer, and @code{pointer}
6106 or @code{__pointer__} for the mode used to represent pointers.
6108 @item packed
6109 @cindex @code{packed} variable attribute
6110 The @code{packed} attribute specifies that a variable or structure field
6111 should have the smallest possible alignment---one byte for a variable,
6112 and one bit for a field, unless you specify a larger value with the
6113 @code{aligned} attribute.
6115 Here is a structure in which the field @code{x} is packed, so that it
6116 immediately follows @code{a}:
6118 @smallexample
6119 struct foo
6121   char a;
6122   int x[2] __attribute__ ((packed));
6124 @end smallexample
6126 @emph{Note:} The 4.1, 4.2 and 4.3 series of GCC ignore the
6127 @code{packed} attribute on bit-fields of type @code{char}.  This has
6128 been fixed in GCC 4.4 but the change can lead to differences in the
6129 structure layout.  See the documentation of
6130 @option{-Wpacked-bitfield-compat} for more information.
6132 @item section ("@var{section-name}")
6133 @cindex @code{section} variable attribute
6134 Normally, the compiler places the objects it generates in sections like
6135 @code{data} and @code{bss}.  Sometimes, however, you need additional sections,
6136 or you need certain particular variables to appear in special sections,
6137 for example to map to special hardware.  The @code{section}
6138 attribute specifies that a variable (or function) lives in a particular
6139 section.  For example, this small program uses several specific section names:
6141 @smallexample
6142 struct duart a __attribute__ ((section ("DUART_A"))) = @{ 0 @};
6143 struct duart b __attribute__ ((section ("DUART_B"))) = @{ 0 @};
6144 char stack[10000] __attribute__ ((section ("STACK"))) = @{ 0 @};
6145 int init_data __attribute__ ((section ("INITDATA")));
6147 main()
6149   /* @r{Initialize stack pointer} */
6150   init_sp (stack + sizeof (stack));
6152   /* @r{Initialize initialized data} */
6153   memcpy (&init_data, &data, &edata - &data);
6155   /* @r{Turn on the serial ports} */
6156   init_duart (&a);
6157   init_duart (&b);
6159 @end smallexample
6161 @noindent
6162 Use the @code{section} attribute with
6163 @emph{global} variables and not @emph{local} variables,
6164 as shown in the example.
6166 You may use the @code{section} attribute with initialized or
6167 uninitialized global variables but the linker requires
6168 each object be defined once, with the exception that uninitialized
6169 variables tentatively go in the @code{common} (or @code{bss}) section
6170 and can be multiply ``defined''.  Using the @code{section} attribute
6171 changes what section the variable goes into and may cause the
6172 linker to issue an error if an uninitialized variable has multiple
6173 definitions.  You can force a variable to be initialized with the
6174 @option{-fno-common} flag or the @code{nocommon} attribute.
6176 Some file formats do not support arbitrary sections so the @code{section}
6177 attribute is not available on all platforms.
6178 If you need to map the entire contents of a module to a particular
6179 section, consider using the facilities of the linker instead.
6181 @item tls_model ("@var{tls_model}")
6182 @cindex @code{tls_model} variable attribute
6183 The @code{tls_model} attribute sets thread-local storage model
6184 (@pxref{Thread-Local}) of a particular @code{__thread} variable,
6185 overriding @option{-ftls-model=} command-line switch on a per-variable
6186 basis.
6187 The @var{tls_model} argument should be one of @code{global-dynamic},
6188 @code{local-dynamic}, @code{initial-exec} or @code{local-exec}.
6190 Not all targets support this attribute.
6192 @item unused
6193 @cindex @code{unused} variable attribute
6194 This attribute, attached to a variable, means that the variable is meant
6195 to be possibly unused.  GCC does not produce a warning for this
6196 variable.
6198 @item used
6199 @cindex @code{used} variable attribute
6200 This attribute, attached to a variable with static storage, means that
6201 the variable must be emitted even if it appears that the variable is not
6202 referenced.
6204 When applied to a static data member of a C++ class template, the
6205 attribute also means that the member is instantiated if the
6206 class itself is instantiated.
6208 @item vector_size (@var{bytes})
6209 @cindex @code{vector_size} variable attribute
6210 This attribute specifies the vector size for the variable, measured in
6211 bytes.  For example, the declaration:
6213 @smallexample
6214 int foo __attribute__ ((vector_size (16)));
6215 @end smallexample
6217 @noindent
6218 causes the compiler to set the mode for @code{foo}, to be 16 bytes,
6219 divided into @code{int} sized units.  Assuming a 32-bit int (a vector of
6220 4 units of 4 bytes), the corresponding mode of @code{foo} is V4SI@.
6222 This attribute is only applicable to integral and float scalars,
6223 although arrays, pointers, and function return values are allowed in
6224 conjunction with this construct.
6226 Aggregates with this attribute are invalid, even if they are of the same
6227 size as a corresponding scalar.  For example, the declaration:
6229 @smallexample
6230 struct S @{ int a; @};
6231 struct S  __attribute__ ((vector_size (16))) foo;
6232 @end smallexample
6234 @noindent
6235 is invalid even if the size of the structure is the same as the size of
6236 the @code{int}.
6238 @item visibility ("@var{visibility_type}")
6239 @cindex @code{visibility} variable attribute
6240 This attribute affects the linkage of the declaration to which it is attached.
6241 The @code{visibility} attribute is described in
6242 @ref{Common Function Attributes}.
6244 @item weak
6245 @cindex @code{weak} variable attribute
6246 The @code{weak} attribute is described in
6247 @ref{Common Function Attributes}.
6249 @end table
6251 @node AVR Variable Attributes
6252 @subsection AVR Variable Attributes
6254 @table @code
6255 @item progmem
6256 @cindex @code{progmem} variable attribute, AVR
6257 The @code{progmem} attribute is used on the AVR to place read-only
6258 data in the non-volatile program memory (flash). The @code{progmem}
6259 attribute accomplishes this by putting respective variables into a
6260 section whose name starts with @code{.progmem}.
6262 This attribute works similar to the @code{section} attribute
6263 but adds additional checking.
6265 @table @asis
6266 @item @bullet{}@tie{} Ordinary AVR cores with 32 general purpose registers:
6267 @code{progmem} affects the location
6268 of the data but not how this data is accessed.
6269 In order to read data located with the @code{progmem} attribute
6270 (inline) assembler must be used.
6271 @smallexample
6272 /* Use custom macros from @w{@uref{http://nongnu.org/avr-libc/user-manual/,AVR-LibC}} */
6273 #include <avr/pgmspace.h> 
6275 /* Locate var in flash memory */
6276 const int var[2] PROGMEM = @{ 1, 2 @};
6278 int read_var (int i)
6280     /* Access var[] by accessor macro from avr/pgmspace.h */
6281     return (int) pgm_read_word (& var[i]);
6283 @end smallexample
6285 AVR is a Harvard architecture processor and data and read-only data
6286 normally resides in the data memory (RAM).
6288 See also the @ref{AVR Named Address Spaces} section for
6289 an alternate way to locate and access data in flash memory.
6291 @item @bullet{}@tie{} AVR cores with flash memory visible in the RAM address range:
6292 On such devices, there is no need for attribute @code{progmem} or
6293 @ref{AVR Named Address Spaces,,@code{__flash}} qualifier at all.
6294 Just use standard C / C++.  The compiler will generate @code{LD*}
6295 instructions.  As flash memory is visible in the RAM address range,
6296 and the default linker script does @emph{not} locate @code{.rodata} in
6297 RAM, no special features are needed in order not to waste RAM for
6298 read-only data or to read from flash.  You might even get slightly better
6299 performance by
6300 avoiding @code{progmem} and @code{__flash}.  This applies to devices from
6301 families @code{avrtiny} and @code{avrxmega3}, see @ref{AVR Options} for
6302 an overview.
6304 @item @bullet{}@tie{}Reduced AVR Tiny cores like ATtiny40:
6305 The compiler adds @code{0x4000}
6306 to the addresses of objects and declarations in @code{progmem} and locates
6307 the objects in flash memory, namely in section @code{.progmem.data}.
6308 The offset is needed because the flash memory is visible in the RAM
6309 address space starting at address @code{0x4000}.
6311 Data in @code{progmem} can be accessed by means of ordinary C@tie{}code,
6312 no special functions or macros are needed.
6314 @smallexample
6315 /* var is located in flash memory */
6316 extern const int var[2] __attribute__((progmem));
6318 int read_var (int i)
6320     return var[i];
6322 @end smallexample
6324 Please notice that on these devices, there is no need for @code{progmem}
6325 at all.
6327 @end table
6329 @item io
6330 @itemx io (@var{addr})
6331 @cindex @code{io} variable attribute, AVR
6332 Variables with the @code{io} attribute are used to address
6333 memory-mapped peripherals in the io address range.
6334 If an address is specified, the variable
6335 is assigned that address, and the value is interpreted as an
6336 address in the data address space.
6337 Example:
6339 @smallexample
6340 volatile int porta __attribute__((io (0x22)));
6341 @end smallexample
6343 The address specified in the address in the data address range.
6345 Otherwise, the variable it is not assigned an address, but the
6346 compiler will still use in/out instructions where applicable,
6347 assuming some other module assigns an address in the io address range.
6348 Example:
6350 @smallexample
6351 extern volatile int porta __attribute__((io));
6352 @end smallexample
6354 @item io_low
6355 @itemx io_low (@var{addr})
6356 @cindex @code{io_low} variable attribute, AVR
6357 This is like the @code{io} attribute, but additionally it informs the
6358 compiler that the object lies in the lower half of the I/O area,
6359 allowing the use of @code{cbi}, @code{sbi}, @code{sbic} and @code{sbis}
6360 instructions.
6362 @item address
6363 @itemx address (@var{addr})
6364 @cindex @code{address} variable attribute, AVR
6365 Variables with the @code{address} attribute are used to address
6366 memory-mapped peripherals that may lie outside the io address range.
6368 @smallexample
6369 volatile int porta __attribute__((address (0x600)));
6370 @end smallexample
6372 @item absdata
6373 @cindex @code{absdata} variable attribute, AVR
6374 Variables in static storage and with the @code{absdata} attribute can
6375 be accessed by the @code{LDS} and @code{STS} instructions which take
6376 absolute addresses.
6378 @itemize @bullet
6379 @item
6380 This attribute is only supported for the reduced AVR Tiny core
6381 like ATtiny40.
6383 @item
6384 You must make sure that respective data is located in the
6385 address range @code{0x40}@dots{}@code{0xbf} accessible by
6386 @code{LDS} and @code{STS}.  One way to achieve this as an
6387 appropriate linker description file.
6389 @item
6390 If the location does not fit the address range of @code{LDS}
6391 and @code{STS}, there is currently (Binutils 2.26) just an unspecific
6392 warning like
6393 @quotation
6394 @code{module.c:(.text+0x1c): warning: internal error: out of range error}
6395 @end quotation
6397 @end itemize
6399 See also the @option{-mabsdata} @ref{AVR Options,command-line option}.
6401 @end table
6403 @node Blackfin Variable Attributes
6404 @subsection Blackfin Variable Attributes
6406 Three attributes are currently defined for the Blackfin.
6408 @table @code
6409 @item l1_data
6410 @itemx l1_data_A
6411 @itemx l1_data_B
6412 @cindex @code{l1_data} variable attribute, Blackfin
6413 @cindex @code{l1_data_A} variable attribute, Blackfin
6414 @cindex @code{l1_data_B} variable attribute, Blackfin
6415 Use these attributes on the Blackfin to place the variable into L1 Data SRAM.
6416 Variables with @code{l1_data} attribute are put into the specific section
6417 named @code{.l1.data}. Those with @code{l1_data_A} attribute are put into
6418 the specific section named @code{.l1.data.A}. Those with @code{l1_data_B}
6419 attribute are put into the specific section named @code{.l1.data.B}.
6421 @item l2
6422 @cindex @code{l2} variable attribute, Blackfin
6423 Use this attribute on the Blackfin to place the variable into L2 SRAM.
6424 Variables with @code{l2} attribute are put into the specific section
6425 named @code{.l2.data}.
6426 @end table
6428 @node H8/300 Variable Attributes
6429 @subsection H8/300 Variable Attributes
6431 These variable attributes are available for H8/300 targets:
6433 @table @code
6434 @item eightbit_data
6435 @cindex @code{eightbit_data} variable attribute, H8/300
6436 @cindex eight-bit data on the H8/300, H8/300H, and H8S
6437 Use this attribute on the H8/300, H8/300H, and H8S to indicate that the specified
6438 variable should be placed into the eight-bit data section.
6439 The compiler generates more efficient code for certain operations
6440 on data in the eight-bit data area.  Note the eight-bit data area is limited to
6441 256 bytes of data.
6443 You must use GAS and GLD from GNU binutils version 2.7 or later for
6444 this attribute to work correctly.
6446 @item tiny_data
6447 @cindex @code{tiny_data} variable attribute, H8/300
6448 @cindex tiny data section on the H8/300H and H8S
6449 Use this attribute on the H8/300H and H8S to indicate that the specified
6450 variable should be placed into the tiny data section.
6451 The compiler generates more efficient code for loads and stores
6452 on data in the tiny data section.  Note the tiny data area is limited to
6453 slightly under 32KB of data.
6455 @end table
6457 @node IA-64 Variable Attributes
6458 @subsection IA-64 Variable Attributes
6460 The IA-64 back end supports the following variable attribute:
6462 @table @code
6463 @item model (@var{model-name})
6464 @cindex @code{model} variable attribute, IA-64
6466 On IA-64, use this attribute to set the addressability of an object.
6467 At present, the only supported identifier for @var{model-name} is
6468 @code{small}, indicating addressability via ``small'' (22-bit)
6469 addresses (so that their addresses can be loaded with the @code{addl}
6470 instruction).  Caveat: such addressing is by definition not position
6471 independent and hence this attribute must not be used for objects
6472 defined by shared libraries.
6474 @end table
6476 @node M32R/D Variable Attributes
6477 @subsection M32R/D Variable Attributes
6479 One attribute is currently defined for the M32R/D@.
6481 @table @code
6482 @item model (@var{model-name})
6483 @cindex @code{model-name} variable attribute, M32R/D
6484 @cindex variable addressability on the M32R/D
6485 Use this attribute on the M32R/D to set the addressability of an object.
6486 The identifier @var{model-name} is one of @code{small}, @code{medium},
6487 or @code{large}, representing each of the code models.
6489 Small model objects live in the lower 16MB of memory (so that their
6490 addresses can be loaded with the @code{ld24} instruction).
6492 Medium and large model objects may live anywhere in the 32-bit address space
6493 (the compiler generates @code{seth/add3} instructions to load their
6494 addresses).
6495 @end table
6497 @node MeP Variable Attributes
6498 @subsection MeP Variable Attributes
6500 The MeP target has a number of addressing modes and busses.  The
6501 @code{near} space spans the standard memory space's first 16 megabytes
6502 (24 bits).  The @code{far} space spans the entire 32-bit memory space.
6503 The @code{based} space is a 128-byte region in the memory space that
6504 is addressed relative to the @code{$tp} register.  The @code{tiny}
6505 space is a 65536-byte region relative to the @code{$gp} register.  In
6506 addition to these memory regions, the MeP target has a separate 16-bit
6507 control bus which is specified with @code{cb} attributes.
6509 @table @code
6511 @item based
6512 @cindex @code{based} variable attribute, MeP
6513 Any variable with the @code{based} attribute is assigned to the
6514 @code{.based} section, and is accessed with relative to the
6515 @code{$tp} register.
6517 @item tiny
6518 @cindex @code{tiny} variable attribute, MeP
6519 Likewise, the @code{tiny} attribute assigned variables to the
6520 @code{.tiny} section, relative to the @code{$gp} register.
6522 @item near
6523 @cindex @code{near} variable attribute, MeP
6524 Variables with the @code{near} attribute are assumed to have addresses
6525 that fit in a 24-bit addressing mode.  This is the default for large
6526 variables (@code{-mtiny=4} is the default) but this attribute can
6527 override @code{-mtiny=} for small variables, or override @code{-ml}.
6529 @item far
6530 @cindex @code{far} variable attribute, MeP
6531 Variables with the @code{far} attribute are addressed using a full
6532 32-bit address.  Since this covers the entire memory space, this
6533 allows modules to make no assumptions about where variables might be
6534 stored.
6536 @item io
6537 @cindex @code{io} variable attribute, MeP
6538 @itemx io (@var{addr})
6539 Variables with the @code{io} attribute are used to address
6540 memory-mapped peripherals.  If an address is specified, the variable
6541 is assigned that address, else it is not assigned an address (it is
6542 assumed some other module assigns an address).  Example:
6544 @smallexample
6545 int timer_count __attribute__((io(0x123)));
6546 @end smallexample
6548 @item cb
6549 @itemx cb (@var{addr})
6550 @cindex @code{cb} variable attribute, MeP
6551 Variables with the @code{cb} attribute are used to access the control
6552 bus, using special instructions.  @code{addr} indicates the control bus
6553 address.  Example:
6555 @smallexample
6556 int cpu_clock __attribute__((cb(0x123)));
6557 @end smallexample
6559 @end table
6561 @node Microsoft Windows Variable Attributes
6562 @subsection Microsoft Windows Variable Attributes
6564 You can use these attributes on Microsoft Windows targets.
6565 @ref{x86 Variable Attributes} for additional Windows compatibility
6566 attributes available on all x86 targets.
6568 @table @code
6569 @item dllimport
6570 @itemx dllexport
6571 @cindex @code{dllimport} variable attribute
6572 @cindex @code{dllexport} variable attribute
6573 The @code{dllimport} and @code{dllexport} attributes are described in
6574 @ref{Microsoft Windows Function Attributes}.
6576 @item selectany
6577 @cindex @code{selectany} variable attribute
6578 The @code{selectany} attribute causes an initialized global variable to
6579 have link-once semantics.  When multiple definitions of the variable are
6580 encountered by the linker, the first is selected and the remainder are
6581 discarded.  Following usage by the Microsoft compiler, the linker is told
6582 @emph{not} to warn about size or content differences of the multiple
6583 definitions.
6585 Although the primary usage of this attribute is for POD types, the
6586 attribute can also be applied to global C++ objects that are initialized
6587 by a constructor.  In this case, the static initialization and destruction
6588 code for the object is emitted in each translation defining the object,
6589 but the calls to the constructor and destructor are protected by a
6590 link-once guard variable.
6592 The @code{selectany} attribute is only available on Microsoft Windows
6593 targets.  You can use @code{__declspec (selectany)} as a synonym for
6594 @code{__attribute__ ((selectany))} for compatibility with other
6595 compilers.
6597 @item shared
6598 @cindex @code{shared} variable attribute
6599 On Microsoft Windows, in addition to putting variable definitions in a named
6600 section, the section can also be shared among all running copies of an
6601 executable or DLL@.  For example, this small program defines shared data
6602 by putting it in a named section @code{shared} and marking the section
6603 shareable:
6605 @smallexample
6606 int foo __attribute__((section ("shared"), shared)) = 0;
6609 main()
6611   /* @r{Read and write foo.  All running
6612      copies see the same value.}  */
6613   return 0;
6615 @end smallexample
6617 @noindent
6618 You may only use the @code{shared} attribute along with @code{section}
6619 attribute with a fully-initialized global definition because of the way
6620 linkers work.  See @code{section} attribute for more information.
6622 The @code{shared} attribute is only available on Microsoft Windows@.
6624 @end table
6626 @node MSP430 Variable Attributes
6627 @subsection MSP430 Variable Attributes
6629 @table @code
6630 @item noinit
6631 @cindex @code{noinit} variable attribute, MSP430 
6632 Any data with the @code{noinit} attribute will not be initialised by
6633 the C runtime startup code, or the program loader.  Not initialising
6634 data in this way can reduce program startup times.
6636 @item persistent
6637 @cindex @code{persistent} variable attribute, MSP430 
6638 Any variable with the @code{persistent} attribute will not be
6639 initialised by the C runtime startup code.  Instead its value will be
6640 set once, when the application is loaded, and then never initialised
6641 again, even if the processor is reset or the program restarts.
6642 Persistent data is intended to be placed into FLASH RAM, where its
6643 value will be retained across resets.  The linker script being used to
6644 create the application should ensure that persistent data is correctly
6645 placed.
6647 @item lower
6648 @itemx upper
6649 @itemx either
6650 @cindex @code{lower} variable attribute, MSP430 
6651 @cindex @code{upper} variable attribute, MSP430 
6652 @cindex @code{either} variable attribute, MSP430 
6653 These attributes are the same as the MSP430 function attributes of the
6654 same name (@pxref{MSP430 Function Attributes}).  
6655 These attributes can be applied to both functions and variables.
6656 @end table
6658 @node Nvidia PTX Variable Attributes
6659 @subsection Nvidia PTX Variable Attributes
6661 These variable attributes are supported by the Nvidia PTX back end:
6663 @table @code
6664 @item shared
6665 @cindex @code{shared} attribute, Nvidia PTX
6666 Use this attribute to place a variable in the @code{.shared} memory space.
6667 This memory space is private to each cooperative thread array; only threads
6668 within one thread block refer to the same instance of the variable.
6669 The runtime does not initialize variables in this memory space.
6670 @end table
6672 @node PowerPC Variable Attributes
6673 @subsection PowerPC Variable Attributes
6675 Three attributes currently are defined for PowerPC configurations:
6676 @code{altivec}, @code{ms_struct} and @code{gcc_struct}.
6678 @cindex @code{ms_struct} variable attribute, PowerPC
6679 @cindex @code{gcc_struct} variable attribute, PowerPC
6680 For full documentation of the struct attributes please see the
6681 documentation in @ref{x86 Variable Attributes}.
6683 @cindex @code{altivec} variable attribute, PowerPC
6684 For documentation of @code{altivec} attribute please see the
6685 documentation in @ref{PowerPC Type Attributes}.
6687 @node RL78 Variable Attributes
6688 @subsection RL78 Variable Attributes
6690 @cindex @code{saddr} variable attribute, RL78
6691 The RL78 back end supports the @code{saddr} variable attribute.  This
6692 specifies placement of the corresponding variable in the SADDR area,
6693 which can be accessed more efficiently than the default memory region.
6695 @node SPU Variable Attributes
6696 @subsection SPU Variable Attributes
6698 @cindex @code{spu_vector} variable attribute, SPU
6699 The SPU supports the @code{spu_vector} attribute for variables.  For
6700 documentation of this attribute please see the documentation in
6701 @ref{SPU Type Attributes}.
6703 @node V850 Variable Attributes
6704 @subsection V850 Variable Attributes
6706 These variable attributes are supported by the V850 back end:
6708 @table @code
6710 @item sda
6711 @cindex @code{sda} variable attribute, V850
6712 Use this attribute to explicitly place a variable in the small data area,
6713 which can hold up to 64 kilobytes.
6715 @item tda
6716 @cindex @code{tda} variable attribute, V850
6717 Use this attribute to explicitly place a variable in the tiny data area,
6718 which can hold up to 256 bytes in total.
6720 @item zda
6721 @cindex @code{zda} variable attribute, V850
6722 Use this attribute to explicitly place a variable in the first 32 kilobytes
6723 of memory.
6724 @end table
6726 @node x86 Variable Attributes
6727 @subsection x86 Variable Attributes
6729 Two attributes are currently defined for x86 configurations:
6730 @code{ms_struct} and @code{gcc_struct}.
6732 @table @code
6733 @item ms_struct
6734 @itemx gcc_struct
6735 @cindex @code{ms_struct} variable attribute, x86
6736 @cindex @code{gcc_struct} variable attribute, x86
6738 If @code{packed} is used on a structure, or if bit-fields are used,
6739 it may be that the Microsoft ABI lays out the structure differently
6740 than the way GCC normally does.  Particularly when moving packed
6741 data between functions compiled with GCC and the native Microsoft compiler
6742 (either via function call or as data in a file), it may be necessary to access
6743 either format.
6745 The @code{ms_struct} and @code{gcc_struct} attributes correspond
6746 to the @option{-mms-bitfields} and @option{-mno-ms-bitfields}
6747 command-line options, respectively;
6748 see @ref{x86 Options}, for details of how structure layout is affected.
6749 @xref{x86 Type Attributes}, for information about the corresponding
6750 attributes on types.
6752 @end table
6754 @node Xstormy16 Variable Attributes
6755 @subsection Xstormy16 Variable Attributes
6757 One attribute is currently defined for xstormy16 configurations:
6758 @code{below100}.
6760 @table @code
6761 @item below100
6762 @cindex @code{below100} variable attribute, Xstormy16
6764 If a variable has the @code{below100} attribute (@code{BELOW100} is
6765 allowed also), GCC places the variable in the first 0x100 bytes of
6766 memory and use special opcodes to access it.  Such variables are
6767 placed in either the @code{.bss_below100} section or the
6768 @code{.data_below100} section.
6770 @end table
6772 @node Type Attributes
6773 @section Specifying Attributes of Types
6774 @cindex attribute of types
6775 @cindex type attributes
6777 The keyword @code{__attribute__} allows you to specify special
6778 attributes of types.  Some type attributes apply only to @code{struct}
6779 and @code{union} types, while others can apply to any type defined
6780 via a @code{typedef} declaration.  Other attributes are defined for
6781 functions (@pxref{Function Attributes}), labels (@pxref{Label 
6782 Attributes}), enumerators (@pxref{Enumerator Attributes}), 
6783 statements (@pxref{Statement Attributes}), and for
6784 variables (@pxref{Variable Attributes}).
6786 The @code{__attribute__} keyword is followed by an attribute specification
6787 inside double parentheses.  
6789 You may specify type attributes in an enum, struct or union type
6790 declaration or definition by placing them immediately after the
6791 @code{struct}, @code{union} or @code{enum} keyword.  A less preferred
6792 syntax is to place them just past the closing curly brace of the
6793 definition.
6795 You can also include type attributes in a @code{typedef} declaration.
6796 @xref{Attribute Syntax}, for details of the exact syntax for using
6797 attributes.
6799 @menu
6800 * Common Type Attributes::
6801 * ARM Type Attributes::
6802 * MeP Type Attributes::
6803 * PowerPC Type Attributes::
6804 * SPU Type Attributes::
6805 * x86 Type Attributes::
6806 @end menu
6808 @node Common Type Attributes
6809 @subsection Common Type Attributes
6811 The following type attributes are supported on most targets.
6813 @table @code
6814 @cindex @code{aligned} type attribute
6815 @item aligned (@var{alignment})
6816 This attribute specifies a minimum alignment (in bytes) for variables
6817 of the specified type.  For example, the declarations:
6819 @smallexample
6820 struct S @{ short f[3]; @} __attribute__ ((aligned (8)));
6821 typedef int more_aligned_int __attribute__ ((aligned (8)));
6822 @end smallexample
6824 @noindent
6825 force the compiler to ensure (as far as it can) that each variable whose
6826 type is @code{struct S} or @code{more_aligned_int} is allocated and
6827 aligned @emph{at least} on a 8-byte boundary.  On a SPARC, having all
6828 variables of type @code{struct S} aligned to 8-byte boundaries allows
6829 the compiler to use the @code{ldd} and @code{std} (doubleword load and
6830 store) instructions when copying one variable of type @code{struct S} to
6831 another, thus improving run-time efficiency.
6833 Note that the alignment of any given @code{struct} or @code{union} type
6834 is required by the ISO C standard to be at least a perfect multiple of
6835 the lowest common multiple of the alignments of all of the members of
6836 the @code{struct} or @code{union} in question.  This means that you @emph{can}
6837 effectively adjust the alignment of a @code{struct} or @code{union}
6838 type by attaching an @code{aligned} attribute to any one of the members
6839 of such a type, but the notation illustrated in the example above is a
6840 more obvious, intuitive, and readable way to request the compiler to
6841 adjust the alignment of an entire @code{struct} or @code{union} type.
6843 As in the preceding example, you can explicitly specify the alignment
6844 (in bytes) that you wish the compiler to use for a given @code{struct}
6845 or @code{union} type.  Alternatively, you can leave out the alignment factor
6846 and just ask the compiler to align a type to the maximum
6847 useful alignment for the target machine you are compiling for.  For
6848 example, you could write:
6850 @smallexample
6851 struct S @{ short f[3]; @} __attribute__ ((aligned));
6852 @end smallexample
6854 Whenever you leave out the alignment factor in an @code{aligned}
6855 attribute specification, the compiler automatically sets the alignment
6856 for the type to the largest alignment that is ever used for any data
6857 type on the target machine you are compiling for.  Doing this can often
6858 make copy operations more efficient, because the compiler can use
6859 whatever instructions copy the biggest chunks of memory when performing
6860 copies to or from the variables that have types that you have aligned
6861 this way.
6863 In the example above, if the size of each @code{short} is 2 bytes, then
6864 the size of the entire @code{struct S} type is 6 bytes.  The smallest
6865 power of two that is greater than or equal to that is 8, so the
6866 compiler sets the alignment for the entire @code{struct S} type to 8
6867 bytes.
6869 Note that although you can ask the compiler to select a time-efficient
6870 alignment for a given type and then declare only individual stand-alone
6871 objects of that type, the compiler's ability to select a time-efficient
6872 alignment is primarily useful only when you plan to create arrays of
6873 variables having the relevant (efficiently aligned) type.  If you
6874 declare or use arrays of variables of an efficiently-aligned type, then
6875 it is likely that your program also does pointer arithmetic (or
6876 subscripting, which amounts to the same thing) on pointers to the
6877 relevant type, and the code that the compiler generates for these
6878 pointer arithmetic operations is often more efficient for
6879 efficiently-aligned types than for other types.
6881 Note that the effectiveness of @code{aligned} attributes may be limited
6882 by inherent limitations in your linker.  On many systems, the linker is
6883 only able to arrange for variables to be aligned up to a certain maximum
6884 alignment.  (For some linkers, the maximum supported alignment may
6885 be very very small.)  If your linker is only able to align variables
6886 up to a maximum of 8-byte alignment, then specifying @code{aligned(16)}
6887 in an @code{__attribute__} still only provides you with 8-byte
6888 alignment.  See your linker documentation for further information.
6890 The @code{aligned} attribute can only increase alignment.  Alignment
6891 can be decreased by specifying the @code{packed} attribute.  See below.
6893 @cindex @code{warn_if_not_aligned} type attribute
6894 @item warn_if_not_aligned (@var{alignment})
6895 This attribute specifies a threshold for the structure field, measured
6896 in bytes.  If the structure field is aligned below the threshold, a
6897 warning will be issued.  For example, the declaration:
6899 @smallexample
6900 typedef unsigned long long __u64
6901    __attribute__((aligned(4),warn_if_not_aligned(8)));
6903 struct foo
6905   int i1;
6906   int i2;
6907   __u64 x;
6909 @end smallexample
6911 @noindent
6912 causes the compiler to issue an warning on @code{struct foo}, like
6913 @samp{warning: alignment 4 of 'struct foo' is less than 8}.
6914 It is used to define @code{struct foo} in such a way that
6915 @code{struct foo} has the same layout and the structure field @code{x}
6916 has the same alignment when @code{__u64} is aligned at either 4 or
6917 8 bytes.  Align @code{struct foo} to 8 bytes:
6919 @smallexample
6920 struct foo
6922   int i1;
6923   int i2;
6924   __u64 x;
6925 @} __attribute__((aligned(8)));
6926 @end smallexample
6928 @noindent
6929 silences the warning.  The compiler also issues a warning, like
6930 @samp{warning: 'x' offset 12 in 'struct foo' isn't aligned to 8},
6931 when the structure field has the misaligned offset:
6933 @smallexample
6934 struct foo
6936   int i1;
6937   int i2;
6938   int i3;
6939   __u64 x;
6940 @} __attribute__((aligned(8)));
6941 @end smallexample
6943 This warning can be disabled by @option{-Wno-if-not-aligned}.
6945 @item bnd_variable_size
6946 @cindex @code{bnd_variable_size} type attribute
6947 @cindex Pointer Bounds Checker attributes
6948 When applied to a structure field, this attribute tells Pointer
6949 Bounds Checker that the size of this field should not be computed
6950 using static type information.  It may be used to mark variably-sized
6951 static array fields placed at the end of a structure.
6953 @smallexample
6954 struct S
6956   int size;
6957   char data[1];
6959 S *p = (S *)malloc (sizeof(S) + 100);
6960 p->data[10] = 0; //Bounds violation
6961 @end smallexample
6963 @noindent
6964 By using an attribute for the field we may avoid unwanted bound
6965 violation checks:
6967 @smallexample
6968 struct S
6970   int size;
6971   char data[1] __attribute__((bnd_variable_size));
6973 S *p = (S *)malloc (sizeof(S) + 100);
6974 p->data[10] = 0; //OK
6975 @end smallexample
6977 @item deprecated
6978 @itemx deprecated (@var{msg})
6979 @cindex @code{deprecated} type attribute
6980 The @code{deprecated} attribute results in a warning if the type
6981 is used anywhere in the source file.  This is useful when identifying
6982 types that are expected to be removed in a future version of a program.
6983 If possible, the warning also includes the location of the declaration
6984 of the deprecated type, to enable users to easily find further
6985 information about why the type is deprecated, or what they should do
6986 instead.  Note that the warnings only occur for uses and then only
6987 if the type is being applied to an identifier that itself is not being
6988 declared as deprecated.
6990 @smallexample
6991 typedef int T1 __attribute__ ((deprecated));
6992 T1 x;
6993 typedef T1 T2;
6994 T2 y;
6995 typedef T1 T3 __attribute__ ((deprecated));
6996 T3 z __attribute__ ((deprecated));
6997 @end smallexample
6999 @noindent
7000 results in a warning on line 2 and 3 but not lines 4, 5, or 6.  No
7001 warning is issued for line 4 because T2 is not explicitly
7002 deprecated.  Line 5 has no warning because T3 is explicitly
7003 deprecated.  Similarly for line 6.  The optional @var{msg}
7004 argument, which must be a string, is printed in the warning if
7005 present.
7007 The @code{deprecated} attribute can also be used for functions and
7008 variables (@pxref{Function Attributes}, @pxref{Variable Attributes}.)
7010 @item designated_init
7011 @cindex @code{designated_init} type attribute
7012 This attribute may only be applied to structure types.  It indicates
7013 that any initialization of an object of this type must use designated
7014 initializers rather than positional initializers.  The intent of this
7015 attribute is to allow the programmer to indicate that a structure's
7016 layout may change, and that therefore relying on positional
7017 initialization will result in future breakage.
7019 GCC emits warnings based on this attribute by default; use
7020 @option{-Wno-designated-init} to suppress them.
7022 @item may_alias
7023 @cindex @code{may_alias} type attribute
7024 Accesses through pointers to types with this attribute are not subject
7025 to type-based alias analysis, but are instead assumed to be able to alias
7026 any other type of objects.
7027 In the context of section 6.5 paragraph 7 of the C99 standard,
7028 an lvalue expression
7029 dereferencing such a pointer is treated like having a character type.
7030 See @option{-fstrict-aliasing} for more information on aliasing issues.
7031 This extension exists to support some vector APIs, in which pointers to
7032 one vector type are permitted to alias pointers to a different vector type.
7034 Note that an object of a type with this attribute does not have any
7035 special semantics.
7037 Example of use:
7039 @smallexample
7040 typedef short __attribute__((__may_alias__)) short_a;
7043 main (void)
7045   int a = 0x12345678;
7046   short_a *b = (short_a *) &a;
7048   b[1] = 0;
7050   if (a == 0x12345678)
7051     abort();
7053   exit(0);
7055 @end smallexample
7057 @noindent
7058 If you replaced @code{short_a} with @code{short} in the variable
7059 declaration, the above program would abort when compiled with
7060 @option{-fstrict-aliasing}, which is on by default at @option{-O2} or
7061 above.
7063 @item packed
7064 @cindex @code{packed} type attribute
7065 This attribute, attached to @code{struct} or @code{union} type
7066 definition, specifies that each member (other than zero-width bit-fields)
7067 of the structure or union is placed to minimize the memory required.  When
7068 attached to an @code{enum} definition, it indicates that the smallest
7069 integral type should be used.
7071 @opindex fshort-enums
7072 Specifying the @code{packed} attribute for @code{struct} and @code{union}
7073 types is equivalent to specifying the @code{packed} attribute on each
7074 of the structure or union members.  Specifying the @option{-fshort-enums}
7075 flag on the command line is equivalent to specifying the @code{packed}
7076 attribute on all @code{enum} definitions.
7078 In the following example @code{struct my_packed_struct}'s members are
7079 packed closely together, but the internal layout of its @code{s} member
7080 is not packed---to do that, @code{struct my_unpacked_struct} needs to
7081 be packed too.
7083 @smallexample
7084 struct my_unpacked_struct
7085  @{
7086     char c;
7087     int i;
7088  @};
7090 struct __attribute__ ((__packed__)) my_packed_struct
7091   @{
7092      char c;
7093      int  i;
7094      struct my_unpacked_struct s;
7095   @};
7096 @end smallexample
7098 You may only specify the @code{packed} attribute attribute on the definition
7099 of an @code{enum}, @code{struct} or @code{union}, not on a @code{typedef}
7100 that does not also define the enumerated type, structure or union.
7102 @item scalar_storage_order ("@var{endianness}")
7103 @cindex @code{scalar_storage_order} type attribute
7104 When attached to a @code{union} or a @code{struct}, this attribute sets
7105 the storage order, aka endianness, of the scalar fields of the type, as
7106 well as the array fields whose component is scalar.  The supported
7107 endiannesses are @code{big-endian} and @code{little-endian}.  The attribute
7108 has no effects on fields which are themselves a @code{union}, a @code{struct}
7109 or an array whose component is a @code{union} or a @code{struct}, and it is
7110 possible for these fields to have a different scalar storage order than the
7111 enclosing type.
7113 This attribute is supported only for targets that use a uniform default
7114 scalar storage order (fortunately, most of them), i.e. targets that store
7115 the scalars either all in big-endian or all in little-endian.
7117 Additional restrictions are enforced for types with the reverse scalar
7118 storage order with regard to the scalar storage order of the target:
7120 @itemize
7121 @item Taking the address of a scalar field of a @code{union} or a
7122 @code{struct} with reverse scalar storage order is not permitted and yields
7123 an error.
7124 @item Taking the address of an array field, whose component is scalar, of
7125 a @code{union} or a @code{struct} with reverse scalar storage order is
7126 permitted but yields a warning, unless @option{-Wno-scalar-storage-order}
7127 is specified.
7128 @item Taking the address of a @code{union} or a @code{struct} with reverse
7129 scalar storage order is permitted.
7130 @end itemize
7132 These restrictions exist because the storage order attribute is lost when
7133 the address of a scalar or the address of an array with scalar component is
7134 taken, so storing indirectly through this address generally does not work.
7135 The second case is nevertheless allowed to be able to perform a block copy
7136 from or to the array.
7138 Moreover, the use of type punning or aliasing to toggle the storage order
7139 is not supported; that is to say, a given scalar object cannot be accessed
7140 through distinct types that assign a different storage order to it.
7142 @item transparent_union
7143 @cindex @code{transparent_union} type attribute
7145 This attribute, attached to a @code{union} type definition, indicates
7146 that any function parameter having that union type causes calls to that
7147 function to be treated in a special way.
7149 First, the argument corresponding to a transparent union type can be of
7150 any type in the union; no cast is required.  Also, if the union contains
7151 a pointer type, the corresponding argument can be a null pointer
7152 constant or a void pointer expression; and if the union contains a void
7153 pointer type, the corresponding argument can be any pointer expression.
7154 If the union member type is a pointer, qualifiers like @code{const} on
7155 the referenced type must be respected, just as with normal pointer
7156 conversions.
7158 Second, the argument is passed to the function using the calling
7159 conventions of the first member of the transparent union, not the calling
7160 conventions of the union itself.  All members of the union must have the
7161 same machine representation; this is necessary for this argument passing
7162 to work properly.
7164 Transparent unions are designed for library functions that have multiple
7165 interfaces for compatibility reasons.  For example, suppose the
7166 @code{wait} function must accept either a value of type @code{int *} to
7167 comply with POSIX, or a value of type @code{union wait *} to comply with
7168 the 4.1BSD interface.  If @code{wait}'s parameter were @code{void *},
7169 @code{wait} would accept both kinds of arguments, but it would also
7170 accept any other pointer type and this would make argument type checking
7171 less useful.  Instead, @code{<sys/wait.h>} might define the interface
7172 as follows:
7174 @smallexample
7175 typedef union __attribute__ ((__transparent_union__))
7176   @{
7177     int *__ip;
7178     union wait *__up;
7179   @} wait_status_ptr_t;
7181 pid_t wait (wait_status_ptr_t);
7182 @end smallexample
7184 @noindent
7185 This interface allows either @code{int *} or @code{union wait *}
7186 arguments to be passed, using the @code{int *} calling convention.
7187 The program can call @code{wait} with arguments of either type:
7189 @smallexample
7190 int w1 () @{ int w; return wait (&w); @}
7191 int w2 () @{ union wait w; return wait (&w); @}
7192 @end smallexample
7194 @noindent
7195 With this interface, @code{wait}'s implementation might look like this:
7197 @smallexample
7198 pid_t wait (wait_status_ptr_t p)
7200   return waitpid (-1, p.__ip, 0);
7202 @end smallexample
7204 @item unused
7205 @cindex @code{unused} type attribute
7206 When attached to a type (including a @code{union} or a @code{struct}),
7207 this attribute means that variables of that type are meant to appear
7208 possibly unused.  GCC does not produce a warning for any variables of
7209 that type, even if the variable appears to do nothing.  This is often
7210 the case with lock or thread classes, which are usually defined and then
7211 not referenced, but contain constructors and destructors that have
7212 nontrivial bookkeeping functions.
7214 @item visibility
7215 @cindex @code{visibility} type attribute
7216 In C++, attribute visibility (@pxref{Function Attributes}) can also be
7217 applied to class, struct, union and enum types.  Unlike other type
7218 attributes, the attribute must appear between the initial keyword and
7219 the name of the type; it cannot appear after the body of the type.
7221 Note that the type visibility is applied to vague linkage entities
7222 associated with the class (vtable, typeinfo node, etc.).  In
7223 particular, if a class is thrown as an exception in one shared object
7224 and caught in another, the class must have default visibility.
7225 Otherwise the two shared objects are unable to use the same
7226 typeinfo node and exception handling will break.
7228 @end table
7230 To specify multiple attributes, separate them by commas within the
7231 double parentheses: for example, @samp{__attribute__ ((aligned (16),
7232 packed))}.
7234 @node ARM Type Attributes
7235 @subsection ARM Type Attributes
7237 @cindex @code{notshared} type attribute, ARM
7238 On those ARM targets that support @code{dllimport} (such as Symbian
7239 OS), you can use the @code{notshared} attribute to indicate that the
7240 virtual table and other similar data for a class should not be
7241 exported from a DLL@.  For example:
7243 @smallexample
7244 class __declspec(notshared) C @{
7245 public:
7246   __declspec(dllimport) C();
7247   virtual void f();
7250 __declspec(dllexport)
7251 C::C() @{@}
7252 @end smallexample
7254 @noindent
7255 In this code, @code{C::C} is exported from the current DLL, but the
7256 virtual table for @code{C} is not exported.  (You can use
7257 @code{__attribute__} instead of @code{__declspec} if you prefer, but
7258 most Symbian OS code uses @code{__declspec}.)
7260 @node MeP Type Attributes
7261 @subsection MeP Type Attributes
7263 @cindex @code{based} type attribute, MeP
7264 @cindex @code{tiny} type attribute, MeP
7265 @cindex @code{near} type attribute, MeP
7266 @cindex @code{far} type attribute, MeP
7267 Many of the MeP variable attributes may be applied to types as well.
7268 Specifically, the @code{based}, @code{tiny}, @code{near}, and
7269 @code{far} attributes may be applied to either.  The @code{io} and
7270 @code{cb} attributes may not be applied to types.
7272 @node PowerPC Type Attributes
7273 @subsection PowerPC Type Attributes
7275 Three attributes currently are defined for PowerPC configurations:
7276 @code{altivec}, @code{ms_struct} and @code{gcc_struct}.
7278 @cindex @code{ms_struct} type attribute, PowerPC
7279 @cindex @code{gcc_struct} type attribute, PowerPC
7280 For full documentation of the @code{ms_struct} and @code{gcc_struct}
7281 attributes please see the documentation in @ref{x86 Type Attributes}.
7283 @cindex @code{altivec} type attribute, PowerPC
7284 The @code{altivec} attribute allows one to declare AltiVec vector data
7285 types supported by the AltiVec Programming Interface Manual.  The
7286 attribute requires an argument to specify one of three vector types:
7287 @code{vector__}, @code{pixel__} (always followed by unsigned short),
7288 and @code{bool__} (always followed by unsigned).
7290 @smallexample
7291 __attribute__((altivec(vector__)))
7292 __attribute__((altivec(pixel__))) unsigned short
7293 __attribute__((altivec(bool__))) unsigned
7294 @end smallexample
7296 These attributes mainly are intended to support the @code{__vector},
7297 @code{__pixel}, and @code{__bool} AltiVec keywords.
7299 @node SPU Type Attributes
7300 @subsection SPU Type Attributes
7302 @cindex @code{spu_vector} type attribute, SPU
7303 The SPU supports the @code{spu_vector} attribute for types.  This attribute
7304 allows one to declare vector data types supported by the Sony/Toshiba/IBM SPU
7305 Language Extensions Specification.  It is intended to support the
7306 @code{__vector} keyword.
7308 @node x86 Type Attributes
7309 @subsection x86 Type Attributes
7311 Two attributes are currently defined for x86 configurations:
7312 @code{ms_struct} and @code{gcc_struct}.
7314 @table @code
7316 @item ms_struct
7317 @itemx gcc_struct
7318 @cindex @code{ms_struct} type attribute, x86
7319 @cindex @code{gcc_struct} type attribute, x86
7321 If @code{packed} is used on a structure, or if bit-fields are used
7322 it may be that the Microsoft ABI packs them differently
7323 than GCC normally packs them.  Particularly when moving packed
7324 data between functions compiled with GCC and the native Microsoft compiler
7325 (either via function call or as data in a file), it may be necessary to access
7326 either format.
7328 The @code{ms_struct} and @code{gcc_struct} attributes correspond
7329 to the @option{-mms-bitfields} and @option{-mno-ms-bitfields}
7330 command-line options, respectively;
7331 see @ref{x86 Options}, for details of how structure layout is affected.
7332 @xref{x86 Variable Attributes}, for information about the corresponding
7333 attributes on variables.
7335 @end table
7337 @node Label Attributes
7338 @section Label Attributes
7339 @cindex Label Attributes
7341 GCC allows attributes to be set on C labels.  @xref{Attribute Syntax}, for 
7342 details of the exact syntax for using attributes.  Other attributes are 
7343 available for functions (@pxref{Function Attributes}), variables 
7344 (@pxref{Variable Attributes}), enumerators (@pxref{Enumerator Attributes}),
7345 statements (@pxref{Statement Attributes}), and for types
7346 (@pxref{Type Attributes}).
7348 This example uses the @code{cold} label attribute to indicate the 
7349 @code{ErrorHandling} branch is unlikely to be taken and that the
7350 @code{ErrorHandling} label is unused:
7352 @smallexample
7354    asm goto ("some asm" : : : : NoError);
7356 /* This branch (the fall-through from the asm) is less commonly used */
7357 ErrorHandling: 
7358    __attribute__((cold, unused)); /* Semi-colon is required here */
7359    printf("error\n");
7360    return 0;
7362 NoError:
7363    printf("no error\n");
7364    return 1;
7365 @end smallexample
7367 @table @code
7368 @item unused
7369 @cindex @code{unused} label attribute
7370 This feature is intended for program-generated code that may contain 
7371 unused labels, but which is compiled with @option{-Wall}.  It is
7372 not normally appropriate to use in it human-written code, though it
7373 could be useful in cases where the code that jumps to the label is
7374 contained within an @code{#ifdef} conditional.
7376 @item hot
7377 @cindex @code{hot} label attribute
7378 The @code{hot} attribute on a label is used to inform the compiler that
7379 the path following the label is more likely than paths that are not so
7380 annotated.  This attribute is used in cases where @code{__builtin_expect}
7381 cannot be used, for instance with computed goto or @code{asm goto}.
7383 @item cold
7384 @cindex @code{cold} label attribute
7385 The @code{cold} attribute on labels is used to inform the compiler that
7386 the path following the label is unlikely to be executed.  This attribute
7387 is used in cases where @code{__builtin_expect} cannot be used, for instance
7388 with computed goto or @code{asm goto}.
7390 @end table
7392 @node Enumerator Attributes
7393 @section Enumerator Attributes
7394 @cindex Enumerator Attributes
7396 GCC allows attributes to be set on enumerators.  @xref{Attribute Syntax}, for
7397 details of the exact syntax for using attributes.  Other attributes are
7398 available for functions (@pxref{Function Attributes}), variables
7399 (@pxref{Variable Attributes}), labels (@pxref{Label Attributes}), statements
7400 (@pxref{Statement Attributes}), and for types (@pxref{Type Attributes}).
7402 This example uses the @code{deprecated} enumerator attribute to indicate the
7403 @code{oldval} enumerator is deprecated:
7405 @smallexample
7406 enum E @{
7407   oldval __attribute__((deprecated)),
7408   newval
7412 fn (void)
7414   return oldval;
7416 @end smallexample
7418 @table @code
7419 @item deprecated
7420 @cindex @code{deprecated} enumerator attribute
7421 The @code{deprecated} attribute results in a warning if the enumerator
7422 is used anywhere in the source file.  This is useful when identifying
7423 enumerators that are expected to be removed in a future version of a
7424 program.  The warning also includes the location of the declaration
7425 of the deprecated enumerator, to enable users to easily find further
7426 information about why the enumerator is deprecated, or what they should
7427 do instead.  Note that the warnings only occurs for uses.
7429 @end table
7431 @node Statement Attributes
7432 @section Statement Attributes
7433 @cindex Statement Attributes
7435 GCC allows attributes to be set on null statements.  @xref{Attribute Syntax},
7436 for details of the exact syntax for using attributes.  Other attributes are
7437 available for functions (@pxref{Function Attributes}), variables
7438 (@pxref{Variable Attributes}), labels (@pxref{Label Attributes}), enumerators
7439 (@pxref{Enumerator Attributes}), and for types (@pxref{Type Attributes}).
7441 This example uses the @code{fallthrough} statement attribute to indicate that
7442 the @option{-Wimplicit-fallthrough} warning should not be emitted:
7444 @smallexample
7445 switch (cond)
7446   @{
7447   case 1:
7448     bar (1);
7449     __attribute__((fallthrough));
7450   case 2:
7451     @dots{}
7452   @}
7453 @end smallexample
7455 @table @code
7456 @item fallthrough
7457 @cindex @code{fallthrough} statement attribute
7458 The @code{fallthrough} attribute with a null statement serves as a
7459 fallthrough statement.  It hints to the compiler that a statement
7460 that falls through to another case label, or user-defined label
7461 in a switch statement is intentional and thus the
7462 @option{-Wimplicit-fallthrough} warning must not trigger.  The
7463 fallthrough attribute may appear at most once in each attribute
7464 list, and may not be mixed with other attributes.  It can only
7465 be used in a switch statement (the compiler will issue an error
7466 otherwise), after a preceding statement and before a logically
7467 succeeding case label, or user-defined label.
7469 @end table
7471 @node Attribute Syntax
7472 @section Attribute Syntax
7473 @cindex attribute syntax
7475 This section describes the syntax with which @code{__attribute__} may be
7476 used, and the constructs to which attribute specifiers bind, for the C
7477 language.  Some details may vary for C++ and Objective-C@.  Because of
7478 infelicities in the grammar for attributes, some forms described here
7479 may not be successfully parsed in all cases.
7481 There are some problems with the semantics of attributes in C++.  For
7482 example, there are no manglings for attributes, although they may affect
7483 code generation, so problems may arise when attributed types are used in
7484 conjunction with templates or overloading.  Similarly, @code{typeid}
7485 does not distinguish between types with different attributes.  Support
7486 for attributes in C++ may be restricted in future to attributes on
7487 declarations only, but not on nested declarators.
7489 @xref{Function Attributes}, for details of the semantics of attributes
7490 applying to functions.  @xref{Variable Attributes}, for details of the
7491 semantics of attributes applying to variables.  @xref{Type Attributes},
7492 for details of the semantics of attributes applying to structure, union
7493 and enumerated types.
7494 @xref{Label Attributes}, for details of the semantics of attributes 
7495 applying to labels.
7496 @xref{Enumerator Attributes}, for details of the semantics of attributes
7497 applying to enumerators.
7498 @xref{Statement Attributes}, for details of the semantics of attributes
7499 applying to statements.
7501 An @dfn{attribute specifier} is of the form
7502 @code{__attribute__ ((@var{attribute-list}))}.  An @dfn{attribute list}
7503 is a possibly empty comma-separated sequence of @dfn{attributes}, where
7504 each attribute is one of the following:
7506 @itemize @bullet
7507 @item
7508 Empty.  Empty attributes are ignored.
7510 @item
7511 An attribute name
7512 (which may be an identifier such as @code{unused}, or a reserved
7513 word such as @code{const}).
7515 @item
7516 An attribute name followed by a parenthesized list of
7517 parameters for the attribute.
7518 These parameters take one of the following forms:
7520 @itemize @bullet
7521 @item
7522 An identifier.  For example, @code{mode} attributes use this form.
7524 @item
7525 An identifier followed by a comma and a non-empty comma-separated list
7526 of expressions.  For example, @code{format} attributes use this form.
7528 @item
7529 A possibly empty comma-separated list of expressions.  For example,
7530 @code{format_arg} attributes use this form with the list being a single
7531 integer constant expression, and @code{alias} attributes use this form
7532 with the list being a single string constant.
7533 @end itemize
7534 @end itemize
7536 An @dfn{attribute specifier list} is a sequence of one or more attribute
7537 specifiers, not separated by any other tokens.
7539 You may optionally specify attribute names with @samp{__}
7540 preceding and following the name.
7541 This allows you to use them in header files without
7542 being concerned about a possible macro of the same name.  For example,
7543 you may use the attribute name @code{__noreturn__} instead of @code{noreturn}.
7546 @subsubheading Label Attributes
7548 In GNU C, an attribute specifier list may appear after the colon following a
7549 label, other than a @code{case} or @code{default} label.  GNU C++ only permits
7550 attributes on labels if the attribute specifier is immediately
7551 followed by a semicolon (i.e., the label applies to an empty
7552 statement).  If the semicolon is missing, C++ label attributes are
7553 ambiguous, as it is permissible for a declaration, which could begin
7554 with an attribute list, to be labelled in C++.  Declarations cannot be
7555 labelled in C90 or C99, so the ambiguity does not arise there.
7557 @subsubheading Enumerator Attributes
7559 In GNU C, an attribute specifier list may appear as part of an enumerator.
7560 The attribute goes after the enumeration constant, before @code{=}, if
7561 present.  The optional attribute in the enumerator appertains to the
7562 enumeration constant.  It is not possible to place the attribute after
7563 the constant expression, if present.
7565 @subsubheading Statement Attributes
7566 In GNU C, an attribute specifier list may appear as part of a null
7567 statement.  The attribute goes before the semicolon.
7569 @subsubheading Type Attributes
7571 An attribute specifier list may appear as part of a @code{struct},
7572 @code{union} or @code{enum} specifier.  It may go either immediately
7573 after the @code{struct}, @code{union} or @code{enum} keyword, or after
7574 the closing brace.  The former syntax is preferred.
7575 Where attribute specifiers follow the closing brace, they are considered
7576 to relate to the structure, union or enumerated type defined, not to any
7577 enclosing declaration the type specifier appears in, and the type
7578 defined is not complete until after the attribute specifiers.
7579 @c Otherwise, there would be the following problems: a shift/reduce
7580 @c conflict between attributes binding the struct/union/enum and
7581 @c binding to the list of specifiers/qualifiers; and "aligned"
7582 @c attributes could use sizeof for the structure, but the size could be
7583 @c changed later by "packed" attributes.
7586 @subsubheading All other attributes
7588 Otherwise, an attribute specifier appears as part of a declaration,
7589 counting declarations of unnamed parameters and type names, and relates
7590 to that declaration (which may be nested in another declaration, for
7591 example in the case of a parameter declaration), or to a particular declarator
7592 within a declaration.  Where an
7593 attribute specifier is applied to a parameter declared as a function or
7594 an array, it should apply to the function or array rather than the
7595 pointer to which the parameter is implicitly converted, but this is not
7596 yet correctly implemented.
7598 Any list of specifiers and qualifiers at the start of a declaration may
7599 contain attribute specifiers, whether or not such a list may in that
7600 context contain storage class specifiers.  (Some attributes, however,
7601 are essentially in the nature of storage class specifiers, and only make
7602 sense where storage class specifiers may be used; for example,
7603 @code{section}.)  There is one necessary limitation to this syntax: the
7604 first old-style parameter declaration in a function definition cannot
7605 begin with an attribute specifier, because such an attribute applies to
7606 the function instead by syntax described below (which, however, is not
7607 yet implemented in this case).  In some other cases, attribute
7608 specifiers are permitted by this grammar but not yet supported by the
7609 compiler.  All attribute specifiers in this place relate to the
7610 declaration as a whole.  In the obsolescent usage where a type of
7611 @code{int} is implied by the absence of type specifiers, such a list of
7612 specifiers and qualifiers may be an attribute specifier list with no
7613 other specifiers or qualifiers.
7615 At present, the first parameter in a function prototype must have some
7616 type specifier that is not an attribute specifier; this resolves an
7617 ambiguity in the interpretation of @code{void f(int
7618 (__attribute__((foo)) x))}, but is subject to change.  At present, if
7619 the parentheses of a function declarator contain only attributes then
7620 those attributes are ignored, rather than yielding an error or warning
7621 or implying a single parameter of type int, but this is subject to
7622 change.
7624 An attribute specifier list may appear immediately before a declarator
7625 (other than the first) in a comma-separated list of declarators in a
7626 declaration of more than one identifier using a single list of
7627 specifiers and qualifiers.  Such attribute specifiers apply
7628 only to the identifier before whose declarator they appear.  For
7629 example, in
7631 @smallexample
7632 __attribute__((noreturn)) void d0 (void),
7633     __attribute__((format(printf, 1, 2))) d1 (const char *, ...),
7634      d2 (void);
7635 @end smallexample
7637 @noindent
7638 the @code{noreturn} attribute applies to all the functions
7639 declared; the @code{format} attribute only applies to @code{d1}.
7641 An attribute specifier list may appear immediately before the comma,
7642 @code{=} or semicolon terminating the declaration of an identifier other
7643 than a function definition.  Such attribute specifiers apply
7644 to the declared object or function.  Where an
7645 assembler name for an object or function is specified (@pxref{Asm
7646 Labels}), the attribute must follow the @code{asm}
7647 specification.
7649 An attribute specifier list may, in future, be permitted to appear after
7650 the declarator in a function definition (before any old-style parameter
7651 declarations or the function body).
7653 Attribute specifiers may be mixed with type qualifiers appearing inside
7654 the @code{[]} of a parameter array declarator, in the C99 construct by
7655 which such qualifiers are applied to the pointer to which the array is
7656 implicitly converted.  Such attribute specifiers apply to the pointer,
7657 not to the array, but at present this is not implemented and they are
7658 ignored.
7660 An attribute specifier list may appear at the start of a nested
7661 declarator.  At present, there are some limitations in this usage: the
7662 attributes correctly apply to the declarator, but for most individual
7663 attributes the semantics this implies are not implemented.
7664 When attribute specifiers follow the @code{*} of a pointer
7665 declarator, they may be mixed with any type qualifiers present.
7666 The following describes the formal semantics of this syntax.  It makes the
7667 most sense if you are familiar with the formal specification of
7668 declarators in the ISO C standard.
7670 Consider (as in C99 subclause 6.7.5 paragraph 4) a declaration @code{T
7671 D1}, where @code{T} contains declaration specifiers that specify a type
7672 @var{Type} (such as @code{int}) and @code{D1} is a declarator that
7673 contains an identifier @var{ident}.  The type specified for @var{ident}
7674 for derived declarators whose type does not include an attribute
7675 specifier is as in the ISO C standard.
7677 If @code{D1} has the form @code{( @var{attribute-specifier-list} D )},
7678 and the declaration @code{T D} specifies the type
7679 ``@var{derived-declarator-type-list} @var{Type}'' for @var{ident}, then
7680 @code{T D1} specifies the type ``@var{derived-declarator-type-list}
7681 @var{attribute-specifier-list} @var{Type}'' for @var{ident}.
7683 If @code{D1} has the form @code{*
7684 @var{type-qualifier-and-attribute-specifier-list} D}, and the
7685 declaration @code{T D} specifies the type
7686 ``@var{derived-declarator-type-list} @var{Type}'' for @var{ident}, then
7687 @code{T D1} specifies the type ``@var{derived-declarator-type-list}
7688 @var{type-qualifier-and-attribute-specifier-list} pointer to @var{Type}'' for
7689 @var{ident}.
7691 For example,
7693 @smallexample
7694 void (__attribute__((noreturn)) ****f) (void);
7695 @end smallexample
7697 @noindent
7698 specifies the type ``pointer to pointer to pointer to pointer to
7699 non-returning function returning @code{void}''.  As another example,
7701 @smallexample
7702 char *__attribute__((aligned(8))) *f;
7703 @end smallexample
7705 @noindent
7706 specifies the type ``pointer to 8-byte-aligned pointer to @code{char}''.
7707 Note again that this does not work with most attributes; for example,
7708 the usage of @samp{aligned} and @samp{noreturn} attributes given above
7709 is not yet supported.
7711 For compatibility with existing code written for compiler versions that
7712 did not implement attributes on nested declarators, some laxity is
7713 allowed in the placing of attributes.  If an attribute that only applies
7714 to types is applied to a declaration, it is treated as applying to
7715 the type of that declaration.  If an attribute that only applies to
7716 declarations is applied to the type of a declaration, it is treated
7717 as applying to that declaration; and, for compatibility with code
7718 placing the attributes immediately before the identifier declared, such
7719 an attribute applied to a function return type is treated as
7720 applying to the function type, and such an attribute applied to an array
7721 element type is treated as applying to the array type.  If an
7722 attribute that only applies to function types is applied to a
7723 pointer-to-function type, it is treated as applying to the pointer
7724 target type; if such an attribute is applied to a function return type
7725 that is not a pointer-to-function type, it is treated as applying
7726 to the function type.
7728 @node Function Prototypes
7729 @section Prototypes and Old-Style Function Definitions
7730 @cindex function prototype declarations
7731 @cindex old-style function definitions
7732 @cindex promotion of formal parameters
7734 GNU C extends ISO C to allow a function prototype to override a later
7735 old-style non-prototype definition.  Consider the following example:
7737 @smallexample
7738 /* @r{Use prototypes unless the compiler is old-fashioned.}  */
7739 #ifdef __STDC__
7740 #define P(x) x
7741 #else
7742 #define P(x) ()
7743 #endif
7745 /* @r{Prototype function declaration.}  */
7746 int isroot P((uid_t));
7748 /* @r{Old-style function definition.}  */
7750 isroot (x)   /* @r{??? lossage here ???} */
7751      uid_t x;
7753   return x == 0;
7755 @end smallexample
7757 Suppose the type @code{uid_t} happens to be @code{short}.  ISO C does
7758 not allow this example, because subword arguments in old-style
7759 non-prototype definitions are promoted.  Therefore in this example the
7760 function definition's argument is really an @code{int}, which does not
7761 match the prototype argument type of @code{short}.
7763 This restriction of ISO C makes it hard to write code that is portable
7764 to traditional C compilers, because the programmer does not know
7765 whether the @code{uid_t} type is @code{short}, @code{int}, or
7766 @code{long}.  Therefore, in cases like these GNU C allows a prototype
7767 to override a later old-style definition.  More precisely, in GNU C, a
7768 function prototype argument type overrides the argument type specified
7769 by a later old-style definition if the former type is the same as the
7770 latter type before promotion.  Thus in GNU C the above example is
7771 equivalent to the following:
7773 @smallexample
7774 int isroot (uid_t);
7777 isroot (uid_t x)
7779   return x == 0;
7781 @end smallexample
7783 @noindent
7784 GNU C++ does not support old-style function definitions, so this
7785 extension is irrelevant.
7787 @node C++ Comments
7788 @section C++ Style Comments
7789 @cindex @code{//}
7790 @cindex C++ comments
7791 @cindex comments, C++ style
7793 In GNU C, you may use C++ style comments, which start with @samp{//} and
7794 continue until the end of the line.  Many other C implementations allow
7795 such comments, and they are included in the 1999 C standard.  However,
7796 C++ style comments are not recognized if you specify an @option{-std}
7797 option specifying a version of ISO C before C99, or @option{-ansi}
7798 (equivalent to @option{-std=c90}).
7800 @node Dollar Signs
7801 @section Dollar Signs in Identifier Names
7802 @cindex $
7803 @cindex dollar signs in identifier names
7804 @cindex identifier names, dollar signs in
7806 In GNU C, you may normally use dollar signs in identifier names.
7807 This is because many traditional C implementations allow such identifiers.
7808 However, dollar signs in identifiers are not supported on a few target
7809 machines, typically because the target assembler does not allow them.
7811 @node Character Escapes
7812 @section The Character @key{ESC} in Constants
7814 You can use the sequence @samp{\e} in a string or character constant to
7815 stand for the ASCII character @key{ESC}.
7817 @node Alignment
7818 @section Inquiring on Alignment of Types or Variables
7819 @cindex alignment
7820 @cindex type alignment
7821 @cindex variable alignment
7823 The keyword @code{__alignof__} allows you to inquire about how an object
7824 is aligned, or the minimum alignment usually required by a type.  Its
7825 syntax is just like @code{sizeof}.
7827 For example, if the target machine requires a @code{double} value to be
7828 aligned on an 8-byte boundary, then @code{__alignof__ (double)} is 8.
7829 This is true on many RISC machines.  On more traditional machine
7830 designs, @code{__alignof__ (double)} is 4 or even 2.
7832 Some machines never actually require alignment; they allow reference to any
7833 data type even at an odd address.  For these machines, @code{__alignof__}
7834 reports the smallest alignment that GCC gives the data type, usually as
7835 mandated by the target ABI.
7837 If the operand of @code{__alignof__} is an lvalue rather than a type,
7838 its value is the required alignment for its type, taking into account
7839 any minimum alignment specified with GCC's @code{__attribute__}
7840 extension (@pxref{Variable Attributes}).  For example, after this
7841 declaration:
7843 @smallexample
7844 struct foo @{ int x; char y; @} foo1;
7845 @end smallexample
7847 @noindent
7848 the value of @code{__alignof__ (foo1.y)} is 1, even though its actual
7849 alignment is probably 2 or 4, the same as @code{__alignof__ (int)}.
7851 It is an error to ask for the alignment of an incomplete type.
7854 @node Inline
7855 @section An Inline Function is As Fast As a Macro
7856 @cindex inline functions
7857 @cindex integrating function code
7858 @cindex open coding
7859 @cindex macros, inline alternative
7861 By declaring a function inline, you can direct GCC to make
7862 calls to that function faster.  One way GCC can achieve this is to
7863 integrate that function's code into the code for its callers.  This
7864 makes execution faster by eliminating the function-call overhead; in
7865 addition, if any of the actual argument values are constant, their
7866 known values may permit simplifications at compile time so that not
7867 all of the inline function's code needs to be included.  The effect on
7868 code size is less predictable; object code may be larger or smaller
7869 with function inlining, depending on the particular case.  You can
7870 also direct GCC to try to integrate all ``simple enough'' functions
7871 into their callers with the option @option{-finline-functions}.
7873 GCC implements three different semantics of declaring a function
7874 inline.  One is available with @option{-std=gnu89} or
7875 @option{-fgnu89-inline} or when @code{gnu_inline} attribute is present
7876 on all inline declarations, another when
7877 @option{-std=c99},
7878 @option{-std=gnu99} or an option for a later C version is used
7879 (without @option{-fgnu89-inline}), and the third
7880 is used when compiling C++.
7882 To declare a function inline, use the @code{inline} keyword in its
7883 declaration, like this:
7885 @smallexample
7886 static inline int
7887 inc (int *a)
7889   return (*a)++;
7891 @end smallexample
7893 If you are writing a header file to be included in ISO C90 programs, write
7894 @code{__inline__} instead of @code{inline}.  @xref{Alternate Keywords}.
7896 The three types of inlining behave similarly in two important cases:
7897 when the @code{inline} keyword is used on a @code{static} function,
7898 like the example above, and when a function is first declared without
7899 using the @code{inline} keyword and then is defined with
7900 @code{inline}, like this:
7902 @smallexample
7903 extern int inc (int *a);
7904 inline int
7905 inc (int *a)
7907   return (*a)++;
7909 @end smallexample
7911 In both of these common cases, the program behaves the same as if you
7912 had not used the @code{inline} keyword, except for its speed.
7914 @cindex inline functions, omission of
7915 @opindex fkeep-inline-functions
7916 When a function is both inline and @code{static}, if all calls to the
7917 function are integrated into the caller, and the function's address is
7918 never used, then the function's own assembler code is never referenced.
7919 In this case, GCC does not actually output assembler code for the
7920 function, unless you specify the option @option{-fkeep-inline-functions}.
7921 If there is a nonintegrated call, then the function is compiled to
7922 assembler code as usual.  The function must also be compiled as usual if
7923 the program refers to its address, because that cannot be inlined.
7925 @opindex Winline
7926 Note that certain usages in a function definition can make it unsuitable
7927 for inline substitution.  Among these usages are: variadic functions,
7928 use of @code{alloca}, use of computed goto (@pxref{Labels as Values}),
7929 use of nonlocal goto, use of nested functions, use of @code{setjmp}, use
7930 of @code{__builtin_longjmp} and use of @code{__builtin_return} or
7931 @code{__builtin_apply_args}.  Using @option{-Winline} warns when a
7932 function marked @code{inline} could not be substituted, and gives the
7933 reason for the failure.
7935 @cindex automatic @code{inline} for C++ member fns
7936 @cindex @code{inline} automatic for C++ member fns
7937 @cindex member fns, automatically @code{inline}
7938 @cindex C++ member fns, automatically @code{inline}
7939 @opindex fno-default-inline
7940 As required by ISO C++, GCC considers member functions defined within
7941 the body of a class to be marked inline even if they are
7942 not explicitly declared with the @code{inline} keyword.  You can
7943 override this with @option{-fno-default-inline}; @pxref{C++ Dialect
7944 Options,,Options Controlling C++ Dialect}.
7946 GCC does not inline any functions when not optimizing unless you specify
7947 the @samp{always_inline} attribute for the function, like this:
7949 @smallexample
7950 /* @r{Prototype.}  */
7951 inline void foo (const char) __attribute__((always_inline));
7952 @end smallexample
7954 The remainder of this section is specific to GNU C90 inlining.
7956 @cindex non-static inline function
7957 When an inline function is not @code{static}, then the compiler must assume
7958 that there may be calls from other source files; since a global symbol can
7959 be defined only once in any program, the function must not be defined in
7960 the other source files, so the calls therein cannot be integrated.
7961 Therefore, a non-@code{static} inline function is always compiled on its
7962 own in the usual fashion.
7964 If you specify both @code{inline} and @code{extern} in the function
7965 definition, then the definition is used only for inlining.  In no case
7966 is the function compiled on its own, not even if you refer to its
7967 address explicitly.  Such an address becomes an external reference, as
7968 if you had only declared the function, and had not defined it.
7970 This combination of @code{inline} and @code{extern} has almost the
7971 effect of a macro.  The way to use it is to put a function definition in
7972 a header file with these keywords, and put another copy of the
7973 definition (lacking @code{inline} and @code{extern}) in a library file.
7974 The definition in the header file causes most calls to the function
7975 to be inlined.  If any uses of the function remain, they refer to
7976 the single copy in the library.
7978 @node Volatiles
7979 @section When is a Volatile Object Accessed?
7980 @cindex accessing volatiles
7981 @cindex volatile read
7982 @cindex volatile write
7983 @cindex volatile access
7985 C has the concept of volatile objects.  These are normally accessed by
7986 pointers and used for accessing hardware or inter-thread
7987 communication.  The standard encourages compilers to refrain from
7988 optimizations concerning accesses to volatile objects, but leaves it
7989 implementation defined as to what constitutes a volatile access.  The
7990 minimum requirement is that at a sequence point all previous accesses
7991 to volatile objects have stabilized and no subsequent accesses have
7992 occurred.  Thus an implementation is free to reorder and combine
7993 volatile accesses that occur between sequence points, but cannot do
7994 so for accesses across a sequence point.  The use of volatile does
7995 not allow you to violate the restriction on updating objects multiple
7996 times between two sequence points.
7998 Accesses to non-volatile objects are not ordered with respect to
7999 volatile accesses.  You cannot use a volatile object as a memory
8000 barrier to order a sequence of writes to non-volatile memory.  For
8001 instance:
8003 @smallexample
8004 int *ptr = @var{something};
8005 volatile int vobj;
8006 *ptr = @var{something};
8007 vobj = 1;
8008 @end smallexample
8010 @noindent
8011 Unless @var{*ptr} and @var{vobj} can be aliased, it is not guaranteed
8012 that the write to @var{*ptr} occurs by the time the update
8013 of @var{vobj} happens.  If you need this guarantee, you must use
8014 a stronger memory barrier such as:
8016 @smallexample
8017 int *ptr = @var{something};
8018 volatile int vobj;
8019 *ptr = @var{something};
8020 asm volatile ("" : : : "memory");
8021 vobj = 1;
8022 @end smallexample
8024 A scalar volatile object is read when it is accessed in a void context:
8026 @smallexample
8027 volatile int *src = @var{somevalue};
8028 *src;
8029 @end smallexample
8031 Such expressions are rvalues, and GCC implements this as a
8032 read of the volatile object being pointed to.
8034 Assignments are also expressions and have an rvalue.  However when
8035 assigning to a scalar volatile, the volatile object is not reread,
8036 regardless of whether the assignment expression's rvalue is used or
8037 not.  If the assignment's rvalue is used, the value is that assigned
8038 to the volatile object.  For instance, there is no read of @var{vobj}
8039 in all the following cases:
8041 @smallexample
8042 int obj;
8043 volatile int vobj;
8044 vobj = @var{something};
8045 obj = vobj = @var{something};
8046 obj ? vobj = @var{onething} : vobj = @var{anotherthing};
8047 obj = (@var{something}, vobj = @var{anotherthing});
8048 @end smallexample
8050 If you need to read the volatile object after an assignment has
8051 occurred, you must use a separate expression with an intervening
8052 sequence point.
8054 As bit-fields are not individually addressable, volatile bit-fields may
8055 be implicitly read when written to, or when adjacent bit-fields are
8056 accessed.  Bit-field operations may be optimized such that adjacent
8057 bit-fields are only partially accessed, if they straddle a storage unit
8058 boundary.  For these reasons it is unwise to use volatile bit-fields to
8059 access hardware.
8061 @node Using Assembly Language with C
8062 @section How to Use Inline Assembly Language in C Code
8063 @cindex @code{asm} keyword
8064 @cindex assembly language in C
8065 @cindex inline assembly language
8066 @cindex mixing assembly language and C
8068 The @code{asm} keyword allows you to embed assembler instructions
8069 within C code.  GCC provides two forms of inline @code{asm}
8070 statements.  A @dfn{basic @code{asm}} statement is one with no
8071 operands (@pxref{Basic Asm}), while an @dfn{extended @code{asm}}
8072 statement (@pxref{Extended Asm}) includes one or more operands.  
8073 The extended form is preferred for mixing C and assembly language
8074 within a function, but to include assembly language at
8075 top level you must use basic @code{asm}.
8077 You can also use the @code{asm} keyword to override the assembler name
8078 for a C symbol, or to place a C variable in a specific register.
8080 @menu
8081 * Basic Asm::          Inline assembler without operands.
8082 * Extended Asm::       Inline assembler with operands.
8083 * Constraints::        Constraints for @code{asm} operands
8084 * Asm Labels::         Specifying the assembler name to use for a C symbol.
8085 * Explicit Register Variables::  Defining variables residing in specified 
8086                        registers.
8087 * Size of an asm::     How GCC calculates the size of an @code{asm} block.
8088 @end menu
8090 @node Basic Asm
8091 @subsection Basic Asm --- Assembler Instructions Without Operands
8092 @cindex basic @code{asm}
8093 @cindex assembly language in C, basic
8095 A basic @code{asm} statement has the following syntax:
8097 @example
8098 asm @r{[} volatile @r{]} ( @var{AssemblerInstructions} )
8099 @end example
8101 The @code{asm} keyword is a GNU extension.
8102 When writing code that can be compiled with @option{-ansi} and the
8103 various @option{-std} options, use @code{__asm__} instead of 
8104 @code{asm} (@pxref{Alternate Keywords}).
8106 @subsubheading Qualifiers
8107 @table @code
8108 @item volatile
8109 The optional @code{volatile} qualifier has no effect. 
8110 All basic @code{asm} blocks are implicitly volatile.
8111 @end table
8113 @subsubheading Parameters
8114 @table @var
8116 @item AssemblerInstructions
8117 This is a literal string that specifies the assembler code. The string can 
8118 contain any instructions recognized by the assembler, including directives. 
8119 GCC does not parse the assembler instructions themselves and 
8120 does not know what they mean or even whether they are valid assembler input. 
8122 You may place multiple assembler instructions together in a single @code{asm} 
8123 string, separated by the characters normally used in assembly code for the 
8124 system. A combination that works in most places is a newline to break the 
8125 line, plus a tab character (written as @samp{\n\t}).
8126 Some assemblers allow semicolons as a line separator. However, 
8127 note that some assembler dialects use semicolons to start a comment. 
8128 @end table
8130 @subsubheading Remarks
8131 Using extended @code{asm} (@pxref{Extended Asm}) typically produces
8132 smaller, safer, and more efficient code, and in most cases it is a
8133 better solution than basic @code{asm}.  However, there are two
8134 situations where only basic @code{asm} can be used:
8136 @itemize @bullet
8137 @item
8138 Extended @code{asm} statements have to be inside a C
8139 function, so to write inline assembly language at file scope (``top-level''),
8140 outside of C functions, you must use basic @code{asm}.
8141 You can use this technique to emit assembler directives,
8142 define assembly language macros that can be invoked elsewhere in the file,
8143 or write entire functions in assembly language.
8145 @item
8146 Functions declared
8147 with the @code{naked} attribute also require basic @code{asm}
8148 (@pxref{Function Attributes}).
8149 @end itemize
8151 Safely accessing C data and calling functions from basic @code{asm} is more 
8152 complex than it may appear. To access C data, it is better to use extended 
8153 @code{asm}.
8155 Do not expect a sequence of @code{asm} statements to remain perfectly 
8156 consecutive after compilation. If certain instructions need to remain 
8157 consecutive in the output, put them in a single multi-instruction @code{asm}
8158 statement. Note that GCC's optimizers can move @code{asm} statements 
8159 relative to other code, including across jumps.
8161 @code{asm} statements may not perform jumps into other @code{asm} statements. 
8162 GCC does not know about these jumps, and therefore cannot take 
8163 account of them when deciding how to optimize. Jumps from @code{asm} to C 
8164 labels are only supported in extended @code{asm}.
8166 Under certain circumstances, GCC may duplicate (or remove duplicates of) your 
8167 assembly code when optimizing. This can lead to unexpected duplicate 
8168 symbol errors during compilation if your assembly code defines symbols or 
8169 labels.
8171 @strong{Warning:} The C standards do not specify semantics for @code{asm},
8172 making it a potential source of incompatibilities between compilers.  These
8173 incompatibilities may not produce compiler warnings/errors.
8175 GCC does not parse basic @code{asm}'s @var{AssemblerInstructions}, which
8176 means there is no way to communicate to the compiler what is happening
8177 inside them.  GCC has no visibility of symbols in the @code{asm} and may
8178 discard them as unreferenced.  It also does not know about side effects of
8179 the assembler code, such as modifications to memory or registers.  Unlike
8180 some compilers, GCC assumes that no changes to general purpose registers
8181 occur.  This assumption may change in a future release.
8183 To avoid complications from future changes to the semantics and the
8184 compatibility issues between compilers, consider replacing basic @code{asm}
8185 with extended @code{asm}.  See
8186 @uref{https://gcc.gnu.org/wiki/ConvertBasicAsmToExtended, How to convert
8187 from basic asm to extended asm} for information about how to perform this
8188 conversion.
8190 The compiler copies the assembler instructions in a basic @code{asm} 
8191 verbatim to the assembly language output file, without 
8192 processing dialects or any of the @samp{%} operators that are available with
8193 extended @code{asm}. This results in minor differences between basic 
8194 @code{asm} strings and extended @code{asm} templates. For example, to refer to 
8195 registers you might use @samp{%eax} in basic @code{asm} and
8196 @samp{%%eax} in extended @code{asm}.
8198 On targets such as x86 that support multiple assembler dialects,
8199 all basic @code{asm} blocks use the assembler dialect specified by the 
8200 @option{-masm} command-line option (@pxref{x86 Options}).  
8201 Basic @code{asm} provides no
8202 mechanism to provide different assembler strings for different dialects.
8204 For basic @code{asm} with non-empty assembler string GCC assumes
8205 the assembler block does not change any general purpose registers,
8206 but it may read or write any globally accessible variable.
8208 Here is an example of basic @code{asm} for i386:
8210 @example
8211 /* Note that this code will not compile with -masm=intel */
8212 #define DebugBreak() asm("int $3")
8213 @end example
8215 @node Extended Asm
8216 @subsection Extended Asm - Assembler Instructions with C Expression Operands
8217 @cindex extended @code{asm}
8218 @cindex assembly language in C, extended
8220 With extended @code{asm} you can read and write C variables from 
8221 assembler and perform jumps from assembler code to C labels.  
8222 Extended @code{asm} syntax uses colons (@samp{:}) to delimit
8223 the operand parameters after the assembler template:
8225 @example
8226 asm @r{[}volatile@r{]} ( @var{AssemblerTemplate} 
8227                  : @var{OutputOperands} 
8228                  @r{[} : @var{InputOperands}
8229                  @r{[} : @var{Clobbers} @r{]} @r{]})
8231 asm @r{[}volatile@r{]} goto ( @var{AssemblerTemplate} 
8232                       : 
8233                       : @var{InputOperands}
8234                       : @var{Clobbers}
8235                       : @var{GotoLabels})
8236 @end example
8238 The @code{asm} keyword is a GNU extension.
8239 When writing code that can be compiled with @option{-ansi} and the
8240 various @option{-std} options, use @code{__asm__} instead of 
8241 @code{asm} (@pxref{Alternate Keywords}).
8243 @subsubheading Qualifiers
8244 @table @code
8246 @item volatile
8247 The typical use of extended @code{asm} statements is to manipulate input 
8248 values to produce output values. However, your @code{asm} statements may 
8249 also produce side effects. If so, you may need to use the @code{volatile} 
8250 qualifier to disable certain optimizations. @xref{Volatile}.
8252 @item goto
8253 This qualifier informs the compiler that the @code{asm} statement may 
8254 perform a jump to one of the labels listed in the @var{GotoLabels}.
8255 @xref{GotoLabels}.
8256 @end table
8258 @subsubheading Parameters
8259 @table @var
8260 @item AssemblerTemplate
8261 This is a literal string that is the template for the assembler code. It is a 
8262 combination of fixed text and tokens that refer to the input, output, 
8263 and goto parameters. @xref{AssemblerTemplate}.
8265 @item OutputOperands
8266 A comma-separated list of the C variables modified by the instructions in the 
8267 @var{AssemblerTemplate}.  An empty list is permitted.  @xref{OutputOperands}.
8269 @item InputOperands
8270 A comma-separated list of C expressions read by the instructions in the 
8271 @var{AssemblerTemplate}.  An empty list is permitted.  @xref{InputOperands}.
8273 @item Clobbers
8274 A comma-separated list of registers or other values changed by the 
8275 @var{AssemblerTemplate}, beyond those listed as outputs.
8276 An empty list is permitted.  @xref{Clobbers and Scratch Registers}.
8278 @item GotoLabels
8279 When you are using the @code{goto} form of @code{asm}, this section contains 
8280 the list of all C labels to which the code in the 
8281 @var{AssemblerTemplate} may jump. 
8282 @xref{GotoLabels}.
8284 @code{asm} statements may not perform jumps into other @code{asm} statements,
8285 only to the listed @var{GotoLabels}.
8286 GCC's optimizers do not know about other jumps; therefore they cannot take 
8287 account of them when deciding how to optimize.
8288 @end table
8290 The total number of input + output + goto operands is limited to 30.
8292 @subsubheading Remarks
8293 The @code{asm} statement allows you to include assembly instructions directly 
8294 within C code. This may help you to maximize performance in time-sensitive 
8295 code or to access assembly instructions that are not readily available to C 
8296 programs.
8298 Note that extended @code{asm} statements must be inside a function. Only 
8299 basic @code{asm} may be outside functions (@pxref{Basic Asm}).
8300 Functions declared with the @code{naked} attribute also require basic 
8301 @code{asm} (@pxref{Function Attributes}).
8303 While the uses of @code{asm} are many and varied, it may help to think of an 
8304 @code{asm} statement as a series of low-level instructions that convert input 
8305 parameters to output parameters. So a simple (if not particularly useful) 
8306 example for i386 using @code{asm} might look like this:
8308 @example
8309 int src = 1;
8310 int dst;   
8312 asm ("mov %1, %0\n\t"
8313     "add $1, %0"
8314     : "=r" (dst) 
8315     : "r" (src));
8317 printf("%d\n", dst);
8318 @end example
8320 This code copies @code{src} to @code{dst} and add 1 to @code{dst}.
8322 @anchor{Volatile}
8323 @subsubsection Volatile
8324 @cindex volatile @code{asm}
8325 @cindex @code{asm} volatile
8327 GCC's optimizers sometimes discard @code{asm} statements if they determine 
8328 there is no need for the output variables. Also, the optimizers may move 
8329 code out of loops if they believe that the code will always return the same 
8330 result (i.e. none of its input values change between calls). Using the 
8331 @code{volatile} qualifier disables these optimizations. @code{asm} statements 
8332 that have no output operands, including @code{asm goto} statements, 
8333 are implicitly volatile.
8335 This i386 code demonstrates a case that does not use (or require) the 
8336 @code{volatile} qualifier. If it is performing assertion checking, this code 
8337 uses @code{asm} to perform the validation. Otherwise, @code{dwRes} is 
8338 unreferenced by any code. As a result, the optimizers can discard the 
8339 @code{asm} statement, which in turn removes the need for the entire 
8340 @code{DoCheck} routine. By omitting the @code{volatile} qualifier when it 
8341 isn't needed you allow the optimizers to produce the most efficient code 
8342 possible.
8344 @example
8345 void DoCheck(uint32_t dwSomeValue)
8347    uint32_t dwRes;
8349    // Assumes dwSomeValue is not zero.
8350    asm ("bsfl %1,%0"
8351      : "=r" (dwRes)
8352      : "r" (dwSomeValue)
8353      : "cc");
8355    assert(dwRes > 3);
8357 @end example
8359 The next example shows a case where the optimizers can recognize that the input 
8360 (@code{dwSomeValue}) never changes during the execution of the function and can 
8361 therefore move the @code{asm} outside the loop to produce more efficient code. 
8362 Again, using @code{volatile} disables this type of optimization.
8364 @example
8365 void do_print(uint32_t dwSomeValue)
8367    uint32_t dwRes;
8369    for (uint32_t x=0; x < 5; x++)
8370    @{
8371       // Assumes dwSomeValue is not zero.
8372       asm ("bsfl %1,%0"
8373         : "=r" (dwRes)
8374         : "r" (dwSomeValue)
8375         : "cc");
8377       printf("%u: %u %u\n", x, dwSomeValue, dwRes);
8378    @}
8380 @end example
8382 The following example demonstrates a case where you need to use the 
8383 @code{volatile} qualifier. 
8384 It uses the x86 @code{rdtsc} instruction, which reads 
8385 the computer's time-stamp counter. Without the @code{volatile} qualifier, 
8386 the optimizers might assume that the @code{asm} block will always return the 
8387 same value and therefore optimize away the second call.
8389 @example
8390 uint64_t msr;
8392 asm volatile ( "rdtsc\n\t"    // Returns the time in EDX:EAX.
8393         "shl $32, %%rdx\n\t"  // Shift the upper bits left.
8394         "or %%rdx, %0"        // 'Or' in the lower bits.
8395         : "=a" (msr)
8396         : 
8397         : "rdx");
8399 printf("msr: %llx\n", msr);
8401 // Do other work...
8403 // Reprint the timestamp
8404 asm volatile ( "rdtsc\n\t"    // Returns the time in EDX:EAX.
8405         "shl $32, %%rdx\n\t"  // Shift the upper bits left.
8406         "or %%rdx, %0"        // 'Or' in the lower bits.
8407         : "=a" (msr)
8408         : 
8409         : "rdx");
8411 printf("msr: %llx\n", msr);
8412 @end example
8414 GCC's optimizers do not treat this code like the non-volatile code in the 
8415 earlier examples. They do not move it out of loops or omit it on the 
8416 assumption that the result from a previous call is still valid.
8418 Note that the compiler can move even volatile @code{asm} instructions relative 
8419 to other code, including across jump instructions. For example, on many 
8420 targets there is a system register that controls the rounding mode of 
8421 floating-point operations. Setting it with a volatile @code{asm}, as in the 
8422 following PowerPC example, does not work reliably.
8424 @example
8425 asm volatile("mtfsf 255, %0" : : "f" (fpenv));
8426 sum = x + y;
8427 @end example
8429 The compiler may move the addition back before the volatile @code{asm}. To 
8430 make it work as expected, add an artificial dependency to the @code{asm} by 
8431 referencing a variable in the subsequent code, for example: 
8433 @example
8434 asm volatile ("mtfsf 255,%1" : "=X" (sum) : "f" (fpenv));
8435 sum = x + y;
8436 @end example
8438 Under certain circumstances, GCC may duplicate (or remove duplicates of) your 
8439 assembly code when optimizing. This can lead to unexpected duplicate symbol 
8440 errors during compilation if your asm code defines symbols or labels. 
8441 Using @samp{%=} 
8442 (@pxref{AssemblerTemplate}) may help resolve this problem.
8444 @anchor{AssemblerTemplate}
8445 @subsubsection Assembler Template
8446 @cindex @code{asm} assembler template
8448 An assembler template is a literal string containing assembler instructions.
8449 The compiler replaces tokens in the template that refer 
8450 to inputs, outputs, and goto labels,
8451 and then outputs the resulting string to the assembler. The 
8452 string can contain any instructions recognized by the assembler, including 
8453 directives. GCC does not parse the assembler instructions 
8454 themselves and does not know what they mean or even whether they are valid 
8455 assembler input. However, it does count the statements 
8456 (@pxref{Size of an asm}).
8458 You may place multiple assembler instructions together in a single @code{asm} 
8459 string, separated by the characters normally used in assembly code for the 
8460 system. A combination that works in most places is a newline to break the 
8461 line, plus a tab character to move to the instruction field (written as 
8462 @samp{\n\t}). 
8463 Some assemblers allow semicolons as a line separator. However, note 
8464 that some assembler dialects use semicolons to start a comment. 
8466 Do not expect a sequence of @code{asm} statements to remain perfectly 
8467 consecutive after compilation, even when you are using the @code{volatile} 
8468 qualifier. If certain instructions need to remain consecutive in the output, 
8469 put them in a single multi-instruction asm statement.
8471 Accessing data from C programs without using input/output operands (such as 
8472 by using global symbols directly from the assembler template) may not work as 
8473 expected. Similarly, calling functions directly from an assembler template 
8474 requires a detailed understanding of the target assembler and ABI.
8476 Since GCC does not parse the assembler template,
8477 it has no visibility of any 
8478 symbols it references. This may result in GCC discarding those symbols as 
8479 unreferenced unless they are also listed as input, output, or goto operands.
8481 @subsubheading Special format strings
8483 In addition to the tokens described by the input, output, and goto operands, 
8484 these tokens have special meanings in the assembler template:
8486 @table @samp
8487 @item %% 
8488 Outputs a single @samp{%} into the assembler code.
8490 @item %= 
8491 Outputs a number that is unique to each instance of the @code{asm} 
8492 statement in the entire compilation. This option is useful when creating local 
8493 labels and referring to them multiple times in a single template that 
8494 generates multiple assembler instructions. 
8496 @item %@{
8497 @itemx %|
8498 @itemx %@}
8499 Outputs @samp{@{}, @samp{|}, and @samp{@}} characters (respectively)
8500 into the assembler code.  When unescaped, these characters have special
8501 meaning to indicate multiple assembler dialects, as described below.
8502 @end table
8504 @subsubheading Multiple assembler dialects in @code{asm} templates
8506 On targets such as x86, GCC supports multiple assembler dialects.
8507 The @option{-masm} option controls which dialect GCC uses as its 
8508 default for inline assembler. The target-specific documentation for the 
8509 @option{-masm} option contains the list of supported dialects, as well as the 
8510 default dialect if the option is not specified. This information may be 
8511 important to understand, since assembler code that works correctly when 
8512 compiled using one dialect will likely fail if compiled using another.
8513 @xref{x86 Options}.
8515 If your code needs to support multiple assembler dialects (for example, if 
8516 you are writing public headers that need to support a variety of compilation 
8517 options), use constructs of this form:
8519 @example
8520 @{ dialect0 | dialect1 | dialect2... @}
8521 @end example
8523 This construct outputs @code{dialect0} 
8524 when using dialect #0 to compile the code, 
8525 @code{dialect1} for dialect #1, etc. If there are fewer alternatives within the 
8526 braces than the number of dialects the compiler supports, the construct 
8527 outputs nothing.
8529 For example, if an x86 compiler supports two dialects
8530 (@samp{att}, @samp{intel}), an 
8531 assembler template such as this:
8533 @example
8534 "bt@{l %[Offset],%[Base] | %[Base],%[Offset]@}; jc %l2"
8535 @end example
8537 @noindent
8538 is equivalent to one of
8540 @example
8541 "btl %[Offset],%[Base] ; jc %l2"   @r{/* att dialect */}
8542 "bt %[Base],%[Offset]; jc %l2"     @r{/* intel dialect */}
8543 @end example
8545 Using that same compiler, this code:
8547 @example
8548 "xchg@{l@}\t@{%%@}ebx, %1"
8549 @end example
8551 @noindent
8552 corresponds to either
8554 @example
8555 "xchgl\t%%ebx, %1"                 @r{/* att dialect */}
8556 "xchg\tebx, %1"                    @r{/* intel dialect */}
8557 @end example
8559 There is no support for nesting dialect alternatives.
8561 @anchor{OutputOperands}
8562 @subsubsection Output Operands
8563 @cindex @code{asm} output operands
8565 An @code{asm} statement has zero or more output operands indicating the names
8566 of C variables modified by the assembler code.
8568 In this i386 example, @code{old} (referred to in the template string as 
8569 @code{%0}) and @code{*Base} (as @code{%1}) are outputs and @code{Offset} 
8570 (@code{%2}) is an input:
8572 @example
8573 bool old;
8575 __asm__ ("btsl %2,%1\n\t" // Turn on zero-based bit #Offset in Base.
8576          "sbb %0,%0"      // Use the CF to calculate old.
8577    : "=r" (old), "+rm" (*Base)
8578    : "Ir" (Offset)
8579    : "cc");
8581 return old;
8582 @end example
8584 Operands are separated by commas.  Each operand has this format:
8586 @example
8587 @r{[} [@var{asmSymbolicName}] @r{]} @var{constraint} (@var{cvariablename})
8588 @end example
8590 @table @var
8591 @item asmSymbolicName
8592 Specifies a symbolic name for the operand.
8593 Reference the name in the assembler template 
8594 by enclosing it in square brackets 
8595 (i.e. @samp{%[Value]}). The scope of the name is the @code{asm} statement 
8596 that contains the definition. Any valid C variable name is acceptable, 
8597 including names already defined in the surrounding code. No two operands 
8598 within the same @code{asm} statement can use the same symbolic name.
8600 When not using an @var{asmSymbolicName}, use the (zero-based) position
8601 of the operand 
8602 in the list of operands in the assembler template. For example if there are 
8603 three output operands, use @samp{%0} in the template to refer to the first, 
8604 @samp{%1} for the second, and @samp{%2} for the third. 
8606 @item constraint
8607 A string constant specifying constraints on the placement of the operand; 
8608 @xref{Constraints}, for details.
8610 Output constraints must begin with either @samp{=} (a variable overwriting an 
8611 existing value) or @samp{+} (when reading and writing). When using 
8612 @samp{=}, do not assume the location contains the existing value
8613 on entry to the @code{asm}, except 
8614 when the operand is tied to an input; @pxref{InputOperands,,Input Operands}.
8616 After the prefix, there must be one or more additional constraints 
8617 (@pxref{Constraints}) that describe where the value resides. Common 
8618 constraints include @samp{r} for register and @samp{m} for memory. 
8619 When you list more than one possible location (for example, @code{"=rm"}),
8620 the compiler chooses the most efficient one based on the current context. 
8621 If you list as many alternates as the @code{asm} statement allows, you permit 
8622 the optimizers to produce the best possible code. 
8623 If you must use a specific register, but your Machine Constraints do not
8624 provide sufficient control to select the specific register you want, 
8625 local register variables may provide a solution (@pxref{Local Register 
8626 Variables}).
8628 @item cvariablename
8629 Specifies a C lvalue expression to hold the output, typically a variable name.
8630 The enclosing parentheses are a required part of the syntax.
8632 @end table
8634 When the compiler selects the registers to use to 
8635 represent the output operands, it does not use any of the clobbered registers 
8636 (@pxref{Clobbers and Scratch Registers}).
8638 Output operand expressions must be lvalues. The compiler cannot check whether 
8639 the operands have data types that are reasonable for the instruction being 
8640 executed. For output expressions that are not directly addressable (for 
8641 example a bit-field), the constraint must allow a register. In that case, GCC 
8642 uses the register as the output of the @code{asm}, and then stores that 
8643 register into the output. 
8645 Operands using the @samp{+} constraint modifier count as two operands 
8646 (that is, both as input and output) towards the total maximum of 30 operands
8647 per @code{asm} statement.
8649 Use the @samp{&} constraint modifier (@pxref{Modifiers}) on all output
8650 operands that must not overlap an input.  Otherwise, 
8651 GCC may allocate the output operand in the same register as an unrelated 
8652 input operand, on the assumption that the assembler code consumes its 
8653 inputs before producing outputs. This assumption may be false if the assembler 
8654 code actually consists of more than one instruction.
8656 The same problem can occur if one output parameter (@var{a}) allows a register 
8657 constraint and another output parameter (@var{b}) allows a memory constraint.
8658 The code generated by GCC to access the memory address in @var{b} can contain
8659 registers which @emph{might} be shared by @var{a}, and GCC considers those 
8660 registers to be inputs to the asm. As above, GCC assumes that such input
8661 registers are consumed before any outputs are written. This assumption may 
8662 result in incorrect behavior if the asm writes to @var{a} before using 
8663 @var{b}. Combining the @samp{&} modifier with the register constraint on @var{a}
8664 ensures that modifying @var{a} does not affect the address referenced by 
8665 @var{b}. Otherwise, the location of @var{b} 
8666 is undefined if @var{a} is modified before using @var{b}.
8668 @code{asm} supports operand modifiers on operands (for example @samp{%k2} 
8669 instead of simply @samp{%2}). Typically these qualifiers are hardware 
8670 dependent. The list of supported modifiers for x86 is found at 
8671 @ref{x86Operandmodifiers,x86 Operand modifiers}.
8673 If the C code that follows the @code{asm} makes no use of any of the output 
8674 operands, use @code{volatile} for the @code{asm} statement to prevent the 
8675 optimizers from discarding the @code{asm} statement as unneeded 
8676 (see @ref{Volatile}).
8678 This code makes no use of the optional @var{asmSymbolicName}. Therefore it 
8679 references the first output operand as @code{%0} (were there a second, it 
8680 would be @code{%1}, etc). The number of the first input operand is one greater 
8681 than that of the last output operand. In this i386 example, that makes 
8682 @code{Mask} referenced as @code{%1}:
8684 @example
8685 uint32_t Mask = 1234;
8686 uint32_t Index;
8688   asm ("bsfl %1, %0"
8689      : "=r" (Index)
8690      : "r" (Mask)
8691      : "cc");
8692 @end example
8694 That code overwrites the variable @code{Index} (@samp{=}),
8695 placing the value in a register (@samp{r}).
8696 Using the generic @samp{r} constraint instead of a constraint for a specific 
8697 register allows the compiler to pick the register to use, which can result 
8698 in more efficient code. This may not be possible if an assembler instruction 
8699 requires a specific register.
8701 The following i386 example uses the @var{asmSymbolicName} syntax.
8702 It produces the 
8703 same result as the code above, but some may consider it more readable or more 
8704 maintainable since reordering index numbers is not necessary when adding or 
8705 removing operands. The names @code{aIndex} and @code{aMask}
8706 are only used in this example to emphasize which 
8707 names get used where.
8708 It is acceptable to reuse the names @code{Index} and @code{Mask}.
8710 @example
8711 uint32_t Mask = 1234;
8712 uint32_t Index;
8714   asm ("bsfl %[aMask], %[aIndex]"
8715      : [aIndex] "=r" (Index)
8716      : [aMask] "r" (Mask)
8717      : "cc");
8718 @end example
8720 Here are some more examples of output operands.
8722 @example
8723 uint32_t c = 1;
8724 uint32_t d;
8725 uint32_t *e = &c;
8727 asm ("mov %[e], %[d]"
8728    : [d] "=rm" (d)
8729    : [e] "rm" (*e));
8730 @end example
8732 Here, @code{d} may either be in a register or in memory. Since the compiler 
8733 might already have the current value of the @code{uint32_t} location
8734 pointed to by @code{e}
8735 in a register, you can enable it to choose the best location
8736 for @code{d} by specifying both constraints.
8738 @anchor{FlagOutputOperands}
8739 @subsubsection Flag Output Operands
8740 @cindex @code{asm} flag output operands
8742 Some targets have a special register that holds the ``flags'' for the
8743 result of an operation or comparison.  Normally, the contents of that
8744 register are either unmodifed by the asm, or the asm is considered to
8745 clobber the contents.
8747 On some targets, a special form of output operand exists by which
8748 conditions in the flags register may be outputs of the asm.  The set of
8749 conditions supported are target specific, but the general rule is that
8750 the output variable must be a scalar integer, and the value is boolean.
8751 When supported, the target defines the preprocessor symbol
8752 @code{__GCC_ASM_FLAG_OUTPUTS__}.
8754 Because of the special nature of the flag output operands, the constraint
8755 may not include alternatives.
8757 Most often, the target has only one flags register, and thus is an implied
8758 operand of many instructions.  In this case, the operand should not be
8759 referenced within the assembler template via @code{%0} etc, as there's
8760 no corresponding text in the assembly language.
8762 @table @asis
8763 @item x86 family
8764 The flag output constraints for the x86 family are of the form
8765 @samp{=@@cc@var{cond}} where @var{cond} is one of the standard
8766 conditions defined in the ISA manual for @code{j@var{cc}} or
8767 @code{set@var{cc}}.
8769 @table @code
8770 @item a
8771 ``above'' or unsigned greater than
8772 @item ae
8773 ``above or equal'' or unsigned greater than or equal
8774 @item b
8775 ``below'' or unsigned less than
8776 @item be
8777 ``below or equal'' or unsigned less than or equal
8778 @item c
8779 carry flag set
8780 @item e
8781 @itemx z
8782 ``equal'' or zero flag set
8783 @item g
8784 signed greater than
8785 @item ge
8786 signed greater than or equal
8787 @item l
8788 signed less than
8789 @item le
8790 signed less than or equal
8791 @item o
8792 overflow flag set
8793 @item p
8794 parity flag set
8795 @item s
8796 sign flag set
8797 @item na
8798 @itemx nae
8799 @itemx nb
8800 @itemx nbe
8801 @itemx nc
8802 @itemx ne
8803 @itemx ng
8804 @itemx nge
8805 @itemx nl
8806 @itemx nle
8807 @itemx no
8808 @itemx np
8809 @itemx ns
8810 @itemx nz
8811 ``not'' @var{flag}, or inverted versions of those above
8812 @end table
8814 @end table
8816 @anchor{InputOperands}
8817 @subsubsection Input Operands
8818 @cindex @code{asm} input operands
8819 @cindex @code{asm} expressions
8821 Input operands make values from C variables and expressions available to the 
8822 assembly code.
8824 Operands are separated by commas.  Each operand has this format:
8826 @example
8827 @r{[} [@var{asmSymbolicName}] @r{]} @var{constraint} (@var{cexpression})
8828 @end example
8830 @table @var
8831 @item asmSymbolicName
8832 Specifies a symbolic name for the operand.
8833 Reference the name in the assembler template 
8834 by enclosing it in square brackets 
8835 (i.e. @samp{%[Value]}). The scope of the name is the @code{asm} statement 
8836 that contains the definition. Any valid C variable name is acceptable, 
8837 including names already defined in the surrounding code. No two operands 
8838 within the same @code{asm} statement can use the same symbolic name.
8840 When not using an @var{asmSymbolicName}, use the (zero-based) position
8841 of the operand 
8842 in the list of operands in the assembler template. For example if there are
8843 two output operands and three inputs,
8844 use @samp{%2} in the template to refer to the first input operand,
8845 @samp{%3} for the second, and @samp{%4} for the third. 
8847 @item constraint
8848 A string constant specifying constraints on the placement of the operand; 
8849 @xref{Constraints}, for details.
8851 Input constraint strings may not begin with either @samp{=} or @samp{+}.
8852 When you list more than one possible location (for example, @samp{"irm"}), 
8853 the compiler chooses the most efficient one based on the current context.
8854 If you must use a specific register, but your Machine Constraints do not
8855 provide sufficient control to select the specific register you want, 
8856 local register variables may provide a solution (@pxref{Local Register 
8857 Variables}).
8859 Input constraints can also be digits (for example, @code{"0"}). This indicates 
8860 that the specified input must be in the same place as the output constraint 
8861 at the (zero-based) index in the output constraint list. 
8862 When using @var{asmSymbolicName} syntax for the output operands,
8863 you may use these names (enclosed in brackets @samp{[]}) instead of digits.
8865 @item cexpression
8866 This is the C variable or expression being passed to the @code{asm} statement 
8867 as input.  The enclosing parentheses are a required part of the syntax.
8869 @end table
8871 When the compiler selects the registers to use to represent the input 
8872 operands, it does not use any of the clobbered registers
8873 (@pxref{Clobbers and Scratch Registers}).
8875 If there are no output operands but there are input operands, place two 
8876 consecutive colons where the output operands would go:
8878 @example
8879 __asm__ ("some instructions"
8880    : /* No outputs. */
8881    : "r" (Offset / 8));
8882 @end example
8884 @strong{Warning:} Do @emph{not} modify the contents of input-only operands 
8885 (except for inputs tied to outputs). The compiler assumes that on exit from 
8886 the @code{asm} statement these operands contain the same values as they 
8887 had before executing the statement. 
8888 It is @emph{not} possible to use clobbers
8889 to inform the compiler that the values in these inputs are changing. One 
8890 common work-around is to tie the changing input variable to an output variable 
8891 that never gets used. Note, however, that if the code that follows the 
8892 @code{asm} statement makes no use of any of the output operands, the GCC 
8893 optimizers may discard the @code{asm} statement as unneeded 
8894 (see @ref{Volatile}).
8896 @code{asm} supports operand modifiers on operands (for example @samp{%k2} 
8897 instead of simply @samp{%2}). Typically these qualifiers are hardware 
8898 dependent. The list of supported modifiers for x86 is found at 
8899 @ref{x86Operandmodifiers,x86 Operand modifiers}.
8901 In this example using the fictitious @code{combine} instruction, the 
8902 constraint @code{"0"} for input operand 1 says that it must occupy the same 
8903 location as output operand 0. Only input operands may use numbers in 
8904 constraints, and they must each refer to an output operand. Only a number (or 
8905 the symbolic assembler name) in the constraint can guarantee that one operand 
8906 is in the same place as another. The mere fact that @code{foo} is the value of 
8907 both operands is not enough to guarantee that they are in the same place in 
8908 the generated assembler code.
8910 @example
8911 asm ("combine %2, %0" 
8912    : "=r" (foo) 
8913    : "0" (foo), "g" (bar));
8914 @end example
8916 Here is an example using symbolic names.
8918 @example
8919 asm ("cmoveq %1, %2, %[result]" 
8920    : [result] "=r"(result) 
8921    : "r" (test), "r" (new), "[result]" (old));
8922 @end example
8924 @anchor{Clobbers and Scratch Registers}
8925 @subsubsection Clobbers and Scratch Registers
8926 @cindex @code{asm} clobbers
8927 @cindex @code{asm} scratch registers
8929 While the compiler is aware of changes to entries listed in the output 
8930 operands, the inline @code{asm} code may modify more than just the outputs. For 
8931 example, calculations may require additional registers, or the processor may 
8932 overwrite a register as a side effect of a particular assembler instruction. 
8933 In order to inform the compiler of these changes, list them in the clobber 
8934 list. Clobber list items are either register names or the special clobbers 
8935 (listed below). Each clobber list item is a string constant 
8936 enclosed in double quotes and separated by commas.
8938 Clobber descriptions may not in any way overlap with an input or output 
8939 operand. For example, you may not have an operand describing a register class 
8940 with one member when listing that register in the clobber list. Variables 
8941 declared to live in specific registers (@pxref{Explicit Register 
8942 Variables}) and used 
8943 as @code{asm} input or output operands must have no part mentioned in the 
8944 clobber description. In particular, there is no way to specify that input 
8945 operands get modified without also specifying them as output operands.
8947 When the compiler selects which registers to use to represent input and output 
8948 operands, it does not use any of the clobbered registers. As a result, 
8949 clobbered registers are available for any use in the assembler code.
8951 Here is a realistic example for the VAX showing the use of clobbered 
8952 registers: 
8954 @example
8955 asm volatile ("movc3 %0, %1, %2"
8956                    : /* No outputs. */
8957                    : "g" (from), "g" (to), "g" (count)
8958                    : "r0", "r1", "r2", "r3", "r4", "r5", "memory");
8959 @end example
8961 Also, there are two special clobber arguments:
8963 @table @code
8964 @item "cc"
8965 The @code{"cc"} clobber indicates that the assembler code modifies the flags 
8966 register. On some machines, GCC represents the condition codes as a specific 
8967 hardware register; @code{"cc"} serves to name this register.
8968 On other machines, condition code handling is different, 
8969 and specifying @code{"cc"} has no effect. But 
8970 it is valid no matter what the target.
8972 @item "memory"
8973 The @code{"memory"} clobber tells the compiler that the assembly code
8974 performs memory 
8975 reads or writes to items other than those listed in the input and output 
8976 operands (for example, accessing the memory pointed to by one of the input 
8977 parameters). To ensure memory contains correct values, GCC may need to flush 
8978 specific register values to memory before executing the @code{asm}. Further, 
8979 the compiler does not assume that any values read from memory before an 
8980 @code{asm} remain unchanged after that @code{asm}; it reloads them as 
8981 needed.  
8982 Using the @code{"memory"} clobber effectively forms a read/write
8983 memory barrier for the compiler.
8985 Note that this clobber does not prevent the @emph{processor} from doing 
8986 speculative reads past the @code{asm} statement. To prevent that, you need 
8987 processor-specific fence instructions.
8989 @end table
8991 Flushing registers to memory has performance implications and may be
8992 an issue for time-sensitive code.  You can provide better information
8993 to GCC to avoid this, as shown in the following examples.  At a
8994 minimum, aliasing rules allow GCC to know what memory @emph{doesn't}
8995 need to be flushed.
8997 Here is a fictitious sum of squares instruction, that takes two
8998 pointers to floating point values in memory and produces a floating
8999 point register output.
9000 Notice that @code{x}, and @code{y} both appear twice in the @code{asm}
9001 parameters, once to specify memory accessed, and once to specify a
9002 base register used by the @code{asm}.  You won't normally be wasting a
9003 register by doing this as GCC can use the same register for both
9004 purposes.  However, it would be foolish to use both @code{%1} and
9005 @code{%3} for @code{x} in this @code{asm} and expect them to be the
9006 same.  In fact, @code{%3} may well not be a register.  It might be a
9007 symbolic memory reference to the object pointed to by @code{x}.
9009 @smallexample
9010 asm ("sumsq %0, %1, %2"
9011      : "+f" (result)
9012      : "r" (x), "r" (y), "m" (*x), "m" (*y));
9013 @end smallexample
9015 Here is a fictitious @code{*z++ = *x++ * *y++} instruction.
9016 Notice that the @code{x}, @code{y} and @code{z} pointer registers
9017 must be specified as input/output because the @code{asm} modifies
9018 them.
9020 @smallexample
9021 asm ("vecmul %0, %1, %2"
9022      : "+r" (z), "+r" (x), "+r" (y), "=m" (*z)
9023      : "m" (*x), "m" (*y));
9024 @end smallexample
9026 An x86 example where the string memory argument is of unknown length.
9028 @smallexample
9029 asm("repne scasb"
9030     : "=c" (count), "+D" (p)
9031     : "m" (*(const char (*)[]) p), "0" (-1), "a" (0));
9032 @end smallexample
9034 If you know the above will only be reading a ten byte array then you
9035 could instead use a memory input like:
9036 @code{"m" (*(const char (*)[10]) p)}.
9038 Here is an example of a PowerPC vector scale implemented in assembly,
9039 complete with vector and condition code clobbers, and some initialized
9040 offset registers that are unchanged by the @code{asm}.
9042 @smallexample
9043 void
9044 dscal (size_t n, double *x, double alpha)
9046   asm ("/* lots of asm here */"
9047        : "+m" (*(double (*)[n]) x), "+&r" (n), "+b" (x)
9048        : "d" (alpha), "b" (32), "b" (48), "b" (64),
9049          "b" (80), "b" (96), "b" (112)
9050        : "cr0",
9051          "vs32","vs33","vs34","vs35","vs36","vs37","vs38","vs39",
9052          "vs40","vs41","vs42","vs43","vs44","vs45","vs46","vs47");
9054 @end smallexample
9056 Rather than allocating fixed registers via clobbers to provide scratch
9057 registers for an @code{asm} statement, an alternative is to define a
9058 variable and make it an early-clobber output as with @code{a2} and
9059 @code{a3} in the example below.  This gives the compiler register
9060 allocator more freedom.  You can also define a variable and make it an
9061 output tied to an input as with @code{a0} and @code{a1}, tied
9062 respectively to @code{ap} and @code{lda}.  Of course, with tied
9063 outputs your @code{asm} can't use the input value after modifying the
9064 output register since they are one and the same register.  What's
9065 more, if you omit the early-clobber on the output, it is possible that
9066 GCC might allocate the same register to another of the inputs if GCC
9067 could prove they had the same value on entry to the @code{asm}.  This
9068 is why @code{a1} has an early-clobber.  Its tied input, @code{lda}
9069 might conceivably be known to have the value 16 and without an
9070 early-clobber share the same register as @code{%11}.  On the other
9071 hand, @code{ap} can't be the same as any of the other inputs, so an
9072 early-clobber on @code{a0} is not needed.  It is also not desirable in
9073 this case.  An early-clobber on @code{a0} would cause GCC to allocate
9074 a separate register for the @code{"m" (*(const double (*)[]) ap)}
9075 input.  Note that tying an input to an output is the way to set up an
9076 initialized temporary register modified by an @code{asm} statement.
9077 An input not tied to an output is assumed by GCC to be unchanged, for
9078 example @code{"b" (16)} below sets up @code{%11} to 16, and GCC might
9079 use that register in following code if the value 16 happened to be
9080 needed.  You can even use a normal @code{asm} output for a scratch if
9081 all inputs that might share the same register are consumed before the
9082 scratch is used.  The VSX registers clobbered by the @code{asm}
9083 statement could have used this technique except for GCC's limit on the
9084 number of @code{asm} parameters.
9086 @smallexample
9087 static void
9088 dgemv_kernel_4x4 (long n, const double *ap, long lda,
9089                   const double *x, double *y, double alpha)
9091   double *a0;
9092   double *a1;
9093   double *a2;
9094   double *a3;
9096   __asm__
9097     (
9098      /* lots of asm here */
9099      "#n=%1 ap=%8=%12 lda=%13 x=%7=%10 y=%0=%2 alpha=%9 o16=%11\n"
9100      "#a0=%3 a1=%4 a2=%5 a3=%6"
9101      :
9102        "+m" (*(double (*)[n]) y),
9103        "+&r" (n),       // 1
9104        "+b" (y),        // 2
9105        "=b" (a0),       // 3
9106        "=&b" (a1),      // 4
9107        "=&b" (a2),      // 5
9108        "=&b" (a3)       // 6
9109      :
9110        "m" (*(const double (*)[n]) x),
9111        "m" (*(const double (*)[]) ap),
9112        "d" (alpha),     // 9
9113        "r" (x),         // 10
9114        "b" (16),        // 11
9115        "3" (ap),        // 12
9116        "4" (lda)        // 13
9117      :
9118        "cr0",
9119        "vs32","vs33","vs34","vs35","vs36","vs37",
9120        "vs40","vs41","vs42","vs43","vs44","vs45","vs46","vs47"
9121      );
9123 @end smallexample
9125 @anchor{GotoLabels}
9126 @subsubsection Goto Labels
9127 @cindex @code{asm} goto labels
9129 @code{asm goto} allows assembly code to jump to one or more C labels.  The
9130 @var{GotoLabels} section in an @code{asm goto} statement contains 
9131 a comma-separated 
9132 list of all C labels to which the assembler code may jump. GCC assumes that 
9133 @code{asm} execution falls through to the next statement (if this is not the 
9134 case, consider using the @code{__builtin_unreachable} intrinsic after the 
9135 @code{asm} statement). Optimization of @code{asm goto} may be improved by 
9136 using the @code{hot} and @code{cold} label attributes (@pxref{Label 
9137 Attributes}).
9139 An @code{asm goto} statement cannot have outputs.
9140 This is due to an internal restriction of 
9141 the compiler: control transfer instructions cannot have outputs. 
9142 If the assembler code does modify anything, use the @code{"memory"} clobber 
9143 to force the 
9144 optimizers to flush all register values to memory and reload them if 
9145 necessary after the @code{asm} statement.
9147 Also note that an @code{asm goto} statement is always implicitly
9148 considered volatile.
9150 To reference a label in the assembler template,
9151 prefix it with @samp{%l} (lowercase @samp{L}) followed 
9152 by its (zero-based) position in @var{GotoLabels} plus the number of input 
9153 operands.  For example, if the @code{asm} has three inputs and references two 
9154 labels, refer to the first label as @samp{%l3} and the second as @samp{%l4}).
9156 Alternately, you can reference labels using the actual C label name enclosed
9157 in brackets.  For example, to reference a label named @code{carry}, you can
9158 use @samp{%l[carry]}.  The label must still be listed in the @var{GotoLabels}
9159 section when using this approach.
9161 Here is an example of @code{asm goto} for i386:
9163 @example
9164 asm goto (
9165     "btl %1, %0\n\t"
9166     "jc %l2"
9167     : /* No outputs. */
9168     : "r" (p1), "r" (p2) 
9169     : "cc" 
9170     : carry);
9172 return 0;
9174 carry:
9175 return 1;
9176 @end example
9178 The following example shows an @code{asm goto} that uses a memory clobber.
9180 @example
9181 int frob(int x)
9183   int y;
9184   asm goto ("frob %%r5, %1; jc %l[error]; mov (%2), %%r5"
9185             : /* No outputs. */
9186             : "r"(x), "r"(&y)
9187             : "r5", "memory" 
9188             : error);
9189   return y;
9190 error:
9191   return -1;
9193 @end example
9195 @anchor{x86Operandmodifiers}
9196 @subsubsection x86 Operand Modifiers
9198 References to input, output, and goto operands in the assembler template
9199 of extended @code{asm} statements can use 
9200 modifiers to affect the way the operands are formatted in 
9201 the code output to the assembler. For example, the 
9202 following code uses the @samp{h} and @samp{b} modifiers for x86:
9204 @example
9205 uint16_t  num;
9206 asm volatile ("xchg %h0, %b0" : "+a" (num) );
9207 @end example
9209 @noindent
9210 These modifiers generate this assembler code:
9212 @example
9213 xchg %ah, %al
9214 @end example
9216 The rest of this discussion uses the following code for illustrative purposes.
9218 @example
9219 int main()
9221    int iInt = 1;
9223 top:
9225    asm volatile goto ("some assembler instructions here"
9226    : /* No outputs. */
9227    : "q" (iInt), "X" (sizeof(unsigned char) + 1)
9228    : /* No clobbers. */
9229    : top);
9231 @end example
9233 With no modifiers, this is what the output from the operands would be for the 
9234 @samp{att} and @samp{intel} dialects of assembler:
9236 @multitable {Operand} {$.L2} {OFFSET FLAT:.L2}
9237 @headitem Operand @tab @samp{att} @tab @samp{intel}
9238 @item @code{%0}
9239 @tab @code{%eax}
9240 @tab @code{eax}
9241 @item @code{%1}
9242 @tab @code{$2}
9243 @tab @code{2}
9244 @item @code{%2}
9245 @tab @code{$.L2}
9246 @tab @code{OFFSET FLAT:.L2}
9247 @end multitable
9249 The table below shows the list of supported modifiers and their effects.
9251 @multitable {Modifier} {Print the opcode suffix for the size of th} {Operand} {@samp{att}} {@samp{intel}}
9252 @headitem Modifier @tab Description @tab Operand @tab @samp{att} @tab @samp{intel}
9253 @item @code{z}
9254 @tab Print the opcode suffix for the size of the current integer operand (one of @code{b}/@code{w}/@code{l}/@code{q}).
9255 @tab @code{%z0}
9256 @tab @code{l}
9257 @tab 
9258 @item @code{b}
9259 @tab Print the QImode name of the register.
9260 @tab @code{%b0}
9261 @tab @code{%al}
9262 @tab @code{al}
9263 @item @code{h}
9264 @tab Print the QImode name for a ``high'' register.
9265 @tab @code{%h0}
9266 @tab @code{%ah}
9267 @tab @code{ah}
9268 @item @code{w}
9269 @tab Print the HImode name of the register.
9270 @tab @code{%w0}
9271 @tab @code{%ax}
9272 @tab @code{ax}
9273 @item @code{k}
9274 @tab Print the SImode name of the register.
9275 @tab @code{%k0}
9276 @tab @code{%eax}
9277 @tab @code{eax}
9278 @item @code{q}
9279 @tab Print the DImode name of the register.
9280 @tab @code{%q0}
9281 @tab @code{%rax}
9282 @tab @code{rax}
9283 @item @code{l}
9284 @tab Print the label name with no punctuation.
9285 @tab @code{%l2}
9286 @tab @code{.L2}
9287 @tab @code{.L2}
9288 @item @code{c}
9289 @tab Require a constant operand and print the constant expression with no punctuation.
9290 @tab @code{%c1}
9291 @tab @code{2}
9292 @tab @code{2}
9293 @end multitable
9295 @code{V} is a special modifier which prints the name of the full integer
9296 register without @code{%}.
9298 @anchor{x86floatingpointasmoperands}
9299 @subsubsection x86 Floating-Point @code{asm} Operands
9301 On x86 targets, there are several rules on the usage of stack-like registers
9302 in the operands of an @code{asm}.  These rules apply only to the operands
9303 that are stack-like registers:
9305 @enumerate
9306 @item
9307 Given a set of input registers that die in an @code{asm}, it is
9308 necessary to know which are implicitly popped by the @code{asm}, and
9309 which must be explicitly popped by GCC@.
9311 An input register that is implicitly popped by the @code{asm} must be
9312 explicitly clobbered, unless it is constrained to match an
9313 output operand.
9315 @item
9316 For any input register that is implicitly popped by an @code{asm}, it is
9317 necessary to know how to adjust the stack to compensate for the pop.
9318 If any non-popped input is closer to the top of the reg-stack than
9319 the implicitly popped register, it would not be possible to know what the
9320 stack looked like---it's not clear how the rest of the stack ``slides
9321 up''.
9323 All implicitly popped input registers must be closer to the top of
9324 the reg-stack than any input that is not implicitly popped.
9326 It is possible that if an input dies in an @code{asm}, the compiler might
9327 use the input register for an output reload.  Consider this example:
9329 @smallexample
9330 asm ("foo" : "=t" (a) : "f" (b));
9331 @end smallexample
9333 @noindent
9334 This code says that input @code{b} is not popped by the @code{asm}, and that
9335 the @code{asm} pushes a result onto the reg-stack, i.e., the stack is one
9336 deeper after the @code{asm} than it was before.  But, it is possible that
9337 reload may think that it can use the same register for both the input and
9338 the output.
9340 To prevent this from happening,
9341 if any input operand uses the @samp{f} constraint, all output register
9342 constraints must use the @samp{&} early-clobber modifier.
9344 The example above is correctly written as:
9346 @smallexample
9347 asm ("foo" : "=&t" (a) : "f" (b));
9348 @end smallexample
9350 @item
9351 Some operands need to be in particular places on the stack.  All
9352 output operands fall in this category---GCC has no other way to
9353 know which registers the outputs appear in unless you indicate
9354 this in the constraints.
9356 Output operands must specifically indicate which register an output
9357 appears in after an @code{asm}.  @samp{=f} is not allowed: the operand
9358 constraints must select a class with a single register.
9360 @item
9361 Output operands may not be ``inserted'' between existing stack registers.
9362 Since no 387 opcode uses a read/write operand, all output operands
9363 are dead before the @code{asm}, and are pushed by the @code{asm}.
9364 It makes no sense to push anywhere but the top of the reg-stack.
9366 Output operands must start at the top of the reg-stack: output
9367 operands may not ``skip'' a register.
9369 @item
9370 Some @code{asm} statements may need extra stack space for internal
9371 calculations.  This can be guaranteed by clobbering stack registers
9372 unrelated to the inputs and outputs.
9374 @end enumerate
9376 This @code{asm}
9377 takes one input, which is internally popped, and produces two outputs.
9379 @smallexample
9380 asm ("fsincos" : "=t" (cos), "=u" (sin) : "0" (inp));
9381 @end smallexample
9383 @noindent
9384 This @code{asm} takes two inputs, which are popped by the @code{fyl2xp1} opcode,
9385 and replaces them with one output.  The @code{st(1)} clobber is necessary 
9386 for the compiler to know that @code{fyl2xp1} pops both inputs.
9388 @smallexample
9389 asm ("fyl2xp1" : "=t" (result) : "0" (x), "u" (y) : "st(1)");
9390 @end smallexample
9392 @lowersections
9393 @include md.texi
9394 @raisesections
9396 @node Asm Labels
9397 @subsection Controlling Names Used in Assembler Code
9398 @cindex assembler names for identifiers
9399 @cindex names used in assembler code
9400 @cindex identifiers, names in assembler code
9402 You can specify the name to be used in the assembler code for a C
9403 function or variable by writing the @code{asm} (or @code{__asm__})
9404 keyword after the declarator.
9405 It is up to you to make sure that the assembler names you choose do not
9406 conflict with any other assembler symbols, or reference registers.
9408 @subsubheading Assembler names for data:
9410 This sample shows how to specify the assembler name for data:
9412 @smallexample
9413 int foo asm ("myfoo") = 2;
9414 @end smallexample
9416 @noindent
9417 This specifies that the name to be used for the variable @code{foo} in
9418 the assembler code should be @samp{myfoo} rather than the usual
9419 @samp{_foo}.
9421 On systems where an underscore is normally prepended to the name of a C
9422 variable, this feature allows you to define names for the
9423 linker that do not start with an underscore.
9425 GCC does not support using this feature with a non-static local variable 
9426 since such variables do not have assembler names.  If you are
9427 trying to put the variable in a particular register, see 
9428 @ref{Explicit Register Variables}.
9430 @subsubheading Assembler names for functions:
9432 To specify the assembler name for functions, write a declaration for the 
9433 function before its definition and put @code{asm} there, like this:
9435 @smallexample
9436 int func (int x, int y) asm ("MYFUNC");
9437      
9438 int func (int x, int y)
9440    /* @r{@dots{}} */
9441 @end smallexample
9443 @noindent
9444 This specifies that the name to be used for the function @code{func} in
9445 the assembler code should be @code{MYFUNC}.
9447 @node Explicit Register Variables
9448 @subsection Variables in Specified Registers
9449 @anchor{Explicit Reg Vars}
9450 @cindex explicit register variables
9451 @cindex variables in specified registers
9452 @cindex specified registers
9454 GNU C allows you to associate specific hardware registers with C 
9455 variables.  In almost all cases, allowing the compiler to assign
9456 registers produces the best code.  However under certain unusual
9457 circumstances, more precise control over the variable storage is 
9458 required.
9460 Both global and local variables can be associated with a register.  The
9461 consequences of performing this association are very different between
9462 the two, as explained in the sections below.
9464 @menu
9465 * Global Register Variables::   Variables declared at global scope.
9466 * Local Register Variables::    Variables declared within a function.
9467 @end menu
9469 @node Global Register Variables
9470 @subsubsection Defining Global Register Variables
9471 @anchor{Global Reg Vars}
9472 @cindex global register variables
9473 @cindex registers, global variables in
9474 @cindex registers, global allocation
9476 You can define a global register variable and associate it with a specified 
9477 register like this:
9479 @smallexample
9480 register int *foo asm ("r12");
9481 @end smallexample
9483 @noindent
9484 Here @code{r12} is the name of the register that should be used. Note that 
9485 this is the same syntax used for defining local register variables, but for 
9486 a global variable the declaration appears outside a function. The 
9487 @code{register} keyword is required, and cannot be combined with 
9488 @code{static}. The register name must be a valid register name for the
9489 target platform.
9491 Registers are a scarce resource on most systems and allowing the 
9492 compiler to manage their usage usually results in the best code. However, 
9493 under special circumstances it can make sense to reserve some globally.
9494 For example this may be useful in programs such as programming language 
9495 interpreters that have a couple of global variables that are accessed 
9496 very often.
9498 After defining a global register variable, for the current compilation
9499 unit:
9501 @itemize @bullet
9502 @item The register is reserved entirely for this use, and will not be 
9503 allocated for any other purpose.
9504 @item The register is not saved and restored by any functions.
9505 @item Stores into this register are never deleted even if they appear to be 
9506 dead, but references may be deleted, moved or simplified.
9507 @end itemize
9509 Note that these points @emph{only} apply to code that is compiled with the
9510 definition. The behavior of code that is merely linked in (for example 
9511 code from libraries) is not affected.
9513 If you want to recompile source files that do not actually use your global 
9514 register variable so they do not use the specified register for any other 
9515 purpose, you need not actually add the global register declaration to 
9516 their source code. It suffices to specify the compiler option 
9517 @option{-ffixed-@var{reg}} (@pxref{Code Gen Options}) to reserve the 
9518 register.
9520 @subsubheading Declaring the variable
9522 Global register variables can not have initial values, because an
9523 executable file has no means to supply initial contents for a register.
9525 When selecting a register, choose one that is normally saved and 
9526 restored by function calls on your machine. This ensures that code
9527 which is unaware of this reservation (such as library routines) will 
9528 restore it before returning.
9530 On machines with register windows, be sure to choose a global
9531 register that is not affected magically by the function call mechanism.
9533 @subsubheading Using the variable
9535 @cindex @code{qsort}, and global register variables
9536 When calling routines that are not aware of the reservation, be 
9537 cautious if those routines call back into code which uses them. As an 
9538 example, if you call the system library version of @code{qsort}, it may 
9539 clobber your registers during execution, but (if you have selected 
9540 appropriate registers) it will restore them before returning. However 
9541 it will @emph{not} restore them before calling @code{qsort}'s comparison 
9542 function. As a result, global values will not reliably be available to 
9543 the comparison function unless the @code{qsort} function itself is rebuilt.
9545 Similarly, it is not safe to access the global register variables from signal
9546 handlers or from more than one thread of control. Unless you recompile 
9547 them specially for the task at hand, the system library routines may 
9548 temporarily use the register for other things.
9550 @cindex register variable after @code{longjmp}
9551 @cindex global register after @code{longjmp}
9552 @cindex value after @code{longjmp}
9553 @findex longjmp
9554 @findex setjmp
9555 On most machines, @code{longjmp} restores to each global register
9556 variable the value it had at the time of the @code{setjmp}. On some
9557 machines, however, @code{longjmp} does not change the value of global
9558 register variables. To be portable, the function that called @code{setjmp}
9559 should make other arrangements to save the values of the global register
9560 variables, and to restore them in a @code{longjmp}. This way, the same
9561 thing happens regardless of what @code{longjmp} does.
9563 Eventually there may be a way of asking the compiler to choose a register 
9564 automatically, but first we need to figure out how it should choose and 
9565 how to enable you to guide the choice.  No solution is evident.
9567 @node Local Register Variables
9568 @subsubsection Specifying Registers for Local Variables
9569 @anchor{Local Reg Vars}
9570 @cindex local variables, specifying registers
9571 @cindex specifying registers for local variables
9572 @cindex registers for local variables
9574 You can define a local register variable and associate it with a specified 
9575 register like this:
9577 @smallexample
9578 register int *foo asm ("r12");
9579 @end smallexample
9581 @noindent
9582 Here @code{r12} is the name of the register that should be used.  Note
9583 that this is the same syntax used for defining global register variables, 
9584 but for a local variable the declaration appears within a function.  The 
9585 @code{register} keyword is required, and cannot be combined with 
9586 @code{static}.  The register name must be a valid register name for the
9587 target platform.
9589 As with global register variables, it is recommended that you choose 
9590 a register that is normally saved and restored by function calls on your 
9591 machine, so that calls to library routines will not clobber it.
9593 The only supported use for this feature is to specify registers
9594 for input and output operands when calling Extended @code{asm} 
9595 (@pxref{Extended Asm}).  This may be necessary if the constraints for a 
9596 particular machine don't provide sufficient control to select the desired 
9597 register.  To force an operand into a register, create a local variable 
9598 and specify the register name after the variable's declaration.  Then use 
9599 the local variable for the @code{asm} operand and specify any constraint 
9600 letter that matches the register:
9602 @smallexample
9603 register int *p1 asm ("r0") = @dots{};
9604 register int *p2 asm ("r1") = @dots{};
9605 register int *result asm ("r0");
9606 asm ("sysint" : "=r" (result) : "0" (p1), "r" (p2));
9607 @end smallexample
9609 @emph{Warning:} In the above example, be aware that a register (for example 
9610 @code{r0}) can be call-clobbered by subsequent code, including function 
9611 calls and library calls for arithmetic operators on other variables (for 
9612 example the initialization of @code{p2}).  In this case, use temporary 
9613 variables for expressions between the register assignments:
9615 @smallexample
9616 int t1 = @dots{};
9617 register int *p1 asm ("r0") = @dots{};
9618 register int *p2 asm ("r1") = t1;
9619 register int *result asm ("r0");
9620 asm ("sysint" : "=r" (result) : "0" (p1), "r" (p2));
9621 @end smallexample
9623 Defining a register variable does not reserve the register.  Other than
9624 when invoking the Extended @code{asm}, the contents of the specified 
9625 register are not guaranteed.  For this reason, the following uses 
9626 are explicitly @emph{not} supported.  If they appear to work, it is only 
9627 happenstance, and may stop working as intended due to (seemingly) 
9628 unrelated changes in surrounding code, or even minor changes in the 
9629 optimization of a future version of gcc:
9631 @itemize @bullet
9632 @item Passing parameters to or from Basic @code{asm}
9633 @item Passing parameters to or from Extended @code{asm} without using input 
9634 or output operands.
9635 @item Passing parameters to or from routines written in assembler (or
9636 other languages) using non-standard calling conventions.
9637 @end itemize
9639 Some developers use Local Register Variables in an attempt to improve 
9640 gcc's allocation of registers, especially in large functions.  In this 
9641 case the register name is essentially a hint to the register allocator.
9642 While in some instances this can generate better code, improvements are
9643 subject to the whims of the allocator/optimizers.  Since there are no
9644 guarantees that your improvements won't be lost, this usage of Local
9645 Register Variables is discouraged.
9647 On the MIPS platform, there is related use for local register variables 
9648 with slightly different characteristics (@pxref{MIPS Coprocessors,, 
9649 Defining coprocessor specifics for MIPS targets, gccint, 
9650 GNU Compiler Collection (GCC) Internals}).
9652 @node Size of an asm
9653 @subsection Size of an @code{asm}
9655 Some targets require that GCC track the size of each instruction used
9656 in order to generate correct code.  Because the final length of the
9657 code produced by an @code{asm} statement is only known by the
9658 assembler, GCC must make an estimate as to how big it will be.  It
9659 does this by counting the number of instructions in the pattern of the
9660 @code{asm} and multiplying that by the length of the longest
9661 instruction supported by that processor.  (When working out the number
9662 of instructions, it assumes that any occurrence of a newline or of
9663 whatever statement separator character is supported by the assembler --
9664 typically @samp{;} --- indicates the end of an instruction.)
9666 Normally, GCC's estimate is adequate to ensure that correct
9667 code is generated, but it is possible to confuse the compiler if you use
9668 pseudo instructions or assembler macros that expand into multiple real
9669 instructions, or if you use assembler directives that expand to more
9670 space in the object file than is needed for a single instruction.
9671 If this happens then the assembler may produce a diagnostic saying that
9672 a label is unreachable.
9674 @node Alternate Keywords
9675 @section Alternate Keywords
9676 @cindex alternate keywords
9677 @cindex keywords, alternate
9679 @option{-ansi} and the various @option{-std} options disable certain
9680 keywords.  This causes trouble when you want to use GNU C extensions, or
9681 a general-purpose header file that should be usable by all programs,
9682 including ISO C programs.  The keywords @code{asm}, @code{typeof} and
9683 @code{inline} are not available in programs compiled with
9684 @option{-ansi} or @option{-std} (although @code{inline} can be used in a
9685 program compiled with @option{-std=c99} or @option{-std=c11}).  The
9686 ISO C99 keyword
9687 @code{restrict} is only available when @option{-std=gnu99} (which will
9688 eventually be the default) or @option{-std=c99} (or the equivalent
9689 @option{-std=iso9899:1999}), or an option for a later standard
9690 version, is used.
9692 The way to solve these problems is to put @samp{__} at the beginning and
9693 end of each problematical keyword.  For example, use @code{__asm__}
9694 instead of @code{asm}, and @code{__inline__} instead of @code{inline}.
9696 Other C compilers won't accept these alternative keywords; if you want to
9697 compile with another compiler, you can define the alternate keywords as
9698 macros to replace them with the customary keywords.  It looks like this:
9700 @smallexample
9701 #ifndef __GNUC__
9702 #define __asm__ asm
9703 #endif
9704 @end smallexample
9706 @findex __extension__
9707 @opindex pedantic
9708 @option{-pedantic} and other options cause warnings for many GNU C extensions.
9709 You can
9710 prevent such warnings within one expression by writing
9711 @code{__extension__} before the expression.  @code{__extension__} has no
9712 effect aside from this.
9714 @node Incomplete Enums
9715 @section Incomplete @code{enum} Types
9717 You can define an @code{enum} tag without specifying its possible values.
9718 This results in an incomplete type, much like what you get if you write
9719 @code{struct foo} without describing the elements.  A later declaration
9720 that does specify the possible values completes the type.
9722 You cannot allocate variables or storage using the type while it is
9723 incomplete.  However, you can work with pointers to that type.
9725 This extension may not be very useful, but it makes the handling of
9726 @code{enum} more consistent with the way @code{struct} and @code{union}
9727 are handled.
9729 This extension is not supported by GNU C++.
9731 @node Function Names
9732 @section Function Names as Strings
9733 @cindex @code{__func__} identifier
9734 @cindex @code{__FUNCTION__} identifier
9735 @cindex @code{__PRETTY_FUNCTION__} identifier
9737 GCC provides three magic constants that hold the name of the current
9738 function as a string.  In C++11 and later modes, all three are treated
9739 as constant expressions and can be used in @code{constexpr} constexts.
9740 The first of these constants is @code{__func__}, which is part of
9741 the C99 standard:
9743 The identifier @code{__func__} is implicitly declared by the translator
9744 as if, immediately following the opening brace of each function
9745 definition, the declaration
9747 @smallexample
9748 static const char __func__[] = "function-name";
9749 @end smallexample
9751 @noindent
9752 appeared, where function-name is the name of the lexically-enclosing
9753 function.  This name is the unadorned name of the function.  As an
9754 extension, at file (or, in C++, namespace scope), @code{__func__}
9755 evaluates to the empty string.
9757 @code{__FUNCTION__} is another name for @code{__func__}, provided for
9758 backward compatibility with old versions of GCC.
9760 In C, @code{__PRETTY_FUNCTION__} is yet another name for
9761 @code{__func__}, except that at file (or, in C++, namespace scope),
9762 it evaluates to the string @code{"top level"}.  In addition, in C++,
9763 @code{__PRETTY_FUNCTION__} contains the signature of the function as
9764 well as its bare name.  For example, this program:
9766 @smallexample
9767 extern "C" int printf (const char *, ...);
9769 class a @{
9770  public:
9771   void sub (int i)
9772     @{
9773       printf ("__FUNCTION__ = %s\n", __FUNCTION__);
9774       printf ("__PRETTY_FUNCTION__ = %s\n", __PRETTY_FUNCTION__);
9775     @}
9779 main (void)
9781   a ax;
9782   ax.sub (0);
9783   return 0;
9785 @end smallexample
9787 @noindent
9788 gives this output:
9790 @smallexample
9791 __FUNCTION__ = sub
9792 __PRETTY_FUNCTION__ = void a::sub(int)
9793 @end smallexample
9795 These identifiers are variables, not preprocessor macros, and may not
9796 be used to initialize @code{char} arrays or be concatenated with string
9797 literals.
9799 @node Return Address
9800 @section Getting the Return or Frame Address of a Function
9802 These functions may be used to get information about the callers of a
9803 function.
9805 @deftypefn {Built-in Function} {void *} __builtin_return_address (unsigned int @var{level})
9806 This function returns the return address of the current function, or of
9807 one of its callers.  The @var{level} argument is number of frames to
9808 scan up the call stack.  A value of @code{0} yields the return address
9809 of the current function, a value of @code{1} yields the return address
9810 of the caller of the current function, and so forth.  When inlining
9811 the expected behavior is that the function returns the address of
9812 the function that is returned to.  To work around this behavior use
9813 the @code{noinline} function attribute.
9815 The @var{level} argument must be a constant integer.
9817 On some machines it may be impossible to determine the return address of
9818 any function other than the current one; in such cases, or when the top
9819 of the stack has been reached, this function returns @code{0} or a
9820 random value.  In addition, @code{__builtin_frame_address} may be used
9821 to determine if the top of the stack has been reached.
9823 Additional post-processing of the returned value may be needed, see
9824 @code{__builtin_extract_return_addr}.
9826 Calling this function with a nonzero argument can have unpredictable
9827 effects, including crashing the calling program.  As a result, calls
9828 that are considered unsafe are diagnosed when the @option{-Wframe-address}
9829 option is in effect.  Such calls should only be made in debugging
9830 situations.
9831 @end deftypefn
9833 @deftypefn {Built-in Function} {void *} __builtin_extract_return_addr (void *@var{addr})
9834 The address as returned by @code{__builtin_return_address} may have to be fed
9835 through this function to get the actual encoded address.  For example, on the
9836 31-bit S/390 platform the highest bit has to be masked out, or on SPARC
9837 platforms an offset has to be added for the true next instruction to be
9838 executed.
9840 If no fixup is needed, this function simply passes through @var{addr}.
9841 @end deftypefn
9843 @deftypefn {Built-in Function} {void *} __builtin_frob_return_address (void *@var{addr})
9844 This function does the reverse of @code{__builtin_extract_return_addr}.
9845 @end deftypefn
9847 @deftypefn {Built-in Function} {void *} __builtin_frame_address (unsigned int @var{level})
9848 This function is similar to @code{__builtin_return_address}, but it
9849 returns the address of the function frame rather than the return address
9850 of the function.  Calling @code{__builtin_frame_address} with a value of
9851 @code{0} yields the frame address of the current function, a value of
9852 @code{1} yields the frame address of the caller of the current function,
9853 and so forth.
9855 The frame is the area on the stack that holds local variables and saved
9856 registers.  The frame address is normally the address of the first word
9857 pushed on to the stack by the function.  However, the exact definition
9858 depends upon the processor and the calling convention.  If the processor
9859 has a dedicated frame pointer register, and the function has a frame,
9860 then @code{__builtin_frame_address} returns the value of the frame
9861 pointer register.
9863 On some machines it may be impossible to determine the frame address of
9864 any function other than the current one; in such cases, or when the top
9865 of the stack has been reached, this function returns @code{0} if
9866 the first frame pointer is properly initialized by the startup code.
9868 Calling this function with a nonzero argument can have unpredictable
9869 effects, including crashing the calling program.  As a result, calls
9870 that are considered unsafe are diagnosed when the @option{-Wframe-address}
9871 option is in effect.  Such calls should only be made in debugging
9872 situations.
9873 @end deftypefn
9875 @node Vector Extensions
9876 @section Using Vector Instructions through Built-in Functions
9878 On some targets, the instruction set contains SIMD vector instructions which
9879 operate on multiple values contained in one large register at the same time.
9880 For example, on the x86 the MMX, 3DNow!@: and SSE extensions can be used
9881 this way.
9883 The first step in using these extensions is to provide the necessary data
9884 types.  This should be done using an appropriate @code{typedef}:
9886 @smallexample
9887 typedef int v4si __attribute__ ((vector_size (16)));
9888 @end smallexample
9890 @noindent
9891 The @code{int} type specifies the base type, while the attribute specifies
9892 the vector size for the variable, measured in bytes.  For example, the
9893 declaration above causes the compiler to set the mode for the @code{v4si}
9894 type to be 16 bytes wide and divided into @code{int} sized units.  For
9895 a 32-bit @code{int} this means a vector of 4 units of 4 bytes, and the
9896 corresponding mode of @code{foo} is @acronym{V4SI}.
9898 The @code{vector_size} attribute is only applicable to integral and
9899 float scalars, although arrays, pointers, and function return values
9900 are allowed in conjunction with this construct. Only sizes that are
9901 a power of two are currently allowed.
9903 All the basic integer types can be used as base types, both as signed
9904 and as unsigned: @code{char}, @code{short}, @code{int}, @code{long},
9905 @code{long long}.  In addition, @code{float} and @code{double} can be
9906 used to build floating-point vector types.
9908 Specifying a combination that is not valid for the current architecture
9909 causes GCC to synthesize the instructions using a narrower mode.
9910 For example, if you specify a variable of type @code{V4SI} and your
9911 architecture does not allow for this specific SIMD type, GCC
9912 produces code that uses 4 @code{SIs}.
9914 The types defined in this manner can be used with a subset of normal C
9915 operations.  Currently, GCC allows using the following operators
9916 on these types: @code{+, -, *, /, unary minus, ^, |, &, ~, %}@.
9918 The operations behave like C++ @code{valarrays}.  Addition is defined as
9919 the addition of the corresponding elements of the operands.  For
9920 example, in the code below, each of the 4 elements in @var{a} is
9921 added to the corresponding 4 elements in @var{b} and the resulting
9922 vector is stored in @var{c}.
9924 @smallexample
9925 typedef int v4si __attribute__ ((vector_size (16)));
9927 v4si a, b, c;
9929 c = a + b;
9930 @end smallexample
9932 Subtraction, multiplication, division, and the logical operations
9933 operate in a similar manner.  Likewise, the result of using the unary
9934 minus or complement operators on a vector type is a vector whose
9935 elements are the negative or complemented values of the corresponding
9936 elements in the operand.
9938 It is possible to use shifting operators @code{<<}, @code{>>} on
9939 integer-type vectors. The operation is defined as following: @code{@{a0,
9940 a1, @dots{}, an@} >> @{b0, b1, @dots{}, bn@} == @{a0 >> b0, a1 >> b1,
9941 @dots{}, an >> bn@}}@. Vector operands must have the same number of
9942 elements. 
9944 For convenience, it is allowed to use a binary vector operation
9945 where one operand is a scalar. In that case the compiler transforms
9946 the scalar operand into a vector where each element is the scalar from
9947 the operation. The transformation happens only if the scalar could be
9948 safely converted to the vector-element type.
9949 Consider the following code.
9951 @smallexample
9952 typedef int v4si __attribute__ ((vector_size (16)));
9954 v4si a, b, c;
9955 long l;
9957 a = b + 1;    /* a = b + @{1,1,1,1@}; */
9958 a = 2 * b;    /* a = @{2,2,2,2@} * b; */
9960 a = l + a;    /* Error, cannot convert long to int. */
9961 @end smallexample
9963 Vectors can be subscripted as if the vector were an array with
9964 the same number of elements and base type.  Out of bound accesses
9965 invoke undefined behavior at run time.  Warnings for out of bound
9966 accesses for vector subscription can be enabled with
9967 @option{-Warray-bounds}.
9969 Vector comparison is supported with standard comparison
9970 operators: @code{==, !=, <, <=, >, >=}. Comparison operands can be
9971 vector expressions of integer-type or real-type. Comparison between
9972 integer-type vectors and real-type vectors are not supported.  The
9973 result of the comparison is a vector of the same width and number of
9974 elements as the comparison operands with a signed integral element
9975 type.
9977 Vectors are compared element-wise producing 0 when comparison is false
9978 and -1 (constant of the appropriate type where all bits are set)
9979 otherwise. Consider the following example.
9981 @smallexample
9982 typedef int v4si __attribute__ ((vector_size (16)));
9984 v4si a = @{1,2,3,4@};
9985 v4si b = @{3,2,1,4@};
9986 v4si c;
9988 c = a >  b;     /* The result would be @{0, 0,-1, 0@}  */
9989 c = a == b;     /* The result would be @{0,-1, 0,-1@}  */
9990 @end smallexample
9992 In C++, the ternary operator @code{?:} is available. @code{a?b:c}, where
9993 @code{b} and @code{c} are vectors of the same type and @code{a} is an
9994 integer vector with the same number of elements of the same size as @code{b}
9995 and @code{c}, computes all three arguments and creates a vector
9996 @code{@{a[0]?b[0]:c[0], a[1]?b[1]:c[1], @dots{}@}}.  Note that unlike in
9997 OpenCL, @code{a} is thus interpreted as @code{a != 0} and not @code{a < 0}.
9998 As in the case of binary operations, this syntax is also accepted when
9999 one of @code{b} or @code{c} is a scalar that is then transformed into a
10000 vector. If both @code{b} and @code{c} are scalars and the type of
10001 @code{true?b:c} has the same size as the element type of @code{a}, then
10002 @code{b} and @code{c} are converted to a vector type whose elements have
10003 this type and with the same number of elements as @code{a}.
10005 In C++, the logic operators @code{!, &&, ||} are available for vectors.
10006 @code{!v} is equivalent to @code{v == 0}, @code{a && b} is equivalent to
10007 @code{a!=0 & b!=0} and @code{a || b} is equivalent to @code{a!=0 | b!=0}.
10008 For mixed operations between a scalar @code{s} and a vector @code{v},
10009 @code{s && v} is equivalent to @code{s?v!=0:0} (the evaluation is
10010 short-circuit) and @code{v && s} is equivalent to @code{v!=0 & (s?-1:0)}.
10012 @findex __builtin_shuffle
10013 Vector shuffling is available using functions
10014 @code{__builtin_shuffle (vec, mask)} and
10015 @code{__builtin_shuffle (vec0, vec1, mask)}.
10016 Both functions construct a permutation of elements from one or two
10017 vectors and return a vector of the same type as the input vector(s).
10018 The @var{mask} is an integral vector with the same width (@var{W})
10019 and element count (@var{N}) as the output vector.
10021 The elements of the input vectors are numbered in memory ordering of
10022 @var{vec0} beginning at 0 and @var{vec1} beginning at @var{N}.  The
10023 elements of @var{mask} are considered modulo @var{N} in the single-operand
10024 case and modulo @math{2*@var{N}} in the two-operand case.
10026 Consider the following example,
10028 @smallexample
10029 typedef int v4si __attribute__ ((vector_size (16)));
10031 v4si a = @{1,2,3,4@};
10032 v4si b = @{5,6,7,8@};
10033 v4si mask1 = @{0,1,1,3@};
10034 v4si mask2 = @{0,4,2,5@};
10035 v4si res;
10037 res = __builtin_shuffle (a, mask1);       /* res is @{1,2,2,4@}  */
10038 res = __builtin_shuffle (a, b, mask2);    /* res is @{1,5,3,6@}  */
10039 @end smallexample
10041 Note that @code{__builtin_shuffle} is intentionally semantically
10042 compatible with the OpenCL @code{shuffle} and @code{shuffle2} functions.
10044 You can declare variables and use them in function calls and returns, as
10045 well as in assignments and some casts.  You can specify a vector type as
10046 a return type for a function.  Vector types can also be used as function
10047 arguments.  It is possible to cast from one vector type to another,
10048 provided they are of the same size (in fact, you can also cast vectors
10049 to and from other datatypes of the same size).
10051 You cannot operate between vectors of different lengths or different
10052 signedness without a cast.
10054 @node Offsetof
10055 @section Support for @code{offsetof}
10056 @findex __builtin_offsetof
10058 GCC implements for both C and C++ a syntactic extension to implement
10059 the @code{offsetof} macro.
10061 @smallexample
10062 primary:
10063         "__builtin_offsetof" "(" @code{typename} "," offsetof_member_designator ")"
10065 offsetof_member_designator:
10066           @code{identifier}
10067         | offsetof_member_designator "." @code{identifier}
10068         | offsetof_member_designator "[" @code{expr} "]"
10069 @end smallexample
10071 This extension is sufficient such that
10073 @smallexample
10074 #define offsetof(@var{type}, @var{member})  __builtin_offsetof (@var{type}, @var{member})
10075 @end smallexample
10077 @noindent
10078 is a suitable definition of the @code{offsetof} macro.  In C++, @var{type}
10079 may be dependent.  In either case, @var{member} may consist of a single
10080 identifier, or a sequence of member accesses and array references.
10082 @node __sync Builtins
10083 @section Legacy @code{__sync} Built-in Functions for Atomic Memory Access
10085 The following built-in functions
10086 are intended to be compatible with those described
10087 in the @cite{Intel Itanium Processor-specific Application Binary Interface},
10088 section 7.4.  As such, they depart from normal GCC practice by not using
10089 the @samp{__builtin_} prefix and also by being overloaded so that they
10090 work on multiple types.
10092 The definition given in the Intel documentation allows only for the use of
10093 the types @code{int}, @code{long}, @code{long long} or their unsigned
10094 counterparts.  GCC allows any scalar type that is 1, 2, 4 or 8 bytes in
10095 size other than the C type @code{_Bool} or the C++ type @code{bool}.
10096 Operations on pointer arguments are performed as if the operands were
10097 of the @code{uintptr_t} type.  That is, they are not scaled by the size
10098 of the type to which the pointer points.
10100 These functions are implemented in terms of the @samp{__atomic}
10101 builtins (@pxref{__atomic Builtins}).  They should not be used for new
10102 code which should use the @samp{__atomic} builtins instead.
10104 Not all operations are supported by all target processors.  If a particular
10105 operation cannot be implemented on the target processor, a warning is
10106 generated and a call to an external function is generated.  The external
10107 function carries the same name as the built-in version,
10108 with an additional suffix
10109 @samp{_@var{n}} where @var{n} is the size of the data type.
10111 @c ??? Should we have a mechanism to suppress this warning?  This is almost
10112 @c useful for implementing the operation under the control of an external
10113 @c mutex.
10115 In most cases, these built-in functions are considered a @dfn{full barrier}.
10116 That is,
10117 no memory operand is moved across the operation, either forward or
10118 backward.  Further, instructions are issued as necessary to prevent the
10119 processor from speculating loads across the operation and from queuing stores
10120 after the operation.
10122 All of the routines are described in the Intel documentation to take
10123 ``an optional list of variables protected by the memory barrier''.  It's
10124 not clear what is meant by that; it could mean that @emph{only} the
10125 listed variables are protected, or it could mean a list of additional
10126 variables to be protected.  The list is ignored by GCC which treats it as
10127 empty.  GCC interprets an empty list as meaning that all globally
10128 accessible variables should be protected.
10130 @table @code
10131 @item @var{type} __sync_fetch_and_add (@var{type} *ptr, @var{type} value, ...)
10132 @itemx @var{type} __sync_fetch_and_sub (@var{type} *ptr, @var{type} value, ...)
10133 @itemx @var{type} __sync_fetch_and_or (@var{type} *ptr, @var{type} value, ...)
10134 @itemx @var{type} __sync_fetch_and_and (@var{type} *ptr, @var{type} value, ...)
10135 @itemx @var{type} __sync_fetch_and_xor (@var{type} *ptr, @var{type} value, ...)
10136 @itemx @var{type} __sync_fetch_and_nand (@var{type} *ptr, @var{type} value, ...)
10137 @findex __sync_fetch_and_add
10138 @findex __sync_fetch_and_sub
10139 @findex __sync_fetch_and_or
10140 @findex __sync_fetch_and_and
10141 @findex __sync_fetch_and_xor
10142 @findex __sync_fetch_and_nand
10143 These built-in functions perform the operation suggested by the name, and
10144 returns the value that had previously been in memory.  That is, operations
10145 on integer operands have the following semantics.  Operations on pointer
10146 arguments are performed as if the operands were of the @code{uintptr_t}
10147 type.  That is, they are not scaled by the size of the type to which
10148 the pointer points.
10150 @smallexample
10151 @{ tmp = *ptr; *ptr @var{op}= value; return tmp; @}
10152 @{ tmp = *ptr; *ptr = ~(tmp & value); return tmp; @}   // nand
10153 @end smallexample
10155 The object pointed to by the first argument must be of integer or pointer
10156 type.  It must not be a boolean type.
10158 @emph{Note:} GCC 4.4 and later implement @code{__sync_fetch_and_nand}
10159 as @code{*ptr = ~(tmp & value)} instead of @code{*ptr = ~tmp & value}.
10161 @item @var{type} __sync_add_and_fetch (@var{type} *ptr, @var{type} value, ...)
10162 @itemx @var{type} __sync_sub_and_fetch (@var{type} *ptr, @var{type} value, ...)
10163 @itemx @var{type} __sync_or_and_fetch (@var{type} *ptr, @var{type} value, ...)
10164 @itemx @var{type} __sync_and_and_fetch (@var{type} *ptr, @var{type} value, ...)
10165 @itemx @var{type} __sync_xor_and_fetch (@var{type} *ptr, @var{type} value, ...)
10166 @itemx @var{type} __sync_nand_and_fetch (@var{type} *ptr, @var{type} value, ...)
10167 @findex __sync_add_and_fetch
10168 @findex __sync_sub_and_fetch
10169 @findex __sync_or_and_fetch
10170 @findex __sync_and_and_fetch
10171 @findex __sync_xor_and_fetch
10172 @findex __sync_nand_and_fetch
10173 These built-in functions perform the operation suggested by the name, and
10174 return the new value.  That is, operations on integer operands have
10175 the following semantics.  Operations on pointer operands are performed as
10176 if the operand's type were @code{uintptr_t}.
10178 @smallexample
10179 @{ *ptr @var{op}= value; return *ptr; @}
10180 @{ *ptr = ~(*ptr & value); return *ptr; @}   // nand
10181 @end smallexample
10183 The same constraints on arguments apply as for the corresponding
10184 @code{__sync_op_and_fetch} built-in functions.
10186 @emph{Note:} GCC 4.4 and later implement @code{__sync_nand_and_fetch}
10187 as @code{*ptr = ~(*ptr & value)} instead of
10188 @code{*ptr = ~*ptr & value}.
10190 @item bool __sync_bool_compare_and_swap (@var{type} *ptr, @var{type} oldval, @var{type} newval, ...)
10191 @itemx @var{type} __sync_val_compare_and_swap (@var{type} *ptr, @var{type} oldval, @var{type} newval, ...)
10192 @findex __sync_bool_compare_and_swap
10193 @findex __sync_val_compare_and_swap
10194 These built-in functions perform an atomic compare and swap.
10195 That is, if the current
10196 value of @code{*@var{ptr}} is @var{oldval}, then write @var{newval} into
10197 @code{*@var{ptr}}.
10199 The ``bool'' version returns true if the comparison is successful and
10200 @var{newval} is written.  The ``val'' version returns the contents
10201 of @code{*@var{ptr}} before the operation.
10203 @item __sync_synchronize (...)
10204 @findex __sync_synchronize
10205 This built-in function issues a full memory barrier.
10207 @item @var{type} __sync_lock_test_and_set (@var{type} *ptr, @var{type} value, ...)
10208 @findex __sync_lock_test_and_set
10209 This built-in function, as described by Intel, is not a traditional test-and-set
10210 operation, but rather an atomic exchange operation.  It writes @var{value}
10211 into @code{*@var{ptr}}, and returns the previous contents of
10212 @code{*@var{ptr}}.
10214 Many targets have only minimal support for such locks, and do not support
10215 a full exchange operation.  In this case, a target may support reduced
10216 functionality here by which the @emph{only} valid value to store is the
10217 immediate constant 1.  The exact value actually stored in @code{*@var{ptr}}
10218 is implementation defined.
10220 This built-in function is not a full barrier,
10221 but rather an @dfn{acquire barrier}.
10222 This means that references after the operation cannot move to (or be
10223 speculated to) before the operation, but previous memory stores may not
10224 be globally visible yet, and previous memory loads may not yet be
10225 satisfied.
10227 @item void __sync_lock_release (@var{type} *ptr, ...)
10228 @findex __sync_lock_release
10229 This built-in function releases the lock acquired by
10230 @code{__sync_lock_test_and_set}.
10231 Normally this means writing the constant 0 to @code{*@var{ptr}}.
10233 This built-in function is not a full barrier,
10234 but rather a @dfn{release barrier}.
10235 This means that all previous memory stores are globally visible, and all
10236 previous memory loads have been satisfied, but following memory reads
10237 are not prevented from being speculated to before the barrier.
10238 @end table
10240 @node __atomic Builtins
10241 @section Built-in Functions for Memory Model Aware Atomic Operations
10243 The following built-in functions approximately match the requirements
10244 for the C++11 memory model.  They are all
10245 identified by being prefixed with @samp{__atomic} and most are
10246 overloaded so that they work with multiple types.
10248 These functions are intended to replace the legacy @samp{__sync}
10249 builtins.  The main difference is that the memory order that is requested
10250 is a parameter to the functions.  New code should always use the
10251 @samp{__atomic} builtins rather than the @samp{__sync} builtins.
10253 Note that the @samp{__atomic} builtins assume that programs will
10254 conform to the C++11 memory model.  In particular, they assume
10255 that programs are free of data races.  See the C++11 standard for
10256 detailed requirements.
10258 The @samp{__atomic} builtins can be used with any integral scalar or
10259 pointer type that is 1, 2, 4, or 8 bytes in length.  16-byte integral
10260 types are also allowed if @samp{__int128} (@pxref{__int128}) is
10261 supported by the architecture.
10263 The four non-arithmetic functions (load, store, exchange, and 
10264 compare_exchange) all have a generic version as well.  This generic
10265 version works on any data type.  It uses the lock-free built-in function
10266 if the specific data type size makes that possible; otherwise, an
10267 external call is left to be resolved at run time.  This external call is
10268 the same format with the addition of a @samp{size_t} parameter inserted
10269 as the first parameter indicating the size of the object being pointed to.
10270 All objects must be the same size.
10272 There are 6 different memory orders that can be specified.  These map
10273 to the C++11 memory orders with the same names, see the C++11 standard
10274 or the @uref{http://gcc.gnu.org/wiki/Atomic/GCCMM/AtomicSync,GCC wiki
10275 on atomic synchronization} for detailed definitions.  Individual
10276 targets may also support additional memory orders for use on specific
10277 architectures.  Refer to the target documentation for details of
10278 these.
10280 An atomic operation can both constrain code motion and
10281 be mapped to hardware instructions for synchronization between threads
10282 (e.g., a fence).  To which extent this happens is controlled by the
10283 memory orders, which are listed here in approximately ascending order of
10284 strength.  The description of each memory order is only meant to roughly
10285 illustrate the effects and is not a specification; see the C++11
10286 memory model for precise semantics.
10288 @table  @code
10289 @item __ATOMIC_RELAXED
10290 Implies no inter-thread ordering constraints.
10291 @item __ATOMIC_CONSUME
10292 This is currently implemented using the stronger @code{__ATOMIC_ACQUIRE}
10293 memory order because of a deficiency in C++11's semantics for
10294 @code{memory_order_consume}.
10295 @item __ATOMIC_ACQUIRE
10296 Creates an inter-thread happens-before constraint from the release (or
10297 stronger) semantic store to this acquire load.  Can prevent hoisting
10298 of code to before the operation.
10299 @item __ATOMIC_RELEASE
10300 Creates an inter-thread happens-before constraint to acquire (or stronger)
10301 semantic loads that read from this release store.  Can prevent sinking
10302 of code to after the operation.
10303 @item __ATOMIC_ACQ_REL
10304 Combines the effects of both @code{__ATOMIC_ACQUIRE} and
10305 @code{__ATOMIC_RELEASE}.
10306 @item __ATOMIC_SEQ_CST
10307 Enforces total ordering with all other @code{__ATOMIC_SEQ_CST} operations.
10308 @end table
10310 Note that in the C++11 memory model, @emph{fences} (e.g.,
10311 @samp{__atomic_thread_fence}) take effect in combination with other
10312 atomic operations on specific memory locations (e.g., atomic loads);
10313 operations on specific memory locations do not necessarily affect other
10314 operations in the same way.
10316 Target architectures are encouraged to provide their own patterns for
10317 each of the atomic built-in functions.  If no target is provided, the original
10318 non-memory model set of @samp{__sync} atomic built-in functions are
10319 used, along with any required synchronization fences surrounding it in
10320 order to achieve the proper behavior.  Execution in this case is subject
10321 to the same restrictions as those built-in functions.
10323 If there is no pattern or mechanism to provide a lock-free instruction
10324 sequence, a call is made to an external routine with the same parameters
10325 to be resolved at run time.
10327 When implementing patterns for these built-in functions, the memory order
10328 parameter can be ignored as long as the pattern implements the most
10329 restrictive @code{__ATOMIC_SEQ_CST} memory order.  Any of the other memory
10330 orders execute correctly with this memory order but they may not execute as
10331 efficiently as they could with a more appropriate implementation of the
10332 relaxed requirements.
10334 Note that the C++11 standard allows for the memory order parameter to be
10335 determined at run time rather than at compile time.  These built-in
10336 functions map any run-time value to @code{__ATOMIC_SEQ_CST} rather
10337 than invoke a runtime library call or inline a switch statement.  This is
10338 standard compliant, safe, and the simplest approach for now.
10340 The memory order parameter is a signed int, but only the lower 16 bits are
10341 reserved for the memory order.  The remainder of the signed int is reserved
10342 for target use and should be 0.  Use of the predefined atomic values
10343 ensures proper usage.
10345 @deftypefn {Built-in Function} @var{type} __atomic_load_n (@var{type} *ptr, int memorder)
10346 This built-in function implements an atomic load operation.  It returns the
10347 contents of @code{*@var{ptr}}.
10349 The valid memory order variants are
10350 @code{__ATOMIC_RELAXED}, @code{__ATOMIC_SEQ_CST}, @code{__ATOMIC_ACQUIRE},
10351 and @code{__ATOMIC_CONSUME}.
10353 @end deftypefn
10355 @deftypefn {Built-in Function} void __atomic_load (@var{type} *ptr, @var{type} *ret, int memorder)
10356 This is the generic version of an atomic load.  It returns the
10357 contents of @code{*@var{ptr}} in @code{*@var{ret}}.
10359 @end deftypefn
10361 @deftypefn {Built-in Function} void __atomic_store_n (@var{type} *ptr, @var{type} val, int memorder)
10362 This built-in function implements an atomic store operation.  It writes 
10363 @code{@var{val}} into @code{*@var{ptr}}.  
10365 The valid memory order variants are
10366 @code{__ATOMIC_RELAXED}, @code{__ATOMIC_SEQ_CST}, and @code{__ATOMIC_RELEASE}.
10368 @end deftypefn
10370 @deftypefn {Built-in Function} void __atomic_store (@var{type} *ptr, @var{type} *val, int memorder)
10371 This is the generic version of an atomic store.  It stores the value
10372 of @code{*@var{val}} into @code{*@var{ptr}}.
10374 @end deftypefn
10376 @deftypefn {Built-in Function} @var{type} __atomic_exchange_n (@var{type} *ptr, @var{type} val, int memorder)
10377 This built-in function implements an atomic exchange operation.  It writes
10378 @var{val} into @code{*@var{ptr}}, and returns the previous contents of
10379 @code{*@var{ptr}}.
10381 The valid memory order variants are
10382 @code{__ATOMIC_RELAXED}, @code{__ATOMIC_SEQ_CST}, @code{__ATOMIC_ACQUIRE},
10383 @code{__ATOMIC_RELEASE}, and @code{__ATOMIC_ACQ_REL}.
10385 @end deftypefn
10387 @deftypefn {Built-in Function} void __atomic_exchange (@var{type} *ptr, @var{type} *val, @var{type} *ret, int memorder)
10388 This is the generic version of an atomic exchange.  It stores the
10389 contents of @code{*@var{val}} into @code{*@var{ptr}}. The original value
10390 of @code{*@var{ptr}} is copied into @code{*@var{ret}}.
10392 @end deftypefn
10394 @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)
10395 This built-in function implements an atomic compare and exchange operation.
10396 This compares the contents of @code{*@var{ptr}} with the contents of
10397 @code{*@var{expected}}. If equal, the operation is a @emph{read-modify-write}
10398 operation that writes @var{desired} into @code{*@var{ptr}}.  If they are not
10399 equal, the operation is a @emph{read} and the current contents of
10400 @code{*@var{ptr}} are written into @code{*@var{expected}}.  @var{weak} is true
10401 for weak compare_exchange, which may fail spuriously, and false for
10402 the strong variation, which never fails spuriously.  Many targets
10403 only offer the strong variation and ignore the parameter.  When in doubt, use
10404 the strong variation.
10406 If @var{desired} is written into @code{*@var{ptr}} then true is returned
10407 and memory is affected according to the
10408 memory order specified by @var{success_memorder}.  There are no
10409 restrictions on what memory order can be used here.
10411 Otherwise, false is returned and memory is affected according
10412 to @var{failure_memorder}. This memory order cannot be
10413 @code{__ATOMIC_RELEASE} nor @code{__ATOMIC_ACQ_REL}.  It also cannot be a
10414 stronger order than that specified by @var{success_memorder}.
10416 @end deftypefn
10418 @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)
10419 This built-in function implements the generic version of
10420 @code{__atomic_compare_exchange}.  The function is virtually identical to
10421 @code{__atomic_compare_exchange_n}, except the desired value is also a
10422 pointer.
10424 @end deftypefn
10426 @deftypefn {Built-in Function} @var{type} __atomic_add_fetch (@var{type} *ptr, @var{type} val, int memorder)
10427 @deftypefnx {Built-in Function} @var{type} __atomic_sub_fetch (@var{type} *ptr, @var{type} val, int memorder)
10428 @deftypefnx {Built-in Function} @var{type} __atomic_and_fetch (@var{type} *ptr, @var{type} val, int memorder)
10429 @deftypefnx {Built-in Function} @var{type} __atomic_xor_fetch (@var{type} *ptr, @var{type} val, int memorder)
10430 @deftypefnx {Built-in Function} @var{type} __atomic_or_fetch (@var{type} *ptr, @var{type} val, int memorder)
10431 @deftypefnx {Built-in Function} @var{type} __atomic_nand_fetch (@var{type} *ptr, @var{type} val, int memorder)
10432 These built-in functions perform the operation suggested by the name, and
10433 return the result of the operation.  Operations on pointer arguments are
10434 performed as if the operands were of the @code{uintptr_t} type.  That is,
10435 they are not scaled by the size of the type to which the pointer points.
10437 @smallexample
10438 @{ *ptr @var{op}= val; return *ptr; @}
10439 @end smallexample
10441 The object pointed to by the first argument must be of integer or pointer
10442 type.  It must not be a boolean type.  All memory orders are valid.
10444 @end deftypefn
10446 @deftypefn {Built-in Function} @var{type} __atomic_fetch_add (@var{type} *ptr, @var{type} val, int memorder)
10447 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_sub (@var{type} *ptr, @var{type} val, int memorder)
10448 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_and (@var{type} *ptr, @var{type} val, int memorder)
10449 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_xor (@var{type} *ptr, @var{type} val, int memorder)
10450 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_or (@var{type} *ptr, @var{type} val, int memorder)
10451 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_nand (@var{type} *ptr, @var{type} val, int memorder)
10452 These built-in functions perform the operation suggested by the name, and
10453 return the value that had previously been in @code{*@var{ptr}}.  Operations
10454 on pointer arguments are performed as if the operands were of
10455 the @code{uintptr_t} type.  That is, they are not scaled by the size of
10456 the type to which the pointer points.
10458 @smallexample
10459 @{ tmp = *ptr; *ptr @var{op}= val; return tmp; @}
10460 @end smallexample
10462 The same constraints on arguments apply as for the corresponding
10463 @code{__atomic_op_fetch} built-in functions.  All memory orders are valid.
10465 @end deftypefn
10467 @deftypefn {Built-in Function} bool __atomic_test_and_set (void *ptr, int memorder)
10469 This built-in function performs an atomic test-and-set operation on
10470 the byte at @code{*@var{ptr}}.  The byte is set to some implementation
10471 defined nonzero ``set'' value and the return value is @code{true} if and only
10472 if the previous contents were ``set''.
10473 It should be only used for operands of type @code{bool} or @code{char}. For 
10474 other types only part of the value may be set.
10476 All memory orders are valid.
10478 @end deftypefn
10480 @deftypefn {Built-in Function} void __atomic_clear (bool *ptr, int memorder)
10482 This built-in function performs an atomic clear operation on
10483 @code{*@var{ptr}}.  After the operation, @code{*@var{ptr}} contains 0.
10484 It should be only used for operands of type @code{bool} or @code{char} and 
10485 in conjunction with @code{__atomic_test_and_set}.
10486 For other types it may only clear partially. If the type is not @code{bool}
10487 prefer using @code{__atomic_store}.
10489 The valid memory order variants are
10490 @code{__ATOMIC_RELAXED}, @code{__ATOMIC_SEQ_CST}, and
10491 @code{__ATOMIC_RELEASE}.
10493 @end deftypefn
10495 @deftypefn {Built-in Function} void __atomic_thread_fence (int memorder)
10497 This built-in function acts as a synchronization fence between threads
10498 based on the specified memory order.
10500 All memory orders are valid.
10502 @end deftypefn
10504 @deftypefn {Built-in Function} void __atomic_signal_fence (int memorder)
10506 This built-in function acts as a synchronization fence between a thread
10507 and signal handlers based in the same thread.
10509 All memory orders are valid.
10511 @end deftypefn
10513 @deftypefn {Built-in Function} bool __atomic_always_lock_free (size_t size,  void *ptr)
10515 This built-in function returns true if objects of @var{size} bytes always
10516 generate lock-free atomic instructions for the target architecture.
10517 @var{size} must resolve to a compile-time constant and the result also
10518 resolves to a compile-time constant.
10520 @var{ptr} is an optional pointer to the object that may be used to determine
10521 alignment.  A value of 0 indicates typical alignment should be used.  The 
10522 compiler may also ignore this parameter.
10524 @smallexample
10525 if (__atomic_always_lock_free (sizeof (long long), 0))
10526 @end smallexample
10528 @end deftypefn
10530 @deftypefn {Built-in Function} bool __atomic_is_lock_free (size_t size, void *ptr)
10532 This built-in function returns true if objects of @var{size} bytes always
10533 generate lock-free atomic instructions for the target architecture.  If
10534 the built-in function is not known to be lock-free, a call is made to a
10535 runtime routine named @code{__atomic_is_lock_free}.
10537 @var{ptr} is an optional pointer to the object that may be used to determine
10538 alignment.  A value of 0 indicates typical alignment should be used.  The 
10539 compiler may also ignore this parameter.
10540 @end deftypefn
10542 @node Integer Overflow Builtins
10543 @section Built-in Functions to Perform Arithmetic with Overflow Checking
10545 The following built-in functions allow performing simple arithmetic operations
10546 together with checking whether the operations overflowed.
10548 @deftypefn {Built-in Function} bool __builtin_add_overflow (@var{type1} a, @var{type2} b, @var{type3} *res)
10549 @deftypefnx {Built-in Function} bool __builtin_sadd_overflow (int a, int b, int *res)
10550 @deftypefnx {Built-in Function} bool __builtin_saddl_overflow (long int a, long int b, long int *res)
10551 @deftypefnx {Built-in Function} bool __builtin_saddll_overflow (long long int a, long long int b, long long int *res)
10552 @deftypefnx {Built-in Function} bool __builtin_uadd_overflow (unsigned int a, unsigned int b, unsigned int *res)
10553 @deftypefnx {Built-in Function} bool __builtin_uaddl_overflow (unsigned long int a, unsigned long int b, unsigned long int *res)
10554 @deftypefnx {Built-in Function} bool __builtin_uaddll_overflow (unsigned long long int a, unsigned long long int b, unsigned long long int *res)
10556 These built-in functions promote the first two operands into infinite precision signed
10557 type and perform addition on those promoted operands.  The result is then
10558 cast to the type the third pointer argument points to and stored there.
10559 If the stored result is equal to the infinite precision result, the built-in
10560 functions return false, otherwise they return true.  As the addition is
10561 performed in infinite signed precision, these built-in functions have fully defined
10562 behavior for all argument values.
10564 The first built-in function allows arbitrary integral types for operands and
10565 the result type must be pointer to some integral type other than enumerated or
10566 boolean type, the rest of the built-in functions have explicit integer types.
10568 The compiler will attempt to use hardware instructions to implement
10569 these built-in functions where possible, like conditional jump on overflow
10570 after addition, conditional jump on carry etc.
10572 @end deftypefn
10574 @deftypefn {Built-in Function} bool __builtin_sub_overflow (@var{type1} a, @var{type2} b, @var{type3} *res)
10575 @deftypefnx {Built-in Function} bool __builtin_ssub_overflow (int a, int b, int *res)
10576 @deftypefnx {Built-in Function} bool __builtin_ssubl_overflow (long int a, long int b, long int *res)
10577 @deftypefnx {Built-in Function} bool __builtin_ssubll_overflow (long long int a, long long int b, long long int *res)
10578 @deftypefnx {Built-in Function} bool __builtin_usub_overflow (unsigned int a, unsigned int b, unsigned int *res)
10579 @deftypefnx {Built-in Function} bool __builtin_usubl_overflow (unsigned long int a, unsigned long int b, unsigned long int *res)
10580 @deftypefnx {Built-in Function} bool __builtin_usubll_overflow (unsigned long long int a, unsigned long long int b, unsigned long long int *res)
10582 These built-in functions are similar to the add overflow checking built-in
10583 functions above, except they perform subtraction, subtract the second argument
10584 from the first one, instead of addition.
10586 @end deftypefn
10588 @deftypefn {Built-in Function} bool __builtin_mul_overflow (@var{type1} a, @var{type2} b, @var{type3} *res)
10589 @deftypefnx {Built-in Function} bool __builtin_smul_overflow (int a, int b, int *res)
10590 @deftypefnx {Built-in Function} bool __builtin_smull_overflow (long int a, long int b, long int *res)
10591 @deftypefnx {Built-in Function} bool __builtin_smulll_overflow (long long int a, long long int b, long long int *res)
10592 @deftypefnx {Built-in Function} bool __builtin_umul_overflow (unsigned int a, unsigned int b, unsigned int *res)
10593 @deftypefnx {Built-in Function} bool __builtin_umull_overflow (unsigned long int a, unsigned long int b, unsigned long int *res)
10594 @deftypefnx {Built-in Function} bool __builtin_umulll_overflow (unsigned long long int a, unsigned long long int b, unsigned long long int *res)
10596 These built-in functions are similar to the add overflow checking built-in
10597 functions above, except they perform multiplication, instead of addition.
10599 @end deftypefn
10601 The following built-in functions allow checking if simple arithmetic operation
10602 would overflow.
10604 @deftypefn {Built-in Function} bool __builtin_add_overflow_p (@var{type1} a, @var{type2} b, @var{type3} c)
10605 @deftypefnx {Built-in Function} bool __builtin_sub_overflow_p (@var{type1} a, @var{type2} b, @var{type3} c)
10606 @deftypefnx {Built-in Function} bool __builtin_mul_overflow_p (@var{type1} a, @var{type2} b, @var{type3} c)
10608 These built-in functions are similar to @code{__builtin_add_overflow},
10609 @code{__builtin_sub_overflow}, or @code{__builtin_mul_overflow}, except that
10610 they don't store the result of the arithmetic operation anywhere and the
10611 last argument is not a pointer, but some expression with integral type other
10612 than enumerated or boolean type.
10614 The built-in functions promote the first two operands into infinite precision signed type
10615 and perform addition on those promoted operands. The result is then
10616 cast to the type of the third argument.  If the cast result is equal to the infinite
10617 precision result, the built-in functions return false, otherwise they return true.
10618 The value of the third argument is ignored, just the side-effects in the third argument
10619 are evaluated, and no integral argument promotions are performed on the last argument.
10620 If the third argument is a bit-field, the type used for the result cast has the
10621 precision and signedness of the given bit-field, rather than precision and signedness
10622 of the underlying type.
10624 For example, the following macro can be used to portably check, at
10625 compile-time, whether or not adding two constant integers will overflow,
10626 and perform the addition only when it is known to be safe and not to trigger
10627 a @option{-Woverflow} warning.
10629 @smallexample
10630 #define INT_ADD_OVERFLOW_P(a, b) \
10631    __builtin_add_overflow_p (a, b, (__typeof__ ((a) + (b))) 0)
10633 enum @{
10634     A = INT_MAX, B = 3,
10635     C = INT_ADD_OVERFLOW_P (A, B) ? 0 : A + B,
10636     D = __builtin_add_overflow_p (1, SCHAR_MAX, (signed char) 0)
10638 @end smallexample
10640 The compiler will attempt to use hardware instructions to implement
10641 these built-in functions where possible, like conditional jump on overflow
10642 after addition, conditional jump on carry etc.
10644 @end deftypefn
10646 @node x86 specific memory model extensions for transactional memory
10647 @section x86-Specific Memory Model Extensions for Transactional Memory
10649 The x86 architecture supports additional memory ordering flags
10650 to mark critical sections for hardware lock elision. 
10651 These must be specified in addition to an existing memory order to
10652 atomic intrinsics.
10654 @table @code
10655 @item __ATOMIC_HLE_ACQUIRE
10656 Start lock elision on a lock variable.
10657 Memory order must be @code{__ATOMIC_ACQUIRE} or stronger.
10658 @item __ATOMIC_HLE_RELEASE
10659 End lock elision on a lock variable.
10660 Memory order must be @code{__ATOMIC_RELEASE} or stronger.
10661 @end table
10663 When a lock acquire fails, it is required for good performance to abort
10664 the transaction quickly. This can be done with a @code{_mm_pause}.
10666 @smallexample
10667 #include <immintrin.h> // For _mm_pause
10669 int lockvar;
10671 /* Acquire lock with lock elision */
10672 while (__atomic_exchange_n(&lockvar, 1, __ATOMIC_ACQUIRE|__ATOMIC_HLE_ACQUIRE))
10673     _mm_pause(); /* Abort failed transaction */
10675 /* Free lock with lock elision */
10676 __atomic_store_n(&lockvar, 0, __ATOMIC_RELEASE|__ATOMIC_HLE_RELEASE);
10677 @end smallexample
10679 @node Object Size Checking
10680 @section Object Size Checking Built-in Functions
10681 @findex __builtin_object_size
10682 @findex __builtin___memcpy_chk
10683 @findex __builtin___mempcpy_chk
10684 @findex __builtin___memmove_chk
10685 @findex __builtin___memset_chk
10686 @findex __builtin___strcpy_chk
10687 @findex __builtin___stpcpy_chk
10688 @findex __builtin___strncpy_chk
10689 @findex __builtin___strcat_chk
10690 @findex __builtin___strncat_chk
10691 @findex __builtin___sprintf_chk
10692 @findex __builtin___snprintf_chk
10693 @findex __builtin___vsprintf_chk
10694 @findex __builtin___vsnprintf_chk
10695 @findex __builtin___printf_chk
10696 @findex __builtin___vprintf_chk
10697 @findex __builtin___fprintf_chk
10698 @findex __builtin___vfprintf_chk
10700 GCC implements a limited buffer overflow protection mechanism that can
10701 prevent some buffer overflow attacks by determining the sizes of objects
10702 into which data is about to be written and preventing the writes when
10703 the size isn't sufficient.  The built-in functions described below yield
10704 the best results when used together and when optimization is enabled.
10705 For example, to detect object sizes across function boundaries or to
10706 follow pointer assignments through non-trivial control flow they rely
10707 on various optimization passes enabled with @option{-O2}.  However, to
10708 a limited extent, they can be used without optimization as well.
10710 @deftypefn {Built-in Function} {size_t} __builtin_object_size (const void * @var{ptr}, int @var{type})
10711 is a built-in construct that returns a constant number of bytes from
10712 @var{ptr} to the end of the object @var{ptr} pointer points to
10713 (if known at compile time).  @code{__builtin_object_size} never evaluates
10714 its arguments for side-effects.  If there are any side-effects in them, it
10715 returns @code{(size_t) -1} for @var{type} 0 or 1 and @code{(size_t) 0}
10716 for @var{type} 2 or 3.  If there are multiple objects @var{ptr} can
10717 point to and all of them are known at compile time, the returned number
10718 is the maximum of remaining byte counts in those objects if @var{type} & 2 is
10719 0 and minimum if nonzero.  If it is not possible to determine which objects
10720 @var{ptr} points to at compile time, @code{__builtin_object_size} should
10721 return @code{(size_t) -1} for @var{type} 0 or 1 and @code{(size_t) 0}
10722 for @var{type} 2 or 3.
10724 @var{type} is an integer constant from 0 to 3.  If the least significant
10725 bit is clear, objects are whole variables, if it is set, a closest
10726 surrounding subobject is considered the object a pointer points to.
10727 The second bit determines if maximum or minimum of remaining bytes
10728 is computed.
10730 @smallexample
10731 struct V @{ char buf1[10]; int b; char buf2[10]; @} var;
10732 char *p = &var.buf1[1], *q = &var.b;
10734 /* Here the object p points to is var.  */
10735 assert (__builtin_object_size (p, 0) == sizeof (var) - 1);
10736 /* The subobject p points to is var.buf1.  */
10737 assert (__builtin_object_size (p, 1) == sizeof (var.buf1) - 1);
10738 /* The object q points to is var.  */
10739 assert (__builtin_object_size (q, 0)
10740         == (char *) (&var + 1) - (char *) &var.b);
10741 /* The subobject q points to is var.b.  */
10742 assert (__builtin_object_size (q, 1) == sizeof (var.b));
10743 @end smallexample
10744 @end deftypefn
10746 There are built-in functions added for many common string operation
10747 functions, e.g., for @code{memcpy} @code{__builtin___memcpy_chk}
10748 built-in is provided.  This built-in has an additional last argument,
10749 which is the number of bytes remaining in the object the @var{dest}
10750 argument points to or @code{(size_t) -1} if the size is not known.
10752 The built-in functions are optimized into the normal string functions
10753 like @code{memcpy} if the last argument is @code{(size_t) -1} or if
10754 it is known at compile time that the destination object will not
10755 be overflowed.  If the compiler can determine at compile time that the
10756 object will always be overflowed, it issues a warning.
10758 The intended use can be e.g.@:
10760 @smallexample
10761 #undef memcpy
10762 #define bos0(dest) __builtin_object_size (dest, 0)
10763 #define memcpy(dest, src, n) \
10764   __builtin___memcpy_chk (dest, src, n, bos0 (dest))
10766 char *volatile p;
10767 char buf[10];
10768 /* It is unknown what object p points to, so this is optimized
10769    into plain memcpy - no checking is possible.  */
10770 memcpy (p, "abcde", n);
10771 /* Destination is known and length too.  It is known at compile
10772    time there will be no overflow.  */
10773 memcpy (&buf[5], "abcde", 5);
10774 /* Destination is known, but the length is not known at compile time.
10775    This will result in __memcpy_chk call that can check for overflow
10776    at run time.  */
10777 memcpy (&buf[5], "abcde", n);
10778 /* Destination is known and it is known at compile time there will
10779    be overflow.  There will be a warning and __memcpy_chk call that
10780    will abort the program at run time.  */
10781 memcpy (&buf[6], "abcde", 5);
10782 @end smallexample
10784 Such built-in functions are provided for @code{memcpy}, @code{mempcpy},
10785 @code{memmove}, @code{memset}, @code{strcpy}, @code{stpcpy}, @code{strncpy},
10786 @code{strcat} and @code{strncat}.
10788 There are also checking built-in functions for formatted output functions.
10789 @smallexample
10790 int __builtin___sprintf_chk (char *s, int flag, size_t os, const char *fmt, ...);
10791 int __builtin___snprintf_chk (char *s, size_t maxlen, int flag, size_t os,
10792                               const char *fmt, ...);
10793 int __builtin___vsprintf_chk (char *s, int flag, size_t os, const char *fmt,
10794                               va_list ap);
10795 int __builtin___vsnprintf_chk (char *s, size_t maxlen, int flag, size_t os,
10796                                const char *fmt, va_list ap);
10797 @end smallexample
10799 The added @var{flag} argument is passed unchanged to @code{__sprintf_chk}
10800 etc.@: functions and can contain implementation specific flags on what
10801 additional security measures the checking function might take, such as
10802 handling @code{%n} differently.
10804 The @var{os} argument is the object size @var{s} points to, like in the
10805 other built-in functions.  There is a small difference in the behavior
10806 though, if @var{os} is @code{(size_t) -1}, the built-in functions are
10807 optimized into the non-checking functions only if @var{flag} is 0, otherwise
10808 the checking function is called with @var{os} argument set to
10809 @code{(size_t) -1}.
10811 In addition to this, there are checking built-in functions
10812 @code{__builtin___printf_chk}, @code{__builtin___vprintf_chk},
10813 @code{__builtin___fprintf_chk} and @code{__builtin___vfprintf_chk}.
10814 These have just one additional argument, @var{flag}, right before
10815 format string @var{fmt}.  If the compiler is able to optimize them to
10816 @code{fputc} etc.@: functions, it does, otherwise the checking function
10817 is called and the @var{flag} argument passed to it.
10819 @node Pointer Bounds Checker builtins
10820 @section Pointer Bounds Checker Built-in Functions
10821 @cindex Pointer Bounds Checker builtins
10822 @findex __builtin___bnd_set_ptr_bounds
10823 @findex __builtin___bnd_narrow_ptr_bounds
10824 @findex __builtin___bnd_copy_ptr_bounds
10825 @findex __builtin___bnd_init_ptr_bounds
10826 @findex __builtin___bnd_null_ptr_bounds
10827 @findex __builtin___bnd_store_ptr_bounds
10828 @findex __builtin___bnd_chk_ptr_lbounds
10829 @findex __builtin___bnd_chk_ptr_ubounds
10830 @findex __builtin___bnd_chk_ptr_bounds
10831 @findex __builtin___bnd_get_ptr_lbound
10832 @findex __builtin___bnd_get_ptr_ubound
10834 GCC provides a set of built-in functions to control Pointer Bounds Checker
10835 instrumentation.  Note that all Pointer Bounds Checker builtins can be used
10836 even if you compile with Pointer Bounds Checker off
10837 (@option{-fno-check-pointer-bounds}).
10838 The behavior may differ in such case as documented below.
10840 @deftypefn {Built-in Function} {void *} __builtin___bnd_set_ptr_bounds (const void *@var{q}, size_t @var{size})
10842 This built-in function returns a new pointer with the value of @var{q}, and
10843 associate it with the bounds [@var{q}, @var{q}+@var{size}-1].  With Pointer
10844 Bounds Checker off, the built-in function just returns the first argument.
10846 @smallexample
10847 extern void *__wrap_malloc (size_t n)
10849   void *p = (void *)__real_malloc (n);
10850   if (!p) return __builtin___bnd_null_ptr_bounds (p);
10851   return __builtin___bnd_set_ptr_bounds (p, n);
10853 @end smallexample
10855 @end deftypefn
10857 @deftypefn {Built-in Function} {void *} __builtin___bnd_narrow_ptr_bounds (const void *@var{p}, const void *@var{q}, size_t  @var{size})
10859 This built-in function returns a new pointer with the value of @var{p}
10860 and associates it with the narrowed bounds formed by the intersection
10861 of bounds associated with @var{q} and the bounds
10862 [@var{p}, @var{p} + @var{size} - 1].
10863 With Pointer Bounds Checker off, the built-in function just returns the first
10864 argument.
10866 @smallexample
10867 void init_objects (object *objs, size_t size)
10869   size_t i;
10870   /* Initialize objects one-by-one passing pointers with bounds of 
10871      an object, not the full array of objects.  */
10872   for (i = 0; i < size; i++)
10873     init_object (__builtin___bnd_narrow_ptr_bounds (objs + i, objs,
10874                                                     sizeof(object)));
10876 @end smallexample
10878 @end deftypefn
10880 @deftypefn {Built-in Function} {void *} __builtin___bnd_copy_ptr_bounds (const void *@var{q}, const void *@var{r})
10882 This built-in function returns a new pointer with the value of @var{q},
10883 and associates it with the bounds already associated with pointer @var{r}.
10884 With Pointer Bounds Checker off, the built-in function just returns the first
10885 argument.
10887 @smallexample
10888 /* Here is a way to get pointer to object's field but
10889    still with the full object's bounds.  */
10890 int *field_ptr = __builtin___bnd_copy_ptr_bounds (&objptr->int_field, 
10891                                                   objptr);
10892 @end smallexample
10894 @end deftypefn
10896 @deftypefn {Built-in Function} {void *} __builtin___bnd_init_ptr_bounds (const void *@var{q})
10898 This built-in function returns a new pointer with the value of @var{q}, and
10899 associates it with INIT (allowing full memory access) bounds. With Pointer
10900 Bounds Checker off, the built-in function just returns the first argument.
10902 @end deftypefn
10904 @deftypefn {Built-in Function} {void *} __builtin___bnd_null_ptr_bounds (const void *@var{q})
10906 This built-in function returns a new pointer with the value of @var{q}, and
10907 associates it with NULL (allowing no memory access) bounds. With Pointer
10908 Bounds Checker off, the built-in function just returns the first argument.
10910 @end deftypefn
10912 @deftypefn {Built-in Function} void __builtin___bnd_store_ptr_bounds (const void **@var{ptr_addr}, const void *@var{ptr_val})
10914 This built-in function stores the bounds associated with pointer @var{ptr_val}
10915 and location @var{ptr_addr} into Bounds Table.  This can be useful to propagate
10916 bounds from legacy code without touching the associated pointer's memory when
10917 pointers are copied as integers.  With Pointer Bounds Checker off, the built-in
10918 function call is ignored.
10920 @end deftypefn
10922 @deftypefn {Built-in Function} void __builtin___bnd_chk_ptr_lbounds (const void *@var{q})
10924 This built-in function checks if the pointer @var{q} is within the lower
10925 bound of its associated bounds.  With Pointer Bounds Checker off, the built-in
10926 function call is ignored.
10928 @smallexample
10929 extern void *__wrap_memset (void *dst, int c, size_t len)
10931   if (len > 0)
10932     @{
10933       __builtin___bnd_chk_ptr_lbounds (dst);
10934       __builtin___bnd_chk_ptr_ubounds ((char *)dst + len - 1);
10935       __real_memset (dst, c, len);
10936     @}
10937   return dst;
10939 @end smallexample
10941 @end deftypefn
10943 @deftypefn {Built-in Function} void __builtin___bnd_chk_ptr_ubounds (const void *@var{q})
10945 This built-in function checks if the pointer @var{q} is within the upper
10946 bound of its associated bounds.  With Pointer Bounds Checker off, the built-in
10947 function call is ignored.
10949 @end deftypefn
10951 @deftypefn {Built-in Function} void __builtin___bnd_chk_ptr_bounds (const void *@var{q}, size_t @var{size})
10953 This built-in function checks if [@var{q}, @var{q} + @var{size} - 1] is within
10954 the lower and upper bounds associated with @var{q}.  With Pointer Bounds Checker
10955 off, the built-in function call is ignored.
10957 @smallexample
10958 extern void *__wrap_memcpy (void *dst, const void *src, size_t n)
10960   if (n > 0)
10961     @{
10962       __bnd_chk_ptr_bounds (dst, n);
10963       __bnd_chk_ptr_bounds (src, n);
10964       __real_memcpy (dst, src, n);
10965     @}
10966   return dst;
10968 @end smallexample
10970 @end deftypefn
10972 @deftypefn {Built-in Function} {const void *} __builtin___bnd_get_ptr_lbound (const void *@var{q})
10974 This built-in function returns the lower bound associated
10975 with the pointer @var{q}, as a pointer value.  
10976 This is useful for debugging using @code{printf}.
10977 With Pointer Bounds Checker off, the built-in function returns 0.
10979 @smallexample
10980 void *lb = __builtin___bnd_get_ptr_lbound (q);
10981 void *ub = __builtin___bnd_get_ptr_ubound (q);
10982 printf ("q = %p  lb(q) = %p  ub(q) = %p", q, lb, ub);
10983 @end smallexample
10985 @end deftypefn
10987 @deftypefn {Built-in Function} {const void *} __builtin___bnd_get_ptr_ubound (const void *@var{q})
10989 This built-in function returns the upper bound (which is a pointer) associated
10990 with the pointer @var{q}.  With Pointer Bounds Checker off,
10991 the built-in function returns -1.
10993 @end deftypefn
10995 @node Other Builtins
10996 @section Other Built-in Functions Provided by GCC
10997 @cindex built-in functions
10998 @findex __builtin_alloca
10999 @findex __builtin_alloca_with_align
11000 @findex __builtin_alloca_with_align_and_max
11001 @findex __builtin_call_with_static_chain
11002 @findex __builtin_fpclassify
11003 @findex __builtin_isfinite
11004 @findex __builtin_isnormal
11005 @findex __builtin_isgreater
11006 @findex __builtin_isgreaterequal
11007 @findex __builtin_isinf_sign
11008 @findex __builtin_isless
11009 @findex __builtin_islessequal
11010 @findex __builtin_islessgreater
11011 @findex __builtin_isunordered
11012 @findex __builtin_powi
11013 @findex __builtin_powif
11014 @findex __builtin_powil
11015 @findex _Exit
11016 @findex _exit
11017 @findex abort
11018 @findex abs
11019 @findex acos
11020 @findex acosf
11021 @findex acosh
11022 @findex acoshf
11023 @findex acoshl
11024 @findex acosl
11025 @findex alloca
11026 @findex asin
11027 @findex asinf
11028 @findex asinh
11029 @findex asinhf
11030 @findex asinhl
11031 @findex asinl
11032 @findex atan
11033 @findex atan2
11034 @findex atan2f
11035 @findex atan2l
11036 @findex atanf
11037 @findex atanh
11038 @findex atanhf
11039 @findex atanhl
11040 @findex atanl
11041 @findex bcmp
11042 @findex bzero
11043 @findex cabs
11044 @findex cabsf
11045 @findex cabsl
11046 @findex cacos
11047 @findex cacosf
11048 @findex cacosh
11049 @findex cacoshf
11050 @findex cacoshl
11051 @findex cacosl
11052 @findex calloc
11053 @findex carg
11054 @findex cargf
11055 @findex cargl
11056 @findex casin
11057 @findex casinf
11058 @findex casinh
11059 @findex casinhf
11060 @findex casinhl
11061 @findex casinl
11062 @findex catan
11063 @findex catanf
11064 @findex catanh
11065 @findex catanhf
11066 @findex catanhl
11067 @findex catanl
11068 @findex cbrt
11069 @findex cbrtf
11070 @findex cbrtl
11071 @findex ccos
11072 @findex ccosf
11073 @findex ccosh
11074 @findex ccoshf
11075 @findex ccoshl
11076 @findex ccosl
11077 @findex ceil
11078 @findex ceilf
11079 @findex ceill
11080 @findex cexp
11081 @findex cexpf
11082 @findex cexpl
11083 @findex cimag
11084 @findex cimagf
11085 @findex cimagl
11086 @findex clog
11087 @findex clogf
11088 @findex clogl
11089 @findex clog10
11090 @findex clog10f
11091 @findex clog10l
11092 @findex conj
11093 @findex conjf
11094 @findex conjl
11095 @findex copysign
11096 @findex copysignf
11097 @findex copysignl
11098 @findex cos
11099 @findex cosf
11100 @findex cosh
11101 @findex coshf
11102 @findex coshl
11103 @findex cosl
11104 @findex cpow
11105 @findex cpowf
11106 @findex cpowl
11107 @findex cproj
11108 @findex cprojf
11109 @findex cprojl
11110 @findex creal
11111 @findex crealf
11112 @findex creall
11113 @findex csin
11114 @findex csinf
11115 @findex csinh
11116 @findex csinhf
11117 @findex csinhl
11118 @findex csinl
11119 @findex csqrt
11120 @findex csqrtf
11121 @findex csqrtl
11122 @findex ctan
11123 @findex ctanf
11124 @findex ctanh
11125 @findex ctanhf
11126 @findex ctanhl
11127 @findex ctanl
11128 @findex dcgettext
11129 @findex dgettext
11130 @findex drem
11131 @findex dremf
11132 @findex dreml
11133 @findex erf
11134 @findex erfc
11135 @findex erfcf
11136 @findex erfcl
11137 @findex erff
11138 @findex erfl
11139 @findex exit
11140 @findex exp
11141 @findex exp10
11142 @findex exp10f
11143 @findex exp10l
11144 @findex exp2
11145 @findex exp2f
11146 @findex exp2l
11147 @findex expf
11148 @findex expl
11149 @findex expm1
11150 @findex expm1f
11151 @findex expm1l
11152 @findex fabs
11153 @findex fabsf
11154 @findex fabsl
11155 @findex fdim
11156 @findex fdimf
11157 @findex fdiml
11158 @findex ffs
11159 @findex floor
11160 @findex floorf
11161 @findex floorl
11162 @findex fma
11163 @findex fmaf
11164 @findex fmal
11165 @findex fmax
11166 @findex fmaxf
11167 @findex fmaxl
11168 @findex fmin
11169 @findex fminf
11170 @findex fminl
11171 @findex fmod
11172 @findex fmodf
11173 @findex fmodl
11174 @findex fprintf
11175 @findex fprintf_unlocked
11176 @findex fputs
11177 @findex fputs_unlocked
11178 @findex frexp
11179 @findex frexpf
11180 @findex frexpl
11181 @findex fscanf
11182 @findex gamma
11183 @findex gammaf
11184 @findex gammal
11185 @findex gamma_r
11186 @findex gammaf_r
11187 @findex gammal_r
11188 @findex gettext
11189 @findex hypot
11190 @findex hypotf
11191 @findex hypotl
11192 @findex ilogb
11193 @findex ilogbf
11194 @findex ilogbl
11195 @findex imaxabs
11196 @findex index
11197 @findex isalnum
11198 @findex isalpha
11199 @findex isascii
11200 @findex isblank
11201 @findex iscntrl
11202 @findex isdigit
11203 @findex isgraph
11204 @findex islower
11205 @findex isprint
11206 @findex ispunct
11207 @findex isspace
11208 @findex isupper
11209 @findex iswalnum
11210 @findex iswalpha
11211 @findex iswblank
11212 @findex iswcntrl
11213 @findex iswdigit
11214 @findex iswgraph
11215 @findex iswlower
11216 @findex iswprint
11217 @findex iswpunct
11218 @findex iswspace
11219 @findex iswupper
11220 @findex iswxdigit
11221 @findex isxdigit
11222 @findex j0
11223 @findex j0f
11224 @findex j0l
11225 @findex j1
11226 @findex j1f
11227 @findex j1l
11228 @findex jn
11229 @findex jnf
11230 @findex jnl
11231 @findex labs
11232 @findex ldexp
11233 @findex ldexpf
11234 @findex ldexpl
11235 @findex lgamma
11236 @findex lgammaf
11237 @findex lgammal
11238 @findex lgamma_r
11239 @findex lgammaf_r
11240 @findex lgammal_r
11241 @findex llabs
11242 @findex llrint
11243 @findex llrintf
11244 @findex llrintl
11245 @findex llround
11246 @findex llroundf
11247 @findex llroundl
11248 @findex log
11249 @findex log10
11250 @findex log10f
11251 @findex log10l
11252 @findex log1p
11253 @findex log1pf
11254 @findex log1pl
11255 @findex log2
11256 @findex log2f
11257 @findex log2l
11258 @findex logb
11259 @findex logbf
11260 @findex logbl
11261 @findex logf
11262 @findex logl
11263 @findex lrint
11264 @findex lrintf
11265 @findex lrintl
11266 @findex lround
11267 @findex lroundf
11268 @findex lroundl
11269 @findex malloc
11270 @findex memchr
11271 @findex memcmp
11272 @findex memcpy
11273 @findex mempcpy
11274 @findex memset
11275 @findex modf
11276 @findex modff
11277 @findex modfl
11278 @findex nearbyint
11279 @findex nearbyintf
11280 @findex nearbyintl
11281 @findex nextafter
11282 @findex nextafterf
11283 @findex nextafterl
11284 @findex nexttoward
11285 @findex nexttowardf
11286 @findex nexttowardl
11287 @findex pow
11288 @findex pow10
11289 @findex pow10f
11290 @findex pow10l
11291 @findex powf
11292 @findex powl
11293 @findex printf
11294 @findex printf_unlocked
11295 @findex putchar
11296 @findex puts
11297 @findex remainder
11298 @findex remainderf
11299 @findex remainderl
11300 @findex remquo
11301 @findex remquof
11302 @findex remquol
11303 @findex rindex
11304 @findex rint
11305 @findex rintf
11306 @findex rintl
11307 @findex round
11308 @findex roundf
11309 @findex roundl
11310 @findex scalb
11311 @findex scalbf
11312 @findex scalbl
11313 @findex scalbln
11314 @findex scalblnf
11315 @findex scalblnf
11316 @findex scalbn
11317 @findex scalbnf
11318 @findex scanfnl
11319 @findex signbit
11320 @findex signbitf
11321 @findex signbitl
11322 @findex signbitd32
11323 @findex signbitd64
11324 @findex signbitd128
11325 @findex significand
11326 @findex significandf
11327 @findex significandl
11328 @findex sin
11329 @findex sincos
11330 @findex sincosf
11331 @findex sincosl
11332 @findex sinf
11333 @findex sinh
11334 @findex sinhf
11335 @findex sinhl
11336 @findex sinl
11337 @findex snprintf
11338 @findex sprintf
11339 @findex sqrt
11340 @findex sqrtf
11341 @findex sqrtl
11342 @findex sscanf
11343 @findex stpcpy
11344 @findex stpncpy
11345 @findex strcasecmp
11346 @findex strcat
11347 @findex strchr
11348 @findex strcmp
11349 @findex strcpy
11350 @findex strcspn
11351 @findex strdup
11352 @findex strfmon
11353 @findex strftime
11354 @findex strlen
11355 @findex strncasecmp
11356 @findex strncat
11357 @findex strncmp
11358 @findex strncpy
11359 @findex strndup
11360 @findex strpbrk
11361 @findex strrchr
11362 @findex strspn
11363 @findex strstr
11364 @findex tan
11365 @findex tanf
11366 @findex tanh
11367 @findex tanhf
11368 @findex tanhl
11369 @findex tanl
11370 @findex tgamma
11371 @findex tgammaf
11372 @findex tgammal
11373 @findex toascii
11374 @findex tolower
11375 @findex toupper
11376 @findex towlower
11377 @findex towupper
11378 @findex trunc
11379 @findex truncf
11380 @findex truncl
11381 @findex vfprintf
11382 @findex vfscanf
11383 @findex vprintf
11384 @findex vscanf
11385 @findex vsnprintf
11386 @findex vsprintf
11387 @findex vsscanf
11388 @findex y0
11389 @findex y0f
11390 @findex y0l
11391 @findex y1
11392 @findex y1f
11393 @findex y1l
11394 @findex yn
11395 @findex ynf
11396 @findex ynl
11398 GCC provides a large number of built-in functions other than the ones
11399 mentioned above.  Some of these are for internal use in the processing
11400 of exceptions or variable-length argument lists and are not
11401 documented here because they may change from time to time; we do not
11402 recommend general use of these functions.
11404 The remaining functions are provided for optimization purposes.
11406 With the exception of built-ins that have library equivalents such as
11407 the standard C library functions discussed below, or that expand to
11408 library calls, GCC built-in functions are always expanded inline and
11409 thus do not have corresponding entry points and their address cannot
11410 be obtained.  Attempting to use them in an expression other than
11411 a function call results in a compile-time error.
11413 @opindex fno-builtin
11414 GCC includes built-in versions of many of the functions in the standard
11415 C library.  These functions come in two forms: one whose names start with
11416 the @code{__builtin_} prefix, and the other without.  Both forms have the
11417 same type (including prototype), the same address (when their address is
11418 taken), and the same meaning as the C library functions even if you specify
11419 the @option{-fno-builtin} option @pxref{C Dialect Options}).  Many of these
11420 functions are only optimized in certain cases; if they are not optimized in
11421 a particular case, a call to the library function is emitted.
11423 @opindex ansi
11424 @opindex std
11425 Outside strict ISO C mode (@option{-ansi}, @option{-std=c90},
11426 @option{-std=c99} or @option{-std=c11}), the functions
11427 @code{_exit}, @code{alloca}, @code{bcmp}, @code{bzero},
11428 @code{dcgettext}, @code{dgettext}, @code{dremf}, @code{dreml},
11429 @code{drem}, @code{exp10f}, @code{exp10l}, @code{exp10}, @code{ffsll},
11430 @code{ffsl}, @code{ffs}, @code{fprintf_unlocked},
11431 @code{fputs_unlocked}, @code{gammaf}, @code{gammal}, @code{gamma},
11432 @code{gammaf_r}, @code{gammal_r}, @code{gamma_r}, @code{gettext},
11433 @code{index}, @code{isascii}, @code{j0f}, @code{j0l}, @code{j0},
11434 @code{j1f}, @code{j1l}, @code{j1}, @code{jnf}, @code{jnl}, @code{jn},
11435 @code{lgammaf_r}, @code{lgammal_r}, @code{lgamma_r}, @code{mempcpy},
11436 @code{pow10f}, @code{pow10l}, @code{pow10}, @code{printf_unlocked},
11437 @code{rindex}, @code{scalbf}, @code{scalbl}, @code{scalb},
11438 @code{signbit}, @code{signbitf}, @code{signbitl}, @code{signbitd32},
11439 @code{signbitd64}, @code{signbitd128}, @code{significandf},
11440 @code{significandl}, @code{significand}, @code{sincosf},
11441 @code{sincosl}, @code{sincos}, @code{stpcpy}, @code{stpncpy},
11442 @code{strcasecmp}, @code{strdup}, @code{strfmon}, @code{strncasecmp},
11443 @code{strndup}, @code{toascii}, @code{y0f}, @code{y0l}, @code{y0},
11444 @code{y1f}, @code{y1l}, @code{y1}, @code{ynf}, @code{ynl} and
11445 @code{yn}
11446 may be handled as built-in functions.
11447 All these functions have corresponding versions
11448 prefixed with @code{__builtin_}, which may be used even in strict C90
11449 mode.
11451 The ISO C99 functions
11452 @code{_Exit}, @code{acoshf}, @code{acoshl}, @code{acosh}, @code{asinhf},
11453 @code{asinhl}, @code{asinh}, @code{atanhf}, @code{atanhl}, @code{atanh},
11454 @code{cabsf}, @code{cabsl}, @code{cabs}, @code{cacosf}, @code{cacoshf},
11455 @code{cacoshl}, @code{cacosh}, @code{cacosl}, @code{cacos},
11456 @code{cargf}, @code{cargl}, @code{carg}, @code{casinf}, @code{casinhf},
11457 @code{casinhl}, @code{casinh}, @code{casinl}, @code{casin},
11458 @code{catanf}, @code{catanhf}, @code{catanhl}, @code{catanh},
11459 @code{catanl}, @code{catan}, @code{cbrtf}, @code{cbrtl}, @code{cbrt},
11460 @code{ccosf}, @code{ccoshf}, @code{ccoshl}, @code{ccosh}, @code{ccosl},
11461 @code{ccos}, @code{cexpf}, @code{cexpl}, @code{cexp}, @code{cimagf},
11462 @code{cimagl}, @code{cimag}, @code{clogf}, @code{clogl}, @code{clog},
11463 @code{conjf}, @code{conjl}, @code{conj}, @code{copysignf}, @code{copysignl},
11464 @code{copysign}, @code{cpowf}, @code{cpowl}, @code{cpow}, @code{cprojf},
11465 @code{cprojl}, @code{cproj}, @code{crealf}, @code{creall}, @code{creal},
11466 @code{csinf}, @code{csinhf}, @code{csinhl}, @code{csinh}, @code{csinl},
11467 @code{csin}, @code{csqrtf}, @code{csqrtl}, @code{csqrt}, @code{ctanf},
11468 @code{ctanhf}, @code{ctanhl}, @code{ctanh}, @code{ctanl}, @code{ctan},
11469 @code{erfcf}, @code{erfcl}, @code{erfc}, @code{erff}, @code{erfl},
11470 @code{erf}, @code{exp2f}, @code{exp2l}, @code{exp2}, @code{expm1f},
11471 @code{expm1l}, @code{expm1}, @code{fdimf}, @code{fdiml}, @code{fdim},
11472 @code{fmaf}, @code{fmal}, @code{fmaxf}, @code{fmaxl}, @code{fmax},
11473 @code{fma}, @code{fminf}, @code{fminl}, @code{fmin}, @code{hypotf},
11474 @code{hypotl}, @code{hypot}, @code{ilogbf}, @code{ilogbl}, @code{ilogb},
11475 @code{imaxabs}, @code{isblank}, @code{iswblank}, @code{lgammaf},
11476 @code{lgammal}, @code{lgamma}, @code{llabs}, @code{llrintf}, @code{llrintl},
11477 @code{llrint}, @code{llroundf}, @code{llroundl}, @code{llround},
11478 @code{log1pf}, @code{log1pl}, @code{log1p}, @code{log2f}, @code{log2l},
11479 @code{log2}, @code{logbf}, @code{logbl}, @code{logb}, @code{lrintf},
11480 @code{lrintl}, @code{lrint}, @code{lroundf}, @code{lroundl},
11481 @code{lround}, @code{nearbyintf}, @code{nearbyintl}, @code{nearbyint},
11482 @code{nextafterf}, @code{nextafterl}, @code{nextafter},
11483 @code{nexttowardf}, @code{nexttowardl}, @code{nexttoward},
11484 @code{remainderf}, @code{remainderl}, @code{remainder}, @code{remquof},
11485 @code{remquol}, @code{remquo}, @code{rintf}, @code{rintl}, @code{rint},
11486 @code{roundf}, @code{roundl}, @code{round}, @code{scalblnf},
11487 @code{scalblnl}, @code{scalbln}, @code{scalbnf}, @code{scalbnl},
11488 @code{scalbn}, @code{snprintf}, @code{tgammaf}, @code{tgammal},
11489 @code{tgamma}, @code{truncf}, @code{truncl}, @code{trunc},
11490 @code{vfscanf}, @code{vscanf}, @code{vsnprintf} and @code{vsscanf}
11491 are handled as built-in functions
11492 except in strict ISO C90 mode (@option{-ansi} or @option{-std=c90}).
11494 There are also built-in versions of the ISO C99 functions
11495 @code{acosf}, @code{acosl}, @code{asinf}, @code{asinl}, @code{atan2f},
11496 @code{atan2l}, @code{atanf}, @code{atanl}, @code{ceilf}, @code{ceill},
11497 @code{cosf}, @code{coshf}, @code{coshl}, @code{cosl}, @code{expf},
11498 @code{expl}, @code{fabsf}, @code{fabsl}, @code{floorf}, @code{floorl},
11499 @code{fmodf}, @code{fmodl}, @code{frexpf}, @code{frexpl}, @code{ldexpf},
11500 @code{ldexpl}, @code{log10f}, @code{log10l}, @code{logf}, @code{logl},
11501 @code{modfl}, @code{modf}, @code{powf}, @code{powl}, @code{sinf},
11502 @code{sinhf}, @code{sinhl}, @code{sinl}, @code{sqrtf}, @code{sqrtl},
11503 @code{tanf}, @code{tanhf}, @code{tanhl} and @code{tanl}
11504 that are recognized in any mode since ISO C90 reserves these names for
11505 the purpose to which ISO C99 puts them.  All these functions have
11506 corresponding versions prefixed with @code{__builtin_}.
11508 There are also built-in functions @code{__builtin_fabsf@var{n}},
11509 @code{__builtin_fabsf@var{n}x}, @code{__builtin_copysignf@var{n}} and
11510 @code{__builtin_copysignf@var{n}x}, corresponding to the TS 18661-3
11511 functions @code{fabsf@var{n}}, @code{fabsf@var{n}x},
11512 @code{copysignf@var{n}} and @code{copysignf@var{n}x}, for supported
11513 types @code{_Float@var{n}} and @code{_Float@var{n}x}.
11515 There are also GNU extension functions @code{clog10}, @code{clog10f} and
11516 @code{clog10l} which names are reserved by ISO C99 for future use.
11517 All these functions have versions prefixed with @code{__builtin_}.
11519 The ISO C94 functions
11520 @code{iswalnum}, @code{iswalpha}, @code{iswcntrl}, @code{iswdigit},
11521 @code{iswgraph}, @code{iswlower}, @code{iswprint}, @code{iswpunct},
11522 @code{iswspace}, @code{iswupper}, @code{iswxdigit}, @code{towlower} and
11523 @code{towupper}
11524 are handled as built-in functions
11525 except in strict ISO C90 mode (@option{-ansi} or @option{-std=c90}).
11527 The ISO C90 functions
11528 @code{abort}, @code{abs}, @code{acos}, @code{asin}, @code{atan2},
11529 @code{atan}, @code{calloc}, @code{ceil}, @code{cosh}, @code{cos},
11530 @code{exit}, @code{exp}, @code{fabs}, @code{floor}, @code{fmod},
11531 @code{fprintf}, @code{fputs}, @code{frexp}, @code{fscanf},
11532 @code{isalnum}, @code{isalpha}, @code{iscntrl}, @code{isdigit},
11533 @code{isgraph}, @code{islower}, @code{isprint}, @code{ispunct},
11534 @code{isspace}, @code{isupper}, @code{isxdigit}, @code{tolower},
11535 @code{toupper}, @code{labs}, @code{ldexp}, @code{log10}, @code{log},
11536 @code{malloc}, @code{memchr}, @code{memcmp}, @code{memcpy},
11537 @code{memset}, @code{modf}, @code{pow}, @code{printf}, @code{putchar},
11538 @code{puts}, @code{scanf}, @code{sinh}, @code{sin}, @code{snprintf},
11539 @code{sprintf}, @code{sqrt}, @code{sscanf}, @code{strcat},
11540 @code{strchr}, @code{strcmp}, @code{strcpy}, @code{strcspn},
11541 @code{strlen}, @code{strncat}, @code{strncmp}, @code{strncpy},
11542 @code{strpbrk}, @code{strrchr}, @code{strspn}, @code{strstr},
11543 @code{tanh}, @code{tan}, @code{vfprintf}, @code{vprintf} and @code{vsprintf}
11544 are all recognized as built-in functions unless
11545 @option{-fno-builtin} is specified (or @option{-fno-builtin-@var{function}}
11546 is specified for an individual function).  All of these functions have
11547 corresponding versions prefixed with @code{__builtin_}.
11549 GCC provides built-in versions of the ISO C99 floating-point comparison
11550 macros that avoid raising exceptions for unordered operands.  They have
11551 the same names as the standard macros ( @code{isgreater},
11552 @code{isgreaterequal}, @code{isless}, @code{islessequal},
11553 @code{islessgreater}, and @code{isunordered}) , with @code{__builtin_}
11554 prefixed.  We intend for a library implementor to be able to simply
11555 @code{#define} each standard macro to its built-in equivalent.
11556 In the same fashion, GCC provides @code{fpclassify}, @code{isfinite},
11557 @code{isinf_sign}, @code{isnormal} and @code{signbit} built-ins used with
11558 @code{__builtin_} prefixed.  The @code{isinf} and @code{isnan}
11559 built-in functions appear both with and without the @code{__builtin_} prefix.
11561 @deftypefn {Built-in Function} void *__builtin_alloca (size_t size)
11562 The @code{__builtin_alloca} function must be called at block scope.
11563 The function allocates an object @var{size} bytes large on the stack
11564 of the calling function.  The object is aligned on the default stack
11565 alignment boundary for the target determined by the
11566 @code{__BIGGEST_ALIGNMENT__} macro.  The @code{__builtin_alloca}
11567 function returns a pointer to the first byte of the allocated object.
11568 The lifetime of the allocated object ends just before the calling
11569 function returns to its caller.   This is so even when
11570 @code{__builtin_alloca} is called within a nested block.
11572 For example, the following function allocates eight objects of @code{n}
11573 bytes each on the stack, storing a pointer to each in consecutive elements
11574 of the array @code{a}.  It then passes the array to function @code{g}
11575 which can safely use the storage pointed to by each of the array elements.
11577 @smallexample
11578 void f (unsigned n)
11580   void *a [8];
11581   for (int i = 0; i != 8; ++i)
11582     a [i] = __builtin_alloca (n);
11584   g (a, n);   // @r{safe}
11586 @end smallexample
11588 Since the @code{__builtin_alloca} function doesn't validate its argument
11589 it is the responsibility of its caller to make sure the argument doesn't
11590 cause it to exceed the stack size limit.
11591 The @code{__builtin_alloca} function is provided to make it possible to
11592 allocate on the stack arrays of bytes with an upper bound that may be
11593 computed at run time.  Since C99 Variable Length Arrays offer
11594 similar functionality under a portable, more convenient, and safer
11595 interface they are recommended instead, in both C99 and C++ programs
11596 where GCC provides them as an extension.
11597 @xref{Variable Length}, for details.
11599 @end deftypefn
11601 @deftypefn {Built-in Function} void *__builtin_alloca_with_align (size_t size, size_t alignment)
11602 The @code{__builtin_alloca_with_align} function must be called at block
11603 scope.  The function allocates an object @var{size} bytes large on
11604 the stack of the calling function.  The allocated object is aligned on
11605 the boundary specified by the argument @var{alignment} whose unit is given
11606 in bits (not bytes).  The @var{size} argument must be positive and not
11607 exceed the stack size limit.  The @var{alignment} argument must be a constant
11608 integer expression that evaluates to a power of 2 greater than or equal to
11609 @code{CHAR_BIT} and less than some unspecified maximum.  Invocations
11610 with other values are rejected with an error indicating the valid bounds.
11611 The function returns a pointer to the first byte of the allocated object.
11612 The lifetime of the allocated object ends at the end of the block in which
11613 the function was called.  The allocated storage is released no later than
11614 just before the calling function returns to its caller, but may be released
11615 at the end of the block in which the function was called.
11617 For example, in the following function the call to @code{g} is unsafe
11618 because when @code{overalign} is non-zero, the space allocated by
11619 @code{__builtin_alloca_with_align} may have been released at the end
11620 of the @code{if} statement in which it was called.
11622 @smallexample
11623 void f (unsigned n, bool overalign)
11625   void *p;
11626   if (overalign)
11627     p = __builtin_alloca_with_align (n, 64 /* bits */);
11628   else
11629     p = __builtin_alloc (n);
11631   g (p, n);   // @r{unsafe}
11633 @end smallexample
11635 Since the @code{__builtin_alloca_with_align} function doesn't validate its
11636 @var{size} argument it is the responsibility of its caller to make sure
11637 the argument doesn't cause it to exceed the stack size limit.
11638 The @code{__builtin_alloca_with_align} function is provided to make
11639 it possible to allocate on the stack overaligned arrays of bytes with
11640 an upper bound that may be computed at run time.  Since C99
11641 Variable Length Arrays offer the same functionality under
11642 a portable, more convenient, and safer interface they are recommended
11643 instead, in both C99 and C++ programs where GCC provides them as
11644 an extension.  @xref{Variable Length}, for details.
11646 @end deftypefn
11648 @deftypefn {Built-in Function} void *__builtin_alloca_with_align_and_max (size_t size, size_t alignment, size_t max_size)
11649 Similar to @code{__builtin_alloca_with_align} but takes an extra argument
11650 specifying an upper bound for @var{size} in case its value cannot be computed
11651 at compile time, for use by @option{-fstack-usage}, @option{-Wstack-usage}
11652 and @option{-Walloca-larger-than}.  @var{max_size} must be a constant integer
11653 expression, it has no effect on code generation and no attempt is made to
11654 check its compatibility with @var{size}.
11656 @end deftypefn
11658 @deftypefn {Built-in Function} int __builtin_types_compatible_p (@var{type1}, @var{type2})
11660 You can use the built-in function @code{__builtin_types_compatible_p} to
11661 determine whether two types are the same.
11663 This built-in function returns 1 if the unqualified versions of the
11664 types @var{type1} and @var{type2} (which are types, not expressions) are
11665 compatible, 0 otherwise.  The result of this built-in function can be
11666 used in integer constant expressions.
11668 This built-in function ignores top level qualifiers (e.g., @code{const},
11669 @code{volatile}).  For example, @code{int} is equivalent to @code{const
11670 int}.
11672 The type @code{int[]} and @code{int[5]} are compatible.  On the other
11673 hand, @code{int} and @code{char *} are not compatible, even if the size
11674 of their types, on the particular architecture are the same.  Also, the
11675 amount of pointer indirection is taken into account when determining
11676 similarity.  Consequently, @code{short *} is not similar to
11677 @code{short **}.  Furthermore, two types that are typedefed are
11678 considered compatible if their underlying types are compatible.
11680 An @code{enum} type is not considered to be compatible with another
11681 @code{enum} type even if both are compatible with the same integer
11682 type; this is what the C standard specifies.
11683 For example, @code{enum @{foo, bar@}} is not similar to
11684 @code{enum @{hot, dog@}}.
11686 You typically use this function in code whose execution varies
11687 depending on the arguments' types.  For example:
11689 @smallexample
11690 #define foo(x)                                                  \
11691   (@{                                                           \
11692     typeof (x) tmp = (x);                                       \
11693     if (__builtin_types_compatible_p (typeof (x), long double)) \
11694       tmp = foo_long_double (tmp);                              \
11695     else if (__builtin_types_compatible_p (typeof (x), double)) \
11696       tmp = foo_double (tmp);                                   \
11697     else if (__builtin_types_compatible_p (typeof (x), float))  \
11698       tmp = foo_float (tmp);                                    \
11699     else                                                        \
11700       abort ();                                                 \
11701     tmp;                                                        \
11702   @})
11703 @end smallexample
11705 @emph{Note:} This construct is only available for C@.
11707 @end deftypefn
11709 @deftypefn {Built-in Function} @var{type} __builtin_call_with_static_chain (@var{call_exp}, @var{pointer_exp})
11711 The @var{call_exp} expression must be a function call, and the
11712 @var{pointer_exp} expression must be a pointer.  The @var{pointer_exp}
11713 is passed to the function call in the target's static chain location.
11714 The result of builtin is the result of the function call.
11716 @emph{Note:} This builtin is only available for C@.
11717 This builtin can be used to call Go closures from C.
11719 @end deftypefn
11721 @deftypefn {Built-in Function} @var{type} __builtin_choose_expr (@var{const_exp}, @var{exp1}, @var{exp2})
11723 You can use the built-in function @code{__builtin_choose_expr} to
11724 evaluate code depending on the value of a constant expression.  This
11725 built-in function returns @var{exp1} if @var{const_exp}, which is an
11726 integer constant expression, is nonzero.  Otherwise it returns @var{exp2}.
11728 This built-in function is analogous to the @samp{? :} operator in C,
11729 except that the expression returned has its type unaltered by promotion
11730 rules.  Also, the built-in function does not evaluate the expression
11731 that is not chosen.  For example, if @var{const_exp} evaluates to true,
11732 @var{exp2} is not evaluated even if it has side-effects.
11734 This built-in function can return an lvalue if the chosen argument is an
11735 lvalue.
11737 If @var{exp1} is returned, the return type is the same as @var{exp1}'s
11738 type.  Similarly, if @var{exp2} is returned, its return type is the same
11739 as @var{exp2}.
11741 Example:
11743 @smallexample
11744 #define foo(x)                                                    \
11745   __builtin_choose_expr (                                         \
11746     __builtin_types_compatible_p (typeof (x), double),            \
11747     foo_double (x),                                               \
11748     __builtin_choose_expr (                                       \
11749       __builtin_types_compatible_p (typeof (x), float),           \
11750       foo_float (x),                                              \
11751       /* @r{The void expression results in a compile-time error}  \
11752          @r{when assigning the result to something.}  */          \
11753       (void)0))
11754 @end smallexample
11756 @emph{Note:} This construct is only available for C@.  Furthermore, the
11757 unused expression (@var{exp1} or @var{exp2} depending on the value of
11758 @var{const_exp}) may still generate syntax errors.  This may change in
11759 future revisions.
11761 @end deftypefn
11763 @deftypefn {Built-in Function} @var{type} __builtin_tgmath (@var{functions}, @var{arguments})
11765 The built-in function @code{__builtin_tgmath}, available only for C
11766 and Objective-C, calls a function determined according to the rules of
11767 @code{<tgmath.h>} macros.  It is intended to be used in
11768 implementations of that header, so that expansions of macros from that
11769 header only expand each of their arguments once, to avoid problems
11770 when calls to such macros are nested inside the arguments of other
11771 calls to such macros; in addition, it results in better diagnostics
11772 for invalid calls to @code{<tgmath.h>} macros than implementations
11773 using other GNU C language features.  For example, the @code{pow}
11774 type-generic macro might be defined as:
11776 @smallexample
11777 #define pow(a, b) __builtin_tgmath (powf, pow, powl, \
11778                                     cpowf, cpow, cpowl, a, b)
11779 @end smallexample
11781 The arguments to @code{__builtin_tgmath} are at least two pointers to
11782 functions, followed by the arguments to the type-generic macro (which
11783 will be passed as arguments to the selected function).  All the
11784 pointers to functions must be pointers to prototyped functions, none
11785 of which may have variable arguments, and all of which must have the
11786 same number of parameters; the number of parameters of the first
11787 function determines how many arguments to @code{__builtin_tgmath} are
11788 interpreted as function pointers, and how many as the arguments to the
11789 called function.
11791 The types of the specified functions must all be different, but
11792 related to each other in the same way as a set of functions that may
11793 be selected between by a macro in @code{<tgmath.h>}.  This means that
11794 the functions are parameterized by a floating-point type @var{t},
11795 different for each such function.  The function return types may all
11796 be the same type, or they may be @var{t} for each function, or they
11797 may be the real type corresponding to @var{t} for each function (if
11798 some of the types @var{t} are complex).  Likewise, for each parameter
11799 position, the type of the parameter in that position may always be the
11800 same type, or may be @var{t} for each function (this case must apply
11801 for at least one parameter position), or may be the real type
11802 corresponding to @var{t} for each function.
11804 The standard rules for @code{<tgmath.h>} macros are used to find a
11805 common type @var{u} from the types of the arguments for parameters
11806 whose types vary between the functions; complex integer types (a GNU
11807 extension) are treated like @code{_Complex double} for this purpose.
11808 If the function return types vary, or are all the same integer type,
11809 the function called is the one for which @var{t} is @var{u}, and it is
11810 an error if there is no such function.  If the function return types
11811 are all the same floating-point type, the type-generic macro is taken
11812 to be one of those from TS 18661 that rounds the result to a narrower
11813 type; if there is a function for which @var{t} is @var{u}, it is
11814 called, and otherwise the first function, if any, for which @var{t}
11815 has at least the range and precision of @var{u} is called, and it is
11816 an error if there is no such function.
11818 @end deftypefn
11820 @deftypefn {Built-in Function} @var{type} __builtin_complex (@var{real}, @var{imag})
11822 The built-in function @code{__builtin_complex} is provided for use in
11823 implementing the ISO C11 macros @code{CMPLXF}, @code{CMPLX} and
11824 @code{CMPLXL}.  @var{real} and @var{imag} must have the same type, a
11825 real binary floating-point type, and the result has the corresponding
11826 complex type with real and imaginary parts @var{real} and @var{imag}.
11827 Unlike @samp{@var{real} + I * @var{imag}}, this works even when
11828 infinities, NaNs and negative zeros are involved.
11830 @end deftypefn
11832 @deftypefn {Built-in Function} int __builtin_constant_p (@var{exp})
11833 You can use the built-in function @code{__builtin_constant_p} to
11834 determine if a value is known to be constant at compile time and hence
11835 that GCC can perform constant-folding on expressions involving that
11836 value.  The argument of the function is the value to test.  The function
11837 returns the integer 1 if the argument is known to be a compile-time
11838 constant and 0 if it is not known to be a compile-time constant.  A
11839 return of 0 does not indicate that the value is @emph{not} a constant,
11840 but merely that GCC cannot prove it is a constant with the specified
11841 value of the @option{-O} option.
11843 You typically use this function in an embedded application where
11844 memory is a critical resource.  If you have some complex calculation,
11845 you may want it to be folded if it involves constants, but need to call
11846 a function if it does not.  For example:
11848 @smallexample
11849 #define Scale_Value(X)      \
11850   (__builtin_constant_p (X) \
11851   ? ((X) * SCALE + OFFSET) : Scale (X))
11852 @end smallexample
11854 You may use this built-in function in either a macro or an inline
11855 function.  However, if you use it in an inlined function and pass an
11856 argument of the function as the argument to the built-in, GCC 
11857 never returns 1 when you call the inline function with a string constant
11858 or compound literal (@pxref{Compound Literals}) and does not return 1
11859 when you pass a constant numeric value to the inline function unless you
11860 specify the @option{-O} option.
11862 You may also use @code{__builtin_constant_p} in initializers for static
11863 data.  For instance, you can write
11865 @smallexample
11866 static const int table[] = @{
11867    __builtin_constant_p (EXPRESSION) ? (EXPRESSION) : -1,
11868    /* @r{@dots{}} */
11870 @end smallexample
11872 @noindent
11873 This is an acceptable initializer even if @var{EXPRESSION} is not a
11874 constant expression, including the case where
11875 @code{__builtin_constant_p} returns 1 because @var{EXPRESSION} can be
11876 folded to a constant but @var{EXPRESSION} contains operands that are
11877 not otherwise permitted in a static initializer (for example,
11878 @code{0 && foo ()}).  GCC must be more conservative about evaluating the
11879 built-in in this case, because it has no opportunity to perform
11880 optimization.
11881 @end deftypefn
11883 @deftypefn {Built-in Function} long __builtin_expect (long @var{exp}, long @var{c})
11884 @opindex fprofile-arcs
11885 You may use @code{__builtin_expect} to provide the compiler with
11886 branch prediction information.  In general, you should prefer to
11887 use actual profile feedback for this (@option{-fprofile-arcs}), as
11888 programmers are notoriously bad at predicting how their programs
11889 actually perform.  However, there are applications in which this
11890 data is hard to collect.
11892 The return value is the value of @var{exp}, which should be an integral
11893 expression.  The semantics of the built-in are that it is expected that
11894 @var{exp} == @var{c}.  For example:
11896 @smallexample
11897 if (__builtin_expect (x, 0))
11898   foo ();
11899 @end smallexample
11901 @noindent
11902 indicates that we do not expect to call @code{foo}, since
11903 we expect @code{x} to be zero.  Since you are limited to integral
11904 expressions for @var{exp}, you should use constructions such as
11906 @smallexample
11907 if (__builtin_expect (ptr != NULL, 1))
11908   foo (*ptr);
11909 @end smallexample
11911 @noindent
11912 when testing pointer or floating-point values.
11913 @end deftypefn
11915 @deftypefn {Built-in Function} void __builtin_trap (void)
11916 This function causes the program to exit abnormally.  GCC implements
11917 this function by using a target-dependent mechanism (such as
11918 intentionally executing an illegal instruction) or by calling
11919 @code{abort}.  The mechanism used may vary from release to release so
11920 you should not rely on any particular implementation.
11921 @end deftypefn
11923 @deftypefn {Built-in Function} void __builtin_unreachable (void)
11924 If control flow reaches the point of the @code{__builtin_unreachable},
11925 the program is undefined.  It is useful in situations where the
11926 compiler cannot deduce the unreachability of the code.
11928 One such case is immediately following an @code{asm} statement that
11929 either never terminates, or one that transfers control elsewhere
11930 and never returns.  In this example, without the
11931 @code{__builtin_unreachable}, GCC issues a warning that control
11932 reaches the end of a non-void function.  It also generates code
11933 to return after the @code{asm}.
11935 @smallexample
11936 int f (int c, int v)
11938   if (c)
11939     @{
11940       return v;
11941     @}
11942   else
11943     @{
11944       asm("jmp error_handler");
11945       __builtin_unreachable ();
11946     @}
11948 @end smallexample
11950 @noindent
11951 Because the @code{asm} statement unconditionally transfers control out
11952 of the function, control never reaches the end of the function
11953 body.  The @code{__builtin_unreachable} is in fact unreachable and
11954 communicates this fact to the compiler.
11956 Another use for @code{__builtin_unreachable} is following a call a
11957 function that never returns but that is not declared
11958 @code{__attribute__((noreturn))}, as in this example:
11960 @smallexample
11961 void function_that_never_returns (void);
11963 int g (int c)
11965   if (c)
11966     @{
11967       return 1;
11968     @}
11969   else
11970     @{
11971       function_that_never_returns ();
11972       __builtin_unreachable ();
11973     @}
11975 @end smallexample
11977 @end deftypefn
11979 @deftypefn {Built-in Function} {void *} __builtin_assume_aligned (const void *@var{exp}, size_t @var{align}, ...)
11980 This function returns its first argument, and allows the compiler
11981 to assume that the returned pointer is at least @var{align} bytes
11982 aligned.  This built-in can have either two or three arguments,
11983 if it has three, the third argument should have integer type, and
11984 if it is nonzero means misalignment offset.  For example:
11986 @smallexample
11987 void *x = __builtin_assume_aligned (arg, 16);
11988 @end smallexample
11990 @noindent
11991 means that the compiler can assume @code{x}, set to @code{arg}, is at least
11992 16-byte aligned, while:
11994 @smallexample
11995 void *x = __builtin_assume_aligned (arg, 32, 8);
11996 @end smallexample
11998 @noindent
11999 means that the compiler can assume for @code{x}, set to @code{arg}, that
12000 @code{(char *) x - 8} is 32-byte aligned.
12001 @end deftypefn
12003 @deftypefn {Built-in Function} int __builtin_LINE ()
12004 This function is the equivalent of the preprocessor @code{__LINE__}
12005 macro and returns a constant integer expression that evaluates to
12006 the line number of the invocation of the built-in.  When used as a C++
12007 default argument for a function @var{F}, it returns the line number
12008 of the call to @var{F}.
12009 @end deftypefn
12011 @deftypefn {Built-in Function} {const char *} __builtin_FUNCTION ()
12012 This function is the equivalent of the @code{__FUNCTION__} symbol
12013 and returns an address constant pointing to the name of the function
12014 from which the built-in was invoked, or the empty string if
12015 the invocation is not at function scope.  When used as a C++ default
12016 argument for a function @var{F}, it returns the name of @var{F}'s
12017 caller or the empty string if the call was not made at function
12018 scope.
12019 @end deftypefn
12021 @deftypefn {Built-in Function} {const char *} __builtin_FILE ()
12022 This function is the equivalent of the preprocessor @code{__FILE__}
12023 macro and returns an address constant pointing to the file name
12024 containing the invocation of the built-in, or the empty string if
12025 the invocation is not at function scope.  When used as a C++ default
12026 argument for a function @var{F}, it returns the file name of the call
12027 to @var{F} or the empty string if the call was not made at function
12028 scope.
12030 For example, in the following, each call to function @code{foo} will
12031 print a line similar to @code{"file.c:123: foo: message"} with the name
12032 of the file and the line number of the @code{printf} call, the name of
12033 the function @code{foo}, followed by the word @code{message}.
12035 @smallexample
12036 const char*
12037 function (const char *func = __builtin_FUNCTION ())
12039   return func;
12042 void foo (void)
12044   printf ("%s:%i: %s: message\n", file (), line (), function ());
12046 @end smallexample
12048 @end deftypefn
12050 @deftypefn {Built-in Function} void __builtin___clear_cache (char *@var{begin}, char *@var{end})
12051 This function is used to flush the processor's instruction cache for
12052 the region of memory between @var{begin} inclusive and @var{end}
12053 exclusive.  Some targets require that the instruction cache be
12054 flushed, after modifying memory containing code, in order to obtain
12055 deterministic behavior.
12057 If the target does not require instruction cache flushes,
12058 @code{__builtin___clear_cache} has no effect.  Otherwise either
12059 instructions are emitted in-line to clear the instruction cache or a
12060 call to the @code{__clear_cache} function in libgcc is made.
12061 @end deftypefn
12063 @deftypefn {Built-in Function} void __builtin_prefetch (const void *@var{addr}, ...)
12064 This function is used to minimize cache-miss latency by moving data into
12065 a cache before it is accessed.
12066 You can insert calls to @code{__builtin_prefetch} into code for which
12067 you know addresses of data in memory that is likely to be accessed soon.
12068 If the target supports them, data prefetch instructions are generated.
12069 If the prefetch is done early enough before the access then the data will
12070 be in the cache by the time it is accessed.
12072 The value of @var{addr} is the address of the memory to prefetch.
12073 There are two optional arguments, @var{rw} and @var{locality}.
12074 The value of @var{rw} is a compile-time constant one or zero; one
12075 means that the prefetch is preparing for a write to the memory address
12076 and zero, the default, means that the prefetch is preparing for a read.
12077 The value @var{locality} must be a compile-time constant integer between
12078 zero and three.  A value of zero means that the data has no temporal
12079 locality, so it need not be left in the cache after the access.  A value
12080 of three means that the data has a high degree of temporal locality and
12081 should be left in all levels of cache possible.  Values of one and two
12082 mean, respectively, a low or moderate degree of temporal locality.  The
12083 default is three.
12085 @smallexample
12086 for (i = 0; i < n; i++)
12087   @{
12088     a[i] = a[i] + b[i];
12089     __builtin_prefetch (&a[i+j], 1, 1);
12090     __builtin_prefetch (&b[i+j], 0, 1);
12091     /* @r{@dots{}} */
12092   @}
12093 @end smallexample
12095 Data prefetch does not generate faults if @var{addr} is invalid, but
12096 the address expression itself must be valid.  For example, a prefetch
12097 of @code{p->next} does not fault if @code{p->next} is not a valid
12098 address, but evaluation faults if @code{p} is not a valid address.
12100 If the target does not support data prefetch, the address expression
12101 is evaluated if it includes side effects but no other code is generated
12102 and GCC does not issue a warning.
12103 @end deftypefn
12105 @deftypefn {Built-in Function} double __builtin_huge_val (void)
12106 Returns a positive infinity, if supported by the floating-point format,
12107 else @code{DBL_MAX}.  This function is suitable for implementing the
12108 ISO C macro @code{HUGE_VAL}.
12109 @end deftypefn
12111 @deftypefn {Built-in Function} float __builtin_huge_valf (void)
12112 Similar to @code{__builtin_huge_val}, except the return type is @code{float}.
12113 @end deftypefn
12115 @deftypefn {Built-in Function} {long double} __builtin_huge_vall (void)
12116 Similar to @code{__builtin_huge_val}, except the return
12117 type is @code{long double}.
12118 @end deftypefn
12120 @deftypefn {Built-in Function} _Float@var{n} __builtin_huge_valf@var{n} (void)
12121 Similar to @code{__builtin_huge_val}, except the return type is
12122 @code{_Float@var{n}}.
12123 @end deftypefn
12125 @deftypefn {Built-in Function} _Float@var{n}x __builtin_huge_valf@var{n}x (void)
12126 Similar to @code{__builtin_huge_val}, except the return type is
12127 @code{_Float@var{n}x}.
12128 @end deftypefn
12130 @deftypefn {Built-in Function} int __builtin_fpclassify (int, int, int, int, int, ...)
12131 This built-in implements the C99 fpclassify functionality.  The first
12132 five int arguments should be the target library's notion of the
12133 possible FP classes and are used for return values.  They must be
12134 constant values and they must appear in this order: @code{FP_NAN},
12135 @code{FP_INFINITE}, @code{FP_NORMAL}, @code{FP_SUBNORMAL} and
12136 @code{FP_ZERO}.  The ellipsis is for exactly one floating-point value
12137 to classify.  GCC treats the last argument as type-generic, which
12138 means it does not do default promotion from float to double.
12139 @end deftypefn
12141 @deftypefn {Built-in Function} double __builtin_inf (void)
12142 Similar to @code{__builtin_huge_val}, except a warning is generated
12143 if the target floating-point format does not support infinities.
12144 @end deftypefn
12146 @deftypefn {Built-in Function} _Decimal32 __builtin_infd32 (void)
12147 Similar to @code{__builtin_inf}, except the return type is @code{_Decimal32}.
12148 @end deftypefn
12150 @deftypefn {Built-in Function} _Decimal64 __builtin_infd64 (void)
12151 Similar to @code{__builtin_inf}, except the return type is @code{_Decimal64}.
12152 @end deftypefn
12154 @deftypefn {Built-in Function} _Decimal128 __builtin_infd128 (void)
12155 Similar to @code{__builtin_inf}, except the return type is @code{_Decimal128}.
12156 @end deftypefn
12158 @deftypefn {Built-in Function} float __builtin_inff (void)
12159 Similar to @code{__builtin_inf}, except the return type is @code{float}.
12160 This function is suitable for implementing the ISO C99 macro @code{INFINITY}.
12161 @end deftypefn
12163 @deftypefn {Built-in Function} {long double} __builtin_infl (void)
12164 Similar to @code{__builtin_inf}, except the return
12165 type is @code{long double}.
12166 @end deftypefn
12168 @deftypefn {Built-in Function} _Float@var{n} __builtin_inff@var{n} (void)
12169 Similar to @code{__builtin_inf}, except the return
12170 type is @code{_Float@var{n}}.
12171 @end deftypefn
12173 @deftypefn {Built-in Function} _Float@var{n} __builtin_inff@var{n}x (void)
12174 Similar to @code{__builtin_inf}, except the return
12175 type is @code{_Float@var{n}x}.
12176 @end deftypefn
12178 @deftypefn {Built-in Function} int __builtin_isinf_sign (...)
12179 Similar to @code{isinf}, except the return value is -1 for
12180 an argument of @code{-Inf} and 1 for an argument of @code{+Inf}.
12181 Note while the parameter list is an
12182 ellipsis, this function only accepts exactly one floating-point
12183 argument.  GCC treats this parameter as type-generic, which means it
12184 does not do default promotion from float to double.
12185 @end deftypefn
12187 @deftypefn {Built-in Function} double __builtin_nan (const char *str)
12188 This is an implementation of the ISO C99 function @code{nan}.
12190 Since ISO C99 defines this function in terms of @code{strtod}, which we
12191 do not implement, a description of the parsing is in order.  The string
12192 is parsed as by @code{strtol}; that is, the base is recognized by
12193 leading @samp{0} or @samp{0x} prefixes.  The number parsed is placed
12194 in the significand such that the least significant bit of the number
12195 is at the least significant bit of the significand.  The number is
12196 truncated to fit the significand field provided.  The significand is
12197 forced to be a quiet NaN@.
12199 This function, if given a string literal all of which would have been
12200 consumed by @code{strtol}, is evaluated early enough that it is considered a
12201 compile-time constant.
12202 @end deftypefn
12204 @deftypefn {Built-in Function} _Decimal32 __builtin_nand32 (const char *str)
12205 Similar to @code{__builtin_nan}, except the return type is @code{_Decimal32}.
12206 @end deftypefn
12208 @deftypefn {Built-in Function} _Decimal64 __builtin_nand64 (const char *str)
12209 Similar to @code{__builtin_nan}, except the return type is @code{_Decimal64}.
12210 @end deftypefn
12212 @deftypefn {Built-in Function} _Decimal128 __builtin_nand128 (const char *str)
12213 Similar to @code{__builtin_nan}, except the return type is @code{_Decimal128}.
12214 @end deftypefn
12216 @deftypefn {Built-in Function} float __builtin_nanf (const char *str)
12217 Similar to @code{__builtin_nan}, except the return type is @code{float}.
12218 @end deftypefn
12220 @deftypefn {Built-in Function} {long double} __builtin_nanl (const char *str)
12221 Similar to @code{__builtin_nan}, except the return type is @code{long double}.
12222 @end deftypefn
12224 @deftypefn {Built-in Function} _Float@var{n} __builtin_nanf@var{n} (const char *str)
12225 Similar to @code{__builtin_nan}, except the return type is
12226 @code{_Float@var{n}}.
12227 @end deftypefn
12229 @deftypefn {Built-in Function} _Float@var{n}x __builtin_nanf@var{n}x (const char *str)
12230 Similar to @code{__builtin_nan}, except the return type is
12231 @code{_Float@var{n}x}.
12232 @end deftypefn
12234 @deftypefn {Built-in Function} double __builtin_nans (const char *str)
12235 Similar to @code{__builtin_nan}, except the significand is forced
12236 to be a signaling NaN@.  The @code{nans} function is proposed by
12237 @uref{http://www.open-std.org/jtc1/sc22/wg14/www/docs/n965.htm,,WG14 N965}.
12238 @end deftypefn
12240 @deftypefn {Built-in Function} float __builtin_nansf (const char *str)
12241 Similar to @code{__builtin_nans}, except the return type is @code{float}.
12242 @end deftypefn
12244 @deftypefn {Built-in Function} {long double} __builtin_nansl (const char *str)
12245 Similar to @code{__builtin_nans}, except the return type is @code{long double}.
12246 @end deftypefn
12248 @deftypefn {Built-in Function} _Float@var{n} __builtin_nansf@var{n} (const char *str)
12249 Similar to @code{__builtin_nans}, except the return type is
12250 @code{_Float@var{n}}.
12251 @end deftypefn
12253 @deftypefn {Built-in Function} _Float@var{n}x __builtin_nansf@var{n}x (const char *str)
12254 Similar to @code{__builtin_nans}, except the return type is
12255 @code{_Float@var{n}x}.
12256 @end deftypefn
12258 @deftypefn {Built-in Function} int __builtin_ffs (int x)
12259 Returns one plus the index of the least significant 1-bit of @var{x}, or
12260 if @var{x} is zero, returns zero.
12261 @end deftypefn
12263 @deftypefn {Built-in Function} int __builtin_clz (unsigned int x)
12264 Returns the number of leading 0-bits in @var{x}, starting at the most
12265 significant bit position.  If @var{x} is 0, the result is undefined.
12266 @end deftypefn
12268 @deftypefn {Built-in Function} int __builtin_ctz (unsigned int x)
12269 Returns the number of trailing 0-bits in @var{x}, starting at the least
12270 significant bit position.  If @var{x} is 0, the result is undefined.
12271 @end deftypefn
12273 @deftypefn {Built-in Function} int __builtin_clrsb (int x)
12274 Returns the number of leading redundant sign bits in @var{x}, i.e.@: the
12275 number of bits following the most significant bit that are identical
12276 to it.  There are no special cases for 0 or other values. 
12277 @end deftypefn
12279 @deftypefn {Built-in Function} int __builtin_popcount (unsigned int x)
12280 Returns the number of 1-bits in @var{x}.
12281 @end deftypefn
12283 @deftypefn {Built-in Function} int __builtin_parity (unsigned int x)
12284 Returns the parity of @var{x}, i.e.@: the number of 1-bits in @var{x}
12285 modulo 2.
12286 @end deftypefn
12288 @deftypefn {Built-in Function} int __builtin_ffsl (long)
12289 Similar to @code{__builtin_ffs}, except the argument type is
12290 @code{long}.
12291 @end deftypefn
12293 @deftypefn {Built-in Function} int __builtin_clzl (unsigned long)
12294 Similar to @code{__builtin_clz}, except the argument type is
12295 @code{unsigned long}.
12296 @end deftypefn
12298 @deftypefn {Built-in Function} int __builtin_ctzl (unsigned long)
12299 Similar to @code{__builtin_ctz}, except the argument type is
12300 @code{unsigned long}.
12301 @end deftypefn
12303 @deftypefn {Built-in Function} int __builtin_clrsbl (long)
12304 Similar to @code{__builtin_clrsb}, except the argument type is
12305 @code{long}.
12306 @end deftypefn
12308 @deftypefn {Built-in Function} int __builtin_popcountl (unsigned long)
12309 Similar to @code{__builtin_popcount}, except the argument type is
12310 @code{unsigned long}.
12311 @end deftypefn
12313 @deftypefn {Built-in Function} int __builtin_parityl (unsigned long)
12314 Similar to @code{__builtin_parity}, except the argument type is
12315 @code{unsigned long}.
12316 @end deftypefn
12318 @deftypefn {Built-in Function} int __builtin_ffsll (long long)
12319 Similar to @code{__builtin_ffs}, except the argument type is
12320 @code{long long}.
12321 @end deftypefn
12323 @deftypefn {Built-in Function} int __builtin_clzll (unsigned long long)
12324 Similar to @code{__builtin_clz}, except the argument type is
12325 @code{unsigned long long}.
12326 @end deftypefn
12328 @deftypefn {Built-in Function} int __builtin_ctzll (unsigned long long)
12329 Similar to @code{__builtin_ctz}, except the argument type is
12330 @code{unsigned long long}.
12331 @end deftypefn
12333 @deftypefn {Built-in Function} int __builtin_clrsbll (long long)
12334 Similar to @code{__builtin_clrsb}, except the argument type is
12335 @code{long long}.
12336 @end deftypefn
12338 @deftypefn {Built-in Function} int __builtin_popcountll (unsigned long long)
12339 Similar to @code{__builtin_popcount}, except the argument type is
12340 @code{unsigned long long}.
12341 @end deftypefn
12343 @deftypefn {Built-in Function} int __builtin_parityll (unsigned long long)
12344 Similar to @code{__builtin_parity}, except the argument type is
12345 @code{unsigned long long}.
12346 @end deftypefn
12348 @deftypefn {Built-in Function} double __builtin_powi (double, int)
12349 Returns the first argument raised to the power of the second.  Unlike the
12350 @code{pow} function no guarantees about precision and rounding are made.
12351 @end deftypefn
12353 @deftypefn {Built-in Function} float __builtin_powif (float, int)
12354 Similar to @code{__builtin_powi}, except the argument and return types
12355 are @code{float}.
12356 @end deftypefn
12358 @deftypefn {Built-in Function} {long double} __builtin_powil (long double, int)
12359 Similar to @code{__builtin_powi}, except the argument and return types
12360 are @code{long double}.
12361 @end deftypefn
12363 @deftypefn {Built-in Function} uint16_t __builtin_bswap16 (uint16_t x)
12364 Returns @var{x} with the order of the bytes reversed; for example,
12365 @code{0xaabb} becomes @code{0xbbaa}.  Byte here always means
12366 exactly 8 bits.
12367 @end deftypefn
12369 @deftypefn {Built-in Function} uint32_t __builtin_bswap32 (uint32_t x)
12370 Similar to @code{__builtin_bswap16}, except the argument and return types
12371 are 32 bit.
12372 @end deftypefn
12374 @deftypefn {Built-in Function} uint64_t __builtin_bswap64 (uint64_t x)
12375 Similar to @code{__builtin_bswap32}, except the argument and return types
12376 are 64 bit.
12377 @end deftypefn
12379 @node Target Builtins
12380 @section Built-in Functions Specific to Particular Target Machines
12382 On some target machines, GCC supports many built-in functions specific
12383 to those machines.  Generally these generate calls to specific machine
12384 instructions, but allow the compiler to schedule those calls.
12386 @menu
12387 * AArch64 Built-in Functions::
12388 * Alpha Built-in Functions::
12389 * Altera Nios II Built-in Functions::
12390 * ARC Built-in Functions::
12391 * ARC SIMD Built-in Functions::
12392 * ARM iWMMXt Built-in Functions::
12393 * ARM C Language Extensions (ACLE)::
12394 * ARM Floating Point Status and Control Intrinsics::
12395 * ARM ARMv8-M Security Extensions::
12396 * AVR Built-in Functions::
12397 * Blackfin Built-in Functions::
12398 * FR-V Built-in Functions::
12399 * MIPS DSP Built-in Functions::
12400 * MIPS Paired-Single Support::
12401 * MIPS Loongson Built-in Functions::
12402 * MIPS SIMD Architecture (MSA) Support::
12403 * Other MIPS Built-in Functions::
12404 * MSP430 Built-in Functions::
12405 * NDS32 Built-in Functions::
12406 * picoChip Built-in Functions::
12407 * PowerPC Built-in Functions::
12408 * PowerPC AltiVec/VSX Built-in Functions::
12409 * PowerPC Hardware Transactional Memory Built-in Functions::
12410 * PowerPC Atomic Memory Operation Functions::
12411 * RX Built-in Functions::
12412 * S/390 System z Built-in Functions::
12413 * SH Built-in Functions::
12414 * SPARC VIS Built-in Functions::
12415 * SPU Built-in Functions::
12416 * TI C6X Built-in Functions::
12417 * TILE-Gx Built-in Functions::
12418 * TILEPro Built-in Functions::
12419 * x86 Built-in Functions::
12420 * x86 transactional memory intrinsics::
12421 @end menu
12423 @node AArch64 Built-in Functions
12424 @subsection AArch64 Built-in Functions
12426 These built-in functions are available for the AArch64 family of
12427 processors.
12428 @smallexample
12429 unsigned int __builtin_aarch64_get_fpcr ()
12430 void __builtin_aarch64_set_fpcr (unsigned int)
12431 unsigned int __builtin_aarch64_get_fpsr ()
12432 void __builtin_aarch64_set_fpsr (unsigned int)
12433 @end smallexample
12435 @node Alpha Built-in Functions
12436 @subsection Alpha Built-in Functions
12438 These built-in functions are available for the Alpha family of
12439 processors, depending on the command-line switches used.
12441 The following built-in functions are always available.  They
12442 all generate the machine instruction that is part of the name.
12444 @smallexample
12445 long __builtin_alpha_implver (void)
12446 long __builtin_alpha_rpcc (void)
12447 long __builtin_alpha_amask (long)
12448 long __builtin_alpha_cmpbge (long, long)
12449 long __builtin_alpha_extbl (long, long)
12450 long __builtin_alpha_extwl (long, long)
12451 long __builtin_alpha_extll (long, long)
12452 long __builtin_alpha_extql (long, long)
12453 long __builtin_alpha_extwh (long, long)
12454 long __builtin_alpha_extlh (long, long)
12455 long __builtin_alpha_extqh (long, long)
12456 long __builtin_alpha_insbl (long, long)
12457 long __builtin_alpha_inswl (long, long)
12458 long __builtin_alpha_insll (long, long)
12459 long __builtin_alpha_insql (long, long)
12460 long __builtin_alpha_inswh (long, long)
12461 long __builtin_alpha_inslh (long, long)
12462 long __builtin_alpha_insqh (long, long)
12463 long __builtin_alpha_mskbl (long, long)
12464 long __builtin_alpha_mskwl (long, long)
12465 long __builtin_alpha_mskll (long, long)
12466 long __builtin_alpha_mskql (long, long)
12467 long __builtin_alpha_mskwh (long, long)
12468 long __builtin_alpha_msklh (long, long)
12469 long __builtin_alpha_mskqh (long, long)
12470 long __builtin_alpha_umulh (long, long)
12471 long __builtin_alpha_zap (long, long)
12472 long __builtin_alpha_zapnot (long, long)
12473 @end smallexample
12475 The following built-in functions are always with @option{-mmax}
12476 or @option{-mcpu=@var{cpu}} where @var{cpu} is @code{pca56} or
12477 later.  They all generate the machine instruction that is part
12478 of the name.
12480 @smallexample
12481 long __builtin_alpha_pklb (long)
12482 long __builtin_alpha_pkwb (long)
12483 long __builtin_alpha_unpkbl (long)
12484 long __builtin_alpha_unpkbw (long)
12485 long __builtin_alpha_minub8 (long, long)
12486 long __builtin_alpha_minsb8 (long, long)
12487 long __builtin_alpha_minuw4 (long, long)
12488 long __builtin_alpha_minsw4 (long, long)
12489 long __builtin_alpha_maxub8 (long, long)
12490 long __builtin_alpha_maxsb8 (long, long)
12491 long __builtin_alpha_maxuw4 (long, long)
12492 long __builtin_alpha_maxsw4 (long, long)
12493 long __builtin_alpha_perr (long, long)
12494 @end smallexample
12496 The following built-in functions are always with @option{-mcix}
12497 or @option{-mcpu=@var{cpu}} where @var{cpu} is @code{ev67} or
12498 later.  They all generate the machine instruction that is part
12499 of the name.
12501 @smallexample
12502 long __builtin_alpha_cttz (long)
12503 long __builtin_alpha_ctlz (long)
12504 long __builtin_alpha_ctpop (long)
12505 @end smallexample
12507 The following built-in functions are available on systems that use the OSF/1
12508 PALcode.  Normally they invoke the @code{rduniq} and @code{wruniq}
12509 PAL calls, but when invoked with @option{-mtls-kernel}, they invoke
12510 @code{rdval} and @code{wrval}.
12512 @smallexample
12513 void *__builtin_thread_pointer (void)
12514 void __builtin_set_thread_pointer (void *)
12515 @end smallexample
12517 @node Altera Nios II Built-in Functions
12518 @subsection Altera Nios II Built-in Functions
12520 These built-in functions are available for the Altera Nios II
12521 family of processors.
12523 The following built-in functions are always available.  They
12524 all generate the machine instruction that is part of the name.
12526 @example
12527 int __builtin_ldbio (volatile const void *)
12528 int __builtin_ldbuio (volatile const void *)
12529 int __builtin_ldhio (volatile const void *)
12530 int __builtin_ldhuio (volatile const void *)
12531 int __builtin_ldwio (volatile const void *)
12532 void __builtin_stbio (volatile void *, int)
12533 void __builtin_sthio (volatile void *, int)
12534 void __builtin_stwio (volatile void *, int)
12535 void __builtin_sync (void)
12536 int __builtin_rdctl (int) 
12537 int __builtin_rdprs (int, int)
12538 void __builtin_wrctl (int, int)
12539 void __builtin_flushd (volatile void *)
12540 void __builtin_flushda (volatile void *)
12541 int __builtin_wrpie (int);
12542 void __builtin_eni (int);
12543 int __builtin_ldex (volatile const void *)
12544 int __builtin_stex (volatile void *, int)
12545 int __builtin_ldsex (volatile const void *)
12546 int __builtin_stsex (volatile void *, int)
12547 @end example
12549 The following built-in functions are always available.  They
12550 all generate a Nios II Custom Instruction. The name of the
12551 function represents the types that the function takes and
12552 returns. The letter before the @code{n} is the return type
12553 or void if absent. The @code{n} represents the first parameter
12554 to all the custom instructions, the custom instruction number.
12555 The two letters after the @code{n} represent the up to two
12556 parameters to the function.
12558 The letters represent the following data types:
12559 @table @code
12560 @item <no letter>
12561 @code{void} for return type and no parameter for parameter types.
12563 @item i
12564 @code{int} for return type and parameter type
12566 @item f
12567 @code{float} for return type and parameter type
12569 @item p
12570 @code{void *} for return type and parameter type
12572 @end table
12574 And the function names are:
12575 @example
12576 void __builtin_custom_n (void)
12577 void __builtin_custom_ni (int)
12578 void __builtin_custom_nf (float)
12579 void __builtin_custom_np (void *)
12580 void __builtin_custom_nii (int, int)
12581 void __builtin_custom_nif (int, float)
12582 void __builtin_custom_nip (int, void *)
12583 void __builtin_custom_nfi (float, int)
12584 void __builtin_custom_nff (float, float)
12585 void __builtin_custom_nfp (float, void *)
12586 void __builtin_custom_npi (void *, int)
12587 void __builtin_custom_npf (void *, float)
12588 void __builtin_custom_npp (void *, void *)
12589 int __builtin_custom_in (void)
12590 int __builtin_custom_ini (int)
12591 int __builtin_custom_inf (float)
12592 int __builtin_custom_inp (void *)
12593 int __builtin_custom_inii (int, int)
12594 int __builtin_custom_inif (int, float)
12595 int __builtin_custom_inip (int, void *)
12596 int __builtin_custom_infi (float, int)
12597 int __builtin_custom_inff (float, float)
12598 int __builtin_custom_infp (float, void *)
12599 int __builtin_custom_inpi (void *, int)
12600 int __builtin_custom_inpf (void *, float)
12601 int __builtin_custom_inpp (void *, void *)
12602 float __builtin_custom_fn (void)
12603 float __builtin_custom_fni (int)
12604 float __builtin_custom_fnf (float)
12605 float __builtin_custom_fnp (void *)
12606 float __builtin_custom_fnii (int, int)
12607 float __builtin_custom_fnif (int, float)
12608 float __builtin_custom_fnip (int, void *)
12609 float __builtin_custom_fnfi (float, int)
12610 float __builtin_custom_fnff (float, float)
12611 float __builtin_custom_fnfp (float, void *)
12612 float __builtin_custom_fnpi (void *, int)
12613 float __builtin_custom_fnpf (void *, float)
12614 float __builtin_custom_fnpp (void *, void *)
12615 void * __builtin_custom_pn (void)
12616 void * __builtin_custom_pni (int)
12617 void * __builtin_custom_pnf (float)
12618 void * __builtin_custom_pnp (void *)
12619 void * __builtin_custom_pnii (int, int)
12620 void * __builtin_custom_pnif (int, float)
12621 void * __builtin_custom_pnip (int, void *)
12622 void * __builtin_custom_pnfi (float, int)
12623 void * __builtin_custom_pnff (float, float)
12624 void * __builtin_custom_pnfp (float, void *)
12625 void * __builtin_custom_pnpi (void *, int)
12626 void * __builtin_custom_pnpf (void *, float)
12627 void * __builtin_custom_pnpp (void *, void *)
12628 @end example
12630 @node ARC Built-in Functions
12631 @subsection ARC Built-in Functions
12633 The following built-in functions are provided for ARC targets.  The
12634 built-ins generate the corresponding assembly instructions.  In the
12635 examples given below, the generated code often requires an operand or
12636 result to be in a register.  Where necessary further code will be
12637 generated to ensure this is true, but for brevity this is not
12638 described in each case.
12640 @emph{Note:} Using a built-in to generate an instruction not supported
12641 by a target may cause problems. At present the compiler is not
12642 guaranteed to detect such misuse, and as a result an internal compiler
12643 error may be generated.
12645 @deftypefn {Built-in Function} int __builtin_arc_aligned (void *@var{val}, int @var{alignval})
12646 Return 1 if @var{val} is known to have the byte alignment given
12647 by @var{alignval}, otherwise return 0.
12648 Note that this is different from
12649 @smallexample
12650 __alignof__(*(char *)@var{val}) >= alignval
12651 @end smallexample
12652 because __alignof__ sees only the type of the dereference, whereas
12653 __builtin_arc_align uses alignment information from the pointer
12654 as well as from the pointed-to type.
12655 The information available will depend on optimization level.
12656 @end deftypefn
12658 @deftypefn {Built-in Function} void __builtin_arc_brk (void)
12659 Generates
12660 @example
12662 @end example
12663 @end deftypefn
12665 @deftypefn {Built-in Function} {unsigned int} __builtin_arc_core_read (unsigned int @var{regno})
12666 The operand is the number of a register to be read.  Generates:
12667 @example
12668 mov  @var{dest}, r@var{regno}
12669 @end example
12670 where the value in @var{dest} will be the result returned from the
12671 built-in.
12672 @end deftypefn
12674 @deftypefn {Built-in Function} void __builtin_arc_core_write (unsigned int @var{regno}, unsigned int @var{val})
12675 The first operand is the number of a register to be written, the
12676 second operand is a compile time constant to write into that
12677 register.  Generates:
12678 @example
12679 mov  r@var{regno}, @var{val}
12680 @end example
12681 @end deftypefn
12683 @deftypefn {Built-in Function} int __builtin_arc_divaw (int @var{a}, int @var{b})
12684 Only available if either @option{-mcpu=ARC700} or @option{-meA} is set.
12685 Generates:
12686 @example
12687 divaw  @var{dest}, @var{a}, @var{b}
12688 @end example
12689 where the value in @var{dest} will be the result returned from the
12690 built-in.
12691 @end deftypefn
12693 @deftypefn {Built-in Function} void __builtin_arc_flag (unsigned int @var{a})
12694 Generates
12695 @example
12696 flag  @var{a}
12697 @end example
12698 @end deftypefn
12700 @deftypefn {Built-in Function} {unsigned int} __builtin_arc_lr (unsigned int @var{auxr})
12701 The operand, @var{auxv}, is the address of an auxiliary register and
12702 must be a compile time constant.  Generates:
12703 @example
12704 lr  @var{dest}, [@var{auxr}]
12705 @end example
12706 Where the value in @var{dest} will be the result returned from the
12707 built-in.
12708 @end deftypefn
12710 @deftypefn {Built-in Function} void __builtin_arc_mul64 (int @var{a}, int @var{b})
12711 Only available with @option{-mmul64}.  Generates:
12712 @example
12713 mul64  @var{a}, @var{b}
12714 @end example
12715 @end deftypefn
12717 @deftypefn {Built-in Function} void __builtin_arc_mulu64 (unsigned int @var{a}, unsigned int @var{b})
12718 Only available with @option{-mmul64}.  Generates:
12719 @example
12720 mulu64  @var{a}, @var{b}
12721 @end example
12722 @end deftypefn
12724 @deftypefn {Built-in Function} void __builtin_arc_nop (void)
12725 Generates:
12726 @example
12728 @end example
12729 @end deftypefn
12731 @deftypefn {Built-in Function} int __builtin_arc_norm (int @var{src})
12732 Only valid if the @samp{norm} instruction is available through the
12733 @option{-mnorm} option or by default with @option{-mcpu=ARC700}.
12734 Generates:
12735 @example
12736 norm  @var{dest}, @var{src}
12737 @end example
12738 Where the value in @var{dest} will be the result returned from the
12739 built-in.
12740 @end deftypefn
12742 @deftypefn {Built-in Function}  {short int} __builtin_arc_normw (short int @var{src})
12743 Only valid if the @samp{normw} instruction is available through the
12744 @option{-mnorm} option or by default with @option{-mcpu=ARC700}.
12745 Generates:
12746 @example
12747 normw  @var{dest}, @var{src}
12748 @end example
12749 Where the value in @var{dest} will be the result returned from the
12750 built-in.
12751 @end deftypefn
12753 @deftypefn {Built-in Function}  void __builtin_arc_rtie (void)
12754 Generates:
12755 @example
12756 rtie
12757 @end example
12758 @end deftypefn
12760 @deftypefn {Built-in Function}  void __builtin_arc_sleep (int @var{a}
12761 Generates:
12762 @example
12763 sleep  @var{a}
12764 @end example
12765 @end deftypefn
12767 @deftypefn {Built-in Function}  void __builtin_arc_sr (unsigned int @var{auxr}, unsigned int @var{val})
12768 The first argument, @var{auxv}, is the address of an auxiliary
12769 register, the second argument, @var{val}, is a compile time constant
12770 to be written to the register.  Generates:
12771 @example
12772 sr  @var{auxr}, [@var{val}]
12773 @end example
12774 @end deftypefn
12776 @deftypefn {Built-in Function}  int __builtin_arc_swap (int @var{src})
12777 Only valid with @option{-mswap}.  Generates:
12778 @example
12779 swap  @var{dest}, @var{src}
12780 @end example
12781 Where the value in @var{dest} will be the result returned from the
12782 built-in.
12783 @end deftypefn
12785 @deftypefn {Built-in Function}  void __builtin_arc_swi (void)
12786 Generates:
12787 @example
12789 @end example
12790 @end deftypefn
12792 @deftypefn {Built-in Function}  void __builtin_arc_sync (void)
12793 Only available with @option{-mcpu=ARC700}.  Generates:
12794 @example
12795 sync
12796 @end example
12797 @end deftypefn
12799 @deftypefn {Built-in Function}  void __builtin_arc_trap_s (unsigned int @var{c})
12800 Only available with @option{-mcpu=ARC700}.  Generates:
12801 @example
12802 trap_s  @var{c}
12803 @end example
12804 @end deftypefn
12806 @deftypefn {Built-in Function}  void __builtin_arc_unimp_s (void)
12807 Only available with @option{-mcpu=ARC700}.  Generates:
12808 @example
12809 unimp_s
12810 @end example
12811 @end deftypefn
12813 The instructions generated by the following builtins are not
12814 considered as candidates for scheduling.  They are not moved around by
12815 the compiler during scheduling, and thus can be expected to appear
12816 where they are put in the C code:
12817 @example
12818 __builtin_arc_brk()
12819 __builtin_arc_core_read()
12820 __builtin_arc_core_write()
12821 __builtin_arc_flag()
12822 __builtin_arc_lr()
12823 __builtin_arc_sleep()
12824 __builtin_arc_sr()
12825 __builtin_arc_swi()
12826 @end example
12828 @node ARC SIMD Built-in Functions
12829 @subsection ARC SIMD Built-in Functions
12831 SIMD builtins provided by the compiler can be used to generate the
12832 vector instructions.  This section describes the available builtins
12833 and their usage in programs.  With the @option{-msimd} option, the
12834 compiler provides 128-bit vector types, which can be specified using
12835 the @code{vector_size} attribute.  The header file @file{arc-simd.h}
12836 can be included to use the following predefined types:
12837 @example
12838 typedef int __v4si   __attribute__((vector_size(16)));
12839 typedef short __v8hi __attribute__((vector_size(16)));
12840 @end example
12842 These types can be used to define 128-bit variables.  The built-in
12843 functions listed in the following section can be used on these
12844 variables to generate the vector operations.
12846 For all builtins, @code{__builtin_arc_@var{someinsn}}, the header file
12847 @file{arc-simd.h} also provides equivalent macros called
12848 @code{_@var{someinsn}} that can be used for programming ease and
12849 improved readability.  The following macros for DMA control are also
12850 provided:
12851 @example
12852 #define _setup_dma_in_channel_reg _vdiwr
12853 #define _setup_dma_out_channel_reg _vdowr
12854 @end example
12856 The following is a complete list of all the SIMD built-ins provided
12857 for ARC, grouped by calling signature.
12859 The following take two @code{__v8hi} arguments and return a
12860 @code{__v8hi} result:
12861 @example
12862 __v8hi __builtin_arc_vaddaw (__v8hi, __v8hi)
12863 __v8hi __builtin_arc_vaddw (__v8hi, __v8hi)
12864 __v8hi __builtin_arc_vand (__v8hi, __v8hi)
12865 __v8hi __builtin_arc_vandaw (__v8hi, __v8hi)
12866 __v8hi __builtin_arc_vavb (__v8hi, __v8hi)
12867 __v8hi __builtin_arc_vavrb (__v8hi, __v8hi)
12868 __v8hi __builtin_arc_vbic (__v8hi, __v8hi)
12869 __v8hi __builtin_arc_vbicaw (__v8hi, __v8hi)
12870 __v8hi __builtin_arc_vdifaw (__v8hi, __v8hi)
12871 __v8hi __builtin_arc_vdifw (__v8hi, __v8hi)
12872 __v8hi __builtin_arc_veqw (__v8hi, __v8hi)
12873 __v8hi __builtin_arc_vh264f (__v8hi, __v8hi)
12874 __v8hi __builtin_arc_vh264ft (__v8hi, __v8hi)
12875 __v8hi __builtin_arc_vh264fw (__v8hi, __v8hi)
12876 __v8hi __builtin_arc_vlew (__v8hi, __v8hi)
12877 __v8hi __builtin_arc_vltw (__v8hi, __v8hi)
12878 __v8hi __builtin_arc_vmaxaw (__v8hi, __v8hi)
12879 __v8hi __builtin_arc_vmaxw (__v8hi, __v8hi)
12880 __v8hi __builtin_arc_vminaw (__v8hi, __v8hi)
12881 __v8hi __builtin_arc_vminw (__v8hi, __v8hi)
12882 __v8hi __builtin_arc_vmr1aw (__v8hi, __v8hi)
12883 __v8hi __builtin_arc_vmr1w (__v8hi, __v8hi)
12884 __v8hi __builtin_arc_vmr2aw (__v8hi, __v8hi)
12885 __v8hi __builtin_arc_vmr2w (__v8hi, __v8hi)
12886 __v8hi __builtin_arc_vmr3aw (__v8hi, __v8hi)
12887 __v8hi __builtin_arc_vmr3w (__v8hi, __v8hi)
12888 __v8hi __builtin_arc_vmr4aw (__v8hi, __v8hi)
12889 __v8hi __builtin_arc_vmr4w (__v8hi, __v8hi)
12890 __v8hi __builtin_arc_vmr5aw (__v8hi, __v8hi)
12891 __v8hi __builtin_arc_vmr5w (__v8hi, __v8hi)
12892 __v8hi __builtin_arc_vmr6aw (__v8hi, __v8hi)
12893 __v8hi __builtin_arc_vmr6w (__v8hi, __v8hi)
12894 __v8hi __builtin_arc_vmr7aw (__v8hi, __v8hi)
12895 __v8hi __builtin_arc_vmr7w (__v8hi, __v8hi)
12896 __v8hi __builtin_arc_vmrb (__v8hi, __v8hi)
12897 __v8hi __builtin_arc_vmulaw (__v8hi, __v8hi)
12898 __v8hi __builtin_arc_vmulfaw (__v8hi, __v8hi)
12899 __v8hi __builtin_arc_vmulfw (__v8hi, __v8hi)
12900 __v8hi __builtin_arc_vmulw (__v8hi, __v8hi)
12901 __v8hi __builtin_arc_vnew (__v8hi, __v8hi)
12902 __v8hi __builtin_arc_vor (__v8hi, __v8hi)
12903 __v8hi __builtin_arc_vsubaw (__v8hi, __v8hi)
12904 __v8hi __builtin_arc_vsubw (__v8hi, __v8hi)
12905 __v8hi __builtin_arc_vsummw (__v8hi, __v8hi)
12906 __v8hi __builtin_arc_vvc1f (__v8hi, __v8hi)
12907 __v8hi __builtin_arc_vvc1ft (__v8hi, __v8hi)
12908 __v8hi __builtin_arc_vxor (__v8hi, __v8hi)
12909 __v8hi __builtin_arc_vxoraw (__v8hi, __v8hi)
12910 @end example
12912 The following take one @code{__v8hi} and one @code{int} argument and return a
12913 @code{__v8hi} result:
12915 @example
12916 __v8hi __builtin_arc_vbaddw (__v8hi, int)
12917 __v8hi __builtin_arc_vbmaxw (__v8hi, int)
12918 __v8hi __builtin_arc_vbminw (__v8hi, int)
12919 __v8hi __builtin_arc_vbmulaw (__v8hi, int)
12920 __v8hi __builtin_arc_vbmulfw (__v8hi, int)
12921 __v8hi __builtin_arc_vbmulw (__v8hi, int)
12922 __v8hi __builtin_arc_vbrsubw (__v8hi, int)
12923 __v8hi __builtin_arc_vbsubw (__v8hi, int)
12924 @end example
12926 The following take one @code{__v8hi} argument and one @code{int} argument which
12927 must be a 3-bit compile time constant indicating a register number
12928 I0-I7.  They return a @code{__v8hi} result.
12929 @example
12930 __v8hi __builtin_arc_vasrw (__v8hi, const int)
12931 __v8hi __builtin_arc_vsr8 (__v8hi, const int)
12932 __v8hi __builtin_arc_vsr8aw (__v8hi, const int)
12933 @end example
12935 The following take one @code{__v8hi} argument and one @code{int}
12936 argument which must be a 6-bit compile time constant.  They return a
12937 @code{__v8hi} result.
12938 @example
12939 __v8hi __builtin_arc_vasrpwbi (__v8hi, const int)
12940 __v8hi __builtin_arc_vasrrpwbi (__v8hi, const int)
12941 __v8hi __builtin_arc_vasrrwi (__v8hi, const int)
12942 __v8hi __builtin_arc_vasrsrwi (__v8hi, const int)
12943 __v8hi __builtin_arc_vasrwi (__v8hi, const int)
12944 __v8hi __builtin_arc_vsr8awi (__v8hi, const int)
12945 __v8hi __builtin_arc_vsr8i (__v8hi, const int)
12946 @end example
12948 The following take one @code{__v8hi} argument and one @code{int} argument which
12949 must be a 8-bit compile time constant.  They return a @code{__v8hi}
12950 result.
12951 @example
12952 __v8hi __builtin_arc_vd6tapf (__v8hi, const int)
12953 __v8hi __builtin_arc_vmvaw (__v8hi, const int)
12954 __v8hi __builtin_arc_vmvw (__v8hi, const int)
12955 __v8hi __builtin_arc_vmvzw (__v8hi, const int)
12956 @end example
12958 The following take two @code{int} arguments, the second of which which
12959 must be a 8-bit compile time constant.  They return a @code{__v8hi}
12960 result:
12961 @example
12962 __v8hi __builtin_arc_vmovaw (int, const int)
12963 __v8hi __builtin_arc_vmovw (int, const int)
12964 __v8hi __builtin_arc_vmovzw (int, const int)
12965 @end example
12967 The following take a single @code{__v8hi} argument and return a
12968 @code{__v8hi} result:
12969 @example
12970 __v8hi __builtin_arc_vabsaw (__v8hi)
12971 __v8hi __builtin_arc_vabsw (__v8hi)
12972 __v8hi __builtin_arc_vaddsuw (__v8hi)
12973 __v8hi __builtin_arc_vexch1 (__v8hi)
12974 __v8hi __builtin_arc_vexch2 (__v8hi)
12975 __v8hi __builtin_arc_vexch4 (__v8hi)
12976 __v8hi __builtin_arc_vsignw (__v8hi)
12977 __v8hi __builtin_arc_vupbaw (__v8hi)
12978 __v8hi __builtin_arc_vupbw (__v8hi)
12979 __v8hi __builtin_arc_vupsbaw (__v8hi)
12980 __v8hi __builtin_arc_vupsbw (__v8hi)
12981 @end example
12983 The following take two @code{int} arguments and return no result:
12984 @example
12985 void __builtin_arc_vdirun (int, int)
12986 void __builtin_arc_vdorun (int, int)
12987 @end example
12989 The following take two @code{int} arguments and return no result.  The
12990 first argument must a 3-bit compile time constant indicating one of
12991 the DR0-DR7 DMA setup channels:
12992 @example
12993 void __builtin_arc_vdiwr (const int, int)
12994 void __builtin_arc_vdowr (const int, int)
12995 @end example
12997 The following take an @code{int} argument and return no result:
12998 @example
12999 void __builtin_arc_vendrec (int)
13000 void __builtin_arc_vrec (int)
13001 void __builtin_arc_vrecrun (int)
13002 void __builtin_arc_vrun (int)
13003 @end example
13005 The following take a @code{__v8hi} argument and two @code{int}
13006 arguments and return a @code{__v8hi} result.  The second argument must
13007 be a 3-bit compile time constants, indicating one the registers I0-I7,
13008 and the third argument must be an 8-bit compile time constant.
13010 @emph{Note:} Although the equivalent hardware instructions do not take
13011 an SIMD register as an operand, these builtins overwrite the relevant
13012 bits of the @code{__v8hi} register provided as the first argument with
13013 the value loaded from the @code{[Ib, u8]} location in the SDM.
13015 @example
13016 __v8hi __builtin_arc_vld32 (__v8hi, const int, const int)
13017 __v8hi __builtin_arc_vld32wh (__v8hi, const int, const int)
13018 __v8hi __builtin_arc_vld32wl (__v8hi, const int, const int)
13019 __v8hi __builtin_arc_vld64 (__v8hi, const int, const int)
13020 @end example
13022 The following take two @code{int} arguments and return a @code{__v8hi}
13023 result.  The first argument must be a 3-bit compile time constants,
13024 indicating one the registers I0-I7, and the second argument must be an
13025 8-bit compile time constant.
13027 @example
13028 __v8hi __builtin_arc_vld128 (const int, const int)
13029 __v8hi __builtin_arc_vld64w (const int, const int)
13030 @end example
13032 The following take a @code{__v8hi} argument and two @code{int}
13033 arguments and return no result.  The second argument must be a 3-bit
13034 compile time constants, indicating one the registers I0-I7, and the
13035 third argument must be an 8-bit compile time constant.
13037 @example
13038 void __builtin_arc_vst128 (__v8hi, const int, const int)
13039 void __builtin_arc_vst64 (__v8hi, const int, const int)
13040 @end example
13042 The following take a @code{__v8hi} argument and three @code{int}
13043 arguments and return no result.  The second argument must be a 3-bit
13044 compile-time constant, identifying the 16-bit sub-register to be
13045 stored, the third argument must be a 3-bit compile time constants,
13046 indicating one the registers I0-I7, and the fourth argument must be an
13047 8-bit compile time constant.
13049 @example
13050 void __builtin_arc_vst16_n (__v8hi, const int, const int, const int)
13051 void __builtin_arc_vst32_n (__v8hi, const int, const int, const int)
13052 @end example
13054 @node ARM iWMMXt Built-in Functions
13055 @subsection ARM iWMMXt Built-in Functions
13057 These built-in functions are available for the ARM family of
13058 processors when the @option{-mcpu=iwmmxt} switch is used:
13060 @smallexample
13061 typedef int v2si __attribute__ ((vector_size (8)));
13062 typedef short v4hi __attribute__ ((vector_size (8)));
13063 typedef char v8qi __attribute__ ((vector_size (8)));
13065 int __builtin_arm_getwcgr0 (void)
13066 void __builtin_arm_setwcgr0 (int)
13067 int __builtin_arm_getwcgr1 (void)
13068 void __builtin_arm_setwcgr1 (int)
13069 int __builtin_arm_getwcgr2 (void)
13070 void __builtin_arm_setwcgr2 (int)
13071 int __builtin_arm_getwcgr3 (void)
13072 void __builtin_arm_setwcgr3 (int)
13073 int __builtin_arm_textrmsb (v8qi, int)
13074 int __builtin_arm_textrmsh (v4hi, int)
13075 int __builtin_arm_textrmsw (v2si, int)
13076 int __builtin_arm_textrmub (v8qi, int)
13077 int __builtin_arm_textrmuh (v4hi, int)
13078 int __builtin_arm_textrmuw (v2si, int)
13079 v8qi __builtin_arm_tinsrb (v8qi, int, int)
13080 v4hi __builtin_arm_tinsrh (v4hi, int, int)
13081 v2si __builtin_arm_tinsrw (v2si, int, int)
13082 long long __builtin_arm_tmia (long long, int, int)
13083 long long __builtin_arm_tmiabb (long long, int, int)
13084 long long __builtin_arm_tmiabt (long long, int, int)
13085 long long __builtin_arm_tmiaph (long long, int, int)
13086 long long __builtin_arm_tmiatb (long long, int, int)
13087 long long __builtin_arm_tmiatt (long long, int, int)
13088 int __builtin_arm_tmovmskb (v8qi)
13089 int __builtin_arm_tmovmskh (v4hi)
13090 int __builtin_arm_tmovmskw (v2si)
13091 long long __builtin_arm_waccb (v8qi)
13092 long long __builtin_arm_wacch (v4hi)
13093 long long __builtin_arm_waccw (v2si)
13094 v8qi __builtin_arm_waddb (v8qi, v8qi)
13095 v8qi __builtin_arm_waddbss (v8qi, v8qi)
13096 v8qi __builtin_arm_waddbus (v8qi, v8qi)
13097 v4hi __builtin_arm_waddh (v4hi, v4hi)
13098 v4hi __builtin_arm_waddhss (v4hi, v4hi)
13099 v4hi __builtin_arm_waddhus (v4hi, v4hi)
13100 v2si __builtin_arm_waddw (v2si, v2si)
13101 v2si __builtin_arm_waddwss (v2si, v2si)
13102 v2si __builtin_arm_waddwus (v2si, v2si)
13103 v8qi __builtin_arm_walign (v8qi, v8qi, int)
13104 long long __builtin_arm_wand(long long, long long)
13105 long long __builtin_arm_wandn (long long, long long)
13106 v8qi __builtin_arm_wavg2b (v8qi, v8qi)
13107 v8qi __builtin_arm_wavg2br (v8qi, v8qi)
13108 v4hi __builtin_arm_wavg2h (v4hi, v4hi)
13109 v4hi __builtin_arm_wavg2hr (v4hi, v4hi)
13110 v8qi __builtin_arm_wcmpeqb (v8qi, v8qi)
13111 v4hi __builtin_arm_wcmpeqh (v4hi, v4hi)
13112 v2si __builtin_arm_wcmpeqw (v2si, v2si)
13113 v8qi __builtin_arm_wcmpgtsb (v8qi, v8qi)
13114 v4hi __builtin_arm_wcmpgtsh (v4hi, v4hi)
13115 v2si __builtin_arm_wcmpgtsw (v2si, v2si)
13116 v8qi __builtin_arm_wcmpgtub (v8qi, v8qi)
13117 v4hi __builtin_arm_wcmpgtuh (v4hi, v4hi)
13118 v2si __builtin_arm_wcmpgtuw (v2si, v2si)
13119 long long __builtin_arm_wmacs (long long, v4hi, v4hi)
13120 long long __builtin_arm_wmacsz (v4hi, v4hi)
13121 long long __builtin_arm_wmacu (long long, v4hi, v4hi)
13122 long long __builtin_arm_wmacuz (v4hi, v4hi)
13123 v4hi __builtin_arm_wmadds (v4hi, v4hi)
13124 v4hi __builtin_arm_wmaddu (v4hi, v4hi)
13125 v8qi __builtin_arm_wmaxsb (v8qi, v8qi)
13126 v4hi __builtin_arm_wmaxsh (v4hi, v4hi)
13127 v2si __builtin_arm_wmaxsw (v2si, v2si)
13128 v8qi __builtin_arm_wmaxub (v8qi, v8qi)
13129 v4hi __builtin_arm_wmaxuh (v4hi, v4hi)
13130 v2si __builtin_arm_wmaxuw (v2si, v2si)
13131 v8qi __builtin_arm_wminsb (v8qi, v8qi)
13132 v4hi __builtin_arm_wminsh (v4hi, v4hi)
13133 v2si __builtin_arm_wminsw (v2si, v2si)
13134 v8qi __builtin_arm_wminub (v8qi, v8qi)
13135 v4hi __builtin_arm_wminuh (v4hi, v4hi)
13136 v2si __builtin_arm_wminuw (v2si, v2si)
13137 v4hi __builtin_arm_wmulsm (v4hi, v4hi)
13138 v4hi __builtin_arm_wmulul (v4hi, v4hi)
13139 v4hi __builtin_arm_wmulum (v4hi, v4hi)
13140 long long __builtin_arm_wor (long long, long long)
13141 v2si __builtin_arm_wpackdss (long long, long long)
13142 v2si __builtin_arm_wpackdus (long long, long long)
13143 v8qi __builtin_arm_wpackhss (v4hi, v4hi)
13144 v8qi __builtin_arm_wpackhus (v4hi, v4hi)
13145 v4hi __builtin_arm_wpackwss (v2si, v2si)
13146 v4hi __builtin_arm_wpackwus (v2si, v2si)
13147 long long __builtin_arm_wrord (long long, long long)
13148 long long __builtin_arm_wrordi (long long, int)
13149 v4hi __builtin_arm_wrorh (v4hi, long long)
13150 v4hi __builtin_arm_wrorhi (v4hi, int)
13151 v2si __builtin_arm_wrorw (v2si, long long)
13152 v2si __builtin_arm_wrorwi (v2si, int)
13153 v2si __builtin_arm_wsadb (v2si, v8qi, v8qi)
13154 v2si __builtin_arm_wsadbz (v8qi, v8qi)
13155 v2si __builtin_arm_wsadh (v2si, v4hi, v4hi)
13156 v2si __builtin_arm_wsadhz (v4hi, v4hi)
13157 v4hi __builtin_arm_wshufh (v4hi, int)
13158 long long __builtin_arm_wslld (long long, long long)
13159 long long __builtin_arm_wslldi (long long, int)
13160 v4hi __builtin_arm_wsllh (v4hi, long long)
13161 v4hi __builtin_arm_wsllhi (v4hi, int)
13162 v2si __builtin_arm_wsllw (v2si, long long)
13163 v2si __builtin_arm_wsllwi (v2si, int)
13164 long long __builtin_arm_wsrad (long long, long long)
13165 long long __builtin_arm_wsradi (long long, int)
13166 v4hi __builtin_arm_wsrah (v4hi, long long)
13167 v4hi __builtin_arm_wsrahi (v4hi, int)
13168 v2si __builtin_arm_wsraw (v2si, long long)
13169 v2si __builtin_arm_wsrawi (v2si, int)
13170 long long __builtin_arm_wsrld (long long, long long)
13171 long long __builtin_arm_wsrldi (long long, int)
13172 v4hi __builtin_arm_wsrlh (v4hi, long long)
13173 v4hi __builtin_arm_wsrlhi (v4hi, int)
13174 v2si __builtin_arm_wsrlw (v2si, long long)
13175 v2si __builtin_arm_wsrlwi (v2si, int)
13176 v8qi __builtin_arm_wsubb (v8qi, v8qi)
13177 v8qi __builtin_arm_wsubbss (v8qi, v8qi)
13178 v8qi __builtin_arm_wsubbus (v8qi, v8qi)
13179 v4hi __builtin_arm_wsubh (v4hi, v4hi)
13180 v4hi __builtin_arm_wsubhss (v4hi, v4hi)
13181 v4hi __builtin_arm_wsubhus (v4hi, v4hi)
13182 v2si __builtin_arm_wsubw (v2si, v2si)
13183 v2si __builtin_arm_wsubwss (v2si, v2si)
13184 v2si __builtin_arm_wsubwus (v2si, v2si)
13185 v4hi __builtin_arm_wunpckehsb (v8qi)
13186 v2si __builtin_arm_wunpckehsh (v4hi)
13187 long long __builtin_arm_wunpckehsw (v2si)
13188 v4hi __builtin_arm_wunpckehub (v8qi)
13189 v2si __builtin_arm_wunpckehuh (v4hi)
13190 long long __builtin_arm_wunpckehuw (v2si)
13191 v4hi __builtin_arm_wunpckelsb (v8qi)
13192 v2si __builtin_arm_wunpckelsh (v4hi)
13193 long long __builtin_arm_wunpckelsw (v2si)
13194 v4hi __builtin_arm_wunpckelub (v8qi)
13195 v2si __builtin_arm_wunpckeluh (v4hi)
13196 long long __builtin_arm_wunpckeluw (v2si)
13197 v8qi __builtin_arm_wunpckihb (v8qi, v8qi)
13198 v4hi __builtin_arm_wunpckihh (v4hi, v4hi)
13199 v2si __builtin_arm_wunpckihw (v2si, v2si)
13200 v8qi __builtin_arm_wunpckilb (v8qi, v8qi)
13201 v4hi __builtin_arm_wunpckilh (v4hi, v4hi)
13202 v2si __builtin_arm_wunpckilw (v2si, v2si)
13203 long long __builtin_arm_wxor (long long, long long)
13204 long long __builtin_arm_wzero ()
13205 @end smallexample
13208 @node ARM C Language Extensions (ACLE)
13209 @subsection ARM C Language Extensions (ACLE)
13211 GCC implements extensions for C as described in the ARM C Language
13212 Extensions (ACLE) specification, which can be found at
13213 @uref{http://infocenter.arm.com/help/topic/com.arm.doc.ihi0053c/IHI0053C_acle_2_0.pdf}.
13215 As a part of ACLE, GCC implements extensions for Advanced SIMD as described in
13216 the ARM C Language Extensions Specification.  The complete list of Advanced SIMD
13217 intrinsics can be found at
13218 @uref{http://infocenter.arm.com/help/topic/com.arm.doc.ihi0073a/IHI0073A_arm_neon_intrinsics_ref.pdf}.
13219 The built-in intrinsics for the Advanced SIMD extension are available when
13220 NEON is enabled.
13222 Currently, ARM and AArch64 back ends do not support ACLE 2.0 fully.  Both
13223 back ends support CRC32 intrinsics and the ARM back end supports the
13224 Coprocessor intrinsics, all from @file{arm_acle.h}.  The ARM back end's 16-bit
13225 floating-point Advanced SIMD intrinsics currently comply to ACLE v1.1.
13226 AArch64's back end does not have support for 16-bit floating point Advanced SIMD
13227 intrinsics yet.
13229 See @ref{ARM Options} and @ref{AArch64 Options} for more information on the
13230 availability of extensions.
13232 @node ARM Floating Point Status and Control Intrinsics
13233 @subsection ARM Floating Point Status and Control Intrinsics
13235 These built-in functions are available for the ARM family of
13236 processors with floating-point unit.
13238 @smallexample
13239 unsigned int __builtin_arm_get_fpscr ()
13240 void __builtin_arm_set_fpscr (unsigned int)
13241 @end smallexample
13243 @node ARM ARMv8-M Security Extensions
13244 @subsection ARM ARMv8-M Security Extensions
13246 GCC implements the ARMv8-M Security Extensions as described in the ARMv8-M
13247 Security Extensions: Requirements on Development Tools Engineering
13248 Specification, which can be found at
13249 @uref{http://infocenter.arm.com/help/topic/com.arm.doc.ecm0359818/ECM0359818_armv8m_security_extensions_reqs_on_dev_tools_1_0.pdf}.
13251 As part of the Security Extensions GCC implements two new function attributes:
13252 @code{cmse_nonsecure_entry} and @code{cmse_nonsecure_call}.
13254 As part of the Security Extensions GCC implements the intrinsics below.  FPTR
13255 is used here to mean any function pointer type.
13257 @smallexample
13258 cmse_address_info_t cmse_TT (void *)
13259 cmse_address_info_t cmse_TT_fptr (FPTR)
13260 cmse_address_info_t cmse_TTT (void *)
13261 cmse_address_info_t cmse_TTT_fptr (FPTR)
13262 cmse_address_info_t cmse_TTA (void *)
13263 cmse_address_info_t cmse_TTA_fptr (FPTR)
13264 cmse_address_info_t cmse_TTAT (void *)
13265 cmse_address_info_t cmse_TTAT_fptr (FPTR)
13266 void * cmse_check_address_range (void *, size_t, int)
13267 typeof(p) cmse_nsfptr_create (FPTR p)
13268 intptr_t cmse_is_nsfptr (FPTR)
13269 int cmse_nonsecure_caller (void)
13270 @end smallexample
13272 @node AVR Built-in Functions
13273 @subsection AVR Built-in Functions
13275 For each built-in function for AVR, there is an equally named,
13276 uppercase built-in macro defined. That way users can easily query if
13277 or if not a specific built-in is implemented or not. For example, if
13278 @code{__builtin_avr_nop} is available the macro
13279 @code{__BUILTIN_AVR_NOP} is defined to @code{1} and undefined otherwise.
13281 @table @code
13283 @item void __builtin_avr_nop (void)
13284 @itemx void __builtin_avr_sei (void)
13285 @itemx void __builtin_avr_cli (void)
13286 @itemx void __builtin_avr_sleep (void)
13287 @itemx void __builtin_avr_wdr (void)
13288 @itemx unsigned char __builtin_avr_swap (unsigned char)
13289 @itemx unsigned int __builtin_avr_fmul (unsigned char, unsigned char)
13290 @itemx int __builtin_avr_fmuls (char, char)
13291 @itemx int __builtin_avr_fmulsu (char, unsigned char)
13292 These built-in functions map to the respective machine
13293 instruction, i.e.@: @code{nop}, @code{sei}, @code{cli}, @code{sleep},
13294 @code{wdr}, @code{swap}, @code{fmul}, @code{fmuls}
13295 resp. @code{fmulsu}. The three @code{fmul*} built-ins are implemented
13296 as library call if no hardware multiplier is available.
13298 @item void __builtin_avr_delay_cycles (unsigned long ticks)
13299 Delay execution for @var{ticks} cycles. Note that this
13300 built-in does not take into account the effect of interrupts that
13301 might increase delay time. @var{ticks} must be a compile-time
13302 integer constant; delays with a variable number of cycles are not supported.
13304 @item char __builtin_avr_flash_segment (const __memx void*)
13305 This built-in takes a byte address to the 24-bit
13306 @ref{AVR Named Address Spaces,address space} @code{__memx} and returns
13307 the number of the flash segment (the 64 KiB chunk) where the address
13308 points to.  Counting starts at @code{0}.
13309 If the address does not point to flash memory, return @code{-1}.
13311 @item uint8_t __builtin_avr_insert_bits (uint32_t map, uint8_t bits, uint8_t val)
13312 Insert bits from @var{bits} into @var{val} and return the resulting
13313 value. The nibbles of @var{map} determine how the insertion is
13314 performed: Let @var{X} be the @var{n}-th nibble of @var{map}
13315 @enumerate
13316 @item If @var{X} is @code{0xf},
13317 then the @var{n}-th bit of @var{val} is returned unaltered.
13319 @item If X is in the range 0@dots{}7,
13320 then the @var{n}-th result bit is set to the @var{X}-th bit of @var{bits}
13322 @item If X is in the range 8@dots{}@code{0xe},
13323 then the @var{n}-th result bit is undefined.
13324 @end enumerate
13326 @noindent
13327 One typical use case for this built-in is adjusting input and
13328 output values to non-contiguous port layouts. Some examples:
13330 @smallexample
13331 // same as val, bits is unused
13332 __builtin_avr_insert_bits (0xffffffff, bits, val)
13333 @end smallexample
13335 @smallexample
13336 // same as bits, val is unused
13337 __builtin_avr_insert_bits (0x76543210, bits, val)
13338 @end smallexample
13340 @smallexample
13341 // same as rotating bits by 4
13342 __builtin_avr_insert_bits (0x32107654, bits, 0)
13343 @end smallexample
13345 @smallexample
13346 // high nibble of result is the high nibble of val
13347 // low nibble of result is the low nibble of bits
13348 __builtin_avr_insert_bits (0xffff3210, bits, val)
13349 @end smallexample
13351 @smallexample
13352 // reverse the bit order of bits
13353 __builtin_avr_insert_bits (0x01234567, bits, 0)
13354 @end smallexample
13356 @item void __builtin_avr_nops (unsigned count)
13357 Insert @var{count} @code{NOP} instructions.
13358 The number of instructions must be a compile-time integer constant.
13360 @end table
13362 @noindent
13363 There are many more AVR-specific built-in functions that are used to
13364 implement the ISO/IEC TR 18037 ``Embedded C'' fixed-point functions of
13365 section 7.18a.6.  You don't need to use these built-ins directly.
13366 Instead, use the declarations as supplied by the @code{stdfix.h} header
13367 with GNU-C99:
13369 @smallexample
13370 #include <stdfix.h>
13372 // Re-interpret the bit representation of unsigned 16-bit
13373 // integer @var{uval} as Q-format 0.16 value.
13374 unsigned fract get_bits (uint_ur_t uval)
13376     return urbits (uval);
13378 @end smallexample
13380 @node Blackfin Built-in Functions
13381 @subsection Blackfin Built-in Functions
13383 Currently, there are two Blackfin-specific built-in functions.  These are
13384 used for generating @code{CSYNC} and @code{SSYNC} machine insns without
13385 using inline assembly; by using these built-in functions the compiler can
13386 automatically add workarounds for hardware errata involving these
13387 instructions.  These functions are named as follows:
13389 @smallexample
13390 void __builtin_bfin_csync (void)
13391 void __builtin_bfin_ssync (void)
13392 @end smallexample
13394 @node FR-V Built-in Functions
13395 @subsection FR-V Built-in Functions
13397 GCC provides many FR-V-specific built-in functions.  In general,
13398 these functions are intended to be compatible with those described
13399 by @cite{FR-V Family, Softune C/C++ Compiler Manual (V6), Fujitsu
13400 Semiconductor}.  The two exceptions are @code{__MDUNPACKH} and
13401 @code{__MBTOHE}, the GCC forms of which pass 128-bit values by
13402 pointer rather than by value.
13404 Most of the functions are named after specific FR-V instructions.
13405 Such functions are said to be ``directly mapped'' and are summarized
13406 here in tabular form.
13408 @menu
13409 * Argument Types::
13410 * Directly-mapped Integer Functions::
13411 * Directly-mapped Media Functions::
13412 * Raw read/write Functions::
13413 * Other Built-in Functions::
13414 @end menu
13416 @node Argument Types
13417 @subsubsection Argument Types
13419 The arguments to the built-in functions can be divided into three groups:
13420 register numbers, compile-time constants and run-time values.  In order
13421 to make this classification clear at a glance, the arguments and return
13422 values are given the following pseudo types:
13424 @multitable @columnfractions .20 .30 .15 .35
13425 @item Pseudo type @tab Real C type @tab Constant? @tab Description
13426 @item @code{uh} @tab @code{unsigned short} @tab No @tab an unsigned halfword
13427 @item @code{uw1} @tab @code{unsigned int} @tab No @tab an unsigned word
13428 @item @code{sw1} @tab @code{int} @tab No @tab a signed word
13429 @item @code{uw2} @tab @code{unsigned long long} @tab No
13430 @tab an unsigned doubleword
13431 @item @code{sw2} @tab @code{long long} @tab No @tab a signed doubleword
13432 @item @code{const} @tab @code{int} @tab Yes @tab an integer constant
13433 @item @code{acc} @tab @code{int} @tab Yes @tab an ACC register number
13434 @item @code{iacc} @tab @code{int} @tab Yes @tab an IACC register number
13435 @end multitable
13437 These pseudo types are not defined by GCC, they are simply a notational
13438 convenience used in this manual.
13440 Arguments of type @code{uh}, @code{uw1}, @code{sw1}, @code{uw2}
13441 and @code{sw2} are evaluated at run time.  They correspond to
13442 register operands in the underlying FR-V instructions.
13444 @code{const} arguments represent immediate operands in the underlying
13445 FR-V instructions.  They must be compile-time constants.
13447 @code{acc} arguments are evaluated at compile time and specify the number
13448 of an accumulator register.  For example, an @code{acc} argument of 2
13449 selects the ACC2 register.
13451 @code{iacc} arguments are similar to @code{acc} arguments but specify the
13452 number of an IACC register.  See @pxref{Other Built-in Functions}
13453 for more details.
13455 @node Directly-mapped Integer Functions
13456 @subsubsection Directly-Mapped Integer Functions
13458 The functions listed below map directly to FR-V I-type instructions.
13460 @multitable @columnfractions .45 .32 .23
13461 @item Function prototype @tab Example usage @tab Assembly output
13462 @item @code{sw1 __ADDSS (sw1, sw1)}
13463 @tab @code{@var{c} = __ADDSS (@var{a}, @var{b})}
13464 @tab @code{ADDSS @var{a},@var{b},@var{c}}
13465 @item @code{sw1 __SCAN (sw1, sw1)}
13466 @tab @code{@var{c} = __SCAN (@var{a}, @var{b})}
13467 @tab @code{SCAN @var{a},@var{b},@var{c}}
13468 @item @code{sw1 __SCUTSS (sw1)}
13469 @tab @code{@var{b} = __SCUTSS (@var{a})}
13470 @tab @code{SCUTSS @var{a},@var{b}}
13471 @item @code{sw1 __SLASS (sw1, sw1)}
13472 @tab @code{@var{c} = __SLASS (@var{a}, @var{b})}
13473 @tab @code{SLASS @var{a},@var{b},@var{c}}
13474 @item @code{void __SMASS (sw1, sw1)}
13475 @tab @code{__SMASS (@var{a}, @var{b})}
13476 @tab @code{SMASS @var{a},@var{b}}
13477 @item @code{void __SMSSS (sw1, sw1)}
13478 @tab @code{__SMSSS (@var{a}, @var{b})}
13479 @tab @code{SMSSS @var{a},@var{b}}
13480 @item @code{void __SMU (sw1, sw1)}
13481 @tab @code{__SMU (@var{a}, @var{b})}
13482 @tab @code{SMU @var{a},@var{b}}
13483 @item @code{sw2 __SMUL (sw1, sw1)}
13484 @tab @code{@var{c} = __SMUL (@var{a}, @var{b})}
13485 @tab @code{SMUL @var{a},@var{b},@var{c}}
13486 @item @code{sw1 __SUBSS (sw1, sw1)}
13487 @tab @code{@var{c} = __SUBSS (@var{a}, @var{b})}
13488 @tab @code{SUBSS @var{a},@var{b},@var{c}}
13489 @item @code{uw2 __UMUL (uw1, uw1)}
13490 @tab @code{@var{c} = __UMUL (@var{a}, @var{b})}
13491 @tab @code{UMUL @var{a},@var{b},@var{c}}
13492 @end multitable
13494 @node Directly-mapped Media Functions
13495 @subsubsection Directly-Mapped Media Functions
13497 The functions listed below map directly to FR-V M-type instructions.
13499 @multitable @columnfractions .45 .32 .23
13500 @item Function prototype @tab Example usage @tab Assembly output
13501 @item @code{uw1 __MABSHS (sw1)}
13502 @tab @code{@var{b} = __MABSHS (@var{a})}
13503 @tab @code{MABSHS @var{a},@var{b}}
13504 @item @code{void __MADDACCS (acc, acc)}
13505 @tab @code{__MADDACCS (@var{b}, @var{a})}
13506 @tab @code{MADDACCS @var{a},@var{b}}
13507 @item @code{sw1 __MADDHSS (sw1, sw1)}
13508 @tab @code{@var{c} = __MADDHSS (@var{a}, @var{b})}
13509 @tab @code{MADDHSS @var{a},@var{b},@var{c}}
13510 @item @code{uw1 __MADDHUS (uw1, uw1)}
13511 @tab @code{@var{c} = __MADDHUS (@var{a}, @var{b})}
13512 @tab @code{MADDHUS @var{a},@var{b},@var{c}}
13513 @item @code{uw1 __MAND (uw1, uw1)}
13514 @tab @code{@var{c} = __MAND (@var{a}, @var{b})}
13515 @tab @code{MAND @var{a},@var{b},@var{c}}
13516 @item @code{void __MASACCS (acc, acc)}
13517 @tab @code{__MASACCS (@var{b}, @var{a})}
13518 @tab @code{MASACCS @var{a},@var{b}}
13519 @item @code{uw1 __MAVEH (uw1, uw1)}
13520 @tab @code{@var{c} = __MAVEH (@var{a}, @var{b})}
13521 @tab @code{MAVEH @var{a},@var{b},@var{c}}
13522 @item @code{uw2 __MBTOH (uw1)}
13523 @tab @code{@var{b} = __MBTOH (@var{a})}
13524 @tab @code{MBTOH @var{a},@var{b}}
13525 @item @code{void __MBTOHE (uw1 *, uw1)}
13526 @tab @code{__MBTOHE (&@var{b}, @var{a})}
13527 @tab @code{MBTOHE @var{a},@var{b}}
13528 @item @code{void __MCLRACC (acc)}
13529 @tab @code{__MCLRACC (@var{a})}
13530 @tab @code{MCLRACC @var{a}}
13531 @item @code{void __MCLRACCA (void)}
13532 @tab @code{__MCLRACCA ()}
13533 @tab @code{MCLRACCA}
13534 @item @code{uw1 __Mcop1 (uw1, uw1)}
13535 @tab @code{@var{c} = __Mcop1 (@var{a}, @var{b})}
13536 @tab @code{Mcop1 @var{a},@var{b},@var{c}}
13537 @item @code{uw1 __Mcop2 (uw1, uw1)}
13538 @tab @code{@var{c} = __Mcop2 (@var{a}, @var{b})}
13539 @tab @code{Mcop2 @var{a},@var{b},@var{c}}
13540 @item @code{uw1 __MCPLHI (uw2, const)}
13541 @tab @code{@var{c} = __MCPLHI (@var{a}, @var{b})}
13542 @tab @code{MCPLHI @var{a},#@var{b},@var{c}}
13543 @item @code{uw1 __MCPLI (uw2, const)}
13544 @tab @code{@var{c} = __MCPLI (@var{a}, @var{b})}
13545 @tab @code{MCPLI @var{a},#@var{b},@var{c}}
13546 @item @code{void __MCPXIS (acc, sw1, sw1)}
13547 @tab @code{__MCPXIS (@var{c}, @var{a}, @var{b})}
13548 @tab @code{MCPXIS @var{a},@var{b},@var{c}}
13549 @item @code{void __MCPXIU (acc, uw1, uw1)}
13550 @tab @code{__MCPXIU (@var{c}, @var{a}, @var{b})}
13551 @tab @code{MCPXIU @var{a},@var{b},@var{c}}
13552 @item @code{void __MCPXRS (acc, sw1, sw1)}
13553 @tab @code{__MCPXRS (@var{c}, @var{a}, @var{b})}
13554 @tab @code{MCPXRS @var{a},@var{b},@var{c}}
13555 @item @code{void __MCPXRU (acc, uw1, uw1)}
13556 @tab @code{__MCPXRU (@var{c}, @var{a}, @var{b})}
13557 @tab @code{MCPXRU @var{a},@var{b},@var{c}}
13558 @item @code{uw1 __MCUT (acc, uw1)}
13559 @tab @code{@var{c} = __MCUT (@var{a}, @var{b})}
13560 @tab @code{MCUT @var{a},@var{b},@var{c}}
13561 @item @code{uw1 __MCUTSS (acc, sw1)}
13562 @tab @code{@var{c} = __MCUTSS (@var{a}, @var{b})}
13563 @tab @code{MCUTSS @var{a},@var{b},@var{c}}
13564 @item @code{void __MDADDACCS (acc, acc)}
13565 @tab @code{__MDADDACCS (@var{b}, @var{a})}
13566 @tab @code{MDADDACCS @var{a},@var{b}}
13567 @item @code{void __MDASACCS (acc, acc)}
13568 @tab @code{__MDASACCS (@var{b}, @var{a})}
13569 @tab @code{MDASACCS @var{a},@var{b}}
13570 @item @code{uw2 __MDCUTSSI (acc, const)}
13571 @tab @code{@var{c} = __MDCUTSSI (@var{a}, @var{b})}
13572 @tab @code{MDCUTSSI @var{a},#@var{b},@var{c}}
13573 @item @code{uw2 __MDPACKH (uw2, uw2)}
13574 @tab @code{@var{c} = __MDPACKH (@var{a}, @var{b})}
13575 @tab @code{MDPACKH @var{a},@var{b},@var{c}}
13576 @item @code{uw2 __MDROTLI (uw2, const)}
13577 @tab @code{@var{c} = __MDROTLI (@var{a}, @var{b})}
13578 @tab @code{MDROTLI @var{a},#@var{b},@var{c}}
13579 @item @code{void __MDSUBACCS (acc, acc)}
13580 @tab @code{__MDSUBACCS (@var{b}, @var{a})}
13581 @tab @code{MDSUBACCS @var{a},@var{b}}
13582 @item @code{void __MDUNPACKH (uw1 *, uw2)}
13583 @tab @code{__MDUNPACKH (&@var{b}, @var{a})}
13584 @tab @code{MDUNPACKH @var{a},@var{b}}
13585 @item @code{uw2 __MEXPDHD (uw1, const)}
13586 @tab @code{@var{c} = __MEXPDHD (@var{a}, @var{b})}
13587 @tab @code{MEXPDHD @var{a},#@var{b},@var{c}}
13588 @item @code{uw1 __MEXPDHW (uw1, const)}
13589 @tab @code{@var{c} = __MEXPDHW (@var{a}, @var{b})}
13590 @tab @code{MEXPDHW @var{a},#@var{b},@var{c}}
13591 @item @code{uw1 __MHDSETH (uw1, const)}
13592 @tab @code{@var{c} = __MHDSETH (@var{a}, @var{b})}
13593 @tab @code{MHDSETH @var{a},#@var{b},@var{c}}
13594 @item @code{sw1 __MHDSETS (const)}
13595 @tab @code{@var{b} = __MHDSETS (@var{a})}
13596 @tab @code{MHDSETS #@var{a},@var{b}}
13597 @item @code{uw1 __MHSETHIH (uw1, const)}
13598 @tab @code{@var{b} = __MHSETHIH (@var{b}, @var{a})}
13599 @tab @code{MHSETHIH #@var{a},@var{b}}
13600 @item @code{sw1 __MHSETHIS (sw1, const)}
13601 @tab @code{@var{b} = __MHSETHIS (@var{b}, @var{a})}
13602 @tab @code{MHSETHIS #@var{a},@var{b}}
13603 @item @code{uw1 __MHSETLOH (uw1, const)}
13604 @tab @code{@var{b} = __MHSETLOH (@var{b}, @var{a})}
13605 @tab @code{MHSETLOH #@var{a},@var{b}}
13606 @item @code{sw1 __MHSETLOS (sw1, const)}
13607 @tab @code{@var{b} = __MHSETLOS (@var{b}, @var{a})}
13608 @tab @code{MHSETLOS #@var{a},@var{b}}
13609 @item @code{uw1 __MHTOB (uw2)}
13610 @tab @code{@var{b} = __MHTOB (@var{a})}
13611 @tab @code{MHTOB @var{a},@var{b}}
13612 @item @code{void __MMACHS (acc, sw1, sw1)}
13613 @tab @code{__MMACHS (@var{c}, @var{a}, @var{b})}
13614 @tab @code{MMACHS @var{a},@var{b},@var{c}}
13615 @item @code{void __MMACHU (acc, uw1, uw1)}
13616 @tab @code{__MMACHU (@var{c}, @var{a}, @var{b})}
13617 @tab @code{MMACHU @var{a},@var{b},@var{c}}
13618 @item @code{void __MMRDHS (acc, sw1, sw1)}
13619 @tab @code{__MMRDHS (@var{c}, @var{a}, @var{b})}
13620 @tab @code{MMRDHS @var{a},@var{b},@var{c}}
13621 @item @code{void __MMRDHU (acc, uw1, uw1)}
13622 @tab @code{__MMRDHU (@var{c}, @var{a}, @var{b})}
13623 @tab @code{MMRDHU @var{a},@var{b},@var{c}}
13624 @item @code{void __MMULHS (acc, sw1, sw1)}
13625 @tab @code{__MMULHS (@var{c}, @var{a}, @var{b})}
13626 @tab @code{MMULHS @var{a},@var{b},@var{c}}
13627 @item @code{void __MMULHU (acc, uw1, uw1)}
13628 @tab @code{__MMULHU (@var{c}, @var{a}, @var{b})}
13629 @tab @code{MMULHU @var{a},@var{b},@var{c}}
13630 @item @code{void __MMULXHS (acc, sw1, sw1)}
13631 @tab @code{__MMULXHS (@var{c}, @var{a}, @var{b})}
13632 @tab @code{MMULXHS @var{a},@var{b},@var{c}}
13633 @item @code{void __MMULXHU (acc, uw1, uw1)}
13634 @tab @code{__MMULXHU (@var{c}, @var{a}, @var{b})}
13635 @tab @code{MMULXHU @var{a},@var{b},@var{c}}
13636 @item @code{uw1 __MNOT (uw1)}
13637 @tab @code{@var{b} = __MNOT (@var{a})}
13638 @tab @code{MNOT @var{a},@var{b}}
13639 @item @code{uw1 __MOR (uw1, uw1)}
13640 @tab @code{@var{c} = __MOR (@var{a}, @var{b})}
13641 @tab @code{MOR @var{a},@var{b},@var{c}}
13642 @item @code{uw1 __MPACKH (uh, uh)}
13643 @tab @code{@var{c} = __MPACKH (@var{a}, @var{b})}
13644 @tab @code{MPACKH @var{a},@var{b},@var{c}}
13645 @item @code{sw2 __MQADDHSS (sw2, sw2)}
13646 @tab @code{@var{c} = __MQADDHSS (@var{a}, @var{b})}
13647 @tab @code{MQADDHSS @var{a},@var{b},@var{c}}
13648 @item @code{uw2 __MQADDHUS (uw2, uw2)}
13649 @tab @code{@var{c} = __MQADDHUS (@var{a}, @var{b})}
13650 @tab @code{MQADDHUS @var{a},@var{b},@var{c}}
13651 @item @code{void __MQCPXIS (acc, sw2, sw2)}
13652 @tab @code{__MQCPXIS (@var{c}, @var{a}, @var{b})}
13653 @tab @code{MQCPXIS @var{a},@var{b},@var{c}}
13654 @item @code{void __MQCPXIU (acc, uw2, uw2)}
13655 @tab @code{__MQCPXIU (@var{c}, @var{a}, @var{b})}
13656 @tab @code{MQCPXIU @var{a},@var{b},@var{c}}
13657 @item @code{void __MQCPXRS (acc, sw2, sw2)}
13658 @tab @code{__MQCPXRS (@var{c}, @var{a}, @var{b})}
13659 @tab @code{MQCPXRS @var{a},@var{b},@var{c}}
13660 @item @code{void __MQCPXRU (acc, uw2, uw2)}
13661 @tab @code{__MQCPXRU (@var{c}, @var{a}, @var{b})}
13662 @tab @code{MQCPXRU @var{a},@var{b},@var{c}}
13663 @item @code{sw2 __MQLCLRHS (sw2, sw2)}
13664 @tab @code{@var{c} = __MQLCLRHS (@var{a}, @var{b})}
13665 @tab @code{MQLCLRHS @var{a},@var{b},@var{c}}
13666 @item @code{sw2 __MQLMTHS (sw2, sw2)}
13667 @tab @code{@var{c} = __MQLMTHS (@var{a}, @var{b})}
13668 @tab @code{MQLMTHS @var{a},@var{b},@var{c}}
13669 @item @code{void __MQMACHS (acc, sw2, sw2)}
13670 @tab @code{__MQMACHS (@var{c}, @var{a}, @var{b})}
13671 @tab @code{MQMACHS @var{a},@var{b},@var{c}}
13672 @item @code{void __MQMACHU (acc, uw2, uw2)}
13673 @tab @code{__MQMACHU (@var{c}, @var{a}, @var{b})}
13674 @tab @code{MQMACHU @var{a},@var{b},@var{c}}
13675 @item @code{void __MQMACXHS (acc, sw2, sw2)}
13676 @tab @code{__MQMACXHS (@var{c}, @var{a}, @var{b})}
13677 @tab @code{MQMACXHS @var{a},@var{b},@var{c}}
13678 @item @code{void __MQMULHS (acc, sw2, sw2)}
13679 @tab @code{__MQMULHS (@var{c}, @var{a}, @var{b})}
13680 @tab @code{MQMULHS @var{a},@var{b},@var{c}}
13681 @item @code{void __MQMULHU (acc, uw2, uw2)}
13682 @tab @code{__MQMULHU (@var{c}, @var{a}, @var{b})}
13683 @tab @code{MQMULHU @var{a},@var{b},@var{c}}
13684 @item @code{void __MQMULXHS (acc, sw2, sw2)}
13685 @tab @code{__MQMULXHS (@var{c}, @var{a}, @var{b})}
13686 @tab @code{MQMULXHS @var{a},@var{b},@var{c}}
13687 @item @code{void __MQMULXHU (acc, uw2, uw2)}
13688 @tab @code{__MQMULXHU (@var{c}, @var{a}, @var{b})}
13689 @tab @code{MQMULXHU @var{a},@var{b},@var{c}}
13690 @item @code{sw2 __MQSATHS (sw2, sw2)}
13691 @tab @code{@var{c} = __MQSATHS (@var{a}, @var{b})}
13692 @tab @code{MQSATHS @var{a},@var{b},@var{c}}
13693 @item @code{uw2 __MQSLLHI (uw2, int)}
13694 @tab @code{@var{c} = __MQSLLHI (@var{a}, @var{b})}
13695 @tab @code{MQSLLHI @var{a},@var{b},@var{c}}
13696 @item @code{sw2 __MQSRAHI (sw2, int)}
13697 @tab @code{@var{c} = __MQSRAHI (@var{a}, @var{b})}
13698 @tab @code{MQSRAHI @var{a},@var{b},@var{c}}
13699 @item @code{sw2 __MQSUBHSS (sw2, sw2)}
13700 @tab @code{@var{c} = __MQSUBHSS (@var{a}, @var{b})}
13701 @tab @code{MQSUBHSS @var{a},@var{b},@var{c}}
13702 @item @code{uw2 __MQSUBHUS (uw2, uw2)}
13703 @tab @code{@var{c} = __MQSUBHUS (@var{a}, @var{b})}
13704 @tab @code{MQSUBHUS @var{a},@var{b},@var{c}}
13705 @item @code{void __MQXMACHS (acc, sw2, sw2)}
13706 @tab @code{__MQXMACHS (@var{c}, @var{a}, @var{b})}
13707 @tab @code{MQXMACHS @var{a},@var{b},@var{c}}
13708 @item @code{void __MQXMACXHS (acc, sw2, sw2)}
13709 @tab @code{__MQXMACXHS (@var{c}, @var{a}, @var{b})}
13710 @tab @code{MQXMACXHS @var{a},@var{b},@var{c}}
13711 @item @code{uw1 __MRDACC (acc)}
13712 @tab @code{@var{b} = __MRDACC (@var{a})}
13713 @tab @code{MRDACC @var{a},@var{b}}
13714 @item @code{uw1 __MRDACCG (acc)}
13715 @tab @code{@var{b} = __MRDACCG (@var{a})}
13716 @tab @code{MRDACCG @var{a},@var{b}}
13717 @item @code{uw1 __MROTLI (uw1, const)}
13718 @tab @code{@var{c} = __MROTLI (@var{a}, @var{b})}
13719 @tab @code{MROTLI @var{a},#@var{b},@var{c}}
13720 @item @code{uw1 __MROTRI (uw1, const)}
13721 @tab @code{@var{c} = __MROTRI (@var{a}, @var{b})}
13722 @tab @code{MROTRI @var{a},#@var{b},@var{c}}
13723 @item @code{sw1 __MSATHS (sw1, sw1)}
13724 @tab @code{@var{c} = __MSATHS (@var{a}, @var{b})}
13725 @tab @code{MSATHS @var{a},@var{b},@var{c}}
13726 @item @code{uw1 __MSATHU (uw1, uw1)}
13727 @tab @code{@var{c} = __MSATHU (@var{a}, @var{b})}
13728 @tab @code{MSATHU @var{a},@var{b},@var{c}}
13729 @item @code{uw1 __MSLLHI (uw1, const)}
13730 @tab @code{@var{c} = __MSLLHI (@var{a}, @var{b})}
13731 @tab @code{MSLLHI @var{a},#@var{b},@var{c}}
13732 @item @code{sw1 __MSRAHI (sw1, const)}
13733 @tab @code{@var{c} = __MSRAHI (@var{a}, @var{b})}
13734 @tab @code{MSRAHI @var{a},#@var{b},@var{c}}
13735 @item @code{uw1 __MSRLHI (uw1, const)}
13736 @tab @code{@var{c} = __MSRLHI (@var{a}, @var{b})}
13737 @tab @code{MSRLHI @var{a},#@var{b},@var{c}}
13738 @item @code{void __MSUBACCS (acc, acc)}
13739 @tab @code{__MSUBACCS (@var{b}, @var{a})}
13740 @tab @code{MSUBACCS @var{a},@var{b}}
13741 @item @code{sw1 __MSUBHSS (sw1, sw1)}
13742 @tab @code{@var{c} = __MSUBHSS (@var{a}, @var{b})}
13743 @tab @code{MSUBHSS @var{a},@var{b},@var{c}}
13744 @item @code{uw1 __MSUBHUS (uw1, uw1)}
13745 @tab @code{@var{c} = __MSUBHUS (@var{a}, @var{b})}
13746 @tab @code{MSUBHUS @var{a},@var{b},@var{c}}
13747 @item @code{void __MTRAP (void)}
13748 @tab @code{__MTRAP ()}
13749 @tab @code{MTRAP}
13750 @item @code{uw2 __MUNPACKH (uw1)}
13751 @tab @code{@var{b} = __MUNPACKH (@var{a})}
13752 @tab @code{MUNPACKH @var{a},@var{b}}
13753 @item @code{uw1 __MWCUT (uw2, uw1)}
13754 @tab @code{@var{c} = __MWCUT (@var{a}, @var{b})}
13755 @tab @code{MWCUT @var{a},@var{b},@var{c}}
13756 @item @code{void __MWTACC (acc, uw1)}
13757 @tab @code{__MWTACC (@var{b}, @var{a})}
13758 @tab @code{MWTACC @var{a},@var{b}}
13759 @item @code{void __MWTACCG (acc, uw1)}
13760 @tab @code{__MWTACCG (@var{b}, @var{a})}
13761 @tab @code{MWTACCG @var{a},@var{b}}
13762 @item @code{uw1 __MXOR (uw1, uw1)}
13763 @tab @code{@var{c} = __MXOR (@var{a}, @var{b})}
13764 @tab @code{MXOR @var{a},@var{b},@var{c}}
13765 @end multitable
13767 @node Raw read/write Functions
13768 @subsubsection Raw Read/Write Functions
13770 This sections describes built-in functions related to read and write
13771 instructions to access memory.  These functions generate
13772 @code{membar} instructions to flush the I/O load and stores where
13773 appropriate, as described in Fujitsu's manual described above.
13775 @table @code
13777 @item unsigned char __builtin_read8 (void *@var{data})
13778 @item unsigned short __builtin_read16 (void *@var{data})
13779 @item unsigned long __builtin_read32 (void *@var{data})
13780 @item unsigned long long __builtin_read64 (void *@var{data})
13782 @item void __builtin_write8 (void *@var{data}, unsigned char @var{datum})
13783 @item void __builtin_write16 (void *@var{data}, unsigned short @var{datum})
13784 @item void __builtin_write32 (void *@var{data}, unsigned long @var{datum})
13785 @item void __builtin_write64 (void *@var{data}, unsigned long long @var{datum})
13786 @end table
13788 @node Other Built-in Functions
13789 @subsubsection Other Built-in Functions
13791 This section describes built-in functions that are not named after
13792 a specific FR-V instruction.
13794 @table @code
13795 @item sw2 __IACCreadll (iacc @var{reg})
13796 Return the full 64-bit value of IACC0@.  The @var{reg} argument is reserved
13797 for future expansion and must be 0.
13799 @item sw1 __IACCreadl (iacc @var{reg})
13800 Return the value of IACC0H if @var{reg} is 0 and IACC0L if @var{reg} is 1.
13801 Other values of @var{reg} are rejected as invalid.
13803 @item void __IACCsetll (iacc @var{reg}, sw2 @var{x})
13804 Set the full 64-bit value of IACC0 to @var{x}.  The @var{reg} argument
13805 is reserved for future expansion and must be 0.
13807 @item void __IACCsetl (iacc @var{reg}, sw1 @var{x})
13808 Set IACC0H to @var{x} if @var{reg} is 0 and IACC0L to @var{x} if @var{reg}
13809 is 1.  Other values of @var{reg} are rejected as invalid.
13811 @item void __data_prefetch0 (const void *@var{x})
13812 Use the @code{dcpl} instruction to load the contents of address @var{x}
13813 into the data cache.
13815 @item void __data_prefetch (const void *@var{x})
13816 Use the @code{nldub} instruction to load the contents of address @var{x}
13817 into the data cache.  The instruction is issued in slot I1@.
13818 @end table
13820 @node MIPS DSP Built-in Functions
13821 @subsection MIPS DSP Built-in Functions
13823 The MIPS DSP Application-Specific Extension (ASE) includes new
13824 instructions that are designed to improve the performance of DSP and
13825 media applications.  It provides instructions that operate on packed
13826 8-bit/16-bit integer data, Q7, Q15 and Q31 fractional data.
13828 GCC supports MIPS DSP operations using both the generic
13829 vector extensions (@pxref{Vector Extensions}) and a collection of
13830 MIPS-specific built-in functions.  Both kinds of support are
13831 enabled by the @option{-mdsp} command-line option.
13833 Revision 2 of the ASE was introduced in the second half of 2006.
13834 This revision adds extra instructions to the original ASE, but is
13835 otherwise backwards-compatible with it.  You can select revision 2
13836 using the command-line option @option{-mdspr2}; this option implies
13837 @option{-mdsp}.
13839 The SCOUNT and POS bits of the DSP control register are global.  The
13840 WRDSP, EXTPDP, EXTPDPV and MTHLIP instructions modify the SCOUNT and
13841 POS bits.  During optimization, the compiler does not delete these
13842 instructions and it does not delete calls to functions containing
13843 these instructions.
13845 At present, GCC only provides support for operations on 32-bit
13846 vectors.  The vector type associated with 8-bit integer data is
13847 usually called @code{v4i8}, the vector type associated with Q7
13848 is usually called @code{v4q7}, the vector type associated with 16-bit
13849 integer data is usually called @code{v2i16}, and the vector type
13850 associated with Q15 is usually called @code{v2q15}.  They can be
13851 defined in C as follows:
13853 @smallexample
13854 typedef signed char v4i8 __attribute__ ((vector_size(4)));
13855 typedef signed char v4q7 __attribute__ ((vector_size(4)));
13856 typedef short v2i16 __attribute__ ((vector_size(4)));
13857 typedef short v2q15 __attribute__ ((vector_size(4)));
13858 @end smallexample
13860 @code{v4i8}, @code{v4q7}, @code{v2i16} and @code{v2q15} values are
13861 initialized in the same way as aggregates.  For example:
13863 @smallexample
13864 v4i8 a = @{1, 2, 3, 4@};
13865 v4i8 b;
13866 b = (v4i8) @{5, 6, 7, 8@};
13868 v2q15 c = @{0x0fcb, 0x3a75@};
13869 v2q15 d;
13870 d = (v2q15) @{0.1234 * 0x1.0p15, 0.4567 * 0x1.0p15@};
13871 @end smallexample
13873 @emph{Note:} The CPU's endianness determines the order in which values
13874 are packed.  On little-endian targets, the first value is the least
13875 significant and the last value is the most significant.  The opposite
13876 order applies to big-endian targets.  For example, the code above
13877 sets the lowest byte of @code{a} to @code{1} on little-endian targets
13878 and @code{4} on big-endian targets.
13880 @emph{Note:} Q7, Q15 and Q31 values must be initialized with their integer
13881 representation.  As shown in this example, the integer representation
13882 of a Q7 value can be obtained by multiplying the fractional value by
13883 @code{0x1.0p7}.  The equivalent for Q15 values is to multiply by
13884 @code{0x1.0p15}.  The equivalent for Q31 values is to multiply by
13885 @code{0x1.0p31}.
13887 The table below lists the @code{v4i8} and @code{v2q15} operations for which
13888 hardware support exists.  @code{a} and @code{b} are @code{v4i8} values,
13889 and @code{c} and @code{d} are @code{v2q15} values.
13891 @multitable @columnfractions .50 .50
13892 @item C code @tab MIPS instruction
13893 @item @code{a + b} @tab @code{addu.qb}
13894 @item @code{c + d} @tab @code{addq.ph}
13895 @item @code{a - b} @tab @code{subu.qb}
13896 @item @code{c - d} @tab @code{subq.ph}
13897 @end multitable
13899 The table below lists the @code{v2i16} operation for which
13900 hardware support exists for the DSP ASE REV 2.  @code{e} and @code{f} are
13901 @code{v2i16} values.
13903 @multitable @columnfractions .50 .50
13904 @item C code @tab MIPS instruction
13905 @item @code{e * f} @tab @code{mul.ph}
13906 @end multitable
13908 It is easier to describe the DSP built-in functions if we first define
13909 the following types:
13911 @smallexample
13912 typedef int q31;
13913 typedef int i32;
13914 typedef unsigned int ui32;
13915 typedef long long a64;
13916 @end smallexample
13918 @code{q31} and @code{i32} are actually the same as @code{int}, but we
13919 use @code{q31} to indicate a Q31 fractional value and @code{i32} to
13920 indicate a 32-bit integer value.  Similarly, @code{a64} is the same as
13921 @code{long long}, but we use @code{a64} to indicate values that are
13922 placed in one of the four DSP accumulators (@code{$ac0},
13923 @code{$ac1}, @code{$ac2} or @code{$ac3}).
13925 Also, some built-in functions prefer or require immediate numbers as
13926 parameters, because the corresponding DSP instructions accept both immediate
13927 numbers and register operands, or accept immediate numbers only.  The
13928 immediate parameters are listed as follows.
13930 @smallexample
13931 imm0_3: 0 to 3.
13932 imm0_7: 0 to 7.
13933 imm0_15: 0 to 15.
13934 imm0_31: 0 to 31.
13935 imm0_63: 0 to 63.
13936 imm0_255: 0 to 255.
13937 imm_n32_31: -32 to 31.
13938 imm_n512_511: -512 to 511.
13939 @end smallexample
13941 The following built-in functions map directly to a particular MIPS DSP
13942 instruction.  Please refer to the architecture specification
13943 for details on what each instruction does.
13945 @smallexample
13946 v2q15 __builtin_mips_addq_ph (v2q15, v2q15)
13947 v2q15 __builtin_mips_addq_s_ph (v2q15, v2q15)
13948 q31 __builtin_mips_addq_s_w (q31, q31)
13949 v4i8 __builtin_mips_addu_qb (v4i8, v4i8)
13950 v4i8 __builtin_mips_addu_s_qb (v4i8, v4i8)
13951 v2q15 __builtin_mips_subq_ph (v2q15, v2q15)
13952 v2q15 __builtin_mips_subq_s_ph (v2q15, v2q15)
13953 q31 __builtin_mips_subq_s_w (q31, q31)
13954 v4i8 __builtin_mips_subu_qb (v4i8, v4i8)
13955 v4i8 __builtin_mips_subu_s_qb (v4i8, v4i8)
13956 i32 __builtin_mips_addsc (i32, i32)
13957 i32 __builtin_mips_addwc (i32, i32)
13958 i32 __builtin_mips_modsub (i32, i32)
13959 i32 __builtin_mips_raddu_w_qb (v4i8)
13960 v2q15 __builtin_mips_absq_s_ph (v2q15)
13961 q31 __builtin_mips_absq_s_w (q31)
13962 v4i8 __builtin_mips_precrq_qb_ph (v2q15, v2q15)
13963 v2q15 __builtin_mips_precrq_ph_w (q31, q31)
13964 v2q15 __builtin_mips_precrq_rs_ph_w (q31, q31)
13965 v4i8 __builtin_mips_precrqu_s_qb_ph (v2q15, v2q15)
13966 q31 __builtin_mips_preceq_w_phl (v2q15)
13967 q31 __builtin_mips_preceq_w_phr (v2q15)
13968 v2q15 __builtin_mips_precequ_ph_qbl (v4i8)
13969 v2q15 __builtin_mips_precequ_ph_qbr (v4i8)
13970 v2q15 __builtin_mips_precequ_ph_qbla (v4i8)
13971 v2q15 __builtin_mips_precequ_ph_qbra (v4i8)
13972 v2q15 __builtin_mips_preceu_ph_qbl (v4i8)
13973 v2q15 __builtin_mips_preceu_ph_qbr (v4i8)
13974 v2q15 __builtin_mips_preceu_ph_qbla (v4i8)
13975 v2q15 __builtin_mips_preceu_ph_qbra (v4i8)
13976 v4i8 __builtin_mips_shll_qb (v4i8, imm0_7)
13977 v4i8 __builtin_mips_shll_qb (v4i8, i32)
13978 v2q15 __builtin_mips_shll_ph (v2q15, imm0_15)
13979 v2q15 __builtin_mips_shll_ph (v2q15, i32)
13980 v2q15 __builtin_mips_shll_s_ph (v2q15, imm0_15)
13981 v2q15 __builtin_mips_shll_s_ph (v2q15, i32)
13982 q31 __builtin_mips_shll_s_w (q31, imm0_31)
13983 q31 __builtin_mips_shll_s_w (q31, i32)
13984 v4i8 __builtin_mips_shrl_qb (v4i8, imm0_7)
13985 v4i8 __builtin_mips_shrl_qb (v4i8, i32)
13986 v2q15 __builtin_mips_shra_ph (v2q15, imm0_15)
13987 v2q15 __builtin_mips_shra_ph (v2q15, i32)
13988 v2q15 __builtin_mips_shra_r_ph (v2q15, imm0_15)
13989 v2q15 __builtin_mips_shra_r_ph (v2q15, i32)
13990 q31 __builtin_mips_shra_r_w (q31, imm0_31)
13991 q31 __builtin_mips_shra_r_w (q31, i32)
13992 v2q15 __builtin_mips_muleu_s_ph_qbl (v4i8, v2q15)
13993 v2q15 __builtin_mips_muleu_s_ph_qbr (v4i8, v2q15)
13994 v2q15 __builtin_mips_mulq_rs_ph (v2q15, v2q15)
13995 q31 __builtin_mips_muleq_s_w_phl (v2q15, v2q15)
13996 q31 __builtin_mips_muleq_s_w_phr (v2q15, v2q15)
13997 a64 __builtin_mips_dpau_h_qbl (a64, v4i8, v4i8)
13998 a64 __builtin_mips_dpau_h_qbr (a64, v4i8, v4i8)
13999 a64 __builtin_mips_dpsu_h_qbl (a64, v4i8, v4i8)
14000 a64 __builtin_mips_dpsu_h_qbr (a64, v4i8, v4i8)
14001 a64 __builtin_mips_dpaq_s_w_ph (a64, v2q15, v2q15)
14002 a64 __builtin_mips_dpaq_sa_l_w (a64, q31, q31)
14003 a64 __builtin_mips_dpsq_s_w_ph (a64, v2q15, v2q15)
14004 a64 __builtin_mips_dpsq_sa_l_w (a64, q31, q31)
14005 a64 __builtin_mips_mulsaq_s_w_ph (a64, v2q15, v2q15)
14006 a64 __builtin_mips_maq_s_w_phl (a64, v2q15, v2q15)
14007 a64 __builtin_mips_maq_s_w_phr (a64, v2q15, v2q15)
14008 a64 __builtin_mips_maq_sa_w_phl (a64, v2q15, v2q15)
14009 a64 __builtin_mips_maq_sa_w_phr (a64, v2q15, v2q15)
14010 i32 __builtin_mips_bitrev (i32)
14011 i32 __builtin_mips_insv (i32, i32)
14012 v4i8 __builtin_mips_repl_qb (imm0_255)
14013 v4i8 __builtin_mips_repl_qb (i32)
14014 v2q15 __builtin_mips_repl_ph (imm_n512_511)
14015 v2q15 __builtin_mips_repl_ph (i32)
14016 void __builtin_mips_cmpu_eq_qb (v4i8, v4i8)
14017 void __builtin_mips_cmpu_lt_qb (v4i8, v4i8)
14018 void __builtin_mips_cmpu_le_qb (v4i8, v4i8)
14019 i32 __builtin_mips_cmpgu_eq_qb (v4i8, v4i8)
14020 i32 __builtin_mips_cmpgu_lt_qb (v4i8, v4i8)
14021 i32 __builtin_mips_cmpgu_le_qb (v4i8, v4i8)
14022 void __builtin_mips_cmp_eq_ph (v2q15, v2q15)
14023 void __builtin_mips_cmp_lt_ph (v2q15, v2q15)
14024 void __builtin_mips_cmp_le_ph (v2q15, v2q15)
14025 v4i8 __builtin_mips_pick_qb (v4i8, v4i8)
14026 v2q15 __builtin_mips_pick_ph (v2q15, v2q15)
14027 v2q15 __builtin_mips_packrl_ph (v2q15, v2q15)
14028 i32 __builtin_mips_extr_w (a64, imm0_31)
14029 i32 __builtin_mips_extr_w (a64, i32)
14030 i32 __builtin_mips_extr_r_w (a64, imm0_31)
14031 i32 __builtin_mips_extr_s_h (a64, i32)
14032 i32 __builtin_mips_extr_rs_w (a64, imm0_31)
14033 i32 __builtin_mips_extr_rs_w (a64, i32)
14034 i32 __builtin_mips_extr_s_h (a64, imm0_31)
14035 i32 __builtin_mips_extr_r_w (a64, i32)
14036 i32 __builtin_mips_extp (a64, imm0_31)
14037 i32 __builtin_mips_extp (a64, i32)
14038 i32 __builtin_mips_extpdp (a64, imm0_31)
14039 i32 __builtin_mips_extpdp (a64, i32)
14040 a64 __builtin_mips_shilo (a64, imm_n32_31)
14041 a64 __builtin_mips_shilo (a64, i32)
14042 a64 __builtin_mips_mthlip (a64, i32)
14043 void __builtin_mips_wrdsp (i32, imm0_63)
14044 i32 __builtin_mips_rddsp (imm0_63)
14045 i32 __builtin_mips_lbux (void *, i32)
14046 i32 __builtin_mips_lhx (void *, i32)
14047 i32 __builtin_mips_lwx (void *, i32)
14048 a64 __builtin_mips_ldx (void *, i32) [MIPS64 only]
14049 i32 __builtin_mips_bposge32 (void)
14050 a64 __builtin_mips_madd (a64, i32, i32);
14051 a64 __builtin_mips_maddu (a64, ui32, ui32);
14052 a64 __builtin_mips_msub (a64, i32, i32);
14053 a64 __builtin_mips_msubu (a64, ui32, ui32);
14054 a64 __builtin_mips_mult (i32, i32);
14055 a64 __builtin_mips_multu (ui32, ui32);
14056 @end smallexample
14058 The following built-in functions map directly to a particular MIPS DSP REV 2
14059 instruction.  Please refer to the architecture specification
14060 for details on what each instruction does.
14062 @smallexample
14063 v4q7 __builtin_mips_absq_s_qb (v4q7);
14064 v2i16 __builtin_mips_addu_ph (v2i16, v2i16);
14065 v2i16 __builtin_mips_addu_s_ph (v2i16, v2i16);
14066 v4i8 __builtin_mips_adduh_qb (v4i8, v4i8);
14067 v4i8 __builtin_mips_adduh_r_qb (v4i8, v4i8);
14068 i32 __builtin_mips_append (i32, i32, imm0_31);
14069 i32 __builtin_mips_balign (i32, i32, imm0_3);
14070 i32 __builtin_mips_cmpgdu_eq_qb (v4i8, v4i8);
14071 i32 __builtin_mips_cmpgdu_lt_qb (v4i8, v4i8);
14072 i32 __builtin_mips_cmpgdu_le_qb (v4i8, v4i8);
14073 a64 __builtin_mips_dpa_w_ph (a64, v2i16, v2i16);
14074 a64 __builtin_mips_dps_w_ph (a64, v2i16, v2i16);
14075 v2i16 __builtin_mips_mul_ph (v2i16, v2i16);
14076 v2i16 __builtin_mips_mul_s_ph (v2i16, v2i16);
14077 q31 __builtin_mips_mulq_rs_w (q31, q31);
14078 v2q15 __builtin_mips_mulq_s_ph (v2q15, v2q15);
14079 q31 __builtin_mips_mulq_s_w (q31, q31);
14080 a64 __builtin_mips_mulsa_w_ph (a64, v2i16, v2i16);
14081 v4i8 __builtin_mips_precr_qb_ph (v2i16, v2i16);
14082 v2i16 __builtin_mips_precr_sra_ph_w (i32, i32, imm0_31);
14083 v2i16 __builtin_mips_precr_sra_r_ph_w (i32, i32, imm0_31);
14084 i32 __builtin_mips_prepend (i32, i32, imm0_31);
14085 v4i8 __builtin_mips_shra_qb (v4i8, imm0_7);
14086 v4i8 __builtin_mips_shra_r_qb (v4i8, imm0_7);
14087 v4i8 __builtin_mips_shra_qb (v4i8, i32);
14088 v4i8 __builtin_mips_shra_r_qb (v4i8, i32);
14089 v2i16 __builtin_mips_shrl_ph (v2i16, imm0_15);
14090 v2i16 __builtin_mips_shrl_ph (v2i16, i32);
14091 v2i16 __builtin_mips_subu_ph (v2i16, v2i16);
14092 v2i16 __builtin_mips_subu_s_ph (v2i16, v2i16);
14093 v4i8 __builtin_mips_subuh_qb (v4i8, v4i8);
14094 v4i8 __builtin_mips_subuh_r_qb (v4i8, v4i8);
14095 v2q15 __builtin_mips_addqh_ph (v2q15, v2q15);
14096 v2q15 __builtin_mips_addqh_r_ph (v2q15, v2q15);
14097 q31 __builtin_mips_addqh_w (q31, q31);
14098 q31 __builtin_mips_addqh_r_w (q31, q31);
14099 v2q15 __builtin_mips_subqh_ph (v2q15, v2q15);
14100 v2q15 __builtin_mips_subqh_r_ph (v2q15, v2q15);
14101 q31 __builtin_mips_subqh_w (q31, q31);
14102 q31 __builtin_mips_subqh_r_w (q31, q31);
14103 a64 __builtin_mips_dpax_w_ph (a64, v2i16, v2i16);
14104 a64 __builtin_mips_dpsx_w_ph (a64, v2i16, v2i16);
14105 a64 __builtin_mips_dpaqx_s_w_ph (a64, v2q15, v2q15);
14106 a64 __builtin_mips_dpaqx_sa_w_ph (a64, v2q15, v2q15);
14107 a64 __builtin_mips_dpsqx_s_w_ph (a64, v2q15, v2q15);
14108 a64 __builtin_mips_dpsqx_sa_w_ph (a64, v2q15, v2q15);
14109 @end smallexample
14112 @node MIPS Paired-Single Support
14113 @subsection MIPS Paired-Single Support
14115 The MIPS64 architecture includes a number of instructions that
14116 operate on pairs of single-precision floating-point values.
14117 Each pair is packed into a 64-bit floating-point register,
14118 with one element being designated the ``upper half'' and
14119 the other being designated the ``lower half''.
14121 GCC supports paired-single operations using both the generic
14122 vector extensions (@pxref{Vector Extensions}) and a collection of
14123 MIPS-specific built-in functions.  Both kinds of support are
14124 enabled by the @option{-mpaired-single} command-line option.
14126 The vector type associated with paired-single values is usually
14127 called @code{v2sf}.  It can be defined in C as follows:
14129 @smallexample
14130 typedef float v2sf __attribute__ ((vector_size (8)));
14131 @end smallexample
14133 @code{v2sf} values are initialized in the same way as aggregates.
14134 For example:
14136 @smallexample
14137 v2sf a = @{1.5, 9.1@};
14138 v2sf b;
14139 float e, f;
14140 b = (v2sf) @{e, f@};
14141 @end smallexample
14143 @emph{Note:} The CPU's endianness determines which value is stored in
14144 the upper half of a register and which value is stored in the lower half.
14145 On little-endian targets, the first value is the lower one and the second
14146 value is the upper one.  The opposite order applies to big-endian targets.
14147 For example, the code above sets the lower half of @code{a} to
14148 @code{1.5} on little-endian targets and @code{9.1} on big-endian targets.
14150 @node MIPS Loongson Built-in Functions
14151 @subsection MIPS Loongson Built-in Functions
14153 GCC provides intrinsics to access the SIMD instructions provided by the
14154 ST Microelectronics Loongson-2E and -2F processors.  These intrinsics,
14155 available after inclusion of the @code{loongson.h} header file,
14156 operate on the following 64-bit vector types:
14158 @itemize
14159 @item @code{uint8x8_t}, a vector of eight unsigned 8-bit integers;
14160 @item @code{uint16x4_t}, a vector of four unsigned 16-bit integers;
14161 @item @code{uint32x2_t}, a vector of two unsigned 32-bit integers;
14162 @item @code{int8x8_t}, a vector of eight signed 8-bit integers;
14163 @item @code{int16x4_t}, a vector of four signed 16-bit integers;
14164 @item @code{int32x2_t}, a vector of two signed 32-bit integers.
14165 @end itemize
14167 The intrinsics provided are listed below; each is named after the
14168 machine instruction to which it corresponds, with suffixes added as
14169 appropriate to distinguish intrinsics that expand to the same machine
14170 instruction yet have different argument types.  Refer to the architecture
14171 documentation for a description of the functionality of each
14172 instruction.
14174 @smallexample
14175 int16x4_t packsswh (int32x2_t s, int32x2_t t);
14176 int8x8_t packsshb (int16x4_t s, int16x4_t t);
14177 uint8x8_t packushb (uint16x4_t s, uint16x4_t t);
14178 uint32x2_t paddw_u (uint32x2_t s, uint32x2_t t);
14179 uint16x4_t paddh_u (uint16x4_t s, uint16x4_t t);
14180 uint8x8_t paddb_u (uint8x8_t s, uint8x8_t t);
14181 int32x2_t paddw_s (int32x2_t s, int32x2_t t);
14182 int16x4_t paddh_s (int16x4_t s, int16x4_t t);
14183 int8x8_t paddb_s (int8x8_t s, int8x8_t t);
14184 uint64_t paddd_u (uint64_t s, uint64_t t);
14185 int64_t paddd_s (int64_t s, int64_t t);
14186 int16x4_t paddsh (int16x4_t s, int16x4_t t);
14187 int8x8_t paddsb (int8x8_t s, int8x8_t t);
14188 uint16x4_t paddush (uint16x4_t s, uint16x4_t t);
14189 uint8x8_t paddusb (uint8x8_t s, uint8x8_t t);
14190 uint64_t pandn_ud (uint64_t s, uint64_t t);
14191 uint32x2_t pandn_uw (uint32x2_t s, uint32x2_t t);
14192 uint16x4_t pandn_uh (uint16x4_t s, uint16x4_t t);
14193 uint8x8_t pandn_ub (uint8x8_t s, uint8x8_t t);
14194 int64_t pandn_sd (int64_t s, int64_t t);
14195 int32x2_t pandn_sw (int32x2_t s, int32x2_t t);
14196 int16x4_t pandn_sh (int16x4_t s, int16x4_t t);
14197 int8x8_t pandn_sb (int8x8_t s, int8x8_t t);
14198 uint16x4_t pavgh (uint16x4_t s, uint16x4_t t);
14199 uint8x8_t pavgb (uint8x8_t s, uint8x8_t t);
14200 uint32x2_t pcmpeqw_u (uint32x2_t s, uint32x2_t t);
14201 uint16x4_t pcmpeqh_u (uint16x4_t s, uint16x4_t t);
14202 uint8x8_t pcmpeqb_u (uint8x8_t s, uint8x8_t t);
14203 int32x2_t pcmpeqw_s (int32x2_t s, int32x2_t t);
14204 int16x4_t pcmpeqh_s (int16x4_t s, int16x4_t t);
14205 int8x8_t pcmpeqb_s (int8x8_t s, int8x8_t t);
14206 uint32x2_t pcmpgtw_u (uint32x2_t s, uint32x2_t t);
14207 uint16x4_t pcmpgth_u (uint16x4_t s, uint16x4_t t);
14208 uint8x8_t pcmpgtb_u (uint8x8_t s, uint8x8_t t);
14209 int32x2_t pcmpgtw_s (int32x2_t s, int32x2_t t);
14210 int16x4_t pcmpgth_s (int16x4_t s, int16x4_t t);
14211 int8x8_t pcmpgtb_s (int8x8_t s, int8x8_t t);
14212 uint16x4_t pextrh_u (uint16x4_t s, int field);
14213 int16x4_t pextrh_s (int16x4_t s, int field);
14214 uint16x4_t pinsrh_0_u (uint16x4_t s, uint16x4_t t);
14215 uint16x4_t pinsrh_1_u (uint16x4_t s, uint16x4_t t);
14216 uint16x4_t pinsrh_2_u (uint16x4_t s, uint16x4_t t);
14217 uint16x4_t pinsrh_3_u (uint16x4_t s, uint16x4_t t);
14218 int16x4_t pinsrh_0_s (int16x4_t s, int16x4_t t);
14219 int16x4_t pinsrh_1_s (int16x4_t s, int16x4_t t);
14220 int16x4_t pinsrh_2_s (int16x4_t s, int16x4_t t);
14221 int16x4_t pinsrh_3_s (int16x4_t s, int16x4_t t);
14222 int32x2_t pmaddhw (int16x4_t s, int16x4_t t);
14223 int16x4_t pmaxsh (int16x4_t s, int16x4_t t);
14224 uint8x8_t pmaxub (uint8x8_t s, uint8x8_t t);
14225 int16x4_t pminsh (int16x4_t s, int16x4_t t);
14226 uint8x8_t pminub (uint8x8_t s, uint8x8_t t);
14227 uint8x8_t pmovmskb_u (uint8x8_t s);
14228 int8x8_t pmovmskb_s (int8x8_t s);
14229 uint16x4_t pmulhuh (uint16x4_t s, uint16x4_t t);
14230 int16x4_t pmulhh (int16x4_t s, int16x4_t t);
14231 int16x4_t pmullh (int16x4_t s, int16x4_t t);
14232 int64_t pmuluw (uint32x2_t s, uint32x2_t t);
14233 uint8x8_t pasubub (uint8x8_t s, uint8x8_t t);
14234 uint16x4_t biadd (uint8x8_t s);
14235 uint16x4_t psadbh (uint8x8_t s, uint8x8_t t);
14236 uint16x4_t pshufh_u (uint16x4_t dest, uint16x4_t s, uint8_t order);
14237 int16x4_t pshufh_s (int16x4_t dest, int16x4_t s, uint8_t order);
14238 uint16x4_t psllh_u (uint16x4_t s, uint8_t amount);
14239 int16x4_t psllh_s (int16x4_t s, uint8_t amount);
14240 uint32x2_t psllw_u (uint32x2_t s, uint8_t amount);
14241 int32x2_t psllw_s (int32x2_t s, uint8_t amount);
14242 uint16x4_t psrlh_u (uint16x4_t s, uint8_t amount);
14243 int16x4_t psrlh_s (int16x4_t s, uint8_t amount);
14244 uint32x2_t psrlw_u (uint32x2_t s, uint8_t amount);
14245 int32x2_t psrlw_s (int32x2_t s, uint8_t amount);
14246 uint16x4_t psrah_u (uint16x4_t s, uint8_t amount);
14247 int16x4_t psrah_s (int16x4_t s, uint8_t amount);
14248 uint32x2_t psraw_u (uint32x2_t s, uint8_t amount);
14249 int32x2_t psraw_s (int32x2_t s, uint8_t amount);
14250 uint32x2_t psubw_u (uint32x2_t s, uint32x2_t t);
14251 uint16x4_t psubh_u (uint16x4_t s, uint16x4_t t);
14252 uint8x8_t psubb_u (uint8x8_t s, uint8x8_t t);
14253 int32x2_t psubw_s (int32x2_t s, int32x2_t t);
14254 int16x4_t psubh_s (int16x4_t s, int16x4_t t);
14255 int8x8_t psubb_s (int8x8_t s, int8x8_t t);
14256 uint64_t psubd_u (uint64_t s, uint64_t t);
14257 int64_t psubd_s (int64_t s, int64_t t);
14258 int16x4_t psubsh (int16x4_t s, int16x4_t t);
14259 int8x8_t psubsb (int8x8_t s, int8x8_t t);
14260 uint16x4_t psubush (uint16x4_t s, uint16x4_t t);
14261 uint8x8_t psubusb (uint8x8_t s, uint8x8_t t);
14262 uint32x2_t punpckhwd_u (uint32x2_t s, uint32x2_t t);
14263 uint16x4_t punpckhhw_u (uint16x4_t s, uint16x4_t t);
14264 uint8x8_t punpckhbh_u (uint8x8_t s, uint8x8_t t);
14265 int32x2_t punpckhwd_s (int32x2_t s, int32x2_t t);
14266 int16x4_t punpckhhw_s (int16x4_t s, int16x4_t t);
14267 int8x8_t punpckhbh_s (int8x8_t s, int8x8_t t);
14268 uint32x2_t punpcklwd_u (uint32x2_t s, uint32x2_t t);
14269 uint16x4_t punpcklhw_u (uint16x4_t s, uint16x4_t t);
14270 uint8x8_t punpcklbh_u (uint8x8_t s, uint8x8_t t);
14271 int32x2_t punpcklwd_s (int32x2_t s, int32x2_t t);
14272 int16x4_t punpcklhw_s (int16x4_t s, int16x4_t t);
14273 int8x8_t punpcklbh_s (int8x8_t s, int8x8_t t);
14274 @end smallexample
14276 @menu
14277 * Paired-Single Arithmetic::
14278 * Paired-Single Built-in Functions::
14279 * MIPS-3D Built-in Functions::
14280 @end menu
14282 @node Paired-Single Arithmetic
14283 @subsubsection Paired-Single Arithmetic
14285 The table below lists the @code{v2sf} operations for which hardware
14286 support exists.  @code{a}, @code{b} and @code{c} are @code{v2sf}
14287 values and @code{x} is an integral value.
14289 @multitable @columnfractions .50 .50
14290 @item C code @tab MIPS instruction
14291 @item @code{a + b} @tab @code{add.ps}
14292 @item @code{a - b} @tab @code{sub.ps}
14293 @item @code{-a} @tab @code{neg.ps}
14294 @item @code{a * b} @tab @code{mul.ps}
14295 @item @code{a * b + c} @tab @code{madd.ps}
14296 @item @code{a * b - c} @tab @code{msub.ps}
14297 @item @code{-(a * b + c)} @tab @code{nmadd.ps}
14298 @item @code{-(a * b - c)} @tab @code{nmsub.ps}
14299 @item @code{x ? a : b} @tab @code{movn.ps}/@code{movz.ps}
14300 @end multitable
14302 Note that the multiply-accumulate instructions can be disabled
14303 using the command-line option @code{-mno-fused-madd}.
14305 @node Paired-Single Built-in Functions
14306 @subsubsection Paired-Single Built-in Functions
14308 The following paired-single functions map directly to a particular
14309 MIPS instruction.  Please refer to the architecture specification
14310 for details on what each instruction does.
14312 @table @code
14313 @item v2sf __builtin_mips_pll_ps (v2sf, v2sf)
14314 Pair lower lower (@code{pll.ps}).
14316 @item v2sf __builtin_mips_pul_ps (v2sf, v2sf)
14317 Pair upper lower (@code{pul.ps}).
14319 @item v2sf __builtin_mips_plu_ps (v2sf, v2sf)
14320 Pair lower upper (@code{plu.ps}).
14322 @item v2sf __builtin_mips_puu_ps (v2sf, v2sf)
14323 Pair upper upper (@code{puu.ps}).
14325 @item v2sf __builtin_mips_cvt_ps_s (float, float)
14326 Convert pair to paired single (@code{cvt.ps.s}).
14328 @item float __builtin_mips_cvt_s_pl (v2sf)
14329 Convert pair lower to single (@code{cvt.s.pl}).
14331 @item float __builtin_mips_cvt_s_pu (v2sf)
14332 Convert pair upper to single (@code{cvt.s.pu}).
14334 @item v2sf __builtin_mips_abs_ps (v2sf)
14335 Absolute value (@code{abs.ps}).
14337 @item v2sf __builtin_mips_alnv_ps (v2sf, v2sf, int)
14338 Align variable (@code{alnv.ps}).
14340 @emph{Note:} The value of the third parameter must be 0 or 4
14341 modulo 8, otherwise the result is unpredictable.  Please read the
14342 instruction description for details.
14343 @end table
14345 The following multi-instruction functions are also available.
14346 In each case, @var{cond} can be any of the 16 floating-point conditions:
14347 @code{f}, @code{un}, @code{eq}, @code{ueq}, @code{olt}, @code{ult},
14348 @code{ole}, @code{ule}, @code{sf}, @code{ngle}, @code{seq}, @code{ngl},
14349 @code{lt}, @code{nge}, @code{le} or @code{ngt}.
14351 @table @code
14352 @item v2sf __builtin_mips_movt_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
14353 @itemx v2sf __builtin_mips_movf_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
14354 Conditional move based on floating-point comparison (@code{c.@var{cond}.ps},
14355 @code{movt.ps}/@code{movf.ps}).
14357 The @code{movt} functions return the value @var{x} computed by:
14359 @smallexample
14360 c.@var{cond}.ps @var{cc},@var{a},@var{b}
14361 mov.ps @var{x},@var{c}
14362 movt.ps @var{x},@var{d},@var{cc}
14363 @end smallexample
14365 The @code{movf} functions are similar but use @code{movf.ps} instead
14366 of @code{movt.ps}.
14368 @item int __builtin_mips_upper_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
14369 @itemx int __builtin_mips_lower_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
14370 Comparison of two paired-single values (@code{c.@var{cond}.ps},
14371 @code{bc1t}/@code{bc1f}).
14373 These functions compare @var{a} and @var{b} using @code{c.@var{cond}.ps}
14374 and return either the upper or lower half of the result.  For example:
14376 @smallexample
14377 v2sf a, b;
14378 if (__builtin_mips_upper_c_eq_ps (a, b))
14379   upper_halves_are_equal ();
14380 else
14381   upper_halves_are_unequal ();
14383 if (__builtin_mips_lower_c_eq_ps (a, b))
14384   lower_halves_are_equal ();
14385 else
14386   lower_halves_are_unequal ();
14387 @end smallexample
14388 @end table
14390 @node MIPS-3D Built-in Functions
14391 @subsubsection MIPS-3D Built-in Functions
14393 The MIPS-3D Application-Specific Extension (ASE) includes additional
14394 paired-single instructions that are designed to improve the performance
14395 of 3D graphics operations.  Support for these instructions is controlled
14396 by the @option{-mips3d} command-line option.
14398 The functions listed below map directly to a particular MIPS-3D
14399 instruction.  Please refer to the architecture specification for
14400 more details on what each instruction does.
14402 @table @code
14403 @item v2sf __builtin_mips_addr_ps (v2sf, v2sf)
14404 Reduction add (@code{addr.ps}).
14406 @item v2sf __builtin_mips_mulr_ps (v2sf, v2sf)
14407 Reduction multiply (@code{mulr.ps}).
14409 @item v2sf __builtin_mips_cvt_pw_ps (v2sf)
14410 Convert paired single to paired word (@code{cvt.pw.ps}).
14412 @item v2sf __builtin_mips_cvt_ps_pw (v2sf)
14413 Convert paired word to paired single (@code{cvt.ps.pw}).
14415 @item float __builtin_mips_recip1_s (float)
14416 @itemx double __builtin_mips_recip1_d (double)
14417 @itemx v2sf __builtin_mips_recip1_ps (v2sf)
14418 Reduced-precision reciprocal (sequence step 1) (@code{recip1.@var{fmt}}).
14420 @item float __builtin_mips_recip2_s (float, float)
14421 @itemx double __builtin_mips_recip2_d (double, double)
14422 @itemx v2sf __builtin_mips_recip2_ps (v2sf, v2sf)
14423 Reduced-precision reciprocal (sequence step 2) (@code{recip2.@var{fmt}}).
14425 @item float __builtin_mips_rsqrt1_s (float)
14426 @itemx double __builtin_mips_rsqrt1_d (double)
14427 @itemx v2sf __builtin_mips_rsqrt1_ps (v2sf)
14428 Reduced-precision reciprocal square root (sequence step 1)
14429 (@code{rsqrt1.@var{fmt}}).
14431 @item float __builtin_mips_rsqrt2_s (float, float)
14432 @itemx double __builtin_mips_rsqrt2_d (double, double)
14433 @itemx v2sf __builtin_mips_rsqrt2_ps (v2sf, v2sf)
14434 Reduced-precision reciprocal square root (sequence step 2)
14435 (@code{rsqrt2.@var{fmt}}).
14436 @end table
14438 The following multi-instruction functions are also available.
14439 In each case, @var{cond} can be any of the 16 floating-point conditions:
14440 @code{f}, @code{un}, @code{eq}, @code{ueq}, @code{olt}, @code{ult},
14441 @code{ole}, @code{ule}, @code{sf}, @code{ngle}, @code{seq},
14442 @code{ngl}, @code{lt}, @code{nge}, @code{le} or @code{ngt}.
14444 @table @code
14445 @item int __builtin_mips_cabs_@var{cond}_s (float @var{a}, float @var{b})
14446 @itemx int __builtin_mips_cabs_@var{cond}_d (double @var{a}, double @var{b})
14447 Absolute comparison of two scalar values (@code{cabs.@var{cond}.@var{fmt}},
14448 @code{bc1t}/@code{bc1f}).
14450 These functions compare @var{a} and @var{b} using @code{cabs.@var{cond}.s}
14451 or @code{cabs.@var{cond}.d} and return the result as a boolean value.
14452 For example:
14454 @smallexample
14455 float a, b;
14456 if (__builtin_mips_cabs_eq_s (a, b))
14457   true ();
14458 else
14459   false ();
14460 @end smallexample
14462 @item int __builtin_mips_upper_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
14463 @itemx int __builtin_mips_lower_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
14464 Absolute comparison of two paired-single values (@code{cabs.@var{cond}.ps},
14465 @code{bc1t}/@code{bc1f}).
14467 These functions compare @var{a} and @var{b} using @code{cabs.@var{cond}.ps}
14468 and return either the upper or lower half of the result.  For example:
14470 @smallexample
14471 v2sf a, b;
14472 if (__builtin_mips_upper_cabs_eq_ps (a, b))
14473   upper_halves_are_equal ();
14474 else
14475   upper_halves_are_unequal ();
14477 if (__builtin_mips_lower_cabs_eq_ps (a, b))
14478   lower_halves_are_equal ();
14479 else
14480   lower_halves_are_unequal ();
14481 @end smallexample
14483 @item v2sf __builtin_mips_movt_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
14484 @itemx v2sf __builtin_mips_movf_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
14485 Conditional move based on absolute comparison (@code{cabs.@var{cond}.ps},
14486 @code{movt.ps}/@code{movf.ps}).
14488 The @code{movt} functions return the value @var{x} computed by:
14490 @smallexample
14491 cabs.@var{cond}.ps @var{cc},@var{a},@var{b}
14492 mov.ps @var{x},@var{c}
14493 movt.ps @var{x},@var{d},@var{cc}
14494 @end smallexample
14496 The @code{movf} functions are similar but use @code{movf.ps} instead
14497 of @code{movt.ps}.
14499 @item int __builtin_mips_any_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
14500 @itemx int __builtin_mips_all_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
14501 @itemx int __builtin_mips_any_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
14502 @itemx int __builtin_mips_all_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
14503 Comparison of two paired-single values
14504 (@code{c.@var{cond}.ps}/@code{cabs.@var{cond}.ps},
14505 @code{bc1any2t}/@code{bc1any2f}).
14507 These functions compare @var{a} and @var{b} using @code{c.@var{cond}.ps}
14508 or @code{cabs.@var{cond}.ps}.  The @code{any} forms return true if either
14509 result is true and the @code{all} forms return true if both results are true.
14510 For example:
14512 @smallexample
14513 v2sf a, b;
14514 if (__builtin_mips_any_c_eq_ps (a, b))
14515   one_is_true ();
14516 else
14517   both_are_false ();
14519 if (__builtin_mips_all_c_eq_ps (a, b))
14520   both_are_true ();
14521 else
14522   one_is_false ();
14523 @end smallexample
14525 @item int __builtin_mips_any_c_@var{cond}_4s (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
14526 @itemx int __builtin_mips_all_c_@var{cond}_4s (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
14527 @itemx int __builtin_mips_any_cabs_@var{cond}_4s (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
14528 @itemx int __builtin_mips_all_cabs_@var{cond}_4s (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
14529 Comparison of four paired-single values
14530 (@code{c.@var{cond}.ps}/@code{cabs.@var{cond}.ps},
14531 @code{bc1any4t}/@code{bc1any4f}).
14533 These functions use @code{c.@var{cond}.ps} or @code{cabs.@var{cond}.ps}
14534 to compare @var{a} with @var{b} and to compare @var{c} with @var{d}.
14535 The @code{any} forms return true if any of the four results are true
14536 and the @code{all} forms return true if all four results are true.
14537 For example:
14539 @smallexample
14540 v2sf a, b, c, d;
14541 if (__builtin_mips_any_c_eq_4s (a, b, c, d))
14542   some_are_true ();
14543 else
14544   all_are_false ();
14546 if (__builtin_mips_all_c_eq_4s (a, b, c, d))
14547   all_are_true ();
14548 else
14549   some_are_false ();
14550 @end smallexample
14551 @end table
14553 @node MIPS SIMD Architecture (MSA) Support
14554 @subsection MIPS SIMD Architecture (MSA) Support
14556 @menu
14557 * MIPS SIMD Architecture Built-in Functions::
14558 @end menu
14560 GCC provides intrinsics to access the SIMD instructions provided by the
14561 MSA MIPS SIMD Architecture.  The interface is made available by including
14562 @code{<msa.h>} and using @option{-mmsa -mhard-float -mfp64 -mnan=2008}.
14563 For each @code{__builtin_msa_*}, there is a shortened name of the intrinsic,
14564 @code{__msa_*}.
14566 MSA implements 128-bit wide vector registers, operating on 8-, 16-, 32- and
14567 64-bit integer, 16- and 32-bit fixed-point, or 32- and 64-bit floating point
14568 data elements.  The following vectors typedefs are included in @code{msa.h}:
14569 @itemize
14570 @item @code{v16i8}, a vector of sixteen signed 8-bit integers;
14571 @item @code{v16u8}, a vector of sixteen unsigned 8-bit integers;
14572 @item @code{v8i16}, a vector of eight signed 16-bit integers;
14573 @item @code{v8u16}, a vector of eight unsigned 16-bit integers;
14574 @item @code{v4i32}, a vector of four signed 32-bit integers;
14575 @item @code{v4u32}, a vector of four unsigned 32-bit integers;
14576 @item @code{v2i64}, a vector of two signed 64-bit integers;
14577 @item @code{v2u64}, a vector of two unsigned 64-bit integers;
14578 @item @code{v4f32}, a vector of four 32-bit floats;
14579 @item @code{v2f64}, a vector of two 64-bit doubles.
14580 @end itemize
14582 Instructions and corresponding built-ins may have additional restrictions and/or
14583 input/output values manipulated:
14584 @itemize
14585 @item @code{imm0_1}, an integer literal in range 0 to 1;
14586 @item @code{imm0_3}, an integer literal in range 0 to 3;
14587 @item @code{imm0_7}, an integer literal in range 0 to 7;
14588 @item @code{imm0_15}, an integer literal in range 0 to 15;
14589 @item @code{imm0_31}, an integer literal in range 0 to 31;
14590 @item @code{imm0_63}, an integer literal in range 0 to 63;
14591 @item @code{imm0_255}, an integer literal in range 0 to 255;
14592 @item @code{imm_n16_15}, an integer literal in range -16 to 15;
14593 @item @code{imm_n512_511}, an integer literal in range -512 to 511;
14594 @item @code{imm_n1024_1022}, an integer literal in range -512 to 511 left
14595 shifted by 1 bit, i.e., -1024, -1022, @dots{}, 1020, 1022;
14596 @item @code{imm_n2048_2044}, an integer literal in range -512 to 511 left
14597 shifted by 2 bits, i.e., -2048, -2044, @dots{}, 2040, 2044;
14598 @item @code{imm_n4096_4088}, an integer literal in range -512 to 511 left
14599 shifted by 3 bits, i.e., -4096, -4088, @dots{}, 4080, 4088;
14600 @item @code{imm1_4}, an integer literal in range 1 to 4;
14601 @item @code{i32, i64, u32, u64, f32, f64}, defined as follows:
14602 @end itemize
14604 @smallexample
14606 typedef int i32;
14607 #if __LONG_MAX__ == __LONG_LONG_MAX__
14608 typedef long i64;
14609 #else
14610 typedef long long i64;
14611 #endif
14613 typedef unsigned int u32;
14614 #if __LONG_MAX__ == __LONG_LONG_MAX__
14615 typedef unsigned long u64;
14616 #else
14617 typedef unsigned long long u64;
14618 #endif
14620 typedef double f64;
14621 typedef float f32;
14623 @end smallexample
14625 @node MIPS SIMD Architecture Built-in Functions
14626 @subsubsection MIPS SIMD Architecture Built-in Functions
14628 The intrinsics provided are listed below; each is named after the
14629 machine instruction.
14631 @smallexample
14632 v16i8 __builtin_msa_add_a_b (v16i8, v16i8);
14633 v8i16 __builtin_msa_add_a_h (v8i16, v8i16);
14634 v4i32 __builtin_msa_add_a_w (v4i32, v4i32);
14635 v2i64 __builtin_msa_add_a_d (v2i64, v2i64);
14637 v16i8 __builtin_msa_adds_a_b (v16i8, v16i8);
14638 v8i16 __builtin_msa_adds_a_h (v8i16, v8i16);
14639 v4i32 __builtin_msa_adds_a_w (v4i32, v4i32);
14640 v2i64 __builtin_msa_adds_a_d (v2i64, v2i64);
14642 v16i8 __builtin_msa_adds_s_b (v16i8, v16i8);
14643 v8i16 __builtin_msa_adds_s_h (v8i16, v8i16);
14644 v4i32 __builtin_msa_adds_s_w (v4i32, v4i32);
14645 v2i64 __builtin_msa_adds_s_d (v2i64, v2i64);
14647 v16u8 __builtin_msa_adds_u_b (v16u8, v16u8);
14648 v8u16 __builtin_msa_adds_u_h (v8u16, v8u16);
14649 v4u32 __builtin_msa_adds_u_w (v4u32, v4u32);
14650 v2u64 __builtin_msa_adds_u_d (v2u64, v2u64);
14652 v16i8 __builtin_msa_addv_b (v16i8, v16i8);
14653 v8i16 __builtin_msa_addv_h (v8i16, v8i16);
14654 v4i32 __builtin_msa_addv_w (v4i32, v4i32);
14655 v2i64 __builtin_msa_addv_d (v2i64, v2i64);
14657 v16i8 __builtin_msa_addvi_b (v16i8, imm0_31);
14658 v8i16 __builtin_msa_addvi_h (v8i16, imm0_31);
14659 v4i32 __builtin_msa_addvi_w (v4i32, imm0_31);
14660 v2i64 __builtin_msa_addvi_d (v2i64, imm0_31);
14662 v16u8 __builtin_msa_and_v (v16u8, v16u8);
14664 v16u8 __builtin_msa_andi_b (v16u8, imm0_255);
14666 v16i8 __builtin_msa_asub_s_b (v16i8, v16i8);
14667 v8i16 __builtin_msa_asub_s_h (v8i16, v8i16);
14668 v4i32 __builtin_msa_asub_s_w (v4i32, v4i32);
14669 v2i64 __builtin_msa_asub_s_d (v2i64, v2i64);
14671 v16u8 __builtin_msa_asub_u_b (v16u8, v16u8);
14672 v8u16 __builtin_msa_asub_u_h (v8u16, v8u16);
14673 v4u32 __builtin_msa_asub_u_w (v4u32, v4u32);
14674 v2u64 __builtin_msa_asub_u_d (v2u64, v2u64);
14676 v16i8 __builtin_msa_ave_s_b (v16i8, v16i8);
14677 v8i16 __builtin_msa_ave_s_h (v8i16, v8i16);
14678 v4i32 __builtin_msa_ave_s_w (v4i32, v4i32);
14679 v2i64 __builtin_msa_ave_s_d (v2i64, v2i64);
14681 v16u8 __builtin_msa_ave_u_b (v16u8, v16u8);
14682 v8u16 __builtin_msa_ave_u_h (v8u16, v8u16);
14683 v4u32 __builtin_msa_ave_u_w (v4u32, v4u32);
14684 v2u64 __builtin_msa_ave_u_d (v2u64, v2u64);
14686 v16i8 __builtin_msa_aver_s_b (v16i8, v16i8);
14687 v8i16 __builtin_msa_aver_s_h (v8i16, v8i16);
14688 v4i32 __builtin_msa_aver_s_w (v4i32, v4i32);
14689 v2i64 __builtin_msa_aver_s_d (v2i64, v2i64);
14691 v16u8 __builtin_msa_aver_u_b (v16u8, v16u8);
14692 v8u16 __builtin_msa_aver_u_h (v8u16, v8u16);
14693 v4u32 __builtin_msa_aver_u_w (v4u32, v4u32);
14694 v2u64 __builtin_msa_aver_u_d (v2u64, v2u64);
14696 v16u8 __builtin_msa_bclr_b (v16u8, v16u8);
14697 v8u16 __builtin_msa_bclr_h (v8u16, v8u16);
14698 v4u32 __builtin_msa_bclr_w (v4u32, v4u32);
14699 v2u64 __builtin_msa_bclr_d (v2u64, v2u64);
14701 v16u8 __builtin_msa_bclri_b (v16u8, imm0_7);
14702 v8u16 __builtin_msa_bclri_h (v8u16, imm0_15);
14703 v4u32 __builtin_msa_bclri_w (v4u32, imm0_31);
14704 v2u64 __builtin_msa_bclri_d (v2u64, imm0_63);
14706 v16u8 __builtin_msa_binsl_b (v16u8, v16u8, v16u8);
14707 v8u16 __builtin_msa_binsl_h (v8u16, v8u16, v8u16);
14708 v4u32 __builtin_msa_binsl_w (v4u32, v4u32, v4u32);
14709 v2u64 __builtin_msa_binsl_d (v2u64, v2u64, v2u64);
14711 v16u8 __builtin_msa_binsli_b (v16u8, v16u8, imm0_7);
14712 v8u16 __builtin_msa_binsli_h (v8u16, v8u16, imm0_15);
14713 v4u32 __builtin_msa_binsli_w (v4u32, v4u32, imm0_31);
14714 v2u64 __builtin_msa_binsli_d (v2u64, v2u64, imm0_63);
14716 v16u8 __builtin_msa_binsr_b (v16u8, v16u8, v16u8);
14717 v8u16 __builtin_msa_binsr_h (v8u16, v8u16, v8u16);
14718 v4u32 __builtin_msa_binsr_w (v4u32, v4u32, v4u32);
14719 v2u64 __builtin_msa_binsr_d (v2u64, v2u64, v2u64);
14721 v16u8 __builtin_msa_binsri_b (v16u8, v16u8, imm0_7);
14722 v8u16 __builtin_msa_binsri_h (v8u16, v8u16, imm0_15);
14723 v4u32 __builtin_msa_binsri_w (v4u32, v4u32, imm0_31);
14724 v2u64 __builtin_msa_binsri_d (v2u64, v2u64, imm0_63);
14726 v16u8 __builtin_msa_bmnz_v (v16u8, v16u8, v16u8);
14728 v16u8 __builtin_msa_bmnzi_b (v16u8, v16u8, imm0_255);
14730 v16u8 __builtin_msa_bmz_v (v16u8, v16u8, v16u8);
14732 v16u8 __builtin_msa_bmzi_b (v16u8, v16u8, imm0_255);
14734 v16u8 __builtin_msa_bneg_b (v16u8, v16u8);
14735 v8u16 __builtin_msa_bneg_h (v8u16, v8u16);
14736 v4u32 __builtin_msa_bneg_w (v4u32, v4u32);
14737 v2u64 __builtin_msa_bneg_d (v2u64, v2u64);
14739 v16u8 __builtin_msa_bnegi_b (v16u8, imm0_7);
14740 v8u16 __builtin_msa_bnegi_h (v8u16, imm0_15);
14741 v4u32 __builtin_msa_bnegi_w (v4u32, imm0_31);
14742 v2u64 __builtin_msa_bnegi_d (v2u64, imm0_63);
14744 i32 __builtin_msa_bnz_b (v16u8);
14745 i32 __builtin_msa_bnz_h (v8u16);
14746 i32 __builtin_msa_bnz_w (v4u32);
14747 i32 __builtin_msa_bnz_d (v2u64);
14749 i32 __builtin_msa_bnz_v (v16u8);
14751 v16u8 __builtin_msa_bsel_v (v16u8, v16u8, v16u8);
14753 v16u8 __builtin_msa_bseli_b (v16u8, v16u8, imm0_255);
14755 v16u8 __builtin_msa_bset_b (v16u8, v16u8);
14756 v8u16 __builtin_msa_bset_h (v8u16, v8u16);
14757 v4u32 __builtin_msa_bset_w (v4u32, v4u32);
14758 v2u64 __builtin_msa_bset_d (v2u64, v2u64);
14760 v16u8 __builtin_msa_bseti_b (v16u8, imm0_7);
14761 v8u16 __builtin_msa_bseti_h (v8u16, imm0_15);
14762 v4u32 __builtin_msa_bseti_w (v4u32, imm0_31);
14763 v2u64 __builtin_msa_bseti_d (v2u64, imm0_63);
14765 i32 __builtin_msa_bz_b (v16u8);
14766 i32 __builtin_msa_bz_h (v8u16);
14767 i32 __builtin_msa_bz_w (v4u32);
14768 i32 __builtin_msa_bz_d (v2u64);
14770 i32 __builtin_msa_bz_v (v16u8);
14772 v16i8 __builtin_msa_ceq_b (v16i8, v16i8);
14773 v8i16 __builtin_msa_ceq_h (v8i16, v8i16);
14774 v4i32 __builtin_msa_ceq_w (v4i32, v4i32);
14775 v2i64 __builtin_msa_ceq_d (v2i64, v2i64);
14777 v16i8 __builtin_msa_ceqi_b (v16i8, imm_n16_15);
14778 v8i16 __builtin_msa_ceqi_h (v8i16, imm_n16_15);
14779 v4i32 __builtin_msa_ceqi_w (v4i32, imm_n16_15);
14780 v2i64 __builtin_msa_ceqi_d (v2i64, imm_n16_15);
14782 i32 __builtin_msa_cfcmsa (imm0_31);
14784 v16i8 __builtin_msa_cle_s_b (v16i8, v16i8);
14785 v8i16 __builtin_msa_cle_s_h (v8i16, v8i16);
14786 v4i32 __builtin_msa_cle_s_w (v4i32, v4i32);
14787 v2i64 __builtin_msa_cle_s_d (v2i64, v2i64);
14789 v16i8 __builtin_msa_cle_u_b (v16u8, v16u8);
14790 v8i16 __builtin_msa_cle_u_h (v8u16, v8u16);
14791 v4i32 __builtin_msa_cle_u_w (v4u32, v4u32);
14792 v2i64 __builtin_msa_cle_u_d (v2u64, v2u64);
14794 v16i8 __builtin_msa_clei_s_b (v16i8, imm_n16_15);
14795 v8i16 __builtin_msa_clei_s_h (v8i16, imm_n16_15);
14796 v4i32 __builtin_msa_clei_s_w (v4i32, imm_n16_15);
14797 v2i64 __builtin_msa_clei_s_d (v2i64, imm_n16_15);
14799 v16i8 __builtin_msa_clei_u_b (v16u8, imm0_31);
14800 v8i16 __builtin_msa_clei_u_h (v8u16, imm0_31);
14801 v4i32 __builtin_msa_clei_u_w (v4u32, imm0_31);
14802 v2i64 __builtin_msa_clei_u_d (v2u64, imm0_31);
14804 v16i8 __builtin_msa_clt_s_b (v16i8, v16i8);
14805 v8i16 __builtin_msa_clt_s_h (v8i16, v8i16);
14806 v4i32 __builtin_msa_clt_s_w (v4i32, v4i32);
14807 v2i64 __builtin_msa_clt_s_d (v2i64, v2i64);
14809 v16i8 __builtin_msa_clt_u_b (v16u8, v16u8);
14810 v8i16 __builtin_msa_clt_u_h (v8u16, v8u16);
14811 v4i32 __builtin_msa_clt_u_w (v4u32, v4u32);
14812 v2i64 __builtin_msa_clt_u_d (v2u64, v2u64);
14814 v16i8 __builtin_msa_clti_s_b (v16i8, imm_n16_15);
14815 v8i16 __builtin_msa_clti_s_h (v8i16, imm_n16_15);
14816 v4i32 __builtin_msa_clti_s_w (v4i32, imm_n16_15);
14817 v2i64 __builtin_msa_clti_s_d (v2i64, imm_n16_15);
14819 v16i8 __builtin_msa_clti_u_b (v16u8, imm0_31);
14820 v8i16 __builtin_msa_clti_u_h (v8u16, imm0_31);
14821 v4i32 __builtin_msa_clti_u_w (v4u32, imm0_31);
14822 v2i64 __builtin_msa_clti_u_d (v2u64, imm0_31);
14824 i32 __builtin_msa_copy_s_b (v16i8, imm0_15);
14825 i32 __builtin_msa_copy_s_h (v8i16, imm0_7);
14826 i32 __builtin_msa_copy_s_w (v4i32, imm0_3);
14827 i64 __builtin_msa_copy_s_d (v2i64, imm0_1);
14829 u32 __builtin_msa_copy_u_b (v16i8, imm0_15);
14830 u32 __builtin_msa_copy_u_h (v8i16, imm0_7);
14831 u32 __builtin_msa_copy_u_w (v4i32, imm0_3);
14832 u64 __builtin_msa_copy_u_d (v2i64, imm0_1);
14834 void __builtin_msa_ctcmsa (imm0_31, i32);
14836 v16i8 __builtin_msa_div_s_b (v16i8, v16i8);
14837 v8i16 __builtin_msa_div_s_h (v8i16, v8i16);
14838 v4i32 __builtin_msa_div_s_w (v4i32, v4i32);
14839 v2i64 __builtin_msa_div_s_d (v2i64, v2i64);
14841 v16u8 __builtin_msa_div_u_b (v16u8, v16u8);
14842 v8u16 __builtin_msa_div_u_h (v8u16, v8u16);
14843 v4u32 __builtin_msa_div_u_w (v4u32, v4u32);
14844 v2u64 __builtin_msa_div_u_d (v2u64, v2u64);
14846 v8i16 __builtin_msa_dotp_s_h (v16i8, v16i8);
14847 v4i32 __builtin_msa_dotp_s_w (v8i16, v8i16);
14848 v2i64 __builtin_msa_dotp_s_d (v4i32, v4i32);
14850 v8u16 __builtin_msa_dotp_u_h (v16u8, v16u8);
14851 v4u32 __builtin_msa_dotp_u_w (v8u16, v8u16);
14852 v2u64 __builtin_msa_dotp_u_d (v4u32, v4u32);
14854 v8i16 __builtin_msa_dpadd_s_h (v8i16, v16i8, v16i8);
14855 v4i32 __builtin_msa_dpadd_s_w (v4i32, v8i16, v8i16);
14856 v2i64 __builtin_msa_dpadd_s_d (v2i64, v4i32, v4i32);
14858 v8u16 __builtin_msa_dpadd_u_h (v8u16, v16u8, v16u8);
14859 v4u32 __builtin_msa_dpadd_u_w (v4u32, v8u16, v8u16);
14860 v2u64 __builtin_msa_dpadd_u_d (v2u64, v4u32, v4u32);
14862 v8i16 __builtin_msa_dpsub_s_h (v8i16, v16i8, v16i8);
14863 v4i32 __builtin_msa_dpsub_s_w (v4i32, v8i16, v8i16);
14864 v2i64 __builtin_msa_dpsub_s_d (v2i64, v4i32, v4i32);
14866 v8i16 __builtin_msa_dpsub_u_h (v8i16, v16u8, v16u8);
14867 v4i32 __builtin_msa_dpsub_u_w (v4i32, v8u16, v8u16);
14868 v2i64 __builtin_msa_dpsub_u_d (v2i64, v4u32, v4u32);
14870 v4f32 __builtin_msa_fadd_w (v4f32, v4f32);
14871 v2f64 __builtin_msa_fadd_d (v2f64, v2f64);
14873 v4i32 __builtin_msa_fcaf_w (v4f32, v4f32);
14874 v2i64 __builtin_msa_fcaf_d (v2f64, v2f64);
14876 v4i32 __builtin_msa_fceq_w (v4f32, v4f32);
14877 v2i64 __builtin_msa_fceq_d (v2f64, v2f64);
14879 v4i32 __builtin_msa_fclass_w (v4f32);
14880 v2i64 __builtin_msa_fclass_d (v2f64);
14882 v4i32 __builtin_msa_fcle_w (v4f32, v4f32);
14883 v2i64 __builtin_msa_fcle_d (v2f64, v2f64);
14885 v4i32 __builtin_msa_fclt_w (v4f32, v4f32);
14886 v2i64 __builtin_msa_fclt_d (v2f64, v2f64);
14888 v4i32 __builtin_msa_fcne_w (v4f32, v4f32);
14889 v2i64 __builtin_msa_fcne_d (v2f64, v2f64);
14891 v4i32 __builtin_msa_fcor_w (v4f32, v4f32);
14892 v2i64 __builtin_msa_fcor_d (v2f64, v2f64);
14894 v4i32 __builtin_msa_fcueq_w (v4f32, v4f32);
14895 v2i64 __builtin_msa_fcueq_d (v2f64, v2f64);
14897 v4i32 __builtin_msa_fcule_w (v4f32, v4f32);
14898 v2i64 __builtin_msa_fcule_d (v2f64, v2f64);
14900 v4i32 __builtin_msa_fcult_w (v4f32, v4f32);
14901 v2i64 __builtin_msa_fcult_d (v2f64, v2f64);
14903 v4i32 __builtin_msa_fcun_w (v4f32, v4f32);
14904 v2i64 __builtin_msa_fcun_d (v2f64, v2f64);
14906 v4i32 __builtin_msa_fcune_w (v4f32, v4f32);
14907 v2i64 __builtin_msa_fcune_d (v2f64, v2f64);
14909 v4f32 __builtin_msa_fdiv_w (v4f32, v4f32);
14910 v2f64 __builtin_msa_fdiv_d (v2f64, v2f64);
14912 v8i16 __builtin_msa_fexdo_h (v4f32, v4f32);
14913 v4f32 __builtin_msa_fexdo_w (v2f64, v2f64);
14915 v4f32 __builtin_msa_fexp2_w (v4f32, v4i32);
14916 v2f64 __builtin_msa_fexp2_d (v2f64, v2i64);
14918 v4f32 __builtin_msa_fexupl_w (v8i16);
14919 v2f64 __builtin_msa_fexupl_d (v4f32);
14921 v4f32 __builtin_msa_fexupr_w (v8i16);
14922 v2f64 __builtin_msa_fexupr_d (v4f32);
14924 v4f32 __builtin_msa_ffint_s_w (v4i32);
14925 v2f64 __builtin_msa_ffint_s_d (v2i64);
14927 v4f32 __builtin_msa_ffint_u_w (v4u32);
14928 v2f64 __builtin_msa_ffint_u_d (v2u64);
14930 v4f32 __builtin_msa_ffql_w (v8i16);
14931 v2f64 __builtin_msa_ffql_d (v4i32);
14933 v4f32 __builtin_msa_ffqr_w (v8i16);
14934 v2f64 __builtin_msa_ffqr_d (v4i32);
14936 v16i8 __builtin_msa_fill_b (i32);
14937 v8i16 __builtin_msa_fill_h (i32);
14938 v4i32 __builtin_msa_fill_w (i32);
14939 v2i64 __builtin_msa_fill_d (i64);
14941 v4f32 __builtin_msa_flog2_w (v4f32);
14942 v2f64 __builtin_msa_flog2_d (v2f64);
14944 v4f32 __builtin_msa_fmadd_w (v4f32, v4f32, v4f32);
14945 v2f64 __builtin_msa_fmadd_d (v2f64, v2f64, v2f64);
14947 v4f32 __builtin_msa_fmax_w (v4f32, v4f32);
14948 v2f64 __builtin_msa_fmax_d (v2f64, v2f64);
14950 v4f32 __builtin_msa_fmax_a_w (v4f32, v4f32);
14951 v2f64 __builtin_msa_fmax_a_d (v2f64, v2f64);
14953 v4f32 __builtin_msa_fmin_w (v4f32, v4f32);
14954 v2f64 __builtin_msa_fmin_d (v2f64, v2f64);
14956 v4f32 __builtin_msa_fmin_a_w (v4f32, v4f32);
14957 v2f64 __builtin_msa_fmin_a_d (v2f64, v2f64);
14959 v4f32 __builtin_msa_fmsub_w (v4f32, v4f32, v4f32);
14960 v2f64 __builtin_msa_fmsub_d (v2f64, v2f64, v2f64);
14962 v4f32 __builtin_msa_fmul_w (v4f32, v4f32);
14963 v2f64 __builtin_msa_fmul_d (v2f64, v2f64);
14965 v4f32 __builtin_msa_frint_w (v4f32);
14966 v2f64 __builtin_msa_frint_d (v2f64);
14968 v4f32 __builtin_msa_frcp_w (v4f32);
14969 v2f64 __builtin_msa_frcp_d (v2f64);
14971 v4f32 __builtin_msa_frsqrt_w (v4f32);
14972 v2f64 __builtin_msa_frsqrt_d (v2f64);
14974 v4i32 __builtin_msa_fsaf_w (v4f32, v4f32);
14975 v2i64 __builtin_msa_fsaf_d (v2f64, v2f64);
14977 v4i32 __builtin_msa_fseq_w (v4f32, v4f32);
14978 v2i64 __builtin_msa_fseq_d (v2f64, v2f64);
14980 v4i32 __builtin_msa_fsle_w (v4f32, v4f32);
14981 v2i64 __builtin_msa_fsle_d (v2f64, v2f64);
14983 v4i32 __builtin_msa_fslt_w (v4f32, v4f32);
14984 v2i64 __builtin_msa_fslt_d (v2f64, v2f64);
14986 v4i32 __builtin_msa_fsne_w (v4f32, v4f32);
14987 v2i64 __builtin_msa_fsne_d (v2f64, v2f64);
14989 v4i32 __builtin_msa_fsor_w (v4f32, v4f32);
14990 v2i64 __builtin_msa_fsor_d (v2f64, v2f64);
14992 v4f32 __builtin_msa_fsqrt_w (v4f32);
14993 v2f64 __builtin_msa_fsqrt_d (v2f64);
14995 v4f32 __builtin_msa_fsub_w (v4f32, v4f32);
14996 v2f64 __builtin_msa_fsub_d (v2f64, v2f64);
14998 v4i32 __builtin_msa_fsueq_w (v4f32, v4f32);
14999 v2i64 __builtin_msa_fsueq_d (v2f64, v2f64);
15001 v4i32 __builtin_msa_fsule_w (v4f32, v4f32);
15002 v2i64 __builtin_msa_fsule_d (v2f64, v2f64);
15004 v4i32 __builtin_msa_fsult_w (v4f32, v4f32);
15005 v2i64 __builtin_msa_fsult_d (v2f64, v2f64);
15007 v4i32 __builtin_msa_fsun_w (v4f32, v4f32);
15008 v2i64 __builtin_msa_fsun_d (v2f64, v2f64);
15010 v4i32 __builtin_msa_fsune_w (v4f32, v4f32);
15011 v2i64 __builtin_msa_fsune_d (v2f64, v2f64);
15013 v4i32 __builtin_msa_ftint_s_w (v4f32);
15014 v2i64 __builtin_msa_ftint_s_d (v2f64);
15016 v4u32 __builtin_msa_ftint_u_w (v4f32);
15017 v2u64 __builtin_msa_ftint_u_d (v2f64);
15019 v8i16 __builtin_msa_ftq_h (v4f32, v4f32);
15020 v4i32 __builtin_msa_ftq_w (v2f64, v2f64);
15022 v4i32 __builtin_msa_ftrunc_s_w (v4f32);
15023 v2i64 __builtin_msa_ftrunc_s_d (v2f64);
15025 v4u32 __builtin_msa_ftrunc_u_w (v4f32);
15026 v2u64 __builtin_msa_ftrunc_u_d (v2f64);
15028 v8i16 __builtin_msa_hadd_s_h (v16i8, v16i8);
15029 v4i32 __builtin_msa_hadd_s_w (v8i16, v8i16);
15030 v2i64 __builtin_msa_hadd_s_d (v4i32, v4i32);
15032 v8u16 __builtin_msa_hadd_u_h (v16u8, v16u8);
15033 v4u32 __builtin_msa_hadd_u_w (v8u16, v8u16);
15034 v2u64 __builtin_msa_hadd_u_d (v4u32, v4u32);
15036 v8i16 __builtin_msa_hsub_s_h (v16i8, v16i8);
15037 v4i32 __builtin_msa_hsub_s_w (v8i16, v8i16);
15038 v2i64 __builtin_msa_hsub_s_d (v4i32, v4i32);
15040 v8i16 __builtin_msa_hsub_u_h (v16u8, v16u8);
15041 v4i32 __builtin_msa_hsub_u_w (v8u16, v8u16);
15042 v2i64 __builtin_msa_hsub_u_d (v4u32, v4u32);
15044 v16i8 __builtin_msa_ilvev_b (v16i8, v16i8);
15045 v8i16 __builtin_msa_ilvev_h (v8i16, v8i16);
15046 v4i32 __builtin_msa_ilvev_w (v4i32, v4i32);
15047 v2i64 __builtin_msa_ilvev_d (v2i64, v2i64);
15049 v16i8 __builtin_msa_ilvl_b (v16i8, v16i8);
15050 v8i16 __builtin_msa_ilvl_h (v8i16, v8i16);
15051 v4i32 __builtin_msa_ilvl_w (v4i32, v4i32);
15052 v2i64 __builtin_msa_ilvl_d (v2i64, v2i64);
15054 v16i8 __builtin_msa_ilvod_b (v16i8, v16i8);
15055 v8i16 __builtin_msa_ilvod_h (v8i16, v8i16);
15056 v4i32 __builtin_msa_ilvod_w (v4i32, v4i32);
15057 v2i64 __builtin_msa_ilvod_d (v2i64, v2i64);
15059 v16i8 __builtin_msa_ilvr_b (v16i8, v16i8);
15060 v8i16 __builtin_msa_ilvr_h (v8i16, v8i16);
15061 v4i32 __builtin_msa_ilvr_w (v4i32, v4i32);
15062 v2i64 __builtin_msa_ilvr_d (v2i64, v2i64);
15064 v16i8 __builtin_msa_insert_b (v16i8, imm0_15, i32);
15065 v8i16 __builtin_msa_insert_h (v8i16, imm0_7, i32);
15066 v4i32 __builtin_msa_insert_w (v4i32, imm0_3, i32);
15067 v2i64 __builtin_msa_insert_d (v2i64, imm0_1, i64);
15069 v16i8 __builtin_msa_insve_b (v16i8, imm0_15, v16i8);
15070 v8i16 __builtin_msa_insve_h (v8i16, imm0_7, v8i16);
15071 v4i32 __builtin_msa_insve_w (v4i32, imm0_3, v4i32);
15072 v2i64 __builtin_msa_insve_d (v2i64, imm0_1, v2i64);
15074 v16i8 __builtin_msa_ld_b (void *, imm_n512_511);
15075 v8i16 __builtin_msa_ld_h (void *, imm_n1024_1022);
15076 v4i32 __builtin_msa_ld_w (void *, imm_n2048_2044);
15077 v2i64 __builtin_msa_ld_d (void *, imm_n4096_4088);
15079 v16i8 __builtin_msa_ldi_b (imm_n512_511);
15080 v8i16 __builtin_msa_ldi_h (imm_n512_511);
15081 v4i32 __builtin_msa_ldi_w (imm_n512_511);
15082 v2i64 __builtin_msa_ldi_d (imm_n512_511);
15084 v8i16 __builtin_msa_madd_q_h (v8i16, v8i16, v8i16);
15085 v4i32 __builtin_msa_madd_q_w (v4i32, v4i32, v4i32);
15087 v8i16 __builtin_msa_maddr_q_h (v8i16, v8i16, v8i16);
15088 v4i32 __builtin_msa_maddr_q_w (v4i32, v4i32, v4i32);
15090 v16i8 __builtin_msa_maddv_b (v16i8, v16i8, v16i8);
15091 v8i16 __builtin_msa_maddv_h (v8i16, v8i16, v8i16);
15092 v4i32 __builtin_msa_maddv_w (v4i32, v4i32, v4i32);
15093 v2i64 __builtin_msa_maddv_d (v2i64, v2i64, v2i64);
15095 v16i8 __builtin_msa_max_a_b (v16i8, v16i8);
15096 v8i16 __builtin_msa_max_a_h (v8i16, v8i16);
15097 v4i32 __builtin_msa_max_a_w (v4i32, v4i32);
15098 v2i64 __builtin_msa_max_a_d (v2i64, v2i64);
15100 v16i8 __builtin_msa_max_s_b (v16i8, v16i8);
15101 v8i16 __builtin_msa_max_s_h (v8i16, v8i16);
15102 v4i32 __builtin_msa_max_s_w (v4i32, v4i32);
15103 v2i64 __builtin_msa_max_s_d (v2i64, v2i64);
15105 v16u8 __builtin_msa_max_u_b (v16u8, v16u8);
15106 v8u16 __builtin_msa_max_u_h (v8u16, v8u16);
15107 v4u32 __builtin_msa_max_u_w (v4u32, v4u32);
15108 v2u64 __builtin_msa_max_u_d (v2u64, v2u64);
15110 v16i8 __builtin_msa_maxi_s_b (v16i8, imm_n16_15);
15111 v8i16 __builtin_msa_maxi_s_h (v8i16, imm_n16_15);
15112 v4i32 __builtin_msa_maxi_s_w (v4i32, imm_n16_15);
15113 v2i64 __builtin_msa_maxi_s_d (v2i64, imm_n16_15);
15115 v16u8 __builtin_msa_maxi_u_b (v16u8, imm0_31);
15116 v8u16 __builtin_msa_maxi_u_h (v8u16, imm0_31);
15117 v4u32 __builtin_msa_maxi_u_w (v4u32, imm0_31);
15118 v2u64 __builtin_msa_maxi_u_d (v2u64, imm0_31);
15120 v16i8 __builtin_msa_min_a_b (v16i8, v16i8);
15121 v8i16 __builtin_msa_min_a_h (v8i16, v8i16);
15122 v4i32 __builtin_msa_min_a_w (v4i32, v4i32);
15123 v2i64 __builtin_msa_min_a_d (v2i64, v2i64);
15125 v16i8 __builtin_msa_min_s_b (v16i8, v16i8);
15126 v8i16 __builtin_msa_min_s_h (v8i16, v8i16);
15127 v4i32 __builtin_msa_min_s_w (v4i32, v4i32);
15128 v2i64 __builtin_msa_min_s_d (v2i64, v2i64);
15130 v16u8 __builtin_msa_min_u_b (v16u8, v16u8);
15131 v8u16 __builtin_msa_min_u_h (v8u16, v8u16);
15132 v4u32 __builtin_msa_min_u_w (v4u32, v4u32);
15133 v2u64 __builtin_msa_min_u_d (v2u64, v2u64);
15135 v16i8 __builtin_msa_mini_s_b (v16i8, imm_n16_15);
15136 v8i16 __builtin_msa_mini_s_h (v8i16, imm_n16_15);
15137 v4i32 __builtin_msa_mini_s_w (v4i32, imm_n16_15);
15138 v2i64 __builtin_msa_mini_s_d (v2i64, imm_n16_15);
15140 v16u8 __builtin_msa_mini_u_b (v16u8, imm0_31);
15141 v8u16 __builtin_msa_mini_u_h (v8u16, imm0_31);
15142 v4u32 __builtin_msa_mini_u_w (v4u32, imm0_31);
15143 v2u64 __builtin_msa_mini_u_d (v2u64, imm0_31);
15145 v16i8 __builtin_msa_mod_s_b (v16i8, v16i8);
15146 v8i16 __builtin_msa_mod_s_h (v8i16, v8i16);
15147 v4i32 __builtin_msa_mod_s_w (v4i32, v4i32);
15148 v2i64 __builtin_msa_mod_s_d (v2i64, v2i64);
15150 v16u8 __builtin_msa_mod_u_b (v16u8, v16u8);
15151 v8u16 __builtin_msa_mod_u_h (v8u16, v8u16);
15152 v4u32 __builtin_msa_mod_u_w (v4u32, v4u32);
15153 v2u64 __builtin_msa_mod_u_d (v2u64, v2u64);
15155 v16i8 __builtin_msa_move_v (v16i8);
15157 v8i16 __builtin_msa_msub_q_h (v8i16, v8i16, v8i16);
15158 v4i32 __builtin_msa_msub_q_w (v4i32, v4i32, v4i32);
15160 v8i16 __builtin_msa_msubr_q_h (v8i16, v8i16, v8i16);
15161 v4i32 __builtin_msa_msubr_q_w (v4i32, v4i32, v4i32);
15163 v16i8 __builtin_msa_msubv_b (v16i8, v16i8, v16i8);
15164 v8i16 __builtin_msa_msubv_h (v8i16, v8i16, v8i16);
15165 v4i32 __builtin_msa_msubv_w (v4i32, v4i32, v4i32);
15166 v2i64 __builtin_msa_msubv_d (v2i64, v2i64, v2i64);
15168 v8i16 __builtin_msa_mul_q_h (v8i16, v8i16);
15169 v4i32 __builtin_msa_mul_q_w (v4i32, v4i32);
15171 v8i16 __builtin_msa_mulr_q_h (v8i16, v8i16);
15172 v4i32 __builtin_msa_mulr_q_w (v4i32, v4i32);
15174 v16i8 __builtin_msa_mulv_b (v16i8, v16i8);
15175 v8i16 __builtin_msa_mulv_h (v8i16, v8i16);
15176 v4i32 __builtin_msa_mulv_w (v4i32, v4i32);
15177 v2i64 __builtin_msa_mulv_d (v2i64, v2i64);
15179 v16i8 __builtin_msa_nloc_b (v16i8);
15180 v8i16 __builtin_msa_nloc_h (v8i16);
15181 v4i32 __builtin_msa_nloc_w (v4i32);
15182 v2i64 __builtin_msa_nloc_d (v2i64);
15184 v16i8 __builtin_msa_nlzc_b (v16i8);
15185 v8i16 __builtin_msa_nlzc_h (v8i16);
15186 v4i32 __builtin_msa_nlzc_w (v4i32);
15187 v2i64 __builtin_msa_nlzc_d (v2i64);
15189 v16u8 __builtin_msa_nor_v (v16u8, v16u8);
15191 v16u8 __builtin_msa_nori_b (v16u8, imm0_255);
15193 v16u8 __builtin_msa_or_v (v16u8, v16u8);
15195 v16u8 __builtin_msa_ori_b (v16u8, imm0_255);
15197 v16i8 __builtin_msa_pckev_b (v16i8, v16i8);
15198 v8i16 __builtin_msa_pckev_h (v8i16, v8i16);
15199 v4i32 __builtin_msa_pckev_w (v4i32, v4i32);
15200 v2i64 __builtin_msa_pckev_d (v2i64, v2i64);
15202 v16i8 __builtin_msa_pckod_b (v16i8, v16i8);
15203 v8i16 __builtin_msa_pckod_h (v8i16, v8i16);
15204 v4i32 __builtin_msa_pckod_w (v4i32, v4i32);
15205 v2i64 __builtin_msa_pckod_d (v2i64, v2i64);
15207 v16i8 __builtin_msa_pcnt_b (v16i8);
15208 v8i16 __builtin_msa_pcnt_h (v8i16);
15209 v4i32 __builtin_msa_pcnt_w (v4i32);
15210 v2i64 __builtin_msa_pcnt_d (v2i64);
15212 v16i8 __builtin_msa_sat_s_b (v16i8, imm0_7);
15213 v8i16 __builtin_msa_sat_s_h (v8i16, imm0_15);
15214 v4i32 __builtin_msa_sat_s_w (v4i32, imm0_31);
15215 v2i64 __builtin_msa_sat_s_d (v2i64, imm0_63);
15217 v16u8 __builtin_msa_sat_u_b (v16u8, imm0_7);
15218 v8u16 __builtin_msa_sat_u_h (v8u16, imm0_15);
15219 v4u32 __builtin_msa_sat_u_w (v4u32, imm0_31);
15220 v2u64 __builtin_msa_sat_u_d (v2u64, imm0_63);
15222 v16i8 __builtin_msa_shf_b (v16i8, imm0_255);
15223 v8i16 __builtin_msa_shf_h (v8i16, imm0_255);
15224 v4i32 __builtin_msa_shf_w (v4i32, imm0_255);
15226 v16i8 __builtin_msa_sld_b (v16i8, v16i8, i32);
15227 v8i16 __builtin_msa_sld_h (v8i16, v8i16, i32);
15228 v4i32 __builtin_msa_sld_w (v4i32, v4i32, i32);
15229 v2i64 __builtin_msa_sld_d (v2i64, v2i64, i32);
15231 v16i8 __builtin_msa_sldi_b (v16i8, v16i8, imm0_15);
15232 v8i16 __builtin_msa_sldi_h (v8i16, v8i16, imm0_7);
15233 v4i32 __builtin_msa_sldi_w (v4i32, v4i32, imm0_3);
15234 v2i64 __builtin_msa_sldi_d (v2i64, v2i64, imm0_1);
15236 v16i8 __builtin_msa_sll_b (v16i8, v16i8);
15237 v8i16 __builtin_msa_sll_h (v8i16, v8i16);
15238 v4i32 __builtin_msa_sll_w (v4i32, v4i32);
15239 v2i64 __builtin_msa_sll_d (v2i64, v2i64);
15241 v16i8 __builtin_msa_slli_b (v16i8, imm0_7);
15242 v8i16 __builtin_msa_slli_h (v8i16, imm0_15);
15243 v4i32 __builtin_msa_slli_w (v4i32, imm0_31);
15244 v2i64 __builtin_msa_slli_d (v2i64, imm0_63);
15246 v16i8 __builtin_msa_splat_b (v16i8, i32);
15247 v8i16 __builtin_msa_splat_h (v8i16, i32);
15248 v4i32 __builtin_msa_splat_w (v4i32, i32);
15249 v2i64 __builtin_msa_splat_d (v2i64, i32);
15251 v16i8 __builtin_msa_splati_b (v16i8, imm0_15);
15252 v8i16 __builtin_msa_splati_h (v8i16, imm0_7);
15253 v4i32 __builtin_msa_splati_w (v4i32, imm0_3);
15254 v2i64 __builtin_msa_splati_d (v2i64, imm0_1);
15256 v16i8 __builtin_msa_sra_b (v16i8, v16i8);
15257 v8i16 __builtin_msa_sra_h (v8i16, v8i16);
15258 v4i32 __builtin_msa_sra_w (v4i32, v4i32);
15259 v2i64 __builtin_msa_sra_d (v2i64, v2i64);
15261 v16i8 __builtin_msa_srai_b (v16i8, imm0_7);
15262 v8i16 __builtin_msa_srai_h (v8i16, imm0_15);
15263 v4i32 __builtin_msa_srai_w (v4i32, imm0_31);
15264 v2i64 __builtin_msa_srai_d (v2i64, imm0_63);
15266 v16i8 __builtin_msa_srar_b (v16i8, v16i8);
15267 v8i16 __builtin_msa_srar_h (v8i16, v8i16);
15268 v4i32 __builtin_msa_srar_w (v4i32, v4i32);
15269 v2i64 __builtin_msa_srar_d (v2i64, v2i64);
15271 v16i8 __builtin_msa_srari_b (v16i8, imm0_7);
15272 v8i16 __builtin_msa_srari_h (v8i16, imm0_15);
15273 v4i32 __builtin_msa_srari_w (v4i32, imm0_31);
15274 v2i64 __builtin_msa_srari_d (v2i64, imm0_63);
15276 v16i8 __builtin_msa_srl_b (v16i8, v16i8);
15277 v8i16 __builtin_msa_srl_h (v8i16, v8i16);
15278 v4i32 __builtin_msa_srl_w (v4i32, v4i32);
15279 v2i64 __builtin_msa_srl_d (v2i64, v2i64);
15281 v16i8 __builtin_msa_srli_b (v16i8, imm0_7);
15282 v8i16 __builtin_msa_srli_h (v8i16, imm0_15);
15283 v4i32 __builtin_msa_srli_w (v4i32, imm0_31);
15284 v2i64 __builtin_msa_srli_d (v2i64, imm0_63);
15286 v16i8 __builtin_msa_srlr_b (v16i8, v16i8);
15287 v8i16 __builtin_msa_srlr_h (v8i16, v8i16);
15288 v4i32 __builtin_msa_srlr_w (v4i32, v4i32);
15289 v2i64 __builtin_msa_srlr_d (v2i64, v2i64);
15291 v16i8 __builtin_msa_srlri_b (v16i8, imm0_7);
15292 v8i16 __builtin_msa_srlri_h (v8i16, imm0_15);
15293 v4i32 __builtin_msa_srlri_w (v4i32, imm0_31);
15294 v2i64 __builtin_msa_srlri_d (v2i64, imm0_63);
15296 void __builtin_msa_st_b (v16i8, void *, imm_n512_511);
15297 void __builtin_msa_st_h (v8i16, void *, imm_n1024_1022);
15298 void __builtin_msa_st_w (v4i32, void *, imm_n2048_2044);
15299 void __builtin_msa_st_d (v2i64, void *, imm_n4096_4088);
15301 v16i8 __builtin_msa_subs_s_b (v16i8, v16i8);
15302 v8i16 __builtin_msa_subs_s_h (v8i16, v8i16);
15303 v4i32 __builtin_msa_subs_s_w (v4i32, v4i32);
15304 v2i64 __builtin_msa_subs_s_d (v2i64, v2i64);
15306 v16u8 __builtin_msa_subs_u_b (v16u8, v16u8);
15307 v8u16 __builtin_msa_subs_u_h (v8u16, v8u16);
15308 v4u32 __builtin_msa_subs_u_w (v4u32, v4u32);
15309 v2u64 __builtin_msa_subs_u_d (v2u64, v2u64);
15311 v16u8 __builtin_msa_subsus_u_b (v16u8, v16i8);
15312 v8u16 __builtin_msa_subsus_u_h (v8u16, v8i16);
15313 v4u32 __builtin_msa_subsus_u_w (v4u32, v4i32);
15314 v2u64 __builtin_msa_subsus_u_d (v2u64, v2i64);
15316 v16i8 __builtin_msa_subsuu_s_b (v16u8, v16u8);
15317 v8i16 __builtin_msa_subsuu_s_h (v8u16, v8u16);
15318 v4i32 __builtin_msa_subsuu_s_w (v4u32, v4u32);
15319 v2i64 __builtin_msa_subsuu_s_d (v2u64, v2u64);
15321 v16i8 __builtin_msa_subv_b (v16i8, v16i8);
15322 v8i16 __builtin_msa_subv_h (v8i16, v8i16);
15323 v4i32 __builtin_msa_subv_w (v4i32, v4i32);
15324 v2i64 __builtin_msa_subv_d (v2i64, v2i64);
15326 v16i8 __builtin_msa_subvi_b (v16i8, imm0_31);
15327 v8i16 __builtin_msa_subvi_h (v8i16, imm0_31);
15328 v4i32 __builtin_msa_subvi_w (v4i32, imm0_31);
15329 v2i64 __builtin_msa_subvi_d (v2i64, imm0_31);
15331 v16i8 __builtin_msa_vshf_b (v16i8, v16i8, v16i8);
15332 v8i16 __builtin_msa_vshf_h (v8i16, v8i16, v8i16);
15333 v4i32 __builtin_msa_vshf_w (v4i32, v4i32, v4i32);
15334 v2i64 __builtin_msa_vshf_d (v2i64, v2i64, v2i64);
15336 v16u8 __builtin_msa_xor_v (v16u8, v16u8);
15338 v16u8 __builtin_msa_xori_b (v16u8, imm0_255);
15339 @end smallexample
15341 @node Other MIPS Built-in Functions
15342 @subsection Other MIPS Built-in Functions
15344 GCC provides other MIPS-specific built-in functions:
15346 @table @code
15347 @item void __builtin_mips_cache (int @var{op}, const volatile void *@var{addr})
15348 Insert a @samp{cache} instruction with operands @var{op} and @var{addr}.
15349 GCC defines the preprocessor macro @code{___GCC_HAVE_BUILTIN_MIPS_CACHE}
15350 when this function is available.
15352 @item unsigned int __builtin_mips_get_fcsr (void)
15353 @itemx void __builtin_mips_set_fcsr (unsigned int @var{value})
15354 Get and set the contents of the floating-point control and status register
15355 (FPU control register 31).  These functions are only available in hard-float
15356 code but can be called in both MIPS16 and non-MIPS16 contexts.
15358 @code{__builtin_mips_set_fcsr} can be used to change any bit of the
15359 register except the condition codes, which GCC assumes are preserved.
15360 @end table
15362 @node MSP430 Built-in Functions
15363 @subsection MSP430 Built-in Functions
15365 GCC provides a couple of special builtin functions to aid in the
15366 writing of interrupt handlers in C.
15368 @table @code
15369 @item __bic_SR_register_on_exit (int @var{mask})
15370 This clears the indicated bits in the saved copy of the status register
15371 currently residing on the stack.  This only works inside interrupt
15372 handlers and the changes to the status register will only take affect
15373 once the handler returns.
15375 @item __bis_SR_register_on_exit (int @var{mask})
15376 This sets the indicated bits in the saved copy of the status register
15377 currently residing on the stack.  This only works inside interrupt
15378 handlers and the changes to the status register will only take affect
15379 once the handler returns.
15381 @item __delay_cycles (long long @var{cycles})
15382 This inserts an instruction sequence that takes exactly @var{cycles}
15383 cycles (between 0 and about 17E9) to complete.  The inserted sequence
15384 may use jumps, loops, or no-ops, and does not interfere with any other
15385 instructions.  Note that @var{cycles} must be a compile-time constant
15386 integer - that is, you must pass a number, not a variable that may be
15387 optimized to a constant later.  The number of cycles delayed by this
15388 builtin is exact.
15389 @end table
15391 @node NDS32 Built-in Functions
15392 @subsection NDS32 Built-in Functions
15394 These built-in functions are available for the NDS32 target:
15396 @deftypefn {Built-in Function} void __builtin_nds32_isync (int *@var{addr})
15397 Insert an ISYNC instruction into the instruction stream where
15398 @var{addr} is an instruction address for serialization.
15399 @end deftypefn
15401 @deftypefn {Built-in Function} void __builtin_nds32_isb (void)
15402 Insert an ISB instruction into the instruction stream.
15403 @end deftypefn
15405 @deftypefn {Built-in Function} int __builtin_nds32_mfsr (int @var{sr})
15406 Return the content of a system register which is mapped by @var{sr}.
15407 @end deftypefn
15409 @deftypefn {Built-in Function} int __builtin_nds32_mfusr (int @var{usr})
15410 Return the content of a user space register which is mapped by @var{usr}.
15411 @end deftypefn
15413 @deftypefn {Built-in Function} void __builtin_nds32_mtsr (int @var{value}, int @var{sr})
15414 Move the @var{value} to a system register which is mapped by @var{sr}.
15415 @end deftypefn
15417 @deftypefn {Built-in Function} void __builtin_nds32_mtusr (int @var{value}, int @var{usr})
15418 Move the @var{value} to a user space register which is mapped by @var{usr}.
15419 @end deftypefn
15421 @deftypefn {Built-in Function} void __builtin_nds32_setgie_en (void)
15422 Enable global interrupt.
15423 @end deftypefn
15425 @deftypefn {Built-in Function} void __builtin_nds32_setgie_dis (void)
15426 Disable global interrupt.
15427 @end deftypefn
15429 @node picoChip Built-in Functions
15430 @subsection picoChip Built-in Functions
15432 GCC provides an interface to selected machine instructions from the
15433 picoChip instruction set.
15435 @table @code
15436 @item int __builtin_sbc (int @var{value})
15437 Sign bit count.  Return the number of consecutive bits in @var{value}
15438 that have the same value as the sign bit.  The result is the number of
15439 leading sign bits minus one, giving the number of redundant sign bits in
15440 @var{value}.
15442 @item int __builtin_byteswap (int @var{value})
15443 Byte swap.  Return the result of swapping the upper and lower bytes of
15444 @var{value}.
15446 @item int __builtin_brev (int @var{value})
15447 Bit reversal.  Return the result of reversing the bits in
15448 @var{value}.  Bit 15 is swapped with bit 0, bit 14 is swapped with bit 1,
15449 and so on.
15451 @item int __builtin_adds (int @var{x}, int @var{y})
15452 Saturating addition.  Return the result of adding @var{x} and @var{y},
15453 storing the value 32767 if the result overflows.
15455 @item int __builtin_subs (int @var{x}, int @var{y})
15456 Saturating subtraction.  Return the result of subtracting @var{y} from
15457 @var{x}, storing the value @minus{}32768 if the result overflows.
15459 @item void __builtin_halt (void)
15460 Halt.  The processor stops execution.  This built-in is useful for
15461 implementing assertions.
15463 @end table
15465 @node PowerPC Built-in Functions
15466 @subsection PowerPC Built-in Functions
15468 The following built-in functions are always available and can be used to
15469 check the PowerPC target platform type:
15471 @deftypefn {Built-in Function} void __builtin_cpu_init (void)
15472 This function is a @code{nop} on the PowerPC platform and is included solely
15473 to maintain API compatibility with the x86 builtins.
15474 @end deftypefn
15476 @deftypefn {Built-in Function} int __builtin_cpu_is (const char *@var{cpuname})
15477 This function returns a value of @code{1} if the run-time CPU is of type
15478 @var{cpuname} and returns @code{0} otherwise
15480 The @code{__builtin_cpu_is} function requires GLIBC 2.23 or newer
15481 which exports the hardware capability bits.  GCC defines the macro
15482 @code{__BUILTIN_CPU_SUPPORTS__} if the @code{__builtin_cpu_supports}
15483 built-in function is fully supported.
15485 If GCC was configured to use a GLIBC before 2.23, the built-in
15486 function @code{__builtin_cpu_is} always returns a 0 and the compiler
15487 issues a warning.
15489 The following CPU names can be detected:
15491 @table @samp
15492 @item power9
15493 IBM POWER9 Server CPU.
15494 @item power8
15495 IBM POWER8 Server CPU.
15496 @item power7
15497 IBM POWER7 Server CPU.
15498 @item power6x
15499 IBM POWER6 Server CPU (RAW mode).
15500 @item power6
15501 IBM POWER6 Server CPU (Architected mode).
15502 @item power5+
15503 IBM POWER5+ Server CPU.
15504 @item power5
15505 IBM POWER5 Server CPU.
15506 @item ppc970
15507 IBM 970 Server CPU (ie, Apple G5).
15508 @item power4
15509 IBM POWER4 Server CPU.
15510 @item ppca2
15511 IBM A2 64-bit Embedded CPU
15512 @item ppc476
15513 IBM PowerPC 476FP 32-bit Embedded CPU.
15514 @item ppc464
15515 IBM PowerPC 464 32-bit Embedded CPU.
15516 @item ppc440
15517 PowerPC 440 32-bit Embedded CPU.
15518 @item ppc405
15519 PowerPC 405 32-bit Embedded CPU.
15520 @item ppc-cell-be
15521 IBM PowerPC Cell Broadband Engine Architecture CPU.
15522 @end table
15524 Here is an example:
15525 @smallexample
15526 #ifdef __BUILTIN_CPU_SUPPORTS__
15527   if (__builtin_cpu_is ("power8"))
15528     @{
15529        do_power8 (); // POWER8 specific implementation.
15530     @}
15531   else
15532 #endif
15533     @{
15534        do_generic (); // Generic implementation.
15535     @}
15536 @end smallexample
15537 @end deftypefn
15539 @deftypefn {Built-in Function} int __builtin_cpu_supports (const char *@var{feature})
15540 This function returns a value of @code{1} if the run-time CPU supports the HWCAP
15541 feature @var{feature} and returns @code{0} otherwise.
15543 The @code{__builtin_cpu_supports} function requires GLIBC 2.23 or
15544 newer which exports the hardware capability bits.  GCC defines the
15545 macro @code{__BUILTIN_CPU_SUPPORTS__} if the
15546 @code{__builtin_cpu_supports} built-in function is fully supported.
15548 If GCC was configured to use a GLIBC before 2.23, the built-in
15549 function @code{__builtin_cpu_suports} always returns a 0 and the
15550 compiler issues a warning.
15552 The following features can be
15553 detected:
15555 @table @samp
15556 @item 4xxmac
15557 4xx CPU has a Multiply Accumulator.
15558 @item altivec
15559 CPU has a SIMD/Vector Unit.
15560 @item arch_2_05
15561 CPU supports ISA 2.05 (eg, POWER6)
15562 @item arch_2_06
15563 CPU supports ISA 2.06 (eg, POWER7)
15564 @item arch_2_07
15565 CPU supports ISA 2.07 (eg, POWER8)
15566 @item arch_3_00
15567 CPU supports ISA 3.0 (eg, POWER9)
15568 @item archpmu
15569 CPU supports the set of compatible performance monitoring events.
15570 @item booke
15571 CPU supports the Embedded ISA category.
15572 @item cellbe
15573 CPU has a CELL broadband engine.
15574 @item dfp
15575 CPU has a decimal floating point unit.
15576 @item dscr
15577 CPU supports the data stream control register.
15578 @item ebb
15579 CPU supports event base branching.
15580 @item efpdouble
15581 CPU has a SPE double precision floating point unit.
15582 @item efpsingle
15583 CPU has a SPE single precision floating point unit.
15584 @item fpu
15585 CPU has a floating point unit.
15586 @item htm
15587 CPU has hardware transaction memory instructions.
15588 @item htm-nosc
15589 Kernel aborts hardware transactions when a syscall is made.
15590 @item ic_snoop
15591 CPU supports icache snooping capabilities.
15592 @item ieee128
15593 CPU supports 128-bit IEEE binary floating point instructions.
15594 @item isel
15595 CPU supports the integer select instruction.
15596 @item mmu
15597 CPU has a memory management unit.
15598 @item notb
15599 CPU does not have a timebase (eg, 601 and 403gx).
15600 @item pa6t
15601 CPU supports the PA Semi 6T CORE ISA.
15602 @item power4
15603 CPU supports ISA 2.00 (eg, POWER4)
15604 @item power5
15605 CPU supports ISA 2.02 (eg, POWER5)
15606 @item power5+
15607 CPU supports ISA 2.03 (eg, POWER5+)
15608 @item power6x
15609 CPU supports ISA 2.05 (eg, POWER6) extended opcodes mffgpr and mftgpr.
15610 @item ppc32
15611 CPU supports 32-bit mode execution.
15612 @item ppc601
15613 CPU supports the old POWER ISA (eg, 601)
15614 @item ppc64
15615 CPU supports 64-bit mode execution.
15616 @item ppcle
15617 CPU supports a little-endian mode that uses address swizzling.
15618 @item smt
15619 CPU support simultaneous multi-threading.
15620 @item spe
15621 CPU has a signal processing extension unit.
15622 @item tar
15623 CPU supports the target address register.
15624 @item true_le
15625 CPU supports true little-endian mode.
15626 @item ucache
15627 CPU has unified I/D cache.
15628 @item vcrypto
15629 CPU supports the vector cryptography instructions.
15630 @item vsx
15631 CPU supports the vector-scalar extension.
15632 @end table
15634 Here is an example:
15635 @smallexample
15636 #ifdef __BUILTIN_CPU_SUPPORTS__
15637   if (__builtin_cpu_supports ("fpu"))
15638     @{
15639        asm("fadd %0,%1,%2" : "=d"(dst) : "d"(src1), "d"(src2));
15640     @}
15641   else
15642 #endif
15643     @{
15644        dst = __fadd (src1, src2); // Software FP addition function.
15645     @}
15646 @end smallexample
15647 @end deftypefn
15649 These built-in functions are available for the PowerPC family of
15650 processors:
15651 @smallexample
15652 float __builtin_recipdivf (float, float);
15653 float __builtin_rsqrtf (float);
15654 double __builtin_recipdiv (double, double);
15655 double __builtin_rsqrt (double);
15656 uint64_t __builtin_ppc_get_timebase ();
15657 unsigned long __builtin_ppc_mftb ();
15658 double __builtin_unpack_longdouble (long double, int);
15659 long double __builtin_pack_longdouble (double, double);
15660 @end smallexample
15662 The @code{vec_rsqrt}, @code{__builtin_rsqrt}, and
15663 @code{__builtin_rsqrtf} functions generate multiple instructions to
15664 implement the reciprocal sqrt functionality using reciprocal sqrt
15665 estimate instructions.
15667 The @code{__builtin_recipdiv}, and @code{__builtin_recipdivf}
15668 functions generate multiple instructions to implement division using
15669 the reciprocal estimate instructions.
15671 The @code{__builtin_ppc_get_timebase} and @code{__builtin_ppc_mftb}
15672 functions generate instructions to read the Time Base Register.  The
15673 @code{__builtin_ppc_get_timebase} function may generate multiple
15674 instructions and always returns the 64 bits of the Time Base Register.
15675 The @code{__builtin_ppc_mftb} function always generates one instruction and
15676 returns the Time Base Register value as an unsigned long, throwing away
15677 the most significant word on 32-bit environments.
15679 Additional built-in functions are available for the 64-bit PowerPC
15680 family of processors, for efficient use of 128-bit floating point
15681 (@code{__float128}) values.
15683 Previous versions of GCC supported some 'q' builtins for IEEE 128-bit
15684 floating point.  These functions are now mapped into the equivalent
15685 'f128' builtin functions.
15687 @smallexample
15688 __builtin_fabsq is mapped into __builtin_fabsf128
15689 __builtin_copysignq is mapped into __builtin_copysignf128
15690 __builtin_infq is mapped into __builtin_inff128
15691 __builtin_huge_valq is mapped into __builtin_huge_valf128
15692 __builtin_nanq is mapped into __builtin_nanf128
15693 __builtin_nansq is mapped into __builtin_nansf128
15694 @end smallexample
15696 The following built-in functions are available on Linux 64-bit systems
15697 that use the ISA 3.0 instruction set.
15699 @table @code
15700 @item __float128 __builtin_sqrtf128 (__float128)
15701 Perform a 128-bit IEEE floating point square root operation.
15702 @findex __builtin_sqrtf128
15704 @item __float128 __builtin_fmaf128 (__float128, __float128, __float128)
15705 Perform a 128-bit IEEE floating point fused multiply and add operation.
15706 @findex __builtin_fmaf128
15708 @item __float128 __builtin_addf128_round_to_odd (__float128, __float128)
15709 Perform a 128-bit IEEE floating point add using round to odd as the
15710 rounding mode.
15711 @findex __builtin_addf128_round_to_odd
15713 @item __float128 __builtin_subf128_round_to_odd (__float128, __float128)
15714 Perform a 128-bit IEEE floating point subtract using round to odd as
15715 the rounding mode.
15716 @findex __builtin_subf128_round_to_odd
15718 @item __float128 __builtin_mulf128_round_to_odd (__float128, __float128)
15719 Perform a 128-bit IEEE floating point multiply using round to odd as
15720 the rounding mode.
15721 @findex __builtin_mulf128_round_to_odd
15723 @item __float128 __builtin_divf128_round_to_odd (__float128, __float128)
15724 Perform a 128-bit IEEE floating point divide using round to odd as
15725 the rounding mode.
15726 @findex __builtin_divf128_round_to_odd
15728 @item __float128 __builtin_sqrtf128_round_to_odd (__float128)
15729 Perform a 128-bit IEEE floating point square root using round to odd
15730 as the rounding mode.
15731 @findex __builtin_sqrtf128_round_to_odd
15733 @item __float128 __builtin_fmaf128 (__float128, __float128, __float128)
15734 Perform a 128-bit IEEE floating point fused multiply and add operation
15735 using round to odd as the rounding mode.
15736 @findex __builtin_fmaf128_round_to_odd
15738 @item double __builtin_truncf128_round_to_odd (__float128)
15739 Convert a 128-bit IEEE floating point value to @code{double} using
15740 round to odd as the rounding mode.
15741 @findex __builtin_truncf128_round_to_odd
15742 @end table
15744 The following built-in functions are available for the PowerPC family
15745 of processors, starting with ISA 2.05 or later (@option{-mcpu=power6}
15746 or @option{-mcmpb}):
15747 @smallexample
15748 unsigned long long __builtin_cmpb (unsigned long long int, unsigned long long int);
15749 unsigned int __builtin_cmpb (unsigned int, unsigned int);
15750 @end smallexample
15752 The @code{__builtin_cmpb} function
15753 performs a byte-wise compare on the contents of its two arguments,
15754 returning the result of the byte-wise comparison as the returned
15755 value.  For each byte comparison, the corresponding byte of the return
15756 value holds 0xff if the input bytes are equal and 0 if the input bytes
15757 are not equal.  If either of the arguments to this built-in function
15758 is wider than 32 bits, the function call expands into the form that
15759 expects @code{unsigned long long int} arguments
15760 which is only available on 64-bit targets.
15762 The following built-in functions are available for the PowerPC family
15763 of processors, starting with ISA 2.06 or later (@option{-mcpu=power7}
15764 or @option{-mpopcntd}):
15765 @smallexample
15766 long __builtin_bpermd (long, long);
15767 int __builtin_divwe (int, int);
15768 int __builtin_divweo (int, int);
15769 unsigned int __builtin_divweu (unsigned int, unsigned int);
15770 unsigned int __builtin_divweuo (unsigned int, unsigned int);
15771 long __builtin_divde (long, long);
15772 long __builtin_divdeo (long, long);
15773 unsigned long __builtin_divdeu (unsigned long, unsigned long);
15774 unsigned long __builtin_divdeuo (unsigned long, unsigned long);
15775 unsigned int cdtbcd (unsigned int);
15776 unsigned int cbcdtd (unsigned int);
15777 unsigned int addg6s (unsigned int, unsigned int);
15778 void __builtin_rs6000_speculation_barrier (void);
15779 @end smallexample
15781 The @code{__builtin_divde}, @code{__builtin_divdeo},
15782 @code{__builtin_divdeu}, @code{__builtin_divdeou} functions require a
15783 64-bit environment support ISA 2.06 or later.
15785 The following built-in functions are available for the PowerPC family
15786 of processors, starting with ISA 3.0 or later (@option{-mcpu=power9}):
15787 @smallexample
15788 long long __builtin_darn (void);
15789 long long __builtin_darn_raw (void);
15790 int __builtin_darn_32 (void);
15792 unsigned int scalar_extract_exp (double source);
15793 unsigned long long int scalar_extract_exp (__ieee128 source);
15795 unsigned long long int scalar_extract_sig (double source);
15796 unsigned __int128 scalar_extract_sig (__ieee128 source);
15798 double
15799 scalar_insert_exp (unsigned long long int significand, unsigned long long int exponent);
15800 double
15801 scalar_insert_exp (double significand, unsigned long long int exponent);
15803 ieee_128
15804 scalar_insert_exp (unsigned __int128 significand, unsigned long long int exponent);
15805 ieee_128
15806 scalar_insert_exp (ieee_128 significand, unsigned long long int exponent);
15808 int scalar_cmp_exp_gt (double arg1, double arg2);
15809 int scalar_cmp_exp_lt (double arg1, double arg2);
15810 int scalar_cmp_exp_eq (double arg1, double arg2);
15811 int scalar_cmp_exp_unordered (double arg1, double arg2);
15813 bool scalar_test_data_class (float source, const int condition);
15814 bool scalar_test_data_class (double source, const int condition);
15815 bool scalar_test_data_class (__ieee128 source, const int condition);
15817 bool scalar_test_neg (float source);
15818 bool scalar_test_neg (double source);
15819 bool scalar_test_neg (__ieee128 source);
15821 int __builtin_byte_in_set (unsigned char u, unsigned long long set);
15822 int __builtin_byte_in_range (unsigned char u, unsigned int range);
15823 int __builtin_byte_in_either_range (unsigned char u, unsigned int ranges);
15825 int __builtin_dfp_dtstsfi_lt (unsigned int comparison, _Decimal64 value);
15826 int __builtin_dfp_dtstsfi_lt (unsigned int comparison, _Decimal128 value);
15827 int __builtin_dfp_dtstsfi_lt_dd (unsigned int comparison, _Decimal64 value);
15828 int __builtin_dfp_dtstsfi_lt_td (unsigned int comparison, _Decimal128 value);
15830 int __builtin_dfp_dtstsfi_gt (unsigned int comparison, _Decimal64 value);
15831 int __builtin_dfp_dtstsfi_gt (unsigned int comparison, _Decimal128 value);
15832 int __builtin_dfp_dtstsfi_gt_dd (unsigned int comparison, _Decimal64 value);
15833 int __builtin_dfp_dtstsfi_gt_td (unsigned int comparison, _Decimal128 value);
15835 int __builtin_dfp_dtstsfi_eq (unsigned int comparison, _Decimal64 value);
15836 int __builtin_dfp_dtstsfi_eq (unsigned int comparison, _Decimal128 value);
15837 int __builtin_dfp_dtstsfi_eq_dd (unsigned int comparison, _Decimal64 value);
15838 int __builtin_dfp_dtstsfi_eq_td (unsigned int comparison, _Decimal128 value);
15840 int __builtin_dfp_dtstsfi_ov (unsigned int comparison, _Decimal64 value);
15841 int __builtin_dfp_dtstsfi_ov (unsigned int comparison, _Decimal128 value);
15842 int __builtin_dfp_dtstsfi_ov_dd (unsigned int comparison, _Decimal64 value);
15843 int __builtin_dfp_dtstsfi_ov_td (unsigned int comparison, _Decimal128 value);
15844 @end smallexample
15846 The @code{__builtin_darn} and @code{__builtin_darn_raw}
15847 functions require a
15848 64-bit environment supporting ISA 3.0 or later.
15849 The @code{__builtin_darn} function provides a 64-bit conditioned
15850 random number.  The @code{__builtin_darn_raw} function provides a
15851 64-bit raw random number.  The @code{__builtin_darn_32} function
15852 provides a 32-bit random number.
15854 The @code{scalar_extract_exp} and @code{scalar_extract_sig}
15855 functions require a 64-bit environment supporting ISA 3.0 or later.
15856 The @code{scalar_extract_exp} and @code{scalar_extract_sig} built-in
15857 functions return the significand and the biased exponent value
15858 respectively of their @code{source} arguments.
15859 When supplied with a 64-bit @code{source} argument, the
15860 result returned by @code{scalar_extract_sig} has
15861 the @code{0x0010000000000000} bit set if the
15862 function's @code{source} argument is in normalized form.
15863 Otherwise, this bit is set to 0.
15864 When supplied with a 128-bit @code{source} argument, the
15865 @code{0x00010000000000000000000000000000} bit of the result is
15866 treated similarly.
15867 Note that the sign of the significand is not represented in the result
15868 returned from the @code{scalar_extract_sig} function.  Use the
15869 @code{scalar_test_neg} function to test the sign of its @code{double}
15870 argument.
15872 The @code{scalar_insert_exp}
15873 functions require a 64-bit environment supporting ISA 3.0 or later.
15874 When supplied with a 64-bit first argument, the
15875 @code{scalar_insert_exp} built-in function returns a double-precision
15876 floating point value that is constructed by assembling the values of its
15877 @code{significand} and @code{exponent} arguments.  The sign of the
15878 result is copied from the most significant bit of the
15879 @code{significand} argument.  The significand and exponent components
15880 of the result are composed of the least significant 11 bits of the
15881 @code{exponent} argument and the least significant 52 bits of the
15882 @code{significand} argument respectively.
15884 When supplied with a 128-bit first argument, the
15885 @code{scalar_insert_exp} built-in function returns a quad-precision
15886 ieee floating point value.  The sign bit of the result is copied from
15887 the most significant bit of the @code{significand} argument.
15888 The significand and exponent components of the result are composed of
15889 the least significant 15 bits of the @code{exponent} argument and the
15890 least significant 112 bits of the @code{significand} argument respectively.
15892 The @code{scalar_cmp_exp_gt}, @code{scalar_cmp_exp_lt},
15893 @code{scalar_cmp_exp_eq}, and @code{scalar_cmp_exp_unordered} built-in
15894 functions return a non-zero value if @code{arg1} is greater than, less
15895 than, equal to, or not comparable to @code{arg2} respectively.  The
15896 arguments are not comparable if one or the other equals NaN (not a
15897 number). 
15899 The @code{scalar_test_data_class} built-in function returns 1
15900 if any of the condition tests enabled by the value of the
15901 @code{condition} variable are true, and 0 otherwise.  The
15902 @code{condition} argument must be a compile-time constant integer with
15903 value not exceeding 127.  The
15904 @code{condition} argument is encoded as a bitmask with each bit
15905 enabling the testing of a different condition, as characterized by the
15906 following:
15907 @smallexample
15908 0x40    Test for NaN
15909 0x20    Test for +Infinity
15910 0x10    Test for -Infinity
15911 0x08    Test for +Zero
15912 0x04    Test for -Zero
15913 0x02    Test for +Denormal
15914 0x01    Test for -Denormal
15915 @end smallexample
15917 The @code{scalar_test_neg} built-in function returns 1 if its
15918 @code{source} argument holds a negative value, 0 otherwise.
15920 The @code{__builtin_byte_in_set} function requires a
15921 64-bit environment supporting ISA 3.0 or later.  This function returns
15922 a non-zero value if and only if its @code{u} argument exactly equals one of
15923 the eight bytes contained within its 64-bit @code{set} argument.
15925 The @code{__builtin_byte_in_range} and
15926 @code{__builtin_byte_in_either_range} require an environment
15927 supporting ISA 3.0 or later.  For these two functions, the
15928 @code{range} argument is encoded as 4 bytes, organized as
15929 @code{hi_1:lo_1:hi_2:lo_2}.
15930 The @code{__builtin_byte_in_range} function returns a
15931 non-zero value if and only if its @code{u} argument is within the
15932 range bounded between @code{lo_2} and @code{hi_2} inclusive.
15933 The @code{__builtin_byte_in_either_range} function returns non-zero if
15934 and only if its @code{u} argument is within either the range bounded
15935 between @code{lo_1} and @code{hi_1} inclusive or the range bounded
15936 between @code{lo_2} and @code{hi_2} inclusive.
15938 The @code{__builtin_dfp_dtstsfi_lt} function returns a non-zero value
15939 if and only if the number of signficant digits of its @code{value} argument
15940 is less than its @code{comparison} argument.  The
15941 @code{__builtin_dfp_dtstsfi_lt_dd} and
15942 @code{__builtin_dfp_dtstsfi_lt_td} functions behave similarly, but
15943 require that the type of the @code{value} argument be
15944 @code{__Decimal64} and @code{__Decimal128} respectively.
15946 The @code{__builtin_dfp_dtstsfi_gt} function returns a non-zero value
15947 if and only if the number of signficant digits of its @code{value} argument
15948 is greater than its @code{comparison} argument.  The
15949 @code{__builtin_dfp_dtstsfi_gt_dd} and
15950 @code{__builtin_dfp_dtstsfi_gt_td} functions behave similarly, but
15951 require that the type of the @code{value} argument be
15952 @code{__Decimal64} and @code{__Decimal128} respectively.
15954 The @code{__builtin_dfp_dtstsfi_eq} function returns a non-zero value
15955 if and only if the number of signficant digits of its @code{value} argument
15956 equals its @code{comparison} argument.  The
15957 @code{__builtin_dfp_dtstsfi_eq_dd} and
15958 @code{__builtin_dfp_dtstsfi_eq_td} functions behave similarly, but
15959 require that the type of the @code{value} argument be
15960 @code{__Decimal64} and @code{__Decimal128} respectively.
15962 The @code{__builtin_dfp_dtstsfi_ov} function returns a non-zero value
15963 if and only if its @code{value} argument has an undefined number of
15964 significant digits, such as when @code{value} is an encoding of @code{NaN}.
15965 The @code{__builtin_dfp_dtstsfi_ov_dd} and
15966 @code{__builtin_dfp_dtstsfi_ov_td} functions behave similarly, but
15967 require that the type of the @code{value} argument be
15968 @code{__Decimal64} and @code{__Decimal128} respectively.
15970 The following built-in functions are also available for the PowerPC family
15971 of processors, starting with ISA 3.0 or later
15972 (@option{-mcpu=power9}).  These string functions are described
15973 separately in order to group the descriptions closer to the function
15974 prototypes:
15975 @smallexample
15976 int vec_all_nez (vector signed char, vector signed char);
15977 int vec_all_nez (vector unsigned char, vector unsigned char);
15978 int vec_all_nez (vector signed short, vector signed short);
15979 int vec_all_nez (vector unsigned short, vector unsigned short);
15980 int vec_all_nez (vector signed int, vector signed int);
15981 int vec_all_nez (vector unsigned int, vector unsigned int);
15983 int vec_any_eqz (vector signed char, vector signed char);
15984 int vec_any_eqz (vector unsigned char, vector unsigned char);
15985 int vec_any_eqz (vector signed short, vector signed short);
15986 int vec_any_eqz (vector unsigned short, vector unsigned short);
15987 int vec_any_eqz (vector signed int, vector signed int);
15988 int vec_any_eqz (vector unsigned int, vector unsigned int);
15990 vector bool char vec_cmpnez (vector signed char arg1, vector signed char arg2);
15991 vector bool char vec_cmpnez (vector unsigned char arg1, vector unsigned char arg2);
15992 vector bool short vec_cmpnez (vector signed short arg1, vector signed short arg2);
15993 vector bool short vec_cmpnez (vector unsigned short arg1, vector unsigned short arg2);
15994 vector bool int vec_cmpnez (vector signed int arg1, vector signed int arg2);
15995 vector bool int vec_cmpnez (vector unsigned int, vector unsigned int);
15997 vector signed char vec_cnttz (vector signed char);
15998 vector unsigned char vec_cnttz (vector unsigned char);
15999 vector signed short vec_cnttz (vector signed short);
16000 vector unsigned short vec_cnttz (vector unsigned short);
16001 vector signed int vec_cnttz (vector signed int);
16002 vector unsigned int vec_cnttz (vector unsigned int);
16003 vector signed long long vec_cnttz (vector signed long long);
16004 vector unsigned long long vec_cnttz (vector unsigned long long);
16006 signed int vec_cntlz_lsbb (vector signed char);
16007 signed int vec_cntlz_lsbb (vector unsigned char);
16009 signed int vec_cnttz_lsbb (vector signed char);
16010 signed int vec_cnttz_lsbb (vector unsigned char);
16012 unsigned int vec_first_match_index (vector signed char, vector signed char);
16013 unsigned int vec_first_match_index (vector unsigned char,
16014                                     vector unsigned char);
16015 unsigned int vec_first_match_index (vector signed int, vector signed int);
16016 unsigned int vec_first_match_index (vector unsigned int, vector unsigned int);
16017 unsigned int vec_first_match_index (vector signed short, vector signed short);
16018 unsigned int vec_first_match_index (vector unsigned short,
16019                                     vector unsigned short);
16020 unsigned int vec_first_match_or_eos_index (vector signed char,
16021                                            vector signed char);
16022 unsigned int vec_first_match_or_eos_index (vector unsigned char,
16023                                            vector unsigned char);
16024 unsigned int vec_first_match_or_eos_index (vector signed int,
16025                                            vector signed int);
16026 unsigned int vec_first_match_or_eos_index (vector unsigned int,
16027                                            vector unsigned int);
16028 unsigned int vec_first_match_or_eos_index (vector signed short,
16029                                            vector signed short);
16030 unsigned int vec_first_match_or_eos_index (vector unsigned short,
16031                                            vector unsigned short);
16032 unsigned int vec_first_mismatch_index (vector signed char,
16033                                        vector signed char);
16034 unsigned int vec_first_mismatch_index (vector unsigned char,
16035                                        vector unsigned char);
16036 unsigned int vec_first_mismatch_index (vector signed int,
16037                                        vector signed int);
16038 unsigned int vec_first_mismatch_index (vector unsigned int,
16039                                        vector unsigned int);
16040 unsigned int vec_first_mismatch_index (vector signed short,
16041                                        vector signed short);
16042 unsigned int vec_first_mismatch_index (vector unsigned short,
16043                                        vector unsigned short);
16044 unsigned int vec_first_mismatch_or_eos_index (vector signed char,
16045                                               vector signed char);
16046 unsigned int vec_first_mismatch_or_eos_index (vector unsigned char,
16047                                               vector unsigned char);
16048 unsigned int vec_first_mismatch_or_eos_index (vector signed int,
16049                                               vector signed int);
16050 unsigned int vec_first_mismatch_or_eos_index (vector unsigned int,
16051                                               vector unsigned int);
16052 unsigned int vec_first_mismatch_or_eos_index (vector signed short,
16053                                               vector signed short);
16054 unsigned int vec_first_mismatch_or_eos_index (vector unsigned short,
16055                                               vector unsigned short);
16057 vector unsigned short vec_pack_to_short_fp32 (vector float, vector float);
16059 vector signed char vec_xl_be (signed long long, signed char *);
16060 vector unsigned char vec_xl_be (signed long long, unsigned char *);
16061 vector signed int vec_xl_be (signed long long, signed int *);
16062 vector unsigned int vec_xl_be (signed long long, unsigned int *);
16063 vector signed __int128 vec_xl_be (signed long long, signed __int128 *);
16064 vector unsigned __int128 vec_xl_be (signed long long, unsigned __int128 *);
16065 vector signed long long vec_xl_be (signed long long, signed long long *);
16066 vector unsigned long long vec_xl_be (signed long long, unsigned long long *);
16067 vector signed short vec_xl_be (signed long long, signed short *);
16068 vector unsigned short vec_xl_be (signed long long, unsigned short *);
16069 vector double vec_xl_be (signed long long, double *);
16070 vector float vec_xl_be (signed long long, float *);
16072 vector signed char vec_xl_len (signed char *addr, size_t len);
16073 vector unsigned char vec_xl_len (unsigned char *addr, size_t len);
16074 vector signed int vec_xl_len (signed int *addr, size_t len);
16075 vector unsigned int vec_xl_len (unsigned int *addr, size_t len);
16076 vector signed __int128 vec_xl_len (signed __int128 *addr, size_t len);
16077 vector unsigned __int128 vec_xl_len (unsigned __int128 *addr, size_t len);
16078 vector signed long long vec_xl_len (signed long long *addr, size_t len);
16079 vector unsigned long long vec_xl_len (unsigned long long *addr, size_t len);
16080 vector signed short vec_xl_len (signed short *addr, size_t len);
16081 vector unsigned short vec_xl_len (unsigned short *addr, size_t len);
16082 vector double vec_xl_len (double *addr, size_t len);
16083 vector float vec_xl_len (float *addr, size_t len);
16085 vector unsigned char vec_xl_len_r (unsigned char *addr, size_t len);
16087 void vec_xst_len (vector signed char data, signed char *addr, size_t len);
16088 void vec_xst_len (vector unsigned char data, unsigned char *addr, size_t len);
16089 void vec_xst_len (vector signed int data, signed int *addr, size_t len);
16090 void vec_xst_len (vector unsigned int data, unsigned int *addr, size_t len);
16091 void vec_xst_len (vector unsigned __int128 data, unsigned __int128 *addr, size_t len);
16092 void vec_xst_len (vector signed long long data, signed long long *addr, size_t len);
16093 void vec_xst_len (vector unsigned long long data, unsigned long long *addr, size_t len);
16094 void vec_xst_len (vector signed short data, signed short *addr, size_t len);
16095 void vec_xst_len (vector unsigned short data, unsigned short *addr, size_t len);
16096 void vec_xst_len (vector signed __int128 data, signed __int128 *addr, size_t len);
16097 void vec_xst_len (vector double data, double *addr, size_t len);
16098 void vec_xst_len (vector float data, float *addr, size_t len);
16100 void vec_xst_len_r (vector unsigned char data, unsigned char *addr, size_t len);
16102 signed char vec_xlx (unsigned int index, vector signed char data);
16103 unsigned char vec_xlx (unsigned int index, vector unsigned char data);
16104 signed short vec_xlx (unsigned int index, vector signed short data);
16105 unsigned short vec_xlx (unsigned int index, vector unsigned short data);
16106 signed int vec_xlx (unsigned int index, vector signed int data);
16107 unsigned int vec_xlx (unsigned int index, vector unsigned int data);
16108 float vec_xlx (unsigned int index, vector float data);
16110 signed char vec_xrx (unsigned int index, vector signed char data);
16111 unsigned char vec_xrx (unsigned int index, vector unsigned char data);
16112 signed short vec_xrx (unsigned int index, vector signed short data);
16113 unsigned short vec_xrx (unsigned int index, vector unsigned short data);
16114 signed int vec_xrx (unsigned int index, vector signed int data);
16115 unsigned int vec_xrx (unsigned int index, vector unsigned int data);
16116 float vec_xrx (unsigned int index, vector float data);
16117 @end smallexample
16119 The @code{vec_all_nez}, @code{vec_any_eqz}, and @code{vec_cmpnez}
16120 perform pairwise comparisons between the elements at the same
16121 positions within their two vector arguments.
16122 The @code{vec_all_nez} function returns a
16123 non-zero value if and only if all pairwise comparisons are not
16124 equal and no element of either vector argument contains a zero.
16125 The @code{vec_any_eqz} function returns a
16126 non-zero value if and only if at least one pairwise comparison is equal
16127 or if at least one element of either vector argument contains a zero.
16128 The @code{vec_cmpnez} function returns a vector of the same type as
16129 its two arguments, within which each element consists of all ones to
16130 denote that either the corresponding elements of the incoming arguments are
16131 not equal or that at least one of the corresponding elements contains
16132 zero.  Otherwise, the element of the returned vector contains all zeros.
16134 The @code{vec_cntlz_lsbb} function returns the count of the number of
16135 consecutive leading byte elements (starting from position 0 within the
16136 supplied vector argument) for which the least-significant bit
16137 equals zero.  The @code{vec_cnttz_lsbb} function returns the count of
16138 the number of consecutive trailing byte elements (starting from
16139 position 15 and counting backwards within the supplied vector
16140 argument) for which the least-significant bit equals zero.
16142 The @code{vec_xl_len} and @code{vec_xst_len} functions require a
16143 64-bit environment supporting ISA 3.0 or later.  The @code{vec_xl_len}
16144 function loads a variable length vector from memory.  The
16145 @code{vec_xst_len} function stores a variable length vector to memory.
16146 With both the @code{vec_xl_len} and @code{vec_xst_len} functions, the
16147 @code{addr} argument represents the memory address to or from which
16148 data will be transferred, and the
16149 @code{len} argument represents the number of bytes to be
16150 transferred, as computed by the C expression @code{min((len & 0xff), 16)}.
16151 If this expression's value is not a multiple of the vector element's
16152 size, the behavior of this function is undefined.
16153 In the case that the underlying computer is configured to run in
16154 big-endian mode, the data transfer moves bytes 0 to @code{(len - 1)} of
16155 the corresponding vector.  In little-endian mode, the data transfer
16156 moves bytes @code{(16 - len)} to @code{15} of the corresponding
16157 vector.  For the load function, any bytes of the result vector that
16158 are not loaded from memory are set to zero.
16159 The value of the @code{addr} argument need not be aligned on a
16160 multiple of the vector's element size.
16162 The @code{vec_xlx} and @code{vec_xrx} functions extract the single
16163 element selected by the @code{index} argument from the vector
16164 represented by the @code{data} argument.  The @code{index} argument
16165 always specifies a byte offset, regardless of the size of the vector
16166 element.  With @code{vec_xlx}, @code{index} is the offset of the first
16167 byte of the element to be extracted.  With @code{vec_xrx}, @code{index}
16168 represents the last byte of the element to be extracted, measured
16169 from the right end of the vector.  In other words, the last byte of
16170 the element to be extracted is found at position @code{(15 - index)}.
16171 There is no requirement that @code{index} be a multiple of the vector
16172 element size.  However, if the size of the vector element added to
16173 @code{index} is greater than 15, the content of the returned value is
16174 undefined.
16176 The following built-in functions are available for the PowerPC family
16177 of processors when hardware decimal floating point
16178 (@option{-mhard-dfp}) is available:
16179 @smallexample
16180 long long __builtin_dxex (_Decimal64);
16181 long long __builtin_dxexq (_Decimal128);
16182 _Decimal64 __builtin_ddedpd (int, _Decimal64);
16183 _Decimal128 __builtin_ddedpdq (int, _Decimal128);
16184 _Decimal64 __builtin_denbcd (int, _Decimal64);
16185 _Decimal128 __builtin_denbcdq (int, _Decimal128);
16186 _Decimal64 __builtin_diex (long long, _Decimal64);
16187 _Decimal128 _builtin_diexq (long long, _Decimal128);
16188 _Decimal64 __builtin_dscli (_Decimal64, int);
16189 _Decimal128 __builtin_dscliq (_Decimal128, int);
16190 _Decimal64 __builtin_dscri (_Decimal64, int);
16191 _Decimal128 __builtin_dscriq (_Decimal128, int);
16192 unsigned long long __builtin_unpack_dec128 (_Decimal128, int);
16193 _Decimal128 __builtin_pack_dec128 (unsigned long long, unsigned long long);
16194 @end smallexample
16196 The following built-in functions are available for the PowerPC family
16197 of processors when the Vector Scalar (vsx) instruction set is
16198 available:
16199 @smallexample
16200 unsigned long long __builtin_unpack_vector_int128 (vector __int128_t, int);
16201 vector __int128_t __builtin_pack_vector_int128 (unsigned long long,
16202                                                 unsigned long long);
16203 @end smallexample
16205 @node PowerPC AltiVec/VSX Built-in Functions
16206 @subsection PowerPC AltiVec Built-in Functions
16208 GCC provides an interface for the PowerPC family of processors to access
16209 the AltiVec operations described in Motorola's AltiVec Programming
16210 Interface Manual.  The interface is made available by including
16211 @code{<altivec.h>} and using @option{-maltivec} and
16212 @option{-mabi=altivec}.  The interface supports the following vector
16213 types.
16215 @smallexample
16216 vector unsigned char
16217 vector signed char
16218 vector bool char
16220 vector unsigned short
16221 vector signed short
16222 vector bool short
16223 vector pixel
16225 vector unsigned int
16226 vector signed int
16227 vector bool int
16228 vector float
16229 @end smallexample
16231 If @option{-mvsx} is used the following additional vector types are
16232 implemented.
16234 @smallexample
16235 vector unsigned long
16236 vector signed long
16237 vector double
16238 @end smallexample
16240 The long types are only implemented for 64-bit code generation, and
16241 the long type is only used in the floating point/integer conversion
16242 instructions.
16244 GCC's implementation of the high-level language interface available from
16245 C and C++ code differs from Motorola's documentation in several ways.
16247 @itemize @bullet
16249 @item
16250 A vector constant is a list of constant expressions within curly braces.
16252 @item
16253 A vector initializer requires no cast if the vector constant is of the
16254 same type as the variable it is initializing.
16256 @item
16257 If @code{signed} or @code{unsigned} is omitted, the signedness of the
16258 vector type is the default signedness of the base type.  The default
16259 varies depending on the operating system, so a portable program should
16260 always specify the signedness.
16262 @item
16263 Compiling with @option{-maltivec} adds keywords @code{__vector},
16264 @code{vector}, @code{__pixel}, @code{pixel}, @code{__bool} and
16265 @code{bool}.  When compiling ISO C, the context-sensitive substitution
16266 of the keywords @code{vector}, @code{pixel} and @code{bool} is
16267 disabled.  To use them, you must include @code{<altivec.h>} instead.
16269 @item
16270 GCC allows using a @code{typedef} name as the type specifier for a
16271 vector type.
16273 @item
16274 For C, overloaded functions are implemented with macros so the following
16275 does not work:
16277 @smallexample
16278   vec_add ((vector signed int)@{1, 2, 3, 4@}, foo);
16279 @end smallexample
16281 @noindent
16282 Since @code{vec_add} is a macro, the vector constant in the example
16283 is treated as four separate arguments.  Wrap the entire argument in
16284 parentheses for this to work.
16285 @end itemize
16287 @emph{Note:} Only the @code{<altivec.h>} interface is supported.
16288 Internally, GCC uses built-in functions to achieve the functionality in
16289 the aforementioned header file, but they are not supported and are
16290 subject to change without notice.
16292 GCC complies with the OpenPOWER 64-Bit ELF V2 ABI Specification,
16293 which may be found at
16294 @uref{http://openpowerfoundation.org/wp-content/uploads/resources/leabi-prd/content/index.html}.
16295 Appendix A of this document lists the vector API interfaces that must be
16296 provided by compliant compilers.  Programmers should preferentially use
16297 the interfaces described therein.  However, historically GCC has provided
16298 additional interfaces for access to vector instructions.  These are
16299 briefly described below.
16301 The following interfaces are supported for the generic and specific
16302 AltiVec operations and the AltiVec predicates.  In cases where there
16303 is a direct mapping between generic and specific operations, only the
16304 generic names are shown here, although the specific operations can also
16305 be used.
16307 Arguments that are documented as @code{const int} require literal
16308 integral values within the range required for that operation.
16310 @smallexample
16311 vector signed char vec_abs (vector signed char);
16312 vector signed short vec_abs (vector signed short);
16313 vector signed int vec_abs (vector signed int);
16314 vector float vec_abs (vector float);
16316 vector signed char vec_abss (vector signed char);
16317 vector signed short vec_abss (vector signed short);
16318 vector signed int vec_abss (vector signed int);
16320 vector signed char vec_add (vector bool char, vector signed char);
16321 vector signed char vec_add (vector signed char, vector bool char);
16322 vector signed char vec_add (vector signed char, vector signed char);
16323 vector unsigned char vec_add (vector bool char, vector unsigned char);
16324 vector unsigned char vec_add (vector unsigned char, vector bool char);
16325 vector unsigned char vec_add (vector unsigned char,
16326                               vector unsigned char);
16327 vector signed short vec_add (vector bool short, vector signed short);
16328 vector signed short vec_add (vector signed short, vector bool short);
16329 vector signed short vec_add (vector signed short, vector signed short);
16330 vector unsigned short vec_add (vector bool short,
16331                                vector unsigned short);
16332 vector unsigned short vec_add (vector unsigned short,
16333                                vector bool short);
16334 vector unsigned short vec_add (vector unsigned short,
16335                                vector unsigned short);
16336 vector signed int vec_add (vector bool int, vector signed int);
16337 vector signed int vec_add (vector signed int, vector bool int);
16338 vector signed int vec_add (vector signed int, vector signed int);
16339 vector unsigned int vec_add (vector bool int, vector unsigned int);
16340 vector unsigned int vec_add (vector unsigned int, vector bool int);
16341 vector unsigned int vec_add (vector unsigned int, vector unsigned int);
16342 vector float vec_add (vector float, vector float);
16344 vector float vec_vaddfp (vector float, vector float);
16346 vector signed int vec_vadduwm (vector bool int, vector signed int);
16347 vector signed int vec_vadduwm (vector signed int, vector bool int);
16348 vector signed int vec_vadduwm (vector signed int, vector signed int);
16349 vector unsigned int vec_vadduwm (vector bool int, vector unsigned int);
16350 vector unsigned int vec_vadduwm (vector unsigned int, vector bool int);
16351 vector unsigned int vec_vadduwm (vector unsigned int,
16352                                  vector unsigned int);
16354 vector signed short vec_vadduhm (vector bool short,
16355                                  vector signed short);
16356 vector signed short vec_vadduhm (vector signed short,
16357                                  vector bool short);
16358 vector signed short vec_vadduhm (vector signed short,
16359                                  vector signed short);
16360 vector unsigned short vec_vadduhm (vector bool short,
16361                                    vector unsigned short);
16362 vector unsigned short vec_vadduhm (vector unsigned short,
16363                                    vector bool short);
16364 vector unsigned short vec_vadduhm (vector unsigned short,
16365                                    vector unsigned short);
16367 vector signed char vec_vaddubm (vector bool char, vector signed char);
16368 vector signed char vec_vaddubm (vector signed char, vector bool char);
16369 vector signed char vec_vaddubm (vector signed char, vector signed char);
16370 vector unsigned char vec_vaddubm (vector bool char,
16371                                   vector unsigned char);
16372 vector unsigned char vec_vaddubm (vector unsigned char,
16373                                   vector bool char);
16374 vector unsigned char vec_vaddubm (vector unsigned char,
16375                                   vector unsigned char);
16377 vector unsigned int vec_addc (vector unsigned int, vector unsigned int);
16379 vector unsigned char vec_adds (vector bool char, vector unsigned char);
16380 vector unsigned char vec_adds (vector unsigned char, vector bool char);
16381 vector unsigned char vec_adds (vector unsigned char,
16382                                vector unsigned char);
16383 vector signed char vec_adds (vector bool char, vector signed char);
16384 vector signed char vec_adds (vector signed char, vector bool char);
16385 vector signed char vec_adds (vector signed char, vector signed char);
16386 vector unsigned short vec_adds (vector bool short,
16387                                 vector unsigned short);
16388 vector unsigned short vec_adds (vector unsigned short,
16389                                 vector bool short);
16390 vector unsigned short vec_adds (vector unsigned short,
16391                                 vector unsigned short);
16392 vector signed short vec_adds (vector bool short, vector signed short);
16393 vector signed short vec_adds (vector signed short, vector bool short);
16394 vector signed short vec_adds (vector signed short, vector signed short);
16395 vector unsigned int vec_adds (vector bool int, vector unsigned int);
16396 vector unsigned int vec_adds (vector unsigned int, vector bool int);
16397 vector unsigned int vec_adds (vector unsigned int, vector unsigned int);
16398 vector signed int vec_adds (vector bool int, vector signed int);
16399 vector signed int vec_adds (vector signed int, vector bool int);
16400 vector signed int vec_adds (vector signed int, vector signed int);
16402 vector signed int vec_vaddsws (vector bool int, vector signed int);
16403 vector signed int vec_vaddsws (vector signed int, vector bool int);
16404 vector signed int vec_vaddsws (vector signed int, vector signed int);
16406 vector unsigned int vec_vadduws (vector bool int, vector unsigned int);
16407 vector unsigned int vec_vadduws (vector unsigned int, vector bool int);
16408 vector unsigned int vec_vadduws (vector unsigned int,
16409                                  vector unsigned int);
16411 vector signed short vec_vaddshs (vector bool short,
16412                                  vector signed short);
16413 vector signed short vec_vaddshs (vector signed short,
16414                                  vector bool short);
16415 vector signed short vec_vaddshs (vector signed short,
16416                                  vector signed short);
16418 vector unsigned short vec_vadduhs (vector bool short,
16419                                    vector unsigned short);
16420 vector unsigned short vec_vadduhs (vector unsigned short,
16421                                    vector bool short);
16422 vector unsigned short vec_vadduhs (vector unsigned short,
16423                                    vector unsigned short);
16425 vector signed char vec_vaddsbs (vector bool char, vector signed char);
16426 vector signed char vec_vaddsbs (vector signed char, vector bool char);
16427 vector signed char vec_vaddsbs (vector signed char, vector signed char);
16429 vector unsigned char vec_vaddubs (vector bool char,
16430                                   vector unsigned char);
16431 vector unsigned char vec_vaddubs (vector unsigned char,
16432                                   vector bool char);
16433 vector unsigned char vec_vaddubs (vector unsigned char,
16434                                   vector unsigned char);
16436 vector float vec_and (vector float, vector float);
16437 vector float vec_and (vector float, vector bool int);
16438 vector float vec_and (vector bool int, vector float);
16439 vector bool long long vec_and (vector bool long long int,
16440                                vector bool long long);
16441 vector bool int vec_and (vector bool int, vector bool int);
16442 vector signed int vec_and (vector bool int, vector signed int);
16443 vector signed int vec_and (vector signed int, vector bool int);
16444 vector signed int vec_and (vector signed int, vector signed int);
16445 vector unsigned int vec_and (vector bool int, vector unsigned int);
16446 vector unsigned int vec_and (vector unsigned int, vector bool int);
16447 vector unsigned int vec_and (vector unsigned int, vector unsigned int);
16448 vector bool short vec_and (vector bool short, vector bool short);
16449 vector signed short vec_and (vector bool short, vector signed short);
16450 vector signed short vec_and (vector signed short, vector bool short);
16451 vector signed short vec_and (vector signed short, vector signed short);
16452 vector unsigned short vec_and (vector bool short,
16453                                vector unsigned short);
16454 vector unsigned short vec_and (vector unsigned short,
16455                                vector bool short);
16456 vector unsigned short vec_and (vector unsigned short,
16457                                vector unsigned short);
16458 vector signed char vec_and (vector bool char, vector signed char);
16459 vector bool char vec_and (vector bool char, vector bool char);
16460 vector signed char vec_and (vector signed char, vector bool char);
16461 vector signed char vec_and (vector signed char, vector signed char);
16462 vector unsigned char vec_and (vector bool char, vector unsigned char);
16463 vector unsigned char vec_and (vector unsigned char, vector bool char);
16464 vector unsigned char vec_and (vector unsigned char,
16465                               vector unsigned char);
16467 vector float vec_andc (vector float, vector float);
16468 vector float vec_andc (vector float, vector bool int);
16469 vector float vec_andc (vector bool int, vector float);
16470 vector bool int vec_andc (vector bool int, vector bool int);
16471 vector signed int vec_andc (vector bool int, vector signed int);
16472 vector signed int vec_andc (vector signed int, vector bool int);
16473 vector signed int vec_andc (vector signed int, vector signed int);
16474 vector unsigned int vec_andc (vector bool int, vector unsigned int);
16475 vector unsigned int vec_andc (vector unsigned int, vector bool int);
16476 vector unsigned int vec_andc (vector unsigned int, vector unsigned int);
16477 vector bool short vec_andc (vector bool short, vector bool short);
16478 vector signed short vec_andc (vector bool short, vector signed short);
16479 vector signed short vec_andc (vector signed short, vector bool short);
16480 vector signed short vec_andc (vector signed short, vector signed short);
16481 vector unsigned short vec_andc (vector bool short,
16482                                 vector unsigned short);
16483 vector unsigned short vec_andc (vector unsigned short,
16484                                 vector bool short);
16485 vector unsigned short vec_andc (vector unsigned short,
16486                                 vector unsigned short);
16487 vector signed char vec_andc (vector bool char, vector signed char);
16488 vector bool char vec_andc (vector bool char, vector bool char);
16489 vector signed char vec_andc (vector signed char, vector bool char);
16490 vector signed char vec_andc (vector signed char, vector signed char);
16491 vector unsigned char vec_andc (vector bool char, vector unsigned char);
16492 vector unsigned char vec_andc (vector unsigned char, vector bool char);
16493 vector unsigned char vec_andc (vector unsigned char,
16494                                vector unsigned char);
16496 vector unsigned char vec_avg (vector unsigned char,
16497                               vector unsigned char);
16498 vector signed char vec_avg (vector signed char, vector signed char);
16499 vector unsigned short vec_avg (vector unsigned short,
16500                                vector unsigned short);
16501 vector signed short vec_avg (vector signed short, vector signed short);
16502 vector unsigned int vec_avg (vector unsigned int, vector unsigned int);
16503 vector signed int vec_avg (vector signed int, vector signed int);
16505 vector signed int vec_vavgsw (vector signed int, vector signed int);
16507 vector unsigned int vec_vavguw (vector unsigned int,
16508                                 vector unsigned int);
16510 vector signed short vec_vavgsh (vector signed short,
16511                                 vector signed short);
16513 vector unsigned short vec_vavguh (vector unsigned short,
16514                                   vector unsigned short);
16516 vector signed char vec_vavgsb (vector signed char, vector signed char);
16518 vector unsigned char vec_vavgub (vector unsigned char,
16519                                  vector unsigned char);
16521 vector float vec_copysign (vector float);
16523 vector float vec_ceil (vector float);
16525 vector signed int vec_cmpb (vector float, vector float);
16527 vector bool char vec_cmpeq (vector bool char, vector bool char);
16528 vector bool short vec_cmpeq (vector bool short, vector bool short);
16529 vector bool int vec_cmpeq (vector bool int, vector bool int);
16530 vector bool char vec_cmpeq (vector signed char, vector signed char);
16531 vector bool char vec_cmpeq (vector unsigned char, vector unsigned char);
16532 vector bool short vec_cmpeq (vector signed short, vector signed short);
16533 vector bool short vec_cmpeq (vector unsigned short,
16534                              vector unsigned short);
16535 vector bool int vec_cmpeq (vector signed int, vector signed int);
16536 vector bool int vec_cmpeq (vector unsigned int, vector unsigned int);
16537 vector bool int vec_cmpeq (vector float, vector float);
16539 vector bool int vec_vcmpeqfp (vector float, vector float);
16541 vector bool int vec_vcmpequw (vector signed int, vector signed int);
16542 vector bool int vec_vcmpequw (vector unsigned int, vector unsigned int);
16544 vector bool short vec_vcmpequh (vector signed short,
16545                                 vector signed short);
16546 vector bool short vec_vcmpequh (vector unsigned short,
16547                                 vector unsigned short);
16549 vector bool char vec_vcmpequb (vector signed char, vector signed char);
16550 vector bool char vec_vcmpequb (vector unsigned char,
16551                                vector unsigned char);
16553 vector bool int vec_cmpge (vector float, vector float);
16555 vector bool char vec_cmpgt (vector unsigned char, vector unsigned char);
16556 vector bool char vec_cmpgt (vector signed char, vector signed char);
16557 vector bool short vec_cmpgt (vector unsigned short,
16558                              vector unsigned short);
16559 vector bool short vec_cmpgt (vector signed short, vector signed short);
16560 vector bool int vec_cmpgt (vector unsigned int, vector unsigned int);
16561 vector bool int vec_cmpgt (vector signed int, vector signed int);
16562 vector bool int vec_cmpgt (vector float, vector float);
16564 vector bool int vec_vcmpgtfp (vector float, vector float);
16566 vector bool int vec_vcmpgtsw (vector signed int, vector signed int);
16568 vector bool int vec_vcmpgtuw (vector unsigned int, vector unsigned int);
16570 vector bool short vec_vcmpgtsh (vector signed short,
16571                                 vector signed short);
16573 vector bool short vec_vcmpgtuh (vector unsigned short,
16574                                 vector unsigned short);
16576 vector bool char vec_vcmpgtsb (vector signed char, vector signed char);
16578 vector bool char vec_vcmpgtub (vector unsigned char,
16579                                vector unsigned char);
16581 vector bool int vec_cmple (vector float, vector float);
16583 vector bool char vec_cmplt (vector unsigned char, vector unsigned char);
16584 vector bool char vec_cmplt (vector signed char, vector signed char);
16585 vector bool short vec_cmplt (vector unsigned short,
16586                              vector unsigned short);
16587 vector bool short vec_cmplt (vector signed short, vector signed short);
16588 vector bool int vec_cmplt (vector unsigned int, vector unsigned int);
16589 vector bool int vec_cmplt (vector signed int, vector signed int);
16590 vector bool int vec_cmplt (vector float, vector float);
16592 vector float vec_cpsgn (vector float, vector float);
16594 vector float vec_ctf (vector unsigned int, const int);
16595 vector float vec_ctf (vector signed int, const int);
16596 vector double vec_ctf (vector unsigned long, const int);
16597 vector double vec_ctf (vector signed long, const int);
16599 vector float vec_vcfsx (vector signed int, const int);
16601 vector float vec_vcfux (vector unsigned int, const int);
16603 vector signed int vec_cts (vector float, const int);
16604 vector signed long vec_cts (vector double, const int);
16606 vector unsigned int vec_ctu (vector float, const int);
16607 vector unsigned long vec_ctu (vector double, const int);
16609 vector double vec_doublee (vector float);
16610 vector double vec_doublee (vector signed int);
16611 vector double vec_doublee (vector unsigned int);
16613 vector double vec_doubleo (vector float);
16614 vector double vec_doubleo (vector signed int);
16615 vector double vec_doubleo (vector unsigned int);
16617 vector double vec_doubleh (vector float);
16618 vector double vec_doubleh (vector signed int);
16619 vector double vec_doubleh (vector unsigned int);
16621 vector double vec_doublel (vector float);
16622 vector double vec_doublel (vector signed int);
16623 vector double vec_doublel (vector unsigned int);
16625 void vec_dss (const int);
16627 void vec_dssall (void);
16629 void vec_dst (const vector unsigned char *, int, const int);
16630 void vec_dst (const vector signed char *, int, const int);
16631 void vec_dst (const vector bool char *, int, const int);
16632 void vec_dst (const vector unsigned short *, int, const int);
16633 void vec_dst (const vector signed short *, int, const int);
16634 void vec_dst (const vector bool short *, int, const int);
16635 void vec_dst (const vector pixel *, int, const int);
16636 void vec_dst (const vector unsigned int *, int, const int);
16637 void vec_dst (const vector signed int *, int, const int);
16638 void vec_dst (const vector bool int *, int, const int);
16639 void vec_dst (const vector float *, int, const int);
16640 void vec_dst (const unsigned char *, int, const int);
16641 void vec_dst (const signed char *, int, const int);
16642 void vec_dst (const unsigned short *, int, const int);
16643 void vec_dst (const short *, int, const int);
16644 void vec_dst (const unsigned int *, int, const int);
16645 void vec_dst (const int *, int, const int);
16646 void vec_dst (const unsigned long *, int, const int);
16647 void vec_dst (const long *, int, const int);
16648 void vec_dst (const float *, int, const int);
16650 void vec_dstst (const vector unsigned char *, int, const int);
16651 void vec_dstst (const vector signed char *, int, const int);
16652 void vec_dstst (const vector bool char *, int, const int);
16653 void vec_dstst (const vector unsigned short *, int, const int);
16654 void vec_dstst (const vector signed short *, int, const int);
16655 void vec_dstst (const vector bool short *, int, const int);
16656 void vec_dstst (const vector pixel *, int, const int);
16657 void vec_dstst (const vector unsigned int *, int, const int);
16658 void vec_dstst (const vector signed int *, int, const int);
16659 void vec_dstst (const vector bool int *, int, const int);
16660 void vec_dstst (const vector float *, int, const int);
16661 void vec_dstst (const unsigned char *, int, const int);
16662 void vec_dstst (const signed char *, int, const int);
16663 void vec_dstst (const unsigned short *, int, const int);
16664 void vec_dstst (const short *, int, const int);
16665 void vec_dstst (const unsigned int *, int, const int);
16666 void vec_dstst (const int *, int, const int);
16667 void vec_dstst (const unsigned long *, int, const int);
16668 void vec_dstst (const long *, int, const int);
16669 void vec_dstst (const float *, int, const int);
16671 void vec_dststt (const vector unsigned char *, int, const int);
16672 void vec_dststt (const vector signed char *, int, const int);
16673 void vec_dststt (const vector bool char *, int, const int);
16674 void vec_dststt (const vector unsigned short *, int, const int);
16675 void vec_dststt (const vector signed short *, int, const int);
16676 void vec_dststt (const vector bool short *, int, const int);
16677 void vec_dststt (const vector pixel *, int, const int);
16678 void vec_dststt (const vector unsigned int *, int, const int);
16679 void vec_dststt (const vector signed int *, int, const int);
16680 void vec_dststt (const vector bool int *, int, const int);
16681 void vec_dststt (const vector float *, int, const int);
16682 void vec_dststt (const unsigned char *, int, const int);
16683 void vec_dststt (const signed char *, int, const int);
16684 void vec_dststt (const unsigned short *, int, const int);
16685 void vec_dststt (const short *, int, const int);
16686 void vec_dststt (const unsigned int *, int, const int);
16687 void vec_dststt (const int *, int, const int);
16688 void vec_dststt (const unsigned long *, int, const int);
16689 void vec_dststt (const long *, int, const int);
16690 void vec_dststt (const float *, int, const int);
16692 void vec_dstt (const vector unsigned char *, int, const int);
16693 void vec_dstt (const vector signed char *, int, const int);
16694 void vec_dstt (const vector bool char *, int, const int);
16695 void vec_dstt (const vector unsigned short *, int, const int);
16696 void vec_dstt (const vector signed short *, int, const int);
16697 void vec_dstt (const vector bool short *, int, const int);
16698 void vec_dstt (const vector pixel *, int, const int);
16699 void vec_dstt (const vector unsigned int *, int, const int);
16700 void vec_dstt (const vector signed int *, int, const int);
16701 void vec_dstt (const vector bool int *, int, const int);
16702 void vec_dstt (const vector float *, int, const int);
16703 void vec_dstt (const unsigned char *, int, const int);
16704 void vec_dstt (const signed char *, int, const int);
16705 void vec_dstt (const unsigned short *, int, const int);
16706 void vec_dstt (const short *, int, const int);
16707 void vec_dstt (const unsigned int *, int, const int);
16708 void vec_dstt (const int *, int, const int);
16709 void vec_dstt (const unsigned long *, int, const int);
16710 void vec_dstt (const long *, int, const int);
16711 void vec_dstt (const float *, int, const int);
16713 vector float vec_expte (vector float);
16715 vector float vec_floor (vector float);
16717 vector float vec_float (vector signed int);
16718 vector float vec_float (vector unsigned int);
16720 vector float vec_float2 (vector signed long long, vector signed long long);
16721 vector float vec_float2 (vector unsigned long long, vector signed long long);
16723 vector float vec_floate (vector double);
16724 vector float vec_floate (vector signed long long);
16725 vector float vec_floate (vector unsigned long long);
16727 vector float vec_floato (vector double);
16728 vector float vec_floato (vector signed long long);
16729 vector float vec_floato (vector unsigned long long);
16731 vector float vec_ld (int, const vector float *);
16732 vector float vec_ld (int, const float *);
16733 vector bool int vec_ld (int, const vector bool int *);
16734 vector signed int vec_ld (int, const vector signed int *);
16735 vector signed int vec_ld (int, const int *);
16736 vector signed int vec_ld (int, const long *);
16737 vector unsigned int vec_ld (int, const vector unsigned int *);
16738 vector unsigned int vec_ld (int, const unsigned int *);
16739 vector unsigned int vec_ld (int, const unsigned long *);
16740 vector bool short vec_ld (int, const vector bool short *);
16741 vector pixel vec_ld (int, const vector pixel *);
16742 vector signed short vec_ld (int, const vector signed short *);
16743 vector signed short vec_ld (int, const short *);
16744 vector unsigned short vec_ld (int, const vector unsigned short *);
16745 vector unsigned short vec_ld (int, const unsigned short *);
16746 vector bool char vec_ld (int, const vector bool char *);
16747 vector signed char vec_ld (int, const vector signed char *);
16748 vector signed char vec_ld (int, const signed char *);
16749 vector unsigned char vec_ld (int, const vector unsigned char *);
16750 vector unsigned char vec_ld (int, const unsigned char *);
16752 vector signed char vec_lde (int, const signed char *);
16753 vector unsigned char vec_lde (int, const unsigned char *);
16754 vector signed short vec_lde (int, const short *);
16755 vector unsigned short vec_lde (int, const unsigned short *);
16756 vector float vec_lde (int, const float *);
16757 vector signed int vec_lde (int, const int *);
16758 vector unsigned int vec_lde (int, const unsigned int *);
16759 vector signed int vec_lde (int, const long *);
16760 vector unsigned int vec_lde (int, const unsigned long *);
16762 vector float vec_lvewx (int, float *);
16763 vector signed int vec_lvewx (int, int *);
16764 vector unsigned int vec_lvewx (int, unsigned int *);
16765 vector signed int vec_lvewx (int, long *);
16766 vector unsigned int vec_lvewx (int, unsigned long *);
16768 vector signed short vec_lvehx (int, short *);
16769 vector unsigned short vec_lvehx (int, unsigned short *);
16771 vector signed char vec_lvebx (int, char *);
16772 vector unsigned char vec_lvebx (int, unsigned char *);
16774 vector float vec_ldl (int, const vector float *);
16775 vector float vec_ldl (int, const float *);
16776 vector bool int vec_ldl (int, const vector bool int *);
16777 vector signed int vec_ldl (int, const vector signed int *);
16778 vector signed int vec_ldl (int, const int *);
16779 vector signed int vec_ldl (int, const long *);
16780 vector unsigned int vec_ldl (int, const vector unsigned int *);
16781 vector unsigned int vec_ldl (int, const unsigned int *);
16782 vector unsigned int vec_ldl (int, const unsigned long *);
16783 vector bool short vec_ldl (int, const vector bool short *);
16784 vector pixel vec_ldl (int, const vector pixel *);
16785 vector signed short vec_ldl (int, const vector signed short *);
16786 vector signed short vec_ldl (int, const short *);
16787 vector unsigned short vec_ldl (int, const vector unsigned short *);
16788 vector unsigned short vec_ldl (int, const unsigned short *);
16789 vector bool char vec_ldl (int, const vector bool char *);
16790 vector signed char vec_ldl (int, const vector signed char *);
16791 vector signed char vec_ldl (int, const signed char *);
16792 vector unsigned char vec_ldl (int, const vector unsigned char *);
16793 vector unsigned char vec_ldl (int, const unsigned char *);
16795 vector float vec_loge (vector float);
16797 vector unsigned char vec_lvsl (int, const volatile unsigned char *);
16798 vector unsigned char vec_lvsl (int, const volatile signed char *);
16799 vector unsigned char vec_lvsl (int, const volatile unsigned short *);
16800 vector unsigned char vec_lvsl (int, const volatile short *);
16801 vector unsigned char vec_lvsl (int, const volatile unsigned int *);
16802 vector unsigned char vec_lvsl (int, const volatile int *);
16803 vector unsigned char vec_lvsl (int, const volatile unsigned long *);
16804 vector unsigned char vec_lvsl (int, const volatile long *);
16805 vector unsigned char vec_lvsl (int, const volatile float *);
16807 vector unsigned char vec_lvsr (int, const volatile unsigned char *);
16808 vector unsigned char vec_lvsr (int, const volatile signed char *);
16809 vector unsigned char vec_lvsr (int, const volatile unsigned short *);
16810 vector unsigned char vec_lvsr (int, const volatile short *);
16811 vector unsigned char vec_lvsr (int, const volatile unsigned int *);
16812 vector unsigned char vec_lvsr (int, const volatile int *);
16813 vector unsigned char vec_lvsr (int, const volatile unsigned long *);
16814 vector unsigned char vec_lvsr (int, const volatile long *);
16815 vector unsigned char vec_lvsr (int, const volatile float *);
16817 vector float vec_madd (vector float, vector float, vector float);
16819 vector signed short vec_madds (vector signed short,
16820                                vector signed short,
16821                                vector signed short);
16823 vector unsigned char vec_max (vector bool char, vector unsigned char);
16824 vector unsigned char vec_max (vector unsigned char, vector bool char);
16825 vector unsigned char vec_max (vector unsigned char,
16826                               vector unsigned char);
16827 vector signed char vec_max (vector bool char, vector signed char);
16828 vector signed char vec_max (vector signed char, vector bool char);
16829 vector signed char vec_max (vector signed char, vector signed char);
16830 vector unsigned short vec_max (vector bool short,
16831                                vector unsigned short);
16832 vector unsigned short vec_max (vector unsigned short,
16833                                vector bool short);
16834 vector unsigned short vec_max (vector unsigned short,
16835                                vector unsigned short);
16836 vector signed short vec_max (vector bool short, vector signed short);
16837 vector signed short vec_max (vector signed short, vector bool short);
16838 vector signed short vec_max (vector signed short, vector signed short);
16839 vector unsigned int vec_max (vector bool int, vector unsigned int);
16840 vector unsigned int vec_max (vector unsigned int, vector bool int);
16841 vector unsigned int vec_max (vector unsigned int, vector unsigned int);
16842 vector signed int vec_max (vector bool int, vector signed int);
16843 vector signed int vec_max (vector signed int, vector bool int);
16844 vector signed int vec_max (vector signed int, vector signed int);
16845 vector float vec_max (vector float, vector float);
16847 vector float vec_vmaxfp (vector float, vector float);
16849 vector signed int vec_vmaxsw (vector bool int, vector signed int);
16850 vector signed int vec_vmaxsw (vector signed int, vector bool int);
16851 vector signed int vec_vmaxsw (vector signed int, vector signed int);
16853 vector unsigned int vec_vmaxuw (vector bool int, vector unsigned int);
16854 vector unsigned int vec_vmaxuw (vector unsigned int, vector bool int);
16855 vector unsigned int vec_vmaxuw (vector unsigned int,
16856                                 vector unsigned int);
16858 vector signed short vec_vmaxsh (vector bool short, vector signed short);
16859 vector signed short vec_vmaxsh (vector signed short, vector bool short);
16860 vector signed short vec_vmaxsh (vector signed short,
16861                                 vector signed short);
16863 vector unsigned short vec_vmaxuh (vector bool short,
16864                                   vector unsigned short);
16865 vector unsigned short vec_vmaxuh (vector unsigned short,
16866                                   vector bool short);
16867 vector unsigned short vec_vmaxuh (vector unsigned short,
16868                                   vector unsigned short);
16870 vector signed char vec_vmaxsb (vector bool char, vector signed char);
16871 vector signed char vec_vmaxsb (vector signed char, vector bool char);
16872 vector signed char vec_vmaxsb (vector signed char, vector signed char);
16874 vector unsigned char vec_vmaxub (vector bool char,
16875                                  vector unsigned char);
16876 vector unsigned char vec_vmaxub (vector unsigned char,
16877                                  vector bool char);
16878 vector unsigned char vec_vmaxub (vector unsigned char,
16879                                  vector unsigned char);
16881 vector bool char vec_mergeh (vector bool char, vector bool char);
16882 vector signed char vec_mergeh (vector signed char, vector signed char);
16883 vector unsigned char vec_mergeh (vector unsigned char,
16884                                  vector unsigned char);
16885 vector bool short vec_mergeh (vector bool short, vector bool short);
16886 vector pixel vec_mergeh (vector pixel, vector pixel);
16887 vector signed short vec_mergeh (vector signed short,
16888                                 vector signed short);
16889 vector unsigned short vec_mergeh (vector unsigned short,
16890                                   vector unsigned short);
16891 vector float vec_mergeh (vector float, vector float);
16892 vector bool int vec_mergeh (vector bool int, vector bool int);
16893 vector signed int vec_mergeh (vector signed int, vector signed int);
16894 vector unsigned int vec_mergeh (vector unsigned int,
16895                                 vector unsigned int);
16897 vector float vec_vmrghw (vector float, vector float);
16898 vector bool int vec_vmrghw (vector bool int, vector bool int);
16899 vector signed int vec_vmrghw (vector signed int, vector signed int);
16900 vector unsigned int vec_vmrghw (vector unsigned int,
16901                                 vector unsigned int);
16903 vector bool short vec_vmrghh (vector bool short, vector bool short);
16904 vector signed short vec_vmrghh (vector signed short,
16905                                 vector signed short);
16906 vector unsigned short vec_vmrghh (vector unsigned short,
16907                                   vector unsigned short);
16908 vector pixel vec_vmrghh (vector pixel, vector pixel);
16910 vector bool char vec_vmrghb (vector bool char, vector bool char);
16911 vector signed char vec_vmrghb (vector signed char, vector signed char);
16912 vector unsigned char vec_vmrghb (vector unsigned char,
16913                                  vector unsigned char);
16915 vector bool char vec_mergel (vector bool char, vector bool char);
16916 vector signed char vec_mergel (vector signed char, vector signed char);
16917 vector unsigned char vec_mergel (vector unsigned char,
16918                                  vector unsigned char);
16919 vector bool short vec_mergel (vector bool short, vector bool short);
16920 vector pixel vec_mergel (vector pixel, vector pixel);
16921 vector signed short vec_mergel (vector signed short,
16922                                 vector signed short);
16923 vector unsigned short vec_mergel (vector unsigned short,
16924                                   vector unsigned short);
16925 vector float vec_mergel (vector float, vector float);
16926 vector bool int vec_mergel (vector bool int, vector bool int);
16927 vector signed int vec_mergel (vector signed int, vector signed int);
16928 vector unsigned int vec_mergel (vector unsigned int,
16929                                 vector unsigned int);
16931 vector float vec_vmrglw (vector float, vector float);
16932 vector signed int vec_vmrglw (vector signed int, vector signed int);
16933 vector unsigned int vec_vmrglw (vector unsigned int,
16934                                 vector unsigned int);
16935 vector bool int vec_vmrglw (vector bool int, vector bool int);
16937 vector bool short vec_vmrglh (vector bool short, vector bool short);
16938 vector signed short vec_vmrglh (vector signed short,
16939                                 vector signed short);
16940 vector unsigned short vec_vmrglh (vector unsigned short,
16941                                   vector unsigned short);
16942 vector pixel vec_vmrglh (vector pixel, vector pixel);
16944 vector bool char vec_vmrglb (vector bool char, vector bool char);
16945 vector signed char vec_vmrglb (vector signed char, vector signed char);
16946 vector unsigned char vec_vmrglb (vector unsigned char,
16947                                  vector unsigned char);
16949 vector unsigned short vec_mfvscr (void);
16951 vector unsigned char vec_min (vector bool char, vector unsigned char);
16952 vector unsigned char vec_min (vector unsigned char, vector bool char);
16953 vector unsigned char vec_min (vector unsigned char,
16954                               vector unsigned char);
16955 vector signed char vec_min (vector bool char, vector signed char);
16956 vector signed char vec_min (vector signed char, vector bool char);
16957 vector signed char vec_min (vector signed char, vector signed char);
16958 vector unsigned short vec_min (vector bool short,
16959                                vector unsigned short);
16960 vector unsigned short vec_min (vector unsigned short,
16961                                vector bool short);
16962 vector unsigned short vec_min (vector unsigned short,
16963                                vector unsigned short);
16964 vector signed short vec_min (vector bool short, vector signed short);
16965 vector signed short vec_min (vector signed short, vector bool short);
16966 vector signed short vec_min (vector signed short, vector signed short);
16967 vector unsigned int vec_min (vector bool int, vector unsigned int);
16968 vector unsigned int vec_min (vector unsigned int, vector bool int);
16969 vector unsigned int vec_min (vector unsigned int, vector unsigned int);
16970 vector signed int vec_min (vector bool int, vector signed int);
16971 vector signed int vec_min (vector signed int, vector bool int);
16972 vector signed int vec_min (vector signed int, vector signed int);
16973 vector float vec_min (vector float, vector float);
16975 vector float vec_vminfp (vector float, vector float);
16977 vector signed int vec_vminsw (vector bool int, vector signed int);
16978 vector signed int vec_vminsw (vector signed int, vector bool int);
16979 vector signed int vec_vminsw (vector signed int, vector signed int);
16981 vector unsigned int vec_vminuw (vector bool int, vector unsigned int);
16982 vector unsigned int vec_vminuw (vector unsigned int, vector bool int);
16983 vector unsigned int vec_vminuw (vector unsigned int,
16984                                 vector unsigned int);
16986 vector signed short vec_vminsh (vector bool short, vector signed short);
16987 vector signed short vec_vminsh (vector signed short, vector bool short);
16988 vector signed short vec_vminsh (vector signed short,
16989                                 vector signed short);
16991 vector unsigned short vec_vminuh (vector bool short,
16992                                   vector unsigned short);
16993 vector unsigned short vec_vminuh (vector unsigned short,
16994                                   vector bool short);
16995 vector unsigned short vec_vminuh (vector unsigned short,
16996                                   vector unsigned short);
16998 vector signed char vec_vminsb (vector bool char, vector signed char);
16999 vector signed char vec_vminsb (vector signed char, vector bool char);
17000 vector signed char vec_vminsb (vector signed char, vector signed char);
17002 vector unsigned char vec_vminub (vector bool char,
17003                                  vector unsigned char);
17004 vector unsigned char vec_vminub (vector unsigned char,
17005                                  vector bool char);
17006 vector unsigned char vec_vminub (vector unsigned char,
17007                                  vector unsigned char);
17009 vector signed short vec_mladd (vector signed short,
17010                                vector signed short,
17011                                vector signed short);
17012 vector signed short vec_mladd (vector signed short,
17013                                vector unsigned short,
17014                                vector unsigned short);
17015 vector signed short vec_mladd (vector unsigned short,
17016                                vector signed short,
17017                                vector signed short);
17018 vector unsigned short vec_mladd (vector unsigned short,
17019                                  vector unsigned short,
17020                                  vector unsigned short);
17022 vector signed short vec_mradds (vector signed short,
17023                                 vector signed short,
17024                                 vector signed short);
17026 vector unsigned int vec_msum (vector unsigned char,
17027                               vector unsigned char,
17028                               vector unsigned int);
17029 vector signed int vec_msum (vector signed char,
17030                             vector unsigned char,
17031                             vector signed int);
17032 vector unsigned int vec_msum (vector unsigned short,
17033                               vector unsigned short,
17034                               vector unsigned int);
17035 vector signed int vec_msum (vector signed short,
17036                             vector signed short,
17037                             vector signed int);
17039 vector signed int vec_vmsumshm (vector signed short,
17040                                 vector signed short,
17041                                 vector signed int);
17043 vector unsigned int vec_vmsumuhm (vector unsigned short,
17044                                   vector unsigned short,
17045                                   vector unsigned int);
17047 vector signed int vec_vmsummbm (vector signed char,
17048                                 vector unsigned char,
17049                                 vector signed int);
17051 vector unsigned int vec_vmsumubm (vector unsigned char,
17052                                   vector unsigned char,
17053                                   vector unsigned int);
17055 vector unsigned int vec_msums (vector unsigned short,
17056                                vector unsigned short,
17057                                vector unsigned int);
17058 vector signed int vec_msums (vector signed short,
17059                              vector signed short,
17060                              vector signed int);
17062 vector signed int vec_vmsumshs (vector signed short,
17063                                 vector signed short,
17064                                 vector signed int);
17066 vector unsigned int vec_vmsumuhs (vector unsigned short,
17067                                   vector unsigned short,
17068                                   vector unsigned int);
17070 void vec_mtvscr (vector signed int);
17071 void vec_mtvscr (vector unsigned int);
17072 void vec_mtvscr (vector bool int);
17073 void vec_mtvscr (vector signed short);
17074 void vec_mtvscr (vector unsigned short);
17075 void vec_mtvscr (vector bool short);
17076 void vec_mtvscr (vector pixel);
17077 void vec_mtvscr (vector signed char);
17078 void vec_mtvscr (vector unsigned char);
17079 void vec_mtvscr (vector bool char);
17081 vector unsigned short vec_mule (vector unsigned char,
17082                                 vector unsigned char);
17083 vector signed short vec_mule (vector signed char,
17084                               vector signed char);
17085 vector unsigned int vec_mule (vector unsigned short,
17086                               vector unsigned short);
17087 vector signed int vec_mule (vector signed short, vector signed short);
17088 vector unsigned long long vec_mule (vector unsigned int,
17089                                     vector unsigned int);
17090 vector signed long long vec_mule (vector signed int,
17091                                   vector signed int);
17093 vector signed int vec_vmulesh (vector signed short,
17094                                vector signed short);
17096 vector unsigned int vec_vmuleuh (vector unsigned short,
17097                                  vector unsigned short);
17099 vector signed short vec_vmulesb (vector signed char,
17100                                  vector signed char);
17102 vector unsigned short vec_vmuleub (vector unsigned char,
17103                                   vector unsigned char);
17105 vector unsigned short vec_mulo (vector unsigned char,
17106                                 vector unsigned char);
17107 vector signed short vec_mulo (vector signed char, vector signed char);
17108 vector unsigned int vec_mulo (vector unsigned short,
17109                               vector unsigned short);
17110 vector signed int vec_mulo (vector signed short, vector signed short);
17111 vector unsigned long long vec_mulo (vector unsigned int,
17112                                     vector unsigned int);
17113 vector signed long long vec_mulo (vector signed int,
17114                                   vector signed int);
17116 vector signed int vec_vmulosh (vector signed short,
17117                                vector signed short);
17119 vector unsigned int vec_vmulouh (vector unsigned short,
17120                                  vector unsigned short);
17122 vector signed short vec_vmulosb (vector signed char,
17123                                  vector signed char);
17125 vector unsigned short vec_vmuloub (vector unsigned char,
17126                                    vector unsigned char);
17128 vector float vec_nmsub (vector float, vector float, vector float);
17130 vector signed char vec_nabs (vector signed char);
17131 vector signed short vec_nabs (vector signed short);
17132 vector signed int vec_nabs (vector signed int);
17133 vector float vec_nabs (vector float);
17134 vector double vec_nabs (vector double);
17136 vector signed char vec_neg (vector signed char);
17137 vector signed short vec_neg (vector signed short);
17138 vector signed int vec_neg (vector signed int);
17139 vector signed long long vec_neg (vector signed long long);
17140 vector float  char vec_neg (vector float);
17141 vector double vec_neg (vector double);
17143 vector float vec_nor (vector float, vector float);
17144 vector signed int vec_nor (vector signed int, vector signed int);
17145 vector unsigned int vec_nor (vector unsigned int, vector unsigned int);
17146 vector bool int vec_nor (vector bool int, vector bool int);
17147 vector signed short vec_nor (vector signed short, vector signed short);
17148 vector unsigned short vec_nor (vector unsigned short,
17149                                vector unsigned short);
17150 vector bool short vec_nor (vector bool short, vector bool short);
17151 vector signed char vec_nor (vector signed char, vector signed char);
17152 vector unsigned char vec_nor (vector unsigned char,
17153                               vector unsigned char);
17154 vector bool char vec_nor (vector bool char, vector bool char);
17156 vector float vec_or (vector float, vector float);
17157 vector float vec_or (vector float, vector bool int);
17158 vector float vec_or (vector bool int, vector float);
17159 vector bool int vec_or (vector bool int, vector bool int);
17160 vector signed int vec_or (vector bool int, vector signed int);
17161 vector signed int vec_or (vector signed int, vector bool int);
17162 vector signed int vec_or (vector signed int, vector signed int);
17163 vector unsigned int vec_or (vector bool int, vector unsigned int);
17164 vector unsigned int vec_or (vector unsigned int, vector bool int);
17165 vector unsigned int vec_or (vector unsigned int, vector unsigned int);
17166 vector bool short vec_or (vector bool short, vector bool short);
17167 vector signed short vec_or (vector bool short, vector signed short);
17168 vector signed short vec_or (vector signed short, vector bool short);
17169 vector signed short vec_or (vector signed short, vector signed short);
17170 vector unsigned short vec_or (vector bool short, vector unsigned short);
17171 vector unsigned short vec_or (vector unsigned short, vector bool short);
17172 vector unsigned short vec_or (vector unsigned short,
17173                               vector unsigned short);
17174 vector signed char vec_or (vector bool char, vector signed char);
17175 vector bool char vec_or (vector bool char, vector bool char);
17176 vector signed char vec_or (vector signed char, vector bool char);
17177 vector signed char vec_or (vector signed char, vector signed char);
17178 vector unsigned char vec_or (vector bool char, vector unsigned char);
17179 vector unsigned char vec_or (vector unsigned char, vector bool char);
17180 vector unsigned char vec_or (vector unsigned char,
17181                              vector unsigned char);
17183 vector signed char vec_pack (vector signed short, vector signed short);
17184 vector unsigned char vec_pack (vector unsigned short,
17185                                vector unsigned short);
17186 vector bool char vec_pack (vector bool short, vector bool short);
17187 vector signed short vec_pack (vector signed int, vector signed int);
17188 vector unsigned short vec_pack (vector unsigned int,
17189                                 vector unsigned int);
17190 vector bool short vec_pack (vector bool int, vector bool int);
17192 vector bool short vec_vpkuwum (vector bool int, vector bool int);
17193 vector signed short vec_vpkuwum (vector signed int, vector signed int);
17194 vector unsigned short vec_vpkuwum (vector unsigned int,
17195                                    vector unsigned int);
17197 vector bool char vec_vpkuhum (vector bool short, vector bool short);
17198 vector signed char vec_vpkuhum (vector signed short,
17199                                 vector signed short);
17200 vector unsigned char vec_vpkuhum (vector unsigned short,
17201                                   vector unsigned short);
17203 vector pixel vec_packpx (vector unsigned int, vector unsigned int);
17205 vector unsigned char vec_packs (vector unsigned short,
17206                                 vector unsigned short);
17207 vector signed char vec_packs (vector signed short, vector signed short);
17208 vector unsigned short vec_packs (vector unsigned int,
17209                                  vector unsigned int);
17210 vector signed short vec_packs (vector signed int, vector signed int);
17212 vector signed short vec_vpkswss (vector signed int, vector signed int);
17214 vector unsigned short vec_vpkuwus (vector unsigned int,
17215                                    vector unsigned int);
17217 vector signed char vec_vpkshss (vector signed short,
17218                                 vector signed short);
17220 vector unsigned char vec_vpkuhus (vector unsigned short,
17221                                   vector unsigned short);
17223 vector unsigned char vec_packsu (vector unsigned short,
17224                                  vector unsigned short);
17225 vector unsigned char vec_packsu (vector signed short,
17226                                  vector signed short);
17227 vector unsigned short vec_packsu (vector unsigned int,
17228                                   vector unsigned int);
17229 vector unsigned short vec_packsu (vector signed int, vector signed int);
17231 vector unsigned short vec_vpkswus (vector signed int,
17232                                    vector signed int);
17234 vector unsigned char vec_vpkshus (vector signed short,
17235                                   vector signed short);
17237 vector float vec_perm (vector float,
17238                        vector float,
17239                        vector unsigned char);
17240 vector signed int vec_perm (vector signed int,
17241                             vector signed int,
17242                             vector unsigned char);
17243 vector unsigned int vec_perm (vector unsigned int,
17244                               vector unsigned int,
17245                               vector unsigned char);
17246 vector bool int vec_perm (vector bool int,
17247                           vector bool int,
17248                           vector unsigned char);
17249 vector signed short vec_perm (vector signed short,
17250                               vector signed short,
17251                               vector unsigned char);
17252 vector unsigned short vec_perm (vector unsigned short,
17253                                 vector unsigned short,
17254                                 vector unsigned char);
17255 vector bool short vec_perm (vector bool short,
17256                             vector bool short,
17257                             vector unsigned char);
17258 vector pixel vec_perm (vector pixel,
17259                        vector pixel,
17260                        vector unsigned char);
17261 vector signed char vec_perm (vector signed char,
17262                              vector signed char,
17263                              vector unsigned char);
17264 vector unsigned char vec_perm (vector unsigned char,
17265                                vector unsigned char,
17266                                vector unsigned char);
17267 vector bool char vec_perm (vector bool char,
17268                            vector bool char,
17269                            vector unsigned char);
17271 vector float vec_re (vector float);
17273 vector bool char vec_reve (vector bool char);
17274 vector signed char vec_reve (vector signed char);
17275 vector unsigned char vec_reve (vector unsigned char);
17276 vector bool int vec_reve (vector bool int);
17277 vector signed int vec_reve (vector signed int);
17278 vector unsigned int vec_reve (vector unsigned int);
17279 vector bool long long vec_reve (vector bool long long);
17280 vector signed long long vec_reve (vector signed long long);
17281 vector unsigned long long vec_reve (vector unsigned long long);
17282 vector bool short vec_reve (vector bool short);
17283 vector signed short vec_reve (vector signed short);
17284 vector unsigned short vec_reve (vector unsigned short);
17286 vector signed char vec_rl (vector signed char,
17287                            vector unsigned char);
17288 vector unsigned char vec_rl (vector unsigned char,
17289                              vector unsigned char);
17290 vector signed short vec_rl (vector signed short, vector unsigned short);
17291 vector unsigned short vec_rl (vector unsigned short,
17292                               vector unsigned short);
17293 vector signed int vec_rl (vector signed int, vector unsigned int);
17294 vector unsigned int vec_rl (vector unsigned int, vector unsigned int);
17296 vector signed int vec_vrlw (vector signed int, vector unsigned int);
17297 vector unsigned int vec_vrlw (vector unsigned int, vector unsigned int);
17299 vector signed short vec_vrlh (vector signed short,
17300                               vector unsigned short);
17301 vector unsigned short vec_vrlh (vector unsigned short,
17302                                 vector unsigned short);
17304 vector signed char vec_vrlb (vector signed char, vector unsigned char);
17305 vector unsigned char vec_vrlb (vector unsigned char,
17306                                vector unsigned char);
17308 vector float vec_round (vector float);
17310 vector float vec_recip (vector float, vector float);
17312 vector float vec_rsqrt (vector float);
17314 vector float vec_rsqrte (vector float);
17316 vector float vec_sel (vector float, vector float, vector bool int);
17317 vector float vec_sel (vector float, vector float, vector unsigned int);
17318 vector signed int vec_sel (vector signed int,
17319                            vector signed int,
17320                            vector bool int);
17321 vector signed int vec_sel (vector signed int,
17322                            vector signed int,
17323                            vector unsigned int);
17324 vector unsigned int vec_sel (vector unsigned int,
17325                              vector unsigned int,
17326                              vector bool int);
17327 vector unsigned int vec_sel (vector unsigned int,
17328                              vector unsigned int,
17329                              vector unsigned int);
17330 vector bool int vec_sel (vector bool int,
17331                          vector bool int,
17332                          vector bool int);
17333 vector bool int vec_sel (vector bool int,
17334                          vector bool int,
17335                          vector unsigned int);
17336 vector signed short vec_sel (vector signed short,
17337                              vector signed short,
17338                              vector bool short);
17339 vector signed short vec_sel (vector signed short,
17340                              vector signed short,
17341                              vector unsigned short);
17342 vector unsigned short vec_sel (vector unsigned short,
17343                                vector unsigned short,
17344                                vector bool short);
17345 vector unsigned short vec_sel (vector unsigned short,
17346                                vector unsigned short,
17347                                vector unsigned short);
17348 vector bool short vec_sel (vector bool short,
17349                            vector bool short,
17350                            vector bool short);
17351 vector bool short vec_sel (vector bool short,
17352                            vector bool short,
17353                            vector unsigned short);
17354 vector signed char vec_sel (vector signed char,
17355                             vector signed char,
17356                             vector bool char);
17357 vector signed char vec_sel (vector signed char,
17358                             vector signed char,
17359                             vector unsigned char);
17360 vector unsigned char vec_sel (vector unsigned char,
17361                               vector unsigned char,
17362                               vector bool char);
17363 vector unsigned char vec_sel (vector unsigned char,
17364                               vector unsigned char,
17365                               vector unsigned char);
17366 vector bool char vec_sel (vector bool char,
17367                           vector bool char,
17368                           vector bool char);
17369 vector bool char vec_sel (vector bool char,
17370                           vector bool char,
17371                           vector unsigned char);
17373 vector signed long long vec_signed (vector double);
17374 vector signed int vec_signed (vector float);
17376 vector signed int vec_signede (vector double);
17377 vector signed int vec_signedo (vector double);
17378 vector signed int vec_signed2 (vector double, vector double);
17380 vector signed char vec_sl (vector signed char,
17381                            vector unsigned char);
17382 vector unsigned char vec_sl (vector unsigned char,
17383                              vector unsigned char);
17384 vector signed short vec_sl (vector signed short, vector unsigned short);
17385 vector unsigned short vec_sl (vector unsigned short,
17386                               vector unsigned short);
17387 vector signed int vec_sl (vector signed int, vector unsigned int);
17388 vector unsigned int vec_sl (vector unsigned int, vector unsigned int);
17390 vector signed int vec_vslw (vector signed int, vector unsigned int);
17391 vector unsigned int vec_vslw (vector unsigned int, vector unsigned int);
17393 vector signed short vec_vslh (vector signed short,
17394                               vector unsigned short);
17395 vector unsigned short vec_vslh (vector unsigned short,
17396                                 vector unsigned short);
17398 vector signed char vec_vslb (vector signed char, vector unsigned char);
17399 vector unsigned char vec_vslb (vector unsigned char,
17400                                vector unsigned char);
17402 vector float vec_sld (vector float, vector float, const int);
17403 vector double vec_sld (vector double, vector double, const int);
17405 vector signed int vec_sld (vector signed int,
17406                            vector signed int,
17407                            const int);
17408 vector unsigned int vec_sld (vector unsigned int,
17409                              vector unsigned int,
17410                              const int);
17411 vector bool int vec_sld (vector bool int,
17412                          vector bool int,
17413                          const int);
17414 vector signed short vec_sld (vector signed short,
17415                              vector signed short,
17416                              const int);
17417 vector unsigned short vec_sld (vector unsigned short,
17418                                vector unsigned short,
17419                                const int);
17420 vector bool short vec_sld (vector bool short,
17421                            vector bool short,
17422                            const int);
17423 vector pixel vec_sld (vector pixel,
17424                       vector pixel,
17425                       const int);
17426 vector signed char vec_sld (vector signed char,
17427                             vector signed char,
17428                             const int);
17429 vector unsigned char vec_sld (vector unsigned char,
17430                               vector unsigned char,
17431                               const int);
17432 vector bool char vec_sld (vector bool char,
17433                           vector bool char,
17434                           const int);
17435 vector bool long long int vec_sld (vector bool long long int,
17436                                    vector bool long long int, const int);
17437 vector long long int vec_sld (vector long long int,
17438                               vector  long long int, const int);
17439 vector unsigned long long int vec_sld (vector unsigned long long int,
17440                                        vector unsigned long long int,
17441                                        const int);
17443 vector signed char vec_sldw (vector signed char,
17444                              vector signed char,
17445                              const int);
17446 vector unsigned char vec_sldw (vector unsigned char,
17447                                vector unsigned char,
17448                                const int);
17449 vector signed short vec_sldw (vector signed short,
17450                               vector signed short,
17451                               const int);
17452 vector unsigned short vec_sldw (vector unsigned short,
17453                                 vector unsigned short,
17454                                 const int);
17455 vector signed int vec_sldw (vector signed int,
17456                             vector signed int,
17457                             const int);
17458 vector unsigned int vec_sldw (vector unsigned int,
17459                               vector unsigned int,
17460                               const int);
17461 vector signed long long vec_sldw (vector signed long long,
17462                                   vector signed long long,
17463                                   const int);
17464 vector unsigned long long vec_sldw (vector unsigned long long,
17465                                     vector unsigned long long,
17466                                     const int);
17468 vector signed int vec_sll (vector signed int,
17469                            vector unsigned int);
17470 vector signed int vec_sll (vector signed int,
17471                            vector unsigned short);
17472 vector signed int vec_sll (vector signed int,
17473                            vector unsigned char);
17474 vector unsigned int vec_sll (vector unsigned int,
17475                              vector unsigned int);
17476 vector unsigned int vec_sll (vector unsigned int,
17477                              vector unsigned short);
17478 vector unsigned int vec_sll (vector unsigned int,
17479                              vector unsigned char);
17480 vector bool int vec_sll (vector bool int,
17481                          vector unsigned int);
17482 vector bool int vec_sll (vector bool int,
17483                          vector unsigned short);
17484 vector bool int vec_sll (vector bool int,
17485                          vector unsigned char);
17486 vector signed short vec_sll (vector signed short,
17487                              vector unsigned int);
17488 vector signed short vec_sll (vector signed short,
17489                              vector unsigned short);
17490 vector signed short vec_sll (vector signed short,
17491                              vector unsigned char);
17492 vector unsigned short vec_sll (vector unsigned short,
17493                                vector unsigned int);
17494 vector unsigned short vec_sll (vector unsigned short,
17495                                vector unsigned short);
17496 vector unsigned short vec_sll (vector unsigned short,
17497                                vector unsigned char);
17498 vector long long int vec_sll (vector long long int,
17499                               vector unsigned char);
17500 vector unsigned long long int vec_sll (vector unsigned long long int,
17501                                        vector unsigned char);
17502 vector bool short vec_sll (vector bool short, vector unsigned int);
17503 vector bool short vec_sll (vector bool short, vector unsigned short);
17504 vector bool short vec_sll (vector bool short, vector unsigned char);
17505 vector pixel vec_sll (vector pixel, vector unsigned int);
17506 vector pixel vec_sll (vector pixel, vector unsigned short);
17507 vector pixel vec_sll (vector pixel, vector unsigned char);
17508 vector signed char vec_sll (vector signed char, vector unsigned int);
17509 vector signed char vec_sll (vector signed char, vector unsigned short);
17510 vector signed char vec_sll (vector signed char, vector unsigned char);
17511 vector unsigned char vec_sll (vector unsigned char,
17512                               vector unsigned int);
17513 vector unsigned char vec_sll (vector unsigned char,
17514                               vector unsigned short);
17515 vector unsigned char vec_sll (vector unsigned char,
17516                               vector unsigned char);
17517 vector bool char vec_sll (vector bool char, vector unsigned int);
17518 vector bool char vec_sll (vector bool char, vector unsigned short);
17519 vector bool char vec_sll (vector bool char, vector unsigned char);
17521 vector float vec_slo (vector float, vector signed char);
17522 vector float vec_slo (vector float, vector unsigned char);
17523 vector signed int vec_slo (vector signed int, vector signed char);
17524 vector signed int vec_slo (vector signed int, vector unsigned char);
17525 vector unsigned int vec_slo (vector unsigned int, vector signed char);
17526 vector unsigned int vec_slo (vector unsigned int, vector unsigned char);
17527 vector signed short vec_slo (vector signed short, vector signed char);
17528 vector signed short vec_slo (vector signed short, vector unsigned char);
17529 vector unsigned short vec_slo (vector unsigned short,
17530                                vector signed char);
17531 vector unsigned short vec_slo (vector unsigned short,
17532                                vector unsigned char);
17533 vector pixel vec_slo (vector pixel, vector signed char);
17534 vector pixel vec_slo (vector pixel, vector unsigned char);
17535 vector signed char vec_slo (vector signed char, vector signed char);
17536 vector signed char vec_slo (vector signed char, vector unsigned char);
17537 vector unsigned char vec_slo (vector unsigned char, vector signed char);
17538 vector unsigned char vec_slo (vector unsigned char,
17539                               vector unsigned char);
17540 vector signed long long vec_slo (vector signed long long, vector signed char);
17541 vector signed long long vec_slo (vector signed long long, vector unsigned char);
17542 vector unsigned long long vec_slo (vector unsigned long long, vector signed char);
17543 vector unsigned long long vec_slo (vector unsigned long long, vector unsigned char);
17545 vector signed char vec_splat (vector signed char, const int);
17546 vector unsigned char vec_splat (vector unsigned char, const int);
17547 vector bool char vec_splat (vector bool char, const int);
17548 vector signed short vec_splat (vector signed short, const int);
17549 vector unsigned short vec_splat (vector unsigned short, const int);
17550 vector bool short vec_splat (vector bool short, const int);
17551 vector pixel vec_splat (vector pixel, const int);
17552 vector float vec_splat (vector float, const int);
17553 vector signed int vec_splat (vector signed int, const int);
17554 vector unsigned int vec_splat (vector unsigned int, const int);
17555 vector bool int vec_splat (vector bool int, const int);
17556 vector signed long vec_splat (vector signed long, const int);
17557 vector unsigned long vec_splat (vector unsigned long, const int);
17559 vector signed char vec_splats (signed char);
17560 vector unsigned char vec_splats (unsigned char);
17561 vector signed short vec_splats (signed short);
17562 vector unsigned short vec_splats (unsigned short);
17563 vector signed int vec_splats (signed int);
17564 vector unsigned int vec_splats (unsigned int);
17565 vector float vec_splats (float);
17567 vector float vec_vspltw (vector float, const int);
17568 vector signed int vec_vspltw (vector signed int, const int);
17569 vector unsigned int vec_vspltw (vector unsigned int, const int);
17570 vector bool int vec_vspltw (vector bool int, const int);
17572 vector bool short vec_vsplth (vector bool short, const int);
17573 vector signed short vec_vsplth (vector signed short, const int);
17574 vector unsigned short vec_vsplth (vector unsigned short, const int);
17575 vector pixel vec_vsplth (vector pixel, const int);
17577 vector signed char vec_vspltb (vector signed char, const int);
17578 vector unsigned char vec_vspltb (vector unsigned char, const int);
17579 vector bool char vec_vspltb (vector bool char, const int);
17581 vector signed char vec_splat_s8 (const int);
17583 vector signed short vec_splat_s16 (const int);
17585 vector signed int vec_splat_s32 (const int);
17587 vector unsigned char vec_splat_u8 (const int);
17589 vector unsigned short vec_splat_u16 (const int);
17591 vector unsigned int vec_splat_u32 (const int);
17593 vector signed char vec_sr (vector signed char, vector unsigned char);
17594 vector unsigned char vec_sr (vector unsigned char,
17595                              vector unsigned char);
17596 vector signed short vec_sr (vector signed short,
17597                             vector unsigned short);
17598 vector unsigned short vec_sr (vector unsigned short,
17599                               vector unsigned short);
17600 vector signed int vec_sr (vector signed int, vector unsigned int);
17601 vector unsigned int vec_sr (vector unsigned int, vector unsigned int);
17603 vector signed int vec_vsrw (vector signed int, vector unsigned int);
17604 vector unsigned int vec_vsrw (vector unsigned int, vector unsigned int);
17606 vector signed short vec_vsrh (vector signed short,
17607                               vector unsigned short);
17608 vector unsigned short vec_vsrh (vector unsigned short,
17609                                 vector unsigned short);
17611 vector signed char vec_vsrb (vector signed char, vector unsigned char);
17612 vector unsigned char vec_vsrb (vector unsigned char,
17613                                vector unsigned char);
17615 vector signed char vec_sra (vector signed char, vector unsigned char);
17616 vector unsigned char vec_sra (vector unsigned char,
17617                               vector unsigned char);
17618 vector signed short vec_sra (vector signed short,
17619                              vector unsigned short);
17620 vector unsigned short vec_sra (vector unsigned short,
17621                                vector unsigned short);
17622 vector signed int vec_sra (vector signed int, vector unsigned int);
17623 vector unsigned int vec_sra (vector unsigned int, vector unsigned int);
17625 vector signed int vec_vsraw (vector signed int, vector unsigned int);
17626 vector unsigned int vec_vsraw (vector unsigned int,
17627                                vector unsigned int);
17629 vector signed short vec_vsrah (vector signed short,
17630                                vector unsigned short);
17631 vector unsigned short vec_vsrah (vector unsigned short,
17632                                  vector unsigned short);
17634 vector signed char vec_vsrab (vector signed char, vector unsigned char);
17635 vector unsigned char vec_vsrab (vector unsigned char,
17636                                 vector unsigned char);
17638 vector signed int vec_srl (vector signed int, vector unsigned int);
17639 vector signed int vec_srl (vector signed int, vector unsigned short);
17640 vector signed int vec_srl (vector signed int, vector unsigned char);
17641 vector unsigned int vec_srl (vector unsigned int, vector unsigned int);
17642 vector unsigned int vec_srl (vector unsigned int,
17643                              vector unsigned short);
17644 vector unsigned int vec_srl (vector unsigned int, vector unsigned char);
17645 vector bool int vec_srl (vector bool int, vector unsigned int);
17646 vector bool int vec_srl (vector bool int, vector unsigned short);
17647 vector bool int vec_srl (vector bool int, vector unsigned char);
17648 vector signed short vec_srl (vector signed short, vector unsigned int);
17649 vector signed short vec_srl (vector signed short,
17650                              vector unsigned short);
17651 vector signed short vec_srl (vector signed short, vector unsigned char);
17652 vector unsigned short vec_srl (vector unsigned short,
17653                                vector unsigned int);
17654 vector unsigned short vec_srl (vector unsigned short,
17655                                vector unsigned short);
17656 vector unsigned short vec_srl (vector unsigned short,
17657                                vector unsigned char);
17658 vector long long int vec_srl (vector long long int,
17659                               vector unsigned char);
17660 vector unsigned long long int vec_srl (vector unsigned long long int,
17661                                        vector unsigned char);
17662 vector bool short vec_srl (vector bool short, vector unsigned int);
17663 vector bool short vec_srl (vector bool short, vector unsigned short);
17664 vector bool short vec_srl (vector bool short, vector unsigned char);
17665 vector pixel vec_srl (vector pixel, vector unsigned int);
17666 vector pixel vec_srl (vector pixel, vector unsigned short);
17667 vector pixel vec_srl (vector pixel, vector unsigned char);
17668 vector signed char vec_srl (vector signed char, vector unsigned int);
17669 vector signed char vec_srl (vector signed char, vector unsigned short);
17670 vector signed char vec_srl (vector signed char, vector unsigned char);
17671 vector unsigned char vec_srl (vector unsigned char,
17672                               vector unsigned int);
17673 vector unsigned char vec_srl (vector unsigned char,
17674                               vector unsigned short);
17675 vector unsigned char vec_srl (vector unsigned char,
17676                               vector unsigned char);
17677 vector bool char vec_srl (vector bool char, vector unsigned int);
17678 vector bool char vec_srl (vector bool char, vector unsigned short);
17679 vector bool char vec_srl (vector bool char, vector unsigned char);
17681 vector float vec_sro (vector float, vector signed char);
17682 vector float vec_sro (vector float, vector unsigned char);
17683 vector signed int vec_sro (vector signed int, vector signed char);
17684 vector signed int vec_sro (vector signed int, vector unsigned char);
17685 vector unsigned int vec_sro (vector unsigned int, vector signed char);
17686 vector unsigned int vec_sro (vector unsigned int, vector unsigned char);
17687 vector signed short vec_sro (vector signed short, vector signed char);
17688 vector signed short vec_sro (vector signed short, vector unsigned char);
17689 vector unsigned short vec_sro (vector unsigned short,
17690                                vector signed char);
17691 vector unsigned short vec_sro (vector unsigned short,
17692                                vector unsigned char);
17693 vector long long int vec_sro (vector long long int,
17694                               vector char);
17695 vector long long int vec_sro (vector long long int,
17696                               vector unsigned char);
17697 vector unsigned long long int vec_sro (vector unsigned long long int,
17698                                        vector char);
17699 vector unsigned long long int vec_sro (vector unsigned long long int,
17700                                        vector unsigned char);
17701 vector pixel vec_sro (vector pixel, vector signed char);
17702 vector pixel vec_sro (vector pixel, vector unsigned char);
17703 vector signed char vec_sro (vector signed char, vector signed char);
17704 vector signed char vec_sro (vector signed char, vector unsigned char);
17705 vector unsigned char vec_sro (vector unsigned char, vector signed char);
17706 vector unsigned char vec_sro (vector unsigned char,
17707                               vector unsigned char);
17709 void vec_st (vector float, int, vector float *);
17710 void vec_st (vector float, int, float *);
17711 void vec_st (vector signed int, int, vector signed int *);
17712 void vec_st (vector signed int, int, int *);
17713 void vec_st (vector unsigned int, int, vector unsigned int *);
17714 void vec_st (vector unsigned int, int, unsigned int *);
17715 void vec_st (vector bool int, int, vector bool int *);
17716 void vec_st (vector bool int, int, unsigned int *);
17717 void vec_st (vector bool int, int, int *);
17718 void vec_st (vector signed short, int, vector signed short *);
17719 void vec_st (vector signed short, int, short *);
17720 void vec_st (vector unsigned short, int, vector unsigned short *);
17721 void vec_st (vector unsigned short, int, unsigned short *);
17722 void vec_st (vector bool short, int, vector bool short *);
17723 void vec_st (vector bool short, int, unsigned short *);
17724 void vec_st (vector pixel, int, vector pixel *);
17725 void vec_st (vector pixel, int, unsigned short *);
17726 void vec_st (vector pixel, int, short *);
17727 void vec_st (vector bool short, int, short *);
17728 void vec_st (vector signed char, int, vector signed char *);
17729 void vec_st (vector signed char, int, signed char *);
17730 void vec_st (vector unsigned char, int, vector unsigned char *);
17731 void vec_st (vector unsigned char, int, unsigned char *);
17732 void vec_st (vector bool char, int, vector bool char *);
17733 void vec_st (vector bool char, int, unsigned char *);
17734 void vec_st (vector bool char, int, signed char *);
17736 void vec_ste (vector signed char, int, signed char *);
17737 void vec_ste (vector unsigned char, int, unsigned char *);
17738 void vec_ste (vector bool char, int, signed char *);
17739 void vec_ste (vector bool char, int, unsigned char *);
17740 void vec_ste (vector signed short, int, short *);
17741 void vec_ste (vector unsigned short, int, unsigned short *);
17742 void vec_ste (vector bool short, int, short *);
17743 void vec_ste (vector bool short, int, unsigned short *);
17744 void vec_ste (vector pixel, int, short *);
17745 void vec_ste (vector pixel, int, unsigned short *);
17746 void vec_ste (vector float, int, float *);
17747 void vec_ste (vector signed int, int, int *);
17748 void vec_ste (vector unsigned int, int, unsigned int *);
17749 void vec_ste (vector bool int, int, int *);
17750 void vec_ste (vector bool int, int, unsigned int *);
17752 void vec_stvewx (vector float, int, float *);
17753 void vec_stvewx (vector signed int, int, int *);
17754 void vec_stvewx (vector unsigned int, int, unsigned int *);
17755 void vec_stvewx (vector bool int, int, int *);
17756 void vec_stvewx (vector bool int, int, unsigned int *);
17758 void vec_stvehx (vector signed short, int, short *);
17759 void vec_stvehx (vector unsigned short, int, unsigned short *);
17760 void vec_stvehx (vector bool short, int, short *);
17761 void vec_stvehx (vector bool short, int, unsigned short *);
17762 void vec_stvehx (vector pixel, int, short *);
17763 void vec_stvehx (vector pixel, int, unsigned short *);
17765 void vec_stvebx (vector signed char, int, signed char *);
17766 void vec_stvebx (vector unsigned char, int, unsigned char *);
17767 void vec_stvebx (vector bool char, int, signed char *);
17768 void vec_stvebx (vector bool char, int, unsigned char *);
17770 void vec_stl (vector float, int, vector float *);
17771 void vec_stl (vector float, int, float *);
17772 void vec_stl (vector signed int, int, vector signed int *);
17773 void vec_stl (vector signed int, int, int *);
17774 void vec_stl (vector unsigned int, int, vector unsigned int *);
17775 void vec_stl (vector unsigned int, int, unsigned int *);
17776 void vec_stl (vector bool int, int, vector bool int *);
17777 void vec_stl (vector bool int, int, unsigned int *);
17778 void vec_stl (vector bool int, int, int *);
17779 void vec_stl (vector signed short, int, vector signed short *);
17780 void vec_stl (vector signed short, int, short *);
17781 void vec_stl (vector unsigned short, int, vector unsigned short *);
17782 void vec_stl (vector unsigned short, int, unsigned short *);
17783 void vec_stl (vector bool short, int, vector bool short *);
17784 void vec_stl (vector bool short, int, unsigned short *);
17785 void vec_stl (vector bool short, int, short *);
17786 void vec_stl (vector pixel, int, vector pixel *);
17787 void vec_stl (vector pixel, int, unsigned short *);
17788 void vec_stl (vector pixel, int, short *);
17789 void vec_stl (vector signed char, int, vector signed char *);
17790 void vec_stl (vector signed char, int, signed char *);
17791 void vec_stl (vector unsigned char, int, vector unsigned char *);
17792 void vec_stl (vector unsigned char, int, unsigned char *);
17793 void vec_stl (vector bool char, int, vector bool char *);
17794 void vec_stl (vector bool char, int, unsigned char *);
17795 void vec_stl (vector bool char, int, signed char *);
17797 vector signed char vec_sub (vector bool char, vector signed char);
17798 vector signed char vec_sub (vector signed char, vector bool char);
17799 vector signed char vec_sub (vector signed char, vector signed char);
17800 vector unsigned char vec_sub (vector bool char, vector unsigned char);
17801 vector unsigned char vec_sub (vector unsigned char, vector bool char);
17802 vector unsigned char vec_sub (vector unsigned char,
17803                               vector unsigned char);
17804 vector signed short vec_sub (vector bool short, vector signed short);
17805 vector signed short vec_sub (vector signed short, vector bool short);
17806 vector signed short vec_sub (vector signed short, vector signed short);
17807 vector unsigned short vec_sub (vector bool short,
17808                                vector unsigned short);
17809 vector unsigned short vec_sub (vector unsigned short,
17810                                vector bool short);
17811 vector unsigned short vec_sub (vector unsigned short,
17812                                vector unsigned short);
17813 vector signed int vec_sub (vector bool int, vector signed int);
17814 vector signed int vec_sub (vector signed int, vector bool int);
17815 vector signed int vec_sub (vector signed int, vector signed int);
17816 vector unsigned int vec_sub (vector bool int, vector unsigned int);
17817 vector unsigned int vec_sub (vector unsigned int, vector bool int);
17818 vector unsigned int vec_sub (vector unsigned int, vector unsigned int);
17819 vector float vec_sub (vector float, vector float);
17821 vector float vec_vsubfp (vector float, vector float);
17823 vector signed int vec_vsubuwm (vector bool int, vector signed int);
17824 vector signed int vec_vsubuwm (vector signed int, vector bool int);
17825 vector signed int vec_vsubuwm (vector signed int, vector signed int);
17826 vector unsigned int vec_vsubuwm (vector bool int, vector unsigned int);
17827 vector unsigned int vec_vsubuwm (vector unsigned int, vector bool int);
17828 vector unsigned int vec_vsubuwm (vector unsigned int,
17829                                  vector unsigned int);
17831 vector signed short vec_vsubuhm (vector bool short,
17832                                  vector signed short);
17833 vector signed short vec_vsubuhm (vector signed short,
17834                                  vector bool short);
17835 vector signed short vec_vsubuhm (vector signed short,
17836                                  vector signed short);
17837 vector unsigned short vec_vsubuhm (vector bool short,
17838                                    vector unsigned short);
17839 vector unsigned short vec_vsubuhm (vector unsigned short,
17840                                    vector bool short);
17841 vector unsigned short vec_vsubuhm (vector unsigned short,
17842                                    vector unsigned short);
17844 vector signed char vec_vsububm (vector bool char, vector signed char);
17845 vector signed char vec_vsububm (vector signed char, vector bool char);
17846 vector signed char vec_vsububm (vector signed char, vector signed char);
17847 vector unsigned char vec_vsububm (vector bool char,
17848                                   vector unsigned char);
17849 vector unsigned char vec_vsububm (vector unsigned char,
17850                                   vector bool char);
17851 vector unsigned char vec_vsububm (vector unsigned char,
17852                                   vector unsigned char);
17854 vector signed int vec_subc (vector signed int, vector signed int);
17855 vector unsigned int vec_subc (vector unsigned int, vector unsigned int);
17856 vector signed __int128 vec_subc (vector signed __int128,
17857                                  vector signed __int128);
17858 vector unsigned __int128 vec_subc (vector unsigned __int128,
17859                                    vector unsigned __int128);
17861 vector signed int vec_sube (vector signed int, vector signed int,
17862                             vector signed int);
17863 vector unsigned int vec_sube (vector unsigned int, vector unsigned int,
17864                               vector unsigned int);
17865 vector signed __int128 vec_sube (vector signed __int128,
17866                                  vector signed __int128,
17867                                  vector signed __int128);
17868 vector unsigned __int128 vec_sube (vector unsigned __int128,
17869                                    vector unsigned __int128,
17870                                    vector unsigned __int128);
17872 vector signed int vec_subec (vector signed int, vector signed int,
17873                              vector signed int);
17874 vector unsigned int vec_subec (vector unsigned int, vector unsigned int,
17875                                vector unsigned int);
17876 vector signed __int128 vec_subec (vector signed __int128,
17877                                   vector signed __int128,
17878                                   vector signed __int128);
17879 vector unsigned __int128 vec_subec (vector unsigned __int128,
17880                                     vector unsigned __int128,
17881                                     vector unsigned __int128);
17883 vector unsigned char vec_subs (vector bool char, vector unsigned char);
17884 vector unsigned char vec_subs (vector unsigned char, vector bool char);
17885 vector unsigned char vec_subs (vector unsigned char,
17886                                vector unsigned char);
17887 vector signed char vec_subs (vector bool char, vector signed char);
17888 vector signed char vec_subs (vector signed char, vector bool char);
17889 vector signed char vec_subs (vector signed char, vector signed char);
17890 vector unsigned short vec_subs (vector bool short,
17891                                 vector unsigned short);
17892 vector unsigned short vec_subs (vector unsigned short,
17893                                 vector bool short);
17894 vector unsigned short vec_subs (vector unsigned short,
17895                                 vector unsigned short);
17896 vector signed short vec_subs (vector bool short, vector signed short);
17897 vector signed short vec_subs (vector signed short, vector bool short);
17898 vector signed short vec_subs (vector signed short, vector signed short);
17899 vector unsigned int vec_subs (vector bool int, vector unsigned int);
17900 vector unsigned int vec_subs (vector unsigned int, vector bool int);
17901 vector unsigned int vec_subs (vector unsigned int, vector unsigned int);
17902 vector signed int vec_subs (vector bool int, vector signed int);
17903 vector signed int vec_subs (vector signed int, vector bool int);
17904 vector signed int vec_subs (vector signed int, vector signed int);
17906 vector signed int vec_vsubsws (vector bool int, vector signed int);
17907 vector signed int vec_vsubsws (vector signed int, vector bool int);
17908 vector signed int vec_vsubsws (vector signed int, vector signed int);
17910 vector unsigned int vec_vsubuws (vector bool int, vector unsigned int);
17911 vector unsigned int vec_vsubuws (vector unsigned int, vector bool int);
17912 vector unsigned int vec_vsubuws (vector unsigned int,
17913                                  vector unsigned int);
17915 vector signed short vec_vsubshs (vector bool short,
17916                                  vector signed short);
17917 vector signed short vec_vsubshs (vector signed short,
17918                                  vector bool short);
17919 vector signed short vec_vsubshs (vector signed short,
17920                                  vector signed short);
17922 vector unsigned short vec_vsubuhs (vector bool short,
17923                                    vector unsigned short);
17924 vector unsigned short vec_vsubuhs (vector unsigned short,
17925                                    vector bool short);
17926 vector unsigned short vec_vsubuhs (vector unsigned short,
17927                                    vector unsigned short);
17929 vector signed char vec_vsubsbs (vector bool char, vector signed char);
17930 vector signed char vec_vsubsbs (vector signed char, vector bool char);
17931 vector signed char vec_vsubsbs (vector signed char, vector signed char);
17933 vector unsigned char vec_vsububs (vector bool char,
17934                                   vector unsigned char);
17935 vector unsigned char vec_vsububs (vector unsigned char,
17936                                   vector bool char);
17937 vector unsigned char vec_vsububs (vector unsigned char,
17938                                   vector unsigned char);
17940 vector unsigned int vec_sum4s (vector unsigned char,
17941                                vector unsigned int);
17942 vector signed int vec_sum4s (vector signed char, vector signed int);
17943 vector signed int vec_sum4s (vector signed short, vector signed int);
17945 vector signed int vec_vsum4shs (vector signed short, vector signed int);
17947 vector signed int vec_vsum4sbs (vector signed char, vector signed int);
17949 vector unsigned int vec_vsum4ubs (vector unsigned char,
17950                                   vector unsigned int);
17952 vector signed int vec_sum2s (vector signed int, vector signed int);
17954 vector signed int vec_sums (vector signed int, vector signed int);
17956 vector float vec_trunc (vector float);
17958 vector signed long long vec_unsigned (vector double);
17959 vector signed int vec_unsigned (vector float);
17961 vector signed int vec_unsignede (vector double);
17962 vector signed int vec_unsignedo (vector double);
17963 vector signed int vec_unsigned2 (vector double, vector double);
17965 vector signed short vec_unpackh (vector signed char);
17966 vector bool short vec_unpackh (vector bool char);
17967 vector signed int vec_unpackh (vector signed short);
17968 vector bool int vec_unpackh (vector bool short);
17969 vector unsigned int vec_unpackh (vector pixel);
17970 vector double vec_unpackh (vector float);
17972 vector bool int vec_vupkhsh (vector bool short);
17973 vector signed int vec_vupkhsh (vector signed short);
17975 vector unsigned int vec_vupkhpx (vector pixel);
17977 vector bool short vec_vupkhsb (vector bool char);
17978 vector signed short vec_vupkhsb (vector signed char);
17980 vector signed short vec_unpackl (vector signed char);
17981 vector bool short vec_unpackl (vector bool char);
17982 vector unsigned int vec_unpackl (vector pixel);
17983 vector signed int vec_unpackl (vector signed short);
17984 vector bool int vec_unpackl (vector bool short);
17985 vector double vec_unpackl (vector float);
17987 vector unsigned int vec_vupklpx (vector pixel);
17989 vector bool int vec_vupklsh (vector bool short);
17990 vector signed int vec_vupklsh (vector signed short);
17992 vector bool short vec_vupklsb (vector bool char);
17993 vector signed short vec_vupklsb (vector signed char);
17995 vector float vec_xor (vector float, vector float);
17996 vector float vec_xor (vector float, vector bool int);
17997 vector float vec_xor (vector bool int, vector float);
17998 vector bool int vec_xor (vector bool int, vector bool int);
17999 vector signed int vec_xor (vector bool int, vector signed int);
18000 vector signed int vec_xor (vector signed int, vector bool int);
18001 vector signed int vec_xor (vector signed int, vector signed int);
18002 vector unsigned int vec_xor (vector bool int, vector unsigned int);
18003 vector unsigned int vec_xor (vector unsigned int, vector bool int);
18004 vector unsigned int vec_xor (vector unsigned int, vector unsigned int);
18005 vector bool short vec_xor (vector bool short, vector bool short);
18006 vector signed short vec_xor (vector bool short, vector signed short);
18007 vector signed short vec_xor (vector signed short, vector bool short);
18008 vector signed short vec_xor (vector signed short, vector signed short);
18009 vector unsigned short vec_xor (vector bool short,
18010                                vector unsigned short);
18011 vector unsigned short vec_xor (vector unsigned short,
18012                                vector bool short);
18013 vector unsigned short vec_xor (vector unsigned short,
18014                                vector unsigned short);
18015 vector signed char vec_xor (vector bool char, vector signed char);
18016 vector bool char vec_xor (vector bool char, vector bool char);
18017 vector signed char vec_xor (vector signed char, vector bool char);
18018 vector signed char vec_xor (vector signed char, vector signed char);
18019 vector unsigned char vec_xor (vector bool char, vector unsigned char);
18020 vector unsigned char vec_xor (vector unsigned char, vector bool char);
18021 vector unsigned char vec_xor (vector unsigned char,
18022                               vector unsigned char);
18024 int vec_all_eq (vector signed char, vector bool char);
18025 int vec_all_eq (vector signed char, vector signed char);
18026 int vec_all_eq (vector unsigned char, vector bool char);
18027 int vec_all_eq (vector unsigned char, vector unsigned char);
18028 int vec_all_eq (vector bool char, vector bool char);
18029 int vec_all_eq (vector bool char, vector unsigned char);
18030 int vec_all_eq (vector bool char, vector signed char);
18031 int vec_all_eq (vector signed short, vector bool short);
18032 int vec_all_eq (vector signed short, vector signed short);
18033 int vec_all_eq (vector unsigned short, vector bool short);
18034 int vec_all_eq (vector unsigned short, vector unsigned short);
18035 int vec_all_eq (vector bool short, vector bool short);
18036 int vec_all_eq (vector bool short, vector unsigned short);
18037 int vec_all_eq (vector bool short, vector signed short);
18038 int vec_all_eq (vector pixel, vector pixel);
18039 int vec_all_eq (vector signed int, vector bool int);
18040 int vec_all_eq (vector signed int, vector signed int);
18041 int vec_all_eq (vector unsigned int, vector bool int);
18042 int vec_all_eq (vector unsigned int, vector unsigned int);
18043 int vec_all_eq (vector bool int, vector bool int);
18044 int vec_all_eq (vector bool int, vector unsigned int);
18045 int vec_all_eq (vector bool int, vector signed int);
18046 int vec_all_eq (vector float, vector float);
18048 int vec_all_ge (vector bool char, vector unsigned char);
18049 int vec_all_ge (vector unsigned char, vector bool char);
18050 int vec_all_ge (vector unsigned char, vector unsigned char);
18051 int vec_all_ge (vector bool char, vector signed char);
18052 int vec_all_ge (vector signed char, vector bool char);
18053 int vec_all_ge (vector signed char, vector signed char);
18054 int vec_all_ge (vector bool short, vector unsigned short);
18055 int vec_all_ge (vector unsigned short, vector bool short);
18056 int vec_all_ge (vector unsigned short, vector unsigned short);
18057 int vec_all_ge (vector signed short, vector signed short);
18058 int vec_all_ge (vector bool short, vector signed short);
18059 int vec_all_ge (vector signed short, vector bool short);
18060 int vec_all_ge (vector bool int, vector unsigned int);
18061 int vec_all_ge (vector unsigned int, vector bool int);
18062 int vec_all_ge (vector unsigned int, vector unsigned int);
18063 int vec_all_ge (vector bool int, vector signed int);
18064 int vec_all_ge (vector signed int, vector bool int);
18065 int vec_all_ge (vector signed int, vector signed int);
18066 int vec_all_ge (vector float, vector float);
18068 int vec_all_gt (vector bool char, vector unsigned char);
18069 int vec_all_gt (vector unsigned char, vector bool char);
18070 int vec_all_gt (vector unsigned char, vector unsigned char);
18071 int vec_all_gt (vector bool char, vector signed char);
18072 int vec_all_gt (vector signed char, vector bool char);
18073 int vec_all_gt (vector signed char, vector signed char);
18074 int vec_all_gt (vector bool short, vector unsigned short);
18075 int vec_all_gt (vector unsigned short, vector bool short);
18076 int vec_all_gt (vector unsigned short, vector unsigned short);
18077 int vec_all_gt (vector bool short, vector signed short);
18078 int vec_all_gt (vector signed short, vector bool short);
18079 int vec_all_gt (vector signed short, vector signed short);
18080 int vec_all_gt (vector bool int, vector unsigned int);
18081 int vec_all_gt (vector unsigned int, vector bool int);
18082 int vec_all_gt (vector unsigned int, vector unsigned int);
18083 int vec_all_gt (vector bool int, vector signed int);
18084 int vec_all_gt (vector signed int, vector bool int);
18085 int vec_all_gt (vector signed int, vector signed int);
18086 int vec_all_gt (vector float, vector float);
18088 int vec_all_in (vector float, vector float);
18090 int vec_all_le (vector bool char, vector unsigned char);
18091 int vec_all_le (vector unsigned char, vector bool char);
18092 int vec_all_le (vector unsigned char, vector unsigned char);
18093 int vec_all_le (vector bool char, vector signed char);
18094 int vec_all_le (vector signed char, vector bool char);
18095 int vec_all_le (vector signed char, vector signed char);
18096 int vec_all_le (vector bool short, vector unsigned short);
18097 int vec_all_le (vector unsigned short, vector bool short);
18098 int vec_all_le (vector unsigned short, vector unsigned short);
18099 int vec_all_le (vector bool short, vector signed short);
18100 int vec_all_le (vector signed short, vector bool short);
18101 int vec_all_le (vector signed short, vector signed short);
18102 int vec_all_le (vector bool int, vector unsigned int);
18103 int vec_all_le (vector unsigned int, vector bool int);
18104 int vec_all_le (vector unsigned int, vector unsigned int);
18105 int vec_all_le (vector bool int, vector signed int);
18106 int vec_all_le (vector signed int, vector bool int);
18107 int vec_all_le (vector signed int, vector signed int);
18108 int vec_all_le (vector float, vector float);
18110 int vec_all_lt (vector bool char, vector unsigned char);
18111 int vec_all_lt (vector unsigned char, vector bool char);
18112 int vec_all_lt (vector unsigned char, vector unsigned char);
18113 int vec_all_lt (vector bool char, vector signed char);
18114 int vec_all_lt (vector signed char, vector bool char);
18115 int vec_all_lt (vector signed char, vector signed char);
18116 int vec_all_lt (vector bool short, vector unsigned short);
18117 int vec_all_lt (vector unsigned short, vector bool short);
18118 int vec_all_lt (vector unsigned short, vector unsigned short);
18119 int vec_all_lt (vector bool short, vector signed short);
18120 int vec_all_lt (vector signed short, vector bool short);
18121 int vec_all_lt (vector signed short, vector signed short);
18122 int vec_all_lt (vector bool int, vector unsigned int);
18123 int vec_all_lt (vector unsigned int, vector bool int);
18124 int vec_all_lt (vector unsigned int, vector unsigned int);
18125 int vec_all_lt (vector bool int, vector signed int);
18126 int vec_all_lt (vector signed int, vector bool int);
18127 int vec_all_lt (vector signed int, vector signed int);
18128 int vec_all_lt (vector float, vector float);
18130 int vec_all_nan (vector float);
18132 int vec_all_ne (vector signed char, vector bool char);
18133 int vec_all_ne (vector signed char, vector signed char);
18134 int vec_all_ne (vector unsigned char, vector bool char);
18135 int vec_all_ne (vector unsigned char, vector unsigned char);
18136 int vec_all_ne (vector bool char, vector bool char);
18137 int vec_all_ne (vector bool char, vector unsigned char);
18138 int vec_all_ne (vector bool char, vector signed char);
18139 int vec_all_ne (vector signed short, vector bool short);
18140 int vec_all_ne (vector signed short, vector signed short);
18141 int vec_all_ne (vector unsigned short, vector bool short);
18142 int vec_all_ne (vector unsigned short, vector unsigned short);
18143 int vec_all_ne (vector bool short, vector bool short);
18144 int vec_all_ne (vector bool short, vector unsigned short);
18145 int vec_all_ne (vector bool short, vector signed short);
18146 int vec_all_ne (vector pixel, vector pixel);
18147 int vec_all_ne (vector signed int, vector bool int);
18148 int vec_all_ne (vector signed int, vector signed int);
18149 int vec_all_ne (vector unsigned int, vector bool int);
18150 int vec_all_ne (vector unsigned int, vector unsigned int);
18151 int vec_all_ne (vector bool int, vector bool int);
18152 int vec_all_ne (vector bool int, vector unsigned int);
18153 int vec_all_ne (vector bool int, vector signed int);
18154 int vec_all_ne (vector float, vector float);
18156 int vec_all_nge (vector float, vector float);
18158 int vec_all_ngt (vector float, vector float);
18160 int vec_all_nle (vector float, vector float);
18162 int vec_all_nlt (vector float, vector float);
18164 int vec_all_numeric (vector float);
18166 int vec_any_eq (vector signed char, vector bool char);
18167 int vec_any_eq (vector signed char, vector signed char);
18168 int vec_any_eq (vector unsigned char, vector bool char);
18169 int vec_any_eq (vector unsigned char, vector unsigned char);
18170 int vec_any_eq (vector bool char, vector bool char);
18171 int vec_any_eq (vector bool char, vector unsigned char);
18172 int vec_any_eq (vector bool char, vector signed char);
18173 int vec_any_eq (vector signed short, vector bool short);
18174 int vec_any_eq (vector signed short, vector signed short);
18175 int vec_any_eq (vector unsigned short, vector bool short);
18176 int vec_any_eq (vector unsigned short, vector unsigned short);
18177 int vec_any_eq (vector bool short, vector bool short);
18178 int vec_any_eq (vector bool short, vector unsigned short);
18179 int vec_any_eq (vector bool short, vector signed short);
18180 int vec_any_eq (vector pixel, vector pixel);
18181 int vec_any_eq (vector signed int, vector bool int);
18182 int vec_any_eq (vector signed int, vector signed int);
18183 int vec_any_eq (vector unsigned int, vector bool int);
18184 int vec_any_eq (vector unsigned int, vector unsigned int);
18185 int vec_any_eq (vector bool int, vector bool int);
18186 int vec_any_eq (vector bool int, vector unsigned int);
18187 int vec_any_eq (vector bool int, vector signed int);
18188 int vec_any_eq (vector float, vector float);
18190 int vec_any_ge (vector signed char, vector bool char);
18191 int vec_any_ge (vector unsigned char, vector bool char);
18192 int vec_any_ge (vector unsigned char, vector unsigned char);
18193 int vec_any_ge (vector signed char, vector signed char);
18194 int vec_any_ge (vector bool char, vector unsigned char);
18195 int vec_any_ge (vector bool char, vector signed char);
18196 int vec_any_ge (vector unsigned short, vector bool short);
18197 int vec_any_ge (vector unsigned short, vector unsigned short);
18198 int vec_any_ge (vector signed short, vector signed short);
18199 int vec_any_ge (vector signed short, vector bool short);
18200 int vec_any_ge (vector bool short, vector unsigned short);
18201 int vec_any_ge (vector bool short, vector signed short);
18202 int vec_any_ge (vector signed int, vector bool int);
18203 int vec_any_ge (vector unsigned int, vector bool int);
18204 int vec_any_ge (vector unsigned int, vector unsigned int);
18205 int vec_any_ge (vector signed int, vector signed int);
18206 int vec_any_ge (vector bool int, vector unsigned int);
18207 int vec_any_ge (vector bool int, vector signed int);
18208 int vec_any_ge (vector float, vector float);
18210 int vec_any_gt (vector bool char, vector unsigned char);
18211 int vec_any_gt (vector unsigned char, vector bool char);
18212 int vec_any_gt (vector unsigned char, vector unsigned char);
18213 int vec_any_gt (vector bool char, vector signed char);
18214 int vec_any_gt (vector signed char, vector bool char);
18215 int vec_any_gt (vector signed char, vector signed char);
18216 int vec_any_gt (vector bool short, vector unsigned short);
18217 int vec_any_gt (vector unsigned short, vector bool short);
18218 int vec_any_gt (vector unsigned short, vector unsigned short);
18219 int vec_any_gt (vector bool short, vector signed short);
18220 int vec_any_gt (vector signed short, vector bool short);
18221 int vec_any_gt (vector signed short, vector signed short);
18222 int vec_any_gt (vector bool int, vector unsigned int);
18223 int vec_any_gt (vector unsigned int, vector bool int);
18224 int vec_any_gt (vector unsigned int, vector unsigned int);
18225 int vec_any_gt (vector bool int, vector signed int);
18226 int vec_any_gt (vector signed int, vector bool int);
18227 int vec_any_gt (vector signed int, vector signed int);
18228 int vec_any_gt (vector float, vector float);
18230 int vec_any_le (vector bool char, vector unsigned char);
18231 int vec_any_le (vector unsigned char, vector bool char);
18232 int vec_any_le (vector unsigned char, vector unsigned char);
18233 int vec_any_le (vector bool char, vector signed char);
18234 int vec_any_le (vector signed char, vector bool char);
18235 int vec_any_le (vector signed char, vector signed char);
18236 int vec_any_le (vector bool short, vector unsigned short);
18237 int vec_any_le (vector unsigned short, vector bool short);
18238 int vec_any_le (vector unsigned short, vector unsigned short);
18239 int vec_any_le (vector bool short, vector signed short);
18240 int vec_any_le (vector signed short, vector bool short);
18241 int vec_any_le (vector signed short, vector signed short);
18242 int vec_any_le (vector bool int, vector unsigned int);
18243 int vec_any_le (vector unsigned int, vector bool int);
18244 int vec_any_le (vector unsigned int, vector unsigned int);
18245 int vec_any_le (vector bool int, vector signed int);
18246 int vec_any_le (vector signed int, vector bool int);
18247 int vec_any_le (vector signed int, vector signed int);
18248 int vec_any_le (vector float, vector float);
18250 int vec_any_lt (vector bool char, vector unsigned char);
18251 int vec_any_lt (vector unsigned char, vector bool char);
18252 int vec_any_lt (vector unsigned char, vector unsigned char);
18253 int vec_any_lt (vector bool char, vector signed char);
18254 int vec_any_lt (vector signed char, vector bool char);
18255 int vec_any_lt (vector signed char, vector signed char);
18256 int vec_any_lt (vector bool short, vector unsigned short);
18257 int vec_any_lt (vector unsigned short, vector bool short);
18258 int vec_any_lt (vector unsigned short, vector unsigned short);
18259 int vec_any_lt (vector bool short, vector signed short);
18260 int vec_any_lt (vector signed short, vector bool short);
18261 int vec_any_lt (vector signed short, vector signed short);
18262 int vec_any_lt (vector bool int, vector unsigned int);
18263 int vec_any_lt (vector unsigned int, vector bool int);
18264 int vec_any_lt (vector unsigned int, vector unsigned int);
18265 int vec_any_lt (vector bool int, vector signed int);
18266 int vec_any_lt (vector signed int, vector bool int);
18267 int vec_any_lt (vector signed int, vector signed int);
18268 int vec_any_lt (vector float, vector float);
18270 int vec_any_nan (vector float);
18272 int vec_any_ne (vector signed char, vector bool char);
18273 int vec_any_ne (vector signed char, vector signed char);
18274 int vec_any_ne (vector unsigned char, vector bool char);
18275 int vec_any_ne (vector unsigned char, vector unsigned char);
18276 int vec_any_ne (vector bool char, vector bool char);
18277 int vec_any_ne (vector bool char, vector unsigned char);
18278 int vec_any_ne (vector bool char, vector signed char);
18279 int vec_any_ne (vector signed short, vector bool short);
18280 int vec_any_ne (vector signed short, vector signed short);
18281 int vec_any_ne (vector unsigned short, vector bool short);
18282 int vec_any_ne (vector unsigned short, vector unsigned short);
18283 int vec_any_ne (vector bool short, vector bool short);
18284 int vec_any_ne (vector bool short, vector unsigned short);
18285 int vec_any_ne (vector bool short, vector signed short);
18286 int vec_any_ne (vector pixel, vector pixel);
18287 int vec_any_ne (vector signed int, vector bool int);
18288 int vec_any_ne (vector signed int, vector signed int);
18289 int vec_any_ne (vector unsigned int, vector bool int);
18290 int vec_any_ne (vector unsigned int, vector unsigned int);
18291 int vec_any_ne (vector bool int, vector bool int);
18292 int vec_any_ne (vector bool int, vector unsigned int);
18293 int vec_any_ne (vector bool int, vector signed int);
18294 int vec_any_ne (vector float, vector float);
18296 int vec_any_nge (vector float, vector float);
18298 int vec_any_ngt (vector float, vector float);
18300 int vec_any_nle (vector float, vector float);
18302 int vec_any_nlt (vector float, vector float);
18304 int vec_any_numeric (vector float);
18306 int vec_any_out (vector float, vector float);
18307 @end smallexample
18309 If the vector/scalar (VSX) instruction set is available, the following
18310 additional functions are available:
18312 @smallexample
18313 vector double vec_abs (vector double);
18314 vector double vec_add (vector double, vector double);
18315 vector double vec_and (vector double, vector double);
18316 vector double vec_and (vector double, vector bool long);
18317 vector double vec_and (vector bool long, vector double);
18318 vector long vec_and (vector long, vector long);
18319 vector long vec_and (vector long, vector bool long);
18320 vector long vec_and (vector bool long, vector long);
18321 vector unsigned long vec_and (vector unsigned long, vector unsigned long);
18322 vector unsigned long vec_and (vector unsigned long, vector bool long);
18323 vector unsigned long vec_and (vector bool long, vector unsigned long);
18324 vector double vec_andc (vector double, vector double);
18325 vector double vec_andc (vector double, vector bool long);
18326 vector double vec_andc (vector bool long, vector double);
18327 vector long vec_andc (vector long, vector long);
18328 vector long vec_andc (vector long, vector bool long);
18329 vector long vec_andc (vector bool long, vector long);
18330 vector unsigned long vec_andc (vector unsigned long, vector unsigned long);
18331 vector unsigned long vec_andc (vector unsigned long, vector bool long);
18332 vector unsigned long vec_andc (vector bool long, vector unsigned long);
18333 vector double vec_ceil (vector double);
18334 vector bool long vec_cmpeq (vector double, vector double);
18335 vector bool long vec_cmpge (vector double, vector double);
18336 vector bool long vec_cmpgt (vector double, vector double);
18337 vector bool long vec_cmple (vector double, vector double);
18338 vector bool long vec_cmplt (vector double, vector double);
18339 vector double vec_cpsgn (vector double, vector double);
18340 vector float vec_div (vector float, vector float);
18341 vector double vec_div (vector double, vector double);
18342 vector long vec_div (vector long, vector long);
18343 vector unsigned long vec_div (vector unsigned long, vector unsigned long);
18344 vector double vec_floor (vector double);
18345 vector double vec_ld (int, const vector double *);
18346 vector double vec_ld (int, const double *);
18347 vector double vec_ldl (int, const vector double *);
18348 vector double vec_ldl (int, const double *);
18349 vector unsigned char vec_lvsl (int, const volatile double *);
18350 vector unsigned char vec_lvsr (int, const volatile double *);
18351 vector double vec_madd (vector double, vector double, vector double);
18352 vector double vec_max (vector double, vector double);
18353 vector signed long vec_mergeh (vector signed long, vector signed long);
18354 vector signed long vec_mergeh (vector signed long, vector bool long);
18355 vector signed long vec_mergeh (vector bool long, vector signed long);
18356 vector unsigned long vec_mergeh (vector unsigned long, vector unsigned long);
18357 vector unsigned long vec_mergeh (vector unsigned long, vector bool long);
18358 vector unsigned long vec_mergeh (vector bool long, vector unsigned long);
18359 vector signed long vec_mergel (vector signed long, vector signed long);
18360 vector signed long vec_mergel (vector signed long, vector bool long);
18361 vector signed long vec_mergel (vector bool long, vector signed long);
18362 vector unsigned long vec_mergel (vector unsigned long, vector unsigned long);
18363 vector unsigned long vec_mergel (vector unsigned long, vector bool long);
18364 vector unsigned long vec_mergel (vector bool long, vector unsigned long);
18365 vector double vec_min (vector double, vector double);
18366 vector float vec_msub (vector float, vector float, vector float);
18367 vector double vec_msub (vector double, vector double, vector double);
18368 vector float vec_mul (vector float, vector float);
18369 vector double vec_mul (vector double, vector double);
18370 vector long vec_mul (vector long, vector long);
18371 vector unsigned long vec_mul (vector unsigned long, vector unsigned long);
18372 vector float vec_nearbyint (vector float);
18373 vector double vec_nearbyint (vector double);
18374 vector float vec_nmadd (vector float, vector float, vector float);
18375 vector double vec_nmadd (vector double, vector double, vector double);
18376 vector double vec_nmsub (vector double, vector double, vector double);
18377 vector double vec_nor (vector double, vector double);
18378 vector long vec_nor (vector long, vector long);
18379 vector long vec_nor (vector long, vector bool long);
18380 vector long vec_nor (vector bool long, vector long);
18381 vector unsigned long vec_nor (vector unsigned long, vector unsigned long);
18382 vector unsigned long vec_nor (vector unsigned long, vector bool long);
18383 vector unsigned long vec_nor (vector bool long, vector unsigned long);
18384 vector double vec_or (vector double, vector double);
18385 vector double vec_or (vector double, vector bool long);
18386 vector double vec_or (vector bool long, vector double);
18387 vector long vec_or (vector long, vector long);
18388 vector long vec_or (vector long, vector bool long);
18389 vector long vec_or (vector bool long, vector long);
18390 vector unsigned long vec_or (vector unsigned long, vector unsigned long);
18391 vector unsigned long vec_or (vector unsigned long, vector bool long);
18392 vector unsigned long vec_or (vector bool long, vector unsigned long);
18393 vector double vec_perm (vector double, vector double, vector unsigned char);
18394 vector long vec_perm (vector long, vector long, vector unsigned char);
18395 vector unsigned long vec_perm (vector unsigned long, vector unsigned long,
18396                                vector unsigned char);
18397 vector double vec_rint (vector double);
18398 vector double vec_recip (vector double, vector double);
18399 vector double vec_rsqrt (vector double);
18400 vector double vec_rsqrte (vector double);
18401 vector double vec_sel (vector double, vector double, vector bool long);
18402 vector double vec_sel (vector double, vector double, vector unsigned long);
18403 vector long vec_sel (vector long, vector long, vector long);
18404 vector long vec_sel (vector long, vector long, vector unsigned long);
18405 vector long vec_sel (vector long, vector long, vector bool long);
18406 vector unsigned long vec_sel (vector unsigned long, vector unsigned long,
18407                               vector long);
18408 vector unsigned long vec_sel (vector unsigned long, vector unsigned long,
18409                               vector unsigned long);
18410 vector unsigned long vec_sel (vector unsigned long, vector unsigned long,
18411                               vector bool long);
18412 vector double vec_splats (double);
18413 vector signed long vec_splats (signed long);
18414 vector unsigned long vec_splats (unsigned long);
18415 vector float vec_sqrt (vector float);
18416 vector double vec_sqrt (vector double);
18417 void vec_st (vector double, int, vector double *);
18418 void vec_st (vector double, int, double *);
18419 vector double vec_sub (vector double, vector double);
18420 vector double vec_trunc (vector double);
18421 vector double vec_xl (int, vector double *);
18422 vector double vec_xl (int, double *);
18423 vector long long vec_xl (int, vector long long *);
18424 vector long long vec_xl (int, long long *);
18425 vector unsigned long long vec_xl (int, vector unsigned long long *);
18426 vector unsigned long long vec_xl (int, unsigned long long *);
18427 vector float vec_xl (int, vector float *);
18428 vector float vec_xl (int, float *);
18429 vector int vec_xl (int, vector int *);
18430 vector int vec_xl (int, int *);
18431 vector unsigned int vec_xl (int, vector unsigned int *);
18432 vector unsigned int vec_xl (int, unsigned int *);
18433 vector double vec_xor (vector double, vector double);
18434 vector double vec_xor (vector double, vector bool long);
18435 vector double vec_xor (vector bool long, vector double);
18436 vector long vec_xor (vector long, vector long);
18437 vector long vec_xor (vector long, vector bool long);
18438 vector long vec_xor (vector bool long, vector long);
18439 vector unsigned long vec_xor (vector unsigned long, vector unsigned long);
18440 vector unsigned long vec_xor (vector unsigned long, vector bool long);
18441 vector unsigned long vec_xor (vector bool long, vector unsigned long);
18442 void vec_xst (vector double, int, vector double *);
18443 void vec_xst (vector double, int, double *);
18444 void vec_xst (vector long long, int, vector long long *);
18445 void vec_xst (vector long long, int, long long *);
18446 void vec_xst (vector unsigned long long, int, vector unsigned long long *);
18447 void vec_xst (vector unsigned long long, int, unsigned long long *);
18448 void vec_xst (vector float, int, vector float *);
18449 void vec_xst (vector float, int, float *);
18450 void vec_xst (vector int, int, vector int *);
18451 void vec_xst (vector int, int, int *);
18452 void vec_xst (vector unsigned int, int, vector unsigned int *);
18453 void vec_xst (vector unsigned int, int, unsigned int *);
18454 int vec_all_eq (vector double, vector double);
18455 int vec_all_ge (vector double, vector double);
18456 int vec_all_gt (vector double, vector double);
18457 int vec_all_le (vector double, vector double);
18458 int vec_all_lt (vector double, vector double);
18459 int vec_all_nan (vector double);
18460 int vec_all_ne (vector double, vector double);
18461 int vec_all_nge (vector double, vector double);
18462 int vec_all_ngt (vector double, vector double);
18463 int vec_all_nle (vector double, vector double);
18464 int vec_all_nlt (vector double, vector double);
18465 int vec_all_numeric (vector double);
18466 int vec_any_eq (vector double, vector double);
18467 int vec_any_ge (vector double, vector double);
18468 int vec_any_gt (vector double, vector double);
18469 int vec_any_le (vector double, vector double);
18470 int vec_any_lt (vector double, vector double);
18471 int vec_any_nan (vector double);
18472 int vec_any_ne (vector double, vector double);
18473 int vec_any_nge (vector double, vector double);
18474 int vec_any_ngt (vector double, vector double);
18475 int vec_any_nle (vector double, vector double);
18476 int vec_any_nlt (vector double, vector double);
18477 int vec_any_numeric (vector double);
18479 vector double vec_vsx_ld (int, const vector double *);
18480 vector double vec_vsx_ld (int, const double *);
18481 vector float vec_vsx_ld (int, const vector float *);
18482 vector float vec_vsx_ld (int, const float *);
18483 vector bool int vec_vsx_ld (int, const vector bool int *);
18484 vector signed int vec_vsx_ld (int, const vector signed int *);
18485 vector signed int vec_vsx_ld (int, const int *);
18486 vector signed int vec_vsx_ld (int, const long *);
18487 vector unsigned int vec_vsx_ld (int, const vector unsigned int *);
18488 vector unsigned int vec_vsx_ld (int, const unsigned int *);
18489 vector unsigned int vec_vsx_ld (int, const unsigned long *);
18490 vector bool short vec_vsx_ld (int, const vector bool short *);
18491 vector pixel vec_vsx_ld (int, const vector pixel *);
18492 vector signed short vec_vsx_ld (int, const vector signed short *);
18493 vector signed short vec_vsx_ld (int, const short *);
18494 vector unsigned short vec_vsx_ld (int, const vector unsigned short *);
18495 vector unsigned short vec_vsx_ld (int, const unsigned short *);
18496 vector bool char vec_vsx_ld (int, const vector bool char *);
18497 vector signed char vec_vsx_ld (int, const vector signed char *);
18498 vector signed char vec_vsx_ld (int, const signed char *);
18499 vector unsigned char vec_vsx_ld (int, const vector unsigned char *);
18500 vector unsigned char vec_vsx_ld (int, const unsigned char *);
18502 void vec_vsx_st (vector double, int, vector double *);
18503 void vec_vsx_st (vector double, int, double *);
18504 void vec_vsx_st (vector float, int, vector float *);
18505 void vec_vsx_st (vector float, int, float *);
18506 void vec_vsx_st (vector signed int, int, vector signed int *);
18507 void vec_vsx_st (vector signed int, int, int *);
18508 void vec_vsx_st (vector unsigned int, int, vector unsigned int *);
18509 void vec_vsx_st (vector unsigned int, int, unsigned int *);
18510 void vec_vsx_st (vector bool int, int, vector bool int *);
18511 void vec_vsx_st (vector bool int, int, unsigned int *);
18512 void vec_vsx_st (vector bool int, int, int *);
18513 void vec_vsx_st (vector signed short, int, vector signed short *);
18514 void vec_vsx_st (vector signed short, int, short *);
18515 void vec_vsx_st (vector unsigned short, int, vector unsigned short *);
18516 void vec_vsx_st (vector unsigned short, int, unsigned short *);
18517 void vec_vsx_st (vector bool short, int, vector bool short *);
18518 void vec_vsx_st (vector bool short, int, unsigned short *);
18519 void vec_vsx_st (vector pixel, int, vector pixel *);
18520 void vec_vsx_st (vector pixel, int, unsigned short *);
18521 void vec_vsx_st (vector pixel, int, short *);
18522 void vec_vsx_st (vector bool short, int, short *);
18523 void vec_vsx_st (vector signed char, int, vector signed char *);
18524 void vec_vsx_st (vector signed char, int, signed char *);
18525 void vec_vsx_st (vector unsigned char, int, vector unsigned char *);
18526 void vec_vsx_st (vector unsigned char, int, unsigned char *);
18527 void vec_vsx_st (vector bool char, int, vector bool char *);
18528 void vec_vsx_st (vector bool char, int, unsigned char *);
18529 void vec_vsx_st (vector bool char, int, signed char *);
18531 vector double vec_xxpermdi (vector double, vector double, const int);
18532 vector float vec_xxpermdi (vector float, vector float, const int);
18533 vector long long vec_xxpermdi (vector long long, vector long long, const int);
18534 vector unsigned long long vec_xxpermdi (vector unsigned long long,
18535                                         vector unsigned long long, const int);
18536 vector int vec_xxpermdi (vector int, vector int, const int);
18537 vector unsigned int vec_xxpermdi (vector unsigned int,
18538                                   vector unsigned int, const int);
18539 vector short vec_xxpermdi (vector short, vector short, const int);
18540 vector unsigned short vec_xxpermdi (vector unsigned short,
18541                                     vector unsigned short, const int);
18542 vector signed char vec_xxpermdi (vector signed char, vector signed char,
18543                                  const int);
18544 vector unsigned char vec_xxpermdi (vector unsigned char,
18545                                    vector unsigned char, const int);
18547 vector double vec_xxsldi (vector double, vector double, int);
18548 vector float vec_xxsldi (vector float, vector float, int);
18549 vector long long vec_xxsldi (vector long long, vector long long, int);
18550 vector unsigned long long vec_xxsldi (vector unsigned long long,
18551                                       vector unsigned long long, int);
18552 vector int vec_xxsldi (vector int, vector int, int);
18553 vector unsigned int vec_xxsldi (vector unsigned int, vector unsigned int, int);
18554 vector short vec_xxsldi (vector short, vector short, int);
18555 vector unsigned short vec_xxsldi (vector unsigned short,
18556                                   vector unsigned short, int);
18557 vector signed char vec_xxsldi (vector signed char, vector signed char, int);
18558 vector unsigned char vec_xxsldi (vector unsigned char,
18559                                  vector unsigned char, int);
18560 @end smallexample
18562 Note that the @samp{vec_ld} and @samp{vec_st} built-in functions always
18563 generate the AltiVec @samp{LVX} and @samp{STVX} instructions even
18564 if the VSX instruction set is available.  The @samp{vec_vsx_ld} and
18565 @samp{vec_vsx_st} built-in functions always generate the VSX @samp{LXVD2X},
18566 @samp{LXVW4X}, @samp{STXVD2X}, and @samp{STXVW4X} instructions.
18568 If the ISA 2.07 additions to the vector/scalar (power8-vector)
18569 instruction set are available, the following additional functions are
18570 available for both 32-bit and 64-bit targets.  For 64-bit targets, you
18571 can use @var{vector long} instead of @var{vector long long},
18572 @var{vector bool long} instead of @var{vector bool long long}, and
18573 @var{vector unsigned long} instead of @var{vector unsigned long long}.
18575 @smallexample
18576 vector long long vec_abs (vector long long);
18578 vector long long vec_add (vector long long, vector long long);
18579 vector unsigned long long vec_add (vector unsigned long long,
18580                                    vector unsigned long long);
18582 int vec_all_eq (vector long long, vector long long);
18583 int vec_all_eq (vector unsigned long long, vector unsigned long long);
18584 int vec_all_ge (vector long long, vector long long);
18585 int vec_all_ge (vector unsigned long long, vector unsigned long long);
18586 int vec_all_gt (vector long long, vector long long);
18587 int vec_all_gt (vector unsigned long long, vector unsigned long long);
18588 int vec_all_le (vector long long, vector long long);
18589 int vec_all_le (vector unsigned long long, vector unsigned long long);
18590 int vec_all_lt (vector long long, vector long long);
18591 int vec_all_lt (vector unsigned long long, vector unsigned long long);
18592 int vec_all_ne (vector long long, vector long long);
18593 int vec_all_ne (vector unsigned long long, vector unsigned long long);
18595 int vec_any_eq (vector long long, vector long long);
18596 int vec_any_eq (vector unsigned long long, vector unsigned long long);
18597 int vec_any_ge (vector long long, vector long long);
18598 int vec_any_ge (vector unsigned long long, vector unsigned long long);
18599 int vec_any_gt (vector long long, vector long long);
18600 int vec_any_gt (vector unsigned long long, vector unsigned long long);
18601 int vec_any_le (vector long long, vector long long);
18602 int vec_any_le (vector unsigned long long, vector unsigned long long);
18603 int vec_any_lt (vector long long, vector long long);
18604 int vec_any_lt (vector unsigned long long, vector unsigned long long);
18605 int vec_any_ne (vector long long, vector long long);
18606 int vec_any_ne (vector unsigned long long, vector unsigned long long);
18608 vector bool long long vec_cmpeq (vector bool long long, vector bool long long);
18610 vector long long vec_eqv (vector long long, vector long long);
18611 vector long long vec_eqv (vector bool long long, vector long long);
18612 vector long long vec_eqv (vector long long, vector bool long long);
18613 vector unsigned long long vec_eqv (vector unsigned long long,
18614                                    vector unsigned long long);
18615 vector unsigned long long vec_eqv (vector bool long long,
18616                                    vector unsigned long long);
18617 vector unsigned long long vec_eqv (vector unsigned long long,
18618                                    vector bool long long);
18619 vector int vec_eqv (vector int, vector int);
18620 vector int vec_eqv (vector bool int, vector int);
18621 vector int vec_eqv (vector int, vector bool int);
18622 vector unsigned int vec_eqv (vector unsigned int, vector unsigned int);
18623 vector unsigned int vec_eqv (vector bool unsigned int,
18624                              vector unsigned int);
18625 vector unsigned int vec_eqv (vector unsigned int,
18626                              vector bool unsigned int);
18627 vector short vec_eqv (vector short, vector short);
18628 vector short vec_eqv (vector bool short, vector short);
18629 vector short vec_eqv (vector short, vector bool short);
18630 vector unsigned short vec_eqv (vector unsigned short, vector unsigned short);
18631 vector unsigned short vec_eqv (vector bool unsigned short,
18632                                vector unsigned short);
18633 vector unsigned short vec_eqv (vector unsigned short,
18634                                vector bool unsigned short);
18635 vector signed char vec_eqv (vector signed char, vector signed char);
18636 vector signed char vec_eqv (vector bool signed char, vector signed char);
18637 vector signed char vec_eqv (vector signed char, vector bool signed char);
18638 vector unsigned char vec_eqv (vector unsigned char, vector unsigned char);
18639 vector unsigned char vec_eqv (vector bool unsigned char, vector unsigned char);
18640 vector unsigned char vec_eqv (vector unsigned char, vector bool unsigned char);
18642 vector long long vec_max (vector long long, vector long long);
18643 vector unsigned long long vec_max (vector unsigned long long,
18644                                    vector unsigned long long);
18646 vector signed int vec_mergee (vector signed int, vector signed int);
18647 vector unsigned int vec_mergee (vector unsigned int, vector unsigned int);
18648 vector bool int vec_mergee (vector bool int, vector bool int);
18650 vector signed int vec_mergeo (vector signed int, vector signed int);
18651 vector unsigned int vec_mergeo (vector unsigned int, vector unsigned int);
18652 vector bool int vec_mergeo (vector bool int, vector bool int);
18654 vector long long vec_min (vector long long, vector long long);
18655 vector unsigned long long vec_min (vector unsigned long long,
18656                                    vector unsigned long long);
18658 vector signed long long vec_nabs (vector signed long long);
18660 vector long long vec_nand (vector long long, vector long long);
18661 vector long long vec_nand (vector bool long long, vector long long);
18662 vector long long vec_nand (vector long long, vector bool long long);
18663 vector unsigned long long vec_nand (vector unsigned long long,
18664                                     vector unsigned long long);
18665 vector unsigned long long vec_nand (vector bool long long,
18666                                    vector unsigned long long);
18667 vector unsigned long long vec_nand (vector unsigned long long,
18668                                     vector bool long long);
18669 vector int vec_nand (vector int, vector int);
18670 vector int vec_nand (vector bool int, vector int);
18671 vector int vec_nand (vector int, vector bool int);
18672 vector unsigned int vec_nand (vector unsigned int, vector unsigned int);
18673 vector unsigned int vec_nand (vector bool unsigned int,
18674                               vector unsigned int);
18675 vector unsigned int vec_nand (vector unsigned int,
18676                               vector bool unsigned int);
18677 vector short vec_nand (vector short, vector short);
18678 vector short vec_nand (vector bool short, vector short);
18679 vector short vec_nand (vector short, vector bool short);
18680 vector unsigned short vec_nand (vector unsigned short, vector unsigned short);
18681 vector unsigned short vec_nand (vector bool unsigned short,
18682                                 vector unsigned short);
18683 vector unsigned short vec_nand (vector unsigned short,
18684                                 vector bool unsigned short);
18685 vector signed char vec_nand (vector signed char, vector signed char);
18686 vector signed char vec_nand (vector bool signed char, vector signed char);
18687 vector signed char vec_nand (vector signed char, vector bool signed char);
18688 vector unsigned char vec_nand (vector unsigned char, vector unsigned char);
18689 vector unsigned char vec_nand (vector bool unsigned char, vector unsigned char);
18690 vector unsigned char vec_nand (vector unsigned char, vector bool unsigned char);
18692 vector long long vec_orc (vector long long, vector long long);
18693 vector long long vec_orc (vector bool long long, vector long long);
18694 vector long long vec_orc (vector long long, vector bool long long);
18695 vector unsigned long long vec_orc (vector unsigned long long,
18696                                    vector unsigned long long);
18697 vector unsigned long long vec_orc (vector bool long long,
18698                                    vector unsigned long long);
18699 vector unsigned long long vec_orc (vector unsigned long long,
18700                                    vector bool long long);
18701 vector int vec_orc (vector int, vector int);
18702 vector int vec_orc (vector bool int, vector int);
18703 vector int vec_orc (vector int, vector bool int);
18704 vector unsigned int vec_orc (vector unsigned int, vector unsigned int);
18705 vector unsigned int vec_orc (vector bool unsigned int,
18706                              vector unsigned int);
18707 vector unsigned int vec_orc (vector unsigned int,
18708                              vector bool unsigned int);
18709 vector short vec_orc (vector short, vector short);
18710 vector short vec_orc (vector bool short, vector short);
18711 vector short vec_orc (vector short, vector bool short);
18712 vector unsigned short vec_orc (vector unsigned short, vector unsigned short);
18713 vector unsigned short vec_orc (vector bool unsigned short,
18714                                vector unsigned short);
18715 vector unsigned short vec_orc (vector unsigned short,
18716                                vector bool unsigned short);
18717 vector signed char vec_orc (vector signed char, vector signed char);
18718 vector signed char vec_orc (vector bool signed char, vector signed char);
18719 vector signed char vec_orc (vector signed char, vector bool signed char);
18720 vector unsigned char vec_orc (vector unsigned char, vector unsigned char);
18721 vector unsigned char vec_orc (vector bool unsigned char, vector unsigned char);
18722 vector unsigned char vec_orc (vector unsigned char, vector bool unsigned char);
18724 vector int vec_pack (vector long long, vector long long);
18725 vector unsigned int vec_pack (vector unsigned long long,
18726                               vector unsigned long long);
18727 vector bool int vec_pack (vector bool long long, vector bool long long);
18728 vector float vec_pack (vector double, vector double);
18730 vector int vec_packs (vector long long, vector long long);
18731 vector unsigned int vec_packs (vector unsigned long long,
18732                                vector unsigned long long);
18734 test_vsi_packsu_vssi_vssi (vector signed short x,
18736 vector unsigned char vec_packsu (vector signed short, vector signed short )
18737 vector unsigned char vec_packsu (vector unsigned short, vector unsigned short )
18738 vector unsigned short int vec_packsu (vector signed int, vector signed int);
18739 vector unsigned short int vec_packsu (vector unsigned int,
18740                                       vector unsigned int);
18741 vector unsigned int vec_packsu (vector long long, vector long long);
18742 vector unsigned int vec_packsu (vector unsigned long long,
18743                                 vector unsigned long long);
18744 vector unsigned int vec_packsu (vector signed long long,
18745                                 vector signed long long);
18747 vector unsigned char vec_popcnt (vector signed char);
18748 vector unsigned char vec_popcnt (vector unsigned char);
18749 vector unsigned short vec_popcnt (vector signed short);
18750 vector unsigned short vec_popcnt (vector unsigned short);
18751 vector unsigned int vec_popcnt (vector signed int);
18752 vector unsigned int vec_popcnt (vector unsigned int);
18753 vector unsigned long long vec_popcnt (vector signed long long);
18754 vector unsigned long long vec_popcnt (vector unsigned long long);
18756 vector long long vec_rl (vector long long,
18757                          vector unsigned long long);
18758 vector long long vec_rl (vector unsigned long long,
18759                          vector unsigned long long);
18761 vector long long vec_sl (vector long long, vector unsigned long long);
18762 vector long long vec_sl (vector unsigned long long,
18763                          vector unsigned long long);
18765 vector long long vec_sr (vector long long, vector unsigned long long);
18766 vector unsigned long long char vec_sr (vector unsigned long long,
18767                                        vector unsigned long long);
18769 vector long long vec_sra (vector long long, vector unsigned long long);
18770 vector unsigned long long vec_sra (vector unsigned long long,
18771                                    vector unsigned long long);
18773 vector long long vec_sub (vector long long, vector long long);
18774 vector unsigned long long vec_sub (vector unsigned long long,
18775                                    vector unsigned long long);
18777 vector long long vec_unpackh (vector int);
18778 vector unsigned long long vec_unpackh (vector unsigned int);
18780 vector long long vec_unpackl (vector int);
18781 vector unsigned long long vec_unpackl (vector unsigned int);
18783 vector long long vec_vaddudm (vector long long, vector long long);
18784 vector long long vec_vaddudm (vector bool long long, vector long long);
18785 vector long long vec_vaddudm (vector long long, vector bool long long);
18786 vector unsigned long long vec_vaddudm (vector unsigned long long,
18787                                        vector unsigned long long);
18788 vector unsigned long long vec_vaddudm (vector bool unsigned long long,
18789                                        vector unsigned long long);
18790 vector unsigned long long vec_vaddudm (vector unsigned long long,
18791                                        vector bool unsigned long long);
18793 vector long long vec_vbpermq (vector signed char, vector signed char);
18794 vector long long vec_vbpermq (vector unsigned char, vector unsigned char);
18796 vector unsigned char vec_bperm (vector unsigned char, vector unsigned char);
18797 vector unsigned char vec_bperm (vector unsigned long long,
18798                                 vector unsigned char);
18799 vector unsigned long long vec_bperm (vector unsigned __int128,
18800                                      vector unsigned char);
18802 vector long long vec_cntlz (vector long long);
18803 vector unsigned long long vec_cntlz (vector unsigned long long);
18804 vector int vec_cntlz (vector int);
18805 vector unsigned int vec_cntlz (vector int);
18806 vector short vec_cntlz (vector short);
18807 vector unsigned short vec_cntlz (vector unsigned short);
18808 vector signed char vec_cntlz (vector signed char);
18809 vector unsigned char vec_cntlz (vector unsigned char);
18811 vector long long vec_vclz (vector long long);
18812 vector unsigned long long vec_vclz (vector unsigned long long);
18813 vector int vec_vclz (vector int);
18814 vector unsigned int vec_vclz (vector int);
18815 vector short vec_vclz (vector short);
18816 vector unsigned short vec_vclz (vector unsigned short);
18817 vector signed char vec_vclz (vector signed char);
18818 vector unsigned char vec_vclz (vector unsigned char);
18820 vector signed char vec_vclzb (vector signed char);
18821 vector unsigned char vec_vclzb (vector unsigned char);
18823 vector long long vec_vclzd (vector long long);
18824 vector unsigned long long vec_vclzd (vector unsigned long long);
18826 vector short vec_vclzh (vector short);
18827 vector unsigned short vec_vclzh (vector unsigned short);
18829 vector int vec_vclzw (vector int);
18830 vector unsigned int vec_vclzw (vector int);
18832 vector signed char vec_vgbbd (vector signed char);
18833 vector unsigned char vec_vgbbd (vector unsigned char);
18835 vector long long vec_vmaxsd (vector long long, vector long long);
18837 vector unsigned long long vec_vmaxud (vector unsigned long long,
18838                                       unsigned vector long long);
18840 vector long long vec_vminsd (vector long long, vector long long);
18842 vector unsigned long long vec_vminud (vector long long,
18843                                       vector long long);
18845 vector int vec_vpksdss (vector long long, vector long long);
18846 vector unsigned int vec_vpksdss (vector long long, vector long long);
18848 vector unsigned int vec_vpkudus (vector unsigned long long,
18849                                  vector unsigned long long);
18851 vector int vec_vpkudum (vector long long, vector long long);
18852 vector unsigned int vec_vpkudum (vector unsigned long long,
18853                                  vector unsigned long long);
18854 vector bool int vec_vpkudum (vector bool long long, vector bool long long);
18856 vector long long vec_vpopcnt (vector long long);
18857 vector unsigned long long vec_vpopcnt (vector unsigned long long);
18858 vector int vec_vpopcnt (vector int);
18859 vector unsigned int vec_vpopcnt (vector int);
18860 vector short vec_vpopcnt (vector short);
18861 vector unsigned short vec_vpopcnt (vector unsigned short);
18862 vector signed char vec_vpopcnt (vector signed char);
18863 vector unsigned char vec_vpopcnt (vector unsigned char);
18865 vector signed char vec_vpopcntb (vector signed char);
18866 vector unsigned char vec_vpopcntb (vector unsigned char);
18868 vector long long vec_vpopcntd (vector long long);
18869 vector unsigned long long vec_vpopcntd (vector unsigned long long);
18871 vector short vec_vpopcnth (vector short);
18872 vector unsigned short vec_vpopcnth (vector unsigned short);
18874 vector int vec_vpopcntw (vector int);
18875 vector unsigned int vec_vpopcntw (vector int);
18877 vector long long vec_vrld (vector long long, vector unsigned long long);
18878 vector unsigned long long vec_vrld (vector unsigned long long,
18879                                     vector unsigned long long);
18881 vector long long vec_vsld (vector long long, vector unsigned long long);
18882 vector long long vec_vsld (vector unsigned long long,
18883                            vector unsigned long long);
18885 vector long long vec_vsrad (vector long long, vector unsigned long long);
18886 vector unsigned long long vec_vsrad (vector unsigned long long,
18887                                      vector unsigned long long);
18889 vector long long vec_vsrd (vector long long, vector unsigned long long);
18890 vector unsigned long long char vec_vsrd (vector unsigned long long,
18891                                          vector unsigned long long);
18893 vector long long vec_vsubudm (vector long long, vector long long);
18894 vector long long vec_vsubudm (vector bool long long, vector long long);
18895 vector long long vec_vsubudm (vector long long, vector bool long long);
18896 vector unsigned long long vec_vsubudm (vector unsigned long long,
18897                                        vector unsigned long long);
18898 vector unsigned long long vec_vsubudm (vector bool long long,
18899                                        vector unsigned long long);
18900 vector unsigned long long vec_vsubudm (vector unsigned long long,
18901                                        vector bool long long);
18903 vector long long vec_vupkhsw (vector int);
18904 vector unsigned long long vec_vupkhsw (vector unsigned int);
18906 vector long long vec_vupklsw (vector int);
18907 vector unsigned long long vec_vupklsw (vector int);
18908 @end smallexample
18910 If the ISA 2.07 additions to the vector/scalar (power8-vector)
18911 instruction set are available, the following additional functions are
18912 available for 64-bit targets.  New vector types
18913 (@var{vector __int128_t} and @var{vector __uint128_t}) are available
18914 to hold the @var{__int128_t} and @var{__uint128_t} types to use these
18915 builtins.
18917 The normal vector extract, and set operations work on
18918 @var{vector __int128_t} and @var{vector __uint128_t} types,
18919 but the index value must be 0.
18921 @smallexample
18922 vector __int128_t vec_vaddcuq (vector __int128_t, vector __int128_t);
18923 vector __uint128_t vec_vaddcuq (vector __uint128_t, vector __uint128_t);
18925 vector __int128_t vec_vadduqm (vector __int128_t, vector __int128_t);
18926 vector __uint128_t vec_vadduqm (vector __uint128_t, vector __uint128_t);
18928 vector __int128_t vec_vaddecuq (vector __int128_t, vector __int128_t,
18929                                 vector __int128_t);
18930 vector __uint128_t vec_vaddecuq (vector __uint128_t, vector __uint128_t,
18931                                  vector __uint128_t);
18933 vector __int128_t vec_vaddeuqm (vector __int128_t, vector __int128_t,
18934                                 vector __int128_t);
18935 vector __uint128_t vec_vaddeuqm (vector __uint128_t, vector __uint128_t,
18936                                  vector __uint128_t);
18938 vector __int128_t vec_vsubecuq (vector __int128_t, vector __int128_t,
18939                                 vector __int128_t);
18940 vector __uint128_t vec_vsubecuq (vector __uint128_t, vector __uint128_t,
18941                                  vector __uint128_t);
18943 vector __int128_t vec_vsubeuqm (vector __int128_t, vector __int128_t,
18944                                 vector __int128_t);
18945 vector __uint128_t vec_vsubeuqm (vector __uint128_t, vector __uint128_t,
18946                                  vector __uint128_t);
18948 vector __int128_t vec_vsubcuq (vector __int128_t, vector __int128_t);
18949 vector __uint128_t vec_vsubcuq (vector __uint128_t, vector __uint128_t);
18951 __int128_t vec_vsubuqm (__int128_t, __int128_t);
18952 __uint128_t vec_vsubuqm (__uint128_t, __uint128_t);
18954 vector __int128_t __builtin_bcdadd (vector __int128_t, vector__int128_t);
18955 int __builtin_bcdadd_lt (vector __int128_t, vector__int128_t);
18956 int __builtin_bcdadd_eq (vector __int128_t, vector__int128_t);
18957 int __builtin_bcdadd_gt (vector __int128_t, vector__int128_t);
18958 int __builtin_bcdadd_ov (vector __int128_t, vector__int128_t);
18959 vector __int128_t bcdsub (vector __int128_t, vector__int128_t);
18960 int __builtin_bcdsub_lt (vector __int128_t, vector__int128_t);
18961 int __builtin_bcdsub_eq (vector __int128_t, vector__int128_t);
18962 int __builtin_bcdsub_gt (vector __int128_t, vector__int128_t);
18963 int __builtin_bcdsub_ov (vector __int128_t, vector__int128_t);
18964 @end smallexample
18966 If the ISA 3.0 instruction set additions (@option{-mcpu=power9})
18967 are available:
18969 @smallexample
18970 vector unsigned long long vec_bperm (vector unsigned long long,
18971                                      vector unsigned char);
18973 vector bool char vec_cmpne (vector bool char, vector bool char);
18974 vector bool char vec_cmpne (vector signed char, vector signed char);
18975 vector bool char vec_cmpne (vector unsigned char, vector unsigned char);
18976 vector bool int vec_cmpne (vector bool int, vector bool int);
18977 vector bool int vec_cmpne (vector signed int, vector signed int);
18978 vector bool int vec_cmpne (vector unsigned int, vector unsigned int);
18979 vector bool long long vec_cmpne (vector bool long long, vector bool long long);
18980 vector bool long long vec_cmpne (vector signed long long,
18981                                  vector signed long long);
18982 vector bool long long vec_cmpne (vector unsigned long long,
18983                                  vector unsigned long long);
18984 vector bool short vec_cmpne (vector bool short, vector bool short);
18985 vector bool short vec_cmpne (vector signed short, vector signed short);
18986 vector bool short vec_cmpne (vector unsigned short, vector unsigned short);
18987 vector bool long long vec_cmpne (vector double, vector double);
18988 vector bool int vec_cmpne (vector float, vector float);
18990 vector float vec_extract_fp32_from_shorth (vector unsigned short);
18991 vector float vec_extract_fp32_from_shortl (vector unsigned short);
18993 vector long long vec_vctz (vector long long);
18994 vector unsigned long long vec_vctz (vector unsigned long long);
18995 vector int vec_vctz (vector int);
18996 vector unsigned int vec_vctz (vector int);
18997 vector short vec_vctz (vector short);
18998 vector unsigned short vec_vctz (vector unsigned short);
18999 vector signed char vec_vctz (vector signed char);
19000 vector unsigned char vec_vctz (vector unsigned char);
19002 vector signed char vec_vctzb (vector signed char);
19003 vector unsigned char vec_vctzb (vector unsigned char);
19005 vector long long vec_vctzd (vector long long);
19006 vector unsigned long long vec_vctzd (vector unsigned long long);
19008 vector short vec_vctzh (vector short);
19009 vector unsigned short vec_vctzh (vector unsigned short);
19011 vector int vec_vctzw (vector int);
19012 vector unsigned int vec_vctzw (vector int);
19014 long long vec_vextract4b (const vector signed char, const int);
19015 long long vec_vextract4b (const vector unsigned char, const int);
19017 vector signed char vec_insert4b (vector int, vector signed char, const int);
19018 vector unsigned char vec_insert4b (vector unsigned int, vector unsigned char,
19019                                    const int);
19020 vector signed char vec_insert4b (long long, vector signed char, const int);
19021 vector unsigned char vec_insert4b (long long, vector unsigned char, const int);
19023 vector unsigned int vec_parity_lsbb (vector signed int);
19024 vector unsigned int vec_parity_lsbb (vector unsigned int);
19025 vector unsigned __int128 vec_parity_lsbb (vector signed __int128);
19026 vector unsigned __int128 vec_parity_lsbb (vector unsigned __int128);
19027 vector unsigned long long vec_parity_lsbb (vector signed long long);
19028 vector unsigned long long vec_parity_lsbb (vector unsigned long long);
19030 vector int vec_vprtyb (vector int);
19031 vector unsigned int vec_vprtyb (vector unsigned int);
19032 vector long long vec_vprtyb (vector long long);
19033 vector unsigned long long vec_vprtyb (vector unsigned long long);
19035 vector int vec_vprtybw (vector int);
19036 vector unsigned int vec_vprtybw (vector unsigned int);
19038 vector long long vec_vprtybd (vector long long);
19039 vector unsigned long long vec_vprtybd (vector unsigned long long);
19040 @end smallexample
19042 On 64-bit targets, if the ISA 3.0 additions (@option{-mcpu=power9})
19043 are available:
19045 @smallexample
19046 vector long vec_vprtyb (vector long);
19047 vector unsigned long vec_vprtyb (vector unsigned long);
19048 vector __int128_t vec_vprtyb (vector __int128_t);
19049 vector __uint128_t vec_vprtyb (vector __uint128_t);
19051 vector long vec_vprtybd (vector long);
19052 vector unsigned long vec_vprtybd (vector unsigned long);
19054 vector __int128_t vec_vprtybq (vector __int128_t);
19055 vector __uint128_t vec_vprtybd (vector __uint128_t);
19056 @end smallexample
19058 The following built-in vector functions are available for the PowerPC family
19059 of processors, starting with ISA 3.0 or later (@option{-mcpu=power9}):
19060 @smallexample
19061 __vector unsigned char
19062 vec_slv (__vector unsigned char src, __vector unsigned char shift_distance);
19063 __vector unsigned char
19064 vec_srv (__vector unsigned char src, __vector unsigned char shift_distance);
19065 @end smallexample
19067 The @code{vec_slv} and @code{vec_srv} functions operate on
19068 all of the bytes of their @code{src} and @code{shift_distance}
19069 arguments in parallel.  The behavior of the @code{vec_slv} is as if
19070 there existed a temporary array of 17 unsigned characters
19071 @code{slv_array} within which elements 0 through 15 are the same as
19072 the entries in the @code{src} array and element 16 equals 0.  The
19073 result returned from the @code{vec_slv} function is a
19074 @code{__vector} of 16 unsigned characters within which element
19075 @code{i} is computed using the C expression
19076 @code{0xff & (*((unsigned short *)(slv_array + i)) << (0x07 &
19077 shift_distance[i]))},
19078 with this resulting value coerced to the @code{unsigned char} type.
19079 The behavior of the @code{vec_srv} is as if
19080 there existed a temporary array of 17 unsigned characters
19081 @code{srv_array} within which element 0 equals zero and
19082 elements 1 through 16 equal the elements 0 through 15 of
19083 the @code{src} array.  The
19084 result returned from the @code{vec_srv} function is a
19085 @code{__vector} of 16 unsigned characters within which element
19086 @code{i} is computed using the C expression
19087 @code{0xff & (*((unsigned short *)(srv_array + i)) >>
19088 (0x07 & shift_distance[i]))},
19089 with this resulting value coerced to the @code{unsigned char} type.
19091 The following built-in functions are available for the PowerPC family
19092 of processors, starting with ISA 3.0 or later (@option{-mcpu=power9}):
19093 @smallexample
19094 __vector unsigned char
19095 vec_absd (__vector unsigned char arg1, __vector unsigned char arg2);
19096 __vector unsigned short
19097 vec_absd (__vector unsigned short arg1, __vector unsigned short arg2);
19098 __vector unsigned int
19099 vec_absd (__vector unsigned int arg1, __vector unsigned int arg2);
19101 __vector unsigned char
19102 vec_absdb (__vector unsigned char arg1, __vector unsigned char arg2);
19103 __vector unsigned short
19104 vec_absdh (__vector unsigned short arg1, __vector unsigned short arg2);
19105 __vector unsigned int
19106 vec_absdw (__vector unsigned int arg1, __vector unsigned int arg2);
19107 @end smallexample
19109 The @code{vec_absd}, @code{vec_absdb}, @code{vec_absdh}, and
19110 @code{vec_absdw} built-in functions each computes the absolute
19111 differences of the pairs of vector elements supplied in its two vector
19112 arguments, placing the absolute differences into the corresponding
19113 elements of the vector result.
19115 The following built-in functions are available for the PowerPC family
19116 of processors, starting with ISA 3.0 or later (@option{-mcpu=power9}):
19117 @smallexample
19118 __vector unsigned int
19119 vec_extract_exp (__vector float source);
19120 __vector unsigned long long int
19121 vec_extract_exp (__vector double source);
19123 __vector unsigned int
19124 vec_extract_sig (__vector float source);
19125 __vector unsigned long long int
19126 vec_extract_sig (__vector double source);
19128 __vector float
19129 vec_insert_exp (__vector unsigned int significands,
19130                 __vector unsigned int exponents);
19131 __vector float
19132 vec_insert_exp (__vector unsigned float significands,
19133                 __vector unsigned int exponents);
19134 __vector double
19135 vec_insert_exp (__vector unsigned long long int significands,
19136                 __vector unsigned long long int exponents);
19137 __vector double
19138 vec_insert_exp (__vector unsigned double significands,
19139                 __vector unsigned long long int exponents);
19141 __vector bool int vec_test_data_class (__vector float source,
19142                                        const int condition);
19143 __vector bool long long int vec_test_data_class (__vector double source,
19144                                                  const int condition);
19145 @end smallexample
19147 The @code{vec_extract_sig} and @code{vec_extract_exp} built-in
19148 functions return vectors representing the significands and biased
19149 exponent values of their @code{source} arguments respectively.
19150 Within the result vector returned by @code{vec_extract_sig}, the
19151 @code{0x800000} bit of each vector element returned when the
19152 function's @code{source} argument is of type @code{float} is set to 1
19153 if the corresponding floating point value is in normalized form.
19154 Otherwise, this bit is set to 0.  When the @code{source} argument is
19155 of type @code{double}, the @code{0x10000000000000} bit within each of
19156 the result vector's elements is set according to the same rules.
19157 Note that the sign of the significand is not represented in the result
19158 returned from the @code{vec_extract_sig} function.  To extract the
19159 sign bits, use the
19160 @code{vec_cpsgn} function, which returns a new vector within which all
19161 of the sign bits of its second argument vector are overwritten with the
19162 sign bits copied from the coresponding elements of its first argument
19163 vector, and all other (non-sign) bits of the second argument vector
19164 are copied unchanged into the result vector.
19166 The @code{vec_insert_exp} built-in functions return a vector of
19167 single- or double-precision floating
19168 point values constructed by assembling the values of their
19169 @code{significands} and @code{exponents} arguments into the
19170 corresponding elements of the returned vector.
19171 The sign of each
19172 element of the result is copied from the most significant bit of the
19173 corresponding entry within the @code{significands} argument.
19174 Note that the relevant
19175 bits of the @code{significands} argument are the same, for both integer
19176 and floating point types.
19178 significand and exponent components of each element of the result are
19179 composed of the least significant bits of the corresponding
19180 @code{significands} element and the least significant bits of the
19181 corresponding @code{exponents} element.
19183 The @code{vec_test_data_class} built-in function returns a vector
19184 representing the results of testing the @code{source} vector for the
19185 condition selected by the @code{condition} argument.  The
19186 @code{condition} argument must be a compile-time constant integer with
19187 value not exceeding 127.  The
19188 @code{condition} argument is encoded as a bitmask with each bit
19189 enabling the testing of a different condition, as characterized by the
19190 following:
19191 @smallexample
19192 0x40    Test for NaN
19193 0x20    Test for +Infinity
19194 0x10    Test for -Infinity
19195 0x08    Test for +Zero
19196 0x04    Test for -Zero
19197 0x02    Test for +Denormal
19198 0x01    Test for -Denormal
19199 @end smallexample
19201 If any of the enabled test conditions is true, the corresponding entry
19202 in the result vector is -1.  Otherwise (all of the enabled test
19203 conditions are false), the corresponding entry of the result vector is 0.
19205 The following built-in functions are available for the PowerPC family
19206 of processors, starting with ISA 3.0 or later (@option{-mcpu=power9}):
19207 @smallexample
19208 vector unsigned int vec_rlmi (vector unsigned int, vector unsigned int,
19209                               vector unsigned int);
19210 vector unsigned long long vec_rlmi (vector unsigned long long,
19211                                     vector unsigned long long,
19212                                     vector unsigned long long);
19213 vector unsigned int vec_rlnm (vector unsigned int, vector unsigned int,
19214                               vector unsigned int);
19215 vector unsigned long long vec_rlnm (vector unsigned long long,
19216                                     vector unsigned long long,
19217                                     vector unsigned long long);
19218 vector unsigned int vec_vrlnm (vector unsigned int, vector unsigned int);
19219 vector unsigned long long vec_vrlnm (vector unsigned long long,
19220                                      vector unsigned long long);
19221 @end smallexample
19223 The result of @code{vec_rlmi} is obtained by rotating each element of
19224 the first argument vector left and inserting it under mask into the
19225 second argument vector.  The third argument vector contains the mask
19226 beginning in bits 11:15, the mask end in bits 19:23, and the shift
19227 count in bits 27:31, of each element.
19229 The result of @code{vec_rlnm} is obtained by rotating each element of
19230 the first argument vector left and ANDing it with a mask specified by
19231 the second and third argument vectors.  The second argument vector
19232 contains the shift count for each element in the low-order byte.  The
19233 third argument vector contains the mask end for each element in the
19234 low-order byte, with the mask begin in the next higher byte.
19236 The result of @code{vec_vrlnm} is obtained by rotating each element
19237 of the first argument vector left and ANDing it with a mask.  The
19238 second argument vector contains the mask  beginning in bits 11:15,
19239 the mask end in bits 19:23, and the shift count in bits 27:31,
19240 of each element.
19242 If the ISA 3.0 instruction set additions (@option{-mcpu=power9})
19243 are available:
19244 @smallexample
19245 vector signed bool char vec_revb (vector signed char);
19246 vector signed char vec_revb (vector signed char);
19247 vector unsigned char vec_revb (vector unsigned char);
19248 vector bool short vec_revb (vector bool short);
19249 vector short vec_revb (vector short);
19250 vector unsigned short vec_revb (vector unsigned short);
19251 vector bool int vec_revb (vector bool int);
19252 vector int vec_revb (vector int);
19253 vector unsigned int vec_revb (vector unsigned int);
19254 vector float vec_revb (vector float);
19255 vector bool long long vec_revb (vector bool long long);
19256 vector long long vec_revb (vector long long);
19257 vector unsigned long long vec_revb (vector unsigned long long);
19258 vector double vec_revb (vector double);
19259 @end smallexample
19261 On 64-bit targets, if the ISA 3.0 additions (@option{-mcpu=power9})
19262 are available:
19263 @smallexample
19264 vector long vec_revb (vector long);
19265 vector unsigned long vec_revb (vector unsigned long);
19266 vector __int128_t vec_revb (vector __int128_t);
19267 vector __uint128_t vec_revb (vector __uint128_t);
19268 @end smallexample
19270 The @code{vec_revb} built-in function reverses the bytes on an element
19271 by element basis.  A vector of @code{vector unsigned char} or
19272 @code{vector signed char} reverses the bytes in the whole word.
19274 If the cryptographic instructions are enabled (@option{-mcrypto} or
19275 @option{-mcpu=power8}), the following builtins are enabled.
19277 @smallexample
19278 vector unsigned long long __builtin_crypto_vsbox (vector unsigned long long);
19280 vector unsigned long long __builtin_crypto_vcipher (vector unsigned long long,
19281                                                     vector unsigned long long);
19283 vector unsigned long long __builtin_crypto_vcipherlast
19284                                      (vector unsigned long long,
19285                                       vector unsigned long long);
19287 vector unsigned long long __builtin_crypto_vncipher (vector unsigned long long,
19288                                                      vector unsigned long long);
19290 vector unsigned long long __builtin_crypto_vncipherlast
19291                                      (vector unsigned long long,
19292                                       vector unsigned long long);
19294 vector unsigned char __builtin_crypto_vpermxor (vector unsigned char,
19295                                                 vector unsigned char,
19296                                                 vector unsigned char);
19298 vector unsigned short __builtin_crypto_vpermxor (vector unsigned short,
19299                                                  vector unsigned short,
19300                                                  vector unsigned short);
19302 vector unsigned int __builtin_crypto_vpermxor (vector unsigned int,
19303                                                vector unsigned int,
19304                                                vector unsigned int);
19306 vector unsigned long long __builtin_crypto_vpermxor (vector unsigned long long,
19307                                                      vector unsigned long long,
19308                                                      vector unsigned long long);
19310 vector unsigned char __builtin_crypto_vpmsumb (vector unsigned char,
19311                                                vector unsigned char);
19313 vector unsigned short __builtin_crypto_vpmsumb (vector unsigned short,
19314                                                 vector unsigned short);
19316 vector unsigned int __builtin_crypto_vpmsumb (vector unsigned int,
19317                                               vector unsigned int);
19319 vector unsigned long long __builtin_crypto_vpmsumb (vector unsigned long long,
19320                                                     vector unsigned long long);
19322 vector unsigned long long __builtin_crypto_vshasigmad
19323                                (vector unsigned long long, int, int);
19325 vector unsigned int __builtin_crypto_vshasigmaw (vector unsigned int,
19326                                                  int, int);
19327 @end smallexample
19329 The second argument to @var{__builtin_crypto_vshasigmad} and
19330 @var{__builtin_crypto_vshasigmaw} must be a constant
19331 integer that is 0 or 1.  The third argument to these built-in functions
19332 must be a constant integer in the range of 0 to 15.
19334 If the ISA 3.0 instruction set additions 
19335 are enabled (@option{-mcpu=power9}), the following additional
19336 functions are available for both 32-bit and 64-bit targets.
19338 vector short vec_xl (int, vector short *);
19339 vector short vec_xl (int, short *);
19340 vector unsigned short vec_xl (int, vector unsigned short *);
19341 vector unsigned short vec_xl (int, unsigned short *);
19342 vector char vec_xl (int, vector char *);
19343 vector char vec_xl (int, char *);
19344 vector unsigned char vec_xl (int, vector unsigned char *);
19345 vector unsigned char vec_xl (int, unsigned char *);
19347 void vec_xst (vector short, int, vector short *);
19348 void vec_xst (vector short, int, short *);
19349 void vec_xst (vector unsigned short, int, vector unsigned short *);
19350 void vec_xst (vector unsigned short, int, unsigned short *);
19351 void vec_xst (vector char, int, vector char *);
19352 void vec_xst (vector char, int, char *);
19353 void vec_xst (vector unsigned char, int, vector unsigned char *);
19354 void vec_xst (vector unsigned char, int, unsigned char *);
19356 @node PowerPC Hardware Transactional Memory Built-in Functions
19357 @subsection PowerPC Hardware Transactional Memory Built-in Functions
19358 GCC provides two interfaces for accessing the Hardware Transactional
19359 Memory (HTM) instructions available on some of the PowerPC family
19360 of processors (eg, POWER8).  The two interfaces come in a low level
19361 interface, consisting of built-in functions specific to PowerPC and a
19362 higher level interface consisting of inline functions that are common
19363 between PowerPC and S/390.
19365 @subsubsection PowerPC HTM Low Level Built-in Functions
19367 The following low level built-in functions are available with
19368 @option{-mhtm} or @option{-mcpu=CPU} where CPU is `power8' or later.
19369 They all generate the machine instruction that is part of the name.
19371 The HTM builtins (with the exception of @code{__builtin_tbegin}) return
19372 the full 4-bit condition register value set by their associated hardware
19373 instruction.  The header file @code{htmintrin.h} defines some macros that can
19374 be used to decipher the return value.  The @code{__builtin_tbegin} builtin
19375 returns a simple true or false value depending on whether a transaction was
19376 successfully started or not.  The arguments of the builtins match exactly the
19377 type and order of the associated hardware instruction's operands, except for
19378 the @code{__builtin_tcheck} builtin, which does not take any input arguments.
19379 Refer to the ISA manual for a description of each instruction's operands.
19381 @smallexample
19382 unsigned int __builtin_tbegin (unsigned int)
19383 unsigned int __builtin_tend (unsigned int)
19385 unsigned int __builtin_tabort (unsigned int)
19386 unsigned int __builtin_tabortdc (unsigned int, unsigned int, unsigned int)
19387 unsigned int __builtin_tabortdci (unsigned int, unsigned int, int)
19388 unsigned int __builtin_tabortwc (unsigned int, unsigned int, unsigned int)
19389 unsigned int __builtin_tabortwci (unsigned int, unsigned int, int)
19391 unsigned int __builtin_tcheck (void)
19392 unsigned int __builtin_treclaim (unsigned int)
19393 unsigned int __builtin_trechkpt (void)
19394 unsigned int __builtin_tsr (unsigned int)
19395 @end smallexample
19397 In addition to the above HTM built-ins, we have added built-ins for
19398 some common extended mnemonics of the HTM instructions:
19400 @smallexample
19401 unsigned int __builtin_tendall (void)
19402 unsigned int __builtin_tresume (void)
19403 unsigned int __builtin_tsuspend (void)
19404 @end smallexample
19406 Note that the semantics of the above HTM builtins are required to mimic
19407 the locking semantics used for critical sections.  Builtins that are used
19408 to create a new transaction or restart a suspended transaction must have
19409 lock acquisition like semantics while those builtins that end or suspend a
19410 transaction must have lock release like semantics.  Specifically, this must
19411 mimic lock semantics as specified by C++11, for example: Lock acquisition is
19412 as-if an execution of __atomic_exchange_n(&globallock,1,__ATOMIC_ACQUIRE)
19413 that returns 0, and lock release is as-if an execution of
19414 __atomic_store(&globallock,0,__ATOMIC_RELEASE), with globallock being an
19415 implicit implementation-defined lock used for all transactions.  The HTM
19416 instructions associated with with the builtins inherently provide the
19417 correct acquisition and release hardware barriers required.  However,
19418 the compiler must also be prohibited from moving loads and stores across
19419 the builtins in a way that would violate their semantics.  This has been
19420 accomplished by adding memory barriers to the associated HTM instructions
19421 (which is a conservative approach to provide acquire and release semantics).
19422 Earlier versions of the compiler did not treat the HTM instructions as
19423 memory barriers.  A @code{__TM_FENCE__} macro has been added, which can
19424 be used to determine whether the current compiler treats HTM instructions
19425 as memory barriers or not.  This allows the user to explicitly add memory
19426 barriers to their code when using an older version of the compiler.
19428 The following set of built-in functions are available to gain access
19429 to the HTM specific special purpose registers.
19431 @smallexample
19432 unsigned long __builtin_get_texasr (void)
19433 unsigned long __builtin_get_texasru (void)
19434 unsigned long __builtin_get_tfhar (void)
19435 unsigned long __builtin_get_tfiar (void)
19437 void __builtin_set_texasr (unsigned long);
19438 void __builtin_set_texasru (unsigned long);
19439 void __builtin_set_tfhar (unsigned long);
19440 void __builtin_set_tfiar (unsigned long);
19441 @end smallexample
19443 Example usage of these low level built-in functions may look like:
19445 @smallexample
19446 #include <htmintrin.h>
19448 int num_retries = 10;
19450 while (1)
19451   @{
19452     if (__builtin_tbegin (0))
19453       @{
19454         /* Transaction State Initiated.  */
19455         if (is_locked (lock))
19456           __builtin_tabort (0);
19457         ... transaction code...
19458         __builtin_tend (0);
19459         break;
19460       @}
19461     else
19462       @{
19463         /* Transaction State Failed.  Use locks if the transaction
19464            failure is "persistent" or we've tried too many times.  */
19465         if (num_retries-- <= 0
19466             || _TEXASRU_FAILURE_PERSISTENT (__builtin_get_texasru ()))
19467           @{
19468             acquire_lock (lock);
19469             ... non transactional fallback path...
19470             release_lock (lock);
19471             break;
19472           @}
19473       @}
19474   @}
19475 @end smallexample
19477 One final built-in function has been added that returns the value of
19478 the 2-bit Transaction State field of the Machine Status Register (MSR)
19479 as stored in @code{CR0}.
19481 @smallexample
19482 unsigned long __builtin_ttest (void)
19483 @end smallexample
19485 This built-in can be used to determine the current transaction state
19486 using the following code example:
19488 @smallexample
19489 #include <htmintrin.h>
19491 unsigned char tx_state = _HTM_STATE (__builtin_ttest ());
19493 if (tx_state == _HTM_TRANSACTIONAL)
19494   @{
19495     /* Code to use in transactional state.  */
19496   @}
19497 else if (tx_state == _HTM_NONTRANSACTIONAL)
19498   @{
19499     /* Code to use in non-transactional state.  */
19500   @}
19501 else if (tx_state == _HTM_SUSPENDED)
19502   @{
19503     /* Code to use in transaction suspended state.  */
19504   @}
19505 @end smallexample
19507 @subsubsection PowerPC HTM High Level Inline Functions
19509 The following high level HTM interface is made available by including
19510 @code{<htmxlintrin.h>} and using @option{-mhtm} or @option{-mcpu=CPU}
19511 where CPU is `power8' or later.  This interface is common between PowerPC
19512 and S/390, allowing users to write one HTM source implementation that
19513 can be compiled and executed on either system.
19515 @smallexample
19516 long __TM_simple_begin (void)
19517 long __TM_begin (void* const TM_buff)
19518 long __TM_end (void)
19519 void __TM_abort (void)
19520 void __TM_named_abort (unsigned char const code)
19521 void __TM_resume (void)
19522 void __TM_suspend (void)
19524 long __TM_is_user_abort (void* const TM_buff)
19525 long __TM_is_named_user_abort (void* const TM_buff, unsigned char *code)
19526 long __TM_is_illegal (void* const TM_buff)
19527 long __TM_is_footprint_exceeded (void* const TM_buff)
19528 long __TM_nesting_depth (void* const TM_buff)
19529 long __TM_is_nested_too_deep(void* const TM_buff)
19530 long __TM_is_conflict(void* const TM_buff)
19531 long __TM_is_failure_persistent(void* const TM_buff)
19532 long __TM_failure_address(void* const TM_buff)
19533 long long __TM_failure_code(void* const TM_buff)
19534 @end smallexample
19536 Using these common set of HTM inline functions, we can create
19537 a more portable version of the HTM example in the previous
19538 section that will work on either PowerPC or S/390:
19540 @smallexample
19541 #include <htmxlintrin.h>
19543 int num_retries = 10;
19544 TM_buff_type TM_buff;
19546 while (1)
19547   @{
19548     if (__TM_begin (TM_buff) == _HTM_TBEGIN_STARTED)
19549       @{
19550         /* Transaction State Initiated.  */
19551         if (is_locked (lock))
19552           __TM_abort ();
19553         ... transaction code...
19554         __TM_end ();
19555         break;
19556       @}
19557     else
19558       @{
19559         /* Transaction State Failed.  Use locks if the transaction
19560            failure is "persistent" or we've tried too many times.  */
19561         if (num_retries-- <= 0
19562             || __TM_is_failure_persistent (TM_buff))
19563           @{
19564             acquire_lock (lock);
19565             ... non transactional fallback path...
19566             release_lock (lock);
19567             break;
19568           @}
19569       @}
19570   @}
19571 @end smallexample
19573 @node PowerPC Atomic Memory Operation Functions
19574 @subsection PowerPC Atomic Memory Operation Functions
19575 ISA 3.0 of the PowerPC added new atomic memory operation (amo)
19576 instructions.  GCC provides support for these instructions in 64-bit
19577 environments.  All of the functions are declared in the include file
19578 @code{amo.h}.
19580 The functions supported are:
19582 @smallexample
19583 #include <amo.h>
19585 uint32_t amo_lwat_add (uint32_t *, uint32_t);
19586 uint32_t amo_lwat_xor (uint32_t *, uint32_t);
19587 uint32_t amo_lwat_ior (uint32_t *, uint32_t);
19588 uint32_t amo_lwat_and (uint32_t *, uint32_t);
19589 uint32_t amo_lwat_umax (uint32_t *, uint32_t);
19590 uint32_t amo_lwat_umin (uint32_t *, uint32_t);
19591 uint32_t amo_lwat_swap (uint32_t *, uint32_t);
19593 int32_t amo_lwat_sadd (int32_t *, int32_t);
19594 int32_t amo_lwat_smax (int32_t *, int32_t);
19595 int32_t amo_lwat_smin (int32_t *, int32_t);
19596 int32_t amo_lwat_sswap (int32_t *, int32_t);
19598 uint64_t amo_ldat_add (uint64_t *, uint64_t);
19599 uint64_t amo_ldat_xor (uint64_t *, uint64_t);
19600 uint64_t amo_ldat_ior (uint64_t *, uint64_t);
19601 uint64_t amo_ldat_and (uint64_t *, uint64_t);
19602 uint64_t amo_ldat_umax (uint64_t *, uint64_t);
19603 uint64_t amo_ldat_umin (uint64_t *, uint64_t);
19604 uint64_t amo_ldat_swap (uint64_t *, uint64_t);
19606 int64_t amo_ldat_sadd (int64_t *, int64_t);
19607 int64_t amo_ldat_smax (int64_t *, int64_t);
19608 int64_t amo_ldat_smin (int64_t *, int64_t);
19609 int64_t amo_ldat_sswap (int64_t *, int64_t);
19611 void amo_stwat_add (uint32_t *, uint32_t);
19612 void amo_stwat_xor (uint32_t *, uint32_t);
19613 void amo_stwat_ior (uint32_t *, uint32_t);
19614 void amo_stwat_and (uint32_t *, uint32_t);
19615 void amo_stwat_umax (uint32_t *, uint32_t);
19616 void amo_stwat_umin (uint32_t *, uint32_t);
19618 void amo_stwat_sadd (int32_t *, int32_t);
19619 void amo_stwat_smax (int32_t *, int32_t);
19620 void amo_stwat_smin (int32_t *, int32_t);
19622 void amo_stdat_add (uint64_t *, uint64_t);
19623 void amo_stdat_xor (uint64_t *, uint64_t);
19624 void amo_stdat_ior (uint64_t *, uint64_t);
19625 void amo_stdat_and (uint64_t *, uint64_t);
19626 void amo_stdat_umax (uint64_t *, uint64_t);
19627 void amo_stdat_umin (uint64_t *, uint64_t);
19629 void amo_stdat_sadd (int64_t *, int64_t);
19630 void amo_stdat_smax (int64_t *, int64_t);
19631 void amo_stdat_smin (int64_t *, int64_t);
19632 @end smallexample
19634 @node RX Built-in Functions
19635 @subsection RX Built-in Functions
19636 GCC supports some of the RX instructions which cannot be expressed in
19637 the C programming language via the use of built-in functions.  The
19638 following functions are supported:
19640 @deftypefn {Built-in Function}  void __builtin_rx_brk (void)
19641 Generates the @code{brk} machine instruction.
19642 @end deftypefn
19644 @deftypefn {Built-in Function}  void __builtin_rx_clrpsw (int)
19645 Generates the @code{clrpsw} machine instruction to clear the specified
19646 bit in the processor status word.
19647 @end deftypefn
19649 @deftypefn {Built-in Function}  void __builtin_rx_int (int)
19650 Generates the @code{int} machine instruction to generate an interrupt
19651 with the specified value.
19652 @end deftypefn
19654 @deftypefn {Built-in Function}  void __builtin_rx_machi (int, int)
19655 Generates the @code{machi} machine instruction to add the result of
19656 multiplying the top 16 bits of the two arguments into the
19657 accumulator.
19658 @end deftypefn
19660 @deftypefn {Built-in Function}  void __builtin_rx_maclo (int, int)
19661 Generates the @code{maclo} machine instruction to add the result of
19662 multiplying the bottom 16 bits of the two arguments into the
19663 accumulator.
19664 @end deftypefn
19666 @deftypefn {Built-in Function}  void __builtin_rx_mulhi (int, int)
19667 Generates the @code{mulhi} machine instruction to place the result of
19668 multiplying the top 16 bits of the two arguments into the
19669 accumulator.
19670 @end deftypefn
19672 @deftypefn {Built-in Function}  void __builtin_rx_mullo (int, int)
19673 Generates the @code{mullo} machine instruction to place the result of
19674 multiplying the bottom 16 bits of the two arguments into the
19675 accumulator.
19676 @end deftypefn
19678 @deftypefn {Built-in Function}  int  __builtin_rx_mvfachi (void)
19679 Generates the @code{mvfachi} machine instruction to read the top
19680 32 bits of the accumulator.
19681 @end deftypefn
19683 @deftypefn {Built-in Function}  int  __builtin_rx_mvfacmi (void)
19684 Generates the @code{mvfacmi} machine instruction to read the middle
19685 32 bits of the accumulator.
19686 @end deftypefn
19688 @deftypefn {Built-in Function}  int __builtin_rx_mvfc (int)
19689 Generates the @code{mvfc} machine instruction which reads the control
19690 register specified in its argument and returns its value.
19691 @end deftypefn
19693 @deftypefn {Built-in Function}  void __builtin_rx_mvtachi (int)
19694 Generates the @code{mvtachi} machine instruction to set the top
19695 32 bits of the accumulator.
19696 @end deftypefn
19698 @deftypefn {Built-in Function}  void __builtin_rx_mvtaclo (int)
19699 Generates the @code{mvtaclo} machine instruction to set the bottom
19700 32 bits of the accumulator.
19701 @end deftypefn
19703 @deftypefn {Built-in Function}  void __builtin_rx_mvtc (int reg, int val)
19704 Generates the @code{mvtc} machine instruction which sets control
19705 register number @code{reg} to @code{val}.
19706 @end deftypefn
19708 @deftypefn {Built-in Function}  void __builtin_rx_mvtipl (int)
19709 Generates the @code{mvtipl} machine instruction set the interrupt
19710 priority level.
19711 @end deftypefn
19713 @deftypefn {Built-in Function}  void __builtin_rx_racw (int)
19714 Generates the @code{racw} machine instruction to round the accumulator
19715 according to the specified mode.
19716 @end deftypefn
19718 @deftypefn {Built-in Function}  int __builtin_rx_revw (int)
19719 Generates the @code{revw} machine instruction which swaps the bytes in
19720 the argument so that bits 0--7 now occupy bits 8--15 and vice versa,
19721 and also bits 16--23 occupy bits 24--31 and vice versa.
19722 @end deftypefn
19724 @deftypefn {Built-in Function}  void __builtin_rx_rmpa (void)
19725 Generates the @code{rmpa} machine instruction which initiates a
19726 repeated multiply and accumulate sequence.
19727 @end deftypefn
19729 @deftypefn {Built-in Function}  void __builtin_rx_round (float)
19730 Generates the @code{round} machine instruction which returns the
19731 floating-point argument rounded according to the current rounding mode
19732 set in the floating-point status word register.
19733 @end deftypefn
19735 @deftypefn {Built-in Function}  int __builtin_rx_sat (int)
19736 Generates the @code{sat} machine instruction which returns the
19737 saturated value of the argument.
19738 @end deftypefn
19740 @deftypefn {Built-in Function}  void __builtin_rx_setpsw (int)
19741 Generates the @code{setpsw} machine instruction to set the specified
19742 bit in the processor status word.
19743 @end deftypefn
19745 @deftypefn {Built-in Function}  void __builtin_rx_wait (void)
19746 Generates the @code{wait} machine instruction.
19747 @end deftypefn
19749 @node S/390 System z Built-in Functions
19750 @subsection S/390 System z Built-in Functions
19751 @deftypefn {Built-in Function} int __builtin_tbegin (void*)
19752 Generates the @code{tbegin} machine instruction starting a
19753 non-constrained hardware transaction.  If the parameter is non-NULL the
19754 memory area is used to store the transaction diagnostic buffer and
19755 will be passed as first operand to @code{tbegin}.  This buffer can be
19756 defined using the @code{struct __htm_tdb} C struct defined in
19757 @code{htmintrin.h} and must reside on a double-word boundary.  The
19758 second tbegin operand is set to @code{0xff0c}. This enables
19759 save/restore of all GPRs and disables aborts for FPR and AR
19760 manipulations inside the transaction body.  The condition code set by
19761 the tbegin instruction is returned as integer value.  The tbegin
19762 instruction by definition overwrites the content of all FPRs.  The
19763 compiler will generate code which saves and restores the FPRs.  For
19764 soft-float code it is recommended to used the @code{*_nofloat}
19765 variant.  In order to prevent a TDB from being written it is required
19766 to pass a constant zero value as parameter.  Passing a zero value
19767 through a variable is not sufficient.  Although modifications of
19768 access registers inside the transaction will not trigger an
19769 transaction abort it is not supported to actually modify them.  Access
19770 registers do not get saved when entering a transaction. They will have
19771 undefined state when reaching the abort code.
19772 @end deftypefn
19774 Macros for the possible return codes of tbegin are defined in the
19775 @code{htmintrin.h} header file:
19777 @table @code
19778 @item _HTM_TBEGIN_STARTED
19779 @code{tbegin} has been executed as part of normal processing.  The
19780 transaction body is supposed to be executed.
19781 @item _HTM_TBEGIN_INDETERMINATE
19782 The transaction was aborted due to an indeterminate condition which
19783 might be persistent.
19784 @item _HTM_TBEGIN_TRANSIENT
19785 The transaction aborted due to a transient failure.  The transaction
19786 should be re-executed in that case.
19787 @item _HTM_TBEGIN_PERSISTENT
19788 The transaction aborted due to a persistent failure.  Re-execution
19789 under same circumstances will not be productive.
19790 @end table
19792 @defmac _HTM_FIRST_USER_ABORT_CODE
19793 The @code{_HTM_FIRST_USER_ABORT_CODE} defined in @code{htmintrin.h}
19794 specifies the first abort code which can be used for
19795 @code{__builtin_tabort}.  Values below this threshold are reserved for
19796 machine use.
19797 @end defmac
19799 @deftp {Data type} {struct __htm_tdb}
19800 The @code{struct __htm_tdb} defined in @code{htmintrin.h} describes
19801 the structure of the transaction diagnostic block as specified in the
19802 Principles of Operation manual chapter 5-91.
19803 @end deftp
19805 @deftypefn {Built-in Function} int __builtin_tbegin_nofloat (void*)
19806 Same as @code{__builtin_tbegin} but without FPR saves and restores.
19807 Using this variant in code making use of FPRs will leave the FPRs in
19808 undefined state when entering the transaction abort handler code.
19809 @end deftypefn
19811 @deftypefn {Built-in Function} int __builtin_tbegin_retry (void*, int)
19812 In addition to @code{__builtin_tbegin} a loop for transient failures
19813 is generated.  If tbegin returns a condition code of 2 the transaction
19814 will be retried as often as specified in the second argument.  The
19815 perform processor assist instruction is used to tell the CPU about the
19816 number of fails so far.
19817 @end deftypefn
19819 @deftypefn {Built-in Function} int __builtin_tbegin_retry_nofloat (void*, int)
19820 Same as @code{__builtin_tbegin_retry} but without FPR saves and
19821 restores.  Using this variant in code making use of FPRs will leave
19822 the FPRs in undefined state when entering the transaction abort
19823 handler code.
19824 @end deftypefn
19826 @deftypefn {Built-in Function} void __builtin_tbeginc (void)
19827 Generates the @code{tbeginc} machine instruction starting a constrained
19828 hardware transaction.  The second operand is set to @code{0xff08}.
19829 @end deftypefn
19831 @deftypefn {Built-in Function} int __builtin_tend (void)
19832 Generates the @code{tend} machine instruction finishing a transaction
19833 and making the changes visible to other threads.  The condition code
19834 generated by tend is returned as integer value.
19835 @end deftypefn
19837 @deftypefn {Built-in Function} void __builtin_tabort (int)
19838 Generates the @code{tabort} machine instruction with the specified
19839 abort code.  Abort codes from 0 through 255 are reserved and will
19840 result in an error message.
19841 @end deftypefn
19843 @deftypefn {Built-in Function} void __builtin_tx_assist (int)
19844 Generates the @code{ppa rX,rY,1} machine instruction.  Where the
19845 integer parameter is loaded into rX and a value of zero is loaded into
19846 rY.  The integer parameter specifies the number of times the
19847 transaction repeatedly aborted.
19848 @end deftypefn
19850 @deftypefn {Built-in Function} int __builtin_tx_nesting_depth (void)
19851 Generates the @code{etnd} machine instruction.  The current nesting
19852 depth is returned as integer value.  For a nesting depth of 0 the code
19853 is not executed as part of an transaction.
19854 @end deftypefn
19856 @deftypefn {Built-in Function} void __builtin_non_tx_store (uint64_t *, uint64_t)
19858 Generates the @code{ntstg} machine instruction.  The second argument
19859 is written to the first arguments location.  The store operation will
19860 not be rolled-back in case of an transaction abort.
19861 @end deftypefn
19863 @node SH Built-in Functions
19864 @subsection SH Built-in Functions
19865 The following built-in functions are supported on the SH1, SH2, SH3 and SH4
19866 families of processors:
19868 @deftypefn {Built-in Function} {void} __builtin_set_thread_pointer (void *@var{ptr})
19869 Sets the @samp{GBR} register to the specified value @var{ptr}.  This is usually
19870 used by system code that manages threads and execution contexts.  The compiler
19871 normally does not generate code that modifies the contents of @samp{GBR} and
19872 thus the value is preserved across function calls.  Changing the @samp{GBR}
19873 value in user code must be done with caution, since the compiler might use
19874 @samp{GBR} in order to access thread local variables.
19876 @end deftypefn
19878 @deftypefn {Built-in Function} {void *} __builtin_thread_pointer (void)
19879 Returns the value that is currently set in the @samp{GBR} register.
19880 Memory loads and stores that use the thread pointer as a base address are
19881 turned into @samp{GBR} based displacement loads and stores, if possible.
19882 For example:
19883 @smallexample
19884 struct my_tcb
19886    int a, b, c, d, e;
19889 int get_tcb_value (void)
19891   // Generate @samp{mov.l @@(8,gbr),r0} instruction
19892   return ((my_tcb*)__builtin_thread_pointer ())->c;
19895 @end smallexample
19896 @end deftypefn
19898 @deftypefn {Built-in Function} {unsigned int} __builtin_sh_get_fpscr (void)
19899 Returns the value that is currently set in the @samp{FPSCR} register.
19900 @end deftypefn
19902 @deftypefn {Built-in Function} {void} __builtin_sh_set_fpscr (unsigned int @var{val})
19903 Sets the @samp{FPSCR} register to the specified value @var{val}, while
19904 preserving the current values of the FR, SZ and PR bits.
19905 @end deftypefn
19907 @node SPARC VIS Built-in Functions
19908 @subsection SPARC VIS Built-in Functions
19910 GCC supports SIMD operations on the SPARC using both the generic vector
19911 extensions (@pxref{Vector Extensions}) as well as built-in functions for
19912 the SPARC Visual Instruction Set (VIS).  When you use the @option{-mvis}
19913 switch, the VIS extension is exposed as the following built-in functions:
19915 @smallexample
19916 typedef int v1si __attribute__ ((vector_size (4)));
19917 typedef int v2si __attribute__ ((vector_size (8)));
19918 typedef short v4hi __attribute__ ((vector_size (8)));
19919 typedef short v2hi __attribute__ ((vector_size (4)));
19920 typedef unsigned char v8qi __attribute__ ((vector_size (8)));
19921 typedef unsigned char v4qi __attribute__ ((vector_size (4)));
19923 void __builtin_vis_write_gsr (int64_t);
19924 int64_t __builtin_vis_read_gsr (void);
19926 void * __builtin_vis_alignaddr (void *, long);
19927 void * __builtin_vis_alignaddrl (void *, long);
19928 int64_t __builtin_vis_faligndatadi (int64_t, int64_t);
19929 v2si __builtin_vis_faligndatav2si (v2si, v2si);
19930 v4hi __builtin_vis_faligndatav4hi (v4si, v4si);
19931 v8qi __builtin_vis_faligndatav8qi (v8qi, v8qi);
19933 v4hi __builtin_vis_fexpand (v4qi);
19935 v4hi __builtin_vis_fmul8x16 (v4qi, v4hi);
19936 v4hi __builtin_vis_fmul8x16au (v4qi, v2hi);
19937 v4hi __builtin_vis_fmul8x16al (v4qi, v2hi);
19938 v4hi __builtin_vis_fmul8sux16 (v8qi, v4hi);
19939 v4hi __builtin_vis_fmul8ulx16 (v8qi, v4hi);
19940 v2si __builtin_vis_fmuld8sux16 (v4qi, v2hi);
19941 v2si __builtin_vis_fmuld8ulx16 (v4qi, v2hi);
19943 v4qi __builtin_vis_fpack16 (v4hi);
19944 v8qi __builtin_vis_fpack32 (v2si, v8qi);
19945 v2hi __builtin_vis_fpackfix (v2si);
19946 v8qi __builtin_vis_fpmerge (v4qi, v4qi);
19948 int64_t __builtin_vis_pdist (v8qi, v8qi, int64_t);
19950 long __builtin_vis_edge8 (void *, void *);
19951 long __builtin_vis_edge8l (void *, void *);
19952 long __builtin_vis_edge16 (void *, void *);
19953 long __builtin_vis_edge16l (void *, void *);
19954 long __builtin_vis_edge32 (void *, void *);
19955 long __builtin_vis_edge32l (void *, void *);
19957 long __builtin_vis_fcmple16 (v4hi, v4hi);
19958 long __builtin_vis_fcmple32 (v2si, v2si);
19959 long __builtin_vis_fcmpne16 (v4hi, v4hi);
19960 long __builtin_vis_fcmpne32 (v2si, v2si);
19961 long __builtin_vis_fcmpgt16 (v4hi, v4hi);
19962 long __builtin_vis_fcmpgt32 (v2si, v2si);
19963 long __builtin_vis_fcmpeq16 (v4hi, v4hi);
19964 long __builtin_vis_fcmpeq32 (v2si, v2si);
19966 v4hi __builtin_vis_fpadd16 (v4hi, v4hi);
19967 v2hi __builtin_vis_fpadd16s (v2hi, v2hi);
19968 v2si __builtin_vis_fpadd32 (v2si, v2si);
19969 v1si __builtin_vis_fpadd32s (v1si, v1si);
19970 v4hi __builtin_vis_fpsub16 (v4hi, v4hi);
19971 v2hi __builtin_vis_fpsub16s (v2hi, v2hi);
19972 v2si __builtin_vis_fpsub32 (v2si, v2si);
19973 v1si __builtin_vis_fpsub32s (v1si, v1si);
19975 long __builtin_vis_array8 (long, long);
19976 long __builtin_vis_array16 (long, long);
19977 long __builtin_vis_array32 (long, long);
19978 @end smallexample
19980 When you use the @option{-mvis2} switch, the VIS version 2.0 built-in
19981 functions also become available:
19983 @smallexample
19984 long __builtin_vis_bmask (long, long);
19985 int64_t __builtin_vis_bshuffledi (int64_t, int64_t);
19986 v2si __builtin_vis_bshufflev2si (v2si, v2si);
19987 v4hi __builtin_vis_bshufflev2si (v4hi, v4hi);
19988 v8qi __builtin_vis_bshufflev2si (v8qi, v8qi);
19990 long __builtin_vis_edge8n (void *, void *);
19991 long __builtin_vis_edge8ln (void *, void *);
19992 long __builtin_vis_edge16n (void *, void *);
19993 long __builtin_vis_edge16ln (void *, void *);
19994 long __builtin_vis_edge32n (void *, void *);
19995 long __builtin_vis_edge32ln (void *, void *);
19996 @end smallexample
19998 When you use the @option{-mvis3} switch, the VIS version 3.0 built-in
19999 functions also become available:
20001 @smallexample
20002 void __builtin_vis_cmask8 (long);
20003 void __builtin_vis_cmask16 (long);
20004 void __builtin_vis_cmask32 (long);
20006 v4hi __builtin_vis_fchksm16 (v4hi, v4hi);
20008 v4hi __builtin_vis_fsll16 (v4hi, v4hi);
20009 v4hi __builtin_vis_fslas16 (v4hi, v4hi);
20010 v4hi __builtin_vis_fsrl16 (v4hi, v4hi);
20011 v4hi __builtin_vis_fsra16 (v4hi, v4hi);
20012 v2si __builtin_vis_fsll16 (v2si, v2si);
20013 v2si __builtin_vis_fslas16 (v2si, v2si);
20014 v2si __builtin_vis_fsrl16 (v2si, v2si);
20015 v2si __builtin_vis_fsra16 (v2si, v2si);
20017 long __builtin_vis_pdistn (v8qi, v8qi);
20019 v4hi __builtin_vis_fmean16 (v4hi, v4hi);
20021 int64_t __builtin_vis_fpadd64 (int64_t, int64_t);
20022 int64_t __builtin_vis_fpsub64 (int64_t, int64_t);
20024 v4hi __builtin_vis_fpadds16 (v4hi, v4hi);
20025 v2hi __builtin_vis_fpadds16s (v2hi, v2hi);
20026 v4hi __builtin_vis_fpsubs16 (v4hi, v4hi);
20027 v2hi __builtin_vis_fpsubs16s (v2hi, v2hi);
20028 v2si __builtin_vis_fpadds32 (v2si, v2si);
20029 v1si __builtin_vis_fpadds32s (v1si, v1si);
20030 v2si __builtin_vis_fpsubs32 (v2si, v2si);
20031 v1si __builtin_vis_fpsubs32s (v1si, v1si);
20033 long __builtin_vis_fucmple8 (v8qi, v8qi);
20034 long __builtin_vis_fucmpne8 (v8qi, v8qi);
20035 long __builtin_vis_fucmpgt8 (v8qi, v8qi);
20036 long __builtin_vis_fucmpeq8 (v8qi, v8qi);
20038 float __builtin_vis_fhadds (float, float);
20039 double __builtin_vis_fhaddd (double, double);
20040 float __builtin_vis_fhsubs (float, float);
20041 double __builtin_vis_fhsubd (double, double);
20042 float __builtin_vis_fnhadds (float, float);
20043 double __builtin_vis_fnhaddd (double, double);
20045 int64_t __builtin_vis_umulxhi (int64_t, int64_t);
20046 int64_t __builtin_vis_xmulx (int64_t, int64_t);
20047 int64_t __builtin_vis_xmulxhi (int64_t, int64_t);
20048 @end smallexample
20050 When you use the @option{-mvis4} switch, the VIS version 4.0 built-in
20051 functions also become available:
20053 @smallexample
20054 v8qi __builtin_vis_fpadd8 (v8qi, v8qi);
20055 v8qi __builtin_vis_fpadds8 (v8qi, v8qi);
20056 v8qi __builtin_vis_fpaddus8 (v8qi, v8qi);
20057 v4hi __builtin_vis_fpaddus16 (v4hi, v4hi);
20059 v8qi __builtin_vis_fpsub8 (v8qi, v8qi);
20060 v8qi __builtin_vis_fpsubs8 (v8qi, v8qi);
20061 v8qi __builtin_vis_fpsubus8 (v8qi, v8qi);
20062 v4hi __builtin_vis_fpsubus16 (v4hi, v4hi);
20064 long __builtin_vis_fpcmple8 (v8qi, v8qi);
20065 long __builtin_vis_fpcmpgt8 (v8qi, v8qi);
20066 long __builtin_vis_fpcmpule16 (v4hi, v4hi);
20067 long __builtin_vis_fpcmpugt16 (v4hi, v4hi);
20068 long __builtin_vis_fpcmpule32 (v2si, v2si);
20069 long __builtin_vis_fpcmpugt32 (v2si, v2si);
20071 v8qi __builtin_vis_fpmax8 (v8qi, v8qi);
20072 v4hi __builtin_vis_fpmax16 (v4hi, v4hi);
20073 v2si __builtin_vis_fpmax32 (v2si, v2si);
20075 v8qi __builtin_vis_fpmaxu8 (v8qi, v8qi);
20076 v4hi __builtin_vis_fpmaxu16 (v4hi, v4hi);
20077 v2si __builtin_vis_fpmaxu32 (v2si, v2si);
20080 v8qi __builtin_vis_fpmin8 (v8qi, v8qi);
20081 v4hi __builtin_vis_fpmin16 (v4hi, v4hi);
20082 v2si __builtin_vis_fpmin32 (v2si, v2si);
20084 v8qi __builtin_vis_fpminu8 (v8qi, v8qi);
20085 v4hi __builtin_vis_fpminu16 (v4hi, v4hi);
20086 v2si __builtin_vis_fpminu32 (v2si, v2si);
20087 @end smallexample
20089 When you use the @option{-mvis4b} switch, the VIS version 4.0B
20090 built-in functions also become available:
20092 @smallexample
20093 v8qi __builtin_vis_dictunpack8 (double, int);
20094 v4hi __builtin_vis_dictunpack16 (double, int);
20095 v2si __builtin_vis_dictunpack32 (double, int);
20097 long __builtin_vis_fpcmple8shl (v8qi, v8qi, int);
20098 long __builtin_vis_fpcmpgt8shl (v8qi, v8qi, int);
20099 long __builtin_vis_fpcmpeq8shl (v8qi, v8qi, int);
20100 long __builtin_vis_fpcmpne8shl (v8qi, v8qi, int);
20102 long __builtin_vis_fpcmple16shl (v4hi, v4hi, int);
20103 long __builtin_vis_fpcmpgt16shl (v4hi, v4hi, int);
20104 long __builtin_vis_fpcmpeq16shl (v4hi, v4hi, int);
20105 long __builtin_vis_fpcmpne16shl (v4hi, v4hi, int);
20107 long __builtin_vis_fpcmple32shl (v2si, v2si, int);
20108 long __builtin_vis_fpcmpgt32shl (v2si, v2si, int);
20109 long __builtin_vis_fpcmpeq32shl (v2si, v2si, int);
20110 long __builtin_vis_fpcmpne32shl (v2si, v2si, int);
20112 long __builtin_vis_fpcmpule8shl (v8qi, v8qi, int);
20113 long __builtin_vis_fpcmpugt8shl (v8qi, v8qi, int);
20114 long __builtin_vis_fpcmpule16shl (v4hi, v4hi, int);
20115 long __builtin_vis_fpcmpugt16shl (v4hi, v4hi, int);
20116 long __builtin_vis_fpcmpule32shl (v2si, v2si, int);
20117 long __builtin_vis_fpcmpugt32shl (v2si, v2si, int);
20119 long __builtin_vis_fpcmpde8shl (v8qi, v8qi, int);
20120 long __builtin_vis_fpcmpde16shl (v4hi, v4hi, int);
20121 long __builtin_vis_fpcmpde32shl (v2si, v2si, int);
20123 long __builtin_vis_fpcmpur8shl (v8qi, v8qi, int);
20124 long __builtin_vis_fpcmpur16shl (v4hi, v4hi, int);
20125 long __builtin_vis_fpcmpur32shl (v2si, v2si, int);
20126 @end smallexample
20128 @node SPU Built-in Functions
20129 @subsection SPU Built-in Functions
20131 GCC provides extensions for the SPU processor as described in the
20132 Sony/Toshiba/IBM SPU Language Extensions Specification.  GCC's
20133 implementation differs in several ways.
20135 @itemize @bullet
20137 @item
20138 The optional extension of specifying vector constants in parentheses is
20139 not supported.
20141 @item
20142 A vector initializer requires no cast if the vector constant is of the
20143 same type as the variable it is initializing.
20145 @item
20146 If @code{signed} or @code{unsigned} is omitted, the signedness of the
20147 vector type is the default signedness of the base type.  The default
20148 varies depending on the operating system, so a portable program should
20149 always specify the signedness.
20151 @item
20152 By default, the keyword @code{__vector} is added. The macro
20153 @code{vector} is defined in @code{<spu_intrinsics.h>} and can be
20154 undefined.
20156 @item
20157 GCC allows using a @code{typedef} name as the type specifier for a
20158 vector type.
20160 @item
20161 For C, overloaded functions are implemented with macros so the following
20162 does not work:
20164 @smallexample
20165   spu_add ((vector signed int)@{1, 2, 3, 4@}, foo);
20166 @end smallexample
20168 @noindent
20169 Since @code{spu_add} is a macro, the vector constant in the example
20170 is treated as four separate arguments.  Wrap the entire argument in
20171 parentheses for this to work.
20173 @item
20174 The extended version of @code{__builtin_expect} is not supported.
20176 @end itemize
20178 @emph{Note:} Only the interface described in the aforementioned
20179 specification is supported. Internally, GCC uses built-in functions to
20180 implement the required functionality, but these are not supported and
20181 are subject to change without notice.
20183 @node TI C6X Built-in Functions
20184 @subsection TI C6X Built-in Functions
20186 GCC provides intrinsics to access certain instructions of the TI C6X
20187 processors.  These intrinsics, listed below, are available after
20188 inclusion of the @code{c6x_intrinsics.h} header file.  They map directly
20189 to C6X instructions.
20191 @smallexample
20193 int _sadd (int, int)
20194 int _ssub (int, int)
20195 int _sadd2 (int, int)
20196 int _ssub2 (int, int)
20197 long long _mpy2 (int, int)
20198 long long _smpy2 (int, int)
20199 int _add4 (int, int)
20200 int _sub4 (int, int)
20201 int _saddu4 (int, int)
20203 int _smpy (int, int)
20204 int _smpyh (int, int)
20205 int _smpyhl (int, int)
20206 int _smpylh (int, int)
20208 int _sshl (int, int)
20209 int _subc (int, int)
20211 int _avg2 (int, int)
20212 int _avgu4 (int, int)
20214 int _clrr (int, int)
20215 int _extr (int, int)
20216 int _extru (int, int)
20217 int _abs (int)
20218 int _abs2 (int)
20220 @end smallexample
20222 @node TILE-Gx Built-in Functions
20223 @subsection TILE-Gx Built-in Functions
20225 GCC provides intrinsics to access every instruction of the TILE-Gx
20226 processor.  The intrinsics are of the form:
20228 @smallexample
20230 unsigned long long __insn_@var{op} (...)
20232 @end smallexample
20234 Where @var{op} is the name of the instruction.  Refer to the ISA manual
20235 for the complete list of instructions.
20237 GCC also provides intrinsics to directly access the network registers.
20238 The intrinsics are:
20240 @smallexample
20242 unsigned long long __tile_idn0_receive (void)
20243 unsigned long long __tile_idn1_receive (void)
20244 unsigned long long __tile_udn0_receive (void)
20245 unsigned long long __tile_udn1_receive (void)
20246 unsigned long long __tile_udn2_receive (void)
20247 unsigned long long __tile_udn3_receive (void)
20248 void __tile_idn_send (unsigned long long)
20249 void __tile_udn_send (unsigned long long)
20251 @end smallexample
20253 The intrinsic @code{void __tile_network_barrier (void)} is used to
20254 guarantee that no network operations before it are reordered with
20255 those after it.
20257 @node TILEPro Built-in Functions
20258 @subsection TILEPro Built-in Functions
20260 GCC provides intrinsics to access every instruction of the TILEPro
20261 processor.  The intrinsics are of the form:
20263 @smallexample
20265 unsigned __insn_@var{op} (...)
20267 @end smallexample
20269 @noindent
20270 where @var{op} is the name of the instruction.  Refer to the ISA manual
20271 for the complete list of instructions.
20273 GCC also provides intrinsics to directly access the network registers.
20274 The intrinsics are:
20276 @smallexample
20278 unsigned __tile_idn0_receive (void)
20279 unsigned __tile_idn1_receive (void)
20280 unsigned __tile_sn_receive (void)
20281 unsigned __tile_udn0_receive (void)
20282 unsigned __tile_udn1_receive (void)
20283 unsigned __tile_udn2_receive (void)
20284 unsigned __tile_udn3_receive (void)
20285 void __tile_idn_send (unsigned)
20286 void __tile_sn_send (unsigned)
20287 void __tile_udn_send (unsigned)
20289 @end smallexample
20291 The intrinsic @code{void __tile_network_barrier (void)} is used to
20292 guarantee that no network operations before it are reordered with
20293 those after it.
20295 @node x86 Built-in Functions
20296 @subsection x86 Built-in Functions
20298 These built-in functions are available for the x86-32 and x86-64 family
20299 of computers, depending on the command-line switches used.
20301 If you specify command-line switches such as @option{-msse},
20302 the compiler could use the extended instruction sets even if the built-ins
20303 are not used explicitly in the program.  For this reason, applications
20304 that perform run-time CPU detection must compile separate files for each
20305 supported architecture, using the appropriate flags.  In particular,
20306 the file containing the CPU detection code should be compiled without
20307 these options.
20309 The following machine modes are available for use with MMX built-in functions
20310 (@pxref{Vector Extensions}): @code{V2SI} for a vector of two 32-bit integers,
20311 @code{V4HI} for a vector of four 16-bit integers, and @code{V8QI} for a
20312 vector of eight 8-bit integers.  Some of the built-in functions operate on
20313 MMX registers as a whole 64-bit entity, these use @code{V1DI} as their mode.
20315 If 3DNow!@: extensions are enabled, @code{V2SF} is used as a mode for a vector
20316 of two 32-bit floating-point values.
20318 If SSE extensions are enabled, @code{V4SF} is used for a vector of four 32-bit
20319 floating-point values.  Some instructions use a vector of four 32-bit
20320 integers, these use @code{V4SI}.  Finally, some instructions operate on an
20321 entire vector register, interpreting it as a 128-bit integer, these use mode
20322 @code{TI}.
20324 The x86-32 and x86-64 family of processors use additional built-in
20325 functions for efficient use of @code{TF} (@code{__float128}) 128-bit
20326 floating point and @code{TC} 128-bit complex floating-point values.
20328 The following floating-point built-in functions are always available.  All
20329 of them implement the function that is part of the name.
20331 @smallexample
20332 __float128 __builtin_fabsq (__float128)
20333 __float128 __builtin_copysignq (__float128, __float128)
20334 @end smallexample
20336 The following built-in functions are always available.
20338 @table @code
20339 @item __float128 __builtin_infq (void)
20340 Similar to @code{__builtin_inf}, except the return type is @code{__float128}.
20341 @findex __builtin_infq
20343 @item __float128 __builtin_huge_valq (void)
20344 Similar to @code{__builtin_huge_val}, except the return type is @code{__float128}.
20345 @findex __builtin_huge_valq
20347 @item __float128 __builtin_nanq (void)
20348 Similar to @code{__builtin_nan}, except the return type is @code{__float128}.
20349 @findex __builtin_nanq
20351 @item __float128 __builtin_nansq (void)
20352 Similar to @code{__builtin_nans}, except the return type is @code{__float128}.
20353 @findex __builtin_nansq
20354 @end table
20356 The following built-in function is always available.
20358 @table @code
20359 @item void __builtin_ia32_pause (void)
20360 Generates the @code{pause} machine instruction with a compiler memory
20361 barrier.
20362 @end table
20364 The following built-in functions are always available and can be used to
20365 check the target platform type.
20367 @deftypefn {Built-in Function} void __builtin_cpu_init (void)
20368 This function runs the CPU detection code to check the type of CPU and the
20369 features supported.  This built-in function needs to be invoked along with the built-in functions
20370 to check CPU type and features, @code{__builtin_cpu_is} and
20371 @code{__builtin_cpu_supports}, only when used in a function that is
20372 executed before any constructors are called.  The CPU detection code is
20373 automatically executed in a very high priority constructor.
20375 For example, this function has to be used in @code{ifunc} resolvers that
20376 check for CPU type using the built-in functions @code{__builtin_cpu_is}
20377 and @code{__builtin_cpu_supports}, or in constructors on targets that
20378 don't support constructor priority.
20379 @smallexample
20381 static void (*resolve_memcpy (void)) (void)
20383   // ifunc resolvers fire before constructors, explicitly call the init
20384   // function.
20385   __builtin_cpu_init ();
20386   if (__builtin_cpu_supports ("ssse3"))
20387     return ssse3_memcpy; // super fast memcpy with ssse3 instructions.
20388   else
20389     return default_memcpy;
20392 void *memcpy (void *, const void *, size_t)
20393      __attribute__ ((ifunc ("resolve_memcpy")));
20394 @end smallexample
20396 @end deftypefn
20398 @deftypefn {Built-in Function} int __builtin_cpu_is (const char *@var{cpuname})
20399 This function returns a positive integer if the run-time CPU
20400 is of type @var{cpuname}
20401 and returns @code{0} otherwise. The following CPU names can be detected:
20403 @table @samp
20404 @item intel
20405 Intel CPU.
20407 @item atom
20408 Intel Atom CPU.
20410 @item core2
20411 Intel Core 2 CPU.
20413 @item corei7
20414 Intel Core i7 CPU.
20416 @item nehalem
20417 Intel Core i7 Nehalem CPU.
20419 @item westmere
20420 Intel Core i7 Westmere CPU.
20422 @item sandybridge
20423 Intel Core i7 Sandy Bridge CPU.
20425 @item amd
20426 AMD CPU.
20428 @item amdfam10h
20429 AMD Family 10h CPU.
20431 @item barcelona
20432 AMD Family 10h Barcelona CPU.
20434 @item shanghai
20435 AMD Family 10h Shanghai CPU.
20437 @item istanbul
20438 AMD Family 10h Istanbul CPU.
20440 @item btver1
20441 AMD Family 14h CPU.
20443 @item amdfam15h
20444 AMD Family 15h CPU.
20446 @item bdver1
20447 AMD Family 15h Bulldozer version 1.
20449 @item bdver2
20450 AMD Family 15h Bulldozer version 2.
20452 @item bdver3
20453 AMD Family 15h Bulldozer version 3.
20455 @item bdver4
20456 AMD Family 15h Bulldozer version 4.
20458 @item btver2
20459 AMD Family 16h CPU.
20461 @item amdfam17h
20462 AMD Family 17h CPU.
20464 @item znver1
20465 AMD Family 17h Zen version 1.
20466 @end table
20468 Here is an example:
20469 @smallexample
20470 if (__builtin_cpu_is ("corei7"))
20471   @{
20472      do_corei7 (); // Core i7 specific implementation.
20473   @}
20474 else
20475   @{
20476      do_generic (); // Generic implementation.
20477   @}
20478 @end smallexample
20479 @end deftypefn
20481 @deftypefn {Built-in Function} int __builtin_cpu_supports (const char *@var{feature})
20482 This function returns a positive integer if the run-time CPU
20483 supports @var{feature}
20484 and returns @code{0} otherwise. The following features can be detected:
20486 @table @samp
20487 @item cmov
20488 CMOV instruction.
20489 @item mmx
20490 MMX instructions.
20491 @item popcnt
20492 POPCNT instruction.
20493 @item sse
20494 SSE instructions.
20495 @item sse2
20496 SSE2 instructions.
20497 @item sse3
20498 SSE3 instructions.
20499 @item ssse3
20500 SSSE3 instructions.
20501 @item sse4.1
20502 SSE4.1 instructions.
20503 @item sse4.2
20504 SSE4.2 instructions.
20505 @item avx
20506 AVX instructions.
20507 @item avx2
20508 AVX2 instructions.
20509 @item avx512f
20510 AVX512F instructions.
20511 @end table
20513 Here is an example:
20514 @smallexample
20515 if (__builtin_cpu_supports ("popcnt"))
20516   @{
20517      asm("popcnt %1,%0" : "=r"(count) : "rm"(n) : "cc");
20518   @}
20519 else
20520   @{
20521      count = generic_countbits (n); //generic implementation.
20522   @}
20523 @end smallexample
20524 @end deftypefn
20527 The following built-in functions are made available by @option{-mmmx}.
20528 All of them generate the machine instruction that is part of the name.
20530 @smallexample
20531 v8qi __builtin_ia32_paddb (v8qi, v8qi)
20532 v4hi __builtin_ia32_paddw (v4hi, v4hi)
20533 v2si __builtin_ia32_paddd (v2si, v2si)
20534 v8qi __builtin_ia32_psubb (v8qi, v8qi)
20535 v4hi __builtin_ia32_psubw (v4hi, v4hi)
20536 v2si __builtin_ia32_psubd (v2si, v2si)
20537 v8qi __builtin_ia32_paddsb (v8qi, v8qi)
20538 v4hi __builtin_ia32_paddsw (v4hi, v4hi)
20539 v8qi __builtin_ia32_psubsb (v8qi, v8qi)
20540 v4hi __builtin_ia32_psubsw (v4hi, v4hi)
20541 v8qi __builtin_ia32_paddusb (v8qi, v8qi)
20542 v4hi __builtin_ia32_paddusw (v4hi, v4hi)
20543 v8qi __builtin_ia32_psubusb (v8qi, v8qi)
20544 v4hi __builtin_ia32_psubusw (v4hi, v4hi)
20545 v4hi __builtin_ia32_pmullw (v4hi, v4hi)
20546 v4hi __builtin_ia32_pmulhw (v4hi, v4hi)
20547 di __builtin_ia32_pand (di, di)
20548 di __builtin_ia32_pandn (di,di)
20549 di __builtin_ia32_por (di, di)
20550 di __builtin_ia32_pxor (di, di)
20551 v8qi __builtin_ia32_pcmpeqb (v8qi, v8qi)
20552 v4hi __builtin_ia32_pcmpeqw (v4hi, v4hi)
20553 v2si __builtin_ia32_pcmpeqd (v2si, v2si)
20554 v8qi __builtin_ia32_pcmpgtb (v8qi, v8qi)
20555 v4hi __builtin_ia32_pcmpgtw (v4hi, v4hi)
20556 v2si __builtin_ia32_pcmpgtd (v2si, v2si)
20557 v8qi __builtin_ia32_punpckhbw (v8qi, v8qi)
20558 v4hi __builtin_ia32_punpckhwd (v4hi, v4hi)
20559 v2si __builtin_ia32_punpckhdq (v2si, v2si)
20560 v8qi __builtin_ia32_punpcklbw (v8qi, v8qi)
20561 v4hi __builtin_ia32_punpcklwd (v4hi, v4hi)
20562 v2si __builtin_ia32_punpckldq (v2si, v2si)
20563 v8qi __builtin_ia32_packsswb (v4hi, v4hi)
20564 v4hi __builtin_ia32_packssdw (v2si, v2si)
20565 v8qi __builtin_ia32_packuswb (v4hi, v4hi)
20567 v4hi __builtin_ia32_psllw (v4hi, v4hi)
20568 v2si __builtin_ia32_pslld (v2si, v2si)
20569 v1di __builtin_ia32_psllq (v1di, v1di)
20570 v4hi __builtin_ia32_psrlw (v4hi, v4hi)
20571 v2si __builtin_ia32_psrld (v2si, v2si)
20572 v1di __builtin_ia32_psrlq (v1di, v1di)
20573 v4hi __builtin_ia32_psraw (v4hi, v4hi)
20574 v2si __builtin_ia32_psrad (v2si, v2si)
20575 v4hi __builtin_ia32_psllwi (v4hi, int)
20576 v2si __builtin_ia32_pslldi (v2si, int)
20577 v1di __builtin_ia32_psllqi (v1di, int)
20578 v4hi __builtin_ia32_psrlwi (v4hi, int)
20579 v2si __builtin_ia32_psrldi (v2si, int)
20580 v1di __builtin_ia32_psrlqi (v1di, int)
20581 v4hi __builtin_ia32_psrawi (v4hi, int)
20582 v2si __builtin_ia32_psradi (v2si, int)
20584 @end smallexample
20586 The following built-in functions are made available either with
20587 @option{-msse}, or with @option{-m3dnowa}.  All of them generate
20588 the machine instruction that is part of the name.
20590 @smallexample
20591 v4hi __builtin_ia32_pmulhuw (v4hi, v4hi)
20592 v8qi __builtin_ia32_pavgb (v8qi, v8qi)
20593 v4hi __builtin_ia32_pavgw (v4hi, v4hi)
20594 v1di __builtin_ia32_psadbw (v8qi, v8qi)
20595 v8qi __builtin_ia32_pmaxub (v8qi, v8qi)
20596 v4hi __builtin_ia32_pmaxsw (v4hi, v4hi)
20597 v8qi __builtin_ia32_pminub (v8qi, v8qi)
20598 v4hi __builtin_ia32_pminsw (v4hi, v4hi)
20599 int __builtin_ia32_pmovmskb (v8qi)
20600 void __builtin_ia32_maskmovq (v8qi, v8qi, char *)
20601 void __builtin_ia32_movntq (di *, di)
20602 void __builtin_ia32_sfence (void)
20603 @end smallexample
20605 The following built-in functions are available when @option{-msse} is used.
20606 All of them generate the machine instruction that is part of the name.
20608 @smallexample
20609 int __builtin_ia32_comieq (v4sf, v4sf)
20610 int __builtin_ia32_comineq (v4sf, v4sf)
20611 int __builtin_ia32_comilt (v4sf, v4sf)
20612 int __builtin_ia32_comile (v4sf, v4sf)
20613 int __builtin_ia32_comigt (v4sf, v4sf)
20614 int __builtin_ia32_comige (v4sf, v4sf)
20615 int __builtin_ia32_ucomieq (v4sf, v4sf)
20616 int __builtin_ia32_ucomineq (v4sf, v4sf)
20617 int __builtin_ia32_ucomilt (v4sf, v4sf)
20618 int __builtin_ia32_ucomile (v4sf, v4sf)
20619 int __builtin_ia32_ucomigt (v4sf, v4sf)
20620 int __builtin_ia32_ucomige (v4sf, v4sf)
20621 v4sf __builtin_ia32_addps (v4sf, v4sf)
20622 v4sf __builtin_ia32_subps (v4sf, v4sf)
20623 v4sf __builtin_ia32_mulps (v4sf, v4sf)
20624 v4sf __builtin_ia32_divps (v4sf, v4sf)
20625 v4sf __builtin_ia32_addss (v4sf, v4sf)
20626 v4sf __builtin_ia32_subss (v4sf, v4sf)
20627 v4sf __builtin_ia32_mulss (v4sf, v4sf)
20628 v4sf __builtin_ia32_divss (v4sf, v4sf)
20629 v4sf __builtin_ia32_cmpeqps (v4sf, v4sf)
20630 v4sf __builtin_ia32_cmpltps (v4sf, v4sf)
20631 v4sf __builtin_ia32_cmpleps (v4sf, v4sf)
20632 v4sf __builtin_ia32_cmpgtps (v4sf, v4sf)
20633 v4sf __builtin_ia32_cmpgeps (v4sf, v4sf)
20634 v4sf __builtin_ia32_cmpunordps (v4sf, v4sf)
20635 v4sf __builtin_ia32_cmpneqps (v4sf, v4sf)
20636 v4sf __builtin_ia32_cmpnltps (v4sf, v4sf)
20637 v4sf __builtin_ia32_cmpnleps (v4sf, v4sf)
20638 v4sf __builtin_ia32_cmpngtps (v4sf, v4sf)
20639 v4sf __builtin_ia32_cmpngeps (v4sf, v4sf)
20640 v4sf __builtin_ia32_cmpordps (v4sf, v4sf)
20641 v4sf __builtin_ia32_cmpeqss (v4sf, v4sf)
20642 v4sf __builtin_ia32_cmpltss (v4sf, v4sf)
20643 v4sf __builtin_ia32_cmpless (v4sf, v4sf)
20644 v4sf __builtin_ia32_cmpunordss (v4sf, v4sf)
20645 v4sf __builtin_ia32_cmpneqss (v4sf, v4sf)
20646 v4sf __builtin_ia32_cmpnltss (v4sf, v4sf)
20647 v4sf __builtin_ia32_cmpnless (v4sf, v4sf)
20648 v4sf __builtin_ia32_cmpordss (v4sf, v4sf)
20649 v4sf __builtin_ia32_maxps (v4sf, v4sf)
20650 v4sf __builtin_ia32_maxss (v4sf, v4sf)
20651 v4sf __builtin_ia32_minps (v4sf, v4sf)
20652 v4sf __builtin_ia32_minss (v4sf, v4sf)
20653 v4sf __builtin_ia32_andps (v4sf, v4sf)
20654 v4sf __builtin_ia32_andnps (v4sf, v4sf)
20655 v4sf __builtin_ia32_orps (v4sf, v4sf)
20656 v4sf __builtin_ia32_xorps (v4sf, v4sf)
20657 v4sf __builtin_ia32_movss (v4sf, v4sf)
20658 v4sf __builtin_ia32_movhlps (v4sf, v4sf)
20659 v4sf __builtin_ia32_movlhps (v4sf, v4sf)
20660 v4sf __builtin_ia32_unpckhps (v4sf, v4sf)
20661 v4sf __builtin_ia32_unpcklps (v4sf, v4sf)
20662 v4sf __builtin_ia32_cvtpi2ps (v4sf, v2si)
20663 v4sf __builtin_ia32_cvtsi2ss (v4sf, int)
20664 v2si __builtin_ia32_cvtps2pi (v4sf)
20665 int __builtin_ia32_cvtss2si (v4sf)
20666 v2si __builtin_ia32_cvttps2pi (v4sf)
20667 int __builtin_ia32_cvttss2si (v4sf)
20668 v4sf __builtin_ia32_rcpps (v4sf)
20669 v4sf __builtin_ia32_rsqrtps (v4sf)
20670 v4sf __builtin_ia32_sqrtps (v4sf)
20671 v4sf __builtin_ia32_rcpss (v4sf)
20672 v4sf __builtin_ia32_rsqrtss (v4sf)
20673 v4sf __builtin_ia32_sqrtss (v4sf)
20674 v4sf __builtin_ia32_shufps (v4sf, v4sf, int)
20675 void __builtin_ia32_movntps (float *, v4sf)
20676 int __builtin_ia32_movmskps (v4sf)
20677 @end smallexample
20679 The following built-in functions are available when @option{-msse} is used.
20681 @table @code
20682 @item v4sf __builtin_ia32_loadups (float *)
20683 Generates the @code{movups} machine instruction as a load from memory.
20684 @item void __builtin_ia32_storeups (float *, v4sf)
20685 Generates the @code{movups} machine instruction as a store to memory.
20686 @item v4sf __builtin_ia32_loadss (float *)
20687 Generates the @code{movss} machine instruction as a load from memory.
20688 @item v4sf __builtin_ia32_loadhps (v4sf, const v2sf *)
20689 Generates the @code{movhps} machine instruction as a load from memory.
20690 @item v4sf __builtin_ia32_loadlps (v4sf, const v2sf *)
20691 Generates the @code{movlps} machine instruction as a load from memory
20692 @item void __builtin_ia32_storehps (v2sf *, v4sf)
20693 Generates the @code{movhps} machine instruction as a store to memory.
20694 @item void __builtin_ia32_storelps (v2sf *, v4sf)
20695 Generates the @code{movlps} machine instruction as a store to memory.
20696 @end table
20698 The following built-in functions are available when @option{-msse2} is used.
20699 All of them generate the machine instruction that is part of the name.
20701 @smallexample
20702 int __builtin_ia32_comisdeq (v2df, v2df)
20703 int __builtin_ia32_comisdlt (v2df, v2df)
20704 int __builtin_ia32_comisdle (v2df, v2df)
20705 int __builtin_ia32_comisdgt (v2df, v2df)
20706 int __builtin_ia32_comisdge (v2df, v2df)
20707 int __builtin_ia32_comisdneq (v2df, v2df)
20708 int __builtin_ia32_ucomisdeq (v2df, v2df)
20709 int __builtin_ia32_ucomisdlt (v2df, v2df)
20710 int __builtin_ia32_ucomisdle (v2df, v2df)
20711 int __builtin_ia32_ucomisdgt (v2df, v2df)
20712 int __builtin_ia32_ucomisdge (v2df, v2df)
20713 int __builtin_ia32_ucomisdneq (v2df, v2df)
20714 v2df __builtin_ia32_cmpeqpd (v2df, v2df)
20715 v2df __builtin_ia32_cmpltpd (v2df, v2df)
20716 v2df __builtin_ia32_cmplepd (v2df, v2df)
20717 v2df __builtin_ia32_cmpgtpd (v2df, v2df)
20718 v2df __builtin_ia32_cmpgepd (v2df, v2df)
20719 v2df __builtin_ia32_cmpunordpd (v2df, v2df)
20720 v2df __builtin_ia32_cmpneqpd (v2df, v2df)
20721 v2df __builtin_ia32_cmpnltpd (v2df, v2df)
20722 v2df __builtin_ia32_cmpnlepd (v2df, v2df)
20723 v2df __builtin_ia32_cmpngtpd (v2df, v2df)
20724 v2df __builtin_ia32_cmpngepd (v2df, v2df)
20725 v2df __builtin_ia32_cmpordpd (v2df, v2df)
20726 v2df __builtin_ia32_cmpeqsd (v2df, v2df)
20727 v2df __builtin_ia32_cmpltsd (v2df, v2df)
20728 v2df __builtin_ia32_cmplesd (v2df, v2df)
20729 v2df __builtin_ia32_cmpunordsd (v2df, v2df)
20730 v2df __builtin_ia32_cmpneqsd (v2df, v2df)
20731 v2df __builtin_ia32_cmpnltsd (v2df, v2df)
20732 v2df __builtin_ia32_cmpnlesd (v2df, v2df)
20733 v2df __builtin_ia32_cmpordsd (v2df, v2df)
20734 v2di __builtin_ia32_paddq (v2di, v2di)
20735 v2di __builtin_ia32_psubq (v2di, v2di)
20736 v2df __builtin_ia32_addpd (v2df, v2df)
20737 v2df __builtin_ia32_subpd (v2df, v2df)
20738 v2df __builtin_ia32_mulpd (v2df, v2df)
20739 v2df __builtin_ia32_divpd (v2df, v2df)
20740 v2df __builtin_ia32_addsd (v2df, v2df)
20741 v2df __builtin_ia32_subsd (v2df, v2df)
20742 v2df __builtin_ia32_mulsd (v2df, v2df)
20743 v2df __builtin_ia32_divsd (v2df, v2df)
20744 v2df __builtin_ia32_minpd (v2df, v2df)
20745 v2df __builtin_ia32_maxpd (v2df, v2df)
20746 v2df __builtin_ia32_minsd (v2df, v2df)
20747 v2df __builtin_ia32_maxsd (v2df, v2df)
20748 v2df __builtin_ia32_andpd (v2df, v2df)
20749 v2df __builtin_ia32_andnpd (v2df, v2df)
20750 v2df __builtin_ia32_orpd (v2df, v2df)
20751 v2df __builtin_ia32_xorpd (v2df, v2df)
20752 v2df __builtin_ia32_movsd (v2df, v2df)
20753 v2df __builtin_ia32_unpckhpd (v2df, v2df)
20754 v2df __builtin_ia32_unpcklpd (v2df, v2df)
20755 v16qi __builtin_ia32_paddb128 (v16qi, v16qi)
20756 v8hi __builtin_ia32_paddw128 (v8hi, v8hi)
20757 v4si __builtin_ia32_paddd128 (v4si, v4si)
20758 v2di __builtin_ia32_paddq128 (v2di, v2di)
20759 v16qi __builtin_ia32_psubb128 (v16qi, v16qi)
20760 v8hi __builtin_ia32_psubw128 (v8hi, v8hi)
20761 v4si __builtin_ia32_psubd128 (v4si, v4si)
20762 v2di __builtin_ia32_psubq128 (v2di, v2di)
20763 v8hi __builtin_ia32_pmullw128 (v8hi, v8hi)
20764 v8hi __builtin_ia32_pmulhw128 (v8hi, v8hi)
20765 v2di __builtin_ia32_pand128 (v2di, v2di)
20766 v2di __builtin_ia32_pandn128 (v2di, v2di)
20767 v2di __builtin_ia32_por128 (v2di, v2di)
20768 v2di __builtin_ia32_pxor128 (v2di, v2di)
20769 v16qi __builtin_ia32_pavgb128 (v16qi, v16qi)
20770 v8hi __builtin_ia32_pavgw128 (v8hi, v8hi)
20771 v16qi __builtin_ia32_pcmpeqb128 (v16qi, v16qi)
20772 v8hi __builtin_ia32_pcmpeqw128 (v8hi, v8hi)
20773 v4si __builtin_ia32_pcmpeqd128 (v4si, v4si)
20774 v16qi __builtin_ia32_pcmpgtb128 (v16qi, v16qi)
20775 v8hi __builtin_ia32_pcmpgtw128 (v8hi, v8hi)
20776 v4si __builtin_ia32_pcmpgtd128 (v4si, v4si)
20777 v16qi __builtin_ia32_pmaxub128 (v16qi, v16qi)
20778 v8hi __builtin_ia32_pmaxsw128 (v8hi, v8hi)
20779 v16qi __builtin_ia32_pminub128 (v16qi, v16qi)
20780 v8hi __builtin_ia32_pminsw128 (v8hi, v8hi)
20781 v16qi __builtin_ia32_punpckhbw128 (v16qi, v16qi)
20782 v8hi __builtin_ia32_punpckhwd128 (v8hi, v8hi)
20783 v4si __builtin_ia32_punpckhdq128 (v4si, v4si)
20784 v2di __builtin_ia32_punpckhqdq128 (v2di, v2di)
20785 v16qi __builtin_ia32_punpcklbw128 (v16qi, v16qi)
20786 v8hi __builtin_ia32_punpcklwd128 (v8hi, v8hi)
20787 v4si __builtin_ia32_punpckldq128 (v4si, v4si)
20788 v2di __builtin_ia32_punpcklqdq128 (v2di, v2di)
20789 v16qi __builtin_ia32_packsswb128 (v8hi, v8hi)
20790 v8hi __builtin_ia32_packssdw128 (v4si, v4si)
20791 v16qi __builtin_ia32_packuswb128 (v8hi, v8hi)
20792 v8hi __builtin_ia32_pmulhuw128 (v8hi, v8hi)
20793 void __builtin_ia32_maskmovdqu (v16qi, v16qi)
20794 v2df __builtin_ia32_loadupd (double *)
20795 void __builtin_ia32_storeupd (double *, v2df)
20796 v2df __builtin_ia32_loadhpd (v2df, double const *)
20797 v2df __builtin_ia32_loadlpd (v2df, double const *)
20798 int __builtin_ia32_movmskpd (v2df)
20799 int __builtin_ia32_pmovmskb128 (v16qi)
20800 void __builtin_ia32_movnti (int *, int)
20801 void __builtin_ia32_movnti64 (long long int *, long long int)
20802 void __builtin_ia32_movntpd (double *, v2df)
20803 void __builtin_ia32_movntdq (v2df *, v2df)
20804 v4si __builtin_ia32_pshufd (v4si, int)
20805 v8hi __builtin_ia32_pshuflw (v8hi, int)
20806 v8hi __builtin_ia32_pshufhw (v8hi, int)
20807 v2di __builtin_ia32_psadbw128 (v16qi, v16qi)
20808 v2df __builtin_ia32_sqrtpd (v2df)
20809 v2df __builtin_ia32_sqrtsd (v2df)
20810 v2df __builtin_ia32_shufpd (v2df, v2df, int)
20811 v2df __builtin_ia32_cvtdq2pd (v4si)
20812 v4sf __builtin_ia32_cvtdq2ps (v4si)
20813 v4si __builtin_ia32_cvtpd2dq (v2df)
20814 v2si __builtin_ia32_cvtpd2pi (v2df)
20815 v4sf __builtin_ia32_cvtpd2ps (v2df)
20816 v4si __builtin_ia32_cvttpd2dq (v2df)
20817 v2si __builtin_ia32_cvttpd2pi (v2df)
20818 v2df __builtin_ia32_cvtpi2pd (v2si)
20819 int __builtin_ia32_cvtsd2si (v2df)
20820 int __builtin_ia32_cvttsd2si (v2df)
20821 long long __builtin_ia32_cvtsd2si64 (v2df)
20822 long long __builtin_ia32_cvttsd2si64 (v2df)
20823 v4si __builtin_ia32_cvtps2dq (v4sf)
20824 v2df __builtin_ia32_cvtps2pd (v4sf)
20825 v4si __builtin_ia32_cvttps2dq (v4sf)
20826 v2df __builtin_ia32_cvtsi2sd (v2df, int)
20827 v2df __builtin_ia32_cvtsi642sd (v2df, long long)
20828 v4sf __builtin_ia32_cvtsd2ss (v4sf, v2df)
20829 v2df __builtin_ia32_cvtss2sd (v2df, v4sf)
20830 void __builtin_ia32_clflush (const void *)
20831 void __builtin_ia32_lfence (void)
20832 void __builtin_ia32_mfence (void)
20833 v16qi __builtin_ia32_loaddqu (const char *)
20834 void __builtin_ia32_storedqu (char *, v16qi)
20835 v1di __builtin_ia32_pmuludq (v2si, v2si)
20836 v2di __builtin_ia32_pmuludq128 (v4si, v4si)
20837 v8hi __builtin_ia32_psllw128 (v8hi, v8hi)
20838 v4si __builtin_ia32_pslld128 (v4si, v4si)
20839 v2di __builtin_ia32_psllq128 (v2di, v2di)
20840 v8hi __builtin_ia32_psrlw128 (v8hi, v8hi)
20841 v4si __builtin_ia32_psrld128 (v4si, v4si)
20842 v2di __builtin_ia32_psrlq128 (v2di, v2di)
20843 v8hi __builtin_ia32_psraw128 (v8hi, v8hi)
20844 v4si __builtin_ia32_psrad128 (v4si, v4si)
20845 v2di __builtin_ia32_pslldqi128 (v2di, int)
20846 v8hi __builtin_ia32_psllwi128 (v8hi, int)
20847 v4si __builtin_ia32_pslldi128 (v4si, int)
20848 v2di __builtin_ia32_psllqi128 (v2di, int)
20849 v2di __builtin_ia32_psrldqi128 (v2di, int)
20850 v8hi __builtin_ia32_psrlwi128 (v8hi, int)
20851 v4si __builtin_ia32_psrldi128 (v4si, int)
20852 v2di __builtin_ia32_psrlqi128 (v2di, int)
20853 v8hi __builtin_ia32_psrawi128 (v8hi, int)
20854 v4si __builtin_ia32_psradi128 (v4si, int)
20855 v4si __builtin_ia32_pmaddwd128 (v8hi, v8hi)
20856 v2di __builtin_ia32_movq128 (v2di)
20857 @end smallexample
20859 The following built-in functions are available when @option{-msse3} is used.
20860 All of them generate the machine instruction that is part of the name.
20862 @smallexample
20863 v2df __builtin_ia32_addsubpd (v2df, v2df)
20864 v4sf __builtin_ia32_addsubps (v4sf, v4sf)
20865 v2df __builtin_ia32_haddpd (v2df, v2df)
20866 v4sf __builtin_ia32_haddps (v4sf, v4sf)
20867 v2df __builtin_ia32_hsubpd (v2df, v2df)
20868 v4sf __builtin_ia32_hsubps (v4sf, v4sf)
20869 v16qi __builtin_ia32_lddqu (char const *)
20870 void __builtin_ia32_monitor (void *, unsigned int, unsigned int)
20871 v4sf __builtin_ia32_movshdup (v4sf)
20872 v4sf __builtin_ia32_movsldup (v4sf)
20873 void __builtin_ia32_mwait (unsigned int, unsigned int)
20874 @end smallexample
20876 The following built-in functions are available when @option{-mssse3} is used.
20877 All of them generate the machine instruction that is part of the name.
20879 @smallexample
20880 v2si __builtin_ia32_phaddd (v2si, v2si)
20881 v4hi __builtin_ia32_phaddw (v4hi, v4hi)
20882 v4hi __builtin_ia32_phaddsw (v4hi, v4hi)
20883 v2si __builtin_ia32_phsubd (v2si, v2si)
20884 v4hi __builtin_ia32_phsubw (v4hi, v4hi)
20885 v4hi __builtin_ia32_phsubsw (v4hi, v4hi)
20886 v4hi __builtin_ia32_pmaddubsw (v8qi, v8qi)
20887 v4hi __builtin_ia32_pmulhrsw (v4hi, v4hi)
20888 v8qi __builtin_ia32_pshufb (v8qi, v8qi)
20889 v8qi __builtin_ia32_psignb (v8qi, v8qi)
20890 v2si __builtin_ia32_psignd (v2si, v2si)
20891 v4hi __builtin_ia32_psignw (v4hi, v4hi)
20892 v1di __builtin_ia32_palignr (v1di, v1di, int)
20893 v8qi __builtin_ia32_pabsb (v8qi)
20894 v2si __builtin_ia32_pabsd (v2si)
20895 v4hi __builtin_ia32_pabsw (v4hi)
20896 @end smallexample
20898 The following built-in functions are available when @option{-mssse3} is used.
20899 All of them generate the machine instruction that is part of the name.
20901 @smallexample
20902 v4si __builtin_ia32_phaddd128 (v4si, v4si)
20903 v8hi __builtin_ia32_phaddw128 (v8hi, v8hi)
20904 v8hi __builtin_ia32_phaddsw128 (v8hi, v8hi)
20905 v4si __builtin_ia32_phsubd128 (v4si, v4si)
20906 v8hi __builtin_ia32_phsubw128 (v8hi, v8hi)
20907 v8hi __builtin_ia32_phsubsw128 (v8hi, v8hi)
20908 v8hi __builtin_ia32_pmaddubsw128 (v16qi, v16qi)
20909 v8hi __builtin_ia32_pmulhrsw128 (v8hi, v8hi)
20910 v16qi __builtin_ia32_pshufb128 (v16qi, v16qi)
20911 v16qi __builtin_ia32_psignb128 (v16qi, v16qi)
20912 v4si __builtin_ia32_psignd128 (v4si, v4si)
20913 v8hi __builtin_ia32_psignw128 (v8hi, v8hi)
20914 v2di __builtin_ia32_palignr128 (v2di, v2di, int)
20915 v16qi __builtin_ia32_pabsb128 (v16qi)
20916 v4si __builtin_ia32_pabsd128 (v4si)
20917 v8hi __builtin_ia32_pabsw128 (v8hi)
20918 @end smallexample
20920 The following built-in functions are available when @option{-msse4.1} is
20921 used.  All of them generate the machine instruction that is part of the
20922 name.
20924 @smallexample
20925 v2df __builtin_ia32_blendpd (v2df, v2df, const int)
20926 v4sf __builtin_ia32_blendps (v4sf, v4sf, const int)
20927 v2df __builtin_ia32_blendvpd (v2df, v2df, v2df)
20928 v4sf __builtin_ia32_blendvps (v4sf, v4sf, v4sf)
20929 v2df __builtin_ia32_dppd (v2df, v2df, const int)
20930 v4sf __builtin_ia32_dpps (v4sf, v4sf, const int)
20931 v4sf __builtin_ia32_insertps128 (v4sf, v4sf, const int)
20932 v2di __builtin_ia32_movntdqa (v2di *);
20933 v16qi __builtin_ia32_mpsadbw128 (v16qi, v16qi, const int)
20934 v8hi __builtin_ia32_packusdw128 (v4si, v4si)
20935 v16qi __builtin_ia32_pblendvb128 (v16qi, v16qi, v16qi)
20936 v8hi __builtin_ia32_pblendw128 (v8hi, v8hi, const int)
20937 v2di __builtin_ia32_pcmpeqq (v2di, v2di)
20938 v8hi __builtin_ia32_phminposuw128 (v8hi)
20939 v16qi __builtin_ia32_pmaxsb128 (v16qi, v16qi)
20940 v4si __builtin_ia32_pmaxsd128 (v4si, v4si)
20941 v4si __builtin_ia32_pmaxud128 (v4si, v4si)
20942 v8hi __builtin_ia32_pmaxuw128 (v8hi, v8hi)
20943 v16qi __builtin_ia32_pminsb128 (v16qi, v16qi)
20944 v4si __builtin_ia32_pminsd128 (v4si, v4si)
20945 v4si __builtin_ia32_pminud128 (v4si, v4si)
20946 v8hi __builtin_ia32_pminuw128 (v8hi, v8hi)
20947 v4si __builtin_ia32_pmovsxbd128 (v16qi)
20948 v2di __builtin_ia32_pmovsxbq128 (v16qi)
20949 v8hi __builtin_ia32_pmovsxbw128 (v16qi)
20950 v2di __builtin_ia32_pmovsxdq128 (v4si)
20951 v4si __builtin_ia32_pmovsxwd128 (v8hi)
20952 v2di __builtin_ia32_pmovsxwq128 (v8hi)
20953 v4si __builtin_ia32_pmovzxbd128 (v16qi)
20954 v2di __builtin_ia32_pmovzxbq128 (v16qi)
20955 v8hi __builtin_ia32_pmovzxbw128 (v16qi)
20956 v2di __builtin_ia32_pmovzxdq128 (v4si)
20957 v4si __builtin_ia32_pmovzxwd128 (v8hi)
20958 v2di __builtin_ia32_pmovzxwq128 (v8hi)
20959 v2di __builtin_ia32_pmuldq128 (v4si, v4si)
20960 v4si __builtin_ia32_pmulld128 (v4si, v4si)
20961 int __builtin_ia32_ptestc128 (v2di, v2di)
20962 int __builtin_ia32_ptestnzc128 (v2di, v2di)
20963 int __builtin_ia32_ptestz128 (v2di, v2di)
20964 v2df __builtin_ia32_roundpd (v2df, const int)
20965 v4sf __builtin_ia32_roundps (v4sf, const int)
20966 v2df __builtin_ia32_roundsd (v2df, v2df, const int)
20967 v4sf __builtin_ia32_roundss (v4sf, v4sf, const int)
20968 @end smallexample
20970 The following built-in functions are available when @option{-msse4.1} is
20971 used.
20973 @table @code
20974 @item v4sf __builtin_ia32_vec_set_v4sf (v4sf, float, const int)
20975 Generates the @code{insertps} machine instruction.
20976 @item int __builtin_ia32_vec_ext_v16qi (v16qi, const int)
20977 Generates the @code{pextrb} machine instruction.
20978 @item v16qi __builtin_ia32_vec_set_v16qi (v16qi, int, const int)
20979 Generates the @code{pinsrb} machine instruction.
20980 @item v4si __builtin_ia32_vec_set_v4si (v4si, int, const int)
20981 Generates the @code{pinsrd} machine instruction.
20982 @item v2di __builtin_ia32_vec_set_v2di (v2di, long long, const int)
20983 Generates the @code{pinsrq} machine instruction in 64bit mode.
20984 @end table
20986 The following built-in functions are changed to generate new SSE4.1
20987 instructions when @option{-msse4.1} is used.
20989 @table @code
20990 @item float __builtin_ia32_vec_ext_v4sf (v4sf, const int)
20991 Generates the @code{extractps} machine instruction.
20992 @item int __builtin_ia32_vec_ext_v4si (v4si, const int)
20993 Generates the @code{pextrd} machine instruction.
20994 @item long long __builtin_ia32_vec_ext_v2di (v2di, const int)
20995 Generates the @code{pextrq} machine instruction in 64bit mode.
20996 @end table
20998 The following built-in functions are available when @option{-msse4.2} is
20999 used.  All of them generate the machine instruction that is part of the
21000 name.
21002 @smallexample
21003 v16qi __builtin_ia32_pcmpestrm128 (v16qi, int, v16qi, int, const int)
21004 int __builtin_ia32_pcmpestri128 (v16qi, int, v16qi, int, const int)
21005 int __builtin_ia32_pcmpestria128 (v16qi, int, v16qi, int, const int)
21006 int __builtin_ia32_pcmpestric128 (v16qi, int, v16qi, int, const int)
21007 int __builtin_ia32_pcmpestrio128 (v16qi, int, v16qi, int, const int)
21008 int __builtin_ia32_pcmpestris128 (v16qi, int, v16qi, int, const int)
21009 int __builtin_ia32_pcmpestriz128 (v16qi, int, v16qi, int, const int)
21010 v16qi __builtin_ia32_pcmpistrm128 (v16qi, v16qi, const int)
21011 int __builtin_ia32_pcmpistri128 (v16qi, v16qi, const int)
21012 int __builtin_ia32_pcmpistria128 (v16qi, v16qi, const int)
21013 int __builtin_ia32_pcmpistric128 (v16qi, v16qi, const int)
21014 int __builtin_ia32_pcmpistrio128 (v16qi, v16qi, const int)
21015 int __builtin_ia32_pcmpistris128 (v16qi, v16qi, const int)
21016 int __builtin_ia32_pcmpistriz128 (v16qi, v16qi, const int)
21017 v2di __builtin_ia32_pcmpgtq (v2di, v2di)
21018 @end smallexample
21020 The following built-in functions are available when @option{-msse4.2} is
21021 used.
21023 @table @code
21024 @item unsigned int __builtin_ia32_crc32qi (unsigned int, unsigned char)
21025 Generates the @code{crc32b} machine instruction.
21026 @item unsigned int __builtin_ia32_crc32hi (unsigned int, unsigned short)
21027 Generates the @code{crc32w} machine instruction.
21028 @item unsigned int __builtin_ia32_crc32si (unsigned int, unsigned int)
21029 Generates the @code{crc32l} machine instruction.
21030 @item unsigned long long __builtin_ia32_crc32di (unsigned long long, unsigned long long)
21031 Generates the @code{crc32q} machine instruction.
21032 @end table
21034 The following built-in functions are changed to generate new SSE4.2
21035 instructions when @option{-msse4.2} is used.
21037 @table @code
21038 @item int __builtin_popcount (unsigned int)
21039 Generates the @code{popcntl} machine instruction.
21040 @item int __builtin_popcountl (unsigned long)
21041 Generates the @code{popcntl} or @code{popcntq} machine instruction,
21042 depending on the size of @code{unsigned long}.
21043 @item int __builtin_popcountll (unsigned long long)
21044 Generates the @code{popcntq} machine instruction.
21045 @end table
21047 The following built-in functions are available when @option{-mavx} is
21048 used. All of them generate the machine instruction that is part of the
21049 name.
21051 @smallexample
21052 v4df __builtin_ia32_addpd256 (v4df,v4df)
21053 v8sf __builtin_ia32_addps256 (v8sf,v8sf)
21054 v4df __builtin_ia32_addsubpd256 (v4df,v4df)
21055 v8sf __builtin_ia32_addsubps256 (v8sf,v8sf)
21056 v4df __builtin_ia32_andnpd256 (v4df,v4df)
21057 v8sf __builtin_ia32_andnps256 (v8sf,v8sf)
21058 v4df __builtin_ia32_andpd256 (v4df,v4df)
21059 v8sf __builtin_ia32_andps256 (v8sf,v8sf)
21060 v4df __builtin_ia32_blendpd256 (v4df,v4df,int)
21061 v8sf __builtin_ia32_blendps256 (v8sf,v8sf,int)
21062 v4df __builtin_ia32_blendvpd256 (v4df,v4df,v4df)
21063 v8sf __builtin_ia32_blendvps256 (v8sf,v8sf,v8sf)
21064 v2df __builtin_ia32_cmppd (v2df,v2df,int)
21065 v4df __builtin_ia32_cmppd256 (v4df,v4df,int)
21066 v4sf __builtin_ia32_cmpps (v4sf,v4sf,int)
21067 v8sf __builtin_ia32_cmpps256 (v8sf,v8sf,int)
21068 v2df __builtin_ia32_cmpsd (v2df,v2df,int)
21069 v4sf __builtin_ia32_cmpss (v4sf,v4sf,int)
21070 v4df __builtin_ia32_cvtdq2pd256 (v4si)
21071 v8sf __builtin_ia32_cvtdq2ps256 (v8si)
21072 v4si __builtin_ia32_cvtpd2dq256 (v4df)
21073 v4sf __builtin_ia32_cvtpd2ps256 (v4df)
21074 v8si __builtin_ia32_cvtps2dq256 (v8sf)
21075 v4df __builtin_ia32_cvtps2pd256 (v4sf)
21076 v4si __builtin_ia32_cvttpd2dq256 (v4df)
21077 v8si __builtin_ia32_cvttps2dq256 (v8sf)
21078 v4df __builtin_ia32_divpd256 (v4df,v4df)
21079 v8sf __builtin_ia32_divps256 (v8sf,v8sf)
21080 v8sf __builtin_ia32_dpps256 (v8sf,v8sf,int)
21081 v4df __builtin_ia32_haddpd256 (v4df,v4df)
21082 v8sf __builtin_ia32_haddps256 (v8sf,v8sf)
21083 v4df __builtin_ia32_hsubpd256 (v4df,v4df)
21084 v8sf __builtin_ia32_hsubps256 (v8sf,v8sf)
21085 v32qi __builtin_ia32_lddqu256 (pcchar)
21086 v32qi __builtin_ia32_loaddqu256 (pcchar)
21087 v4df __builtin_ia32_loadupd256 (pcdouble)
21088 v8sf __builtin_ia32_loadups256 (pcfloat)
21089 v2df __builtin_ia32_maskloadpd (pcv2df,v2df)
21090 v4df __builtin_ia32_maskloadpd256 (pcv4df,v4df)
21091 v4sf __builtin_ia32_maskloadps (pcv4sf,v4sf)
21092 v8sf __builtin_ia32_maskloadps256 (pcv8sf,v8sf)
21093 void __builtin_ia32_maskstorepd (pv2df,v2df,v2df)
21094 void __builtin_ia32_maskstorepd256 (pv4df,v4df,v4df)
21095 void __builtin_ia32_maskstoreps (pv4sf,v4sf,v4sf)
21096 void __builtin_ia32_maskstoreps256 (pv8sf,v8sf,v8sf)
21097 v4df __builtin_ia32_maxpd256 (v4df,v4df)
21098 v8sf __builtin_ia32_maxps256 (v8sf,v8sf)
21099 v4df __builtin_ia32_minpd256 (v4df,v4df)
21100 v8sf __builtin_ia32_minps256 (v8sf,v8sf)
21101 v4df __builtin_ia32_movddup256 (v4df)
21102 int __builtin_ia32_movmskpd256 (v4df)
21103 int __builtin_ia32_movmskps256 (v8sf)
21104 v8sf __builtin_ia32_movshdup256 (v8sf)
21105 v8sf __builtin_ia32_movsldup256 (v8sf)
21106 v4df __builtin_ia32_mulpd256 (v4df,v4df)
21107 v8sf __builtin_ia32_mulps256 (v8sf,v8sf)
21108 v4df __builtin_ia32_orpd256 (v4df,v4df)
21109 v8sf __builtin_ia32_orps256 (v8sf,v8sf)
21110 v2df __builtin_ia32_pd_pd256 (v4df)
21111 v4df __builtin_ia32_pd256_pd (v2df)
21112 v4sf __builtin_ia32_ps_ps256 (v8sf)
21113 v8sf __builtin_ia32_ps256_ps (v4sf)
21114 int __builtin_ia32_ptestc256 (v4di,v4di,ptest)
21115 int __builtin_ia32_ptestnzc256 (v4di,v4di,ptest)
21116 int __builtin_ia32_ptestz256 (v4di,v4di,ptest)
21117 v8sf __builtin_ia32_rcpps256 (v8sf)
21118 v4df __builtin_ia32_roundpd256 (v4df,int)
21119 v8sf __builtin_ia32_roundps256 (v8sf,int)
21120 v8sf __builtin_ia32_rsqrtps_nr256 (v8sf)
21121 v8sf __builtin_ia32_rsqrtps256 (v8sf)
21122 v4df __builtin_ia32_shufpd256 (v4df,v4df,int)
21123 v8sf __builtin_ia32_shufps256 (v8sf,v8sf,int)
21124 v4si __builtin_ia32_si_si256 (v8si)
21125 v8si __builtin_ia32_si256_si (v4si)
21126 v4df __builtin_ia32_sqrtpd256 (v4df)
21127 v8sf __builtin_ia32_sqrtps_nr256 (v8sf)
21128 v8sf __builtin_ia32_sqrtps256 (v8sf)
21129 void __builtin_ia32_storedqu256 (pchar,v32qi)
21130 void __builtin_ia32_storeupd256 (pdouble,v4df)
21131 void __builtin_ia32_storeups256 (pfloat,v8sf)
21132 v4df __builtin_ia32_subpd256 (v4df,v4df)
21133 v8sf __builtin_ia32_subps256 (v8sf,v8sf)
21134 v4df __builtin_ia32_unpckhpd256 (v4df,v4df)
21135 v8sf __builtin_ia32_unpckhps256 (v8sf,v8sf)
21136 v4df __builtin_ia32_unpcklpd256 (v4df,v4df)
21137 v8sf __builtin_ia32_unpcklps256 (v8sf,v8sf)
21138 v4df __builtin_ia32_vbroadcastf128_pd256 (pcv2df)
21139 v8sf __builtin_ia32_vbroadcastf128_ps256 (pcv4sf)
21140 v4df __builtin_ia32_vbroadcastsd256 (pcdouble)
21141 v4sf __builtin_ia32_vbroadcastss (pcfloat)
21142 v8sf __builtin_ia32_vbroadcastss256 (pcfloat)
21143 v2df __builtin_ia32_vextractf128_pd256 (v4df,int)
21144 v4sf __builtin_ia32_vextractf128_ps256 (v8sf,int)
21145 v4si __builtin_ia32_vextractf128_si256 (v8si,int)
21146 v4df __builtin_ia32_vinsertf128_pd256 (v4df,v2df,int)
21147 v8sf __builtin_ia32_vinsertf128_ps256 (v8sf,v4sf,int)
21148 v8si __builtin_ia32_vinsertf128_si256 (v8si,v4si,int)
21149 v4df __builtin_ia32_vperm2f128_pd256 (v4df,v4df,int)
21150 v8sf __builtin_ia32_vperm2f128_ps256 (v8sf,v8sf,int)
21151 v8si __builtin_ia32_vperm2f128_si256 (v8si,v8si,int)
21152 v2df __builtin_ia32_vpermil2pd (v2df,v2df,v2di,int)
21153 v4df __builtin_ia32_vpermil2pd256 (v4df,v4df,v4di,int)
21154 v4sf __builtin_ia32_vpermil2ps (v4sf,v4sf,v4si,int)
21155 v8sf __builtin_ia32_vpermil2ps256 (v8sf,v8sf,v8si,int)
21156 v2df __builtin_ia32_vpermilpd (v2df,int)
21157 v4df __builtin_ia32_vpermilpd256 (v4df,int)
21158 v4sf __builtin_ia32_vpermilps (v4sf,int)
21159 v8sf __builtin_ia32_vpermilps256 (v8sf,int)
21160 v2df __builtin_ia32_vpermilvarpd (v2df,v2di)
21161 v4df __builtin_ia32_vpermilvarpd256 (v4df,v4di)
21162 v4sf __builtin_ia32_vpermilvarps (v4sf,v4si)
21163 v8sf __builtin_ia32_vpermilvarps256 (v8sf,v8si)
21164 int __builtin_ia32_vtestcpd (v2df,v2df,ptest)
21165 int __builtin_ia32_vtestcpd256 (v4df,v4df,ptest)
21166 int __builtin_ia32_vtestcps (v4sf,v4sf,ptest)
21167 int __builtin_ia32_vtestcps256 (v8sf,v8sf,ptest)
21168 int __builtin_ia32_vtestnzcpd (v2df,v2df,ptest)
21169 int __builtin_ia32_vtestnzcpd256 (v4df,v4df,ptest)
21170 int __builtin_ia32_vtestnzcps (v4sf,v4sf,ptest)
21171 int __builtin_ia32_vtestnzcps256 (v8sf,v8sf,ptest)
21172 int __builtin_ia32_vtestzpd (v2df,v2df,ptest)
21173 int __builtin_ia32_vtestzpd256 (v4df,v4df,ptest)
21174 int __builtin_ia32_vtestzps (v4sf,v4sf,ptest)
21175 int __builtin_ia32_vtestzps256 (v8sf,v8sf,ptest)
21176 void __builtin_ia32_vzeroall (void)
21177 void __builtin_ia32_vzeroupper (void)
21178 v4df __builtin_ia32_xorpd256 (v4df,v4df)
21179 v8sf __builtin_ia32_xorps256 (v8sf,v8sf)
21180 @end smallexample
21182 The following built-in functions are available when @option{-mavx2} is
21183 used. All of them generate the machine instruction that is part of the
21184 name.
21186 @smallexample
21187 v32qi __builtin_ia32_mpsadbw256 (v32qi,v32qi,int)
21188 v32qi __builtin_ia32_pabsb256 (v32qi)
21189 v16hi __builtin_ia32_pabsw256 (v16hi)
21190 v8si __builtin_ia32_pabsd256 (v8si)
21191 v16hi __builtin_ia32_packssdw256 (v8si,v8si)
21192 v32qi __builtin_ia32_packsswb256 (v16hi,v16hi)
21193 v16hi __builtin_ia32_packusdw256 (v8si,v8si)
21194 v32qi __builtin_ia32_packuswb256 (v16hi,v16hi)
21195 v32qi __builtin_ia32_paddb256 (v32qi,v32qi)
21196 v16hi __builtin_ia32_paddw256 (v16hi,v16hi)
21197 v8si __builtin_ia32_paddd256 (v8si,v8si)
21198 v4di __builtin_ia32_paddq256 (v4di,v4di)
21199 v32qi __builtin_ia32_paddsb256 (v32qi,v32qi)
21200 v16hi __builtin_ia32_paddsw256 (v16hi,v16hi)
21201 v32qi __builtin_ia32_paddusb256 (v32qi,v32qi)
21202 v16hi __builtin_ia32_paddusw256 (v16hi,v16hi)
21203 v4di __builtin_ia32_palignr256 (v4di,v4di,int)
21204 v4di __builtin_ia32_andsi256 (v4di,v4di)
21205 v4di __builtin_ia32_andnotsi256 (v4di,v4di)
21206 v32qi __builtin_ia32_pavgb256 (v32qi,v32qi)
21207 v16hi __builtin_ia32_pavgw256 (v16hi,v16hi)
21208 v32qi __builtin_ia32_pblendvb256 (v32qi,v32qi,v32qi)
21209 v16hi __builtin_ia32_pblendw256 (v16hi,v16hi,int)
21210 v32qi __builtin_ia32_pcmpeqb256 (v32qi,v32qi)
21211 v16hi __builtin_ia32_pcmpeqw256 (v16hi,v16hi)
21212 v8si __builtin_ia32_pcmpeqd256 (c8si,v8si)
21213 v4di __builtin_ia32_pcmpeqq256 (v4di,v4di)
21214 v32qi __builtin_ia32_pcmpgtb256 (v32qi,v32qi)
21215 v16hi __builtin_ia32_pcmpgtw256 (16hi,v16hi)
21216 v8si __builtin_ia32_pcmpgtd256 (v8si,v8si)
21217 v4di __builtin_ia32_pcmpgtq256 (v4di,v4di)
21218 v16hi __builtin_ia32_phaddw256 (v16hi,v16hi)
21219 v8si __builtin_ia32_phaddd256 (v8si,v8si)
21220 v16hi __builtin_ia32_phaddsw256 (v16hi,v16hi)
21221 v16hi __builtin_ia32_phsubw256 (v16hi,v16hi)
21222 v8si __builtin_ia32_phsubd256 (v8si,v8si)
21223 v16hi __builtin_ia32_phsubsw256 (v16hi,v16hi)
21224 v32qi __builtin_ia32_pmaddubsw256 (v32qi,v32qi)
21225 v16hi __builtin_ia32_pmaddwd256 (v16hi,v16hi)
21226 v32qi __builtin_ia32_pmaxsb256 (v32qi,v32qi)
21227 v16hi __builtin_ia32_pmaxsw256 (v16hi,v16hi)
21228 v8si __builtin_ia32_pmaxsd256 (v8si,v8si)
21229 v32qi __builtin_ia32_pmaxub256 (v32qi,v32qi)
21230 v16hi __builtin_ia32_pmaxuw256 (v16hi,v16hi)
21231 v8si __builtin_ia32_pmaxud256 (v8si,v8si)
21232 v32qi __builtin_ia32_pminsb256 (v32qi,v32qi)
21233 v16hi __builtin_ia32_pminsw256 (v16hi,v16hi)
21234 v8si __builtin_ia32_pminsd256 (v8si,v8si)
21235 v32qi __builtin_ia32_pminub256 (v32qi,v32qi)
21236 v16hi __builtin_ia32_pminuw256 (v16hi,v16hi)
21237 v8si __builtin_ia32_pminud256 (v8si,v8si)
21238 int __builtin_ia32_pmovmskb256 (v32qi)
21239 v16hi __builtin_ia32_pmovsxbw256 (v16qi)
21240 v8si __builtin_ia32_pmovsxbd256 (v16qi)
21241 v4di __builtin_ia32_pmovsxbq256 (v16qi)
21242 v8si __builtin_ia32_pmovsxwd256 (v8hi)
21243 v4di __builtin_ia32_pmovsxwq256 (v8hi)
21244 v4di __builtin_ia32_pmovsxdq256 (v4si)
21245 v16hi __builtin_ia32_pmovzxbw256 (v16qi)
21246 v8si __builtin_ia32_pmovzxbd256 (v16qi)
21247 v4di __builtin_ia32_pmovzxbq256 (v16qi)
21248 v8si __builtin_ia32_pmovzxwd256 (v8hi)
21249 v4di __builtin_ia32_pmovzxwq256 (v8hi)
21250 v4di __builtin_ia32_pmovzxdq256 (v4si)
21251 v4di __builtin_ia32_pmuldq256 (v8si,v8si)
21252 v16hi __builtin_ia32_pmulhrsw256 (v16hi, v16hi)
21253 v16hi __builtin_ia32_pmulhuw256 (v16hi,v16hi)
21254 v16hi __builtin_ia32_pmulhw256 (v16hi,v16hi)
21255 v16hi __builtin_ia32_pmullw256 (v16hi,v16hi)
21256 v8si __builtin_ia32_pmulld256 (v8si,v8si)
21257 v4di __builtin_ia32_pmuludq256 (v8si,v8si)
21258 v4di __builtin_ia32_por256 (v4di,v4di)
21259 v16hi __builtin_ia32_psadbw256 (v32qi,v32qi)
21260 v32qi __builtin_ia32_pshufb256 (v32qi,v32qi)
21261 v8si __builtin_ia32_pshufd256 (v8si,int)
21262 v16hi __builtin_ia32_pshufhw256 (v16hi,int)
21263 v16hi __builtin_ia32_pshuflw256 (v16hi,int)
21264 v32qi __builtin_ia32_psignb256 (v32qi,v32qi)
21265 v16hi __builtin_ia32_psignw256 (v16hi,v16hi)
21266 v8si __builtin_ia32_psignd256 (v8si,v8si)
21267 v4di __builtin_ia32_pslldqi256 (v4di,int)
21268 v16hi __builtin_ia32_psllwi256 (16hi,int)
21269 v16hi __builtin_ia32_psllw256(v16hi,v8hi)
21270 v8si __builtin_ia32_pslldi256 (v8si,int)
21271 v8si __builtin_ia32_pslld256(v8si,v4si)
21272 v4di __builtin_ia32_psllqi256 (v4di,int)
21273 v4di __builtin_ia32_psllq256(v4di,v2di)
21274 v16hi __builtin_ia32_psrawi256 (v16hi,int)
21275 v16hi __builtin_ia32_psraw256 (v16hi,v8hi)
21276 v8si __builtin_ia32_psradi256 (v8si,int)
21277 v8si __builtin_ia32_psrad256 (v8si,v4si)
21278 v4di __builtin_ia32_psrldqi256 (v4di, int)
21279 v16hi __builtin_ia32_psrlwi256 (v16hi,int)
21280 v16hi __builtin_ia32_psrlw256 (v16hi,v8hi)
21281 v8si __builtin_ia32_psrldi256 (v8si,int)
21282 v8si __builtin_ia32_psrld256 (v8si,v4si)
21283 v4di __builtin_ia32_psrlqi256 (v4di,int)
21284 v4di __builtin_ia32_psrlq256(v4di,v2di)
21285 v32qi __builtin_ia32_psubb256 (v32qi,v32qi)
21286 v32hi __builtin_ia32_psubw256 (v16hi,v16hi)
21287 v8si __builtin_ia32_psubd256 (v8si,v8si)
21288 v4di __builtin_ia32_psubq256 (v4di,v4di)
21289 v32qi __builtin_ia32_psubsb256 (v32qi,v32qi)
21290 v16hi __builtin_ia32_psubsw256 (v16hi,v16hi)
21291 v32qi __builtin_ia32_psubusb256 (v32qi,v32qi)
21292 v16hi __builtin_ia32_psubusw256 (v16hi,v16hi)
21293 v32qi __builtin_ia32_punpckhbw256 (v32qi,v32qi)
21294 v16hi __builtin_ia32_punpckhwd256 (v16hi,v16hi)
21295 v8si __builtin_ia32_punpckhdq256 (v8si,v8si)
21296 v4di __builtin_ia32_punpckhqdq256 (v4di,v4di)
21297 v32qi __builtin_ia32_punpcklbw256 (v32qi,v32qi)
21298 v16hi __builtin_ia32_punpcklwd256 (v16hi,v16hi)
21299 v8si __builtin_ia32_punpckldq256 (v8si,v8si)
21300 v4di __builtin_ia32_punpcklqdq256 (v4di,v4di)
21301 v4di __builtin_ia32_pxor256 (v4di,v4di)
21302 v4di __builtin_ia32_movntdqa256 (pv4di)
21303 v4sf __builtin_ia32_vbroadcastss_ps (v4sf)
21304 v8sf __builtin_ia32_vbroadcastss_ps256 (v4sf)
21305 v4df __builtin_ia32_vbroadcastsd_pd256 (v2df)
21306 v4di __builtin_ia32_vbroadcastsi256 (v2di)
21307 v4si __builtin_ia32_pblendd128 (v4si,v4si)
21308 v8si __builtin_ia32_pblendd256 (v8si,v8si)
21309 v32qi __builtin_ia32_pbroadcastb256 (v16qi)
21310 v16hi __builtin_ia32_pbroadcastw256 (v8hi)
21311 v8si __builtin_ia32_pbroadcastd256 (v4si)
21312 v4di __builtin_ia32_pbroadcastq256 (v2di)
21313 v16qi __builtin_ia32_pbroadcastb128 (v16qi)
21314 v8hi __builtin_ia32_pbroadcastw128 (v8hi)
21315 v4si __builtin_ia32_pbroadcastd128 (v4si)
21316 v2di __builtin_ia32_pbroadcastq128 (v2di)
21317 v8si __builtin_ia32_permvarsi256 (v8si,v8si)
21318 v4df __builtin_ia32_permdf256 (v4df,int)
21319 v8sf __builtin_ia32_permvarsf256 (v8sf,v8sf)
21320 v4di __builtin_ia32_permdi256 (v4di,int)
21321 v4di __builtin_ia32_permti256 (v4di,v4di,int)
21322 v4di __builtin_ia32_extract128i256 (v4di,int)
21323 v4di __builtin_ia32_insert128i256 (v4di,v2di,int)
21324 v8si __builtin_ia32_maskloadd256 (pcv8si,v8si)
21325 v4di __builtin_ia32_maskloadq256 (pcv4di,v4di)
21326 v4si __builtin_ia32_maskloadd (pcv4si,v4si)
21327 v2di __builtin_ia32_maskloadq (pcv2di,v2di)
21328 void __builtin_ia32_maskstored256 (pv8si,v8si,v8si)
21329 void __builtin_ia32_maskstoreq256 (pv4di,v4di,v4di)
21330 void __builtin_ia32_maskstored (pv4si,v4si,v4si)
21331 void __builtin_ia32_maskstoreq (pv2di,v2di,v2di)
21332 v8si __builtin_ia32_psllv8si (v8si,v8si)
21333 v4si __builtin_ia32_psllv4si (v4si,v4si)
21334 v4di __builtin_ia32_psllv4di (v4di,v4di)
21335 v2di __builtin_ia32_psllv2di (v2di,v2di)
21336 v8si __builtin_ia32_psrav8si (v8si,v8si)
21337 v4si __builtin_ia32_psrav4si (v4si,v4si)
21338 v8si __builtin_ia32_psrlv8si (v8si,v8si)
21339 v4si __builtin_ia32_psrlv4si (v4si,v4si)
21340 v4di __builtin_ia32_psrlv4di (v4di,v4di)
21341 v2di __builtin_ia32_psrlv2di (v2di,v2di)
21342 v2df __builtin_ia32_gathersiv2df (v2df, pcdouble,v4si,v2df,int)
21343 v4df __builtin_ia32_gathersiv4df (v4df, pcdouble,v4si,v4df,int)
21344 v2df __builtin_ia32_gatherdiv2df (v2df, pcdouble,v2di,v2df,int)
21345 v4df __builtin_ia32_gatherdiv4df (v4df, pcdouble,v4di,v4df,int)
21346 v4sf __builtin_ia32_gathersiv4sf (v4sf, pcfloat,v4si,v4sf,int)
21347 v8sf __builtin_ia32_gathersiv8sf (v8sf, pcfloat,v8si,v8sf,int)
21348 v4sf __builtin_ia32_gatherdiv4sf (v4sf, pcfloat,v2di,v4sf,int)
21349 v4sf __builtin_ia32_gatherdiv4sf256 (v4sf, pcfloat,v4di,v4sf,int)
21350 v2di __builtin_ia32_gathersiv2di (v2di, pcint64,v4si,v2di,int)
21351 v4di __builtin_ia32_gathersiv4di (v4di, pcint64,v4si,v4di,int)
21352 v2di __builtin_ia32_gatherdiv2di (v2di, pcint64,v2di,v2di,int)
21353 v4di __builtin_ia32_gatherdiv4di (v4di, pcint64,v4di,v4di,int)
21354 v4si __builtin_ia32_gathersiv4si (v4si, pcint,v4si,v4si,int)
21355 v8si __builtin_ia32_gathersiv8si (v8si, pcint,v8si,v8si,int)
21356 v4si __builtin_ia32_gatherdiv4si (v4si, pcint,v2di,v4si,int)
21357 v4si __builtin_ia32_gatherdiv4si256 (v4si, pcint,v4di,v4si,int)
21358 @end smallexample
21360 The following built-in functions are available when @option{-maes} is
21361 used.  All of them generate the machine instruction that is part of the
21362 name.
21364 @smallexample
21365 v2di __builtin_ia32_aesenc128 (v2di, v2di)
21366 v2di __builtin_ia32_aesenclast128 (v2di, v2di)
21367 v2di __builtin_ia32_aesdec128 (v2di, v2di)
21368 v2di __builtin_ia32_aesdeclast128 (v2di, v2di)
21369 v2di __builtin_ia32_aeskeygenassist128 (v2di, const int)
21370 v2di __builtin_ia32_aesimc128 (v2di)
21371 @end smallexample
21373 The following built-in function is available when @option{-mpclmul} is
21374 used.
21376 @table @code
21377 @item v2di __builtin_ia32_pclmulqdq128 (v2di, v2di, const int)
21378 Generates the @code{pclmulqdq} machine instruction.
21379 @end table
21381 The following built-in function is available when @option{-mfsgsbase} is
21382 used.  All of them generate the machine instruction that is part of the
21383 name.
21385 @smallexample
21386 unsigned int __builtin_ia32_rdfsbase32 (void)
21387 unsigned long long __builtin_ia32_rdfsbase64 (void)
21388 unsigned int __builtin_ia32_rdgsbase32 (void)
21389 unsigned long long __builtin_ia32_rdgsbase64 (void)
21390 void _writefsbase_u32 (unsigned int)
21391 void _writefsbase_u64 (unsigned long long)
21392 void _writegsbase_u32 (unsigned int)
21393 void _writegsbase_u64 (unsigned long long)
21394 @end smallexample
21396 The following built-in function is available when @option{-mrdrnd} is
21397 used.  All of them generate the machine instruction that is part of the
21398 name.
21400 @smallexample
21401 unsigned int __builtin_ia32_rdrand16_step (unsigned short *)
21402 unsigned int __builtin_ia32_rdrand32_step (unsigned int *)
21403 unsigned int __builtin_ia32_rdrand64_step (unsigned long long *)
21404 @end smallexample
21406 The following built-in functions are available when @option{-msse4a} is used.
21407 All of them generate the machine instruction that is part of the name.
21409 @smallexample
21410 void __builtin_ia32_movntsd (double *, v2df)
21411 void __builtin_ia32_movntss (float *, v4sf)
21412 v2di __builtin_ia32_extrq  (v2di, v16qi)
21413 v2di __builtin_ia32_extrqi (v2di, const unsigned int, const unsigned int)
21414 v2di __builtin_ia32_insertq (v2di, v2di)
21415 v2di __builtin_ia32_insertqi (v2di, v2di, const unsigned int, const unsigned int)
21416 @end smallexample
21418 The following built-in functions are available when @option{-mxop} is used.
21419 @smallexample
21420 v2df __builtin_ia32_vfrczpd (v2df)
21421 v4sf __builtin_ia32_vfrczps (v4sf)
21422 v2df __builtin_ia32_vfrczsd (v2df)
21423 v4sf __builtin_ia32_vfrczss (v4sf)
21424 v4df __builtin_ia32_vfrczpd256 (v4df)
21425 v8sf __builtin_ia32_vfrczps256 (v8sf)
21426 v2di __builtin_ia32_vpcmov (v2di, v2di, v2di)
21427 v2di __builtin_ia32_vpcmov_v2di (v2di, v2di, v2di)
21428 v4si __builtin_ia32_vpcmov_v4si (v4si, v4si, v4si)
21429 v8hi __builtin_ia32_vpcmov_v8hi (v8hi, v8hi, v8hi)
21430 v16qi __builtin_ia32_vpcmov_v16qi (v16qi, v16qi, v16qi)
21431 v2df __builtin_ia32_vpcmov_v2df (v2df, v2df, v2df)
21432 v4sf __builtin_ia32_vpcmov_v4sf (v4sf, v4sf, v4sf)
21433 v4di __builtin_ia32_vpcmov_v4di256 (v4di, v4di, v4di)
21434 v8si __builtin_ia32_vpcmov_v8si256 (v8si, v8si, v8si)
21435 v16hi __builtin_ia32_vpcmov_v16hi256 (v16hi, v16hi, v16hi)
21436 v32qi __builtin_ia32_vpcmov_v32qi256 (v32qi, v32qi, v32qi)
21437 v4df __builtin_ia32_vpcmov_v4df256 (v4df, v4df, v4df)
21438 v8sf __builtin_ia32_vpcmov_v8sf256 (v8sf, v8sf, v8sf)
21439 v16qi __builtin_ia32_vpcomeqb (v16qi, v16qi)
21440 v8hi __builtin_ia32_vpcomeqw (v8hi, v8hi)
21441 v4si __builtin_ia32_vpcomeqd (v4si, v4si)
21442 v2di __builtin_ia32_vpcomeqq (v2di, v2di)
21443 v16qi __builtin_ia32_vpcomequb (v16qi, v16qi)
21444 v4si __builtin_ia32_vpcomequd (v4si, v4si)
21445 v2di __builtin_ia32_vpcomequq (v2di, v2di)
21446 v8hi __builtin_ia32_vpcomequw (v8hi, v8hi)
21447 v8hi __builtin_ia32_vpcomeqw (v8hi, v8hi)
21448 v16qi __builtin_ia32_vpcomfalseb (v16qi, v16qi)
21449 v4si __builtin_ia32_vpcomfalsed (v4si, v4si)
21450 v2di __builtin_ia32_vpcomfalseq (v2di, v2di)
21451 v16qi __builtin_ia32_vpcomfalseub (v16qi, v16qi)
21452 v4si __builtin_ia32_vpcomfalseud (v4si, v4si)
21453 v2di __builtin_ia32_vpcomfalseuq (v2di, v2di)
21454 v8hi __builtin_ia32_vpcomfalseuw (v8hi, v8hi)
21455 v8hi __builtin_ia32_vpcomfalsew (v8hi, v8hi)
21456 v16qi __builtin_ia32_vpcomgeb (v16qi, v16qi)
21457 v4si __builtin_ia32_vpcomged (v4si, v4si)
21458 v2di __builtin_ia32_vpcomgeq (v2di, v2di)
21459 v16qi __builtin_ia32_vpcomgeub (v16qi, v16qi)
21460 v4si __builtin_ia32_vpcomgeud (v4si, v4si)
21461 v2di __builtin_ia32_vpcomgeuq (v2di, v2di)
21462 v8hi __builtin_ia32_vpcomgeuw (v8hi, v8hi)
21463 v8hi __builtin_ia32_vpcomgew (v8hi, v8hi)
21464 v16qi __builtin_ia32_vpcomgtb (v16qi, v16qi)
21465 v4si __builtin_ia32_vpcomgtd (v4si, v4si)
21466 v2di __builtin_ia32_vpcomgtq (v2di, v2di)
21467 v16qi __builtin_ia32_vpcomgtub (v16qi, v16qi)
21468 v4si __builtin_ia32_vpcomgtud (v4si, v4si)
21469 v2di __builtin_ia32_vpcomgtuq (v2di, v2di)
21470 v8hi __builtin_ia32_vpcomgtuw (v8hi, v8hi)
21471 v8hi __builtin_ia32_vpcomgtw (v8hi, v8hi)
21472 v16qi __builtin_ia32_vpcomleb (v16qi, v16qi)
21473 v4si __builtin_ia32_vpcomled (v4si, v4si)
21474 v2di __builtin_ia32_vpcomleq (v2di, v2di)
21475 v16qi __builtin_ia32_vpcomleub (v16qi, v16qi)
21476 v4si __builtin_ia32_vpcomleud (v4si, v4si)
21477 v2di __builtin_ia32_vpcomleuq (v2di, v2di)
21478 v8hi __builtin_ia32_vpcomleuw (v8hi, v8hi)
21479 v8hi __builtin_ia32_vpcomlew (v8hi, v8hi)
21480 v16qi __builtin_ia32_vpcomltb (v16qi, v16qi)
21481 v4si __builtin_ia32_vpcomltd (v4si, v4si)
21482 v2di __builtin_ia32_vpcomltq (v2di, v2di)
21483 v16qi __builtin_ia32_vpcomltub (v16qi, v16qi)
21484 v4si __builtin_ia32_vpcomltud (v4si, v4si)
21485 v2di __builtin_ia32_vpcomltuq (v2di, v2di)
21486 v8hi __builtin_ia32_vpcomltuw (v8hi, v8hi)
21487 v8hi __builtin_ia32_vpcomltw (v8hi, v8hi)
21488 v16qi __builtin_ia32_vpcomneb (v16qi, v16qi)
21489 v4si __builtin_ia32_vpcomned (v4si, v4si)
21490 v2di __builtin_ia32_vpcomneq (v2di, v2di)
21491 v16qi __builtin_ia32_vpcomneub (v16qi, v16qi)
21492 v4si __builtin_ia32_vpcomneud (v4si, v4si)
21493 v2di __builtin_ia32_vpcomneuq (v2di, v2di)
21494 v8hi __builtin_ia32_vpcomneuw (v8hi, v8hi)
21495 v8hi __builtin_ia32_vpcomnew (v8hi, v8hi)
21496 v16qi __builtin_ia32_vpcomtrueb (v16qi, v16qi)
21497 v4si __builtin_ia32_vpcomtrued (v4si, v4si)
21498 v2di __builtin_ia32_vpcomtrueq (v2di, v2di)
21499 v16qi __builtin_ia32_vpcomtrueub (v16qi, v16qi)
21500 v4si __builtin_ia32_vpcomtrueud (v4si, v4si)
21501 v2di __builtin_ia32_vpcomtrueuq (v2di, v2di)
21502 v8hi __builtin_ia32_vpcomtrueuw (v8hi, v8hi)
21503 v8hi __builtin_ia32_vpcomtruew (v8hi, v8hi)
21504 v4si __builtin_ia32_vphaddbd (v16qi)
21505 v2di __builtin_ia32_vphaddbq (v16qi)
21506 v8hi __builtin_ia32_vphaddbw (v16qi)
21507 v2di __builtin_ia32_vphadddq (v4si)
21508 v4si __builtin_ia32_vphaddubd (v16qi)
21509 v2di __builtin_ia32_vphaddubq (v16qi)
21510 v8hi __builtin_ia32_vphaddubw (v16qi)
21511 v2di __builtin_ia32_vphaddudq (v4si)
21512 v4si __builtin_ia32_vphadduwd (v8hi)
21513 v2di __builtin_ia32_vphadduwq (v8hi)
21514 v4si __builtin_ia32_vphaddwd (v8hi)
21515 v2di __builtin_ia32_vphaddwq (v8hi)
21516 v8hi __builtin_ia32_vphsubbw (v16qi)
21517 v2di __builtin_ia32_vphsubdq (v4si)
21518 v4si __builtin_ia32_vphsubwd (v8hi)
21519 v4si __builtin_ia32_vpmacsdd (v4si, v4si, v4si)
21520 v2di __builtin_ia32_vpmacsdqh (v4si, v4si, v2di)
21521 v2di __builtin_ia32_vpmacsdql (v4si, v4si, v2di)
21522 v4si __builtin_ia32_vpmacssdd (v4si, v4si, v4si)
21523 v2di __builtin_ia32_vpmacssdqh (v4si, v4si, v2di)
21524 v2di __builtin_ia32_vpmacssdql (v4si, v4si, v2di)
21525 v4si __builtin_ia32_vpmacsswd (v8hi, v8hi, v4si)
21526 v8hi __builtin_ia32_vpmacssww (v8hi, v8hi, v8hi)
21527 v4si __builtin_ia32_vpmacswd (v8hi, v8hi, v4si)
21528 v8hi __builtin_ia32_vpmacsww (v8hi, v8hi, v8hi)
21529 v4si __builtin_ia32_vpmadcsswd (v8hi, v8hi, v4si)
21530 v4si __builtin_ia32_vpmadcswd (v8hi, v8hi, v4si)
21531 v16qi __builtin_ia32_vpperm (v16qi, v16qi, v16qi)
21532 v16qi __builtin_ia32_vprotb (v16qi, v16qi)
21533 v4si __builtin_ia32_vprotd (v4si, v4si)
21534 v2di __builtin_ia32_vprotq (v2di, v2di)
21535 v8hi __builtin_ia32_vprotw (v8hi, v8hi)
21536 v16qi __builtin_ia32_vpshab (v16qi, v16qi)
21537 v4si __builtin_ia32_vpshad (v4si, v4si)
21538 v2di __builtin_ia32_vpshaq (v2di, v2di)
21539 v8hi __builtin_ia32_vpshaw (v8hi, v8hi)
21540 v16qi __builtin_ia32_vpshlb (v16qi, v16qi)
21541 v4si __builtin_ia32_vpshld (v4si, v4si)
21542 v2di __builtin_ia32_vpshlq (v2di, v2di)
21543 v8hi __builtin_ia32_vpshlw (v8hi, v8hi)
21544 @end smallexample
21546 The following built-in functions are available when @option{-mfma4} is used.
21547 All of them generate the machine instruction that is part of the name.
21549 @smallexample
21550 v2df __builtin_ia32_vfmaddpd (v2df, v2df, v2df)
21551 v4sf __builtin_ia32_vfmaddps (v4sf, v4sf, v4sf)
21552 v2df __builtin_ia32_vfmaddsd (v2df, v2df, v2df)
21553 v4sf __builtin_ia32_vfmaddss (v4sf, v4sf, v4sf)
21554 v2df __builtin_ia32_vfmsubpd (v2df, v2df, v2df)
21555 v4sf __builtin_ia32_vfmsubps (v4sf, v4sf, v4sf)
21556 v2df __builtin_ia32_vfmsubsd (v2df, v2df, v2df)
21557 v4sf __builtin_ia32_vfmsubss (v4sf, v4sf, v4sf)
21558 v2df __builtin_ia32_vfnmaddpd (v2df, v2df, v2df)
21559 v4sf __builtin_ia32_vfnmaddps (v4sf, v4sf, v4sf)
21560 v2df __builtin_ia32_vfnmaddsd (v2df, v2df, v2df)
21561 v4sf __builtin_ia32_vfnmaddss (v4sf, v4sf, v4sf)
21562 v2df __builtin_ia32_vfnmsubpd (v2df, v2df, v2df)
21563 v4sf __builtin_ia32_vfnmsubps (v4sf, v4sf, v4sf)
21564 v2df __builtin_ia32_vfnmsubsd (v2df, v2df, v2df)
21565 v4sf __builtin_ia32_vfnmsubss (v4sf, v4sf, v4sf)
21566 v2df __builtin_ia32_vfmaddsubpd  (v2df, v2df, v2df)
21567 v4sf __builtin_ia32_vfmaddsubps  (v4sf, v4sf, v4sf)
21568 v2df __builtin_ia32_vfmsubaddpd  (v2df, v2df, v2df)
21569 v4sf __builtin_ia32_vfmsubaddps  (v4sf, v4sf, v4sf)
21570 v4df __builtin_ia32_vfmaddpd256 (v4df, v4df, v4df)
21571 v8sf __builtin_ia32_vfmaddps256 (v8sf, v8sf, v8sf)
21572 v4df __builtin_ia32_vfmsubpd256 (v4df, v4df, v4df)
21573 v8sf __builtin_ia32_vfmsubps256 (v8sf, v8sf, v8sf)
21574 v4df __builtin_ia32_vfnmaddpd256 (v4df, v4df, v4df)
21575 v8sf __builtin_ia32_vfnmaddps256 (v8sf, v8sf, v8sf)
21576 v4df __builtin_ia32_vfnmsubpd256 (v4df, v4df, v4df)
21577 v8sf __builtin_ia32_vfnmsubps256 (v8sf, v8sf, v8sf)
21578 v4df __builtin_ia32_vfmaddsubpd256 (v4df, v4df, v4df)
21579 v8sf __builtin_ia32_vfmaddsubps256 (v8sf, v8sf, v8sf)
21580 v4df __builtin_ia32_vfmsubaddpd256 (v4df, v4df, v4df)
21581 v8sf __builtin_ia32_vfmsubaddps256 (v8sf, v8sf, v8sf)
21583 @end smallexample
21585 The following built-in functions are available when @option{-mlwp} is used.
21587 @smallexample
21588 void __builtin_ia32_llwpcb16 (void *);
21589 void __builtin_ia32_llwpcb32 (void *);
21590 void __builtin_ia32_llwpcb64 (void *);
21591 void * __builtin_ia32_llwpcb16 (void);
21592 void * __builtin_ia32_llwpcb32 (void);
21593 void * __builtin_ia32_llwpcb64 (void);
21594 void __builtin_ia32_lwpval16 (unsigned short, unsigned int, unsigned short)
21595 void __builtin_ia32_lwpval32 (unsigned int, unsigned int, unsigned int)
21596 void __builtin_ia32_lwpval64 (unsigned __int64, unsigned int, unsigned int)
21597 unsigned char __builtin_ia32_lwpins16 (unsigned short, unsigned int, unsigned short)
21598 unsigned char __builtin_ia32_lwpins32 (unsigned int, unsigned int, unsigned int)
21599 unsigned char __builtin_ia32_lwpins64 (unsigned __int64, unsigned int, unsigned int)
21600 @end smallexample
21602 The following built-in functions are available when @option{-mbmi} is used.
21603 All of them generate the machine instruction that is part of the name.
21604 @smallexample
21605 unsigned int __builtin_ia32_bextr_u32(unsigned int, unsigned int);
21606 unsigned long long __builtin_ia32_bextr_u64 (unsigned long long, unsigned long long);
21607 @end smallexample
21609 The following built-in functions are available when @option{-mbmi2} is used.
21610 All of them generate the machine instruction that is part of the name.
21611 @smallexample
21612 unsigned int _bzhi_u32 (unsigned int, unsigned int)
21613 unsigned int _pdep_u32 (unsigned int, unsigned int)
21614 unsigned int _pext_u32 (unsigned int, unsigned int)
21615 unsigned long long _bzhi_u64 (unsigned long long, unsigned long long)
21616 unsigned long long _pdep_u64 (unsigned long long, unsigned long long)
21617 unsigned long long _pext_u64 (unsigned long long, unsigned long long)
21618 @end smallexample
21620 The following built-in functions are available when @option{-mlzcnt} is used.
21621 All of them generate the machine instruction that is part of the name.
21622 @smallexample
21623 unsigned short __builtin_ia32_lzcnt_u16(unsigned short);
21624 unsigned int __builtin_ia32_lzcnt_u32(unsigned int);
21625 unsigned long long __builtin_ia32_lzcnt_u64 (unsigned long long);
21626 @end smallexample
21628 The following built-in functions are available when @option{-mfxsr} is used.
21629 All of them generate the machine instruction that is part of the name.
21630 @smallexample
21631 void __builtin_ia32_fxsave (void *)
21632 void __builtin_ia32_fxrstor (void *)
21633 void __builtin_ia32_fxsave64 (void *)
21634 void __builtin_ia32_fxrstor64 (void *)
21635 @end smallexample
21637 The following built-in functions are available when @option{-mxsave} is used.
21638 All of them generate the machine instruction that is part of the name.
21639 @smallexample
21640 void __builtin_ia32_xsave (void *, long long)
21641 void __builtin_ia32_xrstor (void *, long long)
21642 void __builtin_ia32_xsave64 (void *, long long)
21643 void __builtin_ia32_xrstor64 (void *, long long)
21644 @end smallexample
21646 The following built-in functions are available when @option{-mxsaveopt} is used.
21647 All of them generate the machine instruction that is part of the name.
21648 @smallexample
21649 void __builtin_ia32_xsaveopt (void *, long long)
21650 void __builtin_ia32_xsaveopt64 (void *, long long)
21651 @end smallexample
21653 The following built-in functions are available when @option{-mtbm} is used.
21654 Both of them generate the immediate form of the bextr machine instruction.
21655 @smallexample
21656 unsigned int __builtin_ia32_bextri_u32 (unsigned int,
21657                                         const unsigned int);
21658 unsigned long long __builtin_ia32_bextri_u64 (unsigned long long,
21659                                               const unsigned long long);
21660 @end smallexample
21663 The following built-in functions are available when @option{-m3dnow} is used.
21664 All of them generate the machine instruction that is part of the name.
21666 @smallexample
21667 void __builtin_ia32_femms (void)
21668 v8qi __builtin_ia32_pavgusb (v8qi, v8qi)
21669 v2si __builtin_ia32_pf2id (v2sf)
21670 v2sf __builtin_ia32_pfacc (v2sf, v2sf)
21671 v2sf __builtin_ia32_pfadd (v2sf, v2sf)
21672 v2si __builtin_ia32_pfcmpeq (v2sf, v2sf)
21673 v2si __builtin_ia32_pfcmpge (v2sf, v2sf)
21674 v2si __builtin_ia32_pfcmpgt (v2sf, v2sf)
21675 v2sf __builtin_ia32_pfmax (v2sf, v2sf)
21676 v2sf __builtin_ia32_pfmin (v2sf, v2sf)
21677 v2sf __builtin_ia32_pfmul (v2sf, v2sf)
21678 v2sf __builtin_ia32_pfrcp (v2sf)
21679 v2sf __builtin_ia32_pfrcpit1 (v2sf, v2sf)
21680 v2sf __builtin_ia32_pfrcpit2 (v2sf, v2sf)
21681 v2sf __builtin_ia32_pfrsqrt (v2sf)
21682 v2sf __builtin_ia32_pfsub (v2sf, v2sf)
21683 v2sf __builtin_ia32_pfsubr (v2sf, v2sf)
21684 v2sf __builtin_ia32_pi2fd (v2si)
21685 v4hi __builtin_ia32_pmulhrw (v4hi, v4hi)
21686 @end smallexample
21688 The following built-in functions are available when @option{-m3dnowa} is used.
21689 All of them generate the machine instruction that is part of the name.
21691 @smallexample
21692 v2si __builtin_ia32_pf2iw (v2sf)
21693 v2sf __builtin_ia32_pfnacc (v2sf, v2sf)
21694 v2sf __builtin_ia32_pfpnacc (v2sf, v2sf)
21695 v2sf __builtin_ia32_pi2fw (v2si)
21696 v2sf __builtin_ia32_pswapdsf (v2sf)
21697 v2si __builtin_ia32_pswapdsi (v2si)
21698 @end smallexample
21700 The following built-in functions are available when @option{-mrtm} is used
21701 They are used for restricted transactional memory. These are the internal
21702 low level functions. Normally the functions in 
21703 @ref{x86 transactional memory intrinsics} should be used instead.
21705 @smallexample
21706 int __builtin_ia32_xbegin ()
21707 void __builtin_ia32_xend ()
21708 void __builtin_ia32_xabort (status)
21709 int __builtin_ia32_xtest ()
21710 @end smallexample
21712 The following built-in functions are available when @option{-mmwaitx} is used.
21713 All of them generate the machine instruction that is part of the name.
21714 @smallexample
21715 void __builtin_ia32_monitorx (void *, unsigned int, unsigned int)
21716 void __builtin_ia32_mwaitx (unsigned int, unsigned int, unsigned int)
21717 @end smallexample
21719 The following built-in functions are available when @option{-mclzero} is used.
21720 All of them generate the machine instruction that is part of the name.
21721 @smallexample
21722 void __builtin_i32_clzero (void *)
21723 @end smallexample
21725 The following built-in functions are available when @option{-mpku} is used.
21726 They generate reads and writes to PKRU.
21727 @smallexample
21728 void __builtin_ia32_wrpkru (unsigned int)
21729 unsigned int __builtin_ia32_rdpkru ()
21730 @end smallexample
21732 The following built-in functions are available when @option{-mcet} is used.
21733 They are used to support Intel Control-flow Enforcment Technology (CET).
21734 Each built-in function generates the  machine instruction that is part of the
21735 function's name.
21736 @smallexample
21737 unsigned int __builtin_ia32_rdsspd (unsigned int)
21738 unsigned long long __builtin_ia32_rdsspq (unsigned long long)
21739 void __builtin_ia32_incsspd (unsigned int)
21740 void __builtin_ia32_incsspq (unsigned long long)
21741 void __builtin_ia32_saveprevssp(void);
21742 void __builtin_ia32_rstorssp(void *);
21743 void __builtin_ia32_wrssd(unsigned int, void *);
21744 void __builtin_ia32_wrssq(unsigned long long, void *);
21745 void __builtin_ia32_wrussd(unsigned int, void *);
21746 void __builtin_ia32_wrussq(unsigned long long, void *);
21747 void __builtin_ia32_setssbsy(void);
21748 void __builtin_ia32_clrssbsy(void *);
21749 @end smallexample
21751 @node x86 transactional memory intrinsics
21752 @subsection x86 Transactional Memory Intrinsics
21754 These hardware transactional memory intrinsics for x86 allow you to use
21755 memory transactions with RTM (Restricted Transactional Memory).
21756 This support is enabled with the @option{-mrtm} option.
21757 For using HLE (Hardware Lock Elision) see 
21758 @ref{x86 specific memory model extensions for transactional memory} instead.
21760 A memory transaction commits all changes to memory in an atomic way,
21761 as visible to other threads. If the transaction fails it is rolled back
21762 and all side effects discarded.
21764 Generally there is no guarantee that a memory transaction ever succeeds
21765 and suitable fallback code always needs to be supplied.
21767 @deftypefn {RTM Function} {unsigned} _xbegin ()
21768 Start a RTM (Restricted Transactional Memory) transaction. 
21769 Returns @code{_XBEGIN_STARTED} when the transaction
21770 started successfully (note this is not 0, so the constant has to be 
21771 explicitly tested).  
21773 If the transaction aborts, all side-effects 
21774 are undone and an abort code encoded as a bit mask is returned.
21775 The following macros are defined:
21777 @table @code
21778 @item _XABORT_EXPLICIT
21779 Transaction was explicitly aborted with @code{_xabort}.  The parameter passed
21780 to @code{_xabort} is available with @code{_XABORT_CODE(status)}.
21781 @item _XABORT_RETRY
21782 Transaction retry is possible.
21783 @item _XABORT_CONFLICT
21784 Transaction abort due to a memory conflict with another thread.
21785 @item _XABORT_CAPACITY
21786 Transaction abort due to the transaction using too much memory.
21787 @item _XABORT_DEBUG
21788 Transaction abort due to a debug trap.
21789 @item _XABORT_NESTED
21790 Transaction abort in an inner nested transaction.
21791 @end table
21793 There is no guarantee
21794 any transaction ever succeeds, so there always needs to be a valid
21795 fallback path.
21796 @end deftypefn
21798 @deftypefn {RTM Function} {void} _xend ()
21799 Commit the current transaction. When no transaction is active this faults.
21800 All memory side-effects of the transaction become visible
21801 to other threads in an atomic manner.
21802 @end deftypefn
21804 @deftypefn {RTM Function} {int} _xtest ()
21805 Return a nonzero value if a transaction is currently active, otherwise 0.
21806 @end deftypefn
21808 @deftypefn {RTM Function} {void} _xabort (status)
21809 Abort the current transaction. When no transaction is active this is a no-op.
21810 The @var{status} is an 8-bit constant; its value is encoded in the return 
21811 value from @code{_xbegin}.
21812 @end deftypefn
21814 Here is an example showing handling for @code{_XABORT_RETRY}
21815 and a fallback path for other failures:
21817 @smallexample
21818 #include <immintrin.h>
21820 int n_tries, max_tries;
21821 unsigned status = _XABORT_EXPLICIT;
21824 for (n_tries = 0; n_tries < max_tries; n_tries++) 
21825   @{
21826     status = _xbegin ();
21827     if (status == _XBEGIN_STARTED || !(status & _XABORT_RETRY))
21828       break;
21829   @}
21830 if (status == _XBEGIN_STARTED) 
21831   @{
21832     ... transaction code...
21833     _xend ();
21834   @} 
21835 else 
21836   @{
21837     ... non-transactional fallback path...
21838   @}
21839 @end smallexample
21841 @noindent
21842 Note that, in most cases, the transactional and non-transactional code
21843 must synchronize together to ensure consistency.
21845 @node Target Format Checks
21846 @section Format Checks Specific to Particular Target Machines
21848 For some target machines, GCC supports additional options to the
21849 format attribute
21850 (@pxref{Function Attributes,,Declaring Attributes of Functions}).
21852 @menu
21853 * Solaris Format Checks::
21854 * Darwin Format Checks::
21855 @end menu
21857 @node Solaris Format Checks
21858 @subsection Solaris Format Checks
21860 Solaris targets support the @code{cmn_err} (or @code{__cmn_err__}) format
21861 check.  @code{cmn_err} accepts a subset of the standard @code{printf}
21862 conversions, and the two-argument @code{%b} conversion for displaying
21863 bit-fields.  See the Solaris man page for @code{cmn_err} for more information.
21865 @node Darwin Format Checks
21866 @subsection Darwin Format Checks
21868 Darwin targets support the @code{CFString} (or @code{__CFString__}) in the format
21869 attribute context.  Declarations made with such attribution are parsed for correct syntax
21870 and format argument types.  However, parsing of the format string itself is currently undefined
21871 and is not carried out by this version of the compiler.
21873 Additionally, @code{CFStringRefs} (defined by the @code{CoreFoundation} headers) may
21874 also be used as format arguments.  Note that the relevant headers are only likely to be
21875 available on Darwin (OSX) installations.  On such installations, the XCode and system
21876 documentation provide descriptions of @code{CFString}, @code{CFStringRefs} and
21877 associated functions.
21879 @node Pragmas
21880 @section Pragmas Accepted by GCC
21881 @cindex pragmas
21882 @cindex @code{#pragma}
21884 GCC supports several types of pragmas, primarily in order to compile
21885 code originally written for other compilers.  Note that in general
21886 we do not recommend the use of pragmas; @xref{Function Attributes},
21887 for further explanation.
21889 @menu
21890 * AArch64 Pragmas::
21891 * ARM Pragmas::
21892 * M32C Pragmas::
21893 * MeP Pragmas::
21894 * RS/6000 and PowerPC Pragmas::
21895 * S/390 Pragmas::
21896 * Darwin Pragmas::
21897 * Solaris Pragmas::
21898 * Symbol-Renaming Pragmas::
21899 * Structure-Layout Pragmas::
21900 * Weak Pragmas::
21901 * Diagnostic Pragmas::
21902 * Visibility Pragmas::
21903 * Push/Pop Macro Pragmas::
21904 * Function Specific Option Pragmas::
21905 * Loop-Specific Pragmas::
21906 @end menu
21908 @node AArch64 Pragmas
21909 @subsection AArch64 Pragmas
21911 The pragmas defined by the AArch64 target correspond to the AArch64
21912 target function attributes.  They can be specified as below:
21913 @smallexample
21914 #pragma GCC target("string")
21915 @end smallexample
21917 where @code{@var{string}} can be any string accepted as an AArch64 target
21918 attribute.  @xref{AArch64 Function Attributes}, for more details
21919 on the permissible values of @code{string}.
21921 @node ARM Pragmas
21922 @subsection ARM Pragmas
21924 The ARM target defines pragmas for controlling the default addition of
21925 @code{long_call} and @code{short_call} attributes to functions.
21926 @xref{Function Attributes}, for information about the effects of these
21927 attributes.
21929 @table @code
21930 @item long_calls
21931 @cindex pragma, long_calls
21932 Set all subsequent functions to have the @code{long_call} attribute.
21934 @item no_long_calls
21935 @cindex pragma, no_long_calls
21936 Set all subsequent functions to have the @code{short_call} attribute.
21938 @item long_calls_off
21939 @cindex pragma, long_calls_off
21940 Do not affect the @code{long_call} or @code{short_call} attributes of
21941 subsequent functions.
21942 @end table
21944 @node M32C Pragmas
21945 @subsection M32C Pragmas
21947 @table @code
21948 @item GCC memregs @var{number}
21949 @cindex pragma, memregs
21950 Overrides the command-line option @code{-memregs=} for the current
21951 file.  Use with care!  This pragma must be before any function in the
21952 file, and mixing different memregs values in different objects may
21953 make them incompatible.  This pragma is useful when a
21954 performance-critical function uses a memreg for temporary values,
21955 as it may allow you to reduce the number of memregs used.
21957 @item ADDRESS @var{name} @var{address}
21958 @cindex pragma, address
21959 For any declared symbols matching @var{name}, this does three things
21960 to that symbol: it forces the symbol to be located at the given
21961 address (a number), it forces the symbol to be volatile, and it
21962 changes the symbol's scope to be static.  This pragma exists for
21963 compatibility with other compilers, but note that the common
21964 @code{1234H} numeric syntax is not supported (use @code{0x1234}
21965 instead).  Example:
21967 @smallexample
21968 #pragma ADDRESS port3 0x103
21969 char port3;
21970 @end smallexample
21972 @end table
21974 @node MeP Pragmas
21975 @subsection MeP Pragmas
21977 @table @code
21979 @item custom io_volatile (on|off)
21980 @cindex pragma, custom io_volatile
21981 Overrides the command-line option @code{-mio-volatile} for the current
21982 file.  Note that for compatibility with future GCC releases, this
21983 option should only be used once before any @code{io} variables in each
21984 file.
21986 @item GCC coprocessor available @var{registers}
21987 @cindex pragma, coprocessor available
21988 Specifies which coprocessor registers are available to the register
21989 allocator.  @var{registers} may be a single register, register range
21990 separated by ellipses, or comma-separated list of those.  Example:
21992 @smallexample
21993 #pragma GCC coprocessor available $c0...$c10, $c28
21994 @end smallexample
21996 @item GCC coprocessor call_saved @var{registers}
21997 @cindex pragma, coprocessor call_saved
21998 Specifies which coprocessor registers are to be saved and restored by
21999 any function using them.  @var{registers} may be a single register,
22000 register range separated by ellipses, or comma-separated list of
22001 those.  Example:
22003 @smallexample
22004 #pragma GCC coprocessor call_saved $c4...$c6, $c31
22005 @end smallexample
22007 @item GCC coprocessor subclass '(A|B|C|D)' = @var{registers}
22008 @cindex pragma, coprocessor subclass
22009 Creates and defines a register class.  These register classes can be
22010 used by inline @code{asm} constructs.  @var{registers} may be a single
22011 register, register range separated by ellipses, or comma-separated
22012 list of those.  Example:
22014 @smallexample
22015 #pragma GCC coprocessor subclass 'B' = $c2, $c4, $c6
22017 asm ("cpfoo %0" : "=B" (x));
22018 @end smallexample
22020 @item GCC disinterrupt @var{name} , @var{name} @dots{}
22021 @cindex pragma, disinterrupt
22022 For the named functions, the compiler adds code to disable interrupts
22023 for the duration of those functions.  If any functions so named 
22024 are not encountered in the source, a warning is emitted that the pragma is
22025 not used.  Examples:
22027 @smallexample
22028 #pragma disinterrupt foo
22029 #pragma disinterrupt bar, grill
22030 int foo () @{ @dots{} @}
22031 @end smallexample
22033 @item GCC call @var{name} , @var{name} @dots{}
22034 @cindex pragma, call
22035 For the named functions, the compiler always uses a register-indirect
22036 call model when calling the named functions.  Examples:
22038 @smallexample
22039 extern int foo ();
22040 #pragma call foo
22041 @end smallexample
22043 @end table
22045 @node RS/6000 and PowerPC Pragmas
22046 @subsection RS/6000 and PowerPC Pragmas
22048 The RS/6000 and PowerPC targets define one pragma for controlling
22049 whether or not the @code{longcall} attribute is added to function
22050 declarations by default.  This pragma overrides the @option{-mlongcall}
22051 option, but not the @code{longcall} and @code{shortcall} attributes.
22052 @xref{RS/6000 and PowerPC Options}, for more information about when long
22053 calls are and are not necessary.
22055 @table @code
22056 @item longcall (1)
22057 @cindex pragma, longcall
22058 Apply the @code{longcall} attribute to all subsequent function
22059 declarations.
22061 @item longcall (0)
22062 Do not apply the @code{longcall} attribute to subsequent function
22063 declarations.
22064 @end table
22066 @c Describe h8300 pragmas here.
22067 @c Describe sh pragmas here.
22068 @c Describe v850 pragmas here.
22070 @node S/390 Pragmas
22071 @subsection S/390 Pragmas
22073 The pragmas defined by the S/390 target correspond to the S/390
22074 target function attributes and some the additional options:
22076 @table @samp
22077 @item zvector
22078 @itemx no-zvector
22079 @end table
22081 Note that options of the pragma, unlike options of the target
22082 attribute, do change the value of preprocessor macros like
22083 @code{__VEC__}.  They can be specified as below:
22085 @smallexample
22086 #pragma GCC target("string[,string]...")
22087 #pragma GCC target("string"[,"string"]...)
22088 @end smallexample
22090 @node Darwin Pragmas
22091 @subsection Darwin Pragmas
22093 The following pragmas are available for all architectures running the
22094 Darwin operating system.  These are useful for compatibility with other
22095 Mac OS compilers.
22097 @table @code
22098 @item mark @var{tokens}@dots{}
22099 @cindex pragma, mark
22100 This pragma is accepted, but has no effect.
22102 @item options align=@var{alignment}
22103 @cindex pragma, options align
22104 This pragma sets the alignment of fields in structures.  The values of
22105 @var{alignment} may be @code{mac68k}, to emulate m68k alignment, or
22106 @code{power}, to emulate PowerPC alignment.  Uses of this pragma nest
22107 properly; to restore the previous setting, use @code{reset} for the
22108 @var{alignment}.
22110 @item segment @var{tokens}@dots{}
22111 @cindex pragma, segment
22112 This pragma is accepted, but has no effect.
22114 @item unused (@var{var} [, @var{var}]@dots{})
22115 @cindex pragma, unused
22116 This pragma declares variables to be possibly unused.  GCC does not
22117 produce warnings for the listed variables.  The effect is similar to
22118 that of the @code{unused} attribute, except that this pragma may appear
22119 anywhere within the variables' scopes.
22120 @end table
22122 @node Solaris Pragmas
22123 @subsection Solaris Pragmas
22125 The Solaris target supports @code{#pragma redefine_extname}
22126 (@pxref{Symbol-Renaming Pragmas}).  It also supports additional
22127 @code{#pragma} directives for compatibility with the system compiler.
22129 @table @code
22130 @item align @var{alignment} (@var{variable} [, @var{variable}]...)
22131 @cindex pragma, align
22133 Increase the minimum alignment of each @var{variable} to @var{alignment}.
22134 This is the same as GCC's @code{aligned} attribute @pxref{Variable
22135 Attributes}).  Macro expansion occurs on the arguments to this pragma
22136 when compiling C and Objective-C@.  It does not currently occur when
22137 compiling C++, but this is a bug which may be fixed in a future
22138 release.
22140 @item fini (@var{function} [, @var{function}]...)
22141 @cindex pragma, fini
22143 This pragma causes each listed @var{function} to be called after
22144 main, or during shared module unloading, by adding a call to the
22145 @code{.fini} section.
22147 @item init (@var{function} [, @var{function}]...)
22148 @cindex pragma, init
22150 This pragma causes each listed @var{function} to be called during
22151 initialization (before @code{main}) or during shared module loading, by
22152 adding a call to the @code{.init} section.
22154 @end table
22156 @node Symbol-Renaming Pragmas
22157 @subsection Symbol-Renaming Pragmas
22159 GCC supports a @code{#pragma} directive that changes the name used in
22160 assembly for a given declaration. While this pragma is supported on all
22161 platforms, it is intended primarily to provide compatibility with the
22162 Solaris system headers. This effect can also be achieved using the asm
22163 labels extension (@pxref{Asm Labels}).
22165 @table @code
22166 @item redefine_extname @var{oldname} @var{newname}
22167 @cindex pragma, redefine_extname
22169 This pragma gives the C function @var{oldname} the assembly symbol
22170 @var{newname}.  The preprocessor macro @code{__PRAGMA_REDEFINE_EXTNAME}
22171 is defined if this pragma is available (currently on all platforms).
22172 @end table
22174 This pragma and the asm labels extension interact in a complicated
22175 manner.  Here are some corner cases you may want to be aware of:
22177 @enumerate
22178 @item This pragma silently applies only to declarations with external
22179 linkage.  Asm labels do not have this restriction.
22181 @item In C++, this pragma silently applies only to declarations with
22182 ``C'' linkage.  Again, asm labels do not have this restriction.
22184 @item If either of the ways of changing the assembly name of a
22185 declaration are applied to a declaration whose assembly name has
22186 already been determined (either by a previous use of one of these
22187 features, or because the compiler needed the assembly name in order to
22188 generate code), and the new name is different, a warning issues and
22189 the name does not change.
22191 @item The @var{oldname} used by @code{#pragma redefine_extname} is
22192 always the C-language name.
22193 @end enumerate
22195 @node Structure-Layout Pragmas
22196 @subsection Structure-Layout Pragmas
22198 For compatibility with Microsoft Windows compilers, GCC supports a
22199 set of @code{#pragma} directives that change the maximum alignment of
22200 members of structures (other than zero-width bit-fields), unions, and
22201 classes subsequently defined. The @var{n} value below always is required
22202 to be a small power of two and specifies the new alignment in bytes.
22204 @enumerate
22205 @item @code{#pragma pack(@var{n})} simply sets the new alignment.
22206 @item @code{#pragma pack()} sets the alignment to the one that was in
22207 effect when compilation started (see also command-line option
22208 @option{-fpack-struct[=@var{n}]} @pxref{Code Gen Options}).
22209 @item @code{#pragma pack(push[,@var{n}])} pushes the current alignment
22210 setting on an internal stack and then optionally sets the new alignment.
22211 @item @code{#pragma pack(pop)} restores the alignment setting to the one
22212 saved at the top of the internal stack (and removes that stack entry).
22213 Note that @code{#pragma pack([@var{n}])} does not influence this internal
22214 stack; thus it is possible to have @code{#pragma pack(push)} followed by
22215 multiple @code{#pragma pack(@var{n})} instances and finalized by a single
22216 @code{#pragma pack(pop)}.
22217 @end enumerate
22219 Some targets, e.g.@: x86 and PowerPC, support the @code{#pragma ms_struct}
22220 directive which lays out structures and unions subsequently defined as the
22221 documented @code{__attribute__ ((ms_struct))}.
22223 @enumerate
22224 @item @code{#pragma ms_struct on} turns on the Microsoft layout.
22225 @item @code{#pragma ms_struct off} turns off the Microsoft layout.
22226 @item @code{#pragma ms_struct reset} goes back to the default layout.
22227 @end enumerate
22229 Most targets also support the @code{#pragma scalar_storage_order} directive
22230 which lays out structures and unions subsequently defined as the documented
22231 @code{__attribute__ ((scalar_storage_order))}.
22233 @enumerate
22234 @item @code{#pragma scalar_storage_order big-endian} sets the storage order
22235 of the scalar fields to big-endian.
22236 @item @code{#pragma scalar_storage_order little-endian} sets the storage order
22237 of the scalar fields to little-endian.
22238 @item @code{#pragma scalar_storage_order default} goes back to the endianness
22239 that was in effect when compilation started (see also command-line option
22240 @option{-fsso-struct=@var{endianness}} @pxref{C Dialect Options}).
22241 @end enumerate
22243 @node Weak Pragmas
22244 @subsection Weak Pragmas
22246 For compatibility with SVR4, GCC supports a set of @code{#pragma}
22247 directives for declaring symbols to be weak, and defining weak
22248 aliases.
22250 @table @code
22251 @item #pragma weak @var{symbol}
22252 @cindex pragma, weak
22253 This pragma declares @var{symbol} to be weak, as if the declaration
22254 had the attribute of the same name.  The pragma may appear before
22255 or after the declaration of @var{symbol}.  It is not an error for
22256 @var{symbol} to never be defined at all.
22258 @item #pragma weak @var{symbol1} = @var{symbol2}
22259 This pragma declares @var{symbol1} to be a weak alias of @var{symbol2}.
22260 It is an error if @var{symbol2} is not defined in the current
22261 translation unit.
22262 @end table
22264 @node Diagnostic Pragmas
22265 @subsection Diagnostic Pragmas
22267 GCC allows the user to selectively enable or disable certain types of
22268 diagnostics, and change the kind of the diagnostic.  For example, a
22269 project's policy might require that all sources compile with
22270 @option{-Werror} but certain files might have exceptions allowing
22271 specific types of warnings.  Or, a project might selectively enable
22272 diagnostics and treat them as errors depending on which preprocessor
22273 macros are defined.
22275 @table @code
22276 @item #pragma GCC diagnostic @var{kind} @var{option}
22277 @cindex pragma, diagnostic
22279 Modifies the disposition of a diagnostic.  Note that not all
22280 diagnostics are modifiable; at the moment only warnings (normally
22281 controlled by @samp{-W@dots{}}) can be controlled, and not all of them.
22282 Use @option{-fdiagnostics-show-option} to determine which diagnostics
22283 are controllable and which option controls them.
22285 @var{kind} is @samp{error} to treat this diagnostic as an error,
22286 @samp{warning} to treat it like a warning (even if @option{-Werror} is
22287 in effect), or @samp{ignored} if the diagnostic is to be ignored.
22288 @var{option} is a double quoted string that matches the command-line
22289 option.
22291 @smallexample
22292 #pragma GCC diagnostic warning "-Wformat"
22293 #pragma GCC diagnostic error "-Wformat"
22294 #pragma GCC diagnostic ignored "-Wformat"
22295 @end smallexample
22297 Note that these pragmas override any command-line options.  GCC keeps
22298 track of the location of each pragma, and issues diagnostics according
22299 to the state as of that point in the source file.  Thus, pragmas occurring
22300 after a line do not affect diagnostics caused by that line.
22302 @item #pragma GCC diagnostic push
22303 @itemx #pragma GCC diagnostic pop
22305 Causes GCC to remember the state of the diagnostics as of each
22306 @code{push}, and restore to that point at each @code{pop}.  If a
22307 @code{pop} has no matching @code{push}, the command-line options are
22308 restored.
22310 @smallexample
22311 #pragma GCC diagnostic error "-Wuninitialized"
22312   foo(a);                       /* error is given for this one */
22313 #pragma GCC diagnostic push
22314 #pragma GCC diagnostic ignored "-Wuninitialized"
22315   foo(b);                       /* no diagnostic for this one */
22316 #pragma GCC diagnostic pop
22317   foo(c);                       /* error is given for this one */
22318 #pragma GCC diagnostic pop
22319   foo(d);                       /* depends on command-line options */
22320 @end smallexample
22322 @end table
22324 GCC also offers a simple mechanism for printing messages during
22325 compilation.
22327 @table @code
22328 @item #pragma message @var{string}
22329 @cindex pragma, diagnostic
22331 Prints @var{string} as a compiler message on compilation.  The message
22332 is informational only, and is neither a compilation warning nor an error.
22334 @smallexample
22335 #pragma message "Compiling " __FILE__ "..."
22336 @end smallexample
22338 @var{string} may be parenthesized, and is printed with location
22339 information.  For example,
22341 @smallexample
22342 #define DO_PRAGMA(x) _Pragma (#x)
22343 #define TODO(x) DO_PRAGMA(message ("TODO - " #x))
22345 TODO(Remember to fix this)
22346 @end smallexample
22348 @noindent
22349 prints @samp{/tmp/file.c:4: note: #pragma message:
22350 TODO - Remember to fix this}.
22352 @end table
22354 @node Visibility Pragmas
22355 @subsection Visibility Pragmas
22357 @table @code
22358 @item #pragma GCC visibility push(@var{visibility})
22359 @itemx #pragma GCC visibility pop
22360 @cindex pragma, visibility
22362 This pragma allows the user to set the visibility for multiple
22363 declarations without having to give each a visibility attribute
22364 (@pxref{Function Attributes}).
22366 In C++, @samp{#pragma GCC visibility} affects only namespace-scope
22367 declarations.  Class members and template specializations are not
22368 affected; if you want to override the visibility for a particular
22369 member or instantiation, you must use an attribute.
22371 @end table
22374 @node Push/Pop Macro Pragmas
22375 @subsection Push/Pop Macro Pragmas
22377 For compatibility with Microsoft Windows compilers, GCC supports
22378 @samp{#pragma push_macro(@var{"macro_name"})}
22379 and @samp{#pragma pop_macro(@var{"macro_name"})}.
22381 @table @code
22382 @item #pragma push_macro(@var{"macro_name"})
22383 @cindex pragma, push_macro
22384 This pragma saves the value of the macro named as @var{macro_name} to
22385 the top of the stack for this macro.
22387 @item #pragma pop_macro(@var{"macro_name"})
22388 @cindex pragma, pop_macro
22389 This pragma sets the value of the macro named as @var{macro_name} to
22390 the value on top of the stack for this macro. If the stack for
22391 @var{macro_name} is empty, the value of the macro remains unchanged.
22392 @end table
22394 For example:
22396 @smallexample
22397 #define X  1
22398 #pragma push_macro("X")
22399 #undef X
22400 #define X -1
22401 #pragma pop_macro("X")
22402 int x [X];
22403 @end smallexample
22405 @noindent
22406 In this example, the definition of X as 1 is saved by @code{#pragma
22407 push_macro} and restored by @code{#pragma pop_macro}.
22409 @node Function Specific Option Pragmas
22410 @subsection Function Specific Option Pragmas
22412 @table @code
22413 @item #pragma GCC target (@var{"string"}...)
22414 @cindex pragma GCC target
22416 This pragma allows you to set target specific options for functions
22417 defined later in the source file.  One or more strings can be
22418 specified.  Each function that is defined after this point is as
22419 if @code{attribute((target("STRING")))} was specified for that
22420 function.  The parenthesis around the options is optional.
22421 @xref{Function Attributes}, for more information about the
22422 @code{target} attribute and the attribute syntax.
22424 The @code{#pragma GCC target} pragma is presently implemented for
22425 x86, ARM, AArch64, PowerPC, S/390, and Nios II targets only.
22427 @item #pragma GCC optimize (@var{"string"}...)
22428 @cindex pragma GCC optimize
22430 This pragma allows you to set global optimization options for functions
22431 defined later in the source file.  One or more strings can be
22432 specified.  Each function that is defined after this point is as
22433 if @code{attribute((optimize("STRING")))} was specified for that
22434 function.  The parenthesis around the options is optional.
22435 @xref{Function Attributes}, for more information about the
22436 @code{optimize} attribute and the attribute syntax.
22438 @item #pragma GCC push_options
22439 @itemx #pragma GCC pop_options
22440 @cindex pragma GCC push_options
22441 @cindex pragma GCC pop_options
22443 These pragmas maintain a stack of the current target and optimization
22444 options.  It is intended for include files where you temporarily want
22445 to switch to using a different @samp{#pragma GCC target} or
22446 @samp{#pragma GCC optimize} and then to pop back to the previous
22447 options.
22449 @item #pragma GCC reset_options
22450 @cindex pragma GCC reset_options
22452 This pragma clears the current @code{#pragma GCC target} and
22453 @code{#pragma GCC optimize} to use the default switches as specified
22454 on the command line.
22456 @end table
22458 @node Loop-Specific Pragmas
22459 @subsection Loop-Specific Pragmas
22461 @table @code
22462 @item #pragma GCC ivdep
22463 @cindex pragma GCC ivdep
22465 With this pragma, the programmer asserts that there are no loop-carried
22466 dependencies which would prevent consecutive iterations of
22467 the following loop from executing concurrently with SIMD
22468 (single instruction multiple data) instructions.
22470 For example, the compiler can only unconditionally vectorize the following
22471 loop with the pragma:
22473 @smallexample
22474 void foo (int n, int *a, int *b, int *c)
22476   int i, j;
22477 #pragma GCC ivdep
22478   for (i = 0; i < n; ++i)
22479     a[i] = b[i] + c[i];
22481 @end smallexample
22483 @noindent
22484 In this example, using the @code{restrict} qualifier had the same
22485 effect. In the following example, that would not be possible. Assume
22486 @math{k < -m} or @math{k >= m}. Only with the pragma, the compiler knows
22487 that it can unconditionally vectorize the following loop:
22489 @smallexample
22490 void ignore_vec_dep (int *a, int k, int c, int m)
22492 #pragma GCC ivdep
22493   for (int i = 0; i < m; i++)
22494     a[i] = a[i + k] * c;
22496 @end smallexample
22498 @item #pragma GCC unroll @var{n}
22499 @cindex pragma GCC unroll @var{n}
22501 You can use this pragma to control how many times a loop should be unrolled.
22502 It must be placed immediately before a @code{for}, @code{while} or @code{do}
22503 loop or a @code{#pragma GCC ivdep}, and applies only to the loop that follows.
22504 @var{n} is an integer constant expression specifying the unrolling factor.
22505 The values of @math{0} and @math{1} block any unrolling of the loop.
22507 @end table
22509 @node Unnamed Fields
22510 @section Unnamed Structure and Union Fields
22511 @cindex @code{struct}
22512 @cindex @code{union}
22514 As permitted by ISO C11 and for compatibility with other compilers,
22515 GCC allows you to define
22516 a structure or union that contains, as fields, structures and unions
22517 without names.  For example:
22519 @smallexample
22520 struct @{
22521   int a;
22522   union @{
22523     int b;
22524     float c;
22525   @};
22526   int d;
22527 @} foo;
22528 @end smallexample
22530 @noindent
22531 In this example, you are able to access members of the unnamed
22532 union with code like @samp{foo.b}.  Note that only unnamed structs and
22533 unions are allowed, you may not have, for example, an unnamed
22534 @code{int}.
22536 You must never create such structures that cause ambiguous field definitions.
22537 For example, in this structure:
22539 @smallexample
22540 struct @{
22541   int a;
22542   struct @{
22543     int a;
22544   @};
22545 @} foo;
22546 @end smallexample
22548 @noindent
22549 it is ambiguous which @code{a} is being referred to with @samp{foo.a}.
22550 The compiler gives errors for such constructs.
22552 @opindex fms-extensions
22553 Unless @option{-fms-extensions} is used, the unnamed field must be a
22554 structure or union definition without a tag (for example, @samp{struct
22555 @{ int a; @};}).  If @option{-fms-extensions} is used, the field may
22556 also be a definition with a tag such as @samp{struct foo @{ int a;
22557 @};}, a reference to a previously defined structure or union such as
22558 @samp{struct foo;}, or a reference to a @code{typedef} name for a
22559 previously defined structure or union type.
22561 @opindex fplan9-extensions
22562 The option @option{-fplan9-extensions} enables
22563 @option{-fms-extensions} as well as two other extensions.  First, a
22564 pointer to a structure is automatically converted to a pointer to an
22565 anonymous field for assignments and function calls.  For example:
22567 @smallexample
22568 struct s1 @{ int a; @};
22569 struct s2 @{ struct s1; @};
22570 extern void f1 (struct s1 *);
22571 void f2 (struct s2 *p) @{ f1 (p); @}
22572 @end smallexample
22574 @noindent
22575 In the call to @code{f1} inside @code{f2}, the pointer @code{p} is
22576 converted into a pointer to the anonymous field.
22578 Second, when the type of an anonymous field is a @code{typedef} for a
22579 @code{struct} or @code{union}, code may refer to the field using the
22580 name of the @code{typedef}.
22582 @smallexample
22583 typedef struct @{ int a; @} s1;
22584 struct s2 @{ s1; @};
22585 s1 f1 (struct s2 *p) @{ return p->s1; @}
22586 @end smallexample
22588 These usages are only permitted when they are not ambiguous.
22590 @node Thread-Local
22591 @section Thread-Local Storage
22592 @cindex Thread-Local Storage
22593 @cindex @acronym{TLS}
22594 @cindex @code{__thread}
22596 Thread-local storage (@acronym{TLS}) is a mechanism by which variables
22597 are allocated such that there is one instance of the variable per extant
22598 thread.  The runtime model GCC uses to implement this originates
22599 in the IA-64 processor-specific ABI, but has since been migrated
22600 to other processors as well.  It requires significant support from
22601 the linker (@command{ld}), dynamic linker (@command{ld.so}), and
22602 system libraries (@file{libc.so} and @file{libpthread.so}), so it
22603 is not available everywhere.
22605 At the user level, the extension is visible with a new storage
22606 class keyword: @code{__thread}.  For example:
22608 @smallexample
22609 __thread int i;
22610 extern __thread struct state s;
22611 static __thread char *p;
22612 @end smallexample
22614 The @code{__thread} specifier may be used alone, with the @code{extern}
22615 or @code{static} specifiers, but with no other storage class specifier.
22616 When used with @code{extern} or @code{static}, @code{__thread} must appear
22617 immediately after the other storage class specifier.
22619 The @code{__thread} specifier may be applied to any global, file-scoped
22620 static, function-scoped static, or static data member of a class.  It may
22621 not be applied to block-scoped automatic or non-static data member.
22623 When the address-of operator is applied to a thread-local variable, it is
22624 evaluated at run time and returns the address of the current thread's
22625 instance of that variable.  An address so obtained may be used by any
22626 thread.  When a thread terminates, any pointers to thread-local variables
22627 in that thread become invalid.
22629 No static initialization may refer to the address of a thread-local variable.
22631 In C++, if an initializer is present for a thread-local variable, it must
22632 be a @var{constant-expression}, as defined in 5.19.2 of the ANSI/ISO C++
22633 standard.
22635 See @uref{https://www.akkadia.org/drepper/tls.pdf,
22636 ELF Handling For Thread-Local Storage} for a detailed explanation of
22637 the four thread-local storage addressing models, and how the runtime
22638 is expected to function.
22640 @menu
22641 * C99 Thread-Local Edits::
22642 * C++98 Thread-Local Edits::
22643 @end menu
22645 @node C99 Thread-Local Edits
22646 @subsection ISO/IEC 9899:1999 Edits for Thread-Local Storage
22648 The following are a set of changes to ISO/IEC 9899:1999 (aka C99)
22649 that document the exact semantics of the language extension.
22651 @itemize @bullet
22652 @item
22653 @cite{5.1.2  Execution environments}
22655 Add new text after paragraph 1
22657 @quotation
22658 Within either execution environment, a @dfn{thread} is a flow of
22659 control within a program.  It is implementation defined whether
22660 or not there may be more than one thread associated with a program.
22661 It is implementation defined how threads beyond the first are
22662 created, the name and type of the function called at thread
22663 startup, and how threads may be terminated.  However, objects
22664 with thread storage duration shall be initialized before thread
22665 startup.
22666 @end quotation
22668 @item
22669 @cite{6.2.4  Storage durations of objects}
22671 Add new text before paragraph 3
22673 @quotation
22674 An object whose identifier is declared with the storage-class
22675 specifier @w{@code{__thread}} has @dfn{thread storage duration}.
22676 Its lifetime is the entire execution of the thread, and its
22677 stored value is initialized only once, prior to thread startup.
22678 @end quotation
22680 @item
22681 @cite{6.4.1  Keywords}
22683 Add @code{__thread}.
22685 @item
22686 @cite{6.7.1  Storage-class specifiers}
22688 Add @code{__thread} to the list of storage class specifiers in
22689 paragraph 1.
22691 Change paragraph 2 to
22693 @quotation
22694 With the exception of @code{__thread}, at most one storage-class
22695 specifier may be given [@dots{}].  The @code{__thread} specifier may
22696 be used alone, or immediately following @code{extern} or
22697 @code{static}.
22698 @end quotation
22700 Add new text after paragraph 6
22702 @quotation
22703 The declaration of an identifier for a variable that has
22704 block scope that specifies @code{__thread} shall also
22705 specify either @code{extern} or @code{static}.
22707 The @code{__thread} specifier shall be used only with
22708 variables.
22709 @end quotation
22710 @end itemize
22712 @node C++98 Thread-Local Edits
22713 @subsection ISO/IEC 14882:1998 Edits for Thread-Local Storage
22715 The following are a set of changes to ISO/IEC 14882:1998 (aka C++98)
22716 that document the exact semantics of the language extension.
22718 @itemize @bullet
22719 @item
22720 @b{[intro.execution]}
22722 New text after paragraph 4
22724 @quotation
22725 A @dfn{thread} is a flow of control within the abstract machine.
22726 It is implementation defined whether or not there may be more than
22727 one thread.
22728 @end quotation
22730 New text after paragraph 7
22732 @quotation
22733 It is unspecified whether additional action must be taken to
22734 ensure when and whether side effects are visible to other threads.
22735 @end quotation
22737 @item
22738 @b{[lex.key]}
22740 Add @code{__thread}.
22742 @item
22743 @b{[basic.start.main]}
22745 Add after paragraph 5
22747 @quotation
22748 The thread that begins execution at the @code{main} function is called
22749 the @dfn{main thread}.  It is implementation defined how functions
22750 beginning threads other than the main thread are designated or typed.
22751 A function so designated, as well as the @code{main} function, is called
22752 a @dfn{thread startup function}.  It is implementation defined what
22753 happens if a thread startup function returns.  It is implementation
22754 defined what happens to other threads when any thread calls @code{exit}.
22755 @end quotation
22757 @item
22758 @b{[basic.start.init]}
22760 Add after paragraph 4
22762 @quotation
22763 The storage for an object of thread storage duration shall be
22764 statically initialized before the first statement of the thread startup
22765 function.  An object of thread storage duration shall not require
22766 dynamic initialization.
22767 @end quotation
22769 @item
22770 @b{[basic.start.term]}
22772 Add after paragraph 3
22774 @quotation
22775 The type of an object with thread storage duration shall not have a
22776 non-trivial destructor, nor shall it be an array type whose elements
22777 (directly or indirectly) have non-trivial destructors.
22778 @end quotation
22780 @item
22781 @b{[basic.stc]}
22783 Add ``thread storage duration'' to the list in paragraph 1.
22785 Change paragraph 2
22787 @quotation
22788 Thread, static, and automatic storage durations are associated with
22789 objects introduced by declarations [@dots{}].
22790 @end quotation
22792 Add @code{__thread} to the list of specifiers in paragraph 3.
22794 @item
22795 @b{[basic.stc.thread]}
22797 New section before @b{[basic.stc.static]}
22799 @quotation
22800 The keyword @code{__thread} applied to a non-local object gives the
22801 object thread storage duration.
22803 A local variable or class data member declared both @code{static}
22804 and @code{__thread} gives the variable or member thread storage
22805 duration.
22806 @end quotation
22808 @item
22809 @b{[basic.stc.static]}
22811 Change paragraph 1
22813 @quotation
22814 All objects that have neither thread storage duration, dynamic
22815 storage duration nor are local [@dots{}].
22816 @end quotation
22818 @item
22819 @b{[dcl.stc]}
22821 Add @code{__thread} to the list in paragraph 1.
22823 Change paragraph 1
22825 @quotation
22826 With the exception of @code{__thread}, at most one
22827 @var{storage-class-specifier} shall appear in a given
22828 @var{decl-specifier-seq}.  The @code{__thread} specifier may
22829 be used alone, or immediately following the @code{extern} or
22830 @code{static} specifiers.  [@dots{}]
22831 @end quotation
22833 Add after paragraph 5
22835 @quotation
22836 The @code{__thread} specifier can be applied only to the names of objects
22837 and to anonymous unions.
22838 @end quotation
22840 @item
22841 @b{[class.mem]}
22843 Add after paragraph 6
22845 @quotation
22846 Non-@code{static} members shall not be @code{__thread}.
22847 @end quotation
22848 @end itemize
22850 @node Binary constants
22851 @section Binary Constants using the @samp{0b} Prefix
22852 @cindex Binary constants using the @samp{0b} prefix
22854 Integer constants can be written as binary constants, consisting of a
22855 sequence of @samp{0} and @samp{1} digits, prefixed by @samp{0b} or
22856 @samp{0B}.  This is particularly useful in environments that operate a
22857 lot on the bit level (like microcontrollers).
22859 The following statements are identical:
22861 @smallexample
22862 i =       42;
22863 i =     0x2a;
22864 i =      052;
22865 i = 0b101010;
22866 @end smallexample
22868 The type of these constants follows the same rules as for octal or
22869 hexadecimal integer constants, so suffixes like @samp{L} or @samp{UL}
22870 can be applied.
22872 @node C++ Extensions
22873 @chapter Extensions to the C++ Language
22874 @cindex extensions, C++ language
22875 @cindex C++ language extensions
22877 The GNU compiler provides these extensions to the C++ language (and you
22878 can also use most of the C language extensions in your C++ programs).  If you
22879 want to write code that checks whether these features are available, you can
22880 test for the GNU compiler the same way as for C programs: check for a
22881 predefined macro @code{__GNUC__}.  You can also use @code{__GNUG__} to
22882 test specifically for GNU C++ (@pxref{Common Predefined Macros,,
22883 Predefined Macros,cpp,The GNU C Preprocessor}).
22885 @menu
22886 * C++ Volatiles::       What constitutes an access to a volatile object.
22887 * Restricted Pointers:: C99 restricted pointers and references.
22888 * Vague Linkage::       Where G++ puts inlines, vtables and such.
22889 * C++ Interface::       You can use a single C++ header file for both
22890                         declarations and definitions.
22891 * Template Instantiation:: Methods for ensuring that exactly one copy of
22892                         each needed template instantiation is emitted.
22893 * Bound member functions:: You can extract a function pointer to the
22894                         method denoted by a @samp{->*} or @samp{.*} expression.
22895 * C++ Attributes::      Variable, function, and type attributes for C++ only.
22896 * Function Multiversioning::   Declaring multiple function versions.
22897 * Type Traits::         Compiler support for type traits.
22898 * C++ Concepts::        Improved support for generic programming.
22899 * Deprecated Features:: Things will disappear from G++.
22900 * Backwards Compatibility:: Compatibilities with earlier definitions of C++.
22901 @end menu
22903 @node C++ Volatiles
22904 @section When is a Volatile C++ Object Accessed?
22905 @cindex accessing volatiles
22906 @cindex volatile read
22907 @cindex volatile write
22908 @cindex volatile access
22910 The C++ standard differs from the C standard in its treatment of
22911 volatile objects.  It fails to specify what constitutes a volatile
22912 access, except to say that C++ should behave in a similar manner to C
22913 with respect to volatiles, where possible.  However, the different
22914 lvalueness of expressions between C and C++ complicate the behavior.
22915 G++ behaves the same as GCC for volatile access, @xref{C
22916 Extensions,,Volatiles}, for a description of GCC's behavior.
22918 The C and C++ language specifications differ when an object is
22919 accessed in a void context:
22921 @smallexample
22922 volatile int *src = @var{somevalue};
22923 *src;
22924 @end smallexample
22926 The C++ standard specifies that such expressions do not undergo lvalue
22927 to rvalue conversion, and that the type of the dereferenced object may
22928 be incomplete.  The C++ standard does not specify explicitly that it
22929 is lvalue to rvalue conversion that is responsible for causing an
22930 access.  There is reason to believe that it is, because otherwise
22931 certain simple expressions become undefined.  However, because it
22932 would surprise most programmers, G++ treats dereferencing a pointer to
22933 volatile object of complete type as GCC would do for an equivalent
22934 type in C@.  When the object has incomplete type, G++ issues a
22935 warning; if you wish to force an error, you must force a conversion to
22936 rvalue with, for instance, a static cast.
22938 When using a reference to volatile, G++ does not treat equivalent
22939 expressions as accesses to volatiles, but instead issues a warning that
22940 no volatile is accessed.  The rationale for this is that otherwise it
22941 becomes difficult to determine where volatile access occur, and not
22942 possible to ignore the return value from functions returning volatile
22943 references.  Again, if you wish to force a read, cast the reference to
22944 an rvalue.
22946 G++ implements the same behavior as GCC does when assigning to a
22947 volatile object---there is no reread of the assigned-to object, the
22948 assigned rvalue is reused.  Note that in C++ assignment expressions
22949 are lvalues, and if used as an lvalue, the volatile object is
22950 referred to.  For instance, @var{vref} refers to @var{vobj}, as
22951 expected, in the following example:
22953 @smallexample
22954 volatile int vobj;
22955 volatile int &vref = vobj = @var{something};
22956 @end smallexample
22958 @node Restricted Pointers
22959 @section Restricting Pointer Aliasing
22960 @cindex restricted pointers
22961 @cindex restricted references
22962 @cindex restricted this pointer
22964 As with the C front end, G++ understands the C99 feature of restricted pointers,
22965 specified with the @code{__restrict__}, or @code{__restrict} type
22966 qualifier.  Because you cannot compile C++ by specifying the @option{-std=c99}
22967 language flag, @code{restrict} is not a keyword in C++.
22969 In addition to allowing restricted pointers, you can specify restricted
22970 references, which indicate that the reference is not aliased in the local
22971 context.
22973 @smallexample
22974 void fn (int *__restrict__ rptr, int &__restrict__ rref)
22976   /* @r{@dots{}} */
22978 @end smallexample
22980 @noindent
22981 In the body of @code{fn}, @var{rptr} points to an unaliased integer and
22982 @var{rref} refers to a (different) unaliased integer.
22984 You may also specify whether a member function's @var{this} pointer is
22985 unaliased by using @code{__restrict__} as a member function qualifier.
22987 @smallexample
22988 void T::fn () __restrict__
22990   /* @r{@dots{}} */
22992 @end smallexample
22994 @noindent
22995 Within the body of @code{T::fn}, @var{this} has the effective
22996 definition @code{T *__restrict__ const this}.  Notice that the
22997 interpretation of a @code{__restrict__} member function qualifier is
22998 different to that of @code{const} or @code{volatile} qualifier, in that it
22999 is applied to the pointer rather than the object.  This is consistent with
23000 other compilers that implement restricted pointers.
23002 As with all outermost parameter qualifiers, @code{__restrict__} is
23003 ignored in function definition matching.  This means you only need to
23004 specify @code{__restrict__} in a function definition, rather than
23005 in a function prototype as well.
23007 @node Vague Linkage
23008 @section Vague Linkage
23009 @cindex vague linkage
23011 There are several constructs in C++ that require space in the object
23012 file but are not clearly tied to a single translation unit.  We say that
23013 these constructs have ``vague linkage''.  Typically such constructs are
23014 emitted wherever they are needed, though sometimes we can be more
23015 clever.
23017 @table @asis
23018 @item Inline Functions
23019 Inline functions are typically defined in a header file which can be
23020 included in many different compilations.  Hopefully they can usually be
23021 inlined, but sometimes an out-of-line copy is necessary, if the address
23022 of the function is taken or if inlining fails.  In general, we emit an
23023 out-of-line copy in all translation units where one is needed.  As an
23024 exception, we only emit inline virtual functions with the vtable, since
23025 it always requires a copy.
23027 Local static variables and string constants used in an inline function
23028 are also considered to have vague linkage, since they must be shared
23029 between all inlined and out-of-line instances of the function.
23031 @item VTables
23032 @cindex vtable
23033 C++ virtual functions are implemented in most compilers using a lookup
23034 table, known as a vtable.  The vtable contains pointers to the virtual
23035 functions provided by a class, and each object of the class contains a
23036 pointer to its vtable (or vtables, in some multiple-inheritance
23037 situations).  If the class declares any non-inline, non-pure virtual
23038 functions, the first one is chosen as the ``key method'' for the class,
23039 and the vtable is only emitted in the translation unit where the key
23040 method is defined.
23042 @emph{Note:} If the chosen key method is later defined as inline, the
23043 vtable is still emitted in every translation unit that defines it.
23044 Make sure that any inline virtuals are declared inline in the class
23045 body, even if they are not defined there.
23047 @item @code{type_info} objects
23048 @cindex @code{type_info}
23049 @cindex RTTI
23050 C++ requires information about types to be written out in order to
23051 implement @samp{dynamic_cast}, @samp{typeid} and exception handling.
23052 For polymorphic classes (classes with virtual functions), the @samp{type_info}
23053 object is written out along with the vtable so that @samp{dynamic_cast}
23054 can determine the dynamic type of a class object at run time.  For all
23055 other types, we write out the @samp{type_info} object when it is used: when
23056 applying @samp{typeid} to an expression, throwing an object, or
23057 referring to a type in a catch clause or exception specification.
23059 @item Template Instantiations
23060 Most everything in this section also applies to template instantiations,
23061 but there are other options as well.
23062 @xref{Template Instantiation,,Where's the Template?}.
23064 @end table
23066 When used with GNU ld version 2.8 or later on an ELF system such as
23067 GNU/Linux or Solaris 2, or on Microsoft Windows, duplicate copies of
23068 these constructs will be discarded at link time.  This is known as
23069 COMDAT support.
23071 On targets that don't support COMDAT, but do support weak symbols, GCC
23072 uses them.  This way one copy overrides all the others, but
23073 the unused copies still take up space in the executable.
23075 For targets that do not support either COMDAT or weak symbols,
23076 most entities with vague linkage are emitted as local symbols to
23077 avoid duplicate definition errors from the linker.  This does not happen
23078 for local statics in inlines, however, as having multiple copies
23079 almost certainly breaks things.
23081 @xref{C++ Interface,,Declarations and Definitions in One Header}, for
23082 another way to control placement of these constructs.
23084 @node C++ Interface
23085 @section C++ Interface and Implementation Pragmas
23087 @cindex interface and implementation headers, C++
23088 @cindex C++ interface and implementation headers
23089 @cindex pragmas, interface and implementation
23091 @code{#pragma interface} and @code{#pragma implementation} provide the
23092 user with a way of explicitly directing the compiler to emit entities
23093 with vague linkage (and debugging information) in a particular
23094 translation unit.
23096 @emph{Note:} These @code{#pragma}s have been superceded as of GCC 2.7.2
23097 by COMDAT support and the ``key method'' heuristic
23098 mentioned in @ref{Vague Linkage}.  Using them can actually cause your
23099 program to grow due to unnecessary out-of-line copies of inline
23100 functions.
23102 @table @code
23103 @item #pragma interface
23104 @itemx #pragma interface "@var{subdir}/@var{objects}.h"
23105 @kindex #pragma interface
23106 Use this directive in @emph{header files} that define object classes, to save
23107 space in most of the object files that use those classes.  Normally,
23108 local copies of certain information (backup copies of inline member
23109 functions, debugging information, and the internal tables that implement
23110 virtual functions) must be kept in each object file that includes class
23111 definitions.  You can use this pragma to avoid such duplication.  When a
23112 header file containing @samp{#pragma interface} is included in a
23113 compilation, this auxiliary information is not generated (unless
23114 the main input source file itself uses @samp{#pragma implementation}).
23115 Instead, the object files contain references to be resolved at link
23116 time.
23118 The second form of this directive is useful for the case where you have
23119 multiple headers with the same name in different directories.  If you
23120 use this form, you must specify the same string to @samp{#pragma
23121 implementation}.
23123 @item #pragma implementation
23124 @itemx #pragma implementation "@var{objects}.h"
23125 @kindex #pragma implementation
23126 Use this pragma in a @emph{main input file}, when you want full output from
23127 included header files to be generated (and made globally visible).  The
23128 included header file, in turn, should use @samp{#pragma interface}.
23129 Backup copies of inline member functions, debugging information, and the
23130 internal tables used to implement virtual functions are all generated in
23131 implementation files.
23133 @cindex implied @code{#pragma implementation}
23134 @cindex @code{#pragma implementation}, implied
23135 @cindex naming convention, implementation headers
23136 If you use @samp{#pragma implementation} with no argument, it applies to
23137 an include file with the same basename@footnote{A file's @dfn{basename}
23138 is the name stripped of all leading path information and of trailing
23139 suffixes, such as @samp{.h} or @samp{.C} or @samp{.cc}.} as your source
23140 file.  For example, in @file{allclass.cc}, giving just
23141 @samp{#pragma implementation}
23142 by itself is equivalent to @samp{#pragma implementation "allclass.h"}.
23144 Use the string argument if you want a single implementation file to
23145 include code from multiple header files.  (You must also use
23146 @samp{#include} to include the header file; @samp{#pragma
23147 implementation} only specifies how to use the file---it doesn't actually
23148 include it.)
23150 There is no way to split up the contents of a single header file into
23151 multiple implementation files.
23152 @end table
23154 @cindex inlining and C++ pragmas
23155 @cindex C++ pragmas, effect on inlining
23156 @cindex pragmas in C++, effect on inlining
23157 @samp{#pragma implementation} and @samp{#pragma interface} also have an
23158 effect on function inlining.
23160 If you define a class in a header file marked with @samp{#pragma
23161 interface}, the effect on an inline function defined in that class is
23162 similar to an explicit @code{extern} declaration---the compiler emits
23163 no code at all to define an independent version of the function.  Its
23164 definition is used only for inlining with its callers.
23166 @opindex fno-implement-inlines
23167 Conversely, when you include the same header file in a main source file
23168 that declares it as @samp{#pragma implementation}, the compiler emits
23169 code for the function itself; this defines a version of the function
23170 that can be found via pointers (or by callers compiled without
23171 inlining).  If all calls to the function can be inlined, you can avoid
23172 emitting the function by compiling with @option{-fno-implement-inlines}.
23173 If any calls are not inlined, you will get linker errors.
23175 @node Template Instantiation
23176 @section Where's the Template?
23177 @cindex template instantiation
23179 C++ templates were the first language feature to require more
23180 intelligence from the environment than was traditionally found on a UNIX
23181 system.  Somehow the compiler and linker have to make sure that each
23182 template instance occurs exactly once in the executable if it is needed,
23183 and not at all otherwise.  There are two basic approaches to this
23184 problem, which are referred to as the Borland model and the Cfront model.
23186 @table @asis
23187 @item Borland model
23188 Borland C++ solved the template instantiation problem by adding the code
23189 equivalent of common blocks to their linker; the compiler emits template
23190 instances in each translation unit that uses them, and the linker
23191 collapses them together.  The advantage of this model is that the linker
23192 only has to consider the object files themselves; there is no external
23193 complexity to worry about.  The disadvantage is that compilation time
23194 is increased because the template code is being compiled repeatedly.
23195 Code written for this model tends to include definitions of all
23196 templates in the header file, since they must be seen to be
23197 instantiated.
23199 @item Cfront model
23200 The AT&T C++ translator, Cfront, solved the template instantiation
23201 problem by creating the notion of a template repository, an
23202 automatically maintained place where template instances are stored.  A
23203 more modern version of the repository works as follows: As individual
23204 object files are built, the compiler places any template definitions and
23205 instantiations encountered in the repository.  At link time, the link
23206 wrapper adds in the objects in the repository and compiles any needed
23207 instances that were not previously emitted.  The advantages of this
23208 model are more optimal compilation speed and the ability to use the
23209 system linker; to implement the Borland model a compiler vendor also
23210 needs to replace the linker.  The disadvantages are vastly increased
23211 complexity, and thus potential for error; for some code this can be
23212 just as transparent, but in practice it can been very difficult to build
23213 multiple programs in one directory and one program in multiple
23214 directories.  Code written for this model tends to separate definitions
23215 of non-inline member templates into a separate file, which should be
23216 compiled separately.
23217 @end table
23219 G++ implements the Borland model on targets where the linker supports it,
23220 including ELF targets (such as GNU/Linux), Mac OS X and Microsoft Windows.
23221 Otherwise G++ implements neither automatic model.
23223 You have the following options for dealing with template instantiations:
23225 @enumerate
23226 @item
23227 Do nothing.  Code written for the Borland model works fine, but
23228 each translation unit contains instances of each of the templates it
23229 uses.  The duplicate instances will be discarded by the linker, but in
23230 a large program, this can lead to an unacceptable amount of code
23231 duplication in object files or shared libraries.
23233 Duplicate instances of a template can be avoided by defining an explicit
23234 instantiation in one object file, and preventing the compiler from doing
23235 implicit instantiations in any other object files by using an explicit
23236 instantiation declaration, using the @code{extern template} syntax:
23238 @smallexample
23239 extern template int max (int, int);
23240 @end smallexample
23242 This syntax is defined in the C++ 2011 standard, but has been supported by
23243 G++ and other compilers since well before 2011.
23245 Explicit instantiations can be used for the largest or most frequently
23246 duplicated instances, without having to know exactly which other instances
23247 are used in the rest of the program.  You can scatter the explicit
23248 instantiations throughout your program, perhaps putting them in the
23249 translation units where the instances are used or the translation units
23250 that define the templates themselves; you can put all of the explicit
23251 instantiations you need into one big file; or you can create small files
23252 like
23254 @smallexample
23255 #include "Foo.h"
23256 #include "Foo.cc"
23258 template class Foo<int>;
23259 template ostream& operator <<
23260                 (ostream&, const Foo<int>&);
23261 @end smallexample
23263 @noindent
23264 for each of the instances you need, and create a template instantiation
23265 library from those.
23267 This is the simplest option, but also offers flexibility and
23268 fine-grained control when necessary. It is also the most portable
23269 alternative and programs using this approach will work with most modern
23270 compilers.
23272 @item
23273 @opindex frepo
23274 Compile your template-using code with @option{-frepo}.  The compiler
23275 generates files with the extension @samp{.rpo} listing all of the
23276 template instantiations used in the corresponding object files that
23277 could be instantiated there; the link wrapper, @samp{collect2},
23278 then updates the @samp{.rpo} files to tell the compiler where to place
23279 those instantiations and rebuild any affected object files.  The
23280 link-time overhead is negligible after the first pass, as the compiler
23281 continues to place the instantiations in the same files.
23283 This can be a suitable option for application code written for the Borland
23284 model, as it usually just works.  Code written for the Cfront model 
23285 needs to be modified so that the template definitions are available at
23286 one or more points of instantiation; usually this is as simple as adding
23287 @code{#include <tmethods.cc>} to the end of each template header.
23289 For library code, if you want the library to provide all of the template
23290 instantiations it needs, just try to link all of its object files
23291 together; the link will fail, but cause the instantiations to be
23292 generated as a side effect.  Be warned, however, that this may cause
23293 conflicts if multiple libraries try to provide the same instantiations.
23294 For greater control, use explicit instantiation as described in the next
23295 option.
23297 @item
23298 @opindex fno-implicit-templates
23299 Compile your code with @option{-fno-implicit-templates} to disable the
23300 implicit generation of template instances, and explicitly instantiate
23301 all the ones you use.  This approach requires more knowledge of exactly
23302 which instances you need than do the others, but it's less
23303 mysterious and allows greater control if you want to ensure that only
23304 the intended instances are used.
23306 If you are using Cfront-model code, you can probably get away with not
23307 using @option{-fno-implicit-templates} when compiling files that don't
23308 @samp{#include} the member template definitions.
23310 If you use one big file to do the instantiations, you may want to
23311 compile it without @option{-fno-implicit-templates} so you get all of the
23312 instances required by your explicit instantiations (but not by any
23313 other files) without having to specify them as well.
23315 In addition to forward declaration of explicit instantiations
23316 (with @code{extern}), G++ has extended the template instantiation
23317 syntax to support instantiation of the compiler support data for a
23318 template class (i.e.@: the vtable) without instantiating any of its
23319 members (with @code{inline}), and instantiation of only the static data
23320 members of a template class, without the support data or member
23321 functions (with @code{static}):
23323 @smallexample
23324 inline template class Foo<int>;
23325 static template class Foo<int>;
23326 @end smallexample
23327 @end enumerate
23329 @node Bound member functions
23330 @section Extracting the Function Pointer from a Bound Pointer to Member Function
23331 @cindex pmf
23332 @cindex pointer to member function
23333 @cindex bound pointer to member function
23335 In C++, pointer to member functions (PMFs) are implemented using a wide
23336 pointer of sorts to handle all the possible call mechanisms; the PMF
23337 needs to store information about how to adjust the @samp{this} pointer,
23338 and if the function pointed to is virtual, where to find the vtable, and
23339 where in the vtable to look for the member function.  If you are using
23340 PMFs in an inner loop, you should really reconsider that decision.  If
23341 that is not an option, you can extract the pointer to the function that
23342 would be called for a given object/PMF pair and call it directly inside
23343 the inner loop, to save a bit of time.
23345 Note that you still pay the penalty for the call through a
23346 function pointer; on most modern architectures, such a call defeats the
23347 branch prediction features of the CPU@.  This is also true of normal
23348 virtual function calls.
23350 The syntax for this extension is
23352 @smallexample
23353 extern A a;
23354 extern int (A::*fp)();
23355 typedef int (*fptr)(A *);
23357 fptr p = (fptr)(a.*fp);
23358 @end smallexample
23360 For PMF constants (i.e.@: expressions of the form @samp{&Klasse::Member}),
23361 no object is needed to obtain the address of the function.  They can be
23362 converted to function pointers directly:
23364 @smallexample
23365 fptr p1 = (fptr)(&A::foo);
23366 @end smallexample
23368 @opindex Wno-pmf-conversions
23369 You must specify @option{-Wno-pmf-conversions} to use this extension.
23371 @node C++ Attributes
23372 @section C++-Specific Variable, Function, and Type Attributes
23374 Some attributes only make sense for C++ programs.
23376 @table @code
23377 @item abi_tag ("@var{tag}", ...)
23378 @cindex @code{abi_tag} function attribute
23379 @cindex @code{abi_tag} variable attribute
23380 @cindex @code{abi_tag} type attribute
23381 The @code{abi_tag} attribute can be applied to a function, variable, or class
23382 declaration.  It modifies the mangled name of the entity to
23383 incorporate the tag name, in order to distinguish the function or
23384 class from an earlier version with a different ABI; perhaps the class
23385 has changed size, or the function has a different return type that is
23386 not encoded in the mangled name.
23388 The attribute can also be applied to an inline namespace, but does not
23389 affect the mangled name of the namespace; in this case it is only used
23390 for @option{-Wabi-tag} warnings and automatic tagging of functions and
23391 variables.  Tagging inline namespaces is generally preferable to
23392 tagging individual declarations, but the latter is sometimes
23393 necessary, such as when only certain members of a class need to be
23394 tagged.
23396 The argument can be a list of strings of arbitrary length.  The
23397 strings are sorted on output, so the order of the list is
23398 unimportant.
23400 A redeclaration of an entity must not add new ABI tags,
23401 since doing so would change the mangled name.
23403 The ABI tags apply to a name, so all instantiations and
23404 specializations of a template have the same tags.  The attribute will
23405 be ignored if applied to an explicit specialization or instantiation.
23407 The @option{-Wabi-tag} flag enables a warning about a class which does
23408 not have all the ABI tags used by its subobjects and virtual functions; for users with code
23409 that needs to coexist with an earlier ABI, using this option can help
23410 to find all affected types that need to be tagged.
23412 When a type involving an ABI tag is used as the type of a variable or
23413 return type of a function where that tag is not already present in the
23414 signature of the function, the tag is automatically applied to the
23415 variable or function.  @option{-Wabi-tag} also warns about this
23416 situation; this warning can be avoided by explicitly tagging the
23417 variable or function or moving it into a tagged inline namespace.
23419 @item init_priority (@var{priority})
23420 @cindex @code{init_priority} variable attribute
23422 In Standard C++, objects defined at namespace scope are guaranteed to be
23423 initialized in an order in strict accordance with that of their definitions
23424 @emph{in a given translation unit}.  No guarantee is made for initializations
23425 across translation units.  However, GNU C++ allows users to control the
23426 order of initialization of objects defined at namespace scope with the
23427 @code{init_priority} attribute by specifying a relative @var{priority},
23428 a constant integral expression currently bounded between 101 and 65535
23429 inclusive.  Lower numbers indicate a higher priority.
23431 In the following example, @code{A} would normally be created before
23432 @code{B}, but the @code{init_priority} attribute reverses that order:
23434 @smallexample
23435 Some_Class  A  __attribute__ ((init_priority (2000)));
23436 Some_Class  B  __attribute__ ((init_priority (543)));
23437 @end smallexample
23439 @noindent
23440 Note that the particular values of @var{priority} do not matter; only their
23441 relative ordering.
23443 @item warn_unused
23444 @cindex @code{warn_unused} type attribute
23446 For C++ types with non-trivial constructors and/or destructors it is
23447 impossible for the compiler to determine whether a variable of this
23448 type is truly unused if it is not referenced. This type attribute
23449 informs the compiler that variables of this type should be warned
23450 about if they appear to be unused, just like variables of fundamental
23451 types.
23453 This attribute is appropriate for types which just represent a value,
23454 such as @code{std::string}; it is not appropriate for types which
23455 control a resource, such as @code{std::lock_guard}.
23457 This attribute is also accepted in C, but it is unnecessary because C
23458 does not have constructors or destructors.
23460 @end table
23462 @node Function Multiversioning
23463 @section Function Multiversioning
23464 @cindex function versions
23466 With the GNU C++ front end, for x86 targets, you may specify multiple
23467 versions of a function, where each function is specialized for a
23468 specific target feature.  At runtime, the appropriate version of the
23469 function is automatically executed depending on the characteristics of
23470 the execution platform.  Here is an example.
23472 @smallexample
23473 __attribute__ ((target ("default")))
23474 int foo ()
23476   // The default version of foo.
23477   return 0;
23480 __attribute__ ((target ("sse4.2")))
23481 int foo ()
23483   // foo version for SSE4.2
23484   return 1;
23487 __attribute__ ((target ("arch=atom")))
23488 int foo ()
23490   // foo version for the Intel ATOM processor
23491   return 2;
23494 __attribute__ ((target ("arch=amdfam10")))
23495 int foo ()
23497   // foo version for the AMD Family 0x10 processors.
23498   return 3;
23501 int main ()
23503   int (*p)() = &foo;
23504   assert ((*p) () == foo ());
23505   return 0;
23507 @end smallexample
23509 In the above example, four versions of function foo are created. The
23510 first version of foo with the target attribute "default" is the default
23511 version.  This version gets executed when no other target specific
23512 version qualifies for execution on a particular platform. A new version
23513 of foo is created by using the same function signature but with a
23514 different target string.  Function foo is called or a pointer to it is
23515 taken just like a regular function.  GCC takes care of doing the
23516 dispatching to call the right version at runtime.  Refer to the
23517 @uref{http://gcc.gnu.org/wiki/FunctionMultiVersioning, GCC wiki on
23518 Function Multiversioning} for more details.
23520 @node Type Traits
23521 @section Type Traits
23523 The C++ front end implements syntactic extensions that allow
23524 compile-time determination of 
23525 various characteristics of a type (or of a
23526 pair of types).
23528 @table @code
23529 @item __has_nothrow_assign (type)
23530 If @code{type} is const qualified or is a reference type then the trait is
23531 false.  Otherwise if @code{__has_trivial_assign (type)} is true then the trait
23532 is true, else if @code{type} is a cv class or union type with copy assignment
23533 operators that are known not to throw an exception then the trait is true,
23534 else it is false.  Requires: @code{type} shall be a complete type,
23535 (possibly cv-qualified) @code{void}, or an array of unknown bound.
23537 @item __has_nothrow_copy (type)
23538 If @code{__has_trivial_copy (type)} is true then the trait is true, else if
23539 @code{type} is a cv class or union type with copy constructors that
23540 are known not to throw an exception then the trait is true, else it is false.
23541 Requires: @code{type} shall be a complete type, (possibly cv-qualified)
23542 @code{void}, or an array of unknown bound.
23544 @item __has_nothrow_constructor (type)
23545 If @code{__has_trivial_constructor (type)} is true then the trait is
23546 true, else if @code{type} is a cv class or union type (or array
23547 thereof) with a default constructor that is known not to throw an
23548 exception then the trait is true, else it is false.  Requires:
23549 @code{type} shall be a complete type, (possibly cv-qualified)
23550 @code{void}, or an array of unknown bound.
23552 @item __has_trivial_assign (type)
23553 If @code{type} is const qualified or is a reference type then the trait is
23554 false.  Otherwise if @code{__is_pod (type)} is true then the trait is
23555 true, else if @code{type} is a cv class or union type with a trivial
23556 copy assignment ([class.copy]) then the trait is true, else it is
23557 false.  Requires: @code{type} shall be a complete type, (possibly
23558 cv-qualified) @code{void}, or an array of unknown bound.
23560 @item __has_trivial_copy (type)
23561 If @code{__is_pod (type)} is true or @code{type} is a reference type
23562 then the trait is true, else if @code{type} is a cv class or union type
23563 with a trivial copy constructor ([class.copy]) then the trait
23564 is true, else it is false.  Requires: @code{type} shall be a complete
23565 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
23567 @item __has_trivial_constructor (type)
23568 If @code{__is_pod (type)} is true then the trait is true, else if
23569 @code{type} is a cv class or union type (or array thereof) with a
23570 trivial default constructor ([class.ctor]) then the trait is true,
23571 else it is false.  Requires: @code{type} shall be a complete
23572 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
23574 @item __has_trivial_destructor (type)
23575 If @code{__is_pod (type)} is true or @code{type} is a reference type then
23576 the trait is true, else if @code{type} is a cv class or union type (or
23577 array thereof) with a trivial destructor ([class.dtor]) then the trait
23578 is true, else it is false.  Requires: @code{type} shall be a complete
23579 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
23581 @item __has_virtual_destructor (type)
23582 If @code{type} is a class type with a virtual destructor
23583 ([class.dtor]) then the trait is true, else it is false.  Requires:
23584 @code{type} shall be a complete type, (possibly cv-qualified)
23585 @code{void}, or an array of unknown bound.
23587 @item __is_abstract (type)
23588 If @code{type} is an abstract class ([class.abstract]) then the trait
23589 is true, else it is false.  Requires: @code{type} shall be a complete
23590 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
23592 @item __is_base_of (base_type, derived_type)
23593 If @code{base_type} is a base class of @code{derived_type}
23594 ([class.derived]) then the trait is true, otherwise it is false.
23595 Top-level cv qualifications of @code{base_type} and
23596 @code{derived_type} are ignored.  For the purposes of this trait, a
23597 class type is considered is own base.  Requires: if @code{__is_class
23598 (base_type)} and @code{__is_class (derived_type)} are true and
23599 @code{base_type} and @code{derived_type} are not the same type
23600 (disregarding cv-qualifiers), @code{derived_type} shall be a complete
23601 type.  A diagnostic is produced if this requirement is not met.
23603 @item __is_class (type)
23604 If @code{type} is a cv class type, and not a union type
23605 ([basic.compound]) the trait is true, else it is false.
23607 @item __is_empty (type)
23608 If @code{__is_class (type)} is false then the trait is false.
23609 Otherwise @code{type} is considered empty if and only if: @code{type}
23610 has no non-static data members, or all non-static data members, if
23611 any, are bit-fields of length 0, and @code{type} has no virtual
23612 members, and @code{type} has no virtual base classes, and @code{type}
23613 has no base classes @code{base_type} for which
23614 @code{__is_empty (base_type)} is false.  Requires: @code{type} shall
23615 be a complete type, (possibly cv-qualified) @code{void}, or an array
23616 of unknown bound.
23618 @item __is_enum (type)
23619 If @code{type} is a cv enumeration type ([basic.compound]) the trait is
23620 true, else it is false.
23622 @item __is_literal_type (type)
23623 If @code{type} is a literal type ([basic.types]) the trait is
23624 true, else it is false.  Requires: @code{type} shall be a complete type,
23625 (possibly cv-qualified) @code{void}, or an array of unknown bound.
23627 @item __is_pod (type)
23628 If @code{type} is a cv POD type ([basic.types]) then the trait is true,
23629 else it is false.  Requires: @code{type} shall be a complete type,
23630 (possibly cv-qualified) @code{void}, or an array of unknown bound.
23632 @item __is_polymorphic (type)
23633 If @code{type} is a polymorphic class ([class.virtual]) then the trait
23634 is true, else it is false.  Requires: @code{type} shall be a complete
23635 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
23637 @item __is_standard_layout (type)
23638 If @code{type} is a standard-layout type ([basic.types]) the trait is
23639 true, else it is false.  Requires: @code{type} shall be a complete
23640 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
23642 @item __is_trivial (type)
23643 If @code{type} is a trivial type ([basic.types]) the trait is
23644 true, else it is false.  Requires: @code{type} shall be a complete
23645 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
23647 @item __is_union (type)
23648 If @code{type} is a cv union type ([basic.compound]) the trait is
23649 true, else it is false.
23651 @item __underlying_type (type)
23652 The underlying type of @code{type}.  Requires: @code{type} shall be
23653 an enumeration type ([dcl.enum]).
23655 @item __integer_pack (length)
23656 When used as the pattern of a pack expansion within a template
23657 definition, expands to a template argument pack containing integers
23658 from @code{0} to @code{length-1}.  This is provided for efficient
23659 implementation of @code{std::make_integer_sequence}.
23661 @end table
23664 @node C++ Concepts
23665 @section C++ Concepts
23667 C++ concepts provide much-improved support for generic programming. In
23668 particular, they allow the specification of constraints on template arguments.
23669 The constraints are used to extend the usual overloading and partial
23670 specialization capabilities of the language, allowing generic data structures
23671 and algorithms to be ``refined'' based on their properties rather than their
23672 type names.
23674 The following keywords are reserved for concepts.
23676 @table @code
23677 @item assumes
23678 States an expression as an assumption, and if possible, verifies that the
23679 assumption is valid. For example, @code{assume(n > 0)}.
23681 @item axiom
23682 Introduces an axiom definition. Axioms introduce requirements on values.
23684 @item forall
23685 Introduces a universally quantified object in an axiom. For example,
23686 @code{forall (int n) n + 0 == n}).
23688 @item concept
23689 Introduces a concept definition. Concepts are sets of syntactic and semantic
23690 requirements on types and their values.
23692 @item requires
23693 Introduces constraints on template arguments or requirements for a member
23694 function of a class template.
23696 @end table
23698 The front end also exposes a number of internal mechanism that can be used
23699 to simplify the writing of type traits. Note that some of these traits are
23700 likely to be removed in the future.
23702 @table @code
23703 @item __is_same (type1, type2)
23704 A binary type trait: true whenever the type arguments are the same.
23706 @end table
23709 @node Deprecated Features
23710 @section Deprecated Features
23712 In the past, the GNU C++ compiler was extended to experiment with new
23713 features, at a time when the C++ language was still evolving.  Now that
23714 the C++ standard is complete, some of those features are superseded by
23715 superior alternatives.  Using the old features might cause a warning in
23716 some cases that the feature will be dropped in the future.  In other
23717 cases, the feature might be gone already.
23719 While the list below is not exhaustive, it documents some of the options
23720 that are now deprecated:
23722 @table @code
23723 @item -fexternal-templates
23724 @itemx -falt-external-templates
23725 These are two of the many ways for G++ to implement template
23726 instantiation.  @xref{Template Instantiation}.  The C++ standard clearly
23727 defines how template definitions have to be organized across
23728 implementation units.  G++ has an implicit instantiation mechanism that
23729 should work just fine for standard-conforming code.
23731 @item -fstrict-prototype
23732 @itemx -fno-strict-prototype
23733 Previously it was possible to use an empty prototype parameter list to
23734 indicate an unspecified number of parameters (like C), rather than no
23735 parameters, as C++ demands.  This feature has been removed, except where
23736 it is required for backwards compatibility.   @xref{Backwards Compatibility}.
23737 @end table
23739 G++ allows a virtual function returning @samp{void *} to be overridden
23740 by one returning a different pointer type.  This extension to the
23741 covariant return type rules is now deprecated and will be removed from a
23742 future version.
23744 The G++ minimum and maximum operators (@samp{<?} and @samp{>?}) and
23745 their compound forms (@samp{<?=}) and @samp{>?=}) have been deprecated
23746 and are now removed from G++.  Code using these operators should be
23747 modified to use @code{std::min} and @code{std::max} instead.
23749 The named return value extension has been deprecated, and is now
23750 removed from G++.
23752 The use of initializer lists with new expressions has been deprecated,
23753 and is now removed from G++.
23755 Floating and complex non-type template parameters have been deprecated,
23756 and are now removed from G++.
23758 The implicit typename extension has been deprecated and is now
23759 removed from G++.
23761 The use of default arguments in function pointers, function typedefs
23762 and other places where they are not permitted by the standard is
23763 deprecated and will be removed from a future version of G++.
23765 G++ allows floating-point literals to appear in integral constant expressions,
23766 e.g.@: @samp{ enum E @{ e = int(2.2 * 3.7) @} }
23767 This extension is deprecated and will be removed from a future version.
23769 G++ allows static data members of const floating-point type to be declared
23770 with an initializer in a class definition. The standard only allows
23771 initializers for static members of const integral types and const
23772 enumeration types so this extension has been deprecated and will be removed
23773 from a future version.
23775 @node Backwards Compatibility
23776 @section Backwards Compatibility
23777 @cindex Backwards Compatibility
23778 @cindex ARM [Annotated C++ Reference Manual]
23780 Now that there is a definitive ISO standard C++, G++ has a specification
23781 to adhere to.  The C++ language evolved over time, and features that
23782 used to be acceptable in previous drafts of the standard, such as the ARM
23783 [Annotated C++ Reference Manual], are no longer accepted.  In order to allow
23784 compilation of C++ written to such drafts, G++ contains some backwards
23785 compatibilities.  @emph{All such backwards compatibility features are
23786 liable to disappear in future versions of G++.} They should be considered
23787 deprecated.   @xref{Deprecated Features}.
23789 @table @code
23790 @item For scope
23791 If a variable is declared at for scope, it used to remain in scope until
23792 the end of the scope that contained the for statement (rather than just
23793 within the for scope).  G++ retains this, but issues a warning, if such a
23794 variable is accessed outside the for scope.
23796 @item Implicit C language
23797 Old C system header files did not contain an @code{extern "C" @{@dots{}@}}
23798 scope to set the language.  On such systems, all header files are
23799 implicitly scoped inside a C language scope.  Also, an empty prototype
23800 @code{()} is treated as an unspecified number of arguments, rather
23801 than no arguments, as C++ demands.
23802 @end table
23804 @c  LocalWords:  emph deftypefn builtin ARCv2EM SIMD builtins msimd
23805 @c  LocalWords:  typedef v4si v8hi DMA dma vdiwr vdowr