2018-05-14 Sebastian Peryt <sebastian.peryt@intel.com>
[official-gcc.git] / gcc / doc / extend.texi
blobb738b841cd8432c608fed3e3af2d626e89453293
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 attribute
2279 syntax and placement.  Compatible attribute specifications on distinct
2280 declarations of the same function are merged.  An attribute specification
2281 that is not compatible with attributes already applied to a declaration
2282 of the same function is ignored with a warning.
2284 GCC also supports attributes on
2285 variable declarations (@pxref{Variable Attributes}),
2286 labels (@pxref{Label Attributes}),
2287 enumerators (@pxref{Enumerator Attributes}),
2288 statements (@pxref{Statement Attributes}),
2289 and types (@pxref{Type Attributes}).
2291 There is some overlap between the purposes of attributes and pragmas
2292 (@pxref{Pragmas,,Pragmas Accepted by GCC}).  It has been
2293 found convenient to use @code{__attribute__} to achieve a natural
2294 attachment of attributes to their corresponding declarations, whereas
2295 @code{#pragma} is of use for compatibility with other compilers
2296 or constructs that do not naturally form part of the grammar.
2298 In addition to the attributes documented here,
2299 GCC plugins may provide their own attributes.
2301 @menu
2302 * Common Function Attributes::
2303 * AArch64 Function Attributes::
2304 * ARC Function Attributes::
2305 * ARM Function Attributes::
2306 * AVR Function Attributes::
2307 * Blackfin Function Attributes::
2308 * CR16 Function Attributes::
2309 * Epiphany Function Attributes::
2310 * H8/300 Function Attributes::
2311 * IA-64 Function Attributes::
2312 * M32C Function Attributes::
2313 * M32R/D Function Attributes::
2314 * m68k Function Attributes::
2315 * MCORE Function Attributes::
2316 * MeP Function Attributes::
2317 * MicroBlaze Function Attributes::
2318 * Microsoft Windows Function Attributes::
2319 * MIPS Function Attributes::
2320 * MSP430 Function Attributes::
2321 * NDS32 Function Attributes::
2322 * Nios II Function Attributes::
2323 * Nvidia PTX Function Attributes::
2324 * PowerPC Function Attributes::
2325 * RISC-V Function Attributes::
2326 * RL78 Function Attributes::
2327 * RX Function Attributes::
2328 * S/390 Function Attributes::
2329 * SH Function Attributes::
2330 * SPU Function Attributes::
2331 * Symbian OS Function Attributes::
2332 * V850 Function Attributes::
2333 * Visium Function Attributes::
2334 * x86 Function Attributes::
2335 * Xstormy16 Function Attributes::
2336 @end menu
2338 @node Common Function Attributes
2339 @subsection Common Function Attributes
2341 The following attributes are supported on most targets.
2343 @table @code
2344 @c Keep this table alphabetized by attribute name.  Treat _ as space.
2346 @item alias ("@var{target}")
2347 @cindex @code{alias} function attribute
2348 The @code{alias} attribute causes the declaration to be emitted as an
2349 alias for another symbol, which must be specified.  For instance,
2351 @smallexample
2352 void __f () @{ /* @r{Do something.} */; @}
2353 void f () __attribute__ ((weak, alias ("__f")));
2354 @end smallexample
2356 @noindent
2357 defines @samp{f} to be a weak alias for @samp{__f}.  In C++, the
2358 mangled name for the target must be used.  It is an error if @samp{__f}
2359 is not defined in the same translation unit.
2361 This attribute requires assembler and object file support,
2362 and may not be available on all targets.
2364 @item aligned (@var{alignment})
2365 @cindex @code{aligned} function attribute
2366 This attribute specifies a minimum alignment for the function,
2367 measured in bytes.
2369 You cannot use this attribute to decrease the alignment of a function,
2370 only to increase it.  However, when you explicitly specify a function
2371 alignment this overrides the effect of the
2372 @option{-falign-functions} (@pxref{Optimize Options}) option for this
2373 function.
2375 Note that the effectiveness of @code{aligned} attributes may be
2376 limited by inherent limitations in your linker.  On many systems, the
2377 linker is only able to arrange for functions to be aligned up to a
2378 certain maximum alignment.  (For some linkers, the maximum supported
2379 alignment may be very very small.)  See your linker documentation for
2380 further information.
2382 The @code{aligned} attribute can also be used for variables and fields
2383 (@pxref{Variable Attributes}.)
2385 @item alloc_align
2386 @cindex @code{alloc_align} function attribute
2387 The @code{alloc_align} attribute is used to tell the compiler that the
2388 function return value points to memory, where the returned pointer minimum
2389 alignment is given by one of the functions parameters.  GCC uses this
2390 information to improve pointer alignment analysis.
2392 The function parameter denoting the allocated alignment is specified by
2393 one integer argument, whose number is the argument of the attribute.
2394 Argument numbering starts at one.
2396 For instance,
2398 @smallexample
2399 void* my_memalign(size_t, size_t) __attribute__((alloc_align(1)))
2400 @end smallexample
2402 @noindent
2403 declares that @code{my_memalign} returns memory with minimum alignment
2404 given by parameter 1.
2406 @item alloc_size
2407 @cindex @code{alloc_size} function attribute
2408 The @code{alloc_size} attribute is used to tell the compiler that the
2409 function return value points to memory, where the size is given by
2410 one or two of the functions parameters.  GCC uses this
2411 information to improve the correctness of @code{__builtin_object_size}.
2413 The function parameter(s) denoting the allocated size are specified by
2414 one or two integer arguments supplied to the attribute.  The allocated size
2415 is either the value of the single function argument specified or the product
2416 of the two function arguments specified.  Argument numbering starts at
2417 one.
2419 For instance,
2421 @smallexample
2422 void* my_calloc(size_t, size_t) __attribute__((alloc_size(1,2)))
2423 void* my_realloc(void*, size_t) __attribute__((alloc_size(2)))
2424 @end smallexample
2426 @noindent
2427 declares that @code{my_calloc} returns memory of the size given by
2428 the product of parameter 1 and 2 and that @code{my_realloc} returns memory
2429 of the size given by parameter 2.
2431 @item always_inline
2432 @cindex @code{always_inline} function attribute
2433 Generally, functions are not inlined unless optimization is specified.
2434 For functions declared inline, this attribute inlines the function
2435 independent of any restrictions that otherwise apply to inlining.
2436 Failure to inline such a function is diagnosed as an error.
2437 Note that if such a function is called indirectly the compiler may
2438 or may not inline it depending on optimization level and a failure
2439 to inline an indirect call may or may not be diagnosed.
2441 @item artificial
2442 @cindex @code{artificial} function attribute
2443 This attribute is useful for small inline wrappers that if possible
2444 should appear during debugging as a unit.  Depending on the debug
2445 info format it either means marking the function as artificial
2446 or using the caller location for all instructions within the inlined
2447 body.
2449 @item assume_aligned
2450 @cindex @code{assume_aligned} function attribute
2451 The @code{assume_aligned} attribute is used to tell the compiler that the
2452 function return value points to memory, where the returned pointer minimum
2453 alignment is given by the first argument.
2454 If the attribute has two arguments, the second argument is misalignment offset.
2456 For instance
2458 @smallexample
2459 void* my_alloc1(size_t) __attribute__((assume_aligned(16)))
2460 void* my_alloc2(size_t) __attribute__((assume_aligned(32, 8)))
2461 @end smallexample
2463 @noindent
2464 declares that @code{my_alloc1} returns 16-byte aligned pointer and
2465 that @code{my_alloc2} returns a pointer whose value modulo 32 is equal
2466 to 8.
2468 @item bnd_instrument
2469 @cindex @code{bnd_instrument} function attribute
2470 The @code{bnd_instrument} attribute on functions is used to inform the
2471 compiler that the function should be instrumented when compiled
2472 with the @option{-fchkp-instrument-marked-only} option.
2474 @item bnd_legacy
2475 @cindex @code{bnd_legacy} function attribute
2476 @cindex Pointer Bounds Checker attributes
2477 The @code{bnd_legacy} attribute on functions is used to inform the
2478 compiler that the function should not be instrumented when compiled
2479 with the @option{-fcheck-pointer-bounds} option.
2481 @item cold
2482 @cindex @code{cold} function attribute
2483 The @code{cold} attribute on functions is used to inform the compiler that
2484 the function is unlikely to be executed.  The function is optimized for
2485 size rather than speed and on many targets it is placed into a special
2486 subsection of the text section so all cold functions appear close together,
2487 improving code locality of non-cold parts of program.  The paths leading
2488 to calls of cold functions within code are marked as unlikely by the branch
2489 prediction mechanism.  It is thus useful to mark functions used to handle
2490 unlikely conditions, such as @code{perror}, as cold to improve optimization
2491 of hot functions that do call marked functions in rare occasions.
2493 When profile feedback is available, via @option{-fprofile-use}, cold functions
2494 are automatically detected and this attribute is ignored.
2496 @item const
2497 @cindex @code{const} function attribute
2498 @cindex functions that have no side effects
2499 Many functions do not examine any values except their arguments, and
2500 have no effects except to return a value.  Calls to such functions lend
2501 themselves to optimization such as common subexpression elimination.
2502 The @code{const} attribute imposes greater restrictions on a function's
2503 definition than the similar @code{pure} attribute below because it prohibits
2504 the function from reading global variables.  Consequently, the presence of
2505 the attribute on a function declaration allows GCC to emit more efficient
2506 code for some calls to the function.  Decorating the same function with
2507 both the @code{const} and the @code{pure} attribute is diagnosed.
2509 @cindex pointer arguments
2510 Note that a function that has pointer arguments and examines the data
2511 pointed to must @emph{not} be declared @code{const}.  Likewise, a
2512 function that calls a non-@code{const} function usually must not be
2513 @code{const}.  Because a @code{const} function cannot have any side
2514 effects it does not make sense for such a function to return @code{void}.
2515 Declaring such a function is diagnosed.
2517 @item constructor
2518 @itemx destructor
2519 @itemx constructor (@var{priority})
2520 @itemx destructor (@var{priority})
2521 @cindex @code{constructor} function attribute
2522 @cindex @code{destructor} function attribute
2523 The @code{constructor} attribute causes the function to be called
2524 automatically before execution enters @code{main ()}.  Similarly, the
2525 @code{destructor} attribute causes the function to be called
2526 automatically after @code{main ()} completes or @code{exit ()} is
2527 called.  Functions with these attributes are useful for
2528 initializing data that is used implicitly during the execution of
2529 the program.
2531 You may provide an optional integer priority to control the order in
2532 which constructor and destructor functions are run.  A constructor
2533 with a smaller priority number runs before a constructor with a larger
2534 priority number; the opposite relationship holds for destructors.  So,
2535 if you have a constructor that allocates a resource and a destructor
2536 that deallocates the same resource, both functions typically have the
2537 same priority.  The priorities for constructor and destructor
2538 functions are the same as those specified for namespace-scope C++
2539 objects (@pxref{C++ Attributes}).  However, at present, the order in which
2540 constructors for C++ objects with static storage duration and functions
2541 decorated with attribute @code{constructor} are invoked is unspecified.
2542 In mixed declarations, attribute @code{init_priority} can be used to
2543 impose a specific ordering.
2545 @item deprecated
2546 @itemx deprecated (@var{msg})
2547 @cindex @code{deprecated} function attribute
2548 The @code{deprecated} attribute results in a warning if the function
2549 is used anywhere in the source file.  This is useful when identifying
2550 functions that are expected to be removed in a future version of a
2551 program.  The warning also includes the location of the declaration
2552 of the deprecated function, to enable users to easily find further
2553 information about why the function is deprecated, or what they should
2554 do instead.  Note that the warnings only occurs for uses:
2556 @smallexample
2557 int old_fn () __attribute__ ((deprecated));
2558 int old_fn ();
2559 int (*fn_ptr)() = old_fn;
2560 @end smallexample
2562 @noindent
2563 results in a warning on line 3 but not line 2.  The optional @var{msg}
2564 argument, which must be a string, is printed in the warning if
2565 present.
2567 The @code{deprecated} attribute can also be used for variables and
2568 types (@pxref{Variable Attributes}, @pxref{Type Attributes}.)
2570 @item error ("@var{message}")
2571 @itemx warning ("@var{message}")
2572 @cindex @code{error} function attribute
2573 @cindex @code{warning} function attribute
2574 If the @code{error} or @code{warning} attribute 
2575 is used on a function declaration and a call to such a function
2576 is not eliminated through dead code elimination or other optimizations, 
2577 an error or warning (respectively) that includes @var{message} is diagnosed.  
2578 This is useful
2579 for compile-time checking, especially together with @code{__builtin_constant_p}
2580 and inline functions where checking the inline function arguments is not
2581 possible through @code{extern char [(condition) ? 1 : -1];} tricks.
2583 While it is possible to leave the function undefined and thus invoke
2584 a link failure (to define the function with
2585 a message in @code{.gnu.warning*} section),
2586 when using these attributes the problem is diagnosed
2587 earlier and with exact location of the call even in presence of inline
2588 functions or when not emitting debugging information.
2590 @item externally_visible
2591 @cindex @code{externally_visible} function attribute
2592 This attribute, attached to a global variable or function, nullifies
2593 the effect of the @option{-fwhole-program} command-line option, so the
2594 object remains visible outside the current compilation unit.
2596 If @option{-fwhole-program} is used together with @option{-flto} and 
2597 @command{gold} is used as the linker plugin, 
2598 @code{externally_visible} attributes are automatically added to functions 
2599 (not variable yet due to a current @command{gold} issue) 
2600 that are accessed outside of LTO objects according to resolution file
2601 produced by @command{gold}.
2602 For other linkers that cannot generate resolution file,
2603 explicit @code{externally_visible} attributes are still necessary.
2605 @item flatten
2606 @cindex @code{flatten} function attribute
2607 Generally, inlining into a function is limited.  For a function marked with
2608 this attribute, every call inside this function is inlined, if possible.
2609 Whether the function itself is considered for inlining depends on its size and
2610 the current inlining parameters.
2612 @item format (@var{archetype}, @var{string-index}, @var{first-to-check})
2613 @cindex @code{format} function attribute
2614 @cindex functions with @code{printf}, @code{scanf}, @code{strftime} or @code{strfmon} style arguments
2615 @opindex Wformat
2616 The @code{format} attribute specifies that a function takes @code{printf},
2617 @code{scanf}, @code{strftime} or @code{strfmon} style arguments that
2618 should be type-checked against a format string.  For example, the
2619 declaration:
2621 @smallexample
2622 extern int
2623 my_printf (void *my_object, const char *my_format, ...)
2624       __attribute__ ((format (printf, 2, 3)));
2625 @end smallexample
2627 @noindent
2628 causes the compiler to check the arguments in calls to @code{my_printf}
2629 for consistency with the @code{printf} style format string argument
2630 @code{my_format}.
2632 The parameter @var{archetype} determines how the format string is
2633 interpreted, and should be @code{printf}, @code{scanf}, @code{strftime},
2634 @code{gnu_printf}, @code{gnu_scanf}, @code{gnu_strftime} or
2635 @code{strfmon}.  (You can also use @code{__printf__},
2636 @code{__scanf__}, @code{__strftime__} or @code{__strfmon__}.)  On
2637 MinGW targets, @code{ms_printf}, @code{ms_scanf}, and
2638 @code{ms_strftime} are also present.
2639 @var{archetype} values such as @code{printf} refer to the formats accepted
2640 by the system's C runtime library,
2641 while values prefixed with @samp{gnu_} always refer
2642 to the formats accepted by the GNU C Library.  On Microsoft Windows
2643 targets, values prefixed with @samp{ms_} refer to the formats accepted by the
2644 @file{msvcrt.dll} library.
2645 The parameter @var{string-index}
2646 specifies which argument is the format string argument (starting
2647 from 1), while @var{first-to-check} is the number of the first
2648 argument to check against the format string.  For functions
2649 where the arguments are not available to be checked (such as
2650 @code{vprintf}), specify the third parameter as zero.  In this case the
2651 compiler only checks the format string for consistency.  For
2652 @code{strftime} formats, the third parameter is required to be zero.
2653 Since non-static C++ methods have an implicit @code{this} argument, the
2654 arguments of such methods should be counted from two, not one, when
2655 giving values for @var{string-index} and @var{first-to-check}.
2657 In the example above, the format string (@code{my_format}) is the second
2658 argument of the function @code{my_print}, and the arguments to check
2659 start with the third argument, so the correct parameters for the format
2660 attribute are 2 and 3.
2662 @opindex ffreestanding
2663 @opindex fno-builtin
2664 The @code{format} attribute allows you to identify your own functions
2665 that take format strings as arguments, so that GCC can check the
2666 calls to these functions for errors.  The compiler always (unless
2667 @option{-ffreestanding} or @option{-fno-builtin} is used) checks formats
2668 for the standard library functions @code{printf}, @code{fprintf},
2669 @code{sprintf}, @code{scanf}, @code{fscanf}, @code{sscanf}, @code{strftime},
2670 @code{vprintf}, @code{vfprintf} and @code{vsprintf} whenever such
2671 warnings are requested (using @option{-Wformat}), so there is no need to
2672 modify the header file @file{stdio.h}.  In C99 mode, the functions
2673 @code{snprintf}, @code{vsnprintf}, @code{vscanf}, @code{vfscanf} and
2674 @code{vsscanf} are also checked.  Except in strictly conforming C
2675 standard modes, the X/Open function @code{strfmon} is also checked as
2676 are @code{printf_unlocked} and @code{fprintf_unlocked}.
2677 @xref{C Dialect Options,,Options Controlling C Dialect}.
2679 For Objective-C dialects, @code{NSString} (or @code{__NSString__}) is
2680 recognized in the same context.  Declarations including these format attributes
2681 are parsed for correct syntax, however the result of checking of such format
2682 strings is not yet defined, and is not carried out by this version of the
2683 compiler.
2685 The target may also provide additional types of format checks.
2686 @xref{Target Format Checks,,Format Checks Specific to Particular
2687 Target Machines}.
2689 @item format_arg (@var{string-index})
2690 @cindex @code{format_arg} function attribute
2691 @opindex Wformat-nonliteral
2692 The @code{format_arg} attribute specifies that a function takes a format
2693 string for a @code{printf}, @code{scanf}, @code{strftime} or
2694 @code{strfmon} style function and modifies it (for example, to translate
2695 it into another language), so the result can be passed to a
2696 @code{printf}, @code{scanf}, @code{strftime} or @code{strfmon} style
2697 function (with the remaining arguments to the format function the same
2698 as they would have been for the unmodified string).  For example, the
2699 declaration:
2701 @smallexample
2702 extern char *
2703 my_dgettext (char *my_domain, const char *my_format)
2704       __attribute__ ((format_arg (2)));
2705 @end smallexample
2707 @noindent
2708 causes the compiler to check the arguments in calls to a @code{printf},
2709 @code{scanf}, @code{strftime} or @code{strfmon} type function, whose
2710 format string argument is a call to the @code{my_dgettext} function, for
2711 consistency with the format string argument @code{my_format}.  If the
2712 @code{format_arg} attribute had not been specified, all the compiler
2713 could tell in such calls to format functions would be that the format
2714 string argument is not constant; this would generate a warning when
2715 @option{-Wformat-nonliteral} is used, but the calls could not be checked
2716 without the attribute.
2718 The parameter @var{string-index} specifies which argument is the format
2719 string argument (starting from one).  Since non-static C++ methods have
2720 an implicit @code{this} argument, the arguments of such methods should
2721 be counted from two.
2723 The @code{format_arg} attribute allows you to identify your own
2724 functions that modify format strings, so that GCC can check the
2725 calls to @code{printf}, @code{scanf}, @code{strftime} or @code{strfmon}
2726 type function whose operands are a call to one of your own function.
2727 The compiler always treats @code{gettext}, @code{dgettext}, and
2728 @code{dcgettext} in this manner except when strict ISO C support is
2729 requested by @option{-ansi} or an appropriate @option{-std} option, or
2730 @option{-ffreestanding} or @option{-fno-builtin}
2731 is used.  @xref{C Dialect Options,,Options
2732 Controlling C Dialect}.
2734 For Objective-C dialects, the @code{format-arg} attribute may refer to an
2735 @code{NSString} reference for compatibility with the @code{format} attribute
2736 above.
2738 The target may also allow additional types in @code{format-arg} attributes.
2739 @xref{Target Format Checks,,Format Checks Specific to Particular
2740 Target Machines}.
2742 @item gnu_inline
2743 @cindex @code{gnu_inline} function attribute
2744 This attribute should be used with a function that is also declared
2745 with the @code{inline} keyword.  It directs GCC to treat the function
2746 as if it were defined in gnu90 mode even when compiling in C99 or
2747 gnu99 mode.
2749 If the function is declared @code{extern}, then this definition of the
2750 function is used only for inlining.  In no case is the function
2751 compiled as a standalone function, not even if you take its address
2752 explicitly.  Such an address becomes an external reference, as if you
2753 had only declared the function, and had not defined it.  This has
2754 almost the effect of a macro.  The way to use this is to put a
2755 function definition in a header file with this attribute, and put
2756 another copy of the function, without @code{extern}, in a library
2757 file.  The definition in the header file causes most calls to the
2758 function to be inlined.  If any uses of the function remain, they
2759 refer to the single copy in the library.  Note that the two
2760 definitions of the functions need not be precisely the same, although
2761 if they do not have the same effect your program may behave oddly.
2763 In C, if the function is neither @code{extern} nor @code{static}, then
2764 the function is compiled as a standalone function, as well as being
2765 inlined where possible.
2767 This is how GCC traditionally handled functions declared
2768 @code{inline}.  Since ISO C99 specifies a different semantics for
2769 @code{inline}, this function attribute is provided as a transition
2770 measure and as a useful feature in its own right.  This attribute is
2771 available in GCC 4.1.3 and later.  It is available if either of the
2772 preprocessor macros @code{__GNUC_GNU_INLINE__} or
2773 @code{__GNUC_STDC_INLINE__} are defined.  @xref{Inline,,An Inline
2774 Function is As Fast As a Macro}.
2776 In C++, this attribute does not depend on @code{extern} in any way,
2777 but it still requires the @code{inline} keyword to enable its special
2778 behavior.
2780 @item hot
2781 @cindex @code{hot} function attribute
2782 The @code{hot} attribute on a function is used to inform the compiler that
2783 the function is a hot spot of the compiled program.  The function is
2784 optimized more aggressively and on many targets it is placed into a special
2785 subsection of the text section so all hot functions appear close together,
2786 improving locality.
2788 When profile feedback is available, via @option{-fprofile-use}, hot functions
2789 are automatically detected and this attribute is ignored.
2791 @item ifunc ("@var{resolver}")
2792 @cindex @code{ifunc} function attribute
2793 @cindex indirect functions
2794 @cindex functions that are dynamically resolved
2795 The @code{ifunc} attribute is used to mark a function as an indirect
2796 function using the STT_GNU_IFUNC symbol type extension to the ELF
2797 standard.  This allows the resolution of the symbol value to be
2798 determined dynamically at load time, and an optimized version of the
2799 routine to be selected for the particular processor or other system
2800 characteristics determined then.  To use this attribute, first define
2801 the implementation functions available, and a resolver function that
2802 returns a pointer to the selected implementation function.  The
2803 implementation functions' declarations must match the API of the
2804 function being implemented.  The resolver should be declared to
2805 be a function taking no arguments and returning a pointer to
2806 a function of the same type as the implementation.  For example:
2808 @smallexample
2809 void *my_memcpy (void *dst, const void *src, size_t len)
2811   @dots{}
2812   return dst;
2815 static void * (*resolve_memcpy (void))(void *, const void *, size_t)
2817   return my_memcpy; // we will just always select this routine
2819 @end smallexample
2821 @noindent
2822 The exported header file declaring the function the user calls would
2823 contain:
2825 @smallexample
2826 extern void *memcpy (void *, const void *, size_t);
2827 @end smallexample
2829 @noindent
2830 allowing the user to call @code{memcpy} as a regular function, unaware of
2831 the actual implementation.  Finally, the indirect function needs to be
2832 defined in the same translation unit as the resolver function:
2834 @smallexample
2835 void *memcpy (void *, const void *, size_t)
2836      __attribute__ ((ifunc ("resolve_memcpy")));
2837 @end smallexample
2839 In C++, the @code{ifunc} attribute takes a string that is the mangled name
2840 of the resolver function.  A C++ resolver for a non-static member function
2841 of class @code{C} should be declared to return a pointer to a non-member
2842 function taking pointer to @code{C} as the first argument, followed by
2843 the same arguments as of the implementation function.  G++ checks
2844 the signatures of the two functions and issues
2845 a @option{-Wattribute-alias} warning for mismatches.  To suppress a warning
2846 for the necessary cast from a pointer to the implementation member function
2847 to the type of the corresponding non-member function use
2848 the @option{-Wno-pmf-conversions} option.  For example:
2850 @smallexample
2851 class S
2853 private:
2854   int debug_impl (int);
2855   int optimized_impl (int);
2857   typedef int Func (S*, int);
2859   static Func* resolver ();
2860 public:
2862   int interface (int);
2865 int S::debug_impl (int) @{ /* @r{@dots{}} */ @}
2866 int S::optimized_impl (int) @{ /* @r{@dots{}} */ @}
2868 S::Func* S::resolver ()
2870   int (S::*pimpl) (int)
2871     = getenv ("DEBUG") ? &S::debug_impl : &S::optimized_impl;
2873   // Cast triggers -Wno-pmf-conversions.
2874   return reinterpret_cast<Func*>(pimpl);
2877 int S::interface (int) __attribute__ ((ifunc ("_ZN1S8resolverEv")));
2878 @end smallexample
2880 Indirect functions cannot be weak.  Binutils version 2.20.1 or higher
2881 and GNU C Library version 2.11.1 are required to use this feature.
2883 @item interrupt
2884 @itemx interrupt_handler
2885 Many GCC back ends support attributes to indicate that a function is
2886 an interrupt handler, which tells the compiler to generate function
2887 entry and exit sequences that differ from those from regular
2888 functions.  The exact syntax and behavior are target-specific;
2889 refer to the following subsections for details.
2891 @item leaf
2892 @cindex @code{leaf} function attribute
2893 Calls to external functions with this attribute must return to the
2894 current compilation unit only by return or by exception handling.  In
2895 particular, a leaf function is not allowed to invoke callback functions
2896 passed to it from the current compilation unit, directly call functions
2897 exported by the unit, or @code{longjmp} into the unit.  Leaf functions
2898 might still call functions from other compilation units and thus they
2899 are not necessarily leaf in the sense that they contain no function
2900 calls at all.
2902 The attribute is intended for library functions to improve dataflow
2903 analysis.  The compiler takes the hint that any data not escaping the
2904 current compilation unit cannot be used or modified by the leaf
2905 function.  For example, the @code{sin} function is a leaf function, but
2906 @code{qsort} is not.
2908 Note that leaf functions might indirectly run a signal handler defined
2909 in the current compilation unit that uses static variables.  Similarly,
2910 when lazy symbol resolution is in effect, leaf functions might invoke
2911 indirect functions whose resolver function or implementation function is
2912 defined in the current compilation unit and uses static variables.  There
2913 is no standard-compliant way to write such a signal handler, resolver
2914 function, or implementation function, and the best that you can do is to
2915 remove the @code{leaf} attribute or mark all such static variables
2916 @code{volatile}.  Lastly, for ELF-based systems that support symbol
2917 interposition, care should be taken that functions defined in the
2918 current compilation unit do not unexpectedly interpose other symbols
2919 based on the defined standards mode and defined feature test macros;
2920 otherwise an inadvertent callback would be added.
2922 The attribute has no effect on functions defined within the current
2923 compilation unit.  This is to allow easy merging of multiple compilation
2924 units into one, for example, by using the link-time optimization.  For
2925 this reason the attribute is not allowed on types to annotate indirect
2926 calls.
2928 @item malloc
2929 @cindex @code{malloc} function attribute
2930 @cindex functions that behave like malloc
2931 This tells the compiler that a function is @code{malloc}-like, i.e.,
2932 that the pointer @var{P} returned by the function cannot alias any
2933 other pointer valid when the function returns, and moreover no
2934 pointers to valid objects occur in any storage addressed by @var{P}.
2936 Using this attribute can improve optimization.  Functions like
2937 @code{malloc} and @code{calloc} have this property because they return
2938 a pointer to uninitialized or zeroed-out storage.  However, functions
2939 like @code{realloc} do not have this property, as they can return a
2940 pointer to storage containing pointers.
2942 @item no_icf
2943 @cindex @code{no_icf} function attribute
2944 This function attribute prevents a functions from being merged with another
2945 semantically equivalent function.
2947 @item no_instrument_function
2948 @cindex @code{no_instrument_function} function attribute
2949 @opindex finstrument-functions
2950 If @option{-finstrument-functions} is given, profiling function calls are
2951 generated at entry and exit of most user-compiled functions.
2952 Functions with this attribute are not so instrumented.
2954 @item no_profile_instrument_function
2955 @cindex @code{no_profile_instrument_function} function attribute
2956 The @code{no_profile_instrument_function} attribute on functions is used
2957 to inform the compiler that it should not process any profile feedback based
2958 optimization code instrumentation.
2960 @item no_reorder
2961 @cindex @code{no_reorder} function attribute
2962 Do not reorder functions or variables marked @code{no_reorder}
2963 against each other or top level assembler statements the executable.
2964 The actual order in the program will depend on the linker command
2965 line. Static variables marked like this are also not removed.
2966 This has a similar effect
2967 as the @option{-fno-toplevel-reorder} option, but only applies to the
2968 marked symbols.
2970 @item no_sanitize ("@var{sanitize_option}")
2971 @cindex @code{no_sanitize} function attribute
2972 The @code{no_sanitize} attribute on functions is used
2973 to inform the compiler that it should not do sanitization of all options
2974 mentioned in @var{sanitize_option}.  A list of values acceptable by
2975 @option{-fsanitize} option can be provided.
2977 @smallexample
2978 void __attribute__ ((no_sanitize ("alignment", "object-size")))
2979 f () @{ /* @r{Do something.} */; @}
2980 void __attribute__ ((no_sanitize ("alignment,object-size")))
2981 g () @{ /* @r{Do something.} */; @}
2982 @end smallexample
2984 @item no_sanitize_address
2985 @itemx no_address_safety_analysis
2986 @cindex @code{no_sanitize_address} function attribute
2987 The @code{no_sanitize_address} attribute on functions is used
2988 to inform the compiler that it should not instrument memory accesses
2989 in the function when compiling with the @option{-fsanitize=address} option.
2990 The @code{no_address_safety_analysis} is a deprecated alias of the
2991 @code{no_sanitize_address} attribute, new code should use
2992 @code{no_sanitize_address}.
2994 @item no_sanitize_thread
2995 @cindex @code{no_sanitize_thread} function attribute
2996 The @code{no_sanitize_thread} attribute on functions is used
2997 to inform the compiler that it should not instrument memory accesses
2998 in the function when compiling with the @option{-fsanitize=thread} option.
3000 @item no_sanitize_undefined
3001 @cindex @code{no_sanitize_undefined} function attribute
3002 The @code{no_sanitize_undefined} attribute on functions is used
3003 to inform the compiler that it should not check for undefined behavior
3004 in the function when compiling with the @option{-fsanitize=undefined} option.
3006 @item no_split_stack
3007 @cindex @code{no_split_stack} function attribute
3008 @opindex fsplit-stack
3009 If @option{-fsplit-stack} is given, functions have a small
3010 prologue which decides whether to split the stack.  Functions with the
3011 @code{no_split_stack} attribute do not have that prologue, and thus
3012 may run with only a small amount of stack space available.
3014 @item no_stack_limit
3015 @cindex @code{no_stack_limit} function attribute
3016 This attribute locally overrides the @option{-fstack-limit-register}
3017 and @option{-fstack-limit-symbol} command-line options; it has the effect
3018 of disabling stack limit checking in the function it applies to.
3020 @item noclone
3021 @cindex @code{noclone} function attribute
3022 This function attribute prevents a function from being considered for
3023 cloning---a mechanism that produces specialized copies of functions
3024 and which is (currently) performed by interprocedural constant
3025 propagation.
3027 @item noinline
3028 @cindex @code{noinline} function attribute
3029 This function attribute prevents a function from being considered for
3030 inlining.
3031 @c Don't enumerate the optimizations by name here; we try to be
3032 @c future-compatible with this mechanism.
3033 If the function does not have side effects, there are optimizations
3034 other than inlining that cause function calls to be optimized away,
3035 although the function call is live.  To keep such calls from being
3036 optimized away, put
3037 @smallexample
3038 asm ("");
3039 @end smallexample
3041 @noindent
3042 (@pxref{Extended Asm}) in the called function, to serve as a special
3043 side effect.
3045 @item noipa
3046 @cindex @code{noipa} function attribute
3047 Disable interprocedural optimizations between the function with this
3048 attribute and its callers, as if the body of the function is not available
3049 when optimizing callers and the callers are unavailable when optimizing
3050 the body.  This attribute implies @code{noinline}, @code{noclone} and
3051 @code{no_icf} attributes.    However, this attribute is not equivalent
3052 to a combination of other attributes, because its purpose is to suppress
3053 existing and future optimizations employing interprocedural analysis,
3054 including those that do not have an attribute suitable for disabling
3055 them individually.  This attribute is supported mainly for the purpose
3056 of testing the compiler.
3058 @item nonnull (@var{arg-index}, @dots{})
3059 @cindex @code{nonnull} function attribute
3060 @cindex functions with non-null pointer arguments
3061 The @code{nonnull} attribute specifies that some function parameters should
3062 be non-null pointers.  For instance, the declaration:
3064 @smallexample
3065 extern void *
3066 my_memcpy (void *dest, const void *src, size_t len)
3067         __attribute__((nonnull (1, 2)));
3068 @end smallexample
3070 @noindent
3071 causes the compiler to check that, in calls to @code{my_memcpy},
3072 arguments @var{dest} and @var{src} are non-null.  If the compiler
3073 determines that a null pointer is passed in an argument slot marked
3074 as non-null, and the @option{-Wnonnull} option is enabled, a warning
3075 is issued.  The compiler may also choose to make optimizations based
3076 on the knowledge that certain function arguments will never be null.
3078 If no argument index list is given to the @code{nonnull} attribute,
3079 all pointer arguments are marked as non-null.  To illustrate, the
3080 following declaration is equivalent to the previous example:
3082 @smallexample
3083 extern void *
3084 my_memcpy (void *dest, const void *src, size_t len)
3085         __attribute__((nonnull));
3086 @end smallexample
3088 @item noplt
3089 @cindex @code{noplt} function attribute
3090 The @code{noplt} attribute is the counterpart to option @option{-fno-plt}.
3091 Calls to functions marked with this attribute in position-independent code
3092 do not use the PLT.
3094 @smallexample
3095 @group
3096 /* Externally defined function foo.  */
3097 int foo () __attribute__ ((noplt));
3100 main (/* @r{@dots{}} */)
3102   /* @r{@dots{}} */
3103   foo ();
3104   /* @r{@dots{}} */
3106 @end group
3107 @end smallexample
3109 The @code{noplt} attribute on function @code{foo}
3110 tells the compiler to assume that
3111 the function @code{foo} is externally defined and that the call to
3112 @code{foo} must avoid the PLT
3113 in position-independent code.
3115 In position-dependent code, a few targets also convert calls to
3116 functions that are marked to not use the PLT to use the GOT instead.
3118 @item noreturn
3119 @cindex @code{noreturn} function attribute
3120 @cindex functions that never return
3121 A few standard library functions, such as @code{abort} and @code{exit},
3122 cannot return.  GCC knows this automatically.  Some programs define
3123 their own functions that never return.  You can declare them
3124 @code{noreturn} to tell the compiler this fact.  For example,
3126 @smallexample
3127 @group
3128 void fatal () __attribute__ ((noreturn));
3130 void
3131 fatal (/* @r{@dots{}} */)
3133   /* @r{@dots{}} */ /* @r{Print error message.} */ /* @r{@dots{}} */
3134   exit (1);
3136 @end group
3137 @end smallexample
3139 The @code{noreturn} keyword tells the compiler to assume that
3140 @code{fatal} cannot return.  It can then optimize without regard to what
3141 would happen if @code{fatal} ever did return.  This makes slightly
3142 better code.  More importantly, it helps avoid spurious warnings of
3143 uninitialized variables.
3145 The @code{noreturn} keyword does not affect the exceptional path when that
3146 applies: a @code{noreturn}-marked function may still return to the caller
3147 by throwing an exception or calling @code{longjmp}.
3149 Do not assume that registers saved by the calling function are
3150 restored before calling the @code{noreturn} function.
3152 It does not make sense for a @code{noreturn} function to have a return
3153 type other than @code{void}.
3155 @item nothrow
3156 @cindex @code{nothrow} function attribute
3157 The @code{nothrow} attribute is used to inform the compiler that a
3158 function cannot throw an exception.  For example, most functions in
3159 the standard C library can be guaranteed not to throw an exception
3160 with the notable exceptions of @code{qsort} and @code{bsearch} that
3161 take function pointer arguments.
3163 @item optimize
3164 @cindex @code{optimize} function attribute
3165 The @code{optimize} attribute is used to specify that a function is to
3166 be compiled with different optimization options than specified on the
3167 command line.  Arguments can either be numbers or strings.  Numbers
3168 are assumed to be an optimization level.  Strings that begin with
3169 @code{O} are assumed to be an optimization option, while other options
3170 are assumed to be used with a @code{-f} prefix.  You can also use the
3171 @samp{#pragma GCC optimize} pragma to set the optimization options
3172 that affect more than one function.
3173 @xref{Function Specific Option Pragmas}, for details about the
3174 @samp{#pragma GCC optimize} pragma.
3176 This attribute should be used for debugging purposes only.  It is not
3177 suitable in production code.
3179 @item patchable_function_entry
3180 @cindex @code{patchable_function_entry} function attribute
3181 @cindex extra NOP instructions at the function entry point
3182 In case the target's text segment can be made writable at run time by
3183 any means, padding the function entry with a number of NOPs can be
3184 used to provide a universal tool for instrumentation.
3186 The @code{patchable_function_entry} function attribute can be used to
3187 change the number of NOPs to any desired value.  The two-value syntax
3188 is the same as for the command-line switch
3189 @option{-fpatchable-function-entry=N,M}, generating @var{N} NOPs, with
3190 the function entry point before the @var{M}th NOP instruction.
3191 @var{M} defaults to 0 if omitted e.g. function entry point is before
3192 the first NOP.
3194 If patchable function entries are enabled globally using the command-line
3195 option @option{-fpatchable-function-entry=N,M}, then you must disable
3196 instrumentation on all functions that are part of the instrumentation
3197 framework with the attribute @code{patchable_function_entry (0)}
3198 to prevent recursion.
3200 @item pure
3201 @cindex @code{pure} function attribute
3202 @cindex functions that have no side effects
3203 Many functions have no effects except the return value and their
3204 return value depends only on the parameters and/or global variables.
3205 Calls to such functions can be subject
3206 to common subexpression elimination and loop optimization just as an
3207 arithmetic operator would be.  These functions should be declared
3208 with the attribute @code{pure}.  For example,
3210 @smallexample
3211 int square (int) __attribute__ ((pure));
3212 @end smallexample
3214 @noindent
3215 says that the hypothetical function @code{square} is safe to call
3216 fewer times than the program says.
3218 Some common examples of pure functions are @code{strlen} or @code{memcmp}.
3219 Interesting non-pure functions are functions with infinite loops or those
3220 depending on volatile memory or other system resource, that may change between
3221 two consecutive calls (such as @code{feof} in a multithreading environment).
3223 The @code{pure} attribute imposes similar but looser restrictions on
3224 a function's defintion than the @code{const} attribute: it allows the
3225 function to read global variables.  Decorating the same function with
3226 both the @code{pure} and the @code{const} attribute is diagnosed.
3227 Because a @code{pure} function cannot have any side effects it does not
3228 make sense for such a function to return @code{void}.  Declaring such
3229 a function is diagnosed.
3231 @item returns_nonnull
3232 @cindex @code{returns_nonnull} function attribute
3233 The @code{returns_nonnull} attribute specifies that the function
3234 return value should be a non-null pointer.  For instance, the declaration:
3236 @smallexample
3237 extern void *
3238 mymalloc (size_t len) __attribute__((returns_nonnull));
3239 @end smallexample
3241 @noindent
3242 lets the compiler optimize callers based on the knowledge
3243 that the return value will never be null.
3245 @item returns_twice
3246 @cindex @code{returns_twice} function attribute
3247 @cindex functions that return more than once
3248 The @code{returns_twice} attribute tells the compiler that a function may
3249 return more than one time.  The compiler ensures that all registers
3250 are dead before calling such a function and emits a warning about
3251 the variables that may be clobbered after the second return from the
3252 function.  Examples of such functions are @code{setjmp} and @code{vfork}.
3253 The @code{longjmp}-like counterpart of such function, if any, might need
3254 to be marked with the @code{noreturn} attribute.
3256 @item section ("@var{section-name}")
3257 @cindex @code{section} function attribute
3258 @cindex functions in arbitrary sections
3259 Normally, the compiler places the code it generates in the @code{text} section.
3260 Sometimes, however, you need additional sections, or you need certain
3261 particular functions to appear in special sections.  The @code{section}
3262 attribute specifies that a function lives in a particular section.
3263 For example, the declaration:
3265 @smallexample
3266 extern void foobar (void) __attribute__ ((section ("bar")));
3267 @end smallexample
3269 @noindent
3270 puts the function @code{foobar} in the @code{bar} section.
3272 Some file formats do not support arbitrary sections so the @code{section}
3273 attribute is not available on all platforms.
3274 If you need to map the entire contents of a module to a particular
3275 section, consider using the facilities of the linker instead.
3277 @item sentinel
3278 @cindex @code{sentinel} function attribute
3279 This function attribute ensures that a parameter in a function call is
3280 an explicit @code{NULL}.  The attribute is only valid on variadic
3281 functions.  By default, the sentinel is located at position zero, the
3282 last parameter of the function call.  If an optional integer position
3283 argument P is supplied to the attribute, the sentinel must be located at
3284 position P counting backwards from the end of the argument list.
3286 @smallexample
3287 __attribute__ ((sentinel))
3288 is equivalent to
3289 __attribute__ ((sentinel(0)))
3290 @end smallexample
3292 The attribute is automatically set with a position of 0 for the built-in
3293 functions @code{execl} and @code{execlp}.  The built-in function
3294 @code{execle} has the attribute set with a position of 1.
3296 A valid @code{NULL} in this context is defined as zero with any pointer
3297 type.  If your system defines the @code{NULL} macro with an integer type
3298 then you need to add an explicit cast.  GCC replaces @code{stddef.h}
3299 with a copy that redefines NULL appropriately.
3301 The warnings for missing or incorrect sentinels are enabled with
3302 @option{-Wformat}.
3304 @item simd
3305 @itemx simd("@var{mask}")
3306 @cindex @code{simd} function attribute
3307 This attribute enables creation of one or more function versions that
3308 can process multiple arguments using SIMD instructions from a
3309 single invocation.  Specifying this attribute allows compiler to
3310 assume that such versions are available at link time (provided
3311 in the same or another translation unit).  Generated versions are
3312 target-dependent and described in the corresponding Vector ABI document.  For
3313 x86_64 target this document can be found
3314 @w{@uref{https://sourceware.org/glibc/wiki/libmvec?action=AttachFile&do=view&target=VectorABI.txt,here}}.
3316 The optional argument @var{mask} may have the value
3317 @code{notinbranch} or @code{inbranch},
3318 and instructs the compiler to generate non-masked or masked
3319 clones correspondingly. By default, all clones are generated.
3321 If the attribute is specified and @code{#pragma omp declare simd} is
3322 present on a declaration and the @option{-fopenmp} or @option{-fopenmp-simd}
3323 switch is specified, then the attribute is ignored.
3325 @item stack_protect
3326 @cindex @code{stack_protect} function attribute
3327 This attribute adds stack protection code to the function if 
3328 flags @option{-fstack-protector}, @option{-fstack-protector-strong}
3329 or @option{-fstack-protector-explicit} are set.
3331 @item target (@var{options})
3332 @cindex @code{target} function attribute
3333 Multiple target back ends implement the @code{target} attribute
3334 to specify that a function is to
3335 be compiled with different target options than specified on the
3336 command line.  This can be used for instance to have functions
3337 compiled with a different ISA (instruction set architecture) than the
3338 default.  You can also use the @samp{#pragma GCC target} pragma to set
3339 more than one function to be compiled with specific target options.
3340 @xref{Function Specific Option Pragmas}, for details about the
3341 @samp{#pragma GCC target} pragma.
3343 For instance, on an x86, you could declare one function with the
3344 @code{target("sse4.1,arch=core2")} attribute and another with
3345 @code{target("sse4a,arch=amdfam10")}.  This is equivalent to
3346 compiling the first function with @option{-msse4.1} and
3347 @option{-march=core2} options, and the second function with
3348 @option{-msse4a} and @option{-march=amdfam10} options.  It is up to you
3349 to make sure that a function is only invoked on a machine that
3350 supports the particular ISA it is compiled for (for example by using
3351 @code{cpuid} on x86 to determine what feature bits and architecture
3352 family are used).
3354 @smallexample
3355 int core2_func (void) __attribute__ ((__target__ ("arch=core2")));
3356 int sse3_func (void) __attribute__ ((__target__ ("sse3")));
3357 @end smallexample
3359 You can either use multiple
3360 strings separated by commas to specify multiple options,
3361 or separate the options with a comma (@samp{,}) within a single string.
3363 The options supported are specific to each target; refer to @ref{x86
3364 Function Attributes}, @ref{PowerPC Function Attributes},
3365 @ref{ARM Function Attributes}, @ref{AArch64 Function Attributes},
3366 @ref{Nios II Function Attributes}, and @ref{S/390 Function Attributes}
3367 for details.
3369 @item target_clones (@var{options})
3370 @cindex @code{target_clones} function attribute
3371 The @code{target_clones} attribute is used to specify that a function
3372 be cloned into multiple versions compiled with different target options
3373 than specified on the command line.  The supported options and restrictions
3374 are the same as for @code{target} attribute.
3376 For instance, on an x86, you could compile a function with
3377 @code{target_clones("sse4.1,avx")}.  GCC creates two function clones,
3378 one compiled with @option{-msse4.1} and another with @option{-mavx}.
3380 On a PowerPC, you can compile a function with
3381 @code{target_clones("cpu=power9,default")}.  GCC will create two
3382 function clones, one compiled with @option{-mcpu=power9} and another
3383 with the default options.  GCC must be configured to use GLIBC 2.23 or
3384 newer in order to use the @code{target_clones} attribute.
3386 It also creates a resolver function (see
3387 the @code{ifunc} attribute above) that dynamically selects a clone
3388 suitable for current architecture.  The resolver is created only if there
3389 is a usage of a function with @code{target_clones} attribute.
3391 @item unused
3392 @cindex @code{unused} function attribute
3393 This attribute, attached to a function, means that the function is meant
3394 to be possibly unused.  GCC does not produce a warning for this
3395 function.
3397 @item used
3398 @cindex @code{used} function attribute
3399 This attribute, attached to a function, means that code must be emitted
3400 for the function even if it appears that the function is not referenced.
3401 This is useful, for example, when the function is referenced only in
3402 inline assembly.
3404 When applied to a member function of a C++ class template, the
3405 attribute also means that the function is instantiated if the
3406 class itself is instantiated.
3408 @item visibility ("@var{visibility_type}")
3409 @cindex @code{visibility} function attribute
3410 This attribute affects the linkage of the declaration to which it is attached.
3411 It can be applied to variables (@pxref{Common Variable Attributes}) and types
3412 (@pxref{Common Type Attributes}) as well as functions.
3414 There are four supported @var{visibility_type} values: default,
3415 hidden, protected or internal visibility.
3417 @smallexample
3418 void __attribute__ ((visibility ("protected")))
3419 f () @{ /* @r{Do something.} */; @}
3420 int i __attribute__ ((visibility ("hidden")));
3421 @end smallexample
3423 The possible values of @var{visibility_type} correspond to the
3424 visibility settings in the ELF gABI.
3426 @table @code
3427 @c keep this list of visibilities in alphabetical order.
3429 @item default
3430 Default visibility is the normal case for the object file format.
3431 This value is available for the visibility attribute to override other
3432 options that may change the assumed visibility of entities.
3434 On ELF, default visibility means that the declaration is visible to other
3435 modules and, in shared libraries, means that the declared entity may be
3436 overridden.
3438 On Darwin, default visibility means that the declaration is visible to
3439 other modules.
3441 Default visibility corresponds to ``external linkage'' in the language.
3443 @item hidden
3444 Hidden visibility indicates that the entity declared has a new
3445 form of linkage, which we call ``hidden linkage''.  Two
3446 declarations of an object with hidden linkage refer to the same object
3447 if they are in the same shared object.
3449 @item internal
3450 Internal visibility is like hidden visibility, but with additional
3451 processor specific semantics.  Unless otherwise specified by the
3452 psABI, GCC defines internal visibility to mean that a function is
3453 @emph{never} called from another module.  Compare this with hidden
3454 functions which, while they cannot be referenced directly by other
3455 modules, can be referenced indirectly via function pointers.  By
3456 indicating that a function cannot be called from outside the module,
3457 GCC may for instance omit the load of a PIC register since it is known
3458 that the calling function loaded the correct value.
3460 @item protected
3461 Protected visibility is like default visibility except that it
3462 indicates that references within the defining module bind to the
3463 definition in that module.  That is, the declared entity cannot be
3464 overridden by another module.
3466 @end table
3468 All visibilities are supported on many, but not all, ELF targets
3469 (supported when the assembler supports the @samp{.visibility}
3470 pseudo-op).  Default visibility is supported everywhere.  Hidden
3471 visibility is supported on Darwin targets.
3473 The visibility attribute should be applied only to declarations that
3474 would otherwise have external linkage.  The attribute should be applied
3475 consistently, so that the same entity should not be declared with
3476 different settings of the attribute.
3478 In C++, the visibility attribute applies to types as well as functions
3479 and objects, because in C++ types have linkage.  A class must not have
3480 greater visibility than its non-static data member types and bases,
3481 and class members default to the visibility of their class.  Also, a
3482 declaration without explicit visibility is limited to the visibility
3483 of its type.
3485 In C++, you can mark member functions and static member variables of a
3486 class with the visibility attribute.  This is useful if you know a
3487 particular method or static member variable should only be used from
3488 one shared object; then you can mark it hidden while the rest of the
3489 class has default visibility.  Care must be taken to avoid breaking
3490 the One Definition Rule; for example, it is usually not useful to mark
3491 an inline method as hidden without marking the whole class as hidden.
3493 A C++ namespace declaration can also have the visibility attribute.
3495 @smallexample
3496 namespace nspace1 __attribute__ ((visibility ("protected")))
3497 @{ /* @r{Do something.} */; @}
3498 @end smallexample
3500 This attribute applies only to the particular namespace body, not to
3501 other definitions of the same namespace; it is equivalent to using
3502 @samp{#pragma GCC visibility} before and after the namespace
3503 definition (@pxref{Visibility Pragmas}).
3505 In C++, if a template argument has limited visibility, this
3506 restriction is implicitly propagated to the template instantiation.
3507 Otherwise, template instantiations and specializations default to the
3508 visibility of their template.
3510 If both the template and enclosing class have explicit visibility, the
3511 visibility from the template is used.
3513 @item warn_unused_result
3514 @cindex @code{warn_unused_result} function attribute
3515 The @code{warn_unused_result} attribute causes a warning to be emitted
3516 if a caller of the function with this attribute does not use its
3517 return value.  This is useful for functions where not checking
3518 the result is either a security problem or always a bug, such as
3519 @code{realloc}.
3521 @smallexample
3522 int fn () __attribute__ ((warn_unused_result));
3523 int foo ()
3525   if (fn () < 0) return -1;
3526   fn ();
3527   return 0;
3529 @end smallexample
3531 @noindent
3532 results in warning on line 5.
3534 @item weak
3535 @cindex @code{weak} function attribute
3536 The @code{weak} attribute causes the declaration to be emitted as a weak
3537 symbol rather than a global.  This is primarily useful in defining
3538 library functions that can be overridden in user code, though it can
3539 also be used with non-function declarations.  Weak symbols are supported
3540 for ELF targets, and also for a.out targets when using the GNU assembler
3541 and linker.
3543 @item weakref
3544 @itemx weakref ("@var{target}")
3545 @cindex @code{weakref} function attribute
3546 The @code{weakref} attribute marks a declaration as a weak reference.
3547 Without arguments, it should be accompanied by an @code{alias} attribute
3548 naming the target symbol.  Optionally, the @var{target} may be given as
3549 an argument to @code{weakref} itself.  In either case, @code{weakref}
3550 implicitly marks the declaration as @code{weak}.  Without a
3551 @var{target}, given as an argument to @code{weakref} or to @code{alias},
3552 @code{weakref} is equivalent to @code{weak}.
3554 @smallexample
3555 static int x() __attribute__ ((weakref ("y")));
3556 /* is equivalent to... */
3557 static int x() __attribute__ ((weak, weakref, alias ("y")));
3558 /* and to... */
3559 static int x() __attribute__ ((weakref));
3560 static int x() __attribute__ ((alias ("y")));
3561 @end smallexample
3563 A weak reference is an alias that does not by itself require a
3564 definition to be given for the target symbol.  If the target symbol is
3565 only referenced through weak references, then it becomes a @code{weak}
3566 undefined symbol.  If it is directly referenced, however, then such
3567 strong references prevail, and a definition is required for the
3568 symbol, not necessarily in the same translation unit.
3570 The effect is equivalent to moving all references to the alias to a
3571 separate translation unit, renaming the alias to the aliased symbol,
3572 declaring it as weak, compiling the two separate translation units and
3573 performing a reloadable link on them.
3575 At present, a declaration to which @code{weakref} is attached can
3576 only be @code{static}.
3579 @end table
3581 @c This is the end of the target-independent attribute table
3583 @node AArch64 Function Attributes
3584 @subsection AArch64 Function Attributes
3586 The following target-specific function attributes are available for the
3587 AArch64 target.  For the most part, these options mirror the behavior of
3588 similar command-line options (@pxref{AArch64 Options}), but on a
3589 per-function basis.
3591 @table @code
3592 @item general-regs-only
3593 @cindex @code{general-regs-only} function attribute, AArch64
3594 Indicates that no floating-point or Advanced SIMD registers should be
3595 used when generating code for this function.  If the function explicitly
3596 uses floating-point code, then the compiler gives an error.  This is
3597 the same behavior as that of the command-line option
3598 @option{-mgeneral-regs-only}.
3600 @item fix-cortex-a53-835769
3601 @cindex @code{fix-cortex-a53-835769} function attribute, AArch64
3602 Indicates that the workaround for the Cortex-A53 erratum 835769 should be
3603 applied to this function.  To explicitly disable the workaround for this
3604 function specify the negated form: @code{no-fix-cortex-a53-835769}.
3605 This corresponds to the behavior of the command line options
3606 @option{-mfix-cortex-a53-835769} and @option{-mno-fix-cortex-a53-835769}.
3608 @item cmodel=
3609 @cindex @code{cmodel=} function attribute, AArch64
3610 Indicates that code should be generated for a particular code model for
3611 this function.  The behavior and permissible arguments are the same as
3612 for the command line option @option{-mcmodel=}.
3614 @item strict-align
3615 @cindex @code{strict-align} function attribute, AArch64
3616 Indicates that the compiler should not assume that unaligned memory references
3617 are handled by the system.  The behavior is the same as for the command-line
3618 option @option{-mstrict-align}.
3620 @item omit-leaf-frame-pointer
3621 @cindex @code{omit-leaf-frame-pointer} function attribute, AArch64
3622 Indicates that the frame pointer should be omitted for a leaf function call.
3623 To keep the frame pointer, the inverse attribute
3624 @code{no-omit-leaf-frame-pointer} can be specified.  These attributes have
3625 the same behavior as the command-line options @option{-momit-leaf-frame-pointer}
3626 and @option{-mno-omit-leaf-frame-pointer}.
3628 @item tls-dialect=
3629 @cindex @code{tls-dialect=} function attribute, AArch64
3630 Specifies the TLS dialect to use for this function.  The behavior and
3631 permissible arguments are the same as for the command-line option
3632 @option{-mtls-dialect=}.
3634 @item arch=
3635 @cindex @code{arch=} function attribute, AArch64
3636 Specifies the architecture version and architectural extensions to use
3637 for this function.  The behavior and permissible arguments are the same as
3638 for the @option{-march=} command-line option.
3640 @item tune=
3641 @cindex @code{tune=} function attribute, AArch64
3642 Specifies the core for which to tune the performance of this function.
3643 The behavior and permissible arguments are the same as for the @option{-mtune=}
3644 command-line option.
3646 @item cpu=
3647 @cindex @code{cpu=} function attribute, AArch64
3648 Specifies the core for which to tune the performance of this function and also
3649 whose architectural features to use.  The behavior and valid arguments are the
3650 same as for the @option{-mcpu=} command-line option.
3652 @item sign-return-address
3653 @cindex @code{sign-return-address} function attribute, AArch64
3654 Select the function scope on which return address signing will be applied.  The
3655 behavior and permissible arguments are the same as for the command-line option
3656 @option{-msign-return-address=}.  The default value is @code{none}.
3658 @end table
3660 The above target attributes can be specified as follows:
3662 @smallexample
3663 __attribute__((target("@var{attr-string}")))
3665 f (int a)
3667   return a + 5;
3669 @end smallexample
3671 where @code{@var{attr-string}} is one of the attribute strings specified above.
3673 Additionally, the architectural extension string may be specified on its
3674 own.  This can be used to turn on and off particular architectural extensions
3675 without having to specify a particular architecture version or core.  Example:
3677 @smallexample
3678 __attribute__((target("+crc+nocrypto")))
3680 foo (int a)
3682   return a + 5;
3684 @end smallexample
3686 In this example @code{target("+crc+nocrypto")} enables the @code{crc}
3687 extension and disables the @code{crypto} extension for the function @code{foo}
3688 without modifying an existing @option{-march=} or @option{-mcpu} option.
3690 Multiple target function attributes can be specified by separating them with
3691 a comma.  For example:
3692 @smallexample
3693 __attribute__((target("arch=armv8-a+crc+crypto,tune=cortex-a53")))
3695 foo (int a)
3697   return a + 5;
3699 @end smallexample
3701 is valid and compiles function @code{foo} for ARMv8-A with @code{crc}
3702 and @code{crypto} extensions and tunes it for @code{cortex-a53}.
3704 @subsubsection Inlining rules
3705 Specifying target attributes on individual functions or performing link-time
3706 optimization across translation units compiled with different target options
3707 can affect function inlining rules:
3709 In particular, a caller function can inline a callee function only if the
3710 architectural features available to the callee are a subset of the features
3711 available to the caller.
3712 For example: A function @code{foo} compiled with @option{-march=armv8-a+crc},
3713 or tagged with the equivalent @code{arch=armv8-a+crc} attribute,
3714 can inline a function @code{bar} compiled with @option{-march=armv8-a+nocrc}
3715 because the all the architectural features that function @code{bar} requires
3716 are available to function @code{foo}.  Conversely, function @code{bar} cannot
3717 inline function @code{foo}.
3719 Additionally inlining a function compiled with @option{-mstrict-align} into a
3720 function compiled without @code{-mstrict-align} is not allowed.
3721 However, inlining a function compiled without @option{-mstrict-align} into a
3722 function compiled with @option{-mstrict-align} is allowed.
3724 Note that CPU tuning options and attributes such as the @option{-mcpu=},
3725 @option{-mtune=} do not inhibit inlining unless the CPU specified by the
3726 @option{-mcpu=} option or the @code{cpu=} attribute conflicts with the
3727 architectural feature rules specified above.
3729 @node ARC Function Attributes
3730 @subsection ARC Function Attributes
3732 These function attributes are supported by the ARC back end:
3734 @table @code
3735 @item interrupt
3736 @cindex @code{interrupt} function attribute, ARC
3737 Use this attribute to indicate
3738 that the specified function is an interrupt handler.  The compiler generates
3739 function entry and exit sequences suitable for use in an interrupt handler
3740 when this attribute is present.
3742 On the ARC, you must specify the kind of interrupt to be handled
3743 in a parameter to the interrupt attribute like this:
3745 @smallexample
3746 void f () __attribute__ ((interrupt ("ilink1")));
3747 @end smallexample
3749 Permissible values for this parameter are: @w{@code{ilink1}} and
3750 @w{@code{ilink2}}.
3752 @item long_call
3753 @itemx medium_call
3754 @itemx short_call
3755 @cindex @code{long_call} function attribute, ARC
3756 @cindex @code{medium_call} function attribute, ARC
3757 @cindex @code{short_call} function attribute, ARC
3758 @cindex indirect calls, ARC
3759 These attributes specify how a particular function is called.
3760 These attributes override the
3761 @option{-mlong-calls} and @option{-mmedium-calls} (@pxref{ARC Options})
3762 command-line switches and @code{#pragma long_calls} settings.
3764 For ARC, a function marked with the @code{long_call} attribute is
3765 always called using register-indirect jump-and-link instructions,
3766 thereby enabling the called function to be placed anywhere within the
3767 32-bit address space.  A function marked with the @code{medium_call}
3768 attribute will always be close enough to be called with an unconditional
3769 branch-and-link instruction, which has a 25-bit offset from
3770 the call site.  A function marked with the @code{short_call}
3771 attribute will always be close enough to be called with a conditional
3772 branch-and-link instruction, which has a 21-bit offset from
3773 the call site.
3775 @item jli_always
3776 @cindex @code{jli_always} function attribute, ARC
3777 Forces a particular function to be called using @code{jli}
3778 instruction.  The @code{jli} instruction makes use of a table stored
3779 into @code{.jlitab} section, which holds the location of the functions
3780 which are addressed using this instruction.
3782 @item jli_fixed
3783 @cindex @code{jli_fixed} function attribute, ARC
3784 Identical like the above one, but the location of the function in the
3785 @code{jli} table is known and given as an attribute parameter.
3787 @item secure_call
3788 @cindex @code{secure_call} function attribute, ARC
3789 This attribute allows one to mark secure-code functions that are
3790 callable from normal mode.  The location of the secure call function
3791 into the @code{sjli} table needs to be passed as argument.
3793 @end table
3795 @node ARM Function Attributes
3796 @subsection ARM Function Attributes
3798 These function attributes are supported for ARM targets:
3800 @table @code
3801 @item interrupt
3802 @cindex @code{interrupt} function attribute, ARM
3803 Use this attribute to indicate
3804 that the specified function is an interrupt handler.  The compiler generates
3805 function entry and exit sequences suitable for use in an interrupt handler
3806 when this attribute is present.
3808 You can specify the kind of interrupt to be handled by
3809 adding an optional parameter to the interrupt attribute like this:
3811 @smallexample
3812 void f () __attribute__ ((interrupt ("IRQ")));
3813 @end smallexample
3815 @noindent
3816 Permissible values for this parameter are: @code{IRQ}, @code{FIQ},
3817 @code{SWI}, @code{ABORT} and @code{UNDEF}.
3819 On ARMv7-M the interrupt type is ignored, and the attribute means the function
3820 may be called with a word-aligned stack pointer.
3822 @item isr
3823 @cindex @code{isr} function attribute, ARM
3824 Use this attribute on ARM to write Interrupt Service Routines. This is an
3825 alias to the @code{interrupt} attribute above.
3827 @item long_call
3828 @itemx short_call
3829 @cindex @code{long_call} function attribute, ARM
3830 @cindex @code{short_call} function attribute, ARM
3831 @cindex indirect calls, ARM
3832 These attributes specify how a particular function is called.
3833 These attributes override the
3834 @option{-mlong-calls} (@pxref{ARM Options})
3835 command-line switch and @code{#pragma long_calls} settings.  For ARM, the
3836 @code{long_call} attribute indicates that the function might be far
3837 away from the call site and require a different (more expensive)
3838 calling sequence.   The @code{short_call} attribute always places
3839 the offset to the function from the call site into the @samp{BL}
3840 instruction directly.
3842 @item naked
3843 @cindex @code{naked} function attribute, ARM
3844 This attribute allows the compiler to construct the
3845 requisite function declaration, while allowing the body of the
3846 function to be assembly code. The specified function will not have
3847 prologue/epilogue sequences generated by the compiler. Only basic
3848 @code{asm} statements can safely be included in naked functions
3849 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
3850 basic @code{asm} and C code may appear to work, they cannot be
3851 depended upon to work reliably and are not supported.
3853 @item pcs
3854 @cindex @code{pcs} function attribute, ARM
3856 The @code{pcs} attribute can be used to control the calling convention
3857 used for a function on ARM.  The attribute takes an argument that specifies
3858 the calling convention to use.
3860 When compiling using the AAPCS ABI (or a variant of it) then valid
3861 values for the argument are @code{"aapcs"} and @code{"aapcs-vfp"}.  In
3862 order to use a variant other than @code{"aapcs"} then the compiler must
3863 be permitted to use the appropriate co-processor registers (i.e., the
3864 VFP registers must be available in order to use @code{"aapcs-vfp"}).
3865 For example,
3867 @smallexample
3868 /* Argument passed in r0, and result returned in r0+r1.  */
3869 double f2d (float) __attribute__((pcs("aapcs")));
3870 @end smallexample
3872 Variadic functions always use the @code{"aapcs"} calling convention and
3873 the compiler rejects attempts to specify an alternative.
3875 @item target (@var{options})
3876 @cindex @code{target} function attribute
3877 As discussed in @ref{Common Function Attributes}, this attribute 
3878 allows specification of target-specific compilation options.
3880 On ARM, the following options are allowed:
3882 @table @samp
3883 @item thumb
3884 @cindex @code{target("thumb")} function attribute, ARM
3885 Force code generation in the Thumb (T16/T32) ISA, depending on the
3886 architecture level.
3888 @item arm
3889 @cindex @code{target("arm")} function attribute, ARM
3890 Force code generation in the ARM (A32) ISA.
3892 Functions from different modes can be inlined in the caller's mode.
3894 @item fpu=
3895 @cindex @code{target("fpu=")} function attribute, ARM
3896 Specifies the fpu for which to tune the performance of this function.
3897 The behavior and permissible arguments are the same as for the @option{-mfpu=}
3898 command-line option.
3900 @item arch=
3901 @cindex @code{arch=} function attribute, ARM
3902 Specifies the architecture version and architectural extensions to use
3903 for this function.  The behavior and permissible arguments are the same as
3904 for the @option{-march=} command-line option.
3906 The above target attributes can be specified as follows:
3908 @smallexample
3909 __attribute__((target("arch=armv8-a+crc")))
3911 f (int a)
3913   return a + 5;
3915 @end smallexample
3917 Additionally, the architectural extension string may be specified on its
3918 own.  This can be used to turn on and off particular architectural extensions
3919 without having to specify a particular architecture version or core.  Example:
3921 @smallexample
3922 __attribute__((target("+crc+nocrypto")))
3924 foo (int a)
3926   return a + 5;
3928 @end smallexample
3930 In this example @code{target("+crc+nocrypto")} enables the @code{crc}
3931 extension and disables the @code{crypto} extension for the function @code{foo}
3932 without modifying an existing @option{-march=} or @option{-mcpu} option.
3934 @end table
3936 @end table
3938 @node AVR Function Attributes
3939 @subsection AVR Function Attributes
3941 These function attributes are supported by the AVR back end:
3943 @table @code
3944 @item interrupt
3945 @cindex @code{interrupt} function attribute, AVR
3946 Use this attribute to indicate
3947 that the specified function is an interrupt handler.  The compiler generates
3948 function entry and exit sequences suitable for use in an interrupt handler
3949 when this attribute is present.
3951 On the AVR, the hardware globally disables interrupts when an
3952 interrupt is executed.  The first instruction of an interrupt handler
3953 declared with this attribute is a @code{SEI} instruction to
3954 re-enable interrupts.  See also the @code{signal} function attribute
3955 that does not insert a @code{SEI} instruction.  If both @code{signal} and
3956 @code{interrupt} are specified for the same function, @code{signal}
3957 is silently ignored.
3959 @item naked
3960 @cindex @code{naked} function attribute, AVR
3961 This attribute allows the compiler to construct the
3962 requisite function declaration, while allowing the body of the
3963 function to be assembly code. The specified function will not have
3964 prologue/epilogue sequences generated by the compiler. Only basic
3965 @code{asm} statements can safely be included in naked functions
3966 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
3967 basic @code{asm} and C code may appear to work, they cannot be
3968 depended upon to work reliably and are not supported.
3970 @item no_gccisr
3971 @cindex @code{no_gccisr} function attribute, AVR
3972 Do not use @code{__gcc_isr} pseudo instructions in a function with
3973 the @code{interrupt} or @code{signal} attribute aka. interrupt
3974 service routine (ISR).
3975 Use this attribute if the preamble of the ISR prologue should always read
3976 @example
3977 push  __zero_reg__
3978 push  __tmp_reg__
3979 in    __tmp_reg__, __SREG__
3980 push  __tmp_reg__
3981 clr   __zero_reg__
3982 @end example
3983 and accordingly for the postamble of the epilogue --- no matter whether
3984 the mentioned registers are actually used in the ISR or not.
3985 Situations where you might want to use this attribute include:
3986 @itemize @bullet
3987 @item
3988 Code that (effectively) clobbers bits of @code{SREG} other than the
3989 @code{I}-flag by writing to the memory location of @code{SREG}.
3990 @item
3991 Code that uses inline assembler to jump to a different function which
3992 expects (parts of) the prologue code as outlined above to be present.
3993 @end itemize
3994 To disable @code{__gcc_isr} generation for the whole compilation unit,
3995 there is option @option{-mno-gas-isr-prologues}, @pxref{AVR Options}.
3997 @item OS_main
3998 @itemx OS_task
3999 @cindex @code{OS_main} function attribute, AVR
4000 @cindex @code{OS_task} function attribute, AVR
4001 On AVR, functions with the @code{OS_main} or @code{OS_task} attribute
4002 do not save/restore any call-saved register in their prologue/epilogue.
4004 The @code{OS_main} attribute can be used when there @emph{is
4005 guarantee} that interrupts are disabled at the time when the function
4006 is entered.  This saves resources when the stack pointer has to be
4007 changed to set up a frame for local variables.
4009 The @code{OS_task} attribute can be used when there is @emph{no
4010 guarantee} that interrupts are disabled at that time when the function
4011 is entered like for, e@.g@. task functions in a multi-threading operating
4012 system. In that case, changing the stack pointer register is
4013 guarded by save/clear/restore of the global interrupt enable flag.
4015 The differences to the @code{naked} function attribute are:
4016 @itemize @bullet
4017 @item @code{naked} functions do not have a return instruction whereas 
4018 @code{OS_main} and @code{OS_task} functions have a @code{RET} or
4019 @code{RETI} return instruction.
4020 @item @code{naked} functions do not set up a frame for local variables
4021 or a frame pointer whereas @code{OS_main} and @code{OS_task} do this
4022 as needed.
4023 @end itemize
4025 @item signal
4026 @cindex @code{signal} function attribute, AVR
4027 Use this attribute on the AVR to indicate that the specified
4028 function is an interrupt handler.  The compiler generates function
4029 entry and exit sequences suitable for use in an interrupt handler when this
4030 attribute is present.
4032 See also the @code{interrupt} function attribute. 
4034 The AVR hardware globally disables interrupts when an interrupt is executed.
4035 Interrupt handler functions defined with the @code{signal} attribute
4036 do not re-enable interrupts.  It is save to enable interrupts in a
4037 @code{signal} handler.  This ``save'' only applies to the code
4038 generated by the compiler and not to the IRQ layout of the
4039 application which is responsibility of the application.
4041 If both @code{signal} and @code{interrupt} are specified for the same
4042 function, @code{signal} is silently ignored.
4043 @end table
4045 @node Blackfin Function Attributes
4046 @subsection Blackfin Function Attributes
4048 These function attributes are supported by the Blackfin back end:
4050 @table @code
4052 @item exception_handler
4053 @cindex @code{exception_handler} function attribute
4054 @cindex exception handler functions, Blackfin
4055 Use this attribute on the Blackfin to indicate that the specified function
4056 is an exception handler.  The compiler generates function entry and
4057 exit sequences suitable for use in an exception handler when this
4058 attribute is present.
4060 @item interrupt_handler
4061 @cindex @code{interrupt_handler} function attribute, Blackfin
4062 Use this attribute to
4063 indicate that the specified function is an interrupt handler.  The compiler
4064 generates function entry and exit sequences suitable for use in an
4065 interrupt handler when this attribute is present.
4067 @item kspisusp
4068 @cindex @code{kspisusp} function attribute, Blackfin
4069 @cindex User stack pointer in interrupts on the Blackfin
4070 When used together with @code{interrupt_handler}, @code{exception_handler}
4071 or @code{nmi_handler}, code is generated to load the stack pointer
4072 from the USP register in the function prologue.
4074 @item l1_text
4075 @cindex @code{l1_text} function attribute, Blackfin
4076 This attribute specifies a function to be placed into L1 Instruction
4077 SRAM@. The function is put into a specific section named @code{.l1.text}.
4078 With @option{-mfdpic}, function calls with a such function as the callee
4079 or caller uses inlined PLT.
4081 @item l2
4082 @cindex @code{l2} function attribute, Blackfin
4083 This attribute specifies a function to be placed into L2
4084 SRAM. The function is put into a specific section named
4085 @code{.l2.text}. With @option{-mfdpic}, callers of such functions use
4086 an inlined PLT.
4088 @item longcall
4089 @itemx shortcall
4090 @cindex indirect calls, Blackfin
4091 @cindex @code{longcall} function attribute, Blackfin
4092 @cindex @code{shortcall} function attribute, Blackfin
4093 The @code{longcall} attribute
4094 indicates that the function might be far away from the call site and
4095 require a different (more expensive) calling sequence.  The
4096 @code{shortcall} attribute indicates that the function is always close
4097 enough for the shorter calling sequence to be used.  These attributes
4098 override the @option{-mlongcall} switch.
4100 @item nesting
4101 @cindex @code{nesting} function attribute, Blackfin
4102 @cindex Allow nesting in an interrupt handler on the Blackfin processor
4103 Use this attribute together with @code{interrupt_handler},
4104 @code{exception_handler} or @code{nmi_handler} to indicate that the function
4105 entry code should enable nested interrupts or exceptions.
4107 @item nmi_handler
4108 @cindex @code{nmi_handler} function attribute, Blackfin
4109 @cindex NMI handler functions on the Blackfin processor
4110 Use this attribute on the Blackfin to indicate that the specified function
4111 is an NMI handler.  The compiler generates function entry and
4112 exit sequences suitable for use in an NMI handler when this
4113 attribute is present.
4115 @item saveall
4116 @cindex @code{saveall} function attribute, Blackfin
4117 @cindex save all registers on the Blackfin
4118 Use this attribute to indicate that
4119 all registers except the stack pointer should be saved in the prologue
4120 regardless of whether they are used or not.
4121 @end table
4123 @node CR16 Function Attributes
4124 @subsection CR16 Function Attributes
4126 These function attributes are supported by the CR16 back end:
4128 @table @code
4129 @item interrupt
4130 @cindex @code{interrupt} function attribute, CR16
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.
4135 @end table
4137 @node Epiphany Function Attributes
4138 @subsection Epiphany Function Attributes
4140 These function attributes are supported by the Epiphany back end:
4142 @table @code
4143 @item disinterrupt
4144 @cindex @code{disinterrupt} function attribute, Epiphany
4145 This attribute causes the compiler to emit
4146 instructions to disable interrupts for the duration of the given
4147 function.
4149 @item forwarder_section
4150 @cindex @code{forwarder_section} function attribute, Epiphany
4151 This attribute modifies the behavior of an interrupt handler.
4152 The interrupt handler may be in external memory which cannot be
4153 reached by a branch instruction, so generate a local memory trampoline
4154 to transfer control.  The single parameter identifies the section where
4155 the trampoline is placed.
4157 @item interrupt
4158 @cindex @code{interrupt} function attribute, Epiphany
4159 Use this attribute to indicate
4160 that the specified function is an interrupt handler.  The compiler generates
4161 function entry and exit sequences suitable for use in an interrupt handler
4162 when this attribute is present.  It may also generate
4163 a special section with code to initialize the interrupt vector table.
4165 On Epiphany targets one or more optional parameters can be added like this:
4167 @smallexample
4168 void __attribute__ ((interrupt ("dma0, dma1"))) universal_dma_handler ();
4169 @end smallexample
4171 Permissible values for these parameters are: @w{@code{reset}},
4172 @w{@code{software_exception}}, @w{@code{page_miss}},
4173 @w{@code{timer0}}, @w{@code{timer1}}, @w{@code{message}},
4174 @w{@code{dma0}}, @w{@code{dma1}}, @w{@code{wand}} and @w{@code{swi}}.
4175 Multiple parameters indicate that multiple entries in the interrupt
4176 vector table should be initialized for this function, i.e.@: for each
4177 parameter @w{@var{name}}, a jump to the function is emitted in
4178 the section @w{ivt_entry_@var{name}}.  The parameter(s) may be omitted
4179 entirely, in which case no interrupt vector table entry is provided.
4181 Note that interrupts are enabled inside the function
4182 unless the @code{disinterrupt} attribute is also specified.
4184 The following examples are all valid uses of these attributes on
4185 Epiphany targets:
4186 @smallexample
4187 void __attribute__ ((interrupt)) universal_handler ();
4188 void __attribute__ ((interrupt ("dma1"))) dma1_handler ();
4189 void __attribute__ ((interrupt ("dma0, dma1"))) 
4190   universal_dma_handler ();
4191 void __attribute__ ((interrupt ("timer0"), disinterrupt))
4192   fast_timer_handler ();
4193 void __attribute__ ((interrupt ("dma0, dma1"), 
4194                      forwarder_section ("tramp")))
4195   external_dma_handler ();
4196 @end smallexample
4198 @item long_call
4199 @itemx short_call
4200 @cindex @code{long_call} function attribute, Epiphany
4201 @cindex @code{short_call} function attribute, Epiphany
4202 @cindex indirect calls, Epiphany
4203 These attributes specify how a particular function is called.
4204 These attributes override the
4205 @option{-mlong-calls} (@pxref{Adapteva Epiphany Options})
4206 command-line switch and @code{#pragma long_calls} settings.
4207 @end table
4210 @node H8/300 Function Attributes
4211 @subsection H8/300 Function Attributes
4213 These function attributes are available for H8/300 targets:
4215 @table @code
4216 @item function_vector
4217 @cindex @code{function_vector} function attribute, H8/300
4218 Use this attribute on the H8/300, H8/300H, and H8S to indicate 
4219 that the specified function should be called through the function vector.
4220 Calling a function through the function vector reduces code size; however,
4221 the function vector has a limited size (maximum 128 entries on the H8/300
4222 and 64 entries on the H8/300H and H8S)
4223 and shares space with the interrupt vector.
4225 @item interrupt_handler
4226 @cindex @code{interrupt_handler} function attribute, H8/300
4227 Use this attribute on the H8/300, H8/300H, and H8S to
4228 indicate that the specified function is an interrupt handler.  The compiler
4229 generates function entry and exit sequences suitable for use in an
4230 interrupt handler when this attribute is present.
4232 @item saveall
4233 @cindex @code{saveall} function attribute, H8/300
4234 @cindex save all registers on the H8/300, H8/300H, and H8S
4235 Use this attribute on the H8/300, H8/300H, and H8S to indicate that
4236 all registers except the stack pointer should be saved in the prologue
4237 regardless of whether they are used or not.
4238 @end table
4240 @node IA-64 Function Attributes
4241 @subsection IA-64 Function Attributes
4243 These function attributes are supported on IA-64 targets:
4245 @table @code
4246 @item syscall_linkage
4247 @cindex @code{syscall_linkage} function attribute, IA-64
4248 This attribute is used to modify the IA-64 calling convention by marking
4249 all input registers as live at all function exits.  This makes it possible
4250 to restart a system call after an interrupt without having to save/restore
4251 the input registers.  This also prevents kernel data from leaking into
4252 application code.
4254 @item version_id
4255 @cindex @code{version_id} function attribute, IA-64
4256 This IA-64 HP-UX attribute, attached to a global variable or function, renames a
4257 symbol to contain a version string, thus allowing for function level
4258 versioning.  HP-UX system header files may use function level versioning
4259 for some system calls.
4261 @smallexample
4262 extern int foo () __attribute__((version_id ("20040821")));
4263 @end smallexample
4265 @noindent
4266 Calls to @code{foo} are mapped to calls to @code{foo@{20040821@}}.
4267 @end table
4269 @node M32C Function Attributes
4270 @subsection M32C Function Attributes
4272 These function attributes are supported by the M32C back end:
4274 @table @code
4275 @item bank_switch
4276 @cindex @code{bank_switch} function attribute, M32C
4277 When added to an interrupt handler with the M32C port, causes the
4278 prologue and epilogue to use bank switching to preserve the registers
4279 rather than saving them on the stack.
4281 @item fast_interrupt
4282 @cindex @code{fast_interrupt} function attribute, M32C
4283 Use this attribute on the M32C port to indicate that the specified
4284 function is a fast interrupt handler.  This is just like the
4285 @code{interrupt} attribute, except that @code{freit} is used to return
4286 instead of @code{reit}.
4288 @item function_vector
4289 @cindex @code{function_vector} function attribute, M16C/M32C
4290 On M16C/M32C targets, the @code{function_vector} attribute declares a
4291 special page subroutine call function. Use of this attribute reduces
4292 the code size by 2 bytes for each call generated to the
4293 subroutine. The argument to the attribute is the vector number entry
4294 from the special page vector table which contains the 16 low-order
4295 bits of the subroutine's entry address. Each vector table has special
4296 page number (18 to 255) that is used in @code{jsrs} instructions.
4297 Jump addresses of the routines are generated by adding 0x0F0000 (in
4298 case of M16C targets) or 0xFF0000 (in case of M32C targets), to the
4299 2-byte addresses set in the vector table. Therefore you need to ensure
4300 that all the special page vector routines should get mapped within the
4301 address range 0x0F0000 to 0x0FFFFF (for M16C) and 0xFF0000 to 0xFFFFFF
4302 (for M32C).
4304 In the following example 2 bytes are saved for each call to
4305 function @code{foo}.
4307 @smallexample
4308 void foo (void) __attribute__((function_vector(0x18)));
4309 void foo (void)
4313 void bar (void)
4315     foo();
4317 @end smallexample
4319 If functions are defined in one file and are called in another file,
4320 then be sure to write this declaration in both files.
4322 This attribute is ignored for R8C target.
4324 @item interrupt
4325 @cindex @code{interrupt} function attribute, M32C
4326 Use this attribute to indicate
4327 that the specified function is an interrupt handler.  The compiler generates
4328 function entry and exit sequences suitable for use in an interrupt handler
4329 when this attribute is present.
4330 @end table
4332 @node M32R/D Function Attributes
4333 @subsection M32R/D Function Attributes
4335 These function attributes are supported by the M32R/D back end:
4337 @table @code
4338 @item interrupt
4339 @cindex @code{interrupt} function attribute, M32R/D
4340 Use this attribute to indicate
4341 that the specified function is an interrupt handler.  The compiler generates
4342 function entry and exit sequences suitable for use in an interrupt handler
4343 when this attribute is present.
4345 @item model (@var{model-name})
4346 @cindex @code{model} function attribute, M32R/D
4347 @cindex function addressability on the M32R/D
4349 On the M32R/D, use this attribute to set the addressability of an
4350 object, and of the code generated for a function.  The identifier
4351 @var{model-name} is one of @code{small}, @code{medium}, or
4352 @code{large}, representing each of the code models.
4354 Small model objects live in the lower 16MB of memory (so that their
4355 addresses can be loaded with the @code{ld24} instruction), and are
4356 callable with the @code{bl} instruction.
4358 Medium model objects may live anywhere in the 32-bit address space (the
4359 compiler generates @code{seth/add3} instructions to load their addresses),
4360 and are callable with the @code{bl} instruction.
4362 Large model objects may live anywhere in the 32-bit address space (the
4363 compiler generates @code{seth/add3} instructions to load their addresses),
4364 and may not be reachable with the @code{bl} instruction (the compiler
4365 generates the much slower @code{seth/add3/jl} instruction sequence).
4366 @end table
4368 @node m68k Function Attributes
4369 @subsection m68k Function Attributes
4371 These function attributes are supported by the m68k back end:
4373 @table @code
4374 @item interrupt
4375 @itemx interrupt_handler
4376 @cindex @code{interrupt} function attribute, m68k
4377 @cindex @code{interrupt_handler} function attribute, m68k
4378 Use this attribute to
4379 indicate that the specified function is an interrupt handler.  The compiler
4380 generates function entry and exit sequences suitable for use in an
4381 interrupt handler when this attribute is present.  Either name may be used.
4383 @item interrupt_thread
4384 @cindex @code{interrupt_thread} function attribute, fido
4385 Use this attribute on fido, a subarchitecture of the m68k, to indicate
4386 that the specified function is an interrupt handler that is designed
4387 to run as a thread.  The compiler omits generate prologue/epilogue
4388 sequences and replaces the return instruction with a @code{sleep}
4389 instruction.  This attribute is available only on fido.
4390 @end table
4392 @node MCORE Function Attributes
4393 @subsection MCORE Function Attributes
4395 These function attributes are supported by the MCORE back end:
4397 @table @code
4398 @item naked
4399 @cindex @code{naked} function attribute, MCORE
4400 This attribute allows the compiler to construct the
4401 requisite function declaration, while allowing the body of the
4402 function to be assembly code. The specified function will not have
4403 prologue/epilogue sequences generated by the compiler. Only basic
4404 @code{asm} statements can safely be included in naked functions
4405 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
4406 basic @code{asm} and C code may appear to work, they cannot be
4407 depended upon to work reliably and are not supported.
4408 @end table
4410 @node MeP Function Attributes
4411 @subsection MeP Function Attributes
4413 These function attributes are supported by the MeP back end:
4415 @table @code
4416 @item disinterrupt
4417 @cindex @code{disinterrupt} function attribute, MeP
4418 On MeP targets, this attribute causes the compiler to emit
4419 instructions to disable interrupts for the duration of the given
4420 function.
4422 @item interrupt
4423 @cindex @code{interrupt} function attribute, MeP
4424 Use this attribute to indicate
4425 that the specified function is an interrupt handler.  The compiler generates
4426 function entry and exit sequences suitable for use in an interrupt handler
4427 when this attribute is present.
4429 @item near
4430 @cindex @code{near} function attribute, MeP
4431 This attribute causes the compiler to assume the called
4432 function is close enough to use the normal calling convention,
4433 overriding the @option{-mtf} command-line option.
4435 @item far
4436 @cindex @code{far} function attribute, MeP
4437 On MeP targets this causes the compiler to use a calling convention
4438 that assumes the called function is too far away for the built-in
4439 addressing modes.
4441 @item vliw
4442 @cindex @code{vliw} function attribute, MeP
4443 The @code{vliw} attribute tells the compiler to emit
4444 instructions in VLIW mode instead of core mode.  Note that this
4445 attribute is not allowed unless a VLIW coprocessor has been configured
4446 and enabled through command-line options.
4447 @end table
4449 @node MicroBlaze Function Attributes
4450 @subsection MicroBlaze Function Attributes
4452 These function attributes are supported on MicroBlaze targets:
4454 @table @code
4455 @item save_volatiles
4456 @cindex @code{save_volatiles} function attribute, MicroBlaze
4457 Use this attribute to indicate that the function is
4458 an interrupt handler.  All volatile registers (in addition to non-volatile
4459 registers) are saved in the function prologue.  If the function is a leaf
4460 function, only volatiles used by the function are saved.  A normal function
4461 return is generated instead of a return from interrupt.
4463 @item break_handler
4464 @cindex @code{break_handler} function attribute, MicroBlaze
4465 @cindex break handler functions
4466 Use this attribute to indicate that
4467 the specified function is a break handler.  The compiler generates function
4468 entry and exit sequences suitable for use in an break handler when this
4469 attribute is present. The return from @code{break_handler} is done through
4470 the @code{rtbd} instead of @code{rtsd}.
4472 @smallexample
4473 void f () __attribute__ ((break_handler));
4474 @end smallexample
4476 @item interrupt_handler
4477 @itemx fast_interrupt 
4478 @cindex @code{interrupt_handler} function attribute, MicroBlaze
4479 @cindex @code{fast_interrupt} function attribute, MicroBlaze
4480 These attributes indicate that the specified function is an interrupt
4481 handler.  Use the @code{fast_interrupt} attribute to indicate handlers
4482 used in low-latency interrupt mode, and @code{interrupt_handler} for
4483 interrupts that do not use low-latency handlers.  In both cases, GCC
4484 emits appropriate prologue code and generates a return from the handler
4485 using @code{rtid} instead of @code{rtsd}.
4486 @end table
4488 @node Microsoft Windows Function Attributes
4489 @subsection Microsoft Windows Function Attributes
4491 The following attributes are available on Microsoft Windows and Symbian OS
4492 targets.
4494 @table @code
4495 @item dllexport
4496 @cindex @code{dllexport} function attribute
4497 @cindex @code{__declspec(dllexport)}
4498 On Microsoft Windows targets and Symbian OS targets the
4499 @code{dllexport} attribute causes the compiler to provide a global
4500 pointer to a pointer in a DLL, so that it can be referenced with the
4501 @code{dllimport} attribute.  On Microsoft Windows targets, the pointer
4502 name is formed by combining @code{_imp__} and the function or variable
4503 name.
4505 You can use @code{__declspec(dllexport)} as a synonym for
4506 @code{__attribute__ ((dllexport))} for compatibility with other
4507 compilers.
4509 On systems that support the @code{visibility} attribute, this
4510 attribute also implies ``default'' visibility.  It is an error to
4511 explicitly specify any other visibility.
4513 GCC's default behavior is to emit all inline functions with the
4514 @code{dllexport} attribute.  Since this can cause object file-size bloat,
4515 you can use @option{-fno-keep-inline-dllexport}, which tells GCC to
4516 ignore the attribute for inlined functions unless the 
4517 @option{-fkeep-inline-functions} flag is used instead.
4519 The attribute is ignored for undefined symbols.
4521 When applied to C++ classes, the attribute marks defined non-inlined
4522 member functions and static data members as exports.  Static consts
4523 initialized in-class are not marked unless they are also defined
4524 out-of-class.
4526 For Microsoft Windows targets there are alternative methods for
4527 including the symbol in the DLL's export table such as using a
4528 @file{.def} file with an @code{EXPORTS} section or, with GNU ld, using
4529 the @option{--export-all} linker flag.
4531 @item dllimport
4532 @cindex @code{dllimport} function attribute
4533 @cindex @code{__declspec(dllimport)}
4534 On Microsoft Windows and Symbian OS targets, the @code{dllimport}
4535 attribute causes the compiler to reference a function or variable via
4536 a global pointer to a pointer that is set up by the DLL exporting the
4537 symbol.  The attribute implies @code{extern}.  On Microsoft Windows
4538 targets, the pointer name is formed by combining @code{_imp__} and the
4539 function or variable name.
4541 You can use @code{__declspec(dllimport)} as a synonym for
4542 @code{__attribute__ ((dllimport))} for compatibility with other
4543 compilers.
4545 On systems that support the @code{visibility} attribute, this
4546 attribute also implies ``default'' visibility.  It is an error to
4547 explicitly specify any other visibility.
4549 Currently, the attribute is ignored for inlined functions.  If the
4550 attribute is applied to a symbol @emph{definition}, an error is reported.
4551 If a symbol previously declared @code{dllimport} is later defined, the
4552 attribute is ignored in subsequent references, and a warning is emitted.
4553 The attribute is also overridden by a subsequent declaration as
4554 @code{dllexport}.
4556 When applied to C++ classes, the attribute marks non-inlined
4557 member functions and static data members as imports.  However, the
4558 attribute is ignored for virtual methods to allow creation of vtables
4559 using thunks.
4561 On the SH Symbian OS target the @code{dllimport} attribute also has
4562 another affect---it can cause the vtable and run-time type information
4563 for a class to be exported.  This happens when the class has a
4564 dllimported constructor or a non-inline, non-pure virtual function
4565 and, for either of those two conditions, the class also has an inline
4566 constructor or destructor and has a key function that is defined in
4567 the current translation unit.
4569 For Microsoft Windows targets the use of the @code{dllimport}
4570 attribute on functions is not necessary, but provides a small
4571 performance benefit by eliminating a thunk in the DLL@.  The use of the
4572 @code{dllimport} attribute on imported variables can be avoided by passing the
4573 @option{--enable-auto-import} switch to the GNU linker.  As with
4574 functions, using the attribute for a variable eliminates a thunk in
4575 the DLL@.
4577 One drawback to using this attribute is that a pointer to a
4578 @emph{variable} marked as @code{dllimport} cannot be used as a constant
4579 address. However, a pointer to a @emph{function} with the
4580 @code{dllimport} attribute can be used as a constant initializer; in
4581 this case, the address of a stub function in the import lib is
4582 referenced.  On Microsoft Windows targets, the attribute can be disabled
4583 for functions by setting the @option{-mnop-fun-dllimport} flag.
4584 @end table
4586 @node MIPS Function Attributes
4587 @subsection MIPS Function Attributes
4589 These function attributes are supported by the MIPS back end:
4591 @table @code
4592 @item interrupt
4593 @cindex @code{interrupt} function attribute, MIPS
4594 Use this attribute to indicate that the specified function is an interrupt
4595 handler.  The compiler generates function entry and exit sequences suitable
4596 for use in an interrupt handler when this attribute is present.
4597 An optional argument is supported for the interrupt attribute which allows
4598 the interrupt mode to be described.  By default GCC assumes the external
4599 interrupt controller (EIC) mode is in use, this can be explicitly set using
4600 @code{eic}.  When interrupts are non-masked then the requested Interrupt
4601 Priority Level (IPL) is copied to the current IPL which has the effect of only
4602 enabling higher priority interrupts.  To use vectored interrupt mode use
4603 the argument @code{vector=[sw0|sw1|hw0|hw1|hw2|hw3|hw4|hw5]}, this will change
4604 the behavior of the non-masked interrupt support and GCC will arrange to mask
4605 all interrupts from sw0 up to and including the specified interrupt vector.
4607 You can use the following attributes to modify the behavior
4608 of an interrupt handler:
4609 @table @code
4610 @item use_shadow_register_set
4611 @cindex @code{use_shadow_register_set} function attribute, MIPS
4612 Assume that the handler uses a shadow register set, instead of
4613 the main general-purpose registers.  An optional argument @code{intstack} is
4614 supported to indicate that the shadow register set contains a valid stack
4615 pointer.
4617 @item keep_interrupts_masked
4618 @cindex @code{keep_interrupts_masked} function attribute, MIPS
4619 Keep interrupts masked for the whole function.  Without this attribute,
4620 GCC tries to reenable interrupts for as much of the function as it can.
4622 @item use_debug_exception_return
4623 @cindex @code{use_debug_exception_return} function attribute, MIPS
4624 Return using the @code{deret} instruction.  Interrupt handlers that don't
4625 have this attribute return using @code{eret} instead.
4626 @end table
4628 You can use any combination of these attributes, as shown below:
4629 @smallexample
4630 void __attribute__ ((interrupt)) v0 ();
4631 void __attribute__ ((interrupt, use_shadow_register_set)) v1 ();
4632 void __attribute__ ((interrupt, keep_interrupts_masked)) v2 ();
4633 void __attribute__ ((interrupt, use_debug_exception_return)) v3 ();
4634 void __attribute__ ((interrupt, use_shadow_register_set,
4635                      keep_interrupts_masked)) v4 ();
4636 void __attribute__ ((interrupt, use_shadow_register_set,
4637                      use_debug_exception_return)) v5 ();
4638 void __attribute__ ((interrupt, keep_interrupts_masked,
4639                      use_debug_exception_return)) v6 ();
4640 void __attribute__ ((interrupt, use_shadow_register_set,
4641                      keep_interrupts_masked,
4642                      use_debug_exception_return)) v7 ();
4643 void __attribute__ ((interrupt("eic"))) v8 ();
4644 void __attribute__ ((interrupt("vector=hw3"))) v9 ();
4645 @end smallexample
4647 @item long_call
4648 @itemx short_call
4649 @itemx near
4650 @itemx far
4651 @cindex indirect calls, MIPS
4652 @cindex @code{long_call} function attribute, MIPS
4653 @cindex @code{short_call} function attribute, MIPS
4654 @cindex @code{near} function attribute, MIPS
4655 @cindex @code{far} function attribute, MIPS
4656 These attributes specify how a particular function is called on MIPS@.
4657 The attributes override the @option{-mlong-calls} (@pxref{MIPS Options})
4658 command-line switch.  The @code{long_call} and @code{far} attributes are
4659 synonyms, and cause the compiler to always call
4660 the function by first loading its address into a register, and then using
4661 the contents of that register.  The @code{short_call} and @code{near}
4662 attributes are synonyms, and have the opposite
4663 effect; they specify that non-PIC calls should be made using the more
4664 efficient @code{jal} instruction.
4666 @item mips16
4667 @itemx nomips16
4668 @cindex @code{mips16} function attribute, MIPS
4669 @cindex @code{nomips16} function attribute, MIPS
4671 On MIPS targets, you can use the @code{mips16} and @code{nomips16}
4672 function attributes to locally select or turn off MIPS16 code generation.
4673 A function with the @code{mips16} attribute is emitted as MIPS16 code,
4674 while MIPS16 code generation is disabled for functions with the
4675 @code{nomips16} attribute.  These attributes override the
4676 @option{-mips16} and @option{-mno-mips16} options on the command line
4677 (@pxref{MIPS Options}).
4679 When compiling files containing mixed MIPS16 and non-MIPS16 code, the
4680 preprocessor symbol @code{__mips16} reflects the setting on the command line,
4681 not that within individual functions.  Mixed MIPS16 and non-MIPS16 code
4682 may interact badly with some GCC extensions such as @code{__builtin_apply}
4683 (@pxref{Constructing Calls}).
4685 @item micromips, MIPS
4686 @itemx nomicromips, MIPS
4687 @cindex @code{micromips} function attribute
4688 @cindex @code{nomicromips} function attribute
4690 On MIPS targets, you can use the @code{micromips} and @code{nomicromips}
4691 function attributes to locally select or turn off microMIPS code generation.
4692 A function with the @code{micromips} attribute is emitted as microMIPS code,
4693 while microMIPS code generation is disabled for functions with the
4694 @code{nomicromips} attribute.  These attributes override the
4695 @option{-mmicromips} and @option{-mno-micromips} options on the command line
4696 (@pxref{MIPS Options}).
4698 When compiling files containing mixed microMIPS and non-microMIPS code, the
4699 preprocessor symbol @code{__mips_micromips} reflects the setting on the
4700 command line,
4701 not that within individual functions.  Mixed microMIPS and non-microMIPS code
4702 may interact badly with some GCC extensions such as @code{__builtin_apply}
4703 (@pxref{Constructing Calls}).
4705 @item nocompression
4706 @cindex @code{nocompression} function attribute, MIPS
4707 On MIPS targets, you can use the @code{nocompression} function attribute
4708 to locally turn off MIPS16 and microMIPS code generation.  This attribute
4709 overrides the @option{-mips16} and @option{-mmicromips} options on the
4710 command line (@pxref{MIPS Options}).
4711 @end table
4713 @node MSP430 Function Attributes
4714 @subsection MSP430 Function Attributes
4716 These function attributes are supported by the MSP430 back end:
4718 @table @code
4719 @item critical
4720 @cindex @code{critical} function attribute, MSP430
4721 Critical functions disable interrupts upon entry and restore the
4722 previous interrupt state upon exit.  Critical functions cannot also
4723 have the @code{naked} or @code{reentrant} attributes.  They can have
4724 the @code{interrupt} attribute.
4726 @item interrupt
4727 @cindex @code{interrupt} function attribute, MSP430
4728 Use this attribute to indicate
4729 that the specified function is an interrupt handler.  The compiler generates
4730 function entry and exit sequences suitable for use in an interrupt handler
4731 when this attribute is present.
4733 You can provide an argument to the interrupt
4734 attribute which specifies a name or number.  If the argument is a
4735 number it indicates the slot in the interrupt vector table (0 - 31) to
4736 which this handler should be assigned.  If the argument is a name it
4737 is treated as a symbolic name for the vector slot.  These names should
4738 match up with appropriate entries in the linker script.  By default
4739 the names @code{watchdog} for vector 26, @code{nmi} for vector 30 and
4740 @code{reset} for vector 31 are recognized.
4742 @item naked
4743 @cindex @code{naked} function attribute, MSP430
4744 This attribute allows the compiler to construct the
4745 requisite function declaration, while allowing the body of the
4746 function to be assembly code. The specified function will not have
4747 prologue/epilogue sequences generated by the compiler. Only basic
4748 @code{asm} statements can safely be included in naked functions
4749 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
4750 basic @code{asm} and C code may appear to work, they cannot be
4751 depended upon to work reliably and are not supported.
4753 @item reentrant
4754 @cindex @code{reentrant} function attribute, MSP430
4755 Reentrant functions disable interrupts upon entry and enable them
4756 upon exit.  Reentrant functions cannot also have the @code{naked}
4757 or @code{critical} attributes.  They can have the @code{interrupt}
4758 attribute.
4760 @item wakeup
4761 @cindex @code{wakeup} function attribute, MSP430
4762 This attribute only applies to interrupt functions.  It is silently
4763 ignored if applied to a non-interrupt function.  A wakeup interrupt
4764 function will rouse the processor from any low-power state that it
4765 might be in when the function exits.
4767 @item lower
4768 @itemx upper
4769 @itemx either
4770 @cindex @code{lower} function attribute, MSP430
4771 @cindex @code{upper} function attribute, MSP430
4772 @cindex @code{either} function attribute, MSP430
4773 On the MSP430 target these attributes can be used to specify whether
4774 the function or variable should be placed into low memory, high
4775 memory, or the placement should be left to the linker to decide.  The
4776 attributes are only significant if compiling for the MSP430X
4777 architecture.
4779 The attributes work in conjunction with a linker script that has been
4780 augmented to specify where to place sections with a @code{.lower} and
4781 a @code{.upper} prefix.  So, for example, as well as placing the
4782 @code{.data} section, the script also specifies the placement of a
4783 @code{.lower.data} and a @code{.upper.data} section.  The intention
4784 is that @code{lower} sections are placed into a small but easier to
4785 access memory region and the upper sections are placed into a larger, but
4786 slower to access, region.
4788 The @code{either} attribute is special.  It tells the linker to place
4789 the object into the corresponding @code{lower} section if there is
4790 room for it.  If there is insufficient room then the object is placed
4791 into the corresponding @code{upper} section instead.  Note that the
4792 placement algorithm is not very sophisticated.  It does not attempt to
4793 find an optimal packing of the @code{lower} sections.  It just makes
4794 one pass over the objects and does the best that it can.  Using the
4795 @option{-ffunction-sections} and @option{-fdata-sections} command-line
4796 options can help the packing, however, since they produce smaller,
4797 easier to pack regions.
4798 @end table
4800 @node NDS32 Function Attributes
4801 @subsection NDS32 Function Attributes
4803 These function attributes are supported by the NDS32 back end:
4805 @table @code
4806 @item exception
4807 @cindex @code{exception} function attribute
4808 @cindex exception handler functions, NDS32
4809 Use this attribute on the NDS32 target to indicate that the specified function
4810 is an exception handler.  The compiler will generate corresponding sections
4811 for use in an exception handler.
4813 @item interrupt
4814 @cindex @code{interrupt} function attribute, NDS32
4815 On NDS32 target, this attribute indicates that the specified function
4816 is an interrupt handler.  The compiler generates corresponding sections
4817 for use in an interrupt handler.  You can use the following attributes
4818 to modify the behavior:
4819 @table @code
4820 @item nested
4821 @cindex @code{nested} function attribute, NDS32
4822 This interrupt service routine is interruptible.
4823 @item not_nested
4824 @cindex @code{not_nested} function attribute, NDS32
4825 This interrupt service routine is not interruptible.
4826 @item nested_ready
4827 @cindex @code{nested_ready} function attribute, NDS32
4828 This interrupt service routine is interruptible after @code{PSW.GIE}
4829 (global interrupt enable) is set.  This allows interrupt service routine to
4830 finish some short critical code before enabling interrupts.
4831 @item save_all
4832 @cindex @code{save_all} function attribute, NDS32
4833 The system will help save all registers into stack before entering
4834 interrupt handler.
4835 @item partial_save
4836 @cindex @code{partial_save} function attribute, NDS32
4837 The system will help save caller registers into stack before entering
4838 interrupt handler.
4839 @end table
4841 @item naked
4842 @cindex @code{naked} function attribute, NDS32
4843 This attribute allows the compiler to construct the
4844 requisite function declaration, while allowing the body of the
4845 function to be assembly code. The specified function will not have
4846 prologue/epilogue sequences generated by the compiler. Only basic
4847 @code{asm} statements can safely be included in naked functions
4848 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
4849 basic @code{asm} and C code may appear to work, they cannot be
4850 depended upon to work reliably and are not supported.
4852 @item reset
4853 @cindex @code{reset} function attribute, NDS32
4854 @cindex reset handler functions
4855 Use this attribute on the NDS32 target to indicate that the specified function
4856 is a reset handler.  The compiler will generate corresponding sections
4857 for use in a reset handler.  You can use the following attributes
4858 to provide extra exception handling:
4859 @table @code
4860 @item nmi
4861 @cindex @code{nmi} function attribute, NDS32
4862 Provide a user-defined function to handle NMI exception.
4863 @item warm
4864 @cindex @code{warm} function attribute, NDS32
4865 Provide a user-defined function to handle warm reset exception.
4866 @end table
4867 @end table
4869 @node Nios II Function Attributes
4870 @subsection Nios II Function Attributes
4872 These function attributes are supported by the Nios II back end:
4874 @table @code
4875 @item target (@var{options})
4876 @cindex @code{target} function attribute
4877 As discussed in @ref{Common Function Attributes}, this attribute 
4878 allows specification of target-specific compilation options.
4880 When compiling for Nios II, the following options are allowed:
4882 @table @samp
4883 @item custom-@var{insn}=@var{N}
4884 @itemx no-custom-@var{insn}
4885 @cindex @code{target("custom-@var{insn}=@var{N}")} function attribute, Nios II
4886 @cindex @code{target("no-custom-@var{insn}")} function attribute, Nios II
4887 Each @samp{custom-@var{insn}=@var{N}} attribute locally enables use of a
4888 custom instruction with encoding @var{N} when generating code that uses 
4889 @var{insn}.  Similarly, @samp{no-custom-@var{insn}} locally inhibits use of
4890 the custom instruction @var{insn}.
4891 These target attributes correspond to the
4892 @option{-mcustom-@var{insn}=@var{N}} and @option{-mno-custom-@var{insn}}
4893 command-line options, and support the same set of @var{insn} keywords.
4894 @xref{Nios II Options}, for more information.
4896 @item custom-fpu-cfg=@var{name}
4897 @cindex @code{target("custom-fpu-cfg=@var{name}")} function attribute, Nios II
4898 This attribute corresponds to the @option{-mcustom-fpu-cfg=@var{name}}
4899 command-line option, to select a predefined set of custom instructions
4900 named @var{name}.
4901 @xref{Nios II Options}, for more information.
4902 @end table
4903 @end table
4905 @node Nvidia PTX Function Attributes
4906 @subsection Nvidia PTX Function Attributes
4908 These function attributes are supported by the Nvidia PTX back end:
4910 @table @code
4911 @item kernel
4912 @cindex @code{kernel} attribute, Nvidia PTX
4913 This attribute indicates that the corresponding function should be compiled
4914 as a kernel function, which can be invoked from the host via the CUDA RT 
4915 library.
4916 By default functions are only callable only from other PTX functions.
4918 Kernel functions must have @code{void} return type.
4919 @end table
4921 @node PowerPC Function Attributes
4922 @subsection PowerPC Function Attributes
4924 These function attributes are supported by the PowerPC back end:
4926 @table @code
4927 @item longcall
4928 @itemx shortcall
4929 @cindex indirect calls, PowerPC
4930 @cindex @code{longcall} function attribute, PowerPC
4931 @cindex @code{shortcall} function attribute, PowerPC
4932 The @code{longcall} attribute
4933 indicates that the function might be far away from the call site and
4934 require a different (more expensive) calling sequence.  The
4935 @code{shortcall} attribute indicates that the function is always close
4936 enough for the shorter calling sequence to be used.  These attributes
4937 override both the @option{-mlongcall} switch and
4938 the @code{#pragma longcall} setting.
4940 @xref{RS/6000 and PowerPC Options}, for more information on whether long
4941 calls are necessary.
4943 @item target (@var{options})
4944 @cindex @code{target} function attribute
4945 As discussed in @ref{Common Function Attributes}, this attribute 
4946 allows specification of target-specific compilation options.
4948 On the PowerPC, the following options are allowed:
4950 @table @samp
4951 @item altivec
4952 @itemx no-altivec
4953 @cindex @code{target("altivec")} function attribute, PowerPC
4954 Generate code that uses (does not use) AltiVec instructions.  In
4955 32-bit code, you cannot enable AltiVec instructions unless
4956 @option{-mabi=altivec} is used on the command line.
4958 @item cmpb
4959 @itemx no-cmpb
4960 @cindex @code{target("cmpb")} function attribute, PowerPC
4961 Generate code that uses (does not use) the compare bytes instruction
4962 implemented on the POWER6 processor and other processors that support
4963 the PowerPC V2.05 architecture.
4965 @item dlmzb
4966 @itemx no-dlmzb
4967 @cindex @code{target("dlmzb")} function attribute, PowerPC
4968 Generate code that uses (does not use) the string-search @samp{dlmzb}
4969 instruction on the IBM 405, 440, 464 and 476 processors.  This instruction is
4970 generated by default when targeting those processors.
4972 @item fprnd
4973 @itemx no-fprnd
4974 @cindex @code{target("fprnd")} function attribute, PowerPC
4975 Generate code that uses (does not use) the FP round to integer
4976 instructions implemented on the POWER5+ processor and other processors
4977 that support the PowerPC V2.03 architecture.
4979 @item hard-dfp
4980 @itemx no-hard-dfp
4981 @cindex @code{target("hard-dfp")} function attribute, PowerPC
4982 Generate code that uses (does not use) the decimal floating-point
4983 instructions implemented on some POWER processors.
4985 @item isel
4986 @itemx no-isel
4987 @cindex @code{target("isel")} function attribute, PowerPC
4988 Generate code that uses (does not use) ISEL instruction.
4990 @item mfcrf
4991 @itemx no-mfcrf
4992 @cindex @code{target("mfcrf")} function attribute, PowerPC
4993 Generate code that uses (does not use) the move from condition
4994 register field instruction implemented on the POWER4 processor and
4995 other processors that support the PowerPC V2.01 architecture.
4997 @item mfpgpr
4998 @itemx no-mfpgpr
4999 @cindex @code{target("mfpgpr")} function attribute, PowerPC
5000 Generate code that uses (does not use) the FP move to/from general
5001 purpose register instructions implemented on the POWER6X processor and
5002 other processors that support the extended PowerPC V2.05 architecture.
5004 @item mulhw
5005 @itemx no-mulhw
5006 @cindex @code{target("mulhw")} function attribute, PowerPC
5007 Generate code that uses (does not use) the half-word multiply and
5008 multiply-accumulate instructions on the IBM 405, 440, 464 and 476 processors.
5009 These instructions are generated by default when targeting those
5010 processors.
5012 @item multiple
5013 @itemx no-multiple
5014 @cindex @code{target("multiple")} function attribute, PowerPC
5015 Generate code that uses (does not use) the load multiple word
5016 instructions and the store multiple word instructions.
5018 @item update
5019 @itemx no-update
5020 @cindex @code{target("update")} function attribute, PowerPC
5021 Generate code that uses (does not use) the load or store instructions
5022 that update the base register to the address of the calculated memory
5023 location.
5025 @item popcntb
5026 @itemx no-popcntb
5027 @cindex @code{target("popcntb")} function attribute, PowerPC
5028 Generate code that uses (does not use) the popcount and double-precision
5029 FP reciprocal estimate instruction implemented on the POWER5
5030 processor and other processors that support the PowerPC V2.02
5031 architecture.
5033 @item popcntd
5034 @itemx no-popcntd
5035 @cindex @code{target("popcntd")} function attribute, PowerPC
5036 Generate code that uses (does not use) the popcount instruction
5037 implemented on the POWER7 processor and other processors that support
5038 the PowerPC V2.06 architecture.
5040 @item powerpc-gfxopt
5041 @itemx no-powerpc-gfxopt
5042 @cindex @code{target("powerpc-gfxopt")} function attribute, PowerPC
5043 Generate code that uses (does not use) the optional PowerPC
5044 architecture instructions in the Graphics group, including
5045 floating-point select.
5047 @item powerpc-gpopt
5048 @itemx no-powerpc-gpopt
5049 @cindex @code{target("powerpc-gpopt")} function attribute, PowerPC
5050 Generate code that uses (does not use) the optional PowerPC
5051 architecture instructions in the General Purpose group, including
5052 floating-point square root.
5054 @item recip-precision
5055 @itemx no-recip-precision
5056 @cindex @code{target("recip-precision")} function attribute, PowerPC
5057 Assume (do not assume) that the reciprocal estimate instructions
5058 provide higher-precision estimates than is mandated by the PowerPC
5059 ABI.
5061 @item string
5062 @itemx no-string
5063 @cindex @code{target("string")} function attribute, PowerPC
5064 Generate code that uses (does not use) the load string instructions
5065 and the store string word instructions to save multiple registers and
5066 do small block moves.
5068 @item vsx
5069 @itemx no-vsx
5070 @cindex @code{target("vsx")} function attribute, PowerPC
5071 Generate code that uses (does not use) vector/scalar (VSX)
5072 instructions, and also enable the use of built-in functions that allow
5073 more direct access to the VSX instruction set.  In 32-bit code, you
5074 cannot enable VSX or AltiVec instructions unless
5075 @option{-mabi=altivec} is used on the command line.
5077 @item friz
5078 @itemx no-friz
5079 @cindex @code{target("friz")} function attribute, PowerPC
5080 Generate (do not generate) the @code{friz} instruction when the
5081 @option{-funsafe-math-optimizations} option is used to optimize
5082 rounding a floating-point value to 64-bit integer and back to floating
5083 point.  The @code{friz} instruction does not return the same value if
5084 the floating-point number is too large to fit in an integer.
5086 @item avoid-indexed-addresses
5087 @itemx no-avoid-indexed-addresses
5088 @cindex @code{target("avoid-indexed-addresses")} function attribute, PowerPC
5089 Generate code that tries to avoid (not avoid) the use of indexed load
5090 or store instructions.
5092 @item paired
5093 @itemx no-paired
5094 @cindex @code{target("paired")} function attribute, PowerPC
5095 Generate code that uses (does not use) the generation of PAIRED simd
5096 instructions.
5098 @item longcall
5099 @itemx no-longcall
5100 @cindex @code{target("longcall")} function attribute, PowerPC
5101 Generate code that assumes (does not assume) that all calls are far
5102 away so that a longer more expensive calling sequence is required.
5104 @item cpu=@var{CPU}
5105 @cindex @code{target("cpu=@var{CPU}")} function attribute, PowerPC
5106 Specify the architecture to generate code for when compiling the
5107 function.  If you select the @code{target("cpu=power7")} attribute when
5108 generating 32-bit code, VSX and AltiVec instructions are not generated
5109 unless you use the @option{-mabi=altivec} option on the command line.
5111 @item tune=@var{TUNE}
5112 @cindex @code{target("tune=@var{TUNE}")} function attribute, PowerPC
5113 Specify the architecture to tune for when compiling the function.  If
5114 you do not specify the @code{target("tune=@var{TUNE}")} attribute and
5115 you do specify the @code{target("cpu=@var{CPU}")} attribute,
5116 compilation tunes for the @var{CPU} architecture, and not the
5117 default tuning specified on the command line.
5118 @end table
5120 On the PowerPC, the inliner does not inline a
5121 function that has different target options than the caller, unless the
5122 callee has a subset of the target options of the caller.
5123 @end table
5125 @node RISC-V Function Attributes
5126 @subsection RISC-V Function Attributes
5128 These function attributes are supported by the RISC-V back end:
5130 @table @code
5131 @item naked
5132 @cindex @code{naked} function attribute, RISC-V
5133 This attribute allows the compiler to construct the
5134 requisite function declaration, while allowing the body of the
5135 function to be assembly code. The specified function will not have
5136 prologue/epilogue sequences generated by the compiler. Only basic
5137 @code{asm} statements can safely be included in naked functions
5138 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
5139 basic @code{asm} and C code may appear to work, they cannot be
5140 depended upon to work reliably and are not supported.
5141 @end table
5143 @node RL78 Function Attributes
5144 @subsection RL78 Function Attributes
5146 These function attributes are supported by the RL78 back end:
5148 @table @code
5149 @item interrupt
5150 @itemx brk_interrupt
5151 @cindex @code{interrupt} function attribute, RL78
5152 @cindex @code{brk_interrupt} function attribute, RL78
5153 These attributes indicate
5154 that the specified function is an interrupt handler.  The compiler generates
5155 function entry and exit sequences suitable for use in an interrupt handler
5156 when this attribute is present.
5158 Use @code{brk_interrupt} instead of @code{interrupt} for
5159 handlers intended to be used with the @code{BRK} opcode (i.e.@: those
5160 that must end with @code{RETB} instead of @code{RETI}).
5162 @item naked
5163 @cindex @code{naked} function attribute, RL78
5164 This attribute allows the compiler to construct the
5165 requisite function declaration, while allowing the body of the
5166 function to be assembly code. The specified function will not have
5167 prologue/epilogue sequences generated by the compiler. Only basic
5168 @code{asm} statements can safely be included in naked functions
5169 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
5170 basic @code{asm} and C code may appear to work, they cannot be
5171 depended upon to work reliably and are not supported.
5172 @end table
5174 @node RX Function Attributes
5175 @subsection RX Function Attributes
5177 These function attributes are supported by the RX back end:
5179 @table @code
5180 @item fast_interrupt
5181 @cindex @code{fast_interrupt} function attribute, RX
5182 Use this attribute on the RX port to indicate that the specified
5183 function is a fast interrupt handler.  This is just like the
5184 @code{interrupt} attribute, except that @code{freit} is used to return
5185 instead of @code{reit}.
5187 @item interrupt
5188 @cindex @code{interrupt} function attribute, RX
5189 Use this attribute to indicate
5190 that the specified function is an interrupt handler.  The compiler generates
5191 function entry and exit sequences suitable for use in an interrupt handler
5192 when this attribute is present.
5194 On RX and RL78 targets, you may specify one or more vector numbers as arguments
5195 to the attribute, as well as naming an alternate table name.
5196 Parameters are handled sequentially, so one handler can be assigned to
5197 multiple entries in multiple tables.  One may also pass the magic
5198 string @code{"$default"} which causes the function to be used for any
5199 unfilled slots in the current table.
5201 This example shows a simple assignment of a function to one vector in
5202 the default table (note that preprocessor macros may be used for
5203 chip-specific symbolic vector names):
5204 @smallexample
5205 void __attribute__ ((interrupt (5))) txd1_handler ();
5206 @end smallexample
5208 This example assigns a function to two slots in the default table
5209 (using preprocessor macros defined elsewhere) and makes it the default
5210 for the @code{dct} table:
5211 @smallexample
5212 void __attribute__ ((interrupt (RXD1_VECT,RXD2_VECT,"dct","$default")))
5213         txd1_handler ();
5214 @end smallexample
5216 @item naked
5217 @cindex @code{naked} function attribute, RX
5218 This attribute allows the compiler to construct the
5219 requisite function declaration, while allowing the body of the
5220 function to be assembly code. The specified function will not have
5221 prologue/epilogue sequences generated by the compiler. Only basic
5222 @code{asm} statements can safely be included in naked functions
5223 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
5224 basic @code{asm} and C code may appear to work, they cannot be
5225 depended upon to work reliably and are not supported.
5227 @item vector
5228 @cindex @code{vector} function attribute, RX
5229 This RX attribute is similar to the @code{interrupt} attribute, including its
5230 parameters, but does not make the function an interrupt-handler type
5231 function (i.e. it retains the normal C function calling ABI).  See the
5232 @code{interrupt} attribute for a description of its arguments.
5233 @end table
5235 @node S/390 Function Attributes
5236 @subsection S/390 Function Attributes
5238 These function attributes are supported on the S/390:
5240 @table @code
5241 @item hotpatch (@var{halfwords-before-function-label},@var{halfwords-after-function-label})
5242 @cindex @code{hotpatch} function attribute, S/390
5244 On S/390 System z targets, you can use this function attribute to
5245 make GCC generate a ``hot-patching'' function prologue.  If the
5246 @option{-mhotpatch=} command-line option is used at the same time,
5247 the @code{hotpatch} attribute takes precedence.  The first of the
5248 two arguments specifies the number of halfwords to be added before
5249 the function label.  A second argument can be used to specify the
5250 number of halfwords to be added after the function label.  For
5251 both arguments the maximum allowed value is 1000000.
5253 If both arguments are zero, hotpatching is disabled.
5255 @item target (@var{options})
5256 @cindex @code{target} function attribute
5257 As discussed in @ref{Common Function Attributes}, this attribute
5258 allows specification of target-specific compilation options.
5260 On S/390, the following options are supported:
5262 @table @samp
5263 @item arch=
5264 @item tune=
5265 @item stack-guard=
5266 @item stack-size=
5267 @item branch-cost=
5268 @item warn-framesize=
5269 @item backchain
5270 @itemx no-backchain
5271 @item hard-dfp
5272 @itemx no-hard-dfp
5273 @item hard-float
5274 @itemx soft-float
5275 @item htm
5276 @itemx no-htm
5277 @item vx
5278 @itemx no-vx
5279 @item packed-stack
5280 @itemx no-packed-stack
5281 @item small-exec
5282 @itemx no-small-exec
5283 @item mvcle
5284 @itemx no-mvcle
5285 @item warn-dynamicstack
5286 @itemx no-warn-dynamicstack
5287 @end table
5289 The options work exactly like the S/390 specific command line
5290 options (without the prefix @option{-m}) except that they do not
5291 change any feature macros.  For example,
5293 @smallexample
5294 @code{target("no-vx")}
5295 @end smallexample
5297 does not undefine the @code{__VEC__} macro.
5298 @end table
5300 @node SH Function Attributes
5301 @subsection SH Function Attributes
5303 These function attributes are supported on the SH family of processors:
5305 @table @code
5306 @item function_vector
5307 @cindex @code{function_vector} function attribute, SH
5308 @cindex calling functions through the function vector on SH2A
5309 On SH2A targets, this attribute declares a function to be called using the
5310 TBR relative addressing mode.  The argument to this attribute is the entry
5311 number of the same function in a vector table containing all the TBR
5312 relative addressable functions.  For correct operation the TBR must be setup
5313 accordingly to point to the start of the vector table before any functions with
5314 this attribute are invoked.  Usually a good place to do the initialization is
5315 the startup routine.  The TBR relative vector table can have at max 256 function
5316 entries.  The jumps to these functions are generated using a SH2A specific,
5317 non delayed branch instruction JSR/N @@(disp8,TBR).  You must use GAS and GLD
5318 from GNU binutils version 2.7 or later for this attribute to work correctly.
5320 In an application, for a function being called once, this attribute
5321 saves at least 8 bytes of code; and if other successive calls are being
5322 made to the same function, it saves 2 bytes of code per each of these
5323 calls.
5325 @item interrupt_handler
5326 @cindex @code{interrupt_handler} function attribute, SH
5327 Use this attribute to
5328 indicate that the specified function is an interrupt handler.  The compiler
5329 generates function entry and exit sequences suitable for use in an
5330 interrupt handler when this attribute is present.
5332 @item nosave_low_regs
5333 @cindex @code{nosave_low_regs} function attribute, SH
5334 Use this attribute on SH targets to indicate that an @code{interrupt_handler}
5335 function should not save and restore registers R0..R7.  This can be used on SH3*
5336 and SH4* targets that have a second R0..R7 register bank for non-reentrant
5337 interrupt handlers.
5339 @item renesas
5340 @cindex @code{renesas} function attribute, SH
5341 On SH targets this attribute specifies that the function or struct follows the
5342 Renesas ABI.
5344 @item resbank
5345 @cindex @code{resbank} function attribute, SH
5346 On the SH2A target, this attribute enables the high-speed register
5347 saving and restoration using a register bank for @code{interrupt_handler}
5348 routines.  Saving to the bank is performed automatically after the CPU
5349 accepts an interrupt that uses a register bank.
5351 The nineteen 32-bit registers comprising general register R0 to R14,
5352 control register GBR, and system registers MACH, MACL, and PR and the
5353 vector table address offset are saved into a register bank.  Register
5354 banks are stacked in first-in last-out (FILO) sequence.  Restoration
5355 from the bank is executed by issuing a RESBANK instruction.
5357 @item sp_switch
5358 @cindex @code{sp_switch} function attribute, SH
5359 Use this attribute on the SH to indicate an @code{interrupt_handler}
5360 function should switch to an alternate stack.  It expects a string
5361 argument that names a global variable holding the address of the
5362 alternate stack.
5364 @smallexample
5365 void *alt_stack;
5366 void f () __attribute__ ((interrupt_handler,
5367                           sp_switch ("alt_stack")));
5368 @end smallexample
5370 @item trap_exit
5371 @cindex @code{trap_exit} function attribute, SH
5372 Use this attribute on the SH for an @code{interrupt_handler} to return using
5373 @code{trapa} instead of @code{rte}.  This attribute expects an integer
5374 argument specifying the trap number to be used.
5376 @item trapa_handler
5377 @cindex @code{trapa_handler} function attribute, SH
5378 On SH targets this function attribute is similar to @code{interrupt_handler}
5379 but it does not save and restore all registers.
5380 @end table
5382 @node SPU Function Attributes
5383 @subsection SPU Function Attributes
5385 These function attributes are supported by the SPU back end:
5387 @table @code
5388 @item naked
5389 @cindex @code{naked} function attribute, SPU
5390 This attribute allows the compiler to construct the
5391 requisite function declaration, while allowing the body of the
5392 function to be assembly code. The specified function will not have
5393 prologue/epilogue sequences generated by the compiler. Only basic
5394 @code{asm} statements can safely be included in naked functions
5395 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
5396 basic @code{asm} and C code may appear to work, they cannot be
5397 depended upon to work reliably and are not supported.
5398 @end table
5400 @node Symbian OS Function Attributes
5401 @subsection Symbian OS Function Attributes
5403 @xref{Microsoft Windows Function Attributes}, for discussion of the
5404 @code{dllexport} and @code{dllimport} attributes.
5406 @node V850 Function Attributes
5407 @subsection V850 Function Attributes
5409 The V850 back end supports these function attributes:
5411 @table @code
5412 @item interrupt
5413 @itemx interrupt_handler
5414 @cindex @code{interrupt} function attribute, V850
5415 @cindex @code{interrupt_handler} function attribute, V850
5416 Use these attributes to indicate
5417 that the specified function is an interrupt handler.  The compiler generates
5418 function entry and exit sequences suitable for use in an interrupt handler
5419 when either attribute is present.
5420 @end table
5422 @node Visium Function Attributes
5423 @subsection Visium Function Attributes
5425 These function attributes are supported by the Visium back end:
5427 @table @code
5428 @item interrupt
5429 @cindex @code{interrupt} function attribute, Visium
5430 Use this attribute to indicate
5431 that the specified function is an interrupt handler.  The compiler generates
5432 function entry and exit sequences suitable for use in an interrupt handler
5433 when this attribute is present.
5434 @end table
5436 @node x86 Function Attributes
5437 @subsection x86 Function Attributes
5439 These function attributes are supported by the x86 back end:
5441 @table @code
5442 @item cdecl
5443 @cindex @code{cdecl} function attribute, x86-32
5444 @cindex functions that pop the argument stack on x86-32
5445 @opindex mrtd
5446 On the x86-32 targets, the @code{cdecl} attribute causes the compiler to
5447 assume that the calling function pops off the stack space used to
5448 pass arguments.  This is
5449 useful to override the effects of the @option{-mrtd} switch.
5451 @item fastcall
5452 @cindex @code{fastcall} function attribute, x86-32
5453 @cindex functions that pop the argument stack on x86-32
5454 On x86-32 targets, the @code{fastcall} attribute causes the compiler to
5455 pass the first argument (if of integral type) in the register ECX and
5456 the second argument (if of integral type) in the register EDX@.  Subsequent
5457 and other typed arguments are passed on the stack.  The called function
5458 pops the arguments off the stack.  If the number of arguments is variable all
5459 arguments are pushed on the stack.
5461 @item thiscall
5462 @cindex @code{thiscall} function attribute, x86-32
5463 @cindex functions that pop the argument stack on x86-32
5464 On x86-32 targets, the @code{thiscall} attribute causes the compiler to
5465 pass the first argument (if of integral type) in the register ECX.
5466 Subsequent and other typed arguments are passed on the stack. The called
5467 function pops the arguments off the stack.
5468 If the number of arguments is variable all arguments are pushed on the
5469 stack.
5470 The @code{thiscall} attribute is intended for C++ non-static member functions.
5471 As a GCC extension, this calling convention can be used for C functions
5472 and for static member methods.
5474 @item ms_abi
5475 @itemx sysv_abi
5476 @cindex @code{ms_abi} function attribute, x86
5477 @cindex @code{sysv_abi} function attribute, x86
5479 On 32-bit and 64-bit x86 targets, you can use an ABI attribute
5480 to indicate which calling convention should be used for a function.  The
5481 @code{ms_abi} attribute tells the compiler to use the Microsoft ABI,
5482 while the @code{sysv_abi} attribute tells the compiler to use the ABI
5483 used on GNU/Linux and other systems.  The default is to use the Microsoft ABI
5484 when targeting Windows.  On all other systems, the default is the x86/AMD ABI.
5486 Note, the @code{ms_abi} attribute for Microsoft Windows 64-bit targets currently
5487 requires the @option{-maccumulate-outgoing-args} option.
5489 @item callee_pop_aggregate_return (@var{number})
5490 @cindex @code{callee_pop_aggregate_return} function attribute, x86
5492 On x86-32 targets, you can use this attribute to control how
5493 aggregates are returned in memory.  If the caller is responsible for
5494 popping the hidden pointer together with the rest of the arguments, specify
5495 @var{number} equal to zero.  If callee is responsible for popping the
5496 hidden pointer, specify @var{number} equal to one.  
5498 The default x86-32 ABI assumes that the callee pops the
5499 stack for hidden pointer.  However, on x86-32 Microsoft Windows targets,
5500 the compiler assumes that the
5501 caller pops the stack for hidden pointer.
5503 @item ms_hook_prologue
5504 @cindex @code{ms_hook_prologue} function attribute, x86
5506 On 32-bit and 64-bit x86 targets, you can use
5507 this function attribute to make GCC generate the ``hot-patching'' function
5508 prologue used in Win32 API functions in Microsoft Windows XP Service Pack 2
5509 and newer.
5511 @item naked
5512 @cindex @code{naked} function attribute, x86
5513 This attribute allows the compiler to construct the
5514 requisite function declaration, while allowing the body of the
5515 function to be assembly code. The specified function will not have
5516 prologue/epilogue sequences generated by the compiler. Only basic
5517 @code{asm} statements can safely be included in naked functions
5518 (@pxref{Basic Asm}). While using extended @code{asm} or a mixture of
5519 basic @code{asm} and C code may appear to work, they cannot be
5520 depended upon to work reliably and are not supported.
5522 @item regparm (@var{number})
5523 @cindex @code{regparm} function attribute, x86
5524 @cindex functions that are passed arguments in registers on x86-32
5525 On x86-32 targets, the @code{regparm} attribute causes the compiler to
5526 pass arguments number one to @var{number} if they are of integral type
5527 in registers EAX, EDX, and ECX instead of on the stack.  Functions that
5528 take a variable number of arguments continue to be passed all of their
5529 arguments on the stack.
5531 Beware that on some ELF systems this attribute is unsuitable for
5532 global functions in shared libraries with lazy binding (which is the
5533 default).  Lazy binding sends the first call via resolving code in
5534 the loader, which might assume EAX, EDX and ECX can be clobbered, as
5535 per the standard calling conventions.  Solaris 8 is affected by this.
5536 Systems with the GNU C Library version 2.1 or higher
5537 and FreeBSD are believed to be
5538 safe since the loaders there save EAX, EDX and ECX.  (Lazy binding can be
5539 disabled with the linker or the loader if desired, to avoid the
5540 problem.)
5542 @item sseregparm
5543 @cindex @code{sseregparm} function attribute, x86
5544 On x86-32 targets with SSE support, the @code{sseregparm} attribute
5545 causes the compiler to pass up to 3 floating-point arguments in
5546 SSE registers instead of on the stack.  Functions that take a
5547 variable number of arguments continue to pass all of their
5548 floating-point arguments on the stack.
5550 @item force_align_arg_pointer
5551 @cindex @code{force_align_arg_pointer} function attribute, x86
5552 On x86 targets, the @code{force_align_arg_pointer} attribute may be
5553 applied to individual function definitions, generating an alternate
5554 prologue and epilogue that realigns the run-time stack if necessary.
5555 This supports mixing legacy codes that run with a 4-byte aligned stack
5556 with modern codes that keep a 16-byte stack for SSE compatibility.
5558 @item stdcall
5559 @cindex @code{stdcall} function attribute, x86-32
5560 @cindex functions that pop the argument stack on x86-32
5561 On x86-32 targets, the @code{stdcall} attribute causes the compiler to
5562 assume that the called function pops off the stack space used to
5563 pass arguments, unless it takes a variable number of arguments.
5565 @item no_caller_saved_registers
5566 @cindex @code{no_caller_saved_registers} function attribute, x86
5567 Use this attribute to indicate that the specified function has no
5568 caller-saved registers. That is, all registers are callee-saved. For
5569 example, this attribute can be used for a function called from an
5570 interrupt handler. The compiler generates proper function entry and
5571 exit sequences to save and restore any modified registers, except for
5572 the EFLAGS register.  Since GCC doesn't preserve MPX, SSE, MMX nor x87
5573 states, the GCC option @option{-mgeneral-regs-only} should be used to
5574 compile functions with @code{no_caller_saved_registers} attribute.
5576 @item interrupt
5577 @cindex @code{interrupt} function attribute, x86
5578 Use this attribute to indicate that the specified function is an
5579 interrupt handler or an exception handler (depending on parameters passed
5580 to the function, explained further).  The compiler generates function
5581 entry and exit sequences suitable for use in an interrupt handler when
5582 this attribute is present.  The @code{IRET} instruction, instead of the
5583 @code{RET} instruction, is used to return from interrupt handlers.  All
5584 registers, except for the EFLAGS register which is restored by the
5585 @code{IRET} instruction, are preserved by the compiler.  Since GCC
5586 doesn't preserve MPX, SSE, MMX nor x87 states, the GCC option
5587 @option{-mgeneral-regs-only} should be used to compile interrupt and
5588 exception handlers.
5590 Any interruptible-without-stack-switch code must be compiled with
5591 @option{-mno-red-zone} since interrupt handlers can and will, because
5592 of the hardware design, touch the red zone.
5594 An interrupt handler must be declared with a mandatory pointer
5595 argument:
5597 @smallexample
5598 struct interrupt_frame;
5600 __attribute__ ((interrupt))
5601 void
5602 f (struct interrupt_frame *frame)
5605 @end smallexample
5607 @noindent
5608 and you must define @code{struct interrupt_frame} as described in the
5609 processor's manual.
5611 Exception handlers differ from interrupt handlers because the system
5612 pushes an error code on the stack.  An exception handler declaration is
5613 similar to that for an interrupt handler, but with a different mandatory
5614 function signature.  The compiler arranges to pop the error code off the
5615 stack before the @code{IRET} instruction.
5617 @smallexample
5618 #ifdef __x86_64__
5619 typedef unsigned long long int uword_t;
5620 #else
5621 typedef unsigned int uword_t;
5622 #endif
5624 struct interrupt_frame;
5626 __attribute__ ((interrupt))
5627 void
5628 f (struct interrupt_frame *frame, uword_t error_code)
5630   ...
5632 @end smallexample
5634 Exception handlers should only be used for exceptions that push an error
5635 code; you should use an interrupt handler in other cases.  The system
5636 will crash if the wrong kind of handler is used.
5638 @item target (@var{options})
5639 @cindex @code{target} function attribute
5640 As discussed in @ref{Common Function Attributes}, this attribute 
5641 allows specification of target-specific compilation options.
5643 On the x86, the following options are allowed:
5644 @table @samp
5645 @item abm
5646 @itemx no-abm
5647 @cindex @code{target("abm")} function attribute, x86
5648 Enable/disable the generation of the advanced bit instructions.
5650 @item aes
5651 @itemx no-aes
5652 @cindex @code{target("aes")} function attribute, x86
5653 Enable/disable the generation of the AES instructions.
5655 @item default
5656 @cindex @code{target("default")} function attribute, x86
5657 @xref{Function Multiversioning}, where it is used to specify the
5658 default function version.
5660 @item mmx
5661 @itemx no-mmx
5662 @cindex @code{target("mmx")} function attribute, x86
5663 Enable/disable the generation of the MMX instructions.
5665 @item pclmul
5666 @itemx no-pclmul
5667 @cindex @code{target("pclmul")} function attribute, x86
5668 Enable/disable the generation of the PCLMUL instructions.
5670 @item popcnt
5671 @itemx no-popcnt
5672 @cindex @code{target("popcnt")} function attribute, x86
5673 Enable/disable the generation of the POPCNT instruction.
5675 @item sse
5676 @itemx no-sse
5677 @cindex @code{target("sse")} function attribute, x86
5678 Enable/disable the generation of the SSE instructions.
5680 @item sse2
5681 @itemx no-sse2
5682 @cindex @code{target("sse2")} function attribute, x86
5683 Enable/disable the generation of the SSE2 instructions.
5685 @item sse3
5686 @itemx no-sse3
5687 @cindex @code{target("sse3")} function attribute, x86
5688 Enable/disable the generation of the SSE3 instructions.
5690 @item sse4
5691 @itemx no-sse4
5692 @cindex @code{target("sse4")} function attribute, x86
5693 Enable/disable the generation of the SSE4 instructions (both SSE4.1
5694 and SSE4.2).
5696 @item sse4.1
5697 @itemx no-sse4.1
5698 @cindex @code{target("sse4.1")} function attribute, x86
5699 Enable/disable the generation of the sse4.1 instructions.
5701 @item sse4.2
5702 @itemx no-sse4.2
5703 @cindex @code{target("sse4.2")} function attribute, x86
5704 Enable/disable the generation of the sse4.2 instructions.
5706 @item sse4a
5707 @itemx no-sse4a
5708 @cindex @code{target("sse4a")} function attribute, x86
5709 Enable/disable the generation of the SSE4A instructions.
5711 @item fma4
5712 @itemx no-fma4
5713 @cindex @code{target("fma4")} function attribute, x86
5714 Enable/disable the generation of the FMA4 instructions.
5716 @item xop
5717 @itemx no-xop
5718 @cindex @code{target("xop")} function attribute, x86
5719 Enable/disable the generation of the XOP instructions.
5721 @item lwp
5722 @itemx no-lwp
5723 @cindex @code{target("lwp")} function attribute, x86
5724 Enable/disable the generation of the LWP instructions.
5726 @item ssse3
5727 @itemx no-ssse3
5728 @cindex @code{target("ssse3")} function attribute, x86
5729 Enable/disable the generation of the SSSE3 instructions.
5731 @item cld
5732 @itemx no-cld
5733 @cindex @code{target("cld")} function attribute, x86
5734 Enable/disable the generation of the CLD before string moves.
5736 @item fancy-math-387
5737 @itemx no-fancy-math-387
5738 @cindex @code{target("fancy-math-387")} function attribute, x86
5739 Enable/disable the generation of the @code{sin}, @code{cos}, and
5740 @code{sqrt} instructions on the 387 floating-point unit.
5742 @item ieee-fp
5743 @itemx no-ieee-fp
5744 @cindex @code{target("ieee-fp")} function attribute, x86
5745 Enable/disable the generation of floating point that depends on IEEE arithmetic.
5747 @item inline-all-stringops
5748 @itemx no-inline-all-stringops
5749 @cindex @code{target("inline-all-stringops")} function attribute, x86
5750 Enable/disable inlining of string operations.
5752 @item inline-stringops-dynamically
5753 @itemx no-inline-stringops-dynamically
5754 @cindex @code{target("inline-stringops-dynamically")} function attribute, x86
5755 Enable/disable the generation of the inline code to do small string
5756 operations and calling the library routines for large operations.
5758 @item align-stringops
5759 @itemx no-align-stringops
5760 @cindex @code{target("align-stringops")} function attribute, x86
5761 Do/do not align destination of inlined string operations.
5763 @item recip
5764 @itemx no-recip
5765 @cindex @code{target("recip")} function attribute, x86
5766 Enable/disable the generation of RCPSS, RCPPS, RSQRTSS and RSQRTPS
5767 instructions followed an additional Newton-Raphson step instead of
5768 doing a floating-point division.
5770 @item arch=@var{ARCH}
5771 @cindex @code{target("arch=@var{ARCH}")} function attribute, x86
5772 Specify the architecture to generate code for in compiling the function.
5774 @item tune=@var{TUNE}
5775 @cindex @code{target("tune=@var{TUNE}")} function attribute, x86
5776 Specify the architecture to tune for in compiling the function.
5778 @item fpmath=@var{FPMATH}
5779 @cindex @code{target("fpmath=@var{FPMATH}")} function attribute, x86
5780 Specify which floating-point unit to use.  You must specify the
5781 @code{target("fpmath=sse,387")} option as
5782 @code{target("fpmath=sse+387")} because the comma would separate
5783 different options.
5785 @item indirect_branch("@var{choice}")
5786 @cindex @code{indirect_branch} function attribute, x86
5787 On x86 targets, the @code{indirect_branch} attribute causes the compiler
5788 to convert indirect call and jump with @var{choice}.  @samp{keep}
5789 keeps indirect call and jump unmodified.  @samp{thunk} converts indirect
5790 call and jump to call and return thunk.  @samp{thunk-inline} converts
5791 indirect call and jump to inlined call and return thunk.
5792 @samp{thunk-extern} converts indirect call and jump to external call
5793 and return thunk provided in a separate object file.
5795 @item function_return("@var{choice}")
5796 @cindex @code{function_return} function attribute, x86
5797 On x86 targets, the @code{function_return} attribute causes the compiler
5798 to convert function return with @var{choice}.  @samp{keep} keeps function
5799 return unmodified.  @samp{thunk} converts function return to call and
5800 return thunk.  @samp{thunk-inline} converts function return to inlined
5801 call and return thunk.  @samp{thunk-extern} converts function return to
5802 external call and return thunk provided in a separate object file.
5804 @item nocf_check
5805 @cindex @code{nocf_check} function attribute
5806 The @code{nocf_check} attribute on a function is used to inform the
5807 compiler that the function's prologue should not be instrumented when
5808 compiled with the @option{-fcf-protection=branch} option.  The
5809 compiler assumes that the function's address is a valid target for a
5810 control-flow transfer.
5812 The @code{nocf_check} attribute on a type of pointer to function is
5813 used to inform the compiler that a call through the pointer should
5814 not be instrumented when compiled with the
5815 @option{-fcf-protection=branch} option.  The compiler assumes
5816 that the function's address from the pointer is a valid target for
5817 a control-flow transfer.  A direct function call through a function
5818 name is assumed to be a safe call thus direct calls are not
5819 instrumented by the compiler.
5821 The @code{nocf_check} attribute is applied to an object's type.
5822 In case of assignment of a function address or a function pointer to
5823 another pointer, the attribute is not carried over from the right-hand
5824 object's type; the type of left-hand object stays unchanged.  The
5825 compiler checks for @code{nocf_check} attribute mismatch and reports
5826 a warning in case of mismatch.
5828 @smallexample
5830 int foo (void) __attribute__(nocf_check);
5831 void (*foo1)(void) __attribute__(nocf_check);
5832 void (*foo2)(void);
5834 /* foo's address is assumed to be valid.  */
5836 foo (void) 
5838   /* This call site is not checked for control-flow 
5839      validity.  */
5840   (*foo1)();
5842   /* A warning is issued about attribute mismatch.  */
5843   foo1 = foo2; 
5845   /* This call site is still not checked.  */
5846   (*foo1)();
5848   /* This call site is checked.  */
5849   (*foo2)();
5851   /* A warning is issued about attribute mismatch.  */
5852   foo2 = foo1; 
5854   /* This call site is still checked.  */
5855   (*foo2)();
5857   return 0;
5859 @end smallexample
5861 @end table
5863 On the x86, the inliner does not inline a
5864 function that has different target options than the caller, unless the
5865 callee has a subset of the target options of the caller.  For example
5866 a function declared with @code{target("sse3")} can inline a function
5867 with @code{target("sse2")}, since @code{-msse3} implies @code{-msse2}.
5868 @end table
5870 @node Xstormy16 Function Attributes
5871 @subsection Xstormy16 Function Attributes
5873 These function attributes are supported by the Xstormy16 back end:
5875 @table @code
5876 @item interrupt
5877 @cindex @code{interrupt} function attribute, Xstormy16
5878 Use this attribute to indicate
5879 that the specified function is an interrupt handler.  The compiler generates
5880 function entry and exit sequences suitable for use in an interrupt handler
5881 when this attribute is present.
5882 @end table
5884 @node Variable Attributes
5885 @section Specifying Attributes of Variables
5886 @cindex attribute of variables
5887 @cindex variable attributes
5889 The keyword @code{__attribute__} allows you to specify special
5890 attributes of variables or structure fields.  This keyword is followed
5891 by an attribute specification inside double parentheses.  Some
5892 attributes are currently defined generically for variables.
5893 Other attributes are defined for variables on particular target
5894 systems.  Other attributes are available for functions
5895 (@pxref{Function Attributes}), labels (@pxref{Label Attributes}),
5896 enumerators (@pxref{Enumerator Attributes}), statements
5897 (@pxref{Statement Attributes}), and for types (@pxref{Type Attributes}).
5898 Other front ends might define more attributes
5899 (@pxref{C++ Extensions,,Extensions to the C++ Language}).
5901 @xref{Attribute Syntax}, for details of the exact syntax for using
5902 attributes.
5904 @menu
5905 * Common Variable Attributes::
5906 * ARC Variable Attributes::
5907 * AVR Variable Attributes::
5908 * Blackfin Variable Attributes::
5909 * H8/300 Variable Attributes::
5910 * IA-64 Variable Attributes::
5911 * M32R/D Variable Attributes::
5912 * MeP Variable Attributes::
5913 * Microsoft Windows Variable Attributes::
5914 * MSP430 Variable Attributes::
5915 * Nvidia PTX Variable Attributes::
5916 * PowerPC Variable Attributes::
5917 * RL78 Variable Attributes::
5918 * SPU Variable Attributes::
5919 * V850 Variable Attributes::
5920 * x86 Variable Attributes::
5921 * Xstormy16 Variable Attributes::
5922 @end menu
5924 @node Common Variable Attributes
5925 @subsection Common Variable Attributes
5927 The following attributes are supported on most targets.
5929 @table @code
5930 @cindex @code{aligned} variable attribute
5931 @item aligned (@var{alignment})
5932 This attribute specifies a minimum alignment for the variable or
5933 structure field, measured in bytes.  For example, the declaration:
5935 @smallexample
5936 int x __attribute__ ((aligned (16))) = 0;
5937 @end smallexample
5939 @noindent
5940 causes the compiler to allocate the global variable @code{x} on a
5941 16-byte boundary.  On a 68040, this could be used in conjunction with
5942 an @code{asm} expression to access the @code{move16} instruction which
5943 requires 16-byte aligned operands.
5945 You can also specify the alignment of structure fields.  For example, to
5946 create a double-word aligned @code{int} pair, you could write:
5948 @smallexample
5949 struct foo @{ int x[2] __attribute__ ((aligned (8))); @};
5950 @end smallexample
5952 @noindent
5953 This is an alternative to creating a union with a @code{double} member,
5954 which forces the union to be double-word aligned.
5956 As in the preceding examples, you can explicitly specify the alignment
5957 (in bytes) that you wish the compiler to use for a given variable or
5958 structure field.  Alternatively, you can leave out the alignment factor
5959 and just ask the compiler to align a variable or field to the
5960 default alignment for the target architecture you are compiling for.
5961 The default alignment is sufficient for all scalar types, but may not be
5962 enough for all vector types on a target that supports vector operations.
5963 The default alignment is fixed for a particular target ABI.
5965 GCC also provides a target specific macro @code{__BIGGEST_ALIGNMENT__},
5966 which is the largest alignment ever used for any data type on the
5967 target machine you are compiling for.  For example, you could write:
5969 @smallexample
5970 short array[3] __attribute__ ((aligned (__BIGGEST_ALIGNMENT__)));
5971 @end smallexample
5973 The compiler automatically sets the alignment for the declared
5974 variable or field to @code{__BIGGEST_ALIGNMENT__}.  Doing this can
5975 often make copy operations more efficient, because the compiler can
5976 use whatever instructions copy the biggest chunks of memory when
5977 performing copies to or from the variables or fields that you have
5978 aligned this way.  Note that the value of @code{__BIGGEST_ALIGNMENT__}
5979 may change depending on command-line options.
5981 When used on a struct, or struct member, the @code{aligned} attribute can
5982 only increase the alignment; in order to decrease it, the @code{packed}
5983 attribute must be specified as well.  When used as part of a typedef, the
5984 @code{aligned} attribute can both increase and decrease alignment, and
5985 specifying the @code{packed} attribute generates a warning.
5987 Note that the effectiveness of @code{aligned} attributes may be limited
5988 by inherent limitations in your linker.  On many systems, the linker is
5989 only able to arrange for variables to be aligned up to a certain maximum
5990 alignment.  (For some linkers, the maximum supported alignment may
5991 be very very small.)  If your linker is only able to align variables
5992 up to a maximum of 8-byte alignment, then specifying @code{aligned(16)}
5993 in an @code{__attribute__} still only provides you with 8-byte
5994 alignment.  See your linker documentation for further information.
5996 The @code{aligned} attribute can also be used for functions
5997 (@pxref{Common Function Attributes}.)
5999 @cindex @code{warn_if_not_aligned} variable attribute
6000 @item warn_if_not_aligned (@var{alignment})
6001 This attribute specifies a threshold for the structure field, measured
6002 in bytes.  If the structure field is aligned below the threshold, a
6003 warning will be issued.  For example, the declaration:
6005 @smallexample
6006 struct foo
6008   int i1;
6009   int i2;
6010   unsigned long long x __attribute__((warn_if_not_aligned(16)));
6012 @end smallexample
6014 @noindent
6015 causes the compiler to issue an warning on @code{struct foo}, like
6016 @samp{warning: alignment 8 of 'struct foo' is less than 16}.
6017 The compiler also issues a warning, like @samp{warning: 'x' offset
6018 8 in 'struct foo' isn't aligned to 16}, when the structure field has
6019 the misaligned offset:
6021 @smallexample
6022 struct foo
6024   int i1;
6025   int i2;
6026   unsigned long long x __attribute__((warn_if_not_aligned(16)));
6027 @} __attribute__((aligned(16)));
6028 @end smallexample
6030 This warning can be disabled by @option{-Wno-if-not-aligned}.
6031 The @code{warn_if_not_aligned} attribute can also be used for types
6032 (@pxref{Common Type Attributes}.)
6034 @item cleanup (@var{cleanup_function})
6035 @cindex @code{cleanup} variable attribute
6036 The @code{cleanup} attribute runs a function when the variable goes
6037 out of scope.  This attribute can only be applied to auto function
6038 scope variables; it may not be applied to parameters or variables
6039 with static storage duration.  The function must take one parameter,
6040 a pointer to a type compatible with the variable.  The return value
6041 of the function (if any) is ignored.
6043 If @option{-fexceptions} is enabled, then @var{cleanup_function}
6044 is run during the stack unwinding that happens during the
6045 processing of the exception.  Note that the @code{cleanup} attribute
6046 does not allow the exception to be caught, only to perform an action.
6047 It is undefined what happens if @var{cleanup_function} does not
6048 return normally.
6050 @item common
6051 @itemx nocommon
6052 @cindex @code{common} variable attribute
6053 @cindex @code{nocommon} variable attribute
6054 @opindex fcommon
6055 @opindex fno-common
6056 The @code{common} attribute requests GCC to place a variable in
6057 ``common'' storage.  The @code{nocommon} attribute requests the
6058 opposite---to allocate space for it directly.
6060 These attributes override the default chosen by the
6061 @option{-fno-common} and @option{-fcommon} flags respectively.
6063 @item deprecated
6064 @itemx deprecated (@var{msg})
6065 @cindex @code{deprecated} variable attribute
6066 The @code{deprecated} attribute results in a warning if the variable
6067 is used anywhere in the source file.  This is useful when identifying
6068 variables that are expected to be removed in a future version of a
6069 program.  The warning also includes the location of the declaration
6070 of the deprecated variable, to enable users to easily find further
6071 information about why the variable is deprecated, or what they should
6072 do instead.  Note that the warning only occurs for uses:
6074 @smallexample
6075 extern int old_var __attribute__ ((deprecated));
6076 extern int old_var;
6077 int new_fn () @{ return old_var; @}
6078 @end smallexample
6080 @noindent
6081 results in a warning on line 3 but not line 2.  The optional @var{msg}
6082 argument, which must be a string, is printed in the warning if
6083 present.
6085 The @code{deprecated} attribute can also be used for functions and
6086 types (@pxref{Common Function Attributes},
6087 @pxref{Common Type Attributes}).
6089 @item nonstring
6090 @cindex @code{nonstring} variable attribute
6091 The @code{nonstring} variable attribute specifies that an object or member
6092 declaration with type array of @code{char}, @code{signed char}, or
6093 @code{unsigned char}, or pointer to such a type is intended to store
6094 character arrays that do not necessarily contain a terminating @code{NUL}.
6095 This is useful in detecting uses of such arrays or pointers with functions
6096 that expect @code{NUL}-terminated strings, and to avoid warnings when such
6097 an array or pointer is used as an argument to a bounded string manipulation
6098 function such as @code{strncpy}.  For example, without the attribute, GCC
6099 will issue a warning for the @code{strncpy} call below because it may
6100 truncate the copy without appending the terminating @code{NUL} character.
6101 Using the attribute makes it possible to suppress the warning.  However,
6102 when the array is declared with the attribute the call to @code{strlen} is
6103 diagnosed because when the array doesn't contain a @code{NUL}-terminated
6104 string the call is undefined.  To copy, compare, of search non-string
6105 character arrays use the @code{memcpy}, @code{memcmp}, @code{memchr},
6106 and other functions that operate on arrays of bytes.  In addition,
6107 calling @code{strnlen} and @code{strndup} with such arrays is safe
6108 provided a suitable bound is specified, and not diagnosed.
6110 @smallexample
6111 struct Data
6113   char name [32] __attribute__ ((nonstring));
6116 int f (struct Data *pd, const char *s)
6118   strncpy (pd->name, s, sizeof pd->name);
6119   @dots{}
6120   return strlen (pd->name);   // unsafe, gets a warning
6122 @end smallexample
6124 @item mode (@var{mode})
6125 @cindex @code{mode} variable attribute
6126 This attribute specifies the data type for the declaration---whichever
6127 type corresponds to the mode @var{mode}.  This in effect lets you
6128 request an integer or floating-point type according to its width.
6130 @xref{Machine Modes,,, gccint, GNU Compiler Collection (GCC) Internals},
6131 for a list of the possible keywords for @var{mode}.
6132 You may also specify a mode of @code{byte} or @code{__byte__} to
6133 indicate the mode corresponding to a one-byte integer, @code{word} or
6134 @code{__word__} for the mode of a one-word integer, and @code{pointer}
6135 or @code{__pointer__} for the mode used to represent pointers.
6137 @item packed
6138 @cindex @code{packed} variable attribute
6139 The @code{packed} attribute specifies that a variable or structure field
6140 should have the smallest possible alignment---one byte for a variable,
6141 and one bit for a field, unless you specify a larger value with the
6142 @code{aligned} attribute.
6144 Here is a structure in which the field @code{x} is packed, so that it
6145 immediately follows @code{a}:
6147 @smallexample
6148 struct foo
6150   char a;
6151   int x[2] __attribute__ ((packed));
6153 @end smallexample
6155 @emph{Note:} The 4.1, 4.2 and 4.3 series of GCC ignore the
6156 @code{packed} attribute on bit-fields of type @code{char}.  This has
6157 been fixed in GCC 4.4 but the change can lead to differences in the
6158 structure layout.  See the documentation of
6159 @option{-Wpacked-bitfield-compat} for more information.
6161 @item section ("@var{section-name}")
6162 @cindex @code{section} variable attribute
6163 Normally, the compiler places the objects it generates in sections like
6164 @code{data} and @code{bss}.  Sometimes, however, you need additional sections,
6165 or you need certain particular variables to appear in special sections,
6166 for example to map to special hardware.  The @code{section}
6167 attribute specifies that a variable (or function) lives in a particular
6168 section.  For example, this small program uses several specific section names:
6170 @smallexample
6171 struct duart a __attribute__ ((section ("DUART_A"))) = @{ 0 @};
6172 struct duart b __attribute__ ((section ("DUART_B"))) = @{ 0 @};
6173 char stack[10000] __attribute__ ((section ("STACK"))) = @{ 0 @};
6174 int init_data __attribute__ ((section ("INITDATA")));
6176 main()
6178   /* @r{Initialize stack pointer} */
6179   init_sp (stack + sizeof (stack));
6181   /* @r{Initialize initialized data} */
6182   memcpy (&init_data, &data, &edata - &data);
6184   /* @r{Turn on the serial ports} */
6185   init_duart (&a);
6186   init_duart (&b);
6188 @end smallexample
6190 @noindent
6191 Use the @code{section} attribute with
6192 @emph{global} variables and not @emph{local} variables,
6193 as shown in the example.
6195 You may use the @code{section} attribute with initialized or
6196 uninitialized global variables but the linker requires
6197 each object be defined once, with the exception that uninitialized
6198 variables tentatively go in the @code{common} (or @code{bss}) section
6199 and can be multiply ``defined''.  Using the @code{section} attribute
6200 changes what section the variable goes into and may cause the
6201 linker to issue an error if an uninitialized variable has multiple
6202 definitions.  You can force a variable to be initialized with the
6203 @option{-fno-common} flag or the @code{nocommon} attribute.
6205 Some file formats do not support arbitrary sections so the @code{section}
6206 attribute is not available on all platforms.
6207 If you need to map the entire contents of a module to a particular
6208 section, consider using the facilities of the linker instead.
6210 @item tls_model ("@var{tls_model}")
6211 @cindex @code{tls_model} variable attribute
6212 The @code{tls_model} attribute sets thread-local storage model
6213 (@pxref{Thread-Local}) of a particular @code{__thread} variable,
6214 overriding @option{-ftls-model=} command-line switch on a per-variable
6215 basis.
6216 The @var{tls_model} argument should be one of @code{global-dynamic},
6217 @code{local-dynamic}, @code{initial-exec} or @code{local-exec}.
6219 Not all targets support this attribute.
6221 @item unused
6222 @cindex @code{unused} variable attribute
6223 This attribute, attached to a variable, means that the variable is meant
6224 to be possibly unused.  GCC does not produce a warning for this
6225 variable.
6227 @item used
6228 @cindex @code{used} variable attribute
6229 This attribute, attached to a variable with static storage, means that
6230 the variable must be emitted even if it appears that the variable is not
6231 referenced.
6233 When applied to a static data member of a C++ class template, the
6234 attribute also means that the member is instantiated if the
6235 class itself is instantiated.
6237 @item vector_size (@var{bytes})
6238 @cindex @code{vector_size} variable attribute
6239 This attribute specifies the vector size for the variable, measured in
6240 bytes.  For example, the declaration:
6242 @smallexample
6243 int foo __attribute__ ((vector_size (16)));
6244 @end smallexample
6246 @noindent
6247 causes the compiler to set the mode for @code{foo}, to be 16 bytes,
6248 divided into @code{int} sized units.  Assuming a 32-bit int (a vector of
6249 4 units of 4 bytes), the corresponding mode of @code{foo} is V4SI@.
6251 This attribute is only applicable to integral and float scalars,
6252 although arrays, pointers, and function return values are allowed in
6253 conjunction with this construct.
6255 Aggregates with this attribute are invalid, even if they are of the same
6256 size as a corresponding scalar.  For example, the declaration:
6258 @smallexample
6259 struct S @{ int a; @};
6260 struct S  __attribute__ ((vector_size (16))) foo;
6261 @end smallexample
6263 @noindent
6264 is invalid even if the size of the structure is the same as the size of
6265 the @code{int}.
6267 @item visibility ("@var{visibility_type}")
6268 @cindex @code{visibility} variable attribute
6269 This attribute affects the linkage of the declaration to which it is attached.
6270 The @code{visibility} attribute is described in
6271 @ref{Common Function Attributes}.
6273 @item weak
6274 @cindex @code{weak} variable attribute
6275 The @code{weak} attribute is described in
6276 @ref{Common Function Attributes}.
6278 @end table
6280 @node ARC Variable Attributes
6281 @subsection ARC Variable Attributes
6283 @table @code
6284 @item aux
6285 @cindex @code{aux} variable attribute, ARC
6286 The @code{aux} attribute is used to directly access the ARC's
6287 auxiliary register space from C.  The auxilirary register number is
6288 given via attribute argument.
6290 @end table
6292 @node AVR Variable Attributes
6293 @subsection AVR Variable Attributes
6295 @table @code
6296 @item progmem
6297 @cindex @code{progmem} variable attribute, AVR
6298 The @code{progmem} attribute is used on the AVR to place read-only
6299 data in the non-volatile program memory (flash). The @code{progmem}
6300 attribute accomplishes this by putting respective variables into a
6301 section whose name starts with @code{.progmem}.
6303 This attribute works similar to the @code{section} attribute
6304 but adds additional checking.
6306 @table @asis
6307 @item @bullet{}@tie{} Ordinary AVR cores with 32 general purpose registers:
6308 @code{progmem} affects the location
6309 of the data but not how this data is accessed.
6310 In order to read data located with the @code{progmem} attribute
6311 (inline) assembler must be used.
6312 @smallexample
6313 /* Use custom macros from @w{@uref{http://nongnu.org/avr-libc/user-manual/,AVR-LibC}} */
6314 #include <avr/pgmspace.h> 
6316 /* Locate var in flash memory */
6317 const int var[2] PROGMEM = @{ 1, 2 @};
6319 int read_var (int i)
6321     /* Access var[] by accessor macro from avr/pgmspace.h */
6322     return (int) pgm_read_word (& var[i]);
6324 @end smallexample
6326 AVR is a Harvard architecture processor and data and read-only data
6327 normally resides in the data memory (RAM).
6329 See also the @ref{AVR Named Address Spaces} section for
6330 an alternate way to locate and access data in flash memory.
6332 @item @bullet{}@tie{} AVR cores with flash memory visible in the RAM address range:
6333 On such devices, there is no need for attribute @code{progmem} or
6334 @ref{AVR Named Address Spaces,,@code{__flash}} qualifier at all.
6335 Just use standard C / C++.  The compiler will generate @code{LD*}
6336 instructions.  As flash memory is visible in the RAM address range,
6337 and the default linker script does @emph{not} locate @code{.rodata} in
6338 RAM, no special features are needed in order not to waste RAM for
6339 read-only data or to read from flash.  You might even get slightly better
6340 performance by
6341 avoiding @code{progmem} and @code{__flash}.  This applies to devices from
6342 families @code{avrtiny} and @code{avrxmega3}, see @ref{AVR Options} for
6343 an overview.
6345 @item @bullet{}@tie{}Reduced AVR Tiny cores like ATtiny40:
6346 The compiler adds @code{0x4000}
6347 to the addresses of objects and declarations in @code{progmem} and locates
6348 the objects in flash memory, namely in section @code{.progmem.data}.
6349 The offset is needed because the flash memory is visible in the RAM
6350 address space starting at address @code{0x4000}.
6352 Data in @code{progmem} can be accessed by means of ordinary C@tie{}code,
6353 no special functions or macros are needed.
6355 @smallexample
6356 /* var is located in flash memory */
6357 extern const int var[2] __attribute__((progmem));
6359 int read_var (int i)
6361     return var[i];
6363 @end smallexample
6365 Please notice that on these devices, there is no need for @code{progmem}
6366 at all.
6368 @end table
6370 @item io
6371 @itemx io (@var{addr})
6372 @cindex @code{io} variable attribute, AVR
6373 Variables with the @code{io} attribute are used to address
6374 memory-mapped peripherals in the io address range.
6375 If an address is specified, the variable
6376 is assigned that address, and the value is interpreted as an
6377 address in the data address space.
6378 Example:
6380 @smallexample
6381 volatile int porta __attribute__((io (0x22)));
6382 @end smallexample
6384 The address specified in the address in the data address range.
6386 Otherwise, the variable it is not assigned an address, but the
6387 compiler will still use in/out instructions where applicable,
6388 assuming some other module assigns an address in the io address range.
6389 Example:
6391 @smallexample
6392 extern volatile int porta __attribute__((io));
6393 @end smallexample
6395 @item io_low
6396 @itemx io_low (@var{addr})
6397 @cindex @code{io_low} variable attribute, AVR
6398 This is like the @code{io} attribute, but additionally it informs the
6399 compiler that the object lies in the lower half of the I/O area,
6400 allowing the use of @code{cbi}, @code{sbi}, @code{sbic} and @code{sbis}
6401 instructions.
6403 @item address
6404 @itemx address (@var{addr})
6405 @cindex @code{address} variable attribute, AVR
6406 Variables with the @code{address} attribute are used to address
6407 memory-mapped peripherals that may lie outside the io address range.
6409 @smallexample
6410 volatile int porta __attribute__((address (0x600)));
6411 @end smallexample
6413 @item absdata
6414 @cindex @code{absdata} variable attribute, AVR
6415 Variables in static storage and with the @code{absdata} attribute can
6416 be accessed by the @code{LDS} and @code{STS} instructions which take
6417 absolute addresses.
6419 @itemize @bullet
6420 @item
6421 This attribute is only supported for the reduced AVR Tiny core
6422 like ATtiny40.
6424 @item
6425 You must make sure that respective data is located in the
6426 address range @code{0x40}@dots{}@code{0xbf} accessible by
6427 @code{LDS} and @code{STS}.  One way to achieve this as an
6428 appropriate linker description file.
6430 @item
6431 If the location does not fit the address range of @code{LDS}
6432 and @code{STS}, there is currently (Binutils 2.26) just an unspecific
6433 warning like
6434 @quotation
6435 @code{module.c:(.text+0x1c): warning: internal error: out of range error}
6436 @end quotation
6438 @end itemize
6440 See also the @option{-mabsdata} @ref{AVR Options,command-line option}.
6442 @end table
6444 @node Blackfin Variable Attributes
6445 @subsection Blackfin Variable Attributes
6447 Three attributes are currently defined for the Blackfin.
6449 @table @code
6450 @item l1_data
6451 @itemx l1_data_A
6452 @itemx l1_data_B
6453 @cindex @code{l1_data} variable attribute, Blackfin
6454 @cindex @code{l1_data_A} variable attribute, Blackfin
6455 @cindex @code{l1_data_B} variable attribute, Blackfin
6456 Use these attributes on the Blackfin to place the variable into L1 Data SRAM.
6457 Variables with @code{l1_data} attribute are put into the specific section
6458 named @code{.l1.data}. Those with @code{l1_data_A} attribute are put into
6459 the specific section named @code{.l1.data.A}. Those with @code{l1_data_B}
6460 attribute are put into the specific section named @code{.l1.data.B}.
6462 @item l2
6463 @cindex @code{l2} variable attribute, Blackfin
6464 Use this attribute on the Blackfin to place the variable into L2 SRAM.
6465 Variables with @code{l2} attribute are put into the specific section
6466 named @code{.l2.data}.
6467 @end table
6469 @node H8/300 Variable Attributes
6470 @subsection H8/300 Variable Attributes
6472 These variable attributes are available for H8/300 targets:
6474 @table @code
6475 @item eightbit_data
6476 @cindex @code{eightbit_data} variable attribute, H8/300
6477 @cindex eight-bit data on the H8/300, H8/300H, and H8S
6478 Use this attribute on the H8/300, H8/300H, and H8S to indicate that the specified
6479 variable should be placed into the eight-bit data section.
6480 The compiler generates more efficient code for certain operations
6481 on data in the eight-bit data area.  Note the eight-bit data area is limited to
6482 256 bytes of data.
6484 You must use GAS and GLD from GNU binutils version 2.7 or later for
6485 this attribute to work correctly.
6487 @item tiny_data
6488 @cindex @code{tiny_data} variable attribute, H8/300
6489 @cindex tiny data section on the H8/300H and H8S
6490 Use this attribute on the H8/300H and H8S to indicate that the specified
6491 variable should be placed into the tiny data section.
6492 The compiler generates more efficient code for loads and stores
6493 on data in the tiny data section.  Note the tiny data area is limited to
6494 slightly under 32KB of data.
6496 @end table
6498 @node IA-64 Variable Attributes
6499 @subsection IA-64 Variable Attributes
6501 The IA-64 back end supports the following variable attribute:
6503 @table @code
6504 @item model (@var{model-name})
6505 @cindex @code{model} variable attribute, IA-64
6507 On IA-64, use this attribute to set the addressability of an object.
6508 At present, the only supported identifier for @var{model-name} is
6509 @code{small}, indicating addressability via ``small'' (22-bit)
6510 addresses (so that their addresses can be loaded with the @code{addl}
6511 instruction).  Caveat: such addressing is by definition not position
6512 independent and hence this attribute must not be used for objects
6513 defined by shared libraries.
6515 @end table
6517 @node M32R/D Variable Attributes
6518 @subsection M32R/D Variable Attributes
6520 One attribute is currently defined for the M32R/D@.
6522 @table @code
6523 @item model (@var{model-name})
6524 @cindex @code{model-name} variable attribute, M32R/D
6525 @cindex variable addressability on the M32R/D
6526 Use this attribute on the M32R/D to set the addressability of an object.
6527 The identifier @var{model-name} is one of @code{small}, @code{medium},
6528 or @code{large}, representing each of the code models.
6530 Small model objects live in the lower 16MB of memory (so that their
6531 addresses can be loaded with the @code{ld24} instruction).
6533 Medium and large model objects may live anywhere in the 32-bit address space
6534 (the compiler generates @code{seth/add3} instructions to load their
6535 addresses).
6536 @end table
6538 @node MeP Variable Attributes
6539 @subsection MeP Variable Attributes
6541 The MeP target has a number of addressing modes and busses.  The
6542 @code{near} space spans the standard memory space's first 16 megabytes
6543 (24 bits).  The @code{far} space spans the entire 32-bit memory space.
6544 The @code{based} space is a 128-byte region in the memory space that
6545 is addressed relative to the @code{$tp} register.  The @code{tiny}
6546 space is a 65536-byte region relative to the @code{$gp} register.  In
6547 addition to these memory regions, the MeP target has a separate 16-bit
6548 control bus which is specified with @code{cb} attributes.
6550 @table @code
6552 @item based
6553 @cindex @code{based} variable attribute, MeP
6554 Any variable with the @code{based} attribute is assigned to the
6555 @code{.based} section, and is accessed with relative to the
6556 @code{$tp} register.
6558 @item tiny
6559 @cindex @code{tiny} variable attribute, MeP
6560 Likewise, the @code{tiny} attribute assigned variables to the
6561 @code{.tiny} section, relative to the @code{$gp} register.
6563 @item near
6564 @cindex @code{near} variable attribute, MeP
6565 Variables with the @code{near} attribute are assumed to have addresses
6566 that fit in a 24-bit addressing mode.  This is the default for large
6567 variables (@code{-mtiny=4} is the default) but this attribute can
6568 override @code{-mtiny=} for small variables, or override @code{-ml}.
6570 @item far
6571 @cindex @code{far} variable attribute, MeP
6572 Variables with the @code{far} attribute are addressed using a full
6573 32-bit address.  Since this covers the entire memory space, this
6574 allows modules to make no assumptions about where variables might be
6575 stored.
6577 @item io
6578 @cindex @code{io} variable attribute, MeP
6579 @itemx io (@var{addr})
6580 Variables with the @code{io} attribute are used to address
6581 memory-mapped peripherals.  If an address is specified, the variable
6582 is assigned that address, else it is not assigned an address (it is
6583 assumed some other module assigns an address).  Example:
6585 @smallexample
6586 int timer_count __attribute__((io(0x123)));
6587 @end smallexample
6589 @item cb
6590 @itemx cb (@var{addr})
6591 @cindex @code{cb} variable attribute, MeP
6592 Variables with the @code{cb} attribute are used to access the control
6593 bus, using special instructions.  @code{addr} indicates the control bus
6594 address.  Example:
6596 @smallexample
6597 int cpu_clock __attribute__((cb(0x123)));
6598 @end smallexample
6600 @end table
6602 @node Microsoft Windows Variable Attributes
6603 @subsection Microsoft Windows Variable Attributes
6605 You can use these attributes on Microsoft Windows targets.
6606 @ref{x86 Variable Attributes} for additional Windows compatibility
6607 attributes available on all x86 targets.
6609 @table @code
6610 @item dllimport
6611 @itemx dllexport
6612 @cindex @code{dllimport} variable attribute
6613 @cindex @code{dllexport} variable attribute
6614 The @code{dllimport} and @code{dllexport} attributes are described in
6615 @ref{Microsoft Windows Function Attributes}.
6617 @item selectany
6618 @cindex @code{selectany} variable attribute
6619 The @code{selectany} attribute causes an initialized global variable to
6620 have link-once semantics.  When multiple definitions of the variable are
6621 encountered by the linker, the first is selected and the remainder are
6622 discarded.  Following usage by the Microsoft compiler, the linker is told
6623 @emph{not} to warn about size or content differences of the multiple
6624 definitions.
6626 Although the primary usage of this attribute is for POD types, the
6627 attribute can also be applied to global C++ objects that are initialized
6628 by a constructor.  In this case, the static initialization and destruction
6629 code for the object is emitted in each translation defining the object,
6630 but the calls to the constructor and destructor are protected by a
6631 link-once guard variable.
6633 The @code{selectany} attribute is only available on Microsoft Windows
6634 targets.  You can use @code{__declspec (selectany)} as a synonym for
6635 @code{__attribute__ ((selectany))} for compatibility with other
6636 compilers.
6638 @item shared
6639 @cindex @code{shared} variable attribute
6640 On Microsoft Windows, in addition to putting variable definitions in a named
6641 section, the section can also be shared among all running copies of an
6642 executable or DLL@.  For example, this small program defines shared data
6643 by putting it in a named section @code{shared} and marking the section
6644 shareable:
6646 @smallexample
6647 int foo __attribute__((section ("shared"), shared)) = 0;
6650 main()
6652   /* @r{Read and write foo.  All running
6653      copies see the same value.}  */
6654   return 0;
6656 @end smallexample
6658 @noindent
6659 You may only use the @code{shared} attribute along with @code{section}
6660 attribute with a fully-initialized global definition because of the way
6661 linkers work.  See @code{section} attribute for more information.
6663 The @code{shared} attribute is only available on Microsoft Windows@.
6665 @end table
6667 @node MSP430 Variable Attributes
6668 @subsection MSP430 Variable Attributes
6670 @table @code
6671 @item noinit
6672 @cindex @code{noinit} variable attribute, MSP430 
6673 Any data with the @code{noinit} attribute will not be initialised by
6674 the C runtime startup code, or the program loader.  Not initialising
6675 data in this way can reduce program startup times.
6677 @item persistent
6678 @cindex @code{persistent} variable attribute, MSP430 
6679 Any variable with the @code{persistent} attribute will not be
6680 initialised by the C runtime startup code.  Instead its value will be
6681 set once, when the application is loaded, and then never initialised
6682 again, even if the processor is reset or the program restarts.
6683 Persistent data is intended to be placed into FLASH RAM, where its
6684 value will be retained across resets.  The linker script being used to
6685 create the application should ensure that persistent data is correctly
6686 placed.
6688 @item lower
6689 @itemx upper
6690 @itemx either
6691 @cindex @code{lower} variable attribute, MSP430 
6692 @cindex @code{upper} variable attribute, MSP430 
6693 @cindex @code{either} variable attribute, MSP430 
6694 These attributes are the same as the MSP430 function attributes of the
6695 same name (@pxref{MSP430 Function Attributes}).  
6696 These attributes can be applied to both functions and variables.
6697 @end table
6699 @node Nvidia PTX Variable Attributes
6700 @subsection Nvidia PTX Variable Attributes
6702 These variable attributes are supported by the Nvidia PTX back end:
6704 @table @code
6705 @item shared
6706 @cindex @code{shared} attribute, Nvidia PTX
6707 Use this attribute to place a variable in the @code{.shared} memory space.
6708 This memory space is private to each cooperative thread array; only threads
6709 within one thread block refer to the same instance of the variable.
6710 The runtime does not initialize variables in this memory space.
6711 @end table
6713 @node PowerPC Variable Attributes
6714 @subsection PowerPC Variable Attributes
6716 Three attributes currently are defined for PowerPC configurations:
6717 @code{altivec}, @code{ms_struct} and @code{gcc_struct}.
6719 @cindex @code{ms_struct} variable attribute, PowerPC
6720 @cindex @code{gcc_struct} variable attribute, PowerPC
6721 For full documentation of the struct attributes please see the
6722 documentation in @ref{x86 Variable Attributes}.
6724 @cindex @code{altivec} variable attribute, PowerPC
6725 For documentation of @code{altivec} attribute please see the
6726 documentation in @ref{PowerPC Type Attributes}.
6728 @node RL78 Variable Attributes
6729 @subsection RL78 Variable Attributes
6731 @cindex @code{saddr} variable attribute, RL78
6732 The RL78 back end supports the @code{saddr} variable attribute.  This
6733 specifies placement of the corresponding variable in the SADDR area,
6734 which can be accessed more efficiently than the default memory region.
6736 @node SPU Variable Attributes
6737 @subsection SPU Variable Attributes
6739 @cindex @code{spu_vector} variable attribute, SPU
6740 The SPU supports the @code{spu_vector} attribute for variables.  For
6741 documentation of this attribute please see the documentation in
6742 @ref{SPU Type Attributes}.
6744 @node V850 Variable Attributes
6745 @subsection V850 Variable Attributes
6747 These variable attributes are supported by the V850 back end:
6749 @table @code
6751 @item sda
6752 @cindex @code{sda} variable attribute, V850
6753 Use this attribute to explicitly place a variable in the small data area,
6754 which can hold up to 64 kilobytes.
6756 @item tda
6757 @cindex @code{tda} variable attribute, V850
6758 Use this attribute to explicitly place a variable in the tiny data area,
6759 which can hold up to 256 bytes in total.
6761 @item zda
6762 @cindex @code{zda} variable attribute, V850
6763 Use this attribute to explicitly place a variable in the first 32 kilobytes
6764 of memory.
6765 @end table
6767 @node x86 Variable Attributes
6768 @subsection x86 Variable Attributes
6770 Two attributes are currently defined for x86 configurations:
6771 @code{ms_struct} and @code{gcc_struct}.
6773 @table @code
6774 @item ms_struct
6775 @itemx gcc_struct
6776 @cindex @code{ms_struct} variable attribute, x86
6777 @cindex @code{gcc_struct} variable attribute, x86
6779 If @code{packed} is used on a structure, or if bit-fields are used,
6780 it may be that the Microsoft ABI lays out the structure differently
6781 than the way GCC normally does.  Particularly when moving packed
6782 data between functions compiled with GCC and the native Microsoft compiler
6783 (either via function call or as data in a file), it may be necessary to access
6784 either format.
6786 The @code{ms_struct} and @code{gcc_struct} attributes correspond
6787 to the @option{-mms-bitfields} and @option{-mno-ms-bitfields}
6788 command-line options, respectively;
6789 see @ref{x86 Options}, for details of how structure layout is affected.
6790 @xref{x86 Type Attributes}, for information about the corresponding
6791 attributes on types.
6793 @end table
6795 @node Xstormy16 Variable Attributes
6796 @subsection Xstormy16 Variable Attributes
6798 One attribute is currently defined for xstormy16 configurations:
6799 @code{below100}.
6801 @table @code
6802 @item below100
6803 @cindex @code{below100} variable attribute, Xstormy16
6805 If a variable has the @code{below100} attribute (@code{BELOW100} is
6806 allowed also), GCC places the variable in the first 0x100 bytes of
6807 memory and use special opcodes to access it.  Such variables are
6808 placed in either the @code{.bss_below100} section or the
6809 @code{.data_below100} section.
6811 @end table
6813 @node Type Attributes
6814 @section Specifying Attributes of Types
6815 @cindex attribute of types
6816 @cindex type attributes
6818 The keyword @code{__attribute__} allows you to specify special
6819 attributes of types.  Some type attributes apply only to @code{struct}
6820 and @code{union} types, while others can apply to any type defined
6821 via a @code{typedef} declaration.  Other attributes are defined for
6822 functions (@pxref{Function Attributes}), labels (@pxref{Label 
6823 Attributes}), enumerators (@pxref{Enumerator Attributes}), 
6824 statements (@pxref{Statement Attributes}), and for
6825 variables (@pxref{Variable Attributes}).
6827 The @code{__attribute__} keyword is followed by an attribute specification
6828 inside double parentheses.  
6830 You may specify type attributes in an enum, struct or union type
6831 declaration or definition by placing them immediately after the
6832 @code{struct}, @code{union} or @code{enum} keyword.  A less preferred
6833 syntax is to place them just past the closing curly brace of the
6834 definition.
6836 You can also include type attributes in a @code{typedef} declaration.
6837 @xref{Attribute Syntax}, for details of the exact syntax for using
6838 attributes.
6840 @menu
6841 * Common Type Attributes::
6842 * ARC Type Attributes::
6843 * ARM Type Attributes::
6844 * MeP Type Attributes::
6845 * PowerPC Type Attributes::
6846 * SPU Type Attributes::
6847 * x86 Type Attributes::
6848 @end menu
6850 @node Common Type Attributes
6851 @subsection Common Type Attributes
6853 The following type attributes are supported on most targets.
6855 @table @code
6856 @cindex @code{aligned} type attribute
6857 @item aligned (@var{alignment})
6858 This attribute specifies a minimum alignment (in bytes) for variables
6859 of the specified type.  For example, the declarations:
6861 @smallexample
6862 struct S @{ short f[3]; @} __attribute__ ((aligned (8)));
6863 typedef int more_aligned_int __attribute__ ((aligned (8)));
6864 @end smallexample
6866 @noindent
6867 force the compiler to ensure (as far as it can) that each variable whose
6868 type is @code{struct S} or @code{more_aligned_int} is allocated and
6869 aligned @emph{at least} on a 8-byte boundary.  On a SPARC, having all
6870 variables of type @code{struct S} aligned to 8-byte boundaries allows
6871 the compiler to use the @code{ldd} and @code{std} (doubleword load and
6872 store) instructions when copying one variable of type @code{struct S} to
6873 another, thus improving run-time efficiency.
6875 Note that the alignment of any given @code{struct} or @code{union} type
6876 is required by the ISO C standard to be at least a perfect multiple of
6877 the lowest common multiple of the alignments of all of the members of
6878 the @code{struct} or @code{union} in question.  This means that you @emph{can}
6879 effectively adjust the alignment of a @code{struct} or @code{union}
6880 type by attaching an @code{aligned} attribute to any one of the members
6881 of such a type, but the notation illustrated in the example above is a
6882 more obvious, intuitive, and readable way to request the compiler to
6883 adjust the alignment of an entire @code{struct} or @code{union} type.
6885 As in the preceding example, you can explicitly specify the alignment
6886 (in bytes) that you wish the compiler to use for a given @code{struct}
6887 or @code{union} type.  Alternatively, you can leave out the alignment factor
6888 and just ask the compiler to align a type to the maximum
6889 useful alignment for the target machine you are compiling for.  For
6890 example, you could write:
6892 @smallexample
6893 struct S @{ short f[3]; @} __attribute__ ((aligned));
6894 @end smallexample
6896 Whenever you leave out the alignment factor in an @code{aligned}
6897 attribute specification, the compiler automatically sets the alignment
6898 for the type to the largest alignment that is ever used for any data
6899 type on the target machine you are compiling for.  Doing this can often
6900 make copy operations more efficient, because the compiler can use
6901 whatever instructions copy the biggest chunks of memory when performing
6902 copies to or from the variables that have types that you have aligned
6903 this way.
6905 In the example above, if the size of each @code{short} is 2 bytes, then
6906 the size of the entire @code{struct S} type is 6 bytes.  The smallest
6907 power of two that is greater than or equal to that is 8, so the
6908 compiler sets the alignment for the entire @code{struct S} type to 8
6909 bytes.
6911 Note that although you can ask the compiler to select a time-efficient
6912 alignment for a given type and then declare only individual stand-alone
6913 objects of that type, the compiler's ability to select a time-efficient
6914 alignment is primarily useful only when you plan to create arrays of
6915 variables having the relevant (efficiently aligned) type.  If you
6916 declare or use arrays of variables of an efficiently-aligned type, then
6917 it is likely that your program also does pointer arithmetic (or
6918 subscripting, which amounts to the same thing) on pointers to the
6919 relevant type, and the code that the compiler generates for these
6920 pointer arithmetic operations is often more efficient for
6921 efficiently-aligned types than for other types.
6923 Note that the effectiveness of @code{aligned} attributes may be limited
6924 by inherent limitations in your linker.  On many systems, the linker is
6925 only able to arrange for variables to be aligned up to a certain maximum
6926 alignment.  (For some linkers, the maximum supported alignment may
6927 be very very small.)  If your linker is only able to align variables
6928 up to a maximum of 8-byte alignment, then specifying @code{aligned(16)}
6929 in an @code{__attribute__} still only provides you with 8-byte
6930 alignment.  See your linker documentation for further information.
6932 The @code{aligned} attribute can only increase alignment.  Alignment
6933 can be decreased by specifying the @code{packed} attribute.  See below.
6935 @cindex @code{warn_if_not_aligned} type attribute
6936 @item warn_if_not_aligned (@var{alignment})
6937 This attribute specifies a threshold for the structure field, measured
6938 in bytes.  If the structure field is aligned below the threshold, a
6939 warning will be issued.  For example, the declaration:
6941 @smallexample
6942 typedef unsigned long long __u64
6943    __attribute__((aligned(4),warn_if_not_aligned(8)));
6945 struct foo
6947   int i1;
6948   int i2;
6949   __u64 x;
6951 @end smallexample
6953 @noindent
6954 causes the compiler to issue an warning on @code{struct foo}, like
6955 @samp{warning: alignment 4 of 'struct foo' is less than 8}.
6956 It is used to define @code{struct foo} in such a way that
6957 @code{struct foo} has the same layout and the structure field @code{x}
6958 has the same alignment when @code{__u64} is aligned at either 4 or
6959 8 bytes.  Align @code{struct foo} to 8 bytes:
6961 @smallexample
6962 struct foo
6964   int i1;
6965   int i2;
6966   __u64 x;
6967 @} __attribute__((aligned(8)));
6968 @end smallexample
6970 @noindent
6971 silences the warning.  The compiler also issues a warning, like
6972 @samp{warning: 'x' offset 12 in 'struct foo' isn't aligned to 8},
6973 when the structure field has the misaligned offset:
6975 @smallexample
6976 struct foo
6978   int i1;
6979   int i2;
6980   int i3;
6981   __u64 x;
6982 @} __attribute__((aligned(8)));
6983 @end smallexample
6985 This warning can be disabled by @option{-Wno-if-not-aligned}.
6987 @item bnd_variable_size
6988 @cindex @code{bnd_variable_size} type attribute
6989 @cindex Pointer Bounds Checker attributes
6990 When applied to a structure field, this attribute tells Pointer
6991 Bounds Checker that the size of this field should not be computed
6992 using static type information.  It may be used to mark variably-sized
6993 static array fields placed at the end of a structure.
6995 @smallexample
6996 struct S
6998   int size;
6999   char data[1];
7001 S *p = (S *)malloc (sizeof(S) + 100);
7002 p->data[10] = 0; //Bounds violation
7003 @end smallexample
7005 @noindent
7006 By using an attribute for the field we may avoid unwanted bound
7007 violation checks:
7009 @smallexample
7010 struct S
7012   int size;
7013   char data[1] __attribute__((bnd_variable_size));
7015 S *p = (S *)malloc (sizeof(S) + 100);
7016 p->data[10] = 0; //OK
7017 @end smallexample
7019 @item deprecated
7020 @itemx deprecated (@var{msg})
7021 @cindex @code{deprecated} type attribute
7022 The @code{deprecated} attribute results in a warning if the type
7023 is used anywhere in the source file.  This is useful when identifying
7024 types that are expected to be removed in a future version of a program.
7025 If possible, the warning also includes the location of the declaration
7026 of the deprecated type, to enable users to easily find further
7027 information about why the type is deprecated, or what they should do
7028 instead.  Note that the warnings only occur for uses and then only
7029 if the type is being applied to an identifier that itself is not being
7030 declared as deprecated.
7032 @smallexample
7033 typedef int T1 __attribute__ ((deprecated));
7034 T1 x;
7035 typedef T1 T2;
7036 T2 y;
7037 typedef T1 T3 __attribute__ ((deprecated));
7038 T3 z __attribute__ ((deprecated));
7039 @end smallexample
7041 @noindent
7042 results in a warning on line 2 and 3 but not lines 4, 5, or 6.  No
7043 warning is issued for line 4 because T2 is not explicitly
7044 deprecated.  Line 5 has no warning because T3 is explicitly
7045 deprecated.  Similarly for line 6.  The optional @var{msg}
7046 argument, which must be a string, is printed in the warning if
7047 present.
7049 The @code{deprecated} attribute can also be used for functions and
7050 variables (@pxref{Function Attributes}, @pxref{Variable Attributes}.)
7052 @item designated_init
7053 @cindex @code{designated_init} type attribute
7054 This attribute may only be applied to structure types.  It indicates
7055 that any initialization of an object of this type must use designated
7056 initializers rather than positional initializers.  The intent of this
7057 attribute is to allow the programmer to indicate that a structure's
7058 layout may change, and that therefore relying on positional
7059 initialization will result in future breakage.
7061 GCC emits warnings based on this attribute by default; use
7062 @option{-Wno-designated-init} to suppress them.
7064 @item may_alias
7065 @cindex @code{may_alias} type attribute
7066 Accesses through pointers to types with this attribute are not subject
7067 to type-based alias analysis, but are instead assumed to be able to alias
7068 any other type of objects.
7069 In the context of section 6.5 paragraph 7 of the C99 standard,
7070 an lvalue expression
7071 dereferencing such a pointer is treated like having a character type.
7072 See @option{-fstrict-aliasing} for more information on aliasing issues.
7073 This extension exists to support some vector APIs, in which pointers to
7074 one vector type are permitted to alias pointers to a different vector type.
7076 Note that an object of a type with this attribute does not have any
7077 special semantics.
7079 Example of use:
7081 @smallexample
7082 typedef short __attribute__((__may_alias__)) short_a;
7085 main (void)
7087   int a = 0x12345678;
7088   short_a *b = (short_a *) &a;
7090   b[1] = 0;
7092   if (a == 0x12345678)
7093     abort();
7095   exit(0);
7097 @end smallexample
7099 @noindent
7100 If you replaced @code{short_a} with @code{short} in the variable
7101 declaration, the above program would abort when compiled with
7102 @option{-fstrict-aliasing}, which is on by default at @option{-O2} or
7103 above.
7105 @item packed
7106 @cindex @code{packed} type attribute
7107 This attribute, attached to @code{struct} or @code{union} type
7108 definition, specifies that each member (other than zero-width bit-fields)
7109 of the structure or union is placed to minimize the memory required.  When
7110 attached to an @code{enum} definition, it indicates that the smallest
7111 integral type should be used.
7113 @opindex fshort-enums
7114 Specifying the @code{packed} attribute for @code{struct} and @code{union}
7115 types is equivalent to specifying the @code{packed} attribute on each
7116 of the structure or union members.  Specifying the @option{-fshort-enums}
7117 flag on the command line is equivalent to specifying the @code{packed}
7118 attribute on all @code{enum} definitions.
7120 In the following example @code{struct my_packed_struct}'s members are
7121 packed closely together, but the internal layout of its @code{s} member
7122 is not packed---to do that, @code{struct my_unpacked_struct} needs to
7123 be packed too.
7125 @smallexample
7126 struct my_unpacked_struct
7127  @{
7128     char c;
7129     int i;
7130  @};
7132 struct __attribute__ ((__packed__)) my_packed_struct
7133   @{
7134      char c;
7135      int  i;
7136      struct my_unpacked_struct s;
7137   @};
7138 @end smallexample
7140 You may only specify the @code{packed} attribute attribute on the definition
7141 of an @code{enum}, @code{struct} or @code{union}, not on a @code{typedef}
7142 that does not also define the enumerated type, structure or union.
7144 @item scalar_storage_order ("@var{endianness}")
7145 @cindex @code{scalar_storage_order} type attribute
7146 When attached to a @code{union} or a @code{struct}, this attribute sets
7147 the storage order, aka endianness, of the scalar fields of the type, as
7148 well as the array fields whose component is scalar.  The supported
7149 endiannesses are @code{big-endian} and @code{little-endian}.  The attribute
7150 has no effects on fields which are themselves a @code{union}, a @code{struct}
7151 or an array whose component is a @code{union} or a @code{struct}, and it is
7152 possible for these fields to have a different scalar storage order than the
7153 enclosing type.
7155 This attribute is supported only for targets that use a uniform default
7156 scalar storage order (fortunately, most of them), i.e. targets that store
7157 the scalars either all in big-endian or all in little-endian.
7159 Additional restrictions are enforced for types with the reverse scalar
7160 storage order with regard to the scalar storage order of the target:
7162 @itemize
7163 @item Taking the address of a scalar field of a @code{union} or a
7164 @code{struct} with reverse scalar storage order is not permitted and yields
7165 an error.
7166 @item Taking the address of an array field, whose component is scalar, of
7167 a @code{union} or a @code{struct} with reverse scalar storage order is
7168 permitted but yields a warning, unless @option{-Wno-scalar-storage-order}
7169 is specified.
7170 @item Taking the address of a @code{union} or a @code{struct} with reverse
7171 scalar storage order is permitted.
7172 @end itemize
7174 These restrictions exist because the storage order attribute is lost when
7175 the address of a scalar or the address of an array with scalar component is
7176 taken, so storing indirectly through this address generally does not work.
7177 The second case is nevertheless allowed to be able to perform a block copy
7178 from or to the array.
7180 Moreover, the use of type punning or aliasing to toggle the storage order
7181 is not supported; that is to say, a given scalar object cannot be accessed
7182 through distinct types that assign a different storage order to it.
7184 @item transparent_union
7185 @cindex @code{transparent_union} type attribute
7187 This attribute, attached to a @code{union} type definition, indicates
7188 that any function parameter having that union type causes calls to that
7189 function to be treated in a special way.
7191 First, the argument corresponding to a transparent union type can be of
7192 any type in the union; no cast is required.  Also, if the union contains
7193 a pointer type, the corresponding argument can be a null pointer
7194 constant or a void pointer expression; and if the union contains a void
7195 pointer type, the corresponding argument can be any pointer expression.
7196 If the union member type is a pointer, qualifiers like @code{const} on
7197 the referenced type must be respected, just as with normal pointer
7198 conversions.
7200 Second, the argument is passed to the function using the calling
7201 conventions of the first member of the transparent union, not the calling
7202 conventions of the union itself.  All members of the union must have the
7203 same machine representation; this is necessary for this argument passing
7204 to work properly.
7206 Transparent unions are designed for library functions that have multiple
7207 interfaces for compatibility reasons.  For example, suppose the
7208 @code{wait} function must accept either a value of type @code{int *} to
7209 comply with POSIX, or a value of type @code{union wait *} to comply with
7210 the 4.1BSD interface.  If @code{wait}'s parameter were @code{void *},
7211 @code{wait} would accept both kinds of arguments, but it would also
7212 accept any other pointer type and this would make argument type checking
7213 less useful.  Instead, @code{<sys/wait.h>} might define the interface
7214 as follows:
7216 @smallexample
7217 typedef union __attribute__ ((__transparent_union__))
7218   @{
7219     int *__ip;
7220     union wait *__up;
7221   @} wait_status_ptr_t;
7223 pid_t wait (wait_status_ptr_t);
7224 @end smallexample
7226 @noindent
7227 This interface allows either @code{int *} or @code{union wait *}
7228 arguments to be passed, using the @code{int *} calling convention.
7229 The program can call @code{wait} with arguments of either type:
7231 @smallexample
7232 int w1 () @{ int w; return wait (&w); @}
7233 int w2 () @{ union wait w; return wait (&w); @}
7234 @end smallexample
7236 @noindent
7237 With this interface, @code{wait}'s implementation might look like this:
7239 @smallexample
7240 pid_t wait (wait_status_ptr_t p)
7242   return waitpid (-1, p.__ip, 0);
7244 @end smallexample
7246 @item unused
7247 @cindex @code{unused} type attribute
7248 When attached to a type (including a @code{union} or a @code{struct}),
7249 this attribute means that variables of that type are meant to appear
7250 possibly unused.  GCC does not produce a warning for any variables of
7251 that type, even if the variable appears to do nothing.  This is often
7252 the case with lock or thread classes, which are usually defined and then
7253 not referenced, but contain constructors and destructors that have
7254 nontrivial bookkeeping functions.
7256 @item visibility
7257 @cindex @code{visibility} type attribute
7258 In C++, attribute visibility (@pxref{Function Attributes}) can also be
7259 applied to class, struct, union and enum types.  Unlike other type
7260 attributes, the attribute must appear between the initial keyword and
7261 the name of the type; it cannot appear after the body of the type.
7263 Note that the type visibility is applied to vague linkage entities
7264 associated with the class (vtable, typeinfo node, etc.).  In
7265 particular, if a class is thrown as an exception in one shared object
7266 and caught in another, the class must have default visibility.
7267 Otherwise the two shared objects are unable to use the same
7268 typeinfo node and exception handling will break.
7270 @end table
7272 To specify multiple attributes, separate them by commas within the
7273 double parentheses: for example, @samp{__attribute__ ((aligned (16),
7274 packed))}.
7276 @node ARC Type Attributes
7277 @subsection ARC Type Attributes
7279 @cindex @code{uncached} type attribute, ARC
7280 Declaring objects with @code{uncached} allows you to exclude
7281 data-cache participation in load and store operations on those objects
7282 without involving the additional semantic implications of
7283 @code{volatile}.  The @code{.di} instruction suffix is used for all
7284 loads and stores of data declared @code{uncached}.
7286 @node ARM Type Attributes
7287 @subsection ARM Type Attributes
7289 @cindex @code{notshared} type attribute, ARM
7290 On those ARM targets that support @code{dllimport} (such as Symbian
7291 OS), you can use the @code{notshared} attribute to indicate that the
7292 virtual table and other similar data for a class should not be
7293 exported from a DLL@.  For example:
7295 @smallexample
7296 class __declspec(notshared) C @{
7297 public:
7298   __declspec(dllimport) C();
7299   virtual void f();
7302 __declspec(dllexport)
7303 C::C() @{@}
7304 @end smallexample
7306 @noindent
7307 In this code, @code{C::C} is exported from the current DLL, but the
7308 virtual table for @code{C} is not exported.  (You can use
7309 @code{__attribute__} instead of @code{__declspec} if you prefer, but
7310 most Symbian OS code uses @code{__declspec}.)
7312 @node MeP Type Attributes
7313 @subsection MeP Type Attributes
7315 @cindex @code{based} type attribute, MeP
7316 @cindex @code{tiny} type attribute, MeP
7317 @cindex @code{near} type attribute, MeP
7318 @cindex @code{far} type attribute, MeP
7319 Many of the MeP variable attributes may be applied to types as well.
7320 Specifically, the @code{based}, @code{tiny}, @code{near}, and
7321 @code{far} attributes may be applied to either.  The @code{io} and
7322 @code{cb} attributes may not be applied to types.
7324 @node PowerPC Type Attributes
7325 @subsection PowerPC Type Attributes
7327 Three attributes currently are defined for PowerPC configurations:
7328 @code{altivec}, @code{ms_struct} and @code{gcc_struct}.
7330 @cindex @code{ms_struct} type attribute, PowerPC
7331 @cindex @code{gcc_struct} type attribute, PowerPC
7332 For full documentation of the @code{ms_struct} and @code{gcc_struct}
7333 attributes please see the documentation in @ref{x86 Type Attributes}.
7335 @cindex @code{altivec} type attribute, PowerPC
7336 The @code{altivec} attribute allows one to declare AltiVec vector data
7337 types supported by the AltiVec Programming Interface Manual.  The
7338 attribute requires an argument to specify one of three vector types:
7339 @code{vector__}, @code{pixel__} (always followed by unsigned short),
7340 and @code{bool__} (always followed by unsigned).
7342 @smallexample
7343 __attribute__((altivec(vector__)))
7344 __attribute__((altivec(pixel__))) unsigned short
7345 __attribute__((altivec(bool__))) unsigned
7346 @end smallexample
7348 These attributes mainly are intended to support the @code{__vector},
7349 @code{__pixel}, and @code{__bool} AltiVec keywords.
7351 @node SPU Type Attributes
7352 @subsection SPU Type Attributes
7354 @cindex @code{spu_vector} type attribute, SPU
7355 The SPU supports the @code{spu_vector} attribute for types.  This attribute
7356 allows one to declare vector data types supported by the Sony/Toshiba/IBM SPU
7357 Language Extensions Specification.  It is intended to support the
7358 @code{__vector} keyword.
7360 @node x86 Type Attributes
7361 @subsection x86 Type Attributes
7363 Two attributes are currently defined for x86 configurations:
7364 @code{ms_struct} and @code{gcc_struct}.
7366 @table @code
7368 @item ms_struct
7369 @itemx gcc_struct
7370 @cindex @code{ms_struct} type attribute, x86
7371 @cindex @code{gcc_struct} type attribute, x86
7373 If @code{packed} is used on a structure, or if bit-fields are used
7374 it may be that the Microsoft ABI packs them differently
7375 than GCC normally packs them.  Particularly when moving packed
7376 data between functions compiled with GCC and the native Microsoft compiler
7377 (either via function call or as data in a file), it may be necessary to access
7378 either format.
7380 The @code{ms_struct} and @code{gcc_struct} attributes correspond
7381 to the @option{-mms-bitfields} and @option{-mno-ms-bitfields}
7382 command-line options, respectively;
7383 see @ref{x86 Options}, for details of how structure layout is affected.
7384 @xref{x86 Variable Attributes}, for information about the corresponding
7385 attributes on variables.
7387 @end table
7389 @node Label Attributes
7390 @section Label Attributes
7391 @cindex Label Attributes
7393 GCC allows attributes to be set on C labels.  @xref{Attribute Syntax}, for 
7394 details of the exact syntax for using attributes.  Other attributes are 
7395 available for functions (@pxref{Function Attributes}), variables 
7396 (@pxref{Variable Attributes}), enumerators (@pxref{Enumerator Attributes}),
7397 statements (@pxref{Statement Attributes}), and for types
7398 (@pxref{Type Attributes}).
7400 This example uses the @code{cold} label attribute to indicate the 
7401 @code{ErrorHandling} branch is unlikely to be taken and that the
7402 @code{ErrorHandling} label is unused:
7404 @smallexample
7406    asm goto ("some asm" : : : : NoError);
7408 /* This branch (the fall-through from the asm) is less commonly used */
7409 ErrorHandling: 
7410    __attribute__((cold, unused)); /* Semi-colon is required here */
7411    printf("error\n");
7412    return 0;
7414 NoError:
7415    printf("no error\n");
7416    return 1;
7417 @end smallexample
7419 @table @code
7420 @item unused
7421 @cindex @code{unused} label attribute
7422 This feature is intended for program-generated code that may contain 
7423 unused labels, but which is compiled with @option{-Wall}.  It is
7424 not normally appropriate to use in it human-written code, though it
7425 could be useful in cases where the code that jumps to the label is
7426 contained within an @code{#ifdef} conditional.
7428 @item hot
7429 @cindex @code{hot} label attribute
7430 The @code{hot} attribute on a label is used to inform the compiler that
7431 the path following the label is more likely than paths that are not so
7432 annotated.  This attribute is used in cases where @code{__builtin_expect}
7433 cannot be used, for instance with computed goto or @code{asm goto}.
7435 @item cold
7436 @cindex @code{cold} label attribute
7437 The @code{cold} attribute on labels is used to inform the compiler that
7438 the path following the label is unlikely to be executed.  This attribute
7439 is used in cases where @code{__builtin_expect} cannot be used, for instance
7440 with computed goto or @code{asm goto}.
7442 @end table
7444 @node Enumerator Attributes
7445 @section Enumerator Attributes
7446 @cindex Enumerator Attributes
7448 GCC allows attributes to be set on enumerators.  @xref{Attribute Syntax}, for
7449 details of the exact syntax for using attributes.  Other attributes are
7450 available for functions (@pxref{Function Attributes}), variables
7451 (@pxref{Variable Attributes}), labels (@pxref{Label Attributes}), statements
7452 (@pxref{Statement Attributes}), and for types (@pxref{Type Attributes}).
7454 This example uses the @code{deprecated} enumerator attribute to indicate the
7455 @code{oldval} enumerator is deprecated:
7457 @smallexample
7458 enum E @{
7459   oldval __attribute__((deprecated)),
7460   newval
7464 fn (void)
7466   return oldval;
7468 @end smallexample
7470 @table @code
7471 @item deprecated
7472 @cindex @code{deprecated} enumerator attribute
7473 The @code{deprecated} attribute results in a warning if the enumerator
7474 is used anywhere in the source file.  This is useful when identifying
7475 enumerators that are expected to be removed in a future version of a
7476 program.  The warning also includes the location of the declaration
7477 of the deprecated enumerator, to enable users to easily find further
7478 information about why the enumerator is deprecated, or what they should
7479 do instead.  Note that the warnings only occurs for uses.
7481 @end table
7483 @node Statement Attributes
7484 @section Statement Attributes
7485 @cindex Statement Attributes
7487 GCC allows attributes to be set on null statements.  @xref{Attribute Syntax},
7488 for details of the exact syntax for using attributes.  Other attributes are
7489 available for functions (@pxref{Function Attributes}), variables
7490 (@pxref{Variable Attributes}), labels (@pxref{Label Attributes}), enumerators
7491 (@pxref{Enumerator Attributes}), and for types (@pxref{Type Attributes}).
7493 This example uses the @code{fallthrough} statement attribute to indicate that
7494 the @option{-Wimplicit-fallthrough} warning should not be emitted:
7496 @smallexample
7497 switch (cond)
7498   @{
7499   case 1:
7500     bar (1);
7501     __attribute__((fallthrough));
7502   case 2:
7503     @dots{}
7504   @}
7505 @end smallexample
7507 @table @code
7508 @item fallthrough
7509 @cindex @code{fallthrough} statement attribute
7510 The @code{fallthrough} attribute with a null statement serves as a
7511 fallthrough statement.  It hints to the compiler that a statement
7512 that falls through to another case label, or user-defined label
7513 in a switch statement is intentional and thus the
7514 @option{-Wimplicit-fallthrough} warning must not trigger.  The
7515 fallthrough attribute may appear at most once in each attribute
7516 list, and may not be mixed with other attributes.  It can only
7517 be used in a switch statement (the compiler will issue an error
7518 otherwise), after a preceding statement and before a logically
7519 succeeding case label, or user-defined label.
7521 @end table
7523 @node Attribute Syntax
7524 @section Attribute Syntax
7525 @cindex attribute syntax
7527 This section describes the syntax with which @code{__attribute__} may be
7528 used, and the constructs to which attribute specifiers bind, for the C
7529 language.  Some details may vary for C++ and Objective-C@.  Because of
7530 infelicities in the grammar for attributes, some forms described here
7531 may not be successfully parsed in all cases.
7533 There are some problems with the semantics of attributes in C++.  For
7534 example, there are no manglings for attributes, although they may affect
7535 code generation, so problems may arise when attributed types are used in
7536 conjunction with templates or overloading.  Similarly, @code{typeid}
7537 does not distinguish between types with different attributes.  Support
7538 for attributes in C++ may be restricted in future to attributes on
7539 declarations only, but not on nested declarators.
7541 @xref{Function Attributes}, for details of the semantics of attributes
7542 applying to functions.  @xref{Variable Attributes}, for details of the
7543 semantics of attributes applying to variables.  @xref{Type Attributes},
7544 for details of the semantics of attributes applying to structure, union
7545 and enumerated types.
7546 @xref{Label Attributes}, for details of the semantics of attributes 
7547 applying to labels.
7548 @xref{Enumerator Attributes}, for details of the semantics of attributes
7549 applying to enumerators.
7550 @xref{Statement Attributes}, for details of the semantics of attributes
7551 applying to statements.
7553 An @dfn{attribute specifier} is of the form
7554 @code{__attribute__ ((@var{attribute-list}))}.  An @dfn{attribute list}
7555 is a possibly empty comma-separated sequence of @dfn{attributes}, where
7556 each attribute is one of the following:
7558 @itemize @bullet
7559 @item
7560 Empty.  Empty attributes are ignored.
7562 @item
7563 An attribute name
7564 (which may be an identifier such as @code{unused}, or a reserved
7565 word such as @code{const}).
7567 @item
7568 An attribute name followed by a parenthesized list of
7569 parameters for the attribute.
7570 These parameters take one of the following forms:
7572 @itemize @bullet
7573 @item
7574 An identifier.  For example, @code{mode} attributes use this form.
7576 @item
7577 An identifier followed by a comma and a non-empty comma-separated list
7578 of expressions.  For example, @code{format} attributes use this form.
7580 @item
7581 A possibly empty comma-separated list of expressions.  For example,
7582 @code{format_arg} attributes use this form with the list being a single
7583 integer constant expression, and @code{alias} attributes use this form
7584 with the list being a single string constant.
7585 @end itemize
7586 @end itemize
7588 An @dfn{attribute specifier list} is a sequence of one or more attribute
7589 specifiers, not separated by any other tokens.
7591 You may optionally specify attribute names with @samp{__}
7592 preceding and following the name.
7593 This allows you to use them in header files without
7594 being concerned about a possible macro of the same name.  For example,
7595 you may use the attribute name @code{__noreturn__} instead of @code{noreturn}.
7598 @subsubheading Label Attributes
7600 In GNU C, an attribute specifier list may appear after the colon following a
7601 label, other than a @code{case} or @code{default} label.  GNU C++ only permits
7602 attributes on labels if the attribute specifier is immediately
7603 followed by a semicolon (i.e., the label applies to an empty
7604 statement).  If the semicolon is missing, C++ label attributes are
7605 ambiguous, as it is permissible for a declaration, which could begin
7606 with an attribute list, to be labelled in C++.  Declarations cannot be
7607 labelled in C90 or C99, so the ambiguity does not arise there.
7609 @subsubheading Enumerator Attributes
7611 In GNU C, an attribute specifier list may appear as part of an enumerator.
7612 The attribute goes after the enumeration constant, before @code{=}, if
7613 present.  The optional attribute in the enumerator appertains to the
7614 enumeration constant.  It is not possible to place the attribute after
7615 the constant expression, if present.
7617 @subsubheading Statement Attributes
7618 In GNU C, an attribute specifier list may appear as part of a null
7619 statement.  The attribute goes before the semicolon.
7621 @subsubheading Type Attributes
7623 An attribute specifier list may appear as part of a @code{struct},
7624 @code{union} or @code{enum} specifier.  It may go either immediately
7625 after the @code{struct}, @code{union} or @code{enum} keyword, or after
7626 the closing brace.  The former syntax is preferred.
7627 Where attribute specifiers follow the closing brace, they are considered
7628 to relate to the structure, union or enumerated type defined, not to any
7629 enclosing declaration the type specifier appears in, and the type
7630 defined is not complete until after the attribute specifiers.
7631 @c Otherwise, there would be the following problems: a shift/reduce
7632 @c conflict between attributes binding the struct/union/enum and
7633 @c binding to the list of specifiers/qualifiers; and "aligned"
7634 @c attributes could use sizeof for the structure, but the size could be
7635 @c changed later by "packed" attributes.
7638 @subsubheading All other attributes
7640 Otherwise, an attribute specifier appears as part of a declaration,
7641 counting declarations of unnamed parameters and type names, and relates
7642 to that declaration (which may be nested in another declaration, for
7643 example in the case of a parameter declaration), or to a particular declarator
7644 within a declaration.  Where an
7645 attribute specifier is applied to a parameter declared as a function or
7646 an array, it should apply to the function or array rather than the
7647 pointer to which the parameter is implicitly converted, but this is not
7648 yet correctly implemented.
7650 Any list of specifiers and qualifiers at the start of a declaration may
7651 contain attribute specifiers, whether or not such a list may in that
7652 context contain storage class specifiers.  (Some attributes, however,
7653 are essentially in the nature of storage class specifiers, and only make
7654 sense where storage class specifiers may be used; for example,
7655 @code{section}.)  There is one necessary limitation to this syntax: the
7656 first old-style parameter declaration in a function definition cannot
7657 begin with an attribute specifier, because such an attribute applies to
7658 the function instead by syntax described below (which, however, is not
7659 yet implemented in this case).  In some other cases, attribute
7660 specifiers are permitted by this grammar but not yet supported by the
7661 compiler.  All attribute specifiers in this place relate to the
7662 declaration as a whole.  In the obsolescent usage where a type of
7663 @code{int} is implied by the absence of type specifiers, such a list of
7664 specifiers and qualifiers may be an attribute specifier list with no
7665 other specifiers or qualifiers.
7667 At present, the first parameter in a function prototype must have some
7668 type specifier that is not an attribute specifier; this resolves an
7669 ambiguity in the interpretation of @code{void f(int
7670 (__attribute__((foo)) x))}, but is subject to change.  At present, if
7671 the parentheses of a function declarator contain only attributes then
7672 those attributes are ignored, rather than yielding an error or warning
7673 or implying a single parameter of type int, but this is subject to
7674 change.
7676 An attribute specifier list may appear immediately before a declarator
7677 (other than the first) in a comma-separated list of declarators in a
7678 declaration of more than one identifier using a single list of
7679 specifiers and qualifiers.  Such attribute specifiers apply
7680 only to the identifier before whose declarator they appear.  For
7681 example, in
7683 @smallexample
7684 __attribute__((noreturn)) void d0 (void),
7685     __attribute__((format(printf, 1, 2))) d1 (const char *, ...),
7686      d2 (void);
7687 @end smallexample
7689 @noindent
7690 the @code{noreturn} attribute applies to all the functions
7691 declared; the @code{format} attribute only applies to @code{d1}.
7693 An attribute specifier list may appear immediately before the comma,
7694 @code{=} or semicolon terminating the declaration of an identifier other
7695 than a function definition.  Such attribute specifiers apply
7696 to the declared object or function.  Where an
7697 assembler name for an object or function is specified (@pxref{Asm
7698 Labels}), the attribute must follow the @code{asm}
7699 specification.
7701 An attribute specifier list may, in future, be permitted to appear after
7702 the declarator in a function definition (before any old-style parameter
7703 declarations or the function body).
7705 Attribute specifiers may be mixed with type qualifiers appearing inside
7706 the @code{[]} of a parameter array declarator, in the C99 construct by
7707 which such qualifiers are applied to the pointer to which the array is
7708 implicitly converted.  Such attribute specifiers apply to the pointer,
7709 not to the array, but at present this is not implemented and they are
7710 ignored.
7712 An attribute specifier list may appear at the start of a nested
7713 declarator.  At present, there are some limitations in this usage: the
7714 attributes correctly apply to the declarator, but for most individual
7715 attributes the semantics this implies are not implemented.
7716 When attribute specifiers follow the @code{*} of a pointer
7717 declarator, they may be mixed with any type qualifiers present.
7718 The following describes the formal semantics of this syntax.  It makes the
7719 most sense if you are familiar with the formal specification of
7720 declarators in the ISO C standard.
7722 Consider (as in C99 subclause 6.7.5 paragraph 4) a declaration @code{T
7723 D1}, where @code{T} contains declaration specifiers that specify a type
7724 @var{Type} (such as @code{int}) and @code{D1} is a declarator that
7725 contains an identifier @var{ident}.  The type specified for @var{ident}
7726 for derived declarators whose type does not include an attribute
7727 specifier is as in the ISO C standard.
7729 If @code{D1} has the form @code{( @var{attribute-specifier-list} D )},
7730 and the declaration @code{T D} specifies the type
7731 ``@var{derived-declarator-type-list} @var{Type}'' for @var{ident}, then
7732 @code{T D1} specifies the type ``@var{derived-declarator-type-list}
7733 @var{attribute-specifier-list} @var{Type}'' for @var{ident}.
7735 If @code{D1} has the form @code{*
7736 @var{type-qualifier-and-attribute-specifier-list} D}, and the
7737 declaration @code{T D} specifies the type
7738 ``@var{derived-declarator-type-list} @var{Type}'' for @var{ident}, then
7739 @code{T D1} specifies the type ``@var{derived-declarator-type-list}
7740 @var{type-qualifier-and-attribute-specifier-list} pointer to @var{Type}'' for
7741 @var{ident}.
7743 For example,
7745 @smallexample
7746 void (__attribute__((noreturn)) ****f) (void);
7747 @end smallexample
7749 @noindent
7750 specifies the type ``pointer to pointer to pointer to pointer to
7751 non-returning function returning @code{void}''.  As another example,
7753 @smallexample
7754 char *__attribute__((aligned(8))) *f;
7755 @end smallexample
7757 @noindent
7758 specifies the type ``pointer to 8-byte-aligned pointer to @code{char}''.
7759 Note again that this does not work with most attributes; for example,
7760 the usage of @samp{aligned} and @samp{noreturn} attributes given above
7761 is not yet supported.
7763 For compatibility with existing code written for compiler versions that
7764 did not implement attributes on nested declarators, some laxity is
7765 allowed in the placing of attributes.  If an attribute that only applies
7766 to types is applied to a declaration, it is treated as applying to
7767 the type of that declaration.  If an attribute that only applies to
7768 declarations is applied to the type of a declaration, it is treated
7769 as applying to that declaration; and, for compatibility with code
7770 placing the attributes immediately before the identifier declared, such
7771 an attribute applied to a function return type is treated as
7772 applying to the function type, and such an attribute applied to an array
7773 element type is treated as applying to the array type.  If an
7774 attribute that only applies to function types is applied to a
7775 pointer-to-function type, it is treated as applying to the pointer
7776 target type; if such an attribute is applied to a function return type
7777 that is not a pointer-to-function type, it is treated as applying
7778 to the function type.
7780 @node Function Prototypes
7781 @section Prototypes and Old-Style Function Definitions
7782 @cindex function prototype declarations
7783 @cindex old-style function definitions
7784 @cindex promotion of formal parameters
7786 GNU C extends ISO C to allow a function prototype to override a later
7787 old-style non-prototype definition.  Consider the following example:
7789 @smallexample
7790 /* @r{Use prototypes unless the compiler is old-fashioned.}  */
7791 #ifdef __STDC__
7792 #define P(x) x
7793 #else
7794 #define P(x) ()
7795 #endif
7797 /* @r{Prototype function declaration.}  */
7798 int isroot P((uid_t));
7800 /* @r{Old-style function definition.}  */
7802 isroot (x)   /* @r{??? lossage here ???} */
7803      uid_t x;
7805   return x == 0;
7807 @end smallexample
7809 Suppose the type @code{uid_t} happens to be @code{short}.  ISO C does
7810 not allow this example, because subword arguments in old-style
7811 non-prototype definitions are promoted.  Therefore in this example the
7812 function definition's argument is really an @code{int}, which does not
7813 match the prototype argument type of @code{short}.
7815 This restriction of ISO C makes it hard to write code that is portable
7816 to traditional C compilers, because the programmer does not know
7817 whether the @code{uid_t} type is @code{short}, @code{int}, or
7818 @code{long}.  Therefore, in cases like these GNU C allows a prototype
7819 to override a later old-style definition.  More precisely, in GNU C, a
7820 function prototype argument type overrides the argument type specified
7821 by a later old-style definition if the former type is the same as the
7822 latter type before promotion.  Thus in GNU C the above example is
7823 equivalent to the following:
7825 @smallexample
7826 int isroot (uid_t);
7829 isroot (uid_t x)
7831   return x == 0;
7833 @end smallexample
7835 @noindent
7836 GNU C++ does not support old-style function definitions, so this
7837 extension is irrelevant.
7839 @node C++ Comments
7840 @section C++ Style Comments
7841 @cindex @code{//}
7842 @cindex C++ comments
7843 @cindex comments, C++ style
7845 In GNU C, you may use C++ style comments, which start with @samp{//} and
7846 continue until the end of the line.  Many other C implementations allow
7847 such comments, and they are included in the 1999 C standard.  However,
7848 C++ style comments are not recognized if you specify an @option{-std}
7849 option specifying a version of ISO C before C99, or @option{-ansi}
7850 (equivalent to @option{-std=c90}).
7852 @node Dollar Signs
7853 @section Dollar Signs in Identifier Names
7854 @cindex $
7855 @cindex dollar signs in identifier names
7856 @cindex identifier names, dollar signs in
7858 In GNU C, you may normally use dollar signs in identifier names.
7859 This is because many traditional C implementations allow such identifiers.
7860 However, dollar signs in identifiers are not supported on a few target
7861 machines, typically because the target assembler does not allow them.
7863 @node Character Escapes
7864 @section The Character @key{ESC} in Constants
7866 You can use the sequence @samp{\e} in a string or character constant to
7867 stand for the ASCII character @key{ESC}.
7869 @node Alignment
7870 @section Inquiring on Alignment of Types or Variables
7871 @cindex alignment
7872 @cindex type alignment
7873 @cindex variable alignment
7875 The keyword @code{__alignof__} allows you to inquire about how an object
7876 is aligned, or the minimum alignment usually required by a type.  Its
7877 syntax is just like @code{sizeof}.
7879 For example, if the target machine requires a @code{double} value to be
7880 aligned on an 8-byte boundary, then @code{__alignof__ (double)} is 8.
7881 This is true on many RISC machines.  On more traditional machine
7882 designs, @code{__alignof__ (double)} is 4 or even 2.
7884 Some machines never actually require alignment; they allow reference to any
7885 data type even at an odd address.  For these machines, @code{__alignof__}
7886 reports the smallest alignment that GCC gives the data type, usually as
7887 mandated by the target ABI.
7889 If the operand of @code{__alignof__} is an lvalue rather than a type,
7890 its value is the required alignment for its type, taking into account
7891 any minimum alignment specified with GCC's @code{__attribute__}
7892 extension (@pxref{Variable Attributes}).  For example, after this
7893 declaration:
7895 @smallexample
7896 struct foo @{ int x; char y; @} foo1;
7897 @end smallexample
7899 @noindent
7900 the value of @code{__alignof__ (foo1.y)} is 1, even though its actual
7901 alignment is probably 2 or 4, the same as @code{__alignof__ (int)}.
7903 It is an error to ask for the alignment of an incomplete type.
7906 @node Inline
7907 @section An Inline Function is As Fast As a Macro
7908 @cindex inline functions
7909 @cindex integrating function code
7910 @cindex open coding
7911 @cindex macros, inline alternative
7913 By declaring a function inline, you can direct GCC to make
7914 calls to that function faster.  One way GCC can achieve this is to
7915 integrate that function's code into the code for its callers.  This
7916 makes execution faster by eliminating the function-call overhead; in
7917 addition, if any of the actual argument values are constant, their
7918 known values may permit simplifications at compile time so that not
7919 all of the inline function's code needs to be included.  The effect on
7920 code size is less predictable; object code may be larger or smaller
7921 with function inlining, depending on the particular case.  You can
7922 also direct GCC to try to integrate all ``simple enough'' functions
7923 into their callers with the option @option{-finline-functions}.
7925 GCC implements three different semantics of declaring a function
7926 inline.  One is available with @option{-std=gnu89} or
7927 @option{-fgnu89-inline} or when @code{gnu_inline} attribute is present
7928 on all inline declarations, another when
7929 @option{-std=c99},
7930 @option{-std=gnu99} or an option for a later C version is used
7931 (without @option{-fgnu89-inline}), and the third
7932 is used when compiling C++.
7934 To declare a function inline, use the @code{inline} keyword in its
7935 declaration, like this:
7937 @smallexample
7938 static inline int
7939 inc (int *a)
7941   return (*a)++;
7943 @end smallexample
7945 If you are writing a header file to be included in ISO C90 programs, write
7946 @code{__inline__} instead of @code{inline}.  @xref{Alternate Keywords}.
7948 The three types of inlining behave similarly in two important cases:
7949 when the @code{inline} keyword is used on a @code{static} function,
7950 like the example above, and when a function is first declared without
7951 using the @code{inline} keyword and then is defined with
7952 @code{inline}, like this:
7954 @smallexample
7955 extern int inc (int *a);
7956 inline int
7957 inc (int *a)
7959   return (*a)++;
7961 @end smallexample
7963 In both of these common cases, the program behaves the same as if you
7964 had not used the @code{inline} keyword, except for its speed.
7966 @cindex inline functions, omission of
7967 @opindex fkeep-inline-functions
7968 When a function is both inline and @code{static}, if all calls to the
7969 function are integrated into the caller, and the function's address is
7970 never used, then the function's own assembler code is never referenced.
7971 In this case, GCC does not actually output assembler code for the
7972 function, unless you specify the option @option{-fkeep-inline-functions}.
7973 If there is a nonintegrated call, then the function is compiled to
7974 assembler code as usual.  The function must also be compiled as usual if
7975 the program refers to its address, because that cannot be inlined.
7977 @opindex Winline
7978 Note that certain usages in a function definition can make it unsuitable
7979 for inline substitution.  Among these usages are: variadic functions,
7980 use of @code{alloca}, use of computed goto (@pxref{Labels as Values}),
7981 use of nonlocal goto, use of nested functions, use of @code{setjmp}, use
7982 of @code{__builtin_longjmp} and use of @code{__builtin_return} or
7983 @code{__builtin_apply_args}.  Using @option{-Winline} warns when a
7984 function marked @code{inline} could not be substituted, and gives the
7985 reason for the failure.
7987 @cindex automatic @code{inline} for C++ member fns
7988 @cindex @code{inline} automatic for C++ member fns
7989 @cindex member fns, automatically @code{inline}
7990 @cindex C++ member fns, automatically @code{inline}
7991 @opindex fno-default-inline
7992 As required by ISO C++, GCC considers member functions defined within
7993 the body of a class to be marked inline even if they are
7994 not explicitly declared with the @code{inline} keyword.  You can
7995 override this with @option{-fno-default-inline}; @pxref{C++ Dialect
7996 Options,,Options Controlling C++ Dialect}.
7998 GCC does not inline any functions when not optimizing unless you specify
7999 the @samp{always_inline} attribute for the function, like this:
8001 @smallexample
8002 /* @r{Prototype.}  */
8003 inline void foo (const char) __attribute__((always_inline));
8004 @end smallexample
8006 The remainder of this section is specific to GNU C90 inlining.
8008 @cindex non-static inline function
8009 When an inline function is not @code{static}, then the compiler must assume
8010 that there may be calls from other source files; since a global symbol can
8011 be defined only once in any program, the function must not be defined in
8012 the other source files, so the calls therein cannot be integrated.
8013 Therefore, a non-@code{static} inline function is always compiled on its
8014 own in the usual fashion.
8016 If you specify both @code{inline} and @code{extern} in the function
8017 definition, then the definition is used only for inlining.  In no case
8018 is the function compiled on its own, not even if you refer to its
8019 address explicitly.  Such an address becomes an external reference, as
8020 if you had only declared the function, and had not defined it.
8022 This combination of @code{inline} and @code{extern} has almost the
8023 effect of a macro.  The way to use it is to put a function definition in
8024 a header file with these keywords, and put another copy of the
8025 definition (lacking @code{inline} and @code{extern}) in a library file.
8026 The definition in the header file causes most calls to the function
8027 to be inlined.  If any uses of the function remain, they refer to
8028 the single copy in the library.
8030 @node Volatiles
8031 @section When is a Volatile Object Accessed?
8032 @cindex accessing volatiles
8033 @cindex volatile read
8034 @cindex volatile write
8035 @cindex volatile access
8037 C has the concept of volatile objects.  These are normally accessed by
8038 pointers and used for accessing hardware or inter-thread
8039 communication.  The standard encourages compilers to refrain from
8040 optimizations concerning accesses to volatile objects, but leaves it
8041 implementation defined as to what constitutes a volatile access.  The
8042 minimum requirement is that at a sequence point all previous accesses
8043 to volatile objects have stabilized and no subsequent accesses have
8044 occurred.  Thus an implementation is free to reorder and combine
8045 volatile accesses that occur between sequence points, but cannot do
8046 so for accesses across a sequence point.  The use of volatile does
8047 not allow you to violate the restriction on updating objects multiple
8048 times between two sequence points.
8050 Accesses to non-volatile objects are not ordered with respect to
8051 volatile accesses.  You cannot use a volatile object as a memory
8052 barrier to order a sequence of writes to non-volatile memory.  For
8053 instance:
8055 @smallexample
8056 int *ptr = @var{something};
8057 volatile int vobj;
8058 *ptr = @var{something};
8059 vobj = 1;
8060 @end smallexample
8062 @noindent
8063 Unless @var{*ptr} and @var{vobj} can be aliased, it is not guaranteed
8064 that the write to @var{*ptr} occurs by the time the update
8065 of @var{vobj} happens.  If you need this guarantee, you must use
8066 a stronger memory barrier such as:
8068 @smallexample
8069 int *ptr = @var{something};
8070 volatile int vobj;
8071 *ptr = @var{something};
8072 asm volatile ("" : : : "memory");
8073 vobj = 1;
8074 @end smallexample
8076 A scalar volatile object is read when it is accessed in a void context:
8078 @smallexample
8079 volatile int *src = @var{somevalue};
8080 *src;
8081 @end smallexample
8083 Such expressions are rvalues, and GCC implements this as a
8084 read of the volatile object being pointed to.
8086 Assignments are also expressions and have an rvalue.  However when
8087 assigning to a scalar volatile, the volatile object is not reread,
8088 regardless of whether the assignment expression's rvalue is used or
8089 not.  If the assignment's rvalue is used, the value is that assigned
8090 to the volatile object.  For instance, there is no read of @var{vobj}
8091 in all the following cases:
8093 @smallexample
8094 int obj;
8095 volatile int vobj;
8096 vobj = @var{something};
8097 obj = vobj = @var{something};
8098 obj ? vobj = @var{onething} : vobj = @var{anotherthing};
8099 obj = (@var{something}, vobj = @var{anotherthing});
8100 @end smallexample
8102 If you need to read the volatile object after an assignment has
8103 occurred, you must use a separate expression with an intervening
8104 sequence point.
8106 As bit-fields are not individually addressable, volatile bit-fields may
8107 be implicitly read when written to, or when adjacent bit-fields are
8108 accessed.  Bit-field operations may be optimized such that adjacent
8109 bit-fields are only partially accessed, if they straddle a storage unit
8110 boundary.  For these reasons it is unwise to use volatile bit-fields to
8111 access hardware.
8113 @node Using Assembly Language with C
8114 @section How to Use Inline Assembly Language in C Code
8115 @cindex @code{asm} keyword
8116 @cindex assembly language in C
8117 @cindex inline assembly language
8118 @cindex mixing assembly language and C
8120 The @code{asm} keyword allows you to embed assembler instructions
8121 within C code.  GCC provides two forms of inline @code{asm}
8122 statements.  A @dfn{basic @code{asm}} statement is one with no
8123 operands (@pxref{Basic Asm}), while an @dfn{extended @code{asm}}
8124 statement (@pxref{Extended Asm}) includes one or more operands.  
8125 The extended form is preferred for mixing C and assembly language
8126 within a function, but to include assembly language at
8127 top level you must use basic @code{asm}.
8129 You can also use the @code{asm} keyword to override the assembler name
8130 for a C symbol, or to place a C variable in a specific register.
8132 @menu
8133 * Basic Asm::          Inline assembler without operands.
8134 * Extended Asm::       Inline assembler with operands.
8135 * Constraints::        Constraints for @code{asm} operands
8136 * Asm Labels::         Specifying the assembler name to use for a C symbol.
8137 * Explicit Register Variables::  Defining variables residing in specified 
8138                        registers.
8139 * Size of an asm::     How GCC calculates the size of an @code{asm} block.
8140 @end menu
8142 @node Basic Asm
8143 @subsection Basic Asm --- Assembler Instructions Without Operands
8144 @cindex basic @code{asm}
8145 @cindex assembly language in C, basic
8147 A basic @code{asm} statement has the following syntax:
8149 @example
8150 asm @r{[} volatile @r{]} ( @var{AssemblerInstructions} )
8151 @end example
8153 The @code{asm} keyword is a GNU extension.
8154 When writing code that can be compiled with @option{-ansi} and the
8155 various @option{-std} options, use @code{__asm__} instead of 
8156 @code{asm} (@pxref{Alternate Keywords}).
8158 @subsubheading Qualifiers
8159 @table @code
8160 @item volatile
8161 The optional @code{volatile} qualifier has no effect. 
8162 All basic @code{asm} blocks are implicitly volatile.
8163 @end table
8165 @subsubheading Parameters
8166 @table @var
8168 @item AssemblerInstructions
8169 This is a literal string that specifies the assembler code. The string can 
8170 contain any instructions recognized by the assembler, including directives. 
8171 GCC does not parse the assembler instructions themselves and 
8172 does not know what they mean or even whether they are valid assembler input. 
8174 You may place multiple assembler instructions together in a single @code{asm} 
8175 string, separated by the characters normally used in assembly code for the 
8176 system. A combination that works in most places is a newline to break the 
8177 line, plus a tab character (written as @samp{\n\t}).
8178 Some assemblers allow semicolons as a line separator. However, 
8179 note that some assembler dialects use semicolons to start a comment. 
8180 @end table
8182 @subsubheading Remarks
8183 Using extended @code{asm} (@pxref{Extended Asm}) typically produces
8184 smaller, safer, and more efficient code, and in most cases it is a
8185 better solution than basic @code{asm}.  However, there are two
8186 situations where only basic @code{asm} can be used:
8188 @itemize @bullet
8189 @item
8190 Extended @code{asm} statements have to be inside a C
8191 function, so to write inline assembly language at file scope (``top-level''),
8192 outside of C functions, you must use basic @code{asm}.
8193 You can use this technique to emit assembler directives,
8194 define assembly language macros that can be invoked elsewhere in the file,
8195 or write entire functions in assembly language.
8197 @item
8198 Functions declared
8199 with the @code{naked} attribute also require basic @code{asm}
8200 (@pxref{Function Attributes}).
8201 @end itemize
8203 Safely accessing C data and calling functions from basic @code{asm} is more 
8204 complex than it may appear. To access C data, it is better to use extended 
8205 @code{asm}.
8207 Do not expect a sequence of @code{asm} statements to remain perfectly 
8208 consecutive after compilation. If certain instructions need to remain 
8209 consecutive in the output, put them in a single multi-instruction @code{asm}
8210 statement. Note that GCC's optimizers can move @code{asm} statements 
8211 relative to other code, including across jumps.
8213 @code{asm} statements may not perform jumps into other @code{asm} statements. 
8214 GCC does not know about these jumps, and therefore cannot take 
8215 account of them when deciding how to optimize. Jumps from @code{asm} to C 
8216 labels are only supported in extended @code{asm}.
8218 Under certain circumstances, GCC may duplicate (or remove duplicates of) your 
8219 assembly code when optimizing. This can lead to unexpected duplicate 
8220 symbol errors during compilation if your assembly code defines symbols or 
8221 labels.
8223 @strong{Warning:} The C standards do not specify semantics for @code{asm},
8224 making it a potential source of incompatibilities between compilers.  These
8225 incompatibilities may not produce compiler warnings/errors.
8227 GCC does not parse basic @code{asm}'s @var{AssemblerInstructions}, which
8228 means there is no way to communicate to the compiler what is happening
8229 inside them.  GCC has no visibility of symbols in the @code{asm} and may
8230 discard them as unreferenced.  It also does not know about side effects of
8231 the assembler code, such as modifications to memory or registers.  Unlike
8232 some compilers, GCC assumes that no changes to general purpose registers
8233 occur.  This assumption may change in a future release.
8235 To avoid complications from future changes to the semantics and the
8236 compatibility issues between compilers, consider replacing basic @code{asm}
8237 with extended @code{asm}.  See
8238 @uref{https://gcc.gnu.org/wiki/ConvertBasicAsmToExtended, How to convert
8239 from basic asm to extended asm} for information about how to perform this
8240 conversion.
8242 The compiler copies the assembler instructions in a basic @code{asm} 
8243 verbatim to the assembly language output file, without 
8244 processing dialects or any of the @samp{%} operators that are available with
8245 extended @code{asm}. This results in minor differences between basic 
8246 @code{asm} strings and extended @code{asm} templates. For example, to refer to 
8247 registers you might use @samp{%eax} in basic @code{asm} and
8248 @samp{%%eax} in extended @code{asm}.
8250 On targets such as x86 that support multiple assembler dialects,
8251 all basic @code{asm} blocks use the assembler dialect specified by the 
8252 @option{-masm} command-line option (@pxref{x86 Options}).  
8253 Basic @code{asm} provides no
8254 mechanism to provide different assembler strings for different dialects.
8256 For basic @code{asm} with non-empty assembler string GCC assumes
8257 the assembler block does not change any general purpose registers,
8258 but it may read or write any globally accessible variable.
8260 Here is an example of basic @code{asm} for i386:
8262 @example
8263 /* Note that this code will not compile with -masm=intel */
8264 #define DebugBreak() asm("int $3")
8265 @end example
8267 @node Extended Asm
8268 @subsection Extended Asm - Assembler Instructions with C Expression Operands
8269 @cindex extended @code{asm}
8270 @cindex assembly language in C, extended
8272 With extended @code{asm} you can read and write C variables from 
8273 assembler and perform jumps from assembler code to C labels.  
8274 Extended @code{asm} syntax uses colons (@samp{:}) to delimit
8275 the operand parameters after the assembler template:
8277 @example
8278 asm @r{[}volatile@r{]} ( @var{AssemblerTemplate} 
8279                  : @var{OutputOperands} 
8280                  @r{[} : @var{InputOperands}
8281                  @r{[} : @var{Clobbers} @r{]} @r{]})
8283 asm @r{[}volatile@r{]} goto ( @var{AssemblerTemplate} 
8284                       : 
8285                       : @var{InputOperands}
8286                       : @var{Clobbers}
8287                       : @var{GotoLabels})
8288 @end example
8290 The @code{asm} keyword is a GNU extension.
8291 When writing code that can be compiled with @option{-ansi} and the
8292 various @option{-std} options, use @code{__asm__} instead of 
8293 @code{asm} (@pxref{Alternate Keywords}).
8295 @subsubheading Qualifiers
8296 @table @code
8298 @item volatile
8299 The typical use of extended @code{asm} statements is to manipulate input 
8300 values to produce output values. However, your @code{asm} statements may 
8301 also produce side effects. If so, you may need to use the @code{volatile} 
8302 qualifier to disable certain optimizations. @xref{Volatile}.
8304 @item goto
8305 This qualifier informs the compiler that the @code{asm} statement may 
8306 perform a jump to one of the labels listed in the @var{GotoLabels}.
8307 @xref{GotoLabels}.
8308 @end table
8310 @subsubheading Parameters
8311 @table @var
8312 @item AssemblerTemplate
8313 This is a literal string that is the template for the assembler code. It is a 
8314 combination of fixed text and tokens that refer to the input, output, 
8315 and goto parameters. @xref{AssemblerTemplate}.
8317 @item OutputOperands
8318 A comma-separated list of the C variables modified by the instructions in the 
8319 @var{AssemblerTemplate}.  An empty list is permitted.  @xref{OutputOperands}.
8321 @item InputOperands
8322 A comma-separated list of C expressions read by the instructions in the 
8323 @var{AssemblerTemplate}.  An empty list is permitted.  @xref{InputOperands}.
8325 @item Clobbers
8326 A comma-separated list of registers or other values changed by the 
8327 @var{AssemblerTemplate}, beyond those listed as outputs.
8328 An empty list is permitted.  @xref{Clobbers and Scratch Registers}.
8330 @item GotoLabels
8331 When you are using the @code{goto} form of @code{asm}, this section contains 
8332 the list of all C labels to which the code in the 
8333 @var{AssemblerTemplate} may jump. 
8334 @xref{GotoLabels}.
8336 @code{asm} statements may not perform jumps into other @code{asm} statements,
8337 only to the listed @var{GotoLabels}.
8338 GCC's optimizers do not know about other jumps; therefore they cannot take 
8339 account of them when deciding how to optimize.
8340 @end table
8342 The total number of input + output + goto operands is limited to 30.
8344 @subsubheading Remarks
8345 The @code{asm} statement allows you to include assembly instructions directly 
8346 within C code. This may help you to maximize performance in time-sensitive 
8347 code or to access assembly instructions that are not readily available to C 
8348 programs.
8350 Note that extended @code{asm} statements must be inside a function. Only 
8351 basic @code{asm} may be outside functions (@pxref{Basic Asm}).
8352 Functions declared with the @code{naked} attribute also require basic 
8353 @code{asm} (@pxref{Function Attributes}).
8355 While the uses of @code{asm} are many and varied, it may help to think of an 
8356 @code{asm} statement as a series of low-level instructions that convert input 
8357 parameters to output parameters. So a simple (if not particularly useful) 
8358 example for i386 using @code{asm} might look like this:
8360 @example
8361 int src = 1;
8362 int dst;   
8364 asm ("mov %1, %0\n\t"
8365     "add $1, %0"
8366     : "=r" (dst) 
8367     : "r" (src));
8369 printf("%d\n", dst);
8370 @end example
8372 This code copies @code{src} to @code{dst} and add 1 to @code{dst}.
8374 @anchor{Volatile}
8375 @subsubsection Volatile
8376 @cindex volatile @code{asm}
8377 @cindex @code{asm} volatile
8379 GCC's optimizers sometimes discard @code{asm} statements if they determine 
8380 there is no need for the output variables. Also, the optimizers may move 
8381 code out of loops if they believe that the code will always return the same 
8382 result (i.e. none of its input values change between calls). Using the 
8383 @code{volatile} qualifier disables these optimizations. @code{asm} statements 
8384 that have no output operands, including @code{asm goto} statements, 
8385 are implicitly volatile.
8387 This i386 code demonstrates a case that does not use (or require) the 
8388 @code{volatile} qualifier. If it is performing assertion checking, this code 
8389 uses @code{asm} to perform the validation. Otherwise, @code{dwRes} is 
8390 unreferenced by any code. As a result, the optimizers can discard the 
8391 @code{asm} statement, which in turn removes the need for the entire 
8392 @code{DoCheck} routine. By omitting the @code{volatile} qualifier when it 
8393 isn't needed you allow the optimizers to produce the most efficient code 
8394 possible.
8396 @example
8397 void DoCheck(uint32_t dwSomeValue)
8399    uint32_t dwRes;
8401    // Assumes dwSomeValue is not zero.
8402    asm ("bsfl %1,%0"
8403      : "=r" (dwRes)
8404      : "r" (dwSomeValue)
8405      : "cc");
8407    assert(dwRes > 3);
8409 @end example
8411 The next example shows a case where the optimizers can recognize that the input 
8412 (@code{dwSomeValue}) never changes during the execution of the function and can 
8413 therefore move the @code{asm} outside the loop to produce more efficient code. 
8414 Again, using @code{volatile} disables this type of optimization.
8416 @example
8417 void do_print(uint32_t dwSomeValue)
8419    uint32_t dwRes;
8421    for (uint32_t x=0; x < 5; x++)
8422    @{
8423       // Assumes dwSomeValue is not zero.
8424       asm ("bsfl %1,%0"
8425         : "=r" (dwRes)
8426         : "r" (dwSomeValue)
8427         : "cc");
8429       printf("%u: %u %u\n", x, dwSomeValue, dwRes);
8430    @}
8432 @end example
8434 The following example demonstrates a case where you need to use the 
8435 @code{volatile} qualifier. 
8436 It uses the x86 @code{rdtsc} instruction, which reads 
8437 the computer's time-stamp counter. Without the @code{volatile} qualifier, 
8438 the optimizers might assume that the @code{asm} block will always return the 
8439 same value and therefore optimize away the second call.
8441 @example
8442 uint64_t msr;
8444 asm volatile ( "rdtsc\n\t"    // Returns the time in EDX:EAX.
8445         "shl $32, %%rdx\n\t"  // Shift the upper bits left.
8446         "or %%rdx, %0"        // 'Or' in the lower bits.
8447         : "=a" (msr)
8448         : 
8449         : "rdx");
8451 printf("msr: %llx\n", msr);
8453 // Do other work...
8455 // Reprint the timestamp
8456 asm volatile ( "rdtsc\n\t"    // Returns the time in EDX:EAX.
8457         "shl $32, %%rdx\n\t"  // Shift the upper bits left.
8458         "or %%rdx, %0"        // 'Or' in the lower bits.
8459         : "=a" (msr)
8460         : 
8461         : "rdx");
8463 printf("msr: %llx\n", msr);
8464 @end example
8466 GCC's optimizers do not treat this code like the non-volatile code in the 
8467 earlier examples. They do not move it out of loops or omit it on the 
8468 assumption that the result from a previous call is still valid.
8470 Note that the compiler can move even volatile @code{asm} instructions relative 
8471 to other code, including across jump instructions. For example, on many 
8472 targets there is a system register that controls the rounding mode of 
8473 floating-point operations. Setting it with a volatile @code{asm}, as in the 
8474 following PowerPC example, does not work reliably.
8476 @example
8477 asm volatile("mtfsf 255, %0" : : "f" (fpenv));
8478 sum = x + y;
8479 @end example
8481 The compiler may move the addition back before the volatile @code{asm}. To 
8482 make it work as expected, add an artificial dependency to the @code{asm} by 
8483 referencing a variable in the subsequent code, for example: 
8485 @example
8486 asm volatile ("mtfsf 255,%1" : "=X" (sum) : "f" (fpenv));
8487 sum = x + y;
8488 @end example
8490 Under certain circumstances, GCC may duplicate (or remove duplicates of) your 
8491 assembly code when optimizing. This can lead to unexpected duplicate symbol 
8492 errors during compilation if your asm code defines symbols or labels. 
8493 Using @samp{%=} 
8494 (@pxref{AssemblerTemplate}) may help resolve this problem.
8496 @anchor{AssemblerTemplate}
8497 @subsubsection Assembler Template
8498 @cindex @code{asm} assembler template
8500 An assembler template is a literal string containing assembler instructions.
8501 The compiler replaces tokens in the template that refer 
8502 to inputs, outputs, and goto labels,
8503 and then outputs the resulting string to the assembler. The 
8504 string can contain any instructions recognized by the assembler, including 
8505 directives. GCC does not parse the assembler instructions 
8506 themselves and does not know what they mean or even whether they are valid 
8507 assembler input. However, it does count the statements 
8508 (@pxref{Size of an asm}).
8510 You may place multiple assembler instructions together in a single @code{asm} 
8511 string, separated by the characters normally used in assembly code for the 
8512 system. A combination that works in most places is a newline to break the 
8513 line, plus a tab character to move to the instruction field (written as 
8514 @samp{\n\t}). 
8515 Some assemblers allow semicolons as a line separator. However, note 
8516 that some assembler dialects use semicolons to start a comment. 
8518 Do not expect a sequence of @code{asm} statements to remain perfectly 
8519 consecutive after compilation, even when you are using the @code{volatile} 
8520 qualifier. If certain instructions need to remain consecutive in the output, 
8521 put them in a single multi-instruction asm statement.
8523 Accessing data from C programs without using input/output operands (such as 
8524 by using global symbols directly from the assembler template) may not work as 
8525 expected. Similarly, calling functions directly from an assembler template 
8526 requires a detailed understanding of the target assembler and ABI.
8528 Since GCC does not parse the assembler template,
8529 it has no visibility of any 
8530 symbols it references. This may result in GCC discarding those symbols as 
8531 unreferenced unless they are also listed as input, output, or goto operands.
8533 @subsubheading Special format strings
8535 In addition to the tokens described by the input, output, and goto operands, 
8536 these tokens have special meanings in the assembler template:
8538 @table @samp
8539 @item %% 
8540 Outputs a single @samp{%} into the assembler code.
8542 @item %= 
8543 Outputs a number that is unique to each instance of the @code{asm} 
8544 statement in the entire compilation. This option is useful when creating local 
8545 labels and referring to them multiple times in a single template that 
8546 generates multiple assembler instructions. 
8548 @item %@{
8549 @itemx %|
8550 @itemx %@}
8551 Outputs @samp{@{}, @samp{|}, and @samp{@}} characters (respectively)
8552 into the assembler code.  When unescaped, these characters have special
8553 meaning to indicate multiple assembler dialects, as described below.
8554 @end table
8556 @subsubheading Multiple assembler dialects in @code{asm} templates
8558 On targets such as x86, GCC supports multiple assembler dialects.
8559 The @option{-masm} option controls which dialect GCC uses as its 
8560 default for inline assembler. The target-specific documentation for the 
8561 @option{-masm} option contains the list of supported dialects, as well as the 
8562 default dialect if the option is not specified. This information may be 
8563 important to understand, since assembler code that works correctly when 
8564 compiled using one dialect will likely fail if compiled using another.
8565 @xref{x86 Options}.
8567 If your code needs to support multiple assembler dialects (for example, if 
8568 you are writing public headers that need to support a variety of compilation 
8569 options), use constructs of this form:
8571 @example
8572 @{ dialect0 | dialect1 | dialect2... @}
8573 @end example
8575 This construct outputs @code{dialect0} 
8576 when using dialect #0 to compile the code, 
8577 @code{dialect1} for dialect #1, etc. If there are fewer alternatives within the 
8578 braces than the number of dialects the compiler supports, the construct 
8579 outputs nothing.
8581 For example, if an x86 compiler supports two dialects
8582 (@samp{att}, @samp{intel}), an 
8583 assembler template such as this:
8585 @example
8586 "bt@{l %[Offset],%[Base] | %[Base],%[Offset]@}; jc %l2"
8587 @end example
8589 @noindent
8590 is equivalent to one of
8592 @example
8593 "btl %[Offset],%[Base] ; jc %l2"   @r{/* att dialect */}
8594 "bt %[Base],%[Offset]; jc %l2"     @r{/* intel dialect */}
8595 @end example
8597 Using that same compiler, this code:
8599 @example
8600 "xchg@{l@}\t@{%%@}ebx, %1"
8601 @end example
8603 @noindent
8604 corresponds to either
8606 @example
8607 "xchgl\t%%ebx, %1"                 @r{/* att dialect */}
8608 "xchg\tebx, %1"                    @r{/* intel dialect */}
8609 @end example
8611 There is no support for nesting dialect alternatives.
8613 @anchor{OutputOperands}
8614 @subsubsection Output Operands
8615 @cindex @code{asm} output operands
8617 An @code{asm} statement has zero or more output operands indicating the names
8618 of C variables modified by the assembler code.
8620 In this i386 example, @code{old} (referred to in the template string as 
8621 @code{%0}) and @code{*Base} (as @code{%1}) are outputs and @code{Offset} 
8622 (@code{%2}) is an input:
8624 @example
8625 bool old;
8627 __asm__ ("btsl %2,%1\n\t" // Turn on zero-based bit #Offset in Base.
8628          "sbb %0,%0"      // Use the CF to calculate old.
8629    : "=r" (old), "+rm" (*Base)
8630    : "Ir" (Offset)
8631    : "cc");
8633 return old;
8634 @end example
8636 Operands are separated by commas.  Each operand has this format:
8638 @example
8639 @r{[} [@var{asmSymbolicName}] @r{]} @var{constraint} (@var{cvariablename})
8640 @end example
8642 @table @var
8643 @item asmSymbolicName
8644 Specifies a symbolic name for the operand.
8645 Reference the name in the assembler template 
8646 by enclosing it in square brackets 
8647 (i.e. @samp{%[Value]}). The scope of the name is the @code{asm} statement 
8648 that contains the definition. Any valid C variable name is acceptable, 
8649 including names already defined in the surrounding code. No two operands 
8650 within the same @code{asm} statement can use the same symbolic name.
8652 When not using an @var{asmSymbolicName}, use the (zero-based) position
8653 of the operand 
8654 in the list of operands in the assembler template. For example if there are 
8655 three output operands, use @samp{%0} in the template to refer to the first, 
8656 @samp{%1} for the second, and @samp{%2} for the third. 
8658 @item constraint
8659 A string constant specifying constraints on the placement of the operand; 
8660 @xref{Constraints}, for details.
8662 Output constraints must begin with either @samp{=} (a variable overwriting an 
8663 existing value) or @samp{+} (when reading and writing). When using 
8664 @samp{=}, do not assume the location contains the existing value
8665 on entry to the @code{asm}, except 
8666 when the operand is tied to an input; @pxref{InputOperands,,Input Operands}.
8668 After the prefix, there must be one or more additional constraints 
8669 (@pxref{Constraints}) that describe where the value resides. Common 
8670 constraints include @samp{r} for register and @samp{m} for memory. 
8671 When you list more than one possible location (for example, @code{"=rm"}),
8672 the compiler chooses the most efficient one based on the current context. 
8673 If you list as many alternates as the @code{asm} statement allows, you permit 
8674 the optimizers to produce the best possible code. 
8675 If you must use a specific register, but your Machine Constraints do not
8676 provide sufficient control to select the specific register you want, 
8677 local register variables may provide a solution (@pxref{Local Register 
8678 Variables}).
8680 @item cvariablename
8681 Specifies a C lvalue expression to hold the output, typically a variable name.
8682 The enclosing parentheses are a required part of the syntax.
8684 @end table
8686 When the compiler selects the registers to use to 
8687 represent the output operands, it does not use any of the clobbered registers 
8688 (@pxref{Clobbers and Scratch Registers}).
8690 Output operand expressions must be lvalues. The compiler cannot check whether 
8691 the operands have data types that are reasonable for the instruction being 
8692 executed. For output expressions that are not directly addressable (for 
8693 example a bit-field), the constraint must allow a register. In that case, GCC 
8694 uses the register as the output of the @code{asm}, and then stores that 
8695 register into the output. 
8697 Operands using the @samp{+} constraint modifier count as two operands 
8698 (that is, both as input and output) towards the total maximum of 30 operands
8699 per @code{asm} statement.
8701 Use the @samp{&} constraint modifier (@pxref{Modifiers}) on all output
8702 operands that must not overlap an input.  Otherwise, 
8703 GCC may allocate the output operand in the same register as an unrelated 
8704 input operand, on the assumption that the assembler code consumes its 
8705 inputs before producing outputs. This assumption may be false if the assembler 
8706 code actually consists of more than one instruction.
8708 The same problem can occur if one output parameter (@var{a}) allows a register 
8709 constraint and another output parameter (@var{b}) allows a memory constraint.
8710 The code generated by GCC to access the memory address in @var{b} can contain
8711 registers which @emph{might} be shared by @var{a}, and GCC considers those 
8712 registers to be inputs to the asm. As above, GCC assumes that such input
8713 registers are consumed before any outputs are written. This assumption may 
8714 result in incorrect behavior if the asm writes to @var{a} before using 
8715 @var{b}. Combining the @samp{&} modifier with the register constraint on @var{a}
8716 ensures that modifying @var{a} does not affect the address referenced by 
8717 @var{b}. Otherwise, the location of @var{b} 
8718 is undefined if @var{a} is modified before using @var{b}.
8720 @code{asm} supports operand modifiers on operands (for example @samp{%k2} 
8721 instead of simply @samp{%2}). Typically these qualifiers are hardware 
8722 dependent. The list of supported modifiers for x86 is found at 
8723 @ref{x86Operandmodifiers,x86 Operand modifiers}.
8725 If the C code that follows the @code{asm} makes no use of any of the output 
8726 operands, use @code{volatile} for the @code{asm} statement to prevent the 
8727 optimizers from discarding the @code{asm} statement as unneeded 
8728 (see @ref{Volatile}).
8730 This code makes no use of the optional @var{asmSymbolicName}. Therefore it 
8731 references the first output operand as @code{%0} (were there a second, it 
8732 would be @code{%1}, etc). The number of the first input operand is one greater 
8733 than that of the last output operand. In this i386 example, that makes 
8734 @code{Mask} referenced as @code{%1}:
8736 @example
8737 uint32_t Mask = 1234;
8738 uint32_t Index;
8740   asm ("bsfl %1, %0"
8741      : "=r" (Index)
8742      : "r" (Mask)
8743      : "cc");
8744 @end example
8746 That code overwrites the variable @code{Index} (@samp{=}),
8747 placing the value in a register (@samp{r}).
8748 Using the generic @samp{r} constraint instead of a constraint for a specific 
8749 register allows the compiler to pick the register to use, which can result 
8750 in more efficient code. This may not be possible if an assembler instruction 
8751 requires a specific register.
8753 The following i386 example uses the @var{asmSymbolicName} syntax.
8754 It produces the 
8755 same result as the code above, but some may consider it more readable or more 
8756 maintainable since reordering index numbers is not necessary when adding or 
8757 removing operands. The names @code{aIndex} and @code{aMask}
8758 are only used in this example to emphasize which 
8759 names get used where.
8760 It is acceptable to reuse the names @code{Index} and @code{Mask}.
8762 @example
8763 uint32_t Mask = 1234;
8764 uint32_t Index;
8766   asm ("bsfl %[aMask], %[aIndex]"
8767      : [aIndex] "=r" (Index)
8768      : [aMask] "r" (Mask)
8769      : "cc");
8770 @end example
8772 Here are some more examples of output operands.
8774 @example
8775 uint32_t c = 1;
8776 uint32_t d;
8777 uint32_t *e = &c;
8779 asm ("mov %[e], %[d]"
8780    : [d] "=rm" (d)
8781    : [e] "rm" (*e));
8782 @end example
8784 Here, @code{d} may either be in a register or in memory. Since the compiler 
8785 might already have the current value of the @code{uint32_t} location
8786 pointed to by @code{e}
8787 in a register, you can enable it to choose the best location
8788 for @code{d} by specifying both constraints.
8790 @anchor{FlagOutputOperands}
8791 @subsubsection Flag Output Operands
8792 @cindex @code{asm} flag output operands
8794 Some targets have a special register that holds the ``flags'' for the
8795 result of an operation or comparison.  Normally, the contents of that
8796 register are either unmodifed by the asm, or the asm is considered to
8797 clobber the contents.
8799 On some targets, a special form of output operand exists by which
8800 conditions in the flags register may be outputs of the asm.  The set of
8801 conditions supported are target specific, but the general rule is that
8802 the output variable must be a scalar integer, and the value is boolean.
8803 When supported, the target defines the preprocessor symbol
8804 @code{__GCC_ASM_FLAG_OUTPUTS__}.
8806 Because of the special nature of the flag output operands, the constraint
8807 may not include alternatives.
8809 Most often, the target has only one flags register, and thus is an implied
8810 operand of many instructions.  In this case, the operand should not be
8811 referenced within the assembler template via @code{%0} etc, as there's
8812 no corresponding text in the assembly language.
8814 @table @asis
8815 @item x86 family
8816 The flag output constraints for the x86 family are of the form
8817 @samp{=@@cc@var{cond}} where @var{cond} is one of the standard
8818 conditions defined in the ISA manual for @code{j@var{cc}} or
8819 @code{set@var{cc}}.
8821 @table @code
8822 @item a
8823 ``above'' or unsigned greater than
8824 @item ae
8825 ``above or equal'' or unsigned greater than or equal
8826 @item b
8827 ``below'' or unsigned less than
8828 @item be
8829 ``below or equal'' or unsigned less than or equal
8830 @item c
8831 carry flag set
8832 @item e
8833 @itemx z
8834 ``equal'' or zero flag set
8835 @item g
8836 signed greater than
8837 @item ge
8838 signed greater than or equal
8839 @item l
8840 signed less than
8841 @item le
8842 signed less than or equal
8843 @item o
8844 overflow flag set
8845 @item p
8846 parity flag set
8847 @item s
8848 sign flag set
8849 @item na
8850 @itemx nae
8851 @itemx nb
8852 @itemx nbe
8853 @itemx nc
8854 @itemx ne
8855 @itemx ng
8856 @itemx nge
8857 @itemx nl
8858 @itemx nle
8859 @itemx no
8860 @itemx np
8861 @itemx ns
8862 @itemx nz
8863 ``not'' @var{flag}, or inverted versions of those above
8864 @end table
8866 @end table
8868 @anchor{InputOperands}
8869 @subsubsection Input Operands
8870 @cindex @code{asm} input operands
8871 @cindex @code{asm} expressions
8873 Input operands make values from C variables and expressions available to the 
8874 assembly code.
8876 Operands are separated by commas.  Each operand has this format:
8878 @example
8879 @r{[} [@var{asmSymbolicName}] @r{]} @var{constraint} (@var{cexpression})
8880 @end example
8882 @table @var
8883 @item asmSymbolicName
8884 Specifies a symbolic name for the operand.
8885 Reference the name in the assembler template 
8886 by enclosing it in square brackets 
8887 (i.e. @samp{%[Value]}). The scope of the name is the @code{asm} statement 
8888 that contains the definition. Any valid C variable name is acceptable, 
8889 including names already defined in the surrounding code. No two operands 
8890 within the same @code{asm} statement can use the same symbolic name.
8892 When not using an @var{asmSymbolicName}, use the (zero-based) position
8893 of the operand 
8894 in the list of operands in the assembler template. For example if there are
8895 two output operands and three inputs,
8896 use @samp{%2} in the template to refer to the first input operand,
8897 @samp{%3} for the second, and @samp{%4} for the third. 
8899 @item constraint
8900 A string constant specifying constraints on the placement of the operand; 
8901 @xref{Constraints}, for details.
8903 Input constraint strings may not begin with either @samp{=} or @samp{+}.
8904 When you list more than one possible location (for example, @samp{"irm"}), 
8905 the compiler chooses the most efficient one based on the current context.
8906 If you must use a specific register, but your Machine Constraints do not
8907 provide sufficient control to select the specific register you want, 
8908 local register variables may provide a solution (@pxref{Local Register 
8909 Variables}).
8911 Input constraints can also be digits (for example, @code{"0"}). This indicates 
8912 that the specified input must be in the same place as the output constraint 
8913 at the (zero-based) index in the output constraint list. 
8914 When using @var{asmSymbolicName} syntax for the output operands,
8915 you may use these names (enclosed in brackets @samp{[]}) instead of digits.
8917 @item cexpression
8918 This is the C variable or expression being passed to the @code{asm} statement 
8919 as input.  The enclosing parentheses are a required part of the syntax.
8921 @end table
8923 When the compiler selects the registers to use to represent the input 
8924 operands, it does not use any of the clobbered registers
8925 (@pxref{Clobbers and Scratch Registers}).
8927 If there are no output operands but there are input operands, place two 
8928 consecutive colons where the output operands would go:
8930 @example
8931 __asm__ ("some instructions"
8932    : /* No outputs. */
8933    : "r" (Offset / 8));
8934 @end example
8936 @strong{Warning:} Do @emph{not} modify the contents of input-only operands 
8937 (except for inputs tied to outputs). The compiler assumes that on exit from 
8938 the @code{asm} statement these operands contain the same values as they 
8939 had before executing the statement. 
8940 It is @emph{not} possible to use clobbers
8941 to inform the compiler that the values in these inputs are changing. One 
8942 common work-around is to tie the changing input variable to an output variable 
8943 that never gets used. Note, however, that if the code that follows the 
8944 @code{asm} statement makes no use of any of the output operands, the GCC 
8945 optimizers may discard the @code{asm} statement as unneeded 
8946 (see @ref{Volatile}).
8948 @code{asm} supports operand modifiers on operands (for example @samp{%k2} 
8949 instead of simply @samp{%2}). Typically these qualifiers are hardware 
8950 dependent. The list of supported modifiers for x86 is found at 
8951 @ref{x86Operandmodifiers,x86 Operand modifiers}.
8953 In this example using the fictitious @code{combine} instruction, the 
8954 constraint @code{"0"} for input operand 1 says that it must occupy the same 
8955 location as output operand 0. Only input operands may use numbers in 
8956 constraints, and they must each refer to an output operand. Only a number (or 
8957 the symbolic assembler name) in the constraint can guarantee that one operand 
8958 is in the same place as another. The mere fact that @code{foo} is the value of 
8959 both operands is not enough to guarantee that they are in the same place in 
8960 the generated assembler code.
8962 @example
8963 asm ("combine %2, %0" 
8964    : "=r" (foo) 
8965    : "0" (foo), "g" (bar));
8966 @end example
8968 Here is an example using symbolic names.
8970 @example
8971 asm ("cmoveq %1, %2, %[result]" 
8972    : [result] "=r"(result) 
8973    : "r" (test), "r" (new), "[result]" (old));
8974 @end example
8976 @anchor{Clobbers and Scratch Registers}
8977 @subsubsection Clobbers and Scratch Registers
8978 @cindex @code{asm} clobbers
8979 @cindex @code{asm} scratch registers
8981 While the compiler is aware of changes to entries listed in the output 
8982 operands, the inline @code{asm} code may modify more than just the outputs. For 
8983 example, calculations may require additional registers, or the processor may 
8984 overwrite a register as a side effect of a particular assembler instruction. 
8985 In order to inform the compiler of these changes, list them in the clobber 
8986 list. Clobber list items are either register names or the special clobbers 
8987 (listed below). Each clobber list item is a string constant 
8988 enclosed in double quotes and separated by commas.
8990 Clobber descriptions may not in any way overlap with an input or output 
8991 operand. For example, you may not have an operand describing a register class 
8992 with one member when listing that register in the clobber list. Variables 
8993 declared to live in specific registers (@pxref{Explicit Register 
8994 Variables}) and used 
8995 as @code{asm} input or output operands must have no part mentioned in the 
8996 clobber description. In particular, there is no way to specify that input 
8997 operands get modified without also specifying them as output operands.
8999 When the compiler selects which registers to use to represent input and output 
9000 operands, it does not use any of the clobbered registers. As a result, 
9001 clobbered registers are available for any use in the assembler code.
9003 Here is a realistic example for the VAX showing the use of clobbered 
9004 registers: 
9006 @example
9007 asm volatile ("movc3 %0, %1, %2"
9008                    : /* No outputs. */
9009                    : "g" (from), "g" (to), "g" (count)
9010                    : "r0", "r1", "r2", "r3", "r4", "r5", "memory");
9011 @end example
9013 Also, there are two special clobber arguments:
9015 @table @code
9016 @item "cc"
9017 The @code{"cc"} clobber indicates that the assembler code modifies the flags 
9018 register. On some machines, GCC represents the condition codes as a specific 
9019 hardware register; @code{"cc"} serves to name this register.
9020 On other machines, condition code handling is different, 
9021 and specifying @code{"cc"} has no effect. But 
9022 it is valid no matter what the target.
9024 @item "memory"
9025 The @code{"memory"} clobber tells the compiler that the assembly code
9026 performs memory 
9027 reads or writes to items other than those listed in the input and output 
9028 operands (for example, accessing the memory pointed to by one of the input 
9029 parameters). To ensure memory contains correct values, GCC may need to flush 
9030 specific register values to memory before executing the @code{asm}. Further, 
9031 the compiler does not assume that any values read from memory before an 
9032 @code{asm} remain unchanged after that @code{asm}; it reloads them as 
9033 needed.  
9034 Using the @code{"memory"} clobber effectively forms a read/write
9035 memory barrier for the compiler.
9037 Note that this clobber does not prevent the @emph{processor} from doing 
9038 speculative reads past the @code{asm} statement. To prevent that, you need 
9039 processor-specific fence instructions.
9041 @end table
9043 Flushing registers to memory has performance implications and may be
9044 an issue for time-sensitive code.  You can provide better information
9045 to GCC to avoid this, as shown in the following examples.  At a
9046 minimum, aliasing rules allow GCC to know what memory @emph{doesn't}
9047 need to be flushed.
9049 Here is a fictitious sum of squares instruction, that takes two
9050 pointers to floating point values in memory and produces a floating
9051 point register output.
9052 Notice that @code{x}, and @code{y} both appear twice in the @code{asm}
9053 parameters, once to specify memory accessed, and once to specify a
9054 base register used by the @code{asm}.  You won't normally be wasting a
9055 register by doing this as GCC can use the same register for both
9056 purposes.  However, it would be foolish to use both @code{%1} and
9057 @code{%3} for @code{x} in this @code{asm} and expect them to be the
9058 same.  In fact, @code{%3} may well not be a register.  It might be a
9059 symbolic memory reference to the object pointed to by @code{x}.
9061 @smallexample
9062 asm ("sumsq %0, %1, %2"
9063      : "+f" (result)
9064      : "r" (x), "r" (y), "m" (*x), "m" (*y));
9065 @end smallexample
9067 Here is a fictitious @code{*z++ = *x++ * *y++} instruction.
9068 Notice that the @code{x}, @code{y} and @code{z} pointer registers
9069 must be specified as input/output because the @code{asm} modifies
9070 them.
9072 @smallexample
9073 asm ("vecmul %0, %1, %2"
9074      : "+r" (z), "+r" (x), "+r" (y), "=m" (*z)
9075      : "m" (*x), "m" (*y));
9076 @end smallexample
9078 An x86 example where the string memory argument is of unknown length.
9080 @smallexample
9081 asm("repne scasb"
9082     : "=c" (count), "+D" (p)
9083     : "m" (*(const char (*)[]) p), "0" (-1), "a" (0));
9084 @end smallexample
9086 If you know the above will only be reading a ten byte array then you
9087 could instead use a memory input like:
9088 @code{"m" (*(const char (*)[10]) p)}.
9090 Here is an example of a PowerPC vector scale implemented in assembly,
9091 complete with vector and condition code clobbers, and some initialized
9092 offset registers that are unchanged by the @code{asm}.
9094 @smallexample
9095 void
9096 dscal (size_t n, double *x, double alpha)
9098   asm ("/* lots of asm here */"
9099        : "+m" (*(double (*)[n]) x), "+&r" (n), "+b" (x)
9100        : "d" (alpha), "b" (32), "b" (48), "b" (64),
9101          "b" (80), "b" (96), "b" (112)
9102        : "cr0",
9103          "vs32","vs33","vs34","vs35","vs36","vs37","vs38","vs39",
9104          "vs40","vs41","vs42","vs43","vs44","vs45","vs46","vs47");
9106 @end smallexample
9108 Rather than allocating fixed registers via clobbers to provide scratch
9109 registers for an @code{asm} statement, an alternative is to define a
9110 variable and make it an early-clobber output as with @code{a2} and
9111 @code{a3} in the example below.  This gives the compiler register
9112 allocator more freedom.  You can also define a variable and make it an
9113 output tied to an input as with @code{a0} and @code{a1}, tied
9114 respectively to @code{ap} and @code{lda}.  Of course, with tied
9115 outputs your @code{asm} can't use the input value after modifying the
9116 output register since they are one and the same register.  What's
9117 more, if you omit the early-clobber on the output, it is possible that
9118 GCC might allocate the same register to another of the inputs if GCC
9119 could prove they had the same value on entry to the @code{asm}.  This
9120 is why @code{a1} has an early-clobber.  Its tied input, @code{lda}
9121 might conceivably be known to have the value 16 and without an
9122 early-clobber share the same register as @code{%11}.  On the other
9123 hand, @code{ap} can't be the same as any of the other inputs, so an
9124 early-clobber on @code{a0} is not needed.  It is also not desirable in
9125 this case.  An early-clobber on @code{a0} would cause GCC to allocate
9126 a separate register for the @code{"m" (*(const double (*)[]) ap)}
9127 input.  Note that tying an input to an output is the way to set up an
9128 initialized temporary register modified by an @code{asm} statement.
9129 An input not tied to an output is assumed by GCC to be unchanged, for
9130 example @code{"b" (16)} below sets up @code{%11} to 16, and GCC might
9131 use that register in following code if the value 16 happened to be
9132 needed.  You can even use a normal @code{asm} output for a scratch if
9133 all inputs that might share the same register are consumed before the
9134 scratch is used.  The VSX registers clobbered by the @code{asm}
9135 statement could have used this technique except for GCC's limit on the
9136 number of @code{asm} parameters.
9138 @smallexample
9139 static void
9140 dgemv_kernel_4x4 (long n, const double *ap, long lda,
9141                   const double *x, double *y, double alpha)
9143   double *a0;
9144   double *a1;
9145   double *a2;
9146   double *a3;
9148   __asm__
9149     (
9150      /* lots of asm here */
9151      "#n=%1 ap=%8=%12 lda=%13 x=%7=%10 y=%0=%2 alpha=%9 o16=%11\n"
9152      "#a0=%3 a1=%4 a2=%5 a3=%6"
9153      :
9154        "+m" (*(double (*)[n]) y),
9155        "+&r" (n),       // 1
9156        "+b" (y),        // 2
9157        "=b" (a0),       // 3
9158        "=&b" (a1),      // 4
9159        "=&b" (a2),      // 5
9160        "=&b" (a3)       // 6
9161      :
9162        "m" (*(const double (*)[n]) x),
9163        "m" (*(const double (*)[]) ap),
9164        "d" (alpha),     // 9
9165        "r" (x),         // 10
9166        "b" (16),        // 11
9167        "3" (ap),        // 12
9168        "4" (lda)        // 13
9169      :
9170        "cr0",
9171        "vs32","vs33","vs34","vs35","vs36","vs37",
9172        "vs40","vs41","vs42","vs43","vs44","vs45","vs46","vs47"
9173      );
9175 @end smallexample
9177 @anchor{GotoLabels}
9178 @subsubsection Goto Labels
9179 @cindex @code{asm} goto labels
9181 @code{asm goto} allows assembly code to jump to one or more C labels.  The
9182 @var{GotoLabels} section in an @code{asm goto} statement contains 
9183 a comma-separated 
9184 list of all C labels to which the assembler code may jump. GCC assumes that 
9185 @code{asm} execution falls through to the next statement (if this is not the 
9186 case, consider using the @code{__builtin_unreachable} intrinsic after the 
9187 @code{asm} statement). Optimization of @code{asm goto} may be improved by 
9188 using the @code{hot} and @code{cold} label attributes (@pxref{Label 
9189 Attributes}).
9191 An @code{asm goto} statement cannot have outputs.
9192 This is due to an internal restriction of 
9193 the compiler: control transfer instructions cannot have outputs. 
9194 If the assembler code does modify anything, use the @code{"memory"} clobber 
9195 to force the 
9196 optimizers to flush all register values to memory and reload them if 
9197 necessary after the @code{asm} statement.
9199 Also note that an @code{asm goto} statement is always implicitly
9200 considered volatile.
9202 To reference a label in the assembler template,
9203 prefix it with @samp{%l} (lowercase @samp{L}) followed 
9204 by its (zero-based) position in @var{GotoLabels} plus the number of input 
9205 operands.  For example, if the @code{asm} has three inputs and references two 
9206 labels, refer to the first label as @samp{%l3} and the second as @samp{%l4}).
9208 Alternately, you can reference labels using the actual C label name enclosed
9209 in brackets.  For example, to reference a label named @code{carry}, you can
9210 use @samp{%l[carry]}.  The label must still be listed in the @var{GotoLabels}
9211 section when using this approach.
9213 Here is an example of @code{asm goto} for i386:
9215 @example
9216 asm goto (
9217     "btl %1, %0\n\t"
9218     "jc %l2"
9219     : /* No outputs. */
9220     : "r" (p1), "r" (p2) 
9221     : "cc" 
9222     : carry);
9224 return 0;
9226 carry:
9227 return 1;
9228 @end example
9230 The following example shows an @code{asm goto} that uses a memory clobber.
9232 @example
9233 int frob(int x)
9235   int y;
9236   asm goto ("frob %%r5, %1; jc %l[error]; mov (%2), %%r5"
9237             : /* No outputs. */
9238             : "r"(x), "r"(&y)
9239             : "r5", "memory" 
9240             : error);
9241   return y;
9242 error:
9243   return -1;
9245 @end example
9247 @anchor{x86Operandmodifiers}
9248 @subsubsection x86 Operand Modifiers
9250 References to input, output, and goto operands in the assembler template
9251 of extended @code{asm} statements can use 
9252 modifiers to affect the way the operands are formatted in 
9253 the code output to the assembler. For example, the 
9254 following code uses the @samp{h} and @samp{b} modifiers for x86:
9256 @example
9257 uint16_t  num;
9258 asm volatile ("xchg %h0, %b0" : "+a" (num) );
9259 @end example
9261 @noindent
9262 These modifiers generate this assembler code:
9264 @example
9265 xchg %ah, %al
9266 @end example
9268 The rest of this discussion uses the following code for illustrative purposes.
9270 @example
9271 int main()
9273    int iInt = 1;
9275 top:
9277    asm volatile goto ("some assembler instructions here"
9278    : /* No outputs. */
9279    : "q" (iInt), "X" (sizeof(unsigned char) + 1)
9280    : /* No clobbers. */
9281    : top);
9283 @end example
9285 With no modifiers, this is what the output from the operands would be for the 
9286 @samp{att} and @samp{intel} dialects of assembler:
9288 @multitable {Operand} {$.L2} {OFFSET FLAT:.L2}
9289 @headitem Operand @tab @samp{att} @tab @samp{intel}
9290 @item @code{%0}
9291 @tab @code{%eax}
9292 @tab @code{eax}
9293 @item @code{%1}
9294 @tab @code{$2}
9295 @tab @code{2}
9296 @item @code{%2}
9297 @tab @code{$.L2}
9298 @tab @code{OFFSET FLAT:.L2}
9299 @end multitable
9301 The table below shows the list of supported modifiers and their effects.
9303 @multitable {Modifier} {Print the opcode suffix for the size of th} {Operand} {@samp{att}} {@samp{intel}}
9304 @headitem Modifier @tab Description @tab Operand @tab @samp{att} @tab @samp{intel}
9305 @item @code{z}
9306 @tab Print the opcode suffix for the size of the current integer operand (one of @code{b}/@code{w}/@code{l}/@code{q}).
9307 @tab @code{%z0}
9308 @tab @code{l}
9309 @tab 
9310 @item @code{b}
9311 @tab Print the QImode name of the register.
9312 @tab @code{%b0}
9313 @tab @code{%al}
9314 @tab @code{al}
9315 @item @code{h}
9316 @tab Print the QImode name for a ``high'' register.
9317 @tab @code{%h0}
9318 @tab @code{%ah}
9319 @tab @code{ah}
9320 @item @code{w}
9321 @tab Print the HImode name of the register.
9322 @tab @code{%w0}
9323 @tab @code{%ax}
9324 @tab @code{ax}
9325 @item @code{k}
9326 @tab Print the SImode name of the register.
9327 @tab @code{%k0}
9328 @tab @code{%eax}
9329 @tab @code{eax}
9330 @item @code{q}
9331 @tab Print the DImode name of the register.
9332 @tab @code{%q0}
9333 @tab @code{%rax}
9334 @tab @code{rax}
9335 @item @code{l}
9336 @tab Print the label name with no punctuation.
9337 @tab @code{%l2}
9338 @tab @code{.L2}
9339 @tab @code{.L2}
9340 @item @code{c}
9341 @tab Require a constant operand and print the constant expression with no punctuation.
9342 @tab @code{%c1}
9343 @tab @code{2}
9344 @tab @code{2}
9345 @end multitable
9347 @code{V} is a special modifier which prints the name of the full integer
9348 register without @code{%}.
9350 @anchor{x86floatingpointasmoperands}
9351 @subsubsection x86 Floating-Point @code{asm} Operands
9353 On x86 targets, there are several rules on the usage of stack-like registers
9354 in the operands of an @code{asm}.  These rules apply only to the operands
9355 that are stack-like registers:
9357 @enumerate
9358 @item
9359 Given a set of input registers that die in an @code{asm}, it is
9360 necessary to know which are implicitly popped by the @code{asm}, and
9361 which must be explicitly popped by GCC@.
9363 An input register that is implicitly popped by the @code{asm} must be
9364 explicitly clobbered, unless it is constrained to match an
9365 output operand.
9367 @item
9368 For any input register that is implicitly popped by an @code{asm}, it is
9369 necessary to know how to adjust the stack to compensate for the pop.
9370 If any non-popped input is closer to the top of the reg-stack than
9371 the implicitly popped register, it would not be possible to know what the
9372 stack looked like---it's not clear how the rest of the stack ``slides
9373 up''.
9375 All implicitly popped input registers must be closer to the top of
9376 the reg-stack than any input that is not implicitly popped.
9378 It is possible that if an input dies in an @code{asm}, the compiler might
9379 use the input register for an output reload.  Consider this example:
9381 @smallexample
9382 asm ("foo" : "=t" (a) : "f" (b));
9383 @end smallexample
9385 @noindent
9386 This code says that input @code{b} is not popped by the @code{asm}, and that
9387 the @code{asm} pushes a result onto the reg-stack, i.e., the stack is one
9388 deeper after the @code{asm} than it was before.  But, it is possible that
9389 reload may think that it can use the same register for both the input and
9390 the output.
9392 To prevent this from happening,
9393 if any input operand uses the @samp{f} constraint, all output register
9394 constraints must use the @samp{&} early-clobber modifier.
9396 The example above is correctly written as:
9398 @smallexample
9399 asm ("foo" : "=&t" (a) : "f" (b));
9400 @end smallexample
9402 @item
9403 Some operands need to be in particular places on the stack.  All
9404 output operands fall in this category---GCC has no other way to
9405 know which registers the outputs appear in unless you indicate
9406 this in the constraints.
9408 Output operands must specifically indicate which register an output
9409 appears in after an @code{asm}.  @samp{=f} is not allowed: the operand
9410 constraints must select a class with a single register.
9412 @item
9413 Output operands may not be ``inserted'' between existing stack registers.
9414 Since no 387 opcode uses a read/write operand, all output operands
9415 are dead before the @code{asm}, and are pushed by the @code{asm}.
9416 It makes no sense to push anywhere but the top of the reg-stack.
9418 Output operands must start at the top of the reg-stack: output
9419 operands may not ``skip'' a register.
9421 @item
9422 Some @code{asm} statements may need extra stack space for internal
9423 calculations.  This can be guaranteed by clobbering stack registers
9424 unrelated to the inputs and outputs.
9426 @end enumerate
9428 This @code{asm}
9429 takes one input, which is internally popped, and produces two outputs.
9431 @smallexample
9432 asm ("fsincos" : "=t" (cos), "=u" (sin) : "0" (inp));
9433 @end smallexample
9435 @noindent
9436 This @code{asm} takes two inputs, which are popped by the @code{fyl2xp1} opcode,
9437 and replaces them with one output.  The @code{st(1)} clobber is necessary 
9438 for the compiler to know that @code{fyl2xp1} pops both inputs.
9440 @smallexample
9441 asm ("fyl2xp1" : "=t" (result) : "0" (x), "u" (y) : "st(1)");
9442 @end smallexample
9444 @lowersections
9445 @include md.texi
9446 @raisesections
9448 @node Asm Labels
9449 @subsection Controlling Names Used in Assembler Code
9450 @cindex assembler names for identifiers
9451 @cindex names used in assembler code
9452 @cindex identifiers, names in assembler code
9454 You can specify the name to be used in the assembler code for a C
9455 function or variable by writing the @code{asm} (or @code{__asm__})
9456 keyword after the declarator.
9457 It is up to you to make sure that the assembler names you choose do not
9458 conflict with any other assembler symbols, or reference registers.
9460 @subsubheading Assembler names for data:
9462 This sample shows how to specify the assembler name for data:
9464 @smallexample
9465 int foo asm ("myfoo") = 2;
9466 @end smallexample
9468 @noindent
9469 This specifies that the name to be used for the variable @code{foo} in
9470 the assembler code should be @samp{myfoo} rather than the usual
9471 @samp{_foo}.
9473 On systems where an underscore is normally prepended to the name of a C
9474 variable, this feature allows you to define names for the
9475 linker that do not start with an underscore.
9477 GCC does not support using this feature with a non-static local variable 
9478 since such variables do not have assembler names.  If you are
9479 trying to put the variable in a particular register, see 
9480 @ref{Explicit Register Variables}.
9482 @subsubheading Assembler names for functions:
9484 To specify the assembler name for functions, write a declaration for the 
9485 function before its definition and put @code{asm} there, like this:
9487 @smallexample
9488 int func (int x, int y) asm ("MYFUNC");
9489      
9490 int func (int x, int y)
9492    /* @r{@dots{}} */
9493 @end smallexample
9495 @noindent
9496 This specifies that the name to be used for the function @code{func} in
9497 the assembler code should be @code{MYFUNC}.
9499 @node Explicit Register Variables
9500 @subsection Variables in Specified Registers
9501 @anchor{Explicit Reg Vars}
9502 @cindex explicit register variables
9503 @cindex variables in specified registers
9504 @cindex specified registers
9506 GNU C allows you to associate specific hardware registers with C 
9507 variables.  In almost all cases, allowing the compiler to assign
9508 registers produces the best code.  However under certain unusual
9509 circumstances, more precise control over the variable storage is 
9510 required.
9512 Both global and local variables can be associated with a register.  The
9513 consequences of performing this association are very different between
9514 the two, as explained in the sections below.
9516 @menu
9517 * Global Register Variables::   Variables declared at global scope.
9518 * Local Register Variables::    Variables declared within a function.
9519 @end menu
9521 @node Global Register Variables
9522 @subsubsection Defining Global Register Variables
9523 @anchor{Global Reg Vars}
9524 @cindex global register variables
9525 @cindex registers, global variables in
9526 @cindex registers, global allocation
9528 You can define a global register variable and associate it with a specified 
9529 register like this:
9531 @smallexample
9532 register int *foo asm ("r12");
9533 @end smallexample
9535 @noindent
9536 Here @code{r12} is the name of the register that should be used. Note that 
9537 this is the same syntax used for defining local register variables, but for 
9538 a global variable the declaration appears outside a function. The 
9539 @code{register} keyword is required, and cannot be combined with 
9540 @code{static}. The register name must be a valid register name for the
9541 target platform.
9543 Registers are a scarce resource on most systems and allowing the 
9544 compiler to manage their usage usually results in the best code. However, 
9545 under special circumstances it can make sense to reserve some globally.
9546 For example this may be useful in programs such as programming language 
9547 interpreters that have a couple of global variables that are accessed 
9548 very often.
9550 After defining a global register variable, for the current compilation
9551 unit:
9553 @itemize @bullet
9554 @item The register is reserved entirely for this use, and will not be 
9555 allocated for any other purpose.
9556 @item The register is not saved and restored by any functions.
9557 @item Stores into this register are never deleted even if they appear to be 
9558 dead, but references may be deleted, moved or simplified.
9559 @end itemize
9561 Note that these points @emph{only} apply to code that is compiled with the
9562 definition. The behavior of code that is merely linked in (for example 
9563 code from libraries) is not affected.
9565 If you want to recompile source files that do not actually use your global 
9566 register variable so they do not use the specified register for any other 
9567 purpose, you need not actually add the global register declaration to 
9568 their source code. It suffices to specify the compiler option 
9569 @option{-ffixed-@var{reg}} (@pxref{Code Gen Options}) to reserve the 
9570 register.
9572 @subsubheading Declaring the variable
9574 Global register variables can not have initial values, because an
9575 executable file has no means to supply initial contents for a register.
9577 When selecting a register, choose one that is normally saved and 
9578 restored by function calls on your machine. This ensures that code
9579 which is unaware of this reservation (such as library routines) will 
9580 restore it before returning.
9582 On machines with register windows, be sure to choose a global
9583 register that is not affected magically by the function call mechanism.
9585 @subsubheading Using the variable
9587 @cindex @code{qsort}, and global register variables
9588 When calling routines that are not aware of the reservation, be 
9589 cautious if those routines call back into code which uses them. As an 
9590 example, if you call the system library version of @code{qsort}, it may 
9591 clobber your registers during execution, but (if you have selected 
9592 appropriate registers) it will restore them before returning. However 
9593 it will @emph{not} restore them before calling @code{qsort}'s comparison 
9594 function. As a result, global values will not reliably be available to 
9595 the comparison function unless the @code{qsort} function itself is rebuilt.
9597 Similarly, it is not safe to access the global register variables from signal
9598 handlers or from more than one thread of control. Unless you recompile 
9599 them specially for the task at hand, the system library routines may 
9600 temporarily use the register for other things.
9602 @cindex register variable after @code{longjmp}
9603 @cindex global register after @code{longjmp}
9604 @cindex value after @code{longjmp}
9605 @findex longjmp
9606 @findex setjmp
9607 On most machines, @code{longjmp} restores to each global register
9608 variable the value it had at the time of the @code{setjmp}. On some
9609 machines, however, @code{longjmp} does not change the value of global
9610 register variables. To be portable, the function that called @code{setjmp}
9611 should make other arrangements to save the values of the global register
9612 variables, and to restore them in a @code{longjmp}. This way, the same
9613 thing happens regardless of what @code{longjmp} does.
9615 Eventually there may be a way of asking the compiler to choose a register 
9616 automatically, but first we need to figure out how it should choose and 
9617 how to enable you to guide the choice.  No solution is evident.
9619 @node Local Register Variables
9620 @subsubsection Specifying Registers for Local Variables
9621 @anchor{Local Reg Vars}
9622 @cindex local variables, specifying registers
9623 @cindex specifying registers for local variables
9624 @cindex registers for local variables
9626 You can define a local register variable and associate it with a specified 
9627 register like this:
9629 @smallexample
9630 register int *foo asm ("r12");
9631 @end smallexample
9633 @noindent
9634 Here @code{r12} is the name of the register that should be used.  Note
9635 that this is the same syntax used for defining global register variables, 
9636 but for a local variable the declaration appears within a function.  The 
9637 @code{register} keyword is required, and cannot be combined with 
9638 @code{static}.  The register name must be a valid register name for the
9639 target platform.
9641 As with global register variables, it is recommended that you choose 
9642 a register that is normally saved and restored by function calls on your 
9643 machine, so that calls to library routines will not clobber it.
9645 The only supported use for this feature is to specify registers
9646 for input and output operands when calling Extended @code{asm} 
9647 (@pxref{Extended Asm}).  This may be necessary if the constraints for a 
9648 particular machine don't provide sufficient control to select the desired 
9649 register.  To force an operand into a register, create a local variable 
9650 and specify the register name after the variable's declaration.  Then use 
9651 the local variable for the @code{asm} operand and specify any constraint 
9652 letter that matches the register:
9654 @smallexample
9655 register int *p1 asm ("r0") = @dots{};
9656 register int *p2 asm ("r1") = @dots{};
9657 register int *result asm ("r0");
9658 asm ("sysint" : "=r" (result) : "0" (p1), "r" (p2));
9659 @end smallexample
9661 @emph{Warning:} In the above example, be aware that a register (for example 
9662 @code{r0}) can be call-clobbered by subsequent code, including function 
9663 calls and library calls for arithmetic operators on other variables (for 
9664 example the initialization of @code{p2}).  In this case, use temporary 
9665 variables for expressions between the register assignments:
9667 @smallexample
9668 int t1 = @dots{};
9669 register int *p1 asm ("r0") = @dots{};
9670 register int *p2 asm ("r1") = t1;
9671 register int *result asm ("r0");
9672 asm ("sysint" : "=r" (result) : "0" (p1), "r" (p2));
9673 @end smallexample
9675 Defining a register variable does not reserve the register.  Other than
9676 when invoking the Extended @code{asm}, the contents of the specified 
9677 register are not guaranteed.  For this reason, the following uses 
9678 are explicitly @emph{not} supported.  If they appear to work, it is only 
9679 happenstance, and may stop working as intended due to (seemingly) 
9680 unrelated changes in surrounding code, or even minor changes in the 
9681 optimization of a future version of gcc:
9683 @itemize @bullet
9684 @item Passing parameters to or from Basic @code{asm}
9685 @item Passing parameters to or from Extended @code{asm} without using input 
9686 or output operands.
9687 @item Passing parameters to or from routines written in assembler (or
9688 other languages) using non-standard calling conventions.
9689 @end itemize
9691 Some developers use Local Register Variables in an attempt to improve 
9692 gcc's allocation of registers, especially in large functions.  In this 
9693 case the register name is essentially a hint to the register allocator.
9694 While in some instances this can generate better code, improvements are
9695 subject to the whims of the allocator/optimizers.  Since there are no
9696 guarantees that your improvements won't be lost, this usage of Local
9697 Register Variables is discouraged.
9699 On the MIPS platform, there is related use for local register variables 
9700 with slightly different characteristics (@pxref{MIPS Coprocessors,, 
9701 Defining coprocessor specifics for MIPS targets, gccint, 
9702 GNU Compiler Collection (GCC) Internals}).
9704 @node Size of an asm
9705 @subsection Size of an @code{asm}
9707 Some targets require that GCC track the size of each instruction used
9708 in order to generate correct code.  Because the final length of the
9709 code produced by an @code{asm} statement is only known by the
9710 assembler, GCC must make an estimate as to how big it will be.  It
9711 does this by counting the number of instructions in the pattern of the
9712 @code{asm} and multiplying that by the length of the longest
9713 instruction supported by that processor.  (When working out the number
9714 of instructions, it assumes that any occurrence of a newline or of
9715 whatever statement separator character is supported by the assembler --
9716 typically @samp{;} --- indicates the end of an instruction.)
9718 Normally, GCC's estimate is adequate to ensure that correct
9719 code is generated, but it is possible to confuse the compiler if you use
9720 pseudo instructions or assembler macros that expand into multiple real
9721 instructions, or if you use assembler directives that expand to more
9722 space in the object file than is needed for a single instruction.
9723 If this happens then the assembler may produce a diagnostic saying that
9724 a label is unreachable.
9726 @node Alternate Keywords
9727 @section Alternate Keywords
9728 @cindex alternate keywords
9729 @cindex keywords, alternate
9731 @option{-ansi} and the various @option{-std} options disable certain
9732 keywords.  This causes trouble when you want to use GNU C extensions, or
9733 a general-purpose header file that should be usable by all programs,
9734 including ISO C programs.  The keywords @code{asm}, @code{typeof} and
9735 @code{inline} are not available in programs compiled with
9736 @option{-ansi} or @option{-std} (although @code{inline} can be used in a
9737 program compiled with @option{-std=c99} or @option{-std=c11}).  The
9738 ISO C99 keyword
9739 @code{restrict} is only available when @option{-std=gnu99} (which will
9740 eventually be the default) or @option{-std=c99} (or the equivalent
9741 @option{-std=iso9899:1999}), or an option for a later standard
9742 version, is used.
9744 The way to solve these problems is to put @samp{__} at the beginning and
9745 end of each problematical keyword.  For example, use @code{__asm__}
9746 instead of @code{asm}, and @code{__inline__} instead of @code{inline}.
9748 Other C compilers won't accept these alternative keywords; if you want to
9749 compile with another compiler, you can define the alternate keywords as
9750 macros to replace them with the customary keywords.  It looks like this:
9752 @smallexample
9753 #ifndef __GNUC__
9754 #define __asm__ asm
9755 #endif
9756 @end smallexample
9758 @findex __extension__
9759 @opindex pedantic
9760 @option{-pedantic} and other options cause warnings for many GNU C extensions.
9761 You can
9762 prevent such warnings within one expression by writing
9763 @code{__extension__} before the expression.  @code{__extension__} has no
9764 effect aside from this.
9766 @node Incomplete Enums
9767 @section Incomplete @code{enum} Types
9769 You can define an @code{enum} tag without specifying its possible values.
9770 This results in an incomplete type, much like what you get if you write
9771 @code{struct foo} without describing the elements.  A later declaration
9772 that does specify the possible values completes the type.
9774 You cannot allocate variables or storage using the type while it is
9775 incomplete.  However, you can work with pointers to that type.
9777 This extension may not be very useful, but it makes the handling of
9778 @code{enum} more consistent with the way @code{struct} and @code{union}
9779 are handled.
9781 This extension is not supported by GNU C++.
9783 @node Function Names
9784 @section Function Names as Strings
9785 @cindex @code{__func__} identifier
9786 @cindex @code{__FUNCTION__} identifier
9787 @cindex @code{__PRETTY_FUNCTION__} identifier
9789 GCC provides three magic constants that hold the name of the current
9790 function as a string.  In C++11 and later modes, all three are treated
9791 as constant expressions and can be used in @code{constexpr} constexts.
9792 The first of these constants is @code{__func__}, which is part of
9793 the C99 standard:
9795 The identifier @code{__func__} is implicitly declared by the translator
9796 as if, immediately following the opening brace of each function
9797 definition, the declaration
9799 @smallexample
9800 static const char __func__[] = "function-name";
9801 @end smallexample
9803 @noindent
9804 appeared, where function-name is the name of the lexically-enclosing
9805 function.  This name is the unadorned name of the function.  As an
9806 extension, at file (or, in C++, namespace scope), @code{__func__}
9807 evaluates to the empty string.
9809 @code{__FUNCTION__} is another name for @code{__func__}, provided for
9810 backward compatibility with old versions of GCC.
9812 In C, @code{__PRETTY_FUNCTION__} is yet another name for
9813 @code{__func__}, except that at file (or, in C++, namespace scope),
9814 it evaluates to the string @code{"top level"}.  In addition, in C++,
9815 @code{__PRETTY_FUNCTION__} contains the signature of the function as
9816 well as its bare name.  For example, this program:
9818 @smallexample
9819 extern "C" int printf (const char *, ...);
9821 class a @{
9822  public:
9823   void sub (int i)
9824     @{
9825       printf ("__FUNCTION__ = %s\n", __FUNCTION__);
9826       printf ("__PRETTY_FUNCTION__ = %s\n", __PRETTY_FUNCTION__);
9827     @}
9831 main (void)
9833   a ax;
9834   ax.sub (0);
9835   return 0;
9837 @end smallexample
9839 @noindent
9840 gives this output:
9842 @smallexample
9843 __FUNCTION__ = sub
9844 __PRETTY_FUNCTION__ = void a::sub(int)
9845 @end smallexample
9847 These identifiers are variables, not preprocessor macros, and may not
9848 be used to initialize @code{char} arrays or be concatenated with string
9849 literals.
9851 @node Return Address
9852 @section Getting the Return or Frame Address of a Function
9854 These functions may be used to get information about the callers of a
9855 function.
9857 @deftypefn {Built-in Function} {void *} __builtin_return_address (unsigned int @var{level})
9858 This function returns the return address of the current function, or of
9859 one of its callers.  The @var{level} argument is number of frames to
9860 scan up the call stack.  A value of @code{0} yields the return address
9861 of the current function, a value of @code{1} yields the return address
9862 of the caller of the current function, and so forth.  When inlining
9863 the expected behavior is that the function returns the address of
9864 the function that is returned to.  To work around this behavior use
9865 the @code{noinline} function attribute.
9867 The @var{level} argument must be a constant integer.
9869 On some machines it may be impossible to determine the return address of
9870 any function other than the current one; in such cases, or when the top
9871 of the stack has been reached, this function returns @code{0} or a
9872 random value.  In addition, @code{__builtin_frame_address} may be used
9873 to determine if the top of the stack has been reached.
9875 Additional post-processing of the returned value may be needed, see
9876 @code{__builtin_extract_return_addr}.
9878 Calling this function with a nonzero argument can have unpredictable
9879 effects, including crashing the calling program.  As a result, calls
9880 that are considered unsafe are diagnosed when the @option{-Wframe-address}
9881 option is in effect.  Such calls should only be made in debugging
9882 situations.
9883 @end deftypefn
9885 @deftypefn {Built-in Function} {void *} __builtin_extract_return_addr (void *@var{addr})
9886 The address as returned by @code{__builtin_return_address} may have to be fed
9887 through this function to get the actual encoded address.  For example, on the
9888 31-bit S/390 platform the highest bit has to be masked out, or on SPARC
9889 platforms an offset has to be added for the true next instruction to be
9890 executed.
9892 If no fixup is needed, this function simply passes through @var{addr}.
9893 @end deftypefn
9895 @deftypefn {Built-in Function} {void *} __builtin_frob_return_address (void *@var{addr})
9896 This function does the reverse of @code{__builtin_extract_return_addr}.
9897 @end deftypefn
9899 @deftypefn {Built-in Function} {void *} __builtin_frame_address (unsigned int @var{level})
9900 This function is similar to @code{__builtin_return_address}, but it
9901 returns the address of the function frame rather than the return address
9902 of the function.  Calling @code{__builtin_frame_address} with a value of
9903 @code{0} yields the frame address of the current function, a value of
9904 @code{1} yields the frame address of the caller of the current function,
9905 and so forth.
9907 The frame is the area on the stack that holds local variables and saved
9908 registers.  The frame address is normally the address of the first word
9909 pushed on to the stack by the function.  However, the exact definition
9910 depends upon the processor and the calling convention.  If the processor
9911 has a dedicated frame pointer register, and the function has a frame,
9912 then @code{__builtin_frame_address} returns the value of the frame
9913 pointer register.
9915 On some machines it may be impossible to determine the frame address of
9916 any function other than the current one; in such cases, or when the top
9917 of the stack has been reached, this function returns @code{0} if
9918 the first frame pointer is properly initialized by the startup code.
9920 Calling this function with a nonzero argument can have unpredictable
9921 effects, including crashing the calling program.  As a result, calls
9922 that are considered unsafe are diagnosed when the @option{-Wframe-address}
9923 option is in effect.  Such calls should only be made in debugging
9924 situations.
9925 @end deftypefn
9927 @node Vector Extensions
9928 @section Using Vector Instructions through Built-in Functions
9930 On some targets, the instruction set contains SIMD vector instructions which
9931 operate on multiple values contained in one large register at the same time.
9932 For example, on the x86 the MMX, 3DNow!@: and SSE extensions can be used
9933 this way.
9935 The first step in using these extensions is to provide the necessary data
9936 types.  This should be done using an appropriate @code{typedef}:
9938 @smallexample
9939 typedef int v4si __attribute__ ((vector_size (16)));
9940 @end smallexample
9942 @noindent
9943 The @code{int} type specifies the base type, while the attribute specifies
9944 the vector size for the variable, measured in bytes.  For example, the
9945 declaration above causes the compiler to set the mode for the @code{v4si}
9946 type to be 16 bytes wide and divided into @code{int} sized units.  For
9947 a 32-bit @code{int} this means a vector of 4 units of 4 bytes, and the
9948 corresponding mode of @code{foo} is @acronym{V4SI}.
9950 The @code{vector_size} attribute is only applicable to integral and
9951 float scalars, although arrays, pointers, and function return values
9952 are allowed in conjunction with this construct. Only sizes that are
9953 a power of two are currently allowed.
9955 All the basic integer types can be used as base types, both as signed
9956 and as unsigned: @code{char}, @code{short}, @code{int}, @code{long},
9957 @code{long long}.  In addition, @code{float} and @code{double} can be
9958 used to build floating-point vector types.
9960 Specifying a combination that is not valid for the current architecture
9961 causes GCC to synthesize the instructions using a narrower mode.
9962 For example, if you specify a variable of type @code{V4SI} and your
9963 architecture does not allow for this specific SIMD type, GCC
9964 produces code that uses 4 @code{SIs}.
9966 The types defined in this manner can be used with a subset of normal C
9967 operations.  Currently, GCC allows using the following operators
9968 on these types: @code{+, -, *, /, unary minus, ^, |, &, ~, %}@.
9970 The operations behave like C++ @code{valarrays}.  Addition is defined as
9971 the addition of the corresponding elements of the operands.  For
9972 example, in the code below, each of the 4 elements in @var{a} is
9973 added to the corresponding 4 elements in @var{b} and the resulting
9974 vector is stored in @var{c}.
9976 @smallexample
9977 typedef int v4si __attribute__ ((vector_size (16)));
9979 v4si a, b, c;
9981 c = a + b;
9982 @end smallexample
9984 Subtraction, multiplication, division, and the logical operations
9985 operate in a similar manner.  Likewise, the result of using the unary
9986 minus or complement operators on a vector type is a vector whose
9987 elements are the negative or complemented values of the corresponding
9988 elements in the operand.
9990 It is possible to use shifting operators @code{<<}, @code{>>} on
9991 integer-type vectors. The operation is defined as following: @code{@{a0,
9992 a1, @dots{}, an@} >> @{b0, b1, @dots{}, bn@} == @{a0 >> b0, a1 >> b1,
9993 @dots{}, an >> bn@}}@. Vector operands must have the same number of
9994 elements. 
9996 For convenience, it is allowed to use a binary vector operation
9997 where one operand is a scalar. In that case the compiler transforms
9998 the scalar operand into a vector where each element is the scalar from
9999 the operation. The transformation happens only if the scalar could be
10000 safely converted to the vector-element type.
10001 Consider the following code.
10003 @smallexample
10004 typedef int v4si __attribute__ ((vector_size (16)));
10006 v4si a, b, c;
10007 long l;
10009 a = b + 1;    /* a = b + @{1,1,1,1@}; */
10010 a = 2 * b;    /* a = @{2,2,2,2@} * b; */
10012 a = l + a;    /* Error, cannot convert long to int. */
10013 @end smallexample
10015 Vectors can be subscripted as if the vector were an array with
10016 the same number of elements and base type.  Out of bound accesses
10017 invoke undefined behavior at run time.  Warnings for out of bound
10018 accesses for vector subscription can be enabled with
10019 @option{-Warray-bounds}.
10021 Vector comparison is supported with standard comparison
10022 operators: @code{==, !=, <, <=, >, >=}. Comparison operands can be
10023 vector expressions of integer-type or real-type. Comparison between
10024 integer-type vectors and real-type vectors are not supported.  The
10025 result of the comparison is a vector of the same width and number of
10026 elements as the comparison operands with a signed integral element
10027 type.
10029 Vectors are compared element-wise producing 0 when comparison is false
10030 and -1 (constant of the appropriate type where all bits are set)
10031 otherwise. Consider the following example.
10033 @smallexample
10034 typedef int v4si __attribute__ ((vector_size (16)));
10036 v4si a = @{1,2,3,4@};
10037 v4si b = @{3,2,1,4@};
10038 v4si c;
10040 c = a >  b;     /* The result would be @{0, 0,-1, 0@}  */
10041 c = a == b;     /* The result would be @{0,-1, 0,-1@}  */
10042 @end smallexample
10044 In C++, the ternary operator @code{?:} is available. @code{a?b:c}, where
10045 @code{b} and @code{c} are vectors of the same type and @code{a} is an
10046 integer vector with the same number of elements of the same size as @code{b}
10047 and @code{c}, computes all three arguments and creates a vector
10048 @code{@{a[0]?b[0]:c[0], a[1]?b[1]:c[1], @dots{}@}}.  Note that unlike in
10049 OpenCL, @code{a} is thus interpreted as @code{a != 0} and not @code{a < 0}.
10050 As in the case of binary operations, this syntax is also accepted when
10051 one of @code{b} or @code{c} is a scalar that is then transformed into a
10052 vector. If both @code{b} and @code{c} are scalars and the type of
10053 @code{true?b:c} has the same size as the element type of @code{a}, then
10054 @code{b} and @code{c} are converted to a vector type whose elements have
10055 this type and with the same number of elements as @code{a}.
10057 In C++, the logic operators @code{!, &&, ||} are available for vectors.
10058 @code{!v} is equivalent to @code{v == 0}, @code{a && b} is equivalent to
10059 @code{a!=0 & b!=0} and @code{a || b} is equivalent to @code{a!=0 | b!=0}.
10060 For mixed operations between a scalar @code{s} and a vector @code{v},
10061 @code{s && v} is equivalent to @code{s?v!=0:0} (the evaluation is
10062 short-circuit) and @code{v && s} is equivalent to @code{v!=0 & (s?-1:0)}.
10064 @findex __builtin_shuffle
10065 Vector shuffling is available using functions
10066 @code{__builtin_shuffle (vec, mask)} and
10067 @code{__builtin_shuffle (vec0, vec1, mask)}.
10068 Both functions construct a permutation of elements from one or two
10069 vectors and return a vector of the same type as the input vector(s).
10070 The @var{mask} is an integral vector with the same width (@var{W})
10071 and element count (@var{N}) as the output vector.
10073 The elements of the input vectors are numbered in memory ordering of
10074 @var{vec0} beginning at 0 and @var{vec1} beginning at @var{N}.  The
10075 elements of @var{mask} are considered modulo @var{N} in the single-operand
10076 case and modulo @math{2*@var{N}} in the two-operand case.
10078 Consider the following example,
10080 @smallexample
10081 typedef int v4si __attribute__ ((vector_size (16)));
10083 v4si a = @{1,2,3,4@};
10084 v4si b = @{5,6,7,8@};
10085 v4si mask1 = @{0,1,1,3@};
10086 v4si mask2 = @{0,4,2,5@};
10087 v4si res;
10089 res = __builtin_shuffle (a, mask1);       /* res is @{1,2,2,4@}  */
10090 res = __builtin_shuffle (a, b, mask2);    /* res is @{1,5,3,6@}  */
10091 @end smallexample
10093 Note that @code{__builtin_shuffle} is intentionally semantically
10094 compatible with the OpenCL @code{shuffle} and @code{shuffle2} functions.
10096 You can declare variables and use them in function calls and returns, as
10097 well as in assignments and some casts.  You can specify a vector type as
10098 a return type for a function.  Vector types can also be used as function
10099 arguments.  It is possible to cast from one vector type to another,
10100 provided they are of the same size (in fact, you can also cast vectors
10101 to and from other datatypes of the same size).
10103 You cannot operate between vectors of different lengths or different
10104 signedness without a cast.
10106 @node Offsetof
10107 @section Support for @code{offsetof}
10108 @findex __builtin_offsetof
10110 GCC implements for both C and C++ a syntactic extension to implement
10111 the @code{offsetof} macro.
10113 @smallexample
10114 primary:
10115         "__builtin_offsetof" "(" @code{typename} "," offsetof_member_designator ")"
10117 offsetof_member_designator:
10118           @code{identifier}
10119         | offsetof_member_designator "." @code{identifier}
10120         | offsetof_member_designator "[" @code{expr} "]"
10121 @end smallexample
10123 This extension is sufficient such that
10125 @smallexample
10126 #define offsetof(@var{type}, @var{member})  __builtin_offsetof (@var{type}, @var{member})
10127 @end smallexample
10129 @noindent
10130 is a suitable definition of the @code{offsetof} macro.  In C++, @var{type}
10131 may be dependent.  In either case, @var{member} may consist of a single
10132 identifier, or a sequence of member accesses and array references.
10134 @node __sync Builtins
10135 @section Legacy @code{__sync} Built-in Functions for Atomic Memory Access
10137 The following built-in functions
10138 are intended to be compatible with those described
10139 in the @cite{Intel Itanium Processor-specific Application Binary Interface},
10140 section 7.4.  As such, they depart from normal GCC practice by not using
10141 the @samp{__builtin_} prefix and also by being overloaded so that they
10142 work on multiple types.
10144 The definition given in the Intel documentation allows only for the use of
10145 the types @code{int}, @code{long}, @code{long long} or their unsigned
10146 counterparts.  GCC allows any scalar type that is 1, 2, 4 or 8 bytes in
10147 size other than the C type @code{_Bool} or the C++ type @code{bool}.
10148 Operations on pointer arguments are performed as if the operands were
10149 of the @code{uintptr_t} type.  That is, they are not scaled by the size
10150 of the type to which the pointer points.
10152 These functions are implemented in terms of the @samp{__atomic}
10153 builtins (@pxref{__atomic Builtins}).  They should not be used for new
10154 code which should use the @samp{__atomic} builtins instead.
10156 Not all operations are supported by all target processors.  If a particular
10157 operation cannot be implemented on the target processor, a warning is
10158 generated and a call to an external function is generated.  The external
10159 function carries the same name as the built-in version,
10160 with an additional suffix
10161 @samp{_@var{n}} where @var{n} is the size of the data type.
10163 @c ??? Should we have a mechanism to suppress this warning?  This is almost
10164 @c useful for implementing the operation under the control of an external
10165 @c mutex.
10167 In most cases, these built-in functions are considered a @dfn{full barrier}.
10168 That is,
10169 no memory operand is moved across the operation, either forward or
10170 backward.  Further, instructions are issued as necessary to prevent the
10171 processor from speculating loads across the operation and from queuing stores
10172 after the operation.
10174 All of the routines are described in the Intel documentation to take
10175 ``an optional list of variables protected by the memory barrier''.  It's
10176 not clear what is meant by that; it could mean that @emph{only} the
10177 listed variables are protected, or it could mean a list of additional
10178 variables to be protected.  The list is ignored by GCC which treats it as
10179 empty.  GCC interprets an empty list as meaning that all globally
10180 accessible variables should be protected.
10182 @table @code
10183 @item @var{type} __sync_fetch_and_add (@var{type} *ptr, @var{type} value, ...)
10184 @itemx @var{type} __sync_fetch_and_sub (@var{type} *ptr, @var{type} value, ...)
10185 @itemx @var{type} __sync_fetch_and_or (@var{type} *ptr, @var{type} value, ...)
10186 @itemx @var{type} __sync_fetch_and_and (@var{type} *ptr, @var{type} value, ...)
10187 @itemx @var{type} __sync_fetch_and_xor (@var{type} *ptr, @var{type} value, ...)
10188 @itemx @var{type} __sync_fetch_and_nand (@var{type} *ptr, @var{type} value, ...)
10189 @findex __sync_fetch_and_add
10190 @findex __sync_fetch_and_sub
10191 @findex __sync_fetch_and_or
10192 @findex __sync_fetch_and_and
10193 @findex __sync_fetch_and_xor
10194 @findex __sync_fetch_and_nand
10195 These built-in functions perform the operation suggested by the name, and
10196 returns the value that had previously been in memory.  That is, operations
10197 on integer operands have the following semantics.  Operations on pointer
10198 arguments are performed as if the operands were of the @code{uintptr_t}
10199 type.  That is, they are not scaled by the size of the type to which
10200 the pointer points.
10202 @smallexample
10203 @{ tmp = *ptr; *ptr @var{op}= value; return tmp; @}
10204 @{ tmp = *ptr; *ptr = ~(tmp & value); return tmp; @}   // nand
10205 @end smallexample
10207 The object pointed to by the first argument must be of integer or pointer
10208 type.  It must not be a boolean type.
10210 @emph{Note:} GCC 4.4 and later implement @code{__sync_fetch_and_nand}
10211 as @code{*ptr = ~(tmp & value)} instead of @code{*ptr = ~tmp & value}.
10213 @item @var{type} __sync_add_and_fetch (@var{type} *ptr, @var{type} value, ...)
10214 @itemx @var{type} __sync_sub_and_fetch (@var{type} *ptr, @var{type} value, ...)
10215 @itemx @var{type} __sync_or_and_fetch (@var{type} *ptr, @var{type} value, ...)
10216 @itemx @var{type} __sync_and_and_fetch (@var{type} *ptr, @var{type} value, ...)
10217 @itemx @var{type} __sync_xor_and_fetch (@var{type} *ptr, @var{type} value, ...)
10218 @itemx @var{type} __sync_nand_and_fetch (@var{type} *ptr, @var{type} value, ...)
10219 @findex __sync_add_and_fetch
10220 @findex __sync_sub_and_fetch
10221 @findex __sync_or_and_fetch
10222 @findex __sync_and_and_fetch
10223 @findex __sync_xor_and_fetch
10224 @findex __sync_nand_and_fetch
10225 These built-in functions perform the operation suggested by the name, and
10226 return the new value.  That is, operations on integer operands have
10227 the following semantics.  Operations on pointer operands are performed as
10228 if the operand's type were @code{uintptr_t}.
10230 @smallexample
10231 @{ *ptr @var{op}= value; return *ptr; @}
10232 @{ *ptr = ~(*ptr & value); return *ptr; @}   // nand
10233 @end smallexample
10235 The same constraints on arguments apply as for the corresponding
10236 @code{__sync_op_and_fetch} built-in functions.
10238 @emph{Note:} GCC 4.4 and later implement @code{__sync_nand_and_fetch}
10239 as @code{*ptr = ~(*ptr & value)} instead of
10240 @code{*ptr = ~*ptr & value}.
10242 @item bool __sync_bool_compare_and_swap (@var{type} *ptr, @var{type} oldval, @var{type} newval, ...)
10243 @itemx @var{type} __sync_val_compare_and_swap (@var{type} *ptr, @var{type} oldval, @var{type} newval, ...)
10244 @findex __sync_bool_compare_and_swap
10245 @findex __sync_val_compare_and_swap
10246 These built-in functions perform an atomic compare and swap.
10247 That is, if the current
10248 value of @code{*@var{ptr}} is @var{oldval}, then write @var{newval} into
10249 @code{*@var{ptr}}.
10251 The ``bool'' version returns true if the comparison is successful and
10252 @var{newval} is written.  The ``val'' version returns the contents
10253 of @code{*@var{ptr}} before the operation.
10255 @item __sync_synchronize (...)
10256 @findex __sync_synchronize
10257 This built-in function issues a full memory barrier.
10259 @item @var{type} __sync_lock_test_and_set (@var{type} *ptr, @var{type} value, ...)
10260 @findex __sync_lock_test_and_set
10261 This built-in function, as described by Intel, is not a traditional test-and-set
10262 operation, but rather an atomic exchange operation.  It writes @var{value}
10263 into @code{*@var{ptr}}, and returns the previous contents of
10264 @code{*@var{ptr}}.
10266 Many targets have only minimal support for such locks, and do not support
10267 a full exchange operation.  In this case, a target may support reduced
10268 functionality here by which the @emph{only} valid value to store is the
10269 immediate constant 1.  The exact value actually stored in @code{*@var{ptr}}
10270 is implementation defined.
10272 This built-in function is not a full barrier,
10273 but rather an @dfn{acquire barrier}.
10274 This means that references after the operation cannot move to (or be
10275 speculated to) before the operation, but previous memory stores may not
10276 be globally visible yet, and previous memory loads may not yet be
10277 satisfied.
10279 @item void __sync_lock_release (@var{type} *ptr, ...)
10280 @findex __sync_lock_release
10281 This built-in function releases the lock acquired by
10282 @code{__sync_lock_test_and_set}.
10283 Normally this means writing the constant 0 to @code{*@var{ptr}}.
10285 This built-in function is not a full barrier,
10286 but rather a @dfn{release barrier}.
10287 This means that all previous memory stores are globally visible, and all
10288 previous memory loads have been satisfied, but following memory reads
10289 are not prevented from being speculated to before the barrier.
10290 @end table
10292 @node __atomic Builtins
10293 @section Built-in Functions for Memory Model Aware Atomic Operations
10295 The following built-in functions approximately match the requirements
10296 for the C++11 memory model.  They are all
10297 identified by being prefixed with @samp{__atomic} and most are
10298 overloaded so that they work with multiple types.
10300 These functions are intended to replace the legacy @samp{__sync}
10301 builtins.  The main difference is that the memory order that is requested
10302 is a parameter to the functions.  New code should always use the
10303 @samp{__atomic} builtins rather than the @samp{__sync} builtins.
10305 Note that the @samp{__atomic} builtins assume that programs will
10306 conform to the C++11 memory model.  In particular, they assume
10307 that programs are free of data races.  See the C++11 standard for
10308 detailed requirements.
10310 The @samp{__atomic} builtins can be used with any integral scalar or
10311 pointer type that is 1, 2, 4, or 8 bytes in length.  16-byte integral
10312 types are also allowed if @samp{__int128} (@pxref{__int128}) is
10313 supported by the architecture.
10315 The four non-arithmetic functions (load, store, exchange, and 
10316 compare_exchange) all have a generic version as well.  This generic
10317 version works on any data type.  It uses the lock-free built-in function
10318 if the specific data type size makes that possible; otherwise, an
10319 external call is left to be resolved at run time.  This external call is
10320 the same format with the addition of a @samp{size_t} parameter inserted
10321 as the first parameter indicating the size of the object being pointed to.
10322 All objects must be the same size.
10324 There are 6 different memory orders that can be specified.  These map
10325 to the C++11 memory orders with the same names, see the C++11 standard
10326 or the @uref{http://gcc.gnu.org/wiki/Atomic/GCCMM/AtomicSync,GCC wiki
10327 on atomic synchronization} for detailed definitions.  Individual
10328 targets may also support additional memory orders for use on specific
10329 architectures.  Refer to the target documentation for details of
10330 these.
10332 An atomic operation can both constrain code motion and
10333 be mapped to hardware instructions for synchronization between threads
10334 (e.g., a fence).  To which extent this happens is controlled by the
10335 memory orders, which are listed here in approximately ascending order of
10336 strength.  The description of each memory order is only meant to roughly
10337 illustrate the effects and is not a specification; see the C++11
10338 memory model for precise semantics.
10340 @table  @code
10341 @item __ATOMIC_RELAXED
10342 Implies no inter-thread ordering constraints.
10343 @item __ATOMIC_CONSUME
10344 This is currently implemented using the stronger @code{__ATOMIC_ACQUIRE}
10345 memory order because of a deficiency in C++11's semantics for
10346 @code{memory_order_consume}.
10347 @item __ATOMIC_ACQUIRE
10348 Creates an inter-thread happens-before constraint from the release (or
10349 stronger) semantic store to this acquire load.  Can prevent hoisting
10350 of code to before the operation.
10351 @item __ATOMIC_RELEASE
10352 Creates an inter-thread happens-before constraint to acquire (or stronger)
10353 semantic loads that read from this release store.  Can prevent sinking
10354 of code to after the operation.
10355 @item __ATOMIC_ACQ_REL
10356 Combines the effects of both @code{__ATOMIC_ACQUIRE} and
10357 @code{__ATOMIC_RELEASE}.
10358 @item __ATOMIC_SEQ_CST
10359 Enforces total ordering with all other @code{__ATOMIC_SEQ_CST} operations.
10360 @end table
10362 Note that in the C++11 memory model, @emph{fences} (e.g.,
10363 @samp{__atomic_thread_fence}) take effect in combination with other
10364 atomic operations on specific memory locations (e.g., atomic loads);
10365 operations on specific memory locations do not necessarily affect other
10366 operations in the same way.
10368 Target architectures are encouraged to provide their own patterns for
10369 each of the atomic built-in functions.  If no target is provided, the original
10370 non-memory model set of @samp{__sync} atomic built-in functions are
10371 used, along with any required synchronization fences surrounding it in
10372 order to achieve the proper behavior.  Execution in this case is subject
10373 to the same restrictions as those built-in functions.
10375 If there is no pattern or mechanism to provide a lock-free instruction
10376 sequence, a call is made to an external routine with the same parameters
10377 to be resolved at run time.
10379 When implementing patterns for these built-in functions, the memory order
10380 parameter can be ignored as long as the pattern implements the most
10381 restrictive @code{__ATOMIC_SEQ_CST} memory order.  Any of the other memory
10382 orders execute correctly with this memory order but they may not execute as
10383 efficiently as they could with a more appropriate implementation of the
10384 relaxed requirements.
10386 Note that the C++11 standard allows for the memory order parameter to be
10387 determined at run time rather than at compile time.  These built-in
10388 functions map any run-time value to @code{__ATOMIC_SEQ_CST} rather
10389 than invoke a runtime library call or inline a switch statement.  This is
10390 standard compliant, safe, and the simplest approach for now.
10392 The memory order parameter is a signed int, but only the lower 16 bits are
10393 reserved for the memory order.  The remainder of the signed int is reserved
10394 for target use and should be 0.  Use of the predefined atomic values
10395 ensures proper usage.
10397 @deftypefn {Built-in Function} @var{type} __atomic_load_n (@var{type} *ptr, int memorder)
10398 This built-in function implements an atomic load operation.  It returns the
10399 contents of @code{*@var{ptr}}.
10401 The valid memory order variants are
10402 @code{__ATOMIC_RELAXED}, @code{__ATOMIC_SEQ_CST}, @code{__ATOMIC_ACQUIRE},
10403 and @code{__ATOMIC_CONSUME}.
10405 @end deftypefn
10407 @deftypefn {Built-in Function} void __atomic_load (@var{type} *ptr, @var{type} *ret, int memorder)
10408 This is the generic version of an atomic load.  It returns the
10409 contents of @code{*@var{ptr}} in @code{*@var{ret}}.
10411 @end deftypefn
10413 @deftypefn {Built-in Function} void __atomic_store_n (@var{type} *ptr, @var{type} val, int memorder)
10414 This built-in function implements an atomic store operation.  It writes 
10415 @code{@var{val}} into @code{*@var{ptr}}.  
10417 The valid memory order variants are
10418 @code{__ATOMIC_RELAXED}, @code{__ATOMIC_SEQ_CST}, and @code{__ATOMIC_RELEASE}.
10420 @end deftypefn
10422 @deftypefn {Built-in Function} void __atomic_store (@var{type} *ptr, @var{type} *val, int memorder)
10423 This is the generic version of an atomic store.  It stores the value
10424 of @code{*@var{val}} into @code{*@var{ptr}}.
10426 @end deftypefn
10428 @deftypefn {Built-in Function} @var{type} __atomic_exchange_n (@var{type} *ptr, @var{type} val, int memorder)
10429 This built-in function implements an atomic exchange operation.  It writes
10430 @var{val} into @code{*@var{ptr}}, and returns the previous contents of
10431 @code{*@var{ptr}}.
10433 The valid memory order variants are
10434 @code{__ATOMIC_RELAXED}, @code{__ATOMIC_SEQ_CST}, @code{__ATOMIC_ACQUIRE},
10435 @code{__ATOMIC_RELEASE}, and @code{__ATOMIC_ACQ_REL}.
10437 @end deftypefn
10439 @deftypefn {Built-in Function} void __atomic_exchange (@var{type} *ptr, @var{type} *val, @var{type} *ret, int memorder)
10440 This is the generic version of an atomic exchange.  It stores the
10441 contents of @code{*@var{val}} into @code{*@var{ptr}}. The original value
10442 of @code{*@var{ptr}} is copied into @code{*@var{ret}}.
10444 @end deftypefn
10446 @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)
10447 This built-in function implements an atomic compare and exchange operation.
10448 This compares the contents of @code{*@var{ptr}} with the contents of
10449 @code{*@var{expected}}. If equal, the operation is a @emph{read-modify-write}
10450 operation that writes @var{desired} into @code{*@var{ptr}}.  If they are not
10451 equal, the operation is a @emph{read} and the current contents of
10452 @code{*@var{ptr}} are written into @code{*@var{expected}}.  @var{weak} is true
10453 for weak compare_exchange, which may fail spuriously, and false for
10454 the strong variation, which never fails spuriously.  Many targets
10455 only offer the strong variation and ignore the parameter.  When in doubt, use
10456 the strong variation.
10458 If @var{desired} is written into @code{*@var{ptr}} then true is returned
10459 and memory is affected according to the
10460 memory order specified by @var{success_memorder}.  There are no
10461 restrictions on what memory order can be used here.
10463 Otherwise, false is returned and memory is affected according
10464 to @var{failure_memorder}. This memory order cannot be
10465 @code{__ATOMIC_RELEASE} nor @code{__ATOMIC_ACQ_REL}.  It also cannot be a
10466 stronger order than that specified by @var{success_memorder}.
10468 @end deftypefn
10470 @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)
10471 This built-in function implements the generic version of
10472 @code{__atomic_compare_exchange}.  The function is virtually identical to
10473 @code{__atomic_compare_exchange_n}, except the desired value is also a
10474 pointer.
10476 @end deftypefn
10478 @deftypefn {Built-in Function} @var{type} __atomic_add_fetch (@var{type} *ptr, @var{type} val, int memorder)
10479 @deftypefnx {Built-in Function} @var{type} __atomic_sub_fetch (@var{type} *ptr, @var{type} val, int memorder)
10480 @deftypefnx {Built-in Function} @var{type} __atomic_and_fetch (@var{type} *ptr, @var{type} val, int memorder)
10481 @deftypefnx {Built-in Function} @var{type} __atomic_xor_fetch (@var{type} *ptr, @var{type} val, int memorder)
10482 @deftypefnx {Built-in Function} @var{type} __atomic_or_fetch (@var{type} *ptr, @var{type} val, int memorder)
10483 @deftypefnx {Built-in Function} @var{type} __atomic_nand_fetch (@var{type} *ptr, @var{type} val, int memorder)
10484 These built-in functions perform the operation suggested by the name, and
10485 return the result of the operation.  Operations on pointer arguments are
10486 performed as if the operands were of the @code{uintptr_t} type.  That is,
10487 they are not scaled by the size of the type to which the pointer points.
10489 @smallexample
10490 @{ *ptr @var{op}= val; return *ptr; @}
10491 @end smallexample
10493 The object pointed to by the first argument must be of integer or pointer
10494 type.  It must not be a boolean type.  All memory orders are valid.
10496 @end deftypefn
10498 @deftypefn {Built-in Function} @var{type} __atomic_fetch_add (@var{type} *ptr, @var{type} val, int memorder)
10499 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_sub (@var{type} *ptr, @var{type} val, int memorder)
10500 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_and (@var{type} *ptr, @var{type} val, int memorder)
10501 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_xor (@var{type} *ptr, @var{type} val, int memorder)
10502 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_or (@var{type} *ptr, @var{type} val, int memorder)
10503 @deftypefnx {Built-in Function} @var{type} __atomic_fetch_nand (@var{type} *ptr, @var{type} val, int memorder)
10504 These built-in functions perform the operation suggested by the name, and
10505 return the value that had previously been in @code{*@var{ptr}}.  Operations
10506 on pointer arguments are performed as if the operands were of
10507 the @code{uintptr_t} type.  That is, they are not scaled by the size of
10508 the type to which the pointer points.
10510 @smallexample
10511 @{ tmp = *ptr; *ptr @var{op}= val; return tmp; @}
10512 @end smallexample
10514 The same constraints on arguments apply as for the corresponding
10515 @code{__atomic_op_fetch} built-in functions.  All memory orders are valid.
10517 @end deftypefn
10519 @deftypefn {Built-in Function} bool __atomic_test_and_set (void *ptr, int memorder)
10521 This built-in function performs an atomic test-and-set operation on
10522 the byte at @code{*@var{ptr}}.  The byte is set to some implementation
10523 defined nonzero ``set'' value and the return value is @code{true} if and only
10524 if the previous contents were ``set''.
10525 It should be only used for operands of type @code{bool} or @code{char}. For 
10526 other types only part of the value may be set.
10528 All memory orders are valid.
10530 @end deftypefn
10532 @deftypefn {Built-in Function} void __atomic_clear (bool *ptr, int memorder)
10534 This built-in function performs an atomic clear operation on
10535 @code{*@var{ptr}}.  After the operation, @code{*@var{ptr}} contains 0.
10536 It should be only used for operands of type @code{bool} or @code{char} and 
10537 in conjunction with @code{__atomic_test_and_set}.
10538 For other types it may only clear partially. If the type is not @code{bool}
10539 prefer using @code{__atomic_store}.
10541 The valid memory order variants are
10542 @code{__ATOMIC_RELAXED}, @code{__ATOMIC_SEQ_CST}, and
10543 @code{__ATOMIC_RELEASE}.
10545 @end deftypefn
10547 @deftypefn {Built-in Function} void __atomic_thread_fence (int memorder)
10549 This built-in function acts as a synchronization fence between threads
10550 based on the specified memory order.
10552 All memory orders are valid.
10554 @end deftypefn
10556 @deftypefn {Built-in Function} void __atomic_signal_fence (int memorder)
10558 This built-in function acts as a synchronization fence between a thread
10559 and signal handlers based in the same thread.
10561 All memory orders are valid.
10563 @end deftypefn
10565 @deftypefn {Built-in Function} bool __atomic_always_lock_free (size_t size,  void *ptr)
10567 This built-in function returns true if objects of @var{size} bytes always
10568 generate lock-free atomic instructions for the target architecture.
10569 @var{size} must resolve to a compile-time constant and the result also
10570 resolves to a compile-time constant.
10572 @var{ptr} is an optional pointer to the object that may be used to determine
10573 alignment.  A value of 0 indicates typical alignment should be used.  The 
10574 compiler may also ignore this parameter.
10576 @smallexample
10577 if (__atomic_always_lock_free (sizeof (long long), 0))
10578 @end smallexample
10580 @end deftypefn
10582 @deftypefn {Built-in Function} bool __atomic_is_lock_free (size_t size, void *ptr)
10584 This built-in function returns true if objects of @var{size} bytes always
10585 generate lock-free atomic instructions for the target architecture.  If
10586 the built-in function is not known to be lock-free, a call is made to a
10587 runtime routine named @code{__atomic_is_lock_free}.
10589 @var{ptr} is an optional pointer to the object that may be used to determine
10590 alignment.  A value of 0 indicates typical alignment should be used.  The 
10591 compiler may also ignore this parameter.
10592 @end deftypefn
10594 @node Integer Overflow Builtins
10595 @section Built-in Functions to Perform Arithmetic with Overflow Checking
10597 The following built-in functions allow performing simple arithmetic operations
10598 together with checking whether the operations overflowed.
10600 @deftypefn {Built-in Function} bool __builtin_add_overflow (@var{type1} a, @var{type2} b, @var{type3} *res)
10601 @deftypefnx {Built-in Function} bool __builtin_sadd_overflow (int a, int b, int *res)
10602 @deftypefnx {Built-in Function} bool __builtin_saddl_overflow (long int a, long int b, long int *res)
10603 @deftypefnx {Built-in Function} bool __builtin_saddll_overflow (long long int a, long long int b, long long int *res)
10604 @deftypefnx {Built-in Function} bool __builtin_uadd_overflow (unsigned int a, unsigned int b, unsigned int *res)
10605 @deftypefnx {Built-in Function} bool __builtin_uaddl_overflow (unsigned long int a, unsigned long int b, unsigned long int *res)
10606 @deftypefnx {Built-in Function} bool __builtin_uaddll_overflow (unsigned long long int a, unsigned long long int b, unsigned long long int *res)
10608 These built-in functions promote the first two operands into infinite precision signed
10609 type and perform addition on those promoted operands.  The result is then
10610 cast to the type the third pointer argument points to and stored there.
10611 If the stored result is equal to the infinite precision result, the built-in
10612 functions return false, otherwise they return true.  As the addition is
10613 performed in infinite signed precision, these built-in functions have fully defined
10614 behavior for all argument values.
10616 The first built-in function allows arbitrary integral types for operands and
10617 the result type must be pointer to some integral type other than enumerated or
10618 boolean type, the rest of the built-in functions have explicit integer types.
10620 The compiler will attempt to use hardware instructions to implement
10621 these built-in functions where possible, like conditional jump on overflow
10622 after addition, conditional jump on carry etc.
10624 @end deftypefn
10626 @deftypefn {Built-in Function} bool __builtin_sub_overflow (@var{type1} a, @var{type2} b, @var{type3} *res)
10627 @deftypefnx {Built-in Function} bool __builtin_ssub_overflow (int a, int b, int *res)
10628 @deftypefnx {Built-in Function} bool __builtin_ssubl_overflow (long int a, long int b, long int *res)
10629 @deftypefnx {Built-in Function} bool __builtin_ssubll_overflow (long long int a, long long int b, long long int *res)
10630 @deftypefnx {Built-in Function} bool __builtin_usub_overflow (unsigned int a, unsigned int b, unsigned int *res)
10631 @deftypefnx {Built-in Function} bool __builtin_usubl_overflow (unsigned long int a, unsigned long int b, unsigned long int *res)
10632 @deftypefnx {Built-in Function} bool __builtin_usubll_overflow (unsigned long long int a, unsigned long long int b, unsigned long long int *res)
10634 These built-in functions are similar to the add overflow checking built-in
10635 functions above, except they perform subtraction, subtract the second argument
10636 from the first one, instead of addition.
10638 @end deftypefn
10640 @deftypefn {Built-in Function} bool __builtin_mul_overflow (@var{type1} a, @var{type2} b, @var{type3} *res)
10641 @deftypefnx {Built-in Function} bool __builtin_smul_overflow (int a, int b, int *res)
10642 @deftypefnx {Built-in Function} bool __builtin_smull_overflow (long int a, long int b, long int *res)
10643 @deftypefnx {Built-in Function} bool __builtin_smulll_overflow (long long int a, long long int b, long long int *res)
10644 @deftypefnx {Built-in Function} bool __builtin_umul_overflow (unsigned int a, unsigned int b, unsigned int *res)
10645 @deftypefnx {Built-in Function} bool __builtin_umull_overflow (unsigned long int a, unsigned long int b, unsigned long int *res)
10646 @deftypefnx {Built-in Function} bool __builtin_umulll_overflow (unsigned long long int a, unsigned long long int b, unsigned long long int *res)
10648 These built-in functions are similar to the add overflow checking built-in
10649 functions above, except they perform multiplication, instead of addition.
10651 @end deftypefn
10653 The following built-in functions allow checking if simple arithmetic operation
10654 would overflow.
10656 @deftypefn {Built-in Function} bool __builtin_add_overflow_p (@var{type1} a, @var{type2} b, @var{type3} c)
10657 @deftypefnx {Built-in Function} bool __builtin_sub_overflow_p (@var{type1} a, @var{type2} b, @var{type3} c)
10658 @deftypefnx {Built-in Function} bool __builtin_mul_overflow_p (@var{type1} a, @var{type2} b, @var{type3} c)
10660 These built-in functions are similar to @code{__builtin_add_overflow},
10661 @code{__builtin_sub_overflow}, or @code{__builtin_mul_overflow}, except that
10662 they don't store the result of the arithmetic operation anywhere and the
10663 last argument is not a pointer, but some expression with integral type other
10664 than enumerated or boolean type.
10666 The built-in functions promote the first two operands into infinite precision signed type
10667 and perform addition on those promoted operands. The result is then
10668 cast to the type of the third argument.  If the cast result is equal to the infinite
10669 precision result, the built-in functions return false, otherwise they return true.
10670 The value of the third argument is ignored, just the side effects in the third argument
10671 are evaluated, and no integral argument promotions are performed on the last argument.
10672 If the third argument is a bit-field, the type used for the result cast has the
10673 precision and signedness of the given bit-field, rather than precision and signedness
10674 of the underlying type.
10676 For example, the following macro can be used to portably check, at
10677 compile-time, whether or not adding two constant integers will overflow,
10678 and perform the addition only when it is known to be safe and not to trigger
10679 a @option{-Woverflow} warning.
10681 @smallexample
10682 #define INT_ADD_OVERFLOW_P(a, b) \
10683    __builtin_add_overflow_p (a, b, (__typeof__ ((a) + (b))) 0)
10685 enum @{
10686     A = INT_MAX, B = 3,
10687     C = INT_ADD_OVERFLOW_P (A, B) ? 0 : A + B,
10688     D = __builtin_add_overflow_p (1, SCHAR_MAX, (signed char) 0)
10690 @end smallexample
10692 The compiler will attempt to use hardware instructions to implement
10693 these built-in functions where possible, like conditional jump on overflow
10694 after addition, conditional jump on carry etc.
10696 @end deftypefn
10698 @node x86 specific memory model extensions for transactional memory
10699 @section x86-Specific Memory Model Extensions for Transactional Memory
10701 The x86 architecture supports additional memory ordering flags
10702 to mark critical sections for hardware lock elision. 
10703 These must be specified in addition to an existing memory order to
10704 atomic intrinsics.
10706 @table @code
10707 @item __ATOMIC_HLE_ACQUIRE
10708 Start lock elision on a lock variable.
10709 Memory order must be @code{__ATOMIC_ACQUIRE} or stronger.
10710 @item __ATOMIC_HLE_RELEASE
10711 End lock elision on a lock variable.
10712 Memory order must be @code{__ATOMIC_RELEASE} or stronger.
10713 @end table
10715 When a lock acquire fails, it is required for good performance to abort
10716 the transaction quickly. This can be done with a @code{_mm_pause}.
10718 @smallexample
10719 #include <immintrin.h> // For _mm_pause
10721 int lockvar;
10723 /* Acquire lock with lock elision */
10724 while (__atomic_exchange_n(&lockvar, 1, __ATOMIC_ACQUIRE|__ATOMIC_HLE_ACQUIRE))
10725     _mm_pause(); /* Abort failed transaction */
10727 /* Free lock with lock elision */
10728 __atomic_store_n(&lockvar, 0, __ATOMIC_RELEASE|__ATOMIC_HLE_RELEASE);
10729 @end smallexample
10731 @node Object Size Checking
10732 @section Object Size Checking Built-in Functions
10733 @findex __builtin_object_size
10734 @findex __builtin___memcpy_chk
10735 @findex __builtin___mempcpy_chk
10736 @findex __builtin___memmove_chk
10737 @findex __builtin___memset_chk
10738 @findex __builtin___strcpy_chk
10739 @findex __builtin___stpcpy_chk
10740 @findex __builtin___strncpy_chk
10741 @findex __builtin___strcat_chk
10742 @findex __builtin___strncat_chk
10743 @findex __builtin___sprintf_chk
10744 @findex __builtin___snprintf_chk
10745 @findex __builtin___vsprintf_chk
10746 @findex __builtin___vsnprintf_chk
10747 @findex __builtin___printf_chk
10748 @findex __builtin___vprintf_chk
10749 @findex __builtin___fprintf_chk
10750 @findex __builtin___vfprintf_chk
10752 GCC implements a limited buffer overflow protection mechanism that can
10753 prevent some buffer overflow attacks by determining the sizes of objects
10754 into which data is about to be written and preventing the writes when
10755 the size isn't sufficient.  The built-in functions described below yield
10756 the best results when used together and when optimization is enabled.
10757 For example, to detect object sizes across function boundaries or to
10758 follow pointer assignments through non-trivial control flow they rely
10759 on various optimization passes enabled with @option{-O2}.  However, to
10760 a limited extent, they can be used without optimization as well.
10762 @deftypefn {Built-in Function} {size_t} __builtin_object_size (const void * @var{ptr}, int @var{type})
10763 is a built-in construct that returns a constant number of bytes from
10764 @var{ptr} to the end of the object @var{ptr} pointer points to
10765 (if known at compile time).  @code{__builtin_object_size} never evaluates
10766 its arguments for side effects.  If there are any side effects in them, it
10767 returns @code{(size_t) -1} for @var{type} 0 or 1 and @code{(size_t) 0}
10768 for @var{type} 2 or 3.  If there are multiple objects @var{ptr} can
10769 point to and all of them are known at compile time, the returned number
10770 is the maximum of remaining byte counts in those objects if @var{type} & 2 is
10771 0 and minimum if nonzero.  If it is not possible to determine which objects
10772 @var{ptr} points to at compile time, @code{__builtin_object_size} should
10773 return @code{(size_t) -1} for @var{type} 0 or 1 and @code{(size_t) 0}
10774 for @var{type} 2 or 3.
10776 @var{type} is an integer constant from 0 to 3.  If the least significant
10777 bit is clear, objects are whole variables, if it is set, a closest
10778 surrounding subobject is considered the object a pointer points to.
10779 The second bit determines if maximum or minimum of remaining bytes
10780 is computed.
10782 @smallexample
10783 struct V @{ char buf1[10]; int b; char buf2[10]; @} var;
10784 char *p = &var.buf1[1], *q = &var.b;
10786 /* Here the object p points to is var.  */
10787 assert (__builtin_object_size (p, 0) == sizeof (var) - 1);
10788 /* The subobject p points to is var.buf1.  */
10789 assert (__builtin_object_size (p, 1) == sizeof (var.buf1) - 1);
10790 /* The object q points to is var.  */
10791 assert (__builtin_object_size (q, 0)
10792         == (char *) (&var + 1) - (char *) &var.b);
10793 /* The subobject q points to is var.b.  */
10794 assert (__builtin_object_size (q, 1) == sizeof (var.b));
10795 @end smallexample
10796 @end deftypefn
10798 There are built-in functions added for many common string operation
10799 functions, e.g., for @code{memcpy} @code{__builtin___memcpy_chk}
10800 built-in is provided.  This built-in has an additional last argument,
10801 which is the number of bytes remaining in the object the @var{dest}
10802 argument points to or @code{(size_t) -1} if the size is not known.
10804 The built-in functions are optimized into the normal string functions
10805 like @code{memcpy} if the last argument is @code{(size_t) -1} or if
10806 it is known at compile time that the destination object will not
10807 be overflowed.  If the compiler can determine at compile time that the
10808 object will always be overflowed, it issues a warning.
10810 The intended use can be e.g.@:
10812 @smallexample
10813 #undef memcpy
10814 #define bos0(dest) __builtin_object_size (dest, 0)
10815 #define memcpy(dest, src, n) \
10816   __builtin___memcpy_chk (dest, src, n, bos0 (dest))
10818 char *volatile p;
10819 char buf[10];
10820 /* It is unknown what object p points to, so this is optimized
10821    into plain memcpy - no checking is possible.  */
10822 memcpy (p, "abcde", n);
10823 /* Destination is known and length too.  It is known at compile
10824    time there will be no overflow.  */
10825 memcpy (&buf[5], "abcde", 5);
10826 /* Destination is known, but the length is not known at compile time.
10827    This will result in __memcpy_chk call that can check for overflow
10828    at run time.  */
10829 memcpy (&buf[5], "abcde", n);
10830 /* Destination is known and it is known at compile time there will
10831    be overflow.  There will be a warning and __memcpy_chk call that
10832    will abort the program at run time.  */
10833 memcpy (&buf[6], "abcde", 5);
10834 @end smallexample
10836 Such built-in functions are provided for @code{memcpy}, @code{mempcpy},
10837 @code{memmove}, @code{memset}, @code{strcpy}, @code{stpcpy}, @code{strncpy},
10838 @code{strcat} and @code{strncat}.
10840 There are also checking built-in functions for formatted output functions.
10841 @smallexample
10842 int __builtin___sprintf_chk (char *s, int flag, size_t os, const char *fmt, ...);
10843 int __builtin___snprintf_chk (char *s, size_t maxlen, int flag, size_t os,
10844                               const char *fmt, ...);
10845 int __builtin___vsprintf_chk (char *s, int flag, size_t os, const char *fmt,
10846                               va_list ap);
10847 int __builtin___vsnprintf_chk (char *s, size_t maxlen, int flag, size_t os,
10848                                const char *fmt, va_list ap);
10849 @end smallexample
10851 The added @var{flag} argument is passed unchanged to @code{__sprintf_chk}
10852 etc.@: functions and can contain implementation specific flags on what
10853 additional security measures the checking function might take, such as
10854 handling @code{%n} differently.
10856 The @var{os} argument is the object size @var{s} points to, like in the
10857 other built-in functions.  There is a small difference in the behavior
10858 though, if @var{os} is @code{(size_t) -1}, the built-in functions are
10859 optimized into the non-checking functions only if @var{flag} is 0, otherwise
10860 the checking function is called with @var{os} argument set to
10861 @code{(size_t) -1}.
10863 In addition to this, there are checking built-in functions
10864 @code{__builtin___printf_chk}, @code{__builtin___vprintf_chk},
10865 @code{__builtin___fprintf_chk} and @code{__builtin___vfprintf_chk}.
10866 These have just one additional argument, @var{flag}, right before
10867 format string @var{fmt}.  If the compiler is able to optimize them to
10868 @code{fputc} etc.@: functions, it does, otherwise the checking function
10869 is called and the @var{flag} argument passed to it.
10871 @node Pointer Bounds Checker builtins
10872 @section Pointer Bounds Checker Built-in Functions
10873 @cindex Pointer Bounds Checker builtins
10874 @findex __builtin___bnd_set_ptr_bounds
10875 @findex __builtin___bnd_narrow_ptr_bounds
10876 @findex __builtin___bnd_copy_ptr_bounds
10877 @findex __builtin___bnd_init_ptr_bounds
10878 @findex __builtin___bnd_null_ptr_bounds
10879 @findex __builtin___bnd_store_ptr_bounds
10880 @findex __builtin___bnd_chk_ptr_lbounds
10881 @findex __builtin___bnd_chk_ptr_ubounds
10882 @findex __builtin___bnd_chk_ptr_bounds
10883 @findex __builtin___bnd_get_ptr_lbound
10884 @findex __builtin___bnd_get_ptr_ubound
10886 GCC provides a set of built-in functions to control Pointer Bounds Checker
10887 instrumentation.  Note that all Pointer Bounds Checker builtins can be used
10888 even if you compile with Pointer Bounds Checker off
10889 (@option{-fno-check-pointer-bounds}).
10890 The behavior may differ in such case as documented below.
10892 @deftypefn {Built-in Function} {void *} __builtin___bnd_set_ptr_bounds (const void *@var{q}, size_t @var{size})
10894 This built-in function returns a new pointer with the value of @var{q}, and
10895 associate it with the bounds [@var{q}, @var{q}+@var{size}-1].  With Pointer
10896 Bounds Checker off, the built-in function just returns the first argument.
10898 @smallexample
10899 extern void *__wrap_malloc (size_t n)
10901   void *p = (void *)__real_malloc (n);
10902   if (!p) return __builtin___bnd_null_ptr_bounds (p);
10903   return __builtin___bnd_set_ptr_bounds (p, n);
10905 @end smallexample
10907 @end deftypefn
10909 @deftypefn {Built-in Function} {void *} __builtin___bnd_narrow_ptr_bounds (const void *@var{p}, const void *@var{q}, size_t  @var{size})
10911 This built-in function returns a new pointer with the value of @var{p}
10912 and associates it with the narrowed bounds formed by the intersection
10913 of bounds associated with @var{q} and the bounds
10914 [@var{p}, @var{p} + @var{size} - 1].
10915 With Pointer Bounds Checker off, the built-in function just returns the first
10916 argument.
10918 @smallexample
10919 void init_objects (object *objs, size_t size)
10921   size_t i;
10922   /* Initialize objects one-by-one passing pointers with bounds of 
10923      an object, not the full array of objects.  */
10924   for (i = 0; i < size; i++)
10925     init_object (__builtin___bnd_narrow_ptr_bounds (objs + i, objs,
10926                                                     sizeof(object)));
10928 @end smallexample
10930 @end deftypefn
10932 @deftypefn {Built-in Function} {void *} __builtin___bnd_copy_ptr_bounds (const void *@var{q}, const void *@var{r})
10934 This built-in function returns a new pointer with the value of @var{q},
10935 and associates it with the bounds already associated with pointer @var{r}.
10936 With Pointer Bounds Checker off, the built-in function just returns the first
10937 argument.
10939 @smallexample
10940 /* Here is a way to get pointer to object's field but
10941    still with the full object's bounds.  */
10942 int *field_ptr = __builtin___bnd_copy_ptr_bounds (&objptr->int_field, 
10943                                                   objptr);
10944 @end smallexample
10946 @end deftypefn
10948 @deftypefn {Built-in Function} {void *} __builtin___bnd_init_ptr_bounds (const void *@var{q})
10950 This built-in function returns a new pointer with the value of @var{q}, and
10951 associates it with INIT (allowing full memory access) bounds. With Pointer
10952 Bounds Checker off, the built-in function just returns the first argument.
10954 @end deftypefn
10956 @deftypefn {Built-in Function} {void *} __builtin___bnd_null_ptr_bounds (const void *@var{q})
10958 This built-in function returns a new pointer with the value of @var{q}, and
10959 associates it with NULL (allowing no memory access) bounds. With Pointer
10960 Bounds Checker off, the built-in function just returns the first argument.
10962 @end deftypefn
10964 @deftypefn {Built-in Function} void __builtin___bnd_store_ptr_bounds (const void **@var{ptr_addr}, const void *@var{ptr_val})
10966 This built-in function stores the bounds associated with pointer @var{ptr_val}
10967 and location @var{ptr_addr} into Bounds Table.  This can be useful to propagate
10968 bounds from legacy code without touching the associated pointer's memory when
10969 pointers are copied as integers.  With Pointer Bounds Checker off, the built-in
10970 function call is ignored.
10972 @end deftypefn
10974 @deftypefn {Built-in Function} void __builtin___bnd_chk_ptr_lbounds (const void *@var{q})
10976 This built-in function checks if the pointer @var{q} is within the lower
10977 bound of its associated bounds.  With Pointer Bounds Checker off, the built-in
10978 function call is ignored.
10980 @smallexample
10981 extern void *__wrap_memset (void *dst, int c, size_t len)
10983   if (len > 0)
10984     @{
10985       __builtin___bnd_chk_ptr_lbounds (dst);
10986       __builtin___bnd_chk_ptr_ubounds ((char *)dst + len - 1);
10987       __real_memset (dst, c, len);
10988     @}
10989   return dst;
10991 @end smallexample
10993 @end deftypefn
10995 @deftypefn {Built-in Function} void __builtin___bnd_chk_ptr_ubounds (const void *@var{q})
10997 This built-in function checks if the pointer @var{q} is within the upper
10998 bound of its associated bounds.  With Pointer Bounds Checker off, the built-in
10999 function call is ignored.
11001 @end deftypefn
11003 @deftypefn {Built-in Function} void __builtin___bnd_chk_ptr_bounds (const void *@var{q}, size_t @var{size})
11005 This built-in function checks if [@var{q}, @var{q} + @var{size} - 1] is within
11006 the lower and upper bounds associated with @var{q}.  With Pointer Bounds Checker
11007 off, the built-in function call is ignored.
11009 @smallexample
11010 extern void *__wrap_memcpy (void *dst, const void *src, size_t n)
11012   if (n > 0)
11013     @{
11014       __bnd_chk_ptr_bounds (dst, n);
11015       __bnd_chk_ptr_bounds (src, n);
11016       __real_memcpy (dst, src, n);
11017     @}
11018   return dst;
11020 @end smallexample
11022 @end deftypefn
11024 @deftypefn {Built-in Function} {const void *} __builtin___bnd_get_ptr_lbound (const void *@var{q})
11026 This built-in function returns the lower bound associated
11027 with the pointer @var{q}, as a pointer value.  
11028 This is useful for debugging using @code{printf}.
11029 With Pointer Bounds Checker off, the built-in function returns 0.
11031 @smallexample
11032 void *lb = __builtin___bnd_get_ptr_lbound (q);
11033 void *ub = __builtin___bnd_get_ptr_ubound (q);
11034 printf ("q = %p  lb(q) = %p  ub(q) = %p", q, lb, ub);
11035 @end smallexample
11037 @end deftypefn
11039 @deftypefn {Built-in Function} {const void *} __builtin___bnd_get_ptr_ubound (const void *@var{q})
11041 This built-in function returns the upper bound (which is a pointer) associated
11042 with the pointer @var{q}.  With Pointer Bounds Checker off,
11043 the built-in function returns -1.
11045 @end deftypefn
11047 @node Other Builtins
11048 @section Other Built-in Functions Provided by GCC
11049 @cindex built-in functions
11050 @findex __builtin_alloca
11051 @findex __builtin_alloca_with_align
11052 @findex __builtin_alloca_with_align_and_max
11053 @findex __builtin_call_with_static_chain
11054 @findex __builtin_extend_pointer
11055 @findex __builtin_fpclassify
11056 @findex __builtin_isfinite
11057 @findex __builtin_isnormal
11058 @findex __builtin_isgreater
11059 @findex __builtin_isgreaterequal
11060 @findex __builtin_isinf_sign
11061 @findex __builtin_isless
11062 @findex __builtin_islessequal
11063 @findex __builtin_islessgreater
11064 @findex __builtin_isunordered
11065 @findex __builtin_powi
11066 @findex __builtin_powif
11067 @findex __builtin_powil
11068 @findex _Exit
11069 @findex _exit
11070 @findex abort
11071 @findex abs
11072 @findex acos
11073 @findex acosf
11074 @findex acosh
11075 @findex acoshf
11076 @findex acoshl
11077 @findex acosl
11078 @findex alloca
11079 @findex asin
11080 @findex asinf
11081 @findex asinh
11082 @findex asinhf
11083 @findex asinhl
11084 @findex asinl
11085 @findex atan
11086 @findex atan2
11087 @findex atan2f
11088 @findex atan2l
11089 @findex atanf
11090 @findex atanh
11091 @findex atanhf
11092 @findex atanhl
11093 @findex atanl
11094 @findex bcmp
11095 @findex bzero
11096 @findex cabs
11097 @findex cabsf
11098 @findex cabsl
11099 @findex cacos
11100 @findex cacosf
11101 @findex cacosh
11102 @findex cacoshf
11103 @findex cacoshl
11104 @findex cacosl
11105 @findex calloc
11106 @findex carg
11107 @findex cargf
11108 @findex cargl
11109 @findex casin
11110 @findex casinf
11111 @findex casinh
11112 @findex casinhf
11113 @findex casinhl
11114 @findex casinl
11115 @findex catan
11116 @findex catanf
11117 @findex catanh
11118 @findex catanhf
11119 @findex catanhl
11120 @findex catanl
11121 @findex cbrt
11122 @findex cbrtf
11123 @findex cbrtl
11124 @findex ccos
11125 @findex ccosf
11126 @findex ccosh
11127 @findex ccoshf
11128 @findex ccoshl
11129 @findex ccosl
11130 @findex ceil
11131 @findex ceilf
11132 @findex ceill
11133 @findex cexp
11134 @findex cexpf
11135 @findex cexpl
11136 @findex cimag
11137 @findex cimagf
11138 @findex cimagl
11139 @findex clog
11140 @findex clogf
11141 @findex clogl
11142 @findex clog10
11143 @findex clog10f
11144 @findex clog10l
11145 @findex conj
11146 @findex conjf
11147 @findex conjl
11148 @findex copysign
11149 @findex copysignf
11150 @findex copysignl
11151 @findex cos
11152 @findex cosf
11153 @findex cosh
11154 @findex coshf
11155 @findex coshl
11156 @findex cosl
11157 @findex cpow
11158 @findex cpowf
11159 @findex cpowl
11160 @findex cproj
11161 @findex cprojf
11162 @findex cprojl
11163 @findex creal
11164 @findex crealf
11165 @findex creall
11166 @findex csin
11167 @findex csinf
11168 @findex csinh
11169 @findex csinhf
11170 @findex csinhl
11171 @findex csinl
11172 @findex csqrt
11173 @findex csqrtf
11174 @findex csqrtl
11175 @findex ctan
11176 @findex ctanf
11177 @findex ctanh
11178 @findex ctanhf
11179 @findex ctanhl
11180 @findex ctanl
11181 @findex dcgettext
11182 @findex dgettext
11183 @findex drem
11184 @findex dremf
11185 @findex dreml
11186 @findex erf
11187 @findex erfc
11188 @findex erfcf
11189 @findex erfcl
11190 @findex erff
11191 @findex erfl
11192 @findex exit
11193 @findex exp
11194 @findex exp10
11195 @findex exp10f
11196 @findex exp10l
11197 @findex exp2
11198 @findex exp2f
11199 @findex exp2l
11200 @findex expf
11201 @findex expl
11202 @findex expm1
11203 @findex expm1f
11204 @findex expm1l
11205 @findex fabs
11206 @findex fabsf
11207 @findex fabsl
11208 @findex fdim
11209 @findex fdimf
11210 @findex fdiml
11211 @findex ffs
11212 @findex floor
11213 @findex floorf
11214 @findex floorl
11215 @findex fma
11216 @findex fmaf
11217 @findex fmal
11218 @findex fmax
11219 @findex fmaxf
11220 @findex fmaxl
11221 @findex fmin
11222 @findex fminf
11223 @findex fminl
11224 @findex fmod
11225 @findex fmodf
11226 @findex fmodl
11227 @findex fprintf
11228 @findex fprintf_unlocked
11229 @findex fputs
11230 @findex fputs_unlocked
11231 @findex frexp
11232 @findex frexpf
11233 @findex frexpl
11234 @findex fscanf
11235 @findex gamma
11236 @findex gammaf
11237 @findex gammal
11238 @findex gamma_r
11239 @findex gammaf_r
11240 @findex gammal_r
11241 @findex gettext
11242 @findex hypot
11243 @findex hypotf
11244 @findex hypotl
11245 @findex ilogb
11246 @findex ilogbf
11247 @findex ilogbl
11248 @findex imaxabs
11249 @findex index
11250 @findex isalnum
11251 @findex isalpha
11252 @findex isascii
11253 @findex isblank
11254 @findex iscntrl
11255 @findex isdigit
11256 @findex isgraph
11257 @findex islower
11258 @findex isprint
11259 @findex ispunct
11260 @findex isspace
11261 @findex isupper
11262 @findex iswalnum
11263 @findex iswalpha
11264 @findex iswblank
11265 @findex iswcntrl
11266 @findex iswdigit
11267 @findex iswgraph
11268 @findex iswlower
11269 @findex iswprint
11270 @findex iswpunct
11271 @findex iswspace
11272 @findex iswupper
11273 @findex iswxdigit
11274 @findex isxdigit
11275 @findex j0
11276 @findex j0f
11277 @findex j0l
11278 @findex j1
11279 @findex j1f
11280 @findex j1l
11281 @findex jn
11282 @findex jnf
11283 @findex jnl
11284 @findex labs
11285 @findex ldexp
11286 @findex ldexpf
11287 @findex ldexpl
11288 @findex lgamma
11289 @findex lgammaf
11290 @findex lgammal
11291 @findex lgamma_r
11292 @findex lgammaf_r
11293 @findex lgammal_r
11294 @findex llabs
11295 @findex llrint
11296 @findex llrintf
11297 @findex llrintl
11298 @findex llround
11299 @findex llroundf
11300 @findex llroundl
11301 @findex log
11302 @findex log10
11303 @findex log10f
11304 @findex log10l
11305 @findex log1p
11306 @findex log1pf
11307 @findex log1pl
11308 @findex log2
11309 @findex log2f
11310 @findex log2l
11311 @findex logb
11312 @findex logbf
11313 @findex logbl
11314 @findex logf
11315 @findex logl
11316 @findex lrint
11317 @findex lrintf
11318 @findex lrintl
11319 @findex lround
11320 @findex lroundf
11321 @findex lroundl
11322 @findex malloc
11323 @findex memchr
11324 @findex memcmp
11325 @findex memcpy
11326 @findex mempcpy
11327 @findex memset
11328 @findex modf
11329 @findex modff
11330 @findex modfl
11331 @findex nearbyint
11332 @findex nearbyintf
11333 @findex nearbyintl
11334 @findex nextafter
11335 @findex nextafterf
11336 @findex nextafterl
11337 @findex nexttoward
11338 @findex nexttowardf
11339 @findex nexttowardl
11340 @findex pow
11341 @findex pow10
11342 @findex pow10f
11343 @findex pow10l
11344 @findex powf
11345 @findex powl
11346 @findex printf
11347 @findex printf_unlocked
11348 @findex putchar
11349 @findex puts
11350 @findex remainder
11351 @findex remainderf
11352 @findex remainderl
11353 @findex remquo
11354 @findex remquof
11355 @findex remquol
11356 @findex rindex
11357 @findex rint
11358 @findex rintf
11359 @findex rintl
11360 @findex round
11361 @findex roundf
11362 @findex roundl
11363 @findex scalb
11364 @findex scalbf
11365 @findex scalbl
11366 @findex scalbln
11367 @findex scalblnf
11368 @findex scalblnf
11369 @findex scalbn
11370 @findex scalbnf
11371 @findex scanfnl
11372 @findex signbit
11373 @findex signbitf
11374 @findex signbitl
11375 @findex signbitd32
11376 @findex signbitd64
11377 @findex signbitd128
11378 @findex significand
11379 @findex significandf
11380 @findex significandl
11381 @findex sin
11382 @findex sincos
11383 @findex sincosf
11384 @findex sincosl
11385 @findex sinf
11386 @findex sinh
11387 @findex sinhf
11388 @findex sinhl
11389 @findex sinl
11390 @findex snprintf
11391 @findex sprintf
11392 @findex sqrt
11393 @findex sqrtf
11394 @findex sqrtl
11395 @findex sscanf
11396 @findex stpcpy
11397 @findex stpncpy
11398 @findex strcasecmp
11399 @findex strcat
11400 @findex strchr
11401 @findex strcmp
11402 @findex strcpy
11403 @findex strcspn
11404 @findex strdup
11405 @findex strfmon
11406 @findex strftime
11407 @findex strlen
11408 @findex strncasecmp
11409 @findex strncat
11410 @findex strncmp
11411 @findex strncpy
11412 @findex strndup
11413 @findex strpbrk
11414 @findex strrchr
11415 @findex strspn
11416 @findex strstr
11417 @findex tan
11418 @findex tanf
11419 @findex tanh
11420 @findex tanhf
11421 @findex tanhl
11422 @findex tanl
11423 @findex tgamma
11424 @findex tgammaf
11425 @findex tgammal
11426 @findex toascii
11427 @findex tolower
11428 @findex toupper
11429 @findex towlower
11430 @findex towupper
11431 @findex trunc
11432 @findex truncf
11433 @findex truncl
11434 @findex vfprintf
11435 @findex vfscanf
11436 @findex vprintf
11437 @findex vscanf
11438 @findex vsnprintf
11439 @findex vsprintf
11440 @findex vsscanf
11441 @findex y0
11442 @findex y0f
11443 @findex y0l
11444 @findex y1
11445 @findex y1f
11446 @findex y1l
11447 @findex yn
11448 @findex ynf
11449 @findex ynl
11451 GCC provides a large number of built-in functions other than the ones
11452 mentioned above.  Some of these are for internal use in the processing
11453 of exceptions or variable-length argument lists and are not
11454 documented here because they may change from time to time; we do not
11455 recommend general use of these functions.
11457 The remaining functions are provided for optimization purposes.
11459 With the exception of built-ins that have library equivalents such as
11460 the standard C library functions discussed below, or that expand to
11461 library calls, GCC built-in functions are always expanded inline and
11462 thus do not have corresponding entry points and their address cannot
11463 be obtained.  Attempting to use them in an expression other than
11464 a function call results in a compile-time error.
11466 @opindex fno-builtin
11467 GCC includes built-in versions of many of the functions in the standard
11468 C library.  These functions come in two forms: one whose names start with
11469 the @code{__builtin_} prefix, and the other without.  Both forms have the
11470 same type (including prototype), the same address (when their address is
11471 taken), and the same meaning as the C library functions even if you specify
11472 the @option{-fno-builtin} option @pxref{C Dialect Options}).  Many of these
11473 functions are only optimized in certain cases; if they are not optimized in
11474 a particular case, a call to the library function is emitted.
11476 @opindex ansi
11477 @opindex std
11478 Outside strict ISO C mode (@option{-ansi}, @option{-std=c90},
11479 @option{-std=c99} or @option{-std=c11}), the functions
11480 @code{_exit}, @code{alloca}, @code{bcmp}, @code{bzero},
11481 @code{dcgettext}, @code{dgettext}, @code{dremf}, @code{dreml},
11482 @code{drem}, @code{exp10f}, @code{exp10l}, @code{exp10}, @code{ffsll},
11483 @code{ffsl}, @code{ffs}, @code{fprintf_unlocked},
11484 @code{fputs_unlocked}, @code{gammaf}, @code{gammal}, @code{gamma},
11485 @code{gammaf_r}, @code{gammal_r}, @code{gamma_r}, @code{gettext},
11486 @code{index}, @code{isascii}, @code{j0f}, @code{j0l}, @code{j0},
11487 @code{j1f}, @code{j1l}, @code{j1}, @code{jnf}, @code{jnl}, @code{jn},
11488 @code{lgammaf_r}, @code{lgammal_r}, @code{lgamma_r}, @code{mempcpy},
11489 @code{pow10f}, @code{pow10l}, @code{pow10}, @code{printf_unlocked},
11490 @code{rindex}, @code{scalbf}, @code{scalbl}, @code{scalb},
11491 @code{signbit}, @code{signbitf}, @code{signbitl}, @code{signbitd32},
11492 @code{signbitd64}, @code{signbitd128}, @code{significandf},
11493 @code{significandl}, @code{significand}, @code{sincosf},
11494 @code{sincosl}, @code{sincos}, @code{stpcpy}, @code{stpncpy},
11495 @code{strcasecmp}, @code{strdup}, @code{strfmon}, @code{strncasecmp},
11496 @code{strndup}, @code{toascii}, @code{y0f}, @code{y0l}, @code{y0},
11497 @code{y1f}, @code{y1l}, @code{y1}, @code{ynf}, @code{ynl} and
11498 @code{yn}
11499 may be handled as built-in functions.
11500 All these functions have corresponding versions
11501 prefixed with @code{__builtin_}, which may be used even in strict C90
11502 mode.
11504 The ISO C99 functions
11505 @code{_Exit}, @code{acoshf}, @code{acoshl}, @code{acosh}, @code{asinhf},
11506 @code{asinhl}, @code{asinh}, @code{atanhf}, @code{atanhl}, @code{atanh},
11507 @code{cabsf}, @code{cabsl}, @code{cabs}, @code{cacosf}, @code{cacoshf},
11508 @code{cacoshl}, @code{cacosh}, @code{cacosl}, @code{cacos},
11509 @code{cargf}, @code{cargl}, @code{carg}, @code{casinf}, @code{casinhf},
11510 @code{casinhl}, @code{casinh}, @code{casinl}, @code{casin},
11511 @code{catanf}, @code{catanhf}, @code{catanhl}, @code{catanh},
11512 @code{catanl}, @code{catan}, @code{cbrtf}, @code{cbrtl}, @code{cbrt},
11513 @code{ccosf}, @code{ccoshf}, @code{ccoshl}, @code{ccosh}, @code{ccosl},
11514 @code{ccos}, @code{cexpf}, @code{cexpl}, @code{cexp}, @code{cimagf},
11515 @code{cimagl}, @code{cimag}, @code{clogf}, @code{clogl}, @code{clog},
11516 @code{conjf}, @code{conjl}, @code{conj}, @code{copysignf}, @code{copysignl},
11517 @code{copysign}, @code{cpowf}, @code{cpowl}, @code{cpow}, @code{cprojf},
11518 @code{cprojl}, @code{cproj}, @code{crealf}, @code{creall}, @code{creal},
11519 @code{csinf}, @code{csinhf}, @code{csinhl}, @code{csinh}, @code{csinl},
11520 @code{csin}, @code{csqrtf}, @code{csqrtl}, @code{csqrt}, @code{ctanf},
11521 @code{ctanhf}, @code{ctanhl}, @code{ctanh}, @code{ctanl}, @code{ctan},
11522 @code{erfcf}, @code{erfcl}, @code{erfc}, @code{erff}, @code{erfl},
11523 @code{erf}, @code{exp2f}, @code{exp2l}, @code{exp2}, @code{expm1f},
11524 @code{expm1l}, @code{expm1}, @code{fdimf}, @code{fdiml}, @code{fdim},
11525 @code{fmaf}, @code{fmal}, @code{fmaxf}, @code{fmaxl}, @code{fmax},
11526 @code{fma}, @code{fminf}, @code{fminl}, @code{fmin}, @code{hypotf},
11527 @code{hypotl}, @code{hypot}, @code{ilogbf}, @code{ilogbl}, @code{ilogb},
11528 @code{imaxabs}, @code{isblank}, @code{iswblank}, @code{lgammaf},
11529 @code{lgammal}, @code{lgamma}, @code{llabs}, @code{llrintf}, @code{llrintl},
11530 @code{llrint}, @code{llroundf}, @code{llroundl}, @code{llround},
11531 @code{log1pf}, @code{log1pl}, @code{log1p}, @code{log2f}, @code{log2l},
11532 @code{log2}, @code{logbf}, @code{logbl}, @code{logb}, @code{lrintf},
11533 @code{lrintl}, @code{lrint}, @code{lroundf}, @code{lroundl},
11534 @code{lround}, @code{nearbyintf}, @code{nearbyintl}, @code{nearbyint},
11535 @code{nextafterf}, @code{nextafterl}, @code{nextafter},
11536 @code{nexttowardf}, @code{nexttowardl}, @code{nexttoward},
11537 @code{remainderf}, @code{remainderl}, @code{remainder}, @code{remquof},
11538 @code{remquol}, @code{remquo}, @code{rintf}, @code{rintl}, @code{rint},
11539 @code{roundf}, @code{roundl}, @code{round}, @code{scalblnf},
11540 @code{scalblnl}, @code{scalbln}, @code{scalbnf}, @code{scalbnl},
11541 @code{scalbn}, @code{snprintf}, @code{tgammaf}, @code{tgammal},
11542 @code{tgamma}, @code{truncf}, @code{truncl}, @code{trunc},
11543 @code{vfscanf}, @code{vscanf}, @code{vsnprintf} and @code{vsscanf}
11544 are handled as built-in functions
11545 except in strict ISO C90 mode (@option{-ansi} or @option{-std=c90}).
11547 There are also built-in versions of the ISO C99 functions
11548 @code{acosf}, @code{acosl}, @code{asinf}, @code{asinl}, @code{atan2f},
11549 @code{atan2l}, @code{atanf}, @code{atanl}, @code{ceilf}, @code{ceill},
11550 @code{cosf}, @code{coshf}, @code{coshl}, @code{cosl}, @code{expf},
11551 @code{expl}, @code{fabsf}, @code{fabsl}, @code{floorf}, @code{floorl},
11552 @code{fmodf}, @code{fmodl}, @code{frexpf}, @code{frexpl}, @code{ldexpf},
11553 @code{ldexpl}, @code{log10f}, @code{log10l}, @code{logf}, @code{logl},
11554 @code{modfl}, @code{modf}, @code{powf}, @code{powl}, @code{sinf},
11555 @code{sinhf}, @code{sinhl}, @code{sinl}, @code{sqrtf}, @code{sqrtl},
11556 @code{tanf}, @code{tanhf}, @code{tanhl} and @code{tanl}
11557 that are recognized in any mode since ISO C90 reserves these names for
11558 the purpose to which ISO C99 puts them.  All these functions have
11559 corresponding versions prefixed with @code{__builtin_}.
11561 There are also built-in functions @code{__builtin_fabsf@var{n}},
11562 @code{__builtin_fabsf@var{n}x}, @code{__builtin_copysignf@var{n}} and
11563 @code{__builtin_copysignf@var{n}x}, corresponding to the TS 18661-3
11564 functions @code{fabsf@var{n}}, @code{fabsf@var{n}x},
11565 @code{copysignf@var{n}} and @code{copysignf@var{n}x}, for supported
11566 types @code{_Float@var{n}} and @code{_Float@var{n}x}.
11568 There are also GNU extension functions @code{clog10}, @code{clog10f} and
11569 @code{clog10l} which names are reserved by ISO C99 for future use.
11570 All these functions have versions prefixed with @code{__builtin_}.
11572 The ISO C94 functions
11573 @code{iswalnum}, @code{iswalpha}, @code{iswcntrl}, @code{iswdigit},
11574 @code{iswgraph}, @code{iswlower}, @code{iswprint}, @code{iswpunct},
11575 @code{iswspace}, @code{iswupper}, @code{iswxdigit}, @code{towlower} and
11576 @code{towupper}
11577 are handled as built-in functions
11578 except in strict ISO C90 mode (@option{-ansi} or @option{-std=c90}).
11580 The ISO C90 functions
11581 @code{abort}, @code{abs}, @code{acos}, @code{asin}, @code{atan2},
11582 @code{atan}, @code{calloc}, @code{ceil}, @code{cosh}, @code{cos},
11583 @code{exit}, @code{exp}, @code{fabs}, @code{floor}, @code{fmod},
11584 @code{fprintf}, @code{fputs}, @code{frexp}, @code{fscanf},
11585 @code{isalnum}, @code{isalpha}, @code{iscntrl}, @code{isdigit},
11586 @code{isgraph}, @code{islower}, @code{isprint}, @code{ispunct},
11587 @code{isspace}, @code{isupper}, @code{isxdigit}, @code{tolower},
11588 @code{toupper}, @code{labs}, @code{ldexp}, @code{log10}, @code{log},
11589 @code{malloc}, @code{memchr}, @code{memcmp}, @code{memcpy},
11590 @code{memset}, @code{modf}, @code{pow}, @code{printf}, @code{putchar},
11591 @code{puts}, @code{scanf}, @code{sinh}, @code{sin}, @code{snprintf},
11592 @code{sprintf}, @code{sqrt}, @code{sscanf}, @code{strcat},
11593 @code{strchr}, @code{strcmp}, @code{strcpy}, @code{strcspn},
11594 @code{strlen}, @code{strncat}, @code{strncmp}, @code{strncpy},
11595 @code{strpbrk}, @code{strrchr}, @code{strspn}, @code{strstr},
11596 @code{tanh}, @code{tan}, @code{vfprintf}, @code{vprintf} and @code{vsprintf}
11597 are all recognized as built-in functions unless
11598 @option{-fno-builtin} is specified (or @option{-fno-builtin-@var{function}}
11599 is specified for an individual function).  All of these functions have
11600 corresponding versions prefixed with @code{__builtin_}.
11602 GCC provides built-in versions of the ISO C99 floating-point comparison
11603 macros that avoid raising exceptions for unordered operands.  They have
11604 the same names as the standard macros ( @code{isgreater},
11605 @code{isgreaterequal}, @code{isless}, @code{islessequal},
11606 @code{islessgreater}, and @code{isunordered}) , with @code{__builtin_}
11607 prefixed.  We intend for a library implementor to be able to simply
11608 @code{#define} each standard macro to its built-in equivalent.
11609 In the same fashion, GCC provides @code{fpclassify}, @code{isfinite},
11610 @code{isinf_sign}, @code{isnormal} and @code{signbit} built-ins used with
11611 @code{__builtin_} prefixed.  The @code{isinf} and @code{isnan}
11612 built-in functions appear both with and without the @code{__builtin_} prefix.
11614 @deftypefn {Built-in Function} void *__builtin_alloca (size_t size)
11615 The @code{__builtin_alloca} function must be called at block scope.
11616 The function allocates an object @var{size} bytes large on the stack
11617 of the calling function.  The object is aligned on the default stack
11618 alignment boundary for the target determined by the
11619 @code{__BIGGEST_ALIGNMENT__} macro.  The @code{__builtin_alloca}
11620 function returns a pointer to the first byte of the allocated object.
11621 The lifetime of the allocated object ends just before the calling
11622 function returns to its caller.   This is so even when
11623 @code{__builtin_alloca} is called within a nested block.
11625 For example, the following function allocates eight objects of @code{n}
11626 bytes each on the stack, storing a pointer to each in consecutive elements
11627 of the array @code{a}.  It then passes the array to function @code{g}
11628 which can safely use the storage pointed to by each of the array elements.
11630 @smallexample
11631 void f (unsigned n)
11633   void *a [8];
11634   for (int i = 0; i != 8; ++i)
11635     a [i] = __builtin_alloca (n);
11637   g (a, n);   // @r{safe}
11639 @end smallexample
11641 Since the @code{__builtin_alloca} function doesn't validate its argument
11642 it is the responsibility of its caller to make sure the argument doesn't
11643 cause it to exceed the stack size limit.
11644 The @code{__builtin_alloca} function is provided to make it possible to
11645 allocate on the stack arrays of bytes with an upper bound that may be
11646 computed at run time.  Since C99 Variable Length Arrays offer
11647 similar functionality under a portable, more convenient, and safer
11648 interface they are recommended instead, in both C99 and C++ programs
11649 where GCC provides them as an extension.
11650 @xref{Variable Length}, for details.
11652 @end deftypefn
11654 @deftypefn {Built-in Function} void *__builtin_alloca_with_align (size_t size, size_t alignment)
11655 The @code{__builtin_alloca_with_align} function must be called at block
11656 scope.  The function allocates an object @var{size} bytes large on
11657 the stack of the calling function.  The allocated object is aligned on
11658 the boundary specified by the argument @var{alignment} whose unit is given
11659 in bits (not bytes).  The @var{size} argument must be positive and not
11660 exceed the stack size limit.  The @var{alignment} argument must be a constant
11661 integer expression that evaluates to a power of 2 greater than or equal to
11662 @code{CHAR_BIT} and less than some unspecified maximum.  Invocations
11663 with other values are rejected with an error indicating the valid bounds.
11664 The function returns a pointer to the first byte of the allocated object.
11665 The lifetime of the allocated object ends at the end of the block in which
11666 the function was called.  The allocated storage is released no later than
11667 just before the calling function returns to its caller, but may be released
11668 at the end of the block in which the function was called.
11670 For example, in the following function the call to @code{g} is unsafe
11671 because when @code{overalign} is non-zero, the space allocated by
11672 @code{__builtin_alloca_with_align} may have been released at the end
11673 of the @code{if} statement in which it was called.
11675 @smallexample
11676 void f (unsigned n, bool overalign)
11678   void *p;
11679   if (overalign)
11680     p = __builtin_alloca_with_align (n, 64 /* bits */);
11681   else
11682     p = __builtin_alloc (n);
11684   g (p, n);   // @r{unsafe}
11686 @end smallexample
11688 Since the @code{__builtin_alloca_with_align} function doesn't validate its
11689 @var{size} argument it is the responsibility of its caller to make sure
11690 the argument doesn't cause it to exceed the stack size limit.
11691 The @code{__builtin_alloca_with_align} function is provided to make
11692 it possible to allocate on the stack overaligned arrays of bytes with
11693 an upper bound that may be computed at run time.  Since C99
11694 Variable Length Arrays offer the same functionality under
11695 a portable, more convenient, and safer interface they are recommended
11696 instead, in both C99 and C++ programs where GCC provides them as
11697 an extension.  @xref{Variable Length}, for details.
11699 @end deftypefn
11701 @deftypefn {Built-in Function} void *__builtin_alloca_with_align_and_max (size_t size, size_t alignment, size_t max_size)
11702 Similar to @code{__builtin_alloca_with_align} but takes an extra argument
11703 specifying an upper bound for @var{size} in case its value cannot be computed
11704 at compile time, for use by @option{-fstack-usage}, @option{-Wstack-usage}
11705 and @option{-Walloca-larger-than}.  @var{max_size} must be a constant integer
11706 expression, it has no effect on code generation and no attempt is made to
11707 check its compatibility with @var{size}.
11709 @end deftypefn
11711 @deftypefn {Built-in Function} int __builtin_types_compatible_p (@var{type1}, @var{type2})
11713 You can use the built-in function @code{__builtin_types_compatible_p} to
11714 determine whether two types are the same.
11716 This built-in function returns 1 if the unqualified versions of the
11717 types @var{type1} and @var{type2} (which are types, not expressions) are
11718 compatible, 0 otherwise.  The result of this built-in function can be
11719 used in integer constant expressions.
11721 This built-in function ignores top level qualifiers (e.g., @code{const},
11722 @code{volatile}).  For example, @code{int} is equivalent to @code{const
11723 int}.
11725 The type @code{int[]} and @code{int[5]} are compatible.  On the other
11726 hand, @code{int} and @code{char *} are not compatible, even if the size
11727 of their types, on the particular architecture are the same.  Also, the
11728 amount of pointer indirection is taken into account when determining
11729 similarity.  Consequently, @code{short *} is not similar to
11730 @code{short **}.  Furthermore, two types that are typedefed are
11731 considered compatible if their underlying types are compatible.
11733 An @code{enum} type is not considered to be compatible with another
11734 @code{enum} type even if both are compatible with the same integer
11735 type; this is what the C standard specifies.
11736 For example, @code{enum @{foo, bar@}} is not similar to
11737 @code{enum @{hot, dog@}}.
11739 You typically use this function in code whose execution varies
11740 depending on the arguments' types.  For example:
11742 @smallexample
11743 #define foo(x)                                                  \
11744   (@{                                                           \
11745     typeof (x) tmp = (x);                                       \
11746     if (__builtin_types_compatible_p (typeof (x), long double)) \
11747       tmp = foo_long_double (tmp);                              \
11748     else if (__builtin_types_compatible_p (typeof (x), double)) \
11749       tmp = foo_double (tmp);                                   \
11750     else if (__builtin_types_compatible_p (typeof (x), float))  \
11751       tmp = foo_float (tmp);                                    \
11752     else                                                        \
11753       abort ();                                                 \
11754     tmp;                                                        \
11755   @})
11756 @end smallexample
11758 @emph{Note:} This construct is only available for C@.
11760 @end deftypefn
11762 @deftypefn {Built-in Function} @var{type} __builtin_call_with_static_chain (@var{call_exp}, @var{pointer_exp})
11764 The @var{call_exp} expression must be a function call, and the
11765 @var{pointer_exp} expression must be a pointer.  The @var{pointer_exp}
11766 is passed to the function call in the target's static chain location.
11767 The result of builtin is the result of the function call.
11769 @emph{Note:} This builtin is only available for C@.
11770 This builtin can be used to call Go closures from C.
11772 @end deftypefn
11774 @deftypefn {Built-in Function} @var{type} __builtin_choose_expr (@var{const_exp}, @var{exp1}, @var{exp2})
11776 You can use the built-in function @code{__builtin_choose_expr} to
11777 evaluate code depending on the value of a constant expression.  This
11778 built-in function returns @var{exp1} if @var{const_exp}, which is an
11779 integer constant expression, is nonzero.  Otherwise it returns @var{exp2}.
11781 This built-in function is analogous to the @samp{? :} operator in C,
11782 except that the expression returned has its type unaltered by promotion
11783 rules.  Also, the built-in function does not evaluate the expression
11784 that is not chosen.  For example, if @var{const_exp} evaluates to true,
11785 @var{exp2} is not evaluated even if it has side effects.
11787 This built-in function can return an lvalue if the chosen argument is an
11788 lvalue.
11790 If @var{exp1} is returned, the return type is the same as @var{exp1}'s
11791 type.  Similarly, if @var{exp2} is returned, its return type is the same
11792 as @var{exp2}.
11794 Example:
11796 @smallexample
11797 #define foo(x)                                                    \
11798   __builtin_choose_expr (                                         \
11799     __builtin_types_compatible_p (typeof (x), double),            \
11800     foo_double (x),                                               \
11801     __builtin_choose_expr (                                       \
11802       __builtin_types_compatible_p (typeof (x), float),           \
11803       foo_float (x),                                              \
11804       /* @r{The void expression results in a compile-time error}  \
11805          @r{when assigning the result to something.}  */          \
11806       (void)0))
11807 @end smallexample
11809 @emph{Note:} This construct is only available for C@.  Furthermore, the
11810 unused expression (@var{exp1} or @var{exp2} depending on the value of
11811 @var{const_exp}) may still generate syntax errors.  This may change in
11812 future revisions.
11814 @end deftypefn
11816 @deftypefn {Built-in Function} @var{type} __builtin_tgmath (@var{functions}, @var{arguments})
11818 The built-in function @code{__builtin_tgmath}, available only for C
11819 and Objective-C, calls a function determined according to the rules of
11820 @code{<tgmath.h>} macros.  It is intended to be used in
11821 implementations of that header, so that expansions of macros from that
11822 header only expand each of their arguments once, to avoid problems
11823 when calls to such macros are nested inside the arguments of other
11824 calls to such macros; in addition, it results in better diagnostics
11825 for invalid calls to @code{<tgmath.h>} macros than implementations
11826 using other GNU C language features.  For example, the @code{pow}
11827 type-generic macro might be defined as:
11829 @smallexample
11830 #define pow(a, b) __builtin_tgmath (powf, pow, powl, \
11831                                     cpowf, cpow, cpowl, a, b)
11832 @end smallexample
11834 The arguments to @code{__builtin_tgmath} are at least two pointers to
11835 functions, followed by the arguments to the type-generic macro (which
11836 will be passed as arguments to the selected function).  All the
11837 pointers to functions must be pointers to prototyped functions, none
11838 of which may have variable arguments, and all of which must have the
11839 same number of parameters; the number of parameters of the first
11840 function determines how many arguments to @code{__builtin_tgmath} are
11841 interpreted as function pointers, and how many as the arguments to the
11842 called function.
11844 The types of the specified functions must all be different, but
11845 related to each other in the same way as a set of functions that may
11846 be selected between by a macro in @code{<tgmath.h>}.  This means that
11847 the functions are parameterized by a floating-point type @var{t},
11848 different for each such function.  The function return types may all
11849 be the same type, or they may be @var{t} for each function, or they
11850 may be the real type corresponding to @var{t} for each function (if
11851 some of the types @var{t} are complex).  Likewise, for each parameter
11852 position, the type of the parameter in that position may always be the
11853 same type, or may be @var{t} for each function (this case must apply
11854 for at least one parameter position), or may be the real type
11855 corresponding to @var{t} for each function.
11857 The standard rules for @code{<tgmath.h>} macros are used to find a
11858 common type @var{u} from the types of the arguments for parameters
11859 whose types vary between the functions; complex integer types (a GNU
11860 extension) are treated like @code{_Complex double} for this purpose
11861 (or @code{_Complex _Float64} if all the function return types are the
11862 same @code{_Float@var{n}} or @code{_Float@var{n}x} type).
11863 If the function return types vary, or are all the same integer type,
11864 the function called is the one for which @var{t} is @var{u}, and it is
11865 an error if there is no such function.  If the function return types
11866 are all the same floating-point type, the type-generic macro is taken
11867 to be one of those from TS 18661 that rounds the result to a narrower
11868 type; if there is a function for which @var{t} is @var{u}, it is
11869 called, and otherwise the first function, if any, for which @var{t}
11870 has at least the range and precision of @var{u} is called, and it is
11871 an error if there is no such function.
11873 @end deftypefn
11875 @deftypefn {Built-in Function} @var{type} __builtin_complex (@var{real}, @var{imag})
11877 The built-in function @code{__builtin_complex} is provided for use in
11878 implementing the ISO C11 macros @code{CMPLXF}, @code{CMPLX} and
11879 @code{CMPLXL}.  @var{real} and @var{imag} must have the same type, a
11880 real binary floating-point type, and the result has the corresponding
11881 complex type with real and imaginary parts @var{real} and @var{imag}.
11882 Unlike @samp{@var{real} + I * @var{imag}}, this works even when
11883 infinities, NaNs and negative zeros are involved.
11885 @end deftypefn
11887 @deftypefn {Built-in Function} int __builtin_constant_p (@var{exp})
11888 You can use the built-in function @code{__builtin_constant_p} to
11889 determine if a value is known to be constant at compile time and hence
11890 that GCC can perform constant-folding on expressions involving that
11891 value.  The argument of the function is the value to test.  The function
11892 returns the integer 1 if the argument is known to be a compile-time
11893 constant and 0 if it is not known to be a compile-time constant.  A
11894 return of 0 does not indicate that the value is @emph{not} a constant,
11895 but merely that GCC cannot prove it is a constant with the specified
11896 value of the @option{-O} option.
11898 You typically use this function in an embedded application where
11899 memory is a critical resource.  If you have some complex calculation,
11900 you may want it to be folded if it involves constants, but need to call
11901 a function if it does not.  For example:
11903 @smallexample
11904 #define Scale_Value(X)      \
11905   (__builtin_constant_p (X) \
11906   ? ((X) * SCALE + OFFSET) : Scale (X))
11907 @end smallexample
11909 You may use this built-in function in either a macro or an inline
11910 function.  However, if you use it in an inlined function and pass an
11911 argument of the function as the argument to the built-in, GCC 
11912 never returns 1 when you call the inline function with a string constant
11913 or compound literal (@pxref{Compound Literals}) and does not return 1
11914 when you pass a constant numeric value to the inline function unless you
11915 specify the @option{-O} option.
11917 You may also use @code{__builtin_constant_p} in initializers for static
11918 data.  For instance, you can write
11920 @smallexample
11921 static const int table[] = @{
11922    __builtin_constant_p (EXPRESSION) ? (EXPRESSION) : -1,
11923    /* @r{@dots{}} */
11925 @end smallexample
11927 @noindent
11928 This is an acceptable initializer even if @var{EXPRESSION} is not a
11929 constant expression, including the case where
11930 @code{__builtin_constant_p} returns 1 because @var{EXPRESSION} can be
11931 folded to a constant but @var{EXPRESSION} contains operands that are
11932 not otherwise permitted in a static initializer (for example,
11933 @code{0 && foo ()}).  GCC must be more conservative about evaluating the
11934 built-in in this case, because it has no opportunity to perform
11935 optimization.
11936 @end deftypefn
11938 @deftypefn {Built-in Function} long __builtin_expect (long @var{exp}, long @var{c})
11939 @opindex fprofile-arcs
11940 You may use @code{__builtin_expect} to provide the compiler with
11941 branch prediction information.  In general, you should prefer to
11942 use actual profile feedback for this (@option{-fprofile-arcs}), as
11943 programmers are notoriously bad at predicting how their programs
11944 actually perform.  However, there are applications in which this
11945 data is hard to collect.
11947 The return value is the value of @var{exp}, which should be an integral
11948 expression.  The semantics of the built-in are that it is expected that
11949 @var{exp} == @var{c}.  For example:
11951 @smallexample
11952 if (__builtin_expect (x, 0))
11953   foo ();
11954 @end smallexample
11956 @noindent
11957 indicates that we do not expect to call @code{foo}, since
11958 we expect @code{x} to be zero.  Since you are limited to integral
11959 expressions for @var{exp}, you should use constructions such as
11961 @smallexample
11962 if (__builtin_expect (ptr != NULL, 1))
11963   foo (*ptr);
11964 @end smallexample
11966 @noindent
11967 when testing pointer or floating-point values.
11968 @end deftypefn
11970 @deftypefn {Built-in Function} void __builtin_trap (void)
11971 This function causes the program to exit abnormally.  GCC implements
11972 this function by using a target-dependent mechanism (such as
11973 intentionally executing an illegal instruction) or by calling
11974 @code{abort}.  The mechanism used may vary from release to release so
11975 you should not rely on any particular implementation.
11976 @end deftypefn
11978 @deftypefn {Built-in Function} void __builtin_unreachable (void)
11979 If control flow reaches the point of the @code{__builtin_unreachable},
11980 the program is undefined.  It is useful in situations where the
11981 compiler cannot deduce the unreachability of the code.
11983 One such case is immediately following an @code{asm} statement that
11984 either never terminates, or one that transfers control elsewhere
11985 and never returns.  In this example, without the
11986 @code{__builtin_unreachable}, GCC issues a warning that control
11987 reaches the end of a non-void function.  It also generates code
11988 to return after the @code{asm}.
11990 @smallexample
11991 int f (int c, int v)
11993   if (c)
11994     @{
11995       return v;
11996     @}
11997   else
11998     @{
11999       asm("jmp error_handler");
12000       __builtin_unreachable ();
12001     @}
12003 @end smallexample
12005 @noindent
12006 Because the @code{asm} statement unconditionally transfers control out
12007 of the function, control never reaches the end of the function
12008 body.  The @code{__builtin_unreachable} is in fact unreachable and
12009 communicates this fact to the compiler.
12011 Another use for @code{__builtin_unreachable} is following a call a
12012 function that never returns but that is not declared
12013 @code{__attribute__((noreturn))}, as in this example:
12015 @smallexample
12016 void function_that_never_returns (void);
12018 int g (int c)
12020   if (c)
12021     @{
12022       return 1;
12023     @}
12024   else
12025     @{
12026       function_that_never_returns ();
12027       __builtin_unreachable ();
12028     @}
12030 @end smallexample
12032 @end deftypefn
12034 @deftypefn {Built-in Function} {void *} __builtin_assume_aligned (const void *@var{exp}, size_t @var{align}, ...)
12035 This function returns its first argument, and allows the compiler
12036 to assume that the returned pointer is at least @var{align} bytes
12037 aligned.  This built-in can have either two or three arguments,
12038 if it has three, the third argument should have integer type, and
12039 if it is nonzero means misalignment offset.  For example:
12041 @smallexample
12042 void *x = __builtin_assume_aligned (arg, 16);
12043 @end smallexample
12045 @noindent
12046 means that the compiler can assume @code{x}, set to @code{arg}, is at least
12047 16-byte aligned, while:
12049 @smallexample
12050 void *x = __builtin_assume_aligned (arg, 32, 8);
12051 @end smallexample
12053 @noindent
12054 means that the compiler can assume for @code{x}, set to @code{arg}, that
12055 @code{(char *) x - 8} is 32-byte aligned.
12056 @end deftypefn
12058 @deftypefn {Built-in Function} int __builtin_LINE ()
12059 This function is the equivalent of the preprocessor @code{__LINE__}
12060 macro and returns a constant integer expression that evaluates to
12061 the line number of the invocation of the built-in.  When used as a C++
12062 default argument for a function @var{F}, it returns the line number
12063 of the call to @var{F}.
12064 @end deftypefn
12066 @deftypefn {Built-in Function} {const char *} __builtin_FUNCTION ()
12067 This function is the equivalent of the @code{__FUNCTION__} symbol
12068 and returns an address constant pointing to the name of the function
12069 from which the built-in was invoked, or the empty string if
12070 the invocation is not at function scope.  When used as a C++ default
12071 argument for a function @var{F}, it returns the name of @var{F}'s
12072 caller or the empty string if the call was not made at function
12073 scope.
12074 @end deftypefn
12076 @deftypefn {Built-in Function} {const char *} __builtin_FILE ()
12077 This function is the equivalent of the preprocessor @code{__FILE__}
12078 macro and returns an address constant pointing to the file name
12079 containing the invocation of the built-in, or the empty string if
12080 the invocation is not at function scope.  When used as a C++ default
12081 argument for a function @var{F}, it returns the file name of the call
12082 to @var{F} or the empty string if the call was not made at function
12083 scope.
12085 For example, in the following, each call to function @code{foo} will
12086 print a line similar to @code{"file.c:123: foo: message"} with the name
12087 of the file and the line number of the @code{printf} call, the name of
12088 the function @code{foo}, followed by the word @code{message}.
12090 @smallexample
12091 const char*
12092 function (const char *func = __builtin_FUNCTION ())
12094   return func;
12097 void foo (void)
12099   printf ("%s:%i: %s: message\n", file (), line (), function ());
12101 @end smallexample
12103 @end deftypefn
12105 @deftypefn {Built-in Function} void __builtin___clear_cache (char *@var{begin}, char *@var{end})
12106 This function is used to flush the processor's instruction cache for
12107 the region of memory between @var{begin} inclusive and @var{end}
12108 exclusive.  Some targets require that the instruction cache be
12109 flushed, after modifying memory containing code, in order to obtain
12110 deterministic behavior.
12112 If the target does not require instruction cache flushes,
12113 @code{__builtin___clear_cache} has no effect.  Otherwise either
12114 instructions are emitted in-line to clear the instruction cache or a
12115 call to the @code{__clear_cache} function in libgcc is made.
12116 @end deftypefn
12118 @deftypefn {Built-in Function} void __builtin_prefetch (const void *@var{addr}, ...)
12119 This function is used to minimize cache-miss latency by moving data into
12120 a cache before it is accessed.
12121 You can insert calls to @code{__builtin_prefetch} into code for which
12122 you know addresses of data in memory that is likely to be accessed soon.
12123 If the target supports them, data prefetch instructions are generated.
12124 If the prefetch is done early enough before the access then the data will
12125 be in the cache by the time it is accessed.
12127 The value of @var{addr} is the address of the memory to prefetch.
12128 There are two optional arguments, @var{rw} and @var{locality}.
12129 The value of @var{rw} is a compile-time constant one or zero; one
12130 means that the prefetch is preparing for a write to the memory address
12131 and zero, the default, means that the prefetch is preparing for a read.
12132 The value @var{locality} must be a compile-time constant integer between
12133 zero and three.  A value of zero means that the data has no temporal
12134 locality, so it need not be left in the cache after the access.  A value
12135 of three means that the data has a high degree of temporal locality and
12136 should be left in all levels of cache possible.  Values of one and two
12137 mean, respectively, a low or moderate degree of temporal locality.  The
12138 default is three.
12140 @smallexample
12141 for (i = 0; i < n; i++)
12142   @{
12143     a[i] = a[i] + b[i];
12144     __builtin_prefetch (&a[i+j], 1, 1);
12145     __builtin_prefetch (&b[i+j], 0, 1);
12146     /* @r{@dots{}} */
12147   @}
12148 @end smallexample
12150 Data prefetch does not generate faults if @var{addr} is invalid, but
12151 the address expression itself must be valid.  For example, a prefetch
12152 of @code{p->next} does not fault if @code{p->next} is not a valid
12153 address, but evaluation faults if @code{p} is not a valid address.
12155 If the target does not support data prefetch, the address expression
12156 is evaluated if it includes side effects but no other code is generated
12157 and GCC does not issue a warning.
12158 @end deftypefn
12160 @deftypefn {Built-in Function} double __builtin_huge_val (void)
12161 Returns a positive infinity, if supported by the floating-point format,
12162 else @code{DBL_MAX}.  This function is suitable for implementing the
12163 ISO C macro @code{HUGE_VAL}.
12164 @end deftypefn
12166 @deftypefn {Built-in Function} float __builtin_huge_valf (void)
12167 Similar to @code{__builtin_huge_val}, except the return type is @code{float}.
12168 @end deftypefn
12170 @deftypefn {Built-in Function} {long double} __builtin_huge_vall (void)
12171 Similar to @code{__builtin_huge_val}, except the return
12172 type is @code{long double}.
12173 @end deftypefn
12175 @deftypefn {Built-in Function} _Float@var{n} __builtin_huge_valf@var{n} (void)
12176 Similar to @code{__builtin_huge_val}, except the return type is
12177 @code{_Float@var{n}}.
12178 @end deftypefn
12180 @deftypefn {Built-in Function} _Float@var{n}x __builtin_huge_valf@var{n}x (void)
12181 Similar to @code{__builtin_huge_val}, except the return type is
12182 @code{_Float@var{n}x}.
12183 @end deftypefn
12185 @deftypefn {Built-in Function} int __builtin_fpclassify (int, int, int, int, int, ...)
12186 This built-in implements the C99 fpclassify functionality.  The first
12187 five int arguments should be the target library's notion of the
12188 possible FP classes and are used for return values.  They must be
12189 constant values and they must appear in this order: @code{FP_NAN},
12190 @code{FP_INFINITE}, @code{FP_NORMAL}, @code{FP_SUBNORMAL} and
12191 @code{FP_ZERO}.  The ellipsis is for exactly one floating-point value
12192 to classify.  GCC treats the last argument as type-generic, which
12193 means it does not do default promotion from float to double.
12194 @end deftypefn
12196 @deftypefn {Built-in Function} double __builtin_inf (void)
12197 Similar to @code{__builtin_huge_val}, except a warning is generated
12198 if the target floating-point format does not support infinities.
12199 @end deftypefn
12201 @deftypefn {Built-in Function} _Decimal32 __builtin_infd32 (void)
12202 Similar to @code{__builtin_inf}, except the return type is @code{_Decimal32}.
12203 @end deftypefn
12205 @deftypefn {Built-in Function} _Decimal64 __builtin_infd64 (void)
12206 Similar to @code{__builtin_inf}, except the return type is @code{_Decimal64}.
12207 @end deftypefn
12209 @deftypefn {Built-in Function} _Decimal128 __builtin_infd128 (void)
12210 Similar to @code{__builtin_inf}, except the return type is @code{_Decimal128}.
12211 @end deftypefn
12213 @deftypefn {Built-in Function} float __builtin_inff (void)
12214 Similar to @code{__builtin_inf}, except the return type is @code{float}.
12215 This function is suitable for implementing the ISO C99 macro @code{INFINITY}.
12216 @end deftypefn
12218 @deftypefn {Built-in Function} {long double} __builtin_infl (void)
12219 Similar to @code{__builtin_inf}, except the return
12220 type is @code{long double}.
12221 @end deftypefn
12223 @deftypefn {Built-in Function} _Float@var{n} __builtin_inff@var{n} (void)
12224 Similar to @code{__builtin_inf}, except the return
12225 type is @code{_Float@var{n}}.
12226 @end deftypefn
12228 @deftypefn {Built-in Function} _Float@var{n} __builtin_inff@var{n}x (void)
12229 Similar to @code{__builtin_inf}, except the return
12230 type is @code{_Float@var{n}x}.
12231 @end deftypefn
12233 @deftypefn {Built-in Function} int __builtin_isinf_sign (...)
12234 Similar to @code{isinf}, except the return value is -1 for
12235 an argument of @code{-Inf} and 1 for an argument of @code{+Inf}.
12236 Note while the parameter list is an
12237 ellipsis, this function only accepts exactly one floating-point
12238 argument.  GCC treats this parameter as type-generic, which means it
12239 does not do default promotion from float to double.
12240 @end deftypefn
12242 @deftypefn {Built-in Function} double __builtin_nan (const char *str)
12243 This is an implementation of the ISO C99 function @code{nan}.
12245 Since ISO C99 defines this function in terms of @code{strtod}, which we
12246 do not implement, a description of the parsing is in order.  The string
12247 is parsed as by @code{strtol}; that is, the base is recognized by
12248 leading @samp{0} or @samp{0x} prefixes.  The number parsed is placed
12249 in the significand such that the least significant bit of the number
12250 is at the least significant bit of the significand.  The number is
12251 truncated to fit the significand field provided.  The significand is
12252 forced to be a quiet NaN@.
12254 This function, if given a string literal all of which would have been
12255 consumed by @code{strtol}, is evaluated early enough that it is considered a
12256 compile-time constant.
12257 @end deftypefn
12259 @deftypefn {Built-in Function} _Decimal32 __builtin_nand32 (const char *str)
12260 Similar to @code{__builtin_nan}, except the return type is @code{_Decimal32}.
12261 @end deftypefn
12263 @deftypefn {Built-in Function} _Decimal64 __builtin_nand64 (const char *str)
12264 Similar to @code{__builtin_nan}, except the return type is @code{_Decimal64}.
12265 @end deftypefn
12267 @deftypefn {Built-in Function} _Decimal128 __builtin_nand128 (const char *str)
12268 Similar to @code{__builtin_nan}, except the return type is @code{_Decimal128}.
12269 @end deftypefn
12271 @deftypefn {Built-in Function} float __builtin_nanf (const char *str)
12272 Similar to @code{__builtin_nan}, except the return type is @code{float}.
12273 @end deftypefn
12275 @deftypefn {Built-in Function} {long double} __builtin_nanl (const char *str)
12276 Similar to @code{__builtin_nan}, except the return type is @code{long double}.
12277 @end deftypefn
12279 @deftypefn {Built-in Function} _Float@var{n} __builtin_nanf@var{n} (const char *str)
12280 Similar to @code{__builtin_nan}, except the return type is
12281 @code{_Float@var{n}}.
12282 @end deftypefn
12284 @deftypefn {Built-in Function} _Float@var{n}x __builtin_nanf@var{n}x (const char *str)
12285 Similar to @code{__builtin_nan}, except the return type is
12286 @code{_Float@var{n}x}.
12287 @end deftypefn
12289 @deftypefn {Built-in Function} double __builtin_nans (const char *str)
12290 Similar to @code{__builtin_nan}, except the significand is forced
12291 to be a signaling NaN@.  The @code{nans} function is proposed by
12292 @uref{http://www.open-std.org/jtc1/sc22/wg14/www/docs/n965.htm,,WG14 N965}.
12293 @end deftypefn
12295 @deftypefn {Built-in Function} float __builtin_nansf (const char *str)
12296 Similar to @code{__builtin_nans}, except the return type is @code{float}.
12297 @end deftypefn
12299 @deftypefn {Built-in Function} {long double} __builtin_nansl (const char *str)
12300 Similar to @code{__builtin_nans}, except the return type is @code{long double}.
12301 @end deftypefn
12303 @deftypefn {Built-in Function} _Float@var{n} __builtin_nansf@var{n} (const char *str)
12304 Similar to @code{__builtin_nans}, except the return type is
12305 @code{_Float@var{n}}.
12306 @end deftypefn
12308 @deftypefn {Built-in Function} _Float@var{n}x __builtin_nansf@var{n}x (const char *str)
12309 Similar to @code{__builtin_nans}, except the return type is
12310 @code{_Float@var{n}x}.
12311 @end deftypefn
12313 @deftypefn {Built-in Function} int __builtin_ffs (int x)
12314 Returns one plus the index of the least significant 1-bit of @var{x}, or
12315 if @var{x} is zero, returns zero.
12316 @end deftypefn
12318 @deftypefn {Built-in Function} int __builtin_clz (unsigned int x)
12319 Returns the number of leading 0-bits in @var{x}, starting at the most
12320 significant bit position.  If @var{x} is 0, the result is undefined.
12321 @end deftypefn
12323 @deftypefn {Built-in Function} int __builtin_ctz (unsigned int x)
12324 Returns the number of trailing 0-bits in @var{x}, starting at the least
12325 significant bit position.  If @var{x} is 0, the result is undefined.
12326 @end deftypefn
12328 @deftypefn {Built-in Function} int __builtin_clrsb (int x)
12329 Returns the number of leading redundant sign bits in @var{x}, i.e.@: the
12330 number of bits following the most significant bit that are identical
12331 to it.  There are no special cases for 0 or other values. 
12332 @end deftypefn
12334 @deftypefn {Built-in Function} int __builtin_popcount (unsigned int x)
12335 Returns the number of 1-bits in @var{x}.
12336 @end deftypefn
12338 @deftypefn {Built-in Function} int __builtin_parity (unsigned int x)
12339 Returns the parity of @var{x}, i.e.@: the number of 1-bits in @var{x}
12340 modulo 2.
12341 @end deftypefn
12343 @deftypefn {Built-in Function} int __builtin_ffsl (long)
12344 Similar to @code{__builtin_ffs}, except the argument type is
12345 @code{long}.
12346 @end deftypefn
12348 @deftypefn {Built-in Function} int __builtin_clzl (unsigned long)
12349 Similar to @code{__builtin_clz}, except the argument type is
12350 @code{unsigned long}.
12351 @end deftypefn
12353 @deftypefn {Built-in Function} int __builtin_ctzl (unsigned long)
12354 Similar to @code{__builtin_ctz}, except the argument type is
12355 @code{unsigned long}.
12356 @end deftypefn
12358 @deftypefn {Built-in Function} int __builtin_clrsbl (long)
12359 Similar to @code{__builtin_clrsb}, except the argument type is
12360 @code{long}.
12361 @end deftypefn
12363 @deftypefn {Built-in Function} int __builtin_popcountl (unsigned long)
12364 Similar to @code{__builtin_popcount}, except the argument type is
12365 @code{unsigned long}.
12366 @end deftypefn
12368 @deftypefn {Built-in Function} int __builtin_parityl (unsigned long)
12369 Similar to @code{__builtin_parity}, except the argument type is
12370 @code{unsigned long}.
12371 @end deftypefn
12373 @deftypefn {Built-in Function} int __builtin_ffsll (long long)
12374 Similar to @code{__builtin_ffs}, except the argument type is
12375 @code{long long}.
12376 @end deftypefn
12378 @deftypefn {Built-in Function} int __builtin_clzll (unsigned long long)
12379 Similar to @code{__builtin_clz}, except the argument type is
12380 @code{unsigned long long}.
12381 @end deftypefn
12383 @deftypefn {Built-in Function} int __builtin_ctzll (unsigned long long)
12384 Similar to @code{__builtin_ctz}, except the argument type is
12385 @code{unsigned long long}.
12386 @end deftypefn
12388 @deftypefn {Built-in Function} int __builtin_clrsbll (long long)
12389 Similar to @code{__builtin_clrsb}, except the argument type is
12390 @code{long long}.
12391 @end deftypefn
12393 @deftypefn {Built-in Function} int __builtin_popcountll (unsigned long long)
12394 Similar to @code{__builtin_popcount}, except the argument type is
12395 @code{unsigned long long}.
12396 @end deftypefn
12398 @deftypefn {Built-in Function} int __builtin_parityll (unsigned long long)
12399 Similar to @code{__builtin_parity}, except the argument type is
12400 @code{unsigned long long}.
12401 @end deftypefn
12403 @deftypefn {Built-in Function} double __builtin_powi (double, int)
12404 Returns the first argument raised to the power of the second.  Unlike the
12405 @code{pow} function no guarantees about precision and rounding are made.
12406 @end deftypefn
12408 @deftypefn {Built-in Function} float __builtin_powif (float, int)
12409 Similar to @code{__builtin_powi}, except the argument and return types
12410 are @code{float}.
12411 @end deftypefn
12413 @deftypefn {Built-in Function} {long double} __builtin_powil (long double, int)
12414 Similar to @code{__builtin_powi}, except the argument and return types
12415 are @code{long double}.
12416 @end deftypefn
12418 @deftypefn {Built-in Function} uint16_t __builtin_bswap16 (uint16_t x)
12419 Returns @var{x} with the order of the bytes reversed; for example,
12420 @code{0xaabb} becomes @code{0xbbaa}.  Byte here always means
12421 exactly 8 bits.
12422 @end deftypefn
12424 @deftypefn {Built-in Function} uint32_t __builtin_bswap32 (uint32_t x)
12425 Similar to @code{__builtin_bswap16}, except the argument and return types
12426 are 32 bit.
12427 @end deftypefn
12429 @deftypefn {Built-in Function} uint64_t __builtin_bswap64 (uint64_t x)
12430 Similar to @code{__builtin_bswap32}, except the argument and return types
12431 are 64 bit.
12432 @end deftypefn
12434 @deftypefn {Built-in Function} Pmode __builtin_extend_pointer (void * x)
12435 On targets where the user visible pointer size is smaller than the size
12436 of an actual hardware address this function returns the extended user
12437 pointer.  Targets where this is true included ILP32 mode on x86_64 or
12438 Aarch64.  This function is mainly useful when writing inline assembly
12439 code.
12440 @end deftypefn
12442 @deftypefn {Built-in Function} int __builtin_goacc_parlevel_id (int x)
12443 Returns the openacc gang, worker or vector id depending on whether @var{x} is
12444 0, 1 or 2.
12445 @end deftypefn
12447 @deftypefn {Built-in Function} int __builtin_goacc_parlevel_size (int x)
12448 Returns the openacc gang, worker or vector size depending on whether @var{x} is
12449 0, 1 or 2.
12450 @end deftypefn
12452 @node Target Builtins
12453 @section Built-in Functions Specific to Particular Target Machines
12455 On some target machines, GCC supports many built-in functions specific
12456 to those machines.  Generally these generate calls to specific machine
12457 instructions, but allow the compiler to schedule those calls.
12459 @menu
12460 * AArch64 Built-in Functions::
12461 * Alpha Built-in Functions::
12462 * Altera Nios II Built-in Functions::
12463 * ARC Built-in Functions::
12464 * ARC SIMD Built-in Functions::
12465 * ARM iWMMXt Built-in Functions::
12466 * ARM C Language Extensions (ACLE)::
12467 * ARM Floating Point Status and Control Intrinsics::
12468 * ARM ARMv8-M Security Extensions::
12469 * AVR Built-in Functions::
12470 * Blackfin Built-in Functions::
12471 * FR-V Built-in Functions::
12472 * MIPS DSP Built-in Functions::
12473 * MIPS Paired-Single Support::
12474 * MIPS Loongson Built-in Functions::
12475 * MIPS SIMD Architecture (MSA) Support::
12476 * Other MIPS Built-in Functions::
12477 * MSP430 Built-in Functions::
12478 * NDS32 Built-in Functions::
12479 * picoChip Built-in Functions::
12480 * Basic PowerPC Built-in Functions::
12481 * PowerPC AltiVec/VSX Built-in Functions::
12482 * PowerPC Hardware Transactional Memory Built-in Functions::
12483 * PowerPC Atomic Memory Operation Functions::
12484 * RX Built-in Functions::
12485 * S/390 System z Built-in Functions::
12486 * SH Built-in Functions::
12487 * SPARC VIS Built-in Functions::
12488 * SPU Built-in Functions::
12489 * TI C6X Built-in Functions::
12490 * TILE-Gx Built-in Functions::
12491 * TILEPro Built-in Functions::
12492 * x86 Built-in Functions::
12493 * x86 transactional memory intrinsics::
12494 * x86 control-flow protection intrinsics::
12495 @end menu
12497 @node AArch64 Built-in Functions
12498 @subsection AArch64 Built-in Functions
12500 These built-in functions are available for the AArch64 family of
12501 processors.
12502 @smallexample
12503 unsigned int __builtin_aarch64_get_fpcr ()
12504 void __builtin_aarch64_set_fpcr (unsigned int)
12505 unsigned int __builtin_aarch64_get_fpsr ()
12506 void __builtin_aarch64_set_fpsr (unsigned int)
12507 @end smallexample
12509 @node Alpha Built-in Functions
12510 @subsection Alpha Built-in Functions
12512 These built-in functions are available for the Alpha family of
12513 processors, depending on the command-line switches used.
12515 The following built-in functions are always available.  They
12516 all generate the machine instruction that is part of the name.
12518 @smallexample
12519 long __builtin_alpha_implver (void)
12520 long __builtin_alpha_rpcc (void)
12521 long __builtin_alpha_amask (long)
12522 long __builtin_alpha_cmpbge (long, long)
12523 long __builtin_alpha_extbl (long, long)
12524 long __builtin_alpha_extwl (long, long)
12525 long __builtin_alpha_extll (long, long)
12526 long __builtin_alpha_extql (long, long)
12527 long __builtin_alpha_extwh (long, long)
12528 long __builtin_alpha_extlh (long, long)
12529 long __builtin_alpha_extqh (long, long)
12530 long __builtin_alpha_insbl (long, long)
12531 long __builtin_alpha_inswl (long, long)
12532 long __builtin_alpha_insll (long, long)
12533 long __builtin_alpha_insql (long, long)
12534 long __builtin_alpha_inswh (long, long)
12535 long __builtin_alpha_inslh (long, long)
12536 long __builtin_alpha_insqh (long, long)
12537 long __builtin_alpha_mskbl (long, long)
12538 long __builtin_alpha_mskwl (long, long)
12539 long __builtin_alpha_mskll (long, long)
12540 long __builtin_alpha_mskql (long, long)
12541 long __builtin_alpha_mskwh (long, long)
12542 long __builtin_alpha_msklh (long, long)
12543 long __builtin_alpha_mskqh (long, long)
12544 long __builtin_alpha_umulh (long, long)
12545 long __builtin_alpha_zap (long, long)
12546 long __builtin_alpha_zapnot (long, long)
12547 @end smallexample
12549 The following built-in functions are always with @option{-mmax}
12550 or @option{-mcpu=@var{cpu}} where @var{cpu} is @code{pca56} or
12551 later.  They all generate the machine instruction that is part
12552 of the name.
12554 @smallexample
12555 long __builtin_alpha_pklb (long)
12556 long __builtin_alpha_pkwb (long)
12557 long __builtin_alpha_unpkbl (long)
12558 long __builtin_alpha_unpkbw (long)
12559 long __builtin_alpha_minub8 (long, long)
12560 long __builtin_alpha_minsb8 (long, long)
12561 long __builtin_alpha_minuw4 (long, long)
12562 long __builtin_alpha_minsw4 (long, long)
12563 long __builtin_alpha_maxub8 (long, long)
12564 long __builtin_alpha_maxsb8 (long, long)
12565 long __builtin_alpha_maxuw4 (long, long)
12566 long __builtin_alpha_maxsw4 (long, long)
12567 long __builtin_alpha_perr (long, long)
12568 @end smallexample
12570 The following built-in functions are always with @option{-mcix}
12571 or @option{-mcpu=@var{cpu}} where @var{cpu} is @code{ev67} or
12572 later.  They all generate the machine instruction that is part
12573 of the name.
12575 @smallexample
12576 long __builtin_alpha_cttz (long)
12577 long __builtin_alpha_ctlz (long)
12578 long __builtin_alpha_ctpop (long)
12579 @end smallexample
12581 The following built-in functions are available on systems that use the OSF/1
12582 PALcode.  Normally they invoke the @code{rduniq} and @code{wruniq}
12583 PAL calls, but when invoked with @option{-mtls-kernel}, they invoke
12584 @code{rdval} and @code{wrval}.
12586 @smallexample
12587 void *__builtin_thread_pointer (void)
12588 void __builtin_set_thread_pointer (void *)
12589 @end smallexample
12591 @node Altera Nios II Built-in Functions
12592 @subsection Altera Nios II Built-in Functions
12594 These built-in functions are available for the Altera Nios II
12595 family of processors.
12597 The following built-in functions are always available.  They
12598 all generate the machine instruction that is part of the name.
12600 @example
12601 int __builtin_ldbio (volatile const void *)
12602 int __builtin_ldbuio (volatile const void *)
12603 int __builtin_ldhio (volatile const void *)
12604 int __builtin_ldhuio (volatile const void *)
12605 int __builtin_ldwio (volatile const void *)
12606 void __builtin_stbio (volatile void *, int)
12607 void __builtin_sthio (volatile void *, int)
12608 void __builtin_stwio (volatile void *, int)
12609 void __builtin_sync (void)
12610 int __builtin_rdctl (int) 
12611 int __builtin_rdprs (int, int)
12612 void __builtin_wrctl (int, int)
12613 void __builtin_flushd (volatile void *)
12614 void __builtin_flushda (volatile void *)
12615 int __builtin_wrpie (int);
12616 void __builtin_eni (int);
12617 int __builtin_ldex (volatile const void *)
12618 int __builtin_stex (volatile void *, int)
12619 int __builtin_ldsex (volatile const void *)
12620 int __builtin_stsex (volatile void *, int)
12621 @end example
12623 The following built-in functions are always available.  They
12624 all generate a Nios II Custom Instruction. The name of the
12625 function represents the types that the function takes and
12626 returns. The letter before the @code{n} is the return type
12627 or void if absent. The @code{n} represents the first parameter
12628 to all the custom instructions, the custom instruction number.
12629 The two letters after the @code{n} represent the up to two
12630 parameters to the function.
12632 The letters represent the following data types:
12633 @table @code
12634 @item <no letter>
12635 @code{void} for return type and no parameter for parameter types.
12637 @item i
12638 @code{int} for return type and parameter type
12640 @item f
12641 @code{float} for return type and parameter type
12643 @item p
12644 @code{void *} for return type and parameter type
12646 @end table
12648 And the function names are:
12649 @example
12650 void __builtin_custom_n (void)
12651 void __builtin_custom_ni (int)
12652 void __builtin_custom_nf (float)
12653 void __builtin_custom_np (void *)
12654 void __builtin_custom_nii (int, int)
12655 void __builtin_custom_nif (int, float)
12656 void __builtin_custom_nip (int, void *)
12657 void __builtin_custom_nfi (float, int)
12658 void __builtin_custom_nff (float, float)
12659 void __builtin_custom_nfp (float, void *)
12660 void __builtin_custom_npi (void *, int)
12661 void __builtin_custom_npf (void *, float)
12662 void __builtin_custom_npp (void *, void *)
12663 int __builtin_custom_in (void)
12664 int __builtin_custom_ini (int)
12665 int __builtin_custom_inf (float)
12666 int __builtin_custom_inp (void *)
12667 int __builtin_custom_inii (int, int)
12668 int __builtin_custom_inif (int, float)
12669 int __builtin_custom_inip (int, void *)
12670 int __builtin_custom_infi (float, int)
12671 int __builtin_custom_inff (float, float)
12672 int __builtin_custom_infp (float, void *)
12673 int __builtin_custom_inpi (void *, int)
12674 int __builtin_custom_inpf (void *, float)
12675 int __builtin_custom_inpp (void *, void *)
12676 float __builtin_custom_fn (void)
12677 float __builtin_custom_fni (int)
12678 float __builtin_custom_fnf (float)
12679 float __builtin_custom_fnp (void *)
12680 float __builtin_custom_fnii (int, int)
12681 float __builtin_custom_fnif (int, float)
12682 float __builtin_custom_fnip (int, void *)
12683 float __builtin_custom_fnfi (float, int)
12684 float __builtin_custom_fnff (float, float)
12685 float __builtin_custom_fnfp (float, void *)
12686 float __builtin_custom_fnpi (void *, int)
12687 float __builtin_custom_fnpf (void *, float)
12688 float __builtin_custom_fnpp (void *, void *)
12689 void * __builtin_custom_pn (void)
12690 void * __builtin_custom_pni (int)
12691 void * __builtin_custom_pnf (float)
12692 void * __builtin_custom_pnp (void *)
12693 void * __builtin_custom_pnii (int, int)
12694 void * __builtin_custom_pnif (int, float)
12695 void * __builtin_custom_pnip (int, void *)
12696 void * __builtin_custom_pnfi (float, int)
12697 void * __builtin_custom_pnff (float, float)
12698 void * __builtin_custom_pnfp (float, void *)
12699 void * __builtin_custom_pnpi (void *, int)
12700 void * __builtin_custom_pnpf (void *, float)
12701 void * __builtin_custom_pnpp (void *, void *)
12702 @end example
12704 @node ARC Built-in Functions
12705 @subsection ARC Built-in Functions
12707 The following built-in functions are provided for ARC targets.  The
12708 built-ins generate the corresponding assembly instructions.  In the
12709 examples given below, the generated code often requires an operand or
12710 result to be in a register.  Where necessary further code will be
12711 generated to ensure this is true, but for brevity this is not
12712 described in each case.
12714 @emph{Note:} Using a built-in to generate an instruction not supported
12715 by a target may cause problems. At present the compiler is not
12716 guaranteed to detect such misuse, and as a result an internal compiler
12717 error may be generated.
12719 @deftypefn {Built-in Function} int __builtin_arc_aligned (void *@var{val}, int @var{alignval})
12720 Return 1 if @var{val} is known to have the byte alignment given
12721 by @var{alignval}, otherwise return 0.
12722 Note that this is different from
12723 @smallexample
12724 __alignof__(*(char *)@var{val}) >= alignval
12725 @end smallexample
12726 because __alignof__ sees only the type of the dereference, whereas
12727 __builtin_arc_align uses alignment information from the pointer
12728 as well as from the pointed-to type.
12729 The information available will depend on optimization level.
12730 @end deftypefn
12732 @deftypefn {Built-in Function} void __builtin_arc_brk (void)
12733 Generates
12734 @example
12736 @end example
12737 @end deftypefn
12739 @deftypefn {Built-in Function} {unsigned int} __builtin_arc_core_read (unsigned int @var{regno})
12740 The operand is the number of a register to be read.  Generates:
12741 @example
12742 mov  @var{dest}, r@var{regno}
12743 @end example
12744 where the value in @var{dest} will be the result returned from the
12745 built-in.
12746 @end deftypefn
12748 @deftypefn {Built-in Function} void __builtin_arc_core_write (unsigned int @var{regno}, unsigned int @var{val})
12749 The first operand is the number of a register to be written, the
12750 second operand is a compile time constant to write into that
12751 register.  Generates:
12752 @example
12753 mov  r@var{regno}, @var{val}
12754 @end example
12755 @end deftypefn
12757 @deftypefn {Built-in Function} int __builtin_arc_divaw (int @var{a}, int @var{b})
12758 Only available if either @option{-mcpu=ARC700} or @option{-meA} is set.
12759 Generates:
12760 @example
12761 divaw  @var{dest}, @var{a}, @var{b}
12762 @end example
12763 where the value in @var{dest} will be the result returned from the
12764 built-in.
12765 @end deftypefn
12767 @deftypefn {Built-in Function} void __builtin_arc_flag (unsigned int @var{a})
12768 Generates
12769 @example
12770 flag  @var{a}
12771 @end example
12772 @end deftypefn
12774 @deftypefn {Built-in Function} {unsigned int} __builtin_arc_lr (unsigned int @var{auxr})
12775 The operand, @var{auxv}, is the address of an auxiliary register and
12776 must be a compile time constant.  Generates:
12777 @example
12778 lr  @var{dest}, [@var{auxr}]
12779 @end example
12780 Where the value in @var{dest} will be the result returned from the
12781 built-in.
12782 @end deftypefn
12784 @deftypefn {Built-in Function} void __builtin_arc_mul64 (int @var{a}, int @var{b})
12785 Only available with @option{-mmul64}.  Generates:
12786 @example
12787 mul64  @var{a}, @var{b}
12788 @end example
12789 @end deftypefn
12791 @deftypefn {Built-in Function} void __builtin_arc_mulu64 (unsigned int @var{a}, unsigned int @var{b})
12792 Only available with @option{-mmul64}.  Generates:
12793 @example
12794 mulu64  @var{a}, @var{b}
12795 @end example
12796 @end deftypefn
12798 @deftypefn {Built-in Function} void __builtin_arc_nop (void)
12799 Generates:
12800 @example
12802 @end example
12803 @end deftypefn
12805 @deftypefn {Built-in Function} int __builtin_arc_norm (int @var{src})
12806 Only valid if the @samp{norm} instruction is available through the
12807 @option{-mnorm} option or by default with @option{-mcpu=ARC700}.
12808 Generates:
12809 @example
12810 norm  @var{dest}, @var{src}
12811 @end example
12812 Where the value in @var{dest} will be the result returned from the
12813 built-in.
12814 @end deftypefn
12816 @deftypefn {Built-in Function}  {short int} __builtin_arc_normw (short int @var{src})
12817 Only valid if the @samp{normw} instruction is available through the
12818 @option{-mnorm} option or by default with @option{-mcpu=ARC700}.
12819 Generates:
12820 @example
12821 normw  @var{dest}, @var{src}
12822 @end example
12823 Where the value in @var{dest} will be the result returned from the
12824 built-in.
12825 @end deftypefn
12827 @deftypefn {Built-in Function}  void __builtin_arc_rtie (void)
12828 Generates:
12829 @example
12830 rtie
12831 @end example
12832 @end deftypefn
12834 @deftypefn {Built-in Function}  void __builtin_arc_sleep (int @var{a}
12835 Generates:
12836 @example
12837 sleep  @var{a}
12838 @end example
12839 @end deftypefn
12841 @deftypefn {Built-in Function}  void __builtin_arc_sr (unsigned int @var{auxr}, unsigned int @var{val})
12842 The first argument, @var{auxv}, is the address of an auxiliary
12843 register, the second argument, @var{val}, is a compile time constant
12844 to be written to the register.  Generates:
12845 @example
12846 sr  @var{auxr}, [@var{val}]
12847 @end example
12848 @end deftypefn
12850 @deftypefn {Built-in Function}  int __builtin_arc_swap (int @var{src})
12851 Only valid with @option{-mswap}.  Generates:
12852 @example
12853 swap  @var{dest}, @var{src}
12854 @end example
12855 Where the value in @var{dest} will be the result returned from the
12856 built-in.
12857 @end deftypefn
12859 @deftypefn {Built-in Function}  void __builtin_arc_swi (void)
12860 Generates:
12861 @example
12863 @end example
12864 @end deftypefn
12866 @deftypefn {Built-in Function}  void __builtin_arc_sync (void)
12867 Only available with @option{-mcpu=ARC700}.  Generates:
12868 @example
12869 sync
12870 @end example
12871 @end deftypefn
12873 @deftypefn {Built-in Function}  void __builtin_arc_trap_s (unsigned int @var{c})
12874 Only available with @option{-mcpu=ARC700}.  Generates:
12875 @example
12876 trap_s  @var{c}
12877 @end example
12878 @end deftypefn
12880 @deftypefn {Built-in Function}  void __builtin_arc_unimp_s (void)
12881 Only available with @option{-mcpu=ARC700}.  Generates:
12882 @example
12883 unimp_s
12884 @end example
12885 @end deftypefn
12887 The instructions generated by the following builtins are not
12888 considered as candidates for scheduling.  They are not moved around by
12889 the compiler during scheduling, and thus can be expected to appear
12890 where they are put in the C code:
12891 @example
12892 __builtin_arc_brk()
12893 __builtin_arc_core_read()
12894 __builtin_arc_core_write()
12895 __builtin_arc_flag()
12896 __builtin_arc_lr()
12897 __builtin_arc_sleep()
12898 __builtin_arc_sr()
12899 __builtin_arc_swi()
12900 @end example
12902 @node ARC SIMD Built-in Functions
12903 @subsection ARC SIMD Built-in Functions
12905 SIMD builtins provided by the compiler can be used to generate the
12906 vector instructions.  This section describes the available builtins
12907 and their usage in programs.  With the @option{-msimd} option, the
12908 compiler provides 128-bit vector types, which can be specified using
12909 the @code{vector_size} attribute.  The header file @file{arc-simd.h}
12910 can be included to use the following predefined types:
12911 @example
12912 typedef int __v4si   __attribute__((vector_size(16)));
12913 typedef short __v8hi __attribute__((vector_size(16)));
12914 @end example
12916 These types can be used to define 128-bit variables.  The built-in
12917 functions listed in the following section can be used on these
12918 variables to generate the vector operations.
12920 For all builtins, @code{__builtin_arc_@var{someinsn}}, the header file
12921 @file{arc-simd.h} also provides equivalent macros called
12922 @code{_@var{someinsn}} that can be used for programming ease and
12923 improved readability.  The following macros for DMA control are also
12924 provided:
12925 @example
12926 #define _setup_dma_in_channel_reg _vdiwr
12927 #define _setup_dma_out_channel_reg _vdowr
12928 @end example
12930 The following is a complete list of all the SIMD built-ins provided
12931 for ARC, grouped by calling signature.
12933 The following take two @code{__v8hi} arguments and return a
12934 @code{__v8hi} result:
12935 @example
12936 __v8hi __builtin_arc_vaddaw (__v8hi, __v8hi)
12937 __v8hi __builtin_arc_vaddw (__v8hi, __v8hi)
12938 __v8hi __builtin_arc_vand (__v8hi, __v8hi)
12939 __v8hi __builtin_arc_vandaw (__v8hi, __v8hi)
12940 __v8hi __builtin_arc_vavb (__v8hi, __v8hi)
12941 __v8hi __builtin_arc_vavrb (__v8hi, __v8hi)
12942 __v8hi __builtin_arc_vbic (__v8hi, __v8hi)
12943 __v8hi __builtin_arc_vbicaw (__v8hi, __v8hi)
12944 __v8hi __builtin_arc_vdifaw (__v8hi, __v8hi)
12945 __v8hi __builtin_arc_vdifw (__v8hi, __v8hi)
12946 __v8hi __builtin_arc_veqw (__v8hi, __v8hi)
12947 __v8hi __builtin_arc_vh264f (__v8hi, __v8hi)
12948 __v8hi __builtin_arc_vh264ft (__v8hi, __v8hi)
12949 __v8hi __builtin_arc_vh264fw (__v8hi, __v8hi)
12950 __v8hi __builtin_arc_vlew (__v8hi, __v8hi)
12951 __v8hi __builtin_arc_vltw (__v8hi, __v8hi)
12952 __v8hi __builtin_arc_vmaxaw (__v8hi, __v8hi)
12953 __v8hi __builtin_arc_vmaxw (__v8hi, __v8hi)
12954 __v8hi __builtin_arc_vminaw (__v8hi, __v8hi)
12955 __v8hi __builtin_arc_vminw (__v8hi, __v8hi)
12956 __v8hi __builtin_arc_vmr1aw (__v8hi, __v8hi)
12957 __v8hi __builtin_arc_vmr1w (__v8hi, __v8hi)
12958 __v8hi __builtin_arc_vmr2aw (__v8hi, __v8hi)
12959 __v8hi __builtin_arc_vmr2w (__v8hi, __v8hi)
12960 __v8hi __builtin_arc_vmr3aw (__v8hi, __v8hi)
12961 __v8hi __builtin_arc_vmr3w (__v8hi, __v8hi)
12962 __v8hi __builtin_arc_vmr4aw (__v8hi, __v8hi)
12963 __v8hi __builtin_arc_vmr4w (__v8hi, __v8hi)
12964 __v8hi __builtin_arc_vmr5aw (__v8hi, __v8hi)
12965 __v8hi __builtin_arc_vmr5w (__v8hi, __v8hi)
12966 __v8hi __builtin_arc_vmr6aw (__v8hi, __v8hi)
12967 __v8hi __builtin_arc_vmr6w (__v8hi, __v8hi)
12968 __v8hi __builtin_arc_vmr7aw (__v8hi, __v8hi)
12969 __v8hi __builtin_arc_vmr7w (__v8hi, __v8hi)
12970 __v8hi __builtin_arc_vmrb (__v8hi, __v8hi)
12971 __v8hi __builtin_arc_vmulaw (__v8hi, __v8hi)
12972 __v8hi __builtin_arc_vmulfaw (__v8hi, __v8hi)
12973 __v8hi __builtin_arc_vmulfw (__v8hi, __v8hi)
12974 __v8hi __builtin_arc_vmulw (__v8hi, __v8hi)
12975 __v8hi __builtin_arc_vnew (__v8hi, __v8hi)
12976 __v8hi __builtin_arc_vor (__v8hi, __v8hi)
12977 __v8hi __builtin_arc_vsubaw (__v8hi, __v8hi)
12978 __v8hi __builtin_arc_vsubw (__v8hi, __v8hi)
12979 __v8hi __builtin_arc_vsummw (__v8hi, __v8hi)
12980 __v8hi __builtin_arc_vvc1f (__v8hi, __v8hi)
12981 __v8hi __builtin_arc_vvc1ft (__v8hi, __v8hi)
12982 __v8hi __builtin_arc_vxor (__v8hi, __v8hi)
12983 __v8hi __builtin_arc_vxoraw (__v8hi, __v8hi)
12984 @end example
12986 The following take one @code{__v8hi} and one @code{int} argument and return a
12987 @code{__v8hi} result:
12989 @example
12990 __v8hi __builtin_arc_vbaddw (__v8hi, int)
12991 __v8hi __builtin_arc_vbmaxw (__v8hi, int)
12992 __v8hi __builtin_arc_vbminw (__v8hi, int)
12993 __v8hi __builtin_arc_vbmulaw (__v8hi, int)
12994 __v8hi __builtin_arc_vbmulfw (__v8hi, int)
12995 __v8hi __builtin_arc_vbmulw (__v8hi, int)
12996 __v8hi __builtin_arc_vbrsubw (__v8hi, int)
12997 __v8hi __builtin_arc_vbsubw (__v8hi, int)
12998 @end example
13000 The following take one @code{__v8hi} argument and one @code{int} argument which
13001 must be a 3-bit compile time constant indicating a register number
13002 I0-I7.  They return a @code{__v8hi} result.
13003 @example
13004 __v8hi __builtin_arc_vasrw (__v8hi, const int)
13005 __v8hi __builtin_arc_vsr8 (__v8hi, const int)
13006 __v8hi __builtin_arc_vsr8aw (__v8hi, const int)
13007 @end example
13009 The following take one @code{__v8hi} argument and one @code{int}
13010 argument which must be a 6-bit compile time constant.  They return a
13011 @code{__v8hi} result.
13012 @example
13013 __v8hi __builtin_arc_vasrpwbi (__v8hi, const int)
13014 __v8hi __builtin_arc_vasrrpwbi (__v8hi, const int)
13015 __v8hi __builtin_arc_vasrrwi (__v8hi, const int)
13016 __v8hi __builtin_arc_vasrsrwi (__v8hi, const int)
13017 __v8hi __builtin_arc_vasrwi (__v8hi, const int)
13018 __v8hi __builtin_arc_vsr8awi (__v8hi, const int)
13019 __v8hi __builtin_arc_vsr8i (__v8hi, const int)
13020 @end example
13022 The following take one @code{__v8hi} argument and one @code{int} argument which
13023 must be a 8-bit compile time constant.  They return a @code{__v8hi}
13024 result.
13025 @example
13026 __v8hi __builtin_arc_vd6tapf (__v8hi, const int)
13027 __v8hi __builtin_arc_vmvaw (__v8hi, const int)
13028 __v8hi __builtin_arc_vmvw (__v8hi, const int)
13029 __v8hi __builtin_arc_vmvzw (__v8hi, const int)
13030 @end example
13032 The following take two @code{int} arguments, the second of which which
13033 must be a 8-bit compile time constant.  They return a @code{__v8hi}
13034 result:
13035 @example
13036 __v8hi __builtin_arc_vmovaw (int, const int)
13037 __v8hi __builtin_arc_vmovw (int, const int)
13038 __v8hi __builtin_arc_vmovzw (int, const int)
13039 @end example
13041 The following take a single @code{__v8hi} argument and return a
13042 @code{__v8hi} result:
13043 @example
13044 __v8hi __builtin_arc_vabsaw (__v8hi)
13045 __v8hi __builtin_arc_vabsw (__v8hi)
13046 __v8hi __builtin_arc_vaddsuw (__v8hi)
13047 __v8hi __builtin_arc_vexch1 (__v8hi)
13048 __v8hi __builtin_arc_vexch2 (__v8hi)
13049 __v8hi __builtin_arc_vexch4 (__v8hi)
13050 __v8hi __builtin_arc_vsignw (__v8hi)
13051 __v8hi __builtin_arc_vupbaw (__v8hi)
13052 __v8hi __builtin_arc_vupbw (__v8hi)
13053 __v8hi __builtin_arc_vupsbaw (__v8hi)
13054 __v8hi __builtin_arc_vupsbw (__v8hi)
13055 @end example
13057 The following take two @code{int} arguments and return no result:
13058 @example
13059 void __builtin_arc_vdirun (int, int)
13060 void __builtin_arc_vdorun (int, int)
13061 @end example
13063 The following take two @code{int} arguments and return no result.  The
13064 first argument must a 3-bit compile time constant indicating one of
13065 the DR0-DR7 DMA setup channels:
13066 @example
13067 void __builtin_arc_vdiwr (const int, int)
13068 void __builtin_arc_vdowr (const int, int)
13069 @end example
13071 The following take an @code{int} argument and return no result:
13072 @example
13073 void __builtin_arc_vendrec (int)
13074 void __builtin_arc_vrec (int)
13075 void __builtin_arc_vrecrun (int)
13076 void __builtin_arc_vrun (int)
13077 @end example
13079 The following take a @code{__v8hi} argument and two @code{int}
13080 arguments and return a @code{__v8hi} result.  The second argument must
13081 be a 3-bit compile time constants, indicating one the registers I0-I7,
13082 and the third argument must be an 8-bit compile time constant.
13084 @emph{Note:} Although the equivalent hardware instructions do not take
13085 an SIMD register as an operand, these builtins overwrite the relevant
13086 bits of the @code{__v8hi} register provided as the first argument with
13087 the value loaded from the @code{[Ib, u8]} location in the SDM.
13089 @example
13090 __v8hi __builtin_arc_vld32 (__v8hi, const int, const int)
13091 __v8hi __builtin_arc_vld32wh (__v8hi, const int, const int)
13092 __v8hi __builtin_arc_vld32wl (__v8hi, const int, const int)
13093 __v8hi __builtin_arc_vld64 (__v8hi, const int, const int)
13094 @end example
13096 The following take two @code{int} arguments and return a @code{__v8hi}
13097 result.  The first argument must be a 3-bit compile time constants,
13098 indicating one the registers I0-I7, and the second argument must be an
13099 8-bit compile time constant.
13101 @example
13102 __v8hi __builtin_arc_vld128 (const int, const int)
13103 __v8hi __builtin_arc_vld64w (const int, const int)
13104 @end example
13106 The following take a @code{__v8hi} argument and two @code{int}
13107 arguments and return no result.  The second argument must be a 3-bit
13108 compile time constants, indicating one the registers I0-I7, and the
13109 third argument must be an 8-bit compile time constant.
13111 @example
13112 void __builtin_arc_vst128 (__v8hi, const int, const int)
13113 void __builtin_arc_vst64 (__v8hi, const int, const int)
13114 @end example
13116 The following take a @code{__v8hi} argument and three @code{int}
13117 arguments and return no result.  The second argument must be a 3-bit
13118 compile-time constant, identifying the 16-bit sub-register to be
13119 stored, the third argument must be a 3-bit compile time constants,
13120 indicating one the registers I0-I7, and the fourth argument must be an
13121 8-bit compile time constant.
13123 @example
13124 void __builtin_arc_vst16_n (__v8hi, const int, const int, const int)
13125 void __builtin_arc_vst32_n (__v8hi, const int, const int, const int)
13126 @end example
13128 @node ARM iWMMXt Built-in Functions
13129 @subsection ARM iWMMXt Built-in Functions
13131 These built-in functions are available for the ARM family of
13132 processors when the @option{-mcpu=iwmmxt} switch is used:
13134 @smallexample
13135 typedef int v2si __attribute__ ((vector_size (8)));
13136 typedef short v4hi __attribute__ ((vector_size (8)));
13137 typedef char v8qi __attribute__ ((vector_size (8)));
13139 int __builtin_arm_getwcgr0 (void)
13140 void __builtin_arm_setwcgr0 (int)
13141 int __builtin_arm_getwcgr1 (void)
13142 void __builtin_arm_setwcgr1 (int)
13143 int __builtin_arm_getwcgr2 (void)
13144 void __builtin_arm_setwcgr2 (int)
13145 int __builtin_arm_getwcgr3 (void)
13146 void __builtin_arm_setwcgr3 (int)
13147 int __builtin_arm_textrmsb (v8qi, int)
13148 int __builtin_arm_textrmsh (v4hi, int)
13149 int __builtin_arm_textrmsw (v2si, int)
13150 int __builtin_arm_textrmub (v8qi, int)
13151 int __builtin_arm_textrmuh (v4hi, int)
13152 int __builtin_arm_textrmuw (v2si, int)
13153 v8qi __builtin_arm_tinsrb (v8qi, int, int)
13154 v4hi __builtin_arm_tinsrh (v4hi, int, int)
13155 v2si __builtin_arm_tinsrw (v2si, int, int)
13156 long long __builtin_arm_tmia (long long, int, int)
13157 long long __builtin_arm_tmiabb (long long, int, int)
13158 long long __builtin_arm_tmiabt (long long, int, int)
13159 long long __builtin_arm_tmiaph (long long, int, int)
13160 long long __builtin_arm_tmiatb (long long, int, int)
13161 long long __builtin_arm_tmiatt (long long, int, int)
13162 int __builtin_arm_tmovmskb (v8qi)
13163 int __builtin_arm_tmovmskh (v4hi)
13164 int __builtin_arm_tmovmskw (v2si)
13165 long long __builtin_arm_waccb (v8qi)
13166 long long __builtin_arm_wacch (v4hi)
13167 long long __builtin_arm_waccw (v2si)
13168 v8qi __builtin_arm_waddb (v8qi, v8qi)
13169 v8qi __builtin_arm_waddbss (v8qi, v8qi)
13170 v8qi __builtin_arm_waddbus (v8qi, v8qi)
13171 v4hi __builtin_arm_waddh (v4hi, v4hi)
13172 v4hi __builtin_arm_waddhss (v4hi, v4hi)
13173 v4hi __builtin_arm_waddhus (v4hi, v4hi)
13174 v2si __builtin_arm_waddw (v2si, v2si)
13175 v2si __builtin_arm_waddwss (v2si, v2si)
13176 v2si __builtin_arm_waddwus (v2si, v2si)
13177 v8qi __builtin_arm_walign (v8qi, v8qi, int)
13178 long long __builtin_arm_wand(long long, long long)
13179 long long __builtin_arm_wandn (long long, long long)
13180 v8qi __builtin_arm_wavg2b (v8qi, v8qi)
13181 v8qi __builtin_arm_wavg2br (v8qi, v8qi)
13182 v4hi __builtin_arm_wavg2h (v4hi, v4hi)
13183 v4hi __builtin_arm_wavg2hr (v4hi, v4hi)
13184 v8qi __builtin_arm_wcmpeqb (v8qi, v8qi)
13185 v4hi __builtin_arm_wcmpeqh (v4hi, v4hi)
13186 v2si __builtin_arm_wcmpeqw (v2si, v2si)
13187 v8qi __builtin_arm_wcmpgtsb (v8qi, v8qi)
13188 v4hi __builtin_arm_wcmpgtsh (v4hi, v4hi)
13189 v2si __builtin_arm_wcmpgtsw (v2si, v2si)
13190 v8qi __builtin_arm_wcmpgtub (v8qi, v8qi)
13191 v4hi __builtin_arm_wcmpgtuh (v4hi, v4hi)
13192 v2si __builtin_arm_wcmpgtuw (v2si, v2si)
13193 long long __builtin_arm_wmacs (long long, v4hi, v4hi)
13194 long long __builtin_arm_wmacsz (v4hi, v4hi)
13195 long long __builtin_arm_wmacu (long long, v4hi, v4hi)
13196 long long __builtin_arm_wmacuz (v4hi, v4hi)
13197 v4hi __builtin_arm_wmadds (v4hi, v4hi)
13198 v4hi __builtin_arm_wmaddu (v4hi, v4hi)
13199 v8qi __builtin_arm_wmaxsb (v8qi, v8qi)
13200 v4hi __builtin_arm_wmaxsh (v4hi, v4hi)
13201 v2si __builtin_arm_wmaxsw (v2si, v2si)
13202 v8qi __builtin_arm_wmaxub (v8qi, v8qi)
13203 v4hi __builtin_arm_wmaxuh (v4hi, v4hi)
13204 v2si __builtin_arm_wmaxuw (v2si, v2si)
13205 v8qi __builtin_arm_wminsb (v8qi, v8qi)
13206 v4hi __builtin_arm_wminsh (v4hi, v4hi)
13207 v2si __builtin_arm_wminsw (v2si, v2si)
13208 v8qi __builtin_arm_wminub (v8qi, v8qi)
13209 v4hi __builtin_arm_wminuh (v4hi, v4hi)
13210 v2si __builtin_arm_wminuw (v2si, v2si)
13211 v4hi __builtin_arm_wmulsm (v4hi, v4hi)
13212 v4hi __builtin_arm_wmulul (v4hi, v4hi)
13213 v4hi __builtin_arm_wmulum (v4hi, v4hi)
13214 long long __builtin_arm_wor (long long, long long)
13215 v2si __builtin_arm_wpackdss (long long, long long)
13216 v2si __builtin_arm_wpackdus (long long, long long)
13217 v8qi __builtin_arm_wpackhss (v4hi, v4hi)
13218 v8qi __builtin_arm_wpackhus (v4hi, v4hi)
13219 v4hi __builtin_arm_wpackwss (v2si, v2si)
13220 v4hi __builtin_arm_wpackwus (v2si, v2si)
13221 long long __builtin_arm_wrord (long long, long long)
13222 long long __builtin_arm_wrordi (long long, int)
13223 v4hi __builtin_arm_wrorh (v4hi, long long)
13224 v4hi __builtin_arm_wrorhi (v4hi, int)
13225 v2si __builtin_arm_wrorw (v2si, long long)
13226 v2si __builtin_arm_wrorwi (v2si, int)
13227 v2si __builtin_arm_wsadb (v2si, v8qi, v8qi)
13228 v2si __builtin_arm_wsadbz (v8qi, v8qi)
13229 v2si __builtin_arm_wsadh (v2si, v4hi, v4hi)
13230 v2si __builtin_arm_wsadhz (v4hi, v4hi)
13231 v4hi __builtin_arm_wshufh (v4hi, int)
13232 long long __builtin_arm_wslld (long long, long long)
13233 long long __builtin_arm_wslldi (long long, int)
13234 v4hi __builtin_arm_wsllh (v4hi, long long)
13235 v4hi __builtin_arm_wsllhi (v4hi, int)
13236 v2si __builtin_arm_wsllw (v2si, long long)
13237 v2si __builtin_arm_wsllwi (v2si, int)
13238 long long __builtin_arm_wsrad (long long, long long)
13239 long long __builtin_arm_wsradi (long long, int)
13240 v4hi __builtin_arm_wsrah (v4hi, long long)
13241 v4hi __builtin_arm_wsrahi (v4hi, int)
13242 v2si __builtin_arm_wsraw (v2si, long long)
13243 v2si __builtin_arm_wsrawi (v2si, int)
13244 long long __builtin_arm_wsrld (long long, long long)
13245 long long __builtin_arm_wsrldi (long long, int)
13246 v4hi __builtin_arm_wsrlh (v4hi, long long)
13247 v4hi __builtin_arm_wsrlhi (v4hi, int)
13248 v2si __builtin_arm_wsrlw (v2si, long long)
13249 v2si __builtin_arm_wsrlwi (v2si, int)
13250 v8qi __builtin_arm_wsubb (v8qi, v8qi)
13251 v8qi __builtin_arm_wsubbss (v8qi, v8qi)
13252 v8qi __builtin_arm_wsubbus (v8qi, v8qi)
13253 v4hi __builtin_arm_wsubh (v4hi, v4hi)
13254 v4hi __builtin_arm_wsubhss (v4hi, v4hi)
13255 v4hi __builtin_arm_wsubhus (v4hi, v4hi)
13256 v2si __builtin_arm_wsubw (v2si, v2si)
13257 v2si __builtin_arm_wsubwss (v2si, v2si)
13258 v2si __builtin_arm_wsubwus (v2si, v2si)
13259 v4hi __builtin_arm_wunpckehsb (v8qi)
13260 v2si __builtin_arm_wunpckehsh (v4hi)
13261 long long __builtin_arm_wunpckehsw (v2si)
13262 v4hi __builtin_arm_wunpckehub (v8qi)
13263 v2si __builtin_arm_wunpckehuh (v4hi)
13264 long long __builtin_arm_wunpckehuw (v2si)
13265 v4hi __builtin_arm_wunpckelsb (v8qi)
13266 v2si __builtin_arm_wunpckelsh (v4hi)
13267 long long __builtin_arm_wunpckelsw (v2si)
13268 v4hi __builtin_arm_wunpckelub (v8qi)
13269 v2si __builtin_arm_wunpckeluh (v4hi)
13270 long long __builtin_arm_wunpckeluw (v2si)
13271 v8qi __builtin_arm_wunpckihb (v8qi, v8qi)
13272 v4hi __builtin_arm_wunpckihh (v4hi, v4hi)
13273 v2si __builtin_arm_wunpckihw (v2si, v2si)
13274 v8qi __builtin_arm_wunpckilb (v8qi, v8qi)
13275 v4hi __builtin_arm_wunpckilh (v4hi, v4hi)
13276 v2si __builtin_arm_wunpckilw (v2si, v2si)
13277 long long __builtin_arm_wxor (long long, long long)
13278 long long __builtin_arm_wzero ()
13279 @end smallexample
13282 @node ARM C Language Extensions (ACLE)
13283 @subsection ARM C Language Extensions (ACLE)
13285 GCC implements extensions for C as described in the ARM C Language
13286 Extensions (ACLE) specification, which can be found at
13287 @uref{http://infocenter.arm.com/help/topic/com.arm.doc.ihi0053c/IHI0053C_acle_2_0.pdf}.
13289 As a part of ACLE, GCC implements extensions for Advanced SIMD as described in
13290 the ARM C Language Extensions Specification.  The complete list of Advanced SIMD
13291 intrinsics can be found at
13292 @uref{http://infocenter.arm.com/help/topic/com.arm.doc.ihi0073a/IHI0073A_arm_neon_intrinsics_ref.pdf}.
13293 The built-in intrinsics for the Advanced SIMD extension are available when
13294 NEON is enabled.
13296 Currently, ARM and AArch64 back ends do not support ACLE 2.0 fully.  Both
13297 back ends support CRC32 intrinsics and the ARM back end supports the
13298 Coprocessor intrinsics, all from @file{arm_acle.h}.  The ARM back end's 16-bit
13299 floating-point Advanced SIMD intrinsics currently comply to ACLE v1.1.
13300 AArch64's back end does not have support for 16-bit floating point Advanced SIMD
13301 intrinsics yet.
13303 See @ref{ARM Options} and @ref{AArch64 Options} for more information on the
13304 availability of extensions.
13306 @node ARM Floating Point Status and Control Intrinsics
13307 @subsection ARM Floating Point Status and Control Intrinsics
13309 These built-in functions are available for the ARM family of
13310 processors with floating-point unit.
13312 @smallexample
13313 unsigned int __builtin_arm_get_fpscr ()
13314 void __builtin_arm_set_fpscr (unsigned int)
13315 @end smallexample
13317 @node ARM ARMv8-M Security Extensions
13318 @subsection ARM ARMv8-M Security Extensions
13320 GCC implements the ARMv8-M Security Extensions as described in the ARMv8-M
13321 Security Extensions: Requirements on Development Tools Engineering
13322 Specification, which can be found at
13323 @uref{http://infocenter.arm.com/help/topic/com.arm.doc.ecm0359818/ECM0359818_armv8m_security_extensions_reqs_on_dev_tools_1_0.pdf}.
13325 As part of the Security Extensions GCC implements two new function attributes:
13326 @code{cmse_nonsecure_entry} and @code{cmse_nonsecure_call}.
13328 As part of the Security Extensions GCC implements the intrinsics below.  FPTR
13329 is used here to mean any function pointer type.
13331 @smallexample
13332 cmse_address_info_t cmse_TT (void *)
13333 cmse_address_info_t cmse_TT_fptr (FPTR)
13334 cmse_address_info_t cmse_TTT (void *)
13335 cmse_address_info_t cmse_TTT_fptr (FPTR)
13336 cmse_address_info_t cmse_TTA (void *)
13337 cmse_address_info_t cmse_TTA_fptr (FPTR)
13338 cmse_address_info_t cmse_TTAT (void *)
13339 cmse_address_info_t cmse_TTAT_fptr (FPTR)
13340 void * cmse_check_address_range (void *, size_t, int)
13341 typeof(p) cmse_nsfptr_create (FPTR p)
13342 intptr_t cmse_is_nsfptr (FPTR)
13343 int cmse_nonsecure_caller (void)
13344 @end smallexample
13346 @node AVR Built-in Functions
13347 @subsection AVR Built-in Functions
13349 For each built-in function for AVR, there is an equally named,
13350 uppercase built-in macro defined. That way users can easily query if
13351 or if not a specific built-in is implemented or not. For example, if
13352 @code{__builtin_avr_nop} is available the macro
13353 @code{__BUILTIN_AVR_NOP} is defined to @code{1} and undefined otherwise.
13355 @table @code
13357 @item void __builtin_avr_nop (void)
13358 @itemx void __builtin_avr_sei (void)
13359 @itemx void __builtin_avr_cli (void)
13360 @itemx void __builtin_avr_sleep (void)
13361 @itemx void __builtin_avr_wdr (void)
13362 @itemx unsigned char __builtin_avr_swap (unsigned char)
13363 @itemx unsigned int __builtin_avr_fmul (unsigned char, unsigned char)
13364 @itemx int __builtin_avr_fmuls (char, char)
13365 @itemx int __builtin_avr_fmulsu (char, unsigned char)
13366 These built-in functions map to the respective machine
13367 instruction, i.e.@: @code{nop}, @code{sei}, @code{cli}, @code{sleep},
13368 @code{wdr}, @code{swap}, @code{fmul}, @code{fmuls}
13369 resp. @code{fmulsu}. The three @code{fmul*} built-ins are implemented
13370 as library call if no hardware multiplier is available.
13372 @item void __builtin_avr_delay_cycles (unsigned long ticks)
13373 Delay execution for @var{ticks} cycles. Note that this
13374 built-in does not take into account the effect of interrupts that
13375 might increase delay time. @var{ticks} must be a compile-time
13376 integer constant; delays with a variable number of cycles are not supported.
13378 @item char __builtin_avr_flash_segment (const __memx void*)
13379 This built-in takes a byte address to the 24-bit
13380 @ref{AVR Named Address Spaces,address space} @code{__memx} and returns
13381 the number of the flash segment (the 64 KiB chunk) where the address
13382 points to.  Counting starts at @code{0}.
13383 If the address does not point to flash memory, return @code{-1}.
13385 @item uint8_t __builtin_avr_insert_bits (uint32_t map, uint8_t bits, uint8_t val)
13386 Insert bits from @var{bits} into @var{val} and return the resulting
13387 value. The nibbles of @var{map} determine how the insertion is
13388 performed: Let @var{X} be the @var{n}-th nibble of @var{map}
13389 @enumerate
13390 @item If @var{X} is @code{0xf},
13391 then the @var{n}-th bit of @var{val} is returned unaltered.
13393 @item If X is in the range 0@dots{}7,
13394 then the @var{n}-th result bit is set to the @var{X}-th bit of @var{bits}
13396 @item If X is in the range 8@dots{}@code{0xe},
13397 then the @var{n}-th result bit is undefined.
13398 @end enumerate
13400 @noindent
13401 One typical use case for this built-in is adjusting input and
13402 output values to non-contiguous port layouts. Some examples:
13404 @smallexample
13405 // same as val, bits is unused
13406 __builtin_avr_insert_bits (0xffffffff, bits, val)
13407 @end smallexample
13409 @smallexample
13410 // same as bits, val is unused
13411 __builtin_avr_insert_bits (0x76543210, bits, val)
13412 @end smallexample
13414 @smallexample
13415 // same as rotating bits by 4
13416 __builtin_avr_insert_bits (0x32107654, bits, 0)
13417 @end smallexample
13419 @smallexample
13420 // high nibble of result is the high nibble of val
13421 // low nibble of result is the low nibble of bits
13422 __builtin_avr_insert_bits (0xffff3210, bits, val)
13423 @end smallexample
13425 @smallexample
13426 // reverse the bit order of bits
13427 __builtin_avr_insert_bits (0x01234567, bits, 0)
13428 @end smallexample
13430 @item void __builtin_avr_nops (unsigned count)
13431 Insert @var{count} @code{NOP} instructions.
13432 The number of instructions must be a compile-time integer constant.
13434 @end table
13436 @noindent
13437 There are many more AVR-specific built-in functions that are used to
13438 implement the ISO/IEC TR 18037 ``Embedded C'' fixed-point functions of
13439 section 7.18a.6.  You don't need to use these built-ins directly.
13440 Instead, use the declarations as supplied by the @code{stdfix.h} header
13441 with GNU-C99:
13443 @smallexample
13444 #include <stdfix.h>
13446 // Re-interpret the bit representation of unsigned 16-bit
13447 // integer @var{uval} as Q-format 0.16 value.
13448 unsigned fract get_bits (uint_ur_t uval)
13450     return urbits (uval);
13452 @end smallexample
13454 @node Blackfin Built-in Functions
13455 @subsection Blackfin Built-in Functions
13457 Currently, there are two Blackfin-specific built-in functions.  These are
13458 used for generating @code{CSYNC} and @code{SSYNC} machine insns without
13459 using inline assembly; by using these built-in functions the compiler can
13460 automatically add workarounds for hardware errata involving these
13461 instructions.  These functions are named as follows:
13463 @smallexample
13464 void __builtin_bfin_csync (void)
13465 void __builtin_bfin_ssync (void)
13466 @end smallexample
13468 @node FR-V Built-in Functions
13469 @subsection FR-V Built-in Functions
13471 GCC provides many FR-V-specific built-in functions.  In general,
13472 these functions are intended to be compatible with those described
13473 by @cite{FR-V Family, Softune C/C++ Compiler Manual (V6), Fujitsu
13474 Semiconductor}.  The two exceptions are @code{__MDUNPACKH} and
13475 @code{__MBTOHE}, the GCC forms of which pass 128-bit values by
13476 pointer rather than by value.
13478 Most of the functions are named after specific FR-V instructions.
13479 Such functions are said to be ``directly mapped'' and are summarized
13480 here in tabular form.
13482 @menu
13483 * Argument Types::
13484 * Directly-mapped Integer Functions::
13485 * Directly-mapped Media Functions::
13486 * Raw read/write Functions::
13487 * Other Built-in Functions::
13488 @end menu
13490 @node Argument Types
13491 @subsubsection Argument Types
13493 The arguments to the built-in functions can be divided into three groups:
13494 register numbers, compile-time constants and run-time values.  In order
13495 to make this classification clear at a glance, the arguments and return
13496 values are given the following pseudo types:
13498 @multitable @columnfractions .20 .30 .15 .35
13499 @item Pseudo type @tab Real C type @tab Constant? @tab Description
13500 @item @code{uh} @tab @code{unsigned short} @tab No @tab an unsigned halfword
13501 @item @code{uw1} @tab @code{unsigned int} @tab No @tab an unsigned word
13502 @item @code{sw1} @tab @code{int} @tab No @tab a signed word
13503 @item @code{uw2} @tab @code{unsigned long long} @tab No
13504 @tab an unsigned doubleword
13505 @item @code{sw2} @tab @code{long long} @tab No @tab a signed doubleword
13506 @item @code{const} @tab @code{int} @tab Yes @tab an integer constant
13507 @item @code{acc} @tab @code{int} @tab Yes @tab an ACC register number
13508 @item @code{iacc} @tab @code{int} @tab Yes @tab an IACC register number
13509 @end multitable
13511 These pseudo types are not defined by GCC, they are simply a notational
13512 convenience used in this manual.
13514 Arguments of type @code{uh}, @code{uw1}, @code{sw1}, @code{uw2}
13515 and @code{sw2} are evaluated at run time.  They correspond to
13516 register operands in the underlying FR-V instructions.
13518 @code{const} arguments represent immediate operands in the underlying
13519 FR-V instructions.  They must be compile-time constants.
13521 @code{acc} arguments are evaluated at compile time and specify the number
13522 of an accumulator register.  For example, an @code{acc} argument of 2
13523 selects the ACC2 register.
13525 @code{iacc} arguments are similar to @code{acc} arguments but specify the
13526 number of an IACC register.  See @pxref{Other Built-in Functions}
13527 for more details.
13529 @node Directly-mapped Integer Functions
13530 @subsubsection Directly-Mapped Integer Functions
13532 The functions listed below map directly to FR-V I-type instructions.
13534 @multitable @columnfractions .45 .32 .23
13535 @item Function prototype @tab Example usage @tab Assembly output
13536 @item @code{sw1 __ADDSS (sw1, sw1)}
13537 @tab @code{@var{c} = __ADDSS (@var{a}, @var{b})}
13538 @tab @code{ADDSS @var{a},@var{b},@var{c}}
13539 @item @code{sw1 __SCAN (sw1, sw1)}
13540 @tab @code{@var{c} = __SCAN (@var{a}, @var{b})}
13541 @tab @code{SCAN @var{a},@var{b},@var{c}}
13542 @item @code{sw1 __SCUTSS (sw1)}
13543 @tab @code{@var{b} = __SCUTSS (@var{a})}
13544 @tab @code{SCUTSS @var{a},@var{b}}
13545 @item @code{sw1 __SLASS (sw1, sw1)}
13546 @tab @code{@var{c} = __SLASS (@var{a}, @var{b})}
13547 @tab @code{SLASS @var{a},@var{b},@var{c}}
13548 @item @code{void __SMASS (sw1, sw1)}
13549 @tab @code{__SMASS (@var{a}, @var{b})}
13550 @tab @code{SMASS @var{a},@var{b}}
13551 @item @code{void __SMSSS (sw1, sw1)}
13552 @tab @code{__SMSSS (@var{a}, @var{b})}
13553 @tab @code{SMSSS @var{a},@var{b}}
13554 @item @code{void __SMU (sw1, sw1)}
13555 @tab @code{__SMU (@var{a}, @var{b})}
13556 @tab @code{SMU @var{a},@var{b}}
13557 @item @code{sw2 __SMUL (sw1, sw1)}
13558 @tab @code{@var{c} = __SMUL (@var{a}, @var{b})}
13559 @tab @code{SMUL @var{a},@var{b},@var{c}}
13560 @item @code{sw1 __SUBSS (sw1, sw1)}
13561 @tab @code{@var{c} = __SUBSS (@var{a}, @var{b})}
13562 @tab @code{SUBSS @var{a},@var{b},@var{c}}
13563 @item @code{uw2 __UMUL (uw1, uw1)}
13564 @tab @code{@var{c} = __UMUL (@var{a}, @var{b})}
13565 @tab @code{UMUL @var{a},@var{b},@var{c}}
13566 @end multitable
13568 @node Directly-mapped Media Functions
13569 @subsubsection Directly-Mapped Media Functions
13571 The functions listed below map directly to FR-V M-type instructions.
13573 @multitable @columnfractions .45 .32 .23
13574 @item Function prototype @tab Example usage @tab Assembly output
13575 @item @code{uw1 __MABSHS (sw1)}
13576 @tab @code{@var{b} = __MABSHS (@var{a})}
13577 @tab @code{MABSHS @var{a},@var{b}}
13578 @item @code{void __MADDACCS (acc, acc)}
13579 @tab @code{__MADDACCS (@var{b}, @var{a})}
13580 @tab @code{MADDACCS @var{a},@var{b}}
13581 @item @code{sw1 __MADDHSS (sw1, sw1)}
13582 @tab @code{@var{c} = __MADDHSS (@var{a}, @var{b})}
13583 @tab @code{MADDHSS @var{a},@var{b},@var{c}}
13584 @item @code{uw1 __MADDHUS (uw1, uw1)}
13585 @tab @code{@var{c} = __MADDHUS (@var{a}, @var{b})}
13586 @tab @code{MADDHUS @var{a},@var{b},@var{c}}
13587 @item @code{uw1 __MAND (uw1, uw1)}
13588 @tab @code{@var{c} = __MAND (@var{a}, @var{b})}
13589 @tab @code{MAND @var{a},@var{b},@var{c}}
13590 @item @code{void __MASACCS (acc, acc)}
13591 @tab @code{__MASACCS (@var{b}, @var{a})}
13592 @tab @code{MASACCS @var{a},@var{b}}
13593 @item @code{uw1 __MAVEH (uw1, uw1)}
13594 @tab @code{@var{c} = __MAVEH (@var{a}, @var{b})}
13595 @tab @code{MAVEH @var{a},@var{b},@var{c}}
13596 @item @code{uw2 __MBTOH (uw1)}
13597 @tab @code{@var{b} = __MBTOH (@var{a})}
13598 @tab @code{MBTOH @var{a},@var{b}}
13599 @item @code{void __MBTOHE (uw1 *, uw1)}
13600 @tab @code{__MBTOHE (&@var{b}, @var{a})}
13601 @tab @code{MBTOHE @var{a},@var{b}}
13602 @item @code{void __MCLRACC (acc)}
13603 @tab @code{__MCLRACC (@var{a})}
13604 @tab @code{MCLRACC @var{a}}
13605 @item @code{void __MCLRACCA (void)}
13606 @tab @code{__MCLRACCA ()}
13607 @tab @code{MCLRACCA}
13608 @item @code{uw1 __Mcop1 (uw1, uw1)}
13609 @tab @code{@var{c} = __Mcop1 (@var{a}, @var{b})}
13610 @tab @code{Mcop1 @var{a},@var{b},@var{c}}
13611 @item @code{uw1 __Mcop2 (uw1, uw1)}
13612 @tab @code{@var{c} = __Mcop2 (@var{a}, @var{b})}
13613 @tab @code{Mcop2 @var{a},@var{b},@var{c}}
13614 @item @code{uw1 __MCPLHI (uw2, const)}
13615 @tab @code{@var{c} = __MCPLHI (@var{a}, @var{b})}
13616 @tab @code{MCPLHI @var{a},#@var{b},@var{c}}
13617 @item @code{uw1 __MCPLI (uw2, const)}
13618 @tab @code{@var{c} = __MCPLI (@var{a}, @var{b})}
13619 @tab @code{MCPLI @var{a},#@var{b},@var{c}}
13620 @item @code{void __MCPXIS (acc, sw1, sw1)}
13621 @tab @code{__MCPXIS (@var{c}, @var{a}, @var{b})}
13622 @tab @code{MCPXIS @var{a},@var{b},@var{c}}
13623 @item @code{void __MCPXIU (acc, uw1, uw1)}
13624 @tab @code{__MCPXIU (@var{c}, @var{a}, @var{b})}
13625 @tab @code{MCPXIU @var{a},@var{b},@var{c}}
13626 @item @code{void __MCPXRS (acc, sw1, sw1)}
13627 @tab @code{__MCPXRS (@var{c}, @var{a}, @var{b})}
13628 @tab @code{MCPXRS @var{a},@var{b},@var{c}}
13629 @item @code{void __MCPXRU (acc, uw1, uw1)}
13630 @tab @code{__MCPXRU (@var{c}, @var{a}, @var{b})}
13631 @tab @code{MCPXRU @var{a},@var{b},@var{c}}
13632 @item @code{uw1 __MCUT (acc, uw1)}
13633 @tab @code{@var{c} = __MCUT (@var{a}, @var{b})}
13634 @tab @code{MCUT @var{a},@var{b},@var{c}}
13635 @item @code{uw1 __MCUTSS (acc, sw1)}
13636 @tab @code{@var{c} = __MCUTSS (@var{a}, @var{b})}
13637 @tab @code{MCUTSS @var{a},@var{b},@var{c}}
13638 @item @code{void __MDADDACCS (acc, acc)}
13639 @tab @code{__MDADDACCS (@var{b}, @var{a})}
13640 @tab @code{MDADDACCS @var{a},@var{b}}
13641 @item @code{void __MDASACCS (acc, acc)}
13642 @tab @code{__MDASACCS (@var{b}, @var{a})}
13643 @tab @code{MDASACCS @var{a},@var{b}}
13644 @item @code{uw2 __MDCUTSSI (acc, const)}
13645 @tab @code{@var{c} = __MDCUTSSI (@var{a}, @var{b})}
13646 @tab @code{MDCUTSSI @var{a},#@var{b},@var{c}}
13647 @item @code{uw2 __MDPACKH (uw2, uw2)}
13648 @tab @code{@var{c} = __MDPACKH (@var{a}, @var{b})}
13649 @tab @code{MDPACKH @var{a},@var{b},@var{c}}
13650 @item @code{uw2 __MDROTLI (uw2, const)}
13651 @tab @code{@var{c} = __MDROTLI (@var{a}, @var{b})}
13652 @tab @code{MDROTLI @var{a},#@var{b},@var{c}}
13653 @item @code{void __MDSUBACCS (acc, acc)}
13654 @tab @code{__MDSUBACCS (@var{b}, @var{a})}
13655 @tab @code{MDSUBACCS @var{a},@var{b}}
13656 @item @code{void __MDUNPACKH (uw1 *, uw2)}
13657 @tab @code{__MDUNPACKH (&@var{b}, @var{a})}
13658 @tab @code{MDUNPACKH @var{a},@var{b}}
13659 @item @code{uw2 __MEXPDHD (uw1, const)}
13660 @tab @code{@var{c} = __MEXPDHD (@var{a}, @var{b})}
13661 @tab @code{MEXPDHD @var{a},#@var{b},@var{c}}
13662 @item @code{uw1 __MEXPDHW (uw1, const)}
13663 @tab @code{@var{c} = __MEXPDHW (@var{a}, @var{b})}
13664 @tab @code{MEXPDHW @var{a},#@var{b},@var{c}}
13665 @item @code{uw1 __MHDSETH (uw1, const)}
13666 @tab @code{@var{c} = __MHDSETH (@var{a}, @var{b})}
13667 @tab @code{MHDSETH @var{a},#@var{b},@var{c}}
13668 @item @code{sw1 __MHDSETS (const)}
13669 @tab @code{@var{b} = __MHDSETS (@var{a})}
13670 @tab @code{MHDSETS #@var{a},@var{b}}
13671 @item @code{uw1 __MHSETHIH (uw1, const)}
13672 @tab @code{@var{b} = __MHSETHIH (@var{b}, @var{a})}
13673 @tab @code{MHSETHIH #@var{a},@var{b}}
13674 @item @code{sw1 __MHSETHIS (sw1, const)}
13675 @tab @code{@var{b} = __MHSETHIS (@var{b}, @var{a})}
13676 @tab @code{MHSETHIS #@var{a},@var{b}}
13677 @item @code{uw1 __MHSETLOH (uw1, const)}
13678 @tab @code{@var{b} = __MHSETLOH (@var{b}, @var{a})}
13679 @tab @code{MHSETLOH #@var{a},@var{b}}
13680 @item @code{sw1 __MHSETLOS (sw1, const)}
13681 @tab @code{@var{b} = __MHSETLOS (@var{b}, @var{a})}
13682 @tab @code{MHSETLOS #@var{a},@var{b}}
13683 @item @code{uw1 __MHTOB (uw2)}
13684 @tab @code{@var{b} = __MHTOB (@var{a})}
13685 @tab @code{MHTOB @var{a},@var{b}}
13686 @item @code{void __MMACHS (acc, sw1, sw1)}
13687 @tab @code{__MMACHS (@var{c}, @var{a}, @var{b})}
13688 @tab @code{MMACHS @var{a},@var{b},@var{c}}
13689 @item @code{void __MMACHU (acc, uw1, uw1)}
13690 @tab @code{__MMACHU (@var{c}, @var{a}, @var{b})}
13691 @tab @code{MMACHU @var{a},@var{b},@var{c}}
13692 @item @code{void __MMRDHS (acc, sw1, sw1)}
13693 @tab @code{__MMRDHS (@var{c}, @var{a}, @var{b})}
13694 @tab @code{MMRDHS @var{a},@var{b},@var{c}}
13695 @item @code{void __MMRDHU (acc, uw1, uw1)}
13696 @tab @code{__MMRDHU (@var{c}, @var{a}, @var{b})}
13697 @tab @code{MMRDHU @var{a},@var{b},@var{c}}
13698 @item @code{void __MMULHS (acc, sw1, sw1)}
13699 @tab @code{__MMULHS (@var{c}, @var{a}, @var{b})}
13700 @tab @code{MMULHS @var{a},@var{b},@var{c}}
13701 @item @code{void __MMULHU (acc, uw1, uw1)}
13702 @tab @code{__MMULHU (@var{c}, @var{a}, @var{b})}
13703 @tab @code{MMULHU @var{a},@var{b},@var{c}}
13704 @item @code{void __MMULXHS (acc, sw1, sw1)}
13705 @tab @code{__MMULXHS (@var{c}, @var{a}, @var{b})}
13706 @tab @code{MMULXHS @var{a},@var{b},@var{c}}
13707 @item @code{void __MMULXHU (acc, uw1, uw1)}
13708 @tab @code{__MMULXHU (@var{c}, @var{a}, @var{b})}
13709 @tab @code{MMULXHU @var{a},@var{b},@var{c}}
13710 @item @code{uw1 __MNOT (uw1)}
13711 @tab @code{@var{b} = __MNOT (@var{a})}
13712 @tab @code{MNOT @var{a},@var{b}}
13713 @item @code{uw1 __MOR (uw1, uw1)}
13714 @tab @code{@var{c} = __MOR (@var{a}, @var{b})}
13715 @tab @code{MOR @var{a},@var{b},@var{c}}
13716 @item @code{uw1 __MPACKH (uh, uh)}
13717 @tab @code{@var{c} = __MPACKH (@var{a}, @var{b})}
13718 @tab @code{MPACKH @var{a},@var{b},@var{c}}
13719 @item @code{sw2 __MQADDHSS (sw2, sw2)}
13720 @tab @code{@var{c} = __MQADDHSS (@var{a}, @var{b})}
13721 @tab @code{MQADDHSS @var{a},@var{b},@var{c}}
13722 @item @code{uw2 __MQADDHUS (uw2, uw2)}
13723 @tab @code{@var{c} = __MQADDHUS (@var{a}, @var{b})}
13724 @tab @code{MQADDHUS @var{a},@var{b},@var{c}}
13725 @item @code{void __MQCPXIS (acc, sw2, sw2)}
13726 @tab @code{__MQCPXIS (@var{c}, @var{a}, @var{b})}
13727 @tab @code{MQCPXIS @var{a},@var{b},@var{c}}
13728 @item @code{void __MQCPXIU (acc, uw2, uw2)}
13729 @tab @code{__MQCPXIU (@var{c}, @var{a}, @var{b})}
13730 @tab @code{MQCPXIU @var{a},@var{b},@var{c}}
13731 @item @code{void __MQCPXRS (acc, sw2, sw2)}
13732 @tab @code{__MQCPXRS (@var{c}, @var{a}, @var{b})}
13733 @tab @code{MQCPXRS @var{a},@var{b},@var{c}}
13734 @item @code{void __MQCPXRU (acc, uw2, uw2)}
13735 @tab @code{__MQCPXRU (@var{c}, @var{a}, @var{b})}
13736 @tab @code{MQCPXRU @var{a},@var{b},@var{c}}
13737 @item @code{sw2 __MQLCLRHS (sw2, sw2)}
13738 @tab @code{@var{c} = __MQLCLRHS (@var{a}, @var{b})}
13739 @tab @code{MQLCLRHS @var{a},@var{b},@var{c}}
13740 @item @code{sw2 __MQLMTHS (sw2, sw2)}
13741 @tab @code{@var{c} = __MQLMTHS (@var{a}, @var{b})}
13742 @tab @code{MQLMTHS @var{a},@var{b},@var{c}}
13743 @item @code{void __MQMACHS (acc, sw2, sw2)}
13744 @tab @code{__MQMACHS (@var{c}, @var{a}, @var{b})}
13745 @tab @code{MQMACHS @var{a},@var{b},@var{c}}
13746 @item @code{void __MQMACHU (acc, uw2, uw2)}
13747 @tab @code{__MQMACHU (@var{c}, @var{a}, @var{b})}
13748 @tab @code{MQMACHU @var{a},@var{b},@var{c}}
13749 @item @code{void __MQMACXHS (acc, sw2, sw2)}
13750 @tab @code{__MQMACXHS (@var{c}, @var{a}, @var{b})}
13751 @tab @code{MQMACXHS @var{a},@var{b},@var{c}}
13752 @item @code{void __MQMULHS (acc, sw2, sw2)}
13753 @tab @code{__MQMULHS (@var{c}, @var{a}, @var{b})}
13754 @tab @code{MQMULHS @var{a},@var{b},@var{c}}
13755 @item @code{void __MQMULHU (acc, uw2, uw2)}
13756 @tab @code{__MQMULHU (@var{c}, @var{a}, @var{b})}
13757 @tab @code{MQMULHU @var{a},@var{b},@var{c}}
13758 @item @code{void __MQMULXHS (acc, sw2, sw2)}
13759 @tab @code{__MQMULXHS (@var{c}, @var{a}, @var{b})}
13760 @tab @code{MQMULXHS @var{a},@var{b},@var{c}}
13761 @item @code{void __MQMULXHU (acc, uw2, uw2)}
13762 @tab @code{__MQMULXHU (@var{c}, @var{a}, @var{b})}
13763 @tab @code{MQMULXHU @var{a},@var{b},@var{c}}
13764 @item @code{sw2 __MQSATHS (sw2, sw2)}
13765 @tab @code{@var{c} = __MQSATHS (@var{a}, @var{b})}
13766 @tab @code{MQSATHS @var{a},@var{b},@var{c}}
13767 @item @code{uw2 __MQSLLHI (uw2, int)}
13768 @tab @code{@var{c} = __MQSLLHI (@var{a}, @var{b})}
13769 @tab @code{MQSLLHI @var{a},@var{b},@var{c}}
13770 @item @code{sw2 __MQSRAHI (sw2, int)}
13771 @tab @code{@var{c} = __MQSRAHI (@var{a}, @var{b})}
13772 @tab @code{MQSRAHI @var{a},@var{b},@var{c}}
13773 @item @code{sw2 __MQSUBHSS (sw2, sw2)}
13774 @tab @code{@var{c} = __MQSUBHSS (@var{a}, @var{b})}
13775 @tab @code{MQSUBHSS @var{a},@var{b},@var{c}}
13776 @item @code{uw2 __MQSUBHUS (uw2, uw2)}
13777 @tab @code{@var{c} = __MQSUBHUS (@var{a}, @var{b})}
13778 @tab @code{MQSUBHUS @var{a},@var{b},@var{c}}
13779 @item @code{void __MQXMACHS (acc, sw2, sw2)}
13780 @tab @code{__MQXMACHS (@var{c}, @var{a}, @var{b})}
13781 @tab @code{MQXMACHS @var{a},@var{b},@var{c}}
13782 @item @code{void __MQXMACXHS (acc, sw2, sw2)}
13783 @tab @code{__MQXMACXHS (@var{c}, @var{a}, @var{b})}
13784 @tab @code{MQXMACXHS @var{a},@var{b},@var{c}}
13785 @item @code{uw1 __MRDACC (acc)}
13786 @tab @code{@var{b} = __MRDACC (@var{a})}
13787 @tab @code{MRDACC @var{a},@var{b}}
13788 @item @code{uw1 __MRDACCG (acc)}
13789 @tab @code{@var{b} = __MRDACCG (@var{a})}
13790 @tab @code{MRDACCG @var{a},@var{b}}
13791 @item @code{uw1 __MROTLI (uw1, const)}
13792 @tab @code{@var{c} = __MROTLI (@var{a}, @var{b})}
13793 @tab @code{MROTLI @var{a},#@var{b},@var{c}}
13794 @item @code{uw1 __MROTRI (uw1, const)}
13795 @tab @code{@var{c} = __MROTRI (@var{a}, @var{b})}
13796 @tab @code{MROTRI @var{a},#@var{b},@var{c}}
13797 @item @code{sw1 __MSATHS (sw1, sw1)}
13798 @tab @code{@var{c} = __MSATHS (@var{a}, @var{b})}
13799 @tab @code{MSATHS @var{a},@var{b},@var{c}}
13800 @item @code{uw1 __MSATHU (uw1, uw1)}
13801 @tab @code{@var{c} = __MSATHU (@var{a}, @var{b})}
13802 @tab @code{MSATHU @var{a},@var{b},@var{c}}
13803 @item @code{uw1 __MSLLHI (uw1, const)}
13804 @tab @code{@var{c} = __MSLLHI (@var{a}, @var{b})}
13805 @tab @code{MSLLHI @var{a},#@var{b},@var{c}}
13806 @item @code{sw1 __MSRAHI (sw1, const)}
13807 @tab @code{@var{c} = __MSRAHI (@var{a}, @var{b})}
13808 @tab @code{MSRAHI @var{a},#@var{b},@var{c}}
13809 @item @code{uw1 __MSRLHI (uw1, const)}
13810 @tab @code{@var{c} = __MSRLHI (@var{a}, @var{b})}
13811 @tab @code{MSRLHI @var{a},#@var{b},@var{c}}
13812 @item @code{void __MSUBACCS (acc, acc)}
13813 @tab @code{__MSUBACCS (@var{b}, @var{a})}
13814 @tab @code{MSUBACCS @var{a},@var{b}}
13815 @item @code{sw1 __MSUBHSS (sw1, sw1)}
13816 @tab @code{@var{c} = __MSUBHSS (@var{a}, @var{b})}
13817 @tab @code{MSUBHSS @var{a},@var{b},@var{c}}
13818 @item @code{uw1 __MSUBHUS (uw1, uw1)}
13819 @tab @code{@var{c} = __MSUBHUS (@var{a}, @var{b})}
13820 @tab @code{MSUBHUS @var{a},@var{b},@var{c}}
13821 @item @code{void __MTRAP (void)}
13822 @tab @code{__MTRAP ()}
13823 @tab @code{MTRAP}
13824 @item @code{uw2 __MUNPACKH (uw1)}
13825 @tab @code{@var{b} = __MUNPACKH (@var{a})}
13826 @tab @code{MUNPACKH @var{a},@var{b}}
13827 @item @code{uw1 __MWCUT (uw2, uw1)}
13828 @tab @code{@var{c} = __MWCUT (@var{a}, @var{b})}
13829 @tab @code{MWCUT @var{a},@var{b},@var{c}}
13830 @item @code{void __MWTACC (acc, uw1)}
13831 @tab @code{__MWTACC (@var{b}, @var{a})}
13832 @tab @code{MWTACC @var{a},@var{b}}
13833 @item @code{void __MWTACCG (acc, uw1)}
13834 @tab @code{__MWTACCG (@var{b}, @var{a})}
13835 @tab @code{MWTACCG @var{a},@var{b}}
13836 @item @code{uw1 __MXOR (uw1, uw1)}
13837 @tab @code{@var{c} = __MXOR (@var{a}, @var{b})}
13838 @tab @code{MXOR @var{a},@var{b},@var{c}}
13839 @end multitable
13841 @node Raw read/write Functions
13842 @subsubsection Raw Read/Write Functions
13844 This sections describes built-in functions related to read and write
13845 instructions to access memory.  These functions generate
13846 @code{membar} instructions to flush the I/O load and stores where
13847 appropriate, as described in Fujitsu's manual described above.
13849 @table @code
13851 @item unsigned char __builtin_read8 (void *@var{data})
13852 @item unsigned short __builtin_read16 (void *@var{data})
13853 @item unsigned long __builtin_read32 (void *@var{data})
13854 @item unsigned long long __builtin_read64 (void *@var{data})
13856 @item void __builtin_write8 (void *@var{data}, unsigned char @var{datum})
13857 @item void __builtin_write16 (void *@var{data}, unsigned short @var{datum})
13858 @item void __builtin_write32 (void *@var{data}, unsigned long @var{datum})
13859 @item void __builtin_write64 (void *@var{data}, unsigned long long @var{datum})
13860 @end table
13862 @node Other Built-in Functions
13863 @subsubsection Other Built-in Functions
13865 This section describes built-in functions that are not named after
13866 a specific FR-V instruction.
13868 @table @code
13869 @item sw2 __IACCreadll (iacc @var{reg})
13870 Return the full 64-bit value of IACC0@.  The @var{reg} argument is reserved
13871 for future expansion and must be 0.
13873 @item sw1 __IACCreadl (iacc @var{reg})
13874 Return the value of IACC0H if @var{reg} is 0 and IACC0L if @var{reg} is 1.
13875 Other values of @var{reg} are rejected as invalid.
13877 @item void __IACCsetll (iacc @var{reg}, sw2 @var{x})
13878 Set the full 64-bit value of IACC0 to @var{x}.  The @var{reg} argument
13879 is reserved for future expansion and must be 0.
13881 @item void __IACCsetl (iacc @var{reg}, sw1 @var{x})
13882 Set IACC0H to @var{x} if @var{reg} is 0 and IACC0L to @var{x} if @var{reg}
13883 is 1.  Other values of @var{reg} are rejected as invalid.
13885 @item void __data_prefetch0 (const void *@var{x})
13886 Use the @code{dcpl} instruction to load the contents of address @var{x}
13887 into the data cache.
13889 @item void __data_prefetch (const void *@var{x})
13890 Use the @code{nldub} instruction to load the contents of address @var{x}
13891 into the data cache.  The instruction is issued in slot I1@.
13892 @end table
13894 @node MIPS DSP Built-in Functions
13895 @subsection MIPS DSP Built-in Functions
13897 The MIPS DSP Application-Specific Extension (ASE) includes new
13898 instructions that are designed to improve the performance of DSP and
13899 media applications.  It provides instructions that operate on packed
13900 8-bit/16-bit integer data, Q7, Q15 and Q31 fractional data.
13902 GCC supports MIPS DSP operations using both the generic
13903 vector extensions (@pxref{Vector Extensions}) and a collection of
13904 MIPS-specific built-in functions.  Both kinds of support are
13905 enabled by the @option{-mdsp} command-line option.
13907 Revision 2 of the ASE was introduced in the second half of 2006.
13908 This revision adds extra instructions to the original ASE, but is
13909 otherwise backwards-compatible with it.  You can select revision 2
13910 using the command-line option @option{-mdspr2}; this option implies
13911 @option{-mdsp}.
13913 The SCOUNT and POS bits of the DSP control register are global.  The
13914 WRDSP, EXTPDP, EXTPDPV and MTHLIP instructions modify the SCOUNT and
13915 POS bits.  During optimization, the compiler does not delete these
13916 instructions and it does not delete calls to functions containing
13917 these instructions.
13919 At present, GCC only provides support for operations on 32-bit
13920 vectors.  The vector type associated with 8-bit integer data is
13921 usually called @code{v4i8}, the vector type associated with Q7
13922 is usually called @code{v4q7}, the vector type associated with 16-bit
13923 integer data is usually called @code{v2i16}, and the vector type
13924 associated with Q15 is usually called @code{v2q15}.  They can be
13925 defined in C as follows:
13927 @smallexample
13928 typedef signed char v4i8 __attribute__ ((vector_size(4)));
13929 typedef signed char v4q7 __attribute__ ((vector_size(4)));
13930 typedef short v2i16 __attribute__ ((vector_size(4)));
13931 typedef short v2q15 __attribute__ ((vector_size(4)));
13932 @end smallexample
13934 @code{v4i8}, @code{v4q7}, @code{v2i16} and @code{v2q15} values are
13935 initialized in the same way as aggregates.  For example:
13937 @smallexample
13938 v4i8 a = @{1, 2, 3, 4@};
13939 v4i8 b;
13940 b = (v4i8) @{5, 6, 7, 8@};
13942 v2q15 c = @{0x0fcb, 0x3a75@};
13943 v2q15 d;
13944 d = (v2q15) @{0.1234 * 0x1.0p15, 0.4567 * 0x1.0p15@};
13945 @end smallexample
13947 @emph{Note:} The CPU's endianness determines the order in which values
13948 are packed.  On little-endian targets, the first value is the least
13949 significant and the last value is the most significant.  The opposite
13950 order applies to big-endian targets.  For example, the code above
13951 sets the lowest byte of @code{a} to @code{1} on little-endian targets
13952 and @code{4} on big-endian targets.
13954 @emph{Note:} Q7, Q15 and Q31 values must be initialized with their integer
13955 representation.  As shown in this example, the integer representation
13956 of a Q7 value can be obtained by multiplying the fractional value by
13957 @code{0x1.0p7}.  The equivalent for Q15 values is to multiply by
13958 @code{0x1.0p15}.  The equivalent for Q31 values is to multiply by
13959 @code{0x1.0p31}.
13961 The table below lists the @code{v4i8} and @code{v2q15} operations for which
13962 hardware support exists.  @code{a} and @code{b} are @code{v4i8} values,
13963 and @code{c} and @code{d} are @code{v2q15} values.
13965 @multitable @columnfractions .50 .50
13966 @item C code @tab MIPS instruction
13967 @item @code{a + b} @tab @code{addu.qb}
13968 @item @code{c + d} @tab @code{addq.ph}
13969 @item @code{a - b} @tab @code{subu.qb}
13970 @item @code{c - d} @tab @code{subq.ph}
13971 @end multitable
13973 The table below lists the @code{v2i16} operation for which
13974 hardware support exists for the DSP ASE REV 2.  @code{e} and @code{f} are
13975 @code{v2i16} values.
13977 @multitable @columnfractions .50 .50
13978 @item C code @tab MIPS instruction
13979 @item @code{e * f} @tab @code{mul.ph}
13980 @end multitable
13982 It is easier to describe the DSP built-in functions if we first define
13983 the following types:
13985 @smallexample
13986 typedef int q31;
13987 typedef int i32;
13988 typedef unsigned int ui32;
13989 typedef long long a64;
13990 @end smallexample
13992 @code{q31} and @code{i32} are actually the same as @code{int}, but we
13993 use @code{q31} to indicate a Q31 fractional value and @code{i32} to
13994 indicate a 32-bit integer value.  Similarly, @code{a64} is the same as
13995 @code{long long}, but we use @code{a64} to indicate values that are
13996 placed in one of the four DSP accumulators (@code{$ac0},
13997 @code{$ac1}, @code{$ac2} or @code{$ac3}).
13999 Also, some built-in functions prefer or require immediate numbers as
14000 parameters, because the corresponding DSP instructions accept both immediate
14001 numbers and register operands, or accept immediate numbers only.  The
14002 immediate parameters are listed as follows.
14004 @smallexample
14005 imm0_3: 0 to 3.
14006 imm0_7: 0 to 7.
14007 imm0_15: 0 to 15.
14008 imm0_31: 0 to 31.
14009 imm0_63: 0 to 63.
14010 imm0_255: 0 to 255.
14011 imm_n32_31: -32 to 31.
14012 imm_n512_511: -512 to 511.
14013 @end smallexample
14015 The following built-in functions map directly to a particular MIPS DSP
14016 instruction.  Please refer to the architecture specification
14017 for details on what each instruction does.
14019 @smallexample
14020 v2q15 __builtin_mips_addq_ph (v2q15, v2q15)
14021 v2q15 __builtin_mips_addq_s_ph (v2q15, v2q15)
14022 q31 __builtin_mips_addq_s_w (q31, q31)
14023 v4i8 __builtin_mips_addu_qb (v4i8, v4i8)
14024 v4i8 __builtin_mips_addu_s_qb (v4i8, v4i8)
14025 v2q15 __builtin_mips_subq_ph (v2q15, v2q15)
14026 v2q15 __builtin_mips_subq_s_ph (v2q15, v2q15)
14027 q31 __builtin_mips_subq_s_w (q31, q31)
14028 v4i8 __builtin_mips_subu_qb (v4i8, v4i8)
14029 v4i8 __builtin_mips_subu_s_qb (v4i8, v4i8)
14030 i32 __builtin_mips_addsc (i32, i32)
14031 i32 __builtin_mips_addwc (i32, i32)
14032 i32 __builtin_mips_modsub (i32, i32)
14033 i32 __builtin_mips_raddu_w_qb (v4i8)
14034 v2q15 __builtin_mips_absq_s_ph (v2q15)
14035 q31 __builtin_mips_absq_s_w (q31)
14036 v4i8 __builtin_mips_precrq_qb_ph (v2q15, v2q15)
14037 v2q15 __builtin_mips_precrq_ph_w (q31, q31)
14038 v2q15 __builtin_mips_precrq_rs_ph_w (q31, q31)
14039 v4i8 __builtin_mips_precrqu_s_qb_ph (v2q15, v2q15)
14040 q31 __builtin_mips_preceq_w_phl (v2q15)
14041 q31 __builtin_mips_preceq_w_phr (v2q15)
14042 v2q15 __builtin_mips_precequ_ph_qbl (v4i8)
14043 v2q15 __builtin_mips_precequ_ph_qbr (v4i8)
14044 v2q15 __builtin_mips_precequ_ph_qbla (v4i8)
14045 v2q15 __builtin_mips_precequ_ph_qbra (v4i8)
14046 v2q15 __builtin_mips_preceu_ph_qbl (v4i8)
14047 v2q15 __builtin_mips_preceu_ph_qbr (v4i8)
14048 v2q15 __builtin_mips_preceu_ph_qbla (v4i8)
14049 v2q15 __builtin_mips_preceu_ph_qbra (v4i8)
14050 v4i8 __builtin_mips_shll_qb (v4i8, imm0_7)
14051 v4i8 __builtin_mips_shll_qb (v4i8, i32)
14052 v2q15 __builtin_mips_shll_ph (v2q15, imm0_15)
14053 v2q15 __builtin_mips_shll_ph (v2q15, i32)
14054 v2q15 __builtin_mips_shll_s_ph (v2q15, imm0_15)
14055 v2q15 __builtin_mips_shll_s_ph (v2q15, i32)
14056 q31 __builtin_mips_shll_s_w (q31, imm0_31)
14057 q31 __builtin_mips_shll_s_w (q31, i32)
14058 v4i8 __builtin_mips_shrl_qb (v4i8, imm0_7)
14059 v4i8 __builtin_mips_shrl_qb (v4i8, i32)
14060 v2q15 __builtin_mips_shra_ph (v2q15, imm0_15)
14061 v2q15 __builtin_mips_shra_ph (v2q15, i32)
14062 v2q15 __builtin_mips_shra_r_ph (v2q15, imm0_15)
14063 v2q15 __builtin_mips_shra_r_ph (v2q15, i32)
14064 q31 __builtin_mips_shra_r_w (q31, imm0_31)
14065 q31 __builtin_mips_shra_r_w (q31, i32)
14066 v2q15 __builtin_mips_muleu_s_ph_qbl (v4i8, v2q15)
14067 v2q15 __builtin_mips_muleu_s_ph_qbr (v4i8, v2q15)
14068 v2q15 __builtin_mips_mulq_rs_ph (v2q15, v2q15)
14069 q31 __builtin_mips_muleq_s_w_phl (v2q15, v2q15)
14070 q31 __builtin_mips_muleq_s_w_phr (v2q15, v2q15)
14071 a64 __builtin_mips_dpau_h_qbl (a64, v4i8, v4i8)
14072 a64 __builtin_mips_dpau_h_qbr (a64, v4i8, v4i8)
14073 a64 __builtin_mips_dpsu_h_qbl (a64, v4i8, v4i8)
14074 a64 __builtin_mips_dpsu_h_qbr (a64, v4i8, v4i8)
14075 a64 __builtin_mips_dpaq_s_w_ph (a64, v2q15, v2q15)
14076 a64 __builtin_mips_dpaq_sa_l_w (a64, q31, q31)
14077 a64 __builtin_mips_dpsq_s_w_ph (a64, v2q15, v2q15)
14078 a64 __builtin_mips_dpsq_sa_l_w (a64, q31, q31)
14079 a64 __builtin_mips_mulsaq_s_w_ph (a64, v2q15, v2q15)
14080 a64 __builtin_mips_maq_s_w_phl (a64, v2q15, v2q15)
14081 a64 __builtin_mips_maq_s_w_phr (a64, v2q15, v2q15)
14082 a64 __builtin_mips_maq_sa_w_phl (a64, v2q15, v2q15)
14083 a64 __builtin_mips_maq_sa_w_phr (a64, v2q15, v2q15)
14084 i32 __builtin_mips_bitrev (i32)
14085 i32 __builtin_mips_insv (i32, i32)
14086 v4i8 __builtin_mips_repl_qb (imm0_255)
14087 v4i8 __builtin_mips_repl_qb (i32)
14088 v2q15 __builtin_mips_repl_ph (imm_n512_511)
14089 v2q15 __builtin_mips_repl_ph (i32)
14090 void __builtin_mips_cmpu_eq_qb (v4i8, v4i8)
14091 void __builtin_mips_cmpu_lt_qb (v4i8, v4i8)
14092 void __builtin_mips_cmpu_le_qb (v4i8, v4i8)
14093 i32 __builtin_mips_cmpgu_eq_qb (v4i8, v4i8)
14094 i32 __builtin_mips_cmpgu_lt_qb (v4i8, v4i8)
14095 i32 __builtin_mips_cmpgu_le_qb (v4i8, v4i8)
14096 void __builtin_mips_cmp_eq_ph (v2q15, v2q15)
14097 void __builtin_mips_cmp_lt_ph (v2q15, v2q15)
14098 void __builtin_mips_cmp_le_ph (v2q15, v2q15)
14099 v4i8 __builtin_mips_pick_qb (v4i8, v4i8)
14100 v2q15 __builtin_mips_pick_ph (v2q15, v2q15)
14101 v2q15 __builtin_mips_packrl_ph (v2q15, v2q15)
14102 i32 __builtin_mips_extr_w (a64, imm0_31)
14103 i32 __builtin_mips_extr_w (a64, i32)
14104 i32 __builtin_mips_extr_r_w (a64, imm0_31)
14105 i32 __builtin_mips_extr_s_h (a64, i32)
14106 i32 __builtin_mips_extr_rs_w (a64, imm0_31)
14107 i32 __builtin_mips_extr_rs_w (a64, i32)
14108 i32 __builtin_mips_extr_s_h (a64, imm0_31)
14109 i32 __builtin_mips_extr_r_w (a64, i32)
14110 i32 __builtin_mips_extp (a64, imm0_31)
14111 i32 __builtin_mips_extp (a64, i32)
14112 i32 __builtin_mips_extpdp (a64, imm0_31)
14113 i32 __builtin_mips_extpdp (a64, i32)
14114 a64 __builtin_mips_shilo (a64, imm_n32_31)
14115 a64 __builtin_mips_shilo (a64, i32)
14116 a64 __builtin_mips_mthlip (a64, i32)
14117 void __builtin_mips_wrdsp (i32, imm0_63)
14118 i32 __builtin_mips_rddsp (imm0_63)
14119 i32 __builtin_mips_lbux (void *, i32)
14120 i32 __builtin_mips_lhx (void *, i32)
14121 i32 __builtin_mips_lwx (void *, i32)
14122 a64 __builtin_mips_ldx (void *, i32) [MIPS64 only]
14123 i32 __builtin_mips_bposge32 (void)
14124 a64 __builtin_mips_madd (a64, i32, i32);
14125 a64 __builtin_mips_maddu (a64, ui32, ui32);
14126 a64 __builtin_mips_msub (a64, i32, i32);
14127 a64 __builtin_mips_msubu (a64, ui32, ui32);
14128 a64 __builtin_mips_mult (i32, i32);
14129 a64 __builtin_mips_multu (ui32, ui32);
14130 @end smallexample
14132 The following built-in functions map directly to a particular MIPS DSP REV 2
14133 instruction.  Please refer to the architecture specification
14134 for details on what each instruction does.
14136 @smallexample
14137 v4q7 __builtin_mips_absq_s_qb (v4q7);
14138 v2i16 __builtin_mips_addu_ph (v2i16, v2i16);
14139 v2i16 __builtin_mips_addu_s_ph (v2i16, v2i16);
14140 v4i8 __builtin_mips_adduh_qb (v4i8, v4i8);
14141 v4i8 __builtin_mips_adduh_r_qb (v4i8, v4i8);
14142 i32 __builtin_mips_append (i32, i32, imm0_31);
14143 i32 __builtin_mips_balign (i32, i32, imm0_3);
14144 i32 __builtin_mips_cmpgdu_eq_qb (v4i8, v4i8);
14145 i32 __builtin_mips_cmpgdu_lt_qb (v4i8, v4i8);
14146 i32 __builtin_mips_cmpgdu_le_qb (v4i8, v4i8);
14147 a64 __builtin_mips_dpa_w_ph (a64, v2i16, v2i16);
14148 a64 __builtin_mips_dps_w_ph (a64, v2i16, v2i16);
14149 v2i16 __builtin_mips_mul_ph (v2i16, v2i16);
14150 v2i16 __builtin_mips_mul_s_ph (v2i16, v2i16);
14151 q31 __builtin_mips_mulq_rs_w (q31, q31);
14152 v2q15 __builtin_mips_mulq_s_ph (v2q15, v2q15);
14153 q31 __builtin_mips_mulq_s_w (q31, q31);
14154 a64 __builtin_mips_mulsa_w_ph (a64, v2i16, v2i16);
14155 v4i8 __builtin_mips_precr_qb_ph (v2i16, v2i16);
14156 v2i16 __builtin_mips_precr_sra_ph_w (i32, i32, imm0_31);
14157 v2i16 __builtin_mips_precr_sra_r_ph_w (i32, i32, imm0_31);
14158 i32 __builtin_mips_prepend (i32, i32, imm0_31);
14159 v4i8 __builtin_mips_shra_qb (v4i8, imm0_7);
14160 v4i8 __builtin_mips_shra_r_qb (v4i8, imm0_7);
14161 v4i8 __builtin_mips_shra_qb (v4i8, i32);
14162 v4i8 __builtin_mips_shra_r_qb (v4i8, i32);
14163 v2i16 __builtin_mips_shrl_ph (v2i16, imm0_15);
14164 v2i16 __builtin_mips_shrl_ph (v2i16, i32);
14165 v2i16 __builtin_mips_subu_ph (v2i16, v2i16);
14166 v2i16 __builtin_mips_subu_s_ph (v2i16, v2i16);
14167 v4i8 __builtin_mips_subuh_qb (v4i8, v4i8);
14168 v4i8 __builtin_mips_subuh_r_qb (v4i8, v4i8);
14169 v2q15 __builtin_mips_addqh_ph (v2q15, v2q15);
14170 v2q15 __builtin_mips_addqh_r_ph (v2q15, v2q15);
14171 q31 __builtin_mips_addqh_w (q31, q31);
14172 q31 __builtin_mips_addqh_r_w (q31, q31);
14173 v2q15 __builtin_mips_subqh_ph (v2q15, v2q15);
14174 v2q15 __builtin_mips_subqh_r_ph (v2q15, v2q15);
14175 q31 __builtin_mips_subqh_w (q31, q31);
14176 q31 __builtin_mips_subqh_r_w (q31, q31);
14177 a64 __builtin_mips_dpax_w_ph (a64, v2i16, v2i16);
14178 a64 __builtin_mips_dpsx_w_ph (a64, v2i16, v2i16);
14179 a64 __builtin_mips_dpaqx_s_w_ph (a64, v2q15, v2q15);
14180 a64 __builtin_mips_dpaqx_sa_w_ph (a64, v2q15, v2q15);
14181 a64 __builtin_mips_dpsqx_s_w_ph (a64, v2q15, v2q15);
14182 a64 __builtin_mips_dpsqx_sa_w_ph (a64, v2q15, v2q15);
14183 @end smallexample
14186 @node MIPS Paired-Single Support
14187 @subsection MIPS Paired-Single Support
14189 The MIPS64 architecture includes a number of instructions that
14190 operate on pairs of single-precision floating-point values.
14191 Each pair is packed into a 64-bit floating-point register,
14192 with one element being designated the ``upper half'' and
14193 the other being designated the ``lower half''.
14195 GCC supports paired-single operations using both the generic
14196 vector extensions (@pxref{Vector Extensions}) and a collection of
14197 MIPS-specific built-in functions.  Both kinds of support are
14198 enabled by the @option{-mpaired-single} command-line option.
14200 The vector type associated with paired-single values is usually
14201 called @code{v2sf}.  It can be defined in C as follows:
14203 @smallexample
14204 typedef float v2sf __attribute__ ((vector_size (8)));
14205 @end smallexample
14207 @code{v2sf} values are initialized in the same way as aggregates.
14208 For example:
14210 @smallexample
14211 v2sf a = @{1.5, 9.1@};
14212 v2sf b;
14213 float e, f;
14214 b = (v2sf) @{e, f@};
14215 @end smallexample
14217 @emph{Note:} The CPU's endianness determines which value is stored in
14218 the upper half of a register and which value is stored in the lower half.
14219 On little-endian targets, the first value is the lower one and the second
14220 value is the upper one.  The opposite order applies to big-endian targets.
14221 For example, the code above sets the lower half of @code{a} to
14222 @code{1.5} on little-endian targets and @code{9.1} on big-endian targets.
14224 @node MIPS Loongson Built-in Functions
14225 @subsection MIPS Loongson Built-in Functions
14227 GCC provides intrinsics to access the SIMD instructions provided by the
14228 ST Microelectronics Loongson-2E and -2F processors.  These intrinsics,
14229 available after inclusion of the @code{loongson.h} header file,
14230 operate on the following 64-bit vector types:
14232 @itemize
14233 @item @code{uint8x8_t}, a vector of eight unsigned 8-bit integers;
14234 @item @code{uint16x4_t}, a vector of four unsigned 16-bit integers;
14235 @item @code{uint32x2_t}, a vector of two unsigned 32-bit integers;
14236 @item @code{int8x8_t}, a vector of eight signed 8-bit integers;
14237 @item @code{int16x4_t}, a vector of four signed 16-bit integers;
14238 @item @code{int32x2_t}, a vector of two signed 32-bit integers.
14239 @end itemize
14241 The intrinsics provided are listed below; each is named after the
14242 machine instruction to which it corresponds, with suffixes added as
14243 appropriate to distinguish intrinsics that expand to the same machine
14244 instruction yet have different argument types.  Refer to the architecture
14245 documentation for a description of the functionality of each
14246 instruction.
14248 @smallexample
14249 int16x4_t packsswh (int32x2_t s, int32x2_t t);
14250 int8x8_t packsshb (int16x4_t s, int16x4_t t);
14251 uint8x8_t packushb (uint16x4_t s, uint16x4_t t);
14252 uint32x2_t paddw_u (uint32x2_t s, uint32x2_t t);
14253 uint16x4_t paddh_u (uint16x4_t s, uint16x4_t t);
14254 uint8x8_t paddb_u (uint8x8_t s, uint8x8_t t);
14255 int32x2_t paddw_s (int32x2_t s, int32x2_t t);
14256 int16x4_t paddh_s (int16x4_t s, int16x4_t t);
14257 int8x8_t paddb_s (int8x8_t s, int8x8_t t);
14258 uint64_t paddd_u (uint64_t s, uint64_t t);
14259 int64_t paddd_s (int64_t s, int64_t t);
14260 int16x4_t paddsh (int16x4_t s, int16x4_t t);
14261 int8x8_t paddsb (int8x8_t s, int8x8_t t);
14262 uint16x4_t paddush (uint16x4_t s, uint16x4_t t);
14263 uint8x8_t paddusb (uint8x8_t s, uint8x8_t t);
14264 uint64_t pandn_ud (uint64_t s, uint64_t t);
14265 uint32x2_t pandn_uw (uint32x2_t s, uint32x2_t t);
14266 uint16x4_t pandn_uh (uint16x4_t s, uint16x4_t t);
14267 uint8x8_t pandn_ub (uint8x8_t s, uint8x8_t t);
14268 int64_t pandn_sd (int64_t s, int64_t t);
14269 int32x2_t pandn_sw (int32x2_t s, int32x2_t t);
14270 int16x4_t pandn_sh (int16x4_t s, int16x4_t t);
14271 int8x8_t pandn_sb (int8x8_t s, int8x8_t t);
14272 uint16x4_t pavgh (uint16x4_t s, uint16x4_t t);
14273 uint8x8_t pavgb (uint8x8_t s, uint8x8_t t);
14274 uint32x2_t pcmpeqw_u (uint32x2_t s, uint32x2_t t);
14275 uint16x4_t pcmpeqh_u (uint16x4_t s, uint16x4_t t);
14276 uint8x8_t pcmpeqb_u (uint8x8_t s, uint8x8_t t);
14277 int32x2_t pcmpeqw_s (int32x2_t s, int32x2_t t);
14278 int16x4_t pcmpeqh_s (int16x4_t s, int16x4_t t);
14279 int8x8_t pcmpeqb_s (int8x8_t s, int8x8_t t);
14280 uint32x2_t pcmpgtw_u (uint32x2_t s, uint32x2_t t);
14281 uint16x4_t pcmpgth_u (uint16x4_t s, uint16x4_t t);
14282 uint8x8_t pcmpgtb_u (uint8x8_t s, uint8x8_t t);
14283 int32x2_t pcmpgtw_s (int32x2_t s, int32x2_t t);
14284 int16x4_t pcmpgth_s (int16x4_t s, int16x4_t t);
14285 int8x8_t pcmpgtb_s (int8x8_t s, int8x8_t t);
14286 uint16x4_t pextrh_u (uint16x4_t s, int field);
14287 int16x4_t pextrh_s (int16x4_t s, int field);
14288 uint16x4_t pinsrh_0_u (uint16x4_t s, uint16x4_t t);
14289 uint16x4_t pinsrh_1_u (uint16x4_t s, uint16x4_t t);
14290 uint16x4_t pinsrh_2_u (uint16x4_t s, uint16x4_t t);
14291 uint16x4_t pinsrh_3_u (uint16x4_t s, uint16x4_t t);
14292 int16x4_t pinsrh_0_s (int16x4_t s, int16x4_t t);
14293 int16x4_t pinsrh_1_s (int16x4_t s, int16x4_t t);
14294 int16x4_t pinsrh_2_s (int16x4_t s, int16x4_t t);
14295 int16x4_t pinsrh_3_s (int16x4_t s, int16x4_t t);
14296 int32x2_t pmaddhw (int16x4_t s, int16x4_t t);
14297 int16x4_t pmaxsh (int16x4_t s, int16x4_t t);
14298 uint8x8_t pmaxub (uint8x8_t s, uint8x8_t t);
14299 int16x4_t pminsh (int16x4_t s, int16x4_t t);
14300 uint8x8_t pminub (uint8x8_t s, uint8x8_t t);
14301 uint8x8_t pmovmskb_u (uint8x8_t s);
14302 int8x8_t pmovmskb_s (int8x8_t s);
14303 uint16x4_t pmulhuh (uint16x4_t s, uint16x4_t t);
14304 int16x4_t pmulhh (int16x4_t s, int16x4_t t);
14305 int16x4_t pmullh (int16x4_t s, int16x4_t t);
14306 int64_t pmuluw (uint32x2_t s, uint32x2_t t);
14307 uint8x8_t pasubub (uint8x8_t s, uint8x8_t t);
14308 uint16x4_t biadd (uint8x8_t s);
14309 uint16x4_t psadbh (uint8x8_t s, uint8x8_t t);
14310 uint16x4_t pshufh_u (uint16x4_t dest, uint16x4_t s, uint8_t order);
14311 int16x4_t pshufh_s (int16x4_t dest, int16x4_t s, uint8_t order);
14312 uint16x4_t psllh_u (uint16x4_t s, uint8_t amount);
14313 int16x4_t psllh_s (int16x4_t s, uint8_t amount);
14314 uint32x2_t psllw_u (uint32x2_t s, uint8_t amount);
14315 int32x2_t psllw_s (int32x2_t s, uint8_t amount);
14316 uint16x4_t psrlh_u (uint16x4_t s, uint8_t amount);
14317 int16x4_t psrlh_s (int16x4_t s, uint8_t amount);
14318 uint32x2_t psrlw_u (uint32x2_t s, uint8_t amount);
14319 int32x2_t psrlw_s (int32x2_t s, uint8_t amount);
14320 uint16x4_t psrah_u (uint16x4_t s, uint8_t amount);
14321 int16x4_t psrah_s (int16x4_t s, uint8_t amount);
14322 uint32x2_t psraw_u (uint32x2_t s, uint8_t amount);
14323 int32x2_t psraw_s (int32x2_t s, uint8_t amount);
14324 uint32x2_t psubw_u (uint32x2_t s, uint32x2_t t);
14325 uint16x4_t psubh_u (uint16x4_t s, uint16x4_t t);
14326 uint8x8_t psubb_u (uint8x8_t s, uint8x8_t t);
14327 int32x2_t psubw_s (int32x2_t s, int32x2_t t);
14328 int16x4_t psubh_s (int16x4_t s, int16x4_t t);
14329 int8x8_t psubb_s (int8x8_t s, int8x8_t t);
14330 uint64_t psubd_u (uint64_t s, uint64_t t);
14331 int64_t psubd_s (int64_t s, int64_t t);
14332 int16x4_t psubsh (int16x4_t s, int16x4_t t);
14333 int8x8_t psubsb (int8x8_t s, int8x8_t t);
14334 uint16x4_t psubush (uint16x4_t s, uint16x4_t t);
14335 uint8x8_t psubusb (uint8x8_t s, uint8x8_t t);
14336 uint32x2_t punpckhwd_u (uint32x2_t s, uint32x2_t t);
14337 uint16x4_t punpckhhw_u (uint16x4_t s, uint16x4_t t);
14338 uint8x8_t punpckhbh_u (uint8x8_t s, uint8x8_t t);
14339 int32x2_t punpckhwd_s (int32x2_t s, int32x2_t t);
14340 int16x4_t punpckhhw_s (int16x4_t s, int16x4_t t);
14341 int8x8_t punpckhbh_s (int8x8_t s, int8x8_t t);
14342 uint32x2_t punpcklwd_u (uint32x2_t s, uint32x2_t t);
14343 uint16x4_t punpcklhw_u (uint16x4_t s, uint16x4_t t);
14344 uint8x8_t punpcklbh_u (uint8x8_t s, uint8x8_t t);
14345 int32x2_t punpcklwd_s (int32x2_t s, int32x2_t t);
14346 int16x4_t punpcklhw_s (int16x4_t s, int16x4_t t);
14347 int8x8_t punpcklbh_s (int8x8_t s, int8x8_t t);
14348 @end smallexample
14350 @menu
14351 * Paired-Single Arithmetic::
14352 * Paired-Single Built-in Functions::
14353 * MIPS-3D Built-in Functions::
14354 @end menu
14356 @node Paired-Single Arithmetic
14357 @subsubsection Paired-Single Arithmetic
14359 The table below lists the @code{v2sf} operations for which hardware
14360 support exists.  @code{a}, @code{b} and @code{c} are @code{v2sf}
14361 values and @code{x} is an integral value.
14363 @multitable @columnfractions .50 .50
14364 @item C code @tab MIPS instruction
14365 @item @code{a + b} @tab @code{add.ps}
14366 @item @code{a - b} @tab @code{sub.ps}
14367 @item @code{-a} @tab @code{neg.ps}
14368 @item @code{a * b} @tab @code{mul.ps}
14369 @item @code{a * b + c} @tab @code{madd.ps}
14370 @item @code{a * b - c} @tab @code{msub.ps}
14371 @item @code{-(a * b + c)} @tab @code{nmadd.ps}
14372 @item @code{-(a * b - c)} @tab @code{nmsub.ps}
14373 @item @code{x ? a : b} @tab @code{movn.ps}/@code{movz.ps}
14374 @end multitable
14376 Note that the multiply-accumulate instructions can be disabled
14377 using the command-line option @code{-mno-fused-madd}.
14379 @node Paired-Single Built-in Functions
14380 @subsubsection Paired-Single Built-in Functions
14382 The following paired-single functions map directly to a particular
14383 MIPS instruction.  Please refer to the architecture specification
14384 for details on what each instruction does.
14386 @table @code
14387 @item v2sf __builtin_mips_pll_ps (v2sf, v2sf)
14388 Pair lower lower (@code{pll.ps}).
14390 @item v2sf __builtin_mips_pul_ps (v2sf, v2sf)
14391 Pair upper lower (@code{pul.ps}).
14393 @item v2sf __builtin_mips_plu_ps (v2sf, v2sf)
14394 Pair lower upper (@code{plu.ps}).
14396 @item v2sf __builtin_mips_puu_ps (v2sf, v2sf)
14397 Pair upper upper (@code{puu.ps}).
14399 @item v2sf __builtin_mips_cvt_ps_s (float, float)
14400 Convert pair to paired single (@code{cvt.ps.s}).
14402 @item float __builtin_mips_cvt_s_pl (v2sf)
14403 Convert pair lower to single (@code{cvt.s.pl}).
14405 @item float __builtin_mips_cvt_s_pu (v2sf)
14406 Convert pair upper to single (@code{cvt.s.pu}).
14408 @item v2sf __builtin_mips_abs_ps (v2sf)
14409 Absolute value (@code{abs.ps}).
14411 @item v2sf __builtin_mips_alnv_ps (v2sf, v2sf, int)
14412 Align variable (@code{alnv.ps}).
14414 @emph{Note:} The value of the third parameter must be 0 or 4
14415 modulo 8, otherwise the result is unpredictable.  Please read the
14416 instruction description for details.
14417 @end table
14419 The following multi-instruction functions are also available.
14420 In each case, @var{cond} can be any of the 16 floating-point conditions:
14421 @code{f}, @code{un}, @code{eq}, @code{ueq}, @code{olt}, @code{ult},
14422 @code{ole}, @code{ule}, @code{sf}, @code{ngle}, @code{seq}, @code{ngl},
14423 @code{lt}, @code{nge}, @code{le} or @code{ngt}.
14425 @table @code
14426 @item v2sf __builtin_mips_movt_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
14427 @itemx v2sf __builtin_mips_movf_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
14428 Conditional move based on floating-point comparison (@code{c.@var{cond}.ps},
14429 @code{movt.ps}/@code{movf.ps}).
14431 The @code{movt} functions return the value @var{x} computed by:
14433 @smallexample
14434 c.@var{cond}.ps @var{cc},@var{a},@var{b}
14435 mov.ps @var{x},@var{c}
14436 movt.ps @var{x},@var{d},@var{cc}
14437 @end smallexample
14439 The @code{movf} functions are similar but use @code{movf.ps} instead
14440 of @code{movt.ps}.
14442 @item int __builtin_mips_upper_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
14443 @itemx int __builtin_mips_lower_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
14444 Comparison of two paired-single values (@code{c.@var{cond}.ps},
14445 @code{bc1t}/@code{bc1f}).
14447 These functions compare @var{a} and @var{b} using @code{c.@var{cond}.ps}
14448 and return either the upper or lower half of the result.  For example:
14450 @smallexample
14451 v2sf a, b;
14452 if (__builtin_mips_upper_c_eq_ps (a, b))
14453   upper_halves_are_equal ();
14454 else
14455   upper_halves_are_unequal ();
14457 if (__builtin_mips_lower_c_eq_ps (a, b))
14458   lower_halves_are_equal ();
14459 else
14460   lower_halves_are_unequal ();
14461 @end smallexample
14462 @end table
14464 @node MIPS-3D Built-in Functions
14465 @subsubsection MIPS-3D Built-in Functions
14467 The MIPS-3D Application-Specific Extension (ASE) includes additional
14468 paired-single instructions that are designed to improve the performance
14469 of 3D graphics operations.  Support for these instructions is controlled
14470 by the @option{-mips3d} command-line option.
14472 The functions listed below map directly to a particular MIPS-3D
14473 instruction.  Please refer to the architecture specification for
14474 more details on what each instruction does.
14476 @table @code
14477 @item v2sf __builtin_mips_addr_ps (v2sf, v2sf)
14478 Reduction add (@code{addr.ps}).
14480 @item v2sf __builtin_mips_mulr_ps (v2sf, v2sf)
14481 Reduction multiply (@code{mulr.ps}).
14483 @item v2sf __builtin_mips_cvt_pw_ps (v2sf)
14484 Convert paired single to paired word (@code{cvt.pw.ps}).
14486 @item v2sf __builtin_mips_cvt_ps_pw (v2sf)
14487 Convert paired word to paired single (@code{cvt.ps.pw}).
14489 @item float __builtin_mips_recip1_s (float)
14490 @itemx double __builtin_mips_recip1_d (double)
14491 @itemx v2sf __builtin_mips_recip1_ps (v2sf)
14492 Reduced-precision reciprocal (sequence step 1) (@code{recip1.@var{fmt}}).
14494 @item float __builtin_mips_recip2_s (float, float)
14495 @itemx double __builtin_mips_recip2_d (double, double)
14496 @itemx v2sf __builtin_mips_recip2_ps (v2sf, v2sf)
14497 Reduced-precision reciprocal (sequence step 2) (@code{recip2.@var{fmt}}).
14499 @item float __builtin_mips_rsqrt1_s (float)
14500 @itemx double __builtin_mips_rsqrt1_d (double)
14501 @itemx v2sf __builtin_mips_rsqrt1_ps (v2sf)
14502 Reduced-precision reciprocal square root (sequence step 1)
14503 (@code{rsqrt1.@var{fmt}}).
14505 @item float __builtin_mips_rsqrt2_s (float, float)
14506 @itemx double __builtin_mips_rsqrt2_d (double, double)
14507 @itemx v2sf __builtin_mips_rsqrt2_ps (v2sf, v2sf)
14508 Reduced-precision reciprocal square root (sequence step 2)
14509 (@code{rsqrt2.@var{fmt}}).
14510 @end table
14512 The following multi-instruction functions are also available.
14513 In each case, @var{cond} can be any of the 16 floating-point conditions:
14514 @code{f}, @code{un}, @code{eq}, @code{ueq}, @code{olt}, @code{ult},
14515 @code{ole}, @code{ule}, @code{sf}, @code{ngle}, @code{seq},
14516 @code{ngl}, @code{lt}, @code{nge}, @code{le} or @code{ngt}.
14518 @table @code
14519 @item int __builtin_mips_cabs_@var{cond}_s (float @var{a}, float @var{b})
14520 @itemx int __builtin_mips_cabs_@var{cond}_d (double @var{a}, double @var{b})
14521 Absolute comparison of two scalar values (@code{cabs.@var{cond}.@var{fmt}},
14522 @code{bc1t}/@code{bc1f}).
14524 These functions compare @var{a} and @var{b} using @code{cabs.@var{cond}.s}
14525 or @code{cabs.@var{cond}.d} and return the result as a boolean value.
14526 For example:
14528 @smallexample
14529 float a, b;
14530 if (__builtin_mips_cabs_eq_s (a, b))
14531   true ();
14532 else
14533   false ();
14534 @end smallexample
14536 @item int __builtin_mips_upper_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
14537 @itemx int __builtin_mips_lower_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
14538 Absolute comparison of two paired-single values (@code{cabs.@var{cond}.ps},
14539 @code{bc1t}/@code{bc1f}).
14541 These functions compare @var{a} and @var{b} using @code{cabs.@var{cond}.ps}
14542 and return either the upper or lower half of the result.  For example:
14544 @smallexample
14545 v2sf a, b;
14546 if (__builtin_mips_upper_cabs_eq_ps (a, b))
14547   upper_halves_are_equal ();
14548 else
14549   upper_halves_are_unequal ();
14551 if (__builtin_mips_lower_cabs_eq_ps (a, b))
14552   lower_halves_are_equal ();
14553 else
14554   lower_halves_are_unequal ();
14555 @end smallexample
14557 @item v2sf __builtin_mips_movt_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
14558 @itemx v2sf __builtin_mips_movf_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
14559 Conditional move based on absolute comparison (@code{cabs.@var{cond}.ps},
14560 @code{movt.ps}/@code{movf.ps}).
14562 The @code{movt} functions return the value @var{x} computed by:
14564 @smallexample
14565 cabs.@var{cond}.ps @var{cc},@var{a},@var{b}
14566 mov.ps @var{x},@var{c}
14567 movt.ps @var{x},@var{d},@var{cc}
14568 @end smallexample
14570 The @code{movf} functions are similar but use @code{movf.ps} instead
14571 of @code{movt.ps}.
14573 @item int __builtin_mips_any_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
14574 @itemx int __builtin_mips_all_c_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
14575 @itemx int __builtin_mips_any_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
14576 @itemx int __builtin_mips_all_cabs_@var{cond}_ps (v2sf @var{a}, v2sf @var{b})
14577 Comparison of two paired-single values
14578 (@code{c.@var{cond}.ps}/@code{cabs.@var{cond}.ps},
14579 @code{bc1any2t}/@code{bc1any2f}).
14581 These functions compare @var{a} and @var{b} using @code{c.@var{cond}.ps}
14582 or @code{cabs.@var{cond}.ps}.  The @code{any} forms return true if either
14583 result is true and the @code{all} forms return true if both results are true.
14584 For example:
14586 @smallexample
14587 v2sf a, b;
14588 if (__builtin_mips_any_c_eq_ps (a, b))
14589   one_is_true ();
14590 else
14591   both_are_false ();
14593 if (__builtin_mips_all_c_eq_ps (a, b))
14594   both_are_true ();
14595 else
14596   one_is_false ();
14597 @end smallexample
14599 @item int __builtin_mips_any_c_@var{cond}_4s (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
14600 @itemx int __builtin_mips_all_c_@var{cond}_4s (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
14601 @itemx int __builtin_mips_any_cabs_@var{cond}_4s (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
14602 @itemx int __builtin_mips_all_cabs_@var{cond}_4s (v2sf @var{a}, v2sf @var{b}, v2sf @var{c}, v2sf @var{d})
14603 Comparison of four paired-single values
14604 (@code{c.@var{cond}.ps}/@code{cabs.@var{cond}.ps},
14605 @code{bc1any4t}/@code{bc1any4f}).
14607 These functions use @code{c.@var{cond}.ps} or @code{cabs.@var{cond}.ps}
14608 to compare @var{a} with @var{b} and to compare @var{c} with @var{d}.
14609 The @code{any} forms return true if any of the four results are true
14610 and the @code{all} forms return true if all four results are true.
14611 For example:
14613 @smallexample
14614 v2sf a, b, c, d;
14615 if (__builtin_mips_any_c_eq_4s (a, b, c, d))
14616   some_are_true ();
14617 else
14618   all_are_false ();
14620 if (__builtin_mips_all_c_eq_4s (a, b, c, d))
14621   all_are_true ();
14622 else
14623   some_are_false ();
14624 @end smallexample
14625 @end table
14627 @node MIPS SIMD Architecture (MSA) Support
14628 @subsection MIPS SIMD Architecture (MSA) Support
14630 @menu
14631 * MIPS SIMD Architecture Built-in Functions::
14632 @end menu
14634 GCC provides intrinsics to access the SIMD instructions provided by the
14635 MSA MIPS SIMD Architecture.  The interface is made available by including
14636 @code{<msa.h>} and using @option{-mmsa -mhard-float -mfp64 -mnan=2008}.
14637 For each @code{__builtin_msa_*}, there is a shortened name of the intrinsic,
14638 @code{__msa_*}.
14640 MSA implements 128-bit wide vector registers, operating on 8-, 16-, 32- and
14641 64-bit integer, 16- and 32-bit fixed-point, or 32- and 64-bit floating point
14642 data elements.  The following vectors typedefs are included in @code{msa.h}:
14643 @itemize
14644 @item @code{v16i8}, a vector of sixteen signed 8-bit integers;
14645 @item @code{v16u8}, a vector of sixteen unsigned 8-bit integers;
14646 @item @code{v8i16}, a vector of eight signed 16-bit integers;
14647 @item @code{v8u16}, a vector of eight unsigned 16-bit integers;
14648 @item @code{v4i32}, a vector of four signed 32-bit integers;
14649 @item @code{v4u32}, a vector of four unsigned 32-bit integers;
14650 @item @code{v2i64}, a vector of two signed 64-bit integers;
14651 @item @code{v2u64}, a vector of two unsigned 64-bit integers;
14652 @item @code{v4f32}, a vector of four 32-bit floats;
14653 @item @code{v2f64}, a vector of two 64-bit doubles.
14654 @end itemize
14656 Instructions and corresponding built-ins may have additional restrictions and/or
14657 input/output values manipulated:
14658 @itemize
14659 @item @code{imm0_1}, an integer literal in range 0 to 1;
14660 @item @code{imm0_3}, an integer literal in range 0 to 3;
14661 @item @code{imm0_7}, an integer literal in range 0 to 7;
14662 @item @code{imm0_15}, an integer literal in range 0 to 15;
14663 @item @code{imm0_31}, an integer literal in range 0 to 31;
14664 @item @code{imm0_63}, an integer literal in range 0 to 63;
14665 @item @code{imm0_255}, an integer literal in range 0 to 255;
14666 @item @code{imm_n16_15}, an integer literal in range -16 to 15;
14667 @item @code{imm_n512_511}, an integer literal in range -512 to 511;
14668 @item @code{imm_n1024_1022}, an integer literal in range -512 to 511 left
14669 shifted by 1 bit, i.e., -1024, -1022, @dots{}, 1020, 1022;
14670 @item @code{imm_n2048_2044}, an integer literal in range -512 to 511 left
14671 shifted by 2 bits, i.e., -2048, -2044, @dots{}, 2040, 2044;
14672 @item @code{imm_n4096_4088}, an integer literal in range -512 to 511 left
14673 shifted by 3 bits, i.e., -4096, -4088, @dots{}, 4080, 4088;
14674 @item @code{imm1_4}, an integer literal in range 1 to 4;
14675 @item @code{i32, i64, u32, u64, f32, f64}, defined as follows:
14676 @end itemize
14678 @smallexample
14680 typedef int i32;
14681 #if __LONG_MAX__ == __LONG_LONG_MAX__
14682 typedef long i64;
14683 #else
14684 typedef long long i64;
14685 #endif
14687 typedef unsigned int u32;
14688 #if __LONG_MAX__ == __LONG_LONG_MAX__
14689 typedef unsigned long u64;
14690 #else
14691 typedef unsigned long long u64;
14692 #endif
14694 typedef double f64;
14695 typedef float f32;
14697 @end smallexample
14699 @node MIPS SIMD Architecture Built-in Functions
14700 @subsubsection MIPS SIMD Architecture Built-in Functions
14702 The intrinsics provided are listed below; each is named after the
14703 machine instruction.
14705 @smallexample
14706 v16i8 __builtin_msa_add_a_b (v16i8, v16i8);
14707 v8i16 __builtin_msa_add_a_h (v8i16, v8i16);
14708 v4i32 __builtin_msa_add_a_w (v4i32, v4i32);
14709 v2i64 __builtin_msa_add_a_d (v2i64, v2i64);
14711 v16i8 __builtin_msa_adds_a_b (v16i8, v16i8);
14712 v8i16 __builtin_msa_adds_a_h (v8i16, v8i16);
14713 v4i32 __builtin_msa_adds_a_w (v4i32, v4i32);
14714 v2i64 __builtin_msa_adds_a_d (v2i64, v2i64);
14716 v16i8 __builtin_msa_adds_s_b (v16i8, v16i8);
14717 v8i16 __builtin_msa_adds_s_h (v8i16, v8i16);
14718 v4i32 __builtin_msa_adds_s_w (v4i32, v4i32);
14719 v2i64 __builtin_msa_adds_s_d (v2i64, v2i64);
14721 v16u8 __builtin_msa_adds_u_b (v16u8, v16u8);
14722 v8u16 __builtin_msa_adds_u_h (v8u16, v8u16);
14723 v4u32 __builtin_msa_adds_u_w (v4u32, v4u32);
14724 v2u64 __builtin_msa_adds_u_d (v2u64, v2u64);
14726 v16i8 __builtin_msa_addv_b (v16i8, v16i8);
14727 v8i16 __builtin_msa_addv_h (v8i16, v8i16);
14728 v4i32 __builtin_msa_addv_w (v4i32, v4i32);
14729 v2i64 __builtin_msa_addv_d (v2i64, v2i64);
14731 v16i8 __builtin_msa_addvi_b (v16i8, imm0_31);
14732 v8i16 __builtin_msa_addvi_h (v8i16, imm0_31);
14733 v4i32 __builtin_msa_addvi_w (v4i32, imm0_31);
14734 v2i64 __builtin_msa_addvi_d (v2i64, imm0_31);
14736 v16u8 __builtin_msa_and_v (v16u8, v16u8);
14738 v16u8 __builtin_msa_andi_b (v16u8, imm0_255);
14740 v16i8 __builtin_msa_asub_s_b (v16i8, v16i8);
14741 v8i16 __builtin_msa_asub_s_h (v8i16, v8i16);
14742 v4i32 __builtin_msa_asub_s_w (v4i32, v4i32);
14743 v2i64 __builtin_msa_asub_s_d (v2i64, v2i64);
14745 v16u8 __builtin_msa_asub_u_b (v16u8, v16u8);
14746 v8u16 __builtin_msa_asub_u_h (v8u16, v8u16);
14747 v4u32 __builtin_msa_asub_u_w (v4u32, v4u32);
14748 v2u64 __builtin_msa_asub_u_d (v2u64, v2u64);
14750 v16i8 __builtin_msa_ave_s_b (v16i8, v16i8);
14751 v8i16 __builtin_msa_ave_s_h (v8i16, v8i16);
14752 v4i32 __builtin_msa_ave_s_w (v4i32, v4i32);
14753 v2i64 __builtin_msa_ave_s_d (v2i64, v2i64);
14755 v16u8 __builtin_msa_ave_u_b (v16u8, v16u8);
14756 v8u16 __builtin_msa_ave_u_h (v8u16, v8u16);
14757 v4u32 __builtin_msa_ave_u_w (v4u32, v4u32);
14758 v2u64 __builtin_msa_ave_u_d (v2u64, v2u64);
14760 v16i8 __builtin_msa_aver_s_b (v16i8, v16i8);
14761 v8i16 __builtin_msa_aver_s_h (v8i16, v8i16);
14762 v4i32 __builtin_msa_aver_s_w (v4i32, v4i32);
14763 v2i64 __builtin_msa_aver_s_d (v2i64, v2i64);
14765 v16u8 __builtin_msa_aver_u_b (v16u8, v16u8);
14766 v8u16 __builtin_msa_aver_u_h (v8u16, v8u16);
14767 v4u32 __builtin_msa_aver_u_w (v4u32, v4u32);
14768 v2u64 __builtin_msa_aver_u_d (v2u64, v2u64);
14770 v16u8 __builtin_msa_bclr_b (v16u8, v16u8);
14771 v8u16 __builtin_msa_bclr_h (v8u16, v8u16);
14772 v4u32 __builtin_msa_bclr_w (v4u32, v4u32);
14773 v2u64 __builtin_msa_bclr_d (v2u64, v2u64);
14775 v16u8 __builtin_msa_bclri_b (v16u8, imm0_7);
14776 v8u16 __builtin_msa_bclri_h (v8u16, imm0_15);
14777 v4u32 __builtin_msa_bclri_w (v4u32, imm0_31);
14778 v2u64 __builtin_msa_bclri_d (v2u64, imm0_63);
14780 v16u8 __builtin_msa_binsl_b (v16u8, v16u8, v16u8);
14781 v8u16 __builtin_msa_binsl_h (v8u16, v8u16, v8u16);
14782 v4u32 __builtin_msa_binsl_w (v4u32, v4u32, v4u32);
14783 v2u64 __builtin_msa_binsl_d (v2u64, v2u64, v2u64);
14785 v16u8 __builtin_msa_binsli_b (v16u8, v16u8, imm0_7);
14786 v8u16 __builtin_msa_binsli_h (v8u16, v8u16, imm0_15);
14787 v4u32 __builtin_msa_binsli_w (v4u32, v4u32, imm0_31);
14788 v2u64 __builtin_msa_binsli_d (v2u64, v2u64, imm0_63);
14790 v16u8 __builtin_msa_binsr_b (v16u8, v16u8, v16u8);
14791 v8u16 __builtin_msa_binsr_h (v8u16, v8u16, v8u16);
14792 v4u32 __builtin_msa_binsr_w (v4u32, v4u32, v4u32);
14793 v2u64 __builtin_msa_binsr_d (v2u64, v2u64, v2u64);
14795 v16u8 __builtin_msa_binsri_b (v16u8, v16u8, imm0_7);
14796 v8u16 __builtin_msa_binsri_h (v8u16, v8u16, imm0_15);
14797 v4u32 __builtin_msa_binsri_w (v4u32, v4u32, imm0_31);
14798 v2u64 __builtin_msa_binsri_d (v2u64, v2u64, imm0_63);
14800 v16u8 __builtin_msa_bmnz_v (v16u8, v16u8, v16u8);
14802 v16u8 __builtin_msa_bmnzi_b (v16u8, v16u8, imm0_255);
14804 v16u8 __builtin_msa_bmz_v (v16u8, v16u8, v16u8);
14806 v16u8 __builtin_msa_bmzi_b (v16u8, v16u8, imm0_255);
14808 v16u8 __builtin_msa_bneg_b (v16u8, v16u8);
14809 v8u16 __builtin_msa_bneg_h (v8u16, v8u16);
14810 v4u32 __builtin_msa_bneg_w (v4u32, v4u32);
14811 v2u64 __builtin_msa_bneg_d (v2u64, v2u64);
14813 v16u8 __builtin_msa_bnegi_b (v16u8, imm0_7);
14814 v8u16 __builtin_msa_bnegi_h (v8u16, imm0_15);
14815 v4u32 __builtin_msa_bnegi_w (v4u32, imm0_31);
14816 v2u64 __builtin_msa_bnegi_d (v2u64, imm0_63);
14818 i32 __builtin_msa_bnz_b (v16u8);
14819 i32 __builtin_msa_bnz_h (v8u16);
14820 i32 __builtin_msa_bnz_w (v4u32);
14821 i32 __builtin_msa_bnz_d (v2u64);
14823 i32 __builtin_msa_bnz_v (v16u8);
14825 v16u8 __builtin_msa_bsel_v (v16u8, v16u8, v16u8);
14827 v16u8 __builtin_msa_bseli_b (v16u8, v16u8, imm0_255);
14829 v16u8 __builtin_msa_bset_b (v16u8, v16u8);
14830 v8u16 __builtin_msa_bset_h (v8u16, v8u16);
14831 v4u32 __builtin_msa_bset_w (v4u32, v4u32);
14832 v2u64 __builtin_msa_bset_d (v2u64, v2u64);
14834 v16u8 __builtin_msa_bseti_b (v16u8, imm0_7);
14835 v8u16 __builtin_msa_bseti_h (v8u16, imm0_15);
14836 v4u32 __builtin_msa_bseti_w (v4u32, imm0_31);
14837 v2u64 __builtin_msa_bseti_d (v2u64, imm0_63);
14839 i32 __builtin_msa_bz_b (v16u8);
14840 i32 __builtin_msa_bz_h (v8u16);
14841 i32 __builtin_msa_bz_w (v4u32);
14842 i32 __builtin_msa_bz_d (v2u64);
14844 i32 __builtin_msa_bz_v (v16u8);
14846 v16i8 __builtin_msa_ceq_b (v16i8, v16i8);
14847 v8i16 __builtin_msa_ceq_h (v8i16, v8i16);
14848 v4i32 __builtin_msa_ceq_w (v4i32, v4i32);
14849 v2i64 __builtin_msa_ceq_d (v2i64, v2i64);
14851 v16i8 __builtin_msa_ceqi_b (v16i8, imm_n16_15);
14852 v8i16 __builtin_msa_ceqi_h (v8i16, imm_n16_15);
14853 v4i32 __builtin_msa_ceqi_w (v4i32, imm_n16_15);
14854 v2i64 __builtin_msa_ceqi_d (v2i64, imm_n16_15);
14856 i32 __builtin_msa_cfcmsa (imm0_31);
14858 v16i8 __builtin_msa_cle_s_b (v16i8, v16i8);
14859 v8i16 __builtin_msa_cle_s_h (v8i16, v8i16);
14860 v4i32 __builtin_msa_cle_s_w (v4i32, v4i32);
14861 v2i64 __builtin_msa_cle_s_d (v2i64, v2i64);
14863 v16i8 __builtin_msa_cle_u_b (v16u8, v16u8);
14864 v8i16 __builtin_msa_cle_u_h (v8u16, v8u16);
14865 v4i32 __builtin_msa_cle_u_w (v4u32, v4u32);
14866 v2i64 __builtin_msa_cle_u_d (v2u64, v2u64);
14868 v16i8 __builtin_msa_clei_s_b (v16i8, imm_n16_15);
14869 v8i16 __builtin_msa_clei_s_h (v8i16, imm_n16_15);
14870 v4i32 __builtin_msa_clei_s_w (v4i32, imm_n16_15);
14871 v2i64 __builtin_msa_clei_s_d (v2i64, imm_n16_15);
14873 v16i8 __builtin_msa_clei_u_b (v16u8, imm0_31);
14874 v8i16 __builtin_msa_clei_u_h (v8u16, imm0_31);
14875 v4i32 __builtin_msa_clei_u_w (v4u32, imm0_31);
14876 v2i64 __builtin_msa_clei_u_d (v2u64, imm0_31);
14878 v16i8 __builtin_msa_clt_s_b (v16i8, v16i8);
14879 v8i16 __builtin_msa_clt_s_h (v8i16, v8i16);
14880 v4i32 __builtin_msa_clt_s_w (v4i32, v4i32);
14881 v2i64 __builtin_msa_clt_s_d (v2i64, v2i64);
14883 v16i8 __builtin_msa_clt_u_b (v16u8, v16u8);
14884 v8i16 __builtin_msa_clt_u_h (v8u16, v8u16);
14885 v4i32 __builtin_msa_clt_u_w (v4u32, v4u32);
14886 v2i64 __builtin_msa_clt_u_d (v2u64, v2u64);
14888 v16i8 __builtin_msa_clti_s_b (v16i8, imm_n16_15);
14889 v8i16 __builtin_msa_clti_s_h (v8i16, imm_n16_15);
14890 v4i32 __builtin_msa_clti_s_w (v4i32, imm_n16_15);
14891 v2i64 __builtin_msa_clti_s_d (v2i64, imm_n16_15);
14893 v16i8 __builtin_msa_clti_u_b (v16u8, imm0_31);
14894 v8i16 __builtin_msa_clti_u_h (v8u16, imm0_31);
14895 v4i32 __builtin_msa_clti_u_w (v4u32, imm0_31);
14896 v2i64 __builtin_msa_clti_u_d (v2u64, imm0_31);
14898 i32 __builtin_msa_copy_s_b (v16i8, imm0_15);
14899 i32 __builtin_msa_copy_s_h (v8i16, imm0_7);
14900 i32 __builtin_msa_copy_s_w (v4i32, imm0_3);
14901 i64 __builtin_msa_copy_s_d (v2i64, imm0_1);
14903 u32 __builtin_msa_copy_u_b (v16i8, imm0_15);
14904 u32 __builtin_msa_copy_u_h (v8i16, imm0_7);
14905 u32 __builtin_msa_copy_u_w (v4i32, imm0_3);
14906 u64 __builtin_msa_copy_u_d (v2i64, imm0_1);
14908 void __builtin_msa_ctcmsa (imm0_31, i32);
14910 v16i8 __builtin_msa_div_s_b (v16i8, v16i8);
14911 v8i16 __builtin_msa_div_s_h (v8i16, v8i16);
14912 v4i32 __builtin_msa_div_s_w (v4i32, v4i32);
14913 v2i64 __builtin_msa_div_s_d (v2i64, v2i64);
14915 v16u8 __builtin_msa_div_u_b (v16u8, v16u8);
14916 v8u16 __builtin_msa_div_u_h (v8u16, v8u16);
14917 v4u32 __builtin_msa_div_u_w (v4u32, v4u32);
14918 v2u64 __builtin_msa_div_u_d (v2u64, v2u64);
14920 v8i16 __builtin_msa_dotp_s_h (v16i8, v16i8);
14921 v4i32 __builtin_msa_dotp_s_w (v8i16, v8i16);
14922 v2i64 __builtin_msa_dotp_s_d (v4i32, v4i32);
14924 v8u16 __builtin_msa_dotp_u_h (v16u8, v16u8);
14925 v4u32 __builtin_msa_dotp_u_w (v8u16, v8u16);
14926 v2u64 __builtin_msa_dotp_u_d (v4u32, v4u32);
14928 v8i16 __builtin_msa_dpadd_s_h (v8i16, v16i8, v16i8);
14929 v4i32 __builtin_msa_dpadd_s_w (v4i32, v8i16, v8i16);
14930 v2i64 __builtin_msa_dpadd_s_d (v2i64, v4i32, v4i32);
14932 v8u16 __builtin_msa_dpadd_u_h (v8u16, v16u8, v16u8);
14933 v4u32 __builtin_msa_dpadd_u_w (v4u32, v8u16, v8u16);
14934 v2u64 __builtin_msa_dpadd_u_d (v2u64, v4u32, v4u32);
14936 v8i16 __builtin_msa_dpsub_s_h (v8i16, v16i8, v16i8);
14937 v4i32 __builtin_msa_dpsub_s_w (v4i32, v8i16, v8i16);
14938 v2i64 __builtin_msa_dpsub_s_d (v2i64, v4i32, v4i32);
14940 v8i16 __builtin_msa_dpsub_u_h (v8i16, v16u8, v16u8);
14941 v4i32 __builtin_msa_dpsub_u_w (v4i32, v8u16, v8u16);
14942 v2i64 __builtin_msa_dpsub_u_d (v2i64, v4u32, v4u32);
14944 v4f32 __builtin_msa_fadd_w (v4f32, v4f32);
14945 v2f64 __builtin_msa_fadd_d (v2f64, v2f64);
14947 v4i32 __builtin_msa_fcaf_w (v4f32, v4f32);
14948 v2i64 __builtin_msa_fcaf_d (v2f64, v2f64);
14950 v4i32 __builtin_msa_fceq_w (v4f32, v4f32);
14951 v2i64 __builtin_msa_fceq_d (v2f64, v2f64);
14953 v4i32 __builtin_msa_fclass_w (v4f32);
14954 v2i64 __builtin_msa_fclass_d (v2f64);
14956 v4i32 __builtin_msa_fcle_w (v4f32, v4f32);
14957 v2i64 __builtin_msa_fcle_d (v2f64, v2f64);
14959 v4i32 __builtin_msa_fclt_w (v4f32, v4f32);
14960 v2i64 __builtin_msa_fclt_d (v2f64, v2f64);
14962 v4i32 __builtin_msa_fcne_w (v4f32, v4f32);
14963 v2i64 __builtin_msa_fcne_d (v2f64, v2f64);
14965 v4i32 __builtin_msa_fcor_w (v4f32, v4f32);
14966 v2i64 __builtin_msa_fcor_d (v2f64, v2f64);
14968 v4i32 __builtin_msa_fcueq_w (v4f32, v4f32);
14969 v2i64 __builtin_msa_fcueq_d (v2f64, v2f64);
14971 v4i32 __builtin_msa_fcule_w (v4f32, v4f32);
14972 v2i64 __builtin_msa_fcule_d (v2f64, v2f64);
14974 v4i32 __builtin_msa_fcult_w (v4f32, v4f32);
14975 v2i64 __builtin_msa_fcult_d (v2f64, v2f64);
14977 v4i32 __builtin_msa_fcun_w (v4f32, v4f32);
14978 v2i64 __builtin_msa_fcun_d (v2f64, v2f64);
14980 v4i32 __builtin_msa_fcune_w (v4f32, v4f32);
14981 v2i64 __builtin_msa_fcune_d (v2f64, v2f64);
14983 v4f32 __builtin_msa_fdiv_w (v4f32, v4f32);
14984 v2f64 __builtin_msa_fdiv_d (v2f64, v2f64);
14986 v8i16 __builtin_msa_fexdo_h (v4f32, v4f32);
14987 v4f32 __builtin_msa_fexdo_w (v2f64, v2f64);
14989 v4f32 __builtin_msa_fexp2_w (v4f32, v4i32);
14990 v2f64 __builtin_msa_fexp2_d (v2f64, v2i64);
14992 v4f32 __builtin_msa_fexupl_w (v8i16);
14993 v2f64 __builtin_msa_fexupl_d (v4f32);
14995 v4f32 __builtin_msa_fexupr_w (v8i16);
14996 v2f64 __builtin_msa_fexupr_d (v4f32);
14998 v4f32 __builtin_msa_ffint_s_w (v4i32);
14999 v2f64 __builtin_msa_ffint_s_d (v2i64);
15001 v4f32 __builtin_msa_ffint_u_w (v4u32);
15002 v2f64 __builtin_msa_ffint_u_d (v2u64);
15004 v4f32 __builtin_msa_ffql_w (v8i16);
15005 v2f64 __builtin_msa_ffql_d (v4i32);
15007 v4f32 __builtin_msa_ffqr_w (v8i16);
15008 v2f64 __builtin_msa_ffqr_d (v4i32);
15010 v16i8 __builtin_msa_fill_b (i32);
15011 v8i16 __builtin_msa_fill_h (i32);
15012 v4i32 __builtin_msa_fill_w (i32);
15013 v2i64 __builtin_msa_fill_d (i64);
15015 v4f32 __builtin_msa_flog2_w (v4f32);
15016 v2f64 __builtin_msa_flog2_d (v2f64);
15018 v4f32 __builtin_msa_fmadd_w (v4f32, v4f32, v4f32);
15019 v2f64 __builtin_msa_fmadd_d (v2f64, v2f64, v2f64);
15021 v4f32 __builtin_msa_fmax_w (v4f32, v4f32);
15022 v2f64 __builtin_msa_fmax_d (v2f64, v2f64);
15024 v4f32 __builtin_msa_fmax_a_w (v4f32, v4f32);
15025 v2f64 __builtin_msa_fmax_a_d (v2f64, v2f64);
15027 v4f32 __builtin_msa_fmin_w (v4f32, v4f32);
15028 v2f64 __builtin_msa_fmin_d (v2f64, v2f64);
15030 v4f32 __builtin_msa_fmin_a_w (v4f32, v4f32);
15031 v2f64 __builtin_msa_fmin_a_d (v2f64, v2f64);
15033 v4f32 __builtin_msa_fmsub_w (v4f32, v4f32, v4f32);
15034 v2f64 __builtin_msa_fmsub_d (v2f64, v2f64, v2f64);
15036 v4f32 __builtin_msa_fmul_w (v4f32, v4f32);
15037 v2f64 __builtin_msa_fmul_d (v2f64, v2f64);
15039 v4f32 __builtin_msa_frint_w (v4f32);
15040 v2f64 __builtin_msa_frint_d (v2f64);
15042 v4f32 __builtin_msa_frcp_w (v4f32);
15043 v2f64 __builtin_msa_frcp_d (v2f64);
15045 v4f32 __builtin_msa_frsqrt_w (v4f32);
15046 v2f64 __builtin_msa_frsqrt_d (v2f64);
15048 v4i32 __builtin_msa_fsaf_w (v4f32, v4f32);
15049 v2i64 __builtin_msa_fsaf_d (v2f64, v2f64);
15051 v4i32 __builtin_msa_fseq_w (v4f32, v4f32);
15052 v2i64 __builtin_msa_fseq_d (v2f64, v2f64);
15054 v4i32 __builtin_msa_fsle_w (v4f32, v4f32);
15055 v2i64 __builtin_msa_fsle_d (v2f64, v2f64);
15057 v4i32 __builtin_msa_fslt_w (v4f32, v4f32);
15058 v2i64 __builtin_msa_fslt_d (v2f64, v2f64);
15060 v4i32 __builtin_msa_fsne_w (v4f32, v4f32);
15061 v2i64 __builtin_msa_fsne_d (v2f64, v2f64);
15063 v4i32 __builtin_msa_fsor_w (v4f32, v4f32);
15064 v2i64 __builtin_msa_fsor_d (v2f64, v2f64);
15066 v4f32 __builtin_msa_fsqrt_w (v4f32);
15067 v2f64 __builtin_msa_fsqrt_d (v2f64);
15069 v4f32 __builtin_msa_fsub_w (v4f32, v4f32);
15070 v2f64 __builtin_msa_fsub_d (v2f64, v2f64);
15072 v4i32 __builtin_msa_fsueq_w (v4f32, v4f32);
15073 v2i64 __builtin_msa_fsueq_d (v2f64, v2f64);
15075 v4i32 __builtin_msa_fsule_w (v4f32, v4f32);
15076 v2i64 __builtin_msa_fsule_d (v2f64, v2f64);
15078 v4i32 __builtin_msa_fsult_w (v4f32, v4f32);
15079 v2i64 __builtin_msa_fsult_d (v2f64, v2f64);
15081 v4i32 __builtin_msa_fsun_w (v4f32, v4f32);
15082 v2i64 __builtin_msa_fsun_d (v2f64, v2f64);
15084 v4i32 __builtin_msa_fsune_w (v4f32, v4f32);
15085 v2i64 __builtin_msa_fsune_d (v2f64, v2f64);
15087 v4i32 __builtin_msa_ftint_s_w (v4f32);
15088 v2i64 __builtin_msa_ftint_s_d (v2f64);
15090 v4u32 __builtin_msa_ftint_u_w (v4f32);
15091 v2u64 __builtin_msa_ftint_u_d (v2f64);
15093 v8i16 __builtin_msa_ftq_h (v4f32, v4f32);
15094 v4i32 __builtin_msa_ftq_w (v2f64, v2f64);
15096 v4i32 __builtin_msa_ftrunc_s_w (v4f32);
15097 v2i64 __builtin_msa_ftrunc_s_d (v2f64);
15099 v4u32 __builtin_msa_ftrunc_u_w (v4f32);
15100 v2u64 __builtin_msa_ftrunc_u_d (v2f64);
15102 v8i16 __builtin_msa_hadd_s_h (v16i8, v16i8);
15103 v4i32 __builtin_msa_hadd_s_w (v8i16, v8i16);
15104 v2i64 __builtin_msa_hadd_s_d (v4i32, v4i32);
15106 v8u16 __builtin_msa_hadd_u_h (v16u8, v16u8);
15107 v4u32 __builtin_msa_hadd_u_w (v8u16, v8u16);
15108 v2u64 __builtin_msa_hadd_u_d (v4u32, v4u32);
15110 v8i16 __builtin_msa_hsub_s_h (v16i8, v16i8);
15111 v4i32 __builtin_msa_hsub_s_w (v8i16, v8i16);
15112 v2i64 __builtin_msa_hsub_s_d (v4i32, v4i32);
15114 v8i16 __builtin_msa_hsub_u_h (v16u8, v16u8);
15115 v4i32 __builtin_msa_hsub_u_w (v8u16, v8u16);
15116 v2i64 __builtin_msa_hsub_u_d (v4u32, v4u32);
15118 v16i8 __builtin_msa_ilvev_b (v16i8, v16i8);
15119 v8i16 __builtin_msa_ilvev_h (v8i16, v8i16);
15120 v4i32 __builtin_msa_ilvev_w (v4i32, v4i32);
15121 v2i64 __builtin_msa_ilvev_d (v2i64, v2i64);
15123 v16i8 __builtin_msa_ilvl_b (v16i8, v16i8);
15124 v8i16 __builtin_msa_ilvl_h (v8i16, v8i16);
15125 v4i32 __builtin_msa_ilvl_w (v4i32, v4i32);
15126 v2i64 __builtin_msa_ilvl_d (v2i64, v2i64);
15128 v16i8 __builtin_msa_ilvod_b (v16i8, v16i8);
15129 v8i16 __builtin_msa_ilvod_h (v8i16, v8i16);
15130 v4i32 __builtin_msa_ilvod_w (v4i32, v4i32);
15131 v2i64 __builtin_msa_ilvod_d (v2i64, v2i64);
15133 v16i8 __builtin_msa_ilvr_b (v16i8, v16i8);
15134 v8i16 __builtin_msa_ilvr_h (v8i16, v8i16);
15135 v4i32 __builtin_msa_ilvr_w (v4i32, v4i32);
15136 v2i64 __builtin_msa_ilvr_d (v2i64, v2i64);
15138 v16i8 __builtin_msa_insert_b (v16i8, imm0_15, i32);
15139 v8i16 __builtin_msa_insert_h (v8i16, imm0_7, i32);
15140 v4i32 __builtin_msa_insert_w (v4i32, imm0_3, i32);
15141 v2i64 __builtin_msa_insert_d (v2i64, imm0_1, i64);
15143 v16i8 __builtin_msa_insve_b (v16i8, imm0_15, v16i8);
15144 v8i16 __builtin_msa_insve_h (v8i16, imm0_7, v8i16);
15145 v4i32 __builtin_msa_insve_w (v4i32, imm0_3, v4i32);
15146 v2i64 __builtin_msa_insve_d (v2i64, imm0_1, v2i64);
15148 v16i8 __builtin_msa_ld_b (void *, imm_n512_511);
15149 v8i16 __builtin_msa_ld_h (void *, imm_n1024_1022);
15150 v4i32 __builtin_msa_ld_w (void *, imm_n2048_2044);
15151 v2i64 __builtin_msa_ld_d (void *, imm_n4096_4088);
15153 v16i8 __builtin_msa_ldi_b (imm_n512_511);
15154 v8i16 __builtin_msa_ldi_h (imm_n512_511);
15155 v4i32 __builtin_msa_ldi_w (imm_n512_511);
15156 v2i64 __builtin_msa_ldi_d (imm_n512_511);
15158 v8i16 __builtin_msa_madd_q_h (v8i16, v8i16, v8i16);
15159 v4i32 __builtin_msa_madd_q_w (v4i32, v4i32, v4i32);
15161 v8i16 __builtin_msa_maddr_q_h (v8i16, v8i16, v8i16);
15162 v4i32 __builtin_msa_maddr_q_w (v4i32, v4i32, v4i32);
15164 v16i8 __builtin_msa_maddv_b (v16i8, v16i8, v16i8);
15165 v8i16 __builtin_msa_maddv_h (v8i16, v8i16, v8i16);
15166 v4i32 __builtin_msa_maddv_w (v4i32, v4i32, v4i32);
15167 v2i64 __builtin_msa_maddv_d (v2i64, v2i64, v2i64);
15169 v16i8 __builtin_msa_max_a_b (v16i8, v16i8);
15170 v8i16 __builtin_msa_max_a_h (v8i16, v8i16);
15171 v4i32 __builtin_msa_max_a_w (v4i32, v4i32);
15172 v2i64 __builtin_msa_max_a_d (v2i64, v2i64);
15174 v16i8 __builtin_msa_max_s_b (v16i8, v16i8);
15175 v8i16 __builtin_msa_max_s_h (v8i16, v8i16);
15176 v4i32 __builtin_msa_max_s_w (v4i32, v4i32);
15177 v2i64 __builtin_msa_max_s_d (v2i64, v2i64);
15179 v16u8 __builtin_msa_max_u_b (v16u8, v16u8);
15180 v8u16 __builtin_msa_max_u_h (v8u16, v8u16);
15181 v4u32 __builtin_msa_max_u_w (v4u32, v4u32);
15182 v2u64 __builtin_msa_max_u_d (v2u64, v2u64);
15184 v16i8 __builtin_msa_maxi_s_b (v16i8, imm_n16_15);
15185 v8i16 __builtin_msa_maxi_s_h (v8i16, imm_n16_15);
15186 v4i32 __builtin_msa_maxi_s_w (v4i32, imm_n16_15);
15187 v2i64 __builtin_msa_maxi_s_d (v2i64, imm_n16_15);
15189 v16u8 __builtin_msa_maxi_u_b (v16u8, imm0_31);
15190 v8u16 __builtin_msa_maxi_u_h (v8u16, imm0_31);
15191 v4u32 __builtin_msa_maxi_u_w (v4u32, imm0_31);
15192 v2u64 __builtin_msa_maxi_u_d (v2u64, imm0_31);
15194 v16i8 __builtin_msa_min_a_b (v16i8, v16i8);
15195 v8i16 __builtin_msa_min_a_h (v8i16, v8i16);
15196 v4i32 __builtin_msa_min_a_w (v4i32, v4i32);
15197 v2i64 __builtin_msa_min_a_d (v2i64, v2i64);
15199 v16i8 __builtin_msa_min_s_b (v16i8, v16i8);
15200 v8i16 __builtin_msa_min_s_h (v8i16, v8i16);
15201 v4i32 __builtin_msa_min_s_w (v4i32, v4i32);
15202 v2i64 __builtin_msa_min_s_d (v2i64, v2i64);
15204 v16u8 __builtin_msa_min_u_b (v16u8, v16u8);
15205 v8u16 __builtin_msa_min_u_h (v8u16, v8u16);
15206 v4u32 __builtin_msa_min_u_w (v4u32, v4u32);
15207 v2u64 __builtin_msa_min_u_d (v2u64, v2u64);
15209 v16i8 __builtin_msa_mini_s_b (v16i8, imm_n16_15);
15210 v8i16 __builtin_msa_mini_s_h (v8i16, imm_n16_15);
15211 v4i32 __builtin_msa_mini_s_w (v4i32, imm_n16_15);
15212 v2i64 __builtin_msa_mini_s_d (v2i64, imm_n16_15);
15214 v16u8 __builtin_msa_mini_u_b (v16u8, imm0_31);
15215 v8u16 __builtin_msa_mini_u_h (v8u16, imm0_31);
15216 v4u32 __builtin_msa_mini_u_w (v4u32, imm0_31);
15217 v2u64 __builtin_msa_mini_u_d (v2u64, imm0_31);
15219 v16i8 __builtin_msa_mod_s_b (v16i8, v16i8);
15220 v8i16 __builtin_msa_mod_s_h (v8i16, v8i16);
15221 v4i32 __builtin_msa_mod_s_w (v4i32, v4i32);
15222 v2i64 __builtin_msa_mod_s_d (v2i64, v2i64);
15224 v16u8 __builtin_msa_mod_u_b (v16u8, v16u8);
15225 v8u16 __builtin_msa_mod_u_h (v8u16, v8u16);
15226 v4u32 __builtin_msa_mod_u_w (v4u32, v4u32);
15227 v2u64 __builtin_msa_mod_u_d (v2u64, v2u64);
15229 v16i8 __builtin_msa_move_v (v16i8);
15231 v8i16 __builtin_msa_msub_q_h (v8i16, v8i16, v8i16);
15232 v4i32 __builtin_msa_msub_q_w (v4i32, v4i32, v4i32);
15234 v8i16 __builtin_msa_msubr_q_h (v8i16, v8i16, v8i16);
15235 v4i32 __builtin_msa_msubr_q_w (v4i32, v4i32, v4i32);
15237 v16i8 __builtin_msa_msubv_b (v16i8, v16i8, v16i8);
15238 v8i16 __builtin_msa_msubv_h (v8i16, v8i16, v8i16);
15239 v4i32 __builtin_msa_msubv_w (v4i32, v4i32, v4i32);
15240 v2i64 __builtin_msa_msubv_d (v2i64, v2i64, v2i64);
15242 v8i16 __builtin_msa_mul_q_h (v8i16, v8i16);
15243 v4i32 __builtin_msa_mul_q_w (v4i32, v4i32);
15245 v8i16 __builtin_msa_mulr_q_h (v8i16, v8i16);
15246 v4i32 __builtin_msa_mulr_q_w (v4i32, v4i32);
15248 v16i8 __builtin_msa_mulv_b (v16i8, v16i8);
15249 v8i16 __builtin_msa_mulv_h (v8i16, v8i16);
15250 v4i32 __builtin_msa_mulv_w (v4i32, v4i32);
15251 v2i64 __builtin_msa_mulv_d (v2i64, v2i64);
15253 v16i8 __builtin_msa_nloc_b (v16i8);
15254 v8i16 __builtin_msa_nloc_h (v8i16);
15255 v4i32 __builtin_msa_nloc_w (v4i32);
15256 v2i64 __builtin_msa_nloc_d (v2i64);
15258 v16i8 __builtin_msa_nlzc_b (v16i8);
15259 v8i16 __builtin_msa_nlzc_h (v8i16);
15260 v4i32 __builtin_msa_nlzc_w (v4i32);
15261 v2i64 __builtin_msa_nlzc_d (v2i64);
15263 v16u8 __builtin_msa_nor_v (v16u8, v16u8);
15265 v16u8 __builtin_msa_nori_b (v16u8, imm0_255);
15267 v16u8 __builtin_msa_or_v (v16u8, v16u8);
15269 v16u8 __builtin_msa_ori_b (v16u8, imm0_255);
15271 v16i8 __builtin_msa_pckev_b (v16i8, v16i8);
15272 v8i16 __builtin_msa_pckev_h (v8i16, v8i16);
15273 v4i32 __builtin_msa_pckev_w (v4i32, v4i32);
15274 v2i64 __builtin_msa_pckev_d (v2i64, v2i64);
15276 v16i8 __builtin_msa_pckod_b (v16i8, v16i8);
15277 v8i16 __builtin_msa_pckod_h (v8i16, v8i16);
15278 v4i32 __builtin_msa_pckod_w (v4i32, v4i32);
15279 v2i64 __builtin_msa_pckod_d (v2i64, v2i64);
15281 v16i8 __builtin_msa_pcnt_b (v16i8);
15282 v8i16 __builtin_msa_pcnt_h (v8i16);
15283 v4i32 __builtin_msa_pcnt_w (v4i32);
15284 v2i64 __builtin_msa_pcnt_d (v2i64);
15286 v16i8 __builtin_msa_sat_s_b (v16i8, imm0_7);
15287 v8i16 __builtin_msa_sat_s_h (v8i16, imm0_15);
15288 v4i32 __builtin_msa_sat_s_w (v4i32, imm0_31);
15289 v2i64 __builtin_msa_sat_s_d (v2i64, imm0_63);
15291 v16u8 __builtin_msa_sat_u_b (v16u8, imm0_7);
15292 v8u16 __builtin_msa_sat_u_h (v8u16, imm0_15);
15293 v4u32 __builtin_msa_sat_u_w (v4u32, imm0_31);
15294 v2u64 __builtin_msa_sat_u_d (v2u64, imm0_63);
15296 v16i8 __builtin_msa_shf_b (v16i8, imm0_255);
15297 v8i16 __builtin_msa_shf_h (v8i16, imm0_255);
15298 v4i32 __builtin_msa_shf_w (v4i32, imm0_255);
15300 v16i8 __builtin_msa_sld_b (v16i8, v16i8, i32);
15301 v8i16 __builtin_msa_sld_h (v8i16, v8i16, i32);
15302 v4i32 __builtin_msa_sld_w (v4i32, v4i32, i32);
15303 v2i64 __builtin_msa_sld_d (v2i64, v2i64, i32);
15305 v16i8 __builtin_msa_sldi_b (v16i8, v16i8, imm0_15);
15306 v8i16 __builtin_msa_sldi_h (v8i16, v8i16, imm0_7);
15307 v4i32 __builtin_msa_sldi_w (v4i32, v4i32, imm0_3);
15308 v2i64 __builtin_msa_sldi_d (v2i64, v2i64, imm0_1);
15310 v16i8 __builtin_msa_sll_b (v16i8, v16i8);
15311 v8i16 __builtin_msa_sll_h (v8i16, v8i16);
15312 v4i32 __builtin_msa_sll_w (v4i32, v4i32);
15313 v2i64 __builtin_msa_sll_d (v2i64, v2i64);
15315 v16i8 __builtin_msa_slli_b (v16i8, imm0_7);
15316 v8i16 __builtin_msa_slli_h (v8i16, imm0_15);
15317 v4i32 __builtin_msa_slli_w (v4i32, imm0_31);
15318 v2i64 __builtin_msa_slli_d (v2i64, imm0_63);
15320 v16i8 __builtin_msa_splat_b (v16i8, i32);
15321 v8i16 __builtin_msa_splat_h (v8i16, i32);
15322 v4i32 __builtin_msa_splat_w (v4i32, i32);
15323 v2i64 __builtin_msa_splat_d (v2i64, i32);
15325 v16i8 __builtin_msa_splati_b (v16i8, imm0_15);
15326 v8i16 __builtin_msa_splati_h (v8i16, imm0_7);
15327 v4i32 __builtin_msa_splati_w (v4i32, imm0_3);
15328 v2i64 __builtin_msa_splati_d (v2i64, imm0_1);
15330 v16i8 __builtin_msa_sra_b (v16i8, v16i8);
15331 v8i16 __builtin_msa_sra_h (v8i16, v8i16);
15332 v4i32 __builtin_msa_sra_w (v4i32, v4i32);
15333 v2i64 __builtin_msa_sra_d (v2i64, v2i64);
15335 v16i8 __builtin_msa_srai_b (v16i8, imm0_7);
15336 v8i16 __builtin_msa_srai_h (v8i16, imm0_15);
15337 v4i32 __builtin_msa_srai_w (v4i32, imm0_31);
15338 v2i64 __builtin_msa_srai_d (v2i64, imm0_63);
15340 v16i8 __builtin_msa_srar_b (v16i8, v16i8);
15341 v8i16 __builtin_msa_srar_h (v8i16, v8i16);
15342 v4i32 __builtin_msa_srar_w (v4i32, v4i32);
15343 v2i64 __builtin_msa_srar_d (v2i64, v2i64);
15345 v16i8 __builtin_msa_srari_b (v16i8, imm0_7);
15346 v8i16 __builtin_msa_srari_h (v8i16, imm0_15);
15347 v4i32 __builtin_msa_srari_w (v4i32, imm0_31);
15348 v2i64 __builtin_msa_srari_d (v2i64, imm0_63);
15350 v16i8 __builtin_msa_srl_b (v16i8, v16i8);
15351 v8i16 __builtin_msa_srl_h (v8i16, v8i16);
15352 v4i32 __builtin_msa_srl_w (v4i32, v4i32);
15353 v2i64 __builtin_msa_srl_d (v2i64, v2i64);
15355 v16i8 __builtin_msa_srli_b (v16i8, imm0_7);
15356 v8i16 __builtin_msa_srli_h (v8i16, imm0_15);
15357 v4i32 __builtin_msa_srli_w (v4i32, imm0_31);
15358 v2i64 __builtin_msa_srli_d (v2i64, imm0_63);
15360 v16i8 __builtin_msa_srlr_b (v16i8, v16i8);
15361 v8i16 __builtin_msa_srlr_h (v8i16, v8i16);
15362 v4i32 __builtin_msa_srlr_w (v4i32, v4i32);
15363 v2i64 __builtin_msa_srlr_d (v2i64, v2i64);
15365 v16i8 __builtin_msa_srlri_b (v16i8, imm0_7);
15366 v8i16 __builtin_msa_srlri_h (v8i16, imm0_15);
15367 v4i32 __builtin_msa_srlri_w (v4i32, imm0_31);
15368 v2i64 __builtin_msa_srlri_d (v2i64, imm0_63);
15370 void __builtin_msa_st_b (v16i8, void *, imm_n512_511);
15371 void __builtin_msa_st_h (v8i16, void *, imm_n1024_1022);
15372 void __builtin_msa_st_w (v4i32, void *, imm_n2048_2044);
15373 void __builtin_msa_st_d (v2i64, void *, imm_n4096_4088);
15375 v16i8 __builtin_msa_subs_s_b (v16i8, v16i8);
15376 v8i16 __builtin_msa_subs_s_h (v8i16, v8i16);
15377 v4i32 __builtin_msa_subs_s_w (v4i32, v4i32);
15378 v2i64 __builtin_msa_subs_s_d (v2i64, v2i64);
15380 v16u8 __builtin_msa_subs_u_b (v16u8, v16u8);
15381 v8u16 __builtin_msa_subs_u_h (v8u16, v8u16);
15382 v4u32 __builtin_msa_subs_u_w (v4u32, v4u32);
15383 v2u64 __builtin_msa_subs_u_d (v2u64, v2u64);
15385 v16u8 __builtin_msa_subsus_u_b (v16u8, v16i8);
15386 v8u16 __builtin_msa_subsus_u_h (v8u16, v8i16);
15387 v4u32 __builtin_msa_subsus_u_w (v4u32, v4i32);
15388 v2u64 __builtin_msa_subsus_u_d (v2u64, v2i64);
15390 v16i8 __builtin_msa_subsuu_s_b (v16u8, v16u8);
15391 v8i16 __builtin_msa_subsuu_s_h (v8u16, v8u16);
15392 v4i32 __builtin_msa_subsuu_s_w (v4u32, v4u32);
15393 v2i64 __builtin_msa_subsuu_s_d (v2u64, v2u64);
15395 v16i8 __builtin_msa_subv_b (v16i8, v16i8);
15396 v8i16 __builtin_msa_subv_h (v8i16, v8i16);
15397 v4i32 __builtin_msa_subv_w (v4i32, v4i32);
15398 v2i64 __builtin_msa_subv_d (v2i64, v2i64);
15400 v16i8 __builtin_msa_subvi_b (v16i8, imm0_31);
15401 v8i16 __builtin_msa_subvi_h (v8i16, imm0_31);
15402 v4i32 __builtin_msa_subvi_w (v4i32, imm0_31);
15403 v2i64 __builtin_msa_subvi_d (v2i64, imm0_31);
15405 v16i8 __builtin_msa_vshf_b (v16i8, v16i8, v16i8);
15406 v8i16 __builtin_msa_vshf_h (v8i16, v8i16, v8i16);
15407 v4i32 __builtin_msa_vshf_w (v4i32, v4i32, v4i32);
15408 v2i64 __builtin_msa_vshf_d (v2i64, v2i64, v2i64);
15410 v16u8 __builtin_msa_xor_v (v16u8, v16u8);
15412 v16u8 __builtin_msa_xori_b (v16u8, imm0_255);
15413 @end smallexample
15415 @node Other MIPS Built-in Functions
15416 @subsection Other MIPS Built-in Functions
15418 GCC provides other MIPS-specific built-in functions:
15420 @table @code
15421 @item void __builtin_mips_cache (int @var{op}, const volatile void *@var{addr})
15422 Insert a @samp{cache} instruction with operands @var{op} and @var{addr}.
15423 GCC defines the preprocessor macro @code{___GCC_HAVE_BUILTIN_MIPS_CACHE}
15424 when this function is available.
15426 @item unsigned int __builtin_mips_get_fcsr (void)
15427 @itemx void __builtin_mips_set_fcsr (unsigned int @var{value})
15428 Get and set the contents of the floating-point control and status register
15429 (FPU control register 31).  These functions are only available in hard-float
15430 code but can be called in both MIPS16 and non-MIPS16 contexts.
15432 @code{__builtin_mips_set_fcsr} can be used to change any bit of the
15433 register except the condition codes, which GCC assumes are preserved.
15434 @end table
15436 @node MSP430 Built-in Functions
15437 @subsection MSP430 Built-in Functions
15439 GCC provides a couple of special builtin functions to aid in the
15440 writing of interrupt handlers in C.
15442 @table @code
15443 @item __bic_SR_register_on_exit (int @var{mask})
15444 This clears the indicated bits in the saved copy of the status register
15445 currently residing on the stack.  This only works inside interrupt
15446 handlers and the changes to the status register will only take affect
15447 once the handler returns.
15449 @item __bis_SR_register_on_exit (int @var{mask})
15450 This sets the indicated bits in the saved copy of the status register
15451 currently residing on the stack.  This only works inside interrupt
15452 handlers and the changes to the status register will only take affect
15453 once the handler returns.
15455 @item __delay_cycles (long long @var{cycles})
15456 This inserts an instruction sequence that takes exactly @var{cycles}
15457 cycles (between 0 and about 17E9) to complete.  The inserted sequence
15458 may use jumps, loops, or no-ops, and does not interfere with any other
15459 instructions.  Note that @var{cycles} must be a compile-time constant
15460 integer - that is, you must pass a number, not a variable that may be
15461 optimized to a constant later.  The number of cycles delayed by this
15462 builtin is exact.
15463 @end table
15465 @node NDS32 Built-in Functions
15466 @subsection NDS32 Built-in Functions
15468 These built-in functions are available for the NDS32 target:
15470 @deftypefn {Built-in Function} void __builtin_nds32_isync (int *@var{addr})
15471 Insert an ISYNC instruction into the instruction stream where
15472 @var{addr} is an instruction address for serialization.
15473 @end deftypefn
15475 @deftypefn {Built-in Function} void __builtin_nds32_isb (void)
15476 Insert an ISB instruction into the instruction stream.
15477 @end deftypefn
15479 @deftypefn {Built-in Function} int __builtin_nds32_mfsr (int @var{sr})
15480 Return the content of a system register which is mapped by @var{sr}.
15481 @end deftypefn
15483 @deftypefn {Built-in Function} int __builtin_nds32_mfusr (int @var{usr})
15484 Return the content of a user space register which is mapped by @var{usr}.
15485 @end deftypefn
15487 @deftypefn {Built-in Function} void __builtin_nds32_mtsr (int @var{value}, int @var{sr})
15488 Move the @var{value} to a system register which is mapped by @var{sr}.
15489 @end deftypefn
15491 @deftypefn {Built-in Function} void __builtin_nds32_mtusr (int @var{value}, int @var{usr})
15492 Move the @var{value} to a user space register which is mapped by @var{usr}.
15493 @end deftypefn
15495 @deftypefn {Built-in Function} void __builtin_nds32_setgie_en (void)
15496 Enable global interrupt.
15497 @end deftypefn
15499 @deftypefn {Built-in Function} void __builtin_nds32_setgie_dis (void)
15500 Disable global interrupt.
15501 @end deftypefn
15503 @node picoChip Built-in Functions
15504 @subsection picoChip Built-in Functions
15506 GCC provides an interface to selected machine instructions from the
15507 picoChip instruction set.
15509 @table @code
15510 @item int __builtin_sbc (int @var{value})
15511 Sign bit count.  Return the number of consecutive bits in @var{value}
15512 that have the same value as the sign bit.  The result is the number of
15513 leading sign bits minus one, giving the number of redundant sign bits in
15514 @var{value}.
15516 @item int __builtin_byteswap (int @var{value})
15517 Byte swap.  Return the result of swapping the upper and lower bytes of
15518 @var{value}.
15520 @item int __builtin_brev (int @var{value})
15521 Bit reversal.  Return the result of reversing the bits in
15522 @var{value}.  Bit 15 is swapped with bit 0, bit 14 is swapped with bit 1,
15523 and so on.
15525 @item int __builtin_adds (int @var{x}, int @var{y})
15526 Saturating addition.  Return the result of adding @var{x} and @var{y},
15527 storing the value 32767 if the result overflows.
15529 @item int __builtin_subs (int @var{x}, int @var{y})
15530 Saturating subtraction.  Return the result of subtracting @var{y} from
15531 @var{x}, storing the value @minus{}32768 if the result overflows.
15533 @item void __builtin_halt (void)
15534 Halt.  The processor stops execution.  This built-in is useful for
15535 implementing assertions.
15537 @end table
15539 @node Basic PowerPC Built-in Functions
15540 @subsection Basic PowerPC Built-in Functions
15542 @menu
15543 * Basic PowerPC Built-in Functions Available on all Configurations::
15544 * Basic PowerPC Built-in Functions Available on ISA 2.05::
15545 * Basic PowerPC Built-in Functions Available on ISA 2.06::
15546 * Basic PowerPC Built-in Functions Available on ISA 2.07::
15547 * Basic PowerPC Built-in Functions Available on ISA 3.0::
15548 @end menu
15550 This section describes PowerPC built-in functions that do not require
15551 the inclusion of any special header files to declare prototypes or
15552 provide macro definitions.  The sections that follow describe
15553 additional PowerPC built-in functions.
15555 @node Basic PowerPC Built-in Functions Available on all Configurations
15556 @subsubsection Basic PowerPC Built-in Functions Available on all Configurations
15558 @deftypefn {Built-in Function} void __builtin_cpu_init (void)
15559 This function is a @code{nop} on the PowerPC platform and is included solely
15560 to maintain API compatibility with the x86 builtins.
15561 @end deftypefn
15563 @deftypefn {Built-in Function} int __builtin_cpu_is (const char *@var{cpuname})
15564 This function returns a value of @code{1} if the run-time CPU is of type
15565 @var{cpuname} and returns @code{0} otherwise
15567 The @code{__builtin_cpu_is} function requires GLIBC 2.23 or newer
15568 which exports the hardware capability bits.  GCC defines the macro
15569 @code{__BUILTIN_CPU_SUPPORTS__} if the @code{__builtin_cpu_supports}
15570 built-in function is fully supported.
15572 If GCC was configured to use a GLIBC before 2.23, the built-in
15573 function @code{__builtin_cpu_is} always returns a 0 and the compiler
15574 issues a warning.
15576 The following CPU names can be detected:
15578 @table @samp
15579 @item power9
15580 IBM POWER9 Server CPU.
15581 @item power8
15582 IBM POWER8 Server CPU.
15583 @item power7
15584 IBM POWER7 Server CPU.
15585 @item power6x
15586 IBM POWER6 Server CPU (RAW mode).
15587 @item power6
15588 IBM POWER6 Server CPU (Architected mode).
15589 @item power5+
15590 IBM POWER5+ Server CPU.
15591 @item power5
15592 IBM POWER5 Server CPU.
15593 @item ppc970
15594 IBM 970 Server CPU (ie, Apple G5).
15595 @item power4
15596 IBM POWER4 Server CPU.
15597 @item ppca2
15598 IBM A2 64-bit Embedded CPU
15599 @item ppc476
15600 IBM PowerPC 476FP 32-bit Embedded CPU.
15601 @item ppc464
15602 IBM PowerPC 464 32-bit Embedded CPU.
15603 @item ppc440
15604 PowerPC 440 32-bit Embedded CPU.
15605 @item ppc405
15606 PowerPC 405 32-bit Embedded CPU.
15607 @item ppc-cell-be
15608 IBM PowerPC Cell Broadband Engine Architecture CPU.
15609 @end table
15611 Here is an example:
15612 @smallexample
15613 #ifdef __BUILTIN_CPU_SUPPORTS__
15614   if (__builtin_cpu_is ("power8"))
15615     @{
15616        do_power8 (); // POWER8 specific implementation.
15617     @}
15618   else
15619 #endif
15620     @{
15621        do_generic (); // Generic implementation.
15622     @}
15623 @end smallexample
15624 @end deftypefn
15626 @deftypefn {Built-in Function} int __builtin_cpu_supports (const char *@var{feature})
15627 This function returns a value of @code{1} if the run-time CPU supports the HWCAP
15628 feature @var{feature} and returns @code{0} otherwise.
15630 The @code{__builtin_cpu_supports} function requires GLIBC 2.23 or
15631 newer which exports the hardware capability bits.  GCC defines the
15632 macro @code{__BUILTIN_CPU_SUPPORTS__} if the
15633 @code{__builtin_cpu_supports} built-in function is fully supported.
15635 If GCC was configured to use a GLIBC before 2.23, the built-in
15636 function @code{__builtin_cpu_suports} always returns a 0 and the
15637 compiler issues a warning.
15639 The following features can be
15640 detected:
15642 @table @samp
15643 @item 4xxmac
15644 4xx CPU has a Multiply Accumulator.
15645 @item altivec
15646 CPU has a SIMD/Vector Unit.
15647 @item arch_2_05
15648 CPU supports ISA 2.05 (eg, POWER6)
15649 @item arch_2_06
15650 CPU supports ISA 2.06 (eg, POWER7)
15651 @item arch_2_07
15652 CPU supports ISA 2.07 (eg, POWER8)
15653 @item arch_3_00
15654 CPU supports ISA 3.0 (eg, POWER9)
15655 @item archpmu
15656 CPU supports the set of compatible performance monitoring events.
15657 @item booke
15658 CPU supports the Embedded ISA category.
15659 @item cellbe
15660 CPU has a CELL broadband engine.
15661 @item darn
15662 CPU supports the @code{darn} (deliver a random number) instruction.
15663 @item dfp
15664 CPU has a decimal floating point unit.
15665 @item dscr
15666 CPU supports the data stream control register.
15667 @item ebb
15668 CPU supports event base branching.
15669 @item efpdouble
15670 CPU has a SPE double precision floating point unit.
15671 @item efpsingle
15672 CPU has a SPE single precision floating point unit.
15673 @item fpu
15674 CPU has a floating point unit.
15675 @item htm
15676 CPU has hardware transaction memory instructions.
15677 @item htm-nosc
15678 Kernel aborts hardware transactions when a syscall is made.
15679 @item htm-no-suspend
15680 CPU supports hardware transaction memory but does not support the
15681 @code{tsuspend.} instruction.
15682 @item ic_snoop
15683 CPU supports icache snooping capabilities.
15684 @item ieee128
15685 CPU supports 128-bit IEEE binary floating point instructions.
15686 @item isel
15687 CPU supports the integer select instruction.
15688 @item mmu
15689 CPU has a memory management unit.
15690 @item notb
15691 CPU does not have a timebase (eg, 601 and 403gx).
15692 @item pa6t
15693 CPU supports the PA Semi 6T CORE ISA.
15694 @item power4
15695 CPU supports ISA 2.00 (eg, POWER4)
15696 @item power5
15697 CPU supports ISA 2.02 (eg, POWER5)
15698 @item power5+
15699 CPU supports ISA 2.03 (eg, POWER5+)
15700 @item power6x
15701 CPU supports ISA 2.05 (eg, POWER6) extended opcodes mffgpr and mftgpr.
15702 @item ppc32
15703 CPU supports 32-bit mode execution.
15704 @item ppc601
15705 CPU supports the old POWER ISA (eg, 601)
15706 @item ppc64
15707 CPU supports 64-bit mode execution.
15708 @item ppcle
15709 CPU supports a little-endian mode that uses address swizzling.
15710 @item scv
15711 Kernel supports system call vectored.
15712 @item smt
15713 CPU support simultaneous multi-threading.
15714 @item spe
15715 CPU has a signal processing extension unit.
15716 @item tar
15717 CPU supports the target address register.
15718 @item true_le
15719 CPU supports true little-endian mode.
15720 @item ucache
15721 CPU has unified I/D cache.
15722 @item vcrypto
15723 CPU supports the vector cryptography instructions.
15724 @item vsx
15725 CPU supports the vector-scalar extension.
15726 @end table
15728 Here is an example:
15729 @smallexample
15730 #ifdef __BUILTIN_CPU_SUPPORTS__
15731   if (__builtin_cpu_supports ("fpu"))
15732     @{
15733        asm("fadd %0,%1,%2" : "=d"(dst) : "d"(src1), "d"(src2));
15734     @}
15735   else
15736 #endif
15737     @{
15738        dst = __fadd (src1, src2); // Software FP addition function.
15739     @}
15740 @end smallexample
15741 @end deftypefn
15743 The following built-in functions are also available on all PowerPC
15744 processors:
15745 @smallexample
15746 uint64_t __builtin_ppc_get_timebase ();
15747 unsigned long __builtin_ppc_mftb ();
15748 @end smallexample
15750 The @code{__builtin_ppc_get_timebase} and @code{__builtin_ppc_mftb}
15751 functions generate instructions to read the Time Base Register.  The
15752 @code{__builtin_ppc_get_timebase} function may generate multiple
15753 instructions and always returns the 64 bits of the Time Base Register.
15754 The @code{__builtin_ppc_mftb} function always generates one instruction and
15755 returns the Time Base Register value as an unsigned long, throwing away
15756 the most significant word on 32-bit environments.
15758 @node Basic PowerPC Built-in Functions Available on ISA 2.05
15759 @subsubsection Basic PowerPC Built-in Functions Available on ISA 2.05
15761 The basic built-in functions described in this section are
15762 available on the PowerPC family of processors starting with ISA 2.05
15763 or later.  Unless specific options are explicitly disabled on the
15764 command line, specifying option @option{-mcpu=power6} has the effect of
15765 enabling the @option{-mpowerpc64}, @option{-mpowerpc-gpopt},
15766 @option{-mpowerpc-gfxopt}, @option{-mmfcrf}, @option{-mpopcntb},
15767 @option{-mfprnd}, @option{-mcmpb}, @option{-mhard-dfp}, and
15768 @option{-mrecip-precision} options.  Specify the
15769 @option{-maltivec} and @option{-mfpgpr} options explicitly in
15770 combination with the above options if they are desired.
15772 The following functions require option @option{-mcmpb}.
15773 @smallexample
15774 unsigned long long __builtin_cmpb (unsigned long long int, unsigned long long int);
15775 unsigned int __builtin_cmpb (unsigned int, unsigned int);
15776 @end smallexample
15778 The @code{__builtin_cmpb} function
15779 performs a byte-wise compare on the contents of its two arguments,
15780 returning the result of the byte-wise comparison as the returned
15781 value.  For each byte comparison, the corresponding byte of the return
15782 value holds 0xff if the input bytes are equal and 0 if the input bytes
15783 are not equal.  If either of the arguments to this built-in function
15784 is wider than 32 bits, the function call expands into the form that
15785 expects @code{unsigned long long int} arguments
15786 which is only available on 64-bit targets.
15788 The following built-in functions are available
15789 when hardware decimal floating point
15790 (@option{-mhard-dfp}) is available:
15791 @smallexample
15792 _Decimal64 __builtin_ddedpd (int, _Decimal64);
15793 _Decimal128 __builtin_ddedpdq (int, _Decimal128);
15794 _Decimal64 __builtin_denbcd (int, _Decimal64);
15795 _Decimal128 __builtin_denbcdq (int, _Decimal128);
15796 _Decimal64 __builtin_diex (long long, _Decimal64);
15797 _Decimal128 _builtin_diexq (long long, _Decimal128);
15798 _Decimal64 __builtin_dscli (_Decimal64, int);
15799 _Decimal128 __builtin_dscliq (_Decimal128, int);
15800 _Decimal64 __builtin_dscri (_Decimal64, int);
15801 _Decimal128 __builtin_dscriq (_Decimal128, int);
15802 long long __builtin_dxex (_Decimal64);
15803 long long __builtin_dxexq (_Decimal128);
15804 _Decimal128 __builtin_pack_dec128 (unsigned long long, unsigned long long);
15805 unsigned long long __builtin_unpack_dec128 (_Decimal128, int);
15806 @end smallexample
15808 The following functions require @option{-mhard-float},
15809 @option{-mpowerpc-gfxopt}, and @option{-mpopcntb} options.
15811 @smallexample
15812 double __builtin_recipdiv (double, double);
15813 float __builtin_recipdivf (float, float);
15814 double __builtin_rsqrt (double);
15815 float __builtin_rsqrtf (float);
15816 @end smallexample
15818 The @code{vec_rsqrt}, @code{__builtin_rsqrt}, and
15819 @code{__builtin_rsqrtf} functions generate multiple instructions to
15820 implement the reciprocal sqrt functionality using reciprocal sqrt
15821 estimate instructions.
15823 The @code{__builtin_recipdiv}, and @code{__builtin_recipdivf}
15824 functions generate multiple instructions to implement division using
15825 the reciprocal estimate instructions.
15827 The following functions require @option{-mhard-float} and
15828 @option{-mmultiple} options.
15830 @smallexample
15831 long double __builtin_pack_longdouble (double, double);
15832 double __builtin_unpack_longdouble (long double, int);
15833 @end smallexample
15835 @node Basic PowerPC Built-in Functions Available on ISA 2.06
15836 @subsubsection Basic PowerPC Built-in Functions Available on ISA 2.06
15838 The basic built-in functions described in this section are
15839 available on the PowerPC family of processors starting with ISA 2.05
15840 or later.  Unless specific options are explicitly disabled on the
15841 command line, specifying option @option{-mcpu=power7} has the effect of
15842 enabling all the same options as for @option{-mcpu=power6} in
15843 addition to the @option{-maltivec}, @option{-mpopcntd}, and
15844 @option{-mvsx} options.
15846 The following basic built-in functions require @option{-mpopcntd}:
15847 @smallexample
15848 unsigned int __builtin_addg6s (unsigned int, unsigned int);
15849 long long __builtin_bpermd (long long, long long);
15850 unsigned int __builtin_cbcdtd (unsigned int);
15851 unsigned int __builtin_cdtbcd (unsigned int);
15852 long long __builtin_divde (long long, long long);
15853 unsigned long long __builtin_divdeu (unsigned long long, unsigned long long);
15854 int __builtin_divwe (int, int);
15855 unsigned int __builtin_divweu (unsigned int, unsigned int);
15856 vector __int128_t __builtin_pack_vector_int128 (long long, long long);
15857 void __builtin_rs6000_speculation_barrier (void);
15858 long long __builtin_unpack_vector_int128 (vector __int128_t, signed char);
15859 @end smallexample
15861 Of these, the @code{__builtin_divde} and @code{__builtin_divdeu} functions
15862 require a 64-bit environment.
15864 The following basic built-in functions, which are also supported on
15865 x86 targets, require @option{-mfloat128}.
15866 @smallexample
15867 __float128 __builtin_fabsq (__float128);
15868 __float128 __builtin_copysignq (__float128, __float128);
15869 __float128 __builtin_infq (void);
15870 __float128 __builtin_huge_valq (void);
15871 __float128 __builtin_nanq (void);
15872 __float128 __builtin_nansq (void);
15874 __float128 __builtin_sqrtf128 (__float128);
15875 __float128 __builtin_fmaf128 (__float128, __float128, __float128);
15876 @end smallexample
15878 @node Basic PowerPC Built-in Functions Available on ISA 2.07
15879 @subsubsection Basic PowerPC Built-in Functions Available on ISA 2.07
15881 The basic built-in functions described in this section are
15882 available on the PowerPC family of processors starting with ISA 2.07
15883 or later.  Unless specific options are explicitly disabled on the
15884 command line, specifying option @option{-mcpu=power8} has the effect of
15885 enabling all the same options as for @option{-mcpu=power7} in
15886 addition to the @option{-mpower8-fusion}, @option{-mpower8-vector},
15887 @option{-mcrypto}, @option{-mhtm}, @option{-mquad-memory}, and
15888 @option{-mquad-memory-atomic} options.
15890 This section intentionally empty.
15892 @node Basic PowerPC Built-in Functions Available on ISA 3.0
15893 @subsubsection Basic PowerPC Built-in Functions Available on ISA 3.0
15895 The basic built-in functions described in this section are
15896 available on the PowerPC family of processors starting with ISA 3.0
15897 or later.  Unless specific options are explicitly disabled on the
15898 command line, specifying option @option{-mcpu=power9} has the effect of
15899 enabling all the same options as for @option{-mcpu=power8} in
15900 addition to the @option{-misel} option.
15902 The following built-in functions are available on Linux 64-bit systems
15903 that use the ISA 3.0 instruction set (@option{-mcpu=power9}):
15905 @table @code
15906 @item __float128 __builtin_addf128_round_to_odd (__float128, __float128)
15907 Perform a 128-bit IEEE floating point add using round to odd as the
15908 rounding mode.
15909 @findex __builtin_addf128_round_to_odd
15911 @item __float128 __builtin_subf128_round_to_odd (__float128, __float128)
15912 Perform a 128-bit IEEE floating point subtract using round to odd as
15913 the rounding mode.
15914 @findex __builtin_subf128_round_to_odd
15916 @item __float128 __builtin_mulf128_round_to_odd (__float128, __float128)
15917 Perform a 128-bit IEEE floating point multiply using round to odd as
15918 the rounding mode.
15919 @findex __builtin_mulf128_round_to_odd
15921 @item __float128 __builtin_divf128_round_to_odd (__float128, __float128)
15922 Perform a 128-bit IEEE floating point divide using round to odd as
15923 the rounding mode.
15924 @findex __builtin_divf128_round_to_odd
15926 @item __float128 __builtin_sqrtf128_round_to_odd (__float128)
15927 Perform a 128-bit IEEE floating point square root using round to odd
15928 as the rounding mode.
15929 @findex __builtin_sqrtf128_round_to_odd
15931 @item __float128 __builtin_fmaf128_round_to_odd (__float128, __float128, __float128)
15932 Perform a 128-bit IEEE floating point fused multiply and add operation
15933 using round to odd as the rounding mode.
15934 @findex __builtin_fmaf128_round_to_odd
15936 @item double __builtin_truncf128_round_to_odd (__float128)
15937 Convert a 128-bit IEEE floating point value to @code{double} using
15938 round to odd as the rounding mode.
15939 @findex __builtin_truncf128_round_to_odd
15940 @end table
15942 The following additional built-in functions are also available for the
15943 PowerPC family of processors, starting with ISA 3.0 or later:
15944 @smallexample
15945 long long __builtin_darn (void);
15946 long long __builtin_darn_raw (void);
15947 int __builtin_darn_32 (void);
15948 @end smallexample
15950 The @code{__builtin_darn} and @code{__builtin_darn_raw}
15951 functions require a
15952 64-bit environment supporting ISA 3.0 or later.
15953 The @code{__builtin_darn} function provides a 64-bit conditioned
15954 random number.  The @code{__builtin_darn_raw} function provides a
15955 64-bit raw random number.  The @code{__builtin_darn_32} function
15956 provides a 32-bit conditioned random number.
15958 The following additional built-in functions are also available for the
15959 PowerPC family of processors, starting with ISA 3.0 or later:
15961 @smallexample
15962 int __builtin_byte_in_set (unsigned char u, unsigned long long set);
15963 int __builtin_byte_in_range (unsigned char u, unsigned int range);
15964 int __builtin_byte_in_either_range (unsigned char u, unsigned int ranges);
15966 int __builtin_dfp_dtstsfi_lt (unsigned int comparison, _Decimal64 value);
15967 int __builtin_dfp_dtstsfi_lt (unsigned int comparison, _Decimal128 value);
15968 int __builtin_dfp_dtstsfi_lt_dd (unsigned int comparison, _Decimal64 value);
15969 int __builtin_dfp_dtstsfi_lt_td (unsigned int comparison, _Decimal128 value);
15971 int __builtin_dfp_dtstsfi_gt (unsigned int comparison, _Decimal64 value);
15972 int __builtin_dfp_dtstsfi_gt (unsigned int comparison, _Decimal128 value);
15973 int __builtin_dfp_dtstsfi_gt_dd (unsigned int comparison, _Decimal64 value);
15974 int __builtin_dfp_dtstsfi_gt_td (unsigned int comparison, _Decimal128 value);
15976 int __builtin_dfp_dtstsfi_eq (unsigned int comparison, _Decimal64 value);
15977 int __builtin_dfp_dtstsfi_eq (unsigned int comparison, _Decimal128 value);
15978 int __builtin_dfp_dtstsfi_eq_dd (unsigned int comparison, _Decimal64 value);
15979 int __builtin_dfp_dtstsfi_eq_td (unsigned int comparison, _Decimal128 value);
15981 int __builtin_dfp_dtstsfi_ov (unsigned int comparison, _Decimal64 value);
15982 int __builtin_dfp_dtstsfi_ov (unsigned int comparison, _Decimal128 value);
15983 int __builtin_dfp_dtstsfi_ov_dd (unsigned int comparison, _Decimal64 value);
15984 int __builtin_dfp_dtstsfi_ov_td (unsigned int comparison, _Decimal128 value);
15985 @end smallexample
15986 The @code{__builtin_byte_in_set} function requires a
15987 64-bit environment supporting ISA 3.0 or later.  This function returns
15988 a non-zero value if and only if its @code{u} argument exactly equals one of
15989 the eight bytes contained within its 64-bit @code{set} argument.
15991 The @code{__builtin_byte_in_range} and
15992 @code{__builtin_byte_in_either_range} require an environment
15993 supporting ISA 3.0 or later.  For these two functions, the
15994 @code{range} argument is encoded as 4 bytes, organized as
15995 @code{hi_1:lo_1:hi_2:lo_2}.
15996 The @code{__builtin_byte_in_range} function returns a
15997 non-zero value if and only if its @code{u} argument is within the
15998 range bounded between @code{lo_2} and @code{hi_2} inclusive.
15999 The @code{__builtin_byte_in_either_range} function returns non-zero if
16000 and only if its @code{u} argument is within either the range bounded
16001 between @code{lo_1} and @code{hi_1} inclusive or the range bounded
16002 between @code{lo_2} and @code{hi_2} inclusive.
16004 The @code{__builtin_dfp_dtstsfi_lt} function returns a non-zero value
16005 if and only if the number of signficant digits of its @code{value} argument
16006 is less than its @code{comparison} argument.  The
16007 @code{__builtin_dfp_dtstsfi_lt_dd} and
16008 @code{__builtin_dfp_dtstsfi_lt_td} functions behave similarly, but
16009 require that the type of the @code{value} argument be
16010 @code{__Decimal64} and @code{__Decimal128} respectively.
16012 The @code{__builtin_dfp_dtstsfi_gt} function returns a non-zero value
16013 if and only if the number of signficant digits of its @code{value} argument
16014 is greater than its @code{comparison} argument.  The
16015 @code{__builtin_dfp_dtstsfi_gt_dd} and
16016 @code{__builtin_dfp_dtstsfi_gt_td} functions behave similarly, but
16017 require that the type of the @code{value} argument be
16018 @code{__Decimal64} and @code{__Decimal128} respectively.
16020 The @code{__builtin_dfp_dtstsfi_eq} function returns a non-zero value
16021 if and only if the number of signficant digits of its @code{value} argument
16022 equals its @code{comparison} argument.  The
16023 @code{__builtin_dfp_dtstsfi_eq_dd} and
16024 @code{__builtin_dfp_dtstsfi_eq_td} functions behave similarly, but
16025 require that the type of the @code{value} argument be
16026 @code{__Decimal64} and @code{__Decimal128} respectively.
16028 The @code{__builtin_dfp_dtstsfi_ov} function returns a non-zero value
16029 if and only if its @code{value} argument has an undefined number of
16030 significant digits, such as when @code{value} is an encoding of @code{NaN}.
16031 The @code{__builtin_dfp_dtstsfi_ov_dd} and
16032 @code{__builtin_dfp_dtstsfi_ov_td} functions behave similarly, but
16033 require that the type of the @code{value} argument be
16034 @code{__Decimal64} and @code{__Decimal128} respectively.
16038 @node PowerPC AltiVec/VSX Built-in Functions
16039 @subsection PowerPC AltiVec Built-in Functions
16041 GCC provides an interface for the PowerPC family of processors to access
16042 the AltiVec operations described in Motorola's AltiVec Programming
16043 Interface Manual.  The interface is made available by including
16044 @code{<altivec.h>} and using @option{-maltivec} and
16045 @option{-mabi=altivec}.  The interface supports the following vector
16046 types.
16048 @smallexample
16049 vector unsigned char
16050 vector signed char
16051 vector bool char
16053 vector unsigned short
16054 vector signed short
16055 vector bool short
16056 vector pixel
16058 vector unsigned int
16059 vector signed int
16060 vector bool int
16061 vector float
16062 @end smallexample
16064 If @option{-mvsx} is used the following additional vector types are
16065 implemented.
16067 @smallexample
16068 vector unsigned long
16069 vector signed long
16070 vector double
16071 @end smallexample
16073 The long types are only implemented for 64-bit code generation, and
16074 the long type is only used in the floating point/integer conversion
16075 instructions.
16077 GCC's implementation of the high-level language interface available from
16078 C and C++ code differs from Motorola's documentation in several ways.
16080 @itemize @bullet
16082 @item
16083 A vector constant is a list of constant expressions within curly braces.
16085 @item
16086 A vector initializer requires no cast if the vector constant is of the
16087 same type as the variable it is initializing.
16089 @item
16090 If @code{signed} or @code{unsigned} is omitted, the signedness of the
16091 vector type is the default signedness of the base type.  The default
16092 varies depending on the operating system, so a portable program should
16093 always specify the signedness.
16095 @item
16096 Compiling with @option{-maltivec} adds keywords @code{__vector},
16097 @code{vector}, @code{__pixel}, @code{pixel}, @code{__bool} and
16098 @code{bool}.  When compiling ISO C, the context-sensitive substitution
16099 of the keywords @code{vector}, @code{pixel} and @code{bool} is
16100 disabled.  To use them, you must include @code{<altivec.h>} instead.
16102 @item
16103 GCC allows using a @code{typedef} name as the type specifier for a
16104 vector type.
16106 @item
16107 For C, overloaded functions are implemented with macros so the following
16108 does not work:
16110 @smallexample
16111   vec_add ((vector signed int)@{1, 2, 3, 4@}, foo);
16112 @end smallexample
16114 @noindent
16115 Since @code{vec_add} is a macro, the vector constant in the example
16116 is treated as four separate arguments.  Wrap the entire argument in
16117 parentheses for this to work.
16118 @end itemize
16120 @emph{Note:} Only the @code{<altivec.h>} interface is supported.
16121 Internally, GCC uses built-in functions to achieve the functionality in
16122 the aforementioned header file, but they are not supported and are
16123 subject to change without notice.
16125 GCC complies with the OpenPOWER 64-Bit ELF V2 ABI Specification,
16126 which may be found at
16127 @uref{http://openpowerfoundation.org/wp-content/uploads/resources/leabi-prd/content/index.html}.
16128 Appendix A of this document lists the vector API interfaces that must be
16129 provided by compliant compilers.  Programmers should preferentially use
16130 the interfaces described therein.  However, historically GCC has provided
16131 additional interfaces for access to vector instructions.  These are
16132 briefly described below.
16134 The following interfaces are supported for the generic and specific
16135 AltiVec operations and the AltiVec predicates.  In cases where there
16136 is a direct mapping between generic and specific operations, only the
16137 generic names are shown here, although the specific operations can also
16138 be used.
16140 Arguments that are documented as @code{const int} require literal
16141 integral values within the range required for that operation.
16143 @smallexample
16144 vector signed char vec_abs (vector signed char);
16145 vector signed short vec_abs (vector signed short);
16146 vector signed int vec_abs (vector signed int);
16147 vector float vec_abs (vector float);
16149 vector signed char vec_abss (vector signed char);
16150 vector signed short vec_abss (vector signed short);
16151 vector signed int vec_abss (vector signed int);
16153 vector signed char vec_add (vector bool char, vector signed char);
16154 vector signed char vec_add (vector signed char, vector bool char);
16155 vector signed char vec_add (vector signed char, vector signed char);
16156 vector unsigned char vec_add (vector bool char, vector unsigned char);
16157 vector unsigned char vec_add (vector unsigned char, vector bool char);
16158 vector unsigned char vec_add (vector unsigned char,
16159                               vector unsigned char);
16160 vector signed short vec_add (vector bool short, vector signed short);
16161 vector signed short vec_add (vector signed short, vector bool short);
16162 vector signed short vec_add (vector signed short, vector signed short);
16163 vector unsigned short vec_add (vector bool short,
16164                                vector unsigned short);
16165 vector unsigned short vec_add (vector unsigned short,
16166                                vector bool short);
16167 vector unsigned short vec_add (vector unsigned short,
16168                                vector unsigned short);
16169 vector signed int vec_add (vector bool int, vector signed int);
16170 vector signed int vec_add (vector signed int, vector bool int);
16171 vector signed int vec_add (vector signed int, vector signed int);
16172 vector unsigned int vec_add (vector bool int, vector unsigned int);
16173 vector unsigned int vec_add (vector unsigned int, vector bool int);
16174 vector unsigned int vec_add (vector unsigned int, vector unsigned int);
16175 vector float vec_add (vector float, vector float);
16177 vector float vec_vaddfp (vector float, vector float);
16179 vector signed int vec_vadduwm (vector bool int, vector signed int);
16180 vector signed int vec_vadduwm (vector signed int, vector bool int);
16181 vector signed int vec_vadduwm (vector signed int, vector signed int);
16182 vector unsigned int vec_vadduwm (vector bool int, vector unsigned int);
16183 vector unsigned int vec_vadduwm (vector unsigned int, vector bool int);
16184 vector unsigned int vec_vadduwm (vector unsigned int,
16185                                  vector unsigned int);
16187 vector signed short vec_vadduhm (vector bool short,
16188                                  vector signed short);
16189 vector signed short vec_vadduhm (vector signed short,
16190                                  vector bool short);
16191 vector signed short vec_vadduhm (vector signed short,
16192                                  vector signed short);
16193 vector unsigned short vec_vadduhm (vector bool short,
16194                                    vector unsigned short);
16195 vector unsigned short vec_vadduhm (vector unsigned short,
16196                                    vector bool short);
16197 vector unsigned short vec_vadduhm (vector unsigned short,
16198                                    vector unsigned short);
16200 vector signed char vec_vaddubm (vector bool char, vector signed char);
16201 vector signed char vec_vaddubm (vector signed char, vector bool char);
16202 vector signed char vec_vaddubm (vector signed char, vector signed char);
16203 vector unsigned char vec_vaddubm (vector bool char,
16204                                   vector unsigned char);
16205 vector unsigned char vec_vaddubm (vector unsigned char,
16206                                   vector bool char);
16207 vector unsigned char vec_vaddubm (vector unsigned char,
16208                                   vector unsigned char);
16210 vector unsigned int vec_addc (vector unsigned int, vector unsigned int);
16212 vector unsigned char vec_adds (vector bool char, vector unsigned char);
16213 vector unsigned char vec_adds (vector unsigned char, vector bool char);
16214 vector unsigned char vec_adds (vector unsigned char,
16215                                vector unsigned char);
16216 vector signed char vec_adds (vector bool char, vector signed char);
16217 vector signed char vec_adds (vector signed char, vector bool char);
16218 vector signed char vec_adds (vector signed char, vector signed char);
16219 vector unsigned short vec_adds (vector bool short,
16220                                 vector unsigned short);
16221 vector unsigned short vec_adds (vector unsigned short,
16222                                 vector bool short);
16223 vector unsigned short vec_adds (vector unsigned short,
16224                                 vector unsigned short);
16225 vector signed short vec_adds (vector bool short, vector signed short);
16226 vector signed short vec_adds (vector signed short, vector bool short);
16227 vector signed short vec_adds (vector signed short, vector signed short);
16228 vector unsigned int vec_adds (vector bool int, vector unsigned int);
16229 vector unsigned int vec_adds (vector unsigned int, vector bool int);
16230 vector unsigned int vec_adds (vector unsigned int, vector unsigned int);
16231 vector signed int vec_adds (vector bool int, vector signed int);
16232 vector signed int vec_adds (vector signed int, vector bool int);
16233 vector signed int vec_adds (vector signed int, vector signed int);
16235 vector signed int vec_vaddsws (vector bool int, vector signed int);
16236 vector signed int vec_vaddsws (vector signed int, vector bool int);
16237 vector signed int vec_vaddsws (vector signed int, vector signed int);
16239 vector unsigned int vec_vadduws (vector bool int, vector unsigned int);
16240 vector unsigned int vec_vadduws (vector unsigned int, vector bool int);
16241 vector unsigned int vec_vadduws (vector unsigned int,
16242                                  vector unsigned int);
16244 vector signed short vec_vaddshs (vector bool short,
16245                                  vector signed short);
16246 vector signed short vec_vaddshs (vector signed short,
16247                                  vector bool short);
16248 vector signed short vec_vaddshs (vector signed short,
16249                                  vector signed short);
16251 vector unsigned short vec_vadduhs (vector bool short,
16252                                    vector unsigned short);
16253 vector unsigned short vec_vadduhs (vector unsigned short,
16254                                    vector bool short);
16255 vector unsigned short vec_vadduhs (vector unsigned short,
16256                                    vector unsigned short);
16258 vector signed char vec_vaddsbs (vector bool char, vector signed char);
16259 vector signed char vec_vaddsbs (vector signed char, vector bool char);
16260 vector signed char vec_vaddsbs (vector signed char, vector signed char);
16262 vector unsigned char vec_vaddubs (vector bool char,
16263                                   vector unsigned char);
16264 vector unsigned char vec_vaddubs (vector unsigned char,
16265                                   vector bool char);
16266 vector unsigned char vec_vaddubs (vector unsigned char,
16267                                   vector unsigned char);
16269 vector float vec_and (vector float, vector float);
16270 vector float vec_and (vector float, vector bool int);
16271 vector float vec_and (vector bool int, vector float);
16272 vector bool long long vec_and (vector bool long long int,
16273                                vector bool long long);
16274 vector bool int vec_and (vector bool int, vector bool int);
16275 vector signed int vec_and (vector bool int, vector signed int);
16276 vector signed int vec_and (vector signed int, vector bool int);
16277 vector signed int vec_and (vector signed int, vector signed int);
16278 vector unsigned int vec_and (vector bool int, vector unsigned int);
16279 vector unsigned int vec_and (vector unsigned int, vector bool int);
16280 vector unsigned int vec_and (vector unsigned int, vector unsigned int);
16281 vector bool short vec_and (vector bool short, vector bool short);
16282 vector signed short vec_and (vector bool short, vector signed short);
16283 vector signed short vec_and (vector signed short, vector bool short);
16284 vector signed short vec_and (vector signed short, vector signed short);
16285 vector unsigned short vec_and (vector bool short,
16286                                vector unsigned short);
16287 vector unsigned short vec_and (vector unsigned short,
16288                                vector bool short);
16289 vector unsigned short vec_and (vector unsigned short,
16290                                vector unsigned short);
16291 vector signed char vec_and (vector bool char, vector signed char);
16292 vector bool char vec_and (vector bool char, vector bool char);
16293 vector signed char vec_and (vector signed char, vector bool char);
16294 vector signed char vec_and (vector signed char, vector signed char);
16295 vector unsigned char vec_and (vector bool char, vector unsigned char);
16296 vector unsigned char vec_and (vector unsigned char, vector bool char);
16297 vector unsigned char vec_and (vector unsigned char,
16298                               vector unsigned char);
16300 vector float vec_andc (vector float, vector float);
16301 vector float vec_andc (vector float, vector bool int);
16302 vector float vec_andc (vector bool int, vector float);
16303 vector bool int vec_andc (vector bool int, vector bool int);
16304 vector signed int vec_andc (vector bool int, vector signed int);
16305 vector signed int vec_andc (vector signed int, vector bool int);
16306 vector signed int vec_andc (vector signed int, vector signed int);
16307 vector unsigned int vec_andc (vector bool int, vector unsigned int);
16308 vector unsigned int vec_andc (vector unsigned int, vector bool int);
16309 vector unsigned int vec_andc (vector unsigned int, vector unsigned int);
16310 vector bool short vec_andc (vector bool short, vector bool short);
16311 vector signed short vec_andc (vector bool short, vector signed short);
16312 vector signed short vec_andc (vector signed short, vector bool short);
16313 vector signed short vec_andc (vector signed short, vector signed short);
16314 vector unsigned short vec_andc (vector bool short,
16315                                 vector unsigned short);
16316 vector unsigned short vec_andc (vector unsigned short,
16317                                 vector bool short);
16318 vector unsigned short vec_andc (vector unsigned short,
16319                                 vector unsigned short);
16320 vector signed char vec_andc (vector bool char, vector signed char);
16321 vector bool char vec_andc (vector bool char, vector bool char);
16322 vector signed char vec_andc (vector signed char, vector bool char);
16323 vector signed char vec_andc (vector signed char, vector signed char);
16324 vector unsigned char vec_andc (vector bool char, vector unsigned char);
16325 vector unsigned char vec_andc (vector unsigned char, vector bool char);
16326 vector unsigned char vec_andc (vector unsigned char,
16327                                vector unsigned char);
16329 vector unsigned char vec_avg (vector unsigned char,
16330                               vector unsigned char);
16331 vector signed char vec_avg (vector signed char, vector signed char);
16332 vector unsigned short vec_avg (vector unsigned short,
16333                                vector unsigned short);
16334 vector signed short vec_avg (vector signed short, vector signed short);
16335 vector unsigned int vec_avg (vector unsigned int, vector unsigned int);
16336 vector signed int vec_avg (vector signed int, vector signed int);
16338 vector signed int vec_vavgsw (vector signed int, vector signed int);
16340 vector unsigned int vec_vavguw (vector unsigned int,
16341                                 vector unsigned int);
16343 vector signed short vec_vavgsh (vector signed short,
16344                                 vector signed short);
16346 vector unsigned short vec_vavguh (vector unsigned short,
16347                                   vector unsigned short);
16349 vector signed char vec_vavgsb (vector signed char, vector signed char);
16351 vector unsigned char vec_vavgub (vector unsigned char,
16352                                  vector unsigned char);
16354 vector float vec_copysign (vector float);
16356 vector float vec_ceil (vector float);
16358 vector signed int vec_cmpb (vector float, vector float);
16360 vector bool char vec_cmpeq (vector bool char, vector bool char);
16361 vector bool short vec_cmpeq (vector bool short, vector bool short);
16362 vector bool int vec_cmpeq (vector bool int, vector bool int);
16363 vector bool char vec_cmpeq (vector signed char, vector signed char);
16364 vector bool char vec_cmpeq (vector unsigned char, vector unsigned char);
16365 vector bool short vec_cmpeq (vector signed short, vector signed short);
16366 vector bool short vec_cmpeq (vector unsigned short,
16367                              vector unsigned short);
16368 vector bool int vec_cmpeq (vector signed int, vector signed int);
16369 vector bool int vec_cmpeq (vector unsigned int, vector unsigned int);
16370 vector bool int vec_cmpeq (vector float, vector float);
16372 vector bool int vec_vcmpeqfp (vector float, vector float);
16374 vector bool int vec_vcmpequw (vector signed int, vector signed int);
16375 vector bool int vec_vcmpequw (vector unsigned int, vector unsigned int);
16377 vector bool short vec_vcmpequh (vector signed short,
16378                                 vector signed short);
16379 vector bool short vec_vcmpequh (vector unsigned short,
16380                                 vector unsigned short);
16382 vector bool char vec_vcmpequb (vector signed char, vector signed char);
16383 vector bool char vec_vcmpequb (vector unsigned char,
16384                                vector unsigned char);
16386 vector bool int vec_cmpge (vector float, vector float);
16388 vector bool char vec_cmpgt (vector unsigned char, vector unsigned char);
16389 vector bool char vec_cmpgt (vector signed char, vector signed char);
16390 vector bool short vec_cmpgt (vector unsigned short,
16391                              vector unsigned short);
16392 vector bool short vec_cmpgt (vector signed short, vector signed short);
16393 vector bool int vec_cmpgt (vector unsigned int, vector unsigned int);
16394 vector bool int vec_cmpgt (vector signed int, vector signed int);
16395 vector bool int vec_cmpgt (vector float, vector float);
16397 vector bool int vec_vcmpgtfp (vector float, vector float);
16399 vector bool int vec_vcmpgtsw (vector signed int, vector signed int);
16401 vector bool int vec_vcmpgtuw (vector unsigned int, vector unsigned int);
16403 vector bool short vec_vcmpgtsh (vector signed short,
16404                                 vector signed short);
16406 vector bool short vec_vcmpgtuh (vector unsigned short,
16407                                 vector unsigned short);
16409 vector bool char vec_vcmpgtsb (vector signed char, vector signed char);
16411 vector bool char vec_vcmpgtub (vector unsigned char,
16412                                vector unsigned char);
16414 vector bool int vec_cmple (vector float, vector float);
16416 vector bool char vec_cmplt (vector unsigned char, vector unsigned char);
16417 vector bool char vec_cmplt (vector signed char, vector signed char);
16418 vector bool short vec_cmplt (vector unsigned short,
16419                              vector unsigned short);
16420 vector bool short vec_cmplt (vector signed short, vector signed short);
16421 vector bool int vec_cmplt (vector unsigned int, vector unsigned int);
16422 vector bool int vec_cmplt (vector signed int, vector signed int);
16423 vector bool int vec_cmplt (vector float, vector float);
16425 vector float vec_cpsgn (vector float, vector float);
16427 vector float vec_ctf (vector unsigned int, const int);
16428 vector float vec_ctf (vector signed int, const int);
16429 vector double vec_ctf (vector unsigned long, const int);
16430 vector double vec_ctf (vector signed long, const int);
16432 vector float vec_vcfsx (vector signed int, const int);
16434 vector float vec_vcfux (vector unsigned int, const int);
16436 vector signed int vec_cts (vector float, const int);
16437 vector signed long vec_cts (vector double, const int);
16439 vector unsigned int vec_ctu (vector float, const int);
16440 vector unsigned long vec_ctu (vector double, const int);
16442 vector double vec_doublee (vector float);
16443 vector double vec_doublee (vector signed int);
16444 vector double vec_doublee (vector unsigned int);
16446 vector double vec_doubleo (vector float);
16447 vector double vec_doubleo (vector signed int);
16448 vector double vec_doubleo (vector unsigned int);
16450 vector double vec_doubleh (vector float);
16451 vector double vec_doubleh (vector signed int);
16452 vector double vec_doubleh (vector unsigned int);
16454 vector double vec_doublel (vector float);
16455 vector double vec_doublel (vector signed int);
16456 vector double vec_doublel (vector unsigned int);
16458 void vec_dss (const int);
16460 void vec_dssall (void);
16462 void vec_dst (const vector unsigned char *, int, const int);
16463 void vec_dst (const vector signed char *, int, const int);
16464 void vec_dst (const vector bool char *, int, const int);
16465 void vec_dst (const vector unsigned short *, int, const int);
16466 void vec_dst (const vector signed short *, int, const int);
16467 void vec_dst (const vector bool short *, int, const int);
16468 void vec_dst (const vector pixel *, int, const int);
16469 void vec_dst (const vector unsigned int *, int, const int);
16470 void vec_dst (const vector signed int *, int, const int);
16471 void vec_dst (const vector bool int *, int, const int);
16472 void vec_dst (const vector float *, int, const int);
16473 void vec_dst (const unsigned char *, int, const int);
16474 void vec_dst (const signed char *, int, const int);
16475 void vec_dst (const unsigned short *, int, const int);
16476 void vec_dst (const short *, int, const int);
16477 void vec_dst (const unsigned int *, int, const int);
16478 void vec_dst (const int *, int, const int);
16479 void vec_dst (const unsigned long *, int, const int);
16480 void vec_dst (const long *, int, const int);
16481 void vec_dst (const float *, int, const int);
16483 void vec_dstst (const vector unsigned char *, int, const int);
16484 void vec_dstst (const vector signed char *, int, const int);
16485 void vec_dstst (const vector bool char *, int, const int);
16486 void vec_dstst (const vector unsigned short *, int, const int);
16487 void vec_dstst (const vector signed short *, int, const int);
16488 void vec_dstst (const vector bool short *, int, const int);
16489 void vec_dstst (const vector pixel *, int, const int);
16490 void vec_dstst (const vector unsigned int *, int, const int);
16491 void vec_dstst (const vector signed int *, int, const int);
16492 void vec_dstst (const vector bool int *, int, const int);
16493 void vec_dstst (const vector float *, int, const int);
16494 void vec_dstst (const unsigned char *, int, const int);
16495 void vec_dstst (const signed char *, int, const int);
16496 void vec_dstst (const unsigned short *, int, const int);
16497 void vec_dstst (const short *, int, const int);
16498 void vec_dstst (const unsigned int *, int, const int);
16499 void vec_dstst (const int *, int, const int);
16500 void vec_dstst (const unsigned long *, int, const int);
16501 void vec_dstst (const long *, int, const int);
16502 void vec_dstst (const float *, int, const int);
16504 void vec_dststt (const vector unsigned char *, int, const int);
16505 void vec_dststt (const vector signed char *, int, const int);
16506 void vec_dststt (const vector bool char *, int, const int);
16507 void vec_dststt (const vector unsigned short *, int, const int);
16508 void vec_dststt (const vector signed short *, int, const int);
16509 void vec_dststt (const vector bool short *, int, const int);
16510 void vec_dststt (const vector pixel *, int, const int);
16511 void vec_dststt (const vector unsigned int *, int, const int);
16512 void vec_dststt (const vector signed int *, int, const int);
16513 void vec_dststt (const vector bool int *, int, const int);
16514 void vec_dststt (const vector float *, int, const int);
16515 void vec_dststt (const unsigned char *, int, const int);
16516 void vec_dststt (const signed char *, int, const int);
16517 void vec_dststt (const unsigned short *, int, const int);
16518 void vec_dststt (const short *, int, const int);
16519 void vec_dststt (const unsigned int *, int, const int);
16520 void vec_dststt (const int *, int, const int);
16521 void vec_dststt (const unsigned long *, int, const int);
16522 void vec_dststt (const long *, int, const int);
16523 void vec_dststt (const float *, int, const int);
16525 void vec_dstt (const vector unsigned char *, int, const int);
16526 void vec_dstt (const vector signed char *, int, const int);
16527 void vec_dstt (const vector bool char *, int, const int);
16528 void vec_dstt (const vector unsigned short *, int, const int);
16529 void vec_dstt (const vector signed short *, int, const int);
16530 void vec_dstt (const vector bool short *, int, const int);
16531 void vec_dstt (const vector pixel *, int, const int);
16532 void vec_dstt (const vector unsigned int *, int, const int);
16533 void vec_dstt (const vector signed int *, int, const int);
16534 void vec_dstt (const vector bool int *, int, const int);
16535 void vec_dstt (const vector float *, int, const int);
16536 void vec_dstt (const unsigned char *, int, const int);
16537 void vec_dstt (const signed char *, int, const int);
16538 void vec_dstt (const unsigned short *, int, const int);
16539 void vec_dstt (const short *, int, const int);
16540 void vec_dstt (const unsigned int *, int, const int);
16541 void vec_dstt (const int *, int, const int);
16542 void vec_dstt (const unsigned long *, int, const int);
16543 void vec_dstt (const long *, int, const int);
16544 void vec_dstt (const float *, int, const int);
16546 vector float vec_expte (vector float);
16548 vector float vec_floor (vector float);
16550 vector float vec_float (vector signed int);
16551 vector float vec_float (vector unsigned int);
16553 vector float vec_float2 (vector signed long long, vector signed long long);
16554 vector float vec_float2 (vector unsigned long long, vector signed long long);
16556 vector float vec_floate (vector double);
16557 vector float vec_floate (vector signed long long);
16558 vector float vec_floate (vector unsigned long long);
16560 vector float vec_floato (vector double);
16561 vector float vec_floato (vector signed long long);
16562 vector float vec_floato (vector unsigned long long);
16564 vector float vec_ld (int, const vector float *);
16565 vector float vec_ld (int, const float *);
16566 vector bool int vec_ld (int, const vector bool int *);
16567 vector signed int vec_ld (int, const vector signed int *);
16568 vector signed int vec_ld (int, const int *);
16569 vector signed int vec_ld (int, const long *);
16570 vector unsigned int vec_ld (int, const vector unsigned int *);
16571 vector unsigned int vec_ld (int, const unsigned int *);
16572 vector unsigned int vec_ld (int, const unsigned long *);
16573 vector bool short vec_ld (int, const vector bool short *);
16574 vector pixel vec_ld (int, const vector pixel *);
16575 vector signed short vec_ld (int, const vector signed short *);
16576 vector signed short vec_ld (int, const short *);
16577 vector unsigned short vec_ld (int, const vector unsigned short *);
16578 vector unsigned short vec_ld (int, const unsigned short *);
16579 vector bool char vec_ld (int, const vector bool char *);
16580 vector signed char vec_ld (int, const vector signed char *);
16581 vector signed char vec_ld (int, const signed char *);
16582 vector unsigned char vec_ld (int, const vector unsigned char *);
16583 vector unsigned char vec_ld (int, const unsigned char *);
16585 vector signed char vec_lde (int, const signed char *);
16586 vector unsigned char vec_lde (int, const unsigned char *);
16587 vector signed short vec_lde (int, const short *);
16588 vector unsigned short vec_lde (int, const unsigned short *);
16589 vector float vec_lde (int, const float *);
16590 vector signed int vec_lde (int, const int *);
16591 vector unsigned int vec_lde (int, const unsigned int *);
16592 vector signed int vec_lde (int, const long *);
16593 vector unsigned int vec_lde (int, const unsigned long *);
16595 vector float vec_lvewx (int, float *);
16596 vector signed int vec_lvewx (int, int *);
16597 vector unsigned int vec_lvewx (int, unsigned int *);
16598 vector signed int vec_lvewx (int, long *);
16599 vector unsigned int vec_lvewx (int, unsigned long *);
16601 vector signed short vec_lvehx (int, short *);
16602 vector unsigned short vec_lvehx (int, unsigned short *);
16604 vector signed char vec_lvebx (int, char *);
16605 vector unsigned char vec_lvebx (int, unsigned char *);
16607 vector float vec_ldl (int, const vector float *);
16608 vector float vec_ldl (int, const float *);
16609 vector bool int vec_ldl (int, const vector bool int *);
16610 vector signed int vec_ldl (int, const vector signed int *);
16611 vector signed int vec_ldl (int, const int *);
16612 vector signed int vec_ldl (int, const long *);
16613 vector unsigned int vec_ldl (int, const vector unsigned int *);
16614 vector unsigned int vec_ldl (int, const unsigned int *);
16615 vector unsigned int vec_ldl (int, const unsigned long *);
16616 vector bool short vec_ldl (int, const vector bool short *);
16617 vector pixel vec_ldl (int, const vector pixel *);
16618 vector signed short vec_ldl (int, const vector signed short *);
16619 vector signed short vec_ldl (int, const short *);
16620 vector unsigned short vec_ldl (int, const vector unsigned short *);
16621 vector unsigned short vec_ldl (int, const unsigned short *);
16622 vector bool char vec_ldl (int, const vector bool char *);
16623 vector signed char vec_ldl (int, const vector signed char *);
16624 vector signed char vec_ldl (int, const signed char *);
16625 vector unsigned char vec_ldl (int, const vector unsigned char *);
16626 vector unsigned char vec_ldl (int, const unsigned char *);
16628 vector float vec_loge (vector float);
16630 vector unsigned char vec_lvsl (int, const volatile unsigned char *);
16631 vector unsigned char vec_lvsl (int, const volatile signed char *);
16632 vector unsigned char vec_lvsl (int, const volatile unsigned short *);
16633 vector unsigned char vec_lvsl (int, const volatile short *);
16634 vector unsigned char vec_lvsl (int, const volatile unsigned int *);
16635 vector unsigned char vec_lvsl (int, const volatile int *);
16636 vector unsigned char vec_lvsl (int, const volatile unsigned long *);
16637 vector unsigned char vec_lvsl (int, const volatile long *);
16638 vector unsigned char vec_lvsl (int, const volatile float *);
16640 vector unsigned char vec_lvsr (int, const volatile unsigned char *);
16641 vector unsigned char vec_lvsr (int, const volatile signed char *);
16642 vector unsigned char vec_lvsr (int, const volatile unsigned short *);
16643 vector unsigned char vec_lvsr (int, const volatile short *);
16644 vector unsigned char vec_lvsr (int, const volatile unsigned int *);
16645 vector unsigned char vec_lvsr (int, const volatile int *);
16646 vector unsigned char vec_lvsr (int, const volatile unsigned long *);
16647 vector unsigned char vec_lvsr (int, const volatile long *);
16648 vector unsigned char vec_lvsr (int, const volatile float *);
16650 vector float vec_madd (vector float, vector float, vector float);
16652 vector signed short vec_madds (vector signed short,
16653                                vector signed short,
16654                                vector signed short);
16656 vector unsigned char vec_max (vector bool char, vector unsigned char);
16657 vector unsigned char vec_max (vector unsigned char, vector bool char);
16658 vector unsigned char vec_max (vector unsigned char,
16659                               vector unsigned char);
16660 vector signed char vec_max (vector bool char, vector signed char);
16661 vector signed char vec_max (vector signed char, vector bool char);
16662 vector signed char vec_max (vector signed char, vector signed char);
16663 vector unsigned short vec_max (vector bool short,
16664                                vector unsigned short);
16665 vector unsigned short vec_max (vector unsigned short,
16666                                vector bool short);
16667 vector unsigned short vec_max (vector unsigned short,
16668                                vector unsigned short);
16669 vector signed short vec_max (vector bool short, vector signed short);
16670 vector signed short vec_max (vector signed short, vector bool short);
16671 vector signed short vec_max (vector signed short, vector signed short);
16672 vector unsigned int vec_max (vector bool int, vector unsigned int);
16673 vector unsigned int vec_max (vector unsigned int, vector bool int);
16674 vector unsigned int vec_max (vector unsigned int, vector unsigned int);
16675 vector signed int vec_max (vector bool int, vector signed int);
16676 vector signed int vec_max (vector signed int, vector bool int);
16677 vector signed int vec_max (vector signed int, vector signed int);
16678 vector float vec_max (vector float, vector float);
16680 vector float vec_vmaxfp (vector float, vector float);
16682 vector signed int vec_vmaxsw (vector bool int, vector signed int);
16683 vector signed int vec_vmaxsw (vector signed int, vector bool int);
16684 vector signed int vec_vmaxsw (vector signed int, vector signed int);
16686 vector unsigned int vec_vmaxuw (vector bool int, vector unsigned int);
16687 vector unsigned int vec_vmaxuw (vector unsigned int, vector bool int);
16688 vector unsigned int vec_vmaxuw (vector unsigned int,
16689                                 vector unsigned int);
16691 vector signed short vec_vmaxsh (vector bool short, vector signed short);
16692 vector signed short vec_vmaxsh (vector signed short, vector bool short);
16693 vector signed short vec_vmaxsh (vector signed short,
16694                                 vector signed short);
16696 vector unsigned short vec_vmaxuh (vector bool short,
16697                                   vector unsigned short);
16698 vector unsigned short vec_vmaxuh (vector unsigned short,
16699                                   vector bool short);
16700 vector unsigned short vec_vmaxuh (vector unsigned short,
16701                                   vector unsigned short);
16703 vector signed char vec_vmaxsb (vector bool char, vector signed char);
16704 vector signed char vec_vmaxsb (vector signed char, vector bool char);
16705 vector signed char vec_vmaxsb (vector signed char, vector signed char);
16707 vector unsigned char vec_vmaxub (vector bool char,
16708                                  vector unsigned char);
16709 vector unsigned char vec_vmaxub (vector unsigned char,
16710                                  vector bool char);
16711 vector unsigned char vec_vmaxub (vector unsigned char,
16712                                  vector unsigned char);
16714 vector bool char vec_mergeh (vector bool char, vector bool char);
16715 vector signed char vec_mergeh (vector signed char, vector signed char);
16716 vector unsigned char vec_mergeh (vector unsigned char,
16717                                  vector unsigned char);
16718 vector bool short vec_mergeh (vector bool short, vector bool short);
16719 vector pixel vec_mergeh (vector pixel, vector pixel);
16720 vector signed short vec_mergeh (vector signed short,
16721                                 vector signed short);
16722 vector unsigned short vec_mergeh (vector unsigned short,
16723                                   vector unsigned short);
16724 vector float vec_mergeh (vector float, vector float);
16725 vector bool int vec_mergeh (vector bool int, vector bool int);
16726 vector signed int vec_mergeh (vector signed int, vector signed int);
16727 vector unsigned int vec_mergeh (vector unsigned int,
16728                                 vector unsigned int);
16730 vector float vec_vmrghw (vector float, vector float);
16731 vector bool int vec_vmrghw (vector bool int, vector bool int);
16732 vector signed int vec_vmrghw (vector signed int, vector signed int);
16733 vector unsigned int vec_vmrghw (vector unsigned int,
16734                                 vector unsigned int);
16736 vector bool short vec_vmrghh (vector bool short, vector bool short);
16737 vector signed short vec_vmrghh (vector signed short,
16738                                 vector signed short);
16739 vector unsigned short vec_vmrghh (vector unsigned short,
16740                                   vector unsigned short);
16741 vector pixel vec_vmrghh (vector pixel, vector pixel);
16743 vector bool char vec_vmrghb (vector bool char, vector bool char);
16744 vector signed char vec_vmrghb (vector signed char, vector signed char);
16745 vector unsigned char vec_vmrghb (vector unsigned char,
16746                                  vector unsigned char);
16748 vector bool char vec_mergel (vector bool char, vector bool char);
16749 vector signed char vec_mergel (vector signed char, vector signed char);
16750 vector unsigned char vec_mergel (vector unsigned char,
16751                                  vector unsigned char);
16752 vector bool short vec_mergel (vector bool short, vector bool short);
16753 vector pixel vec_mergel (vector pixel, vector pixel);
16754 vector signed short vec_mergel (vector signed short,
16755                                 vector signed short);
16756 vector unsigned short vec_mergel (vector unsigned short,
16757                                   vector unsigned short);
16758 vector float vec_mergel (vector float, vector float);
16759 vector bool int vec_mergel (vector bool int, vector bool int);
16760 vector signed int vec_mergel (vector signed int, vector signed int);
16761 vector unsigned int vec_mergel (vector unsigned int,
16762                                 vector unsigned int);
16764 vector float vec_vmrglw (vector float, vector float);
16765 vector signed int vec_vmrglw (vector signed int, vector signed int);
16766 vector unsigned int vec_vmrglw (vector unsigned int,
16767                                 vector unsigned int);
16768 vector bool int vec_vmrglw (vector bool int, vector bool int);
16770 vector bool short vec_vmrglh (vector bool short, vector bool short);
16771 vector signed short vec_vmrglh (vector signed short,
16772                                 vector signed short);
16773 vector unsigned short vec_vmrglh (vector unsigned short,
16774                                   vector unsigned short);
16775 vector pixel vec_vmrglh (vector pixel, vector pixel);
16777 vector bool char vec_vmrglb (vector bool char, vector bool char);
16778 vector signed char vec_vmrglb (vector signed char, vector signed char);
16779 vector unsigned char vec_vmrglb (vector unsigned char,
16780                                  vector unsigned char);
16782 vector unsigned short vec_mfvscr (void);
16784 vector unsigned char vec_min (vector bool char, vector unsigned char);
16785 vector unsigned char vec_min (vector unsigned char, vector bool char);
16786 vector unsigned char vec_min (vector unsigned char,
16787                               vector unsigned char);
16788 vector signed char vec_min (vector bool char, vector signed char);
16789 vector signed char vec_min (vector signed char, vector bool char);
16790 vector signed char vec_min (vector signed char, vector signed char);
16791 vector unsigned short vec_min (vector bool short,
16792                                vector unsigned short);
16793 vector unsigned short vec_min (vector unsigned short,
16794                                vector bool short);
16795 vector unsigned short vec_min (vector unsigned short,
16796                                vector unsigned short);
16797 vector signed short vec_min (vector bool short, vector signed short);
16798 vector signed short vec_min (vector signed short, vector bool short);
16799 vector signed short vec_min (vector signed short, vector signed short);
16800 vector unsigned int vec_min (vector bool int, vector unsigned int);
16801 vector unsigned int vec_min (vector unsigned int, vector bool int);
16802 vector unsigned int vec_min (vector unsigned int, vector unsigned int);
16803 vector signed int vec_min (vector bool int, vector signed int);
16804 vector signed int vec_min (vector signed int, vector bool int);
16805 vector signed int vec_min (vector signed int, vector signed int);
16806 vector float vec_min (vector float, vector float);
16808 vector float vec_vminfp (vector float, vector float);
16810 vector signed int vec_vminsw (vector bool int, vector signed int);
16811 vector signed int vec_vminsw (vector signed int, vector bool int);
16812 vector signed int vec_vminsw (vector signed int, vector signed int);
16814 vector unsigned int vec_vminuw (vector bool int, vector unsigned int);
16815 vector unsigned int vec_vminuw (vector unsigned int, vector bool int);
16816 vector unsigned int vec_vminuw (vector unsigned int,
16817                                 vector unsigned int);
16819 vector signed short vec_vminsh (vector bool short, vector signed short);
16820 vector signed short vec_vminsh (vector signed short, vector bool short);
16821 vector signed short vec_vminsh (vector signed short,
16822                                 vector signed short);
16824 vector unsigned short vec_vminuh (vector bool short,
16825                                   vector unsigned short);
16826 vector unsigned short vec_vminuh (vector unsigned short,
16827                                   vector bool short);
16828 vector unsigned short vec_vminuh (vector unsigned short,
16829                                   vector unsigned short);
16831 vector signed char vec_vminsb (vector bool char, vector signed char);
16832 vector signed char vec_vminsb (vector signed char, vector bool char);
16833 vector signed char vec_vminsb (vector signed char, vector signed char);
16835 vector unsigned char vec_vminub (vector bool char,
16836                                  vector unsigned char);
16837 vector unsigned char vec_vminub (vector unsigned char,
16838                                  vector bool char);
16839 vector unsigned char vec_vminub (vector unsigned char,
16840                                  vector unsigned char);
16842 vector signed short vec_mladd (vector signed short,
16843                                vector signed short,
16844                                vector signed short);
16845 vector signed short vec_mladd (vector signed short,
16846                                vector unsigned short,
16847                                vector unsigned short);
16848 vector signed short vec_mladd (vector unsigned short,
16849                                vector signed short,
16850                                vector signed short);
16851 vector unsigned short vec_mladd (vector unsigned short,
16852                                  vector unsigned short,
16853                                  vector unsigned short);
16855 vector signed short vec_mradds (vector signed short,
16856                                 vector signed short,
16857                                 vector signed short);
16859 vector unsigned int vec_msum (vector unsigned char,
16860                               vector unsigned char,
16861                               vector unsigned int);
16862 vector signed int vec_msum (vector signed char,
16863                             vector unsigned char,
16864                             vector signed int);
16865 vector unsigned int vec_msum (vector unsigned short,
16866                               vector unsigned short,
16867                               vector unsigned int);
16868 vector signed int vec_msum (vector signed short,
16869                             vector signed short,
16870                             vector signed int);
16872 vector signed int vec_vmsumshm (vector signed short,
16873                                 vector signed short,
16874                                 vector signed int);
16876 vector unsigned int vec_vmsumuhm (vector unsigned short,
16877                                   vector unsigned short,
16878                                   vector unsigned int);
16880 vector signed int vec_vmsummbm (vector signed char,
16881                                 vector unsigned char,
16882                                 vector signed int);
16884 vector unsigned int vec_vmsumubm (vector unsigned char,
16885                                   vector unsigned char,
16886                                   vector unsigned int);
16888 vector unsigned int vec_msums (vector unsigned short,
16889                                vector unsigned short,
16890                                vector unsigned int);
16891 vector signed int vec_msums (vector signed short,
16892                              vector signed short,
16893                              vector signed int);
16895 vector signed int vec_vmsumshs (vector signed short,
16896                                 vector signed short,
16897                                 vector signed int);
16899 vector unsigned int vec_vmsumuhs (vector unsigned short,
16900                                   vector unsigned short,
16901                                   vector unsigned int);
16903 void vec_mtvscr (vector signed int);
16904 void vec_mtvscr (vector unsigned int);
16905 void vec_mtvscr (vector bool int);
16906 void vec_mtvscr (vector signed short);
16907 void vec_mtvscr (vector unsigned short);
16908 void vec_mtvscr (vector bool short);
16909 void vec_mtvscr (vector pixel);
16910 void vec_mtvscr (vector signed char);
16911 void vec_mtvscr (vector unsigned char);
16912 void vec_mtvscr (vector bool char);
16914 vector unsigned short vec_mule (vector unsigned char,
16915                                 vector unsigned char);
16916 vector signed short vec_mule (vector signed char,
16917                               vector signed char);
16918 vector unsigned int vec_mule (vector unsigned short,
16919                               vector unsigned short);
16920 vector signed int vec_mule (vector signed short, vector signed short);
16921 vector unsigned long long vec_mule (vector unsigned int,
16922                                     vector unsigned int);
16923 vector signed long long vec_mule (vector signed int,
16924                                   vector signed int);
16926 vector signed int vec_vmulesh (vector signed short,
16927                                vector signed short);
16929 vector unsigned int vec_vmuleuh (vector unsigned short,
16930                                  vector unsigned short);
16932 vector signed short vec_vmulesb (vector signed char,
16933                                  vector signed char);
16935 vector unsigned short vec_vmuleub (vector unsigned char,
16936                                   vector unsigned char);
16938 vector unsigned short vec_mulo (vector unsigned char,
16939                                 vector unsigned char);
16940 vector signed short vec_mulo (vector signed char, vector signed char);
16941 vector unsigned int vec_mulo (vector unsigned short,
16942                               vector unsigned short);
16943 vector signed int vec_mulo (vector signed short, vector signed short);
16944 vector unsigned long long vec_mulo (vector unsigned int,
16945                                     vector unsigned int);
16946 vector signed long long vec_mulo (vector signed int,
16947                                   vector signed int);
16949 vector signed int vec_vmulosh (vector signed short,
16950                                vector signed short);
16952 vector unsigned int vec_vmulouh (vector unsigned short,
16953                                  vector unsigned short);
16955 vector signed short vec_vmulosb (vector signed char,
16956                                  vector signed char);
16958 vector unsigned short vec_vmuloub (vector unsigned char,
16959                                    vector unsigned char);
16961 vector float vec_nmsub (vector float, vector float, vector float);
16963 vector signed char vec_nabs (vector signed char);
16964 vector signed short vec_nabs (vector signed short);
16965 vector signed int vec_nabs (vector signed int);
16966 vector float vec_nabs (vector float);
16967 vector double vec_nabs (vector double);
16969 vector signed char vec_neg (vector signed char);
16970 vector signed short vec_neg (vector signed short);
16971 vector signed int vec_neg (vector signed int);
16972 vector signed long long vec_neg (vector signed long long);
16973 vector float  char vec_neg (vector float);
16974 vector double vec_neg (vector double);
16976 vector float vec_nor (vector float, vector float);
16977 vector signed int vec_nor (vector signed int, vector signed int);
16978 vector unsigned int vec_nor (vector unsigned int, vector unsigned int);
16979 vector bool int vec_nor (vector bool int, vector bool int);
16980 vector signed short vec_nor (vector signed short, vector signed short);
16981 vector unsigned short vec_nor (vector unsigned short,
16982                                vector unsigned short);
16983 vector bool short vec_nor (vector bool short, vector bool short);
16984 vector signed char vec_nor (vector signed char, vector signed char);
16985 vector unsigned char vec_nor (vector unsigned char,
16986                               vector unsigned char);
16987 vector bool char vec_nor (vector bool char, vector bool char);
16989 vector float vec_or (vector float, vector float);
16990 vector float vec_or (vector float, vector bool int);
16991 vector float vec_or (vector bool int, vector float);
16992 vector bool int vec_or (vector bool int, vector bool int);
16993 vector signed int vec_or (vector bool int, vector signed int);
16994 vector signed int vec_or (vector signed int, vector bool int);
16995 vector signed int vec_or (vector signed int, vector signed int);
16996 vector unsigned int vec_or (vector bool int, vector unsigned int);
16997 vector unsigned int vec_or (vector unsigned int, vector bool int);
16998 vector unsigned int vec_or (vector unsigned int, vector unsigned int);
16999 vector bool short vec_or (vector bool short, vector bool short);
17000 vector signed short vec_or (vector bool short, vector signed short);
17001 vector signed short vec_or (vector signed short, vector bool short);
17002 vector signed short vec_or (vector signed short, vector signed short);
17003 vector unsigned short vec_or (vector bool short, vector unsigned short);
17004 vector unsigned short vec_or (vector unsigned short, vector bool short);
17005 vector unsigned short vec_or (vector unsigned short,
17006                               vector unsigned short);
17007 vector signed char vec_or (vector bool char, vector signed char);
17008 vector bool char vec_or (vector bool char, vector bool char);
17009 vector signed char vec_or (vector signed char, vector bool char);
17010 vector signed char vec_or (vector signed char, vector signed char);
17011 vector unsigned char vec_or (vector bool char, vector unsigned char);
17012 vector unsigned char vec_or (vector unsigned char, vector bool char);
17013 vector unsigned char vec_or (vector unsigned char,
17014                              vector unsigned char);
17016 vector signed char vec_pack (vector signed short, vector signed short);
17017 vector unsigned char vec_pack (vector unsigned short,
17018                                vector unsigned short);
17019 vector bool char vec_pack (vector bool short, vector bool short);
17020 vector signed short vec_pack (vector signed int, vector signed int);
17021 vector unsigned short vec_pack (vector unsigned int,
17022                                 vector unsigned int);
17023 vector bool short vec_pack (vector bool int, vector bool int);
17025 vector bool short vec_vpkuwum (vector bool int, vector bool int);
17026 vector signed short vec_vpkuwum (vector signed int, vector signed int);
17027 vector unsigned short vec_vpkuwum (vector unsigned int,
17028                                    vector unsigned int);
17030 vector bool char vec_vpkuhum (vector bool short, vector bool short);
17031 vector signed char vec_vpkuhum (vector signed short,
17032                                 vector signed short);
17033 vector unsigned char vec_vpkuhum (vector unsigned short,
17034                                   vector unsigned short);
17036 vector pixel vec_packpx (vector unsigned int, vector unsigned int);
17038 vector unsigned char vec_packs (vector unsigned short,
17039                                 vector unsigned short);
17040 vector signed char vec_packs (vector signed short, vector signed short);
17041 vector unsigned short vec_packs (vector unsigned int,
17042                                  vector unsigned int);
17043 vector signed short vec_packs (vector signed int, vector signed int);
17045 vector signed short vec_vpkswss (vector signed int, vector signed int);
17047 vector unsigned short vec_vpkuwus (vector unsigned int,
17048                                    vector unsigned int);
17050 vector signed char vec_vpkshss (vector signed short,
17051                                 vector signed short);
17053 vector unsigned char vec_vpkuhus (vector unsigned short,
17054                                   vector unsigned short);
17056 vector unsigned char vec_packsu (vector unsigned short,
17057                                  vector unsigned short);
17058 vector unsigned char vec_packsu (vector signed short,
17059                                  vector signed short);
17060 vector unsigned short vec_packsu (vector unsigned int,
17061                                   vector unsigned int);
17062 vector unsigned short vec_packsu (vector signed int, vector signed int);
17064 vector unsigned short vec_vpkswus (vector signed int,
17065                                    vector signed int);
17067 vector unsigned char vec_vpkshus (vector signed short,
17068                                   vector signed short);
17070 vector float vec_perm (vector float,
17071                        vector float,
17072                        vector unsigned char);
17073 vector signed int vec_perm (vector signed int,
17074                             vector signed int,
17075                             vector unsigned char);
17076 vector unsigned int vec_perm (vector unsigned int,
17077                               vector unsigned int,
17078                               vector unsigned char);
17079 vector bool int vec_perm (vector bool int,
17080                           vector bool int,
17081                           vector unsigned char);
17082 vector signed short vec_perm (vector signed short,
17083                               vector signed short,
17084                               vector unsigned char);
17085 vector unsigned short vec_perm (vector unsigned short,
17086                                 vector unsigned short,
17087                                 vector unsigned char);
17088 vector bool short vec_perm (vector bool short,
17089                             vector bool short,
17090                             vector unsigned char);
17091 vector pixel vec_perm (vector pixel,
17092                        vector pixel,
17093                        vector unsigned char);
17094 vector signed char vec_perm (vector signed char,
17095                              vector signed char,
17096                              vector unsigned char);
17097 vector unsigned char vec_perm (vector unsigned char,
17098                                vector unsigned char,
17099                                vector unsigned char);
17100 vector bool char vec_perm (vector bool char,
17101                            vector bool char,
17102                            vector unsigned char);
17104 vector float vec_re (vector float);
17106 vector bool char vec_reve (vector bool char);
17107 vector signed char vec_reve (vector signed char);
17108 vector unsigned char vec_reve (vector unsigned char);
17109 vector bool int vec_reve (vector bool int);
17110 vector signed int vec_reve (vector signed int);
17111 vector unsigned int vec_reve (vector unsigned int);
17112 vector bool long long vec_reve (vector bool long long);
17113 vector signed long long vec_reve (vector signed long long);
17114 vector unsigned long long vec_reve (vector unsigned long long);
17115 vector bool short vec_reve (vector bool short);
17116 vector signed short vec_reve (vector signed short);
17117 vector unsigned short vec_reve (vector unsigned short);
17119 vector signed char vec_rl (vector signed char,
17120                            vector unsigned char);
17121 vector unsigned char vec_rl (vector unsigned char,
17122                              vector unsigned char);
17123 vector signed short vec_rl (vector signed short, vector unsigned short);
17124 vector unsigned short vec_rl (vector unsigned short,
17125                               vector unsigned short);
17126 vector signed int vec_rl (vector signed int, vector unsigned int);
17127 vector unsigned int vec_rl (vector unsigned int, vector unsigned int);
17129 vector signed int vec_vrlw (vector signed int, vector unsigned int);
17130 vector unsigned int vec_vrlw (vector unsigned int, vector unsigned int);
17132 vector signed short vec_vrlh (vector signed short,
17133                               vector unsigned short);
17134 vector unsigned short vec_vrlh (vector unsigned short,
17135                                 vector unsigned short);
17137 vector signed char vec_vrlb (vector signed char, vector unsigned char);
17138 vector unsigned char vec_vrlb (vector unsigned char,
17139                                vector unsigned char);
17141 vector float vec_round (vector float);
17143 vector float vec_recip (vector float, vector float);
17145 vector float vec_rsqrt (vector float);
17147 vector float vec_rsqrte (vector float);
17149 vector float vec_sel (vector float, vector float, vector bool int);
17150 vector float vec_sel (vector float, vector float, vector unsigned int);
17151 vector signed int vec_sel (vector signed int,
17152                            vector signed int,
17153                            vector bool int);
17154 vector signed int vec_sel (vector signed int,
17155                            vector signed int,
17156                            vector unsigned int);
17157 vector unsigned int vec_sel (vector unsigned int,
17158                              vector unsigned int,
17159                              vector bool int);
17160 vector unsigned int vec_sel (vector unsigned int,
17161                              vector unsigned int,
17162                              vector unsigned int);
17163 vector bool int vec_sel (vector bool int,
17164                          vector bool int,
17165                          vector bool int);
17166 vector bool int vec_sel (vector bool int,
17167                          vector bool int,
17168                          vector unsigned int);
17169 vector signed short vec_sel (vector signed short,
17170                              vector signed short,
17171                              vector bool short);
17172 vector signed short vec_sel (vector signed short,
17173                              vector signed short,
17174                              vector unsigned short);
17175 vector unsigned short vec_sel (vector unsigned short,
17176                                vector unsigned short,
17177                                vector bool short);
17178 vector unsigned short vec_sel (vector unsigned short,
17179                                vector unsigned short,
17180                                vector unsigned short);
17181 vector bool short vec_sel (vector bool short,
17182                            vector bool short,
17183                            vector bool short);
17184 vector bool short vec_sel (vector bool short,
17185                            vector bool short,
17186                            vector unsigned short);
17187 vector signed char vec_sel (vector signed char,
17188                             vector signed char,
17189                             vector bool char);
17190 vector signed char vec_sel (vector signed char,
17191                             vector signed char,
17192                             vector unsigned char);
17193 vector unsigned char vec_sel (vector unsigned char,
17194                               vector unsigned char,
17195                               vector bool char);
17196 vector unsigned char vec_sel (vector unsigned char,
17197                               vector unsigned char,
17198                               vector unsigned char);
17199 vector bool char vec_sel (vector bool char,
17200                           vector bool char,
17201                           vector bool char);
17202 vector bool char vec_sel (vector bool char,
17203                           vector bool char,
17204                           vector unsigned char);
17206 vector signed long long vec_signed (vector double);
17207 vector signed int vec_signed (vector float);
17209 vector signed int vec_signede (vector double);
17210 vector signed int vec_signedo (vector double);
17211 vector signed int vec_signed2 (vector double, vector double);
17213 vector signed char vec_sl (vector signed char,
17214                            vector unsigned char);
17215 vector unsigned char vec_sl (vector unsigned char,
17216                              vector unsigned char);
17217 vector signed short vec_sl (vector signed short, vector unsigned short);
17218 vector unsigned short vec_sl (vector unsigned short,
17219                               vector unsigned short);
17220 vector signed int vec_sl (vector signed int, vector unsigned int);
17221 vector unsigned int vec_sl (vector unsigned int, vector unsigned int);
17223 vector signed int vec_vslw (vector signed int, vector unsigned int);
17224 vector unsigned int vec_vslw (vector unsigned int, vector unsigned int);
17226 vector signed short vec_vslh (vector signed short,
17227                               vector unsigned short);
17228 vector unsigned short vec_vslh (vector unsigned short,
17229                                 vector unsigned short);
17231 vector signed char vec_vslb (vector signed char, vector unsigned char);
17232 vector unsigned char vec_vslb (vector unsigned char,
17233                                vector unsigned char);
17235 vector float vec_sld (vector float, vector float, const int);
17236 vector double vec_sld (vector double, vector double, const int);
17238 vector signed int vec_sld (vector signed int,
17239                            vector signed int,
17240                            const int);
17241 vector unsigned int vec_sld (vector unsigned int,
17242                              vector unsigned int,
17243                              const int);
17244 vector bool int vec_sld (vector bool int,
17245                          vector bool int,
17246                          const int);
17247 vector signed short vec_sld (vector signed short,
17248                              vector signed short,
17249                              const int);
17250 vector unsigned short vec_sld (vector unsigned short,
17251                                vector unsigned short,
17252                                const int);
17253 vector bool short vec_sld (vector bool short,
17254                            vector bool short,
17255                            const int);
17256 vector pixel vec_sld (vector pixel,
17257                       vector pixel,
17258                       const int);
17259 vector signed char vec_sld (vector signed char,
17260                             vector signed char,
17261                             const int);
17262 vector unsigned char vec_sld (vector unsigned char,
17263                               vector unsigned char,
17264                               const int);
17265 vector bool char vec_sld (vector bool char,
17266                           vector bool char,
17267                           const int);
17268 vector bool long long int vec_sld (vector bool long long int,
17269                                    vector bool long long int, const int);
17270 vector long long int vec_sld (vector long long int,
17271                               vector  long long int, const int);
17272 vector unsigned long long int vec_sld (vector unsigned long long int,
17273                                        vector unsigned long long int,
17274                                        const int);
17276 vector signed char vec_sldw (vector signed char,
17277                              vector signed char,
17278                              const int);
17279 vector unsigned char vec_sldw (vector unsigned char,
17280                                vector unsigned char,
17281                                const int);
17282 vector signed short vec_sldw (vector signed short,
17283                               vector signed short,
17284                               const int);
17285 vector unsigned short vec_sldw (vector unsigned short,
17286                                 vector unsigned short,
17287                                 const int);
17288 vector signed int vec_sldw (vector signed int,
17289                             vector signed int,
17290                             const int);
17291 vector unsigned int vec_sldw (vector unsigned int,
17292                               vector unsigned int,
17293                               const int);
17294 vector signed long long vec_sldw (vector signed long long,
17295                                   vector signed long long,
17296                                   const int);
17297 vector unsigned long long vec_sldw (vector unsigned long long,
17298                                     vector unsigned long long,
17299                                     const int);
17301 vector signed int vec_sll (vector signed int,
17302                            vector unsigned int);
17303 vector signed int vec_sll (vector signed int,
17304                            vector unsigned short);
17305 vector signed int vec_sll (vector signed int,
17306                            vector unsigned char);
17307 vector unsigned int vec_sll (vector unsigned int,
17308                              vector unsigned int);
17309 vector unsigned int vec_sll (vector unsigned int,
17310                              vector unsigned short);
17311 vector unsigned int vec_sll (vector unsigned int,
17312                              vector unsigned char);
17313 vector bool int vec_sll (vector bool int,
17314                          vector unsigned int);
17315 vector bool int vec_sll (vector bool int,
17316                          vector unsigned short);
17317 vector bool int vec_sll (vector bool int,
17318                          vector unsigned char);
17319 vector signed short vec_sll (vector signed short,
17320                              vector unsigned int);
17321 vector signed short vec_sll (vector signed short,
17322                              vector unsigned short);
17323 vector signed short vec_sll (vector signed short,
17324                              vector unsigned char);
17325 vector unsigned short vec_sll (vector unsigned short,
17326                                vector unsigned int);
17327 vector unsigned short vec_sll (vector unsigned short,
17328                                vector unsigned short);
17329 vector unsigned short vec_sll (vector unsigned short,
17330                                vector unsigned char);
17331 vector long long int vec_sll (vector long long int,
17332                               vector unsigned char);
17333 vector unsigned long long int vec_sll (vector unsigned long long int,
17334                                        vector unsigned char);
17335 vector bool short vec_sll (vector bool short, vector unsigned int);
17336 vector bool short vec_sll (vector bool short, vector unsigned short);
17337 vector bool short vec_sll (vector bool short, vector unsigned char);
17338 vector pixel vec_sll (vector pixel, vector unsigned int);
17339 vector pixel vec_sll (vector pixel, vector unsigned short);
17340 vector pixel vec_sll (vector pixel, vector unsigned char);
17341 vector signed char vec_sll (vector signed char, vector unsigned int);
17342 vector signed char vec_sll (vector signed char, vector unsigned short);
17343 vector signed char vec_sll (vector signed char, vector unsigned char);
17344 vector unsigned char vec_sll (vector unsigned char,
17345                               vector unsigned int);
17346 vector unsigned char vec_sll (vector unsigned char,
17347                               vector unsigned short);
17348 vector unsigned char vec_sll (vector unsigned char,
17349                               vector unsigned char);
17350 vector bool char vec_sll (vector bool char, vector unsigned int);
17351 vector bool char vec_sll (vector bool char, vector unsigned short);
17352 vector bool char vec_sll (vector bool char, vector unsigned char);
17354 vector float vec_slo (vector float, vector signed char);
17355 vector float vec_slo (vector float, vector unsigned char);
17356 vector signed int vec_slo (vector signed int, vector signed char);
17357 vector signed int vec_slo (vector signed int, vector unsigned char);
17358 vector unsigned int vec_slo (vector unsigned int, vector signed char);
17359 vector unsigned int vec_slo (vector unsigned int, vector unsigned char);
17360 vector signed short vec_slo (vector signed short, vector signed char);
17361 vector signed short vec_slo (vector signed short, vector unsigned char);
17362 vector unsigned short vec_slo (vector unsigned short,
17363                                vector signed char);
17364 vector unsigned short vec_slo (vector unsigned short,
17365                                vector unsigned char);
17366 vector pixel vec_slo (vector pixel, vector signed char);
17367 vector pixel vec_slo (vector pixel, vector unsigned char);
17368 vector signed char vec_slo (vector signed char, vector signed char);
17369 vector signed char vec_slo (vector signed char, vector unsigned char);
17370 vector unsigned char vec_slo (vector unsigned char, vector signed char);
17371 vector unsigned char vec_slo (vector unsigned char,
17372                               vector unsigned char);
17373 vector signed long long vec_slo (vector signed long long, vector signed char);
17374 vector signed long long vec_slo (vector signed long long, vector unsigned char);
17375 vector unsigned long long vec_slo (vector unsigned long long, vector signed char);
17376 vector unsigned long long vec_slo (vector unsigned long long, vector unsigned char);
17378 vector signed char vec_splat (vector signed char, const int);
17379 vector unsigned char vec_splat (vector unsigned char, const int);
17380 vector bool char vec_splat (vector bool char, const int);
17381 vector signed short vec_splat (vector signed short, const int);
17382 vector unsigned short vec_splat (vector unsigned short, const int);
17383 vector bool short vec_splat (vector bool short, const int);
17384 vector pixel vec_splat (vector pixel, const int);
17385 vector float vec_splat (vector float, const int);
17386 vector signed int vec_splat (vector signed int, const int);
17387 vector unsigned int vec_splat (vector unsigned int, const int);
17388 vector bool int vec_splat (vector bool int, const int);
17389 vector signed long vec_splat (vector signed long, const int);
17390 vector unsigned long vec_splat (vector unsigned long, const int);
17392 vector signed char vec_splats (signed char);
17393 vector unsigned char vec_splats (unsigned char);
17394 vector signed short vec_splats (signed short);
17395 vector unsigned short vec_splats (unsigned short);
17396 vector signed int vec_splats (signed int);
17397 vector unsigned int vec_splats (unsigned int);
17398 vector float vec_splats (float);
17400 vector float vec_vspltw (vector float, const int);
17401 vector signed int vec_vspltw (vector signed int, const int);
17402 vector unsigned int vec_vspltw (vector unsigned int, const int);
17403 vector bool int vec_vspltw (vector bool int, const int);
17405 vector bool short vec_vsplth (vector bool short, const int);
17406 vector signed short vec_vsplth (vector signed short, const int);
17407 vector unsigned short vec_vsplth (vector unsigned short, const int);
17408 vector pixel vec_vsplth (vector pixel, const int);
17410 vector signed char vec_vspltb (vector signed char, const int);
17411 vector unsigned char vec_vspltb (vector unsigned char, const int);
17412 vector bool char vec_vspltb (vector bool char, const int);
17414 vector signed char vec_splat_s8 (const int);
17416 vector signed short vec_splat_s16 (const int);
17418 vector signed int vec_splat_s32 (const int);
17420 vector unsigned char vec_splat_u8 (const int);
17422 vector unsigned short vec_splat_u16 (const int);
17424 vector unsigned int vec_splat_u32 (const int);
17426 vector signed char vec_sr (vector signed char, vector unsigned char);
17427 vector unsigned char vec_sr (vector unsigned char,
17428                              vector unsigned char);
17429 vector signed short vec_sr (vector signed short,
17430                             vector unsigned short);
17431 vector unsigned short vec_sr (vector unsigned short,
17432                               vector unsigned short);
17433 vector signed int vec_sr (vector signed int, vector unsigned int);
17434 vector unsigned int vec_sr (vector unsigned int, vector unsigned int);
17436 vector signed int vec_vsrw (vector signed int, vector unsigned int);
17437 vector unsigned int vec_vsrw (vector unsigned int, vector unsigned int);
17439 vector signed short vec_vsrh (vector signed short,
17440                               vector unsigned short);
17441 vector unsigned short vec_vsrh (vector unsigned short,
17442                                 vector unsigned short);
17444 vector signed char vec_vsrb (vector signed char, vector unsigned char);
17445 vector unsigned char vec_vsrb (vector unsigned char,
17446                                vector unsigned char);
17448 vector signed char vec_sra (vector signed char, vector unsigned char);
17449 vector unsigned char vec_sra (vector unsigned char,
17450                               vector unsigned char);
17451 vector signed short vec_sra (vector signed short,
17452                              vector unsigned short);
17453 vector unsigned short vec_sra (vector unsigned short,
17454                                vector unsigned short);
17455 vector signed int vec_sra (vector signed int, vector unsigned int);
17456 vector unsigned int vec_sra (vector unsigned int, vector unsigned int);
17458 vector signed int vec_vsraw (vector signed int, vector unsigned int);
17459 vector unsigned int vec_vsraw (vector unsigned int,
17460                                vector unsigned int);
17462 vector signed short vec_vsrah (vector signed short,
17463                                vector unsigned short);
17464 vector unsigned short vec_vsrah (vector unsigned short,
17465                                  vector unsigned short);
17467 vector signed char vec_vsrab (vector signed char, vector unsigned char);
17468 vector unsigned char vec_vsrab (vector unsigned char,
17469                                 vector unsigned char);
17471 vector signed int vec_srl (vector signed int, vector unsigned int);
17472 vector signed int vec_srl (vector signed int, vector unsigned short);
17473 vector signed int vec_srl (vector signed int, vector unsigned char);
17474 vector unsigned int vec_srl (vector unsigned int, vector unsigned int);
17475 vector unsigned int vec_srl (vector unsigned int,
17476                              vector unsigned short);
17477 vector unsigned int vec_srl (vector unsigned int, vector unsigned char);
17478 vector bool int vec_srl (vector bool int, vector unsigned int);
17479 vector bool int vec_srl (vector bool int, vector unsigned short);
17480 vector bool int vec_srl (vector bool int, vector unsigned char);
17481 vector signed short vec_srl (vector signed short, vector unsigned int);
17482 vector signed short vec_srl (vector signed short,
17483                              vector unsigned short);
17484 vector signed short vec_srl (vector signed short, vector unsigned char);
17485 vector unsigned short vec_srl (vector unsigned short,
17486                                vector unsigned int);
17487 vector unsigned short vec_srl (vector unsigned short,
17488                                vector unsigned short);
17489 vector unsigned short vec_srl (vector unsigned short,
17490                                vector unsigned char);
17491 vector long long int vec_srl (vector long long int,
17492                               vector unsigned char);
17493 vector unsigned long long int vec_srl (vector unsigned long long int,
17494                                        vector unsigned char);
17495 vector bool short vec_srl (vector bool short, vector unsigned int);
17496 vector bool short vec_srl (vector bool short, vector unsigned short);
17497 vector bool short vec_srl (vector bool short, vector unsigned char);
17498 vector pixel vec_srl (vector pixel, vector unsigned int);
17499 vector pixel vec_srl (vector pixel, vector unsigned short);
17500 vector pixel vec_srl (vector pixel, vector unsigned char);
17501 vector signed char vec_srl (vector signed char, vector unsigned int);
17502 vector signed char vec_srl (vector signed char, vector unsigned short);
17503 vector signed char vec_srl (vector signed char, vector unsigned char);
17504 vector unsigned char vec_srl (vector unsigned char,
17505                               vector unsigned int);
17506 vector unsigned char vec_srl (vector unsigned char,
17507                               vector unsigned short);
17508 vector unsigned char vec_srl (vector unsigned char,
17509                               vector unsigned char);
17510 vector bool char vec_srl (vector bool char, vector unsigned int);
17511 vector bool char vec_srl (vector bool char, vector unsigned short);
17512 vector bool char vec_srl (vector bool char, vector unsigned char);
17514 vector float vec_sro (vector float, vector signed char);
17515 vector float vec_sro (vector float, vector unsigned char);
17516 vector signed int vec_sro (vector signed int, vector signed char);
17517 vector signed int vec_sro (vector signed int, vector unsigned char);
17518 vector unsigned int vec_sro (vector unsigned int, vector signed char);
17519 vector unsigned int vec_sro (vector unsigned int, vector unsigned char);
17520 vector signed short vec_sro (vector signed short, vector signed char);
17521 vector signed short vec_sro (vector signed short, vector unsigned char);
17522 vector unsigned short vec_sro (vector unsigned short,
17523                                vector signed char);
17524 vector unsigned short vec_sro (vector unsigned short,
17525                                vector unsigned char);
17526 vector long long int vec_sro (vector long long int,
17527                               vector char);
17528 vector long long int vec_sro (vector long long int,
17529                               vector unsigned char);
17530 vector unsigned long long int vec_sro (vector unsigned long long int,
17531                                        vector char);
17532 vector unsigned long long int vec_sro (vector unsigned long long int,
17533                                        vector unsigned char);
17534 vector pixel vec_sro (vector pixel, vector signed char);
17535 vector pixel vec_sro (vector pixel, vector unsigned char);
17536 vector signed char vec_sro (vector signed char, vector signed char);
17537 vector signed char vec_sro (vector signed char, vector unsigned char);
17538 vector unsigned char vec_sro (vector unsigned char, vector signed char);
17539 vector unsigned char vec_sro (vector unsigned char,
17540                               vector unsigned char);
17542 void vec_st (vector float, int, vector float *);
17543 void vec_st (vector float, int, float *);
17544 void vec_st (vector signed int, int, vector signed int *);
17545 void vec_st (vector signed int, int, int *);
17546 void vec_st (vector unsigned int, int, vector unsigned int *);
17547 void vec_st (vector unsigned int, int, unsigned int *);
17548 void vec_st (vector bool int, int, vector bool int *);
17549 void vec_st (vector bool int, int, unsigned int *);
17550 void vec_st (vector bool int, int, int *);
17551 void vec_st (vector signed short, int, vector signed short *);
17552 void vec_st (vector signed short, int, short *);
17553 void vec_st (vector unsigned short, int, vector unsigned short *);
17554 void vec_st (vector unsigned short, int, unsigned short *);
17555 void vec_st (vector bool short, int, vector bool short *);
17556 void vec_st (vector bool short, int, unsigned short *);
17557 void vec_st (vector pixel, int, vector pixel *);
17558 void vec_st (vector pixel, int, unsigned short *);
17559 void vec_st (vector pixel, int, short *);
17560 void vec_st (vector bool short, int, short *);
17561 void vec_st (vector signed char, int, vector signed char *);
17562 void vec_st (vector signed char, int, signed char *);
17563 void vec_st (vector unsigned char, int, vector unsigned char *);
17564 void vec_st (vector unsigned char, int, unsigned char *);
17565 void vec_st (vector bool char, int, vector bool char *);
17566 void vec_st (vector bool char, int, unsigned char *);
17567 void vec_st (vector bool char, int, signed char *);
17569 void vec_ste (vector signed char, int, signed char *);
17570 void vec_ste (vector unsigned char, int, unsigned char *);
17571 void vec_ste (vector bool char, int, signed char *);
17572 void vec_ste (vector bool char, int, unsigned char *);
17573 void vec_ste (vector signed short, int, short *);
17574 void vec_ste (vector unsigned short, int, unsigned short *);
17575 void vec_ste (vector bool short, int, short *);
17576 void vec_ste (vector bool short, int, unsigned short *);
17577 void vec_ste (vector pixel, int, short *);
17578 void vec_ste (vector pixel, int, unsigned short *);
17579 void vec_ste (vector float, int, float *);
17580 void vec_ste (vector signed int, int, int *);
17581 void vec_ste (vector unsigned int, int, unsigned int *);
17582 void vec_ste (vector bool int, int, int *);
17583 void vec_ste (vector bool int, int, unsigned int *);
17585 void vec_stvewx (vector float, int, float *);
17586 void vec_stvewx (vector signed int, int, int *);
17587 void vec_stvewx (vector unsigned int, int, unsigned int *);
17588 void vec_stvewx (vector bool int, int, int *);
17589 void vec_stvewx (vector bool int, int, unsigned int *);
17591 void vec_stvehx (vector signed short, int, short *);
17592 void vec_stvehx (vector unsigned short, int, unsigned short *);
17593 void vec_stvehx (vector bool short, int, short *);
17594 void vec_stvehx (vector bool short, int, unsigned short *);
17595 void vec_stvehx (vector pixel, int, short *);
17596 void vec_stvehx (vector pixel, int, unsigned short *);
17598 void vec_stvebx (vector signed char, int, signed char *);
17599 void vec_stvebx (vector unsigned char, int, unsigned char *);
17600 void vec_stvebx (vector bool char, int, signed char *);
17601 void vec_stvebx (vector bool char, int, unsigned char *);
17603 void vec_stl (vector float, int, vector float *);
17604 void vec_stl (vector float, int, float *);
17605 void vec_stl (vector signed int, int, vector signed int *);
17606 void vec_stl (vector signed int, int, int *);
17607 void vec_stl (vector unsigned int, int, vector unsigned int *);
17608 void vec_stl (vector unsigned int, int, unsigned int *);
17609 void vec_stl (vector bool int, int, vector bool int *);
17610 void vec_stl (vector bool int, int, unsigned int *);
17611 void vec_stl (vector bool int, int, int *);
17612 void vec_stl (vector signed short, int, vector signed short *);
17613 void vec_stl (vector signed short, int, short *);
17614 void vec_stl (vector unsigned short, int, vector unsigned short *);
17615 void vec_stl (vector unsigned short, int, unsigned short *);
17616 void vec_stl (vector bool short, int, vector bool short *);
17617 void vec_stl (vector bool short, int, unsigned short *);
17618 void vec_stl (vector bool short, int, short *);
17619 void vec_stl (vector pixel, int, vector pixel *);
17620 void vec_stl (vector pixel, int, unsigned short *);
17621 void vec_stl (vector pixel, int, short *);
17622 void vec_stl (vector signed char, int, vector signed char *);
17623 void vec_stl (vector signed char, int, signed char *);
17624 void vec_stl (vector unsigned char, int, vector unsigned char *);
17625 void vec_stl (vector unsigned char, int, unsigned char *);
17626 void vec_stl (vector bool char, int, vector bool char *);
17627 void vec_stl (vector bool char, int, unsigned char *);
17628 void vec_stl (vector bool char, int, signed char *);
17630 vector signed char vec_sub (vector bool char, vector signed char);
17631 vector signed char vec_sub (vector signed char, vector bool char);
17632 vector signed char vec_sub (vector signed char, vector signed char);
17633 vector unsigned char vec_sub (vector bool char, vector unsigned char);
17634 vector unsigned char vec_sub (vector unsigned char, vector bool char);
17635 vector unsigned char vec_sub (vector unsigned char,
17636                               vector unsigned char);
17637 vector signed short vec_sub (vector bool short, vector signed short);
17638 vector signed short vec_sub (vector signed short, vector bool short);
17639 vector signed short vec_sub (vector signed short, vector signed short);
17640 vector unsigned short vec_sub (vector bool short,
17641                                vector unsigned short);
17642 vector unsigned short vec_sub (vector unsigned short,
17643                                vector bool short);
17644 vector unsigned short vec_sub (vector unsigned short,
17645                                vector unsigned short);
17646 vector signed int vec_sub (vector bool int, vector signed int);
17647 vector signed int vec_sub (vector signed int, vector bool int);
17648 vector signed int vec_sub (vector signed int, vector signed int);
17649 vector unsigned int vec_sub (vector bool int, vector unsigned int);
17650 vector unsigned int vec_sub (vector unsigned int, vector bool int);
17651 vector unsigned int vec_sub (vector unsigned int, vector unsigned int);
17652 vector float vec_sub (vector float, vector float);
17654 vector float vec_vsubfp (vector float, vector float);
17656 vector signed int vec_vsubuwm (vector bool int, vector signed int);
17657 vector signed int vec_vsubuwm (vector signed int, vector bool int);
17658 vector signed int vec_vsubuwm (vector signed int, vector signed int);
17659 vector unsigned int vec_vsubuwm (vector bool int, vector unsigned int);
17660 vector unsigned int vec_vsubuwm (vector unsigned int, vector bool int);
17661 vector unsigned int vec_vsubuwm (vector unsigned int,
17662                                  vector unsigned int);
17664 vector signed short vec_vsubuhm (vector bool short,
17665                                  vector signed short);
17666 vector signed short vec_vsubuhm (vector signed short,
17667                                  vector bool short);
17668 vector signed short vec_vsubuhm (vector signed short,
17669                                  vector signed short);
17670 vector unsigned short vec_vsubuhm (vector bool short,
17671                                    vector unsigned short);
17672 vector unsigned short vec_vsubuhm (vector unsigned short,
17673                                    vector bool short);
17674 vector unsigned short vec_vsubuhm (vector unsigned short,
17675                                    vector unsigned short);
17677 vector signed char vec_vsububm (vector bool char, vector signed char);
17678 vector signed char vec_vsububm (vector signed char, vector bool char);
17679 vector signed char vec_vsububm (vector signed char, vector signed char);
17680 vector unsigned char vec_vsububm (vector bool char,
17681                                   vector unsigned char);
17682 vector unsigned char vec_vsububm (vector unsigned char,
17683                                   vector bool char);
17684 vector unsigned char vec_vsububm (vector unsigned char,
17685                                   vector unsigned char);
17687 vector signed int vec_subc (vector signed int, vector signed int);
17688 vector unsigned int vec_subc (vector unsigned int, vector unsigned int);
17689 vector signed __int128 vec_subc (vector signed __int128,
17690                                  vector signed __int128);
17691 vector unsigned __int128 vec_subc (vector unsigned __int128,
17692                                    vector unsigned __int128);
17694 vector signed int vec_sube (vector signed int, vector signed int,
17695                             vector signed int);
17696 vector unsigned int vec_sube (vector unsigned int, vector unsigned int,
17697                               vector unsigned int);
17698 vector signed __int128 vec_sube (vector signed __int128,
17699                                  vector signed __int128,
17700                                  vector signed __int128);
17701 vector unsigned __int128 vec_sube (vector unsigned __int128,
17702                                    vector unsigned __int128,
17703                                    vector unsigned __int128);
17705 vector signed int vec_subec (vector signed int, vector signed int,
17706                              vector signed int);
17707 vector unsigned int vec_subec (vector unsigned int, vector unsigned int,
17708                                vector unsigned int);
17709 vector signed __int128 vec_subec (vector signed __int128,
17710                                   vector signed __int128,
17711                                   vector signed __int128);
17712 vector unsigned __int128 vec_subec (vector unsigned __int128,
17713                                     vector unsigned __int128,
17714                                     vector unsigned __int128);
17716 vector unsigned char vec_subs (vector bool char, vector unsigned char);
17717 vector unsigned char vec_subs (vector unsigned char, vector bool char);
17718 vector unsigned char vec_subs (vector unsigned char,
17719                                vector unsigned char);
17720 vector signed char vec_subs (vector bool char, vector signed char);
17721 vector signed char vec_subs (vector signed char, vector bool char);
17722 vector signed char vec_subs (vector signed char, vector signed char);
17723 vector unsigned short vec_subs (vector bool short,
17724                                 vector unsigned short);
17725 vector unsigned short vec_subs (vector unsigned short,
17726                                 vector bool short);
17727 vector unsigned short vec_subs (vector unsigned short,
17728                                 vector unsigned short);
17729 vector signed short vec_subs (vector bool short, vector signed short);
17730 vector signed short vec_subs (vector signed short, vector bool short);
17731 vector signed short vec_subs (vector signed short, vector signed short);
17732 vector unsigned int vec_subs (vector bool int, vector unsigned int);
17733 vector unsigned int vec_subs (vector unsigned int, vector bool int);
17734 vector unsigned int vec_subs (vector unsigned int, vector unsigned int);
17735 vector signed int vec_subs (vector bool int, vector signed int);
17736 vector signed int vec_subs (vector signed int, vector bool int);
17737 vector signed int vec_subs (vector signed int, vector signed int);
17739 vector signed int vec_vsubsws (vector bool int, vector signed int);
17740 vector signed int vec_vsubsws (vector signed int, vector bool int);
17741 vector signed int vec_vsubsws (vector signed int, vector signed int);
17743 vector unsigned int vec_vsubuws (vector bool int, vector unsigned int);
17744 vector unsigned int vec_vsubuws (vector unsigned int, vector bool int);
17745 vector unsigned int vec_vsubuws (vector unsigned int,
17746                                  vector unsigned int);
17748 vector signed short vec_vsubshs (vector bool short,
17749                                  vector signed short);
17750 vector signed short vec_vsubshs (vector signed short,
17751                                  vector bool short);
17752 vector signed short vec_vsubshs (vector signed short,
17753                                  vector signed short);
17755 vector unsigned short vec_vsubuhs (vector bool short,
17756                                    vector unsigned short);
17757 vector unsigned short vec_vsubuhs (vector unsigned short,
17758                                    vector bool short);
17759 vector unsigned short vec_vsubuhs (vector unsigned short,
17760                                    vector unsigned short);
17762 vector signed char vec_vsubsbs (vector bool char, vector signed char);
17763 vector signed char vec_vsubsbs (vector signed char, vector bool char);
17764 vector signed char vec_vsubsbs (vector signed char, vector signed char);
17766 vector unsigned char vec_vsububs (vector bool char,
17767                                   vector unsigned char);
17768 vector unsigned char vec_vsububs (vector unsigned char,
17769                                   vector bool char);
17770 vector unsigned char vec_vsububs (vector unsigned char,
17771                                   vector unsigned char);
17773 vector unsigned int vec_sum4s (vector unsigned char,
17774                                vector unsigned int);
17775 vector signed int vec_sum4s (vector signed char, vector signed int);
17776 vector signed int vec_sum4s (vector signed short, vector signed int);
17778 vector signed int vec_vsum4shs (vector signed short, vector signed int);
17780 vector signed int vec_vsum4sbs (vector signed char, vector signed int);
17782 vector unsigned int vec_vsum4ubs (vector unsigned char,
17783                                   vector unsigned int);
17785 vector signed int vec_sum2s (vector signed int, vector signed int);
17787 vector signed int vec_sums (vector signed int, vector signed int);
17789 vector float vec_trunc (vector float);
17791 vector signed long long vec_unsigned (vector double);
17792 vector signed int vec_unsigned (vector float);
17794 vector signed int vec_unsignede (vector double);
17795 vector signed int vec_unsignedo (vector double);
17796 vector signed int vec_unsigned2 (vector double, vector double);
17798 vector signed short vec_unpackh (vector signed char);
17799 vector bool short vec_unpackh (vector bool char);
17800 vector signed int vec_unpackh (vector signed short);
17801 vector bool int vec_unpackh (vector bool short);
17802 vector unsigned int vec_unpackh (vector pixel);
17803 vector double vec_unpackh (vector float);
17805 vector bool int vec_vupkhsh (vector bool short);
17806 vector signed int vec_vupkhsh (vector signed short);
17808 vector unsigned int vec_vupkhpx (vector pixel);
17810 vector bool short vec_vupkhsb (vector bool char);
17811 vector signed short vec_vupkhsb (vector signed char);
17813 vector signed short vec_unpackl (vector signed char);
17814 vector bool short vec_unpackl (vector bool char);
17815 vector unsigned int vec_unpackl (vector pixel);
17816 vector signed int vec_unpackl (vector signed short);
17817 vector bool int vec_unpackl (vector bool short);
17818 vector double vec_unpackl (vector float);
17820 vector unsigned int vec_vupklpx (vector pixel);
17822 vector bool int vec_vupklsh (vector bool short);
17823 vector signed int vec_vupklsh (vector signed short);
17825 vector bool short vec_vupklsb (vector bool char);
17826 vector signed short vec_vupklsb (vector signed char);
17828 vector float vec_xor (vector float, vector float);
17829 vector float vec_xor (vector float, vector bool int);
17830 vector float vec_xor (vector bool int, vector float);
17831 vector bool int vec_xor (vector bool int, vector bool int);
17832 vector signed int vec_xor (vector bool int, vector signed int);
17833 vector signed int vec_xor (vector signed int, vector bool int);
17834 vector signed int vec_xor (vector signed int, vector signed int);
17835 vector unsigned int vec_xor (vector bool int, vector unsigned int);
17836 vector unsigned int vec_xor (vector unsigned int, vector bool int);
17837 vector unsigned int vec_xor (vector unsigned int, vector unsigned int);
17838 vector bool short vec_xor (vector bool short, vector bool short);
17839 vector signed short vec_xor (vector bool short, vector signed short);
17840 vector signed short vec_xor (vector signed short, vector bool short);
17841 vector signed short vec_xor (vector signed short, vector signed short);
17842 vector unsigned short vec_xor (vector bool short,
17843                                vector unsigned short);
17844 vector unsigned short vec_xor (vector unsigned short,
17845                                vector bool short);
17846 vector unsigned short vec_xor (vector unsigned short,
17847                                vector unsigned short);
17848 vector signed char vec_xor (vector bool char, vector signed char);
17849 vector bool char vec_xor (vector bool char, vector bool char);
17850 vector signed char vec_xor (vector signed char, vector bool char);
17851 vector signed char vec_xor (vector signed char, vector signed char);
17852 vector unsigned char vec_xor (vector bool char, vector unsigned char);
17853 vector unsigned char vec_xor (vector unsigned char, vector bool char);
17854 vector unsigned char vec_xor (vector unsigned char,
17855                               vector unsigned char);
17857 int vec_all_eq (vector signed char, vector bool char);
17858 int vec_all_eq (vector signed char, vector signed char);
17859 int vec_all_eq (vector unsigned char, vector bool char);
17860 int vec_all_eq (vector unsigned char, vector unsigned char);
17861 int vec_all_eq (vector bool char, vector bool char);
17862 int vec_all_eq (vector bool char, vector unsigned char);
17863 int vec_all_eq (vector bool char, vector signed char);
17864 int vec_all_eq (vector signed short, vector bool short);
17865 int vec_all_eq (vector signed short, vector signed short);
17866 int vec_all_eq (vector unsigned short, vector bool short);
17867 int vec_all_eq (vector unsigned short, vector unsigned short);
17868 int vec_all_eq (vector bool short, vector bool short);
17869 int vec_all_eq (vector bool short, vector unsigned short);
17870 int vec_all_eq (vector bool short, vector signed short);
17871 int vec_all_eq (vector pixel, vector pixel);
17872 int vec_all_eq (vector signed int, vector bool int);
17873 int vec_all_eq (vector signed int, vector signed int);
17874 int vec_all_eq (vector unsigned int, vector bool int);
17875 int vec_all_eq (vector unsigned int, vector unsigned int);
17876 int vec_all_eq (vector bool int, vector bool int);
17877 int vec_all_eq (vector bool int, vector unsigned int);
17878 int vec_all_eq (vector bool int, vector signed int);
17879 int vec_all_eq (vector float, vector float);
17881 int vec_all_ge (vector bool char, vector unsigned char);
17882 int vec_all_ge (vector unsigned char, vector bool char);
17883 int vec_all_ge (vector unsigned char, vector unsigned char);
17884 int vec_all_ge (vector bool char, vector signed char);
17885 int vec_all_ge (vector signed char, vector bool char);
17886 int vec_all_ge (vector signed char, vector signed char);
17887 int vec_all_ge (vector bool short, vector unsigned short);
17888 int vec_all_ge (vector unsigned short, vector bool short);
17889 int vec_all_ge (vector unsigned short, vector unsigned short);
17890 int vec_all_ge (vector signed short, vector signed short);
17891 int vec_all_ge (vector bool short, vector signed short);
17892 int vec_all_ge (vector signed short, vector bool short);
17893 int vec_all_ge (vector bool int, vector unsigned int);
17894 int vec_all_ge (vector unsigned int, vector bool int);
17895 int vec_all_ge (vector unsigned int, vector unsigned int);
17896 int vec_all_ge (vector bool int, vector signed int);
17897 int vec_all_ge (vector signed int, vector bool int);
17898 int vec_all_ge (vector signed int, vector signed int);
17899 int vec_all_ge (vector float, vector float);
17901 int vec_all_gt (vector bool char, vector unsigned char);
17902 int vec_all_gt (vector unsigned char, vector bool char);
17903 int vec_all_gt (vector unsigned char, vector unsigned char);
17904 int vec_all_gt (vector bool char, vector signed char);
17905 int vec_all_gt (vector signed char, vector bool char);
17906 int vec_all_gt (vector signed char, vector signed char);
17907 int vec_all_gt (vector bool short, vector unsigned short);
17908 int vec_all_gt (vector unsigned short, vector bool short);
17909 int vec_all_gt (vector unsigned short, vector unsigned short);
17910 int vec_all_gt (vector bool short, vector signed short);
17911 int vec_all_gt (vector signed short, vector bool short);
17912 int vec_all_gt (vector signed short, vector signed short);
17913 int vec_all_gt (vector bool int, vector unsigned int);
17914 int vec_all_gt (vector unsigned int, vector bool int);
17915 int vec_all_gt (vector unsigned int, vector unsigned int);
17916 int vec_all_gt (vector bool int, vector signed int);
17917 int vec_all_gt (vector signed int, vector bool int);
17918 int vec_all_gt (vector signed int, vector signed int);
17919 int vec_all_gt (vector float, vector float);
17921 int vec_all_in (vector float, vector float);
17923 int vec_all_le (vector bool char, vector unsigned char);
17924 int vec_all_le (vector unsigned char, vector bool char);
17925 int vec_all_le (vector unsigned char, vector unsigned char);
17926 int vec_all_le (vector bool char, vector signed char);
17927 int vec_all_le (vector signed char, vector bool char);
17928 int vec_all_le (vector signed char, vector signed char);
17929 int vec_all_le (vector bool short, vector unsigned short);
17930 int vec_all_le (vector unsigned short, vector bool short);
17931 int vec_all_le (vector unsigned short, vector unsigned short);
17932 int vec_all_le (vector bool short, vector signed short);
17933 int vec_all_le (vector signed short, vector bool short);
17934 int vec_all_le (vector signed short, vector signed short);
17935 int vec_all_le (vector bool int, vector unsigned int);
17936 int vec_all_le (vector unsigned int, vector bool int);
17937 int vec_all_le (vector unsigned int, vector unsigned int);
17938 int vec_all_le (vector bool int, vector signed int);
17939 int vec_all_le (vector signed int, vector bool int);
17940 int vec_all_le (vector signed int, vector signed int);
17941 int vec_all_le (vector float, vector float);
17943 int vec_all_lt (vector bool char, vector unsigned char);
17944 int vec_all_lt (vector unsigned char, vector bool char);
17945 int vec_all_lt (vector unsigned char, vector unsigned char);
17946 int vec_all_lt (vector bool char, vector signed char);
17947 int vec_all_lt (vector signed char, vector bool char);
17948 int vec_all_lt (vector signed char, vector signed char);
17949 int vec_all_lt (vector bool short, vector unsigned short);
17950 int vec_all_lt (vector unsigned short, vector bool short);
17951 int vec_all_lt (vector unsigned short, vector unsigned short);
17952 int vec_all_lt (vector bool short, vector signed short);
17953 int vec_all_lt (vector signed short, vector bool short);
17954 int vec_all_lt (vector signed short, vector signed short);
17955 int vec_all_lt (vector bool int, vector unsigned int);
17956 int vec_all_lt (vector unsigned int, vector bool int);
17957 int vec_all_lt (vector unsigned int, vector unsigned int);
17958 int vec_all_lt (vector bool int, vector signed int);
17959 int vec_all_lt (vector signed int, vector bool int);
17960 int vec_all_lt (vector signed int, vector signed int);
17961 int vec_all_lt (vector float, vector float);
17963 int vec_all_nan (vector float);
17965 int vec_all_ne (vector signed char, vector bool char);
17966 int vec_all_ne (vector signed char, vector signed char);
17967 int vec_all_ne (vector unsigned char, vector bool char);
17968 int vec_all_ne (vector unsigned char, vector unsigned char);
17969 int vec_all_ne (vector bool char, vector bool char);
17970 int vec_all_ne (vector bool char, vector unsigned char);
17971 int vec_all_ne (vector bool char, vector signed char);
17972 int vec_all_ne (vector signed short, vector bool short);
17973 int vec_all_ne (vector signed short, vector signed short);
17974 int vec_all_ne (vector unsigned short, vector bool short);
17975 int vec_all_ne (vector unsigned short, vector unsigned short);
17976 int vec_all_ne (vector bool short, vector bool short);
17977 int vec_all_ne (vector bool short, vector unsigned short);
17978 int vec_all_ne (vector bool short, vector signed short);
17979 int vec_all_ne (vector pixel, vector pixel);
17980 int vec_all_ne (vector signed int, vector bool int);
17981 int vec_all_ne (vector signed int, vector signed int);
17982 int vec_all_ne (vector unsigned int, vector bool int);
17983 int vec_all_ne (vector unsigned int, vector unsigned int);
17984 int vec_all_ne (vector bool int, vector bool int);
17985 int vec_all_ne (vector bool int, vector unsigned int);
17986 int vec_all_ne (vector bool int, vector signed int);
17987 int vec_all_ne (vector float, vector float);
17989 int vec_all_nge (vector float, vector float);
17991 int vec_all_ngt (vector float, vector float);
17993 int vec_all_nle (vector float, vector float);
17995 int vec_all_nlt (vector float, vector float);
17997 int vec_all_numeric (vector float);
17999 int vec_any_eq (vector signed char, vector bool char);
18000 int vec_any_eq (vector signed char, vector signed char);
18001 int vec_any_eq (vector unsigned char, vector bool char);
18002 int vec_any_eq (vector unsigned char, vector unsigned char);
18003 int vec_any_eq (vector bool char, vector bool char);
18004 int vec_any_eq (vector bool char, vector unsigned char);
18005 int vec_any_eq (vector bool char, vector signed char);
18006 int vec_any_eq (vector signed short, vector bool short);
18007 int vec_any_eq (vector signed short, vector signed short);
18008 int vec_any_eq (vector unsigned short, vector bool short);
18009 int vec_any_eq (vector unsigned short, vector unsigned short);
18010 int vec_any_eq (vector bool short, vector bool short);
18011 int vec_any_eq (vector bool short, vector unsigned short);
18012 int vec_any_eq (vector bool short, vector signed short);
18013 int vec_any_eq (vector pixel, vector pixel);
18014 int vec_any_eq (vector signed int, vector bool int);
18015 int vec_any_eq (vector signed int, vector signed int);
18016 int vec_any_eq (vector unsigned int, vector bool int);
18017 int vec_any_eq (vector unsigned int, vector unsigned int);
18018 int vec_any_eq (vector bool int, vector bool int);
18019 int vec_any_eq (vector bool int, vector unsigned int);
18020 int vec_any_eq (vector bool int, vector signed int);
18021 int vec_any_eq (vector float, vector float);
18023 int vec_any_ge (vector signed char, vector bool char);
18024 int vec_any_ge (vector unsigned char, vector bool char);
18025 int vec_any_ge (vector unsigned char, vector unsigned char);
18026 int vec_any_ge (vector signed char, vector signed char);
18027 int vec_any_ge (vector bool char, vector unsigned char);
18028 int vec_any_ge (vector bool char, vector signed char);
18029 int vec_any_ge (vector unsigned short, vector bool short);
18030 int vec_any_ge (vector unsigned short, vector unsigned short);
18031 int vec_any_ge (vector signed short, vector signed short);
18032 int vec_any_ge (vector signed short, vector bool short);
18033 int vec_any_ge (vector bool short, vector unsigned short);
18034 int vec_any_ge (vector bool short, vector signed short);
18035 int vec_any_ge (vector signed int, vector bool int);
18036 int vec_any_ge (vector unsigned int, vector bool int);
18037 int vec_any_ge (vector unsigned int, vector unsigned int);
18038 int vec_any_ge (vector signed int, vector signed int);
18039 int vec_any_ge (vector bool int, vector unsigned int);
18040 int vec_any_ge (vector bool int, vector signed int);
18041 int vec_any_ge (vector float, vector float);
18043 int vec_any_gt (vector bool char, vector unsigned char);
18044 int vec_any_gt (vector unsigned char, vector bool char);
18045 int vec_any_gt (vector unsigned char, vector unsigned char);
18046 int vec_any_gt (vector bool char, vector signed char);
18047 int vec_any_gt (vector signed char, vector bool char);
18048 int vec_any_gt (vector signed char, vector signed char);
18049 int vec_any_gt (vector bool short, vector unsigned short);
18050 int vec_any_gt (vector unsigned short, vector bool short);
18051 int vec_any_gt (vector unsigned short, vector unsigned short);
18052 int vec_any_gt (vector bool short, vector signed short);
18053 int vec_any_gt (vector signed short, vector bool short);
18054 int vec_any_gt (vector signed short, vector signed short);
18055 int vec_any_gt (vector bool int, vector unsigned int);
18056 int vec_any_gt (vector unsigned int, vector bool int);
18057 int vec_any_gt (vector unsigned int, vector unsigned int);
18058 int vec_any_gt (vector bool int, vector signed int);
18059 int vec_any_gt (vector signed int, vector bool int);
18060 int vec_any_gt (vector signed int, vector signed int);
18061 int vec_any_gt (vector float, vector float);
18063 int vec_any_le (vector bool char, vector unsigned char);
18064 int vec_any_le (vector unsigned char, vector bool char);
18065 int vec_any_le (vector unsigned char, vector unsigned char);
18066 int vec_any_le (vector bool char, vector signed char);
18067 int vec_any_le (vector signed char, vector bool char);
18068 int vec_any_le (vector signed char, vector signed char);
18069 int vec_any_le (vector bool short, vector unsigned short);
18070 int vec_any_le (vector unsigned short, vector bool short);
18071 int vec_any_le (vector unsigned short, vector unsigned short);
18072 int vec_any_le (vector bool short, vector signed short);
18073 int vec_any_le (vector signed short, vector bool short);
18074 int vec_any_le (vector signed short, vector signed short);
18075 int vec_any_le (vector bool int, vector unsigned int);
18076 int vec_any_le (vector unsigned int, vector bool int);
18077 int vec_any_le (vector unsigned int, vector unsigned int);
18078 int vec_any_le (vector bool int, vector signed int);
18079 int vec_any_le (vector signed int, vector bool int);
18080 int vec_any_le (vector signed int, vector signed int);
18081 int vec_any_le (vector float, vector float);
18083 int vec_any_lt (vector bool char, vector unsigned char);
18084 int vec_any_lt (vector unsigned char, vector bool char);
18085 int vec_any_lt (vector unsigned char, vector unsigned char);
18086 int vec_any_lt (vector bool char, vector signed char);
18087 int vec_any_lt (vector signed char, vector bool char);
18088 int vec_any_lt (vector signed char, vector signed char);
18089 int vec_any_lt (vector bool short, vector unsigned short);
18090 int vec_any_lt (vector unsigned short, vector bool short);
18091 int vec_any_lt (vector unsigned short, vector unsigned short);
18092 int vec_any_lt (vector bool short, vector signed short);
18093 int vec_any_lt (vector signed short, vector bool short);
18094 int vec_any_lt (vector signed short, vector signed short);
18095 int vec_any_lt (vector bool int, vector unsigned int);
18096 int vec_any_lt (vector unsigned int, vector bool int);
18097 int vec_any_lt (vector unsigned int, vector unsigned int);
18098 int vec_any_lt (vector bool int, vector signed int);
18099 int vec_any_lt (vector signed int, vector bool int);
18100 int vec_any_lt (vector signed int, vector signed int);
18101 int vec_any_lt (vector float, vector float);
18103 int vec_any_nan (vector float);
18105 int vec_any_ne (vector signed char, vector bool char);
18106 int vec_any_ne (vector signed char, vector signed char);
18107 int vec_any_ne (vector unsigned char, vector bool char);
18108 int vec_any_ne (vector unsigned char, vector unsigned char);
18109 int vec_any_ne (vector bool char, vector bool char);
18110 int vec_any_ne (vector bool char, vector unsigned char);
18111 int vec_any_ne (vector bool char, vector signed char);
18112 int vec_any_ne (vector signed short, vector bool short);
18113 int vec_any_ne (vector signed short, vector signed short);
18114 int vec_any_ne (vector unsigned short, vector bool short);
18115 int vec_any_ne (vector unsigned short, vector unsigned short);
18116 int vec_any_ne (vector bool short, vector bool short);
18117 int vec_any_ne (vector bool short, vector unsigned short);
18118 int vec_any_ne (vector bool short, vector signed short);
18119 int vec_any_ne (vector pixel, vector pixel);
18120 int vec_any_ne (vector signed int, vector bool int);
18121 int vec_any_ne (vector signed int, vector signed int);
18122 int vec_any_ne (vector unsigned int, vector bool int);
18123 int vec_any_ne (vector unsigned int, vector unsigned int);
18124 int vec_any_ne (vector bool int, vector bool int);
18125 int vec_any_ne (vector bool int, vector unsigned int);
18126 int vec_any_ne (vector bool int, vector signed int);
18127 int vec_any_ne (vector float, vector float);
18129 int vec_any_nge (vector float, vector float);
18131 int vec_any_ngt (vector float, vector float);
18133 int vec_any_nle (vector float, vector float);
18135 int vec_any_nlt (vector float, vector float);
18137 int vec_any_numeric (vector float);
18139 int vec_any_out (vector float, vector float);
18140 @end smallexample
18142 If the vector/scalar (VSX) instruction set is available, the following
18143 additional functions are available:
18145 @smallexample
18146 vector double vec_abs (vector double);
18147 vector double vec_add (vector double, vector double);
18148 vector double vec_and (vector double, vector double);
18149 vector double vec_and (vector double, vector bool long);
18150 vector double vec_and (vector bool long, vector double);
18151 vector long vec_and (vector long, vector long);
18152 vector long vec_and (vector long, vector bool long);
18153 vector long vec_and (vector bool long, vector long);
18154 vector unsigned long vec_and (vector unsigned long, vector unsigned long);
18155 vector unsigned long vec_and (vector unsigned long, vector bool long);
18156 vector unsigned long vec_and (vector bool long, vector unsigned long);
18157 vector double vec_andc (vector double, vector double);
18158 vector double vec_andc (vector double, vector bool long);
18159 vector double vec_andc (vector bool long, vector double);
18160 vector long vec_andc (vector long, vector long);
18161 vector long vec_andc (vector long, vector bool long);
18162 vector long vec_andc (vector bool long, vector long);
18163 vector unsigned long vec_andc (vector unsigned long, vector unsigned long);
18164 vector unsigned long vec_andc (vector unsigned long, vector bool long);
18165 vector unsigned long vec_andc (vector bool long, vector unsigned long);
18166 vector double vec_ceil (vector double);
18167 vector bool long vec_cmpeq (vector double, vector double);
18168 vector bool long vec_cmpge (vector double, vector double);
18169 vector bool long vec_cmpgt (vector double, vector double);
18170 vector bool long vec_cmple (vector double, vector double);
18171 vector bool long vec_cmplt (vector double, vector double);
18172 vector double vec_cpsgn (vector double, vector double);
18173 vector float vec_div (vector float, vector float);
18174 vector double vec_div (vector double, vector double);
18175 vector long vec_div (vector long, vector long);
18176 vector unsigned long vec_div (vector unsigned long, vector unsigned long);
18177 vector double vec_floor (vector double);
18178 vector __int128 vec_ld (int, const vector __int128 *);
18179 vector unsigned __int128 vec_ld (int, const vector unsigned __int128 *);
18180 vector __int128 vec_ld (int, const __int128 *);
18181 vector unsigned __int128 vec_ld (int, const unsigned __int128 *);
18182 vector double vec_ld (int, const vector double *);
18183 vector double vec_ld (int, const double *);
18184 vector double vec_ldl (int, const vector double *);
18185 vector double vec_ldl (int, const double *);
18186 vector unsigned char vec_lvsl (int, const volatile double *);
18187 vector unsigned char vec_lvsr (int, const volatile double *);
18188 vector double vec_madd (vector double, vector double, vector double);
18189 vector double vec_max (vector double, vector double);
18190 vector signed long vec_mergeh (vector signed long, vector signed long);
18191 vector signed long vec_mergeh (vector signed long, vector bool long);
18192 vector signed long vec_mergeh (vector bool long, vector signed long);
18193 vector unsigned long vec_mergeh (vector unsigned long, vector unsigned long);
18194 vector unsigned long vec_mergeh (vector unsigned long, vector bool long);
18195 vector unsigned long vec_mergeh (vector bool long, vector unsigned long);
18196 vector signed long vec_mergel (vector signed long, vector signed long);
18197 vector signed long vec_mergel (vector signed long, vector bool long);
18198 vector signed long vec_mergel (vector bool long, vector signed long);
18199 vector unsigned long vec_mergel (vector unsigned long, vector unsigned long);
18200 vector unsigned long vec_mergel (vector unsigned long, vector bool long);
18201 vector unsigned long vec_mergel (vector bool long, vector unsigned long);
18202 vector double vec_min (vector double, vector double);
18203 vector float vec_msub (vector float, vector float, vector float);
18204 vector double vec_msub (vector double, vector double, vector double);
18205 vector float vec_mul (vector float, vector float);
18206 vector double vec_mul (vector double, vector double);
18207 vector long vec_mul (vector long, vector long);
18208 vector unsigned long vec_mul (vector unsigned long, vector unsigned long);
18209 vector float vec_nearbyint (vector float);
18210 vector double vec_nearbyint (vector double);
18211 vector float vec_nmadd (vector float, vector float, vector float);
18212 vector double vec_nmadd (vector double, vector double, vector double);
18213 vector double vec_nmsub (vector double, vector double, vector double);
18214 vector double vec_nor (vector double, vector double);
18215 vector long vec_nor (vector long, vector long);
18216 vector long vec_nor (vector long, vector bool long);
18217 vector long vec_nor (vector bool long, vector long);
18218 vector unsigned long vec_nor (vector unsigned long, vector unsigned long);
18219 vector unsigned long vec_nor (vector unsigned long, vector bool long);
18220 vector unsigned long vec_nor (vector bool long, vector unsigned long);
18221 vector double vec_or (vector double, vector double);
18222 vector double vec_or (vector double, vector bool long);
18223 vector double vec_or (vector bool long, vector double);
18224 vector long vec_or (vector long, vector long);
18225 vector long vec_or (vector long, vector bool long);
18226 vector long vec_or (vector bool long, vector long);
18227 vector unsigned long vec_or (vector unsigned long, vector unsigned long);
18228 vector unsigned long vec_or (vector unsigned long, vector bool long);
18229 vector unsigned long vec_or (vector bool long, vector unsigned long);
18230 vector double vec_perm (vector double, vector double, vector unsigned char);
18231 vector long vec_perm (vector long, vector long, vector unsigned char);
18232 vector unsigned long vec_perm (vector unsigned long, vector unsigned long,
18233                                vector unsigned char);
18234 vector bool char vec_permxor (vector bool char, vector bool char,
18235                               vector bool char);
18236 vector unsigned char vec_permxor (vector signed char, vector signed char,
18237                                   vector signed char);
18238 vector unsigned char vec_permxor (vector unsigned char, vector unsigned char,
18239                                   vector unsigned char);
18240 vector double vec_rint (vector double);
18241 vector double vec_recip (vector double, vector double);
18242 vector double vec_rsqrt (vector double);
18243 vector double vec_rsqrte (vector double);
18244 vector double vec_sel (vector double, vector double, vector bool long);
18245 vector double vec_sel (vector double, vector double, vector unsigned long);
18246 vector long vec_sel (vector long, vector long, vector long);
18247 vector long vec_sel (vector long, vector long, vector unsigned long);
18248 vector long vec_sel (vector long, vector long, vector bool long);
18249 vector unsigned long vec_sel (vector unsigned long, vector unsigned long,
18250                               vector long);
18251 vector unsigned long vec_sel (vector unsigned long, vector unsigned long,
18252                               vector unsigned long);
18253 vector unsigned long vec_sel (vector unsigned long, vector unsigned long,
18254                               vector bool long);
18255 vector double vec_splats (double);
18256 vector signed long vec_splats (signed long);
18257 vector unsigned long vec_splats (unsigned long);
18258 vector float vec_sqrt (vector float);
18259 vector double vec_sqrt (vector double);
18260 void vec_st (vector double, int, vector double *);
18261 void vec_st (vector double, int, double *);
18262 vector double vec_sub (vector double, vector double);
18263 vector double vec_trunc (vector double);
18264 vector double vec_xl (int, vector double *);
18265 vector double vec_xl (int, double *);
18266 vector long long vec_xl (int, vector long long *);
18267 vector long long vec_xl (int, long long *);
18268 vector unsigned long long vec_xl (int, vector unsigned long long *);
18269 vector unsigned long long vec_xl (int, unsigned long long *);
18270 vector float vec_xl (int, vector float *);
18271 vector float vec_xl (int, float *);
18272 vector int vec_xl (int, vector int *);
18273 vector int vec_xl (int, int *);
18274 vector unsigned int vec_xl (int, vector unsigned int *);
18275 vector unsigned int vec_xl (int, unsigned int *);
18276 vector double vec_xor (vector double, vector double);
18277 vector double vec_xor (vector double, vector bool long);
18278 vector double vec_xor (vector bool long, vector double);
18279 vector long vec_xor (vector long, vector long);
18280 vector long vec_xor (vector long, vector bool long);
18281 vector long vec_xor (vector bool long, vector long);
18282 vector unsigned long vec_xor (vector unsigned long, vector unsigned long);
18283 vector unsigned long vec_xor (vector unsigned long, vector bool long);
18284 vector unsigned long vec_xor (vector bool long, vector unsigned long);
18285 void vec_xst (vector double, int, vector double *);
18286 void vec_xst (vector double, int, double *);
18287 void vec_xst (vector long long, int, vector long long *);
18288 void vec_xst (vector long long, int, long long *);
18289 void vec_xst (vector unsigned long long, int, vector unsigned long long *);
18290 void vec_xst (vector unsigned long long, int, unsigned long long *);
18291 void vec_xst (vector float, int, vector float *);
18292 void vec_xst (vector float, int, float *);
18293 void vec_xst (vector int, int, vector int *);
18294 void vec_xst (vector int, int, int *);
18295 void vec_xst (vector unsigned int, int, vector unsigned int *);
18296 void vec_xst (vector unsigned int, int, unsigned int *);
18297 int vec_all_eq (vector double, vector double);
18298 int vec_all_ge (vector double, vector double);
18299 int vec_all_gt (vector double, vector double);
18300 int vec_all_le (vector double, vector double);
18301 int vec_all_lt (vector double, vector double);
18302 int vec_all_nan (vector double);
18303 int vec_all_ne (vector double, vector double);
18304 int vec_all_nge (vector double, vector double);
18305 int vec_all_ngt (vector double, vector double);
18306 int vec_all_nle (vector double, vector double);
18307 int vec_all_nlt (vector double, vector double);
18308 int vec_all_numeric (vector double);
18309 int vec_any_eq (vector double, vector double);
18310 int vec_any_ge (vector double, vector double);
18311 int vec_any_gt (vector double, vector double);
18312 int vec_any_le (vector double, vector double);
18313 int vec_any_lt (vector double, vector double);
18314 int vec_any_nan (vector double);
18315 int vec_any_ne (vector double, vector double);
18316 int vec_any_nge (vector double, vector double);
18317 int vec_any_ngt (vector double, vector double);
18318 int vec_any_nle (vector double, vector double);
18319 int vec_any_nlt (vector double, vector double);
18320 int vec_any_numeric (vector double);
18322 vector double vec_vsx_ld (int, const vector double *);
18323 vector double vec_vsx_ld (int, const double *);
18324 vector float vec_vsx_ld (int, const vector float *);
18325 vector float vec_vsx_ld (int, const float *);
18326 vector bool int vec_vsx_ld (int, const vector bool int *);
18327 vector signed int vec_vsx_ld (int, const vector signed int *);
18328 vector signed int vec_vsx_ld (int, const int *);
18329 vector signed int vec_vsx_ld (int, const long *);
18330 vector unsigned int vec_vsx_ld (int, const vector unsigned int *);
18331 vector unsigned int vec_vsx_ld (int, const unsigned int *);
18332 vector unsigned int vec_vsx_ld (int, const unsigned long *);
18333 vector bool short vec_vsx_ld (int, const vector bool short *);
18334 vector pixel vec_vsx_ld (int, const vector pixel *);
18335 vector signed short vec_vsx_ld (int, const vector signed short *);
18336 vector signed short vec_vsx_ld (int, const short *);
18337 vector unsigned short vec_vsx_ld (int, const vector unsigned short *);
18338 vector unsigned short vec_vsx_ld (int, const unsigned short *);
18339 vector bool char vec_vsx_ld (int, const vector bool char *);
18340 vector signed char vec_vsx_ld (int, const vector signed char *);
18341 vector signed char vec_vsx_ld (int, const signed char *);
18342 vector unsigned char vec_vsx_ld (int, const vector unsigned char *);
18343 vector unsigned char vec_vsx_ld (int, const unsigned char *);
18345 void vec_vsx_st (vector double, int, vector double *);
18346 void vec_vsx_st (vector double, int, double *);
18347 void vec_vsx_st (vector float, int, vector float *);
18348 void vec_vsx_st (vector float, int, float *);
18349 void vec_vsx_st (vector signed int, int, vector signed int *);
18350 void vec_vsx_st (vector signed int, int, int *);
18351 void vec_vsx_st (vector unsigned int, int, vector unsigned int *);
18352 void vec_vsx_st (vector unsigned int, int, unsigned int *);
18353 void vec_vsx_st (vector bool int, int, vector bool int *);
18354 void vec_vsx_st (vector bool int, int, unsigned int *);
18355 void vec_vsx_st (vector bool int, int, int *);
18356 void vec_vsx_st (vector signed short, int, vector signed short *);
18357 void vec_vsx_st (vector signed short, int, short *);
18358 void vec_vsx_st (vector unsigned short, int, vector unsigned short *);
18359 void vec_vsx_st (vector unsigned short, int, unsigned short *);
18360 void vec_vsx_st (vector bool short, int, vector bool short *);
18361 void vec_vsx_st (vector bool short, int, unsigned short *);
18362 void vec_vsx_st (vector pixel, int, vector pixel *);
18363 void vec_vsx_st (vector pixel, int, unsigned short *);
18364 void vec_vsx_st (vector pixel, int, short *);
18365 void vec_vsx_st (vector bool short, int, short *);
18366 void vec_vsx_st (vector signed char, int, vector signed char *);
18367 void vec_vsx_st (vector signed char, int, signed char *);
18368 void vec_vsx_st (vector unsigned char, int, vector unsigned char *);
18369 void vec_vsx_st (vector unsigned char, int, unsigned char *);
18370 void vec_vsx_st (vector bool char, int, vector bool char *);
18371 void vec_vsx_st (vector bool char, int, unsigned char *);
18372 void vec_vsx_st (vector bool char, int, signed char *);
18374 vector double vec_xxpermdi (vector double, vector double, const int);
18375 vector float vec_xxpermdi (vector float, vector float, const int);
18376 vector long long vec_xxpermdi (vector long long, vector long long, const int);
18377 vector unsigned long long vec_xxpermdi (vector unsigned long long,
18378                                         vector unsigned long long, const int);
18379 vector int vec_xxpermdi (vector int, vector int, const int);
18380 vector unsigned int vec_xxpermdi (vector unsigned int,
18381                                   vector unsigned int, const int);
18382 vector short vec_xxpermdi (vector short, vector short, const int);
18383 vector unsigned short vec_xxpermdi (vector unsigned short,
18384                                     vector unsigned short, const int);
18385 vector signed char vec_xxpermdi (vector signed char, vector signed char,
18386                                  const int);
18387 vector unsigned char vec_xxpermdi (vector unsigned char,
18388                                    vector unsigned char, const int);
18390 vector double vec_xxsldi (vector double, vector double, int);
18391 vector float vec_xxsldi (vector float, vector float, int);
18392 vector long long vec_xxsldi (vector long long, vector long long, int);
18393 vector unsigned long long vec_xxsldi (vector unsigned long long,
18394                                       vector unsigned long long, int);
18395 vector int vec_xxsldi (vector int, vector int, int);
18396 vector unsigned int vec_xxsldi (vector unsigned int, vector unsigned int, int);
18397 vector short vec_xxsldi (vector short, vector short, int);
18398 vector unsigned short vec_xxsldi (vector unsigned short,
18399                                   vector unsigned short, int);
18400 vector signed char vec_xxsldi (vector signed char, vector signed char, int);
18401 vector unsigned char vec_xxsldi (vector unsigned char,
18402                                  vector unsigned char, int);
18403 @end smallexample
18405 Note that the @samp{vec_ld} and @samp{vec_st} built-in functions always
18406 generate the AltiVec @samp{LVX} and @samp{STVX} instructions even
18407 if the VSX instruction set is available.  The @samp{vec_vsx_ld} and
18408 @samp{vec_vsx_st} built-in functions always generate the VSX @samp{LXVD2X},
18409 @samp{LXVW4X}, @samp{STXVD2X}, and @samp{STXVW4X} instructions.
18411 If the ISA 2.07 additions to the vector/scalar (power8-vector)
18412 instruction set are available, the following additional functions are
18413 available for both 32-bit and 64-bit targets.  For 64-bit targets, you
18414 can use @var{vector long} instead of @var{vector long long},
18415 @var{vector bool long} instead of @var{vector bool long long}, and
18416 @var{vector unsigned long} instead of @var{vector unsigned long long}.
18418 @smallexample
18419 vector long long vec_abs (vector long long);
18421 vector long long vec_add (vector long long, vector long long);
18422 vector unsigned long long vec_add (vector unsigned long long,
18423                                    vector unsigned long long);
18425 int vec_all_eq (vector long long, vector long long);
18426 int vec_all_eq (vector unsigned long long, vector unsigned long long);
18427 int vec_all_ge (vector long long, vector long long);
18428 int vec_all_ge (vector unsigned long long, vector unsigned long long);
18429 int vec_all_gt (vector long long, vector long long);
18430 int vec_all_gt (vector unsigned long long, vector unsigned long long);
18431 int vec_all_le (vector long long, vector long long);
18432 int vec_all_le (vector unsigned long long, vector unsigned long long);
18433 int vec_all_lt (vector long long, vector long long);
18434 int vec_all_lt (vector unsigned long long, vector unsigned long long);
18435 int vec_all_ne (vector long long, vector long long);
18436 int vec_all_ne (vector unsigned long long, vector unsigned long long);
18438 int vec_any_eq (vector long long, vector long long);
18439 int vec_any_eq (vector unsigned long long, vector unsigned long long);
18440 int vec_any_ge (vector long long, vector long long);
18441 int vec_any_ge (vector unsigned long long, vector unsigned long long);
18442 int vec_any_gt (vector long long, vector long long);
18443 int vec_any_gt (vector unsigned long long, vector unsigned long long);
18444 int vec_any_le (vector long long, vector long long);
18445 int vec_any_le (vector unsigned long long, vector unsigned long long);
18446 int vec_any_lt (vector long long, vector long long);
18447 int vec_any_lt (vector unsigned long long, vector unsigned long long);
18448 int vec_any_ne (vector long long, vector long long);
18449 int vec_any_ne (vector unsigned long long, vector unsigned long long);
18451 vector bool long long vec_cmpeq (vector bool long long, vector bool long long);
18453 vector long long vec_eqv (vector long long, vector long long);
18454 vector long long vec_eqv (vector bool long long, vector long long);
18455 vector long long vec_eqv (vector long long, vector bool long long);
18456 vector unsigned long long vec_eqv (vector unsigned long long,
18457                                    vector unsigned long long);
18458 vector unsigned long long vec_eqv (vector bool long long,
18459                                    vector unsigned long long);
18460 vector unsigned long long vec_eqv (vector unsigned long long,
18461                                    vector bool long long);
18462 vector int vec_eqv (vector int, vector int);
18463 vector int vec_eqv (vector bool int, vector int);
18464 vector int vec_eqv (vector int, vector bool int);
18465 vector unsigned int vec_eqv (vector unsigned int, vector unsigned int);
18466 vector unsigned int vec_eqv (vector bool unsigned int,
18467                              vector unsigned int);
18468 vector unsigned int vec_eqv (vector unsigned int,
18469                              vector bool unsigned int);
18470 vector short vec_eqv (vector short, vector short);
18471 vector short vec_eqv (vector bool short, vector short);
18472 vector short vec_eqv (vector short, vector bool short);
18473 vector unsigned short vec_eqv (vector unsigned short, vector unsigned short);
18474 vector unsigned short vec_eqv (vector bool unsigned short,
18475                                vector unsigned short);
18476 vector unsigned short vec_eqv (vector unsigned short,
18477                                vector bool unsigned short);
18478 vector signed char vec_eqv (vector signed char, vector signed char);
18479 vector signed char vec_eqv (vector bool signed char, vector signed char);
18480 vector signed char vec_eqv (vector signed char, vector bool signed char);
18481 vector unsigned char vec_eqv (vector unsigned char, vector unsigned char);
18482 vector unsigned char vec_eqv (vector bool unsigned char, vector unsigned char);
18483 vector unsigned char vec_eqv (vector unsigned char, vector bool unsigned char);
18485 vector long long vec_max (vector long long, vector long long);
18486 vector unsigned long long vec_max (vector unsigned long long,
18487                                    vector unsigned long long);
18489 vector signed int vec_mergee (vector signed int, vector signed int);
18490 vector unsigned int vec_mergee (vector unsigned int, vector unsigned int);
18491 vector bool int vec_mergee (vector bool int, vector bool int);
18493 vector signed int vec_mergeo (vector signed int, vector signed int);
18494 vector unsigned int vec_mergeo (vector unsigned int, vector unsigned int);
18495 vector bool int vec_mergeo (vector bool int, vector bool int);
18497 vector long long vec_min (vector long long, vector long long);
18498 vector unsigned long long vec_min (vector unsigned long long,
18499                                    vector unsigned long long);
18501 vector signed long long vec_nabs (vector signed long long);
18503 vector long long vec_nand (vector long long, vector long long);
18504 vector long long vec_nand (vector bool long long, vector long long);
18505 vector long long vec_nand (vector long long, vector bool long long);
18506 vector unsigned long long vec_nand (vector unsigned long long,
18507                                     vector unsigned long long);
18508 vector unsigned long long vec_nand (vector bool long long,
18509                                    vector unsigned long long);
18510 vector unsigned long long vec_nand (vector unsigned long long,
18511                                     vector bool long long);
18512 vector int vec_nand (vector int, vector int);
18513 vector int vec_nand (vector bool int, vector int);
18514 vector int vec_nand (vector int, vector bool int);
18515 vector unsigned int vec_nand (vector unsigned int, vector unsigned int);
18516 vector unsigned int vec_nand (vector bool unsigned int,
18517                               vector unsigned int);
18518 vector unsigned int vec_nand (vector unsigned int,
18519                               vector bool unsigned int);
18520 vector short vec_nand (vector short, vector short);
18521 vector short vec_nand (vector bool short, vector short);
18522 vector short vec_nand (vector short, vector bool short);
18523 vector unsigned short vec_nand (vector unsigned short, vector unsigned short);
18524 vector unsigned short vec_nand (vector bool unsigned short,
18525                                 vector unsigned short);
18526 vector unsigned short vec_nand (vector unsigned short,
18527                                 vector bool unsigned short);
18528 vector signed char vec_nand (vector signed char, vector signed char);
18529 vector signed char vec_nand (vector bool signed char, vector signed char);
18530 vector signed char vec_nand (vector signed char, vector bool signed char);
18531 vector unsigned char vec_nand (vector unsigned char, vector unsigned char);
18532 vector unsigned char vec_nand (vector bool unsigned char, vector unsigned char);
18533 vector unsigned char vec_nand (vector unsigned char, vector bool unsigned char);
18535 vector long long vec_orc (vector long long, vector long long);
18536 vector long long vec_orc (vector bool long long, vector long long);
18537 vector long long vec_orc (vector long long, vector bool long long);
18538 vector unsigned long long vec_orc (vector unsigned long long,
18539                                    vector unsigned long long);
18540 vector unsigned long long vec_orc (vector bool long long,
18541                                    vector unsigned long long);
18542 vector unsigned long long vec_orc (vector unsigned long long,
18543                                    vector bool long long);
18544 vector int vec_orc (vector int, vector int);
18545 vector int vec_orc (vector bool int, vector int);
18546 vector int vec_orc (vector int, vector bool int);
18547 vector unsigned int vec_orc (vector unsigned int, vector unsigned int);
18548 vector unsigned int vec_orc (vector bool unsigned int,
18549                              vector unsigned int);
18550 vector unsigned int vec_orc (vector unsigned int,
18551                              vector bool unsigned int);
18552 vector short vec_orc (vector short, vector short);
18553 vector short vec_orc (vector bool short, vector short);
18554 vector short vec_orc (vector short, vector bool short);
18555 vector unsigned short vec_orc (vector unsigned short, vector unsigned short);
18556 vector unsigned short vec_orc (vector bool unsigned short,
18557                                vector unsigned short);
18558 vector unsigned short vec_orc (vector unsigned short,
18559                                vector bool unsigned short);
18560 vector signed char vec_orc (vector signed char, vector signed char);
18561 vector signed char vec_orc (vector bool signed char, vector signed char);
18562 vector signed char vec_orc (vector signed char, vector bool signed char);
18563 vector unsigned char vec_orc (vector unsigned char, vector unsigned char);
18564 vector unsigned char vec_orc (vector bool unsigned char, vector unsigned char);
18565 vector unsigned char vec_orc (vector unsigned char, vector bool unsigned char);
18567 vector int vec_pack (vector long long, vector long long);
18568 vector unsigned int vec_pack (vector unsigned long long,
18569                               vector unsigned long long);
18570 vector bool int vec_pack (vector bool long long, vector bool long long);
18571 vector float vec_pack (vector double, vector double);
18573 vector int vec_packs (vector long long, vector long long);
18574 vector unsigned int vec_packs (vector unsigned long long,
18575                                vector unsigned long long);
18577 test_vsi_packsu_vssi_vssi (vector signed short x,
18579 vector unsigned char vec_packsu (vector signed short, vector signed short )
18580 vector unsigned char vec_packsu (vector unsigned short, vector unsigned short )
18581 vector unsigned short int vec_packsu (vector signed int, vector signed int);
18582 vector unsigned short int vec_packsu (vector unsigned int,
18583                                       vector unsigned int);
18584 vector unsigned int vec_packsu (vector long long, vector long long);
18585 vector unsigned int vec_packsu (vector unsigned long long,
18586                                 vector unsigned long long);
18587 vector unsigned int vec_packsu (vector signed long long,
18588                                 vector signed long long);
18590 vector unsigned char vec_popcnt (vector signed char);
18591 vector unsigned char vec_popcnt (vector unsigned char);
18592 vector unsigned short vec_popcnt (vector signed short);
18593 vector unsigned short vec_popcnt (vector unsigned short);
18594 vector unsigned int vec_popcnt (vector signed int);
18595 vector unsigned int vec_popcnt (vector unsigned int);
18596 vector unsigned long long vec_popcnt (vector signed long long);
18597 vector unsigned long long vec_popcnt (vector unsigned long long);
18599 vector long long vec_rl (vector long long,
18600                          vector unsigned long long);
18601 vector long long vec_rl (vector unsigned long long,
18602                          vector unsigned long long);
18604 vector long long vec_sl (vector long long, vector unsigned long long);
18605 vector long long vec_sl (vector unsigned long long,
18606                          vector unsigned long long);
18608 vector long long vec_sr (vector long long, vector unsigned long long);
18609 vector unsigned long long char vec_sr (vector unsigned long long,
18610                                        vector unsigned long long);
18612 vector long long vec_sra (vector long long, vector unsigned long long);
18613 vector unsigned long long vec_sra (vector unsigned long long,
18614                                    vector unsigned long long);
18616 vector long long vec_sub (vector long long, vector long long);
18617 vector unsigned long long vec_sub (vector unsigned long long,
18618                                    vector unsigned long long);
18620 vector long long vec_unpackh (vector int);
18621 vector unsigned long long vec_unpackh (vector unsigned int);
18623 vector long long vec_unpackl (vector int);
18624 vector unsigned long long vec_unpackl (vector unsigned int);
18626 vector long long vec_vaddudm (vector long long, vector long long);
18627 vector long long vec_vaddudm (vector bool long long, vector long long);
18628 vector long long vec_vaddudm (vector long long, vector bool long long);
18629 vector unsigned long long vec_vaddudm (vector unsigned long long,
18630                                        vector unsigned long long);
18631 vector unsigned long long vec_vaddudm (vector bool unsigned long long,
18632                                        vector unsigned long long);
18633 vector unsigned long long vec_vaddudm (vector unsigned long long,
18634                                        vector bool unsigned long long);
18636 vector long long vec_vbpermq (vector signed char, vector signed char);
18637 vector long long vec_vbpermq (vector unsigned char, vector unsigned char);
18639 vector unsigned char vec_bperm (vector unsigned char, vector unsigned char);
18640 vector unsigned char vec_bperm (vector unsigned long long,
18641                                 vector unsigned char);
18642 vector unsigned long long vec_bperm (vector unsigned __int128,
18643                                      vector unsigned char);
18645 vector long long vec_cntlz (vector long long);
18646 vector unsigned long long vec_cntlz (vector unsigned long long);
18647 vector int vec_cntlz (vector int);
18648 vector unsigned int vec_cntlz (vector int);
18649 vector short vec_cntlz (vector short);
18650 vector unsigned short vec_cntlz (vector unsigned short);
18651 vector signed char vec_cntlz (vector signed char);
18652 vector unsigned char vec_cntlz (vector unsigned char);
18654 vector long long vec_vclz (vector long long);
18655 vector unsigned long long vec_vclz (vector unsigned long long);
18656 vector int vec_vclz (vector int);
18657 vector unsigned int vec_vclz (vector int);
18658 vector short vec_vclz (vector short);
18659 vector unsigned short vec_vclz (vector unsigned short);
18660 vector signed char vec_vclz (vector signed char);
18661 vector unsigned char vec_vclz (vector unsigned char);
18663 vector signed char vec_vclzb (vector signed char);
18664 vector unsigned char vec_vclzb (vector unsigned char);
18666 vector long long vec_vclzd (vector long long);
18667 vector unsigned long long vec_vclzd (vector unsigned long long);
18669 vector short vec_vclzh (vector short);
18670 vector unsigned short vec_vclzh (vector unsigned short);
18672 vector int vec_vclzw (vector int);
18673 vector unsigned int vec_vclzw (vector int);
18675 vector signed char vec_vgbbd (vector signed char);
18676 vector unsigned char vec_vgbbd (vector unsigned char);
18678 vector long long vec_vmaxsd (vector long long, vector long long);
18680 vector unsigned long long vec_vmaxud (vector unsigned long long,
18681                                       unsigned vector long long);
18683 vector long long vec_vminsd (vector long long, vector long long);
18685 vector unsigned long long vec_vminud (vector long long,
18686                                       vector long long);
18688 vector int vec_vpksdss (vector long long, vector long long);
18689 vector unsigned int vec_vpksdss (vector long long, vector long long);
18691 vector unsigned int vec_vpkudus (vector unsigned long long,
18692                                  vector unsigned long long);
18694 vector int vec_vpkudum (vector long long, vector long long);
18695 vector unsigned int vec_vpkudum (vector unsigned long long,
18696                                  vector unsigned long long);
18697 vector bool int vec_vpkudum (vector bool long long, vector bool long long);
18699 vector long long vec_vpopcnt (vector long long);
18700 vector unsigned long long vec_vpopcnt (vector unsigned long long);
18701 vector int vec_vpopcnt (vector int);
18702 vector unsigned int vec_vpopcnt (vector int);
18703 vector short vec_vpopcnt (vector short);
18704 vector unsigned short vec_vpopcnt (vector unsigned short);
18705 vector signed char vec_vpopcnt (vector signed char);
18706 vector unsigned char vec_vpopcnt (vector unsigned char);
18708 vector signed char vec_vpopcntb (vector signed char);
18709 vector unsigned char vec_vpopcntb (vector unsigned char);
18711 vector long long vec_vpopcntd (vector long long);
18712 vector unsigned long long vec_vpopcntd (vector unsigned long long);
18714 vector short vec_vpopcnth (vector short);
18715 vector unsigned short vec_vpopcnth (vector unsigned short);
18717 vector int vec_vpopcntw (vector int);
18718 vector unsigned int vec_vpopcntw (vector int);
18720 vector long long vec_vrld (vector long long, vector unsigned long long);
18721 vector unsigned long long vec_vrld (vector unsigned long long,
18722                                     vector unsigned long long);
18724 vector long long vec_vsld (vector long long, vector unsigned long long);
18725 vector long long vec_vsld (vector unsigned long long,
18726                            vector unsigned long long);
18728 vector long long vec_vsrad (vector long long, vector unsigned long long);
18729 vector unsigned long long vec_vsrad (vector unsigned long long,
18730                                      vector unsigned long long);
18732 vector long long vec_vsrd (vector long long, vector unsigned long long);
18733 vector unsigned long long char vec_vsrd (vector unsigned long long,
18734                                          vector unsigned long long);
18736 vector long long vec_vsubudm (vector long long, vector long long);
18737 vector long long vec_vsubudm (vector bool long long, vector long long);
18738 vector long long vec_vsubudm (vector long long, vector bool long long);
18739 vector unsigned long long vec_vsubudm (vector unsigned long long,
18740                                        vector unsigned long long);
18741 vector unsigned long long vec_vsubudm (vector bool long long,
18742                                        vector unsigned long long);
18743 vector unsigned long long vec_vsubudm (vector unsigned long long,
18744                                        vector bool long long);
18746 vector long long vec_vupkhsw (vector int);
18747 vector unsigned long long vec_vupkhsw (vector unsigned int);
18749 vector long long vec_vupklsw (vector int);
18750 vector unsigned long long vec_vupklsw (vector int);
18751 @end smallexample
18753 If the ISA 2.07 additions to the vector/scalar (power8-vector)
18754 instruction set are available, the following additional functions are
18755 available for 64-bit targets.  New vector types
18756 (@var{vector __int128_t} and @var{vector __uint128_t}) are available
18757 to hold the @var{__int128_t} and @var{__uint128_t} types to use these
18758 builtins.
18760 The normal vector extract, and set operations work on
18761 @var{vector __int128_t} and @var{vector __uint128_t} types,
18762 but the index value must be 0.
18764 @smallexample
18765 vector __int128_t vec_vaddcuq (vector __int128_t, vector __int128_t);
18766 vector __uint128_t vec_vaddcuq (vector __uint128_t, vector __uint128_t);
18768 vector __int128_t vec_vadduqm (vector __int128_t, vector __int128_t);
18769 vector __uint128_t vec_vadduqm (vector __uint128_t, vector __uint128_t);
18771 vector __int128_t vec_vaddecuq (vector __int128_t, vector __int128_t,
18772                                 vector __int128_t);
18773 vector __uint128_t vec_vaddecuq (vector __uint128_t, vector __uint128_t,
18774                                  vector __uint128_t);
18776 vector __int128_t vec_vaddeuqm (vector __int128_t, vector __int128_t,
18777                                 vector __int128_t);
18778 vector __uint128_t vec_vaddeuqm (vector __uint128_t, vector __uint128_t,
18779                                  vector __uint128_t);
18781 vector __int128_t vec_vsubecuq (vector __int128_t, vector __int128_t,
18782                                 vector __int128_t);
18783 vector __uint128_t vec_vsubecuq (vector __uint128_t, vector __uint128_t,
18784                                  vector __uint128_t);
18786 vector __int128_t vec_vsubeuqm (vector __int128_t, vector __int128_t,
18787                                 vector __int128_t);
18788 vector __uint128_t vec_vsubeuqm (vector __uint128_t, vector __uint128_t,
18789                                  vector __uint128_t);
18791 vector __int128_t vec_vsubcuq (vector __int128_t, vector __int128_t);
18792 vector __uint128_t vec_vsubcuq (vector __uint128_t, vector __uint128_t);
18794 __int128_t vec_vsubuqm (__int128_t, __int128_t);
18795 __uint128_t vec_vsubuqm (__uint128_t, __uint128_t);
18797 vector __int128_t __builtin_bcdadd (vector __int128_t, vector __int128_t);
18798 int __builtin_bcdadd_lt (vector __int128_t, vector __int128_t);
18799 int __builtin_bcdadd_eq (vector __int128_t, vector __int128_t);
18800 int __builtin_bcdadd_gt (vector __int128_t, vector __int128_t);
18801 int __builtin_bcdadd_ov (vector __int128_t, vector __int128_t);
18802 vector __int128_t bcdsub (vector __int128_t, vector __int128_t);
18803 int __builtin_bcdsub_lt (vector __int128_t, vector __int128_t);
18804 int __builtin_bcdsub_eq (vector __int128_t, vector __int128_t);
18805 int __builtin_bcdsub_gt (vector __int128_t, vector __int128_t);
18806 int __builtin_bcdsub_ov (vector __int128_t, vector __int128_t);
18807 @end smallexample
18809 The following additional built-in functions are also available for the
18810 PowerPC family of processors, starting with ISA 3.0
18811 (@option{-mcpu=power9}) or later:
18812 @smallexample
18813 unsigned int scalar_extract_exp (double source);
18814 unsigned long long int scalar_extract_exp (__ieee128 source);
18816 unsigned long long int scalar_extract_sig (double source);
18817 unsigned __int128 scalar_extract_sig (__ieee128 source);
18819 double
18820 scalar_insert_exp (unsigned long long int significand, unsigned long long int exponent);
18821 double
18822 scalar_insert_exp (double significand, unsigned long long int exponent);
18824 ieee_128
18825 scalar_insert_exp (unsigned __int128 significand, unsigned long long int exponent);
18826 ieee_128
18827 scalar_insert_exp (ieee_128 significand, unsigned long long int exponent);
18829 int scalar_cmp_exp_gt (double arg1, double arg2);
18830 int scalar_cmp_exp_lt (double arg1, double arg2);
18831 int scalar_cmp_exp_eq (double arg1, double arg2);
18832 int scalar_cmp_exp_unordered (double arg1, double arg2);
18834 bool scalar_test_data_class (float source, const int condition);
18835 bool scalar_test_data_class (double source, const int condition);
18836 bool scalar_test_data_class (__ieee128 source, const int condition);
18838 bool scalar_test_neg (float source);
18839 bool scalar_test_neg (double source);
18840 bool scalar_test_neg (__ieee128 source);
18841 @end smallexample
18843 The @code{scalar_extract_exp} and @code{scalar_extract_sig}
18844 functions require a 64-bit environment supporting ISA 3.0 or later.
18845 The @code{scalar_extract_exp} and @code{scalar_extract_sig} built-in
18846 functions return the significand and the biased exponent value
18847 respectively of their @code{source} arguments.
18848 When supplied with a 64-bit @code{source} argument, the
18849 result returned by @code{scalar_extract_sig} has
18850 the @code{0x0010000000000000} bit set if the
18851 function's @code{source} argument is in normalized form.
18852 Otherwise, this bit is set to 0.
18853 When supplied with a 128-bit @code{source} argument, the
18854 @code{0x00010000000000000000000000000000} bit of the result is
18855 treated similarly.
18856 Note that the sign of the significand is not represented in the result
18857 returned from the @code{scalar_extract_sig} function.  Use the
18858 @code{scalar_test_neg} function to test the sign of its @code{double}
18859 argument.
18861 The @code{scalar_insert_exp}
18862 functions require a 64-bit environment supporting ISA 3.0 or later.
18863 When supplied with a 64-bit first argument, the
18864 @code{scalar_insert_exp} built-in function returns a double-precision
18865 floating point value that is constructed by assembling the values of its
18866 @code{significand} and @code{exponent} arguments.  The sign of the
18867 result is copied from the most significant bit of the
18868 @code{significand} argument.  The significand and exponent components
18869 of the result are composed of the least significant 11 bits of the
18870 @code{exponent} argument and the least significant 52 bits of the
18871 @code{significand} argument respectively.
18873 When supplied with a 128-bit first argument, the
18874 @code{scalar_insert_exp} built-in function returns a quad-precision
18875 ieee floating point value.  The sign bit of the result is copied from
18876 the most significant bit of the @code{significand} argument.
18877 The significand and exponent components of the result are composed of
18878 the least significant 15 bits of the @code{exponent} argument and the
18879 least significant 112 bits of the @code{significand} argument respectively.
18881 The @code{scalar_cmp_exp_gt}, @code{scalar_cmp_exp_lt},
18882 @code{scalar_cmp_exp_eq}, and @code{scalar_cmp_exp_unordered} built-in
18883 functions return a non-zero value if @code{arg1} is greater than, less
18884 than, equal to, or not comparable to @code{arg2} respectively.  The
18885 arguments are not comparable if one or the other equals NaN (not a
18886 number). 
18888 The @code{scalar_test_data_class} built-in function returns 1
18889 if any of the condition tests enabled by the value of the
18890 @code{condition} variable are true, and 0 otherwise.  The
18891 @code{condition} argument must be a compile-time constant integer with
18892 value not exceeding 127.  The
18893 @code{condition} argument is encoded as a bitmask with each bit
18894 enabling the testing of a different condition, as characterized by the
18895 following:
18896 @smallexample
18897 0x40    Test for NaN
18898 0x20    Test for +Infinity
18899 0x10    Test for -Infinity
18900 0x08    Test for +Zero
18901 0x04    Test for -Zero
18902 0x02    Test for +Denormal
18903 0x01    Test for -Denormal
18904 @end smallexample
18906 The @code{scalar_test_neg} built-in function returns 1 if its
18907 @code{source} argument holds a negative value, 0 otherwise.
18909 The following built-in functions are also available for the PowerPC family
18910 of processors, starting with ISA 3.0 or later
18911 (@option{-mcpu=power9}).  These string functions are described
18912 separately in order to group the descriptions closer to the function
18913 prototypes:
18914 @smallexample
18915 int vec_all_nez (vector signed char, vector signed char);
18916 int vec_all_nez (vector unsigned char, vector unsigned char);
18917 int vec_all_nez (vector signed short, vector signed short);
18918 int vec_all_nez (vector unsigned short, vector unsigned short);
18919 int vec_all_nez (vector signed int, vector signed int);
18920 int vec_all_nez (vector unsigned int, vector unsigned int);
18922 int vec_any_eqz (vector signed char, vector signed char);
18923 int vec_any_eqz (vector unsigned char, vector unsigned char);
18924 int vec_any_eqz (vector signed short, vector signed short);
18925 int vec_any_eqz (vector unsigned short, vector unsigned short);
18926 int vec_any_eqz (vector signed int, vector signed int);
18927 int vec_any_eqz (vector unsigned int, vector unsigned int);
18929 vector bool char vec_cmpnez (vector signed char arg1, vector signed char arg2);
18930 vector bool char vec_cmpnez (vector unsigned char arg1, vector unsigned char arg2);
18931 vector bool short vec_cmpnez (vector signed short arg1, vector signed short arg2);
18932 vector bool short vec_cmpnez (vector unsigned short arg1, vector unsigned short arg2);
18933 vector bool int vec_cmpnez (vector signed int arg1, vector signed int arg2);
18934 vector bool int vec_cmpnez (vector unsigned int, vector unsigned int);
18936 vector signed char vec_cnttz (vector signed char);
18937 vector unsigned char vec_cnttz (vector unsigned char);
18938 vector signed short vec_cnttz (vector signed short);
18939 vector unsigned short vec_cnttz (vector unsigned short);
18940 vector signed int vec_cnttz (vector signed int);
18941 vector unsigned int vec_cnttz (vector unsigned int);
18942 vector signed long long vec_cnttz (vector signed long long);
18943 vector unsigned long long vec_cnttz (vector unsigned long long);
18945 signed int vec_cntlz_lsbb (vector signed char);
18946 signed int vec_cntlz_lsbb (vector unsigned char);
18948 signed int vec_cnttz_lsbb (vector signed char);
18949 signed int vec_cnttz_lsbb (vector unsigned char);
18951 unsigned int vec_first_match_index (vector signed char, vector signed char);
18952 unsigned int vec_first_match_index (vector unsigned char,
18953                                     vector unsigned char);
18954 unsigned int vec_first_match_index (vector signed int, vector signed int);
18955 unsigned int vec_first_match_index (vector unsigned int, vector unsigned int);
18956 unsigned int vec_first_match_index (vector signed short, vector signed short);
18957 unsigned int vec_first_match_index (vector unsigned short,
18958                                     vector unsigned short);
18959 unsigned int vec_first_match_or_eos_index (vector signed char,
18960                                            vector signed char);
18961 unsigned int vec_first_match_or_eos_index (vector unsigned char,
18962                                            vector unsigned char);
18963 unsigned int vec_first_match_or_eos_index (vector signed int,
18964                                            vector signed int);
18965 unsigned int vec_first_match_or_eos_index (vector unsigned int,
18966                                            vector unsigned int);
18967 unsigned int vec_first_match_or_eos_index (vector signed short,
18968                                            vector signed short);
18969 unsigned int vec_first_match_or_eos_index (vector unsigned short,
18970                                            vector unsigned short);
18971 unsigned int vec_first_mismatch_index (vector signed char,
18972                                        vector signed char);
18973 unsigned int vec_first_mismatch_index (vector unsigned char,
18974                                        vector unsigned char);
18975 unsigned int vec_first_mismatch_index (vector signed int,
18976                                        vector signed int);
18977 unsigned int vec_first_mismatch_index (vector unsigned int,
18978                                        vector unsigned int);
18979 unsigned int vec_first_mismatch_index (vector signed short,
18980                                        vector signed short);
18981 unsigned int vec_first_mismatch_index (vector unsigned short,
18982                                        vector unsigned short);
18983 unsigned int vec_first_mismatch_or_eos_index (vector signed char,
18984                                               vector signed char);
18985 unsigned int vec_first_mismatch_or_eos_index (vector unsigned char,
18986                                               vector unsigned char);
18987 unsigned int vec_first_mismatch_or_eos_index (vector signed int,
18988                                               vector signed int);
18989 unsigned int vec_first_mismatch_or_eos_index (vector unsigned int,
18990                                               vector unsigned int);
18991 unsigned int vec_first_mismatch_or_eos_index (vector signed short,
18992                                               vector signed short);
18993 unsigned int vec_first_mismatch_or_eos_index (vector unsigned short,
18994                                               vector unsigned short);
18996 vector unsigned short vec_pack_to_short_fp32 (vector float, vector float);
18998 vector signed char vec_xl_be (signed long long, signed char *);
18999 vector unsigned char vec_xl_be (signed long long, unsigned char *);
19000 vector signed int vec_xl_be (signed long long, signed int *);
19001 vector unsigned int vec_xl_be (signed long long, unsigned int *);
19002 vector signed __int128 vec_xl_be (signed long long, signed __int128 *);
19003 vector unsigned __int128 vec_xl_be (signed long long, unsigned __int128 *);
19004 vector signed long long vec_xl_be (signed long long, signed long long *);
19005 vector unsigned long long vec_xl_be (signed long long, unsigned long long *);
19006 vector signed short vec_xl_be (signed long long, signed short *);
19007 vector unsigned short vec_xl_be (signed long long, unsigned short *);
19008 vector double vec_xl_be (signed long long, double *);
19009 vector float vec_xl_be (signed long long, float *);
19011 vector signed char vec_xl_len (signed char *addr, size_t len);
19012 vector unsigned char vec_xl_len (unsigned char *addr, size_t len);
19013 vector signed int vec_xl_len (signed int *addr, size_t len);
19014 vector unsigned int vec_xl_len (unsigned int *addr, size_t len);
19015 vector signed __int128 vec_xl_len (signed __int128 *addr, size_t len);
19016 vector unsigned __int128 vec_xl_len (unsigned __int128 *addr, size_t len);
19017 vector signed long long vec_xl_len (signed long long *addr, size_t len);
19018 vector unsigned long long vec_xl_len (unsigned long long *addr, size_t len);
19019 vector signed short vec_xl_len (signed short *addr, size_t len);
19020 vector unsigned short vec_xl_len (unsigned short *addr, size_t len);
19021 vector double vec_xl_len (double *addr, size_t len);
19022 vector float vec_xl_len (float *addr, size_t len);
19024 vector unsigned char vec_xl_len_r (unsigned char *addr, size_t len);
19026 void vec_xst_len (vector signed char data, signed char *addr, size_t len);
19027 void vec_xst_len (vector unsigned char data, unsigned char *addr, size_t len);
19028 void vec_xst_len (vector signed int data, signed int *addr, size_t len);
19029 void vec_xst_len (vector unsigned int data, unsigned int *addr, size_t len);
19030 void vec_xst_len (vector unsigned __int128 data, unsigned __int128 *addr, size_t len);
19031 void vec_xst_len (vector signed long long data, signed long long *addr, size_t len);
19032 void vec_xst_len (vector unsigned long long data, unsigned long long *addr, size_t len);
19033 void vec_xst_len (vector signed short data, signed short *addr, size_t len);
19034 void vec_xst_len (vector unsigned short data, unsigned short *addr, size_t len);
19035 void vec_xst_len (vector signed __int128 data, signed __int128 *addr, size_t len);
19036 void vec_xst_len (vector double data, double *addr, size_t len);
19037 void vec_xst_len (vector float data, float *addr, size_t len);
19039 void vec_xst_len_r (vector unsigned char data, unsigned char *addr, size_t len);
19041 signed char vec_xlx (unsigned int index, vector signed char data);
19042 unsigned char vec_xlx (unsigned int index, vector unsigned char data);
19043 signed short vec_xlx (unsigned int index, vector signed short data);
19044 unsigned short vec_xlx (unsigned int index, vector unsigned short data);
19045 signed int vec_xlx (unsigned int index, vector signed int data);
19046 unsigned int vec_xlx (unsigned int index, vector unsigned int data);
19047 float vec_xlx (unsigned int index, vector float data);
19049 signed char vec_xrx (unsigned int index, vector signed char data);
19050 unsigned char vec_xrx (unsigned int index, vector unsigned char data);
19051 signed short vec_xrx (unsigned int index, vector signed short data);
19052 unsigned short vec_xrx (unsigned int index, vector unsigned short data);
19053 signed int vec_xrx (unsigned int index, vector signed int data);
19054 unsigned int vec_xrx (unsigned int index, vector unsigned int data);
19055 float vec_xrx (unsigned int index, vector float data);
19056 @end smallexample
19058 The @code{vec_all_nez}, @code{vec_any_eqz}, and @code{vec_cmpnez}
19059 perform pairwise comparisons between the elements at the same
19060 positions within their two vector arguments.
19061 The @code{vec_all_nez} function returns a
19062 non-zero value if and only if all pairwise comparisons are not
19063 equal and no element of either vector argument contains a zero.
19064 The @code{vec_any_eqz} function returns a
19065 non-zero value if and only if at least one pairwise comparison is equal
19066 or if at least one element of either vector argument contains a zero.
19067 The @code{vec_cmpnez} function returns a vector of the same type as
19068 its two arguments, within which each element consists of all ones to
19069 denote that either the corresponding elements of the incoming arguments are
19070 not equal or that at least one of the corresponding elements contains
19071 zero.  Otherwise, the element of the returned vector contains all zeros.
19073 The @code{vec_cntlz_lsbb} function returns the count of the number of
19074 consecutive leading byte elements (starting from position 0 within the
19075 supplied vector argument) for which the least-significant bit
19076 equals zero.  The @code{vec_cnttz_lsbb} function returns the count of
19077 the number of consecutive trailing byte elements (starting from
19078 position 15 and counting backwards within the supplied vector
19079 argument) for which the least-significant bit equals zero.
19081 The @code{vec_xl_len} and @code{vec_xst_len} functions require a
19082 64-bit environment supporting ISA 3.0 or later.  The @code{vec_xl_len}
19083 function loads a variable length vector from memory.  The
19084 @code{vec_xst_len} function stores a variable length vector to memory.
19085 With both the @code{vec_xl_len} and @code{vec_xst_len} functions, the
19086 @code{addr} argument represents the memory address to or from which
19087 data will be transferred, and the
19088 @code{len} argument represents the number of bytes to be
19089 transferred, as computed by the C expression @code{min((len & 0xff), 16)}.
19090 If this expression's value is not a multiple of the vector element's
19091 size, the behavior of this function is undefined.
19092 In the case that the underlying computer is configured to run in
19093 big-endian mode, the data transfer moves bytes 0 to @code{(len - 1)} of
19094 the corresponding vector.  In little-endian mode, the data transfer
19095 moves bytes @code{(16 - len)} to @code{15} of the corresponding
19096 vector.  For the load function, any bytes of the result vector that
19097 are not loaded from memory are set to zero.
19098 The value of the @code{addr} argument need not be aligned on a
19099 multiple of the vector's element size.
19101 The @code{vec_xlx} and @code{vec_xrx} functions extract the single
19102 element selected by the @code{index} argument from the vector
19103 represented by the @code{data} argument.  The @code{index} argument
19104 always specifies a byte offset, regardless of the size of the vector
19105 element.  With @code{vec_xlx}, @code{index} is the offset of the first
19106 byte of the element to be extracted.  With @code{vec_xrx}, @code{index}
19107 represents the last byte of the element to be extracted, measured
19108 from the right end of the vector.  In other words, the last byte of
19109 the element to be extracted is found at position @code{(15 - index)}.
19110 There is no requirement that @code{index} be a multiple of the vector
19111 element size.  However, if the size of the vector element added to
19112 @code{index} is greater than 15, the content of the returned value is
19113 undefined.
19115 If the ISA 3.0 instruction set additions (@option{-mcpu=power9})
19116 are available:
19118 @smallexample
19119 vector unsigned long long vec_bperm (vector unsigned long long,
19120                                      vector unsigned char);
19122 vector bool char vec_cmpne (vector bool char, vector bool char);
19123 vector bool char vec_cmpne (vector signed char, vector signed char);
19124 vector bool char vec_cmpne (vector unsigned char, vector unsigned char);
19125 vector bool int vec_cmpne (vector bool int, vector bool int);
19126 vector bool int vec_cmpne (vector signed int, vector signed int);
19127 vector bool int vec_cmpne (vector unsigned int, vector unsigned int);
19128 vector bool long long vec_cmpne (vector bool long long, vector bool long long);
19129 vector bool long long vec_cmpne (vector signed long long,
19130                                  vector signed long long);
19131 vector bool long long vec_cmpne (vector unsigned long long,
19132                                  vector unsigned long long);
19133 vector bool short vec_cmpne (vector bool short, vector bool short);
19134 vector bool short vec_cmpne (vector signed short, vector signed short);
19135 vector bool short vec_cmpne (vector unsigned short, vector unsigned short);
19136 vector bool long long vec_cmpne (vector double, vector double);
19137 vector bool int vec_cmpne (vector float, vector float);
19139 vector float vec_extract_fp32_from_shorth (vector unsigned short);
19140 vector float vec_extract_fp32_from_shortl (vector unsigned short);
19142 vector long long vec_vctz (vector long long);
19143 vector unsigned long long vec_vctz (vector unsigned long long);
19144 vector int vec_vctz (vector int);
19145 vector unsigned int vec_vctz (vector int);
19146 vector short vec_vctz (vector short);
19147 vector unsigned short vec_vctz (vector unsigned short);
19148 vector signed char vec_vctz (vector signed char);
19149 vector unsigned char vec_vctz (vector unsigned char);
19151 vector signed char vec_vctzb (vector signed char);
19152 vector unsigned char vec_vctzb (vector unsigned char);
19154 vector long long vec_vctzd (vector long long);
19155 vector unsigned long long vec_vctzd (vector unsigned long long);
19157 vector short vec_vctzh (vector short);
19158 vector unsigned short vec_vctzh (vector unsigned short);
19160 vector int vec_vctzw (vector int);
19161 vector unsigned int vec_vctzw (vector int);
19163 vector unsigned long long vec_extract4b (vector unsigned char, const int);
19165 vector unsigned char vec_insert4b (vector signed int, vector unsigned char,
19166                                    const int);
19167 vector unsigned char vec_insert4b (vector unsigned int, vector unsigned char,
19168                                    const int);
19170 vector unsigned int vec_parity_lsbb (vector signed int);
19171 vector unsigned int vec_parity_lsbb (vector unsigned int);
19172 vector unsigned __int128 vec_parity_lsbb (vector signed __int128);
19173 vector unsigned __int128 vec_parity_lsbb (vector unsigned __int128);
19174 vector unsigned long long vec_parity_lsbb (vector signed long long);
19175 vector unsigned long long vec_parity_lsbb (vector unsigned long long);
19177 vector int vec_vprtyb (vector int);
19178 vector unsigned int vec_vprtyb (vector unsigned int);
19179 vector long long vec_vprtyb (vector long long);
19180 vector unsigned long long vec_vprtyb (vector unsigned long long);
19182 vector int vec_vprtybw (vector int);
19183 vector unsigned int vec_vprtybw (vector unsigned int);
19185 vector long long vec_vprtybd (vector long long);
19186 vector unsigned long long vec_vprtybd (vector unsigned long long);
19187 @end smallexample
19189 On 64-bit targets, if the ISA 3.0 additions (@option{-mcpu=power9})
19190 are available:
19192 @smallexample
19193 vector long vec_vprtyb (vector long);
19194 vector unsigned long vec_vprtyb (vector unsigned long);
19195 vector __int128_t vec_vprtyb (vector __int128_t);
19196 vector __uint128_t vec_vprtyb (vector __uint128_t);
19198 vector long vec_vprtybd (vector long);
19199 vector unsigned long vec_vprtybd (vector unsigned long);
19201 vector __int128_t vec_vprtybq (vector __int128_t);
19202 vector __uint128_t vec_vprtybd (vector __uint128_t);
19203 @end smallexample
19205 The following built-in vector 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 char
19209 vec_slv (__vector unsigned char src, __vector unsigned char shift_distance);
19210 __vector unsigned char
19211 vec_srv (__vector unsigned char src, __vector unsigned char shift_distance);
19212 @end smallexample
19214 The @code{vec_slv} and @code{vec_srv} functions operate on
19215 all of the bytes of their @code{src} and @code{shift_distance}
19216 arguments in parallel.  The behavior of the @code{vec_slv} is as if
19217 there existed a temporary array of 17 unsigned characters
19218 @code{slv_array} within which elements 0 through 15 are the same as
19219 the entries in the @code{src} array and element 16 equals 0.  The
19220 result returned from the @code{vec_slv} function is a
19221 @code{__vector} of 16 unsigned characters within which element
19222 @code{i} is computed using the C expression
19223 @code{0xff & (*((unsigned short *)(slv_array + i)) << (0x07 &
19224 shift_distance[i]))},
19225 with this resulting value coerced to the @code{unsigned char} type.
19226 The behavior of the @code{vec_srv} is as if
19227 there existed a temporary array of 17 unsigned characters
19228 @code{srv_array} within which element 0 equals zero and
19229 elements 1 through 16 equal the elements 0 through 15 of
19230 the @code{src} array.  The
19231 result returned from the @code{vec_srv} function is a
19232 @code{__vector} of 16 unsigned characters within which element
19233 @code{i} is computed using the C expression
19234 @code{0xff & (*((unsigned short *)(srv_array + i)) >>
19235 (0x07 & shift_distance[i]))},
19236 with this resulting value coerced to the @code{unsigned char} type.
19238 The following built-in functions are available for the PowerPC family
19239 of processors, starting with ISA 3.0 or later (@option{-mcpu=power9}):
19240 @smallexample
19241 __vector unsigned char
19242 vec_absd (__vector unsigned char arg1, __vector unsigned char arg2);
19243 __vector unsigned short
19244 vec_absd (__vector unsigned short arg1, __vector unsigned short arg2);
19245 __vector unsigned int
19246 vec_absd (__vector unsigned int arg1, __vector unsigned int arg2);
19248 __vector unsigned char
19249 vec_absdb (__vector unsigned char arg1, __vector unsigned char arg2);
19250 __vector unsigned short
19251 vec_absdh (__vector unsigned short arg1, __vector unsigned short arg2);
19252 __vector unsigned int
19253 vec_absdw (__vector unsigned int arg1, __vector unsigned int arg2);
19254 @end smallexample
19256 The @code{vec_absd}, @code{vec_absdb}, @code{vec_absdh}, and
19257 @code{vec_absdw} built-in functions each computes the absolute
19258 differences of the pairs of vector elements supplied in its two vector
19259 arguments, placing the absolute differences into the corresponding
19260 elements of the vector result.
19262 The following built-in functions are available for the PowerPC family
19263 of processors, starting with ISA 3.0 or later (@option{-mcpu=power9}):
19264 @smallexample
19265 __vector unsigned int
19266 vec_extract_exp (__vector float source);
19267 __vector unsigned long long int
19268 vec_extract_exp (__vector double source);
19270 __vector unsigned int
19271 vec_extract_sig (__vector float source);
19272 __vector unsigned long long int
19273 vec_extract_sig (__vector double source);
19275 __vector float
19276 vec_insert_exp (__vector unsigned int significands,
19277                 __vector unsigned int exponents);
19278 __vector float
19279 vec_insert_exp (__vector unsigned float significands,
19280                 __vector unsigned int exponents);
19281 __vector double
19282 vec_insert_exp (__vector unsigned long long int significands,
19283                 __vector unsigned long long int exponents);
19284 __vector double
19285 vec_insert_exp (__vector unsigned double significands,
19286                 __vector unsigned long long int exponents);
19288 __vector bool int vec_test_data_class (__vector float source,
19289                                        const int condition);
19290 __vector bool long long int vec_test_data_class (__vector double source,
19291                                                  const int condition);
19292 @end smallexample
19294 The @code{vec_extract_sig} and @code{vec_extract_exp} built-in
19295 functions return vectors representing the significands and biased
19296 exponent values of their @code{source} arguments respectively.
19297 Within the result vector returned by @code{vec_extract_sig}, the
19298 @code{0x800000} bit of each vector element returned when the
19299 function's @code{source} argument is of type @code{float} is set to 1
19300 if the corresponding floating point value is in normalized form.
19301 Otherwise, this bit is set to 0.  When the @code{source} argument is
19302 of type @code{double}, the @code{0x10000000000000} bit within each of
19303 the result vector's elements is set according to the same rules.
19304 Note that the sign of the significand is not represented in the result
19305 returned from the @code{vec_extract_sig} function.  To extract the
19306 sign bits, use the
19307 @code{vec_cpsgn} function, which returns a new vector within which all
19308 of the sign bits of its second argument vector are overwritten with the
19309 sign bits copied from the coresponding elements of its first argument
19310 vector, and all other (non-sign) bits of the second argument vector
19311 are copied unchanged into the result vector.
19313 The @code{vec_insert_exp} built-in functions return a vector of
19314 single- or double-precision floating
19315 point values constructed by assembling the values of their
19316 @code{significands} and @code{exponents} arguments into the
19317 corresponding elements of the returned vector.
19318 The sign of each
19319 element of the result is copied from the most significant bit of the
19320 corresponding entry within the @code{significands} argument.
19321 Note that the relevant
19322 bits of the @code{significands} argument are the same, for both integer
19323 and floating point types.
19325 significand and exponent components of each element of the result are
19326 composed of the least significant bits of the corresponding
19327 @code{significands} element and the least significant bits of the
19328 corresponding @code{exponents} element.
19330 The @code{vec_test_data_class} built-in function returns a vector
19331 representing the results of testing the @code{source} vector for the
19332 condition selected by the @code{condition} argument.  The
19333 @code{condition} argument must be a compile-time constant integer with
19334 value not exceeding 127.  The
19335 @code{condition} argument is encoded as a bitmask with each bit
19336 enabling the testing of a different condition, as characterized by the
19337 following:
19338 @smallexample
19339 0x40    Test for NaN
19340 0x20    Test for +Infinity
19341 0x10    Test for -Infinity
19342 0x08    Test for +Zero
19343 0x04    Test for -Zero
19344 0x02    Test for +Denormal
19345 0x01    Test for -Denormal
19346 @end smallexample
19348 If any of the enabled test conditions is true, the corresponding entry
19349 in the result vector is -1.  Otherwise (all of the enabled test
19350 conditions are false), the corresponding entry of the result vector is 0.
19352 The following built-in functions are available for the PowerPC family
19353 of processors, starting with ISA 3.0 or later (@option{-mcpu=power9}):
19354 @smallexample
19355 vector unsigned int vec_rlmi (vector unsigned int, vector unsigned int,
19356                               vector unsigned int);
19357 vector unsigned long long vec_rlmi (vector unsigned long long,
19358                                     vector unsigned long long,
19359                                     vector unsigned long long);
19360 vector unsigned int vec_rlnm (vector unsigned int, vector unsigned int,
19361                               vector unsigned int);
19362 vector unsigned long long vec_rlnm (vector unsigned long long,
19363                                     vector unsigned long long,
19364                                     vector unsigned long long);
19365 vector unsigned int vec_vrlnm (vector unsigned int, vector unsigned int);
19366 vector unsigned long long vec_vrlnm (vector unsigned long long,
19367                                      vector unsigned long long);
19368 @end smallexample
19370 The result of @code{vec_rlmi} is obtained by rotating each element of
19371 the first argument vector left and inserting it under mask into the
19372 second argument vector.  The third argument vector contains the mask
19373 beginning in bits 11:15, the mask end in bits 19:23, and the shift
19374 count in bits 27:31, of each element.
19376 The result of @code{vec_rlnm} is obtained by rotating each element of
19377 the first argument vector left and ANDing it with a mask specified by
19378 the second and third argument vectors.  The second argument vector
19379 contains the shift count for each element in the low-order byte.  The
19380 third argument vector contains the mask end for each element in the
19381 low-order byte, with the mask begin in the next higher byte.
19383 The result of @code{vec_vrlnm} is obtained by rotating each element
19384 of the first argument vector left and ANDing it with a mask.  The
19385 second argument vector contains the mask  beginning in bits 11:15,
19386 the mask end in bits 19:23, and the shift count in bits 27:31,
19387 of each element.
19389 If the ISA 3.0 instruction set additions (@option{-mcpu=power9})
19390 are available:
19391 @smallexample
19392 vector signed bool char vec_revb (vector signed char);
19393 vector signed char vec_revb (vector signed char);
19394 vector unsigned char vec_revb (vector unsigned char);
19395 vector bool short vec_revb (vector bool short);
19396 vector short vec_revb (vector short);
19397 vector unsigned short vec_revb (vector unsigned short);
19398 vector bool int vec_revb (vector bool int);
19399 vector int vec_revb (vector int);
19400 vector unsigned int vec_revb (vector unsigned int);
19401 vector float vec_revb (vector float);
19402 vector bool long long vec_revb (vector bool long long);
19403 vector long long vec_revb (vector long long);
19404 vector unsigned long long vec_revb (vector unsigned long long);
19405 vector double vec_revb (vector double);
19406 @end smallexample
19408 On 64-bit targets, if the ISA 3.0 additions (@option{-mcpu=power9})
19409 are available:
19410 @smallexample
19411 vector long vec_revb (vector long);
19412 vector unsigned long vec_revb (vector unsigned long);
19413 vector __int128_t vec_revb (vector __int128_t);
19414 vector __uint128_t vec_revb (vector __uint128_t);
19415 @end smallexample
19417 The @code{vec_revb} built-in function reverses the bytes on an element
19418 by element basis.  A vector of @code{vector unsigned char} or
19419 @code{vector signed char} reverses the bytes in the whole word.
19421 If the cryptographic instructions are enabled (@option{-mcrypto} or
19422 @option{-mcpu=power8}), the following builtins are enabled.
19424 @smallexample
19425 vector unsigned long long __builtin_crypto_vsbox (vector unsigned long long);
19427 vector unsigned long long __builtin_crypto_vcipher (vector unsigned long long,
19428                                                     vector unsigned long long);
19430 vector unsigned long long __builtin_crypto_vcipherlast
19431                                      (vector unsigned long long,
19432                                       vector unsigned long long);
19434 vector unsigned long long __builtin_crypto_vncipher (vector unsigned long long,
19435                                                      vector unsigned long long);
19437 vector unsigned long long __builtin_crypto_vncipherlast
19438                                      (vector unsigned long long,
19439                                       vector unsigned long long);
19441 vector unsigned char __builtin_crypto_vpermxor (vector unsigned char,
19442                                                 vector unsigned char,
19443                                                 vector unsigned char);
19445 vector unsigned short __builtin_crypto_vpermxor (vector unsigned short,
19446                                                  vector unsigned short,
19447                                                  vector unsigned short);
19449 vector unsigned int __builtin_crypto_vpermxor (vector unsigned int,
19450                                                vector unsigned int,
19451                                                vector unsigned int);
19453 vector unsigned long long __builtin_crypto_vpermxor (vector unsigned long long,
19454                                                      vector unsigned long long,
19455                                                      vector unsigned long long);
19457 vector unsigned char __builtin_crypto_vpmsumb (vector unsigned char,
19458                                                vector unsigned char);
19460 vector unsigned short __builtin_crypto_vpmsumb (vector unsigned short,
19461                                                 vector unsigned short);
19463 vector unsigned int __builtin_crypto_vpmsumb (vector unsigned int,
19464                                               vector unsigned int);
19466 vector unsigned long long __builtin_crypto_vpmsumb (vector unsigned long long,
19467                                                     vector unsigned long long);
19469 vector unsigned long long __builtin_crypto_vshasigmad
19470                                (vector unsigned long long, int, int);
19472 vector unsigned int __builtin_crypto_vshasigmaw (vector unsigned int,
19473                                                  int, int);
19474 @end smallexample
19476 The second argument to @var{__builtin_crypto_vshasigmad} and
19477 @var{__builtin_crypto_vshasigmaw} must be a constant
19478 integer that is 0 or 1.  The third argument to these built-in functions
19479 must be a constant integer in the range of 0 to 15.
19481 If the ISA 3.0 instruction set additions 
19482 are enabled (@option{-mcpu=power9}), the following additional
19483 functions are available for both 32-bit and 64-bit targets.
19485 vector short vec_xl (int, vector short *);
19486 vector short vec_xl (int, short *);
19487 vector unsigned short vec_xl (int, vector unsigned short *);
19488 vector unsigned short vec_xl (int, unsigned short *);
19489 vector char vec_xl (int, vector char *);
19490 vector char vec_xl (int, char *);
19491 vector unsigned char vec_xl (int, vector unsigned char *);
19492 vector unsigned char vec_xl (int, unsigned char *);
19494 void vec_xst (vector short, int, vector short *);
19495 void vec_xst (vector short, int, short *);
19496 void vec_xst (vector unsigned short, int, vector unsigned short *);
19497 void vec_xst (vector unsigned short, int, unsigned short *);
19498 void vec_xst (vector char, int, vector char *);
19499 void vec_xst (vector char, int, char *);
19500 void vec_xst (vector unsigned char, int, vector unsigned char *);
19501 void vec_xst (vector unsigned char, int, unsigned char *);
19503 @node PowerPC Hardware Transactional Memory Built-in Functions
19504 @subsection PowerPC Hardware Transactional Memory Built-in Functions
19505 GCC provides two interfaces for accessing the Hardware Transactional
19506 Memory (HTM) instructions available on some of the PowerPC family
19507 of processors (eg, POWER8).  The two interfaces come in a low level
19508 interface, consisting of built-in functions specific to PowerPC and a
19509 higher level interface consisting of inline functions that are common
19510 between PowerPC and S/390.
19512 @subsubsection PowerPC HTM Low Level Built-in Functions
19514 The following low level built-in functions are available with
19515 @option{-mhtm} or @option{-mcpu=CPU} where CPU is `power8' or later.
19516 They all generate the machine instruction that is part of the name.
19518 The HTM builtins (with the exception of @code{__builtin_tbegin}) return
19519 the full 4-bit condition register value set by their associated hardware
19520 instruction.  The header file @code{htmintrin.h} defines some macros that can
19521 be used to decipher the return value.  The @code{__builtin_tbegin} builtin
19522 returns a simple true or false value depending on whether a transaction was
19523 successfully started or not.  The arguments of the builtins match exactly the
19524 type and order of the associated hardware instruction's operands, except for
19525 the @code{__builtin_tcheck} builtin, which does not take any input arguments.
19526 Refer to the ISA manual for a description of each instruction's operands.
19528 @smallexample
19529 unsigned int __builtin_tbegin (unsigned int)
19530 unsigned int __builtin_tend (unsigned int)
19532 unsigned int __builtin_tabort (unsigned int)
19533 unsigned int __builtin_tabortdc (unsigned int, unsigned int, unsigned int)
19534 unsigned int __builtin_tabortdci (unsigned int, unsigned int, int)
19535 unsigned int __builtin_tabortwc (unsigned int, unsigned int, unsigned int)
19536 unsigned int __builtin_tabortwci (unsigned int, unsigned int, int)
19538 unsigned int __builtin_tcheck (void)
19539 unsigned int __builtin_treclaim (unsigned int)
19540 unsigned int __builtin_trechkpt (void)
19541 unsigned int __builtin_tsr (unsigned int)
19542 @end smallexample
19544 In addition to the above HTM built-ins, we have added built-ins for
19545 some common extended mnemonics of the HTM instructions:
19547 @smallexample
19548 unsigned int __builtin_tendall (void)
19549 unsigned int __builtin_tresume (void)
19550 unsigned int __builtin_tsuspend (void)
19551 @end smallexample
19553 Note that the semantics of the above HTM builtins are required to mimic
19554 the locking semantics used for critical sections.  Builtins that are used
19555 to create a new transaction or restart a suspended transaction must have
19556 lock acquisition like semantics while those builtins that end or suspend a
19557 transaction must have lock release like semantics.  Specifically, this must
19558 mimic lock semantics as specified by C++11, for example: Lock acquisition is
19559 as-if an execution of __atomic_exchange_n(&globallock,1,__ATOMIC_ACQUIRE)
19560 that returns 0, and lock release is as-if an execution of
19561 __atomic_store(&globallock,0,__ATOMIC_RELEASE), with globallock being an
19562 implicit implementation-defined lock used for all transactions.  The HTM
19563 instructions associated with with the builtins inherently provide the
19564 correct acquisition and release hardware barriers required.  However,
19565 the compiler must also be prohibited from moving loads and stores across
19566 the builtins in a way that would violate their semantics.  This has been
19567 accomplished by adding memory barriers to the associated HTM instructions
19568 (which is a conservative approach to provide acquire and release semantics).
19569 Earlier versions of the compiler did not treat the HTM instructions as
19570 memory barriers.  A @code{__TM_FENCE__} macro has been added, which can
19571 be used to determine whether the current compiler treats HTM instructions
19572 as memory barriers or not.  This allows the user to explicitly add memory
19573 barriers to their code when using an older version of the compiler.
19575 The following set of built-in functions are available to gain access
19576 to the HTM specific special purpose registers.
19578 @smallexample
19579 unsigned long __builtin_get_texasr (void)
19580 unsigned long __builtin_get_texasru (void)
19581 unsigned long __builtin_get_tfhar (void)
19582 unsigned long __builtin_get_tfiar (void)
19584 void __builtin_set_texasr (unsigned long);
19585 void __builtin_set_texasru (unsigned long);
19586 void __builtin_set_tfhar (unsigned long);
19587 void __builtin_set_tfiar (unsigned long);
19588 @end smallexample
19590 Example usage of these low level built-in functions may look like:
19592 @smallexample
19593 #include <htmintrin.h>
19595 int num_retries = 10;
19597 while (1)
19598   @{
19599     if (__builtin_tbegin (0))
19600       @{
19601         /* Transaction State Initiated.  */
19602         if (is_locked (lock))
19603           __builtin_tabort (0);
19604         ... transaction code...
19605         __builtin_tend (0);
19606         break;
19607       @}
19608     else
19609       @{
19610         /* Transaction State Failed.  Use locks if the transaction
19611            failure is "persistent" or we've tried too many times.  */
19612         if (num_retries-- <= 0
19613             || _TEXASRU_FAILURE_PERSISTENT (__builtin_get_texasru ()))
19614           @{
19615             acquire_lock (lock);
19616             ... non transactional fallback path...
19617             release_lock (lock);
19618             break;
19619           @}
19620       @}
19621   @}
19622 @end smallexample
19624 One final built-in function has been added that returns the value of
19625 the 2-bit Transaction State field of the Machine Status Register (MSR)
19626 as stored in @code{CR0}.
19628 @smallexample
19629 unsigned long __builtin_ttest (void)
19630 @end smallexample
19632 This built-in can be used to determine the current transaction state
19633 using the following code example:
19635 @smallexample
19636 #include <htmintrin.h>
19638 unsigned char tx_state = _HTM_STATE (__builtin_ttest ());
19640 if (tx_state == _HTM_TRANSACTIONAL)
19641   @{
19642     /* Code to use in transactional state.  */
19643   @}
19644 else if (tx_state == _HTM_NONTRANSACTIONAL)
19645   @{
19646     /* Code to use in non-transactional state.  */
19647   @}
19648 else if (tx_state == _HTM_SUSPENDED)
19649   @{
19650     /* Code to use in transaction suspended state.  */
19651   @}
19652 @end smallexample
19654 @subsubsection PowerPC HTM High Level Inline Functions
19656 The following high level HTM interface is made available by including
19657 @code{<htmxlintrin.h>} and using @option{-mhtm} or @option{-mcpu=CPU}
19658 where CPU is `power8' or later.  This interface is common between PowerPC
19659 and S/390, allowing users to write one HTM source implementation that
19660 can be compiled and executed on either system.
19662 @smallexample
19663 long __TM_simple_begin (void)
19664 long __TM_begin (void* const TM_buff)
19665 long __TM_end (void)
19666 void __TM_abort (void)
19667 void __TM_named_abort (unsigned char const code)
19668 void __TM_resume (void)
19669 void __TM_suspend (void)
19671 long __TM_is_user_abort (void* const TM_buff)
19672 long __TM_is_named_user_abort (void* const TM_buff, unsigned char *code)
19673 long __TM_is_illegal (void* const TM_buff)
19674 long __TM_is_footprint_exceeded (void* const TM_buff)
19675 long __TM_nesting_depth (void* const TM_buff)
19676 long __TM_is_nested_too_deep(void* const TM_buff)
19677 long __TM_is_conflict(void* const TM_buff)
19678 long __TM_is_failure_persistent(void* const TM_buff)
19679 long __TM_failure_address(void* const TM_buff)
19680 long long __TM_failure_code(void* const TM_buff)
19681 @end smallexample
19683 Using these common set of HTM inline functions, we can create
19684 a more portable version of the HTM example in the previous
19685 section that will work on either PowerPC or S/390:
19687 @smallexample
19688 #include <htmxlintrin.h>
19690 int num_retries = 10;
19691 TM_buff_type TM_buff;
19693 while (1)
19694   @{
19695     if (__TM_begin (TM_buff) == _HTM_TBEGIN_STARTED)
19696       @{
19697         /* Transaction State Initiated.  */
19698         if (is_locked (lock))
19699           __TM_abort ();
19700         ... transaction code...
19701         __TM_end ();
19702         break;
19703       @}
19704     else
19705       @{
19706         /* Transaction State Failed.  Use locks if the transaction
19707            failure is "persistent" or we've tried too many times.  */
19708         if (num_retries-- <= 0
19709             || __TM_is_failure_persistent (TM_buff))
19710           @{
19711             acquire_lock (lock);
19712             ... non transactional fallback path...
19713             release_lock (lock);
19714             break;
19715           @}
19716       @}
19717   @}
19718 @end smallexample
19720 @node PowerPC Atomic Memory Operation Functions
19721 @subsection PowerPC Atomic Memory Operation Functions
19722 ISA 3.0 of the PowerPC added new atomic memory operation (amo)
19723 instructions.  GCC provides support for these instructions in 64-bit
19724 environments.  All of the functions are declared in the include file
19725 @code{amo.h}.
19727 The functions supported are:
19729 @smallexample
19730 #include <amo.h>
19732 uint32_t amo_lwat_add (uint32_t *, uint32_t);
19733 uint32_t amo_lwat_xor (uint32_t *, uint32_t);
19734 uint32_t amo_lwat_ior (uint32_t *, uint32_t);
19735 uint32_t amo_lwat_and (uint32_t *, uint32_t);
19736 uint32_t amo_lwat_umax (uint32_t *, uint32_t);
19737 uint32_t amo_lwat_umin (uint32_t *, uint32_t);
19738 uint32_t amo_lwat_swap (uint32_t *, uint32_t);
19740 int32_t amo_lwat_sadd (int32_t *, int32_t);
19741 int32_t amo_lwat_smax (int32_t *, int32_t);
19742 int32_t amo_lwat_smin (int32_t *, int32_t);
19743 int32_t amo_lwat_sswap (int32_t *, int32_t);
19745 uint64_t amo_ldat_add (uint64_t *, uint64_t);
19746 uint64_t amo_ldat_xor (uint64_t *, uint64_t);
19747 uint64_t amo_ldat_ior (uint64_t *, uint64_t);
19748 uint64_t amo_ldat_and (uint64_t *, uint64_t);
19749 uint64_t amo_ldat_umax (uint64_t *, uint64_t);
19750 uint64_t amo_ldat_umin (uint64_t *, uint64_t);
19751 uint64_t amo_ldat_swap (uint64_t *, uint64_t);
19753 int64_t amo_ldat_sadd (int64_t *, int64_t);
19754 int64_t amo_ldat_smax (int64_t *, int64_t);
19755 int64_t amo_ldat_smin (int64_t *, int64_t);
19756 int64_t amo_ldat_sswap (int64_t *, int64_t);
19758 void amo_stwat_add (uint32_t *, uint32_t);
19759 void amo_stwat_xor (uint32_t *, uint32_t);
19760 void amo_stwat_ior (uint32_t *, uint32_t);
19761 void amo_stwat_and (uint32_t *, uint32_t);
19762 void amo_stwat_umax (uint32_t *, uint32_t);
19763 void amo_stwat_umin (uint32_t *, uint32_t);
19765 void amo_stwat_sadd (int32_t *, int32_t);
19766 void amo_stwat_smax (int32_t *, int32_t);
19767 void amo_stwat_smin (int32_t *, int32_t);
19769 void amo_stdat_add (uint64_t *, uint64_t);
19770 void amo_stdat_xor (uint64_t *, uint64_t);
19771 void amo_stdat_ior (uint64_t *, uint64_t);
19772 void amo_stdat_and (uint64_t *, uint64_t);
19773 void amo_stdat_umax (uint64_t *, uint64_t);
19774 void amo_stdat_umin (uint64_t *, uint64_t);
19776 void amo_stdat_sadd (int64_t *, int64_t);
19777 void amo_stdat_smax (int64_t *, int64_t);
19778 void amo_stdat_smin (int64_t *, int64_t);
19779 @end smallexample
19781 @node RX Built-in Functions
19782 @subsection RX Built-in Functions
19783 GCC supports some of the RX instructions which cannot be expressed in
19784 the C programming language via the use of built-in functions.  The
19785 following functions are supported:
19787 @deftypefn {Built-in Function}  void __builtin_rx_brk (void)
19788 Generates the @code{brk} machine instruction.
19789 @end deftypefn
19791 @deftypefn {Built-in Function}  void __builtin_rx_clrpsw (int)
19792 Generates the @code{clrpsw} machine instruction to clear the specified
19793 bit in the processor status word.
19794 @end deftypefn
19796 @deftypefn {Built-in Function}  void __builtin_rx_int (int)
19797 Generates the @code{int} machine instruction to generate an interrupt
19798 with the specified value.
19799 @end deftypefn
19801 @deftypefn {Built-in Function}  void __builtin_rx_machi (int, int)
19802 Generates the @code{machi} machine instruction to add the result of
19803 multiplying the top 16 bits of the two arguments into the
19804 accumulator.
19805 @end deftypefn
19807 @deftypefn {Built-in Function}  void __builtin_rx_maclo (int, int)
19808 Generates the @code{maclo} machine instruction to add the result of
19809 multiplying the bottom 16 bits of the two arguments into the
19810 accumulator.
19811 @end deftypefn
19813 @deftypefn {Built-in Function}  void __builtin_rx_mulhi (int, int)
19814 Generates the @code{mulhi} machine instruction to place the result of
19815 multiplying the top 16 bits of the two arguments into the
19816 accumulator.
19817 @end deftypefn
19819 @deftypefn {Built-in Function}  void __builtin_rx_mullo (int, int)
19820 Generates the @code{mullo} machine instruction to place the result of
19821 multiplying the bottom 16 bits of the two arguments into the
19822 accumulator.
19823 @end deftypefn
19825 @deftypefn {Built-in Function}  int  __builtin_rx_mvfachi (void)
19826 Generates the @code{mvfachi} machine instruction to read the top
19827 32 bits of the accumulator.
19828 @end deftypefn
19830 @deftypefn {Built-in Function}  int  __builtin_rx_mvfacmi (void)
19831 Generates the @code{mvfacmi} machine instruction to read the middle
19832 32 bits of the accumulator.
19833 @end deftypefn
19835 @deftypefn {Built-in Function}  int __builtin_rx_mvfc (int)
19836 Generates the @code{mvfc} machine instruction which reads the control
19837 register specified in its argument and returns its value.
19838 @end deftypefn
19840 @deftypefn {Built-in Function}  void __builtin_rx_mvtachi (int)
19841 Generates the @code{mvtachi} machine instruction to set the top
19842 32 bits of the accumulator.
19843 @end deftypefn
19845 @deftypefn {Built-in Function}  void __builtin_rx_mvtaclo (int)
19846 Generates the @code{mvtaclo} machine instruction to set the bottom
19847 32 bits of the accumulator.
19848 @end deftypefn
19850 @deftypefn {Built-in Function}  void __builtin_rx_mvtc (int reg, int val)
19851 Generates the @code{mvtc} machine instruction which sets control
19852 register number @code{reg} to @code{val}.
19853 @end deftypefn
19855 @deftypefn {Built-in Function}  void __builtin_rx_mvtipl (int)
19856 Generates the @code{mvtipl} machine instruction set the interrupt
19857 priority level.
19858 @end deftypefn
19860 @deftypefn {Built-in Function}  void __builtin_rx_racw (int)
19861 Generates the @code{racw} machine instruction to round the accumulator
19862 according to the specified mode.
19863 @end deftypefn
19865 @deftypefn {Built-in Function}  int __builtin_rx_revw (int)
19866 Generates the @code{revw} machine instruction which swaps the bytes in
19867 the argument so that bits 0--7 now occupy bits 8--15 and vice versa,
19868 and also bits 16--23 occupy bits 24--31 and vice versa.
19869 @end deftypefn
19871 @deftypefn {Built-in Function}  void __builtin_rx_rmpa (void)
19872 Generates the @code{rmpa} machine instruction which initiates a
19873 repeated multiply and accumulate sequence.
19874 @end deftypefn
19876 @deftypefn {Built-in Function}  void __builtin_rx_round (float)
19877 Generates the @code{round} machine instruction which returns the
19878 floating-point argument rounded according to the current rounding mode
19879 set in the floating-point status word register.
19880 @end deftypefn
19882 @deftypefn {Built-in Function}  int __builtin_rx_sat (int)
19883 Generates the @code{sat} machine instruction which returns the
19884 saturated value of the argument.
19885 @end deftypefn
19887 @deftypefn {Built-in Function}  void __builtin_rx_setpsw (int)
19888 Generates the @code{setpsw} machine instruction to set the specified
19889 bit in the processor status word.
19890 @end deftypefn
19892 @deftypefn {Built-in Function}  void __builtin_rx_wait (void)
19893 Generates the @code{wait} machine instruction.
19894 @end deftypefn
19896 @node S/390 System z Built-in Functions
19897 @subsection S/390 System z Built-in Functions
19898 @deftypefn {Built-in Function} int __builtin_tbegin (void*)
19899 Generates the @code{tbegin} machine instruction starting a
19900 non-constrained hardware transaction.  If the parameter is non-NULL the
19901 memory area is used to store the transaction diagnostic buffer and
19902 will be passed as first operand to @code{tbegin}.  This buffer can be
19903 defined using the @code{struct __htm_tdb} C struct defined in
19904 @code{htmintrin.h} and must reside on a double-word boundary.  The
19905 second tbegin operand is set to @code{0xff0c}. This enables
19906 save/restore of all GPRs and disables aborts for FPR and AR
19907 manipulations inside the transaction body.  The condition code set by
19908 the tbegin instruction is returned as integer value.  The tbegin
19909 instruction by definition overwrites the content of all FPRs.  The
19910 compiler will generate code which saves and restores the FPRs.  For
19911 soft-float code it is recommended to used the @code{*_nofloat}
19912 variant.  In order to prevent a TDB from being written it is required
19913 to pass a constant zero value as parameter.  Passing a zero value
19914 through a variable is not sufficient.  Although modifications of
19915 access registers inside the transaction will not trigger an
19916 transaction abort it is not supported to actually modify them.  Access
19917 registers do not get saved when entering a transaction. They will have
19918 undefined state when reaching the abort code.
19919 @end deftypefn
19921 Macros for the possible return codes of tbegin are defined in the
19922 @code{htmintrin.h} header file:
19924 @table @code
19925 @item _HTM_TBEGIN_STARTED
19926 @code{tbegin} has been executed as part of normal processing.  The
19927 transaction body is supposed to be executed.
19928 @item _HTM_TBEGIN_INDETERMINATE
19929 The transaction was aborted due to an indeterminate condition which
19930 might be persistent.
19931 @item _HTM_TBEGIN_TRANSIENT
19932 The transaction aborted due to a transient failure.  The transaction
19933 should be re-executed in that case.
19934 @item _HTM_TBEGIN_PERSISTENT
19935 The transaction aborted due to a persistent failure.  Re-execution
19936 under same circumstances will not be productive.
19937 @end table
19939 @defmac _HTM_FIRST_USER_ABORT_CODE
19940 The @code{_HTM_FIRST_USER_ABORT_CODE} defined in @code{htmintrin.h}
19941 specifies the first abort code which can be used for
19942 @code{__builtin_tabort}.  Values below this threshold are reserved for
19943 machine use.
19944 @end defmac
19946 @deftp {Data type} {struct __htm_tdb}
19947 The @code{struct __htm_tdb} defined in @code{htmintrin.h} describes
19948 the structure of the transaction diagnostic block as specified in the
19949 Principles of Operation manual chapter 5-91.
19950 @end deftp
19952 @deftypefn {Built-in Function} int __builtin_tbegin_nofloat (void*)
19953 Same as @code{__builtin_tbegin} but without FPR saves and restores.
19954 Using this variant in code making use of FPRs will leave the FPRs in
19955 undefined state when entering the transaction abort handler code.
19956 @end deftypefn
19958 @deftypefn {Built-in Function} int __builtin_tbegin_retry (void*, int)
19959 In addition to @code{__builtin_tbegin} a loop for transient failures
19960 is generated.  If tbegin returns a condition code of 2 the transaction
19961 will be retried as often as specified in the second argument.  The
19962 perform processor assist instruction is used to tell the CPU about the
19963 number of fails so far.
19964 @end deftypefn
19966 @deftypefn {Built-in Function} int __builtin_tbegin_retry_nofloat (void*, int)
19967 Same as @code{__builtin_tbegin_retry} but without FPR saves and
19968 restores.  Using this variant in code making use of FPRs will leave
19969 the FPRs in undefined state when entering the transaction abort
19970 handler code.
19971 @end deftypefn
19973 @deftypefn {Built-in Function} void __builtin_tbeginc (void)
19974 Generates the @code{tbeginc} machine instruction starting a constrained
19975 hardware transaction.  The second operand is set to @code{0xff08}.
19976 @end deftypefn
19978 @deftypefn {Built-in Function} int __builtin_tend (void)
19979 Generates the @code{tend} machine instruction finishing a transaction
19980 and making the changes visible to other threads.  The condition code
19981 generated by tend is returned as integer value.
19982 @end deftypefn
19984 @deftypefn {Built-in Function} void __builtin_tabort (int)
19985 Generates the @code{tabort} machine instruction with the specified
19986 abort code.  Abort codes from 0 through 255 are reserved and will
19987 result in an error message.
19988 @end deftypefn
19990 @deftypefn {Built-in Function} void __builtin_tx_assist (int)
19991 Generates the @code{ppa rX,rY,1} machine instruction.  Where the
19992 integer parameter is loaded into rX and a value of zero is loaded into
19993 rY.  The integer parameter specifies the number of times the
19994 transaction repeatedly aborted.
19995 @end deftypefn
19997 @deftypefn {Built-in Function} int __builtin_tx_nesting_depth (void)
19998 Generates the @code{etnd} machine instruction.  The current nesting
19999 depth is returned as integer value.  For a nesting depth of 0 the code
20000 is not executed as part of an transaction.
20001 @end deftypefn
20003 @deftypefn {Built-in Function} void __builtin_non_tx_store (uint64_t *, uint64_t)
20005 Generates the @code{ntstg} machine instruction.  The second argument
20006 is written to the first arguments location.  The store operation will
20007 not be rolled-back in case of an transaction abort.
20008 @end deftypefn
20010 @node SH Built-in Functions
20011 @subsection SH Built-in Functions
20012 The following built-in functions are supported on the SH1, SH2, SH3 and SH4
20013 families of processors:
20015 @deftypefn {Built-in Function} {void} __builtin_set_thread_pointer (void *@var{ptr})
20016 Sets the @samp{GBR} register to the specified value @var{ptr}.  This is usually
20017 used by system code that manages threads and execution contexts.  The compiler
20018 normally does not generate code that modifies the contents of @samp{GBR} and
20019 thus the value is preserved across function calls.  Changing the @samp{GBR}
20020 value in user code must be done with caution, since the compiler might use
20021 @samp{GBR} in order to access thread local variables.
20023 @end deftypefn
20025 @deftypefn {Built-in Function} {void *} __builtin_thread_pointer (void)
20026 Returns the value that is currently set in the @samp{GBR} register.
20027 Memory loads and stores that use the thread pointer as a base address are
20028 turned into @samp{GBR} based displacement loads and stores, if possible.
20029 For example:
20030 @smallexample
20031 struct my_tcb
20033    int a, b, c, d, e;
20036 int get_tcb_value (void)
20038   // Generate @samp{mov.l @@(8,gbr),r0} instruction
20039   return ((my_tcb*)__builtin_thread_pointer ())->c;
20042 @end smallexample
20043 @end deftypefn
20045 @deftypefn {Built-in Function} {unsigned int} __builtin_sh_get_fpscr (void)
20046 Returns the value that is currently set in the @samp{FPSCR} register.
20047 @end deftypefn
20049 @deftypefn {Built-in Function} {void} __builtin_sh_set_fpscr (unsigned int @var{val})
20050 Sets the @samp{FPSCR} register to the specified value @var{val}, while
20051 preserving the current values of the FR, SZ and PR bits.
20052 @end deftypefn
20054 @node SPARC VIS Built-in Functions
20055 @subsection SPARC VIS Built-in Functions
20057 GCC supports SIMD operations on the SPARC using both the generic vector
20058 extensions (@pxref{Vector Extensions}) as well as built-in functions for
20059 the SPARC Visual Instruction Set (VIS).  When you use the @option{-mvis}
20060 switch, the VIS extension is exposed as the following built-in functions:
20062 @smallexample
20063 typedef int v1si __attribute__ ((vector_size (4)));
20064 typedef int v2si __attribute__ ((vector_size (8)));
20065 typedef short v4hi __attribute__ ((vector_size (8)));
20066 typedef short v2hi __attribute__ ((vector_size (4)));
20067 typedef unsigned char v8qi __attribute__ ((vector_size (8)));
20068 typedef unsigned char v4qi __attribute__ ((vector_size (4)));
20070 void __builtin_vis_write_gsr (int64_t);
20071 int64_t __builtin_vis_read_gsr (void);
20073 void * __builtin_vis_alignaddr (void *, long);
20074 void * __builtin_vis_alignaddrl (void *, long);
20075 int64_t __builtin_vis_faligndatadi (int64_t, int64_t);
20076 v2si __builtin_vis_faligndatav2si (v2si, v2si);
20077 v4hi __builtin_vis_faligndatav4hi (v4si, v4si);
20078 v8qi __builtin_vis_faligndatav8qi (v8qi, v8qi);
20080 v4hi __builtin_vis_fexpand (v4qi);
20082 v4hi __builtin_vis_fmul8x16 (v4qi, v4hi);
20083 v4hi __builtin_vis_fmul8x16au (v4qi, v2hi);
20084 v4hi __builtin_vis_fmul8x16al (v4qi, v2hi);
20085 v4hi __builtin_vis_fmul8sux16 (v8qi, v4hi);
20086 v4hi __builtin_vis_fmul8ulx16 (v8qi, v4hi);
20087 v2si __builtin_vis_fmuld8sux16 (v4qi, v2hi);
20088 v2si __builtin_vis_fmuld8ulx16 (v4qi, v2hi);
20090 v4qi __builtin_vis_fpack16 (v4hi);
20091 v8qi __builtin_vis_fpack32 (v2si, v8qi);
20092 v2hi __builtin_vis_fpackfix (v2si);
20093 v8qi __builtin_vis_fpmerge (v4qi, v4qi);
20095 int64_t __builtin_vis_pdist (v8qi, v8qi, int64_t);
20097 long __builtin_vis_edge8 (void *, void *);
20098 long __builtin_vis_edge8l (void *, void *);
20099 long __builtin_vis_edge16 (void *, void *);
20100 long __builtin_vis_edge16l (void *, void *);
20101 long __builtin_vis_edge32 (void *, void *);
20102 long __builtin_vis_edge32l (void *, void *);
20104 long __builtin_vis_fcmple16 (v4hi, v4hi);
20105 long __builtin_vis_fcmple32 (v2si, v2si);
20106 long __builtin_vis_fcmpne16 (v4hi, v4hi);
20107 long __builtin_vis_fcmpne32 (v2si, v2si);
20108 long __builtin_vis_fcmpgt16 (v4hi, v4hi);
20109 long __builtin_vis_fcmpgt32 (v2si, v2si);
20110 long __builtin_vis_fcmpeq16 (v4hi, v4hi);
20111 long __builtin_vis_fcmpeq32 (v2si, v2si);
20113 v4hi __builtin_vis_fpadd16 (v4hi, v4hi);
20114 v2hi __builtin_vis_fpadd16s (v2hi, v2hi);
20115 v2si __builtin_vis_fpadd32 (v2si, v2si);
20116 v1si __builtin_vis_fpadd32s (v1si, v1si);
20117 v4hi __builtin_vis_fpsub16 (v4hi, v4hi);
20118 v2hi __builtin_vis_fpsub16s (v2hi, v2hi);
20119 v2si __builtin_vis_fpsub32 (v2si, v2si);
20120 v1si __builtin_vis_fpsub32s (v1si, v1si);
20122 long __builtin_vis_array8 (long, long);
20123 long __builtin_vis_array16 (long, long);
20124 long __builtin_vis_array32 (long, long);
20125 @end smallexample
20127 When you use the @option{-mvis2} switch, the VIS version 2.0 built-in
20128 functions also become available:
20130 @smallexample
20131 long __builtin_vis_bmask (long, long);
20132 int64_t __builtin_vis_bshuffledi (int64_t, int64_t);
20133 v2si __builtin_vis_bshufflev2si (v2si, v2si);
20134 v4hi __builtin_vis_bshufflev2si (v4hi, v4hi);
20135 v8qi __builtin_vis_bshufflev2si (v8qi, v8qi);
20137 long __builtin_vis_edge8n (void *, void *);
20138 long __builtin_vis_edge8ln (void *, void *);
20139 long __builtin_vis_edge16n (void *, void *);
20140 long __builtin_vis_edge16ln (void *, void *);
20141 long __builtin_vis_edge32n (void *, void *);
20142 long __builtin_vis_edge32ln (void *, void *);
20143 @end smallexample
20145 When you use the @option{-mvis3} switch, the VIS version 3.0 built-in
20146 functions also become available:
20148 @smallexample
20149 void __builtin_vis_cmask8 (long);
20150 void __builtin_vis_cmask16 (long);
20151 void __builtin_vis_cmask32 (long);
20153 v4hi __builtin_vis_fchksm16 (v4hi, v4hi);
20155 v4hi __builtin_vis_fsll16 (v4hi, v4hi);
20156 v4hi __builtin_vis_fslas16 (v4hi, v4hi);
20157 v4hi __builtin_vis_fsrl16 (v4hi, v4hi);
20158 v4hi __builtin_vis_fsra16 (v4hi, v4hi);
20159 v2si __builtin_vis_fsll16 (v2si, v2si);
20160 v2si __builtin_vis_fslas16 (v2si, v2si);
20161 v2si __builtin_vis_fsrl16 (v2si, v2si);
20162 v2si __builtin_vis_fsra16 (v2si, v2si);
20164 long __builtin_vis_pdistn (v8qi, v8qi);
20166 v4hi __builtin_vis_fmean16 (v4hi, v4hi);
20168 int64_t __builtin_vis_fpadd64 (int64_t, int64_t);
20169 int64_t __builtin_vis_fpsub64 (int64_t, int64_t);
20171 v4hi __builtin_vis_fpadds16 (v4hi, v4hi);
20172 v2hi __builtin_vis_fpadds16s (v2hi, v2hi);
20173 v4hi __builtin_vis_fpsubs16 (v4hi, v4hi);
20174 v2hi __builtin_vis_fpsubs16s (v2hi, v2hi);
20175 v2si __builtin_vis_fpadds32 (v2si, v2si);
20176 v1si __builtin_vis_fpadds32s (v1si, v1si);
20177 v2si __builtin_vis_fpsubs32 (v2si, v2si);
20178 v1si __builtin_vis_fpsubs32s (v1si, v1si);
20180 long __builtin_vis_fucmple8 (v8qi, v8qi);
20181 long __builtin_vis_fucmpne8 (v8qi, v8qi);
20182 long __builtin_vis_fucmpgt8 (v8qi, v8qi);
20183 long __builtin_vis_fucmpeq8 (v8qi, v8qi);
20185 float __builtin_vis_fhadds (float, float);
20186 double __builtin_vis_fhaddd (double, double);
20187 float __builtin_vis_fhsubs (float, float);
20188 double __builtin_vis_fhsubd (double, double);
20189 float __builtin_vis_fnhadds (float, float);
20190 double __builtin_vis_fnhaddd (double, double);
20192 int64_t __builtin_vis_umulxhi (int64_t, int64_t);
20193 int64_t __builtin_vis_xmulx (int64_t, int64_t);
20194 int64_t __builtin_vis_xmulxhi (int64_t, int64_t);
20195 @end smallexample
20197 When you use the @option{-mvis4} switch, the VIS version 4.0 built-in
20198 functions also become available:
20200 @smallexample
20201 v8qi __builtin_vis_fpadd8 (v8qi, v8qi);
20202 v8qi __builtin_vis_fpadds8 (v8qi, v8qi);
20203 v8qi __builtin_vis_fpaddus8 (v8qi, v8qi);
20204 v4hi __builtin_vis_fpaddus16 (v4hi, v4hi);
20206 v8qi __builtin_vis_fpsub8 (v8qi, v8qi);
20207 v8qi __builtin_vis_fpsubs8 (v8qi, v8qi);
20208 v8qi __builtin_vis_fpsubus8 (v8qi, v8qi);
20209 v4hi __builtin_vis_fpsubus16 (v4hi, v4hi);
20211 long __builtin_vis_fpcmple8 (v8qi, v8qi);
20212 long __builtin_vis_fpcmpgt8 (v8qi, v8qi);
20213 long __builtin_vis_fpcmpule16 (v4hi, v4hi);
20214 long __builtin_vis_fpcmpugt16 (v4hi, v4hi);
20215 long __builtin_vis_fpcmpule32 (v2si, v2si);
20216 long __builtin_vis_fpcmpugt32 (v2si, v2si);
20218 v8qi __builtin_vis_fpmax8 (v8qi, v8qi);
20219 v4hi __builtin_vis_fpmax16 (v4hi, v4hi);
20220 v2si __builtin_vis_fpmax32 (v2si, v2si);
20222 v8qi __builtin_vis_fpmaxu8 (v8qi, v8qi);
20223 v4hi __builtin_vis_fpmaxu16 (v4hi, v4hi);
20224 v2si __builtin_vis_fpmaxu32 (v2si, v2si);
20227 v8qi __builtin_vis_fpmin8 (v8qi, v8qi);
20228 v4hi __builtin_vis_fpmin16 (v4hi, v4hi);
20229 v2si __builtin_vis_fpmin32 (v2si, v2si);
20231 v8qi __builtin_vis_fpminu8 (v8qi, v8qi);
20232 v4hi __builtin_vis_fpminu16 (v4hi, v4hi);
20233 v2si __builtin_vis_fpminu32 (v2si, v2si);
20234 @end smallexample
20236 When you use the @option{-mvis4b} switch, the VIS version 4.0B
20237 built-in functions also become available:
20239 @smallexample
20240 v8qi __builtin_vis_dictunpack8 (double, int);
20241 v4hi __builtin_vis_dictunpack16 (double, int);
20242 v2si __builtin_vis_dictunpack32 (double, int);
20244 long __builtin_vis_fpcmple8shl (v8qi, v8qi, int);
20245 long __builtin_vis_fpcmpgt8shl (v8qi, v8qi, int);
20246 long __builtin_vis_fpcmpeq8shl (v8qi, v8qi, int);
20247 long __builtin_vis_fpcmpne8shl (v8qi, v8qi, int);
20249 long __builtin_vis_fpcmple16shl (v4hi, v4hi, int);
20250 long __builtin_vis_fpcmpgt16shl (v4hi, v4hi, int);
20251 long __builtin_vis_fpcmpeq16shl (v4hi, v4hi, int);
20252 long __builtin_vis_fpcmpne16shl (v4hi, v4hi, int);
20254 long __builtin_vis_fpcmple32shl (v2si, v2si, int);
20255 long __builtin_vis_fpcmpgt32shl (v2si, v2si, int);
20256 long __builtin_vis_fpcmpeq32shl (v2si, v2si, int);
20257 long __builtin_vis_fpcmpne32shl (v2si, v2si, int);
20259 long __builtin_vis_fpcmpule8shl (v8qi, v8qi, int);
20260 long __builtin_vis_fpcmpugt8shl (v8qi, v8qi, int);
20261 long __builtin_vis_fpcmpule16shl (v4hi, v4hi, int);
20262 long __builtin_vis_fpcmpugt16shl (v4hi, v4hi, int);
20263 long __builtin_vis_fpcmpule32shl (v2si, v2si, int);
20264 long __builtin_vis_fpcmpugt32shl (v2si, v2si, int);
20266 long __builtin_vis_fpcmpde8shl (v8qi, v8qi, int);
20267 long __builtin_vis_fpcmpde16shl (v4hi, v4hi, int);
20268 long __builtin_vis_fpcmpde32shl (v2si, v2si, int);
20270 long __builtin_vis_fpcmpur8shl (v8qi, v8qi, int);
20271 long __builtin_vis_fpcmpur16shl (v4hi, v4hi, int);
20272 long __builtin_vis_fpcmpur32shl (v2si, v2si, int);
20273 @end smallexample
20275 @node SPU Built-in Functions
20276 @subsection SPU Built-in Functions
20278 GCC provides extensions for the SPU processor as described in the
20279 Sony/Toshiba/IBM SPU Language Extensions Specification.  GCC's
20280 implementation differs in several ways.
20282 @itemize @bullet
20284 @item
20285 The optional extension of specifying vector constants in parentheses is
20286 not supported.
20288 @item
20289 A vector initializer requires no cast if the vector constant is of the
20290 same type as the variable it is initializing.
20292 @item
20293 If @code{signed} or @code{unsigned} is omitted, the signedness of the
20294 vector type is the default signedness of the base type.  The default
20295 varies depending on the operating system, so a portable program should
20296 always specify the signedness.
20298 @item
20299 By default, the keyword @code{__vector} is added. The macro
20300 @code{vector} is defined in @code{<spu_intrinsics.h>} and can be
20301 undefined.
20303 @item
20304 GCC allows using a @code{typedef} name as the type specifier for a
20305 vector type.
20307 @item
20308 For C, overloaded functions are implemented with macros so the following
20309 does not work:
20311 @smallexample
20312   spu_add ((vector signed int)@{1, 2, 3, 4@}, foo);
20313 @end smallexample
20315 @noindent
20316 Since @code{spu_add} is a macro, the vector constant in the example
20317 is treated as four separate arguments.  Wrap the entire argument in
20318 parentheses for this to work.
20320 @item
20321 The extended version of @code{__builtin_expect} is not supported.
20323 @end itemize
20325 @emph{Note:} Only the interface described in the aforementioned
20326 specification is supported. Internally, GCC uses built-in functions to
20327 implement the required functionality, but these are not supported and
20328 are subject to change without notice.
20330 @node TI C6X Built-in Functions
20331 @subsection TI C6X Built-in Functions
20333 GCC provides intrinsics to access certain instructions of the TI C6X
20334 processors.  These intrinsics, listed below, are available after
20335 inclusion of the @code{c6x_intrinsics.h} header file.  They map directly
20336 to C6X instructions.
20338 @smallexample
20340 int _sadd (int, int)
20341 int _ssub (int, int)
20342 int _sadd2 (int, int)
20343 int _ssub2 (int, int)
20344 long long _mpy2 (int, int)
20345 long long _smpy2 (int, int)
20346 int _add4 (int, int)
20347 int _sub4 (int, int)
20348 int _saddu4 (int, int)
20350 int _smpy (int, int)
20351 int _smpyh (int, int)
20352 int _smpyhl (int, int)
20353 int _smpylh (int, int)
20355 int _sshl (int, int)
20356 int _subc (int, int)
20358 int _avg2 (int, int)
20359 int _avgu4 (int, int)
20361 int _clrr (int, int)
20362 int _extr (int, int)
20363 int _extru (int, int)
20364 int _abs (int)
20365 int _abs2 (int)
20367 @end smallexample
20369 @node TILE-Gx Built-in Functions
20370 @subsection TILE-Gx Built-in Functions
20372 GCC provides intrinsics to access every instruction of the TILE-Gx
20373 processor.  The intrinsics are of the form:
20375 @smallexample
20377 unsigned long long __insn_@var{op} (...)
20379 @end smallexample
20381 Where @var{op} is the name of the instruction.  Refer to the ISA manual
20382 for the complete list of instructions.
20384 GCC also provides intrinsics to directly access the network registers.
20385 The intrinsics are:
20387 @smallexample
20389 unsigned long long __tile_idn0_receive (void)
20390 unsigned long long __tile_idn1_receive (void)
20391 unsigned long long __tile_udn0_receive (void)
20392 unsigned long long __tile_udn1_receive (void)
20393 unsigned long long __tile_udn2_receive (void)
20394 unsigned long long __tile_udn3_receive (void)
20395 void __tile_idn_send (unsigned long long)
20396 void __tile_udn_send (unsigned long long)
20398 @end smallexample
20400 The intrinsic @code{void __tile_network_barrier (void)} is used to
20401 guarantee that no network operations before it are reordered with
20402 those after it.
20404 @node TILEPro Built-in Functions
20405 @subsection TILEPro Built-in Functions
20407 GCC provides intrinsics to access every instruction of the TILEPro
20408 processor.  The intrinsics are of the form:
20410 @smallexample
20412 unsigned __insn_@var{op} (...)
20414 @end smallexample
20416 @noindent
20417 where @var{op} is the name of the instruction.  Refer to the ISA manual
20418 for the complete list of instructions.
20420 GCC also provides intrinsics to directly access the network registers.
20421 The intrinsics are:
20423 @smallexample
20425 unsigned __tile_idn0_receive (void)
20426 unsigned __tile_idn1_receive (void)
20427 unsigned __tile_sn_receive (void)
20428 unsigned __tile_udn0_receive (void)
20429 unsigned __tile_udn1_receive (void)
20430 unsigned __tile_udn2_receive (void)
20431 unsigned __tile_udn3_receive (void)
20432 void __tile_idn_send (unsigned)
20433 void __tile_sn_send (unsigned)
20434 void __tile_udn_send (unsigned)
20436 @end smallexample
20438 The intrinsic @code{void __tile_network_barrier (void)} is used to
20439 guarantee that no network operations before it are reordered with
20440 those after it.
20442 @node x86 Built-in Functions
20443 @subsection x86 Built-in Functions
20445 These built-in functions are available for the x86-32 and x86-64 family
20446 of computers, depending on the command-line switches used.
20448 If you specify command-line switches such as @option{-msse},
20449 the compiler could use the extended instruction sets even if the built-ins
20450 are not used explicitly in the program.  For this reason, applications
20451 that perform run-time CPU detection must compile separate files for each
20452 supported architecture, using the appropriate flags.  In particular,
20453 the file containing the CPU detection code should be compiled without
20454 these options.
20456 The following machine modes are available for use with MMX built-in functions
20457 (@pxref{Vector Extensions}): @code{V2SI} for a vector of two 32-bit integers,
20458 @code{V4HI} for a vector of four 16-bit integers, and @code{V8QI} for a
20459 vector of eight 8-bit integers.  Some of the built-in functions operate on
20460 MMX registers as a whole 64-bit entity, these use @code{V1DI} as their mode.
20462 If 3DNow!@: extensions are enabled, @code{V2SF} is used as a mode for a vector
20463 of two 32-bit floating-point values.
20465 If SSE extensions are enabled, @code{V4SF} is used for a vector of four 32-bit
20466 floating-point values.  Some instructions use a vector of four 32-bit
20467 integers, these use @code{V4SI}.  Finally, some instructions operate on an
20468 entire vector register, interpreting it as a 128-bit integer, these use mode
20469 @code{TI}.
20471 The x86-32 and x86-64 family of processors use additional built-in
20472 functions for efficient use of @code{TF} (@code{__float128}) 128-bit
20473 floating point and @code{TC} 128-bit complex floating-point values.
20475 The following floating-point built-in functions are always available.  All
20476 of them implement the function that is part of the name.
20478 @smallexample
20479 __float128 __builtin_fabsq (__float128)
20480 __float128 __builtin_copysignq (__float128, __float128)
20481 @end smallexample
20483 The following built-in functions are always available.
20485 @table @code
20486 @item __float128 __builtin_infq (void)
20487 Similar to @code{__builtin_inf}, except the return type is @code{__float128}.
20488 @findex __builtin_infq
20490 @item __float128 __builtin_huge_valq (void)
20491 Similar to @code{__builtin_huge_val}, except the return type is @code{__float128}.
20492 @findex __builtin_huge_valq
20494 @item __float128 __builtin_nanq (void)
20495 Similar to @code{__builtin_nan}, except the return type is @code{__float128}.
20496 @findex __builtin_nanq
20498 @item __float128 __builtin_nansq (void)
20499 Similar to @code{__builtin_nans}, except the return type is @code{__float128}.
20500 @findex __builtin_nansq
20501 @end table
20503 The following built-in function is always available.
20505 @table @code
20506 @item void __builtin_ia32_pause (void)
20507 Generates the @code{pause} machine instruction with a compiler memory
20508 barrier.
20509 @end table
20511 The following built-in functions are always available and can be used to
20512 check the target platform type.
20514 @deftypefn {Built-in Function} void __builtin_cpu_init (void)
20515 This function runs the CPU detection code to check the type of CPU and the
20516 features supported.  This built-in function needs to be invoked along with the built-in functions
20517 to check CPU type and features, @code{__builtin_cpu_is} and
20518 @code{__builtin_cpu_supports}, only when used in a function that is
20519 executed before any constructors are called.  The CPU detection code is
20520 automatically executed in a very high priority constructor.
20522 For example, this function has to be used in @code{ifunc} resolvers that
20523 check for CPU type using the built-in functions @code{__builtin_cpu_is}
20524 and @code{__builtin_cpu_supports}, or in constructors on targets that
20525 don't support constructor priority.
20526 @smallexample
20528 static void (*resolve_memcpy (void)) (void)
20530   // ifunc resolvers fire before constructors, explicitly call the init
20531   // function.
20532   __builtin_cpu_init ();
20533   if (__builtin_cpu_supports ("ssse3"))
20534     return ssse3_memcpy; // super fast memcpy with ssse3 instructions.
20535   else
20536     return default_memcpy;
20539 void *memcpy (void *, const void *, size_t)
20540      __attribute__ ((ifunc ("resolve_memcpy")));
20541 @end smallexample
20543 @end deftypefn
20545 @deftypefn {Built-in Function} int __builtin_cpu_is (const char *@var{cpuname})
20546 This function returns a positive integer if the run-time CPU
20547 is of type @var{cpuname}
20548 and returns @code{0} otherwise. The following CPU names can be detected:
20550 @table @samp
20551 @item intel
20552 Intel CPU.
20554 @item atom
20555 Intel Atom CPU.
20557 @item core2
20558 Intel Core 2 CPU.
20560 @item corei7
20561 Intel Core i7 CPU.
20563 @item nehalem
20564 Intel Core i7 Nehalem CPU.
20566 @item westmere
20567 Intel Core i7 Westmere CPU.
20569 @item sandybridge
20570 Intel Core i7 Sandy Bridge CPU.
20572 @item amd
20573 AMD CPU.
20575 @item amdfam10h
20576 AMD Family 10h CPU.
20578 @item barcelona
20579 AMD Family 10h Barcelona CPU.
20581 @item shanghai
20582 AMD Family 10h Shanghai CPU.
20584 @item istanbul
20585 AMD Family 10h Istanbul CPU.
20587 @item btver1
20588 AMD Family 14h CPU.
20590 @item amdfam15h
20591 AMD Family 15h CPU.
20593 @item bdver1
20594 AMD Family 15h Bulldozer version 1.
20596 @item bdver2
20597 AMD Family 15h Bulldozer version 2.
20599 @item bdver3
20600 AMD Family 15h Bulldozer version 3.
20602 @item bdver4
20603 AMD Family 15h Bulldozer version 4.
20605 @item btver2
20606 AMD Family 16h CPU.
20608 @item amdfam17h
20609 AMD Family 17h CPU.
20611 @item znver1
20612 AMD Family 17h Zen version 1.
20613 @end table
20615 Here is an example:
20616 @smallexample
20617 if (__builtin_cpu_is ("corei7"))
20618   @{
20619      do_corei7 (); // Core i7 specific implementation.
20620   @}
20621 else
20622   @{
20623      do_generic (); // Generic implementation.
20624   @}
20625 @end smallexample
20626 @end deftypefn
20628 @deftypefn {Built-in Function} int __builtin_cpu_supports (const char *@var{feature})
20629 This function returns a positive integer if the run-time CPU
20630 supports @var{feature}
20631 and returns @code{0} otherwise. The following features can be detected:
20633 @table @samp
20634 @item cmov
20635 CMOV instruction.
20636 @item mmx
20637 MMX instructions.
20638 @item popcnt
20639 POPCNT instruction.
20640 @item sse
20641 SSE instructions.
20642 @item sse2
20643 SSE2 instructions.
20644 @item sse3
20645 SSE3 instructions.
20646 @item ssse3
20647 SSSE3 instructions.
20648 @item sse4.1
20649 SSE4.1 instructions.
20650 @item sse4.2
20651 SSE4.2 instructions.
20652 @item avx
20653 AVX instructions.
20654 @item avx2
20655 AVX2 instructions.
20656 @item avx512f
20657 AVX512F instructions.
20658 @end table
20660 Here is an example:
20661 @smallexample
20662 if (__builtin_cpu_supports ("popcnt"))
20663   @{
20664      asm("popcnt %1,%0" : "=r"(count) : "rm"(n) : "cc");
20665   @}
20666 else
20667   @{
20668      count = generic_countbits (n); //generic implementation.
20669   @}
20670 @end smallexample
20671 @end deftypefn
20674 The following built-in functions are made available by @option{-mmmx}.
20675 All of them generate the machine instruction that is part of the name.
20677 @smallexample
20678 v8qi __builtin_ia32_paddb (v8qi, v8qi)
20679 v4hi __builtin_ia32_paddw (v4hi, v4hi)
20680 v2si __builtin_ia32_paddd (v2si, v2si)
20681 v8qi __builtin_ia32_psubb (v8qi, v8qi)
20682 v4hi __builtin_ia32_psubw (v4hi, v4hi)
20683 v2si __builtin_ia32_psubd (v2si, v2si)
20684 v8qi __builtin_ia32_paddsb (v8qi, v8qi)
20685 v4hi __builtin_ia32_paddsw (v4hi, v4hi)
20686 v8qi __builtin_ia32_psubsb (v8qi, v8qi)
20687 v4hi __builtin_ia32_psubsw (v4hi, v4hi)
20688 v8qi __builtin_ia32_paddusb (v8qi, v8qi)
20689 v4hi __builtin_ia32_paddusw (v4hi, v4hi)
20690 v8qi __builtin_ia32_psubusb (v8qi, v8qi)
20691 v4hi __builtin_ia32_psubusw (v4hi, v4hi)
20692 v4hi __builtin_ia32_pmullw (v4hi, v4hi)
20693 v4hi __builtin_ia32_pmulhw (v4hi, v4hi)
20694 di __builtin_ia32_pand (di, di)
20695 di __builtin_ia32_pandn (di,di)
20696 di __builtin_ia32_por (di, di)
20697 di __builtin_ia32_pxor (di, di)
20698 v8qi __builtin_ia32_pcmpeqb (v8qi, v8qi)
20699 v4hi __builtin_ia32_pcmpeqw (v4hi, v4hi)
20700 v2si __builtin_ia32_pcmpeqd (v2si, v2si)
20701 v8qi __builtin_ia32_pcmpgtb (v8qi, v8qi)
20702 v4hi __builtin_ia32_pcmpgtw (v4hi, v4hi)
20703 v2si __builtin_ia32_pcmpgtd (v2si, v2si)
20704 v8qi __builtin_ia32_punpckhbw (v8qi, v8qi)
20705 v4hi __builtin_ia32_punpckhwd (v4hi, v4hi)
20706 v2si __builtin_ia32_punpckhdq (v2si, v2si)
20707 v8qi __builtin_ia32_punpcklbw (v8qi, v8qi)
20708 v4hi __builtin_ia32_punpcklwd (v4hi, v4hi)
20709 v2si __builtin_ia32_punpckldq (v2si, v2si)
20710 v8qi __builtin_ia32_packsswb (v4hi, v4hi)
20711 v4hi __builtin_ia32_packssdw (v2si, v2si)
20712 v8qi __builtin_ia32_packuswb (v4hi, v4hi)
20714 v4hi __builtin_ia32_psllw (v4hi, v4hi)
20715 v2si __builtin_ia32_pslld (v2si, v2si)
20716 v1di __builtin_ia32_psllq (v1di, v1di)
20717 v4hi __builtin_ia32_psrlw (v4hi, v4hi)
20718 v2si __builtin_ia32_psrld (v2si, v2si)
20719 v1di __builtin_ia32_psrlq (v1di, v1di)
20720 v4hi __builtin_ia32_psraw (v4hi, v4hi)
20721 v2si __builtin_ia32_psrad (v2si, v2si)
20722 v4hi __builtin_ia32_psllwi (v4hi, int)
20723 v2si __builtin_ia32_pslldi (v2si, int)
20724 v1di __builtin_ia32_psllqi (v1di, int)
20725 v4hi __builtin_ia32_psrlwi (v4hi, int)
20726 v2si __builtin_ia32_psrldi (v2si, int)
20727 v1di __builtin_ia32_psrlqi (v1di, int)
20728 v4hi __builtin_ia32_psrawi (v4hi, int)
20729 v2si __builtin_ia32_psradi (v2si, int)
20731 @end smallexample
20733 The following built-in functions are made available either with
20734 @option{-msse}, or with @option{-m3dnowa}.  All of them generate
20735 the machine instruction that is part of the name.
20737 @smallexample
20738 v4hi __builtin_ia32_pmulhuw (v4hi, v4hi)
20739 v8qi __builtin_ia32_pavgb (v8qi, v8qi)
20740 v4hi __builtin_ia32_pavgw (v4hi, v4hi)
20741 v1di __builtin_ia32_psadbw (v8qi, v8qi)
20742 v8qi __builtin_ia32_pmaxub (v8qi, v8qi)
20743 v4hi __builtin_ia32_pmaxsw (v4hi, v4hi)
20744 v8qi __builtin_ia32_pminub (v8qi, v8qi)
20745 v4hi __builtin_ia32_pminsw (v4hi, v4hi)
20746 int __builtin_ia32_pmovmskb (v8qi)
20747 void __builtin_ia32_maskmovq (v8qi, v8qi, char *)
20748 void __builtin_ia32_movntq (di *, di)
20749 void __builtin_ia32_sfence (void)
20750 @end smallexample
20752 The following built-in functions are available when @option{-msse} is used.
20753 All of them generate the machine instruction that is part of the name.
20755 @smallexample
20756 int __builtin_ia32_comieq (v4sf, v4sf)
20757 int __builtin_ia32_comineq (v4sf, v4sf)
20758 int __builtin_ia32_comilt (v4sf, v4sf)
20759 int __builtin_ia32_comile (v4sf, v4sf)
20760 int __builtin_ia32_comigt (v4sf, v4sf)
20761 int __builtin_ia32_comige (v4sf, v4sf)
20762 int __builtin_ia32_ucomieq (v4sf, v4sf)
20763 int __builtin_ia32_ucomineq (v4sf, v4sf)
20764 int __builtin_ia32_ucomilt (v4sf, v4sf)
20765 int __builtin_ia32_ucomile (v4sf, v4sf)
20766 int __builtin_ia32_ucomigt (v4sf, v4sf)
20767 int __builtin_ia32_ucomige (v4sf, v4sf)
20768 v4sf __builtin_ia32_addps (v4sf, v4sf)
20769 v4sf __builtin_ia32_subps (v4sf, v4sf)
20770 v4sf __builtin_ia32_mulps (v4sf, v4sf)
20771 v4sf __builtin_ia32_divps (v4sf, v4sf)
20772 v4sf __builtin_ia32_addss (v4sf, v4sf)
20773 v4sf __builtin_ia32_subss (v4sf, v4sf)
20774 v4sf __builtin_ia32_mulss (v4sf, v4sf)
20775 v4sf __builtin_ia32_divss (v4sf, v4sf)
20776 v4sf __builtin_ia32_cmpeqps (v4sf, v4sf)
20777 v4sf __builtin_ia32_cmpltps (v4sf, v4sf)
20778 v4sf __builtin_ia32_cmpleps (v4sf, v4sf)
20779 v4sf __builtin_ia32_cmpgtps (v4sf, v4sf)
20780 v4sf __builtin_ia32_cmpgeps (v4sf, v4sf)
20781 v4sf __builtin_ia32_cmpunordps (v4sf, v4sf)
20782 v4sf __builtin_ia32_cmpneqps (v4sf, v4sf)
20783 v4sf __builtin_ia32_cmpnltps (v4sf, v4sf)
20784 v4sf __builtin_ia32_cmpnleps (v4sf, v4sf)
20785 v4sf __builtin_ia32_cmpngtps (v4sf, v4sf)
20786 v4sf __builtin_ia32_cmpngeps (v4sf, v4sf)
20787 v4sf __builtin_ia32_cmpordps (v4sf, v4sf)
20788 v4sf __builtin_ia32_cmpeqss (v4sf, v4sf)
20789 v4sf __builtin_ia32_cmpltss (v4sf, v4sf)
20790 v4sf __builtin_ia32_cmpless (v4sf, v4sf)
20791 v4sf __builtin_ia32_cmpunordss (v4sf, v4sf)
20792 v4sf __builtin_ia32_cmpneqss (v4sf, v4sf)
20793 v4sf __builtin_ia32_cmpnltss (v4sf, v4sf)
20794 v4sf __builtin_ia32_cmpnless (v4sf, v4sf)
20795 v4sf __builtin_ia32_cmpordss (v4sf, v4sf)
20796 v4sf __builtin_ia32_maxps (v4sf, v4sf)
20797 v4sf __builtin_ia32_maxss (v4sf, v4sf)
20798 v4sf __builtin_ia32_minps (v4sf, v4sf)
20799 v4sf __builtin_ia32_minss (v4sf, v4sf)
20800 v4sf __builtin_ia32_andps (v4sf, v4sf)
20801 v4sf __builtin_ia32_andnps (v4sf, v4sf)
20802 v4sf __builtin_ia32_orps (v4sf, v4sf)
20803 v4sf __builtin_ia32_xorps (v4sf, v4sf)
20804 v4sf __builtin_ia32_movss (v4sf, v4sf)
20805 v4sf __builtin_ia32_movhlps (v4sf, v4sf)
20806 v4sf __builtin_ia32_movlhps (v4sf, v4sf)
20807 v4sf __builtin_ia32_unpckhps (v4sf, v4sf)
20808 v4sf __builtin_ia32_unpcklps (v4sf, v4sf)
20809 v4sf __builtin_ia32_cvtpi2ps (v4sf, v2si)
20810 v4sf __builtin_ia32_cvtsi2ss (v4sf, int)
20811 v2si __builtin_ia32_cvtps2pi (v4sf)
20812 int __builtin_ia32_cvtss2si (v4sf)
20813 v2si __builtin_ia32_cvttps2pi (v4sf)
20814 int __builtin_ia32_cvttss2si (v4sf)
20815 v4sf __builtin_ia32_rcpps (v4sf)
20816 v4sf __builtin_ia32_rsqrtps (v4sf)
20817 v4sf __builtin_ia32_sqrtps (v4sf)
20818 v4sf __builtin_ia32_rcpss (v4sf)
20819 v4sf __builtin_ia32_rsqrtss (v4sf)
20820 v4sf __builtin_ia32_sqrtss (v4sf)
20821 v4sf __builtin_ia32_shufps (v4sf, v4sf, int)
20822 void __builtin_ia32_movntps (float *, v4sf)
20823 int __builtin_ia32_movmskps (v4sf)
20824 @end smallexample
20826 The following built-in functions are available when @option{-msse} is used.
20828 @table @code
20829 @item v4sf __builtin_ia32_loadups (float *)
20830 Generates the @code{movups} machine instruction as a load from memory.
20831 @item void __builtin_ia32_storeups (float *, v4sf)
20832 Generates the @code{movups} machine instruction as a store to memory.
20833 @item v4sf __builtin_ia32_loadss (float *)
20834 Generates the @code{movss} machine instruction as a load from memory.
20835 @item v4sf __builtin_ia32_loadhps (v4sf, const v2sf *)
20836 Generates the @code{movhps} machine instruction as a load from memory.
20837 @item v4sf __builtin_ia32_loadlps (v4sf, const v2sf *)
20838 Generates the @code{movlps} machine instruction as a load from memory
20839 @item void __builtin_ia32_storehps (v2sf *, v4sf)
20840 Generates the @code{movhps} machine instruction as a store to memory.
20841 @item void __builtin_ia32_storelps (v2sf *, v4sf)
20842 Generates the @code{movlps} machine instruction as a store to memory.
20843 @end table
20845 The following built-in functions are available when @option{-msse2} is used.
20846 All of them generate the machine instruction that is part of the name.
20848 @smallexample
20849 int __builtin_ia32_comisdeq (v2df, v2df)
20850 int __builtin_ia32_comisdlt (v2df, v2df)
20851 int __builtin_ia32_comisdle (v2df, v2df)
20852 int __builtin_ia32_comisdgt (v2df, v2df)
20853 int __builtin_ia32_comisdge (v2df, v2df)
20854 int __builtin_ia32_comisdneq (v2df, v2df)
20855 int __builtin_ia32_ucomisdeq (v2df, v2df)
20856 int __builtin_ia32_ucomisdlt (v2df, v2df)
20857 int __builtin_ia32_ucomisdle (v2df, v2df)
20858 int __builtin_ia32_ucomisdgt (v2df, v2df)
20859 int __builtin_ia32_ucomisdge (v2df, v2df)
20860 int __builtin_ia32_ucomisdneq (v2df, v2df)
20861 v2df __builtin_ia32_cmpeqpd (v2df, v2df)
20862 v2df __builtin_ia32_cmpltpd (v2df, v2df)
20863 v2df __builtin_ia32_cmplepd (v2df, v2df)
20864 v2df __builtin_ia32_cmpgtpd (v2df, v2df)
20865 v2df __builtin_ia32_cmpgepd (v2df, v2df)
20866 v2df __builtin_ia32_cmpunordpd (v2df, v2df)
20867 v2df __builtin_ia32_cmpneqpd (v2df, v2df)
20868 v2df __builtin_ia32_cmpnltpd (v2df, v2df)
20869 v2df __builtin_ia32_cmpnlepd (v2df, v2df)
20870 v2df __builtin_ia32_cmpngtpd (v2df, v2df)
20871 v2df __builtin_ia32_cmpngepd (v2df, v2df)
20872 v2df __builtin_ia32_cmpordpd (v2df, v2df)
20873 v2df __builtin_ia32_cmpeqsd (v2df, v2df)
20874 v2df __builtin_ia32_cmpltsd (v2df, v2df)
20875 v2df __builtin_ia32_cmplesd (v2df, v2df)
20876 v2df __builtin_ia32_cmpunordsd (v2df, v2df)
20877 v2df __builtin_ia32_cmpneqsd (v2df, v2df)
20878 v2df __builtin_ia32_cmpnltsd (v2df, v2df)
20879 v2df __builtin_ia32_cmpnlesd (v2df, v2df)
20880 v2df __builtin_ia32_cmpordsd (v2df, v2df)
20881 v2di __builtin_ia32_paddq (v2di, v2di)
20882 v2di __builtin_ia32_psubq (v2di, v2di)
20883 v2df __builtin_ia32_addpd (v2df, v2df)
20884 v2df __builtin_ia32_subpd (v2df, v2df)
20885 v2df __builtin_ia32_mulpd (v2df, v2df)
20886 v2df __builtin_ia32_divpd (v2df, v2df)
20887 v2df __builtin_ia32_addsd (v2df, v2df)
20888 v2df __builtin_ia32_subsd (v2df, v2df)
20889 v2df __builtin_ia32_mulsd (v2df, v2df)
20890 v2df __builtin_ia32_divsd (v2df, v2df)
20891 v2df __builtin_ia32_minpd (v2df, v2df)
20892 v2df __builtin_ia32_maxpd (v2df, v2df)
20893 v2df __builtin_ia32_minsd (v2df, v2df)
20894 v2df __builtin_ia32_maxsd (v2df, v2df)
20895 v2df __builtin_ia32_andpd (v2df, v2df)
20896 v2df __builtin_ia32_andnpd (v2df, v2df)
20897 v2df __builtin_ia32_orpd (v2df, v2df)
20898 v2df __builtin_ia32_xorpd (v2df, v2df)
20899 v2df __builtin_ia32_movsd (v2df, v2df)
20900 v2df __builtin_ia32_unpckhpd (v2df, v2df)
20901 v2df __builtin_ia32_unpcklpd (v2df, v2df)
20902 v16qi __builtin_ia32_paddb128 (v16qi, v16qi)
20903 v8hi __builtin_ia32_paddw128 (v8hi, v8hi)
20904 v4si __builtin_ia32_paddd128 (v4si, v4si)
20905 v2di __builtin_ia32_paddq128 (v2di, v2di)
20906 v16qi __builtin_ia32_psubb128 (v16qi, v16qi)
20907 v8hi __builtin_ia32_psubw128 (v8hi, v8hi)
20908 v4si __builtin_ia32_psubd128 (v4si, v4si)
20909 v2di __builtin_ia32_psubq128 (v2di, v2di)
20910 v8hi __builtin_ia32_pmullw128 (v8hi, v8hi)
20911 v8hi __builtin_ia32_pmulhw128 (v8hi, v8hi)
20912 v2di __builtin_ia32_pand128 (v2di, v2di)
20913 v2di __builtin_ia32_pandn128 (v2di, v2di)
20914 v2di __builtin_ia32_por128 (v2di, v2di)
20915 v2di __builtin_ia32_pxor128 (v2di, v2di)
20916 v16qi __builtin_ia32_pavgb128 (v16qi, v16qi)
20917 v8hi __builtin_ia32_pavgw128 (v8hi, v8hi)
20918 v16qi __builtin_ia32_pcmpeqb128 (v16qi, v16qi)
20919 v8hi __builtin_ia32_pcmpeqw128 (v8hi, v8hi)
20920 v4si __builtin_ia32_pcmpeqd128 (v4si, v4si)
20921 v16qi __builtin_ia32_pcmpgtb128 (v16qi, v16qi)
20922 v8hi __builtin_ia32_pcmpgtw128 (v8hi, v8hi)
20923 v4si __builtin_ia32_pcmpgtd128 (v4si, v4si)
20924 v16qi __builtin_ia32_pmaxub128 (v16qi, v16qi)
20925 v8hi __builtin_ia32_pmaxsw128 (v8hi, v8hi)
20926 v16qi __builtin_ia32_pminub128 (v16qi, v16qi)
20927 v8hi __builtin_ia32_pminsw128 (v8hi, v8hi)
20928 v16qi __builtin_ia32_punpckhbw128 (v16qi, v16qi)
20929 v8hi __builtin_ia32_punpckhwd128 (v8hi, v8hi)
20930 v4si __builtin_ia32_punpckhdq128 (v4si, v4si)
20931 v2di __builtin_ia32_punpckhqdq128 (v2di, v2di)
20932 v16qi __builtin_ia32_punpcklbw128 (v16qi, v16qi)
20933 v8hi __builtin_ia32_punpcklwd128 (v8hi, v8hi)
20934 v4si __builtin_ia32_punpckldq128 (v4si, v4si)
20935 v2di __builtin_ia32_punpcklqdq128 (v2di, v2di)
20936 v16qi __builtin_ia32_packsswb128 (v8hi, v8hi)
20937 v8hi __builtin_ia32_packssdw128 (v4si, v4si)
20938 v16qi __builtin_ia32_packuswb128 (v8hi, v8hi)
20939 v8hi __builtin_ia32_pmulhuw128 (v8hi, v8hi)
20940 void __builtin_ia32_maskmovdqu (v16qi, v16qi)
20941 v2df __builtin_ia32_loadupd (double *)
20942 void __builtin_ia32_storeupd (double *, v2df)
20943 v2df __builtin_ia32_loadhpd (v2df, double const *)
20944 v2df __builtin_ia32_loadlpd (v2df, double const *)
20945 int __builtin_ia32_movmskpd (v2df)
20946 int __builtin_ia32_pmovmskb128 (v16qi)
20947 void __builtin_ia32_movnti (int *, int)
20948 void __builtin_ia32_movnti64 (long long int *, long long int)
20949 void __builtin_ia32_movntpd (double *, v2df)
20950 void __builtin_ia32_movntdq (v2df *, v2df)
20951 v4si __builtin_ia32_pshufd (v4si, int)
20952 v8hi __builtin_ia32_pshuflw (v8hi, int)
20953 v8hi __builtin_ia32_pshufhw (v8hi, int)
20954 v2di __builtin_ia32_psadbw128 (v16qi, v16qi)
20955 v2df __builtin_ia32_sqrtpd (v2df)
20956 v2df __builtin_ia32_sqrtsd (v2df)
20957 v2df __builtin_ia32_shufpd (v2df, v2df, int)
20958 v2df __builtin_ia32_cvtdq2pd (v4si)
20959 v4sf __builtin_ia32_cvtdq2ps (v4si)
20960 v4si __builtin_ia32_cvtpd2dq (v2df)
20961 v2si __builtin_ia32_cvtpd2pi (v2df)
20962 v4sf __builtin_ia32_cvtpd2ps (v2df)
20963 v4si __builtin_ia32_cvttpd2dq (v2df)
20964 v2si __builtin_ia32_cvttpd2pi (v2df)
20965 v2df __builtin_ia32_cvtpi2pd (v2si)
20966 int __builtin_ia32_cvtsd2si (v2df)
20967 int __builtin_ia32_cvttsd2si (v2df)
20968 long long __builtin_ia32_cvtsd2si64 (v2df)
20969 long long __builtin_ia32_cvttsd2si64 (v2df)
20970 v4si __builtin_ia32_cvtps2dq (v4sf)
20971 v2df __builtin_ia32_cvtps2pd (v4sf)
20972 v4si __builtin_ia32_cvttps2dq (v4sf)
20973 v2df __builtin_ia32_cvtsi2sd (v2df, int)
20974 v2df __builtin_ia32_cvtsi642sd (v2df, long long)
20975 v4sf __builtin_ia32_cvtsd2ss (v4sf, v2df)
20976 v2df __builtin_ia32_cvtss2sd (v2df, v4sf)
20977 void __builtin_ia32_clflush (const void *)
20978 void __builtin_ia32_lfence (void)
20979 void __builtin_ia32_mfence (void)
20980 v16qi __builtin_ia32_loaddqu (const char *)
20981 void __builtin_ia32_storedqu (char *, v16qi)
20982 v1di __builtin_ia32_pmuludq (v2si, v2si)
20983 v2di __builtin_ia32_pmuludq128 (v4si, v4si)
20984 v8hi __builtin_ia32_psllw128 (v8hi, v8hi)
20985 v4si __builtin_ia32_pslld128 (v4si, v4si)
20986 v2di __builtin_ia32_psllq128 (v2di, v2di)
20987 v8hi __builtin_ia32_psrlw128 (v8hi, v8hi)
20988 v4si __builtin_ia32_psrld128 (v4si, v4si)
20989 v2di __builtin_ia32_psrlq128 (v2di, v2di)
20990 v8hi __builtin_ia32_psraw128 (v8hi, v8hi)
20991 v4si __builtin_ia32_psrad128 (v4si, v4si)
20992 v2di __builtin_ia32_pslldqi128 (v2di, int)
20993 v8hi __builtin_ia32_psllwi128 (v8hi, int)
20994 v4si __builtin_ia32_pslldi128 (v4si, int)
20995 v2di __builtin_ia32_psllqi128 (v2di, int)
20996 v2di __builtin_ia32_psrldqi128 (v2di, int)
20997 v8hi __builtin_ia32_psrlwi128 (v8hi, int)
20998 v4si __builtin_ia32_psrldi128 (v4si, int)
20999 v2di __builtin_ia32_psrlqi128 (v2di, int)
21000 v8hi __builtin_ia32_psrawi128 (v8hi, int)
21001 v4si __builtin_ia32_psradi128 (v4si, int)
21002 v4si __builtin_ia32_pmaddwd128 (v8hi, v8hi)
21003 v2di __builtin_ia32_movq128 (v2di)
21004 @end smallexample
21006 The following built-in functions are available when @option{-msse3} is used.
21007 All of them generate the machine instruction that is part of the name.
21009 @smallexample
21010 v2df __builtin_ia32_addsubpd (v2df, v2df)
21011 v4sf __builtin_ia32_addsubps (v4sf, v4sf)
21012 v2df __builtin_ia32_haddpd (v2df, v2df)
21013 v4sf __builtin_ia32_haddps (v4sf, v4sf)
21014 v2df __builtin_ia32_hsubpd (v2df, v2df)
21015 v4sf __builtin_ia32_hsubps (v4sf, v4sf)
21016 v16qi __builtin_ia32_lddqu (char const *)
21017 void __builtin_ia32_monitor (void *, unsigned int, unsigned int)
21018 v4sf __builtin_ia32_movshdup (v4sf)
21019 v4sf __builtin_ia32_movsldup (v4sf)
21020 void __builtin_ia32_mwait (unsigned int, unsigned int)
21021 @end smallexample
21023 The following built-in functions are available when @option{-mssse3} is used.
21024 All of them generate the machine instruction that is part of the name.
21026 @smallexample
21027 v2si __builtin_ia32_phaddd (v2si, v2si)
21028 v4hi __builtin_ia32_phaddw (v4hi, v4hi)
21029 v4hi __builtin_ia32_phaddsw (v4hi, v4hi)
21030 v2si __builtin_ia32_phsubd (v2si, v2si)
21031 v4hi __builtin_ia32_phsubw (v4hi, v4hi)
21032 v4hi __builtin_ia32_phsubsw (v4hi, v4hi)
21033 v4hi __builtin_ia32_pmaddubsw (v8qi, v8qi)
21034 v4hi __builtin_ia32_pmulhrsw (v4hi, v4hi)
21035 v8qi __builtin_ia32_pshufb (v8qi, v8qi)
21036 v8qi __builtin_ia32_psignb (v8qi, v8qi)
21037 v2si __builtin_ia32_psignd (v2si, v2si)
21038 v4hi __builtin_ia32_psignw (v4hi, v4hi)
21039 v1di __builtin_ia32_palignr (v1di, v1di, int)
21040 v8qi __builtin_ia32_pabsb (v8qi)
21041 v2si __builtin_ia32_pabsd (v2si)
21042 v4hi __builtin_ia32_pabsw (v4hi)
21043 @end smallexample
21045 The following built-in functions are available when @option{-mssse3} is used.
21046 All of them generate the machine instruction that is part of the name.
21048 @smallexample
21049 v4si __builtin_ia32_phaddd128 (v4si, v4si)
21050 v8hi __builtin_ia32_phaddw128 (v8hi, v8hi)
21051 v8hi __builtin_ia32_phaddsw128 (v8hi, v8hi)
21052 v4si __builtin_ia32_phsubd128 (v4si, v4si)
21053 v8hi __builtin_ia32_phsubw128 (v8hi, v8hi)
21054 v8hi __builtin_ia32_phsubsw128 (v8hi, v8hi)
21055 v8hi __builtin_ia32_pmaddubsw128 (v16qi, v16qi)
21056 v8hi __builtin_ia32_pmulhrsw128 (v8hi, v8hi)
21057 v16qi __builtin_ia32_pshufb128 (v16qi, v16qi)
21058 v16qi __builtin_ia32_psignb128 (v16qi, v16qi)
21059 v4si __builtin_ia32_psignd128 (v4si, v4si)
21060 v8hi __builtin_ia32_psignw128 (v8hi, v8hi)
21061 v2di __builtin_ia32_palignr128 (v2di, v2di, int)
21062 v16qi __builtin_ia32_pabsb128 (v16qi)
21063 v4si __builtin_ia32_pabsd128 (v4si)
21064 v8hi __builtin_ia32_pabsw128 (v8hi)
21065 @end smallexample
21067 The following built-in functions are available when @option{-msse4.1} is
21068 used.  All of them generate the machine instruction that is part of the
21069 name.
21071 @smallexample
21072 v2df __builtin_ia32_blendpd (v2df, v2df, const int)
21073 v4sf __builtin_ia32_blendps (v4sf, v4sf, const int)
21074 v2df __builtin_ia32_blendvpd (v2df, v2df, v2df)
21075 v4sf __builtin_ia32_blendvps (v4sf, v4sf, v4sf)
21076 v2df __builtin_ia32_dppd (v2df, v2df, const int)
21077 v4sf __builtin_ia32_dpps (v4sf, v4sf, const int)
21078 v4sf __builtin_ia32_insertps128 (v4sf, v4sf, const int)
21079 v2di __builtin_ia32_movntdqa (v2di *);
21080 v16qi __builtin_ia32_mpsadbw128 (v16qi, v16qi, const int)
21081 v8hi __builtin_ia32_packusdw128 (v4si, v4si)
21082 v16qi __builtin_ia32_pblendvb128 (v16qi, v16qi, v16qi)
21083 v8hi __builtin_ia32_pblendw128 (v8hi, v8hi, const int)
21084 v2di __builtin_ia32_pcmpeqq (v2di, v2di)
21085 v8hi __builtin_ia32_phminposuw128 (v8hi)
21086 v16qi __builtin_ia32_pmaxsb128 (v16qi, v16qi)
21087 v4si __builtin_ia32_pmaxsd128 (v4si, v4si)
21088 v4si __builtin_ia32_pmaxud128 (v4si, v4si)
21089 v8hi __builtin_ia32_pmaxuw128 (v8hi, v8hi)
21090 v16qi __builtin_ia32_pminsb128 (v16qi, v16qi)
21091 v4si __builtin_ia32_pminsd128 (v4si, v4si)
21092 v4si __builtin_ia32_pminud128 (v4si, v4si)
21093 v8hi __builtin_ia32_pminuw128 (v8hi, v8hi)
21094 v4si __builtin_ia32_pmovsxbd128 (v16qi)
21095 v2di __builtin_ia32_pmovsxbq128 (v16qi)
21096 v8hi __builtin_ia32_pmovsxbw128 (v16qi)
21097 v2di __builtin_ia32_pmovsxdq128 (v4si)
21098 v4si __builtin_ia32_pmovsxwd128 (v8hi)
21099 v2di __builtin_ia32_pmovsxwq128 (v8hi)
21100 v4si __builtin_ia32_pmovzxbd128 (v16qi)
21101 v2di __builtin_ia32_pmovzxbq128 (v16qi)
21102 v8hi __builtin_ia32_pmovzxbw128 (v16qi)
21103 v2di __builtin_ia32_pmovzxdq128 (v4si)
21104 v4si __builtin_ia32_pmovzxwd128 (v8hi)
21105 v2di __builtin_ia32_pmovzxwq128 (v8hi)
21106 v2di __builtin_ia32_pmuldq128 (v4si, v4si)
21107 v4si __builtin_ia32_pmulld128 (v4si, v4si)
21108 int __builtin_ia32_ptestc128 (v2di, v2di)
21109 int __builtin_ia32_ptestnzc128 (v2di, v2di)
21110 int __builtin_ia32_ptestz128 (v2di, v2di)
21111 v2df __builtin_ia32_roundpd (v2df, const int)
21112 v4sf __builtin_ia32_roundps (v4sf, const int)
21113 v2df __builtin_ia32_roundsd (v2df, v2df, const int)
21114 v4sf __builtin_ia32_roundss (v4sf, v4sf, const int)
21115 @end smallexample
21117 The following built-in functions are available when @option{-msse4.1} is
21118 used.
21120 @table @code
21121 @item v4sf __builtin_ia32_vec_set_v4sf (v4sf, float, const int)
21122 Generates the @code{insertps} machine instruction.
21123 @item int __builtin_ia32_vec_ext_v16qi (v16qi, const int)
21124 Generates the @code{pextrb} machine instruction.
21125 @item v16qi __builtin_ia32_vec_set_v16qi (v16qi, int, const int)
21126 Generates the @code{pinsrb} machine instruction.
21127 @item v4si __builtin_ia32_vec_set_v4si (v4si, int, const int)
21128 Generates the @code{pinsrd} machine instruction.
21129 @item v2di __builtin_ia32_vec_set_v2di (v2di, long long, const int)
21130 Generates the @code{pinsrq} machine instruction in 64bit mode.
21131 @end table
21133 The following built-in functions are changed to generate new SSE4.1
21134 instructions when @option{-msse4.1} is used.
21136 @table @code
21137 @item float __builtin_ia32_vec_ext_v4sf (v4sf, const int)
21138 Generates the @code{extractps} machine instruction.
21139 @item int __builtin_ia32_vec_ext_v4si (v4si, const int)
21140 Generates the @code{pextrd} machine instruction.
21141 @item long long __builtin_ia32_vec_ext_v2di (v2di, const int)
21142 Generates the @code{pextrq} machine instruction in 64bit mode.
21143 @end table
21145 The following built-in functions are available when @option{-msse4.2} is
21146 used.  All of them generate the machine instruction that is part of the
21147 name.
21149 @smallexample
21150 v16qi __builtin_ia32_pcmpestrm128 (v16qi, int, v16qi, int, const int)
21151 int __builtin_ia32_pcmpestri128 (v16qi, int, v16qi, int, const int)
21152 int __builtin_ia32_pcmpestria128 (v16qi, int, v16qi, int, const int)
21153 int __builtin_ia32_pcmpestric128 (v16qi, int, v16qi, int, const int)
21154 int __builtin_ia32_pcmpestrio128 (v16qi, int, v16qi, int, const int)
21155 int __builtin_ia32_pcmpestris128 (v16qi, int, v16qi, int, const int)
21156 int __builtin_ia32_pcmpestriz128 (v16qi, int, v16qi, int, const int)
21157 v16qi __builtin_ia32_pcmpistrm128 (v16qi, v16qi, const int)
21158 int __builtin_ia32_pcmpistri128 (v16qi, v16qi, const int)
21159 int __builtin_ia32_pcmpistria128 (v16qi, v16qi, const int)
21160 int __builtin_ia32_pcmpistric128 (v16qi, v16qi, const int)
21161 int __builtin_ia32_pcmpistrio128 (v16qi, v16qi, const int)
21162 int __builtin_ia32_pcmpistris128 (v16qi, v16qi, const int)
21163 int __builtin_ia32_pcmpistriz128 (v16qi, v16qi, const int)
21164 v2di __builtin_ia32_pcmpgtq (v2di, v2di)
21165 @end smallexample
21167 The following built-in functions are available when @option{-msse4.2} is
21168 used.
21170 @table @code
21171 @item unsigned int __builtin_ia32_crc32qi (unsigned int, unsigned char)
21172 Generates the @code{crc32b} machine instruction.
21173 @item unsigned int __builtin_ia32_crc32hi (unsigned int, unsigned short)
21174 Generates the @code{crc32w} machine instruction.
21175 @item unsigned int __builtin_ia32_crc32si (unsigned int, unsigned int)
21176 Generates the @code{crc32l} machine instruction.
21177 @item unsigned long long __builtin_ia32_crc32di (unsigned long long, unsigned long long)
21178 Generates the @code{crc32q} machine instruction.
21179 @end table
21181 The following built-in functions are changed to generate new SSE4.2
21182 instructions when @option{-msse4.2} is used.
21184 @table @code
21185 @item int __builtin_popcount (unsigned int)
21186 Generates the @code{popcntl} machine instruction.
21187 @item int __builtin_popcountl (unsigned long)
21188 Generates the @code{popcntl} or @code{popcntq} machine instruction,
21189 depending on the size of @code{unsigned long}.
21190 @item int __builtin_popcountll (unsigned long long)
21191 Generates the @code{popcntq} machine instruction.
21192 @end table
21194 The following built-in functions are available when @option{-mavx} is
21195 used. All of them generate the machine instruction that is part of the
21196 name.
21198 @smallexample
21199 v4df __builtin_ia32_addpd256 (v4df,v4df)
21200 v8sf __builtin_ia32_addps256 (v8sf,v8sf)
21201 v4df __builtin_ia32_addsubpd256 (v4df,v4df)
21202 v8sf __builtin_ia32_addsubps256 (v8sf,v8sf)
21203 v4df __builtin_ia32_andnpd256 (v4df,v4df)
21204 v8sf __builtin_ia32_andnps256 (v8sf,v8sf)
21205 v4df __builtin_ia32_andpd256 (v4df,v4df)
21206 v8sf __builtin_ia32_andps256 (v8sf,v8sf)
21207 v4df __builtin_ia32_blendpd256 (v4df,v4df,int)
21208 v8sf __builtin_ia32_blendps256 (v8sf,v8sf,int)
21209 v4df __builtin_ia32_blendvpd256 (v4df,v4df,v4df)
21210 v8sf __builtin_ia32_blendvps256 (v8sf,v8sf,v8sf)
21211 v2df __builtin_ia32_cmppd (v2df,v2df,int)
21212 v4df __builtin_ia32_cmppd256 (v4df,v4df,int)
21213 v4sf __builtin_ia32_cmpps (v4sf,v4sf,int)
21214 v8sf __builtin_ia32_cmpps256 (v8sf,v8sf,int)
21215 v2df __builtin_ia32_cmpsd (v2df,v2df,int)
21216 v4sf __builtin_ia32_cmpss (v4sf,v4sf,int)
21217 v4df __builtin_ia32_cvtdq2pd256 (v4si)
21218 v8sf __builtin_ia32_cvtdq2ps256 (v8si)
21219 v4si __builtin_ia32_cvtpd2dq256 (v4df)
21220 v4sf __builtin_ia32_cvtpd2ps256 (v4df)
21221 v8si __builtin_ia32_cvtps2dq256 (v8sf)
21222 v4df __builtin_ia32_cvtps2pd256 (v4sf)
21223 v4si __builtin_ia32_cvttpd2dq256 (v4df)
21224 v8si __builtin_ia32_cvttps2dq256 (v8sf)
21225 v4df __builtin_ia32_divpd256 (v4df,v4df)
21226 v8sf __builtin_ia32_divps256 (v8sf,v8sf)
21227 v8sf __builtin_ia32_dpps256 (v8sf,v8sf,int)
21228 v4df __builtin_ia32_haddpd256 (v4df,v4df)
21229 v8sf __builtin_ia32_haddps256 (v8sf,v8sf)
21230 v4df __builtin_ia32_hsubpd256 (v4df,v4df)
21231 v8sf __builtin_ia32_hsubps256 (v8sf,v8sf)
21232 v32qi __builtin_ia32_lddqu256 (pcchar)
21233 v32qi __builtin_ia32_loaddqu256 (pcchar)
21234 v4df __builtin_ia32_loadupd256 (pcdouble)
21235 v8sf __builtin_ia32_loadups256 (pcfloat)
21236 v2df __builtin_ia32_maskloadpd (pcv2df,v2df)
21237 v4df __builtin_ia32_maskloadpd256 (pcv4df,v4df)
21238 v4sf __builtin_ia32_maskloadps (pcv4sf,v4sf)
21239 v8sf __builtin_ia32_maskloadps256 (pcv8sf,v8sf)
21240 void __builtin_ia32_maskstorepd (pv2df,v2df,v2df)
21241 void __builtin_ia32_maskstorepd256 (pv4df,v4df,v4df)
21242 void __builtin_ia32_maskstoreps (pv4sf,v4sf,v4sf)
21243 void __builtin_ia32_maskstoreps256 (pv8sf,v8sf,v8sf)
21244 v4df __builtin_ia32_maxpd256 (v4df,v4df)
21245 v8sf __builtin_ia32_maxps256 (v8sf,v8sf)
21246 v4df __builtin_ia32_minpd256 (v4df,v4df)
21247 v8sf __builtin_ia32_minps256 (v8sf,v8sf)
21248 v4df __builtin_ia32_movddup256 (v4df)
21249 int __builtin_ia32_movmskpd256 (v4df)
21250 int __builtin_ia32_movmskps256 (v8sf)
21251 v8sf __builtin_ia32_movshdup256 (v8sf)
21252 v8sf __builtin_ia32_movsldup256 (v8sf)
21253 v4df __builtin_ia32_mulpd256 (v4df,v4df)
21254 v8sf __builtin_ia32_mulps256 (v8sf,v8sf)
21255 v4df __builtin_ia32_orpd256 (v4df,v4df)
21256 v8sf __builtin_ia32_orps256 (v8sf,v8sf)
21257 v2df __builtin_ia32_pd_pd256 (v4df)
21258 v4df __builtin_ia32_pd256_pd (v2df)
21259 v4sf __builtin_ia32_ps_ps256 (v8sf)
21260 v8sf __builtin_ia32_ps256_ps (v4sf)
21261 int __builtin_ia32_ptestc256 (v4di,v4di,ptest)
21262 int __builtin_ia32_ptestnzc256 (v4di,v4di,ptest)
21263 int __builtin_ia32_ptestz256 (v4di,v4di,ptest)
21264 v8sf __builtin_ia32_rcpps256 (v8sf)
21265 v4df __builtin_ia32_roundpd256 (v4df,int)
21266 v8sf __builtin_ia32_roundps256 (v8sf,int)
21267 v8sf __builtin_ia32_rsqrtps_nr256 (v8sf)
21268 v8sf __builtin_ia32_rsqrtps256 (v8sf)
21269 v4df __builtin_ia32_shufpd256 (v4df,v4df,int)
21270 v8sf __builtin_ia32_shufps256 (v8sf,v8sf,int)
21271 v4si __builtin_ia32_si_si256 (v8si)
21272 v8si __builtin_ia32_si256_si (v4si)
21273 v4df __builtin_ia32_sqrtpd256 (v4df)
21274 v8sf __builtin_ia32_sqrtps_nr256 (v8sf)
21275 v8sf __builtin_ia32_sqrtps256 (v8sf)
21276 void __builtin_ia32_storedqu256 (pchar,v32qi)
21277 void __builtin_ia32_storeupd256 (pdouble,v4df)
21278 void __builtin_ia32_storeups256 (pfloat,v8sf)
21279 v4df __builtin_ia32_subpd256 (v4df,v4df)
21280 v8sf __builtin_ia32_subps256 (v8sf,v8sf)
21281 v4df __builtin_ia32_unpckhpd256 (v4df,v4df)
21282 v8sf __builtin_ia32_unpckhps256 (v8sf,v8sf)
21283 v4df __builtin_ia32_unpcklpd256 (v4df,v4df)
21284 v8sf __builtin_ia32_unpcklps256 (v8sf,v8sf)
21285 v4df __builtin_ia32_vbroadcastf128_pd256 (pcv2df)
21286 v8sf __builtin_ia32_vbroadcastf128_ps256 (pcv4sf)
21287 v4df __builtin_ia32_vbroadcastsd256 (pcdouble)
21288 v4sf __builtin_ia32_vbroadcastss (pcfloat)
21289 v8sf __builtin_ia32_vbroadcastss256 (pcfloat)
21290 v2df __builtin_ia32_vextractf128_pd256 (v4df,int)
21291 v4sf __builtin_ia32_vextractf128_ps256 (v8sf,int)
21292 v4si __builtin_ia32_vextractf128_si256 (v8si,int)
21293 v4df __builtin_ia32_vinsertf128_pd256 (v4df,v2df,int)
21294 v8sf __builtin_ia32_vinsertf128_ps256 (v8sf,v4sf,int)
21295 v8si __builtin_ia32_vinsertf128_si256 (v8si,v4si,int)
21296 v4df __builtin_ia32_vperm2f128_pd256 (v4df,v4df,int)
21297 v8sf __builtin_ia32_vperm2f128_ps256 (v8sf,v8sf,int)
21298 v8si __builtin_ia32_vperm2f128_si256 (v8si,v8si,int)
21299 v2df __builtin_ia32_vpermil2pd (v2df,v2df,v2di,int)
21300 v4df __builtin_ia32_vpermil2pd256 (v4df,v4df,v4di,int)
21301 v4sf __builtin_ia32_vpermil2ps (v4sf,v4sf,v4si,int)
21302 v8sf __builtin_ia32_vpermil2ps256 (v8sf,v8sf,v8si,int)
21303 v2df __builtin_ia32_vpermilpd (v2df,int)
21304 v4df __builtin_ia32_vpermilpd256 (v4df,int)
21305 v4sf __builtin_ia32_vpermilps (v4sf,int)
21306 v8sf __builtin_ia32_vpermilps256 (v8sf,int)
21307 v2df __builtin_ia32_vpermilvarpd (v2df,v2di)
21308 v4df __builtin_ia32_vpermilvarpd256 (v4df,v4di)
21309 v4sf __builtin_ia32_vpermilvarps (v4sf,v4si)
21310 v8sf __builtin_ia32_vpermilvarps256 (v8sf,v8si)
21311 int __builtin_ia32_vtestcpd (v2df,v2df,ptest)
21312 int __builtin_ia32_vtestcpd256 (v4df,v4df,ptest)
21313 int __builtin_ia32_vtestcps (v4sf,v4sf,ptest)
21314 int __builtin_ia32_vtestcps256 (v8sf,v8sf,ptest)
21315 int __builtin_ia32_vtestnzcpd (v2df,v2df,ptest)
21316 int __builtin_ia32_vtestnzcpd256 (v4df,v4df,ptest)
21317 int __builtin_ia32_vtestnzcps (v4sf,v4sf,ptest)
21318 int __builtin_ia32_vtestnzcps256 (v8sf,v8sf,ptest)
21319 int __builtin_ia32_vtestzpd (v2df,v2df,ptest)
21320 int __builtin_ia32_vtestzpd256 (v4df,v4df,ptest)
21321 int __builtin_ia32_vtestzps (v4sf,v4sf,ptest)
21322 int __builtin_ia32_vtestzps256 (v8sf,v8sf,ptest)
21323 void __builtin_ia32_vzeroall (void)
21324 void __builtin_ia32_vzeroupper (void)
21325 v4df __builtin_ia32_xorpd256 (v4df,v4df)
21326 v8sf __builtin_ia32_xorps256 (v8sf,v8sf)
21327 @end smallexample
21329 The following built-in functions are available when @option{-mavx2} is
21330 used. All of them generate the machine instruction that is part of the
21331 name.
21333 @smallexample
21334 v32qi __builtin_ia32_mpsadbw256 (v32qi,v32qi,int)
21335 v32qi __builtin_ia32_pabsb256 (v32qi)
21336 v16hi __builtin_ia32_pabsw256 (v16hi)
21337 v8si __builtin_ia32_pabsd256 (v8si)
21338 v16hi __builtin_ia32_packssdw256 (v8si,v8si)
21339 v32qi __builtin_ia32_packsswb256 (v16hi,v16hi)
21340 v16hi __builtin_ia32_packusdw256 (v8si,v8si)
21341 v32qi __builtin_ia32_packuswb256 (v16hi,v16hi)
21342 v32qi __builtin_ia32_paddb256 (v32qi,v32qi)
21343 v16hi __builtin_ia32_paddw256 (v16hi,v16hi)
21344 v8si __builtin_ia32_paddd256 (v8si,v8si)
21345 v4di __builtin_ia32_paddq256 (v4di,v4di)
21346 v32qi __builtin_ia32_paddsb256 (v32qi,v32qi)
21347 v16hi __builtin_ia32_paddsw256 (v16hi,v16hi)
21348 v32qi __builtin_ia32_paddusb256 (v32qi,v32qi)
21349 v16hi __builtin_ia32_paddusw256 (v16hi,v16hi)
21350 v4di __builtin_ia32_palignr256 (v4di,v4di,int)
21351 v4di __builtin_ia32_andsi256 (v4di,v4di)
21352 v4di __builtin_ia32_andnotsi256 (v4di,v4di)
21353 v32qi __builtin_ia32_pavgb256 (v32qi,v32qi)
21354 v16hi __builtin_ia32_pavgw256 (v16hi,v16hi)
21355 v32qi __builtin_ia32_pblendvb256 (v32qi,v32qi,v32qi)
21356 v16hi __builtin_ia32_pblendw256 (v16hi,v16hi,int)
21357 v32qi __builtin_ia32_pcmpeqb256 (v32qi,v32qi)
21358 v16hi __builtin_ia32_pcmpeqw256 (v16hi,v16hi)
21359 v8si __builtin_ia32_pcmpeqd256 (c8si,v8si)
21360 v4di __builtin_ia32_pcmpeqq256 (v4di,v4di)
21361 v32qi __builtin_ia32_pcmpgtb256 (v32qi,v32qi)
21362 v16hi __builtin_ia32_pcmpgtw256 (16hi,v16hi)
21363 v8si __builtin_ia32_pcmpgtd256 (v8si,v8si)
21364 v4di __builtin_ia32_pcmpgtq256 (v4di,v4di)
21365 v16hi __builtin_ia32_phaddw256 (v16hi,v16hi)
21366 v8si __builtin_ia32_phaddd256 (v8si,v8si)
21367 v16hi __builtin_ia32_phaddsw256 (v16hi,v16hi)
21368 v16hi __builtin_ia32_phsubw256 (v16hi,v16hi)
21369 v8si __builtin_ia32_phsubd256 (v8si,v8si)
21370 v16hi __builtin_ia32_phsubsw256 (v16hi,v16hi)
21371 v32qi __builtin_ia32_pmaddubsw256 (v32qi,v32qi)
21372 v16hi __builtin_ia32_pmaddwd256 (v16hi,v16hi)
21373 v32qi __builtin_ia32_pmaxsb256 (v32qi,v32qi)
21374 v16hi __builtin_ia32_pmaxsw256 (v16hi,v16hi)
21375 v8si __builtin_ia32_pmaxsd256 (v8si,v8si)
21376 v32qi __builtin_ia32_pmaxub256 (v32qi,v32qi)
21377 v16hi __builtin_ia32_pmaxuw256 (v16hi,v16hi)
21378 v8si __builtin_ia32_pmaxud256 (v8si,v8si)
21379 v32qi __builtin_ia32_pminsb256 (v32qi,v32qi)
21380 v16hi __builtin_ia32_pminsw256 (v16hi,v16hi)
21381 v8si __builtin_ia32_pminsd256 (v8si,v8si)
21382 v32qi __builtin_ia32_pminub256 (v32qi,v32qi)
21383 v16hi __builtin_ia32_pminuw256 (v16hi,v16hi)
21384 v8si __builtin_ia32_pminud256 (v8si,v8si)
21385 int __builtin_ia32_pmovmskb256 (v32qi)
21386 v16hi __builtin_ia32_pmovsxbw256 (v16qi)
21387 v8si __builtin_ia32_pmovsxbd256 (v16qi)
21388 v4di __builtin_ia32_pmovsxbq256 (v16qi)
21389 v8si __builtin_ia32_pmovsxwd256 (v8hi)
21390 v4di __builtin_ia32_pmovsxwq256 (v8hi)
21391 v4di __builtin_ia32_pmovsxdq256 (v4si)
21392 v16hi __builtin_ia32_pmovzxbw256 (v16qi)
21393 v8si __builtin_ia32_pmovzxbd256 (v16qi)
21394 v4di __builtin_ia32_pmovzxbq256 (v16qi)
21395 v8si __builtin_ia32_pmovzxwd256 (v8hi)
21396 v4di __builtin_ia32_pmovzxwq256 (v8hi)
21397 v4di __builtin_ia32_pmovzxdq256 (v4si)
21398 v4di __builtin_ia32_pmuldq256 (v8si,v8si)
21399 v16hi __builtin_ia32_pmulhrsw256 (v16hi, v16hi)
21400 v16hi __builtin_ia32_pmulhuw256 (v16hi,v16hi)
21401 v16hi __builtin_ia32_pmulhw256 (v16hi,v16hi)
21402 v16hi __builtin_ia32_pmullw256 (v16hi,v16hi)
21403 v8si __builtin_ia32_pmulld256 (v8si,v8si)
21404 v4di __builtin_ia32_pmuludq256 (v8si,v8si)
21405 v4di __builtin_ia32_por256 (v4di,v4di)
21406 v16hi __builtin_ia32_psadbw256 (v32qi,v32qi)
21407 v32qi __builtin_ia32_pshufb256 (v32qi,v32qi)
21408 v8si __builtin_ia32_pshufd256 (v8si,int)
21409 v16hi __builtin_ia32_pshufhw256 (v16hi,int)
21410 v16hi __builtin_ia32_pshuflw256 (v16hi,int)
21411 v32qi __builtin_ia32_psignb256 (v32qi,v32qi)
21412 v16hi __builtin_ia32_psignw256 (v16hi,v16hi)
21413 v8si __builtin_ia32_psignd256 (v8si,v8si)
21414 v4di __builtin_ia32_pslldqi256 (v4di,int)
21415 v16hi __builtin_ia32_psllwi256 (16hi,int)
21416 v16hi __builtin_ia32_psllw256(v16hi,v8hi)
21417 v8si __builtin_ia32_pslldi256 (v8si,int)
21418 v8si __builtin_ia32_pslld256(v8si,v4si)
21419 v4di __builtin_ia32_psllqi256 (v4di,int)
21420 v4di __builtin_ia32_psllq256(v4di,v2di)
21421 v16hi __builtin_ia32_psrawi256 (v16hi,int)
21422 v16hi __builtin_ia32_psraw256 (v16hi,v8hi)
21423 v8si __builtin_ia32_psradi256 (v8si,int)
21424 v8si __builtin_ia32_psrad256 (v8si,v4si)
21425 v4di __builtin_ia32_psrldqi256 (v4di, int)
21426 v16hi __builtin_ia32_psrlwi256 (v16hi,int)
21427 v16hi __builtin_ia32_psrlw256 (v16hi,v8hi)
21428 v8si __builtin_ia32_psrldi256 (v8si,int)
21429 v8si __builtin_ia32_psrld256 (v8si,v4si)
21430 v4di __builtin_ia32_psrlqi256 (v4di,int)
21431 v4di __builtin_ia32_psrlq256(v4di,v2di)
21432 v32qi __builtin_ia32_psubb256 (v32qi,v32qi)
21433 v32hi __builtin_ia32_psubw256 (v16hi,v16hi)
21434 v8si __builtin_ia32_psubd256 (v8si,v8si)
21435 v4di __builtin_ia32_psubq256 (v4di,v4di)
21436 v32qi __builtin_ia32_psubsb256 (v32qi,v32qi)
21437 v16hi __builtin_ia32_psubsw256 (v16hi,v16hi)
21438 v32qi __builtin_ia32_psubusb256 (v32qi,v32qi)
21439 v16hi __builtin_ia32_psubusw256 (v16hi,v16hi)
21440 v32qi __builtin_ia32_punpckhbw256 (v32qi,v32qi)
21441 v16hi __builtin_ia32_punpckhwd256 (v16hi,v16hi)
21442 v8si __builtin_ia32_punpckhdq256 (v8si,v8si)
21443 v4di __builtin_ia32_punpckhqdq256 (v4di,v4di)
21444 v32qi __builtin_ia32_punpcklbw256 (v32qi,v32qi)
21445 v16hi __builtin_ia32_punpcklwd256 (v16hi,v16hi)
21446 v8si __builtin_ia32_punpckldq256 (v8si,v8si)
21447 v4di __builtin_ia32_punpcklqdq256 (v4di,v4di)
21448 v4di __builtin_ia32_pxor256 (v4di,v4di)
21449 v4di __builtin_ia32_movntdqa256 (pv4di)
21450 v4sf __builtin_ia32_vbroadcastss_ps (v4sf)
21451 v8sf __builtin_ia32_vbroadcastss_ps256 (v4sf)
21452 v4df __builtin_ia32_vbroadcastsd_pd256 (v2df)
21453 v4di __builtin_ia32_vbroadcastsi256 (v2di)
21454 v4si __builtin_ia32_pblendd128 (v4si,v4si)
21455 v8si __builtin_ia32_pblendd256 (v8si,v8si)
21456 v32qi __builtin_ia32_pbroadcastb256 (v16qi)
21457 v16hi __builtin_ia32_pbroadcastw256 (v8hi)
21458 v8si __builtin_ia32_pbroadcastd256 (v4si)
21459 v4di __builtin_ia32_pbroadcastq256 (v2di)
21460 v16qi __builtin_ia32_pbroadcastb128 (v16qi)
21461 v8hi __builtin_ia32_pbroadcastw128 (v8hi)
21462 v4si __builtin_ia32_pbroadcastd128 (v4si)
21463 v2di __builtin_ia32_pbroadcastq128 (v2di)
21464 v8si __builtin_ia32_permvarsi256 (v8si,v8si)
21465 v4df __builtin_ia32_permdf256 (v4df,int)
21466 v8sf __builtin_ia32_permvarsf256 (v8sf,v8sf)
21467 v4di __builtin_ia32_permdi256 (v4di,int)
21468 v4di __builtin_ia32_permti256 (v4di,v4di,int)
21469 v4di __builtin_ia32_extract128i256 (v4di,int)
21470 v4di __builtin_ia32_insert128i256 (v4di,v2di,int)
21471 v8si __builtin_ia32_maskloadd256 (pcv8si,v8si)
21472 v4di __builtin_ia32_maskloadq256 (pcv4di,v4di)
21473 v4si __builtin_ia32_maskloadd (pcv4si,v4si)
21474 v2di __builtin_ia32_maskloadq (pcv2di,v2di)
21475 void __builtin_ia32_maskstored256 (pv8si,v8si,v8si)
21476 void __builtin_ia32_maskstoreq256 (pv4di,v4di,v4di)
21477 void __builtin_ia32_maskstored (pv4si,v4si,v4si)
21478 void __builtin_ia32_maskstoreq (pv2di,v2di,v2di)
21479 v8si __builtin_ia32_psllv8si (v8si,v8si)
21480 v4si __builtin_ia32_psllv4si (v4si,v4si)
21481 v4di __builtin_ia32_psllv4di (v4di,v4di)
21482 v2di __builtin_ia32_psllv2di (v2di,v2di)
21483 v8si __builtin_ia32_psrav8si (v8si,v8si)
21484 v4si __builtin_ia32_psrav4si (v4si,v4si)
21485 v8si __builtin_ia32_psrlv8si (v8si,v8si)
21486 v4si __builtin_ia32_psrlv4si (v4si,v4si)
21487 v4di __builtin_ia32_psrlv4di (v4di,v4di)
21488 v2di __builtin_ia32_psrlv2di (v2di,v2di)
21489 v2df __builtin_ia32_gathersiv2df (v2df, pcdouble,v4si,v2df,int)
21490 v4df __builtin_ia32_gathersiv4df (v4df, pcdouble,v4si,v4df,int)
21491 v2df __builtin_ia32_gatherdiv2df (v2df, pcdouble,v2di,v2df,int)
21492 v4df __builtin_ia32_gatherdiv4df (v4df, pcdouble,v4di,v4df,int)
21493 v4sf __builtin_ia32_gathersiv4sf (v4sf, pcfloat,v4si,v4sf,int)
21494 v8sf __builtin_ia32_gathersiv8sf (v8sf, pcfloat,v8si,v8sf,int)
21495 v4sf __builtin_ia32_gatherdiv4sf (v4sf, pcfloat,v2di,v4sf,int)
21496 v4sf __builtin_ia32_gatherdiv4sf256 (v4sf, pcfloat,v4di,v4sf,int)
21497 v2di __builtin_ia32_gathersiv2di (v2di, pcint64,v4si,v2di,int)
21498 v4di __builtin_ia32_gathersiv4di (v4di, pcint64,v4si,v4di,int)
21499 v2di __builtin_ia32_gatherdiv2di (v2di, pcint64,v2di,v2di,int)
21500 v4di __builtin_ia32_gatherdiv4di (v4di, pcint64,v4di,v4di,int)
21501 v4si __builtin_ia32_gathersiv4si (v4si, pcint,v4si,v4si,int)
21502 v8si __builtin_ia32_gathersiv8si (v8si, pcint,v8si,v8si,int)
21503 v4si __builtin_ia32_gatherdiv4si (v4si, pcint,v2di,v4si,int)
21504 v4si __builtin_ia32_gatherdiv4si256 (v4si, pcint,v4di,v4si,int)
21505 @end smallexample
21507 The following built-in functions are available when @option{-maes} is
21508 used.  All of them generate the machine instruction that is part of the
21509 name.
21511 @smallexample
21512 v2di __builtin_ia32_aesenc128 (v2di, v2di)
21513 v2di __builtin_ia32_aesenclast128 (v2di, v2di)
21514 v2di __builtin_ia32_aesdec128 (v2di, v2di)
21515 v2di __builtin_ia32_aesdeclast128 (v2di, v2di)
21516 v2di __builtin_ia32_aeskeygenassist128 (v2di, const int)
21517 v2di __builtin_ia32_aesimc128 (v2di)
21518 @end smallexample
21520 The following built-in function is available when @option{-mpclmul} is
21521 used.
21523 @table @code
21524 @item v2di __builtin_ia32_pclmulqdq128 (v2di, v2di, const int)
21525 Generates the @code{pclmulqdq} machine instruction.
21526 @end table
21528 The following built-in function is available when @option{-mfsgsbase} is
21529 used.  All of them generate the machine instruction that is part of the
21530 name.
21532 @smallexample
21533 unsigned int __builtin_ia32_rdfsbase32 (void)
21534 unsigned long long __builtin_ia32_rdfsbase64 (void)
21535 unsigned int __builtin_ia32_rdgsbase32 (void)
21536 unsigned long long __builtin_ia32_rdgsbase64 (void)
21537 void _writefsbase_u32 (unsigned int)
21538 void _writefsbase_u64 (unsigned long long)
21539 void _writegsbase_u32 (unsigned int)
21540 void _writegsbase_u64 (unsigned long long)
21541 @end smallexample
21543 The following built-in function is available when @option{-mrdrnd} is
21544 used.  All of them generate the machine instruction that is part of the
21545 name.
21547 @smallexample
21548 unsigned int __builtin_ia32_rdrand16_step (unsigned short *)
21549 unsigned int __builtin_ia32_rdrand32_step (unsigned int *)
21550 unsigned int __builtin_ia32_rdrand64_step (unsigned long long *)
21551 @end smallexample
21553 The following built-in functions are available when @option{-msse4a} is used.
21554 All of them generate the machine instruction that is part of the name.
21556 @smallexample
21557 void __builtin_ia32_movntsd (double *, v2df)
21558 void __builtin_ia32_movntss (float *, v4sf)
21559 v2di __builtin_ia32_extrq  (v2di, v16qi)
21560 v2di __builtin_ia32_extrqi (v2di, const unsigned int, const unsigned int)
21561 v2di __builtin_ia32_insertq (v2di, v2di)
21562 v2di __builtin_ia32_insertqi (v2di, v2di, const unsigned int, const unsigned int)
21563 @end smallexample
21565 The following built-in functions are available when @option{-mxop} is used.
21566 @smallexample
21567 v2df __builtin_ia32_vfrczpd (v2df)
21568 v4sf __builtin_ia32_vfrczps (v4sf)
21569 v2df __builtin_ia32_vfrczsd (v2df)
21570 v4sf __builtin_ia32_vfrczss (v4sf)
21571 v4df __builtin_ia32_vfrczpd256 (v4df)
21572 v8sf __builtin_ia32_vfrczps256 (v8sf)
21573 v2di __builtin_ia32_vpcmov (v2di, v2di, v2di)
21574 v2di __builtin_ia32_vpcmov_v2di (v2di, v2di, v2di)
21575 v4si __builtin_ia32_vpcmov_v4si (v4si, v4si, v4si)
21576 v8hi __builtin_ia32_vpcmov_v8hi (v8hi, v8hi, v8hi)
21577 v16qi __builtin_ia32_vpcmov_v16qi (v16qi, v16qi, v16qi)
21578 v2df __builtin_ia32_vpcmov_v2df (v2df, v2df, v2df)
21579 v4sf __builtin_ia32_vpcmov_v4sf (v4sf, v4sf, v4sf)
21580 v4di __builtin_ia32_vpcmov_v4di256 (v4di, v4di, v4di)
21581 v8si __builtin_ia32_vpcmov_v8si256 (v8si, v8si, v8si)
21582 v16hi __builtin_ia32_vpcmov_v16hi256 (v16hi, v16hi, v16hi)
21583 v32qi __builtin_ia32_vpcmov_v32qi256 (v32qi, v32qi, v32qi)
21584 v4df __builtin_ia32_vpcmov_v4df256 (v4df, v4df, v4df)
21585 v8sf __builtin_ia32_vpcmov_v8sf256 (v8sf, v8sf, v8sf)
21586 v16qi __builtin_ia32_vpcomeqb (v16qi, v16qi)
21587 v8hi __builtin_ia32_vpcomeqw (v8hi, v8hi)
21588 v4si __builtin_ia32_vpcomeqd (v4si, v4si)
21589 v2di __builtin_ia32_vpcomeqq (v2di, v2di)
21590 v16qi __builtin_ia32_vpcomequb (v16qi, v16qi)
21591 v4si __builtin_ia32_vpcomequd (v4si, v4si)
21592 v2di __builtin_ia32_vpcomequq (v2di, v2di)
21593 v8hi __builtin_ia32_vpcomequw (v8hi, v8hi)
21594 v8hi __builtin_ia32_vpcomeqw (v8hi, v8hi)
21595 v16qi __builtin_ia32_vpcomfalseb (v16qi, v16qi)
21596 v4si __builtin_ia32_vpcomfalsed (v4si, v4si)
21597 v2di __builtin_ia32_vpcomfalseq (v2di, v2di)
21598 v16qi __builtin_ia32_vpcomfalseub (v16qi, v16qi)
21599 v4si __builtin_ia32_vpcomfalseud (v4si, v4si)
21600 v2di __builtin_ia32_vpcomfalseuq (v2di, v2di)
21601 v8hi __builtin_ia32_vpcomfalseuw (v8hi, v8hi)
21602 v8hi __builtin_ia32_vpcomfalsew (v8hi, v8hi)
21603 v16qi __builtin_ia32_vpcomgeb (v16qi, v16qi)
21604 v4si __builtin_ia32_vpcomged (v4si, v4si)
21605 v2di __builtin_ia32_vpcomgeq (v2di, v2di)
21606 v16qi __builtin_ia32_vpcomgeub (v16qi, v16qi)
21607 v4si __builtin_ia32_vpcomgeud (v4si, v4si)
21608 v2di __builtin_ia32_vpcomgeuq (v2di, v2di)
21609 v8hi __builtin_ia32_vpcomgeuw (v8hi, v8hi)
21610 v8hi __builtin_ia32_vpcomgew (v8hi, v8hi)
21611 v16qi __builtin_ia32_vpcomgtb (v16qi, v16qi)
21612 v4si __builtin_ia32_vpcomgtd (v4si, v4si)
21613 v2di __builtin_ia32_vpcomgtq (v2di, v2di)
21614 v16qi __builtin_ia32_vpcomgtub (v16qi, v16qi)
21615 v4si __builtin_ia32_vpcomgtud (v4si, v4si)
21616 v2di __builtin_ia32_vpcomgtuq (v2di, v2di)
21617 v8hi __builtin_ia32_vpcomgtuw (v8hi, v8hi)
21618 v8hi __builtin_ia32_vpcomgtw (v8hi, v8hi)
21619 v16qi __builtin_ia32_vpcomleb (v16qi, v16qi)
21620 v4si __builtin_ia32_vpcomled (v4si, v4si)
21621 v2di __builtin_ia32_vpcomleq (v2di, v2di)
21622 v16qi __builtin_ia32_vpcomleub (v16qi, v16qi)
21623 v4si __builtin_ia32_vpcomleud (v4si, v4si)
21624 v2di __builtin_ia32_vpcomleuq (v2di, v2di)
21625 v8hi __builtin_ia32_vpcomleuw (v8hi, v8hi)
21626 v8hi __builtin_ia32_vpcomlew (v8hi, v8hi)
21627 v16qi __builtin_ia32_vpcomltb (v16qi, v16qi)
21628 v4si __builtin_ia32_vpcomltd (v4si, v4si)
21629 v2di __builtin_ia32_vpcomltq (v2di, v2di)
21630 v16qi __builtin_ia32_vpcomltub (v16qi, v16qi)
21631 v4si __builtin_ia32_vpcomltud (v4si, v4si)
21632 v2di __builtin_ia32_vpcomltuq (v2di, v2di)
21633 v8hi __builtin_ia32_vpcomltuw (v8hi, v8hi)
21634 v8hi __builtin_ia32_vpcomltw (v8hi, v8hi)
21635 v16qi __builtin_ia32_vpcomneb (v16qi, v16qi)
21636 v4si __builtin_ia32_vpcomned (v4si, v4si)
21637 v2di __builtin_ia32_vpcomneq (v2di, v2di)
21638 v16qi __builtin_ia32_vpcomneub (v16qi, v16qi)
21639 v4si __builtin_ia32_vpcomneud (v4si, v4si)
21640 v2di __builtin_ia32_vpcomneuq (v2di, v2di)
21641 v8hi __builtin_ia32_vpcomneuw (v8hi, v8hi)
21642 v8hi __builtin_ia32_vpcomnew (v8hi, v8hi)
21643 v16qi __builtin_ia32_vpcomtrueb (v16qi, v16qi)
21644 v4si __builtin_ia32_vpcomtrued (v4si, v4si)
21645 v2di __builtin_ia32_vpcomtrueq (v2di, v2di)
21646 v16qi __builtin_ia32_vpcomtrueub (v16qi, v16qi)
21647 v4si __builtin_ia32_vpcomtrueud (v4si, v4si)
21648 v2di __builtin_ia32_vpcomtrueuq (v2di, v2di)
21649 v8hi __builtin_ia32_vpcomtrueuw (v8hi, v8hi)
21650 v8hi __builtin_ia32_vpcomtruew (v8hi, v8hi)
21651 v4si __builtin_ia32_vphaddbd (v16qi)
21652 v2di __builtin_ia32_vphaddbq (v16qi)
21653 v8hi __builtin_ia32_vphaddbw (v16qi)
21654 v2di __builtin_ia32_vphadddq (v4si)
21655 v4si __builtin_ia32_vphaddubd (v16qi)
21656 v2di __builtin_ia32_vphaddubq (v16qi)
21657 v8hi __builtin_ia32_vphaddubw (v16qi)
21658 v2di __builtin_ia32_vphaddudq (v4si)
21659 v4si __builtin_ia32_vphadduwd (v8hi)
21660 v2di __builtin_ia32_vphadduwq (v8hi)
21661 v4si __builtin_ia32_vphaddwd (v8hi)
21662 v2di __builtin_ia32_vphaddwq (v8hi)
21663 v8hi __builtin_ia32_vphsubbw (v16qi)
21664 v2di __builtin_ia32_vphsubdq (v4si)
21665 v4si __builtin_ia32_vphsubwd (v8hi)
21666 v4si __builtin_ia32_vpmacsdd (v4si, v4si, v4si)
21667 v2di __builtin_ia32_vpmacsdqh (v4si, v4si, v2di)
21668 v2di __builtin_ia32_vpmacsdql (v4si, v4si, v2di)
21669 v4si __builtin_ia32_vpmacssdd (v4si, v4si, v4si)
21670 v2di __builtin_ia32_vpmacssdqh (v4si, v4si, v2di)
21671 v2di __builtin_ia32_vpmacssdql (v4si, v4si, v2di)
21672 v4si __builtin_ia32_vpmacsswd (v8hi, v8hi, v4si)
21673 v8hi __builtin_ia32_vpmacssww (v8hi, v8hi, v8hi)
21674 v4si __builtin_ia32_vpmacswd (v8hi, v8hi, v4si)
21675 v8hi __builtin_ia32_vpmacsww (v8hi, v8hi, v8hi)
21676 v4si __builtin_ia32_vpmadcsswd (v8hi, v8hi, v4si)
21677 v4si __builtin_ia32_vpmadcswd (v8hi, v8hi, v4si)
21678 v16qi __builtin_ia32_vpperm (v16qi, v16qi, v16qi)
21679 v16qi __builtin_ia32_vprotb (v16qi, v16qi)
21680 v4si __builtin_ia32_vprotd (v4si, v4si)
21681 v2di __builtin_ia32_vprotq (v2di, v2di)
21682 v8hi __builtin_ia32_vprotw (v8hi, v8hi)
21683 v16qi __builtin_ia32_vpshab (v16qi, v16qi)
21684 v4si __builtin_ia32_vpshad (v4si, v4si)
21685 v2di __builtin_ia32_vpshaq (v2di, v2di)
21686 v8hi __builtin_ia32_vpshaw (v8hi, v8hi)
21687 v16qi __builtin_ia32_vpshlb (v16qi, v16qi)
21688 v4si __builtin_ia32_vpshld (v4si, v4si)
21689 v2di __builtin_ia32_vpshlq (v2di, v2di)
21690 v8hi __builtin_ia32_vpshlw (v8hi, v8hi)
21691 @end smallexample
21693 The following built-in functions are available when @option{-mfma4} is used.
21694 All of them generate the machine instruction that is part of the name.
21696 @smallexample
21697 v2df __builtin_ia32_vfmaddpd (v2df, v2df, v2df)
21698 v4sf __builtin_ia32_vfmaddps (v4sf, v4sf, v4sf)
21699 v2df __builtin_ia32_vfmaddsd (v2df, v2df, v2df)
21700 v4sf __builtin_ia32_vfmaddss (v4sf, v4sf, v4sf)
21701 v2df __builtin_ia32_vfmsubpd (v2df, v2df, v2df)
21702 v4sf __builtin_ia32_vfmsubps (v4sf, v4sf, v4sf)
21703 v2df __builtin_ia32_vfmsubsd (v2df, v2df, v2df)
21704 v4sf __builtin_ia32_vfmsubss (v4sf, v4sf, v4sf)
21705 v2df __builtin_ia32_vfnmaddpd (v2df, v2df, v2df)
21706 v4sf __builtin_ia32_vfnmaddps (v4sf, v4sf, v4sf)
21707 v2df __builtin_ia32_vfnmaddsd (v2df, v2df, v2df)
21708 v4sf __builtin_ia32_vfnmaddss (v4sf, v4sf, v4sf)
21709 v2df __builtin_ia32_vfnmsubpd (v2df, v2df, v2df)
21710 v4sf __builtin_ia32_vfnmsubps (v4sf, v4sf, v4sf)
21711 v2df __builtin_ia32_vfnmsubsd (v2df, v2df, v2df)
21712 v4sf __builtin_ia32_vfnmsubss (v4sf, v4sf, v4sf)
21713 v2df __builtin_ia32_vfmaddsubpd  (v2df, v2df, v2df)
21714 v4sf __builtin_ia32_vfmaddsubps  (v4sf, v4sf, v4sf)
21715 v2df __builtin_ia32_vfmsubaddpd  (v2df, v2df, v2df)
21716 v4sf __builtin_ia32_vfmsubaddps  (v4sf, v4sf, v4sf)
21717 v4df __builtin_ia32_vfmaddpd256 (v4df, v4df, v4df)
21718 v8sf __builtin_ia32_vfmaddps256 (v8sf, v8sf, v8sf)
21719 v4df __builtin_ia32_vfmsubpd256 (v4df, v4df, v4df)
21720 v8sf __builtin_ia32_vfmsubps256 (v8sf, v8sf, v8sf)
21721 v4df __builtin_ia32_vfnmaddpd256 (v4df, v4df, v4df)
21722 v8sf __builtin_ia32_vfnmaddps256 (v8sf, v8sf, v8sf)
21723 v4df __builtin_ia32_vfnmsubpd256 (v4df, v4df, v4df)
21724 v8sf __builtin_ia32_vfnmsubps256 (v8sf, v8sf, v8sf)
21725 v4df __builtin_ia32_vfmaddsubpd256 (v4df, v4df, v4df)
21726 v8sf __builtin_ia32_vfmaddsubps256 (v8sf, v8sf, v8sf)
21727 v4df __builtin_ia32_vfmsubaddpd256 (v4df, v4df, v4df)
21728 v8sf __builtin_ia32_vfmsubaddps256 (v8sf, v8sf, v8sf)
21730 @end smallexample
21732 The following built-in functions are available when @option{-mlwp} is used.
21734 @smallexample
21735 void __builtin_ia32_llwpcb16 (void *);
21736 void __builtin_ia32_llwpcb32 (void *);
21737 void __builtin_ia32_llwpcb64 (void *);
21738 void * __builtin_ia32_llwpcb16 (void);
21739 void * __builtin_ia32_llwpcb32 (void);
21740 void * __builtin_ia32_llwpcb64 (void);
21741 void __builtin_ia32_lwpval16 (unsigned short, unsigned int, unsigned short)
21742 void __builtin_ia32_lwpval32 (unsigned int, unsigned int, unsigned int)
21743 void __builtin_ia32_lwpval64 (unsigned __int64, unsigned int, unsigned int)
21744 unsigned char __builtin_ia32_lwpins16 (unsigned short, unsigned int, unsigned short)
21745 unsigned char __builtin_ia32_lwpins32 (unsigned int, unsigned int, unsigned int)
21746 unsigned char __builtin_ia32_lwpins64 (unsigned __int64, unsigned int, unsigned int)
21747 @end smallexample
21749 The following built-in functions are available when @option{-mbmi} is used.
21750 All of them generate the machine instruction that is part of the name.
21751 @smallexample
21752 unsigned int __builtin_ia32_bextr_u32(unsigned int, unsigned int);
21753 unsigned long long __builtin_ia32_bextr_u64 (unsigned long long, unsigned long long);
21754 @end smallexample
21756 The following built-in functions are available when @option{-mbmi2} is used.
21757 All of them generate the machine instruction that is part of the name.
21758 @smallexample
21759 unsigned int _bzhi_u32 (unsigned int, unsigned int)
21760 unsigned int _pdep_u32 (unsigned int, unsigned int)
21761 unsigned int _pext_u32 (unsigned int, unsigned int)
21762 unsigned long long _bzhi_u64 (unsigned long long, unsigned long long)
21763 unsigned long long _pdep_u64 (unsigned long long, unsigned long long)
21764 unsigned long long _pext_u64 (unsigned long long, unsigned long long)
21765 @end smallexample
21767 The following built-in functions are available when @option{-mlzcnt} is used.
21768 All of them generate the machine instruction that is part of the name.
21769 @smallexample
21770 unsigned short __builtin_ia32_lzcnt_u16(unsigned short);
21771 unsigned int __builtin_ia32_lzcnt_u32(unsigned int);
21772 unsigned long long __builtin_ia32_lzcnt_u64 (unsigned long long);
21773 @end smallexample
21775 The following built-in functions are available when @option{-mfxsr} is used.
21776 All of them generate the machine instruction that is part of the name.
21777 @smallexample
21778 void __builtin_ia32_fxsave (void *)
21779 void __builtin_ia32_fxrstor (void *)
21780 void __builtin_ia32_fxsave64 (void *)
21781 void __builtin_ia32_fxrstor64 (void *)
21782 @end smallexample
21784 The following built-in functions are available when @option{-mxsave} is used.
21785 All of them generate the machine instruction that is part of the name.
21786 @smallexample
21787 void __builtin_ia32_xsave (void *, long long)
21788 void __builtin_ia32_xrstor (void *, long long)
21789 void __builtin_ia32_xsave64 (void *, long long)
21790 void __builtin_ia32_xrstor64 (void *, long long)
21791 @end smallexample
21793 The following built-in functions are available when @option{-mxsaveopt} is used.
21794 All of them generate the machine instruction that is part of the name.
21795 @smallexample
21796 void __builtin_ia32_xsaveopt (void *, long long)
21797 void __builtin_ia32_xsaveopt64 (void *, long long)
21798 @end smallexample
21800 The following built-in functions are available when @option{-mtbm} is used.
21801 Both of them generate the immediate form of the bextr machine instruction.
21802 @smallexample
21803 unsigned int __builtin_ia32_bextri_u32 (unsigned int,
21804                                         const unsigned int);
21805 unsigned long long __builtin_ia32_bextri_u64 (unsigned long long,
21806                                               const unsigned long long);
21807 @end smallexample
21810 The following built-in functions are available when @option{-m3dnow} is used.
21811 All of them generate the machine instruction that is part of the name.
21813 @smallexample
21814 void __builtin_ia32_femms (void)
21815 v8qi __builtin_ia32_pavgusb (v8qi, v8qi)
21816 v2si __builtin_ia32_pf2id (v2sf)
21817 v2sf __builtin_ia32_pfacc (v2sf, v2sf)
21818 v2sf __builtin_ia32_pfadd (v2sf, v2sf)
21819 v2si __builtin_ia32_pfcmpeq (v2sf, v2sf)
21820 v2si __builtin_ia32_pfcmpge (v2sf, v2sf)
21821 v2si __builtin_ia32_pfcmpgt (v2sf, v2sf)
21822 v2sf __builtin_ia32_pfmax (v2sf, v2sf)
21823 v2sf __builtin_ia32_pfmin (v2sf, v2sf)
21824 v2sf __builtin_ia32_pfmul (v2sf, v2sf)
21825 v2sf __builtin_ia32_pfrcp (v2sf)
21826 v2sf __builtin_ia32_pfrcpit1 (v2sf, v2sf)
21827 v2sf __builtin_ia32_pfrcpit2 (v2sf, v2sf)
21828 v2sf __builtin_ia32_pfrsqrt (v2sf)
21829 v2sf __builtin_ia32_pfsub (v2sf, v2sf)
21830 v2sf __builtin_ia32_pfsubr (v2sf, v2sf)
21831 v2sf __builtin_ia32_pi2fd (v2si)
21832 v4hi __builtin_ia32_pmulhrw (v4hi, v4hi)
21833 @end smallexample
21835 The following built-in functions are available when @option{-m3dnowa} is used.
21836 All of them generate the machine instruction that is part of the name.
21838 @smallexample
21839 v2si __builtin_ia32_pf2iw (v2sf)
21840 v2sf __builtin_ia32_pfnacc (v2sf, v2sf)
21841 v2sf __builtin_ia32_pfpnacc (v2sf, v2sf)
21842 v2sf __builtin_ia32_pi2fw (v2si)
21843 v2sf __builtin_ia32_pswapdsf (v2sf)
21844 v2si __builtin_ia32_pswapdsi (v2si)
21845 @end smallexample
21847 The following built-in functions are available when @option{-mrtm} is used
21848 They are used for restricted transactional memory. These are the internal
21849 low level functions. Normally the functions in 
21850 @ref{x86 transactional memory intrinsics} should be used instead.
21852 @smallexample
21853 int __builtin_ia32_xbegin ()
21854 void __builtin_ia32_xend ()
21855 void __builtin_ia32_xabort (status)
21856 int __builtin_ia32_xtest ()
21857 @end smallexample
21859 The following built-in functions are available when @option{-mmwaitx} is used.
21860 All of them generate the machine instruction that is part of the name.
21861 @smallexample
21862 void __builtin_ia32_monitorx (void *, unsigned int, unsigned int)
21863 void __builtin_ia32_mwaitx (unsigned int, unsigned int, unsigned int)
21864 @end smallexample
21866 The following built-in functions are available when @option{-mclzero} is used.
21867 All of them generate the machine instruction that is part of the name.
21868 @smallexample
21869 void __builtin_i32_clzero (void *)
21870 @end smallexample
21872 The following built-in functions are available when @option{-mpku} is used.
21873 They generate reads and writes to PKRU.
21874 @smallexample
21875 void __builtin_ia32_wrpkru (unsigned int)
21876 unsigned int __builtin_ia32_rdpkru ()
21877 @end smallexample
21879 The following built-in functions are available when @option{-mcet} or
21880 @option{-mshstk} option is used.  They support shadow stack
21881 machine instructions from Intel Control-flow Enforcement Technology (CET).
21882 Each built-in function generates the  machine instruction that is part
21883 of the function's name.  These are the internal low-level functions.
21884 Normally the functions in @ref{x86 control-flow protection intrinsics}
21885 should be used instead.
21887 @smallexample
21888 unsigned int __builtin_ia32_rdsspd (void)
21889 unsigned long long __builtin_ia32_rdsspq (void)
21890 void __builtin_ia32_incsspd (unsigned int)
21891 void __builtin_ia32_incsspq (unsigned long long)
21892 void __builtin_ia32_saveprevssp(void);
21893 void __builtin_ia32_rstorssp(void *);
21894 void __builtin_ia32_wrssd(unsigned int, void *);
21895 void __builtin_ia32_wrssq(unsigned long long, void *);
21896 void __builtin_ia32_wrussd(unsigned int, void *);
21897 void __builtin_ia32_wrussq(unsigned long long, void *);
21898 void __builtin_ia32_setssbsy(void);
21899 void __builtin_ia32_clrssbsy(void *);
21900 @end smallexample
21902 @node x86 transactional memory intrinsics
21903 @subsection x86 Transactional Memory Intrinsics
21905 These hardware transactional memory intrinsics for x86 allow you to use
21906 memory transactions with RTM (Restricted Transactional Memory).
21907 This support is enabled with the @option{-mrtm} option.
21908 For using HLE (Hardware Lock Elision) see 
21909 @ref{x86 specific memory model extensions for transactional memory} instead.
21911 A memory transaction commits all changes to memory in an atomic way,
21912 as visible to other threads. If the transaction fails it is rolled back
21913 and all side effects discarded.
21915 Generally there is no guarantee that a memory transaction ever succeeds
21916 and suitable fallback code always needs to be supplied.
21918 @deftypefn {RTM Function} {unsigned} _xbegin ()
21919 Start a RTM (Restricted Transactional Memory) transaction. 
21920 Returns @code{_XBEGIN_STARTED} when the transaction
21921 started successfully (note this is not 0, so the constant has to be 
21922 explicitly tested).  
21924 If the transaction aborts, all side effects
21925 are undone and an abort code encoded as a bit mask is returned.
21926 The following macros are defined:
21928 @table @code
21929 @item _XABORT_EXPLICIT
21930 Transaction was explicitly aborted with @code{_xabort}.  The parameter passed
21931 to @code{_xabort} is available with @code{_XABORT_CODE(status)}.
21932 @item _XABORT_RETRY
21933 Transaction retry is possible.
21934 @item _XABORT_CONFLICT
21935 Transaction abort due to a memory conflict with another thread.
21936 @item _XABORT_CAPACITY
21937 Transaction abort due to the transaction using too much memory.
21938 @item _XABORT_DEBUG
21939 Transaction abort due to a debug trap.
21940 @item _XABORT_NESTED
21941 Transaction abort in an inner nested transaction.
21942 @end table
21944 There is no guarantee
21945 any transaction ever succeeds, so there always needs to be a valid
21946 fallback path.
21947 @end deftypefn
21949 @deftypefn {RTM Function} {void} _xend ()
21950 Commit the current transaction. When no transaction is active this faults.
21951 All memory side effects of the transaction become visible
21952 to other threads in an atomic manner.
21953 @end deftypefn
21955 @deftypefn {RTM Function} {int} _xtest ()
21956 Return a nonzero value if a transaction is currently active, otherwise 0.
21957 @end deftypefn
21959 @deftypefn {RTM Function} {void} _xabort (status)
21960 Abort the current transaction. When no transaction is active this is a no-op.
21961 The @var{status} is an 8-bit constant; its value is encoded in the return 
21962 value from @code{_xbegin}.
21963 @end deftypefn
21965 Here is an example showing handling for @code{_XABORT_RETRY}
21966 and a fallback path for other failures:
21968 @smallexample
21969 #include <immintrin.h>
21971 int n_tries, max_tries;
21972 unsigned status = _XABORT_EXPLICIT;
21975 for (n_tries = 0; n_tries < max_tries; n_tries++) 
21976   @{
21977     status = _xbegin ();
21978     if (status == _XBEGIN_STARTED || !(status & _XABORT_RETRY))
21979       break;
21980   @}
21981 if (status == _XBEGIN_STARTED) 
21982   @{
21983     ... transaction code...
21984     _xend ();
21985   @} 
21986 else 
21987   @{
21988     ... non-transactional fallback path...
21989   @}
21990 @end smallexample
21992 @noindent
21993 Note that, in most cases, the transactional and non-transactional code
21994 must synchronize together to ensure consistency.
21996 @node x86 control-flow protection intrinsics
21997 @subsection x86 Control-Flow Protection Intrinsics
21999 @deftypefn {CET Function} {ret_type} _get_ssp (void)
22000 Get the current value of shadow stack pointer if shadow stack support
22001 from Intel CET is enabled in the hardware or @code{0} otherwise.
22002 The @code{ret_type} is @code{unsigned long long} for 64-bit targets 
22003 and @code{unsigned int} for 32-bit targets.
22004 @end deftypefn
22006 @deftypefn {CET Function} void _inc_ssp (unsigned int)
22007 Increment the current shadow stack pointer by the size specified by the
22008 function argument.  The argument is masked to a byte value for security
22009 reasons, so to increment by more than 255 bytes you must call the function
22010 multiple times.
22011 @end deftypefn
22013 The shadow stack unwind code looks like:
22015 @smallexample
22016 #include <immintrin.h>
22018 /* Unwind the shadow stack for EH.  */
22019 #define _Unwind_Frames_Extra(x)       \
22020   do                                  \
22021     @{                                \
22022       _Unwind_Word ssp = _get_ssp (); \
22023       if (ssp != 0)                   \
22024         @{                            \
22025           _Unwind_Word tmp = (x);     \
22026           while (tmp > 255)           \
22027             @{                        \
22028               _inc_ssp (tmp);         \
22029               tmp -= 255;             \
22030             @}                        \
22031           _inc_ssp (tmp);             \
22032         @}                            \
22033     @}                                \
22034     while (0)
22035 @end smallexample
22037 @noindent
22038 This code runs unconditionally on all 64-bit processors.  For 32-bit
22039 processors the code runs on those that support multi-byte NOP instructions.
22041 @node Target Format Checks
22042 @section Format Checks Specific to Particular Target Machines
22044 For some target machines, GCC supports additional options to the
22045 format attribute
22046 (@pxref{Function Attributes,,Declaring Attributes of Functions}).
22048 @menu
22049 * Solaris Format Checks::
22050 * Darwin Format Checks::
22051 @end menu
22053 @node Solaris Format Checks
22054 @subsection Solaris Format Checks
22056 Solaris targets support the @code{cmn_err} (or @code{__cmn_err__}) format
22057 check.  @code{cmn_err} accepts a subset of the standard @code{printf}
22058 conversions, and the two-argument @code{%b} conversion for displaying
22059 bit-fields.  See the Solaris man page for @code{cmn_err} for more information.
22061 @node Darwin Format Checks
22062 @subsection Darwin Format Checks
22064 Darwin targets support the @code{CFString} (or @code{__CFString__}) in the format
22065 attribute context.  Declarations made with such attribution are parsed for correct syntax
22066 and format argument types.  However, parsing of the format string itself is currently undefined
22067 and is not carried out by this version of the compiler.
22069 Additionally, @code{CFStringRefs} (defined by the @code{CoreFoundation} headers) may
22070 also be used as format arguments.  Note that the relevant headers are only likely to be
22071 available on Darwin (OSX) installations.  On such installations, the XCode and system
22072 documentation provide descriptions of @code{CFString}, @code{CFStringRefs} and
22073 associated functions.
22075 @node Pragmas
22076 @section Pragmas Accepted by GCC
22077 @cindex pragmas
22078 @cindex @code{#pragma}
22080 GCC supports several types of pragmas, primarily in order to compile
22081 code originally written for other compilers.  Note that in general
22082 we do not recommend the use of pragmas; @xref{Function Attributes},
22083 for further explanation.
22085 @menu
22086 * AArch64 Pragmas::
22087 * ARM Pragmas::
22088 * M32C Pragmas::
22089 * MeP Pragmas::
22090 * RS/6000 and PowerPC Pragmas::
22091 * S/390 Pragmas::
22092 * Darwin Pragmas::
22093 * Solaris Pragmas::
22094 * Symbol-Renaming Pragmas::
22095 * Structure-Layout Pragmas::
22096 * Weak Pragmas::
22097 * Diagnostic Pragmas::
22098 * Visibility Pragmas::
22099 * Push/Pop Macro Pragmas::
22100 * Function Specific Option Pragmas::
22101 * Loop-Specific Pragmas::
22102 @end menu
22104 @node AArch64 Pragmas
22105 @subsection AArch64 Pragmas
22107 The pragmas defined by the AArch64 target correspond to the AArch64
22108 target function attributes.  They can be specified as below:
22109 @smallexample
22110 #pragma GCC target("string")
22111 @end smallexample
22113 where @code{@var{string}} can be any string accepted as an AArch64 target
22114 attribute.  @xref{AArch64 Function Attributes}, for more details
22115 on the permissible values of @code{string}.
22117 @node ARM Pragmas
22118 @subsection ARM Pragmas
22120 The ARM target defines pragmas for controlling the default addition of
22121 @code{long_call} and @code{short_call} attributes to functions.
22122 @xref{Function Attributes}, for information about the effects of these
22123 attributes.
22125 @table @code
22126 @item long_calls
22127 @cindex pragma, long_calls
22128 Set all subsequent functions to have the @code{long_call} attribute.
22130 @item no_long_calls
22131 @cindex pragma, no_long_calls
22132 Set all subsequent functions to have the @code{short_call} attribute.
22134 @item long_calls_off
22135 @cindex pragma, long_calls_off
22136 Do not affect the @code{long_call} or @code{short_call} attributes of
22137 subsequent functions.
22138 @end table
22140 @node M32C Pragmas
22141 @subsection M32C Pragmas
22143 @table @code
22144 @item GCC memregs @var{number}
22145 @cindex pragma, memregs
22146 Overrides the command-line option @code{-memregs=} for the current
22147 file.  Use with care!  This pragma must be before any function in the
22148 file, and mixing different memregs values in different objects may
22149 make them incompatible.  This pragma is useful when a
22150 performance-critical function uses a memreg for temporary values,
22151 as it may allow you to reduce the number of memregs used.
22153 @item ADDRESS @var{name} @var{address}
22154 @cindex pragma, address
22155 For any declared symbols matching @var{name}, this does three things
22156 to that symbol: it forces the symbol to be located at the given
22157 address (a number), it forces the symbol to be volatile, and it
22158 changes the symbol's scope to be static.  This pragma exists for
22159 compatibility with other compilers, but note that the common
22160 @code{1234H} numeric syntax is not supported (use @code{0x1234}
22161 instead).  Example:
22163 @smallexample
22164 #pragma ADDRESS port3 0x103
22165 char port3;
22166 @end smallexample
22168 @end table
22170 @node MeP Pragmas
22171 @subsection MeP Pragmas
22173 @table @code
22175 @item custom io_volatile (on|off)
22176 @cindex pragma, custom io_volatile
22177 Overrides the command-line option @code{-mio-volatile} for the current
22178 file.  Note that for compatibility with future GCC releases, this
22179 option should only be used once before any @code{io} variables in each
22180 file.
22182 @item GCC coprocessor available @var{registers}
22183 @cindex pragma, coprocessor available
22184 Specifies which coprocessor registers are available to the register
22185 allocator.  @var{registers} may be a single register, register range
22186 separated by ellipses, or comma-separated list of those.  Example:
22188 @smallexample
22189 #pragma GCC coprocessor available $c0...$c10, $c28
22190 @end smallexample
22192 @item GCC coprocessor call_saved @var{registers}
22193 @cindex pragma, coprocessor call_saved
22194 Specifies which coprocessor registers are to be saved and restored by
22195 any function using them.  @var{registers} may be a single register,
22196 register range separated by ellipses, or comma-separated list of
22197 those.  Example:
22199 @smallexample
22200 #pragma GCC coprocessor call_saved $c4...$c6, $c31
22201 @end smallexample
22203 @item GCC coprocessor subclass '(A|B|C|D)' = @var{registers}
22204 @cindex pragma, coprocessor subclass
22205 Creates and defines a register class.  These register classes can be
22206 used by inline @code{asm} constructs.  @var{registers} may be a single
22207 register, register range separated by ellipses, or comma-separated
22208 list of those.  Example:
22210 @smallexample
22211 #pragma GCC coprocessor subclass 'B' = $c2, $c4, $c6
22213 asm ("cpfoo %0" : "=B" (x));
22214 @end smallexample
22216 @item GCC disinterrupt @var{name} , @var{name} @dots{}
22217 @cindex pragma, disinterrupt
22218 For the named functions, the compiler adds code to disable interrupts
22219 for the duration of those functions.  If any functions so named 
22220 are not encountered in the source, a warning is emitted that the pragma is
22221 not used.  Examples:
22223 @smallexample
22224 #pragma disinterrupt foo
22225 #pragma disinterrupt bar, grill
22226 int foo () @{ @dots{} @}
22227 @end smallexample
22229 @item GCC call @var{name} , @var{name} @dots{}
22230 @cindex pragma, call
22231 For the named functions, the compiler always uses a register-indirect
22232 call model when calling the named functions.  Examples:
22234 @smallexample
22235 extern int foo ();
22236 #pragma call foo
22237 @end smallexample
22239 @end table
22241 @node RS/6000 and PowerPC Pragmas
22242 @subsection RS/6000 and PowerPC Pragmas
22244 The RS/6000 and PowerPC targets define one pragma for controlling
22245 whether or not the @code{longcall} attribute is added to function
22246 declarations by default.  This pragma overrides the @option{-mlongcall}
22247 option, but not the @code{longcall} and @code{shortcall} attributes.
22248 @xref{RS/6000 and PowerPC Options}, for more information about when long
22249 calls are and are not necessary.
22251 @table @code
22252 @item longcall (1)
22253 @cindex pragma, longcall
22254 Apply the @code{longcall} attribute to all subsequent function
22255 declarations.
22257 @item longcall (0)
22258 Do not apply the @code{longcall} attribute to subsequent function
22259 declarations.
22260 @end table
22262 @c Describe h8300 pragmas here.
22263 @c Describe sh pragmas here.
22264 @c Describe v850 pragmas here.
22266 @node S/390 Pragmas
22267 @subsection S/390 Pragmas
22269 The pragmas defined by the S/390 target correspond to the S/390
22270 target function attributes and some the additional options:
22272 @table @samp
22273 @item zvector
22274 @itemx no-zvector
22275 @end table
22277 Note that options of the pragma, unlike options of the target
22278 attribute, do change the value of preprocessor macros like
22279 @code{__VEC__}.  They can be specified as below:
22281 @smallexample
22282 #pragma GCC target("string[,string]...")
22283 #pragma GCC target("string"[,"string"]...)
22284 @end smallexample
22286 @node Darwin Pragmas
22287 @subsection Darwin Pragmas
22289 The following pragmas are available for all architectures running the
22290 Darwin operating system.  These are useful for compatibility with other
22291 Mac OS compilers.
22293 @table @code
22294 @item mark @var{tokens}@dots{}
22295 @cindex pragma, mark
22296 This pragma is accepted, but has no effect.
22298 @item options align=@var{alignment}
22299 @cindex pragma, options align
22300 This pragma sets the alignment of fields in structures.  The values of
22301 @var{alignment} may be @code{mac68k}, to emulate m68k alignment, or
22302 @code{power}, to emulate PowerPC alignment.  Uses of this pragma nest
22303 properly; to restore the previous setting, use @code{reset} for the
22304 @var{alignment}.
22306 @item segment @var{tokens}@dots{}
22307 @cindex pragma, segment
22308 This pragma is accepted, but has no effect.
22310 @item unused (@var{var} [, @var{var}]@dots{})
22311 @cindex pragma, unused
22312 This pragma declares variables to be possibly unused.  GCC does not
22313 produce warnings for the listed variables.  The effect is similar to
22314 that of the @code{unused} attribute, except that this pragma may appear
22315 anywhere within the variables' scopes.
22316 @end table
22318 @node Solaris Pragmas
22319 @subsection Solaris Pragmas
22321 The Solaris target supports @code{#pragma redefine_extname}
22322 (@pxref{Symbol-Renaming Pragmas}).  It also supports additional
22323 @code{#pragma} directives for compatibility with the system compiler.
22325 @table @code
22326 @item align @var{alignment} (@var{variable} [, @var{variable}]...)
22327 @cindex pragma, align
22329 Increase the minimum alignment of each @var{variable} to @var{alignment}.
22330 This is the same as GCC's @code{aligned} attribute @pxref{Variable
22331 Attributes}).  Macro expansion occurs on the arguments to this pragma
22332 when compiling C and Objective-C@.  It does not currently occur when
22333 compiling C++, but this is a bug which may be fixed in a future
22334 release.
22336 @item fini (@var{function} [, @var{function}]...)
22337 @cindex pragma, fini
22339 This pragma causes each listed @var{function} to be called after
22340 main, or during shared module unloading, by adding a call to the
22341 @code{.fini} section.
22343 @item init (@var{function} [, @var{function}]...)
22344 @cindex pragma, init
22346 This pragma causes each listed @var{function} to be called during
22347 initialization (before @code{main}) or during shared module loading, by
22348 adding a call to the @code{.init} section.
22350 @end table
22352 @node Symbol-Renaming Pragmas
22353 @subsection Symbol-Renaming Pragmas
22355 GCC supports a @code{#pragma} directive that changes the name used in
22356 assembly for a given declaration. While this pragma is supported on all
22357 platforms, it is intended primarily to provide compatibility with the
22358 Solaris system headers. This effect can also be achieved using the asm
22359 labels extension (@pxref{Asm Labels}).
22361 @table @code
22362 @item redefine_extname @var{oldname} @var{newname}
22363 @cindex pragma, redefine_extname
22365 This pragma gives the C function @var{oldname} the assembly symbol
22366 @var{newname}.  The preprocessor macro @code{__PRAGMA_REDEFINE_EXTNAME}
22367 is defined if this pragma is available (currently on all platforms).
22368 @end table
22370 This pragma and the asm labels extension interact in a complicated
22371 manner.  Here are some corner cases you may want to be aware of:
22373 @enumerate
22374 @item This pragma silently applies only to declarations with external
22375 linkage.  Asm labels do not have this restriction.
22377 @item In C++, this pragma silently applies only to declarations with
22378 ``C'' linkage.  Again, asm labels do not have this restriction.
22380 @item If either of the ways of changing the assembly name of a
22381 declaration are applied to a declaration whose assembly name has
22382 already been determined (either by a previous use of one of these
22383 features, or because the compiler needed the assembly name in order to
22384 generate code), and the new name is different, a warning issues and
22385 the name does not change.
22387 @item The @var{oldname} used by @code{#pragma redefine_extname} is
22388 always the C-language name.
22389 @end enumerate
22391 @node Structure-Layout Pragmas
22392 @subsection Structure-Layout Pragmas
22394 For compatibility with Microsoft Windows compilers, GCC supports a
22395 set of @code{#pragma} directives that change the maximum alignment of
22396 members of structures (other than zero-width bit-fields), unions, and
22397 classes subsequently defined. The @var{n} value below always is required
22398 to be a small power of two and specifies the new alignment in bytes.
22400 @enumerate
22401 @item @code{#pragma pack(@var{n})} simply sets the new alignment.
22402 @item @code{#pragma pack()} sets the alignment to the one that was in
22403 effect when compilation started (see also command-line option
22404 @option{-fpack-struct[=@var{n}]} @pxref{Code Gen Options}).
22405 @item @code{#pragma pack(push[,@var{n}])} pushes the current alignment
22406 setting on an internal stack and then optionally sets the new alignment.
22407 @item @code{#pragma pack(pop)} restores the alignment setting to the one
22408 saved at the top of the internal stack (and removes that stack entry).
22409 Note that @code{#pragma pack([@var{n}])} does not influence this internal
22410 stack; thus it is possible to have @code{#pragma pack(push)} followed by
22411 multiple @code{#pragma pack(@var{n})} instances and finalized by a single
22412 @code{#pragma pack(pop)}.
22413 @end enumerate
22415 Some targets, e.g.@: x86 and PowerPC, support the @code{#pragma ms_struct}
22416 directive which lays out structures and unions subsequently defined as the
22417 documented @code{__attribute__ ((ms_struct))}.
22419 @enumerate
22420 @item @code{#pragma ms_struct on} turns on the Microsoft layout.
22421 @item @code{#pragma ms_struct off} turns off the Microsoft layout.
22422 @item @code{#pragma ms_struct reset} goes back to the default layout.
22423 @end enumerate
22425 Most targets also support the @code{#pragma scalar_storage_order} directive
22426 which lays out structures and unions subsequently defined as the documented
22427 @code{__attribute__ ((scalar_storage_order))}.
22429 @enumerate
22430 @item @code{#pragma scalar_storage_order big-endian} sets the storage order
22431 of the scalar fields to big-endian.
22432 @item @code{#pragma scalar_storage_order little-endian} sets the storage order
22433 of the scalar fields to little-endian.
22434 @item @code{#pragma scalar_storage_order default} goes back to the endianness
22435 that was in effect when compilation started (see also command-line option
22436 @option{-fsso-struct=@var{endianness}} @pxref{C Dialect Options}).
22437 @end enumerate
22439 @node Weak Pragmas
22440 @subsection Weak Pragmas
22442 For compatibility with SVR4, GCC supports a set of @code{#pragma}
22443 directives for declaring symbols to be weak, and defining weak
22444 aliases.
22446 @table @code
22447 @item #pragma weak @var{symbol}
22448 @cindex pragma, weak
22449 This pragma declares @var{symbol} to be weak, as if the declaration
22450 had the attribute of the same name.  The pragma may appear before
22451 or after the declaration of @var{symbol}.  It is not an error for
22452 @var{symbol} to never be defined at all.
22454 @item #pragma weak @var{symbol1} = @var{symbol2}
22455 This pragma declares @var{symbol1} to be a weak alias of @var{symbol2}.
22456 It is an error if @var{symbol2} is not defined in the current
22457 translation unit.
22458 @end table
22460 @node Diagnostic Pragmas
22461 @subsection Diagnostic Pragmas
22463 GCC allows the user to selectively enable or disable certain types of
22464 diagnostics, and change the kind of the diagnostic.  For example, a
22465 project's policy might require that all sources compile with
22466 @option{-Werror} but certain files might have exceptions allowing
22467 specific types of warnings.  Or, a project might selectively enable
22468 diagnostics and treat them as errors depending on which preprocessor
22469 macros are defined.
22471 @table @code
22472 @item #pragma GCC diagnostic @var{kind} @var{option}
22473 @cindex pragma, diagnostic
22475 Modifies the disposition of a diagnostic.  Note that not all
22476 diagnostics are modifiable; at the moment only warnings (normally
22477 controlled by @samp{-W@dots{}}) can be controlled, and not all of them.
22478 Use @option{-fdiagnostics-show-option} to determine which diagnostics
22479 are controllable and which option controls them.
22481 @var{kind} is @samp{error} to treat this diagnostic as an error,
22482 @samp{warning} to treat it like a warning (even if @option{-Werror} is
22483 in effect), or @samp{ignored} if the diagnostic is to be ignored.
22484 @var{option} is a double quoted string that matches the command-line
22485 option.
22487 @smallexample
22488 #pragma GCC diagnostic warning "-Wformat"
22489 #pragma GCC diagnostic error "-Wformat"
22490 #pragma GCC diagnostic ignored "-Wformat"
22491 @end smallexample
22493 Note that these pragmas override any command-line options.  GCC keeps
22494 track of the location of each pragma, and issues diagnostics according
22495 to the state as of that point in the source file.  Thus, pragmas occurring
22496 after a line do not affect diagnostics caused by that line.
22498 @item #pragma GCC diagnostic push
22499 @itemx #pragma GCC diagnostic pop
22501 Causes GCC to remember the state of the diagnostics as of each
22502 @code{push}, and restore to that point at each @code{pop}.  If a
22503 @code{pop} has no matching @code{push}, the command-line options are
22504 restored.
22506 @smallexample
22507 #pragma GCC diagnostic error "-Wuninitialized"
22508   foo(a);                       /* error is given for this one */
22509 #pragma GCC diagnostic push
22510 #pragma GCC diagnostic ignored "-Wuninitialized"
22511   foo(b);                       /* no diagnostic for this one */
22512 #pragma GCC diagnostic pop
22513   foo(c);                       /* error is given for this one */
22514 #pragma GCC diagnostic pop
22515   foo(d);                       /* depends on command-line options */
22516 @end smallexample
22518 @end table
22520 GCC also offers a simple mechanism for printing messages during
22521 compilation.
22523 @table @code
22524 @item #pragma message @var{string}
22525 @cindex pragma, diagnostic
22527 Prints @var{string} as a compiler message on compilation.  The message
22528 is informational only, and is neither a compilation warning nor an error.
22530 @smallexample
22531 #pragma message "Compiling " __FILE__ "..."
22532 @end smallexample
22534 @var{string} may be parenthesized, and is printed with location
22535 information.  For example,
22537 @smallexample
22538 #define DO_PRAGMA(x) _Pragma (#x)
22539 #define TODO(x) DO_PRAGMA(message ("TODO - " #x))
22541 TODO(Remember to fix this)
22542 @end smallexample
22544 @noindent
22545 prints @samp{/tmp/file.c:4: note: #pragma message:
22546 TODO - Remember to fix this}.
22548 @end table
22550 @node Visibility Pragmas
22551 @subsection Visibility Pragmas
22553 @table @code
22554 @item #pragma GCC visibility push(@var{visibility})
22555 @itemx #pragma GCC visibility pop
22556 @cindex pragma, visibility
22558 This pragma allows the user to set the visibility for multiple
22559 declarations without having to give each a visibility attribute
22560 (@pxref{Function Attributes}).
22562 In C++, @samp{#pragma GCC visibility} affects only namespace-scope
22563 declarations.  Class members and template specializations are not
22564 affected; if you want to override the visibility for a particular
22565 member or instantiation, you must use an attribute.
22567 @end table
22570 @node Push/Pop Macro Pragmas
22571 @subsection Push/Pop Macro Pragmas
22573 For compatibility with Microsoft Windows compilers, GCC supports
22574 @samp{#pragma push_macro(@var{"macro_name"})}
22575 and @samp{#pragma pop_macro(@var{"macro_name"})}.
22577 @table @code
22578 @item #pragma push_macro(@var{"macro_name"})
22579 @cindex pragma, push_macro
22580 This pragma saves the value of the macro named as @var{macro_name} to
22581 the top of the stack for this macro.
22583 @item #pragma pop_macro(@var{"macro_name"})
22584 @cindex pragma, pop_macro
22585 This pragma sets the value of the macro named as @var{macro_name} to
22586 the value on top of the stack for this macro. If the stack for
22587 @var{macro_name} is empty, the value of the macro remains unchanged.
22588 @end table
22590 For example:
22592 @smallexample
22593 #define X  1
22594 #pragma push_macro("X")
22595 #undef X
22596 #define X -1
22597 #pragma pop_macro("X")
22598 int x [X];
22599 @end smallexample
22601 @noindent
22602 In this example, the definition of X as 1 is saved by @code{#pragma
22603 push_macro} and restored by @code{#pragma pop_macro}.
22605 @node Function Specific Option Pragmas
22606 @subsection Function Specific Option Pragmas
22608 @table @code
22609 @item #pragma GCC target (@var{"string"}...)
22610 @cindex pragma GCC target
22612 This pragma allows you to set target specific options for functions
22613 defined later in the source file.  One or more strings can be
22614 specified.  Each function that is defined after this point is as
22615 if @code{attribute((target("STRING")))} was specified for that
22616 function.  The parenthesis around the options is optional.
22617 @xref{Function Attributes}, for more information about the
22618 @code{target} attribute and the attribute syntax.
22620 The @code{#pragma GCC target} pragma is presently implemented for
22621 x86, ARM, AArch64, PowerPC, S/390, and Nios II targets only.
22623 @item #pragma GCC optimize (@var{"string"}...)
22624 @cindex pragma GCC optimize
22626 This pragma allows you to set global optimization options for functions
22627 defined later in the source file.  One or more strings can be
22628 specified.  Each function that is defined after this point is as
22629 if @code{attribute((optimize("STRING")))} was specified for that
22630 function.  The parenthesis around the options is optional.
22631 @xref{Function Attributes}, for more information about the
22632 @code{optimize} attribute and the attribute syntax.
22634 @item #pragma GCC push_options
22635 @itemx #pragma GCC pop_options
22636 @cindex pragma GCC push_options
22637 @cindex pragma GCC pop_options
22639 These pragmas maintain a stack of the current target and optimization
22640 options.  It is intended for include files where you temporarily want
22641 to switch to using a different @samp{#pragma GCC target} or
22642 @samp{#pragma GCC optimize} and then to pop back to the previous
22643 options.
22645 @item #pragma GCC reset_options
22646 @cindex pragma GCC reset_options
22648 This pragma clears the current @code{#pragma GCC target} and
22649 @code{#pragma GCC optimize} to use the default switches as specified
22650 on the command line.
22652 @end table
22654 @node Loop-Specific Pragmas
22655 @subsection Loop-Specific Pragmas
22657 @table @code
22658 @item #pragma GCC ivdep
22659 @cindex pragma GCC ivdep
22661 With this pragma, the programmer asserts that there are no loop-carried
22662 dependencies which would prevent consecutive iterations of
22663 the following loop from executing concurrently with SIMD
22664 (single instruction multiple data) instructions.
22666 For example, the compiler can only unconditionally vectorize the following
22667 loop with the pragma:
22669 @smallexample
22670 void foo (int n, int *a, int *b, int *c)
22672   int i, j;
22673 #pragma GCC ivdep
22674   for (i = 0; i < n; ++i)
22675     a[i] = b[i] + c[i];
22677 @end smallexample
22679 @noindent
22680 In this example, using the @code{restrict} qualifier had the same
22681 effect. In the following example, that would not be possible. Assume
22682 @math{k < -m} or @math{k >= m}. Only with the pragma, the compiler knows
22683 that it can unconditionally vectorize the following loop:
22685 @smallexample
22686 void ignore_vec_dep (int *a, int k, int c, int m)
22688 #pragma GCC ivdep
22689   for (int i = 0; i < m; i++)
22690     a[i] = a[i + k] * c;
22692 @end smallexample
22694 @item #pragma GCC unroll @var{n}
22695 @cindex pragma GCC unroll @var{n}
22697 You can use this pragma to control how many times a loop should be unrolled.
22698 It must be placed immediately before a @code{for}, @code{while} or @code{do}
22699 loop or a @code{#pragma GCC ivdep}, and applies only to the loop that follows.
22700 @var{n} is an integer constant expression specifying the unrolling factor.
22701 The values of @math{0} and @math{1} block any unrolling of the loop.
22703 @end table
22705 @node Unnamed Fields
22706 @section Unnamed Structure and Union Fields
22707 @cindex @code{struct}
22708 @cindex @code{union}
22710 As permitted by ISO C11 and for compatibility with other compilers,
22711 GCC allows you to define
22712 a structure or union that contains, as fields, structures and unions
22713 without names.  For example:
22715 @smallexample
22716 struct @{
22717   int a;
22718   union @{
22719     int b;
22720     float c;
22721   @};
22722   int d;
22723 @} foo;
22724 @end smallexample
22726 @noindent
22727 In this example, you are able to access members of the unnamed
22728 union with code like @samp{foo.b}.  Note that only unnamed structs and
22729 unions are allowed, you may not have, for example, an unnamed
22730 @code{int}.
22732 You must never create such structures that cause ambiguous field definitions.
22733 For example, in this structure:
22735 @smallexample
22736 struct @{
22737   int a;
22738   struct @{
22739     int a;
22740   @};
22741 @} foo;
22742 @end smallexample
22744 @noindent
22745 it is ambiguous which @code{a} is being referred to with @samp{foo.a}.
22746 The compiler gives errors for such constructs.
22748 @opindex fms-extensions
22749 Unless @option{-fms-extensions} is used, the unnamed field must be a
22750 structure or union definition without a tag (for example, @samp{struct
22751 @{ int a; @};}).  If @option{-fms-extensions} is used, the field may
22752 also be a definition with a tag such as @samp{struct foo @{ int a;
22753 @};}, a reference to a previously defined structure or union such as
22754 @samp{struct foo;}, or a reference to a @code{typedef} name for a
22755 previously defined structure or union type.
22757 @opindex fplan9-extensions
22758 The option @option{-fplan9-extensions} enables
22759 @option{-fms-extensions} as well as two other extensions.  First, a
22760 pointer to a structure is automatically converted to a pointer to an
22761 anonymous field for assignments and function calls.  For example:
22763 @smallexample
22764 struct s1 @{ int a; @};
22765 struct s2 @{ struct s1; @};
22766 extern void f1 (struct s1 *);
22767 void f2 (struct s2 *p) @{ f1 (p); @}
22768 @end smallexample
22770 @noindent
22771 In the call to @code{f1} inside @code{f2}, the pointer @code{p} is
22772 converted into a pointer to the anonymous field.
22774 Second, when the type of an anonymous field is a @code{typedef} for a
22775 @code{struct} or @code{union}, code may refer to the field using the
22776 name of the @code{typedef}.
22778 @smallexample
22779 typedef struct @{ int a; @} s1;
22780 struct s2 @{ s1; @};
22781 s1 f1 (struct s2 *p) @{ return p->s1; @}
22782 @end smallexample
22784 These usages are only permitted when they are not ambiguous.
22786 @node Thread-Local
22787 @section Thread-Local Storage
22788 @cindex Thread-Local Storage
22789 @cindex @acronym{TLS}
22790 @cindex @code{__thread}
22792 Thread-local storage (@acronym{TLS}) is a mechanism by which variables
22793 are allocated such that there is one instance of the variable per extant
22794 thread.  The runtime model GCC uses to implement this originates
22795 in the IA-64 processor-specific ABI, but has since been migrated
22796 to other processors as well.  It requires significant support from
22797 the linker (@command{ld}), dynamic linker (@command{ld.so}), and
22798 system libraries (@file{libc.so} and @file{libpthread.so}), so it
22799 is not available everywhere.
22801 At the user level, the extension is visible with a new storage
22802 class keyword: @code{__thread}.  For example:
22804 @smallexample
22805 __thread int i;
22806 extern __thread struct state s;
22807 static __thread char *p;
22808 @end smallexample
22810 The @code{__thread} specifier may be used alone, with the @code{extern}
22811 or @code{static} specifiers, but with no other storage class specifier.
22812 When used with @code{extern} or @code{static}, @code{__thread} must appear
22813 immediately after the other storage class specifier.
22815 The @code{__thread} specifier may be applied to any global, file-scoped
22816 static, function-scoped static, or static data member of a class.  It may
22817 not be applied to block-scoped automatic or non-static data member.
22819 When the address-of operator is applied to a thread-local variable, it is
22820 evaluated at run time and returns the address of the current thread's
22821 instance of that variable.  An address so obtained may be used by any
22822 thread.  When a thread terminates, any pointers to thread-local variables
22823 in that thread become invalid.
22825 No static initialization may refer to the address of a thread-local variable.
22827 In C++, if an initializer is present for a thread-local variable, it must
22828 be a @var{constant-expression}, as defined in 5.19.2 of the ANSI/ISO C++
22829 standard.
22831 See @uref{https://www.akkadia.org/drepper/tls.pdf,
22832 ELF Handling For Thread-Local Storage} for a detailed explanation of
22833 the four thread-local storage addressing models, and how the runtime
22834 is expected to function.
22836 @menu
22837 * C99 Thread-Local Edits::
22838 * C++98 Thread-Local Edits::
22839 @end menu
22841 @node C99 Thread-Local Edits
22842 @subsection ISO/IEC 9899:1999 Edits for Thread-Local Storage
22844 The following are a set of changes to ISO/IEC 9899:1999 (aka C99)
22845 that document the exact semantics of the language extension.
22847 @itemize @bullet
22848 @item
22849 @cite{5.1.2  Execution environments}
22851 Add new text after paragraph 1
22853 @quotation
22854 Within either execution environment, a @dfn{thread} is a flow of
22855 control within a program.  It is implementation defined whether
22856 or not there may be more than one thread associated with a program.
22857 It is implementation defined how threads beyond the first are
22858 created, the name and type of the function called at thread
22859 startup, and how threads may be terminated.  However, objects
22860 with thread storage duration shall be initialized before thread
22861 startup.
22862 @end quotation
22864 @item
22865 @cite{6.2.4  Storage durations of objects}
22867 Add new text before paragraph 3
22869 @quotation
22870 An object whose identifier is declared with the storage-class
22871 specifier @w{@code{__thread}} has @dfn{thread storage duration}.
22872 Its lifetime is the entire execution of the thread, and its
22873 stored value is initialized only once, prior to thread startup.
22874 @end quotation
22876 @item
22877 @cite{6.4.1  Keywords}
22879 Add @code{__thread}.
22881 @item
22882 @cite{6.7.1  Storage-class specifiers}
22884 Add @code{__thread} to the list of storage class specifiers in
22885 paragraph 1.
22887 Change paragraph 2 to
22889 @quotation
22890 With the exception of @code{__thread}, at most one storage-class
22891 specifier may be given [@dots{}].  The @code{__thread} specifier may
22892 be used alone, or immediately following @code{extern} or
22893 @code{static}.
22894 @end quotation
22896 Add new text after paragraph 6
22898 @quotation
22899 The declaration of an identifier for a variable that has
22900 block scope that specifies @code{__thread} shall also
22901 specify either @code{extern} or @code{static}.
22903 The @code{__thread} specifier shall be used only with
22904 variables.
22905 @end quotation
22906 @end itemize
22908 @node C++98 Thread-Local Edits
22909 @subsection ISO/IEC 14882:1998 Edits for Thread-Local Storage
22911 The following are a set of changes to ISO/IEC 14882:1998 (aka C++98)
22912 that document the exact semantics of the language extension.
22914 @itemize @bullet
22915 @item
22916 @b{[intro.execution]}
22918 New text after paragraph 4
22920 @quotation
22921 A @dfn{thread} is a flow of control within the abstract machine.
22922 It is implementation defined whether or not there may be more than
22923 one thread.
22924 @end quotation
22926 New text after paragraph 7
22928 @quotation
22929 It is unspecified whether additional action must be taken to
22930 ensure when and whether side effects are visible to other threads.
22931 @end quotation
22933 @item
22934 @b{[lex.key]}
22936 Add @code{__thread}.
22938 @item
22939 @b{[basic.start.main]}
22941 Add after paragraph 5
22943 @quotation
22944 The thread that begins execution at the @code{main} function is called
22945 the @dfn{main thread}.  It is implementation defined how functions
22946 beginning threads other than the main thread are designated or typed.
22947 A function so designated, as well as the @code{main} function, is called
22948 a @dfn{thread startup function}.  It is implementation defined what
22949 happens if a thread startup function returns.  It is implementation
22950 defined what happens to other threads when any thread calls @code{exit}.
22951 @end quotation
22953 @item
22954 @b{[basic.start.init]}
22956 Add after paragraph 4
22958 @quotation
22959 The storage for an object of thread storage duration shall be
22960 statically initialized before the first statement of the thread startup
22961 function.  An object of thread storage duration shall not require
22962 dynamic initialization.
22963 @end quotation
22965 @item
22966 @b{[basic.start.term]}
22968 Add after paragraph 3
22970 @quotation
22971 The type of an object with thread storage duration shall not have a
22972 non-trivial destructor, nor shall it be an array type whose elements
22973 (directly or indirectly) have non-trivial destructors.
22974 @end quotation
22976 @item
22977 @b{[basic.stc]}
22979 Add ``thread storage duration'' to the list in paragraph 1.
22981 Change paragraph 2
22983 @quotation
22984 Thread, static, and automatic storage durations are associated with
22985 objects introduced by declarations [@dots{}].
22986 @end quotation
22988 Add @code{__thread} to the list of specifiers in paragraph 3.
22990 @item
22991 @b{[basic.stc.thread]}
22993 New section before @b{[basic.stc.static]}
22995 @quotation
22996 The keyword @code{__thread} applied to a non-local object gives the
22997 object thread storage duration.
22999 A local variable or class data member declared both @code{static}
23000 and @code{__thread} gives the variable or member thread storage
23001 duration.
23002 @end quotation
23004 @item
23005 @b{[basic.stc.static]}
23007 Change paragraph 1
23009 @quotation
23010 All objects that have neither thread storage duration, dynamic
23011 storage duration nor are local [@dots{}].
23012 @end quotation
23014 @item
23015 @b{[dcl.stc]}
23017 Add @code{__thread} to the list in paragraph 1.
23019 Change paragraph 1
23021 @quotation
23022 With the exception of @code{__thread}, at most one
23023 @var{storage-class-specifier} shall appear in a given
23024 @var{decl-specifier-seq}.  The @code{__thread} specifier may
23025 be used alone, or immediately following the @code{extern} or
23026 @code{static} specifiers.  [@dots{}]
23027 @end quotation
23029 Add after paragraph 5
23031 @quotation
23032 The @code{__thread} specifier can be applied only to the names of objects
23033 and to anonymous unions.
23034 @end quotation
23036 @item
23037 @b{[class.mem]}
23039 Add after paragraph 6
23041 @quotation
23042 Non-@code{static} members shall not be @code{__thread}.
23043 @end quotation
23044 @end itemize
23046 @node Binary constants
23047 @section Binary Constants using the @samp{0b} Prefix
23048 @cindex Binary constants using the @samp{0b} prefix
23050 Integer constants can be written as binary constants, consisting of a
23051 sequence of @samp{0} and @samp{1} digits, prefixed by @samp{0b} or
23052 @samp{0B}.  This is particularly useful in environments that operate a
23053 lot on the bit level (like microcontrollers).
23055 The following statements are identical:
23057 @smallexample
23058 i =       42;
23059 i =     0x2a;
23060 i =      052;
23061 i = 0b101010;
23062 @end smallexample
23064 The type of these constants follows the same rules as for octal or
23065 hexadecimal integer constants, so suffixes like @samp{L} or @samp{UL}
23066 can be applied.
23068 @node C++ Extensions
23069 @chapter Extensions to the C++ Language
23070 @cindex extensions, C++ language
23071 @cindex C++ language extensions
23073 The GNU compiler provides these extensions to the C++ language (and you
23074 can also use most of the C language extensions in your C++ programs).  If you
23075 want to write code that checks whether these features are available, you can
23076 test for the GNU compiler the same way as for C programs: check for a
23077 predefined macro @code{__GNUC__}.  You can also use @code{__GNUG__} to
23078 test specifically for GNU C++ (@pxref{Common Predefined Macros,,
23079 Predefined Macros,cpp,The GNU C Preprocessor}).
23081 @menu
23082 * C++ Volatiles::       What constitutes an access to a volatile object.
23083 * Restricted Pointers:: C99 restricted pointers and references.
23084 * Vague Linkage::       Where G++ puts inlines, vtables and such.
23085 * C++ Interface::       You can use a single C++ header file for both
23086                         declarations and definitions.
23087 * Template Instantiation:: Methods for ensuring that exactly one copy of
23088                         each needed template instantiation is emitted.
23089 * Bound member functions:: You can extract a function pointer to the
23090                         method denoted by a @samp{->*} or @samp{.*} expression.
23091 * C++ Attributes::      Variable, function, and type attributes for C++ only.
23092 * Function Multiversioning::   Declaring multiple function versions.
23093 * Type Traits::         Compiler support for type traits.
23094 * C++ Concepts::        Improved support for generic programming.
23095 * Deprecated Features:: Things will disappear from G++.
23096 * Backwards Compatibility:: Compatibilities with earlier definitions of C++.
23097 @end menu
23099 @node C++ Volatiles
23100 @section When is a Volatile C++ Object Accessed?
23101 @cindex accessing volatiles
23102 @cindex volatile read
23103 @cindex volatile write
23104 @cindex volatile access
23106 The C++ standard differs from the C standard in its treatment of
23107 volatile objects.  It fails to specify what constitutes a volatile
23108 access, except to say that C++ should behave in a similar manner to C
23109 with respect to volatiles, where possible.  However, the different
23110 lvalueness of expressions between C and C++ complicate the behavior.
23111 G++ behaves the same as GCC for volatile access, @xref{C
23112 Extensions,,Volatiles}, for a description of GCC's behavior.
23114 The C and C++ language specifications differ when an object is
23115 accessed in a void context:
23117 @smallexample
23118 volatile int *src = @var{somevalue};
23119 *src;
23120 @end smallexample
23122 The C++ standard specifies that such expressions do not undergo lvalue
23123 to rvalue conversion, and that the type of the dereferenced object may
23124 be incomplete.  The C++ standard does not specify explicitly that it
23125 is lvalue to rvalue conversion that is responsible for causing an
23126 access.  There is reason to believe that it is, because otherwise
23127 certain simple expressions become undefined.  However, because it
23128 would surprise most programmers, G++ treats dereferencing a pointer to
23129 volatile object of complete type as GCC would do for an equivalent
23130 type in C@.  When the object has incomplete type, G++ issues a
23131 warning; if you wish to force an error, you must force a conversion to
23132 rvalue with, for instance, a static cast.
23134 When using a reference to volatile, G++ does not treat equivalent
23135 expressions as accesses to volatiles, but instead issues a warning that
23136 no volatile is accessed.  The rationale for this is that otherwise it
23137 becomes difficult to determine where volatile access occur, and not
23138 possible to ignore the return value from functions returning volatile
23139 references.  Again, if you wish to force a read, cast the reference to
23140 an rvalue.
23142 G++ implements the same behavior as GCC does when assigning to a
23143 volatile object---there is no reread of the assigned-to object, the
23144 assigned rvalue is reused.  Note that in C++ assignment expressions
23145 are lvalues, and if used as an lvalue, the volatile object is
23146 referred to.  For instance, @var{vref} refers to @var{vobj}, as
23147 expected, in the following example:
23149 @smallexample
23150 volatile int vobj;
23151 volatile int &vref = vobj = @var{something};
23152 @end smallexample
23154 @node Restricted Pointers
23155 @section Restricting Pointer Aliasing
23156 @cindex restricted pointers
23157 @cindex restricted references
23158 @cindex restricted this pointer
23160 As with the C front end, G++ understands the C99 feature of restricted pointers,
23161 specified with the @code{__restrict__}, or @code{__restrict} type
23162 qualifier.  Because you cannot compile C++ by specifying the @option{-std=c99}
23163 language flag, @code{restrict} is not a keyword in C++.
23165 In addition to allowing restricted pointers, you can specify restricted
23166 references, which indicate that the reference is not aliased in the local
23167 context.
23169 @smallexample
23170 void fn (int *__restrict__ rptr, int &__restrict__ rref)
23172   /* @r{@dots{}} */
23174 @end smallexample
23176 @noindent
23177 In the body of @code{fn}, @var{rptr} points to an unaliased integer and
23178 @var{rref} refers to a (different) unaliased integer.
23180 You may also specify whether a member function's @var{this} pointer is
23181 unaliased by using @code{__restrict__} as a member function qualifier.
23183 @smallexample
23184 void T::fn () __restrict__
23186   /* @r{@dots{}} */
23188 @end smallexample
23190 @noindent
23191 Within the body of @code{T::fn}, @var{this} has the effective
23192 definition @code{T *__restrict__ const this}.  Notice that the
23193 interpretation of a @code{__restrict__} member function qualifier is
23194 different to that of @code{const} or @code{volatile} qualifier, in that it
23195 is applied to the pointer rather than the object.  This is consistent with
23196 other compilers that implement restricted pointers.
23198 As with all outermost parameter qualifiers, @code{__restrict__} is
23199 ignored in function definition matching.  This means you only need to
23200 specify @code{__restrict__} in a function definition, rather than
23201 in a function prototype as well.
23203 @node Vague Linkage
23204 @section Vague Linkage
23205 @cindex vague linkage
23207 There are several constructs in C++ that require space in the object
23208 file but are not clearly tied to a single translation unit.  We say that
23209 these constructs have ``vague linkage''.  Typically such constructs are
23210 emitted wherever they are needed, though sometimes we can be more
23211 clever.
23213 @table @asis
23214 @item Inline Functions
23215 Inline functions are typically defined in a header file which can be
23216 included in many different compilations.  Hopefully they can usually be
23217 inlined, but sometimes an out-of-line copy is necessary, if the address
23218 of the function is taken or if inlining fails.  In general, we emit an
23219 out-of-line copy in all translation units where one is needed.  As an
23220 exception, we only emit inline virtual functions with the vtable, since
23221 it always requires a copy.
23223 Local static variables and string constants used in an inline function
23224 are also considered to have vague linkage, since they must be shared
23225 between all inlined and out-of-line instances of the function.
23227 @item VTables
23228 @cindex vtable
23229 C++ virtual functions are implemented in most compilers using a lookup
23230 table, known as a vtable.  The vtable contains pointers to the virtual
23231 functions provided by a class, and each object of the class contains a
23232 pointer to its vtable (or vtables, in some multiple-inheritance
23233 situations).  If the class declares any non-inline, non-pure virtual
23234 functions, the first one is chosen as the ``key method'' for the class,
23235 and the vtable is only emitted in the translation unit where the key
23236 method is defined.
23238 @emph{Note:} If the chosen key method is later defined as inline, the
23239 vtable is still emitted in every translation unit that defines it.
23240 Make sure that any inline virtuals are declared inline in the class
23241 body, even if they are not defined there.
23243 @item @code{type_info} objects
23244 @cindex @code{type_info}
23245 @cindex RTTI
23246 C++ requires information about types to be written out in order to
23247 implement @samp{dynamic_cast}, @samp{typeid} and exception handling.
23248 For polymorphic classes (classes with virtual functions), the @samp{type_info}
23249 object is written out along with the vtable so that @samp{dynamic_cast}
23250 can determine the dynamic type of a class object at run time.  For all
23251 other types, we write out the @samp{type_info} object when it is used: when
23252 applying @samp{typeid} to an expression, throwing an object, or
23253 referring to a type in a catch clause or exception specification.
23255 @item Template Instantiations
23256 Most everything in this section also applies to template instantiations,
23257 but there are other options as well.
23258 @xref{Template Instantiation,,Where's the Template?}.
23260 @end table
23262 When used with GNU ld version 2.8 or later on an ELF system such as
23263 GNU/Linux or Solaris 2, or on Microsoft Windows, duplicate copies of
23264 these constructs will be discarded at link time.  This is known as
23265 COMDAT support.
23267 On targets that don't support COMDAT, but do support weak symbols, GCC
23268 uses them.  This way one copy overrides all the others, but
23269 the unused copies still take up space in the executable.
23271 For targets that do not support either COMDAT or weak symbols,
23272 most entities with vague linkage are emitted as local symbols to
23273 avoid duplicate definition errors from the linker.  This does not happen
23274 for local statics in inlines, however, as having multiple copies
23275 almost certainly breaks things.
23277 @xref{C++ Interface,,Declarations and Definitions in One Header}, for
23278 another way to control placement of these constructs.
23280 @node C++ Interface
23281 @section C++ Interface and Implementation Pragmas
23283 @cindex interface and implementation headers, C++
23284 @cindex C++ interface and implementation headers
23285 @cindex pragmas, interface and implementation
23287 @code{#pragma interface} and @code{#pragma implementation} provide the
23288 user with a way of explicitly directing the compiler to emit entities
23289 with vague linkage (and debugging information) in a particular
23290 translation unit.
23292 @emph{Note:} These @code{#pragma}s have been superceded as of GCC 2.7.2
23293 by COMDAT support and the ``key method'' heuristic
23294 mentioned in @ref{Vague Linkage}.  Using them can actually cause your
23295 program to grow due to unnecessary out-of-line copies of inline
23296 functions.
23298 @table @code
23299 @item #pragma interface
23300 @itemx #pragma interface "@var{subdir}/@var{objects}.h"
23301 @kindex #pragma interface
23302 Use this directive in @emph{header files} that define object classes, to save
23303 space in most of the object files that use those classes.  Normally,
23304 local copies of certain information (backup copies of inline member
23305 functions, debugging information, and the internal tables that implement
23306 virtual functions) must be kept in each object file that includes class
23307 definitions.  You can use this pragma to avoid such duplication.  When a
23308 header file containing @samp{#pragma interface} is included in a
23309 compilation, this auxiliary information is not generated (unless
23310 the main input source file itself uses @samp{#pragma implementation}).
23311 Instead, the object files contain references to be resolved at link
23312 time.
23314 The second form of this directive is useful for the case where you have
23315 multiple headers with the same name in different directories.  If you
23316 use this form, you must specify the same string to @samp{#pragma
23317 implementation}.
23319 @item #pragma implementation
23320 @itemx #pragma implementation "@var{objects}.h"
23321 @kindex #pragma implementation
23322 Use this pragma in a @emph{main input file}, when you want full output from
23323 included header files to be generated (and made globally visible).  The
23324 included header file, in turn, should use @samp{#pragma interface}.
23325 Backup copies of inline member functions, debugging information, and the
23326 internal tables used to implement virtual functions are all generated in
23327 implementation files.
23329 @cindex implied @code{#pragma implementation}
23330 @cindex @code{#pragma implementation}, implied
23331 @cindex naming convention, implementation headers
23332 If you use @samp{#pragma implementation} with no argument, it applies to
23333 an include file with the same basename@footnote{A file's @dfn{basename}
23334 is the name stripped of all leading path information and of trailing
23335 suffixes, such as @samp{.h} or @samp{.C} or @samp{.cc}.} as your source
23336 file.  For example, in @file{allclass.cc}, giving just
23337 @samp{#pragma implementation}
23338 by itself is equivalent to @samp{#pragma implementation "allclass.h"}.
23340 Use the string argument if you want a single implementation file to
23341 include code from multiple header files.  (You must also use
23342 @samp{#include} to include the header file; @samp{#pragma
23343 implementation} only specifies how to use the file---it doesn't actually
23344 include it.)
23346 There is no way to split up the contents of a single header file into
23347 multiple implementation files.
23348 @end table
23350 @cindex inlining and C++ pragmas
23351 @cindex C++ pragmas, effect on inlining
23352 @cindex pragmas in C++, effect on inlining
23353 @samp{#pragma implementation} and @samp{#pragma interface} also have an
23354 effect on function inlining.
23356 If you define a class in a header file marked with @samp{#pragma
23357 interface}, the effect on an inline function defined in that class is
23358 similar to an explicit @code{extern} declaration---the compiler emits
23359 no code at all to define an independent version of the function.  Its
23360 definition is used only for inlining with its callers.
23362 @opindex fno-implement-inlines
23363 Conversely, when you include the same header file in a main source file
23364 that declares it as @samp{#pragma implementation}, the compiler emits
23365 code for the function itself; this defines a version of the function
23366 that can be found via pointers (or by callers compiled without
23367 inlining).  If all calls to the function can be inlined, you can avoid
23368 emitting the function by compiling with @option{-fno-implement-inlines}.
23369 If any calls are not inlined, you will get linker errors.
23371 @node Template Instantiation
23372 @section Where's the Template?
23373 @cindex template instantiation
23375 C++ templates were the first language feature to require more
23376 intelligence from the environment than was traditionally found on a UNIX
23377 system.  Somehow the compiler and linker have to make sure that each
23378 template instance occurs exactly once in the executable if it is needed,
23379 and not at all otherwise.  There are two basic approaches to this
23380 problem, which are referred to as the Borland model and the Cfront model.
23382 @table @asis
23383 @item Borland model
23384 Borland C++ solved the template instantiation problem by adding the code
23385 equivalent of common blocks to their linker; the compiler emits template
23386 instances in each translation unit that uses them, and the linker
23387 collapses them together.  The advantage of this model is that the linker
23388 only has to consider the object files themselves; there is no external
23389 complexity to worry about.  The disadvantage is that compilation time
23390 is increased because the template code is being compiled repeatedly.
23391 Code written for this model tends to include definitions of all
23392 templates in the header file, since they must be seen to be
23393 instantiated.
23395 @item Cfront model
23396 The AT&T C++ translator, Cfront, solved the template instantiation
23397 problem by creating the notion of a template repository, an
23398 automatically maintained place where template instances are stored.  A
23399 more modern version of the repository works as follows: As individual
23400 object files are built, the compiler places any template definitions and
23401 instantiations encountered in the repository.  At link time, the link
23402 wrapper adds in the objects in the repository and compiles any needed
23403 instances that were not previously emitted.  The advantages of this
23404 model are more optimal compilation speed and the ability to use the
23405 system linker; to implement the Borland model a compiler vendor also
23406 needs to replace the linker.  The disadvantages are vastly increased
23407 complexity, and thus potential for error; for some code this can be
23408 just as transparent, but in practice it can been very difficult to build
23409 multiple programs in one directory and one program in multiple
23410 directories.  Code written for this model tends to separate definitions
23411 of non-inline member templates into a separate file, which should be
23412 compiled separately.
23413 @end table
23415 G++ implements the Borland model on targets where the linker supports it,
23416 including ELF targets (such as GNU/Linux), Mac OS X and Microsoft Windows.
23417 Otherwise G++ implements neither automatic model.
23419 You have the following options for dealing with template instantiations:
23421 @enumerate
23422 @item
23423 Do nothing.  Code written for the Borland model works fine, but
23424 each translation unit contains instances of each of the templates it
23425 uses.  The duplicate instances will be discarded by the linker, but in
23426 a large program, this can lead to an unacceptable amount of code
23427 duplication in object files or shared libraries.
23429 Duplicate instances of a template can be avoided by defining an explicit
23430 instantiation in one object file, and preventing the compiler from doing
23431 implicit instantiations in any other object files by using an explicit
23432 instantiation declaration, using the @code{extern template} syntax:
23434 @smallexample
23435 extern template int max (int, int);
23436 @end smallexample
23438 This syntax is defined in the C++ 2011 standard, but has been supported by
23439 G++ and other compilers since well before 2011.
23441 Explicit instantiations can be used for the largest or most frequently
23442 duplicated instances, without having to know exactly which other instances
23443 are used in the rest of the program.  You can scatter the explicit
23444 instantiations throughout your program, perhaps putting them in the
23445 translation units where the instances are used or the translation units
23446 that define the templates themselves; you can put all of the explicit
23447 instantiations you need into one big file; or you can create small files
23448 like
23450 @smallexample
23451 #include "Foo.h"
23452 #include "Foo.cc"
23454 template class Foo<int>;
23455 template ostream& operator <<
23456                 (ostream&, const Foo<int>&);
23457 @end smallexample
23459 @noindent
23460 for each of the instances you need, and create a template instantiation
23461 library from those.
23463 This is the simplest option, but also offers flexibility and
23464 fine-grained control when necessary. It is also the most portable
23465 alternative and programs using this approach will work with most modern
23466 compilers.
23468 @item
23469 @opindex frepo
23470 Compile your template-using code with @option{-frepo}.  The compiler
23471 generates files with the extension @samp{.rpo} listing all of the
23472 template instantiations used in the corresponding object files that
23473 could be instantiated there; the link wrapper, @samp{collect2},
23474 then updates the @samp{.rpo} files to tell the compiler where to place
23475 those instantiations and rebuild any affected object files.  The
23476 link-time overhead is negligible after the first pass, as the compiler
23477 continues to place the instantiations in the same files.
23479 This can be a suitable option for application code written for the Borland
23480 model, as it usually just works.  Code written for the Cfront model 
23481 needs to be modified so that the template definitions are available at
23482 one or more points of instantiation; usually this is as simple as adding
23483 @code{#include <tmethods.cc>} to the end of each template header.
23485 For library code, if you want the library to provide all of the template
23486 instantiations it needs, just try to link all of its object files
23487 together; the link will fail, but cause the instantiations to be
23488 generated as a side effect.  Be warned, however, that this may cause
23489 conflicts if multiple libraries try to provide the same instantiations.
23490 For greater control, use explicit instantiation as described in the next
23491 option.
23493 @item
23494 @opindex fno-implicit-templates
23495 Compile your code with @option{-fno-implicit-templates} to disable the
23496 implicit generation of template instances, and explicitly instantiate
23497 all the ones you use.  This approach requires more knowledge of exactly
23498 which instances you need than do the others, but it's less
23499 mysterious and allows greater control if you want to ensure that only
23500 the intended instances are used.
23502 If you are using Cfront-model code, you can probably get away with not
23503 using @option{-fno-implicit-templates} when compiling files that don't
23504 @samp{#include} the member template definitions.
23506 If you use one big file to do the instantiations, you may want to
23507 compile it without @option{-fno-implicit-templates} so you get all of the
23508 instances required by your explicit instantiations (but not by any
23509 other files) without having to specify them as well.
23511 In addition to forward declaration of explicit instantiations
23512 (with @code{extern}), G++ has extended the template instantiation
23513 syntax to support instantiation of the compiler support data for a
23514 template class (i.e.@: the vtable) without instantiating any of its
23515 members (with @code{inline}), and instantiation of only the static data
23516 members of a template class, without the support data or member
23517 functions (with @code{static}):
23519 @smallexample
23520 inline template class Foo<int>;
23521 static template class Foo<int>;
23522 @end smallexample
23523 @end enumerate
23525 @node Bound member functions
23526 @section Extracting the Function Pointer from a Bound Pointer to Member Function
23527 @cindex pmf
23528 @cindex pointer to member function
23529 @cindex bound pointer to member function
23531 In C++, pointer to member functions (PMFs) are implemented using a wide
23532 pointer of sorts to handle all the possible call mechanisms; the PMF
23533 needs to store information about how to adjust the @samp{this} pointer,
23534 and if the function pointed to is virtual, where to find the vtable, and
23535 where in the vtable to look for the member function.  If you are using
23536 PMFs in an inner loop, you should really reconsider that decision.  If
23537 that is not an option, you can extract the pointer to the function that
23538 would be called for a given object/PMF pair and call it directly inside
23539 the inner loop, to save a bit of time.
23541 Note that you still pay the penalty for the call through a
23542 function pointer; on most modern architectures, such a call defeats the
23543 branch prediction features of the CPU@.  This is also true of normal
23544 virtual function calls.
23546 The syntax for this extension is
23548 @smallexample
23549 extern A a;
23550 extern int (A::*fp)();
23551 typedef int (*fptr)(A *);
23553 fptr p = (fptr)(a.*fp);
23554 @end smallexample
23556 For PMF constants (i.e.@: expressions of the form @samp{&Klasse::Member}),
23557 no object is needed to obtain the address of the function.  They can be
23558 converted to function pointers directly:
23560 @smallexample
23561 fptr p1 = (fptr)(&A::foo);
23562 @end smallexample
23564 @opindex Wno-pmf-conversions
23565 You must specify @option{-Wno-pmf-conversions} to use this extension.
23567 @node C++ Attributes
23568 @section C++-Specific Variable, Function, and Type Attributes
23570 Some attributes only make sense for C++ programs.
23572 @table @code
23573 @item abi_tag ("@var{tag}", ...)
23574 @cindex @code{abi_tag} function attribute
23575 @cindex @code{abi_tag} variable attribute
23576 @cindex @code{abi_tag} type attribute
23577 The @code{abi_tag} attribute can be applied to a function, variable, or class
23578 declaration.  It modifies the mangled name of the entity to
23579 incorporate the tag name, in order to distinguish the function or
23580 class from an earlier version with a different ABI; perhaps the class
23581 has changed size, or the function has a different return type that is
23582 not encoded in the mangled name.
23584 The attribute can also be applied to an inline namespace, but does not
23585 affect the mangled name of the namespace; in this case it is only used
23586 for @option{-Wabi-tag} warnings and automatic tagging of functions and
23587 variables.  Tagging inline namespaces is generally preferable to
23588 tagging individual declarations, but the latter is sometimes
23589 necessary, such as when only certain members of a class need to be
23590 tagged.
23592 The argument can be a list of strings of arbitrary length.  The
23593 strings are sorted on output, so the order of the list is
23594 unimportant.
23596 A redeclaration of an entity must not add new ABI tags,
23597 since doing so would change the mangled name.
23599 The ABI tags apply to a name, so all instantiations and
23600 specializations of a template have the same tags.  The attribute will
23601 be ignored if applied to an explicit specialization or instantiation.
23603 The @option{-Wabi-tag} flag enables a warning about a class which does
23604 not have all the ABI tags used by its subobjects and virtual functions; for users with code
23605 that needs to coexist with an earlier ABI, using this option can help
23606 to find all affected types that need to be tagged.
23608 When a type involving an ABI tag is used as the type of a variable or
23609 return type of a function where that tag is not already present in the
23610 signature of the function, the tag is automatically applied to the
23611 variable or function.  @option{-Wabi-tag} also warns about this
23612 situation; this warning can be avoided by explicitly tagging the
23613 variable or function or moving it into a tagged inline namespace.
23615 @item init_priority (@var{priority})
23616 @cindex @code{init_priority} variable attribute
23618 In Standard C++, objects defined at namespace scope are guaranteed to be
23619 initialized in an order in strict accordance with that of their definitions
23620 @emph{in a given translation unit}.  No guarantee is made for initializations
23621 across translation units.  However, GNU C++ allows users to control the
23622 order of initialization of objects defined at namespace scope with the
23623 @code{init_priority} attribute by specifying a relative @var{priority},
23624 a constant integral expression currently bounded between 101 and 65535
23625 inclusive.  Lower numbers indicate a higher priority.
23627 In the following example, @code{A} would normally be created before
23628 @code{B}, but the @code{init_priority} attribute reverses that order:
23630 @smallexample
23631 Some_Class  A  __attribute__ ((init_priority (2000)));
23632 Some_Class  B  __attribute__ ((init_priority (543)));
23633 @end smallexample
23635 @noindent
23636 Note that the particular values of @var{priority} do not matter; only their
23637 relative ordering.
23639 @item warn_unused
23640 @cindex @code{warn_unused} type attribute
23642 For C++ types with non-trivial constructors and/or destructors it is
23643 impossible for the compiler to determine whether a variable of this
23644 type is truly unused if it is not referenced. This type attribute
23645 informs the compiler that variables of this type should be warned
23646 about if they appear to be unused, just like variables of fundamental
23647 types.
23649 This attribute is appropriate for types which just represent a value,
23650 such as @code{std::string}; it is not appropriate for types which
23651 control a resource, such as @code{std::lock_guard}.
23653 This attribute is also accepted in C, but it is unnecessary because C
23654 does not have constructors or destructors.
23656 @end table
23658 @node Function Multiversioning
23659 @section Function Multiversioning
23660 @cindex function versions
23662 With the GNU C++ front end, for x86 targets, you may specify multiple
23663 versions of a function, where each function is specialized for a
23664 specific target feature.  At runtime, the appropriate version of the
23665 function is automatically executed depending on the characteristics of
23666 the execution platform.  Here is an example.
23668 @smallexample
23669 __attribute__ ((target ("default")))
23670 int foo ()
23672   // The default version of foo.
23673   return 0;
23676 __attribute__ ((target ("sse4.2")))
23677 int foo ()
23679   // foo version for SSE4.2
23680   return 1;
23683 __attribute__ ((target ("arch=atom")))
23684 int foo ()
23686   // foo version for the Intel ATOM processor
23687   return 2;
23690 __attribute__ ((target ("arch=amdfam10")))
23691 int foo ()
23693   // foo version for the AMD Family 0x10 processors.
23694   return 3;
23697 int main ()
23699   int (*p)() = &foo;
23700   assert ((*p) () == foo ());
23701   return 0;
23703 @end smallexample
23705 In the above example, four versions of function foo are created. The
23706 first version of foo with the target attribute "default" is the default
23707 version.  This version gets executed when no other target specific
23708 version qualifies for execution on a particular platform. A new version
23709 of foo is created by using the same function signature but with a
23710 different target string.  Function foo is called or a pointer to it is
23711 taken just like a regular function.  GCC takes care of doing the
23712 dispatching to call the right version at runtime.  Refer to the
23713 @uref{http://gcc.gnu.org/wiki/FunctionMultiVersioning, GCC wiki on
23714 Function Multiversioning} for more details.
23716 @node Type Traits
23717 @section Type Traits
23719 The C++ front end implements syntactic extensions that allow
23720 compile-time determination of 
23721 various characteristics of a type (or of a
23722 pair of types).
23724 @table @code
23725 @item __has_nothrow_assign (type)
23726 If @code{type} is const qualified or is a reference type then the trait is
23727 false.  Otherwise if @code{__has_trivial_assign (type)} is true then the trait
23728 is true, else if @code{type} is a cv class or union type with copy assignment
23729 operators that are known not to throw an exception then the trait is true,
23730 else it is false.  Requires: @code{type} shall be a complete type,
23731 (possibly cv-qualified) @code{void}, or an array of unknown bound.
23733 @item __has_nothrow_copy (type)
23734 If @code{__has_trivial_copy (type)} is true then the trait is true, else if
23735 @code{type} is a cv class or union type with copy constructors that
23736 are known not to throw an exception then the trait is true, else it is false.
23737 Requires: @code{type} shall be a complete type, (possibly cv-qualified)
23738 @code{void}, or an array of unknown bound.
23740 @item __has_nothrow_constructor (type)
23741 If @code{__has_trivial_constructor (type)} is true then the trait is
23742 true, else if @code{type} is a cv class or union type (or array
23743 thereof) with a default constructor that is known not to throw an
23744 exception then the trait is true, else it is false.  Requires:
23745 @code{type} shall be a complete type, (possibly cv-qualified)
23746 @code{void}, or an array of unknown bound.
23748 @item __has_trivial_assign (type)
23749 If @code{type} is const qualified or is a reference type then the trait is
23750 false.  Otherwise if @code{__is_pod (type)} is true then the trait is
23751 true, else if @code{type} is a cv class or union type with a trivial
23752 copy assignment ([class.copy]) then the trait is true, else it is
23753 false.  Requires: @code{type} shall be a complete type, (possibly
23754 cv-qualified) @code{void}, or an array of unknown bound.
23756 @item __has_trivial_copy (type)
23757 If @code{__is_pod (type)} is true or @code{type} is a reference type
23758 then the trait is true, else if @code{type} is a cv class or union type
23759 with a trivial copy constructor ([class.copy]) then the trait
23760 is true, else it is false.  Requires: @code{type} shall be a complete
23761 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
23763 @item __has_trivial_constructor (type)
23764 If @code{__is_pod (type)} is true then the trait is true, else if
23765 @code{type} is a cv class or union type (or array thereof) with a
23766 trivial default constructor ([class.ctor]) then the trait is true,
23767 else it is false.  Requires: @code{type} shall be a complete
23768 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
23770 @item __has_trivial_destructor (type)
23771 If @code{__is_pod (type)} is true or @code{type} is a reference type then
23772 the trait is true, else if @code{type} is a cv class or union type (or
23773 array thereof) with a trivial destructor ([class.dtor]) then the trait
23774 is true, else it is false.  Requires: @code{type} shall be a complete
23775 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
23777 @item __has_virtual_destructor (type)
23778 If @code{type} is a class type with a virtual destructor
23779 ([class.dtor]) then the trait is true, else it is false.  Requires:
23780 @code{type} shall be a complete type, (possibly cv-qualified)
23781 @code{void}, or an array of unknown bound.
23783 @item __is_abstract (type)
23784 If @code{type} is an abstract class ([class.abstract]) then the trait
23785 is true, else it is false.  Requires: @code{type} shall be a complete
23786 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
23788 @item __is_base_of (base_type, derived_type)
23789 If @code{base_type} is a base class of @code{derived_type}
23790 ([class.derived]) then the trait is true, otherwise it is false.
23791 Top-level cv qualifications of @code{base_type} and
23792 @code{derived_type} are ignored.  For the purposes of this trait, a
23793 class type is considered is own base.  Requires: if @code{__is_class
23794 (base_type)} and @code{__is_class (derived_type)} are true and
23795 @code{base_type} and @code{derived_type} are not the same type
23796 (disregarding cv-qualifiers), @code{derived_type} shall be a complete
23797 type.  A diagnostic is produced if this requirement is not met.
23799 @item __is_class (type)
23800 If @code{type} is a cv class type, and not a union type
23801 ([basic.compound]) the trait is true, else it is false.
23803 @item __is_empty (type)
23804 If @code{__is_class (type)} is false then the trait is false.
23805 Otherwise @code{type} is considered empty if and only if: @code{type}
23806 has no non-static data members, or all non-static data members, if
23807 any, are bit-fields of length 0, and @code{type} has no virtual
23808 members, and @code{type} has no virtual base classes, and @code{type}
23809 has no base classes @code{base_type} for which
23810 @code{__is_empty (base_type)} is false.  Requires: @code{type} shall
23811 be a complete type, (possibly cv-qualified) @code{void}, or an array
23812 of unknown bound.
23814 @item __is_enum (type)
23815 If @code{type} is a cv enumeration type ([basic.compound]) the trait is
23816 true, else it is false.
23818 @item __is_literal_type (type)
23819 If @code{type} is a literal type ([basic.types]) the trait is
23820 true, else it is false.  Requires: @code{type} shall be a complete type,
23821 (possibly cv-qualified) @code{void}, or an array of unknown bound.
23823 @item __is_pod (type)
23824 If @code{type} is a cv POD type ([basic.types]) then the trait is true,
23825 else it is false.  Requires: @code{type} shall be a complete type,
23826 (possibly cv-qualified) @code{void}, or an array of unknown bound.
23828 @item __is_polymorphic (type)
23829 If @code{type} is a polymorphic class ([class.virtual]) then the trait
23830 is true, else it is false.  Requires: @code{type} shall be a complete
23831 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
23833 @item __is_standard_layout (type)
23834 If @code{type} is a standard-layout type ([basic.types]) the trait is
23835 true, else it is false.  Requires: @code{type} shall be a complete
23836 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
23838 @item __is_trivial (type)
23839 If @code{type} is a trivial type ([basic.types]) the trait is
23840 true, else it is false.  Requires: @code{type} shall be a complete
23841 type, (possibly cv-qualified) @code{void}, or an array of unknown bound.
23843 @item __is_union (type)
23844 If @code{type} is a cv union type ([basic.compound]) the trait is
23845 true, else it is false.
23847 @item __underlying_type (type)
23848 The underlying type of @code{type}.  Requires: @code{type} shall be
23849 an enumeration type ([dcl.enum]).
23851 @item __integer_pack (length)
23852 When used as the pattern of a pack expansion within a template
23853 definition, expands to a template argument pack containing integers
23854 from @code{0} to @code{length-1}.  This is provided for efficient
23855 implementation of @code{std::make_integer_sequence}.
23857 @end table
23860 @node C++ Concepts
23861 @section C++ Concepts
23863 C++ concepts provide much-improved support for generic programming. In
23864 particular, they allow the specification of constraints on template arguments.
23865 The constraints are used to extend the usual overloading and partial
23866 specialization capabilities of the language, allowing generic data structures
23867 and algorithms to be ``refined'' based on their properties rather than their
23868 type names.
23870 The following keywords are reserved for concepts.
23872 @table @code
23873 @item assumes
23874 States an expression as an assumption, and if possible, verifies that the
23875 assumption is valid. For example, @code{assume(n > 0)}.
23877 @item axiom
23878 Introduces an axiom definition. Axioms introduce requirements on values.
23880 @item forall
23881 Introduces a universally quantified object in an axiom. For example,
23882 @code{forall (int n) n + 0 == n}).
23884 @item concept
23885 Introduces a concept definition. Concepts are sets of syntactic and semantic
23886 requirements on types and their values.
23888 @item requires
23889 Introduces constraints on template arguments or requirements for a member
23890 function of a class template.
23892 @end table
23894 The front end also exposes a number of internal mechanism that can be used
23895 to simplify the writing of type traits. Note that some of these traits are
23896 likely to be removed in the future.
23898 @table @code
23899 @item __is_same (type1, type2)
23900 A binary type trait: true whenever the type arguments are the same.
23902 @end table
23905 @node Deprecated Features
23906 @section Deprecated Features
23908 In the past, the GNU C++ compiler was extended to experiment with new
23909 features, at a time when the C++ language was still evolving.  Now that
23910 the C++ standard is complete, some of those features are superseded by
23911 superior alternatives.  Using the old features might cause a warning in
23912 some cases that the feature will be dropped in the future.  In other
23913 cases, the feature might be gone already.
23915 G++ allows a virtual function returning @samp{void *} to be overridden
23916 by one returning a different pointer type.  This extension to the
23917 covariant return type rules is now deprecated and will be removed from a
23918 future version.
23920 The use of default arguments in function pointers, function typedefs
23921 and other places where they are not permitted by the standard is
23922 deprecated and will be removed from a future version of G++.
23924 G++ allows floating-point literals to appear in integral constant expressions,
23925 e.g.@: @samp{ enum E @{ e = int(2.2 * 3.7) @} }
23926 This extension is deprecated and will be removed from a future version.
23928 G++ allows static data members of const floating-point type to be declared
23929 with an initializer in a class definition. The standard only allows
23930 initializers for static members of const integral types and const
23931 enumeration types so this extension has been deprecated and will be removed
23932 from a future version.
23934 G++ allows attributes to follow a parenthesized direct initializer,
23935 e.g.@: @samp{ int f (0) __attribute__ ((something)); } This extension
23936 has been ignored since G++ 3.3 and is deprecated.
23938 G++ allows anonymous structs and unions to have members that are not
23939 public non-static data members (i.e.@: fields).  These extensions are
23940 deprecated.
23942 @node Backwards Compatibility
23943 @section Backwards Compatibility
23944 @cindex Backwards Compatibility
23945 @cindex ARM [Annotated C++ Reference Manual]
23947 Now that there is a definitive ISO standard C++, G++ has a specification
23948 to adhere to.  The C++ language evolved over time, and features that
23949 used to be acceptable in previous drafts of the standard, such as the ARM
23950 [Annotated C++ Reference Manual], are no longer accepted.  In order to allow
23951 compilation of C++ written to such drafts, G++ contains some backwards
23952 compatibilities.  @emph{All such backwards compatibility features are
23953 liable to disappear in future versions of G++.} They should be considered
23954 deprecated.   @xref{Deprecated Features}.
23956 @table @code
23958 @item Implicit C language
23959 Old C system header files did not contain an @code{extern "C" @{@dots{}@}}
23960 scope to set the language.  On such systems, all header files are
23961 implicitly scoped inside a C language scope.  Also, an empty prototype
23962 @code{()} is treated as an unspecified number of arguments, rather
23963 than no arguments, as C++ demands.
23965 @end table
23967 @c  LocalWords:  emph deftypefn builtin ARCv2EM SIMD builtins msimd
23968 @c  LocalWords:  typedef v4si v8hi DMA dma vdiwr vdowr